@lunora/server 1.0.0-alpha.278 → 1.0.0-alpha.279
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
CHANGED
|
@@ -3748,6 +3748,20 @@ interface PresenceFunctions {
|
|
|
3748
3748
|
}, {
|
|
3749
3749
|
lastSeen: number;
|
|
3750
3750
|
}>;
|
|
3751
|
+
/**
|
|
3752
|
+
* Drop the caller's own row for `(roomId, sessionId)` now, instead of
|
|
3753
|
+
* leaving it to age out. The client adapters call it (when given a `leave`
|
|
3754
|
+
* reference) as a room is left while the socket stays open — a room switch or
|
|
3755
|
+
* an unmount — which `disconnect` never sees. The same ownership gate as
|
|
3756
|
+
* `disconnect`: a row held by another identity is left alone, so the result
|
|
3757
|
+
* says whether a row was removed.
|
|
3758
|
+
*/
|
|
3759
|
+
leave: RegisteredMutation<{
|
|
3760
|
+
roomId: StringColumnValidator;
|
|
3761
|
+
sessionId: StringColumnValidator;
|
|
3762
|
+
}, {
|
|
3763
|
+
left: boolean;
|
|
3764
|
+
}>;
|
|
3751
3765
|
/**
|
|
3752
3766
|
* Live query returning the non-expired members of `roomId` in the caller's
|
|
3753
3767
|
* tenant, newest heartbeat first. Subscribe to it for a reactive "who's
|
package/dist/index.d.ts
CHANGED
|
@@ -3748,6 +3748,20 @@ interface PresenceFunctions {
|
|
|
3748
3748
|
}, {
|
|
3749
3749
|
lastSeen: number;
|
|
3750
3750
|
}>;
|
|
3751
|
+
/**
|
|
3752
|
+
* Drop the caller's own row for `(roomId, sessionId)` now, instead of
|
|
3753
|
+
* leaving it to age out. The client adapters call it (when given a `leave`
|
|
3754
|
+
* reference) as a room is left while the socket stays open — a room switch or
|
|
3755
|
+
* an unmount — which `disconnect` never sees. The same ownership gate as
|
|
3756
|
+
* `disconnect`: a row held by another identity is left alone, so the result
|
|
3757
|
+
* says whether a row was removed.
|
|
3758
|
+
*/
|
|
3759
|
+
leave: RegisteredMutation<{
|
|
3760
|
+
roomId: StringColumnValidator;
|
|
3761
|
+
sessionId: StringColumnValidator;
|
|
3762
|
+
}, {
|
|
3763
|
+
left: boolean;
|
|
3764
|
+
}>;
|
|
3751
3765
|
/**
|
|
3752
3766
|
* Live query returning the non-expired members of `roomId` in the caller's
|
|
3753
3767
|
* tenant, newest heartbeat first. Subscribe to it for a reactive "who's
|
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-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-
|
|
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-aj9Ec70J.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as b}from"@lunora/errors";import{v as n}from"@lunora/values";import{initLunora as x}from"./initLunora-DcvCGLL_.mjs";import{onDisconnect as L}from"./onConnect-BLRoOpv2.mjs";import{g as A,h as D,a as P}from"./plugin-CyLqvCB9.mjs";const N=3e4,B=1024,C=8,E=4096,y="presence",q="present",i=`${y}_${q}`,U=l=>{const c=l?.orgId;return typeof c=="string"?c:""},F=A(y,{tables:{[q]:D({data:n.optional(n.record(n.string(),n.any())),lastSeen:n.number(),roomId:n.string(),sessionId:n.string(),tenantId:n.string(),userId:n.optional(n.string())}).index("byTenantRoomSession",["tenantId","roomId","sessionId"]).index("byTenantRoomLastSeen",["tenantId","roomId","lastSeen"])}}),{internalMutation:O,mutation:p,query:$}=x.dataModel().create(),J=(l={})=>{const c=l.ttlMs??N,S=l.tenant??U,w=Math.max(0,Math.min(l.disconnectGraceMs??0,c)),h=l.maxSessions,T=h!==void 0&&Number.isFinite(h)?Math.max(1,Math.floor(h)):B,g=p.input({data:n.optional(n.record(n.string(),n.any())),roomId:n.string(),sessionId:n.string()}).mutation(async({args:t,ctx:e})=>{const a=Date.now(),o=e.auth.userId??void 0,s=S(await e.auth.getIdentity());if(t.data!==void 0&&new TextEncoder().encode(JSON.stringify(t.data)).length>E)throw new b("BAD_REQUEST",`presence data exceeds the ${String(E)}-byte limit`);const d=await e.db.query(i).withIndex("byTenantRoomSession",I=>I.eq("tenantId",s).eq("roomId",t.roomId).eq("sessionId",t.sessionId)).first();if(d&&(d.userId??void 0)!==o)throw new b("FORBIDDEN","presence heartbeat denied: this (roomId, sessionId) is held by another identity");const m={lastSeen:a,roomId:t.roomId,sessionId:t.sessionId,tenantId:s,...t.data===void 0?{}:{data:t.data},...o===void 0?{}:{userId:o}};await(d?e.db.patch(i,d._id,m):e.db.insert(i,m));const f=a-c-Math.max(w,c),u=(await e.db.query(i).withIndex("byTenantRoomLastSeen",I=>I.eq("tenantId",s).eq("roomId",t.roomId)).order("asc").take(C)).filter(I=>I.lastSeen<=f);return await Promise.all(u.map(I=>e.db.delete(i,I._id))),{lastSeen:a}}),_=$.input({roomId:n.string()}).query(async({args:t,ctx:e})=>{const a=Date.now()-c,o=S(await e.auth.getIdentity()),d=(await e.db.query(i).withIndex("byTenantRoomLastSeen",r=>r.eq("tenantId",o).eq("roomId",t.roomId)).order("desc").take(T)).filter(r=>r.lastSeen>a),m=new Set,f=[];for(const r of d){const u=r.userId;if(u!==void 0){if(m.has(u))continue;m.add(u)}const I={lastSeen:r.lastSeen,roomId:r.roomId};u!==void 0&&(I.userId=u),r.data!==void 0&&(I.data=r.data),f.push(I)}return f}),M=p.input({roomId:n.string(),sessionId:n.string()}).mutation(async({args:t,ctx:e})=>{const a=S(await e.auth.getIdentity()),o=await e.db.query(i).withIndex("byTenantRoomSession",s=>s.eq("tenantId",a).eq("roomId",t.roomId).eq("sessionId",t.sessionId)).first();return!o||(o.userId??void 0)!==(e.auth.userId??void 0)?{left:!1}:(await e.db.delete(i,o._id),{left:!0})}),R=O.input({roomId:n.string(),tenantId:n.string()}).mutation(async({args:t,ctx:e})=>{const a=Date.now()-c,o=await e.db.query(i).withIndex("byTenantRoomLastSeen",s=>s.eq("tenantId",t.tenantId).eq("roomId",t.roomId)).filter(s=>s.lastSeen<=a).collect();return await Promise.all(o.map(s=>e.db.delete(i,s._id))),{deleted:o.length}}),v=L(async(t,e)=>{const a=e.context?.roomId,o=e.context?.sessionId;if(typeof a!="string"||typeof o!="string")return;const s=S(await t.auth.getIdentity()),d=await t.db.query(i).withIndex("byTenantRoomSession",r=>r.eq("tenantId",s).eq("roomId",a).eq("sessionId",o)).first();if(!d)return;const m=e.userId??void 0;if((d.userId??void 0)!==m)return;if(w===0){await t.db.delete(i,d._id);return}const f=Math.min(d.lastSeen,Date.now()+w-c);await t.db.patch(i,d._id,{lastSeen:f})});return P(y,{extension:F,functions:{disconnect:v,heartbeat:g,leave:M,listPresent:_,sweep:R}})};export{N as PRESENCE_DEFAULT_TTL_MS,i as PRESENCE_TABLE,J as definePresence,F as presenceExtension};
|
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.279",
|
|
4
4
|
"description": "Server primitives for Lunora: defineSchema, defineTable, query, mutation, and action",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"backend",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@lunora/errors": ">=1.0.0-alpha.77 <2.0.0-0",
|
|
76
76
|
"@lunora/scheduler": "^1.0.0-alpha.173",
|
|
77
|
-
"@lunora/shard-engine": "^1.0.0-alpha.
|
|
77
|
+
"@lunora/shard-engine": "^1.0.0-alpha.206",
|
|
78
78
|
"@lunora/values": "^1.0.0-alpha.95",
|
|
79
79
|
"@lunora/wire": "1.0.0-alpha.6",
|
|
80
80
|
"drizzle-orm": "1.0.0-rc.5",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as E}from"@lunora/errors";import{v as e}from"@lunora/values";import{initLunora as x}from"./initLunora-DcvCGLL_.mjs";import{onDisconnect as R}from"./onConnect-BLRoOpv2.mjs";import{g as L,h as A,a as v}from"./plugin-CyLqvCB9.mjs";const D=3e4,P=1024,N=8,b=4096,y="presence",p="present",r=`${y}_${p}`,B=l=>{const I=l?.orgId;return typeof I=="string"?I:""},C=L(y,{tables:{[p]:A({data:e.optional(e.record(e.string(),e.any())),lastSeen:e.number(),roomId:e.string(),sessionId:e.string(),tenantId:e.string(),userId:e.optional(e.string())}).index("byTenantRoomSession",["tenantId","roomId","sessionId"]).index("byTenantRoomLastSeen",["tenantId","roomId","lastSeen"])}}),{internalMutation:U,mutation:F,query:O}=x.dataModel().create(),H=(l={})=>{const I=l.ttlMs??D,S=l.tenant??B,w=Math.max(0,Math.min(l.disconnectGraceMs??0,I)),h=l.maxSessions,T=h!==void 0&&Number.isFinite(h)?Math.max(1,Math.floor(h)):P,_=F.input({data:e.optional(e.record(e.string(),e.any())),roomId:e.string(),sessionId:e.string()}).mutation(async({args:t,ctx:n})=>{const c=Date.now(),d=n.auth.userId??void 0,o=S(await n.auth.getIdentity());if(t.data!==void 0&&new TextEncoder().encode(JSON.stringify(t.data)).length>b)throw new E("BAD_REQUEST",`presence data exceeds the ${String(b)}-byte limit`);const s=await n.db.query(r).withIndex("byTenantRoomSession",i=>i.eq("tenantId",o).eq("roomId",t.roomId).eq("sessionId",t.sessionId)).first();if(s&&(s.userId??void 0)!==d)throw new E("FORBIDDEN","presence heartbeat denied: this (roomId, sessionId) is held by another identity");const m={lastSeen:c,roomId:t.roomId,sessionId:t.sessionId,tenantId:o,...t.data===void 0?{}:{data:t.data},...d===void 0?{}:{userId:d}};await(s?n.db.patch(r,s._id,m):n.db.insert(r,m));const f=c-I-Math.max(w,I),u=(await n.db.query(r).withIndex("byTenantRoomLastSeen",i=>i.eq("tenantId",o).eq("roomId",t.roomId)).order("asc").take(N)).filter(i=>i.lastSeen<=f);return await Promise.all(u.map(i=>n.db.delete(r,i._id))),{lastSeen:c}}),q=O.input({roomId:e.string()}).query(async({args:t,ctx:n})=>{const c=Date.now()-I,d=S(await n.auth.getIdentity()),s=(await n.db.query(r).withIndex("byTenantRoomLastSeen",a=>a.eq("tenantId",d).eq("roomId",t.roomId)).order("desc").take(T)).filter(a=>a.lastSeen>c),m=new Set,f=[];for(const a of s){const u=a.userId;if(u!==void 0){if(m.has(u))continue;m.add(u)}const i={lastSeen:a.lastSeen,roomId:a.roomId};u!==void 0&&(i.userId=u),a.data!==void 0&&(i.data=a.data),f.push(i)}return f}),g=U.input({roomId:e.string(),tenantId:e.string()}).mutation(async({args:t,ctx:n})=>{const c=Date.now()-I,d=await n.db.query(r).withIndex("byTenantRoomLastSeen",o=>o.eq("tenantId",t.tenantId).eq("roomId",t.roomId)).filter(o=>o.lastSeen<=c).collect();return await Promise.all(d.map(o=>n.db.delete(r,o._id))),{deleted:d.length}}),M=R(async(t,n)=>{const c=n.context?.roomId,d=n.context?.sessionId;if(typeof c!="string"||typeof d!="string")return;const o=S(await t.auth.getIdentity()),s=await t.db.query(r).withIndex("byTenantRoomSession",a=>a.eq("tenantId",o).eq("roomId",c).eq("sessionId",d)).first();if(!s)return;const m=n.userId??void 0;if((s.userId??void 0)!==m)return;if(w===0){await t.db.delete(r,s._id);return}const f=Math.min(s.lastSeen,Date.now()+w-I);await t.db.patch(r,s._id,{lastSeen:f})});return v(y,{extension:C,functions:{disconnect:M,heartbeat:_,listPresent:q,sweep:g}})};export{D as PRESENCE_DEFAULT_TTL_MS,r as PRESENCE_TABLE,H as definePresence,C as presenceExtension};
|