@skmtc/core 0.58.4 → 0.58.5
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/GenerateContext.d.ts +3 -0
- package/esm/context/GenerateContext.js +40 -4
- package/esm/dsl/model/toModelProjectionBase.d.ts +4 -1
- package/package.json +1 -1
- package/script/context/GenerateContext.d.ts +3 -0
- package/script/context/GenerateContext.js +40 -4
- package/script/dsl/model/toModelProjectionBase.d.ts +4 -1
|
@@ -368,6 +368,9 @@ export declare class GenerateContext implements GenerateContextType {
|
|
|
368
368
|
* `toEnrichments` against the given `ref` and `variant`. The full
|
|
369
369
|
* identifier is assembled through the projection's language
|
|
370
370
|
* (`lang.toIdentifier`).
|
|
371
|
+
*
|
|
372
|
+
* With no projection options, `toIdentifierName` and `toExportPath` are
|
|
373
|
+
* asked once in a run for each projection, ref and variant.
|
|
371
374
|
*/
|
|
372
375
|
toModelContentSettings<V extends GeneratedValue, EnrichmentType, ProjectionOptions>(args: BuildModelSettingsArgs<V, EnrichmentType, ProjectionOptions>): ContentSettings<EnrichmentType>;
|
|
373
376
|
/**
|
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
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");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_failedItems, _GenerateContext_foldedPaths, _GenerateContext_released, _GenerateContext_previews, _GenerateContext_captureChannel, _GenerateContext_enrichmentAudit, _GenerateContext_currentSubjectTrail, _GenerateContext_logsGeneratorLines, _GenerateContext_subjectCounts, _GenerateContext_reportSkippedEnrichment, _GenerateContext_logError, _GenerateContext_failItem, _GenerateContext_captureSubjectResult, _GenerateContext_runByGenerator, _GenerateContext_runBySubject, _GenerateContext_toGeneratorRuns, _GenerateContext_toSteps, _GenerateContext_release, _GenerateContext_affirmNotReleased, _GenerateContext_logGeneratorLine, _GenerateContext_runGenerator, _GenerateContext_schemaRefNames, _GenerateContext_subjectDefaults, _GenerateContext_runSubjects, _GenerateContext_addPreview, _GenerateContext_toContentSettingsExportPath, _GenerateContext_ejectedBySuffixedPath_get, _GenerateContext_ejectedBySuffixedPathCache, _GenerateContext_findContainer, _GenerateContext_toContainer;
|
|
12
|
+
var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_failedItems, _GenerateContext_foldedPaths, _GenerateContext_released, _GenerateContext_previews, _GenerateContext_captureChannel, _GenerateContext_enrichmentAudit, _GenerateContext_currentSubjectTrail, _GenerateContext_logsGeneratorLines, _GenerateContext_subjectCounts, _GenerateContext_reportSkippedEnrichment, _GenerateContext_logError, _GenerateContext_failItem, _GenerateContext_captureSubjectResult, _GenerateContext_runByGenerator, _GenerateContext_runBySubject, _GenerateContext_toGeneratorRuns, _GenerateContext_toSteps, _GenerateContext_release, _GenerateContext_affirmNotReleased, _GenerateContext_logGeneratorLine, _GenerateContext_runGenerator, _GenerateContext_schemaRefNames, _GenerateContext_subjectDefaults, _GenerateContext_runSubjects, _GenerateContext_addPreview, _GenerateContext_toContentSettingsExportPath, _GenerateContext_ejectedBySuffixedPath_get, _GenerateContext_ejectedBySuffixedPathCache, _GenerateContext_modelIdentities, _GenerateContext_findContainer, _GenerateContext_toContainer;
|
|
13
13
|
import { applyGeneratedSuffixToWorkspacePath, normalizeWorkspacePath } from '../helpers/normalizeWorkspacePath.js';
|
|
14
14
|
import { getByWorkspacePath } from '../helpers/getByWorkspacePath.js';
|
|
15
15
|
import { DEFAULT_GENERATED_SUFFIX } from '../helpers/applyGeneratedSuffix.js';
|
|
@@ -204,6 +204,21 @@ export class GenerateContext {
|
|
|
204
204
|
/** The counts of the generator {@link toArtifacts} is running. */
|
|
205
205
|
_GenerateContext_subjectCounts.set(this, { offered: 0, transformed: 0, failed: 0 });
|
|
206
206
|
_GenerateContext_ejectedBySuffixedPathCache.set(this, void 0);
|
|
207
|
+
/** By a model projection class: the name and the export path of each model and variant it was asked for. */
|
|
208
|
+
_GenerateContext_modelIdentities.set(this, new Map()
|
|
209
|
+
/**
|
|
210
|
+
* Look up an already-registered file by path, or `undefined` if none
|
|
211
|
+
* exists. In a run with `onArtifact`, a lookup of a file that was given
|
|
212
|
+
* to the host throws. Neutral primitive: returns the abstract `FileBase` and never
|
|
213
|
+
* constructs anything, so a (future) language-owned `register` can ask
|
|
214
|
+
* "does this file exist yet?" without the engine knowing the language.
|
|
215
|
+
* To create on a miss, add a file your language constructs with
|
|
216
|
+
* {@link addFile} (`getFile(path) ?? addFile(lang.createFile(…))`).
|
|
217
|
+
*
|
|
218
|
+
* `filePath` may be in any spelling. It is normalized only when it is no
|
|
219
|
+
* key: a key is a normalized path. The file's own `path` is the key.
|
|
220
|
+
*/
|
|
221
|
+
);
|
|
207
222
|
this.logger = logger;
|
|
208
223
|
__classPrivateFieldSet(this, _GenerateContext_logsGeneratorLines, logsGeneratorLines, "f");
|
|
209
224
|
__classPrivateFieldSet(this, _GenerateContext_files, new Map(), "f");
|
|
@@ -874,17 +889,38 @@ export class GenerateContext {
|
|
|
874
889
|
* `toEnrichments` against the given `ref` and `variant`. The full
|
|
875
890
|
* identifier is assembled through the projection's language
|
|
876
891
|
* (`lang.toIdentifier`).
|
|
892
|
+
*
|
|
893
|
+
* With no projection options, `toIdentifierName` and `toExportPath` are
|
|
894
|
+
* asked once in a run for each projection, ref and variant.
|
|
877
895
|
*/
|
|
878
896
|
toModelContentSettings(args) {
|
|
879
897
|
const { ref, projection, variant = DEFAULT_VARIANT } = args;
|
|
880
898
|
const options = readProjectionOptions(args);
|
|
881
899
|
const enrichments = projection.toEnrichments({ ref, context: this, variant });
|
|
900
|
+
// A model is referred to many times in a run, and its name and its
|
|
901
|
+
// export path are the same each time: they come from the ref, the
|
|
902
|
+
// enrichments and the variant. With options they can differ, so only a
|
|
903
|
+
// call with no options is kept.
|
|
904
|
+
// Each part of the key can hold any character: the lengths keep them apart.
|
|
905
|
+
const key = options === undefined
|
|
906
|
+
? `${ref.refPath.length}:${ref.refName.length}:${ref.refPath}${ref.refName}${variant}`
|
|
907
|
+
: undefined;
|
|
908
|
+
const kept = key === undefined ? undefined : __classPrivateFieldGet(this, _GenerateContext_modelIdentities, "f").get(projection)?.get(key);
|
|
909
|
+
const identity = kept ?? {
|
|
910
|
+
name: projection.toIdentifierName({ ref, enrichments, variant, options }),
|
|
911
|
+
exportPath: __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toContentSettingsExportPath).call(this, projection.toExportPath({ ref, enrichments, variant, options }), projection.id)
|
|
912
|
+
};
|
|
913
|
+
if (key !== undefined && kept === undefined) {
|
|
914
|
+
const byKey = __classPrivateFieldGet(this, _GenerateContext_modelIdentities, "f").get(projection) ?? new Map();
|
|
915
|
+
byKey.set(key, identity);
|
|
916
|
+
__classPrivateFieldGet(this, _GenerateContext_modelIdentities, "f").set(projection, byKey);
|
|
917
|
+
}
|
|
882
918
|
return new ContentSettings({
|
|
883
919
|
identifier: projection.lang.toIdentifier({
|
|
884
|
-
name:
|
|
920
|
+
name: identity.name,
|
|
885
921
|
...projection.toIdentifierType(ref, this)
|
|
886
922
|
}),
|
|
887
|
-
exportPath:
|
|
923
|
+
exportPath: identity.exportPath,
|
|
888
924
|
enrichments,
|
|
889
925
|
variant
|
|
890
926
|
});
|
|
@@ -954,7 +990,7 @@ export class GenerateContext {
|
|
|
954
990
|
return place?.findDefinitions({ name })?.[0];
|
|
955
991
|
}
|
|
956
992
|
}
|
|
957
|
-
_GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakMap(), _GenerateContext_foldedPaths = new WeakMap(), _GenerateContext_released = new WeakMap(), _GenerateContext_previews = new WeakMap(), _GenerateContext_captureChannel = new WeakMap(), _GenerateContext_enrichmentAudit = new WeakMap(), _GenerateContext_currentSubjectTrail = new WeakMap(), _GenerateContext_logsGeneratorLines = new WeakMap(), _GenerateContext_subjectCounts = new WeakMap(), _GenerateContext_ejectedBySuffixedPathCache = new WeakMap(), _GenerateContext_instances = new WeakSet(), _GenerateContext_reportSkippedEnrichment = function _GenerateContext_reportSkippedEnrichment(block, variant, path) {
|
|
993
|
+
_GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakMap(), _GenerateContext_foldedPaths = new WeakMap(), _GenerateContext_released = new WeakMap(), _GenerateContext_previews = new WeakMap(), _GenerateContext_captureChannel = new WeakMap(), _GenerateContext_enrichmentAudit = new WeakMap(), _GenerateContext_currentSubjectTrail = new WeakMap(), _GenerateContext_logsGeneratorLines = new WeakMap(), _GenerateContext_subjectCounts = new WeakMap(), _GenerateContext_ejectedBySuffixedPathCache = new WeakMap(), _GenerateContext_modelIdentities = new WeakMap(), _GenerateContext_instances = new WeakSet(), _GenerateContext_reportSkippedEnrichment = function _GenerateContext_reportSkippedEnrichment(block, variant, path) {
|
|
958
994
|
if (!hasVariantEnrichment(block, variant))
|
|
959
995
|
return;
|
|
960
996
|
__classPrivateFieldGet(this, _GenerateContext_enrichmentAudit, "f").report({
|
|
@@ -44,7 +44,10 @@ type ToEnrichmentsArgs = {
|
|
|
44
44
|
*/
|
|
45
45
|
export type ModelProjectionBaseConfig<EnrichmentType = undefined, IdType extends IdentifierType = IdentifierType, ProjectionOptions = undefined> = {
|
|
46
46
|
id: string;
|
|
47
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Pure: the cache-key name. With no projection options,
|
|
49
|
+
* `toModelContentSettings` asks for it once in a run and keeps it.
|
|
50
|
+
*/
|
|
48
51
|
toIdentifierName: (args: ToModelIdentifierNameArgs<EnrichmentType, ProjectionOptions>) => string;
|
|
49
52
|
/**
|
|
50
53
|
* Context-aware, overridable: the non-`name` parts of the identifier
|
package/package.json
CHANGED
|
@@ -368,6 +368,9 @@ export declare class GenerateContext implements GenerateContextType {
|
|
|
368
368
|
* `toEnrichments` against the given `ref` and `variant`. The full
|
|
369
369
|
* identifier is assembled through the projection's language
|
|
370
370
|
* (`lang.toIdentifier`).
|
|
371
|
+
*
|
|
372
|
+
* With no projection options, `toIdentifierName` and `toExportPath` are
|
|
373
|
+
* asked once in a run for each projection, ref and variant.
|
|
371
374
|
*/
|
|
372
375
|
toModelContentSettings<V extends GeneratedValue, EnrichmentType, ProjectionOptions>(args: BuildModelSettingsArgs<V, EnrichmentType, ProjectionOptions>): ContentSettings<EnrichmentType>;
|
|
373
376
|
/**
|
|
@@ -13,7 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
|
-
var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_failedItems, _GenerateContext_foldedPaths, _GenerateContext_released, _GenerateContext_previews, _GenerateContext_captureChannel, _GenerateContext_enrichmentAudit, _GenerateContext_currentSubjectTrail, _GenerateContext_logsGeneratorLines, _GenerateContext_subjectCounts, _GenerateContext_reportSkippedEnrichment, _GenerateContext_logError, _GenerateContext_failItem, _GenerateContext_captureSubjectResult, _GenerateContext_runByGenerator, _GenerateContext_runBySubject, _GenerateContext_toGeneratorRuns, _GenerateContext_toSteps, _GenerateContext_release, _GenerateContext_affirmNotReleased, _GenerateContext_logGeneratorLine, _GenerateContext_runGenerator, _GenerateContext_schemaRefNames, _GenerateContext_subjectDefaults, _GenerateContext_runSubjects, _GenerateContext_addPreview, _GenerateContext_toContentSettingsExportPath, _GenerateContext_ejectedBySuffixedPath_get, _GenerateContext_ejectedBySuffixedPathCache, _GenerateContext_findContainer, _GenerateContext_toContainer;
|
|
16
|
+
var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_failedItems, _GenerateContext_foldedPaths, _GenerateContext_released, _GenerateContext_previews, _GenerateContext_captureChannel, _GenerateContext_enrichmentAudit, _GenerateContext_currentSubjectTrail, _GenerateContext_logsGeneratorLines, _GenerateContext_subjectCounts, _GenerateContext_reportSkippedEnrichment, _GenerateContext_logError, _GenerateContext_failItem, _GenerateContext_captureSubjectResult, _GenerateContext_runByGenerator, _GenerateContext_runBySubject, _GenerateContext_toGeneratorRuns, _GenerateContext_toSteps, _GenerateContext_release, _GenerateContext_affirmNotReleased, _GenerateContext_logGeneratorLine, _GenerateContext_runGenerator, _GenerateContext_schemaRefNames, _GenerateContext_subjectDefaults, _GenerateContext_runSubjects, _GenerateContext_addPreview, _GenerateContext_toContentSettingsExportPath, _GenerateContext_ejectedBySuffixedPath_get, _GenerateContext_ejectedBySuffixedPathCache, _GenerateContext_modelIdentities, _GenerateContext_findContainer, _GenerateContext_toContainer;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.GenerateContext = exports.toWebhookSource = exports.toOasOperationSource = exports.toModelSource = exports.toGqlOperationSource = void 0;
|
|
19
19
|
const normalizeWorkspacePath_js_1 = require("../helpers/normalizeWorkspacePath.js");
|
|
@@ -214,6 +214,21 @@ class GenerateContext {
|
|
|
214
214
|
/** The counts of the generator {@link toArtifacts} is running. */
|
|
215
215
|
_GenerateContext_subjectCounts.set(this, { offered: 0, transformed: 0, failed: 0 });
|
|
216
216
|
_GenerateContext_ejectedBySuffixedPathCache.set(this, void 0);
|
|
217
|
+
/** By a model projection class: the name and the export path of each model and variant it was asked for. */
|
|
218
|
+
_GenerateContext_modelIdentities.set(this, new Map()
|
|
219
|
+
/**
|
|
220
|
+
* Look up an already-registered file by path, or `undefined` if none
|
|
221
|
+
* exists. In a run with `onArtifact`, a lookup of a file that was given
|
|
222
|
+
* to the host throws. Neutral primitive: returns the abstract `FileBase` and never
|
|
223
|
+
* constructs anything, so a (future) language-owned `register` can ask
|
|
224
|
+
* "does this file exist yet?" without the engine knowing the language.
|
|
225
|
+
* To create on a miss, add a file your language constructs with
|
|
226
|
+
* {@link addFile} (`getFile(path) ?? addFile(lang.createFile(…))`).
|
|
227
|
+
*
|
|
228
|
+
* `filePath` may be in any spelling. It is normalized only when it is no
|
|
229
|
+
* key: a key is a normalized path. The file's own `path` is the key.
|
|
230
|
+
*/
|
|
231
|
+
);
|
|
217
232
|
this.logger = logger;
|
|
218
233
|
__classPrivateFieldSet(this, _GenerateContext_logsGeneratorLines, logsGeneratorLines, "f");
|
|
219
234
|
__classPrivateFieldSet(this, _GenerateContext_files, new Map(), "f");
|
|
@@ -884,17 +899,38 @@ class GenerateContext {
|
|
|
884
899
|
* `toEnrichments` against the given `ref` and `variant`. The full
|
|
885
900
|
* identifier is assembled through the projection's language
|
|
886
901
|
* (`lang.toIdentifier`).
|
|
902
|
+
*
|
|
903
|
+
* With no projection options, `toIdentifierName` and `toExportPath` are
|
|
904
|
+
* asked once in a run for each projection, ref and variant.
|
|
887
905
|
*/
|
|
888
906
|
toModelContentSettings(args) {
|
|
889
907
|
const { ref, projection, variant = Variant_js_1.DEFAULT_VARIANT } = args;
|
|
890
908
|
const options = (0, ProjectionOptions_js_1.readProjectionOptions)(args);
|
|
891
909
|
const enrichments = projection.toEnrichments({ ref, context: this, variant });
|
|
910
|
+
// A model is referred to many times in a run, and its name and its
|
|
911
|
+
// export path are the same each time: they come from the ref, the
|
|
912
|
+
// enrichments and the variant. With options they can differ, so only a
|
|
913
|
+
// call with no options is kept.
|
|
914
|
+
// Each part of the key can hold any character: the lengths keep them apart.
|
|
915
|
+
const key = options === undefined
|
|
916
|
+
? `${ref.refPath.length}:${ref.refName.length}:${ref.refPath}${ref.refName}${variant}`
|
|
917
|
+
: undefined;
|
|
918
|
+
const kept = key === undefined ? undefined : __classPrivateFieldGet(this, _GenerateContext_modelIdentities, "f").get(projection)?.get(key);
|
|
919
|
+
const identity = kept ?? {
|
|
920
|
+
name: projection.toIdentifierName({ ref, enrichments, variant, options }),
|
|
921
|
+
exportPath: __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toContentSettingsExportPath).call(this, projection.toExportPath({ ref, enrichments, variant, options }), projection.id)
|
|
922
|
+
};
|
|
923
|
+
if (key !== undefined && kept === undefined) {
|
|
924
|
+
const byKey = __classPrivateFieldGet(this, _GenerateContext_modelIdentities, "f").get(projection) ?? new Map();
|
|
925
|
+
byKey.set(key, identity);
|
|
926
|
+
__classPrivateFieldGet(this, _GenerateContext_modelIdentities, "f").set(projection, byKey);
|
|
927
|
+
}
|
|
892
928
|
return new ContentSettings_js_1.ContentSettings({
|
|
893
929
|
identifier: projection.lang.toIdentifier({
|
|
894
|
-
name:
|
|
930
|
+
name: identity.name,
|
|
895
931
|
...projection.toIdentifierType(ref, this)
|
|
896
932
|
}),
|
|
897
|
-
exportPath:
|
|
933
|
+
exportPath: identity.exportPath,
|
|
898
934
|
enrichments,
|
|
899
935
|
variant
|
|
900
936
|
});
|
|
@@ -965,7 +1001,7 @@ class GenerateContext {
|
|
|
965
1001
|
}
|
|
966
1002
|
}
|
|
967
1003
|
exports.GenerateContext = GenerateContext;
|
|
968
|
-
_GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakMap(), _GenerateContext_foldedPaths = new WeakMap(), _GenerateContext_released = new WeakMap(), _GenerateContext_previews = new WeakMap(), _GenerateContext_captureChannel = new WeakMap(), _GenerateContext_enrichmentAudit = new WeakMap(), _GenerateContext_currentSubjectTrail = new WeakMap(), _GenerateContext_logsGeneratorLines = new WeakMap(), _GenerateContext_subjectCounts = new WeakMap(), _GenerateContext_ejectedBySuffixedPathCache = new WeakMap(), _GenerateContext_instances = new WeakSet(), _GenerateContext_reportSkippedEnrichment = function _GenerateContext_reportSkippedEnrichment(block, variant, path) {
|
|
1004
|
+
_GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakMap(), _GenerateContext_foldedPaths = new WeakMap(), _GenerateContext_released = new WeakMap(), _GenerateContext_previews = new WeakMap(), _GenerateContext_captureChannel = new WeakMap(), _GenerateContext_enrichmentAudit = new WeakMap(), _GenerateContext_currentSubjectTrail = new WeakMap(), _GenerateContext_logsGeneratorLines = new WeakMap(), _GenerateContext_subjectCounts = new WeakMap(), _GenerateContext_ejectedBySuffixedPathCache = new WeakMap(), _GenerateContext_modelIdentities = new WeakMap(), _GenerateContext_instances = new WeakSet(), _GenerateContext_reportSkippedEnrichment = function _GenerateContext_reportSkippedEnrichment(block, variant, path) {
|
|
969
1005
|
if (!(0, EnrichmentAudit_js_1.hasVariantEnrichment)(block, variant))
|
|
970
1006
|
return;
|
|
971
1007
|
__classPrivateFieldGet(this, _GenerateContext_enrichmentAudit, "f").report({
|
|
@@ -44,7 +44,10 @@ type ToEnrichmentsArgs = {
|
|
|
44
44
|
*/
|
|
45
45
|
export type ModelProjectionBaseConfig<EnrichmentType = undefined, IdType extends IdentifierType = IdentifierType, ProjectionOptions = undefined> = {
|
|
46
46
|
id: string;
|
|
47
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Pure: the cache-key name. With no projection options,
|
|
49
|
+
* `toModelContentSettings` asks for it once in a run and keeps it.
|
|
50
|
+
*/
|
|
48
51
|
toIdentifierName: (args: ToModelIdentifierNameArgs<EnrichmentType, ProjectionOptions>) => string;
|
|
49
52
|
/**
|
|
50
53
|
* Context-aware, overridable: the non-`name` parts of the identifier
|