mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-30 22:22:02 +02:00
Add @yaakapp/api everywhere
This commit is contained in:
23
plugins/importer-curl/package-lock.json
generated
23
plugins/importer-curl/package-lock.json
generated
@@ -8,13 +8,13 @@
|
||||
"name": "importer-curl",
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"@yaakapp/api": "^0.1.6",
|
||||
"shell-quote": "^1.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.14.9",
|
||||
"@types/shell-quote": "^1.7.5",
|
||||
"typescript": "^5.5.2",
|
||||
"vite": "^5.3.2",
|
||||
"vitest": "^1.4.0"
|
||||
}
|
||||
},
|
||||
@@ -708,6 +708,27 @@
|
||||
"url": "https://opencollective.com/vitest"
|
||||
}
|
||||
},
|
||||
"node_modules/@yaakapp/api": {
|
||||
"version": "0.1.6",
|
||||
"resolved": "https://registry.npmjs.org/@yaakapp/api/-/api-0.1.6.tgz",
|
||||
"integrity": "sha512-5lYXKcOVmLzVUrkfU4JOCbz+CBV5Dm/cALoZvfbelvZWOVu3sTrBxS9cbNVQQq2B6WwLInSevk7pMq58GqIj5Q==",
|
||||
"dependencies": {
|
||||
"@types/node": "^22.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@yaakapp/api/node_modules/@types/node": {
|
||||
"version": "22.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.3.0.tgz",
|
||||
"integrity": "sha512-nrWpWVaDZuaVc5X84xJ0vNrLvomM205oQyLsRt7OHNZbSHslcWsvgFR7O7hire2ZonjLrWBbedmotmIlJDVd6g==",
|
||||
"dependencies": {
|
||||
"undici-types": "~6.18.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@yaakapp/api/node_modules/undici-types": {
|
||||
"version": "6.18.2",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.18.2.tgz",
|
||||
"integrity": "sha512-5ruQbENj95yDYJNS3TvcaxPMshV7aizdv/hWYjGIKoANWKjhWNBsr2YEuYZKodQulB1b8l7ILOuDQep3afowQQ=="
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.11.3",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"build": "yaakcli ./src/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@yaakapp/api": "^0.1.6",
|
||||
"shell-quote": "^1.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
import { Environment, Folder, HttpRequest, HttpUrlParameter, Model, Workspace, YaakContext } from '@yaakapp/api';
|
||||
import { ControlOperator, parse, ParseEntry } from 'shell-quote';
|
||||
import {
|
||||
Environment,
|
||||
Folder,
|
||||
HttpRequest,
|
||||
HttpUrlParameter,
|
||||
Model,
|
||||
Workspace,
|
||||
} from '../../../src-web/lib/models';
|
||||
|
||||
type AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>;
|
||||
|
||||
@@ -39,7 +32,7 @@ type Pair = string | boolean;
|
||||
|
||||
type PairsByName = Record<string, Pair[]>;
|
||||
|
||||
export function pluginHookImport(_: any, rawData: string) {
|
||||
export function pluginHookImport(ctx: YaakContext, rawData: string) {
|
||||
if (!rawData.match(/^\s*curl /)) {
|
||||
return null;
|
||||
}
|
||||
@@ -92,7 +85,7 @@ export function pluginHookImport(_: any, rawData: string) {
|
||||
|
||||
if (op?.startsWith('$')) {
|
||||
// Handle the case where literal like -H $'Header: \'Some Quoted Thing\''
|
||||
const str = op.slice(2, op.length - 1).replace(/\\'/g, "'");
|
||||
const str = op.slice(2, op.length - 1).replace(/\\'/g, '\'');
|
||||
|
||||
currentCommand.push(str);
|
||||
continue;
|
||||
@@ -192,9 +185,9 @@ function importCommand(parseEntries: ParseEntry[], workspaceId: string) {
|
||||
const authenticationType = username ? (isDigest ? 'digest' : 'basic') : null;
|
||||
const authentication = username
|
||||
? {
|
||||
username: username.trim(),
|
||||
password: (password ?? '').trim(),
|
||||
}
|
||||
username: username.trim(),
|
||||
password: (password ?? '').trim(),
|
||||
}
|
||||
: {};
|
||||
|
||||
// Headers
|
||||
@@ -413,6 +406,7 @@ function splitOnce(str: string, sep: string): string[] {
|
||||
}
|
||||
|
||||
const idCount: Partial<Record<Model['model'], number>> = {};
|
||||
|
||||
function generateId(model: Model['model']): string {
|
||||
idCount[model] = (idCount[model] ?? -1) + 1;
|
||||
return `GENERATE_ID::${model.toUpperCase()}_${idCount[model]}`;
|
||||
|
||||
Reference in New Issue
Block a user