NPM workspaces

This commit is contained in:
Gregory Schier
2024-09-30 18:11:51 -07:00
parent 035d7927f9
commit 9df586cb59
22 changed files with 5118 additions and 1972 deletions

5064
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,24 @@
{ {
"name": "@yaakapp/plugins", "name": "@yaakapp/plugins",
"repository": "https://github.com/yaakapp/plugins", "repository": "https://github.com/yaakapp/plugins",
"workspaces": [
"plugins/*"
],
"private": true, "private": true,
"scripts": { "scripts": {
"build": "node scripts/build-plugins.cjs", "build": "workspaces-run --parallel -- npm run --workspaces build",
"dev": "workspaces-run --parallel -- npm run --workspaces dev",
"test": "vitest run", "test": "vitest run",
"lint": "tsc" "lint": "tsc"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^22.7.4",
"jsonpath": "^1.1.1", "jsonpath": "^1.1.1",
"typescript": "^5.6.2",
"vitest": "^2.0.4", "vitest": "^2.0.4",
"typescript": "^5.5.2" "workspaces-run": "^1.0.2"
},
"dependencies": {
"@yaakapp/api": "^0.2.9"
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -3,15 +3,7 @@
"private": true, "private": true,
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build": "yaakcli build ./src/index.js" "build": "yaakcli build ./src/index.js",
}, "dev": "yaakcli dev ./src/index.js"
"dependencies": {
"@yaakapp/api": "^0.2.7"
},
"devDependencies": {
"@types/node": "^20.14.9",
"typescript": "^5.5.2",
"vitest": "^1.4.0",
"@yaakapp/cli": "^0.0.42"
} }
} }

View File

@@ -23,6 +23,7 @@ export async function pluginHookExport(_ctx: Context, request: Partial<HttpReque
if (request.method) xs.push('-X', request.method); if (request.method) xs.push('-X', request.method);
if (request.url) xs.push(quote(request.url)); if (request.url) xs.push(quote(request.url));
xs.push(NEWLINE); xs.push(NEWLINE);
// Add URL params // Add URL params

View File

@@ -8,7 +8,7 @@
"name": "filter-jsonpath", "name": "filter-jsonpath",
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.2.7", "@yaakapp/api": "^0.2.9",
"jsonpath-plus": "^9.0.0" "jsonpath-plus": "^9.0.0"
}, },
"devDependencies": { "devDependencies": {
@@ -49,9 +49,9 @@
} }
}, },
"node_modules/@yaakapp/api": { "node_modules/@yaakapp/api": {
"version": "0.2.7", "version": "0.2.8",
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.2.7.tgz", "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.2.8.tgz",
"integrity": "sha512-vU9KtEwe5a+6VpDtV5+GSV+BpZETer/M9TtZ+oDZovvFMO0d55KqPfs7S6PuMru6e8Yxky8mO1TjL4Vsylh2Gg==", "integrity": "sha512-m+6xHIH/X8uTP65oeaSGmz90UOhl7sW5E2rNKix5MEKSFg0BzBupXMjBIT6EXtrxcCvUdOPtSP3ARriWsiZixQ==",
"dependencies": { "dependencies": {
"@types/node": "^22.5.4" "@types/node": "^22.5.4"
} }

View File

@@ -3,15 +3,13 @@
"private": true, "private": true,
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build": "yaakcli build ./src/index.ts" "build": "yaakcli build ./src/index.ts",
"dev": "yaakcli dev ./src/index.js"
}, },
"dependencies": { "dependencies": {
"jsonpath-plus": "^9.0.0", "jsonpath-plus": "^9.0.0"
"@yaakapp/api": "^0.2.7"
}, },
"devDependencies": { "devDependencies": {
"@yaakapp/cli": "^0.0.42", "@types/jsonpath": "^0.2.4"
"@types/node": "^20.14.9",
"typescript": "^5.5.2"
} }
} }

View File

@@ -9,7 +9,7 @@
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"@xmldom/xmldom": "^0.8.10", "@xmldom/xmldom": "^0.8.10",
"@yaakapp/api": "^0.2.7", "@yaakapp/api": "^0.2.9",
"xpath": "^0.0.34" "xpath": "^0.0.34"
}, },
"devDependencies": { "devDependencies": {
@@ -36,9 +36,9 @@
} }
}, },
"node_modules/@yaakapp/api": { "node_modules/@yaakapp/api": {
"version": "0.2.7", "version": "0.2.8",
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.2.7.tgz", "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.2.8.tgz",
"integrity": "sha512-vU9KtEwe5a+6VpDtV5+GSV+BpZETer/M9TtZ+oDZovvFMO0d55KqPfs7S6PuMru6e8Yxky8mO1TjL4Vsylh2Gg==", "integrity": "sha512-m+6xHIH/X8uTP65oeaSGmz90UOhl7sW5E2rNKix5MEKSFg0BzBupXMjBIT6EXtrxcCvUdOPtSP3ARriWsiZixQ==",
"dependencies": { "dependencies": {
"@types/node": "^22.5.4" "@types/node": "^22.5.4"
} }

View File

@@ -3,16 +3,11 @@
"private": true, "private": true,
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build": "yaakcli build ./src/index.js" "build": "yaakcli build ./src/index.js",
"dev": "yaakcli dev ./src/index.js"
}, },
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.2.7",
"@xmldom/xmldom": "^0.8.10", "@xmldom/xmldom": "^0.8.10",
"xpath": "^0.0.34" "xpath": "^0.0.34"
},
"devDependencies": {
"@yaakapp/cli": "^0.0.42",
"@types/node": "^20.14.9",
"typescript": "^5.5.2"
} }
} }

View File

@@ -8,7 +8,7 @@
"name": "importer-curl", "name": "importer-curl",
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.2.7", "@yaakapp/api": "^0.2.9",
"shell-quote": "^1.8.1" "shell-quote": "^1.8.1"
}, },
"devDependencies": { "devDependencies": {
@@ -710,9 +710,9 @@
} }
}, },
"node_modules/@yaakapp/api": { "node_modules/@yaakapp/api": {
"version": "0.2.7", "version": "0.2.8",
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.2.7.tgz", "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.2.8.tgz",
"integrity": "sha512-vU9KtEwe5a+6VpDtV5+GSV+BpZETer/M9TtZ+oDZovvFMO0d55KqPfs7S6PuMru6e8Yxky8mO1TjL4Vsylh2Gg==", "integrity": "sha512-m+6xHIH/X8uTP65oeaSGmz90UOhl7sW5E2rNKix5MEKSFg0BzBupXMjBIT6EXtrxcCvUdOPtSP3ARriWsiZixQ==",
"dependencies": { "dependencies": {
"@types/node": "^22.5.4" "@types/node": "^22.5.4"
} }

View File

@@ -3,17 +3,10 @@
"private": true, "private": true,
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build": "yaakcli build ./src/index.js" "build": "yaakcli build ./src/index.js",
"dev": "yaakcli dev ./src/index.js"
}, },
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.2.7",
"shell-quote": "^1.8.1" "shell-quote": "^1.8.1"
},
"devDependencies": {
"@yaakapp/cli": "^0.0.42",
"@types/node": "^20.14.9",
"@types/shell-quote": "^1.7.5",
"typescript": "^5.5.2",
"vitest": "^1.4.0"
} }
} }

View File

@@ -8,7 +8,7 @@
"name": "importer-insomnia", "name": "importer-insomnia",
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.2.7", "@yaakapp/api": "^0.2.9",
"yaml": "^2.4.2" "yaml": "^2.4.2"
}, },
"devDependencies": { "devDependencies": {
@@ -27,9 +27,9 @@
} }
}, },
"node_modules/@yaakapp/api": { "node_modules/@yaakapp/api": {
"version": "0.2.7", "version": "0.2.8",
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.2.7.tgz", "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.2.8.tgz",
"integrity": "sha512-vU9KtEwe5a+6VpDtV5+GSV+BpZETer/M9TtZ+oDZovvFMO0d55KqPfs7S6PuMru6e8Yxky8mO1TjL4Vsylh2Gg==", "integrity": "sha512-m+6xHIH/X8uTP65oeaSGmz90UOhl7sW5E2rNKix5MEKSFg0BzBupXMjBIT6EXtrxcCvUdOPtSP3ARriWsiZixQ==",
"dependencies": { "dependencies": {
"@types/node": "^22.5.4" "@types/node": "^22.5.4"
} }

View File

@@ -3,15 +3,10 @@
"private": true, "private": true,
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build": "yaakcli build ./src/index.js" "build": "yaakcli build ./src/index.js",
"dev": "yaakcli dev ./src/index.js"
}, },
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.2.7",
"yaml": "^2.4.2" "yaml": "^2.4.2"
},
"devDependencies": {
"@yaakapp/cli": "^0.0.42",
"@types/node": "^20.14.9",
"typescript": "^5.5.2"
} }
} }

View File

@@ -8,7 +8,7 @@
"name": "importer-openapi", "name": "importer-openapi",
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.2.7", "@yaakapp/api": "^0.2.9",
"openapi-to-postmanv2": "^4.23.1", "openapi-to-postmanv2": "^4.23.1",
"yaml": "^2.4.2" "yaml": "^2.4.2"
}, },
@@ -57,9 +57,9 @@
} }
}, },
"node_modules/@yaakapp/api": { "node_modules/@yaakapp/api": {
"version": "0.2.7", "version": "0.2.8",
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.2.7.tgz", "resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.2.8.tgz",
"integrity": "sha512-vU9KtEwe5a+6VpDtV5+GSV+BpZETer/M9TtZ+oDZovvFMO0d55KqPfs7S6PuMru6e8Yxky8mO1TjL4Vsylh2Gg==", "integrity": "sha512-m+6xHIH/X8uTP65oeaSGmz90UOhl7sW5E2rNKix5MEKSFg0BzBupXMjBIT6EXtrxcCvUdOPtSP3ARriWsiZixQ==",
"dependencies": { "dependencies": {
"@types/node": "^22.5.4" "@types/node": "^22.5.4"
} }

View File

@@ -3,17 +3,11 @@
"private": true, "private": true,
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build": "yaakcli build ./src/index.js" "build": "yaakcli build ./src/index.js",
"dev": "yaakcli dev ./src/index.js"
}, },
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.2.7",
"openapi-to-postmanv2": "^4.23.1", "openapi-to-postmanv2": "^4.23.1",
"yaml": "^2.4.2" "yaml": "^2.4.2"
},
"devDependencies": {
"@yaakapp/cli": "^0.0.42",
"@types/node": "^20.14.9",
"@types/openapi-to-postmanv2": "^3.2.4",
"typescript": "^5.5.2"
} }
} }

View File

@@ -8,7 +8,7 @@
"name": "importer-postman", "name": "importer-postman",
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.2.7" "@yaakapp/api": "^0.2.9"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.14.9", "@types/node": "^20.14.9",

View File

@@ -4,16 +4,7 @@
"version": "0.0.1", "version": "0.0.1",
"main": "./build/index.js", "main": "./build/index.js",
"scripts": { "scripts": {
"build": "yaakcli build ./src/index.js" "build": "yaakcli build ./src/index.js",
}, "dev": "yaakcli dev ./src/index.js"
"dependencies": {
"@yaakapp/api": "^0.2.7"
},
"devDependencies": {
"@yaakapp/cli": "^0.0.42",
"@types/node": "^20.14.9",
"esbuild": "^0.21.5",
"typescript": "^5.5.2",
"vitest": "^1.4.0"
} }
} }

View File

@@ -8,7 +8,7 @@
"name": "importer-yaak", "name": "importer-yaak",
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.2.7" "@yaakapp/api": "^0.2.9"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.14.9", "@types/node": "^20.14.9",

View File

@@ -3,15 +3,7 @@
"private": true, "private": true,
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build": "yaakcli build ./src/index.js" "build": "yaakcli build ./src/index.js",
}, "dev": "yaakcli dev ./src/index.js"
"dependencies": {
"@yaakapp/api": "^0.2.7"
},
"devDependencies": {
"@yaakapp/cli": "^0.0.42",
"@types/node": "^20.14.9",
"esbuild": "^0.21.5",
"typescript": "^5.5.2"
} }
} }

View File

@@ -9,7 +9,7 @@
"version": "0.0.1", "version": "0.0.1",
"dependencies": { "dependencies": {
"@xmldom/xmldom": "^0.8.10", "@xmldom/xmldom": "^0.8.10",
"@yaakapp/api": "^0.2.7", "@yaakapp/api": "^0.2.9",
"jsonpath-plus": "^9.0.0", "jsonpath-plus": "^9.0.0",
"xpath": "^0.0.34" "xpath": "^0.0.34"
}, },

View File

@@ -3,19 +3,15 @@
"private": true, "private": true,
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build": "yaakcli build ./src/index.ts" "build": "yaakcli build ./src/index.ts",
"dev": "yaakcli dev ./src/index.js"
}, },
"dependencies": { "dependencies": {
"@yaakapp/api": "^0.2.7",
"jsonpath-plus": "^9.0.0", "jsonpath-plus": "^9.0.0",
"xpath": "^0.0.34", "xpath": "^0.0.34",
"@xmldom/xmldom": "^0.8.10" "@xmldom/xmldom": "^0.8.10"
}, },
"devDependencies": { "devDependencies": {
"@yaakapp/cli": "^0.0.42", "@types/jsonpath": "^0.2.4"
"@types/jsonpath": "^0.2.4",
"@types/node": "^20.14.9",
"typescript": "^5.5.2",
"vitest": "^1.4.0"
} }
} }

View File

@@ -1,213 +0,0 @@
export type Model =
| Settings
| Workspace
| Folder
| GrpcConnection
| GrpcRequest
| GrpcEvent
| HttpRequest
| HttpResponse
| KeyValue
| Environment
| CookieJar;
export interface BaseModel {
readonly id: string;
readonly createdAt: string;
readonly updatedAt: string;
}
export interface Settings extends BaseModel {
readonly model: 'settings';
theme: string;
appearance: string;
themeLight: string;
themeDark: string;
updateChannel: string;
interfaceFontSize: number;
interfaceScale: number;
editorFontSize: number;
editorSoftWrap: boolean;
openWorkspaceNewWindow: boolean | null;
}
export interface Workspace extends BaseModel {
readonly model: 'workspace';
name: string;
description: string;
variables: EnvironmentVariable[];
settingValidateCertificates: boolean;
settingFollowRedirects: boolean;
settingRequestTimeout: number;
}
export interface CookieJar extends BaseModel {
readonly model: 'cookie_jar';
workspaceId: string;
name: string;
cookies: Cookie[];
}
export interface Cookie {
raw_cookie: string;
domain: { HostOnly: string } | { Suffix: string } | 'NotPresent' | 'Empty';
expires: { AtUtc: string } | 'SessionEnd';
path: [string, boolean];
}
export function cookieDomain(cookie: Cookie): string {
if (cookie.domain === 'NotPresent' || cookie.domain === 'Empty') {
return 'n/a';
}
if ('HostOnly' in cookie.domain) {
return cookie.domain.HostOnly;
}
if ('Suffix' in cookie.domain) {
return cookie.domain.Suffix;
}
return 'unknown';
}
export interface EnvironmentVariable {
name: string;
value: string;
enabled?: boolean;
}
export interface Folder extends BaseModel {
readonly workspaceId: string;
readonly model: 'folder';
folderId: string | null;
sortPriority: number;
name: string;
}
export interface Environment extends BaseModel {
readonly workspaceId: string;
readonly model: 'environment';
name: string;
variables: EnvironmentVariable[];
}
export interface HttpHeader {
name: string;
value: string;
enabled?: boolean;
}
export interface HttpUrlParameter {
name: string;
value: string;
enabled?: boolean;
}
export interface GrpcMetadataEntry {
name: string;
value: string;
enabled?: boolean;
}
export interface GrpcRequest extends BaseModel {
readonly workspaceId: string;
readonly model: 'grpc_request';
folderId: string | null;
sortPriority: number;
name: string;
url: string;
service: string | null;
method: string | null;
message: string;
authentication: Record<string, string | number | boolean | null | undefined>;
authenticationType: string | null;
metadata: GrpcMetadataEntry[];
}
export interface GrpcEvent extends BaseModel {
readonly workspaceId: string;
readonly requestId: string;
readonly connectionId: string;
readonly model: 'grpc_event';
content: string;
status: number | null;
error: string | null;
eventType:
| 'info'
| 'error'
| 'client_message'
| 'server_message'
| 'connection_start'
| 'connection_end';
metadata: Record<string, string>;
}
export interface GrpcConnection extends BaseModel {
readonly workspaceId: string;
readonly requestId: string;
readonly model: 'grpc_connection';
service: string;
method: string;
elapsed: number;
elapsedConnection: number;
status: number;
url: string;
error: string | null;
trailers: Record<string, string>;
}
export interface HttpRequest extends BaseModel {
readonly workspaceId: string;
readonly model: 'http_request';
folderId: string | null;
sortPriority: number;
name: string;
url: string;
urlParameters: HttpUrlParameter[];
body: Record<string, unknown>;
bodyType: string | null;
authentication: Record<string, string | number | boolean | null | undefined>;
authenticationType: string | null;
method: string;
headers: HttpHeader[];
}
export interface KeyValue extends Omit<BaseModel, 'id'> {
readonly model: 'key_value';
readonly key: string;
readonly namespace: string;
value: string;
}
export interface HttpResponse extends BaseModel {
readonly workspaceId: string;
readonly model: 'http_response';
readonly requestId: string;
readonly bodyPath: string | null;
readonly contentLength: number | null;
readonly error: string;
readonly status: number;
readonly elapsed: number;
readonly elapsedHeaders: number;
readonly statusReason: string;
readonly version: string;
readonly remoteAddr: string;
readonly url: string;
readonly headers: HttpHeader[];
}
export function isResponseLoading(response: HttpResponse | GrpcConnection): boolean {
return response.elapsed === 0;
}
export function modelsEq(a: Model, b: Model) {
if (a.model === 'key_value' && b.model === 'key_value') {
return a.key === b.key && a.namespace === b.namespace;
}
if ('id' in a && 'id' in b) {
return a.id === b.id;
}
return false;
}
export function getContentTypeHeader(headers: HttpHeader[]): string | null {
return headers.find((h) => h.name.toLowerCase() === 'content-type')?.value ?? null;
}