@skmtc/core 0.44.2 → 0.46.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.js +136 -34
- package/esm/context/generateTypes.d.ts +7 -6
- package/esm/context/generateTypes.js +2 -0
- 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/refFns.d.ts +108 -43
- package/esm/helpers/refFns.js +166 -57
- package/esm/oas/document/Document.d.ts +6 -0
- package/esm/oas/document/Document.js +44 -2
- package/esm/oas/header/Header.js +4 -1
- package/esm/oas/parameter/Parameter.d.ts +1 -1
- package/esm/oas/parameter/Parameter.js +5 -2
- 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/schemaPath/traverseSchema.js +11 -5
- package/esm/parse/missingSchema.d.ts +30 -0
- package/esm/parse/missingSchema.js +33 -0
- package/esm/parse/v3-0/header/toHeadersV3.js +5 -0
- package/esm/parse/v3-0/parameter/toParameterV3.js +11 -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-1/header/toHeadersV3.js +5 -0
- package/esm/parse/v3-1/parameter/toParameterV3.js +11 -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-2/header/toHeadersV3.js +5 -0
- package/esm/parse/v3-2/parameter/toParameterV3.js +11 -0
- package/esm/parse/v3-2/ref/toRefTargetV3.d.ts +23 -0
- package/esm/parse/v3-2/ref/toRefTargetV3.js +70 -0
- 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/TypeSystem.d.ts +3 -3
- 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.js +135 -33
- package/script/context/generateTypes.d.ts +7 -6
- package/script/context/generateTypes.js +2 -0
- 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/refFns.d.ts +108 -43
- package/script/helpers/refFns.js +180 -59
- package/script/oas/document/Document.d.ts +6 -0
- package/script/oas/document/Document.js +44 -2
- package/script/oas/header/Header.js +4 -1
- package/script/oas/parameter/Parameter.d.ts +1 -1
- package/script/oas/parameter/Parameter.js +5 -2
- 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/schemaPath/traverseSchema.js +10 -4
- package/script/parse/missingSchema.d.ts +30 -0
- package/script/parse/missingSchema.js +38 -0
- package/script/parse/v3-0/header/toHeadersV3.js +5 -0
- package/script/parse/v3-0/parameter/toParameterV3.js +11 -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-1/header/toHeadersV3.js +5 -0
- package/script/parse/v3-1/parameter/toParameterV3.js +11 -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-2/header/toHeadersV3.js +5 -0
- package/script/parse/v3-2/parameter/toParameterV3.js +11 -0
- package/script/parse/v3-2/ref/toRefTargetV3.d.ts +23 -0
- package/script/parse/v3-2/ref/toRefTargetV3.js +74 -0
- 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/TypeSystem.d.ts +3 -3
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toRefTargetV3 = void 0;
|
|
4
|
+
const isPlainObject_js_1 = require("../../isPlainObject.js");
|
|
5
|
+
const toSchemasV3_js_1 = require("../schema/toSchemasV3.js");
|
|
6
|
+
const toParameterV3_js_1 = require("../parameter/toParameterV3.js");
|
|
7
|
+
const toResponseV3_js_1 = require("../response/toResponseV3.js");
|
|
8
|
+
const toRequestBodiesV3_js_1 = require("../requestBody/toRequestBodiesV3.js");
|
|
9
|
+
const toHeadersV3_js_1 = require("../header/toHeadersV3.js");
|
|
10
|
+
const toLinksV3_js_1 = require("../link/toLinksV3.js");
|
|
11
|
+
const toExamplesV3_js_1 = require("../example/toExamplesV3.js");
|
|
12
|
+
const toSecuritySchemes_js_1 = require("../securitySchemes/toSecuritySchemes.js");
|
|
13
|
+
const tryParseAt_js_1 = require("../../../context/tryParseAt.js");
|
|
14
|
+
/**
|
|
15
|
+
* The raw value read as the OpenAPI type its parser takes, as the components
|
|
16
|
+
* parser reads `documentObject.components`: the parser checks what it reads.
|
|
17
|
+
*/
|
|
18
|
+
const isRawEntry = (value) => (0, isPlainObject_js_1.isPlainObject)(value);
|
|
19
|
+
/**
|
|
20
|
+
* Parses the target of a ref that does not point at a component
|
|
21
|
+
* (`#/components/schemas/Pet/properties/tag`, `#/paths/~1pets/get/parameters/0`)
|
|
22
|
+
* at its own position, with the parser that components of its kind use. Gives
|
|
23
|
+
* `undefined` when the target does not parse (the parser has logged why).
|
|
24
|
+
*/
|
|
25
|
+
const toRefTargetV3 = ({ refType, name, value, stackTrail, context }) => {
|
|
26
|
+
switch (refType) {
|
|
27
|
+
case 'schema':
|
|
28
|
+
return isRawEntry(value)
|
|
29
|
+
? (0, toSchemasV3_js_1.toOptionalSchemasV3)({ schemas: { [name]: value }, stackTrail, context })?.[name]
|
|
30
|
+
: undefined;
|
|
31
|
+
case 'parameter':
|
|
32
|
+
return isRawEntry(value)
|
|
33
|
+
? (0, toParameterV3_js_1.toOptionalParametersV3)({ parameters: { [name]: value }, stackTrail, context })?.[name]
|
|
34
|
+
: undefined;
|
|
35
|
+
case 'response':
|
|
36
|
+
return isRawEntry(value)
|
|
37
|
+
? (0, toResponseV3_js_1.toOptionalResponsesV3)({ responses: { [name]: value }, stackTrail, context })?.[name]
|
|
38
|
+
: undefined;
|
|
39
|
+
case 'requestBody':
|
|
40
|
+
return isRawEntry(value)
|
|
41
|
+
? (0, toRequestBodiesV3_js_1.toRequestBodiesV3)({ requestBodies: { [name]: value }, stackTrail, context })?.[name]
|
|
42
|
+
: undefined;
|
|
43
|
+
case 'header':
|
|
44
|
+
return isRawEntry(value)
|
|
45
|
+
? (0, toHeadersV3_js_1.toComponentHeadersV3)({ headers: { [name]: value }, stackTrail, context })?.[name]
|
|
46
|
+
: undefined;
|
|
47
|
+
case 'link':
|
|
48
|
+
return isRawEntry(value)
|
|
49
|
+
? (0, toLinksV3_js_1.toLinksV3)({ links: { [name]: value }, stackTrail, context })?.[name]
|
|
50
|
+
: undefined;
|
|
51
|
+
case 'example':
|
|
52
|
+
// No components parser reads a single example by key, so the target
|
|
53
|
+
// is parsed as `toExamplesV3` parses each entry, under `tryParseAt`.
|
|
54
|
+
return isRawEntry(value)
|
|
55
|
+
? (0, tryParseAt_js_1.tryParseAt)({
|
|
56
|
+
stackTrail,
|
|
57
|
+
key: name,
|
|
58
|
+
context,
|
|
59
|
+
type: 'INVALID_EXAMPLE',
|
|
60
|
+
parent: value,
|
|
61
|
+
fn: st => (0, toExamplesV3_js_1.toExampleV3)({ example: value, stackTrail: st, context })
|
|
62
|
+
})
|
|
63
|
+
: undefined;
|
|
64
|
+
case 'securityScheme':
|
|
65
|
+
return isRawEntry(value)
|
|
66
|
+
? (0, toSecuritySchemes_js_1.toSecuritySchemesV3)({ securitySchemes: { [name]: value }, stackTrail, context })?.[name]
|
|
67
|
+
: undefined;
|
|
68
|
+
default: {
|
|
69
|
+
const _exhaustive = refType;
|
|
70
|
+
throw new Error(`Unhandled ref type: ${_exhaustive}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
exports.toRefTargetV3 = toRefTargetV3;
|
|
@@ -9,6 +9,7 @@ const toMediaTypeItemV3_js_1 = require("../mediaType/toMediaTypeItemV3.js");
|
|
|
9
9
|
const Header_js_1 = require("../../../oas/header/Header.js");
|
|
10
10
|
const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toSpecificationExtensionsV3.js");
|
|
11
11
|
const toComponentEntries_js_1 = require("../../toComponentEntries.js");
|
|
12
|
+
const missingSchema_js_1 = require("../../missingSchema.js");
|
|
12
13
|
const toHeadersV3 = ({ headers, stackTrail, context }) => {
|
|
13
14
|
if (!headers) {
|
|
14
15
|
return undefined;
|
|
@@ -68,5 +69,9 @@ const toHeaderV3 = ({ header, name, stackTrail, context }) => {
|
|
|
68
69
|
content: stackTrail.trace('content', st => (0, toMediaTypeItemV3_js_1.toOptionalMediaTypeItemsV3)({ content, stackTrail: st, context })),
|
|
69
70
|
extensionFields
|
|
70
71
|
};
|
|
72
|
+
// A `null` schema or content reads as absent; a boolean schema does not.
|
|
73
|
+
if (typeof schema !== 'boolean' && fields.schema === undefined && fields.content === undefined) {
|
|
74
|
+
fields.schema = (0, missingSchema_js_1.toMissingHeaderSchema)({ header, name, stackTrail, context });
|
|
75
|
+
}
|
|
71
76
|
return new Header_js_1.OasHeader(fields);
|
|
72
77
|
};
|
|
@@ -45,6 +45,7 @@ const Parameter_js_1 = require("../../../oas/parameter/Parameter.js");
|
|
|
45
45
|
const toSpecificationExtensionsV3_js_1 = require("../specificationExtensions/toSpecificationExtensionsV3.js");
|
|
46
46
|
const v = __importStar(require("valibot"));
|
|
47
47
|
const emptyParameter_js_1 = require("../../emptyParameter.js");
|
|
48
|
+
const missingSchema_js_1 = require("../../missingSchema.js");
|
|
48
49
|
const pathParameters_js_1 = require("../../pathParameters.js");
|
|
49
50
|
const toParameterListV3 = ({ parameters, stackTrail, context }) => (0, pathParameters_js_1.toParameterEntries)({ parameters, stackTrail, context })?.flatMap((parameter, index) => toParameterEntryV3({ parameter, index, stackTrail, context }));
|
|
50
51
|
exports.toParameterListV3 = toParameterListV3;
|
|
@@ -169,6 +170,16 @@ const toParameterV3 = ({ parameter, stackTrail, context }) => {
|
|
|
169
170
|
content: stackTrail.trace('content', st => (0, toMediaTypeItemV3_js_1.toOptionalMediaTypeItemsV3)({ content, stackTrail: st, context })),
|
|
170
171
|
extensionFields
|
|
171
172
|
};
|
|
173
|
+
// A `null` schema or content reads as absent; a boolean schema does not.
|
|
174
|
+
if (typeof schema !== 'boolean' && fields.schema === undefined && fields.content === undefined) {
|
|
175
|
+
fields.schema = (0, missingSchema_js_1.toMissingParameterSchema)({
|
|
176
|
+
parameter,
|
|
177
|
+
name,
|
|
178
|
+
location: parsedLocation,
|
|
179
|
+
stackTrail,
|
|
180
|
+
context
|
|
181
|
+
});
|
|
182
|
+
}
|
|
172
183
|
return context.withStackTrail(stackTrail, () => new Parameter_js_1.OasParameter(fields, context));
|
|
173
184
|
};
|
|
174
185
|
const toStyle = ({ style, location, stackTrail }) => {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ParseContextType } from '../../../context/parseTypes.js';
|
|
2
|
+
import type { StackTrail } from '../../../context/StackTrail.js';
|
|
3
|
+
import type { ComponentsEntry } from '../../../oas/components/Components.js';
|
|
4
|
+
import type { OasRefData } from '../../../oas/ref/ref-types.js';
|
|
5
|
+
/** What {@link toRefTargetV3} parses. */
|
|
6
|
+
export type ToRefTargetArgs = {
|
|
7
|
+
/** The kind of component the ref is written for. */
|
|
8
|
+
refType: OasRefData['refType'];
|
|
9
|
+
/** The last segment of the target's pointer, unescaped: the key it parses under. */
|
|
10
|
+
name: string;
|
|
11
|
+
/** The raw value at the pointer. */
|
|
12
|
+
value: Record<string, unknown>;
|
|
13
|
+
/** The trail of the target's parent, so the target parses at its own position. */
|
|
14
|
+
stackTrail: StackTrail;
|
|
15
|
+
context: ParseContextType;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Parses the target of a ref that does not point at a component
|
|
19
|
+
* (`#/components/schemas/Pet/properties/tag`, `#/paths/~1pets/get/parameters/0`)
|
|
20
|
+
* at its own position, with the parser that components of its kind use. Gives
|
|
21
|
+
* `undefined` when the target does not parse (the parser has logged why).
|
|
22
|
+
*/
|
|
23
|
+
export declare const toRefTargetV3: ({ refType, name, value, stackTrail, context }: ToRefTargetArgs) => ComponentsEntry | undefined;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toRefTargetV3 = void 0;
|
|
4
|
+
const isPlainObject_js_1 = require("../../isPlainObject.js");
|
|
5
|
+
const toSchemasV3_js_1 = require("../schema/toSchemasV3.js");
|
|
6
|
+
const toParameterV3_js_1 = require("../parameter/toParameterV3.js");
|
|
7
|
+
const toResponseV3_js_1 = require("../response/toResponseV3.js");
|
|
8
|
+
const toRequestBodiesV3_js_1 = require("../requestBody/toRequestBodiesV3.js");
|
|
9
|
+
const toHeadersV3_js_1 = require("../header/toHeadersV3.js");
|
|
10
|
+
const toLinksV3_js_1 = require("../link/toLinksV3.js");
|
|
11
|
+
const toExamplesV3_js_1 = require("../example/toExamplesV3.js");
|
|
12
|
+
const toSecuritySchemes_js_1 = require("../securitySchemes/toSecuritySchemes.js");
|
|
13
|
+
const tryParseAt_js_1 = require("../../../context/tryParseAt.js");
|
|
14
|
+
/**
|
|
15
|
+
* The raw value read as the OpenAPI type its parser takes, as the components
|
|
16
|
+
* parser reads `documentObject.components`: the parser checks what it reads.
|
|
17
|
+
*/
|
|
18
|
+
const isRawEntry = (value) => (0, isPlainObject_js_1.isPlainObject)(value);
|
|
19
|
+
/**
|
|
20
|
+
* Parses the target of a ref that does not point at a component
|
|
21
|
+
* (`#/components/schemas/Pet/properties/tag`, `#/paths/~1pets/get/parameters/0`)
|
|
22
|
+
* at its own position, with the parser that components of its kind use. Gives
|
|
23
|
+
* `undefined` when the target does not parse (the parser has logged why).
|
|
24
|
+
*/
|
|
25
|
+
const toRefTargetV3 = ({ refType, name, value, stackTrail, context }) => {
|
|
26
|
+
switch (refType) {
|
|
27
|
+
case 'schema':
|
|
28
|
+
return isRawEntry(value)
|
|
29
|
+
? (0, toSchemasV3_js_1.toOptionalSchemasV3)({ schemas: { [name]: value }, stackTrail, context })?.[name]
|
|
30
|
+
: undefined;
|
|
31
|
+
case 'parameter':
|
|
32
|
+
return isRawEntry(value)
|
|
33
|
+
? (0, toParameterV3_js_1.toOptionalParametersV3)({ parameters: { [name]: value }, stackTrail, context })?.[name]
|
|
34
|
+
: undefined;
|
|
35
|
+
case 'response':
|
|
36
|
+
return isRawEntry(value)
|
|
37
|
+
? (0, toResponseV3_js_1.toOptionalResponsesV3)({ responses: { [name]: value }, stackTrail, context })?.[name]
|
|
38
|
+
: undefined;
|
|
39
|
+
case 'requestBody':
|
|
40
|
+
return isRawEntry(value)
|
|
41
|
+
? (0, toRequestBodiesV3_js_1.toRequestBodiesV3)({ requestBodies: { [name]: value }, stackTrail, context })?.[name]
|
|
42
|
+
: undefined;
|
|
43
|
+
case 'header':
|
|
44
|
+
return isRawEntry(value)
|
|
45
|
+
? (0, toHeadersV3_js_1.toComponentHeadersV3)({ headers: { [name]: value }, stackTrail, context })?.[name]
|
|
46
|
+
: undefined;
|
|
47
|
+
case 'link':
|
|
48
|
+
return isRawEntry(value)
|
|
49
|
+
? (0, toLinksV3_js_1.toLinksV3)({ links: { [name]: value }, stackTrail, context })?.[name]
|
|
50
|
+
: undefined;
|
|
51
|
+
case 'example':
|
|
52
|
+
// No components parser reads a single example by key, so the target
|
|
53
|
+
// is parsed as `toExamplesV3` parses each entry, under `tryParseAt`.
|
|
54
|
+
return isRawEntry(value)
|
|
55
|
+
? (0, tryParseAt_js_1.tryParseAt)({
|
|
56
|
+
stackTrail,
|
|
57
|
+
key: name,
|
|
58
|
+
context,
|
|
59
|
+
type: 'INVALID_EXAMPLE',
|
|
60
|
+
parent: value,
|
|
61
|
+
fn: st => (0, toExamplesV3_js_1.toExampleV3)({ example: value, stackTrail: st, context })
|
|
62
|
+
})
|
|
63
|
+
: undefined;
|
|
64
|
+
case 'securityScheme':
|
|
65
|
+
return isRawEntry(value)
|
|
66
|
+
? (0, toSecuritySchemes_js_1.toSecuritySchemesV3)({ securitySchemes: { [name]: value }, stackTrail, context })?.[name]
|
|
67
|
+
: undefined;
|
|
68
|
+
default: {
|
|
69
|
+
const _exhaustive = refType;
|
|
70
|
+
throw new Error(`Unhandled ref type: ${_exhaustive}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
exports.toRefTargetV3 = toRefTargetV3;
|
|
@@ -43,7 +43,7 @@ import type { ModelEntry } from '../dsl/model/toModelEntry.js';
|
|
|
43
43
|
*
|
|
44
44
|
* const modelEntry = toModelEntry({
|
|
45
45
|
* id: 'typescript-models',
|
|
46
|
-
* transform: ({ context,
|
|
46
|
+
* transform: ({ context, ref }) => {}
|
|
47
47
|
* });
|
|
48
48
|
* // modelEntry.type === 'model'
|
|
49
49
|
* ```
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @fileoverview Caller options for projections.
|
|
3
3
|
*
|
|
4
4
|
* Options are typed data the CALLING generator passes when it inserts a
|
|
5
|
-
* peer: `context.insertModel(Peer,
|
|
5
|
+
* peer: `context.insertModel(Peer, ref, { options })`. Enrichments are
|
|
6
6
|
* the user's per-subject configuration and a variant selects one of them;
|
|
7
7
|
* options belong to the caller.
|
|
8
8
|
*
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @fileoverview Caller options for projections.
|
|
4
4
|
*
|
|
5
5
|
* Options are typed data the CALLING generator passes when it inserts a
|
|
6
|
-
* peer: `context.insertModel(Peer,
|
|
6
|
+
* peer: `context.insertModel(Peer, ref, { options })`. Enrichments are
|
|
7
7
|
* the user's per-subject configuration and a variant selects one of them;
|
|
8
8
|
* options belong to the caller.
|
|
9
9
|
*
|
|
@@ -99,14 +99,14 @@ import type { Brand } from './Brand.js';
|
|
|
99
99
|
* @example In generator contexts
|
|
100
100
|
* ```typescript
|
|
101
101
|
* class ModelGenerator extends ModelProjectionBase {
|
|
102
|
-
* constructor(args: {
|
|
102
|
+
* constructor(args: { ref: RefParts; ... }) {
|
|
103
103
|
* super(args);
|
|
104
|
-
* // this.refName is
|
|
104
|
+
* // this.ref.refName is the name of the model's ref
|
|
105
105
|
* }
|
|
106
106
|
*
|
|
107
107
|
* toDefinition(): Definition {
|
|
108
108
|
* // RefName ensures we're working with valid schema identifiers
|
|
109
|
-
* const schemaName = this.refName; // Type: RefName
|
|
109
|
+
* const schemaName = this.ref.refName; // Type: RefName
|
|
110
110
|
* return new Definition({
|
|
111
111
|
* identifier: createType(schemaName),
|
|
112
112
|
* // ...
|
|
@@ -7,7 +7,7 @@ import type { GenerateContextType } from '../context/generateTypes.js';
|
|
|
7
7
|
import type { CustomValue } from '../dsl/CustomValue.js';
|
|
8
8
|
import type { OasVoid } from '../oas/void/Void.js';
|
|
9
9
|
import type { GeneratorKey } from '../dsl/GeneratorKeys.js';
|
|
10
|
-
import type {
|
|
10
|
+
import type { RefParts } from '../helpers/refFns.js';
|
|
11
11
|
/**
|
|
12
12
|
* Union type representing all possible type system values in the SKMTC code generation system.
|
|
13
13
|
*
|
|
@@ -539,8 +539,8 @@ export type TypeSystemArgs<Schema extends SchemaType> = {
|
|
|
539
539
|
destinationPath: string;
|
|
540
540
|
/** The schema to transform */
|
|
541
541
|
schema: Schema;
|
|
542
|
-
/**
|
|
543
|
-
rootRef?:
|
|
542
|
+
/** The ref of the model whose value tree holds the schema */
|
|
543
|
+
rootRef?: RefParts;
|
|
544
544
|
/** Whether the schema field is required */
|
|
545
545
|
required: boolean | undefined;
|
|
546
546
|
};
|