@scalar/workspace-store 0.10.2 → 0.11.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.
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/helpers/overrides-proxy.ts"],
4
+ "sourcesContent": ["import { isObject, type UnknownObject } from '@/helpers/general'\n\nconst isOverridesProxy = Symbol('isOverridesProxy')\n\nexport const createOverridesProxy = <T extends object>(targetObject: T, overrides?: unknown): T => {\n if (!targetObject || typeof targetObject !== 'object') {\n return targetObject\n }\n\n // Create a handler for the proxy\n const handler: ProxyHandler<T> = {\n get(target, prop, receiver) {\n if (prop === isOverridesProxy) {\n return true\n }\n\n if (prop === TARGET_SYMBOL) {\n // Return the original target object when accessing the TARGET_SYMBOL\n return target\n }\n\n const value = Reflect.get(target, prop, receiver)\n\n if (!isObject(value)) {\n return Reflect.get(overrides ?? {}, prop, receiver) ?? value\n }\n\n // If neither exists, return undefined\n // @ts-ignore\n return createOverridesProxy(value, overrides?.[prop])\n },\n\n set(target, prop, value, receiver) {\n if (prop === isOverridesProxy || prop === TARGET_SYMBOL) {\n // Don't allow setting these special properties\n return false\n }\n\n // Check if there's an override for this property\n const hasOverride = overrides && Reflect.has(overrides, prop)\n\n if (hasOverride && overrides && typeof overrides === 'object') {\n // Set the value on the overrides object, but ignore the receiver to avoid proxy issues\n ;(overrides as any)[prop] = value\n return true\n }\n\n // Set the value on the original target\n return Reflect.set(target, prop, value, receiver)\n },\n }\n\n // Create and return the proxy\n return new Proxy<T>(targetObject, handler)\n}\n\nexport const TARGET_SYMBOL = Symbol('overridesProxyTarget')\nexport function unpackOverridesProxy<T extends UnknownObject>(obj: T): T {\n if ((obj as T & { [isOverridesProxy]: boolean | undefined })[isOverridesProxy]) {\n return (obj as T & { [TARGET_SYMBOL]: T })[TARGET_SYMBOL]\n }\n\n return obj\n}\n"],
5
+ "mappings": "AAAA,SAAS,gBAAoC;AAE7C,MAAM,mBAAmB,OAAO,kBAAkB;AAE3C,MAAM,uBAAuB,CAAmB,cAAiB,cAA2B;AACjG,MAAI,CAAC,gBAAgB,OAAO,iBAAiB,UAAU;AACrD,WAAO;AAAA,EACT;AAGA,QAAM,UAA2B;AAAA,IAC/B,IAAI,QAAQ,MAAM,UAAU;AAC1B,UAAI,SAAS,kBAAkB;AAC7B,eAAO;AAAA,MACT;AAEA,UAAI,SAAS,eAAe;AAE1B,eAAO;AAAA,MACT;AAEA,YAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM,QAAQ;AAEhD,UAAI,CAAC,SAAS,KAAK,GAAG;AACpB,eAAO,QAAQ,IAAI,aAAa,CAAC,GAAG,MAAM,QAAQ,KAAK;AAAA,MACzD;AAIA,aAAO,qBAAqB,OAAO,YAAY,IAAI,CAAC;AAAA,IACtD;AAAA,IAEA,IAAI,QAAQ,MAAM,OAAO,UAAU;AACjC,UAAI,SAAS,oBAAoB,SAAS,eAAe;AAEvD,eAAO;AAAA,MACT;AAGA,YAAM,cAAc,aAAa,QAAQ,IAAI,WAAW,IAAI;AAE5D,UAAI,eAAe,aAAa,OAAO,cAAc,UAAU;AAE7D;AAAC,QAAC,UAAkB,IAAI,IAAI;AAC5B,eAAO;AAAA,MACT;AAGA,aAAO,QAAQ,IAAI,QAAQ,MAAM,OAAO,QAAQ;AAAA,IAClD;AAAA,EACF;AAGA,SAAO,IAAI,MAAS,cAAc,OAAO;AAC3C;AAEO,MAAM,gBAAgB,OAAO,sBAAsB;AACnD,SAAS,qBAA8C,KAAW;AACvE,MAAK,IAAwD,gBAAgB,GAAG;AAC9E,WAAQ,IAAmC,aAAa;AAAA,EAC1D;AAEA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -1,5 +1,4 @@
1
1
  import type { UnknownObject } from './general.js';
2
- export declare const TARGET_SYMBOL: unique symbol;
3
2
  /**
4
3
  * Creates a proxy that automatically resolves JSON references ($ref) in an object.
5
4
  * The proxy intercepts property access and automatically resolves any $ref references
@@ -49,6 +48,7 @@ export declare const TARGET_SYMBOL: unique symbol;
49
48
  * console.log(proxy1 === proxy2) // true
50
49
  */
51
50
  export declare function createMagicProxy<T extends UnknownObject | UnknownObject[]>(targetObject: T, sourceDocument?: T, resolvedProxyCache?: WeakMap<object, T>): T;
51
+ export declare const TARGET_SYMBOL: unique symbol;
52
52
  /**
53
53
  * Gets the raw (non-proxied) version of an object created by createMagicProxy.
54
54
  * This is useful when you need to access the original object without the magic proxy wrapper.
@@ -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,GAAG,aAAa,EAAE,EACxE,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
+ {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/helpers/proxy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AA2H9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EAAE,EACxE,YAAY,EAAE,CAAC,EACf,cAAc,GAAE,CAAgB,EAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GACtC,CAAC,CAyBH;AAED,eAAO,MAAM,aAAa,eAA6B,CAAA;AACvD;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,aAAa,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAMzD"}
@@ -1,14 +1,14 @@
1
1
  import { isReactive, toRaw } from "vue";
2
2
  import { getValueByPath, parseJsonPointer } from "./json-path-utils.js";
3
3
  import { isLocalRef, isObject } from "./general.js";
4
- const TARGET_SYMBOL = Symbol("target");
4
+ const isMagicProxy = Symbol("isMagicProxy");
5
5
  function createProxyHandler(sourceDocument, resolvedProxyCache) {
6
6
  return {
7
7
  get(target, property, receiver) {
8
8
  if (property === TARGET_SYMBOL) {
9
9
  return target;
10
10
  }
11
- if (property === "__isProxy") {
11
+ if (property === isMagicProxy) {
12
12
  return true;
13
13
  }
14
14
  const value = Reflect.get(target, property, receiver);
@@ -92,8 +92,12 @@ function createMagicProxy(targetObject, sourceDocument = targetObject, resolvedP
92
92
  }
93
93
  return proxy;
94
94
  }
95
+ const TARGET_SYMBOL = Symbol("magicProxyTarget");
95
96
  function getRaw(obj) {
96
- return obj[TARGET_SYMBOL];
97
+ if (obj[isMagicProxy]) {
98
+ return obj[TARGET_SYMBOL];
99
+ }
100
+ return obj;
97
101
  }
98
102
  export {
99
103
  TARGET_SYMBOL,
@@ -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 | UnknownObject[],\n resolvedProxyCache?: WeakMap<object, UnknownObject | UnknownObject[]>,\n): ProxyHandler<UnknownObject | 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) && !Array.isArray(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 | UnknownObject[]>(\n targetObject: T,\n sourceDocument: T = targetObject,\n resolvedProxyCache?: WeakMap<object, T>,\n): T {\n if (!isObject(targetObject) && !Array.isArray(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,oBAC+C;AAC/C,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,QAA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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;",
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\nconst isMagicProxy = Symbol('isMagicProxy')\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 | UnknownObject[],\n resolvedProxyCache?: WeakMap<object, UnknownObject | UnknownObject[]>,\n): ProxyHandler<UnknownObject | UnknownObject[]> {\n return {\n get(target, property, receiver) {\n if (property === TARGET_SYMBOL) {\n return target\n }\n\n if (property === isMagicProxy) {\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) && !Array.isArray(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 | UnknownObject[]>(\n targetObject: T,\n sourceDocument: T = targetObject,\n resolvedProxyCache?: WeakMap<object, T>,\n): T {\n if (!isObject(targetObject) && !Array.isArray(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\nexport const TARGET_SYMBOL = Symbol('magicProxyTarget')\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 if ((obj as T & { [isMagicProxy]: boolean | undefined })[isMagicProxy]) {\n return (obj as T & { [TARGET_SYMBOL]: T })[TARGET_SYMBOL]\n }\n\n return obj\n}\n"],
5
+ "mappings": "AAAA,SAAS,YAAY,aAAa;AAClC,SAAS,gBAAgB,wBAAwB;AACjD,SAAS,YAAY,gBAAgB;AAGrC,MAAM,eAAe,OAAO,cAAc;AAW1C,SAAS,mBACP,gBACA,oBAC+C;AAC/C,SAAO;AAAA,IACL,IAAI,QAAQ,UAAU,UAAU;AAC9B,UAAI,aAAa,eAAe;AAC9B,eAAO;AAAA,MACT;AAEA,UAAI,aAAa,cAAc;AAC7B,eAAO;AAAA,MACT;AAEA,YAAM,QAAQ,QAAQ,IAAI,QAAQ,UAAU,QAAQ;AASpD,YAAM,wBAAwB,CAACA,QAAgB,gBAAyB;AACtE,YAAI,CAAC,SAASA,MAAK,KAAK,CAAC,MAAM,QAAQA,MAAK,GAAG;AAC7C,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,kBAAkB;AAAA,MACnE;AAEA,aAAO,sBAAsB,KAAK;AAAA,IACpC;AAAA,IAEA,IAAI,QAAuB,UAAkB,UA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BAAiB,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,KAAK,CAAC,MAAM,QAAQ,YAAY,GAAG;AAC3D,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;AAEO,MAAM,gBAAgB,OAAO,kBAAkB;AAW/C,SAAS,OAAgC,KAAW;AACzD,MAAK,IAAoD,YAAY,GAAG;AACtE,WAAQ,IAAmC,aAAa;AAAA,EAC1D;AAEA,SAAO;AACT;",
6
6
  "names": ["value"]
7
7
  }
@@ -52,7 +52,7 @@ function generateClientMutators(store) {
52
52
  * Returns mutators for the currently active document.
53
53
  * Falls back to the first document if no active document is set.
54
54
  */
55
- active: () => documentMutators(store.workspace["x-scalar-active-document"] ?? Object.keys(store.workspace.documents)[0]),
55
+ active: () => documentMutators(store.workspace["x-scalar-active-document"] ?? Object.keys(store.workspace.documents)[0] ?? ""),
56
56
  /**
57
57
  * Returns mutators for a specific document by name.
58
58
  *
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/mutators/index.ts"],
4
- "sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport { cookieMutators } from '@/mutators/cookie'\nimport { environmentMutators } from '@/mutators/environment'\nimport { getDocument } from '@/mutators/helpers'\nimport { requestMutators } from '@/mutators/request'\nimport { requestExampleMutators } from '@/mutators/request-example'\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 * @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 requestExampleMutators: requestExampleMutators(document),\n requestMutators: requestMutators(document),\n securitySchemeMutators: securitySchemeMutators(document?.components?.securitySchemes),\n environmentMutators: environmentMutators(document),\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 environmentMutators: environmentMutators(store.workspace),\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"],
5
- "mappings": "AACA,SAAS,sBAAsB;AAC/B,SAAS,2BAA2B;AACpC,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,8BAA8B;AACvC,SAAS,8BAA8B;AACvC,SAAS,sBAAsB;AAQxB,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,wBAAwB,uBAAuB,QAAQ;AAAA,MACvD,iBAAiB,gBAAgB,QAAQ;AAAA,MACzC,wBAAwB,uBAAuB,UAAU,YAAY,eAAe;AAAA,MACpF,qBAAqB,oBAAoB,QAAQ;AAAA,MACjD,gBAAgB,eAAe,QAAQ;AAAA,MACvC,gBAAgB,eAAe,UAAU,OAAO;AAAA,IAClD;AAAA,EACF;AAOA,QAAM,oBAAoB,MAAM;AAC9B,UAAM,YAAY,MAAM;AAGxB,QAAI,CAAC,UAAU,gCAAgC,GAAG;AAChD,gBAAU,gCAAgC,IAAI,CAAC;AAAA,IACjD;AAGA,QAAI,CAAC,MAAM,UAAU,yCAAyC,GAAG;AAC/D,YAAM,UAAU,yCAAyC,IAAI,CAAC;AAAA,IAChE;AAEA,WAAO;AAAA,MACL,qBAAqB,oBAAoB,MAAM,SAAS;AAAA,MACxD,gBAAgB,eAAe,MAAM,SAAS;AAAA,MAC9C,gBAAgB,eAAe,MAAM,UAAU,gCAAgC,CAAC;AAAA,MAChF,wBAAwB,uBAAuB,MAAM,UAAU,yCAAyC,CAAC;AAAA,IAC3G;AAAA,EACF;AAEA,SAAO;AAAA;AAAA;AAAA;AAAA,IAIL,WAAW,MAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA,IAKnC,QAAQ,MACN,iBAAiB,MAAM,UAAU,0BAA0B,KAAK,OAAO,KAAK,MAAM,UAAU,SAAS,EAAE,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAM3G,KAAK,CAAC,SAAiB,iBAAiB,IAAI;AAAA,EAC9C;AACF;",
4
+ "sourcesContent": ["import type { WorkspaceStore } from '@/client'\nimport { cookieMutators } from '@/mutators/cookie'\nimport { environmentMutators } from '@/mutators/environment'\nimport { getDocument } from '@/mutators/helpers'\nimport { requestMutators } from '@/mutators/request'\nimport { requestExampleMutators } from '@/mutators/request-example'\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 * @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 requestExampleMutators: requestExampleMutators(document),\n requestMutators: requestMutators(document),\n securitySchemeMutators: securitySchemeMutators(document?.components?.securitySchemes),\n environmentMutators: environmentMutators(document),\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 environmentMutators: environmentMutators(store.workspace),\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"],
5
+ "mappings": "AACA,SAAS,sBAAsB;AAC/B,SAAS,2BAA2B;AACpC,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,8BAA8B;AACvC,SAAS,8BAA8B;AACvC,SAAS,sBAAsB;AAQxB,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;A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tagsMap, titlesMap, getModelId) => {
15
15
  const schemas = content.components?.schemas ?? {};
16
16
  const untagged = [];
17
17
  for (const name in schemas) {
18
- if (schemas[name]["x-internal"] || schemas[name]["x-scalar-ignore"] || !Object.hasOwn(schemas, name)) {
18
+ if (schemas[name]?.["x-internal"] || schemas[name]?.["x-scalar-ignore"] || !Object.hasOwn(schemas, name)) {
19
19
  continue;
20
20
  }
21
21
  const ref = `#/content/components/schemas/${name}`;
22
- if (schemas[name]["x-tags"]) {
22
+ if (schemas[name]?.["x-tags"]) {
23
23
  schemas[name]["x-tags"].forEach((tagName) => {
24
24
  const { tag } = getTag(tagsMap, tagName);
25
25
  tagsMap.get(tagName)?.entries.push(createSchemaEntry(ref, name, titlesMap, getModelId, tag));
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/navigation/helpers/traverse-schemas.ts"],
4
- "sourcesContent": ["import { getTag } from '@/navigation/helpers/get-tag'\nimport type { TagsMap, TraverseSpecOptions } from '@/navigation/types'\nimport type { TraversedSchema } from '@/schemas/navigation'\nimport type { OpenApiDocument } from '@/schemas/v3.1/strict/openapi-document'\nimport type { SchemaObject } from '@/schemas/v3.1/strict/schema'\nimport type { TagObject } from '@/schemas/v3.1/strict/tag'\n\n/** Creates a traversed schema entry from an OpenAPI schema object.\n *\n * @param ref - JSON pointer reference to the schema in the OpenAPI document\n * @param name - Name of the schema, defaults to 'Unknown'\n * @param titlesMap - Map to store schema IDs and titles for mobile header navigation\n * @param getModelId - Function to generate unique IDs for schemas\n * @returns A traversed schema entry with ID, title, name and reference\n */\nconst createSchemaEntry = (\n ref: string,\n name = 'Unknown',\n titlesMap: Map<string, string>,\n getModelId: TraverseSpecOptions['getModelId'],\n tag?: TagObject,\n schema?: SchemaObject,\n): TraversedSchema => {\n const id = getModelId({ name }, tag)\n\n // Use schema.title if available, otherwise fall back to name\n // @see https://json-schema.org/draft/2020-12/json-schema-core#section-4.3.5\n const title = (schema?.title as string) || name\n\n titlesMap.set(id, title)\n\n return {\n id,\n title,\n name,\n ref,\n type: 'model',\n }\n}\n\n/** Traverses the schemas in an OpenAPI document to build an array of model entries.\n *\n * This function processes each schema in components.schemas to:\n * - Filter out internal schemas (marked with x-internal) and schemas to ignore (marked with x-scalar-ignore)\n * - Create model entries with unique references and IDs\n * - Store model IDs and titles for mobile header navigation\n *\n * @param content - The OpenAPI document to traverse\n * @param titlesMap - Map to store schema IDs and titles for mobile header navigation\n * @param getModelId - Function to generate unique IDs for schemas\n * @returns Array of traversed schema entries\n */\nexport const traverseSchemas = (\n content: OpenApiDocument,\n /** Map of tagNames and their entries */\n tagsMap: TagsMap,\n /** Map of titles for the mobile header */\n titlesMap: Map<string, string>,\n getModelId: TraverseSpecOptions['getModelId'],\n): TraversedSchema[] => {\n const schemas = content.components?.schemas ?? {}\n const untagged: TraversedSchema[] = []\n\n for (const name in schemas) {\n if (schemas[name]['x-internal'] || schemas[name]['x-scalar-ignore'] || !Object.hasOwn(schemas, name)) {\n continue\n }\n\n const ref = `#/content/components/schemas/${name}`\n\n // Add to tags\n if (schemas[name]['x-tags']) {\n schemas[name]['x-tags'].forEach((tagName: string) => {\n const { tag } = getTag(tagsMap, tagName)\n tagsMap.get(tagName)?.entries.push(createSchemaEntry(ref, name, titlesMap, getModelId, tag))\n })\n }\n // Add to untagged\n else {\n untagged.push(createSchemaEntry(ref, name, titlesMap, getModelId, undefined, schemas[name]))\n }\n }\n\n return untagged\n}\n"],
5
- "mappings": "AAAA,SAAS,cAAc;AAevB,MAAM,oBAAoB,CACxB,KACA,OAAO,WACP,WACA,YACA,KACA,WACoB;AACpB,QAAM,KAAK,WAAW,EAAE,KAAK,GAAG,GAAG;AAInC,QAAM,QAAS,QAAQ,SAAoB;AAE3C,YAAU,IAAI,IAAI,KAAK;AAEvB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,EACR;AACF;AAcO,MAAM,kBAAkB,CAC7B,SAEA,SAEA,WACA,eACsB;AACtB,QAAM,UAAU,QAAQ,YAAY,WAAW,CAAC;AAChD,QAAM,WAA8B,CAAC;AAErC,aAAW,QAAQ,SAAS;AAC1B,QAAI,QAAQ,IAAI,EAAE,YAAY,KAAK,QAAQ,IAAI,EAAE,iBAAiB,KAAK,CAAC,OAAO,OAAO,SAAS,IAAI,GAAG;AACpG;AAAA,IACF;AAEA,UAAM,MAAM,gCAAgC,IAAI;AAGhD,QAAI,QAAQ,IAAI,EAAE,QAAQ,GAAG;AAC3B,cAAQ,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,YAAoB;AACnD,cAAM,EAAE,IAAI,IAAI,OAAO,SAAS,OAAO;AACvC,gBAAQ,IAAI,OAAO,GAAG,QAAQ,KAAK,kBAAkB,KAAK,MAAM,WAAW,YAAY,GAAG,CAAC;AAAA,MAC7F,CAAC;AAAA,IACH,OAEK;AACH,eAAS,KAAK,kBAAkB,KAAK,MAAM,WAAW,YAAY,QAAW,QAAQ,IAAI,CAAC,CAAC;AAAA,IAC7F;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import { getTag } from '@/navigation/helpers/get-tag'\nimport type { TagsMap, TraverseSpecOptions } from '@/navigation/types'\nimport type { TraversedSchema } from '@/schemas/navigation'\nimport type { OpenApiDocument } from '@/schemas/v3.1/strict/openapi-document'\nimport type { SchemaObject } from '@/schemas/v3.1/strict/schema'\nimport type { TagObject } from '@/schemas/v3.1/strict/tag'\n\n/** Creates a traversed schema entry from an OpenAPI schema object.\n *\n * @param ref - JSON pointer reference to the schema in the OpenAPI document\n * @param name - Name of the schema, defaults to 'Unknown'\n * @param titlesMap - Map to store schema IDs and titles for mobile header navigation\n * @param getModelId - Function to generate unique IDs for schemas\n * @returns A traversed schema entry with ID, title, name and reference\n */\nconst createSchemaEntry = (\n ref: string,\n name = 'Unknown',\n titlesMap: Map<string, string>,\n getModelId: TraverseSpecOptions['getModelId'],\n tag?: TagObject,\n schema?: SchemaObject,\n): TraversedSchema => {\n const id = getModelId({ name }, tag)\n\n // Use schema.title if available, otherwise fall back to name\n // @see https://json-schema.org/draft/2020-12/json-schema-core#section-4.3.5\n const title = (schema?.title as string) || name\n\n titlesMap.set(id, title)\n\n return {\n id,\n title,\n name,\n ref,\n type: 'model',\n }\n}\n\n/** Traverses the schemas in an OpenAPI document to build an array of model entries.\n *\n * This function processes each schema in components.schemas to:\n * - Filter out internal schemas (marked with x-internal) and schemas to ignore (marked with x-scalar-ignore)\n * - Create model entries with unique references and IDs\n * - Store model IDs and titles for mobile header navigation\n *\n * @param content - The OpenAPI document to traverse\n * @param titlesMap - Map to store schema IDs and titles for mobile header navigation\n * @param getModelId - Function to generate unique IDs for schemas\n * @returns Array of traversed schema entries\n */\nexport const traverseSchemas = (\n content: OpenApiDocument,\n /** Map of tagNames and their entries */\n tagsMap: TagsMap,\n /** Map of titles for the mobile header */\n titlesMap: Map<string, string>,\n getModelId: TraverseSpecOptions['getModelId'],\n): TraversedSchema[] => {\n const schemas = content.components?.schemas ?? {}\n const untagged: TraversedSchema[] = []\n\n for (const name in schemas) {\n if (schemas[name]?.['x-internal'] || schemas[name]?.['x-scalar-ignore'] || !Object.hasOwn(schemas, name)) {\n continue\n }\n\n const ref = `#/content/components/schemas/${name}`\n\n // Add to tags\n if (schemas[name]?.['x-tags']) {\n schemas[name]['x-tags'].forEach((tagName: string) => {\n const { tag } = getTag(tagsMap, tagName)\n tagsMap.get(tagName)?.entries.push(createSchemaEntry(ref, name, titlesMap, getModelId, tag))\n })\n }\n // Add to untagged\n else {\n untagged.push(createSchemaEntry(ref, name, titlesMap, getModelId, undefined, schemas[name]))\n }\n }\n\n return untagged\n}\n"],
5
+ "mappings": "AAAA,SAAS,cAAc;AAevB,MAAM,oBAAoB,CACxB,KACA,OAAO,WACP,WACA,YACA,KACA,WACoB;AACpB,QAAM,KAAK,WAAW,EAAE,KAAK,GAAG,GAAG;AAInC,QAAM,QAAS,QAAQ,SAAoB;AAE3C,YAAU,IAAI,IAAI,KAAK;AAEvB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM;AAAA,EACR;AACF;AAcO,MAAM,kBAAkB,CAC7B,SAEA,SAEA,WACA,eACsB;AACtB,QAAM,UAAU,QAAQ,YAAY,WAAW,CAAC;AAChD,QAAM,WAA8B,CAAC;AAErC,aAAW,QAAQ,SAAS;AAC1B,QAAI,QAAQ,IAAI,IAAI,YAAY,KAAK,QAAQ,IAAI,IAAI,iBAAiB,KAAK,CAAC,OAAO,OAAO,SAAS,IAAI,GAAG;AACxG;AAAA,IACF;AAEA,UAAM,MAAM,gCAAgC,IAAI;AAGhD,QAAI,QAAQ,IAAI,IAAI,QAAQ,GAAG;AAC7B,cAAQ,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,YAAoB;AACnD,cAAM,EAAE,IAAI,IAAI,OAAO,SAAS,OAAO;AACvC,gBAAQ,IAAI,OAAO,GAAG,QAAQ,KAAK,kBAAkB,KAAK,MAAM,WAAW,YAAY,GAAG,CAAC;AAAA,MAC7F,CAAC;AAAA,IACH,OAEK;AACH,eAAS,KAAK,kBAAkB,KAAK,MAAM,WAAW,YAAY,QAAW,QAAQ,IAAI,CAAC,CAAC;AAAA,IAC7F;AAAA,EACF;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -66,8 +66,8 @@ const traverseTags = (content, tagsMap, titlesMap, { getTagId, tagsSorter, opera
66
66
  }
67
67
  const keys = Array.from(tagsMap.keys());
68
68
  const tags = getSortedTagEntries(keys, tagsMap, titlesMap, { getTagId, tagsSorter, operationsSorter });
69
- if (tags.length === 1 && tags[0].title === "default") {
70
- return tags[0].children ?? [];
69
+ if (tags.length === 1 && tags[0]?.title === "default") {
70
+ return tags[0]?.children ?? [];
71
71
  }
72
72
  return tags;
73
73
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/navigation/helpers/traverse-tags.ts"],
4
- "sourcesContent": ["import type { TagObject } from '@/schemas/v3.1/strict/tag'\nimport { getTag } from './get-tag'\nimport type { TagsMap, TraverseSpecOptions } from '@/navigation/types'\nimport type { OpenApiDocument } from '@/schemas/v3.1/strict/openapi-document'\nimport type { TraversedEntry, TraversedTag } from '@/schemas/navigation'\n\ntype Options = Pick<TraverseSpecOptions, 'getTagId' | 'tagsSorter' | 'operationsSorter'>\n\n/** Creates a traversed tag entry from an OpenAPI tag object.\n *\n * @param tag - The OpenAPI tag object\n * @param titlesMap - Map to store tag IDs and titles for mobile header navigation\n * @param getTagId - Function to generate unique IDs for tags\n * @param children - Array of child entries (operations, webhooks, etc.)\n * @param isGroup - Whether this tag represents a group of tags\n * @returns A traversed tag entry with ID, title, name and children\n */\nconst createTagEntry = (\n tag: TagObject,\n titlesMap: Map<string, string>,\n getTagId: TraverseSpecOptions['getTagId'],\n children: TraversedEntry[],\n isGroup = false,\n): TraversedTag => {\n const id = getTagId(tag)\n const title = tag['x-displayName'] ?? tag.name ?? 'Untitled Tag'\n titlesMap.set(id, title)\n\n return {\n id,\n title,\n name: tag.name || title,\n children,\n isGroup,\n type: 'tag',\n }\n}\n\n/** Sorts and processes tags to create a hierarchical structure of tag entries.\n *\n * This function handles:\n * - Sorting tags alphabetically or using a custom sort function\n * - Ensuring the default tag appears last\n * - Sorting operations within tags by title, method, or custom function\n * - Filtering out internal and ignored tags\n * - Creating tag entries with their associated operations\n *\n * @param _keys - Array of tag keys to process\n * @param tagsMap - Map of tags and their entries\n * @param tagsDict - Dictionary of OpenAPI tags by name\n * @param titlesMap - Map of titles for the mobile header\n * @param options - Sorting and ID generation options\n * @returns Array of processed and sorted tag entries\n */\n/** Sorts tags and returns entries */\nconst getSortedTagEntries = (\n _keys: string[],\n /** Map of tags and their entries */\n tagsMap: TagsMap,\n /** Map of titles for the mobile header */\n titlesMap: Map<string, string>,\n { getTagId, tagsSorter, operationsSorter }: Options,\n) => {\n // Ensure that default is last if it exists\n const hasDefault = _keys.includes('default')\n const keys = hasDefault ? _keys.filter((key) => key !== 'default') : _keys\n\n // Alpha sort\n if (tagsSorter === 'alpha') {\n keys.sort((a, b) => {\n const nameA = getTag(tagsMap, a).tag['x-displayName'] || a || 'Untitled Tag'\n const nameB = getTag(tagsMap, b).tag['x-displayName'] || b || 'Untitled Tag'\n return nameA.localeCompare(nameB)\n })\n }\n // Custom sort\n else if (typeof tagsSorter === 'function') {\n keys.sort((a, b) => tagsSorter(getTag(tagsMap, a).tag, getTag(tagsMap, b).tag))\n }\n\n if (hasDefault) {\n keys.push('default')\n }\n\n /**\n * Process each tag and its entries:\n * - Skip internal and ignored tags\n * - Sort operations within tags\n * - Create tag entries with sorted operations\n */\n return keys.flatMap((key) => {\n const { tag, entries } = getTag(tagsMap, key)\n\n // Skip if the tag is internal or scalar-ignore\n if (tag['x-internal'] || tag['x-scalar-ignore']) {\n return []\n }\n\n // Alpha sort\n if (operationsSorter === 'alpha') {\n entries.sort((a, b) => ('method' in a && 'method' in b ? a.title.localeCompare(b.title) : 0))\n }\n // Method sort\n else if (operationsSorter === 'method') {\n entries.sort((a, b) => ('method' in a && 'method' in b ? a.method.localeCompare(b.method) : 0))\n }\n // Custom sort\n else if (typeof operationsSorter === 'function') {\n entries.sort((a, b) => {\n // Guard against tags\n if ((a.type !== 'operation' && a.type !== 'webhook') || (b.type !== 'operation' && b.type !== 'webhook')) {\n return 0\n }\n\n // Handle webhooks as well as operations\n const pathA = a.type === 'operation' ? a.path : a.name\n const pathB = b.type === 'operation' ? b.path : b.name\n\n return operationsSorter(\n { method: a.method, path: pathA, ref: a.ref, httpVerb: a.method },\n { method: b.method, path: pathB, ref: b.ref, httpVerb: b.method },\n )\n })\n }\n\n return entries.length ? createTagEntry(tag, titlesMap, getTagId, entries) : []\n })\n}\n\n/**\n * Traverses the tags map to create navigation entries, handling both grouped and ungrouped tags.\n *\n * This function processes the OpenAPI document's tags to:\n * - Handle tag groups if specified via x-tagGroups\n * - Sort tags and their operations according to provided sorters\n * - Create navigation entries for each tag or tag group\n * - Flatten default tag entries if it's the only tag present\n */\nexport const traverseTags = (\n content: OpenApiDocument,\n /** Map of tags and their entries */\n tagsMap: TagsMap,\n /** Map of titles for the mobile title */\n titlesMap: Map<string, string>,\n { getTagId, tagsSorter, operationsSorter }: Options,\n): TraversedEntry[] => {\n // x-tagGroups\n if (content['x-tagGroups']) {\n const tagGroups = content['x-tagGroups']\n\n return tagGroups.flatMap((tagGroup) => {\n const entries = getSortedTagEntries(tagGroup.tags ?? [], tagsMap, titlesMap, {\n getTagId,\n tagsSorter,\n operationsSorter,\n })\n return entries.length ? createTagEntry(tagGroup, titlesMap, getTagId, entries, true) : []\n })\n }\n\n // Ungrouped regular tags\n const keys = Array.from(tagsMap.keys())\n const tags = getSortedTagEntries(keys, tagsMap, titlesMap, { getTagId, tagsSorter, operationsSorter })\n\n // Flatten if we only have default tag\n if (tags.length === 1 && tags[0].title === 'default') {\n return tags[0].children ?? []\n }\n\n return tags\n}\n"],
5
- "mappings": "AACA,SAAS,cAAc;AAgBvB,MAAM,iBAAiB,CACrB,KACA,WACA,UACA,UACA,UAAU,UACO;AACjB,QAAM,KAAK,SAAS,GAAG;AACvB,QAAM,QAAQ,IAAI,eAAe,KAAK,IAAI,QAAQ;AAClD,YAAU,IAAI,IAAI,KAAK;AAEvB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,MAAM,IAAI,QAAQ;AAAA,IAClB;AAAA,IACA;AAAA,IACA,MAAM;AAAA,EACR;AACF;AAmBA,MAAM,sBAAsB,CAC1B,OAEA,SAEA,WACA,EAAE,UAAU,YAAY,iBAAiB,MACtC;AAEH,QAAM,aAAa,MAAM,SAAS,SAAS;AAC3C,QAAM,OAAO,aAAa,MAAM,OAAO,CAAC,QAAQ,QAAQ,SAAS,IAAI;AAGrE,MAAI,eAAe,SAAS;AAC1B,SAAK,KAAK,CAAC,GAAG,MAAM;AAClB,YAAM,QAAQ,OAAO,SAAS,CAAC,EAAE,IAAI,eAAe,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E,KAAK,UAAU,EAAE,OAAO;AAAA,QAClE;AAAA,MACF,CAAC;AAAA,IACH;AAEA,WAAO,QAAQ,SAAS,eAAe,KAAK,WAAW,UAAU,OAAO,IAAI,CAAC;AAAA,EAC/E,CAAC;AACH;AAWO,MAAM,eAAe,CAC1B,SAEA,SAEA,WACA,EAAE,UAAU,YAAY,iBAAiB,MACpB;AAErB,MAAI,QAAQ,aAAa,GAAG;AAC1B,UAAM,YAAY,QAAQ,aAAa;AAEvC,WAAO,UAAU,QAAQ,CAAC,aAAa;AACrC,YAAM,UAAU,oBAAoB,SAAS,QAAQ,CAAC,GAAG,SAAS,WAAW;AAAA,QAC3E;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AACD,aAAO,QAAQ,SAAS,eAAe,UAAU,WAAW,UAAU,SAAS,IAAI,IAAI,CAAC;AAAA,IAC1F,CAAC;AAAA,EACH;AAGA,QAAM,OAAO,MAAM,KAAK,QAAQ,KAAK,CAAC;AACtC,QAAM,OAAO,oBAAoB,MAAM,SAAS,WAAW,EAAE,UAAU,YAAY,iBAAiB,CAAC;AAGrG,MAAI,KAAK,WAAW,KAAK,KAAK,CAAC,EAAE,UAAU,WAAW;AACpD,WAAO,KAAK,CAAC,EAAE,YAAY,CAAC;AAAA,EAC9B;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["import type { TagObject } from '@/schemas/v3.1/strict/tag'\nimport { getTag } from './get-tag'\nimport type { TagsMap, TraverseSpecOptions } from '@/navigation/types'\nimport type { OpenApiDocument } from '@/schemas/v3.1/strict/openapi-document'\nimport type { TraversedEntry, TraversedTag } from '@/schemas/navigation'\n\ntype Options = Pick<TraverseSpecOptions, 'getTagId' | 'tagsSorter' | 'operationsSorter'>\n\n/** Creates a traversed tag entry from an OpenAPI tag object.\n *\n * @param tag - The OpenAPI tag object\n * @param titlesMap - Map to store tag IDs and titles for mobile header navigation\n * @param getTagId - Function to generate unique IDs for tags\n * @param children - Array of child entries (operations, webhooks, etc.)\n * @param isGroup - Whether this tag represents a group of tags\n * @returns A traversed tag entry with ID, title, name and children\n */\nconst createTagEntry = (\n tag: TagObject,\n titlesMap: Map<string, string>,\n getTagId: TraverseSpecOptions['getTagId'],\n children: TraversedEntry[],\n isGroup = false,\n): TraversedTag => {\n const id = getTagId(tag)\n const title = tag['x-displayName'] ?? tag.name ?? 'Untitled Tag'\n titlesMap.set(id, title)\n\n return {\n id,\n title,\n name: tag.name || title,\n children,\n isGroup,\n type: 'tag',\n }\n}\n\n/** Sorts and processes tags to create a hierarchical structure of tag entries.\n *\n * This function handles:\n * - Sorting tags alphabetically or using a custom sort function\n * - Ensuring the default tag appears last\n * - Sorting operations within tags by title, method, or custom function\n * - Filtering out internal and ignored tags\n * - Creating tag entries with their associated operations\n *\n * @param _keys - Array of tag keys to process\n * @param tagsMap - Map of tags and their entries\n * @param tagsDict - Dictionary of OpenAPI tags by name\n * @param titlesMap - Map of titles for the mobile header\n * @param options - Sorting and ID generation options\n * @returns Array of processed and sorted tag entries\n */\n/** Sorts tags and returns entries */\nconst getSortedTagEntries = (\n _keys: string[],\n /** Map of tags and their entries */\n tagsMap: TagsMap,\n /** Map of titles for the mobile header */\n titlesMap: Map<string, string>,\n { getTagId, tagsSorter, operationsSorter }: Options,\n) => {\n // Ensure that default is last if it exists\n const hasDefault = _keys.includes('default')\n const keys = hasDefault ? _keys.filter((key) => key !== 'default') : _keys\n\n // Alpha sort\n if (tagsSorter === 'alpha') {\n keys.sort((a, b) => {\n const nameA = getTag(tagsMap, a).tag['x-displayName'] || a || 'Untitled Tag'\n const nameB = getTag(tagsMap, b).tag['x-displayName'] || b || 'Untitled Tag'\n return nameA.localeCompare(nameB)\n })\n }\n // Custom sort\n else if (typeof tagsSorter === 'function') {\n keys.sort((a, b) => tagsSorter(getTag(tagsMap, a).tag, getTag(tagsMap, b).tag))\n }\n\n if (hasDefault) {\n keys.push('default')\n }\n\n /**\n * Process each tag and its entries:\n * - Skip internal and ignored tags\n * - Sort operations within tags\n * - Create tag entries with sorted operations\n */\n return keys.flatMap((key) => {\n const { tag, entries } = getTag(tagsMap, key)\n\n // Skip if the tag is internal or scalar-ignore\n if (tag['x-internal'] || tag['x-scalar-ignore']) {\n return []\n }\n\n // Alpha sort\n if (operationsSorter === 'alpha') {\n entries.sort((a, b) => ('method' in a && 'method' in b ? a.title.localeCompare(b.title) : 0))\n }\n // Method sort\n else if (operationsSorter === 'method') {\n entries.sort((a, b) => ('method' in a && 'method' in b ? a.method.localeCompare(b.method) : 0))\n }\n // Custom sort\n else if (typeof operationsSorter === 'function') {\n entries.sort((a, b) => {\n // Guard against tags\n if ((a.type !== 'operation' && a.type !== 'webhook') || (b.type !== 'operation' && b.type !== 'webhook')) {\n return 0\n }\n\n // Handle webhooks as well as operations\n const pathA = a.type === 'operation' ? a.path : a.name\n const pathB = b.type === 'operation' ? b.path : b.name\n\n return operationsSorter(\n { method: a.method, path: pathA, ref: a.ref, httpVerb: a.method },\n { method: b.method, path: pathB, ref: b.ref, httpVerb: b.method },\n )\n })\n }\n\n return entries.length ? createTagEntry(tag, titlesMap, getTagId, entries) : []\n })\n}\n\n/**\n * Traverses the tags map to create navigation entries, handling both grouped and ungrouped tags.\n *\n * This function processes the OpenAPI document's tags to:\n * - Handle tag groups if specified via x-tagGroups\n * - Sort tags and their operations according to provided sorters\n * - Create navigation entries for each tag or tag group\n * - Flatten default tag entries if it's the only tag present\n */\nexport const traverseTags = (\n content: OpenApiDocument,\n /** Map of tags and their entries */\n tagsMap: TagsMap,\n /** Map of titles for the mobile title */\n titlesMap: Map<string, string>,\n { getTagId, tagsSorter, operationsSorter }: Options,\n): TraversedEntry[] => {\n // x-tagGroups\n if (content['x-tagGroups']) {\n const tagGroups = content['x-tagGroups']\n\n return tagGroups.flatMap((tagGroup) => {\n const entries = getSortedTagEntries(tagGroup.tags ?? [], tagsMap, titlesMap, {\n getTagId,\n tagsSorter,\n operationsSorter,\n })\n return entries.length ? createTagEntry(tagGroup, titlesMap, getTagId, entries, true) : []\n })\n }\n\n // Ungrouped regular tags\n const keys = Array.from(tagsMap.keys())\n const tags = getSortedTagEntries(keys, tagsMap, titlesMap, { getTagId, tagsSorter, operationsSorter })\n\n // Flatten if we only have default tag\n if (tags.length === 1 && tags[0]?.title === 'default') {\n return tags[0]?.children ?? []\n }\n\n return tags\n}\n"],
5
+ "mappings": "AACA,SAAS,cAAc;AAgBvB,MAAM,iBAAiB,CACrB,KACA,WACA,UACA,UACA,UAAU,UACO;AACjB,QAAM,KAAK,SAAS,GAAG;AACvB,QAAM,QAAQ,IAAI,eAAe,KAAK,IAAI,QAAQ;AAClD,YAAU,IAAI,IAAI,KAAK;AAEvB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,MAAM,IAAI,QAAQ;AAAA,IAClB;AAAA,IACA;AAAA,IACA,MAAM;AAAA,EACR;AACF;AAmBA,MAAM,sBAAsB,CAC1B,OAEA,SAEA,WACA,EAAE,UAAU,YAAY,iBAAiB,MACtC;AAEH,QAAM,aAAa,MAAM,SAAS,SAAS;AAC3C,QAAM,OAAO,aAAa,MAAM,OAAO,CAAC,QAAQ,QAAQ,SAAS,IAAI;AAGrE,MAAI,eAAe,SAAS;AAC1B,SAAK,KAAK,CAAC,GAAG,MAAM;AAClB,YAAM,QAAQ,OAAO,SAAS,CAAC,EAAE,IAAI,eAAe,KAAK,KAAK;AAC9D,YAAM,QAAQ,OAAO,SAAS,CAAC,EAAE,IAAI,eAAe,KAAK,KAAK;AAC9D,aAAO,MAAM,cAAc,KAAK;AAAA,IAClC,CAAC;AAAA,EACH,WAES,OAAO,eAAe,YAAY;AACzC,SAAK,KAAK,CAAC,GAAG,MAAM,WAAW,OAAO,SAAS,CAAC,EAAE,KAAK,OAAO,SAAS,CAAC,EAAE,GAAG,CAAC;AAAA,EAChF;AAEA,MAAI,YAAY;AACd,SAAK,KAAK,SAAS;AAAA,EACrB;AAQA,SAAO,KAAK,QAAQ,CAAC,QAAQ;AAC3B,UAAM,EAAE,KAAK,QAAQ,IAA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AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AACD,aAAO,QAAQ,SAAS,eAAe,UAAU,WAAW,UAAU,SAAS,IAAI,IAAI,CAAC;AAAA,IAC1F,CAAC;AAAA,EACH;AAGA,QAAM,OAAO,MAAM,KAAK,QAAQ,KAAK,CAAC;AACtC,QAAM,OAAO,oBAAoB,MAAM,SAAS,WAAW,EAAE,UAAU,YAAY,iBAAiB,CAAC;AAGrG,MAAI,KAAK,WAAW,KAAK,KAAK,CAAC,GAAG,UAAU,WAAW;AACrD,WAAO,KAAK,CAAC,GAAG,YAAY,CAAC;AAAA,EAC/B;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,5 @@
1
1
  import { type Static } from '@sinclair/typebox';
2
- import type { DeepTransform } from '../../types.js';
2
+ import type { DeepRequired } from '../../types.js';
3
3
  /**
4
4
  * ReferenceConfigSchema defines the shape of the configuration object
5
5
  * for the API Reference. All properties are optional due to Type.Partial.
@@ -49,5 +49,5 @@ export declare const ReferenceConfigSchema: import("@sinclair/typebox").TObject<
49
49
  httpClients: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"c/libcurl" | "clojure/clj_http" | "csharp/httpclient" | "csharp/restsharp" | "dart/http" | "go/native" | "http/http1.1" | "java/asynchttp" | "java/nethttp" | "java/okhttp" | "java/unirest" | "js/axios" | "js/fetch" | "js/jquery" | "js/ofetch" | "js/xhr" | "kotlin/okhttp" | "node/axios" | "node/fetch" | "node/ofetch" | "node/undici" | "objc/nsurlsession" | "ocaml/cohttp" | "php/curl" | "php/guzzle" | "powershell/restmethod" | "powershell/webrequest" | "python/python3" | "python/requests" | "python/httpx_sync" | "python/httpx_async" | "r/httr" | "ruby/native" | "rust/reqwest" | "shell/curl" | "shell/httpie" | "shell/wget" | "swift/nsurlsession">[]>>>;
50
50
  }>;
51
51
  export type ReferenceConfig = Static<typeof ReferenceConfigSchema>;
52
- export declare const defaultReferenceConfig: DeepTransform<ReferenceConfig, 'NonNullable'>;
52
+ export declare const defaultReferenceConfig: DeepRequired<ReferenceConfig>;
53
53
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schemas/reference-config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAOrD,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,SAAS,CAAA;AAE1D;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuBjC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAElE,eAAO,MAAM,sBAAsB,EAAE,aAAa,CAAC,eAAe,EAAE,aAAa,CAkChF,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schemas/reference-config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAOrD,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,SAAS,CAAA;AAEzD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuBjC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAElE,eAAO,MAAM,sBAAsB,EAAE,YAAY,CAAC,eAAe,CAkChE,CAAA"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/schemas/reference-config/index.ts"],
4
- "sourcesContent": ["import { Type, type Static } from '@sinclair/typebox'\nimport { AVAILABLE_CLIENTS } from '@scalar/types/snippetz'\nimport { defaultMeta, MetaSchema } from '@/schemas/reference-config/meta'\nimport { defaultFeatures, FeaturesSchema } from '@/schemas/reference-config/features'\nimport { AppearanceSchema, defaultAppearance } from '@/schemas/reference-config/appearance'\nimport { defaultRouting, RoutingSchema } from '@/schemas/reference-config/routing'\nimport { defaultSettings, SettingsSchema } from '@/schemas/reference-config/settings'\nimport type { DeepTransform, MutableArray } from '@/types'\n\n/**\n * ReferenceConfigSchema defines the shape of the configuration object\n * for the API Reference. All properties are optional due to Type.Partial.\n * This schema is used for validating and typing the configuration.\n */\nexport const ReferenceConfigSchema = Type.Partial(\n Type.Object({\n /** Document level title */\n title: Type.String(),\n /** Unique slug to identify the document */\n slug: Type.String(),\n /** Settings for the API reference (controls behavior and options) */\n settings: SettingsSchema,\n /** Tag sorting method: currently only 'alpha' (alphabetical) is supported */\n tagSort: Type.Union([Type.Literal('alpha')]),\n /** Operation sorting method: by HTTP method or alphabetically */\n operationSort: Type.Union([Type.Literal('method'), Type.Literal('alpha')]),\n /** Routing configuration (controls navigation) */\n routing: RoutingSchema,\n /** Appearance configuration (controls theming and UI options) */\n appearance: AppearanceSchema,\n /** Features configuration (toggles for enabling/disabling features) */\n features: FeaturesSchema,\n /** Meta information */\n meta: MetaSchema,\n /** List of enabled HTTP clients for code samples */\n httpClients: Type.Array(Type.Union(AVAILABLE_CLIENTS.map((client) => Type.Literal(client)))),\n }),\n)\n\nexport type ReferenceConfig = Static<typeof ReferenceConfigSchema>\n\nexport const defaultReferenceConfig: DeepTransform<ReferenceConfig, 'NonNullable'> = {\n title: 'Scalar API Reference',\n slug: 'scalar-api-reference',\n tagSort: 'alpha',\n operationSort: 'method',\n\n /**\n * Default settings for the API reference.\n */\n settings: defaultSettings,\n\n /**\n * Default routing configuration for the API reference.\n */\n routing: defaultRouting,\n /**\n * Default appearance configuration for the API reference.\n */\n appearance: defaultAppearance,\n\n /**\n * Default features configuration for the API reference.\n */\n features: defaultFeatures,\n\n /**\n * Default meta configuration for the API reference.\n */\n meta: defaultMeta,\n\n /**\n * Default HTTP clients for the API reference.\n */\n httpClients: AVAILABLE_CLIENTS as MutableArray<typeof AVAILABLE_CLIENTS>,\n}\n"],
5
- "mappings": "AAAA,SAAS,YAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,aAAa,kBAAkB;AACxC,SAAS,iBAAiB,sBAAsB;AAChD,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,gBAAgB,qBAAqB;AAC9C,SAAS,iBAAiB,sBAAsB;AAQzC,MAAM,wBAAwB,KAAK;AAAA,EACxC,KAAK,OAAO;AAAA;AAAA,IAEV,OAAO,KAAK,OAAO;AAAA;AAAA,IAEnB,MAAM,KAAK,OAAO;AAAA;AAAA,IAElB,UAAU;AAAA;AAAA,IAEV,SAAS,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,CAAC,CAAC;AAAA;AAAA,IAE3C,eAAe,KAAK,MAAM,CAAC,KAAK,QAAQ,QAAQ,GAAG,KAAK,QAAQ,OAAO,CAAC,CAAC;AAAA;AAAA,IAEzE,SAAS;AAAA;AAAA,IAET,YAAY;AAAA;AAAA,IAEZ,UAAU;AAAA;AAAA,IAEV,MAAM;AAAA;AAAA,IAEN,aAAa,KAAK,MAAM,KAAK,MAAM,kBAAkB,IAAI,CAAC,WAAW,KAAK,QAAQ,MAAM,CAAC,CAAC,CAAC;AAAA,EAC7F,CAAC;AACH;AAIO,MAAM,yBAAwE;AAAA,EACnF,OAAO;AAAA,EACP,MAAM;AAAA,EACN,SAAS;AAAA,EACT,eAAe;AAAA;AAAA;AAAA;AAAA,EAKf,UAAU;AAAA;AAAA;AAAA;AAAA,EAKV,SAAS;AAAA;AAAA;AAAA;AAAA,EAIT,YAAY;AAAA;AAAA;AAAA;AAAA,EAKZ,UAAU;AAAA;AAAA;AAAA;AAAA,EAKV,MAAM;AAAA;AAAA;AAAA;AAAA,EAKN,aAAa;AACf;",
4
+ "sourcesContent": ["import { Type, type Static } from '@sinclair/typebox'\nimport { AVAILABLE_CLIENTS } from '@scalar/types/snippetz'\nimport { defaultMeta, MetaSchema } from '@/schemas/reference-config/meta'\nimport { defaultFeatures, FeaturesSchema } from '@/schemas/reference-config/features'\nimport { AppearanceSchema, defaultAppearance } from '@/schemas/reference-config/appearance'\nimport { defaultRouting, RoutingSchema } from '@/schemas/reference-config/routing'\nimport { defaultSettings, SettingsSchema } from '@/schemas/reference-config/settings'\nimport type { DeepRequired, MutableArray } from '@/types'\n\n/**\n * ReferenceConfigSchema defines the shape of the configuration object\n * for the API Reference. All properties are optional due to Type.Partial.\n * This schema is used for validating and typing the configuration.\n */\nexport const ReferenceConfigSchema = Type.Partial(\n Type.Object({\n /** Document level title */\n title: Type.String(),\n /** Unique slug to identify the document */\n slug: Type.String(),\n /** Settings for the API reference (controls behavior and options) */\n settings: SettingsSchema,\n /** Tag sorting method: currently only 'alpha' (alphabetical) is supported */\n tagSort: Type.Union([Type.Literal('alpha')]),\n /** Operation sorting method: by HTTP method or alphabetically */\n operationSort: Type.Union([Type.Literal('method'), Type.Literal('alpha')]),\n /** Routing configuration (controls navigation) */\n routing: RoutingSchema,\n /** Appearance configuration (controls theming and UI options) */\n appearance: AppearanceSchema,\n /** Features configuration (toggles for enabling/disabling features) */\n features: FeaturesSchema,\n /** Meta information */\n meta: MetaSchema,\n /** List of enabled HTTP clients for code samples */\n httpClients: Type.Array(Type.Union(AVAILABLE_CLIENTS.map((client) => Type.Literal(client)))),\n }),\n)\n\nexport type ReferenceConfig = Static<typeof ReferenceConfigSchema>\n\nexport const defaultReferenceConfig: DeepRequired<ReferenceConfig> = {\n title: 'Scalar API Reference',\n slug: 'scalar-api-reference',\n tagSort: 'alpha',\n operationSort: 'method',\n\n /**\n * Default settings for the API reference.\n */\n settings: defaultSettings,\n\n /**\n * Default routing configuration for the API reference.\n */\n routing: defaultRouting,\n /**\n * Default appearance configuration for the API reference.\n */\n appearance: defaultAppearance,\n\n /**\n * Default features configuration for the API reference.\n */\n features: defaultFeatures,\n\n /**\n * Default meta configuration for the API reference.\n */\n meta: defaultMeta,\n\n /**\n * Default HTTP clients for the API reference.\n */\n httpClients: AVAILABLE_CLIENTS as MutableArray<typeof AVAILABLE_CLIENTS>,\n}\n"],
5
+ "mappings": "AAAA,SAAS,YAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,aAAa,kBAAkB;AACxC,SAAS,iBAAiB,sBAAsB;AAChD,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,gBAAgB,qBAAqB;AAC9C,SAAS,iBAAiB,sBAAsB;AAQzC,MAAM,wBAAwB,KAAK;AAAA,EACxC,KAAK,OAAO;AAAA;AAAA,IAEV,OAAO,KAAK,OAAO;AAAA;AAAA,IAEnB,MAAM,KAAK,OAAO;AAAA;AAAA,IAElB,UAAU;AAAA;AAAA,IAEV,SAAS,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,CAAC,CAAC;AAAA;AAAA,IAE3C,eAAe,KAAK,MAAM,CAAC,KAAK,QAAQ,QAAQ,GAAG,KAAK,QAAQ,OAAO,CAAC,CAAC;AAAA;AAAA,IAEzE,SAAS;AAAA;AAAA,IAET,YAAY;AAAA;AAAA,IAEZ,UAAU;AAAA;AAAA,IAEV,MAAM;AAAA;AAAA,IAEN,aAAa,KAAK,MAAM,KAAK,MAAM,kBAAkB,IAAI,CAAC,WAAW,KAAK,QAAQ,MAAM,CAAC,CAAC,CAAC;AAAA,EAC7F,CAAC;AACH;AAIO,MAAM,yBAAwD;AAAA,EACnE,OAAO;AAAA,EACP,MAAM;AAAA,EACN,SAAS;AAAA,EACT,eAAe;AAAA;AAAA;AAAA;AAAA,EAKf,UAAU;AAAA;AAAA;AAAA;AAAA,EAKV,SAAS;AAAA;AAAA;AAAA;AAAA,EAIT,YAAY;AAAA;AAAA;AAAA;AAAA,EAKZ,UAAU;AAAA;AAAA;AAAA;AAAA,EAKV,MAAM;AAAA;AAAA;AAAA;AAAA,EAKN,aAAa;AACf;",
6
6
  "names": []
7
7
  }
@@ -1,8 +1,10 @@
1
1
  import type { ReferenceObject } from '../../schemas/v3.1/strict/reference.js';
2
- /** Type guard to check if a value is a reference */
3
- export declare const isReference: (value: unknown) => value is ReferenceObject;
4
2
  /**
5
3
  * Type helper we can use if we have performed the isReference check higher in the stack
6
4
  */
7
5
  export type Dereference<T> = Exclude<T, ReferenceObject>;
6
+ /** Type guard to check if a value is a reference */
7
+ export declare const isReference: (value: unknown) => value is ReferenceObject;
8
+ /** Type guard to check if a reference has been resolved */
9
+ export declare const isResolvedRef: <T>(value: unknown) => value is Dereference<T>;
8
10
  //# sourceMappingURL=type-guard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"type-guard.d.ts","sourceRoot":"","sources":["../../../src/schemas/v3.1/type-guard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAEtE,oDAAoD;AACpD,eAAO,MAAM,WAAW,UAAW,OAAO,KAAG,KAAK,IAAI,eACU,CAAA;AAEhE;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,eAAe,CAAC,CAAA"}
1
+ {"version":3,"file":"type-guard.d.ts","sourceRoot":"","sources":["../../../src/schemas/v3.1/type-guard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAEtE;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,eAAe,CAAC,CAAA;AAExD,oDAAoD;AACpD,eAAO,MAAM,WAAW,UAAW,OAAO,KAAG,KAAK,IAAI,eACU,CAAA;AAEhE,2DAA2D;AAC3D,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,OAAO,KAAG,KAAK,IAAI,WAAW,CAAC,CAAC,CACL,CAAA"}
@@ -1,5 +1,7 @@
1
1
  const isReference = (value) => typeof value === "object" && value !== null && "$ref" in value;
2
+ const isResolvedRef = (value) => typeof value === "object" && value !== null && !("$ref" in value);
2
3
  export {
3
- isReference
4
+ isReference,
5
+ isResolvedRef
4
6
  };
5
7
  //# sourceMappingURL=type-guard.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/schemas/v3.1/type-guard.ts"],
4
- "sourcesContent": ["import type { ReferenceObject } from '@/schemas/v3.1/strict/reference'\n\n/** Type guard to check if a value is a reference */\nexport const isReference = (value: unknown): value is ReferenceObject =>\n typeof value === 'object' && value !== null && '$ref' in value\n\n/**\n * Type helper we can use if we have performed the isReference check higher in the stack\n */\nexport type Dereference<T> = Exclude<T, ReferenceObject>\n"],
5
- "mappings": "AAGO,MAAM,cAAc,CAAC,UAC1B,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;",
4
+ "sourcesContent": ["import type { ReferenceObject } from '@/schemas/v3.1/strict/reference'\n\n/**\n * Type helper we can use if we have performed the isReference check higher in the stack\n */\nexport type Dereference<T> = Exclude<T, ReferenceObject>\n\n/** Type guard to check if a value is a reference */\nexport const isReference = (value: unknown): value is ReferenceObject =>\n typeof value === 'object' && value !== null && '$ref' in value\n\n/** Type guard to check if a reference has been resolved */\nexport const isResolvedRef = <T>(value: unknown): value is Dereference<T> =>\n typeof value === 'object' && value !== null && !('$ref' in value)\n"],
5
+ "mappings": "AAQO,MAAM,cAAc,CAAC,UAC1B,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;AAGpD,MAAM,gBAAgB,CAAI,UAC/B,OAAO,UAAU,YAAY,UAAU,QAAQ,EAAE,UAAU;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAG/E,OAAO,EAAoB,KAAK,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAyB,KAAK,eAAe,EAAE,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GvF;;;;;;;;;;;OAWG;;IAwCH;;;;;;;;;;OAUG;;mBApJc,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG;YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,cAAc,EAAE,CAAA;SAAE,CAAC;;;;;;IAwJzG;;;;;;;;;;;;;;;;;OAiBG;mBACY,MAAM;IAGrB;;;;;;;;;OASG;yBA9G6B,sBAAsB;GAiHzD"}
package/dist/server.js CHANGED
@@ -32,7 +32,9 @@ function filterHttpMethodsOnly(paths) {
32
32
  function escapePaths(paths) {
33
33
  const result = {};
34
34
  Object.keys(paths).forEach((path) => {
35
- result[escapeJsonPointer(path)] = paths[path];
35
+ if (paths[path]) {
36
+ result[escapeJsonPointer(path)] = paths[path];
37
+ }
36
38
  });
37
39
  return result;
38
40
  }
@@ -43,7 +45,7 @@ function externalizeComponentReferences(document, meta) {
43
45
  }
44
46
  Object.entries(document.components).forEach(([type, component]) => {
45
47
  if (!component || typeof component !== "object") {
46
- return result;
48
+ return;
47
49
  }
48
50
  result[type] = {};
49
51
  Object.keys(component).forEach((name) => {
@@ -60,7 +62,7 @@ function externalizePathReferences(document, meta) {
60
62
  }
61
63
  Object.entries(document.paths).forEach(([path, pathItem]) => {
62
64
  if (!pathItem || typeof pathItem !== "object") {
63
- return result;
65
+ return;
64
66
  }
65
67
  const pathItemRecord = pathItem;
66
68
  result[path] = {};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/server.ts"],
4
- "sourcesContent": ["import { escapeJsonPointer, upgrade } from '@scalar/openapi-parser'\nimport { getValueByPath, parseJsonPointer } from './helpers/json-path-utils'\nimport type { WorkspaceDocumentMeta, WorkspaceMeta } from './schemas/workspace'\nimport fs from 'node:fs/promises'\nimport { cwd } from 'node:process'\nimport { createNavigation, type createNavigationOptions } from '@/navigation'\nimport { extensions } from '@/schemas/extensions'\nimport { OpenAPIDocumentSchema, type OpenApiDocument } from '@/schemas/v3.1/strict/openapi-document'\nimport type { PathsObject } from '@/schemas/v3.1/strict/paths'\nimport { keyOf } from '@/helpers/general'\nimport type { OperationObject } from '@/schemas/v3.1/strict/path-operations'\nimport { fetchUrls, readFiles } from '@scalar/openapi-parser/plugins'\nimport { coerceValue } from '@/schemas/typebox-coerce'\nimport type { ComponentsObject } from '@/schemas/v3.1/strict/components'\nimport type { TraversedEntry } from '@/schemas/navigation'\n\nconst DEFAULT_ASSETS_FOLDER = 'assets'\nexport const WORKSPACE_FILE_NAME = 'scalar-workspace.json'\n\ntype WorkspaceDocumentMetaInput = {\n name: string\n meta?: WorkspaceDocumentMeta\n}\n\ntype UrlDoc = { url: string } & WorkspaceDocumentMetaInput\ntype FileDoc = { path: string } & WorkspaceDocumentMetaInput\ntype ObjectDoc = { document: Record<string, unknown> } & WorkspaceDocumentMetaInput\n\ntype WorkspaceDocumentInput = UrlDoc | ObjectDoc | FileDoc\n\ntype CreateServerWorkspaceStoreBase = {\n documents: WorkspaceDocumentInput[]\n meta?: WorkspaceMeta\n config?: createNavigationOptions\n}\ntype CreateServerWorkspaceStore =\n | ({\n directory?: string\n mode: 'static'\n } & CreateServerWorkspaceStoreBase)\n | ({\n baseUrl: string\n mode: 'ssr'\n } & CreateServerWorkspaceStoreBase)\n\nconst httpMethods = new Set(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'])\n\n/**\n * Filters an OpenAPI PathsObject to only include standard HTTP methods.\n * Removes any vendor extensions or other non-HTTP properties.\n *\n * @param paths - The OpenAPI PathsObject to filter\n * @returns A new PathsObject containing only standard HTTP methods\n *\n * @example\n * Input: {\n * \"/users\": {\n * \"get\": {...},\n * \"x-custom\": {...},\n * \"post\": {...}\n * }\n * }\n * Output: {\n * \"/users\": {\n * \"get\": {...},\n * \"post\": {...}\n * }\n * }\n */\nexport function filterHttpMethodsOnly(paths: PathsObject) {\n const result: Record<string, Record<string, OperationObject>> = {}\n\n // Todo: skip extension properties\n for (const [path, methods] of Object.entries(paths)) {\n if (!methods) {\n continue\n }\n\n const filteredMethods: Record<string, any> = {}\n\n for (const [method, operation] of Object.entries(methods)) {\n if (httpMethods.has(method.toLowerCase())) {\n filteredMethods[method] = operation\n }\n }\n\n if (Object.keys(filteredMethods).length > 0) {\n result[path] = filteredMethods\n }\n }\n\n return result\n}\n\n/**\n * Escapes path keys in an OpenAPI PathsObject to be JSON Pointer compatible.\n * This is necessary because OpenAPI paths can contain characters that need to be escaped\n * when used as JSON Pointer references (like '/' and '~').\n *\n * @example\n * Input: { \"/users/{id}\": { ... } }\n * Output: { \"/users~1{id}\": { ... } }\n */\nexport function escapePaths(paths: Record<string, Record<string, OperationObject>>) {\n const result: Record<string, Record<string, OperationObject>> = {}\n Object.keys(paths).forEach((path) => {\n result[escapeJsonPointer(path)] = paths[path]\n })\n\n return result\n}\n\n/**\n * Externalizes components by turning them into refs.\n */\nexport function externalizeComponentReferences(\n document: OpenApiDocument,\n meta: { mode: 'ssr'; name: string; baseUrl: string } | { mode: 'static'; name: string; directory: string },\n) {\n const result: Record<string, any> = {}\n\n if (!document.components) {\n return result\n }\n\n Object.entries(document.components).forEach(([type, component]) => {\n if (!component || typeof component !== 'object') {\n return result\n }\n\n result[type] = {}\n Object.keys(component).forEach((name) => {\n const ref =\n meta.mode === 'ssr'\n ? `${meta.baseUrl}/${meta.name}/components/${type}/${name}#`\n : `./chunks/${meta.name}/components/${type}/${name}.json#`\n\n result[type][name] = { '$ref': ref, $global: true }\n })\n })\n\n return result\n}\n\n/**\n * Externalizes paths operations by turning them into refs.\n */\nexport function externalizePathReferences(\n document: OpenApiDocument,\n meta: { mode: 'ssr'; name: string; baseUrl: string } | { mode: 'static'; name: string; directory: string },\n) {\n const result: Record<string, any> = {}\n\n if (!document.paths) {\n return result\n }\n\n Object.entries(document.paths).forEach(([path, pathItem]) => {\n if (!pathItem || typeof pathItem !== 'object') {\n return result\n }\n\n const pathItemRecord = pathItem as Record<string, unknown>\n\n result[path] = {}\n\n const escapedPath = escapeJsonPointer(path)\n\n keyOf(pathItemRecord).forEach((type) => {\n if (httpMethods.has(type)) {\n const ref =\n meta.mode === 'ssr'\n ? `${meta.baseUrl}/${meta.name}/operations/${escapedPath}/${type}#`\n : `./chunks/${meta.name}/operations/${escapedPath}/${type}.json#`\n\n result[path][type] = { '$ref': ref, $global: true }\n } else {\n result[path][type] = pathItemRecord[type]\n }\n })\n })\n\n return result\n}\n\n/**\n * Resolves a workspace document from various input sources (URL, local file, or direct document object).\n *\n * @param workspaceDocument - The document input to resolve, which can be:\n * - A URL to fetch the document from\n * - A local file path to read the document from\n * - A direct document object\n * @returns A promise that resolves to an object containing:\n * - ok: boolean indicating if the resolution was successful\n * - data: The resolved document data\n *\n * @example\n * // Resolve from URL\n * const urlDoc = await loadDocument({ name: 'api', url: 'https://api.example.com/openapi.json' })\n *\n * // Resolve direct document\n * const directDoc = await loadDocument({\n * name: 'inline',\n * document: { openapi: '3.0.0', paths: {} }\n * })\n */\nasync function loadDocument(workspaceDocument: WorkspaceDocumentInput) {\n if ('url' in workspaceDocument) {\n return fetchUrls().exec(workspaceDocument.url)\n }\n\n if ('path' in workspaceDocument) {\n return readFiles().exec(workspaceDocument.path)\n }\n\n return {\n ok: true as const,\n data: workspaceDocument.document,\n }\n}\n\n/**\n * Create server state workspace store\n */\nexport async function createServerWorkspaceStore(workspaceProps: CreateServerWorkspaceStore) {\n /**\n * Base workspace document containing essential metadata and document references.\n *\n * This workspace document provides the minimal information needed for initial rendering.\n * All components and path operations are replaced with references to enable lazy loading.\n *\n * In SSR mode, references point to API endpoints.\n * In static mode, references point to filesystem chunks.\n */\n const workspace = {\n ...workspaceProps.meta,\n documents: {} as Record<string, OpenApiDocument & { [extensions.document.navigation]: TraversedEntry[] }>,\n }\n\n /**\n * A map of document chunks that can be loaded asynchronously by the client.\n * Each document is split into components and operations to enable lazy loading.\n * The keys are document names and values contain the components and operations\n * for that document.\n */\n const assets = {} as Record<\n string,\n { components?: ComponentsObject; operations?: Record<string, Record<string, OperationObject>> }\n >\n\n /**\n * Adds a new document to the workspace.\n *\n * This function processes an OpenAPI document by:\n * 1. Converting it to OpenAPI 3.1 format if needed\n * 2. Separating it into reusable components and path operations\n * 3. Externalizing references based on the workspace mode (SSR or static)\n * 4. Adding the processed document to the workspace with its metadata\n *\n * The resulting document contains minimal information with externalized references\n * that will be resolved on-demand through the workspace's get() method.\n *\n * @param document - The OpenAPI document to process and add\n * @param meta - Document metadata containing the required name and optional settings\n */\n const addDocumentSync = (document: Record<string, unknown>, meta: { name: string } & WorkspaceDocumentMeta) => {\n const { name, ...documentMeta } = meta\n\n const documentV3 = coerceValue(OpenAPIDocumentSchema, upgrade(document).specification)\n\n // add the assets\n assets[meta.name] = {\n components: documentV3.components,\n operations: documentV3.paths && escapePaths(filterHttpMethodsOnly(documentV3.paths)),\n }\n\n const options =\n workspaceProps.mode === 'ssr'\n ? { mode: workspaceProps.mode, name, baseUrl: workspaceProps.baseUrl }\n : { mode: workspaceProps.mode, name, directory: workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER }\n\n const components = externalizeComponentReferences(documentV3, options)\n const paths = externalizePathReferences(documentV3, options)\n\n // Build the sidebar entries\n const { entries } = createNavigation(documentV3, workspaceProps.config ?? {})\n\n // The document is now a minimal version with externalized references to components and operations.\n // These references will be resolved asynchronously when needed through the workspace's get() method.\n workspace.documents[meta.name] = {\n ...documentMeta,\n ...documentV3,\n components,\n paths,\n [extensions.document.navigation]: entries,\n }\n }\n\n /**\n * Adds a new document to the workspace asynchronously.\n *\n * This function:\n * 1. Loads the document using the provided input\n * 2. Checks if the document loaded successfully\n * 3. If successful, adds the document to the workspace using addDocumentSync\n *\n * @param input - The document input containing the document source and metadata\n */\n const addDocument = async (input: WorkspaceDocumentInput) => {\n const document = await loadDocument(input)\n\n if (!document.ok) {\n console.warn(`Failed to load document \"${input.name}`)\n return\n }\n\n addDocumentSync(document.data as Record<string, unknown>, { name: input.name, ...input.meta })\n }\n\n // Load and process all initial documents in parallel\n await Promise.all(workspaceProps.documents.map(addDocument))\n\n return {\n /**\n * Generates workspace chunks by writing components and operations to the filesystem.\n *\n * This method is only available in static mode. It creates a directory structure containing:\n * - A workspace file with metadata and document references\n * - Component chunks split by type (schemas, parameters, etc)\n * - Operation chunks split by path and HTTP method\n *\n * The generated workspace references will be relative file paths pointing to these chunks.\n *\n * @throws {Error} If called when mode is not 'static'\n */\n generateWorkspaceChunks: async () => {\n if (workspaceProps.mode !== 'static') {\n throw 'Mode has to be set to `static` to generate filesystem workspace chunks'\n }\n\n // Write the workspace document\n const basePath = `${cwd()}/${workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER}`\n await fs.mkdir(basePath, { recursive: true })\n\n // Write the workspace contents on the file system\n await fs.writeFile(`${basePath}/${WORKSPACE_FILE_NAME}`, JSON.stringify(workspace))\n\n // Write the chunks\n for (const [name, { components, operations }] of Object.entries(assets)) {\n // Write the components chunks\n if (components) {\n for (const [type, component] of Object.entries(components as Record<string, Record<string, unknown>>)) {\n const componentPath = `${basePath}/chunks/${name}/components/${type}`\n await fs.mkdir(componentPath, { recursive: true })\n\n for (const [key, value] of Object.entries(component)) {\n await fs.writeFile(`${componentPath}/${key}.json`, JSON.stringify(value))\n }\n }\n }\n\n // Write the operations chunks\n if (operations) {\n for (const [path, methods] of Object.entries(operations)) {\n const operationPath = `${basePath}/chunks/${name}/operations/${path}`\n await fs.mkdir(operationPath, { recursive: true })\n\n for (const [method, operation] of Object.entries(methods)) {\n await fs.writeFile(`${operationPath}/${method}.json`, JSON.stringify(operation))\n }\n }\n }\n }\n },\n /**\n * Returns the workspace document containing metadata and all sparse documents.\n *\n * The workspace document includes:\n * - Global workspace metadata (theme, active document, etc)\n * - Document metadata and sparse document\n * - In SSR mode: References point to in-memory chunks\n * - In static mode: References point to filesystem chunks\n *\n * @returns The complete workspace document\n */\n getWorkspace: () => {\n return workspace\n },\n /**\n * Retrieves a chunk of data from the workspace using a JSON Pointer\n *\n * A JSON Pointer is a string that references a specific location in a JSON document.\n * Only components and operations chunks can be retrieved.\n *\n * @example\n * ```ts\n * // Get a component\n * get('#/document-name/components/schemas/User')\n *\n * // Get an operation\n * get('#/document-name/operations/pets/get')\n * ```\n *\n * @param pointer - The JSON Pointer string to locate the chunk\n * @returns The chunk data if found, undefined otherwise\n */\n get: (pointer: string) => {\n return getValueByPath(assets, parseJsonPointer(pointer))\n },\n /**\n * Adds a new document to the workspace asynchronously.\n *\n * This function:\n * 1. Loads the document using the provided input\n * 2. Checks if the document loaded successfully\n * 3. If successful, adds the document to the workspace using addDocumentSync\n *\n * @param input - The document input containing the document source and metadata\n */\n addDocument,\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,mBAAmB,eAAe;AAC3C,SAAS,gBAAgB,wBAAwB;AAEjD,OAAO,QAAQ;AACf,SAAS,WAAW;AACpB,SAAS,wBAAsD;AAC/D,SAAS,kBAAkB;AAC3B,SAAS,6BAAmD;AAE5D,SAAS,aAAa;AAEtB,SAAS,WAAW,iBAAiB;AACrC,SAAS,mBAAmB;AAI5B,MAAM,wBAAwB;AACvB,MAAM,sBAAsB;AA4BnC,MAAM,cAAc,oBAAI,IAAI,CAAC,OAAO,OAAO,QAAQ,UAAU,WAAW,QAAQ,SAAS,OAAO,CAAC;AAwB1F,SAAS,sBAAsB,OAAoB;AACxD,QAAM,SAA0D,CAAC;AAGjE,aAAW,CAAC,MAAM,OAAO,KAAK,OAAO,QAAQ,KAAK,GAAG;AACnD,QAAI,CAAC,SAAS;AACZ;AAAA,IACF;AAEA,UAAM,kBAAuC,CAAC;AAE9C,eAAW,CAAC,QAAQ,SAAS,KAAK,OAAO,QAAQ,OAAO,GAAG;AACzD,UAAI,YAAY,IAAI,OAAO,YAAY,CAAC,GAAG;AACzC,wBAAgB,MAAM,IAAI;AAAA,MAC5B;AAAA,IACF;AAEA,QAAI,OAAO,KAAK,eAAe,EAAE,SAAS,GAAG;AAC3C,aAAO,IAAI,IAAI;AAAA,IACjB;AAAA,EACF;AAEA,SAAO;AACT;AAWO,S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AAG,aAAa,IAAI,GAAG,SAAS,KAAK,UAAU,KAAK,CAAC;AAAA,YAC1E;AAAA,UACF;AAAA,QACF;AAGA,YAAI,YAAY;AACd,qBAAW,CAAC,MAAM,OAAO,KAAK,OAAO,QAAQ,UAAU,GAAG;AACxD,kBAAM,gBAAgB,GAAG,QAAQ,WAAW,IAAI,eAAe,IAAI;AACnE,kBAAM,GAAG,MAAM,eAAe,EAAE,WAAW,KAAK,CAAC;AAEjD,uBAAW,CAAC,QAAQ,SAAS,KAAK,OAAO,QAAQ,OAAO,GAAG;AACzD,oBAAM,GAAG,UAAU,GAAG,aAAa,IAAI,MAAM,SAAS,KAAK,UAAU,SAAS,CAAC;AAAA,YACjF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAYA,cAAc,MAAM;AAClB,aAAO;AAAA,IACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAmBA,KAAK,CAAC,YAAoB;AACxB,aAAO,eAAe,QAAQ,iBAAiB,OAAO,CAAC;AAAA,IACzD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWA;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { escapeJsonPointer, upgrade } from '@scalar/openapi-parser'\nimport { getValueByPath, parseJsonPointer } from './helpers/json-path-utils'\nimport type { WorkspaceDocumentMeta, WorkspaceMeta } from './schemas/workspace'\nimport fs from 'node:fs/promises'\nimport { cwd } from 'node:process'\nimport { createNavigation, type createNavigationOptions } from '@/navigation'\nimport { extensions } from '@/schemas/extensions'\nimport { OpenAPIDocumentSchema, type OpenApiDocument } from '@/schemas/v3.1/strict/openapi-document'\nimport type { PathsObject } from '@/schemas/v3.1/strict/paths'\nimport { keyOf } from '@/helpers/general'\nimport type { OperationObject } from '@/schemas/v3.1/strict/path-operations'\nimport { fetchUrls, readFiles } from '@scalar/openapi-parser/plugins'\nimport { coerceValue } from '@/schemas/typebox-coerce'\nimport type { ComponentsObject } from '@/schemas/v3.1/strict/components'\nimport type { TraversedEntry } from '@/schemas/navigation'\n\nconst DEFAULT_ASSETS_FOLDER = 'assets'\nexport const WORKSPACE_FILE_NAME = 'scalar-workspace.json'\n\ntype WorkspaceDocumentMetaInput = {\n name: string\n meta?: WorkspaceDocumentMeta\n}\n\ntype UrlDoc = { url: string } & WorkspaceDocumentMetaInput\ntype FileDoc = { path: string } & WorkspaceDocumentMetaInput\ntype ObjectDoc = { document: Record<string, unknown> } & WorkspaceDocumentMetaInput\n\ntype WorkspaceDocumentInput = UrlDoc | ObjectDoc | FileDoc\n\ntype CreateServerWorkspaceStoreBase = {\n documents: WorkspaceDocumentInput[]\n meta?: WorkspaceMeta\n config?: createNavigationOptions\n}\ntype CreateServerWorkspaceStore =\n | ({\n directory?: string\n mode: 'static'\n } & CreateServerWorkspaceStoreBase)\n | ({\n baseUrl: string\n mode: 'ssr'\n } & CreateServerWorkspaceStoreBase)\n\nconst httpMethods = new Set(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'])\n\n/**\n * Filters an OpenAPI PathsObject to only include standard HTTP methods.\n * Removes any vendor extensions or other non-HTTP properties.\n *\n * @param paths - The OpenAPI PathsObject to filter\n * @returns A new PathsObject containing only standard HTTP methods\n *\n * @example\n * Input: {\n * \"/users\": {\n * \"get\": {...},\n * \"x-custom\": {...},\n * \"post\": {...}\n * }\n * }\n * Output: {\n * \"/users\": {\n * \"get\": {...},\n * \"post\": {...}\n * }\n * }\n */\nexport function filterHttpMethodsOnly(paths: PathsObject) {\n const result: Record<string, Record<string, OperationObject>> = {}\n\n // Todo: skip extension properties\n for (const [path, methods] of Object.entries(paths)) {\n if (!methods) {\n continue\n }\n\n const filteredMethods: Record<string, any> = {}\n\n for (const [method, operation] of Object.entries(methods)) {\n if (httpMethods.has(method.toLowerCase())) {\n filteredMethods[method] = operation\n }\n }\n\n if (Object.keys(filteredMethods).length > 0) {\n result[path] = filteredMethods\n }\n }\n\n return result\n}\n\n/**\n * Escapes path keys in an OpenAPI PathsObject to be JSON Pointer compatible.\n * This is necessary because OpenAPI paths can contain characters that need to be escaped\n * when used as JSON Pointer references (like '/' and '~').\n *\n * @example\n * Input: { \"/users/{id}\": { ... } }\n * Output: { \"/users~1{id}\": { ... } }\n */\nexport function escapePaths(paths: Record<string, Record<string, OperationObject>>) {\n const result: Record<string, Record<string, OperationObject>> = {}\n\n Object.keys(paths).forEach((path) => {\n if (paths[path]) {\n result[escapeJsonPointer(path)] = paths[path]\n }\n })\n\n return result\n}\n\n/**\n * Externalizes components by turning them into refs.\n */\nexport function externalizeComponentReferences(\n document: OpenApiDocument,\n meta: { mode: 'ssr'; name: string; baseUrl: string } | { mode: 'static'; name: string; directory: string },\n) {\n const result: Record<string, any> = {}\n\n if (!document.components) {\n return result\n }\n\n Object.entries(document.components).forEach(([type, component]) => {\n if (!component || typeof component !== 'object') {\n return\n }\n\n result[type] = {}\n Object.keys(component).forEach((name) => {\n const ref =\n meta.mode === 'ssr'\n ? `${meta.baseUrl}/${meta.name}/components/${type}/${name}#`\n : `./chunks/${meta.name}/components/${type}/${name}.json#`\n\n result[type][name] = { '$ref': ref, $global: true }\n })\n })\n\n return result\n}\n\n/**\n * Externalizes paths operations by turning them into refs.\n */\nexport function externalizePathReferences(\n document: OpenApiDocument,\n meta: { mode: 'ssr'; name: string; baseUrl: string } | { mode: 'static'; name: string; directory: string },\n) {\n const result: Record<string, any> = {}\n\n if (!document.paths) {\n return result\n }\n\n Object.entries(document.paths).forEach(([path, pathItem]) => {\n if (!pathItem || typeof pathItem !== 'object') {\n return\n }\n\n const pathItemRecord = pathItem as Record<string, unknown>\n\n result[path] = {}\n\n const escapedPath = escapeJsonPointer(path)\n\n keyOf(pathItemRecord).forEach((type) => {\n if (httpMethods.has(type)) {\n const ref =\n meta.mode === 'ssr'\n ? `${meta.baseUrl}/${meta.name}/operations/${escapedPath}/${type}#`\n : `./chunks/${meta.name}/operations/${escapedPath}/${type}.json#`\n\n result[path][type] = { '$ref': ref, $global: true }\n } else {\n result[path][type] = pathItemRecord[type]\n }\n })\n })\n\n return result\n}\n\n/**\n * Resolves a workspace document from various input sources (URL, local file, or direct document object).\n *\n * @param workspaceDocument - The document input to resolve, which can be:\n * - A URL to fetch the document from\n * - A local file path to read the document from\n * - A direct document object\n * @returns A promise that resolves to an object containing:\n * - ok: boolean indicating if the resolution was successful\n * - data: The resolved document data\n *\n * @example\n * // Resolve from URL\n * const urlDoc = await loadDocument({ name: 'api', url: 'https://api.example.com/openapi.json' })\n *\n * // Resolve direct document\n * const directDoc = await loadDocument({\n * name: 'inline',\n * document: { openapi: '3.0.0', paths: {} }\n * })\n */\nasync function loadDocument(workspaceDocument: WorkspaceDocumentInput) {\n if ('url' in workspaceDocument) {\n return fetchUrls().exec(workspaceDocument.url)\n }\n\n if ('path' in workspaceDocument) {\n return readFiles().exec(workspaceDocument.path)\n }\n\n return {\n ok: true as const,\n data: workspaceDocument.document,\n }\n}\n\n/**\n * Create server state workspace store\n */\nexport async function createServerWorkspaceStore(workspaceProps: CreateServerWorkspaceStore) {\n /**\n * Base workspace document containing essential metadata and document references.\n *\n * This workspace document provides the minimal information needed for initial rendering.\n * All components and path operations are replaced with references to enable lazy loading.\n *\n * In SSR mode, references point to API endpoints.\n * In static mode, references point to filesystem chunks.\n */\n const workspace = {\n ...workspaceProps.meta,\n documents: {} as Record<string, OpenApiDocument & { [extensions.document.navigation]: TraversedEntry[] }>,\n }\n\n /**\n * A map of document chunks that can be loaded asynchronously by the client.\n * Each document is split into components and operations to enable lazy loading.\n * The keys are document names and values contain the components and operations\n * for that document.\n */\n const assets = {} as Record<\n string,\n { components?: ComponentsObject; operations?: Record<string, Record<string, OperationObject>> }\n >\n\n /**\n * Adds a new document to the workspace.\n *\n * This function processes an OpenAPI document by:\n * 1. Converting it to OpenAPI 3.1 format if needed\n * 2. Separating it into reusable components and path operations\n * 3. Externalizing references based on the workspace mode (SSR or static)\n * 4. Adding the processed document to the workspace with its metadata\n *\n * The resulting document contains minimal information with externalized references\n * that will be resolved on-demand through the workspace's get() method.\n *\n * @param document - The OpenAPI document to process and add\n * @param meta - Document metadata containing the required name and optional settings\n */\n const addDocumentSync = (document: Record<string, unknown>, meta: { name: string } & WorkspaceDocumentMeta) => {\n const { name, ...documentMeta } = meta\n\n const documentV3 = coerceValue(OpenAPIDocumentSchema, upgrade(document).specification)\n\n // add the assets\n assets[meta.name] = {\n components: documentV3.components,\n operations: documentV3.paths && escapePaths(filterHttpMethodsOnly(documentV3.paths)),\n }\n\n const options =\n workspaceProps.mode === 'ssr'\n ? { mode: workspaceProps.mode, name, baseUrl: workspaceProps.baseUrl }\n : { mode: workspaceProps.mode, name, directory: workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER }\n\n const components = externalizeComponentReferences(documentV3, options)\n const paths = externalizePathReferences(documentV3, options)\n\n // Build the sidebar entries\n const { entries } = createNavigation(documentV3, workspaceProps.config ?? {})\n\n // The document is now a minimal version with externalized references to components and operations.\n // These references will be resolved asynchronously when needed through the workspace's get() method.\n workspace.documents[meta.name] = {\n ...documentMeta,\n ...documentV3,\n components,\n paths,\n [extensions.document.navigation]: entries,\n }\n }\n\n /**\n * Adds a new document to the workspace asynchronously.\n *\n * This function:\n * 1. Loads the document using the provided input\n * 2. Checks if the document loaded successfully\n * 3. If successful, adds the document to the workspace using addDocumentSync\n *\n * @param input - The document input containing the document source and metadata\n */\n const addDocument = async (input: WorkspaceDocumentInput) => {\n const document = await loadDocument(input)\n\n if (!document.ok) {\n console.warn(`Failed to load document \"${input.name}`)\n return\n }\n\n addDocumentSync(document.data as Record<string, unknown>, { name: input.name, ...input.meta })\n }\n\n // Load and process all initial documents in parallel\n await Promise.all(workspaceProps.documents.map(addDocument))\n\n return {\n /**\n * Generates workspace chunks by writing components and operations to the filesystem.\n *\n * This method is only available in static mode. It creates a directory structure containing:\n * - A workspace file with metadata and document references\n * - Component chunks split by type (schemas, parameters, etc)\n * - Operation chunks split by path and HTTP method\n *\n * The generated workspace references will be relative file paths pointing to these chunks.\n *\n * @throws {Error} If called when mode is not 'static'\n */\n generateWorkspaceChunks: async () => {\n if (workspaceProps.mode !== 'static') {\n throw 'Mode has to be set to `static` to generate filesystem workspace chunks'\n }\n\n // Write the workspace document\n const basePath = `${cwd()}/${workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER}`\n await fs.mkdir(basePath, { recursive: true })\n\n // Write the workspace contents on the file system\n await fs.writeFile(`${basePath}/${WORKSPACE_FILE_NAME}`, JSON.stringify(workspace))\n\n // Write the chunks\n for (const [name, { components, operations }] of Object.entries(assets)) {\n // Write the components chunks\n if (components) {\n for (const [type, component] of Object.entries(components as Record<string, Record<string, unknown>>)) {\n const componentPath = `${basePath}/chunks/${name}/components/${type}`\n await fs.mkdir(componentPath, { recursive: true })\n\n for (const [key, value] of Object.entries(component)) {\n await fs.writeFile(`${componentPath}/${key}.json`, JSON.stringify(value))\n }\n }\n }\n\n // Write the operations chunks\n if (operations) {\n for (const [path, methods] of Object.entries(operations)) {\n const operationPath = `${basePath}/chunks/${name}/operations/${path}`\n await fs.mkdir(operationPath, { recursive: true })\n\n for (const [method, operation] of Object.entries(methods)) {\n await fs.writeFile(`${operationPath}/${method}.json`, JSON.stringify(operation))\n }\n }\n }\n }\n },\n /**\n * Returns the workspace document containing metadata and all sparse documents.\n *\n * The workspace document includes:\n * - Global workspace metadata (theme, active document, etc)\n * - Document metadata and sparse document\n * - In SSR mode: References point to in-memory chunks\n * - In static mode: References point to filesystem chunks\n *\n * @returns The complete workspace document\n */\n getWorkspace: () => {\n return workspace\n },\n /**\n * Retrieves a chunk of data from the workspace using a JSON Pointer\n *\n * A JSON Pointer is a string that references a specific location in a JSON document.\n * Only components and operations chunks can be retrieved.\n *\n * @example\n * ```ts\n * // Get a component\n * get('#/document-name/components/schemas/User')\n *\n * // Get an operation\n * get('#/document-name/operations/pets/get')\n * ```\n *\n * @param pointer - The JSON Pointer string to locate the chunk\n * @returns The chunk data if found, undefined otherwise\n */\n get: (pointer: string) => {\n return getValueByPath(assets, parseJsonPointer(pointer))\n },\n /**\n * Adds a new document to the workspace asynchronously.\n *\n * This function:\n * 1. Loads the document using the provided input\n * 2. Checks if the document loaded successfully\n * 3. If successful, adds the document to the workspace using addDocumentSync\n *\n * @param input - The document input containing the document source and metadata\n */\n addDocument,\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,mBAAmB,eAAe;AAC3C,SAAS,gBAAgB,wBAAwB;AAEjD,OAAO,QAAQ;AACf,SAAS,WAAW;AACpB,SAAS,wBAAsD;AAC/D,SAAS,kBAAkB;AAC3B,SAAS,6BAAmD;AAE5D,SAAS,aAAa;AAEtB,SAAS,WAAW,iBAAiB;AACrC,SAAS,mBAAmB;AAI5B,MAAM,wBAAwB;AACvB,MAAM,sBAAsB;AA4BnC,MAAM,cAAc,oBAAI,IAAI,CAAC,OAAO,OAAO,QAAQ,UAAU,WAAW,QAAQ,SAAS,OAAO,CAAC;AAwB1F,SAAS,sBAAsB,OAAoB;AACxD,QAAM,SAA0D,CAAC;AAGjE,aAAW,CAAC,MAAM,OAAO,KAAK,OAAO,QAAQ,KAAK,GAAG;AACnD,QAAI,CAAC,SAAS;AACZ;AAAA,IACF;AAEA,UAAM,kBAAuC,CAAC;AAE9C,eAAW,CAAC,QAAQ,SAAS,KAAK,OAAO,QAAQ,OAAO,GAAG;AACzD,UAAI,YAAY,IAAI,OAAO,YAAY,CAAC,GAAG;AACzC,wBAAgB,MAAM,IAAI;AAAA,MAC5B;AAAA,IACF;AAEA,QAAI,OAAO,KAAK,eAAe,EAAE,SAAS,GAAG;AAC3C,aAAO,IAAI,IAAI;AAAA,IACjB;AAAA,EACF;AAEA,SAAO;AACT;AAWO,SAAS,YAAY,OAAwD;AAClF,QAAM,SAA0D,CAA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AAI,GAAG,SAAS,KAAK,UAAU,KAAK,CAAC;AAAA,YAC1E;AAAA,UACF;AAAA,QACF;AAGA,YAAI,YAAY;AACd,qBAAW,CAAC,MAAM,OAAO,KAAK,OAAO,QAAQ,UAAU,GAAG;AACxD,kBAAM,gBAAgB,GAAG,QAAQ,WAAW,IAAI,eAAe,IAAI;AACnE,kBAAM,GAAG,MAAM,eAAe,EAAE,WAAW,KAAK,CAAC;AAEjD,uBAAW,CAAC,QAAQ,SAAS,KAAK,OAAO,QAAQ,OAAO,GAAG;AACzD,oBAAM,GAAG,UAAU,GAAG,aAAa,IAAI,MAAM,SAAS,KAAK,UAAU,SAAS,CAAC;AAAA,YACjF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAYA,cAAc,MAAM;AAClB,aAAO;AAAA,IACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAmBA,KAAK,CAAC,YAAoB;AACxB,aAAO,eAAe,QAAQ,iBAAiB,OAAO,CAAC;AAAA,IACzD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWA;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
package/dist/types.d.ts CHANGED
@@ -1,41 +1,9 @@
1
- /**
2
- * Applies a type transformation to a given type T based on the Transform parameter.
3
- *
4
- * This utility type supports common TypeScript transformations:
5
- * - 'NonNullable': Removes null and undefined from the type
6
- * - 'Partial': Makes all properties optional
7
- * - 'Required': Makes all properties required
8
- * - 'Readonly': Makes all properties readonly
9
- *
10
- * If no valid transformation is provided, returns the original type unchanged.
11
- *
12
- * @template T - The type to transform
13
- * @template Transform - The transformation to apply ('NonNullable' | 'Partial' | 'Required' | 'Readonly')
14
- */
15
- type ApplyTransform<T, Transform> = Transform extends 'NonNullable' ? NonNullable<T> : Transform extends 'Partial' ? Partial<T> : Transform extends 'Required' ? Required<T> : Transform extends 'Readonly' ? Readonly<T> : T;
16
- /**
17
- * Recursively applies a type transformation to all levels of a nested type structure.
18
- *
19
- * This utility type traverses through complex nested types and applies the specified transformation
20
- * at each level. It handles:
21
- * - Functions: Returns the function type unchanged (no transformation applied)
22
- * - Arrays: Recursively transforms each element in the array
23
- * - Objects: Recursively transforms each property value in the object
24
- * - Primitives: Applies the transformation directly using ApplyTransform
25
- *
26
- * The transformation is applied using the ApplyTransform utility, which supports:
27
- * 'NonNullable', 'Partial', 'Required', and 'Readonly' transformations.
28
- *
29
- * @template T - The type to recursively transform
30
- * @template Transform - The transformation to apply at each level
31
- * @example
32
- * // Make all properties in a nested object optional
33
- * type OptionalNested = DeepTransform<{ a: { b: string } }, 'Partial'>
34
- * // Result: { a?: { b?: string } }
35
- */
36
- export type DeepTransform<T, Transform> = T extends (...args: any[]) => any ? T : T extends Array<infer U> ? Array<DeepTransform<U, Transform>> : T extends object ? {
37
- [K in keyof T]-?: DeepTransform<ApplyTransform<NonNullable<T[K]>, Transform>, Transform>;
38
- } : ApplyTransform<NonNullable<T>, Transform>;
1
+ export type DeepRequired<T> = T extends Function ? T : T extends Array<infer U> ? Array<DeepRequired<U>> : T extends object ? {
2
+ [K in keyof T]-?: DeepRequired<T[K]>;
3
+ } : T;
4
+ export type DeepPartial<T> = T extends Function ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends object ? {
5
+ [K in keyof T]?: DeepPartial<T[K]>;
6
+ } : T;
39
7
  /**
40
8
  * Converts a readonly array type to a mutable array type.
41
9
  *
@@ -53,5 +21,4 @@ export type DeepTransform<T, Transform> = T extends (...args: any[]) => any ? T
53
21
  export type MutableArray<T extends readonly any[]> = {
54
22
  -readonly [k in keyof T]: T[k];
55
23
  };
56
- export {};
57
24
  //# sourceMappingURL=types.d.ts.map