@lunora/server 1.0.0-alpha.60 → 1.0.0-alpha.62
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/data-model.d.mts +10 -10
- package/dist/data-model.d.ts +10 -10
- package/dist/index.d.mts +19 -19
- package/dist/index.d.ts +19 -19
- package/dist/packem_shared/{types.d-C4CMJK8x.d.mts → types.d-BXr-YW9j.d.mts} +1 -1
- package/dist/packem_shared/{types.d-DdYF8E18.d.ts → types.d-D6Lv3h_-.d.ts} +1 -1
- package/dist/rls/testing.d.mts +1 -1
- package/dist/rls/testing.d.ts +1 -1
- package/dist/types.d.mts +21 -21
- package/dist/types.d.ts +21 -21
- package/package.json +4 -4
package/dist/data-model.d.mts
CHANGED
|
@@ -93,7 +93,7 @@ type RelationWhere<DM, REL extends Record<keyof DM, object>, T extends keyof DM>
|
|
|
93
93
|
/**
|
|
94
94
|
* Relation-aware `where` tree — the column predicates of {@link Where} plus
|
|
95
95
|
* Prisma-style relation predicates resolved by the `@lunora/do` pre-resolver.
|
|
96
|
-
* `Where
|
|
96
|
+
* `Where<DM[T]>` stays the column-only structural mirror for back-compat; the
|
|
97
97
|
* table facade threads `REL` through this richer form.
|
|
98
98
|
*/
|
|
99
99
|
type WhereOf<DM, REL extends Record<keyof DM, object>, T extends keyof DM> = RelationWhere<DM, REL, T> & { [K in keyof DM[T]]?: DM[T][K] | WhereOperators<DM[T][K]>; } & {
|
|
@@ -176,7 +176,7 @@ type SelectAlwaysKeep<DM, T extends keyof DM> = ("_creationTime" | "_id") & keyo
|
|
|
176
176
|
*/
|
|
177
177
|
type ProjectDoc<DM, T extends keyof DM, S> = S extends ReadonlyArray<infer K> ? (K extends keyof DM[T] ? Pick<DM[T], (K & keyof DM[T]) | SelectAlwaysKeep<DM, T>> : DM[T]) : DM[T];
|
|
178
178
|
/**
|
|
179
|
-
* `Doc
|
|
179
|
+
* `Doc<T>` narrowed to exactly the relations requested in the with-arg `W` and,
|
|
180
180
|
* when a `select` tuple `S` is supplied, to its projected columns. `S` defaults
|
|
181
181
|
* to `undefined` so the 4-argument form (the codegen-emitted callers) keeps the
|
|
182
182
|
* full document.
|
|
@@ -207,7 +207,7 @@ interface RestrictableQueryOptionsOf<DM, REL extends Record<keyof DM, object>, T
|
|
|
207
207
|
restrictsCounts?: boolean;
|
|
208
208
|
where?: WhereOf<DM, REL, T>;
|
|
209
209
|
}
|
|
210
|
-
/** Args for `ctx.db
|
|
210
|
+
/** Args for `ctx.db.<table>.aggregate({ op, field?, where? })`. */
|
|
211
211
|
interface TableAggregateOptions<TDocument> extends RestrictableQueryOptions<TDocument> {
|
|
212
212
|
field?: keyof TDocument & string;
|
|
213
213
|
op: AggregateOp;
|
|
@@ -217,7 +217,7 @@ interface TableAggregateOptionsOf<DM, REL extends Record<keyof DM, object>, T ex
|
|
|
217
217
|
field?: keyof DM[T] & string;
|
|
218
218
|
op: AggregateOp;
|
|
219
219
|
}
|
|
220
|
-
/** Args for `ctx.db
|
|
220
|
+
/** Args for `ctx.db.<table>.groupBy({ by, agg?, where? })`. */
|
|
221
221
|
interface TableGroupByOptions<TDocument> extends RestrictableQueryOptions<TDocument> {
|
|
222
222
|
agg?: {
|
|
223
223
|
field?: keyof TDocument & string;
|
|
@@ -238,7 +238,7 @@ interface GroupByEntry<TDocument> {
|
|
|
238
238
|
key: Partial<TDocument>;
|
|
239
239
|
value: null | number;
|
|
240
240
|
}
|
|
241
|
-
/** Args for `ctx.db
|
|
241
|
+
/** Args for `ctx.db.<table>.rank(name, args)`. `row` is either an id or a row doc. */
|
|
242
242
|
interface TableRankOptions<TDocument> extends RestrictableQueryOptions<TDocument> {
|
|
243
243
|
row: string | TDocument;
|
|
244
244
|
}
|
|
@@ -247,7 +247,7 @@ interface RankResult {
|
|
|
247
247
|
position: number;
|
|
248
248
|
total: number;
|
|
249
249
|
}
|
|
250
|
-
/** Args for `ctx.db
|
|
250
|
+
/** Args for `ctx.db.<table>.rankPage(name, args)`. */
|
|
251
251
|
interface TableRankPageOptions<TDocument> extends RestrictableQueryOptions<TDocument> {
|
|
252
252
|
cursor?: null | string;
|
|
253
253
|
take?: number;
|
|
@@ -330,7 +330,7 @@ interface GeoReader<TDocument> {
|
|
|
330
330
|
take: (limit: number) => Promise<TDocument[]>;
|
|
331
331
|
unique: () => Promise<TDocument | null>;
|
|
332
332
|
}
|
|
333
|
-
/** Read-only typed table accessor exposed on `QueryCtx.db
|
|
333
|
+
/** Read-only typed table accessor exposed on `QueryCtx.db.<table>`. */
|
|
334
334
|
interface TableReaderFacade<DM, REL extends Record<keyof DM, object>, RANK extends Record<keyof DM, string>, SEARCH extends Record<keyof DM, string>, T extends keyof DM, GEO extends Record<keyof DM, string> = Record<keyof DM, never>> {
|
|
335
335
|
/**
|
|
336
336
|
* Reduce rows in this table to a scalar (`avg`/`max`/`min`/`sum` — `count`
|
|
@@ -395,7 +395,7 @@ interface TableReaderFacade<DM, REL extends Record<keyof DM, object>, RANK exten
|
|
|
395
395
|
*/
|
|
396
396
|
withSearchIndex: (indexName: SEARCH[T], search: (q: SearchFilterBuilder<DM[T]>) => SearchFilterBuilder<DM[T]>) => SearchReader<DM[T]>;
|
|
397
397
|
}
|
|
398
|
-
/** Read-write typed table accessor exposed on `MutationCtx.db
|
|
398
|
+
/** Read-write typed table accessor exposed on `MutationCtx.db.<table>` / `ActionCtx.db.<table>`. */
|
|
399
399
|
interface TableWriterFacade<DM, IM extends Record<keyof DM, object>, REL extends Record<keyof DM, object>, RANK extends Record<keyof DM, string>, SEARCH extends Record<keyof DM, string>, T extends keyof DM, GEO extends Record<keyof DM, string> = Record<keyof DM, never>> extends TableReaderFacade<DM, REL, RANK, SEARCH, T, GEO> {
|
|
400
400
|
/**
|
|
401
401
|
* Delete a row by id. On a `.softDelete()` table this flips the marker column
|
|
@@ -505,8 +505,8 @@ interface TableWriterFacade<DM, IM extends Record<keyof DM, object>, REL extends
|
|
|
505
505
|
}
|
|
506
506
|
/** Conflict target for `upsert`/`upsertMany`: one column of table `T`, or a tuple of them. */
|
|
507
507
|
type UpsertTargetOf<DM, T extends keyof DM> = ReadonlyArray<keyof DM[T] & string> | (keyof DM[T] & string);
|
|
508
|
-
/** Per-table read facade — `ctx.db
|
|
508
|
+
/** Per-table read facade — `ctx.db.<table>` on a `QueryCtx`. */
|
|
509
509
|
type DatabaseReaderFacade<DM, REL extends Record<keyof DM, object>, RANK extends Record<keyof DM, string>, SEARCH extends Record<keyof DM, string>, GEO extends Record<keyof DM, string> = Record<keyof DM, never>> = { readonly [T in keyof DM]: TableReaderFacade<DM, REL, RANK, SEARCH, T, GEO>; };
|
|
510
|
-
/** Per-table read-write facade — `ctx.db
|
|
510
|
+
/** Per-table read-write facade — `ctx.db.<table>` on a `MutationCtx` / `ActionCtx`. */
|
|
511
511
|
type DatabaseWriterFacade<DM, IM extends Record<keyof DM, object>, REL extends Record<keyof DM, object>, RANK extends Record<keyof DM, string>, SEARCH extends Record<keyof DM, string>, GEO extends Record<keyof DM, string> = Record<keyof DM, never>> = { readonly [T in keyof DM]: TableWriterFacade<DM, IM, REL, RANK, SEARCH, T, GEO>; };
|
|
512
512
|
export { AggregateOp, DatabaseReaderFacade, DatabaseWriterFacade, GeoBoundingBox, GeoFilterBuilder, GeoPointInput, GeoReader, GroupByEntry, Id, LoadWith, ManyRelationWhere, OneRelationWhere, OrderBy, QueryArgs, QueryArgsOf, QueryPage, RankPage, RankResult, RestrictableQueryOptions, RestrictableQueryOptionsOf, SearchFilterBuilder, SearchReader, TableAggregateOptions, TableAggregateOptionsOf, TableGroupByOptions, TableGroupByOptionsOf, TableRankOptions, TableRankPageOptions, TableReaderFacade, TableWriterFacade, UpsertTargetOf, Where, WhereOf, WhereOperators, WithArg };
|
package/dist/data-model.d.ts
CHANGED
|
@@ -93,7 +93,7 @@ type RelationWhere<DM, REL extends Record<keyof DM, object>, T extends keyof DM>
|
|
|
93
93
|
/**
|
|
94
94
|
* Relation-aware `where` tree — the column predicates of {@link Where} plus
|
|
95
95
|
* Prisma-style relation predicates resolved by the `@lunora/do` pre-resolver.
|
|
96
|
-
* `Where
|
|
96
|
+
* `Where<DM[T]>` stays the column-only structural mirror for back-compat; the
|
|
97
97
|
* table facade threads `REL` through this richer form.
|
|
98
98
|
*/
|
|
99
99
|
type WhereOf<DM, REL extends Record<keyof DM, object>, T extends keyof DM> = RelationWhere<DM, REL, T> & { [K in keyof DM[T]]?: DM[T][K] | WhereOperators<DM[T][K]>; } & {
|
|
@@ -176,7 +176,7 @@ type SelectAlwaysKeep<DM, T extends keyof DM> = ("_creationTime" | "_id") & keyo
|
|
|
176
176
|
*/
|
|
177
177
|
type ProjectDoc<DM, T extends keyof DM, S> = S extends ReadonlyArray<infer K> ? (K extends keyof DM[T] ? Pick<DM[T], (K & keyof DM[T]) | SelectAlwaysKeep<DM, T>> : DM[T]) : DM[T];
|
|
178
178
|
/**
|
|
179
|
-
* `Doc
|
|
179
|
+
* `Doc<T>` narrowed to exactly the relations requested in the with-arg `W` and,
|
|
180
180
|
* when a `select` tuple `S` is supplied, to its projected columns. `S` defaults
|
|
181
181
|
* to `undefined` so the 4-argument form (the codegen-emitted callers) keeps the
|
|
182
182
|
* full document.
|
|
@@ -207,7 +207,7 @@ interface RestrictableQueryOptionsOf<DM, REL extends Record<keyof DM, object>, T
|
|
|
207
207
|
restrictsCounts?: boolean;
|
|
208
208
|
where?: WhereOf<DM, REL, T>;
|
|
209
209
|
}
|
|
210
|
-
/** Args for `ctx.db
|
|
210
|
+
/** Args for `ctx.db.<table>.aggregate({ op, field?, where? })`. */
|
|
211
211
|
interface TableAggregateOptions<TDocument> extends RestrictableQueryOptions<TDocument> {
|
|
212
212
|
field?: keyof TDocument & string;
|
|
213
213
|
op: AggregateOp;
|
|
@@ -217,7 +217,7 @@ interface TableAggregateOptionsOf<DM, REL extends Record<keyof DM, object>, T ex
|
|
|
217
217
|
field?: keyof DM[T] & string;
|
|
218
218
|
op: AggregateOp;
|
|
219
219
|
}
|
|
220
|
-
/** Args for `ctx.db
|
|
220
|
+
/** Args for `ctx.db.<table>.groupBy({ by, agg?, where? })`. */
|
|
221
221
|
interface TableGroupByOptions<TDocument> extends RestrictableQueryOptions<TDocument> {
|
|
222
222
|
agg?: {
|
|
223
223
|
field?: keyof TDocument & string;
|
|
@@ -238,7 +238,7 @@ interface GroupByEntry<TDocument> {
|
|
|
238
238
|
key: Partial<TDocument>;
|
|
239
239
|
value: null | number;
|
|
240
240
|
}
|
|
241
|
-
/** Args for `ctx.db
|
|
241
|
+
/** Args for `ctx.db.<table>.rank(name, args)`. `row` is either an id or a row doc. */
|
|
242
242
|
interface TableRankOptions<TDocument> extends RestrictableQueryOptions<TDocument> {
|
|
243
243
|
row: string | TDocument;
|
|
244
244
|
}
|
|
@@ -247,7 +247,7 @@ interface RankResult {
|
|
|
247
247
|
position: number;
|
|
248
248
|
total: number;
|
|
249
249
|
}
|
|
250
|
-
/** Args for `ctx.db
|
|
250
|
+
/** Args for `ctx.db.<table>.rankPage(name, args)`. */
|
|
251
251
|
interface TableRankPageOptions<TDocument> extends RestrictableQueryOptions<TDocument> {
|
|
252
252
|
cursor?: null | string;
|
|
253
253
|
take?: number;
|
|
@@ -330,7 +330,7 @@ interface GeoReader<TDocument> {
|
|
|
330
330
|
take: (limit: number) => Promise<TDocument[]>;
|
|
331
331
|
unique: () => Promise<TDocument | null>;
|
|
332
332
|
}
|
|
333
|
-
/** Read-only typed table accessor exposed on `QueryCtx.db
|
|
333
|
+
/** Read-only typed table accessor exposed on `QueryCtx.db.<table>`. */
|
|
334
334
|
interface TableReaderFacade<DM, REL extends Record<keyof DM, object>, RANK extends Record<keyof DM, string>, SEARCH extends Record<keyof DM, string>, T extends keyof DM, GEO extends Record<keyof DM, string> = Record<keyof DM, never>> {
|
|
335
335
|
/**
|
|
336
336
|
* Reduce rows in this table to a scalar (`avg`/`max`/`min`/`sum` — `count`
|
|
@@ -395,7 +395,7 @@ interface TableReaderFacade<DM, REL extends Record<keyof DM, object>, RANK exten
|
|
|
395
395
|
*/
|
|
396
396
|
withSearchIndex: (indexName: SEARCH[T], search: (q: SearchFilterBuilder<DM[T]>) => SearchFilterBuilder<DM[T]>) => SearchReader<DM[T]>;
|
|
397
397
|
}
|
|
398
|
-
/** Read-write typed table accessor exposed on `MutationCtx.db
|
|
398
|
+
/** Read-write typed table accessor exposed on `MutationCtx.db.<table>` / `ActionCtx.db.<table>`. */
|
|
399
399
|
interface TableWriterFacade<DM, IM extends Record<keyof DM, object>, REL extends Record<keyof DM, object>, RANK extends Record<keyof DM, string>, SEARCH extends Record<keyof DM, string>, T extends keyof DM, GEO extends Record<keyof DM, string> = Record<keyof DM, never>> extends TableReaderFacade<DM, REL, RANK, SEARCH, T, GEO> {
|
|
400
400
|
/**
|
|
401
401
|
* Delete a row by id. On a `.softDelete()` table this flips the marker column
|
|
@@ -505,8 +505,8 @@ interface TableWriterFacade<DM, IM extends Record<keyof DM, object>, REL extends
|
|
|
505
505
|
}
|
|
506
506
|
/** Conflict target for `upsert`/`upsertMany`: one column of table `T`, or a tuple of them. */
|
|
507
507
|
type UpsertTargetOf<DM, T extends keyof DM> = ReadonlyArray<keyof DM[T] & string> | (keyof DM[T] & string);
|
|
508
|
-
/** Per-table read facade — `ctx.db
|
|
508
|
+
/** Per-table read facade — `ctx.db.<table>` on a `QueryCtx`. */
|
|
509
509
|
type DatabaseReaderFacade<DM, REL extends Record<keyof DM, object>, RANK extends Record<keyof DM, string>, SEARCH extends Record<keyof DM, string>, GEO extends Record<keyof DM, string> = Record<keyof DM, never>> = { readonly [T in keyof DM]: TableReaderFacade<DM, REL, RANK, SEARCH, T, GEO>; };
|
|
510
|
-
/** Per-table read-write facade — `ctx.db
|
|
510
|
+
/** Per-table read-write facade — `ctx.db.<table>` on a `MutationCtx` / `ActionCtx`. */
|
|
511
511
|
type DatabaseWriterFacade<DM, IM extends Record<keyof DM, object>, REL extends Record<keyof DM, object>, RANK extends Record<keyof DM, string>, SEARCH extends Record<keyof DM, string>, GEO extends Record<keyof DM, string> = Record<keyof DM, never>> = { readonly [T in keyof DM]: TableWriterFacade<DM, IM, REL, RANK, SEARCH, T, GEO>; };
|
|
512
512
|
export { AggregateOp, DatabaseReaderFacade, DatabaseWriterFacade, GeoBoundingBox, GeoFilterBuilder, GeoPointInput, GeoReader, GroupByEntry, Id, LoadWith, ManyRelationWhere, OneRelationWhere, OrderBy, QueryArgs, QueryArgsOf, QueryPage, RankPage, RankResult, RestrictableQueryOptions, RestrictableQueryOptionsOf, SearchFilterBuilder, SearchReader, TableAggregateOptions, TableAggregateOptionsOf, TableGroupByOptions, TableGroupByOptionsOf, TableRankOptions, TableRankPageOptions, TableReaderFacade, TableWriterFacade, UpsertTargetOf, Where, WhereOf, WhereOperators, WithArg };
|
package/dist/index.d.mts
CHANGED
|
@@ -6,8 +6,8 @@ import { LunoraError as LunoraError$1, LunoraErrorCode } from '@lunora/errors';
|
|
|
6
6
|
export 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
|
-
import { b as Permission, R as Role, T as TypedDefinePolicyInput, a as Policy, D as DefinePolicyInput, W as WhereInput, c as RlsOptions } from "./packem_shared/types.d-
|
|
10
|
-
export type { d as PolicyContext, e as PolicyDecision, f as PolicyDecisionOf, P as PolicyOperation } from "./packem_shared/types.d-
|
|
9
|
+
import { b as Permission, R as Role, T as TypedDefinePolicyInput, a as Policy, D as DefinePolicyInput, W as WhereInput, c as RlsOptions } from "./packem_shared/types.d-BXr-YW9j.mjs";
|
|
10
|
+
export type { d as PolicyContext, e as PolicyDecision, f as PolicyDecisionOf, P as PolicyOperation } from "./packem_shared/types.d-BXr-YW9j.mjs";
|
|
11
11
|
export { type CronJob, type CronJobsBuilder, type CronScheduleKind, type DailySchedule, type IntervalSchedule, type MonthlySchedule, type WeeklySchedule, cronJobs } from '@lunora/scheduler';
|
|
12
12
|
/**
|
|
13
13
|
* Make any resolved storage capability bucket-aware so `ctx.storage.bucket(name)`
|
|
@@ -51,7 +51,7 @@ type Middleware<ContextIn, ContextOut> = (options: {
|
|
|
51
51
|
ctx: ContextIn;
|
|
52
52
|
next: MiddlewareNext<ContextIn>;
|
|
53
53
|
}) => ContextOut | Promise<ContextOut>;
|
|
54
|
-
/** Options accepted by `initLunora.dataModel
|
|
54
|
+
/** Options accepted by `initLunora.dataModel<DM>().create(...)`. Reserved for transformer/error-formatter wiring. */
|
|
55
55
|
type CreateOptions = Record<never, never>;
|
|
56
56
|
/**
|
|
57
57
|
* `Output` carries the type declared by `.output(validator)`. It defaults to
|
|
@@ -66,7 +66,7 @@ interface QueryBuilder<Context, Args extends ArgsValidator, Output = undefined>
|
|
|
66
66
|
readonly __lunoraProcedure: "query";
|
|
67
67
|
/**
|
|
68
68
|
* Publish this query on the opt-in public REST surface (plan 167) — the
|
|
69
|
-
* runtime mints `GET /_lunora/rest
|
|
69
|
+
* runtime mints `GET /_lunora/rest/<namespace>/<fn>` (and `POST`), dispatching
|
|
70
70
|
* THROUGH the procedure so `ctx.auth` / RLS / validators are enforced, and the
|
|
71
71
|
* generated OpenAPI describes it. Default-closed: omit to keep it RPC-only.
|
|
72
72
|
*/
|
|
@@ -93,7 +93,7 @@ interface QueryBuilder<Context, Args extends ArgsValidator, Output = undefined>
|
|
|
93
93
|
}) => Output | Promise<Output>) => RegisteredQuery<Args, Output>;
|
|
94
94
|
/**
|
|
95
95
|
* Terminal: declare this procedure as a streaming query. The handler is an
|
|
96
|
-
* async generator (or any function returning an `AsyncIterable
|
|
96
|
+
* async generator (or any function returning an `AsyncIterable<R>`) that
|
|
97
97
|
* yields one chunk per server-pushed frame. The third `signal` argument is
|
|
98
98
|
* tripped when the client cancels — break out of the loop or check
|
|
99
99
|
* `signal.aborted` between yields. `.output()` does not apply: per-chunk
|
|
@@ -117,7 +117,7 @@ interface MutationBuilder<Context, Args extends ArgsValidator, Output = undefine
|
|
|
117
117
|
readonly __lunoraProcedure: "mutation";
|
|
118
118
|
/**
|
|
119
119
|
* Publish this mutation on the opt-in public REST surface (plan 167) — the
|
|
120
|
-
* runtime mints `POST /_lunora/rest
|
|
120
|
+
* runtime mints `POST /_lunora/rest/<namespace>/<fn>`, dispatching THROUGH the
|
|
121
121
|
* procedure so `ctx.auth` / RLS / validators are enforced, and the generated
|
|
122
122
|
* OpenAPI describes it. Default-closed: omit to keep it RPC-only.
|
|
123
123
|
*/
|
|
@@ -162,7 +162,7 @@ interface ActionBuilder<Context, Args extends ArgsValidator, Output = undefined>
|
|
|
162
162
|
}) => Output | Promise<Output>) => RegisteredAction<Args, Output>;
|
|
163
163
|
/**
|
|
164
164
|
* Publish this action on the opt-in public REST surface (plan 167) — the
|
|
165
|
-
* runtime mints `POST /_lunora/rest
|
|
165
|
+
* runtime mints `POST /_lunora/rest/<namespace>/<fn>`, dispatching THROUGH the
|
|
166
166
|
* procedure so `ctx.auth` / RLS / validators are enforced, and the generated
|
|
167
167
|
* OpenAPI describes it. Default-closed: omit to keep it RPC-only.
|
|
168
168
|
*/
|
|
@@ -291,7 +291,7 @@ interface DataModelInit<DataModel> {
|
|
|
291
291
|
create: (options?: CreateOptions) => LunoraBuilders;
|
|
292
292
|
}
|
|
293
293
|
/**
|
|
294
|
-
* Entry point for the procedure builder. `dataModel
|
|
294
|
+
* Entry point for the procedure builder. `dataModel<DM>()` binds the generated
|
|
295
295
|
* `DataModel` (phantom for now), and `.create()` yields the public root builders
|
|
296
296
|
* plus their `internal*` counterparts.
|
|
297
297
|
*/
|
|
@@ -482,7 +482,7 @@ interface FacadeEntry {
|
|
|
482
482
|
* Insert many documents into this table in one call. With
|
|
483
483
|
* `{ skipDuplicates: true }`, UNIQUE breaches resolve to `null` for that row
|
|
484
484
|
* instead of failing the batch. The typed facade narrows the return to
|
|
485
|
-
* `Id
|
|
485
|
+
* `Id<T>[]` when skipDuplicates is not requested.
|
|
486
486
|
*/
|
|
487
487
|
insertMany: (documents: ReadonlyArray<Record<string, unknown>>, options?: {
|
|
488
488
|
limit?: number;
|
|
@@ -556,7 +556,7 @@ interface UpsertManyArgs {
|
|
|
556
556
|
*
|
|
557
557
|
* The by-id accessors (`get`/`delete`/`patch`/`replace`) forward the bound
|
|
558
558
|
* `tableName` as `expectedTable` so the underlying writer scopes its id lookup
|
|
559
|
-
* to this table. Without it, a branded `Id
|
|
559
|
+
* to this table. Without it, a branded `Id<"posts">` carrying another table's
|
|
560
560
|
* id would resolve cross-table (the writer probes every table by id), letting
|
|
561
561
|
* `ctx.db.posts.get(foreignId)` read — or `.delete`/`.patch`/`.replace`
|
|
562
562
|
* mutate — a row in an unrelated table (IDOR). Writers that ignore the second
|
|
@@ -710,7 +710,7 @@ interface HttpRouteBuilder<SearchParams extends ArgsValidator, Body extends Args
|
|
|
710
710
|
/**
|
|
711
711
|
* Terminal: declare this route as a streaming Server-Sent Events endpoint.
|
|
712
712
|
* The handler is an async generator (or any function returning an
|
|
713
|
-
* `AsyncIterable
|
|
713
|
+
* `AsyncIterable<R>`) that yields one chunk per SSE `data:` frame; on
|
|
714
714
|
* iterator completion the route writes a final `event: complete` frame; on
|
|
715
715
|
* throw, an `event: error` frame is written with `{code, message}` before
|
|
716
716
|
* the stream closes. The chunks are JSON-encoded; `R` is inferred from the
|
|
@@ -957,7 +957,7 @@ interface ListArgsSpec<TDocument, F, O extends string> {
|
|
|
957
957
|
* `limit` clamped into `[1, maxLimit]`, `orderBy` reshaped from
|
|
958
958
|
* `{ field, direction }[]` into `ctx.db`'s `{ column: direction }[]`.
|
|
959
959
|
*
|
|
960
|
-
* Returns `QueryArgs
|
|
960
|
+
* Returns `QueryArgs<Doc>` — bound to the table, not free — so a mismatch
|
|
961
961
|
* between what this helper declares and what the table actually holds is a
|
|
962
962
|
* compile error at the `findMany` call site.
|
|
963
963
|
*/
|
|
@@ -967,10 +967,10 @@ interface ListArgsSpec<TDocument, F, O extends string> {
|
|
|
967
967
|
declare const clampLimit: (limit: number | undefined, fallback: number, maxLimit: number) => number;
|
|
968
968
|
/**
|
|
969
969
|
* Declare the filter / sort / page arguments for a list endpoint, plus the
|
|
970
|
-
* translation into `ctx.db
|
|
970
|
+
* translation into `ctx.db.<table>.findMany(...)` options. See the module docs
|
|
971
971
|
* for the shape and the reasoning behind it.
|
|
972
972
|
*
|
|
973
|
-
* Curried on the document type: `defineListArgs
|
|
973
|
+
* Curried on the document type: `defineListArgs<Doc<"messages">>()({ … })`. The
|
|
974
974
|
* extra `()` buys the thing that matters — with `Doc` bound, `filter` keys and
|
|
975
975
|
* `orderBy` entries are checked against the table's real columns, so a typo or a
|
|
976
976
|
* column renamed out from under the endpoint is a COMPILE error instead of a
|
|
@@ -1030,7 +1030,7 @@ type ExtensionTablesOf<P> = P extends {
|
|
|
1030
1030
|
type InstalledTables<T extends Record<string, TableDefinition>, Plugins extends ReadonlyArray<unknown>> = Plugins extends readonly [infer Head, ...infer Rest] ? InstalledTables<ExtensionTablesOf<Head> & T, Rest> : T;
|
|
1031
1031
|
/**
|
|
1032
1032
|
* Union every plugin's `ContextOut` in a tuple — the type-level mirror of the
|
|
1033
|
-
* `ctx.api
|
|
1033
|
+
* `ctx.api.<key>` additions {@link composePluginMiddleware} accumulates as each
|
|
1034
1034
|
* plugin middleware runs. Independent of the incoming context, which the builder
|
|
1035
1035
|
* infers at the `.use(...)` site.
|
|
1036
1036
|
*/
|
|
@@ -1083,7 +1083,7 @@ interface Plugin<TExtension extends Record<string, TableDefinition> = Record<str
|
|
|
1083
1083
|
/**
|
|
1084
1084
|
* Optional middleware. Users attach with `c.query.use(plugin.middleware)`.
|
|
1085
1085
|
* The middleware can extend `ctx`; convention is to attach helpers under
|
|
1086
|
-
* `ctx.api
|
|
1086
|
+
* `ctx.api.<key>`, e.g.
|
|
1087
1087
|
*
|
|
1088
1088
|
* ```ts
|
|
1089
1089
|
* middleware: ({ ctx, next }) =>
|
|
@@ -1228,7 +1228,7 @@ declare const installPlugins: <T extends Record<string, TableDefinition>, const
|
|
|
1228
1228
|
* Compose every plugin's middleware into a single middleware you attach with one
|
|
1229
1229
|
* `.use(...)`. Plugins without middleware (schema-only) are skipped; the rest run
|
|
1230
1230
|
* in array order, each seeing the context the previous one widened, so the final
|
|
1231
|
-
* `next({ ctx })` the builder receives carries every plugin's `ctx.api
|
|
1231
|
+
* `next({ ctx })` the builder receives carries every plugin's `ctx.api.<key>`
|
|
1232
1232
|
* additions. Equivalent to `.use(a.middleware).use(b.middleware)…` but as one
|
|
1233
1233
|
* value, the middleware sibling of {@link installPlugins}.
|
|
1234
1234
|
*
|
|
@@ -1388,7 +1388,7 @@ interface TableBuilder<Shape extends Record<string, Validator> = Record<string,
|
|
|
1388
1388
|
shardBy: (field: keyof Shape & string) => TableBuilder<Shape>;
|
|
1389
1389
|
/**
|
|
1390
1390
|
* Turn on soft delete. Adds a nullable timestamp column (`options.field`,
|
|
1391
|
-
* default `deletedAt`) and changes `ctx.db
|
|
1391
|
+
* default `deletedAt`) and changes `ctx.db.<table>.delete()` to **set** it
|
|
1392
1392
|
* instead of removing the row; `onDelete: "cascade"` children are recursively
|
|
1393
1393
|
* soft-deleted too. **List reads** (`findMany`/`findFirst`/`query()`/`count`/
|
|
1394
1394
|
* `aggregate`/relation loads) then hide soft-deleted rows unless they pass
|
|
@@ -2114,7 +2114,7 @@ declare const definePolicy: <Context = unknown>(input: DefinePolicyInput<Context
|
|
|
2114
2114
|
/**
|
|
2115
2115
|
* Build a project-bound, relation-aware `definePolicy` typed against the
|
|
2116
2116
|
* generated `DataModel` (`DM`) + `Relations` (`REL`) maps. Codegen emits a
|
|
2117
|
-
* `createPolicyDsl
|
|
2117
|
+
* `createPolicyDsl<DataModel, Relations>()` binding into `_generated/server.ts`,
|
|
2118
2118
|
* so importing `definePolicy` from the generated module constrains `table` to a
|
|
2119
2119
|
* real table name and type-checks the `when` predicate — including Prisma-style
|
|
2120
2120
|
* relation predicates (`is`/`some`/…) the `@lunora/do` pre-resolver now resolves
|
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ import { LunoraError as LunoraError$1, LunoraErrorCode } from '@lunora/errors';
|
|
|
6
6
|
export 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
|
-
import { b as Permission, R as Role, T as TypedDefinePolicyInput, a as Policy, D as DefinePolicyInput, W as WhereInput, c as RlsOptions } from "./packem_shared/types.d-
|
|
10
|
-
export type { d as PolicyContext, e as PolicyDecision, f as PolicyDecisionOf, P as PolicyOperation } from "./packem_shared/types.d-
|
|
9
|
+
import { b as Permission, R as Role, T as TypedDefinePolicyInput, a as Policy, D as DefinePolicyInput, W as WhereInput, c as RlsOptions } from "./packem_shared/types.d-D6Lv3h_-.js";
|
|
10
|
+
export type { d as PolicyContext, e as PolicyDecision, f as PolicyDecisionOf, P as PolicyOperation } from "./packem_shared/types.d-D6Lv3h_-.js";
|
|
11
11
|
export { type CronJob, type CronJobsBuilder, type CronScheduleKind, type DailySchedule, type IntervalSchedule, type MonthlySchedule, type WeeklySchedule, cronJobs } from '@lunora/scheduler';
|
|
12
12
|
/**
|
|
13
13
|
* Make any resolved storage capability bucket-aware so `ctx.storage.bucket(name)`
|
|
@@ -51,7 +51,7 @@ type Middleware<ContextIn, ContextOut> = (options: {
|
|
|
51
51
|
ctx: ContextIn;
|
|
52
52
|
next: MiddlewareNext<ContextIn>;
|
|
53
53
|
}) => ContextOut | Promise<ContextOut>;
|
|
54
|
-
/** Options accepted by `initLunora.dataModel
|
|
54
|
+
/** Options accepted by `initLunora.dataModel<DM>().create(...)`. Reserved for transformer/error-formatter wiring. */
|
|
55
55
|
type CreateOptions = Record<never, never>;
|
|
56
56
|
/**
|
|
57
57
|
* `Output` carries the type declared by `.output(validator)`. It defaults to
|
|
@@ -66,7 +66,7 @@ interface QueryBuilder<Context, Args extends ArgsValidator, Output = undefined>
|
|
|
66
66
|
readonly __lunoraProcedure: "query";
|
|
67
67
|
/**
|
|
68
68
|
* Publish this query on the opt-in public REST surface (plan 167) — the
|
|
69
|
-
* runtime mints `GET /_lunora/rest
|
|
69
|
+
* runtime mints `GET /_lunora/rest/<namespace>/<fn>` (and `POST`), dispatching
|
|
70
70
|
* THROUGH the procedure so `ctx.auth` / RLS / validators are enforced, and the
|
|
71
71
|
* generated OpenAPI describes it. Default-closed: omit to keep it RPC-only.
|
|
72
72
|
*/
|
|
@@ -93,7 +93,7 @@ interface QueryBuilder<Context, Args extends ArgsValidator, Output = undefined>
|
|
|
93
93
|
}) => Output | Promise<Output>) => RegisteredQuery<Args, Output>;
|
|
94
94
|
/**
|
|
95
95
|
* Terminal: declare this procedure as a streaming query. The handler is an
|
|
96
|
-
* async generator (or any function returning an `AsyncIterable
|
|
96
|
+
* async generator (or any function returning an `AsyncIterable<R>`) that
|
|
97
97
|
* yields one chunk per server-pushed frame. The third `signal` argument is
|
|
98
98
|
* tripped when the client cancels — break out of the loop or check
|
|
99
99
|
* `signal.aborted` between yields. `.output()` does not apply: per-chunk
|
|
@@ -117,7 +117,7 @@ interface MutationBuilder<Context, Args extends ArgsValidator, Output = undefine
|
|
|
117
117
|
readonly __lunoraProcedure: "mutation";
|
|
118
118
|
/**
|
|
119
119
|
* Publish this mutation on the opt-in public REST surface (plan 167) — the
|
|
120
|
-
* runtime mints `POST /_lunora/rest
|
|
120
|
+
* runtime mints `POST /_lunora/rest/<namespace>/<fn>`, dispatching THROUGH the
|
|
121
121
|
* procedure so `ctx.auth` / RLS / validators are enforced, and the generated
|
|
122
122
|
* OpenAPI describes it. Default-closed: omit to keep it RPC-only.
|
|
123
123
|
*/
|
|
@@ -162,7 +162,7 @@ interface ActionBuilder<Context, Args extends ArgsValidator, Output = undefined>
|
|
|
162
162
|
}) => Output | Promise<Output>) => RegisteredAction<Args, Output>;
|
|
163
163
|
/**
|
|
164
164
|
* Publish this action on the opt-in public REST surface (plan 167) — the
|
|
165
|
-
* runtime mints `POST /_lunora/rest
|
|
165
|
+
* runtime mints `POST /_lunora/rest/<namespace>/<fn>`, dispatching THROUGH the
|
|
166
166
|
* procedure so `ctx.auth` / RLS / validators are enforced, and the generated
|
|
167
167
|
* OpenAPI describes it. Default-closed: omit to keep it RPC-only.
|
|
168
168
|
*/
|
|
@@ -291,7 +291,7 @@ interface DataModelInit<DataModel> {
|
|
|
291
291
|
create: (options?: CreateOptions) => LunoraBuilders;
|
|
292
292
|
}
|
|
293
293
|
/**
|
|
294
|
-
* Entry point for the procedure builder. `dataModel
|
|
294
|
+
* Entry point for the procedure builder. `dataModel<DM>()` binds the generated
|
|
295
295
|
* `DataModel` (phantom for now), and `.create()` yields the public root builders
|
|
296
296
|
* plus their `internal*` counterparts.
|
|
297
297
|
*/
|
|
@@ -482,7 +482,7 @@ interface FacadeEntry {
|
|
|
482
482
|
* Insert many documents into this table in one call. With
|
|
483
483
|
* `{ skipDuplicates: true }`, UNIQUE breaches resolve to `null` for that row
|
|
484
484
|
* instead of failing the batch. The typed facade narrows the return to
|
|
485
|
-
* `Id
|
|
485
|
+
* `Id<T>[]` when skipDuplicates is not requested.
|
|
486
486
|
*/
|
|
487
487
|
insertMany: (documents: ReadonlyArray<Record<string, unknown>>, options?: {
|
|
488
488
|
limit?: number;
|
|
@@ -556,7 +556,7 @@ interface UpsertManyArgs {
|
|
|
556
556
|
*
|
|
557
557
|
* The by-id accessors (`get`/`delete`/`patch`/`replace`) forward the bound
|
|
558
558
|
* `tableName` as `expectedTable` so the underlying writer scopes its id lookup
|
|
559
|
-
* to this table. Without it, a branded `Id
|
|
559
|
+
* to this table. Without it, a branded `Id<"posts">` carrying another table's
|
|
560
560
|
* id would resolve cross-table (the writer probes every table by id), letting
|
|
561
561
|
* `ctx.db.posts.get(foreignId)` read — or `.delete`/`.patch`/`.replace`
|
|
562
562
|
* mutate — a row in an unrelated table (IDOR). Writers that ignore the second
|
|
@@ -710,7 +710,7 @@ interface HttpRouteBuilder<SearchParams extends ArgsValidator, Body extends Args
|
|
|
710
710
|
/**
|
|
711
711
|
* Terminal: declare this route as a streaming Server-Sent Events endpoint.
|
|
712
712
|
* The handler is an async generator (or any function returning an
|
|
713
|
-
* `AsyncIterable
|
|
713
|
+
* `AsyncIterable<R>`) that yields one chunk per SSE `data:` frame; on
|
|
714
714
|
* iterator completion the route writes a final `event: complete` frame; on
|
|
715
715
|
* throw, an `event: error` frame is written with `{code, message}` before
|
|
716
716
|
* the stream closes. The chunks are JSON-encoded; `R` is inferred from the
|
|
@@ -957,7 +957,7 @@ interface ListArgsSpec<TDocument, F, O extends string> {
|
|
|
957
957
|
* `limit` clamped into `[1, maxLimit]`, `orderBy` reshaped from
|
|
958
958
|
* `{ field, direction }[]` into `ctx.db`'s `{ column: direction }[]`.
|
|
959
959
|
*
|
|
960
|
-
* Returns `QueryArgs
|
|
960
|
+
* Returns `QueryArgs<Doc>` — bound to the table, not free — so a mismatch
|
|
961
961
|
* between what this helper declares and what the table actually holds is a
|
|
962
962
|
* compile error at the `findMany` call site.
|
|
963
963
|
*/
|
|
@@ -967,10 +967,10 @@ interface ListArgsSpec<TDocument, F, O extends string> {
|
|
|
967
967
|
declare const clampLimit: (limit: number | undefined, fallback: number, maxLimit: number) => number;
|
|
968
968
|
/**
|
|
969
969
|
* Declare the filter / sort / page arguments for a list endpoint, plus the
|
|
970
|
-
* translation into `ctx.db
|
|
970
|
+
* translation into `ctx.db.<table>.findMany(...)` options. See the module docs
|
|
971
971
|
* for the shape and the reasoning behind it.
|
|
972
972
|
*
|
|
973
|
-
* Curried on the document type: `defineListArgs
|
|
973
|
+
* Curried on the document type: `defineListArgs<Doc<"messages">>()({ … })`. The
|
|
974
974
|
* extra `()` buys the thing that matters — with `Doc` bound, `filter` keys and
|
|
975
975
|
* `orderBy` entries are checked against the table's real columns, so a typo or a
|
|
976
976
|
* column renamed out from under the endpoint is a COMPILE error instead of a
|
|
@@ -1030,7 +1030,7 @@ type ExtensionTablesOf<P> = P extends {
|
|
|
1030
1030
|
type InstalledTables<T extends Record<string, TableDefinition>, Plugins extends ReadonlyArray<unknown>> = Plugins extends readonly [infer Head, ...infer Rest] ? InstalledTables<ExtensionTablesOf<Head> & T, Rest> : T;
|
|
1031
1031
|
/**
|
|
1032
1032
|
* Union every plugin's `ContextOut` in a tuple — the type-level mirror of the
|
|
1033
|
-
* `ctx.api
|
|
1033
|
+
* `ctx.api.<key>` additions {@link composePluginMiddleware} accumulates as each
|
|
1034
1034
|
* plugin middleware runs. Independent of the incoming context, which the builder
|
|
1035
1035
|
* infers at the `.use(...)` site.
|
|
1036
1036
|
*/
|
|
@@ -1083,7 +1083,7 @@ interface Plugin<TExtension extends Record<string, TableDefinition> = Record<str
|
|
|
1083
1083
|
/**
|
|
1084
1084
|
* Optional middleware. Users attach with `c.query.use(plugin.middleware)`.
|
|
1085
1085
|
* The middleware can extend `ctx`; convention is to attach helpers under
|
|
1086
|
-
* `ctx.api
|
|
1086
|
+
* `ctx.api.<key>`, e.g.
|
|
1087
1087
|
*
|
|
1088
1088
|
* ```ts
|
|
1089
1089
|
* middleware: ({ ctx, next }) =>
|
|
@@ -1228,7 +1228,7 @@ declare const installPlugins: <T extends Record<string, TableDefinition>, const
|
|
|
1228
1228
|
* Compose every plugin's middleware into a single middleware you attach with one
|
|
1229
1229
|
* `.use(...)`. Plugins without middleware (schema-only) are skipped; the rest run
|
|
1230
1230
|
* in array order, each seeing the context the previous one widened, so the final
|
|
1231
|
-
* `next({ ctx })` the builder receives carries every plugin's `ctx.api
|
|
1231
|
+
* `next({ ctx })` the builder receives carries every plugin's `ctx.api.<key>`
|
|
1232
1232
|
* additions. Equivalent to `.use(a.middleware).use(b.middleware)…` but as one
|
|
1233
1233
|
* value, the middleware sibling of {@link installPlugins}.
|
|
1234
1234
|
*
|
|
@@ -1388,7 +1388,7 @@ interface TableBuilder<Shape extends Record<string, Validator> = Record<string,
|
|
|
1388
1388
|
shardBy: (field: keyof Shape & string) => TableBuilder<Shape>;
|
|
1389
1389
|
/**
|
|
1390
1390
|
* Turn on soft delete. Adds a nullable timestamp column (`options.field`,
|
|
1391
|
-
* default `deletedAt`) and changes `ctx.db
|
|
1391
|
+
* default `deletedAt`) and changes `ctx.db.<table>.delete()` to **set** it
|
|
1392
1392
|
* instead of removing the row; `onDelete: "cascade"` children are recursively
|
|
1393
1393
|
* soft-deleted too. **List reads** (`findMany`/`findFirst`/`query()`/`count`/
|
|
1394
1394
|
* `aggregate`/relation loads) then hide soft-deleted rows unless they pass
|
|
@@ -2114,7 +2114,7 @@ declare const definePolicy: <Context = unknown>(input: DefinePolicyInput<Context
|
|
|
2114
2114
|
/**
|
|
2115
2115
|
* Build a project-bound, relation-aware `definePolicy` typed against the
|
|
2116
2116
|
* generated `DataModel` (`DM`) + `Relations` (`REL`) maps. Codegen emits a
|
|
2117
|
-
* `createPolicyDsl
|
|
2117
|
+
* `createPolicyDsl<DataModel, Relations>()` binding into `_generated/server.ts`,
|
|
2118
2118
|
* so importing `definePolicy` from the generated module constrains `table` to a
|
|
2119
2119
|
* real table name and type-checks the `when` predicate — including Prisma-style
|
|
2120
2120
|
* relation predicates (`is`/`some`/…) the `@lunora/do` pre-resolver now resolves
|
|
@@ -32,7 +32,7 @@ type PolicyDecision = WhereInput | boolean | undefined;
|
|
|
32
32
|
* generated `DataModel` (`DM`) + `Relations` (`REL`) maps and a table `T`. A
|
|
33
33
|
* read policy may now return a Prisma-style relation predicate (the
|
|
34
34
|
* `@lunora/do` pre-resolver resolves it via a semijoin), so the typed
|
|
35
|
-
* authoring surface accepts `WhereOf
|
|
35
|
+
* authoring surface accepts `WhereOf<DM, REL, T>` — column predicates **and**
|
|
36
36
|
* `is`/`isNot`/`some`/`none`/`every` over `T`'s declared relations — in
|
|
37
37
|
* addition to the `boolean`/`undefined` decisions. Used by the project-bound
|
|
38
38
|
* `definePolicy` from `createPolicyDsl`.
|
|
@@ -32,7 +32,7 @@ type PolicyDecision = WhereInput | boolean | undefined;
|
|
|
32
32
|
* generated `DataModel` (`DM`) + `Relations` (`REL`) maps and a table `T`. A
|
|
33
33
|
* read policy may now return a Prisma-style relation predicate (the
|
|
34
34
|
* `@lunora/do` pre-resolver resolves it via a semijoin), so the typed
|
|
35
|
-
* authoring surface accepts `WhereOf
|
|
35
|
+
* authoring surface accepts `WhereOf<DM, REL, T>` — column predicates **and**
|
|
36
36
|
* `is`/`isNot`/`some`/`none`/`every` over `T`'s declared relations — in
|
|
37
37
|
* addition to the `boolean`/`undefined` decisions. Used by the project-bound
|
|
38
38
|
* `definePolicy` from `createPolicyDsl`.
|
package/dist/rls/testing.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as PolicyOperation, R as Role, a as Policy } from "../packem_shared/types.d-
|
|
1
|
+
import { P as PolicyOperation, R as Role, a as Policy } from "../packem_shared/types.d-BXr-YW9j.mjs";
|
|
2
2
|
import "../data-model.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* The slice of a request identity a policy reads. Mirrors the
|
package/dist/rls/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as PolicyOperation, R as Role, a as Policy } from "../packem_shared/types.d-
|
|
1
|
+
import { P as PolicyOperation, R as Role, a as Policy } from "../packem_shared/types.d-D6Lv3h_-.js";
|
|
2
2
|
import "../data-model.js";
|
|
3
3
|
/**
|
|
4
4
|
* The slice of a request identity a policy reads. Mirrors the
|
package/dist/types.d.mts
CHANGED
|
@@ -418,7 +418,7 @@ interface TableDefinition<Shape extends Record<string, Validator> = Record<strin
|
|
|
418
418
|
* data field doesn't collide with the fluent `.softDelete()` builder method —
|
|
419
419
|
* same convention as `shardBy()`/`shardMode`). When present, the table carries
|
|
420
420
|
* a nullable timestamp column (`field`, default `deletedAt`):
|
|
421
|
-
* `ctx.db
|
|
421
|
+
* `ctx.db.<table>.delete()` flips it instead of physically removing the row,
|
|
422
422
|
* and **list reads** (`findMany`/`findFirst`/`query()`/`count`/`aggregate`/
|
|
423
423
|
* relation loads) hide rows whose `field` is set unless
|
|
424
424
|
* `includeDeleted: true` is passed. By-id `get`/`patch`/`replace` and
|
|
@@ -524,7 +524,7 @@ type RestCacheConfig = RestCachePolicy;
|
|
|
524
524
|
/**
|
|
525
525
|
* Opt-in public-surface tag attached by the `.expose({ rest: true })` builder
|
|
526
526
|
* modifier (plan 167). Marks a procedure as deliberately published over the
|
|
527
|
-
* public REST surface: the runtime mints a `/_lunora/rest
|
|
527
|
+
* public REST surface: the runtime mints a `/_lunora/rest/<namespace>/<fn>` route
|
|
528
528
|
* that dispatches THROUGH the procedure (so `ctx.auth` / RLS / validators are
|
|
529
529
|
* enforced), and the generated OpenAPI describes it. Everything is default-closed
|
|
530
530
|
* — a procedure without this tag is unreachable over REST.
|
|
@@ -571,7 +571,7 @@ type RegisteredMutation<A extends ArgsValidator, R> = RegisteredFunction<A, R, "
|
|
|
571
571
|
type RegisteredAction<A extends ArgsValidator, R> = RegisteredFunction<A, R, "action">;
|
|
572
572
|
/**
|
|
573
573
|
* Structural mirror of `@lunora/client`'s `FunctionReference` — the handle the
|
|
574
|
-
* generated `api` / `internal` objects hand you, carrying
|
|
574
|
+
* generated `api` / `internal` objects hand you, carrying `<file>:<function>`
|
|
575
575
|
* in `__lunoraRef`. Redeclared here so `@lunora/server` needs no dependency on
|
|
576
576
|
* the client package, exactly as {@link Scheduler} avoids one on
|
|
577
577
|
* `@lunora/scheduler`. `RegisteredFunction` has no `__lunoraRef`, so the two
|
|
@@ -593,8 +593,8 @@ interface FunctionHandle<Kind extends "action" | "mutation" | "query" | "stream"
|
|
|
593
593
|
* contextually type a parameter against a multi-signature type, so a hand-built
|
|
594
594
|
* ctx object must annotate its `(reference, args)` explicitly — see
|
|
595
595
|
* `@lunora/testing`'s harness). It does not work: a concrete
|
|
596
|
-
* `RegisteredQuery
|
|
597
|
-
* `RegisteredFunction
|
|
596
|
+
* `RegisteredQuery<{…}, number>` is not assignable to a
|
|
597
|
+
* `RegisteredFunction<ArgsValidator, …>` constraint, because `handler`'s args
|
|
598
598
|
* are in a contravariant position. Two inference sites it is.
|
|
599
599
|
*/
|
|
600
600
|
interface RunQuery {
|
|
@@ -638,7 +638,7 @@ type RegisteredLifecycleHook = RegisteredFunction<Record<string, never>, void, "
|
|
|
638
638
|
};
|
|
639
639
|
/**
|
|
640
640
|
* A streaming query registration. Unlike {@link RegisteredFunction} the handler
|
|
641
|
-
* returns an `AsyncIterable
|
|
641
|
+
* returns an `AsyncIterable<R>` synchronously (it does NOT `Promise<R>`); the
|
|
642
642
|
* runtime drives it frame by frame and forwards each chunk to the caller. The
|
|
643
643
|
* third `signal` argument is wired to the caller's cancel signal so the handler
|
|
644
644
|
* can stop early — break out of the loop or check `signal.aborted` between
|
|
@@ -689,7 +689,7 @@ interface SystemQuery<T extends SystemTableName> {
|
|
|
689
689
|
* Read-only reader over Lunora's system tables (`_scheduled_functions`,
|
|
690
690
|
* `_storage`), exposed as `ctx.db.system`. Mirrors Convex's `ctx.db.system`.
|
|
691
691
|
*
|
|
692
|
-
* **Best-effort and eventually consistent.** Unlike `ctx.db
|
|
692
|
+
* **Best-effort and eventually consistent.** Unlike `ctx.db.<table>` — which
|
|
693
693
|
* reads the shard's transactional SQLite snapshot — the data behind these tables
|
|
694
694
|
* lives OUTSIDE the shard (scheduled functions in the `SchedulerDO`, storage
|
|
695
695
|
* objects in R2). Every `collect()` / `get()` reaches across to that source.
|
|
@@ -728,7 +728,7 @@ interface DatabaseReader {
|
|
|
728
728
|
*
|
|
729
729
|
* This is the **parse boundary** for an id that arrived as a plain `string`: a
|
|
730
730
|
* wire payload, a mutator's args, a change plan computed on the client. The
|
|
731
|
-
* alternative is `value as Id
|
|
731
|
+
* alternative is `value as Id<"table">` at every such call site — an assertion,
|
|
732
732
|
* not a check, and one that has to be repeated for every table a helper is
|
|
733
733
|
* generic over:
|
|
734
734
|
*
|
|
@@ -794,8 +794,8 @@ interface PaginationResult<T = Record<string, unknown>> {
|
|
|
794
794
|
}
|
|
795
795
|
/**
|
|
796
796
|
* The fluent `ctx.db.query(table)` reader. Generic over the document type
|
|
797
|
-
* `Row` so the generated `ctx.db` can bind it to `Doc
|
|
798
|
-
* every terminal then resolve typed rows — no `as unknown as Doc
|
|
797
|
+
* `Row` so the generated `ctx.db` can bind it to `Doc<table>` (the chain and
|
|
798
|
+
* every terminal then resolve typed rows — no `as unknown as Doc<...>` casts),
|
|
799
799
|
* and over the table's declared index names so `.withIndex()` / `.withSearchIndex()`
|
|
800
800
|
* / `.withGeoIndex()` reject a name the table does not declare.
|
|
801
801
|
*
|
|
@@ -815,9 +815,9 @@ interface PaginationResult<T = Record<string, unknown>> {
|
|
|
815
815
|
* **Why `with*` are method signatures and everything else is a property.**
|
|
816
816
|
* Narrowing a parameter makes the enclosing type contravariant in it, so as
|
|
817
817
|
* function properties these would make a BOUND reader
|
|
818
|
-
* (`TableReader
|
|
819
|
-
* the unbound `TableReader
|
|
820
|
-
* `(reader: TableReader
|
|
818
|
+
* (`TableReader<Doc, "by_x">`, what `ctx.db.query(t)` returns) unassignable to
|
|
819
|
+
* the unbound `TableReader<Doc>` — quietly breaking every helper factored as
|
|
820
|
+
* `(reader: TableReader<Doc<"users">>) => …`, which is the obvious way to share
|
|
821
821
|
* query logic. A method signature is bivariant in its parameters, which keeps
|
|
822
822
|
* that direction working while the narrow parameter still rejects an undeclared
|
|
823
823
|
* name at the call site. Both directions are pinned in `types.test-d.ts`.
|
|
@@ -1122,8 +1122,8 @@ interface ScheduledJob {
|
|
|
1122
1122
|
shardKey?: string;
|
|
1123
1123
|
}
|
|
1124
1124
|
/**
|
|
1125
|
-
* A schedulable durable-workflow reference — the generated `workflows
|
|
1126
|
-
* `agents
|
|
1125
|
+
* A schedulable durable-workflow reference — the generated `workflows.<name>` /
|
|
1126
|
+
* `agents.<name>` object, which carries its `WORKFLOW_*`/`AGENT_*` binding and
|
|
1127
1127
|
* stable name. Structural mirror of `@lunora/scheduler`'s `WorkflowReference` so
|
|
1128
1128
|
* `ctx.scheduler` can target a workflow/agent without a dependency on
|
|
1129
1129
|
* `@lunora/scheduler` / `@lunora/workflow`. A scheduled workflow target starts a
|
|
@@ -1147,8 +1147,8 @@ interface Scheduler {
|
|
|
1147
1147
|
list: () => Promise<ScheduledJob[]>;
|
|
1148
1148
|
/**
|
|
1149
1149
|
* Schedule a one-shot run `delayMs` from now. `target` is a function path
|
|
1150
|
-
* (`"ns:fn"`) dispatched as a one-shot, or a generated `workflows
|
|
1151
|
-
* `agents
|
|
1150
|
+
* (`"ns:fn"`) dispatched as a one-shot, or a generated `workflows.<name>` /
|
|
1151
|
+
* `agents.<name>` reference which starts a fresh durable instance on fire
|
|
1152
1152
|
* (the args become its `params`).
|
|
1153
1153
|
*/
|
|
1154
1154
|
runAfter: (delayMs: number, target: SchedulableWorkflowReference | string, args?: Record<string, unknown>) => Promise<string>;
|
|
@@ -1370,12 +1370,12 @@ interface TriggerRankPageOptions {
|
|
|
1370
1370
|
/**
|
|
1371
1371
|
* Portable, table/id-addressed ORM writer handed to trigger handlers via
|
|
1372
1372
|
* `ctx.db`. Mirrors `@lunora/do`'s runtime `DatabaseWriterLike` surface — it is
|
|
1373
|
-
* **not** the generated per-table `ctx.db
|
|
1373
|
+
* **not** the generated per-table `ctx.db.<table>` facade (which can't be typed
|
|
1374
1374
|
* from inside `defineTable`, where the full schema isn't known).
|
|
1375
1375
|
*
|
|
1376
1376
|
* `aggregate`/`groupBy`/`count`/`rank`/`rankPage` route through the same
|
|
1377
1377
|
* trigger-maintained counter and rank tables the user-facing reader uses, so
|
|
1378
|
-
* a handler's `ctx.db
|
|
1378
|
+
* a handler's `ctx.db.<table>.aggregate(...)` observes the just-staged write
|
|
1379
1379
|
* within the same DO transaction (the counter step happens before the trigger
|
|
1380
1380
|
* fires).
|
|
1381
1381
|
*/
|
|
@@ -1562,7 +1562,7 @@ interface VectorSearch<IndexName extends string = string> extends VectorSearchRe
|
|
|
1562
1562
|
}
|
|
1563
1563
|
/**
|
|
1564
1564
|
* Structured, filterable key/value fields attached to a log line — the second
|
|
1565
|
-
* argument of a `ctx.log
|
|
1565
|
+
* argument of a `ctx.log.<level>(message, fields)` call, or the fields bound by
|
|
1566
1566
|
* `ctx.log.with(fields)`. They travel to an `ObservabilitySink`'s `onLog` and,
|
|
1567
1567
|
* for a network sink, become OTLP log-record attributes a log pipeline (or the
|
|
1568
1568
|
* Cloud log viewer) can filter and index on. Primitive values pass through;
|
|
@@ -1682,7 +1682,7 @@ interface SpanHandle {
|
|
|
1682
1682
|
addLink: (link: SpanLink) => void;
|
|
1683
1683
|
/**
|
|
1684
1684
|
* Attach an AI **evaluation** verdict to this (generation) span as the
|
|
1685
|
-
* `gen_ai.evaluation
|
|
1685
|
+
* `gen_ai.evaluation.<name>.score` / `.label` OpenTelemetry attributes, so a
|
|
1686
1686
|
* scorer's grade rides the same trace as the generation it graded. Convenience
|
|
1687
1687
|
* over {@link SpanHandle.setAttributes} that owns the key format; privacy-safe —
|
|
1688
1688
|
* only the name, score, and optional label are emitted. Throws on an empty name
|
package/dist/types.d.ts
CHANGED
|
@@ -418,7 +418,7 @@ interface TableDefinition<Shape extends Record<string, Validator> = Record<strin
|
|
|
418
418
|
* data field doesn't collide with the fluent `.softDelete()` builder method —
|
|
419
419
|
* same convention as `shardBy()`/`shardMode`). When present, the table carries
|
|
420
420
|
* a nullable timestamp column (`field`, default `deletedAt`):
|
|
421
|
-
* `ctx.db
|
|
421
|
+
* `ctx.db.<table>.delete()` flips it instead of physically removing the row,
|
|
422
422
|
* and **list reads** (`findMany`/`findFirst`/`query()`/`count`/`aggregate`/
|
|
423
423
|
* relation loads) hide rows whose `field` is set unless
|
|
424
424
|
* `includeDeleted: true` is passed. By-id `get`/`patch`/`replace` and
|
|
@@ -524,7 +524,7 @@ type RestCacheConfig = RestCachePolicy;
|
|
|
524
524
|
/**
|
|
525
525
|
* Opt-in public-surface tag attached by the `.expose({ rest: true })` builder
|
|
526
526
|
* modifier (plan 167). Marks a procedure as deliberately published over the
|
|
527
|
-
* public REST surface: the runtime mints a `/_lunora/rest
|
|
527
|
+
* public REST surface: the runtime mints a `/_lunora/rest/<namespace>/<fn>` route
|
|
528
528
|
* that dispatches THROUGH the procedure (so `ctx.auth` / RLS / validators are
|
|
529
529
|
* enforced), and the generated OpenAPI describes it. Everything is default-closed
|
|
530
530
|
* — a procedure without this tag is unreachable over REST.
|
|
@@ -571,7 +571,7 @@ type RegisteredMutation<A extends ArgsValidator, R> = RegisteredFunction<A, R, "
|
|
|
571
571
|
type RegisteredAction<A extends ArgsValidator, R> = RegisteredFunction<A, R, "action">;
|
|
572
572
|
/**
|
|
573
573
|
* Structural mirror of `@lunora/client`'s `FunctionReference` — the handle the
|
|
574
|
-
* generated `api` / `internal` objects hand you, carrying
|
|
574
|
+
* generated `api` / `internal` objects hand you, carrying `<file>:<function>`
|
|
575
575
|
* in `__lunoraRef`. Redeclared here so `@lunora/server` needs no dependency on
|
|
576
576
|
* the client package, exactly as {@link Scheduler} avoids one on
|
|
577
577
|
* `@lunora/scheduler`. `RegisteredFunction` has no `__lunoraRef`, so the two
|
|
@@ -593,8 +593,8 @@ interface FunctionHandle<Kind extends "action" | "mutation" | "query" | "stream"
|
|
|
593
593
|
* contextually type a parameter against a multi-signature type, so a hand-built
|
|
594
594
|
* ctx object must annotate its `(reference, args)` explicitly — see
|
|
595
595
|
* `@lunora/testing`'s harness). It does not work: a concrete
|
|
596
|
-
* `RegisteredQuery
|
|
597
|
-
* `RegisteredFunction
|
|
596
|
+
* `RegisteredQuery<{…}, number>` is not assignable to a
|
|
597
|
+
* `RegisteredFunction<ArgsValidator, …>` constraint, because `handler`'s args
|
|
598
598
|
* are in a contravariant position. Two inference sites it is.
|
|
599
599
|
*/
|
|
600
600
|
interface RunQuery {
|
|
@@ -638,7 +638,7 @@ type RegisteredLifecycleHook = RegisteredFunction<Record<string, never>, void, "
|
|
|
638
638
|
};
|
|
639
639
|
/**
|
|
640
640
|
* A streaming query registration. Unlike {@link RegisteredFunction} the handler
|
|
641
|
-
* returns an `AsyncIterable
|
|
641
|
+
* returns an `AsyncIterable<R>` synchronously (it does NOT `Promise<R>`); the
|
|
642
642
|
* runtime drives it frame by frame and forwards each chunk to the caller. The
|
|
643
643
|
* third `signal` argument is wired to the caller's cancel signal so the handler
|
|
644
644
|
* can stop early — break out of the loop or check `signal.aborted` between
|
|
@@ -689,7 +689,7 @@ interface SystemQuery<T extends SystemTableName> {
|
|
|
689
689
|
* Read-only reader over Lunora's system tables (`_scheduled_functions`,
|
|
690
690
|
* `_storage`), exposed as `ctx.db.system`. Mirrors Convex's `ctx.db.system`.
|
|
691
691
|
*
|
|
692
|
-
* **Best-effort and eventually consistent.** Unlike `ctx.db
|
|
692
|
+
* **Best-effort and eventually consistent.** Unlike `ctx.db.<table>` — which
|
|
693
693
|
* reads the shard's transactional SQLite snapshot — the data behind these tables
|
|
694
694
|
* lives OUTSIDE the shard (scheduled functions in the `SchedulerDO`, storage
|
|
695
695
|
* objects in R2). Every `collect()` / `get()` reaches across to that source.
|
|
@@ -728,7 +728,7 @@ interface DatabaseReader {
|
|
|
728
728
|
*
|
|
729
729
|
* This is the **parse boundary** for an id that arrived as a plain `string`: a
|
|
730
730
|
* wire payload, a mutator's args, a change plan computed on the client. The
|
|
731
|
-
* alternative is `value as Id
|
|
731
|
+
* alternative is `value as Id<"table">` at every such call site — an assertion,
|
|
732
732
|
* not a check, and one that has to be repeated for every table a helper is
|
|
733
733
|
* generic over:
|
|
734
734
|
*
|
|
@@ -794,8 +794,8 @@ interface PaginationResult<T = Record<string, unknown>> {
|
|
|
794
794
|
}
|
|
795
795
|
/**
|
|
796
796
|
* The fluent `ctx.db.query(table)` reader. Generic over the document type
|
|
797
|
-
* `Row` so the generated `ctx.db` can bind it to `Doc
|
|
798
|
-
* every terminal then resolve typed rows — no `as unknown as Doc
|
|
797
|
+
* `Row` so the generated `ctx.db` can bind it to `Doc<table>` (the chain and
|
|
798
|
+
* every terminal then resolve typed rows — no `as unknown as Doc<...>` casts),
|
|
799
799
|
* and over the table's declared index names so `.withIndex()` / `.withSearchIndex()`
|
|
800
800
|
* / `.withGeoIndex()` reject a name the table does not declare.
|
|
801
801
|
*
|
|
@@ -815,9 +815,9 @@ interface PaginationResult<T = Record<string, unknown>> {
|
|
|
815
815
|
* **Why `with*` are method signatures and everything else is a property.**
|
|
816
816
|
* Narrowing a parameter makes the enclosing type contravariant in it, so as
|
|
817
817
|
* function properties these would make a BOUND reader
|
|
818
|
-
* (`TableReader
|
|
819
|
-
* the unbound `TableReader
|
|
820
|
-
* `(reader: TableReader
|
|
818
|
+
* (`TableReader<Doc, "by_x">`, what `ctx.db.query(t)` returns) unassignable to
|
|
819
|
+
* the unbound `TableReader<Doc>` — quietly breaking every helper factored as
|
|
820
|
+
* `(reader: TableReader<Doc<"users">>) => …`, which is the obvious way to share
|
|
821
821
|
* query logic. A method signature is bivariant in its parameters, which keeps
|
|
822
822
|
* that direction working while the narrow parameter still rejects an undeclared
|
|
823
823
|
* name at the call site. Both directions are pinned in `types.test-d.ts`.
|
|
@@ -1122,8 +1122,8 @@ interface ScheduledJob {
|
|
|
1122
1122
|
shardKey?: string;
|
|
1123
1123
|
}
|
|
1124
1124
|
/**
|
|
1125
|
-
* A schedulable durable-workflow reference — the generated `workflows
|
|
1126
|
-
* `agents
|
|
1125
|
+
* A schedulable durable-workflow reference — the generated `workflows.<name>` /
|
|
1126
|
+
* `agents.<name>` object, which carries its `WORKFLOW_*`/`AGENT_*` binding and
|
|
1127
1127
|
* stable name. Structural mirror of `@lunora/scheduler`'s `WorkflowReference` so
|
|
1128
1128
|
* `ctx.scheduler` can target a workflow/agent without a dependency on
|
|
1129
1129
|
* `@lunora/scheduler` / `@lunora/workflow`. A scheduled workflow target starts a
|
|
@@ -1147,8 +1147,8 @@ interface Scheduler {
|
|
|
1147
1147
|
list: () => Promise<ScheduledJob[]>;
|
|
1148
1148
|
/**
|
|
1149
1149
|
* Schedule a one-shot run `delayMs` from now. `target` is a function path
|
|
1150
|
-
* (`"ns:fn"`) dispatched as a one-shot, or a generated `workflows
|
|
1151
|
-
* `agents
|
|
1150
|
+
* (`"ns:fn"`) dispatched as a one-shot, or a generated `workflows.<name>` /
|
|
1151
|
+
* `agents.<name>` reference which starts a fresh durable instance on fire
|
|
1152
1152
|
* (the args become its `params`).
|
|
1153
1153
|
*/
|
|
1154
1154
|
runAfter: (delayMs: number, target: SchedulableWorkflowReference | string, args?: Record<string, unknown>) => Promise<string>;
|
|
@@ -1370,12 +1370,12 @@ interface TriggerRankPageOptions {
|
|
|
1370
1370
|
/**
|
|
1371
1371
|
* Portable, table/id-addressed ORM writer handed to trigger handlers via
|
|
1372
1372
|
* `ctx.db`. Mirrors `@lunora/do`'s runtime `DatabaseWriterLike` surface — it is
|
|
1373
|
-
* **not** the generated per-table `ctx.db
|
|
1373
|
+
* **not** the generated per-table `ctx.db.<table>` facade (which can't be typed
|
|
1374
1374
|
* from inside `defineTable`, where the full schema isn't known).
|
|
1375
1375
|
*
|
|
1376
1376
|
* `aggregate`/`groupBy`/`count`/`rank`/`rankPage` route through the same
|
|
1377
1377
|
* trigger-maintained counter and rank tables the user-facing reader uses, so
|
|
1378
|
-
* a handler's `ctx.db
|
|
1378
|
+
* a handler's `ctx.db.<table>.aggregate(...)` observes the just-staged write
|
|
1379
1379
|
* within the same DO transaction (the counter step happens before the trigger
|
|
1380
1380
|
* fires).
|
|
1381
1381
|
*/
|
|
@@ -1562,7 +1562,7 @@ interface VectorSearch<IndexName extends string = string> extends VectorSearchRe
|
|
|
1562
1562
|
}
|
|
1563
1563
|
/**
|
|
1564
1564
|
* Structured, filterable key/value fields attached to a log line — the second
|
|
1565
|
-
* argument of a `ctx.log
|
|
1565
|
+
* argument of a `ctx.log.<level>(message, fields)` call, or the fields bound by
|
|
1566
1566
|
* `ctx.log.with(fields)`. They travel to an `ObservabilitySink`'s `onLog` and,
|
|
1567
1567
|
* for a network sink, become OTLP log-record attributes a log pipeline (or the
|
|
1568
1568
|
* Cloud log viewer) can filter and index on. Primitive values pass through;
|
|
@@ -1682,7 +1682,7 @@ interface SpanHandle {
|
|
|
1682
1682
|
addLink: (link: SpanLink) => void;
|
|
1683
1683
|
/**
|
|
1684
1684
|
* Attach an AI **evaluation** verdict to this (generation) span as the
|
|
1685
|
-
* `gen_ai.evaluation
|
|
1685
|
+
* `gen_ai.evaluation.<name>.score` / `.label` OpenTelemetry attributes, so a
|
|
1686
1686
|
* scorer's grade rides the same trace as the generation it graded. Convenience
|
|
1687
1687
|
* over {@link SpanHandle.setAttributes} that owns the key format; privacy-safe —
|
|
1688
1688
|
* only the name, score, and optional label are emitted. Throws on an empty name
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/server",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.62",
|
|
4
4
|
"description": "Server primitives for Lunora: defineSchema, defineTable, query, mutation, and action",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"backend",
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
"access": "public"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
70
|
-
"@lunora/scheduler": "1.0.0-alpha.
|
|
71
|
-
"@lunora/values": "1.0.0-alpha.
|
|
69
|
+
"@lunora/errors": "1.0.0-alpha.14",
|
|
70
|
+
"@lunora/scheduler": "1.0.0-alpha.21",
|
|
71
|
+
"@lunora/values": "1.0.0-alpha.19",
|
|
72
72
|
"drizzle-orm": "^0.45.2",
|
|
73
73
|
"hono": "^4.12.32"
|
|
74
74
|
},
|