@lunora/server 1.0.0-alpha.93 → 1.0.0-alpha.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +69 -48
- package/dist/index.d.ts +69 -48
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{ACTION_CACHE_DEFAULT_TTL_MS-C16AYOi9.mjs → ACTION_CACHE_DEFAULT_TTL_MS-DZ4b4IoT.mjs} +1 -1
- package/dist/packem_shared/{DOCUMENT_HISTORY_REDACTED_FIELDS-BZxXxU_P.mjs → DOCUMENT_HISTORY_REDACTED_FIELDS-B5mE3zak.mjs} +1 -1
- package/dist/packem_shared/{LunoraEnvError-_BakoYQ3.mjs → LunoraEnvError-CXbrsFI8.mjs} +2 -2
- package/dist/packem_shared/PRESENCE_DEFAULT_TTL_MS-DSTJZMfc.mjs +1 -0
- package/dist/packem_shared/apply-output-C5wZ5EAL.mjs +1 -0
- package/dist/packem_shared/{bindOrm-lWdeDi9P.mjs → bindOrm-ChQydkdL.mjs} +1 -1
- package/dist/packem_shared/buildMaskRegistry-DpWMtalG.mjs +1 -0
- package/dist/packem_shared/buildRlsReadRegistry-CIGmNx0b.mjs +1 -0
- package/dist/packem_shared/compose-middleware-3i5Qk3sb.mjs +1 -0
- package/dist/packem_shared/composePluginMiddleware-pe7Ncehp.mjs +1 -0
- package/dist/packem_shared/createPolicyDsl-BZa6SqLJ.mjs +1 -0
- package/dist/packem_shared/{createSecrets-CyrEddTF.mjs → createSecrets-D6rLB42U.mjs} +1 -1
- package/dist/packem_shared/{defineAggregateIndex-C3kWoQ-P.mjs → defineAggregateIndex-DFVCeuX1.mjs} +1 -1
- package/dist/packem_shared/defineMigration-CXOS0Bvq.mjs +1 -0
- package/dist/packem_shared/{defineShape-DYxbNl5W.mjs → defineShape-BWgwFuMT.mjs} +1 -1
- package/dist/packem_shared/defineStorageRule-Dv4nJE0H.mjs +1 -0
- package/dist/packem_shared/httpAction-B8X6jXen.mjs +5 -0
- package/dist/packem_shared/initLunora-D8WltggT.mjs +1 -0
- package/dist/packem_shared/mask-pIhIWBcr.mjs +1 -0
- package/dist/packem_shared/middleware-Cz5s6CH-.mjs +1 -0
- package/dist/packem_shared/plugin-yKCbHnlj.mjs +1 -0
- package/dist/packem_shared/policy-tag-V0lqFzgS.mjs +1 -0
- package/dist/packem_shared/protectPublic-Csf6ObbJ.mjs +1 -0
- package/dist/packem_shared/rls-BjRa5pMm.mjs +1 -0
- package/dist/packem_shared/run-middleware-CuM-Chm3.mjs +1 -0
- package/dist/packem_shared/storageRules-DHvF6Fjq.mjs +1 -0
- package/dist/rls/testing.mjs +1 -1
- package/dist/types.d.mts +83 -22
- package/dist/types.d.ts +83 -22
- package/package.json +3 -3
- package/dist/packem_shared/LunoraError-DcKdk9Ti.mjs +0 -1
- package/dist/packem_shared/PRESENCE_DEFAULT_TTL_MS-B9-YC21L.mjs +0 -1
- package/dist/packem_shared/apply-output-BG8Bd0Ug.mjs +0 -1
- package/dist/packem_shared/buildMaskRegistry-72SL8fJn.mjs +0 -1
- package/dist/packem_shared/buildRlsReadRegistry-Ct60PLD-.mjs +0 -1
- package/dist/packem_shared/composePluginMiddleware-D8I_XMLV.mjs +0 -1
- package/dist/packem_shared/createPolicyDsl-DNfByAUX.mjs +0 -1
- package/dist/packem_shared/defineMigration-7GI9Qbtd.mjs +0 -1
- package/dist/packem_shared/defineStorageRule-BvxHVq3b.mjs +0 -1
- package/dist/packem_shared/httpAction-D3b9-YiY.mjs +0 -5
- package/dist/packem_shared/initLunora-B2sfmFJ6.mjs +0 -1
- package/dist/packem_shared/mask-NVloFLLY.mjs +0 -1
- package/dist/packem_shared/middleware-EloVU9X1.mjs +0 -1
- package/dist/packem_shared/plugin-DfuRhJS1.mjs +0 -1
- package/dist/packem_shared/policy-tag-D4RzgQnw.mjs +0 -1
- package/dist/packem_shared/protectPublic-Bo4G9xaV.mjs +0 -1
- package/dist/packem_shared/rls-B6du_B-q.mjs +0 -1
- package/dist/packem_shared/run-middleware-B-JeGGp9.mjs +0 -1
- package/dist/packem_shared/storageRules-91NHMDL6.mjs +0 -1
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
|
|
6
|
-
export type
|
|
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";
|
|
@@ -62,14 +62,17 @@ interface QueryBuilder<Context, Args extends ArgsValidator, Output = undefined>
|
|
|
62
62
|
expose: (config: ExposeConfig) => QueryBuilder<Context, Args, Output>;
|
|
63
63
|
input: <A extends ArgsValidator>(validators: A) => QueryBuilder<Context, A & Args, Output>;
|
|
64
64
|
/**
|
|
65
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
66
|
-
* from middleware as `ctx.meta
|
|
67
|
-
* `fn.meta` so codegen and other tooling can enumerate it.
|
|
65
|
+
* Attach static, per-procedure metadata. Merges across calls and is readable
|
|
66
|
+
* from middleware as `ctx.meta`.
|
|
68
67
|
*
|
|
69
68
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
70
|
-
* "pins/create" })`
|
|
71
|
-
* where the same policy expressed only as
|
|
72
|
-
*
|
|
69
|
+
* "pins/create" })` lets ONE generic middleware read the policy it is meant
|
|
70
|
+
* to enforce off `ctx.meta`, where the same policy expressed only as
|
|
71
|
+
* `.use(rateLimit("pins/create"))` has to be re-parameterised at every
|
|
72
|
+
* `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
|
|
73
|
+
* and deep-frozen: the same copy reaches every request, so it must not be
|
|
74
|
+
* mutable, and the object you passed stays yours (unfrozen). It must be
|
|
75
|
+
* structured-cloneable data — a function or class instance is rejected.
|
|
73
76
|
*/
|
|
74
77
|
meta: (value: Record<string, unknown>) => QueryBuilder<Context, Args, Output>;
|
|
75
78
|
output: <V extends Validator>(validator: V) => QueryBuilder<Context, Args, Infer<V>>;
|
|
@@ -85,8 +88,14 @@ interface QueryBuilder<Context, Args extends ArgsValidator, Output = undefined>
|
|
|
85
88
|
* async generator (or any function returning an `AsyncIterable<R>`) that
|
|
86
89
|
* yields one chunk per server-pushed frame. The third `signal` argument is
|
|
87
90
|
* tripped when the client cancels — break out of the loop or check
|
|
88
|
-
* `signal.aborted` between yields.
|
|
89
|
-
*
|
|
91
|
+
* `signal.aborted` between yields.
|
|
92
|
+
*
|
|
93
|
+
* **Unavailable after `.output()`, deliberately.** Chunks are yielded as-is —
|
|
94
|
+
* there is no per-chunk validation — so `.output(...).stream(...)` used to
|
|
95
|
+
* compile and quietly enforce nothing, which is worse than not offering the
|
|
96
|
+
* combination: the author asked for validation and was told yes. Declaring an
|
|
97
|
+
* output on a stream is now a type error rather than a false promise. Validate
|
|
98
|
+
* inside the handler, or return the whole payload from `.query()` instead.
|
|
90
99
|
*
|
|
91
100
|
* Pass `{ durable: true }` to make the run outlive the socket that opened
|
|
92
101
|
* it: chunks are persisted as they are produced, so a reload resumes the
|
|
@@ -94,11 +103,11 @@ interface QueryBuilder<Context, Args extends ArgsValidator, Output = undefined>
|
|
|
94
103
|
* second client with the same arguments attaches to the same transcript.
|
|
95
104
|
* That is what an LLM response wants; a progress ticker does not need it.
|
|
96
105
|
*/
|
|
97
|
-
stream: <R>(handler: (options: {
|
|
106
|
+
stream: [Output] extends [undefined] ? <R>(handler: (options: {
|
|
98
107
|
args: InferArgs<Args>;
|
|
99
108
|
ctx: Context;
|
|
100
109
|
signal: AbortSignal;
|
|
101
|
-
}) => AsyncGenerator<R, void, void> | AsyncIterable<R>, options?: StreamOptions) => RegisteredStream<Args, R
|
|
110
|
+
}) => AsyncGenerator<R, void, void> | AsyncIterable<R>, options?: StreamOptions) => RegisteredStream<Args, R> : never;
|
|
102
111
|
use: <ContextOut>(middleware: Middleware<Context, ContextOut>) => QueryBuilder<ContextOut, Args, Output>;
|
|
103
112
|
/**
|
|
104
113
|
* Mark this query as paid. The origin worker answers an unpaid client RPC
|
|
@@ -119,14 +128,17 @@ interface MutationBuilder<Context, Args extends ArgsValidator, Output = undefine
|
|
|
119
128
|
expose: (config: ExposeConfig) => MutationBuilder<Context, Args, Output>;
|
|
120
129
|
input: <A extends ArgsValidator>(validators: A) => MutationBuilder<Context, A & Args, Output>;
|
|
121
130
|
/**
|
|
122
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
123
|
-
* from middleware as `ctx.meta
|
|
124
|
-
* `fn.meta` so codegen and other tooling can enumerate it.
|
|
131
|
+
* Attach static, per-procedure metadata. Merges across calls and is readable
|
|
132
|
+
* from middleware as `ctx.meta`.
|
|
125
133
|
*
|
|
126
134
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
127
|
-
* "pins/create" })`
|
|
128
|
-
* where the same policy expressed only as
|
|
129
|
-
*
|
|
135
|
+
* "pins/create" })` lets ONE generic middleware read the policy it is meant
|
|
136
|
+
* to enforce off `ctx.meta`, where the same policy expressed only as
|
|
137
|
+
* `.use(rateLimit("pins/create"))` has to be re-parameterised at every
|
|
138
|
+
* `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
|
|
139
|
+
* and deep-frozen: the same copy reaches every request, so it must not be
|
|
140
|
+
* mutable, and the object you passed stays yours (unfrozen). It must be
|
|
141
|
+
* structured-cloneable data — a function or class instance is rejected.
|
|
130
142
|
*/
|
|
131
143
|
meta: (value: Record<string, unknown>) => MutationBuilder<Context, Args, Output>;
|
|
132
144
|
mutation: [Output] extends [undefined] ? <R>(handler: (options: {
|
|
@@ -164,14 +176,17 @@ interface ActionBuilder<Context, Args extends ArgsValidator, Output = undefined>
|
|
|
164
176
|
expose: (config: ExposeConfig) => ActionBuilder<Context, Args, Output>;
|
|
165
177
|
input: <A extends ArgsValidator>(validators: A) => ActionBuilder<Context, A & Args, Output>;
|
|
166
178
|
/**
|
|
167
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
168
|
-
* from middleware as `ctx.meta
|
|
169
|
-
* `fn.meta` so codegen and other tooling can enumerate it.
|
|
179
|
+
* Attach static, per-procedure metadata. Merges across calls and is readable
|
|
180
|
+
* from middleware as `ctx.meta`.
|
|
170
181
|
*
|
|
171
182
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
172
|
-
* "pins/create" })`
|
|
173
|
-
* where the same policy expressed only as
|
|
174
|
-
*
|
|
183
|
+
* "pins/create" })` lets ONE generic middleware read the policy it is meant
|
|
184
|
+
* to enforce off `ctx.meta`, where the same policy expressed only as
|
|
185
|
+
* `.use(rateLimit("pins/create"))` has to be re-parameterised at every
|
|
186
|
+
* `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
|
|
187
|
+
* and deep-frozen: the same copy reaches every request, so it must not be
|
|
188
|
+
* mutable, and the object you passed stays yours (unfrozen). It must be
|
|
189
|
+
* structured-cloneable data — a function or class instance is rejected.
|
|
175
190
|
*/
|
|
176
191
|
meta: (value: Record<string, unknown>) => ActionBuilder<Context, Args, Output>;
|
|
177
192
|
output: <V extends Validator>(validator: V) => ActionBuilder<Context, Args, Infer<V>>;
|
|
@@ -195,14 +210,17 @@ interface InternalQueryBuilder<Context, Args extends ArgsValidator, Output = und
|
|
|
195
210
|
readonly __lunoraVisibility: "internal";
|
|
196
211
|
input: <A extends ArgsValidator>(validators: A) => InternalQueryBuilder<Context, A & Args, Output>;
|
|
197
212
|
/**
|
|
198
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
199
|
-
* from middleware as `ctx.meta
|
|
200
|
-
* `fn.meta` so codegen and other tooling can enumerate it.
|
|
213
|
+
* Attach static, per-procedure metadata. Merges across calls and is readable
|
|
214
|
+
* from middleware as `ctx.meta`.
|
|
201
215
|
*
|
|
202
216
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
203
|
-
* "pins/create" })`
|
|
204
|
-
* where the same policy expressed only as
|
|
205
|
-
*
|
|
217
|
+
* "pins/create" })` lets ONE generic middleware read the policy it is meant
|
|
218
|
+
* to enforce off `ctx.meta`, where the same policy expressed only as
|
|
219
|
+
* `.use(rateLimit("pins/create"))` has to be re-parameterised at every
|
|
220
|
+
* `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
|
|
221
|
+
* and deep-frozen: the same copy reaches every request, so it must not be
|
|
222
|
+
* mutable, and the object you passed stays yours (unfrozen). It must be
|
|
223
|
+
* structured-cloneable data — a function or class instance is rejected.
|
|
206
224
|
*/
|
|
207
225
|
meta: (value: Record<string, unknown>) => InternalQueryBuilder<Context, Args, Output>;
|
|
208
226
|
output: <V extends Validator>(validator: V) => InternalQueryBuilder<Context, Args, Infer<V>>;
|
|
@@ -226,14 +244,17 @@ interface InternalMutationBuilder<Context, Args extends ArgsValidator, Output =
|
|
|
226
244
|
readonly __lunoraVisibility: "internal";
|
|
227
245
|
input: <A extends ArgsValidator>(validators: A) => InternalMutationBuilder<Context, A & Args, Output>;
|
|
228
246
|
/**
|
|
229
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
230
|
-
* from middleware as `ctx.meta
|
|
231
|
-
* `fn.meta` so codegen and other tooling can enumerate it.
|
|
247
|
+
* Attach static, per-procedure metadata. Merges across calls and is readable
|
|
248
|
+
* from middleware as `ctx.meta`.
|
|
232
249
|
*
|
|
233
250
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
234
|
-
* "pins/create" })`
|
|
235
|
-
* where the same policy expressed only as
|
|
236
|
-
*
|
|
251
|
+
* "pins/create" })` lets ONE generic middleware read the policy it is meant
|
|
252
|
+
* to enforce off `ctx.meta`, where the same policy expressed only as
|
|
253
|
+
* `.use(rateLimit("pins/create"))` has to be re-parameterised at every
|
|
254
|
+
* `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
|
|
255
|
+
* and deep-frozen: the same copy reaches every request, so it must not be
|
|
256
|
+
* mutable, and the object you passed stays yours (unfrozen). It must be
|
|
257
|
+
* structured-cloneable data — a function or class instance is rejected.
|
|
237
258
|
*/
|
|
238
259
|
meta: (value: Record<string, unknown>) => InternalMutationBuilder<Context, Args, Output>;
|
|
239
260
|
mutation: [Output] extends [undefined] ? <R>(handler: (options: {
|
|
@@ -258,14 +279,17 @@ interface InternalActionBuilder<Context, Args extends ArgsValidator, Output = un
|
|
|
258
279
|
}) => Output | Promise<Output>) => RegisteredAction<Args, Output>;
|
|
259
280
|
input: <A extends ArgsValidator>(validators: A) => InternalActionBuilder<Context, A & Args, Output>;
|
|
260
281
|
/**
|
|
261
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
262
|
-
* from middleware as `ctx.meta
|
|
263
|
-
* `fn.meta` so codegen and other tooling can enumerate it.
|
|
282
|
+
* Attach static, per-procedure metadata. Merges across calls and is readable
|
|
283
|
+
* from middleware as `ctx.meta`.
|
|
264
284
|
*
|
|
265
285
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
266
|
-
* "pins/create" })`
|
|
267
|
-
* where the same policy expressed only as
|
|
268
|
-
*
|
|
286
|
+
* "pins/create" })` lets ONE generic middleware read the policy it is meant
|
|
287
|
+
* to enforce off `ctx.meta`, where the same policy expressed only as
|
|
288
|
+
* `.use(rateLimit("pins/create"))` has to be re-parameterised at every
|
|
289
|
+
* `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
|
|
290
|
+
* and deep-frozen: the same copy reaches every request, so it must not be
|
|
291
|
+
* mutable, and the object you passed stays yours (unfrozen). It must be
|
|
292
|
+
* structured-cloneable data — a function or class instance is rejected.
|
|
269
293
|
*/
|
|
270
294
|
meta: (value: Record<string, unknown>) => InternalActionBuilder<Context, Args, Output>;
|
|
271
295
|
output: <V extends Validator>(validator: V) => InternalActionBuilder<Context, Args, Infer<V>>;
|
|
@@ -1254,7 +1278,7 @@ interface EnvKeyFailure {
|
|
|
1254
1278
|
*
|
|
1255
1279
|
* Named export only (no default) per the repo export convention.
|
|
1256
1280
|
*/
|
|
1257
|
-
declare class LunoraEnvError extends LunoraError
|
|
1281
|
+
declare class LunoraEnvError extends LunoraError {
|
|
1258
1282
|
readonly failures: ReadonlyArray<EnvKeyFailure>;
|
|
1259
1283
|
constructor(failures: ReadonlyArray<EnvKeyFailure>);
|
|
1260
1284
|
}
|
|
@@ -1304,9 +1328,6 @@ interface EnvAccessor<S extends EnvShape> {
|
|
|
1304
1328
|
* invalid — lazily on first access of that key, or eagerly via `config.parse(env)`.
|
|
1305
1329
|
*/
|
|
1306
1330
|
declare const defineEnv: <S extends EnvShape>(shape: S) => EnvAccessor<S>;
|
|
1307
|
-
declare class LunoraError extends LunoraError$1 {
|
|
1308
|
-
constructor(code: LunoraErrorCode, message?: string, data?: unknown);
|
|
1309
|
-
}
|
|
1310
1331
|
/**
|
|
1311
1332
|
* Minimal structural writer the facade binds over. Declared with **method**
|
|
1312
1333
|
* syntax (not arrow properties) so a more-specifically-typed writer — both
|
|
@@ -3095,4 +3116,4 @@ interface StorageContextIn {
|
|
|
3095
3116
|
}
|
|
3096
3117
|
declare const storageRules: <Context extends StorageContextIn = StorageContextIn>(rules: ReadonlyArray<StorageRule<Context>>, options?: StorageRulesOptions) => Middleware<Context, Context>;
|
|
3097
3118
|
declare const VERSION = "0.0.0";
|
|
3098
|
-
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,
|
|
3119
|
+
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 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
|
|
6
|
-
export type
|
|
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";
|
|
@@ -62,14 +62,17 @@ interface QueryBuilder<Context, Args extends ArgsValidator, Output = undefined>
|
|
|
62
62
|
expose: (config: ExposeConfig) => QueryBuilder<Context, Args, Output>;
|
|
63
63
|
input: <A extends ArgsValidator>(validators: A) => QueryBuilder<Context, A & Args, Output>;
|
|
64
64
|
/**
|
|
65
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
66
|
-
* from middleware as `ctx.meta
|
|
67
|
-
* `fn.meta` so codegen and other tooling can enumerate it.
|
|
65
|
+
* Attach static, per-procedure metadata. Merges across calls and is readable
|
|
66
|
+
* from middleware as `ctx.meta`.
|
|
68
67
|
*
|
|
69
68
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
70
|
-
* "pins/create" })`
|
|
71
|
-
* where the same policy expressed only as
|
|
72
|
-
*
|
|
69
|
+
* "pins/create" })` lets ONE generic middleware read the policy it is meant
|
|
70
|
+
* to enforce off `ctx.meta`, where the same policy expressed only as
|
|
71
|
+
* `.use(rateLimit("pins/create"))` has to be re-parameterised at every
|
|
72
|
+
* `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
|
|
73
|
+
* and deep-frozen: the same copy reaches every request, so it must not be
|
|
74
|
+
* mutable, and the object you passed stays yours (unfrozen). It must be
|
|
75
|
+
* structured-cloneable data — a function or class instance is rejected.
|
|
73
76
|
*/
|
|
74
77
|
meta: (value: Record<string, unknown>) => QueryBuilder<Context, Args, Output>;
|
|
75
78
|
output: <V extends Validator>(validator: V) => QueryBuilder<Context, Args, Infer<V>>;
|
|
@@ -85,8 +88,14 @@ interface QueryBuilder<Context, Args extends ArgsValidator, Output = undefined>
|
|
|
85
88
|
* async generator (or any function returning an `AsyncIterable<R>`) that
|
|
86
89
|
* yields one chunk per server-pushed frame. The third `signal` argument is
|
|
87
90
|
* tripped when the client cancels — break out of the loop or check
|
|
88
|
-
* `signal.aborted` between yields.
|
|
89
|
-
*
|
|
91
|
+
* `signal.aborted` between yields.
|
|
92
|
+
*
|
|
93
|
+
* **Unavailable after `.output()`, deliberately.** Chunks are yielded as-is —
|
|
94
|
+
* there is no per-chunk validation — so `.output(...).stream(...)` used to
|
|
95
|
+
* compile and quietly enforce nothing, which is worse than not offering the
|
|
96
|
+
* combination: the author asked for validation and was told yes. Declaring an
|
|
97
|
+
* output on a stream is now a type error rather than a false promise. Validate
|
|
98
|
+
* inside the handler, or return the whole payload from `.query()` instead.
|
|
90
99
|
*
|
|
91
100
|
* Pass `{ durable: true }` to make the run outlive the socket that opened
|
|
92
101
|
* it: chunks are persisted as they are produced, so a reload resumes the
|
|
@@ -94,11 +103,11 @@ interface QueryBuilder<Context, Args extends ArgsValidator, Output = undefined>
|
|
|
94
103
|
* second client with the same arguments attaches to the same transcript.
|
|
95
104
|
* That is what an LLM response wants; a progress ticker does not need it.
|
|
96
105
|
*/
|
|
97
|
-
stream: <R>(handler: (options: {
|
|
106
|
+
stream: [Output] extends [undefined] ? <R>(handler: (options: {
|
|
98
107
|
args: InferArgs<Args>;
|
|
99
108
|
ctx: Context;
|
|
100
109
|
signal: AbortSignal;
|
|
101
|
-
}) => AsyncGenerator<R, void, void> | AsyncIterable<R>, options?: StreamOptions) => RegisteredStream<Args, R
|
|
110
|
+
}) => AsyncGenerator<R, void, void> | AsyncIterable<R>, options?: StreamOptions) => RegisteredStream<Args, R> : never;
|
|
102
111
|
use: <ContextOut>(middleware: Middleware<Context, ContextOut>) => QueryBuilder<ContextOut, Args, Output>;
|
|
103
112
|
/**
|
|
104
113
|
* Mark this query as paid. The origin worker answers an unpaid client RPC
|
|
@@ -119,14 +128,17 @@ interface MutationBuilder<Context, Args extends ArgsValidator, Output = undefine
|
|
|
119
128
|
expose: (config: ExposeConfig) => MutationBuilder<Context, Args, Output>;
|
|
120
129
|
input: <A extends ArgsValidator>(validators: A) => MutationBuilder<Context, A & Args, Output>;
|
|
121
130
|
/**
|
|
122
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
123
|
-
* from middleware as `ctx.meta
|
|
124
|
-
* `fn.meta` so codegen and other tooling can enumerate it.
|
|
131
|
+
* Attach static, per-procedure metadata. Merges across calls and is readable
|
|
132
|
+
* from middleware as `ctx.meta`.
|
|
125
133
|
*
|
|
126
134
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
127
|
-
* "pins/create" })`
|
|
128
|
-
* where the same policy expressed only as
|
|
129
|
-
*
|
|
135
|
+
* "pins/create" })` lets ONE generic middleware read the policy it is meant
|
|
136
|
+
* to enforce off `ctx.meta`, where the same policy expressed only as
|
|
137
|
+
* `.use(rateLimit("pins/create"))` has to be re-parameterised at every
|
|
138
|
+
* `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
|
|
139
|
+
* and deep-frozen: the same copy reaches every request, so it must not be
|
|
140
|
+
* mutable, and the object you passed stays yours (unfrozen). It must be
|
|
141
|
+
* structured-cloneable data — a function or class instance is rejected.
|
|
130
142
|
*/
|
|
131
143
|
meta: (value: Record<string, unknown>) => MutationBuilder<Context, Args, Output>;
|
|
132
144
|
mutation: [Output] extends [undefined] ? <R>(handler: (options: {
|
|
@@ -164,14 +176,17 @@ interface ActionBuilder<Context, Args extends ArgsValidator, Output = undefined>
|
|
|
164
176
|
expose: (config: ExposeConfig) => ActionBuilder<Context, Args, Output>;
|
|
165
177
|
input: <A extends ArgsValidator>(validators: A) => ActionBuilder<Context, A & Args, Output>;
|
|
166
178
|
/**
|
|
167
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
168
|
-
* from middleware as `ctx.meta
|
|
169
|
-
* `fn.meta` so codegen and other tooling can enumerate it.
|
|
179
|
+
* Attach static, per-procedure metadata. Merges across calls and is readable
|
|
180
|
+
* from middleware as `ctx.meta`.
|
|
170
181
|
*
|
|
171
182
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
172
|
-
* "pins/create" })`
|
|
173
|
-
* where the same policy expressed only as
|
|
174
|
-
*
|
|
183
|
+
* "pins/create" })` lets ONE generic middleware read the policy it is meant
|
|
184
|
+
* to enforce off `ctx.meta`, where the same policy expressed only as
|
|
185
|
+
* `.use(rateLimit("pins/create"))` has to be re-parameterised at every
|
|
186
|
+
* `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
|
|
187
|
+
* and deep-frozen: the same copy reaches every request, so it must not be
|
|
188
|
+
* mutable, and the object you passed stays yours (unfrozen). It must be
|
|
189
|
+
* structured-cloneable data — a function or class instance is rejected.
|
|
175
190
|
*/
|
|
176
191
|
meta: (value: Record<string, unknown>) => ActionBuilder<Context, Args, Output>;
|
|
177
192
|
output: <V extends Validator>(validator: V) => ActionBuilder<Context, Args, Infer<V>>;
|
|
@@ -195,14 +210,17 @@ interface InternalQueryBuilder<Context, Args extends ArgsValidator, Output = und
|
|
|
195
210
|
readonly __lunoraVisibility: "internal";
|
|
196
211
|
input: <A extends ArgsValidator>(validators: A) => InternalQueryBuilder<Context, A & Args, Output>;
|
|
197
212
|
/**
|
|
198
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
199
|
-
* from middleware as `ctx.meta
|
|
200
|
-
* `fn.meta` so codegen and other tooling can enumerate it.
|
|
213
|
+
* Attach static, per-procedure metadata. Merges across calls and is readable
|
|
214
|
+
* from middleware as `ctx.meta`.
|
|
201
215
|
*
|
|
202
216
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
203
|
-
* "pins/create" })`
|
|
204
|
-
* where the same policy expressed only as
|
|
205
|
-
*
|
|
217
|
+
* "pins/create" })` lets ONE generic middleware read the policy it is meant
|
|
218
|
+
* to enforce off `ctx.meta`, where the same policy expressed only as
|
|
219
|
+
* `.use(rateLimit("pins/create"))` has to be re-parameterised at every
|
|
220
|
+
* `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
|
|
221
|
+
* and deep-frozen: the same copy reaches every request, so it must not be
|
|
222
|
+
* mutable, and the object you passed stays yours (unfrozen). It must be
|
|
223
|
+
* structured-cloneable data — a function or class instance is rejected.
|
|
206
224
|
*/
|
|
207
225
|
meta: (value: Record<string, unknown>) => InternalQueryBuilder<Context, Args, Output>;
|
|
208
226
|
output: <V extends Validator>(validator: V) => InternalQueryBuilder<Context, Args, Infer<V>>;
|
|
@@ -226,14 +244,17 @@ interface InternalMutationBuilder<Context, Args extends ArgsValidator, Output =
|
|
|
226
244
|
readonly __lunoraVisibility: "internal";
|
|
227
245
|
input: <A extends ArgsValidator>(validators: A) => InternalMutationBuilder<Context, A & Args, Output>;
|
|
228
246
|
/**
|
|
229
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
230
|
-
* from middleware as `ctx.meta
|
|
231
|
-
* `fn.meta` so codegen and other tooling can enumerate it.
|
|
247
|
+
* Attach static, per-procedure metadata. Merges across calls and is readable
|
|
248
|
+
* from middleware as `ctx.meta`.
|
|
232
249
|
*
|
|
233
250
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
234
|
-
* "pins/create" })`
|
|
235
|
-
* where the same policy expressed only as
|
|
236
|
-
*
|
|
251
|
+
* "pins/create" })` lets ONE generic middleware read the policy it is meant
|
|
252
|
+
* to enforce off `ctx.meta`, where the same policy expressed only as
|
|
253
|
+
* `.use(rateLimit("pins/create"))` has to be re-parameterised at every
|
|
254
|
+
* `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
|
|
255
|
+
* and deep-frozen: the same copy reaches every request, so it must not be
|
|
256
|
+
* mutable, and the object you passed stays yours (unfrozen). It must be
|
|
257
|
+
* structured-cloneable data — a function or class instance is rejected.
|
|
237
258
|
*/
|
|
238
259
|
meta: (value: Record<string, unknown>) => InternalMutationBuilder<Context, Args, Output>;
|
|
239
260
|
mutation: [Output] extends [undefined] ? <R>(handler: (options: {
|
|
@@ -258,14 +279,17 @@ interface InternalActionBuilder<Context, Args extends ArgsValidator, Output = un
|
|
|
258
279
|
}) => Output | Promise<Output>) => RegisteredAction<Args, Output>;
|
|
259
280
|
input: <A extends ArgsValidator>(validators: A) => InternalActionBuilder<Context, A & Args, Output>;
|
|
260
281
|
/**
|
|
261
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
262
|
-
* from middleware as `ctx.meta
|
|
263
|
-
* `fn.meta` so codegen and other tooling can enumerate it.
|
|
282
|
+
* Attach static, per-procedure metadata. Merges across calls and is readable
|
|
283
|
+
* from middleware as `ctx.meta`.
|
|
264
284
|
*
|
|
265
285
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
266
|
-
* "pins/create" })`
|
|
267
|
-
* where the same policy expressed only as
|
|
268
|
-
*
|
|
286
|
+
* "pins/create" })` lets ONE generic middleware read the policy it is meant
|
|
287
|
+
* to enforce off `ctx.meta`, where the same policy expressed only as
|
|
288
|
+
* `.use(rateLimit("pins/create"))` has to be re-parameterised at every
|
|
289
|
+
* `.use()` site. Mirrors tRPC's `.meta()`. The value is structured-cloned
|
|
290
|
+
* and deep-frozen: the same copy reaches every request, so it must not be
|
|
291
|
+
* mutable, and the object you passed stays yours (unfrozen). It must be
|
|
292
|
+
* structured-cloneable data — a function or class instance is rejected.
|
|
269
293
|
*/
|
|
270
294
|
meta: (value: Record<string, unknown>) => InternalActionBuilder<Context, Args, Output>;
|
|
271
295
|
output: <V extends Validator>(validator: V) => InternalActionBuilder<Context, Args, Infer<V>>;
|
|
@@ -1254,7 +1278,7 @@ interface EnvKeyFailure {
|
|
|
1254
1278
|
*
|
|
1255
1279
|
* Named export only (no default) per the repo export convention.
|
|
1256
1280
|
*/
|
|
1257
|
-
declare class LunoraEnvError extends LunoraError
|
|
1281
|
+
declare class LunoraEnvError extends LunoraError {
|
|
1258
1282
|
readonly failures: ReadonlyArray<EnvKeyFailure>;
|
|
1259
1283
|
constructor(failures: ReadonlyArray<EnvKeyFailure>);
|
|
1260
1284
|
}
|
|
@@ -1304,9 +1328,6 @@ interface EnvAccessor<S extends EnvShape> {
|
|
|
1304
1328
|
* invalid — lazily on first access of that key, or eagerly via `config.parse(env)`.
|
|
1305
1329
|
*/
|
|
1306
1330
|
declare const defineEnv: <S extends EnvShape>(shape: S) => EnvAccessor<S>;
|
|
1307
|
-
declare class LunoraError extends LunoraError$1 {
|
|
1308
|
-
constructor(code: LunoraErrorCode, message?: string, data?: unknown);
|
|
1309
|
-
}
|
|
1310
1331
|
/**
|
|
1311
1332
|
* Minimal structural writer the facade binds over. Declared with **method**
|
|
1312
1333
|
* syntax (not arrow properties) so a more-specifically-typed writer — both
|
|
@@ -3095,4 +3116,4 @@ interface StorageContextIn {
|
|
|
3095
3116
|
}
|
|
3096
3117
|
declare const storageRules: <Context extends StorageContextIn = StorageContextIn>(rules: ReadonlyArray<StorageRule<Context>>, options?: StorageRulesOptions) => Middleware<Context, Context>;
|
|
3097
3118
|
declare const VERSION = "0.0.0";
|
|
3098
|
-
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,
|
|
3119
|
+
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 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-
|
|
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-DZ4b4IoT.mjs";import{initLunora as m}from"./packem_shared/initLunora-D8WltggT.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-B5mE3zak.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-DSTJZMfc.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isLunoraError as S}from"@lunora/errors";import{v as d}from"@lunora/values";import{e as f,d as U}from"./wire-codec-hZHn-Ooo.mjs";import{s as D}from"./stable-key-B_BlboiY.mjs";import{initLunora as F}from"./initLunora-
|
|
1
|
+
import{isLunoraError as S}from"@lunora/errors";import{v as d}from"@lunora/values";import{e as f,d as U}from"./wire-codec-hZHn-Ooo.mjs";import{s as D}from"./stable-key-B_BlboiY.mjs";import{initLunora as F}from"./initLunora-D8WltggT.mjs";import{g as k,h as q,a as B}from"./plugin-yKCbHnlj.mjs";const P=i=>D(f(i)),R=3600*1e3,H=512*1024,V=8,b=64,K=64,W=256,$=4096,u="actionCache",h="entries",c=`${u}_${h}`,T=i=>i===void 0?"":P(i),x=async(i,m)=>{const A=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(`${i}\0${m}`));return[...new Uint8Array(A)].map(y=>y.toString(16).padStart(2,"0")).join("")},G=k(u,{tables:{[h]:q({expiresAt:d.number(),key:d.string(),name:d.string(),value:d.string()}).index("byKey",["key"],{unique:!0}).index("byName",["name"]).index("byExpiresAt",["expiresAt"])}}),{internalMutation:J}=F.dataModel().create(),te=(i={})=>{const m=i.ttlMs!==void 0&&Number.isFinite(i.ttlMs)?Math.max(1,Math.floor(i.ttlMs)):R,A=i.maxValueBytes!==void 0&&Number.isFinite(i.maxValueBytes)?Math.max(1,Math.floor(i.maxValueBytes)):H,y=async(e,t)=>{const n=(await e.db.query(c).withIndex("byExpiresAt").order("asc").take(V)).filter(r=>r.expiresAt<=t);await Promise.all(n.map(async r=>e.db.delete(r._id)))},C=async(e,t)=>e.db.query(c).withIndex("byKey",a=>a.eq("key",t)).first(),N=new Set(["CONFLICT","NOT_FOUND","NOT_UNIQUE"]),I=async(e,t,a)=>{try{await(t?e.db.patch(t._id,{expiresAt:a.expiresAt,value:a.value}):e.db.insert(c,a))}catch(n){if(S(n)&&N.has(n.code))return;throw n}},M=async(e,t,a,n)=>{const r=T(a),s=await x(t,r),l=Date.now(),o=await C(e,s);if(o&&o.expiresAt>l)return U(JSON.parse(o.value)).v;const p=await n(),w=JSON.stringify(f({v:p})),E=Date.now(),O=E+m;return new TextEncoder().encode(w).length<=A?await I(e,o,{expiresAt:O,key:s,name:t,value:w}):o&&await e.db.delete(o._id),await y(e,E),p},L=async(e,t,a)=>{const n=await x(t,T(a)),r=await e.db.query(c).withIndex("byKey",s=>s.eq("key",n)).take(b);await Promise.all(r.map(async s=>e.db.delete(s._id)))},_=async(e,t,a,n)=>{if(n>=K)return{complete:!1,deleted:a};const r=await e.db.query(c).withIndex("byName",s=>s.eq("name",t)).take(b);return r.length===0?{complete:!0,deleted:a}:(await Promise.all(r.map(async s=>e.db.delete(s._id))),_(e,t,a+r.length,n+1))},g=async(e,t)=>_(e,t,0,0),v=J.input({limit:d.optional(d.number())}).mutation(async({args:e,ctx:t})=>{const a=Date.now(),n=e.limit!==void 0&&Number.isFinite(e.limit)?Math.min($,Math.max(1,Math.floor(e.limit))):W,s=(await t.db.query(c).withIndex("byExpiresAt").order("asc").take(n)).filter(l=>l.expiresAt<=a);return await Promise.all(s.map(async l=>t.db.delete(l._id))),{deleted:s.length}});return{...B(u,{extension:G,functions:{purgeExpired:v}}),invalidate:L,invalidateAll:g,wrap:M}};export{R as ACTION_CACHE_DEFAULT_TTL_MS,c as ACTION_CACHE_TABLE,G as actionCacheExtension,x as cacheKeyFor,te as defineActionCache};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v as r}from"@lunora/values";import{d as A,e as h}from"./wire-codec-hZHn-Ooo.mjs";import{initLunora as v}from"./initLunora-
|
|
1
|
+
import{v as r}from"@lunora/values";import{d as A,e as h}from"./wire-codec-hZHn-Ooo.mjs";import{initLunora as v}from"./initLunora-D8WltggT.mjs";import{g as x,h as R,a as U}from"./plugin-yKCbHnlj.mjs";const H=2160*60*60*1e3,q=64*1024,E=200,C=64,F=512,y=16,L=["_commitSeq","seq"],B=["accessToken","apiKey","backupCodes","clientSecret","hashedPassword","password","privateKey","refreshToken","secret","totpSecret"],p="documentHistory",I="versions",l=`${p}_${I}`,P=x(p,{tables:{[I]:R({doc:r.optional(r.string()),documentId:r.string(),op:r.union(r.literal("delete"),r.literal("insert"),r.literal("update")),previous:r.optional(r.string()),recordedAt:r.number(),seq:r.number(),tableName:r.string(),truncated:r.optional(r.boolean())}).commitOrdered().index("byDocumentRecordedAt",["documentId","recordedAt","seq"]).index("byRecordedAt",["recordedAt"])}}),{internalMutation:Y,internalQuery:j}=v.dataModel().create(),X=(d={})=>{const T=d.retentionMs!==void 0&&Number.isFinite(d.retentionMs)?Math.max(1,Math.floor(d.retentionMs)):H,_=d.maxSnapshotBytes!==void 0&&Number.isFinite(d.maxSnapshotBytes)?Math.max(1,Math.floor(d.maxSnapshotBytes)):q,D=new Set([...B,...d.redact??[]]);let b=0;const M=()=>(b+=1,b),m=(e,t=0)=>{if(Array.isArray(e))return t>=y?void 0:e.map(o=>m(o,t+1));if(typeof e!="object"||e===null||Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)return e;if(!(t>=y))return Object.fromEntries(Object.entries(e).filter(([o])=>!D.has(o)).map(([o,i])=>[o,m(i,t+1)]))},f=e=>{if(e===void 0)return;const t=JSON.stringify(h(m(e)));return new TextEncoder().encode(t).length>_?void 0:t},u=async(e,t)=>{const o=f(t.doc),i=f(t.previous),n=t.doc!==void 0&&o===void 0||t.previous!==void 0&&i===void 0;await e.db.insert(l,{documentId:t.documentId,op:t.op,recordedAt:Date.now(),seq:M(),tableName:t.tableName,...n?{truncated:!0}:{},...o===void 0?{}:{doc:o},...i===void 0?{}:{previous:i}})},S=e=>({documentHistoryDelete:e.afterDelete(async(t,o)=>u(t,{documentId:o.id,op:"delete",previous:o.previous,tableName:o.table})),documentHistoryInsert:e.afterInsert(async(t,o)=>u(t,{doc:o.doc,documentId:o.id,op:"insert",tableName:o.table})),documentHistoryUpdate:e.afterUpdate(async(t,o)=>u(t,{doc:o.doc,documentId:o.id,op:"update",previous:o.previous,tableName:o.table}))}),N=j.input({before:r.optional(r.number()),documentId:r.string(),limit:r.optional(r.number())}).query(async({args:e,ctx:t})=>{const o=e.limit!==void 0&&Number.isFinite(e.limit)?Math.max(1,Math.floor(e.limit)):E,i=await t.db.query(l).withIndex("byDocumentRecordedAt",n=>e.before===void 0?n.eq("documentId",e.documentId):n.eq("documentId",e.documentId).lte("recordedAt",e.before)).order("desc").take(o);return i.sort((n,a)=>{for(const c of L){const s=(a[c]??0)-(n[c]??0);if(s!==0)return s}return 0}),i.map(n=>({documentId:n.documentId,op:n.op,recordedAt:n.recordedAt,tableName:n.tableName,...n.doc===void 0?{}:{doc:A(JSON.parse(n.doc))},...n.previous===void 0?{}:{previous:A(JSON.parse(n.previous))},...n.truncated===!0?{truncated:!0}:{}}))}),O=Y.input({limit:r.optional(r.number())}).mutation(async({args:e,ctx:t})=>{const o=Date.now()-T,i=e.limit!==void 0&&Number.isFinite(e.limit)?Math.max(1,Math.floor(e.limit)):F;let n=0;for(let a=0;a<C&&n<i;a+=1){const c=await t.db.query(l).withIndex("byRecordedAt",s=>s.lt("recordedAt",o)).order("asc").take(Math.min(E,i-n));if(c.length===0)return{deleted:n};await Promise.all(c.map(async s=>t.db.delete(s._id))),n+=c.length}return{deleted:n}});return{...U(p,{extension:P,functions:{listForDocument:N,vacuum:O}}),record:S}};export{B as DOCUMENT_HISTORY_REDACTED_FIELDS,l as DOCUMENT_HISTORY_TABLE,X as defineDocumentHistory,P as documentHistoryExtension};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{LunoraError as A}from"@lunora/errors";import{optionalInner as h}from"@lunora/values";const b=/(?:key|password|secret|token)$/iu,d=t=>b.test(t),
|
|
1
|
+
import{LunoraError as A}from"@lunora/errors";import{optionalInner as h}from"@lunora/values";const b=/(?:key|password|secret|token)$/iu,d=t=>b.test(t),w=[/^sk_/u,/^pk_/u,/^rk_/u,/^ghp_/u,/^gho_/u,/^ghs_/u,/^ghr_/u,/^github_pat_/u,/^xox[baprs]-/u,/^AKIA/u,/^AIza/u,/^Bearer\s/u],L=/[\w./+-]{24,}/gu,p=/^[\w./+-]+$/u,I=/\b(?:(?:sk|pk|rk|ghp|gho|ghs|ghr)_[\w./+-]*|github_pat_[\w./+-]*|xox[baprs]-[\w./+-]*)/gu,N=/\b(?:AKIA|AIza)[\w./+-]+|Bearer\s+[\w./+-]+/gu,v=/:\/\/([\w.%+-]*):[\w.%+-]+@/gu,a="[redacted]",D=t=>{if(w.some(n=>n.test(t)))return!0;const e=t.trim();return e.length>=24&&p.test(e)},S=/(["'])(?<inner>(?:\\.|(?!\1).)*)\1/gu,y=/\b(?<key>[A-Za-z_]\w*)\s*[=:]\s*\S+/gu,T=t=>{let e=t;return e=e.replaceAll(S,(n,...r)=>{const s=r.at(-1);return s?.inner!==void 0&&D(s.inner)?a:n}),e=e.replaceAll(v,(n,r)=>`://${r}:${a}@`),e=e.replaceAll(I,a),e=e.replaceAll(N,a),e=e.replaceAll(y,(n,...r)=>{const s=r.at(-1);return s?.key!==void 0&&d(s.key)?`${s.key}=${a}`:n}),e=e.replaceAll(L,a),e},R=(t,e,n)=>{const r=T(t);return typeof n=="string"&&n!==""&&d(e)?r.replaceAll(n,a):r};class g extends A{failures;constructor(e){const n=e.map(r=>` - ${r.key}: ${r.message}`).join(`
|
|
2
2
|
`);super("ENV_INVALID",`Invalid environment (${String(e.length)} key(s)):
|
|
3
|
-
${n}`,{name:"LunoraEnvError"}),this.failures=e}}const
|
|
3
|
+
${n}`,{name:"LunoraEnvError"}),this.failures=e}}const K=new Set(["1","on","true","yes"]),O=new Set(["0","false","no","off"]),$=/^-?\d+$/u,k=t=>{if(t.kind!=="optional")return t.kind;const e=h(t);return e?k(e):t.kind},U=(t,e)=>{if(typeof e!="string")return e;switch(k(t)){case"bigint":return $.test(e.trim())?BigInt(e.trim()):e;case"boolean":{const n=e.trim().toLowerCase();return K.has(n)?!0:O.has(n)?!1:e}case"number":{const n=e.trim();if(n==="")return e;const r=Number(n);return Number.isNaN(r)?e:r}default:return e}},_=(t,e,n,r)=>{const s=n[t];if(s===void 0&&e.kind==="optional")return{ok:!0,value:void 0};const c=e.safeParse(U(e,s));return c.ok?{ok:!0,value:c.value}:(r.push({key:t,message:R(c.error.message,t,s)}),{ok:!1})},m=t=>{if(typeof t!="object"||t===null)throw new g([{key:"<env>",message:`expected an object, received ${t===null?"null":typeof t}`}]);return t},F=t=>{const e=Object.keys(t),n=new WeakMap,r=(s=>{const c=m(s);let i=n.get(c);i===void 0&&(i=new Map,n.set(c,i));const l=i,E=u=>{if(l.has(u))return l.get(u);const o=[],f=_(u,t[u],c,o);if(!f.ok)throw new g(o);return l.set(u,f.value),f.value};return new Proxy({},{get(u,o){if(!(typeof o!="string"||!(o in t)))return E(o)},getOwnPropertyDescriptor(u,o){if(typeof o=="string"&&o in t)return{configurable:!0,enumerable:!0,value:E(o),writable:!1}},has(u,o){return typeof o=="string"&&o in t},ownKeys(){return e}})});return r.parse=s=>{const c=m(s),i=[],l={};for(const E of e){const u=_(E,t[E],c,i);u.ok&&u.value!==void 0&&(l[E]=u.value)}if(i.length>0)throw new g(i);return l},r};export{g as LunoraEnvError,F as defineEnv,T as redactSecrets};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as b}from"@lunora/errors";import{v as t}from"@lunora/values";import{initLunora as M}from"./initLunora-D8WltggT.mjs";import{onDisconnect as T}from"./onConnect-BLRoOpv2.mjs";import{g as v,h as A,a as L}from"./plugin-yKCbHnlj.mjs";const D=3e4,g=1024,P=8,p=4096,w="presence",h="present",l=`${w}_${h}`,N=v(w,{tables:{[h]:A({data:t.optional(t.record(t.string(),t.any())),lastSeen:t.number(),roomId:t.string(),sessionId:t.string(),userId:t.optional(t.string())}).index("byRoomSession",["roomId","sessionId"]).index("byRoom",["roomId"]).index("byRoomLastSeen",["roomId","lastSeen"])}}),{mutation:E,query:B}=M.dataModel().create(),G=(u={})=>{const m=u.ttlMs??D,f=Math.max(0,Math.min(u.disconnectGraceMs??0,m)),S=u.maxSessions,y=S!==void 0&&Number.isFinite(S)?Math.max(1,Math.floor(S)):g,_=E.input({data:t.optional(t.record(t.string(),t.any())),roomId:t.string(),sessionId:t.string()}).mutation(async({args:o,ctx:s})=>{const r=Date.now(),d=s.auth.userId??void 0;if(o.data!==void 0&&new TextEncoder().encode(JSON.stringify(o.data)).length>p)throw new b("BAD_REQUEST",`presence data exceeds the ${String(p)}-byte limit`);const e=await s.db.query(l).withIndex("byRoomSession",i=>i.eq("roomId",o.roomId).eq("sessionId",o.sessionId)).first();if(e&&(e.userId??void 0)!==d)throw new b("FORBIDDEN","presence heartbeat denied: this (roomId, sessionId) is held by another identity");const a={lastSeen:r,roomId:o.roomId,sessionId:o.sessionId,...o.data===void 0?{}:{data:o.data},...d===void 0?{}:{userId:d}};await(e?s.db.patch(e._id,a):s.db.insert(l,a));const I=r-m-Math.max(f,m),c=(await s.db.query(l).withIndex("byRoomLastSeen",i=>i.eq("roomId",o.roomId)).order("asc").take(P)).filter(i=>i.lastSeen<=I);return await Promise.all(c.map(i=>s.db.delete(i._id))),{lastSeen:r}}),x=B.input({roomId:t.string()}).query(async({args:o,ctx:s})=>{const r=Date.now()-m,e=(await s.db.query(l).withIndex("byRoomLastSeen",n=>n.eq("roomId",o.roomId)).order("desc").take(y)).filter(n=>n.lastSeen>r),a=new Set,I=[];for(const n of e){const c=n.userId;if(c!==void 0){if(a.has(c))continue;a.add(c)}const i={lastSeen:n.lastSeen,roomId:n.roomId};c!==void 0&&(i.userId=c),n.data!==void 0&&(i.data=n.data),I.push(i)}return I}),R={...E.input({roomId:t.string()}).mutation(async({args:o,ctx:s})=>{const r=Date.now()-m,d=await s.db.query(l).withIndex("byRoom",e=>e.eq("roomId",o.roomId)).filter(e=>e.lastSeen<=r).collect();return await Promise.all(d.map(e=>s.db.delete(e._id))),{deleted:d.length}}),visibility:"internal"},q=T(async(o,s)=>{const r=s.context?.roomId,d=s.context?.sessionId;if(typeof r!="string"||typeof d!="string")return;const e=await o.db.query(l).withIndex("byRoomSession",n=>n.eq("roomId",r).eq("sessionId",d)).first();if(!e)return;const a=s.userId??void 0;if((e.userId??void 0)!==a)return;if(f===0){await o.db.delete(e._id);return}const I=Math.min(e.lastSeen,Date.now()+f-m);await o.db.patch(e._id,{lastSeen:I})});return L(w,{extension:N,functions:{disconnect:q,heartbeat:_,listPresent:x,sweep:R}})};export{D as PRESENCE_DEFAULT_TTL_MS,l as PRESENCE_TABLE,G as definePresence,N as presenceExtension};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as o}from"@lunora/errors";import{ValidationError as a}from"@lunora/values";const p=(t,e)=>{try{return t.parse(e,{rejectUnknownKeys:!0})}catch(r){throw r instanceof a?new o("INTERNAL_SERVER_ERROR",`Response did not match the declared output schema: ${r.message}`):r}};export{p as a};
|