@lunora/server 1.0.0-alpha.277 → 1.0.0-alpha.278

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.
@@ -1,5 +1,5 @@
1
1
  import { TransactionHeadroomTracker, SqlExec } from '@lunora/shard-engine';
2
- import { D as DatabaseWriter, S as Schema } from "./packem_shared/types.d-BTY_1dJ8.mjs";
2
+ import { D as DatabaseWriter, S as Schema } from "./packem_shared/types.d-CJnJltzy.mjs";
3
3
  import '@lunora/values';
4
4
  /** Where the current dispatch's tracker lives: an `AsyncLocalStorage` fits, and so does any stand-in. */
5
5
  interface HeadroomScope {
@@ -1,5 +1,5 @@
1
1
  import { TransactionHeadroomTracker, SqlExec } from '@lunora/shard-engine';
2
- import { D as DatabaseWriter, S as Schema } from "./packem_shared/types.d-BTY_1dJ8.js";
2
+ import { D as DatabaseWriter, S as Schema } from "./packem_shared/types.d-CJnJltzy.js";
3
3
  import '@lunora/values';
4
4
  /** Where the current dispatch's tracker lives: an `AsyncLocalStorage` fits, and so does any stand-in. */
5
5
  interface HeadroomScope {
@@ -1 +1 @@
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};
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-BTwq-NUO.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-BTY_1dJ8.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-BTY_1dJ8.mjs";
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-CJnJltzy.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-CJnJltzy.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';
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-BTY_1dJ8.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-BTY_1dJ8.js";
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-CJnJltzy.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-CJnJltzy.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';
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-Dv4DKrj0.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-BCa6sLSJ.mjs";import{LunoraEnvError as M,defineEnv as P}from"./packem_shared/LunoraEnvError-06_Zc4yc.mjs";import{bindOrm as y,bindTableFacade as O,defineLazyFacade as F}from"./packem_shared/bindOrm-D5mVDvbi.mjs";import{httpAction as N,httpRoute as U,httpRouter as H,lastEventId as k,sseEvent as w}from"./packem_shared/httpAction-Bfw3qwLG.mjs";import{serveStorageObject as V}from"./packem_shared/serveStorageObject-CLz3qhNI.mjs";import{defineIdentity as j}from"./packem_shared/defineIdentity-DwkNKwYa.mjs";import{default as z}from"./packem_shared/defineIdentityGuard-Bt8N65Zs.mjs";import{onConnect as J,onDisconnect as K,onShardInit as Q}from"./packem_shared/onConnect-BLRoOpv2.mjs";import{DEFAULT_LIMIT as q,DEFAULT_MAX_LIMIT as Z,clampLimit as $,defineListArgs as ee}from"./packem_shared/DEFAULT_LIMIT-pT_tV8R0.mjs";import{defineLiveStream as oe,liveStreamRouter as te}from"./packem_shared/defineLiveStream-q9yO3wl6.mjs";import{defineMigration as ne}from"./packem_shared/defineMigration-CXOS0Bvq.mjs";import{defineModule as ae}from"./packem_shared/defineModule-OecXWM3U.mjs";import{defineMutator as se}from"./packem_shared/defineMutator-DlLFSWbO.mjs";import{platformAdmin as pe}from"./packem_shared/platformAdmin-kczXQme8.mjs";import{c as ce,d as le,a as Ee,b as ue,e as Se,f as De,g as he,h as Te,i as Re,j as Ae,k as ge,m as Le}from"./packem_shared/plugin-CyLqvCB9.mjs";import{PRESENCE_DEFAULT_TTL_MS as Ie,PRESENCE_TABLE as Ce,definePresence as Me,presenceExtension as Pe}from"./packem_shared/PRESENCE_DEFAULT_TTL_MS-TXTxGfEA.mjs";import{PROCEDURE_META as ye,UNLOADED_META as Oe,procedureMeta as Fe}from"./packem_shared/PROCEDURE_META-DVzrXpfa.mjs";import{protectPublic as Ne}from"./packem_shared/protectPublic-Bi5_95aP.mjs";import{onQueryChange as He}from"./packem_shared/onQueryChange-iuLzmyPs.mjs";import{defineRoom as we}from"./packem_shared/defineRoom-CoGi-xwm.mjs";import{createServices as Ve}from"./packem_shared/createServices-IJvoqi0e.mjs";import{defineShape as je}from"./packem_shared/defineShape-H-0IbZlb.mjs";import{defineWebSocket as ze}from"./packem_shared/defineWebSocket-BHoy6_ox.mjs";import{onWhisper as Je}from"./packem_shared/onWhisper-CfDbFLQh.mjs";import{LunoraError as Qe}from"@lunora/errors";import{cronJobs as qe}from"@lunora/scheduler";import{ValidationError as $e,v as er}from"@lunora/values";import{allowAll as or,deny as tr,isDeny as ir,toWhereInput as nr}from"./packem_shared/allowAll-DkRAgItV.mjs";import{asBucketStorage as ar}from"./packem_shared/asBucketStorage-DoGYOjq3.mjs";import{assertShapesDeclareReadPolicies as sr,buildRlsReadRegistry as mr,composeShapeReadWhere as pr}from"./packem_shared/assertShapesDeclareReadPolicies-C09SMvM4.mjs";import{buildMaskRegistry as cr}from"./packem_shared/buildMaskRegistry-DpWMtalG.mjs";import{createPolicyDsl as Er,definePermission as ur,definePolicies as Sr,definePolicy as Dr,defineRole as hr}from"./packem_shared/createPolicyDsl-BZa6SqLJ.mjs";import{defineStorageRule as Rr,defineStorageRules as Ar}from"./packem_shared/defineStorageRule-Dv4nJE0H.mjs";import{isSafeHeaderValue as Lr}from"./packem_shared/isSafeHeaderValue-DswDADFy.mjs";import{mask as Ir}from"./packem_shared/mask-DHJtsP7t.mjs";import{r as Mr}from"./packem_shared/redact-secrets-BpatNz48.mjs";import{r as br}from"./packem_shared/middleware-CHYtnvZP.mjs";import{storageRules as Or}from"./packem_shared/storageRules-BVIXkoRg.mjs";const e="0.0.0";export{t as ACTION_CACHE_DEFAULT_TTL_MS,i as ACTION_CACHE_TABLE,q as DEFAULT_LIMIT,Z as DEFAULT_MAX_LIMIT,g as DOCUMENT_HISTORY_REDACTED_FIELDS,L as DOCUMENT_HISTORY_TABLE,M as LunoraEnvError,Qe as LunoraError,Ie as PRESENCE_DEFAULT_TTL_MS,Ce as PRESENCE_TABLE,ye as PROCEDURE_META,Oe as UNLOADED_META,e as VERSION,$e as ValidationError,n as actionCacheExtension,or as allowAll,ar as asBucketStorage,sr as assertShapesDeclareReadPolicies,u as beginDeferredDeletes,T as beginDeferredSchedules,y as bindOrm,O as bindTableFacade,cr as buildMaskRegistry,mr as buildRlsReadRegistry,f as cacheKeyFor,$ as clampLimit,ce as composePluginMiddleware,pr as composeShapeReadWhere,Er as createPolicyDsl,l as createSecrets,Ve as createServices,qe as cronJobs,a as defineActionCache,le as defineAggregateIndex,Ee as defineComponent,_ as defineDocumentHistory,P as defineEnv,j as defineIdentity,z as defineIdentityGuard,F as defineLazyFacade,ee as defineListArgs,oe as defineLiveStream,ne as defineMigration,ae as defineModule,se as defineMutator,ur as definePermission,ue as definePlugin,Sr as definePolicies,Dr as definePolicy,Me as definePresence,Se as defineRankIndex,hr as defineRole,we as defineRoom,De as defineSchema,he as defineSchemaExtension,je as defineShape,Rr as defineStorageRule,Ar as defineStorageRules,Te as defineTable,Re as defineVectorIndex,ze as defineWebSocket,tr as deny,I as documentHistoryExtension,S as flushDeferredDeletes,N as httpAction,U as httpRoute,H as httpRouter,Ae as indexFieldsFromSchema,s as initLunora,ge as installPlugins,ir as isDeny,p as isPerDispatchMiddleware,Lr as isSafeHeaderValue,k as lastEventId,te as liveStreamRouter,Ir as mask,Le as mergeSchemaExtension,J as onConnect,K as onDisconnect,He as onQueryChange,Q as onShardInit,Je as onWhisper,pe as platformAdmin,Pe as presenceExtension,Fe as procedureMeta,Ne as protectPublic,Mr as redactSecrets,br as rls,V as serveStorageObject,w as sseEvent,Or as storageRules,x as tagPerDispatchMiddleware,nr as toWhereInput,er as v,D as withDeferredDeletes,R as withDeferredSchedules};
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-Dv4DKrj0.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-BTwq-NUO.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-BCa6sLSJ.mjs";import{LunoraEnvError as M,defineEnv as P}from"./packem_shared/LunoraEnvError-06_Zc4yc.mjs";import{bindOrm as y,bindTableFacade as O,defineLazyFacade as F}from"./packem_shared/bindOrm-D5mVDvbi.mjs";import{httpAction as N,httpRoute as U,httpRouter as H,lastEventId as k,sseEvent as w}from"./packem_shared/httpAction-Bfw3qwLG.mjs";import{serveStorageObject as V}from"./packem_shared/serveStorageObject-CLz3qhNI.mjs";import{defineIdentity as j}from"./packem_shared/defineIdentity-DwkNKwYa.mjs";import{default as z}from"./packem_shared/defineIdentityGuard-Bt8N65Zs.mjs";import{onConnect as J,onDisconnect as K,onShardInit as Q}from"./packem_shared/onConnect-BLRoOpv2.mjs";import{DEFAULT_LIMIT as q,DEFAULT_MAX_LIMIT as Z,clampLimit as $,defineListArgs as ee}from"./packem_shared/DEFAULT_LIMIT-pT_tV8R0.mjs";import{defineLiveStream as oe,liveStreamRouter as te}from"./packem_shared/defineLiveStream-q9yO3wl6.mjs";import{defineMigration as ne}from"./packem_shared/defineMigration-CXOS0Bvq.mjs";import{defineModule as ae}from"./packem_shared/defineModule-OecXWM3U.mjs";import{defineMutator as se}from"./packem_shared/defineMutator-DlLFSWbO.mjs";import{platformAdmin as pe}from"./packem_shared/platformAdmin-kczXQme8.mjs";import{c as ce,d as le,a as Ee,b as ue,e as Se,f as De,g as he,h as Te,i as Re,j as Ae,k as ge,m as Le}from"./packem_shared/plugin-CyLqvCB9.mjs";import{PRESENCE_DEFAULT_TTL_MS as Ie,PRESENCE_TABLE as Ce,definePresence as Me,presenceExtension as Pe}from"./packem_shared/PRESENCE_DEFAULT_TTL_MS-TXTxGfEA.mjs";import{PROCEDURE_META as ye,UNLOADED_META as Oe,procedureMeta as Fe}from"./packem_shared/PROCEDURE_META-DVzrXpfa.mjs";import{protectPublic as Ne}from"./packem_shared/protectPublic-Bi5_95aP.mjs";import{onQueryChange as He}from"./packem_shared/onQueryChange-iuLzmyPs.mjs";import{defineRoom as we}from"./packem_shared/defineRoom-CoGi-xwm.mjs";import{createServices as Ve}from"./packem_shared/createServices-IJvoqi0e.mjs";import{defineShape as je}from"./packem_shared/defineShape-H-0IbZlb.mjs";import{defineWebSocket as ze}from"./packem_shared/defineWebSocket-BHoy6_ox.mjs";import{onWhisper as Je}from"./packem_shared/onWhisper-CfDbFLQh.mjs";import{LunoraError as Qe}from"@lunora/errors";import{cronJobs as qe}from"@lunora/scheduler";import{ValidationError as $e,v as er}from"@lunora/values";import{allowAll as or,deny as tr,isDeny as ir,toWhereInput as nr}from"./packem_shared/allowAll-DkRAgItV.mjs";import{asBucketStorage as ar}from"./packem_shared/asBucketStorage-DoGYOjq3.mjs";import{assertShapesDeclareReadPolicies as sr,buildRlsReadRegistry as mr,composeShapeReadWhere as pr}from"./packem_shared/assertShapesDeclareReadPolicies-C09SMvM4.mjs";import{buildMaskRegistry as cr}from"./packem_shared/buildMaskRegistry-DpWMtalG.mjs";import{createPolicyDsl as Er,definePermission as ur,definePolicies as Sr,definePolicy as Dr,defineRole as hr}from"./packem_shared/createPolicyDsl-BZa6SqLJ.mjs";import{defineStorageRule as Rr,defineStorageRules as Ar}from"./packem_shared/defineStorageRule-Dv4nJE0H.mjs";import{isSafeHeaderValue as Lr}from"./packem_shared/isSafeHeaderValue-DswDADFy.mjs";import{mask as Ir}from"./packem_shared/mask-DHJtsP7t.mjs";import{r as Mr}from"./packem_shared/redact-secrets-BpatNz48.mjs";import{r as br}from"./packem_shared/middleware-CHYtnvZP.mjs";import{storageRules as Or}from"./packem_shared/storageRules-BVIXkoRg.mjs";const e="0.0.0";export{t as ACTION_CACHE_DEFAULT_TTL_MS,i as ACTION_CACHE_TABLE,q as DEFAULT_LIMIT,Z as DEFAULT_MAX_LIMIT,g as DOCUMENT_HISTORY_REDACTED_FIELDS,L as DOCUMENT_HISTORY_TABLE,M as LunoraEnvError,Qe as LunoraError,Ie as PRESENCE_DEFAULT_TTL_MS,Ce as PRESENCE_TABLE,ye as PROCEDURE_META,Oe as UNLOADED_META,e as VERSION,$e as ValidationError,n as actionCacheExtension,or as allowAll,ar as asBucketStorage,sr as assertShapesDeclareReadPolicies,u as beginDeferredDeletes,T as beginDeferredSchedules,y as bindOrm,O as bindTableFacade,cr as buildMaskRegistry,mr as buildRlsReadRegistry,f as cacheKeyFor,$ as clampLimit,ce as composePluginMiddleware,pr as composeShapeReadWhere,Er as createPolicyDsl,l as createSecrets,Ve as createServices,qe as cronJobs,a as defineActionCache,le as defineAggregateIndex,Ee as defineComponent,_ as defineDocumentHistory,P as defineEnv,j as defineIdentity,z as defineIdentityGuard,F as defineLazyFacade,ee as defineListArgs,oe as defineLiveStream,ne as defineMigration,ae as defineModule,se as defineMutator,ur as definePermission,ue as definePlugin,Sr as definePolicies,Dr as definePolicy,Me as definePresence,Se as defineRankIndex,hr as defineRole,we as defineRoom,De as defineSchema,he as defineSchemaExtension,je as defineShape,Rr as defineStorageRule,Ar as defineStorageRules,Te as defineTable,Re as defineVectorIndex,ze as defineWebSocket,tr as deny,I as documentHistoryExtension,S as flushDeferredDeletes,N as httpAction,U as httpRoute,H as httpRouter,Ae as indexFieldsFromSchema,s as initLunora,ge as installPlugins,ir as isDeny,p as isPerDispatchMiddleware,Lr as isSafeHeaderValue,k as lastEventId,te as liveStreamRouter,Ir as mask,Le as mergeSchemaExtension,J as onConnect,K as onDisconnect,He as onQueryChange,Q as onShardInit,Je as onWhisper,pe as platformAdmin,Pe as presenceExtension,Fe as procedureMeta,Ne as protectPublic,Mr as redactSecrets,br as rls,V as serveStorageObject,w as sseEvent,Or as storageRules,x as tagPerDispatchMiddleware,nr as toWhereInput,er 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-BTY_1dJ8.mjs";
44
+ import { a as SpanHandle, L as LunoraTracer } from "./packem_shared/types.d-CJnJltzy.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-BTY_1dJ8.js";
44
+ import { a as SpanHandle, L as LunoraTracer } from "./packem_shared/types.d-CJnJltzy.js";
45
45
  import '@lunora/values';
46
46
  /**
47
47
  * @since 1.0.0
@@ -0,0 +1 @@
1
+ import{assertScheduleInstant as x,assertScheduleDelay as D,resolveScheduleId as O,assertDedupKey as S}from"@lunora/scheduler";import{encodeArgsOrThrow as $}from"@lunora/wire";const A=new WeakMap,m=o=>{if(typeof o=="string")return o;const n=o??{},e=n.__lunoraRef??n.binding;return typeof e=="string"?e:"<unknown>"},b=o=>{let n=o;for(;n!==void 0&&!n.open;)n=n.parent;return n},j=(o,n,e)=>o==="runAfter"?Math.max(n,e-Date.now()):Math.max(n,e),k=async(o,{id:n,run:e,token:r})=>{if(o?.handOff!==void 0){await o.handOff(n,e,r);return}await e(),o?.forget(n)},K=(o,n)=>{const e=o,r={decisions:new Map,innermost:void 0,outbox:n},l=(t,i,s,c,u)=>e[t].call(e,i,s,c,u),d=(t,i,s,c,u)=>{const h=m(s);r.decisions.has(h)||r.decisions.set(h,r.outbox?.admit(h));const g=r.decisions.get(h),p=g===void 0?i:j(t,i,g),w=r.innermost;if(w===void 0)return l(t,p,s,c,u);const a=O(u?.id),y={...u,dedupKey:S(u?.dedupKey)??`${a}-${crypto.randomUUID().replaceAll("-","")}`},v=r.outbox?.record(a,{args:$(`ctx.scheduler.${t}`,m(s),c),options:y,target:s,when:Math.ceil(t==="runAfter"?Date.now()+p:p)});return w.pending.push({id:a,run:async()=>l(t,p,s,c,{...y,id:a}),token:v}),Promise.resolve(a)},f={...e,runAfter:(t,i,s,c)=>(D(t,"ctx.scheduler.runAfter"),d("runAfter",t,i,s,c)),runAt:(t,i,s,c)=>(x(t,Date.now(),"ctx.scheduler.runAt"),d("runAt",t,i,s,c))};return Object.setPrototypeOf(f,Object.getPrototypeOf(e)),A.set(f,r),f},M=o=>{const{scheduler:n}=o,e=typeof n=="object"&&n!==null?A.get(n):void 0;if(!e)return async()=>{};const r={open:!0,parent:e.innermost,pending:[]};return e.innermost=r,async l=>{if(!r.open)return;r.open=!1,e.innermost===r&&(e.innermost=b(r.parent));const d=r.pending.splice(0);if(d.length===0)return;if(!l){for(const{id:c}of d)e.outbox?.forget(c);return}const f=b(r.parent);if(f!==void 0){f.pending.push(...d);return}const t=[];for(const c of d)try{await k(e.outbox,c)}catch(u){t.push(u)}const[i,...s]=t;if(i!==void 0)throw e.outbox?.wake(),s.length===0?i:new AggregateError(t,`ctx.scheduler: ${String(t.length)} of ${String(d.length)} deferred jobs failed to reach the scheduler after the commit`)}};export{M as beginDeferredSchedules,K as withDeferredSchedules};
@@ -1964,6 +1964,15 @@ interface SchedulableWorkflowReference {
1964
1964
  type SchedulableTarget = FunctionHandle<"action" | "mutation", unknown, unknown> | SchedulableWorkflowReference | string;
1965
1965
  /** Per-call options for {@link Scheduler.runAfter} / {@link Scheduler.runAt}. */
1966
1966
  interface ScheduleRunOptions {
1967
+ /**
1968
+ * The key the job's receiver dedups a re-delivery on. Defaults to one minted per scheduling;
1969
+ * set it when the same logical job may be scheduled more than once and must run once. Must
1970
+ * match `^[A-Za-z0-9_][A-Za-z0-9_-]{0,99}$`; inside a mutation a key that does not is refused
1971
+ * there and then, rolling the mutation back. A function target remembers the key for 24 hours,
1972
+ * a workflow target for as long as its instance exists, and the key is shared by every job
1973
+ * reaching the same shard: scope a fixed key yourself when callers could collide.
1974
+ */
1975
+ dedupKey?: string;
1967
1976
  /** Retry policy for this job; the scheduler's defaults apply when omitted. */
1968
1977
  retry?: RetryPolicy;
1969
1978
  /**
@@ -1964,6 +1964,15 @@ interface SchedulableWorkflowReference {
1964
1964
  type SchedulableTarget = FunctionHandle<"action" | "mutation", unknown, unknown> | SchedulableWorkflowReference | string;
1965
1965
  /** Per-call options for {@link Scheduler.runAfter} / {@link Scheduler.runAt}. */
1966
1966
  interface ScheduleRunOptions {
1967
+ /**
1968
+ * The key the job's receiver dedups a re-delivery on. Defaults to one minted per scheduling;
1969
+ * set it when the same logical job may be scheduled more than once and must run once. Must
1970
+ * match `^[A-Za-z0-9_][A-Za-z0-9_-]{0,99}$`; inside a mutation a key that does not is refused
1971
+ * there and then, rolling the mutation back. A function target remembers the key for 24 hours,
1972
+ * a workflow target for as long as its instance exists, and the key is shared by every job
1973
+ * reaching the same shard: scope a fixed key yourself when callers could collide.
1974
+ */
1975
+ dedupKey?: string;
1967
1976
  /** Retry policy for this job; the scheduler's defaults apply when omitted. */
1968
1977
  retry?: RetryPolicy;
1969
1978
  /**
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, 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-BTY_1dJ8.mjs";
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-CJnJltzy.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, 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-BTY_1dJ8.js";
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-CJnJltzy.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.277",
3
+ "version": "1.0.0-alpha.278",
4
4
  "description": "Server primitives for Lunora: defineSchema, defineTable, query, mutation, and action",
5
5
  "keywords": [
6
6
  "backend",
@@ -73,7 +73,7 @@
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.170",
76
+ "@lunora/scheduler": "^1.0.0-alpha.173",
77
77
  "@lunora/shard-engine": "^1.0.0-alpha.204",
78
78
  "@lunora/values": "^1.0.0-alpha.95",
79
79
  "@lunora/wire": "1.0.0-alpha.6",
@@ -1 +0,0 @@
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};