@skmtc/core 0.28.7 → 0.29.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.js +16 -16
- package/esm/context/RenderContext.d.ts +7 -7
- package/esm/context/RenderContext.js +17 -12
- package/esm/deps/jsr.io/@std/path/1.1.6/posix/is_absolute.d.ts +16 -0
- package/esm/deps/jsr.io/@std/path/1.1.6/posix/is_absolute.js +23 -0
- package/esm/deps/jsr.io/@std/path/1.1.6/windows/is_absolute.d.ts +16 -0
- package/esm/deps/jsr.io/@std/path/1.1.6/windows/is_absolute.js +38 -0
- package/esm/dsl/model/ModelDriver.js +4 -3
- package/esm/dsl/operation/gql/GqlOperationDriver.js +4 -3
- package/esm/dsl/operation/oas/OasOperationDriver.js +4 -3
- package/esm/dsl/webhook/WebhookDriver.js +4 -3
- package/esm/helpers/applyGeneratedSuffix.js +1 -1
- package/esm/helpers/isImported.d.ts +10 -74
- package/esm/helpers/isImported.js +12 -76
- package/esm/helpers/normalizeWorkspacePath.d.ts +64 -0
- package/esm/helpers/normalizeWorkspacePath.js +98 -0
- package/esm/helpers/toResolvedArtifactPath.d.ts +8 -5
- package/esm/helpers/toResolvedArtifactPath.js +11 -7
- package/esm/helpers/toWorkspacePath.d.ts +3 -3
- package/esm/helpers/toWorkspacePath.js +5 -5
- package/esm/mod.d.ts +1 -0
- package/esm/mod.js +1 -0
- package/esm/types/Settings.js +6 -8
- package/package.json +1 -1
- package/script/context/GenerateContext.js +16 -16
- package/script/context/RenderContext.d.ts +7 -7
- package/script/context/RenderContext.js +17 -12
- package/script/deps/jsr.io/@std/path/1.1.6/posix/is_absolute.d.ts +16 -0
- package/script/deps/jsr.io/@std/path/1.1.6/posix/is_absolute.js +26 -0
- package/script/deps/jsr.io/@std/path/1.1.6/windows/is_absolute.d.ts +16 -0
- package/script/deps/jsr.io/@std/path/1.1.6/windows/is_absolute.js +41 -0
- package/script/dsl/model/ModelDriver.js +4 -3
- package/script/dsl/operation/gql/GqlOperationDriver.js +4 -3
- package/script/dsl/operation/oas/OasOperationDriver.js +4 -3
- package/script/dsl/webhook/WebhookDriver.js +4 -3
- package/script/helpers/applyGeneratedSuffix.js +1 -1
- package/script/helpers/isImported.d.ts +10 -74
- package/script/helpers/isImported.js +12 -76
- package/script/helpers/normalizeWorkspacePath.d.ts +64 -0
- package/script/helpers/normalizeWorkspacePath.js +107 -0
- package/script/helpers/toResolvedArtifactPath.d.ts +8 -5
- package/script/helpers/toResolvedArtifactPath.js +11 -7
- package/script/helpers/toWorkspacePath.d.ts +3 -3
- package/script/helpers/toWorkspacePath.js +5 -5
- package/script/mod.d.ts +1 -0
- package/script/mod.js +1 -0
- package/script/types/Settings.js +7 -9
- package/esm/deps/jsr.io/@std/path/1.1.6/extname.d.ts +0 -24
- package/esm/deps/jsr.io/@std/path/1.1.6/extname.js +0 -31
- package/esm/deps/jsr.io/@std/path/1.1.6/normalize.d.ts +0 -25
- package/esm/deps/jsr.io/@std/path/1.1.6/normalize.js +0 -32
- package/esm/deps/jsr.io/@std/path/1.1.6/windows/extname.d.ts +0 -17
- package/esm/deps/jsr.io/@std/path/1.1.6/windows/extname.js +0 -83
- package/script/deps/jsr.io/@std/path/1.1.6/extname.d.ts +0 -24
- package/script/deps/jsr.io/@std/path/1.1.6/extname.js +0 -34
- package/script/deps/jsr.io/@std/path/1.1.6/normalize.d.ts +0 -25
- package/script/deps/jsr.io/@std/path/1.1.6/normalize.js +0 -35
- package/script/deps/jsr.io/@std/path/1.1.6/windows/extname.d.ts +0 -17
- package/script/deps/jsr.io/@std/path/1.1.6/windows/extname.js +0 -86
|
@@ -10,7 +10,7 @@ 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_previews, _GenerateContext_captureChannel, _GenerateContext_enrichmentAudit, _GenerateContext_reportSkippedEnrichment, _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 {
|
|
13
|
+
import { normalizeWorkspacePath } from '../helpers/normalizeWorkspacePath.js';
|
|
14
14
|
import { applyGeneratedSuffix, DEFAULT_GENERATED_SUFFIX } from '../helpers/applyGeneratedSuffix.js';
|
|
15
15
|
import { OasOperationDriver } from '../dsl/operation/oas/OasOperationDriver.js';
|
|
16
16
|
import { WebhookDriver } from '../dsl/webhook/WebhookDriver.js';
|
|
@@ -443,7 +443,7 @@ export class GenerateContext {
|
|
|
443
443
|
* language-constructed file, use {@link addFile}.
|
|
444
444
|
*/
|
|
445
445
|
getFile(filePath) {
|
|
446
|
-
return __classPrivateFieldGet(this, _GenerateContext_files, "f").get(
|
|
446
|
+
return __classPrivateFieldGet(this, _GenerateContext_files, "f").get(normalizeWorkspacePath(filePath));
|
|
447
447
|
}
|
|
448
448
|
/**
|
|
449
449
|
* Read-only view of every file generated so far, keyed by (normalized)
|
|
@@ -467,7 +467,7 @@ export class GenerateContext {
|
|
|
467
467
|
* (`context.getFile(path) ?? context.addFile(new KtFile({ … }))`).
|
|
468
468
|
*/
|
|
469
469
|
addFile(file) {
|
|
470
|
-
const normalizedPath =
|
|
470
|
+
const normalizedPath = normalizeWorkspacePath(file.path);
|
|
471
471
|
if (__classPrivateFieldGet(this, _GenerateContext_files, "f").has(normalizedPath)) {
|
|
472
472
|
throw new Error(`File already exists: ${normalizedPath}`);
|
|
473
473
|
}
|
|
@@ -481,7 +481,7 @@ export class GenerateContext {
|
|
|
481
481
|
* @param args - Registration arguments with destination path and JSON content
|
|
482
482
|
*/
|
|
483
483
|
registerJson({ destinationPath, json }) {
|
|
484
|
-
const normalizedPath =
|
|
484
|
+
const normalizedPath = normalizeWorkspacePath(destinationPath);
|
|
485
485
|
let currentFile = this.getFile(normalizedPath);
|
|
486
486
|
if (!currentFile) {
|
|
487
487
|
currentFile = new JsonFile({ path: normalizedPath, content: {} });
|
|
@@ -500,7 +500,7 @@ export class GenerateContext {
|
|
|
500
500
|
* @experimental This method is experimental and may change in future versions
|
|
501
501
|
*/
|
|
502
502
|
registerMarkdown({ destinationPath, markdown }) {
|
|
503
|
-
const normalizedPath =
|
|
503
|
+
const normalizedPath = normalizeWorkspacePath(destinationPath);
|
|
504
504
|
let currentFile = this.getFile(normalizedPath);
|
|
505
505
|
if (!currentFile) {
|
|
506
506
|
currentFile = new MarkdownFile({ path: normalizedPath, content: '' });
|
|
@@ -521,7 +521,7 @@ export class GenerateContext {
|
|
|
521
521
|
* @mutates this.files
|
|
522
522
|
*/
|
|
523
523
|
register({ imports = [], reExports = [], definitions, custom, destinationPath, into }) {
|
|
524
|
-
const normalizedPath =
|
|
524
|
+
const normalizedPath = normalizeWorkspacePath(destinationPath);
|
|
525
525
|
const currentFile = this.getFile(normalizedPath);
|
|
526
526
|
// `register` never creates files — it speaks pure data and the engine
|
|
527
527
|
// never names a file class. Callers pre-create the destination file
|
|
@@ -629,7 +629,7 @@ export class GenerateContext {
|
|
|
629
629
|
// the use site (same ephemeral read the Drivers make) — pre-creates
|
|
630
630
|
// the destination file caller-side, and stores via the pure-data
|
|
631
631
|
// `register`.
|
|
632
|
-
const normalizedPath =
|
|
632
|
+
const normalizedPath = normalizeWorkspacePath(destinationPath);
|
|
633
633
|
if (!this.getFile(normalizedPath)) {
|
|
634
634
|
this.addFile(projection.lang.createFile({ path: normalizedPath, settings: this.settings }));
|
|
635
635
|
}
|
|
@@ -696,7 +696,7 @@ export class GenerateContext {
|
|
|
696
696
|
enrichments,
|
|
697
697
|
variant,
|
|
698
698
|
options
|
|
699
|
-
})),
|
|
699
|
+
}), args.projection.id),
|
|
700
700
|
enrichments,
|
|
701
701
|
variant
|
|
702
702
|
});
|
|
@@ -724,7 +724,7 @@ export class GenerateContext {
|
|
|
724
724
|
enrichments,
|
|
725
725
|
variant,
|
|
726
726
|
options
|
|
727
|
-
})),
|
|
727
|
+
}), args.projection.id),
|
|
728
728
|
enrichments,
|
|
729
729
|
variant
|
|
730
730
|
});
|
|
@@ -757,7 +757,7 @@ export class GenerateContext {
|
|
|
757
757
|
enrichments,
|
|
758
758
|
variant,
|
|
759
759
|
options
|
|
760
|
-
})),
|
|
760
|
+
}), args.projection.id),
|
|
761
761
|
enrichments,
|
|
762
762
|
variant
|
|
763
763
|
});
|
|
@@ -779,7 +779,7 @@ export class GenerateContext {
|
|
|
779
779
|
name: projection.toIdentifierName({ refName, enrichments, variant, options }),
|
|
780
780
|
...projection.toIdentifierType(refName, this)
|
|
781
781
|
}),
|
|
782
|
-
exportPath: __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toContentSettingsExportPath).call(this, projection.toExportPath({ refName, enrichments, variant, options })),
|
|
782
|
+
exportPath: __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toContentSettingsExportPath).call(this, projection.toExportPath({ refName, enrichments, variant, options }), projection.id),
|
|
783
783
|
enrichments,
|
|
784
784
|
variant
|
|
785
785
|
});
|
|
@@ -1165,15 +1165,15 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_previews = new WeakMap(
|
|
|
1165
1165
|
module: { ...module, exportPath: __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toContentSettingsExportPath).call(this, module.exportPath) },
|
|
1166
1166
|
source
|
|
1167
1167
|
};
|
|
1168
|
-
}, _GenerateContext_toContentSettingsExportPath = function _GenerateContext_toContentSettingsExportPath(exportPath) {
|
|
1169
|
-
const suffixed = applyGeneratedSuffix(exportPath, this.settings?.generatedSuffix ?? DEFAULT_GENERATED_SUFFIX);
|
|
1170
|
-
return __classPrivateFieldGet(this, _GenerateContext_instances, "a", _GenerateContext_ejectedBySuffixedPath_get).get(
|
|
1168
|
+
}, _GenerateContext_toContentSettingsExportPath = function _GenerateContext_toContentSettingsExportPath(exportPath, generatorId) {
|
|
1169
|
+
const suffixed = applyGeneratedSuffix(normalizeWorkspacePath(exportPath, { generatorId }), this.settings?.generatedSuffix ?? DEFAULT_GENERATED_SUFFIX);
|
|
1170
|
+
return __classPrivateFieldGet(this, _GenerateContext_instances, "a", _GenerateContext_ejectedBySuffixedPath_get).get(suffixed) ?? suffixed;
|
|
1171
1171
|
}, _GenerateContext_ejectedBySuffixedPath_get = function _GenerateContext_ejectedBySuffixedPath_get() {
|
|
1172
1172
|
if (__classPrivateFieldGet(this, _GenerateContext_ejectedBySuffixedPathCache, "f") === undefined) {
|
|
1173
1173
|
const suffix = this.settings?.generatedSuffix ?? DEFAULT_GENERATED_SUFFIX;
|
|
1174
1174
|
__classPrivateFieldSet(this, _GenerateContext_ejectedBySuffixedPathCache, new Map((this.settings?.ejected ?? []).map(ejectedPath => {
|
|
1175
|
-
const normalized =
|
|
1176
|
-
return [
|
|
1175
|
+
const normalized = normalizeWorkspacePath(ejectedPath);
|
|
1176
|
+
return [applyGeneratedSuffix(normalized, suffix), normalized];
|
|
1177
1177
|
})), "f");
|
|
1178
1178
|
}
|
|
1179
1179
|
return __classPrivateFieldGet(this, _GenerateContext_ejectedBySuffixedPathCache, "f");
|
|
@@ -130,13 +130,13 @@ export declare class RenderContext {
|
|
|
130
130
|
*/
|
|
131
131
|
collate(stackTrail: StackTrail): FilesRenderResult;
|
|
132
132
|
/**
|
|
133
|
-
* Retrieves a file from the context by its
|
|
133
|
+
* Retrieves a file from the context by its export path.
|
|
134
134
|
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* exists
|
|
135
|
+
* The path is canonicalized first ({@link normalizeWorkspacePath}), so any
|
|
136
|
+
* spelling of the same export path finds the same file. Throws when no
|
|
137
|
+
* file exists at that path.
|
|
138
138
|
*
|
|
139
|
-
* @param filePath - The
|
|
139
|
+
* @param filePath - The export path to retrieve, in any spelling
|
|
140
140
|
* @returns The File or JsonFile instance
|
|
141
141
|
* @throws {Error} When the file is not found in the context
|
|
142
142
|
*
|
|
@@ -145,9 +145,9 @@ export declare class RenderContext {
|
|
|
145
145
|
* const file = renderContext.getFile('./src/models/User.ts');
|
|
146
146
|
* console.log(file.toString()); // Access file content
|
|
147
147
|
*
|
|
148
|
-
* //
|
|
148
|
+
* // Every spelling of the same export path finds the same file
|
|
149
149
|
* const sameFile = renderContext.getFile('src/models/User.ts');
|
|
150
|
-
* const alsoSameFile = renderContext.getFile('
|
|
150
|
+
* const alsoSameFile = renderContext.getFile('@/src/models/User.ts');
|
|
151
151
|
* ```
|
|
152
152
|
*/
|
|
153
153
|
getFile(filePath: string): FileBase;
|
|
@@ -11,7 +11,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _RenderContext_captureChannel, _RenderContext_sink, _RenderContext_captures;
|
|
13
13
|
import invariant from 'tiny-invariant';
|
|
14
|
-
import {
|
|
14
|
+
import { normalizeWorkspacePath } from '../helpers/normalizeWorkspacePath.js';
|
|
15
15
|
import { toResolvedArtifactPath } from '../helpers/toResolvedArtifactPath.js';
|
|
16
16
|
import { CodeFileBase } from '../dsl/CodeFileBase.js';
|
|
17
17
|
import { CaptureSink } from '../anchors/CaptureSink.js';
|
|
@@ -168,8 +168,9 @@ export class RenderContext {
|
|
|
168
168
|
__classPrivateFieldSet(this, _RenderContext_sink, undefined, "f");
|
|
169
169
|
}
|
|
170
170
|
// Build one sidecar per captured File from the spans the sink
|
|
171
|
-
// resolved (no re-render, no `toString`). Keyed by
|
|
172
|
-
// matching the
|
|
171
|
+
// resolved (no re-render, no `toString`). Keyed by the resolved artifact
|
|
172
|
+
// path, matching `artifacts` and the manifest, so a sidecar sits at
|
|
173
|
+
// `<outDir>/<artifact key>.skm.json` where doctor looks for it.
|
|
173
174
|
const { parser, schemaSrc, generatorMeta } = postPassConfig;
|
|
174
175
|
const sidecars = {};
|
|
175
176
|
const generationMap = [];
|
|
@@ -182,7 +183,11 @@ export class RenderContext {
|
|
|
182
183
|
parser,
|
|
183
184
|
generatorMeta
|
|
184
185
|
});
|
|
185
|
-
|
|
186
|
+
const artifactPath = toResolvedArtifactPath({
|
|
187
|
+
basePath: this.basePath,
|
|
188
|
+
destinationPath: capture.destinationPath
|
|
189
|
+
});
|
|
190
|
+
sidecars[artifactPath] = sidecar;
|
|
186
191
|
generationMap.push(...entriesForSidecar(sidecar));
|
|
187
192
|
}
|
|
188
193
|
__classPrivateFieldSet(this, _RenderContext_captures, [], "f");
|
|
@@ -270,13 +275,13 @@ export class RenderContext {
|
|
|
270
275
|
return output;
|
|
271
276
|
}
|
|
272
277
|
/**
|
|
273
|
-
* Retrieves a file from the context by its
|
|
278
|
+
* Retrieves a file from the context by its export path.
|
|
274
279
|
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* exists
|
|
280
|
+
* The path is canonicalized first ({@link normalizeWorkspacePath}), so any
|
|
281
|
+
* spelling of the same export path finds the same file. Throws when no
|
|
282
|
+
* file exists at that path.
|
|
278
283
|
*
|
|
279
|
-
* @param filePath - The
|
|
284
|
+
* @param filePath - The export path to retrieve, in any spelling
|
|
280
285
|
* @returns The File or JsonFile instance
|
|
281
286
|
* @throws {Error} When the file is not found in the context
|
|
282
287
|
*
|
|
@@ -285,13 +290,13 @@ export class RenderContext {
|
|
|
285
290
|
* const file = renderContext.getFile('./src/models/User.ts');
|
|
286
291
|
* console.log(file.toString()); // Access file content
|
|
287
292
|
*
|
|
288
|
-
* //
|
|
293
|
+
* // Every spelling of the same export path finds the same file
|
|
289
294
|
* const sameFile = renderContext.getFile('src/models/User.ts');
|
|
290
|
-
* const alsoSameFile = renderContext.getFile('
|
|
295
|
+
* const alsoSameFile = renderContext.getFile('@/src/models/User.ts');
|
|
291
296
|
* ```
|
|
292
297
|
*/
|
|
293
298
|
getFile(filePath) {
|
|
294
|
-
const normalizedPath =
|
|
299
|
+
const normalizedPath = normalizeWorkspacePath(filePath);
|
|
295
300
|
const currentFile = this.files.get(normalizedPath);
|
|
296
301
|
invariant(currentFile, `File not found during render phase: ${normalizedPath}`);
|
|
297
302
|
return currentFile;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verifies whether provided path is absolute.
|
|
3
|
+
*
|
|
4
|
+
* @example Usage
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { isAbsolute } from "@std/path/posix/is-absolute";
|
|
7
|
+
* import { assert, assertFalse } from "@std/assert";
|
|
8
|
+
*
|
|
9
|
+
* assert(isAbsolute("/home/user/Documents/"));
|
|
10
|
+
* assertFalse(isAbsolute("home/user/Documents/"));
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param path The path to verify.
|
|
14
|
+
* @returns Whether the path is absolute.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isAbsolute(path: string): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
import { assertPath } from "../_common/assert_path.js";
|
|
4
|
+
import { isPosixPathSeparator } from "./_util.js";
|
|
5
|
+
/**
|
|
6
|
+
* Verifies whether provided path is absolute.
|
|
7
|
+
*
|
|
8
|
+
* @example Usage
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { isAbsolute } from "@std/path/posix/is-absolute";
|
|
11
|
+
* import { assert, assertFalse } from "@std/assert";
|
|
12
|
+
*
|
|
13
|
+
* assert(isAbsolute("/home/user/Documents/"));
|
|
14
|
+
* assertFalse(isAbsolute("home/user/Documents/"));
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @param path The path to verify.
|
|
18
|
+
* @returns Whether the path is absolute.
|
|
19
|
+
*/
|
|
20
|
+
export function isAbsolute(path) {
|
|
21
|
+
assertPath(path);
|
|
22
|
+
return path.length > 0 && isPosixPathSeparator(path.charCodeAt(0));
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verifies whether provided path is absolute.
|
|
3
|
+
*
|
|
4
|
+
* @example Usage
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { isAbsolute } from "@std/path/windows/is-absolute";
|
|
7
|
+
* import { assert, assertFalse } from "@std/assert";
|
|
8
|
+
*
|
|
9
|
+
* assert(isAbsolute("C:\\foo\\bar"));
|
|
10
|
+
* assertFalse(isAbsolute("..\\baz"));
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param path The path to verify.
|
|
14
|
+
* @returns `true` if the path is absolute, `false` otherwise.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isAbsolute(path: string): boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
import { CHAR_COLON } from "../_common/constants.js";
|
|
4
|
+
import { assertPath } from "../_common/assert_path.js";
|
|
5
|
+
import { isPathSeparator, isWindowsDeviceRoot } from "./_util.js";
|
|
6
|
+
/**
|
|
7
|
+
* Verifies whether provided path is absolute.
|
|
8
|
+
*
|
|
9
|
+
* @example Usage
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { isAbsolute } from "@std/path/windows/is-absolute";
|
|
12
|
+
* import { assert, assertFalse } from "@std/assert";
|
|
13
|
+
*
|
|
14
|
+
* assert(isAbsolute("C:\\foo\\bar"));
|
|
15
|
+
* assertFalse(isAbsolute("..\\baz"));
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param path The path to verify.
|
|
19
|
+
* @returns `true` if the path is absolute, `false` otherwise.
|
|
20
|
+
*/
|
|
21
|
+
export function isAbsolute(path) {
|
|
22
|
+
assertPath(path);
|
|
23
|
+
const len = path.length;
|
|
24
|
+
if (len === 0)
|
|
25
|
+
return false;
|
|
26
|
+
const code = path.charCodeAt(0);
|
|
27
|
+
if (isPathSeparator(code)) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
else if (isWindowsDeviceRoot(code)) {
|
|
31
|
+
// Possible device root
|
|
32
|
+
if (len > 2 && path.charCodeAt(1) === CHAR_COLON) {
|
|
33
|
+
if (isPathSeparator(path.charCodeAt(2)))
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeWorkspacePath } from '../../helpers/normalizeWorkspacePath.js';
|
|
2
2
|
import { toModelGeneratorKey } from '../GeneratorKeys.js';
|
|
3
3
|
import { DEFAULT_VARIANT } from '../../types/Variant.js';
|
|
4
4
|
import { readProjectionOptions, toValueOptions } from '../../types/ProjectionOptions.js';
|
|
@@ -104,7 +104,8 @@ export class ModelDriver {
|
|
|
104
104
|
apply({ destinationPath } = {}) {
|
|
105
105
|
const { identifier, exportPath } = this.settings;
|
|
106
106
|
const definition = this.getDefinition({ identifier, exportPath });
|
|
107
|
-
if (destinationPath &&
|
|
107
|
+
if (destinationPath &&
|
|
108
|
+
normalizeWorkspacePath(exportPath) !== normalizeWorkspacePath(destinationPath)) {
|
|
108
109
|
// Cross-file import of the peer's identifier from its export path.
|
|
109
110
|
// The language builds the import object (`toImport`) and creates the
|
|
110
111
|
// destination file on first write (caller-side); the engine stores
|
|
@@ -124,7 +125,7 @@ export class ModelDriver {
|
|
|
124
125
|
* cache-hit path). Returns the normalized path.
|
|
125
126
|
*/
|
|
126
127
|
ensureFile(path) {
|
|
127
|
-
const normalizedPath =
|
|
128
|
+
const normalizedPath = normalizeWorkspacePath(path);
|
|
128
129
|
if (!this.context.getFile(normalizedPath)) {
|
|
129
130
|
this.context.addFile(this.projection.lang.createFile({ path: normalizedPath, settings: this.context.settings }));
|
|
130
131
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeWorkspacePath } from '../../../helpers/normalizeWorkspacePath.js';
|
|
2
2
|
import { toGqlOperationGeneratorKey } from '../../GeneratorKeys.js';
|
|
3
3
|
import { DEFAULT_VARIANT } from '../../../types/Variant.js';
|
|
4
4
|
import { readProjectionOptions, toValueOptions } from '../../../types/ProjectionOptions.js';
|
|
@@ -95,7 +95,8 @@ export class GqlOperationDriver {
|
|
|
95
95
|
apply({ destinationPath } = {}) {
|
|
96
96
|
const { identifier, exportPath } = this.settings;
|
|
97
97
|
const definition = this.getDefinition({ identifier, exportPath });
|
|
98
|
-
if (destinationPath &&
|
|
98
|
+
if (destinationPath &&
|
|
99
|
+
normalizeWorkspacePath(exportPath) !== normalizeWorkspacePath(destinationPath)) {
|
|
99
100
|
// Cross-file import of the peer's identifier from its export path.
|
|
100
101
|
// The language builds the import object (`toImport`) and creates the
|
|
101
102
|
// destination file on first write (caller-side); the engine stores
|
|
@@ -117,7 +118,7 @@ export class GqlOperationDriver {
|
|
|
117
118
|
* cache-hit path). Returns the normalized path.
|
|
118
119
|
*/
|
|
119
120
|
ensureFile(path) {
|
|
120
|
-
const normalizedPath =
|
|
121
|
+
const normalizedPath = normalizeWorkspacePath(path);
|
|
121
122
|
if (!this.context.getFile(normalizedPath)) {
|
|
122
123
|
this.context.addFile(this.projection.lang.createFile({ path: normalizedPath, settings: this.context.settings }));
|
|
123
124
|
}
|
|
@@ -10,7 +10,7 @@ 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 _OasOperationDriver_into;
|
|
13
|
-
import {
|
|
13
|
+
import { normalizeWorkspacePath } from '../../../helpers/normalizeWorkspacePath.js';
|
|
14
14
|
import invariant from 'tiny-invariant';
|
|
15
15
|
import { toOasOperationGeneratorKey } from '../../GeneratorKeys.js';
|
|
16
16
|
import { DEFAULT_VARIANT } from '../../../types/Variant.js';
|
|
@@ -134,7 +134,8 @@ export class OasOperationDriver {
|
|
|
134
134
|
const { identifier, exportPath } = this.settings;
|
|
135
135
|
// The file an import has to be stitched into, or `undefined` when there
|
|
136
136
|
// is none to stitch — no destination, or the projection's own file.
|
|
137
|
-
const importInto = destinationPath &&
|
|
137
|
+
const importInto = destinationPath &&
|
|
138
|
+
normalizeWorkspacePath(exportPath) !== normalizeWorkspacePath(destinationPath)
|
|
138
139
|
? destinationPath
|
|
139
140
|
: undefined;
|
|
140
141
|
// A member is declared inside its container, so it has no module-level
|
|
@@ -168,7 +169,7 @@ export class OasOperationDriver {
|
|
|
168
169
|
* cache-hit path). Returns the normalized path.
|
|
169
170
|
*/
|
|
170
171
|
ensureFile(path) {
|
|
171
|
-
const normalizedPath =
|
|
172
|
+
const normalizedPath = normalizeWorkspacePath(path);
|
|
172
173
|
if (!this.context.getFile(normalizedPath)) {
|
|
173
174
|
this.context.addFile(this.projection.lang.createFile({ path: normalizedPath, settings: this.context.settings }));
|
|
174
175
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeWorkspacePath } from '../../helpers/normalizeWorkspacePath.js';
|
|
2
2
|
import { toWebhookGeneratorKey } from '../GeneratorKeys.js';
|
|
3
3
|
import { DEFAULT_VARIANT } from '../../types/Variant.js';
|
|
4
4
|
import { readProjectionOptions, toValueOptions } from '../../types/ProjectionOptions.js';
|
|
@@ -95,7 +95,8 @@ export class WebhookDriver {
|
|
|
95
95
|
apply({ destinationPath } = {}) {
|
|
96
96
|
const { identifier, exportPath } = this.settings;
|
|
97
97
|
const definition = this.getDefinition({ identifier, exportPath });
|
|
98
|
-
if (destinationPath &&
|
|
98
|
+
if (destinationPath &&
|
|
99
|
+
normalizeWorkspacePath(exportPath) !== normalizeWorkspacePath(destinationPath)) {
|
|
99
100
|
// Cross-file import of the peer's identifier from its export path.
|
|
100
101
|
this.ensureFile(destinationPath);
|
|
101
102
|
this.context.register({
|
|
@@ -110,7 +111,7 @@ export class WebhookDriver {
|
|
|
110
111
|
* projection's language. Returns the normalized path.
|
|
111
112
|
*/
|
|
112
113
|
ensureFile(path) {
|
|
113
|
-
const normalizedPath =
|
|
114
|
+
const normalizedPath = normalizeWorkspacePath(path);
|
|
114
115
|
if (!this.context.getFile(normalizedPath)) {
|
|
115
116
|
this.context.addFile(this.projection.lang.createFile({ path: normalizedPath, settings: this.context.settings }));
|
|
116
117
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extname } from '../deps/jsr.io/@std/path/1.1.6/extname.js';
|
|
1
|
+
import { extname } from '../deps/jsr.io/@std/path/1.1.6/posix/extname.js';
|
|
2
2
|
/**
|
|
3
3
|
* The filename suffix marking a file as engine-owned, applied by the
|
|
4
4
|
* engine when a projection's `toExportPath` result is stored into
|
|
@@ -1,81 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Whether two workspace paths name different files, so a symbol from one
|
|
3
|
+
* must be imported into the other.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Both are canonicalized with {@link normalizeWorkspacePath}, so every
|
|
6
|
+
* spelling of one file compares equal: `@/`, `./`, the bare form, and
|
|
7
|
+
* Windows separators. Throws, as that does, for a path that cannot name a
|
|
8
|
+
* file below `basePath` (a `..` segment, a Windows drive path).
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
* across different operating systems and path formats (handling './' vs absolute
|
|
11
|
-
* paths, different separators, etc.).
|
|
12
|
-
*
|
|
13
|
-
* @param pathOne - The first file path to compare
|
|
14
|
-
* @param pathTwo - The second file path to compare
|
|
15
|
-
* @returns `true` if the paths are different (import needed), `false` if they're the same file
|
|
16
|
-
*
|
|
17
|
-
* @example Basic path comparison
|
|
18
|
-
* ```typescript
|
|
19
|
-
* import { isImported } from '@skmtc/core';
|
|
20
|
-
*
|
|
21
|
-
* // Same file, no import needed
|
|
22
|
-
* console.log(isImported('./src/user.ts', './src/user.ts')); // false
|
|
23
|
-
*
|
|
24
|
-
* // Different files, import needed
|
|
25
|
-
* console.log(isImported('./src/user.ts', './src/product.ts')); // true
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @example Path normalization handling
|
|
29
|
-
* ```typescript
|
|
30
|
-
* // These all represent the same file after normalization
|
|
31
|
-
* console.log(isImported('./src/user.ts', 'src/user.ts')); // false
|
|
32
|
-
* console.log(isImported('src/./user.ts', 'src/user.ts')); // false
|
|
33
|
-
* console.log(isImported('src/models/../user.ts', 'src/user.ts')); // false
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @example Usage in import decision logic
|
|
10
|
+
* @example
|
|
37
11
|
* ```typescript
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* targetFile: string,
|
|
42
|
-
* importName: string
|
|
43
|
-
* ) {
|
|
44
|
-
* if (isImported(sourceFile, targetFile)) {
|
|
45
|
-
* // Files are different, add import
|
|
46
|
-
* this.addImport(sourceFile, targetFile, importName);
|
|
47
|
-
* console.log(`Added import: ${importName} from ${targetFile}`);
|
|
48
|
-
* } else {
|
|
49
|
-
* // Same file, no import needed
|
|
50
|
-
* console.log(`No import needed - same file: ${sourceFile}`);
|
|
51
|
-
* }
|
|
52
|
-
* }
|
|
53
|
-
* }
|
|
54
|
-
* ```
|
|
55
|
-
*
|
|
56
|
-
* @example Cross-platform path handling
|
|
57
|
-
* ```typescript
|
|
58
|
-
* // Works consistently across platforms
|
|
59
|
-
* const windowsPath = 'src\\models\\user.ts';
|
|
60
|
-
* const unixPath = 'src/models/user.ts';
|
|
61
|
-
*
|
|
62
|
-
* console.log(isImported(windowsPath, unixPath)); // false (same file)
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
|
-
* @example In generator context
|
|
66
|
-
* ```typescript
|
|
67
|
-
* class ModelGenerator {
|
|
68
|
-
* generateModel(modelPath: string, referencePath: string) {
|
|
69
|
-
* const definition = this.createModelDefinition();
|
|
70
|
-
*
|
|
71
|
-
* if (isImported(modelPath, referencePath)) {
|
|
72
|
-
* // Need to import the referenced model
|
|
73
|
-
* definition.addImport(referencePath, 'ReferencedModel');
|
|
74
|
-
* }
|
|
75
|
-
*
|
|
76
|
-
* return definition;
|
|
77
|
-
* }
|
|
78
|
-
* }
|
|
12
|
+
* isImported('@/src/user.ts', './src/user.ts') // false — one file
|
|
13
|
+
* isImported('src\\user.ts', 'src/user.ts') // false — one file
|
|
14
|
+
* isImported('@/src/user.ts', '@/src/product.ts') // true
|
|
79
15
|
* ```
|
|
80
16
|
*/
|
|
81
17
|
export declare const isImported: (pathOne: string, pathTwo: string) => boolean;
|
|
@@ -1,84 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeWorkspacePath } from './normalizeWorkspacePath.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Whether two workspace paths name different files, so a symbol from one
|
|
4
|
+
* must be imported into the other.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Both are canonicalized with {@link normalizeWorkspacePath}, so every
|
|
7
|
+
* spelling of one file compares equal: `@/`, `./`, the bare form, and
|
|
8
|
+
* Windows separators. Throws, as that does, for a path that cannot name a
|
|
9
|
+
* file below `basePath` (a `..` segment, a Windows drive path).
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
* across different operating systems and path formats (handling './' vs absolute
|
|
12
|
-
* paths, different separators, etc.).
|
|
13
|
-
*
|
|
14
|
-
* @param pathOne - The first file path to compare
|
|
15
|
-
* @param pathTwo - The second file path to compare
|
|
16
|
-
* @returns `true` if the paths are different (import needed), `false` if they're the same file
|
|
17
|
-
*
|
|
18
|
-
* @example Basic path comparison
|
|
19
|
-
* ```typescript
|
|
20
|
-
* import { isImported } from '@skmtc/core';
|
|
21
|
-
*
|
|
22
|
-
* // Same file, no import needed
|
|
23
|
-
* console.log(isImported('./src/user.ts', './src/user.ts')); // false
|
|
24
|
-
*
|
|
25
|
-
* // Different files, import needed
|
|
26
|
-
* console.log(isImported('./src/user.ts', './src/product.ts')); // true
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @example Path normalization handling
|
|
30
|
-
* ```typescript
|
|
31
|
-
* // These all represent the same file after normalization
|
|
32
|
-
* console.log(isImported('./src/user.ts', 'src/user.ts')); // false
|
|
33
|
-
* console.log(isImported('src/./user.ts', 'src/user.ts')); // false
|
|
34
|
-
* console.log(isImported('src/models/../user.ts', 'src/user.ts')); // false
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @example Usage in import decision logic
|
|
11
|
+
* @example
|
|
38
12
|
* ```typescript
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* targetFile: string,
|
|
43
|
-
* importName: string
|
|
44
|
-
* ) {
|
|
45
|
-
* if (isImported(sourceFile, targetFile)) {
|
|
46
|
-
* // Files are different, add import
|
|
47
|
-
* this.addImport(sourceFile, targetFile, importName);
|
|
48
|
-
* console.log(`Added import: ${importName} from ${targetFile}`);
|
|
49
|
-
* } else {
|
|
50
|
-
* // Same file, no import needed
|
|
51
|
-
* console.log(`No import needed - same file: ${sourceFile}`);
|
|
52
|
-
* }
|
|
53
|
-
* }
|
|
54
|
-
* }
|
|
55
|
-
* ```
|
|
56
|
-
*
|
|
57
|
-
* @example Cross-platform path handling
|
|
58
|
-
* ```typescript
|
|
59
|
-
* // Works consistently across platforms
|
|
60
|
-
* const windowsPath = 'src\\models\\user.ts';
|
|
61
|
-
* const unixPath = 'src/models/user.ts';
|
|
62
|
-
*
|
|
63
|
-
* console.log(isImported(windowsPath, unixPath)); // false (same file)
|
|
64
|
-
* ```
|
|
65
|
-
*
|
|
66
|
-
* @example In generator context
|
|
67
|
-
* ```typescript
|
|
68
|
-
* class ModelGenerator {
|
|
69
|
-
* generateModel(modelPath: string, referencePath: string) {
|
|
70
|
-
* const definition = this.createModelDefinition();
|
|
71
|
-
*
|
|
72
|
-
* if (isImported(modelPath, referencePath)) {
|
|
73
|
-
* // Need to import the referenced model
|
|
74
|
-
* definition.addImport(referencePath, 'ReferencedModel');
|
|
75
|
-
* }
|
|
76
|
-
*
|
|
77
|
-
* return definition;
|
|
78
|
-
* }
|
|
79
|
-
* }
|
|
13
|
+
* isImported('@/src/user.ts', './src/user.ts') // false — one file
|
|
14
|
+
* isImported('src\\user.ts', 'src/user.ts') // false — one file
|
|
15
|
+
* isImported('@/src/user.ts', '@/src/product.ts') // true
|
|
80
16
|
* ```
|
|
81
17
|
*/
|
|
82
18
|
export const isImported = (pathOne, pathTwo) => {
|
|
83
|
-
return
|
|
19
|
+
return normalizeWorkspacePath(pathOne) !== normalizeWorkspacePath(pathTwo);
|
|
84
20
|
};
|