@skmtc/core 0.47.4 → 0.49.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 +1 -1
- package/esm/context/CoreContext.js +6 -2
- package/esm/context/GenerateContext.d.ts +15 -4
- package/esm/context/GenerateContext.js +40 -34
- package/esm/context/ParseContext.d.ts +4 -4
- package/esm/context/ParseContext.js +6 -6
- package/esm/context/RenderContext.d.ts +3 -2
- package/esm/context/RenderContext.js +6 -5
- package/esm/context/generateTypes.d.ts +10 -6
- package/esm/context/tryParseAt.d.ts +1 -1
- package/esm/context/tryParseAt.js +1 -1
- package/esm/dsl/ContentSettings.d.ts +17 -12
- package/esm/dsl/ContentSettings.js +13 -9
- package/esm/dsl/Inserted.d.ts +4 -3
- package/esm/dsl/Inserted.js +2 -2
- package/esm/dsl/PendingDefinition.d.ts +3 -2
- package/esm/dsl/driverFiles.d.ts +46 -0
- package/esm/dsl/driverFiles.js +31 -0
- package/esm/dsl/model/ModelDriver.d.ts +5 -7
- package/esm/dsl/model/ModelDriver.js +12 -29
- package/esm/dsl/operation/gql/GqlOperationDriver.d.ts +1 -1
- package/esm/dsl/operation/gql/GqlOperationDriver.js +15 -12
- package/esm/dsl/operation/oas/OasOperationDriver.d.ts +1 -1
- package/esm/dsl/operation/oas/OasOperationDriver.js +11 -14
- package/esm/dsl/webhook/WebhookDriver.d.ts +1 -1
- package/esm/dsl/webhook/WebhookDriver.js +15 -12
- package/esm/enrichments/EnrichmentAudit.d.ts +1 -1
- package/esm/enrichments/EnrichmentWarning.d.ts +1 -1
- package/esm/enrichments/findUnknownKeys.d.ts +1 -1
- package/esm/enrichments/findUnknownKeys.js +1 -1
- package/esm/enrichments/parseEnrichmentUmbrella.d.ts +1 -1
- package/esm/enrichments/parseEnrichmentUmbrella.js +1 -1
- package/esm/enrichments/parseEnrichmentValue.d.ts +2 -2
- package/esm/enrichments/parseEnrichmentValue.js +2 -2
- package/esm/enrichments/readEnrichments.d.ts +4 -4
- package/esm/enrichments/readEnrichments.js +4 -4
- package/esm/enrichments/validateConfig.d.ts +1 -1
- package/esm/helpers/applyGeneratedSuffix.d.ts +1 -1
- package/esm/helpers/applyGeneratedSuffix.js +1 -1
- package/esm/helpers/getByWorkspacePath.d.ts +9 -0
- package/esm/helpers/getByWorkspacePath.js +10 -0
- package/esm/helpers/normalizeWorkspacePath.d.ts +26 -3
- package/esm/helpers/normalizeWorkspacePath.js +17 -2
- package/esm/oas/array/Array.d.ts +2 -2
- package/esm/oas/array/Array.js +2 -2
- package/esm/oas/boolean/Boolean.d.ts +2 -2
- package/esm/oas/boolean/Boolean.js +2 -2
- package/esm/oas/integer/Integer.d.ts +2 -2
- package/esm/oas/integer/Integer.js +2 -2
- package/esm/oas/intersection/Intersection.d.ts +3 -3
- package/esm/oas/intersection/Intersection.js +3 -3
- package/esm/oas/number/Number.d.ts +2 -2
- package/esm/oas/number/Number.js +2 -2
- package/esm/oas/object/Object.d.ts +2 -2
- package/esm/oas/object/Object.js +2 -2
- package/esm/oas/operation/Operation.d.ts +1 -1
- package/esm/oas/operation/Operation.js +1 -1
- package/esm/oas/operation/toEffectiveParameters.d.ts +2 -2
- package/esm/oas/operation/toEffectiveParameters.js +2 -2
- package/esm/oas/ref/DanglingRefError.d.ts +1 -1
- package/esm/oas/ref/DanglingRefError.js +1 -1
- package/esm/oas/ref/Ref.d.ts +2 -2
- package/esm/oas/ref/Ref.js +2 -2
- package/esm/oas/string/String.d.ts +2 -2
- package/esm/oas/string/String.js +2 -2
- package/esm/oas/union/Union.d.ts +3 -3
- package/esm/oas/union/Union.js +3 -3
- package/esm/oas/unknown/Unknown.d.ts +2 -2
- package/esm/oas/unknown/Unknown.js +2 -2
- package/esm/parse/allOfSystem.d.ts +4 -4
- package/esm/parse/allOfSystem.js +2 -2
- package/esm/parse/anyOfSystem.d.ts +5 -5
- package/esm/parse/anyOfSystem.js +4 -4
- package/esm/parse/keptRefs.d.ts +2 -2
- package/esm/parse/v3-0/_merge-all-of/merge-union.d.ts +1 -1
- package/esm/parse/v3-0/_merge-all-of/merge-union.js +3 -3
- package/esm/parse/v3-0/_merge-all-of/merge.js +2 -2
- package/esm/parse/v3-0/_merge-all-of/types.d.ts +4 -4
- package/esm/parse/v3-0/ref/toRefV31.js +1 -1
- package/esm/parse/v3-0/schema/toSchemasV3.js +3 -3
- package/esm/parse/v3-1/_merge-all-of/merge-union.d.ts +1 -1
- package/esm/parse/v3-1/_merge-all-of/merge-union.js +3 -3
- package/esm/parse/v3-1/_merge-all-of/merge.js +2 -2
- package/esm/parse/v3-1/_merge-all-of/types.d.ts +4 -4
- package/esm/parse/v3-1/ref/toRefV31.js +1 -1
- package/esm/parse/v3-1/schema/toSchemasV3.js +3 -3
- package/esm/parse/v3-2/_merge-all-of/merge-union.d.ts +1 -1
- package/esm/parse/v3-2/_merge-all-of/merge-union.js +3 -3
- package/esm/parse/v3-2/_merge-all-of/merge.js +2 -2
- package/esm/parse/v3-2/_merge-all-of/types.d.ts +4 -4
- package/esm/parse/v3-2/ref/toRefV31.js +1 -1
- package/esm/parse/v3-2/schema/toSchemasV3.js +3 -3
- package/esm/run/toEnrichmentDefaults.d.ts +1 -1
- package/esm/run/toEnrichmentDefaults.js +1 -1
- package/esm/types/EnrichmentDefaults.d.ts +1 -1
- package/esm/types/EnrichmentDefaults.js +1 -1
- package/esm/types/Enrichments.d.ts +1 -1
- package/esm/types/Manifest.d.ts +1 -1
- package/esm/types/ModuleSelect.d.ts +1 -1
- package/esm/types/Settings.d.ts +29 -11
- package/esm/types/Settings.js +13 -6
- package/esm/types/Variant.d.ts +3 -3
- package/esm/types/Variant.js +3 -3
- package/package.json +1 -1
- package/script/context/CoreContext.d.ts +1 -1
- package/script/context/CoreContext.js +6 -2
- package/script/context/GenerateContext.d.ts +15 -4
- package/script/context/GenerateContext.js +38 -32
- package/script/context/ParseContext.d.ts +4 -4
- package/script/context/ParseContext.js +6 -6
- package/script/context/RenderContext.d.ts +3 -2
- package/script/context/RenderContext.js +6 -5
- package/script/context/generateTypes.d.ts +10 -6
- package/script/context/tryParseAt.d.ts +1 -1
- package/script/context/tryParseAt.js +1 -1
- package/script/dsl/ContentSettings.d.ts +17 -12
- package/script/dsl/ContentSettings.js +13 -9
- package/script/dsl/Inserted.d.ts +4 -3
- package/script/dsl/Inserted.js +2 -2
- package/script/dsl/PendingDefinition.d.ts +3 -2
- package/script/dsl/driverFiles.d.ts +46 -0
- package/script/dsl/driverFiles.js +38 -0
- package/script/dsl/model/ModelDriver.d.ts +5 -7
- package/script/dsl/model/ModelDriver.js +12 -29
- package/script/dsl/operation/gql/GqlOperationDriver.d.ts +1 -1
- package/script/dsl/operation/gql/GqlOperationDriver.js +15 -12
- package/script/dsl/operation/oas/OasOperationDriver.d.ts +1 -1
- package/script/dsl/operation/oas/OasOperationDriver.js +11 -14
- package/script/dsl/webhook/WebhookDriver.d.ts +1 -1
- package/script/dsl/webhook/WebhookDriver.js +15 -12
- package/script/enrichments/EnrichmentAudit.d.ts +1 -1
- package/script/enrichments/EnrichmentWarning.d.ts +1 -1
- package/script/enrichments/findUnknownKeys.d.ts +1 -1
- package/script/enrichments/findUnknownKeys.js +1 -1
- package/script/enrichments/parseEnrichmentUmbrella.d.ts +1 -1
- package/script/enrichments/parseEnrichmentUmbrella.js +1 -1
- package/script/enrichments/parseEnrichmentValue.d.ts +2 -2
- package/script/enrichments/parseEnrichmentValue.js +2 -2
- package/script/enrichments/readEnrichments.d.ts +4 -4
- package/script/enrichments/readEnrichments.js +4 -4
- package/script/enrichments/validateConfig.d.ts +1 -1
- package/script/helpers/applyGeneratedSuffix.d.ts +1 -1
- package/script/helpers/applyGeneratedSuffix.js +1 -1
- package/script/helpers/getByWorkspacePath.d.ts +9 -0
- package/script/helpers/getByWorkspacePath.js +14 -0
- package/script/helpers/normalizeWorkspacePath.d.ts +26 -3
- package/script/helpers/normalizeWorkspacePath.js +19 -3
- package/script/oas/array/Array.d.ts +2 -2
- package/script/oas/array/Array.js +2 -2
- package/script/oas/boolean/Boolean.d.ts +2 -2
- package/script/oas/boolean/Boolean.js +2 -2
- package/script/oas/integer/Integer.d.ts +2 -2
- package/script/oas/integer/Integer.js +2 -2
- package/script/oas/intersection/Intersection.d.ts +3 -3
- package/script/oas/intersection/Intersection.js +3 -3
- package/script/oas/number/Number.d.ts +2 -2
- package/script/oas/number/Number.js +2 -2
- package/script/oas/object/Object.d.ts +2 -2
- package/script/oas/object/Object.js +2 -2
- package/script/oas/operation/Operation.d.ts +1 -1
- package/script/oas/operation/Operation.js +1 -1
- package/script/oas/operation/toEffectiveParameters.d.ts +2 -2
- package/script/oas/operation/toEffectiveParameters.js +2 -2
- package/script/oas/ref/DanglingRefError.d.ts +1 -1
- package/script/oas/ref/DanglingRefError.js +1 -1
- package/script/oas/ref/Ref.d.ts +2 -2
- package/script/oas/ref/Ref.js +2 -2
- package/script/oas/string/String.d.ts +2 -2
- package/script/oas/string/String.js +2 -2
- package/script/oas/union/Union.d.ts +3 -3
- package/script/oas/union/Union.js +3 -3
- package/script/oas/unknown/Unknown.d.ts +2 -2
- package/script/oas/unknown/Unknown.js +2 -2
- package/script/parse/allOfSystem.d.ts +4 -4
- package/script/parse/allOfSystem.js +2 -2
- package/script/parse/anyOfSystem.d.ts +5 -5
- package/script/parse/anyOfSystem.js +4 -4
- package/script/parse/keptRefs.d.ts +2 -2
- package/script/parse/v3-0/_merge-all-of/merge-union.d.ts +1 -1
- package/script/parse/v3-0/_merge-all-of/merge-union.js +3 -3
- package/script/parse/v3-0/_merge-all-of/merge.js +2 -2
- package/script/parse/v3-0/_merge-all-of/types.d.ts +4 -4
- package/script/parse/v3-0/ref/toRefV31.js +1 -1
- package/script/parse/v3-0/schema/toSchemasV3.js +3 -3
- package/script/parse/v3-1/_merge-all-of/merge-union.d.ts +1 -1
- package/script/parse/v3-1/_merge-all-of/merge-union.js +3 -3
- package/script/parse/v3-1/_merge-all-of/merge.js +2 -2
- package/script/parse/v3-1/_merge-all-of/types.d.ts +4 -4
- package/script/parse/v3-1/ref/toRefV31.js +1 -1
- package/script/parse/v3-1/schema/toSchemasV3.js +3 -3
- package/script/parse/v3-2/_merge-all-of/merge-union.d.ts +1 -1
- package/script/parse/v3-2/_merge-all-of/merge-union.js +3 -3
- package/script/parse/v3-2/_merge-all-of/merge.js +2 -2
- package/script/parse/v3-2/_merge-all-of/types.d.ts +4 -4
- package/script/parse/v3-2/ref/toRefV31.js +1 -1
- package/script/parse/v3-2/schema/toSchemasV3.js +3 -3
- package/script/run/toEnrichmentDefaults.d.ts +1 -1
- package/script/run/toEnrichmentDefaults.js +1 -1
- package/script/types/EnrichmentDefaults.d.ts +1 -1
- package/script/types/EnrichmentDefaults.js +1 -1
- package/script/types/Enrichments.d.ts +1 -1
- package/script/types/Manifest.d.ts +1 -1
- package/script/types/ModuleSelect.d.ts +1 -1
- package/script/types/Settings.d.ts +29 -11
- package/script/types/Settings.js +14 -7
- package/script/types/Variant.d.ts +3 -3
- package/script/types/Variant.js +3 -3
|
@@ -304,7 +304,7 @@ export declare class CoreContext {
|
|
|
304
304
|
* Seed-values sibling of {@link toSupportedSubjects}: parse the document, then
|
|
305
305
|
* call each generator's `toEnrichmentDefaults` over its supported subjects —
|
|
306
306
|
* no transform, no render. Returns the default enrichment values keyed by the
|
|
307
|
-
* `
|
|
307
|
+
* `skmtc.config.json#settings.enrichments` routing, plus parse issues. Fails open
|
|
308
308
|
* like {@link toArtifacts}: a bad schema surfaces as a `parseIssue` and the
|
|
309
309
|
* defaults map is returned empty.
|
|
310
310
|
*/
|
|
@@ -426,7 +426,7 @@ export class CoreContext {
|
|
|
426
426
|
* Seed-values sibling of {@link toSupportedSubjects}: parse the document, then
|
|
427
427
|
* call each generator's `toEnrichmentDefaults` over its supported subjects —
|
|
428
428
|
* no transform, no render. Returns the default enrichment values keyed by the
|
|
429
|
-
* `
|
|
429
|
+
* `skmtc.config.json#settings.enrichments` routing, plus parse issues. Fails open
|
|
430
430
|
* like {@link toArtifacts}: a bad schema surfaces as a `parseIssue` and the
|
|
431
431
|
* defaults map is returned empty.
|
|
432
432
|
*/
|
|
@@ -536,11 +536,15 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
|
|
|
536
536
|
}
|
|
537
537
|
}
|
|
538
538
|
}, _CoreContext_setupParsePhase = function _CoreContext_setupParsePhase(input, settings) {
|
|
539
|
+
if (settings?.parse && settings.system) {
|
|
540
|
+
this.logger.warn('settings.parse and settings.system are both set: settings.parse is used and settings.system is ignored. ' +
|
|
541
|
+
'settings.system is the deprecated name of settings.parse; remove it.');
|
|
542
|
+
}
|
|
539
543
|
const parseContext = new ParseContext({
|
|
540
544
|
input,
|
|
541
545
|
logger: this.logger,
|
|
542
546
|
silent: this.silent,
|
|
543
|
-
system: settings?.system
|
|
547
|
+
system: settings?.parse ?? settings?.system
|
|
544
548
|
});
|
|
545
549
|
return { type: 'parse', context: parseContext };
|
|
546
550
|
}, _CoreContext_setupGeneratePhase = function _CoreContext_setupGeneratePhase({ document, settings, toGeneratorConfigMap, captureChannel }) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type WorkspacePath } from '../helpers/normalizeWorkspacePath.js';
|
|
1
2
|
import type { DefinitionBase } from '../dsl/Definition.js';
|
|
2
3
|
import type { PendingDefinition } from '../dsl/PendingDefinition.js';
|
|
3
4
|
import type { OasSchema } from '../oas/schema/Schema.js';
|
|
@@ -201,7 +202,7 @@ export declare class GenerateContext implements GenerateContextType {
|
|
|
201
202
|
* document — the *values* counterpart of {@link toSupportedSubjects}. For
|
|
202
203
|
* every generator that advertises `toEnrichmentDefaults`, calls it over the
|
|
203
204
|
* subjects the generator supports and keeps the non-`undefined` subject-scope
|
|
204
|
-
* leaves, keyed by the `
|
|
205
|
+
* leaves, keyed by the `skmtc.config.json#settings.enrichments` routing:
|
|
205
206
|
* `[id][path][method]['main']` for operations, `[id][refName]['main']` for
|
|
206
207
|
* models. Seeding targets the `'main'` variant; a generator that advertises
|
|
207
208
|
* no defaults (or whose every subject returns `undefined`) is omitted.
|
|
@@ -216,10 +217,19 @@ export declare class GenerateContext implements GenerateContextType {
|
|
|
216
217
|
* exists. Neutral primitive: returns the abstract `FileBase` and never
|
|
217
218
|
* constructs anything, so a (future) language-owned `register` can ask
|
|
218
219
|
* "does this file exist yet?" without the engine knowing the language.
|
|
219
|
-
* To create
|
|
220
|
-
*
|
|
220
|
+
* To create on a miss, add a file your language constructs with
|
|
221
|
+
* {@link addFile} (`getFile(path) ?? addFile(lang.createFile(…))`).
|
|
222
|
+
*
|
|
223
|
+
* `filePath` may be in any spelling. It is normalized only when it is no
|
|
224
|
+
* key: a key is a normalized path. The file's own `path` is the key.
|
|
221
225
|
*/
|
|
222
226
|
getFile(filePath: string): FileBase | undefined;
|
|
227
|
+
/**
|
|
228
|
+
* The file whose normalized path is `path`, or `undefined`. A normalized
|
|
229
|
+
* path is a key as it is, so a miss is not normalized again, as it is in
|
|
230
|
+
* {@link getFile}: there is no file there in any spelling.
|
|
231
|
+
*/
|
|
232
|
+
getFileByWorkspacePath(path: WorkspacePath): FileBase | undefined;
|
|
223
233
|
/**
|
|
224
234
|
* Read-only view of every file generated so far, keyed by (normalized)
|
|
225
235
|
* export path. An **inspection / tooling** seam — NOT a coordination
|
|
@@ -235,7 +245,8 @@ export declare class GenerateContext implements GenerateContextType {
|
|
|
235
245
|
* Store a language-constructed file. The engine never constructs a
|
|
236
246
|
* concrete (language) `File`; the language's `register` builds its own
|
|
237
247
|
* `FileBase` subclass and hands it in here. Throws if a file already
|
|
238
|
-
* exists at the (normalized) path.
|
|
248
|
+
* exists at the (normalized) path. Sets `file.path` to that normalized
|
|
249
|
+
* path, the file's key. Returns the stored file, so
|
|
239
250
|
* get-or-create is a single expression at the call site
|
|
240
251
|
* (`context.getFile(path) ?? context.addFile(new KtFile({ … }))`).
|
|
241
252
|
*/
|
|
@@ -10,8 +10,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_failedItems, _GenerateContext_foldedPaths, _GenerateContext_previews, _GenerateContext_captureChannel, _GenerateContext_enrichmentAudit, _GenerateContext_currentSubjectTrail, _GenerateContext_reportSkippedEnrichment, _GenerateContext_logError, _GenerateContext_failItem, _GenerateContext_schemaRefNames, _GenerateContext_subjectDefaults, _GenerateContext_runOasOperationGenerator, _GenerateContext_runWebhookGenerator, _GenerateContext_runGqlOperationGenerator, _GenerateContext_runModelGenerator, _GenerateContext_addPreview, _GenerateContext_toContentSettingsExportPath, _GenerateContext_ejectedBySuffixedPath_get, _GenerateContext_ejectedBySuffixedPathCache, _GenerateContext_findContainer, _GenerateContext_toContainer;
|
|
13
|
-
import { normalizeWorkspacePath } from '../helpers/normalizeWorkspacePath.js';
|
|
14
|
-
import {
|
|
13
|
+
import { applyGeneratedSuffixToWorkspacePath, normalizeWorkspacePath } from '../helpers/normalizeWorkspacePath.js';
|
|
14
|
+
import { getByWorkspacePath } from '../helpers/getByWorkspacePath.js';
|
|
15
|
+
import { DEFAULT_GENERATED_SUFFIX } from '../helpers/applyGeneratedSuffix.js';
|
|
15
16
|
import { DanglingRefError } from '../oas/ref/DanglingRefError.js';
|
|
16
17
|
import { isDefaultRefPath, isRemoteRefPath, toModelKey, toRefPointer, toSchemaComponentRef } from '../helpers/refFns.js';
|
|
17
18
|
import { isMethod } from '../types/Method.js';
|
|
@@ -381,7 +382,7 @@ export class GenerateContext {
|
|
|
381
382
|
* document — the *values* counterpart of {@link toSupportedSubjects}. For
|
|
382
383
|
* every generator that advertises `toEnrichmentDefaults`, calls it over the
|
|
383
384
|
* subjects the generator supports and keeps the non-`undefined` subject-scope
|
|
384
|
-
* leaves, keyed by the `
|
|
385
|
+
* leaves, keyed by the `skmtc.config.json#settings.enrichments` routing:
|
|
385
386
|
* `[id][path][method]['main']` for operations, `[id][refName]['main']` for
|
|
386
387
|
* models. Seeding targets the `'main'` variant; a generator that advertises
|
|
387
388
|
* no defaults (or whose every subject returns `undefined`) is omitted.
|
|
@@ -477,11 +478,22 @@ export class GenerateContext {
|
|
|
477
478
|
* exists. Neutral primitive: returns the abstract `FileBase` and never
|
|
478
479
|
* constructs anything, so a (future) language-owned `register` can ask
|
|
479
480
|
* "does this file exist yet?" without the engine knowing the language.
|
|
480
|
-
* To create
|
|
481
|
-
*
|
|
481
|
+
* To create on a miss, add a file your language constructs with
|
|
482
|
+
* {@link addFile} (`getFile(path) ?? addFile(lang.createFile(…))`).
|
|
483
|
+
*
|
|
484
|
+
* `filePath` may be in any spelling. It is normalized only when it is no
|
|
485
|
+
* key: a key is a normalized path. The file's own `path` is the key.
|
|
482
486
|
*/
|
|
483
487
|
getFile(filePath) {
|
|
484
|
-
return __classPrivateFieldGet(this, _GenerateContext_files, "f")
|
|
488
|
+
return getByWorkspacePath(__classPrivateFieldGet(this, _GenerateContext_files, "f"), filePath);
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* The file whose normalized path is `path`, or `undefined`. A normalized
|
|
492
|
+
* path is a key as it is, so a miss is not normalized again, as it is in
|
|
493
|
+
* {@link getFile}: there is no file there in any spelling.
|
|
494
|
+
*/
|
|
495
|
+
getFileByWorkspacePath(path) {
|
|
496
|
+
return __classPrivateFieldGet(this, _GenerateContext_files, "f").get(path);
|
|
485
497
|
}
|
|
486
498
|
/**
|
|
487
499
|
* Read-only view of every file generated so far, keyed by (normalized)
|
|
@@ -500,7 +512,8 @@ export class GenerateContext {
|
|
|
500
512
|
* Store a language-constructed file. The engine never constructs a
|
|
501
513
|
* concrete (language) `File`; the language's `register` builds its own
|
|
502
514
|
* `FileBase` subclass and hands it in here. Throws if a file already
|
|
503
|
-
* exists at the (normalized) path.
|
|
515
|
+
* exists at the (normalized) path. Sets `file.path` to that normalized
|
|
516
|
+
* path, the file's key. Returns the stored file, so
|
|
504
517
|
* get-or-create is a single expression at the call site
|
|
505
518
|
* (`context.getFile(path) ?? context.addFile(new KtFile({ … }))`).
|
|
506
519
|
*/
|
|
@@ -517,6 +530,7 @@ export class GenerateContext {
|
|
|
517
530
|
if (existingPath !== undefined) {
|
|
518
531
|
throw new Error(`File '${normalizedPath}' differs from '${existingPath}' only in case. On a file system that ignores case, as macOS's and Windows' do by default, they are one file.`);
|
|
519
532
|
}
|
|
533
|
+
file.path = normalizedPath;
|
|
520
534
|
__classPrivateFieldGet(this, _GenerateContext_files, "f").set(normalizedPath, file);
|
|
521
535
|
__classPrivateFieldGet(this, _GenerateContext_foldedPaths, "f").set(foldedPath, normalizedPath);
|
|
522
536
|
return file;
|
|
@@ -528,12 +542,8 @@ export class GenerateContext {
|
|
|
528
542
|
* @param args - Registration arguments with destination path and JSON content
|
|
529
543
|
*/
|
|
530
544
|
registerJson({ destinationPath, json }) {
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
if (!currentFile) {
|
|
534
|
-
currentFile = new JsonFile({ path: normalizedPath, content: {} });
|
|
535
|
-
this.addFile(currentFile);
|
|
536
|
-
}
|
|
545
|
+
const currentFile = this.getFile(destinationPath) ??
|
|
546
|
+
this.addFile(new JsonFile({ path: normalizeWorkspacePath(destinationPath), content: {} }));
|
|
537
547
|
invariant(currentFile instanceof JsonFile, `File at "${destinationPath}" is not a "JsonFile" type`);
|
|
538
548
|
currentFile.content = json;
|
|
539
549
|
}
|
|
@@ -547,12 +557,8 @@ export class GenerateContext {
|
|
|
547
557
|
* @experimental This method is experimental and may change in future versions
|
|
548
558
|
*/
|
|
549
559
|
registerMarkdown({ destinationPath, markdown }) {
|
|
550
|
-
const
|
|
551
|
-
|
|
552
|
-
if (!currentFile) {
|
|
553
|
-
currentFile = new MarkdownFile({ path: normalizedPath, content: '' });
|
|
554
|
-
this.addFile(currentFile);
|
|
555
|
-
}
|
|
560
|
+
const currentFile = this.getFile(destinationPath) ??
|
|
561
|
+
this.addFile(new MarkdownFile({ path: normalizeWorkspacePath(destinationPath), content: '' }));
|
|
556
562
|
invariant(currentFile instanceof MarkdownFile, `File at "${destinationPath}" is not a "MarkdownFile" type`);
|
|
557
563
|
currentFile.content = markdown;
|
|
558
564
|
}
|
|
@@ -568,14 +574,13 @@ export class GenerateContext {
|
|
|
568
574
|
* @mutates this.files
|
|
569
575
|
*/
|
|
570
576
|
register({ imports = [], reExports = [], definitions, custom, destinationPath, into }) {
|
|
571
|
-
const
|
|
572
|
-
const currentFile = this.getFile(normalizedPath);
|
|
577
|
+
const currentFile = this.getFile(destinationPath);
|
|
573
578
|
// `register` never creates files — it speaks pure data and the engine
|
|
574
579
|
// never names a file class. Callers pre-create the destination file
|
|
575
580
|
// through their language (the lang package's register function, the
|
|
576
581
|
// Drivers' ensureFile); reaching a file-miss here is a bug at the
|
|
577
582
|
// caller.
|
|
578
|
-
invariant(currentFile, `Cannot register into '${
|
|
583
|
+
invariant(currentFile, () => `Cannot register into '${normalizeWorkspacePath(destinationPath)}' — the file does not exist. ` +
|
|
579
584
|
`Pre-create it through your lang (its register function does this).`);
|
|
580
585
|
// `custom` is language-neutral — it lives on `FileBase`, so any file
|
|
581
586
|
// (code or not, e.g. a JSON/Markdown file) can receive it. Last
|
|
@@ -597,7 +602,7 @@ export class GenerateContext {
|
|
|
597
602
|
const placesADefinition = definitions?.some(definition => definition !== undefined) ?? false;
|
|
598
603
|
const place = into === undefined || !placesADefinition
|
|
599
604
|
? currentFile
|
|
600
|
-
: __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toContainer).call(this, currentFile, into,
|
|
605
|
+
: __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toContainer).call(this, currentFile, into, currentFile.path);
|
|
601
606
|
definitions?.forEach(definition => {
|
|
602
607
|
if (definition) {
|
|
603
608
|
place.addDefinition(definition);
|
|
@@ -673,17 +678,18 @@ export class GenerateContext {
|
|
|
673
678
|
// the use site (same ephemeral read the Drivers make) — pre-creates
|
|
674
679
|
// the destination file caller-side, and stores via the pure-data
|
|
675
680
|
// `register`.
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
681
|
+
const file = this.getFile(destinationPath) ??
|
|
682
|
+
this.addFile(projection.lang.createFile({
|
|
683
|
+
path: normalizeWorkspacePath(destinationPath),
|
|
684
|
+
settings: this.settings
|
|
685
|
+
}));
|
|
680
686
|
const definition = projection.lang.toDefinition({
|
|
681
687
|
context: this,
|
|
682
688
|
identifier: projection.createIdentifier(fallbackName),
|
|
683
689
|
value,
|
|
684
690
|
noExport: insertOptions.noExport
|
|
685
691
|
});
|
|
686
|
-
this.register({ definitions: [definition], destinationPath:
|
|
692
|
+
this.register({ definitions: [definition], destinationPath: file.path });
|
|
687
693
|
// @TODO Using mapped types would help avoid generics casting
|
|
688
694
|
return definition;
|
|
689
695
|
}
|
|
@@ -760,10 +766,10 @@ export class GenerateContext {
|
|
|
760
766
|
}),
|
|
761
767
|
...args.projection.toIdentifierType(args.operation, this)
|
|
762
768
|
}),
|
|
763
|
-
|
|
764
|
-
//
|
|
765
|
-
args.exportPath ??
|
|
766
|
-
args.projection.toExportPath({
|
|
769
|
+
// A member has no file of its own: the Driver passes its container's,
|
|
770
|
+
// which is a finished export path (normalized, suffixed, ejected).
|
|
771
|
+
exportPath: args.exportPath ??
|
|
772
|
+
__classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toContentSettingsExportPath).call(this, args.projection.toExportPath({
|
|
767
773
|
operation: args.operation,
|
|
768
774
|
enrichments,
|
|
769
775
|
variant,
|
|
@@ -1235,14 +1241,14 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_failedItems = new WeakM
|
|
|
1235
1241
|
source
|
|
1236
1242
|
};
|
|
1237
1243
|
}, _GenerateContext_toContentSettingsExportPath = function _GenerateContext_toContentSettingsExportPath(exportPath, generatorId) {
|
|
1238
|
-
const suffixed =
|
|
1244
|
+
const suffixed = applyGeneratedSuffixToWorkspacePath(normalizeWorkspacePath(exportPath, { generatorId }), this.settings?.generatedSuffix ?? DEFAULT_GENERATED_SUFFIX, { generatorId });
|
|
1239
1245
|
return __classPrivateFieldGet(this, _GenerateContext_instances, "a", _GenerateContext_ejectedBySuffixedPath_get).get(suffixed) ?? suffixed;
|
|
1240
1246
|
}, _GenerateContext_ejectedBySuffixedPath_get = function _GenerateContext_ejectedBySuffixedPath_get() {
|
|
1241
1247
|
if (__classPrivateFieldGet(this, _GenerateContext_ejectedBySuffixedPathCache, "f") === undefined) {
|
|
1242
1248
|
const suffix = this.settings?.generatedSuffix ?? DEFAULT_GENERATED_SUFFIX;
|
|
1243
1249
|
__classPrivateFieldSet(this, _GenerateContext_ejectedBySuffixedPathCache, new Map((this.settings?.ejected ?? []).map(ejectedPath => {
|
|
1244
1250
|
const normalized = normalizeWorkspacePath(ejectedPath);
|
|
1245
|
-
return [
|
|
1251
|
+
return [applyGeneratedSuffixToWorkspacePath(normalized, suffix), normalized];
|
|
1246
1252
|
})), "f");
|
|
1247
1253
|
}
|
|
1248
1254
|
return __classPrivateFieldGet(this, _GenerateContext_ejectedBySuffixedPathCache, "f");
|
|
@@ -72,7 +72,7 @@ type ConstructorArgs = {
|
|
|
72
72
|
options?: {
|
|
73
73
|
gql?: GqlParseOptions;
|
|
74
74
|
};
|
|
75
|
-
/** `
|
|
75
|
+
/** `skmtc.config.json#settings.parse`: how the OpenAPI parsers treat what they cannot read faithfully. */
|
|
76
76
|
system?: SystemSettings;
|
|
77
77
|
};
|
|
78
78
|
export declare class ParseContext {
|
|
@@ -90,7 +90,7 @@ export declare class ParseContext {
|
|
|
90
90
|
currentStackTrail: StackTrail | undefined;
|
|
91
91
|
/**
|
|
92
92
|
* How the OpenAPI parsers treat what they cannot read faithfully
|
|
93
|
-
* (`
|
|
93
|
+
* (`skmtc.config.json#settings.parse`). Each setting left out is `strict`.
|
|
94
94
|
*/
|
|
95
95
|
system: SystemSettings;
|
|
96
96
|
constructor({ input, logger, silent, options, system }: ConstructorArgs);
|
|
@@ -102,7 +102,7 @@ export declare class ParseContext {
|
|
|
102
102
|
get oasDocument(): OasDocument;
|
|
103
103
|
/** OAS-only accessor; symmetric reason to {@link oasDocument}. */
|
|
104
104
|
get documentObject(): OpenAPIV3.Document;
|
|
105
|
-
/** The refs of the document that a merge keeps as refs (`
|
|
105
|
+
/** The refs of the document that a merge keeps as refs (`parse.intersections`); `undefined` under `merge`. */
|
|
106
106
|
get keptRefs(): KeptRefs | undefined;
|
|
107
107
|
/** GQL-only accessor; throws if called on an OAS context. */
|
|
108
108
|
get schema(): GraphQLSchema;
|
|
@@ -180,7 +180,7 @@ export declare class ParseContext {
|
|
|
180
180
|
* What a merge reads in place of a `$ref` that names nothing: an `allOf`
|
|
181
181
|
* member, or in a `oneOf` or `anyOf`, a member's own `allOf` member or a
|
|
182
182
|
* member merged with the keywords beside the union. When
|
|
183
|
-
* `
|
|
183
|
+
* `parse.danglingRefs` lists `allOfMember`, it is `{}`, which
|
|
184
184
|
* adds nothing to the merge (`A & unknown` is `A`), and a `DANGLING_REF`
|
|
185
185
|
* warning at `stackTrail`: the model has no properties from that member.
|
|
186
186
|
* Otherwise it throws `DanglingRefError`, and what holds the `allOf` is
|
|
@@ -147,7 +147,7 @@ export class ParseContext {
|
|
|
147
147
|
});
|
|
148
148
|
/**
|
|
149
149
|
* How the OpenAPI parsers treat what they cannot read faithfully
|
|
150
|
-
* (`
|
|
150
|
+
* (`skmtc.config.json#settings.parse`). Each setting left out is `strict`.
|
|
151
151
|
*/
|
|
152
152
|
Object.defineProperty(this, "system", {
|
|
153
153
|
enumerable: true,
|
|
@@ -239,7 +239,7 @@ export class ParseContext {
|
|
|
239
239
|
}
|
|
240
240
|
return this.protocol.documentObject;
|
|
241
241
|
}
|
|
242
|
-
/** The refs of the document that a merge keeps as refs (`
|
|
242
|
+
/** The refs of the document that a merge keeps as refs (`parse.intersections`); `undefined` under `merge`. */
|
|
243
243
|
get keptRefs() {
|
|
244
244
|
__classPrivateFieldSet(this, _ParseContext_keptRefs, __classPrivateFieldGet(this, _ParseContext_keptRefs, "f") ?? {
|
|
245
245
|
value: toKeptRefs({ documentObject: this.documentObject, setting: this.system.intersections })
|
|
@@ -458,7 +458,7 @@ export class ParseContext {
|
|
|
458
458
|
* What a merge reads in place of a `$ref` that names nothing: an `allOf`
|
|
459
459
|
* member, or in a `oneOf` or `anyOf`, a member's own `allOf` member or a
|
|
460
460
|
* member merged with the keywords beside the union. When
|
|
461
|
-
* `
|
|
461
|
+
* `parse.danglingRefs` lists `allOfMember`, it is `{}`, which
|
|
462
462
|
* adds nothing to the merge (`A & unknown` is `A`), and a `DANGLING_REF`
|
|
463
463
|
* warning at `stackTrail`: the model has no properties from that member.
|
|
464
464
|
* Otherwise it throws `DanglingRefError`, and what holds the `allOf` is
|
|
@@ -471,7 +471,7 @@ export class ParseContext {
|
|
|
471
471
|
}
|
|
472
472
|
this.logIssueNoKey({
|
|
473
473
|
level: 'warning',
|
|
474
|
-
message: `${error.message}. It is left out of the allOf merge (
|
|
474
|
+
message: `${error.message}. It is left out of the allOf merge (parse.danglingRefs lists 'allOfMember').`,
|
|
475
475
|
parent: { $ref: error.ref },
|
|
476
476
|
stackTrail,
|
|
477
477
|
type: 'DANGLING_REF'
|
|
@@ -827,7 +827,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
827
827
|
else if (this.system.danglingRefs?.includes(ref.refType)) {
|
|
828
828
|
this.logIssueNoKey({
|
|
829
829
|
level: 'warning',
|
|
830
|
-
message: `${error.message}. It is kept (
|
|
830
|
+
message: `${error.message}. It is kept (parse.danglingRefs lists '${ref.refType}'), and resolving it throws DanglingRefError.`,
|
|
831
831
|
parent: { $ref: ref.$ref },
|
|
832
832
|
stackTrail: consumer,
|
|
833
833
|
type: 'DANGLING_REF'
|
|
@@ -840,7 +840,7 @@ _ParseContext_refConsumers = new WeakMap(), _ParseContext_refErrors = new WeakMa
|
|
|
840
840
|
refTarget,
|
|
841
841
|
error,
|
|
842
842
|
type: 'DANGLING_REF',
|
|
843
|
-
message: `${error.message}, so what holds it is removed. To keep it, list '${ref.refType}' in
|
|
843
|
+
message: `${error.message}, so what holds it is removed. To keep it, list '${ref.refType}' in parse.danglingRefs.`
|
|
844
844
|
});
|
|
845
845
|
}
|
|
846
846
|
}
|
|
@@ -132,8 +132,9 @@ export declare class RenderContext {
|
|
|
132
132
|
/**
|
|
133
133
|
* Retrieves a file from the context by its export path.
|
|
134
134
|
*
|
|
135
|
-
*
|
|
136
|
-
* spelling of the same export path finds the
|
|
135
|
+
* A path that is no key is canonicalized ({@link normalizeWorkspacePath})
|
|
136
|
+
* and looked up again, so any spelling of the same export path finds the
|
|
137
|
+
* same file. Throws when no
|
|
137
138
|
* file exists at that path.
|
|
138
139
|
*
|
|
139
140
|
* @param filePath - The export path to retrieve, in any spelling
|
|
@@ -11,6 +11,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _RenderContext_captureChannel, _RenderContext_capture;
|
|
13
13
|
import invariant from 'tiny-invariant';
|
|
14
|
+
import { getByWorkspacePath } from '../helpers/getByWorkspacePath.js';
|
|
14
15
|
import { normalizeWorkspacePath } from '../helpers/normalizeWorkspacePath.js';
|
|
15
16
|
import { toResolvedArtifactPath } from '../helpers/toResolvedArtifactPath.js';
|
|
16
17
|
import { CodeFileBase } from '../dsl/CodeFileBase.js';
|
|
@@ -244,8 +245,9 @@ export class RenderContext {
|
|
|
244
245
|
/**
|
|
245
246
|
* Retrieves a file from the context by its export path.
|
|
246
247
|
*
|
|
247
|
-
*
|
|
248
|
-
* spelling of the same export path finds the
|
|
248
|
+
* A path that is no key is canonicalized ({@link normalizeWorkspacePath})
|
|
249
|
+
* and looked up again, so any spelling of the same export path finds the
|
|
250
|
+
* same file. Throws when no
|
|
249
251
|
* file exists at that path.
|
|
250
252
|
*
|
|
251
253
|
* @param filePath - The export path to retrieve, in any spelling
|
|
@@ -263,9 +265,8 @@ export class RenderContext {
|
|
|
263
265
|
* ```
|
|
264
266
|
*/
|
|
265
267
|
getFile(filePath) {
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
invariant(currentFile, `File not found during render phase: ${normalizedPath}`);
|
|
268
|
+
const currentFile = getByWorkspacePath(this.files, filePath);
|
|
269
|
+
invariant(currentFile, () => `File not found during render phase: ${normalizeWorkspacePath(filePath)}`);
|
|
269
270
|
return currentFile;
|
|
270
271
|
}
|
|
271
272
|
/**
|
|
@@ -20,6 +20,7 @@ import type { ContentSettings } from '../dsl/ContentSettings.js';
|
|
|
20
20
|
import type { RefParts } from '../helpers/refFns.js';
|
|
21
21
|
import type { SchemaToNonRef, TypeSystemOutput } from '../types/TypeSystem.js';
|
|
22
22
|
import type { FileBase } from '../dsl/FileBase.js';
|
|
23
|
+
import type { WorkspacePath } from '../helpers/normalizeWorkspacePath.js';
|
|
23
24
|
import type { ImportBase } from '../dsl/ImportBase.js';
|
|
24
25
|
import type { ReExportBase } from '../dsl/ReExportBase.js';
|
|
25
26
|
import type { Stringable } from '../dsl/Stringable.js';
|
|
@@ -178,16 +179,16 @@ export type AnyOasDocument = OpenAPIV2.Document | OpenAPIV3.Document | OpenAPIV3
|
|
|
178
179
|
* non-JSON types (`multipart/form-data`, `text/plain`) logs nothing.
|
|
179
180
|
*
|
|
180
181
|
* `ALLOF_CONTRADICTION` (`warning`) — `allOf` members contradict, and
|
|
181
|
-
* `
|
|
182
|
+
* `parse.allOf: latestWins` kept the later member's keywords. One for each
|
|
182
183
|
* schema; the message names the keywords.
|
|
183
184
|
*
|
|
184
|
-
* `ANYOF_AS_UNKNOWN` (`warning`) — `
|
|
185
|
+
* `ANYOF_AS_UNKNOWN` (`warning`) — `parse.anyOf: unknown` read an `anyOf`
|
|
185
186
|
* of two or more members as any value. The schema keeps its other keywords.
|
|
186
187
|
* One for each schema.
|
|
187
188
|
*
|
|
188
189
|
* `DANGLING_REF` — a `$ref` names nothing in the document: no component has
|
|
189
190
|
* its name, or it is part of a loop of `$ref`s (`A` is a `$ref` to `B`, and
|
|
190
|
-
* `B` to `A`). One for each place the `$ref` is written. A `warning` when `
|
|
191
|
+
* `B` to `A`). One for each place the `$ref` is written. A `warning` when `parse.danglingRefs` lists
|
|
191
192
|
* the `$ref`'s kind: the ref stays, and resolving it throws
|
|
192
193
|
* `DanglingRefError`; with `allOfMember` listed, a `$ref` that core merges
|
|
193
194
|
* (in an `allOf`, or in a `oneOf` or `anyOf` member) is left out of the
|
|
@@ -198,7 +199,7 @@ export type AnyOasDocument = OpenAPIV2.Document | OpenAPIV3.Document | OpenAPIV3
|
|
|
198
199
|
* `REF_TYPE_MISMATCH` (`error`) — a `$ref` names a component of the wrong
|
|
199
200
|
* kind, such as a request body that is a `$ref` to
|
|
200
201
|
* `#/components/schemas/Pet`. One for each place the `$ref` is written. What
|
|
201
|
-
* holds the ref is removed; `
|
|
202
|
+
* holds the ref is removed; `parse.danglingRefs` does not apply.
|
|
202
203
|
*
|
|
203
204
|
* `RUN_FAILED` (`error`) — the run itself failed outside the per-item
|
|
204
205
|
* catches. Its `location` names the entry and phase, for example
|
|
@@ -374,9 +375,10 @@ export type ToOasOperationSettingsFields<V extends GeneratedValue, EnrichmentTyp
|
|
|
374
375
|
* The Driver passes the container's path when the projection declared a
|
|
375
376
|
* `toContainer`: a member is declared inside its container, so it has no
|
|
376
377
|
* file of its own to compute, and restating one is a way for the two to
|
|
377
|
-
* disagree.
|
|
378
|
+
* disagree. It is the container's `ContentSettings.exportPath`, used as it
|
|
379
|
+
* is: the suffix and `ejected` were applied when that was made.
|
|
378
380
|
*/
|
|
379
|
-
exportPath?:
|
|
381
|
+
exportPath?: WorkspacePath;
|
|
380
382
|
};
|
|
381
383
|
/** {@link ToOasOperationSettingsFields} plus the caller's options. */
|
|
382
384
|
export type ToOasOperationSettingsArgs<V extends GeneratedValue, EnrichmentType = undefined, ProjectionOptions = undefined> = ToOasOperationSettingsFields<V, EnrichmentType, ProjectionOptions> & ProjectionOptionsArg<NoInfer<ProjectionOptions>>;
|
|
@@ -470,6 +472,8 @@ export type GenerateContextType = {
|
|
|
470
472
|
register: (args: ContextRegisterArgs) => void;
|
|
471
473
|
/** Look up an existing file by path (no creation); the neutral read primitive. */
|
|
472
474
|
getFile: (filePath: string) => FileBase | undefined;
|
|
475
|
+
/** Look up an existing file by its normalized path, which is its key: a miss is not normalized again. */
|
|
476
|
+
getFileByWorkspacePath: (path: WorkspacePath) => FileBase | undefined;
|
|
473
477
|
/** Read-only view of every file generated so far — an inspection/tooling seam (not coordination). */
|
|
474
478
|
inspectedFiles: ReadonlyMap<string, FileBase>;
|
|
475
479
|
/** Store a language-constructed file; the neutral write primitive. Returns the stored file. */
|
|
@@ -63,7 +63,7 @@ export type TryParseAtArgs<T> = {
|
|
|
63
63
|
* given `type` and the thrown value as `cause`. A `DanglingRefError`
|
|
64
64
|
* is logged as `DANGLING_REF`: core resolved a ref while it parsed (one
|
|
65
65
|
* it merges, in an `allOf` or a `oneOf` or `anyOf` member, when
|
|
66
|
-
* `
|
|
66
|
+
* `parse.danglingRefs` does not list `allOfMember`)
|
|
67
67
|
* - registers a ref error if `refKey` is provided
|
|
68
68
|
* - returns `undefined`
|
|
69
69
|
*
|
|
@@ -27,7 +27,7 @@ import { DanglingRefError } from '../oas/ref/DanglingRefError.js';
|
|
|
27
27
|
* given `type` and the thrown value as `cause`. A `DanglingRefError`
|
|
28
28
|
* is logged as `DANGLING_REF`: core resolved a ref while it parsed (one
|
|
29
29
|
* it merges, in an `allOf` or a `oneOf` or `anyOf` member, when
|
|
30
|
-
* `
|
|
30
|
+
* `parse.danglingRefs` does not list `allOfMember`)
|
|
31
31
|
* - registers a ref error if `refKey` is provided
|
|
32
32
|
* - returns `undefined`
|
|
33
33
|
*
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { IdentifierBase } from './IdentifierBase.js';
|
|
2
|
+
import type { WorkspacePath } from '../helpers/normalizeWorkspacePath.js';
|
|
2
3
|
/**
|
|
3
4
|
* Arguments for creating empty ContentSettings without enrichments.
|
|
4
5
|
*/
|
|
5
6
|
type EmptyArgs = {
|
|
6
7
|
/** The path where generated content will be exported */
|
|
7
|
-
exportPath:
|
|
8
|
+
exportPath: WorkspacePath;
|
|
8
9
|
/** The identifier for the content being generated */
|
|
9
10
|
identifier: IdentifierBase;
|
|
10
11
|
/**
|
|
@@ -24,7 +25,7 @@ type CreateArgs<EnrichmentType = undefined> = {
|
|
|
24
25
|
/** The identifier for the content being generated */
|
|
25
26
|
identifier: IdentifierBase;
|
|
26
27
|
/** The path where generated content will be exported */
|
|
27
|
-
exportPath:
|
|
28
|
+
exportPath: WorkspacePath;
|
|
28
29
|
/** Custom enrichment data for extending generation */
|
|
29
30
|
enrichments: EnrichmentType;
|
|
30
31
|
/**
|
|
@@ -58,15 +59,15 @@ type CreateArgs<EnrichmentType = undefined> = {
|
|
|
58
59
|
*
|
|
59
60
|
* @example Basic settings without enrichments
|
|
60
61
|
* ```typescript
|
|
61
|
-
* import { ContentSettings } from '@skmtc/core';
|
|
62
|
+
* import { ContentSettings, normalizeWorkspacePath } from '@skmtc/core';
|
|
62
63
|
* import { createType } from '@skmtc/lang-typescript';
|
|
63
64
|
*
|
|
64
65
|
* const settings = ContentSettings.empty({
|
|
65
|
-
* exportPath: './src/generated/models.ts',
|
|
66
|
+
* exportPath: normalizeWorkspacePath('./src/generated/models.ts'),
|
|
66
67
|
* identifier: createType('UserModels')
|
|
67
68
|
* });
|
|
68
69
|
*
|
|
69
|
-
* console.log(settings.exportPath); // '
|
|
70
|
+
* console.log(settings.exportPath); // '@/src/generated/models.ts'
|
|
70
71
|
* console.log(settings.enrichments); // undefined
|
|
71
72
|
* ```
|
|
72
73
|
*
|
|
@@ -80,7 +81,7 @@ type CreateArgs<EnrichmentType = undefined> = {
|
|
|
80
81
|
*
|
|
81
82
|
* const enrichedSettings = new ContentSettings({
|
|
82
83
|
* identifier: createType('ValidatedModels'),
|
|
83
|
-
* exportPath: './src/models/validated.ts',
|
|
84
|
+
* exportPath: normalizeWorkspacePath('./src/models/validated.ts'),
|
|
84
85
|
* enrichments: {
|
|
85
86
|
* validateRequired: true,
|
|
86
87
|
* generateComments: true,
|
|
@@ -102,7 +103,7 @@ type CreateArgs<EnrichmentType = undefined> = {
|
|
|
102
103
|
* ...args,
|
|
103
104
|
* settings: new ContentSettings({
|
|
104
105
|
* identifier: createType(args.refName),
|
|
105
|
-
* exportPath: './src/validated-models.ts',
|
|
106
|
+
* exportPath: normalizeWorkspacePath('./src/validated-models.ts'),
|
|
106
107
|
* enrichments: {
|
|
107
108
|
* validateRequired: true,
|
|
108
109
|
* generateComments: false,
|
|
@@ -132,8 +133,12 @@ type CreateArgs<EnrichmentType = undefined> = {
|
|
|
132
133
|
export declare class ContentSettings<EnrichmentType = undefined> {
|
|
133
134
|
/** The identifier for the content being generated */
|
|
134
135
|
identifier: IdentifierBase;
|
|
135
|
-
/**
|
|
136
|
-
|
|
136
|
+
/**
|
|
137
|
+
* The path where generated content will be exported, normalized
|
|
138
|
+
* ({@link normalizeWorkspacePath}): it finds its file without being
|
|
139
|
+
* normalized again.
|
|
140
|
+
*/
|
|
141
|
+
exportPath: WorkspacePath;
|
|
137
142
|
/** Custom enrichment data for extending generation */
|
|
138
143
|
enrichments: EnrichmentType;
|
|
139
144
|
/**
|
|
@@ -156,7 +161,7 @@ export declare class ContentSettings<EnrichmentType = undefined> {
|
|
|
156
161
|
* ```typescript
|
|
157
162
|
* const settings = new ContentSettings({
|
|
158
163
|
* identifier: createType('ApiModels'),
|
|
159
|
-
* exportPath: './src/api/models.ts',
|
|
164
|
+
* exportPath: normalizeWorkspacePath('./src/api/models.ts'),
|
|
160
165
|
* enrichments: {
|
|
161
166
|
* includeValidation: true,
|
|
162
167
|
* format: 'detailed'
|
|
@@ -182,7 +187,7 @@ export declare class ContentSettings<EnrichmentType = undefined> {
|
|
|
182
187
|
* ```typescript
|
|
183
188
|
* const basicSettings = ContentSettings.empty({
|
|
184
189
|
* identifier: createType('SimpleModels'),
|
|
185
|
-
* exportPath: './src/models.ts'
|
|
190
|
+
* exportPath: normalizeWorkspacePath('./src/models.ts')
|
|
186
191
|
* });
|
|
187
192
|
*
|
|
188
193
|
* console.log(basicSettings.enrichments); // undefined
|
|
@@ -194,7 +199,7 @@ export declare class ContentSettings<EnrichmentType = undefined> {
|
|
|
194
199
|
* ...args,
|
|
195
200
|
* settings: ContentSettings.empty({
|
|
196
201
|
* identifier: createType(args.refName),
|
|
197
|
-
* exportPath: './src/simple-models.ts'
|
|
202
|
+
* exportPath: normalizeWorkspacePath('./src/simple-models.ts')
|
|
198
203
|
* })
|
|
199
204
|
* });
|
|
200
205
|
* }
|