@lunora/codegen 1.0.0-alpha.7 → 1.0.0-alpha.8
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/dist/index.d.mts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.mjs +7 -7
- package/dist/packem_shared/{CONTAINERS_FILENAME-0K-pjNb8.mjs → CONTAINERS_FILENAME-DlP6YM_Q.mjs} +1 -1
- package/dist/packem_shared/{CodegenDiagnosticError-54jWDxA9.mjs → CodegenDiagnosticError-DeblMkzO.mjs} +3 -2
- package/dist/packem_shared/{SCHEMA_SNAPSHOT_FILENAME-g7kpX8hu.mjs → SCHEMA_SNAPSHOT_FILENAME-Ic_wUaIc.mjs} +20 -5
- package/dist/packem_shared/{WORKFLOWS_FILENAME-DRDQdhfq.mjs → WORKFLOWS_FILENAME-D62dcBGg.mjs} +1 -1
- package/dist/packem_shared/{discoverCrons-BL6iGuJ3.mjs → discoverCrons-nHPo3UeE.mjs} +19 -16
- package/dist/packem_shared/{discoverMigrations-Doj_-BAA.mjs → discoverMigrations-Dy24kmeD.mjs} +9 -3
- package/dist/packem_shared/{discoverSchema-DYl0QfDH.mjs → discoverSchema-fVmAXacI.mjs} +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -731,8 +731,14 @@ declare class CodegenDiagnosticError extends Error {
|
|
|
731
731
|
* ts-morph `Node`'s position in its source file.
|
|
732
732
|
*
|
|
733
733
|
* Message format: `@lunora/codegen: <detail> (<file>:<line>:<column>)`
|
|
734
|
+
*
|
|
735
|
+
* `meta` is merged onto the returned error for callers that also carry the
|
|
736
|
+
* project-wide `LunoraError` envelope (`code`/`name`/`status`) — it never
|
|
737
|
+
* touches `file`/`line`/`column`, and the error stays an instance of
|
|
738
|
+
* {@link CodegenDiagnosticError} so the Vite overlay's `instanceof` location
|
|
739
|
+
* lookup is unaffected.
|
|
734
740
|
*/
|
|
735
|
-
declare const diagnosticAt: (node: Node, detail: string) => CodegenDiagnosticError;
|
|
741
|
+
declare const diagnosticAt: (node: Node, detail: string, meta?: Record<string, unknown>) => CodegenDiagnosticError;
|
|
736
742
|
/**
|
|
737
743
|
* Discover `ctx.authApi.<method>(...)` (and bare `authApi.<method>(...)`) calls
|
|
738
744
|
* under the lunora source directory and attribute each to the exported function
|
|
@@ -1357,6 +1363,11 @@ declare const refreshCodegenProject: (project: Project, lunoraDirectory: string)
|
|
|
1357
1363
|
* Top-level codegen entry. Parses `<projectRoot>/lunora/schema.ts` and every
|
|
1358
1364
|
* function file under `<projectRoot>/lunora/`, then writes
|
|
1359
1365
|
* `_generated/{api,server,dataModel}.ts` next to them.
|
|
1366
|
+
*
|
|
1367
|
+
* When `LUNORA_CODEGEN_TIMING` is set (truthy), a single diagnostic summary
|
|
1368
|
+
* line is written to stderr with the total wall time and the discovery-vs-emit
|
|
1369
|
+
* split — opt-in instrumentation that is otherwise zero-cost and side-effect-free
|
|
1370
|
+
* on the returned {@link CodegenResult}.
|
|
1360
1371
|
*/
|
|
1361
1372
|
declare const runCodegen: (options: CodegenOptions) => CodegenResult;
|
|
1362
1373
|
interface CodegenOptions {
|
package/dist/index.d.ts
CHANGED
|
@@ -731,8 +731,14 @@ declare class CodegenDiagnosticError extends Error {
|
|
|
731
731
|
* ts-morph `Node`'s position in its source file.
|
|
732
732
|
*
|
|
733
733
|
* Message format: `@lunora/codegen: <detail> (<file>:<line>:<column>)`
|
|
734
|
+
*
|
|
735
|
+
* `meta` is merged onto the returned error for callers that also carry the
|
|
736
|
+
* project-wide `LunoraError` envelope (`code`/`name`/`status`) — it never
|
|
737
|
+
* touches `file`/`line`/`column`, and the error stays an instance of
|
|
738
|
+
* {@link CodegenDiagnosticError} so the Vite overlay's `instanceof` location
|
|
739
|
+
* lookup is unaffected.
|
|
734
740
|
*/
|
|
735
|
-
declare const diagnosticAt: (node: Node, detail: string) => CodegenDiagnosticError;
|
|
741
|
+
declare const diagnosticAt: (node: Node, detail: string, meta?: Record<string, unknown>) => CodegenDiagnosticError;
|
|
736
742
|
/**
|
|
737
743
|
* Discover `ctx.authApi.<method>(...)` (and bare `authApi.<method>(...)`) calls
|
|
738
744
|
* under the lunora source directory and attribute each to the exported function
|
|
@@ -1357,6 +1363,11 @@ declare const refreshCodegenProject: (project: Project, lunoraDirectory: string)
|
|
|
1357
1363
|
* Top-level codegen entry. Parses `<projectRoot>/lunora/schema.ts` and every
|
|
1358
1364
|
* function file under `<projectRoot>/lunora/`, then writes
|
|
1359
1365
|
* `_generated/{api,server,dataModel}.ts` next to them.
|
|
1366
|
+
*
|
|
1367
|
+
* When `LUNORA_CODEGEN_TIMING` is set (truthy), a single diagnostic summary
|
|
1368
|
+
* line is written to stderr with the total wall time and the discovery-vs-emit
|
|
1369
|
+
* split — opt-in instrumentation that is otherwise zero-cost and side-effect-free
|
|
1370
|
+
* on the returned {@link CodegenResult}.
|
|
1360
1371
|
*/
|
|
1361
1372
|
declare const runCodegen: (options: CodegenOptions) => CodegenResult;
|
|
1362
1373
|
interface CodegenOptions {
|
package/dist/index.mjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
export { formatAdvisories, lintSchema } from './packem_shared/formatAdvisories-8NIv1k0I.mjs';
|
|
2
|
-
export { CodegenDiagnosticError, diagnosticAt } from './packem_shared/CodegenDiagnosticError-
|
|
2
|
+
export { CodegenDiagnosticError, diagnosticAt } from './packem_shared/CodegenDiagnosticError-DeblMkzO.mjs';
|
|
3
3
|
export { default as discoverAuthApiCalls } from './packem_shared/discoverAuthApiCalls-C35R6z0T.mjs';
|
|
4
|
-
export { CONTAINERS_FILENAME, discoverContainers } from './packem_shared/CONTAINERS_FILENAME-
|
|
5
|
-
export { default as discoverCrons } from './packem_shared/discoverCrons-
|
|
4
|
+
export { CONTAINERS_FILENAME, discoverContainers } from './packem_shared/CONTAINERS_FILENAME-DlP6YM_Q.mjs';
|
|
5
|
+
export { default as discoverCrons } from './packem_shared/discoverCrons-nHPo3UeE.mjs';
|
|
6
6
|
export { discoverFunctions } from './packem_shared/discoverFunctions-DEgAcRuD.mjs';
|
|
7
7
|
export { default as discoverHttpRoutes } from './packem_shared/discoverHttpRoutes-C978pBiG.mjs';
|
|
8
8
|
export { default as discoverInserts } from './packem_shared/discoverInserts-pLBFsSAV.mjs';
|
|
9
9
|
export { default as discoverMaskProcedures } from './packem_shared/discoverMaskProcedures-B64zA740.mjs';
|
|
10
|
-
export { default as discoverMigrations } from './packem_shared/discoverMigrations-
|
|
10
|
+
export { default as discoverMigrations } from './packem_shared/discoverMigrations-Dy24kmeD.mjs';
|
|
11
11
|
export { default as discoverNondeterministicCalls } from './packem_shared/discoverNondeterministicCalls-4KiPQxQU.mjs';
|
|
12
12
|
export { default as discoverQueries } from './packem_shared/discoverQueries-BkIi0dBD.mjs';
|
|
13
13
|
export { default as discoverR2sqlCalls } from './packem_shared/discoverR2sqlCalls-BpDqvcUn.mjs';
|
|
14
14
|
export { discoverRlsMetadata, default as discoverRlsProcedures } from './packem_shared/discoverRlsMetadata-DpRB1HMe.mjs';
|
|
15
|
-
export { default as discoverSchema } from './packem_shared/discoverSchema-
|
|
15
|
+
export { default as discoverSchema } from './packem_shared/discoverSchema-fVmAXacI.mjs';
|
|
16
16
|
export { default as discoverStorageRulesMetadata } from './packem_shared/discoverStorageRulesMetadata-DAqJUxUv.mjs';
|
|
17
|
-
export { WORKFLOWS_FILENAME, discoverWorkflows } from './packem_shared/WORKFLOWS_FILENAME-
|
|
17
|
+
export { WORKFLOWS_FILENAME, discoverWorkflows } from './packem_shared/WORKFLOWS_FILENAME-D62dcBGg.mjs';
|
|
18
18
|
export { GENERATED_HEADER, emitApi, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers } from './packem_shared/GENERATED_HEADER-DF1hQcix.mjs';
|
|
19
19
|
export { emitApp } from './packem_shared/emitApp-Ci_hcJNO.mjs';
|
|
20
20
|
export { buildOpenApiDocument, emitOpenApi, emitOpenApiModule } from './packem_shared/buildOpenApiDocument-Cns1EkCQ.mjs';
|
|
21
21
|
export { OPENRPC_VERSION, buildOpenRpcDocument, emitOpenRpc, emitOpenRpcModule } from './packem_shared/OPENRPC_VERSION-C7zKVeKi.mjs';
|
|
22
|
-
export { SCHEMA_SNAPSHOT_FILENAME, createCodegenProject, refreshCodegenProject, runCodegen } from './packem_shared/SCHEMA_SNAPSHOT_FILENAME-
|
|
22
|
+
export { SCHEMA_SNAPSHOT_FILENAME, createCodegenProject, refreshCodegenProject, runCodegen } from './packem_shared/SCHEMA_SNAPSHOT_FILENAME-Ic_wUaIc.mjs';
|
|
23
23
|
export { SCHEMA_SNAPSHOT_VERSION, SchemaSnapshotParseError, buildSchemaSnapshot, diffSchemaSnapshots, evaluateSchemaDrift, parseSchemaSnapshot, serializeSchemaSnapshot } from './packem_shared/SCHEMA_SNAPSHOT_VERSION-DzLDbWk3.mjs';
|
|
24
24
|
export { schemaFromIr } from './packem_shared/schemaFromIr-DTYsLBaA.mjs';
|
|
25
25
|
export { LUNORA_ERROR_CODES, validatorIrToJsonSchema } from './packem_shared/LUNORA_ERROR_CODES-CySpQPD3.mjs';
|
package/dist/packem_shared/{CONTAINERS_FILENAME-0K-pjNb8.mjs → CONTAINERS_FILENAME-DlP6YM_Q.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-DeblMkzO.mjs';
|
|
6
6
|
|
|
7
7
|
const CONTAINERS_FILENAME = "containers.ts";
|
|
8
8
|
const isDefineContainer = (identifier) => {
|
|
@@ -10,13 +10,14 @@ class CodegenDiagnosticError extends Error {
|
|
|
10
10
|
this.column = column;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
const diagnosticAt = (node, detail) => {
|
|
13
|
+
const diagnosticAt = (node, detail, meta) => {
|
|
14
14
|
const sourceFile = node.getSourceFile();
|
|
15
15
|
const file = sourceFile.getFilePath();
|
|
16
16
|
const line = node.getStartLineNumber();
|
|
17
17
|
const { column } = sourceFile.getLineAndColumnAtPos(node.getStart());
|
|
18
18
|
const message = `@lunora/codegen: ${detail} (${file}:${line.toString()}:${column.toString()})`;
|
|
19
|
-
|
|
19
|
+
const error = new CodegenDiagnosticError(message, file, line, column);
|
|
20
|
+
return meta ? Object.assign(error, meta) : error;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
export { CodegenDiagnosticError, diagnosticAt };
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join, dirname } from 'node:path';
|
|
3
|
+
import { performance } from 'node:perf_hooks';
|
|
3
4
|
import { Node, SyntaxKind, Project } from 'ts-morph';
|
|
4
5
|
import { lintSchema } from './formatAdvisories-8NIv1k0I.mjs';
|
|
5
6
|
import { listLunoraSourceFiles, lunoraRelativePath, classifyProcedureCall, discoverFunctions } from './discoverFunctions-DEgAcRuD.mjs';
|
|
6
7
|
import discoverAuthApiCalls from './discoverAuthApiCalls-C35R6z0T.mjs';
|
|
7
|
-
import { discoverContainers } from './CONTAINERS_FILENAME-
|
|
8
|
-
import discoverCrons from './discoverCrons-
|
|
8
|
+
import { discoverContainers } from './CONTAINERS_FILENAME-DlP6YM_Q.mjs';
|
|
9
|
+
import discoverCrons from './discoverCrons-nHPo3UeE.mjs';
|
|
9
10
|
import discoverHttpRoutes from './discoverHttpRoutes-C978pBiG.mjs';
|
|
10
11
|
import discoverInserts from './discoverInserts-pLBFsSAV.mjs';
|
|
11
12
|
import discoverMaskProcedures, { discoverMaskMetadata } from './discoverMaskProcedures-B64zA740.mjs';
|
|
12
|
-
import discoverMigrations from './discoverMigrations-
|
|
13
|
+
import discoverMigrations from './discoverMigrations-Dy24kmeD.mjs';
|
|
13
14
|
import discoverNondeterministicCalls from './discoverNondeterministicCalls-4KiPQxQU.mjs';
|
|
14
15
|
import discoverQueries from './discoverQueries-BkIi0dBD.mjs';
|
|
15
16
|
import discoverR2sqlCalls from './discoverR2sqlCalls-BpDqvcUn.mjs';
|
|
16
17
|
import discoverRlsProcedures, { discoverRlsMetadata } from './discoverRlsMetadata-DpRB1HMe.mjs';
|
|
17
|
-
import discoverSchema from './discoverSchema-
|
|
18
|
+
import discoverSchema from './discoverSchema-fVmAXacI.mjs';
|
|
18
19
|
import discoverStorageRulesMetadata from './discoverStorageRulesMetadata-DAqJUxUv.mjs';
|
|
19
20
|
import { e as enclosingExportName$1 } from './discover-ast-CT6BgBr4.mjs';
|
|
20
|
-
import { discoverWorkflows } from './WORKFLOWS_FILENAME-
|
|
21
|
+
import { discoverWorkflows } from './WORKFLOWS_FILENAME-D62dcBGg.mjs';
|
|
21
22
|
import { buildStorageColumns, emitDataModel, emitApi, emitServer, emitFunctions, emitShard, emitContainers, emitWorkflows, emitCrons, emitVectors, emitDrizzleSchema, emitSeed, emitWranglerCronTriggers } from './GENERATED_HEADER-DF1hQcix.mjs';
|
|
22
23
|
import { emitApp } from './emitApp-Ci_hcJNO.mjs';
|
|
23
24
|
import { buildOpenApiDocument, emitOpenApiModule } from './buildOpenApiDocument-Cns1EkCQ.mjs';
|
|
@@ -676,6 +677,10 @@ const readProjectVersion = (projectRoot) => {
|
|
|
676
677
|
return void 0;
|
|
677
678
|
}
|
|
678
679
|
};
|
|
680
|
+
const isTimingEnabled = () => {
|
|
681
|
+
const flag = process.env["LUNORA_CODEGEN_TIMING"];
|
|
682
|
+
return flag !== void 0 && flag !== "";
|
|
683
|
+
};
|
|
679
684
|
const findTsconfig = (startPath) => {
|
|
680
685
|
let directory = existsSync(startPath) ? startPath : dirname(startPath);
|
|
681
686
|
while (directory && directory !== dirname(directory)) {
|
|
@@ -717,6 +722,8 @@ const refreshCodegenProject = (project, lunoraDirectory) => {
|
|
|
717
722
|
}
|
|
718
723
|
};
|
|
719
724
|
const runCodegen = (options) => {
|
|
725
|
+
const timingEnabled = isTimingEnabled();
|
|
726
|
+
const startedAt = timingEnabled ? performance.now() : 0;
|
|
720
727
|
const lunoraDirectory = join(options.projectRoot, options.lunoraDirectory ?? "lunora");
|
|
721
728
|
const schemaPath = join(lunoraDirectory, "schema.ts");
|
|
722
729
|
if (!existsSync(schemaPath)) {
|
|
@@ -771,6 +778,7 @@ const runCodegen = (options) => {
|
|
|
771
778
|
workflowCount: workflows.length
|
|
772
779
|
});
|
|
773
780
|
const useUmbrella = dependencies.has("lunorash");
|
|
781
|
+
const emitStartedAt = timingEnabled ? performance.now() : 0;
|
|
774
782
|
const dataModelContent = emitDataModel(schema, useUmbrella);
|
|
775
783
|
const apiContent = emitApi(functions, workflows, useUmbrella);
|
|
776
784
|
const serverContent = emitServer({
|
|
@@ -889,6 +897,13 @@ const runCodegen = (options) => {
|
|
|
889
897
|
writeIfChanged(schemaSnapshotPath, serializeSchemaSnapshot(schemaSnapshot));
|
|
890
898
|
}
|
|
891
899
|
}
|
|
900
|
+
if (timingEnabled) {
|
|
901
|
+
const finishedAt = performance.now();
|
|
902
|
+
const total = Math.round(finishedAt - startedAt);
|
|
903
|
+
const discovery = Math.round(emitStartedAt - startedAt);
|
|
904
|
+
const emit = Math.round(finishedAt - emitStartedAt);
|
|
905
|
+
console.error(`@lunora/codegen: codegen took ${total.toString()}ms (discovery ${discovery.toString()}ms, emit ${emit.toString()}ms)`);
|
|
906
|
+
}
|
|
892
907
|
return {
|
|
893
908
|
advisories,
|
|
894
909
|
containers,
|
package/dist/packem_shared/{WORKFLOWS_FILENAME-DRDQdhfq.mjs → WORKFLOWS_FILENAME-D62dcBGg.mjs}
RENAMED
|
@@ -2,7 +2,7 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { workflowDefaultName, workflowClassName, workflowBindingName } from '@lunora/workflow';
|
|
4
4
|
import { SyntaxKind, Node } from 'ts-morph';
|
|
5
|
-
import { diagnosticAt } from './CodegenDiagnosticError-
|
|
5
|
+
import { diagnosticAt } from './CodegenDiagnosticError-DeblMkzO.mjs';
|
|
6
6
|
|
|
7
7
|
const WORKFLOWS_FILENAME = "workflows.ts";
|
|
8
8
|
const isDefineWorkflow = (identifier) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isValidCronExpression, compileCronSchedule, CRON_SCHEDULE_KINDS } from '@lunora/scheduler';
|
|
2
2
|
import { SyntaxKind, Node } from 'ts-morph';
|
|
3
|
+
import { diagnosticAt } from './CodegenDiagnosticError-DeblMkzO.mjs';
|
|
3
4
|
import { listLunoraSourceFiles } from './discoverFunctions-DEgAcRuD.mjs';
|
|
4
5
|
import { s as sanitizeNamespace } from './paths-BRd6JHuF.mjs';
|
|
5
6
|
|
|
@@ -71,7 +72,7 @@ const literalValue = (node, jobName) => {
|
|
|
71
72
|
if (Node.isArrayLiteralExpression(node)) {
|
|
72
73
|
return node.getElements().map((element) => literalValue(element, jobName));
|
|
73
74
|
}
|
|
74
|
-
throw
|
|
75
|
+
throw diagnosticAt(node, `Cron job "${jobName}" passes a non-static value where a literal is required; codegen can only read literals.`, {
|
|
75
76
|
code: "CRON_NON_STATIC_VALUE",
|
|
76
77
|
name: "LunoraError",
|
|
77
78
|
status: 500
|
|
@@ -81,8 +82,9 @@ const objectLiteralValue = (object, jobName) => {
|
|
|
81
82
|
const result = {};
|
|
82
83
|
for (const property of object.getProperties()) {
|
|
83
84
|
if (!Node.isPropertyAssignment(property)) {
|
|
84
|
-
throw
|
|
85
|
-
|
|
85
|
+
throw diagnosticAt(
|
|
86
|
+
property,
|
|
87
|
+
`Cron job "${jobName}" uses an unsupported object property (shorthand/spread/method) where a static literal is required.`,
|
|
86
88
|
{
|
|
87
89
|
code: "CRON_NON_STATIC_VALUE",
|
|
88
90
|
name: "LunoraError",
|
|
@@ -100,8 +102,9 @@ const objectLiteralValue = (object, jobName) => {
|
|
|
100
102
|
const functionPathFromArgument = (call, index, jobName) => {
|
|
101
103
|
const argument = call.getArguments()[index];
|
|
102
104
|
if (!argument || !Node.isPropertyAccessExpression(argument)) {
|
|
103
|
-
throw
|
|
104
|
-
|
|
105
|
+
throw diagnosticAt(
|
|
106
|
+
call,
|
|
107
|
+
`Cron job "${jobName}" must reference a function statically (e.g. internal.email.digest); codegen cannot resolve a dynamic reference.`,
|
|
105
108
|
{
|
|
106
109
|
code: "CRON_NON_STATIC_FN",
|
|
107
110
|
name: "LunoraError",
|
|
@@ -112,7 +115,7 @@ const functionPathFromArgument = (call, index, jobName) => {
|
|
|
112
115
|
const functionName = argument.getName();
|
|
113
116
|
const receiver = argument.getExpression();
|
|
114
117
|
if (!Node.isPropertyAccessExpression(receiver)) {
|
|
115
|
-
throw
|
|
118
|
+
throw diagnosticAt(argument, `Cron job "${jobName}" function reference must be of the form internal.file.fn (two property accesses).`, {
|
|
116
119
|
code: "CRON_NON_STATIC_FN",
|
|
117
120
|
name: "LunoraError",
|
|
118
121
|
status: 500
|
|
@@ -133,8 +136,9 @@ const resolveTarget = (call, index, jobName, workflowsByName) => {
|
|
|
133
136
|
if (workflow) {
|
|
134
137
|
return workflowTarget(workflow);
|
|
135
138
|
}
|
|
136
|
-
throw
|
|
137
|
-
|
|
139
|
+
throw diagnosticAt(
|
|
140
|
+
argument,
|
|
141
|
+
`Cron job "${jobName}" targets workflows.${argument.getName()}, but no such workflow is declared in lunora/workflows.ts.`,
|
|
138
142
|
{
|
|
139
143
|
code: "CRON_NON_STATIC_FN",
|
|
140
144
|
name: "LunoraError",
|
|
@@ -149,10 +153,9 @@ const resolveTarget = (call, index, jobName, workflowsByName) => {
|
|
|
149
153
|
if (workflow) {
|
|
150
154
|
return workflowTarget(workflow);
|
|
151
155
|
}
|
|
152
|
-
throw
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
),
|
|
156
|
+
throw diagnosticAt(
|
|
157
|
+
argument,
|
|
158
|
+
`Cron job "${jobName}" references "${argument.getText()}", which is neither a function (internal.file.fn / api.file.fn) nor a declared workflow in lunora/workflows.ts.`,
|
|
156
159
|
{
|
|
157
160
|
code: "CRON_NON_STATIC_FN",
|
|
158
161
|
name: "LunoraError",
|
|
@@ -172,7 +175,7 @@ const cronFromCall = (call, callee, builderNames, workflowsByName) => {
|
|
|
172
175
|
}
|
|
173
176
|
const name = stringArgument(call, 0);
|
|
174
177
|
if (name === void 0 || name.trim() === "") {
|
|
175
|
-
throw
|
|
178
|
+
throw diagnosticAt(call, `A cron ".${method}(...)" registration must pass a non-empty string-literal name as its first argument.`, {
|
|
176
179
|
code: "CRON_NAME_NOT_STATIC",
|
|
177
180
|
name: "LunoraError",
|
|
178
181
|
status: 500
|
|
@@ -182,14 +185,14 @@ const cronFromCall = (call, callee, builderNames, workflowsByName) => {
|
|
|
182
185
|
if (method === "cron") {
|
|
183
186
|
const expression = stringArgument(call, 1);
|
|
184
187
|
if (expression === void 0) {
|
|
185
|
-
throw
|
|
188
|
+
throw diagnosticAt(call, `Cron job "${name}" must pass a string-literal cron expression to ".cron(...)".`, {
|
|
186
189
|
code: "CRON_EXPR_NOT_STATIC",
|
|
187
190
|
name: "LunoraError",
|
|
188
191
|
status: 500
|
|
189
192
|
});
|
|
190
193
|
}
|
|
191
194
|
if (!isValidCronExpression(expression)) {
|
|
192
|
-
throw
|
|
195
|
+
throw diagnosticAt(call, `Cron job "${name}" has an invalid cron expression "${expression}" — expected 5 or 6 space-separated fields.`, {
|
|
193
196
|
code: "CRON_EXPR_INVALID",
|
|
194
197
|
name: "LunoraError",
|
|
195
198
|
status: 500
|
|
@@ -199,7 +202,7 @@ const cronFromCall = (call, callee, builderNames, workflowsByName) => {
|
|
|
199
202
|
} else {
|
|
200
203
|
const scheduleArgument = call.getArguments()[1];
|
|
201
204
|
if (!scheduleArgument || !Node.isObjectLiteralExpression(scheduleArgument)) {
|
|
202
|
-
throw
|
|
205
|
+
throw diagnosticAt(call, `Cron job "${name}" must pass an object-literal schedule to ".${method}(...)".`, {
|
|
203
206
|
code: "CRON_SCHEDULE_NOT_STATIC",
|
|
204
207
|
name: "LunoraError",
|
|
205
208
|
status: 500
|
package/dist/packem_shared/{discoverMigrations-Doj_-BAA.mjs → discoverMigrations-Dy24kmeD.mjs}
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { relative, sep } from 'node:path';
|
|
2
2
|
import { SyntaxKind, Node } from 'ts-morph';
|
|
3
|
+
import { diagnosticAt } from './CodegenDiagnosticError-DeblMkzO.mjs';
|
|
3
4
|
import { listLunoraSourceFiles } from './discoverFunctions-DEgAcRuD.mjs';
|
|
4
5
|
|
|
5
6
|
const TS_EXTENSION_RE = /\.ts$/u;
|
|
@@ -43,9 +44,14 @@ const migrationFromDeclaration = (declaration, relativePath) => {
|
|
|
43
44
|
const id = stringProperty(argument, "id");
|
|
44
45
|
const exportName = declaration.getName();
|
|
45
46
|
if (id === void 0 || id.trim() === "") {
|
|
46
|
-
throw
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
throw diagnosticAt(
|
|
48
|
+
argument,
|
|
49
|
+
`Migration "${exportName}" in "${relativePath}" must declare \`id\` as a non-empty string literal so codegen can key the registry.`,
|
|
50
|
+
{
|
|
51
|
+
code: "MIGRATION_ID_NOT_STATIC",
|
|
52
|
+
name: "LunoraError",
|
|
53
|
+
status: 500
|
|
54
|
+
}
|
|
49
55
|
);
|
|
50
56
|
}
|
|
51
57
|
return { exportName, filePath: relativePath, id, table: stringProperty(argument, "table") ?? "" };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Node, SyntaxKind } from 'ts-morph';
|
|
2
|
-
import { diagnosticAt } from './CodegenDiagnosticError-
|
|
2
|
+
import { diagnosticAt } from './CodegenDiagnosticError-DeblMkzO.mjs';
|
|
3
3
|
import { a as parseObjectShape } from './parse-validator-tuQtHrsr.mjs';
|
|
4
4
|
import { createRequire } from 'node:module';
|
|
5
5
|
import { join } from 'node:path';
|