@skmtc/core 0.54.1 → 0.55.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.js +2 -1
- package/esm/context/FilePlan.d.ts +56 -0
- package/esm/context/FilePlan.js +188 -0
- package/esm/context/GenerateContext.d.ts +18 -0
- package/esm/context/GenerateContext.js +28 -1
- package/esm/context/StderrConsoleHandler.d.ts +12 -0
- package/esm/context/StderrConsoleHandler.js +14 -0
- package/esm/context/Subject.d.ts +51 -7
- package/esm/context/Subject.js +76 -8
- package/esm/enrichments/EnrichmentAudit.d.ts +7 -0
- package/esm/enrichments/EnrichmentAudit.js +36 -4
- package/package.json +1 -1
- package/script/context/CoreContext.js +2 -1
- package/script/context/FilePlan.d.ts +56 -0
- package/script/context/FilePlan.js +192 -0
- package/script/context/GenerateContext.d.ts +18 -0
- package/script/context/GenerateContext.js +28 -1
- package/script/context/StderrConsoleHandler.d.ts +12 -0
- package/script/context/StderrConsoleHandler.js +18 -0
- package/script/context/Subject.d.ts +51 -7
- package/script/context/Subject.js +75 -7
- package/script/enrichments/EnrichmentAudit.d.ts +7 -0
- package/script/enrichments/EnrichmentAudit.js +36 -4
|
@@ -5,6 +5,12 @@ const refFns_js_1 = require("../helpers/refFns.js");
|
|
|
5
5
|
/** An OpenAPI operation as a subject. Its results and enrichments are at `[path][method]`. */
|
|
6
6
|
class OasOperationSubject {
|
|
7
7
|
constructor(operation) {
|
|
8
|
+
Object.defineProperty(this, "type", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value: 'oasOperation'
|
|
13
|
+
});
|
|
8
14
|
Object.defineProperty(this, "operation", {
|
|
9
15
|
enumerable: true,
|
|
10
16
|
configurable: true,
|
|
@@ -48,6 +54,16 @@ class OasOperationSubject {
|
|
|
48
54
|
toPreviewModule({ entry, context, variant }) {
|
|
49
55
|
return entry.toPreviewModule?.({ context, operation: this.operation, variant });
|
|
50
56
|
}
|
|
57
|
+
toExportPath({ projection, context, variant }) {
|
|
58
|
+
if (projection.type !== 'oasOperation') {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const enrichments = projection.toEnrichments({ operation: this.operation, context, variant });
|
|
62
|
+
return projection.toExportPath({ operation: this.operation, enrichments, variant });
|
|
63
|
+
}
|
|
64
|
+
toNamedModels(reach) {
|
|
65
|
+
return reach.namedByOperation(this.operation);
|
|
66
|
+
}
|
|
51
67
|
toSource({ generatorId, variant }) {
|
|
52
68
|
return (0, exports.toOasOperationSource)({ operation: this.operation, generatorId, variant });
|
|
53
69
|
}
|
|
@@ -60,6 +76,12 @@ exports.OasOperationSubject = OasOperationSubject;
|
|
|
60
76
|
*/
|
|
61
77
|
class WebhookSubject {
|
|
62
78
|
constructor(webhook) {
|
|
79
|
+
Object.defineProperty(this, "type", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
configurable: true,
|
|
82
|
+
writable: true,
|
|
83
|
+
value: 'webhook'
|
|
84
|
+
});
|
|
63
85
|
Object.defineProperty(this, "webhook", {
|
|
64
86
|
enumerable: true,
|
|
65
87
|
configurable: true,
|
|
@@ -103,6 +125,16 @@ class WebhookSubject {
|
|
|
103
125
|
toPreviewModule({ entry, context, variant }) {
|
|
104
126
|
return entry.toPreviewModule?.({ context, webhook: this.webhook, variant });
|
|
105
127
|
}
|
|
128
|
+
toExportPath({ projection, context, variant }) {
|
|
129
|
+
if (projection.type !== 'webhook') {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
const enrichments = projection.toEnrichments({ webhook: this.webhook, context, variant });
|
|
133
|
+
return projection.toExportPath({ webhook: this.webhook, enrichments, variant });
|
|
134
|
+
}
|
|
135
|
+
toNamedModels(reach) {
|
|
136
|
+
return reach.namedByWebhook(this.webhook);
|
|
137
|
+
}
|
|
106
138
|
toSource({ generatorId, variant }) {
|
|
107
139
|
return (0, exports.toWebhookSource)({ webhook: this.webhook, generatorId, variant });
|
|
108
140
|
}
|
|
@@ -115,6 +147,12 @@ exports.WebhookSubject = WebhookSubject;
|
|
|
115
147
|
*/
|
|
116
148
|
class GqlOperationSubject {
|
|
117
149
|
constructor(operation) {
|
|
150
|
+
Object.defineProperty(this, "type", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
configurable: true,
|
|
153
|
+
writable: true,
|
|
154
|
+
value: 'gqlOperation'
|
|
155
|
+
});
|
|
118
156
|
Object.defineProperty(this, "operation", {
|
|
119
157
|
enumerable: true,
|
|
120
158
|
configurable: true,
|
|
@@ -157,14 +195,33 @@ class GqlOperationSubject {
|
|
|
157
195
|
toPreviewModule({ entry, context, variant }) {
|
|
158
196
|
return entry.toPreviewModule?.({ context, operation: this.operation, variant });
|
|
159
197
|
}
|
|
198
|
+
// A GraphQL document has no `$ref`s to read a reach from, so its files are not planned.
|
|
199
|
+
toExportPath() {
|
|
200
|
+
return undefined;
|
|
201
|
+
}
|
|
202
|
+
toNamedModels() {
|
|
203
|
+
return [];
|
|
204
|
+
}
|
|
160
205
|
toSource({ generatorId, variant }) {
|
|
161
206
|
return (0, exports.toGqlOperationSource)({ operation: this.operation, generatorId, variant });
|
|
162
207
|
}
|
|
163
208
|
}
|
|
164
209
|
exports.GqlOperationSubject = GqlOperationSubject;
|
|
165
|
-
/**
|
|
210
|
+
/**
|
|
211
|
+
* A model as a subject. Its results and enrichments are at its model key
|
|
212
|
+
* (`toModelKey`): the `refName` of a component, the whole pointer of any
|
|
213
|
+
* other model. The run makes one for each schema component of either
|
|
214
|
+
* protocol; the file plan also makes one for a model that is no component,
|
|
215
|
+
* which a `$ref` to a place inside a schema gives.
|
|
216
|
+
*/
|
|
166
217
|
class ModelSubject {
|
|
167
|
-
constructor(
|
|
218
|
+
constructor(ref) {
|
|
219
|
+
Object.defineProperty(this, "type", {
|
|
220
|
+
enumerable: true,
|
|
221
|
+
configurable: true,
|
|
222
|
+
writable: true,
|
|
223
|
+
value: 'model'
|
|
224
|
+
});
|
|
168
225
|
Object.defineProperty(this, "refName", {
|
|
169
226
|
enumerable: true,
|
|
170
227
|
configurable: true,
|
|
@@ -195,11 +252,12 @@ class ModelSubject {
|
|
|
195
252
|
writable: true,
|
|
196
253
|
value: void 0
|
|
197
254
|
});
|
|
198
|
-
this.refName = refName;
|
|
199
|
-
this.ref =
|
|
200
|
-
|
|
201
|
-
this.
|
|
202
|
-
this.
|
|
255
|
+
this.refName = ref.refName;
|
|
256
|
+
this.ref = ref;
|
|
257
|
+
const key = (0, refFns_js_1.toModelKey)(ref);
|
|
258
|
+
this.trail = key;
|
|
259
|
+
this.enrichmentPath = [key];
|
|
260
|
+
this.label = key;
|
|
203
261
|
}
|
|
204
262
|
isSupported({ entry, context, variant }) {
|
|
205
263
|
return (typeof entry.isSupported !== 'function' ||
|
|
@@ -214,6 +272,16 @@ class ModelSubject {
|
|
|
214
272
|
toPreviewModule({ entry, context, variant }) {
|
|
215
273
|
return entry.toPreviewModule?.({ context, ref: this.ref, variant });
|
|
216
274
|
}
|
|
275
|
+
toExportPath({ projection, context, variant }) {
|
|
276
|
+
if (projection.type !== 'model') {
|
|
277
|
+
return undefined;
|
|
278
|
+
}
|
|
279
|
+
const enrichments = projection.toEnrichments({ ref: this.ref, context, variant });
|
|
280
|
+
return projection.toExportPath({ ref: this.ref, enrichments, variant });
|
|
281
|
+
}
|
|
282
|
+
toNamedModels() {
|
|
283
|
+
return [(0, refFns_js_1.toModelKey)(this.ref)];
|
|
284
|
+
}
|
|
217
285
|
toSource({ generatorId, variant }) {
|
|
218
286
|
return (0, exports.toModelSource)({ refName: this.refName, generatorId, variant });
|
|
219
287
|
}
|
|
@@ -50,6 +50,13 @@ type FinalizeArgs = {
|
|
|
50
50
|
};
|
|
51
51
|
export declare class EnrichmentAudit {
|
|
52
52
|
#private;
|
|
53
|
+
/**
|
|
54
|
+
* Runs `fn` with nothing recorded: no lookup counts as a use, and no
|
|
55
|
+
* warning is kept. For a reader that is not the run, such as the file
|
|
56
|
+
* plan: it reads enrichments for projections the run may never insert,
|
|
57
|
+
* and those reads must not make configured paths look used.
|
|
58
|
+
*/
|
|
59
|
+
withoutRecording<T>(fn: () => T): T;
|
|
53
60
|
/**
|
|
54
61
|
* Record one enrichment lookup. Every prefix of `segments` is marked
|
|
55
62
|
* consumed, so block-level and leaf-level reads land in one namespace.
|
|
@@ -32,7 +32,13 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
32
32
|
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");
|
|
33
33
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
34
34
|
};
|
|
35
|
-
var
|
|
35
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
36
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
37
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
38
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
39
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
40
|
+
};
|
|
41
|
+
var _EnrichmentAudit_instances, _EnrichmentAudit_consumed, _EnrichmentAudit_children, _EnrichmentAudit_warnings, _EnrichmentAudit_reported, _EnrichmentAudit_records, _EnrichmentAudit_isConsumed, _EnrichmentAudit_divergenceSuggestion, _EnrichmentAudit_checkBlock;
|
|
36
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
43
|
exports.hasVariantEnrichment = exports.EnrichmentAudit = void 0;
|
|
38
44
|
const Enrichments_js_1 = require("../types/Enrichments.js");
|
|
@@ -54,17 +60,41 @@ class EnrichmentAudit {
|
|
|
54
60
|
);
|
|
55
61
|
/** Identity keys of reported warnings — reads repeat, warnings must not. */
|
|
56
62
|
_EnrichmentAudit_reported.set(this, new Set()
|
|
63
|
+
/** `false` inside {@link withoutRecording}. */
|
|
64
|
+
);
|
|
65
|
+
/** `false` inside {@link withoutRecording}. */
|
|
66
|
+
_EnrichmentAudit_records.set(this, true
|
|
57
67
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
68
|
+
* Runs `fn` with nothing recorded: no lookup counts as a use, and no
|
|
69
|
+
* warning is kept. For a reader that is not the run, such as the file
|
|
70
|
+
* plan: it reads enrichments for projections the run may never insert,
|
|
71
|
+
* and those reads must not make configured paths look used.
|
|
60
72
|
*/
|
|
61
73
|
);
|
|
62
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Runs `fn` with nothing recorded: no lookup counts as a use, and no
|
|
77
|
+
* warning is kept. For a reader that is not the run, such as the file
|
|
78
|
+
* plan: it reads enrichments for projections the run may never insert,
|
|
79
|
+
* and those reads must not make configured paths look used.
|
|
80
|
+
*/
|
|
81
|
+
withoutRecording(fn) {
|
|
82
|
+
const records = __classPrivateFieldGet(this, _EnrichmentAudit_records, "f");
|
|
83
|
+
__classPrivateFieldSet(this, _EnrichmentAudit_records, false, "f");
|
|
84
|
+
try {
|
|
85
|
+
return fn();
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
__classPrivateFieldSet(this, _EnrichmentAudit_records, records, "f");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
63
91
|
/**
|
|
64
92
|
* Record one enrichment lookup. Every prefix of `segments` is marked
|
|
65
93
|
* consumed, so block-level and leaf-level reads land in one namespace.
|
|
66
94
|
*/
|
|
67
95
|
consume(segments) {
|
|
96
|
+
if (!__classPrivateFieldGet(this, _EnrichmentAudit_records, "f"))
|
|
97
|
+
return;
|
|
68
98
|
let parentKey = toPathKey([]);
|
|
69
99
|
for (let end = 1; end <= segments.length; end++) {
|
|
70
100
|
const key = toPathKey(segments.slice(0, end));
|
|
@@ -85,6 +115,8 @@ class EnrichmentAudit {
|
|
|
85
115
|
* warning.
|
|
86
116
|
*/
|
|
87
117
|
report(warning) {
|
|
118
|
+
if (!__classPrivateFieldGet(this, _EnrichmentAudit_records, "f"))
|
|
119
|
+
return;
|
|
88
120
|
const key = toPathKey([warning.type, ...warning.path]);
|
|
89
121
|
if (__classPrivateFieldGet(this, _EnrichmentAudit_reported, "f").has(key))
|
|
90
122
|
return;
|
|
@@ -181,7 +213,7 @@ class EnrichmentAudit {
|
|
|
181
213
|
}
|
|
182
214
|
}
|
|
183
215
|
exports.EnrichmentAudit = EnrichmentAudit;
|
|
184
|
-
_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) {
|
|
216
|
+
_EnrichmentAudit_consumed = new WeakMap(), _EnrichmentAudit_children = new WeakMap(), _EnrichmentAudit_warnings = new WeakMap(), _EnrichmentAudit_reported = new WeakMap(), _EnrichmentAudit_records = new WeakMap(), _EnrichmentAudit_instances = new WeakSet(), _EnrichmentAudit_isConsumed = function _EnrichmentAudit_isConsumed(segments) {
|
|
185
217
|
return __classPrivateFieldGet(this, _EnrichmentAudit_consumed, "f").has(toPathKey(segments));
|
|
186
218
|
}, _EnrichmentAudit_divergenceSuggestion = function _EnrichmentAudit_divergenceSuggestion(path) {
|
|
187
219
|
for (let depth = 0; depth < path.length; depth++) {
|