mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-11 22:40:26 +01:00
Update importers for folder environment and fix tests
This commit is contained in:
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -72,12 +72,16 @@ jobs:
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# Some things (eg. WASM package) requires building before lint will work
|
||||
- name: Run bootstrap
|
||||
run: npm run bootstrap
|
||||
|
||||
- name: Run lint
|
||||
run: npm run lint
|
||||
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
|
||||
- name: Set version
|
||||
run: npm run replace-version
|
||||
env:
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
"migration": "node scripts/create-migration.cjs",
|
||||
"build": "npm run --workspaces --if-present build",
|
||||
"build-plugins": "npm run --workspaces --if-present build",
|
||||
"test": "npm run --workspaces --if-present test",
|
||||
"icons": "run-p icons:*",
|
||||
"icons:dev": "tauri icon src-tauri/icons/icon.png --output src-tauri/icons/release",
|
||||
"icons:release": "tauri icon src-tauri/icons/icon-dev.png --output src-tauri/icons/dev",
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"scripts": {
|
||||
"build": "yaakcli build",
|
||||
"dev": "yaakcli dev",
|
||||
"lint": "tsc --noEmit && eslint . --ext .ts,.tsx"
|
||||
"lint": "tsc --noEmit && eslint . --ext .ts,.tsx",
|
||||
"test": "vitest --run tests"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"scripts": {
|
||||
"build": "yaakcli build",
|
||||
"dev": "yaakcli dev",
|
||||
"lint":"tsc --noEmit && eslint . --ext .ts,.tsx"
|
||||
"lint":"tsc --noEmit && eslint . --ext .ts,.tsx",
|
||||
"test": "vitest --run tests"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"scripts": {
|
||||
"build": "yaakcli build",
|
||||
"dev": "yaakcli dev",
|
||||
"lint":"tsc --noEmit && eslint . --ext .ts,.tsx"
|
||||
"lint":"tsc --noEmit && eslint . --ext .ts,.tsx",
|
||||
"test": "vitest --run tests"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
"scripts": {
|
||||
"build": "yaakcli build",
|
||||
"dev": "yaakcli dev",
|
||||
"lint":"tsc --noEmit && eslint . --ext .ts,.tsx"
|
||||
"lint": "tsc --noEmit && eslint . --ext .ts,.tsx",
|
||||
"test": "vitest --run tests"
|
||||
},
|
||||
"dependencies": {
|
||||
"shell-quote": "^1.8.1"
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
"scripts": {
|
||||
"build": "yaakcli build",
|
||||
"dev": "yaakcli dev",
|
||||
"lint":"tsc --noEmit && eslint . --ext .ts,.tsx"
|
||||
"lint":"tsc --noEmit && eslint . --ext .ts,.tsx",
|
||||
"test": "vitest --run tests"
|
||||
},
|
||||
"dependencies": {
|
||||
"yaml": "^2.4.2"
|
||||
|
||||
@@ -30,18 +30,25 @@ export function convertInsomniaV5(parsed: any) {
|
||||
model: 'workspace',
|
||||
name: parsed.name,
|
||||
description: meta.description || undefined,
|
||||
...importHeaders(parsed),
|
||||
...importAuthentication(parsed),
|
||||
});
|
||||
|
||||
// Import environments
|
||||
resources.environments.push(
|
||||
importEnvironment(parsed.environments, meta.id, true),
|
||||
...(parsed.environments.subEnvironments ?? []).map((r: any) => importEnvironment(r, meta.id)),
|
||||
);
|
||||
|
||||
// Import folders
|
||||
const nextFolder = (children: any[], parentId: string) => {
|
||||
for (const child of children ?? []) {
|
||||
if (!isJSObject(child)) continue;
|
||||
|
||||
if (Array.isArray(child.children)) {
|
||||
resources.folders.push(importFolder(child, meta.id, parentId));
|
||||
const { folder, environment } = importFolder(child, meta.id, parentId);
|
||||
resources.folders.push(folder);
|
||||
if (environment) resources.environments.push(environment);
|
||||
nextFolder(child.children, child.meta.id);
|
||||
} else if (child.method) {
|
||||
resources.httpRequests.push(importHttpRequest(child, meta.id, parentId));
|
||||
@@ -191,8 +198,8 @@ function importWebsocketRequest(
|
||||
};
|
||||
}
|
||||
|
||||
function importHeaders(r: any) {
|
||||
const headers = (r.headers ?? [])
|
||||
function importHeaders(obj: any) {
|
||||
const headers = (obj.headers ?? [])
|
||||
.map((h: any) => ({
|
||||
enabled: !h.disabled,
|
||||
name: h.name ?? '',
|
||||
@@ -202,19 +209,19 @@ function importHeaders(r: any) {
|
||||
return { headers } as const;
|
||||
}
|
||||
|
||||
function importAuthentication(r: any) {
|
||||
function importAuthentication(obj: any) {
|
||||
let authenticationType: string | null = null;
|
||||
let authentication = {};
|
||||
if (r.authentication?.type === 'bearer') {
|
||||
if (obj.authentication?.type === 'bearer') {
|
||||
authenticationType = 'bearer';
|
||||
authentication = {
|
||||
token: convertSyntax(r.authentication.token),
|
||||
token: convertSyntax(obj.authentication.token),
|
||||
};
|
||||
} else if (r.authentication?.type === 'basic') {
|
||||
} else if (obj.authentication?.type === 'basic') {
|
||||
authenticationType = 'basic';
|
||||
authentication = {
|
||||
username: convertSyntax(r.authentication.username),
|
||||
password: convertSyntax(r.authentication.password),
|
||||
username: convertSyntax(obj.authentication.username),
|
||||
password: convertSyntax(obj.authentication.password),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -225,13 +232,37 @@ function importFolder(
|
||||
f: any,
|
||||
workspaceId: string,
|
||||
parentId: string,
|
||||
): PartialImportResources['folders'][0] {
|
||||
): {
|
||||
folder: PartialImportResources['folders'][0];
|
||||
environment: PartialImportResources['environments'][0] | null;
|
||||
} {
|
||||
const id = f.meta?.id ?? f._id;
|
||||
const created = f.meta?.created ?? f.created;
|
||||
const updated = f.meta?.modified ?? f.updated;
|
||||
const sortKey = f.meta?.sortKey ?? f.sortKey;
|
||||
|
||||
let environment: PartialImportResources['environments'][0] | null = null;
|
||||
if (Object.keys(f.environment ?? {}).length > 0) {
|
||||
environment = {
|
||||
id: convertId(id + 'folder'),
|
||||
createdAt: created ? new Date(created).toISOString().replace('Z', '') : undefined,
|
||||
updatedAt: updated ? new Date(updated).toISOString().replace('Z', '') : undefined,
|
||||
workspaceId: convertId(workspaceId),
|
||||
public: true,
|
||||
parentModel: 'folder',
|
||||
parentId: convertId(id),
|
||||
model: 'environment',
|
||||
name: 'Folder Environment',
|
||||
variables: Object.entries(f.environment ?? {}).map(([name, value]) => ({
|
||||
enabled: true,
|
||||
name,
|
||||
value: `${value}`,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
folder: {
|
||||
model: 'folder',
|
||||
id: convertId(id),
|
||||
createdAt: created ? new Date(created).toISOString().replace('Z', '') : undefined,
|
||||
@@ -241,6 +272,10 @@ function importFolder(
|
||||
workspaceId: convertId(workspaceId),
|
||||
description: f.description || undefined,
|
||||
name: f.name,
|
||||
...importAuthentication(f),
|
||||
...importHeaders(f),
|
||||
},
|
||||
environment,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -263,7 +298,8 @@ function importEnvironment(
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-expect-error
|
||||
sortPriority: sortKey, // Will be added to Yaak later
|
||||
base: isParent ?? e.parentId === workspaceId,
|
||||
parentModel: isParent ? 'workspace' : 'environment',
|
||||
parentId: null,
|
||||
model: 'environment',
|
||||
name: e.name,
|
||||
variables: Object.entries(e.data ?? {}).map(([name, value]) => ({
|
||||
|
||||
@@ -38,6 +38,8 @@ collection:
|
||||
name: foo
|
||||
value: bar
|
||||
disabled: false
|
||||
environment:
|
||||
folder_env_var: testing
|
||||
- name: New Request
|
||||
meta:
|
||||
id: req_e3f8cdbd58784a539dd4c1e127d73451
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
"resources": {
|
||||
"environments": [
|
||||
{
|
||||
"base": true,
|
||||
"createdAt": "2025-05-14T04:45:24.903",
|
||||
"id": "GENERATE_ID::env_e46dc73e8ccda30ca132153e8f11183bd08119ce",
|
||||
"model": "environment",
|
||||
@@ -10,6 +9,26 @@
|
||||
"public": true,
|
||||
"updatedAt": "2025-05-14T04:45:24.903",
|
||||
"variables": [],
|
||||
"workspaceId": "GENERATE_ID::wrk_9717dd1c9e0c4b2e9ed6d2abcf3bd45c",
|
||||
"parentId": null,
|
||||
"parentModel": "workspace"
|
||||
},
|
||||
{
|
||||
"createdAt": "2025-05-16T16:48:12.298",
|
||||
"id": "GENERATE_ID::fld_296933ea4ea84783a775d199997e9be7folder",
|
||||
"model": "environment",
|
||||
"name": "Folder Environment",
|
||||
"parentId": "GENERATE_ID::fld_296933ea4ea84783a775d199997e9be7",
|
||||
"parentModel": "folder",
|
||||
"public": true,
|
||||
"updatedAt": "2025-05-16T16:49:02.427",
|
||||
"variables": [
|
||||
{
|
||||
"enabled": true,
|
||||
"name": "folder_env_var",
|
||||
"value": "testing"
|
||||
}
|
||||
],
|
||||
"workspaceId": "GENERATE_ID::wrk_9717dd1c9e0c4b2e9ed6d2abcf3bd45c"
|
||||
}
|
||||
],
|
||||
@@ -22,7 +41,16 @@
|
||||
"name": "My Folder",
|
||||
"sortPriority": -1747414092298,
|
||||
"updatedAt": "2025-05-16T16:49:02.427",
|
||||
"workspaceId": "GENERATE_ID::wrk_9717dd1c9e0c4b2e9ed6d2abcf3bd45c"
|
||||
"workspaceId": "GENERATE_ID::wrk_9717dd1c9e0c4b2e9ed6d2abcf3bd45c",
|
||||
"authentication": {},
|
||||
"authenticationType": null,
|
||||
"headers": [
|
||||
{
|
||||
"enabled": true,
|
||||
"name": "foo",
|
||||
"value": "bar"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"grpcRequests": [],
|
||||
@@ -80,7 +108,10 @@
|
||||
"id": "GENERATE_ID::wrk_9717dd1c9e0c4b2e9ed6d2abcf3bd45c",
|
||||
"model": "workspace",
|
||||
"name": "Debugging",
|
||||
"updatedAt": "2025-05-14T04:45:24.902"
|
||||
"updatedAt": "2025-05-14T04:45:24.902",
|
||||
"authentication": {},
|
||||
"authenticationType": null,
|
||||
"headers": []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
{
|
||||
"createdAt": "2025-01-13T15:15:43.767",
|
||||
"updatedAt": "2025-01-13T15:15:55.209",
|
||||
"base": true,
|
||||
"public": true,
|
||||
"id": "GENERATE_ID::env_20945044d3c8497ca8b717bef750987e",
|
||||
"model": "environment",
|
||||
"name": "Base Environment",
|
||||
"parentId": null,
|
||||
"parentModel": "workspace",
|
||||
"variables": [
|
||||
{
|
||||
"enabled": true,
|
||||
@@ -21,11 +22,12 @@
|
||||
{
|
||||
"createdAt": "2025-01-13T15:15:58.515",
|
||||
"updatedAt": "2025-01-13T15:16:34.705",
|
||||
"base": false,
|
||||
"public": true,
|
||||
"id": "GENERATE_ID::env_6f7728bb7fc04d558d668e954d756ea2",
|
||||
"model": "environment",
|
||||
"name": "Production",
|
||||
"parentId": null,
|
||||
"parentModel": "environment",
|
||||
"sortPriority": 1736781358515,
|
||||
"variables": [
|
||||
{
|
||||
@@ -39,8 +41,9 @@
|
||||
{
|
||||
"createdAt": "2025-01-13T15:16:14.707",
|
||||
"updatedAt": "2025-01-13T15:16:31.078",
|
||||
"base": false,
|
||||
"public": true,
|
||||
"parentId": null,
|
||||
"parentModel": "environment",
|
||||
"id": "GENERATE_ID::env_976a8b6eb5d44fb6a20150f65c32d243",
|
||||
"model": "environment",
|
||||
"name": "Staging",
|
||||
@@ -64,7 +67,10 @@
|
||||
"model": "folder",
|
||||
"name": "Top Level",
|
||||
"sortPriority": -1736781404718,
|
||||
"workspaceId": "GENERATE_ID::wrk_c1eacfa750a04f3ea9985ef28043fa53"
|
||||
"workspaceId": "GENERATE_ID::wrk_c1eacfa750a04f3ea9985ef28043fa53",
|
||||
"authentication": {},
|
||||
"authenticationType": null,
|
||||
"headers": []
|
||||
}
|
||||
],
|
||||
"grpcRequests": [
|
||||
@@ -165,7 +171,10 @@
|
||||
"description": "This is the description",
|
||||
"id": "GENERATE_ID::wrk_c1eacfa750a04f3ea9985ef28043fa53",
|
||||
"model": "workspace",
|
||||
"name": "Dummy"
|
||||
"name": "Dummy",
|
||||
"authentication": {},
|
||||
"authenticationType": null,
|
||||
"headers": []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
"scripts": {
|
||||
"build": "yaakcli build",
|
||||
"dev": "yaakcli dev",
|
||||
"lint":"tsc --noEmit && eslint . --ext .ts,.tsx"
|
||||
"lint":"tsc --noEmit && eslint . --ext .ts,.tsx",
|
||||
"test": "vitest --run tests"
|
||||
},
|
||||
"dependencies": {
|
||||
"openapi-to-postmanv2": "^5.0.0",
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"scripts": {
|
||||
"build": "yaakcli build",
|
||||
"dev": "yaakcli dev",
|
||||
"lint":"tsc --noEmit && eslint . --ext .ts,.tsx"
|
||||
"lint": "tsc --noEmit && eslint . --ext .ts,.tsx",
|
||||
"test": "vitest --run tests"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +57,10 @@ export function convertPostman(contents: string): ImportPluginResponse | undefin
|
||||
|
||||
const rawDescription = info.description;
|
||||
const description =
|
||||
typeof rawDescription === 'object' && rawDescription !== null && 'content' in rawDescription
|
||||
typeof rawDescription === 'object' && rawDescription != null && 'content' in rawDescription
|
||||
? String(rawDescription.content)
|
||||
: rawDescription == null
|
||||
? undefined
|
||||
: String(rawDescription);
|
||||
|
||||
const workspace: ExportResources['workspaces'][0] = {
|
||||
@@ -75,6 +77,8 @@ export function convertPostman(contents: string): ImportPluginResponse | undefin
|
||||
id: generateId('environment'),
|
||||
name: 'Global Variables',
|
||||
workspaceId: workspace.id,
|
||||
parentModel: 'workspace',
|
||||
parentId: null,
|
||||
variables:
|
||||
toArray<{ key: string; value: string }>(root.variable).map((v) => ({
|
||||
name: v.key,
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
"model": "environment",
|
||||
"name": "Global Variables",
|
||||
"variables": [],
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0"
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"parentId": null,
|
||||
"parentModel": "workspace"
|
||||
}
|
||||
],
|
||||
"httpRequests": [
|
||||
@@ -25,6 +27,7 @@
|
||||
"name": "Request 1",
|
||||
"method": "GET",
|
||||
"url": "",
|
||||
"sortPriority": 2,
|
||||
"urlParameters": [],
|
||||
"body": {},
|
||||
"bodyType": null,
|
||||
@@ -39,6 +42,7 @@
|
||||
"folderId": "GENERATE_ID::FOLDER_0",
|
||||
"name": "Request 2",
|
||||
"method": "GET",
|
||||
"sortPriority": 3,
|
||||
"url": "",
|
||||
"urlParameters": [],
|
||||
"body": {},
|
||||
@@ -52,6 +56,7 @@
|
||||
"id": "GENERATE_ID::HTTP_REQUEST_2",
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"folderId": null,
|
||||
"sortPriority": 4,
|
||||
"name": "Request 3",
|
||||
"method": "GET",
|
||||
"url": "",
|
||||
@@ -69,6 +74,7 @@
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"id": "GENERATE_ID::FOLDER_0",
|
||||
"name": "Top Folder",
|
||||
"sortPriority": 0,
|
||||
"folderId": null
|
||||
},
|
||||
{
|
||||
@@ -76,6 +82,7 @@
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_0",
|
||||
"id": "GENERATE_ID::FOLDER_1",
|
||||
"name": "Nested Folder",
|
||||
"sortPriority": 1,
|
||||
"folderId": "GENERATE_ID::FOLDER_0"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_1",
|
||||
"model": "environment",
|
||||
"name": "Global Variables",
|
||||
"parentId": null,
|
||||
"parentModel": "workspace",
|
||||
"variables": [
|
||||
{
|
||||
"name": "COLLECTION VARIABLE",
|
||||
@@ -28,6 +30,7 @@
|
||||
"workspaceId": "GENERATE_ID::WORKSPACE_1",
|
||||
"folderId": null,
|
||||
"name": "Form URL",
|
||||
"sortPriority": 0,
|
||||
"method": "POST",
|
||||
"url": "example.com/:foo/:bar",
|
||||
"urlParameters": [
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"scripts": {
|
||||
"build": "yaakcli build",
|
||||
"dev": "yaakcli dev",
|
||||
"lint":"tsc --noEmit && eslint . --ext .ts,.tsx"
|
||||
"lint":"tsc --noEmit && eslint . --ext .ts,.tsx",
|
||||
"test": "vitest --run tests"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,15 +69,13 @@ export function migrateImport(contents: string) {
|
||||
// Migrate v4 to v5
|
||||
for (const environment of parsed.resources.environments ?? []) {
|
||||
if ('base' in environment && environment.base) {
|
||||
environment.parentId = environment.workspaceId;
|
||||
environment.parentType = 'workspace';
|
||||
delete environment.environmentId;
|
||||
environment.parentModel = 'workspace';
|
||||
environment.parentId = null;
|
||||
delete environment.base;
|
||||
} else if ('base' in environment && !environment.base) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const baseEnvironment = parsed.resources.environments.find((e: any) => e.base);
|
||||
environment.parentId = baseEnvironment?.id ?? null;
|
||||
environment.parentType = 'environment';
|
||||
delete environment.environmentId;
|
||||
environment.parentModel = 'environment';
|
||||
environment.parentId = null;
|
||||
delete environment.base;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,16 +31,20 @@ describe('importer-yaak', () => {
|
||||
JSON.stringify({
|
||||
yaakSchema: 2,
|
||||
resources: {
|
||||
environments: [{
|
||||
environments: [
|
||||
{
|
||||
id: 'e_1',
|
||||
workspaceId: 'w_1',
|
||||
name: 'Production',
|
||||
variables: [{ name: 'E1', value: 'E1!' }],
|
||||
}],
|
||||
workspaces: [{
|
||||
},
|
||||
],
|
||||
workspaces: [
|
||||
{
|
||||
id: 'w_1',
|
||||
variables: [{ name: 'W1', value: 'W1!' }],
|
||||
}],
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
);
|
||||
@@ -48,21 +52,98 @@ describe('importer-yaak', () => {
|
||||
expect(imported).toEqual(
|
||||
expect.objectContaining({
|
||||
resources: {
|
||||
workspaces: [{
|
||||
workspaces: [
|
||||
{
|
||||
id: 'w_1',
|
||||
}],
|
||||
environments: [{
|
||||
},
|
||||
],
|
||||
environments: [
|
||||
{
|
||||
id: 'e_1',
|
||||
base: false,
|
||||
workspaceId: 'w_1',
|
||||
name: 'Production',
|
||||
variables: [{ name: 'E1', value: 'E1!' }],
|
||||
}, {
|
||||
parentModel: 'environment',
|
||||
parentId: null,
|
||||
},
|
||||
{
|
||||
id: 'GENERATE_ID::base_env_w_1',
|
||||
workspaceId: 'w_1',
|
||||
name: 'Global Variables',
|
||||
variables: [{ name: 'W1', value: 'W1!' }],
|
||||
}],
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
test('converts schema 4 to 5', () => {
|
||||
const imported = migrateImport(
|
||||
JSON.stringify({
|
||||
yaakSchema: 2,
|
||||
resources: {
|
||||
environments: [
|
||||
{
|
||||
id: 'e_1',
|
||||
workspaceId: 'w_1',
|
||||
base: false,
|
||||
name: 'Production',
|
||||
variables: [{ name: 'E1', value: 'E1!' }],
|
||||
},
|
||||
{
|
||||
id: 'e_1',
|
||||
workspaceId: 'w_1',
|
||||
base: true,
|
||||
name: 'Global Variables',
|
||||
variables: [{ name: 'G1', value: 'G1!' }],
|
||||
},
|
||||
],
|
||||
folders: [
|
||||
{
|
||||
id: 'f_1',
|
||||
},
|
||||
],
|
||||
workspaces: [
|
||||
{
|
||||
id: 'w_1',
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
expect(imported).toEqual(
|
||||
expect.objectContaining({
|
||||
resources: {
|
||||
workspaces: [
|
||||
{
|
||||
id: 'w_1',
|
||||
},
|
||||
],
|
||||
folders: [
|
||||
{
|
||||
id: 'f_1',
|
||||
},
|
||||
],
|
||||
environments: [
|
||||
{
|
||||
id: 'e_1',
|
||||
workspaceId: 'w_1',
|
||||
name: 'Production',
|
||||
variables: [{ name: 'E1', value: 'E1!' }],
|
||||
parentModel: 'environment',
|
||||
parentId: null,
|
||||
},
|
||||
{
|
||||
id: 'e_1',
|
||||
workspaceId: 'w_1',
|
||||
name: 'Global Variables',
|
||||
parentModel: 'workspace',
|
||||
parentId: null,
|
||||
variables: [{ name: 'G1', value: 'G1!' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"scripts": {
|
||||
"build": "yaakcli build",
|
||||
"dev": "yaakcli dev",
|
||||
"lint":"tsc --noEmit && eslint . --ext .ts,.tsx"
|
||||
"lint":"tsc --noEmit && eslint . --ext .ts,.tsx",
|
||||
"test": "vitest --run tests"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
"scripts": {
|
||||
"build": "yaakcli build",
|
||||
"dev": "yaakcli dev",
|
||||
"lint":"tsc --noEmit && eslint . --ext .ts,.tsx"
|
||||
"lint":"tsc --noEmit && eslint . --ext .ts,.tsx",
|
||||
"test": "vitest --run tests"
|
||||
},
|
||||
"dependencies": {
|
||||
"date-fns": "^4.1.0"
|
||||
|
||||
@@ -39,6 +39,19 @@ pub(crate) async fn import_data<R: Runtime>(
|
||||
.map(|mut v| {
|
||||
v.id = maybe_gen_id::<Environment>(v.id.as_str(), &mut id_map);
|
||||
v.workspace_id = maybe_gen_id::<Workspace>(v.workspace_id.as_str(), &mut id_map);
|
||||
match (v.parent_model.as_str(), v.parent_id.clone().as_deref()) {
|
||||
("folder", Some(parent_id)) => {
|
||||
v.parent_id = Some(maybe_gen_id::<Folder>(&parent_id, &mut id_map));
|
||||
}
|
||||
("", _) => {
|
||||
// Fix any empty ones
|
||||
v.parent_model = "workspace".to_string();
|
||||
}
|
||||
_ => {
|
||||
// Parent ID only required for the folder case
|
||||
v.parent_id = None;
|
||||
}
|
||||
};
|
||||
v
|
||||
})
|
||||
.collect();
|
||||
|
||||
Reference in New Issue
Block a user