mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 17:58:27 +02:00
Extract base environment (#149)
This commit is contained in:
311
package-lock.json
generated
311
package-lock.json
generated
@@ -20,18 +20,18 @@
|
|||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tauri-apps/cli": "^2.1.0",
|
"@tauri-apps/cli": "^2.1.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.5.0",
|
"@typescript-eslint/eslint-plugin": "^8.18.1",
|
||||||
"@typescript-eslint/parser": "^8.5.0",
|
"@typescript-eslint/parser": "^8.18.1",
|
||||||
"eslint": "^8",
|
"eslint": "^8",
|
||||||
"eslint-config-prettier": "^8",
|
"eslint-config-prettier": "^8",
|
||||||
"eslint-plugin-import": "^2.30.0",
|
"eslint-plugin-import": "^2.31.0",
|
||||||
"eslint-plugin-jsx-a11y": "^6.10.0",
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||||
"eslint-plugin-react": "^7.35.2",
|
"eslint-plugin-react": "^7.37.2",
|
||||||
"eslint-plugin-react-hooks": "^4.6.2",
|
"eslint-plugin-react-hooks": "^5.1.0",
|
||||||
"nodejs-file-downloader": "^4.13.0",
|
"nodejs-file-downloader": "^4.13.0",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.4.2",
|
||||||
"typescript": "^5.6.2"
|
"typescript": "^5.7.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@alloc/quick-lru": {
|
"node_modules/@alloc/quick-lru": {
|
||||||
@@ -3399,17 +3399,17 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||||
"version": "8.8.1",
|
"version": "8.18.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.18.1.tgz",
|
||||||
"integrity": "sha512-xfvdgA8AP/vxHgtgU310+WBnLB4uJQ9XdyP17RebG26rLtDrQJV3ZYrcopX91GrHmMoH8bdSwMRh2a//TiJ1jQ==",
|
"integrity": "sha512-Ncvsq5CT3Gvh+uJG0Lwlho6suwDfUXH0HztslDf5I+F2wAFAZMRwYLEorumpKLzmO2suAXZ/td1tBg4NZIi9CQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint-community/regexpp": "^4.10.0",
|
"@eslint-community/regexpp": "^4.10.0",
|
||||||
"@typescript-eslint/scope-manager": "8.8.1",
|
"@typescript-eslint/scope-manager": "8.18.1",
|
||||||
"@typescript-eslint/type-utils": "8.8.1",
|
"@typescript-eslint/type-utils": "8.18.1",
|
||||||
"@typescript-eslint/utils": "8.8.1",
|
"@typescript-eslint/utils": "8.18.1",
|
||||||
"@typescript-eslint/visitor-keys": "8.8.1",
|
"@typescript-eslint/visitor-keys": "8.18.1",
|
||||||
"graphemer": "^1.4.0",
|
"graphemer": "^1.4.0",
|
||||||
"ignore": "^5.3.1",
|
"ignore": "^5.3.1",
|
||||||
"natural-compare": "^1.4.0",
|
"natural-compare": "^1.4.0",
|
||||||
@@ -3424,25 +3424,21 @@
|
|||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0",
|
"@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0",
|
||||||
"eslint": "^8.57.0 || ^9.0.0"
|
"eslint": "^8.57.0 || ^9.0.0",
|
||||||
},
|
"typescript": ">=4.8.4 <5.8.0"
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"typescript": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/parser": {
|
"node_modules/@typescript-eslint/parser": {
|
||||||
"version": "8.8.1",
|
"version": "8.18.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.18.1.tgz",
|
||||||
"integrity": "sha512-hQUVn2Lij2NAxVFEdvIGxT9gP1tq2yM83m+by3whWFsWC+1y8pxxxHUFE1UqDu2VsGi2i6RLcv4QvouM84U+ow==",
|
"integrity": "sha512-rBnTWHCdbYM2lh7hjyXqxk70wvon3p2FyaniZuey5TrcGBpfhVp0OxOa6gxr9Q9YhZFKyfbEnxc24ZnVbbUkCA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "BSD-2-Clause",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/scope-manager": "8.8.1",
|
"@typescript-eslint/scope-manager": "8.18.1",
|
||||||
"@typescript-eslint/types": "8.8.1",
|
"@typescript-eslint/types": "8.18.1",
|
||||||
"@typescript-eslint/typescript-estree": "8.8.1",
|
"@typescript-eslint/typescript-estree": "8.18.1",
|
||||||
"@typescript-eslint/visitor-keys": "8.8.1",
|
"@typescript-eslint/visitor-keys": "8.18.1",
|
||||||
"debug": "^4.3.4"
|
"debug": "^4.3.4"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -3453,23 +3449,19 @@
|
|||||||
"url": "https://opencollective.com/typescript-eslint"
|
"url": "https://opencollective.com/typescript-eslint"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"eslint": "^8.57.0 || ^9.0.0"
|
"eslint": "^8.57.0 || ^9.0.0",
|
||||||
},
|
"typescript": ">=4.8.4 <5.8.0"
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"typescript": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/scope-manager": {
|
"node_modules/@typescript-eslint/scope-manager": {
|
||||||
"version": "8.8.1",
|
"version": "8.18.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.18.1.tgz",
|
||||||
"integrity": "sha512-X4JdU+66Mazev/J0gfXlcC/dV6JI37h+93W9BRYXrSn0hrE64IoWgVkO9MSJgEzoWkxONgaQpICWg8vAN74wlA==",
|
"integrity": "sha512-HxfHo2b090M5s2+/9Z3gkBhI6xBH8OJCFjH9MhQ+nnoZqxU3wNxkLT+VWXWSFWc3UF3Z+CfPAyqdCTdoXtDPCQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/types": "8.8.1",
|
"@typescript-eslint/types": "8.18.1",
|
||||||
"@typescript-eslint/visitor-keys": "8.8.1"
|
"@typescript-eslint/visitor-keys": "8.18.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||||
@@ -3480,14 +3472,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/type-utils": {
|
"node_modules/@typescript-eslint/type-utils": {
|
||||||
"version": "8.8.1",
|
"version": "8.18.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.18.1.tgz",
|
||||||
"integrity": "sha512-qSVnpcbLP8CALORf0za+vjLYj1Wp8HSoiI8zYU5tHxRVj30702Z1Yw4cLwfNKhTPWp5+P+k1pjmD5Zd1nhxiZA==",
|
"integrity": "sha512-jAhTdK/Qx2NJPNOTxXpMwlOiSymtR2j283TtPqXkKBdH8OAMmhiUfP0kJjc/qSE51Xrq02Gj9NY7MwK+UxVwHQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/typescript-estree": "8.8.1",
|
"@typescript-eslint/typescript-estree": "8.18.1",
|
||||||
"@typescript-eslint/utils": "8.8.1",
|
"@typescript-eslint/utils": "8.18.1",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"ts-api-utils": "^1.3.0"
|
"ts-api-utils": "^1.3.0"
|
||||||
},
|
},
|
||||||
@@ -3498,16 +3490,15 @@
|
|||||||
"type": "opencollective",
|
"type": "opencollective",
|
||||||
"url": "https://opencollective.com/typescript-eslint"
|
"url": "https://opencollective.com/typescript-eslint"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependencies": {
|
||||||
"typescript": {
|
"eslint": "^8.57.0 || ^9.0.0",
|
||||||
"optional": true
|
"typescript": ">=4.8.4 <5.8.0"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/types": {
|
"node_modules/@typescript-eslint/types": {
|
||||||
"version": "8.8.1",
|
"version": "8.18.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.18.1.tgz",
|
||||||
"integrity": "sha512-WCcTP4SDXzMd23N27u66zTKMuEevH4uzU8C9jf0RO4E04yVHgQgW+r+TeVTNnO1KIfrL8ebgVVYYMMO3+jC55Q==",
|
"integrity": "sha512-7uoAUsCj66qdNQNpH2G8MyTFlgerum8ubf21s3TSM3XmKXuIn+H2Sifh/ES2nPOPiYSRJWAk0fDkW0APBWcpfw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -3519,14 +3510,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/typescript-estree": {
|
"node_modules/@typescript-eslint/typescript-estree": {
|
||||||
"version": "8.8.1",
|
"version": "8.18.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.18.1.tgz",
|
||||||
"integrity": "sha512-A5d1R9p+X+1js4JogdNilDuuq+EHZdsH9MjTVxXOdVFfTJXunKJR/v+fNNyO4TnoOn5HqobzfRlc70NC6HTcdg==",
|
"integrity": "sha512-z8U21WI5txzl2XYOW7i9hJhxoKKNG1kcU4RzyNvKrdZDmbjkmLBo8bgeiOJmA06kizLI76/CCBAAGlTlEeUfyg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "BSD-2-Clause",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/types": "8.8.1",
|
"@typescript-eslint/types": "8.18.1",
|
||||||
"@typescript-eslint/visitor-keys": "8.8.1",
|
"@typescript-eslint/visitor-keys": "8.18.1",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"fast-glob": "^3.3.2",
|
"fast-glob": "^3.3.2",
|
||||||
"is-glob": "^4.0.3",
|
"is-glob": "^4.0.3",
|
||||||
@@ -3541,23 +3532,21 @@
|
|||||||
"type": "opencollective",
|
"type": "opencollective",
|
||||||
"url": "https://opencollective.com/typescript-eslint"
|
"url": "https://opencollective.com/typescript-eslint"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependencies": {
|
||||||
"typescript": {
|
"typescript": ">=4.8.4 <5.8.0"
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/utils": {
|
"node_modules/@typescript-eslint/utils": {
|
||||||
"version": "8.8.1",
|
"version": "8.18.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.18.1.tgz",
|
||||||
"integrity": "sha512-/QkNJDbV0bdL7H7d0/y0qBbV2HTtf0TIyjSDTvvmQEzeVx8jEImEbLuOA4EsvE8gIgqMitns0ifb5uQhMj8d9w==",
|
"integrity": "sha512-8vikiIj2ebrC4WRdcAdDcmnu9Q/MXXwg+STf40BVfT8exDqBCUPdypvzcUPxEqRGKg9ALagZ0UWcYCtn+4W2iQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint-community/eslint-utils": "^4.4.0",
|
"@eslint-community/eslint-utils": "^4.4.0",
|
||||||
"@typescript-eslint/scope-manager": "8.8.1",
|
"@typescript-eslint/scope-manager": "8.18.1",
|
||||||
"@typescript-eslint/types": "8.8.1",
|
"@typescript-eslint/types": "8.18.1",
|
||||||
"@typescript-eslint/typescript-estree": "8.8.1"
|
"@typescript-eslint/typescript-estree": "8.18.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||||
@@ -3567,18 +3556,19 @@
|
|||||||
"url": "https://opencollective.com/typescript-eslint"
|
"url": "https://opencollective.com/typescript-eslint"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"eslint": "^8.57.0 || ^9.0.0"
|
"eslint": "^8.57.0 || ^9.0.0",
|
||||||
|
"typescript": ">=4.8.4 <5.8.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/visitor-keys": {
|
"node_modules/@typescript-eslint/visitor-keys": {
|
||||||
"version": "8.8.1",
|
"version": "8.18.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.18.1.tgz",
|
||||||
"integrity": "sha512-0/TdC3aeRAsW7MDvYRwEc1Uwm0TIBfzjPFgg60UU2Haj5qsCs9cc3zNgY71edqE3LbWfF/WoZQd3lJoDXFQpag==",
|
"integrity": "sha512-Vj0WLm5/ZsD013YeUKn+K0y8p1M0jPpxOkKdbD1wB0ns53a5piVY02zjf072TblEweAbcYiFiPoSMF3kp+VhhQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/types": "8.8.1",
|
"@typescript-eslint/types": "8.18.1",
|
||||||
"eslint-visitor-keys": "^3.4.3"
|
"eslint-visitor-keys": "^4.2.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||||
@@ -3588,6 +3578,19 @@
|
|||||||
"url": "https://opencollective.com/typescript-eslint"
|
"url": "https://opencollective.com/typescript-eslint"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": {
|
||||||
|
"version": "4.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz",
|
||||||
|
"integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/eslint"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@ungap/structured-clone": {
|
"node_modules/@ungap/structured-clone": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz",
|
||||||
@@ -3871,13 +3874,13 @@
|
|||||||
"license": "Python-2.0"
|
"license": "Python-2.0"
|
||||||
},
|
},
|
||||||
"node_modules/aria-query": {
|
"node_modules/aria-query": {
|
||||||
"version": "5.1.3",
|
"version": "5.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.2.tgz",
|
||||||
"integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==",
|
"integrity": "sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"engines": {
|
||||||
"deep-equal": "^2.0.5"
|
"node": ">= 0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/array-buffer-byte-length": {
|
"node_modules/array-buffer-byte-length": {
|
||||||
@@ -5604,39 +5607,6 @@
|
|||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/deep-equal": {
|
|
||||||
"version": "2.2.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.3.tgz",
|
|
||||||
"integrity": "sha512-ZIwpnevOurS8bpT4192sqAowWM76JDKSHYzMLty3BZGSswgq6pBaH3DhCSW5xVAZICZyKdOBPjwww5wfgT/6PA==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"array-buffer-byte-length": "^1.0.0",
|
|
||||||
"call-bind": "^1.0.5",
|
|
||||||
"es-get-iterator": "^1.1.3",
|
|
||||||
"get-intrinsic": "^1.2.2",
|
|
||||||
"is-arguments": "^1.1.1",
|
|
||||||
"is-array-buffer": "^3.0.2",
|
|
||||||
"is-date-object": "^1.0.5",
|
|
||||||
"is-regex": "^1.1.4",
|
|
||||||
"is-shared-array-buffer": "^1.0.2",
|
|
||||||
"isarray": "^2.0.5",
|
|
||||||
"object-is": "^1.1.5",
|
|
||||||
"object-keys": "^1.1.1",
|
|
||||||
"object.assign": "^4.1.4",
|
|
||||||
"regexp.prototype.flags": "^1.5.1",
|
|
||||||
"side-channel": "^1.0.4",
|
|
||||||
"which-boxed-primitive": "^1.0.2",
|
|
||||||
"which-collection": "^1.0.1",
|
|
||||||
"which-typed-array": "^1.1.13"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.4"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/deep-extend": {
|
"node_modules/deep-extend": {
|
||||||
"version": "0.6.0",
|
"version": "0.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz",
|
||||||
@@ -6087,27 +6057,6 @@
|
|||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/es-get-iterator": {
|
|
||||||
"version": "1.1.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.3.tgz",
|
|
||||||
"integrity": "sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"call-bind": "^1.0.2",
|
|
||||||
"get-intrinsic": "^1.1.3",
|
|
||||||
"has-symbols": "^1.0.3",
|
|
||||||
"is-arguments": "^1.1.1",
|
|
||||||
"is-map": "^2.0.2",
|
|
||||||
"is-set": "^2.0.2",
|
|
||||||
"is-string": "^1.0.7",
|
|
||||||
"isarray": "^2.0.5",
|
|
||||||
"stop-iteration-iterator": "^1.0.0"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/es-iterator-helpers": {
|
"node_modules/es-iterator-helpers": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/es-iterator-helpers/-/es-iterator-helpers-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/es-iterator-helpers/-/es-iterator-helpers-1.1.0.tgz",
|
||||||
@@ -6471,13 +6420,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint-plugin-jsx-a11y": {
|
"node_modules/eslint-plugin-jsx-a11y": {
|
||||||
"version": "6.10.0",
|
"version": "6.10.2",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.10.2.tgz",
|
||||||
"integrity": "sha512-ySOHvXX8eSN6zz8Bywacm7CvGNhUtdjvqfQDVe6020TUK34Cywkw7m0KsCCk1Qtm9G1FayfTN1/7mMYnYO2Bhg==",
|
"integrity": "sha512-scB3nz4WmG75pV8+3eRUQOHZlNSUhFNq37xnpgRkCCELU3XMvXAxLk1eqWWyE22Ki4Q01Fnsw9BA3cJHDPgn2Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"aria-query": "~5.1.3",
|
"aria-query": "^5.3.2",
|
||||||
"array-includes": "^3.1.8",
|
"array-includes": "^3.1.8",
|
||||||
"array.prototype.flatmap": "^1.3.2",
|
"array.prototype.flatmap": "^1.3.2",
|
||||||
"ast-types-flow": "^0.0.8",
|
"ast-types-flow": "^0.0.8",
|
||||||
@@ -6485,14 +6434,13 @@
|
|||||||
"axobject-query": "^4.1.0",
|
"axobject-query": "^4.1.0",
|
||||||
"damerau-levenshtein": "^1.0.8",
|
"damerau-levenshtein": "^1.0.8",
|
||||||
"emoji-regex": "^9.2.2",
|
"emoji-regex": "^9.2.2",
|
||||||
"es-iterator-helpers": "^1.0.19",
|
|
||||||
"hasown": "^2.0.2",
|
"hasown": "^2.0.2",
|
||||||
"jsx-ast-utils": "^3.3.5",
|
"jsx-ast-utils": "^3.3.5",
|
||||||
"language-tags": "^1.0.9",
|
"language-tags": "^1.0.9",
|
||||||
"minimatch": "^3.1.2",
|
"minimatch": "^3.1.2",
|
||||||
"object.fromentries": "^2.0.8",
|
"object.fromentries": "^2.0.8",
|
||||||
"safe-regex-test": "^1.0.3",
|
"safe-regex-test": "^1.0.3",
|
||||||
"string.prototype.includes": "^2.0.0"
|
"string.prototype.includes": "^2.0.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4.0"
|
"node": ">=4.0"
|
||||||
@@ -6526,9 +6474,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint-plugin-react": {
|
"node_modules/eslint-plugin-react": {
|
||||||
"version": "7.37.1",
|
"version": "7.37.2",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.37.1.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.37.2.tgz",
|
||||||
"integrity": "sha512-xwTnwDqzbDRA8uJ7BMxPs/EXRB3i8ZfnOIp8BsxEQkT0nHPp+WWceqGgo6rKb9ctNi8GJLDT4Go5HAWELa/WMg==",
|
"integrity": "sha512-EsTAnj9fLVr/GZleBLFbj/sSuXeWmp1eXIN60ceYnZveqEaUCyW4X+Vh4WTdUhCkW4xutXYqTXCUSyqD4rB75w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -6537,7 +6485,7 @@
|
|||||||
"array.prototype.flatmap": "^1.3.2",
|
"array.prototype.flatmap": "^1.3.2",
|
||||||
"array.prototype.tosorted": "^1.1.4",
|
"array.prototype.tosorted": "^1.1.4",
|
||||||
"doctrine": "^2.1.0",
|
"doctrine": "^2.1.0",
|
||||||
"es-iterator-helpers": "^1.0.19",
|
"es-iterator-helpers": "^1.1.0",
|
||||||
"estraverse": "^5.3.0",
|
"estraverse": "^5.3.0",
|
||||||
"hasown": "^2.0.2",
|
"hasown": "^2.0.2",
|
||||||
"jsx-ast-utils": "^2.4.1 || ^3.0.0",
|
"jsx-ast-utils": "^2.4.1 || ^3.0.0",
|
||||||
@@ -6559,16 +6507,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint-plugin-react-hooks": {
|
"node_modules/eslint-plugin-react-hooks": {
|
||||||
"version": "4.6.2",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-5.1.0.tgz",
|
||||||
"integrity": "sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==",
|
"integrity": "sha512-mpJRtPgHN2tNAvZ35AMfqeB3Xqeo273QxrHJsbBEPWODRM4r0yB6jfoROqKEYrOn27UtRPpcpHc2UqyBSuUNTw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0"
|
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint-plugin-react-refresh": {
|
"node_modules/eslint-plugin-react-refresh": {
|
||||||
@@ -8120,23 +8068,6 @@
|
|||||||
"url": "https://github.com/sponsors/wooorm"
|
"url": "https://github.com/sponsors/wooorm"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/is-arguments": {
|
|
||||||
"version": "1.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz",
|
|
||||||
"integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"call-bind": "^1.0.2",
|
|
||||||
"has-tostringtag": "^1.0.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.4"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/is-array-buffer": {
|
"node_modules/is-array-buffer": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.4.tgz",
|
||||||
@@ -10818,23 +10749,6 @@
|
|||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/object-is": {
|
|
||||||
"version": "1.1.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.6.tgz",
|
|
||||||
"integrity": "sha512-F8cZ+KfGlSGi09lJT7/Nd6KJZ9ygtvYC0/UYYLI9nmQKLMnydpB9yvbv9K1uSkEu7FU9vYPmVwLg328tX+ot3Q==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"call-bind": "^1.0.7",
|
|
||||||
"define-properties": "^1.2.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.4"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/object-keys": {
|
"node_modules/object-keys": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
|
||||||
@@ -13277,19 +13191,6 @@
|
|||||||
"stacktrace-gps": "^3.0.4"
|
"stacktrace-gps": "^3.0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/stop-iteration-iterator": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz",
|
|
||||||
"integrity": "sha512-iCGQj+0l0HOdZ2AEeBADlsRC+vsnDsZsbdSiH1yNSjcfKM7fdpCMfqAL/dwF5BLiw/XhRft/Wax6zQbhq2BcjQ==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"internal-slot": "^1.0.4"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/string_decoder": {
|
"node_modules/string_decoder": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
|
||||||
@@ -13349,14 +13250,18 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/string.prototype.includes": {
|
"node_modules/string.prototype.includes": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/string.prototype.includes/-/string.prototype.includes-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/string.prototype.includes/-/string.prototype.includes-2.0.1.tgz",
|
||||||
"integrity": "sha512-E34CkBgyeqNDcrbU76cDjL5JLcVrtSdYq0MEh/B10r17pRP4ciHLwTgnuLV8Ay6cgEMLkcBkFCKyFZ43YldYzg==",
|
"integrity": "sha512-o7+c9bW6zpAdJHTtujeePODAhkuicdAryFsfVKwA+wGw89wJ4GTY484WTucM9hLtDEOpOvI+aHnzqnC5lHp4Rg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"define-properties": "^1.1.3",
|
"call-bind": "^1.0.7",
|
||||||
"es-abstract": "^1.17.5"
|
"define-properties": "^1.2.1",
|
||||||
|
"es-abstract": "^1.23.3"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/string.prototype.matchall": {
|
"node_modules/string.prototype.matchall": {
|
||||||
@@ -14774,9 +14679,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/typescript": {
|
"node_modules/typescript": {
|
||||||
"version": "5.6.3",
|
"version": "5.7.2",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz",
|
||||||
"integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==",
|
"integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -15891,7 +15796,7 @@
|
|||||||
},
|
},
|
||||||
"plugin-runtime-types": {
|
"plugin-runtime-types": {
|
||||||
"name": "@yaakapp/api",
|
"name": "@yaakapp/api",
|
||||||
"version": "0.2.16",
|
"version": "0.2.17",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "^22.5.4"
|
"@types/node": "^22.5.4"
|
||||||
},
|
},
|
||||||
|
|||||||
16
package.json
16
package.json
@@ -33,17 +33,17 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tauri-apps/cli": "^2.1.0",
|
"@tauri-apps/cli": "^2.1.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.5.0",
|
"@typescript-eslint/eslint-plugin": "^8.18.1",
|
||||||
"@typescript-eslint/parser": "^8.5.0",
|
"@typescript-eslint/parser": "^8.18.1",
|
||||||
"eslint": "^8",
|
"eslint": "^8",
|
||||||
"eslint-config-prettier": "^8",
|
"eslint-config-prettier": "^8",
|
||||||
"eslint-plugin-import": "^2.30.0",
|
"eslint-plugin-import": "^2.31.0",
|
||||||
"eslint-plugin-jsx-a11y": "^6.10.0",
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||||
"eslint-plugin-react": "^7.35.2",
|
"eslint-plugin-react": "^7.37.2",
|
||||||
"eslint-plugin-react-hooks": "^4.6.2",
|
"eslint-plugin-react-hooks": "^5.1.0",
|
||||||
"nodejs-file-downloader": "^4.13.0",
|
"nodejs-file-downloader": "^4.13.0",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.4.2",
|
||||||
"typescript": "^5.6.2"
|
"typescript": "^5.7.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@yaakapp/api",
|
"name": "@yaakapp/api",
|
||||||
"version": "0.2.16",
|
"version": "0.2.17",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"typings": "./lib/index.d.ts",
|
"typings": "./lib/index.d.ts",
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
|
||||||
export type Environment = { model: "environment", id: string, workspaceId: string, createdAt: string, updatedAt: string, name: string, variables: Array<EnvironmentVariable>, };
|
export type Environment = { model: "environment", id: string, workspaceId: string, environmentId: string | null, createdAt: string, updatedAt: string, name: string, variables: Array<EnvironmentVariable>, };
|
||||||
|
|
||||||
export type EnvironmentVariable = { enabled?: boolean, name: string, value: string, };
|
export type EnvironmentVariable = { enabled?: boolean, name: string, value: string, };
|
||||||
|
|
||||||
export type Folder = { model: "folder", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, name: string, sortPriority: number, };
|
export type Folder = { model: "folder", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, name: string, description: string, sortPriority: number, };
|
||||||
|
|
||||||
export type GrpcMetadataEntry = { enabled?: boolean, name: string, value: string, };
|
export type GrpcMetadataEntry = { enabled?: boolean, name: string, value: string, };
|
||||||
|
|
||||||
export type GrpcRequest = { model: "grpc_request", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, authenticationType: string | null, authentication: Record<string, any>, message: string, metadata: Array<GrpcMetadataEntry>, method: string | null, name: string, service: string | null, sortPriority: number, url: string, };
|
export type GrpcRequest = { model: "grpc_request", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, authenticationType: string | null, authentication: Record<string, any>, description: string, message: string, metadata: Array<GrpcMetadataEntry>, method: string | null, name: string, service: string | null, sortPriority: number, url: string, };
|
||||||
|
|
||||||
export type HttpRequest = { model: "http_request", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, authentication: Record<string, any>, authenticationType: string | null, body: Record<string, any>, bodyType: string | null, headers: Array<HttpRequestHeader>, method: string, name: string, sortPriority: number, url: string, urlParameters: Array<HttpUrlParameter>, };
|
export type HttpRequest = { model: "http_request", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, authentication: Record<string, any>, authenticationType: string | null, body: Record<string, any>, bodyType: string | null, description: string, headers: Array<HttpRequestHeader>, method: string, name: string, sortPriority: number, url: string, urlParameters: Array<HttpUrlParameter>, };
|
||||||
|
|
||||||
export type HttpRequestHeader = { enabled?: boolean, name: string, value: string, };
|
export type HttpRequestHeader = { enabled?: boolean, name: string, value: string, };
|
||||||
|
|
||||||
@@ -22,4 +22,4 @@ export type HttpResponseState = "initialized" | "connected" | "closed";
|
|||||||
|
|
||||||
export type HttpUrlParameter = { enabled?: boolean, name: string, value: string, };
|
export type HttpUrlParameter = { enabled?: boolean, name: string, value: string, };
|
||||||
|
|
||||||
export type Workspace = { model: "workspace", id: string, createdAt: string, updatedAt: string, name: string, description: string, variables: Array<EnvironmentVariable>, settingValidateCertificates: boolean, settingFollowRedirects: boolean, settingRequestTimeout: number, };
|
export type Workspace = { model: "workspace", id: string, createdAt: string, updatedAt: string, name: string, description: string, settingValidateCertificates: boolean, settingFollowRedirects: boolean, settingRequestTimeout: number, };
|
||||||
|
|||||||
45
src-tauri/migrations/20241219140051_base-environments.sql
Normal file
45
src-tauri/migrations/20241219140051_base-environments.sql
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
-- Add the new field
|
||||||
|
ALTER TABLE environments
|
||||||
|
ADD COLUMN environment_id TEXT REFERENCES environments (id) ON DELETE CASCADE;
|
||||||
|
|
||||||
|
-- Create temporary column so we know which rows are meant to be base environments. We'll use this to update
|
||||||
|
-- child environments to point to them.
|
||||||
|
ALTER TABLE environments
|
||||||
|
ADD COLUMN migrated_base_env BOOLEAN DEFAULT FALSE NOT NULL;
|
||||||
|
|
||||||
|
-- Create a base environment for each workspace
|
||||||
|
INSERT INTO environments (id, workspace_id, name, variables, migrated_base_env)
|
||||||
|
SELECT (
|
||||||
|
-- This is the best way to generate a random string in SQLite, apparently
|
||||||
|
'ev_' || SUBSTR('abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23457789', (ABS(RANDOM()) % 57) + 1, 1) ||
|
||||||
|
SUBSTR('abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23457789', (ABS(RANDOM()) % 57) + 1, 1) ||
|
||||||
|
SUBSTR('abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23457789', (ABS(RANDOM()) % 57) + 1, 1) ||
|
||||||
|
SUBSTR('abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23457789', (ABS(RANDOM()) % 57) + 1, 1) ||
|
||||||
|
SUBSTR('abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23457789', (ABS(RANDOM()) % 57) + 1, 1) ||
|
||||||
|
SUBSTR('abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23457789', (ABS(RANDOM()) % 57) + 1, 1) ||
|
||||||
|
SUBSTR('abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23457789', (ABS(RANDOM()) % 57) + 1, 1) ||
|
||||||
|
SUBSTR('abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23457789', (ABS(RANDOM()) % 57) + 1, 1) ||
|
||||||
|
SUBSTR('abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23457789', (ABS(RANDOM()) % 57) + 1, 1) ||
|
||||||
|
SUBSTR('abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23457789', (ABS(RANDOM()) % 57) + 1, 1)
|
||||||
|
),
|
||||||
|
workspaces.id,
|
||||||
|
'Global Variables',
|
||||||
|
variables,
|
||||||
|
TRUE
|
||||||
|
FROM workspaces;
|
||||||
|
|
||||||
|
-- Update all non-base environments to point to newly created base environments
|
||||||
|
UPDATE environments
|
||||||
|
SET environment_id = ( SELECT base_env.id
|
||||||
|
FROM environments AS base_env
|
||||||
|
WHERE base_env.workspace_id = environments.workspace_id
|
||||||
|
AND base_env.migrated_base_env IS TRUE )
|
||||||
|
WHERE migrated_base_env IS FALSE;
|
||||||
|
|
||||||
|
-- Drop temporary column
|
||||||
|
ALTER TABLE environments
|
||||||
|
DROP COLUMN migrated_base_env;
|
||||||
|
|
||||||
|
-- Drop the old variables column
|
||||||
|
-- IMPORTANT: Skip to give the user the option to roll back to a previous app version. We can drop it once the migration working in the real world
|
||||||
|
-- ALTER TABLE workspaces DROP COLUMN variables;
|
||||||
@@ -34,7 +34,7 @@ pub async fn get_workspace_export_resources(
|
|||||||
let app_handle = window.app_handle();
|
let app_handle = window.app_handle();
|
||||||
let mut data = WorkspaceExport {
|
let mut data = WorkspaceExport {
|
||||||
yaak_version: app_handle.package_info().version.clone().to_string(),
|
yaak_version: app_handle.package_info().version.clone().to_string(),
|
||||||
yaak_schema: 2,
|
yaak_schema: 3,
|
||||||
timestamp: chrono::Utc::now().naive_utc(),
|
timestamp: chrono::Utc::now().naive_utc(),
|
||||||
resources: WorkspaceExportResources {
|
resources: WorkspaceExportResources {
|
||||||
workspaces: Vec::new(),
|
workspaces: Vec::new(),
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ use yaak_models::models::{
|
|||||||
HttpResponseState, ProxySetting, ProxySettingAuth,
|
HttpResponseState, ProxySetting, ProxySettingAuth,
|
||||||
};
|
};
|
||||||
use yaak_models::queries::{
|
use yaak_models::queries::{
|
||||||
get_http_response, get_or_create_settings, get_workspace, update_response_if_id,
|
get_base_environment, get_http_response, get_or_create_settings, get_workspace,
|
||||||
upsert_cookie_jar,
|
update_response_if_id, upsert_cookie_jar,
|
||||||
};
|
};
|
||||||
use yaak_plugin_runtime::events::{RenderPurpose, WindowContext};
|
use yaak_plugin_runtime::events::{RenderPurpose, WindowContext};
|
||||||
|
|
||||||
@@ -43,6 +43,9 @@ pub async fn send_http_request<R: Runtime>(
|
|||||||
) -> Result<HttpResponse, String> {
|
) -> Result<HttpResponse, String> {
|
||||||
let workspace =
|
let workspace =
|
||||||
get_workspace(window, &request.workspace_id).await.expect("Failed to get Workspace");
|
get_workspace(window, &request.workspace_id).await.expect("Failed to get Workspace");
|
||||||
|
let base_environment = get_base_environment(window, &request.workspace_id)
|
||||||
|
.await
|
||||||
|
.expect("Failed to get base environment");
|
||||||
let settings = get_or_create_settings(window).await;
|
let settings = get_or_create_settings(window).await;
|
||||||
let cb = PluginTemplateCallback::new(
|
let cb = PluginTemplateCallback::new(
|
||||||
window.app_handle(),
|
window.app_handle(),
|
||||||
@@ -54,7 +57,7 @@ pub async fn send_http_request<R: Runtime>(
|
|||||||
let response = Arc::new(Mutex::new(og_response.clone()));
|
let response = Arc::new(Mutex::new(og_response.clone()));
|
||||||
|
|
||||||
let rendered_request =
|
let rendered_request =
|
||||||
render_http_request(&request, &workspace, environment.as_ref(), &cb).await;
|
render_http_request(&request, &base_environment, environment.as_ref(), &cb).await;
|
||||||
|
|
||||||
let mut url_string = rendered_request.url;
|
let mut url_string = rendered_request.url;
|
||||||
|
|
||||||
|
|||||||
@@ -56,14 +56,15 @@ use yaak_models::queries::{
|
|||||||
delete_cookie_jar, delete_environment, delete_folder, delete_grpc_connection,
|
delete_cookie_jar, delete_environment, delete_folder, delete_grpc_connection,
|
||||||
delete_grpc_request, delete_http_request, delete_http_response, delete_plugin,
|
delete_grpc_request, delete_http_request, delete_http_response, delete_plugin,
|
||||||
delete_workspace, duplicate_folder, duplicate_grpc_request, duplicate_http_request,
|
delete_workspace, duplicate_folder, duplicate_grpc_request, duplicate_http_request,
|
||||||
generate_id, generate_model_id, get_cookie_jar, get_environment, get_folder,
|
generate_id, generate_model_id, get_base_environment, get_cookie_jar, get_environment,
|
||||||
get_grpc_connection, get_grpc_request, get_http_request, get_http_response, get_key_value_raw,
|
get_folder, get_grpc_connection, get_grpc_request, get_http_request, get_http_response,
|
||||||
get_or_create_settings, get_plugin, get_workspace, list_cookie_jars, list_environments,
|
get_key_value_raw, get_or_create_settings, get_plugin, get_workspace, list_cookie_jars,
|
||||||
list_folders, list_grpc_connections_for_workspace, list_grpc_events, list_grpc_requests,
|
list_environments, list_folders, list_grpc_connections_for_workspace, list_grpc_events,
|
||||||
list_http_requests, list_http_responses_for_request, list_http_responses_for_workspace,
|
list_grpc_requests, list_http_requests, list_http_responses_for_request,
|
||||||
list_plugins, list_workspaces, set_key_value_raw, update_response_if_id, update_settings,
|
list_http_responses_for_workspace, list_plugins, list_workspaces, set_key_value_raw,
|
||||||
upsert_cookie_jar, upsert_environment, upsert_folder, upsert_grpc_connection,
|
update_response_if_id, update_settings, upsert_cookie_jar, upsert_environment, upsert_folder,
|
||||||
upsert_grpc_event, upsert_grpc_request, upsert_http_request, upsert_plugin, upsert_workspace,
|
upsert_grpc_connection, upsert_grpc_event, upsert_grpc_request, upsert_http_request,
|
||||||
|
upsert_plugin, upsert_workspace,
|
||||||
};
|
};
|
||||||
use yaak_plugin_runtime::events::{
|
use yaak_plugin_runtime::events::{
|
||||||
BootResponse, CallHttpRequestActionRequest, FilterResponse, FindHttpResponsesResponse,
|
BootResponse, CallHttpRequestActionRequest, FilterResponse, FindHttpResponsesResponse,
|
||||||
@@ -143,10 +144,11 @@ async fn cmd_render_template<R: Runtime>(
|
|||||||
Some(id) => Some(get_environment(&window, id).await.map_err(|e| e.to_string())?),
|
Some(id) => Some(get_environment(&window, id).await.map_err(|e| e.to_string())?),
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
let workspace = get_workspace(&window, &workspace_id).await.map_err(|e| e.to_string())?;
|
let base_environment =
|
||||||
|
get_base_environment(&window, &workspace_id).await.map_err(|e| e.to_string())?;
|
||||||
let rendered = render_template(
|
let rendered = render_template(
|
||||||
template,
|
template,
|
||||||
&workspace,
|
&base_environment,
|
||||||
environment.as_ref(),
|
environment.as_ref(),
|
||||||
&PluginTemplateCallback::new(
|
&PluginTemplateCallback::new(
|
||||||
&app_handle,
|
&app_handle,
|
||||||
@@ -208,10 +210,11 @@ async fn cmd_grpc_go<R: Runtime>(
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| e.to_string())?
|
.map_err(|e| e.to_string())?
|
||||||
.ok_or("Failed to find GRPC request")?;
|
.ok_or("Failed to find GRPC request")?;
|
||||||
let workspace = get_workspace(&window, &req.workspace_id).await.map_err(|e| e.to_string())?;
|
let base_environment =
|
||||||
|
get_base_environment(&window, &req.workspace_id).await.map_err(|e| e.to_string())?;
|
||||||
let req = render_grpc_request(
|
let req = render_grpc_request(
|
||||||
&req,
|
&req,
|
||||||
&workspace,
|
&base_environment,
|
||||||
environment.as_ref(),
|
environment.as_ref(),
|
||||||
&PluginTemplateCallback::new(
|
&PluginTemplateCallback::new(
|
||||||
window.app_handle(),
|
window.app_handle(),
|
||||||
@@ -337,7 +340,7 @@ async fn cmd_grpc_go<R: Runtime>(
|
|||||||
let cb = {
|
let cb = {
|
||||||
let cancelled_rx = cancelled_rx.clone();
|
let cancelled_rx = cancelled_rx.clone();
|
||||||
let window = window.clone();
|
let window = window.clone();
|
||||||
let workspace = workspace.clone();
|
let workspace = base_environment.clone();
|
||||||
let environment = environment.clone();
|
let environment = environment.clone();
|
||||||
let base_msg = base_msg.clone();
|
let base_msg = base_msg.clone();
|
||||||
let method_desc = method_desc.clone();
|
let method_desc = method_desc.clone();
|
||||||
@@ -433,7 +436,7 @@ async fn cmd_grpc_go<R: Runtime>(
|
|||||||
let msg = if req.message.is_empty() { "{}".to_string() } else { req.message };
|
let msg = if req.message.is_empty() { "{}".to_string() } else { req.message };
|
||||||
let msg = render_template(
|
let msg = render_template(
|
||||||
msg.as_str(),
|
msg.as_str(),
|
||||||
&workspace.clone(),
|
&base_environment.clone(),
|
||||||
environment.as_ref(),
|
environment.as_ref(),
|
||||||
&PluginTemplateCallback::new(
|
&PluginTemplateCallback::new(
|
||||||
window.app_handle(),
|
window.app_handle(),
|
||||||
@@ -852,12 +855,31 @@ async fn cmd_import_data<R: Runtime>(
|
|||||||
}
|
}
|
||||||
info!("Imported {} workspaces", imported_resources.workspaces.len());
|
info!("Imported {} workspaces", imported_resources.workspaces.len());
|
||||||
|
|
||||||
for mut v in resources.environments {
|
// Environments can foreign-key to themselves, so we need to import from
|
||||||
v.id = maybe_gen_id(v.id.as_str(), ModelType::TypeEnvironment, &mut id_map);
|
// the top of the tree to the bottom to avoid foreign key conflicts.
|
||||||
v.workspace_id =
|
// We do this by looping until we've imported them all, only importing if:
|
||||||
maybe_gen_id(v.workspace_id.as_str(), ModelType::TypeWorkspace, &mut id_map);
|
// - The parent has been imported
|
||||||
let x = upsert_environment(&window, v).await.map_err(|e| e.to_string())?;
|
// - The environment hasn't already been imported
|
||||||
imported_resources.environments.push(x.clone());
|
// The loop exits when imported.len == to_import.len
|
||||||
|
while imported_resources.environments.len() < resources.environments.len() {
|
||||||
|
for mut v in resources.environments.clone() {
|
||||||
|
v.id = maybe_gen_id(v.id.as_str(), ModelType::TypeEnvironment, &mut id_map);
|
||||||
|
v.workspace_id =
|
||||||
|
maybe_gen_id(v.workspace_id.as_str(), ModelType::TypeWorkspace, &mut id_map);
|
||||||
|
v.environment_id =
|
||||||
|
maybe_gen_id_opt(v.environment_id, ModelType::TypeEnvironment, &mut id_map);
|
||||||
|
if let Some(fid) = v.environment_id.clone() {
|
||||||
|
let imported_parent = imported_resources.environments.iter().find(|f| f.id == fid);
|
||||||
|
if imported_parent.is_none() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(_) = imported_resources.environments.iter().find(|f| f.id == v.id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let x = upsert_environment(&window, v).await.map_err(|e| e.to_string())?;
|
||||||
|
imported_resources.environments.push(x.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
info!("Imported {} environments", imported_resources.environments.len());
|
info!("Imported {} environments", imported_resources.environments.len());
|
||||||
|
|
||||||
@@ -2109,9 +2131,17 @@ async fn handle_plugin_event<R: Runtime>(
|
|||||||
.await
|
.await
|
||||||
.expect("Failed to get workspace_id from window URL");
|
.expect("Failed to get workspace_id from window URL");
|
||||||
let environment = environment_from_window(&window).await;
|
let environment = environment_from_window(&window).await;
|
||||||
|
let base_environment = get_base_environment(&window, workspace.id.as_str())
|
||||||
|
.await
|
||||||
|
.expect("Failed to get base environment");
|
||||||
let cb = PluginTemplateCallback::new(app_handle, &window_context, req.purpose);
|
let cb = PluginTemplateCallback::new(app_handle, &window_context, req.purpose);
|
||||||
let http_request =
|
let http_request = render_http_request(
|
||||||
render_http_request(&req.http_request, &workspace, environment.as_ref(), &cb).await;
|
&req.http_request,
|
||||||
|
&base_environment,
|
||||||
|
environment.as_ref(),
|
||||||
|
&cb,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
Some(InternalEventPayload::RenderHttpRequestResponse(RenderHttpRequestResponse {
|
Some(InternalEventPayload::RenderHttpRequestResponse(RenderHttpRequestResponse {
|
||||||
http_request,
|
http_request,
|
||||||
}))
|
}))
|
||||||
@@ -2124,8 +2154,12 @@ async fn handle_plugin_event<R: Runtime>(
|
|||||||
.await
|
.await
|
||||||
.expect("Failed to get workspace_id from window URL");
|
.expect("Failed to get workspace_id from window URL");
|
||||||
let environment = environment_from_window(&window).await;
|
let environment = environment_from_window(&window).await;
|
||||||
|
let base_environment = get_base_environment(&window, workspace.id.as_str())
|
||||||
|
.await
|
||||||
|
.expect("Failed to get base environment");
|
||||||
let cb = PluginTemplateCallback::new(app_handle, &window_context, req.purpose);
|
let cb = PluginTemplateCallback::new(app_handle, &window_context, req.purpose);
|
||||||
let data = render_json_value(req.data, &workspace, environment.as_ref(), &cb).await;
|
let data =
|
||||||
|
render_json_value(req.data, &base_environment, environment.as_ref(), &cb).await;
|
||||||
Some(InternalEventPayload::TemplateRenderResponse(TemplateRenderResponse { data }))
|
Some(InternalEventPayload::TemplateRenderResponse(TemplateRenderResponse { data }))
|
||||||
}
|
}
|
||||||
InternalEventPayload::ReloadResponse => {
|
InternalEventPayload::ReloadResponse => {
|
||||||
|
|||||||
@@ -3,37 +3,37 @@ use serde_json::{json, Map, Value};
|
|||||||
use std::collections::{BTreeMap, HashMap};
|
use std::collections::{BTreeMap, HashMap};
|
||||||
use yaak_models::models::{
|
use yaak_models::models::{
|
||||||
Environment, EnvironmentVariable, GrpcMetadataEntry, GrpcRequest, HttpRequest,
|
Environment, EnvironmentVariable, GrpcMetadataEntry, GrpcRequest, HttpRequest,
|
||||||
HttpRequestHeader, HttpUrlParameter, Workspace,
|
HttpRequestHeader, HttpUrlParameter,
|
||||||
};
|
};
|
||||||
use yaak_templates::{parse_and_render, TemplateCallback};
|
use yaak_templates::{parse_and_render, TemplateCallback};
|
||||||
|
|
||||||
pub async fn render_template<T: TemplateCallback>(
|
pub async fn render_template<T: TemplateCallback>(
|
||||||
template: &str,
|
template: &str,
|
||||||
w: &Workspace,
|
base_environment: &Environment,
|
||||||
e: Option<&Environment>,
|
environment: Option<&Environment>,
|
||||||
cb: &T,
|
cb: &T,
|
||||||
) -> String {
|
) -> String {
|
||||||
let vars = &make_vars_hashmap(w, e);
|
let vars = &make_vars_hashmap(base_environment, environment);
|
||||||
render(template, vars, cb).await
|
render(template, vars, cb).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn render_json_value<T: TemplateCallback>(
|
pub async fn render_json_value<T: TemplateCallback>(
|
||||||
value: Value,
|
value: Value,
|
||||||
w: &Workspace,
|
base_environment: &Environment,
|
||||||
e: Option<&Environment>,
|
environment: Option<&Environment>,
|
||||||
cb: &T,
|
cb: &T,
|
||||||
) -> Value {
|
) -> Value {
|
||||||
let vars = &make_vars_hashmap(w, e);
|
let vars = &make_vars_hashmap(base_environment, environment);
|
||||||
render_json_value_raw(value, vars, cb).await
|
render_json_value_raw(value, vars, cb).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn render_grpc_request<T: TemplateCallback>(
|
pub async fn render_grpc_request<T: TemplateCallback>(
|
||||||
r: &GrpcRequest,
|
r: &GrpcRequest,
|
||||||
w: &Workspace,
|
base_environment: &Environment,
|
||||||
e: Option<&Environment>,
|
environment: Option<&Environment>,
|
||||||
cb: &T,
|
cb: &T,
|
||||||
) -> GrpcRequest {
|
) -> GrpcRequest {
|
||||||
let vars = &make_vars_hashmap(w, e);
|
let vars = &make_vars_hashmap(base_environment, environment);
|
||||||
|
|
||||||
let mut metadata = Vec::new();
|
let mut metadata = Vec::new();
|
||||||
for p in r.metadata.clone() {
|
for p in r.metadata.clone() {
|
||||||
@@ -61,11 +61,11 @@ pub async fn render_grpc_request<T: TemplateCallback>(
|
|||||||
|
|
||||||
pub async fn render_http_request(
|
pub async fn render_http_request(
|
||||||
r: &HttpRequest,
|
r: &HttpRequest,
|
||||||
w: &Workspace,
|
base_environment: &Environment,
|
||||||
e: Option<&Environment>,
|
environment: Option<&Environment>,
|
||||||
cb: &PluginTemplateCallback,
|
cb: &PluginTemplateCallback,
|
||||||
) -> HttpRequest {
|
) -> HttpRequest {
|
||||||
let vars = &make_vars_hashmap(w, e);
|
let vars = &make_vars_hashmap(base_environment, environment);
|
||||||
|
|
||||||
let mut url_parameters = Vec::new();
|
let mut url_parameters = Vec::new();
|
||||||
for p in r.url_parameters.clone() {
|
for p in r.url_parameters.clone() {
|
||||||
@@ -110,11 +110,11 @@ pub async fn render_http_request(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn make_vars_hashmap(
|
pub fn make_vars_hashmap(
|
||||||
workspace: &Workspace,
|
base_environment: &Environment,
|
||||||
environment: Option<&Environment>,
|
environment: Option<&Environment>,
|
||||||
) -> HashMap<String, String> {
|
) -> HashMap<String, String> {
|
||||||
let mut variables = HashMap::new();
|
let mut variables = HashMap::new();
|
||||||
variables = add_variable_to_map(variables, &workspace.variables);
|
variables = add_variable_to_map(variables, &base_environment.variables);
|
||||||
|
|
||||||
if let Some(e) = environment {
|
if let Some(e) = environment {
|
||||||
variables = add_variable_to_map(variables, &e.variables);
|
variables = add_variable_to_map(variables, &e.variables);
|
||||||
|
|||||||
@@ -7233,19 +7233,15 @@ function pluginHookImport(ctx, contents) {
|
|||||||
};
|
};
|
||||||
const workspacesToImport = parsed.resources.filter(isWorkspace);
|
const workspacesToImport = parsed.resources.filter(isWorkspace);
|
||||||
for (const workspaceToImport of workspacesToImport) {
|
for (const workspaceToImport of workspacesToImport) {
|
||||||
const baseEnvironment = parsed.resources.find(
|
|
||||||
(r) => isEnvironment(r) && r.parentId === workspaceToImport._id
|
|
||||||
);
|
|
||||||
resources.workspaces.push({
|
resources.workspaces.push({
|
||||||
id: convertId(workspaceToImport._id),
|
id: convertId(workspaceToImport._id),
|
||||||
createdAt: new Date(workspacesToImport.created ?? Date.now()).toISOString().replace("Z", ""),
|
createdAt: new Date(workspacesToImport.created ?? Date.now()).toISOString().replace("Z", ""),
|
||||||
updatedAt: new Date(workspacesToImport.updated ?? Date.now()).toISOString().replace("Z", ""),
|
updatedAt: new Date(workspacesToImport.updated ?? Date.now()).toISOString().replace("Z", ""),
|
||||||
model: "workspace",
|
model: "workspace",
|
||||||
name: workspaceToImport.name,
|
name: workspaceToImport.name
|
||||||
variables: baseEnvironment ? parseVariables(baseEnvironment.data) : []
|
|
||||||
});
|
});
|
||||||
const environmentsToImport = parsed.resources.filter(
|
const environmentsToImport = parsed.resources.filter(
|
||||||
(r) => isEnvironment(r) && r.parentId === baseEnvironment?._id
|
(r) => isEnvironment(r)
|
||||||
);
|
);
|
||||||
resources.environments.push(
|
resources.environments.push(
|
||||||
...environmentsToImport.map((r) => importEnvironment(r, workspaceToImport._id))
|
...environmentsToImport.map((r) => importEnvironment(r, workspaceToImport._id))
|
||||||
@@ -7394,13 +7390,6 @@ function importHttpRequest(r, workspaceId, sortPriority = 0) {
|
|||||||
})).filter(({ name, value }) => name !== "" || value !== "")
|
})).filter(({ name, value }) => name !== "" || value !== "")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function parseVariables(data) {
|
|
||||||
return Object.entries(data).map(([name, value]) => ({
|
|
||||||
enabled: true,
|
|
||||||
name,
|
|
||||||
value: `${value}`
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
function convertSyntax(variable) {
|
function convertSyntax(variable) {
|
||||||
if (!isJSString(variable)) return variable;
|
if (!isJSString(variable)) return variable;
|
||||||
return variable.replaceAll(/{{\s*(_\.)?([^}]+)\s*}}/g, "${[$2]}");
|
return variable.replaceAll(/{{\s*(_\.)?([^}]+)\s*}}/g, "${[$2]}");
|
||||||
|
|||||||
@@ -145878,13 +145878,20 @@ function pluginHookImport(_ctx, contents) {
|
|||||||
model: "workspace",
|
model: "workspace",
|
||||||
id: generateId("workspace"),
|
id: generateId("workspace"),
|
||||||
name: info.name || "Postman Import",
|
name: info.name || "Postman Import",
|
||||||
description: info.description?.content ?? info.description ?? "",
|
description: info.description?.content ?? info.description ?? ""
|
||||||
|
};
|
||||||
|
exportResources.workspaces.push(workspace);
|
||||||
|
const environment = {
|
||||||
|
model: "environment",
|
||||||
|
id: generateId("environment"),
|
||||||
|
name: "Global Variables",
|
||||||
|
workspaceId: workspace.id,
|
||||||
variables: root.variable?.map((v) => ({
|
variables: root.variable?.map((v) => ({
|
||||||
name: v.key,
|
name: v.key,
|
||||||
value: v.value
|
value: v.value
|
||||||
})) ?? []
|
})) ?? []
|
||||||
};
|
};
|
||||||
exportResources.workspaces.push(workspace);
|
exportResources.environments.push(environment);
|
||||||
const importItem = (v, folderId = null) => {
|
const importItem = (v, folderId = null) => {
|
||||||
if (typeof v.name === "string" && Array.isArray(v.item)) {
|
if (typeof v.name === "string" && Array.isArray(v.item)) {
|
||||||
const folder = {
|
const folder = {
|
||||||
|
|||||||
@@ -45,13 +45,20 @@ function pluginHookImport(_ctx, contents) {
|
|||||||
model: "workspace",
|
model: "workspace",
|
||||||
id: generateId("workspace"),
|
id: generateId("workspace"),
|
||||||
name: info.name || "Postman Import",
|
name: info.name || "Postman Import",
|
||||||
description: info.description?.content ?? info.description ?? "",
|
description: info.description?.content ?? info.description ?? ""
|
||||||
|
};
|
||||||
|
exportResources.workspaces.push(workspace);
|
||||||
|
const environment = {
|
||||||
|
model: "environment",
|
||||||
|
id: generateId("environment"),
|
||||||
|
name: "Global Variables",
|
||||||
|
workspaceId: workspace.id,
|
||||||
variables: root.variable?.map((v) => ({
|
variables: root.variable?.map((v) => ({
|
||||||
name: v.key,
|
name: v.key,
|
||||||
value: v.value
|
value: v.value
|
||||||
})) ?? []
|
})) ?? []
|
||||||
};
|
};
|
||||||
exportResources.workspaces.push(workspace);
|
exportResources.environments.push(environment);
|
||||||
const importItem = (v, folderId = null) => {
|
const importItem = (v, folderId = null) => {
|
||||||
if (typeof v.name === "string" && Array.isArray(v.item)) {
|
if (typeof v.name === "string" && Array.isArray(v.item)) {
|
||||||
const folder = {
|
const folder = {
|
||||||
|
|||||||
@@ -41,6 +41,24 @@ function pluginHookImport(_ctx, contents) {
|
|||||||
parsed.resources.httpRequests = parsed.resources.requests;
|
parsed.resources.httpRequests = parsed.resources.requests;
|
||||||
delete parsed.resources["requests"];
|
delete parsed.resources["requests"];
|
||||||
}
|
}
|
||||||
|
for (const workspace of parsed.resources.workspaces ?? []) {
|
||||||
|
if ("variables" in workspace) {
|
||||||
|
const baseEnvironment = {
|
||||||
|
id: `GENERATE_ID::base_env_${workspace["id"]}`,
|
||||||
|
name: "Global Variables",
|
||||||
|
variables: workspace.variables,
|
||||||
|
workspaceId: workspace.id
|
||||||
|
};
|
||||||
|
parsed.resources.environments = parsed.resources.environments ?? [];
|
||||||
|
parsed.resources.environments.push(baseEnvironment);
|
||||||
|
delete workspace.variables;
|
||||||
|
for (const environment of parsed.resources.environments) {
|
||||||
|
if (environment.workspaceId === workspace.id && environment.id !== baseEnvironment.id) {
|
||||||
|
environment.environmentId = baseEnvironment.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return { resources: parsed.resources };
|
return { resources: parsed.resources };
|
||||||
}
|
}
|
||||||
function isJSObject(obj) {
|
function isJSObject(obj) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export type CookieExpires = { "AtUtc": string } | "SessionEnd";
|
|||||||
|
|
||||||
export type CookieJar = { model: "cookie_jar", id: string, createdAt: string, updatedAt: string, workspaceId: string, cookies: Array<Cookie>, name: string, };
|
export type CookieJar = { model: "cookie_jar", id: string, createdAt: string, updatedAt: string, workspaceId: string, cookies: Array<Cookie>, name: string, };
|
||||||
|
|
||||||
export type Environment = { model: "environment", id: string, workspaceId: string, createdAt: string, updatedAt: string, name: string, variables: Array<EnvironmentVariable>, };
|
export type Environment = { model: "environment", id: string, workspaceId: string, environmentId: string | null, createdAt: string, updatedAt: string, name: string, variables: Array<EnvironmentVariable>, };
|
||||||
|
|
||||||
export type EnvironmentVariable = { enabled?: boolean, name: string, value: string, };
|
export type EnvironmentVariable = { enabled?: boolean, name: string, value: string, };
|
||||||
|
|
||||||
@@ -50,4 +50,4 @@ export type ProxySettingAuth = { user: string, password: string, };
|
|||||||
|
|
||||||
export type Settings = { model: "settings", id: string, createdAt: string, updatedAt: string, appearance: string, editorFontSize: number, editorSoftWrap: boolean, interfaceFontSize: number, interfaceScale: number, openWorkspaceNewWindow: boolean | null, telemetry: boolean, theme: string, themeDark: string, themeLight: string, updateChannel: string, proxy: ProxySetting | null, };
|
export type Settings = { model: "settings", id: string, createdAt: string, updatedAt: string, appearance: string, editorFontSize: number, editorSoftWrap: boolean, interfaceFontSize: number, interfaceScale: number, openWorkspaceNewWindow: boolean | null, telemetry: boolean, theme: string, themeDark: string, themeLight: string, updateChannel: string, proxy: ProxySetting | null, };
|
||||||
|
|
||||||
export type Workspace = { model: "workspace", id: string, createdAt: string, updatedAt: string, name: string, description: string, variables: Array<EnvironmentVariable>, settingValidateCertificates: boolean, settingFollowRedirects: boolean, settingRequestTimeout: number, };
|
export type Workspace = { model: "workspace", id: string, createdAt: string, updatedAt: string, name: string, description: string, settingValidateCertificates: boolean, settingFollowRedirects: boolean, settingRequestTimeout: number, };
|
||||||
|
|||||||
@@ -110,7 +110,6 @@ pub struct Workspace {
|
|||||||
pub updated_at: NaiveDateTime,
|
pub updated_at: NaiveDateTime,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub description: String,
|
pub description: String,
|
||||||
pub variables: Vec<EnvironmentVariable>,
|
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
#[serde(default = "default_true")]
|
#[serde(default = "default_true")]
|
||||||
@@ -134,14 +133,12 @@ pub enum WorkspaceIden {
|
|||||||
SettingFollowRedirects,
|
SettingFollowRedirects,
|
||||||
SettingRequestTimeout,
|
SettingRequestTimeout,
|
||||||
SettingValidateCertificates,
|
SettingValidateCertificates,
|
||||||
Variables,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'s> TryFrom<&Row<'s>> for Workspace {
|
impl<'s> TryFrom<&Row<'s>> for Workspace {
|
||||||
type Error = rusqlite::Error;
|
type Error = rusqlite::Error;
|
||||||
|
|
||||||
fn try_from(r: &Row<'s>) -> Result<Self, Self::Error> {
|
fn try_from(r: &Row<'s>) -> Result<Self, Self::Error> {
|
||||||
let variables: String = r.get("variables")?;
|
|
||||||
Ok(Workspace {
|
Ok(Workspace {
|
||||||
id: r.get("id")?,
|
id: r.get("id")?,
|
||||||
model: r.get("model")?,
|
model: r.get("model")?,
|
||||||
@@ -149,7 +146,6 @@ impl<'s> TryFrom<&Row<'s>> for Workspace {
|
|||||||
updated_at: r.get("updated_at")?,
|
updated_at: r.get("updated_at")?,
|
||||||
name: r.get("name")?,
|
name: r.get("name")?,
|
||||||
description: r.get("description")?,
|
description: r.get("description")?,
|
||||||
variables: serde_json::from_str(variables.as_str()).unwrap_or_default(),
|
|
||||||
setting_validate_certificates: r.get("setting_validate_certificates")?,
|
setting_validate_certificates: r.get("setting_validate_certificates")?,
|
||||||
setting_follow_redirects: r.get("setting_follow_redirects")?,
|
setting_follow_redirects: r.get("setting_follow_redirects")?,
|
||||||
setting_request_timeout: r.get("setting_request_timeout")?,
|
setting_request_timeout: r.get("setting_request_timeout")?,
|
||||||
@@ -248,6 +244,7 @@ pub struct Environment {
|
|||||||
pub model: String,
|
pub model: String,
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub workspace_id: String,
|
pub workspace_id: String,
|
||||||
|
pub environment_id: Option<String>,
|
||||||
pub created_at: NaiveDateTime,
|
pub created_at: NaiveDateTime,
|
||||||
pub updated_at: NaiveDateTime,
|
pub updated_at: NaiveDateTime,
|
||||||
|
|
||||||
@@ -263,6 +260,7 @@ pub enum EnvironmentIden {
|
|||||||
Id,
|
Id,
|
||||||
CreatedAt,
|
CreatedAt,
|
||||||
UpdatedAt,
|
UpdatedAt,
|
||||||
|
EnvironmentId,
|
||||||
WorkspaceId,
|
WorkspaceId,
|
||||||
|
|
||||||
Name,
|
Name,
|
||||||
@@ -278,6 +276,7 @@ impl<'s> TryFrom<&Row<'s>> for Environment {
|
|||||||
id: r.get("id")?,
|
id: r.get("id")?,
|
||||||
model: r.get("model")?,
|
model: r.get("model")?,
|
||||||
workspace_id: r.get("workspace_id")?,
|
workspace_id: r.get("workspace_id")?,
|
||||||
|
environment_id: r.get("environment_id")?,
|
||||||
created_at: r.get("created_at")?,
|
created_at: r.get("created_at")?,
|
||||||
updated_at: r.get("updated_at")?,
|
updated_at: r.get("updated_at")?,
|
||||||
name: r.get("name")?,
|
name: r.get("name")?,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use crate::models::{
|
|||||||
Settings, SettingsIden, Workspace, WorkspaceIden,
|
Settings, SettingsIden, Workspace, WorkspaceIden,
|
||||||
};
|
};
|
||||||
use crate::plugin::SqliteConnection;
|
use crate::plugin::SqliteConnection;
|
||||||
use log::{debug, error};
|
use log::{debug, error, info};
|
||||||
use rand::distributions::{Alphanumeric, DistString};
|
use rand::distributions::{Alphanumeric, DistString};
|
||||||
use rusqlite::OptionalExtension;
|
use rusqlite::OptionalExtension;
|
||||||
use sea_query::ColumnRef::Asterisk;
|
use sea_query::ColumnRef::Asterisk;
|
||||||
@@ -191,7 +191,6 @@ pub async fn upsert_workspace<R: Runtime>(
|
|||||||
WorkspaceIden::UpdatedAt,
|
WorkspaceIden::UpdatedAt,
|
||||||
WorkspaceIden::Name,
|
WorkspaceIden::Name,
|
||||||
WorkspaceIden::Description,
|
WorkspaceIden::Description,
|
||||||
WorkspaceIden::Variables,
|
|
||||||
WorkspaceIden::SettingRequestTimeout,
|
WorkspaceIden::SettingRequestTimeout,
|
||||||
WorkspaceIden::SettingFollowRedirects,
|
WorkspaceIden::SettingFollowRedirects,
|
||||||
WorkspaceIden::SettingValidateCertificates,
|
WorkspaceIden::SettingValidateCertificates,
|
||||||
@@ -202,7 +201,6 @@ pub async fn upsert_workspace<R: Runtime>(
|
|||||||
CurrentTimestamp.into(),
|
CurrentTimestamp.into(),
|
||||||
trimmed_name.into(),
|
trimmed_name.into(),
|
||||||
workspace.description.into(),
|
workspace.description.into(),
|
||||||
serde_json::to_string(&workspace.variables)?.into(),
|
|
||||||
workspace.setting_request_timeout.into(),
|
workspace.setting_request_timeout.into(),
|
||||||
workspace.setting_follow_redirects.into(),
|
workspace.setting_follow_redirects.into(),
|
||||||
workspace.setting_validate_certificates.into(),
|
workspace.setting_validate_certificates.into(),
|
||||||
@@ -213,7 +211,6 @@ pub async fn upsert_workspace<R: Runtime>(
|
|||||||
WorkspaceIden::UpdatedAt,
|
WorkspaceIden::UpdatedAt,
|
||||||
WorkspaceIden::Name,
|
WorkspaceIden::Name,
|
||||||
WorkspaceIden::Description,
|
WorkspaceIden::Description,
|
||||||
WorkspaceIden::Variables,
|
|
||||||
WorkspaceIden::SettingRequestTimeout,
|
WorkspaceIden::SettingRequestTimeout,
|
||||||
WorkspaceIden::SettingFollowRedirects,
|
WorkspaceIden::SettingFollowRedirects,
|
||||||
WorkspaceIden::SettingValidateCertificates,
|
WorkspaceIden::SettingValidateCertificates,
|
||||||
@@ -739,21 +736,41 @@ pub async fn upsert_cookie_jar<R: Runtime>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn list_environments<R: Runtime>(
|
pub async fn list_environments<R: Runtime>(
|
||||||
mgr: &impl Manager<R>,
|
window: &WebviewWindow<R>,
|
||||||
workspace_id: &str,
|
workspace_id: &str,
|
||||||
) -> Result<Vec<Environment>> {
|
) -> Result<Vec<Environment>> {
|
||||||
let dbm = &*mgr.state::<SqliteConnection>();
|
let mut environments: Vec<Environment> = {
|
||||||
let db = dbm.0.lock().await.get().unwrap();
|
let dbm = &*window.state::<SqliteConnection>();
|
||||||
|
let db = dbm.0.lock().await.get().unwrap();
|
||||||
|
let (sql, params) = Query::select()
|
||||||
|
.from(EnvironmentIden::Table)
|
||||||
|
.cond_where(Expr::col(EnvironmentIden::WorkspaceId).eq(workspace_id))
|
||||||
|
.column(Asterisk)
|
||||||
|
.order_by(EnvironmentIden::CreatedAt, Order::Desc)
|
||||||
|
.build_rusqlite(SqliteQueryBuilder);
|
||||||
|
let mut stmt = db.prepare(sql.as_str())?;
|
||||||
|
let items = stmt.query_map(&*params.as_params(), |row| row.try_into())?;
|
||||||
|
items.map(|v| v.unwrap()).collect()
|
||||||
|
};
|
||||||
|
|
||||||
let (sql, params) = Query::select()
|
let base_environment =
|
||||||
.from(EnvironmentIden::Table)
|
environments.iter().find(|e| e.environment_id == None && e.workspace_id == workspace_id);
|
||||||
.cond_where(Expr::col(EnvironmentIden::WorkspaceId).eq(workspace_id))
|
|
||||||
.column(Asterisk)
|
if let None = base_environment {
|
||||||
.order_by(EnvironmentIden::CreatedAt, Order::Desc)
|
let base_environment = upsert_environment(
|
||||||
.build_rusqlite(SqliteQueryBuilder);
|
window,
|
||||||
let mut stmt = db.prepare(sql.as_str())?;
|
Environment {
|
||||||
let items = stmt.query_map(&*params.as_params(), |row| row.try_into())?;
|
workspace_id: workspace_id.to_string(),
|
||||||
Ok(items.map(|v| v.unwrap()).collect())
|
name: "Global Variables".to_string(),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
info!("Created base environment for {workspace_id}");
|
||||||
|
environments.push(base_environment);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(environments)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete_environment<R: Runtime>(
|
pub async fn delete_environment<R: Runtime>(
|
||||||
@@ -839,7 +856,7 @@ pub async fn update_settings<R: Runtime>(
|
|||||||
None => None,
|
None => None,
|
||||||
Some(p) => Some(serde_json::to_string(&p)?),
|
Some(p) => Some(serde_json::to_string(&p)?),
|
||||||
})
|
})
|
||||||
.into(),
|
.into(),
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
.returning_all()
|
.returning_all()
|
||||||
@@ -869,6 +886,7 @@ pub async fn upsert_environment<R: Runtime>(
|
|||||||
EnvironmentIden::Id,
|
EnvironmentIden::Id,
|
||||||
EnvironmentIden::CreatedAt,
|
EnvironmentIden::CreatedAt,
|
||||||
EnvironmentIden::UpdatedAt,
|
EnvironmentIden::UpdatedAt,
|
||||||
|
EnvironmentIden::EnvironmentId,
|
||||||
EnvironmentIden::WorkspaceId,
|
EnvironmentIden::WorkspaceId,
|
||||||
EnvironmentIden::Name,
|
EnvironmentIden::Name,
|
||||||
EnvironmentIden::Variables,
|
EnvironmentIden::Variables,
|
||||||
@@ -877,7 +895,8 @@ pub async fn upsert_environment<R: Runtime>(
|
|||||||
id.as_str().into(),
|
id.as_str().into(),
|
||||||
CurrentTimestamp.into(),
|
CurrentTimestamp.into(),
|
||||||
CurrentTimestamp.into(),
|
CurrentTimestamp.into(),
|
||||||
environment.workspace_id.as_str().into(),
|
environment.environment_id.into(),
|
||||||
|
environment.workspace_id.into(),
|
||||||
trimmed_name.into(),
|
trimmed_name.into(),
|
||||||
serde_json::to_string(&environment.variables)?.into(),
|
serde_json::to_string(&environment.variables)?.into(),
|
||||||
])
|
])
|
||||||
@@ -911,6 +930,26 @@ pub async fn get_environment<R: Runtime>(mgr: &impl Manager<R>, id: &str) -> Res
|
|||||||
Ok(stmt.query_row(&*params.as_params(), |row| row.try_into())?)
|
Ok(stmt.query_row(&*params.as_params(), |row| row.try_into())?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_base_environment<R: Runtime>(
|
||||||
|
mgr: &impl Manager<R>,
|
||||||
|
workspace_id: &str,
|
||||||
|
) -> Result<Environment> {
|
||||||
|
let dbm = &*mgr.state::<SqliteConnection>();
|
||||||
|
let db = dbm.0.lock().await.get().unwrap();
|
||||||
|
|
||||||
|
let (sql, params) = Query::select()
|
||||||
|
.from(EnvironmentIden::Table)
|
||||||
|
.column(Asterisk)
|
||||||
|
.cond_where(
|
||||||
|
Cond::all()
|
||||||
|
.add(Expr::col(EnvironmentIden::WorkspaceId).eq(workspace_id))
|
||||||
|
.add(Expr::col(EnvironmentIden::EnvironmentId).is_null()),
|
||||||
|
)
|
||||||
|
.build_rusqlite(SqliteQueryBuilder);
|
||||||
|
let mut stmt = db.prepare(sql.as_str())?;
|
||||||
|
Ok(stmt.query_row(&*params.as_params(), |row| row.try_into())?)
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn get_plugin<R: Runtime>(mgr: &impl Manager<R>, id: &str) -> Result<Plugin> {
|
pub async fn get_plugin<R: Runtime>(mgr: &impl Manager<R>, id: &str) -> Result<Plugin> {
|
||||||
let dbm = &*mgr.state::<SqliteConnection>();
|
let dbm = &*mgr.state::<SqliteConnection>();
|
||||||
let db = dbm.0.lock().await.get().unwrap();
|
let db = dbm.0.lock().await.get().unwrap();
|
||||||
@@ -1142,7 +1181,7 @@ pub async fn duplicate_folder<R: Runtime>(
|
|||||||
..src_folder.clone()
|
..src_folder.clone()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
for m in http_requests {
|
for m in http_requests {
|
||||||
upsert_http_request(
|
upsert_http_request(
|
||||||
@@ -1154,7 +1193,7 @@ pub async fn duplicate_folder<R: Runtime>(
|
|||||||
..m
|
..m
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
for m in grpc_requests {
|
for m in grpc_requests {
|
||||||
upsert_grpc_request(
|
upsert_grpc_request(
|
||||||
@@ -1166,7 +1205,7 @@ pub async fn duplicate_folder<R: Runtime>(
|
|||||||
..m
|
..m
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
for m in folders {
|
for m in folders {
|
||||||
// Recurse down
|
// Recurse down
|
||||||
@@ -1177,7 +1216,7 @@ pub async fn duplicate_folder<R: Runtime>(
|
|||||||
..m
|
..m
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -1336,7 +1375,7 @@ pub async fn create_default_http_response<R: Runtime>(
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||||
|
|
||||||
export type Environment = { model: "environment", id: string, workspaceId: string, createdAt: string, updatedAt: string, name: string, variables: Array<EnvironmentVariable>, };
|
export type Environment = { model: "environment", id: string, workspaceId: string, environmentId: string | null, createdAt: string, updatedAt: string, name: string, variables: Array<EnvironmentVariable>, };
|
||||||
|
|
||||||
export type EnvironmentVariable = { enabled?: boolean, name: string, value: string, };
|
export type EnvironmentVariable = { enabled?: boolean, name: string, value: string, };
|
||||||
|
|
||||||
export type Folder = { model: "folder", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, name: string, sortPriority: number, };
|
export type Folder = { model: "folder", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, name: string, description: string, sortPriority: number, };
|
||||||
|
|
||||||
export type GrpcMetadataEntry = { enabled?: boolean, name: string, value: string, };
|
export type GrpcMetadataEntry = { enabled?: boolean, name: string, value: string, };
|
||||||
|
|
||||||
export type GrpcRequest = { model: "grpc_request", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, authenticationType: string | null, authentication: Record<string, any>, message: string, metadata: Array<GrpcMetadataEntry>, method: string | null, name: string, service: string | null, sortPriority: number, url: string, };
|
export type GrpcRequest = { model: "grpc_request", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, authenticationType: string | null, authentication: Record<string, any>, description: string, message: string, metadata: Array<GrpcMetadataEntry>, method: string | null, name: string, service: string | null, sortPriority: number, url: string, };
|
||||||
|
|
||||||
export type HttpRequest = { model: "http_request", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, authentication: Record<string, any>, authenticationType: string | null, body: Record<string, any>, bodyType: string | null, headers: Array<HttpRequestHeader>, method: string, name: string, sortPriority: number, url: string, urlParameters: Array<HttpUrlParameter>, };
|
export type HttpRequest = { model: "http_request", id: string, createdAt: string, updatedAt: string, workspaceId: string, folderId: string | null, authentication: Record<string, any>, authenticationType: string | null, body: Record<string, any>, bodyType: string | null, description: string, headers: Array<HttpRequestHeader>, method: string, name: string, sortPriority: number, url: string, urlParameters: Array<HttpUrlParameter>, };
|
||||||
|
|
||||||
export type HttpRequestHeader = { enabled?: boolean, name: string, value: string, };
|
export type HttpRequestHeader = { enabled?: boolean, name: string, value: string, };
|
||||||
|
|
||||||
@@ -22,4 +22,4 @@ export type HttpResponseState = "initialized" | "connected" | "closed";
|
|||||||
|
|
||||||
export type HttpUrlParameter = { enabled?: boolean, name: string, value: string, };
|
export type HttpUrlParameter = { enabled?: boolean, name: string, value: string, };
|
||||||
|
|
||||||
export type Workspace = { model: "workspace", id: string, createdAt: string, updatedAt: string, name: string, description: string, variables: Array<EnvironmentVariable>, settingValidateCertificates: boolean, settingFollowRedirects: boolean, settingRequestTimeout: number, };
|
export type Workspace = { model: "workspace", id: string, createdAt: string, updatedAt: string, name: string, description: string, settingValidateCertificates: boolean, settingFollowRedirects: boolean, settingRequestTimeout: number, };
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export function CommandPalette({ onClose }: { onClose: () => void }) {
|
|||||||
const [activeEnvironment, setActiveEnvironmentId] = useActiveEnvironment();
|
const [activeEnvironment, setActiveEnvironmentId] = useActiveEnvironment();
|
||||||
const httpRequestActions = useHttpRequestActions();
|
const httpRequestActions = useHttpRequestActions();
|
||||||
const workspaces = useWorkspaces();
|
const workspaces = useWorkspaces();
|
||||||
const environments = useEnvironments();
|
const { subEnvironments } = useEnvironments();
|
||||||
const recentEnvironments = useRecentEnvironments();
|
const recentEnvironments = useRecentEnvironments();
|
||||||
const recentWorkspaces = useRecentWorkspaces();
|
const recentWorkspaces = useRecentWorkspaces();
|
||||||
const requests = useRequests();
|
const requests = useRequests();
|
||||||
@@ -211,7 +211,7 @@ export function CommandPalette({ onClose }: { onClose: () => void }) {
|
|||||||
}, [recentRequests, requests]);
|
}, [recentRequests, requests]);
|
||||||
|
|
||||||
const sortedEnvironments = useMemo(() => {
|
const sortedEnvironments = useMemo(() => {
|
||||||
return [...environments].sort((a, b) => {
|
return [...subEnvironments].sort((a, b) => {
|
||||||
const aRecentIndex = recentEnvironments.indexOf(a.id);
|
const aRecentIndex = recentEnvironments.indexOf(a.id);
|
||||||
const bRecentIndex = recentEnvironments.indexOf(b.id);
|
const bRecentIndex = recentEnvironments.indexOf(b.id);
|
||||||
|
|
||||||
@@ -225,7 +225,7 @@ export function CommandPalette({ onClose }: { onClose: () => void }) {
|
|||||||
return a.createdAt.localeCompare(b.createdAt);
|
return a.createdAt.localeCompare(b.createdAt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [environments, recentEnvironments]);
|
}, [subEnvironments, recentEnvironments]);
|
||||||
|
|
||||||
const sortedWorkspaces = useMemo(() => {
|
const sortedWorkspaces = useMemo(() => {
|
||||||
return [...workspaces].sort((a, b) => {
|
return [...workspaces].sort((a, b) => {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { memo, useCallback, useMemo } from 'react';
|
import { memo, useCallback, useMemo } from 'react';
|
||||||
import { useActiveEnvironment } from '../hooks/useActiveEnvironment';
|
import { useActiveEnvironment } from '../hooks/useActiveEnvironment';
|
||||||
import { useActiveWorkspace } from '../hooks/useActiveWorkspace';
|
|
||||||
import { useEnvironments } from '../hooks/useEnvironments';
|
import { useEnvironments } from '../hooks/useEnvironments';
|
||||||
import type { ButtonProps } from './core/Button';
|
import type { ButtonProps } from './core/Button';
|
||||||
import { Button } from './core/Button';
|
import { Button } from './core/Button';
|
||||||
@@ -19,8 +18,7 @@ export const EnvironmentActionsDropdown = memo(function EnvironmentActionsDropdo
|
|||||||
className,
|
className,
|
||||||
...buttonProps
|
...buttonProps
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const environments = useEnvironments();
|
const { subEnvironments, baseEnvironment } = useEnvironments();
|
||||||
const activeWorkspace = useActiveWorkspace();
|
|
||||||
const [activeEnvironment, setActiveEnvironmentId] = useActiveEnvironment();
|
const [activeEnvironment, setActiveEnvironmentId] = useActiveEnvironment();
|
||||||
const dialog = useDialog();
|
const dialog = useDialog();
|
||||||
|
|
||||||
@@ -36,7 +34,7 @@ export const EnvironmentActionsDropdown = memo(function EnvironmentActionsDropdo
|
|||||||
|
|
||||||
const items: DropdownItem[] = useMemo(
|
const items: DropdownItem[] = useMemo(
|
||||||
() => [
|
() => [
|
||||||
...environments.map(
|
...subEnvironments.map(
|
||||||
(e) => ({
|
(e) => ({
|
||||||
key: e.id,
|
key: e.id,
|
||||||
label: e.name,
|
label: e.name,
|
||||||
@@ -51,7 +49,7 @@ export const EnvironmentActionsDropdown = memo(function EnvironmentActionsDropdo
|
|||||||
}),
|
}),
|
||||||
[activeEnvironment?.id],
|
[activeEnvironment?.id],
|
||||||
),
|
),
|
||||||
...((environments.length > 0
|
...((subEnvironments.length > 0
|
||||||
? [{ type: 'separator', label: 'Environments' }]
|
? [{ type: 'separator', label: 'Environments' }]
|
||||||
: []) as DropdownItem[]),
|
: []) as DropdownItem[]),
|
||||||
{
|
{
|
||||||
@@ -62,11 +60,11 @@ export const EnvironmentActionsDropdown = memo(function EnvironmentActionsDropdo
|
|||||||
onSelect: showEnvironmentDialog,
|
onSelect: showEnvironmentDialog,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[activeEnvironment?.id, environments, setActiveEnvironmentId, showEnvironmentDialog],
|
[activeEnvironment?.id, subEnvironments, setActiveEnvironmentId, showEnvironmentDialog],
|
||||||
);
|
);
|
||||||
|
|
||||||
const hasWorkspaceVars =
|
const hasBaseVars =
|
||||||
(activeWorkspace?.variables ?? []).filter((v) => v.enabled && (v.name || v.value)).length > 0;
|
(baseEnvironment?.variables ?? []).filter((v) => v.enabled && (v.name || v.value)).length > 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dropdown items={items}>
|
<Dropdown items={items}>
|
||||||
@@ -75,14 +73,14 @@ export const EnvironmentActionsDropdown = memo(function EnvironmentActionsDropdo
|
|||||||
className={classNames(
|
className={classNames(
|
||||||
className,
|
className,
|
||||||
'text !px-2 truncate',
|
'text !px-2 truncate',
|
||||||
!activeEnvironment && !hasWorkspaceVars && 'text-text-subtlest italic',
|
!activeEnvironment && !hasBaseVars && 'text-text-subtlest italic',
|
||||||
)}
|
)}
|
||||||
// If no environments, the button simply opens the dialog.
|
// If no environments, the button simply opens the dialog.
|
||||||
// NOTE: We don't create a new button because we want to reuse the hotkey from the menu items
|
// NOTE: We don't create a new button because we want to reuse the hotkey from the menu items
|
||||||
onClick={environments.length === 0 ? showEnvironmentDialog : undefined}
|
onClick={subEnvironments.length === 0 ? showEnvironmentDialog : undefined}
|
||||||
{...buttonProps}
|
{...buttonProps}
|
||||||
>
|
>
|
||||||
{activeEnvironment?.name ?? (hasWorkspaceVars ? 'Environment' : 'No Environment')}
|
{activeEnvironment?.name ?? (hasBaseVars ? 'Environment' : 'No Environment')}
|
||||||
</Button>
|
</Button>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
|
import type { Environment } from '@yaakapp-internal/models';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import React, { useCallback, useMemo, useState } from 'react';
|
import React, { useCallback, useMemo, useState } from 'react';
|
||||||
import { useActiveWorkspace } from '../hooks/useActiveWorkspace';
|
|
||||||
import { useCreateEnvironment } from '../hooks/useCreateEnvironment';
|
import { useCreateEnvironment } from '../hooks/useCreateEnvironment';
|
||||||
import { useDeleteEnvironment } from '../hooks/useDeleteEnvironment';
|
import { useDeleteEnvironment } from '../hooks/useDeleteEnvironment';
|
||||||
import { useEnvironments } from '../hooks/useEnvironments';
|
import { useEnvironments } from '../hooks/useEnvironments';
|
||||||
import { useKeyValue } from '../hooks/useKeyValue';
|
import { useKeyValue } from '../hooks/useKeyValue';
|
||||||
import { usePrompt } from '../hooks/usePrompt';
|
import { usePrompt } from '../hooks/usePrompt';
|
||||||
import { useUpdateEnvironment } from '../hooks/useUpdateEnvironment';
|
import { useUpdateEnvironment } from '../hooks/useUpdateEnvironment';
|
||||||
import { useUpdateWorkspace } from '../hooks/useUpdateWorkspace';
|
import { Banner } from './core/Banner';
|
||||||
import type { Environment, Workspace } from '@yaakapp-internal/models';
|
|
||||||
import { Button } from './core/Button';
|
import { Button } from './core/Button';
|
||||||
import { ContextMenu } from './core/Dropdown';
|
import { ContextMenu } from './core/Dropdown';
|
||||||
import type {
|
import type {
|
||||||
@@ -31,18 +30,15 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const EnvironmentEditDialog = function ({ initialEnvironment }: Props) {
|
export const EnvironmentEditDialog = function ({ initialEnvironment }: Props) {
|
||||||
const [selectedEnvironmentId, setSelectedEnvironmentId] = useState<string | null>(
|
|
||||||
initialEnvironment?.id ?? null,
|
|
||||||
);
|
|
||||||
const environments = useEnvironments();
|
|
||||||
const createEnvironment = useCreateEnvironment();
|
const createEnvironment = useCreateEnvironment();
|
||||||
const activeWorkspace = useActiveWorkspace();
|
const { baseEnvironment, subEnvironments, allEnvironments } = useEnvironments();
|
||||||
|
|
||||||
const selectedEnvironment = useMemo(
|
const [selectedEnvironmentId, setSelectedEnvironmentId] = useState<string | null>(
|
||||||
() => environments.find((e) => e.id === selectedEnvironmentId) ?? null,
|
initialEnvironment?.id ?? baseEnvironment?.id ?? null,
|
||||||
[environments, selectedEnvironmentId],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const selectedEnvironment = allEnvironments.find((e) => e.id === selectedEnvironmentId);
|
||||||
|
|
||||||
const handleCreateEnvironment = async () => {
|
const handleCreateEnvironment = async () => {
|
||||||
const e = await createEnvironment.mutateAsync();
|
const e = await createEnvironment.mutateAsync();
|
||||||
if (e == null) return;
|
if (e == null) return;
|
||||||
@@ -59,8 +55,8 @@ export const EnvironmentEditDialog = function ({ initialEnvironment }: Props) {
|
|||||||
<aside className="w-full min-w-0 pt-2">
|
<aside className="w-full min-w-0 pt-2">
|
||||||
<div className="min-w-0 h-full overflow-y-auto pt-1">
|
<div className="min-w-0 h-full overflow-y-auto pt-1">
|
||||||
<SidebarButton
|
<SidebarButton
|
||||||
active={selectedEnvironment?.id == null}
|
active={selectedEnvironment?.id == baseEnvironment?.id}
|
||||||
onClick={() => setSelectedEnvironmentId(null)}
|
onClick={() => setSelectedEnvironmentId(baseEnvironment?.id ?? null)}
|
||||||
environment={null}
|
environment={null}
|
||||||
rightSlot={
|
rightSlot={
|
||||||
<IconButton
|
<IconButton
|
||||||
@@ -75,14 +71,14 @@ export const EnvironmentEditDialog = function ({ initialEnvironment }: Props) {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
Global Variables
|
{baseEnvironment?.name}
|
||||||
</SidebarButton>
|
</SidebarButton>
|
||||||
{environments.length > 0 && (
|
{subEnvironments.length > 0 && (
|
||||||
<div className="px-2">
|
<div className="px-2">
|
||||||
<Separator className="my-3"></Separator>
|
<Separator className="my-3"></Separator>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{environments.map((e) => (
|
{subEnvironments.map((e) => (
|
||||||
<SidebarButton
|
<SidebarButton
|
||||||
key={e.id}
|
key={e.id}
|
||||||
active={selectedEnvironment?.id === e.id}
|
active={selectedEnvironment?.id === e.id}
|
||||||
@@ -96,11 +92,20 @@ export const EnvironmentEditDialog = function ({ initialEnvironment }: Props) {
|
|||||||
</aside>
|
</aside>
|
||||||
)}
|
)}
|
||||||
secondSlot={() =>
|
secondSlot={() =>
|
||||||
activeWorkspace != null && (
|
selectedEnvironmentId == null ? (
|
||||||
|
<div className="p-3 mt-10">
|
||||||
|
<Banner color="danger">No selected environment</Banner>
|
||||||
|
</div>
|
||||||
|
) : selectedEnvironment == null ? (
|
||||||
|
<div className="p-3 mt-10">
|
||||||
|
<Banner color="danger">
|
||||||
|
Failed to find selected environment <InlineCode>{selectedEnvironmentId}</InlineCode>
|
||||||
|
</Banner>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
<EnvironmentEditor
|
<EnvironmentEditor
|
||||||
className="pt-2 border-l border-border-subtle"
|
className="pt-2 border-l border-border-subtle"
|
||||||
environment={selectedEnvironment}
|
environment={selectedEnvironment}
|
||||||
workspace={activeWorkspace}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -110,11 +115,9 @@ export const EnvironmentEditDialog = function ({ initialEnvironment }: Props) {
|
|||||||
|
|
||||||
const EnvironmentEditor = function ({
|
const EnvironmentEditor = function ({
|
||||||
environment,
|
environment,
|
||||||
workspace,
|
|
||||||
className,
|
className,
|
||||||
}: {
|
}: {
|
||||||
environment: Environment | null;
|
environment: Environment;
|
||||||
workspace: Workspace;
|
|
||||||
className?: string;
|
className?: string;
|
||||||
}) {
|
}) {
|
||||||
const valueVisibility = useKeyValue<boolean>({
|
const valueVisibility = useKeyValue<boolean>({
|
||||||
@@ -122,37 +125,25 @@ const EnvironmentEditor = function ({
|
|||||||
key: 'environmentValueVisibility',
|
key: 'environmentValueVisibility',
|
||||||
fallback: true,
|
fallback: true,
|
||||||
});
|
});
|
||||||
const environments = useEnvironments();
|
const { subEnvironments } = useEnvironments();
|
||||||
const updateEnvironment = useUpdateEnvironment(environment?.id ?? null);
|
const updateEnvironment = useUpdateEnvironment(environment?.id ?? null);
|
||||||
const updateWorkspace = useUpdateWorkspace(workspace.id);
|
|
||||||
const variables = environment == null ? workspace.variables : environment.variables;
|
|
||||||
const handleChange = useCallback<PairEditorProps['onChange']>(
|
const handleChange = useCallback<PairEditorProps['onChange']>(
|
||||||
(variables) => {
|
(variables) => updateEnvironment.mutate({ variables }),
|
||||||
if (environment != null) {
|
[updateEnvironment],
|
||||||
updateEnvironment.mutate({ variables });
|
|
||||||
} else {
|
|
||||||
updateWorkspace.mutate({ variables });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[updateWorkspace, updateEnvironment, environment],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Gather a list of env names from other environments, to help the user get them aligned
|
// Gather a list of env names from other environments, to help the user get them aligned
|
||||||
const nameAutocomplete = useMemo<GenericCompletionConfig>(() => {
|
const nameAutocomplete = useMemo<GenericCompletionConfig>(() => {
|
||||||
const otherEnvironments = environments.filter((e) => e.id !== environment?.id);
|
|
||||||
const allVariableNames =
|
const allVariableNames =
|
||||||
environment == null
|
environment == null
|
||||||
? [
|
? [] // Nothing to autocomplete if we're in the base environment
|
||||||
// Nothing to autocomplete if we're in the base environment
|
: subEnvironments
|
||||||
]
|
.filter((e) => e.environmentId != null)
|
||||||
: [
|
.flatMap((e) => e.variables.map((v) => v.name));
|
||||||
...workspace.variables.map((v) => v.name),
|
|
||||||
...otherEnvironments.flatMap((e) => e.variables.map((v) => v.name)),
|
|
||||||
];
|
|
||||||
|
|
||||||
// Filter out empty strings and variables that already exist
|
// Filter out empty strings and variables that already exist
|
||||||
const variableNames = allVariableNames.filter(
|
const variableNames = allVariableNames.filter(
|
||||||
(name) => name != '' && !variables.find((v) => v.name === name),
|
(name) => name != '' && !environment.variables.find((v) => v.name === name),
|
||||||
);
|
);
|
||||||
const uniqueVariableNames = [...new Set(variableNames)];
|
const uniqueVariableNames = [...new Set(variableNames)];
|
||||||
const options = uniqueVariableNames.map(
|
const options = uniqueVariableNames.map(
|
||||||
@@ -162,7 +153,7 @@ const EnvironmentEditor = function ({
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
return { options };
|
return { options };
|
||||||
}, [environments, variables, workspace, environment]);
|
}, [subEnvironments, environment]);
|
||||||
|
|
||||||
const validateName = useCallback((name: string) => {
|
const validateName = useCallback((name: string) => {
|
||||||
// Empty just means the variable doesn't have a name yet, and is unusable
|
// Empty just means the variable doesn't have a name yet, and is unusable
|
||||||
@@ -174,7 +165,7 @@ const EnvironmentEditor = function ({
|
|||||||
<VStack space={4} className={classNames(className, 'pl-4')}>
|
<VStack space={4} className={classNames(className, 'pl-4')}>
|
||||||
<HStack space={2} className="justify-between">
|
<HStack space={2} className="justify-between">
|
||||||
<Heading className="w-full flex items-center gap-1">
|
<Heading className="w-full flex items-center gap-1">
|
||||||
<div>{environment?.name ?? 'Global Variables'}</div>
|
<div>{environment?.name}</div>
|
||||||
<IconButton
|
<IconButton
|
||||||
iconClassName="text-text-subtlest"
|
iconClassName="text-text-subtlest"
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -195,8 +186,8 @@ const EnvironmentEditor = function ({
|
|||||||
nameValidate={validateName}
|
nameValidate={validateName}
|
||||||
valueType={valueVisibility.value ? 'text' : 'password'}
|
valueType={valueVisibility.value ? 'text' : 'password'}
|
||||||
valueAutocompleteVariables={true}
|
valueAutocompleteVariables={true}
|
||||||
forceUpdateKey={environment?.id ?? workspace?.id ?? 'n/a'}
|
forceUpdateKey={environment.id}
|
||||||
pairs={variables}
|
pairs={environment.variables}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export function FolderSettingsDialog({ folderId }: Props) {
|
|||||||
|
|
||||||
<MarkdownEditor
|
<MarkdownEditor
|
||||||
name="folder-description"
|
name="folder-description"
|
||||||
placeholder="A Markdown description of this folder."
|
placeholder="Folder description"
|
||||||
className="min-h-[10rem] border border-border px-2"
|
className="min-h-[10rem] border border-border px-2"
|
||||||
defaultValue={folder.description}
|
defaultValue={folder.description}
|
||||||
onChange={(description) => {
|
onChange={(description) => {
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ export function GrpcConnectionSetupPane({
|
|||||||
<TabContent value={TAB_DESCRIPTION}>
|
<TabContent value={TAB_DESCRIPTION}>
|
||||||
<MarkdownEditor
|
<MarkdownEditor
|
||||||
name="request-description"
|
name="request-description"
|
||||||
placeholder="A Markdown description of this request."
|
placeholder="Request description"
|
||||||
defaultValue={activeRequest.description}
|
defaultValue={activeRequest.description}
|
||||||
onChange={handleDescriptionChange}
|
onChange={handleDescriptionChange}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -461,7 +461,7 @@ export const RequestPane = memo(function RequestPane({
|
|||||||
/>
|
/>
|
||||||
<MarkdownEditor
|
<MarkdownEditor
|
||||||
name="request-description"
|
name="request-description"
|
||||||
placeholder="A Markdown description of this request."
|
placeholder="Request description"
|
||||||
defaultValue={activeRequest.description}
|
defaultValue={activeRequest.description}
|
||||||
onChange={(description) =>
|
onChange={(description) =>
|
||||||
updateRequest.mutate({ id: activeRequestId, update: { description } })
|
updateRequest.mutate({ id: activeRequestId, update: { description } })
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export function WorkspaceSettingsDialog({ workspaceId }: Props) {
|
|||||||
|
|
||||||
<MarkdownEditor
|
<MarkdownEditor
|
||||||
name="workspace-description"
|
name="workspace-description"
|
||||||
placeholder="A Markdown description of this workspace."
|
placeholder="Workspace description"
|
||||||
className="min-h-[10rem] border border-border px-2"
|
className="min-h-[10rem] border border-border px-2"
|
||||||
defaultValue={workspace.description}
|
defaultValue={workspace.description}
|
||||||
onChange={(description) => updateWorkspace.mutate({ description })}
|
onChange={(description) => updateWorkspace.mutate({ description })}
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
import { getRouteApi, useSearch } from '@tanstack/react-router';
|
import { getRouteApi, useSearch } from '@tanstack/react-router';
|
||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { useEnvironments } from './useEnvironments';
|
import { useEnvironments } from './useEnvironments';
|
||||||
|
|
||||||
export function useActiveEnvironment() {
|
export function useActiveEnvironment() {
|
||||||
const [id, setId] = useActiveEnvironmentId();
|
const [id, setId] = useActiveEnvironmentId();
|
||||||
const environments = useEnvironments();
|
const { subEnvironments } = useEnvironments();
|
||||||
const environment = useMemo(
|
const environment = subEnvironments.find((w) => w.id === id) ?? null;
|
||||||
() => environments.find((w) => w.id === id) ?? null,
|
|
||||||
[environments, id],
|
|
||||||
);
|
|
||||||
return [environment, setId] as const;
|
return [environment, setId] as const;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import type { EnvironmentVariable } from '@yaakapp-internal/models';
|
import type { EnvironmentVariable } from '@yaakapp-internal/models';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useActiveEnvironment } from './useActiveEnvironment';
|
import { useActiveEnvironment } from './useActiveEnvironment';
|
||||||
import { useActiveWorkspace } from './useActiveWorkspace';
|
import { useEnvironments } from './useEnvironments';
|
||||||
|
|
||||||
export function useActiveEnvironmentVariables() {
|
export function useActiveEnvironmentVariables() {
|
||||||
const workspace = useActiveWorkspace();
|
const { baseEnvironment } = useEnvironments();
|
||||||
const [environment] = useActiveEnvironment();
|
const [environment] = useActiveEnvironment();
|
||||||
|
|
||||||
const variables = useMemo(() => {
|
const variables = useMemo(() => {
|
||||||
const varMap: Record<string, EnvironmentVariable> = {};
|
const varMap: Record<string, EnvironmentVariable> = {};
|
||||||
|
|
||||||
const allVariables = [...(workspace?.variables ?? []), ...(environment?.variables ?? [])];
|
const allVariables = [...(baseEnvironment?.variables ?? []), ...(environment?.variables ?? [])];
|
||||||
|
|
||||||
for (const v of allVariables) {
|
for (const v of allVariables) {
|
||||||
if (!v.enabled || !v.name) continue;
|
if (!v.enabled || !v.name) continue;
|
||||||
@@ -18,7 +18,7 @@ export function useActiveEnvironmentVariables() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Object.values(varMap);
|
return Object.values(varMap);
|
||||||
}, [workspace, environment]);
|
}, [baseEnvironment?.variables, environment?.variables]);
|
||||||
|
|
||||||
return variables;
|
return variables;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,11 @@ import { atom } from 'jotai/index';
|
|||||||
export const environmentsAtom = atom<Environment[]>([]);
|
export const environmentsAtom = atom<Environment[]>([]);
|
||||||
|
|
||||||
export function useEnvironments() {
|
export function useEnvironments() {
|
||||||
return useAtomValue(environmentsAtom);
|
const allEnvironments = useAtomValue(environmentsAtom);
|
||||||
|
const baseEnvironment = allEnvironments.find((e) => e.environmentId == null);
|
||||||
|
const subEnvironments = allEnvironments.filter(
|
||||||
|
(e) => e.environmentId === (baseEnvironment?.id ?? 'n/a'),
|
||||||
|
);
|
||||||
|
|
||||||
|
return { baseEnvironment, subEnvironments, allEnvironments } as const;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const namespace = 'global';
|
|||||||
const fallback: string[] = [];
|
const fallback: string[] = [];
|
||||||
|
|
||||||
export function useRecentEnvironments() {
|
export function useRecentEnvironments() {
|
||||||
const environments = useEnvironments();
|
const { subEnvironments } = useEnvironments();
|
||||||
const activeWorkspace = useActiveWorkspace();
|
const activeWorkspace = useActiveWorkspace();
|
||||||
const [activeEnvironment] = useActiveEnvironment();
|
const [activeEnvironment] = useActiveEnvironment();
|
||||||
const kv = useKeyValue<string[]>({
|
const kv = useKeyValue<string[]>({
|
||||||
@@ -30,8 +30,8 @@ export function useRecentEnvironments() {
|
|||||||
}, [activeEnvironment?.id]);
|
}, [activeEnvironment?.id]);
|
||||||
|
|
||||||
const onlyValidIds = useMemo(
|
const onlyValidIds = useMemo(
|
||||||
() => kv.value?.filter((id) => environments.some((e) => e.id === id)) ?? [],
|
() => kv.value?.filter((id) => subEnvironments.some((e) => e.id === id)) ?? [],
|
||||||
[kv.value, environments],
|
[kv.value, subEnvironments],
|
||||||
);
|
);
|
||||||
|
|
||||||
return onlyValidIds;
|
return onlyValidIds;
|
||||||
|
|||||||
Reference in New Issue
Block a user