@scalar/workspace-store 0.28.1 → 0.28.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/client.d.ts +10 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +42 -2
- package/dist/client.js.map +2 -2
- package/dist/entities/auth/index.d.ts +75 -0
- package/dist/entities/auth/index.d.ts.map +1 -0
- package/dist/entities/auth/index.js +89 -0
- package/dist/entities/auth/index.js.map +7 -0
- package/dist/entities/auth/schema.d.ts +7318 -0
- package/dist/entities/auth/schema.d.ts.map +1 -0
- package/dist/entities/auth/schema.js +74 -0
- package/dist/entities/auth/schema.js.map +7 -0
- package/dist/entities/history/index.d.ts +93 -0
- package/dist/entities/history/index.d.ts.map +1 -0
- package/dist/entities/history/index.js +62 -0
- package/dist/entities/history/index.js.map +7 -0
- package/dist/entities/history/schema.d.ts +234 -0
- package/dist/entities/history/schema.d.ts.map +1 -0
- package/dist/{schemas/extensions/operation/x-scalar-history.js → entities/history/schema.js} +5 -6
- package/dist/{schemas/extensions/operation/x-scalar-history.js.map → entities/history/schema.js.map} +3 -3
- package/dist/events/definitions/auth.d.ts +14 -0
- package/dist/events/definitions/auth.d.ts.map +1 -1
- package/dist/mutators/auth.d.ts +10 -17
- package/dist/mutators/auth.d.ts.map +1 -1
- package/dist/mutators/auth.js +87 -57
- package/dist/mutators/auth.js.map +2 -2
- package/dist/mutators/index.d.ts +4 -12
- package/dist/mutators/index.d.ts.map +1 -1
- package/dist/mutators/index.js +1 -1
- package/dist/mutators/index.js.map +2 -2
- package/dist/mutators/operation.d.ts +2 -2
- package/dist/mutators/operation.d.ts.map +1 -1
- package/dist/mutators/operation.js +9 -16
- package/dist/mutators/operation.js.map +2 -2
- package/dist/mutators/server.d.ts.map +1 -1
- package/dist/mutators/server.js +0 -3
- package/dist/mutators/server.js.map +2 -2
- package/dist/persistence/index.d.ts +16 -3
- package/dist/persistence/index.d.ts.map +1 -1
- package/dist/persistence/index.js +47 -3
- package/dist/persistence/index.js.map +2 -2
- package/dist/plugins/bundler/index.d.ts +7 -0
- package/dist/plugins/bundler/index.d.ts.map +1 -1
- package/dist/plugins/bundler/index.js +17 -0
- package/dist/plugins/bundler/index.js.map +2 -2
- package/dist/plugins/client/persistence.d.ts.map +1 -1
- package/dist/plugins/client/persistence.js +12 -0
- package/dist/plugins/client/persistence.js.map +2 -2
- package/dist/resolve.d.ts +9 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/resolve.js +28 -0
- package/dist/resolve.js.map +7 -0
- package/dist/schemas/extensions/security/index.d.ts +2 -0
- package/dist/schemas/extensions/security/index.d.ts.map +1 -0
- package/dist/schemas/extensions/security/index.js +1 -0
- package/dist/schemas/extensions/security/index.js.map +7 -0
- package/dist/schemas/inmemory-workspace.d.ts +2952 -149
- package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
- package/dist/schemas/inmemory-workspace.js +5 -1
- package/dist/schemas/inmemory-workspace.js.map +2 -2
- package/dist/schemas/reference-config/index.d.ts +35 -149
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/settings.d.ts +35 -149
- package/dist/schemas/reference-config/settings.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/oauth-flow.d.ts +5 -35
- package/dist/schemas/v3.1/strict/oauth-flow.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/oauth-flow.js +1 -16
- package/dist/schemas/v3.1/strict/oauth-flow.js.map +2 -2
- package/dist/schemas/v3.1/strict/oauthflows.d.ts +0 -29
- package/dist/schemas/v3.1/strict/oauthflows.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +1245 -6744
- package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/openapi-document.js +2 -10
- package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
- package/dist/schemas/v3.1/strict/operation.d.ts +1 -70
- package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/operation.js +1 -7
- package/dist/schemas/v3.1/strict/operation.js.map +2 -2
- package/dist/schemas/v3.1/strict/ref-definitions.d.ts +0 -1
- package/dist/schemas/v3.1/strict/ref-definitions.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/ref-definitions.js +1 -3
- package/dist/schemas/v3.1/strict/ref-definitions.js.map +2 -2
- package/dist/schemas/v3.1/strict/schema.d.ts +50 -46
- package/dist/schemas/v3.1/strict/schema.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/schema.js +5 -2
- package/dist/schemas/v3.1/strict/schema.js.map +2 -2
- package/dist/schemas/v3.1/strict/security-scheme.d.ts +3 -11
- package/dist/schemas/v3.1/strict/security-scheme.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/security-scheme.js +0 -7
- package/dist/schemas/v3.1/strict/security-scheme.js.map +2 -2
- package/dist/schemas/workspace.d.ts +245 -1043
- package/dist/schemas/workspace.d.ts.map +1 -1
- package/dist/workspace-plugin.d.ts +8 -0
- package/dist/workspace-plugin.d.ts.map +1 -1
- package/package.json +26 -6
- package/dist/schemas/extensions/operation/x-scalar-history.d.ts +0 -217
- package/dist/schemas/extensions/operation/x-scalar-history.d.ts.map +0 -1
- package/dist/schemas/extensions/security/x-scalar-selected-security.d.ts +0 -17
- package/dist/schemas/extensions/security/x-scalar-selected-security.d.ts.map +0 -1
- package/dist/schemas/extensions/security/x-scalar-selected-security.js +0 -14
- package/dist/schemas/extensions/security/x-scalar-selected-security.js.map +0 -7
|
@@ -95,10 +95,27 @@ const normalizeAuthSchemes = () => {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
};
|
|
98
|
+
const normalizeRefs = () => {
|
|
99
|
+
return {
|
|
100
|
+
type: "lifecycle",
|
|
101
|
+
onBeforeNodeProcess: (node, context) => {
|
|
102
|
+
const { path } = context;
|
|
103
|
+
if (typeof node["$ref"] === "string" && !(path[0] === "components" && path[1] === "schemas")) {
|
|
104
|
+
const keepProperties = /* @__PURE__ */ new Set(["$ref", "summary", "description", "$status"]);
|
|
105
|
+
Object.keys(node).forEach((key) => {
|
|
106
|
+
if (!keepProperties.has(key)) {
|
|
107
|
+
delete node[key];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
};
|
|
98
114
|
export {
|
|
99
115
|
externalValueResolver,
|
|
100
116
|
loadingStatus,
|
|
101
117
|
normalizeAuthSchemes,
|
|
118
|
+
normalizeRefs,
|
|
102
119
|
refsEverywhere,
|
|
103
120
|
restoreOriginalRefs
|
|
104
121
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/bundler/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * This file contains a collection of plugins used for the bundler.\n * Plugins defined here can extend or modify the behavior of the bundling process,\n * such as adding lifecycle hooks or custom processing logic.\n */\n\nimport type { LifecyclePlugin } from '@scalar/json-magic/bundle'\n\nimport { isLocalRef } from '@/helpers/general'\nimport { getResolvedRef } from '@/plugins/bundler/helpers'\n\n/**\n * A lifecycle plugin that adds a `$status` property to nodes during resolution.\n * - Sets `$status` to 'loading' when resolution starts.\n * - Sets `$status` to 'error' if resolution fails.\n * - Removes `$status` when resolution succeeds.\n */\nexport const loadingStatus = (): LifecyclePlugin => {\n return {\n type: 'lifecycle',\n onResolveStart: (node) => {\n node['$status'] = 'loading'\n },\n onResolveError: (node) => {\n node['$status'] = 'error'\n },\n onResolveSuccess: (node) => {\n delete node['$status']\n },\n }\n}\n\n/**\n * Lifecycle plugin to resolve and embed external content referenced by an 'externalValue' property in a node.\n *\n * When a node contains an 'externalValue' property (as a string), this plugin will:\n * - Fetch the external resource (such as a URL or file) using the fetchUrls plugin.\n * - If the fetch is successful, assign the fetched data to the node's 'value' property.\n *\n * This is useful for inlining external content (like examples or schemas) into the OpenAPI document during bundling.\n *\n * @param node - The node being processed, which may contain an 'externalValue' property.\n */\nexport const externalValueResolver = (): LifecyclePlugin => {\n return {\n type: 'lifecycle',\n onAfterNodeProcess: async (node, context) => {\n const externalValue = node['externalValue']\n const cache = context.resolutionCache\n\n // Only process if 'externalValue' is a string\n if (typeof externalValue !== 'string') {\n return\n }\n\n const loader = context.loaders.find((it) => it.validate(externalValue))\n\n // We can not process the external value\n if (!loader) {\n return\n }\n\n if (!cache.has(externalValue)) {\n cache.set(externalValue, loader.exec(externalValue))\n }\n\n const result = await cache.get(externalValue)\n\n // If fetch is successful, assign the data to the node's 'value' property\n if (result?.ok) {\n node['value'] = result.data\n }\n },\n }\n}\n\n/**\n * Lifecycle plugin to resolve $ref on any object, including non-standard locations like the info object.\n *\n * This plugin will:\n * - Detect if a node contains a $ref property (as a string).\n * - If the node is under the 'info' path, attempt to resolve the reference using fetchUrls.\n * - Replace the node's properties with the resolved data if successful.\n *\n * Note: This currently only supports refs on the 'info' object and does not handle primitive types.\n */\nexport const refsEverywhere = (): LifecyclePlugin => {\n return {\n type: 'lifecycle',\n onBeforeNodeProcess: async (node, context) => {\n const { path, resolutionCache, parentNode } = context\n const ref = node['$ref']\n\n // Only process nodes that have a $ref property as a string\n if (typeof ref !== 'string') {\n return\n }\n\n // Can not resolve top level refs\n if (!parentNode || !path.length) {\n return\n }\n\n const loader = context.loaders.find((it) => it.validate(ref))\n\n // Can not load the external ref\n if (!loader) {\n return\n }\n\n // Support resolving $ref on the info object\n if (path[0] === 'info') {\n // Use the cache to avoid duplicate fetches\n if (!resolutionCache.has(ref)) {\n resolutionCache.set(ref, loader.exec(ref))\n }\n\n const result = await resolutionCache.get(ref)\n\n if (result?.ok) {\n // Replace the ref with the resolved data\n parentNode[path.at(-1)!] = result.data\n }\n }\n },\n }\n}\n\n/**\n * Lifecycle plugin to restore original $ref values after processing.\n *\n * This plugin is intended to be used as a \"lifecycle\" plugin in the bundling process.\n * It operates in the `onAfterNodeProcess` hook, and its main purpose is to restore\n * the original $ref values for external references that may have been replaced or\n * rewritten during the bundling process.\n *\n * How it works:\n * - For each node processed, if the node contains a $ref property (as a string),\n * and the root document contains an \"x-ext-urls\" mapping object,\n * the plugin will attempt to restore the original $ref value.\n * - The \"x-ext-urls\" object is expected to be a mapping from the rewritten $ref\n * (e.g., a hashed or compressed reference) back to the original external URL or path.\n * - If a mapping exists for the current $ref, the plugin replaces the $ref value\n * with the original value from the mapping. If no mapping exists (e.g., for local refs),\n * the $ref value is left unchanged.\n *\n * This is useful for scenarios where you want to present or export the bundled document\n * with the original external $ref values, rather than the internal or rewritten ones.\n *\n * @returns {LifecyclePlugin} The plugin object for use in the bundler.\n */\nexport const restoreOriginalRefs = (): LifecyclePlugin => {\n return {\n type: 'lifecycle',\n onBeforeNodeProcess: (node, context) => {\n const ref = node['$ref']\n const root = context.rootNode\n const extUrls = root['x-ext-urls']\n\n // Only process if $ref is a string and x-ext-urls is a valid object\n if (typeof ref !== 'string' || typeof extUrls !== 'object' || extUrls === null || !isLocalRef(ref)) {\n return\n }\n\n // Working with local refs\n\n const segments = ref.split('/')\n const key = segments.at(-1) ?? ''\n\n // Replace the $ref with the original version from the mapping,\n // or keep the current version if there is no mapping (e.g., for local refs)\n node['$ref'] = (extUrls as Record<string, string>)[key] ?? ref\n },\n }\n}\n\n/**\n * Lifecycle plugin to normalize the `scheme` property in securitySchemes to lowercase.\n *\n * Our typebox schemas require the `scheme` property to be a lowercase string.\n * This plugin ensures that any `scheme` field under `components.securitySchemes` is normalized to lowercase, fixing\n * potential user input errors such as \"Bearer\" or \"BASIC\".\n *\n * Example:\n * ```yaml\n * Before normalization:\n * components:\n * securitySchemes:\n * bearerAuth:\n * type: http\n * scheme: Bearer\n * ```\n * After normalization:\n * ```yaml\n * components:\n * securitySchemes:\n * bearerAuth:\n * type: http\n * scheme: bearer\n * ```\n */\nexport const normalizeAuthSchemes = (): LifecyclePlugin => {\n return {\n type: 'lifecycle',\n onAfterNodeProcess: (node, context) => {\n const { path } = context\n\n // Check if we're at components.securitySchemes.{schemeName}\n if (path.length === 3 && path[0] === 'components' && path[1] === 'securitySchemes') {\n const targetNode = getResolvedRef(node, context)\n\n // If the scheme exists and is a string, normalize to lowercase if not already\n if (\n typeof targetNode === 'object' &&\n targetNode !== null &&\n 'scheme' in targetNode &&\n typeof targetNode['scheme'] === 'string' &&\n targetNode['scheme'].toLowerCase() !== targetNode['scheme']\n ) {\n targetNode['scheme'] = targetNode['scheme'].toLowerCase()\n }\n }\n },\n }\n}\n"],
|
|
5
|
-
"mappings": "AAQA,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAQxB,MAAM,gBAAgB,MAAuB;AAClD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,gBAAgB,CAAC,SAAS;AACxB,WAAK,SAAS,IAAI;AAAA,IACpB;AAAA,IACA,gBAAgB,CAAC,SAAS;AACxB,WAAK,SAAS,IAAI;AAAA,IACpB;AAAA,IACA,kBAAkB,CAAC,SAAS;AAC1B,aAAO,KAAK,SAAS;AAAA,IACvB;AAAA,EACF;AACF;AAaO,MAAM,wBAAwB,MAAuB;AAC1D,SAAO;AAAA,IACL,MAAM;AAAA,IACN,oBAAoB,OAAO,MAAM,YAAY;AAC3C,YAAM,gBAAgB,KAAK,eAAe;AAC1C,YAAM,QAAQ,QAAQ;AAGtB,UAAI,OAAO,kBAAkB,UAAU;AACrC;AAAA,MACF;AAEA,YAAM,SAAS,QAAQ,QAAQ,KAAK,CAAC,OAAO,GAAG,SAAS,aAAa,CAAC;AAGtE,UAAI,CAAC,QAAQ;AACX;AAAA,MACF;AAEA,UAAI,CAAC,MAAM,IAAI,aAAa,GAAG;AAC7B,cAAM,IAAI,eAAe,OAAO,KAAK,aAAa,CAAC;AAAA,MACrD;AAEA,YAAM,SAAS,MAAM,MAAM,IAAI,aAAa;AAG5C,UAAI,QAAQ,IAAI;AACd,aAAK,OAAO,IAAI,OAAO;AAAA,MACzB;AAAA,IACF;AAAA,EAC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BAAoB,CAAC,MAAM,YAAY;AACrC,YAAM,EAAE,KAAK,IAAI;AAGjB,UAAI,KAAK,WAAW,KAAK,KAAK,CAAC,MAAM,gBAAgB,KAAK,CAAC,MAAM,mBAAmB;AAClF,cAAM,aAAa,eAAe,MAAM,OAAO;AAG/C,YACE,OAAO,eAAe,YACtB,eAAe,QACf,YAAY,cACZ,OAAO,WAAW,QAAQ,MAAM,YAChC,WAAW,QAAQ,EAAE,YAAY,MAAM,WAAW,QAAQ,GAC1D;AACA,qBAAW,QAAQ,IAAI,WAAW,QAAQ,EAAE,YAAY;AAAA,QAC1D;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
4
|
+
"sourcesContent": ["/**\n * This file contains a collection of plugins used for the bundler.\n * Plugins defined here can extend or modify the behavior of the bundling process,\n * such as adding lifecycle hooks or custom processing logic.\n */\n\nimport type { LifecyclePlugin } from '@scalar/json-magic/bundle'\n\nimport { isLocalRef } from '@/helpers/general'\nimport { getResolvedRef } from '@/plugins/bundler/helpers'\n\n/**\n * A lifecycle plugin that adds a `$status` property to nodes during resolution.\n * - Sets `$status` to 'loading' when resolution starts.\n * - Sets `$status` to 'error' if resolution fails.\n * - Removes `$status` when resolution succeeds.\n */\nexport const loadingStatus = (): LifecyclePlugin => {\n return {\n type: 'lifecycle',\n onResolveStart: (node) => {\n node['$status'] = 'loading'\n },\n onResolveError: (node) => {\n node['$status'] = 'error'\n },\n onResolveSuccess: (node) => {\n delete node['$status']\n },\n }\n}\n\n/**\n * Lifecycle plugin to resolve and embed external content referenced by an 'externalValue' property in a node.\n *\n * When a node contains an 'externalValue' property (as a string), this plugin will:\n * - Fetch the external resource (such as a URL or file) using the fetchUrls plugin.\n * - If the fetch is successful, assign the fetched data to the node's 'value' property.\n *\n * This is useful for inlining external content (like examples or schemas) into the OpenAPI document during bundling.\n *\n * @param node - The node being processed, which may contain an 'externalValue' property.\n */\nexport const externalValueResolver = (): LifecyclePlugin => {\n return {\n type: 'lifecycle',\n onAfterNodeProcess: async (node, context) => {\n const externalValue = node['externalValue']\n const cache = context.resolutionCache\n\n // Only process if 'externalValue' is a string\n if (typeof externalValue !== 'string') {\n return\n }\n\n const loader = context.loaders.find((it) => it.validate(externalValue))\n\n // We can not process the external value\n if (!loader) {\n return\n }\n\n if (!cache.has(externalValue)) {\n cache.set(externalValue, loader.exec(externalValue))\n }\n\n const result = await cache.get(externalValue)\n\n // If fetch is successful, assign the data to the node's 'value' property\n if (result?.ok) {\n node['value'] = result.data\n }\n },\n }\n}\n\n/**\n * Lifecycle plugin to resolve $ref on any object, including non-standard locations like the info object.\n *\n * This plugin will:\n * - Detect if a node contains a $ref property (as a string).\n * - If the node is under the 'info' path, attempt to resolve the reference using fetchUrls.\n * - Replace the node's properties with the resolved data if successful.\n *\n * Note: This currently only supports refs on the 'info' object and does not handle primitive types.\n */\nexport const refsEverywhere = (): LifecyclePlugin => {\n return {\n type: 'lifecycle',\n onBeforeNodeProcess: async (node, context) => {\n const { path, resolutionCache, parentNode } = context\n const ref = node['$ref']\n\n // Only process nodes that have a $ref property as a string\n if (typeof ref !== 'string') {\n return\n }\n\n // Can not resolve top level refs\n if (!parentNode || !path.length) {\n return\n }\n\n const loader = context.loaders.find((it) => it.validate(ref))\n\n // Can not load the external ref\n if (!loader) {\n return\n }\n\n // Support resolving $ref on the info object\n if (path[0] === 'info') {\n // Use the cache to avoid duplicate fetches\n if (!resolutionCache.has(ref)) {\n resolutionCache.set(ref, loader.exec(ref))\n }\n\n const result = await resolutionCache.get(ref)\n\n if (result?.ok) {\n // Replace the ref with the resolved data\n parentNode[path.at(-1)!] = result.data\n }\n }\n },\n }\n}\n\n/**\n * Lifecycle plugin to restore original $ref values after processing.\n *\n * This plugin is intended to be used as a \"lifecycle\" plugin in the bundling process.\n * It operates in the `onAfterNodeProcess` hook, and its main purpose is to restore\n * the original $ref values for external references that may have been replaced or\n * rewritten during the bundling process.\n *\n * How it works:\n * - For each node processed, if the node contains a $ref property (as a string),\n * and the root document contains an \"x-ext-urls\" mapping object,\n * the plugin will attempt to restore the original $ref value.\n * - The \"x-ext-urls\" object is expected to be a mapping from the rewritten $ref\n * (e.g., a hashed or compressed reference) back to the original external URL or path.\n * - If a mapping exists for the current $ref, the plugin replaces the $ref value\n * with the original value from the mapping. If no mapping exists (e.g., for local refs),\n * the $ref value is left unchanged.\n *\n * This is useful for scenarios where you want to present or export the bundled document\n * with the original external $ref values, rather than the internal or rewritten ones.\n *\n * @returns {LifecyclePlugin} The plugin object for use in the bundler.\n */\nexport const restoreOriginalRefs = (): LifecyclePlugin => {\n return {\n type: 'lifecycle',\n onBeforeNodeProcess: (node, context) => {\n const ref = node['$ref']\n const root = context.rootNode\n const extUrls = root['x-ext-urls']\n\n // Only process if $ref is a string and x-ext-urls is a valid object\n if (typeof ref !== 'string' || typeof extUrls !== 'object' || extUrls === null || !isLocalRef(ref)) {\n return\n }\n\n // Working with local refs\n\n const segments = ref.split('/')\n const key = segments.at(-1) ?? ''\n\n // Replace the $ref with the original version from the mapping,\n // or keep the current version if there is no mapping (e.g., for local refs)\n node['$ref'] = (extUrls as Record<string, string>)[key] ?? ref\n },\n }\n}\n\n/**\n * Lifecycle plugin to normalize the `scheme` property in securitySchemes to lowercase.\n *\n * Our typebox schemas require the `scheme` property to be a lowercase string.\n * This plugin ensures that any `scheme` field under `components.securitySchemes` is normalized to lowercase, fixing\n * potential user input errors such as \"Bearer\" or \"BASIC\".\n *\n * Example:\n * ```yaml\n * Before normalization:\n * components:\n * securitySchemes:\n * bearerAuth:\n * type: http\n * scheme: Bearer\n * ```\n * After normalization:\n * ```yaml\n * components:\n * securitySchemes:\n * bearerAuth:\n * type: http\n * scheme: bearer\n * ```\n */\nexport const normalizeAuthSchemes = (): LifecyclePlugin => {\n return {\n type: 'lifecycle',\n onAfterNodeProcess: (node, context) => {\n const { path } = context\n\n // Check if we're at components.securitySchemes.{schemeName}\n if (path.length === 3 && path[0] === 'components' && path[1] === 'securitySchemes') {\n const targetNode = getResolvedRef(node, context)\n\n // If the scheme exists and is a string, normalize to lowercase if not already\n if (\n typeof targetNode === 'object' &&\n targetNode !== null &&\n 'scheme' in targetNode &&\n typeof targetNode['scheme'] === 'string' &&\n targetNode['scheme'].toLowerCase() !== targetNode['scheme']\n ) {\n targetNode['scheme'] = targetNode['scheme'].toLowerCase()\n }\n }\n },\n }\n}\n\n/**\n * Lifecycle plugin to normalize $ref nodes:\n * Ensures that for any non-schema object containing a $ref, only $ref,\n * summary, description, and $status properties are preserved.\n * This keeps $ref references clean and predictable for downstream consumers.\n */\nexport const normalizeRefs = (): LifecyclePlugin => {\n return {\n type: 'lifecycle',\n onBeforeNodeProcess: (node, context) => {\n const { path } = context\n\n // If the node is a $ref and we are not on the schema object, we need to normalize the $ref\n if (typeof node['$ref'] === 'string' && !(path[0] === 'components' && path[1] === 'schemas')) {\n // Remove any other properties from the node and only keep the '$ref', 'summary', 'description' and '$status'\n const keepProperties = new Set(['$ref', 'summary', 'description', '$status'])\n\n Object.keys(node).forEach((key) => {\n if (!keepProperties.has(key)) {\n delete node[key]\n }\n })\n }\n },\n }\n}\n"],
|
|
5
|
+
"mappings": "AAQA,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAQxB,MAAM,gBAAgB,MAAuB;AAClD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,gBAAgB,CAAC,SAAS;AACxB,WAAK,SAAS,IAAI;AAAA,IACpB;AAAA,IACA,gBAAgB,CAAC,SAAS;AACxB,WAAK,SAAS,IAAI;AAAA,IACpB;AAAA,IACA,kBAAkB,CAAC,SAAS;AAC1B,aAAO,KAAK,SAAS;AAAA,IACvB;AAAA,EACF;AACF;AAaO,MAAM,wBAAwB,MAAuB;AAC1D,SAAO;AAAA,IACL,MAAM;AAAA,IACN,oBAAoB,OAAO,MAAM,YAAY;AAC3C,YAAM,gBAAgB,KAAK,eAAe;AAC1C,YAAM,QAAQ,QAAQ;AAGtB,UAAI,OAAO,kBAAkB,UAAU;AACrC;AAAA,MACF;AAE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ACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../src/plugins/client/persistence.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEzD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAU,0CAKrC;IACD,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,KAAG,OAAO,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../src/plugins/client/persistence.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEzD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAU,0CAKrC;IACD,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,KAAG,OAAO,CAAC,eAAe,CAwE1B,CAAA"}
|
|
@@ -42,6 +42,18 @@ const persistencePlugin = async ({
|
|
|
42
42
|
() => persistence.overrides.setItem(workspaceId, event.documentName, event.value)
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
|
+
if (event.type === "history") {
|
|
46
|
+
return execute(
|
|
47
|
+
`history-${workspaceId}-${event.documentName}`,
|
|
48
|
+
() => persistence.history.setItem(workspaceId, event.documentName, event.value)
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
if (event.type === "auth") {
|
|
52
|
+
return execute(
|
|
53
|
+
`auth-${workspaceId}-${event.documentName}`,
|
|
54
|
+
() => persistence.auth.setItem(workspaceId, event.documentName, event.value)
|
|
55
|
+
);
|
|
56
|
+
}
|
|
45
57
|
if (event.type === "deleteDocument") {
|
|
46
58
|
return execute(
|
|
47
59
|
`deleteDocument-${workspaceId}-${event.documentName}`,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/client/persistence.ts"],
|
|
4
|
-
"sourcesContent": ["import { debounce } from '@scalar/helpers/general/debounce'\n\nimport { createWorkspaceStorePersistence } from '@/persistence'\nimport type { WorkspacePlugin } from '@/workspace-plugin'\n\n/**\n * Plugin to persist workspace state changes with debounced writes.\n * Each type of change (meta, documentConfigs, documents, etc.) is debounced by key (type + workspaceId + optional documentName).\n * The debounce delay can be customized, defaults to 500ms.\n *\n * This avoids excessive writes to IndexedDB or other persistence layer when changes occur rapidly.\n */\nexport const persistencePlugin = async ({\n workspaceId,\n debounceDelay = 500,\n /** Maximum time in milliseconds to wait before forcing execution, even with continuous calls. */\n maxWait = 10000,\n}: {\n workspaceId: string\n debounceDelay?: number\n maxWait?: number\n}): Promise<WorkspacePlugin> => {\n // Create the persistence instance (e.g., IndexedDB, localForage, etc.)\n const persistence = await createWorkspaceStorePersistence()\n // Debounced execute function for batching similar state changes\n const { execute } = debounce({ delay: debounceDelay, maxWait })\n\n return {\n hooks: {\n /**\n * Handles all workspace state change events.\n * Each write is debounced by a composite key to prevent frequent writes for the same entity.\n */\n onWorkspaceStateChanges(event) {\n // If the event is for workspace meta data, debounce by workspaceId\n if (event.type === 'meta') {\n return execute(`meta-${workspaceId}`, () => persistence.meta.setItem(workspaceId, event.value))\n }\n\n // Debounce per document content and workspace\n if (event.type === 'documents') {\n return execute(`documents-${workspaceId}-${event.documentName}`, () =>\n persistence.documents.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Debounce per intermediate document and workspace\n if (event.type === 'intermediateDocuments') {\n return execute(`intermediateDocuments-${workspaceId}-${event.documentName}`, () =>\n persistence.intermediateDocuments.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Debounce per original document and workspace\n if (event.type === 'originalDocuments') {\n return execute(`originalDocuments-${workspaceId}-${event.documentName}`, () =>\n persistence.originalDocuments.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Debounce per document override and workspace\n if (event.type === 'overrides') {\n return execute(`overrides-${workspaceId}-${event.documentName}`, () =>\n persistence.overrides.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Delete document\n if (event.type === 'deleteDocument') {\n return execute(`deleteDocument-${workspaceId}-${event.documentName}`, () =>\n persistence.workspace.deleteDocument(workspaceId, event.documentName),\n )\n }\n\n // No action for other event types\n return\n },\n },\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,gBAAgB;AAEzB,SAAS,uCAAuC;AAUzC,MAAM,oBAAoB,OAAO;AAAA,EACtC;AAAA,EACA,gBAAgB;AAAA;AAAA,EAEhB,UAAU;AACZ,MAIgC;AAE9B,QAAM,cAAc,MAAM,gCAAgC;AAE1D,QAAM,EAAE,QAAQ,IAAI,SAAS,EAAE,OAAO,eAAe,QAAQ,CAAC;AAE9D,SAAO;AAAA,IACL,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,MAKL,wBAAwB,OAAO;AAE7B,YAAI,MAAM,SAAS,QAAQ;AACzB,iBAAO,QAAQ,QAAQ,WAAW,IAAI,MAAM,YAAY,KAAK,QAAQ,aAAa,MAAM,KAAK,CAAC;AAAA,QAChG;AAGA,YAAI,MAAM,SAAS,aAAa;AAC9B,iBAAO;AAAA,YAAQ,aAAa,WAAW,IAAI,MAAM,YAAY;AAAA,YAAI,MAC/D,YAAY,UAAU,QAAQ,aAAa,MAAM,cAAc,MAAM,KAAK;AAAA,UAC5E;AAAA,QACF;AAGA,YAAI,MAAM,SAAS,yBAAyB;AAC1C,iBAAO;AAAA,YAAQ,yBAAyB,WAAW,IAAI,MAAM,YAAY;AAAA,YAAI,MAC3E,YAAY,sBAAsB,QAAQ,aAAa,MAAM,cAAc,MAAM,KAAK;AAAA,UACxF;AAAA,QACF;AAGA,YAAI,MAAM,SAAS,qBAAqB;AACtC,iBAAO;AAAA,YAAQ,qBAAqB,WAAW,IAAI,MAAM,YAAY;AAAA,YAAI,MACvE,YAAY,kBAAkB,QAAQ,aAAa,MAAM,cAAc,MAAM,KAAK;AAAA,UACpF;AAAA,QACF;AAGA,YAAI,MAAM,SAAS,aAAa;AAC9B,iBAAO;AAAA,YAAQ,aAAa,WAAW,IAAI,MAAM,YAAY;AAAA,YAAI,MAC/D,YAAY,UAAU,QAAQ,aAAa,MAAM,cAAc,MAAM,KAAK;AAAA,UAC5E;AAAA,QACF;AAGA,YAAI,MAAM,SAAS,kBAAkB;AACnC,iBAAO;AAAA,YAAQ,kBAAkB,WAAW,IAAI,MAAM,YAAY;AAAA,YAAI,MACpE,YAAY,UAAU,eAAe,aAAa,MAAM,YAAY;AAAA,UACtE;AAAA,QACF;AAGA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
4
|
+
"sourcesContent": ["import { debounce } from '@scalar/helpers/general/debounce'\n\nimport { createWorkspaceStorePersistence } from '@/persistence'\nimport type { WorkspacePlugin } from '@/workspace-plugin'\n\n/**\n * Plugin to persist workspace state changes with debounced writes.\n * Each type of change (meta, documentConfigs, documents, etc.) is debounced by key (type + workspaceId + optional documentName).\n * The debounce delay can be customized, defaults to 500ms.\n *\n * This avoids excessive writes to IndexedDB or other persistence layer when changes occur rapidly.\n */\nexport const persistencePlugin = async ({\n workspaceId,\n debounceDelay = 500,\n /** Maximum time in milliseconds to wait before forcing execution, even with continuous calls. */\n maxWait = 10000,\n}: {\n workspaceId: string\n debounceDelay?: number\n maxWait?: number\n}): Promise<WorkspacePlugin> => {\n // Create the persistence instance (e.g., IndexedDB, localForage, etc.)\n const persistence = await createWorkspaceStorePersistence()\n // Debounced execute function for batching similar state changes\n const { execute } = debounce({ delay: debounceDelay, maxWait })\n\n return {\n hooks: {\n /**\n * Handles all workspace state change events.\n * Each write is debounced by a composite key to prevent frequent writes for the same entity.\n */\n onWorkspaceStateChanges(event) {\n // If the event is for workspace meta data, debounce by workspaceId\n if (event.type === 'meta') {\n return execute(`meta-${workspaceId}`, () => persistence.meta.setItem(workspaceId, event.value))\n }\n\n // Debounce per document content and workspace\n if (event.type === 'documents') {\n return execute(`documents-${workspaceId}-${event.documentName}`, () =>\n persistence.documents.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Debounce per intermediate document and workspace\n if (event.type === 'intermediateDocuments') {\n return execute(`intermediateDocuments-${workspaceId}-${event.documentName}`, () =>\n persistence.intermediateDocuments.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Debounce per original document and workspace\n if (event.type === 'originalDocuments') {\n return execute(`originalDocuments-${workspaceId}-${event.documentName}`, () =>\n persistence.originalDocuments.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Debounce per document override and workspace\n if (event.type === 'overrides') {\n return execute(`overrides-${workspaceId}-${event.documentName}`, () =>\n persistence.overrides.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Debounce per document history and workspace\n if (event.type === 'history') {\n return execute(`history-${workspaceId}-${event.documentName}`, () =>\n persistence.history.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Debounce per document auth and workspace\n if (event.type === 'auth') {\n return execute(`auth-${workspaceId}-${event.documentName}`, () =>\n persistence.auth.setItem(workspaceId, event.documentName, event.value),\n )\n }\n\n // Delete document\n if (event.type === 'deleteDocument') {\n return execute(`deleteDocument-${workspaceId}-${event.documentName}`, () =>\n persistence.workspace.deleteDocument(workspaceId, event.documentName),\n )\n }\n\n // No action for other event types\n return\n },\n },\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gBAAgB;AAEzB,SAAS,uCAAuC;AAUzC,MAAM,oBAAoB,OAAO;AAAA,EACtC;AAAA,EACA,gBAAgB;AAAA;AAAA,EAEhB,UAAU;AACZ,MAIgC;AAE9B,QAAM,cAAc,MAAM,gCAAgC;AAE1D,QAAM,EAAE,QAAQ,IAAI,SAAS,EAAE,OAAO,eAAe,QAAQ,CAAC;AAE9D,SAAO;AAAA,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Q,aAAa,MAAM,cAAc,MAAM,KAAK;AAAA,UACvE;AAAA,QACF;AAGA,YAAI,MAAM,SAAS,kBAAkB;AACnC,iBAAO;AAAA,YAAQ,kBAAkB,WAAW,IAAI,MAAM,YAAY;AAAA,YAAI,MACpE,YAAY,UAAU,eAAe,aAAa,MAAM,YAAY;AAAA,UACtE;AAAA,QACF;AAGA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MaybeRefSchemaObject, SchemaObject } from './schemas/v3.1/strict/schema.js';
|
|
2
|
+
type ResolvedSchema<T> = T extends undefined ? undefined : SchemaObject & {
|
|
3
|
+
$ref?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const resolve: {
|
|
6
|
+
schema: <T extends MaybeRefSchemaObject | undefined>(schema: T) => ResolvedSchema<T>;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAUtF,KAAK,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,SAAS,GAAG,YAAY,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE3F,eAAO,MAAM,OAAO;aACT,CAAC,SAAS,oBAAoB,GAAG,SAAS,UAAU,CAAC,KAAG,cAAc,CAAC,CAAC,CAAC;CAWnF,CAAA"}
|
package/dist/resolve.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Type } from "@scalar/typebox";
|
|
2
|
+
import { getResolvedRef } from "./helpers/get-resolved-ref.js";
|
|
3
|
+
import { compose } from "./schemas/compose.js";
|
|
4
|
+
import { coerceValue } from "./schemas/typebox-coerce.js";
|
|
5
|
+
import { SchemaObjectSchema } from "./schemas/v3.1/strict/openapi-document.js";
|
|
6
|
+
const mergeSiblingReferences = (node) => {
|
|
7
|
+
const { "$ref-value": value, ...rest } = node;
|
|
8
|
+
return {
|
|
9
|
+
...value,
|
|
10
|
+
...rest
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const resolve = {
|
|
14
|
+
schema: (schema) => {
|
|
15
|
+
if (schema === void 0) {
|
|
16
|
+
return void 0;
|
|
17
|
+
}
|
|
18
|
+
const resoled = getResolvedRef(schema, mergeSiblingReferences);
|
|
19
|
+
return coerceValue(
|
|
20
|
+
compose(SchemaObjectSchema, Type.Object({ $ref: Type.Optional(Type.String()) })),
|
|
21
|
+
resoled
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
resolve
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/resolve.ts"],
|
|
4
|
+
"sourcesContent": ["import { Type } from '@scalar/typebox'\n\nimport { type RefNode, getResolvedRef } from '@/helpers/get-resolved-ref'\nimport { compose } from '@/schemas/compose'\nimport { coerceValue } from '@/schemas/typebox-coerce'\nimport { SchemaObjectSchema } from '@/schemas/v3.1/strict/openapi-document'\nimport type { MaybeRefSchemaObject, SchemaObject } from '@/schemas/v3.1/strict/schema'\n\nconst mergeSiblingReferences = <Node>(node: RefNode<Node>) => {\n const { '$ref-value': value, ...rest } = node\n return {\n ...value,\n ...rest,\n }\n}\n\ntype ResolvedSchema<T> = T extends undefined ? undefined : SchemaObject & { $ref?: string }\n\nexport const resolve = {\n schema: <T extends MaybeRefSchemaObject | undefined>(schema: T): ResolvedSchema<T> => {\n if (schema === undefined) {\n return undefined as ResolvedSchema<T>\n }\n\n const resoled = getResolvedRef(schema, mergeSiblingReferences)\n return coerceValue(\n compose(SchemaObjectSchema, Type.Object({ $ref: Type.Optional(Type.String()) })),\n resoled,\n ) as ResolvedSchema<T>\n },\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY;AAErB,SAAuB,sBAAsB;AAC7C,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AAGnC,MAAM,yBAAyB,CAAO,SAAwB;AAC5D,QAAM,EAAE,cAAc,OAAO,GAAG,KAAK,IAAI;AACzC,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AACF;AAIO,MAAM,UAAU;AAAA,EACrB,QAAQ,CAA6C,WAAiC;AACpF,QAAI,WAAW,QAAW;AACxB,aAAO;AAAA,IACT;AAEA,UAAM,UAAU,eAAe,QAAQ,sBAAsB;AAC7D,WAAO;AAAA,MACL,QAAQ,oBAAoB,KAAK,OAAO,EAAE,MAAM,KAAK,SAAS,KAAK,OAAO,CAAC,EAAE,CAAC,CAAC;AAAA,MAC/E;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/schemas/extensions/security/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,6BAA6B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.js.map
|