@lunora/server 1.0.0-alpha.94 → 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 +59 -44
- package/dist/index.d.ts +59 -44
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{ACTION_CACHE_DEFAULT_TTL_MS-BG6A6rHA.mjs → ACTION_CACHE_DEFAULT_TTL_MS-DZ4b4IoT.mjs} +1 -1
- package/dist/packem_shared/{DOCUMENT_HISTORY_REDACTED_FIELDS-CXOIUOBE.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 +2 -2
- package/dist/packem_shared/LunoraError-DcKdk9Ti.mjs +0 -1
- package/dist/packem_shared/PRESENCE_DEFAULT_TTL_MS-B6z9BcPN.mjs +0 -1
- package/dist/packem_shared/apply-output-D7vpBeeu.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-DEN_78Kj.mjs +0 -5
- package/dist/packem_shared/initLunora-BxNkWYTz.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>>;
|
|
@@ -125,14 +128,17 @@ interface MutationBuilder<Context, Args extends ArgsValidator, Output = undefine
|
|
|
125
128
|
expose: (config: ExposeConfig) => MutationBuilder<Context, Args, Output>;
|
|
126
129
|
input: <A extends ArgsValidator>(validators: A) => MutationBuilder<Context, A & Args, Output>;
|
|
127
130
|
/**
|
|
128
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
129
|
-
* from middleware as `ctx.meta
|
|
130
|
-
* `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`.
|
|
131
133
|
*
|
|
132
134
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
133
|
-
* "pins/create" })`
|
|
134
|
-
* where the same policy expressed only as
|
|
135
|
-
*
|
|
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.
|
|
136
142
|
*/
|
|
137
143
|
meta: (value: Record<string, unknown>) => MutationBuilder<Context, Args, Output>;
|
|
138
144
|
mutation: [Output] extends [undefined] ? <R>(handler: (options: {
|
|
@@ -170,14 +176,17 @@ interface ActionBuilder<Context, Args extends ArgsValidator, Output = undefined>
|
|
|
170
176
|
expose: (config: ExposeConfig) => ActionBuilder<Context, Args, Output>;
|
|
171
177
|
input: <A extends ArgsValidator>(validators: A) => ActionBuilder<Context, A & Args, Output>;
|
|
172
178
|
/**
|
|
173
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
174
|
-
* from middleware as `ctx.meta
|
|
175
|
-
* `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`.
|
|
176
181
|
*
|
|
177
182
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
178
|
-
* "pins/create" })`
|
|
179
|
-
* where the same policy expressed only as
|
|
180
|
-
*
|
|
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.
|
|
181
190
|
*/
|
|
182
191
|
meta: (value: Record<string, unknown>) => ActionBuilder<Context, Args, Output>;
|
|
183
192
|
output: <V extends Validator>(validator: V) => ActionBuilder<Context, Args, Infer<V>>;
|
|
@@ -201,14 +210,17 @@ interface InternalQueryBuilder<Context, Args extends ArgsValidator, Output = und
|
|
|
201
210
|
readonly __lunoraVisibility: "internal";
|
|
202
211
|
input: <A extends ArgsValidator>(validators: A) => InternalQueryBuilder<Context, A & Args, Output>;
|
|
203
212
|
/**
|
|
204
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
205
|
-
* from middleware as `ctx.meta
|
|
206
|
-
* `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`.
|
|
207
215
|
*
|
|
208
216
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
209
|
-
* "pins/create" })`
|
|
210
|
-
* where the same policy expressed only as
|
|
211
|
-
*
|
|
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.
|
|
212
224
|
*/
|
|
213
225
|
meta: (value: Record<string, unknown>) => InternalQueryBuilder<Context, Args, Output>;
|
|
214
226
|
output: <V extends Validator>(validator: V) => InternalQueryBuilder<Context, Args, Infer<V>>;
|
|
@@ -232,14 +244,17 @@ interface InternalMutationBuilder<Context, Args extends ArgsValidator, Output =
|
|
|
232
244
|
readonly __lunoraVisibility: "internal";
|
|
233
245
|
input: <A extends ArgsValidator>(validators: A) => InternalMutationBuilder<Context, A & Args, Output>;
|
|
234
246
|
/**
|
|
235
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
236
|
-
* from middleware as `ctx.meta
|
|
237
|
-
* `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`.
|
|
238
249
|
*
|
|
239
250
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
240
|
-
* "pins/create" })`
|
|
241
|
-
* where the same policy expressed only as
|
|
242
|
-
*
|
|
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.
|
|
243
258
|
*/
|
|
244
259
|
meta: (value: Record<string, unknown>) => InternalMutationBuilder<Context, Args, Output>;
|
|
245
260
|
mutation: [Output] extends [undefined] ? <R>(handler: (options: {
|
|
@@ -264,14 +279,17 @@ interface InternalActionBuilder<Context, Args extends ArgsValidator, Output = un
|
|
|
264
279
|
}) => Output | Promise<Output>) => RegisteredAction<Args, Output>;
|
|
265
280
|
input: <A extends ArgsValidator>(validators: A) => InternalActionBuilder<Context, A & Args, Output>;
|
|
266
281
|
/**
|
|
267
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
268
|
-
* from middleware as `ctx.meta
|
|
269
|
-
* `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`.
|
|
270
284
|
*
|
|
271
285
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
272
|
-
* "pins/create" })`
|
|
273
|
-
* where the same policy expressed only as
|
|
274
|
-
*
|
|
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.
|
|
275
293
|
*/
|
|
276
294
|
meta: (value: Record<string, unknown>) => InternalActionBuilder<Context, Args, Output>;
|
|
277
295
|
output: <V extends Validator>(validator: V) => InternalActionBuilder<Context, Args, Infer<V>>;
|
|
@@ -1260,7 +1278,7 @@ interface EnvKeyFailure {
|
|
|
1260
1278
|
*
|
|
1261
1279
|
* Named export only (no default) per the repo export convention.
|
|
1262
1280
|
*/
|
|
1263
|
-
declare class LunoraEnvError extends LunoraError
|
|
1281
|
+
declare class LunoraEnvError extends LunoraError {
|
|
1264
1282
|
readonly failures: ReadonlyArray<EnvKeyFailure>;
|
|
1265
1283
|
constructor(failures: ReadonlyArray<EnvKeyFailure>);
|
|
1266
1284
|
}
|
|
@@ -1310,9 +1328,6 @@ interface EnvAccessor<S extends EnvShape> {
|
|
|
1310
1328
|
* invalid — lazily on first access of that key, or eagerly via `config.parse(env)`.
|
|
1311
1329
|
*/
|
|
1312
1330
|
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
1331
|
/**
|
|
1317
1332
|
* Minimal structural writer the facade binds over. Declared with **method**
|
|
1318
1333
|
* syntax (not arrow properties) so a more-specifically-typed writer — both
|
|
@@ -3101,4 +3116,4 @@ interface StorageContextIn {
|
|
|
3101
3116
|
}
|
|
3102
3117
|
declare const storageRules: <Context extends StorageContextIn = StorageContextIn>(rules: ReadonlyArray<StorageRule<Context>>, options?: StorageRulesOptions) => Middleware<Context, Context>;
|
|
3103
3118
|
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,
|
|
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>>;
|
|
@@ -125,14 +128,17 @@ interface MutationBuilder<Context, Args extends ArgsValidator, Output = undefine
|
|
|
125
128
|
expose: (config: ExposeConfig) => MutationBuilder<Context, Args, Output>;
|
|
126
129
|
input: <A extends ArgsValidator>(validators: A) => MutationBuilder<Context, A & Args, Output>;
|
|
127
130
|
/**
|
|
128
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
129
|
-
* from middleware as `ctx.meta
|
|
130
|
-
* `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`.
|
|
131
133
|
*
|
|
132
134
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
133
|
-
* "pins/create" })`
|
|
134
|
-
* where the same policy expressed only as
|
|
135
|
-
*
|
|
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.
|
|
136
142
|
*/
|
|
137
143
|
meta: (value: Record<string, unknown>) => MutationBuilder<Context, Args, Output>;
|
|
138
144
|
mutation: [Output] extends [undefined] ? <R>(handler: (options: {
|
|
@@ -170,14 +176,17 @@ interface ActionBuilder<Context, Args extends ArgsValidator, Output = undefined>
|
|
|
170
176
|
expose: (config: ExposeConfig) => ActionBuilder<Context, Args, Output>;
|
|
171
177
|
input: <A extends ArgsValidator>(validators: A) => ActionBuilder<Context, A & Args, Output>;
|
|
172
178
|
/**
|
|
173
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
174
|
-
* from middleware as `ctx.meta
|
|
175
|
-
* `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`.
|
|
176
181
|
*
|
|
177
182
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
178
|
-
* "pins/create" })`
|
|
179
|
-
* where the same policy expressed only as
|
|
180
|
-
*
|
|
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.
|
|
181
190
|
*/
|
|
182
191
|
meta: (value: Record<string, unknown>) => ActionBuilder<Context, Args, Output>;
|
|
183
192
|
output: <V extends Validator>(validator: V) => ActionBuilder<Context, Args, Infer<V>>;
|
|
@@ -201,14 +210,17 @@ interface InternalQueryBuilder<Context, Args extends ArgsValidator, Output = und
|
|
|
201
210
|
readonly __lunoraVisibility: "internal";
|
|
202
211
|
input: <A extends ArgsValidator>(validators: A) => InternalQueryBuilder<Context, A & Args, Output>;
|
|
203
212
|
/**
|
|
204
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
205
|
-
* from middleware as `ctx.meta
|
|
206
|
-
* `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`.
|
|
207
215
|
*
|
|
208
216
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
209
|
-
* "pins/create" })`
|
|
210
|
-
* where the same policy expressed only as
|
|
211
|
-
*
|
|
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.
|
|
212
224
|
*/
|
|
213
225
|
meta: (value: Record<string, unknown>) => InternalQueryBuilder<Context, Args, Output>;
|
|
214
226
|
output: <V extends Validator>(validator: V) => InternalQueryBuilder<Context, Args, Infer<V>>;
|
|
@@ -232,14 +244,17 @@ interface InternalMutationBuilder<Context, Args extends ArgsValidator, Output =
|
|
|
232
244
|
readonly __lunoraVisibility: "internal";
|
|
233
245
|
input: <A extends ArgsValidator>(validators: A) => InternalMutationBuilder<Context, A & Args, Output>;
|
|
234
246
|
/**
|
|
235
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
236
|
-
* from middleware as `ctx.meta
|
|
237
|
-
* `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`.
|
|
238
249
|
*
|
|
239
250
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
240
|
-
* "pins/create" })`
|
|
241
|
-
* where the same policy expressed only as
|
|
242
|
-
*
|
|
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.
|
|
243
258
|
*/
|
|
244
259
|
meta: (value: Record<string, unknown>) => InternalMutationBuilder<Context, Args, Output>;
|
|
245
260
|
mutation: [Output] extends [undefined] ? <R>(handler: (options: {
|
|
@@ -264,14 +279,17 @@ interface InternalActionBuilder<Context, Args extends ArgsValidator, Output = un
|
|
|
264
279
|
}) => Output | Promise<Output>) => RegisteredAction<Args, Output>;
|
|
265
280
|
input: <A extends ArgsValidator>(validators: A) => InternalActionBuilder<Context, A & Args, Output>;
|
|
266
281
|
/**
|
|
267
|
-
* Attach static, per-procedure metadata. Merges across calls
|
|
268
|
-
* from middleware as `ctx.meta
|
|
269
|
-
* `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`.
|
|
270
284
|
*
|
|
271
285
|
* The point is policy that is DATA rather than a call: `.meta({ rateLimit:
|
|
272
|
-
* "pins/create" })`
|
|
273
|
-
* where the same policy expressed only as
|
|
274
|
-
*
|
|
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.
|
|
275
293
|
*/
|
|
276
294
|
meta: (value: Record<string, unknown>) => InternalActionBuilder<Context, Args, Output>;
|
|
277
295
|
output: <V extends Validator>(validator: V) => InternalActionBuilder<Context, Args, Infer<V>>;
|
|
@@ -1260,7 +1278,7 @@ interface EnvKeyFailure {
|
|
|
1260
1278
|
*
|
|
1261
1279
|
* Named export only (no default) per the repo export convention.
|
|
1262
1280
|
*/
|
|
1263
|
-
declare class LunoraEnvError extends LunoraError
|
|
1281
|
+
declare class LunoraEnvError extends LunoraError {
|
|
1264
1282
|
readonly failures: ReadonlyArray<EnvKeyFailure>;
|
|
1265
1283
|
constructor(failures: ReadonlyArray<EnvKeyFailure>);
|
|
1266
1284
|
}
|
|
@@ -1310,9 +1328,6 @@ interface EnvAccessor<S extends EnvShape> {
|
|
|
1310
1328
|
* invalid — lazily on first access of that key, or eagerly via `config.parse(env)`.
|
|
1311
1329
|
*/
|
|
1312
1330
|
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
1331
|
/**
|
|
1317
1332
|
* Minimal structural writer the facade binds over. Declared with **method**
|
|
1318
1333
|
* syntax (not arrow properties) so a more-specifically-typed writer — both
|
|
@@ -3101,4 +3116,4 @@ interface StorageContextIn {
|
|
|
3101
3116
|
}
|
|
3102
3117
|
declare const storageRules: <Context extends StorageContextIn = StorageContextIn>(rules: ReadonlyArray<StorageRule<Context>>, options?: StorageRulesOptions) => Middleware<Context, Context>;
|
|
3103
3118
|
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,
|
|
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LunoraError as h}from"@lunora/errors";const u=e=>typeof e=="object"&&e!==null&&e.code==="CONFLICT"&&e.kind==="unique",a=(e,t,
|
|
1
|
+
import{LunoraError as h}from"@lunora/errors";const u=e=>typeof e=="object"&&e!==null&&e.code==="CONFLICT"&&e.kind==="unique",a=(e,t,r)=>{const i=typeof t=="string"?[t]:t;if(i.length===0)throw new h("INTERNAL",`ctx.db.${e}.upsert: "target" must name at least one field`);const n={};for(const s of i){if(!(s in r))throw new h("INTERNAL",`ctx.db.${e}.upsert: target field "${s}" is missing from the create document`);n[s]=r[s]}return n},f=(e,t)=>{const r=async(n,s)=>{if(s?.skipDuplicates!==!0)return e.insert(t,n);try{return await e.insert(t,n)}catch(o){if(u(o))return null;throw o}},i=async({create:n,target:s,update:o})=>{const d=a(t,s,n),c=await e.findFirst(t,{where:d});return c&&typeof c._id=="string"?(await e.patch(c._id,o??n,t),{created:!1,id:c._id}):{created:!0,id:await e.insert(t,n)}};return{aggregate:n=>e.aggregate(t,n),count:n=>e.count(t,n),delete:n=>e.delete(n,t),deleteMany:(n,s)=>{if(Array.isArray(n)){if(e.deleteMany===void 0)throw new h("INTERNAL",`ctx.db.${t}.deleteMany is unavailable: this writer has no batch delete`);return e.deleteMany(n,s,t)}if(e.deleteWhere===void 0)throw new h("INTERNAL",`ctx.db.${t}.deleteMany({ where }) is unavailable: this writer has no where-based delete`);const o=n;return e.deleteWhere(t,o.where,{limit:o.limit})},exists:async n=>await e.findFirst(t,n===void 0?void 0:{where:n})!==null,findFirst:n=>e.findFirst(t,n),findFirstOrThrow:n=>e.findFirstOrThrow(t,n),findMany:n=>e.findMany(t,n),get:n=>e.get(n,t),groupBy:n=>e.groupBy(t,n),hardDelete:n=>e.delete(n,t,{hard:!0}),insert:r,insertMany:(n,s)=>{if(e.insertMany===void 0)throw new h("INTERNAL",`ctx.db.${t}.insertMany is unavailable: this writer has no batch insert`);return e.insertMany(t,n,s)},patch:(n,s)=>e.patch(n,s,t),patchMany:(n,s)=>{if(Array.isArray(n)){if(e.patchMany===void 0)throw new h("INTERNAL",`ctx.db.${t}.patchMany is unavailable: this writer has no batch patch`);return e.patchMany(n.map(d=>({id:d.id,patch:d.values})),s,t)}if(e.patchWhere===void 0)throw new h("INTERNAL",`ctx.db.${t}.patchMany({ where, values }) is unavailable: this writer has no where-based patch`);const o=n;return e.patchWhere(t,{patch:o.values,where:o.where},{limit:o.limit})},rank:(n,s)=>e.rank(t,n,s),rankPage:(n,s)=>e.rankPage(t,n,s),replace:(n,s)=>e.replace(n,s,t),restore:async n=>{if(!e.restore)throw new h("INTERNAL",`ctx.db.${t}.restore is unavailable: this writer has no restore (is the table .softDelete()?)`);await e.restore(n,t)},upsert:i,upsertMany:async({rows:n,target:s})=>{const o=[];for(const d of n)o.push(await i({create:d.create,target:s,update:d.update}));return o},withGeoIndex:(n,s)=>e.query(t).withGeoIndex(n,s),withSearchIndex:(n,s)=>e.query(t).withSearchIndex(n,s)}},l=e=>{const t=r=>{const i=e[r];if(!i)throw new h("INTERNAL",`unknown table: ${r}`);return i};return{delete:(r,i)=>t(r).delete(i),insert:r=>({values:i=>t(r).insert(i)}),query:e,replace:(r,i)=>({with:n=>t(r).replace(i,n)}),update:(r,i)=>({set:n=>t(r).patch(i,n)})}};export{l as bindOrm,f as bindTableFacade};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const u=Symbol.for("lunora.mask.middleware-columns"),l=(o,n)=>(Object.defineProperty(o,u,{configurable:!0,enumerable:!1,value:n}),o),f=o=>{if(!(o===null||typeof o!="function"&&typeof o!="object"))return o[u]},i=o=>{const n=new Map;for(const c of o){const t=f(c);if(t)for(const[e,r]of t.columns){const s=n.get(e)??new Set;for(const a of r)s.add(a);n.set(e,s)}}return n.size>0?n:void 0},b=o=>{const n=new Map;for(const c of o){const t=c?.maskedTables;if(t)for(const[e,r]of t){const s=n.get(e)??new Set;for(const a of r)s.add(a);n.set(e,s)}}return n};export{b as buildMaskRegistry,f as readMaskTag,l as tagMaskMiddleware,i as unionMaskColumns};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as d,c as f,d as h}from"./middleware-Cz5s6CH-.mjs";import{r as p}from"./policy-tag-V0lqFzgS.mjs";import{deny as u}from"./allowAll-DkRAgItV.mjs";const c=u(),g=s=>{const e=s?.rls?.tags;return e||p(s)},b=(s,e)=>{const r=d(e.roles),t=new Map,n=new Map;for(const o of e.policies){if(o.on!=="read")continue;const a=t.get(o.table)??new Set;if(a.has(o.when))continue;a.add(o.when),t.set(o.table,a);const i=n.get(o.table)??[];i.push(o),n.set(o.table,i)}for(const[o,a]of n){const i=s.get(o)??[];i.push({policies:a,rolePermissions:r}),s.set(o,i)}},l=s=>{const e=s.OR;return Array.isArray(e)&&e.length===0&&Object.keys(s).length===1},y=(s,e)=>!s||Object.keys(s).length===0?e:l(s)||Object.keys(e).length===0?s:{AND:[s,e]},R=(s,e)=>f(s.policies,{auth:{can:h(e.roles,s.rolePermissions),identity:e.identity,roles:e.roles,userId:e.userId},ctx:e.ctx}),m=(s,e)=>{const r=s.byTable.get(e.table);if(!r||r.length===0)return e.rlsRequired&&!e.tablePublic?c:void 0;const t=[];for(const n of r){const o=R(n,e);if(o===void 0)return;l(o)||t.push(o)}return t.length===0?c:t.length===1?t[0]:{OR:t}},P=s=>{const e=new Map,r=new Set;for(const t of s)for(const n of g(t))r.has(n)||(r.add(n),b(e,n));return{byTable:e}},W=(s,e)=>y(m(s,e),e.shapeWhere);export{P as buildRlsReadRegistry,W as composeShapeReadWhere};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{unionMaskColumns as n,tagMaskMiddleware as d}from"./buildMaskRegistry-DpWMtalG.mjs";import{r as m,t as i}from"./policy-tag-V0lqFzgS.mjs";import{r as c}from"./run-middleware-CuM-Chm3.mjs";const g=s=>{const o=(async({ctx:r,next:e})=>c(s,r,l=>e({ctx:l}))),a=s.flatMap(r=>m(r));a.length>0&&i(o,a);const t=n(s);return t&&d(o,{columns:t}),o};export{g as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./compose-middleware-3i5Qk3sb.mjs";import{c as i,a as s,b as o,g as m,k as l,m as t}from"./plugin-yKCbHnlj.mjs";export{i as composePluginMiddleware,s as defineComponent,o as definePlugin,m as defineSchemaExtension,l as installPlugins,t as mergeSchemaExtension};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as i}from"@lunora/errors";const c=e=>({on:e.on,table:e.table,when:e.when}),l=()=>e=>({on:e.on,table:e.table,when:e.when}),a=(e,n={})=>({name:e,...n}),d=e=>{const n=new Map;for(const o of e){const r=JSON.stringify([o.table,o.on]),t=n.get(r)??new Set;if(t.has(o.when))throw new i("INTERNAL",`definePolicies: duplicate policy for (table "${o.table}", on "${o.on}") — the same decision function is registered more than once. Multiple distinct policies per (table, on) are allowed (reads OR, writes AND); remove the duplicate.`);t.add(o.when),n.set(r,t)}return e},h=(e,n={})=>({name:e,...n});export{l as createPolicyDsl,a as definePermission,d as definePolicies,c as definePolicy,h as defineRole};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LunoraError as n}from"@lunora/errors";const o=["put","list","delete","getWithMetadata","head","createMultipartUpload","idFromName","newUniqueId","getByName","send","sendBatch","writeDataPoint","create","createBatch"],s=t=>{if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.get!="function"?!1:!o.some(r=>typeof e[r]=="function")},
|
|
1
|
+
import{LunoraError as n}from"@lunora/errors";const o=["put","list","delete","getWithMetadata","head","createMultipartUpload","idFromName","newUniqueId","getByName","send","sendBatch","writeDataPoint","create","createBatch"],s=t=>{if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.get!="function"?!1:!o.some(r=>typeof e[r]=="function")},i=t=>({get:async e=>{const r=t[e];if(!s(r))throw new n("INTERNAL",`ctx.secrets: no Secrets Store binding named "${e}". Add a \`secrets_store_secrets[]\` entry (binding "${e}", pointing at your store + secret) to wrangler.jsonc — \`ctx.secrets\` reads a Secrets Store binding, not a plain \`.dev.vars\` value.`);return r.get()}});export{i as createSecrets};
|
package/dist/packem_shared/{defineAggregateIndex-C3kWoQ-P.mjs → defineAggregateIndex-DFVCeuX1.mjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d,e as n,f as i,h as s,i as f,j as x,v as r}from"./plugin-
|
|
1
|
+
import{d,e as n,f as i,h as s,i as f,j as x,v as r}from"./plugin-yKCbHnlj.mjs";export{d as defineAggregateIndex,n as defineRankIndex,i as defineSchema,s as defineTable,f as defineVectorIndex,x as indexFieldsFromSchema,r as validateIndexFields};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as t}from"@lunora/errors";const n=r=>{if(r.id.trim()==="")throw new t("INTERNAL","defineMigration: `id` must be a non-empty string");return{__lunoraMigration:!0,...r}};export{n as defineMigration};
|