@scalar/workspace-store 0.7.0 → 0.9.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 +44 -0
- package/README.md +86 -1
- package/dist/client.d.ts +46 -45152
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +173 -14
- package/dist/client.js.map +2 -2
- package/dist/helpers/apply-selective-updates.d.ts +17 -0
- package/dist/helpers/apply-selective-updates.d.ts.map +1 -0
- package/dist/helpers/apply-selective-updates.js +13 -0
- package/dist/helpers/apply-selective-updates.js.map +7 -0
- package/dist/helpers/general.d.ts +58 -0
- package/dist/helpers/general.d.ts.map +1 -1
- package/dist/helpers/general.js +18 -1
- package/dist/helpers/general.js.map +2 -2
- package/dist/helpers/proxy.d.ts +1 -1
- package/dist/helpers/proxy.d.ts.map +1 -1
- package/dist/helpers/proxy.js.map +2 -2
- package/dist/mutators/cookie.d.ts +17 -0
- package/dist/mutators/cookie.d.ts.map +1 -0
- package/dist/mutators/cookie.js +31 -0
- package/dist/mutators/cookie.js.map +7 -0
- package/dist/mutators/environment.d.ts +17 -0
- package/dist/mutators/environment.d.ts.map +1 -0
- package/dist/mutators/environment.js +31 -0
- package/dist/mutators/environment.js.map +7 -0
- package/dist/mutators/helpers.d.ts +34580 -0
- package/dist/mutators/helpers.d.ts.map +1 -0
- package/dist/mutators/helpers.js +11 -0
- package/dist/mutators/helpers.js.map +7 -0
- package/dist/mutators/index.d.ts +108 -0
- package/dist/mutators/index.d.ts.map +1 -0
- package/dist/mutators/index.js +67 -0
- package/dist/mutators/index.js.map +7 -0
- package/dist/mutators/request-example.d.ts +21 -0
- package/dist/mutators/request-example.d.ts.map +1 -0
- package/dist/mutators/request-example.js +58 -0
- package/dist/mutators/request-example.js.map +7 -0
- package/dist/mutators/request.d.ts +22 -0
- package/dist/mutators/request.d.ts.map +1 -0
- package/dist/mutators/request.js +53 -0
- package/dist/mutators/request.js.map +7 -0
- package/dist/mutators/security-schemes.d.ts +14 -0
- package/dist/mutators/security-schemes.d.ts.map +1 -0
- package/dist/mutators/security-schemes.js +27 -0
- package/dist/mutators/security-schemes.js.map +7 -0
- package/dist/mutators/server.d.ts +12 -0
- package/dist/mutators/server.d.ts.map +1 -0
- package/dist/mutators/server.js +24 -0
- package/dist/mutators/server.js.map +7 -0
- package/dist/navigation/helpers/traverse-description.d.ts +2 -1
- package/dist/navigation/helpers/traverse-description.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-description.js.map +2 -2
- package/dist/navigation/helpers/traverse-document.d.ts +89 -2
- package/dist/navigation/helpers/traverse-document.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-document.js.map +2 -2
- package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-paths.js.map +2 -2
- package/dist/navigation/helpers/traverse-schemas.d.ts +2 -1
- package/dist/navigation/helpers/traverse-schemas.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-schemas.js.map +2 -2
- package/dist/navigation/helpers/traverse-tags.d.ts +2 -1
- package/dist/navigation/helpers/traverse-tags.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-tags.js.map +2 -2
- package/dist/navigation/helpers/traverse-webhooks.d.ts +2 -1
- package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
- package/dist/navigation/helpers/traverse-webhooks.js.map +2 -2
- package/dist/navigation/types.d.ts +1 -39
- package/dist/navigation/types.d.ts.map +1 -1
- package/dist/schemas/compose.d.ts.map +1 -0
- package/dist/schemas/{v3.1/compose.js.map → compose.js.map} +1 -1
- package/dist/schemas/inmemory-workspace.d.ts +68 -0
- package/dist/schemas/inmemory-workspace.d.ts.map +1 -0
- package/dist/schemas/inmemory-workspace.js +14 -0
- package/dist/schemas/inmemory-workspace.js.map +7 -0
- package/dist/schemas/navigation.d.ts +148 -0
- package/dist/schemas/navigation.d.ts.map +1 -0
- package/dist/schemas/navigation.js +76 -0
- package/dist/schemas/navigation.js.map +7 -0
- package/dist/schemas/reference-config/index.d.ts +1 -1
- package/dist/schemas/v3.1/strict/callback.js +1 -1
- package/dist/schemas/v3.1/strict/callback.js.map +1 -1
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.d.ts +16 -0
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js +13 -0
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js.map +7 -0
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.d.ts +27 -0
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.js +23 -0
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.js.map +7 -0
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-request-example.d.ts +38 -0
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-request-example.d.ts.map +1 -0
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-request-example.js +45 -0
- package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-request-example.js.map +7 -0
- package/dist/schemas/v3.1/strict/components.d.ts +45 -7948
- package/dist/schemas/v3.1/strict/components.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/components.js +4 -2
- package/dist/schemas/v3.1/strict/components.js.map +2 -2
- package/dist/schemas/v3.1/strict/contact.js +1 -1
- package/dist/schemas/v3.1/strict/contact.js.map +1 -1
- package/dist/schemas/v3.1/strict/discriminator.js +1 -1
- package/dist/schemas/v3.1/strict/discriminator.js.map +1 -1
- package/dist/schemas/v3.1/strict/encoding.js +1 -1
- package/dist/schemas/v3.1/strict/encoding.js.map +1 -1
- package/dist/schemas/v3.1/strict/example.js +1 -1
- package/dist/schemas/v3.1/strict/example.js.map +1 -1
- package/dist/schemas/v3.1/strict/external-documentation.js +1 -1
- package/dist/schemas/v3.1/strict/external-documentation.js.map +1 -1
- package/dist/schemas/v3.1/strict/header.js +1 -1
- package/dist/schemas/v3.1/strict/header.js.map +1 -1
- package/dist/schemas/v3.1/strict/info.js +1 -1
- package/dist/schemas/v3.1/strict/info.js.map +1 -1
- package/dist/schemas/v3.1/strict/license.js +1 -1
- package/dist/schemas/v3.1/strict/license.js.map +1 -1
- package/dist/schemas/v3.1/strict/link.js +1 -1
- package/dist/schemas/v3.1/strict/link.js.map +1 -1
- package/dist/schemas/v3.1/strict/media-type.js +1 -1
- package/dist/schemas/v3.1/strict/media-type.js.map +1 -1
- package/dist/schemas/v3.1/strict/oauth-flow.js +1 -1
- package/dist/schemas/v3.1/strict/oauth-flow.js.map +1 -1
- package/dist/schemas/v3.1/strict/oauthflows.js +1 -1
- package/dist/schemas/v3.1/strict/oauthflows.js.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +63 -0
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.js +12 -2
- package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
- package/dist/schemas/v3.1/strict/operation.d.ts +18 -0
- package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/operation.js +8 -1
- package/dist/schemas/v3.1/strict/operation.js.map +2 -2
- package/dist/schemas/v3.1/strict/parameter.js +1 -1
- package/dist/schemas/v3.1/strict/parameter.js.map +1 -1
- package/dist/schemas/v3.1/strict/path-item.d.ts +6 -0
- package/dist/schemas/v3.1/strict/path-item.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/path-item.js +7 -1
- package/dist/schemas/v3.1/strict/path-item.js.map +2 -2
- package/dist/schemas/v3.1/strict/path-operations.d.ts +3975 -228
- package/dist/schemas/v3.1/strict/path-operations.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/paths.d.ts +1864 -1
- package/dist/schemas/v3.1/strict/paths.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/paths.js +1 -1
- package/dist/schemas/v3.1/strict/paths.js.map +1 -1
- package/dist/schemas/v3.1/strict/reference.js +1 -1
- package/dist/schemas/v3.1/strict/reference.js.map +1 -1
- package/dist/schemas/v3.1/strict/request-body.js +1 -1
- package/dist/schemas/v3.1/strict/request-body.js.map +1 -1
- package/dist/schemas/v3.1/strict/response.js +1 -1
- package/dist/schemas/v3.1/strict/response.js.map +1 -1
- package/dist/schemas/v3.1/strict/responses.js +1 -1
- package/dist/schemas/v3.1/strict/responses.js.map +1 -1
- package/dist/schemas/v3.1/strict/schema.js +1 -1
- package/dist/schemas/v3.1/strict/schema.js.map +1 -1
- package/dist/schemas/v3.1/strict/security-requirement.js +1 -1
- package/dist/schemas/v3.1/strict/security-requirement.js.map +1 -1
- package/dist/schemas/v3.1/strict/security-scheme.js +1 -1
- package/dist/schemas/v3.1/strict/security-scheme.js.map +1 -1
- package/dist/schemas/v3.1/strict/server-variable.js +1 -1
- package/dist/schemas/v3.1/strict/server-variable.js.map +1 -1
- package/dist/schemas/v3.1/strict/server.js +1 -1
- package/dist/schemas/v3.1/strict/server.js.map +1 -1
- package/dist/schemas/v3.1/strict/tag.js +1 -1
- package/dist/schemas/v3.1/strict/tag.js.map +1 -1
- package/dist/schemas/v3.1/strict/xml.js +1 -1
- package/dist/schemas/v3.1/strict/xml.js.map +1 -1
- package/dist/schemas/workspace-specification/config.d.ts +48 -0
- package/dist/schemas/workspace-specification/config.d.ts.map +1 -0
- package/dist/schemas/workspace-specification/config.js +11 -0
- package/dist/schemas/workspace-specification/config.js.map +7 -0
- package/dist/schemas/workspace-specification/index.d.ts +210 -0
- package/dist/schemas/workspace-specification/index.d.ts.map +1 -0
- package/dist/schemas/workspace-specification/index.js +27 -0
- package/dist/schemas/workspace-specification/index.js.map +7 -0
- package/dist/schemas/workspace-specification/info.d.ts +5 -0
- package/dist/schemas/workspace-specification/info.d.ts.map +1 -0
- package/dist/schemas/workspace-specification/info.js +9 -0
- package/dist/schemas/workspace-specification/info.js.map +7 -0
- package/dist/schemas/workspace.d.ts +147 -79
- package/dist/schemas/workspace.d.ts.map +1 -1
- package/dist/schemas/workspace.js +19 -4
- package/dist/schemas/workspace.js.map +2 -2
- package/dist/server.d.ts +860 -188
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js.map +1 -1
- package/package.json +12 -10
- package/dist/schemas/v3.1/compose.d.ts.map +0 -1
- /package/dist/schemas/{v3.1/compose.d.ts → compose.d.ts} +0 -0
- /package/dist/schemas/{v3.1/compose.js → compose.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/helpers/general.ts"],
|
|
4
|
-
"sourcesContent": ["export type UnknownObject = Record<string, unknown>\n\n/**\n * Returns true if the value is a non-null object (but not an array).\n *\n * @example\n * ```ts\n * isObject({}) // true\n * isObject([]) // false\n * isObject(null) // false\n * ```\n */\nexport function isObject(value: unknown): value is UnknownObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/**\n * Checks if a string is a local reference (starts with #)\n * @param value - The reference string to check\n * @returns true if the string is a local reference, false otherwise\n * @example\n * ```ts\n * isLocalRef('#/components/schemas/User') // true\n * isLocalRef('https://example.com/schema.json') // false\n * isLocalRef('./local-schema.json') // false\n * ```\n */\nexport function isLocalRef(value: string): boolean {\n return value.startsWith('#')\n}\n\nexport function keyOf<T extends Record<string, unknown>>(value: T) {\n return Object.keys(value) as (keyof T)[]\n}\n"],
|
|
5
|
-
"mappings": "AAYO,SAAS,SAAS,OAAwC;AAC/D,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAaO,SAAS,WAAW,OAAwB;AACjD,SAAO,MAAM,WAAW,GAAG;AAC7B;AAEO,SAAS,MAAyC,OAAU;AACjE,SAAO,OAAO,KAAK,KAAK;AAC1B;",
|
|
4
|
+
"sourcesContent": ["export type UnknownObject = Record<string, unknown>\n\n/**\n * Returns true if the value is a non-null object (but not an array).\n *\n * @example\n * ```ts\n * isObject({}) // true\n * isObject([]) // false\n * isObject(null) // false\n * ```\n */\nexport function isObject(value: unknown): value is UnknownObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/**\n * Checks if a string is a local reference (starts with #)\n * @param value - The reference string to check\n * @returns true if the string is a local reference, false otherwise\n * @example\n * ```ts\n * isLocalRef('#/components/schemas/User') // true\n * isLocalRef('https://example.com/schema.json') // false\n * isLocalRef('./local-schema.json') // false\n * ```\n */\nexport function isLocalRef(value: string): boolean {\n return value.startsWith('#')\n}\n\nexport function keyOf<T extends Record<string, unknown>>(value: T) {\n return Object.keys(value) as (keyof T)[]\n}\n\n/**\n * Deep clones a value using JSON serialization.\n *\n * @param value - The value to deep clone\n * @template T - The type of the value\n * @returns A deep clone of the value\n */\nexport const deepClone = <T>(value: T): T => {\n return JSON.parse(JSON.stringify(value)) as T\n}\n\n/**\n * Splits an array into two arrays based on a condition.\n *\n * This function takes an array and a predicate function, then returns a tuple containing\n * two arrays: the first contains elements that pass the condition, and the second contains\n * elements that fail the condition.\n *\n * @param array - The array to split\n * @param condition - A predicate function that determines which array each element belongs to\n * @returns A tuple of two arrays: [passingElements, failingElements]\n *\n * @example\n * ```ts\n * const numbers = [1, 2, 3, 4, 5, 6]\n * const [evens, odds] = split(numbers, (n) => n % 2 === 0)\n * // evens: [2, 4, 6]\n * // odds: [1, 3, 5]\n *\n * const words = ['apple', 'banana', 'cherry', 'date']\n * const [longWords, shortWords] = split(words, (word) => word.length > 5)\n * // longWords: ['banana', 'cherry']\n * // shortWords: ['apple', 'date']\n * ```\n */\nexport const split = <T>(array: T[], condition: (element: T) => boolean) => {\n return array.reduce<[T[], T[]]>(\n ([pass, fail], item) => {\n return condition(item) ? [[...pass, item], fail] : [pass, [...fail, item]]\n },\n [[], []],\n )\n}\n\n/**\n * Safely assigns properties from a source object to a target object.\n *\n * This function uses Object.assign to copy enumerable properties from the source object\n * to the target object. It's a type-safe wrapper around Object.assign that ensures\n * the source object is compatible with the target object's type.\n *\n * @param target - The target object to assign properties to\n * @param source - The source object containing properties to assign\n * @template T - The type of the target object\n *\n * @example\n * ```ts\n * const target = { name: 'John', age: 30 }\n * const source = { age: 31, city: 'New York' }\n * safeAssign(target, source)\n * // target is now: { name: 'John', age: 31, city: 'New York' }\n *\n * const config = { theme: 'dark', language: 'en' }\n * const updates = { theme: 'light' }\n * safeAssign(config, updates)\n * // config is now: { theme: 'light', language: 'en' }\n * ```\n */\nexport const safeAssign = <T extends Record<string, unknown>>(target: T, source: Partial<T>) => {\n Object.assign(target, source)\n}\n"],
|
|
5
|
+
"mappings": "AAYO,SAAS,SAAS,OAAwC;AAC/D,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAaO,SAAS,WAAW,OAAwB;AACjD,SAAO,MAAM,WAAW,GAAG;AAC7B;AAEO,SAAS,MAAyC,OAAU;AACjE,SAAO,OAAO,KAAK,KAAK;AAC1B;AASO,MAAM,YAAY,CAAI,UAAgB;AAC3C,SAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACzC;AA0BO,MAAM,QAAQ,CAAI,OAAY,cAAuC;AAC1E,SAAO,MAAM;AAAA,IACX,CAAC,CAAC,MAAM,IAAI,GAAG,SAAS;AACtB,aAAO,UAAU,IAAI,IAAI,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC;AAAA,IAC3E;AAAA,IACA,CAAC,CAAC,GAAG,CAAC,CAAC;AAAA,EACT;AACF;AA0BO,MAAM,aAAa,CAAoC,QAAW,WAAuB;AAC9F,SAAO,OAAO,QAAQ,MAAM;AAC9B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/helpers/proxy.d.ts
CHANGED
|
@@ -59,5 +59,5 @@ export declare function createMagicProxy<T extends UnknownObject>(targetObject:
|
|
|
59
59
|
* const proxy = createMagicProxy({ foo: { $ref: '#/bar' } })
|
|
60
60
|
* const raw = getRaw(proxy) // { foo: { $ref: '#/bar' } }
|
|
61
61
|
*/
|
|
62
|
-
export declare function getRaw(obj:
|
|
62
|
+
export declare function getRaw<T extends UnknownObject>(obj: T): T;
|
|
63
63
|
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/helpers/proxy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAE9C,eAAO,MAAM,aAAa,eAAmB,CAAA;AAyH7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,aAAa,EACtD,YAAY,EAAE,CAAC,EACf,cAAc,GAAE,CAAgB,EAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GACtC,CAAC,CAyBH;AAED;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/helpers/proxy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAE9C,eAAO,MAAM,aAAa,eAAmB,CAAA;AAyH7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,aAAa,EACtD,YAAY,EAAE,CAAC,EACf,cAAc,GAAE,CAAgB,EAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GACtC,CAAC,CAyBH;AAED;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,aAAa,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAEzD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/helpers/proxy.ts"],
|
|
4
|
-
"sourcesContent": ["import { isReactive, toRaw } from 'vue'\nimport { getValueByPath, parseJsonPointer } from './json-path-utils'\nimport { isLocalRef, isObject } from './general'\nimport type { UnknownObject } from './general'\n\nexport const TARGET_SYMBOL = Symbol('target')\n\n/**\n * Creates a proxy handler that automatically resolves JSON references ($ref) in an object.\n * The handler intercepts property access, assignment, and property enumeration to automatically\n * resolve any $ref references to their target values in the source document.\n *\n * @param sourceDocument - The source document containing the reference targets\n * @param resolvedProxyCache - Optional cache to store resolved proxies and prevent duplicate proxies\n * @returns A proxy handler that automatically resolves $ref references\n */\nfunction createProxyHandler(\n sourceDocument: UnknownObject,\n resolvedProxyCache?: WeakMap<object, UnknownObject>,\n): ProxyHandler<UnknownObject> {\n return {\n get(target, property, receiver) {\n if (property === TARGET_SYMBOL) {\n return target\n }\n\n if (property === '__isProxy') {\n return true\n }\n\n const value = Reflect.get(target, property, receiver)\n\n /**\n * Recursively resolves nested references in an object.\n * If the value is not an object, returns it as is.\n * If the value has a $ref property:\n * - For local references: resolves the reference and continues resolving nested refs\n * - For all other objects: creates a proxy for lazy resolution\n */\n const deepResolveNestedRefs = (value: unknown, originalRef?: string) => {\n if (!isObject(value)) {\n return value\n }\n\n if ('$ref' in value) {\n const ref = value.$ref as string\n\n if (isLocalRef(ref)) {\n const referencePath = parseJsonPointer(ref)\n const resolvedValue = getValueByPath(sourceDocument, referencePath)\n\n // preserve the first $ref to maintain the original reference\n return deepResolveNestedRefs(resolvedValue, originalRef ?? ref)\n }\n }\n\n if (originalRef) {\n return createMagicProxy({ ...value, 'x-original-ref': originalRef }, sourceDocument, resolvedProxyCache)\n }\n\n return createMagicProxy(value, sourceDocument, resolvedProxyCache)\n }\n\n return deepResolveNestedRefs(value)\n },\n\n set(target: UnknownObject, property: string, newValue: unknown, receiver: UnknownObject) {\n const rawTarget = isReactive(target) ? toRaw(target) : target\n const currentValue = rawTarget[property]\n\n if (\n isObject(currentValue) &&\n '$ref' in currentValue &&\n typeof currentValue.$ref === 'string' &&\n isLocalRef(currentValue.$ref)\n ) {\n const referencePath = parseJsonPointer(currentValue.$ref)\n const targetObject = getValueByPath(sourceDocument, referencePath.slice(0, -1)) as UnknownObject\n const lastPathSegment = referencePath[referencePath.length - 1]\n\n if (targetObject && lastPathSegment) {\n targetObject[lastPathSegment] = newValue\n }\n } else {\n Reflect.set(rawTarget, property, newValue, receiver)\n }\n return true\n },\n\n has(target: UnknownObject, key: string) {\n if (typeof key === 'string' && key !== '$ref' && typeof target.$ref === 'string' && isLocalRef(target.$ref)) {\n const referencePath = parseJsonPointer(target['$ref'])\n const resolvedValue = getValueByPath(sourceDocument, referencePath) as UnknownObject\n\n return resolvedValue ? key in resolvedValue : false\n }\n\n return key in target\n },\n\n ownKeys(target: UnknownObject) {\n if ('$ref' in target && typeof target.$ref === 'string' && isLocalRef(target.$ref)) {\n const referencePath = parseJsonPointer(target['$ref'])\n const resolvedValue = getValueByPath(sourceDocument, referencePath)\n\n return resolvedValue ? Reflect.ownKeys(resolvedValue) : []\n }\n\n return Reflect.ownKeys(target)\n },\n\n getOwnPropertyDescriptor(target: UnknownObject, key: string) {\n if ('$ref' in target && key !== '$ref' && typeof target.$ref === 'string' && isLocalRef(target.$ref)) {\n const referencePath = parseJsonPointer(target['$ref'])\n const resolvedValue = getValueByPath(sourceDocument, referencePath)\n\n if (resolvedValue) {\n return Object.getOwnPropertyDescriptor(resolvedValue, key)\n }\n }\n\n return Object.getOwnPropertyDescriptor(target, key)\n },\n }\n}\n\n/**\n * Creates a proxy that automatically resolves JSON references ($ref) in an object.\n * The proxy intercepts property access and automatically resolves any $ref references\n * to their target values in the source document.\n *\n * @param targetObject - The object to create a proxy for\n * @param sourceDocument - The source document containing the reference targets (defaults to targetObject)\n * @param resolvedProxyCache - Optional cache to store resolved proxies and prevent duplicate proxies\n * @returns A proxy that automatically resolves $ref references\n *\n * @example\n * // Basic usage with local references\n * const doc = {\n * components: {\n * schemas: {\n * User: { type: 'object', properties: { name: { type: 'string' } } }\n * }\n * },\n * paths: {\n * '/users': {\n * get: {\n * responses: {\n * 200: {\n * content: {\n * 'application/json': {\n * schema: { $ref: '#/components/schemas/User' }\n * }\n * }\n * }\n * }\n * }\n * }\n * }\n * }\n *\n * const proxy = createMagicProxy(doc)\n * // Accessing the schema will automatically resolve the $ref\n * console.log(proxy.paths['/users'].get.responses[200].content['application/json'].schema)\n * // Output: { type: 'object', properties: { name: { type: 'string' } } }\n *\n * @example\n * // Using with a cache to prevent duplicate proxies\n * const cache = new WeakMap()\n * const proxy1 = createMagicProxy(doc, doc, cache)\n * const proxy2 = createMagicProxy(doc, doc, cache)\n * // proxy1 and proxy2 are the same instance due to caching\n * console.log(proxy1 === proxy2) // true\n */\nexport function createMagicProxy<T extends UnknownObject>(\n targetObject: T,\n sourceDocument: T = targetObject,\n resolvedProxyCache?: WeakMap<object, T>,\n): T {\n if (!isObject(targetObject)) {\n return targetObject\n }\n\n const rawTarget = isReactive(targetObject) ? toRaw(targetObject) : targetObject\n\n // check for cached results\n if (resolvedProxyCache?.has(rawTarget)) {\n const cachedValue = resolvedProxyCache.get(rawTarget)\n\n if (cachedValue) {\n return cachedValue\n }\n }\n\n // Create a handler with the correct context\n const handler = createProxyHandler(sourceDocument, resolvedProxyCache)\n const proxy = new Proxy<T>(rawTarget, handler)\n\n if (resolvedProxyCache) {\n resolvedProxyCache.set(rawTarget, proxy)\n }\n\n return proxy\n}\n\n/**\n * Gets the raw (non-proxied) version of an object created by createMagicProxy.\n * This is useful when you need to access the original object without the magic proxy wrapper.\n *\n * @param obj - The magic proxy object to get the raw version of\n * @returns The raw version of the object\n * @example\n * const proxy = createMagicProxy({ foo: { $ref: '#/bar'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ACA,iBAAoB,cACpB,oBACG;AACH,MAAI,CAAC,SAAS,YAAY,GAAG;AAC3B,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,WAAW,YAAY,IAAI,MAAM,YAAY,IAAI;AAGnE,MAAI,oBAAoB,IAAI,SAAS,GAAG;AACtC,UAAM,cAAc,mBAAmB,IAAI,SAAS;AAEpD,QAAI,aAAa;AACf,aAAO;AAAA,IACT;AAAA,EACF;AAGA,QAAM,UAAU,mBAAmB,gBAAgB,kBAAkB;AACrE,QAAM,QAAQ,IAAI,MAAS,WAAW,OAAO;AAE7C,MAAI,oBAAoB;AACtB,uBAAmB,IAAI,WAAW,KAAK;AAAA,EACzC;AAEA,SAAO;AACT;AAYO,SAAS,
|
|
4
|
+
"sourcesContent": ["import { isReactive, toRaw } from 'vue'\nimport { getValueByPath, parseJsonPointer } from './json-path-utils'\nimport { isLocalRef, isObject } from './general'\nimport type { UnknownObject } from './general'\n\nexport const TARGET_SYMBOL = Symbol('target')\n\n/**\n * Creates a proxy handler that automatically resolves JSON references ($ref) in an object.\n * The handler intercepts property access, assignment, and property enumeration to automatically\n * resolve any $ref references to their target values in the source document.\n *\n * @param sourceDocument - The source document containing the reference targets\n * @param resolvedProxyCache - Optional cache to store resolved proxies and prevent duplicate proxies\n * @returns A proxy handler that automatically resolves $ref references\n */\nfunction createProxyHandler(\n sourceDocument: UnknownObject,\n resolvedProxyCache?: WeakMap<object, UnknownObject>,\n): ProxyHandler<UnknownObject> {\n return {\n get(target, property, receiver) {\n if (property === TARGET_SYMBOL) {\n return target\n }\n\n if (property === '__isProxy') {\n return true\n }\n\n const value = Reflect.get(target, property, receiver)\n\n /**\n * Recursively resolves nested references in an object.\n * If the value is not an object, returns it as is.\n * If the value has a $ref property:\n * - For local references: resolves the reference and continues resolving nested refs\n * - For all other objects: creates a proxy for lazy resolution\n */\n const deepResolveNestedRefs = (value: unknown, originalRef?: string) => {\n if (!isObject(value)) {\n return value\n }\n\n if ('$ref' in value) {\n const ref = value.$ref as string\n\n if (isLocalRef(ref)) {\n const referencePath = parseJsonPointer(ref)\n const resolvedValue = getValueByPath(sourceDocument, referencePath)\n\n // preserve the first $ref to maintain the original reference\n return deepResolveNestedRefs(resolvedValue, originalRef ?? ref)\n }\n }\n\n if (originalRef) {\n return createMagicProxy({ ...value, 'x-original-ref': originalRef }, sourceDocument, resolvedProxyCache)\n }\n\n return createMagicProxy(value, sourceDocument, resolvedProxyCache)\n }\n\n return deepResolveNestedRefs(value)\n },\n\n set(target: UnknownObject, property: string, newValue: unknown, receiver: UnknownObject) {\n const rawTarget = isReactive(target) ? toRaw(target) : target\n const currentValue = rawTarget[property]\n\n if (\n isObject(currentValue) &&\n '$ref' in currentValue &&\n typeof currentValue.$ref === 'string' &&\n isLocalRef(currentValue.$ref)\n ) {\n const referencePath = parseJsonPointer(currentValue.$ref)\n const targetObject = getValueByPath(sourceDocument, referencePath.slice(0, -1)) as UnknownObject\n const lastPathSegment = referencePath[referencePath.length - 1]\n\n if (targetObject && lastPathSegment) {\n targetObject[lastPathSegment] = newValue\n }\n } else {\n Reflect.set(rawTarget, property, newValue, receiver)\n }\n return true\n },\n\n has(target: UnknownObject, key: string) {\n if (typeof key === 'string' && key !== '$ref' && typeof target.$ref === 'string' && isLocalRef(target.$ref)) {\n const referencePath = parseJsonPointer(target['$ref'])\n const resolvedValue = getValueByPath(sourceDocument, referencePath) as UnknownObject\n\n return resolvedValue ? key in resolvedValue : false\n }\n\n return key in target\n },\n\n ownKeys(target: UnknownObject) {\n if ('$ref' in target && typeof target.$ref === 'string' && isLocalRef(target.$ref)) {\n const referencePath = parseJsonPointer(target['$ref'])\n const resolvedValue = getValueByPath(sourceDocument, referencePath)\n\n return resolvedValue ? Reflect.ownKeys(resolvedValue) : []\n }\n\n return Reflect.ownKeys(target)\n },\n\n getOwnPropertyDescriptor(target: UnknownObject, key: string) {\n if ('$ref' in target && key !== '$ref' && typeof target.$ref === 'string' && isLocalRef(target.$ref)) {\n const referencePath = parseJsonPointer(target['$ref'])\n const resolvedValue = getValueByPath(sourceDocument, referencePath)\n\n if (resolvedValue) {\n return Object.getOwnPropertyDescriptor(resolvedValue, key)\n }\n }\n\n return Object.getOwnPropertyDescriptor(target, key)\n },\n }\n}\n\n/**\n * Creates a proxy that automatically resolves JSON references ($ref) in an object.\n * The proxy intercepts property access and automatically resolves any $ref references\n * to their target values in the source document.\n *\n * @param targetObject - The object to create a proxy for\n * @param sourceDocument - The source document containing the reference targets (defaults to targetObject)\n * @param resolvedProxyCache - Optional cache to store resolved proxies and prevent duplicate proxies\n * @returns A proxy that automatically resolves $ref references\n *\n * @example\n * // Basic usage with local references\n * const doc = {\n * components: {\n * schemas: {\n * User: { type: 'object', properties: { name: { type: 'string' } } }\n * }\n * },\n * paths: {\n * '/users': {\n * get: {\n * responses: {\n * 200: {\n * content: {\n * 'application/json': {\n * schema: { $ref: '#/components/schemas/User' }\n * }\n * }\n * }\n * }\n * }\n * }\n * }\n * }\n *\n * const proxy = createMagicProxy(doc)\n * // Accessing the schema will automatically resolve the $ref\n * console.log(proxy.paths['/users'].get.responses[200].content['application/json'].schema)\n * // Output: { type: 'object', properties: { name: { type: 'string' } } }\n *\n * @example\n * // Using with a cache to prevent duplicate proxies\n * const cache = new WeakMap()\n * const proxy1 = createMagicProxy(doc, doc, cache)\n * const proxy2 = createMagicProxy(doc, doc, cache)\n * // proxy1 and proxy2 are the same instance due to caching\n * console.log(proxy1 === proxy2) // true\n */\nexport function createMagicProxy<T extends UnknownObject>(\n targetObject: T,\n sourceDocument: T = targetObject,\n resolvedProxyCache?: WeakMap<object, T>,\n): T {\n if (!isObject(targetObject)) {\n return targetObject\n }\n\n const rawTarget = isReactive(targetObject) ? toRaw(targetObject) : targetObject\n\n // check for cached results\n if (resolvedProxyCache?.has(rawTarget)) {\n const cachedValue = resolvedProxyCache.get(rawTarget)\n\n if (cachedValue) {\n return cachedValue\n }\n }\n\n // Create a handler with the correct context\n const handler = createProxyHandler(sourceDocument, resolvedProxyCache)\n const proxy = new Proxy<T>(rawTarget, handler)\n\n if (resolvedProxyCache) {\n resolvedProxyCache.set(rawTarget, proxy)\n }\n\n return proxy\n}\n\n/**\n * Gets the raw (non-proxied) version of an object created by createMagicProxy.\n * This is useful when you need to access the original object without the magic proxy wrapper.\n *\n * @param obj - The magic proxy object to get the raw version of\n * @returns The raw version of the object\n * @example\n * const proxy = createMagicProxy({ foo: { $ref: '#/bar' } })\n * const raw = getRaw(proxy) // { foo: { $ref: '#/bar' } }\n */\nexport function getRaw<T extends UnknownObject>(obj: T): T {\n return (obj as T & { [TARGET_SYMBOL]: T })[TARGET_SYMBOL]\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY,aAAa;AAClC,SAAS,gBAAgB,wBAAwB;AACjD,SAAS,YAAY,gBAAgB;AAG9B,MAAM,gBAAgB,OAAO,QAAQ;AAW5C,SAAS,mBACP,gBACA,oBAC6B;AAC7B,SAAO;AAAA,IACL,IAAI,QAAQ,UAAU,UAAU;AAC9B,UAAI,aAAa,eAAe;AAC9B,eAAO;AAAA,MACT;AAEA,UAAI,aAAa,aAAa;AAC5B,eAAO;AAAA,MACT;AAEA,YAAM,QAAQ,QAAQ,IAAI,QAAQ,UAAU,QAAQ;AASpD,YAAM,wBAAwB,CAACA,QAAgB,gBAAyB;AACtE,YAAI,CAAC,SAASA,MAAK,GAAG;AACpB,iBAAOA;AAAA,QACT;AAEA,YAAI,UAAUA,QAAO;AACnB,gBAAM,MAAMA,OAAM;AAElB,cAAI,WAAW,GAAG,GAAG;AACnB,kBAAM,gBAAgB,iBAAiB,GAAG;AAC1C,kBAAM,gBAAgB,eAAe,gBAAgB,aAAa;AAGlE,mBAAO,sBAAsB,eAAe,eAAe,GAAG;AAAA,UAChE;AAAA,QACF;AAEA,YAAI,aAAa;AACf,iBAAO,iBAAiB,EAAE,GAAGA,QAAO,kBAAkB,YAAY,GAAG,gBAAgB,kBAAkB;AAAA,QACzG;AAEA,eAAO,iBAAiBA,QAAO,gBAAgB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UAAU,UAAU,QAAQ,UAAU,OAAO,OAAO,SAAS,YAAY,WAAW,OAAO,IAAI,GAAG;AACpG,cAAM,gBAAgB,iBAAiB,OAAO,MAAM,CAAC;AACrD,cAAM,gBAAgB,eAAe,gBAAgB,aAAa;AAElE,YAAI,eAAe;AACjB,iBAAO,OAAO,yBAAyB,eAAe,GAAG;AAAA,QAC3D;AAAA,MACF;AAEA,aAAO,OAAO,yBAAyB,QAAQ,GAAG;AAAA,IACpD;AAAA,EACF;AACF;AAkDO,SAAS,iBACd,cACA,iBAAoB,cACpB,oBACG;AACH,MAAI,CAAC,SAAS,YAAY,GAAG;AAC3B,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,WAAW,YAAY,IAAI,MAAM,YAAY,IAAI;AAGnE,MAAI,oBAAoB,IAAI,SAAS,GAAG;AACtC,UAAM,cAAc,mBAAmB,IAAI,SAAS;AAEpD,QAAI,aAAa;AACf,aAAO;AAAA,IACT;AAAA,EACF;AAGA,QAAM,UAAU,mBAAmB,gBAAgB,kBAAkB;AACrE,QAAM,QAAQ,IAAI,MAAS,WAAW,OAAO;AAE7C,MAAI,oBAAoB;AACtB,uBAAmB,IAAI,WAAW,KAAK;AAAA,EACzC;AAEA,SAAO;AACT;AAYO,SAAS,OAAgC,KAAW;AACzD,SAAQ,IAAmC,aAAa;AAC1D;",
|
|
6
6
|
"names": ["value"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { UnknownObject } from '../helpers/general.js';
|
|
2
|
+
import type { XScalarClientConfigCookie, XScalarClientConfigCookies } from '../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies.js';
|
|
3
|
+
/**
|
|
4
|
+
* Cookie mutators for managing client configuration cookies in OpenAPI documents.
|
|
5
|
+
* Provides functions to add and delete cookies from the document's x-scalar-client-config-cookies extension.
|
|
6
|
+
*
|
|
7
|
+
* @param store - The workspace store containing the documents
|
|
8
|
+
* @param documentName - The name of the document to operate on
|
|
9
|
+
* @returns Object containing addCookie and deleteCookie functions
|
|
10
|
+
*/
|
|
11
|
+
export declare const cookieMutators: (document?: UnknownObject & {
|
|
12
|
+
"x-scalar-client-config-cookies"?: XScalarClientConfigCookies;
|
|
13
|
+
}) => {
|
|
14
|
+
addCookie: (cookie: XScalarClientConfigCookie) => boolean;
|
|
15
|
+
deleteCookie: (cookieName: string) => boolean;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=cookie.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../src/mutators/cookie.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC3B,MAAM,+EAA+E,CAAA;AAEtF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,cACd,aAAa,GAAG;IAAE,gCAAgC,CAAC,EAAE,0BAA0B,CAAA;CAAE;wBAwBjE,yBAAyB;+BA+BlB,MAAM;CAazC,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const cookieMutators = (document) => {
|
|
2
|
+
const addCookie = (cookie) => {
|
|
3
|
+
if (!document) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
if (!document["x-scalar-client-config-cookies"]) {
|
|
7
|
+
document["x-scalar-client-config-cookies"] = {};
|
|
8
|
+
}
|
|
9
|
+
if (document["x-scalar-client-config-cookies"][cookie.name]) {
|
|
10
|
+
console.warn(`Cookie with name "${cookie.name}" already exists in the document.`);
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
document["x-scalar-client-config-cookies"][cookie.name] = cookie;
|
|
14
|
+
return true;
|
|
15
|
+
};
|
|
16
|
+
const deleteCookie = (cookieName) => {
|
|
17
|
+
if (!document || !document["x-scalar-client-config-cookies"]) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
delete document["x-scalar-client-config-cookies"][cookieName];
|
|
21
|
+
return true;
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
addCookie,
|
|
25
|
+
deleteCookie
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
cookieMutators
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=cookie.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/mutators/cookie.ts"],
|
|
4
|
+
"sourcesContent": ["import type { UnknownObject } from '@/helpers/general'\nimport type {\n XScalarClientConfigCookie,\n XScalarClientConfigCookies,\n} from '@/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies'\n\n/**\n * Cookie mutators for managing client configuration cookies in OpenAPI documents.\n * Provides functions to add and delete cookies from the document's x-scalar-client-config-cookies extension.\n *\n * @param store - The workspace store containing the documents\n * @param documentName - The name of the document to operate on\n * @returns Object containing addCookie and deleteCookie functions\n */\nexport const cookieMutators = (\n document?: UnknownObject & { 'x-scalar-client-config-cookies'?: XScalarClientConfigCookies },\n) => {\n /**\n * Adds a new cookie to the document's client configuration.\n * If a cookie with the same name already exists, it will log a warning and return false.\n *\n * @param cookie - The cookie configuration to add\n * @returns true if the cookie was added successfully, false if it already exists\n *\n * @example\n * // Add a new authentication cookie\n * const success = addCookie({\n * name: 'auth-token',\n * value: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',\n * domain: '.example.com',\n * path: '/'\n * })\n *\n * if (success) {\n * console.log('Cookie added successfully')\n * } else {\n * console.log('Cookie already exists')\n * }\n */\n const addCookie = (cookie: XScalarClientConfigCookie) => {\n if (!document) {\n return false\n }\n\n if (!document['x-scalar-client-config-cookies']) {\n document['x-scalar-client-config-cookies'] = {}\n }\n\n if (document['x-scalar-client-config-cookies'][cookie.name]) {\n console.warn(`Cookie with name \"${cookie.name}\" already exists in the document.`)\n return false\n }\n\n document['x-scalar-client-config-cookies'][cookie.name] = cookie\n return true\n }\n\n /**\n * Removes a cookie from the document's x-scalar-client-config-cookies extension by its name.\n * Returns false if the document or cookies object does not exist, otherwise deletes the cookie and returns true.\n *\n * @param cookieName - The name of the cookie to remove\n *\n * @example\n * // Remove an authentication cookie\n * deleteCookie('auth-token')\n *\n * // Remove a session cookie\n * deleteCookie('session-id')\n */\n const deleteCookie = (cookieName: string) => {\n if (!document || !document['x-scalar-client-config-cookies']) {\n return false\n }\n\n delete document['x-scalar-client-config-cookies'][cookieName]\n return true\n }\n\n return {\n addCookie,\n deleteCookie,\n }\n}\n"],
|
|
5
|
+
"mappings": "AAcO,MAAM,iBAAiB,CAC5B,aACG;AAuBH,QAAM,YAAY,CAAC,WAAsC;AACvD,QAAI,CAAC,UAAU;AACb,aAAO;AAAA,IACT;AAEA,QAAI,CAAC,SAAS,gCAAgC,GAAG;AAC/C,eAAS,gCAAgC,IAAI,CAAC;AAAA,IAChD;AAEA,QAAI,SAAS,gCAAgC,EAAE,OAAO,IAAI,GAAG;AAC3D,cAAQ,KAAK,qBAAqB,OAAO,IAAI,mCAAmC;AAChF,aAAO;AAAA,IACT;AAEA,aAAS,gCAAgC,EAAE,OAAO,IAAI,IAAI;AAC1D,WAAO;AAAA,EACT;AAeA,QAAM,eAAe,CAAC,eAAuB;AAC3C,QAAI,CAAC,YAAY,CAAC,SAAS,gCAAgC,GAAG;AAC5D,aAAO;AAAA,IACT;AAEA,WAAO,SAAS,gCAAgC,EAAE,UAAU;AAC5D,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { UnknownObject } from '../helpers/general.js';
|
|
2
|
+
import type { xScalarClientConfigEnvironment, XScalarClientConfigEnvironments } from '../schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.js';
|
|
3
|
+
/**
|
|
4
|
+
* Environment mutators for managing client configuration environments in OpenAPI documents.
|
|
5
|
+
* Provides functions to add and delete environments from the document's x-scalar-client-config-environments extension.
|
|
6
|
+
*
|
|
7
|
+
* @param store - The workspace store containing the documents
|
|
8
|
+
* @param documentName - The name of the document to operate on
|
|
9
|
+
* @returns Object containing addEnvironment and deleteEnvironment functions
|
|
10
|
+
*/
|
|
11
|
+
export declare const environmentMutators: (document?: UnknownObject & {
|
|
12
|
+
"x-scalar-client-config-environments"?: XScalarClientConfigEnvironments;
|
|
13
|
+
}) => {
|
|
14
|
+
addEnvironment: (name: string, environment: xScalarClientConfigEnvironment) => boolean;
|
|
15
|
+
deleteEnvironment: (environmentName: string) => boolean;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/mutators/environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EACV,8BAA8B,EAC9B,+BAA+B,EAChC,MAAM,oFAAoF,CAAA;AAE3F;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,cACnB,aAAa,GAAG;IAAE,qCAAqC,CAAC,EAAE,+BAA+B,CAAA;CAAE;2BAsBxE,MAAM,eAAe,8BAA8B;yCA6BrC,MAAM;CAanD,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const environmentMutators = (document) => {
|
|
2
|
+
const addEnvironment = (name, environment) => {
|
|
3
|
+
if (!document) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
if (!document["x-scalar-client-config-environments"]) {
|
|
7
|
+
document["x-scalar-client-config-environments"] = {};
|
|
8
|
+
}
|
|
9
|
+
if (document["x-scalar-client-config-environments"][name]) {
|
|
10
|
+
console.warn(`Environment with name "${name}" already exists in the document.`);
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
document["x-scalar-client-config-environments"][name] = environment;
|
|
14
|
+
return true;
|
|
15
|
+
};
|
|
16
|
+
const deleteEnvironment = (environmentName) => {
|
|
17
|
+
if (!document || !document["x-scalar-client-config-environments"]) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
delete document["x-scalar-client-config-environments"][environmentName];
|
|
21
|
+
return true;
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
addEnvironment,
|
|
25
|
+
deleteEnvironment
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
environmentMutators
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/mutators/environment.ts"],
|
|
4
|
+
"sourcesContent": ["import type { UnknownObject } from '@/helpers/general'\nimport type {\n xScalarClientConfigEnvironment,\n XScalarClientConfigEnvironments,\n} from '@/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments'\n\n/**\n * Environment mutators for managing client configuration environments in OpenAPI documents.\n * Provides functions to add and delete environments from the document's x-scalar-client-config-environments extension.\n *\n * @param store - The workspace store containing the documents\n * @param documentName - The name of the document to operate on\n * @returns Object containing addEnvironment and deleteEnvironment functions\n */\nexport const environmentMutators = (\n document?: UnknownObject & { 'x-scalar-client-config-environments'?: XScalarClientConfigEnvironments },\n) => {\n /**\n * Adds a new environment to the document's client configuration.\n * If an environment with the same name already exists, it will log a warning and return false.\n *\n * @param name - The name of the environment to add\n * @param environment - The environment configuration to add\n * @returns true if the environment was added successfully, false if it already exists or document is missing\n *\n * @example\n * // Add a new development environment\n * const success = addEnvironment('development', {\n * variables: { apiUrl: 'https://dev.example.com/api' }\n * })\n *\n * if (success) {\n * console.log('Environment added successfully')\n * } else {\n * console.log('Environment already exists')\n * }\n */\n const addEnvironment = (name: string, environment: xScalarClientConfigEnvironment) => {\n if (!document) {\n return false\n }\n\n if (!document['x-scalar-client-config-environments']) {\n document['x-scalar-client-config-environments'] = {}\n }\n\n if (document['x-scalar-client-config-environments'][name]) {\n console.warn(`Environment with name \"${name}\" already exists in the document.`)\n return false\n }\n\n document['x-scalar-client-config-environments'][name] = environment\n return true\n }\n\n /**\n * Removes an environment from the document's x-scalar-client-config-environments extension by its name.\n * Returns false if the document or environments object does not exist, otherwise deletes the environment and returns true.\n *\n * @param environmentName - The name of the environment to remove\n * @returns true if the environment was deleted, false otherwise\n *\n * @example\n * // Remove a development environment\n * deleteEnvironment('development')\n */\n const deleteEnvironment = (environmentName: string) => {\n if (!document || !document['x-scalar-client-config-environments']) {\n return false\n }\n\n delete document['x-scalar-client-config-environments'][environmentName]\n return true\n }\n\n return {\n addEnvironment,\n deleteEnvironment,\n }\n}\n"],
|
|
5
|
+
"mappings": "AAcO,MAAM,sBAAsB,CACjC,aACG;AAqBH,QAAM,iBAAiB,CAAC,MAAc,gBAAgD;AACpF,QAAI,CAAC,UAAU;AACb,aAAO;AAAA,IACT;AAEA,QAAI,CAAC,SAAS,qCAAqC,GAAG;AACpD,eAAS,qCAAqC,IAAI,CAAC;AAAA,IACrD;AAEA,QAAI,SAAS,qCAAqC,EAAE,IAAI,GAAG;AACzD,cAAQ,KAAK,0BAA0B,IAAI,mCAAmC;AAC9E,aAAO;AAAA,IACT;AAEA,aAAS,qCAAqC,EAAE,IAAI,IAAI;AACxD,WAAO;AAAA,EACT;AAaA,QAAM,oBAAoB,CAAC,oBAA4B;AACrD,QAAI,CAAC,YAAY,CAAC,SAAS,qCAAqC,GAAG;AACjE,aAAO;AAAA,IACT;AAEA,WAAO,SAAS,qCAAqC,EAAE,eAAe;AACtE,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|