@skmtc/core 0.47.4 → 0.48.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/GenerateContext.d.ts +14 -3
- package/esm/context/GenerateContext.js +39 -33
- package/esm/context/RenderContext.d.ts +3 -2
- package/esm/context/RenderContext.js +6 -5
- package/esm/context/generateTypes.d.ts +6 -2
- 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/helpers/getByWorkspacePath.d.ts +9 -0
- package/esm/helpers/getByWorkspacePath.js +10 -0
- package/esm/helpers/normalizeWorkspacePath.d.ts +25 -2
- package/esm/helpers/normalizeWorkspacePath.js +16 -1
- package/package.json +1 -1
- package/script/context/GenerateContext.d.ts +14 -3
- package/script/context/GenerateContext.js +37 -31
- package/script/context/RenderContext.d.ts +3 -2
- package/script/context/RenderContext.js +6 -5
- package/script/context/generateTypes.d.ts +6 -2
- 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/helpers/getByWorkspacePath.d.ts +9 -0
- package/script/helpers/getByWorkspacePath.js +14 -0
- package/script/helpers/normalizeWorkspacePath.d.ts +25 -2
- package/script/helpers/normalizeWorkspacePath.js +18 -2
|
@@ -16,7 +16,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
var _OasOperationDriver_into;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.OasOperationDriver = void 0;
|
|
19
|
-
const
|
|
19
|
+
const driverFiles_js_1 = require("../../driverFiles.js");
|
|
20
20
|
const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
|
|
21
21
|
const GeneratorKeys_js_1 = require("../../GeneratorKeys.js");
|
|
22
22
|
const Variant_js_1 = require("../../../types/Variant.js");
|
|
@@ -140,10 +140,7 @@ class OasOperationDriver {
|
|
|
140
140
|
const { identifier, exportPath } = this.settings;
|
|
141
141
|
// The file an import has to be stitched into, or `undefined` when there
|
|
142
142
|
// is none to stitch — no destination, or the projection's own file.
|
|
143
|
-
const importInto = destinationPath
|
|
144
|
-
(0, normalizeWorkspacePath_js_1.normalizeWorkspacePath)(exportPath) !== (0, normalizeWorkspacePath_js_1.normalizeWorkspacePath)(destinationPath)
|
|
145
|
-
? destinationPath
|
|
146
|
-
: undefined;
|
|
143
|
+
const importInto = (0, driverFiles_js_1.toImportDestination)({ context: this.context, exportPath, destinationPath });
|
|
147
144
|
// A member is declared inside its container, so it has no module-level
|
|
148
145
|
// name — an import of it would name a symbol its file never exports, and
|
|
149
146
|
// the `Inserted.toName()` handed back would be unresolvable. What a caller
|
|
@@ -160,10 +157,13 @@ class OasOperationDriver {
|
|
|
160
157
|
// via the pure-data `context.register`. The import lands in the
|
|
161
158
|
// caller's file (`destinationPath`); `insertOperation` only composes
|
|
162
159
|
// same-language generators, so the peer's `lang` is the caller's.
|
|
163
|
-
this.ensureFile(importInto);
|
|
164
160
|
this.context.register({
|
|
165
161
|
imports: [this.projection.lang.toImport({ identifier, module: exportPath })],
|
|
166
|
-
destinationPath:
|
|
162
|
+
destinationPath: (0, driverFiles_js_1.toImportFile)({
|
|
163
|
+
context: this.context,
|
|
164
|
+
lang: this.projection.lang,
|
|
165
|
+
destination: importInto
|
|
166
|
+
}).path
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
return definition;
|
|
@@ -172,14 +172,10 @@ class OasOperationDriver {
|
|
|
172
172
|
* Ensure the file at `path` exists, creating it on first write through
|
|
173
173
|
* the projection's language — the static read off the projection class
|
|
174
174
|
* at the use site, never persisted (works pre-construction on the
|
|
175
|
-
* cache-hit path). Returns the
|
|
175
|
+
* cache-hit path). Returns the file.
|
|
176
176
|
*/
|
|
177
177
|
ensureFile(path) {
|
|
178
|
-
|
|
179
|
-
if (!this.context.getFile(normalizedPath)) {
|
|
180
|
-
this.context.addFile(this.projection.lang.createFile({ path: normalizedPath, settings: this.context.settings }));
|
|
181
|
-
}
|
|
182
|
-
return normalizedPath;
|
|
178
|
+
return (0, driverFiles_js_1.ensureFile)({ context: this.context, lang: this.projection.lang, path });
|
|
183
179
|
}
|
|
184
180
|
getDefinition({ identifier, exportPath }) {
|
|
185
181
|
// A member's place is its container, resolved (and created, on the first
|
|
@@ -191,7 +187,8 @@ class OasOperationDriver {
|
|
|
191
187
|
const into = __classPrivateFieldGet(this, _OasOperationDriver_into, "f");
|
|
192
188
|
// Spread rather than always-pass: a non-member's call shape is exactly
|
|
193
189
|
// what it was, so nothing downstream sees a key it never had.
|
|
194
|
-
const cachedDefinition =
|
|
190
|
+
const cachedDefinition = (0, driverFiles_js_1.findDefinitionAt)({
|
|
191
|
+
context: this.context,
|
|
195
192
|
name: identifier.name,
|
|
196
193
|
exportPath,
|
|
197
194
|
...(into !== undefined ? { into } : {})
|
|
@@ -36,7 +36,7 @@ export declare class WebhookDriver<V extends GeneratedValue, EnrichmentType = un
|
|
|
36
36
|
private apply;
|
|
37
37
|
/**
|
|
38
38
|
* Ensure the file at `path` exists, creating it on first write through the
|
|
39
|
-
* projection's language. Returns the
|
|
39
|
+
* projection's language. Returns the file.
|
|
40
40
|
*/
|
|
41
41
|
private ensureFile;
|
|
42
42
|
private getDefinition;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.WebhookDriver = void 0;
|
|
7
|
-
const
|
|
7
|
+
const driverFiles_js_1 = require("../driverFiles.js");
|
|
8
8
|
const GeneratorKeys_js_1 = require("../GeneratorKeys.js");
|
|
9
9
|
const Variant_js_1 = require("../../types/Variant.js");
|
|
10
10
|
const ProjectionOptions_js_1 = require("../../types/ProjectionOptions.js");
|
|
@@ -101,30 +101,33 @@ class WebhookDriver {
|
|
|
101
101
|
apply({ destinationPath } = {}) {
|
|
102
102
|
const { identifier, exportPath } = this.settings;
|
|
103
103
|
const definition = this.getDefinition({ identifier, exportPath });
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
const importInto = (0, driverFiles_js_1.toImportDestination)({ context: this.context, exportPath, destinationPath });
|
|
105
|
+
if (importInto !== undefined) {
|
|
106
106
|
// Cross-file import of the peer's identifier from its export path.
|
|
107
|
-
this.ensureFile(destinationPath);
|
|
108
107
|
this.context.register({
|
|
109
108
|
imports: [this.projection.lang.toImport({ identifier, module: exportPath })],
|
|
110
|
-
destinationPath
|
|
109
|
+
destinationPath: (0, driverFiles_js_1.toImportFile)({
|
|
110
|
+
context: this.context,
|
|
111
|
+
lang: this.projection.lang,
|
|
112
|
+
destination: importInto
|
|
113
|
+
}).path
|
|
111
114
|
});
|
|
112
115
|
}
|
|
113
116
|
return definition;
|
|
114
117
|
}
|
|
115
118
|
/**
|
|
116
119
|
* Ensure the file at `path` exists, creating it on first write through the
|
|
117
|
-
* projection's language. Returns the
|
|
120
|
+
* projection's language. Returns the file.
|
|
118
121
|
*/
|
|
119
122
|
ensureFile(path) {
|
|
120
|
-
|
|
121
|
-
if (!this.context.getFile(normalizedPath)) {
|
|
122
|
-
this.context.addFile(this.projection.lang.createFile({ path: normalizedPath, settings: this.context.settings }));
|
|
123
|
-
}
|
|
124
|
-
return normalizedPath;
|
|
123
|
+
return (0, driverFiles_js_1.ensureFile)({ context: this.context, lang: this.projection.lang, path });
|
|
125
124
|
}
|
|
126
125
|
getDefinition({ identifier, exportPath }) {
|
|
127
|
-
const cachedDefinition =
|
|
126
|
+
const cachedDefinition = (0, driverFiles_js_1.findDefinitionAt)({
|
|
127
|
+
context: this.context,
|
|
128
|
+
name: identifier.name,
|
|
129
|
+
exportPath
|
|
130
|
+
});
|
|
128
131
|
if (this.affirmDefinition(cachedDefinition, exportPath)) {
|
|
129
132
|
return cachedDefinition;
|
|
130
133
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The value at `path` in a map keyed by normalized workspace paths, such as
|
|
3
|
+
* the engine's files. A path that is a key is normalized already, so only a
|
|
4
|
+
* path that is no key is normalized, and looked up again.
|
|
5
|
+
*
|
|
6
|
+
* Throws, as {@link normalizeWorkspacePath} does, for a path that is no key
|
|
7
|
+
* and cannot name a file below `basePath`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getByWorkspacePath: <Value>(map: ReadonlyMap<string, Value>, path: string) => Value | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getByWorkspacePath = void 0;
|
|
4
|
+
const normalizeWorkspacePath_js_1 = require("./normalizeWorkspacePath.js");
|
|
5
|
+
/**
|
|
6
|
+
* The value at `path` in a map keyed by normalized workspace paths, such as
|
|
7
|
+
* the engine's files. A path that is a key is normalized already, so only a
|
|
8
|
+
* path that is no key is normalized, and looked up again.
|
|
9
|
+
*
|
|
10
|
+
* Throws, as {@link normalizeWorkspacePath} does, for a path that is no key
|
|
11
|
+
* and cannot name a file below `basePath`.
|
|
12
|
+
*/
|
|
13
|
+
const getByWorkspacePath = (map, path) => map.get(path) ?? map.get((0, normalizeWorkspacePath_js_1.normalizeWorkspacePath)(path));
|
|
14
|
+
exports.getByWorkspacePath = getByWorkspacePath;
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
import type { Brand } from '../types/Brand.js';
|
|
2
|
+
/**
|
|
3
|
+
* A workspace path in its one spelling. Only this module makes one:
|
|
4
|
+
* {@link normalizeWorkspacePath}, and
|
|
5
|
+
* {@link applyGeneratedSuffixToWorkspacePath} for one with the suffix
|
|
6
|
+
* inserted. The engine keys files by it, so a value of this type finds its
|
|
7
|
+
* file without being normalized again.
|
|
8
|
+
*/
|
|
9
|
+
export type WorkspacePath = Brand<string, 'WorkspacePath'>;
|
|
10
|
+
/**
|
|
11
|
+
* `Path`, unless it is already a {@link WorkspacePath}: normalizing one
|
|
12
|
+
* again is a compile error.
|
|
13
|
+
*/
|
|
14
|
+
export type UncheckedPath<Path extends string> = Path extends WorkspacePath ? never : Path;
|
|
1
15
|
/**
|
|
2
16
|
* Options for {@link normalizeWorkspacePath} and {@link toNormalizedWorkspacePath}.
|
|
3
17
|
*/
|
|
@@ -50,7 +64,9 @@ export declare const toNormalizedWorkspacePath: (path: string, { generatorId }?:
|
|
|
50
64
|
* return one as `@/types/User.ts`, `./types/User.ts`, `/types/User.ts`,
|
|
51
65
|
* `types/User.ts`, or with Windows separators; the engine stores this form
|
|
52
66
|
* and nothing else, so file-map keys, import modules and the ejected lookup
|
|
53
|
-
* always agree. The result is a fixed point
|
|
67
|
+
* always agree. The result is a fixed point, and is typed
|
|
68
|
+
* {@link WorkspacePath} so that passing it in again does not compile: a
|
|
69
|
+
* value of that type is already in this form.
|
|
54
70
|
*
|
|
55
71
|
* Throws in the cases {@link toNormalizedWorkspacePath} throws.
|
|
56
72
|
*
|
|
@@ -61,4 +77,11 @@ export declare const toNormalizedWorkspacePath: (path: string, { generatorId }?:
|
|
|
61
77
|
* normalizeWorkspacePath('../User.ts') // throws
|
|
62
78
|
* ```
|
|
63
79
|
*/
|
|
64
|
-
export declare const normalizeWorkspacePath: (path:
|
|
80
|
+
export declare const normalizeWorkspacePath: <Path extends string>(path: UncheckedPath<Path>, options?: NormalizeWorkspacePathOptions) => WorkspacePath;
|
|
81
|
+
/**
|
|
82
|
+
* `path` with the generated-file suffix inserted ({@link applyGeneratedSuffix}),
|
|
83
|
+
* still a {@link WorkspacePath}. A suffix with no separator only lengthens the
|
|
84
|
+
* last segment of a path in its one spelling, so the result is in that
|
|
85
|
+
* spelling too; a suffix with one is normalized with the path.
|
|
86
|
+
*/
|
|
87
|
+
export declare const applyGeneratedSuffixToWorkspacePath: (path: WorkspacePath, suffix: string, options?: NormalizeWorkspacePathOptions) => WorkspacePath;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeWorkspacePath = exports.toNormalizedWorkspacePath = exports.isValidWorkspacePath = exports.hasWorkspaceAnchor = exports.isAbsolutePath = exports.hasParentSegment = void 0;
|
|
3
|
+
exports.applyGeneratedSuffixToWorkspacePath = exports.normalizeWorkspacePath = exports.toNormalizedWorkspacePath = exports.isValidWorkspacePath = exports.hasWorkspaceAnchor = exports.isAbsolutePath = exports.hasParentSegment = void 0;
|
|
4
4
|
const normalize_js_1 = require("../deps/jsr.io/@std/path/1.1.6/posix/normalize.js");
|
|
5
5
|
const is_absolute_js_1 = require("../deps/jsr.io/@std/path/1.1.6/posix/is_absolute.js");
|
|
6
6
|
const is_absolute_js_2 = require("../deps/jsr.io/@std/path/1.1.6/windows/is_absolute.js");
|
|
7
7
|
const toWorkspacePath_js_1 = require("./toWorkspacePath.js");
|
|
8
|
+
const applyGeneratedSuffix_js_1 = require("./applyGeneratedSuffix.js");
|
|
8
9
|
/**
|
|
9
10
|
* Whether a path contains a `..` parent-reference segment. `..` is a parent
|
|
10
11
|
* reference only as a whole segment — a directory name that merely contains
|
|
@@ -77,7 +78,9 @@ exports.toNormalizedWorkspacePath = toNormalizedWorkspacePath;
|
|
|
77
78
|
* return one as `@/types/User.ts`, `./types/User.ts`, `/types/User.ts`,
|
|
78
79
|
* `types/User.ts`, or with Windows separators; the engine stores this form
|
|
79
80
|
* and nothing else, so file-map keys, import modules and the ejected lookup
|
|
80
|
-
* always agree. The result is a fixed point
|
|
81
|
+
* always agree. The result is a fixed point, and is typed
|
|
82
|
+
* {@link WorkspacePath} so that passing it in again does not compile: a
|
|
83
|
+
* value of that type is already in this form.
|
|
81
84
|
*
|
|
82
85
|
* Throws in the cases {@link toNormalizedWorkspacePath} throws.
|
|
83
86
|
*
|
|
@@ -90,6 +93,19 @@ exports.toNormalizedWorkspacePath = toNormalizedWorkspacePath;
|
|
|
90
93
|
*/
|
|
91
94
|
const normalizeWorkspacePath = (path, options = {}) => `@/${(0, exports.toNormalizedWorkspacePath)(path, options)}`;
|
|
92
95
|
exports.normalizeWorkspacePath = normalizeWorkspacePath;
|
|
96
|
+
/**
|
|
97
|
+
* `path` with the generated-file suffix inserted ({@link applyGeneratedSuffix}),
|
|
98
|
+
* still a {@link WorkspacePath}. A suffix with no separator only lengthens the
|
|
99
|
+
* last segment of a path in its one spelling, so the result is in that
|
|
100
|
+
* spelling too; a suffix with one is normalized with the path.
|
|
101
|
+
*/
|
|
102
|
+
const applyGeneratedSuffixToWorkspacePath = (path, suffix, options = {}) => {
|
|
103
|
+
const suffixed = (0, applyGeneratedSuffix_js_1.applyGeneratedSuffix)(path, suffix);
|
|
104
|
+
return /[/\\]/.test(suffix)
|
|
105
|
+
? (0, exports.normalizeWorkspacePath)(suffixed, options)
|
|
106
|
+
: suffixed;
|
|
107
|
+
};
|
|
108
|
+
exports.applyGeneratedSuffixToWorkspacePath = applyGeneratedSuffixToWorkspacePath;
|
|
93
109
|
/**
|
|
94
110
|
* Separator swap, then every anchor spelling goes (`@/`, `./`, a leading
|
|
95
111
|
* `/` — {@link toWorkspacePath}), then POSIX normalize of what is left so
|