@skmtc/core 0.27.0 → 0.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/context/CoreContext.d.ts.map +1 -1
- package/esm/context/CoreContext.js +4 -2
- package/esm/context/GenerateContext.d.ts +16 -2
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +94 -15
- package/esm/context/generateTypes.d.ts +33 -2
- package/esm/context/generateTypes.d.ts.map +1 -1
- package/esm/dsl/model/ModelDriver.d.ts.map +1 -1
- package/esm/dsl/model/ModelDriver.js +1 -2
- package/esm/dsl/model/toModelProjectionBase.d.ts +1 -1
- package/esm/dsl/model/toModelProjectionBase.d.ts.map +1 -1
- package/esm/dsl/model/toModelProjectionBase.js +9 -9
- package/esm/dsl/operation/gql/GqlOperationDriver.d.ts.map +1 -1
- package/esm/dsl/operation/gql/GqlOperationDriver.js +1 -3
- package/esm/dsl/operation/gql/toGqlOperationProjectionBase.d.ts +1 -1
- package/esm/dsl/operation/gql/toGqlOperationProjectionBase.d.ts.map +1 -1
- package/esm/dsl/operation/gql/toGqlOperationProjectionBase.js +9 -15
- package/esm/dsl/operation/oas/OasOperationDriver.d.ts.map +1 -1
- package/esm/dsl/operation/oas/OasOperationDriver.js +1 -3
- package/esm/dsl/operation/oas/toOasOperationProjectionBase.d.ts +1 -1
- package/esm/dsl/operation/oas/toOasOperationProjectionBase.d.ts.map +1 -1
- package/esm/dsl/operation/oas/toOasOperationProjectionBase.js +9 -15
- package/esm/dsl/webhook/WebhookDriver.d.ts.map +1 -1
- package/esm/dsl/webhook/WebhookDriver.js +1 -3
- package/esm/dsl/webhook/toWebhookProjectionBase.d.ts +1 -1
- package/esm/dsl/webhook/toWebhookProjectionBase.d.ts.map +1 -1
- package/esm/dsl/webhook/toWebhookProjectionBase.js +9 -15
- package/esm/enrichments/EnrichmentAudit.d.ts +79 -0
- package/esm/enrichments/EnrichmentAudit.d.ts.map +1 -0
- package/esm/enrichments/EnrichmentAudit.js +210 -0
- package/esm/enrichments/EnrichmentWarning.d.ts +72 -0
- package/esm/enrichments/EnrichmentWarning.d.ts.map +1 -0
- package/esm/enrichments/EnrichmentWarning.js +50 -0
- package/esm/enrichments/findUnknownKeys.d.ts +40 -0
- package/esm/enrichments/findUnknownKeys.d.ts.map +1 -0
- package/esm/enrichments/findUnknownKeys.js +80 -0
- package/esm/enrichments/parseEnrichmentUmbrella.d.ts +63 -0
- package/esm/enrichments/parseEnrichmentUmbrella.d.ts.map +1 -0
- package/esm/enrichments/parseEnrichmentUmbrella.js +66 -0
- package/esm/enrichments/toEnrichmentDescriptor.d.ts.map +1 -1
- package/esm/enrichments/toEnrichmentDescriptor.js +1 -20
- package/esm/enrichments/valibotShape.d.ts +51 -0
- package/esm/enrichments/valibotShape.d.ts.map +1 -0
- package/esm/enrichments/valibotShape.js +37 -0
- package/esm/helpers/nearestKey.d.ts +18 -0
- package/esm/helpers/nearestKey.d.ts.map +1 -0
- package/esm/helpers/nearestKey.js +60 -0
- package/esm/mod.d.ts +2 -0
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +2 -0
- package/esm/run/toArtifacts.d.ts.map +1 -1
- package/esm/run/toArtifacts.js +2 -1
- package/esm/types/Manifest.d.ts +9 -0
- package/esm/types/Manifest.d.ts.map +1 -1
- package/esm/types/Manifest.js +2 -0
- package/package.json +1 -1
- package/script/context/CoreContext.d.ts.map +1 -1
- package/script/context/CoreContext.js +4 -2
- package/script/context/GenerateContext.d.ts +16 -2
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +94 -15
- package/script/context/generateTypes.d.ts +33 -2
- package/script/context/generateTypes.d.ts.map +1 -1
- package/script/dsl/model/ModelDriver.d.ts.map +1 -1
- package/script/dsl/model/ModelDriver.js +1 -5
- package/script/dsl/model/toModelProjectionBase.d.ts +1 -1
- package/script/dsl/model/toModelProjectionBase.d.ts.map +1 -1
- package/script/dsl/model/toModelProjectionBase.js +9 -45
- package/script/dsl/operation/gql/GqlOperationDriver.d.ts.map +1 -1
- package/script/dsl/operation/gql/GqlOperationDriver.js +1 -6
- package/script/dsl/operation/gql/toGqlOperationProjectionBase.d.ts +1 -1
- package/script/dsl/operation/gql/toGqlOperationProjectionBase.d.ts.map +1 -1
- package/script/dsl/operation/gql/toGqlOperationProjectionBase.js +9 -51
- package/script/dsl/operation/oas/OasOperationDriver.d.ts.map +1 -1
- package/script/dsl/operation/oas/OasOperationDriver.js +1 -6
- package/script/dsl/operation/oas/toOasOperationProjectionBase.d.ts +1 -1
- package/script/dsl/operation/oas/toOasOperationProjectionBase.d.ts.map +1 -1
- package/script/dsl/operation/oas/toOasOperationProjectionBase.js +9 -51
- package/script/dsl/webhook/WebhookDriver.d.ts.map +1 -1
- package/script/dsl/webhook/WebhookDriver.js +1 -6
- package/script/dsl/webhook/toWebhookProjectionBase.d.ts +1 -1
- package/script/dsl/webhook/toWebhookProjectionBase.d.ts.map +1 -1
- package/script/dsl/webhook/toWebhookProjectionBase.js +9 -51
- package/script/enrichments/EnrichmentAudit.d.ts +79 -0
- package/script/enrichments/EnrichmentAudit.d.ts.map +1 -0
- package/script/enrichments/EnrichmentAudit.js +215 -0
- package/script/enrichments/EnrichmentWarning.d.ts +72 -0
- package/script/enrichments/EnrichmentWarning.d.ts.map +1 -0
- package/script/enrichments/EnrichmentWarning.js +87 -0
- package/script/enrichments/findUnknownKeys.d.ts +40 -0
- package/script/enrichments/findUnknownKeys.d.ts.map +1 -0
- package/script/enrichments/findUnknownKeys.js +84 -0
- package/script/enrichments/parseEnrichmentUmbrella.d.ts +63 -0
- package/script/enrichments/parseEnrichmentUmbrella.d.ts.map +1 -0
- package/script/enrichments/parseEnrichmentUmbrella.js +103 -0
- package/script/enrichments/toEnrichmentDescriptor.d.ts.map +1 -1
- package/script/enrichments/toEnrichmentDescriptor.js +10 -29
- package/script/enrichments/valibotShape.d.ts +51 -0
- package/script/enrichments/valibotShape.d.ts.map +1 -0
- package/script/enrichments/valibotShape.js +44 -0
- package/script/helpers/nearestKey.d.ts +18 -0
- package/script/helpers/nearestKey.d.ts.map +1 -0
- package/script/helpers/nearestKey.js +64 -0
- package/script/mod.d.ts +2 -0
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +2 -0
- package/script/run/toArtifacts.d.ts.map +1 -1
- package/script/run/toArtifacts.js +2 -1
- package/script/types/Manifest.d.ts +9 -0
- package/script/types/Manifest.d.ts.map +1 -1
- package/script/types/Manifest.js +2 -0
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { toGqlOperationGeneratorKey } from '../../GeneratorKeys.js';
|
|
2
|
-
import * as v from 'valibot';
|
|
3
|
-
import get from 'lodash-es/get.js';
|
|
4
2
|
import { DEFAULT_VARIANT } from '../../../types/Variant.js';
|
|
5
|
-
import {
|
|
3
|
+
import { parseEnrichmentUmbrella } from '../../../enrichments/parseEnrichmentUmbrella.js';
|
|
6
4
|
/**
|
|
7
5
|
* Build a GraphQL operation projection base class from a per-generator
|
|
8
6
|
* config.
|
|
@@ -148,18 +146,14 @@ export const toGqlOperationProjectionBase = (base, config) => {
|
|
|
148
146
|
// and the variant axis is core-owned; generator and stack are
|
|
149
147
|
// run-constants (`[id][_generator]`, `[_stack]`). The required composite
|
|
150
148
|
// schema parses the raw umbrella once — typed, cast-free.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
generator: get(context.settings, ['enrichments', config.id, GENERATOR_ENRICHMENT_KEY]),
|
|
160
|
-
stack: get(context.settings, ['enrichments', STACK_ENRICHMENT_KEY])
|
|
161
|
-
};
|
|
162
|
-
return v.parse(config.toEnrichmentSchema(), raw);
|
|
149
|
+
// The helper routes the reads through the recording accessor
|
|
150
|
+
// (consumption audit) and reports schema-dropped keys.
|
|
151
|
+
return parseEnrichmentUmbrella({
|
|
152
|
+
context,
|
|
153
|
+
generatorId: config.id,
|
|
154
|
+
subjectSegments: [operation.rootKind, operation.fieldName, variant],
|
|
155
|
+
schema: config.toEnrichmentSchema()
|
|
156
|
+
});
|
|
163
157
|
}
|
|
164
158
|
}),
|
|
165
159
|
_a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OasOperationDriver.d.ts","sourceRoot":"","sources":["../../../../src/dsl/operation/oas/OasOperationDriver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAI/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAE7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"OasOperationDriver.d.ts","sourceRoot":"","sources":["../../../../src/dsl/operation/oas/OasOperationDriver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAI/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAE7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AAG5E,KAAK,mBAAmB,CAAC,CAAC,SAAS,cAAc,EAAE,cAAc,GAAG,SAAS,IAAI;IAC/E,OAAO,EAAE,mBAAmB,CAAA;IAC5B,UAAU,EAAE,sBAAsB,CAAC,CAAC,EAAE,cAAc,CAAC,CAAA;IACrD,SAAS,EAAE,YAAY,CAAA;IACvB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAWD;;;;;;;;GAQG;AACH,qBAAa,kBAAkB,CAAC,CAAC,SAAS,cAAc,EAAE,cAAc,GAAG,SAAS;IAClF,OAAO,EAAE,mBAAmB,CAAA;IAC5B,UAAU,EAAE,sBAAsB,CAAC,CAAC,EAAE,cAAc,CAAC,CAAA;IACrD,SAAS,EAAE,YAAY,CAAA;IACvB,QAAQ,EAAE,eAAe,CAAC,cAAc,CAAC,CAAA;IACzC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAA;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;gBAEH,EACV,OAAO,EACP,UAAU,EACV,SAAS,EACT,eAAe,EACf,QAAQ,EACR,OAAyB,EAC1B,EAAE,mBAAmB,CAAC,CAAC,EAAE,cAAc,CAAC;IA0BzC,OAAO,CAAC,KAAK;IAsBb;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,aAAa;IAgCrB,OAAO,CAAC,gBAAgB;CAsBzB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { normalize } from '../../../deps/jsr.io/@std/path/1.1.6/normalize.js';
|
|
2
2
|
import { toOasOperationGeneratorKey } from '../../GeneratorKeys.js';
|
|
3
3
|
import { DEFAULT_VARIANT } from '../../../types/Variant.js';
|
|
4
|
-
import get from 'lodash-es/get.js';
|
|
5
4
|
/**
|
|
6
5
|
* Driver for the OAS operation insertion lifecycle.
|
|
7
6
|
*
|
|
@@ -171,8 +170,7 @@ const assertPeerVariantExists = ({ context, generatorId, operation, variant }) =
|
|
|
171
170
|
if (variant === DEFAULT_VARIANT) {
|
|
172
171
|
return;
|
|
173
172
|
}
|
|
174
|
-
const opEnrichments =
|
|
175
|
-
'enrichments',
|
|
173
|
+
const opEnrichments = context.readEnrichment([
|
|
176
174
|
generatorId,
|
|
177
175
|
operation.path,
|
|
178
176
|
operation.method
|
|
@@ -12,7 +12,7 @@ import type { OasSchema } from '../../../oas/schema/Schema.js';
|
|
|
12
12
|
import type { OasRef } from '../../../oas/ref/Ref.js';
|
|
13
13
|
import type { OasVoid } from '../../../oas/void/Void.js';
|
|
14
14
|
import type { OasOperationProjection, OasOperationProjectionConstructorArgs, ToOasOperationIdentifierNameArgs, ToOasOperationExportPathArgs } from './types.js';
|
|
15
|
-
import * as v from 'valibot';
|
|
15
|
+
import type * as v from 'valibot';
|
|
16
16
|
/**
|
|
17
17
|
* Configuration for {@link toOasOperationProjectionBase}.
|
|
18
18
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toOasOperationProjectionBase.d.ts","sourceRoot":"","sources":["../../../../src/dsl/operation/oas/toOasOperationProjectionBase.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AAC5E,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,KAAK,EACV,sBAAsB,EACtB,qCAAqC,EACrC,gCAAgC,EAChC,4BAA4B,EAC7B,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"toOasOperationProjectionBase.d.ts","sourceRoot":"","sources":["../../../../src/dsl/operation/oas/toOasOperationProjectionBase.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AAC5E,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,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
1
|
import { toOasOperationGeneratorKey } from '../../GeneratorKeys.js';
|
|
2
|
-
import * as v from 'valibot';
|
|
3
|
-
import get from 'lodash-es/get.js';
|
|
4
2
|
import { DEFAULT_VARIANT } from '../../../types/Variant.js';
|
|
5
|
-
import {
|
|
3
|
+
import { parseEnrichmentUmbrella } from '../../../enrichments/parseEnrichmentUmbrella.js';
|
|
6
4
|
/**
|
|
7
5
|
* Build an OAS operation projection base class from a per-generator config.
|
|
8
6
|
*
|
|
@@ -148,18 +146,14 @@ export const toOasOperationProjectionBase = (base, config) => {
|
|
|
148
146
|
// the engine has already asserted `'main'` exists; generator and stack
|
|
149
147
|
// are run-constants (`[id][_generator]`, `[_stack]`). The required
|
|
150
148
|
// composite schema parses the raw umbrella once — typed, cast-free.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
generator: get(context.settings, ['enrichments', config.id, GENERATOR_ENRICHMENT_KEY]),
|
|
160
|
-
stack: get(context.settings, ['enrichments', STACK_ENRICHMENT_KEY])
|
|
161
|
-
};
|
|
162
|
-
return v.parse(config.toEnrichmentSchema(), raw);
|
|
149
|
+
// The helper routes the reads through the recording accessor
|
|
150
|
+
// (consumption audit) and reports schema-dropped keys.
|
|
151
|
+
return parseEnrichmentUmbrella({
|
|
152
|
+
context,
|
|
153
|
+
generatorId: config.id,
|
|
154
|
+
subjectSegments: [operation.path, operation.method, variant],
|
|
155
|
+
schema: config.toEnrichmentSchema()
|
|
156
|
+
});
|
|
163
157
|
}
|
|
164
158
|
}),
|
|
165
159
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebhookDriver.d.ts","sourceRoot":"","sources":["../../../src/dsl/webhook/WebhookDriver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE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;IAChD,OAAO,EAAE,UAAU,CAAA;IACnB,QAAQ,EAAE,eAAe,CAAC,cAAc,CAAC,CAAA;IACzC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAA;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;gBAEH,EACV,OAAO,EACP,UAAU,EACV,OAAO,EACP,eAAe,EACf,QAAQ,EACR,OAAyB,EAC1B,EAAE,iBAAiB,CAAC,CAAC,EAAE,cAAc,CAAC;IA0BvC,OAAO,CAAC,KAAK;IAiBb;;;OAGG;IACH,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,aAAa;IAgCrB,OAAO,CAAC,gBAAgB;CAsBzB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { normalize } from '../../deps/jsr.io/@std/path/1.1.6/normalize.js';
|
|
2
2
|
import { toWebhookGeneratorKey } from '../GeneratorKeys.js';
|
|
3
3
|
import { DEFAULT_VARIANT } from '../../types/Variant.js';
|
|
4
|
-
import get from 'lodash-es/get.js';
|
|
5
4
|
/**
|
|
6
5
|
* Driver for the webhook insertion lifecycle.
|
|
7
6
|
*
|
|
@@ -155,8 +154,7 @@ const assertPeerVariantExists = ({ context, generatorId, webhook, variant }) =>
|
|
|
155
154
|
if (variant === DEFAULT_VARIANT) {
|
|
156
155
|
return;
|
|
157
156
|
}
|
|
158
|
-
const webhookEnrichments =
|
|
159
|
-
'enrichments',
|
|
157
|
+
const webhookEnrichments = context.readEnrichment([
|
|
160
158
|
generatorId,
|
|
161
159
|
webhook.name,
|
|
162
160
|
webhook.method
|
|
@@ -14,7 +14,7 @@ import type { OasSchema } from '../../oas/schema/Schema.js';
|
|
|
14
14
|
import type { OasRef } from '../../oas/ref/Ref.js';
|
|
15
15
|
import type { OasVoid } from '../../oas/void/Void.js';
|
|
16
16
|
import type { WebhookProjectionConstructorArgs, ToWebhookIdentifierNameArgs, ToWebhookExportPathArgs } from './types.js';
|
|
17
|
-
import * as v from 'valibot';
|
|
17
|
+
import type * as v from 'valibot';
|
|
18
18
|
/**
|
|
19
19
|
* Configuration for {@link toWebhookProjectionBase}.
|
|
20
20
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toWebhookProjectionBase.d.ts","sourceRoot":"","sources":["../../../src/dsl/webhook/toWebhookProjectionBase.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AACzE,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AACvE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EACV,gCAAgC,EAChC,2BAA2B,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,0BAC9C,sBAAsB,CAAC,CAAC,EAAE,kBAAkB,CAAC,aAC9C,YAAY,YACd,IAAI,CAAC,sBAAsB,EAAE,UAAU,GAAG,SAAS,CAAC,GAC5D,QAAQ,CAAC,CAAC,EAAE,kBAAkB,CAAC;QAUlC;;;WAGG;oBACS,CAAC,SAAS,cAAc,gDACtB,eAAe,CAAC,CAAC,EAAE,oBAAkB,CAAC,WACzC,OAAO,YACP,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,SAAS,CAAC,GACxD,QAAQ,CAAC,CAAC,EAAE,oBAAkB,CAAC;QAQlC;;;;WAIG;8BAED,CAAC,SAAS,cAAc,EACxB,MAAM,SAAS,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,OAAO,gDAGzC,eAAe,CAAC,CAAC,EAAE,oBAAkB,CAAC,4BACxB,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC,YAC3E,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,SAAS,CAAC,GACxD,2BAA2B,CAAC,CAAC,EAAE,MAAM,CAAC;;;;;;;UAlG3B,SAAS;6EA3DgD,MAAM;gCAMnD,UAAU,WAAW,mBAAmB;qEACH,MAAM;wBAoBlD;QAAE,OAAO,EAAE,UAAU,CAAC;QAAC,OAAO,EAAE,mBAAmB,CAAA;KAAE,KAAK,OAAO;oBAwC5D,+BAA+B,iBAAiB,KAAG,cAAc;IAiBzF;;;;OAIG;2BAC4B,MAAM,iBAAiB,KAAG,cAAc,GAAG,SAAS;;CAmFtF,CAAA"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { toWebhookGeneratorKey } from '../GeneratorKeys.js';
|
|
2
|
-
import * as v from 'valibot';
|
|
3
|
-
import get from 'lodash-es/get.js';
|
|
4
2
|
import { DEFAULT_VARIANT } from '../../types/Variant.js';
|
|
5
|
-
import {
|
|
3
|
+
import { parseEnrichmentUmbrella } from '../../enrichments/parseEnrichmentUmbrella.js';
|
|
6
4
|
/**
|
|
7
5
|
* Build a webhook projection base class from a per-generator config.
|
|
8
6
|
*
|
|
@@ -131,18 +129,14 @@ export const toWebhookProjectionBase = (base, config) => {
|
|
|
131
129
|
// the engine has already asserted `'main'` exists; generator and stack
|
|
132
130
|
// are run-constants (`[id][_generator]`, `[_stack]`). The required
|
|
133
131
|
// composite schema parses the raw umbrella once — typed, cast-free.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
generator: get(context.settings, ['enrichments', config.id, GENERATOR_ENRICHMENT_KEY]),
|
|
143
|
-
stack: get(context.settings, ['enrichments', STACK_ENRICHMENT_KEY])
|
|
144
|
-
};
|
|
145
|
-
return v.parse(config.toEnrichmentSchema(), raw);
|
|
132
|
+
// The helper routes the reads through the recording accessor
|
|
133
|
+
// (consumption audit) and reports schema-dropped keys.
|
|
134
|
+
return parseEnrichmentUmbrella({
|
|
135
|
+
context,
|
|
136
|
+
generatorId: config.id,
|
|
137
|
+
subjectSegments: [webhook.name, webhook.method, variant],
|
|
138
|
+
schema: config.toEnrichmentSchema()
|
|
139
|
+
});
|
|
146
140
|
}
|
|
147
141
|
}),
|
|
148
142
|
/**
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The enrichment consumption audit.
|
|
3
|
+
*
|
|
4
|
+
* The engine already performs every enrichment lookup during the generate
|
|
5
|
+
* walk — the dispatch loops read each `[generatorId][...subject]` block to
|
|
6
|
+
* enumerate variants, the projection statics read each subject leaf and
|
|
7
|
+
* the run-constant scopes, and the Drivers read peer blocks for the
|
|
8
|
+
* variant guard. `EnrichmentAudit` records those lookups (every read is
|
|
9
|
+
* routed through `GenerateContext.readEnrichment`, the single choke
|
|
10
|
+
* point) and, post-walk, diffs them against the paths actually present in
|
|
11
|
+
* `settings.enrichments`. A configured path no lookup touched is dead
|
|
12
|
+
* config — a typo'd generator id / path / method / model name, or an
|
|
13
|
+
* entry orphaned by spec evolution — and becomes an
|
|
14
|
+
* `UNCONSUMED_ENRICHMENT` warning on the manifest.
|
|
15
|
+
*
|
|
16
|
+
* Consumption is recorded prefix-closed: consuming
|
|
17
|
+
* `[id, '/pets', 'post', 'main']` also marks `[id, '/pets', 'post']`,
|
|
18
|
+
* `[id, '/pets']`, and `[id]`. The present-path enumeration walks each
|
|
19
|
+
* generator's slice to the block depth its entry type dictates (model:
|
|
20
|
+
* `[refName]`; operation / webhook / GQL: two segments), so the diff
|
|
21
|
+
* compares like with like. Reserved keys (`_generator`, `_stack`) are
|
|
22
|
+
* engine-owned constants and never flagged.
|
|
23
|
+
*
|
|
24
|
+
* Everything here is warn-level and fail-open — the audit can only add
|
|
25
|
+
* warnings to the manifest, never change generation output.
|
|
26
|
+
*
|
|
27
|
+
* @module EnrichmentAudit
|
|
28
|
+
*/
|
|
29
|
+
import { type GeneratorEnrichments } from '../types/Enrichments.js';
|
|
30
|
+
import { type EnrichmentWarning } from './EnrichmentWarning.js';
|
|
31
|
+
/**
|
|
32
|
+
* The slice of a generator entry the audit needs: its id and the entry
|
|
33
|
+
* type that dictates its enrichment routing depth.
|
|
34
|
+
*/
|
|
35
|
+
export type AuditGenerator = {
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly type: 'oasOperation' | 'gqlOperation' | 'model' | 'webhook';
|
|
38
|
+
};
|
|
39
|
+
type FinalizeArgs = {
|
|
40
|
+
/** The consumer's `client.json#settings.enrichments` record. */
|
|
41
|
+
enrichments: GeneratorEnrichments | undefined;
|
|
42
|
+
/** The generators configured for this run. */
|
|
43
|
+
generators: readonly AuditGenerator[];
|
|
44
|
+
/**
|
|
45
|
+
* Generator ids the consumer skipped wholesale (string entries in
|
|
46
|
+
* `settings.skip`). Their slices are reported as info, not warnings —
|
|
47
|
+
* a temporary skip is legitimate, not dead config.
|
|
48
|
+
*/
|
|
49
|
+
skippedGeneratorIds: readonly string[];
|
|
50
|
+
};
|
|
51
|
+
export declare class EnrichmentAudit {
|
|
52
|
+
#private;
|
|
53
|
+
/**
|
|
54
|
+
* Record one enrichment lookup. Every prefix of `segments` is marked
|
|
55
|
+
* consumed, so block-level and leaf-level reads land in one namespace.
|
|
56
|
+
*/
|
|
57
|
+
consume(segments: readonly string[]): void;
|
|
58
|
+
/**
|
|
59
|
+
* Add a warning, deduplicated on `(type, path)` — the same lookup can
|
|
60
|
+
* repeat many times per run (one per insert call) and must produce one
|
|
61
|
+
* warning.
|
|
62
|
+
*/
|
|
63
|
+
report(warning: EnrichmentWarning): void;
|
|
64
|
+
/**
|
|
65
|
+
* Diff the configured enrichment paths against the consumed set and
|
|
66
|
+
* return every warning gathered during the run plus the addressing
|
|
67
|
+
* misses found here. Called once, after the generate walk.
|
|
68
|
+
*/
|
|
69
|
+
finalize({ enrichments, generators, skippedGeneratorIds }: FinalizeArgs): EnrichmentWarning[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Whether an enrichment block declares the given variant — the presence
|
|
73
|
+
* probe behind `SKIPPED_SUBJECT_ENRICHMENT` info lines. Exported for the
|
|
74
|
+
* dispatch loops; a non-record block (absent or malformed) has no
|
|
75
|
+
* variants.
|
|
76
|
+
*/
|
|
77
|
+
export declare const hasVariantEnrichment: (block: unknown, variant: string) => boolean;
|
|
78
|
+
export {};
|
|
79
|
+
//# sourceMappingURL=EnrichmentAudit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnrichmentAudit.d.ts","sourceRoot":"","sources":["../../src/enrichments/EnrichmentAudit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAwB,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAGrF;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,cAAc,GAAG,OAAO,GAAG,SAAS,CAAA;CACrE,CAAA;AAED,KAAK,YAAY,GAAG;IAClB,gEAAgE;IAChE,WAAW,EAAE,oBAAoB,GAAG,SAAS,CAAA;IAC7C,8CAA8C;IAC9C,UAAU,EAAE,SAAS,cAAc,EAAE,CAAA;IACrC;;;;OAIG;IACH,mBAAmB,EAAE,SAAS,MAAM,EAAE,CAAA;CACvC,CAAA;AAOD,qBAAa,eAAe;;IAS1B;;;OAGG;IACH,OAAO,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI;IAkB1C;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IA6CxC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,mBAAmB,EAAE,EAAE,YAAY,GAAG,iBAAiB,EAAE;CAgG9F;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,OAAO,EAAE,SAAS,MAAM,KAAG,OAClC,CAAA"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The enrichment consumption audit.
|
|
3
|
+
*
|
|
4
|
+
* The engine already performs every enrichment lookup during the generate
|
|
5
|
+
* walk — the dispatch loops read each `[generatorId][...subject]` block to
|
|
6
|
+
* enumerate variants, the projection statics read each subject leaf and
|
|
7
|
+
* the run-constant scopes, and the Drivers read peer blocks for the
|
|
8
|
+
* variant guard. `EnrichmentAudit` records those lookups (every read is
|
|
9
|
+
* routed through `GenerateContext.readEnrichment`, the single choke
|
|
10
|
+
* point) and, post-walk, diffs them against the paths actually present in
|
|
11
|
+
* `settings.enrichments`. A configured path no lookup touched is dead
|
|
12
|
+
* config — a typo'd generator id / path / method / model name, or an
|
|
13
|
+
* entry orphaned by spec evolution — and becomes an
|
|
14
|
+
* `UNCONSUMED_ENRICHMENT` warning on the manifest.
|
|
15
|
+
*
|
|
16
|
+
* Consumption is recorded prefix-closed: consuming
|
|
17
|
+
* `[id, '/pets', 'post', 'main']` also marks `[id, '/pets', 'post']`,
|
|
18
|
+
* `[id, '/pets']`, and `[id]`. The present-path enumeration walks each
|
|
19
|
+
* generator's slice to the block depth its entry type dictates (model:
|
|
20
|
+
* `[refName]`; operation / webhook / GQL: two segments), so the diff
|
|
21
|
+
* compares like with like. Reserved keys (`_generator`, `_stack`) are
|
|
22
|
+
* engine-owned constants and never flagged.
|
|
23
|
+
*
|
|
24
|
+
* Everything here is warn-level and fail-open — the audit can only add
|
|
25
|
+
* warnings to the manifest, never change generation output.
|
|
26
|
+
*
|
|
27
|
+
* @module EnrichmentAudit
|
|
28
|
+
*/
|
|
29
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
30
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
31
|
+
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");
|
|
32
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
33
|
+
};
|
|
34
|
+
var _EnrichmentAudit_instances, _EnrichmentAudit_consumed, _EnrichmentAudit_children, _EnrichmentAudit_warnings, _EnrichmentAudit_reported, _EnrichmentAudit_isConsumed, _EnrichmentAudit_divergenceSuggestion, _EnrichmentAudit_checkBlock;
|
|
35
|
+
import { STACK_ENRICHMENT_KEY, isReservedEnrichmentKey } from '../types/Enrichments.js';
|
|
36
|
+
import { formatEnrichmentPath } from './EnrichmentWarning.js';
|
|
37
|
+
import { nearestKey } from '../helpers/nearestKey.js';
|
|
38
|
+
const toPathKey = (segments) => JSON.stringify(segments);
|
|
39
|
+
const isRecord = (input) => typeof input === 'object' && input !== null && !Array.isArray(input);
|
|
40
|
+
export class EnrichmentAudit {
|
|
41
|
+
constructor() {
|
|
42
|
+
_EnrichmentAudit_instances.add(this);
|
|
43
|
+
/** Prefix-closed set of consumed routing paths, keyed by {@link toPathKey}. */
|
|
44
|
+
_EnrichmentAudit_consumed.set(this, new Set()
|
|
45
|
+
/** Consumed child segments per parent path — the suggestion candidates. */
|
|
46
|
+
);
|
|
47
|
+
/** Consumed child segments per parent path — the suggestion candidates. */
|
|
48
|
+
_EnrichmentAudit_children.set(this, new Map());
|
|
49
|
+
_EnrichmentAudit_warnings.set(this, []
|
|
50
|
+
/** Identity keys of reported warnings — reads repeat, warnings must not. */
|
|
51
|
+
);
|
|
52
|
+
/** Identity keys of reported warnings — reads repeat, warnings must not. */
|
|
53
|
+
_EnrichmentAudit_reported.set(this, new Set()
|
|
54
|
+
/**
|
|
55
|
+
* Record one enrichment lookup. Every prefix of `segments` is marked
|
|
56
|
+
* consumed, so block-level and leaf-level reads land in one namespace.
|
|
57
|
+
*/
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Record one enrichment lookup. Every prefix of `segments` is marked
|
|
62
|
+
* consumed, so block-level and leaf-level reads land in one namespace.
|
|
63
|
+
*/
|
|
64
|
+
consume(segments) {
|
|
65
|
+
let parentKey = toPathKey([]);
|
|
66
|
+
for (let end = 1; end <= segments.length; end++) {
|
|
67
|
+
const key = toPathKey(segments.slice(0, end));
|
|
68
|
+
__classPrivateFieldGet(this, _EnrichmentAudit_consumed, "f").add(key);
|
|
69
|
+
const siblings = __classPrivateFieldGet(this, _EnrichmentAudit_children, "f").get(parentKey);
|
|
70
|
+
if (siblings) {
|
|
71
|
+
siblings.add(segments[end - 1]);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
__classPrivateFieldGet(this, _EnrichmentAudit_children, "f").set(parentKey, new Set([segments[end - 1]]));
|
|
75
|
+
}
|
|
76
|
+
parentKey = key;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Add a warning, deduplicated on `(type, path)` — the same lookup can
|
|
81
|
+
* repeat many times per run (one per insert call) and must produce one
|
|
82
|
+
* warning.
|
|
83
|
+
*/
|
|
84
|
+
report(warning) {
|
|
85
|
+
const key = toPathKey([warning.type, ...warning.path]);
|
|
86
|
+
if (__classPrivateFieldGet(this, _EnrichmentAudit_reported, "f").has(key))
|
|
87
|
+
return;
|
|
88
|
+
__classPrivateFieldGet(this, _EnrichmentAudit_reported, "f").add(key);
|
|
89
|
+
__classPrivateFieldGet(this, _EnrichmentAudit_warnings, "f").push(warning);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Diff the configured enrichment paths against the consumed set and
|
|
93
|
+
* return every warning gathered during the run plus the addressing
|
|
94
|
+
* misses found here. Called once, after the generate walk.
|
|
95
|
+
*/
|
|
96
|
+
finalize({ enrichments, generators, skippedGeneratorIds }) {
|
|
97
|
+
if (!isRecord(enrichments))
|
|
98
|
+
return [...__classPrivateFieldGet(this, _EnrichmentAudit_warnings, "f")];
|
|
99
|
+
const generatorsById = new Map(generators.map(generator => [generator.id, generator]));
|
|
100
|
+
const skipped = new Set(skippedGeneratorIds);
|
|
101
|
+
for (const [generatorId, slot] of Object.entries(enrichments)) {
|
|
102
|
+
if (generatorId === STACK_ENRICHMENT_KEY)
|
|
103
|
+
continue;
|
|
104
|
+
// Other `_`-prefixed keys are structurally invalid — the
|
|
105
|
+
// `generatorEnrichments` schema flags those at config load.
|
|
106
|
+
if (isReservedEnrichmentKey(generatorId))
|
|
107
|
+
continue;
|
|
108
|
+
if (skipped.has(generatorId)) {
|
|
109
|
+
this.report({
|
|
110
|
+
level: 'info',
|
|
111
|
+
type: 'SKIPPED_GENERATOR_ENRICHMENT',
|
|
112
|
+
path: [generatorId],
|
|
113
|
+
message: `generator '${generatorId}' is skipped in this run — ` +
|
|
114
|
+
`its enrichments were not applied`
|
|
115
|
+
});
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const generator = generatorsById.get(generatorId);
|
|
119
|
+
if (!generator) {
|
|
120
|
+
// An insert-only peer (reached via insertOperation / insertModel
|
|
121
|
+
// without an entry of its own) still consumes its slice through
|
|
122
|
+
// the projection statics — a consumed prefix means the slice is
|
|
123
|
+
// live, and without an entry type its depth is unknowable, so the
|
|
124
|
+
// audit leaves it alone.
|
|
125
|
+
if (__classPrivateFieldGet(this, _EnrichmentAudit_instances, "m", _EnrichmentAudit_isConsumed).call(this, [generatorId]))
|
|
126
|
+
continue;
|
|
127
|
+
const suggestion = nearestKey(generatorId, generatorsById.keys());
|
|
128
|
+
this.report({
|
|
129
|
+
level: 'warning',
|
|
130
|
+
type: 'UNKNOWN_GENERATOR_ID',
|
|
131
|
+
path: [generatorId],
|
|
132
|
+
message: `enrichments are configured for '${generatorId}' but no generator ` +
|
|
133
|
+
`with that id is in this run` +
|
|
134
|
+
(suggestion !== undefined ? ` (did you mean '${suggestion}'?)` : ''),
|
|
135
|
+
...(suggestion !== undefined ? { suggestion } : {})
|
|
136
|
+
});
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (!isRecord(slot))
|
|
140
|
+
continue;
|
|
141
|
+
// The generator is in the run but consumed nothing at all — the
|
|
142
|
+
// document has no subjects of its type (or the wrong protocol).
|
|
143
|
+
// Per-entry warnings would fall back to cross-generator siblings for
|
|
144
|
+
// their "did you mean …?" and could name an unrelated generator, so
|
|
145
|
+
// collapse to one generator-level warning that says what happened.
|
|
146
|
+
const hasSubjectEntries = Object.keys(slot).some(key => !isReservedEnrichmentKey(key));
|
|
147
|
+
if (!__classPrivateFieldGet(this, _EnrichmentAudit_instances, "m", _EnrichmentAudit_isConsumed).call(this, [generatorId]) && hasSubjectEntries) {
|
|
148
|
+
this.report({
|
|
149
|
+
level: 'warning',
|
|
150
|
+
type: 'UNCONSUMED_ENRICHMENT',
|
|
151
|
+
path: [generatorId],
|
|
152
|
+
message: `enrichments are configured for '${generatorId}' but it matched ` +
|
|
153
|
+
`no subjects in this run — its enrichments were never read`
|
|
154
|
+
});
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
// Block depth per entry type: `[refName]` for models,
|
|
158
|
+
// `[path][method]` / `[name][method]` / `[rootKind][fieldName]`
|
|
159
|
+
// for the operation-shaped types.
|
|
160
|
+
const subjectDepth = generator.type === 'model' ? 1 : 2;
|
|
161
|
+
for (const [subjectKey, subjectValue] of Object.entries(slot)) {
|
|
162
|
+
// `_generator` (and any other reserved key) is engine-owned — read
|
|
163
|
+
// through the dedicated helpers by known key, always consumed.
|
|
164
|
+
if (isReservedEnrichmentKey(subjectKey))
|
|
165
|
+
continue;
|
|
166
|
+
if (subjectDepth === 1 ||
|
|
167
|
+
!isRecord(subjectValue) ||
|
|
168
|
+
Object.keys(subjectValue).length === 0) {
|
|
169
|
+
__classPrivateFieldGet(this, _EnrichmentAudit_instances, "m", _EnrichmentAudit_checkBlock).call(this, [generatorId, subjectKey]);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
for (const methodKey of Object.keys(subjectValue)) {
|
|
173
|
+
__classPrivateFieldGet(this, _EnrichmentAudit_instances, "m", _EnrichmentAudit_checkBlock).call(this, [generatorId, subjectKey, methodKey]);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return [...__classPrivateFieldGet(this, _EnrichmentAudit_warnings, "f")];
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
_EnrichmentAudit_consumed = new WeakMap(), _EnrichmentAudit_children = new WeakMap(), _EnrichmentAudit_warnings = new WeakMap(), _EnrichmentAudit_reported = new WeakMap(), _EnrichmentAudit_instances = new WeakSet(), _EnrichmentAudit_isConsumed = function _EnrichmentAudit_isConsumed(segments) {
|
|
181
|
+
return __classPrivateFieldGet(this, _EnrichmentAudit_consumed, "f").has(toPathKey(segments));
|
|
182
|
+
}, _EnrichmentAudit_divergenceSuggestion = function _EnrichmentAudit_divergenceSuggestion(path) {
|
|
183
|
+
for (let depth = 0; depth < path.length; depth++) {
|
|
184
|
+
if (__classPrivateFieldGet(this, _EnrichmentAudit_instances, "m", _EnrichmentAudit_isConsumed).call(this, path.slice(0, depth + 1)))
|
|
185
|
+
continue;
|
|
186
|
+
const siblings = __classPrivateFieldGet(this, _EnrichmentAudit_children, "f").get(toPathKey(path.slice(0, depth)));
|
|
187
|
+
return siblings ? nearestKey(path[depth], siblings) : undefined;
|
|
188
|
+
}
|
|
189
|
+
return undefined;
|
|
190
|
+
}, _EnrichmentAudit_checkBlock = function _EnrichmentAudit_checkBlock(path) {
|
|
191
|
+
if (__classPrivateFieldGet(this, _EnrichmentAudit_instances, "m", _EnrichmentAudit_isConsumed).call(this, path))
|
|
192
|
+
return;
|
|
193
|
+
const suggestion = __classPrivateFieldGet(this, _EnrichmentAudit_instances, "m", _EnrichmentAudit_divergenceSuggestion).call(this, path);
|
|
194
|
+
this.report({
|
|
195
|
+
level: 'warning',
|
|
196
|
+
type: 'UNCONSUMED_ENRICHMENT',
|
|
197
|
+
path,
|
|
198
|
+
message: `enrichment entry '${formatEnrichmentPath(path)}' was never consumed — ` +
|
|
199
|
+
`no matching generator or subject in this run` +
|
|
200
|
+
(suggestion !== undefined ? ` (did you mean '${suggestion}'?)` : ''),
|
|
201
|
+
...(suggestion !== undefined ? { suggestion } : {})
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Whether an enrichment block declares the given variant — the presence
|
|
206
|
+
* probe behind `SKIPPED_SUBJECT_ENRICHMENT` info lines. Exported for the
|
|
207
|
+
* dispatch loops; a non-record block (absent or malformed) has no
|
|
208
|
+
* variants.
|
|
209
|
+
*/
|
|
210
|
+
export const hasVariantEnrichment = (block, variant) => isRecord(block) && variant in block;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The enrichment-warning surface — the manifest's record of
|
|
3
|
+
* enrichment config that did not do what the consumer intended.
|
|
4
|
+
*
|
|
5
|
+
* Three validation layers precede this one: structural validation at CLI
|
|
6
|
+
* load (`generatorEnrichments`), the per-leaf Valibot parse at generate
|
|
7
|
+
* time (a wrongly-typed value in a reached leaf throws), and the
|
|
8
|
+
* missing-`'main'` variant throw (`toVariantList`). All three are loud.
|
|
9
|
+
* What they cannot see is *addressing*: a typo'd generator id, path,
|
|
10
|
+
* method, or model name makes `get()` miss silently — defaults apply and
|
|
11
|
+
* the config entry is dead. Unknown leaf keys are equally silent:
|
|
12
|
+
* `v.object` strips them before the generator sees them.
|
|
13
|
+
*
|
|
14
|
+
* `EnrichmentWarning` is the shared shape for both detectors:
|
|
15
|
+
*
|
|
16
|
+
* - the **consumption audit** (`EnrichmentAudit`) — records every
|
|
17
|
+
* enrichment lookup the engine performs during the generate walk and,
|
|
18
|
+
* post-walk, flags configured entries no lookup ever touched;
|
|
19
|
+
* - **unknown-key detection** (`findUnknownKeys`, run inside
|
|
20
|
+
* `parseEnrichmentUmbrella`) — flags leaf keys the generator's schema
|
|
21
|
+
* does not declare.
|
|
22
|
+
*
|
|
23
|
+
* Both are warn-level and fail-open: generation output is never affected.
|
|
24
|
+
* The warnings ride the manifest (`manifest.enrichmentWarnings`) so
|
|
25
|
+
* post-run diagnostics can re-read them without re-running.
|
|
26
|
+
*
|
|
27
|
+
* @module EnrichmentWarning
|
|
28
|
+
*/
|
|
29
|
+
import * as v from 'valibot';
|
|
30
|
+
/**
|
|
31
|
+
* Discriminates what went wrong with an enrichment entry:
|
|
32
|
+
*
|
|
33
|
+
* - `UNCONSUMED_ENRICHMENT` — a configured routing path no engine lookup
|
|
34
|
+
* consumed (typo'd path / method / model name, or an entry orphaned by
|
|
35
|
+
* spec evolution). Warning.
|
|
36
|
+
* - `UNKNOWN_GENERATOR_ID` — a top-level enrichment key that matches no
|
|
37
|
+
* generator in the run (and no insert-only peer consumed it). Warning.
|
|
38
|
+
* - `UNKNOWN_ENRICHMENT_KEY` — a leaf key the generator's enrichment
|
|
39
|
+
* schema does not declare; Valibot strips it silently. Warning.
|
|
40
|
+
* - `SKIPPED_SUBJECT_ENRICHMENT` — the entry is addressed correctly but
|
|
41
|
+
* its subject was excluded by `skip`/`include`. Info: temporary skips
|
|
42
|
+
* are legitimate, so this is not treated as dead config.
|
|
43
|
+
* - `SKIPPED_GENERATOR_ENRICHMENT` — the whole generator is skipped
|
|
44
|
+
* (string entry in `settings.skip`) while enrichments for it exist.
|
|
45
|
+
* Info, for the same reason.
|
|
46
|
+
*/
|
|
47
|
+
export type EnrichmentWarningType = 'UNCONSUMED_ENRICHMENT' | 'UNKNOWN_GENERATOR_ID' | 'UNKNOWN_ENRICHMENT_KEY' | 'SKIPPED_SUBJECT_ENRICHMENT' | 'SKIPPED_GENERATOR_ENRICHMENT';
|
|
48
|
+
export declare const enrichmentWarningType: v.GenericSchema<EnrichmentWarningType>;
|
|
49
|
+
/**
|
|
50
|
+
* One enrichment-config warning. `path` is the routing key sequence under
|
|
51
|
+
* `client.json#settings.enrichments` locating the offending entry —
|
|
52
|
+
* `[generatorId, ...subjectSegments]` for addressing warnings, extended
|
|
53
|
+
* down to the leaf key for `UNKNOWN_ENRICHMENT_KEY`. `suggestion` carries
|
|
54
|
+
* the nearest known key when a close match exists (`submitLabl` →
|
|
55
|
+
* `submitLabel`); the human-readable `message` already folds it in.
|
|
56
|
+
*/
|
|
57
|
+
export type EnrichmentWarning = {
|
|
58
|
+
level: 'warning' | 'info';
|
|
59
|
+
type: EnrichmentWarningType;
|
|
60
|
+
path: readonly string[];
|
|
61
|
+
message: string;
|
|
62
|
+
suggestion?: string;
|
|
63
|
+
};
|
|
64
|
+
export declare const enrichmentWarning: v.GenericSchema<EnrichmentWarning>;
|
|
65
|
+
/**
|
|
66
|
+
* Render a routing path for warning messages:
|
|
67
|
+
* `['@skmtc/gen-shadcn-form', '/pets', 'post']` →
|
|
68
|
+
* `'@skmtc/gen-shadcn-form → /pets → post'`. The arrow separator keeps
|
|
69
|
+
* segments visually distinct even when they contain dots or slashes.
|
|
70
|
+
*/
|
|
71
|
+
export declare const formatEnrichmentPath: (path: readonly string[]) => string;
|
|
72
|
+
//# sourceMappingURL=EnrichmentWarning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnrichmentWarning.d.ts","sourceRoot":"","sources":["../../src/enrichments/EnrichmentWarning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,qBAAqB,GAC7B,uBAAuB,GACvB,sBAAsB,GACtB,wBAAwB,GACxB,4BAA4B,GAC5B,8BAA8B,CAAA;AAElC,eAAO,MAAM,qBAAqB,EAAE,CAAC,CAAC,aAAa,CAAC,qBAAqB,CAMvE,CAAA;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,SAAS,GAAG,MAAM,CAAA;IACzB,IAAI,EAAE,qBAAqB,CAAA;IAC3B,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,CAAC,CAAC,aAAa,CAAC,iBAAiB,CAM/D,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,MAAM,SAAS,MAAM,EAAE,KAAG,MAA0B,CAAA"}
|