@skmtc/core 0.45.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/anchors/attribute.js +3 -2
- package/esm/context/CoreContext.d.ts +1 -1
- package/esm/context/CoreContext.js +1 -1
- package/esm/context/GenerateContext.d.ts +13 -10
- package/esm/context/GenerateContext.js +36 -25
- package/esm/context/ParseContext.d.ts +3 -0
- package/esm/context/ParseContext.js +151 -39
- package/esm/context/generateTypes.d.ts +7 -6
- package/esm/dsl/GeneratorKeys.d.ts +21 -15
- package/esm/dsl/GeneratorKeys.js +16 -11
- package/esm/dsl/Inserted.d.ts +1 -1
- package/esm/dsl/Inserted.js +1 -1
- package/esm/dsl/model/ModelDriver.d.ts +6 -5
- package/esm/dsl/model/ModelDriver.js +22 -20
- package/esm/dsl/model/toModelEntry.d.ts +18 -18
- package/esm/dsl/model/toModelEntry.js +9 -9
- package/esm/dsl/model/toModelProjectionBase.d.ts +17 -16
- package/esm/dsl/model/toModelProjectionBase.js +12 -8
- package/esm/dsl/model/types.d.ts +26 -17
- package/esm/dsl/operation/gql/toGqlOperationProjectionBase.d.ts +2 -2
- package/esm/dsl/operation/gql/toGqlOperationProjectionBase.js +2 -2
- package/esm/dsl/operation/oas/toOasOperationProjectionBase.d.ts +2 -2
- package/esm/dsl/operation/oas/toOasOperationProjectionBase.js +2 -2
- package/esm/dsl/webhook/toWebhookProjectionBase.d.ts +2 -2
- package/esm/dsl/webhook/toWebhookProjectionBase.js +2 -2
- package/esm/helpers/collateExamples.js +35 -17
- package/esm/helpers/refFns.d.ts +108 -43
- package/esm/helpers/refFns.js +166 -57
- package/esm/mod.d.ts +1 -0
- package/esm/mod.js +1 -0
- package/esm/oas/document/Document.d.ts +6 -0
- package/esm/oas/document/Document.js +44 -2
- package/esm/oas/intersection/Intersection.d.ts +122 -0
- package/esm/oas/intersection/Intersection.js +266 -0
- package/esm/oas/mediaType/jsonMediaType.d.ts +1 -1
- package/esm/oas/mediaType/jsonMediaType.js +3 -3
- package/esm/oas/ref/DanglingRefError.d.ts +5 -2
- package/esm/oas/ref/DanglingRefError.js +4 -3
- package/esm/oas/ref/Ref.d.ts +23 -12
- package/esm/oas/ref/Ref.js +68 -72
- package/esm/oas/requestBody/RequestBody.d.ts +1 -1
- package/esm/oas/requestBody/RequestBody.js +1 -1
- package/esm/oas/response/Response.d.ts +1 -1
- package/esm/oas/response/Response.js +1 -1
- package/esm/oas/schema/Schema.d.ts +4 -2
- package/esm/oas/schema/siblings.d.ts +10 -2
- package/esm/oas/schema/siblings.js +87 -22
- package/esm/oas/schemaPath/traverseSchema.d.ts +2 -0
- package/esm/oas/schemaPath/traverseSchema.js +51 -5
- package/esm/parse/allOfSystem.d.ts +3 -0
- package/esm/parse/allOfSystem.js +2 -1
- package/esm/parse/keptIntersection.d.ts +53 -0
- package/esm/parse/keptIntersection.js +155 -0
- package/esm/parse/keptRefs.d.ts +23 -0
- package/esm/parse/keptRefs.js +59 -0
- package/esm/parse/toCyclicRefs.d.ts +8 -0
- package/esm/parse/toCyclicRefs.js +126 -0
- package/esm/parse/toDeclaredTypes.d.ts +20 -0
- package/esm/parse/toDeclaredTypes.js +43 -0
- package/esm/parse/v3-0/_merge-all-of/merge-intersection.js +8 -4
- package/esm/parse/v3-0/_merge-all-of/merge-union.js +7 -1
- package/esm/parse/v3-0/_merge-all-of/merge.js +13 -0
- package/esm/parse/v3-0/_merge-all-of/types.d.ts +3 -0
- package/esm/parse/v3-0/intersection/toIntersection.d.ts +12 -0
- package/esm/parse/v3-0/intersection/toIntersection.js +61 -0
- package/esm/parse/v3-0/ref/toRefTargetV3.d.ts +23 -0
- package/esm/parse/v3-0/ref/toRefTargetV3.js +70 -0
- package/esm/parse/v3-0/schema/toSchemasV3.js +13 -1
- package/esm/parse/v3-1/_merge-all-of/merge-intersection.js +8 -4
- package/esm/parse/v3-1/_merge-all-of/merge-union.js +7 -1
- package/esm/parse/v3-1/_merge-all-of/merge.js +13 -0
- package/esm/parse/v3-1/_merge-all-of/types.d.ts +3 -0
- package/esm/parse/v3-1/intersection/toIntersection.d.ts +12 -0
- package/esm/parse/v3-1/intersection/toIntersection.js +61 -0
- package/esm/parse/v3-1/ref/toRefTargetV3.d.ts +23 -0
- package/esm/parse/v3-1/ref/toRefTargetV3.js +70 -0
- package/esm/parse/v3-1/schema/toSchemasV3.js +15 -2
- package/esm/parse/v3-2/_merge-all-of/merge-intersection.js +8 -4
- package/esm/parse/v3-2/_merge-all-of/merge-union.js +7 -1
- package/esm/parse/v3-2/_merge-all-of/merge.js +13 -0
- package/esm/parse/v3-2/_merge-all-of/types.d.ts +3 -0
- package/esm/parse/v3-2/intersection/toIntersection.d.ts +12 -0
- package/esm/parse/v3-2/intersection/toIntersection.js +61 -0
- package/esm/parse/v3-2/ref/toRefTargetV3.d.ts +23 -0
- package/esm/parse/v3-2/ref/toRefTargetV3.js +70 -0
- package/esm/parse/v3-2/schema/toSchemasV3.js +15 -2
- package/esm/types/GeneratorType.d.ts +1 -1
- package/esm/types/ProjectionOptions.d.ts +1 -1
- package/esm/types/ProjectionOptions.js +1 -1
- package/esm/types/RefName.d.ts +3 -3
- package/esm/types/Settings.d.ts +9 -0
- package/esm/types/Settings.js +2 -1
- package/esm/types/TypeSystem.d.ts +20 -5
- package/package.json +1 -1
- package/script/anchors/attribute.js +3 -2
- package/script/context/CoreContext.d.ts +1 -1
- package/script/context/CoreContext.js +1 -1
- package/script/context/GenerateContext.d.ts +13 -10
- package/script/context/GenerateContext.js +36 -25
- package/script/context/ParseContext.d.ts +3 -0
- package/script/context/ParseContext.js +150 -38
- package/script/context/generateTypes.d.ts +7 -6
- package/script/dsl/GeneratorKeys.d.ts +21 -15
- package/script/dsl/GeneratorKeys.js +16 -11
- package/script/dsl/Inserted.d.ts +1 -1
- package/script/dsl/Inserted.js +1 -1
- package/script/dsl/model/ModelDriver.d.ts +6 -5
- package/script/dsl/model/ModelDriver.js +22 -20
- package/script/dsl/model/toModelEntry.d.ts +18 -18
- package/script/dsl/model/toModelEntry.js +9 -9
- package/script/dsl/model/toModelProjectionBase.d.ts +17 -16
- package/script/dsl/model/toModelProjectionBase.js +12 -8
- package/script/dsl/model/types.d.ts +26 -17
- package/script/dsl/operation/gql/toGqlOperationProjectionBase.d.ts +2 -2
- package/script/dsl/operation/gql/toGqlOperationProjectionBase.js +2 -2
- package/script/dsl/operation/oas/toOasOperationProjectionBase.d.ts +2 -2
- package/script/dsl/operation/oas/toOasOperationProjectionBase.js +2 -2
- package/script/dsl/webhook/toWebhookProjectionBase.d.ts +2 -2
- package/script/dsl/webhook/toWebhookProjectionBase.js +2 -2
- package/script/helpers/collateExamples.js +35 -17
- package/script/helpers/refFns.d.ts +108 -43
- package/script/helpers/refFns.js +180 -59
- package/script/mod.d.ts +1 -0
- package/script/mod.js +1 -0
- package/script/oas/document/Document.d.ts +6 -0
- package/script/oas/document/Document.js +44 -2
- package/script/oas/intersection/Intersection.d.ts +122 -0
- package/script/oas/intersection/Intersection.js +270 -0
- package/script/oas/mediaType/jsonMediaType.d.ts +1 -1
- package/script/oas/mediaType/jsonMediaType.js +3 -3
- package/script/oas/ref/DanglingRefError.d.ts +5 -2
- package/script/oas/ref/DanglingRefError.js +4 -3
- package/script/oas/ref/Ref.d.ts +23 -12
- package/script/oas/ref/Ref.js +67 -71
- package/script/oas/requestBody/RequestBody.d.ts +1 -1
- package/script/oas/requestBody/RequestBody.js +1 -1
- package/script/oas/response/Response.d.ts +1 -1
- package/script/oas/response/Response.js +1 -1
- package/script/oas/schema/Schema.d.ts +4 -2
- package/script/oas/schema/siblings.d.ts +10 -2
- package/script/oas/schema/siblings.js +89 -23
- package/script/oas/schemaPath/traverseSchema.d.ts +2 -0
- package/script/oas/schemaPath/traverseSchema.js +50 -4
- package/script/parse/allOfSystem.d.ts +3 -0
- package/script/parse/allOfSystem.js +2 -1
- package/script/parse/keptIntersection.d.ts +53 -0
- package/script/parse/keptIntersection.js +164 -0
- package/script/parse/keptRefs.d.ts +23 -0
- package/script/parse/keptRefs.js +63 -0
- package/script/parse/toCyclicRefs.d.ts +8 -0
- package/script/parse/toCyclicRefs.js +130 -0
- package/script/parse/toDeclaredTypes.d.ts +20 -0
- package/script/parse/toDeclaredTypes.js +48 -0
- package/script/parse/v3-0/_merge-all-of/merge-intersection.js +8 -4
- package/script/parse/v3-0/_merge-all-of/merge-union.js +7 -1
- package/script/parse/v3-0/_merge-all-of/merge.js +13 -0
- package/script/parse/v3-0/_merge-all-of/types.d.ts +3 -0
- package/script/parse/v3-0/intersection/toIntersection.d.ts +12 -0
- package/script/parse/v3-0/intersection/toIntersection.js +65 -0
- package/script/parse/v3-0/ref/toRefTargetV3.d.ts +23 -0
- package/script/parse/v3-0/ref/toRefTargetV3.js +74 -0
- package/script/parse/v3-0/schema/toSchemasV3.js +13 -1
- package/script/parse/v3-1/_merge-all-of/merge-intersection.js +8 -4
- package/script/parse/v3-1/_merge-all-of/merge-union.js +7 -1
- package/script/parse/v3-1/_merge-all-of/merge.js +13 -0
- package/script/parse/v3-1/_merge-all-of/types.d.ts +3 -0
- package/script/parse/v3-1/intersection/toIntersection.d.ts +12 -0
- package/script/parse/v3-1/intersection/toIntersection.js +65 -0
- package/script/parse/v3-1/ref/toRefTargetV3.d.ts +23 -0
- package/script/parse/v3-1/ref/toRefTargetV3.js +74 -0
- package/script/parse/v3-1/schema/toSchemasV3.js +15 -2
- package/script/parse/v3-2/_merge-all-of/merge-intersection.js +8 -4
- package/script/parse/v3-2/_merge-all-of/merge-union.js +7 -1
- package/script/parse/v3-2/_merge-all-of/merge.js +13 -0
- package/script/parse/v3-2/_merge-all-of/types.d.ts +3 -0
- package/script/parse/v3-2/intersection/toIntersection.d.ts +12 -0
- package/script/parse/v3-2/intersection/toIntersection.js +65 -0
- package/script/parse/v3-2/ref/toRefTargetV3.d.ts +23 -0
- package/script/parse/v3-2/ref/toRefTargetV3.js +74 -0
- package/script/parse/v3-2/schema/toSchemasV3.js +15 -2
- package/script/types/GeneratorType.d.ts +1 -1
- package/script/types/ProjectionOptions.d.ts +1 -1
- package/script/types/ProjectionOptions.js +1 -1
- package/script/types/RefName.d.ts +3 -3
- package/script/types/Settings.d.ts +9 -0
- package/script/types/Settings.js +2 -1
- package/script/types/TypeSystem.d.ts +20 -5
|
@@ -3,7 +3,7 @@ import type { GenerateContextType, InsertModelOptions } from '../../context/gene
|
|
|
3
3
|
import type { ContentSettings } from '../ContentSettings.js';
|
|
4
4
|
import type { GeneratedDefinition } from '../GeneratedValue.js';
|
|
5
5
|
import type { GeneratedValue } from '../GeneratedValue.js';
|
|
6
|
-
import type
|
|
6
|
+
import { type RefParts } from '../../helpers/refFns.js';
|
|
7
7
|
/**
|
|
8
8
|
* The `insertModel` call plus the context. The Driver defaults `variant`
|
|
9
9
|
* to `'main'` and `noExport` to `false`, and reads the caller's options
|
|
@@ -12,8 +12,9 @@ import type { RefName } from '../../types/RefName.js';
|
|
|
12
12
|
type CreateModelArgs<V extends GeneratedValue, EnrichmentType, ProjectionOptions> = {
|
|
13
13
|
context: GenerateContextType;
|
|
14
14
|
projection: ModelProjection<V, EnrichmentType, ProjectionOptions>;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
/** The model's ref; an `OasRef` fits it. */
|
|
16
|
+
ref: RefParts;
|
|
17
|
+
rootRef?: RefParts;
|
|
17
18
|
} & InsertModelOptions<ProjectionOptions>;
|
|
18
19
|
/**
|
|
19
20
|
* Driver for the model insertion lifecycle.
|
|
@@ -27,11 +28,11 @@ type CreateModelArgs<V extends GeneratedValue, EnrichmentType, ProjectionOptions
|
|
|
27
28
|
export declare class ModelDriver<V extends GeneratedValue, EnrichmentType, ProjectionOptions = undefined> {
|
|
28
29
|
context: GenerateContextType;
|
|
29
30
|
projection: ModelProjection<V, EnrichmentType, ProjectionOptions>;
|
|
30
|
-
|
|
31
|
+
ref: RefParts;
|
|
31
32
|
settings: ContentSettings<EnrichmentType>;
|
|
32
33
|
destinationPath?: string;
|
|
33
34
|
definition: GeneratedDefinition<V>;
|
|
34
|
-
rootRef?:
|
|
35
|
+
rootRef?: RefParts;
|
|
35
36
|
noExport: boolean;
|
|
36
37
|
variant: string;
|
|
37
38
|
/** The caller's options, as passed to `insertModel`. */
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.toModelRef = exports.isReferencedBack = exports.ModelDriver = void 0;
|
|
7
7
|
const normalizeWorkspacePath_js_1 = require("../../helpers/normalizeWorkspacePath.js");
|
|
8
8
|
const GeneratorKeys_js_1 = require("../GeneratorKeys.js");
|
|
9
|
+
const refFns_js_1 = require("../../helpers/refFns.js");
|
|
9
10
|
const Variant_js_1 = require("../../types/Variant.js");
|
|
10
11
|
const ProjectionOptions_js_1 = require("../../types/ProjectionOptions.js");
|
|
11
12
|
const isEqual_js_1 = __importDefault(require("lodash-es/isEqual.js"));
|
|
@@ -38,7 +39,7 @@ class ModelDriver {
|
|
|
38
39
|
writable: true,
|
|
39
40
|
value: void 0
|
|
40
41
|
});
|
|
41
|
-
Object.defineProperty(this, "
|
|
42
|
+
Object.defineProperty(this, "ref", {
|
|
42
43
|
enumerable: true,
|
|
43
44
|
configurable: true,
|
|
44
45
|
writable: true,
|
|
@@ -87,10 +88,10 @@ class ModelDriver {
|
|
|
87
88
|
writable: true,
|
|
88
89
|
value: void 0
|
|
89
90
|
});
|
|
90
|
-
const { context, projection,
|
|
91
|
+
const { context, projection, ref, destinationPath, rootRef, noExport = false, variant = Variant_js_1.DEFAULT_VARIANT } = args;
|
|
91
92
|
this.context = context;
|
|
92
93
|
this.projection = projection;
|
|
93
|
-
this.
|
|
94
|
+
this.ref = ref;
|
|
94
95
|
this.destinationPath = destinationPath;
|
|
95
96
|
this.rootRef = rootRef;
|
|
96
97
|
this.noExport = noExport;
|
|
@@ -131,7 +132,7 @@ class ModelDriver {
|
|
|
131
132
|
getDefinition({ identifier, exportPath }) {
|
|
132
133
|
const generatorKey = (0, GeneratorKeys_js_1.toModelGeneratorKey)({
|
|
133
134
|
generatorId: this.projection.id,
|
|
134
|
-
|
|
135
|
+
ref: this.ref,
|
|
135
136
|
variant: this.settings.variant
|
|
136
137
|
});
|
|
137
138
|
const pending = findPending({ context: this.context, name: identifier.name, exportPath });
|
|
@@ -164,7 +165,7 @@ class ModelDriver {
|
|
|
164
165
|
projection: this.projection
|
|
165
166
|
});
|
|
166
167
|
const value = whilePending({ context: this.context, marker }, () => new this.projection({
|
|
167
|
-
|
|
168
|
+
ref: this.ref,
|
|
168
169
|
context: this.context,
|
|
169
170
|
settings: this.settings,
|
|
170
171
|
destinationPath: this.settings.exportPath,
|
|
@@ -198,7 +199,7 @@ class ModelDriver {
|
|
|
198
199
|
}
|
|
199
200
|
const currentKey = (0, GeneratorKeys_js_1.toModelGeneratorKey)({
|
|
200
201
|
generatorId: this.projection.id,
|
|
201
|
-
|
|
202
|
+
ref: this.ref,
|
|
202
203
|
variant: this.settings.variant
|
|
203
204
|
});
|
|
204
205
|
assertSameKey({
|
|
@@ -306,11 +307,11 @@ const isReferencedBack = ({ context, settings }) => {
|
|
|
306
307
|
exports.isReferencedBack = isReferencedBack;
|
|
307
308
|
/** A model's content settings, once the peer is known to have the variant and to support the model. */
|
|
308
309
|
const toModelSettings = (args) => {
|
|
309
|
-
const { context, projection,
|
|
310
|
-
assertPeerVariantExists({ context, generatorId: projection.id,
|
|
311
|
-
assertPeerSupported({ context, projection,
|
|
310
|
+
const { context, projection, ref, variant = Variant_js_1.DEFAULT_VARIANT } = args;
|
|
311
|
+
assertPeerVariantExists({ context, generatorId: projection.id, ref, variant });
|
|
312
|
+
assertPeerSupported({ context, projection, ref, variant });
|
|
312
313
|
return context.toModelContentSettings({
|
|
313
|
-
|
|
314
|
+
ref,
|
|
314
315
|
projection,
|
|
315
316
|
variant,
|
|
316
317
|
options: (0, ProjectionOptions_js_1.readProjectionOptions)(args)
|
|
@@ -327,7 +328,7 @@ const toModelSettings = (args) => {
|
|
|
327
328
|
* {@link ModelDriver}.
|
|
328
329
|
*/
|
|
329
330
|
const toModelRef = (args) => {
|
|
330
|
-
const { context, projection,
|
|
331
|
+
const { context, projection, ref, destinationPath, variant = Variant_js_1.DEFAULT_VARIANT } = args;
|
|
331
332
|
const settings = toModelSettings(args);
|
|
332
333
|
const pending = findPending({
|
|
333
334
|
context,
|
|
@@ -339,7 +340,7 @@ const toModelRef = (args) => {
|
|
|
339
340
|
pending,
|
|
340
341
|
name: settings.identifier.name,
|
|
341
342
|
exportPath: settings.exportPath,
|
|
342
|
-
generatorKey: (0, GeneratorKeys_js_1.toModelGeneratorKey)({ generatorId: projection.id,
|
|
343
|
+
generatorKey: (0, GeneratorKeys_js_1.toModelGeneratorKey)({ generatorId: projection.id, ref, variant }),
|
|
343
344
|
options: (0, ProjectionOptions_js_1.readProjectionOptions)(args),
|
|
344
345
|
projection
|
|
345
346
|
});
|
|
@@ -384,22 +385,23 @@ exports.toModelRef = toModelRef;
|
|
|
384
385
|
* key. The Driver throws here — loud at the call site — rather than
|
|
385
386
|
* letting silently-wrong output reach the consumer.
|
|
386
387
|
*/
|
|
387
|
-
const assertPeerVariantExists = ({ context, generatorId,
|
|
388
|
+
const assertPeerVariantExists = ({ context, generatorId, ref, variant }) => {
|
|
388
389
|
if (variant === Variant_js_1.DEFAULT_VARIANT) {
|
|
389
390
|
return;
|
|
390
391
|
}
|
|
391
|
-
const
|
|
392
|
+
const key = (0, refFns_js_1.toModelKey)(ref);
|
|
393
|
+
const modelEnrichments = context.readEnrichment([generatorId, key]);
|
|
392
394
|
if (modelEnrichments === null || modelEnrichments === undefined) {
|
|
393
|
-
throw new Error(`[${generatorId}] Cannot insert variant '${variant}' for '${
|
|
395
|
+
throw new Error(`[${generatorId}] Cannot insert variant '${variant}' for '${key}' — ` +
|
|
394
396
|
`peer has no enrichments configured. Only '${Variant_js_1.DEFAULT_VARIANT}' is permitted.`);
|
|
395
397
|
}
|
|
396
398
|
if (typeof modelEnrichments !== 'object' || Array.isArray(modelEnrichments)) {
|
|
397
|
-
throw new Error(`[${generatorId}] Cannot insert variant '${variant}' for '${
|
|
399
|
+
throw new Error(`[${generatorId}] Cannot insert variant '${variant}' for '${key}' — ` +
|
|
398
400
|
`peer enrichment is not a variant record.`);
|
|
399
401
|
}
|
|
400
402
|
if (!(variant in modelEnrichments)) {
|
|
401
403
|
const available = Object.keys(modelEnrichments).join(', ');
|
|
402
|
-
throw new Error(`[${generatorId}] Cannot insert variant '${variant}' for '${
|
|
404
|
+
throw new Error(`[${generatorId}] Cannot insert variant '${variant}' for '${key}'. ` +
|
|
403
405
|
`Available variants: ${available}.`);
|
|
404
406
|
}
|
|
405
407
|
};
|
|
@@ -422,10 +424,10 @@ const assertPeerVariantExists = ({ context, generatorId, refName, variant }) =>
|
|
|
422
424
|
* model: `toModelProjectionBase` defaults it to `() => true`, and a
|
|
423
425
|
* hand-rolled projection may omit it.
|
|
424
426
|
*/
|
|
425
|
-
const assertPeerSupported = ({ context, projection,
|
|
427
|
+
const assertPeerSupported = ({ context, projection, ref, variant }) => {
|
|
426
428
|
const isSupported = projection.isSupported ?? (() => true);
|
|
427
|
-
if (!isSupported({
|
|
428
|
-
throw new Error(`[${projection.id}] Cannot insert '${
|
|
429
|
+
if (!isSupported({ ref, context, variant })) {
|
|
430
|
+
throw new Error(`[${projection.id}] Cannot insert '${(0, refFns_js_1.toModelKey)(ref)}' — peer generator ` +
|
|
429
431
|
`does not support this model (isSupported returned false).`);
|
|
430
432
|
}
|
|
431
433
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RefParts } from '../../helpers/refFns.js';
|
|
2
2
|
import type { EnrichmentRequest } from '../../types/EnrichmentRequest.js';
|
|
3
3
|
import type { TransformModelArgs, ToModelPreviewModuleArgs, ToModelEnrichmentsArgs, IsSupportedModelArgs } from './types.js';
|
|
4
4
|
import type { PreviewModule } from '../../types/Preview.js';
|
|
5
5
|
import type * as v from 'valibot';
|
|
6
6
|
type ToModelEntryArgs<EnrichmentType = undefined> = {
|
|
7
7
|
id: string;
|
|
8
|
-
transform: ({ context,
|
|
8
|
+
transform: ({ context, ref, variant }: TransformModelArgs) => void;
|
|
9
9
|
toEnrichmentSchema: () => v.GenericSchema<EnrichmentType>;
|
|
10
10
|
isSupported?: (args: IsSupportedModelArgs) => boolean;
|
|
11
11
|
/**
|
|
@@ -13,20 +13,20 @@ type ToModelEntryArgs<EnrichmentType = undefined> = {
|
|
|
13
13
|
* function returning `false` when omitted.
|
|
14
14
|
*/
|
|
15
15
|
supportsVariant?: () => boolean;
|
|
16
|
-
toPreviewModule?: ({ context,
|
|
17
|
-
toEnrichmentRequest?: <RequestedEnrichment extends EnrichmentType>(
|
|
18
|
-
toEnrichmentDefaults?: ({
|
|
16
|
+
toPreviewModule?: ({ context, ref, variant }: ToModelPreviewModuleArgs) => PreviewModule;
|
|
17
|
+
toEnrichmentRequest?: <RequestedEnrichment extends EnrichmentType>(ref: RefParts) => EnrichmentRequest<RequestedEnrichment> | undefined;
|
|
18
|
+
toEnrichmentDefaults?: ({ ref, context, variant }: ToModelEnrichmentsArgs) => EnrichmentType | undefined;
|
|
19
19
|
};
|
|
20
20
|
export type ModelEntry<EnrichmentType = undefined> = {
|
|
21
21
|
id: string;
|
|
22
22
|
type: 'model';
|
|
23
|
-
transform: ({ context,
|
|
23
|
+
transform: ({ context, ref, variant }: TransformModelArgs) => void;
|
|
24
24
|
isSupported: (args: IsSupportedModelArgs) => boolean;
|
|
25
25
|
supportsVariant: () => boolean;
|
|
26
|
-
toPreviewModule?: ({ context,
|
|
26
|
+
toPreviewModule?: ({ context, ref, variant }: ToModelPreviewModuleArgs) => PreviewModule;
|
|
27
27
|
toEnrichmentSchema: () => v.GenericSchema<EnrichmentType>;
|
|
28
|
-
toEnrichmentRequest?: <RequestedEnrichment extends EnrichmentType>(
|
|
29
|
-
toEnrichmentDefaults?: ({
|
|
28
|
+
toEnrichmentRequest?: <RequestedEnrichment extends EnrichmentType>(ref: RefParts) => EnrichmentRequest<RequestedEnrichment> | undefined;
|
|
29
|
+
toEnrichmentDefaults?: ({ ref, context, variant }: ToModelEnrichmentsArgs) => EnrichmentType | undefined;
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
32
|
* Creates a model transformation entry for the SKMTC pipeline.
|
|
@@ -45,7 +45,7 @@ export type ModelEntry<EnrichmentType = undefined> = {
|
|
|
45
45
|
* @param args.isSupported - Optional capability gate; a model whose predicate
|
|
46
46
|
* returns `false` is recorded `notSupported` and its `transform` is skipped.
|
|
47
47
|
* Resolve the schema inside the predicate when needed
|
|
48
|
-
* (`context.resolveSchemaRefOnce(
|
|
48
|
+
* (`context.resolveSchemaRefOnce(ref)`). Defaults to supporting every model.
|
|
49
49
|
* @param args.toPreviewModule - Optional function to generate preview modules
|
|
50
50
|
* @param args.toEnrichmentSchema - Optional function to provide enrichment validation
|
|
51
51
|
* @param args.toEnrichmentRequest - Optional function to request enrichments
|
|
@@ -57,12 +57,12 @@ export type ModelEntry<EnrichmentType = undefined> = {
|
|
|
57
57
|
*
|
|
58
58
|
* const typeScriptModelEntry = toModelEntry({
|
|
59
59
|
* id: 'typescript-models',
|
|
60
|
-
* transform: ({ context,
|
|
61
|
-
* context.insertModel(TsModel,
|
|
60
|
+
* transform: ({ context, ref }) => {
|
|
61
|
+
* context.insertModel(TsModel, ref);
|
|
62
62
|
* },
|
|
63
|
-
* toPreviewModule: ({ context,
|
|
63
|
+
* toPreviewModule: ({ context, ref }) => ({
|
|
64
64
|
* group: 'forms',
|
|
65
|
-
* title: `${refName} Model`,
|
|
65
|
+
* title: `${ref.refName} Model`,
|
|
66
66
|
* description: 'Generated TypeScript interface'
|
|
67
67
|
* })
|
|
68
68
|
* });
|
|
@@ -72,15 +72,15 @@ export type ModelEntry<EnrichmentType = undefined> = {
|
|
|
72
72
|
* ```typescript
|
|
73
73
|
* const validationModelEntry = toModelEntry({
|
|
74
74
|
* id: 'validation-schemas',
|
|
75
|
-
* transform: ({ context,
|
|
76
|
-
* context.insertModel(ValidationModel,
|
|
75
|
+
* transform: ({ context, ref }) => {
|
|
76
|
+
* context.insertModel(ValidationModel, ref);
|
|
77
77
|
* },
|
|
78
78
|
* toEnrichmentSchema: () => v.object({
|
|
79
79
|
* strict: v.optional(v.boolean()),
|
|
80
80
|
* nullable: v.optional(v.boolean())
|
|
81
81
|
* }),
|
|
82
|
-
* toEnrichmentRequest: (
|
|
83
|
-
* path: `models.${refName}`,
|
|
82
|
+
* toEnrichmentRequest: (ref) => ({
|
|
83
|
+
* path: `models.${ref.refName}`,
|
|
84
84
|
* schema: enrichmentSchema
|
|
85
85
|
* })
|
|
86
86
|
* });
|
|
@@ -18,7 +18,7 @@ exports.toModelEntry = void 0;
|
|
|
18
18
|
* @param args.isSupported - Optional capability gate; a model whose predicate
|
|
19
19
|
* returns `false` is recorded `notSupported` and its `transform` is skipped.
|
|
20
20
|
* Resolve the schema inside the predicate when needed
|
|
21
|
-
* (`context.resolveSchemaRefOnce(
|
|
21
|
+
* (`context.resolveSchemaRefOnce(ref)`). Defaults to supporting every model.
|
|
22
22
|
* @param args.toPreviewModule - Optional function to generate preview modules
|
|
23
23
|
* @param args.toEnrichmentSchema - Optional function to provide enrichment validation
|
|
24
24
|
* @param args.toEnrichmentRequest - Optional function to request enrichments
|
|
@@ -30,12 +30,12 @@ exports.toModelEntry = void 0;
|
|
|
30
30
|
*
|
|
31
31
|
* const typeScriptModelEntry = toModelEntry({
|
|
32
32
|
* id: 'typescript-models',
|
|
33
|
-
* transform: ({ context,
|
|
34
|
-
* context.insertModel(TsModel,
|
|
33
|
+
* transform: ({ context, ref }) => {
|
|
34
|
+
* context.insertModel(TsModel, ref);
|
|
35
35
|
* },
|
|
36
|
-
* toPreviewModule: ({ context,
|
|
36
|
+
* toPreviewModule: ({ context, ref }) => ({
|
|
37
37
|
* group: 'forms',
|
|
38
|
-
* title: `${refName} Model`,
|
|
38
|
+
* title: `${ref.refName} Model`,
|
|
39
39
|
* description: 'Generated TypeScript interface'
|
|
40
40
|
* })
|
|
41
41
|
* });
|
|
@@ -45,15 +45,15 @@ exports.toModelEntry = void 0;
|
|
|
45
45
|
* ```typescript
|
|
46
46
|
* const validationModelEntry = toModelEntry({
|
|
47
47
|
* id: 'validation-schemas',
|
|
48
|
-
* transform: ({ context,
|
|
49
|
-
* context.insertModel(ValidationModel,
|
|
48
|
+
* transform: ({ context, ref }) => {
|
|
49
|
+
* context.insertModel(ValidationModel, ref);
|
|
50
50
|
* },
|
|
51
51
|
* toEnrichmentSchema: () => v.object({
|
|
52
52
|
* strict: v.optional(v.boolean()),
|
|
53
53
|
* nullable: v.optional(v.boolean())
|
|
54
54
|
* }),
|
|
55
|
-
* toEnrichmentRequest: (
|
|
56
|
-
* path: `models.${refName}`,
|
|
55
|
+
* toEnrichmentRequest: (ref) => ({
|
|
56
|
+
* path: `models.${ref.refName}`,
|
|
57
57
|
* schema: enrichmentSchema
|
|
58
58
|
* })
|
|
59
59
|
* });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GenerateContextType, InsertNormalizedModelArgs, InsertNormalizedModelOptions, InsertNormalizedModelReturn } from '../../context/generateTypes.js';
|
|
2
2
|
import { type ProjectionOptionsArg, type ProjectionOptionsRest } from '../../types/ProjectionOptions.js';
|
|
3
3
|
import { type PeerInsertOptions } from '../../types/InsertOptions.js';
|
|
4
|
-
import type
|
|
4
|
+
import { type RefParts } from '../../helpers/refFns.js';
|
|
5
5
|
import type { ContentSettings } from '../ContentSettings.js';
|
|
6
6
|
import type { LangSnippetConstructor } from '../Lang.js';
|
|
7
7
|
import type { IdentifierType } from '../IdentifierType.js';
|
|
@@ -21,10 +21,11 @@ import type * as v from 'valibot';
|
|
|
21
21
|
export type ModelProjectionArgs<EnrichmentType = undefined, ProjectionOptions = undefined> = {
|
|
22
22
|
context: GenerateContextType;
|
|
23
23
|
settings: ContentSettings<EnrichmentType>;
|
|
24
|
-
|
|
24
|
+
/** The model's ref (see {@link RefParts}); an `OasRef` fits it. */
|
|
25
|
+
ref: RefParts;
|
|
25
26
|
} & ProjectionOptionsArg<ProjectionOptions>;
|
|
26
27
|
type ToEnrichmentsArgs = {
|
|
27
|
-
|
|
28
|
+
ref: RefParts;
|
|
28
29
|
context: GenerateContextType;
|
|
29
30
|
/** Model variant whose enrichment should be resolved (see {@link Variant}) */
|
|
30
31
|
variant: string;
|
|
@@ -52,7 +53,7 @@ export type ModelProjectionBaseConfig<EnrichmentType = undefined, IdType extends
|
|
|
52
53
|
* `type` is bound to that language's `EntityType` vocabulary (the loose
|
|
53
54
|
* `string` by default). The tightening rides the type argument.
|
|
54
55
|
*/
|
|
55
|
-
toIdentifierType: (
|
|
56
|
+
toIdentifierType: (ref: RefParts, context: GenerateContextType) => IdType;
|
|
56
57
|
toExportPath: (args: ToModelExportPathArgs<EnrichmentType, ProjectionOptions>) => string;
|
|
57
58
|
/**
|
|
58
59
|
* Required composite schema for the `{ subject, generator, stack }`
|
|
@@ -76,10 +77,12 @@ export type ModelProjectionBaseConfig<EnrichmentType = undefined, IdType extends
|
|
|
76
77
|
* `insertModel` (the model counterpart of the operation-reference
|
|
77
78
|
* protocol). When omitted, advertises support for every model.
|
|
78
79
|
*/
|
|
79
|
-
isSupported?: (args:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
isSupported?: (args: IsSupportedArgs) => boolean;
|
|
81
|
+
};
|
|
82
|
+
/** What a model projection's `isSupported` receives. */
|
|
83
|
+
type IsSupportedArgs = {
|
|
84
|
+
ref: RefParts;
|
|
85
|
+
context: GenerateContextType;
|
|
83
86
|
};
|
|
84
87
|
/**
|
|
85
88
|
* Build a model projection base class from a per-generator config.
|
|
@@ -103,7 +106,8 @@ export type ModelProjectionBaseConfig<EnrichmentType = undefined, IdType extends
|
|
|
103
106
|
export declare const toModelProjectionBase: <EnrichmentType = undefined, IdType extends IdentifierType = IdentifierType, ProjectionOptions = undefined>(base: LangSnippetConstructor, config: ModelProjectionBaseConfig<EnrichmentType, IdType, ProjectionOptions>) => {
|
|
104
107
|
new (args: ModelProjectionArgs<EnrichmentType, ProjectionOptions>): {
|
|
105
108
|
settings: ContentSettings<EnrichmentType>;
|
|
106
|
-
|
|
109
|
+
/** The ref this model is built for (see {@link RefParts}). */
|
|
110
|
+
ref: RefParts;
|
|
107
111
|
/** The caller's options. */
|
|
108
112
|
options: ProjectionOptions;
|
|
109
113
|
/**
|
|
@@ -112,7 +116,7 @@ export declare const toModelProjectionBase: <EnrichmentType = undefined, IdType
|
|
|
112
116
|
* unless `noExport` is set. `{ options }` is required when the peer
|
|
113
117
|
* declares options and refused when it does not.
|
|
114
118
|
*/
|
|
115
|
-
insertModel<V extends GeneratedValue, PeerEnrichmentType = undefined, PeerProjectionOptions = undefined>(projection: ModelProjection<V, PeerEnrichmentType, PeerProjectionOptions>,
|
|
119
|
+
insertModel<V extends GeneratedValue, PeerEnrichmentType = undefined, PeerProjectionOptions = undefined>(projection: ModelProjection<V, PeerEnrichmentType, PeerProjectionOptions>, ref: RefParts, ...rest: ProjectionOptionsRest<PeerInsertOptions<PeerProjectionOptions>, PeerProjectionOptions>): Inserted<V, PeerEnrichmentType>;
|
|
116
120
|
/**
|
|
117
121
|
* Insert a related model with reference normalization. If `schema` is a
|
|
118
122
|
* `$ref`, the referenced name is used; otherwise `fallbackName` applies.
|
|
@@ -126,19 +130,16 @@ export declare const toModelProjectionBase: <EnrichmentType = undefined, IdType
|
|
|
126
130
|
id: string;
|
|
127
131
|
type: "model";
|
|
128
132
|
toIdentifierName: (args: ToModelIdentifierNameArgs<EnrichmentType, ProjectionOptions>) => string;
|
|
129
|
-
toIdentifierType: (
|
|
133
|
+
toIdentifierType: (ref: RefParts, context: GenerateContextType) => IdType;
|
|
130
134
|
toExportPath: (args: ToModelExportPathArgs<EnrichmentType, ProjectionOptions>) => string;
|
|
131
|
-
toEnrichments: ({
|
|
135
|
+
toEnrichments: ({ ref, context, variant }: ToEnrichmentsArgs) => EnrichmentType;
|
|
132
136
|
/**
|
|
133
137
|
* Derive the seed enrichment values for a model from its schema (the CMS
|
|
134
138
|
* persists these, then the user edits). Returns `undefined` when the
|
|
135
139
|
* generator declares no `toEnrichmentDefaults` — the common case.
|
|
136
140
|
*/
|
|
137
141
|
toEnrichmentDefaults: (args: ToEnrichmentsArgs) => EnrichmentType | undefined;
|
|
138
|
-
isSupported: (args:
|
|
139
|
-
refName: RefName;
|
|
140
|
-
context: GenerateContextType;
|
|
141
|
-
}) => boolean;
|
|
142
|
+
isSupported: (args: IsSupportedArgs) => boolean;
|
|
142
143
|
lang: import("../Lang.js").Lang;
|
|
143
144
|
};
|
|
144
145
|
export {};
|
|
@@ -4,6 +4,7 @@ exports.toModelProjectionBase = void 0;
|
|
|
4
4
|
const ProjectionOptions_js_1 = require("../../types/ProjectionOptions.js");
|
|
5
5
|
const InsertOptions_js_1 = require("../../types/InsertOptions.js");
|
|
6
6
|
const GeneratorKeys_js_1 = require("../GeneratorKeys.js");
|
|
7
|
+
const refFns_js_1 = require("../../helpers/refFns.js");
|
|
7
8
|
const Variant_js_1 = require("../../types/Variant.js");
|
|
8
9
|
const parseEnrichmentUmbrella_js_1 = require("../../enrichments/parseEnrichmentUmbrella.js");
|
|
9
10
|
/**
|
|
@@ -33,7 +34,7 @@ const toModelProjectionBase = (base, config) => {
|
|
|
33
34
|
context: args.context,
|
|
34
35
|
generatorKey: (0, GeneratorKeys_js_1.toModelGeneratorKey)({
|
|
35
36
|
generatorId: config.id,
|
|
36
|
-
|
|
37
|
+
ref: args.ref,
|
|
37
38
|
variant: args.settings.variant ?? Variant_js_1.DEFAULT_VARIANT
|
|
38
39
|
})
|
|
39
40
|
});
|
|
@@ -43,7 +44,8 @@ const toModelProjectionBase = (base, config) => {
|
|
|
43
44
|
writable: true,
|
|
44
45
|
value: void 0
|
|
45
46
|
});
|
|
46
|
-
|
|
47
|
+
/** The ref this model is built for (see {@link RefParts}). */
|
|
48
|
+
Object.defineProperty(this, "ref", {
|
|
47
49
|
enumerable: true,
|
|
48
50
|
configurable: true,
|
|
49
51
|
writable: true,
|
|
@@ -56,7 +58,7 @@ const toModelProjectionBase = (base, config) => {
|
|
|
56
58
|
writable: true,
|
|
57
59
|
value: void 0
|
|
58
60
|
});
|
|
59
|
-
this.
|
|
61
|
+
this.ref = args.ref;
|
|
60
62
|
this.settings = args.settings;
|
|
61
63
|
this.options = (0, ProjectionOptions_js_1.readProjectionOptions)(args);
|
|
62
64
|
}
|
|
@@ -66,8 +68,8 @@ const toModelProjectionBase = (base, config) => {
|
|
|
66
68
|
* unless `noExport` is set. `{ options }` is required when the peer
|
|
67
69
|
* declares options and refused when it does not.
|
|
68
70
|
*/
|
|
69
|
-
insertModel(projection,
|
|
70
|
-
return this.context.insertModel(projection,
|
|
71
|
+
insertModel(projection, ref, ...rest) {
|
|
72
|
+
return this.context.insertModel(projection, ref, {
|
|
71
73
|
...(0, InsertOptions_js_1.toPeerInsertOptions)(rest),
|
|
72
74
|
destinationPath: this.settings.exportPath
|
|
73
75
|
});
|
|
@@ -118,10 +120,12 @@ const toModelProjectionBase = (base, config) => {
|
|
|
118
120
|
enumerable: true,
|
|
119
121
|
configurable: true,
|
|
120
122
|
writable: true,
|
|
121
|
-
value: ({
|
|
123
|
+
value: ({ ref, context, variant }) => {
|
|
122
124
|
// The three enrichment scopes assembled into the umbrella a generator
|
|
123
125
|
// reads off `this.settings.enrichments`. Subject is per-item
|
|
124
|
-
// (`[id][refName][variant]
|
|
126
|
+
// (`[id][refName][variant]`, or the whole pointer in place of
|
|
127
|
+
// `refName` for a ref that does not point at a component, `toModelKey`)
|
|
128
|
+
// — the variant axis is core-owned, and the
|
|
125
129
|
// engine has already asserted `'main'` exists; generator and stack are
|
|
126
130
|
// run-constants (`[id][_generator]`, `[_stack]`). The required composite
|
|
127
131
|
// schema parses the raw umbrella once — typed, cast-free.
|
|
@@ -130,7 +134,7 @@ const toModelProjectionBase = (base, config) => {
|
|
|
130
134
|
return (0, parseEnrichmentUmbrella_js_1.parseEnrichmentUmbrella)({
|
|
131
135
|
context,
|
|
132
136
|
generatorId: config.id,
|
|
133
|
-
subjectSegments: [
|
|
137
|
+
subjectSegments: [(0, refFns_js_1.toModelKey)(ref), variant],
|
|
134
138
|
schema: config.toEnrichmentSchema()
|
|
135
139
|
});
|
|
136
140
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GenerateContextType } from '../../context/generateTypes.js';
|
|
2
2
|
import type { Lang } from '../Lang.js';
|
|
3
3
|
import type { ContentSettings } from '../ContentSettings.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { RefParts } from '../../helpers/refFns.js';
|
|
5
5
|
import type { IdentifierType } from '../IdentifierType.js';
|
|
6
6
|
import type { IdentifierBase } from '../IdentifierBase.js';
|
|
7
7
|
import type { GeneratedValue } from '../GeneratedValue.js';
|
|
@@ -16,27 +16,31 @@ import type { ProjectionOptionsArg } from '../../types/ProjectionOptions.js';
|
|
|
16
16
|
*/
|
|
17
17
|
export type ModelProjectionConstructorArgs<EnrichmentType = undefined, ProjectionOptions = undefined> = {
|
|
18
18
|
context: GenerateContextType;
|
|
19
|
-
|
|
19
|
+
/** The model's ref (see {@link RefParts}); an `OasRef` fits it. */
|
|
20
|
+
ref: RefParts;
|
|
20
21
|
settings: ContentSettings<EnrichmentType>;
|
|
21
22
|
destinationPath: string;
|
|
22
|
-
rootRef?:
|
|
23
|
+
rootRef?: RefParts;
|
|
23
24
|
} & ProjectionOptionsArg<ProjectionOptions>;
|
|
24
25
|
export type WithTransformModel = {
|
|
25
|
-
transformModel: (
|
|
26
|
+
transformModel: (ref: RefParts) => void;
|
|
26
27
|
};
|
|
27
28
|
export type ToModelEnrichmentsArgs = {
|
|
28
|
-
|
|
29
|
+
/** The model's ref (see {@link RefParts}); an `OasRef` fits it. */
|
|
30
|
+
ref: RefParts;
|
|
29
31
|
context: GenerateContextType;
|
|
30
32
|
/** Model variant whose enrichment should be resolved (see {@link Variant}) */
|
|
31
33
|
variant: string;
|
|
32
34
|
};
|
|
33
35
|
export type TransformModelArgs = {
|
|
34
36
|
context: GenerateContextType;
|
|
35
|
-
|
|
37
|
+
/** The model's ref (see {@link RefParts}); an `OasRef` fits it. */
|
|
38
|
+
ref: RefParts;
|
|
36
39
|
/**
|
|
37
40
|
* The model variant the engine is dispatching for this call. The
|
|
38
41
|
* engine fans out one `transform` call per variant declared in the
|
|
39
|
-
* consumer's `enrichments[id][refName]` block (
|
|
42
|
+
* consumer's `enrichments[id][refName]` block (the whole pointer for a
|
|
43
|
+
* model that is not a component) (or just `'main'`
|
|
40
44
|
* when no enrichments are configured). See {@link Variant}.
|
|
41
45
|
*/
|
|
42
46
|
variant: string;
|
|
@@ -46,24 +50,27 @@ export type TransformModelArgs = {
|
|
|
46
50
|
* entry/dispatch boundary. The capability counterpart of
|
|
47
51
|
* {@link TransformModelArgs}: it carries the resolved enrichment umbrella so
|
|
48
52
|
* the predicate can gate on user config, but no schema — the predicate
|
|
49
|
-
* resolves the schema itself (`context.resolveSchemaRefOnce(
|
|
53
|
+
* resolves the schema itself (`context.resolveSchemaRefOnce(ref)`)
|
|
50
54
|
* when it needs it, mirroring how `transform` works.
|
|
51
55
|
*/
|
|
52
56
|
export type IsSupportedModelArgs = {
|
|
53
57
|
context: GenerateContextType;
|
|
54
|
-
|
|
58
|
+
/** The model's ref (see {@link RefParts}); an `OasRef` fits it. */
|
|
59
|
+
ref: RefParts;
|
|
55
60
|
/** Model variant being probed (see {@link Variant}) */
|
|
56
61
|
variant: string;
|
|
57
62
|
};
|
|
58
63
|
export type ToModelPreviewModuleArgs = {
|
|
59
64
|
context: GenerateContextType;
|
|
60
|
-
|
|
65
|
+
/** The model's ref (see {@link RefParts}); an `OasRef` fits it. */
|
|
66
|
+
ref: RefParts;
|
|
61
67
|
/** Model variant the preview module describes (see {@link Variant}) */
|
|
62
68
|
variant: string;
|
|
63
69
|
};
|
|
64
70
|
export type ToModelMappingArgs = {
|
|
65
71
|
context: GenerateContextType;
|
|
66
|
-
|
|
72
|
+
/** The model's ref (see {@link RefParts}); an `OasRef` fits it. */
|
|
73
|
+
ref: RefParts;
|
|
67
74
|
/** Model variant the mapping module describes (see {@link Variant}) */
|
|
68
75
|
variant: string;
|
|
69
76
|
};
|
|
@@ -72,13 +79,15 @@ export type ToModelMappingArgs = {
|
|
|
72
79
|
* depends on them: definitions are cached by name and export path.
|
|
73
80
|
*/
|
|
74
81
|
export type ToModelIdentifierNameArgs<EnrichmentType = undefined, ProjectionOptions = undefined> = {
|
|
75
|
-
|
|
82
|
+
/** The model's ref (see {@link RefParts}); an `OasRef` fits it. */
|
|
83
|
+
ref: RefParts;
|
|
76
84
|
enrichments: EnrichmentType;
|
|
77
85
|
/** Model variant the identifier should disambiguate (see {@link Variant}) */
|
|
78
86
|
variant: string;
|
|
79
87
|
} & ProjectionOptionsArg<ProjectionOptions>;
|
|
80
88
|
export type ToModelExportPathArgs<EnrichmentType = undefined, ProjectionOptions = undefined> = {
|
|
81
|
-
|
|
89
|
+
/** The model's ref (see {@link RefParts}); an `OasRef` fits it. */
|
|
90
|
+
ref: RefParts;
|
|
82
91
|
enrichments: EnrichmentType;
|
|
83
92
|
/** Model variant the export path should disambiguate (see {@link Variant}) */
|
|
84
93
|
variant: string;
|
|
@@ -95,7 +104,7 @@ export type ToModelExportPathArgs<EnrichmentType = undefined, ProjectionOptions
|
|
|
95
104
|
export type ModelProjection<V extends GeneratedValue, EnrichmentType = undefined, ProjectionOptions = undefined> = {
|
|
96
105
|
prototype: V;
|
|
97
106
|
} & {
|
|
98
|
-
new ({ context,
|
|
107
|
+
new ({ context, ref, settings, destinationPath, rootRef, options }: ModelProjectionConstructorArgs<EnrichmentType, ProjectionOptions>): V;
|
|
99
108
|
id: string;
|
|
100
109
|
type: 'model';
|
|
101
110
|
/**
|
|
@@ -111,11 +120,11 @@ export type ModelProjection<V extends GeneratedValue, EnrichmentType = undefined
|
|
|
111
120
|
* Context-aware, overridable: the non-`name` parts of the identifier
|
|
112
121
|
* (`type` / `typeName` / `exported`), derived from the schema. The engine
|
|
113
122
|
* assembles `lang.toIdentifier({ name: toIdentifierName(args),
|
|
114
|
-
* ...toIdentifierType(
|
|
123
|
+
* ...toIdentifierType(ref, context) })`.
|
|
115
124
|
*/
|
|
116
|
-
toIdentifierType: (
|
|
125
|
+
toIdentifierType: (ref: RefParts, context: GenerateContextType) => IdentifierType;
|
|
117
126
|
toExportPath: (args: ToModelExportPathArgs<EnrichmentType, ProjectionOptions>) => string;
|
|
118
|
-
toEnrichments: ({
|
|
127
|
+
toEnrichments: ({ ref, context, variant }: ToModelEnrichmentsArgs) => EnrichmentType;
|
|
119
128
|
/**
|
|
120
129
|
* Family-level capability predicate, surfaced as a static by
|
|
121
130
|
* `toModelProjectionBase` (default `() => true`). The Driver probes it on
|
|
@@ -9,7 +9,7 @@ import type { IdentifierType } from '../../IdentifierType.js';
|
|
|
9
9
|
import type { GeneratedValue } from '../../GeneratedValue.js';
|
|
10
10
|
import type { Inserted } from '../../Inserted.js';
|
|
11
11
|
import type { ModelProjection, NormalizedModelProjection } from '../../model/types.js';
|
|
12
|
-
import type {
|
|
12
|
+
import type { RefParts } from '../../../helpers/refFns.js';
|
|
13
13
|
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';
|
|
@@ -103,7 +103,7 @@ export declare const toGqlOperationProjectionBase: <EnrichmentType = undefined,
|
|
|
103
103
|
* `{ options }` is required when the peer declares options and refused
|
|
104
104
|
* when it does not.
|
|
105
105
|
*/
|
|
106
|
-
insertModel<V extends GeneratedValue, PeerEnrichmentType_1 = undefined, PeerProjectionOptions_1 = undefined>(projection: ModelProjection<V, PeerEnrichmentType_1, PeerProjectionOptions_1>,
|
|
106
|
+
insertModel<V extends GeneratedValue, PeerEnrichmentType_1 = undefined, PeerProjectionOptions_1 = undefined>(projection: ModelProjection<V, PeerEnrichmentType_1, PeerProjectionOptions_1>, ref: RefParts, ...rest: ProjectionOptionsRest<PeerInsertOptions<PeerProjectionOptions_1>, PeerProjectionOptions_1>): Inserted<V, PeerEnrichmentType_1>;
|
|
107
107
|
/**
|
|
108
108
|
* Insert a related model with reference normalization. Useful for
|
|
109
109
|
* schemas that may be either a `$ref` or a concrete object.
|
|
@@ -86,8 +86,8 @@ const toGqlOperationProjectionBase = (base, config) => {
|
|
|
86
86
|
* `{ options }` is required when the peer declares options and refused
|
|
87
87
|
* when it does not.
|
|
88
88
|
*/
|
|
89
|
-
insertModel(projection,
|
|
90
|
-
return this.context.insertModel(projection,
|
|
89
|
+
insertModel(projection, ref, ...rest) {
|
|
90
|
+
return this.context.insertModel(projection, ref, {
|
|
91
91
|
...(0, InsertOptions_js_1.toPeerInsertOptions)(rest),
|
|
92
92
|
destinationPath: this.settings.exportPath
|
|
93
93
|
});
|
|
@@ -10,7 +10,7 @@ import type { IdentifierType } from '../../IdentifierType.js';
|
|
|
10
10
|
import type { GeneratedValue } from '../../GeneratedValue.js';
|
|
11
11
|
import type { Inserted } from '../../Inserted.js';
|
|
12
12
|
import type { ModelProjection, NormalizedModelProjection } from '../../model/types.js';
|
|
13
|
-
import type {
|
|
13
|
+
import type { RefParts } from '../../../helpers/refFns.js';
|
|
14
14
|
import type { OasSchema } from '../../../oas/schema/Schema.js';
|
|
15
15
|
import type { OasRef } from '../../../oas/ref/Ref.js';
|
|
16
16
|
import type { OasVoid } from '../../../oas/void/Void.js';
|
|
@@ -128,7 +128,7 @@ export declare const toOasOperationProjectionBase: <EnrichmentType = undefined,
|
|
|
128
128
|
* `{ options }` is required when the peer declares options and refused
|
|
129
129
|
* when it does not.
|
|
130
130
|
*/
|
|
131
|
-
insertModel<V extends GeneratedValue, PeerEnrichmentType_1 = undefined, PeerProjectionOptions_1 = undefined>(projection: ModelProjection<V, PeerEnrichmentType_1, PeerProjectionOptions_1>,
|
|
131
|
+
insertModel<V extends GeneratedValue, PeerEnrichmentType_1 = undefined, PeerProjectionOptions_1 = undefined>(projection: ModelProjection<V, PeerEnrichmentType_1, PeerProjectionOptions_1>, ref: RefParts, ...rest: ProjectionOptionsRest<PeerInsertOptions<PeerProjectionOptions_1>, PeerProjectionOptions_1>): Inserted<V, PeerEnrichmentType_1>;
|
|
132
132
|
/**
|
|
133
133
|
* Insert a related model with reference normalization. Useful for inline
|
|
134
134
|
* request/response schemas where the schema may be either a `$ref` or a
|
|
@@ -103,8 +103,8 @@ const toOasOperationProjectionBase = (base, config) => {
|
|
|
103
103
|
* `{ options }` is required when the peer declares options and refused
|
|
104
104
|
* when it does not.
|
|
105
105
|
*/
|
|
106
|
-
insertModel(projection,
|
|
107
|
-
return this.context.insertModel(projection,
|
|
106
|
+
insertModel(projection, ref, ...rest) {
|
|
107
|
+
return this.context.insertModel(projection, ref, {
|
|
108
108
|
...(0, InsertOptions_js_1.toPeerInsertOptions)(rest),
|
|
109
109
|
destinationPath: this.settings.exportPath
|
|
110
110
|
});
|