@lunora/server 1.0.0-alpha.94 → 1.0.0-alpha.96

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 (54) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.mts +85 -50
  3. package/dist/index.d.ts +85 -50
  4. package/dist/index.mjs +1 -1
  5. package/dist/packem_shared/{ACTION_CACHE_DEFAULT_TTL_MS-BG6A6rHA.mjs → ACTION_CACHE_DEFAULT_TTL_MS-OuQ-AJjz.mjs} +1 -1
  6. package/dist/packem_shared/{DOCUMENT_HISTORY_REDACTED_FIELDS-CXOIUOBE.mjs → DOCUMENT_HISTORY_REDACTED_FIELDS-wgfbacHx.mjs} +1 -1
  7. package/dist/packem_shared/{LunoraEnvError-_BakoYQ3.mjs → LunoraEnvError-CXbrsFI8.mjs} +2 -2
  8. package/dist/packem_shared/PRESENCE_DEFAULT_TTL_MS-lsooaSaF.mjs +1 -0
  9. package/dist/packem_shared/apply-output-C5wZ5EAL.mjs +1 -0
  10. package/dist/packem_shared/{bindOrm-lWdeDi9P.mjs → bindOrm-ChQydkdL.mjs} +1 -1
  11. package/dist/packem_shared/buildMaskRegistry-DpWMtalG.mjs +1 -0
  12. package/dist/packem_shared/buildRlsReadRegistry-CIGmNx0b.mjs +1 -0
  13. package/dist/packem_shared/compose-middleware-3i5Qk3sb.mjs +1 -0
  14. package/dist/packem_shared/composePluginMiddleware-pe7Ncehp.mjs +1 -0
  15. package/dist/packem_shared/createPolicyDsl-BZa6SqLJ.mjs +1 -0
  16. package/dist/packem_shared/{createSecrets-CyrEddTF.mjs → createSecrets-D6rLB42U.mjs} +1 -1
  17. package/dist/packem_shared/{defineAggregateIndex-C3kWoQ-P.mjs → defineAggregateIndex-DFVCeuX1.mjs} +1 -1
  18. package/dist/packem_shared/defineMigration-CXOS0Bvq.mjs +1 -0
  19. package/dist/packem_shared/{defineShape-DYxbNl5W.mjs → defineShape-BWgwFuMT.mjs} +1 -1
  20. package/dist/packem_shared/defineStorageRule-Dv4nJE0H.mjs +1 -0
  21. package/dist/packem_shared/httpAction-B8X6jXen.mjs +5 -0
  22. package/dist/packem_shared/initLunora-D5TSiy5j.mjs +1 -0
  23. package/dist/packem_shared/mask-pIhIWBcr.mjs +1 -0
  24. package/dist/packem_shared/middleware-Cz5s6CH-.mjs +1 -0
  25. package/dist/packem_shared/plugin-yKCbHnlj.mjs +1 -0
  26. package/dist/packem_shared/policy-tag-V0lqFzgS.mjs +1 -0
  27. package/dist/packem_shared/protectPublic-Csf6ObbJ.mjs +1 -0
  28. package/dist/packem_shared/rls-BjRa5pMm.mjs +1 -0
  29. package/dist/packem_shared/run-middleware-CuM-Chm3.mjs +1 -0
  30. package/dist/packem_shared/storageRules-DHvF6Fjq.mjs +1 -0
  31. package/dist/packem_shared/{wire-codec-hZHn-Ooo.mjs → wire-codec-uveYSVra.mjs} +1 -1
  32. package/dist/rls/testing.mjs +1 -1
  33. package/dist/types.d.mts +83 -22
  34. package/dist/types.d.ts +83 -22
  35. package/package.json +4 -4
  36. package/dist/packem_shared/LunoraError-DcKdk9Ti.mjs +0 -1
  37. package/dist/packem_shared/PRESENCE_DEFAULT_TTL_MS-B6z9BcPN.mjs +0 -1
  38. package/dist/packem_shared/apply-output-D7vpBeeu.mjs +0 -1
  39. package/dist/packem_shared/buildMaskRegistry-72SL8fJn.mjs +0 -1
  40. package/dist/packem_shared/buildRlsReadRegistry-Ct60PLD-.mjs +0 -1
  41. package/dist/packem_shared/composePluginMiddleware-D8I_XMLV.mjs +0 -1
  42. package/dist/packem_shared/createPolicyDsl-DNfByAUX.mjs +0 -1
  43. package/dist/packem_shared/defineMigration-7GI9Qbtd.mjs +0 -1
  44. package/dist/packem_shared/defineStorageRule-BvxHVq3b.mjs +0 -1
  45. package/dist/packem_shared/httpAction-DEN_78Kj.mjs +0 -5
  46. package/dist/packem_shared/initLunora-BxNkWYTz.mjs +0 -1
  47. package/dist/packem_shared/mask-NVloFLLY.mjs +0 -1
  48. package/dist/packem_shared/middleware-EloVU9X1.mjs +0 -1
  49. package/dist/packem_shared/plugin-DfuRhJS1.mjs +0 -1
  50. package/dist/packem_shared/policy-tag-D4RzgQnw.mjs +0 -1
  51. package/dist/packem_shared/protectPublic-Bo4G9xaV.mjs +0 -1
  52. package/dist/packem_shared/rls-B6du_B-q.mjs +0 -1
  53. package/dist/packem_shared/run-middleware-B-JeGGp9.mjs +0 -1
  54. package/dist/packem_shared/storageRules-91NHMDL6.mjs +0 -1
package/README.md CHANGED
@@ -116,7 +116,7 @@ The dev server and CLI automatically bump `compatibility_date` to the minimum re
116
116
  **Set cache headers declaratively** on an `httpRoute`:
117
117
 
118
118
  ```ts
119
- import { httpRoute } from "./_generated/server";
119
+ import { httpRoute, v } from "@lunora/server";
120
120
 
121
121
  export const getProduct = httpRoute
122
122
  .get("/api/products/:id")
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Validator, Infer, v, Id, ValidatorMap, InferValidatorMap, ColumnValidator } from '@lunora/values';
2
2
  export { type ColumnValidator, type GeoPoint, type Id, type Infer, ValidationError, type Validator, type ValidatorKind, v } from '@lunora/values';
3
3
  import { ArgsValidator, InferArgs, RegisteredAction, ExposeConfig, X402ProcedureConfig, ActionCtx, MutationCtx, RegisteredMutation, QueryCtx, RegisteredQuery, DurableStreamOptions, RegisteredStream, FunctionKind, TableDefinition, RegisteredFunction, VectorIndexDefinition, Schema, AggregateOp, GlobalBackend, RelationDefinition, OnDeleteAction, SearchLanguage, SearchStrategy, ExternalSourceDefinition, TriggerBuilder, TriggerDefinition, VectorEmbedder, VectorMetric, DurableObjectJurisdiction, AggregateIndexDefinition, RankIndexDefinition, Secrets, LifecycleEvent, ShardInitEvent, RegisteredLifecycleHook } from "./types.mjs";
4
- export { type AnyApi, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type IndexDefinition, type IndexRangeBuilder, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type MutationStorage, type PaginationOptions, type PaginationResult, type RankSortKey, type ReadOnlyStorage, type RestCacheConfig, type RunQueryOptions, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type SearchFilterBuilder, type SearchIndexDefinition, type ShardMode, type SpanEvaluation, type SpanHandle, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type StorageObjectHead, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerCtx, type TriggerDatabase, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorMatch, type VectorMatches, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowEventDefinition, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, anyApi } from "./types.mjs";
5
- import { LunoraError as LunoraError$1, LunoraErrorCode } from '@lunora/errors';
6
- export type { LunoraErrorCode } from '@lunora/errors';
4
+ export { type AnyApi, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type IndexDefinition, type IndexRangeBuilder, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type MutationStorage, type PaginationOptions, type PaginationResult, type RankSortKey, type ReadOnlyStorage, type RestCacheConfig, type RunQueryOptions, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type SearchFilterBuilder, type SearchIndexDefinition, type ShardMode, type SpanEvaluation, type SpanHandle, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type StorageObjectBody, type StorageObjectHead, type StorageRange, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerCtx, type TriggerDatabase, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorMatch, type VectorMatches, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowEventDefinition, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, anyApi } from "./types.mjs";
5
+ import { LunoraError } from '@lunora/errors';
6
+ export { LunoraError, type LunoraErrorCode } from '@lunora/errors';
7
7
  import { Context, Hono } from 'hono';
8
8
  import { WhereOperators, QueryArgs as QueryArgs$2 } from "./data-model.mjs";
9
9
  import { W as WhereInput, a as Policy, b as RlsOptions, c as Permission, R as Role, T as TypedDefinePolicyInput, D as DefinePolicyInput } from "./packem_shared/types.d-B-pIn8rE.mjs";
@@ -40,6 +40,26 @@ type Middleware<ContextIn, ContextOut> = (options: {
40
40
  ctx: ContextIn;
41
41
  next: MiddlewareNext<ContextIn>;
42
42
  }) => ContextOut | Promise<ContextOut>;
43
+ /**
44
+ * The context a `.use(...)` step actually receives: the procedure context plus
45
+ * `args`, the call's arguments as declared by `.input(...)` up to this point in
46
+ * the chain.
47
+ *
48
+ * A middleware that gates on the payload — a CAPTCHA token, a signup email —
49
+ * has nowhere else to read it from: the procedure context carries the resolved
50
+ * identity, not the request body. `args` is surfaced only AFTER the validators
51
+ * have run, and as a frozen shallow copy, so a middleware cannot rewrite what
52
+ * the handler is then handed.
53
+ *
54
+ * This is a PROCEDURE-builder surface. `httpAction` / `httpRoute` have no
55
+ * `.use()` chain at all (`HttpActionCtx` is not a builder context) — an HTTP
56
+ * handler reads its own `request` / `searchParams` / `body` and calls the
57
+ * underlying helper (`verifyTurnstile(...)`, `assertEmailAllowed(...)`) inline,
58
+ * or mounts a hono middleware.
59
+ */
60
+ type MiddlewareContext<Context, Args extends ArgsValidator> = Context & {
61
+ readonly args: Readonly<InferArgs<Args>>;
62
+ };
43
63
  /** Options accepted by `initLunora.dataModel<DM>().create(...)`. Reserved for transformer/error-formatter wiring. */
44
64
  type CreateOptions = Record<never, never>;
45
65
  /**
@@ -62,14 +82,17 @@ interface QueryBuilder<Context, Args extends ArgsValidator, Output = undefined>
62
82
  expose: (config: ExposeConfig) => QueryBuilder<Context, Args, Output>;
63
83
  input: <A extends ArgsValidator>(validators: A) => QueryBuilder<Context, A & Args, Output>;
64
84
  /**
65
- * Attach static, per-procedure metadata. Merges across calls, is readable
66
- * from middleware as `ctx.meta`, and is stamped onto the registration as
67
- * `fn.meta` so codegen and other tooling can enumerate it.
85
+ * Attach static, per-procedure metadata. Merges across calls and is readable
86
+ * from middleware as `ctx.meta`.
68
87
  *
69
88
  * The point is policy that is DATA rather than a call: `.meta({ rateLimit:
70
- * "pins/create" })` can be walked to generate a rate-limit registry or docs,
71
- * where the same policy expressed only as `.use(rateLimit("pins/create"))`
72
- * can only be executed. Mirrors tRPC's `.meta()`.
89
+ * "pins/create" })` lets ONE generic middleware read the policy it is meant
90
+ * to enforce off `ctx.meta`, where the same policy expressed only as
91
+ * `.use(rateLimit("pins/create"))` has to be re-parameterised at every
92
+ * `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
93
+ * and deep-frozen: the same copy reaches every request, so it must not be
94
+ * mutable, and the object you passed stays yours (unfrozen). It must be
95
+ * structured-cloneable data — a function or class instance is rejected.
73
96
  */
74
97
  meta: (value: Record<string, unknown>) => QueryBuilder<Context, Args, Output>;
75
98
  output: <V extends Validator>(validator: V) => QueryBuilder<Context, Args, Infer<V>>;
@@ -105,7 +128,7 @@ interface QueryBuilder<Context, Args extends ArgsValidator, Output = undefined>
105
128
  ctx: Context;
106
129
  signal: AbortSignal;
107
130
  }) => AsyncGenerator<R, void, void> | AsyncIterable<R>, options?: StreamOptions) => RegisteredStream<Args, R> : never;
108
- use: <ContextOut>(middleware: Middleware<Context, ContextOut>) => QueryBuilder<ContextOut, Args, Output>;
131
+ use: <ContextOut>(middleware: Middleware<MiddlewareContext<Context, Args>, ContextOut>) => QueryBuilder<ContextOut, Args, Output>;
109
132
  /**
110
133
  * Mark this query as paid. The origin worker answers an unpaid client RPC
111
134
  * with HTTP 402, verifies + settles the x402 payment, then dispatches. `price`
@@ -125,14 +148,17 @@ interface MutationBuilder<Context, Args extends ArgsValidator, Output = undefine
125
148
  expose: (config: ExposeConfig) => MutationBuilder<Context, Args, Output>;
126
149
  input: <A extends ArgsValidator>(validators: A) => MutationBuilder<Context, A & Args, Output>;
127
150
  /**
128
- * Attach static, per-procedure metadata. Merges across calls, is readable
129
- * from middleware as `ctx.meta`, and is stamped onto the registration as
130
- * `fn.meta` so codegen and other tooling can enumerate it.
151
+ * Attach static, per-procedure metadata. Merges across calls and is readable
152
+ * from middleware as `ctx.meta`.
131
153
  *
132
154
  * The point is policy that is DATA rather than a call: `.meta({ rateLimit:
133
- * "pins/create" })` can be walked to generate a rate-limit registry or docs,
134
- * where the same policy expressed only as `.use(rateLimit("pins/create"))`
135
- * can only be executed. Mirrors tRPC's `.meta()`.
155
+ * "pins/create" })` lets ONE generic middleware read the policy it is meant
156
+ * to enforce off `ctx.meta`, where the same policy expressed only as
157
+ * `.use(rateLimit("pins/create"))` has to be re-parameterised at every
158
+ * `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
159
+ * and deep-frozen: the same copy reaches every request, so it must not be
160
+ * mutable, and the object you passed stays yours (unfrozen). It must be
161
+ * structured-cloneable data — a function or class instance is rejected.
136
162
  */
137
163
  meta: (value: Record<string, unknown>) => MutationBuilder<Context, Args, Output>;
138
164
  mutation: [Output] extends [undefined] ? <R>(handler: (options: {
@@ -143,7 +169,7 @@ interface MutationBuilder<Context, Args extends ArgsValidator, Output = undefine
143
169
  ctx: Context;
144
170
  }) => Output | Promise<Output>) => RegisteredMutation<Args, Output>;
145
171
  output: <V extends Validator>(validator: V) => MutationBuilder<Context, Args, Infer<V>>;
146
- use: <ContextOut>(middleware: Middleware<Context, ContextOut>) => MutationBuilder<ContextOut, Args, Output>;
172
+ use: <ContextOut>(middleware: Middleware<MiddlewareContext<Context, Args>, ContextOut>) => MutationBuilder<ContextOut, Args, Output>;
147
173
  /**
148
174
  * Mark this mutation as paid. The origin worker answers an unpaid client RPC
149
175
  * with HTTP 402, verifies + settles the x402 payment, then dispatches. `price`
@@ -170,18 +196,21 @@ interface ActionBuilder<Context, Args extends ArgsValidator, Output = undefined>
170
196
  expose: (config: ExposeConfig) => ActionBuilder<Context, Args, Output>;
171
197
  input: <A extends ArgsValidator>(validators: A) => ActionBuilder<Context, A & Args, Output>;
172
198
  /**
173
- * Attach static, per-procedure metadata. Merges across calls, is readable
174
- * from middleware as `ctx.meta`, and is stamped onto the registration as
175
- * `fn.meta` so codegen and other tooling can enumerate it.
199
+ * Attach static, per-procedure metadata. Merges across calls and is readable
200
+ * from middleware as `ctx.meta`.
176
201
  *
177
202
  * The point is policy that is DATA rather than a call: `.meta({ rateLimit:
178
- * "pins/create" })` can be walked to generate a rate-limit registry or docs,
179
- * where the same policy expressed only as `.use(rateLimit("pins/create"))`
180
- * can only be executed. Mirrors tRPC's `.meta()`.
203
+ * "pins/create" })` lets ONE generic middleware read the policy it is meant
204
+ * to enforce off `ctx.meta`, where the same policy expressed only as
205
+ * `.use(rateLimit("pins/create"))` has to be re-parameterised at every
206
+ * `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
207
+ * and deep-frozen: the same copy reaches every request, so it must not be
208
+ * mutable, and the object you passed stays yours (unfrozen). It must be
209
+ * structured-cloneable data — a function or class instance is rejected.
181
210
  */
182
211
  meta: (value: Record<string, unknown>) => ActionBuilder<Context, Args, Output>;
183
212
  output: <V extends Validator>(validator: V) => ActionBuilder<Context, Args, Infer<V>>;
184
- use: <ContextOut>(middleware: Middleware<Context, ContextOut>) => ActionBuilder<ContextOut, Args, Output>;
213
+ use: <ContextOut>(middleware: Middleware<MiddlewareContext<Context, Args>, ContextOut>) => ActionBuilder<ContextOut, Args, Output>;
185
214
  /**
186
215
  * Mark this action as paid. The origin worker answers an unpaid client RPC
187
216
  * with HTTP 402, verifies + settles the x402 payment, then dispatches. `price`
@@ -201,14 +230,17 @@ interface InternalQueryBuilder<Context, Args extends ArgsValidator, Output = und
201
230
  readonly __lunoraVisibility: "internal";
202
231
  input: <A extends ArgsValidator>(validators: A) => InternalQueryBuilder<Context, A & Args, Output>;
203
232
  /**
204
- * Attach static, per-procedure metadata. Merges across calls, is readable
205
- * from middleware as `ctx.meta`, and is stamped onto the registration as
206
- * `fn.meta` so codegen and other tooling can enumerate it.
233
+ * Attach static, per-procedure metadata. Merges across calls and is readable
234
+ * from middleware as `ctx.meta`.
207
235
  *
208
236
  * The point is policy that is DATA rather than a call: `.meta({ rateLimit:
209
- * "pins/create" })` can be walked to generate a rate-limit registry or docs,
210
- * where the same policy expressed only as `.use(rateLimit("pins/create"))`
211
- * can only be executed. Mirrors tRPC's `.meta()`.
237
+ * "pins/create" })` lets ONE generic middleware read the policy it is meant
238
+ * to enforce off `ctx.meta`, where the same policy expressed only as
239
+ * `.use(rateLimit("pins/create"))` has to be re-parameterised at every
240
+ * `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
241
+ * and deep-frozen: the same copy reaches every request, so it must not be
242
+ * mutable, and the object you passed stays yours (unfrozen). It must be
243
+ * structured-cloneable data — a function or class instance is rejected.
212
244
  */
213
245
  meta: (value: Record<string, unknown>) => InternalQueryBuilder<Context, Args, Output>;
214
246
  output: <V extends Validator>(validator: V) => InternalQueryBuilder<Context, Args, Infer<V>>;
@@ -225,21 +257,24 @@ interface InternalQueryBuilder<Context, Args extends ArgsValidator, Output = und
225
257
  ctx: Context;
226
258
  signal: AbortSignal;
227
259
  }) => AsyncGenerator<R, void, void> | AsyncIterable<R>, options?: StreamOptions) => RegisteredStream<Args, R>;
228
- use: <ContextOut>(middleware: Middleware<Context, ContextOut>) => InternalQueryBuilder<ContextOut, Args, Output>;
260
+ use: <ContextOut>(middleware: Middleware<MiddlewareContext<Context, Args>, ContextOut>) => InternalQueryBuilder<ContextOut, Args, Output>;
229
261
  }
230
262
  interface InternalMutationBuilder<Context, Args extends ArgsValidator, Output = undefined> {
231
263
  readonly __lunoraProcedure: "mutation";
232
264
  readonly __lunoraVisibility: "internal";
233
265
  input: <A extends ArgsValidator>(validators: A) => InternalMutationBuilder<Context, A & Args, Output>;
234
266
  /**
235
- * Attach static, per-procedure metadata. Merges across calls, is readable
236
- * from middleware as `ctx.meta`, and is stamped onto the registration as
237
- * `fn.meta` so codegen and other tooling can enumerate it.
267
+ * Attach static, per-procedure metadata. Merges across calls and is readable
268
+ * from middleware as `ctx.meta`.
238
269
  *
239
270
  * The point is policy that is DATA rather than a call: `.meta({ rateLimit:
240
- * "pins/create" })` can be walked to generate a rate-limit registry or docs,
241
- * where the same policy expressed only as `.use(rateLimit("pins/create"))`
242
- * can only be executed. Mirrors tRPC's `.meta()`.
271
+ * "pins/create" })` lets ONE generic middleware read the policy it is meant
272
+ * to enforce off `ctx.meta`, where the same policy expressed only as
273
+ * `.use(rateLimit("pins/create"))` has to be re-parameterised at every
274
+ * `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
275
+ * and deep-frozen: the same copy reaches every request, so it must not be
276
+ * mutable, and the object you passed stays yours (unfrozen). It must be
277
+ * structured-cloneable data — a function or class instance is rejected.
243
278
  */
244
279
  meta: (value: Record<string, unknown>) => InternalMutationBuilder<Context, Args, Output>;
245
280
  mutation: [Output] extends [undefined] ? <R>(handler: (options: {
@@ -250,7 +285,7 @@ interface InternalMutationBuilder<Context, Args extends ArgsValidator, Output =
250
285
  ctx: Context;
251
286
  }) => Output | Promise<Output>) => RegisteredMutation<Args, Output>;
252
287
  output: <V extends Validator>(validator: V) => InternalMutationBuilder<Context, Args, Infer<V>>;
253
- use: <ContextOut>(middleware: Middleware<Context, ContextOut>) => InternalMutationBuilder<ContextOut, Args, Output>;
288
+ use: <ContextOut>(middleware: Middleware<MiddlewareContext<Context, Args>, ContextOut>) => InternalMutationBuilder<ContextOut, Args, Output>;
254
289
  }
255
290
  interface InternalActionBuilder<Context, Args extends ArgsValidator, Output = undefined> {
256
291
  readonly __lunoraProcedure: "action";
@@ -264,18 +299,21 @@ interface InternalActionBuilder<Context, Args extends ArgsValidator, Output = un
264
299
  }) => Output | Promise<Output>) => RegisteredAction<Args, Output>;
265
300
  input: <A extends ArgsValidator>(validators: A) => InternalActionBuilder<Context, A & Args, Output>;
266
301
  /**
267
- * Attach static, per-procedure metadata. Merges across calls, is readable
268
- * from middleware as `ctx.meta`, and is stamped onto the registration as
269
- * `fn.meta` so codegen and other tooling can enumerate it.
302
+ * Attach static, per-procedure metadata. Merges across calls and is readable
303
+ * from middleware as `ctx.meta`.
270
304
  *
271
305
  * The point is policy that is DATA rather than a call: `.meta({ rateLimit:
272
- * "pins/create" })` can be walked to generate a rate-limit registry or docs,
273
- * where the same policy expressed only as `.use(rateLimit("pins/create"))`
274
- * can only be executed. Mirrors tRPC's `.meta()`.
306
+ * "pins/create" })` lets ONE generic middleware read the policy it is meant
307
+ * to enforce off `ctx.meta`, where the same policy expressed only as
308
+ * `.use(rateLimit("pins/create"))` has to be re-parameterised at every
309
+ * `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
310
+ * and deep-frozen: the same copy reaches every request, so it must not be
311
+ * mutable, and the object you passed stays yours (unfrozen). It must be
312
+ * structured-cloneable data — a function or class instance is rejected.
275
313
  */
276
314
  meta: (value: Record<string, unknown>) => InternalActionBuilder<Context, Args, Output>;
277
315
  output: <V extends Validator>(validator: V) => InternalActionBuilder<Context, Args, Infer<V>>;
278
- use: <ContextOut>(middleware: Middleware<Context, ContextOut>) => InternalActionBuilder<ContextOut, Args, Output>;
316
+ use: <ContextOut>(middleware: Middleware<MiddlewareContext<Context, Args>, ContextOut>) => InternalActionBuilder<ContextOut, Args, Output>;
279
317
  }
280
318
  /** The public root builders plus their `internal*` counterparts, returned by `.create()`. */
281
319
  interface LunoraBuilders {
@@ -1260,7 +1298,7 @@ interface EnvKeyFailure {
1260
1298
  *
1261
1299
  * Named export only (no default) per the repo export convention.
1262
1300
  */
1263
- declare class LunoraEnvError extends LunoraError$1 {
1301
+ declare class LunoraEnvError extends LunoraError {
1264
1302
  readonly failures: ReadonlyArray<EnvKeyFailure>;
1265
1303
  constructor(failures: ReadonlyArray<EnvKeyFailure>);
1266
1304
  }
@@ -1310,9 +1348,6 @@ interface EnvAccessor<S extends EnvShape> {
1310
1348
  * invalid — lazily on first access of that key, or eagerly via `config.parse(env)`.
1311
1349
  */
1312
1350
  declare const defineEnv: <S extends EnvShape>(shape: S) => EnvAccessor<S>;
1313
- declare class LunoraError extends LunoraError$1 {
1314
- constructor(code: LunoraErrorCode, message?: string, data?: unknown);
1315
- }
1316
1351
  /**
1317
1352
  * Minimal structural writer the facade binds over. Declared with **method**
1318
1353
  * syntax (not arrow properties) so a more-specifically-typed writer — both
@@ -3101,4 +3136,4 @@ interface StorageContextIn {
3101
3136
  }
3102
3137
  declare const storageRules: <Context extends StorageContextIn = StorageContextIn>(rules: ReadonlyArray<StorageRule<Context>>, options?: StorageRulesOptions) => Middleware<Context, Context>;
3103
3138
  declare const VERSION = "0.0.0";
3104
- export { DEFAULT_ACTION_CACHE_TTL_MS as ACTION_CACHE_DEFAULT_TTL_MS, ACTION_CACHE_TABLE, type ActionBuilder, type ActionCacheComponent, type ActionCacheContext, type ActionCacheDatabase, type ActionCacheFunctions, type ActionCtx, type AggregateIndexDefinition, type AggregateIndexOptions, type AggregateOp, type ArgsValidator, type Component, type ComponentFunctions, type CreateOptions, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_REDACTED_FIELDS as DOCUMENT_HISTORY_REDACTED_FIELDS, DOCUMENT_HISTORY_TABLE, type DataModelInit, type DeferredDeleteFlushResult, type DefineActionCacheOptions, type DefineComponentOptions, type DefineDocumentHistoryOptions, type DefineIdentityOptions, type DefineListArgsConfig, type DefinePluginOptions, type DefinePolicyInput, type DefinePresenceOptions, type DefineStorageRuleInput, type DocumentHistoryComponent, type DocumentHistoryEntry, type DocumentHistoryFunctions, type DurableObjectJurisdiction, type DurableStreamOptions, type EmptyArgs, type EnvAccessor, type EnvKeyFailure, type EnvShape, type ExposeConfig, type ExtendableSchema, type FacadeEntry, type FacadeWriterLike, type FunctionKind, type HttpActionCtx, type HttpActionHandler, type HttpMethod, type HttpRoute, type HttpRouteBuilder, type HttpRouteFactory, type HttpRouteHandlerOptions, type HttpStreamHandlerOptions, type IdentityContract, type IdentityRejectMode, type IdentityValidation, type IndexFieldsByTable, type InferArgs, type InferEnv, type InferIdentity, type InlineAggregateIndexOptions, type InlineRankIndexOptions, type InternalActionBuilder, type InternalMutationBuilder, type InternalQueryBuilder, type LifecycleEvent, type LifecycleHandler, type ListArgsSpec, type ListArgsValidators, type ListArgsValue, type ListFilterOperators, type ListOrderByEntry, type ListWhere, type LunoraBuilders, LunoraEnvError, LunoraError, type LunoraHttpApp, type LunoraHttpEnv, type LunoraRouteHandler, type ManyRelation, type MaskColumns, type MaskContext, type MaskFn, type MaskOptions, type MaskPolicies, type MaskRegistry, type MaskStrategy, type Middleware, type MiddlewareNext, type MigrationCtx, type MigrationDefinition, type MigrationDocument, type MigrationReader, type MigrationTransform, type MutationBuilder, type MutationCtx, type MutatorDefinition, type OnDeleteAction, type OneRelation, type OrmLike, DEFAULT_TTL_MS as PRESENCE_DEFAULT_TTL_MS, PRESENCE_TABLE, type Permission, type Plugin, type Policy, type PrefixedTables, type PresenceComponent, type PresenceFunctions, type PresenceMember, type ProtectPublicOptions, type QueryBuilder, type QueryCtx, type RankIndexDefinition, type RankIndexOptions, type ReactorHandler, type ReactorOutcome, type ReactorSelect, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMigration, type RegisteredMutation, type RegisteredMutator, type RegisteredQuery, type RegisteredReactor, type RegisteredShape, type RegisteredStream, type RelationBuilder, type RelationDefinition, type RlsOptions, type RlsReadRegistry, type Role, type Schema, type SchemaExtension, type ShapeDefinition, type ShapeReadWhereRequest, type ShardInitEvent, type ShardInitHandler, type StorageOperation, type StorageRule, type StorageRuleContext, type StorageRuleDecision, type StorageRulesOptions, type TableBuilder, type TableDefinition, type TerminalKind, type TriggerBuilder, type TriggerDefinition, type TypedDefinePolicyInput, VERSION, type VectorEmbedder, type VectorIndexDefinition, type VectorIndexOptions, type VectorMetric, type VectorizeOptions, type WhereInput, actionCacheExtension, allowAll, asBucketStorage, bindOrm, bindTableFacade, buildMaskRegistry, buildRlsReadRegistry, cacheKeyFor, clampLimit, composePluginMiddleware, composeShapeReadWhere, createPolicyDsl, createSecrets, defineActionCache, defineAggregateIndex, defineComponent, defineDocumentHistory, defineEnv, defineIdentity, defineListArgs, defineMigration, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, deny, documentHistoryExtension, flushDeferredDeletes, httpAction, httpRoute, httpRouter, indexFieldsFromSchema, initLunora, installPlugins, isDeny, isSafeHeaderValue, mask, mergeSchemaExtension, onConnect, onDisconnect, onQueryChange, onShardInit, presenceExtension, protectPublic, redactSecrets, rls, serveStorageObject, storageRules, toWhereInput, withDeferredDeletes };
3139
+ export { DEFAULT_ACTION_CACHE_TTL_MS as ACTION_CACHE_DEFAULT_TTL_MS, ACTION_CACHE_TABLE, type ActionBuilder, type ActionCacheComponent, type ActionCacheContext, type ActionCacheDatabase, type ActionCacheFunctions, type ActionCtx, type AggregateIndexDefinition, type AggregateIndexOptions, type AggregateOp, type ArgsValidator, type Component, type ComponentFunctions, type CreateOptions, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_REDACTED_FIELDS as DOCUMENT_HISTORY_REDACTED_FIELDS, DOCUMENT_HISTORY_TABLE, type DataModelInit, type DeferredDeleteFlushResult, type DefineActionCacheOptions, type DefineComponentOptions, type DefineDocumentHistoryOptions, type DefineIdentityOptions, type DefineListArgsConfig, type DefinePluginOptions, type DefinePolicyInput, type DefinePresenceOptions, type DefineStorageRuleInput, type DocumentHistoryComponent, type DocumentHistoryEntry, type DocumentHistoryFunctions, type DurableObjectJurisdiction, type DurableStreamOptions, type EmptyArgs, type EnvAccessor, type EnvKeyFailure, type EnvShape, type ExposeConfig, type ExtendableSchema, type FacadeEntry, type FacadeWriterLike, type FunctionKind, type HttpActionCtx, type HttpActionHandler, type HttpMethod, type HttpRoute, type HttpRouteBuilder, type HttpRouteFactory, type HttpRouteHandlerOptions, type HttpStreamHandlerOptions, type IdentityContract, type IdentityRejectMode, type IdentityValidation, type IndexFieldsByTable, type InferArgs, type InferEnv, type InferIdentity, type InlineAggregateIndexOptions, type InlineRankIndexOptions, type InternalActionBuilder, type InternalMutationBuilder, type InternalQueryBuilder, type LifecycleEvent, type LifecycleHandler, type ListArgsSpec, type ListArgsValidators, type ListArgsValue, type ListFilterOperators, type ListOrderByEntry, type ListWhere, type LunoraBuilders, LunoraEnvError, type LunoraHttpApp, type LunoraHttpEnv, type LunoraRouteHandler, type ManyRelation, type MaskColumns, type MaskContext, type MaskFn, type MaskOptions, type MaskPolicies, type MaskRegistry, type MaskStrategy, type Middleware, type MiddlewareContext, type MiddlewareNext, type MigrationCtx, type MigrationDefinition, type MigrationDocument, type MigrationReader, type MigrationTransform, type MutationBuilder, type MutationCtx, type MutatorDefinition, type OnDeleteAction, type OneRelation, type OrmLike, DEFAULT_TTL_MS as PRESENCE_DEFAULT_TTL_MS, PRESENCE_TABLE, type Permission, type Plugin, type Policy, type PrefixedTables, type PresenceComponent, type PresenceFunctions, type PresenceMember, type ProtectPublicOptions, type QueryBuilder, type QueryCtx, type RankIndexDefinition, type RankIndexOptions, type ReactorHandler, type ReactorOutcome, type ReactorSelect, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMigration, type RegisteredMutation, type RegisteredMutator, type RegisteredQuery, type RegisteredReactor, type RegisteredShape, type RegisteredStream, type RelationBuilder, type RelationDefinition, type RlsOptions, type RlsReadRegistry, type Role, type Schema, type SchemaExtension, type ShapeDefinition, type ShapeReadWhereRequest, type ShardInitEvent, type ShardInitHandler, type StorageOperation, type StorageRule, type StorageRuleContext, type StorageRuleDecision, type StorageRulesOptions, type TableBuilder, type TableDefinition, type TerminalKind, type TriggerBuilder, type TriggerDefinition, type TypedDefinePolicyInput, VERSION, type VectorEmbedder, type VectorIndexDefinition, type VectorIndexOptions, type VectorMetric, type VectorizeOptions, type WhereInput, actionCacheExtension, allowAll, asBucketStorage, bindOrm, bindTableFacade, buildMaskRegistry, buildRlsReadRegistry, cacheKeyFor, clampLimit, composePluginMiddleware, composeShapeReadWhere, createPolicyDsl, createSecrets, defineActionCache, defineAggregateIndex, defineComponent, defineDocumentHistory, defineEnv, defineIdentity, defineListArgs, defineMigration, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, deny, documentHistoryExtension, flushDeferredDeletes, httpAction, httpRoute, httpRouter, indexFieldsFromSchema, initLunora, installPlugins, isDeny, isSafeHeaderValue, mask, mergeSchemaExtension, onConnect, onDisconnect, onQueryChange, onShardInit, presenceExtension, protectPublic, redactSecrets, rls, serveStorageObject, storageRules, toWhereInput, withDeferredDeletes };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Validator, Infer, v, Id, ValidatorMap, InferValidatorMap, ColumnValidator } from '@lunora/values';
2
2
  export { type ColumnValidator, type GeoPoint, type Id, type Infer, ValidationError, type Validator, type ValidatorKind, v } from '@lunora/values';
3
3
  import { ArgsValidator, InferArgs, RegisteredAction, ExposeConfig, X402ProcedureConfig, ActionCtx, MutationCtx, RegisteredMutation, QueryCtx, RegisteredQuery, DurableStreamOptions, RegisteredStream, FunctionKind, TableDefinition, RegisteredFunction, VectorIndexDefinition, Schema, AggregateOp, GlobalBackend, RelationDefinition, OnDeleteAction, SearchLanguage, SearchStrategy, ExternalSourceDefinition, TriggerBuilder, TriggerDefinition, VectorEmbedder, VectorMetric, DurableObjectJurisdiction, AggregateIndexDefinition, RankIndexDefinition, Secrets, LifecycleEvent, ShardInitEvent, RegisteredLifecycleHook } from "./types.js";
4
- export { type AnyApi, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type IndexDefinition, type IndexRangeBuilder, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type MutationStorage, type PaginationOptions, type PaginationResult, type RankSortKey, type ReadOnlyStorage, type RestCacheConfig, type RunQueryOptions, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type SearchFilterBuilder, type SearchIndexDefinition, type ShardMode, type SpanEvaluation, type SpanHandle, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type StorageObjectHead, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerCtx, type TriggerDatabase, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorMatch, type VectorMatches, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowEventDefinition, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, anyApi } from "./types.js";
5
- import { LunoraError as LunoraError$1, LunoraErrorCode } from '@lunora/errors';
6
- export type { LunoraErrorCode } from '@lunora/errors';
4
+ export { type AnyApi, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type IndexDefinition, type IndexRangeBuilder, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type MutationStorage, type PaginationOptions, type PaginationResult, type RankSortKey, type ReadOnlyStorage, type RestCacheConfig, type RunQueryOptions, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type SearchFilterBuilder, type SearchIndexDefinition, type ShardMode, type SpanEvaluation, type SpanHandle, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type StorageObjectBody, type StorageObjectHead, type StorageRange, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerCtx, type TriggerDatabase, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorMatch, type VectorMatches, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowEventDefinition, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, anyApi } from "./types.js";
5
+ import { LunoraError } from '@lunora/errors';
6
+ export { LunoraError, type LunoraErrorCode } from '@lunora/errors';
7
7
  import { Context, Hono } from 'hono';
8
8
  import { WhereOperators, QueryArgs as QueryArgs$2 } from "./data-model.js";
9
9
  import { W as WhereInput, a as Policy, b as RlsOptions, c as Permission, R as Role, T as TypedDefinePolicyInput, D as DefinePolicyInput } from "./packem_shared/types.d-CdPDEjhz.js";
@@ -40,6 +40,26 @@ type Middleware<ContextIn, ContextOut> = (options: {
40
40
  ctx: ContextIn;
41
41
  next: MiddlewareNext<ContextIn>;
42
42
  }) => ContextOut | Promise<ContextOut>;
43
+ /**
44
+ * The context a `.use(...)` step actually receives: the procedure context plus
45
+ * `args`, the call's arguments as declared by `.input(...)` up to this point in
46
+ * the chain.
47
+ *
48
+ * A middleware that gates on the payload — a CAPTCHA token, a signup email —
49
+ * has nowhere else to read it from: the procedure context carries the resolved
50
+ * identity, not the request body. `args` is surfaced only AFTER the validators
51
+ * have run, and as a frozen shallow copy, so a middleware cannot rewrite what
52
+ * the handler is then handed.
53
+ *
54
+ * This is a PROCEDURE-builder surface. `httpAction` / `httpRoute` have no
55
+ * `.use()` chain at all (`HttpActionCtx` is not a builder context) — an HTTP
56
+ * handler reads its own `request` / `searchParams` / `body` and calls the
57
+ * underlying helper (`verifyTurnstile(...)`, `assertEmailAllowed(...)`) inline,
58
+ * or mounts a hono middleware.
59
+ */
60
+ type MiddlewareContext<Context, Args extends ArgsValidator> = Context & {
61
+ readonly args: Readonly<InferArgs<Args>>;
62
+ };
43
63
  /** Options accepted by `initLunora.dataModel<DM>().create(...)`. Reserved for transformer/error-formatter wiring. */
44
64
  type CreateOptions = Record<never, never>;
45
65
  /**
@@ -62,14 +82,17 @@ interface QueryBuilder<Context, Args extends ArgsValidator, Output = undefined>
62
82
  expose: (config: ExposeConfig) => QueryBuilder<Context, Args, Output>;
63
83
  input: <A extends ArgsValidator>(validators: A) => QueryBuilder<Context, A & Args, Output>;
64
84
  /**
65
- * Attach static, per-procedure metadata. Merges across calls, is readable
66
- * from middleware as `ctx.meta`, and is stamped onto the registration as
67
- * `fn.meta` so codegen and other tooling can enumerate it.
85
+ * Attach static, per-procedure metadata. Merges across calls and is readable
86
+ * from middleware as `ctx.meta`.
68
87
  *
69
88
  * The point is policy that is DATA rather than a call: `.meta({ rateLimit:
70
- * "pins/create" })` can be walked to generate a rate-limit registry or docs,
71
- * where the same policy expressed only as `.use(rateLimit("pins/create"))`
72
- * can only be executed. Mirrors tRPC's `.meta()`.
89
+ * "pins/create" })` lets ONE generic middleware read the policy it is meant
90
+ * to enforce off `ctx.meta`, where the same policy expressed only as
91
+ * `.use(rateLimit("pins/create"))` has to be re-parameterised at every
92
+ * `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
93
+ * and deep-frozen: the same copy reaches every request, so it must not be
94
+ * mutable, and the object you passed stays yours (unfrozen). It must be
95
+ * structured-cloneable data — a function or class instance is rejected.
73
96
  */
74
97
  meta: (value: Record<string, unknown>) => QueryBuilder<Context, Args, Output>;
75
98
  output: <V extends Validator>(validator: V) => QueryBuilder<Context, Args, Infer<V>>;
@@ -105,7 +128,7 @@ interface QueryBuilder<Context, Args extends ArgsValidator, Output = undefined>
105
128
  ctx: Context;
106
129
  signal: AbortSignal;
107
130
  }) => AsyncGenerator<R, void, void> | AsyncIterable<R>, options?: StreamOptions) => RegisteredStream<Args, R> : never;
108
- use: <ContextOut>(middleware: Middleware<Context, ContextOut>) => QueryBuilder<ContextOut, Args, Output>;
131
+ use: <ContextOut>(middleware: Middleware<MiddlewareContext<Context, Args>, ContextOut>) => QueryBuilder<ContextOut, Args, Output>;
109
132
  /**
110
133
  * Mark this query as paid. The origin worker answers an unpaid client RPC
111
134
  * with HTTP 402, verifies + settles the x402 payment, then dispatches. `price`
@@ -125,14 +148,17 @@ interface MutationBuilder<Context, Args extends ArgsValidator, Output = undefine
125
148
  expose: (config: ExposeConfig) => MutationBuilder<Context, Args, Output>;
126
149
  input: <A extends ArgsValidator>(validators: A) => MutationBuilder<Context, A & Args, Output>;
127
150
  /**
128
- * Attach static, per-procedure metadata. Merges across calls, is readable
129
- * from middleware as `ctx.meta`, and is stamped onto the registration as
130
- * `fn.meta` so codegen and other tooling can enumerate it.
151
+ * Attach static, per-procedure metadata. Merges across calls and is readable
152
+ * from middleware as `ctx.meta`.
131
153
  *
132
154
  * The point is policy that is DATA rather than a call: `.meta({ rateLimit:
133
- * "pins/create" })` can be walked to generate a rate-limit registry or docs,
134
- * where the same policy expressed only as `.use(rateLimit("pins/create"))`
135
- * can only be executed. Mirrors tRPC's `.meta()`.
155
+ * "pins/create" })` lets ONE generic middleware read the policy it is meant
156
+ * to enforce off `ctx.meta`, where the same policy expressed only as
157
+ * `.use(rateLimit("pins/create"))` has to be re-parameterised at every
158
+ * `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
159
+ * and deep-frozen: the same copy reaches every request, so it must not be
160
+ * mutable, and the object you passed stays yours (unfrozen). It must be
161
+ * structured-cloneable data — a function or class instance is rejected.
136
162
  */
137
163
  meta: (value: Record<string, unknown>) => MutationBuilder<Context, Args, Output>;
138
164
  mutation: [Output] extends [undefined] ? <R>(handler: (options: {
@@ -143,7 +169,7 @@ interface MutationBuilder<Context, Args extends ArgsValidator, Output = undefine
143
169
  ctx: Context;
144
170
  }) => Output | Promise<Output>) => RegisteredMutation<Args, Output>;
145
171
  output: <V extends Validator>(validator: V) => MutationBuilder<Context, Args, Infer<V>>;
146
- use: <ContextOut>(middleware: Middleware<Context, ContextOut>) => MutationBuilder<ContextOut, Args, Output>;
172
+ use: <ContextOut>(middleware: Middleware<MiddlewareContext<Context, Args>, ContextOut>) => MutationBuilder<ContextOut, Args, Output>;
147
173
  /**
148
174
  * Mark this mutation as paid. The origin worker answers an unpaid client RPC
149
175
  * with HTTP 402, verifies + settles the x402 payment, then dispatches. `price`
@@ -170,18 +196,21 @@ interface ActionBuilder<Context, Args extends ArgsValidator, Output = undefined>
170
196
  expose: (config: ExposeConfig) => ActionBuilder<Context, Args, Output>;
171
197
  input: <A extends ArgsValidator>(validators: A) => ActionBuilder<Context, A & Args, Output>;
172
198
  /**
173
- * Attach static, per-procedure metadata. Merges across calls, is readable
174
- * from middleware as `ctx.meta`, and is stamped onto the registration as
175
- * `fn.meta` so codegen and other tooling can enumerate it.
199
+ * Attach static, per-procedure metadata. Merges across calls and is readable
200
+ * from middleware as `ctx.meta`.
176
201
  *
177
202
  * The point is policy that is DATA rather than a call: `.meta({ rateLimit:
178
- * "pins/create" })` can be walked to generate a rate-limit registry or docs,
179
- * where the same policy expressed only as `.use(rateLimit("pins/create"))`
180
- * can only be executed. Mirrors tRPC's `.meta()`.
203
+ * "pins/create" })` lets ONE generic middleware read the policy it is meant
204
+ * to enforce off `ctx.meta`, where the same policy expressed only as
205
+ * `.use(rateLimit("pins/create"))` has to be re-parameterised at every
206
+ * `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
207
+ * and deep-frozen: the same copy reaches every request, so it must not be
208
+ * mutable, and the object you passed stays yours (unfrozen). It must be
209
+ * structured-cloneable data — a function or class instance is rejected.
181
210
  */
182
211
  meta: (value: Record<string, unknown>) => ActionBuilder<Context, Args, Output>;
183
212
  output: <V extends Validator>(validator: V) => ActionBuilder<Context, Args, Infer<V>>;
184
- use: <ContextOut>(middleware: Middleware<Context, ContextOut>) => ActionBuilder<ContextOut, Args, Output>;
213
+ use: <ContextOut>(middleware: Middleware<MiddlewareContext<Context, Args>, ContextOut>) => ActionBuilder<ContextOut, Args, Output>;
185
214
  /**
186
215
  * Mark this action as paid. The origin worker answers an unpaid client RPC
187
216
  * with HTTP 402, verifies + settles the x402 payment, then dispatches. `price`
@@ -201,14 +230,17 @@ interface InternalQueryBuilder<Context, Args extends ArgsValidator, Output = und
201
230
  readonly __lunoraVisibility: "internal";
202
231
  input: <A extends ArgsValidator>(validators: A) => InternalQueryBuilder<Context, A & Args, Output>;
203
232
  /**
204
- * Attach static, per-procedure metadata. Merges across calls, is readable
205
- * from middleware as `ctx.meta`, and is stamped onto the registration as
206
- * `fn.meta` so codegen and other tooling can enumerate it.
233
+ * Attach static, per-procedure metadata. Merges across calls and is readable
234
+ * from middleware as `ctx.meta`.
207
235
  *
208
236
  * The point is policy that is DATA rather than a call: `.meta({ rateLimit:
209
- * "pins/create" })` can be walked to generate a rate-limit registry or docs,
210
- * where the same policy expressed only as `.use(rateLimit("pins/create"))`
211
- * can only be executed. Mirrors tRPC's `.meta()`.
237
+ * "pins/create" })` lets ONE generic middleware read the policy it is meant
238
+ * to enforce off `ctx.meta`, where the same policy expressed only as
239
+ * `.use(rateLimit("pins/create"))` has to be re-parameterised at every
240
+ * `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
241
+ * and deep-frozen: the same copy reaches every request, so it must not be
242
+ * mutable, and the object you passed stays yours (unfrozen). It must be
243
+ * structured-cloneable data — a function or class instance is rejected.
212
244
  */
213
245
  meta: (value: Record<string, unknown>) => InternalQueryBuilder<Context, Args, Output>;
214
246
  output: <V extends Validator>(validator: V) => InternalQueryBuilder<Context, Args, Infer<V>>;
@@ -225,21 +257,24 @@ interface InternalQueryBuilder<Context, Args extends ArgsValidator, Output = und
225
257
  ctx: Context;
226
258
  signal: AbortSignal;
227
259
  }) => AsyncGenerator<R, void, void> | AsyncIterable<R>, options?: StreamOptions) => RegisteredStream<Args, R>;
228
- use: <ContextOut>(middleware: Middleware<Context, ContextOut>) => InternalQueryBuilder<ContextOut, Args, Output>;
260
+ use: <ContextOut>(middleware: Middleware<MiddlewareContext<Context, Args>, ContextOut>) => InternalQueryBuilder<ContextOut, Args, Output>;
229
261
  }
230
262
  interface InternalMutationBuilder<Context, Args extends ArgsValidator, Output = undefined> {
231
263
  readonly __lunoraProcedure: "mutation";
232
264
  readonly __lunoraVisibility: "internal";
233
265
  input: <A extends ArgsValidator>(validators: A) => InternalMutationBuilder<Context, A & Args, Output>;
234
266
  /**
235
- * Attach static, per-procedure metadata. Merges across calls, is readable
236
- * from middleware as `ctx.meta`, and is stamped onto the registration as
237
- * `fn.meta` so codegen and other tooling can enumerate it.
267
+ * Attach static, per-procedure metadata. Merges across calls and is readable
268
+ * from middleware as `ctx.meta`.
238
269
  *
239
270
  * The point is policy that is DATA rather than a call: `.meta({ rateLimit:
240
- * "pins/create" })` can be walked to generate a rate-limit registry or docs,
241
- * where the same policy expressed only as `.use(rateLimit("pins/create"))`
242
- * can only be executed. Mirrors tRPC's `.meta()`.
271
+ * "pins/create" })` lets ONE generic middleware read the policy it is meant
272
+ * to enforce off `ctx.meta`, where the same policy expressed only as
273
+ * `.use(rateLimit("pins/create"))` has to be re-parameterised at every
274
+ * `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
275
+ * and deep-frozen: the same copy reaches every request, so it must not be
276
+ * mutable, and the object you passed stays yours (unfrozen). It must be
277
+ * structured-cloneable data — a function or class instance is rejected.
243
278
  */
244
279
  meta: (value: Record<string, unknown>) => InternalMutationBuilder<Context, Args, Output>;
245
280
  mutation: [Output] extends [undefined] ? <R>(handler: (options: {
@@ -250,7 +285,7 @@ interface InternalMutationBuilder<Context, Args extends ArgsValidator, Output =
250
285
  ctx: Context;
251
286
  }) => Output | Promise<Output>) => RegisteredMutation<Args, Output>;
252
287
  output: <V extends Validator>(validator: V) => InternalMutationBuilder<Context, Args, Infer<V>>;
253
- use: <ContextOut>(middleware: Middleware<Context, ContextOut>) => InternalMutationBuilder<ContextOut, Args, Output>;
288
+ use: <ContextOut>(middleware: Middleware<MiddlewareContext<Context, Args>, ContextOut>) => InternalMutationBuilder<ContextOut, Args, Output>;
254
289
  }
255
290
  interface InternalActionBuilder<Context, Args extends ArgsValidator, Output = undefined> {
256
291
  readonly __lunoraProcedure: "action";
@@ -264,18 +299,21 @@ interface InternalActionBuilder<Context, Args extends ArgsValidator, Output = un
264
299
  }) => Output | Promise<Output>) => RegisteredAction<Args, Output>;
265
300
  input: <A extends ArgsValidator>(validators: A) => InternalActionBuilder<Context, A & Args, Output>;
266
301
  /**
267
- * Attach static, per-procedure metadata. Merges across calls, is readable
268
- * from middleware as `ctx.meta`, and is stamped onto the registration as
269
- * `fn.meta` so codegen and other tooling can enumerate it.
302
+ * Attach static, per-procedure metadata. Merges across calls and is readable
303
+ * from middleware as `ctx.meta`.
270
304
  *
271
305
  * The point is policy that is DATA rather than a call: `.meta({ rateLimit:
272
- * "pins/create" })` can be walked to generate a rate-limit registry or docs,
273
- * where the same policy expressed only as `.use(rateLimit("pins/create"))`
274
- * can only be executed. Mirrors tRPC's `.meta()`.
306
+ * "pins/create" })` lets ONE generic middleware read the policy it is meant
307
+ * to enforce off `ctx.meta`, where the same policy expressed only as
308
+ * `.use(rateLimit("pins/create"))` has to be re-parameterised at every
309
+ * `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
310
+ * and deep-frozen: the same copy reaches every request, so it must not be
311
+ * mutable, and the object you passed stays yours (unfrozen). It must be
312
+ * structured-cloneable data — a function or class instance is rejected.
275
313
  */
276
314
  meta: (value: Record<string, unknown>) => InternalActionBuilder<Context, Args, Output>;
277
315
  output: <V extends Validator>(validator: V) => InternalActionBuilder<Context, Args, Infer<V>>;
278
- use: <ContextOut>(middleware: Middleware<Context, ContextOut>) => InternalActionBuilder<ContextOut, Args, Output>;
316
+ use: <ContextOut>(middleware: Middleware<MiddlewareContext<Context, Args>, ContextOut>) => InternalActionBuilder<ContextOut, Args, Output>;
279
317
  }
280
318
  /** The public root builders plus their `internal*` counterparts, returned by `.create()`. */
281
319
  interface LunoraBuilders {
@@ -1260,7 +1298,7 @@ interface EnvKeyFailure {
1260
1298
  *
1261
1299
  * Named export only (no default) per the repo export convention.
1262
1300
  */
1263
- declare class LunoraEnvError extends LunoraError$1 {
1301
+ declare class LunoraEnvError extends LunoraError {
1264
1302
  readonly failures: ReadonlyArray<EnvKeyFailure>;
1265
1303
  constructor(failures: ReadonlyArray<EnvKeyFailure>);
1266
1304
  }
@@ -1310,9 +1348,6 @@ interface EnvAccessor<S extends EnvShape> {
1310
1348
  * invalid — lazily on first access of that key, or eagerly via `config.parse(env)`.
1311
1349
  */
1312
1350
  declare const defineEnv: <S extends EnvShape>(shape: S) => EnvAccessor<S>;
1313
- declare class LunoraError extends LunoraError$1 {
1314
- constructor(code: LunoraErrorCode, message?: string, data?: unknown);
1315
- }
1316
1351
  /**
1317
1352
  * Minimal structural writer the facade binds over. Declared with **method**
1318
1353
  * syntax (not arrow properties) so a more-specifically-typed writer — both
@@ -3101,4 +3136,4 @@ interface StorageContextIn {
3101
3136
  }
3102
3137
  declare const storageRules: <Context extends StorageContextIn = StorageContextIn>(rules: ReadonlyArray<StorageRule<Context>>, options?: StorageRulesOptions) => Middleware<Context, Context>;
3103
3138
  declare const VERSION = "0.0.0";
3104
- export { DEFAULT_ACTION_CACHE_TTL_MS as ACTION_CACHE_DEFAULT_TTL_MS, ACTION_CACHE_TABLE, type ActionBuilder, type ActionCacheComponent, type ActionCacheContext, type ActionCacheDatabase, type ActionCacheFunctions, type ActionCtx, type AggregateIndexDefinition, type AggregateIndexOptions, type AggregateOp, type ArgsValidator, type Component, type ComponentFunctions, type CreateOptions, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_REDACTED_FIELDS as DOCUMENT_HISTORY_REDACTED_FIELDS, DOCUMENT_HISTORY_TABLE, type DataModelInit, type DeferredDeleteFlushResult, type DefineActionCacheOptions, type DefineComponentOptions, type DefineDocumentHistoryOptions, type DefineIdentityOptions, type DefineListArgsConfig, type DefinePluginOptions, type DefinePolicyInput, type DefinePresenceOptions, type DefineStorageRuleInput, type DocumentHistoryComponent, type DocumentHistoryEntry, type DocumentHistoryFunctions, type DurableObjectJurisdiction, type DurableStreamOptions, type EmptyArgs, type EnvAccessor, type EnvKeyFailure, type EnvShape, type ExposeConfig, type ExtendableSchema, type FacadeEntry, type FacadeWriterLike, type FunctionKind, type HttpActionCtx, type HttpActionHandler, type HttpMethod, type HttpRoute, type HttpRouteBuilder, type HttpRouteFactory, type HttpRouteHandlerOptions, type HttpStreamHandlerOptions, type IdentityContract, type IdentityRejectMode, type IdentityValidation, type IndexFieldsByTable, type InferArgs, type InferEnv, type InferIdentity, type InlineAggregateIndexOptions, type InlineRankIndexOptions, type InternalActionBuilder, type InternalMutationBuilder, type InternalQueryBuilder, type LifecycleEvent, type LifecycleHandler, type ListArgsSpec, type ListArgsValidators, type ListArgsValue, type ListFilterOperators, type ListOrderByEntry, type ListWhere, type LunoraBuilders, LunoraEnvError, LunoraError, type LunoraHttpApp, type LunoraHttpEnv, type LunoraRouteHandler, type ManyRelation, type MaskColumns, type MaskContext, type MaskFn, type MaskOptions, type MaskPolicies, type MaskRegistry, type MaskStrategy, type Middleware, type MiddlewareNext, type MigrationCtx, type MigrationDefinition, type MigrationDocument, type MigrationReader, type MigrationTransform, type MutationBuilder, type MutationCtx, type MutatorDefinition, type OnDeleteAction, type OneRelation, type OrmLike, DEFAULT_TTL_MS as PRESENCE_DEFAULT_TTL_MS, PRESENCE_TABLE, type Permission, type Plugin, type Policy, type PrefixedTables, type PresenceComponent, type PresenceFunctions, type PresenceMember, type ProtectPublicOptions, type QueryBuilder, type QueryCtx, type RankIndexDefinition, type RankIndexOptions, type ReactorHandler, type ReactorOutcome, type ReactorSelect, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMigration, type RegisteredMutation, type RegisteredMutator, type RegisteredQuery, type RegisteredReactor, type RegisteredShape, type RegisteredStream, type RelationBuilder, type RelationDefinition, type RlsOptions, type RlsReadRegistry, type Role, type Schema, type SchemaExtension, type ShapeDefinition, type ShapeReadWhereRequest, type ShardInitEvent, type ShardInitHandler, type StorageOperation, type StorageRule, type StorageRuleContext, type StorageRuleDecision, type StorageRulesOptions, type TableBuilder, type TableDefinition, type TerminalKind, type TriggerBuilder, type TriggerDefinition, type TypedDefinePolicyInput, VERSION, type VectorEmbedder, type VectorIndexDefinition, type VectorIndexOptions, type VectorMetric, type VectorizeOptions, type WhereInput, actionCacheExtension, allowAll, asBucketStorage, bindOrm, bindTableFacade, buildMaskRegistry, buildRlsReadRegistry, cacheKeyFor, clampLimit, composePluginMiddleware, composeShapeReadWhere, createPolicyDsl, createSecrets, defineActionCache, defineAggregateIndex, defineComponent, defineDocumentHistory, defineEnv, defineIdentity, defineListArgs, defineMigration, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, deny, documentHistoryExtension, flushDeferredDeletes, httpAction, httpRoute, httpRouter, indexFieldsFromSchema, initLunora, installPlugins, isDeny, isSafeHeaderValue, mask, mergeSchemaExtension, onConnect, onDisconnect, onQueryChange, onShardInit, presenceExtension, protectPublic, redactSecrets, rls, serveStorageObject, storageRules, toWhereInput, withDeferredDeletes };
3139
+ export { DEFAULT_ACTION_CACHE_TTL_MS as ACTION_CACHE_DEFAULT_TTL_MS, ACTION_CACHE_TABLE, type ActionBuilder, type ActionCacheComponent, type ActionCacheContext, type ActionCacheDatabase, type ActionCacheFunctions, type ActionCtx, type AggregateIndexDefinition, type AggregateIndexOptions, type AggregateOp, type ArgsValidator, type Component, type ComponentFunctions, type CreateOptions, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_REDACTED_FIELDS as DOCUMENT_HISTORY_REDACTED_FIELDS, DOCUMENT_HISTORY_TABLE, type DataModelInit, type DeferredDeleteFlushResult, type DefineActionCacheOptions, type DefineComponentOptions, type DefineDocumentHistoryOptions, type DefineIdentityOptions, type DefineListArgsConfig, type DefinePluginOptions, type DefinePolicyInput, type DefinePresenceOptions, type DefineStorageRuleInput, type DocumentHistoryComponent, type DocumentHistoryEntry, type DocumentHistoryFunctions, type DurableObjectJurisdiction, type DurableStreamOptions, type EmptyArgs, type EnvAccessor, type EnvKeyFailure, type EnvShape, type ExposeConfig, type ExtendableSchema, type FacadeEntry, type FacadeWriterLike, type FunctionKind, type HttpActionCtx, type HttpActionHandler, type HttpMethod, type HttpRoute, type HttpRouteBuilder, type HttpRouteFactory, type HttpRouteHandlerOptions, type HttpStreamHandlerOptions, type IdentityContract, type IdentityRejectMode, type IdentityValidation, type IndexFieldsByTable, type InferArgs, type InferEnv, type InferIdentity, type InlineAggregateIndexOptions, type InlineRankIndexOptions, type InternalActionBuilder, type InternalMutationBuilder, type InternalQueryBuilder, type LifecycleEvent, type LifecycleHandler, type ListArgsSpec, type ListArgsValidators, type ListArgsValue, type ListFilterOperators, type ListOrderByEntry, type ListWhere, type LunoraBuilders, LunoraEnvError, type LunoraHttpApp, type LunoraHttpEnv, type LunoraRouteHandler, type ManyRelation, type MaskColumns, type MaskContext, type MaskFn, type MaskOptions, type MaskPolicies, type MaskRegistry, type MaskStrategy, type Middleware, type MiddlewareContext, type MiddlewareNext, type MigrationCtx, type MigrationDefinition, type MigrationDocument, type MigrationReader, type MigrationTransform, type MutationBuilder, type MutationCtx, type MutatorDefinition, type OnDeleteAction, type OneRelation, type OrmLike, DEFAULT_TTL_MS as PRESENCE_DEFAULT_TTL_MS, PRESENCE_TABLE, type Permission, type Plugin, type Policy, type PrefixedTables, type PresenceComponent, type PresenceFunctions, type PresenceMember, type ProtectPublicOptions, type QueryBuilder, type QueryCtx, type RankIndexDefinition, type RankIndexOptions, type ReactorHandler, type ReactorOutcome, type ReactorSelect, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMigration, type RegisteredMutation, type RegisteredMutator, type RegisteredQuery, type RegisteredReactor, type RegisteredShape, type RegisteredStream, type RelationBuilder, type RelationDefinition, type RlsOptions, type RlsReadRegistry, type Role, type Schema, type SchemaExtension, type ShapeDefinition, type ShapeReadWhereRequest, type ShardInitEvent, type ShardInitHandler, type StorageOperation, type StorageRule, type StorageRuleContext, type StorageRuleDecision, type StorageRulesOptions, type TableBuilder, type TableDefinition, type TerminalKind, type TriggerBuilder, type TriggerDefinition, type TypedDefinePolicyInput, VERSION, type VectorEmbedder, type VectorIndexDefinition, type VectorIndexOptions, type VectorMetric, type VectorizeOptions, type WhereInput, actionCacheExtension, allowAll, asBucketStorage, bindOrm, bindTableFacade, buildMaskRegistry, buildRlsReadRegistry, cacheKeyFor, clampLimit, composePluginMiddleware, composeShapeReadWhere, createPolicyDsl, createSecrets, defineActionCache, defineAggregateIndex, defineComponent, defineDocumentHistory, defineEnv, defineIdentity, defineListArgs, defineMigration, defineMutator, definePermission, definePlugin, definePolicies, definePolicy, definePresence, defineRankIndex, defineRole, defineSchema, defineSchemaExtension, defineShape, defineStorageRule, defineStorageRules, defineTable, defineVectorIndex, deny, documentHistoryExtension, flushDeferredDeletes, httpAction, httpRoute, httpRouter, indexFieldsFromSchema, initLunora, installPlugins, isDeny, isSafeHeaderValue, mask, mergeSchemaExtension, onConnect, onDisconnect, onQueryChange, onShardInit, presenceExtension, protectPublic, redactSecrets, rls, serveStorageObject, storageRules, toWhereInput, withDeferredDeletes };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{ACTION_CACHE_DEFAULT_TTL_MS as t,ACTION_CACHE_TABLE as n,actionCacheExtension as i,cacheKeyFor as a,defineActionCache as f}from"./packem_shared/ACTION_CACHE_DEFAULT_TTL_MS-BG6A6rHA.mjs";import{initLunora as m}from"./packem_shared/initLunora-BxNkWYTz.mjs";import{createSecrets as p}from"./packem_shared/createSecrets-CyrEddTF.mjs";import{flushDeferredDeletes as c,withDeferredDeletes as l}from"./packem_shared/flushDeferredDeletes-DEJXlhop.mjs";import{DOCUMENT_HISTORY_REDACTED_FIELDS as u,DOCUMENT_HISTORY_TABLE as S,defineDocumentHistory as T,documentHistoryExtension as h}from"./packem_shared/DOCUMENT_HISTORY_REDACTED_FIELDS-CXOIUOBE.mjs";import{LunoraEnvError as g,defineEnv as R,redactSecrets as _}from"./packem_shared/LunoraEnvError-_BakoYQ3.mjs";import{LunoraError as L}from"./packem_shared/LunoraError-DcKdk9Ti.mjs";import{bindOrm as I,bindTableFacade as y}from"./packem_shared/bindOrm-lWdeDi9P.mjs";import{httpAction as P,httpRoute as b,httpRouter as F,isSafeHeaderValue as O,serveStorageObject as H}from"./packem_shared/httpAction-DEN_78Kj.mjs";import{defineIdentity as U}from"./packem_shared/defineIdentity-DwkNKwYa.mjs";import{onConnect as v,onDisconnect as B,onShardInit as V}from"./packem_shared/onConnect-BLRoOpv2.mjs";import{DEFAULT_LIMIT as j,DEFAULT_MAX_LIMIT as W,clampLimit as Y,defineListArgs as J}from"./packem_shared/DEFAULT_LIMIT-DC-M6faS.mjs";import{defineMigration as Q}from"./packem_shared/defineMigration-7GI9Qbtd.mjs";import{defineMutator as q}from"./packem_shared/defineMutator-DKy8UtbB.mjs";import{c as G,d as Z,a as $,b as ee,e as oe,f as re,g as te,h as ne,i as ie,j as ae,k as fe,m as se}from"./packem_shared/plugin-DfuRhJS1.mjs";import{PRESENCE_DEFAULT_TTL_MS as de,PRESENCE_TABLE as pe,definePresence as xe,presenceExtension as ce}from"./packem_shared/PRESENCE_DEFAULT_TTL_MS-B6z9BcPN.mjs";import{protectPublic as Ee}from"./packem_shared/protectPublic-Bo4G9xaV.mjs";import{onQueryChange as Se}from"./packem_shared/onQueryChange-pRK6Dh3g.mjs";import{defineShape as he}from"./packem_shared/defineShape-DYxbNl5W.mjs";import{anyApi as ge}from"./types.mjs";import{cronJobs as _e}from"@lunora/scheduler";import{ValidationError as Le,v as Ce}from"@lunora/values";import{allowAll as ye,deny as Me,isDeny as Pe,toWhereInput as be}from"./packem_shared/allowAll-DkRAgItV.mjs";import{asBucketStorage as Oe}from"./packem_shared/asBucketStorage-BthCnWop.mjs";import{buildMaskRegistry as Ne}from"./packem_shared/buildMaskRegistry-72SL8fJn.mjs";import{buildRlsReadRegistry as ke,composeShapeReadWhere as ve}from"./packem_shared/buildRlsReadRegistry-Ct60PLD-.mjs";import{createPolicyDsl as Ve,definePermission as we,definePolicies as je,definePolicy as We,defineRole as Ye}from"./packem_shared/createPolicyDsl-DNfByAUX.mjs";import{defineStorageRule as Ke,defineStorageRules as Qe}from"./packem_shared/defineStorageRule-BvxHVq3b.mjs";import{mask as qe}from"./packem_shared/mask-NVloFLLY.mjs";import{r as Ge}from"./packem_shared/middleware-EloVU9X1.mjs";import{storageRules as $e}from"./packem_shared/storageRules-91NHMDL6.mjs";const e="0.0.0";export{t as ACTION_CACHE_DEFAULT_TTL_MS,n as ACTION_CACHE_TABLE,j as DEFAULT_LIMIT,W as DEFAULT_MAX_LIMIT,u as DOCUMENT_HISTORY_REDACTED_FIELDS,S as DOCUMENT_HISTORY_TABLE,g as LunoraEnvError,L as LunoraError,de as PRESENCE_DEFAULT_TTL_MS,pe as PRESENCE_TABLE,e as VERSION,Le as ValidationError,i as actionCacheExtension,ye as allowAll,ge as anyApi,Oe as asBucketStorage,I as bindOrm,y as bindTableFacade,Ne as buildMaskRegistry,ke as buildRlsReadRegistry,a as cacheKeyFor,Y as clampLimit,G as composePluginMiddleware,ve as composeShapeReadWhere,Ve as createPolicyDsl,p as createSecrets,_e as cronJobs,f as defineActionCache,Z as defineAggregateIndex,$ as defineComponent,T as defineDocumentHistory,R as defineEnv,U as defineIdentity,J as defineListArgs,Q as defineMigration,q as defineMutator,we as definePermission,ee as definePlugin,je as definePolicies,We as definePolicy,xe as definePresence,oe as defineRankIndex,Ye as defineRole,re as defineSchema,te as defineSchemaExtension,he as defineShape,Ke as defineStorageRule,Qe as defineStorageRules,ne as defineTable,ie as defineVectorIndex,Me as deny,h as documentHistoryExtension,c as flushDeferredDeletes,P as httpAction,b as httpRoute,F as httpRouter,ae as indexFieldsFromSchema,m as initLunora,fe as installPlugins,Pe as isDeny,O as isSafeHeaderValue,qe as mask,se as mergeSchemaExtension,v as onConnect,B as onDisconnect,Se as onQueryChange,V as onShardInit,ce as presenceExtension,Ee as protectPublic,_ as redactSecrets,Ge as rls,H as serveStorageObject,$e as storageRules,be as toWhereInput,Ce as v,l as withDeferredDeletes};
1
+ import{ACTION_CACHE_DEFAULT_TTL_MS as t,ACTION_CACHE_TABLE as n,actionCacheExtension as i,cacheKeyFor as a,defineActionCache as f}from"./packem_shared/ACTION_CACHE_DEFAULT_TTL_MS-OuQ-AJjz.mjs";import{initLunora as m}from"./packem_shared/initLunora-D5TSiy5j.mjs";import{createSecrets as p}from"./packem_shared/createSecrets-D6rLB42U.mjs";import{flushDeferredDeletes as c,withDeferredDeletes as l}from"./packem_shared/flushDeferredDeletes-DEJXlhop.mjs";import{DOCUMENT_HISTORY_REDACTED_FIELDS as u,DOCUMENT_HISTORY_TABLE as S,defineDocumentHistory as T,documentHistoryExtension as h}from"./packem_shared/DOCUMENT_HISTORY_REDACTED_FIELDS-wgfbacHx.mjs";import{LunoraEnvError as g,defineEnv as R,redactSecrets as _}from"./packem_shared/LunoraEnvError-CXbrsFI8.mjs";import{bindOrm as L,bindTableFacade as C}from"./packem_shared/bindOrm-ChQydkdL.mjs";import{httpAction as y,httpRoute as M,httpRouter as P,isSafeHeaderValue as b,serveStorageObject as F}from"./packem_shared/httpAction-B8X6jXen.mjs";import{defineIdentity as H}from"./packem_shared/defineIdentity-DwkNKwYa.mjs";import{onConnect as U,onDisconnect as k,onShardInit as v}from"./packem_shared/onConnect-BLRoOpv2.mjs";import{DEFAULT_LIMIT as V,DEFAULT_MAX_LIMIT as w,clampLimit as j,defineListArgs as W}from"./packem_shared/DEFAULT_LIMIT-DC-M6faS.mjs";import{defineMigration as J}from"./packem_shared/defineMigration-CXOS0Bvq.mjs";import{defineMutator as Q}from"./packem_shared/defineMutator-DKy8UtbB.mjs";import{c as q,d as z,a as G,b as Z,e as $,f as ee,g as oe,h as re,i as te,j as ne,k as ie,m as ae}from"./packem_shared/plugin-yKCbHnlj.mjs";import{PRESENCE_DEFAULT_TTL_MS as se,PRESENCE_TABLE as me,definePresence as de,presenceExtension as pe}from"./packem_shared/PRESENCE_DEFAULT_TTL_MS-lsooaSaF.mjs";import{protectPublic as ce}from"./packem_shared/protectPublic-Csf6ObbJ.mjs";import{onQueryChange as Ee}from"./packem_shared/onQueryChange-pRK6Dh3g.mjs";import{defineShape as Se}from"./packem_shared/defineShape-BWgwFuMT.mjs";import{anyApi as he}from"./types.mjs";import{LunoraError as ge}from"@lunora/errors";import{cronJobs as _e}from"@lunora/scheduler";import{ValidationError as Le,v as Ce}from"@lunora/values";import{allowAll as ye,deny as Me,isDeny as Pe,toWhereInput as be}from"./packem_shared/allowAll-DkRAgItV.mjs";import{asBucketStorage as Oe}from"./packem_shared/asBucketStorage-BthCnWop.mjs";import{buildMaskRegistry as Ne}from"./packem_shared/buildMaskRegistry-DpWMtalG.mjs";import{buildRlsReadRegistry as ke,composeShapeReadWhere as ve}from"./packem_shared/buildRlsReadRegistry-CIGmNx0b.mjs";import{createPolicyDsl as Ve,definePermission as we,definePolicies as je,definePolicy as We,defineRole as Ye}from"./packem_shared/createPolicyDsl-BZa6SqLJ.mjs";import{defineStorageRule as Ke,defineStorageRules as Qe}from"./packem_shared/defineStorageRule-Dv4nJE0H.mjs";import{mask as qe}from"./packem_shared/mask-pIhIWBcr.mjs";import{r as Ge}from"./packem_shared/middleware-Cz5s6CH-.mjs";import{storageRules as $e}from"./packem_shared/storageRules-DHvF6Fjq.mjs";const e="0.0.0";export{t as ACTION_CACHE_DEFAULT_TTL_MS,n as ACTION_CACHE_TABLE,V as DEFAULT_LIMIT,w as DEFAULT_MAX_LIMIT,u as DOCUMENT_HISTORY_REDACTED_FIELDS,S as DOCUMENT_HISTORY_TABLE,g as LunoraEnvError,ge as LunoraError,se as PRESENCE_DEFAULT_TTL_MS,me as PRESENCE_TABLE,e as VERSION,Le as ValidationError,i as actionCacheExtension,ye as allowAll,he as anyApi,Oe as asBucketStorage,L as bindOrm,C as bindTableFacade,Ne as buildMaskRegistry,ke as buildRlsReadRegistry,a as cacheKeyFor,j as clampLimit,q as composePluginMiddleware,ve as composeShapeReadWhere,Ve as createPolicyDsl,p as createSecrets,_e as cronJobs,f as defineActionCache,z as defineAggregateIndex,G as defineComponent,T as defineDocumentHistory,R as defineEnv,H as defineIdentity,W as defineListArgs,J as defineMigration,Q as defineMutator,we as definePermission,Z as definePlugin,je as definePolicies,We as definePolicy,de as definePresence,$ as defineRankIndex,Ye as defineRole,ee as defineSchema,oe as defineSchemaExtension,Se as defineShape,Ke as defineStorageRule,Qe as defineStorageRules,re as defineTable,te as defineVectorIndex,Me as deny,h as documentHistoryExtension,c as flushDeferredDeletes,y as httpAction,M as httpRoute,P as httpRouter,ne as indexFieldsFromSchema,m as initLunora,ie as installPlugins,Pe as isDeny,b as isSafeHeaderValue,qe as mask,ae as mergeSchemaExtension,U as onConnect,k as onDisconnect,Ee as onQueryChange,v as onShardInit,pe as presenceExtension,ce as protectPublic,_ as redactSecrets,Ge as rls,F as serveStorageObject,$e as storageRules,be as toWhereInput,Ce as v,l as withDeferredDeletes};