@scalar/workspace-store 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/client.js.map +2 -2
- package/dist/events/bus.d.ts +14 -4
- package/dist/events/bus.d.ts.map +1 -1
- package/dist/events/bus.js +12 -10
- package/dist/events/bus.js.map +2 -2
- package/dist/events/definitions/analytics.d.ts +3 -3
- package/dist/events/definitions/analytics.d.ts.map +1 -1
- package/dist/events/definitions/auth.d.ts +59 -14
- package/dist/events/definitions/auth.d.ts.map +1 -1
- package/dist/events/definitions/common.d.ts +5 -0
- package/dist/events/definitions/common.d.ts.map +1 -0
- package/dist/events/definitions/common.js +1 -0
- package/dist/events/definitions/common.js.map +7 -0
- package/dist/events/definitions/document.d.ts +2 -2
- package/dist/events/definitions/environment.d.ts +37 -0
- package/dist/events/definitions/environment.d.ts.map +1 -0
- package/dist/events/definitions/environment.js +1 -0
- package/dist/events/definitions/environment.js.map +7 -0
- package/dist/events/definitions/index.d.ts +3 -1
- package/dist/events/definitions/index.d.ts.map +1 -1
- package/dist/events/definitions/meta.d.ts +9 -3
- package/dist/events/definitions/meta.d.ts.map +1 -1
- package/dist/events/definitions/operation.d.ts +200 -0
- package/dist/events/definitions/operation.d.ts.map +1 -1
- package/dist/events/definitions/ui.d.ts +5 -0
- package/dist/events/definitions/ui.d.ts.map +1 -1
- package/dist/events/index.d.ts +1 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js.map +2 -2
- package/dist/helpers/generate-unique-value.d.ts +40 -0
- package/dist/helpers/generate-unique-value.d.ts.map +1 -0
- package/dist/helpers/generate-unique-value.js +42 -0
- package/dist/helpers/generate-unique-value.js.map +7 -0
- package/dist/helpers/overrides-proxy.d.ts.map +1 -1
- package/dist/helpers/overrides-proxy.js +1 -1
- package/dist/helpers/overrides-proxy.js.map +2 -2
- package/dist/helpers/unpack-proxy.d.ts +1 -1
- package/dist/helpers/unpack-proxy.d.ts.map +1 -1
- package/dist/helpers/unpack-proxy.js.map +2 -2
- package/dist/mutators/auth.d.ts +210 -0
- package/dist/mutators/auth.d.ts.map +1 -0
- package/dist/mutators/auth.js +223 -0
- package/dist/mutators/auth.js.map +7 -0
- package/dist/mutators/environment.d.ts +21 -13
- package/dist/mutators/environment.d.ts.map +1 -1
- package/dist/mutators/environment.js +46 -25
- package/dist/mutators/environment.js.map +2 -2
- package/dist/mutators/index.d.ts +6 -12
- package/dist/mutators/index.d.ts.map +1 -1
- package/dist/mutators/index.js +45 -4
- package/dist/mutators/index.js.map +2 -2
- package/dist/mutators/operation.d.ts +313 -0
- package/dist/mutators/operation.d.ts.map +1 -0
- package/dist/mutators/operation.js +340 -0
- package/dist/mutators/operation.js.map +7 -0
- package/dist/schemas/extensions/document/x-scalar-environments.d.ts +52 -0
- package/dist/schemas/extensions/document/x-scalar-environments.d.ts.map +1 -0
- package/dist/schemas/extensions/document/x-scalar-environments.js +25 -0
- package/dist/schemas/extensions/document/x-scalar-environments.js.map +7 -0
- package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.d.ts +13 -0
- package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.d.ts.map +1 -0
- package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.js +9 -0
- package/dist/schemas/extensions/operation/x-scalar-operation-identifiers.js.map +7 -0
- package/dist/schemas/extensions/operation/x-scalar-selected-content-type.d.ts +21 -0
- package/dist/schemas/extensions/operation/x-scalar-selected-content-type.d.ts.map +1 -0
- package/dist/schemas/extensions/operation/x-scalar-selected-content-type.js +8 -0
- package/dist/schemas/extensions/operation/x-scalar-selected-content-type.js.map +7 -0
- package/dist/schemas/extensions/security/x-scalar-selected-security.d.ts +17 -0
- package/dist/schemas/extensions/security/x-scalar-selected-security.d.ts.map +1 -0
- package/dist/schemas/extensions/security/x-scalar-selected-security.js +14 -0
- package/dist/schemas/extensions/security/x-scalar-selected-security.js.map +7 -0
- package/dist/schemas/extensions/workspace/x-scalar-active-environment.d.ts +8 -0
- package/dist/schemas/extensions/workspace/x-scalar-active-environment.d.ts.map +1 -0
- package/dist/schemas/extensions/workspace/x-scalar-active-environment.js +8 -0
- package/dist/schemas/extensions/workspace/x-scalar-active-environment.js.map +7 -0
- package/dist/schemas/inmemory-workspace.d.ts +56 -24
- package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
- package/dist/schemas/reference-config/index.d.ts +28 -12
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +28 -12
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +956 -413
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.js +9 -6
- package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
- package/dist/schemas/v3.1/strict/operation.d.ts +10 -6
- package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/operation.js +9 -7
- package/dist/schemas/v3.1/strict/operation.js.map +2 -2
- package/dist/schemas/v3.1/strict/request-body.d.ts +6 -3
- package/dist/schemas/v3.1/strict/request-body.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/request-body.js +15 -8
- package/dist/schemas/v3.1/strict/request-body.js.map +2 -2
- package/dist/schemas/workspace-specification/config.d.ts +28 -12
- package/dist/schemas/workspace-specification/config.d.ts.map +1 -1
- package/dist/schemas/workspace-specification/index.d.ts +28 -12
- package/dist/schemas/workspace-specification/index.d.ts.map +1 -1
- package/dist/schemas/workspace.d.ts +227 -103
- package/dist/schemas/workspace.d.ts.map +1 -1
- package/dist/schemas/workspace.js +16 -10
- package/dist/schemas/workspace.js.map +2 -2
- package/package.json +9 -4
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.d.ts +0 -33
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.d.ts.map +0 -1
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.js +0 -23
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.js.map +0 -7
|
@@ -1,31 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
xScalarEnvVarSchema,
|
|
3
|
+
xScalarEnvironmentSchema
|
|
4
|
+
} from "../schemas/extensions/document/x-scalar-environments.js";
|
|
5
|
+
import { coerceValue } from "../schemas/typebox-coerce.js";
|
|
6
|
+
const upsertEnvironment = (document, workspace, { environmentName, payload, collectionType, oldEnvironmentName }) => {
|
|
7
|
+
const collection = collectionType === "document" ? document : workspace;
|
|
8
|
+
if (!collection) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (!collection["x-scalar-environments"]) {
|
|
12
|
+
collection["x-scalar-environments"] = {};
|
|
13
|
+
}
|
|
14
|
+
const isNewEnvironment = !collection["x-scalar-environments"][oldEnvironmentName ?? environmentName];
|
|
15
|
+
const parsed = coerceValue(xScalarEnvironmentSchema, {
|
|
16
|
+
...collection["x-scalar-environments"][oldEnvironmentName ?? environmentName],
|
|
17
|
+
...payload
|
|
18
|
+
});
|
|
19
|
+
collection["x-scalar-environments"][environmentName] = parsed;
|
|
20
|
+
if (oldEnvironmentName && oldEnvironmentName !== environmentName) {
|
|
21
|
+
delete collection["x-scalar-environments"][oldEnvironmentName];
|
|
22
|
+
if (workspace["x-scalar-active-environment"] === oldEnvironmentName) {
|
|
23
|
+
workspace["x-scalar-active-environment"] = environmentName;
|
|
5
24
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
}
|
|
26
|
+
if (isNewEnvironment) {
|
|
27
|
+
workspace["x-scalar-active-environment"] = environmentName;
|
|
28
|
+
}
|
|
29
|
+
return parsed;
|
|
30
|
+
};
|
|
31
|
+
const upsertEnvironmentVariable = (collection, { environmentName, variable, index }) => {
|
|
32
|
+
if (!collection?.["x-scalar-environments"]?.[environmentName]) {
|
|
33
|
+
console.error("Environment not found", environmentName);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const parsed = coerceValue(xScalarEnvVarSchema, variable);
|
|
37
|
+
if (index !== void 0) {
|
|
38
|
+
if (parsed.name === "") {
|
|
39
|
+
collection["x-scalar-environments"][environmentName].variables.splice(index, 1);
|
|
40
|
+
return;
|
|
19
41
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
deleteEnvironment
|
|
26
|
-
};
|
|
42
|
+
collection["x-scalar-environments"][environmentName].variables[index] = parsed;
|
|
43
|
+
} else {
|
|
44
|
+
collection["x-scalar-environments"][environmentName].variables.push(parsed);
|
|
45
|
+
}
|
|
46
|
+
return parsed;
|
|
27
47
|
};
|
|
28
48
|
export {
|
|
29
|
-
|
|
49
|
+
upsertEnvironment,
|
|
50
|
+
upsertEnvironmentVariable
|
|
30
51
|
};
|
|
31
52
|
//# sourceMappingURL=environment.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mutators/environment.ts"],
|
|
4
|
-
"sourcesContent": ["import type {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { EnvironmentEvents } from '@/events/definitions/environment'\nimport type { Workspace, WorkspaceDocument } from '@/schemas'\nimport {\n type XScalarEnvVar,\n type XScalarEnvironment,\n xScalarEnvVarSchema,\n xScalarEnvironmentSchema,\n} from '@/schemas/extensions/document/x-scalar-environments'\nimport { coerceValue } from '@/schemas/typebox-coerce'\n\n/**\n * Adds OR updates an environment to the document or workspace.\n *\n * @param document - current document if available\n * @param workspace - current workspace if available\n * @param environmentName - Name of the environment to add\n * @param payload - The environment configuration to add\n * @param oldEnvironmentName - Only needed when renaming the environment\n * @returns the parsed environment that was added or updated or undefined if the collection is not found\n */\nexport const upsertEnvironment = (\n document: WorkspaceDocument | null,\n workspace: Workspace,\n { environmentName, payload, collectionType, oldEnvironmentName }: EnvironmentEvents['environment:upsert:environment'],\n): XScalarEnvironment | undefined => {\n /** Discriminating between document and workspace */\n const collection = collectionType === 'document' ? document : workspace\n if (!collection) {\n return\n }\n\n if (!collection['x-scalar-environments']) {\n collection['x-scalar-environments'] = {}\n }\n\n // Check if this is a new environment before we create it\n const isNewEnvironment = !collection['x-scalar-environments'][oldEnvironmentName ?? environmentName]\n\n // Ensure we parse the payload but keep the old variables\n const parsed = coerceValue(xScalarEnvironmentSchema, {\n ...collection['x-scalar-environments'][oldEnvironmentName ?? environmentName],\n ...payload,\n })\n collection['x-scalar-environments'][environmentName] = parsed\n\n // If we are renaming the environment, we need to delete the old one\n if (oldEnvironmentName && oldEnvironmentName !== environmentName) {\n delete collection['x-scalar-environments'][oldEnvironmentName]\n\n // If the old environment was active, we need to set the new environment as active\n if (workspace['x-scalar-active-environment'] === oldEnvironmentName) {\n workspace['x-scalar-active-environment'] = environmentName\n }\n }\n\n // Set the newly created workspace environment as active\n if (isNewEnvironment) {\n workspace['x-scalar-active-environment'] = environmentName\n }\n\n return parsed\n}\n\n/**\n * Adds OR updates an environment variable to the document or workspace.\n *\n * @param collection - Workspace OR document\n * @param environmentName - Name of the environment to add the variable to\n * @param variableName - Name of the variable to add\n * @param value - Value of the variable to add\n * @returns the parsed variable that was added or updated or undefined if the collection is not found\n */\nexport const upsertEnvironmentVariable = (\n collection: WorkspaceDocument | Workspace | null,\n { environmentName, variable, index }: EnvironmentEvents['environment:upsert:environment-variable'],\n): XScalarEnvVar | undefined => {\n // The environment should exist by now if we are upserting a variable\n if (!collection?.['x-scalar-environments']?.[environmentName]) {\n console.error('Environment not found', environmentName)\n return\n }\n\n // Ensure we parse the variable for type safety\n const parsed = coerceValue(xScalarEnvVarSchema, variable)\n\n if (index !== undefined) {\n // Delete the row if the name is empty\n if (parsed.name === '') {\n collection['x-scalar-environments'][environmentName].variables.splice(index, 1)\n return\n }\n\n // Update\n collection['x-scalar-environments'][environmentName].variables[index] = parsed\n }\n // Add\n else {\n collection['x-scalar-environments'][environmentName].variables.push(parsed)\n }\n\n return parsed\n}\n"],
|
|
5
|
+
"mappings": "AAEA;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAAmB;AAYrB,MAAM,oBAAoB,CAC/B,UACA,WACA,EAAE,iBAAiB,SAAS,gBAAgB,mBAAmB,MAC5B;AAEnC,QAAM,aAAa,mBAAmB,aAAa,WAAW;AAC9D,MAAI,CAAC,YAAY;AACf;AAAA,EACF;AAEA,MAAI,CAAC,WAAW,uBAAuB,GAAG;AACxC,eAAW,uBAAuB,IAAI,CAAC;AAAA,EACzC;AAGA,QAAM,mBAAmB,CAAC,WAAW,uBAAuB,EAAE,sBAAsB,eAAe;AAGnG,QAAM,SAAS,YAAY,0BAA0B;AAAA,IACnD,GAAG,WAAW,uBAAuB,EAAE,sBAAsB,eAAe;AAAA,IAC5E,GAAG;AAAA,EACL,CAAC;AACD,aAAW,uBAAuB,EAAE,eAAe,IAAI;AAGvD,MAAI,sBAAsB,uBAAuB,iBAAiB;AAChE,WAAO,WAAW,uBAAuB,EAAE,kBAAkB;AAG7D,QAAI,UAAU,6BAA6B,MAAM,oBAAoB;AACnE,gBAAU,6BAA6B,IAAI;AAAA,IAC7C;AAAA,EACF;AAGA,MAAI,kBAAkB;AACpB,cAAU,6BAA6B,IAAI;AAAA,EAC7C;AAEA,SAAO;AACT;AAWO,MAAM,4BAA4B,CACvC,YACA,EAAE,iBAAiB,UAAU,MAAM,MACL;AAE9B,MAAI,CAAC,aAAa,uBAAuB,IAAI,eAAe,GAAG;AAC7D,YAAQ,MAAM,yBAAyB,eAAe;AACtD;AAAA,EACF;AAGA,QAAM,SAAS,YAAY,qBAAqB,QAAQ;AAExD,MAAI,UAAU,QAAW;AAEvB,QAAI,OAAO,SAAS,IAAI;AACtB,iBAAW,uBAAuB,EAAE,eAAe,EAAE,UAAU,OAAO,OAAO,CAAC;AAC9E;AAAA,IACF;AAGA,eAAW,uBAAuB,EAAE,eAAe,EAAE,UAAU,KAAK,IAAI;AAAA,EAC1E,OAEK;AACH,eAAW,uBAAuB,EAAE,eAAe,EAAE,UAAU,KAAK,MAAM;AAAA,EAC5E;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/mutators/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
/** biome-ignore-all lint/performance/noBarrelFile: Mutators entry point */
|
|
1
2
|
import type { WorkspaceStore } from '../client.js';
|
|
2
3
|
/**
|
|
3
4
|
* Generates a set of mutators for managing OpenAPI document and workspace state.
|
|
4
5
|
*
|
|
6
|
+
* @deprecated use the individual mutators instead, this will be removed after we move fully to the new store
|
|
7
|
+
*
|
|
5
8
|
* @param store - The workspace store containing all documents and workspace-level data
|
|
6
9
|
* @returns An object with mutators for the workspace, the active document, and any named document
|
|
7
10
|
*/
|
|
@@ -10,10 +13,6 @@ export declare function generateClientMutators(store: WorkspaceStore): {
|
|
|
10
13
|
* Returns mutators for the workspace-level configuration.
|
|
11
14
|
*/
|
|
12
15
|
workspace: () => {
|
|
13
|
-
environmentMutators: {
|
|
14
|
-
addEnvironment: (name: string, environment: import("../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.js").xScalarClientConfigEnvironment) => boolean;
|
|
15
|
-
deleteEnvironment: (environmentName: string) => boolean;
|
|
16
|
-
};
|
|
17
16
|
cookieMutators: {
|
|
18
17
|
addCookie: (cookie: import("../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js").XScalarClientConfigCookie) => boolean;
|
|
19
18
|
deleteCookie: (cookieName: string) => boolean;
|
|
@@ -43,10 +42,6 @@ export declare function generateClientMutators(store: WorkspaceStore): {
|
|
|
43
42
|
addSecurityScheme: (name: string, securityScheme: import("../schemas/v3.1/strict/security-scheme.js").SecuritySchemeObject) => boolean;
|
|
44
43
|
deleteSecurityScheme: (name: string) => boolean;
|
|
45
44
|
};
|
|
46
|
-
environmentMutators: {
|
|
47
|
-
addEnvironment: (name: string, environment: import("../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.js").xScalarClientConfigEnvironment) => boolean;
|
|
48
|
-
deleteEnvironment: (environmentName: string) => boolean;
|
|
49
|
-
};
|
|
50
45
|
cookieMutators: {
|
|
51
46
|
addCookie: (cookie: import("../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js").XScalarClientConfigCookie) => boolean;
|
|
52
47
|
deleteCookie: (cookieName: string) => boolean;
|
|
@@ -73,10 +68,6 @@ export declare function generateClientMutators(store: WorkspaceStore): {
|
|
|
73
68
|
addSecurityScheme: (name: string, securityScheme: import("../schemas/v3.1/strict/security-scheme.js").SecuritySchemeObject) => boolean;
|
|
74
69
|
deleteSecurityScheme: (name: string) => boolean;
|
|
75
70
|
};
|
|
76
|
-
environmentMutators: {
|
|
77
|
-
addEnvironment: (name: string, environment: import("../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.js").xScalarClientConfigEnvironment) => boolean;
|
|
78
|
-
deleteEnvironment: (environmentName: string) => boolean;
|
|
79
|
-
};
|
|
80
71
|
cookieMutators: {
|
|
81
72
|
addCookie: (cookie: import("../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js").XScalarClientConfigCookie) => boolean;
|
|
82
73
|
deleteCookie: (cookieName: string) => boolean;
|
|
@@ -87,4 +78,7 @@ export declare function generateClientMutators(store: WorkspaceStore): {
|
|
|
87
78
|
};
|
|
88
79
|
};
|
|
89
80
|
};
|
|
81
|
+
export { type AuthMeta, type SecuritySchemeUpdate, deleteSecurityScheme, updateSecurityScheme, updateSelectedAuthTab, updateSelectedScopes, updateSelectedSecuritySchemes, } from './auth.js';
|
|
82
|
+
export { upsertEnvironment, upsertEnvironmentVariable, } from './environment.js';
|
|
83
|
+
export { type OperationExampleMeta, type OperationMeta, addOperationParameter, addOperationRequestBodyFormRow, deleteAllOperationParameters, deleteOperationParameter, deleteOperationRequestBodyFormRow, updateOperationMethodDraft as updateOperationMethod, updateOperationParameter, updateOperationPathDraft as updateOperationPath, updateOperationRequestBodyContentType, updateOperationRequestBodyExample, updateOperationRequestBodyFormRow, updateOperationSummary, } from './operation.js';
|
|
90
84
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mutators/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mutators/index.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAO9C;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc;IA4DxD;;OAEG;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;;;;;;;;;;;;;;;IAGH;;;;OAIG;gBACS,MAAM;;;;;;;;;;;;;;;;;;;;;EAErB;AAED,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,oBAAoB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,QAAQ,CAAA;AACf,OAAO,EACL,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,qBAAqB,EACrB,8BAA8B,EAC9B,4BAA4B,EAC5B,wBAAwB,EACxB,iCAAiC,EACjC,0BAA0B,IAAI,qBAAqB,EACnD,wBAAwB,EACxB,wBAAwB,IAAI,mBAAmB,EAC/C,qCAAqC,EACrC,iCAAiC,EACjC,iCAAiC,EACjC,sBAAsB,GACvB,MAAM,aAAa,CAAA"}
|
package/dist/mutators/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { cookieMutators } from "../mutators/cookie.js";
|
|
2
|
-
import { environmentMutators } from "../mutators/environment.js";
|
|
3
2
|
import { getDocument } from "../mutators/helpers.js";
|
|
4
3
|
import { requestMutators } from "../mutators/request.js";
|
|
5
4
|
import { securitySchemeMutators } from "../mutators/security-schemes.js";
|
|
@@ -21,7 +20,6 @@ function generateClientMutators(store) {
|
|
|
21
20
|
return {
|
|
22
21
|
requestMutators: requestMutators(document),
|
|
23
22
|
securitySchemeMutators: securitySchemeMutators(document?.components?.securitySchemes),
|
|
24
|
-
environmentMutators: environmentMutators(document),
|
|
25
23
|
cookieMutators: cookieMutators(document),
|
|
26
24
|
serverMutators: serverMutators(document?.servers)
|
|
27
25
|
};
|
|
@@ -35,7 +33,6 @@ function generateClientMutators(store) {
|
|
|
35
33
|
store.workspace["x-scalar-client-config-security-schemes"] = {};
|
|
36
34
|
}
|
|
37
35
|
return {
|
|
38
|
-
environmentMutators: environmentMutators(store.workspace),
|
|
39
36
|
cookieMutators: cookieMutators(store.workspace),
|
|
40
37
|
serverMutators: serverMutators(store.workspace["x-scalar-client-config-servers"]),
|
|
41
38
|
securitySchemeMutators: securitySchemeMutators(store.workspace["x-scalar-client-config-security-schemes"])
|
|
@@ -59,7 +56,51 @@ function generateClientMutators(store) {
|
|
|
59
56
|
doc: (name) => documentMutators(name)
|
|
60
57
|
};
|
|
61
58
|
}
|
|
59
|
+
import {
|
|
60
|
+
deleteSecurityScheme,
|
|
61
|
+
updateSecurityScheme,
|
|
62
|
+
updateSelectedAuthTab,
|
|
63
|
+
updateSelectedScopes,
|
|
64
|
+
updateSelectedSecuritySchemes
|
|
65
|
+
} from "./auth.js";
|
|
66
|
+
import {
|
|
67
|
+
upsertEnvironment,
|
|
68
|
+
upsertEnvironmentVariable
|
|
69
|
+
} from "./environment.js";
|
|
70
|
+
import {
|
|
71
|
+
addOperationParameter,
|
|
72
|
+
addOperationRequestBodyFormRow,
|
|
73
|
+
deleteAllOperationParameters,
|
|
74
|
+
deleteOperationParameter,
|
|
75
|
+
deleteOperationRequestBodyFormRow,
|
|
76
|
+
updateOperationMethodDraft,
|
|
77
|
+
updateOperationParameter,
|
|
78
|
+
updateOperationPathDraft,
|
|
79
|
+
updateOperationRequestBodyContentType,
|
|
80
|
+
updateOperationRequestBodyExample,
|
|
81
|
+
updateOperationRequestBodyFormRow,
|
|
82
|
+
updateOperationSummary
|
|
83
|
+
} from "./operation.js";
|
|
62
84
|
export {
|
|
63
|
-
|
|
85
|
+
addOperationParameter,
|
|
86
|
+
addOperationRequestBodyFormRow,
|
|
87
|
+
deleteAllOperationParameters,
|
|
88
|
+
deleteOperationParameter,
|
|
89
|
+
deleteOperationRequestBodyFormRow,
|
|
90
|
+
deleteSecurityScheme,
|
|
91
|
+
generateClientMutators,
|
|
92
|
+
updateOperationMethodDraft as updateOperationMethod,
|
|
93
|
+
updateOperationParameter,
|
|
94
|
+
updateOperationPathDraft as updateOperationPath,
|
|
95
|
+
updateOperationRequestBodyContentType,
|
|
96
|
+
updateOperationRequestBodyExample,
|
|
97
|
+
updateOperationRequestBodyFormRow,
|
|
98
|
+
updateOperationSummary,
|
|
99
|
+
updateSecurityScheme,
|
|
100
|
+
updateSelectedAuthTab,
|
|
101
|
+
updateSelectedScopes,
|
|
102
|
+
updateSelectedSecuritySchemes,
|
|
103
|
+
upsertEnvironment,
|
|
104
|
+
upsertEnvironmentVariable
|
|
64
105
|
};
|
|
65
106
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mutators/index.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/** biome-ignore-all lint/performance/noBarrelFile: Mutators entry point */\nimport type { WorkspaceStore } from '@/client'\nimport { cookieMutators } from '@/mutators/cookie'\nimport { getDocument } from '@/mutators/helpers'\nimport { requestMutators } from '@/mutators/request'\nimport { securitySchemeMutators } from '@/mutators/security-schemes'\nimport { serverMutators } from '@/mutators/server'\n\n/**\n * Generates a set of mutators for managing OpenAPI document and workspace state.\n *\n * @deprecated use the individual mutators instead, this will be removed after we move fully to the new store\n *\n * @param store - The workspace store containing all documents and workspace-level data\n * @returns An object with mutators for the workspace, the active document, and any named document\n */\nexport function generateClientMutators(store: WorkspaceStore) {\n /**\n * Returns mutators for a specific document by name.\n *\n * @param documentName - The name of the document to get mutators for\n * @returns An object containing mutators for requests, request examples, security schemes, environments, and cookies\n */\n const documentMutators = (documentName: string) => {\n const document = getDocument(store, documentName)\n\n if (document) {\n // Make sure the document has a servers array\n if (!document.servers) {\n document.servers = []\n }\n\n // Make sure the document has the securitySchema object\n if (!document.components) {\n document.components = {}\n }\n\n if (!document.components.securitySchemes) {\n document.components.securitySchemes = {}\n }\n }\n\n return {\n requestMutators: requestMutators(document),\n securitySchemeMutators: securitySchemeMutators(document?.components?.securitySchemes),\n cookieMutators: cookieMutators(document),\n serverMutators: serverMutators(document?.servers),\n }\n }\n\n /**\n * Returns mutators for the workspace-level configuration.\n *\n * @returns An object containing mutators for environments and cookies at the workspace level\n */\n const workspaceMutators = () => {\n const workspace = store.workspace\n\n // Make sure the workspace has a servers array\n if (!workspace['x-scalar-client-config-servers']) {\n workspace['x-scalar-client-config-servers'] = []\n }\n\n // Make sure the workspace has the securitySchema object\n if (!store.workspace['x-scalar-client-config-security-schemes']) {\n store.workspace['x-scalar-client-config-security-schemes'] = {}\n }\n\n return {\n cookieMutators: cookieMutators(store.workspace),\n serverMutators: serverMutators(store.workspace['x-scalar-client-config-servers']),\n securitySchemeMutators: securitySchemeMutators(store.workspace['x-scalar-client-config-security-schemes']),\n }\n }\n\n return {\n /**\n * Returns mutators for the workspace-level configuration.\n */\n workspace: () => workspaceMutators(),\n /**\n * Returns mutators for the currently active document.\n * Falls back to the first document if no active document is set.\n */\n active: () =>\n documentMutators(store.workspace['x-scalar-active-document'] ?? Object.keys(store.workspace.documents)[0] ?? ''),\n /**\n * Returns mutators for a specific document by name.\n *\n * @param name - The name of the document\n */\n doc: (name: string) => documentMutators(name),\n }\n}\n\nexport {\n type AuthMeta,\n type SecuritySchemeUpdate,\n deleteSecurityScheme,\n updateSecurityScheme,\n updateSelectedAuthTab,\n updateSelectedScopes,\n updateSelectedSecuritySchemes,\n} from './auth'\nexport {\n upsertEnvironment,\n upsertEnvironmentVariable,\n} from './environment'\nexport {\n type OperationExampleMeta,\n type OperationMeta,\n addOperationParameter,\n addOperationRequestBodyFormRow,\n deleteAllOperationParameters,\n deleteOperationParameter,\n deleteOperationRequestBodyFormRow,\n updateOperationMethodDraft as updateOperationMethod,\n updateOperationParameter,\n updateOperationPathDraft as updateOperationPath,\n updateOperationRequestBodyContentType,\n updateOperationRequestBodyExample,\n updateOperationRequestBodyFormRow,\n updateOperationSummary,\n} from './operation'\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,8BAA8B;AACvC,SAAS,sBAAsB;AAUxB,SAAS,uBAAuB,OAAuB;AAO5D,QAAM,mBAAmB,CAAC,iBAAyB;AACjD,UAAM,WAAW,YAAY,OAAO,YAAY;AAEhD,QAAI,UAAU;AAEZ,UAAI,CAAC,SAAS,SAAS;AACrB,iBAAS,UAAU,CAAC;AAAA,MACtB;AAGA,UAAI,CAAC,SAAS,YAAY;AACxB,iBAAS,aAAa,CAAC;AAAA,MACzB;AAEA,UAAI,CAAC,SAAS,WAAW,iBAAiB;AACxC,iBAAS,WAAW,kBAAkB,CAAC;AAAA,MACzC;AAAA,IACF;AAEA,WAAO;AAAA,MACL,iBAAiB,gBAA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http-methods';
|
|
2
|
+
import type { WorkspaceDocument } from '../schemas.js';
|
|
3
|
+
/**
|
|
4
|
+
* Describes the minimal identity for an operation in the workspace document.
|
|
5
|
+
* It is used by mutators to find the target operation under `paths`.
|
|
6
|
+
*
|
|
7
|
+
* Example:
|
|
8
|
+
* ```ts
|
|
9
|
+
* const meta: OperationMeta = { method: 'get', path: '/users/{id}' }
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export type OperationMeta = {
|
|
13
|
+
method: HttpMethod;
|
|
14
|
+
path: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Extends {@link OperationMeta} with an `exampleKey` to address a specific
|
|
18
|
+
* example variant (e.g. per environment or scenario) for request/parameters.
|
|
19
|
+
*
|
|
20
|
+
* Example:
|
|
21
|
+
* ```ts
|
|
22
|
+
* const meta: OperationExampleMeta = {
|
|
23
|
+
* method: 'post',
|
|
24
|
+
* path: '/upload',
|
|
25
|
+
* exampleKey: 'default',
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export type OperationExampleMeta = OperationMeta & {
|
|
30
|
+
exampleKey: string;
|
|
31
|
+
};
|
|
32
|
+
/** ------------------------------------------------------------------------------------------------
|
|
33
|
+
* Operation Draft Mutators
|
|
34
|
+
* ------------------------------------------------------------------------------------------------ */
|
|
35
|
+
/**
|
|
36
|
+
* Updates the `summary` of an operation.
|
|
37
|
+
* Safely no-ops if the document or operation does not exist.
|
|
38
|
+
*
|
|
39
|
+
* Example:
|
|
40
|
+
* ```ts
|
|
41
|
+
* updateOperationSummary({
|
|
42
|
+
* document,
|
|
43
|
+
* meta: { method: 'get', path: '/users/{id}' },
|
|
44
|
+
* payload: { summary: 'Get a single user' },
|
|
45
|
+
* })
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare const updateOperationSummary: ({ document, meta, payload: { summary }, }: {
|
|
49
|
+
document: WorkspaceDocument | null;
|
|
50
|
+
payload: {
|
|
51
|
+
summary: string;
|
|
52
|
+
};
|
|
53
|
+
meta: OperationMeta;
|
|
54
|
+
}) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Stores the chosen HTTP method under `x-scalar-method` on the operation.
|
|
57
|
+
* This does not move the operation to a different method slot under `paths`;
|
|
58
|
+
* it records the desired method as an extension for downstream consumers.
|
|
59
|
+
* Safely no-ops if the document or operation does not exist.
|
|
60
|
+
*
|
|
61
|
+
* Example:
|
|
62
|
+
* ```ts
|
|
63
|
+
* updateOperationMethodDraft({
|
|
64
|
+
* document,
|
|
65
|
+
* meta: { method: 'get', path: '/users' },
|
|
66
|
+
* payload: { method: 'post' },
|
|
67
|
+
* })
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare const updateOperationMethodDraft: ({ document, meta, payload: { method }, }: {
|
|
71
|
+
document: WorkspaceDocument | null;
|
|
72
|
+
payload: {
|
|
73
|
+
method: HttpMethod;
|
|
74
|
+
};
|
|
75
|
+
meta: OperationMeta;
|
|
76
|
+
}) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Records a normalized path for the operation under `x-scalar-path`, and
|
|
79
|
+
* synchronizes path parameters in `operation.parameters` with the placeholders
|
|
80
|
+
* present in the provided `path` (e.g. `/users/{id}`). Existing non-path
|
|
81
|
+
* parameters are preserved.
|
|
82
|
+
* Safely no-ops if the document or operation does not exist.
|
|
83
|
+
*
|
|
84
|
+
* Example:
|
|
85
|
+
* ```ts
|
|
86
|
+
* updateOperationPathDraft({
|
|
87
|
+
* document,
|
|
88
|
+
* meta: { method: 'get', path: '/users/{id}' },
|
|
89
|
+
* payload: { path: '/users/{id}' },
|
|
90
|
+
* })
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare const updateOperationPathDraft: ({ document, meta, payload: { path }, }: {
|
|
94
|
+
document: WorkspaceDocument | null;
|
|
95
|
+
payload: {
|
|
96
|
+
path: string;
|
|
97
|
+
};
|
|
98
|
+
meta: OperationMeta;
|
|
99
|
+
}) => void;
|
|
100
|
+
/** ------------------------------------------------------------------------------------------------
|
|
101
|
+
* Operation Parameters Mutators
|
|
102
|
+
* ------------------------------------------------------------------------------------------------ */
|
|
103
|
+
/**
|
|
104
|
+
* Adds a parameter to the operation with an example value tracked by `exampleKey`.
|
|
105
|
+
* For `path` parameters `required` is set to true automatically.
|
|
106
|
+
* Safely no-ops if the document or operation does not exist.
|
|
107
|
+
*
|
|
108
|
+
* Example:
|
|
109
|
+
* ```ts
|
|
110
|
+
* addOperationParameter({
|
|
111
|
+
* document,
|
|
112
|
+
* type: 'query',
|
|
113
|
+
* meta: { method: 'get', path: '/search', exampleKey: 'default' },
|
|
114
|
+
* payload: { key: 'q', value: 'john', isEnabled: true },
|
|
115
|
+
* })
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare const addOperationParameter: ({ document, meta, payload, type, }: {
|
|
119
|
+
document: WorkspaceDocument | null;
|
|
120
|
+
type: "header" | "path" | "query" | "cookie";
|
|
121
|
+
payload: {
|
|
122
|
+
key: string;
|
|
123
|
+
value: string;
|
|
124
|
+
isEnabled: boolean;
|
|
125
|
+
};
|
|
126
|
+
meta: OperationExampleMeta;
|
|
127
|
+
}) => void;
|
|
128
|
+
/**
|
|
129
|
+
* Updates an existing parameter of a given `type` by its index within that
|
|
130
|
+
* type subset (e.g. the N-th query parameter). Supports updating name, value,
|
|
131
|
+
* and enabled state for the targeted example.
|
|
132
|
+
* Safely no-ops if the document, operation, or parameter does not exist.
|
|
133
|
+
*
|
|
134
|
+
* Example:
|
|
135
|
+
* ```ts
|
|
136
|
+
* updateOperationParameter({
|
|
137
|
+
* document,
|
|
138
|
+
* type: 'query',
|
|
139
|
+
* index: 0,
|
|
140
|
+
* meta: { method: 'get', path: '/search', exampleKey: 'default' },
|
|
141
|
+
* payload: { value: 'alice', isEnabled: true },
|
|
142
|
+
* })
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
export declare const updateOperationParameter: ({ document, meta, type, payload, index, }: {
|
|
146
|
+
document: WorkspaceDocument | null;
|
|
147
|
+
type: "header" | "path" | "query" | "cookie";
|
|
148
|
+
index: number;
|
|
149
|
+
payload: Partial<{
|
|
150
|
+
key: string;
|
|
151
|
+
value: string;
|
|
152
|
+
isEnabled: boolean;
|
|
153
|
+
}>;
|
|
154
|
+
meta: OperationExampleMeta;
|
|
155
|
+
}) => void;
|
|
156
|
+
/**
|
|
157
|
+
* Removes a parameter from the operation by resolving its position within
|
|
158
|
+
* the filtered list of parameters of the specified `type`.
|
|
159
|
+
* Safely no-ops if the document, operation, or parameter does not exist.
|
|
160
|
+
*
|
|
161
|
+
* Example:
|
|
162
|
+
* ```ts
|
|
163
|
+
* deleteOperationParameter({
|
|
164
|
+
* document,
|
|
165
|
+
* type: 'header',
|
|
166
|
+
* index: 1,
|
|
167
|
+
* meta: { method: 'get', path: '/users', exampleKey: 'default' },
|
|
168
|
+
* })
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export declare const deleteOperationParameter: ({ document, meta, index, type, }: {
|
|
172
|
+
document: WorkspaceDocument | null;
|
|
173
|
+
type: "header" | "path" | "query" | "cookie";
|
|
174
|
+
index: number;
|
|
175
|
+
meta: OperationExampleMeta;
|
|
176
|
+
}) => void;
|
|
177
|
+
/**
|
|
178
|
+
* Deletes all parameters of a given `type` from the operation.
|
|
179
|
+
* Safely no-ops if the document or operation does not exist.
|
|
180
|
+
*
|
|
181
|
+
* Example:
|
|
182
|
+
* ```ts
|
|
183
|
+
* deleteAllOperationParameters({
|
|
184
|
+
* document,
|
|
185
|
+
* type: 'cookie',
|
|
186
|
+
* meta: { method: 'get', path: '/users' },
|
|
187
|
+
* })
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
export declare const deleteAllOperationParameters: ({ document, meta, type, }: {
|
|
191
|
+
document: WorkspaceDocument | null;
|
|
192
|
+
type: "header" | "path" | "query" | "cookie";
|
|
193
|
+
meta: OperationMeta;
|
|
194
|
+
}) => void;
|
|
195
|
+
/** ------------------------------------------------------------------------------------------------
|
|
196
|
+
* Operation Request Body Mutators
|
|
197
|
+
* ------------------------------------------------------------------------------------------------ */
|
|
198
|
+
/**
|
|
199
|
+
* Sets the selected request-body content type for the current `exampleKey`.
|
|
200
|
+
* This stores the selection under `x-scalar-selected-content-type` on the
|
|
201
|
+
* resolved requestBody. Safely no-ops if the document or operation does not exist.
|
|
202
|
+
*
|
|
203
|
+
* Example:
|
|
204
|
+
* ```ts
|
|
205
|
+
* updateOperationRequestBodyContentType({
|
|
206
|
+
* document,
|
|
207
|
+
* meta: { method: 'post', path: '/upload', exampleKey: 'default' },
|
|
208
|
+
* payload: { contentType: 'multipart/form-data' },
|
|
209
|
+
* })
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
export declare const updateOperationRequestBodyContentType: ({ document, meta, payload, }: {
|
|
213
|
+
document: WorkspaceDocument | null;
|
|
214
|
+
payload: {
|
|
215
|
+
contentType: string;
|
|
216
|
+
};
|
|
217
|
+
meta: OperationExampleMeta;
|
|
218
|
+
}) => void;
|
|
219
|
+
/**
|
|
220
|
+
* Creates or updates a concrete example value for a specific request-body
|
|
221
|
+
* `contentType` and `exampleKey`. Safely no-ops if the document or operation
|
|
222
|
+
* does not exist.
|
|
223
|
+
*
|
|
224
|
+
* Example:
|
|
225
|
+
* ```ts
|
|
226
|
+
* updateOperationRequestBodyExample({
|
|
227
|
+
* document,
|
|
228
|
+
* contentType: 'application/json',
|
|
229
|
+
* meta: { method: 'post', path: '/users', exampleKey: 'default' },
|
|
230
|
+
* payload: { value: JSON.stringify({ name: 'Ada' }) },
|
|
231
|
+
* })
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
export declare const updateOperationRequestBodyExample: ({ document, meta, payload, contentType, }: {
|
|
235
|
+
document: WorkspaceDocument | null;
|
|
236
|
+
contentType: string;
|
|
237
|
+
payload: {
|
|
238
|
+
value: string | File | undefined;
|
|
239
|
+
};
|
|
240
|
+
meta: OperationExampleMeta;
|
|
241
|
+
}) => void;
|
|
242
|
+
/**
|
|
243
|
+
* Appends a form-data row to the request-body example identified by
|
|
244
|
+
* `contentType` and `exampleKey`. Initializes the example as an array when
|
|
245
|
+
* needed. Safely no-ops if the document or operation does not exist.
|
|
246
|
+
*
|
|
247
|
+
* Example:
|
|
248
|
+
* ```ts
|
|
249
|
+
* addOperationRequestBodyFormRow({
|
|
250
|
+
* document,
|
|
251
|
+
* contentType: 'multipart/form-data',
|
|
252
|
+
* meta: { method: 'post', path: '/upload', exampleKey: 'default' },
|
|
253
|
+
* payload: { key: 'file', value: new File(['x'], 'a.txt') },
|
|
254
|
+
* })
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
export declare const addOperationRequestBodyFormRow: ({ document, meta, payload, contentType, }: {
|
|
258
|
+
document: WorkspaceDocument | null;
|
|
259
|
+
payload: Partial<{
|
|
260
|
+
key: string;
|
|
261
|
+
value?: string | File;
|
|
262
|
+
}>;
|
|
263
|
+
contentType: string;
|
|
264
|
+
meta: OperationExampleMeta;
|
|
265
|
+
}) => void;
|
|
266
|
+
/**
|
|
267
|
+
* Updates a form-data row at a given `index` for the specified example and
|
|
268
|
+
* `contentType`. Setting `payload.value` to `null` clears the value (sets to
|
|
269
|
+
* `undefined`). Safely no-ops if the document, operation, or example does not exist.
|
|
270
|
+
*
|
|
271
|
+
* Example:
|
|
272
|
+
* ```ts
|
|
273
|
+
* updateOperationRequestBodyFormRow({
|
|
274
|
+
* document,
|
|
275
|
+
* index: 0,
|
|
276
|
+
* contentType: 'multipart/form-data',
|
|
277
|
+
* meta: { method: 'post', path: '/upload', exampleKey: 'default' },
|
|
278
|
+
* payload: { key: 'description', value: 'Profile picture' },
|
|
279
|
+
* })
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
export declare const updateOperationRequestBodyFormRow: ({ document, meta, index, payload, contentType, }: {
|
|
283
|
+
document: WorkspaceDocument | null;
|
|
284
|
+
index: number;
|
|
285
|
+
payload: Partial<{
|
|
286
|
+
key: string;
|
|
287
|
+
value: string | File | null;
|
|
288
|
+
}>;
|
|
289
|
+
contentType: string;
|
|
290
|
+
meta: OperationExampleMeta;
|
|
291
|
+
}) => void;
|
|
292
|
+
/**
|
|
293
|
+
* Deletes a form-data row at a given `index` from the example for the given
|
|
294
|
+
* `contentType`. If the example becomes empty, the example entry is removed.
|
|
295
|
+
* Safely no-ops if the document, operation, example, or row does not exist.
|
|
296
|
+
*
|
|
297
|
+
* Example:
|
|
298
|
+
* ```ts
|
|
299
|
+
* deleteOperationRequestBodyFormRow({
|
|
300
|
+
* document,
|
|
301
|
+
* index: 0,
|
|
302
|
+
* contentType: 'multipart/form-data',
|
|
303
|
+
* meta: { method: 'post', path: '/upload', exampleKey: 'default' },
|
|
304
|
+
* })
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
export declare const deleteOperationRequestBodyFormRow: ({ document, meta, index, contentType, }: {
|
|
308
|
+
document: WorkspaceDocument | null;
|
|
309
|
+
index: number;
|
|
310
|
+
contentType: string;
|
|
311
|
+
meta: OperationExampleMeta;
|
|
312
|
+
}) => void;
|
|
313
|
+
//# sourceMappingURL=operation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../src/mutators/operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAGnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAElD;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,UAAU,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IACjD,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;sGAEsG;AAEtG;;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