@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # @scalar/workspace-store
2
2
 
3
+ ## 0.74.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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.
8
+
9
+ Show RAML named types in schema headings instead of adding a "RAML type:" line to the description.
10
+
11
+ 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`.
12
+
13
+ ### Patch Changes
14
+
15
+ - [#11029](https://github.com/scalar/scalar/pull/11029): fix: respect contains match counts in simple array examples
16
+
17
+ 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.
18
+
19
+ 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.
20
+ - [#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.
21
+ - [#11102](https://github.com/scalar/scalar/pull/11102): Update @scalar/typebox to 0.1.4.
22
+ - [#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.
23
+ - [#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.
24
+
25
+ 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.
26
+
27
+ 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.
28
+
29
+ ## 0.73.0
30
+
31
+ ### Minor Changes
32
+
33
+ - [#10816](https://github.com/scalar/scalar/pull/10816): Add `documentTypes` to `createWorkspaceStore`, so the store can ingest document formats it does not support natively. A registered type claims a document before the OpenAPI and AsyncAPI pipelines run, and the store keeps it as an opaque plugin document with `plugin` navigation entries built by the type.
34
+
35
+ ### Patch Changes
36
+
37
+ - [#10816](https://github.com/scalar/scalar/pull/10816): Keep plugin document classification consistent through replacement, hydration, and rebasing. Exclude plugin documents from Ask AI and reject unsupported request, authentication, and mock-server processing even when plugin data contains OpenAPI or AsyncAPI fields.
38
+ - [#10983](https://github.com/scalar/scalar/pull/10983): Preserve literal $ref values in AsyncAPI examples, schema values, and extensions during initial loading and lazy resolution without fetching them. Index authored document keys without following virtual proxy links. Keep wrapper resolution independent of key order and ignore reference siblings in AsyncAPI parameter schemas and wrapped OpenAPI 3.0 and draft-04/06 schemas, including identifiers and anchors in those ignored siblings. Traverse only schema and identity keywords supported by the wrapped format so unknown keyword values stay literal, including draft-04 `id` and draft-06/07 `$id` handling.
39
+ - [#10983](https://github.com/scalar/scalar/pull/10983): Resolve references inside AsyncAPI Multi Format Schema Objects and OpenAPI 3.2 media type `itemSchema` fields while preserving literal schema values. Keep `schemaFormat` and `schema` annotations in ordinary JSON Schema objects as literal data. Resolve native AsyncAPI schema `externalDocs` and tuple `additionalItems` references without processing ordinary JSON Schema annotations. Preserve schema contexts inside AsyncAPI protocol bindings. Resolve named AsyncAPI servers, variables, and reusable components even when their names match literal-data keywords. Ignore reference siblings in native AsyncAPI and draft-07 schemas.
40
+
3
41
  ## 0.72.0
4
42
 
5
43
  ### 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
@@ -7,6 +7,7 @@ import type { OperationMeta } from './events/definitions/operation.js';
7
7
  import { type ExternalExampleResolver } from './helpers/external-examples.js';
8
8
  import type { NavigationOptions } from './navigation/get-navigation-options.js';
9
9
  import type { InMemoryWorkspace } from './schemas/inmemory-workspace.js';
10
+ import { type DocumentTypeDefinition } from './schemas/plugin-document.js';
10
11
  import type { RequestBodyObject } from './schemas/v3.2/strict/openapi-document.js';
11
12
  import { type OpenApiDocument } from './schemas/v3.2/strict/openapi-document.js';
12
13
  import type { DocumentMetaExtensions, Workspace, WorkspaceDocument, WorkspaceDocumentMeta, WorkspaceExtensions, WorkspaceMeta } from './schemas/workspace.js';
@@ -75,6 +76,11 @@ type WorkspaceProps = {
75
76
  plugins?: WorkspacePlugin[];
76
77
  /** A file loader plugin for resolving local file references (for non browser environments) */
77
78
  fileLoader?: LoaderPlugin;
79
+ /**
80
+ * Document formats the store does not support natively. Each one is checked, in order, before the
81
+ * built-in OpenAPI and AsyncAPI pipelines.
82
+ */
83
+ documentTypes?: readonly DocumentTypeDefinition[];
78
84
  /**
79
85
  * Whether writes to the workspace are observable. Defaults to `true`.
80
86
  *
@@ -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;AACjE,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,oBAAoB,CAAA;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAMnE,OAAO,EAAE,KAAK,uBAAuB,EAAiC,MAAM,6BAA6B,CAAA;AAWzG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAe5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAKrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC/E,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,KAAK,EACV,sBAAsB,EACtB,SAAS,EACT,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACd,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,sBAAsB,EAAE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ACH,eAAe,IAAI,iBAAiB,CAAA;IACpC;;;;;;;OAOG;IACH,aAAa,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAC7C;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,gCAAgC,CAAC,aAAa,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAC3F;;;;;;;;;;;;;;;;;;;OAmBG;IACH,cAAc,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,OAAO,CACtD;QACE,EAAE,EAAE,KAAK,CAAA;QACT,IAAI,EAAE,iBAAiB,GAAG,cAAc,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,cA+3CtE,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,8 +16,10 @@ 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
20
  import { asyncApiModelChunkReference } from './helpers/asyncapi-model-chunk-reference.js';
21
21
  import { chunkReference, expandChunkIndex } from './helpers/chunk-index.js';
22
+ import { compactUpgradeMetadata } from './helpers/compact-upgrade-metadata.js';
22
23
  import { deepClone } from './helpers/deep-clone.js';
23
24
  import { createDetectChangesProxy } from './helpers/detect-changes-proxy.js';
24
25
  import { bumpDocumentRevision } from './helpers/document-revision.js';
@@ -32,14 +33,17 @@ import { createOverridesProxy } from './helpers/overrides-proxy.js';
32
33
  import { resolveSecurityRequirements, restoreSecurityRequirements } from './helpers/resolve-security-requirements.js';
33
34
  import { snapshotRequestBodies } from './helpers/snapshot-request-bodies.js';
34
35
  import { unpackProxyObject } from './helpers/unpack-proxy.js';
35
- import { createNavigation, traverseAsyncApiDocument } from './navigation/index.js';
36
+ import { createNavigation, traverseAsyncApiDocument, traversePluginDocument } from './navigation/index.js';
36
37
  import { externalValueResolver, loadingStatus, normalizeAuthSchemes, normalizeRefs, openApiDocument, refsEverywhere, removeExtraScalarKeys, resolveOpenApiDocument, restoreOriginalRefs, syncPathParameters, } from './plugins/bundler/index.js';
38
+ import { asyncApiSchemaResources } from './plugins/bundler/async-api-schema-resources.js';
37
39
  import { codeSampleSources } from './plugins/bundler/code-sample-sources.js';
38
40
  import { extensions } from './schemas/extensions.js';
41
+ import { PLUGIN_DOCUMENT_TYPE_KEY, findDocumentType, } from './schemas/plugin-document.js';
39
42
  import { isAsyncApiDocument, isOpenApiDocument } from './schemas/type-guards.js';
40
43
  import { generateSchema } from './schemas/v3.2/openapi/index.js';
41
44
  import { recursiveRef } from './schemas/v3.2/openapi/reference.js';
42
45
  import { OpenAPIDocumentSchema as OpenAPIDocumentSchemaStrict, } from './schemas/v3.2/strict/openapi-document.js';
46
+ import { upgradeDocuments } from './plugins/bundler/upgrade-documents.js';
43
47
  /**
44
48
  * Maximum number of external references and example `externalValue`s fetched at once while bundling
45
49
  * a document. Keeps large documents (which can reference thousands of external examples) from opening
@@ -142,6 +146,7 @@ const METADATA_ONLY_DOCUMENT_KEYS = new Set([
142
146
  */
143
147
  const purgeInternalDocumentKeys = (input) => {
144
148
  const result = deepClone(input);
149
+ compactUpgradeMetadata(result);
145
150
  // Top level keys that need to be excluded from the original document
146
151
  // Nested keys are removed during the previous step of the bundler process
147
152
  const EXCLUDE_KEYS = [
@@ -157,6 +162,7 @@ const purgeInternalDocumentKeys = (input) => {
157
162
  'x-scalar-original-document-hash',
158
163
  'x-scalar-original-source-url',
159
164
  'x-scalar-registry-meta',
165
+ PLUGIN_DOCUMENT_TYPE_KEY,
160
166
  ];
161
167
  // Remove top-level properties that should only exist temporarily or for internal usage
162
168
  // These properties are used for internal purposes and are not needed in the final bundled document
@@ -490,6 +496,16 @@ export const createWorkspaceStore = (workspaceProps) => {
490
496
  activeDocument['x-scalar-is-dirty'] = false;
491
497
  return true;
492
498
  };
499
+ /** The placeholder shown for a document that could not be loaded. */
500
+ const createLoadFailedDocument = (name, meta) => ({
501
+ ...meta,
502
+ openapi: '3.1.0',
503
+ info: {
504
+ title: `Document '${name}' could not be loaded`,
505
+ version: 'unknown',
506
+ },
507
+ 'x-scalar-original-document-hash': 'not-a-hash',
508
+ });
493
509
  // Add a document to the store synchronously from an in-memory OpenAPI or AsyncAPI document
494
510
  async function addInMemoryDocument(input, navigationOptions) {
495
511
  const { name } = input;
@@ -499,6 +515,9 @@ export const createWorkspaceStore = (workspaceProps) => {
499
515
  // else reads it, so every step below — including the check for a server-generated navigation —
500
516
  // sees the document a non-compact server store would have sent.
501
517
  withMeasurementSync('expandChunkIndex', () => expandChunkIndex(clonedRawInputDocument));
518
+ // The marker belongs to the store, never the source. Remove it before capturing the saved
519
+ // baseline so an export before the first save cannot leak it or misclassify the document.
520
+ delete clonedRawInputDocument[PLUGIN_DOCUMENT_TYPE_KEY];
502
521
  withMeasurementSync('initialize', () => {
503
522
  if (input.initialize !== false) {
504
523
  // Store the original document in the originalDocuments map
@@ -530,6 +549,46 @@ export const createWorkspaceStore = (workspaceProps) => {
530
549
  if (workspaceProps?.fileLoader) {
531
550
  loaders.push(workspaceProps.fileLoader);
532
551
  }
552
+ // Registered document types come first, so a format they claim never reaches the OpenAPI
553
+ // upgrade and coercion below (which would turn it into a broken OpenAPI document).
554
+ const documentType = findDocumentType(workspaceProps?.documentTypes, clonedRawInputDocument);
555
+ if (documentType) {
556
+ // Third-party code runs here, so a failure ends up as the usual "could not be loaded" document
557
+ // instead of leaving the workspace without this document.
558
+ try {
559
+ const ingestedDocument = await withMeasurementAsync('ingest', async () => (await documentType.ingest?.(deepClone(clonedRawInputDocument), { documentName: name })) ??
560
+ clonedRawInputDocument);
561
+ const pluginDocument = createMagicProxy({
562
+ ...ingestedDocument,
563
+ info: isObject(ingestedDocument.info) ? ingestedDocument.info : {},
564
+ ...meta,
565
+ [PLUGIN_DOCUMENT_TYPE_KEY]: documentType.type,
566
+ 'x-scalar-original-document-hash': input.documentHash,
567
+ 'x-scalar-original-source-url': input.documentSource,
568
+ });
569
+ if (documentType.bundle && pluginDocument[extensions.document.navigation] === undefined) {
570
+ await withMeasurementAsync('bundle', async () => await bundle(getRaw(pluginDocument), {
571
+ treeShake: false,
572
+ plugins: loaders,
573
+ urlMap: true,
574
+ origin: input.documentSource,
575
+ }));
576
+ }
577
+ if (pluginDocument[extensions.document.navigation] === undefined) {
578
+ pluginDocument[extensions.document.navigation] = traversePluginDocument(name, pluginDocument, documentType, navigationOptions);
579
+ }
580
+ const pluginOverrides = unpackProxyObject(overrides[name]);
581
+ workspace.documents[name] = needsOverridesProxy(pluginOverrides)
582
+ ? createOverridesProxy(pluginDocument, { overrides: pluginOverrides })
583
+ : pluginDocument;
584
+ return true;
585
+ }
586
+ catch (error) {
587
+ console.error(`Failed to load document '${name}' with document type '${documentType.type}':`, error);
588
+ workspace.documents[name] = createLoadFailedDocument(name, meta);
589
+ return false;
590
+ }
591
+ }
533
592
  // AsyncAPI ingestion: skip the OpenAPI-specific upgrade and validation pipeline.
534
593
  // The OpenAPI `coerce` step would otherwise inject an empty `openapi: ''` field
535
594
  // and break the type discriminator. We still run the AsyncAPI-specific upgrader so
@@ -538,6 +597,10 @@ export const createWorkspaceStore = (workspaceProps) => {
538
597
  if (isAsyncApiDocument(clonedRawInputDocument)) {
539
598
  // Capture the original version before the upgrader bumps `asyncapi` to the latest.
540
599
  const originalAasVersion = clonedRawInputDocument.asyncapi;
600
+ if (originalAasVersion.startsWith('2.')) {
601
+ // Preserve the 2.x message-level schema format before upgrading its channel structure.
602
+ await loadInlineAsyncApiSchemaResources(createMagicProxy(clonedRawInputDocument), input.documentSource ?? '/', loaders);
603
+ }
541
604
  // The upgrader is typed against the loose `UnknownObject` shape; the result is a valid
542
605
  // 3.x AsyncAPI document, so cast it back so the spread below still satisfies `AsyncApiDocument`.
543
606
  const upgradedAsyncApiDocument = withMeasurementSync('upgrade', () => upgradeAsyncApi(deepClone(clonedRawInputDocument)));
@@ -550,8 +613,9 @@ export const createWorkspaceStore = (workspaceProps) => {
550
613
  });
551
614
  if (asyncApiDocument[extensions.document.navigation] === undefined) {
552
615
  await withMeasurementAsync('bundle', async () => await bundle(getRaw(asyncApiDocument), {
616
+ traversal: 'document',
553
617
  treeShake: false,
554
- plugins: loaders,
618
+ plugins: [asyncApiSchemaResources(), ...loaders],
555
619
  urlMap: true,
556
620
  origin: input.documentSource,
557
621
  }));
@@ -566,15 +630,17 @@ export const createWorkspaceStore = (workspaceProps) => {
566
630
  workspace.documents[name] = needsOverridesProxy(asyncApiOverrides)
567
631
  ? createOverridesProxy(asyncApiDocument, { overrides: asyncApiOverrides })
568
632
  : asyncApiDocument;
569
- return;
633
+ return true;
570
634
  }
571
- const inputDocument = withMeasurementSync('upgrade', () => upgrade(deepClone(clonedRawInputDocument), '3.1'));
635
+ const inputDocument = deepClone(clonedRawInputDocument);
572
636
  const strictDocument = createMagicProxy({
573
637
  ...inputDocument,
574
638
  // Partial API descriptions still need document traversal rather than standalone schema traversal.
575
639
  openapi: inputDocument.openapi ?? '',
576
640
  ...meta,
577
- 'x-original-oas-version': clonedRawInputDocument.openapi ?? clonedRawInputDocument.swagger,
641
+ 'x-original-oas-version': clonedRawInputDocument['x-original-oas-version'] ??
642
+ clonedRawInputDocument.openapi ??
643
+ clonedRawInputDocument.swagger,
578
644
  'x-scalar-original-document-hash': input.documentHash,
579
645
  'x-scalar-original-source-url': input.documentSource,
580
646
  }, { showInternal: true, documentUri: resolveOpenApiDocument(inputDocument, input.documentSource ?? '/')?.baseUri });
@@ -589,6 +655,7 @@ export const createWorkspaceStore = (workspaceProps) => {
589
655
  plugins: [
590
656
  ...loaders,
591
657
  codeSampleSources(),
658
+ upgradeDocuments(clonedRawInputDocument.openapi ?? clonedRawInputDocument.swagger),
592
659
  openApiDocument(),
593
660
  normalizeRefs(),
594
661
  externalValueResolver({ lazy: true }),
@@ -632,6 +699,7 @@ export const createWorkspaceStore = (workspaceProps) => {
632
699
  : magicDocument;
633
700
  const baselineDocument = workspace.documents[name];
634
701
  requestBodyBaselines[name] = withMeasurementSync('snapshotRequestBodies', () => snapshotRequestBodies(baselineDocument));
702
+ return true;
635
703
  }
636
704
  // Asynchronously adds a new document to the workspace by loading and validating the input.
637
705
  // If loading fails, a placeholder error document is added instead.
@@ -647,37 +715,20 @@ export const createWorkspaceStore = (workspaceProps) => {
647
715
  return await withMeasurementAsync('addDocument', async () => {
648
716
  if (!resolve.ok) {
649
717
  console.error(`Failed to fetch document '${name}': request was not successful`);
650
- workspace.documents[name] = {
651
- ...meta,
652
- openapi: '3.1.0',
653
- info: {
654
- title: `Document '${name}' could not be loaded`,
655
- version: 'unknown',
656
- },
657
- 'x-scalar-original-document-hash': 'not-a-hash',
658
- };
718
+ workspace.documents[name] = createLoadFailedDocument(name, meta);
659
719
  return false;
660
720
  }
661
721
  if (!isObject(resolve.data)) {
662
722
  console.error(`Failed to load document '${name}': response data is not a valid object`);
663
- workspace.documents[name] = {
664
- ...meta,
665
- openapi: '3.1.0',
666
- info: {
667
- title: `Document '${name}' could not be loaded`,
668
- version: 'unknown',
669
- },
670
- 'x-scalar-original-document-hash': 'not-a-hash',
671
- };
723
+ workspace.documents[name] = createLoadFailedDocument(name, meta);
672
724
  return false;
673
725
  }
674
- await addInMemoryDocument({
726
+ return await addInMemoryDocument({
675
727
  ...input,
676
728
  document: resolve.data,
677
729
  documentSource: getDocumentSource(input),
678
730
  documentHash: generateHash(resolve.raw),
679
731
  }, navigationOptions);
680
- return true;
681
732
  });
682
733
  }
683
734
  const getOriginalDocument = (documentName) => {
@@ -734,6 +785,7 @@ export const createWorkspaceStore = (workspaceProps) => {
734
785
  const authoredDocument = deepClone(rawDocument);
735
786
  restoreSecurityRequirements(authoredDocument);
736
787
  const original = (await bundle(authoredDocument, {
788
+ traversal: isAsyncApiDocument(authoredDocument) ? 'document' : undefined,
737
789
  plugins: [openApiDocument(), restoreOriginalRefs(), removeExtraScalarKeys()],
738
790
  treeShake: false,
739
791
  urlMap: true,
@@ -991,12 +1043,17 @@ export const createWorkspaceStore = (workspaceProps) => {
991
1043
  visitedNodesCaches.set(activeDocument, visitedNodes);
992
1044
  }
993
1045
  return bundle(target, {
994
- root: activeDocument,
1046
+ inputPath: path,
995
1047
  traversal: 'document',
1048
+ root: activeDocument,
996
1049
  origin: activeDocument?.['x-scalar-original-source-url'],
997
1050
  treeShake: false,
998
1051
  plugins: [
999
- codeSampleSources(path),
1052
+ ...(activeDocument && isOpenApiDocument(activeDocument)
1053
+ ? [upgradeDocuments(activeDocument['x-original-oas-version'])]
1054
+ : []),
1055
+ codeSampleSources(),
1056
+ asyncApiSchemaResources(),
1000
1057
  openApiDocument(),
1001
1058
  fetchUrls({
1002
1059
  fetch: extraDocumentConfigurations[getActiveDocumentName()]?.fetch ?? workspaceProps?.fetch,
@@ -1180,7 +1237,9 @@ export const createWorkspaceStore = (workspaceProps) => {
1180
1237
  message: `No changes detected for document '${name}': document hash matches the active document`,
1181
1238
  };
1182
1239
  }
1183
- const newDocumentOrigin = resolve.data;
1240
+ // Source markers are not classification evidence, including when rebasing a saved baseline.
1241
+ const newDocumentOrigin = deepClone(resolve.data);
1242
+ delete newDocumentOrigin[PLUGIN_DOCUMENT_TYPE_KEY];
1184
1243
  // ---- Override the configurations and metadata
1185
1244
  overrides[name] = input.overrides ?? {};
1186
1245
  extraDocumentConfigurations[name] = { fetch: input.fetch };
@@ -1220,7 +1279,8 @@ export const createWorkspaceStore = (workspaceProps) => {
1220
1279
  // If the caller provided a fully resolved document, use it as-is.
1221
1280
  return applyChangesInput.resolvedDocument;
1222
1281
  };
1223
- const mergedDocument = getNewActiveDocument();
1282
+ const mergedDocument = deepClone(getNewActiveDocument());
1283
+ delete mergedDocument[PLUGIN_DOCUMENT_TYPE_KEY];
1224
1284
  // Detect whether the rebase folded in any local edits. When the
1225
1285
  // merged result matches the upstream snapshot the pull was
1226
1286
  // effectively a fast-forward (no unsaved local work to carry
@@ -1258,9 +1318,6 @@ export const createWorkspaceStore = (workspaceProps) => {
1258
1318
  const activeServers = activeDocumentRaw.servers;
1259
1319
  const mergedHasServers = Array.isArray(mergedServers) && mergedServers.length > 0;
1260
1320
  const activeHasServers = Array.isArray(activeServers) && activeServers.length > 0;
1261
- const preservedServers = !isAsyncApiDocument(mergedDocument) && !mergedHasServers && activeHasServers
1262
- ? deepClone(activeServers)
1263
- : undefined;
1264
1321
  // add the new active document to the workspace but don't re-initialize
1265
1322
  await addInMemoryDocument({
1266
1323
  ...input,
@@ -1283,11 +1340,16 @@ export const createWorkspaceStore = (workspaceProps) => {
1283
1340
  'x-scalar-selected-server': activeDocumentRaw['x-scalar-selected-server'],
1284
1341
  ...(environments !== undefined ? { 'x-scalar-environments': environments } : {}),
1285
1342
  ...(order !== undefined ? { 'x-scalar-order': order } : {}),
1286
- ...(preservedServers !== undefined ? { servers: preservedServers } : {}),
1287
1343
  // Flag local edits that need pushing - see note above.
1288
1344
  'x-scalar-is-dirty': hasLocalChangesAgainstUpstream,
1289
1345
  },
1290
1346
  });
1347
+ // Re-ingestion determines the resulting format. Raw input can carry OpenAPI-looking fields
1348
+ // while being claimed by a plugin, so only preserve HTTP servers after classification.
1349
+ const rebasedDocument = workspace.documents[name];
1350
+ if (isOpenApi && isOpenApiDocument(rebasedDocument) && !mergedHasServers && activeHasServers) {
1351
+ rebasedDocument.servers = deepClone(activeServers);
1352
+ }
1291
1353
  },
1292
1354
  };
1293
1355
  },