@skmtc/core 0.56.1 → 0.58.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/context/CoreContext.d.ts +4 -4
- package/esm/context/GenerateContext.d.ts +0 -2
- package/esm/context/GenerateContext.js +25 -5
- package/esm/dsl/model/ModelDriver.d.ts +0 -2
- package/esm/dsl/model/ModelDriver.js +1 -9
- package/esm/dsl/model/types.d.ts +1 -2
- package/esm/run/toArtifacts.d.ts +4 -4
- package/esm/types/TypeSystem.d.ts +0 -3
- package/package.json +1 -1
- package/script/context/CoreContext.d.ts +4 -4
- package/script/context/GenerateContext.d.ts +0 -2
- package/script/context/GenerateContext.js +25 -5
- package/script/dsl/model/ModelDriver.d.ts +0 -2
- package/script/dsl/model/ModelDriver.js +1 -9
- package/script/dsl/model/types.d.ts +1 -2
- package/script/run/toArtifacts.d.ts +4 -4
- package/script/types/TypeSystem.d.ts +0 -3
|
@@ -119,10 +119,10 @@ export type ToArtifactsArgs = {
|
|
|
119
119
|
* the run can let it go. That run goes subject by subject, and writes the
|
|
120
120
|
* same files. A file can have its definitions in another order when more
|
|
121
121
|
* than one generator inserts into it: each subject runs every generator
|
|
122
|
-
* before the next subject runs
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
122
|
+
* before the next subject runs. A run without `onArtifact` takes the model
|
|
123
|
+
* generators first, then the operation generators, then the webhook
|
|
124
|
+
* generators, so the order of these kinds in the config changes no file.
|
|
125
|
+
* A run with
|
|
126
126
|
* `attribution.postPass` or `inspect`, or of a GraphQL document, gives
|
|
127
127
|
* every file at the end.
|
|
128
128
|
*
|
|
@@ -98,8 +98,6 @@ export type CreateAndRegisterDefinition<Schema extends SchemaType> = {
|
|
|
98
98
|
destinationPath: string;
|
|
99
99
|
/** Function to transform the schema into a generated value */
|
|
100
100
|
schemaToValueFn: SchemaToValueFn;
|
|
101
|
-
/** The ref of the model whose value tree holds the schema */
|
|
102
|
-
rootRef?: RefParts;
|
|
103
101
|
/** Whether to exclude this definition from exports */
|
|
104
102
|
noExport?: boolean;
|
|
105
103
|
};
|
|
@@ -40,6 +40,25 @@ import { EnrichmentAudit, hasVariantEnrichment } from '../enrichments/Enrichment
|
|
|
40
40
|
import { toSerializedError } from '../types/SerializedError.js';
|
|
41
41
|
import { GenerationFailure } from './toGenerationFailure.js';
|
|
42
42
|
import { formatEnrichmentPath } from '../enrichments/EnrichmentWarning.js';
|
|
43
|
+
/**
|
|
44
|
+
* Where a generator's kind comes in a run: the model generators, then the
|
|
45
|
+
* operation generators, then the webhook generators.
|
|
46
|
+
*/
|
|
47
|
+
const toKindRank = ({ type }) => {
|
|
48
|
+
switch (type) {
|
|
49
|
+
case 'model':
|
|
50
|
+
return 0;
|
|
51
|
+
case 'oasOperation':
|
|
52
|
+
case 'gqlOperation':
|
|
53
|
+
return 1;
|
|
54
|
+
case 'webhook':
|
|
55
|
+
return 2;
|
|
56
|
+
default: {
|
|
57
|
+
const _exhaustive = type;
|
|
58
|
+
throw new Error(`Invalid generator type: ${JSON.stringify(_exhaustive)}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
43
62
|
/** What one of a generator's subjects is called on its log line. */
|
|
44
63
|
const toSubjectNoun = ({ type }) => {
|
|
45
64
|
switch (type) {
|
|
@@ -261,9 +280,10 @@ export class GenerateContext {
|
|
|
261
280
|
toArtifacts(stackTrail, release) {
|
|
262
281
|
const generators = Object.values(this.toGeneratorConfigMap());
|
|
263
282
|
// A run that gives each file when it is complete goes subject by
|
|
264
|
-
// subject. Any other run goes generator by generator
|
|
265
|
-
//
|
|
266
|
-
//
|
|
283
|
+
// subject. Any other run goes generator by generator, by kind: the
|
|
284
|
+
// models, the operations, the webhooks. Both write the same files,
|
|
285
|
+
// whatever the order of the kinds in the config; a file that more than
|
|
286
|
+
// one generator inserts into can have its definitions in another order.
|
|
267
287
|
if (release !== undefined && this.document.type === 'oas') {
|
|
268
288
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runBySubject).call(this, this.document.value, generators, stackTrail, release);
|
|
269
289
|
}
|
|
@@ -744,7 +764,6 @@ export class GenerateContext {
|
|
|
744
764
|
context: this,
|
|
745
765
|
projection,
|
|
746
766
|
ref,
|
|
747
|
-
rootRef: ref,
|
|
748
767
|
...toInsertOptions(rest)
|
|
749
768
|
});
|
|
750
769
|
return new Inserted({ settings, definition });
|
|
@@ -959,7 +978,8 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
959
978
|
if (result === 'error') {
|
|
960
979
|
__classPrivateFieldGet(this, _GenerateContext_subjectCounts, "f").failed += 1;
|
|
961
980
|
}
|
|
962
|
-
}, _GenerateContext_runByGenerator = function _GenerateContext_runByGenerator(
|
|
981
|
+
}, _GenerateContext_runByGenerator = function _GenerateContext_runByGenerator(listed, stackTrail) {
|
|
982
|
+
const generators = listed.toSorted((first, second) => toKindRank(first) - toKindRank(second));
|
|
963
983
|
generators.forEach(generatorConfig => {
|
|
964
984
|
stackTrail.trace(generatorConfig.id, st => {
|
|
965
985
|
// Whole-generator skip (string entry in `skip`). No per-operation
|
|
@@ -15,7 +15,6 @@ type CreateModelArgs<V extends GeneratedValue, EnrichmentType, ProjectionOptions
|
|
|
15
15
|
projection: ModelProjection<V, EnrichmentType, ProjectionOptions>;
|
|
16
16
|
/** The model's ref; an `OasRef` fits it. */
|
|
17
17
|
ref: RefParts;
|
|
18
|
-
rootRef?: RefParts;
|
|
19
18
|
} & InsertModelOptions<ProjectionOptions>;
|
|
20
19
|
/**
|
|
21
20
|
* Driver for the model insertion lifecycle.
|
|
@@ -33,7 +32,6 @@ export declare class ModelDriver<V extends GeneratedValue, EnrichmentType, Proje
|
|
|
33
32
|
settings: ContentSettings<EnrichmentType>;
|
|
34
33
|
destinationPath?: string;
|
|
35
34
|
definition: GeneratedDefinition<V>;
|
|
36
|
-
rootRef?: RefParts;
|
|
37
35
|
noExport: boolean;
|
|
38
36
|
variant: string;
|
|
39
37
|
/** The caller's options, as passed to `insertModel`. */
|
|
@@ -57,12 +57,6 @@ export class ModelDriver {
|
|
|
57
57
|
writable: true,
|
|
58
58
|
value: void 0
|
|
59
59
|
});
|
|
60
|
-
Object.defineProperty(this, "rootRef", {
|
|
61
|
-
enumerable: true,
|
|
62
|
-
configurable: true,
|
|
63
|
-
writable: true,
|
|
64
|
-
value: void 0
|
|
65
|
-
});
|
|
66
60
|
Object.defineProperty(this, "noExport", {
|
|
67
61
|
enumerable: true,
|
|
68
62
|
configurable: true,
|
|
@@ -82,12 +76,11 @@ export class ModelDriver {
|
|
|
82
76
|
writable: true,
|
|
83
77
|
value: void 0
|
|
84
78
|
});
|
|
85
|
-
const { context, projection, ref, destinationPath,
|
|
79
|
+
const { context, projection, ref, destinationPath, noExport = false, variant = DEFAULT_VARIANT } = args;
|
|
86
80
|
this.context = context;
|
|
87
81
|
this.projection = projection;
|
|
88
82
|
this.ref = ref;
|
|
89
83
|
this.destinationPath = destinationPath;
|
|
90
|
-
this.rootRef = rootRef;
|
|
91
84
|
this.noExport = noExport;
|
|
92
85
|
this.variant = variant;
|
|
93
86
|
this.options = readProjectionOptions(args);
|
|
@@ -158,7 +151,6 @@ export class ModelDriver {
|
|
|
158
151
|
context: this.context,
|
|
159
152
|
settings: this.settings,
|
|
160
153
|
destinationPath: this.settings.exportPath,
|
|
161
|
-
rootRef: this.rootRef,
|
|
162
154
|
options: this.options
|
|
163
155
|
}));
|
|
164
156
|
const definition = this.projection.lang.toDefinition({
|
package/esm/dsl/model/types.d.ts
CHANGED
|
@@ -20,7 +20,6 @@ export type ModelProjectionConstructorArgs<EnrichmentType = undefined, Projectio
|
|
|
20
20
|
ref: RefParts;
|
|
21
21
|
settings: ContentSettings<EnrichmentType>;
|
|
22
22
|
destinationPath: string;
|
|
23
|
-
rootRef?: RefParts;
|
|
24
23
|
} & ProjectionOptionsArg<ProjectionOptions>;
|
|
25
24
|
export type WithTransformModel = {
|
|
26
25
|
transformModel: (ref: RefParts) => void;
|
|
@@ -104,7 +103,7 @@ export type ToModelExportPathArgs<EnrichmentType = undefined, ProjectionOptions
|
|
|
104
103
|
export type ModelProjection<V extends GeneratedValue, EnrichmentType = undefined, ProjectionOptions = undefined> = {
|
|
105
104
|
prototype: V;
|
|
106
105
|
} & {
|
|
107
|
-
new ({ context, ref, settings, destinationPath,
|
|
106
|
+
new ({ context, ref, settings, destinationPath, options }: ModelProjectionConstructorArgs<EnrichmentType, ProjectionOptions>): V;
|
|
108
107
|
id: string;
|
|
109
108
|
type: 'model';
|
|
110
109
|
/**
|
package/esm/run/toArtifacts.d.ts
CHANGED
|
@@ -77,10 +77,10 @@ type TransformArgs = {
|
|
|
77
77
|
* the run can let it go. That run goes subject by subject, and writes the
|
|
78
78
|
* same files. A file can have its definitions in another order when more
|
|
79
79
|
* than one generator inserts into it: each subject runs every generator
|
|
80
|
-
* before the next subject runs
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
80
|
+
* before the next subject runs. A run without `onArtifact` takes the model
|
|
81
|
+
* generators first, then the operation generators, then the webhook
|
|
82
|
+
* generators, so the order of these kinds in the config changes no file.
|
|
83
|
+
* A run with
|
|
84
84
|
* `attribution.postPass` or `inspect`, or of a GraphQL document, gives
|
|
85
85
|
* every file at the end.
|
|
86
86
|
*
|
|
@@ -7,7 +7,6 @@ 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 { RefParts } from '../helpers/refFns.js';
|
|
11
10
|
/**
|
|
12
11
|
* Union type representing all possible type system values in the SKMTC code generation system.
|
|
13
12
|
*
|
|
@@ -554,8 +553,6 @@ export type TypeSystemArgs<Schema extends SchemaType> = {
|
|
|
554
553
|
destinationPath: string;
|
|
555
554
|
/** The schema to transform */
|
|
556
555
|
schema: Schema;
|
|
557
|
-
/** The ref of the model whose value tree holds the schema */
|
|
558
|
-
rootRef?: RefParts;
|
|
559
556
|
/** Whether the schema field is required */
|
|
560
557
|
required: boolean | undefined;
|
|
561
558
|
};
|
package/package.json
CHANGED
|
@@ -119,10 +119,10 @@ export type ToArtifactsArgs = {
|
|
|
119
119
|
* the run can let it go. That run goes subject by subject, and writes the
|
|
120
120
|
* same files. A file can have its definitions in another order when more
|
|
121
121
|
* than one generator inserts into it: each subject runs every generator
|
|
122
|
-
* before the next subject runs
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
122
|
+
* before the next subject runs. A run without `onArtifact` takes the model
|
|
123
|
+
* generators first, then the operation generators, then the webhook
|
|
124
|
+
* generators, so the order of these kinds in the config changes no file.
|
|
125
|
+
* A run with
|
|
126
126
|
* `attribution.postPass` or `inspect`, or of a GraphQL document, gives
|
|
127
127
|
* every file at the end.
|
|
128
128
|
*
|
|
@@ -98,8 +98,6 @@ export type CreateAndRegisterDefinition<Schema extends SchemaType> = {
|
|
|
98
98
|
destinationPath: string;
|
|
99
99
|
/** Function to transform the schema into a generated value */
|
|
100
100
|
schemaToValueFn: SchemaToValueFn;
|
|
101
|
-
/** The ref of the model whose value tree holds the schema */
|
|
102
|
-
rootRef?: RefParts;
|
|
103
101
|
/** Whether to exclude this definition from exports */
|
|
104
102
|
noExport?: boolean;
|
|
105
103
|
};
|
|
@@ -50,6 +50,25 @@ const EnrichmentAudit_js_1 = require("../enrichments/EnrichmentAudit.js");
|
|
|
50
50
|
const SerializedError_js_1 = require("../types/SerializedError.js");
|
|
51
51
|
const toGenerationFailure_js_1 = require("./toGenerationFailure.js");
|
|
52
52
|
const EnrichmentWarning_js_1 = require("../enrichments/EnrichmentWarning.js");
|
|
53
|
+
/**
|
|
54
|
+
* Where a generator's kind comes in a run: the model generators, then the
|
|
55
|
+
* operation generators, then the webhook generators.
|
|
56
|
+
*/
|
|
57
|
+
const toKindRank = ({ type }) => {
|
|
58
|
+
switch (type) {
|
|
59
|
+
case 'model':
|
|
60
|
+
return 0;
|
|
61
|
+
case 'oasOperation':
|
|
62
|
+
case 'gqlOperation':
|
|
63
|
+
return 1;
|
|
64
|
+
case 'webhook':
|
|
65
|
+
return 2;
|
|
66
|
+
default: {
|
|
67
|
+
const _exhaustive = type;
|
|
68
|
+
throw new Error(`Invalid generator type: ${JSON.stringify(_exhaustive)}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
53
72
|
/** What one of a generator's subjects is called on its log line. */
|
|
54
73
|
const toSubjectNoun = ({ type }) => {
|
|
55
74
|
switch (type) {
|
|
@@ -271,9 +290,10 @@ class GenerateContext {
|
|
|
271
290
|
toArtifacts(stackTrail, release) {
|
|
272
291
|
const generators = Object.values(this.toGeneratorConfigMap());
|
|
273
292
|
// A run that gives each file when it is complete goes subject by
|
|
274
|
-
// subject. Any other run goes generator by generator
|
|
275
|
-
//
|
|
276
|
-
//
|
|
293
|
+
// subject. Any other run goes generator by generator, by kind: the
|
|
294
|
+
// models, the operations, the webhooks. Both write the same files,
|
|
295
|
+
// whatever the order of the kinds in the config; a file that more than
|
|
296
|
+
// one generator inserts into can have its definitions in another order.
|
|
277
297
|
if (release !== undefined && this.document.type === 'oas') {
|
|
278
298
|
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_runBySubject).call(this, this.document.value, generators, stackTrail, release);
|
|
279
299
|
}
|
|
@@ -754,7 +774,6 @@ class GenerateContext {
|
|
|
754
774
|
context: this,
|
|
755
775
|
projection,
|
|
756
776
|
ref,
|
|
757
|
-
rootRef: ref,
|
|
758
777
|
...(0, InsertOptions_js_1.toInsertOptions)(rest)
|
|
759
778
|
});
|
|
760
779
|
return new Inserted_js_1.Inserted({ settings, definition });
|
|
@@ -970,7 +989,8 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
970
989
|
if (result === 'error') {
|
|
971
990
|
__classPrivateFieldGet(this, _GenerateContext_subjectCounts, "f").failed += 1;
|
|
972
991
|
}
|
|
973
|
-
}, _GenerateContext_runByGenerator = function _GenerateContext_runByGenerator(
|
|
992
|
+
}, _GenerateContext_runByGenerator = function _GenerateContext_runByGenerator(listed, stackTrail) {
|
|
993
|
+
const generators = listed.toSorted((first, second) => toKindRank(first) - toKindRank(second));
|
|
974
994
|
generators.forEach(generatorConfig => {
|
|
975
995
|
stackTrail.trace(generatorConfig.id, st => {
|
|
976
996
|
// Whole-generator skip (string entry in `skip`). No per-operation
|
|
@@ -15,7 +15,6 @@ type CreateModelArgs<V extends GeneratedValue, EnrichmentType, ProjectionOptions
|
|
|
15
15
|
projection: ModelProjection<V, EnrichmentType, ProjectionOptions>;
|
|
16
16
|
/** The model's ref; an `OasRef` fits it. */
|
|
17
17
|
ref: RefParts;
|
|
18
|
-
rootRef?: RefParts;
|
|
19
18
|
} & InsertModelOptions<ProjectionOptions>;
|
|
20
19
|
/**
|
|
21
20
|
* Driver for the model insertion lifecycle.
|
|
@@ -33,7 +32,6 @@ export declare class ModelDriver<V extends GeneratedValue, EnrichmentType, Proje
|
|
|
33
32
|
settings: ContentSettings<EnrichmentType>;
|
|
34
33
|
destinationPath?: string;
|
|
35
34
|
definition: GeneratedDefinition<V>;
|
|
36
|
-
rootRef?: RefParts;
|
|
37
35
|
noExport: boolean;
|
|
38
36
|
variant: string;
|
|
39
37
|
/** The caller's options, as passed to `insertModel`. */
|
|
@@ -63,12 +63,6 @@ class ModelDriver {
|
|
|
63
63
|
writable: true,
|
|
64
64
|
value: void 0
|
|
65
65
|
});
|
|
66
|
-
Object.defineProperty(this, "rootRef", {
|
|
67
|
-
enumerable: true,
|
|
68
|
-
configurable: true,
|
|
69
|
-
writable: true,
|
|
70
|
-
value: void 0
|
|
71
|
-
});
|
|
72
66
|
Object.defineProperty(this, "noExport", {
|
|
73
67
|
enumerable: true,
|
|
74
68
|
configurable: true,
|
|
@@ -88,12 +82,11 @@ class ModelDriver {
|
|
|
88
82
|
writable: true,
|
|
89
83
|
value: void 0
|
|
90
84
|
});
|
|
91
|
-
const { context, projection, ref, destinationPath,
|
|
85
|
+
const { context, projection, ref, destinationPath, noExport = false, variant = Variant_js_1.DEFAULT_VARIANT } = args;
|
|
92
86
|
this.context = context;
|
|
93
87
|
this.projection = projection;
|
|
94
88
|
this.ref = ref;
|
|
95
89
|
this.destinationPath = destinationPath;
|
|
96
|
-
this.rootRef = rootRef;
|
|
97
90
|
this.noExport = noExport;
|
|
98
91
|
this.variant = variant;
|
|
99
92
|
this.options = (0, ProjectionOptions_js_1.readProjectionOptions)(args);
|
|
@@ -164,7 +157,6 @@ class ModelDriver {
|
|
|
164
157
|
context: this.context,
|
|
165
158
|
settings: this.settings,
|
|
166
159
|
destinationPath: this.settings.exportPath,
|
|
167
|
-
rootRef: this.rootRef,
|
|
168
160
|
options: this.options
|
|
169
161
|
}));
|
|
170
162
|
const definition = this.projection.lang.toDefinition({
|
|
@@ -20,7 +20,6 @@ export type ModelProjectionConstructorArgs<EnrichmentType = undefined, Projectio
|
|
|
20
20
|
ref: RefParts;
|
|
21
21
|
settings: ContentSettings<EnrichmentType>;
|
|
22
22
|
destinationPath: string;
|
|
23
|
-
rootRef?: RefParts;
|
|
24
23
|
} & ProjectionOptionsArg<ProjectionOptions>;
|
|
25
24
|
export type WithTransformModel = {
|
|
26
25
|
transformModel: (ref: RefParts) => void;
|
|
@@ -104,7 +103,7 @@ export type ToModelExportPathArgs<EnrichmentType = undefined, ProjectionOptions
|
|
|
104
103
|
export type ModelProjection<V extends GeneratedValue, EnrichmentType = undefined, ProjectionOptions = undefined> = {
|
|
105
104
|
prototype: V;
|
|
106
105
|
} & {
|
|
107
|
-
new ({ context, ref, settings, destinationPath,
|
|
106
|
+
new ({ context, ref, settings, destinationPath, options }: ModelProjectionConstructorArgs<EnrichmentType, ProjectionOptions>): V;
|
|
108
107
|
id: string;
|
|
109
108
|
type: 'model';
|
|
110
109
|
/**
|
|
@@ -77,10 +77,10 @@ type TransformArgs = {
|
|
|
77
77
|
* the run can let it go. That run goes subject by subject, and writes the
|
|
78
78
|
* same files. A file can have its definitions in another order when more
|
|
79
79
|
* than one generator inserts into it: each subject runs every generator
|
|
80
|
-
* before the next subject runs
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
80
|
+
* before the next subject runs. A run without `onArtifact` takes the model
|
|
81
|
+
* generators first, then the operation generators, then the webhook
|
|
82
|
+
* generators, so the order of these kinds in the config changes no file.
|
|
83
|
+
* A run with
|
|
84
84
|
* `attribution.postPass` or `inspect`, or of a GraphQL document, gives
|
|
85
85
|
* every file at the end.
|
|
86
86
|
*
|
|
@@ -7,7 +7,6 @@ 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 { RefParts } from '../helpers/refFns.js';
|
|
11
10
|
/**
|
|
12
11
|
* Union type representing all possible type system values in the SKMTC code generation system.
|
|
13
12
|
*
|
|
@@ -554,8 +553,6 @@ export type TypeSystemArgs<Schema extends SchemaType> = {
|
|
|
554
553
|
destinationPath: string;
|
|
555
554
|
/** The schema to transform */
|
|
556
555
|
schema: Schema;
|
|
557
|
-
/** The ref of the model whose value tree holds the schema */
|
|
558
|
-
rootRef?: RefParts;
|
|
559
556
|
/** Whether the schema field is required */
|
|
560
557
|
required: boolean | undefined;
|
|
561
558
|
};
|