@lunora/codegen 1.0.0-alpha.3 → 1.0.0-alpha.31
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__/package-og.svg +1 -1
- package/dist/index.d.mts +1084 -25
- package/dist/index.d.ts +1084 -25
- package/dist/index.mjs +29 -23
- package/dist/packem_shared/{CONTAINERS_FILENAME-0K-pjNb8.mjs → CONTAINERS_FILENAME-DjpXMqhp.mjs} +1 -1
- package/dist/packem_shared/{CodegenDiagnosticError-54jWDxA9.mjs → CodegenDiagnosticError-DyQ5FwkM.mjs} +7 -5
- package/dist/packem_shared/FLAGS_FILENAME-BjpS5w08.mjs +139 -0
- package/dist/packem_shared/{GENERATED_HEADER-CuLyj0WQ.mjs → GENERATED_HEADER-f6nMvllu.mjs} +853 -65
- package/dist/packem_shared/MUTATORS_FILENAME-BZOfUhlY.mjs +81 -0
- package/dist/packem_shared/{OPENRPC_VERSION-BGUrsrt_.mjs → OPENRPC_VERSION-u5SqDDGk.mjs} +1 -1
- package/dist/packem_shared/QUEUES_FILENAME-BF0iUmx7.mjs +119 -0
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-Ca-TlVEc.mjs +3481 -0
- package/dist/packem_shared/{SCHEMA_SNAPSHOT_VERSION-DzLDbWk3.mjs → SCHEMA_SNAPSHOT_VERSION-D0ARY6rL.mjs} +18 -2
- package/dist/packem_shared/SHAPES_FILENAME-DOhPGi-6.mjs +94 -0
- package/dist/packem_shared/{WORKFLOWS_FILENAME-DRDQdhfq.mjs → WORKFLOWS_FILENAME-CCC_42o3.mjs} +42 -2
- package/dist/packem_shared/{buildOpenApiDocument-CXwnbp4b.mjs → buildOpenApiDocument-AgKWmlry.mjs} +1 -1
- package/dist/packem_shared/{discoverAuthApiCalls-C35R6z0T.mjs → discoverAuthApiCalls-URDoTADN.mjs} +1 -1
- package/dist/packem_shared/{discoverCrons-BL6iGuJ3.mjs → discoverCrons-DdZOeroL.mjs} +20 -17
- package/dist/packem_shared/{discoverFunctions-DEgAcRuD.mjs → discoverFunctions-BJdF7lRs.mjs} +63 -9
- package/dist/packem_shared/{discoverHttpRoutes-C978pBiG.mjs → discoverHttpRoutes-CcwP-Rkr.mjs} +2 -2
- package/dist/packem_shared/{discoverInserts-CRQdXvHO.mjs → discoverInserts-BpFhM32L.mjs} +24 -2
- package/dist/packem_shared/{discoverMaskProcedures-B64zA740.mjs → discoverMaskProcedures-DT-v8wvj.mjs} +58 -2
- package/dist/packem_shared/{discoverMigrations-Doj_-BAA.mjs → discoverMigrations-cG1idBVM.mjs} +10 -4
- package/dist/packem_shared/{discoverNondeterministicCalls-4KiPQxQU.mjs → discoverNondeterministicCalls-CEOjmfk4.mjs} +1 -1
- package/dist/packem_shared/{discoverQueries-BkIi0dBD.mjs → discoverQueries-DeVBQVAG.mjs} +1 -1
- package/dist/packem_shared/{discoverR2sqlCalls-BpDqvcUn.mjs → discoverR2sqlCalls-CWCAU-xJ.mjs} +1 -1
- package/dist/packem_shared/{discoverRlsMetadata-DpRB1HMe.mjs → discoverRlsMetadata-BL0oukaK.mjs} +1 -1
- package/dist/packem_shared/{discoverSchema-BBulgGbH.mjs → discoverSchema-CeXJWVKV.mjs} +349 -17
- package/dist/packem_shared/{discoverStorageRulesMetadata-DAqJUxUv.mjs → discoverStorageRulesMetadata-CFHByjIl.mjs} +1 -1
- package/dist/packem_shared/{emitApp-CzSxVDaG.mjs → emitApp-BUCrHOeI.mjs} +94 -8
- package/dist/packem_shared/{formatAdvisories-8NIv1k0I.mjs → formatAdvisories-C9wNBNvL.mjs} +47 -3
- package/dist/packem_shared/{parse-validator-tuQtHrsr.mjs → parse-validator-D6zI2i85.mjs} +5 -3
- package/dist/packem_shared/redact-oTmsol5A.mjs +33 -0
- package/package.json +9 -7
- package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-BQ_kCZ81.mjs +0 -903
package/dist/index.mjs
CHANGED
|
@@ -1,28 +1,34 @@
|
|
|
1
|
-
export { formatAdvisories, lintSchema } from './packem_shared/formatAdvisories-
|
|
2
|
-
export { CodegenDiagnosticError, diagnosticAt } from './packem_shared/CodegenDiagnosticError-
|
|
3
|
-
export { default as discoverAuthApiCalls } from './packem_shared/discoverAuthApiCalls-
|
|
4
|
-
export { CONTAINERS_FILENAME, discoverContainers } from './packem_shared/CONTAINERS_FILENAME-
|
|
5
|
-
export { default as discoverCrons } from './packem_shared/discoverCrons-
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export { default as
|
|
9
|
-
export { default as
|
|
10
|
-
export { default as
|
|
11
|
-
export { default as
|
|
12
|
-
export {
|
|
13
|
-
export { default as
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export { default as
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
1
|
+
export { formatAdvisories, lintSchema } from './packem_shared/formatAdvisories-C9wNBNvL.mjs';
|
|
2
|
+
export { CodegenDiagnosticError, diagnosticAt } from './packem_shared/CodegenDiagnosticError-DyQ5FwkM.mjs';
|
|
3
|
+
export { default as discoverAuthApiCalls } from './packem_shared/discoverAuthApiCalls-URDoTADN.mjs';
|
|
4
|
+
export { CONTAINERS_FILENAME, discoverContainers } from './packem_shared/CONTAINERS_FILENAME-DjpXMqhp.mjs';
|
|
5
|
+
export { default as discoverCrons } from './packem_shared/discoverCrons-DdZOeroL.mjs';
|
|
6
|
+
export { FLAGS_FILENAME, discoverFlags } from './packem_shared/FLAGS_FILENAME-BjpS5w08.mjs';
|
|
7
|
+
export { discoverFunctions } from './packem_shared/discoverFunctions-BJdF7lRs.mjs';
|
|
8
|
+
export { default as discoverHttpRoutes } from './packem_shared/discoverHttpRoutes-CcwP-Rkr.mjs';
|
|
9
|
+
export { default as discoverInserts } from './packem_shared/discoverInserts-BpFhM32L.mjs';
|
|
10
|
+
export { default as discoverMaskProcedures } from './packem_shared/discoverMaskProcedures-DT-v8wvj.mjs';
|
|
11
|
+
export { default as discoverMigrations } from './packem_shared/discoverMigrations-cG1idBVM.mjs';
|
|
12
|
+
export { MUTATORS_FILENAME, discoverMutators } from './packem_shared/MUTATORS_FILENAME-BZOfUhlY.mjs';
|
|
13
|
+
export { default as discoverNondeterministicCalls } from './packem_shared/discoverNondeterministicCalls-CEOjmfk4.mjs';
|
|
14
|
+
export { default as discoverQueries } from './packem_shared/discoverQueries-DeVBQVAG.mjs';
|
|
15
|
+
export { QUEUES_FILENAME, discoverQueues } from './packem_shared/QUEUES_FILENAME-BF0iUmx7.mjs';
|
|
16
|
+
export { default as discoverR2sqlCalls } from './packem_shared/discoverR2sqlCalls-CWCAU-xJ.mjs';
|
|
17
|
+
export { discoverRlsMetadata, default as discoverRlsProcedures } from './packem_shared/discoverRlsMetadata-BL0oukaK.mjs';
|
|
18
|
+
export { default as discoverSchema } from './packem_shared/discoverSchema-CeXJWVKV.mjs';
|
|
19
|
+
export { SHAPES_FILENAME, discoverShapes } from './packem_shared/SHAPES_FILENAME-DOhPGi-6.mjs';
|
|
20
|
+
export { default as discoverStorageRulesMetadata } from './packem_shared/discoverStorageRulesMetadata-CFHByjIl.mjs';
|
|
21
|
+
export { WORKFLOWS_FILENAME, discoverWorkflows } from './packem_shared/WORKFLOWS_FILENAME-CCC_42o3.mjs';
|
|
22
|
+
export { GENERATED_HEADER, emitApi, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers } from './packem_shared/GENERATED_HEADER-f6nMvllu.mjs';
|
|
23
|
+
export { emitApp } from './packem_shared/emitApp-BUCrHOeI.mjs';
|
|
24
|
+
export { buildOpenApiDocument, emitOpenApi, emitOpenApiModule } from './packem_shared/buildOpenApiDocument-AgKWmlry.mjs';
|
|
25
|
+
export { OPENRPC_VERSION, buildOpenRpcDocument, emitOpenRpc, emitOpenRpcModule } from './packem_shared/OPENRPC_VERSION-u5SqDDGk.mjs';
|
|
26
|
+
export { SCHEMA_SNAPSHOT_FILENAME, createCodegenProject, refreshCodegenProject, runCodegen } from './packem_shared/SCHEMA_SNAPSHOT_FILENAME-Ca-TlVEc.mjs';
|
|
27
|
+
export { SCHEMA_SNAPSHOT_VERSION, SchemaSnapshotParseError, buildSchemaSnapshot, diffSchemaSnapshots, evaluateSchemaDrift, parseSchemaSnapshot, serializeSchemaSnapshot } from './packem_shared/SCHEMA_SNAPSHOT_VERSION-D0ARY6rL.mjs';
|
|
24
28
|
export { schemaFromIr } from './packem_shared/schemaFromIr-DTYsLBaA.mjs';
|
|
25
29
|
export { LUNORA_ERROR_CODES, validatorIrToJsonSchema } from './packem_shared/LUNORA_ERROR_CODES-CySpQPD3.mjs';
|
|
30
|
+
export { redact, secretKindOf } from './packem_shared/redact-oTmsol5A.mjs';
|
|
31
|
+
export { MESSAGE_SOLUTIONS as LUNORA_SOLUTION_RULES, findSolutionByMessage as findLunoraSolution } from '@lunora/errors';
|
|
26
32
|
|
|
27
33
|
const VERSION = "0.0.0";
|
|
28
34
|
|
package/dist/packem_shared/{CONTAINERS_FILENAME-0K-pjNb8.mjs → CONTAINERS_FILENAME-DjpXMqhp.mjs}
RENAMED
|
@@ -2,7 +2,7 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { containerClassName, containerBindingName, normalizeContainerImage } from '@lunora/container';
|
|
4
4
|
import { SyntaxKind, Node } from 'ts-morph';
|
|
5
|
-
import { diagnosticAt } from './CodegenDiagnosticError-
|
|
5
|
+
import { diagnosticAt } from './CodegenDiagnosticError-DyQ5FwkM.mjs';
|
|
6
6
|
|
|
7
7
|
const CONTAINERS_FILENAME = "containers.ts";
|
|
8
8
|
const isDefineContainer = (identifier) => {
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
2
|
+
|
|
3
|
+
class CodegenDiagnosticError extends LunoraError {
|
|
2
4
|
column;
|
|
3
5
|
file;
|
|
4
6
|
line;
|
|
5
7
|
constructor(message, file, line, column) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = "CodegenDiagnosticError";
|
|
8
|
+
super("CODEGEN_DIAGNOSTIC", message, { location: { column, file, line }, name: "CodegenDiagnosticError" });
|
|
8
9
|
this.file = file;
|
|
9
10
|
this.line = line;
|
|
10
11
|
this.column = column;
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
|
-
const diagnosticAt = (node, detail) => {
|
|
14
|
+
const diagnosticAt = (node, detail, meta) => {
|
|
14
15
|
const sourceFile = node.getSourceFile();
|
|
15
16
|
const file = sourceFile.getFilePath();
|
|
16
17
|
const line = node.getStartLineNumber();
|
|
17
18
|
const { column } = sourceFile.getLineAndColumnAtPos(node.getStart());
|
|
18
19
|
const message = `@lunora/codegen: ${detail} (${file}:${line.toString()}:${column.toString()})`;
|
|
19
|
-
|
|
20
|
+
const error = new CodegenDiagnosticError(message, file, line, column);
|
|
21
|
+
return meta ? Object.assign(error, meta) : error;
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
export { CodegenDiagnosticError, diagnosticAt };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { SyntaxKind, Node } from 'ts-morph';
|
|
4
|
+
import { listLunoraSourceFiles } from './discoverFunctions-BJdF7lRs.mjs';
|
|
5
|
+
|
|
6
|
+
const FLAGS_FILENAME = "flags.ts";
|
|
7
|
+
const FLAG_TYPES = /* @__PURE__ */ new Set(["boolean", "number", "object", "string"]);
|
|
8
|
+
const FLAGSHIP_PROVIDER_MODULE = "@lunora/flags/providers/flagship";
|
|
9
|
+
const isFlagshipProvider = (identifier) => {
|
|
10
|
+
const symbol = identifier.getSymbol();
|
|
11
|
+
if (!symbol) {
|
|
12
|
+
return identifier.getText() === "flagshipProvider";
|
|
13
|
+
}
|
|
14
|
+
for (const declaration of symbol.getDeclarations()) {
|
|
15
|
+
if (!Node.isImportSpecifier(declaration)) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (declaration.getImportDeclaration().getModuleSpecifierValue() !== FLAGSHIP_PROVIDER_MODULE) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return declaration.getNameNode().getText() === "flagshipProvider";
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
};
|
|
25
|
+
const stringPropertyOrUndefined = (argument, property) => {
|
|
26
|
+
const node = argument.getProperty(property);
|
|
27
|
+
if (!node || !Node.isPropertyAssignment(node)) {
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
30
|
+
const initializer = node.getInitializerOrThrow();
|
|
31
|
+
if (Node.isStringLiteral(initializer) || Node.isNoSubstitutionTemplateLiteral(initializer)) {
|
|
32
|
+
return initializer.getLiteralValue();
|
|
33
|
+
}
|
|
34
|
+
return void 0;
|
|
35
|
+
};
|
|
36
|
+
const flagshipIrFromCall = (call) => {
|
|
37
|
+
const argument = call.getArguments()[0];
|
|
38
|
+
if (argument && Node.isObjectLiteralExpression(argument)) {
|
|
39
|
+
const bindingName = stringPropertyOrUndefined(argument, "binding");
|
|
40
|
+
if (bindingName !== void 0 && bindingName.length > 0) {
|
|
41
|
+
return { bindingName, mode: "binding", provider: "flagship" };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return { mode: "http", provider: "flagship" };
|
|
45
|
+
};
|
|
46
|
+
const defaultExportExpression = (source) => {
|
|
47
|
+
const assignment = source.getExportAssignment((declaration2) => !declaration2.isExportEquals());
|
|
48
|
+
if (!assignment) {
|
|
49
|
+
return void 0;
|
|
50
|
+
}
|
|
51
|
+
const expression = assignment.getExpression();
|
|
52
|
+
if (!Node.isIdentifier(expression)) {
|
|
53
|
+
return expression;
|
|
54
|
+
}
|
|
55
|
+
const declaration = expression.getSymbol()?.getValueDeclaration();
|
|
56
|
+
if (declaration && Node.isVariableDeclaration(declaration)) {
|
|
57
|
+
return declaration.getInitializer();
|
|
58
|
+
}
|
|
59
|
+
return expression;
|
|
60
|
+
};
|
|
61
|
+
const providerInitializer = (defineFlagsCall) => {
|
|
62
|
+
const argument = defineFlagsCall.getArguments()[0];
|
|
63
|
+
if (!argument || !Node.isObjectLiteralExpression(argument)) {
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
const property = argument.getProperty("provider");
|
|
67
|
+
return property && Node.isPropertyAssignment(property) ? property.getInitializer() : void 0;
|
|
68
|
+
};
|
|
69
|
+
const discoverFlags = (project, lunoraDirectory) => {
|
|
70
|
+
const flagsPath = join(lunoraDirectory, FLAGS_FILENAME);
|
|
71
|
+
if (!existsSync(flagsPath)) {
|
|
72
|
+
return void 0;
|
|
73
|
+
}
|
|
74
|
+
const source = project.getSourceFile(flagsPath) ?? project.addSourceFileAtPath(flagsPath);
|
|
75
|
+
const exported = defaultExportExpression(source);
|
|
76
|
+
if (!exported || !Node.isCallExpression(exported)) {
|
|
77
|
+
return { provider: "custom" };
|
|
78
|
+
}
|
|
79
|
+
const provider = providerInitializer(exported);
|
|
80
|
+
if (provider && Node.isCallExpression(provider)) {
|
|
81
|
+
const callee = provider.getExpression();
|
|
82
|
+
if (Node.isIdentifier(callee) && isFlagshipProvider(callee)) {
|
|
83
|
+
return flagshipIrFromCall(provider);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return { provider: "custom" };
|
|
87
|
+
};
|
|
88
|
+
const isContextIdentifier = (node) => Node.isIdentifier(node) && node.getText() === "ctx";
|
|
89
|
+
const flagTypeFromAccess = (access) => {
|
|
90
|
+
const name = access.getName();
|
|
91
|
+
if (!FLAG_TYPES.has(name)) {
|
|
92
|
+
return void 0;
|
|
93
|
+
}
|
|
94
|
+
const receiver = access.getExpression();
|
|
95
|
+
if (!Node.isPropertyAccessExpression(receiver)) {
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
if (receiver.getName() === "flags" && isContextIdentifier(receiver.getExpression())) {
|
|
99
|
+
return name;
|
|
100
|
+
}
|
|
101
|
+
const inner = receiver.getExpression();
|
|
102
|
+
if (receiver.getName() === "details" && Node.isPropertyAccessExpression(inner) && inner.getName() === "flags" && isContextIdentifier(inner.getExpression())) {
|
|
103
|
+
return name;
|
|
104
|
+
}
|
|
105
|
+
return void 0;
|
|
106
|
+
};
|
|
107
|
+
const flagKeyFromCall = (call) => {
|
|
108
|
+
const callee = call.getExpression();
|
|
109
|
+
if (!Node.isPropertyAccessExpression(callee)) {
|
|
110
|
+
return void 0;
|
|
111
|
+
}
|
|
112
|
+
const type = flagTypeFromAccess(callee);
|
|
113
|
+
if (type === void 0) {
|
|
114
|
+
return void 0;
|
|
115
|
+
}
|
|
116
|
+
const argument = call.getArguments()[0];
|
|
117
|
+
if (!argument || !(Node.isStringLiteral(argument) || Node.isNoSubstitutionTemplateLiteral(argument))) {
|
|
118
|
+
return void 0;
|
|
119
|
+
}
|
|
120
|
+
const key = argument.getLiteralValue();
|
|
121
|
+
return key.length > 0 ? { key, type } : void 0;
|
|
122
|
+
};
|
|
123
|
+
const discoverFlagKeys = (project, lunoraDirectory) => {
|
|
124
|
+
const found = /* @__PURE__ */ new Map();
|
|
125
|
+
for (const filePath of listLunoraSourceFiles(lunoraDirectory)) {
|
|
126
|
+
const sourceFile = project.getSourceFile(filePath) ?? project.addSourceFileAtPath(filePath);
|
|
127
|
+
for (const call of sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression)) {
|
|
128
|
+
const candidate = flagKeyFromCall(call);
|
|
129
|
+
if (candidate && !found.has(candidate.key)) {
|
|
130
|
+
found.set(candidate.key, candidate.type);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return [...found.entries()].map(([key, type]) => {
|
|
135
|
+
return { key, type };
|
|
136
|
+
}).toSorted((a, b) => a.key.localeCompare(b.key));
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export { FLAGS_FILENAME, discoverFlagKeys, discoverFlags };
|