@lunora/server 1.0.0-alpha.83 → 1.0.0-alpha.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1620 -1482
- package/dist/index.d.ts +1620 -1482
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/DOCUMENT_HISTORY_REDACTED_FIELDS-B5M6QNiq.mjs +1 -0
- package/dist/packem_shared/flushDeferredDeletes-DEJXlhop.mjs +1 -0
- package/dist/types.d.mts +21 -2
- package/dist/types.d.ts +21 -2
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{initLunora as t}from"./packem_shared/initLunora-B2sfmFJ6.mjs";import{createSecrets as i}from"./packem_shared/createSecrets-CyrEddTF.mjs";import{LunoraEnvError as
|
|
1
|
+
import{initLunora as t}from"./packem_shared/initLunora-B2sfmFJ6.mjs";import{createSecrets as i}from"./packem_shared/createSecrets-CyrEddTF.mjs";import{flushDeferredDeletes as a,withDeferredDeletes as s}from"./packem_shared/flushDeferredDeletes-DEJXlhop.mjs";import{DOCUMENT_HISTORY_REDACTED_FIELDS as d,DOCUMENT_HISTORY_TABLE as p,defineDocumentHistory as x,documentHistoryExtension as c}from"./packem_shared/DOCUMENT_HISTORY_REDACTED_FIELDS-B5M6QNiq.mjs";import{LunoraEnvError as E,defineEnv as u,redactSecrets as S}from"./packem_shared/LunoraEnvError-ByvihJFy.mjs";import{LunoraError as R}from"./packem_shared/LunoraError-DcKdk9Ti.mjs";import{bindOrm as D,bindTableFacade as T}from"./packem_shared/bindOrm-lWdeDi9P.mjs";import{httpAction as L,httpRoute as A,httpRouter as _,isSafeHeaderValue as y,serveStorageObject as P}from"./packem_shared/httpAction-D3b9-YiY.mjs";import{defineIdentity as M}from"./packem_shared/defineIdentity-DwkNKwYa.mjs";import{onConnect as F,onDisconnect as O,onShardInit as k}from"./packem_shared/onConnect-BLRoOpv2.mjs";import{DEFAULT_LIMIT as N,DEFAULT_MAX_LIMIT as U,clampLimit as v,defineListArgs as V}from"./packem_shared/DEFAULT_LIMIT-DC-M6faS.mjs";import{defineMigration as B}from"./packem_shared/defineMigration-7GI9Qbtd.mjs";import{defineMutator as W}from"./packem_shared/defineMutator-DKy8UtbB.mjs";import{c as J,d as Q,a as X,b as q,e as z,f as G,g as K,h as Z,i as $,j as ee,k as re,m as oe}from"./packem_shared/plugin-DQcLxTx1.mjs";import{PRESENCE_DEFAULT_TTL_MS as ne,PRESENCE_TABLE as ie,definePresence as fe,presenceExtension as ae}from"./packem_shared/PRESENCE_DEFAULT_TTL_MS-BpSPSCwL.mjs";import{protectPublic as me}from"./packem_shared/protectPublic-Bo4G9xaV.mjs";import{onQueryChange as pe}from"./packem_shared/onQueryChange-DDxYz2CF.mjs";import{defineShape as ce}from"./packem_shared/defineShape-DYxbNl5W.mjs";import{anyApi as Ee}from"./types.mjs";import{cronJobs as Se}from"@lunora/scheduler";import{ValidationError as Re,v as he}from"@lunora/values";import{allowAll as Te,deny as Ie,isDeny as Le,toWhereInput as Ae}from"./packem_shared/allowAll-DkRAgItV.mjs";import{asBucketStorage as ye}from"./packem_shared/asBucketStorage-BthCnWop.mjs";import{buildMaskRegistry as be}from"./packem_shared/buildMaskRegistry-72SL8fJn.mjs";import{buildRlsReadRegistry as Ce,composeShapeReadWhere as Fe}from"./packem_shared/buildRlsReadRegistry-Deq8inqS.mjs";import{createPolicyDsl as ke,definePermission as He,definePolicies as Ne,definePolicy as Ue,defineRole as ve}from"./packem_shared/createPolicyDsl-DNfByAUX.mjs";import{defineStorageRule as we,defineStorageRules as Be}from"./packem_shared/defineStorageRule-BvxHVq3b.mjs";import{mask as We}from"./packem_shared/mask-Da7q82ZC.mjs";import{r as Je}from"./packem_shared/middleware-DEW0yLvU.mjs";import{storageRules as Xe}from"./packem_shared/storageRules-CyaiZ0av.mjs";const e="0.0.0";export{N as DEFAULT_LIMIT,U as DEFAULT_MAX_LIMIT,d as DOCUMENT_HISTORY_REDACTED_FIELDS,p as DOCUMENT_HISTORY_TABLE,E as LunoraEnvError,R as LunoraError,ne as PRESENCE_DEFAULT_TTL_MS,ie as PRESENCE_TABLE,e as VERSION,Re as ValidationError,Te as allowAll,Ee as anyApi,ye as asBucketStorage,D as bindOrm,T as bindTableFacade,be as buildMaskRegistry,Ce as buildRlsReadRegistry,v as clampLimit,J as composePluginMiddleware,Fe as composeShapeReadWhere,ke as createPolicyDsl,i as createSecrets,Se as cronJobs,Q as defineAggregateIndex,X as defineComponent,x as defineDocumentHistory,u as defineEnv,M as defineIdentity,V as defineListArgs,B as defineMigration,W as defineMutator,He as definePermission,q as definePlugin,Ne as definePolicies,Ue as definePolicy,fe as definePresence,z as defineRankIndex,ve as defineRole,G as defineSchema,K as defineSchemaExtension,ce as defineShape,we as defineStorageRule,Be as defineStorageRules,Z as defineTable,$ as defineVectorIndex,Ie as deny,c as documentHistoryExtension,a as flushDeferredDeletes,L as httpAction,A as httpRoute,_ as httpRouter,ee as indexFieldsFromSchema,t as initLunora,re as installPlugins,Le as isDeny,y as isSafeHeaderValue,We as mask,oe as mergeSchemaExtension,F as onConnect,O as onDisconnect,pe as onQueryChange,k as onShardInit,ae as presenceExtension,me as protectPublic,S as redactSecrets,Je as rls,P as serveStorageObject,Xe as storageRules,Ae as toWhereInput,he as v,s as withDeferredDeletes};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{v as a}from"@lunora/values";import{initLunora as k}from"./initLunora-B2sfmFJ6.mjs";import{g as C,h as L,a as P}from"./plugin-DQcLxTx1.mjs";const T=e=>{let r="";for(let d=0;d<e.length;d+=32768)r+=String.fromCharCode(...e.subarray(d,d+32768));return btoa(r)},F=e=>{const r=atob(e),y=new Uint8Array(r.length);for(let d=0;d<r.length;d+=1)y[d]=r.codePointAt(d)??0;return y},f="$lunora.wire$",_=64,R=1024,N="__proto__",M={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},h={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},H=e=>{if(e===null||typeof e!="object")return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype},A=(e,r=0)=>{if(r>_)throw new RangeError(`wire-codec: value nesting exceeds the ${_}-level limit`);if(e===void 0)return[f,"undefined"];if(e===null)return null;const y=typeof e;if(y==="bigint")return[f,"bigint",e.toString()];if(y==="number"){const t=e;return Number.isNaN(t)?[f,"nan"]:t===1/0?[f,"inf"]:t===-1/0?[f,"-inf"]:t}if(y!=="object")return e;if(e instanceof Date)return[f,"date",A(e.getTime(),r+1)];if(e instanceof Error){const t=e,c={};for(const b of Object.keys(t))t[b]!==void 0&&(c[b]=A(t[b],r+1));const u=[f,"error",t.name,t.message,c];return t.cause!==void 0&&u.push(A(t.cause,r+1)),u}if(e instanceof URL)return[f,"url",e.href];if(e instanceof Map)return[f,"map",[...e.entries()].map(([t,c])=>[A(t,r+1),A(c,r+1)])];if(e instanceof Set)return[f,"set",[...e].map(t=>A(t,r+1))];if(e instanceof ArrayBuffer)return[f,"bytes",T(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,c=t.constructor.name,u=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return c==="Uint8Array"?[f,"bytes",T(u)]:[f,"bytes",T(u),c]}if(Array.isArray(e)){const t=e.map(c=>A(c,r+1));return t.length>0&&t[0]===f?[f,"arr",t]:t}if(!H(e)){const t=e.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${t} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const d=e,m={};for(const t of Object.keys(d)){const c=d[t];if(c===void 0)continue;const u=A(c,r+1);t===N?Object.defineProperty(m,t,{configurable:!0,enumerable:!0,value:u,writable:!0}):m[t]=u}return m},l=(e,r=0)=>{if(r>_)throw new RangeError(`wire-codec: value nesting exceeds the ${_}-level limit`);if(e===null||typeof e!="object")return e;if(Array.isArray(e)){if(e[0]===f)switch(e[1]){case"-inf":return-1/0;case"arr":return e[2].map(t=>l(t,r+1));case"bigint":{const t=e[2];if(typeof t!="string"||t.length>R||!/^-?\d+$/.test(t))throw new RangeError(`wire-codec: invalid or over-long bigint (max ${R} digits)`);return BigInt(t)}case"date":return new Date(l(e[2],r+1));case"map":return new Map(e[2].map(([t,c])=>[l(t,r+1),l(c,r+1)]));case"set":return new Set(e[2].map(t=>l(t,r+1)));case"url":return new URL(e[2]);case"error":{const t=e[2],c=e[3],u=(Object.hasOwn(h,t)?h[t]:void 0)??Error,b=new u(c);b.name!==t&&Object.defineProperty(b,"name",{configurable:!0,value:t,writable:!0});const I=l(e[4],r+1);for(const E of Object.keys(I))E===N?Object.defineProperty(b,E,{configurable:!0,enumerable:!0,value:I[E],writable:!0}):b[E]=I[E];return e.length>5&&Object.defineProperty(b,"cause",{configurable:!0,value:l(e[5],r+1),writable:!0}),b}case"bytes":{const t=F(e[2]),c=e[3]??"Uint8Array";if(c==="ArrayBuffer")return t.buffer.byteLength===t.byteLength?t.buffer:t.slice().buffer;const u=Object.hasOwn(M,c)?M[c]:void 0;return u?new u(t.slice().buffer):t}case"inf":return 1/0;case"nan":return Number.NaN;case"undefined":return;default:return e.map(t=>l(t,r+1))}return e.map(m=>l(m,r+1))}const y=e,d={};for(const m of Object.keys(y)){const t=l(y[m],r+1);m===N?Object.defineProperty(d,m,{configurable:!0,enumerable:!0,value:t,writable:!0}):d[m]=t}return d},q=2160*60*60*1e3,Y=64*1024,U=200,$=64,J=512,x=16,K=["_commitSeq","seq"],X=["accessToken","apiKey","backupCodes","clientSecret","hashedPassword","password","privateKey","refreshToken","secret","totpSecret"],D="documentHistory",j="versions",S=`${D}_${j}`,G=C(D,{tables:{[j]:L({doc:a.optional(a.string()),documentId:a.string(),op:a.union(a.literal("delete"),a.literal("insert"),a.literal("update")),previous:a.optional(a.string()),recordedAt:a.number(),seq:a.number(),tableName:a.string(),truncated:a.optional(a.boolean())}).commitOrdered().index("byDocumentRecordedAt",["documentId","recordedAt","seq"]).index("byRecordedAt",["recordedAt"])}}),{internalMutation:V,internalQuery:W}=k.dataModel().create(),ee=(e={})=>{const r=e.retentionMs!==void 0&&Number.isFinite(e.retentionMs)?Math.max(1,Math.floor(e.retentionMs)):q,y=e.maxSnapshotBytes!==void 0&&Number.isFinite(e.maxSnapshotBytes)?Math.max(1,Math.floor(e.maxSnapshotBytes)):Y,d=new Set([...X,...e.redact??[]]);let m=0;const t=()=>(m+=1,m),c=(n,o=0)=>{if(Array.isArray(n))return o>=x?void 0:n.map(i=>c(i,o+1));if(typeof n!="object"||n===null||Object.getPrototypeOf(n)!==Object.prototype&&Object.getPrototypeOf(n)!==null)return n;if(!(o>=x))return Object.fromEntries(Object.entries(n).filter(([i])=>!d.has(i)).map(([i,p])=>[i,c(p,o+1)]))},u=n=>{if(n===void 0)return;const o=JSON.stringify(A(c(n)));return new TextEncoder().encode(o).length>y?void 0:o},b=async(n,o)=>{const i=u(o.doc),p=u(o.previous),s=o.doc!==void 0&&i===void 0||o.previous!==void 0&&p===void 0;await n.db.insert(S,{documentId:o.documentId,op:o.op,recordedAt:Date.now(),seq:t(),tableName:o.tableName,...s?{truncated:!0}:{},...i===void 0?{}:{doc:i},...p===void 0?{}:{previous:p}})},I=n=>({documentHistoryDelete:n.afterDelete(async(o,i)=>b(o,{documentId:i.id,op:"delete",previous:i.previous,tableName:i.table})),documentHistoryInsert:n.afterInsert(async(o,i)=>b(o,{doc:i.doc,documentId:i.id,op:"insert",tableName:i.table})),documentHistoryUpdate:n.afterUpdate(async(o,i)=>b(o,{doc:i.doc,documentId:i.id,op:"update",previous:i.previous,tableName:i.table}))}),E=W.input({before:a.optional(a.number()),documentId:a.string(),limit:a.optional(a.number())}).query(async({args:n,ctx:o})=>{const i=n.limit!==void 0&&Number.isFinite(n.limit)?Math.max(1,Math.floor(n.limit)):U,p=await o.db.query(S).withIndex("byDocumentRecordedAt",s=>n.before===void 0?s.eq("documentId",n.documentId):s.eq("documentId",n.documentId).lte("recordedAt",n.before)).order("desc").take(i);return p.sort((s,w)=>{for(const g of K){const O=(w[g]??0)-(s[g]??0);if(O!==0)return O}return 0}),p.map(s=>({documentId:s.documentId,op:s.op,recordedAt:s.recordedAt,tableName:s.tableName,...s.doc===void 0?{}:{doc:l(JSON.parse(s.doc))},...s.previous===void 0?{}:{previous:l(JSON.parse(s.previous))},...s.truncated===!0?{truncated:!0}:{}}))}),B=V.input({limit:a.optional(a.number())}).mutation(async({args:n,ctx:o})=>{const i=Date.now()-r,p=n.limit!==void 0&&Number.isFinite(n.limit)?Math.max(1,Math.floor(n.limit)):J;let s=0;for(let w=0;w<$&&s<p;w+=1){const g=await o.db.query(S).withIndex("byRecordedAt",O=>O.lt("recordedAt",i)).order("asc").take(Math.min(U,p-s));if(g.length===0)return{deleted:s};await Promise.all(g.map(async O=>o.db.delete(O._id))),s+=g.length}return{deleted:s}});return{...P(D,{extension:G,functions:{listForDocument:E,vacuum:B}}),record:I}};export{X as DOCUMENT_HISTORY_REDACTED_FIELDS,S as DOCUMENT_HISTORY_TABLE,ee as defineDocumentHistory,G as documentHistoryExtension};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const l=new WeakMap,i=f=>{const a=[],o=n=>{const e=n??{},s={...e,deleteAfterCommit:r=>{a.push({key:r,storage:e})}};return Object.setPrototypeOf(s,Object.getPrototypeOf(e)),typeof e.bucket=="function"&&(s.bucket=r=>o(e.bucket?.(r))),l.set(s,a),s};return o(f)},u=async f=>{const{log:a,storage:o}=f??{},n=typeof o=="object"&&o!==null?l.get(o):void 0;if(!n||n.length===0)return{attempted:0,failures:[]};const e=n.splice(0),r=(await Promise.allSettled(e.map(async({key:t,storage:c})=>{if(typeof c.delete!="function")throw new TypeError("ctx.storage: no storage configured, so the object was not deleted");await c.delete(t)}))).flatMap((t,c)=>t.status==="rejected"?[{error:t.reason,key:e[c]?.key??""}]:[]);for(const t of r)a?.warn("ctx.storage.deleteAfterCommit: delete failed, object leaked",{error:String(t.error),key:t.key});return{attempted:e.length,failures:r}};export{u as flushDeferredDeletes,i as withDeferredDeletes};
|
package/dist/types.d.mts
CHANGED
|
@@ -1665,6 +1665,25 @@ interface ReadOnlyStorage<Buckets extends string = string> {
|
|
|
1665
1665
|
*/
|
|
1666
1666
|
head: (key: string) => Promise<StorageObjectHead | null>;
|
|
1667
1667
|
}
|
|
1668
|
+
/**
|
|
1669
|
+
* `ctx.storage` inside a **mutation**: the read surface, plus the one write a
|
|
1670
|
+
* transactional context can safely express. See `@lunora/server`'s
|
|
1671
|
+
* `deferred-deletes.ts` for why `delete` itself stays action-only.
|
|
1672
|
+
*/
|
|
1673
|
+
interface MutationStorage<Buckets extends string = string> extends ReadOnlyStorage<Buckets> {
|
|
1674
|
+
/** Select a named bucket; deletes queued on it are flushed against that bucket. */
|
|
1675
|
+
bucket: (name: Buckets) => MutationStorage<Buckets>;
|
|
1676
|
+
/**
|
|
1677
|
+
* Queue `key` for deletion once this mutation commits.
|
|
1678
|
+
*
|
|
1679
|
+
* Returns `void`, not a promise: nothing has been attempted yet, so the object
|
|
1680
|
+
* is still there on the next line. A rolled-back mutation never flushes, so
|
|
1681
|
+
* the row deletion and the object cleanup cannot disagree. A failed delete
|
|
1682
|
+
* leaks the object rather than failing a mutation that already succeeded, and
|
|
1683
|
+
* is logged with its key.
|
|
1684
|
+
*/
|
|
1685
|
+
deleteAfterCommit: (key: string) => void;
|
|
1686
|
+
}
|
|
1668
1687
|
interface Storage<Buckets extends string = string> extends ReadOnlyStorage<Buckets> {
|
|
1669
1688
|
/** Select a named bucket; the returned accessor exposes the full read/write surface. */
|
|
1670
1689
|
bucket: (name: Buckets) => Storage<Buckets>;
|
|
@@ -2177,7 +2196,7 @@ interface MutationCtx {
|
|
|
2177
2196
|
readonly secrets: Secrets;
|
|
2178
2197
|
/** Attach facts to THIS request's span — the wide event; see {@link LunoraWideEvent}. */
|
|
2179
2198
|
readonly span: LunoraWideEvent;
|
|
2180
|
-
readonly storage:
|
|
2199
|
+
readonly storage: MutationStorage;
|
|
2181
2200
|
/** Wrap a sub-operation in its own nested span; see {@link LunoraTracer}. */
|
|
2182
2201
|
readonly trace: LunoraTracer;
|
|
2183
2202
|
readonly vectors: VectorSearch;
|
|
@@ -2248,4 +2267,4 @@ interface ActionCtx {
|
|
|
2248
2267
|
*/
|
|
2249
2268
|
type AnyApi = Record<string, Record<string, RegisteredFunction<ArgsValidator, unknown, FunctionKind>>>;
|
|
2250
2269
|
declare const anyApi: AnyApi;
|
|
2251
|
-
export { type ActionCtx, type AggregateIndexDefinition, type AggregateOp, type AnyApi, type ArgsValidator, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type DurableObjectJurisdiction, type DurableStreamOptions, type ExposeConfig, type ExternalSourceCursor, type ExternalSourceDefinition, type ExternalSourceMode, type ExternalSourceRefresh, type FunctionKind, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type GlobalBackend, type IndexDefinition, type IndexRangeBuilder, type InferArgs, type LifecycleEvent, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type MutationCtx, type OnDeleteAction, type PaginationOptions, type PaginationResult, type QueryCtx, type RankIndexDefinition, type RankSortKey, type ReadOnlyStorage, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMutation, type RegisteredQuery, type RegisteredStream, type RelationDefinition, type RestCacheConfig, type RunQueryOptions, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type Schema, type SearchFilterBuilder, type SearchIndexDefinition, type SearchLanguage, type SearchStrategy, type Secrets, type SecretsStoreSecretLike, type ShardInitEvent, type ShardMode, type SpanEvaluation, type SpanHandle, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type StorageObjectHead, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableDefinition, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerBuilder, type TriggerCtx, type TriggerDatabase, type TriggerDefinition, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorEmbedder, type VectorIndexDefinition, type VectorMatch, type VectorMatches, type VectorMetric, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowEventDefinition, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, type X402ProcedureConfig, anyApi };
|
|
2270
|
+
export { type ActionCtx, type AggregateIndexDefinition, type AggregateOp, type AnyApi, type ArgsValidator, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type DurableObjectJurisdiction, type DurableStreamOptions, type ExposeConfig, type ExternalSourceCursor, type ExternalSourceDefinition, type ExternalSourceMode, type ExternalSourceRefresh, type FunctionKind, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type GlobalBackend, type IndexDefinition, type IndexRangeBuilder, type InferArgs, type LifecycleEvent, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type MutationCtx, type MutationStorage, type OnDeleteAction, type PaginationOptions, type PaginationResult, type QueryCtx, type RankIndexDefinition, type RankSortKey, type ReadOnlyStorage, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMutation, type RegisteredQuery, type RegisteredStream, type RelationDefinition, type RestCacheConfig, type RunQueryOptions, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type Schema, type SearchFilterBuilder, type SearchIndexDefinition, type SearchLanguage, type SearchStrategy, type Secrets, type SecretsStoreSecretLike, type ShardInitEvent, type ShardMode, type SpanEvaluation, type SpanHandle, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type StorageObjectHead, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableDefinition, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerBuilder, type TriggerCtx, type TriggerDatabase, type TriggerDefinition, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorEmbedder, type VectorIndexDefinition, type VectorMatch, type VectorMatches, type VectorMetric, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowEventDefinition, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, type X402ProcedureConfig, anyApi };
|
package/dist/types.d.ts
CHANGED
|
@@ -1665,6 +1665,25 @@ interface ReadOnlyStorage<Buckets extends string = string> {
|
|
|
1665
1665
|
*/
|
|
1666
1666
|
head: (key: string) => Promise<StorageObjectHead | null>;
|
|
1667
1667
|
}
|
|
1668
|
+
/**
|
|
1669
|
+
* `ctx.storage` inside a **mutation**: the read surface, plus the one write a
|
|
1670
|
+
* transactional context can safely express. See `@lunora/server`'s
|
|
1671
|
+
* `deferred-deletes.ts` for why `delete` itself stays action-only.
|
|
1672
|
+
*/
|
|
1673
|
+
interface MutationStorage<Buckets extends string = string> extends ReadOnlyStorage<Buckets> {
|
|
1674
|
+
/** Select a named bucket; deletes queued on it are flushed against that bucket. */
|
|
1675
|
+
bucket: (name: Buckets) => MutationStorage<Buckets>;
|
|
1676
|
+
/**
|
|
1677
|
+
* Queue `key` for deletion once this mutation commits.
|
|
1678
|
+
*
|
|
1679
|
+
* Returns `void`, not a promise: nothing has been attempted yet, so the object
|
|
1680
|
+
* is still there on the next line. A rolled-back mutation never flushes, so
|
|
1681
|
+
* the row deletion and the object cleanup cannot disagree. A failed delete
|
|
1682
|
+
* leaks the object rather than failing a mutation that already succeeded, and
|
|
1683
|
+
* is logged with its key.
|
|
1684
|
+
*/
|
|
1685
|
+
deleteAfterCommit: (key: string) => void;
|
|
1686
|
+
}
|
|
1668
1687
|
interface Storage<Buckets extends string = string> extends ReadOnlyStorage<Buckets> {
|
|
1669
1688
|
/** Select a named bucket; the returned accessor exposes the full read/write surface. */
|
|
1670
1689
|
bucket: (name: Buckets) => Storage<Buckets>;
|
|
@@ -2177,7 +2196,7 @@ interface MutationCtx {
|
|
|
2177
2196
|
readonly secrets: Secrets;
|
|
2178
2197
|
/** Attach facts to THIS request's span — the wide event; see {@link LunoraWideEvent}. */
|
|
2179
2198
|
readonly span: LunoraWideEvent;
|
|
2180
|
-
readonly storage:
|
|
2199
|
+
readonly storage: MutationStorage;
|
|
2181
2200
|
/** Wrap a sub-operation in its own nested span; see {@link LunoraTracer}. */
|
|
2182
2201
|
readonly trace: LunoraTracer;
|
|
2183
2202
|
readonly vectors: VectorSearch;
|
|
@@ -2248,4 +2267,4 @@ interface ActionCtx {
|
|
|
2248
2267
|
*/
|
|
2249
2268
|
type AnyApi = Record<string, Record<string, RegisteredFunction<ArgsValidator, unknown, FunctionKind>>>;
|
|
2250
2269
|
declare const anyApi: AnyApi;
|
|
2251
|
-
export { type ActionCtx, type AggregateIndexDefinition, type AggregateOp, type AnyApi, type ArgsValidator, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type DurableObjectJurisdiction, type DurableStreamOptions, type ExposeConfig, type ExternalSourceCursor, type ExternalSourceDefinition, type ExternalSourceMode, type ExternalSourceRefresh, type FunctionKind, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type GlobalBackend, type IndexDefinition, type IndexRangeBuilder, type InferArgs, type LifecycleEvent, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type MutationCtx, type OnDeleteAction, type PaginationOptions, type PaginationResult, type QueryCtx, type RankIndexDefinition, type RankSortKey, type ReadOnlyStorage, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMutation, type RegisteredQuery, type RegisteredStream, type RelationDefinition, type RestCacheConfig, type RunQueryOptions, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type Schema, type SearchFilterBuilder, type SearchIndexDefinition, type SearchLanguage, type SearchStrategy, type Secrets, type SecretsStoreSecretLike, type ShardInitEvent, type ShardMode, type SpanEvaluation, type SpanHandle, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type StorageObjectHead, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableDefinition, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerBuilder, type TriggerCtx, type TriggerDatabase, type TriggerDefinition, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorEmbedder, type VectorIndexDefinition, type VectorMatch, type VectorMatches, type VectorMetric, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowEventDefinition, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, type X402ProcedureConfig, anyApi };
|
|
2270
|
+
export { type ActionCtx, type AggregateIndexDefinition, type AggregateOp, type AnyApi, type ArgsValidator, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type DurableObjectJurisdiction, type DurableStreamOptions, type ExposeConfig, type ExternalSourceCursor, type ExternalSourceDefinition, type ExternalSourceMode, type ExternalSourceRefresh, type FunctionKind, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type GlobalBackend, type IndexDefinition, type IndexRangeBuilder, type InferArgs, type LifecycleEvent, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type MutationCtx, type MutationStorage, type OnDeleteAction, type PaginationOptions, type PaginationResult, type QueryCtx, type RankIndexDefinition, type RankSortKey, type ReadOnlyStorage, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMutation, type RegisteredQuery, type RegisteredStream, type RelationDefinition, type RestCacheConfig, type RunQueryOptions, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type Schema, type SearchFilterBuilder, type SearchIndexDefinition, type SearchLanguage, type SearchStrategy, type Secrets, type SecretsStoreSecretLike, type ShardInitEvent, type ShardMode, type SpanEvaluation, type SpanHandle, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type StorageObjectHead, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableDefinition, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerBuilder, type TriggerCtx, type TriggerDatabase, type TriggerDefinition, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorEmbedder, type VectorIndexDefinition, type VectorMatch, type VectorMatches, type VectorMetric, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowEventDefinition, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, type X402ProcedureConfig, anyApi };
|
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.85",
|
|
4
4
|
"description": "Server primitives for Lunora: defineSchema, defineTable, query, mutation, and action",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"backend",
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
"access": "public"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
70
|
-
"@lunora/scheduler": "1.0.0-alpha.
|
|
71
|
-
"@lunora/values": "1.0.0-alpha.
|
|
69
|
+
"@lunora/errors": "1.0.0-alpha.24",
|
|
70
|
+
"@lunora/scheduler": "1.0.0-alpha.39",
|
|
71
|
+
"@lunora/values": "1.0.0-alpha.29",
|
|
72
72
|
"drizzle-orm": "^0.45.2",
|
|
73
73
|
"hono": "^4.13.1"
|
|
74
74
|
},
|