@scalar/workspace-store 0.73.0 → 0.75.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.
Files changed (122) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +10 -0
  3. package/dist/client.d.ts +3 -0
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +77 -10
  6. package/dist/entities/auth/schema.d.ts +405 -40
  7. package/dist/entities/auth/schema.d.ts.map +1 -1
  8. package/dist/helpers/async-api-schema-resources/load-inline.d.ts +7 -0
  9. package/dist/helpers/async-api-schema-resources/load-inline.d.ts.map +1 -0
  10. package/dist/helpers/async-api-schema-resources/load-inline.js +31 -0
  11. package/dist/helpers/async-api-schema-resources/protobuf-imports.d.ts +8 -0
  12. package/dist/helpers/async-api-schema-resources/protobuf-imports.d.ts.map +1 -0
  13. package/dist/helpers/async-api-schema-resources/protobuf-imports.js +25 -0
  14. package/dist/helpers/async-api-schema-resources/raml-source.d.ts +12 -0
  15. package/dist/helpers/async-api-schema-resources/raml-source.d.ts.map +1 -0
  16. package/dist/helpers/async-api-schema-resources/raml-source.js +32 -0
  17. package/dist/helpers/async-api-schema-resources/resolver.d.ts +12 -0
  18. package/dist/helpers/async-api-schema-resources/resolver.d.ts.map +1 -0
  19. package/dist/helpers/async-api-schema-resources/resolver.js +31 -0
  20. package/dist/helpers/async-api-schema-resources/resources.d.ts +13 -0
  21. package/dist/helpers/async-api-schema-resources/resources.d.ts.map +1 -0
  22. package/dist/helpers/async-api-schema-resources/resources.js +133 -0
  23. package/dist/helpers/async-api-schema-resources/schema-resource-path.d.ts +3 -0
  24. package/dist/helpers/async-api-schema-resources/schema-resource-path.d.ts.map +1 -0
  25. package/dist/helpers/async-api-schema-resources/schema-resource-path.js +9 -0
  26. package/dist/helpers/async-api-schema-resources/schema-wrappers.d.ts +9 -0
  27. package/dist/helpers/async-api-schema-resources/schema-wrappers.d.ts.map +1 -0
  28. package/dist/helpers/async-api-schema-resources/schema-wrappers.js +69 -0
  29. package/dist/helpers/async-api-schema-resources/track-edits.d.ts +3 -0
  30. package/dist/helpers/async-api-schema-resources/track-edits.d.ts.map +1 -0
  31. package/dist/helpers/async-api-schema-resources/track-edits.js +46 -0
  32. package/dist/helpers/compact-upgrade-metadata.d.ts +3 -0
  33. package/dist/helpers/compact-upgrade-metadata.d.ts.map +1 -0
  34. package/dist/helpers/compact-upgrade-metadata.js +71 -0
  35. package/dist/helpers/is-file-schema.js +1 -1
  36. package/dist/helpers/querystring-parameter.d.ts +3 -1
  37. package/dist/helpers/querystring-parameter.d.ts.map +1 -1
  38. package/dist/helpers/querystring-parameter.js +2 -2
  39. package/dist/helpers/resolve-async-api-schema.d.ts +2 -0
  40. package/dist/helpers/resolve-async-api-schema.d.ts.map +1 -1
  41. package/dist/helpers/resolve-async-api-schema.js +25 -1
  42. package/dist/helpers/use-async-api-schema-resources.d.ts +12 -0
  43. package/dist/helpers/use-async-api-schema-resources.d.ts.map +1 -0
  44. package/dist/helpers/use-async-api-schema-resources.js +24 -0
  45. package/dist/mutators/operation/parameters.d.ts.map +1 -1
  46. package/dist/mutators/operation/parameters.js +9 -1
  47. package/dist/mutators/operation/reset-request-body.d.ts.map +1 -1
  48. package/dist/mutators/operation/reset-request-body.js +3 -1
  49. package/dist/navigation/helpers/get-x-badges.d.ts +10 -0
  50. package/dist/navigation/helpers/get-x-badges.d.ts.map +1 -0
  51. package/dist/navigation/helpers/get-x-badges.js +26 -0
  52. package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
  53. package/dist/navigation/helpers/traverse-paths.js +3 -0
  54. package/dist/navigation/helpers/traverse-schemas.d.ts.map +1 -1
  55. package/dist/navigation/helpers/traverse-schemas.js +3 -0
  56. package/dist/navigation/helpers/traverse-tags.d.ts.map +1 -1
  57. package/dist/navigation/helpers/traverse-tags.js +3 -0
  58. package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
  59. package/dist/navigation/helpers/traverse-webhooks.js +3 -0
  60. package/dist/plugins/bundler/async-api-schema-resources.d.ts +4 -0
  61. package/dist/plugins/bundler/async-api-schema-resources.d.ts.map +1 -0
  62. package/dist/plugins/bundler/async-api-schema-resources.js +20 -0
  63. package/dist/plugins/bundler/index.d.ts +1 -1
  64. package/dist/plugins/bundler/index.d.ts.map +1 -1
  65. package/dist/plugins/bundler/index.js +7 -4
  66. package/dist/plugins/bundler/openapi-document.d.ts +5 -1
  67. package/dist/plugins/bundler/openapi-document.d.ts.map +1 -1
  68. package/dist/plugins/bundler/openapi-document.js +7 -3
  69. package/dist/plugins/bundler/upgrade-documents.d.ts +4 -0
  70. package/dist/plugins/bundler/upgrade-documents.d.ts.map +1 -0
  71. package/dist/plugins/bundler/upgrade-documents.js +357 -0
  72. package/dist/request-example/builder/body/build-request-body.d.ts +1 -1
  73. package/dist/request-example/builder/body/build-request-body.d.ts.map +1 -1
  74. package/dist/request-example/builder/body/build-request-body.js +2 -2
  75. package/dist/request-example/builder/body/get-request-body-example.d.ts +2 -2
  76. package/dist/request-example/builder/body/get-request-body-example.d.ts.map +1 -1
  77. package/dist/request-example/builder/body/get-request-body-example.js +7 -3
  78. package/dist/request-example/builder/build-request.d.ts.map +1 -1
  79. package/dist/request-example/builder/build-request.js +3 -2
  80. package/dist/request-example/builder/helpers/array-contains.d.ts +15 -0
  81. package/dist/request-example/builder/helpers/array-contains.d.ts.map +1 -0
  82. package/dist/request-example/builder/helpers/array-contains.js +199 -0
  83. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts +9 -0
  84. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts.map +1 -1
  85. package/dist/request-example/builder/helpers/get-example-from-schema.js +162 -31
  86. package/dist/request-example/builder/request-factory.d.ts +5 -1
  87. package/dist/request-example/builder/request-factory.d.ts.map +1 -1
  88. package/dist/request-example/builder/request-factory.js +5 -3
  89. package/dist/request-example/builder/security/build-request-security.d.ts +6 -4
  90. package/dist/request-example/builder/security/build-request-security.d.ts.map +1 -1
  91. package/dist/request-example/builder/security/build-request-security.js +1 -0
  92. package/dist/schemas/extensions/security/x-scalar-token-prefix.d.ts +11 -0
  93. package/dist/schemas/extensions/security/x-scalar-token-prefix.d.ts.map +1 -0
  94. package/dist/schemas/extensions/security/x-scalar-token-prefix.js +8 -0
  95. package/dist/schemas/navigation.d.ts +49 -0
  96. package/dist/schemas/navigation.d.ts.map +1 -1
  97. package/dist/schemas/navigation.js +5 -0
  98. package/dist/schemas/reference-config/index.d.ts +81 -8
  99. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  100. package/dist/schemas/reference-config/settings.d.ts +81 -8
  101. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  102. package/dist/schemas/v3.1/strict/openapi-document.d.ts +2835 -280
  103. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  104. package/dist/schemas/v3.1/strict/schema.d.ts +62 -10
  105. package/dist/schemas/v3.1/strict/schema.d.ts.map +1 -1
  106. package/dist/schemas/v3.1/strict/schema.js +10 -2
  107. package/dist/schemas/v3.1/strict/security-scheme.d.ts +4 -1
  108. package/dist/schemas/v3.1/strict/security-scheme.d.ts.map +1 -1
  109. package/dist/schemas/v3.1/strict/security-scheme.js +2 -1
  110. package/dist/schemas/v3.2/openapi/index.d.ts.map +1 -1
  111. package/dist/schemas/v3.2/openapi/index.js +7 -2
  112. package/dist/schemas/v3.2/strict/openapi-document.d.ts +2835 -280
  113. package/dist/schemas/v3.2/strict/openapi-document.d.ts.map +1 -1
  114. package/dist/schemas/v3.2/strict/schema.d.ts +62 -10
  115. package/dist/schemas/v3.2/strict/schema.d.ts.map +1 -1
  116. package/dist/schemas/v3.2/strict/schema.js +10 -2
  117. package/dist/schemas/v3.2/strict/security-scheme.d.ts +4 -1
  118. package/dist/schemas/v3.2/strict/security-scheme.d.ts.map +1 -1
  119. package/dist/schemas/v3.2/strict/security-scheme.js +2 -1
  120. package/dist/server.d.ts.map +1 -1
  121. package/dist/server.js +33 -3
  122. package/package.json +16 -15
@@ -0,0 +1,71 @@
1
+ import { isObject } from '@scalar/helpers/object/is-object';
2
+ /** Retain only upgrade bookkeeping needed by references that still load external resources. */
3
+ export const compactUpgradeMetadata = (document) => {
4
+ const metadata = document['x-scalar-upgrade'];
5
+ if (!isObject(metadata)) {
6
+ return;
7
+ }
8
+ const references = [];
9
+ const visited = new WeakSet();
10
+ const visit = (value, path) => {
11
+ if (value === null || typeof value !== 'object' || visited.has(value)) {
12
+ return;
13
+ }
14
+ visited.add(value);
15
+ if (isObject(value) && typeof value.$ref === 'string' && !value.$ref.startsWith('#')) {
16
+ references.push(path);
17
+ }
18
+ for (const [key, child] of Object.entries(value)) {
19
+ if (key !== 'x-scalar-upgrade' && key !== 'x-ext' && key !== 'x-ext-urls') {
20
+ visit(child, [...path, key]);
21
+ }
22
+ }
23
+ };
24
+ visit(document, []);
25
+ if (references.length === 0) {
26
+ delete document['x-scalar-upgrade'];
27
+ return;
28
+ }
29
+ // External resources can refer back to relocated entry targets. Keep those mappings,
30
+ // but descendants that follow the same prefix substitution need no separate entry.
31
+ const mappings = new Map();
32
+ if (Array.isArray(metadata.locations)) {
33
+ // upgradeFragment records parents before visiting their children. Preserve that order:
34
+ // descendant mappings can only be omitted after their inherited prefix is known.
35
+ metadata.locations = metadata.locations.filter((location) => {
36
+ if (!isObject(location) || !Array.isArray(location.source) || !Array.isArray(location.output)) {
37
+ return false;
38
+ }
39
+ const source = location.source;
40
+ const output = location.output;
41
+ const key = JSON.stringify(source);
42
+ // Multiple media types can copy one source; the resolver uses its first destination.
43
+ if (mappings.has(key)) {
44
+ return false;
45
+ }
46
+ mappings.set(key, output);
47
+ for (let length = source.length - 1; length >= 0; length--) {
48
+ const parent = mappings.get(JSON.stringify(source.slice(0, length)));
49
+ if (parent) {
50
+ if (JSON.stringify([...parent, ...source.slice(length)]) === JSON.stringify(output)) {
51
+ return false;
52
+ }
53
+ break;
54
+ }
55
+ }
56
+ return true;
57
+ });
58
+ }
59
+ if (Array.isArray(metadata.contexts)) {
60
+ const contexts = metadata.contexts.filter((context) => {
61
+ const prefix = isObject(context) ? context.path : undefined;
62
+ return Array.isArray(prefix) && references.some((path) => prefix.every((part, index) => path[index] === part));
63
+ });
64
+ if (contexts.length === 0) {
65
+ delete metadata.contexts;
66
+ }
67
+ else {
68
+ metadata.contexts = contexts;
69
+ }
70
+ }
71
+ };
@@ -7,7 +7,7 @@ import { isArraySchema, isStringSchema } from '../schemas/v3.2/strict/type-guard
7
7
  export const isFileSchema = (schema, allowUntyped = true, contentType) => {
8
8
  const seen = new Set();
9
9
  const visit = (input, allowAlternatives = true, allowRawBinary = false) => {
10
- if (!input || seen.has(input)) {
10
+ if (!input || typeof input === 'boolean' || seen.has(input)) {
11
11
  return false;
12
12
  }
13
13
  seen.add(input);
@@ -11,7 +11,9 @@ export type QuerystringParameter = {
11
11
  * Resolve the selected whole-query example, including content-schema defaults.
12
12
  * This module serializes outgoing queries; mock-server/src/utils/querystring-parameter.ts decodes incoming ones.
13
13
  */
14
- export declare const getQuerystringParameter: (parameter: ParameterObject, exampleName?: string, { defaultDisabled, includeDisabled, }?: {
14
+ export declare const getQuerystringParameter: (parameter: ParameterObject, exampleName?: string, { defaultDisabled, includeDisabled, openapiVersion, jsonSchemaDialect, }?: {
15
+ openapiVersion?: string;
16
+ jsonSchemaDialect?: string;
15
17
  defaultDisabled?: boolean;
16
18
  /** Editors must retain the value when its checkbox is off. */
17
19
  includeDisabled?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"querystring-parameter.d.ts","sourceRoot":"","sources":["../../src/helpers/querystring-parameter.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAiB,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAE5G,yFAAyF;AACzF,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,OAAO,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACzC,sGAAsG;IACtG,IAAI,EAAE,WAAW,GAAG,YAAY,GAAG,MAAM,CAAA;CAC1C,CAAA;AAmBD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,cACvB,eAAe,gBACZ,MAAM,0CAIjB;IACD,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,8DAA8D;IAC9D,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,KACA,oBAAoB,GAAG,SA4BzB,CAAA;AAED,wFAAwF;AACxF,eAAO,MAAM,6BAA6B,cAC7B,oBAAoB,cACpB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC,KACrE,MAyDF,CAAA"}
1
+ {"version":3,"file":"querystring-parameter.d.ts","sourceRoot":"","sources":["../../src/helpers/querystring-parameter.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,cAAc,EAAiB,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAE5G,yFAAyF;AACzF,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,OAAO,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACzC,sGAAsG;IACtG,IAAI,EAAE,WAAW,GAAG,YAAY,GAAG,MAAM,CAAA;CAC1C,CAAA;AAmBD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,cACvB,eAAe,gBACZ,MAAM,6EAMjB;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,8DAA8D;IAC9D,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,KACA,oBAAoB,GAAG,SA4BzB,CAAA;AAED,wFAAwF;AACxF,eAAO,MAAM,6BAA6B,cAC7B,oBAAoB,cACpB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC,KACrE,MAyDF,CAAA"}
@@ -26,7 +26,7 @@ const getQuerystringValueKind = (example, source) => {
26
26
  * Resolve the selected whole-query example, including content-schema defaults.
27
27
  * This module serializes outgoing queries; mock-server/src/utils/querystring-parameter.ts decodes incoming ones.
28
28
  */
29
- export const getQuerystringParameter = (parameter, exampleName, { defaultDisabled = true, includeDisabled = false, } = {}) => {
29
+ export const getQuerystringParameter = (parameter, exampleName, { defaultDisabled = true, includeDisabled = false, openapiVersion, jsonSchemaDialect, } = {}) => {
30
30
  if (parameter.in !== 'querystring' || !('content' in parameter) || !parameter.content) {
31
31
  return undefined;
32
32
  }
@@ -46,7 +46,7 @@ export const getQuerystringParameter = (parameter, exampleName, { defaultDisable
46
46
  const schema = getResolvedRef(mediaType?.schema);
47
47
  let resolvedValue = value;
48
48
  if (resolvedValue === undefined) {
49
- resolvedValue = schema ? getExampleFromSchema(schema) : '';
49
+ resolvedValue = schema ? getExampleFromSchema(schema, { openapiVersion, jsonSchemaDialect }) : '';
50
50
  }
51
51
  return {
52
52
  value: resolvedValue,
@@ -1,4 +1,5 @@
1
1
  import type { SchemaObject } from '../schemas/v3.2/strict/openapi-document.js';
2
+ import type { AsyncApiSchemaResources } from './async-api-schema-resources/resources.js';
2
3
  /** Keep non-JSON schema languages out of JSON Schema rendering and traversal. */
3
4
  export declare const isAsyncApiJsonSchemaFormat: (format: unknown) => boolean;
4
5
  /** A schema that can use the shared renderer, or source in another schema language. */
@@ -9,6 +10,7 @@ type AsyncApiSchema = {
9
10
  kind: 'source';
10
11
  format: string;
11
12
  value: unknown;
13
+ resources?: AsyncApiSchemaResources;
12
14
  };
13
15
  /** Resolve the wrapper and its schema without discarding the declared schema language. */
14
16
  export declare const resolveAsyncApiSchema: (value: unknown) => AsyncApiSchema | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-async-api-schema.d.ts","sourceRoot":"","sources":["../../src/helpers/resolve-async-api-schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAA;AAK3E,iFAAiF;AACjF,eAAO,MAAM,0BAA0B,WAAY,OAAO,KAAG,OAkB5D,CAAA;AAED,uFAAuF;AACvF,KAAK,cAAc,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,YAAY,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAA;AAEnH,0FAA0F;AAC1F,eAAO,MAAM,qBAAqB,UAAW,OAAO,KAAG,cAAc,GAAG,SAgBvE,CAAA"}
1
+ {"version":3,"file":"resolve-async-api-schema.d.ts","sourceRoot":"","sources":["../../src/helpers/resolve-async-api-schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAA;AAC3E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAKrF,iFAAiF;AACjF,eAAO,MAAM,0BAA0B,WAAY,OAAO,KAAG,OAkB5D,CAAA;AAED,uFAAuF;AACvF,KAAK,cAAc,GACf;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,YAAY,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,uBAAuB,CAAA;CAAE,CAAA;AAsB3F,0FAA0F;AAC1F,eAAO,MAAM,qBAAqB,UAAW,OAAO,KAAG,cAAc,GAAG,SAsBvE,CAAA"}
@@ -22,6 +22,24 @@ export const isAsyncApiJsonSchemaFormat = (format) => {
22
22
  'application/vnd.oai.openapi+yaml',
23
23
  ].includes(mediaType ?? '');
24
24
  };
25
+ /** Restore only validated dependency metadata, rather than trusting arbitrary extension fields. */
26
+ const readResources = (value) => {
27
+ if (!isObject(value) ||
28
+ typeof value.origin !== 'string' ||
29
+ !isObject(value.files) ||
30
+ (value.failed !== undefined && value.failed !== true) ||
31
+ (value.deferred !== undefined && value.deferred !== true))
32
+ return undefined;
33
+ const entries = Object.entries(value.files);
34
+ if (!entries.every((entry) => typeof entry[1] === 'string'))
35
+ return undefined;
36
+ return {
37
+ origin: value.origin,
38
+ files: Object.fromEntries(entries),
39
+ ...(value.failed === true ? { failed: true } : {}),
40
+ ...(value.deferred === true ? { deferred: true } : {}),
41
+ };
42
+ };
25
43
  /** Resolve the wrapper and its schema without discarding the declared schema language. */
26
44
  export const resolveAsyncApiSchema = (value) => {
27
45
  const resolved = getResolvedAsyncApiRef(value);
@@ -31,7 +49,13 @@ export const resolveAsyncApiSchema = (value) => {
31
49
  return undefined;
32
50
  }
33
51
  if (wrapped && !isAsyncApiJsonSchemaFormat(resolved.schemaFormat)) {
34
- return { kind: 'source', format: String(resolved.schemaFormat), value: schema };
52
+ const resources = readResources(resolved['x-scalar-schema-resources']);
53
+ return {
54
+ kind: 'source',
55
+ format: String(resolved.schemaFormat),
56
+ value: schema,
57
+ ...(resources ? { resources } : {}),
58
+ };
35
59
  }
36
60
  if (typeof schema === 'boolean') {
37
61
  return { kind: 'schema', schema: getBooleanSchema(schema) };
@@ -0,0 +1,12 @@
1
+ import { type InjectionKey, type ShallowRef } from 'vue';
2
+ import { type AsyncApiSchemaResourceResolver } from './async-api-schema-resources/resolver.js';
3
+ import type { AsyncApiSchemaResources } from './async-api-schema-resources/resources.js';
4
+ /** Share the current document's authenticated loader and cache across expanded native schemas. */
5
+ export declare const ASYNC_API_SCHEMA_RESOURCES: InjectionKey<() => AsyncApiSchemaResourceResolver>;
6
+ /** This scope is mounted by expanded message/model slots, so collapsed schemas never fetch. */
7
+ export declare const useAsyncApiSchemaResources: (input: () => {
8
+ format: string;
9
+ value: unknown;
10
+ resources?: AsyncApiSchemaResources;
11
+ }) => ShallowRef<AsyncApiSchemaResources | undefined>;
12
+ //# sourceMappingURL=use-async-api-schema-resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-async-api-schema-resources.d.ts","sourceRoot":"","sources":["../../src/helpers/use-async-api-schema-resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAA+C,MAAM,KAAK,CAAA;AAErG,OAAO,EACL,KAAK,8BAA8B,EAEpC,MAAM,uCAAuC,CAAA;AAC9C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAErF,kGAAkG;AAClG,eAAO,MAAM,0BAA0B,EAAE,YAAY,CAAC,MAAM,8BAA8B,CACpD,CAAA;AAEtC,+FAA+F;AAC/F,eAAO,MAAM,0BAA0B,UAC9B,MAAM;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,uBAAuB,CAAA;CAAE,KACnF,UAAU,CAAC,uBAAuB,GAAG,SAAS,CAqBhD,CAAA"}
@@ -0,0 +1,24 @@
1
+ import { inject, onServerPrefetch, shallowRef, watch } from 'vue';
2
+ import { createAsyncApiSchemaResourceResolver, } from './async-api-schema-resources/resolver.js';
3
+ /** Share the current document's authenticated loader and cache across expanded native schemas. */
4
+ export const ASYNC_API_SCHEMA_RESOURCES = Symbol('async-api-schema-resources');
5
+ /** This scope is mounted by expanded message/model slots, so collapsed schemas never fetch. */
6
+ export const useAsyncApiSchemaResources = (input) => {
7
+ const fallback = createAsyncApiSchemaResourceResolver();
8
+ const resolver = inject(ASYNC_API_SCHEMA_RESOURCES, () => fallback);
9
+ const resolved = shallowRef();
10
+ let pending;
11
+ watch(input, ({ format, value, resources }, _old, onCleanup) => {
12
+ let current = true;
13
+ onCleanup(() => {
14
+ current = false;
15
+ });
16
+ resolved.value = resources?.deferred ? undefined : resources;
17
+ pending = resolver()(format, value, resources).then((result) => {
18
+ if (current)
19
+ resolved.value = result;
20
+ });
21
+ }, { immediate: true, deep: true, flush: 'sync' });
22
+ onServerPrefetch(() => pending);
23
+ return resolved;
24
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/parameters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAOrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAmClD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB,aACzB,iBAAiB,GAAG,IAAI,8CACU,eAAe,CAAC,4BAA4B,CAAC,SA4H1F,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,8BAA8B,aAC/B,iBAAiB,GAAG,IAAI,yCACK,eAAe,CAAC,mCAAmC,CAAC,SA8C5F,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,aACzB,iBAAiB,GAAG,IAAI,+BACL,eAAe,CAAC,4BAA4B,CAAC,SAkC3E,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,aAC7B,iBAAiB,GAAG,IAAI,kBAClB,eAAe,CAAC,iCAAiC,CAAC,SAgBnE,CAAA"}
1
+ {"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/parameters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAOrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAmClD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB,aACzB,iBAAiB,GAAG,IAAI,8CACU,eAAe,CAAC,4BAA4B,CAAC,SAoI1F,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,8BAA8B,aAC/B,iBAAiB,GAAG,IAAI,yCACK,eAAe,CAAC,mCAAmC,CAAC,SA8C5F,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,aACzB,iBAAiB,GAAG,IAAI,+BACL,eAAe,CAAC,4BAA4B,CAAC,SAkC3E,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,aAC7B,iBAAiB,GAAG,IAAI,kBAClB,eAAe,CAAC,iCAAiC,CAAC,SAgBnE,CAAA"}
@@ -44,7 +44,15 @@ const getPathItemsForParameterMutation = (pathItemRef) => {
44
44
  export const upsertOperationParameter = (document, { meta, type, payload, originalParameter }) => {
45
45
  // We are editing an existing parameter
46
46
  if (originalParameter) {
47
- const querystring = getQuerystringParameter(originalParameter, meta.exampleKey, { includeDisabled: true });
47
+ const querystring = getQuerystringParameter(originalParameter, meta.exampleKey, {
48
+ includeDisabled: true,
49
+ ...(isOpenApiDocument(document)
50
+ ? {
51
+ openapiVersion: document['x-original-oas-version'] || document.openapi,
52
+ jsonSchemaDialect: document.jsonSchemaDialect,
53
+ }
54
+ : {}),
55
+ });
48
56
  const preserveQuerystringValue = querystring && payload.value === serializeQuerystringParameter(querystring);
49
57
  const param = originalParameter;
50
58
  const selected = getParameterExample(param, meta.exampleKey);
@@ -1 +1 @@
1
- {"version":3,"file":"reset-request-body.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/reset-request-body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAgBrE,0FAA0F;AAC1F,eAAO,MAAM,yBAAyB,UAC7B,cAAc,GAAG,IAAI,yFAOzB,eAAe,CAAC,6BAA6B,CAAC,KAChD,OAAO,CAAC,IAAI,CAqHd,CAAA"}
1
+ {"version":3,"file":"reset-request-body.d.ts","sourceRoot":"","sources":["../../../src/mutators/operation/reset-request-body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAgBrE,0FAA0F;AAC1F,eAAO,MAAM,yBAAyB,UAC7B,cAAc,GAAG,IAAI,yFAOzB,eAAe,CAAC,6BAA6B,CAAC,KAChD,OAAO,CAAC,IAAI,CA8Hd,CAAA"}
@@ -22,7 +22,9 @@ export const resetOperationRequestBody = async (store, { documentName, meta, con
22
22
  const originalExample = originalBody && getExample(originalBody, meta.exampleKey, contentType);
23
23
  const restored = getExampleValue(originalExample) || originalExample?.externalValue
24
24
  ? snapshotSchema(originalExample)
25
- : { value: getSchemaExampleFromBody(body, contentType, requestBodyCompositionSelection, openapiVersion) ?? '' };
25
+ : {
26
+ value: getSchemaExampleFromBody(body, contentType, requestBodyCompositionSelection, openapiVersion ?? (document['x-original-oas-version'] || document.openapi), document.jsonSchemaDialect) ?? '',
27
+ };
26
28
  // Loading a baseline can resolve remote references. Do not discard typing that happened while
27
29
  // it loaded, or write into a document that has since been replaced or removed.
28
30
  if (store.workspace.documents[documentName] !== document ||
@@ -0,0 +1,10 @@
1
+ import type { XBadge } from '../../schemas/extensions/operation/x-badge.js';
2
+ /**
3
+ * Reads the `x-badges` extension of an OpenAPI object (operation, tag, tag group or schema)
4
+ * for the navigation entry of that object.
5
+ *
6
+ * Badges without a name are dropped, and so are fields with an invalid value.
7
+ * Returns `undefined` when no badge is left, so the entry can omit the key.
8
+ */
9
+ export declare const getXBadges: (object: unknown) => XBadge[] | undefined;
10
+ //# sourceMappingURL=get-x-badges.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-x-badges.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/get-x-badges.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAA;AAEpE;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,WAAY,OAAO,KAAG,MAAM,EAAE,GAAG,SAoBvD,CAAA"}
@@ -0,0 +1,26 @@
1
+ import { isObject } from '@scalar/helpers/object/is-object';
2
+ /**
3
+ * Reads the `x-badges` extension of an OpenAPI object (operation, tag, tag group or schema)
4
+ * for the navigation entry of that object.
5
+ *
6
+ * Badges without a name are dropped, and so are fields with an invalid value.
7
+ * Returns `undefined` when no badge is left, so the entry can omit the key.
8
+ */
9
+ export const getXBadges = (object) => {
10
+ if (!isObject(object) || !Array.isArray(object['x-badges'])) {
11
+ return undefined;
12
+ }
13
+ const badges = object['x-badges'].flatMap((badge) => {
14
+ if (!isObject(badge) || typeof badge.name !== 'string' || badge.name === '') {
15
+ return [];
16
+ }
17
+ return [
18
+ {
19
+ name: badge.name,
20
+ ...(badge.position === 'before' || badge.position === 'after' ? { position: badge.position } : {}),
21
+ ...(typeof badge.color === 'string' ? { color: badge.color } : {}),
22
+ },
23
+ ];
24
+ });
25
+ return badges.length ? badges : undefined;
26
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"traverse-paths.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-paths.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE5F,OAAO,KAAK,EAA+B,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAK9F,eAAO,MAAM,qBAAqB,cAAe,eAAe,YAE/D,CAAA;AAsED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa,yEAMvB;IACD,QAAQ,EAAE,eAAe,CAAA;IACzB,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAA;IAChB,0DAA0D;IAC1D,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAA;IAC7C,kBAAkB;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,oFAAoF;IACpF,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;CAC5C,KAAG;IAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAA;CA2D7C,CAAA"}
1
+ {"version":3,"file":"traverse-paths.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-paths.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE5F,OAAO,KAAK,EAA+B,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAK9F,eAAO,MAAM,qBAAqB,cAAe,eAAe,YAE/D,CAAA;AAwED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa,yEAMvB;IACD,QAAQ,EAAE,eAAe,CAAA;IACzB,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAA;IAChB,0DAA0D;IAC1D,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAA;IAC7C,kBAAkB;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,oFAAoF;IACpF,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;CAC5C,KAAG;IAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAA;CA2D7C,CAAA"}
@@ -3,6 +3,7 @@ import { forEachPathItemOperation, getPathItemOperationKey } from '../../helpers
3
3
  import { getPathEntries } from '../../helpers/get-path-entries.js';
4
4
  import { getResolvedRef, mergeSiblingReferences } from '../../helpers/get-resolved-ref.js';
5
5
  import { isHidden } from '../../helpers/is-hidden.js';
6
+ import { getXBadges } from './get-x-badges.js';
6
7
  import { traverseOperationExamples } from './traverse-examples.js';
7
8
  import { XScalarStabilityValues } from '../../schemas/extensions/operation/index.js';
8
9
  import { getNavigationTagNames } from './get-navigation-tag-names.js';
@@ -33,6 +34,7 @@ const createOperationEntry = ({ ref, operation, method, path, generateId, parent
33
34
  });
34
35
  const title = operationTitleSource !== 'path' && operation.summary?.trim() ? operation.summary : path;
35
36
  const isDeprecated = isDeprecatedOperation(operation);
37
+ const badges = getXBadges(operation);
36
38
  const examples = traverseOperationExamples(operation).map((example) => ({
37
39
  type: 'example',
38
40
  id: generateId({
@@ -51,6 +53,7 @@ const createOperationEntry = ({ ref, operation, method, path, generateId, parent
51
53
  ref,
52
54
  type: 'operation',
53
55
  isDeprecated,
56
+ ...(badges ? { badges } : {}),
54
57
  children: examples.length ? examples : undefined,
55
58
  };
56
59
  return entry;
@@ -1 +1 @@
1
- {"version":3,"file":"traverse-schemas.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-schemas.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,KAAK,EAAa,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,wCAAwC,CAAA;AA2C3F;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,mDAKzB;IACD,QAAQ,EAAE,eAAe,CAAA;IACzB,wCAAwC;IACxC,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAA;IAC7C,UAAU,EAAE,MAAM,CAAA;CACnB,KAAG,eAAe,EAmDlB,CAAA"}
1
+ {"version":3,"file":"traverse-schemas.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-schemas.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,KAAK,EAAa,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,wCAAwC,CAAA;AA6C3F;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,mDAKzB;IACD,QAAQ,EAAE,eAAe,CAAA;IACzB,wCAAwC;IACxC,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAA;IAC7C,UAAU,EAAE,MAAM,CAAA;CACnB,KAAG,eAAe,EAmDlB,CAAA"}
@@ -3,6 +3,7 @@ import { getResolvedRef, mergeSiblingReferences } from '../../helpers/get-resolv
3
3
  import { isHidden } from '../../helpers/is-hidden.js';
4
4
  import { getNavigationTagNames } from './get-navigation-tag-names.js';
5
5
  import { getTag } from './get-tag.js';
6
+ import { getXBadges } from './get-x-badges.js';
6
7
  /** Creates a traversed schema entry from an OpenAPI schema object.
7
8
  *
8
9
  * @param ref - JSON pointer reference to the schema in the OpenAPI document
@@ -17,12 +18,14 @@ const createSchemaEntry = ({ ref, name, generateId, parentTag, _schema, parentId
17
18
  // Use schema.title if available, otherwise fall back to name
18
19
  // @see https://json-schema.org/draft/2020-12/json-schema-core#section-4.3.5
19
20
  const title = (isObject(schema) && 'title' in schema && schema.title) || name;
21
+ const badges = getXBadges(schema);
20
22
  const entry = {
21
23
  id,
22
24
  title,
23
25
  name,
24
26
  ref,
25
27
  type: 'model',
28
+ ...(badges ? { badges } : {}),
26
29
  };
27
30
  return entry;
28
31
  };
@@ -1 +1 @@
1
- {"version":3,"file":"traverse-tags.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-tags.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,sBAAsB,CAAA;AACxE,OAAO,KAAK,EAAE,eAAe,EAAa,MAAM,wCAAwC,CAAA;AAIxF,KAAK,OAAO,GAAG,IAAI,CAAC,mBAAmB,EAAE,YAAY,GAAG,kBAAkB,GAAG,YAAY,CAAC,CAAA;AAqS1F;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,8FAKtB;IACD,QAAQ,EAAE,eAAe,CAAA;IACzB,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;CACjB,KAAG,cAAc,EAuEjB,CAAA"}
1
+ {"version":3,"file":"traverse-tags.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-tags.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,sBAAsB,CAAA;AACxE,OAAO,KAAK,EAAE,eAAe,EAAa,MAAM,wCAAwC,CAAA;AAIxF,KAAK,OAAO,GAAG,IAAI,CAAC,mBAAmB,EAAE,YAAY,GAAG,kBAAkB,GAAG,YAAY,CAAC,CAAA;AAuS1F;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,8FAKtB;IACD,QAAQ,EAAE,eAAe,CAAA;IACzB,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;CACjB,KAAG,cAAc,EAuEjB,CAAA"}
@@ -3,6 +3,7 @@ import { getTagKind } from '../../helpers/get-tag-kind.js';
3
3
  import { isHidden } from '../../helpers/is-hidden.js';
4
4
  import { unpackProxyObject } from '../../helpers/unpack-proxy.js';
5
5
  import { getTagExternalDocs } from './get-tag-external-docs.js';
6
+ import { getXBadges } from './get-x-badges.js';
6
7
  import { getXKeysFromObject } from './get-x-keys.js';
7
8
  import { getTag } from './get-tag.js';
8
9
  /** Creates a traversed tag entry from an OpenAPI tag object.
@@ -24,6 +25,7 @@ const createTagEntry = ({ tag, generateId, children, isGroup = false, isTagGroup
24
25
  });
25
26
  // `summary` is the OpenAPI 3.2 display label; `x-displayName` keeps precedence for backwards compatibility.
26
27
  const externalDocs = getTagExternalDocs(tag);
28
+ const badges = getXBadges(tag);
27
29
  const title = tag['x-displayName'] ?? tag.summary ?? tag.name ?? 'Untitled Tag';
28
30
  // Update the order of the children based on the items
29
31
  // This will ensure that the sort order is always in sync with the items
@@ -40,6 +42,7 @@ const createTagEntry = ({ tag, generateId, children, isGroup = false, isTagGroup
40
42
  // Real OpenAPI 3.2 nested-tag sections keep this unset and render their summary heading.
41
43
  ...(isTagGroup ? { isTagGroup: true } : {}),
42
44
  isWebhooks: false,
45
+ ...(badges ? { badges } : {}),
43
46
  type: 'tag',
44
47
  xKeys: getXKeysFromObject(unpackProxyObject(tag)),
45
48
  };
@@ -1 +1 @@
1
- {"version":3,"file":"traverse-webhooks.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-webhooks.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,KAAK,EAAa,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAA8B,MAAM,wCAAwC,CAAA;AA4DzG;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,6EAM1B;IACD,uBAAuB;IACvB,QAAQ,EAAE,eAAe,CAAA;IACzB,6CAA6C;IAC7C,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAA;IAC7C,wBAAwB,EAAE,MAAM,CAAA;IAChC,UAAU,EAAE,MAAM,CAAA;CACnB,KAAG,gBAAgB,EAwDnB,CAAA"}
1
+ {"version":3,"file":"traverse-webhooks.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-webhooks.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,KAAK,EAAa,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAA8B,MAAM,wCAAwC,CAAA;AA8DzG;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,6EAM1B;IACD,uBAAuB;IACvB,QAAQ,EAAE,eAAe,CAAA;IACzB,6CAA6C;IAC7C,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAA;IAC7C,wBAAwB,EAAE,MAAM,CAAA;IAChC,UAAU,EAAE,MAAM,CAAA;CACnB,KAAG,gBAAgB,EAwDnB,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import { forEachPathItemOperation, getPathItemOperationKey } from '../../helpers/for-each-path-item-operation.js';
2
2
  import { getResolvedRef, mergeSiblingReferences } from '../../helpers/get-resolved-ref.js';
3
3
  import { isHidden } from '../../helpers/is-hidden.js';
4
+ import { getXBadges } from './get-x-badges.js';
4
5
  import { isDeprecatedOperation } from './traverse-paths.js';
5
6
  import { getNavigationTagNames } from './get-navigation-tag-names.js';
6
7
  import { getTag } from './get-tag.js';
@@ -24,6 +25,7 @@ const createWebhookEntry = ({ ref, method, name, title, generateId, parentTag, w
24
25
  parentTag,
25
26
  parentId: parentId,
26
27
  });
28
+ const badges = getXBadges(webhook);
27
29
  const entry = {
28
30
  id,
29
31
  title,
@@ -32,6 +34,7 @@ const createWebhookEntry = ({ ref, method, name, title, generateId, parentTag, w
32
34
  method: method,
33
35
  type: 'webhook',
34
36
  isDeprecated,
37
+ ...(badges ? { badges } : {}),
35
38
  };
36
39
  return entry;
37
40
  };
@@ -0,0 +1,4 @@
1
+ import type { LifecyclePlugin } from '@scalar/json-magic/bundle';
2
+ /** Defer native dependencies only at real AsyncAPI schema wrappers, never inside examples or extensions. */
3
+ export declare const asyncApiSchemaResources: () => LifecyclePlugin;
4
+ //# sourceMappingURL=async-api-schema-resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-api-schema-resources.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/async-api-schema-resources.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAIhE,4GAA4G;AAC5G,eAAO,MAAM,uBAAuB,QAAO,eAc1C,CAAA"}
@@ -0,0 +1,20 @@
1
+ import { isObject } from '@scalar/helpers/object/is-object';
2
+ import { deferSchemaResources } from '../../helpers/async-api-schema-resources/resources.js';
3
+ /** Defer native dependencies only at real AsyncAPI schema wrappers, never inside examples or extensions. */
4
+ export const asyncApiSchemaResources = () => {
5
+ return {
6
+ type: 'lifecycle',
7
+ onBeforeNodeProcess: (node, context) => {
8
+ if (context.referenceContext !== 'asyncapi-schema' || typeof node.schemaFormat !== 'string' || '$ref' in node)
9
+ return;
10
+ // Completed server graphs stay portable. Deferred metadata must use the actual containing file,
11
+ // since its origin controls future downloads and may have been supplied by the document author.
12
+ const existing = node['x-scalar-schema-resources'];
13
+ if (existing !== undefined && !(isObject(existing) && existing.deferred === true))
14
+ return;
15
+ const resources = deferSchemaResources(node.schemaFormat, context.origin);
16
+ if (resources)
17
+ node['x-scalar-schema-resources'] = resources;
18
+ },
19
+ };
20
+ };
@@ -90,7 +90,7 @@ export declare const normalizeAuthSchemes: () => LifecyclePlugin;
90
90
  /**
91
91
  * Lifecycle plugin to normalize $ref nodes:
92
92
  * Ensures that for any OpenAPI Reference Object containing a $ref, only $ref,
93
- * summary, description, and $status properties are preserved.
93
+ * summary, description, $status, and $global properties are preserved.
94
94
  * This keeps $ref references clean and predictable for downstream consumers.
95
95
  *
96
96
  * Schema Objects are deliberately skipped: in JSON Schema 2020-12 a $ref may
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,KAAK,eAAe,EAAwB,MAAM,2BAA2B,CAAA;AAStF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAO,eAahC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,aAAc;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,KAAG,eA6CpE,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,QAAO,eAwCjC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,mBAAmB,QAAO,eA6BtC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,oBAAoB,QAAO,eAuBvC,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,QAAO,eAyBhC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,QAAO,eAmFrC,CAAA;AAKD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAO,eAaxC,CAAA;AAED,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,KAAK,eAAe,EAAwB,MAAM,2BAA2B,CAAA;AAStF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAO,eAahC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,aAAc;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,KAAG,eA6CpE,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,QAAO,eAwCjC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,mBAAmB,QAAO,eA6BtC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,oBAAoB,QAAO,eAuBvC,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,QAAO,eAyBhC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,QAAO,eAmFrC,CAAA;AAKD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAO,eAexC,CAAA;AAED,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA"}
@@ -221,7 +221,7 @@ export const normalizeAuthSchemes = () => {
221
221
  /**
222
222
  * Lifecycle plugin to normalize $ref nodes:
223
223
  * Ensures that for any OpenAPI Reference Object containing a $ref, only $ref,
224
- * summary, description, and $status properties are preserved.
224
+ * summary, description, $status, and $global properties are preserved.
225
225
  * This keeps $ref references clean and predictable for downstream consumers.
226
226
  *
227
227
  * Schema Objects are deliberately skipped: in JSON Schema 2020-12 a $ref may
@@ -240,8 +240,8 @@ export const normalizeRefs = () => {
240
240
  // and in raw external schema documents. Stripping those siblings would discard the binding and leave
241
241
  // `$dynamicRef` resolving to the template's empty fallback. See https://github.com/scalar/scalar/issues/9414.
242
242
  if (typeof node['$ref'] === 'string' && !isSchema) {
243
- // Remove any other properties from the node and only keep the '$ref', 'summary', 'description' and '$status'
244
- const keepProperties = new Set(['$ref', 'summary', 'description', '$status']);
243
+ // Keep the server chunk marker so reloads retain the owning document's dialect and media types.
244
+ const keepProperties = new Set(['$ref', 'summary', 'description', '$status', '$global']);
245
245
  Object.keys(node).forEach((key) => {
246
246
  if (!keepProperties.has(key)) {
247
247
  delete node[key];
@@ -331,8 +331,11 @@ const NESTED_INTERNAL_KEYS = ['__scalar_', '$status'];
331
331
  export const removeExtraScalarKeys = () => {
332
332
  return {
333
333
  type: 'lifecycle',
334
- onBeforeNodeProcess: (node) => {
334
+ onBeforeNodeProcess: (node, context) => {
335
335
  if (isObject(node)) {
336
+ // Authored edits must reload native dependencies; workspace snapshots retain their prepared graphs.
337
+ if (context.referenceContext === 'asyncapi-schema')
338
+ delete node['x-scalar-schema-resources'];
336
339
  for (const key of NESTED_INTERNAL_KEYS) {
337
340
  if (key in node) {
338
341
  delete node[key];
@@ -2,5 +2,9 @@ import { type DocumentResolver, type LifecyclePlugin } from '@scalar/json-magic/
2
2
  /** Resolves an OpenAPI document's declared identity against its retrieval location. */
3
3
  export declare const resolveOpenApiDocument: DocumentResolver;
4
4
  /** Honors `$self` for complete OpenAPI documents, including external and cached documents. */
5
- export declare const openApiDocument: () => LifecyclePlugin;
5
+ export declare const openApiDocument: (options?: {
6
+ preserveOriginalRefs?: boolean;
7
+ /** The caller already supplies the node location within the complete bundle. */
8
+ useContextPath?: boolean;
9
+ }) => LifecyclePlugin;
6
10
  //# sourceMappingURL=openapi-document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openapi-document.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/openapi-document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAwB,MAAM,2BAA2B,CAAA;AAI7G,uFAAuF;AACvF,eAAO,MAAM,sBAAsB,EAAE,gBASpC,CAAA;AAED,8FAA8F;AAC9F,eAAO,MAAM,eAAe,QAAO,eAwClC,CAAA"}
1
+ {"version":3,"file":"openapi-document.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/openapi-document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAwB,MAAM,2BAA2B,CAAA;AAI7G,uFAAuF;AACvF,eAAO,MAAM,sBAAsB,EAAE,gBASpC,CAAA;AAED,8FAA8F;AAC9F,eAAO,MAAM,eAAe,aAAc;IACxC,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,gFAAgF;IAChF,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,KAAG,eA4CH,CAAA"}
@@ -13,7 +13,7 @@ export const resolveOpenApiDocument = (document, retrievalUri) => {
13
13
  return { baseUri, metadata: { openapi: document.openapi, $self: self } };
14
14
  };
15
15
  /** Honors `$self` for complete OpenAPI documents, including external and cached documents. */
16
- export const openApiDocument = () => {
16
+ export const openApiDocument = (options) => {
17
17
  const authoredRefs = new WeakMap();
18
18
  const paths = new WeakMap();
19
19
  const indexPaths = (value, path) => {
@@ -29,10 +29,14 @@ export const openApiDocument = () => {
29
29
  type: 'lifecycle',
30
30
  resolveDocument: resolveOpenApiDocument,
31
31
  onBeforeNodeProcess: (node, context) => {
32
- if (typeof node.$ref === 'string' && resolveOpenApiDocument(context.rootNode, context.origin)) {
32
+ if (typeof node.$ref === 'string' &&
33
+ (options?.preserveOriginalRefs || resolveOpenApiDocument(context.rootNode, context.origin))) {
33
34
  // Partial bundles report paths relative to the selected subtree. Index the supplied root
34
35
  // so the saved references can also be restored when exporting the entire document.
35
- indexPaths(context.rootNode, []);
36
+ if (options?.useContextPath)
37
+ paths.set(node, context.path);
38
+ else
39
+ indexPaths(context.rootNode, []);
36
40
  authoredRefs.set(node, node.$ref);
37
41
  }
38
42
  },
@@ -0,0 +1,4 @@
1
+ import { type LifecyclePlugin } from '@scalar/json-magic/bundle';
2
+ /** Upgrade loaded resources at their source locations, before bundling hides them under x-ext. */
3
+ export declare const upgradeDocuments: (entryVersion?: unknown) => LifecyclePlugin;
4
+ //# sourceMappingURL=upgrade-documents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-documents.d.ts","sourceRoot":"","sources":["../../../src/plugins/bundler/upgrade-documents.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,eAAe,EAAwB,MAAM,2BAA2B,CAAA;AAsGtF,kGAAkG;AAClG,eAAO,MAAM,gBAAgB,kBAAmB,OAAO,KAAG,eAkSzD,CAAA"}