@skmtc/core 0.41.0 → 0.42.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.
- package/esm/context/ParseContext.d.ts +17 -0
- package/esm/context/ParseContext.js +50 -28
- package/esm/context/generateTypes.d.ts +10 -10
- package/esm/context/tryParseAt.d.ts +3 -3
- package/esm/context/tryParseAt.js +4 -4
- package/esm/helpers/refFns.d.ts +3 -1
- package/esm/helpers/refFns.js +5 -2
- package/esm/oas/operation/Operation.d.ts +1 -4
- package/esm/oas/operation/Operation.js +5 -6
- package/esm/oas/operation/toEffectiveParameters.d.ts +0 -8
- package/esm/oas/operation/toEffectiveParameters.js +3 -32
- package/esm/oas/ref/DanglingRefError.d.ts +3 -3
- package/esm/oas/ref/DanglingRefError.js +3 -3
- package/esm/oas/ref/Ref.d.ts +1 -1
- package/esm/oas/ref/Ref.js +1 -1
- package/esm/oas/union/Union.d.ts +1 -1
- package/esm/oas/union/Union.js +1 -1
- package/esm/oas/webhook/Webhook.js +4 -2
- package/esm/parse/v3-0/_merge-all-of/merge-union.js +9 -1
- package/esm/parse/v3-0/schema/toSchemasV3.js +6 -3
- package/esm/parse/v3-1/_merge-all-of/merge-union.js +16 -4
- package/esm/parse/v3-1/schema/toSchemasV3.js +6 -3
- package/esm/parse/v3-2/_merge-all-of/merge-union.js +16 -4
- package/esm/parse/v3-2/schema/toSchemasV3.js +6 -3
- package/esm/types/Settings.d.ts +19 -8
- package/esm/types/Settings.js +18 -1
- package/package.json +1 -1
- package/script/context/ParseContext.d.ts +17 -0
- package/script/context/ParseContext.js +50 -28
- package/script/context/generateTypes.d.ts +10 -10
- package/script/context/tryParseAt.d.ts +3 -3
- package/script/context/tryParseAt.js +4 -4
- package/script/helpers/refFns.d.ts +3 -1
- package/script/helpers/refFns.js +5 -2
- package/script/oas/operation/Operation.d.ts +1 -4
- package/script/oas/operation/Operation.js +4 -5
- package/script/oas/operation/toEffectiveParameters.d.ts +0 -8
- package/script/oas/operation/toEffectiveParameters.js +4 -34
- package/script/oas/ref/DanglingRefError.d.ts +3 -3
- package/script/oas/ref/DanglingRefError.js +3 -3
- package/script/oas/ref/Ref.d.ts +1 -1
- package/script/oas/ref/Ref.js +1 -1
- package/script/oas/union/Union.d.ts +1 -1
- package/script/oas/union/Union.js +1 -1
- package/script/oas/webhook/Webhook.js +3 -1
- package/script/parse/v3-0/_merge-all-of/merge-union.js +9 -1
- package/script/parse/v3-0/schema/toSchemasV3.js +6 -3
- package/script/parse/v3-1/_merge-all-of/merge-union.js +16 -4
- package/script/parse/v3-1/schema/toSchemasV3.js +6 -3
- package/script/parse/v3-2/_merge-all-of/merge-union.js +16 -4
- package/script/parse/v3-2/schema/toSchemasV3.js +6 -3
- package/script/types/Settings.d.ts +19 -8
- package/script/types/Settings.js +19 -2
|
@@ -182,7 +182,7 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
182
182
|
const system = (0, allOfSystem_js_1.toAllOfSystem)(context);
|
|
183
183
|
const merged = (0, merge_intersection_js_1.mergeIntersection)({
|
|
184
184
|
schema,
|
|
185
|
-
getRef: (0, refFns_js_2.toGetRef)(context.documentObject),
|
|
185
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, $ref => context.toDanglingAllOfMember({ $ref, stackTrail })),
|
|
186
186
|
system
|
|
187
187
|
});
|
|
188
188
|
(0, allOfSystem_js_1.logAllOfContradictions)({ system, stackTrail, parent: schema, context });
|
|
@@ -196,7 +196,9 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
196
196
|
const merged = (0, merge_union_js_1.mergeUnion)({
|
|
197
197
|
// A null member makes the union nullable: `oneOf: [$ref, null]` is a nullable reference.
|
|
198
198
|
schema: withoutNullMembers(schema, 'oneOf'),
|
|
199
|
-
|
|
199
|
+
// A member's own `allOf`, or a member merged with the keywords beside
|
|
200
|
+
// the `oneOf`, is merged here, so it follows `allOfMember` too.
|
|
201
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, $ref => context.toDanglingAllOfMember({ $ref, stackTrail })),
|
|
200
202
|
system,
|
|
201
203
|
groupType: 'oneOf'
|
|
202
204
|
});
|
|
@@ -264,7 +266,8 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
264
266
|
const system = (0, allOfSystem_js_1.toAllOfSystem)(context);
|
|
265
267
|
const merged = (0, merge_union_js_1.mergeUnion)({
|
|
266
268
|
schema: withoutNullMembers(schema, 'anyOf'),
|
|
267
|
-
|
|
269
|
+
// As for `oneOf`: what is merged here follows `allOfMember`.
|
|
270
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, $ref => context.toDanglingAllOfMember({ $ref, stackTrail })),
|
|
268
271
|
system,
|
|
269
272
|
groupType: 'anyOf'
|
|
270
273
|
});
|
|
@@ -5,6 +5,7 @@ const decompose_union_js_1 = require("./decompose-union.js");
|
|
|
5
5
|
const merge_js_1 = require("./merge.js");
|
|
6
6
|
const cross_product_js_1 = require("./cross-product.js");
|
|
7
7
|
const refFns_js_1 = require("../../../helpers/refFns.js");
|
|
8
|
+
const DanglingRefError_js_1 = require("../../../oas/ref/DanglingRefError.js");
|
|
8
9
|
const mergeUnion = ({ schema, getRef, normalize, system, groupType }) => {
|
|
9
10
|
const { beforeExcluded, decomposed, afterExcluded } = (0, decompose_union_js_1.decomposeUnion)({ schema, groupType });
|
|
10
11
|
// if (decomposed.length === 1) {
|
|
@@ -61,13 +62,20 @@ exports.toOwnSystem = toOwnSystem;
|
|
|
61
62
|
* ({@link toOwnSystem}). Inside an outer first pass under `latestWins`, a
|
|
62
63
|
* cross product with no pair that merges fails its pair: the outer pass then
|
|
63
64
|
* leaves the pair out, or lets the later member win.
|
|
65
|
+
*
|
|
66
|
+
* A `$ref` that names nothing is not a contradiction, so its pair is not left
|
|
67
|
+
* out for it: the `DanglingRefError` is thrown on, and `system.danglingRefs`
|
|
68
|
+
* decides (`allOfMember`).
|
|
64
69
|
*/
|
|
65
70
|
const mergePairs = ({ pairs, merge, system }) => {
|
|
66
71
|
const mergeEach = (pairSystem) => pairs.flatMap(pair => {
|
|
67
72
|
try {
|
|
68
73
|
return [merge(pair, pairSystem)];
|
|
69
74
|
}
|
|
70
|
-
catch (
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (DanglingRefError_js_1.DanglingRefError.is(error)) {
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
71
79
|
return [];
|
|
72
80
|
}
|
|
73
81
|
});
|
|
@@ -120,8 +128,9 @@ exports.mergeCrossProduct = mergeCrossProduct;
|
|
|
120
128
|
* to a `oneOf` with `minLength` beside it. Union-level keys (`nullable`,
|
|
121
129
|
* `description`, …) are not merged in, and a `$ref` member is returned
|
|
122
130
|
* unchanged. A member that conflicts with the
|
|
123
|
-
* siblings is dropped, as in the cross product
|
|
124
|
-
*
|
|
131
|
+
* siblings is dropped, as in the cross product, but not one with a `$ref`
|
|
132
|
+
* that names nothing: that is no conflict. A schema with no group is its own
|
|
133
|
+
* only member and is returned unchanged.
|
|
125
134
|
*/
|
|
126
135
|
const withGroupSiblings = ({ schema, members, getRef, normalize, system, groupType }) => {
|
|
127
136
|
if (!Array.isArray(schema[groupType])) {
|
|
@@ -141,7 +150,10 @@ const withGroupSiblings = ({ schema, members, getRef, normalize, system, groupTy
|
|
|
141
150
|
try {
|
|
142
151
|
return (0, merge_js_1.mergeSchemasOrRefs)({ first: siblingSchema, second: member, getRef, normalize, system });
|
|
143
152
|
}
|
|
144
|
-
catch (
|
|
153
|
+
catch (error) {
|
|
154
|
+
if (DanglingRefError_js_1.DanglingRefError.is(error)) {
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
145
157
|
return undefined;
|
|
146
158
|
}
|
|
147
159
|
})
|
|
@@ -234,7 +234,7 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
234
234
|
const system = (0, allOfSystem_js_1.toAllOfSystem)(context);
|
|
235
235
|
const merged = (0, merge_intersection_js_1.mergeIntersection)({
|
|
236
236
|
schema: wrapper,
|
|
237
|
-
getRef: (0, refFns_js_2.toGetRef)(context.documentObject),
|
|
237
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, $ref => context.toDanglingAllOfMember({ $ref, stackTrail })),
|
|
238
238
|
normalize: normalize_schema_shape_js_1.normalizeMergeMember,
|
|
239
239
|
system
|
|
240
240
|
});
|
|
@@ -266,7 +266,9 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
266
266
|
const system = (0, allOfSystem_js_1.toAllOfSystem)(context);
|
|
267
267
|
const merged = (0, merge_union_js_1.mergeUnion)({
|
|
268
268
|
schema: withoutNull,
|
|
269
|
-
|
|
269
|
+
// A member's own `allOf`, or a member merged with the keywords beside
|
|
270
|
+
// the `oneOf`, is merged here, so it follows `allOfMember` too.
|
|
271
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, $ref => context.toDanglingAllOfMember({ $ref, stackTrail })),
|
|
270
272
|
normalize: normalize_schema_shape_js_1.normalizeMergeMember,
|
|
271
273
|
system,
|
|
272
274
|
groupType: 'oneOf'
|
|
@@ -347,7 +349,8 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
347
349
|
const system = (0, allOfSystem_js_1.toAllOfSystem)(context);
|
|
348
350
|
const merged = (0, merge_union_js_1.mergeUnion)({
|
|
349
351
|
schema: withoutNull,
|
|
350
|
-
|
|
352
|
+
// As for `oneOf`: what is merged here follows `allOfMember`.
|
|
353
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, $ref => context.toDanglingAllOfMember({ $ref, stackTrail })),
|
|
351
354
|
normalize: normalize_schema_shape_js_1.normalizeMergeMember,
|
|
352
355
|
system,
|
|
353
356
|
groupType: 'anyOf'
|
|
@@ -5,6 +5,7 @@ const decompose_union_js_1 = require("./decompose-union.js");
|
|
|
5
5
|
const merge_js_1 = require("./merge.js");
|
|
6
6
|
const cross_product_js_1 = require("./cross-product.js");
|
|
7
7
|
const refFns_js_1 = require("../../../helpers/refFns.js");
|
|
8
|
+
const DanglingRefError_js_1 = require("../../../oas/ref/DanglingRefError.js");
|
|
8
9
|
const mergeUnion = ({ schema, getRef, normalize, system, groupType }) => {
|
|
9
10
|
const { beforeExcluded, decomposed, afterExcluded } = (0, decompose_union_js_1.decomposeUnion)({ schema, groupType });
|
|
10
11
|
// if (decomposed.length === 1) {
|
|
@@ -61,13 +62,20 @@ exports.toOwnSystem = toOwnSystem;
|
|
|
61
62
|
* ({@link toOwnSystem}). Inside an outer first pass under `latestWins`, a
|
|
62
63
|
* cross product with no pair that merges fails its pair: the outer pass then
|
|
63
64
|
* leaves the pair out, or lets the later member win.
|
|
65
|
+
*
|
|
66
|
+
* A `$ref` that names nothing is not a contradiction, so its pair is not left
|
|
67
|
+
* out for it: the `DanglingRefError` is thrown on, and `system.danglingRefs`
|
|
68
|
+
* decides (`allOfMember`).
|
|
64
69
|
*/
|
|
65
70
|
const mergePairs = ({ pairs, merge, system }) => {
|
|
66
71
|
const mergeEach = (pairSystem) => pairs.flatMap(pair => {
|
|
67
72
|
try {
|
|
68
73
|
return [merge(pair, pairSystem)];
|
|
69
74
|
}
|
|
70
|
-
catch (
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (DanglingRefError_js_1.DanglingRefError.is(error)) {
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
71
79
|
return [];
|
|
72
80
|
}
|
|
73
81
|
});
|
|
@@ -120,8 +128,9 @@ exports.mergeCrossProduct = mergeCrossProduct;
|
|
|
120
128
|
* to a `oneOf` with `minLength` beside it. Union-level keys (`nullable`,
|
|
121
129
|
* `description`, …) are not merged in, and a `$ref` member is returned
|
|
122
130
|
* unchanged. A member that conflicts with the
|
|
123
|
-
* siblings is dropped, as in the cross product
|
|
124
|
-
*
|
|
131
|
+
* siblings is dropped, as in the cross product, but not one with a `$ref`
|
|
132
|
+
* that names nothing: that is no conflict. A schema with no group is its own
|
|
133
|
+
* only member and is returned unchanged.
|
|
125
134
|
*/
|
|
126
135
|
const withGroupSiblings = ({ schema, members, getRef, normalize, system, groupType }) => {
|
|
127
136
|
if (!Array.isArray(schema[groupType])) {
|
|
@@ -141,7 +150,10 @@ const withGroupSiblings = ({ schema, members, getRef, normalize, system, groupTy
|
|
|
141
150
|
try {
|
|
142
151
|
return (0, merge_js_1.mergeSchemasOrRefs)({ first: siblingSchema, second: member, getRef, normalize, system });
|
|
143
152
|
}
|
|
144
|
-
catch (
|
|
153
|
+
catch (error) {
|
|
154
|
+
if (DanglingRefError_js_1.DanglingRefError.is(error)) {
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
145
157
|
return undefined;
|
|
146
158
|
}
|
|
147
159
|
})
|
|
@@ -234,7 +234,7 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
234
234
|
const system = (0, allOfSystem_js_1.toAllOfSystem)(context);
|
|
235
235
|
const merged = (0, merge_intersection_js_1.mergeIntersection)({
|
|
236
236
|
schema: wrapper,
|
|
237
|
-
getRef: (0, refFns_js_2.toGetRef)(context.documentObject),
|
|
237
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, $ref => context.toDanglingAllOfMember({ $ref, stackTrail })),
|
|
238
238
|
normalize: normalize_schema_shape_js_1.normalizeMergeMember,
|
|
239
239
|
system
|
|
240
240
|
});
|
|
@@ -266,7 +266,9 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
266
266
|
const system = (0, allOfSystem_js_1.toAllOfSystem)(context);
|
|
267
267
|
const merged = (0, merge_union_js_1.mergeUnion)({
|
|
268
268
|
schema: withoutNull,
|
|
269
|
-
|
|
269
|
+
// A member's own `allOf`, or a member merged with the keywords beside
|
|
270
|
+
// the `oneOf`, is merged here, so it follows `allOfMember` too.
|
|
271
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, $ref => context.toDanglingAllOfMember({ $ref, stackTrail })),
|
|
270
272
|
normalize: normalize_schema_shape_js_1.normalizeMergeMember,
|
|
271
273
|
system,
|
|
272
274
|
groupType: 'oneOf'
|
|
@@ -347,7 +349,8 @@ const toSchemaV3 = ({ schema, stackTrail, context }) => {
|
|
|
347
349
|
const system = (0, allOfSystem_js_1.toAllOfSystem)(context);
|
|
348
350
|
const merged = (0, merge_union_js_1.mergeUnion)({
|
|
349
351
|
schema: withoutNull,
|
|
350
|
-
|
|
352
|
+
// As for `oneOf`: what is merged here follows `allOfMember`.
|
|
353
|
+
getRef: (0, refFns_js_2.toGetRef)(context.documentObject, $ref => context.toDanglingAllOfMember({ $ref, stackTrail })),
|
|
351
354
|
normalize: normalize_schema_shape_js_1.normalizeMergeMember,
|
|
352
355
|
system,
|
|
353
356
|
groupType: 'anyOf'
|
|
@@ -162,6 +162,15 @@ export declare const includeModels: v.GenericSchema<IncludeModels>;
|
|
|
162
162
|
* {@link AnchorsSettings} for the consumer-facing fields.
|
|
163
163
|
*/
|
|
164
164
|
export declare const anchorsSettings: v.GenericSchema<AnchorsSettings>;
|
|
165
|
+
/**
|
|
166
|
+
* What `client.json#settings.system.danglingRefs` can list: each kind of
|
|
167
|
+
* `$ref`, and `allOfMember`, a `$ref` that core merges at parse: a member of
|
|
168
|
+
* an `allOf`, also one inside a `oneOf` or `anyOf` member, or a `oneOf` or
|
|
169
|
+
* `anyOf` member merged with the keywords beside the union.
|
|
170
|
+
*/
|
|
171
|
+
export declare const danglingRefKinds: readonly ["schema", "parameter", "requestBody", "response", "header", "securityScheme", "example", "link", "allOfMember"];
|
|
172
|
+
/** A kind of `$ref` that `system.danglingRefs` can let name nothing. */
|
|
173
|
+
export type DanglingRefKind = (typeof danglingRefKinds)[number];
|
|
165
174
|
/** Valibot schema for {@link SystemSettings}: `client.json#settings.system`. */
|
|
166
175
|
export declare const systemSettings: v.GenericSchema<SystemSettings>;
|
|
167
176
|
export declare const clientSettings: v.GenericSchema<ClientSettings>;
|
|
@@ -450,15 +459,17 @@ export type SystemSettings = {
|
|
|
450
459
|
*/
|
|
451
460
|
anyOf?: 'union' | 'unknown';
|
|
452
461
|
/**
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
* the
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
* member
|
|
462
|
+
* The kinds of `$ref` that may name nothing in the document. A dangling
|
|
463
|
+
* `$ref` of a listed kind stays, with a warning, and resolving it throws
|
|
464
|
+
* `DanglingRefError` for the generator to handle. A dangling `$ref` of any
|
|
465
|
+
* other kind is a parse error, and what holds it is removed, with what uses
|
|
466
|
+
* that. `allOfMember` is core's own choice, made at parse: a `$ref` that
|
|
467
|
+
* core merges (a member of an `allOf`, also inside a `oneOf` or `anyOf`
|
|
468
|
+
* member, or a union member merged with the keywords beside the union) is
|
|
469
|
+
* left out of the merge, so its properties are not in the model. The
|
|
470
|
+
* default, `[]`, lists none.
|
|
460
471
|
*/
|
|
461
|
-
danglingRefs?:
|
|
472
|
+
danglingRefs?: DanglingRefKind[];
|
|
462
473
|
};
|
|
463
474
|
export type ClientSettings = {
|
|
464
475
|
/** Base output path for generated files */
|
package/script/types/Settings.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.skmtcClientConfig = exports.clientSettings = exports.systemSettings = exports.anchorsSettings = exports.includeModels = exports.includeModelRefs = exports.includeOperations = exports.includePaths = exports.skipModels = exports.skipModelRefs = exports.skipOperations = exports.skipPaths = exports.modulePackages = exports.modulePackage = void 0;
|
|
36
|
+
exports.skmtcClientConfig = exports.clientSettings = exports.systemSettings = exports.danglingRefKinds = exports.anchorsSettings = exports.includeModels = exports.includeModelRefs = exports.includeOperations = exports.includePaths = exports.skipModels = exports.skipModelRefs = exports.skipOperations = exports.skipPaths = exports.modulePackages = exports.modulePackage = void 0;
|
|
37
37
|
/**
|
|
38
38
|
* @fileoverview SKMTC Core Settings and Configuration
|
|
39
39
|
*
|
|
@@ -205,13 +205,30 @@ exports.anchorsSettings = v.object({
|
|
|
205
205
|
enabled: v.boolean(),
|
|
206
206
|
out: v.optional(v.string())
|
|
207
207
|
});
|
|
208
|
+
/**
|
|
209
|
+
* What `client.json#settings.system.danglingRefs` can list: each kind of
|
|
210
|
+
* `$ref`, and `allOfMember`, a `$ref` that core merges at parse: a member of
|
|
211
|
+
* an `allOf`, also one inside a `oneOf` or `anyOf` member, or a `oneOf` or
|
|
212
|
+
* `anyOf` member merged with the keywords beside the union.
|
|
213
|
+
*/
|
|
214
|
+
exports.danglingRefKinds = [
|
|
215
|
+
'schema',
|
|
216
|
+
'parameter',
|
|
217
|
+
'requestBody',
|
|
218
|
+
'response',
|
|
219
|
+
'header',
|
|
220
|
+
'securityScheme',
|
|
221
|
+
'example',
|
|
222
|
+
'link',
|
|
223
|
+
'allOfMember'
|
|
224
|
+
];
|
|
208
225
|
/** Valibot schema for {@link SystemSettings}: `client.json#settings.system`. */
|
|
209
226
|
exports.systemSettings = v.object({
|
|
210
227
|
allOf: v.optional(v.picklist(['strict', 'latestWins'])),
|
|
211
228
|
responseContradictions: v.optional(v.picklist(['strict', 'unknown'])),
|
|
212
229
|
not: v.optional(v.picklist(['strict', 'unknown'])),
|
|
213
230
|
anyOf: v.optional(v.picklist(['union', 'unknown'])),
|
|
214
|
-
danglingRefs: v.optional(v.picklist(
|
|
231
|
+
danglingRefs: v.optional(v.array(v.picklist(exports.danglingRefKinds)))
|
|
215
232
|
});
|
|
216
233
|
exports.clientSettings = v.object({
|
|
217
234
|
basePath: v.optional(v.pipe(v.string(), v.check(basePath => !(0, normalizeWorkspacePath_js_1.isAbsolutePath)(basePath), 'basePath must be relative to the SKMTC root (the directory containing .skmtc/); ' +
|