@skmtc/core 0.58.2 → 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.
@@ -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 (the array form of `get` keeps dotted paths intact);
179
- * the read is recorded so the post-walk consumption audit can flag
180
- * configured entries no lookup ever touched.
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 get from 'lodash-es/get.js';
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 (the array form of `get` keeps dotted paths intact);
222
- * the read is recorded so the post-walk consumption audit can flag
223
- * configured entries no lookup ever touched.
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 get(this.settings, ['enrichments', ...segments]);
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) {
@@ -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 lodash paths) and records the read for the post-walk
501
- * consumption audit, so configured-but-never-read entries surface as
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;
@@ -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 isEqual from 'lodash-es/isEqual.js';
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 (!isEqual(cachedOptions, options)) {
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 isEqual from 'lodash-es/isEqual.js';
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 (!isEqual(cachedOptions, this.options)) {
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 isEqual from 'lodash-es/isEqual.js';
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 (!isEqual(cachedOptions, this.options)) {
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 isEqual from 'lodash-es/isEqual.js';
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 (!isEqual(cachedOptions, this.options)) {
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('lodash');
50
+ * const simple = parseModuleName('zod');
51
51
  * // {
52
52
  * // scheme: null,
53
53
  * // scopeName: null,
54
- * // packageName: 'lodash',
54
+ * // packageName: 'zod',
55
55
  * // version: null
56
56
  * // }
57
57
  *
58
58
  * // Package with version
59
- * const versioned = parseModuleName('lodash@4.17.21');
59
+ * const versioned = parseModuleName('zod@3.23.8');
60
60
  * // {
61
61
  * // scheme: null,
62
62
  * // scopeName: null,
63
- * // packageName: 'lodash',
64
- * // version: '4.17.21'
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:lodash@^4.17.0');
101
+ * const npmModule = parseModuleName('npm:zod@^3.23.0');
102
102
  * // {
103
103
  * // scheme: 'npm',
104
104
  * // scopeName: null,
105
- * // packageName: 'lodash',
106
- * // version: '^4.17.0'
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('lodash');
22
+ * const simple = parseModuleName('zod');
23
23
  * // {
24
24
  * // scheme: null,
25
25
  * // scopeName: null,
26
- * // packageName: 'lodash',
26
+ * // packageName: 'zod',
27
27
  * // version: null
28
28
  * // }
29
29
  *
30
30
  * // Package with version
31
- * const versioned = parseModuleName('lodash@4.17.21');
31
+ * const versioned = parseModuleName('zod@3.23.8');
32
32
  * // {
33
33
  * // scheme: null,
34
34
  * // scopeName: null,
35
- * // packageName: 'lodash',
36
- * // version: '4.17.21'
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:lodash@^4.17.0');
73
+ * const npmModule = parseModuleName('npm:zod@^3.23.0');
74
74
  * // {
75
75
  * // scheme: 'npm',
76
76
  * // scopeName: null,
77
- * // packageName: 'lodash',
78
- * // version: '^4.17.0'
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 `lodash-es/get()` returns `unknown` and the engine
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 isEqual from 'lodash-es/isEqual.js';
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) ? (applied === true) !== (original === true) : !isEqual(applied, original);
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 => isEqual(object[keyword], siblings[keyword]));
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 => isEqual(object.properties?.[name], siblings.properties?.[name])));
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.2",
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
  },
@@ -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 (the array form of `get` keeps dotted paths intact);
179
- * the read is recorded so the post-walk consumption audit can flag
180
- * configured entries no lookup ever touched.
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 get_js_1 = __importDefault(require("lodash-es/get.js"));
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 (the array form of `get` keeps dotted paths intact);
232
- * the read is recorded so the post-walk consumption audit can flag
233
- * configured entries no lookup ever touched.
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, get_js_1.default)(this.settings, ['enrichments', ...segments]);
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) {
@@ -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 lodash paths) and records the read for the post-walk
501
- * consumption audit, so configured-but-never-read entries surface as
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 isEqual_js_1 = __importDefault(require("lodash-es/isEqual.js"));
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, isEqual_js_1.default)(cachedOptions, options)) {
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 isEqual_js_1 = __importDefault(require("lodash-es/isEqual.js"));
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, isEqual_js_1.default)(cachedOptions, this.options)) {
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 isEqual_js_1 = __importDefault(require("lodash-es/isEqual.js"));
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, isEqual_js_1.default)(cachedOptions, this.options)) {
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 isEqual_js_1 = __importDefault(require("lodash-es/isEqual.js"));
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, isEqual_js_1.default)(cachedOptions, this.options)) {
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('lodash');
50
+ * const simple = parseModuleName('zod');
51
51
  * // {
52
52
  * // scheme: null,
53
53
  * // scopeName: null,
54
- * // packageName: 'lodash',
54
+ * // packageName: 'zod',
55
55
  * // version: null
56
56
  * // }
57
57
  *
58
58
  * // Package with version
59
- * const versioned = parseModuleName('lodash@4.17.21');
59
+ * const versioned = parseModuleName('zod@3.23.8');
60
60
  * // {
61
61
  * // scheme: null,
62
62
  * // scopeName: null,
63
- * // packageName: 'lodash',
64
- * // version: '4.17.21'
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:lodash@^4.17.0');
101
+ * const npmModule = parseModuleName('npm:zod@^3.23.0');
102
102
  * // {
103
103
  * // scheme: 'npm',
104
104
  * // scopeName: null,
105
- * // packageName: 'lodash',
106
- * // version: '^4.17.0'
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('lodash');
25
+ * const simple = parseModuleName('zod');
26
26
  * // {
27
27
  * // scheme: null,
28
28
  * // scopeName: null,
29
- * // packageName: 'lodash',
29
+ * // packageName: 'zod',
30
30
  * // version: null
31
31
  * // }
32
32
  *
33
33
  * // Package with version
34
- * const versioned = parseModuleName('lodash@4.17.21');
34
+ * const versioned = parseModuleName('zod@3.23.8');
35
35
  * // {
36
36
  * // scheme: null,
37
37
  * // scopeName: null,
38
- * // packageName: 'lodash',
39
- * // version: '4.17.21'
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:lodash@^4.17.0');
76
+ * const npmModule = parseModuleName('npm:zod@^3.23.0');
77
77
  * // {
78
78
  * // scheme: 'npm',
79
79
  * // scopeName: null,
80
- * // packageName: 'lodash',
81
- * // version: '^4.17.0'
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 `lodash-es/get()` returns `unknown` and the engine
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 isEqual_js_1 = __importDefault(require("lodash-es/isEqual.js"));
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) ? (applied === true) !== (original === true) : !(0, isEqual_js_1.default)(applied, original);
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, isEqual_js_1.default)(object[keyword], siblings[keyword]));
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, isEqual_js_1.default)(object.properties?.[name], siblings.properties?.[name])));
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':