primitive-admin 1.0.55 → 1.0.56
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/assets/skill/skills/primitive-platform/SKILL.md +230 -2
- package/dist/bin/primitive.js +1 -1
- package/dist/src/commands/database-types.js +4 -4
- package/dist/src/commands/database-types.js.map +1 -1
- package/dist/src/commands/databases.js +5 -5
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/documents.js +2 -2
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/guides.d.ts +15 -12
- package/dist/src/commands/guides.js +22 -15
- package/dist/src/commands/guides.js.map +1 -1
- package/dist/src/commands/metadata.js +48 -3
- package/dist/src/commands/metadata.js.map +1 -1
- package/dist/src/commands/scripts.d.ts +18 -0
- package/dist/src/commands/scripts.js +59 -5
- package/dist/src/commands/scripts.js.map +1 -1
- package/dist/src/commands/sync-app-settings.d.ts +14 -4
- package/dist/src/commands/sync-app-settings.js +48 -8
- package/dist/src/commands/sync-app-settings.js.map +1 -1
- package/dist/src/commands/sync.d.ts +100 -0
- package/dist/src/commands/sync.js +1578 -402
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/workflows.js +23 -6
- package/dist/src/commands/workflows.js.map +1 -1
- package/dist/src/lib/api-client.d.ts +27 -1
- package/dist/src/lib/api-client.js +25 -2
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-settings-descriptor.js +4 -0
- package/dist/src/lib/app-settings-descriptor.js.map +1 -1
- package/dist/src/lib/codegen-shared/generatedFiles.d.ts +21 -0
- package/dist/src/lib/codegen-shared/generatedFiles.js +40 -0
- package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -1
- package/dist/src/lib/codegen-shared/prettierStable.d.ts +262 -0
- package/dist/src/lib/codegen-shared/prettierStable.js +610 -0
- package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -0
- package/dist/src/lib/db-codegen/dbGenerator.js +8 -5
- package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -1
- package/dist/src/lib/db-codegen/dbNaming.d.ts +5 -0
- package/dist/src/lib/db-codegen/dbNaming.js +8 -2
- package/dist/src/lib/db-codegen/dbNaming.js.map +1 -1
- package/dist/src/lib/db-codegen/dbTemplates.d.ts +17 -2
- package/dist/src/lib/db-codegen/dbTemplates.js +85 -40
- package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -1
- package/dist/src/lib/db-codegen/dbTsTypes.d.ts +13 -22
- package/dist/src/lib/db-codegen/dbTsTypes.js +33 -28
- package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
- package/dist/src/lib/db-codegen/generated-operation-def-descriptor.d.ts +11 -0
- package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js +11 -0
- package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js.map +1 -1
- package/dist/src/lib/generated-allowlist.js +7 -0
- package/dist/src/lib/generated-allowlist.js.map +1 -1
- package/dist/src/lib/platform-owned.d.ts +37 -0
- package/dist/src/lib/platform-owned.js +46 -0
- package/dist/src/lib/platform-owned.js.map +1 -0
- package/dist/src/lib/swift-codegen/dbGenerator.d.ts +32 -0
- package/dist/src/lib/swift-codegen/dbGenerator.js +338 -36
- package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -1
- package/dist/src/lib/swift-codegen/dbSwiftTypes.d.ts +1 -1
- package/dist/src/lib/swift-codegen/dbSwiftTypes.js +1 -1
- package/dist/src/lib/swift-codegen/generator.d.ts +1 -0
- package/dist/src/lib/swift-codegen/generator.js +91 -3
- package/dist/src/lib/swift-codegen/generator.js.map +1 -1
- package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +90 -0
- package/dist/src/lib/swift-codegen/siblingSymbols.js +152 -0
- package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -0
- package/dist/src/lib/sync-resource-types.d.ts +222 -10
- package/dist/src/lib/sync-resource-types.js +407 -20
- package/dist/src/lib/sync-resource-types.js.map +1 -1
- package/dist/src/lib/template.d.ts +1 -1
- package/dist/src/lib/template.js +6 -3
- package/dist/src/lib/template.js.map +1 -1
- package/dist/src/lib/toml-metadata-config.js +18 -0
- package/dist/src/lib/toml-metadata-config.js.map +1 -1
- package/dist/src/lib/workflow-apply.js +12 -2
- package/dist/src/lib/workflow-apply.js.map +1 -1
- package/dist/src/lib/workflow-codegen/generator.d.ts +9 -0
- package/dist/src/lib/workflow-codegen/generator.js +126 -55
- package/dist/src/lib/workflow-codegen/generator.js.map +1 -1
- package/dist/src/lib/workflow-codegen/invokerIR.d.ts +6 -8
- package/dist/src/lib/workflow-codegen/invokerIR.js +8 -8
- package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -1
- package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +17 -1
- package/dist/src/lib/workflow-codegen/schemaToTs.js +59 -38
- package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -1
- package/dist/src/lib/workflow-payload.d.ts +19 -0
- package/dist/src/lib/workflow-payload.js +21 -0
- package/dist/src/lib/workflow-payload.js.map +1 -1
- package/dist/src/lib/workflow-toml-validator.d.ts +30 -0
- package/dist/src/lib/workflow-toml-validator.js +206 -0
- package/dist/src/lib/workflow-toml-validator.js.map +1 -1
- package/dist/src/types/index.d.ts +1 -0
- package/package.json +2 -1
|
@@ -31,8 +31,13 @@ import * as path from "path";
|
|
|
31
31
|
import { writeOrCheckGeneratedFiles, } from "../codegen-shared/generatedFiles.js";
|
|
32
32
|
import { fingerprintToml } from "../db-codegen/dbFingerprint.js";
|
|
33
33
|
import { describeWorkflowInvoker } from "../workflow-codegen/invokerIR.js";
|
|
34
|
-
import { renderSwiftRootType } from "./schemaToSwift.js";
|
|
34
|
+
import { renderSwiftRootType, SwiftCodegenError } from "./schemaToSwift.js";
|
|
35
35
|
import { structTypeName, workflowSwiftFactoryName } from "./swiftNaming.js";
|
|
36
|
+
// Foreign banner guarded against when a workflow run shares an output dir with
|
|
37
|
+
// the database Swift generator (issue #1653, class 3b). Function-time use only,
|
|
38
|
+
// so the generator.ts ↔ dbGenerator.ts import cycle resolves safely.
|
|
39
|
+
import { DB_SWIFT_BANNER_PREFIX } from "./dbGenerator.js";
|
|
40
|
+
import { assertNoRetainedSiblingCollision, assertNoForeignGeneratorSymbolCollision, } from "./siblingSymbols.js";
|
|
36
41
|
/** Suffix identifying a generated Swift file. */
|
|
37
42
|
export const GENERATED_SWIFT_FILE_SUFFIX = ".generated.swift";
|
|
38
43
|
/**
|
|
@@ -149,7 +154,18 @@ export function renderWorkflowSwiftFile(input) {
|
|
|
149
154
|
].join("\n");
|
|
150
155
|
const imports = ["import Foundation", `import ${CLIENT_MODULE}`].join("\n");
|
|
151
156
|
const content = [banner, imports, wf.inputDecl, wf.outputDecl, renderInvoker(wf)].join("\n\n") + "\n";
|
|
152
|
-
|
|
157
|
+
// Every top-level Swift symbol this file declares: the `<Key>Input` /
|
|
158
|
+
// `<Key>Output` types, the `<Key>Workflow` invoker struct, and its
|
|
159
|
+
// free-function factory. Enumerating ALL of them (issue #1653, Codex
|
|
160
|
+
// refinement) lets the run-scoped registry catch a cross-workflow collision on
|
|
161
|
+
// any of them, not just Input/Output.
|
|
162
|
+
const symbols = [
|
|
163
|
+
wf.inputTypeName,
|
|
164
|
+
wf.outputTypeName,
|
|
165
|
+
`${wf.base}Workflow`,
|
|
166
|
+
workflowSwiftFactoryName(wf.key),
|
|
167
|
+
];
|
|
168
|
+
return { key: wf.key, content, symbols };
|
|
153
169
|
}
|
|
154
170
|
/**
|
|
155
171
|
* Run Swift workflow codegen end-to-end. One `<key>.generated.swift` per
|
|
@@ -158,14 +174,78 @@ export function renderWorkflowSwiftFile(input) {
|
|
|
158
174
|
*/
|
|
159
175
|
export async function generateWorkflowSwiftTypes(options) {
|
|
160
176
|
const outAbs = path.resolve(options.outputDir);
|
|
177
|
+
// Run-scoped registry: emitted top-level Swift symbol → the workflow key that
|
|
178
|
+
// emitted it. Two DIFFERENT keys emitting the same symbol redeclare when all
|
|
179
|
+
// `.generated.swift` files compile into one module (issue #1653, class 1).
|
|
180
|
+
const symbolOwner = new Map();
|
|
161
181
|
const filesToWrite = new Map();
|
|
162
182
|
for (const input of options.inputs) {
|
|
163
183
|
const rendered = renderWorkflowSwiftFile(input);
|
|
164
184
|
if (!rendered)
|
|
165
|
-
continue; // reserved workflow — no file
|
|
185
|
+
continue; // reserved workflow — no file, no symbols
|
|
186
|
+
for (const symbol of rendered.symbols) {
|
|
187
|
+
const prior = symbolOwner.get(symbol);
|
|
188
|
+
if (prior !== undefined && prior !== rendered.key) {
|
|
189
|
+
throw new SwiftCodegenError(`swift workflow codegen: type-name collision — workflow keys ` +
|
|
190
|
+
`"${prior}" and "${rendered.key}" both produce Swift type ` +
|
|
191
|
+
`"${symbol}", which redeclare when all .generated.swift files ` +
|
|
192
|
+
`compile into one module. Rename one workflow key so the two differ ` +
|
|
193
|
+
`after Swift PascalCase normalization.`, { sourceFile: `workflows/${rendered.key}.toml` });
|
|
194
|
+
}
|
|
195
|
+
symbolOwner.set(symbol, rendered.key);
|
|
196
|
+
}
|
|
166
197
|
const filePath = path.join(outAbs, `${rendered.key}${GENERATED_SWIFT_FILE_SUFFIX}`);
|
|
167
198
|
filesToWrite.set(filePath, rendered.content);
|
|
168
199
|
}
|
|
200
|
+
// Filtered-run sibling collision (issue #1653, class 1 for `--single` runs).
|
|
201
|
+
// A `singleWorkflow` run renders only the selected key; its retained sibling
|
|
202
|
+
// `.generated.swift` files stay on disk but never enter `symbolOwner` above,
|
|
203
|
+
// so a symbol this run emits could still redeclare against a sibling once
|
|
204
|
+
// every file compiles into one module. The foreign-banner write guard does NOT
|
|
205
|
+
// cover this (siblings carry the SAME banner and a different filename, so there
|
|
206
|
+
// is no path or banner collision). Compare against the retained siblings' own
|
|
207
|
+
// declared symbols — no persistent manifest (sponsor decision #1).
|
|
208
|
+
if (options.singleWorkflow === true) {
|
|
209
|
+
await assertNoRetainedSiblingCollision({
|
|
210
|
+
outputDir: outAbs,
|
|
211
|
+
ownershipBanner: SWIFT_BANNER_PREFIX,
|
|
212
|
+
suffix: GENERATED_SWIFT_FILE_SUFFIX,
|
|
213
|
+
emitted: symbolOwner,
|
|
214
|
+
ownPaths: filesToWrite.keys(),
|
|
215
|
+
makeError: ({ symbol, owner, siblingStem }) => new SwiftCodegenError(`swift workflow codegen: type-name collision with a retained sibling — ` +
|
|
216
|
+
`workflow key "${owner}" (this run) and the existing ` +
|
|
217
|
+
`"${siblingStem}${GENERATED_SWIFT_FILE_SUFFIX}" both declare Swift ` +
|
|
218
|
+
`symbol "${symbol}", which redeclares when all .generated.swift files ` +
|
|
219
|
+
`compile into one module. A filtered (single-workflow) run does not ` +
|
|
220
|
+
`regenerate siblings, so both files coexist. Rename one workflow key, ` +
|
|
221
|
+
`or regenerate the whole output directory.`, { sourceFile: `workflows/${owner}.toml` }),
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
// Cross-generator namespace collision (issue #1857), the mirror of the check
|
|
225
|
+
// in the DB generator. A workflow's top-level symbol (`<Key>Input`, etc.) can
|
|
226
|
+
// match the namespace enum name a DATABASE-generated file already declares in
|
|
227
|
+
// a shared output dir — e.g. workflow `foo` emits a top-level struct `FooInput`
|
|
228
|
+
// while db type `foo-input` emits `public enum FooInput`. Their filenames
|
|
229
|
+
// differ, so the foreign-banner WRITE guard below (path-only) never trips, and
|
|
230
|
+
// the retained-sibling guard above only scans workflow-owned files. This scan
|
|
231
|
+
// reads the DB-owned siblings' declared top-level symbols and throws if any of
|
|
232
|
+
// this run's emitted symbols collides. It runs on every workflow run (not just
|
|
233
|
+
// filtered), because a full workflow run does not regenerate DB files — they
|
|
234
|
+
// coexist regardless of ordering.
|
|
235
|
+
await assertNoForeignGeneratorSymbolCollision({
|
|
236
|
+
outputDir: outAbs,
|
|
237
|
+
foreignBanner: DB_SWIFT_BANNER_PREFIX,
|
|
238
|
+
suffix: GENERATED_SWIFT_FILE_SUFFIX,
|
|
239
|
+
emitted: symbolOwner,
|
|
240
|
+
makeError: ({ symbol, owner, siblingStem }) => new SwiftCodegenError(`swift workflow codegen: type-name collision with a database-generated ` +
|
|
241
|
+
`file — workflow key "${owner}" emits Swift type "${symbol}", but the ` +
|
|
242
|
+
`existing "${siblingStem}${GENERATED_SWIFT_FILE_SUFFIX}" (owned by the ` +
|
|
243
|
+
`database Swift generator) already declares a top-level "${symbol}" in ` +
|
|
244
|
+
`the same output directory, which redeclares when all .generated.swift ` +
|
|
245
|
+
`files compile into one module. Rename the workflow or the ` +
|
|
246
|
+
`"${siblingStem}" database type so the two differ after Swift ` +
|
|
247
|
+
`normalization, or give one generator a separate --output directory.`, { sourceFile: `workflows/${owner}.toml` }),
|
|
248
|
+
});
|
|
169
249
|
return await writeOrCheckGeneratedFiles({
|
|
170
250
|
outputDir: outAbs,
|
|
171
251
|
filesToWrite,
|
|
@@ -173,6 +253,14 @@ export async function generateWorkflowSwiftTypes(options) {
|
|
|
173
253
|
fullOwnership: options.singleWorkflow !== true,
|
|
174
254
|
generatedSuffix: GENERATED_SWIFT_FILE_SUFFIX,
|
|
175
255
|
ownershipBanner: SWIFT_BANNER_PREFIX,
|
|
256
|
+
// Class 3b: never clobber a file owned by the database Swift generator.
|
|
257
|
+
foreignOwnershipBanners: [DB_SWIFT_BANNER_PREFIX],
|
|
258
|
+
onForeignBannerCollision: ({ filePath, foreignBanner }) => new SwiftCodegenError(`swift codegen: output collision — this run would overwrite ` +
|
|
259
|
+
`"${path.basename(filePath)}" in the shared output directory, which ` +
|
|
260
|
+
`is already owned by a different generator (banner ` +
|
|
261
|
+
`"${foreignBanner.trim()}"). A workflow key and a database type with ` +
|
|
262
|
+
`the same name cannot share an output directory; give one generator a ` +
|
|
263
|
+
`separate --output directory.`),
|
|
176
264
|
});
|
|
177
265
|
}
|
|
178
266
|
//# sourceMappingURL=generator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../src/lib/swift-codegen/generator.ts"],"names":[],"mappings":"AAAA;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
+
* Retained-sibling collision detection for filtered Swift codegen runs
|
|
3
|
+
* (issue #1653, class 3a for `--single` runs).
|
|
4
|
+
*
|
|
5
|
+
* A `singleType` / `singleWorkflow` run renders ONLY the selected input, but its
|
|
6
|
+
* sibling `.generated.swift` files stay on disk (they are deliberately retained
|
|
7
|
+
* — orphan cleanup is scoped to the filtered file). Those siblings never enter
|
|
8
|
+
* the run-scoped in-memory registry, which sees only `options.inputs`, so a
|
|
9
|
+
* symbol the filtered run emits could still redeclare against a sibling once all
|
|
10
|
+
* files compile into one module.
|
|
11
|
+
*
|
|
12
|
+
* The cross-generator foreign-banner write guard does NOT cover this: siblings
|
|
13
|
+
* carry the SAME ownership banner and a DIFFERENT filename, so there is neither a
|
|
14
|
+
* path collision nor a foreign banner to trip. This module closes that gap by
|
|
15
|
+
* re-deriving each retained sibling's declared top-level symbols directly from
|
|
16
|
+
* the file on disk and comparing them against the run's emitted symbols — no
|
|
17
|
+
* persistent symbol manifest (sponsor decision #1 reserved that for a follow-up).
|
|
18
|
+
*/
|
|
19
|
+
/** Parse the module-level Swift symbols declared in a generated file's source. */
|
|
20
|
+
export declare function parseTopLevelSwiftSymbols(content: string): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Map each retained sibling's declared top-level symbol → the sibling's file
|
|
23
|
+
* stem (its owner). Only generator-owned files (content starts with
|
|
24
|
+
* `ownershipBanner`) are considered; the run's own output paths are excluded so
|
|
25
|
+
* a filtered re-run never collides with the file it is about to rewrite. On the
|
|
26
|
+
* first sibling that declares a symbol, that sibling wins (deterministic by
|
|
27
|
+
* directory-read order).
|
|
28
|
+
*/
|
|
29
|
+
export declare function collectRetainedSiblingSymbols(opts: {
|
|
30
|
+
outputDir: string;
|
|
31
|
+
ownershipBanner: string;
|
|
32
|
+
suffix: string;
|
|
33
|
+
excludePaths: Iterable<string>;
|
|
34
|
+
}): Promise<Map<string, string>>;
|
|
35
|
+
/**
|
|
36
|
+
* Throw if any symbol this filtered run emits collides with a retained sibling
|
|
37
|
+
* already on disk. `emitted` maps symbol → the emitting input's owner key; a
|
|
38
|
+
* sibling owning the SAME symbol under a DIFFERENT stem is a redeclaration. The
|
|
39
|
+
* caller supplies `makeError` so the shared module stays free of the Swift
|
|
40
|
+
* error type.
|
|
41
|
+
*/
|
|
42
|
+
export declare function assertNoRetainedSiblingCollision(opts: {
|
|
43
|
+
outputDir: string;
|
|
44
|
+
ownershipBanner: string;
|
|
45
|
+
suffix: string;
|
|
46
|
+
emitted: Map<string, string>;
|
|
47
|
+
ownPaths: Iterable<string>;
|
|
48
|
+
makeError: (info: {
|
|
49
|
+
symbol: string;
|
|
50
|
+
owner: string;
|
|
51
|
+
siblingStem: string;
|
|
52
|
+
}) => Error;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Throw if any symbol this run emits collides with a top-level symbol declared
|
|
56
|
+
* by a file owned by ANOTHER generator (a DIFFERENT ownership banner) in the
|
|
57
|
+
* same output dir (issue #1857).
|
|
58
|
+
*
|
|
59
|
+
* The same-banner retained-sibling guard above and the foreign-banner WRITE
|
|
60
|
+
* guard both miss this class. When database and workflow Swift codegen share an
|
|
61
|
+
* output dir, a database type `foo-input` emits `public enum FooInput` in
|
|
62
|
+
* `foo-input.generated.swift`, while workflow `foo` emits a top-level struct
|
|
63
|
+
* `FooInput` in `foo.generated.swift`. The two symbols redeclare when the files
|
|
64
|
+
* compile into one module, but:
|
|
65
|
+
* - the retained-sibling guard only scans files carrying THIS generator's own
|
|
66
|
+
* banner, so it never reads the other generator's file; and
|
|
67
|
+
* - the foreign-banner write guard only fires on identical file PATHS, and
|
|
68
|
+
* these filenames differ.
|
|
69
|
+
* So both generators succeed and `swift build` fails with an invalid
|
|
70
|
+
* redeclaration. This guard closes the gap: whichever generator runs second
|
|
71
|
+
* finds the other's file already on disk and reports the clash. It intentionally
|
|
72
|
+
* runs on every run (full or filtered), because a full run does not regenerate
|
|
73
|
+
* the foreign generator's files — they always coexist.
|
|
74
|
+
*
|
|
75
|
+
* `emitted` maps symbol → the emitting input's owner key. A foreign file owning
|
|
76
|
+
* the SAME symbol is always a redeclaration: foreign files carry a different
|
|
77
|
+
* banner and (because same-path clashes are caught by the write guard) a
|
|
78
|
+
* different filename, so there is no self-collision to exclude.
|
|
79
|
+
*/
|
|
80
|
+
export declare function assertNoForeignGeneratorSymbolCollision(opts: {
|
|
81
|
+
outputDir: string;
|
|
82
|
+
foreignBanner: string;
|
|
83
|
+
suffix: string;
|
|
84
|
+
emitted: Map<string, string>;
|
|
85
|
+
makeError: (info: {
|
|
86
|
+
symbol: string;
|
|
87
|
+
owner: string;
|
|
88
|
+
siblingStem: string;
|
|
89
|
+
}) => Error;
|
|
90
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retained-sibling collision detection for filtered Swift codegen runs
|
|
3
|
+
* (issue #1653, class 3a for `--single` runs).
|
|
4
|
+
*
|
|
5
|
+
* A `singleType` / `singleWorkflow` run renders ONLY the selected input, but its
|
|
6
|
+
* sibling `.generated.swift` files stay on disk (they are deliberately retained
|
|
7
|
+
* — orphan cleanup is scoped to the filtered file). Those siblings never enter
|
|
8
|
+
* the run-scoped in-memory registry, which sees only `options.inputs`, so a
|
|
9
|
+
* symbol the filtered run emits could still redeclare against a sibling once all
|
|
10
|
+
* files compile into one module.
|
|
11
|
+
*
|
|
12
|
+
* The cross-generator foreign-banner write guard does NOT cover this: siblings
|
|
13
|
+
* carry the SAME ownership banner and a DIFFERENT filename, so there is neither a
|
|
14
|
+
* path collision nor a foreign banner to trip. This module closes that gap by
|
|
15
|
+
* re-deriving each retained sibling's declared top-level symbols directly from
|
|
16
|
+
* the file on disk and comparing them against the run's emitted symbols — no
|
|
17
|
+
* persistent symbol manifest (sponsor decision #1 reserved that for a follow-up).
|
|
18
|
+
*/
|
|
19
|
+
import * as path from "path";
|
|
20
|
+
import { promises as fsp } from "fs";
|
|
21
|
+
/**
|
|
22
|
+
* Top-level Swift declarations a generated file exposes to its module. Anchored
|
|
23
|
+
* to column 0 so nested (indented) enum/struct declarations and the `<Type>Ops`
|
|
24
|
+
* factory's struct methods are excluded — only module-level symbols can collide
|
|
25
|
+
* across files. A backtick-escaped reserved-word identifier is unescaped so the
|
|
26
|
+
* key matches what the emitter tracks in its registry.
|
|
27
|
+
*
|
|
28
|
+
* The identifier character class mirrors the emitter's alphabet in
|
|
29
|
+
* `swiftNaming.ts` exactly (`isLetter` = `\p{L}`, `isAsciiDigit` = ASCII `0`–`9`,
|
|
30
|
+
* plus `_`), so the parser recognizes precisely what the emitter can emit —
|
|
31
|
+
* including Unicode-letter identifiers like `ÉFlowInput` that an ASCII-only
|
|
32
|
+
* `[A-Za-z0-9_]+` capture would miss (issue #1705). The `u` flag makes `\p{L}`
|
|
33
|
+
* a valid Unicode property escape.
|
|
34
|
+
*/
|
|
35
|
+
const TOP_LEVEL_DECL = /^public (?:struct|typealias|enum|func)\s+`?([\p{L}0-9_]+)`?/u;
|
|
36
|
+
/** Parse the module-level Swift symbols declared in a generated file's source. */
|
|
37
|
+
export function parseTopLevelSwiftSymbols(content) {
|
|
38
|
+
const symbols = [];
|
|
39
|
+
for (const line of content.split("\n")) {
|
|
40
|
+
const m = TOP_LEVEL_DECL.exec(line);
|
|
41
|
+
if (m)
|
|
42
|
+
symbols.push(m[1]);
|
|
43
|
+
}
|
|
44
|
+
return symbols;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Map each retained sibling's declared top-level symbol → the sibling's file
|
|
48
|
+
* stem (its owner). Only generator-owned files (content starts with
|
|
49
|
+
* `ownershipBanner`) are considered; the run's own output paths are excluded so
|
|
50
|
+
* a filtered re-run never collides with the file it is about to rewrite. On the
|
|
51
|
+
* first sibling that declares a symbol, that sibling wins (deterministic by
|
|
52
|
+
* directory-read order).
|
|
53
|
+
*/
|
|
54
|
+
export async function collectRetainedSiblingSymbols(opts) {
|
|
55
|
+
const exclude = new Set([...opts.excludePaths].map((p) => path.resolve(p)));
|
|
56
|
+
const out = new Map();
|
|
57
|
+
let entries;
|
|
58
|
+
try {
|
|
59
|
+
entries = await fsp.readdir(opts.outputDir, { withFileTypes: true });
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return out; // output dir absent → no siblings
|
|
63
|
+
}
|
|
64
|
+
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
65
|
+
if (!entry.isFile() || !entry.name.endsWith(opts.suffix))
|
|
66
|
+
continue;
|
|
67
|
+
const filePath = path.resolve(opts.outputDir, entry.name);
|
|
68
|
+
if (exclude.has(filePath))
|
|
69
|
+
continue;
|
|
70
|
+
let content;
|
|
71
|
+
try {
|
|
72
|
+
content = await fsp.readFile(filePath, "utf-8");
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (!content.startsWith(opts.ownershipBanner))
|
|
78
|
+
continue; // not ours
|
|
79
|
+
const stem = entry.name.slice(0, -opts.suffix.length);
|
|
80
|
+
for (const symbol of parseTopLevelSwiftSymbols(content)) {
|
|
81
|
+
if (!out.has(symbol))
|
|
82
|
+
out.set(symbol, stem);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Throw if any symbol this filtered run emits collides with a retained sibling
|
|
89
|
+
* already on disk. `emitted` maps symbol → the emitting input's owner key; a
|
|
90
|
+
* sibling owning the SAME symbol under a DIFFERENT stem is a redeclaration. The
|
|
91
|
+
* caller supplies `makeError` so the shared module stays free of the Swift
|
|
92
|
+
* error type.
|
|
93
|
+
*/
|
|
94
|
+
export async function assertNoRetainedSiblingCollision(opts) {
|
|
95
|
+
const siblings = await collectRetainedSiblingSymbols({
|
|
96
|
+
outputDir: opts.outputDir,
|
|
97
|
+
ownershipBanner: opts.ownershipBanner,
|
|
98
|
+
suffix: opts.suffix,
|
|
99
|
+
excludePaths: opts.ownPaths,
|
|
100
|
+
});
|
|
101
|
+
if (siblings.size === 0)
|
|
102
|
+
return;
|
|
103
|
+
for (const [symbol, owner] of opts.emitted) {
|
|
104
|
+
const siblingStem = siblings.get(symbol);
|
|
105
|
+
if (siblingStem !== undefined && siblingStem !== owner) {
|
|
106
|
+
throw opts.makeError({ symbol, owner, siblingStem });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Throw if any symbol this run emits collides with a top-level symbol declared
|
|
112
|
+
* by a file owned by ANOTHER generator (a DIFFERENT ownership banner) in the
|
|
113
|
+
* same output dir (issue #1857).
|
|
114
|
+
*
|
|
115
|
+
* The same-banner retained-sibling guard above and the foreign-banner WRITE
|
|
116
|
+
* guard both miss this class. When database and workflow Swift codegen share an
|
|
117
|
+
* output dir, a database type `foo-input` emits `public enum FooInput` in
|
|
118
|
+
* `foo-input.generated.swift`, while workflow `foo` emits a top-level struct
|
|
119
|
+
* `FooInput` in `foo.generated.swift`. The two symbols redeclare when the files
|
|
120
|
+
* compile into one module, but:
|
|
121
|
+
* - the retained-sibling guard only scans files carrying THIS generator's own
|
|
122
|
+
* banner, so it never reads the other generator's file; and
|
|
123
|
+
* - the foreign-banner write guard only fires on identical file PATHS, and
|
|
124
|
+
* these filenames differ.
|
|
125
|
+
* So both generators succeed and `swift build` fails with an invalid
|
|
126
|
+
* redeclaration. This guard closes the gap: whichever generator runs second
|
|
127
|
+
* finds the other's file already on disk and reports the clash. It intentionally
|
|
128
|
+
* runs on every run (full or filtered), because a full run does not regenerate
|
|
129
|
+
* the foreign generator's files — they always coexist.
|
|
130
|
+
*
|
|
131
|
+
* `emitted` maps symbol → the emitting input's owner key. A foreign file owning
|
|
132
|
+
* the SAME symbol is always a redeclaration: foreign files carry a different
|
|
133
|
+
* banner and (because same-path clashes are caught by the write guard) a
|
|
134
|
+
* different filename, so there is no self-collision to exclude.
|
|
135
|
+
*/
|
|
136
|
+
export async function assertNoForeignGeneratorSymbolCollision(opts) {
|
|
137
|
+
const foreign = await collectRetainedSiblingSymbols({
|
|
138
|
+
outputDir: opts.outputDir,
|
|
139
|
+
ownershipBanner: opts.foreignBanner,
|
|
140
|
+
suffix: opts.suffix,
|
|
141
|
+
excludePaths: [], // foreign-banner files are never this run's own outputs
|
|
142
|
+
});
|
|
143
|
+
if (foreign.size === 0)
|
|
144
|
+
return;
|
|
145
|
+
for (const [symbol, owner] of opts.emitted) {
|
|
146
|
+
const siblingStem = foreign.get(symbol);
|
|
147
|
+
if (siblingStem !== undefined) {
|
|
148
|
+
throw opts.makeError({ symbol, owner, siblingStem });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=siblingSymbols.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"siblingSymbols.js","sourceRoot":"","sources":["../../../../src/lib/swift-codegen/siblingSymbols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,IAAI,GAAG,EAAE,MAAM,IAAI,CAAC;AAErC;;;;;;;;;;;;;GAaG;AACH,MAAM,cAAc,GAClB,8DAA8D,CAAC;AAEjE,kFAAkF;AAClF,MAAM,UAAU,yBAAyB,CAAC,OAAe;IACvD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,MAAM,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAAC,IAKnD;IACC,MAAM,OAAO,G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