@skmtc/core 0.58.2 → 0.58.4
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/BuiltOnRead.d.ts +37 -0
- package/esm/context/BuiltOnRead.js +199 -0
- package/esm/context/CoreContext.js +11 -5
- package/esm/context/GenerateContext.d.ts +3 -3
- package/esm/context/GenerateContext.js +13 -6
- package/esm/context/ParseContext.js +116 -11
- package/esm/context/Subject.d.ts +29 -2
- package/esm/context/Subject.js +67 -6
- package/esm/context/generateTypes.d.ts +2 -2
- package/esm/dsl/model/ModelDriver.js +2 -2
- package/esm/dsl/operation/gql/GqlOperationDriver.js +2 -2
- package/esm/dsl/operation/oas/OasOperationDriver.js +2 -2
- package/esm/dsl/webhook/WebhookDriver.js +2 -2
- package/esm/helpers/getPath.d.ts +6 -0
- package/esm/helpers/getPath.js +6 -0
- package/esm/helpers/isDeepEqual.d.ts +17 -0
- package/esm/helpers/isDeepEqual.js +93 -0
- package/esm/helpers/parseModuleName.d.ts +8 -8
- package/esm/helpers/parseModuleName.js +8 -8
- package/esm/helpers/toVariantList.d.ts +1 -1
- package/esm/oas/document/Document.d.ts +5 -1
- package/esm/oas/document/Document.js +10 -1
- package/esm/oas/document/documentSource.d.ts +37 -0
- package/esm/oas/document/documentSource.js +27 -0
- package/esm/oas/schema/siblings.js +6 -4
- package/esm/parse/v3-0/operation/toOperationsV3.d.ts +14 -0
- package/esm/parse/v3-0/operation/toOperationsV3.js +68 -67
- package/esm/parse/v3-1/operation/toOperationsV3.d.ts +14 -0
- package/esm/parse/v3-1/operation/toOperationsV3.js +68 -67
- package/esm/parse/v3-2/operation/toOperationsV3.d.ts +14 -0
- package/esm/parse/v3-2/operation/toOperationsV3.js +69 -68
- package/package.json +1 -4
- package/script/context/BuiltOnRead.d.ts +37 -0
- package/script/context/BuiltOnRead.js +203 -0
- package/script/context/CoreContext.js +11 -5
- package/script/context/GenerateContext.d.ts +3 -3
- package/script/context/GenerateContext.js +13 -6
- package/script/context/ParseContext.js +116 -11
- package/script/context/Subject.d.ts +29 -2
- package/script/context/Subject.js +67 -6
- package/script/context/generateTypes.d.ts +2 -2
- package/script/dsl/model/ModelDriver.js +2 -5
- package/script/dsl/operation/gql/GqlOperationDriver.js +2 -5
- package/script/dsl/operation/oas/OasOperationDriver.js +2 -2
- package/script/dsl/webhook/WebhookDriver.js +2 -5
- package/script/helpers/getPath.d.ts +6 -0
- package/script/helpers/getPath.js +10 -0
- package/script/helpers/isDeepEqual.d.ts +17 -0
- package/script/helpers/isDeepEqual.js +97 -0
- package/script/helpers/parseModuleName.d.ts +8 -8
- package/script/helpers/parseModuleName.js +8 -8
- package/script/helpers/toVariantList.d.ts +1 -1
- package/script/oas/document/Document.d.ts +5 -1
- package/script/oas/document/Document.js +10 -1
- package/script/oas/document/documentSource.d.ts +37 -0
- package/script/oas/document/documentSource.js +36 -0
- package/script/oas/schema/siblings.js +6 -7
- package/script/parse/v3-0/operation/toOperationsV3.d.ts +14 -0
- package/script/parse/v3-0/operation/toOperationsV3.js +71 -69
- package/script/parse/v3-1/operation/toOperationsV3.d.ts +14 -0
- package/script/parse/v3-1/operation/toOperationsV3.js +71 -69
- package/script/parse/v3-2/operation/toOperationsV3.d.ts +14 -0
- package/script/parse/v3-2/operation/toOperationsV3.js +72 -70
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _OasOperationSubject_operation, _OasOperationSubject_loader, _OasOperationSubject_inStep;
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
15
|
exports.toModelSource = exports.toGqlOperationSource = exports.toWebhookSource = exports.toOasOperationSource = exports.ModelSubject = exports.GqlOperationSubject = exports.WebhookSubject = exports.OasOperationSubject = void 0;
|
|
4
16
|
const refFns_js_1 = require("../helpers/refFns.js");
|
|
5
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* An OpenAPI operation as a subject. Its results and enrichments are at `[path][method]`.
|
|
19
|
+
*
|
|
20
|
+
* It holds the operation it is constructed with. In a run that builds
|
|
21
|
+
* operations on read, it lets that one go once the file plan is built. In
|
|
22
|
+
* its step, the first read builds its operation through the document, and
|
|
23
|
+
* it lets the operation go when the step has run.
|
|
24
|
+
*/
|
|
6
25
|
class OasOperationSubject {
|
|
7
26
|
constructor(operation) {
|
|
8
27
|
Object.defineProperty(this, "type", {
|
|
@@ -11,7 +30,13 @@ class OasOperationSubject {
|
|
|
11
30
|
writable: true,
|
|
12
31
|
value: 'oasOperation'
|
|
13
32
|
});
|
|
14
|
-
Object.defineProperty(this, "
|
|
33
|
+
Object.defineProperty(this, "path", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true,
|
|
37
|
+
value: void 0
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(this, "method", {
|
|
15
40
|
enumerable: true,
|
|
16
41
|
configurable: true,
|
|
17
42
|
writable: true,
|
|
@@ -35,18 +60,53 @@ class OasOperationSubject {
|
|
|
35
60
|
writable: true,
|
|
36
61
|
value: void 0
|
|
37
62
|
});
|
|
38
|
-
this
|
|
63
|
+
_OasOperationSubject_operation.set(this, void 0);
|
|
64
|
+
_OasOperationSubject_loader.set(this, void 0);
|
|
65
|
+
/** Whether its step runs now. */
|
|
66
|
+
_OasOperationSubject_inStep.set(this, false);
|
|
67
|
+
__classPrivateFieldSet(this, _OasOperationSubject_operation, operation, "f");
|
|
68
|
+
this.path = operation.path;
|
|
69
|
+
this.method = operation.method;
|
|
39
70
|
this.trail = [operation.path, operation.method];
|
|
40
71
|
this.enrichmentPath = this.trail;
|
|
41
72
|
this.label = `${operation.method.toUpperCase()} ${operation.path}`;
|
|
42
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Its operation. In a run that builds operations on read, only while its
|
|
76
|
+
* step runs: the first read in the step builds it.
|
|
77
|
+
*/
|
|
78
|
+
get operation() {
|
|
79
|
+
if (__classPrivateFieldGet(this, _OasOperationSubject_operation, "f") === undefined && __classPrivateFieldGet(this, _OasOperationSubject_inStep, "f") && __classPrivateFieldGet(this, _OasOperationSubject_loader, "f") !== undefined) {
|
|
80
|
+
__classPrivateFieldSet(this, _OasOperationSubject_operation, __classPrivateFieldGet(this, _OasOperationSubject_loader, "f").load(this), "f");
|
|
81
|
+
}
|
|
82
|
+
if (__classPrivateFieldGet(this, _OasOperationSubject_operation, "f") === undefined) {
|
|
83
|
+
throw new Error(`The operation of ${this.label} is read outside its step, after it was let go`);
|
|
84
|
+
}
|
|
85
|
+
return __classPrivateFieldGet(this, _OasOperationSubject_operation, "f");
|
|
86
|
+
}
|
|
87
|
+
/** Lets go of the operation it was constructed with: from now on, `loader` gives it. */
|
|
88
|
+
buildOnRead(loader) {
|
|
89
|
+
__classPrivateFieldSet(this, _OasOperationSubject_loader, loader, "f");
|
|
90
|
+
__classPrivateFieldSet(this, _OasOperationSubject_operation, undefined, "f");
|
|
91
|
+
}
|
|
92
|
+
/** Its step starts. A step that never reads its operation, such as one with no generator, builds none. */
|
|
93
|
+
startStep() {
|
|
94
|
+
__classPrivateFieldSet(this, _OasOperationSubject_inStep, true, "f");
|
|
95
|
+
}
|
|
96
|
+
/** Its step has run: it lets go of the operation the step built. */
|
|
97
|
+
finishStep() {
|
|
98
|
+
__classPrivateFieldSet(this, _OasOperationSubject_inStep, false, "f");
|
|
99
|
+
if (__classPrivateFieldGet(this, _OasOperationSubject_loader, "f") !== undefined) {
|
|
100
|
+
__classPrivateFieldGet(this, _OasOperationSubject_loader, "f").letGo(this);
|
|
101
|
+
__classPrivateFieldSet(this, _OasOperationSubject_operation, undefined, "f");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
43
104
|
isSupported({ entry, context, variant }) {
|
|
44
105
|
return (typeof entry.isSupported !== 'function' ||
|
|
45
106
|
entry.isSupported({ operation: this.operation, context, variant }));
|
|
46
107
|
}
|
|
47
108
|
matches(filter, variant) {
|
|
48
|
-
|
|
49
|
-
return matchesPathFilter({ paths: filter, path, method, variant });
|
|
109
|
+
return matchesPathFilter({ paths: filter, path: this.path, method: this.method, variant });
|
|
50
110
|
}
|
|
51
111
|
transform({ entry, context, variant }) {
|
|
52
112
|
entry.transform({ context, operation: this.operation, variant });
|
|
@@ -62,13 +122,14 @@ class OasOperationSubject {
|
|
|
62
122
|
return projection.toExportPath({ operation: this.operation, enrichments, variant });
|
|
63
123
|
}
|
|
64
124
|
toNamedModels(reach) {
|
|
65
|
-
return reach.namedByOperation(this
|
|
125
|
+
return reach.namedByOperation(this);
|
|
66
126
|
}
|
|
67
127
|
toSource({ generatorId, variant }) {
|
|
68
128
|
return (0, exports.toOasOperationSource)({ operation: this.operation, generatorId, variant });
|
|
69
129
|
}
|
|
70
130
|
}
|
|
71
131
|
exports.OasOperationSubject = OasOperationSubject;
|
|
132
|
+
_OasOperationSubject_operation = new WeakMap(), _OasOperationSubject_loader = new WeakMap(), _OasOperationSubject_inStep = new WeakMap();
|
|
72
133
|
/**
|
|
73
134
|
* A 3.1 webhook as a subject. Its results are at `['webhook'][name][method]`
|
|
74
135
|
* and its enrichments at `[name][method]`. A filter has the shape of an
|
|
@@ -497,8 +497,8 @@ export type GenerateContextType = {
|
|
|
497
497
|
* The recording enrichment accessor — the single choke point every
|
|
498
498
|
* enrichment lookup routes through. Reads the node at
|
|
499
499
|
* `settings.enrichments[...segments]` (segments are literal keys, never
|
|
500
|
-
* dotted
|
|
501
|
-
*
|
|
500
|
+
* dotted paths) and records the read for the post-walk consumption
|
|
501
|
+
* audit, so configured-but-never-read entries surface as
|
|
502
502
|
* `UNCONSUMED_ENRICHMENT` warnings.
|
|
503
503
|
*/
|
|
504
504
|
readEnrichment: (segments: readonly string[]) => unknown;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.toModelRef = exports.isReferencedBack = exports.ModelDriver = void 0;
|
|
7
4
|
const driverFiles_js_1 = require("../driverFiles.js");
|
|
@@ -9,7 +6,7 @@ const GeneratorKeys_js_1 = require("../GeneratorKeys.js");
|
|
|
9
6
|
const refFns_js_1 = require("../../helpers/refFns.js");
|
|
10
7
|
const Variant_js_1 = require("../../types/Variant.js");
|
|
11
8
|
const ProjectionOptions_js_1 = require("../../types/ProjectionOptions.js");
|
|
12
|
-
const
|
|
9
|
+
const isDeepEqual_js_1 = require("../../helpers/isDeepEqual.js");
|
|
13
10
|
const CodeFileBase_js_1 = require("../CodeFileBase.js");
|
|
14
11
|
const PendingDefinition_js_1 = require("../PendingDefinition.js");
|
|
15
12
|
/**
|
|
@@ -218,7 +215,7 @@ const assertSameKey = ({ name, exportPath, cachedKey, generatorKey }) => {
|
|
|
218
215
|
};
|
|
219
216
|
/** One name in one file built with other caller options collides too: options are identity. */
|
|
220
217
|
const assertSameOptions = ({ name, exportPath, cachedOptions, options }) => {
|
|
221
|
-
if (!(0,
|
|
218
|
+
if (!(0, isDeepEqual_js_1.isDeepEqual)(cachedOptions, options)) {
|
|
222
219
|
throw new Error(`Registered definition mismatch: '${name}' in file '${exportPath}'. Cached options ${JSON.stringify(cachedOptions)} do not match new options ${JSON.stringify(options)}. Fold options into toIdentifierName.`);
|
|
223
220
|
}
|
|
224
221
|
};
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.GqlOperationDriver = void 0;
|
|
7
4
|
const driverFiles_js_1 = require("../../driverFiles.js");
|
|
8
5
|
const GeneratorKeys_js_1 = require("../../GeneratorKeys.js");
|
|
9
6
|
const Variant_js_1 = require("../../../types/Variant.js");
|
|
10
7
|
const ProjectionOptions_js_1 = require("../../../types/ProjectionOptions.js");
|
|
11
|
-
const
|
|
8
|
+
const isDeepEqual_js_1 = require("../../../helpers/isDeepEqual.js");
|
|
12
9
|
/**
|
|
13
10
|
* Driver for the GraphQL operation insertion lifecycle.
|
|
14
11
|
*
|
|
@@ -175,7 +172,7 @@ class GqlOperationDriver {
|
|
|
175
172
|
// Options are identity, like the variant, but cannot ride the key: a hit
|
|
176
173
|
// is checked against the options its value was built with.
|
|
177
174
|
const cachedOptions = (0, ProjectionOptions_js_1.toValueOptions)(definition.value);
|
|
178
|
-
if (!(0,
|
|
175
|
+
if (!(0, isDeepEqual_js_1.isDeepEqual)(cachedOptions, this.options)) {
|
|
179
176
|
throw new Error(`Registered definition mismatch: '${definition.identifier.name}' in file '${exportPath}'. Cached options ${JSON.stringify(cachedOptions)} do not match new options ${JSON.stringify(this.options)}. Fold options into toIdentifierName.`);
|
|
180
177
|
}
|
|
181
178
|
return true;
|
|
@@ -21,7 +21,7 @@ const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
|
|
|
21
21
|
const GeneratorKeys_js_1 = require("../../GeneratorKeys.js");
|
|
22
22
|
const Variant_js_1 = require("../../../types/Variant.js");
|
|
23
23
|
const ProjectionOptions_js_1 = require("../../../types/ProjectionOptions.js");
|
|
24
|
-
const
|
|
24
|
+
const isDeepEqual_js_1 = require("../../../helpers/isDeepEqual.js");
|
|
25
25
|
/**
|
|
26
26
|
* Driver for the OAS operation insertion lifecycle.
|
|
27
27
|
*
|
|
@@ -238,7 +238,7 @@ class OasOperationDriver {
|
|
|
238
238
|
// Options are identity, like the variant, but cannot ride the key: a hit
|
|
239
239
|
// is checked against the options its value was built with.
|
|
240
240
|
const cachedOptions = (0, ProjectionOptions_js_1.toValueOptions)(definition.value);
|
|
241
|
-
if (!(0,
|
|
241
|
+
if (!(0, isDeepEqual_js_1.isDeepEqual)(cachedOptions, this.options)) {
|
|
242
242
|
throw new Error(`Registered definition mismatch: '${definition.identifier.name}' in file '${exportPath}'. Cached options ${JSON.stringify(cachedOptions)} do not match new options ${JSON.stringify(this.options)}. Fold options into toIdentifierName.`);
|
|
243
243
|
}
|
|
244
244
|
return true;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.WebhookDriver = void 0;
|
|
7
4
|
const driverFiles_js_1 = require("../driverFiles.js");
|
|
8
5
|
const GeneratorKeys_js_1 = require("../GeneratorKeys.js");
|
|
9
6
|
const Variant_js_1 = require("../../types/Variant.js");
|
|
10
7
|
const ProjectionOptions_js_1 = require("../../types/ProjectionOptions.js");
|
|
11
|
-
const
|
|
8
|
+
const isDeepEqual_js_1 = require("../../helpers/isDeepEqual.js");
|
|
12
9
|
/**
|
|
13
10
|
* Driver for the webhook insertion lifecycle.
|
|
14
11
|
*
|
|
@@ -168,7 +165,7 @@ class WebhookDriver {
|
|
|
168
165
|
// Options are identity, like the variant, but cannot ride the key: a hit
|
|
169
166
|
// is checked against the options its value was built with.
|
|
170
167
|
const cachedOptions = (0, ProjectionOptions_js_1.toValueOptions)(definition.value);
|
|
171
|
-
if (!(0,
|
|
168
|
+
if (!(0, isDeepEqual_js_1.isDeepEqual)(cachedOptions, this.options)) {
|
|
172
169
|
throw new Error(`Registered definition mismatch: '${definition.identifier.name}' in file '${exportPath}'. Cached options ${JSON.stringify(cachedOptions)} do not match new options ${JSON.stringify(this.options)}. Fold options into toIdentifierName.`);
|
|
173
170
|
}
|
|
174
171
|
return true;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The value at `path` in `value`. Each step is one literal key, so a key with
|
|
3
|
+
* dots or brackets (an operation path) stays whole. A step from `undefined` or
|
|
4
|
+
* `null` gives `undefined`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getPath: (value: unknown, path: readonly [string, ...string[]]) => unknown;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPath = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The value at `path` in `value`. Each step is one literal key, so a key with
|
|
6
|
+
* dots or brackets (an operation path) stays whole. A step from `undefined` or
|
|
7
|
+
* `null` gives `undefined`.
|
|
8
|
+
*/
|
|
9
|
+
const getPath = (value, path) => path.reduce((current, key) => current === undefined || current === null ? undefined : Reflect.get(Object(current), key), value);
|
|
10
|
+
exports.getPath = getPath;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether two values have the same content.
|
|
3
|
+
*
|
|
4
|
+
* - Primitives and functions are equal to themselves; `NaN` equals `NaN`, and
|
|
5
|
+
* `0` equals `-0`.
|
|
6
|
+
* - Arrays are equal item by item; a hole is `undefined`.
|
|
7
|
+
* - Objects need one constructor and the same own enumerable keys, in any
|
|
8
|
+
* order: `{ a: undefined }` is not `{}`. Private fields are not read.
|
|
9
|
+
* - Dates and boxed booleans, numbers and strings are equal by value, regular
|
|
10
|
+
* expressions by source and flags, errors by name and message, typed arrays
|
|
11
|
+
* by their items, and maps and sets by their entries in any order.
|
|
12
|
+
* - Cycles of the same shape are equal.
|
|
13
|
+
* - Every other kind of object (an `ArrayBuffer`, a `DataView`, a boxed symbol
|
|
14
|
+
* or bigint, a promise) is equal to itself only. A boxed primitive is not
|
|
15
|
+
* equal to the primitive.
|
|
16
|
+
*/
|
|
17
|
+
export declare const isDeepEqual: (left: unknown, right: unknown) => boolean;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isDeepEqual = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Whether two values have the same content.
|
|
6
|
+
*
|
|
7
|
+
* - Primitives and functions are equal to themselves; `NaN` equals `NaN`, and
|
|
8
|
+
* `0` equals `-0`.
|
|
9
|
+
* - Arrays are equal item by item; a hole is `undefined`.
|
|
10
|
+
* - Objects need one constructor and the same own enumerable keys, in any
|
|
11
|
+
* order: `{ a: undefined }` is not `{}`. Private fields are not read.
|
|
12
|
+
* - Dates and boxed booleans, numbers and strings are equal by value, regular
|
|
13
|
+
* expressions by source and flags, errors by name and message, typed arrays
|
|
14
|
+
* by their items, and maps and sets by their entries in any order.
|
|
15
|
+
* - Cycles of the same shape are equal.
|
|
16
|
+
* - Every other kind of object (an `ArrayBuffer`, a `DataView`, a boxed symbol
|
|
17
|
+
* or bigint, a promise) is equal to itself only. A boxed primitive is not
|
|
18
|
+
* equal to the primitive.
|
|
19
|
+
*/
|
|
20
|
+
const isDeepEqual = (left, right) => isEqualWithin(left, right, new Map());
|
|
21
|
+
exports.isDeepEqual = isDeepEqual;
|
|
22
|
+
const isEqualWithin = (left, right, pairs) => {
|
|
23
|
+
if (left === right || (Number.isNaN(left) && Number.isNaN(right))) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
if (!isObject(left) || !isObject(right)) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
const tag = toTag(left);
|
|
30
|
+
if (tag !== toTag(right)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const partner = pairs.get(left);
|
|
34
|
+
if (partner !== undefined && pairs.has(right)) {
|
|
35
|
+
return partner === right && pairs.get(right) === left;
|
|
36
|
+
}
|
|
37
|
+
pairs.set(left, right).set(right, left);
|
|
38
|
+
const result = isSameContent({ left, right, tag, pairs });
|
|
39
|
+
pairs.delete(left);
|
|
40
|
+
pairs.delete(right);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
const isObject = (value) => typeof value === 'object' && value !== null;
|
|
44
|
+
const toTag = (value) => Object.prototype.toString.call(value);
|
|
45
|
+
const isSameContent = ({ left, right, tag, pairs }) => {
|
|
46
|
+
switch (tag) {
|
|
47
|
+
case '[object Object]':
|
|
48
|
+
return isSameObject(left, right, pairs);
|
|
49
|
+
case '[object Array]':
|
|
50
|
+
return Array.isArray(left) && Array.isArray(right) && isSameItems(left, right, pairs);
|
|
51
|
+
case '[object Map]':
|
|
52
|
+
return (left instanceof Map && right instanceof Map && isSameUnordered([...left], [...right], pairs));
|
|
53
|
+
case '[object Set]':
|
|
54
|
+
return (left instanceof Set && right instanceof Set && isSameUnordered([...left], [...right], pairs));
|
|
55
|
+
case '[object Boolean]':
|
|
56
|
+
case '[object Number]':
|
|
57
|
+
case '[object Date]':
|
|
58
|
+
return isEqualWithin(Number(left), Number(right), pairs);
|
|
59
|
+
case '[object String]':
|
|
60
|
+
case '[object RegExp]':
|
|
61
|
+
return String(left) === String(right);
|
|
62
|
+
case '[object Error]':
|
|
63
|
+
return left instanceof Error && right instanceof Error && isSameError(left, right);
|
|
64
|
+
default:
|
|
65
|
+
// The indices of a typed array are its own enumerable keys.
|
|
66
|
+
return isTypedArray(left) && isSameObject(left, right, pairs);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const isSameError = (left, right) => left.name === right.name && left.message === right.message;
|
|
70
|
+
const isTypedArray = (value) => ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
71
|
+
const isSameObject = (left, right, pairs) => {
|
|
72
|
+
const keys = toEnumerableKeys(left);
|
|
73
|
+
return (keys.length === toEnumerableKeys(right).length &&
|
|
74
|
+
keys.every(key => Object.hasOwn(right, key) &&
|
|
75
|
+
isEqualWithin(Reflect.get(left, key), Reflect.get(right, key), pairs)) &&
|
|
76
|
+
// An own `constructor` key is data, such as a property of that name: it
|
|
77
|
+
// was compared with the other keys.
|
|
78
|
+
(keys.includes('constructor') || isSameConstructor(left, right)));
|
|
79
|
+
};
|
|
80
|
+
const toEnumerableKeys = (value) => Reflect.ownKeys(value).filter(key => Object.prototype.propertyIsEnumerable.call(value, key));
|
|
81
|
+
/** An object with no prototype has no constructor, and matches an object literal. */
|
|
82
|
+
const isSameConstructor = (left, right) => left.constructor === right.constructor || !('constructor' in left && 'constructor' in right);
|
|
83
|
+
const isSameItems = (left, right, pairs) => left.length === right.length &&
|
|
84
|
+
// `Array.from` reads a hole as `undefined`, where `every` would skip it.
|
|
85
|
+
Array.from(left).every((item, index) => isEqualWithin(item, right[index], pairs));
|
|
86
|
+
const isSameUnordered = (left, right, pairs) => {
|
|
87
|
+
const unmatched = [...right];
|
|
88
|
+
return (left.length === right.length &&
|
|
89
|
+
left.every(item => {
|
|
90
|
+
const index = unmatched.findIndex(other => isEqualWithin(item, other, pairs));
|
|
91
|
+
if (index === -1) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
unmatched.splice(index, 1);
|
|
95
|
+
return true;
|
|
96
|
+
}));
|
|
97
|
+
};
|
|
@@ -47,21 +47,21 @@ export type ParsedModuleName = {
|
|
|
47
47
|
* import { parseModuleName } from '@skmtc/core';
|
|
48
48
|
*
|
|
49
49
|
* // Simple package name
|
|
50
|
-
* const simple = parseModuleName('
|
|
50
|
+
* const simple = parseModuleName('zod');
|
|
51
51
|
* // {
|
|
52
52
|
* // scheme: null,
|
|
53
53
|
* // scopeName: null,
|
|
54
|
-
* // packageName: '
|
|
54
|
+
* // packageName: 'zod',
|
|
55
55
|
* // version: null
|
|
56
56
|
* // }
|
|
57
57
|
*
|
|
58
58
|
* // Package with version
|
|
59
|
-
* const versioned = parseModuleName('
|
|
59
|
+
* const versioned = parseModuleName('zod@3.23.8');
|
|
60
60
|
* // {
|
|
61
61
|
* // scheme: null,
|
|
62
62
|
* // scopeName: null,
|
|
63
|
-
* // packageName: '
|
|
64
|
-
* // version: '
|
|
63
|
+
* // packageName: 'zod',
|
|
64
|
+
* // version: '3.23.8'
|
|
65
65
|
* // }
|
|
66
66
|
* ```
|
|
67
67
|
*
|
|
@@ -98,12 +98,12 @@ export type ParsedModuleName = {
|
|
|
98
98
|
* // }
|
|
99
99
|
*
|
|
100
100
|
* // npm module with scheme
|
|
101
|
-
* const npmModule = parseModuleName('npm:
|
|
101
|
+
* const npmModule = parseModuleName('npm:zod@^3.23.0');
|
|
102
102
|
* // {
|
|
103
103
|
* // scheme: 'npm',
|
|
104
104
|
* // scopeName: null,
|
|
105
|
-
* // packageName: '
|
|
106
|
-
* // version: '^
|
|
105
|
+
* // packageName: 'zod',
|
|
106
|
+
* // version: '^3.23.0'
|
|
107
107
|
* // }
|
|
108
108
|
*
|
|
109
109
|
* // HTTPS module
|
|
@@ -22,21 +22,21 @@ exports.parseModuleName = void 0;
|
|
|
22
22
|
* import { parseModuleName } from '@skmtc/core';
|
|
23
23
|
*
|
|
24
24
|
* // Simple package name
|
|
25
|
-
* const simple = parseModuleName('
|
|
25
|
+
* const simple = parseModuleName('zod');
|
|
26
26
|
* // {
|
|
27
27
|
* // scheme: null,
|
|
28
28
|
* // scopeName: null,
|
|
29
|
-
* // packageName: '
|
|
29
|
+
* // packageName: 'zod',
|
|
30
30
|
* // version: null
|
|
31
31
|
* // }
|
|
32
32
|
*
|
|
33
33
|
* // Package with version
|
|
34
|
-
* const versioned = parseModuleName('
|
|
34
|
+
* const versioned = parseModuleName('zod@3.23.8');
|
|
35
35
|
* // {
|
|
36
36
|
* // scheme: null,
|
|
37
37
|
* // scopeName: null,
|
|
38
|
-
* // packageName: '
|
|
39
|
-
* // version: '
|
|
38
|
+
* // packageName: 'zod',
|
|
39
|
+
* // version: '3.23.8'
|
|
40
40
|
* // }
|
|
41
41
|
* ```
|
|
42
42
|
*
|
|
@@ -73,12 +73,12 @@ exports.parseModuleName = void 0;
|
|
|
73
73
|
* // }
|
|
74
74
|
*
|
|
75
75
|
* // npm module with scheme
|
|
76
|
-
* const npmModule = parseModuleName('npm:
|
|
76
|
+
* const npmModule = parseModuleName('npm:zod@^3.23.0');
|
|
77
77
|
* // {
|
|
78
78
|
* // scheme: 'npm',
|
|
79
79
|
* // scopeName: null,
|
|
80
|
-
* // packageName: '
|
|
81
|
-
* // version: '^
|
|
80
|
+
* // packageName: 'zod',
|
|
81
|
+
* // version: '^3.23.0'
|
|
82
82
|
* // }
|
|
83
83
|
*
|
|
84
84
|
* // HTTPS module
|
|
@@ -2,7 +2,7 @@ type ToVariantListArgs = {
|
|
|
2
2
|
/**
|
|
3
3
|
* The enrichment block at `[generatorId][path][method]` (OAS) or
|
|
4
4
|
* `[generatorId][rootKind][fieldName]` (GQL). Typed as `unknown`
|
|
5
|
-
* because `
|
|
5
|
+
* because `readEnrichment` returns `unknown` and the engine
|
|
6
6
|
* doesn't pre-validate this branch.
|
|
7
7
|
*/
|
|
8
8
|
opEnrichments: unknown;
|
|
@@ -231,7 +231,11 @@ export declare class OasDocument {
|
|
|
231
231
|
/** API metadata */
|
|
232
232
|
get info(): OasInfo;
|
|
233
233
|
get servers(): OasServer[] | undefined;
|
|
234
|
-
/**
|
|
234
|
+
/**
|
|
235
|
+
* List of all operations for the API. In a run with `onArtifact` the parsed
|
|
236
|
+
* operations are let go once the file plan is built; the first time they
|
|
237
|
+
* are listed after that, each is built again and kept.
|
|
238
|
+
*/
|
|
235
239
|
get operations(): OasOperation[];
|
|
236
240
|
/** List of all 3.1 webhooks for the API (kept separate from operations) */
|
|
237
241
|
get webhooks(): OasWebhook[];
|
|
@@ -14,6 +14,7 @@ var _OasDocument_fields, _OasDocument_refTargets;
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.OasDocument = void 0;
|
|
16
16
|
require("../../_dnt.polyfills.js");
|
|
17
|
+
const documentSource_js_1 = require("./documentSource.js");
|
|
17
18
|
/**
|
|
18
19
|
* Represents a complete OpenAPI v3 document in the SKMTC OAS processing system.
|
|
19
20
|
*
|
|
@@ -292,11 +293,19 @@ class OasDocument {
|
|
|
292
293
|
}
|
|
293
294
|
return __classPrivateFieldGet(this, _OasDocument_fields, "f").servers;
|
|
294
295
|
}
|
|
295
|
-
/**
|
|
296
|
+
/**
|
|
297
|
+
* List of all operations for the API. In a run with `onArtifact` the parsed
|
|
298
|
+
* operations are let go once the file plan is built; the first time they
|
|
299
|
+
* are listed after that, each is built again and kept.
|
|
300
|
+
*/
|
|
296
301
|
get operations() {
|
|
297
302
|
if (!__classPrivateFieldGet(this, _OasDocument_fields, "f")) {
|
|
298
303
|
throw new Error(`Accessing 'operations' before fields are set`);
|
|
299
304
|
}
|
|
305
|
+
const list = (0, documentSource_js_1.takeUnlistedOperations)(this);
|
|
306
|
+
if (list !== undefined) {
|
|
307
|
+
__classPrivateFieldGet(this, _OasDocument_fields, "f").operations = list();
|
|
308
|
+
}
|
|
300
309
|
return __classPrivateFieldGet(this, _OasDocument_fields, "f").operations;
|
|
301
310
|
}
|
|
302
311
|
/** List of all 3.1 webhooks for the API (kept separate from operations) */
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A document whose operations and component schemas are built again when a
|
|
3
|
+
* generator reads them, in a run with `onArtifact`. Internal: `mod.ts` does
|
|
4
|
+
* not list this file.
|
|
5
|
+
*/
|
|
6
|
+
import type { OasDocument } from './Document.js';
|
|
7
|
+
import type { OasOperation } from '../operation/Operation.js';
|
|
8
|
+
import type { OasSchema } from '../schema/Schema.js';
|
|
9
|
+
import type { OasRef } from '../ref/Ref.js';
|
|
10
|
+
import type { Method } from '../../types/Method.js';
|
|
11
|
+
import type { RefName } from '../../types/RefName.js';
|
|
12
|
+
/** Where an operation is in a document. An `OasOperation` fits it. */
|
|
13
|
+
export type OperationPlace = {
|
|
14
|
+
path: string;
|
|
15
|
+
method: Method;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* How the parse context that parsed a document builds one of its operations
|
|
19
|
+
* or component schemas again from the input document. A rebuild records no
|
|
20
|
+
* issue and no ref.
|
|
21
|
+
*/
|
|
22
|
+
export type DocumentSource = {
|
|
23
|
+
toOperation(place: OperationPlace): OasOperation;
|
|
24
|
+
toSchema(name: RefName): OasSchema | OasRef<'schema'>;
|
|
25
|
+
};
|
|
26
|
+
/** Marks a parse context, before it parses, as one of a run that gives files early. */
|
|
27
|
+
export declare const markPlannedParse: (parseContext: object) => void;
|
|
28
|
+
/** Whether `markPlannedParse` marked the parse context. */
|
|
29
|
+
export declare const isPlannedParse: (parseContext: object) => boolean;
|
|
30
|
+
/** Keeps how the parse context builds the parts of `document` again. */
|
|
31
|
+
export declare const setDocumentSource: (document: OasDocument, source: DocumentSource) => void;
|
|
32
|
+
/** How the parts of `document` are built again, or `undefined` when its run builds nothing again. */
|
|
33
|
+
export declare const toDocumentSource: (document: OasDocument) => DocumentSource | undefined;
|
|
34
|
+
/** `document` has let its parsed operations go: `list` builds every one, the first time they are listed. */
|
|
35
|
+
export declare const setUnlistedOperations: (document: OasDocument, list: () => OasOperation[]) => void;
|
|
36
|
+
/** How to list the operations of `document` that were let go, once: after that they are listed. */
|
|
37
|
+
export declare const takeUnlistedOperations: (document: OasDocument) => (() => OasOperation[]) | undefined;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.takeUnlistedOperations = exports.setUnlistedOperations = exports.toDocumentSource = exports.setDocumentSource = exports.isPlannedParse = exports.markPlannedParse = void 0;
|
|
4
|
+
const sources = new WeakMap();
|
|
5
|
+
/** The parse contexts of runs that give files early, whose documents are built on read. */
|
|
6
|
+
const plannedParses = new WeakSet();
|
|
7
|
+
/** Marks a parse context, before it parses, as one of a run that gives files early. */
|
|
8
|
+
const markPlannedParse = (parseContext) => {
|
|
9
|
+
plannedParses.add(parseContext);
|
|
10
|
+
};
|
|
11
|
+
exports.markPlannedParse = markPlannedParse;
|
|
12
|
+
/** Whether `markPlannedParse` marked the parse context. */
|
|
13
|
+
const isPlannedParse = (parseContext) => plannedParses.has(parseContext);
|
|
14
|
+
exports.isPlannedParse = isPlannedParse;
|
|
15
|
+
/** Each document whose parsed operations were let go, and how to list them all again. */
|
|
16
|
+
const unlistedOperations = new WeakMap();
|
|
17
|
+
/** Keeps how the parse context builds the parts of `document` again. */
|
|
18
|
+
const setDocumentSource = (document, source) => {
|
|
19
|
+
sources.set(document, source);
|
|
20
|
+
};
|
|
21
|
+
exports.setDocumentSource = setDocumentSource;
|
|
22
|
+
/** How the parts of `document` are built again, or `undefined` when its run builds nothing again. */
|
|
23
|
+
const toDocumentSource = (document) => sources.get(document);
|
|
24
|
+
exports.toDocumentSource = toDocumentSource;
|
|
25
|
+
/** `document` has let its parsed operations go: `list` builds every one, the first time they are listed. */
|
|
26
|
+
const setUnlistedOperations = (document, list) => {
|
|
27
|
+
unlistedOperations.set(document, list);
|
|
28
|
+
};
|
|
29
|
+
exports.setUnlistedOperations = setUnlistedOperations;
|
|
30
|
+
/** How to list the operations of `document` that were let go, once: after that they are listed. */
|
|
31
|
+
const takeUnlistedOperations = (document) => {
|
|
32
|
+
const list = unlistedOperations.get(document);
|
|
33
|
+
unlistedOperations.delete(document);
|
|
34
|
+
return list;
|
|
35
|
+
};
|
|
36
|
+
exports.takeUnlistedOperations = takeUnlistedOperations;
|
|
@@ -32,13 +32,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
exports.toSiblingEnums = exports.toSiblingValue = exports.isIntegerFormat = exports.isNumberFormat = exports.VALUE_CHECKS = exports.isObjectValue = exports.isArrayValue = exports.isBooleanValue = exports.isIntegerValue = exports.isNumberValue = exports.isStringValue = exports.toSiblingAnnotations = exports.toChangedObjectKeywords = exports.toSkippedSiblings = exports.changesValues = exports.changesTarget = exports.hasSiblingKeywords = exports.mergeSiblingKeywords = exports.SIBLINGS_BY_TYPE = void 0;
|
|
40
37
|
const v = __importStar(require("valibot"));
|
|
41
|
-
const
|
|
38
|
+
const isDeepEqual_js_1 = require("../../helpers/isDeepEqual.js");
|
|
42
39
|
const DanglingRefError_js_1 = require("../ref/DanglingRefError.js");
|
|
43
40
|
const number_types_js_1 = require("../number/number-types.js");
|
|
44
41
|
const integer_types_js_1 = require("../integer/integer-types.js");
|
|
@@ -181,7 +178,9 @@ const toChangedKeywords = (copy, target, siblings) => {
|
|
|
181
178
|
}
|
|
182
179
|
const applied = Reflect.get(copy, keyword);
|
|
183
180
|
const original = Reflect.get(target, keyword);
|
|
184
|
-
return BOOLEAN_KEYWORDS.includes(keyword)
|
|
181
|
+
return BOOLEAN_KEYWORDS.includes(keyword)
|
|
182
|
+
? (applied === true) !== (original === true)
|
|
183
|
+
: !(0, isDeepEqual_js_1.isDeepEqual)(applied, original);
|
|
185
184
|
});
|
|
186
185
|
};
|
|
187
186
|
/** Whether the keywords next to a reference change `target` at that site. The engine behind `OasRef.resolve`. */
|
|
@@ -238,13 +237,13 @@ exports.toSkippedSiblings = toSkippedSiblings;
|
|
|
238
237
|
*/
|
|
239
238
|
const toChangedObjectKeywords = (target, siblings) => {
|
|
240
239
|
const objects = target.toTargetParts().filter(part => part.type === 'object');
|
|
241
|
-
const isSame = (keyword) => objects.some(object => (0,
|
|
240
|
+
const isSame = (keyword) => objects.some(object => (0, isDeepEqual_js_1.isDeepEqual)(object[keyword], siblings[keyword]));
|
|
242
241
|
const isUnchanged = (keyword) => {
|
|
243
242
|
switch (keyword) {
|
|
244
243
|
case 'required':
|
|
245
244
|
return (siblings.required ?? []).every(name => objects.some(object => object.required?.includes(name)));
|
|
246
245
|
case 'properties':
|
|
247
|
-
return Object.keys(siblings.properties ?? {}).every(name => objects.some(object => (0,
|
|
246
|
+
return Object.keys(siblings.properties ?? {}).every(name => objects.some(object => (0, isDeepEqual_js_1.isDeepEqual)(object.properties?.[name], siblings.properties?.[name])));
|
|
248
247
|
case 'additionalProperties':
|
|
249
248
|
case 'minProperties':
|
|
250
249
|
case 'maxProperties':
|
|
@@ -22,4 +22,18 @@ export type ToOperationsV3Args = {
|
|
|
22
22
|
context: ParseContextType;
|
|
23
23
|
};
|
|
24
24
|
export declare const toOperationsV3: ({ paths, stackTrail, context }: ToOperationsV3Args) => OasOperation[];
|
|
25
|
+
export type ToPathOperationsV3Args = {
|
|
26
|
+
path: string;
|
|
27
|
+
pathItem: OpenAPIV3.PathItemObject;
|
|
28
|
+
/** The trail of the path item, with `path` already pushed. */
|
|
29
|
+
stackTrail: StackTrail;
|
|
30
|
+
context: ParseContextType;
|
|
31
|
+
/** Parses only the operation at this method. */
|
|
32
|
+
method?: Method;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* The operations of the path item at `path`. They share one parsed path
|
|
36
|
+
* item. With `method`, only the operation at that method is parsed.
|
|
37
|
+
*/
|
|
38
|
+
export declare const toPathOperationsV3: ({ path, pathItem, stackTrail: pathStack, context, method: only }: ToPathOperationsV3Args) => OasOperation[];
|
|
25
39
|
export {};
|