Move plugins to this repo

This commit is contained in:
Gregory Schier
2024-06-27 21:44:45 -07:00
parent d1d08963fb
commit a63b485b95
35 changed files with 6931 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
export function pluginHookImport(ctx: any, contents: string) {
let parsed;
try {
parsed = JSON.parse(contents);
} catch (err) {
return undefined;
}
if (!isJSObject(parsed)) {
return undefined;
}
const isYaakExport = 'yaakSchema' in parsed;
if (!isYaakExport) {
return;
}
// Migrate v1 to v2 -- changes requests to httpRequests
if ('requests' in parsed.resources) {
parsed.resources.httpRequests = parsed.resources.requests;
delete parsed.resources['requests'];
}
return { resources: parsed.resources }; // Should already be in the correct format
}
export function isJSObject(obj: any) {
return Object.prototype.toString.call(obj) === '[object Object]';
}