@lunora/codegen 1.0.0-alpha.43 → 1.0.0-alpha.430

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 (131) hide show
  1. package/LICENSE.md +201 -104
  2. package/README.md +4 -4
  3. package/dist/index.d.mts +4575 -2150
  4. package/dist/index.d.ts +4575 -2150
  5. package/dist/index.mjs +1 -36
  6. package/dist/packem_shared/AGENTS_FILENAME-BSW65Q9R.mjs +1 -0
  7. package/dist/packem_shared/ALL_NOTIFY_CHANNELS-DI0zmZGs.mjs +1 -0
  8. package/dist/packem_shared/CAPABILITY_PROBES-DCzOjTN7.mjs +25 -0
  9. package/dist/packem_shared/COMPANION_BINDING-Da_v9XpC.mjs +1 -0
  10. package/dist/packem_shared/CONTAINERS_FILENAME-Dy3qWGfI.mjs +1 -0
  11. package/dist/packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs +1 -0
  12. package/dist/packem_shared/DEFAULT_TARGET-CnglMKg_.mjs +1 -0
  13. package/dist/packem_shared/ENV_FILENAME-DFx_jlpa.mjs +1 -0
  14. package/dist/packem_shared/FLAGS_FILENAME-CDaIBL6L.mjs +1 -0
  15. package/dist/packem_shared/GENERATED_HEADER-DgrhC3Iv.mjs +1 -0
  16. package/dist/packem_shared/LUNORA_ERROR_CODES-D7AVT7qF.mjs +1 -0
  17. package/dist/packem_shared/MUTATORS_FILENAME-SLAN2VXq.mjs +1 -0
  18. package/dist/packem_shared/OPENRPC_VERSION-DkWde9eh.mjs +3 -0
  19. package/dist/packem_shared/PROJECT_CONFIG_FILENAMES-CLfsyvjA.mjs +1 -0
  20. package/dist/packem_shared/QUEUES_FILENAME-CVkpGqoY.mjs +1 -0
  21. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-C0ZU8cQz.mjs +57 -0
  22. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-DTLoSaNn.mjs +2 -0
  23. package/dist/packem_shared/SHAPES_FILENAME-Cf4sum4C.mjs +1 -0
  24. package/dist/packem_shared/SchemaSnapshotParseError-CV7mmuPi.mjs +17 -0
  25. package/dist/packem_shared/WORKFLOWS_FILENAME-Dtxo_XBw.mjs +1 -0
  26. package/dist/packem_shared/attribution-B8xa6AeK.mjs +1 -0
  27. package/dist/packem_shared/buildOpenApiDocument-C3zlve6K.mjs +3 -0
  28. package/dist/packem_shared/capabilitiesUsedBy-BcDkRoOu.mjs +1 -0
  29. package/dist/packem_shared/classify-procedure-call-BK_MMoue.mjs +1 -0
  30. package/dist/packem_shared/companionServiceBinding-BZjm486n.mjs +1 -0
  31. package/dist/packem_shared/context-property-calls-As5I0QR6.mjs +1 -0
  32. package/dist/packem_shared/context-root-CO8PbZi5.mjs +1 -0
  33. package/dist/packem_shared/createCodegenProject-C4XuJSap.mjs +1 -0
  34. package/dist/packem_shared/database-calls-Cug60vT9.mjs +1 -0
  35. package/dist/packem_shared/declared-output-Iaar469J.mjs +1 -0
  36. package/dist/packem_shared/describeErrorLevelFindings-DlkgCw8a.mjs +1 -0
  37. package/dist/packem_shared/discoverAuthApiCalls-DcvsgL5u.mjs +1 -0
  38. package/dist/packem_shared/discoverCrons-MpIC14pg.mjs +1 -0
  39. package/dist/packem_shared/discoverFunctions-CGwHnz_a.mjs +1 -0
  40. package/dist/packem_shared/discoverHttpRoutes-BtMgsfzG.mjs +1 -0
  41. package/dist/packem_shared/discoverHyperdriveCalls-B--Nvx36.mjs +1 -0
  42. package/dist/packem_shared/discoverInserts-Dx7Lxey3.mjs +1 -0
  43. package/dist/packem_shared/discoverMaskProcedures-Dj_hkZz2.mjs +1 -0
  44. package/dist/packem_shared/discoverMigrations-DaBdK1Bv.mjs +1 -0
  45. package/dist/packem_shared/discoverNondeterministicCalls-MeKjo_UX.mjs +1 -0
  46. package/dist/packem_shared/discoverQueries-BlhMsXuk.mjs +1 -0
  47. package/dist/packem_shared/discoverR2sqlCalls-DHvclvkv.mjs +1 -0
  48. package/dist/packem_shared/discoverRlsMetadata-CO-pRHOx.mjs +1 -0
  49. package/dist/packem_shared/discoverRlsProcedures-CUfhUqfY.mjs +1 -0
  50. package/dist/packem_shared/discoverSandboxUsage-CdrJNRFd.mjs +1 -0
  51. package/dist/packem_shared/discoverSchema-CL9PLdOu.mjs +1 -0
  52. package/dist/packem_shared/discoverStorageRulesMetadata-D_pYyr1i.mjs +1 -0
  53. package/dist/packem_shared/dispatch-namespace-DwTjD7BU.mjs +1 -0
  54. package/dist/packem_shared/emitAgents-vWoT8-Yb.mjs +1 -0
  55. package/dist/packem_shared/emitApi-lwadq5G7.mjs +147 -0
  56. package/dist/packem_shared/emitApp-_YbbmtTw.mjs +1207 -0
  57. package/dist/packem_shared/emitCrons-CCRKs482.mjs +138 -0
  58. package/dist/packem_shared/emitDataModel-Cen7mAmM.mjs +114 -0
  59. package/dist/packem_shared/emitDrizzleSchema-lRoq3OJs.mjs +15 -0
  60. package/dist/packem_shared/emitFunctions-ppMX7E3X.mjs +528 -0
  61. package/dist/packem_shared/emitServer-CGRV_uIq.mjs +1 -0
  62. package/dist/packem_shared/emitShard-DhgRjlEf.mjs +1 -0
  63. package/dist/packem_shared/exported-procedure-chains-ej9ozyZB.mjs +1 -0
  64. package/dist/packem_shared/fingerprintSchemaSources-BqPD3mw0.mjs +1 -0
  65. package/dist/packem_shared/formatAdvisories-Bue5tbp6.mjs +2 -0
  66. package/dist/packem_shared/handler-reference-_zhtPddp.mjs +1 -0
  67. package/dist/packem_shared/index-BwLaIVqA.mjs +1 -0
  68. package/dist/packem_shared/index-CQuAXbal.mjs +1 -0
  69. package/dist/packem_shared/ip-reads-D8rPYtZ6.mjs +1 -0
  70. package/dist/packem_shared/isD1GlobalTable-udvHAAzD.mjs +1 -0
  71. package/dist/packem_shared/isTestPath-DJeZ18i9.mjs +1 -0
  72. package/dist/packem_shared/isTypedSchema-CDv3pJB6.mjs +4 -0
  73. package/dist/packem_shared/json-data-Chfs2Cz5.mjs +1 -0
  74. package/dist/packem_shared/loadProjectConfig-BXwH3_gn.mjs +1 -0
  75. package/dist/packem_shared/module-specifiers-BctA0m_p.mjs +1 -0
  76. package/dist/packem_shared/modules-isOWiSYI.mjs +1 -0
  77. package/dist/packem_shared/parse-validator-BisfC8bR.mjs +1 -0
  78. package/dist/packem_shared/platform-8oj7iXQy.mjs +1 -0
  79. package/dist/packem_shared/policies-CrNWTJQi.mjs +1 -0
  80. package/dist/packem_shared/project-config-file-DR7xrrNB.mjs +1 -0
  81. package/dist/packem_shared/property-name-7cBlgK_O.mjs +1 -0
  82. package/dist/packem_shared/qualifiers-qqH8fRTo.mjs +1 -0
  83. package/dist/packem_shared/readPackageDependencies-RHhGiz0k.mjs +1 -0
  84. package/dist/packem_shared/redact-Cy14LEnc.mjs +1 -0
  85. package/dist/packem_shared/reserved-words-CW1QFbTd.mjs +1 -0
  86. package/dist/packem_shared/schema-BgM8A3XV.mjs +1 -0
  87. package/dist/packem_shared/schemaFromIr-CByOxuZb.mjs +1 -0
  88. package/dist/packem_shared/server-Dfxmm5Zw.mjs +377 -0
  89. package/dist/packem_shared/shard-WWiw5i1B.mjs +1922 -0
  90. package/dist/packem_shared/shard-runtime-G5mZQjY0.mjs +351 -0
  91. package/dist/packem_shared/shared-Cn7dMQ_u.mjs +13 -0
  92. package/dist/packem_shared/unwrap-handler-return-BnsKyz9W.mjs +1 -0
  93. package/dist/sdk/index.d.mts +288 -0
  94. package/dist/sdk/index.d.ts +288 -0
  95. package/dist/sdk/index.mjs +394 -0
  96. package/package.json +32 -10
  97. package/dist/packem_shared/AGENTS_FILENAME-BksnAJgx.mjs +0 -116
  98. package/dist/packem_shared/CONTAINERS_FILENAME-DjpXMqhp.mjs +0 -224
  99. package/dist/packem_shared/CodegenDiagnosticError-DyQ5FwkM.mjs +0 -24
  100. package/dist/packem_shared/FLAGS_FILENAME-fEZtzWXi.mjs +0 -139
  101. package/dist/packem_shared/GENERATED_HEADER-B-FzJ297.mjs +0 -4
  102. package/dist/packem_shared/LUNORA_ERROR_CODES-DvTLozCu.mjs +0 -68
  103. package/dist/packem_shared/MUTATORS_FILENAME-BZOfUhlY.mjs +0 -81
  104. package/dist/packem_shared/OPENRPC_VERSION-DqTYxQ22.mjs +0 -60
  105. package/dist/packem_shared/QUEUES_FILENAME-Xv6Vy-Ku.mjs +0 -145
  106. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-BbF69nj9.mjs +0 -3497
  107. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-D0ARY6rL.mjs +0 -249
  108. package/dist/packem_shared/SHAPES_FILENAME-DOhPGi-6.mjs +0 -94
  109. package/dist/packem_shared/WORKFLOWS_FILENAME-B2By8S4s.mjs +0 -152
  110. package/dist/packem_shared/buildOpenApiDocument-BrN41JMl.mjs +0 -183
  111. package/dist/packem_shared/discover-ast-CT6BgBr4.mjs +0 -13
  112. package/dist/packem_shared/discoverAuthApiCalls-WMx8L2FG.mjs +0 -62
  113. package/dist/packem_shared/discoverCrons-DJJ3ZE5F.mjs +0 -271
  114. package/dist/packem_shared/discoverFunctions-CZ91aenA.mjs +0 -518
  115. package/dist/packem_shared/discoverHttpRoutes-DNZLDCmm.mjs +0 -131
  116. package/dist/packem_shared/discoverInserts-DFRJhmCv.mjs +0 -61
  117. package/dist/packem_shared/discoverMaskProcedures-B5iFnZ-X.mjs +0 -273
  118. package/dist/packem_shared/discoverMigrations-CdKtMlBc.mjs +0 -97
  119. package/dist/packem_shared/discoverNondeterministicCalls-C_PrQPkA.mjs +0 -122
  120. package/dist/packem_shared/discoverQueries-B8W9UPrt.mjs +0 -62
  121. package/dist/packem_shared/discoverR2sqlCalls-Bm7Rfnf4.mjs +0 -80
  122. package/dist/packem_shared/discoverRlsMetadata-B4GL4ZKm.mjs +0 -280
  123. package/dist/packem_shared/discoverSchema-DFWVgU5o.mjs +0 -874
  124. package/dist/packem_shared/discoverStorageRulesMetadata-nosjYcvN.mjs +0 -97
  125. package/dist/packem_shared/emit-DtherCpQ.mjs +0 -3727
  126. package/dist/packem_shared/emitApp-D7daY94X.mjs +0 -691
  127. package/dist/packem_shared/formatAdvisories-DRhEiJUz.mjs +0 -114
  128. package/dist/packem_shared/parse-validator-BSJo1HGP.mjs +0 -144
  129. package/dist/packem_shared/paths-BRd6JHuF.mjs +0 -11
  130. package/dist/packem_shared/redact-oTmsol5A.mjs +0 -33
  131. package/dist/packem_shared/schemaFromIr-DTYsLBaA.mjs +0 -57
@@ -1,116 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import { agentDefaultName, agentClassName, agentBindingName, voiceBindingName, voiceClassName } from '@lunora/agent/naming';
4
- import { SyntaxKind, Node } from 'ts-morph';
5
- import { diagnosticAt } from './CodegenDiagnosticError-DyQ5FwkM.mjs';
6
-
7
- const AGENTS_FILENAME = "agents.ts";
8
- const isDefineAgent = (identifier) => {
9
- const symbol = identifier.getSymbol();
10
- if (!symbol) {
11
- return identifier.getText() === "defineAgent";
12
- }
13
- for (const declaration of symbol.getDeclarations()) {
14
- if (!Node.isImportSpecifier(declaration)) {
15
- continue;
16
- }
17
- if (declaration.getImportDeclaration().getModuleSpecifierValue() !== "@lunora/agent") {
18
- return false;
19
- }
20
- return declaration.getNameNode().getText() === "defineAgent";
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
- `agent "${exportName}": \`${property}\` must be a static string literal — it is deploy configuration codegen writes into wrangler.jsonc`
31
- );
32
- };
33
- const booleanProperty = (expression, exportName, property) => {
34
- if (expression.getKind() === SyntaxKind.TrueKeyword) {
35
- return true;
36
- }
37
- if (expression.getKind() === SyntaxKind.FalseKeyword) {
38
- return false;
39
- }
40
- throw diagnosticAt(
41
- expression,
42
- `agent "${exportName}": \`${property}\` must be a static boolean literal — it is deploy configuration codegen writes into the ctx.agents wiring spec`
43
- );
44
- };
45
- const agentFromCall = (call, exportName) => {
46
- const argument = call.getArguments()[0];
47
- if (!argument || !Node.isObjectLiteralExpression(argument)) {
48
- throw diagnosticAt(call, `agent "${exportName}": defineAgent must be passed an inline object literal`);
49
- }
50
- const ir = {
51
- bindingName: agentBindingName(exportName),
52
- className: agentClassName(exportName),
53
- exportName,
54
- name: agentDefaultName(exportName)
55
- };
56
- const nameProperty = argument.getProperty("name");
57
- if (nameProperty && Node.isPropertyAssignment(nameProperty)) {
58
- ir.name = stringProperty(nameProperty.getInitializerOrThrow(), exportName, "name");
59
- }
60
- const publicRunProperty = argument.getProperty("publicRun");
61
- if (publicRunProperty && Node.isPropertyAssignment(publicRunProperty) && booleanProperty(publicRunProperty.getInitializerOrThrow(), exportName, "publicRun")) {
62
- ir.publicRun = true;
63
- }
64
- const voiceProperty = argument.getProperty("voice");
65
- if (voiceProperty && Node.isPropertyAssignment(voiceProperty)) {
66
- const voiceInitializer = voiceProperty.getInitializerOrThrow();
67
- if (!Node.isObjectLiteralExpression(voiceInitializer)) {
68
- throw diagnosticAt(
69
- voiceInitializer,
70
- `agent "${exportName}": \`voice\` must be an inline object literal — its presence tells codegen to emit the voice-session Durable Object`
71
- );
72
- }
73
- ir.voice = true;
74
- ir.voiceBindingName = voiceBindingName(exportName);
75
- ir.voiceClassName = voiceClassName(exportName);
76
- }
77
- if (argument.getProperty("onEmail")) {
78
- ir.onEmail = true;
79
- }
80
- return ir;
81
- };
82
- const agentsFromSource = (source) => {
83
- const agents = [];
84
- for (const declaration of source.getVariableDeclarations()) {
85
- if (!declaration.isExported()) {
86
- continue;
87
- }
88
- const initializer = declaration.getInitializer();
89
- if (initializer?.getKind() !== SyntaxKind.CallExpression) {
90
- continue;
91
- }
92
- const call = initializer;
93
- const callee = call.getExpression();
94
- if (!Node.isIdentifier(callee) || !isDefineAgent(callee)) {
95
- continue;
96
- }
97
- const nameNode = declaration.getNameNode();
98
- if (!Node.isIdentifier(nameNode)) {
99
- throw diagnosticAt(nameNode, "defineAgent exports must be plain named exports (no destructuring)");
100
- }
101
- agents.push(agentFromCall(call, nameNode.getText()));
102
- }
103
- return agents;
104
- };
105
- const discoverAgents = (project, lunoraDirectory) => {
106
- const agentsPath = join(lunoraDirectory, AGENTS_FILENAME);
107
- if (!existsSync(agentsPath)) {
108
- return [];
109
- }
110
- const source = project.getSourceFile(agentsPath) ?? project.addSourceFileAtPath(agentsPath);
111
- const agents = agentsFromSource(source);
112
- agents.sort((a, b) => a.exportName.localeCompare(b.exportName));
113
- return agents;
114
- };
115
-
116
- export { AGENTS_FILENAME, discoverAgents };
@@ -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-DyQ5FwkM.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,24 +0,0 @@
1
- import { LunoraError } from '@lunora/errors';
2
-
3
- class CodegenDiagnosticError extends LunoraError {
4
- column;
5
- file;
6
- line;
7
- constructor(message, file, line, column) {
8
- super("CODEGEN_DIAGNOSTIC", message, { location: { column, file, line }, name: "CodegenDiagnosticError" });
9
- this.file = file;
10
- this.line = line;
11
- this.column = column;
12
- }
13
- }
14
- const diagnosticAt = (node, detail, meta) => {
15
- const sourceFile = node.getSourceFile();
16
- const file = sourceFile.getFilePath();
17
- const line = node.getStartLineNumber();
18
- const { column } = sourceFile.getLineAndColumnAtPos(node.getStart());
19
- const message = `@lunora/codegen: ${detail} (${file}:${line.toString()}:${column.toString()})`;
20
- const error = new CodegenDiagnosticError(message, file, line, column);
21
- return meta ? Object.assign(error, meta) : error;
22
- };
23
-
24
- export { CodegenDiagnosticError, diagnosticAt };
@@ -1,139 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import { SyntaxKind, Node } from 'ts-morph';
4
- import { listLunoraSourceFiles } from './discoverFunctions-CZ91aenA.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 };
@@ -1,4 +0,0 @@
1
- import '@lunora/agent/component';
2
- import '@lunora/errors';
3
- export { G as GENERATED_HEADER, n as buildStorageColumns, e as emitAgents, a as emitApi, b as emitCollections, c as emitContainers, d as emitCrons, f as emitDataModel, g as emitDrizzleSchema, h as emitFunctions, o as emitQueues, p as emitSeed, i as emitServer, j as emitShard, k as emitVectors, l as emitWorkflows, m as emitWranglerCronTriggers } from './emit-DtherCpQ.mjs';
4
- import './paths-BRd6JHuF.mjs';
@@ -1,68 +0,0 @@
1
- import { jsonSchemaFromNode, objectSchemaFromNodes } from '@lunora/values';
2
-
3
- const literalConst = (literalValue) => {
4
- if (literalValue === void 0) {
5
- return {};
6
- }
7
- const trimmed = literalValue.trim();
8
- if (trimmed === "true") {
9
- return { const: true };
10
- }
11
- if (trimmed === "false") {
12
- return { const: false };
13
- }
14
- if (trimmed === "null") {
15
- return { const: null, type: "null" };
16
- }
17
- if (trimmed.startsWith('"') && trimmed.endsWith('"')) {
18
- try {
19
- return { const: JSON.parse(trimmed), type: "string" };
20
- } catch {
21
- return { const: trimmed.slice(1, -1), type: "string" };
22
- }
23
- }
24
- if (trimmed.startsWith("'") && trimmed.endsWith("'")) {
25
- return { const: trimmed.slice(1, -1), type: "string" };
26
- }
27
- const asNumber = Number(trimmed);
28
- if (!Number.isNaN(asNumber)) {
29
- return { const: asNumber };
30
- }
31
- return { const: trimmed };
32
- };
33
- const irReader = {
34
- constraints: () => void 0,
35
- inner: (validator) => validator.inner,
36
- isNullable: (validator) => validator.column?.notNull === false,
37
- // `ValidatorIR.kind` is a loose `string` (build-time AST); narrow it to the
38
- // shared reader's `ValidatorKind`. Unknown kinds fall through the mapper's
39
- // `default` branch to an empty schema, exactly as before.
40
- kind: (validator) => validator.kind,
41
- literalSchema: (validator) => literalConst(validator.literalValue),
42
- members: (validator) => validator.members ?? [],
43
- shape: (validator) => validator.shape ?? {},
44
- tableName: (validator) => validator.tableName,
45
- valueChild: (validator) => validator.valueType
46
- };
47
- const validatorIrToJsonSchema = (validator) => jsonSchemaFromNode(validator, irReader);
48
- const objectSchema = (shape) => objectSchemaFromNodes(shape, irReader);
49
- const argsObjectSchema = (args) => objectSchema(args);
50
- const LUNORA_ERROR_CODES = [
51
- "BAD_REQUEST",
52
- "CONFLICT",
53
- "COUNT_RLS_UNSUPPORTED",
54
- "FORBIDDEN",
55
- "FUNCTION_NOT_FOUND",
56
- "INTERNAL",
57
- "INTERNAL_SERVER_ERROR",
58
- "METHOD_NOT_ALLOWED",
59
- "NOT_FOUND",
60
- "NOT_IMPLEMENTED",
61
- "PAYLOAD_TOO_LARGE",
62
- "TOO_MANY_REQUESTS",
63
- "UNAUTHORIZED",
64
- "UNPROCESSABLE",
65
- "VALIDATION_ERROR"
66
- ];
67
-
68
- export { LUNORA_ERROR_CODES, argsObjectSchema, literalConst, objectSchema, validatorIrToJsonSchema };
@@ -1,81 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import { Node, SyntaxKind } from 'ts-morph';
4
- import { diagnosticAt } from './CodegenDiagnosticError-DyQ5FwkM.mjs';
5
-
6
- const MUTATORS_FILENAME = "mutators.ts";
7
- const MUTATOR_MODULE_SPECIFIERS = /* @__PURE__ */ new Set(["@lunora/server", "lunorash/server"]);
8
- const isDefineMutator = (identifier) => {
9
- const symbol = identifier.getSymbol();
10
- if (!symbol) {
11
- return identifier.getText() === "defineMutator";
12
- }
13
- for (const declaration of symbol.getDeclarations()) {
14
- if (!Node.isImportSpecifier(declaration)) {
15
- continue;
16
- }
17
- if (!MUTATOR_MODULE_SPECIFIERS.has(declaration.getImportDeclaration().getModuleSpecifierValue())) {
18
- return false;
19
- }
20
- return declaration.getNameNode().getText() === "defineMutator";
21
- }
22
- return false;
23
- };
24
- const isMutatorNamespaceImport = (identifier) => {
25
- const symbol = identifier.getSymbol();
26
- if (!symbol) {
27
- return false;
28
- }
29
- for (const declaration of symbol.getDeclarations()) {
30
- if (!Node.isNamespaceImport(declaration)) {
31
- continue;
32
- }
33
- const importDeclaration = declaration.getFirstAncestorByKind(SyntaxKind.ImportDeclaration);
34
- return importDeclaration !== void 0 && MUTATOR_MODULE_SPECIFIERS.has(importDeclaration.getModuleSpecifierValue());
35
- }
36
- return false;
37
- };
38
- const isDefineMutatorCallee = (callee) => {
39
- if (Node.isIdentifier(callee)) {
40
- return isDefineMutator(callee);
41
- }
42
- if (Node.isPropertyAccessExpression(callee)) {
43
- const object = callee.getExpression();
44
- return callee.getName() === "defineMutator" && Node.isIdentifier(object) && isMutatorNamespaceImport(object);
45
- }
46
- return false;
47
- };
48
- const mutatorsFromSource = (source) => {
49
- const mutators = [];
50
- for (const declaration of source.getVariableDeclarations()) {
51
- if (!declaration.isExported()) {
52
- continue;
53
- }
54
- const initializer = declaration.getInitializer();
55
- if (initializer?.getKind() !== SyntaxKind.CallExpression) {
56
- continue;
57
- }
58
- const callee = initializer.getExpression();
59
- if (!isDefineMutatorCallee(callee)) {
60
- continue;
61
- }
62
- const nameNode = declaration.getNameNode();
63
- if (!Node.isIdentifier(nameNode)) {
64
- throw diagnosticAt(nameNode, "defineMutator exports must be plain named exports (no destructuring)");
65
- }
66
- mutators.push({ exportName: nameNode.getText(), filePath: "mutators" });
67
- }
68
- return mutators;
69
- };
70
- const discoverMutators = (project, lunoraDirectory) => {
71
- const mutatorsPath = join(lunoraDirectory, MUTATORS_FILENAME);
72
- if (!existsSync(mutatorsPath)) {
73
- return [];
74
- }
75
- const source = project.getSourceFile(mutatorsPath) ?? project.addSourceFileAtPath(mutatorsPath);
76
- const mutators = mutatorsFromSource(source);
77
- mutators.sort((a, b) => a.exportName.localeCompare(b.exportName));
78
- return mutators;
79
- };
80
-
81
- export { MUTATORS_FILENAME, discoverMutators, isDefineMutatorCallee };