@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
@@ -67,7 +67,7 @@ export const buildRequestBody = (requestBody,
67
67
  /** The key of the current example */
68
68
  exampleName = 'default',
69
69
  /** Selected anyOf/oneOf request-body variants keyed by schema path */
70
- requestBodyCompositionSelection, openapiVersion) => {
70
+ requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect) => {
71
71
  if (!requestBody) {
72
72
  return null;
73
73
  }
@@ -77,7 +77,7 @@ requestBodyCompositionSelection, openapiVersion) => {
77
77
  return null;
78
78
  }
79
79
  /** An example value */
80
- const example = getExampleFromBody(requestBody, bodyContentType, exampleName, requestBodyCompositionSelection, openapiVersion);
80
+ const example = getExampleFromBody(requestBody, bodyContentType, exampleName, requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect);
81
81
  if (!example) {
82
82
  return null;
83
83
  }
@@ -10,9 +10,9 @@ import type { ExampleObject, RequestBodyObject } from '@scalar/workspace-store/s
10
10
  *
11
11
  * Returns `undefined` when there is no schema for the content type.
12
12
  */
13
- export declare const getSchemaExampleFromBody: (requestBody: RequestBodyObject, contentType: string, requestBodyCompositionSelection?: Record<string, number>, openapiVersion?: string) => unknown;
13
+ export declare const getSchemaExampleFromBody: (requestBody: RequestBodyObject, contentType: string, requestBodyCompositionSelection?: Record<string, number>, openapiVersion?: string, jsonSchemaDialect?: string) => unknown;
14
14
  /**
15
15
  * Basically getExample + we generate an example from the schema if no example is found
16
16
  */
17
- export declare const getExampleFromBody: (requestBody: RequestBodyObject, contentType: string, exampleName: string, requestBodyCompositionSelection?: Record<string, number>, openapiVersion?: string) => ExampleObject | null;
17
+ export declare const getExampleFromBody: (requestBody: RequestBodyObject, contentType: string, exampleName: string, requestBodyCompositionSelection?: Record<string, number>, openapiVersion?: string, jsonSchemaDialect?: string) => ExampleObject | null;
18
18
  //# sourceMappingURL=get-request-body-example.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-request-body-example.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/get-request-body-example.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAElB,MAAM,8DAA8D,CAAA;AAUrE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,gBACtB,iBAAiB,eACjB,MAAM,oCACe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACvC,MAAM,KACtB,OA8BF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,gBAChB,iBAAiB,eACjB,MAAM,eACN,MAAM,oCACe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACvC,MAAM,KACtB,aAAa,GAAG,IA4ClB,CAAA"}
1
+ {"version":3,"file":"get-request-body-example.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/body/get-request-body-example.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAElB,MAAM,8DAA8D,CAAA;AAUrE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,gBACtB,iBAAiB,eACjB,MAAM,oCACe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACvC,MAAM,sBACH,MAAM,KACzB,OAiCF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,gBAChB,iBAAiB,eACjB,MAAM,eACN,MAAM,oCACe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,mBACvC,MAAM,sBACH,MAAM,KACzB,aAAa,GAAG,IA8ClB,CAAA"}
@@ -18,7 +18,7 @@ import { getXmlBodyExample } from '../../xml/get-xml-body-example.js';
18
18
  *
19
19
  * Returns `undefined` when there is no schema for the content type.
20
20
  */
21
- export const getSchemaExampleFromBody = (requestBody, contentType, requestBodyCompositionSelection, openapiVersion) => {
21
+ export const getSchemaExampleFromBody = (requestBody, contentType, requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect) => {
22
22
  const mediaType = requestBody.content?.[contentType];
23
23
  const schema = mediaType?.schema ??
24
24
  (mediaType?.itemSchema && parseMimeType(contentType).type === 'multipart'
@@ -27,6 +27,7 @@ export const getSchemaExampleFromBody = (requestBody, contentType, requestBodyCo
27
27
  if (isXmlMediaType(contentType)) {
28
28
  return getXmlBodyExample(mediaType?.schema, undefined, {
29
29
  openapiVersion,
30
+ jsonSchemaDialect,
30
31
  mode: 'write',
31
32
  compositionSelection: requestBodyCompositionSelection,
32
33
  schemaPath: ['requestBody'],
@@ -37,6 +38,8 @@ export const getSchemaExampleFromBody = (requestBody, contentType, requestBodyCo
37
38
  }
38
39
  const value = getExampleFromSchema(snapshotSchema(schema), {
39
40
  mode: 'write',
41
+ openapiVersion,
42
+ jsonSchemaDialect,
40
43
  compositionSelection: requestBodyCompositionSelection,
41
44
  }, {
42
45
  schemaPath: ['requestBody'],
@@ -46,7 +49,7 @@ export const getSchemaExampleFromBody = (requestBody, contentType, requestBodyCo
46
49
  /**
47
50
  * Basically getExample + we generate an example from the schema if no example is found
48
51
  */
49
- export const getExampleFromBody = (requestBody, contentType, exampleName, requestBodyCompositionSelection, openapiVersion) => {
52
+ export const getExampleFromBody = (requestBody, contentType, exampleName, requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect) => {
50
53
  // Return the existing example when it carries a usable value. An example that only has an
51
54
  // `externalValue` (not yet resolved to a `value`) is treated as missing, so we fall back to a
52
55
  // schema-generated example instead of building an empty request body.
@@ -54,6 +57,7 @@ export const getExampleFromBody = (requestBody, contentType, exampleName, reques
54
57
  if (isXmlMediaType(contentType)) {
55
58
  const result = getXmlBodyExample(requestBody.content?.[contentType]?.schema, example, {
56
59
  openapiVersion,
60
+ jsonSchemaDialect,
57
61
  mode: 'write',
58
62
  compositionSelection: requestBodyCompositionSelection,
59
63
  schemaPath: ['requestBody'],
@@ -77,7 +81,7 @@ export const getExampleFromBody = (requestBody, contentType, exampleName, reques
77
81
  return selected.source === 'value' ? example : { ...example, value: selected.value };
78
82
  }
79
83
  // Generate an example from the schema
80
- const schemaExample = getSchemaExampleFromBody(requestBody, contentType, requestBodyCompositionSelection, openapiVersion);
84
+ const schemaExample = getSchemaExampleFromBody(requestBody, contentType, requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect);
81
85
  if (schemaExample === undefined || schemaExample === null) {
82
86
  return null;
83
87
  }
@@ -0,0 +1,15 @@
1
+ /** Dialects whose direct array assertions this generator understands. */
2
+ type ArrayDialect = 'modern' | 'draft7' | 'unsupported';
3
+ type Primitive = string | number | boolean | null;
4
+ /** Unknown dialects and pre-3.1 OpenAPI must not acquire modern contains semantics. */
5
+ export declare const getArrayDialect: (dialect?: string, openapiVersion?: string) => ArrayDialect;
6
+ /**
7
+ * Fill direct primitive arrays with a single contains rule. Tuple values count toward the same
8
+ * limits as tail values. Candidates are bounded and selected linearly; no composition traversal,
9
+ * nested value synthesis, or XML branch selection is attempted. Unsupported schemas return undefined
10
+ * for the existing generator. Contradictions or exhausted candidates return a partial example.
11
+ * TODO: Handle independent contains rules across references and compositions in a follow-up.
12
+ */
13
+ export declare const generateContainsArray: (schema: Record<string, unknown>, prefixes: unknown[], generate: (schema: unknown) => unknown, dialect: ArrayDialect) => Primitive[] | undefined;
14
+ export {};
15
+ //# sourceMappingURL=array-contains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array-contains.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/array-contains.ts"],"names":[],"mappings":"AAEA,yEAAyE;AACzE,KAAK,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,aAAa,CAAA;AACvD,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;AAEjD,uFAAuF;AACvF,eAAO,MAAM,eAAe,aAAc,MAAM,mBAAmB,MAAM,KAAG,YAY3E,CAAA;AAoGD;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,WACxB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YACrB,OAAO,EAAE,YACT,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,WAC7B,YAAY,KACpB,SAAS,EAAE,GAAG,SA8FhB,CAAA"}
@@ -0,0 +1,199 @@
1
+ import { isObject } from '@scalar/helpers/object/is-object';
2
+ /** Unknown dialects and pre-3.1 OpenAPI must not acquire modern contains semantics. */
3
+ export const getArrayDialect = (dialect, openapiVersion) => {
4
+ if (openapiVersion && !/^3\.[1-9](?:\.|$)/.test(openapiVersion)) {
5
+ return 'unsupported';
6
+ }
7
+ if (!dialect || /^https:\/\/spec\.openapis\.org\/oas\/3\.[12]\/dialect\/base#?$/.test(dialect)) {
8
+ return 'modern';
9
+ }
10
+ const uri = dialect.replace(/#$/, '');
11
+ if (uri === 'https://json-schema.org/draft/2020-12/schema') {
12
+ return 'modern';
13
+ }
14
+ return uri === 'http://json-schema.org/draft-07/schema' ? 'draft7' : 'unsupported';
15
+ };
16
+ const MAX_ITEMS = 999;
17
+ const MAX_CANDIDATES = 128;
18
+ const isPrimitive = (value) => value === null ||
19
+ typeof value === 'string' ||
20
+ typeof value === 'boolean' ||
21
+ (typeof value === 'number' && Number.isFinite(value));
22
+ const keywords = new Set([
23
+ '__scalar_',
24
+ '$status',
25
+ '$global',
26
+ 'type',
27
+ 'const',
28
+ 'enum',
29
+ 'minimum',
30
+ 'maximum',
31
+ 'exclusiveMinimum',
32
+ 'exclusiveMaximum',
33
+ 'minLength',
34
+ 'maxLength',
35
+ 'title',
36
+ 'description',
37
+ 'default',
38
+ 'example',
39
+ 'examples',
40
+ 'deprecated',
41
+ 'readOnly',
42
+ 'writeOnly',
43
+ 'xml',
44
+ 'externalDocs',
45
+ ]);
46
+ /** Complex assertions are left to the existing best-effort generator, never treated as nonmatches. */
47
+ const isSimple = (schema) => {
48
+ if (typeof schema === 'boolean') {
49
+ return true;
50
+ }
51
+ if (!isObject(schema) || Object.keys(schema).some((key) => !keywords.has(key) && !key.startsWith('x-'))) {
52
+ return false;
53
+ }
54
+ if (schema.type !== undefined &&
55
+ (typeof schema.type !== 'string' || !['string', 'number', 'integer', 'boolean', 'null'].includes(schema.type))) {
56
+ return false;
57
+ }
58
+ if ('const' in schema && !isPrimitive(schema.const)) {
59
+ return false;
60
+ }
61
+ return (!('enum' in schema) ||
62
+ (Array.isArray(schema.enum) && schema.enum.length <= MAX_CANDIDATES && schema.enum.every(isPrimitive)));
63
+ };
64
+ const bound = (value, fallback) => typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : fallback;
65
+ const matches = (schema, value) => {
66
+ if (typeof schema === 'boolean') {
67
+ return schema;
68
+ }
69
+ if ('const' in schema && value !== schema.const) {
70
+ return false;
71
+ }
72
+ if (Array.isArray(schema.enum) && !schema.enum.includes(value)) {
73
+ return false;
74
+ }
75
+ if (schema.type !== undefined) {
76
+ const type = value === null ? 'null' : typeof value;
77
+ if (schema.type === 'integer' ? typeof value !== 'number' || !Number.isInteger(value) : schema.type !== type) {
78
+ return false;
79
+ }
80
+ }
81
+ if (typeof value === 'number') {
82
+ if (typeof schema.minimum === 'number' && value < schema.minimum) {
83
+ return false;
84
+ }
85
+ if (typeof schema.maximum === 'number' && value > schema.maximum) {
86
+ return false;
87
+ }
88
+ if (typeof schema.exclusiveMinimum === 'number' && value <= schema.exclusiveMinimum) {
89
+ return false;
90
+ }
91
+ if (typeof schema.exclusiveMaximum === 'number' && value >= schema.exclusiveMaximum) {
92
+ return false;
93
+ }
94
+ }
95
+ if (typeof value === 'string') {
96
+ const length = Array.from(value).length;
97
+ if (length < bound(schema.minLength, 0) || length > bound(schema.maxLength, Number.POSITIVE_INFINITY)) {
98
+ return false;
99
+ }
100
+ }
101
+ return true;
102
+ };
103
+ /**
104
+ * Fill direct primitive arrays with a single contains rule. Tuple values count toward the same
105
+ * limits as tail values. Candidates are bounded and selected linearly; no composition traversal,
106
+ * nested value synthesis, or XML branch selection is attempted. Unsupported schemas return undefined
107
+ * for the existing generator. Contradictions or exhausted candidates return a partial example.
108
+ * TODO: Handle independent contains rules across references and compositions in a follow-up.
109
+ */
110
+ export const generateContainsArray = (schema, prefixes, generate, dialect) => {
111
+ if (dialect === 'unsupported' || !('contains' in schema) || !isSimple(schema.contains)) {
112
+ return undefined;
113
+ }
114
+ if (schema.allOf || schema.anyOf || schema.oneOf || schema.$ref) {
115
+ return undefined;
116
+ }
117
+ const contains = schema.contains;
118
+ const items = schema.items ?? true;
119
+ const tuple = dialect === 'modern' && Array.isArray(schema.prefixItems) ? schema.prefixItems : [];
120
+ if (!isSimple(items) || !tuple.every(isSimple) || (dialect === 'draft7' && schema.prefixItems)) {
121
+ return undefined;
122
+ }
123
+ const minimum = dialect === 'modern' ? bound(schema.minContains, 1) : 1;
124
+ const maximum = dialect === 'modern' ? bound(schema.maxContains, Number.POSITIVE_INFINITY) : Number.POSITIVE_INFINITY;
125
+ const maxItems = Math.min(bound(schema.maxItems, MAX_ITEMS), MAX_ITEMS);
126
+ const length = Math.min(maxItems, Math.max(bound(schema.minItems, 0), minimum, prefixes.length));
127
+ const values = [];
128
+ const candidates = [];
129
+ const add = (value) => {
130
+ if (isPrimitive(value) && candidates.length < MAX_CANDIDATES && !candidates.includes(value)) {
131
+ candidates.push(value);
132
+ }
133
+ };
134
+ // Authored item examples remain fixed even when they cannot satisfy the array constraints.
135
+ const unrestricted = items === true ||
136
+ (isObject(items) && !['type', 'const', 'enum', 'example', 'examples', 'default'].some((key) => key in items));
137
+ const sampleSchema = unrestricted ? contains : items;
138
+ const generatedSample = typeof sampleSchema === 'boolean' ? null : generate(sampleSchema);
139
+ const sample = unrestricted ? (generatedSample ?? null) : generatedSample;
140
+ const authored = isObject(items) && (items.example !== undefined || (Array.isArray(items.examples) && items.examples.length > 0));
141
+ add(sample);
142
+ if (!authored) {
143
+ for (const source of [contains, items]) {
144
+ if (!isObject(source)) {
145
+ continue;
146
+ }
147
+ if ('const' in source) {
148
+ add(source.const);
149
+ }
150
+ if (Array.isArray(source.enum)) {
151
+ source.enum.forEach(add);
152
+ }
153
+ add(generate(source));
154
+ for (const key of ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum']) {
155
+ const limit = source[key];
156
+ if (typeof limit === 'number') {
157
+ for (const offset of [0, 1, -1]) {
158
+ add(limit + offset);
159
+ }
160
+ }
161
+ }
162
+ }
163
+ for (const value of [null, 1, 2, 3, 0, -1, true, false, '', 'string', 'a']) {
164
+ add(value);
165
+ }
166
+ for (let index = 4; index < 32; index++) {
167
+ add(index);
168
+ add(`string${index}`);
169
+ }
170
+ }
171
+ const available = authored ? candidates : candidates.filter((value) => matches(items, value));
172
+ let count = 0;
173
+ const append = (value) => {
174
+ const match = matches(contains, value);
175
+ if ((!authored && match && count >= maximum) || (schema.uniqueItems === true && values.includes(value))) {
176
+ return false;
177
+ }
178
+ values.push(value);
179
+ count += Number(match);
180
+ return true;
181
+ };
182
+ for (const [index, value] of prefixes.slice(0, maxItems).entries()) {
183
+ if (!isPrimitive(value) || !matches(tuple[index] ?? true, value) || !append(value)) {
184
+ return values;
185
+ }
186
+ }
187
+ if (items === false || (sample === undefined && typeof items !== 'boolean')) {
188
+ return values;
189
+ }
190
+ while (values.length < maxItems && (values.length < length || (!authored && count < minimum))) {
191
+ const candidate = available.find((value) => (authored || count >= minimum || matches(contains, value)) &&
192
+ (authored || !matches(contains, value) || count < maximum) &&
193
+ (schema.uniqueItems !== true || !values.includes(value)));
194
+ if (candidate === undefined || !append(candidate)) {
195
+ break;
196
+ }
197
+ }
198
+ return values;
199
+ };
@@ -5,6 +5,12 @@ import { EXAMPLE_EVALUATION, type ExampleEvaluationState } from './example-evalu
5
5
  export declare const selectExampleComposition: (schema: SchemaObject, schemaPath: string[], options?: GetExampleFromSchemaOptions, arrayItem?: boolean, value?: Record<string, unknown>) => SchemaObject | undefined;
6
6
  /** Options shared by data generation and schema-aware serializers. */
7
7
  export type GetExampleFromSchemaOptions = {
8
+ /** Declared document version; absent means a standalone modern schema. */
9
+ openapiVersion?: string;
10
+ /** Original version when a loader upgraded the document. */
11
+ originalOpenapiVersion?: string;
12
+ /** Default dialect, overridden by a schema resource's $schema. */
13
+ jsonSchemaDialect?: string;
8
14
  /** Internal provenance capture, excluded from persistent result caches. */
9
15
  [EXAMPLE_EVALUATION]?: ExampleEvaluationState;
10
16
  /** Preserve binary filename examples as File objects for multipart serializers. */
@@ -1 +1 @@
1
- {"version":3,"file":"get-example-from-schema.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/get-example-from-schema.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAM5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,OAAO,EAAE,kBAAkB,EAA0B,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAob9G,gGAAgG;AAChG,eAAO,MAAM,wBAAwB,WAC3B,YAAY,cACR,MAAM,EAAE,YACV,2BAA2B,+BAE7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,YAAY,GAAG,SAoBjB,CAAA;AA6tBD,sEAAsE;AACtE,MAAM,MAAM,2BAA2B,GAAG;IACxC,2EAA2E;IAC3E,CAAC,kBAAkB,CAAC,CAAC,EAAE,sBAAsB,CAAA;IAC7C,mFAAmF;IACnF,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kFAAkF;IAClF,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,qDAAqD;IACrD,8BAA8B,CAAC,EAAE,OAAO,CAAA;IACxC,0DAA0D;IAC1D,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC9C,CAAA;AA6fD;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,yBAAyB,WACrB,YAAY,YACV,2BAA2B,sGAUlC,OAAO,CAAC;IACT,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,YAAY,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IACrB,6EAA6E;IAC7E,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,qGAAqG;IACrG,YAAY,EAAE,YAAY,CAAA;IAC1B,4FAA4F;IAC5F,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAClC,+GAA+G;IAC/G,kBAAkB,EAAE,OAAO,CAAA;CAC5B,CAAC,KACD,OAgTF,CAAA;AAkBD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,WACvB,YAAY,YACV,2BAA2B,YAC5B,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,KACvD,OA2BF,CAAA"}
1
+ {"version":3,"file":"get-example-from-schema.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/get-example-from-schema.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAM5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAG1E,OAAO,EAAE,kBAAkB,EAA0B,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAob9G,gGAAgG;AAChG,eAAO,MAAM,wBAAwB,WAC3B,YAAY,cACR,MAAM,EAAE,YACV,2BAA2B,+BAE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,OAAO,CAAA;CAC5B,CAAC,KACD,OAoTF,CAAA;AAkBD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,WACvB,YAAY,YACV,2BAA2B,YAC5B,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,KACvD,OA8BF,CAAA"}
@@ -9,6 +9,7 @@ import { isFileSchema } from '../../../helpers/is-file-schema.js';
9
9
  import { resolveFormSchema } from '../../../helpers/resolve-form-schema.js';
10
10
  import { unpackProxyObject } from '../../../helpers/unpack-proxy.js';
11
11
  import { resolve } from '../../../resolve.js';
12
+ import { generateContainsArray, getArrayDialect } from './array-contains.js';
12
13
  import { EXAMPLE_EVALUATION } from './example-evaluation.js';
13
14
  /** Maximum recursion depth to prevent infinite loops in circular references */
14
15
  const MAX_LEVELS_DEEP = 10;
@@ -759,6 +760,20 @@ const handleArraySchema = (schema, options, level, seen, cacheKey, schemaPath, d
759
760
  seen,
760
761
  dynamicScope: childScope,
761
762
  })) ?? [];
763
+ const counted = generateContainsArray(schema, values, (item) => getExampleFromSchema(item, options, {
764
+ level: level + 1,
765
+ schemaPath: [...schemaPath, 'items'],
766
+ seen,
767
+ dynamicScope: childScope,
768
+ }), getArrayDialect(options?.jsonSchemaDialect, options?.originalOpenapiVersion ?? options?.openapiVersion));
769
+ if (counted) {
770
+ const items = 'items' in schema ? resolve.schema(schema.items) : undefined;
771
+ const tag = items && 'xml' in items ? items.xml?.name : undefined;
772
+ const result = options?.xml && 'xml' in schema && schema.xml?.wrapped && tag
773
+ ? counted.map((item, index) => (index < (prefixes?.length ?? 0) ? item : { [tag]: item }))
774
+ : counted;
775
+ return cache(schema, result, cacheKey, skipCache);
776
+ }
762
777
  if (prefixes && values.length >= minItems) {
763
778
  return cache(schema, values, cacheKey, skipCache);
764
779
  }
@@ -887,11 +902,15 @@ const handleArraySchema = (schema, options, level, seen, cacheKey, schemaPath, d
887
902
  const unrestricted = itemSchema === undefined ||
888
903
  target === true ||
889
904
  (target !== undefined && items && Object.keys(items).every((key) => ITEM_ANNOTATIONS.has(key)));
890
- // The strict model does not yet expose contains, but runtime 3.1+ descriptions can provide it.
905
+ // Preserve best-effort sampling for complex contains schemas in recognized dialects.
906
+ // This fallback does not grade matches or enforce minContains/maxContains.
891
907
  const contains = 'contains' in schema && schema.contains && typeof schema.contains === 'object' && !Array.isArray(schema.contains)
892
908
  ? resolve.schema(schema.contains)
893
909
  : undefined;
894
- if (unrestricted && contains) {
910
+ if (unrestricted &&
911
+ contains &&
912
+ getArrayDialect(options?.jsonSchemaDialect, options?.originalOpenapiVersion ?? options?.openapiVersion) !==
913
+ 'unsupported') {
895
914
  const sample = getExampleFromSchema(contains, options, {
896
915
  level: level + 1,
897
916
  schemaPath: [...schemaPath, 'contains'],
@@ -950,6 +969,9 @@ const getUnionPrimitiveValue = (schema, makeUpRandomData, emptyString) => {
950
969
  };
951
970
  /** Create stable cache key from the options object */
952
971
  const createOptionsCacheKey = (options) => JSON.stringify({
972
+ openapiVersion: options?.openapiVersion,
973
+ originalOpenapiVersion: options?.originalOpenapiVersion,
974
+ jsonSchemaDialect: options?.jsonSchemaDialect,
953
975
  binaryAsFile: options?.binaryAsFile,
954
976
  emptyString: options?.emptyString,
955
977
  xml: options?.xml,
@@ -1380,6 +1402,9 @@ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, n
1380
1402
  if (!isDefined(_schema)) {
1381
1403
  return undefined;
1382
1404
  }
1405
+ if (typeof _schema.$schema === 'string') {
1406
+ options = { ...options, jsonSchemaDialect: _schema.$schema };
1407
+ }
1383
1408
  // Resolve a `$dynamicRef` against the active dynamic scope, then continue with the bound schema.
1384
1409
  // When nothing matches, fall through and render the reference as before (no regression).
1385
1410
  if (isDynamicRef(_schema)) {
@@ -1643,6 +1668,9 @@ const asBinaryFile = (schema, value, options, schemaPath = []) => {
1643
1668
  * Treat returned values as read-only: cached results and padded items can share object references.
1644
1669
  */
1645
1670
  export const getExampleFromSchema = (schema, options, context = {}) => {
1671
+ if (schema && typeof schema === 'object' && '$schema' in schema && typeof schema.$schema === 'string') {
1672
+ options = { ...options, jsonSchemaDialect: schema.$schema };
1673
+ }
1646
1674
  const capture = options?.[EXAMPLE_EVALUATION];
1647
1675
  if (!capture) {
1648
1676
  const value = generateExampleFromSchema(schema, options, context);
@@ -185,7 +185,7 @@ export type RequestFactory = {
185
185
  * Builds a request object fastory which can be used to build a request object.
186
186
  * @returns A request object factory
187
187
  */
188
- export declare const requestFactory: ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, openapiVersion, requestBodyCompositionSelection, }: RequestExampleMeta & {
188
+ export declare const requestFactory: ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, openapiVersion, jsonSchemaDialect, requestBodyCompositionSelection, }: RequestExampleMeta & {
189
189
  /** The operation object */
190
190
  operation: OperationObject;
191
191
  /** For environment variables in the inputs */
@@ -205,6 +205,8 @@ export declare const requestFactory: ({ exampleName, globalCookies, method, oper
205
205
  /** Selected anyOf/oneOf request-body variants keyed by schema path */
206
206
  /** Originating OpenAPI version, used for version-specific serialization. */
207
207
  openapiVersion?: string;
208
+ /** Document default for schema resources without $schema. */
209
+ jsonSchemaDialect?: string;
208
210
  requestBodyCompositionSelection?: Record<string, number>;
209
211
  }) => {
210
212
  request: RequestFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"request-factory.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/request-factory.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAE5F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAA;AA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AAa,EAAE,CAAA;IAExB;;;OAGG;IACH,KAAK,EAAE,YAAY,CAAA;IAEnB;;;;OAIG;IACH,QAAQ,EAAE,0BAA0B,EAAE,CAAA;IAEtC;;;OAGG;IACH,8BAA8B,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAE5C;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;QACf;;;WAGG;QACH,UAAU,EAAE,OAAO,CAAA;QACnB;;;WAGG;QACH,eAAe,EAAE,OAAO,CAAA;KACzB,CAAC,CAAA;CACH,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,qLAaxB,kBAAkB,GAAG;IACtB,2BAA2B;IAC3B,SAAS,EAAE,eAAe,CAAA;IAC1B,8CAA8C;IAC9C,WAAW,EAAE,kBAAkB,CAAA;IAC/B,mCAAmC;IACnC,aAAa,EAAE,aAAa,EAAE,CAAA;IAC9B,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAA;IAChB,wBAAwB;IACxB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,qEAAqE;IACrE,UAAU,EAAE,OAAO,CAAA;IACnB,8DAA8D;IAC9D,uBAAuB,EAAE,0BAA0B,EAAE,CAAA;IACrD,sEAAsE;IACtE,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACzD,KAAG;IACF,OAAO,EAAE,cAAc,CAAA;CA8ExB,CAAA"}
1
+ {"version":3,"file":"request-factory.d.ts","sourceRoot":"","sources":["../../../src/request-example/builder/request-factory.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAA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FxB,CAAA"}
@@ -12,14 +12,16 @@ import { buildRequestParameters } from './header/build-request-parameters.js';
12
12
  * Builds a request object fastory which can be used to build a request object.
13
13
  * @returns A request object factory
14
14
  */
15
- export const requestFactory = ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, openapiVersion, requestBodyCompositionSelection, }) => {
15
+ export const requestFactory = ({ exampleName, globalCookies, method, operation, path, proxyUrl, server, defaultHeaders, isElectron, selectedSecuritySchemes, openapiVersion, jsonSchemaDialect, requestBodyCompositionSelection, }) => {
16
16
  const requestBody = getResolvedRef(operation.requestBody);
17
17
  /** Build out the request parameters */
18
18
  const params = buildRequestParameters(operation.parameters ?? [], exampleName, openapiVersion);
19
19
  const querystringParameter = operation.parameters
20
20
  ?.map((parameter) => getResolvedRef(parameter))
21
21
  .find((parameter) => parameter?.in === 'querystring');
22
- const querystring = querystringParameter ? getQuerystringParameter(querystringParameter, exampleName) : undefined;
22
+ const querystring = querystringParameter
23
+ ? getQuerystringParameter(querystringParameter, exampleName, { openapiVersion, jsonSchemaDialect })
24
+ : undefined;
23
25
  const security = buildRequestSecurity(selectedSecuritySchemes);
24
26
  const headers = new Headers({
25
27
  ...filterDisabledDefaultHeaders(operation, exampleName, defaultHeaders),
@@ -27,7 +29,7 @@ export const requestFactory = ({ exampleName, globalCookies, method, operation,
27
29
  });
28
30
  // If the method can have a body, build the request body, otherwise set it to null
29
31
  const body = canMethodHaveBody(method)
30
- ? buildRequestBody(requestBody, exampleName, requestBodyCompositionSelection, openapiVersion)
32
+ ? buildRequestBody(requestBody, exampleName, requestBodyCompositionSelection, openapiVersion, jsonSchemaDialect)
31
33
  : null;
32
34
  // Delete the Content-Type header so the browser will set it automatically based on the request body
33
35
  if (body?.mode === 'formdata' || body?.mode === 'urlencoded') {
@@ -250,6 +250,29 @@ export type TraversedModels = BaseSchema & {
250
250
  name: string;
251
251
  children?: TraversedEntry[];
252
252
  };
253
+ export declare const TraversedPluginEntrySchemaDefinition: import("@scalar/typebox").TIntersect<[import("@scalar/typebox").TObject<{
254
+ id: import("@scalar/typebox").TString;
255
+ title: import("@scalar/typebox").TString;
256
+ }>, import("@scalar/typebox").TObject<{
257
+ type: import("@scalar/typebox").TLiteral<"plugin">;
258
+ documentType: import("@scalar/typebox").TString;
259
+ kind: import("@scalar/typebox").TOptional<import("@scalar/typebox").TString>;
260
+ children: import("@scalar/typebox").TOptional<import("@scalar/typebox").TArray<import("@scalar/typebox").TRef<"TraversedEntryObject">>>;
261
+ }>]>;
262
+ /**
263
+ * An entry contributed by a registered document type (see `DocumentTypeDefinition`).
264
+ *
265
+ * The store and sidebar only rely on the base fields; `kind` lets the document type tell its own
266
+ * entries apart (e.g. a workflow and a step) when it renders them.
267
+ */
268
+ export type TraversedPluginEntry = BaseSchema & {
269
+ type: 'plugin';
270
+ /** The document type that produced the entry */
271
+ documentType: string;
272
+ /** Free-form discriminator owned by the document type */
273
+ kind?: string;
274
+ children?: TraversedEntry[];
275
+ };
253
276
  export declare const TraversedEntrySchemaDefinition: import("@scalar/typebox").TUnion<[import("@scalar/typebox").TIntersect<[import("@scalar/typebox").TObject<{
254
277
  id: import("@scalar/typebox").TString;
255
278
  title: import("@scalar/typebox").TString;
@@ -341,8 +364,16 @@ export declare const TraversedEntrySchemaDefinition: import("@scalar/typebox").T
341
364
  type: import("@scalar/typebox").TLiteral<"models">;
342
365
  name: import("@scalar/typebox").TString;
343
366
  children: import("@scalar/typebox").TOptional<import("@scalar/typebox").TArray<import("@scalar/typebox").TRef<"TraversedEntryObject">>>;
367
+ }>]>, import("@scalar/typebox").TIntersect<[import("@scalar/typebox").TObject<{
368
+ id: import("@scalar/typebox").TString;
369
+ title: import("@scalar/typebox").TString;
370
+ }>, import("@scalar/typebox").TObject<{
371
+ type: import("@scalar/typebox").TLiteral<"plugin">;
372
+ documentType: import("@scalar/typebox").TString;
373
+ kind: import("@scalar/typebox").TOptional<import("@scalar/typebox").TString>;
374
+ children: import("@scalar/typebox").TOptional<import("@scalar/typebox").TArray<import("@scalar/typebox").TRef<"TraversedEntryObject">>>;
344
375
  }>]>]>;
345
- export type TraversedEntry = TraversedDescription | TraversedOperation | TraversedAsyncApiOperation | TraversedAsyncApiChannel | TraversedAsyncApiMessage | TraversedSchema | TraversedTag | TraversedWebhook | TraversedExample | TraversedDocument | TraversedModels;
376
+ export type TraversedEntry = TraversedDescription | TraversedOperation | TraversedAsyncApiOperation | TraversedAsyncApiChannel | TraversedAsyncApiMessage | TraversedSchema | TraversedTag | TraversedWebhook | TraversedExample | TraversedDocument | TraversedModels | TraversedPluginEntry;
346
377
  /**
347
378
  * Type helper for when we are storing the parent entry in the entry itself.
348
379
  * The parent is recursively defined to also include its own parent, except for
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/schemas/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAG7C,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAA;AAC/F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAEtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAE1D;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;AAE9D,eAAO,MAAM,8BAA8B;;;EAGzC,CAAA;AAEF,KAAK,UAAU,GAAG;IAChB;;;;OAIG;IACH,EAAE,EAAE,MAAM,CAAA;IACV,2CAA2C;IAC3C,KAAK,EAA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IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,kBAAkB,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,gBAAgB,GACxB,eAAe,GACf,kBAAkB,GAClB,QAAQ,GACR,cAAc,GACd,sBAAsB,GACtB,oBAAoB,GACpB,oBAAoB,GACpB,YAAY,GACZ,UAAU,GACV,YAAY,CAAA;AAEhB,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,MAAM,CAAA"}
@@ -74,6 +74,12 @@ export const TraversedModelsSchemaDefinition = compose(NavigationBaseSchemaDefin
74
74
  name: Type.String(),
75
75
  children: Type.Optional(Type.Array(TraversedEntryObjectRef)),
76
76
  }));
77
+ export const TraversedPluginEntrySchemaDefinition = compose(NavigationBaseSchemaDefinition, Type.Object({
78
+ type: Type.Literal('plugin'),
79
+ documentType: Type.String(),
80
+ kind: Type.Optional(Type.String()),
81
+ children: Type.Optional(Type.Array(TraversedEntryObjectRef)),
82
+ }));
77
83
  export const TraversedEntrySchemaDefinition = Type.Union([
78
84
  TraversedDescriptionSchemaDefinition,
79
85
  TraversedOperationSchemaDefinition,
@@ -86,4 +92,5 @@ export const TraversedEntrySchemaDefinition = Type.Union([
86
92
  TraversedExampleSchemaDefinition,
87
93
  TraversedDocumentSchemaDefinition,
88
94
  TraversedModelsSchemaDefinition,
95
+ TraversedPluginEntrySchemaDefinition,
89
96
  ]);
@@ -0,0 +1,67 @@
1
+ import type { UnknownObject } from '../helpers/general.js';
2
+ import type { TraversedEntry } from './navigation.js';
3
+ import type { OpenAPIExtensions } from './v3.2/strict/openapi-document.js';
4
+ /** Document extension that marks a document as owned by a registered document type. */
5
+ export declare const PLUGIN_DOCUMENT_TYPE_KEY = "x-scalar-document-type";
6
+ /**
7
+ * A document whose format is not built into the store (OpenAPI and AsyncAPI are).
8
+ *
9
+ * The store treats the content as opaque: it keeps the document as ingested, adds the bookkeeping
10
+ * extensions every workspace document carries, and leaves the rest to the registered document type.
11
+ */
12
+ export type PluginDocument = Omit<OpenAPIExtensions, 'x-original-oas-version'> & {
13
+ /** The `type` of the document type definition that claimed this document. */
14
+ 'x-scalar-document-type': string;
15
+ /**
16
+ * Document metadata. Taken from the format's own `info` object when it has one (Arazzo and Overlay do);
17
+ * otherwise the store adds an empty one, so every workspace document exposes `info`.
18
+ */
19
+ info: {
20
+ title?: string;
21
+ version?: string;
22
+ description?: string;
23
+ } & Record<string, unknown>;
24
+ } & Record<string, unknown>;
25
+ /**
26
+ * Teaches the workspace store about a document format it does not support natively.
27
+ *
28
+ * A registered type is checked before the built-in OpenAPI and AsyncAPI pipelines, so a document it
29
+ * claims never goes through the OpenAPI upgrade or coercion.
30
+ */
31
+ export type DocumentTypeDefinition = {
32
+ /** Stable identifier stored on every claimed document as `x-scalar-document-type`. */
33
+ type: string;
34
+ /** Whether this definition handles the raw (parsed) input document. */
35
+ detect: (document: UnknownObject) => boolean;
36
+ /**
37
+ * Optional hook to upgrade, validate or normalize the raw document before it is stored.
38
+ * Receives a clone, so it may mutate and return the same object.
39
+ */
40
+ ingest?: (document: UnknownObject, context: {
41
+ documentName: string;
42
+ }) => UnknownObject | Promise<UnknownObject>;
43
+ /**
44
+ * Resolve `$ref`s with the store's loaders (fetch, file loader) before storing the document.
45
+ * Defaults to `false`, since the reference semantics of a foreign format are not known to the store.
46
+ */
47
+ bundle?: boolean;
48
+ /**
49
+ * Build the sidebar entries for the document. The store wraps them in the document root entry.
50
+ * Ids must be unique across the workspace, so prefix them with the given `documentId`.
51
+ */
52
+ traverse: (context: {
53
+ documentName: string;
54
+ documentId: string;
55
+ document: PluginDocument;
56
+ }) => TraversedEntry[];
57
+ };
58
+ /** Narrow a value to a document claimed by a registered document type. */
59
+ export declare const isPluginDocument: (value: unknown) => value is PluginDocument;
60
+ /**
61
+ * Find the registered document type that claims a raw document, if any.
62
+ *
63
+ * Every document goes through `detect`, so one that throws counts as "not mine". Otherwise a bug in a
64
+ * single document type would stop OpenAPI and AsyncAPI documents from loading too.
65
+ */
66
+ export declare const findDocumentType: (documentTypes: readonly DocumentTypeDefinition[] | undefined, document: UnknownObject) => DocumentTypeDefinition | undefined;
67
+ //# sourceMappingURL=plugin-document.d.ts.map