@lunora/codegen 1.0.0-alpha.28 → 1.0.0-alpha.29
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 +10 -53
- package/dist/index.d.ts +10 -53
- package/dist/index.mjs +27 -27
- package/dist/packem_shared/{CONTAINERS_FILENAME-DlP6YM_Q.mjs → CONTAINERS_FILENAME-DjpXMqhp.mjs} +1 -1
- package/dist/packem_shared/{CodegenDiagnosticError-DeblMkzO.mjs → CodegenDiagnosticError-DyQ5FwkM.mjs} +4 -3
- package/dist/packem_shared/{FLAGS_FILENAME-B1vE0LIo.mjs → FLAGS_FILENAME-CQz5jIns.mjs} +1 -1
- package/dist/packem_shared/{GENERATED_HEADER-Bq7mlUUg.mjs → GENERATED_HEADER-f6nMvllu.mjs} +9 -4
- package/dist/packem_shared/{MUTATORS_FILENAME-BhqdPtKp.mjs → MUTATORS_FILENAME-BZOfUhlY.mjs} +1 -1
- package/dist/packem_shared/{OPENRPC_VERSION-CPz5aJ8A.mjs → OPENRPC_VERSION-u5SqDDGk.mjs} +1 -1
- package/dist/packem_shared/{QUEUES_FILENAME-B5_eWCRe.mjs → QUEUES_FILENAME-BF0iUmx7.mjs} +1 -1
- package/dist/packem_shared/{SCHEMA_SNAPSHOT_FILENAME-BSBSVXEv.mjs → SCHEMA_SNAPSHOT_FILENAME-DtCmOeaL.mjs} +27 -26
- package/dist/packem_shared/{SCHEMA_SNAPSHOT_VERSION-wWGP2_5E.mjs → SCHEMA_SNAPSHOT_VERSION-D0ARY6rL.mjs} +6 -2
- package/dist/packem_shared/{SHAPES_FILENAME-ChV7MqgE.mjs → SHAPES_FILENAME-DOhPGi-6.mjs} +1 -1
- package/dist/packem_shared/{WORKFLOWS_FILENAME-CCisG0Vy.mjs → WORKFLOWS_FILENAME-CCC_42o3.mjs} +1 -1
- package/dist/packem_shared/{buildOpenApiDocument-DLAW4ldJ.mjs → buildOpenApiDocument-AgKWmlry.mjs} +1 -1
- package/dist/packem_shared/{discoverAuthApiCalls-CoirYbg6.mjs → discoverAuthApiCalls-CGjWoLJ3.mjs} +1 -1
- package/dist/packem_shared/{discoverCrons-Cev7RRAf.mjs → discoverCrons-De98wIzl.mjs} +2 -2
- package/dist/packem_shared/{discoverFunctions-BWMczzBx.mjs → discoverFunctions-CCVrvWhX.mjs} +1 -1
- package/dist/packem_shared/{discoverHttpRoutes-CfP6cMzt.mjs → discoverHttpRoutes-3tvf_95b.mjs} +2 -2
- package/dist/packem_shared/{discoverInserts-C7zxXkUf.mjs → discoverInserts-B0k4i6Yu.mjs} +1 -1
- package/dist/packem_shared/{discoverMaskProcedures-Cm81kwrb.mjs → discoverMaskProcedures-C0sofRvW.mjs} +1 -1
- package/dist/packem_shared/{discoverMigrations-Bi5nJ0mJ.mjs → discoverMigrations-DfBWvCoA.mjs} +2 -2
- package/dist/packem_shared/{discoverNondeterministicCalls-C4M8AXmQ.mjs → discoverNondeterministicCalls-DXiWO-nI.mjs} +1 -1
- package/dist/packem_shared/{discoverQueries-B0wGT-xe.mjs → discoverQueries-B9KbrYF9.mjs} +1 -1
- package/dist/packem_shared/{discoverR2sqlCalls-BVNMd428.mjs → discoverR2sqlCalls-CkBDIqPt.mjs} +1 -1
- package/dist/packem_shared/{discoverRlsMetadata-BS9GOGC5.mjs → discoverRlsMetadata-BXrKzID4.mjs} +1 -1
- package/dist/packem_shared/{discoverSchema-KYq55qu3.mjs → discoverSchema-B9Xfdg5V.mjs} +4 -3
- package/dist/packem_shared/{discoverStorageRulesMetadata-Da8BKXcI.mjs → discoverStorageRulesMetadata-C1Q-Ct2p.mjs} +1 -1
- package/dist/packem_shared/{emitApp-YuSwauCv.mjs → emitApp-DKt3rPtr.mjs} +1 -1
- package/dist/packem_shared/{parse-validator-Cabb60UV.mjs → parse-validator-D6zI2i85.mjs} +3 -2
- package/package.json +8 -7
- package/dist/packem_shared/LUNORA_SOLUTION_RULES-BTejmZp-.mjs +0 -131
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Finding } from '@lunora/advisor';
|
|
2
2
|
export type { Finding } from '@lunora/advisor';
|
|
3
|
+
import { LunoraError } from '@lunora/errors';
|
|
4
|
+
export { MESSAGE_SOLUTIONS as LUNORA_SOLUTION_RULES, type Solution as LunoraSolution, type SolutionRule as LunoraSolutionRule, findSolutionByMessage as findLunoraSolution } from '@lunora/errors';
|
|
3
5
|
import { Node, Project } from 'ts-morph';
|
|
4
6
|
import { StudioFeaturesResult } from '@lunora/do';
|
|
5
7
|
import { Schema } from '@lunora/server';
|
|
@@ -915,10 +917,12 @@ declare const formatAdvisories: (findings: ReadonlyArray<Finding>) => string;
|
|
|
915
917
|
/**
|
|
916
918
|
* An error thrown by codegen discovery when the user's schema or function
|
|
917
919
|
* source has a structural problem that can be pinpointed to a specific source
|
|
918
|
-
* location.
|
|
919
|
-
*
|
|
920
|
+
* location. A `LunoraError` subclass (`code: "CODEGEN_DIAGNOSTIC"`); the `file`,
|
|
921
|
+
* `line`, and `column` properties (also passed through as the base `loc`) mirror
|
|
922
|
+
* what Vite's error-overlay `loc` field expects so the browser can display the
|
|
923
|
+
* exact spot.
|
|
920
924
|
*/
|
|
921
|
-
declare class CodegenDiagnosticError extends
|
|
925
|
+
declare class CodegenDiagnosticError extends LunoraError {
|
|
922
926
|
readonly column: number;
|
|
923
927
|
readonly file: string;
|
|
924
928
|
readonly line: number;
|
|
@@ -1625,8 +1629,8 @@ declare const serializeSchemaSnapshot: (snapshot: SchemaSnapshot) => string;
|
|
|
1625
1629
|
* treat a corrupt baseline as a hard error rather than silently degrading to a
|
|
1626
1630
|
* "first capture" that would mask drift and then overwrite the bad file.
|
|
1627
1631
|
*/
|
|
1628
|
-
declare class SchemaSnapshotParseError extends
|
|
1629
|
-
|
|
1632
|
+
declare class SchemaSnapshotParseError extends LunoraError {
|
|
1633
|
+
constructor(message: string);
|
|
1630
1634
|
}
|
|
1631
1635
|
/**
|
|
1632
1636
|
* Parse a committed snapshot file. Returns `undefined` ONLY when the content is
|
|
@@ -1875,52 +1879,5 @@ declare const validatorIrToJsonSchema: (validator: ValidatorIR) => JsonSchema;
|
|
|
1875
1879
|
* the contract; clients switch on `error.code`. Kept sorted for stable output.
|
|
1876
1880
|
*/
|
|
1877
1881
|
declare const LUNORA_ERROR_CODES: ReadonlyArray<string>;
|
|
1878
|
-
/**
|
|
1879
|
-
* Lunora-specific error→solution hints. A small rule table mapping the exact
|
|
1880
|
-
* messages Lunora throws — codegen/schema diagnostics, worker-entry export gaps,
|
|
1881
|
-
* and the runtime data-layer conflicts — to an actionable fix.
|
|
1882
|
-
*
|
|
1883
|
-
* This table is the single source of truth shared by every consumer that wants
|
|
1884
|
-
* to turn a raw Lunora error into a fix hint: the Vite error overlay
|
|
1885
|
-
* (`@lunora/vite`) renders the Markdown in the browser, and the standalone
|
|
1886
|
-
* `lunora dev` CLI prints it to the terminal. It lives in `@lunora/codegen`
|
|
1887
|
-
* because codegen owns most of the throw sites, so the hints stay next to the
|
|
1888
|
-
* code that produces the messages.
|
|
1889
|
-
*
|
|
1890
|
-
* Matching is on the **message text**. By the time a diagnostic reaches a
|
|
1891
|
-
* consumer it has often been flattened to a plain `{ message }` (the overlay
|
|
1892
|
-
* pushes codegen errors through `server.hot.send` with `name === "Error"`), so
|
|
1893
|
-
* the class identity is gone and the message is the only stable signal.
|
|
1894
|
-
*
|
|
1895
|
-
* Bodies are Markdown — the overlay renders them; the CLI prints them (lightly
|
|
1896
|
-
* de-marked) as-is.
|
|
1897
|
-
*/
|
|
1898
|
-
/** A resolved hint for a recognized Lunora error. */
|
|
1899
|
-
interface LunoraSolution {
|
|
1900
|
-
/** Markdown body shown under the header. */
|
|
1901
|
-
body: string;
|
|
1902
|
-
/** Short header for the solution. */
|
|
1903
|
-
header: string;
|
|
1904
|
-
/** Stable id (used in DEBUG logs and tests). */
|
|
1905
|
-
id: string;
|
|
1906
|
-
}
|
|
1907
|
-
/** A single error→solution rule: a {@link LunoraSolution} plus its matcher. */
|
|
1908
|
-
interface LunoraSolutionRule extends LunoraSolution {
|
|
1909
|
-
/** True when this rule recognizes the error message. */
|
|
1910
|
-
test: (message: string) => boolean;
|
|
1911
|
-
}
|
|
1912
|
-
/**
|
|
1913
|
-
* The rules, ordered most- to least-specific: the dev-time codegen/schema rules
|
|
1914
|
-
* come first because they're the errors a developer hits while editing
|
|
1915
|
-
* `lunora/`, then the runtime data-layer conflicts that surface from the worker.
|
|
1916
|
-
* The first matching rule (in array order) wins.
|
|
1917
|
-
*/
|
|
1918
|
-
declare const LUNORA_SOLUTION_RULES: ReadonlyArray<LunoraSolutionRule>;
|
|
1919
|
-
/**
|
|
1920
|
-
* Find the first Lunora solution whose rule matches `message`, or `undefined`
|
|
1921
|
-
* if none recognize it. Consumers turn the returned Markdown into their own
|
|
1922
|
-
* presentation (overlay panel, terminal hint, …).
|
|
1923
|
-
*/
|
|
1924
|
-
declare const findLunoraSolution: (message: string) => LunoraSolution | undefined;
|
|
1925
1882
|
declare const VERSION = "0.0.0";
|
|
1926
|
-
export { type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type CronJobIR, type DriftChange, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES,
|
|
1883
|
+
export { type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type CronJobIR, type DriftChange, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type R2sqlCallIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SHAPES_FILENAME, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type ShapeIR, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, diagnosticAt, diffSchemaSnapshots, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, evaluateSchemaDrift, formatAdvisories, lintSchema, parseSchemaSnapshot, refreshCodegenProject, runCodegen, schemaFromIr, serializeSchemaSnapshot, validatorIrToJsonSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Finding } from '@lunora/advisor';
|
|
2
2
|
export type { Finding } from '@lunora/advisor';
|
|
3
|
+
import { LunoraError } from '@lunora/errors';
|
|
4
|
+
export { MESSAGE_SOLUTIONS as LUNORA_SOLUTION_RULES, type Solution as LunoraSolution, type SolutionRule as LunoraSolutionRule, findSolutionByMessage as findLunoraSolution } from '@lunora/errors';
|
|
3
5
|
import { Node, Project } from 'ts-morph';
|
|
4
6
|
import { StudioFeaturesResult } from '@lunora/do';
|
|
5
7
|
import { Schema } from '@lunora/server';
|
|
@@ -915,10 +917,12 @@ declare const formatAdvisories: (findings: ReadonlyArray<Finding>) => string;
|
|
|
915
917
|
/**
|
|
916
918
|
* An error thrown by codegen discovery when the user's schema or function
|
|
917
919
|
* source has a structural problem that can be pinpointed to a specific source
|
|
918
|
-
* location.
|
|
919
|
-
*
|
|
920
|
+
* location. A `LunoraError` subclass (`code: "CODEGEN_DIAGNOSTIC"`); the `file`,
|
|
921
|
+
* `line`, and `column` properties (also passed through as the base `loc`) mirror
|
|
922
|
+
* what Vite's error-overlay `loc` field expects so the browser can display the
|
|
923
|
+
* exact spot.
|
|
920
924
|
*/
|
|
921
|
-
declare class CodegenDiagnosticError extends
|
|
925
|
+
declare class CodegenDiagnosticError extends LunoraError {
|
|
922
926
|
readonly column: number;
|
|
923
927
|
readonly file: string;
|
|
924
928
|
readonly line: number;
|
|
@@ -1625,8 +1629,8 @@ declare const serializeSchemaSnapshot: (snapshot: SchemaSnapshot) => string;
|
|
|
1625
1629
|
* treat a corrupt baseline as a hard error rather than silently degrading to a
|
|
1626
1630
|
* "first capture" that would mask drift and then overwrite the bad file.
|
|
1627
1631
|
*/
|
|
1628
|
-
declare class SchemaSnapshotParseError extends
|
|
1629
|
-
|
|
1632
|
+
declare class SchemaSnapshotParseError extends LunoraError {
|
|
1633
|
+
constructor(message: string);
|
|
1630
1634
|
}
|
|
1631
1635
|
/**
|
|
1632
1636
|
* Parse a committed snapshot file. Returns `undefined` ONLY when the content is
|
|
@@ -1875,52 +1879,5 @@ declare const validatorIrToJsonSchema: (validator: ValidatorIR) => JsonSchema;
|
|
|
1875
1879
|
* the contract; clients switch on `error.code`. Kept sorted for stable output.
|
|
1876
1880
|
*/
|
|
1877
1881
|
declare const LUNORA_ERROR_CODES: ReadonlyArray<string>;
|
|
1878
|
-
/**
|
|
1879
|
-
* Lunora-specific error→solution hints. A small rule table mapping the exact
|
|
1880
|
-
* messages Lunora throws — codegen/schema diagnostics, worker-entry export gaps,
|
|
1881
|
-
* and the runtime data-layer conflicts — to an actionable fix.
|
|
1882
|
-
*
|
|
1883
|
-
* This table is the single source of truth shared by every consumer that wants
|
|
1884
|
-
* to turn a raw Lunora error into a fix hint: the Vite error overlay
|
|
1885
|
-
* (`@lunora/vite`) renders the Markdown in the browser, and the standalone
|
|
1886
|
-
* `lunora dev` CLI prints it to the terminal. It lives in `@lunora/codegen`
|
|
1887
|
-
* because codegen owns most of the throw sites, so the hints stay next to the
|
|
1888
|
-
* code that produces the messages.
|
|
1889
|
-
*
|
|
1890
|
-
* Matching is on the **message text**. By the time a diagnostic reaches a
|
|
1891
|
-
* consumer it has often been flattened to a plain `{ message }` (the overlay
|
|
1892
|
-
* pushes codegen errors through `server.hot.send` with `name === "Error"`), so
|
|
1893
|
-
* the class identity is gone and the message is the only stable signal.
|
|
1894
|
-
*
|
|
1895
|
-
* Bodies are Markdown — the overlay renders them; the CLI prints them (lightly
|
|
1896
|
-
* de-marked) as-is.
|
|
1897
|
-
*/
|
|
1898
|
-
/** A resolved hint for a recognized Lunora error. */
|
|
1899
|
-
interface LunoraSolution {
|
|
1900
|
-
/** Markdown body shown under the header. */
|
|
1901
|
-
body: string;
|
|
1902
|
-
/** Short header for the solution. */
|
|
1903
|
-
header: string;
|
|
1904
|
-
/** Stable id (used in DEBUG logs and tests). */
|
|
1905
|
-
id: string;
|
|
1906
|
-
}
|
|
1907
|
-
/** A single error→solution rule: a {@link LunoraSolution} plus its matcher. */
|
|
1908
|
-
interface LunoraSolutionRule extends LunoraSolution {
|
|
1909
|
-
/** True when this rule recognizes the error message. */
|
|
1910
|
-
test: (message: string) => boolean;
|
|
1911
|
-
}
|
|
1912
|
-
/**
|
|
1913
|
-
* The rules, ordered most- to least-specific: the dev-time codegen/schema rules
|
|
1914
|
-
* come first because they're the errors a developer hits while editing
|
|
1915
|
-
* `lunora/`, then the runtime data-layer conflicts that surface from the worker.
|
|
1916
|
-
* The first matching rule (in array order) wins.
|
|
1917
|
-
*/
|
|
1918
|
-
declare const LUNORA_SOLUTION_RULES: ReadonlyArray<LunoraSolutionRule>;
|
|
1919
|
-
/**
|
|
1920
|
-
* Find the first Lunora solution whose rule matches `message`, or `undefined`
|
|
1921
|
-
* if none recognize it. Consumers turn the returned Markdown into their own
|
|
1922
|
-
* presentation (overlay panel, terminal hint, …).
|
|
1923
|
-
*/
|
|
1924
|
-
declare const findLunoraSolution: (message: string) => LunoraSolution | undefined;
|
|
1925
1882
|
declare const VERSION = "0.0.0";
|
|
1926
|
-
export { type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type CronJobIR, type DriftChange, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES,
|
|
1883
|
+
export { type AuthApiCallIR, CONTAINERS_FILENAME, CodegenDiagnosticError, type CodegenOptions, type CodegenResult, type ContainerIR, type CronJobIR, type DriftChange, type EmitAppOptions, FLAGS_FILENAME, type FieldSnapshot, type FlagsIR, type FunctionIR, GENERATED_HEADER, type HttpRouteIR, type IndexIR, type IndexSnapshot, type InsertWriteIR, LUNORA_ERROR_CODES, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, OPENRPC_VERSION, type OpenApiEmitInput, type OpenRpcEmitInput, type ProjectIR, QUEUES_FILENAME, type QueryReadIR, type QueueIR, type R2sqlCallIR, type RelationSnapshot, type RlsMetadataIR, type RlsPolicyIR, type RlsProcedureIR, type RlsRoleIR, SCHEMA_SNAPSHOT_FILENAME, SCHEMA_SNAPSHOT_VERSION, SHAPES_FILENAME, type SchemaDrift, type SchemaDriftDecision, type SchemaIR, type SchemaSnapshot, SchemaSnapshotParseError, type ShapeIR, type StorageRuleIR, type StorageRulesMetadataIR, type TableIR, type TableSnapshot, VERSION, type ValidatorIR, type VectorIndexIR, WORKFLOWS_FILENAME, type WorkflowIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, diagnosticAt, diffSchemaSnapshots, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, evaluateSchemaDrift, formatAdvisories, lintSchema, parseSchemaSnapshot, refreshCodegenProject, runCodegen, schemaFromIr, serializeSchemaSnapshot, validatorIrToJsonSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
export { formatAdvisories, lintSchema } from './packem_shared/formatAdvisories-DdjK7sgh.mjs';
|
|
2
|
-
export { CodegenDiagnosticError, diagnosticAt } from './packem_shared/CodegenDiagnosticError-
|
|
3
|
-
export { default as discoverAuthApiCalls } from './packem_shared/discoverAuthApiCalls-
|
|
4
|
-
export { CONTAINERS_FILENAME, discoverContainers } from './packem_shared/CONTAINERS_FILENAME-
|
|
5
|
-
export { default as discoverCrons } from './packem_shared/discoverCrons-
|
|
6
|
-
export { FLAGS_FILENAME, discoverFlags } from './packem_shared/FLAGS_FILENAME-
|
|
7
|
-
export { discoverFunctions } from './packem_shared/discoverFunctions-
|
|
8
|
-
export { default as discoverHttpRoutes } from './packem_shared/discoverHttpRoutes-
|
|
9
|
-
export { default as discoverInserts } from './packem_shared/discoverInserts-
|
|
10
|
-
export { default as discoverMaskProcedures } from './packem_shared/discoverMaskProcedures-
|
|
11
|
-
export { default as discoverMigrations } from './packem_shared/discoverMigrations-
|
|
12
|
-
export { MUTATORS_FILENAME, discoverMutators } from './packem_shared/MUTATORS_FILENAME-
|
|
13
|
-
export { default as discoverNondeterministicCalls } from './packem_shared/discoverNondeterministicCalls-
|
|
14
|
-
export { default as discoverQueries } from './packem_shared/discoverQueries-
|
|
15
|
-
export { QUEUES_FILENAME, discoverQueues } from './packem_shared/QUEUES_FILENAME-
|
|
16
|
-
export { default as discoverR2sqlCalls } from './packem_shared/discoverR2sqlCalls-
|
|
17
|
-
export { discoverRlsMetadata, default as discoverRlsProcedures } from './packem_shared/discoverRlsMetadata-
|
|
18
|
-
export { default as discoverSchema } from './packem_shared/discoverSchema-
|
|
19
|
-
export { SHAPES_FILENAME, discoverShapes } from './packem_shared/SHAPES_FILENAME-
|
|
20
|
-
export { default as discoverStorageRulesMetadata } from './packem_shared/discoverStorageRulesMetadata-
|
|
21
|
-
export { WORKFLOWS_FILENAME, discoverWorkflows } from './packem_shared/WORKFLOWS_FILENAME-
|
|
22
|
-
export { GENERATED_HEADER, emitApi, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers } from './packem_shared/GENERATED_HEADER-
|
|
23
|
-
export { emitApp } from './packem_shared/emitApp-
|
|
24
|
-
export { buildOpenApiDocument, emitOpenApi, emitOpenApiModule } from './packem_shared/buildOpenApiDocument-
|
|
25
|
-
export { OPENRPC_VERSION, buildOpenRpcDocument, emitOpenRpc, emitOpenRpcModule } from './packem_shared/OPENRPC_VERSION-
|
|
26
|
-
export { SCHEMA_SNAPSHOT_FILENAME, createCodegenProject, refreshCodegenProject, runCodegen } from './packem_shared/SCHEMA_SNAPSHOT_FILENAME-
|
|
27
|
-
export { SCHEMA_SNAPSHOT_VERSION, SchemaSnapshotParseError, buildSchemaSnapshot, diffSchemaSnapshots, evaluateSchemaDrift, parseSchemaSnapshot, serializeSchemaSnapshot } from './packem_shared/SCHEMA_SNAPSHOT_VERSION-
|
|
2
|
+
export { CodegenDiagnosticError, diagnosticAt } from './packem_shared/CodegenDiagnosticError-DyQ5FwkM.mjs';
|
|
3
|
+
export { default as discoverAuthApiCalls } from './packem_shared/discoverAuthApiCalls-CGjWoLJ3.mjs';
|
|
4
|
+
export { CONTAINERS_FILENAME, discoverContainers } from './packem_shared/CONTAINERS_FILENAME-DjpXMqhp.mjs';
|
|
5
|
+
export { default as discoverCrons } from './packem_shared/discoverCrons-De98wIzl.mjs';
|
|
6
|
+
export { FLAGS_FILENAME, discoverFlags } from './packem_shared/FLAGS_FILENAME-CQz5jIns.mjs';
|
|
7
|
+
export { discoverFunctions } from './packem_shared/discoverFunctions-CCVrvWhX.mjs';
|
|
8
|
+
export { default as discoverHttpRoutes } from './packem_shared/discoverHttpRoutes-3tvf_95b.mjs';
|
|
9
|
+
export { default as discoverInserts } from './packem_shared/discoverInserts-B0k4i6Yu.mjs';
|
|
10
|
+
export { default as discoverMaskProcedures } from './packem_shared/discoverMaskProcedures-C0sofRvW.mjs';
|
|
11
|
+
export { default as discoverMigrations } from './packem_shared/discoverMigrations-DfBWvCoA.mjs';
|
|
12
|
+
export { MUTATORS_FILENAME, discoverMutators } from './packem_shared/MUTATORS_FILENAME-BZOfUhlY.mjs';
|
|
13
|
+
export { default as discoverNondeterministicCalls } from './packem_shared/discoverNondeterministicCalls-DXiWO-nI.mjs';
|
|
14
|
+
export { default as discoverQueries } from './packem_shared/discoverQueries-B9KbrYF9.mjs';
|
|
15
|
+
export { QUEUES_FILENAME, discoverQueues } from './packem_shared/QUEUES_FILENAME-BF0iUmx7.mjs';
|
|
16
|
+
export { default as discoverR2sqlCalls } from './packem_shared/discoverR2sqlCalls-CkBDIqPt.mjs';
|
|
17
|
+
export { discoverRlsMetadata, default as discoverRlsProcedures } from './packem_shared/discoverRlsMetadata-BXrKzID4.mjs';
|
|
18
|
+
export { default as discoverSchema } from './packem_shared/discoverSchema-B9Xfdg5V.mjs';
|
|
19
|
+
export { SHAPES_FILENAME, discoverShapes } from './packem_shared/SHAPES_FILENAME-DOhPGi-6.mjs';
|
|
20
|
+
export { default as discoverStorageRulesMetadata } from './packem_shared/discoverStorageRulesMetadata-C1Q-Ct2p.mjs';
|
|
21
|
+
export { WORKFLOWS_FILENAME, discoverWorkflows } from './packem_shared/WORKFLOWS_FILENAME-CCC_42o3.mjs';
|
|
22
|
+
export { GENERATED_HEADER, emitApi, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers } from './packem_shared/GENERATED_HEADER-f6nMvllu.mjs';
|
|
23
|
+
export { emitApp } from './packem_shared/emitApp-DKt3rPtr.mjs';
|
|
24
|
+
export { buildOpenApiDocument, emitOpenApi, emitOpenApiModule } from './packem_shared/buildOpenApiDocument-AgKWmlry.mjs';
|
|
25
|
+
export { OPENRPC_VERSION, buildOpenRpcDocument, emitOpenRpc, emitOpenRpcModule } from './packem_shared/OPENRPC_VERSION-u5SqDDGk.mjs';
|
|
26
|
+
export { SCHEMA_SNAPSHOT_FILENAME, createCodegenProject, refreshCodegenProject, runCodegen } from './packem_shared/SCHEMA_SNAPSHOT_FILENAME-DtCmOeaL.mjs';
|
|
27
|
+
export { SCHEMA_SNAPSHOT_VERSION, SchemaSnapshotParseError, buildSchemaSnapshot, diffSchemaSnapshots, evaluateSchemaDrift, parseSchemaSnapshot, serializeSchemaSnapshot } from './packem_shared/SCHEMA_SNAPSHOT_VERSION-D0ARY6rL.mjs';
|
|
28
28
|
export { schemaFromIr } from './packem_shared/schemaFromIr-DTYsLBaA.mjs';
|
|
29
29
|
export { LUNORA_ERROR_CODES, validatorIrToJsonSchema } from './packem_shared/LUNORA_ERROR_CODES-CySpQPD3.mjs';
|
|
30
|
-
export { LUNORA_SOLUTION_RULES, findLunoraSolution } from '
|
|
30
|
+
export { MESSAGE_SOLUTIONS as LUNORA_SOLUTION_RULES, findSolutionByMessage as findLunoraSolution } from '@lunora/errors';
|
|
31
31
|
|
|
32
32
|
const VERSION = "0.0.0";
|
|
33
33
|
|
package/dist/packem_shared/{CONTAINERS_FILENAME-DlP6YM_Q.mjs → CONTAINERS_FILENAME-DjpXMqhp.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-DyQ5FwkM.mjs';
|
|
6
6
|
|
|
7
7
|
const CONTAINERS_FILENAME = "containers.ts";
|
|
8
8
|
const isDefineContainer = (identifier) => {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
2
|
+
|
|
3
|
+
class CodegenDiagnosticError extends LunoraError {
|
|
2
4
|
column;
|
|
3
5
|
file;
|
|
4
6
|
line;
|
|
5
7
|
constructor(message, file, line, column) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = "CodegenDiagnosticError";
|
|
8
|
+
super("CODEGEN_DIAGNOSTIC", message, { location: { column, file, line }, name: "CodegenDiagnosticError" });
|
|
8
9
|
this.file = file;
|
|
9
10
|
this.line = line;
|
|
10
11
|
this.column = column;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { SyntaxKind, Node } from 'ts-morph';
|
|
4
|
-
import { listLunoraSourceFiles } from './discoverFunctions-
|
|
4
|
+
import { listLunoraSourceFiles } from './discoverFunctions-CCVrvWhX.mjs';
|
|
5
5
|
|
|
6
6
|
const FLAGS_FILENAME = "flags.ts";
|
|
7
7
|
const FLAG_TYPES = /* @__PURE__ */ new Set(["boolean", "number", "object", "string"]);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
1
2
|
import { s as sanitizeNamespace } from './paths-BRd6JHuF.mjs';
|
|
2
3
|
|
|
3
4
|
const LITERAL_VALUE_RE = /^(?:"[^"\\]*"|'[^'\\]*'|-?\d+(?:\.\d+)?|true|false|null)$/u;
|
|
@@ -193,7 +194,7 @@ const IDENTIFIER_RE = /^[A-Za-z_$][\w$]*$/u;
|
|
|
193
194
|
const IMPORT_PATH_RE = /^[\w./-]+$/u;
|
|
194
195
|
const assertIdentifier = (value, context) => {
|
|
195
196
|
if (!IDENTIFIER_RE.test(value)) {
|
|
196
|
-
throw new
|
|
197
|
+
throw new LunoraError("INTERNAL", `@lunora/codegen: ${context} is not a valid JS identifier: ${JSON.stringify(value)}`);
|
|
197
198
|
}
|
|
198
199
|
};
|
|
199
200
|
const renderPropertyKey = (fieldName) => IDENTIFIER_RE.test(fieldName) ? fieldName : JSON.stringify(fieldName);
|
|
@@ -220,7 +221,10 @@ const literalToType = (value) => {
|
|
|
220
221
|
return "unknown";
|
|
221
222
|
}
|
|
222
223
|
if (!LITERAL_VALUE_RE.test(value)) {
|
|
223
|
-
throw new
|
|
224
|
+
throw new LunoraError(
|
|
225
|
+
"INTERNAL",
|
|
226
|
+
`@lunora/codegen: v.literal() argument is not a parseable string/number/boolean/null literal: ${JSON.stringify(value)}`
|
|
227
|
+
);
|
|
224
228
|
}
|
|
225
229
|
return value;
|
|
226
230
|
};
|
|
@@ -657,7 +661,7 @@ const renderFunctionRegistry = (functions, migrations, mutators = [], shapes = [
|
|
|
657
661
|
}
|
|
658
662
|
const importLines = [...aliasByPath.entries()].map(([filePath, alias]) => {
|
|
659
663
|
if (!IMPORT_PATH_RE.test(filePath)) {
|
|
660
|
-
throw new
|
|
664
|
+
throw new LunoraError("INTERNAL", `@lunora/codegen: refusing to emit import for unsafe file path: ${JSON.stringify(filePath)}`);
|
|
661
665
|
}
|
|
662
666
|
return `import * as ${alias} from "../${filePath}.js";`;
|
|
663
667
|
}).join("\n");
|
|
@@ -2075,7 +2079,8 @@ const emitShard = ({
|
|
|
2075
2079
|
const hasD1Global = schema.tables.some((table) => table.shardMode === "global" && table.globalBackend !== "hyperdrive");
|
|
2076
2080
|
const hasSourcedTables = schema.tables.some((table) => table.externalSource !== void 0);
|
|
2077
2081
|
if (hasD1Global && hasHyperdriveGlobal) {
|
|
2078
|
-
throw new
|
|
2082
|
+
throw new LunoraError(
|
|
2083
|
+
"INTERNAL",
|
|
2079
2084
|
'lunora codegen: mixing `.global()` (D1) and `.global({ backend: "hyperdrive" })` tables in one app is not supported yet — use a single global backend.'
|
|
2080
2085
|
);
|
|
2081
2086
|
}
|
package/dist/packem_shared/{MUTATORS_FILENAME-BhqdPtKp.mjs → MUTATORS_FILENAME-BZOfUhlY.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { Node, SyntaxKind } from 'ts-morph';
|
|
4
|
-
import { diagnosticAt } from './CodegenDiagnosticError-
|
|
4
|
+
import { diagnosticAt } from './CodegenDiagnosticError-DyQ5FwkM.mjs';
|
|
5
5
|
|
|
6
6
|
const MUTATORS_FILENAME = "mutators.ts";
|
|
7
7
|
const MUTATOR_MODULE_SPECIFIERS = /* @__PURE__ */ new Set(["@lunora/server", "lunorash/server"]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GENERATED_HEADER } from './GENERATED_HEADER-
|
|
1
|
+
import { GENERATED_HEADER } from './GENERATED_HEADER-f6nMvllu.mjs';
|
|
2
2
|
import { s as sanitizeNamespace } from './paths-BRd6JHuF.mjs';
|
|
3
3
|
import { argsObjectSchema, LUNORA_ERROR_CODES } from './LUNORA_ERROR_CODES-CySpQPD3.mjs';
|
|
4
4
|
|
|
@@ -2,7 +2,7 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { queueDefaultName, queueBindingName } from '@lunora/queue';
|
|
4
4
|
import { SyntaxKind, Node } from 'ts-morph';
|
|
5
|
-
import { diagnosticAt } from './CodegenDiagnosticError-
|
|
5
|
+
import { diagnosticAt } from './CodegenDiagnosticError-DyQ5FwkM.mjs';
|
|
6
6
|
|
|
7
7
|
const QUEUES_FILENAME = "queues.ts";
|
|
8
8
|
const isDefineQueue = (identifier) => {
|
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
import { existsSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join, dirname } from 'node:path';
|
|
3
3
|
import { performance } from 'node:perf_hooks';
|
|
4
|
+
import { LunoraError } from '@lunora/errors';
|
|
4
5
|
import { Node, SyntaxKind, Project } from 'ts-morph';
|
|
5
6
|
import { lintSchema } from './formatAdvisories-DdjK7sgh.mjs';
|
|
6
|
-
import { listLunoraSourceFiles, lunoraRelativePath, classifyProcedureCall, discoverFunctions } from './discoverFunctions-
|
|
7
|
-
import discoverAuthApiCalls from './discoverAuthApiCalls-
|
|
8
|
-
import { discoverContainers } from './CONTAINERS_FILENAME-
|
|
9
|
-
import discoverCrons from './discoverCrons-
|
|
10
|
-
import { discoverFlagKeys } from './FLAGS_FILENAME-
|
|
11
|
-
import discoverHttpRoutes from './discoverHttpRoutes-
|
|
12
|
-
import { diagnosticAt } from './CodegenDiagnosticError-
|
|
13
|
-
import discoverInserts from './discoverInserts-
|
|
14
|
-
import discoverMaskProcedures, { discoverMaskMetadata } from './discoverMaskProcedures-
|
|
15
|
-
import discoverMigrations from './discoverMigrations-
|
|
16
|
-
import { MUTATORS_FILENAME, isDefineMutatorCallee, discoverMutators } from './MUTATORS_FILENAME-
|
|
17
|
-
import discoverNondeterministicCalls from './discoverNondeterministicCalls-
|
|
18
|
-
import discoverQueries from './discoverQueries-
|
|
19
|
-
import { discoverQueues } from './QUEUES_FILENAME-
|
|
20
|
-
import discoverR2sqlCalls from './discoverR2sqlCalls-
|
|
21
|
-
import discoverRlsProcedures, { discoverRlsMetadata } from './discoverRlsMetadata-
|
|
22
|
-
import discoverSchema from './discoverSchema-
|
|
23
|
-
import { discoverShapes } from './SHAPES_FILENAME-
|
|
24
|
-
import discoverStorageRulesMetadata from './discoverStorageRulesMetadata-
|
|
7
|
+
import { listLunoraSourceFiles, lunoraRelativePath, classifyProcedureCall, discoverFunctions } from './discoverFunctions-CCVrvWhX.mjs';
|
|
8
|
+
import discoverAuthApiCalls from './discoverAuthApiCalls-CGjWoLJ3.mjs';
|
|
9
|
+
import { discoverContainers } from './CONTAINERS_FILENAME-DjpXMqhp.mjs';
|
|
10
|
+
import discoverCrons from './discoverCrons-De98wIzl.mjs';
|
|
11
|
+
import { discoverFlagKeys } from './FLAGS_FILENAME-CQz5jIns.mjs';
|
|
12
|
+
import discoverHttpRoutes from './discoverHttpRoutes-3tvf_95b.mjs';
|
|
13
|
+
import { diagnosticAt } from './CodegenDiagnosticError-DyQ5FwkM.mjs';
|
|
14
|
+
import discoverInserts from './discoverInserts-B0k4i6Yu.mjs';
|
|
15
|
+
import discoverMaskProcedures, { discoverMaskMetadata } from './discoverMaskProcedures-C0sofRvW.mjs';
|
|
16
|
+
import discoverMigrations from './discoverMigrations-DfBWvCoA.mjs';
|
|
17
|
+
import { MUTATORS_FILENAME, isDefineMutatorCallee, discoverMutators } from './MUTATORS_FILENAME-BZOfUhlY.mjs';
|
|
18
|
+
import discoverNondeterministicCalls from './discoverNondeterministicCalls-DXiWO-nI.mjs';
|
|
19
|
+
import discoverQueries from './discoverQueries-B9KbrYF9.mjs';
|
|
20
|
+
import { discoverQueues } from './QUEUES_FILENAME-BF0iUmx7.mjs';
|
|
21
|
+
import discoverR2sqlCalls from './discoverR2sqlCalls-CkBDIqPt.mjs';
|
|
22
|
+
import discoverRlsProcedures, { discoverRlsMetadata } from './discoverRlsMetadata-BXrKzID4.mjs';
|
|
23
|
+
import discoverSchema from './discoverSchema-B9Xfdg5V.mjs';
|
|
24
|
+
import { discoverShapes } from './SHAPES_FILENAME-DOhPGi-6.mjs';
|
|
25
|
+
import discoverStorageRulesMetadata from './discoverStorageRulesMetadata-C1Q-Ct2p.mjs';
|
|
25
26
|
import { e as enclosingExportName$1 } from './discover-ast-CT6BgBr4.mjs';
|
|
26
|
-
import { discoverWorkflows } from './WORKFLOWS_FILENAME-
|
|
27
|
-
import { buildStorageColumns, emitDataModel, emitApi, emitServer, emitFunctions, emitShard, emitCollections, emitContainers, emitWorkflows, emitQueues, emitCrons, emitVectors, emitDrizzleSchema, emitSeed, emitWranglerCronTriggers } from './GENERATED_HEADER-
|
|
28
|
-
import { emitApp } from './emitApp-
|
|
29
|
-
import { buildOpenApiDocument, emitOpenApiModule } from './buildOpenApiDocument-
|
|
30
|
-
import { buildOpenRpcDocument, emitOpenRpcModule } from './OPENRPC_VERSION-
|
|
31
|
-
import { buildSchemaSnapshot, serializeSchemaSnapshot } from './SCHEMA_SNAPSHOT_VERSION-
|
|
27
|
+
import { discoverWorkflows } from './WORKFLOWS_FILENAME-CCC_42o3.mjs';
|
|
28
|
+
import { buildStorageColumns, emitDataModel, emitApi, emitServer, emitFunctions, emitShard, emitCollections, emitContainers, emitWorkflows, emitQueues, emitCrons, emitVectors, emitDrizzleSchema, emitSeed, emitWranglerCronTriggers } from './GENERATED_HEADER-f6nMvllu.mjs';
|
|
29
|
+
import { emitApp } from './emitApp-DKt3rPtr.mjs';
|
|
30
|
+
import { buildOpenApiDocument, emitOpenApiModule } from './buildOpenApiDocument-AgKWmlry.mjs';
|
|
31
|
+
import { buildOpenRpcDocument, emitOpenRpcModule } from './OPENRPC_VERSION-u5SqDDGk.mjs';
|
|
32
|
+
import { buildSchemaSnapshot, serializeSchemaSnapshot } from './SCHEMA_SNAPSHOT_VERSION-D0ARY6rL.mjs';
|
|
32
33
|
|
|
33
34
|
const HTTP_VERBS = /* @__PURE__ */ new Set(["delete", "get", "head", "options", "patch", "post", "put"]);
|
|
34
35
|
const TERMINAL_STEPS = /* @__PURE__ */ new Set(["handler", "stream"]);
|
|
@@ -901,7 +902,7 @@ const runCodegen = (options) => {
|
|
|
901
902
|
const lunoraDirectory = join(options.projectRoot, options.lunoraDirectory ?? "lunora");
|
|
902
903
|
const schemaPath = join(lunoraDirectory, "schema.ts");
|
|
903
904
|
if (!existsSync(schemaPath)) {
|
|
904
|
-
throw new
|
|
905
|
+
throw new LunoraError("INTERNAL", `schema.ts not found at ${schemaPath}`);
|
|
905
906
|
}
|
|
906
907
|
const project = options.project ?? createCodegenProject(lunoraDirectory);
|
|
907
908
|
const schema = discoverSchema(project, schemaPath, options.projectRoot);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
2
|
+
|
|
1
3
|
const SCHEMA_SNAPSHOT_VERSION = 1;
|
|
2
4
|
const encodeShardMode = (mode) => {
|
|
3
5
|
if (mode === "global" || mode === "root") {
|
|
@@ -47,8 +49,10 @@ const buildSchemaSnapshot = (schema, migrationIds) => {
|
|
|
47
49
|
};
|
|
48
50
|
const serializeSchemaSnapshot = (snapshot) => `${JSON.stringify(snapshot, void 0, 2)}
|
|
49
51
|
`;
|
|
50
|
-
class SchemaSnapshotParseError extends
|
|
51
|
-
|
|
52
|
+
class SchemaSnapshotParseError extends LunoraError {
|
|
53
|
+
constructor(message) {
|
|
54
|
+
super("SCHEMA_SNAPSHOT_PARSE", message, { name: "SchemaSnapshotParseError" });
|
|
55
|
+
}
|
|
52
56
|
}
|
|
53
57
|
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
54
58
|
const isValidTableSnapshot = (value) => isRecord(value) && isRecord(value.fields) && isRecord(value.indexes) && isRecord(value.relations) && typeof value.shardMode === "string";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { SyntaxKind, Node } from 'ts-morph';
|
|
4
|
-
import { diagnosticAt } from './CodegenDiagnosticError-
|
|
4
|
+
import { diagnosticAt } from './CodegenDiagnosticError-DyQ5FwkM.mjs';
|
|
5
5
|
|
|
6
6
|
const SHAPES_FILENAME = "shapes.ts";
|
|
7
7
|
const SHAPE_MODULE_SPECIFIERS = /* @__PURE__ */ new Set(["@lunora/server", "lunorash/server"]);
|
package/dist/packem_shared/{WORKFLOWS_FILENAME-CCisG0Vy.mjs → WORKFLOWS_FILENAME-CCC_42o3.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-DyQ5FwkM.mjs';
|
|
6
6
|
|
|
7
7
|
const WORKFLOWS_FILENAME = "workflows.ts";
|
|
8
8
|
const STEP_METHODS = /* @__PURE__ */ new Set(["do", "sleep", "sleepUntil", "waitForEvent"]);
|
package/dist/packem_shared/{buildOpenApiDocument-DLAW4ldJ.mjs → buildOpenApiDocument-AgKWmlry.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GENERATED_HEADER } from './GENERATED_HEADER-
|
|
1
|
+
import { GENERATED_HEADER } from './GENERATED_HEADER-f6nMvllu.mjs';
|
|
2
2
|
import { s as sanitizeNamespace } from './paths-BRd6JHuF.mjs';
|
|
3
3
|
import { LUNORA_ERROR_CODES, objectSchema, argsObjectSchema, validatorIrToJsonSchema } from './LUNORA_ERROR_CODES-CySpQPD3.mjs';
|
|
4
4
|
|
package/dist/packem_shared/{discoverAuthApiCalls-CoirYbg6.mjs → discoverAuthApiCalls-CGjWoLJ3.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { relative, sep } from 'node:path';
|
|
2
2
|
import { SyntaxKind, Node } from 'ts-morph';
|
|
3
3
|
import { T as TS_EXTENSION_RE, e as enclosingExportName } from './discover-ast-CT6BgBr4.mjs';
|
|
4
|
-
import { listLunoraSourceFiles } from './discoverFunctions-
|
|
4
|
+
import { listLunoraSourceFiles } from './discoverFunctions-CCVrvWhX.mjs';
|
|
5
5
|
|
|
6
6
|
const isAuthApiCall = (call) => {
|
|
7
7
|
const callee = call.getExpression();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isValidCronExpression, compileCronSchedule, CRON_SCHEDULE_KINDS } from '@lunora/scheduler';
|
|
2
2
|
import { SyntaxKind, Node } from 'ts-morph';
|
|
3
|
-
import { diagnosticAt } from './CodegenDiagnosticError-
|
|
4
|
-
import { listLunoraSourceFiles } from './discoverFunctions-
|
|
3
|
+
import { diagnosticAt } from './CodegenDiagnosticError-DyQ5FwkM.mjs';
|
|
4
|
+
import { listLunoraSourceFiles } from './discoverFunctions-CCVrvWhX.mjs';
|
|
5
5
|
import { s as sanitizeNamespace } from './paths-BRd6JHuF.mjs';
|
|
6
6
|
|
|
7
7
|
const CRON_METHODS = /* @__PURE__ */ new Set([...CRON_SCHEDULE_KINDS, "cron"]);
|
package/dist/packem_shared/{discoverFunctions-BWMczzBx.mjs → discoverFunctions-CCVrvWhX.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readdirSync, lstatSync } from 'node:fs';
|
|
2
2
|
import { join, extname, relative, sep } from 'node:path';
|
|
3
3
|
import { Node, SyntaxKind } from 'ts-morph';
|
|
4
|
-
import { a as parseObjectShape } from './parse-validator-
|
|
4
|
+
import { a as parseObjectShape } from './parse-validator-D6zI2i85.mjs';
|
|
5
5
|
import { s as sanitizeNamespace } from './paths-BRd6JHuF.mjs';
|
|
6
6
|
|
|
7
7
|
const FUNCTION_KINDS = /* @__PURE__ */ new Set(["action", "mutation", "query", "stream"]);
|
package/dist/packem_shared/{discoverHttpRoutes-CfP6cMzt.mjs → discoverHttpRoutes-3tvf_95b.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { relative, sep } from 'node:path';
|
|
2
2
|
import { Node } from 'ts-morph';
|
|
3
|
-
import { listLunoraSourceFiles } from './discoverFunctions-
|
|
4
|
-
import { p as parseValidator, a as parseObjectShape } from './parse-validator-
|
|
3
|
+
import { listLunoraSourceFiles } from './discoverFunctions-CCVrvWhX.mjs';
|
|
4
|
+
import { p as parseValidator, a as parseObjectShape } from './parse-validator-D6zI2i85.mjs';
|
|
5
5
|
|
|
6
6
|
const TS_EXTENSION_RE = /\.ts$/u;
|
|
7
7
|
const HTTP_VERBS = /* @__PURE__ */ new Set(["delete", "get", "head", "options", "patch", "post", "put"]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SyntaxKind, Node } from 'ts-morph';
|
|
2
2
|
import { e as enclosingExportName } from './discover-ast-CT6BgBr4.mjs';
|
|
3
|
-
import { listLunoraSourceFiles, lunoraRelativePath } from './discoverFunctions-
|
|
3
|
+
import { listLunoraSourceFiles, lunoraRelativePath } from './discoverFunctions-CCVrvWhX.mjs';
|
|
4
4
|
|
|
5
5
|
const isDatabaseInsertCall = (call) => {
|
|
6
6
|
const callee = call.getExpression();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Node, SyntaxKind } from 'ts-morph';
|
|
2
|
-
import { listLunoraSourceFiles, lunoraRelativePath, classifyProcedureCall } from './discoverFunctions-
|
|
2
|
+
import { listLunoraSourceFiles, lunoraRelativePath, classifyProcedureCall } from './discoverFunctions-CCVrvWhX.mjs';
|
|
3
3
|
|
|
4
4
|
const isMaskCall = (node) => {
|
|
5
5
|
if (!Node.isCallExpression(node)) {
|
package/dist/packem_shared/{discoverMigrations-Bi5nJ0mJ.mjs → discoverMigrations-DfBWvCoA.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { relative, sep } from 'node:path';
|
|
2
2
|
import { SyntaxKind, Node } from 'ts-morph';
|
|
3
|
-
import { diagnosticAt } from './CodegenDiagnosticError-
|
|
4
|
-
import { listLunoraSourceFiles } from './discoverFunctions-
|
|
3
|
+
import { diagnosticAt } from './CodegenDiagnosticError-DyQ5FwkM.mjs';
|
|
4
|
+
import { listLunoraSourceFiles } from './discoverFunctions-CCVrvWhX.mjs';
|
|
5
5
|
|
|
6
6
|
const TS_EXTENSION_RE = /\.ts$/u;
|
|
7
7
|
const isDefineMigration = (identifier) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Node, SyntaxKind } from 'ts-morph';
|
|
2
|
-
import { listLunoraSourceFiles, lunoraRelativePath, classifyProcedureCall } from './discoverFunctions-
|
|
2
|
+
import { listLunoraSourceFiles, lunoraRelativePath, classifyProcedureCall } from './discoverFunctions-CCVrvWhX.mjs';
|
|
3
3
|
|
|
4
4
|
const PROPERTY_CALLS = {
|
|
5
5
|
"crypto.getRandomValues": "crypto.getRandomValues",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SyntaxKind, Node } from 'ts-morph';
|
|
2
|
-
import { listLunoraSourceFiles, lunoraRelativePath } from './discoverFunctions-
|
|
2
|
+
import { listLunoraSourceFiles, lunoraRelativePath } from './discoverFunctions-CCVrvWhX.mjs';
|
|
3
3
|
|
|
4
4
|
const INDEX_METHODS = /* @__PURE__ */ new Set(["withIndex", "withSearchIndex"]);
|
|
5
5
|
const isDatabaseQueryCall = (call) => {
|
package/dist/packem_shared/{discoverR2sqlCalls-BVNMd428.mjs → discoverR2sqlCalls-CkBDIqPt.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Node, SyntaxKind } from 'ts-morph';
|
|
2
|
-
import { listLunoraSourceFiles, lunoraRelativePath, classifyProcedureCall } from './discoverFunctions-
|
|
2
|
+
import { listLunoraSourceFiles, lunoraRelativePath, classifyProcedureCall } from './discoverFunctions-CCVrvWhX.mjs';
|
|
3
3
|
|
|
4
4
|
const handlerOf = (call, receiver) => {
|
|
5
5
|
if (receiver) {
|
package/dist/packem_shared/{discoverRlsMetadata-BS9GOGC5.mjs → discoverRlsMetadata-BXrKzID4.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Node, SyntaxKind } from 'ts-morph';
|
|
2
|
-
import { listLunoraSourceFiles, lunoraRelativePath, classifyProcedureCall } from './discoverFunctions-
|
|
2
|
+
import { listLunoraSourceFiles, lunoraRelativePath, classifyProcedureCall } from './discoverFunctions-CCVrvWhX.mjs';
|
|
3
3
|
|
|
4
4
|
const isRlsCall = (node) => {
|
|
5
5
|
if (!Node.isCallExpression(node)) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
1
2
|
import { Node, SyntaxKind } from 'ts-morph';
|
|
2
|
-
import { diagnosticAt } from './CodegenDiagnosticError-
|
|
3
|
-
import { a as parseObjectShape } from './parse-validator-
|
|
3
|
+
import { diagnosticAt } from './CodegenDiagnosticError-DyQ5FwkM.mjs';
|
|
4
|
+
import { a as parseObjectShape } from './parse-validator-D6zI2i85.mjs';
|
|
4
5
|
import { createRequire } from 'node:module';
|
|
5
6
|
import { join } from 'node:path';
|
|
6
7
|
|
|
@@ -847,7 +848,7 @@ const discoverSchema = (project, schemaPath, projectRoot) => {
|
|
|
847
848
|
return Node.isIdentifier(callee) && callee.getText() === "defineSchema";
|
|
848
849
|
});
|
|
849
850
|
if (!defineSchemaCall) {
|
|
850
|
-
throw new
|
|
851
|
+
throw new LunoraError("INTERNAL", `defineSchema() not found in ${schemaPath}`);
|
|
851
852
|
}
|
|
852
853
|
const argument = defineSchemaCall.getArguments()[0];
|
|
853
854
|
if (!argument || !Node.isObjectLiteralExpression(argument)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Node } from 'ts-morph';
|
|
2
|
-
import { listLunoraSourceFiles, lunoraRelativePath, classifyProcedureCall } from './discoverFunctions-
|
|
2
|
+
import { listLunoraSourceFiles, lunoraRelativePath, classifyProcedureCall } from './discoverFunctions-CCVrvWhX.mjs';
|
|
3
3
|
|
|
4
4
|
const STORAGE_OPERATIONS = /* @__PURE__ */ new Set(["delete", "list", "read", "write"]);
|
|
5
5
|
const isStorageRulesCall = (node) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
1
2
|
import { Node } from 'ts-morph';
|
|
2
3
|
|
|
3
4
|
const FIELD_NAME_RE = /^[A-Za-z_$][\w$]*$/u;
|
|
@@ -53,7 +54,7 @@ const parseObjectShape = (object) => {
|
|
|
53
54
|
}
|
|
54
55
|
const fieldName = property.getName();
|
|
55
56
|
if (!FIELD_NAME_RE.test(fieldName)) {
|
|
56
|
-
throw new
|
|
57
|
+
throw new LunoraError("INTERNAL", `@lunora/codegen: field name is not a valid JS identifier: ${JSON.stringify(fieldName)}`);
|
|
57
58
|
}
|
|
58
59
|
out[fieldName] = parseValidator(initializer);
|
|
59
60
|
}
|
|
@@ -106,7 +107,7 @@ const parseBuilderMember = (member, args) => {
|
|
|
106
107
|
};
|
|
107
108
|
}
|
|
108
109
|
default: {
|
|
109
|
-
throw new
|
|
110
|
+
throw new LunoraError("INTERNAL", `Unsupported validator kind: ${member}`);
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/codegen",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.29",
|
|
4
4
|
"description": "Code generator for Lunora: emits _generated/{api,server,dataModel}.ts from your schema",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -46,12 +46,13 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@lunora/advisor": "1.0.0-alpha.
|
|
50
|
-
"@lunora/container": "1.0.0-alpha.
|
|
51
|
-
"@lunora/
|
|
52
|
-
"@lunora/
|
|
53
|
-
"@lunora/
|
|
54
|
-
"@lunora/
|
|
49
|
+
"@lunora/advisor": "1.0.0-alpha.16",
|
|
50
|
+
"@lunora/container": "1.0.0-alpha.6",
|
|
51
|
+
"@lunora/errors": "1.0.0-alpha.1",
|
|
52
|
+
"@lunora/queue": "1.0.0-alpha.3",
|
|
53
|
+
"@lunora/scheduler": "1.0.0-alpha.5",
|
|
54
|
+
"@lunora/values": "1.0.0-alpha.4",
|
|
55
|
+
"@lunora/workflow": "1.0.0-alpha.6",
|
|
55
56
|
"ts-morph": "^28.0.0"
|
|
56
57
|
},
|
|
57
58
|
"engines": {
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
const LUNORA_SOLUTION_RULES = [
|
|
2
|
-
{
|
|
3
|
-
body: [
|
|
4
|
-
"Lunora codegen couldn't find a schema to generate from.",
|
|
5
|
-
"",
|
|
6
|
-
"Create `lunora/schema.ts` exporting a `defineSchema(...)` call:",
|
|
7
|
-
"",
|
|
8
|
-
"```ts",
|
|
9
|
-
'import { defineSchema, defineTable, v } from "@lunora/server";',
|
|
10
|
-
"",
|
|
11
|
-
"export default defineSchema({",
|
|
12
|
-
" messages: defineTable({ body: v.string() }),",
|
|
13
|
-
"});",
|
|
14
|
-
"```",
|
|
15
|
-
"",
|
|
16
|
-
"Or run `lunora init` to scaffold Lunora (a sample `lunora/schema.ts` included) into your app."
|
|
17
|
-
].join("\n"),
|
|
18
|
-
header: "No Lunora schema found",
|
|
19
|
-
id: "lunora-schema-missing",
|
|
20
|
-
test: (message) => message.includes("defineSchema() not found") || message.includes("schema.ts not found at")
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
body: [
|
|
24
|
-
"`defineSchema(...)` must be called with an **inline object literal** mapping table names to `defineTable(...)`:",
|
|
25
|
-
"",
|
|
26
|
-
"```ts",
|
|
27
|
-
"export default defineSchema({",
|
|
28
|
-
" todos: defineTable({ title: v.string(), done: v.boolean() }),",
|
|
29
|
-
"});",
|
|
30
|
-
"```",
|
|
31
|
-
"",
|
|
32
|
-
"Codegen reads the schema statically, so it can't follow a variable or a spread — pass the object literal directly."
|
|
33
|
-
].join("\n"),
|
|
34
|
-
header: "`defineSchema()` needs an inline object literal",
|
|
35
|
-
id: "lunora-schema-not-object-literal",
|
|
36
|
-
test: (message) => message.includes("defineSchema() expects an object literal")
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
body: [
|
|
40
|
-
"This table name collides with a built-in `ctx.db` member, so the generated client can't expose it.",
|
|
41
|
-
"",
|
|
42
|
-
"Rename the table to anything that isn't a reserved name (the error lists them) — e.g. `userAccounts` instead of `insert`."
|
|
43
|
-
].join("\n"),
|
|
44
|
-
header: "Table name is reserved",
|
|
45
|
-
id: "lunora-table-reserved",
|
|
46
|
-
test: (message) => message.includes("is reserved") && message.includes("ctx.db")
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
body: [
|
|
50
|
-
"Two tables resolve to the same name — usually a base table and a schema **extension** both defining it.",
|
|
51
|
-
"",
|
|
52
|
-
"Rename one of them, or drop the duplicate from the extension. Each table name must be unique across `defineSchema(...)` and every `.extend(...)`."
|
|
53
|
-
].join("\n"),
|
|
54
|
-
header: "Duplicate table name",
|
|
55
|
-
id: "lunora-table-duplicate",
|
|
56
|
-
// Anchor on `.extend(` — the only Lunora throw for this is
|
|
57
|
-
// `defineSchema(...).extend(...): table "x" already exists …`. Matching a
|
|
58
|
-
// bare "already exists"/"extension" pair would false-positive on
|
|
59
|
-
// unrelated forwarded errors (e.g. a "file already exists" + "extension").
|
|
60
|
-
test: (message) => message.includes("already exists") && message.includes(".extend(")
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
body: [
|
|
64
|
-
'`.jurisdiction(...)` accepts only a **string literal** of `"eu"`, `"us"`, or `"fedramp"`:',
|
|
65
|
-
"",
|
|
66
|
-
"```ts",
|
|
67
|
-
'defineSchema({ /* … */ }).jurisdiction("eu");',
|
|
68
|
-
"```"
|
|
69
|
-
].join("\n"),
|
|
70
|
-
header: "Invalid `.jurisdiction(...)` value",
|
|
71
|
-
id: "lunora-jurisdiction",
|
|
72
|
-
test: (message) => message.includes("unknown jurisdiction") || message.includes("jurisdiction") && message.includes('"eu", "us", or "fedramp"')
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
body: [
|
|
76
|
-
"The `unique` flag on an index must be a **literal** `true` or `false`, not a computed value — codegen needs to read it statically:",
|
|
77
|
-
"",
|
|
78
|
-
"```ts",
|
|
79
|
-
'defineTable({ email: v.string() }).index("by_email", ["email"], { unique: true });',
|
|
80
|
-
"```"
|
|
81
|
-
].join("\n"),
|
|
82
|
-
header: "`unique` must be a literal",
|
|
83
|
-
id: "lunora-unique-literal",
|
|
84
|
-
test: (message) => message.includes("must be a literal") && message.includes("unique")
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
body: [
|
|
88
|
-
"A declared container/workflow class isn't re-exported by your worker entry, so `wrangler deploy` would reject it.",
|
|
89
|
-
"",
|
|
90
|
-
"Add the generated re-export shown in the error to your worker entry (e.g. `src/index.ts`):",
|
|
91
|
-
"",
|
|
92
|
-
"```ts",
|
|
93
|
-
'export * from "./lunora/_generated/containers";',
|
|
94
|
-
"```"
|
|
95
|
-
].join("\n"),
|
|
96
|
-
header: "Binding not exported by your worker entry",
|
|
97
|
-
id: "lunora-worker-entry-export-gap",
|
|
98
|
-
test: (message) => message.includes("not exported by your worker entry")
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
body: [
|
|
102
|
-
"A row with the same value already exists in a `unique` index.",
|
|
103
|
-
"",
|
|
104
|
-
"- If you meant to upsert, use `ctx.db.<table>().upsert(...)` (or `.patch(...)` an existing row) instead of `.insert(...)`.",
|
|
105
|
-
`- Otherwise pick a value that isn't already taken, and consider surfacing a friendly "already exists" message to the user.`
|
|
106
|
-
].join("\n"),
|
|
107
|
-
header: "Unique constraint violation",
|
|
108
|
-
id: "lunora-runtime-unique",
|
|
109
|
-
test: (message) => message.includes("unique constraint violation on")
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
body: [
|
|
113
|
-
"Another write changed this row while your mutation was running (optimistic concurrency conflict).",
|
|
114
|
-
"",
|
|
115
|
-
"Re-read the row and retry the mutation with the fresh value. Lunora serializes a DO's mutations, so a persistent conflict usually means the handler conflicts **with itself** (e.g. a trigger or cascade touching the same row) — split that work rather than adding a retry loop."
|
|
116
|
-
].join("\n"),
|
|
117
|
-
header: "Optimistic concurrency conflict",
|
|
118
|
-
id: "lunora-runtime-occ",
|
|
119
|
-
test: (message) => message.includes("optimistic concurrency conflict")
|
|
120
|
-
}
|
|
121
|
-
];
|
|
122
|
-
const findLunoraSolution = (message) => {
|
|
123
|
-
for (const rule of LUNORA_SOLUTION_RULES) {
|
|
124
|
-
if (rule.test(message)) {
|
|
125
|
-
return { body: rule.body, header: rule.header, id: rule.id };
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return void 0;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
export { LUNORA_SOLUTION_RULES, findLunoraSolution };
|