@lunora/codegen 1.0.0-alpha.25 → 1.0.0-alpha.251

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 (113) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/index.d.mts +3734 -1247
  4. package/dist/index.d.ts +3734 -1247
  5. package/dist/index.mjs +1 -34
  6. package/dist/packem_shared/AGENTS_FILENAME-D8SgT3OR.mjs +1 -0
  7. package/dist/packem_shared/CAPABILITY_PROBES-BbW-W0N2.mjs +22 -0
  8. package/dist/packem_shared/CONTAINERS_FILENAME-C13yKxas.mjs +1 -0
  9. package/dist/packem_shared/CodegenDiagnosticError-BUXlG3P-.mjs +1 -0
  10. package/dist/packem_shared/DEFAULT_TARGET-vMWzRzRF.mjs +1 -0
  11. package/dist/packem_shared/FLAGS_FILENAME-W5XQz_Po.mjs +1 -0
  12. package/dist/packem_shared/GENERATED_HEADER-DSXl0YM2.mjs +1 -0
  13. package/dist/packem_shared/LUNORA_ERROR_CODES-C2s0xWQD.mjs +1 -0
  14. package/dist/packem_shared/MUTATORS_FILENAME-DqWOgC5Z.mjs +1 -0
  15. package/dist/packem_shared/NOTIFY_FILENAME-C1J_47et.mjs +1 -0
  16. package/dist/packem_shared/OPENRPC_VERSION-Cr7Zzp6s.mjs +3 -0
  17. package/dist/packem_shared/PROJECT_CONFIG_FILENAMES-DzOu-lSc.mjs +1 -0
  18. package/dist/packem_shared/QUEUES_FILENAME-RGwht3Xu.mjs +1 -0
  19. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-qrQnFo7L.mjs +11 -0
  20. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-C0oHwiJZ.mjs +2 -0
  21. package/dist/packem_shared/SDK_LANGUAGES-Df_CnJx5.mjs +372 -0
  22. package/dist/packem_shared/SHAPES_FILENAME-DRUFomCj.mjs +1 -0
  23. package/dist/packem_shared/SchemaSnapshotParseError-CPOXlFhI.mjs +18 -0
  24. package/dist/packem_shared/WORKFLOWS_FILENAME-4-ib4HH-.mjs +1 -0
  25. package/dist/packem_shared/buildOpenApiDocument-SxfElVzK.mjs +3 -0
  26. package/dist/packem_shared/chain-mte5djRJ.mjs +1 -0
  27. package/dist/packem_shared/classify-procedure-call-CmcShAze.mjs +1 -0
  28. package/dist/packem_shared/context-property-calls-CWf9-6G5.mjs +1 -0
  29. package/dist/packem_shared/declared-output-Iaar469J.mjs +1 -0
  30. package/dist/packem_shared/describeErrorLevelFindings-vzaGS9KL.mjs +1 -0
  31. package/dist/packem_shared/discoverAuthApiCalls-DoSN_yc3.mjs +1 -0
  32. package/dist/packem_shared/discoverCrons-BEALHx1S.mjs +1 -0
  33. package/dist/packem_shared/discoverFunctions-BcBzcG5x.mjs +1 -0
  34. package/dist/packem_shared/discoverHttpRoutes-CJHS4llq.mjs +1 -0
  35. package/dist/packem_shared/discoverHyperdriveCalls-Bkbh4tG7.mjs +1 -0
  36. package/dist/packem_shared/discoverInserts-DpuLYPPd.mjs +1 -0
  37. package/dist/packem_shared/discoverMaskProcedures-B0w8gM0S.mjs +1 -0
  38. package/dist/packem_shared/discoverMigrations-Dt7ywfZv.mjs +1 -0
  39. package/dist/packem_shared/discoverNondeterministicCalls-CNJV2BiP.mjs +1 -0
  40. package/dist/packem_shared/discoverQueries-BcdqjYky.mjs +1 -0
  41. package/dist/packem_shared/discoverR2sqlCalls-30Wtbc0P.mjs +1 -0
  42. package/dist/packem_shared/discoverRlsMetadata-mXBmPOGj.mjs +1 -0
  43. package/dist/packem_shared/discoverRlsProcedures-F4Cy-kSi.mjs +1 -0
  44. package/dist/packem_shared/discoverSandboxUsage-BnsPld5I.mjs +1 -0
  45. package/dist/packem_shared/discoverSchema-D5R60b4F.mjs +1 -0
  46. package/dist/packem_shared/discoverStorageRulesMetadata-D3Ot9g5f.mjs +1 -0
  47. package/dist/packem_shared/emitAgents-DtZrevpx.mjs +1 -0
  48. package/dist/packem_shared/emitApi-DdW9RyGG.mjs +154 -0
  49. package/dist/packem_shared/emitApp-Cp0kB4-N.mjs +860 -0
  50. package/dist/packem_shared/emitCrons-BRKXFGFu.mjs +83 -0
  51. package/dist/packem_shared/emitDataModel-D3WuEZ4b.mjs +113 -0
  52. package/dist/packem_shared/emitDrizzleSchema-Cv0HtLR3.mjs +15 -0
  53. package/dist/packem_shared/emitFunctions-BgNeOZt_.mjs +249 -0
  54. package/dist/packem_shared/emitServer-BOpHpi8r.mjs +370 -0
  55. package/dist/packem_shared/emitShard-HB5NPFdO.mjs +1 -0
  56. package/dist/packem_shared/exported-procedure-chains-D48EXUVQ.mjs +1 -0
  57. package/dist/packem_shared/fingerprintSchemaSources-Cl1CJFeh.mjs +1 -0
  58. package/dist/packem_shared/formatAdvisories-DwmUKYuc.mjs +2 -0
  59. package/dist/packem_shared/index-D7dKfGPh.mjs +1 -0
  60. package/dist/packem_shared/ir-DBSvhNa-.mjs +1 -0
  61. package/dist/packem_shared/isD1GlobalTable-udvHAAzD.mjs +1 -0
  62. package/dist/packem_shared/isTypedSchema-CKzc3ioR.mjs +4 -0
  63. package/dist/packem_shared/json-data-Chfs2Cz5.mjs +1 -0
  64. package/dist/packem_shared/listLunoraSourceFiles-CSlcBYlo.mjs +1 -0
  65. package/dist/packem_shared/loadProjectConfig-nNIDOrlR.mjs +1 -0
  66. package/dist/packem_shared/module-specifiers-WF8iAydP.mjs +1 -0
  67. package/dist/packem_shared/modules-DyCocr1e.mjs +1 -0
  68. package/dist/packem_shared/parse-validator-C6fHL7OS.mjs +1 -0
  69. package/dist/packem_shared/paths-C-9fwEgQ.mjs +1 -0
  70. package/dist/packem_shared/qualifiers-BhOL15WZ.mjs +1 -0
  71. package/dist/packem_shared/readPackageDependencies-C6h6FZuP.mjs +1 -0
  72. package/dist/packem_shared/readServiceBindings-CeQvSswr.mjs +1 -0
  73. package/dist/packem_shared/redact-Cy14LEnc.mjs +1 -0
  74. package/dist/packem_shared/schemaFromIr-BWFnvCVg.mjs +1 -0
  75. package/dist/packem_shared/shard-CyNCZP7J.mjs +1435 -0
  76. package/dist/packem_shared/shard-runtime-DMN3MgIM.mjs +321 -0
  77. package/dist/packem_shared/shared-DjUziztz.mjs +9 -0
  78. package/dist/packem_shared/sourceCapabilitySignals-oZFprILA.mjs +1 -0
  79. package/dist/packem_shared/unwrap-handler-return-DVY_kFF7.mjs +1 -0
  80. package/package.json +16 -7
  81. package/dist/packem_shared/CONTAINERS_FILENAME-DlP6YM_Q.mjs +0 -224
  82. package/dist/packem_shared/CodegenDiagnosticError-DeblMkzO.mjs +0 -23
  83. package/dist/packem_shared/FLAGS_FILENAME-B1vE0LIo.mjs +0 -139
  84. package/dist/packem_shared/GENERATED_HEADER-BullHnLo.mjs +0 -3265
  85. package/dist/packem_shared/LUNORA_ERROR_CODES-CySpQPD3.mjs +0 -61
  86. package/dist/packem_shared/LUNORA_SOLUTION_RULES-BTejmZp-.mjs +0 -131
  87. package/dist/packem_shared/MUTATORS_FILENAME-BhqdPtKp.mjs +0 -81
  88. package/dist/packem_shared/OPENRPC_VERSION-D7MAVX3K.mjs +0 -60
  89. package/dist/packem_shared/QUEUES_FILENAME-B5_eWCRe.mjs +0 -119
  90. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-BAcxxSdB.mjs +0 -1130
  91. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-wWGP2_5E.mjs +0 -245
  92. package/dist/packem_shared/SHAPES_FILENAME-ChV7MqgE.mjs +0 -94
  93. package/dist/packem_shared/WORKFLOWS_FILENAME-CCisG0Vy.mjs +0 -124
  94. package/dist/packem_shared/buildOpenApiDocument-Bm56LsBb.mjs +0 -183
  95. package/dist/packem_shared/discover-ast-CT6BgBr4.mjs +0 -13
  96. package/dist/packem_shared/discoverAuthApiCalls-CoirYbg6.mjs +0 -62
  97. package/dist/packem_shared/discoverCrons-Cev7RRAf.mjs +0 -257
  98. package/dist/packem_shared/discoverFunctions-BWMczzBx.mjs +0 -465
  99. package/dist/packem_shared/discoverHttpRoutes-CfP6cMzt.mjs +0 -131
  100. package/dist/packem_shared/discoverInserts-C7zxXkUf.mjs +0 -61
  101. package/dist/packem_shared/discoverMaskProcedures-Cm81kwrb.mjs +0 -217
  102. package/dist/packem_shared/discoverMigrations-Bi5nJ0mJ.mjs +0 -97
  103. package/dist/packem_shared/discoverNondeterministicCalls-C4M8AXmQ.mjs +0 -122
  104. package/dist/packem_shared/discoverQueries-B0wGT-xe.mjs +0 -62
  105. package/dist/packem_shared/discoverR2sqlCalls-BVNMd428.mjs +0 -80
  106. package/dist/packem_shared/discoverRlsMetadata-BS9GOGC5.mjs +0 -280
  107. package/dist/packem_shared/discoverSchema-KYq55qu3.mjs +0 -864
  108. package/dist/packem_shared/discoverStorageRulesMetadata-Da8BKXcI.mjs +0 -97
  109. package/dist/packem_shared/emitApp-BUN7hhlY.mjs +0 -666
  110. package/dist/packem_shared/formatAdvisories-DdjK7sgh.mjs +0 -81
  111. package/dist/packem_shared/parse-validator-Cabb60UV.mjs +0 -133
  112. package/dist/packem_shared/paths-BRd6JHuF.mjs +0 -11
  113. package/dist/packem_shared/schemaFromIr-DTYsLBaA.mjs +0 -57
@@ -1,23 +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, meta) => {
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
- const error = new CodegenDiagnosticError(message, file, line, column);
20
- return meta ? Object.assign(error, meta) : error;
21
- };
22
-
23
- 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-BWMczzBx.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 };