@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # @scalar/workspace-store
2
2
 
3
+ ## 0.75.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#11103](https://github.com/scalar/scalar/pull/11103): Support `x-scalar-token-prefix` on header API keys. Generated code examples and outgoing requests add the configured prefix while stored credentials remain unchanged.
8
+ - [#11020](https://github.com/scalar/scalar/pull/11020): feat: show `x-badges` in the sidebar with the new `showBadgesInSidebar` option
9
+
10
+ The option is off by default, so the sidebar looks the same as before. When it is on, the sidebar shows the `x-badges` of operations, webhooks, tags (including nested OpenAPI 3.2 tags), `x-tagGroups` entries and models next to their titles. Navigation entries of these types get an optional `badges` field.
11
+
12
+ ### Patch Changes
13
+
14
+ - [#11123](https://github.com/scalar/scalar/pull/11123): Fix the API reference freezing on schemas with several recursive or cross-referencing `$ref`s. Generated examples that are too large to render at full depth are now rendered at the deepest depth that fits.
15
+ - [#11115](https://github.com/scalar/scalar/pull/11115): Fix examples for a `oneOf` or `anyOf` variant that is a nullable object or array, which came out as `null` instead of the object or array.
16
+ - [#11113](https://github.com/scalar/scalar/pull/11113): Load native AsyncAPI RAML and Protobuf dependencies when their message or model is expanded, sharing authenticated downloads until the document changes and preserving source fallback and prebuilt server resources.
17
+
18
+ Use the containing document location for deferred dependencies and prevent remote schemas from invoking a filesystem loader.
19
+
20
+ ## 0.74.0
21
+
22
+ ### Minor Changes
23
+
24
+ - [#11089](https://github.com/scalar/scalar/pull/11089): Resolve external RAML and Protobuf dependencies for structured AsyncAPI schema documentation, preserving source fallback when dependencies cannot be fully resolved.
25
+
26
+ Show RAML named types in schema headings instead of adding a "RAML type:" line to the description.
27
+
28
+ Show inline object item titles in array type signatures across all `@scalar/blocks` consumers, including OpenAPI documentation: an array with `items: { type: 'object', title: 'Pet' }` now displays `array of Pet` instead of `array of object`.
29
+
30
+ ### Patch Changes
31
+
32
+ - [#11029](https://github.com/scalar/scalar/pull/11029): fix: respect contains match counts in simple array examples
33
+
34
+ Generate matching and nonmatching primitive items for direct contains constraints, counting tuple prefixes and respecting item schemas, length bounds, uniqueness, and the declared dialect. Authored examples remain authoritative. Candidate generation is bounded and may return a partial example for contradictory constraints.
35
+
36
+ Complex references and compositions, nested object or array candidate synthesis, and XML branch reconstruction retain existing best-effort behavior and are deferred to a follow-up.
37
+ - [#11099](https://github.com/scalar/scalar/pull/11099): Update compatible runtime and styling dependencies, align editor dependency versions, and preserve document-change comparisons with updated microdiff semantics.
38
+ - [#11102](https://github.com/scalar/scalar/pull/11102): Update @scalar/typebox to 0.1.4.
39
+ - [#11029](https://github.com/scalar/scalar/pull/11029): Preserve authored array item examples when contains constraints cannot be satisfied, and pass only dialect context to streaming example generation.
40
+ - [#10997](https://github.com/scalar/scalar/pull/10997): Upgrade referenced OpenAPI 2.0 and 3.0 resources before bundling, including bare fragments interpreted in their owning API description's dialect and media types. Preserve authored reference targets when schemas and parameters move, and retain their context through lazy loading, serialization, and export.
41
+
42
+ Add JSON Magic resource and target lifecycle hooks and the typed `upgradeFragment` API. Headerless external resources are traversed through referenced subtrees, including when reached from OpenAPI 3.1/3.2 descriptions. Exports retain compact `x-scalar-upgrade` bookkeeping only when lazy external references still need the original dialect, relocation mappings, or media types.
43
+
44
+ Resources already stored in an input bundle's `x-ext` keep their existing layout so saved references remain valid. Legacy keywords in those stored resources, including OpenAPI 2.0 schema `x-nullable` and `type: file`, deliberately remain unconverted; newly loaded legacy resources are upgraded.
45
+
3
46
  ## 0.73.0
4
47
 
5
48
  ### Minor Changes
package/README.md CHANGED
@@ -605,6 +605,16 @@ await result.applyChanges({ resolvedDocument: newDocument })
605
605
 
606
606
  After `applyChanges` returns, the merged document becomes both the new active document and the new saved baseline, so a subsequent `revertDocumentChanges` rolls back to the post-rebase state rather than the pre-rebase original.
607
607
 
608
+ ## Referenced OpenAPI upgrades
609
+
610
+ The workspace store uses JSON Magic's resource and target lifecycle hooks to
611
+ upgrade newly loaded referenced OpenAPI 2.0 and 3.0 resources. It retains compact
612
+ `x-scalar-upgrade` bookkeeping when lazy external references still need the
613
+ original dialect, relocation mappings, or media types. Editable exports keep
614
+ that bookkeeping only while those external references remain. Resources already
615
+ stored in an input bundle's `x-ext` retain their existing layout and legacy
616
+ keywords, including `x-nullable` and `type: file`, so saved pointers remain valid.
617
+
608
618
  ## OpenAPI document identity
609
619
 
610
620
  The store honors `$self` when resolving relative references in an OpenAPI 3.2 description. Relative identities resolve against the document source URL. External documents keep their own identities, including across partial bundles.
package/dist/client.d.ts CHANGED
@@ -4,6 +4,7 @@ import type { PartialDeep } from 'type-fest';
4
4
  import { type AuthStore } from './entities/auth/index.js';
5
5
  import { type HistoryStore } from './entities/history/index.js';
6
6
  import type { OperationMeta } from './events/definitions/operation.js';
7
+ import { type AsyncApiSchemaResourceResolver } from './helpers/async-api-schema-resources/resolver.js';
7
8
  import { type ExternalExampleResolver } from './helpers/external-examples.js';
8
9
  import type { NavigationOptions } from './navigation/get-navigation-options.js';
9
10
  import type { InMemoryWorkspace } from './schemas/inmemory-workspace.js';
@@ -114,6 +115,8 @@ type WorkspaceProps = {
114
115
  * @see https://github.com/microsoft/TypeScript/issues/43817#issuecomment-827746462
115
116
  */
116
117
  export type WorkspaceStore = {
118
+ /** Resolve native schema dependencies only when a consumer displays them. */
119
+ asyncApiSchemaResources: (documentName?: string) => AsyncApiSchemaResourceResolver;
117
120
  /** Resolve external examples without mutating the document or its edit history. */
118
121
  externalExamples: (documentName?: string) => ExternalExampleResolver;
119
122
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,YAAY,EAAU,MAAM,2BAA2B,CAAA;AAErE,OAAO,EAAE,KAAK,UAAU,EAAe,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAQ7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAI5C,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,iBAAiB,CAAA;AACj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c,GAAG,qBAAqB,CAAA;QAChE,OAAO,EAAE,MAAM,CAAA;KAChB,GACD;QACE,EAAE,EAAE,IAAI,CAAA;QACR,OAAO,EAAE,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,CAAC,CAAA;QAC1C,SAAS,EAAE,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,WAAW,CAAC,CAAA;QAChD,YAAY,EAAE,CACZ,iBAAiB,EACb;YACE,iBAAiB,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,CAAA;SACzC,GACD;YACE,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;SAC1C,KACF,OAAO,CAAC,IAAI,CAAC,CAAA;KACnB,CACJ,CAAA;CACF,CAAA;AA2DD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,oBAAqB,cAAc,KAAG,cA26CtE,CAAA;AAGD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA"}
package/dist/client.js CHANGED
@@ -9,7 +9,6 @@ import { bundle } from '@scalar/json-magic/bundle';
9
9
  import { fetchUrls } from '@scalar/json-magic/bundle/plugins/browser';
10
10
  import { apply, diff, merge } from '@scalar/json-magic/diff';
11
11
  import { createMagicProxy, getRaw } from '@scalar/json-magic/magic-proxy';
12
- import { upgrade } from '@scalar/openapi-upgrader';
13
12
  import { asyncApiObjectSchema } from '@scalar/schemas/asyncapi/3.1';
14
13
  import { Value } from '@scalar/typebox/value';
15
14
  import { coerce } from '@scalar/validation';
@@ -17,11 +16,15 @@ import { reactive } from 'vue';
17
16
  import YAML from 'yaml';
18
17
  import { createAuthStore } from './entities/auth/index.js';
19
18
  import { createHistoryStore } from './entities/history/index.js';
19
+ import { loadInlineAsyncApiSchemaResources } from './helpers/async-api-schema-resources/load-inline.js';
20
+ import { createAsyncApiSchemaResourceResolver, } from './helpers/async-api-schema-resources/resolver.js';
21
+ import { createNativeSchemaEditTracker } from './helpers/async-api-schema-resources/track-edits.js';
20
22
  import { asyncApiModelChunkReference } from './helpers/asyncapi-model-chunk-reference.js';
21
23
  import { chunkReference, expandChunkIndex } from './helpers/chunk-index.js';
24
+ import { compactUpgradeMetadata } from './helpers/compact-upgrade-metadata.js';
22
25
  import { deepClone } from './helpers/deep-clone.js';
23
26
  import { createDetectChangesProxy } from './helpers/detect-changes-proxy.js';
24
- import { bumpDocumentRevision } from './helpers/document-revision.js';
27
+ import { bumpDocumentRevision, getDocumentRevision } from './helpers/document-revision.js';
25
28
  import { createExternalExampleResolver } from './helpers/external-examples.js';
26
29
  import { safeAssign } from './helpers/general.js';
27
30
  import { getFetch } from './helpers/get-fetch.js';
@@ -31,9 +34,10 @@ import { normalizeBooleanSchemas } from './helpers/normalize-boolean-schemas.js'
31
34
  import { createOverridesProxy } from './helpers/overrides-proxy.js';
32
35
  import { resolveSecurityRequirements, restoreSecurityRequirements } from './helpers/resolve-security-requirements.js';
33
36
  import { snapshotRequestBodies } from './helpers/snapshot-request-bodies.js';
34
- import { unpackProxyObject } from './helpers/unpack-proxy.js';
37
+ import { unpackProxyObject, unpackProxyShallow } from './helpers/unpack-proxy.js';
35
38
  import { createNavigation, traverseAsyncApiDocument, traversePluginDocument } from './navigation/index.js';
36
39
  import { externalValueResolver, loadingStatus, normalizeAuthSchemes, normalizeRefs, openApiDocument, refsEverywhere, removeExtraScalarKeys, resolveOpenApiDocument, restoreOriginalRefs, syncPathParameters, } from './plugins/bundler/index.js';
40
+ import { asyncApiSchemaResources } from './plugins/bundler/async-api-schema-resources.js';
37
41
  import { codeSampleSources } from './plugins/bundler/code-sample-sources.js';
38
42
  import { extensions } from './schemas/extensions.js';
39
43
  import { PLUGIN_DOCUMENT_TYPE_KEY, findDocumentType, } from './schemas/plugin-document.js';
@@ -41,6 +45,7 @@ import { isAsyncApiDocument, isOpenApiDocument } from './schemas/type-guards.js'
41
45
  import { generateSchema } from './schemas/v3.2/openapi/index.js';
42
46
  import { recursiveRef } from './schemas/v3.2/openapi/reference.js';
43
47
  import { OpenAPIDocumentSchema as OpenAPIDocumentSchemaStrict, } from './schemas/v3.2/strict/openapi-document.js';
48
+ import { upgradeDocuments } from './plugins/bundler/upgrade-documents.js';
44
49
  /**
45
50
  * Maximum number of external references and example `externalValue`s fetched at once while bundling
46
51
  * a document. Keeps large documents (which can reference thousands of external examples) from opening
@@ -143,6 +148,7 @@ const METADATA_ONLY_DOCUMENT_KEYS = new Set([
143
148
  */
144
149
  const purgeInternalDocumentKeys = (input) => {
145
150
  const result = deepClone(input);
151
+ compactUpgradeMetadata(result);
146
152
  // Top level keys that need to be excluded from the original document
147
153
  // Nested keys are removed during the previous step of the bundler process
148
154
  const EXCLUDE_KEYS = [
@@ -188,6 +194,24 @@ export const createWorkspaceStore = (workspaceProps) => {
188
194
  * This can include settings that can not be persisted between sessions (not JSON serializable)
189
195
  */
190
196
  const extraDocumentConfigurations = {};
197
+ const nativeSchemaResolvers = new WeakMap();
198
+ const nativeSchemaEdits = new WeakSet();
199
+ const trackNativeSchemaEdits = createNativeSchemaEditTracker();
200
+ const nativeSchemaRevisions = new WeakMap();
201
+ const checkNativeSchemaEdits = (document) => {
202
+ const raw = unpackProxyShallow(document);
203
+ const revision = getDocumentRevision(raw);
204
+ // Reactive workspaces can skip the source comparison until a write occurs. Plain workspaces
205
+ // have no write hooks, so they compare on each read instead.
206
+ if (isReactiveWorkspace && nativeSchemaRevisions.get(raw) === revision)
207
+ return;
208
+ nativeSchemaRevisions.set(raw, revision);
209
+ if (trackNativeSchemaEdits(document)) {
210
+ nativeSchemaResolvers.delete(raw);
211
+ nativeSchemaEdits.add(raw);
212
+ }
213
+ };
214
+ const fallbackNativeSchemas = createAsyncApiSchemaResourceResolver();
191
215
  const externalExampleResolvers = new WeakMap();
192
216
  const fallbackExternalExamples = createExternalExampleResolver({
193
217
  fetch: workspaceProps?.fetch,
@@ -593,6 +617,10 @@ export const createWorkspaceStore = (workspaceProps) => {
593
617
  if (isAsyncApiDocument(clonedRawInputDocument)) {
594
618
  // Capture the original version before the upgrader bumps `asyncapi` to the latest.
595
619
  const originalAasVersion = clonedRawInputDocument.asyncapi;
620
+ if (originalAasVersion.startsWith('2.')) {
621
+ // Preserve the 2.x message-level schema format before upgrading its channel structure.
622
+ await loadInlineAsyncApiSchemaResources(createMagicProxy(clonedRawInputDocument), input.documentSource ?? '/', loaders, { lazy: true });
623
+ }
596
624
  // The upgrader is typed against the loose `UnknownObject` shape; the result is a valid
597
625
  // 3.x AsyncAPI document, so cast it back so the spread below still satisfies `AsyncApiDocument`.
598
626
  const upgradedAsyncApiDocument = withMeasurementSync('upgrade', () => upgradeAsyncApi(deepClone(clonedRawInputDocument)));
@@ -607,7 +635,7 @@ export const createWorkspaceStore = (workspaceProps) => {
607
635
  await withMeasurementAsync('bundle', async () => await bundle(getRaw(asyncApiDocument), {
608
636
  traversal: 'document',
609
637
  treeShake: false,
610
- plugins: loaders,
638
+ plugins: [asyncApiSchemaResources(), ...loaders],
611
639
  urlMap: true,
612
640
  origin: input.documentSource,
613
641
  }));
@@ -618,19 +646,23 @@ export const createWorkspaceStore = (workspaceProps) => {
618
646
  const navigation = traverseAsyncApiDocument(name, asyncApiDocument, navigationOptions);
619
647
  asyncApiDocument[extensions.document.navigation] = navigation;
620
648
  }
649
+ checkNativeSchemaEdits(asyncApiDocument);
621
650
  const asyncApiOverrides = unpackProxyObject(overrides[name]);
622
651
  workspace.documents[name] = needsOverridesProxy(asyncApiOverrides)
623
652
  ? createOverridesProxy(asyncApiDocument, { overrides: asyncApiOverrides })
624
653
  : asyncApiDocument;
654
+ checkNativeSchemaEdits(workspace.documents[name]);
625
655
  return true;
626
656
  }
627
- const inputDocument = withMeasurementSync('upgrade', () => upgrade(deepClone(clonedRawInputDocument), '3.1'));
657
+ const inputDocument = deepClone(clonedRawInputDocument);
628
658
  const strictDocument = createMagicProxy({
629
659
  ...inputDocument,
630
660
  // Partial API descriptions still need document traversal rather than standalone schema traversal.
631
661
  openapi: inputDocument.openapi ?? '',
632
662
  ...meta,
633
- 'x-original-oas-version': clonedRawInputDocument.openapi ?? clonedRawInputDocument.swagger,
663
+ 'x-original-oas-version': clonedRawInputDocument['x-original-oas-version'] ??
664
+ clonedRawInputDocument.openapi ??
665
+ clonedRawInputDocument.swagger,
634
666
  'x-scalar-original-document-hash': input.documentHash,
635
667
  'x-scalar-original-source-url': input.documentSource,
636
668
  }, { showInternal: true, documentUri: resolveOpenApiDocument(inputDocument, input.documentSource ?? '/')?.baseUri });
@@ -645,6 +677,7 @@ export const createWorkspaceStore = (workspaceProps) => {
645
677
  plugins: [
646
678
  ...loaders,
647
679
  codeSampleSources(),
680
+ upgradeDocuments(clonedRawInputDocument.openapi ?? clonedRawInputDocument.swagger),
648
681
  openApiDocument(),
649
682
  normalizeRefs(),
650
683
  externalValueResolver({ lazy: true }),
@@ -774,6 +807,7 @@ export const createWorkspaceStore = (workspaceProps) => {
774
807
  const authoredDocument = deepClone(rawDocument);
775
808
  restoreSecurityRequirements(authoredDocument);
776
809
  const original = (await bundle(authoredDocument, {
810
+ traversal: isAsyncApiDocument(authoredDocument) ? 'document' : undefined,
777
811
  plugins: [openApiDocument(), restoreOriginalRefs(), removeExtraScalarKeys()],
778
812
  treeShake: false,
779
813
  urlMap: true,
@@ -899,6 +933,25 @@ export const createWorkspaceStore = (workspaceProps) => {
899
933
  // This is needed because we are doing partial bundle operations
900
934
  const visitedNodesCaches = new WeakMap();
901
935
  return {
936
+ asyncApiSchemaResources: (documentName) => {
937
+ const name = documentName ?? getActiveDocumentName();
938
+ const document = workspace.documents[name];
939
+ if (!document)
940
+ return fallbackNativeSchemas;
941
+ const raw = unpackProxyShallow(document);
942
+ checkNativeSchemaEdits(document);
943
+ const cached = nativeSchemaResolvers.get(raw);
944
+ if (cached)
945
+ return cached;
946
+ const resolve = createAsyncApiSchemaResourceResolver({
947
+ origin: document['x-scalar-original-source-url'],
948
+ usePreparedResources: !nativeSchemaEdits.has(raw),
949
+ fileLoader: workspaceProps?.fileLoader,
950
+ fetch: extraDocumentConfigurations[name]?.fetch ?? workspaceProps?.fetch,
951
+ });
952
+ nativeSchemaResolvers.set(raw, resolve);
953
+ return resolve;
954
+ },
902
955
  externalExamples: (documentName) => {
903
956
  const name = documentName ?? getActiveDocumentName();
904
957
  const document = workspace.documents[name];
@@ -1011,7 +1064,7 @@ export const createWorkspaceStore = (workspaceProps) => {
1011
1064
  path.length === 3 &&
1012
1065
  path[0] === 'components' &&
1013
1066
  path[1] === 'schemas') {
1014
- const node = getRaw(target);
1067
+ const node = unpackProxyShallow(target);
1015
1068
  const name = path[2];
1016
1069
  if (name && typeof node.$ref === 'string' && node.$global === true) {
1017
1070
  node.$ref = asyncApiModelChunkReference(node.$ref, name);
@@ -1030,13 +1083,18 @@ export const createWorkspaceStore = (workspaceProps) => {
1030
1083
  if (activeDocument) {
1031
1084
  visitedNodesCaches.set(activeDocument, visitedNodes);
1032
1085
  }
1033
- return bundle(target, {
1034
- root: activeDocument,
1086
+ const result = await bundle(target, {
1087
+ inputPath: path,
1035
1088
  traversal: 'document',
1089
+ root: activeDocument,
1036
1090
  origin: activeDocument?.['x-scalar-original-source-url'],
1037
1091
  treeShake: false,
1038
1092
  plugins: [
1039
- codeSampleSources(path),
1093
+ ...(activeDocument && isOpenApiDocument(activeDocument)
1094
+ ? [upgradeDocuments(activeDocument['x-original-oas-version'])]
1095
+ : []),
1096
+ codeSampleSources(),
1097
+ asyncApiSchemaResources(),
1040
1098
  openApiDocument(),
1041
1099
  fetchUrls({
1042
1100
  fetch: extraDocumentConfigurations[getActiveDocumentName()]?.fetch ?? workspaceProps?.fetch,
@@ -1049,6 +1107,9 @@ export const createWorkspaceStore = (workspaceProps) => {
1049
1107
  urlMap: true,
1050
1108
  visitedNodes,
1051
1109
  });
1110
+ if (activeDocument)
1111
+ checkNativeSchemaEdits(activeDocument);
1112
+ return result;
1052
1113
  },
1053
1114
  addDocument,
1054
1115
  /**
@@ -1155,6 +1216,8 @@ export const createWorkspaceStore = (workspaceProps) => {
1155
1216
  documentUri: resolveOpenApiDocument(doc, doc['x-scalar-original-source-url'] ?? '/')?.baseUri,
1156
1217
  });
1157
1218
  const documentOverrides = input.overrides[name];
1219
+ if (isAsyncApiDocument(magicDocument))
1220
+ checkNativeSchemaEdits(magicDocument);
1158
1221
  return [
1159
1222
  name,
1160
1223
  needsOverridesProxy(documentOverrides)
@@ -1162,6 +1225,10 @@ export const createWorkspaceStore = (workspaceProps) => {
1162
1225
  : magicDocument,
1163
1226
  ];
1164
1227
  })));
1228
+ for (const document of Object.values(workspace.documents)) {
1229
+ if (isAsyncApiDocument(document))
1230
+ checkNativeSchemaEdits(document);
1231
+ }
1165
1232
  safeAssign(originalDocuments, input.originalDocuments);
1166
1233
  safeAssign(intermediateDocuments, input.intermediateDocuments);
1167
1234
  safeAssign(overrides, input.overrides);