@scalar/openapi-upgrader 0.4.11 → 0.5.1

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.
@@ -1,5 +1,8 @@
1
+ import { escapeJsonPointer } from '@scalar/helpers/json/escape-json-pointer';
2
+ import { parseJsonPointerSegments } from '@scalar/helpers/json/parse-json-pointer-segments';
3
+ import { isObject } from '@scalar/helpers/object/is-object';
1
4
  import { isSchemaPath } from '@scalar/helpers/openapi/is-schema-path';
2
- import { isInsideDataValue, isNamedSchemaMap } from '../helpers/is-inside-data-value.js';
5
+ import { isInsideDataValue, isNamedOpenApiMap, isNamedSchemaMap, isOpenApiObjectName, } from '../helpers/is-inside-data-value.js';
3
6
  import { traverse } from '../helpers/traverse.js';
4
7
  // Keywords that only describe a schema. An arm made of these and `nullable` constrains nothing else.
5
8
  const ANNOTATION_KEYWORDS = new Set([
@@ -13,21 +16,98 @@ const ANNOTATION_KEYWORDS = new Set([
13
16
  'readOnly',
14
17
  'writeOnly',
15
18
  ]);
16
- /**
17
- * Determine if the node at `path` is one arm of a `oneOf` or `anyOf`.
18
- *
19
- * Extension payloads can contain objects that look like union arms too. Only interpret unions
20
- * in schema context, keeping extension values opaque and allowing schema names prefixed by `x-`.
21
- */
22
- function isUnionArm(path) {
23
- if (!path || path.length < 2 || !isSchemaPath(path.slice(0, -2))) {
24
- return false;
19
+ /** Keep extension payloads opaque, including extensions outside Schema Objects. */
20
+ const isInsideExtension = (path) => {
21
+ const segments = path?.[0] === 'x-ext' && path[1] !== undefined ? path.slice(2) : path;
22
+ // This legacy root extension is migrated as a Webhooks Object below.
23
+ const objectPath = path?.[0] === 'x-webhooks' ? ['webhooks', ...path.slice(1)] : segments;
24
+ return (!!objectPath &&
25
+ objectPath.some((segment, index) => segment.startsWith('x-') &&
26
+ !isNamedSchemaMap(objectPath.slice(0, index)) &&
27
+ !isOpenApiObjectName(objectPath, index)));
28
+ };
29
+ /** Keep schema keywords separate from author-chosen names. */
30
+ const isSchemaObjectPath = (path) => !!path && isSchemaPath(path) && !isNamedSchemaMap(path) && !isInsideExtension(path);
31
+ /** Interpret referenced fragments at their consuming location and leave unrecognized extension data opaque. */
32
+ const getResourcePath = (path, bundle) => {
33
+ if (path?.[0] !== 'x-ext') {
34
+ return path;
35
+ }
36
+ for (let length = path.length; length >= 1; length--) {
37
+ const context = bundle.fragments.get(JSON.stringify(path.slice(0, length)));
38
+ if (context) {
39
+ return [...context, ...path.slice(length)];
40
+ }
41
+ }
42
+ return undefined;
43
+ };
44
+ /** Decode the URI fragment before parsing pointer tokens, without decoding literal percent signs twice. */
45
+ const parseLocalReference = (ref) => {
46
+ if (!ref.startsWith('#')) {
47
+ return undefined;
25
48
  }
26
- const isInsideSchemaExtension = path.some((segment, index) => {
27
- const parent = path.slice(0, index);
28
- return segment.startsWith('x-') && isSchemaPath(parent) && !isNamedSchemaMap(parent);
49
+ try {
50
+ const pointer = decodeURIComponent(ref.slice(1));
51
+ return pointer.startsWith('/') ? parseJsonPointerSegments(pointer.replaceAll('%', '%25')) : undefined;
52
+ }
53
+ catch {
54
+ // Invalid URI escapes must not make an otherwise unrelated migration fail.
55
+ return undefined;
56
+ }
57
+ };
58
+ /** Establish fragment contexts from real references, never from an extension's field names. */
59
+ const getBundleContext = (content) => {
60
+ const preserved = new Set();
61
+ const resources = content['x-ext'];
62
+ if (isObject(resources)) {
63
+ for (const [key, resource] of Object.entries(resources)) {
64
+ if (!isObject(resource)) {
65
+ continue;
66
+ }
67
+ if ((typeof resource.openapi === 'string' && !resource.openapi.startsWith('3.0')) ||
68
+ typeof resource.swagger === 'string' ||
69
+ typeof resource.$schema === 'string') {
70
+ preserved.add(key);
71
+ }
72
+ }
73
+ }
74
+ const fragments = new Map();
75
+ const bundle = { preserved, fragments };
76
+ const references = [];
77
+ traverse(content, (node, path = []) => {
78
+ if (path[0] === 'x-ext' && preserved.has(path[1] ?? '')) {
79
+ return node;
80
+ }
81
+ const target = typeof node.$ref === 'string' ? parseLocalReference(node.$ref) : undefined;
82
+ if (target?.[0] === 'x-ext') {
83
+ references.push({ path, target });
84
+ }
85
+ return node;
29
86
  });
30
- if (isInsideSchemaExtension) {
87
+ // A referenced fragment can itself contain references to more fragments.
88
+ while (references.length > 0) {
89
+ const pending = references.splice(0);
90
+ for (const reference of pending) {
91
+ const path = getResourcePath(reference.path, bundle);
92
+ if (path && !isInsideDataValue(path, '3.0') && !isInsideExtension(path)) {
93
+ const key = JSON.stringify(reference.target);
94
+ if (!fragments.has(key)) {
95
+ fragments.set(key, isSchemaObjectPath(path) ? ['schema'] : path);
96
+ }
97
+ }
98
+ else {
99
+ references.push(reference);
100
+ }
101
+ }
102
+ if (references.length === pending.length) {
103
+ break;
104
+ }
105
+ }
106
+ return bundle;
107
+ };
108
+ /** Determine if the node at `path` is one arm of a schema's `oneOf` or `anyOf`. */
109
+ function isUnionArm(path) {
110
+ if (!path || path.length < 2 || !isSchemaObjectPath(path.slice(0, -2))) {
31
111
  return false;
32
112
  }
33
113
  const keyword = path[path.length - 2];
@@ -40,6 +120,51 @@ function isUnionArm(path) {
40
120
  function isNullableOnly(schema) {
41
121
  return Object.keys(schema).every((key) => key === 'nullable' || ANNOTATION_KEYWORDS.has(key) || key.startsWith('x-'));
42
122
  }
123
+ /** Plan nullable composition wrapping consistently for migrations and reference locations. */
124
+ export const getNullableComposition = (schema) => {
125
+ if (schema.nullable !== true || schema.type !== undefined || typeof schema.$ref === 'string') {
126
+ return undefined;
127
+ }
128
+ const keywords = ['allOf', 'anyOf', 'oneOf'].filter((keyword) => Array.isArray(schema[keyword]));
129
+ if (keywords.length === 0) {
130
+ return undefined;
131
+ }
132
+ const { allOf, anyOf, oneOf } = schema;
133
+ const composition = {
134
+ ...(allOf === undefined ? {} : { allOf }),
135
+ ...(anyOf === undefined ? {} : { anyOf }),
136
+ ...(oneOf === undefined ? {} : { oneOf }),
137
+ };
138
+ const unwrapAllOf = Object.keys(composition).length === 1 && Array.isArray(allOf) && allOf.length === 1;
139
+ return { base: unwrapAllOf && Array.isArray(allOf) ? allOf[0] : composition, keywords, unwrapAllOf };
140
+ };
141
+ /** Keep local references pointing at the same subschema when composition members move. */
142
+ const relocateReference = (ref, compositions) => {
143
+ const segments = parseLocalReference(ref);
144
+ if (!segments) {
145
+ return ref;
146
+ }
147
+ const output = [];
148
+ for (let index = 0; index < segments.length; index++) {
149
+ const keyword = segments[index];
150
+ const composition = compositions.get(JSON.stringify(segments.slice(0, index)));
151
+ if (composition?.keywords.includes(keyword)) {
152
+ output.push('anyOf', '0');
153
+ if (keyword === 'allOf' && composition.unwrapAllOf && segments[index + 1] === '0') {
154
+ index++;
155
+ }
156
+ else {
157
+ output.push(keyword);
158
+ }
159
+ }
160
+ else {
161
+ output.push(keyword);
162
+ }
163
+ }
164
+ return output.every((segment, index) => segment === segments[index]) && output.length === segments.length
165
+ ? ref
166
+ : `#/${output.map((segment) => encodeURIComponent(escapeJsonPointer(segment))).join('/')}`;
167
+ };
43
168
  /**
44
169
  * Upgrade from OpenAPI 3.0.x to 3.1.1
45
170
  *
@@ -52,46 +177,65 @@ export function upgradeFromThreeToThreeOne(originalContent) {
52
177
  return content;
53
178
  }
54
179
  content.openapi = '3.1.1';
55
- // Single traversal that handles all transformations
56
- content = traverse(content, applyChangesToDocument);
180
+ const bundle = getBundleContext(content);
181
+ const isPreservedResource = (path) => path?.[0] === 'x-ext' && bundle.preserved.has(path[1] ?? '');
182
+ const compositions = new Map();
183
+ // Record moves in the original tree before applying them, including nested compositions.
184
+ traverse(content, (node, path = []) => {
185
+ const schemaPath = getResourcePath(path, bundle);
186
+ const composition = getNullableComposition(node);
187
+ if (!isPreservedResource(path) &&
188
+ composition &&
189
+ isSchemaObjectPath(schemaPath) &&
190
+ !isInsideDataValue(schemaPath, '3.0')) {
191
+ compositions.set(JSON.stringify(path), composition);
192
+ }
193
+ return node;
194
+ });
195
+ content = traverse(content, (node, path) => {
196
+ const schemaPath = getResourcePath(path, bundle);
197
+ if (isPreservedResource(path) || !schemaPath) {
198
+ return node;
199
+ }
200
+ if (typeof node.$ref === 'string' && !isInsideDataValue(schemaPath, '3.0') && !isInsideExtension(schemaPath)) {
201
+ node.$ref = relocateReference(node.$ref, compositions);
202
+ }
203
+ return applyChangesToDocument(node, schemaPath);
204
+ });
57
205
  return content;
58
206
  }
59
- const applyChangesToDocument = (schema, path) => {
60
- // 0. Bail out inside data values (example, default, const, enum). These hold user data, not a
61
- // schema, so none of the schema transforms below apply and running them would corrupt the data.
62
- if (isInsideDataValue(path, '3.0')) {
207
+ /** Apply one migration step to a node at its semantic OpenAPI location. */
208
+ export const applyChangesToDocument = (schema, path) => {
209
+ // Data values and extension payloads are opaque, even when their keys look like schema keywords.
210
+ if (isInsideDataValue(path, '3.0') || isInsideExtension(path)) {
63
211
  return schema;
64
212
  }
65
- // 1. Handle nullable types
66
- if (schema.type !== undefined && schema.nullable === true) {
67
- schema.type = [schema.type, 'null'];
213
+ // Only schema keywords migrate: a property named `nullable` or an extension payload is data.
214
+ if (isSchemaObjectPath(path)) {
215
+ const composition = getNullableComposition(schema);
216
+ if (schema.type !== undefined && schema.nullable === true) {
217
+ schema.type = [schema.type, 'null'];
218
+ }
219
+ else if (schema.nullable === true) {
220
+ // Preserve the legacy nullable-reference spelling used by OpenAPI 3.0 exporters.
221
+ if (typeof schema.$ref === 'string') {
222
+ schema.anyOf = [{ $ref: schema.$ref }, { type: 'null' }];
223
+ delete schema.$ref;
224
+ }
225
+ else if (composition) {
226
+ // Keep sibling constraints and annotations outside the union, as for nullable references.
227
+ schema.anyOf = [composition.base, { type: 'null' }];
228
+ delete schema.allOf;
229
+ delete schema.oneOf;
230
+ }
231
+ else if (isUnionArm(path) && isNullableOnly(schema)) {
232
+ // Some exporters use a nullable-only alternative to mean "or null".
233
+ schema.type = 'null';
234
+ }
235
+ }
236
+ // `nullable: false` and an untyped nullable without a union add no constraints in 3.1.
68
237
  delete schema.nullable;
69
238
  }
70
- // 1b. Handle nullable `$ref` patterns.
71
- // OpenAPI 3.0 had no way to mark a `$ref` as nullable, so people wrote `nullable: true` next to
72
- // a `$ref`, or next to an `allOf` wrapping one. `nullable` does not exist in 3.1, so leaving these
73
- // untouched would silently drop the null option. Rewrite them to the 3.1 null-union form. This only
74
- // runs when there is no sibling `type` (that case is handled above).
75
- else if (schema.nullable === true && schema.type === undefined) {
76
- if (typeof schema.$ref === 'string') {
77
- const { nullable: _nullable, $ref, ...rest } = schema;
78
- return { ...rest, anyOf: [{ $ref }, { type: 'null' }] };
79
- }
80
- if (Array.isArray(schema.allOf)) {
81
- const { nullable: _nullable, allOf, ...rest } = schema;
82
- // A single-member `allOf` unwraps so the union reads `anyOf: [<member>, { type: 'null' }]`.
83
- const base = allOf.length === 1 ? allOf[0] : { allOf };
84
- return { ...rest, anyOf: [base, { type: 'null' }] };
85
- }
86
- // A union arm that says nothing but `nullable: true` is how some 3.0 exporters spell "or null":
87
- // `oneOf: [{ nullable: true }, { $ref: X }]`. Left alone, the arm reads as "any value" in 3.1 and
88
- // swallows the real arm, so it becomes the `{ type: 'null' }` arm it was meant to be.
89
- if (isUnionArm(path) && isNullableOnly(schema)) {
90
- delete schema.nullable;
91
- schema.type = 'null';
92
- }
93
- // Otherwise there is nothing for `nullable` to attach to, so leave the schema untouched.
94
- }
95
239
  // 2. Handle exclusiveMinimum and exclusiveMaximum
96
240
  if (schema.exclusiveMinimum === true && schema.minimum !== undefined) {
97
241
  schema.exclusiveMinimum = schema.minimum;
@@ -114,13 +258,13 @@ const applyChangesToDocument = (schema, path) => {
114
258
  const isInsideExamplesMap = path?.some((segment, index) => {
115
259
  if (segment === 'examples' && index > 0) {
116
260
  // If the parent node is a named-schema map, 'examples' is a member name, not an examples map
117
- return !isNamedSchemaMap(path.slice(0, index));
261
+ return !isNamedSchemaMap(path.slice(0, index)) && !isNamedOpenApiMap(path.slice(0, index));
118
262
  }
119
263
  return false;
120
264
  });
121
265
  // If the current node is itself a map of named subschemas, a key called 'example' is a
122
266
  // member name (property, $defs entry, components/schemas entry) and not the schema keyword.
123
- if (schema.example !== undefined && !isInsideExamplesMap && !isNamedSchemaMap(path)) {
267
+ if (schema.example !== undefined && !isInsideExamplesMap && !isNamedSchemaMap(path) && !isNamedOpenApiMap(path)) {
124
268
  if (isSchemaPath(path)) {
125
269
  schema.examples = [schema.example];
126
270
  }
@@ -1,3 +1,7 @@
1
+ /** Identify maps whose keys name OpenAPI objects rather than schema/data keywords. */
2
+ export declare const isNamedOpenApiMap: (path: string[] | undefined) => boolean;
3
+ /** Distinguish author-chosen OpenAPI names from keywords and Specification Extensions. */
4
+ export declare const isOpenApiObjectName: (path: readonly string[], index: number) => boolean;
1
5
  /**
2
6
  * Determine if the node at `path` is a map of named subschemas rather than a schema object.
3
7
  *
@@ -1 +1 @@
1
- {"version":3,"file":"is-inside-data-value.d.ts","sourceRoot":"","sources":["../../src/helpers/is-inside-data-value.ts"],"names":[],"mappings":"AAaA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,OAAO,CAcpE;AAiBD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,aAAa,EAAE,KAAK,GAAG,KAAK,GAAG,OAAO,CAwCnG"}
1
+ {"version":3,"file":"is-inside-data-value.d.ts","sourceRoot":"","sources":["../../src/helpers/is-inside-data-value.ts"],"names":[],"mappings":"AA2CA,sFAAsF;AACtF,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,EAAE,GAAG,SAAS,KAAG,OAAgD,CAAA;AAE/G,0FAA0F;AAC1F,eAAO,MAAM,mBAAmB,GAAI,MAAM,SAAS,MAAM,EAAE,EAAE,OAAO,MAAM,KAAG,OAgB5E,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,OAAO,CAcpE;AAiBD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,aAAa,EAAE,KAAK,GAAG,KAAK,GAAG,OAAO,CAwCnG"}
@@ -1,13 +1,64 @@
1
+ import { isSchemaPath } from '@scalar/helpers/openapi/is-schema-path';
1
2
  // Segments whose value is a map of *named* subschemas. Keys inside these maps are
2
3
  // arbitrary names (property names, definition names), never schema keywords.
3
4
  const NAMED_SCHEMA_MAP_SEGMENTS = new Set(['properties', 'patternProperties', '$defs', 'definitions']);
4
- /** Identify response, parameter, and header names so their spelling cannot turn them into schema keywords. */
5
- const isOpenApiObjectName = (path, index) => (index === 1 && (path[0] === 'responses' || path[0] === 'parameters')) ||
6
- (index === 2 && path[0] === 'components' && (path[1] === 'responses' || path[1] === 'parameters')) ||
7
- // A reusable object or header named `headers` is not itself a header map.
8
- (path[index - 1] === 'headers' &&
9
- !isOpenApiObjectName(path, index - 1) &&
10
- !isNamedSchemaMap(path.slice(0, index - 1)));
5
+ const OPENAPI_NAME_MAPS = new Set([
6
+ 'paths',
7
+ 'webhooks',
8
+ 'responses',
9
+ 'content',
10
+ 'headers',
11
+ 'examples',
12
+ 'links',
13
+ 'encoding',
14
+ 'variables',
15
+ 'parameters',
16
+ 'requestBodies',
17
+ 'securitySchemes',
18
+ 'pathItems',
19
+ 'scopes',
20
+ 'schemas',
21
+ ]);
22
+ /** Count author-chosen key levels before entering a Schema Object. */
23
+ const openApiNameLevels = (path) => {
24
+ const segments = path[0] === 'x-ext' && path[1] !== undefined ? path.slice(2) : path;
25
+ let levels = 0;
26
+ for (const [index, segment] of segments.entries()) {
27
+ if (levels > 0) {
28
+ levels--;
29
+ }
30
+ else if (isSchemaPath(segments.slice(0, index))) {
31
+ return 0;
32
+ }
33
+ else if (segment === 'callbacks') {
34
+ // A callback map has a callback name, followed by a runtime-expression map.
35
+ levels = 2;
36
+ }
37
+ else if (OPENAPI_NAME_MAPS.has(segment) || (index === 0 && segment === 'x-webhooks')) {
38
+ levels = 1;
39
+ }
40
+ }
41
+ return levels;
42
+ };
43
+ /** Identify maps whose keys name OpenAPI objects rather than schema/data keywords. */
44
+ export const isNamedOpenApiMap = (path) => !!path && openApiNameLevels(path) > 0;
45
+ /** Distinguish author-chosen OpenAPI names from keywords and Specification Extensions. */
46
+ export const isOpenApiObjectName = (path, index) => {
47
+ const parent = path.slice(0, index);
48
+ const levels = openApiNameLevels(parent);
49
+ if (levels === 0) {
50
+ return false;
51
+ }
52
+ if (!path[index]?.startsWith('x-')) {
53
+ return true;
54
+ }
55
+ const resourceParent = parent[0] === 'x-ext' && parent[1] !== undefined ? parent.slice(2) : parent;
56
+ const isPaths = resourceParent.length === 1 && resourceParent[0] === 'paths';
57
+ const isResponses = resourceParent.at(-1) === 'responses' &&
58
+ !(resourceParent.length === 1 || (resourceParent.length === 2 && resourceParent[0] === 'components'));
59
+ const isCallbackExpression = levels === 1 && openApiNameLevels(parent.slice(0, -1)) === 2;
60
+ return !isPaths && !isResponses && !isCallbackExpression;
61
+ };
11
62
  /**
12
63
  * Determine if the node at `path` is a map of named subschemas rather than a schema object.
13
64
  *
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { type UpgradeOptions, type UpgradeResult, upgrade } from './upgrade.js';
2
+ export { type FragmentKind, type FragmentLocation, type FragmentUpgradeOptions, type FragmentUpgradeResult, upgradeFragment, } from './upgrade-fragment.js';
2
3
  export { UpgradeIncompatibilityError } from './upgrade-incompatibility-error.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5E,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5E,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,eAAe,GAChB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAA"}
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { upgrade } from './upgrade.js';
2
+ export { upgradeFragment, } from './upgrade-fragment.js';
2
3
  export { UpgradeIncompatibilityError } from './upgrade-incompatibility-error.js';
@@ -0,0 +1,44 @@
1
+ /** The OpenAPI object a reference expects, independent of its storage location. */
2
+ export type FragmentKind = 'document' | 'schema' | 'parameter' | 'header' | 'response' | 'path-item' | 'operation' | 'request-body' | 'callback';
3
+ /** Original and converted JSON Pointer segments, relative to the fragment root.
4
+ * Apply the longest source prefix to authored pointers; the first output is canonical when media types copy a schema.
5
+ * Generated bundle pointers and already converted discriminator mappings must not be remapped.
6
+ */
7
+ export type FragmentLocation = {
8
+ source: readonly string[];
9
+ output: readonly string[];
10
+ };
11
+ /** Context required to interpret a fragment that has no version header. */
12
+ export type FragmentUpgradeOptions = {
13
+ from: '2.0' | '3.0';
14
+ to: '3.1';
15
+ kind: FragmentKind;
16
+ consumes?: readonly string[];
17
+ produces?: readonly string[];
18
+ /**
19
+ * Resolve original 2.0 parameter aliases before choosing parameters or requestBody.
20
+ * Return source content with nested refs rebased to the consuming resource. Failed lookups
21
+ * retain the authored reference. Without this callback, referenced body/form parameters stay in parameters.
22
+ */
23
+ resolveSource?: (ref: string) => Promise<unknown>;
24
+ };
25
+ /** Converted content and the locations of original reference targets. */
26
+ export type FragmentUpgradeResult = {
27
+ value: unknown;
28
+ /** Changed locations in traversal order. Unchanged descendants inherit their parent mapping. */
29
+ locations: FragmentLocation[];
30
+ /** Effective operation media types, needed when later loading bare external fragments. */
31
+ contexts: {
32
+ path: readonly string[];
33
+ consumes: readonly string[];
34
+ produces: readonly string[];
35
+ }[];
36
+ };
37
+ /**
38
+ * Upgrade a complete document or a typed fragment without inventing a wrapper document.
39
+ * Returns a copy; literal examples and extension payloads remain data.
40
+ * Authored references retain source pointers: use locations to resolve them against converted content.
41
+ * A standalone schema resource with $schema retains its declared dialect.
42
+ */
43
+ export declare const upgradeFragment: (input: unknown, options: FragmentUpgradeOptions) => Promise<FragmentUpgradeResult>;
44
+ //# sourceMappingURL=upgrade-fragment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-fragment.d.ts","sourceRoot":"","sources":["../src/upgrade-fragment.ts"],"names":[],"mappings":"AAkBA,mFAAmF;AACnF,MAAM,MAAM,YAAY,GACpB,UAAU,GACV,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,UAAU,GACV,WAAW,GACX,WAAW,GACX,cAAc,GACd,UAAU,CAAA;AAEd;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAAE,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAA;AAEvF,2EAA2E;AAC3E,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,KAAK,GAAG,KAAK,CAAA;IACnB,EAAE,EAAE,KAAK,CAAA;IACT,IAAI,EAAE,YAAY,CAAA;IAClB,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC5B,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC5B;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAClD,CAAA;AAED,yEAAyE;AACzE,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,OAAO,CAAA;IACd,gGAAgG;IAChG,SAAS,EAAE,gBAAgB,EAAE,CAAA;IAC7B,0FAA0F;IAC1F,QAAQ,EAAE;QAAE,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,EAAE,CAAA;CAClG,CAAA;AAsCD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,OAAO,EACd,SAAS,sBAAsB,KAC9B,OAAO,CAAC,qBAAqB,CAmd/B,CAAA"}