@lunora/codegen 1.0.0-alpha.50 → 1.0.0-alpha.52

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 (28) hide show
  1. package/dist/index.d.mts +66 -4
  2. package/dist/index.d.ts +66 -4
  3. package/dist/index.mjs +22 -21
  4. package/dist/packem_shared/{FLAGS_FILENAME-Dg4mKUuz.mjs → FLAGS_FILENAME-D5igzqwR.mjs} +1 -1
  5. package/dist/packem_shared/{GENERATED_HEADER-C5paWNYO.mjs → GENERATED_HEADER-D5mkGdTx.mjs} +1 -1
  6. package/dist/packem_shared/NOTIFY_FILENAME-CK2IrsrP.mjs +152 -0
  7. package/dist/packem_shared/{OPENRPC_VERSION-7A2weq2u.mjs → OPENRPC_VERSION-Dnru3-Tg.mjs} +1 -1
  8. package/dist/packem_shared/{SCHEMA_SNAPSHOT_FILENAME-G5dkcxPR.mjs → SCHEMA_SNAPSHOT_FILENAME-7_LhHIAy.mjs} +118 -23
  9. package/dist/packem_shared/{buildOpenApiDocument-B7mEdzA2.mjs → buildOpenApiDocument-BH50tL6w.mjs} +80 -1
  10. package/dist/packem_shared/{discoverAuthApiCalls-Dx3K42rk.mjs → discoverAuthApiCalls-Dhwgf4J4.mjs} +1 -1
  11. package/dist/packem_shared/{discoverCrons-DvqkEWdx.mjs → discoverCrons-UbQLLmMS.mjs} +1 -1
  12. package/dist/packem_shared/{discoverFunctions-BJ-qR7Rg.mjs → discoverFunctions-COG_Xkyz.mjs} +27 -1
  13. package/dist/packem_shared/{discoverHttpRoutes-daCzuTe8.mjs → discoverHttpRoutes-CVXWZkzo.mjs} +2 -2
  14. package/dist/packem_shared/{discoverInserts-DI4q5NxE.mjs → discoverInserts-DdWnXmLS.mjs} +1 -1
  15. package/dist/packem_shared/{discoverMaskProcedures-BcTOEKNU.mjs → discoverMaskProcedures-BG58_fw3.mjs} +1 -1
  16. package/dist/packem_shared/{discoverMigrations-VNUFvCwr.mjs → discoverMigrations-Bw1U01zr.mjs} +1 -1
  17. package/dist/packem_shared/{discoverNondeterministicCalls-S0N2xLCq.mjs → discoverNondeterministicCalls-BbXEFZUT.mjs} +1 -1
  18. package/dist/packem_shared/{discoverQueries-CJnnnLpd.mjs → discoverQueries-CDmxu2ET.mjs} +1 -1
  19. package/dist/packem_shared/{discoverR2sqlCalls-pnpicWfz.mjs → discoverR2sqlCalls-Bn7QVv7J.mjs} +1 -1
  20. package/dist/packem_shared/{discoverRlsMetadata-DppniPUH.mjs → discoverRlsMetadata-D9uN35no.mjs} +1 -1
  21. package/dist/packem_shared/{discoverSandboxUsage-BUM2r90k.mjs → discoverSandboxUsage-B5jDU6Bt.mjs} +1 -1
  22. package/dist/packem_shared/{discoverSchema-BaSAvooG.mjs → discoverSchema-BJp5_T4o.mjs} +32 -1
  23. package/dist/packem_shared/{discoverStorageRulesMetadata-CnHl2rXD.mjs → discoverStorageRulesMetadata-BqMhuEjo.mjs} +1 -1
  24. package/dist/packem_shared/{emit-ClTbCLy4.mjs → emit-B4LUyyg7.mjs} +98 -18
  25. package/dist/packem_shared/{emitApp-CzzrjVqH.mjs → emitApp-BJ6weBMT.mjs} +11 -2
  26. package/dist/packem_shared/{formatAdvisories-BmF7Mplc.mjs → formatAdvisories-Cans5TWS.mjs} +17 -1
  27. package/dist/packem_shared/{parse-validator-BSJo1HGP.mjs → parse-validator-BDGV8iue.mjs} +1 -1
  28. package/package.json +7 -7
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Finding } from '@lunora/advisor';
1
+ import { AdvisorExportSink, AdvisorGeoIndexUsage, AdvisorNotifyCall, AdvisorNotifyConfig, Finding } from '@lunora/advisor';
2
2
  export type { Finding } from '@lunora/advisor';
3
3
  import { LunoraError } from '@lunora/errors';
4
4
  export { MESSAGE_SOLUTIONS as LUNORA_SOLUTION_RULES, type Solution as LunoraSolution, type SolutionRule as LunoraSolutionRule, findSolutionByMessage as findLunoraSolution } from '@lunora/errors';
@@ -66,6 +66,21 @@ interface SearchIndexIR {
66
66
  filterFields?: ReadonlyArray<string>;
67
67
  name: string;
68
68
  }
69
+ /** A `.geoIndex(name, { field, precision? })` declaration — a geohash companion over a `v.geoPoint()` column. */
70
+ interface GeoIndexIR {
71
+ /** The `v.geoPoint()` column feeding the geohash. */
72
+ field: string;
73
+ name: string;
74
+ /** Geohash precision (characters) maintained on the companion; omitted ⇒ the runtime default. */
75
+ precision?: number;
76
+ }
77
+ /** A `.ttl(field, { after? })` declaration — declarative table-level auto-expiry. */
78
+ interface TtlIR {
79
+ /** Millisecond offset added to `field` to derive the expiry (`field + after`); omitted ⇒ `field` is the absolute expiry. */
80
+ after?: number;
81
+ /** The epoch-millisecond expiry column. */
82
+ field: string;
83
+ }
69
84
  interface VectorIndexIR {
70
85
  dimensions?: number;
71
86
  /** Shape A: the single source column. Shape B: undefined (derived via a `select` fn). */
@@ -163,6 +178,8 @@ interface TableIR {
163
178
  * `"hyperdrive"` (a Postgres/MySQL database via Cloudflare Hyperdrive). Only
164
179
  * meaningful when `shardMode === "global"`; absent for sharded/root tables.
165
180
  */
181
+ /** Geospatial indexes declared inline via `.geoIndex(name, …)`. Optional so hand-built IR may omit it (discovery always sets it). */
182
+ geoIndexes?: ReadonlyArray<GeoIndexIR>;
166
183
  globalBackend?: "d1" | "hyperdrive";
167
184
  indexes: ReadonlyArray<IndexIR>;
168
185
  /**
@@ -187,6 +204,8 @@ interface TableIR {
187
204
  softDelete?: {
188
205
  field: string;
189
206
  };
207
+ /** Set when the chain carried `.ttl(field, { after? })` — the declarative auto-expiry policy read by the DO alarm sweep. */
208
+ ttl?: TtlIR;
190
209
  /** Vector indexes declared inline via `.vectorize()` (DSL Shape A). */
191
210
  vectorIndexes: ReadonlyArray<VectorIndexIR>;
192
211
  }
@@ -214,6 +233,16 @@ interface SchemaIR {
214
233
  interface FunctionIR {
215
234
  args: Record<string, ValidatorIR>;
216
235
  exportName: string;
236
+ /**
237
+ * Set by the `.expose({ rest: true })` builder modifier (plan 167). When
238
+ * `rest` is `true` the function is published on the public REST surface, so the
239
+ * OpenAPI emitter describes it as a real `/_lunora/rest/&lt;namespace>/&lt;fn>` path
240
+ * (the single source of truth the runtime router also derives from). Absent →
241
+ * RPC-only (the default; not on the REST surface).
242
+ */
243
+ expose?: {
244
+ rest?: boolean;
245
+ };
217
246
  /** Path relative to `&lt;projectRoot>/lunora/` without extension, e.g. "messages". */
218
247
  filePath: string;
219
248
  kind: "action" | "mutation" | "query" | "stream";
@@ -925,6 +954,8 @@ interface ProcedureMiddlewareIR {
925
954
  unboundedAiGeneration: boolean;
926
955
  /** `true` when the chain carries `.use(verifyTurnstile(...))` or a `protectPublic({ captcha })` bundle. */
927
956
  usesCaptcha: boolean;
957
+ /** `true` when the chain carries `.use(emailGateMiddleware(...))` (`@lunora/auth`). Feeds the `signup_mutation_without_disposable_gating` lint. */
958
+ usesEmailGate: boolean;
928
959
  /** `true` when the handler calls `ctx.db.insertManyUnsafe(...)`, bypassing validators and triggers. Feeds the `insert_many_unsafe_user_data` lint. */
929
960
  usesInsertManyUnsafe: boolean;
930
961
  /** `true` when the chain carries `.use(mask(...))`. */
@@ -1689,8 +1720,10 @@ interface LintSchemaOptions {
1689
1720
  containerKeyAccesses?: ReadonlyArray<ContainerKeyAccessIR>;
1690
1721
  containerOverrides?: ReadonlyArray<ContainerOverrideIR>;
1691
1722
  containers?: ReadonlyArray<ContainerIR>;
1723
+ exportSinks?: ReadonlyArray<AdvisorExportSink>;
1692
1724
  failOpenGuards?: ReadonlyArray<FailOpenGuardIR>;
1693
1725
  flagSecurityDefaults?: ReadonlyArray<FlagSecurityDefaultIR>;
1726
+ geoIndexUsages?: ReadonlyArray<AdvisorGeoIndexUsage>;
1694
1727
  httpActionGuards?: ReadonlyArray<HttpActionGuardIR>;
1695
1728
  httpHeaderWrites?: ReadonlyArray<HttpHeaderWriteIR>;
1696
1729
  identityClaimReads?: ReadonlyArray<IdentityClaimReadIR>;
@@ -1703,6 +1736,8 @@ interface LintSchemaOptions {
1703
1736
  mutatorWrites?: ReadonlyArray<MutatorWriteIR>;
1704
1737
  nondeterministicCalls?: ReadonlyArray<NondeterministicCallIR>;
1705
1738
  normalizeIdAuthorizations?: ReadonlyArray<NormalizeIdAuthorizationIR>;
1739
+ notifyCalls?: ReadonlyArray<AdvisorNotifyCall>;
1740
+ notifyConfig?: AdvisorNotifyConfig;
1706
1741
  ownerFieldWrites?: ReadonlyArray<OwnerFieldWriteIR>;
1707
1742
  paymentWebhooks?: ReadonlyArray<PaymentWebhookIR>;
1708
1743
  privilegedDispatches?: ReadonlyArray<PrivilegedDispatchIR>;
@@ -1872,6 +1907,27 @@ declare const discoverMutators: (project: Project, lunoraDirectory: string) => M
1872
1907
  * produced per call site.
1873
1908
  */
1874
1909
  declare const discoverNondeterministicCalls: (project: Project, lunoraDirectory: string) => NondeterministicCallIR[];
1910
+ /** The only file a `@lunora/notify` provider may be declared in — mirrors `lunora/flags.ts`. */
1911
+ declare const NOTIFY_FILENAME = "notify.ts";
1912
+ /**
1913
+ * Discover `ctx.notify` / `ctx.push` sends lexically inside the handler body of
1914
+ * every exported `query(...)` / `mutation(...)` registration under the lunora
1915
+ * source directory — the `notify_send_outside_action` lint input. `action(...)`
1916
+ * (and `stream(...)`) registrations are intentionally skipped: a notification
1917
+ * send is external I/O that belongs in actions. One {@link AdvisorNotifyCall} is
1918
+ * produced per send site.
1919
+ */
1920
+ declare const discoverNotifyCalls: (project: Project, lunoraDirectory: string) => AdvisorNotifyCall[];
1921
+ /**
1922
+ * Discover which push channels the project's `lunora/notify.ts` default export
1923
+ * (`defineNotify({...})`) wires plus whether any handler sends a push — the
1924
+ * `notify_missing_push_config` lint input. Returns `undefined` when the file is
1925
+ * absent (the app declares no notify config). The read is metadata-only and
1926
+ * lenient (like `discoverFlags`): a `webPush`/`fcm` property's mere presence
1927
+ * counts as the channel being wired; a non-literal config degrades to "unwired"
1928
+ * rather than throwing.
1929
+ */
1930
+ declare const discoverNotifyConfig: (project: Project, lunoraDirectory: string) => AdvisorNotifyConfig | undefined;
1875
1931
  /**
1876
1932
  * Discover `ctx.db.query("table")…` reads under the lunora source directory and
1877
1933
  * reduce each to a {@link QueryReadIR}. Only reads that call `.filter()` are
@@ -2027,6 +2083,8 @@ interface EmitServerOptions {
2027
2083
  hasImages?: boolean;
2028
2084
  /** A `lunora/` source uses `@lunora/bindings/kv` / `ctx.kv` — wires `ctx.kv` onto every ctx. */
2029
2085
  hasKv?: boolean;
2086
+ /** The project declares `lunora/notify.ts` — wires `ctx.notify` + its `ctx.push` alias (`@lunora/notify`) onto every ctx. */
2087
+ hasNotify?: boolean;
2030
2088
  hasPayments?: boolean;
2031
2089
  /** A `lunora/` source uses `@lunora/bindings/pipelines` / `ctx.pipelines` — wires `ctx.pipelines` onto ActionCtx only. */
2032
2090
  hasPipelines?: boolean;
@@ -2051,7 +2109,7 @@ interface EmitServerOptions {
2051
2109
  useUmbrella?: boolean;
2052
2110
  workflows?: ReadonlyArray<WorkflowIR>;
2053
2111
  }
2054
- declare const emitServer: ({ agents, containers, env, hasAccessFacade, hasAi, hasAnalytics, hasBrowser, hasFlags, hasHyperdrive, hasImages, hasKv, hasPayments, hasPipelines, hasR2sql, hasX402, identity, queues, schema, storageRuleBuckets, useUmbrella, workflows }?: EmitServerOptions) => string;
2112
+ declare const emitServer: ({ agents, containers, env, hasAccessFacade, hasAi, hasAnalytics, hasBrowser, hasFlags, hasHyperdrive, hasImages, hasKv, hasNotify, hasPayments, hasPipelines, hasR2sql, hasX402, identity, queues, schema, storageRuleBuckets, useUmbrella, workflows }?: EmitServerOptions) => string;
2055
2113
  interface EmitFunctionsOptions {
2056
2114
  agents?: ReadonlyArray<AgentIR>;
2057
2115
  functions: ReadonlyArray<FunctionIR>;
@@ -2118,6 +2176,8 @@ interface EmitShardOptions {
2118
2176
  hasImages?: boolean;
2119
2177
  /** A `lunora/` source reads `ctx.kv` — wires `ctx.kv` onto every ctx. */
2120
2178
  hasKv?: boolean;
2179
+ /** The project declares `lunora/notify.ts` — wires `ctx.notify` + its `ctx.push` alias (`@lunora/notify`) onto every ctx. */
2180
+ hasNotify?: boolean;
2121
2181
  hasPayments?: boolean;
2122
2182
  /** A `lunora/` source reads `ctx.pipelines` — wires `ctx.pipelines` onto the ActionCtx only. */
2123
2183
  hasPipelines?: boolean;
@@ -2140,7 +2200,7 @@ interface EmitShardOptions {
2140
2200
  useUmbrella?: boolean;
2141
2201
  workflows?: ReadonlyArray<WorkflowIR>;
2142
2202
  }
2143
- declare const emitShard: ({ advisories, agents, containers, env, flagKeys, hasAccessFacade, hasAi, hasAnalytics, hasBrowser, hasFlags, hasHyperdrive, hasImages, hasKv, hasPayments, hasPipelines, hasR2sql, hasX402, maskMetadata, mutators, queues, rlsMetadata, schema, shapes, storageRules, studioFeatures, useUmbrella, workflows }: EmitShardOptions) => string;
2203
+ declare const emitShard: ({ advisories, agents, containers, env, flagKeys, hasAccessFacade, hasAi, hasAnalytics, hasBrowser, hasFlags, hasHyperdrive, hasImages, hasKv, hasNotify, hasPayments, hasPipelines, hasR2sql, hasX402, maskMetadata, mutators, queues, rlsMetadata, schema, shapes, storageRules, studioFeatures, useUmbrella, workflows }: EmitShardOptions) => string;
2144
2204
  /**
2145
2205
  * Emit drizzle `sqliteTable` definitions for the project schema, split into
2146
2206
  * `global` (D1-backed) and `shard` (DO-SQLite-backed) buckets. Tables marked
@@ -2232,6 +2292,8 @@ interface EmitAppOptions {
2232
2292
  hasImages: boolean;
2233
2293
  /** App uses `@lunora/bindings/kv` / `ctx.kv` → emit `.kv()`. */
2234
2294
  hasKv: boolean;
2295
+ /** App declares `lunora/notify.ts` (`@lunora/notify`) → wire `options.notifySubscriptionStore` so the studio Notifications page can read registered devices. */
2296
+ hasNotify: boolean;
2235
2297
  /** App uses `@lunora/payment` / `ctx.payments` → emit `.payment()`. */
2236
2298
  hasPayments: boolean;
2237
2299
  /** App declares push queues (`defineQueue`) → wire `LUNORA_QUEUE_REGISTRY` into the worker's `queue()` consumer entry. */
@@ -2727,4 +2789,4 @@ declare const secretKindOf: (value: string) => string | undefined;
2727
2789
  /** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
2728
2790
  declare const redact: (value: string) => string;
2729
2791
  declare const VERSION = "0.0.0";
2730
- export { AGENTS_FILENAME, type AgentIR, 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, type LintSchemaOptions, 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 SandboxUsage, 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, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, evaluateSchemaDrift, formatAdvisories, lintSchema, parseSchemaSnapshot, redact, refreshCodegenProject, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, validatorIrToJsonSchema };
2792
+ export { AGENTS_FILENAME, type AgentIR, 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, type LintSchemaOptions, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, 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 SandboxUsage, 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, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, evaluateSchemaDrift, formatAdvisories, lintSchema, parseSchemaSnapshot, redact, refreshCodegenProject, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, validatorIrToJsonSchema };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Finding } from '@lunora/advisor';
1
+ import { AdvisorExportSink, AdvisorGeoIndexUsage, AdvisorNotifyCall, AdvisorNotifyConfig, Finding } from '@lunora/advisor';
2
2
  export type { Finding } from '@lunora/advisor';
3
3
  import { LunoraError } from '@lunora/errors';
4
4
  export { MESSAGE_SOLUTIONS as LUNORA_SOLUTION_RULES, type Solution as LunoraSolution, type SolutionRule as LunoraSolutionRule, findSolutionByMessage as findLunoraSolution } from '@lunora/errors';
@@ -66,6 +66,21 @@ interface SearchIndexIR {
66
66
  filterFields?: ReadonlyArray<string>;
67
67
  name: string;
68
68
  }
69
+ /** A `.geoIndex(name, { field, precision? })` declaration — a geohash companion over a `v.geoPoint()` column. */
70
+ interface GeoIndexIR {
71
+ /** The `v.geoPoint()` column feeding the geohash. */
72
+ field: string;
73
+ name: string;
74
+ /** Geohash precision (characters) maintained on the companion; omitted ⇒ the runtime default. */
75
+ precision?: number;
76
+ }
77
+ /** A `.ttl(field, { after? })` declaration — declarative table-level auto-expiry. */
78
+ interface TtlIR {
79
+ /** Millisecond offset added to `field` to derive the expiry (`field + after`); omitted ⇒ `field` is the absolute expiry. */
80
+ after?: number;
81
+ /** The epoch-millisecond expiry column. */
82
+ field: string;
83
+ }
69
84
  interface VectorIndexIR {
70
85
  dimensions?: number;
71
86
  /** Shape A: the single source column. Shape B: undefined (derived via a `select` fn). */
@@ -163,6 +178,8 @@ interface TableIR {
163
178
  * `"hyperdrive"` (a Postgres/MySQL database via Cloudflare Hyperdrive). Only
164
179
  * meaningful when `shardMode === "global"`; absent for sharded/root tables.
165
180
  */
181
+ /** Geospatial indexes declared inline via `.geoIndex(name, …)`. Optional so hand-built IR may omit it (discovery always sets it). */
182
+ geoIndexes?: ReadonlyArray<GeoIndexIR>;
166
183
  globalBackend?: "d1" | "hyperdrive";
167
184
  indexes: ReadonlyArray<IndexIR>;
168
185
  /**
@@ -187,6 +204,8 @@ interface TableIR {
187
204
  softDelete?: {
188
205
  field: string;
189
206
  };
207
+ /** Set when the chain carried `.ttl(field, { after? })` — the declarative auto-expiry policy read by the DO alarm sweep. */
208
+ ttl?: TtlIR;
190
209
  /** Vector indexes declared inline via `.vectorize()` (DSL Shape A). */
191
210
  vectorIndexes: ReadonlyArray<VectorIndexIR>;
192
211
  }
@@ -214,6 +233,16 @@ interface SchemaIR {
214
233
  interface FunctionIR {
215
234
  args: Record<string, ValidatorIR>;
216
235
  exportName: string;
236
+ /**
237
+ * Set by the `.expose({ rest: true })` builder modifier (plan 167). When
238
+ * `rest` is `true` the function is published on the public REST surface, so the
239
+ * OpenAPI emitter describes it as a real `/_lunora/rest/&lt;namespace>/&lt;fn>` path
240
+ * (the single source of truth the runtime router also derives from). Absent →
241
+ * RPC-only (the default; not on the REST surface).
242
+ */
243
+ expose?: {
244
+ rest?: boolean;
245
+ };
217
246
  /** Path relative to `&lt;projectRoot>/lunora/` without extension, e.g. "messages". */
218
247
  filePath: string;
219
248
  kind: "action" | "mutation" | "query" | "stream";
@@ -925,6 +954,8 @@ interface ProcedureMiddlewareIR {
925
954
  unboundedAiGeneration: boolean;
926
955
  /** `true` when the chain carries `.use(verifyTurnstile(...))` or a `protectPublic({ captcha })` bundle. */
927
956
  usesCaptcha: boolean;
957
+ /** `true` when the chain carries `.use(emailGateMiddleware(...))` (`@lunora/auth`). Feeds the `signup_mutation_without_disposable_gating` lint. */
958
+ usesEmailGate: boolean;
928
959
  /** `true` when the handler calls `ctx.db.insertManyUnsafe(...)`, bypassing validators and triggers. Feeds the `insert_many_unsafe_user_data` lint. */
929
960
  usesInsertManyUnsafe: boolean;
930
961
  /** `true` when the chain carries `.use(mask(...))`. */
@@ -1689,8 +1720,10 @@ interface LintSchemaOptions {
1689
1720
  containerKeyAccesses?: ReadonlyArray<ContainerKeyAccessIR>;
1690
1721
  containerOverrides?: ReadonlyArray<ContainerOverrideIR>;
1691
1722
  containers?: ReadonlyArray<ContainerIR>;
1723
+ exportSinks?: ReadonlyArray<AdvisorExportSink>;
1692
1724
  failOpenGuards?: ReadonlyArray<FailOpenGuardIR>;
1693
1725
  flagSecurityDefaults?: ReadonlyArray<FlagSecurityDefaultIR>;
1726
+ geoIndexUsages?: ReadonlyArray<AdvisorGeoIndexUsage>;
1694
1727
  httpActionGuards?: ReadonlyArray<HttpActionGuardIR>;
1695
1728
  httpHeaderWrites?: ReadonlyArray<HttpHeaderWriteIR>;
1696
1729
  identityClaimReads?: ReadonlyArray<IdentityClaimReadIR>;
@@ -1703,6 +1736,8 @@ interface LintSchemaOptions {
1703
1736
  mutatorWrites?: ReadonlyArray<MutatorWriteIR>;
1704
1737
  nondeterministicCalls?: ReadonlyArray<NondeterministicCallIR>;
1705
1738
  normalizeIdAuthorizations?: ReadonlyArray<NormalizeIdAuthorizationIR>;
1739
+ notifyCalls?: ReadonlyArray<AdvisorNotifyCall>;
1740
+ notifyConfig?: AdvisorNotifyConfig;
1706
1741
  ownerFieldWrites?: ReadonlyArray<OwnerFieldWriteIR>;
1707
1742
  paymentWebhooks?: ReadonlyArray<PaymentWebhookIR>;
1708
1743
  privilegedDispatches?: ReadonlyArray<PrivilegedDispatchIR>;
@@ -1872,6 +1907,27 @@ declare const discoverMutators: (project: Project, lunoraDirectory: string) => M
1872
1907
  * produced per call site.
1873
1908
  */
1874
1909
  declare const discoverNondeterministicCalls: (project: Project, lunoraDirectory: string) => NondeterministicCallIR[];
1910
+ /** The only file a `@lunora/notify` provider may be declared in — mirrors `lunora/flags.ts`. */
1911
+ declare const NOTIFY_FILENAME = "notify.ts";
1912
+ /**
1913
+ * Discover `ctx.notify` / `ctx.push` sends lexically inside the handler body of
1914
+ * every exported `query(...)` / `mutation(...)` registration under the lunora
1915
+ * source directory — the `notify_send_outside_action` lint input. `action(...)`
1916
+ * (and `stream(...)`) registrations are intentionally skipped: a notification
1917
+ * send is external I/O that belongs in actions. One {@link AdvisorNotifyCall} is
1918
+ * produced per send site.
1919
+ */
1920
+ declare const discoverNotifyCalls: (project: Project, lunoraDirectory: string) => AdvisorNotifyCall[];
1921
+ /**
1922
+ * Discover which push channels the project's `lunora/notify.ts` default export
1923
+ * (`defineNotify({...})`) wires plus whether any handler sends a push — the
1924
+ * `notify_missing_push_config` lint input. Returns `undefined` when the file is
1925
+ * absent (the app declares no notify config). The read is metadata-only and
1926
+ * lenient (like `discoverFlags`): a `webPush`/`fcm` property's mere presence
1927
+ * counts as the channel being wired; a non-literal config degrades to "unwired"
1928
+ * rather than throwing.
1929
+ */
1930
+ declare const discoverNotifyConfig: (project: Project, lunoraDirectory: string) => AdvisorNotifyConfig | undefined;
1875
1931
  /**
1876
1932
  * Discover `ctx.db.query("table")…` reads under the lunora source directory and
1877
1933
  * reduce each to a {@link QueryReadIR}. Only reads that call `.filter()` are
@@ -2027,6 +2083,8 @@ interface EmitServerOptions {
2027
2083
  hasImages?: boolean;
2028
2084
  /** A `lunora/` source uses `@lunora/bindings/kv` / `ctx.kv` — wires `ctx.kv` onto every ctx. */
2029
2085
  hasKv?: boolean;
2086
+ /** The project declares `lunora/notify.ts` — wires `ctx.notify` + its `ctx.push` alias (`@lunora/notify`) onto every ctx. */
2087
+ hasNotify?: boolean;
2030
2088
  hasPayments?: boolean;
2031
2089
  /** A `lunora/` source uses `@lunora/bindings/pipelines` / `ctx.pipelines` — wires `ctx.pipelines` onto ActionCtx only. */
2032
2090
  hasPipelines?: boolean;
@@ -2051,7 +2109,7 @@ interface EmitServerOptions {
2051
2109
  useUmbrella?: boolean;
2052
2110
  workflows?: ReadonlyArray<WorkflowIR>;
2053
2111
  }
2054
- declare const emitServer: ({ agents, containers, env, hasAccessFacade, hasAi, hasAnalytics, hasBrowser, hasFlags, hasHyperdrive, hasImages, hasKv, hasPayments, hasPipelines, hasR2sql, hasX402, identity, queues, schema, storageRuleBuckets, useUmbrella, workflows }?: EmitServerOptions) => string;
2112
+ declare const emitServer: ({ agents, containers, env, hasAccessFacade, hasAi, hasAnalytics, hasBrowser, hasFlags, hasHyperdrive, hasImages, hasKv, hasNotify, hasPayments, hasPipelines, hasR2sql, hasX402, identity, queues, schema, storageRuleBuckets, useUmbrella, workflows }?: EmitServerOptions) => string;
2055
2113
  interface EmitFunctionsOptions {
2056
2114
  agents?: ReadonlyArray<AgentIR>;
2057
2115
  functions: ReadonlyArray<FunctionIR>;
@@ -2118,6 +2176,8 @@ interface EmitShardOptions {
2118
2176
  hasImages?: boolean;
2119
2177
  /** A `lunora/` source reads `ctx.kv` — wires `ctx.kv` onto every ctx. */
2120
2178
  hasKv?: boolean;
2179
+ /** The project declares `lunora/notify.ts` — wires `ctx.notify` + its `ctx.push` alias (`@lunora/notify`) onto every ctx. */
2180
+ hasNotify?: boolean;
2121
2181
  hasPayments?: boolean;
2122
2182
  /** A `lunora/` source reads `ctx.pipelines` — wires `ctx.pipelines` onto the ActionCtx only. */
2123
2183
  hasPipelines?: boolean;
@@ -2140,7 +2200,7 @@ interface EmitShardOptions {
2140
2200
  useUmbrella?: boolean;
2141
2201
  workflows?: ReadonlyArray<WorkflowIR>;
2142
2202
  }
2143
- declare const emitShard: ({ advisories, agents, containers, env, flagKeys, hasAccessFacade, hasAi, hasAnalytics, hasBrowser, hasFlags, hasHyperdrive, hasImages, hasKv, hasPayments, hasPipelines, hasR2sql, hasX402, maskMetadata, mutators, queues, rlsMetadata, schema, shapes, storageRules, studioFeatures, useUmbrella, workflows }: EmitShardOptions) => string;
2203
+ declare const emitShard: ({ advisories, agents, containers, env, flagKeys, hasAccessFacade, hasAi, hasAnalytics, hasBrowser, hasFlags, hasHyperdrive, hasImages, hasKv, hasNotify, hasPayments, hasPipelines, hasR2sql, hasX402, maskMetadata, mutators, queues, rlsMetadata, schema, shapes, storageRules, studioFeatures, useUmbrella, workflows }: EmitShardOptions) => string;
2144
2204
  /**
2145
2205
  * Emit drizzle `sqliteTable` definitions for the project schema, split into
2146
2206
  * `global` (D1-backed) and `shard` (DO-SQLite-backed) buckets. Tables marked
@@ -2232,6 +2292,8 @@ interface EmitAppOptions {
2232
2292
  hasImages: boolean;
2233
2293
  /** App uses `@lunora/bindings/kv` / `ctx.kv` → emit `.kv()`. */
2234
2294
  hasKv: boolean;
2295
+ /** App declares `lunora/notify.ts` (`@lunora/notify`) → wire `options.notifySubscriptionStore` so the studio Notifications page can read registered devices. */
2296
+ hasNotify: boolean;
2235
2297
  /** App uses `@lunora/payment` / `ctx.payments` → emit `.payment()`. */
2236
2298
  hasPayments: boolean;
2237
2299
  /** App declares push queues (`defineQueue`) → wire `LUNORA_QUEUE_REGISTRY` into the worker's `queue()` consumer entry. */
@@ -2727,4 +2789,4 @@ declare const secretKindOf: (value: string) => string | undefined;
2727
2789
  /** A redacted preview of a secret value — first 4 chars plus its length, never the full value. */
2728
2790
  declare const redact: (value: string) => string;
2729
2791
  declare const VERSION = "0.0.0";
2730
- export { AGENTS_FILENAME, type AgentIR, 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, type LintSchemaOptions, 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 SandboxUsage, 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, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, evaluateSchemaDrift, formatAdvisories, lintSchema, parseSchemaSnapshot, redact, refreshCodegenProject, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, validatorIrToJsonSchema };
2792
+ export { AGENTS_FILENAME, type AgentIR, 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, type LintSchemaOptions, MUTATORS_FILENAME, type MaskProcedureIR, type MigrationIR, type MutatorIR, NOTIFY_FILENAME, 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 SandboxUsage, 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, type WranglerVariableIR, buildOpenApiDocument, buildOpenRpcDocument, buildSchemaSnapshot, createCodegenProject, diagnosticAt, diffSchemaSnapshots, discoverAgents, discoverAuthApiCalls, discoverContainers, discoverCrons, discoverFlags, discoverFunctions, discoverHttpRoutes, discoverInserts, discoverMaskProcedures, discoverMigrations, discoverMutators, discoverNondeterministicCalls, discoverNotifyCalls, discoverNotifyConfig, discoverQueries, discoverQueues, discoverR2sqlCalls, discoverRlsMetadata, discoverRlsProcedures, discoverSandboxUsage, discoverSchema, discoverShapes, discoverStorageRulesMetadata, discoverWorkflows, emitAgents, emitApi, emitApp, emitCollections, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitOpenApi, emitOpenApiModule, emitOpenRpc, emitOpenRpcModule, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers, evaluateSchemaDrift, formatAdvisories, lintSchema, parseSchemaSnapshot, redact, refreshCodegenProject, runCodegen, schemaFromIr, secretKindOf, serializeSchemaSnapshot, validatorIrToJsonSchema };
package/dist/index.mjs CHANGED
@@ -1,31 +1,32 @@
1
- export { formatAdvisories, lintSchema } from './packem_shared/formatAdvisories-BmF7Mplc.mjs';
1
+ export { formatAdvisories, lintSchema } from './packem_shared/formatAdvisories-Cans5TWS.mjs';
2
2
  export { CodegenDiagnosticError, diagnosticAt } from './packem_shared/CodegenDiagnosticError-DyQ5FwkM.mjs';
3
3
  export { AGENTS_FILENAME, discoverAgents } from './packem_shared/AGENTS_FILENAME-Cxx7wiSs.mjs';
4
- export { default as discoverAuthApiCalls } from './packem_shared/discoverAuthApiCalls-Dx3K42rk.mjs';
4
+ export { default as discoverAuthApiCalls } from './packem_shared/discoverAuthApiCalls-Dhwgf4J4.mjs';
5
5
  export { CONTAINERS_FILENAME, discoverContainers } from './packem_shared/CONTAINERS_FILENAME-DjpXMqhp.mjs';
6
- export { default as discoverCrons } from './packem_shared/discoverCrons-DvqkEWdx.mjs';
7
- export { FLAGS_FILENAME, discoverFlags } from './packem_shared/FLAGS_FILENAME-Dg4mKUuz.mjs';
8
- export { discoverFunctions } from './packem_shared/discoverFunctions-BJ-qR7Rg.mjs';
9
- export { default as discoverHttpRoutes } from './packem_shared/discoverHttpRoutes-daCzuTe8.mjs';
10
- export { default as discoverInserts } from './packem_shared/discoverInserts-DI4q5NxE.mjs';
11
- export { default as discoverMaskProcedures } from './packem_shared/discoverMaskProcedures-BcTOEKNU.mjs';
12
- export { default as discoverMigrations } from './packem_shared/discoverMigrations-VNUFvCwr.mjs';
6
+ export { default as discoverCrons } from './packem_shared/discoverCrons-UbQLLmMS.mjs';
7
+ export { FLAGS_FILENAME, discoverFlags } from './packem_shared/FLAGS_FILENAME-D5igzqwR.mjs';
8
+ export { discoverFunctions } from './packem_shared/discoverFunctions-COG_Xkyz.mjs';
9
+ export { default as discoverHttpRoutes } from './packem_shared/discoverHttpRoutes-CVXWZkzo.mjs';
10
+ export { default as discoverInserts } from './packem_shared/discoverInserts-DdWnXmLS.mjs';
11
+ export { default as discoverMaskProcedures } from './packem_shared/discoverMaskProcedures-BG58_fw3.mjs';
12
+ export { default as discoverMigrations } from './packem_shared/discoverMigrations-Bw1U01zr.mjs';
13
13
  export { MUTATORS_FILENAME, discoverMutators } from './packem_shared/MUTATORS_FILENAME-BZOfUhlY.mjs';
14
- export { default as discoverNondeterministicCalls } from './packem_shared/discoverNondeterministicCalls-S0N2xLCq.mjs';
15
- export { default as discoverQueries } from './packem_shared/discoverQueries-CJnnnLpd.mjs';
14
+ export { default as discoverNondeterministicCalls } from './packem_shared/discoverNondeterministicCalls-BbXEFZUT.mjs';
15
+ export { NOTIFY_FILENAME, discoverNotifyCalls, discoverNotifyConfig } from './packem_shared/NOTIFY_FILENAME-CK2IrsrP.mjs';
16
+ export { default as discoverQueries } from './packem_shared/discoverQueries-CDmxu2ET.mjs';
16
17
  export { QUEUES_FILENAME, discoverQueues } from './packem_shared/QUEUES_FILENAME-Xv6Vy-Ku.mjs';
17
- export { default as discoverR2sqlCalls } from './packem_shared/discoverR2sqlCalls-pnpicWfz.mjs';
18
- export { discoverRlsMetadata, default as discoverRlsProcedures } from './packem_shared/discoverRlsMetadata-DppniPUH.mjs';
19
- export { discoverSandboxUsage } from './packem_shared/discoverSandboxUsage-BUM2r90k.mjs';
20
- export { default as discoverSchema } from './packem_shared/discoverSchema-BaSAvooG.mjs';
18
+ export { default as discoverR2sqlCalls } from './packem_shared/discoverR2sqlCalls-Bn7QVv7J.mjs';
19
+ export { discoverRlsMetadata, default as discoverRlsProcedures } from './packem_shared/discoverRlsMetadata-D9uN35no.mjs';
20
+ export { discoverSandboxUsage } from './packem_shared/discoverSandboxUsage-B5jDU6Bt.mjs';
21
+ export { default as discoverSchema } from './packem_shared/discoverSchema-BJp5_T4o.mjs';
21
22
  export { SHAPES_FILENAME, discoverShapes } from './packem_shared/SHAPES_FILENAME-DOhPGi-6.mjs';
22
- export { default as discoverStorageRulesMetadata } from './packem_shared/discoverStorageRulesMetadata-CnHl2rXD.mjs';
23
+ export { default as discoverStorageRulesMetadata } from './packem_shared/discoverStorageRulesMetadata-BqMhuEjo.mjs';
23
24
  export { WORKFLOWS_FILENAME, discoverWorkflows } from './packem_shared/WORKFLOWS_FILENAME-Dtuzvluc.mjs';
24
- export { G as GENERATED_HEADER, e as emitAgents, a as emitApi, b as emitCollections, c as emitContainers, d as emitCrons, f as emitDataModel, g as emitDrizzleSchema, h as emitFunctions, i as emitServer, j as emitShard, k as emitVectors, l as emitWorkflows, m as emitWranglerCronTriggers } from './packem_shared/emit-ClTbCLy4.mjs';
25
- export { emitApp } from './packem_shared/emitApp-CzzrjVqH.mjs';
26
- export { buildOpenApiDocument, emitOpenApi, emitOpenApiModule } from './packem_shared/buildOpenApiDocument-B7mEdzA2.mjs';
27
- export { OPENRPC_VERSION, buildOpenRpcDocument, emitOpenRpc, emitOpenRpcModule } from './packem_shared/OPENRPC_VERSION-7A2weq2u.mjs';
28
- export { SCHEMA_SNAPSHOT_FILENAME, createCodegenProject, refreshCodegenProject, runCodegen } from './packem_shared/SCHEMA_SNAPSHOT_FILENAME-G5dkcxPR.mjs';
25
+ export { G as GENERATED_HEADER, e as emitAgents, a as emitApi, b as emitCollections, c as emitContainers, d as emitCrons, f as emitDataModel, g as emitDrizzleSchema, h as emitFunctions, i as emitServer, j as emitShard, k as emitVectors, l as emitWorkflows, m as emitWranglerCronTriggers } from './packem_shared/emit-B4LUyyg7.mjs';
26
+ export { emitApp } from './packem_shared/emitApp-BJ6weBMT.mjs';
27
+ export { buildOpenApiDocument, emitOpenApi, emitOpenApiModule } from './packem_shared/buildOpenApiDocument-BH50tL6w.mjs';
28
+ export { OPENRPC_VERSION, buildOpenRpcDocument, emitOpenRpc, emitOpenRpcModule } from './packem_shared/OPENRPC_VERSION-Dnru3-Tg.mjs';
29
+ export { SCHEMA_SNAPSHOT_FILENAME, createCodegenProject, refreshCodegenProject, runCodegen } from './packem_shared/SCHEMA_SNAPSHOT_FILENAME-7_LhHIAy.mjs';
29
30
  export { SCHEMA_SNAPSHOT_VERSION, SchemaSnapshotParseError, buildSchemaSnapshot, diffSchemaSnapshots, evaluateSchemaDrift, parseSchemaSnapshot, serializeSchemaSnapshot } from './packem_shared/SCHEMA_SNAPSHOT_VERSION-D0ARY6rL.mjs';
30
31
  export { schemaFromIr } from './packem_shared/schemaFromIr-DTYsLBaA.mjs';
31
32
  export { LUNORA_ERROR_CODES, validatorIrToJsonSchema } from './packem_shared/LUNORA_ERROR_CODES-DvTLozCu.mjs';
@@ -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-BJ-qR7Rg.mjs';
4
+ import { listLunoraSourceFiles } from './discoverFunctions-COG_Xkyz.mjs';
5
5
 
6
6
  const FLAGS_FILENAME = "flags.ts";
7
7
  const FLAG_TYPES = /* @__PURE__ */ new Set(["boolean", "number", "object", "string"]);
@@ -1,4 +1,4 @@
1
1
  import '@lunora/agent/component';
2
2
  import '@lunora/errors';
3
- export { G as GENERATED_HEADER, n as buildStorageColumns, e as emitAgents, a as emitApi, b as emitCollections, c as emitContainers, d as emitCrons, f as emitDataModel, g as emitDrizzleSchema, h as emitFunctions, o as emitQueues, p as emitSeed, i as emitServer, j as emitShard, k as emitVectors, l as emitWorkflows, m as emitWranglerCronTriggers } from './emit-ClTbCLy4.mjs';
3
+ export { G as GENERATED_HEADER, n as buildStorageColumns, e as emitAgents, a as emitApi, b as emitCollections, c as emitContainers, d as emitCrons, f as emitDataModel, g as emitDrizzleSchema, h as emitFunctions, o as emitQueues, p as emitSeed, i as emitServer, j as emitShard, k as emitVectors, l as emitWorkflows, m as emitWranglerCronTriggers } from './emit-B4LUyyg7.mjs';
4
4
  import './paths-BRd6JHuF.mjs';
@@ -0,0 +1,152 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { SyntaxKind, Node } from 'ts-morph';
4
+ import { listLunoraSourceFiles, lunoraRelativePath, classifyProcedureCall } from './discoverFunctions-COG_Xkyz.mjs';
5
+
6
+ const NOTIFY_FILENAME = "notify.ts";
7
+ const NOTIFY_SEND_METHODS = /* @__PURE__ */ new Set(["chat", "inApp", "send", "webhook"]);
8
+ const PUSH_SEND_METHODS = /* @__PURE__ */ new Set(["broadcast", "send"]);
9
+ const handlerOf = (call, receiver) => {
10
+ if (receiver) {
11
+ const handler = call.getArguments()[0];
12
+ return handler && (Node.isArrowFunction(handler) || Node.isFunctionExpression(handler)) ? handler : void 0;
13
+ }
14
+ const first = call.getArguments()[0];
15
+ if (!first || !Node.isObjectLiteralExpression(first)) {
16
+ return void 0;
17
+ }
18
+ const handlerProperty = first.getProperty("handler");
19
+ if (!handlerProperty || !Node.isPropertyAssignment(handlerProperty)) {
20
+ return void 0;
21
+ }
22
+ const initializer = handlerProperty.getInitializer();
23
+ return initializer && (Node.isArrowFunction(initializer) || Node.isFunctionExpression(initializer)) ? initializer : void 0;
24
+ };
25
+ const exportedProcedureHandler = (declaration) => {
26
+ const initializer = declaration.getInitializer();
27
+ if (!initializer || !Node.isCallExpression(initializer)) {
28
+ return void 0;
29
+ }
30
+ const classified = classifyProcedureCall(initializer);
31
+ if (!classified) {
32
+ return void 0;
33
+ }
34
+ const handler = handlerOf(initializer, classified.receiver);
35
+ return handler ? { exportName: declaration.getName(), handler, kind: classified.kind } : void 0;
36
+ };
37
+ const proceduresInSourceFile = (sourceFile) => {
38
+ const found = [];
39
+ for (const statement of sourceFile.getVariableStatements()) {
40
+ if (!statement.isExported()) {
41
+ continue;
42
+ }
43
+ for (const declaration of statement.getDeclarations()) {
44
+ const procedure = exportedProcedureHandler(declaration);
45
+ if (procedure) {
46
+ found.push(procedure);
47
+ }
48
+ }
49
+ }
50
+ return found;
51
+ };
52
+ const facadeOf = (node) => {
53
+ if (!Node.isPropertyAccessExpression(node)) {
54
+ return void 0;
55
+ }
56
+ const name = node.getName();
57
+ const receiver = node.getExpression();
58
+ if ((name === "notify" || name === "push") && Node.isIdentifier(receiver) && receiver.getText() === "ctx") {
59
+ return name;
60
+ }
61
+ if (name === "push" && facadeOf(receiver) === "notify") {
62
+ return "push";
63
+ }
64
+ return void 0;
65
+ };
66
+ const notifyCalleeOf = (access) => {
67
+ if (!Node.isPropertyAccessExpression(access)) {
68
+ return void 0;
69
+ }
70
+ const method = access.getName();
71
+ const facade = facadeOf(access.getExpression());
72
+ if (facade === "notify" && NOTIFY_SEND_METHODS.has(method)) {
73
+ return `ctx.notify.${method}`;
74
+ }
75
+ if (facade === "push" && PUSH_SEND_METHODS.has(method)) {
76
+ return `ctx.push.${method}`;
77
+ }
78
+ return void 0;
79
+ };
80
+ const isPushSend = (access) => {
81
+ if (!Node.isPropertyAccessExpression(access)) {
82
+ return false;
83
+ }
84
+ return facadeOf(access.getExpression()) === "push" && PUSH_SEND_METHODS.has(access.getName());
85
+ };
86
+ const discoverNotifyCalls = (project, lunoraDirectory) => {
87
+ const calls = [];
88
+ for (const filePath of listLunoraSourceFiles(lunoraDirectory)) {
89
+ const sourceFile = project.getSourceFile(filePath) ?? project.addSourceFileAtPath(filePath);
90
+ const relativePath = lunoraRelativePath(lunoraDirectory, filePath);
91
+ for (const procedure of proceduresInSourceFile(sourceFile)) {
92
+ if (procedure.kind !== "query" && procedure.kind !== "mutation") {
93
+ continue;
94
+ }
95
+ for (const access of procedure.handler.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression)) {
96
+ const callee = notifyCalleeOf(access);
97
+ if (callee !== void 0) {
98
+ calls.push({ callee, exportName: procedure.exportName, file: relativePath, kind: procedure.kind, line: access.getStartLineNumber() });
99
+ }
100
+ }
101
+ }
102
+ }
103
+ return calls;
104
+ };
105
+ const projectUsesPush = (project, lunoraDirectory) => {
106
+ for (const filePath of listLunoraSourceFiles(lunoraDirectory)) {
107
+ const sourceFile = project.getSourceFile(filePath) ?? project.addSourceFileAtPath(filePath);
108
+ for (const procedure of proceduresInSourceFile(sourceFile)) {
109
+ for (const access of procedure.handler.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression)) {
110
+ if (isPushSend(access)) {
111
+ return true;
112
+ }
113
+ }
114
+ }
115
+ }
116
+ return false;
117
+ };
118
+ const defaultExportExpression = (source) => {
119
+ const assignment = source.getExportAssignment((declaration2) => !declaration2.isExportEquals());
120
+ if (!assignment) {
121
+ return void 0;
122
+ }
123
+ const expression = assignment.getExpression();
124
+ if (!Node.isIdentifier(expression)) {
125
+ return expression;
126
+ }
127
+ const declaration = expression.getSymbol()?.getValueDeclaration();
128
+ if (declaration && Node.isVariableDeclaration(declaration)) {
129
+ return declaration.getInitializer();
130
+ }
131
+ return expression;
132
+ };
133
+ const discoverNotifyConfig = (project, lunoraDirectory) => {
134
+ const notifyPath = join(lunoraDirectory, NOTIFY_FILENAME);
135
+ if (!existsSync(notifyPath)) {
136
+ return void 0;
137
+ }
138
+ const source = project.getSourceFile(notifyPath) ?? project.addSourceFileAtPath(notifyPath);
139
+ const exported = defaultExportExpression(source);
140
+ let hasWebPush = false;
141
+ let hasFcm = false;
142
+ if (exported && Node.isCallExpression(exported)) {
143
+ const argument = exported.getArguments()[0];
144
+ if (argument && Node.isObjectLiteralExpression(argument)) {
145
+ hasWebPush = argument.getProperty("webPush") !== void 0;
146
+ hasFcm = argument.getProperty("fcm") !== void 0;
147
+ }
148
+ }
149
+ return { hasFcm, hasWebPush, usesPush: projectUsesPush(project, lunoraDirectory) };
150
+ };
151
+
152
+ export { NOTIFY_FILENAME, discoverNotifyCalls, discoverNotifyConfig };
@@ -1,4 +1,4 @@
1
- import { G as GENERATED_HEADER } from './emit-ClTbCLy4.mjs';
1
+ import { G as GENERATED_HEADER } from './emit-B4LUyyg7.mjs';
2
2
  import { s as sanitizeNamespace } from './paths-BRd6JHuF.mjs';
3
3
  import { argsObjectSchema, LUNORA_ERROR_CODES } from './LUNORA_ERROR_CODES-DvTLozCu.mjs';
4
4