@scalar/workspace-store 0.72.0 → 0.74.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 (105) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +10 -0
  3. package/dist/client.d.ts +6 -0
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +96 -34
  6. package/dist/entities/auth/schema.d.ts +235 -40
  7. package/dist/entities/auth/schema.d.ts.map +1 -1
  8. package/dist/helpers/async-api-schema-resources/load-inline.d.ts +5 -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 +71 -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/resources.d.ts +10 -0
  18. package/dist/helpers/async-api-schema-resources/resources.d.ts.map +1 -0
  19. package/dist/helpers/async-api-schema-resources/resources.js +124 -0
  20. package/dist/helpers/async-api-schema-resources/schema-resource-path.d.ts +3 -0
  21. package/dist/helpers/async-api-schema-resources/schema-resource-path.d.ts.map +1 -0
  22. package/dist/helpers/async-api-schema-resources/schema-resource-path.js +9 -0
  23. package/dist/helpers/compact-upgrade-metadata.d.ts +3 -0
  24. package/dist/helpers/compact-upgrade-metadata.d.ts.map +1 -0
  25. package/dist/helpers/compact-upgrade-metadata.js +71 -0
  26. package/dist/helpers/is-file-schema.js +1 -1
  27. package/dist/helpers/querystring-parameter.d.ts +3 -1
  28. package/dist/helpers/querystring-parameter.d.ts.map +1 -1
  29. package/dist/helpers/querystring-parameter.js +2 -2
  30. package/dist/helpers/resolve-async-api-schema.d.ts +2 -0
  31. package/dist/helpers/resolve-async-api-schema.d.ts.map +1 -1
  32. package/dist/helpers/resolve-async-api-schema.js +23 -1
  33. package/dist/mutators/auth.d.ts.map +1 -1
  34. package/dist/mutators/operation/parameters.d.ts.map +1 -1
  35. package/dist/mutators/operation/parameters.js +9 -1
  36. package/dist/mutators/operation/reset-request-body.d.ts.map +1 -1
  37. package/dist/mutators/operation/reset-request-body.js +3 -1
  38. package/dist/navigation/helpers/traverse-plugin-document.d.ts +11 -0
  39. package/dist/navigation/helpers/traverse-plugin-document.d.ts.map +1 -0
  40. package/dist/navigation/helpers/traverse-plugin-document.js +24 -0
  41. package/dist/navigation/helpers/update-order-ids.d.ts.map +1 -1
  42. package/dist/navigation/helpers/update-order-ids.js +2 -1
  43. package/dist/navigation/index.d.ts +1 -0
  44. package/dist/navigation/index.d.ts.map +1 -1
  45. package/dist/navigation/index.js +1 -0
  46. package/dist/plugins/bundler/async-api-schema-resources.d.ts +4 -0
  47. package/dist/plugins/bundler/async-api-schema-resources.d.ts.map +1 -0
  48. package/dist/plugins/bundler/async-api-schema-resources.js +20 -0
  49. package/dist/plugins/bundler/index.d.ts +1 -1
  50. package/dist/plugins/bundler/index.d.ts.map +1 -1
  51. package/dist/plugins/bundler/index.js +7 -4
  52. package/dist/plugins/bundler/openapi-document.d.ts +5 -1
  53. package/dist/plugins/bundler/openapi-document.d.ts.map +1 -1
  54. package/dist/plugins/bundler/openapi-document.js +9 -7
  55. package/dist/plugins/bundler/upgrade-documents.d.ts +4 -0
  56. package/dist/plugins/bundler/upgrade-documents.d.ts.map +1 -0
  57. package/dist/plugins/bundler/upgrade-documents.js +357 -0
  58. package/dist/request-example/builder/body/build-request-body.d.ts +1 -1
  59. package/dist/request-example/builder/body/build-request-body.d.ts.map +1 -1
  60. package/dist/request-example/builder/body/build-request-body.js +2 -2
  61. package/dist/request-example/builder/body/get-request-body-example.d.ts +2 -2
  62. package/dist/request-example/builder/body/get-request-body-example.d.ts.map +1 -1
  63. package/dist/request-example/builder/body/get-request-body-example.js +7 -3
  64. package/dist/request-example/builder/helpers/array-contains.d.ts +15 -0
  65. package/dist/request-example/builder/helpers/array-contains.d.ts.map +1 -0
  66. package/dist/request-example/builder/helpers/array-contains.js +199 -0
  67. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts +6 -0
  68. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts.map +1 -1
  69. package/dist/request-example/builder/helpers/get-example-from-schema.js +30 -2
  70. package/dist/request-example/builder/request-factory.d.ts +3 -1
  71. package/dist/request-example/builder/request-factory.d.ts.map +1 -1
  72. package/dist/request-example/builder/request-factory.js +5 -3
  73. package/dist/schemas/navigation.d.ts +32 -1
  74. package/dist/schemas/navigation.d.ts.map +1 -1
  75. package/dist/schemas/navigation.js +7 -0
  76. package/dist/schemas/plugin-document.d.ts +67 -0
  77. package/dist/schemas/plugin-document.d.ts.map +1 -0
  78. package/dist/schemas/plugin-document.js +20 -0
  79. package/dist/schemas/reference-config/index.d.ts +47 -8
  80. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  81. package/dist/schemas/reference-config/settings.d.ts +47 -8
  82. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  83. package/dist/schemas/type-guards.d.ts +4 -2
  84. package/dist/schemas/type-guards.d.ts.map +1 -1
  85. package/dist/schemas/type-guards.js +7 -4
  86. package/dist/schemas/v3.1/strict/openapi-document.d.ts +1645 -280
  87. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  88. package/dist/schemas/v3.1/strict/schema.d.ts +62 -10
  89. package/dist/schemas/v3.1/strict/schema.d.ts.map +1 -1
  90. package/dist/schemas/v3.1/strict/schema.js +10 -2
  91. package/dist/schemas/v3.2/openapi/index.d.ts.map +1 -1
  92. package/dist/schemas/v3.2/openapi/index.js +5 -2
  93. package/dist/schemas/v3.2/strict/openapi-document.d.ts +1645 -280
  94. package/dist/schemas/v3.2/strict/openapi-document.d.ts.map +1 -1
  95. package/dist/schemas/v3.2/strict/schema.d.ts +62 -10
  96. package/dist/schemas/v3.2/strict/schema.d.ts.map +1 -1
  97. package/dist/schemas/v3.2/strict/schema.js +10 -2
  98. package/dist/schemas/workspace.d.ts +2 -1
  99. package/dist/schemas/workspace.d.ts.map +1 -1
  100. package/dist/schemas.d.ts +1 -0
  101. package/dist/schemas.d.ts.map +1 -1
  102. package/dist/schemas.js +1 -0
  103. package/dist/server.d.ts.map +1 -1
  104. package/dist/server.js +33 -3
  105. package/package.json +17 -16
@@ -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,11 @@
1
+ import { type NavigationOptions } from '../get-navigation-options.js';
2
+ import type { TraversedDocument } from '../../schemas/navigation.js';
3
+ import type { DocumentTypeDefinition, PluginDocument } from '../../schemas/plugin-document.js';
4
+ /**
5
+ * Build the navigation root for a document claimed by a registered document type.
6
+ *
7
+ * The root entry (id, title, icon) follows the same conventions as OpenAPI and AsyncAPI documents so the
8
+ * sidebar, document selector and deep links treat it the same way; the children come from the type.
9
+ */
10
+ export declare const traversePluginDocument: (documentName: string, document: PluginDocument, documentType: DocumentTypeDefinition, options?: NavigationOptions) => TraversedDocument;
11
+ //# sourceMappingURL=traverse-plugin-document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traverse-plugin-document.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/traverse-plugin-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAwB,MAAM,qCAAqC,CAAA;AAClG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAEvF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,iBACnB,MAAM,YACV,cAAc,gBACV,sBAAsB,YAC1B,iBAAiB,KAC1B,iBAkBF,CAAA"}
@@ -0,0 +1,24 @@
1
+ import { getNavigationOptions } from '../get-navigation-options.js';
2
+ /**
3
+ * Build the navigation root for a document claimed by a registered document type.
4
+ *
5
+ * The root entry (id, title, icon) follows the same conventions as OpenAPI and AsyncAPI documents so the
6
+ * sidebar, document selector and deep links treat it the same way; the children come from the type.
7
+ */
8
+ export const traversePluginDocument = (documentName, document, documentType, options) => {
9
+ const { generateId } = getNavigationOptions(documentName, options);
10
+ const title = document.info.title?.trim() || 'Untitled Document';
11
+ const documentId = generateId({
12
+ type: 'document',
13
+ info: { title, version: document.info.version ?? '' },
14
+ name: documentName,
15
+ });
16
+ return {
17
+ id: documentId,
18
+ type: 'document',
19
+ title,
20
+ name: documentName,
21
+ children: documentType.traverse({ documentName, documentId, document }),
22
+ icon: document['x-scalar-icon'],
23
+ };
24
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"update-order-ids.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/update-order-ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAG9C,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEvH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAEtE,KAAK,mBAAmB,GAAG;IACzB,KAAK,EAAE,cAAc,CAAA;IACrB,UAAU,EAAE,WAAW,CAAA;CACxB,GAAG,CACA;IACE,8DAA8D;IAC9D,OAAO,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAA;IAC1E,SAAS,EAAE,eAAe,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb,GACD;IACE,6CAA6C;IAC7C,OAAO,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,CAAA;IACnC,GAAG,EAAE,SAAS,CAAA;CACf,CACJ,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,mCAAoC,mBAAmB,SAiEjF,CAAA"}
1
+ {"version":3,"file":"update-order-ids.d.ts","sourceRoot":"","sources":["../../../src/navigation/helpers/update-order-ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAG9C,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAGvH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAEtE,KAAK,mBAAmB,GAAG;IACzB,KAAK,EAAE,cAAc,CAAA;IACrB,UAAU,EAAE,WAAW,CAAA;CACxB,GAAG,CACA;IACE,8DAA8D;IAC9D,OAAO,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAA;IAC1E,SAAS,EAAE,eAAe,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb,GACD;IACE,6CAA6C;IAC7C,OAAO,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,CAAA;IACnC,GAAG,EAAE,SAAS,CAAA;CACf,CACJ,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,mCAAoC,mBAAmB,SAiEjF,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { canHaveOrder, getOpenapiObject } from './get-openapi-object.js';
2
2
  import { getParentEntry } from './get-parent-entry.js';
3
+ import { isPluginDocument } from '../../schemas/plugin-document.js';
3
4
  import { isOpenApiDocument } from '../../schemas/type-guards.js';
4
5
  /**
5
6
  * Updates the order ID of an entry (operation or tag) in the sidebar.
@@ -50,7 +51,7 @@ export const updateOrderIds = ({ store, generateId, ...rest }) => {
50
51
  return;
51
52
  }
52
53
  // Operation/webhook entries: generate a new operation ID with the updated path and method
53
- const parentTag = entry.parent.type === 'tag' && 'name' in parentOpenAPIObject
54
+ const parentTag = entry.parent.type === 'tag' && 'name' in parentOpenAPIObject && !isPluginDocument(parentOpenAPIObject)
54
55
  ? { tag: parentOpenAPIObject, id: entry.parent.id }
55
56
  : undefined;
56
57
  order[index] = generateId({
@@ -5,5 +5,6 @@ export { type TagEntriesMap, getTagEntries } from './helpers/get-tag-entries.js'
5
5
  export { traverseAsyncApiDocument } from './helpers/traverse-asyncapi-document.js';
6
6
  export { traverseDocument as createNavigation } from './helpers/traverse-document.js';
7
7
  export { getUniqueExampleName } from './helpers/traverse-examples.js';
8
+ export { traversePluginDocument } from './helpers/traverse-plugin-document.js';
8
9
  export type { TraverseSpecOptions as createNavigationOptions } from './types.js';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/navigation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,EAAE,KAAK,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,KAAK,aAAa,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAA;AAC/E,OAAO,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAClE,YAAY,EAAE,mBAAmB,IAAI,uBAAuB,EAAE,MAAM,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/navigation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,EAAE,KAAK,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,KAAK,aAAa,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAA;AAC/E,OAAO,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAA;AAC3E,YAAY,EAAE,mBAAmB,IAAI,uBAAuB,EAAE,MAAM,SAAS,CAAA"}
@@ -5,3 +5,4 @@ export { getTagEntries } from './helpers/get-tag-entries.js';
5
5
  export { traverseAsyncApiDocument } from './helpers/traverse-asyncapi-document.js';
6
6
  export { traverseDocument as createNavigation } from './helpers/traverse-document.js';
7
7
  export { getUniqueExampleName } from './helpers/traverse-examples.js';
8
+ export { traversePluginDocument } from './helpers/traverse-plugin-document.js';
@@ -0,0 +1,4 @@
1
+ import type { LifecyclePlugin } from '@scalar/json-magic/bundle';
2
+ /** Load 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":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAIhE,2GAA2G;AAC3G,eAAO,MAAM,uBAAuB,QAAO,eAe1C,CAAA"}
@@ -0,0 +1,20 @@
1
+ import { createSchemaResourceLoader } from '../../helpers/async-api-schema-resources/resources.js';
2
+ /** Load native dependencies only at real AsyncAPI schema wrappers, never inside examples or extensions. */
3
+ export const asyncApiSchemaResources = () => {
4
+ const load = createSchemaResourceLoader();
5
+ return {
6
+ type: 'lifecycle',
7
+ onBeforeNodeProcess: async (node, context) => {
8
+ if (context.referenceContext !== 'asyncapi-schema' || typeof node.schemaFormat !== 'string' || '$ref' in node)
9
+ return;
10
+ // Serialized workspace/SSR graphs carry their origin through relocation. Authored copies are inert
11
+ // data: readers validate and bound them, no credentials or loader capabilities are restored here.
12
+ // Editable-document cleanup removes these graphs before an authored change is ingested again.
13
+ if (node['x-scalar-schema-resources'] !== undefined)
14
+ return;
15
+ const resources = await load(node.schemaFormat, node.schema, context.origin, context.loaders);
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;AAE7G,uFAAuF;AACvF,eAAO,MAAM,sBAAsB,EAAE,gBAcpC,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"}
@@ -1,11 +1,9 @@
1
1
  import { isObject } from '@scalar/helpers/object/is-object';
2
2
  import { resolveReferencePath } from '@scalar/json-magic/bundle';
3
+ import { isOpenApiDocument } from '../../schemas/type-guards.js';
3
4
  /** Resolves an OpenAPI document's declared identity against its retrieval location. */
4
5
  export const resolveOpenApiDocument = (document, retrievalUri) => {
5
- if (!isObject(document) ||
6
- typeof document.openapi !== 'string' ||
7
- !/^3\.2\.\d+$/.test(document.openapi) ||
8
- typeof document.$self !== 'string') {
6
+ if (!isOpenApiDocument(document) || !/^3\.2\.\d+$/.test(document.openapi) || typeof document.$self !== 'string') {
9
7
  return undefined;
10
8
  }
11
9
  const self = resolveReferencePath(retrievalUri, document.$self);
@@ -15,7 +13,7 @@ export const resolveOpenApiDocument = (document, retrievalUri) => {
15
13
  return { baseUri, metadata: { openapi: document.openapi, $self: self } };
16
14
  };
17
15
  /** Honors `$self` for complete OpenAPI documents, including external and cached documents. */
18
- export const openApiDocument = () => {
16
+ export const openApiDocument = (options) => {
19
17
  const authoredRefs = new WeakMap();
20
18
  const paths = new WeakMap();
21
19
  const indexPaths = (value, path) => {
@@ -31,10 +29,14 @@ export const openApiDocument = () => {
31
29
  type: 'lifecycle',
32
30
  resolveDocument: resolveOpenApiDocument,
33
31
  onBeforeNodeProcess: (node, context) => {
34
- if (typeof node.$ref === 'string' && resolveOpenApiDocument(context.rootNode, context.origin)) {
32
+ if (typeof node.$ref === 'string' &&
33
+ (options?.preserveOriginalRefs || resolveOpenApiDocument(context.rootNode, context.origin))) {
35
34
  // Partial bundles report paths relative to the selected subtree. Index the supplied root
36
35
  // so the saved references can also be restored when exporting the entire document.
37
- indexPaths(context.rootNode, []);
36
+ if (options?.useContextPath)
37
+ paths.set(node, context.path);
38
+ else
39
+ indexPaths(context.rootNode, []);
38
40
  authoredRefs.set(node, node.$ref);
39
41
  }
40
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"}
@@ -0,0 +1,357 @@
1
+ import { parseJsonPointerSegments } from '@scalar/helpers/json/parse-json-pointer-segments';
2
+ import { isObject } from '@scalar/helpers/object/is-object';
3
+ import { isSchemaPath } from '@scalar/helpers/openapi/is-schema-path';
4
+ import { resolveReferencePath } from '@scalar/json-magic/bundle';
5
+ import { getHash, uniqueValueGeneratorFactory } from '@scalar/json-magic/bundle/value-generator';
6
+ import { getValueByPath } from '@scalar/json-magic/helpers/get-value-by-path';
7
+ import { upgradeFragment } from '@scalar/openapi-upgrader';
8
+ import { openApiDocument, resolveOpenApiDocument } from './openapi-document.js';
9
+ const metadataKey = 'x-scalar-upgrade';
10
+ const sourceVersion = (value) => {
11
+ if (value === '2.0') {
12
+ return '2.0';
13
+ }
14
+ if (value === '3.0') {
15
+ return '3.0';
16
+ }
17
+ if (typeof value === 'string' && /^3\.0\.\d+$/.test(value)) {
18
+ return '3.0';
19
+ }
20
+ return undefined;
21
+ };
22
+ const metadataCache = new WeakMap();
23
+ const metadata = (document) => {
24
+ if (!isObject(document) || !isObject(document[metadataKey])) {
25
+ return undefined;
26
+ }
27
+ const entry = document[metadataKey];
28
+ if (metadataCache.has(entry)) {
29
+ return metadataCache.get(entry);
30
+ }
31
+ const from = sourceVersion(entry.from);
32
+ const locations = Array.isArray(entry.locations)
33
+ ? entry.locations.filter((location) => isObject(location) &&
34
+ Array.isArray(location.source) &&
35
+ Array.isArray(location.output) &&
36
+ location.source.every((part) => typeof part === 'string') &&
37
+ location.output.every((part) => typeof part === 'string'))
38
+ : undefined;
39
+ const pointers = new Map();
40
+ for (const location of locations ?? []) {
41
+ const key = JSON.stringify(location.source);
42
+ if (!pointers.has(key)) {
43
+ pointers.set(key, location.output);
44
+ }
45
+ }
46
+ const result = from && locations ? { from, locations, pointers } : undefined;
47
+ metadataCache.set(entry, result);
48
+ return result;
49
+ };
50
+ const pointerSegments = (fragment) => {
51
+ let decoded = fragment;
52
+ try {
53
+ decoded = decodeURIComponent(fragment);
54
+ }
55
+ catch {
56
+ /* Retain legacy literal percent characters. */
57
+ }
58
+ // The shared helper decodes URI escapes too; protect literal percent signs from a second decode.
59
+ return decoded.startsWith('/') ? parseJsonPointerSegments(decoded.replaceAll('%', '%25')) : [];
60
+ };
61
+ const atPath = (value, path) => getValueByPath(value, [...path]).value;
62
+ const stringArray = (value) => Array.isArray(value) && value.every((part) => typeof part === 'string');
63
+ const fragmentKind = (path) => {
64
+ if (isSchemaPath([...path])) {
65
+ return 'schema';
66
+ }
67
+ if (path.at(-2) === 'callbacks') {
68
+ return 'callback';
69
+ }
70
+ if (path.at(-3) === 'callbacks') {
71
+ return 'path-item';
72
+ }
73
+ if (path.at(-2) === 'parameters') {
74
+ return 'parameter';
75
+ }
76
+ if (path.at(-2) === 'headers') {
77
+ return 'header';
78
+ }
79
+ if (path.at(-2) === 'responses') {
80
+ return 'response';
81
+ }
82
+ if (path.at(-1) === 'requestBody' || path.at(-2) === 'requestBodies') {
83
+ return 'request-body';
84
+ }
85
+ if (path.at(-2) === 'paths' || path.at(-2) === 'pathItems' || path.at(-2) === 'webhooks') {
86
+ return 'path-item';
87
+ }
88
+ return undefined;
89
+ };
90
+ /** Upgrade loaded resources at their source locations, before bundling hides them under x-ext. */
91
+ export const upgradeDocuments = (entryVersion) => {
92
+ const sources = new Map();
93
+ let entryUri;
94
+ const resolvers = new Map();
95
+ const converted = new WeakSet();
96
+ const transformedReferences = new WeakSet();
97
+ const originalReferences = openApiDocument({ preserveOriginalRefs: true, useContextPath: true });
98
+ const markConverted = (value) => {
99
+ if (value === null || typeof value !== 'object' || converted.has(value)) {
100
+ return;
101
+ }
102
+ converted.add(value);
103
+ Object.values(value).forEach(markConverted);
104
+ };
105
+ return {
106
+ type: 'lifecycle',
107
+ onAfterNodeProcess: (node, context) => {
108
+ if (transformedReferences.has(node)) {
109
+ return originalReferences.onAfterNodeProcess?.(node, context);
110
+ }
111
+ },
112
+ onDocumentLoaded: async (document, { uri, loadDocument, stored }) => {
113
+ entryUri ??= uri;
114
+ const from = !stored && isObject(document) ? sourceVersion(document.swagger ?? document.openapi) : undefined;
115
+ const version = from ??
116
+ metadata(document)?.from ??
117
+ (isObject(document)
118
+ ? (sourceVersion(document['x-original-oas-version']) ??
119
+ (typeof document.openapi === 'string' || typeof document.swagger === 'string' ? 'modern' : undefined))
120
+ : undefined);
121
+ // Retain source context only when a complete legacy resource will be replaced.
122
+ // Lazy resolves of an already upgraded root must not copy the whole API description.
123
+ sources.set(uri, { document: from && !metadata(document) ? structuredClone(document) : document, version });
124
+ const resolveSource = async (ref, origin = uri, visited = new Set()) => {
125
+ const [prefix, fragment = ''] = ref.split('#', 2);
126
+ const resource = prefix ? resolveReferencePath(origin, prefix) : origin;
127
+ const absolute = `${resource}#${fragment}`;
128
+ if (visited.has(absolute)) {
129
+ throw new Error(`Cyclic parameter reference: ${absolute}`);
130
+ }
131
+ visited.add(absolute);
132
+ const loaded = resource === uri ? { ok: true, data: document } : await loadDocument(resource);
133
+ if (!loaded.ok) {
134
+ throw new Error(`Cannot upgrade referenced parameter: ${absolute}`);
135
+ }
136
+ const target = atPath(loaded.data, pointerSegments(fragment));
137
+ if (isObject(target) && typeof target.$ref === 'string') {
138
+ return resolveSource(target.$ref, resource, visited);
139
+ }
140
+ // The operation may inline a referenced body/form parameter. Rebase its schema refs
141
+ // before moving it out of its resource; example/default payloads remain literal data.
142
+ const rebased = new WeakMap();
143
+ const rebase = (value, kind = 'object') => {
144
+ if (value === null || typeof value !== 'object') {
145
+ return value;
146
+ }
147
+ if (rebased.has(value)) {
148
+ return rebased.get(value);
149
+ }
150
+ if (Array.isArray(value)) {
151
+ const result = [];
152
+ rebased.set(value, result);
153
+ result.push(...value.map((entry) => rebase(entry, kind)));
154
+ return result;
155
+ }
156
+ const result = Object.create(null);
157
+ rebased.set(value, result);
158
+ for (const [key, child] of Object.entries(value)) {
159
+ const [name, entry] = (() => {
160
+ if (key === '$ref' && typeof child === 'string') {
161
+ const [relative, pointer] = child.split('#', 2);
162
+ const targetResource = relative ? resolveReferencePath(resource, relative) : resource;
163
+ const base = targetResource === uri ? '' : targetResource;
164
+ return [key, `${base}${pointer === undefined ? '' : `#${pointer}`}`];
165
+ }
166
+ if (['example', 'examples', 'default', 'enum', 'const'].includes(key) && kind !== 'map') {
167
+ return [key, structuredClone(child)];
168
+ }
169
+ if (key.startsWith('x-') && kind !== 'map') {
170
+ return [key, structuredClone(child)];
171
+ }
172
+ return [
173
+ key,
174
+ rebase(child, key === 'properties' || key === 'definitions'
175
+ ? 'map'
176
+ : key === 'schema' || kind === 'map'
177
+ ? 'schema'
178
+ : kind),
179
+ ];
180
+ })();
181
+ result[name] = entry;
182
+ }
183
+ return result;
184
+ };
185
+ return rebase(target);
186
+ };
187
+ resolvers.set(uri, resolveSource);
188
+ if (!from || metadata(document)) {
189
+ return document;
190
+ }
191
+ const result = await upgradeFragment(document, { from, to: '3.1', kind: 'document', resolveSource });
192
+ if (!isObject(result.value)) {
193
+ return result.value;
194
+ }
195
+ // Keep only prefix substitutions that cannot be inherited from a relocated parent.
196
+ const prefixes = new Map();
197
+ const locations = result.locations.filter(({ source, output }) => {
198
+ const key = JSON.stringify(source);
199
+ if (prefixes.has(key)) {
200
+ return false;
201
+ }
202
+ prefixes.set(key, output);
203
+ for (let length = source.length - 1; length >= 0; length--) {
204
+ const parent = prefixes.get(JSON.stringify(source.slice(0, length)));
205
+ if (parent) {
206
+ return JSON.stringify([...parent, ...source.slice(length)]) !== JSON.stringify(output);
207
+ }
208
+ }
209
+ return JSON.stringify(source) !== JSON.stringify(output);
210
+ });
211
+ const keepMetadata = uri !== entryUri || locations.length > 0 || result.contexts.length > 0;
212
+ const upgraded = {
213
+ ...result.value,
214
+ ...(keepMetadata ? { [metadataKey]: { from, locations, contexts: result.contexts } } : {}),
215
+ ...(uri === entryUri && isObject(document) && !document['x-original-oas-version']
216
+ ? { 'x-original-oas-version': document.swagger ?? document.openapi }
217
+ : {}),
218
+ };
219
+ markConverted(upgraded);
220
+ return upgraded;
221
+ },
222
+ resolveDocument: (document, uri) => {
223
+ const upgrade = metadata(document);
224
+ if (!upgrade) {
225
+ return isObject(document) && !document.openapi && !document.swagger && !document.asyncapi
226
+ ? { baseUri: uri, visitReferencedSubtrees: true }
227
+ : undefined;
228
+ }
229
+ const identity = resolveOpenApiDocument(document, uri);
230
+ return {
231
+ ...identity,
232
+ baseUri: identity?.baseUri ?? uri,
233
+ remapPointer: (pointer) => {
234
+ for (let length = pointer.length; length >= 0; length--) {
235
+ const output = upgrade.pointers.get(JSON.stringify(pointer.slice(0, length)));
236
+ if (output) {
237
+ return [...output, ...pointer.slice(length)];
238
+ }
239
+ }
240
+ return pointer;
241
+ },
242
+ };
243
+ },
244
+ onBeforeTargetProcess: async (target, context) => {
245
+ if (!isObject(target) || context.path[0] === metadataKey) {
246
+ return undefined;
247
+ }
248
+ const source = sources.get(context.uri);
249
+ const document = context.document;
250
+ // Complete versioned resources were converted at load time. Saved resources carry
251
+ // the same information so lazy resolution after serialization cannot upgrade twice.
252
+ const referenceNode = atPath(context.referenceSource.document, context.referenceSource.path);
253
+ if (isObject(document) && (document.openapi || document.swagger || metadata(document))) {
254
+ if (metadata(document) && document !== context.referencedFrom.rootNode && isObject(referenceNode)) {
255
+ originalReferences.onBeforeNodeProcess?.(referenceNode, {
256
+ ...context.referencedFrom,
257
+ path: context.referenceSource.document === context.referencedFrom.rootNode
258
+ ? [...context.referenceSource.path]
259
+ : context.referencedFrom.path,
260
+ });
261
+ transformedReferences.add(referenceNode);
262
+ }
263
+ return undefined;
264
+ }
265
+ if (converted.has(target)) {
266
+ return undefined;
267
+ }
268
+ const referring = sources.get(context.referenceSource.uri);
269
+ const storedPath = context.referenceSource.path;
270
+ const variant = storedPath[0] === metadataKey && storedPath[1] === 'variants'
271
+ ? atPath(context.referenceSource.document, storedPath.slice(0, 3))
272
+ : undefined;
273
+ const inherited = isObject(variant) ? sourceVersion(variant.from) : undefined;
274
+ const from = inherited ?? referring?.version ?? sourceVersion(entryVersion);
275
+ if (!from || from === 'modern' || typeof target.$schema === 'string') {
276
+ return undefined;
277
+ }
278
+ const path = isObject(variant) && stringArray(variant.semanticPath)
279
+ ? [...variant.semanticPath, ...storedPath.slice(4)]
280
+ : storedPath;
281
+ const kind = fragmentKind(path);
282
+ if (!kind || !isObject(document)) {
283
+ return undefined;
284
+ }
285
+ if (isObject(referenceNode)) {
286
+ originalReferences.onBeforeNodeProcess?.(referenceNode, {
287
+ ...context.referencedFrom,
288
+ path: context.referenceSource.document === context.referencedFrom.rootNode
289
+ ? [...context.referenceSource.path]
290
+ : context.referencedFrom.path,
291
+ });
292
+ transformedReferences.add(referenceNode);
293
+ }
294
+ // Saved API descriptions restore external refs and discard bundled resources. Keep
295
+ // the original entry dialect so bare targets are interpreted the same way on reload.
296
+ const entryDialect = entryUri === undefined ? undefined : sources.get(entryUri)?.version;
297
+ if (entryDialect && entryDialect !== 'modern' && !metadata(context.referencedFrom.rootNode)) {
298
+ context.referencedFrom.rootNode[metadataKey] = { from: entryDialect, locations: [] };
299
+ }
300
+ const originalValue = atPath(source?.document ?? document, context.path) ?? target;
301
+ const original = context.path.length === 0 && isObject(originalValue)
302
+ ? Object.fromEntries(Object.entries(originalValue).filter(([key]) => key !== metadataKey))
303
+ : originalValue;
304
+ const owner = referring?.document;
305
+ const operation = path[0] === 'paths' ? atPath(owner, path.slice(0, 3)) : undefined;
306
+ const savedContexts = atPath(owner, [metadataKey, 'contexts']);
307
+ const saved = Array.isArray(savedContexts)
308
+ ? savedContexts
309
+ .filter((item) => isObject(item) &&
310
+ stringArray(item.consumes) &&
311
+ stringArray(item.produces) &&
312
+ stringArray(item.path) &&
313
+ item.path.every((segment, index) => segment === path[index]))
314
+ .sort((a, b) => b.path.length - a.path.length)[0]
315
+ : undefined;
316
+ const consumes = isObject(variant) && stringArray(variant.consumes)
317
+ ? variant.consumes
318
+ : isObject(operation) && stringArray(operation.consumes)
319
+ ? operation.consumes
320
+ : isObject(owner) && stringArray(owner.consumes)
321
+ ? owner.consumes
322
+ : saved?.consumes;
323
+ const produces = isObject(variant) && stringArray(variant.produces)
324
+ ? variant.produces
325
+ : isObject(operation) && stringArray(operation.produces)
326
+ ? operation.produces
327
+ : isObject(owner) && stringArray(owner.produces)
328
+ ? owner.produces
329
+ : saved?.produces;
330
+ const storage = Object.assign(Object.create(null), isObject(document[metadataKey]) ? document[metadataKey] : {});
331
+ const mappings = Object.assign(Object.create(null), Object.fromEntries(Object.entries(isObject(storage.mappings) ? storage.mappings : {}).filter(([key, value]) => !['__proto__', 'prototype', 'constructor'].includes(key) && typeof value === 'string')));
332
+ const { generate } = uniqueValueGeneratorFactory(getHash, mappings);
333
+ const key = await generate(JSON.stringify([context.path, from, kind, consumes, produces]));
334
+ storage.mappings = mappings;
335
+ document[metadataKey] = storage;
336
+ const variantPath = [metadataKey, 'variants', key, 'value'];
337
+ const cached = atPath(document, variantPath);
338
+ if (cached !== undefined) {
339
+ return { value: cached, path: variantPath };
340
+ }
341
+ const result = await upgradeFragment(original, {
342
+ from,
343
+ to: '3.1',
344
+ kind,
345
+ consumes,
346
+ produces,
347
+ resolveSource: resolvers.get(context.uri),
348
+ });
349
+ markConverted(result.value);
350
+ const variants = Object.assign(Object.create(null), isObject(storage.variants) ? storage.variants : {});
351
+ variants[key] = { from, semanticPath: path, consumes, produces, value: result.value };
352
+ storage.variants = variants;
353
+ document[metadataKey] = storage;
354
+ return { value: result.value, path: variantPath };
355
+ },
356
+ };
357
+ };
@@ -43,6 +43,6 @@ export declare const buildRequestBody: (requestBody: RequestBodyObject | undefin
43
43
  /** The key of the current example */
44
44
  exampleName?: string,
45
45
  /** Selected anyOf/oneOf request-body variants keyed by schema path */
46
- requestBodyCompositionSelection?: Record<string, number>, openapiVersion?: string) => RequestBody | null;
46
+ requestBodyCompositionSelection?: Record<string, number>, openapiVersion?: string, jsonSchemaDialect?: string) => RequestBody | null;
47
47
  export {};
48
48
  //# sourceMappingURL=build-request-body.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-request-body.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/build-request-body.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAA;AAMjG,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,mBAAmB,CAAA;AAO1B,KAAK,QAAQ,GAAG;IACd,IAAI,EAAE,UAAU,CAAA;IAChB,KAAK,EAAE,CACH;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,MAAM,CAAA;QACb,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,GACD;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,IAAI,CAAA;QACX,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,GACD;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,IAAI,CAAA;QACX,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CACJ,EAAE,CAAA;CACJ,CAAA;AAwBD,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,YAAY,CAAA;IAClB,KAAK,EAAE;QACL,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;CACJ,CAAA;AAED,KAAK,GAAG,GAAG;IACT,IAAI,EAAE,KAAK,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,WAAW,GACnB,QAAQ,GACR,UAAU,GACV,GAAG,GACH;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,aAAa,EAAE,CAAA;CAAE,CAAA;AA2CtE;;GAEG;AACH,eAAO,MAAM,gBAAgB,gBACd,iBAAiB,GAAG,SAAS;AAC1C,qCAAqC;;AAErC,sEAAsE;kCACpC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACvC,MAAM,KACtB,WAAW,GAAG,IAiXhB,CAAA"}
1
+ {"version":3,"file":"build-request-body.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/build-request-body.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAA;AAMjG,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,mBAAmB,CAAA;AAO1B,KAAK,QAAQ,GAAG;IACd,IAAI,EAAE,UAAU,CAAA;IAChB,KAAK,EAAE,CACH;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,MAAM,CAAA;QACb,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,GACD;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,IAAI,CAAA;QACX,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,GACD;QACE,IAAI,EAAE,MAAM,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,IAAI,CAAA;QACX,WAAW,CAAC,EAAE,MAAM,CAAA;KACrB,CACJ,EAAE,CAAA;CACJ,CAAA;AAwBD,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,YAAY,CAAA;IAClB,KAAK,EAAE;QACL,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;CACJ,CAAA;AAED,KAAK,GAAG,GAAG;IACT,IAAI,EAAE,KAAK,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,WAAW,GACnB,QAAQ,GACR,UAAU,GACV,GAAG,GACH;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,aAAa,EAAE,CAAA;CAAE,CAAA;AA2CtE;;GAEG;AACH,eAAO,MAAM,gBAAgB,gBACd,iBAAiB,GAAG,SAAS;AAC1C,qCAAqC;;AAErC,sEAAsE;kCACpC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACvC,MAAM,sBACH,MAAM,KACzB,WAAW,GAAG,IAkXhB,CAAA"}