@lunora/server 1.0.0-alpha.262 → 1.0.0-alpha.263
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/in-process.d.mts +18 -4
- package/dist/in-process.d.ts +18 -4
- package/dist/in-process.mjs +1 -1
- package/dist/index.d.mts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.mjs +1 -1
- package/dist/otel.d.mts +1 -1
- package/dist/otel.d.ts +1 -1
- package/dist/packem_shared/beginDeferredSchedules--FVDtp-M.mjs +1 -0
- package/dist/packem_shared/{types.d-CuZXI4PC.d.mts → types.d-BM3crF47.d.mts} +15 -3
- package/dist/packem_shared/{types.d-CuZXI4PC.d.ts → types.d-BM3crF47.d.ts} +15 -3
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +4 -4
- package/dist/packem_shared/beginDeferredSchedules-C7QLYr6C.mjs +0 -1
package/dist/in-process.d.mts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { SqlExec } from '@lunora/shard-engine';
|
|
2
|
-
import { D as DatabaseWriter, S as Schema } from "./packem_shared/types.d-
|
|
1
|
+
import { TransactionHeadroomTracker, SqlExec } from '@lunora/shard-engine';
|
|
2
|
+
import { D as DatabaseWriter, S as Schema } from "./packem_shared/types.d-BM3crF47.mjs";
|
|
3
3
|
import '@lunora/values';
|
|
4
|
+
/** Where the current dispatch's tracker lives: an `AsyncLocalStorage` fits, and so does any stand-in. */
|
|
5
|
+
interface HeadroomScope {
|
|
6
|
+
getStore: () => TransactionHeadroomTracker | undefined;
|
|
7
|
+
run: <R>(store: TransactionHeadroomTracker, body: () => R) => R;
|
|
8
|
+
}
|
|
4
9
|
/** The kind of a registered Lunora function. */
|
|
5
10
|
type FunctionKind = "action" | "mutation" | "query";
|
|
6
11
|
/**
|
|
@@ -38,6 +43,12 @@ interface InProcessRuntimeOptions {
|
|
|
38
43
|
* @default true
|
|
39
44
|
*/
|
|
40
45
|
enforceRls?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Where each dispatch's resource budget lives. Supply an `AsyncLocalStorage` when queries or
|
|
48
|
+
* actions can overlap, so a dispatch resumed after an await keeps its own budget; without one
|
|
49
|
+
* the budget is swapped at each entry, which is only right for entries that do not overlap.
|
|
50
|
+
*/
|
|
51
|
+
headroomScope?: HeadroomScope;
|
|
41
52
|
/**
|
|
42
53
|
* The `ctx.scheduler` the consumer installs, when it installs one. A
|
|
43
54
|
* scheduler wrapped with `withDeferredSchedules` has the jobs a mutation
|
|
@@ -59,8 +70,6 @@ interface InProcessRuntime {
|
|
|
59
70
|
database: DatabaseWriter;
|
|
60
71
|
rawDatabase: DatabaseWriter;
|
|
61
72
|
};
|
|
62
|
-
/** Start a new top-level dispatch with a full resource budget. Call before every query/action entry. */
|
|
63
|
-
resetHeadroom: () => void;
|
|
64
73
|
/**
|
|
65
74
|
* Run `body` as one top-level entry: serialized behind every other entry that
|
|
66
75
|
* came through here, inside a BEGIN/COMMIT span that rolls back on a throw,
|
|
@@ -68,6 +77,11 @@ interface InProcessRuntime {
|
|
|
68
77
|
* must not observe another entry's uncommitted writes may use it too.
|
|
69
78
|
*/
|
|
70
79
|
runInTransaction: <R>(body: () => Promise<R> | R) => Promise<R>;
|
|
80
|
+
/**
|
|
81
|
+
* Run `body` as one top-level dispatch with a full resource budget. Wrap every query/action entry.
|
|
82
|
+
* Replaces `resetHeadroom()`: call `runWithBudget(() => run())` where you called `resetHeadroom(); run()`.
|
|
83
|
+
*/
|
|
84
|
+
runWithBudget: <R>(body: () => R) => R;
|
|
71
85
|
}
|
|
72
86
|
/**
|
|
73
87
|
* Migrate `schema` onto `options.sql` and return the dispatch wiring around it.
|
package/dist/in-process.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { SqlExec } from '@lunora/shard-engine';
|
|
2
|
-
import { D as DatabaseWriter, S as Schema } from "./packem_shared/types.d-
|
|
1
|
+
import { TransactionHeadroomTracker, SqlExec } from '@lunora/shard-engine';
|
|
2
|
+
import { D as DatabaseWriter, S as Schema } from "./packem_shared/types.d-BM3crF47.js";
|
|
3
3
|
import '@lunora/values';
|
|
4
|
+
/** Where the current dispatch's tracker lives: an `AsyncLocalStorage` fits, and so does any stand-in. */
|
|
5
|
+
interface HeadroomScope {
|
|
6
|
+
getStore: () => TransactionHeadroomTracker | undefined;
|
|
7
|
+
run: <R>(store: TransactionHeadroomTracker, body: () => R) => R;
|
|
8
|
+
}
|
|
4
9
|
/** The kind of a registered Lunora function. */
|
|
5
10
|
type FunctionKind = "action" | "mutation" | "query";
|
|
6
11
|
/**
|
|
@@ -38,6 +43,12 @@ interface InProcessRuntimeOptions {
|
|
|
38
43
|
* @default true
|
|
39
44
|
*/
|
|
40
45
|
enforceRls?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Where each dispatch's resource budget lives. Supply an `AsyncLocalStorage` when queries or
|
|
48
|
+
* actions can overlap, so a dispatch resumed after an await keeps its own budget; without one
|
|
49
|
+
* the budget is swapped at each entry, which is only right for entries that do not overlap.
|
|
50
|
+
*/
|
|
51
|
+
headroomScope?: HeadroomScope;
|
|
41
52
|
/**
|
|
42
53
|
* The `ctx.scheduler` the consumer installs, when it installs one. A
|
|
43
54
|
* scheduler wrapped with `withDeferredSchedules` has the jobs a mutation
|
|
@@ -59,8 +70,6 @@ interface InProcessRuntime {
|
|
|
59
70
|
database: DatabaseWriter;
|
|
60
71
|
rawDatabase: DatabaseWriter;
|
|
61
72
|
};
|
|
62
|
-
/** Start a new top-level dispatch with a full resource budget. Call before every query/action entry. */
|
|
63
|
-
resetHeadroom: () => void;
|
|
64
73
|
/**
|
|
65
74
|
* Run `body` as one top-level entry: serialized behind every other entry that
|
|
66
75
|
* came through here, inside a BEGIN/COMMIT span that rolls back on a throw,
|
|
@@ -68,6 +77,11 @@ interface InProcessRuntime {
|
|
|
68
77
|
* must not observe another entry's uncommitted writes may use it too.
|
|
69
78
|
*/
|
|
70
79
|
runInTransaction: <R>(body: () => Promise<R> | R) => Promise<R>;
|
|
80
|
+
/**
|
|
81
|
+
* Run `body` as one top-level dispatch with a full resource budget. Wrap every query/action entry.
|
|
82
|
+
* Replaces `resetHeadroom()`: call `runWithBudget(() => run())` where you called `resetHeadroom(); run()`.
|
|
83
|
+
*/
|
|
84
|
+
runWithBudget: <R>(body: () => R) => R;
|
|
71
85
|
}
|
|
72
86
|
/**
|
|
73
87
|
* Migrate `schema` onto `options.sql` and return the dispatch wiring around it.
|
package/dist/in-process.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LunoraError as
|
|
1
|
+
import{LunoraError as R}from"@lunora/errors";import{TransactionHeadroomTracker as l,runShardMigrations as p,createShardCtxDb as w,RLS_UNWRAP_SYMBOL as T}from"@lunora/shard-engine";import{beginDeferredSchedules as g}from"./packem_shared/beginDeferredSchedules--FVDtp-M.mjs";import{bindTableFacade as S}from"./packem_shared/bindOrm-D5mVDvbi.mjs";class y extends l{fallback=new l;scope;constructor(r){super(),this.scope=r}run(r){return this.scope===void 0?(this.fallback=new l,r()):this.scope.run(new l,r)}headroom(){return this.current().headroom()}recordRead(r){this.current().recordRead(r)}recordReadBytes(r){this.current().recordReadBytes(r)}recordDocumentRead(r,n){this.current().recordDocumentRead(r,n)}recordWrite(r){this.current().recordWrite(r)}current(){return this.scope?.getStore()??this.fallback}}const C=e=>{if(e===null||typeof e.userId!="string"||e.userId.length===0)return{claims:null,userId:null};const{userId:r,...n}=e;return{claims:Object.keys(n).length>0?n:null,userId:r}},O=(e,r)=>{const{scheduler:n,sql:a}=r,i=e;p(a,i);const c=new y(r.headroomScope),m=t=>{const o=t;for(const s of Object.keys(i.tables))o[s]=S(t,s);return t};let u=!1;const I=t=>{const o=w({auth:{identity:t.claims,userId:t.userId},enforceRls:r.enforceRls??!0,headroom:c,inTransaction:()=>u,schema:i,sql:a}),s=o[T]??o;return{database:m(o),rawDatabase:m(s)}},d=t=>{a.exec.call(a,t)};let f=Promise.resolve();return{createWriters:I,runWithBudget:t=>c.run(t),runInTransaction:t=>{const o=async()=>{const b=g({scheduler:n});d("BEGIN"),u=!0;try{const h=await t();return d("COMMIT"),u=!1,await b(!0),h}catch(h){u=!1;try{d("ROLLBACK")}catch{}throw await b(!1),h}},s=f.then(()=>c.run(o));return f=s.then(()=>{},()=>{}),s}}},k=e=>{if(typeof e!="object"||e===null)return;const{kind:r}=e;if(r==="query"||r==="mutation"||r==="action")return r},P=(e,r,n,a,i)=>{const c=k(r);if(c!==e)throw new R("INTERNAL",`expected a registered ${e}, received a ${c??"non-function"} reference`);if(!i&&r.visibility==="internal")throw new R("INTERNAL",`This ${e} is an internal function — it is unreachable from the external RPC boundary in production. Call it through ctx.run${e.charAt(0).toUpperCase()}${e.slice(1)} from another function instead.`);return Promise.resolve(r.handler(n,a??{}))};export{O as createInProcessRuntime,k as registeredFunctionKind,C as resolveInProcessIdentity,P as runRegisteredFunction};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Validator, Infer, ColumnValidator, Id, StringColumnValidator, ValidatorMap, InferValidatorMap } from '@lunora/values';
|
|
2
2
|
export { type ColumnValidator, type GeoPoint, type Id, type Infer, ValidationError, type Validator, type ValidatorKind, v } from '@lunora/values';
|
|
3
|
-
import { A as ArgsValidator, I as InferArgs, R as RegisteredAction, E as ExposeConfig, X as X402ProcedureConfig, b as ActionCtx, c as RegisteredInternalAction, M as MutationCtx, d as RegisteredInternalMutation, Q as QueryCtx, e as RegisteredInternalQuery, f as DurableStreamOptions, g as RegisteredInternalStream, h as RegisteredMutation, i as RegisteredQuery, j as RegisteredStream, F as FunctionKind, T as TableDefinition, k as RegisteredFunction, V as VectorIndexDefinition, S as Schema, l as AggregateOp, G as GlobalBackend, K as KeyedRelationDefinition, m as RelationThrough, n as ThroughRelationDefinition, O as OnDeleteAction, o as RelationDefinition, p as SearchLanguage, q as SearchStrategy, r as ExternalSourceDefinition, s as TriggerBuilder, t as TriggerDefinition, u as VectorEmbedder, v as VectorMetric, w as DurableObjectJurisdiction, x as AggregateIndexDefinition, y as RankIndexDefinition, z as Secrets, B as LiveTopicRef, C as LifecycleEvent, H as ShardInitEvent, J as RegisteredLifecycleHook, W as WhisperEvent } from "./packem_shared/types.d-
|
|
4
|
-
export type { N as AuthState, P as CachePurge, U as DatabaseReader, D as DatabaseWriter, Y as FunctionVisibility, Z as GeoBoundingBox, _ as GeoFilterBuilder, $ as GeoIndexDefinition, a0 as GeoPointInput, a1 as IndexDefinition, a2 as IndexRangeBuilder, a3 as LifecycleEventKind, a4 as LogFields, a5 as LunoraLogMethod, a6 as LunoraLogger, a7 as LunoraMetrics, L as LunoraTracer, a8 as LunoraWideEvent, a9 as MutationStorage, aa as PaginationOptions, ab as PaginationResult, ac as PatchIfResult, ad as RankSortKey, ae as ReadOnlyStorage, af as RelatedDirection, ag as RelatedNode, ah as RelatedOptions, ai as RelatedPage, aj as RelatedStart, ak as RelatedStartReference, al as RestCacheConfig, am as RetryPolicy, an as RunQueryOptions, ao as
|
|
3
|
+
import { A as ArgsValidator, I as InferArgs, R as RegisteredAction, E as ExposeConfig, X as X402ProcedureConfig, b as ActionCtx, c as RegisteredInternalAction, M as MutationCtx, d as RegisteredInternalMutation, Q as QueryCtx, e as RegisteredInternalQuery, f as DurableStreamOptions, g as RegisteredInternalStream, h as RegisteredMutation, i as RegisteredQuery, j as RegisteredStream, F as FunctionKind, T as TableDefinition, k as RegisteredFunction, V as VectorIndexDefinition, S as Schema, l as AggregateOp, G as GlobalBackend, K as KeyedRelationDefinition, m as RelationThrough, n as ThroughRelationDefinition, O as OnDeleteAction, o as RelationDefinition, p as SearchLanguage, q as SearchStrategy, r as ExternalSourceDefinition, s as TriggerBuilder, t as TriggerDefinition, u as VectorEmbedder, v as VectorMetric, w as DurableObjectJurisdiction, x as AggregateIndexDefinition, y as RankIndexDefinition, z as Secrets, B as LiveTopicRef, C as LifecycleEvent, H as ShardInitEvent, J as RegisteredLifecycleHook, W as WhisperEvent } from "./packem_shared/types.d-BM3crF47.mjs";
|
|
4
|
+
export type { N as AuthState, P as CachePurge, U as DatabaseReader, D as DatabaseWriter, Y as FunctionVisibility, Z as GeoBoundingBox, _ as GeoFilterBuilder, $ as GeoIndexDefinition, a0 as GeoPointInput, a1 as IndexDefinition, a2 as IndexRangeBuilder, a3 as LifecycleEventKind, a4 as LogFields, a5 as LunoraLogMethod, a6 as LunoraLogger, a7 as LunoraMetrics, L as LunoraTracer, a8 as LunoraWideEvent, a9 as MutationStorage, aa as PaginationOptions, ab as PaginationResult, ac as PatchIfResult, ad as RankSortKey, ae as ReadOnlyStorage, af as RelatedDirection, ag as RelatedNode, ah as RelatedOptions, ai as RelatedPage, aj as RelatedStart, ak as RelatedStartReference, al as RestCacheConfig, am as RetryPolicy, an as RunQueryOptions, ao as ScheduleRunOptions, ap as ScheduledFunctionDoc, aq as ScheduledJob, ar as ScheduledJobState, as as ScheduledJobView, at as Scheduler, au as SearchFilterBuilder, av as SearchIndexDefinition, aw as ShardMode, ax as SpanContextIds, ay as SpanEvaluation, a as SpanHandle, az as SpanIdentity, aA as SpanKind, aB as SpanLink, aC as SpanOptions, aD as Storage, aE as StorageListOptions, aF as StorageListResult, aG as StorageMetadata, aH as StorageMultipartUpload, aI as StorageMultipartUploadOptions, aJ as StorageObjectBody, aK as StorageObjectHead, aL as StorageRange, aM as StorageUploadBody, aN as StorageUploadOptions, aO as StorageUploadResult, aP as StorageUploadedPart, aQ as SystemDatabaseReader, aR as SystemDoc, aS as SystemQuery, aT as SystemTableName, aU as TableReader, aV as TableVectorIndex, aW as TriggerAggregateOptions, aX as TriggerCtx, aY as TriggerDatabase, aZ as TriggerDeleteEvent, a_ as TriggerEvent, a$ as TriggerGroupByEntry, b0 as TriggerGroupByOptions, b1 as TriggerHandler, b2 as TriggerInsertEvent, b3 as TriggerOp, b4 as TriggerQueryArgs, b5 as TriggerQueryPage, b6 as TriggerRankOptions, b7 as TriggerRankPageOptions, b8 as TriggerRankResult, b9 as TriggerRow, ba as TriggerTiming, bb as TriggerUpdateEvent, bc as TtlDefinition, bd as VectorMatch, be as VectorMatches, bf as VectorQueryInput, bg as VectorRecord, bh as VectorSearch, bi as VectorSearchReader, bj as VectorUpsertInput, bk as WorkflowCreateOptions, bl as WorkflowEventDefinition, bm as WorkflowHandle, bn as WorkflowInstance, bo as WorkflowInstanceEvent, bp as WorkflowInstanceStatus, bq as WorkflowStatusResult, br as Workflows } from "./packem_shared/types.d-BM3crF47.mjs";
|
|
5
5
|
import { LunoraError } from '@lunora/errors';
|
|
6
6
|
export { LunoraError, type LunoraErrorCode } from '@lunora/errors';
|
|
7
7
|
import { Context, Hono, ExecutionContext } from 'hono';
|
|
@@ -1364,6 +1364,12 @@ interface ScheduleOutbox {
|
|
|
1364
1364
|
admit: (target: string) => number | undefined;
|
|
1365
1365
|
/** Release custody — the scheduler has the job, or the window that owned it was dropped. */
|
|
1366
1366
|
forget: (id: string) => void;
|
|
1367
|
+
/**
|
|
1368
|
+
* Run one post-commit hand-off under the store's eye and release custody when it lands, so an
|
|
1369
|
+
* operator who drops the entry while the call is still awaiting the scheduler is seen, and the
|
|
1370
|
+
* job is taken back out when it lands. When absent the facade runs the call and `forget`s the id.
|
|
1371
|
+
*/
|
|
1372
|
+
handOff?: (id: string, run: () => Promise<unknown>, token?: string) => Promise<void>;
|
|
1367
1373
|
/**
|
|
1368
1374
|
* Take custody of one buffered call. Runs INSIDE the transaction, so a throw
|
|
1369
1375
|
* here rolls the mutation back — which is the right answer, and the only
|
|
@@ -1378,7 +1384,7 @@ interface ScheduleOutbox {
|
|
|
1378
1384
|
options: Record<string, unknown> | undefined;
|
|
1379
1385
|
target: unknown;
|
|
1380
1386
|
when: number;
|
|
1381
|
-
}) =>
|
|
1387
|
+
}) => string | undefined;
|
|
1382
1388
|
/** Ask the host to wake its retry loop — called when a dispatch left entries behind. */
|
|
1383
1389
|
wake: () => void;
|
|
1384
1390
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Validator, Infer, ColumnValidator, Id, StringColumnValidator, ValidatorMap, InferValidatorMap } from '@lunora/values';
|
|
2
2
|
export { type ColumnValidator, type GeoPoint, type Id, type Infer, ValidationError, type Validator, type ValidatorKind, v } from '@lunora/values';
|
|
3
|
-
import { A as ArgsValidator, I as InferArgs, R as RegisteredAction, E as ExposeConfig, X as X402ProcedureConfig, b as ActionCtx, c as RegisteredInternalAction, M as MutationCtx, d as RegisteredInternalMutation, Q as QueryCtx, e as RegisteredInternalQuery, f as DurableStreamOptions, g as RegisteredInternalStream, h as RegisteredMutation, i as RegisteredQuery, j as RegisteredStream, F as FunctionKind, T as TableDefinition, k as RegisteredFunction, V as VectorIndexDefinition, S as Schema, l as AggregateOp, G as GlobalBackend, K as KeyedRelationDefinition, m as RelationThrough, n as ThroughRelationDefinition, O as OnDeleteAction, o as RelationDefinition, p as SearchLanguage, q as SearchStrategy, r as ExternalSourceDefinition, s as TriggerBuilder, t as TriggerDefinition, u as VectorEmbedder, v as VectorMetric, w as DurableObjectJurisdiction, x as AggregateIndexDefinition, y as RankIndexDefinition, z as Secrets, B as LiveTopicRef, C as LifecycleEvent, H as ShardInitEvent, J as RegisteredLifecycleHook, W as WhisperEvent } from "./packem_shared/types.d-
|
|
4
|
-
export type { N as AuthState, P as CachePurge, U as DatabaseReader, D as DatabaseWriter, Y as FunctionVisibility, Z as GeoBoundingBox, _ as GeoFilterBuilder, $ as GeoIndexDefinition, a0 as GeoPointInput, a1 as IndexDefinition, a2 as IndexRangeBuilder, a3 as LifecycleEventKind, a4 as LogFields, a5 as LunoraLogMethod, a6 as LunoraLogger, a7 as LunoraMetrics, L as LunoraTracer, a8 as LunoraWideEvent, a9 as MutationStorage, aa as PaginationOptions, ab as PaginationResult, ac as PatchIfResult, ad as RankSortKey, ae as ReadOnlyStorage, af as RelatedDirection, ag as RelatedNode, ah as RelatedOptions, ai as RelatedPage, aj as RelatedStart, ak as RelatedStartReference, al as RestCacheConfig, am as RetryPolicy, an as RunQueryOptions, ao as
|
|
3
|
+
import { A as ArgsValidator, I as InferArgs, R as RegisteredAction, E as ExposeConfig, X as X402ProcedureConfig, b as ActionCtx, c as RegisteredInternalAction, M as MutationCtx, d as RegisteredInternalMutation, Q as QueryCtx, e as RegisteredInternalQuery, f as DurableStreamOptions, g as RegisteredInternalStream, h as RegisteredMutation, i as RegisteredQuery, j as RegisteredStream, F as FunctionKind, T as TableDefinition, k as RegisteredFunction, V as VectorIndexDefinition, S as Schema, l as AggregateOp, G as GlobalBackend, K as KeyedRelationDefinition, m as RelationThrough, n as ThroughRelationDefinition, O as OnDeleteAction, o as RelationDefinition, p as SearchLanguage, q as SearchStrategy, r as ExternalSourceDefinition, s as TriggerBuilder, t as TriggerDefinition, u as VectorEmbedder, v as VectorMetric, w as DurableObjectJurisdiction, x as AggregateIndexDefinition, y as RankIndexDefinition, z as Secrets, B as LiveTopicRef, C as LifecycleEvent, H as ShardInitEvent, J as RegisteredLifecycleHook, W as WhisperEvent } from "./packem_shared/types.d-BM3crF47.js";
|
|
4
|
+
export type { N as AuthState, P as CachePurge, U as DatabaseReader, D as DatabaseWriter, Y as FunctionVisibility, Z as GeoBoundingBox, _ as GeoFilterBuilder, $ as GeoIndexDefinition, a0 as GeoPointInput, a1 as IndexDefinition, a2 as IndexRangeBuilder, a3 as LifecycleEventKind, a4 as LogFields, a5 as LunoraLogMethod, a6 as LunoraLogger, a7 as LunoraMetrics, L as LunoraTracer, a8 as LunoraWideEvent, a9 as MutationStorage, aa as PaginationOptions, ab as PaginationResult, ac as PatchIfResult, ad as RankSortKey, ae as ReadOnlyStorage, af as RelatedDirection, ag as RelatedNode, ah as RelatedOptions, ai as RelatedPage, aj as RelatedStart, ak as RelatedStartReference, al as RestCacheConfig, am as RetryPolicy, an as RunQueryOptions, ao as ScheduleRunOptions, ap as ScheduledFunctionDoc, aq as ScheduledJob, ar as ScheduledJobState, as as ScheduledJobView, at as Scheduler, au as SearchFilterBuilder, av as SearchIndexDefinition, aw as ShardMode, ax as SpanContextIds, ay as SpanEvaluation, a as SpanHandle, az as SpanIdentity, aA as SpanKind, aB as SpanLink, aC as SpanOptions, aD as Storage, aE as StorageListOptions, aF as StorageListResult, aG as StorageMetadata, aH as StorageMultipartUpload, aI as StorageMultipartUploadOptions, aJ as StorageObjectBody, aK as StorageObjectHead, aL as StorageRange, aM as StorageUploadBody, aN as StorageUploadOptions, aO as StorageUploadResult, aP as StorageUploadedPart, aQ as SystemDatabaseReader, aR as SystemDoc, aS as SystemQuery, aT as SystemTableName, aU as TableReader, aV as TableVectorIndex, aW as TriggerAggregateOptions, aX as TriggerCtx, aY as TriggerDatabase, aZ as TriggerDeleteEvent, a_ as TriggerEvent, a$ as TriggerGroupByEntry, b0 as TriggerGroupByOptions, b1 as TriggerHandler, b2 as TriggerInsertEvent, b3 as TriggerOp, b4 as TriggerQueryArgs, b5 as TriggerQueryPage, b6 as TriggerRankOptions, b7 as TriggerRankPageOptions, b8 as TriggerRankResult, b9 as TriggerRow, ba as TriggerTiming, bb as TriggerUpdateEvent, bc as TtlDefinition, bd as VectorMatch, be as VectorMatches, bf as VectorQueryInput, bg as VectorRecord, bh as VectorSearch, bi as VectorSearchReader, bj as VectorUpsertInput, bk as WorkflowCreateOptions, bl as WorkflowEventDefinition, bm as WorkflowHandle, bn as WorkflowInstance, bo as WorkflowInstanceEvent, bp as WorkflowInstanceStatus, bq as WorkflowStatusResult, br as Workflows } from "./packem_shared/types.d-BM3crF47.js";
|
|
5
5
|
import { LunoraError } from '@lunora/errors';
|
|
6
6
|
export { LunoraError, type LunoraErrorCode } from '@lunora/errors';
|
|
7
7
|
import { Context, Hono, ExecutionContext } from 'hono';
|
|
@@ -1364,6 +1364,12 @@ interface ScheduleOutbox {
|
|
|
1364
1364
|
admit: (target: string) => number | undefined;
|
|
1365
1365
|
/** Release custody — the scheduler has the job, or the window that owned it was dropped. */
|
|
1366
1366
|
forget: (id: string) => void;
|
|
1367
|
+
/**
|
|
1368
|
+
* Run one post-commit hand-off under the store's eye and release custody when it lands, so an
|
|
1369
|
+
* operator who drops the entry while the call is still awaiting the scheduler is seen, and the
|
|
1370
|
+
* job is taken back out when it lands. When absent the facade runs the call and `forget`s the id.
|
|
1371
|
+
*/
|
|
1372
|
+
handOff?: (id: string, run: () => Promise<unknown>, token?: string) => Promise<void>;
|
|
1367
1373
|
/**
|
|
1368
1374
|
* Take custody of one buffered call. Runs INSIDE the transaction, so a throw
|
|
1369
1375
|
* here rolls the mutation back — which is the right answer, and the only
|
|
@@ -1378,7 +1384,7 @@ interface ScheduleOutbox {
|
|
|
1378
1384
|
options: Record<string, unknown> | undefined;
|
|
1379
1385
|
target: unknown;
|
|
1380
1386
|
when: number;
|
|
1381
|
-
}) =>
|
|
1387
|
+
}) => string | undefined;
|
|
1382
1388
|
/** Ask the host to wake its retry loop — called when a dispatch left entries behind. */
|
|
1383
1389
|
wake: () => void;
|
|
1384
1390
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ACTION_CACHE_DEFAULT_TTL_MS as t,ACTION_CACHE_TABLE as i,actionCacheExtension as n,cacheKeyFor as f,defineActionCache as a}from"./packem_shared/ACTION_CACHE_DEFAULT_TTL_MS-DMYtb827.mjs";import{initLunora as s}from"./packem_shared/initLunora-DcvCGLL_.mjs";import{isPerDispatchMiddleware as p,tagPerDispatchMiddleware as x}from"./packem_shared/isPerDispatchMiddleware-DDQPatSm.mjs";import{createSecrets as l}from"./packem_shared/createSecrets-D6rLB42U.mjs";import{beginDeferredDeletes as u,flushDeferredDeletes as S,withDeferredDeletes as D}from"./packem_shared/beginDeferredDeletes-DhwFBbvs.mjs";import{beginDeferredSchedules as T,withDeferredSchedules as R}from"./packem_shared/beginDeferredSchedules-
|
|
1
|
+
import{ACTION_CACHE_DEFAULT_TTL_MS as t,ACTION_CACHE_TABLE as i,actionCacheExtension as n,cacheKeyFor as f,defineActionCache as a}from"./packem_shared/ACTION_CACHE_DEFAULT_TTL_MS-DMYtb827.mjs";import{initLunora as s}from"./packem_shared/initLunora-DcvCGLL_.mjs";import{isPerDispatchMiddleware as p,tagPerDispatchMiddleware as x}from"./packem_shared/isPerDispatchMiddleware-DDQPatSm.mjs";import{createSecrets as l}from"./packem_shared/createSecrets-D6rLB42U.mjs";import{beginDeferredDeletes as u,flushDeferredDeletes as S,withDeferredDeletes as D}from"./packem_shared/beginDeferredDeletes-DhwFBbvs.mjs";import{beginDeferredSchedules as T,withDeferredSchedules as R}from"./packem_shared/beginDeferredSchedules--FVDtp-M.mjs";import{DOCUMENT_HISTORY_REDACTED_FIELDS as g,DOCUMENT_HISTORY_TABLE as L,defineDocumentHistory as _,documentHistoryExtension as I}from"./packem_shared/DOCUMENT_HISTORY_REDACTED_FIELDS-MUPXbAHR.mjs";import{LunoraEnvError as M,defineEnv as P,redactSecrets as b}from"./packem_shared/LunoraEnvError-bkdMu_-N.mjs";import{bindOrm as O,bindTableFacade as F,defineLazyFacade as v}from"./packem_shared/bindOrm-D5mVDvbi.mjs";import{httpAction as U,httpRoute as H,httpRouter as k,lastEventId as w,sseEvent as B}from"./packem_shared/httpAction-DuAVtPa_.mjs";import{serveStorageObject as W}from"./packem_shared/serveStorageObject-CLz3qhNI.mjs";import{defineIdentity as Y}from"./packem_shared/defineIdentity-DwkNKwYa.mjs";import{default as G}from"./packem_shared/defineIdentityGuard-Bt8N65Zs.mjs";import{onConnect as K,onDisconnect as Q,onShardInit as X}from"./packem_shared/onConnect-BLRoOpv2.mjs";import{DEFAULT_LIMIT as Z,DEFAULT_MAX_LIMIT as $,clampLimit as ee,defineListArgs as re}from"./packem_shared/DEFAULT_LIMIT-pT_tV8R0.mjs";import{defineLiveStream as te,liveStreamRouter as ie}from"./packem_shared/defineLiveStream-BmMpdotv.mjs";import{defineMigration as fe}from"./packem_shared/defineMigration-CXOS0Bvq.mjs";import{defineModule as de}from"./packem_shared/defineModule-OecXWM3U.mjs";import{defineMutator as me}from"./packem_shared/defineMutator-DlLFSWbO.mjs";import{platformAdmin as xe}from"./packem_shared/platformAdmin-kczXQme8.mjs";import{c as le,d as Ee,a as ue,b as Se,e as De,f as he,g as Te,h as Re,i as Ae,j as ge,k as Le,m as _e}from"./packem_shared/plugin-D0ogWCbA.mjs";import{PRESENCE_DEFAULT_TTL_MS as Ce,PRESENCE_TABLE as Me,definePresence as Pe,presenceExtension as be}from"./packem_shared/PRESENCE_DEFAULT_TTL_MS-CKPKoWy_.mjs";import{PROCEDURE_META as Oe,UNLOADED_META as Fe,procedureMeta as ve}from"./packem_shared/PROCEDURE_META-DVzrXpfa.mjs";import{protectPublic as Ue}from"./packem_shared/protectPublic-Bi5_95aP.mjs";import{onQueryChange as ke}from"./packem_shared/onQueryChange-iuLzmyPs.mjs";import{defineRoom as Be}from"./packem_shared/defineRoom-CoGi-xwm.mjs";import{createServices as We}from"./packem_shared/createServices-IJvoqi0e.mjs";import{defineShape as Ye}from"./packem_shared/defineShape-JcqUI9iZ.mjs";import{defineWebSocket as Ge}from"./packem_shared/defineWebSocket-BHoy6_ox.mjs";import{onWhisper as Ke}from"./packem_shared/onWhisper-CfDbFLQh.mjs";import{LunoraError as Xe}from"@lunora/errors";import{cronJobs as Ze}from"@lunora/scheduler";import{ValidationError as er,v as rr}from"@lunora/values";import{allowAll as tr,deny as ir,isDeny as nr,toWhereInput as fr}from"./packem_shared/allowAll-DkRAgItV.mjs";import{asBucketStorage as dr}from"./packem_shared/asBucketStorage-DoGYOjq3.mjs";import{assertShapesDeclareReadPolicies as mr,buildRlsReadRegistry as pr,composeShapeReadWhere as xr}from"./packem_shared/assertShapesDeclareReadPolicies-BfxqaO3Z.mjs";import{buildMaskRegistry as lr}from"./packem_shared/buildMaskRegistry-DpWMtalG.mjs";import{createPolicyDsl as ur,definePermission as Sr,definePolicies as Dr,definePolicy as hr,defineRole as Tr}from"./packem_shared/createPolicyDsl-BZa6SqLJ.mjs";import{defineStorageRule as Ar,defineStorageRules as gr}from"./packem_shared/defineStorageRule-Dv4nJE0H.mjs";import{isSafeHeaderValue as _r}from"./packem_shared/isSafeHeaderValue-DswDADFy.mjs";import{mask as Cr}from"./packem_shared/mask-Wqcb6WNS.mjs";import{r as Pr}from"./packem_shared/middleware-D4Z_QWhU.mjs";import{storageRules as yr}from"./packem_shared/storageRules-DmYr_Gi9.mjs";const e="0.0.0";export{t as ACTION_CACHE_DEFAULT_TTL_MS,i as ACTION_CACHE_TABLE,Z as DEFAULT_LIMIT,$ as DEFAULT_MAX_LIMIT,g as DOCUMENT_HISTORY_REDACTED_FIELDS,L as DOCUMENT_HISTORY_TABLE,M as LunoraEnvError,Xe as LunoraError,Ce as PRESENCE_DEFAULT_TTL_MS,Me as PRESENCE_TABLE,Oe as PROCEDURE_META,Fe as UNLOADED_META,e as VERSION,er as ValidationError,n as actionCacheExtension,tr as allowAll,dr as asBucketStorage,mr as assertShapesDeclareReadPolicies,u as beginDeferredDeletes,T as beginDeferredSchedules,O as bindOrm,F as bindTableFacade,lr as buildMaskRegistry,pr as buildRlsReadRegistry,f as cacheKeyFor,ee as clampLimit,le as composePluginMiddleware,xr as composeShapeReadWhere,ur as createPolicyDsl,l as createSecrets,We as createServices,Ze as cronJobs,a as defineActionCache,Ee as defineAggregateIndex,ue as defineComponent,_ as defineDocumentHistory,P as defineEnv,Y as defineIdentity,G as defineIdentityGuard,v as defineLazyFacade,re as defineListArgs,te as defineLiveStream,fe as defineMigration,de as defineModule,me as defineMutator,Sr as definePermission,Se as definePlugin,Dr as definePolicies,hr as definePolicy,Pe as definePresence,De as defineRankIndex,Tr as defineRole,Be as defineRoom,he as defineSchema,Te as defineSchemaExtension,Ye as defineShape,Ar as defineStorageRule,gr as defineStorageRules,Re as defineTable,Ae as defineVectorIndex,Ge as defineWebSocket,ir as deny,I as documentHistoryExtension,S as flushDeferredDeletes,U as httpAction,H as httpRoute,k as httpRouter,ge as indexFieldsFromSchema,s as initLunora,Le as installPlugins,nr as isDeny,p as isPerDispatchMiddleware,_r as isSafeHeaderValue,w as lastEventId,ie as liveStreamRouter,Cr as mask,_e as mergeSchemaExtension,K as onConnect,Q as onDisconnect,ke as onQueryChange,X as onShardInit,Ke as onWhisper,xe as platformAdmin,be as presenceExtension,ve as procedureMeta,Ue as protectPublic,b as redactSecrets,Pr as rls,W as serveStorageObject,B as sseEvent,yr as storageRules,x as tagPerDispatchMiddleware,fr as toWhereInput,rr as v,D as withDeferredDeletes,R as withDeferredSchedules};
|
package/dist/otel.d.mts
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
* `@opentelemetry/api` is a PEER dependency: it keeps a module-global registry,
|
|
42
42
|
* so a second copy in the tree would silently split it.
|
|
43
43
|
*/
|
|
44
|
-
import { a as SpanHandle, L as LunoraTracer } from "./packem_shared/types.d-
|
|
44
|
+
import { a as SpanHandle, L as LunoraTracer } from "./packem_shared/types.d-BM3crF47.mjs";
|
|
45
45
|
import '@lunora/values';
|
|
46
46
|
/**
|
|
47
47
|
* @since 1.0.0
|
package/dist/otel.d.ts
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
* `@opentelemetry/api` is a PEER dependency: it keeps a module-global registry,
|
|
42
42
|
* so a second copy in the tree would silently split it.
|
|
43
43
|
*/
|
|
44
|
-
import { a as SpanHandle, L as LunoraTracer } from "./packem_shared/types.d-
|
|
44
|
+
import { a as SpanHandle, L as LunoraTracer } from "./packem_shared/types.d-BM3crF47.js";
|
|
45
45
|
import '@lunora/values';
|
|
46
46
|
/**
|
|
47
47
|
* @since 1.0.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{assertScheduleInstant as y,assertScheduleDelay as A,resolveScheduleId as O}from"@lunora/scheduler";import{encodeArgsOrThrow as S}from"@lunora/wire";const v=new WeakMap,b=o=>{if(typeof o=="string")return o;const n=o??{},e=n.__lunoraRef??n.binding;return typeof e=="string"?e:"<unknown>"},m=o=>{let n=o;for(;n!==void 0&&!n.open;)n=n.parent;return n},D=(o,n,e)=>o==="runAfter"?Math.max(n,e-Date.now()):Math.max(n,e),j=async(o,{id:n,run:e,token:t})=>{if(o?.handOff!==void 0){await o.handOff(n,e,t);return}await e(),o?.forget(n)},M=(o,n)=>{const e=o,t={decisions:new Map,innermost:void 0,outbox:n},a=(r,i,s,c,d)=>e[r].call(e,i,s,c,d),u=(r,i,s,c,d)=>{const l=b(s);t.decisions.has(l)||t.decisions.set(l,t.outbox?.admit(l));const g=t.decisions.get(l),h=g===void 0?i:D(r,i,g),w=t.innermost;if(w===void 0)return a(r,h,s,c,d);const p=O(d?.id),x=t.outbox?.record(p,{args:S(`ctx.scheduler.${r}`,b(s),c),options:d,target:s,when:Math.ceil(r==="runAfter"?Date.now()+h:h)});return w.pending.push({id:p,run:async()=>a(r,h,s,c,{...d,id:p}),token:x}),Promise.resolve(p)},f={...e,runAfter:(r,i,s,c)=>(A(r,"ctx.scheduler.runAfter"),u("runAfter",r,i,s,c)),runAt:(r,i,s,c)=>(y(r,Date.now(),"ctx.scheduler.runAt"),u("runAt",r,i,s,c))};return Object.setPrototypeOf(f,Object.getPrototypeOf(e)),v.set(f,t),f},P=o=>{const{scheduler:n}=o,e=typeof n=="object"&&n!==null?v.get(n):void 0;if(!e)return async()=>{};const t={open:!0,parent:e.innermost,pending:[]};return e.innermost=t,async a=>{if(!t.open)return;t.open=!1,e.innermost===t&&(e.innermost=m(t.parent));const u=t.pending.splice(0);if(u.length===0)return;if(!a){for(const{id:c}of u)e.outbox?.forget(c);return}const f=m(t.parent);if(f!==void 0){f.pending.push(...u);return}const r=[];for(const c of u)try{await j(e.outbox,c)}catch(d){r.push(d)}const[i,...s]=r;if(i!==void 0)throw e.outbox?.wake(),s.length===0?i:new AggregateError(r,`ctx.scheduler: ${String(r.length)} of ${String(u.length)} deferred jobs failed to reach the scheduler after the commit`)}};export{P as beginDeferredSchedules,M as withDeferredSchedules};
|
|
@@ -1861,6 +1861,13 @@ interface RetryPolicy {
|
|
|
1861
1861
|
backoff?: "exponential" | "linear";
|
|
1862
1862
|
/** Base delay in milliseconds for the first retry. Default `30_000`. */
|
|
1863
1863
|
baseMs?: number;
|
|
1864
|
+
/**
|
|
1865
|
+
* Keep retrying instead of dead-lettering, overriding `maxAttempts`. Delays are clamped to between
|
|
1866
|
+
* 1 second and 30 minutes, so a `maxMs` below the ceiling sets how often a failing job retries.
|
|
1867
|
+
* `cancel` applies once the scheduler has accepted the job; while it is still in a shard's outbox
|
|
1868
|
+
* custody, drop it from Studio's Outbox view. Honoured by SchedulerDO.
|
|
1869
|
+
*/
|
|
1870
|
+
forever?: boolean;
|
|
1864
1871
|
/** Maximum number of dispatch attempts before dead-lettering. Default `5`. */
|
|
1865
1872
|
maxAttempts?: number;
|
|
1866
1873
|
/** Optional ceiling clamping the computed backoff delay. */
|
|
@@ -1943,6 +1950,11 @@ interface SchedulableWorkflowReference {
|
|
|
1943
1950
|
* A `query` is not schedulable — a deferred job exists to have an effect.
|
|
1944
1951
|
*/
|
|
1945
1952
|
type SchedulableTarget = FunctionHandle<"action" | "mutation", unknown, unknown> | SchedulableWorkflowReference | string;
|
|
1953
|
+
/** Per-call options for {@link Scheduler.runAfter} / {@link Scheduler.runAt}. */
|
|
1954
|
+
interface ScheduleRunOptions {
|
|
1955
|
+
/** Retry policy for this job; the scheduler's defaults apply when omitted. */
|
|
1956
|
+
retry?: RetryPolicy;
|
|
1957
|
+
}
|
|
1946
1958
|
interface Scheduler {
|
|
1947
1959
|
/** Cancel a pending job by id. `cancelled` is `false` when no such job exists. */
|
|
1948
1960
|
cancel: (id: string) => Promise<{
|
|
@@ -1957,9 +1969,9 @@ interface Scheduler {
|
|
|
1957
1969
|
* for the accepted targets. A workflow/agent reference starts a fresh
|
|
1958
1970
|
* durable instance on fire (the args become its `params`).
|
|
1959
1971
|
*/
|
|
1960
|
-
runAfter: (delayMs: number, target: SchedulableTarget, args?: Record<string, unknown
|
|
1972
|
+
runAfter: (delayMs: number, target: SchedulableTarget, args?: Record<string, unknown>, options?: ScheduleRunOptions) => Promise<string>;
|
|
1961
1973
|
/** Like {@link Scheduler.runAfter} but fires at an absolute epoch-ms timestamp. */
|
|
1962
|
-
runAt: (timestampMs: number, target: SchedulableTarget, args?: Record<string, unknown
|
|
1974
|
+
runAt: (timestampMs: number, target: SchedulableTarget, args?: Record<string, unknown>, options?: ScheduleRunOptions) => Promise<string>;
|
|
1963
1975
|
}
|
|
1964
1976
|
/**
|
|
1965
1977
|
* A workflow instance's lifecycle status. Clean public mirror of
|
|
@@ -2984,4 +2996,4 @@ interface ActionCtx {
|
|
|
2984
2996
|
/** Start / resume / inspect durable workflows; see {@link Workflows}. */
|
|
2985
2997
|
readonly workflows: Workflows;
|
|
2986
2998
|
}
|
|
2987
|
-
export { GeoIndexDefinition as $, ArgsValidator as A, LiveTopicRef as B, LifecycleEvent as C, DatabaseWriter as D, ExposeConfig as E, FunctionKind as F, GlobalBackend as G, ShardInitEvent as H, InferArgs as I, RegisteredLifecycleHook as J, KeyedRelationDefinition as K, LunoraTracer as L, MutationCtx as M, AuthState as N, OnDeleteAction as O, CachePurge as P, QueryCtx as Q, RegisteredAction as R, Schema as S, TableDefinition as T, DatabaseReader as U, VectorIndexDefinition as V, WhisperEvent as W, X402ProcedureConfig as X, FunctionVisibility as Y, GeoBoundingBox as Z, GeoFilterBuilder as _, SpanHandle as a,
|
|
2999
|
+
export { GeoIndexDefinition as $, ArgsValidator as A, LiveTopicRef as B, LifecycleEvent as C, DatabaseWriter as D, ExposeConfig as E, FunctionKind as F, GlobalBackend as G, ShardInitEvent as H, InferArgs as I, RegisteredLifecycleHook as J, KeyedRelationDefinition as K, LunoraTracer as L, MutationCtx as M, AuthState as N, OnDeleteAction as O, CachePurge as P, QueryCtx as Q, RegisteredAction as R, Schema as S, TableDefinition as T, DatabaseReader as U, VectorIndexDefinition as V, WhisperEvent as W, X402ProcedureConfig as X, FunctionVisibility as Y, GeoBoundingBox as Z, GeoFilterBuilder as _, SpanHandle as a, TriggerGroupByEntry as a$, GeoPointInput as a0, IndexDefinition as a1, IndexRangeBuilder as a2, LifecycleEventKind as a3, LogFields as a4, LunoraLogMethod as a5, LunoraLogger as a6, LunoraMetrics as a7, LunoraWideEvent as a8, MutationStorage as a9, SpanKind as aA, SpanLink as aB, SpanOptions as aC, Storage as aD, StorageListOptions as aE, StorageListResult as aF, StorageMetadata as aG, StorageMultipartUpload as aH, StorageMultipartUploadOptions as aI, StorageObjectBody as aJ, StorageObjectHead as aK, StorageRange as aL, StorageUploadBody as aM, StorageUploadOptions as aN, StorageUploadResult as aO, StorageUploadedPart as aP, SystemDatabaseReader as aQ, SystemDoc as aR, SystemQuery as aS, SystemTableName as aT, TableReader as aU, TableVectorIndex as aV, TriggerAggregateOptions as aW, TriggerCtx as aX, TriggerDatabase as aY, TriggerDeleteEvent as aZ, TriggerEvent as a_, PaginationOptions as aa, PaginationResult as ab, PatchIfResult as ac, RankSortKey as ad, ReadOnlyStorage as ae, RelatedDirection as af, RelatedNode as ag, RelatedOptions as ah, RelatedPage as ai, RelatedStart as aj, RelatedStartReference as ak, RestCacheConfig as al, RetryPolicy as am, RunQueryOptions as an, ScheduleRunOptions as ao, ScheduledFunctionDoc as ap, ScheduledJob as aq, ScheduledJobState as ar, ScheduledJobView as as, Scheduler as at, SearchFilterBuilder as au, SearchIndexDefinition as av, ShardMode as aw, SpanContextIds as ax, SpanEvaluation as ay, SpanIdentity as az, ActionCtx as b, TriggerGroupByOptions as b0, TriggerHandler as b1, TriggerInsertEvent as b2, TriggerOp as b3, TriggerQueryArgs as b4, TriggerQueryPage as b5, TriggerRankOptions as b6, TriggerRankPageOptions as b7, TriggerRankResult as b8, TriggerRow as b9, TriggerTiming as ba, TriggerUpdateEvent as bb, TtlDefinition as bc, VectorMatch as bd, VectorMatches as be, VectorQueryInput as bf, VectorRecord as bg, VectorSearch as bh, VectorSearchReader as bi, VectorUpsertInput as bj, WorkflowCreateOptions as bk, WorkflowEventDefinition as bl, WorkflowHandle as bm, WorkflowInstance as bn, WorkflowInstanceEvent as bo, WorkflowInstanceStatus as bp, WorkflowStatusResult as bq, Workflows as br, ExternalSourceCursor as bs, ExternalSourceMode as bt, ExternalSourceRefresh as bu, SecretsStoreSecretLike as bv, RegisteredInternalAction as c, RegisteredInternalMutation as d, RegisteredInternalQuery as e, DurableStreamOptions as f, RegisteredInternalStream as g, RegisteredMutation as h, RegisteredQuery as i, RegisteredStream as j, RegisteredFunction as k, AggregateOp as l, RelationThrough as m, ThroughRelationDefinition as n, RelationDefinition as o, SearchLanguage as p, SearchStrategy as q, ExternalSourceDefinition as r, TriggerBuilder as s, TriggerDefinition as t, VectorEmbedder as u, VectorMetric as v, DurableObjectJurisdiction as w, AggregateIndexDefinition as x, RankIndexDefinition as y, Secrets as z };
|
|
@@ -1861,6 +1861,13 @@ interface RetryPolicy {
|
|
|
1861
1861
|
backoff?: "exponential" | "linear";
|
|
1862
1862
|
/** Base delay in milliseconds for the first retry. Default `30_000`. */
|
|
1863
1863
|
baseMs?: number;
|
|
1864
|
+
/**
|
|
1865
|
+
* Keep retrying instead of dead-lettering, overriding `maxAttempts`. Delays are clamped to between
|
|
1866
|
+
* 1 second and 30 minutes, so a `maxMs` below the ceiling sets how often a failing job retries.
|
|
1867
|
+
* `cancel` applies once the scheduler has accepted the job; while it is still in a shard's outbox
|
|
1868
|
+
* custody, drop it from Studio's Outbox view. Honoured by SchedulerDO.
|
|
1869
|
+
*/
|
|
1870
|
+
forever?: boolean;
|
|
1864
1871
|
/** Maximum number of dispatch attempts before dead-lettering. Default `5`. */
|
|
1865
1872
|
maxAttempts?: number;
|
|
1866
1873
|
/** Optional ceiling clamping the computed backoff delay. */
|
|
@@ -1943,6 +1950,11 @@ interface SchedulableWorkflowReference {
|
|
|
1943
1950
|
* A `query` is not schedulable — a deferred job exists to have an effect.
|
|
1944
1951
|
*/
|
|
1945
1952
|
type SchedulableTarget = FunctionHandle<"action" | "mutation", unknown, unknown> | SchedulableWorkflowReference | string;
|
|
1953
|
+
/** Per-call options for {@link Scheduler.runAfter} / {@link Scheduler.runAt}. */
|
|
1954
|
+
interface ScheduleRunOptions {
|
|
1955
|
+
/** Retry policy for this job; the scheduler's defaults apply when omitted. */
|
|
1956
|
+
retry?: RetryPolicy;
|
|
1957
|
+
}
|
|
1946
1958
|
interface Scheduler {
|
|
1947
1959
|
/** Cancel a pending job by id. `cancelled` is `false` when no such job exists. */
|
|
1948
1960
|
cancel: (id: string) => Promise<{
|
|
@@ -1957,9 +1969,9 @@ interface Scheduler {
|
|
|
1957
1969
|
* for the accepted targets. A workflow/agent reference starts a fresh
|
|
1958
1970
|
* durable instance on fire (the args become its `params`).
|
|
1959
1971
|
*/
|
|
1960
|
-
runAfter: (delayMs: number, target: SchedulableTarget, args?: Record<string, unknown
|
|
1972
|
+
runAfter: (delayMs: number, target: SchedulableTarget, args?: Record<string, unknown>, options?: ScheduleRunOptions) => Promise<string>;
|
|
1961
1973
|
/** Like {@link Scheduler.runAfter} but fires at an absolute epoch-ms timestamp. */
|
|
1962
|
-
runAt: (timestampMs: number, target: SchedulableTarget, args?: Record<string, unknown
|
|
1974
|
+
runAt: (timestampMs: number, target: SchedulableTarget, args?: Record<string, unknown>, options?: ScheduleRunOptions) => Promise<string>;
|
|
1963
1975
|
}
|
|
1964
1976
|
/**
|
|
1965
1977
|
* A workflow instance's lifecycle status. Clean public mirror of
|
|
@@ -2984,4 +2996,4 @@ interface ActionCtx {
|
|
|
2984
2996
|
/** Start / resume / inspect durable workflows; see {@link Workflows}. */
|
|
2985
2997
|
readonly workflows: Workflows;
|
|
2986
2998
|
}
|
|
2987
|
-
export { GeoIndexDefinition as $, ArgsValidator as A, LiveTopicRef as B, LifecycleEvent as C, DatabaseWriter as D, ExposeConfig as E, FunctionKind as F, GlobalBackend as G, ShardInitEvent as H, InferArgs as I, RegisteredLifecycleHook as J, KeyedRelationDefinition as K, LunoraTracer as L, MutationCtx as M, AuthState as N, OnDeleteAction as O, CachePurge as P, QueryCtx as Q, RegisteredAction as R, Schema as S, TableDefinition as T, DatabaseReader as U, VectorIndexDefinition as V, WhisperEvent as W, X402ProcedureConfig as X, FunctionVisibility as Y, GeoBoundingBox as Z, GeoFilterBuilder as _, SpanHandle as a,
|
|
2999
|
+
export { GeoIndexDefinition as $, ArgsValidator as A, LiveTopicRef as B, LifecycleEvent as C, DatabaseWriter as D, ExposeConfig as E, FunctionKind as F, GlobalBackend as G, ShardInitEvent as H, InferArgs as I, RegisteredLifecycleHook as J, KeyedRelationDefinition as K, LunoraTracer as L, MutationCtx as M, AuthState as N, OnDeleteAction as O, CachePurge as P, QueryCtx as Q, RegisteredAction as R, Schema as S, TableDefinition as T, DatabaseReader as U, VectorIndexDefinition as V, WhisperEvent as W, X402ProcedureConfig as X, FunctionVisibility as Y, GeoBoundingBox as Z, GeoFilterBuilder as _, SpanHandle as a, TriggerGroupByEntry as a$, GeoPointInput as a0, IndexDefinition as a1, IndexRangeBuilder as a2, LifecycleEventKind as a3, LogFields as a4, LunoraLogMethod as a5, LunoraLogger as a6, LunoraMetrics as a7, LunoraWideEvent as a8, MutationStorage as a9, SpanKind as aA, SpanLink as aB, SpanOptions as aC, Storage as aD, StorageListOptions as aE, StorageListResult as aF, StorageMetadata as aG, StorageMultipartUpload as aH, StorageMultipartUploadOptions as aI, StorageObjectBody as aJ, StorageObjectHead as aK, StorageRange as aL, StorageUploadBody as aM, StorageUploadOptions as aN, StorageUploadResult as aO, StorageUploadedPart as aP, SystemDatabaseReader as aQ, SystemDoc as aR, SystemQuery as aS, SystemTableName as aT, TableReader as aU, TableVectorIndex as aV, TriggerAggregateOptions as aW, TriggerCtx as aX, TriggerDatabase as aY, TriggerDeleteEvent as aZ, TriggerEvent as a_, PaginationOptions as aa, PaginationResult as ab, PatchIfResult as ac, RankSortKey as ad, ReadOnlyStorage as ae, RelatedDirection as af, RelatedNode as ag, RelatedOptions as ah, RelatedPage as ai, RelatedStart as aj, RelatedStartReference as ak, RestCacheConfig as al, RetryPolicy as am, RunQueryOptions as an, ScheduleRunOptions as ao, ScheduledFunctionDoc as ap, ScheduledJob as aq, ScheduledJobState as ar, ScheduledJobView as as, Scheduler as at, SearchFilterBuilder as au, SearchIndexDefinition as av, ShardMode as aw, SpanContextIds as ax, SpanEvaluation as ay, SpanIdentity as az, ActionCtx as b, TriggerGroupByOptions as b0, TriggerHandler as b1, TriggerInsertEvent as b2, TriggerOp as b3, TriggerQueryArgs as b4, TriggerQueryPage as b5, TriggerRankOptions as b6, TriggerRankPageOptions as b7, TriggerRankResult as b8, TriggerRow as b9, TriggerTiming as ba, TriggerUpdateEvent as bb, TtlDefinition as bc, VectorMatch as bd, VectorMatches as be, VectorQueryInput as bf, VectorRecord as bg, VectorSearch as bh, VectorSearchReader as bi, VectorUpsertInput as bj, WorkflowCreateOptions as bk, WorkflowEventDefinition as bl, WorkflowHandle as bm, WorkflowInstance as bn, WorkflowInstanceEvent as bo, WorkflowInstanceStatus as bp, WorkflowStatusResult as bq, Workflows as br, ExternalSourceCursor as bs, ExternalSourceMode as bt, ExternalSourceRefresh as bu, SecretsStoreSecretLike as bv, RegisteredInternalAction as c, RegisteredInternalMutation as d, RegisteredInternalQuery as e, DurableStreamOptions as f, RegisteredInternalStream as g, RegisteredMutation as h, RegisteredQuery as i, RegisteredStream as j, RegisteredFunction as k, AggregateOp as l, RelationThrough as m, ThroughRelationDefinition as n, RelationDefinition as o, SearchLanguage as p, SearchStrategy as q, ExternalSourceDefinition as r, TriggerBuilder as s, TriggerDefinition as t, VectorEmbedder as u, VectorMetric as v, DurableObjectJurisdiction as w, AggregateIndexDefinition as x, RankIndexDefinition as y, Secrets as z };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { b as ActionCtx, x as AggregateIndexDefinition, l as AggregateOp, A as ArgsValidator, N as AuthState, P as CachePurge, U as DatabaseReader, D as DatabaseWriter, w as DurableObjectJurisdiction, f as DurableStreamOptions, E as ExposeConfig,
|
|
1
|
+
export type { b as ActionCtx, x as AggregateIndexDefinition, l as AggregateOp, A as ArgsValidator, N as AuthState, P as CachePurge, U as DatabaseReader, D as DatabaseWriter, w as DurableObjectJurisdiction, f as DurableStreamOptions, E as ExposeConfig, bs as ExternalSourceCursor, r as ExternalSourceDefinition, bt as ExternalSourceMode, bu as ExternalSourceRefresh, F as FunctionKind, Y as FunctionVisibility, Z as GeoBoundingBox, _ as GeoFilterBuilder, $ as GeoIndexDefinition, a0 as GeoPointInput, G as GlobalBackend, a1 as IndexDefinition, a2 as IndexRangeBuilder, I as InferArgs, K as KeyedRelationDefinition, C as LifecycleEvent, a3 as LifecycleEventKind, a4 as LogFields, a5 as LunoraLogMethod, a6 as LunoraLogger, a7 as LunoraMetrics, L as LunoraTracer, a8 as LunoraWideEvent, M as MutationCtx, a9 as MutationStorage, O as OnDeleteAction, aa as PaginationOptions, ab as PaginationResult, ac as PatchIfResult, Q as QueryCtx, y as RankIndexDefinition, ad as RankSortKey, ae as ReadOnlyStorage, R as RegisteredAction, k as RegisteredFunction, c as RegisteredInternalAction, d as RegisteredInternalMutation, e as RegisteredInternalQuery, g as RegisteredInternalStream, J as RegisteredLifecycleHook, h as RegisteredMutation, i as RegisteredQuery, j as RegisteredStream, af as RelatedDirection, ag as RelatedNode, ah as RelatedOptions, ai as RelatedPage, aj as RelatedStart, ak as RelatedStartReference, o as RelationDefinition, m as RelationThrough, al as RestCacheConfig, am as RetryPolicy, an as RunQueryOptions, ao as ScheduleRunOptions, ap as ScheduledFunctionDoc, aq as ScheduledJob, ar as ScheduledJobState, as as ScheduledJobView, at as Scheduler, S as Schema, au as SearchFilterBuilder, av as SearchIndexDefinition, p as SearchLanguage, q as SearchStrategy, z as Secrets, bv as SecretsStoreSecretLike, H as ShardInitEvent, aw as ShardMode, ax as SpanContextIds, ay as SpanEvaluation, a as SpanHandle, az as SpanIdentity, aA as SpanKind, aB as SpanLink, aC as SpanOptions, aD as Storage, aE as StorageListOptions, aF as StorageListResult, aG as StorageMetadata, aH as StorageMultipartUpload, aI as StorageMultipartUploadOptions, aJ as StorageObjectBody, aK as StorageObjectHead, aL as StorageRange, aM as StorageUploadBody, aN as StorageUploadOptions, aO as StorageUploadResult, aP as StorageUploadedPart, aQ as SystemDatabaseReader, aR as SystemDoc, aS as SystemQuery, aT as SystemTableName, T as TableDefinition, aU as TableReader, aV as TableVectorIndex, n as ThroughRelationDefinition, aW as TriggerAggregateOptions, s as TriggerBuilder, aX as TriggerCtx, aY as TriggerDatabase, t as TriggerDefinition, aZ as TriggerDeleteEvent, a_ as TriggerEvent, a$ as TriggerGroupByEntry, b0 as TriggerGroupByOptions, b1 as TriggerHandler, b2 as TriggerInsertEvent, b3 as TriggerOp, b4 as TriggerQueryArgs, b5 as TriggerQueryPage, b6 as TriggerRankOptions, b7 as TriggerRankPageOptions, b8 as TriggerRankResult, b9 as TriggerRow, ba as TriggerTiming, bb as TriggerUpdateEvent, bc as TtlDefinition, u as VectorEmbedder, V as VectorIndexDefinition, bd as VectorMatch, be as VectorMatches, v as VectorMetric, bf as VectorQueryInput, bg as VectorRecord, bh as VectorSearch, bi as VectorSearchReader, bj as VectorUpsertInput, W as WhisperEvent, bk as WorkflowCreateOptions, bl as WorkflowEventDefinition, bm as WorkflowHandle, bn as WorkflowInstance, bo as WorkflowInstanceEvent, bp as WorkflowInstanceStatus, bq as WorkflowStatusResult, br as Workflows, X as X402ProcedureConfig } from "./packem_shared/types.d-BM3crF47.mjs";
|
|
2
2
|
import '@lunora/values';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { b as ActionCtx, x as AggregateIndexDefinition, l as AggregateOp, A as ArgsValidator, N as AuthState, P as CachePurge, U as DatabaseReader, D as DatabaseWriter, w as DurableObjectJurisdiction, f as DurableStreamOptions, E as ExposeConfig,
|
|
1
|
+
export type { b as ActionCtx, x as AggregateIndexDefinition, l as AggregateOp, A as ArgsValidator, N as AuthState, P as CachePurge, U as DatabaseReader, D as DatabaseWriter, w as DurableObjectJurisdiction, f as DurableStreamOptions, E as ExposeConfig, bs as ExternalSourceCursor, r as ExternalSourceDefinition, bt as ExternalSourceMode, bu as ExternalSourceRefresh, F as FunctionKind, Y as FunctionVisibility, Z as GeoBoundingBox, _ as GeoFilterBuilder, $ as GeoIndexDefinition, a0 as GeoPointInput, G as GlobalBackend, a1 as IndexDefinition, a2 as IndexRangeBuilder, I as InferArgs, K as KeyedRelationDefinition, C as LifecycleEvent, a3 as LifecycleEventKind, a4 as LogFields, a5 as LunoraLogMethod, a6 as LunoraLogger, a7 as LunoraMetrics, L as LunoraTracer, a8 as LunoraWideEvent, M as MutationCtx, a9 as MutationStorage, O as OnDeleteAction, aa as PaginationOptions, ab as PaginationResult, ac as PatchIfResult, Q as QueryCtx, y as RankIndexDefinition, ad as RankSortKey, ae as ReadOnlyStorage, R as RegisteredAction, k as RegisteredFunction, c as RegisteredInternalAction, d as RegisteredInternalMutation, e as RegisteredInternalQuery, g as RegisteredInternalStream, J as RegisteredLifecycleHook, h as RegisteredMutation, i as RegisteredQuery, j as RegisteredStream, af as RelatedDirection, ag as RelatedNode, ah as RelatedOptions, ai as RelatedPage, aj as RelatedStart, ak as RelatedStartReference, o as RelationDefinition, m as RelationThrough, al as RestCacheConfig, am as RetryPolicy, an as RunQueryOptions, ao as ScheduleRunOptions, ap as ScheduledFunctionDoc, aq as ScheduledJob, ar as ScheduledJobState, as as ScheduledJobView, at as Scheduler, S as Schema, au as SearchFilterBuilder, av as SearchIndexDefinition, p as SearchLanguage, q as SearchStrategy, z as Secrets, bv as SecretsStoreSecretLike, H as ShardInitEvent, aw as ShardMode, ax as SpanContextIds, ay as SpanEvaluation, a as SpanHandle, az as SpanIdentity, aA as SpanKind, aB as SpanLink, aC as SpanOptions, aD as Storage, aE as StorageListOptions, aF as StorageListResult, aG as StorageMetadata, aH as StorageMultipartUpload, aI as StorageMultipartUploadOptions, aJ as StorageObjectBody, aK as StorageObjectHead, aL as StorageRange, aM as StorageUploadBody, aN as StorageUploadOptions, aO as StorageUploadResult, aP as StorageUploadedPart, aQ as SystemDatabaseReader, aR as SystemDoc, aS as SystemQuery, aT as SystemTableName, T as TableDefinition, aU as TableReader, aV as TableVectorIndex, n as ThroughRelationDefinition, aW as TriggerAggregateOptions, s as TriggerBuilder, aX as TriggerCtx, aY as TriggerDatabase, t as TriggerDefinition, aZ as TriggerDeleteEvent, a_ as TriggerEvent, a$ as TriggerGroupByEntry, b0 as TriggerGroupByOptions, b1 as TriggerHandler, b2 as TriggerInsertEvent, b3 as TriggerOp, b4 as TriggerQueryArgs, b5 as TriggerQueryPage, b6 as TriggerRankOptions, b7 as TriggerRankPageOptions, b8 as TriggerRankResult, b9 as TriggerRow, ba as TriggerTiming, bb as TriggerUpdateEvent, bc as TtlDefinition, u as VectorEmbedder, V as VectorIndexDefinition, bd as VectorMatch, be as VectorMatches, v as VectorMetric, bf as VectorQueryInput, bg as VectorRecord, bh as VectorSearch, bi as VectorSearchReader, bj as VectorUpsertInput, W as WhisperEvent, bk as WorkflowCreateOptions, bl as WorkflowEventDefinition, bm as WorkflowHandle, bn as WorkflowInstance, bo as WorkflowInstanceEvent, bp as WorkflowInstanceStatus, bq as WorkflowStatusResult, br as Workflows, X as X402ProcedureConfig } from "./packem_shared/types.d-BM3crF47.js";
|
|
2
2
|
import '@lunora/values';
|
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.263",
|
|
4
4
|
"description": "Server primitives for Lunora: defineSchema, defineTable, query, mutation, and action",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"backend",
|
|
@@ -73,9 +73,9 @@
|
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@lunora/errors": ">=1.0.0-alpha.77 <2.0.0-0",
|
|
76
|
-
"@lunora/scheduler": "1.0.0-alpha.
|
|
77
|
-
"@lunora/shard-engine": "1.0.0-alpha.
|
|
78
|
-
"@lunora/values": "1.0.0-alpha.
|
|
76
|
+
"@lunora/scheduler": "1.0.0-alpha.165",
|
|
77
|
+
"@lunora/shard-engine": "1.0.0-alpha.182",
|
|
78
|
+
"@lunora/values": "1.0.0-alpha.92",
|
|
79
79
|
"@lunora/wire": "1.0.0-alpha.6",
|
|
80
80
|
"drizzle-orm": "1.0.0-rc.5",
|
|
81
81
|
"hono": "^4.13.13"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{assertScheduleInstant as A,assertScheduleDelay as v,resolveScheduleId as y}from"@lunora/scheduler";import{encodeArgsOrThrow as S}from"@lunora/wire";const m=new WeakMap,w=c=>{if(typeof c=="string")return c;const r=c??{},e=r.__lunoraRef??r.binding;return typeof e=="string"?e:"<unknown>"},x=c=>{let r=c;for(;r!==void 0&&!r.open;)r=r.parent;return r},D=(c,r,e)=>c==="runAfter"?Math.max(r,e-Date.now()):Math.max(r,e),k=(c,r)=>{const e=c,t={decisions:new Map,innermost:void 0,outbox:r},a=(n,i,o,s,d)=>e[n].call(e,i,o,s,d),u=(n,i,o,s,d)=>{const l=w(o);t.decisions.has(l)||t.decisions.set(l,t.outbox?.admit(l));const g=t.decisions.get(l),h=g===void 0?i:D(n,i,g),b=t.innermost;if(b===void 0)return a(n,h,o,s,d);const p=y(d?.id);return t.outbox?.record(p,{args:S(`ctx.scheduler.${n}`,w(o),s),options:d,target:o,when:Math.ceil(n==="runAfter"?Date.now()+h:h)}),b.pending.push({id:p,run:async()=>a(n,h,o,s,{...d,id:p})}),Promise.resolve(p)},f={...e,runAfter:(n,i,o,s)=>(v(n,"ctx.scheduler.runAfter"),u("runAfter",n,i,o,s)),runAt:(n,i,o,s)=>(A(n,Date.now(),"ctx.scheduler.runAt"),u("runAt",n,i,o,s))};return Object.setPrototypeOf(f,Object.getPrototypeOf(e)),m.set(f,t),f},q=c=>{const{scheduler:r}=c,e=typeof r=="object"&&r!==null?m.get(r):void 0;if(!e)return async()=>{};const t={open:!0,parent:e.innermost,pending:[]};return e.innermost=t,async a=>{if(!t.open)return;t.open=!1,e.innermost===t&&(e.innermost=x(t.parent));const u=t.pending.splice(0);if(u.length===0)return;if(!a){for(const{id:s}of u)e.outbox?.forget(s);return}const f=x(t.parent);if(f!==void 0){f.pending.push(...u);return}const n=[];for(const{id:s,run:d}of u)try{await d(),e.outbox?.forget(s)}catch(l){n.push(l)}const[i,...o]=n;if(i!==void 0)throw e.outbox?.wake(),o.length===0?i:new AggregateError(n,`ctx.scheduler: ${String(n.length)} of ${String(u.length)} deferred jobs failed to reach the scheduler after the commit`)}};export{q as beginDeferredSchedules,k as withDeferredSchedules};
|