@lunora/codegen 1.0.0-alpha.1 → 1.0.0-alpha.100

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 (76) hide show
  1. package/LICENSE.md +6 -0
  2. package/__assets__/package-og.svg +1 -1
  3. package/dist/index.d.mts +2756 -884
  4. package/dist/index.d.ts +2756 -884
  5. package/dist/index.mjs +1 -28
  6. package/dist/packem_shared/AGENTS_FILENAME-Dk-k250h.mjs +1 -0
  7. package/dist/packem_shared/CONTAINERS_FILENAME-DQpyhY6c.mjs +1 -0
  8. package/dist/packem_shared/CodegenDiagnosticError-DPezpZTz.mjs +1 -0
  9. package/dist/packem_shared/DEFAULT_TARGET-CH5disA3.mjs +1 -0
  10. package/dist/packem_shared/FLAGS_FILENAME-Boqm0YCP.mjs +1 -0
  11. package/dist/packem_shared/GENERATED_HEADER-C5Dapn_Y.mjs +1 -0
  12. package/dist/packem_shared/LUNORA_ERROR_CODES-zfAI2OFs.mjs +1 -0
  13. package/dist/packem_shared/MUTATORS_FILENAME-Cp_JxLSz.mjs +1 -0
  14. package/dist/packem_shared/NOTIFY_FILENAME-DwyJ5I4Q.mjs +1 -0
  15. package/dist/packem_shared/OPENRPC_VERSION-DkNdVeNM.mjs +3 -0
  16. package/dist/packem_shared/QUEUES_FILENAME-QpMZsde0.mjs +1 -0
  17. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-hQUs7FJj.mjs +9 -0
  18. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-CFhF_hmg.mjs +2 -0
  19. package/dist/packem_shared/SHAPES_FILENAME-WxXOsYfe.mjs +1 -0
  20. package/dist/packem_shared/SchemaSnapshotParseError-BkgxjBPQ.mjs +16 -0
  21. package/dist/packem_shared/WORKFLOWS_FILENAME-Dz80zqeT.mjs +1 -0
  22. package/dist/packem_shared/buildOpenApiDocument-DcpvOBMi.mjs +3 -0
  23. package/dist/packem_shared/describeErrorLevelFindings-IhNx9gPr.mjs +1 -0
  24. package/dist/packem_shared/discover-ast-7ABwvTVn.mjs +1 -0
  25. package/dist/packem_shared/discover-queries-i4Vd2si7.mjs +1 -0
  26. package/dist/packem_shared/discoverAuthApiCalls-XfNbxqlq.mjs +1 -0
  27. package/dist/packem_shared/discoverCrons-RlATa0_t.mjs +1 -0
  28. package/dist/packem_shared/discoverFunctions-4TNKUv7P.mjs +1 -0
  29. package/dist/packem_shared/discoverHttpRoutes-DQivLBqT.mjs +1 -0
  30. package/dist/packem_shared/discoverInserts-D6szWzrV.mjs +1 -0
  31. package/dist/packem_shared/discoverMaskProcedures-BBPqLXA5.mjs +1 -0
  32. package/dist/packem_shared/discoverMigrations-rbjxflR8.mjs +1 -0
  33. package/dist/packem_shared/discoverNondeterministicCalls-Bxr652Rz.mjs +1 -0
  34. package/dist/packem_shared/discoverQueries-uFtLDmn_.mjs +1 -0
  35. package/dist/packem_shared/discoverR2sqlCalls-DMxG6gHr.mjs +1 -0
  36. package/dist/packem_shared/discoverRlsMetadata-B63ARnKG.mjs +1 -0
  37. package/dist/packem_shared/discoverSandboxUsage-DBM98vVh.mjs +1 -0
  38. package/dist/packem_shared/discoverSchema-BNr7PVcZ.mjs +1 -0
  39. package/dist/packem_shared/discoverStorageRulesMetadata-_40MGqRX.mjs +1 -0
  40. package/dist/packem_shared/emit-B8FxCABN.mjs +2054 -0
  41. package/dist/packem_shared/emitApp-Dg-jOuj6.mjs +526 -0
  42. package/dist/packem_shared/formatAdvisories-CQvIhQ04.mjs +2 -0
  43. package/dist/packem_shared/module-specifiers-8FEEiUcv.mjs +1 -0
  44. package/dist/packem_shared/parse-validator-CusS8QwU.mjs +1 -0
  45. package/dist/packem_shared/paths-BmX5O1sG.mjs +1 -0
  46. package/dist/packem_shared/readPackageDependencies-CogJX1Ia.mjs +1 -0
  47. package/dist/packem_shared/redact-6jD4lAhq.mjs +1 -0
  48. package/dist/packem_shared/schemaFromIr-R1ZFzVyy.mjs +1 -0
  49. package/package.json +12 -7
  50. package/dist/packem_shared/CONTAINERS_FILENAME-0K-pjNb8.mjs +0 -224
  51. package/dist/packem_shared/CodegenDiagnosticError-54jWDxA9.mjs +0 -22
  52. package/dist/packem_shared/LUNORA_ERROR_CODES-CySpQPD3.mjs +0 -61
  53. package/dist/packem_shared/buildOpenApiDocument-yHVN66Xd.mjs +0 -183
  54. package/dist/packem_shared/buildOpenRpcDocument-BZGY1-jT.mjs +0 -60
  55. package/dist/packem_shared/buildSchemaSnapshot-DzLDbWk3.mjs +0 -233
  56. package/dist/packem_shared/createCodegenProject-DGJm0_Pk.mjs +0 -895
  57. package/dist/packem_shared/discover-ast-CT6BgBr4.mjs +0 -13
  58. package/dist/packem_shared/discoverAuthApiCalls-C35R6z0T.mjs +0 -62
  59. package/dist/packem_shared/discoverCrons-BL6iGuJ3.mjs +0 -254
  60. package/dist/packem_shared/discoverFunctions-DEgAcRuD.mjs +0 -460
  61. package/dist/packem_shared/discoverHttpRoutes-C978pBiG.mjs +0 -131
  62. package/dist/packem_shared/discoverInserts-CRQdXvHO.mjs +0 -39
  63. package/dist/packem_shared/discoverMaskProcedures-B64zA740.mjs +0 -217
  64. package/dist/packem_shared/discoverMigrations-Doj_-BAA.mjs +0 -91
  65. package/dist/packem_shared/discoverNondeterministicCalls-4KiPQxQU.mjs +0 -122
  66. package/dist/packem_shared/discoverQueries-BkIi0dBD.mjs +0 -62
  67. package/dist/packem_shared/discoverRlsMetadata-DpRB1HMe.mjs +0 -280
  68. package/dist/packem_shared/discoverSchema-BBulgGbH.mjs +0 -542
  69. package/dist/packem_shared/discoverStorageRulesMetadata-DAqJUxUv.mjs +0 -97
  70. package/dist/packem_shared/discoverWorkflows-DRDQdhfq.mjs +0 -84
  71. package/dist/packem_shared/emitApi-hRVC-kE7.mjs +0 -2426
  72. package/dist/packem_shared/emitApp-CzZ6GbrD.mjs +0 -593
  73. package/dist/packem_shared/lintSchema-DicbOHvH.mjs +0 -68
  74. package/dist/packem_shared/parse-validator-tuQtHrsr.mjs +0 -132
  75. package/dist/packem_shared/paths-BRd6JHuF.mjs +0 -11
  76. package/dist/packem_shared/schemaFromIr-DTYsLBaA.mjs +0 -57
@@ -1,84 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import { workflowDefaultName, workflowClassName, workflowBindingName } from '@lunora/workflow';
4
- import { SyntaxKind, Node } from 'ts-morph';
5
- import { diagnosticAt } from './CodegenDiagnosticError-54jWDxA9.mjs';
6
-
7
- const WORKFLOWS_FILENAME = "workflows.ts";
8
- const isDefineWorkflow = (identifier) => {
9
- const symbol = identifier.getSymbol();
10
- if (!symbol) {
11
- return identifier.getText() === "defineWorkflow";
12
- }
13
- for (const declaration of symbol.getDeclarations()) {
14
- if (!Node.isImportSpecifier(declaration)) {
15
- continue;
16
- }
17
- if (declaration.getImportDeclaration().getModuleSpecifierValue() !== "@lunora/workflow") {
18
- return false;
19
- }
20
- return declaration.getNameNode().getText() === "defineWorkflow";
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
- `workflow "${exportName}": \`${property}\` must be a static string literal — it is deploy configuration codegen writes into wrangler.jsonc`
31
- );
32
- };
33
- const workflowFromCall = (call, exportName) => {
34
- const argument = call.getArguments()[0];
35
- if (!argument || !Node.isObjectLiteralExpression(argument)) {
36
- throw diagnosticAt(call, `workflow "${exportName}": defineWorkflow must be passed an inline object literal`);
37
- }
38
- const ir = {
39
- bindingName: workflowBindingName(exportName),
40
- className: workflowClassName(exportName),
41
- exportName,
42
- name: workflowDefaultName(exportName)
43
- };
44
- const nameProperty = argument.getProperty("name");
45
- if (nameProperty && Node.isPropertyAssignment(nameProperty)) {
46
- ir.name = stringProperty(nameProperty.getInitializerOrThrow(), exportName, "name");
47
- }
48
- return ir;
49
- };
50
- const workflowsFromSource = (source) => {
51
- const workflows = [];
52
- for (const declaration of source.getVariableDeclarations()) {
53
- if (!declaration.isExported()) {
54
- continue;
55
- }
56
- const initializer = declaration.getInitializer();
57
- if (initializer?.getKind() !== SyntaxKind.CallExpression) {
58
- continue;
59
- }
60
- const call = initializer;
61
- const callee = call.getExpression();
62
- if (!Node.isIdentifier(callee) || !isDefineWorkflow(callee)) {
63
- continue;
64
- }
65
- const nameNode = declaration.getNameNode();
66
- if (!Node.isIdentifier(nameNode)) {
67
- throw diagnosticAt(nameNode, "defineWorkflow exports must be plain named exports (no destructuring)");
68
- }
69
- workflows.push(workflowFromCall(call, nameNode.getText()));
70
- }
71
- return workflows;
72
- };
73
- const discoverWorkflows = (project, lunoraDirectory) => {
74
- const workflowsPath = join(lunoraDirectory, WORKFLOWS_FILENAME);
75
- if (!existsSync(workflowsPath)) {
76
- return [];
77
- }
78
- const source = project.getSourceFile(workflowsPath) ?? project.addSourceFileAtPath(workflowsPath);
79
- const workflows = workflowsFromSource(source);
80
- workflows.sort((a, b) => a.exportName.localeCompare(b.exportName));
81
- return workflows;
82
- };
83
-
84
- export { WORKFLOWS_FILENAME, discoverWorkflows };