@lunora/codegen 1.0.0-alpha.3 → 1.0.0-alpha.300

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.
Files changed (118) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +1 -1
  3. package/__assets__/package-og.svg +1 -1
  4. package/dist/index.d.mts +4477 -1093
  5. package/dist/index.d.ts +4477 -1093
  6. package/dist/index.mjs +1 -29
  7. package/dist/packem_shared/AGENTS_FILENAME-B6-kjzM3.mjs +1 -0
  8. package/dist/packem_shared/CAPABILITY_PROBES-brcmKenl.mjs +25 -0
  9. package/dist/packem_shared/CONTAINERS_FILENAME-dFRtAyIe.mjs +1 -0
  10. package/dist/packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs +1 -0
  11. package/dist/packem_shared/DEFAULT_TARGET-BnQiNNKu.mjs +1 -0
  12. package/dist/packem_shared/FLAGS_FILENAME-Bf0MSlHH.mjs +1 -0
  13. package/dist/packem_shared/GENERATED_HEADER-Ck_WOHzE.mjs +1 -0
  14. package/dist/packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs +1 -0
  15. package/dist/packem_shared/MUTATORS_FILENAME-Bw0YtaO8.mjs +1 -0
  16. package/dist/packem_shared/NOTIFY_FILENAME-CPjbiHQl.mjs +1 -0
  17. package/dist/packem_shared/OPENRPC_VERSION-CCY7xqSL.mjs +3 -0
  18. package/dist/packem_shared/PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs +1 -0
  19. package/dist/packem_shared/QUEUES_FILENAME-CsRy4VTF.mjs +1 -0
  20. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-BfK-dKlK.mjs +11 -0
  21. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs +2 -0
  22. package/dist/packem_shared/SDK_LANGUAGES-Df_CnJx5.mjs +372 -0
  23. package/dist/packem_shared/SHAPES_FILENAME-DkBUN9dK.mjs +1 -0
  24. package/dist/packem_shared/SchemaSnapshotParseError-BRJT7c2k.mjs +18 -0
  25. package/dist/packem_shared/WORKFLOWS_FILENAME-CQR8fE9B.mjs +1 -0
  26. package/dist/packem_shared/attribution-hVBriwzy.mjs +1 -0
  27. package/dist/packem_shared/buildOpenApiDocument-DFv-RYZU.mjs +3 -0
  28. package/dist/packem_shared/capabilitiesUsedBy-QgSZyE0T.mjs +1 -0
  29. package/dist/packem_shared/chain-CRDaTj2c.mjs +1 -0
  30. package/dist/packem_shared/classify-procedure-call-BAj0D1u2.mjs +1 -0
  31. package/dist/packem_shared/context-property-calls-DJ_A1R5i.mjs +1 -0
  32. package/dist/packem_shared/context-root-wBahDTzk.mjs +1 -0
  33. package/dist/packem_shared/createCodegenProject-V51_yBw3.mjs +1 -0
  34. package/dist/packem_shared/database-calls-CHZbBUCZ.mjs +1 -0
  35. package/dist/packem_shared/declared-output-Iaar469J.mjs +1 -0
  36. package/dist/packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs +1 -0
  37. package/dist/packem_shared/discoverAuthApiCalls-xs0ONfI-.mjs +1 -0
  38. package/dist/packem_shared/discoverCrons-DF7dOP9x.mjs +1 -0
  39. package/dist/packem_shared/discoverFunctions-DaEZl3uE.mjs +1 -0
  40. package/dist/packem_shared/discoverHttpRoutes-C_u9YiFb.mjs +1 -0
  41. package/dist/packem_shared/discoverHyperdriveCalls-BUrA_96X.mjs +1 -0
  42. package/dist/packem_shared/discoverInserts-OT_fiEGq.mjs +1 -0
  43. package/dist/packem_shared/discoverMaskProcedures-CcB18tzB.mjs +1 -0
  44. package/dist/packem_shared/discoverMigrations-C9mLIhGZ.mjs +1 -0
  45. package/dist/packem_shared/discoverNondeterministicCalls-9ZDpRptb.mjs +1 -0
  46. package/dist/packem_shared/discoverQueries-C8V4cMIP.mjs +1 -0
  47. package/dist/packem_shared/discoverR2sqlCalls-COKmDnih.mjs +1 -0
  48. package/dist/packem_shared/discoverRlsMetadata-Cb8JR1b4.mjs +1 -0
  49. package/dist/packem_shared/discoverRlsProcedures-BlUd32bU.mjs +1 -0
  50. package/dist/packem_shared/discoverSandboxUsage-w6Q3RvxZ.mjs +1 -0
  51. package/dist/packem_shared/discoverSchema-CRBUNY3s.mjs +1 -0
  52. package/dist/packem_shared/discoverStorageRulesMetadata-BPJplDfz.mjs +1 -0
  53. package/dist/packem_shared/dispatch-namespace-DwTjD7BU.mjs +1 -0
  54. package/dist/packem_shared/emitAgents-D_UUdNe1.mjs +1 -0
  55. package/dist/packem_shared/emitApi-Zx6VPN-7.mjs +135 -0
  56. package/dist/packem_shared/emitApp-DAZCUDbr.mjs +864 -0
  57. package/dist/packem_shared/emitCrons-BQW2lviZ.mjs +96 -0
  58. package/dist/packem_shared/emitDataModel-BskFt9Wv.mjs +114 -0
  59. package/dist/packem_shared/emitDrizzleSchema-DitcRZ1a.mjs +15 -0
  60. package/dist/packem_shared/emitFunctions-BeKgL3dl.mjs +241 -0
  61. package/dist/packem_shared/emitServer-D1vA5_X1.mjs +1 -0
  62. package/dist/packem_shared/emitShard-C8I2zw1K.mjs +1 -0
  63. package/dist/packem_shared/exported-procedure-chains-DKK5HoK3.mjs +1 -0
  64. package/dist/packem_shared/fingerprintSchemaSources-eVG9aVt0.mjs +1 -0
  65. package/dist/packem_shared/formatAdvisories-BCVASH7N.mjs +2 -0
  66. package/dist/packem_shared/handler-reference-vIeqkhV_.mjs +1 -0
  67. package/dist/packem_shared/index-DZZpHXMv.mjs +1 -0
  68. package/dist/packem_shared/isD1GlobalTable-udvHAAzD.mjs +1 -0
  69. package/dist/packem_shared/isTestPath-B81lOULB.mjs +1 -0
  70. package/dist/packem_shared/isTypedSchema-CKzc3ioR.mjs +4 -0
  71. package/dist/packem_shared/json-data-Chfs2Cz5.mjs +1 -0
  72. package/dist/packem_shared/loadProjectConfig-NO0dVJSl.mjs +1 -0
  73. package/dist/packem_shared/module-specifiers-WF8iAydP.mjs +1 -0
  74. package/dist/packem_shared/modules-CjOcuQnK.mjs +1 -0
  75. package/dist/packem_shared/parse-validator-IDBKIT7M.mjs +1 -0
  76. package/dist/packem_shared/platform-8oj7iXQy.mjs +1 -0
  77. package/dist/packem_shared/project-config-file-BV7RR-l6.mjs +1 -0
  78. package/dist/packem_shared/qualifiers-DEdXn5wP.mjs +1 -0
  79. package/dist/packem_shared/readPackageDependencies-RHhGiz0k.mjs +1 -0
  80. package/dist/packem_shared/readServiceBindings-DvqIThzd.mjs +1 -0
  81. package/dist/packem_shared/redact-Cy14LEnc.mjs +1 -0
  82. package/dist/packem_shared/reserved-words-CW1QFbTd.mjs +1 -0
  83. package/dist/packem_shared/schema-BgM8A3XV.mjs +1 -0
  84. package/dist/packem_shared/schemaFromIr-BWFnvCVg.mjs +1 -0
  85. package/dist/packem_shared/server-DAvi_bv_.mjs +368 -0
  86. package/dist/packem_shared/shard-BTj5Z44S.mjs +1446 -0
  87. package/dist/packem_shared/shard-runtime-BX0xmo0P.mjs +326 -0
  88. package/dist/packem_shared/shared-DnCokNcE.mjs +13 -0
  89. package/dist/packem_shared/unwrap-handler-return-B-jQde6M.mjs +1 -0
  90. package/package.json +18 -7
  91. package/dist/packem_shared/CONTAINERS_FILENAME-0K-pjNb8.mjs +0 -224
  92. package/dist/packem_shared/CodegenDiagnosticError-54jWDxA9.mjs +0 -22
  93. package/dist/packem_shared/GENERATED_HEADER-CuLyj0WQ.mjs +0 -2486
  94. package/dist/packem_shared/LUNORA_ERROR_CODES-CySpQPD3.mjs +0 -61
  95. package/dist/packem_shared/OPENRPC_VERSION-BGUrsrt_.mjs +0 -60
  96. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-BQ_kCZ81.mjs +0 -903
  97. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-DzLDbWk3.mjs +0 -233
  98. package/dist/packem_shared/WORKFLOWS_FILENAME-DRDQdhfq.mjs +0 -84
  99. package/dist/packem_shared/buildOpenApiDocument-CXwnbp4b.mjs +0 -183
  100. package/dist/packem_shared/discover-ast-CT6BgBr4.mjs +0 -13
  101. package/dist/packem_shared/discoverAuthApiCalls-C35R6z0T.mjs +0 -62
  102. package/dist/packem_shared/discoverCrons-BL6iGuJ3.mjs +0 -254
  103. package/dist/packem_shared/discoverFunctions-DEgAcRuD.mjs +0 -460
  104. package/dist/packem_shared/discoverHttpRoutes-C978pBiG.mjs +0 -131
  105. package/dist/packem_shared/discoverInserts-CRQdXvHO.mjs +0 -39
  106. package/dist/packem_shared/discoverMaskProcedures-B64zA740.mjs +0 -217
  107. package/dist/packem_shared/discoverMigrations-Doj_-BAA.mjs +0 -91
  108. package/dist/packem_shared/discoverNondeterministicCalls-4KiPQxQU.mjs +0 -122
  109. package/dist/packem_shared/discoverQueries-BkIi0dBD.mjs +0 -62
  110. package/dist/packem_shared/discoverR2sqlCalls-BpDqvcUn.mjs +0 -80
  111. package/dist/packem_shared/discoverRlsMetadata-DpRB1HMe.mjs +0 -280
  112. package/dist/packem_shared/discoverSchema-BBulgGbH.mjs +0 -542
  113. package/dist/packem_shared/discoverStorageRulesMetadata-DAqJUxUv.mjs +0 -97
  114. package/dist/packem_shared/emitApp-CzSxVDaG.mjs +0 -599
  115. package/dist/packem_shared/formatAdvisories-8NIv1k0I.mjs +0 -69
  116. package/dist/packem_shared/parse-validator-tuQtHrsr.mjs +0 -132
  117. package/dist/packem_shared/paths-BRd6JHuF.mjs +0 -11
  118. package/dist/packem_shared/schemaFromIr-DTYsLBaA.mjs +0 -57
@@ -1,224 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import { containerClassName, containerBindingName, normalizeContainerImage } from '@lunora/container';
4
- import { SyntaxKind, Node } from 'ts-morph';
5
- import { diagnosticAt } from './CodegenDiagnosticError-54jWDxA9.mjs';
6
-
7
- const CONTAINERS_FILENAME = "containers.ts";
8
- const isDefineContainer = (identifier) => {
9
- const symbol = identifier.getSymbol();
10
- if (!symbol) {
11
- return identifier.getText() === "defineContainer";
12
- }
13
- for (const declaration of symbol.getDeclarations()) {
14
- if (!Node.isImportSpecifier(declaration)) {
15
- continue;
16
- }
17
- if (declaration.getImportDeclaration().getModuleSpecifierValue() !== "@lunora/container") {
18
- return false;
19
- }
20
- return declaration.getNameNode().getText() === "defineContainer";
21
- }
22
- return false;
23
- };
24
- const stringProperty = (expression, exportName, property) => {
25
- if (Node.isStringLiteral(expression) || Node.isNoSubstitutionTemplateLiteral(expression)) {
26
- return expression.getLiteralValue();
27
- }
28
- throw diagnosticAt(
29
- expression,
30
- `container "${exportName}": \`${property}\` must be a static string literal — it is deploy configuration codegen writes into wrangler.jsonc`
31
- );
32
- };
33
- const numberProperty = (expression, exportName, property) => {
34
- if (Node.isNumericLiteral(expression)) {
35
- return expression.getLiteralValue();
36
- }
37
- throw diagnosticAt(
38
- expression,
39
- `container "${exportName}": \`${property}\` must be a static number literal — it is deploy configuration codegen writes into wrangler.jsonc`
40
- );
41
- };
42
- const imageFromExpression = (expression, exportName) => {
43
- if (Node.isStringLiteral(expression) || Node.isNoSubstitutionTemplateLiteral(expression)) {
44
- return normalizeContainerImage(expression.getLiteralValue());
45
- }
46
- if (Node.isObjectLiteralExpression(expression)) {
47
- const registry = expression.getProperty("registry");
48
- if (registry && Node.isPropertyAssignment(registry)) {
49
- const initializer = registry.getInitializerOrThrow();
50
- return normalizeContainerImage({ registry: stringProperty(initializer, exportName, "image.registry") });
51
- }
52
- const build = expression.getProperty("build");
53
- if (build && Node.isPropertyAssignment(build)) {
54
- const initializer = build.getInitializerOrThrow();
55
- return normalizeContainerImage({ build: stringProperty(initializer, exportName, "image.build") });
56
- }
57
- }
58
- throw diagnosticAt(expression, `container "${exportName}": \`image\` must be a static string path, { registry: "…" }, or { build: "…" } literal`);
59
- };
60
- const stringRecordLiteral = (expression) => {
61
- if (!Node.isObjectLiteralExpression(expression)) {
62
- return void 0;
63
- }
64
- const record = {};
65
- for (const property of expression.getProperties()) {
66
- if (!Node.isPropertyAssignment(property)) {
67
- continue;
68
- }
69
- const value = property.getInitializerOrThrow();
70
- if (Node.isStringLiteral(value) || Node.isNoSubstitutionTemplateLiteral(value)) {
71
- record[property.getName()] = value.getLiteralValue();
72
- }
73
- }
74
- return Object.keys(record).length > 0 ? record : void 0;
75
- };
76
- const rolloutLiteral = (expression) => {
77
- if (!Node.isObjectLiteralExpression(expression)) {
78
- return void 0;
79
- }
80
- const rollout = {};
81
- for (const property of expression.getProperties()) {
82
- if (!Node.isPropertyAssignment(property)) {
83
- continue;
84
- }
85
- const key = property.getName();
86
- const value = property.getInitializerOrThrow();
87
- if (Node.isNumericLiteral(value) && (key === "gracePeriodSeconds" || key === "stepPercentage")) {
88
- rollout[key] = value.getLiteralValue();
89
- }
90
- }
91
- return rollout.gracePeriodSeconds === void 0 && rollout.stepPercentage === void 0 ? void 0 : rollout;
92
- };
93
- const booleanLiteral = (expression) => {
94
- if (Node.isTrueLiteral(expression)) {
95
- return true;
96
- }
97
- if (Node.isFalseLiteral(expression)) {
98
- return false;
99
- }
100
- return void 0;
101
- };
102
- const stringOrNumberLiteral = (expression) => {
103
- if (Node.isStringLiteral(expression) || Node.isNoSubstitutionTemplateLiteral(expression)) {
104
- return expression.getLiteralValue();
105
- }
106
- if (Node.isNumericLiteral(expression)) {
107
- return expression.getLiteralValue();
108
- }
109
- return void 0;
110
- };
111
- const instanceTypeFromExpression = (expression, exportName) => {
112
- if (Node.isStringLiteral(expression)) {
113
- return expression.getLiteralValue();
114
- }
115
- if (Node.isObjectLiteralExpression(expression)) {
116
- const custom = {};
117
- for (const property of expression.getProperties()) {
118
- if (!Node.isPropertyAssignment(property)) {
119
- throw diagnosticAt(property, `container "${exportName}": \`instanceType\` must be an object of static number literals`);
120
- }
121
- const key = property.getName();
122
- if (key !== "diskMb" && key !== "memoryMib" && key !== "vcpu") {
123
- throw diagnosticAt(property, `container "${exportName}": unknown \`instanceType\` field "${key}" — expected vcpu, memoryMib, or diskMb`);
124
- }
125
- custom[key] = numberProperty(property.getInitializerOrThrow(), exportName, `instanceType.${key}`);
126
- }
127
- return custom;
128
- }
129
- throw diagnosticAt(expression, `container "${exportName}": \`instanceType\` must be a static string or { vcpu, memoryMib, diskMb } literal`);
130
- };
131
- const containerFromCall = (call, exportName) => {
132
- const argument = call.getArguments()[0];
133
- if (!argument || !Node.isObjectLiteralExpression(argument)) {
134
- throw diagnosticAt(call, `container "${exportName}": defineContainer must be passed an inline object literal`);
135
- }
136
- const ir = {
137
- bindingName: containerBindingName(exportName),
138
- className: containerClassName(exportName),
139
- exportName,
140
- image: { buildContext: ".", dockerfilePath: "./Dockerfile", kind: "dockerfile" }
141
- };
142
- let sawImage = false;
143
- for (const property of argument.getProperties()) {
144
- if (!Node.isPropertyAssignment(property)) {
145
- continue;
146
- }
147
- const key = property.getName();
148
- const initializer = property.getInitializerOrThrow();
149
- switch (key) {
150
- case "buildArgs": {
151
- ir.buildArgs = stringRecordLiteral(initializer);
152
- break;
153
- }
154
- case "enableInternet": {
155
- ir.enableInternet = booleanLiteral(initializer);
156
- break;
157
- }
158
- case "image": {
159
- ir.image = imageFromExpression(initializer, exportName);
160
- sawImage = true;
161
- break;
162
- }
163
- case "instanceType": {
164
- ir.instanceType = instanceTypeFromExpression(initializer, exportName);
165
- break;
166
- }
167
- case "maxInstances": {
168
- ir.maxInstances = numberProperty(initializer, exportName, "maxInstances");
169
- break;
170
- }
171
- case "name": {
172
- ir.name = stringProperty(initializer, exportName, "name");
173
- break;
174
- }
175
- case "rollout": {
176
- ir.rollout = rolloutLiteral(initializer);
177
- break;
178
- }
179
- case "sleepAfter": {
180
- ir.sleepAfter = stringOrNumberLiteral(initializer);
181
- break;
182
- }
183
- }
184
- }
185
- if (!sawImage) {
186
- throw diagnosticAt(argument, `container "${exportName}": defineContainer requires a static \`image\` property`);
187
- }
188
- return ir;
189
- };
190
- const containersFromSource = (source) => {
191
- const containers = [];
192
- for (const declaration of source.getVariableDeclarations()) {
193
- if (!declaration.isExported()) {
194
- continue;
195
- }
196
- const initializer = declaration.getInitializer();
197
- if (initializer?.getKind() !== SyntaxKind.CallExpression) {
198
- continue;
199
- }
200
- const call = initializer;
201
- const callee = call.getExpression();
202
- if (!Node.isIdentifier(callee) || !isDefineContainer(callee)) {
203
- continue;
204
- }
205
- const nameNode = declaration.getNameNode();
206
- if (!Node.isIdentifier(nameNode)) {
207
- throw diagnosticAt(nameNode, "defineContainer exports must be plain named exports (no destructuring)");
208
- }
209
- containers.push(containerFromCall(call, nameNode.getText()));
210
- }
211
- return containers;
212
- };
213
- const discoverContainers = (project, lunoraDirectory) => {
214
- const containersPath = join(lunoraDirectory, CONTAINERS_FILENAME);
215
- if (!existsSync(containersPath)) {
216
- return [];
217
- }
218
- const source = project.getSourceFile(containersPath) ?? project.addSourceFileAtPath(containersPath);
219
- const containers = containersFromSource(source);
220
- containers.sort((a, b) => a.exportName.localeCompare(b.exportName));
221
- return containers;
222
- };
223
-
224
- export { CONTAINERS_FILENAME, discoverContainers };
@@ -1,22 +0,0 @@
1
- class CodegenDiagnosticError extends Error {
2
- column;
3
- file;
4
- line;
5
- constructor(message, file, line, column) {
6
- super(message);
7
- this.name = "CodegenDiagnosticError";
8
- this.file = file;
9
- this.line = line;
10
- this.column = column;
11
- }
12
- }
13
- const diagnosticAt = (node, detail) => {
14
- const sourceFile = node.getSourceFile();
15
- const file = sourceFile.getFilePath();
16
- const line = node.getStartLineNumber();
17
- const { column } = sourceFile.getLineAndColumnAtPos(node.getStart());
18
- const message = `@lunora/codegen: ${detail} (${file}:${line.toString()}:${column.toString()})`;
19
- return new CodegenDiagnosticError(message, file, line, column);
20
- };
21
-
22
- export { CodegenDiagnosticError, diagnosticAt };