@spine-event-engine/proto-tools 2.0.0-snapshot.10
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/LICENSE +201 -0
- package/README.md +103 -0
- package/REFERENCE.md +90 -0
- package/bin/spine-proto.mjs +2 -0
- package/dist/src/cli/spine-proto-bootstrap.d.ts +4 -0
- package/dist/src/cli/spine-proto-bootstrap.d.ts.map +1 -0
- package/dist/src/cli/spine-proto-bootstrap.js +52 -0
- package/dist/src/cli/spine-proto-bootstrap.js.map +1 -0
- package/dist/src/cli/spine-proto.d.ts +3 -0
- package/dist/src/cli/spine-proto.d.ts.map +1 -0
- package/dist/src/cli/spine-proto.js +32 -0
- package/dist/src/cli/spine-proto.js.map +1 -0
- package/dist/src/generation/authored-interface-provider.d.ts +28 -0
- package/dist/src/generation/authored-interface-provider.d.ts.map +1 -0
- package/dist/src/generation/authored-interface-provider.js +244 -0
- package/dist/src/generation/authored-interface-provider.js.map +1 -0
- package/dist/src/generation/build-time-handler-analyzer.d.ts +195 -0
- package/dist/src/generation/build-time-handler-analyzer.d.ts.map +1 -0
- package/dist/src/generation/build-time-handler-analyzer.js +1308 -0
- package/dist/src/generation/build-time-handler-analyzer.js.map +1 -0
- package/dist/src/generation/generated-registry-writer.d.ts +58 -0
- package/dist/src/generation/generated-registry-writer.d.ts.map +1 -0
- package/dist/src/generation/generated-registry-writer.js +465 -0
- package/dist/src/generation/generated-registry-writer.js.map +1 -0
- package/dist/src/generation/generated-source-policy.d.ts +21 -0
- package/dist/src/generation/generated-source-policy.d.ts.map +1 -0
- package/dist/src/generation/generated-source-policy.js +126 -0
- package/dist/src/generation/generated-source-policy.js.map +1 -0
- package/dist/src/generation/generation-reuse.mjs +106 -0
- package/dist/src/generation/generator.d.ts +195 -0
- package/dist/src/generation/generator.d.ts.map +1 -0
- package/dist/src/generation/generator.js +566 -0
- package/dist/src/generation/generator.js.map +1 -0
- package/dist/src/generation/handler-codegen.d.ts +48 -0
- package/dist/src/generation/handler-codegen.d.ts.map +1 -0
- package/dist/src/generation/handler-codegen.js +214 -0
- package/dist/src/generation/handler-codegen.js.map +1 -0
- package/dist/src/generation/handler-generator.d.ts +7 -0
- package/dist/src/generation/handler-generator.d.ts.map +1 -0
- package/dist/src/generation/handler-generator.js +55 -0
- package/dist/src/generation/handler-generator.js.map +1 -0
- package/dist/src/generation/interface-generator.d.ts +21 -0
- package/dist/src/generation/interface-generator.d.ts.map +1 -0
- package/dist/src/generation/interface-generator.js +277 -0
- package/dist/src/generation/interface-generator.js.map +1 -0
- package/dist/src/generation/interface-provider.d.ts +30 -0
- package/dist/src/generation/interface-provider.d.ts.map +1 -0
- package/dist/src/generation/interface-provider.js +15 -0
- package/dist/src/generation/interface-provider.js.map +1 -0
- package/dist/src/generation/rejection-generator.d.ts +9 -0
- package/dist/src/generation/rejection-generator.d.ts.map +1 -0
- package/dist/src/generation/rejection-generator.js +62 -0
- package/dist/src/generation/rejection-generator.js.map +1 -0
- package/dist/src/generation/source-view.d.ts +103 -0
- package/dist/src/generation/source-view.d.ts.map +1 -0
- package/dist/src/generation/source-view.js +298 -0
- package/dist/src/generation/source-view.js.map +1 -0
- package/dist/src/index.d.ts +139 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +546 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/io/atomic-manifest.d.ts +32 -0
- package/dist/src/io/atomic-manifest.d.ts.map +1 -0
- package/dist/src/io/atomic-manifest.js +56 -0
- package/dist/src/io/atomic-manifest.js.map +1 -0
- package/dist/src/io/manifest-reader.d.ts +8 -0
- package/dist/src/io/manifest-reader.d.ts.map +1 -0
- package/dist/src/io/manifest-reader.js +19 -0
- package/dist/src/io/manifest-reader.js.map +1 -0
- package/dist/src/model/model-graph.d.ts +68 -0
- package/dist/src/model/model-graph.d.ts.map +1 -0
- package/dist/src/model/model-graph.js +220 -0
- package/dist/src/model/model-graph.js.map +1 -0
- package/dist/src/model/npm-package-name.d.ts +7 -0
- package/dist/src/model/npm-package-name.d.ts.map +1 -0
- package/dist/src/model/npm-package-name.js +33 -0
- package/dist/src/model/npm-package-name.js.map +1 -0
- package/dist/src/model/registry-dependency.d.ts +10 -0
- package/dist/src/model/registry-dependency.d.ts.map +1 -0
- package/dist/src/model/registry-dependency.js +66 -0
- package/dist/src/model/registry-dependency.js.map +1 -0
- package/dist/src/testing/index.d.ts +8 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +20 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +54 -0
- package/scripts/clean-dist.mjs +7 -0
- package/scripts/copy-runtime-modules.mjs +23 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, CodeMatters. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
5
|
+
* in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
10
|
+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
11
|
+
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
|
+
* the License.
|
|
13
|
+
*/
|
|
14
|
+
import { lstatSync, mkdirSync, opendirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
15
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
16
|
+
import ts from "typescript";
|
|
17
|
+
import { BuildHandlerAnalyzer } from "./build-time-handler-analyzer.js";
|
|
18
|
+
import { GeneratedRegistryWriter } from "./generated-registry-writer.js";
|
|
19
|
+
const maxCompilerRoots = 1000;
|
|
20
|
+
const maxDiscoveryEntries = 1000;
|
|
21
|
+
const defaultOperations = {
|
|
22
|
+
mkdir: (path) => {
|
|
23
|
+
mkdirSync(path, { recursive: true });
|
|
24
|
+
},
|
|
25
|
+
write: (path, source) => {
|
|
26
|
+
writeFileSync(path, source, "utf8");
|
|
27
|
+
},
|
|
28
|
+
rename: renameSync,
|
|
29
|
+
remove: (path) => {
|
|
30
|
+
rmSync(path, { force: true });
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Creates and atomically replaces an application's generated handler registry from tooling.
|
|
35
|
+
*
|
|
36
|
+
* @param options Application root and generation configuration.
|
|
37
|
+
* @param operations Optional filesystem operations used for generation.
|
|
38
|
+
*/
|
|
39
|
+
export function generateHandlerRegistry(options, operations = {}) {
|
|
40
|
+
const appRoot = HandlerFiles.directory(resolve(options.appRoot), "Application root");
|
|
41
|
+
const project = HandlerFiles.file(appRoot, join(appRoot, "tsconfig.json"), "Project");
|
|
42
|
+
const generatedRoot = HandlerFiles.path(appRoot, join(appRoot, "generated"), "Generated root");
|
|
43
|
+
const outputFile = HandlerFiles.path(generatedRoot, join(generatedRoot, "handler/generated-handler-registry.ts"), "Generated output");
|
|
44
|
+
const { program, sources } = HandlerFiles.program(appRoot, project);
|
|
45
|
+
const analysis = BuildHandlerAnalyzer.analyze(program, sources);
|
|
46
|
+
if (analysis.diagnostics.length > 0)
|
|
47
|
+
throw new Error(HandlerFiles.diagnostics(analysis.diagnostics));
|
|
48
|
+
const source = new GeneratedRegistryWriter().render(analysis, { outputFile });
|
|
49
|
+
(operations.mkdir ?? defaultOperations.mkdir)(dirname(outputFile));
|
|
50
|
+
HandlerFiles.write(outputFile, source, operations);
|
|
51
|
+
}
|
|
52
|
+
const HandlerFiles = Object.freeze({
|
|
53
|
+
program(appRoot, project) {
|
|
54
|
+
const config = ts.readConfigFile(project, (path) => ts.sys.readFile(path));
|
|
55
|
+
if (config.error !== undefined)
|
|
56
|
+
throw new Error(HandlerFiles.configDiagnostics([config.error]));
|
|
57
|
+
HandlerFiles.assertIncludes(HandlerFiles.value(config.config, "include"), appRoot);
|
|
58
|
+
const parsed = ts.parseJsonConfigFileContent(config.config, HandlerFiles.configHost(appRoot, dirname(project)), dirname(project), undefined, project);
|
|
59
|
+
if (parsed.errors.length > 0)
|
|
60
|
+
throw new Error(HandlerFiles.configDiagnostics(parsed.errors));
|
|
61
|
+
if ((parsed.projectReferences?.length ?? 0) > 0)
|
|
62
|
+
throw new Error("Project references are not supported for handler generation.");
|
|
63
|
+
if (parsed.fileNames.length > maxCompilerRoots)
|
|
64
|
+
throw new Error(`Handler source count exceeds ${String(maxCompilerRoots)}.`);
|
|
65
|
+
const roots = parsed.fileNames.map((file) => HandlerFiles.typeScriptFile(appRoot, file));
|
|
66
|
+
const program = ts.createProgram({
|
|
67
|
+
rootNames: roots,
|
|
68
|
+
options: parsed.options,
|
|
69
|
+
...(parsed.projectReferences === undefined
|
|
70
|
+
? {}
|
|
71
|
+
: { projectReferences: parsed.projectReferences }),
|
|
72
|
+
});
|
|
73
|
+
const sources = roots
|
|
74
|
+
.map((root) => program.getSourceFile(root))
|
|
75
|
+
.filter(HandlerFiles.sourceFile);
|
|
76
|
+
return { program, sources };
|
|
77
|
+
},
|
|
78
|
+
assertIncludes(value, appRoot) {
|
|
79
|
+
if (!Array.isArray(value))
|
|
80
|
+
return;
|
|
81
|
+
for (const include of value) {
|
|
82
|
+
if (typeof include !== "string")
|
|
83
|
+
continue;
|
|
84
|
+
if (include.split(/[\\/]/u).includes(".."))
|
|
85
|
+
throw new Error(`Handler source must stay within ${appRoot}.`);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
value(value, key) {
|
|
89
|
+
if (typeof value !== "object" || value === null)
|
|
90
|
+
return undefined;
|
|
91
|
+
return value[key];
|
|
92
|
+
},
|
|
93
|
+
configHost(appRoot, currentDirectory) {
|
|
94
|
+
let entries = 0;
|
|
95
|
+
// TypeScript 6.0.3 exports matchFiles at runtime but omits it from its declarations.
|
|
96
|
+
const matchFiles = ts.matchFiles;
|
|
97
|
+
return {
|
|
98
|
+
useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
|
|
99
|
+
readDirectory: (path, extensions, excludes, includes, depth) => matchFiles(path, extensions, excludes, includes, ts.sys.useCaseSensitiveFileNames, currentDirectory, depth, (directory) => {
|
|
100
|
+
const resolvedDirectory = resolve(currentDirectory, directory);
|
|
101
|
+
HandlerFiles.containedPath(appRoot, resolvedDirectory, "Handler discovery directory");
|
|
102
|
+
const files = [];
|
|
103
|
+
const directories = [];
|
|
104
|
+
const handle = opendirSync(resolvedDirectory);
|
|
105
|
+
try {
|
|
106
|
+
let entry;
|
|
107
|
+
while ((entry = handle.readSync()) !== null) {
|
|
108
|
+
entries += 1;
|
|
109
|
+
if (entries > maxDiscoveryEntries)
|
|
110
|
+
throw new Error(`Handler discovery entry count exceeds ${String(maxDiscoveryEntries)}.`);
|
|
111
|
+
const candidate = join(resolvedDirectory, entry.name);
|
|
112
|
+
if (lstatSync(candidate).isSymbolicLink())
|
|
113
|
+
throw new Error(`Handler discovery must not traverse symlink: ${candidate}`);
|
|
114
|
+
if (entry.isDirectory())
|
|
115
|
+
directories.push(entry.name);
|
|
116
|
+
else if (entry.isFile())
|
|
117
|
+
files.push(entry.name);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
handle.closeSync();
|
|
122
|
+
}
|
|
123
|
+
return { files, directories };
|
|
124
|
+
}, (path) => ts.sys.realpath?.(path) ?? path),
|
|
125
|
+
fileExists: (path) => ts.sys.fileExists(path),
|
|
126
|
+
readFile: (path) => ts.sys.readFile(path),
|
|
127
|
+
trace: () => undefined,
|
|
128
|
+
directoryExists: (path) => ts.sys.directoryExists(path),
|
|
129
|
+
realpath: (path) => ts.sys.realpath?.(path) ?? path,
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
sourceFile(value) {
|
|
133
|
+
return value !== undefined;
|
|
134
|
+
},
|
|
135
|
+
diagnostics(diagnostics) {
|
|
136
|
+
return diagnostics
|
|
137
|
+
.map((diagnostic) => {
|
|
138
|
+
const location = `${diagnostic.sourceFile}:${String(diagnostic.line)}:` + String(diagnostic.column);
|
|
139
|
+
return `${location} ${diagnostic.code} ${diagnostic.message}`;
|
|
140
|
+
})
|
|
141
|
+
.join("\n");
|
|
142
|
+
},
|
|
143
|
+
configDiagnostics(diagnostics) {
|
|
144
|
+
return ts.formatDiagnosticsWithColorAndContext(diagnostics, {
|
|
145
|
+
getCanonicalFileName: (fileName) => fileName,
|
|
146
|
+
getCurrentDirectory: () => process.cwd(),
|
|
147
|
+
getNewLine: () => "\n",
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
file(root, value, label) {
|
|
151
|
+
const path = HandlerFiles.path(root, value, label);
|
|
152
|
+
if (!lstatSync(path).isFile())
|
|
153
|
+
throw new Error(`${label} must be a regular file: ${path}`);
|
|
154
|
+
return path;
|
|
155
|
+
},
|
|
156
|
+
typeScriptFile(root, value) {
|
|
157
|
+
if (!value.endsWith(".ts") || value.endsWith(".d.ts"))
|
|
158
|
+
throw new Error(`Handler source must be a TypeScript file: ${value}`);
|
|
159
|
+
return HandlerFiles.file(root, value, "Handler source");
|
|
160
|
+
},
|
|
161
|
+
directory(path, label) {
|
|
162
|
+
HandlerFiles.assertNoSymlinkAncestors(path, label);
|
|
163
|
+
if (!lstatSync(path).isDirectory())
|
|
164
|
+
throw new Error(`${label} must be a directory: ${path}`);
|
|
165
|
+
return path;
|
|
166
|
+
},
|
|
167
|
+
path(root, path, label) {
|
|
168
|
+
const value = relative(root, path);
|
|
169
|
+
if (value === "" || value.startsWith("..") || isAbsolute(value))
|
|
170
|
+
throw new Error(`${label} must stay within ${root}.`);
|
|
171
|
+
HandlerFiles.assertNoSymlinkAncestors(path, label);
|
|
172
|
+
return path;
|
|
173
|
+
},
|
|
174
|
+
containedPath(root, path, label) {
|
|
175
|
+
const value = relative(root, path);
|
|
176
|
+
if (value.startsWith("..") || isAbsolute(value))
|
|
177
|
+
throw new Error(`${label} must stay within ${root}.`);
|
|
178
|
+
HandlerFiles.assertNoSymlinkAncestors(path, label);
|
|
179
|
+
return path;
|
|
180
|
+
},
|
|
181
|
+
assertNoSymlinkAncestors(path, label) {
|
|
182
|
+
const parts = resolve(path).split(sep).filter(Boolean);
|
|
183
|
+
let current = sep;
|
|
184
|
+
for (const part of parts) {
|
|
185
|
+
current = join(current, part);
|
|
186
|
+
try {
|
|
187
|
+
if (lstatSync(current).isSymbolicLink())
|
|
188
|
+
throw new Error(`${label} must not use a symlink path.`);
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
if (error.code !== "ENOENT")
|
|
192
|
+
throw error;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
write(outputFile, source, operations) {
|
|
197
|
+
const fileOperations = { ...defaultOperations, ...operations };
|
|
198
|
+
const stage = join(dirname(outputFile), `.${basename(outputFile)}.${String(process.pid)}.${crypto.randomUUID()}.tmp`);
|
|
199
|
+
try {
|
|
200
|
+
fileOperations.write(stage, source);
|
|
201
|
+
fileOperations.rename(stage, outputFile);
|
|
202
|
+
}
|
|
203
|
+
catch (primary) {
|
|
204
|
+
try {
|
|
205
|
+
fileOperations.remove(stage);
|
|
206
|
+
}
|
|
207
|
+
catch (cleanup) {
|
|
208
|
+
throw new AggregateError([primary, cleanup], "Generated handler registry publication failed.");
|
|
209
|
+
}
|
|
210
|
+
throw primary;
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
//# sourceMappingURL=handler-codegen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler-codegen.js","sourceRoot":"","sources":["../../../src/generation/handler-codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/F,OAAO,EAAE,QAAQ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Ac,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC/B,CAAC;YAAC,OAAO,OAAO,EAAE,CAAC;gBACjB,MAAM,IAAI,cAAc,CACtB,CAAC,OAAO,EAAE,OAAO,CAAC,EAClB,gDAAgD,CACjD,CAAC;YACJ,CAAC;YACD,MAAM,OAAO,CAAC;QAChB,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler-generator.d.ts","sourceRoot":"","sources":["../../../src/generation/handler-generator.ts"],"names":[],"mappings":"AAoBA;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC;IAAE,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAsChF,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, CodeMatters. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
5
|
+
* in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
10
|
+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
11
|
+
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
|
+
* the License.
|
|
13
|
+
*/
|
|
14
|
+
import { generateHandlerRegistry } from "./handler-codegen.js";
|
|
15
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
16
|
+
import { join } from "node:path";
|
|
17
|
+
import { ProtoConfig, ProtoManifest } from "../index.js";
|
|
18
|
+
import { generatedSource } from "./generated-source-policy.js";
|
|
19
|
+
/**
|
|
20
|
+
* Generates application handler registries.
|
|
21
|
+
*/
|
|
22
|
+
export const HandlerGeneration = Object.freeze({
|
|
23
|
+
// prettier-ignore
|
|
24
|
+
/**
|
|
25
|
+
* Generates an application's conventional handler registry from its TypeScript project.
|
|
26
|
+
*
|
|
27
|
+
* @param applicationRoot The application package root.
|
|
28
|
+
* @returns Nothing.
|
|
29
|
+
*/
|
|
30
|
+
generate(applicationRoot) {
|
|
31
|
+
const config = existsSync(join(applicationRoot, "spine-proto.json"))
|
|
32
|
+
? ProtoConfig.read(applicationRoot)
|
|
33
|
+
: undefined;
|
|
34
|
+
const sources = config?.mode === "application"
|
|
35
|
+
? config.modelPackages.flatMap((modelPackage) => {
|
|
36
|
+
const modelRoot = join(applicationRoot, "node_modules", modelPackage);
|
|
37
|
+
const manifest = join(modelRoot, "spine-proto-manifest.json");
|
|
38
|
+
if (existsSync(manifest))
|
|
39
|
+
return ProtoManifest.read(modelRoot).protoFiles;
|
|
40
|
+
const module = join(modelRoot, "dist", "generated", "proto-module.js");
|
|
41
|
+
return existsSync(module)
|
|
42
|
+
? [...readFileSync(module, "utf8").matchAll(/^ \* Source Proto: (.+)$/gmu)].map((match) => match[1] ?? "")
|
|
43
|
+
: [];
|
|
44
|
+
})
|
|
45
|
+
: [];
|
|
46
|
+
if (sources.length === 0)
|
|
47
|
+
throw new Error("spine-proto: handler generation requires model Proto provenance");
|
|
48
|
+
generateHandlerRegistry({ appRoot: applicationRoot }, {
|
|
49
|
+
write(path, source) {
|
|
50
|
+
writeFileSync(path, generatedSource(source, sources), "utf8");
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=handler-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler-generator.js","sourceRoot":"","sources":["../../../src/generation/handler-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAA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YACT,CAAC,CAAC;YACJ,CAAC,CAAC,EAAE,CAAC;QACP,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;QACrF,uBAAuB,CACrB,EAAE,OAAO,EAAE,eAAe,EAAE,EAC5B;YACE,KAAK,CAAC,IAAI,EAAE,MAAM;gBAChB,aAAa,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC;YAChE,CAAC;SACF,CACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Schema } from "@bufbuild/protoplugin";
|
|
2
|
+
import type { InterfaceDeclarationProvider } from "./interface-provider.js";
|
|
3
|
+
import type { ModelSourceView } from "./source-view.js";
|
|
4
|
+
/**
|
|
5
|
+
* Reads the immutable source-view handoff for the post-Buf interface phase.
|
|
6
|
+
*
|
|
7
|
+
* @param cwd Plugin working directory containing its staged `output` tree.
|
|
8
|
+
* @returns A validated source view, or undefined when no handoff was supplied.
|
|
9
|
+
*/
|
|
10
|
+
export declare function stagedSourceView(cwd?: string): ModelSourceView | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Generates file-scoped empty TypeScript interfaces and nominal schema tokens.
|
|
13
|
+
*
|
|
14
|
+
* Provider-resolved authored declarations are emitted when a compatible
|
|
15
|
+
* discovery provider supplies them; unresolved declarations are omitted.
|
|
16
|
+
*/
|
|
17
|
+
export declare const InterfaceGenerator: Readonly<{
|
|
18
|
+
generateCompanions(schema: Schema): void;
|
|
19
|
+
generateWithProvider(schema: Schema, provider: InterfaceDeclarationProvider, sourceView?: ModelSourceView): void;
|
|
20
|
+
}>;
|
|
21
|
+
//# sourceMappingURL=interface-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface-generator.d.ts","sourceRoot":"","sources":["../../../src/generation/interface-generator.ts"],"names":[],"mappings":"AAeA,OAAO,EAAqC,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAKvF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAWxD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAsB,GAAG,eAAe,GAAG,SAAS,CAsEzF;AAqGD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC;IACxC,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,oBAAoB,CAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,4BAA4B,EACtC,UAAU,CAAC,EAAE,eAAe,GAC3B,IAAI,CAAC;CACT,CAsIC,CAAC"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, CodeMatters. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
5
|
+
* in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
10
|
+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
11
|
+
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
|
+
* the License.
|
|
13
|
+
*/
|
|
14
|
+
import { getOption } from "@bufbuild/protobuf";
|
|
15
|
+
import { createEcmaScriptPlugin, runNodeJs } from "@bufbuild/protoplugin";
|
|
16
|
+
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
19
|
+
const authoredProviderModule = (await import(import.meta.url.endsWith(".ts")
|
|
20
|
+
? "./authored-interface-provider.ts"
|
|
21
|
+
: "./authored-interface-provider.js"));
|
|
22
|
+
const { AuthoredInterfaceProvider } = authoredProviderModule;
|
|
23
|
+
const typescriptIdentifier = /^[A-Za-z_$][A-Za-z0-9_$]*$/u;
|
|
24
|
+
/**
|
|
25
|
+
* Reads the immutable source-view handoff for the post-Buf interface phase.
|
|
26
|
+
*
|
|
27
|
+
* @param cwd Plugin working directory containing its staged `output` tree.
|
|
28
|
+
* @returns A validated source view, or undefined when no handoff was supplied.
|
|
29
|
+
*/
|
|
30
|
+
export function stagedSourceView(cwd = process.cwd()) {
|
|
31
|
+
const path = join(cwd, ".spine-source-view.json");
|
|
32
|
+
if (!existsSync(path))
|
|
33
|
+
return undefined;
|
|
34
|
+
const value = JSON.parse(readFileSync(path, "utf8"));
|
|
35
|
+
if (value === null || typeof value !== "object")
|
|
36
|
+
throw new Error("spine-proto: invalid staged source view");
|
|
37
|
+
const view = value;
|
|
38
|
+
const expectedStage = resolve(cwd, "output");
|
|
39
|
+
const within = (root, path) => {
|
|
40
|
+
const pathRelative = relative(root, path);
|
|
41
|
+
return pathRelative === "" || (!pathRelative.startsWith("..") && !isAbsolute(pathRelative));
|
|
42
|
+
};
|
|
43
|
+
if (typeof view.packageRoot !== "string" ||
|
|
44
|
+
typeof view.stagedGeneratedRoot !== "string" ||
|
|
45
|
+
typeof view.liveGeneratedRoot !== "string" ||
|
|
46
|
+
!Array.isArray(view.authoredFiles) ||
|
|
47
|
+
!Array.isArray(view.compilerFiles))
|
|
48
|
+
throw new Error("spine-proto: invalid staged source view");
|
|
49
|
+
const packageRoot = view.packageRoot;
|
|
50
|
+
const stagedGeneratedRoot = view.stagedGeneratedRoot;
|
|
51
|
+
const liveGeneratedRoot = view.liveGeneratedRoot;
|
|
52
|
+
const rawAuthoredFiles = view.authoredFiles;
|
|
53
|
+
const rawCompilerFiles = view.compilerFiles;
|
|
54
|
+
const authoredFiles = rawAuthoredFiles.filter((file) => typeof file === "string");
|
|
55
|
+
const compilerFiles = rawCompilerFiles.filter((file) => typeof file === "string");
|
|
56
|
+
const liveParent = dirname(liveGeneratedRoot);
|
|
57
|
+
const liveName = basename(liveGeneratedRoot);
|
|
58
|
+
const transactionStage = join(liveParent, `.${liveName}.stage-`);
|
|
59
|
+
const transactionBackup = join(liveParent, `.${liveName}.`);
|
|
60
|
+
const isTransactionArtifact = (file) => file.startsWith(transactionStage) ||
|
|
61
|
+
(file.startsWith(transactionBackup) && file.includes(".backup"));
|
|
62
|
+
if (!isAbsolute(packageRoot) ||
|
|
63
|
+
resolve(packageRoot) !== packageRoot ||
|
|
64
|
+
!isAbsolute(stagedGeneratedRoot) ||
|
|
65
|
+
resolve(stagedGeneratedRoot) !== stagedGeneratedRoot ||
|
|
66
|
+
stagedGeneratedRoot !== expectedStage ||
|
|
67
|
+
!isAbsolute(liveGeneratedRoot) ||
|
|
68
|
+
resolve(liveGeneratedRoot) !== liveGeneratedRoot ||
|
|
69
|
+
!within(packageRoot, liveGeneratedRoot) ||
|
|
70
|
+
authoredFiles.length !== rawAuthoredFiles.length ||
|
|
71
|
+
compilerFiles.length !== rawCompilerFiles.length ||
|
|
72
|
+
authoredFiles.some((file) => !compilerFiles.includes(file)) ||
|
|
73
|
+
[...authoredFiles, ...compilerFiles].some((file) => !isAbsolute(file) ||
|
|
74
|
+
resolve(file) !== file ||
|
|
75
|
+
!within(packageRoot, file) ||
|
|
76
|
+
within(liveGeneratedRoot, file) ||
|
|
77
|
+
within(stagedGeneratedRoot, file) ||
|
|
78
|
+
isTransactionArtifact(file)))
|
|
79
|
+
throw new Error("spine-proto: invalid staged source view");
|
|
80
|
+
return Object.freeze({
|
|
81
|
+
authoredFiles: Object.freeze(authoredFiles.map((file) => file)),
|
|
82
|
+
compilerFiles: Object.freeze(compilerFiles.map((file) => file)),
|
|
83
|
+
liveGeneratedRoot,
|
|
84
|
+
packageRoot,
|
|
85
|
+
stagedGeneratedRoot,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
const reservedTypeScriptWords = new Set([
|
|
89
|
+
"await",
|
|
90
|
+
"break",
|
|
91
|
+
"case",
|
|
92
|
+
"catch",
|
|
93
|
+
"class",
|
|
94
|
+
"const",
|
|
95
|
+
"continue",
|
|
96
|
+
"debugger",
|
|
97
|
+
"default",
|
|
98
|
+
"delete",
|
|
99
|
+
"do",
|
|
100
|
+
"else",
|
|
101
|
+
"enum",
|
|
102
|
+
"export",
|
|
103
|
+
"extends",
|
|
104
|
+
"false",
|
|
105
|
+
"finally",
|
|
106
|
+
"for",
|
|
107
|
+
"function",
|
|
108
|
+
"if",
|
|
109
|
+
"implements",
|
|
110
|
+
"import",
|
|
111
|
+
"in",
|
|
112
|
+
"instanceof",
|
|
113
|
+
"interface",
|
|
114
|
+
"let",
|
|
115
|
+
"new",
|
|
116
|
+
"null",
|
|
117
|
+
"package",
|
|
118
|
+
"private",
|
|
119
|
+
"protected",
|
|
120
|
+
"public",
|
|
121
|
+
"return",
|
|
122
|
+
"super",
|
|
123
|
+
"switch",
|
|
124
|
+
"static",
|
|
125
|
+
"this",
|
|
126
|
+
"throw",
|
|
127
|
+
"true",
|
|
128
|
+
"try",
|
|
129
|
+
"typeof",
|
|
130
|
+
"var",
|
|
131
|
+
"void",
|
|
132
|
+
"while",
|
|
133
|
+
"with",
|
|
134
|
+
"yield",
|
|
135
|
+
]);
|
|
136
|
+
const protoPackage = "@spine-event-engine/proto";
|
|
137
|
+
const packagedOptions = (await import(protoPackage).catch(() => undefined));
|
|
138
|
+
function optionExtension(files, name) {
|
|
139
|
+
const visited = new Set();
|
|
140
|
+
const find = (candidates) => {
|
|
141
|
+
for (const file of candidates) {
|
|
142
|
+
if (visited.has(file))
|
|
143
|
+
continue;
|
|
144
|
+
visited.add(file);
|
|
145
|
+
const extension = file.extensions.find((candidate) => candidate.name === name);
|
|
146
|
+
if (extension !== undefined)
|
|
147
|
+
return extension;
|
|
148
|
+
const nested = find(file.dependencies);
|
|
149
|
+
if (nested !== undefined)
|
|
150
|
+
return nested;
|
|
151
|
+
}
|
|
152
|
+
return undefined;
|
|
153
|
+
};
|
|
154
|
+
const extension = find(files);
|
|
155
|
+
if (extension !== undefined)
|
|
156
|
+
return extension;
|
|
157
|
+
const packaged = name === "every_is" ? packagedOptions?.every_is : packagedOptions?.is;
|
|
158
|
+
if (packaged !== undefined)
|
|
159
|
+
return packaged;
|
|
160
|
+
throw new Error(`spine-proto: missing (${name}) option descriptor`);
|
|
161
|
+
}
|
|
162
|
+
function companionPath(name) {
|
|
163
|
+
return `interfaces/${name.replace(/([a-z0-9])([A-Z])/gu, "$1-$2").toLowerCase()}.ts`;
|
|
164
|
+
}
|
|
165
|
+
function collectMessages(messages) {
|
|
166
|
+
return messages.flatMap((message) => [message, ...collectMessages(message.nestedMessages)]);
|
|
167
|
+
}
|
|
168
|
+
function assertTypeName(name, source) {
|
|
169
|
+
if (!typescriptIdentifier.test(name) || reservedTypeScriptWords.has(name)) {
|
|
170
|
+
throw new Error(`spine-proto: ${source}: ts_type must be a non-empty TypeScript identifier`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function validateMessageDeclarations(isOption, file) {
|
|
174
|
+
for (const message of collectMessages(file.messages)) {
|
|
175
|
+
const option = getOption(message, isOption);
|
|
176
|
+
if (option.tsType.length > 0)
|
|
177
|
+
assertTypeName(option.tsType, `${file.proto.name}:${message.name}`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Generates file-scoped empty TypeScript interfaces and nominal schema tokens.
|
|
182
|
+
*
|
|
183
|
+
* Provider-resolved authored declarations are emitted when a compatible
|
|
184
|
+
* discovery provider supplies them; unresolved declarations are omitted.
|
|
185
|
+
*/
|
|
186
|
+
export const InterfaceGenerator = Object.freeze({
|
|
187
|
+
generateCompanions(schema) {
|
|
188
|
+
InterfaceGenerator.generateWithProvider(schema, new AuthoredInterfaceProvider());
|
|
189
|
+
},
|
|
190
|
+
generateWithProvider(schema, provider, suppliedSourceView) {
|
|
191
|
+
const optionFiles = schema.allFiles ?? schema.files;
|
|
192
|
+
const everyIs = optionExtension(optionFiles, "every_is");
|
|
193
|
+
const isOption = optionExtension(optionFiles, "is");
|
|
194
|
+
const sourceView = suppliedSourceView ?? stagedSourceView();
|
|
195
|
+
const authored = new Map();
|
|
196
|
+
const generated = new Map();
|
|
197
|
+
for (const file of schema.files) {
|
|
198
|
+
validateMessageDeclarations(isOption, file);
|
|
199
|
+
for (const message of collectMessages(file.messages)) {
|
|
200
|
+
const declaration = getOption(message, isOption);
|
|
201
|
+
if (declaration.tsType.length === 0)
|
|
202
|
+
continue;
|
|
203
|
+
const members = authored.get(declaration.tsType) ?? [];
|
|
204
|
+
members.push(message);
|
|
205
|
+
authored.set(declaration.tsType, members);
|
|
206
|
+
}
|
|
207
|
+
const declaration = getOption(file, everyIs);
|
|
208
|
+
if (declaration.generate) {
|
|
209
|
+
assertTypeName(declaration.tsType, file.proto.name);
|
|
210
|
+
if (generated.has(declaration.tsType))
|
|
211
|
+
throw new Error(`spine-proto: ${file.proto.name}: duplicate generated interface name`);
|
|
212
|
+
generated.set(declaration.tsType, { file, members: collectMessages(file.messages) });
|
|
213
|
+
}
|
|
214
|
+
else if (declaration.tsType.length > 0) {
|
|
215
|
+
const members = authored.get(declaration.tsType) ?? [];
|
|
216
|
+
members.push(...collectMessages(file.messages));
|
|
217
|
+
authored.set(declaration.tsType, members);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
for (const name of authored.keys()) {
|
|
221
|
+
if (generated.has(name))
|
|
222
|
+
throw new Error(`spine-proto: generated and authored interface names conflict`);
|
|
223
|
+
}
|
|
224
|
+
const paths = new Set();
|
|
225
|
+
for (const name of [...generated.keys(), ...authored.keys()]) {
|
|
226
|
+
const path = companionPath(name);
|
|
227
|
+
if (paths.has(path))
|
|
228
|
+
throw new Error(`spine-proto: duplicate interface companion path ${path}`);
|
|
229
|
+
paths.add(path);
|
|
230
|
+
}
|
|
231
|
+
const resolved = [...authored.entries()].map(([name, members]) => ({
|
|
232
|
+
name,
|
|
233
|
+
members,
|
|
234
|
+
declaration: provider.resolve(name, members, sourceView),
|
|
235
|
+
}));
|
|
236
|
+
for (const candidate of generated.values()) {
|
|
237
|
+
if (candidate.members.length === 0)
|
|
238
|
+
throw new Error(`${candidate.file.proto.name}: every_is cannot target an empty message set`);
|
|
239
|
+
}
|
|
240
|
+
for (const candidate of resolved) {
|
|
241
|
+
if (candidate.declaration !== undefined &&
|
|
242
|
+
(candidate.declaration.name !== candidate.name ||
|
|
243
|
+
candidate.declaration.importPath.length === 0))
|
|
244
|
+
throw new Error("spine-proto: authored interface provider returned an irreconcilable declaration");
|
|
245
|
+
}
|
|
246
|
+
for (const [name, candidate] of generated) {
|
|
247
|
+
const members = candidate.members;
|
|
248
|
+
const output = schema.generateFile(companionPath(name));
|
|
249
|
+
const define = output.import("MessageInterfaces", "@spine-event-engine/core");
|
|
250
|
+
const token = output.import("MessageInterface", "@spine-event-engine/core", true);
|
|
251
|
+
const schemaImports = members.map((member) => output.importSchema(member));
|
|
252
|
+
output.preamble(candidate.file);
|
|
253
|
+
output.print("/** Generated file-level message interface. */\n", `export interface ${name} {}\n\n`, "const memberSchemas: readonly [", ...schemaImports.flatMap((member, index) => index === 0 ? ["typeof ", member] : [", typeof ", member]), "] = [", ...schemaImports.flatMap((member, index) => (index === 0 ? [member] : [", ", member])), "];\n\n", "/** Generated nominal runtime token for this message interface. */\n", output.export("const", name), ": ", token, `<${name}, typeof memberSchemas> = `, define, `.define<${name}, typeof memberSchemas>(memberSchemas);\n`);
|
|
254
|
+
}
|
|
255
|
+
for (const candidate of resolved) {
|
|
256
|
+
if (candidate.declaration === undefined)
|
|
257
|
+
continue;
|
|
258
|
+
const output = schema.generateFile(companionPath(candidate.name));
|
|
259
|
+
const define = output.import("MessageInterfaces", "@spine-event-engine/core");
|
|
260
|
+
const token = output.import("MessageInterface", "@spine-event-engine/core", true);
|
|
261
|
+
const schemaImports = candidate.members.map((member) => output.importSchema(member));
|
|
262
|
+
const sourceFile = candidate.members[0]?.file;
|
|
263
|
+
if (sourceFile === undefined)
|
|
264
|
+
throw new Error("spine-proto: authored interface has no members");
|
|
265
|
+
output.preamble(sourceFile);
|
|
266
|
+
output.print(`import type { ${candidate.declaration.name} as Authored${candidate.name} } from ${JSON.stringify(candidate.declaration.importPath)};\n\n`, `export type ${candidate.name} = Authored${candidate.name};\n\n`, "const memberSchemas: readonly [", ...schemaImports.flatMap((member, index) => index === 0 ? ["typeof ", member] : [", typeof ", member]), "] = [", ...schemaImports.flatMap((member, index) => (index === 0 ? [member] : [", ", member])), `];\n\nexport const ${candidate.name}: `, token, `<Authored${candidate.name}, typeof memberSchemas> = `, define, `.define<Authored${candidate.name}, typeof memberSchemas>(memberSchemas);\n`);
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
const interfacePlugin = createEcmaScriptPlugin({
|
|
271
|
+
name: "protoc-gen-spine-interfaces",
|
|
272
|
+
version: "1.0.0",
|
|
273
|
+
generateTs: InterfaceGenerator.generateCompanions,
|
|
274
|
+
});
|
|
275
|
+
if (process.argv[1] !== undefined && resolve(process.argv[1]) === fileURLToPath(import.meta.url))
|
|
276
|
+
runNodeJs(interfacePlugin);
|
|
277
|
+
//# sourceMappingURL=interface-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface-generator.js","sourceRoot":"","sources":["../../../src/generation/interface-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAuD,MAAM,oBAAoB,CAAC;AACpG,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAe,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EAAE,aAAa,EAA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