@skmtc/core 0.58.1 → 0.58.3
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/FilePlan.d.ts +1 -0
- package/esm/context/FilePlan.js +39 -8
- package/esm/context/GenerateContext.d.ts +3 -3
- package/esm/context/GenerateContext.js +7 -6
- package/esm/context/generateTypes.d.ts +2 -2
- package/esm/dsl/DeclaredProjection.d.ts +5 -0
- 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/schema/siblings.js +6 -4
- package/package.json +1 -4
- package/script/context/FilePlan.d.ts +1 -0
- package/script/context/FilePlan.js +39 -8
- package/script/context/GenerateContext.d.ts +3 -3
- package/script/context/GenerateContext.js +7 -6
- package/script/context/generateTypes.d.ts +2 -2
- package/script/dsl/DeclaredProjection.d.ts +5 -0
- 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/schema/siblings.js +6 -7
|
@@ -39,6 +39,7 @@ export declare class FilePlan {
|
|
|
39
39
|
/**
|
|
40
40
|
* How many times a projection could not say where a subject's file is: a
|
|
41
41
|
* static threw, or the subject's enrichments have variants and no `main`.
|
|
42
|
+
* Each declared projection counts, also one that another is asked for.
|
|
42
43
|
* The run reports such a fault where it happens. The plan leaves the file out.
|
|
43
44
|
*/
|
|
44
45
|
unanswered: number;
|
package/esm/context/FilePlan.js
CHANGED
|
@@ -9,10 +9,29 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
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");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _FilePlan_instances, _FilePlan_context, _FilePlan_projections, _FilePlan_toFilePath, _FilePlan_paths, _FilePlan_indexes, _FilePlan_left, _FilePlan_held, _FilePlan_namedLeft, _FilePlan_filesBehind, _FilePlan_modelFiles, _FilePlan_toFilesBehind, _FilePlan_toModelFiles, _FilePlan_toFiles, _FilePlan_toVariants, _FilePlan_toIndex;
|
|
12
|
+
var _FilePlan_instances, _FilePlan_context, _FilePlan_projections, _FilePlan_toFilePath, _FilePlan_paths, _FilePlan_indexes, _FilePlan_left, _FilePlan_held, _FilePlan_namedLeft, _FilePlan_filesBehind, _FilePlan_modelFiles, _FilePlan_toFilesBehind, _FilePlan_toModelFiles, _FilePlan_toFiles, _FilePlan_toGroupFiles, _FilePlan_toVariants, _FilePlan_toIndex;
|
|
13
13
|
import { ModelSubject } from './Subject.js';
|
|
14
14
|
import { fromModelKey } from '../helpers/refFns.js';
|
|
15
15
|
import { toVariantList } from '../helpers/toVariantList.js';
|
|
16
|
+
/**
|
|
17
|
+
* Whether two declared projections of one kind give every subject the same
|
|
18
|
+
* answer. A projection always does with itself, also when it gives a new
|
|
19
|
+
* function each time a static is read.
|
|
20
|
+
*/
|
|
21
|
+
const haveSameAnswers = (first, second) => first === second ||
|
|
22
|
+
(first.id === second.id &&
|
|
23
|
+
first.toEnrichments === second.toEnrichments &&
|
|
24
|
+
first.toExportPath === second.toExportPath);
|
|
25
|
+
/** Groups the declared projections of one kind. The groups keep the order of their first projections. */
|
|
26
|
+
const toDeclaredOfType = (projections) => {
|
|
27
|
+
const asked = projections.filter((projection, index) => projections.findIndex(other => haveSameAnswers(other, projection)) === index);
|
|
28
|
+
const groupOf = projections.map(projection => asked.findIndex(other => haveSameAnswers(other, projection)));
|
|
29
|
+
const groups = asked.map((projection, index) => ({
|
|
30
|
+
projection,
|
|
31
|
+
size: groupOf.filter(group => group === index).length
|
|
32
|
+
}));
|
|
33
|
+
return { groups, groupOf };
|
|
34
|
+
};
|
|
16
35
|
/**
|
|
17
36
|
* Which subjects of a run hold each file, known before the run from what the
|
|
18
37
|
* entries declared. A subject holds a file when it can write to it or read
|
|
@@ -63,12 +82,14 @@ export class FilePlan {
|
|
|
63
82
|
/**
|
|
64
83
|
* How many times a projection could not say where a subject's file is: a
|
|
65
84
|
* static threw, or the subject's enrichments have variants and no `main`.
|
|
85
|
+
* Each declared projection counts, also one that another is asked for.
|
|
66
86
|
* The run reports such a fault where it happens. The plan leaves the file out.
|
|
67
87
|
*/
|
|
68
88
|
);
|
|
69
89
|
/**
|
|
70
90
|
* How many times a projection could not say where a subject's file is: a
|
|
71
91
|
* static threw, or the subject's enrichments have variants and no `main`.
|
|
92
|
+
* Each declared projection counts, also one that another is asked for.
|
|
72
93
|
* The run reports such a fault where it happens. The plan leaves the file out.
|
|
73
94
|
*/
|
|
74
95
|
Object.defineProperty(this, "unanswered", {
|
|
@@ -78,7 +99,10 @@ export class FilePlan {
|
|
|
78
99
|
value: 0
|
|
79
100
|
});
|
|
80
101
|
__classPrivateFieldSet(this, _FilePlan_context, context, "f");
|
|
81
|
-
__classPrivateFieldSet(this, _FilePlan_projections, Map.groupBy(projections, projection => projection.type),
|
|
102
|
+
__classPrivateFieldSet(this, _FilePlan_projections, new Map([...Map.groupBy(projections, projection => projection.type)].map(([type, ofType]) => [
|
|
103
|
+
type,
|
|
104
|
+
toDeclaredOfType(ofType)
|
|
105
|
+
])), "f");
|
|
82
106
|
__classPrivateFieldSet(this, _FilePlan_toFilePath, toFilePath, "f");
|
|
83
107
|
subjects.forEach(subject => {
|
|
84
108
|
// A model names itself, so its own files are among the files behind
|
|
@@ -152,18 +176,25 @@ _FilePlan_context = new WeakMap(), _FilePlan_projections = new WeakMap(), _FileP
|
|
|
152
176
|
__classPrivateFieldGet(this, _FilePlan_modelFiles, "f").set(key, files);
|
|
153
177
|
return files;
|
|
154
178
|
}, _FilePlan_toFiles = function _FilePlan_toFiles(subject) {
|
|
155
|
-
const
|
|
156
|
-
|
|
179
|
+
const declared = __classPrivateFieldGet(this, _FilePlan_projections, "f").get(subject.type);
|
|
180
|
+
if (declared === undefined) {
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
const filesOfGroup = declared.groups.map(group => __classPrivateFieldGet(this, _FilePlan_instances, "m", _FilePlan_toGroupFiles).call(this, subject, group));
|
|
184
|
+
return declared.groupOf.flatMap(group => filesOfGroup[group]);
|
|
185
|
+
}, _FilePlan_toGroupFiles = function _FilePlan_toGroupFiles(subject, group) {
|
|
186
|
+
const { projection, size } = group;
|
|
187
|
+
return __classPrivateFieldGet(this, _FilePlan_instances, "m", _FilePlan_toVariants).call(this, subject, group).flatMap(variant => {
|
|
157
188
|
try {
|
|
158
189
|
const exportPath = subject.toExportPath({ projection, context: __classPrivateFieldGet(this, _FilePlan_context, "f"), variant });
|
|
159
190
|
return exportPath === undefined ? [] : [__classPrivateFieldGet(this, _FilePlan_instances, "m", _FilePlan_toIndex).call(this, __classPrivateFieldGet(this, _FilePlan_toFilePath, "f").call(this, exportPath, projection.id))];
|
|
160
191
|
}
|
|
161
192
|
catch {
|
|
162
|
-
this.unanswered +=
|
|
193
|
+
this.unanswered += size;
|
|
163
194
|
return [];
|
|
164
195
|
}
|
|
165
|
-
})
|
|
166
|
-
}, _FilePlan_toVariants = function _FilePlan_toVariants(subject, projection) {
|
|
196
|
+
});
|
|
197
|
+
}, _FilePlan_toVariants = function _FilePlan_toVariants(subject, { projection, size }) {
|
|
167
198
|
try {
|
|
168
199
|
return toVariantList({
|
|
169
200
|
opEnrichments: __classPrivateFieldGet(this, _FilePlan_context, "f").readEnrichment([projection.id, ...subject.enrichmentPath]),
|
|
@@ -172,7 +203,7 @@ _FilePlan_context = new WeakMap(), _FilePlan_projections = new WeakMap(), _FileP
|
|
|
172
203
|
});
|
|
173
204
|
}
|
|
174
205
|
catch {
|
|
175
|
-
this.unanswered +=
|
|
206
|
+
this.unanswered += size;
|
|
176
207
|
return [];
|
|
177
208
|
}
|
|
178
209
|
}, _FilePlan_toIndex = function _FilePlan_toIndex(path) {
|
|
@@ -175,9 +175,9 @@ export declare class GenerateContext implements GenerateContextType {
|
|
|
175
175
|
* The recording enrichment accessor — the single choke point every
|
|
176
176
|
* enrichment lookup routes through (dispatch loops, projection-base
|
|
177
177
|
* `toEnrichments`, the Drivers' peer-variant guards). Segments are
|
|
178
|
-
* literal keys (
|
|
179
|
-
*
|
|
180
|
-
*
|
|
178
|
+
* literal keys (`getPath` keeps dotted paths intact); the read is
|
|
179
|
+
* recorded so the post-walk consumption audit can flag configured
|
|
180
|
+
* entries no lookup ever touched.
|
|
181
181
|
*/
|
|
182
182
|
readEnrichment(segments: readonly string[]): unknown;
|
|
183
183
|
/** Add a warning to this run's enrichment audit (deduplicated). */
|
|
@@ -28,7 +28,7 @@ import { toVariantList } from '../helpers/toVariantList.js';
|
|
|
28
28
|
import { GqlOperationSubject, ModelSubject, OasOperationSubject, WebhookSubject } from './Subject.js';
|
|
29
29
|
import { FilePlan } from './FilePlan.js';
|
|
30
30
|
export { toGqlOperationSource, toModelSource, toOasOperationSource, toWebhookSource } from './Subject.js';
|
|
31
|
-
import
|
|
31
|
+
import { getPath } from '../helpers/getPath.js';
|
|
32
32
|
import { Inserted } from '../dsl/Inserted.js';
|
|
33
33
|
import { CodeFileBase } from '../dsl/CodeFileBase.js';
|
|
34
34
|
import { isDefinitionContainer } from '../dsl/DefinitionContainer.js';
|
|
@@ -218,9 +218,9 @@ export class GenerateContext {
|
|
|
218
218
|
* The recording enrichment accessor — the single choke point every
|
|
219
219
|
* enrichment lookup routes through (dispatch loops, projection-base
|
|
220
220
|
* `toEnrichments`, the Drivers' peer-variant guards). Segments are
|
|
221
|
-
* literal keys (
|
|
222
|
-
*
|
|
223
|
-
*
|
|
221
|
+
* literal keys (`getPath` keeps dotted paths intact); the read is
|
|
222
|
+
* recorded so the post-walk consumption audit can flag configured
|
|
223
|
+
* entries no lookup ever touched.
|
|
224
224
|
*/
|
|
225
225
|
readEnrichment(segments) {
|
|
226
226
|
// Recording only matters when there is config to audit — on the common
|
|
@@ -229,7 +229,7 @@ export class GenerateContext {
|
|
|
229
229
|
if (this.settings?.enrichments !== undefined) {
|
|
230
230
|
__classPrivateFieldGet(this, _GenerateContext_enrichmentAudit, "f").consume(segments);
|
|
231
231
|
}
|
|
232
|
-
return
|
|
232
|
+
return getPath(this.settings, ['enrichments', ...segments]);
|
|
233
233
|
}
|
|
234
234
|
/** Add a warning to this run's enrichment audit (deduplicated). */
|
|
235
235
|
reportEnrichmentWarning(warning) {
|
|
@@ -1097,7 +1097,8 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1097
1097
|
if (__classPrivateFieldGet(this, _GenerateContext_released, "f").has(path)) {
|
|
1098
1098
|
throw new Error(`File '${path}' was complete and given to the host before this subject used it. ` +
|
|
1099
1099
|
`A generator inserts a projection that its entry does not list in 'projections', ` +
|
|
1100
|
-
`or inserts a model that this subject does not reach through '$ref's
|
|
1100
|
+
`or inserts a model that this subject does not reach through '$ref's, ` +
|
|
1101
|
+
`or a static of a listed projection answers differently through 'this' from one that shares it.`);
|
|
1101
1102
|
}
|
|
1102
1103
|
}, _GenerateContext_logGeneratorLine = function _GenerateContext_logGeneratorLine(generatorTrail, message) {
|
|
1103
1104
|
if (!__classPrivateFieldGet(this, _GenerateContext_logsGeneratorLines, "f")) {
|
|
@@ -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;
|
|
@@ -44,5 +44,10 @@ export type DeclaredGqlOperationProjection = {
|
|
|
44
44
|
* and each one of another generator that it inserts, such as the model
|
|
45
45
|
* projection an operation generator takes its schemas from. From the list,
|
|
46
46
|
* core can know before a run which files the generator can write.
|
|
47
|
+
*
|
|
48
|
+
* Projections with the same `type` and `id`, and the same `toEnrichments`
|
|
49
|
+
* and `toExportPath` functions (compared by reference), are taken to give the
|
|
50
|
+
* same answers: the file plan asks one of them for all. So the answer of such
|
|
51
|
+
* a static must not depend on the class it is called on, through `this`.
|
|
47
52
|
*/
|
|
48
53
|
export type DeclaredProjection = DeclaredModelProjection | DeclaredOasOperationProjection | DeclaredWebhookProjection | DeclaredGqlOperationProjection;
|
|
@@ -3,7 +3,7 @@ import { toModelGeneratorKey } from '../GeneratorKeys.js';
|
|
|
3
3
|
import { toModelKey } from '../../helpers/refFns.js';
|
|
4
4
|
import { DEFAULT_VARIANT } from '../../types/Variant.js';
|
|
5
5
|
import { readProjectionOptions, toValueOptions } from '../../types/ProjectionOptions.js';
|
|
6
|
-
import
|
|
6
|
+
import { isDeepEqual } from '../../helpers/isDeepEqual.js';
|
|
7
7
|
import { CodeFileBase } from '../CodeFileBase.js';
|
|
8
8
|
import { PendingDefinition } from '../PendingDefinition.js';
|
|
9
9
|
/**
|
|
@@ -211,7 +211,7 @@ const assertSameKey = ({ name, exportPath, cachedKey, generatorKey }) => {
|
|
|
211
211
|
};
|
|
212
212
|
/** One name in one file built with other caller options collides too: options are identity. */
|
|
213
213
|
const assertSameOptions = ({ name, exportPath, cachedOptions, options }) => {
|
|
214
|
-
if (!
|
|
214
|
+
if (!isDeepEqual(cachedOptions, options)) {
|
|
215
215
|
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.`);
|
|
216
216
|
}
|
|
217
217
|
};
|
|
@@ -2,7 +2,7 @@ import { ensureFile, findDefinitionAt, toImportDestination, toImportFile } from
|
|
|
2
2
|
import { toGqlOperationGeneratorKey } from '../../GeneratorKeys.js';
|
|
3
3
|
import { DEFAULT_VARIANT } from '../../../types/Variant.js';
|
|
4
4
|
import { readProjectionOptions, toValueOptions } from '../../../types/ProjectionOptions.js';
|
|
5
|
-
import
|
|
5
|
+
import { isDeepEqual } from '../../../helpers/isDeepEqual.js';
|
|
6
6
|
/**
|
|
7
7
|
* Driver for the GraphQL operation insertion lifecycle.
|
|
8
8
|
*
|
|
@@ -169,7 +169,7 @@ export class GqlOperationDriver {
|
|
|
169
169
|
// Options are identity, like the variant, but cannot ride the key: a hit
|
|
170
170
|
// is checked against the options its value was built with.
|
|
171
171
|
const cachedOptions = toValueOptions(definition.value);
|
|
172
|
-
if (!
|
|
172
|
+
if (!isDeepEqual(cachedOptions, this.options)) {
|
|
173
173
|
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.`);
|
|
174
174
|
}
|
|
175
175
|
return true;
|
|
@@ -15,7 +15,7 @@ import invariant from 'tiny-invariant';
|
|
|
15
15
|
import { toOasOperationGeneratorKey } from '../../GeneratorKeys.js';
|
|
16
16
|
import { DEFAULT_VARIANT } from '../../../types/Variant.js';
|
|
17
17
|
import { readProjectionOptions, toValueOptions } from '../../../types/ProjectionOptions.js';
|
|
18
|
-
import
|
|
18
|
+
import { isDeepEqual } from '../../../helpers/isDeepEqual.js';
|
|
19
19
|
/**
|
|
20
20
|
* Driver for the OAS operation insertion lifecycle.
|
|
21
21
|
*
|
|
@@ -232,7 +232,7 @@ export class OasOperationDriver {
|
|
|
232
232
|
// Options are identity, like the variant, but cannot ride the key: a hit
|
|
233
233
|
// is checked against the options its value was built with.
|
|
234
234
|
const cachedOptions = toValueOptions(definition.value);
|
|
235
|
-
if (!
|
|
235
|
+
if (!isDeepEqual(cachedOptions, this.options)) {
|
|
236
236
|
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.`);
|
|
237
237
|
}
|
|
238
238
|
return true;
|
|
@@ -2,7 +2,7 @@ import { ensureFile, findDefinitionAt, toImportDestination, toImportFile } from
|
|
|
2
2
|
import { toWebhookGeneratorKey } from '../GeneratorKeys.js';
|
|
3
3
|
import { DEFAULT_VARIANT } from '../../types/Variant.js';
|
|
4
4
|
import { readProjectionOptions, toValueOptions } from '../../types/ProjectionOptions.js';
|
|
5
|
-
import
|
|
5
|
+
import { isDeepEqual } from '../../helpers/isDeepEqual.js';
|
|
6
6
|
/**
|
|
7
7
|
* Driver for the webhook insertion lifecycle.
|
|
8
8
|
*
|
|
@@ -162,7 +162,7 @@ export class WebhookDriver {
|
|
|
162
162
|
// Options are identity, like the variant, but cannot ride the key: a hit
|
|
163
163
|
// is checked against the options its value was built with.
|
|
164
164
|
const cachedOptions = toValueOptions(definition.value);
|
|
165
|
-
if (!
|
|
165
|
+
if (!isDeepEqual(cachedOptions, this.options)) {
|
|
166
166
|
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.`);
|
|
167
167
|
}
|
|
168
168
|
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,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 const getPath = (value, path) => path.reduce((current, key) => current === undefined || current === null ? undefined : Reflect.get(Object(current), key), value);
|
|
@@ -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,93 @@
|
|
|
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 const isDeepEqual = (left, right) => isEqualWithin(left, right, new Map());
|
|
18
|
+
const isEqualWithin = (left, right, pairs) => {
|
|
19
|
+
if (left === right || (Number.isNaN(left) && Number.isNaN(right))) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
if (!isObject(left) || !isObject(right)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const tag = toTag(left);
|
|
26
|
+
if (tag !== toTag(right)) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
const partner = pairs.get(left);
|
|
30
|
+
if (partner !== undefined && pairs.has(right)) {
|
|
31
|
+
return partner === right && pairs.get(right) === left;
|
|
32
|
+
}
|
|
33
|
+
pairs.set(left, right).set(right, left);
|
|
34
|
+
const result = isSameContent({ left, right, tag, pairs });
|
|
35
|
+
pairs.delete(left);
|
|
36
|
+
pairs.delete(right);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
const isObject = (value) => typeof value === 'object' && value !== null;
|
|
40
|
+
const toTag = (value) => Object.prototype.toString.call(value);
|
|
41
|
+
const isSameContent = ({ left, right, tag, pairs }) => {
|
|
42
|
+
switch (tag) {
|
|
43
|
+
case '[object Object]':
|
|
44
|
+
return isSameObject(left, right, pairs);
|
|
45
|
+
case '[object Array]':
|
|
46
|
+
return Array.isArray(left) && Array.isArray(right) && isSameItems(left, right, pairs);
|
|
47
|
+
case '[object Map]':
|
|
48
|
+
return (left instanceof Map && right instanceof Map && isSameUnordered([...left], [...right], pairs));
|
|
49
|
+
case '[object Set]':
|
|
50
|
+
return (left instanceof Set && right instanceof Set && isSameUnordered([...left], [...right], pairs));
|
|
51
|
+
case '[object Boolean]':
|
|
52
|
+
case '[object Number]':
|
|
53
|
+
case '[object Date]':
|
|
54
|
+
return isEqualWithin(Number(left), Number(right), pairs);
|
|
55
|
+
case '[object String]':
|
|
56
|
+
case '[object RegExp]':
|
|
57
|
+
return String(left) === String(right);
|
|
58
|
+
case '[object Error]':
|
|
59
|
+
return left instanceof Error && right instanceof Error && isSameError(left, right);
|
|
60
|
+
default:
|
|
61
|
+
// The indices of a typed array are its own enumerable keys.
|
|
62
|
+
return isTypedArray(left) && isSameObject(left, right, pairs);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const isSameError = (left, right) => left.name === right.name && left.message === right.message;
|
|
66
|
+
const isTypedArray = (value) => ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
67
|
+
const isSameObject = (left, right, pairs) => {
|
|
68
|
+
const keys = toEnumerableKeys(left);
|
|
69
|
+
return (keys.length === toEnumerableKeys(right).length &&
|
|
70
|
+
keys.every(key => Object.hasOwn(right, key) &&
|
|
71
|
+
isEqualWithin(Reflect.get(left, key), Reflect.get(right, key), pairs)) &&
|
|
72
|
+
// An own `constructor` key is data, such as a property of that name: it
|
|
73
|
+
// was compared with the other keys.
|
|
74
|
+
(keys.includes('constructor') || isSameConstructor(left, right)));
|
|
75
|
+
};
|
|
76
|
+
const toEnumerableKeys = (value) => Reflect.ownKeys(value).filter(key => Object.prototype.propertyIsEnumerable.call(value, key));
|
|
77
|
+
/** An object with no prototype has no constructor, and matches an object literal. */
|
|
78
|
+
const isSameConstructor = (left, right) => left.constructor === right.constructor || !('constructor' in left && 'constructor' in right);
|
|
79
|
+
const isSameItems = (left, right, pairs) => left.length === right.length &&
|
|
80
|
+
// `Array.from` reads a hole as `undefined`, where `every` would skip it.
|
|
81
|
+
Array.from(left).every((item, index) => isEqualWithin(item, right[index], pairs));
|
|
82
|
+
const isSameUnordered = (left, right, pairs) => {
|
|
83
|
+
const unmatched = [...right];
|
|
84
|
+
return (left.length === right.length &&
|
|
85
|
+
left.every(item => {
|
|
86
|
+
const index = unmatched.findIndex(other => isEqualWithin(item, other, pairs));
|
|
87
|
+
if (index === -1) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
unmatched.splice(index, 1);
|
|
91
|
+
return true;
|
|
92
|
+
}));
|
|
93
|
+
};
|
|
@@ -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
|
|
@@ -19,21 +19,21 @@
|
|
|
19
19
|
* import { parseModuleName } from '@skmtc/core';
|
|
20
20
|
*
|
|
21
21
|
* // Simple package name
|
|
22
|
-
* const simple = parseModuleName('
|
|
22
|
+
* const simple = parseModuleName('zod');
|
|
23
23
|
* // {
|
|
24
24
|
* // scheme: null,
|
|
25
25
|
* // scopeName: null,
|
|
26
|
-
* // packageName: '
|
|
26
|
+
* // packageName: 'zod',
|
|
27
27
|
* // version: null
|
|
28
28
|
* // }
|
|
29
29
|
*
|
|
30
30
|
* // Package with version
|
|
31
|
-
* const versioned = parseModuleName('
|
|
31
|
+
* const versioned = parseModuleName('zod@3.23.8');
|
|
32
32
|
* // {
|
|
33
33
|
* // scheme: null,
|
|
34
34
|
* // scopeName: null,
|
|
35
|
-
* // packageName: '
|
|
36
|
-
* // version: '
|
|
35
|
+
* // packageName: 'zod',
|
|
36
|
+
* // version: '3.23.8'
|
|
37
37
|
* // }
|
|
38
38
|
* ```
|
|
39
39
|
*
|
|
@@ -70,12 +70,12 @@
|
|
|
70
70
|
* // }
|
|
71
71
|
*
|
|
72
72
|
* // npm module with scheme
|
|
73
|
-
* const npmModule = parseModuleName('npm:
|
|
73
|
+
* const npmModule = parseModuleName('npm:zod@^3.23.0');
|
|
74
74
|
* // {
|
|
75
75
|
* // scheme: 'npm',
|
|
76
76
|
* // scopeName: null,
|
|
77
|
-
* // packageName: '
|
|
78
|
-
* // version: '^
|
|
77
|
+
* // packageName: 'zod',
|
|
78
|
+
* // version: '^3.23.0'
|
|
79
79
|
* // }
|
|
80
80
|
*
|
|
81
81
|
* // 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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
-
import
|
|
2
|
+
import { isDeepEqual } from '../../helpers/isDeepEqual.js';
|
|
3
3
|
import { DanglingRefError } from '../ref/DanglingRefError.js';
|
|
4
4
|
import { numberFormat } from '../number/number-types.js';
|
|
5
5
|
import { integerFormat } from '../integer/integer-types.js';
|
|
@@ -140,7 +140,9 @@ const toChangedKeywords = (copy, target, siblings) => {
|
|
|
140
140
|
}
|
|
141
141
|
const applied = Reflect.get(copy, keyword);
|
|
142
142
|
const original = Reflect.get(target, keyword);
|
|
143
|
-
return BOOLEAN_KEYWORDS.includes(keyword)
|
|
143
|
+
return BOOLEAN_KEYWORDS.includes(keyword)
|
|
144
|
+
? (applied === true) !== (original === true)
|
|
145
|
+
: !isDeepEqual(applied, original);
|
|
144
146
|
});
|
|
145
147
|
};
|
|
146
148
|
/** Whether the keywords next to a reference change `target` at that site. The engine behind `OasRef.resolve`. */
|
|
@@ -194,13 +196,13 @@ export const toSkippedSiblings = (target, siblings, nullable) => {
|
|
|
194
196
|
*/
|
|
195
197
|
export const toChangedObjectKeywords = (target, siblings) => {
|
|
196
198
|
const objects = target.toTargetParts().filter(part => part.type === 'object');
|
|
197
|
-
const isSame = (keyword) => objects.some(object =>
|
|
199
|
+
const isSame = (keyword) => objects.some(object => isDeepEqual(object[keyword], siblings[keyword]));
|
|
198
200
|
const isUnchanged = (keyword) => {
|
|
199
201
|
switch (keyword) {
|
|
200
202
|
case 'required':
|
|
201
203
|
return (siblings.required ?? []).every(name => objects.some(object => object.required?.includes(name)));
|
|
202
204
|
case 'properties':
|
|
203
|
-
return Object.keys(siblings.properties ?? {}).every(name => objects.some(object =>
|
|
205
|
+
return Object.keys(siblings.properties ?? {}).every(name => objects.some(object => isDeepEqual(object.properties?.[name], siblings.properties?.[name])));
|
|
204
206
|
case 'additionalProperties':
|
|
205
207
|
case 'minProperties':
|
|
206
208
|
case 'maxProperties':
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skmtc/core",
|
|
3
|
-
"version": "0.58.
|
|
3
|
+
"version": "0.58.3",
|
|
4
4
|
"description": "Skmtc is a declarative code generation framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openapi",
|
|
@@ -213,9 +213,7 @@
|
|
|
213
213
|
},
|
|
214
214
|
"rootDir": "./",
|
|
215
215
|
"dependencies": {
|
|
216
|
-
"@types/lodash-es": "4.17.12",
|
|
217
216
|
"graphql": "^16.9.0",
|
|
218
|
-
"lodash-es": "4.17.21",
|
|
219
217
|
"openapi-types": "^12.1.3",
|
|
220
218
|
"tiny-invariant": "1.3.3",
|
|
221
219
|
"valibot": "1.5.0",
|
|
@@ -223,7 +221,6 @@
|
|
|
223
221
|
},
|
|
224
222
|
"devDependencies": {
|
|
225
223
|
"@types/node": "^20.9.0",
|
|
226
|
-
"@types/lodash-es": "4.17.12",
|
|
227
224
|
"openapi-types": "12.1.3",
|
|
228
225
|
"valibot": "1.1.0"
|
|
229
226
|
},
|
|
@@ -39,6 +39,7 @@ export declare class FilePlan {
|
|
|
39
39
|
/**
|
|
40
40
|
* How many times a projection could not say where a subject's file is: a
|
|
41
41
|
* static threw, or the subject's enrichments have variants and no `main`.
|
|
42
|
+
* Each declared projection counts, also one that another is asked for.
|
|
42
43
|
* The run reports such a fault where it happens. The plan leaves the file out.
|
|
43
44
|
*/
|
|
44
45
|
unanswered: number;
|
|
@@ -10,12 +10,31 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
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
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _FilePlan_instances, _FilePlan_context, _FilePlan_projections, _FilePlan_toFilePath, _FilePlan_paths, _FilePlan_indexes, _FilePlan_left, _FilePlan_held, _FilePlan_namedLeft, _FilePlan_filesBehind, _FilePlan_modelFiles, _FilePlan_toFilesBehind, _FilePlan_toModelFiles, _FilePlan_toFiles, _FilePlan_toVariants, _FilePlan_toIndex;
|
|
13
|
+
var _FilePlan_instances, _FilePlan_context, _FilePlan_projections, _FilePlan_toFilePath, _FilePlan_paths, _FilePlan_indexes, _FilePlan_left, _FilePlan_held, _FilePlan_namedLeft, _FilePlan_filesBehind, _FilePlan_modelFiles, _FilePlan_toFilesBehind, _FilePlan_toModelFiles, _FilePlan_toFiles, _FilePlan_toGroupFiles, _FilePlan_toVariants, _FilePlan_toIndex;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.FilePlan = void 0;
|
|
16
16
|
const Subject_js_1 = require("./Subject.js");
|
|
17
17
|
const refFns_js_1 = require("../helpers/refFns.js");
|
|
18
18
|
const toVariantList_js_1 = require("../helpers/toVariantList.js");
|
|
19
|
+
/**
|
|
20
|
+
* Whether two declared projections of one kind give every subject the same
|
|
21
|
+
* answer. A projection always does with itself, also when it gives a new
|
|
22
|
+
* function each time a static is read.
|
|
23
|
+
*/
|
|
24
|
+
const haveSameAnswers = (first, second) => first === second ||
|
|
25
|
+
(first.id === second.id &&
|
|
26
|
+
first.toEnrichments === second.toEnrichments &&
|
|
27
|
+
first.toExportPath === second.toExportPath);
|
|
28
|
+
/** Groups the declared projections of one kind. The groups keep the order of their first projections. */
|
|
29
|
+
const toDeclaredOfType = (projections) => {
|
|
30
|
+
const asked = projections.filter((projection, index) => projections.findIndex(other => haveSameAnswers(other, projection)) === index);
|
|
31
|
+
const groupOf = projections.map(projection => asked.findIndex(other => haveSameAnswers(other, projection)));
|
|
32
|
+
const groups = asked.map((projection, index) => ({
|
|
33
|
+
projection,
|
|
34
|
+
size: groupOf.filter(group => group === index).length
|
|
35
|
+
}));
|
|
36
|
+
return { groups, groupOf };
|
|
37
|
+
};
|
|
19
38
|
/**
|
|
20
39
|
* Which subjects of a run hold each file, known before the run from what the
|
|
21
40
|
* entries declared. A subject holds a file when it can write to it or read
|
|
@@ -66,12 +85,14 @@ class FilePlan {
|
|
|
66
85
|
/**
|
|
67
86
|
* How many times a projection could not say where a subject's file is: a
|
|
68
87
|
* static threw, or the subject's enrichments have variants and no `main`.
|
|
88
|
+
* Each declared projection counts, also one that another is asked for.
|
|
69
89
|
* The run reports such a fault where it happens. The plan leaves the file out.
|
|
70
90
|
*/
|
|
71
91
|
);
|
|
72
92
|
/**
|
|
73
93
|
* How many times a projection could not say where a subject's file is: a
|
|
74
94
|
* static threw, or the subject's enrichments have variants and no `main`.
|
|
95
|
+
* Each declared projection counts, also one that another is asked for.
|
|
75
96
|
* The run reports such a fault where it happens. The plan leaves the file out.
|
|
76
97
|
*/
|
|
77
98
|
Object.defineProperty(this, "unanswered", {
|
|
@@ -81,7 +102,10 @@ class FilePlan {
|
|
|
81
102
|
value: 0
|
|
82
103
|
});
|
|
83
104
|
__classPrivateFieldSet(this, _FilePlan_context, context, "f");
|
|
84
|
-
__classPrivateFieldSet(this, _FilePlan_projections, Map.groupBy(projections, projection => projection.type),
|
|
105
|
+
__classPrivateFieldSet(this, _FilePlan_projections, new Map([...Map.groupBy(projections, projection => projection.type)].map(([type, ofType]) => [
|
|
106
|
+
type,
|
|
107
|
+
toDeclaredOfType(ofType)
|
|
108
|
+
])), "f");
|
|
85
109
|
__classPrivateFieldSet(this, _FilePlan_toFilePath, toFilePath, "f");
|
|
86
110
|
subjects.forEach(subject => {
|
|
87
111
|
// A model names itself, so its own files are among the files behind
|
|
@@ -156,18 +180,25 @@ _FilePlan_context = new WeakMap(), _FilePlan_projections = new WeakMap(), _FileP
|
|
|
156
180
|
__classPrivateFieldGet(this, _FilePlan_modelFiles, "f").set(key, files);
|
|
157
181
|
return files;
|
|
158
182
|
}, _FilePlan_toFiles = function _FilePlan_toFiles(subject) {
|
|
159
|
-
const
|
|
160
|
-
|
|
183
|
+
const declared = __classPrivateFieldGet(this, _FilePlan_projections, "f").get(subject.type);
|
|
184
|
+
if (declared === undefined) {
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
187
|
+
const filesOfGroup = declared.groups.map(group => __classPrivateFieldGet(this, _FilePlan_instances, "m", _FilePlan_toGroupFiles).call(this, subject, group));
|
|
188
|
+
return declared.groupOf.flatMap(group => filesOfGroup[group]);
|
|
189
|
+
}, _FilePlan_toGroupFiles = function _FilePlan_toGroupFiles(subject, group) {
|
|
190
|
+
const { projection, size } = group;
|
|
191
|
+
return __classPrivateFieldGet(this, _FilePlan_instances, "m", _FilePlan_toVariants).call(this, subject, group).flatMap(variant => {
|
|
161
192
|
try {
|
|
162
193
|
const exportPath = subject.toExportPath({ projection, context: __classPrivateFieldGet(this, _FilePlan_context, "f"), variant });
|
|
163
194
|
return exportPath === undefined ? [] : [__classPrivateFieldGet(this, _FilePlan_instances, "m", _FilePlan_toIndex).call(this, __classPrivateFieldGet(this, _FilePlan_toFilePath, "f").call(this, exportPath, projection.id))];
|
|
164
195
|
}
|
|
165
196
|
catch {
|
|
166
|
-
this.unanswered +=
|
|
197
|
+
this.unanswered += size;
|
|
167
198
|
return [];
|
|
168
199
|
}
|
|
169
|
-
})
|
|
170
|
-
}, _FilePlan_toVariants = function _FilePlan_toVariants(subject, projection) {
|
|
200
|
+
});
|
|
201
|
+
}, _FilePlan_toVariants = function _FilePlan_toVariants(subject, { projection, size }) {
|
|
171
202
|
try {
|
|
172
203
|
return (0, toVariantList_js_1.toVariantList)({
|
|
173
204
|
opEnrichments: __classPrivateFieldGet(this, _FilePlan_context, "f").readEnrichment([projection.id, ...subject.enrichmentPath]),
|
|
@@ -176,7 +207,7 @@ _FilePlan_context = new WeakMap(), _FilePlan_projections = new WeakMap(), _FileP
|
|
|
176
207
|
});
|
|
177
208
|
}
|
|
178
209
|
catch {
|
|
179
|
-
this.unanswered +=
|
|
210
|
+
this.unanswered += size;
|
|
180
211
|
return [];
|
|
181
212
|
}
|
|
182
213
|
}, _FilePlan_toIndex = function _FilePlan_toIndex(path) {
|
|
@@ -175,9 +175,9 @@ export declare class GenerateContext implements GenerateContextType {
|
|
|
175
175
|
* The recording enrichment accessor — the single choke point every
|
|
176
176
|
* enrichment lookup routes through (dispatch loops, projection-base
|
|
177
177
|
* `toEnrichments`, the Drivers' peer-variant guards). Segments are
|
|
178
|
-
* literal keys (
|
|
179
|
-
*
|
|
180
|
-
*
|
|
178
|
+
* literal keys (`getPath` keeps dotted paths intact); the read is
|
|
179
|
+
* recorded so the post-walk consumption audit can flag configured
|
|
180
|
+
* entries no lookup ever touched.
|
|
181
181
|
*/
|
|
182
182
|
readEnrichment(segments: readonly string[]): unknown;
|
|
183
183
|
/** Add a warning to this run's enrichment audit (deduplicated). */
|
|
@@ -38,7 +38,7 @@ Object.defineProperty(exports, "toGqlOperationSource", { enumerable: true, get:
|
|
|
38
38
|
Object.defineProperty(exports, "toModelSource", { enumerable: true, get: function () { return Subject_js_2.toModelSource; } });
|
|
39
39
|
Object.defineProperty(exports, "toOasOperationSource", { enumerable: true, get: function () { return Subject_js_2.toOasOperationSource; } });
|
|
40
40
|
Object.defineProperty(exports, "toWebhookSource", { enumerable: true, get: function () { return Subject_js_2.toWebhookSource; } });
|
|
41
|
-
const
|
|
41
|
+
const getPath_js_1 = require("../helpers/getPath.js");
|
|
42
42
|
const Inserted_js_1 = require("../dsl/Inserted.js");
|
|
43
43
|
const CodeFileBase_js_1 = require("../dsl/CodeFileBase.js");
|
|
44
44
|
const DefinitionContainer_js_1 = require("../dsl/DefinitionContainer.js");
|
|
@@ -228,9 +228,9 @@ class GenerateContext {
|
|
|
228
228
|
* The recording enrichment accessor — the single choke point every
|
|
229
229
|
* enrichment lookup routes through (dispatch loops, projection-base
|
|
230
230
|
* `toEnrichments`, the Drivers' peer-variant guards). Segments are
|
|
231
|
-
* literal keys (
|
|
232
|
-
*
|
|
233
|
-
*
|
|
231
|
+
* literal keys (`getPath` keeps dotted paths intact); the read is
|
|
232
|
+
* recorded so the post-walk consumption audit can flag configured
|
|
233
|
+
* entries no lookup ever touched.
|
|
234
234
|
*/
|
|
235
235
|
readEnrichment(segments) {
|
|
236
236
|
// Recording only matters when there is config to audit — on the common
|
|
@@ -239,7 +239,7 @@ class GenerateContext {
|
|
|
239
239
|
if (this.settings?.enrichments !== undefined) {
|
|
240
240
|
__classPrivateFieldGet(this, _GenerateContext_enrichmentAudit, "f").consume(segments);
|
|
241
241
|
}
|
|
242
|
-
return (0,
|
|
242
|
+
return (0, getPath_js_1.getPath)(this.settings, ['enrichments', ...segments]);
|
|
243
243
|
}
|
|
244
244
|
/** Add a warning to this run's enrichment audit (deduplicated). */
|
|
245
245
|
reportEnrichmentWarning(warning) {
|
|
@@ -1108,7 +1108,8 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1108
1108
|
if (__classPrivateFieldGet(this, _GenerateContext_released, "f").has(path)) {
|
|
1109
1109
|
throw new Error(`File '${path}' was complete and given to the host before this subject used it. ` +
|
|
1110
1110
|
`A generator inserts a projection that its entry does not list in 'projections', ` +
|
|
1111
|
-
`or inserts a model that this subject does not reach through '$ref's
|
|
1111
|
+
`or inserts a model that this subject does not reach through '$ref's, ` +
|
|
1112
|
+
`or a static of a listed projection answers differently through 'this' from one that shares it.`);
|
|
1112
1113
|
}
|
|
1113
1114
|
}, _GenerateContext_logGeneratorLine = function _GenerateContext_logGeneratorLine(generatorTrail, message) {
|
|
1114
1115
|
if (!__classPrivateFieldGet(this, _GenerateContext_logsGeneratorLines, "f")) {
|
|
@@ -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;
|
|
@@ -44,5 +44,10 @@ export type DeclaredGqlOperationProjection = {
|
|
|
44
44
|
* and each one of another generator that it inserts, such as the model
|
|
45
45
|
* projection an operation generator takes its schemas from. From the list,
|
|
46
46
|
* core can know before a run which files the generator can write.
|
|
47
|
+
*
|
|
48
|
+
* Projections with the same `type` and `id`, and the same `toEnrichments`
|
|
49
|
+
* and `toExportPath` functions (compared by reference), are taken to give the
|
|
50
|
+
* same answers: the file plan asks one of them for all. So the answer of such
|
|
51
|
+
* a static must not depend on the class it is called on, through `this`.
|
|
47
52
|
*/
|
|
48
53
|
export type DeclaredProjection = DeclaredModelProjection | DeclaredOasOperationProjection | DeclaredWebhookProjection | DeclaredGqlOperationProjection;
|
|
@@ -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;
|
|
@@ -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':
|