diff --git a/package-lock.json b/package-lock.json index de4cca53..7dfa923f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "plugins/*" ], "dependencies": { - "@yaakapp/api": "^0.5.0" + "@yaakapp/api": "^0.5.1" }, "devDependencies": { "@types/node": "^22.7.4", @@ -999,9 +999,9 @@ } }, "node_modules/@yaakapp/api": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.5.0.tgz", - "integrity": "sha512-M0PPLGWQft+eQOOJ7ubwvRm3LTYXjAWQ8nniiqV3TkRcwa5++PteIH0OHV2L3Pei8cRQA8S25AD+RajyvFC8XQ==", + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.5.1.tgz", + "integrity": "sha512-0YFrrTJVjrnsSm9BTxSnz1pd1+Q52/CBV1QpTVtXPPqlSIwcvj7jMdwuDpSKy5G8xbaoVzTgBnW25RgKog/q7g==", "dependencies": { "@types/node": "^22.5.4" } @@ -1054,10 +1054,6 @@ "resolved": "plugins/importer-yaak", "link": true }, - "node_modules/@yaakapp/template-function-file": { - "resolved": "plugins/template-function-file", - "link": true - }, "node_modules/@yaakapp/template-function-fs": { "resolved": "plugins/template-function-fs", "link": true @@ -7196,7 +7192,8 @@ }, "plugins/template-function-file": { "name": "@yaakapp/template-function-file", - "version": "0.0.1" + "version": "0.0.1", + "extraneous": true }, "plugins/template-function-fs": { "name": "@yaakapp/template-function-fs", @@ -7225,6 +7222,11 @@ "devDependencies": { "@types/jsonpath": "^0.2.4" } + }, + "plugins/template-function-secure": { + "name": "@yaakapp/template-function-secure", + "version": "0.0.1", + "extraneous": true } } } diff --git a/package.json b/package.json index ef57489a..1e60d96c 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,6 @@ "workspaces-run": "^1.0.2" }, "dependencies": { - "@yaakapp/api": "^0.5.0" + "@yaakapp/api": "^0.5.1" } } diff --git a/plugins/importer-insomnia/src/index.ts b/plugins/importer-insomnia/src/index.ts index d4e04b0a..e589365a 100644 --- a/plugins/importer-insomnia/src/index.ts +++ b/plugins/importer-insomnia/src/index.ts @@ -101,7 +101,7 @@ function importEnvironment(e: any, workspaceId: string): ExportResources['enviro createdAt: e.created ? new Date(e.created).toISOString().replace('Z', '') : undefined, updatedAt: e.updated ? new Date(e.updated).toISOString().replace('Z', '') : undefined, workspaceId: convertId(workspaceId), - environmentId: e.parentId === workspaceId ? null : convertId(e.parentId), + base: e.parentId === workspaceId, model: 'environment', name: e.name, variables: Object.entries(e.data).map(([name, value]) => ({ diff --git a/plugins/importer-insomnia/tests/fixtures/basic.output.json b/plugins/importer-insomnia/tests/fixtures/basic.output.json index f989ec0e..c1381750 100644 --- a/plugins/importer-insomnia/tests/fixtures/basic.output.json +++ b/plugins/importer-insomnia/tests/fixtures/basic.output.json @@ -3,7 +3,7 @@ "environments": [ { "createdAt": "2025-01-13T15:15:43.767", - "environmentId": null, + "base": true, "id": "GENERATE_ID::env_16c0dec5b77c414ae0e419b8f10c3701300c5900", "model": "environment", "name": "Base Environment", @@ -18,7 +18,7 @@ }, { "createdAt": "2025-01-13T15:15:58.515", - "environmentId": "GENERATE_ID::env_16c0dec5b77c414ae0e419b8f10c3701300c5900", + "base": false, "id": "GENERATE_ID::env_799ae3d723ef44af91b4817e5d057e6d", "model": "environment", "name": "Production", @@ -33,7 +33,7 @@ }, { "createdAt": "2025-01-13T15:16:14.707", - "environmentId": "GENERATE_ID::env_16c0dec5b77c414ae0e419b8f10c3701300c5900", + "base": false, "id": "GENERATE_ID::env_030fbfdbb274426ebd78e2e6518f8553", "model": "environment", "name": "Staging", diff --git a/plugins/importer-yaak/src/index.ts b/plugins/importer-yaak/src/index.ts index d4295358..1a71cfbb 100644 --- a/plugins/importer-yaak/src/index.ts +++ b/plugins/importer-yaak/src/index.ts @@ -46,7 +46,7 @@ export function migrateImport(contents: string) { parsed.resources.environments = parsed.resources.environments ?? []; parsed.resources.environments.push(baseEnvironment); - // Delete variables key from workspace + // Delete variables key from the workspace delete workspace.variables; // Add environmentId to relevant environments @@ -58,6 +58,14 @@ export function migrateImport(contents: string) { } } + // Migrate v3 to v4 + for (const environment of parsed.resources.environments ?? []) { + if ('environmentId' in environment) { + environment.base = environment.environmentId == null; + delete environment.environmentId; + } + } + return { resources: parsed.resources }; // Should already be in the correct format } diff --git a/plugins/importer-yaak/tests/index.test.ts b/plugins/importer-yaak/tests/index.test.ts index 533acd6e..a55e62b1 100644 --- a/plugins/importer-yaak/tests/index.test.ts +++ b/plugins/importer-yaak/tests/index.test.ts @@ -53,7 +53,7 @@ describe('importer-yaak', () => { }], environments: [{ id: 'e_1', - environmentId: 'GENERATE_ID::base_env_w_1', + base: false, workspaceId: 'w_1', name: 'Production', variables: [{ name: 'E1', value: 'E1!' }], diff --git a/plugins/template-function-file/package.json b/plugins/template-function-file/package.json deleted file mode 100644 index 59aea7ab..00000000 --- a/plugins/template-function-file/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "@yaakapp/template-function-file", - "private": true, - "version": "0.0.1", - "scripts": { - "build": "yaakcli build ./src/index.ts", - "dev": "yaakcli dev ./src/index.js" - } -} diff --git a/plugins/template-function-file/src/index.ts b/plugins/template-function-file/src/index.ts deleted file mode 100644 index 472c1a0d..00000000 --- a/plugins/template-function-file/src/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { CallTemplateFunctionArgs, Context, PluginDefinition } from '@yaakapp/api'; -import fs from 'node:fs'; - -export const plugin: PluginDefinition = { - templateFunctions: [{ - name: 'fs.readFile', - args: [{ title: 'Select File', type: 'file', name: 'path', label: 'File' }], - async onRender(_ctx: Context, args: CallTemplateFunctionArgs): Promise { - if (!args.values.path) return null; - - try { - return fs.promises.readFile(args.values.path, 'utf-8'); - } catch (err) { - return null; - } - }, - }], -};