@party-stack/runtime 0.2.0
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/LICENSE +21 -0
- package/lib/coordinator/createPersistedCollectionCoordinator.d.ts +4 -0
- package/lib/coordinator/createPersistedCollectionCoordinator.d.ts.map +1 -0
- package/lib/coordinator/createPersistedCollectionCoordinator.js +283 -0
- package/lib/coordinator/createPersistedCollectionCoordinator.js.map +1 -0
- package/lib/coordinator/index.d.ts +2 -0
- package/lib/coordinator/index.d.ts.map +1 -0
- package/lib/coordinator/index.js +2 -0
- package/lib/coordinator/index.js.map +1 -0
- package/lib/effection/index.d.ts +5 -0
- package/lib/effection/index.d.ts.map +1 -0
- package/lib/effection/index.js +28 -0
- package/lib/effection/index.js.map +1 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -0
- package/lib/memory/MemoryBlobBytesStore.d.ts +9 -0
- package/lib/memory/MemoryBlobBytesStore.d.ts.map +1 -0
- package/lib/memory/MemoryBlobBytesStore.js +21 -0
- package/lib/memory/MemoryBlobBytesStore.js.map +1 -0
- package/lib/memory/MemoryBlobBytesStore.test.d.ts +2 -0
- package/lib/memory/MemoryBlobBytesStore.test.d.ts.map +1 -0
- package/lib/memory/MemoryBlobBytesStore.test.js +12 -0
- package/lib/memory/MemoryBlobBytesStore.test.js.map +1 -0
- package/lib/types.d.ts +23 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/utils/createDefaultRuntime.d.ts +3 -0
- package/lib/utils/createDefaultRuntime.d.ts.map +1 -0
- package/lib/utils/createDefaultRuntime.js +14 -0
- package/lib/utils/createDefaultRuntime.js.map +1 -0
- package/lib/utils/createLocalCollection.d.ts +9 -0
- package/lib/utils/createLocalCollection.d.ts.map +1 -0
- package/lib/utils/createLocalCollection.js +21 -0
- package/lib/utils/createLocalCollection.js.map +1 -0
- package/lib/utils/createLocalCollection.test.d.ts +2 -0
- package/lib/utils/createLocalCollection.test.d.ts.map +1 -0
- package/lib/utils/createLocalCollection.test.js +236 -0
- package/lib/utils/createLocalCollection.test.js.map +1 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Robert Fidler
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Coordination } from "@party-stack/coordination";
|
|
2
|
+
import type { PersistedCollectionCoordinator, PersistenceAdapter } from "@tanstack/db-sqlite-persistence-core";
|
|
3
|
+
export declare function createPersistedCollectionCoordinator(coordination: Coordination, adapter: PersistenceAdapter): PersistedCollectionCoordinator;
|
|
4
|
+
//# sourceMappingURL=createPersistedCollectionCoordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPersistedCollectionCoordinator.d.ts","sourceRoot":"","sources":["../../src/coordinator/createPersistedCollectionCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,YAAY,EAGpB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,KAAK,EAER,8BAA8B,EAG9B,kBAAkB,EAIrB,MAAM,sCAAsC,CAAC;AAuI9C,wBAAgB,oCAAoC,CAChD,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,kBAAkB,GAC5B,8BAA8B,CAgBhC"}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { isCoordinationHost, } from "@party-stack/coordination";
|
|
2
|
+
import { safeRandomUUID } from "@tanstack/db-sqlite-persistence-core";
|
|
3
|
+
const PERSISTENCE_SERVICE = "party-stack.persistence.v1";
|
|
4
|
+
const MAX_DEDUPLICATION_ENTRIES = 1_000;
|
|
5
|
+
const MAX_PENDING_RELAYS = 1_000;
|
|
6
|
+
const coordinatorCache = new WeakMap();
|
|
7
|
+
function isRecord(value) {
|
|
8
|
+
return (typeof value === "object" &&
|
|
9
|
+
value !== null);
|
|
10
|
+
}
|
|
11
|
+
function relayKey(collectionId, message) {
|
|
12
|
+
const payload = isRecord(message.payload)
|
|
13
|
+
? message.payload
|
|
14
|
+
: {};
|
|
15
|
+
return JSON.stringify([
|
|
16
|
+
collectionId,
|
|
17
|
+
message.senderId,
|
|
18
|
+
payload.type,
|
|
19
|
+
payload.txId,
|
|
20
|
+
payload.resetEpoch,
|
|
21
|
+
payload.term,
|
|
22
|
+
payload.seq,
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
export function createPersistedCollectionCoordinator(coordination, adapter) {
|
|
26
|
+
let adapters = coordinatorCache.get(coordination);
|
|
27
|
+
if (!adapters) {
|
|
28
|
+
adapters = new WeakMap();
|
|
29
|
+
coordinatorCache.set(coordination, adapters);
|
|
30
|
+
}
|
|
31
|
+
const existing = adapters.get(adapter);
|
|
32
|
+
if (existing)
|
|
33
|
+
return existing;
|
|
34
|
+
const created = new CoordinationPersistenceShim(coordination, adapter);
|
|
35
|
+
adapters.set(adapter, created);
|
|
36
|
+
return created;
|
|
37
|
+
}
|
|
38
|
+
class CoordinationPersistenceShim {
|
|
39
|
+
coordination;
|
|
40
|
+
adapter;
|
|
41
|
+
nodeId = safeRandomUUID();
|
|
42
|
+
positions = new Map();
|
|
43
|
+
appliedEnvelopes = new Map();
|
|
44
|
+
relayedMessages = new Set();
|
|
45
|
+
service;
|
|
46
|
+
server;
|
|
47
|
+
pendingRelays = 0;
|
|
48
|
+
constructor(coordination, adapter) {
|
|
49
|
+
this.coordination = coordination;
|
|
50
|
+
this.adapter = adapter;
|
|
51
|
+
this.service =
|
|
52
|
+
coordination.service(PERSISTENCE_SERVICE);
|
|
53
|
+
this.server = isCoordinationHost(coordination)
|
|
54
|
+
? coordination.serve(PERSISTENCE_SERVICE, {
|
|
55
|
+
ensureLeadership: () => Promise.resolve(),
|
|
56
|
+
ensureRemoteSubset: () => Promise.resolve(),
|
|
57
|
+
ensurePersistedIndex: (input) => this.adapter.ensureIndex(input.collectionId, input.signature, input.spec),
|
|
58
|
+
applyLocalMutations: (input) => this.applyMutations(input),
|
|
59
|
+
pullSince: (input) => this.handlePullSince(input),
|
|
60
|
+
relayMessage: (input) => this.relayMessage(input),
|
|
61
|
+
})
|
|
62
|
+
: undefined;
|
|
63
|
+
}
|
|
64
|
+
getNodeId() {
|
|
65
|
+
return this.nodeId;
|
|
66
|
+
}
|
|
67
|
+
subscribe(collectionId, callback) {
|
|
68
|
+
return this.service.events.subscribe("message", (event) => {
|
|
69
|
+
if (event.collectionId ===
|
|
70
|
+
collectionId) {
|
|
71
|
+
callback(event.message);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
publish(collectionId, message) {
|
|
76
|
+
if (this.server &&
|
|
77
|
+
isCoordinationHost(this.coordination) &&
|
|
78
|
+
this.coordination.isLeader) {
|
|
79
|
+
this.publishMessage({
|
|
80
|
+
collectionId,
|
|
81
|
+
message,
|
|
82
|
+
});
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (this.pendingRelays >=
|
|
86
|
+
MAX_PENDING_RELAYS) {
|
|
87
|
+
console.warn(`Dropping persistence relay for "${collectionId}" because the pending relay limit was reached.`);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
this.pendingRelays += 1;
|
|
91
|
+
void this.service.methods
|
|
92
|
+
.relayMessage({
|
|
93
|
+
collectionId,
|
|
94
|
+
message,
|
|
95
|
+
})
|
|
96
|
+
.catch((error) => {
|
|
97
|
+
console.warn(`Failed to relay persistence message for "${collectionId}".`, error);
|
|
98
|
+
})
|
|
99
|
+
.finally(() => {
|
|
100
|
+
this.pendingRelays -= 1;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
isLeader() {
|
|
104
|
+
return (isCoordinationHost(this.coordination) &&
|
|
105
|
+
this.coordination.isLeader);
|
|
106
|
+
}
|
|
107
|
+
ensureLeadership() {
|
|
108
|
+
return this.service.methods.ensureLeadership({
|
|
109
|
+
collectionId: "*",
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
requestEnsureRemoteSubset(collectionId, options) {
|
|
113
|
+
const serializableOptions = { ...options };
|
|
114
|
+
delete serializableOptions.subscription;
|
|
115
|
+
return this.service.methods.ensureRemoteSubset({
|
|
116
|
+
collectionId,
|
|
117
|
+
options: serializableOptions,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
requestEnsurePersistedIndex(collectionId, signature, spec) {
|
|
121
|
+
return this.service.methods.ensurePersistedIndex({
|
|
122
|
+
collectionId,
|
|
123
|
+
signature,
|
|
124
|
+
spec,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
requestApplyLocalMutations(collectionId, mutations) {
|
|
128
|
+
return this.service.methods.applyLocalMutations({
|
|
129
|
+
collectionId,
|
|
130
|
+
rpcId: safeRandomUUID(),
|
|
131
|
+
envelopeId: safeRandomUUID(),
|
|
132
|
+
mutations,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
pullSince(collectionId, fromRowVersion) {
|
|
136
|
+
return this.service.methods.pullSince({
|
|
137
|
+
collectionId,
|
|
138
|
+
rpcId: safeRandomUUID(),
|
|
139
|
+
fromRowVersion,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
relayMessage(input) {
|
|
143
|
+
const key = relayKey(input.collectionId, input.message);
|
|
144
|
+
if (this.relayedMessages.has(key)) {
|
|
145
|
+
return Promise.resolve();
|
|
146
|
+
}
|
|
147
|
+
this.relayedMessages.add(key);
|
|
148
|
+
if (this.relayedMessages.size >
|
|
149
|
+
MAX_DEDUPLICATION_ENTRIES) {
|
|
150
|
+
const oldest = this.relayedMessages.values().next()
|
|
151
|
+
.value;
|
|
152
|
+
if (oldest) {
|
|
153
|
+
this.relayedMessages.delete(oldest);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
this.publishMessage(input);
|
|
157
|
+
return Promise.resolve();
|
|
158
|
+
}
|
|
159
|
+
publishMessage(input) {
|
|
160
|
+
this.server?.events.publish("message", input);
|
|
161
|
+
}
|
|
162
|
+
async position(collectionId) {
|
|
163
|
+
let position = this.positions.get(collectionId);
|
|
164
|
+
if (!position) {
|
|
165
|
+
position = Promise.resolve(this.adapter.getStreamPosition?.(collectionId)).then((current) => ({
|
|
166
|
+
term: (current?.latestTerm ?? 0) + 1,
|
|
167
|
+
seq: current?.latestSeq ?? 0,
|
|
168
|
+
rowVersion: current?.latestRowVersion ?? 0,
|
|
169
|
+
}));
|
|
170
|
+
this.positions.set(collectionId, position);
|
|
171
|
+
}
|
|
172
|
+
return position;
|
|
173
|
+
}
|
|
174
|
+
async applyMutations(input) {
|
|
175
|
+
const previous = this.appliedEnvelopes.get(input.envelopeId);
|
|
176
|
+
if (previous) {
|
|
177
|
+
return {
|
|
178
|
+
...previous,
|
|
179
|
+
rpcId: input.rpcId,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
const position = await this.position(input.collectionId);
|
|
183
|
+
position.seq += 1;
|
|
184
|
+
position.rowVersion += 1;
|
|
185
|
+
const txId = input.envelopeId;
|
|
186
|
+
await this.adapter.applyCommittedTx(input.collectionId, {
|
|
187
|
+
txId,
|
|
188
|
+
term: position.term,
|
|
189
|
+
seq: position.seq,
|
|
190
|
+
rowVersion: position.rowVersion,
|
|
191
|
+
mutations: input.mutations.map((mutation) => ({
|
|
192
|
+
type: mutation.type,
|
|
193
|
+
key: mutation.key,
|
|
194
|
+
value: mutation.value,
|
|
195
|
+
})),
|
|
196
|
+
});
|
|
197
|
+
const committed = {
|
|
198
|
+
v: 1,
|
|
199
|
+
dbName: this.coordinationScope(),
|
|
200
|
+
collectionId: input.collectionId,
|
|
201
|
+
senderId: this.nodeId,
|
|
202
|
+
ts: Date.now(),
|
|
203
|
+
payload: {
|
|
204
|
+
type: "tx:committed",
|
|
205
|
+
term: position.term,
|
|
206
|
+
seq: position.seq,
|
|
207
|
+
txId,
|
|
208
|
+
latestRowVersion: position.rowVersion,
|
|
209
|
+
requiresFullReload: false,
|
|
210
|
+
changedRows: input.mutations
|
|
211
|
+
.filter((mutation) => mutation.type !==
|
|
212
|
+
"delete")
|
|
213
|
+
.map((mutation) => ({
|
|
214
|
+
key: mutation.key,
|
|
215
|
+
value: mutation.value,
|
|
216
|
+
})),
|
|
217
|
+
deletedKeys: input.mutations
|
|
218
|
+
.filter((mutation) => mutation.type ===
|
|
219
|
+
"delete")
|
|
220
|
+
.map((mutation) => mutation.key),
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
this.publishMessage({
|
|
224
|
+
collectionId: input.collectionId,
|
|
225
|
+
message: committed,
|
|
226
|
+
});
|
|
227
|
+
const response = {
|
|
228
|
+
type: "rpc:applyLocalMutations:res",
|
|
229
|
+
rpcId: input.rpcId,
|
|
230
|
+
ok: true,
|
|
231
|
+
term: position.term,
|
|
232
|
+
seq: position.seq,
|
|
233
|
+
latestRowVersion: position.rowVersion,
|
|
234
|
+
acceptedMutationIds: input.mutations.map((mutation) => mutation.mutationId),
|
|
235
|
+
};
|
|
236
|
+
this.appliedEnvelopes.set(input.envelopeId, response);
|
|
237
|
+
if (this.appliedEnvelopes.size >
|
|
238
|
+
MAX_DEDUPLICATION_ENTRIES) {
|
|
239
|
+
const oldest = this.appliedEnvelopes.keys().next()
|
|
240
|
+
.value;
|
|
241
|
+
if (oldest) {
|
|
242
|
+
this.appliedEnvelopes.delete(oldest);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return response;
|
|
246
|
+
}
|
|
247
|
+
async handlePullSince(input) {
|
|
248
|
+
const position = await this.position(input.collectionId);
|
|
249
|
+
const result = await this.adapter.pullSince?.(input.collectionId, input.fromRowVersion);
|
|
250
|
+
if (!result || result.requiresFullReload) {
|
|
251
|
+
return {
|
|
252
|
+
type: "rpc:pullSince:res",
|
|
253
|
+
rpcId: input.rpcId,
|
|
254
|
+
ok: true,
|
|
255
|
+
latestTerm: position.term,
|
|
256
|
+
latestSeq: position.seq,
|
|
257
|
+
latestRowVersion: result?.latestRowVersion ??
|
|
258
|
+
position.rowVersion,
|
|
259
|
+
requiresFullReload: true,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
return {
|
|
263
|
+
type: "rpc:pullSince:res",
|
|
264
|
+
rpcId: input.rpcId,
|
|
265
|
+
ok: true,
|
|
266
|
+
latestTerm: position.term,
|
|
267
|
+
latestSeq: position.seq,
|
|
268
|
+
latestRowVersion: result.latestRowVersion,
|
|
269
|
+
requiresFullReload: false,
|
|
270
|
+
changedKeys: result.changedKeys,
|
|
271
|
+
deletedKeys: result.deletedKeys,
|
|
272
|
+
deltas: result.deltas,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
coordinationScope() {
|
|
276
|
+
return "scope" in this.coordination &&
|
|
277
|
+
typeof this.coordination.scope ===
|
|
278
|
+
"string"
|
|
279
|
+
? this.coordination.scope
|
|
280
|
+
: "party-stack";
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=createPersistedCollectionCoordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPersistedCollectionCoordinator.js","sourceRoot":"","sources":["../../src/coordinator/createPersistedCollectionCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,kBAAkB,GAIrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAatE,MAAM,mBAAmB,GACrB,4BAA4B,CAAC;AACjC,MAAM,yBAAyB,GAAG,KAAK,CAAC;AACxC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AA+FjC,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAMjC,CAAC;AAEJ,SAAS,QAAQ,CACb,KAAc;IAEd,OAAO,CACH,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI,CACjB,CAAC;AACN,CAAC;AAED,SAAS,QAAQ,CACb,YAAoB,EACpB,OAAkC;IAElC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC;QACrC,CAAC,CAAC,OAAO,CAAC,OAAO;QACjB,CAAC,CAAC,EAAE,CAAC;IACT,OAAO,IAAI,CAAC,SAAS,CAAC;QAClB,YAAY;QACZ,OAAO,CAAC,QAAQ;QAChB,OAAO,CAAC,IAAI;QACZ,OAAO,CAAC,IAAI;QACZ,OAAO,CAAC,UAAU;QAClB,OAAO,CAAC,IAAI;QACZ,OAAO,CAAC,GAAG;KACd,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,oCAAoC,CAChD,YAA0B,EAC1B,OAA2B;IAE3B,IAAI,QAAQ,GACR,gBAAgB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YACR,UAAU,EAAE,QAAQ,CAAC,IAAI;YACzB,SAAS,EAAE,QAAQ,CAAC,GAAG;YACvB,gBAAgB,EACZ,MAAM,CAAC,gBAAgB;YAC3B,kBAAkB,EAAE,KAAK;YACzB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,MAAM,EAAE,MAAM,CAAC,MAAM;SACxB,CAAC;IACN,CAAC;IAEO,iBAAiB;QACrB,OAAO,OAAO,IAAI,IAAI,CAAC,YAAY;YAC/B,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK;gBAC1B,QAAQ;YACZ,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK;YACzB,CAAC,CAAC,aAAa,CAAC;IACxB,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/coordinator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,2CAA2C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/coordinator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,2CAA2C,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Operation, type Stream } from "effection";
|
|
2
|
+
import type { RuntimeAdapter, RuntimeAdapterProvider } from "../types.js";
|
|
3
|
+
export declare function useRuntimeAdapter(provider: RuntimeAdapter | RuntimeAdapterProvider, owner: string, namespace: string): Operation<RuntimeAdapter>;
|
|
4
|
+
export declare function useConnectivityChanges(runtime: RuntimeAdapter): Operation<Stream<boolean, void>>;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/effection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,SAAS,EACd,KAAK,MAAM,EACd,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EACR,cAAc,EACd,sBAAsB,EACzB,MAAM,aAAa,CAAC;AAErB,wBAAgB,iBAAiB,CAC7B,QAAQ,EAAE,cAAc,GAAG,sBAAsB,EACjD,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAClB,SAAS,CAAC,cAAc,CAAC,CAgB3B;AAED,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,cAAc,GACxB,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAalC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createSignal, resource, until, } from "effection";
|
|
2
|
+
export function useRuntimeAdapter(provider, owner, namespace) {
|
|
3
|
+
return resource(function* (provide) {
|
|
4
|
+
const runtime = typeof provider === "function"
|
|
5
|
+
? yield* until(Promise.resolve(provider(owner, namespace)))
|
|
6
|
+
: provider;
|
|
7
|
+
try {
|
|
8
|
+
yield* provide(runtime);
|
|
9
|
+
}
|
|
10
|
+
finally {
|
|
11
|
+
yield* until(Promise.resolve(runtime.cleanup?.()));
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export function useConnectivityChanges(runtime) {
|
|
16
|
+
return resource(function* (provide) {
|
|
17
|
+
const signal = createSignal();
|
|
18
|
+
const unsubscribe = runtime.connectivity?.subscribe((isConnected) => signal.send(isConnected));
|
|
19
|
+
try {
|
|
20
|
+
yield* provide(signal);
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
unsubscribe?.();
|
|
24
|
+
signal.close();
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/effection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EACZ,QAAQ,EACR,KAAK,GAGR,MAAM,WAAW,CAAC;AAMnB,MAAM,UAAU,iBAAiB,CAC7B,QAAiD,EACjD,KAAa,EACb,SAAiB;IAEjB,OAAO,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO;QAC9B,MAAM,OAAO,GACT,OAAO,QAAQ,KAAK,UAAU;YAC1B,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CACR,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAC9C;YACH,CAAC,CAAC,QAAQ,CAAC;QACnB,IAAI,CAAC;YACD,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC5B,CAAC;gBAAS,CAAC;YACP,KAAK,CAAC,CAAC,KAAK,CACR,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CACvC,CAAC;QACN,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,sBAAsB,CAClC,OAAuB;IAEvB,OAAO,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO;QAC9B,MAAM,MAAM,GAAG,YAAY,EAAiB,CAAC;QAC7C,MAAM,WAAW,GAAG,OAAO,CAAC,YAAY,EAAE,SAAS,CAC/C,CAAC,WAAW,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAC5C,CAAC;QACF,IAAI,CAAC;YACD,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC;gBAAS,CAAC;YACP,WAAW,EAAE,EAAE,CAAC;YAChB,MAAM,CAAC,KAAK,EAAE,CAAC;QACnB,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { createPersistedCollectionCoordinator, } from "./coordinator/index.js";
|
|
2
|
+
export { createDefaultRuntime } from "./utils/createDefaultRuntime.js";
|
|
3
|
+
export { createLocalCollection } from "./utils/createLocalCollection.js";
|
|
4
|
+
export { MemoryBlobBytesStore } from "./memory/MemoryBlobBytesStore.js";
|
|
5
|
+
export { CoordinationClosedError, CoordinationError, CoordinationProtocolError, CoordinationServiceError, CoordinationTaskRejectedError, CoordinationTransportError, LockBroadcastCoordination, SingleProcessCoordination, isCoordinationHost, } from "@party-stack/coordination";
|
|
6
|
+
export type { BlobBytesStore, NetworkConnectivity, PersistenceAdapter, RuntimeAdapter, RuntimeAdapterProvider, } from "./types.js";
|
|
7
|
+
export type { Coordination, CoordinationCallOptions, CoordinationClient, CoordinationErrorCode, CoordinationHost, CoordinationMethodInput, CoordinationMethodResult, CoordinationOptions, CoordinationService, CoordinationServiceClient, CoordinationServiceEvents, CoordinationServiceHandler, CoordinationServiceHandlers, CoordinationServiceMethods, CoordinationServicePublisher, CoordinationServiceServer, CoordinationTaskContext, LockBroadcastCoordinationOptions, } from "@party-stack/coordination";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oCAAoC,GACvC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EACH,uBAAuB,EACvB,iBAAiB,EACjB,yBAAyB,EACzB,wBAAwB,EACxB,6BAA6B,EAC7B,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,EACzB,kBAAkB,GACrB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACR,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,sBAAsB,GACzB,MAAM,YAAY,CAAC;AACpB,YAAY,EACR,YAAY,EACZ,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,4BAA4B,EAC5B,yBAAyB,EACzB,uBAAuB,EACvB,gCAAgC,GACnC,MAAM,2BAA2B,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createPersistedCollectionCoordinator, } from "./coordinator/index.js";
|
|
2
|
+
export { createDefaultRuntime } from "./utils/createDefaultRuntime.js";
|
|
3
|
+
export { createLocalCollection } from "./utils/createLocalCollection.js";
|
|
4
|
+
export { MemoryBlobBytesStore } from "./memory/MemoryBlobBytesStore.js";
|
|
5
|
+
export { CoordinationClosedError, CoordinationError, CoordinationProtocolError, CoordinationServiceError, CoordinationTaskRejectedError, CoordinationTransportError, LockBroadcastCoordination, SingleProcessCoordination, isCoordinationHost, } from "@party-stack/coordination";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oCAAoC,GACvC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EACH,uBAAuB,EACvB,iBAAiB,EACjB,yBAAyB,EACzB,wBAAwB,EACxB,6BAA6B,EAC7B,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,EACzB,kBAAkB,GACrB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BlobBytesStore } from "../types.js";
|
|
2
|
+
export declare class MemoryBlobBytesStore implements BlobBytesStore {
|
|
3
|
+
readonly blobs: Map<string, Blob>;
|
|
4
|
+
constructor(blobs?: Map<string, Blob>);
|
|
5
|
+
write(id: string, blob: Blob): Promise<void>;
|
|
6
|
+
read(id: string): Promise<Blob>;
|
|
7
|
+
delete(id: string): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=MemoryBlobBytesStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MemoryBlobBytesStore.d.ts","sourceRoot":"","sources":["../../src/memory/MemoryBlobBytesStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,qBAAa,oBAAqB,YAAW,cAAc;IAC3C,QAAQ,CAAC,KAAK;gBAAL,KAAK,oBAA0B;IAEpD,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAK5C,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO/B,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAIpC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export class MemoryBlobBytesStore {
|
|
2
|
+
blobs;
|
|
3
|
+
constructor(blobs = new Map()) {
|
|
4
|
+
this.blobs = blobs;
|
|
5
|
+
}
|
|
6
|
+
write(id, blob) {
|
|
7
|
+
this.blobs.set(id, blob);
|
|
8
|
+
return Promise.resolve();
|
|
9
|
+
}
|
|
10
|
+
read(id) {
|
|
11
|
+
const blob = this.blobs.get(id);
|
|
12
|
+
return blob
|
|
13
|
+
? Promise.resolve(blob)
|
|
14
|
+
: Promise.reject(new Error(`Blob bytes not found for "${id}".`));
|
|
15
|
+
}
|
|
16
|
+
delete(id) {
|
|
17
|
+
this.blobs.delete(id);
|
|
18
|
+
return Promise.resolve();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=MemoryBlobBytesStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MemoryBlobBytesStore.js","sourceRoot":"","sources":["../../src/memory/MemoryBlobBytesStore.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,oBAAoB;IACR;IAArB,YAAqB,QAAQ,IAAI,GAAG,EAAgB;QAA/B,UAAK,GAAL,KAAK,CAA0B;IAAG,CAAC;IAExD,KAAK,CAAC,EAAU,EAAE,IAAU;QACxB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACzB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAED,IAAI,CAAC,EAAU;QACX,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChC,OAAO,IAAI;YACP,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YACvB,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,6BAA6B,EAAE,IAAI,CAAC,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,CAAC,EAAU;QACb,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACtB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MemoryBlobBytesStore.test.d.ts","sourceRoot":"","sources":["../../src/memory/MemoryBlobBytesStore.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { MemoryBlobBytesStore } from "./MemoryBlobBytesStore.js";
|
|
3
|
+
describe("MemoryBlobBytesStore", () => {
|
|
4
|
+
it("stores, reads, and deletes blobs", async () => {
|
|
5
|
+
const store = new MemoryBlobBytesStore();
|
|
6
|
+
await store.write("folder/blob", new Blob(["hello"]));
|
|
7
|
+
expect(await (await store.read("folder/blob")).text()).toBe("hello");
|
|
8
|
+
await store.delete("folder/blob");
|
|
9
|
+
await expect(store.read("folder/blob")).rejects.toThrow('Blob bytes not found for "folder/blob".');
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=MemoryBlobBytesStore.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MemoryBlobBytesStore.test.js","sourceRoot":"","sources":["../../src/memory/MemoryBlobBytesStore.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAC9C,MAAM,KAAK,GAAG,IAAI,oBAAoB,EAAE,CAAC;QACzC,MAAM,KAAK,CAAC,KAAK,CAAC,aAAa,EAAE,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAEtD,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAErE,MAAM,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QAClC,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CACnD,yCAAyC,CAC5C,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Coordination } from "@party-stack/coordination";
|
|
2
|
+
import type { PersistenceAdapter } from "@tanstack/db-sqlite-persistence-core";
|
|
3
|
+
export interface BlobBytesStore {
|
|
4
|
+
write(id: string, blob: Blob): Promise<void>;
|
|
5
|
+
read(id: string): Promise<Blob>;
|
|
6
|
+
delete(id: string): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export interface NetworkConnectivity {
|
|
9
|
+
readonly isConnected: boolean;
|
|
10
|
+
subscribe(callback: (isConnected: boolean) => void): () => void;
|
|
11
|
+
}
|
|
12
|
+
export type { PersistenceAdapter } from "@tanstack/db-sqlite-persistence-core";
|
|
13
|
+
export interface RuntimeAdapter {
|
|
14
|
+
readonly owner: string;
|
|
15
|
+
readonly namespace: string;
|
|
16
|
+
blobBytes: BlobBytesStore;
|
|
17
|
+
coordination: Coordination;
|
|
18
|
+
connectivity?: NetworkConnectivity;
|
|
19
|
+
persistence?: PersistenceAdapter;
|
|
20
|
+
cleanup?: () => void | Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export type RuntimeAdapterProvider = (owner: string, namespace: string) => RuntimeAdapter | Promise<RuntimeAdapter>;
|
|
23
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE/E,MAAM,WAAW,cAAc;IAC3B,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,mBAAmB;IAChC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,SAAS,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACnE;AAED,YAAY,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE/E,MAAM,WAAW,cAAc;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,cAAc,CAAC;IAC1B,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC;AAED,MAAM,MAAM,sBAAsB,GAAG,CACjC,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,KAChB,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC"}
|
package/lib/types.js
ADDED
package/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDefaultRuntime.d.ts","sourceRoot":"","sources":["../../src/utils/createDefaultRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,oBAAoB,CAChC,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAClB,cAAc,CAWhB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SingleProcessCoordination } from "@party-stack/coordination";
|
|
2
|
+
import { MemoryBlobBytesStore } from "../memory/MemoryBlobBytesStore.js";
|
|
3
|
+
export function createDefaultRuntime(owner, namespace) {
|
|
4
|
+
const scope = `party-stack:${owner}:${namespace}`;
|
|
5
|
+
const coordination = new SingleProcessCoordination({ scope });
|
|
6
|
+
return {
|
|
7
|
+
owner,
|
|
8
|
+
namespace,
|
|
9
|
+
blobBytes: new MemoryBlobBytesStore(),
|
|
10
|
+
coordination,
|
|
11
|
+
cleanup: () => coordination.close(),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=createDefaultRuntime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDefaultRuntime.js","sourceRoot":"","sources":["../../src/utils/createDefaultRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAGzE,MAAM,UAAU,oBAAoB,CAChC,KAAa,EACb,SAAiB;IAEjB,MAAM,KAAK,GAAG,eAAe,KAAK,IAAI,SAAS,EAAE,CAAC;IAClD,MAAM,YAAY,GACd,IAAI,yBAAyB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7C,OAAO;QACH,KAAK;QACL,SAAS;QACT,SAAS,EAAE,IAAI,oBAAoB,EAAE;QACrC,YAAY;QACZ,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE;KACtC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Collection } from "@tanstack/db";
|
|
2
|
+
import type { RuntimeAdapter } from "../types.js";
|
|
3
|
+
export declare function createLocalCollection<T extends object, TKey extends string | number>(options: {
|
|
4
|
+
name: string;
|
|
5
|
+
getKey: (value: T) => TKey;
|
|
6
|
+
runtime: RuntimeAdapter;
|
|
7
|
+
schemaVersion?: number;
|
|
8
|
+
}): Collection<T, TKey>;
|
|
9
|
+
//# sourceMappingURL=createLocalCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createLocalCollection.d.ts","sourceRoot":"","sources":["../../src/utils/createLocalCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgD,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAG7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM,EAAE,OAAO,EAAE;IAC3F,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC3B,OAAO,EAAE,cAAc,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAsBtB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createCollection, localOnlyCollectionOptions } from "@tanstack/db";
|
|
2
|
+
import { persistedCollectionOptions } from "@tanstack/db-sqlite-persistence-core";
|
|
3
|
+
import { createPersistedCollectionCoordinator } from "../coordinator/createPersistedCollectionCoordinator.js";
|
|
4
|
+
export function createLocalCollection(options) {
|
|
5
|
+
const collectionOptions = {
|
|
6
|
+
id: `party-stack:${options.runtime.owner}:${options.runtime.namespace}:${options.name}`,
|
|
7
|
+
getKey: options.getKey,
|
|
8
|
+
};
|
|
9
|
+
const persistence = options.runtime.persistence;
|
|
10
|
+
return createCollection(persistence
|
|
11
|
+
? persistedCollectionOptions({
|
|
12
|
+
...collectionOptions,
|
|
13
|
+
schemaVersion: options.schemaVersion,
|
|
14
|
+
persistence: {
|
|
15
|
+
adapter: persistence,
|
|
16
|
+
coordinator: createPersistedCollectionCoordinator(options.runtime.coordination, persistence),
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
: localOnlyCollectionOptions(collectionOptions));
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=createLocalCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createLocalCollection.js","sourceRoot":"","sources":["../../src/utils/createLocalCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAmB,MAAM,cAAc,CAAC;AAC7F,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,oCAAoC,EAAE,MAAM,wDAAwD,CAAC;AAG9G,MAAM,UAAU,qBAAqB,CAAiD,OAKrF;IACG,MAAM,iBAAiB,GAAG;QACtB,EAAE,EAAE,eAAe,OAAO,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,EAAE;QACvF,MAAM,EAAE,OAAO,CAAC,MAAM;KACzB,CAAC;IACF,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;IAEhD,OAAO,gBAAgB,CACnB,WAAW;QACP,CAAC,CAAC,0BAA0B,CAAU;YAChC,GAAG,iBAAiB;YACpB,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,WAAW,EAAE;gBACT,OAAO,EAAE,WAAW;gBACpB,WAAW,EAAE,oCAAoC,CAC7C,OAAO,CAAC,OAAO,CAAC,YAAY,EAC5B,WAAW,CACd;aACJ;SACJ,CAAC;QACJ,CAAC,CAAC,0BAA0B,CAAU,iBAAiB,CAAC,CAC/D,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createLocalCollection.test.d.ts","sourceRoot":"","sources":["../../src/utils/createLocalCollection.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { SingleProcessCoordination, } from "@party-stack/coordination";
|
|
2
|
+
import { SharedWorkerCoordinationClient, SharedWorkerCoordinationHost, } from "@party-stack/coordination/shared-worker";
|
|
3
|
+
import { describe, expect, it, vi, } from "vitest";
|
|
4
|
+
import { createPersistedCollectionCoordinator } from "../coordinator/createPersistedCollectionCoordinator.js";
|
|
5
|
+
import { MemoryBlobBytesStore } from "../memory/MemoryBlobBytesStore.js";
|
|
6
|
+
import { createLocalCollection } from "./createLocalCollection.js";
|
|
7
|
+
function memoryAdapter() {
|
|
8
|
+
const collections = new Map();
|
|
9
|
+
const positions = new Map();
|
|
10
|
+
const rows = (collectionId) => {
|
|
11
|
+
let collection = collections.get(collectionId);
|
|
12
|
+
if (!collection) {
|
|
13
|
+
collection = new Map();
|
|
14
|
+
collections.set(collectionId, collection);
|
|
15
|
+
}
|
|
16
|
+
return collection;
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
loadSubset: (collectionId) => Promise.resolve([...rows(collectionId)].map(([key, value]) => ({
|
|
20
|
+
key,
|
|
21
|
+
value,
|
|
22
|
+
}))),
|
|
23
|
+
applyCommittedTx: (collectionId, transaction) => {
|
|
24
|
+
const collection = rows(collectionId);
|
|
25
|
+
for (const mutation of transaction.mutations) {
|
|
26
|
+
if (mutation.type === "delete") {
|
|
27
|
+
collection.delete(mutation.key);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
collection.set(mutation.key, mutation.value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
positions.set(collectionId, {
|
|
34
|
+
latestTerm: transaction.term,
|
|
35
|
+
latestSeq: transaction.seq,
|
|
36
|
+
latestRowVersion: transaction.rowVersion,
|
|
37
|
+
});
|
|
38
|
+
return Promise.resolve();
|
|
39
|
+
},
|
|
40
|
+
ensureIndex: () => Promise.resolve(),
|
|
41
|
+
getStreamPosition: (collectionId) => Promise.resolve(positions.get(collectionId) ?? {
|
|
42
|
+
latestTerm: 0,
|
|
43
|
+
latestSeq: 0,
|
|
44
|
+
latestRowVersion: 0,
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function coordinatedRuntime(options) {
|
|
49
|
+
const coordination = options.coordination;
|
|
50
|
+
const runtime = {
|
|
51
|
+
owner: "test-owner",
|
|
52
|
+
namespace: "test-runtime",
|
|
53
|
+
blobBytes: new MemoryBlobBytesStore(),
|
|
54
|
+
persistence: options.adapter,
|
|
55
|
+
coordination,
|
|
56
|
+
};
|
|
57
|
+
return { runtime, coordination };
|
|
58
|
+
}
|
|
59
|
+
describe("createLocalCollection", () => {
|
|
60
|
+
it("creates an in-memory collection without runtime persistence", async () => {
|
|
61
|
+
const coordination = new SingleProcessCoordination({
|
|
62
|
+
scope: "memory-items",
|
|
63
|
+
});
|
|
64
|
+
const collection = createLocalCollection({
|
|
65
|
+
name: "memory-items",
|
|
66
|
+
getKey: (item) => item.id,
|
|
67
|
+
runtime: {
|
|
68
|
+
owner: "test-owner",
|
|
69
|
+
namespace: "memory",
|
|
70
|
+
blobBytes: new MemoryBlobBytesStore(),
|
|
71
|
+
coordination,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
await collection.preload();
|
|
75
|
+
const transaction = collection.insert({
|
|
76
|
+
id: "one",
|
|
77
|
+
title: "In memory",
|
|
78
|
+
});
|
|
79
|
+
await transaction.isPersisted.promise;
|
|
80
|
+
expect(collection.get("one")).toMatchObject({
|
|
81
|
+
id: "one",
|
|
82
|
+
title: "In memory",
|
|
83
|
+
});
|
|
84
|
+
await collection.cleanup();
|
|
85
|
+
await coordination.close();
|
|
86
|
+
});
|
|
87
|
+
it("loads through the runtime persistence adapter when available", async () => {
|
|
88
|
+
const loadSubset = vi.fn(() => Promise.resolve([
|
|
89
|
+
{
|
|
90
|
+
key: "one",
|
|
91
|
+
value: {
|
|
92
|
+
id: "one",
|
|
93
|
+
title: "Persisted",
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
]));
|
|
97
|
+
const adapter = {
|
|
98
|
+
loadSubset,
|
|
99
|
+
applyCommittedTx: vi.fn(() => Promise.resolve()),
|
|
100
|
+
ensureIndex: vi.fn(() => Promise.resolve()),
|
|
101
|
+
};
|
|
102
|
+
const coordination = new SingleProcessCoordination({
|
|
103
|
+
scope: "persisted-items",
|
|
104
|
+
});
|
|
105
|
+
const collection = createLocalCollection({
|
|
106
|
+
name: "persisted-items",
|
|
107
|
+
getKey: (item) => item.id,
|
|
108
|
+
runtime: {
|
|
109
|
+
owner: "test-owner",
|
|
110
|
+
namespace: "persisted",
|
|
111
|
+
blobBytes: new MemoryBlobBytesStore(),
|
|
112
|
+
persistence: adapter,
|
|
113
|
+
coordination,
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
await collection.preload();
|
|
117
|
+
expect(loadSubset).toHaveBeenCalledWith("party-stack:test-owner:persisted:persisted-items", expect.any(Object), expect.any(Object));
|
|
118
|
+
expect(collection.get("one")).toMatchObject({
|
|
119
|
+
id: "one",
|
|
120
|
+
title: "Persisted",
|
|
121
|
+
});
|
|
122
|
+
await collection.cleanup();
|
|
123
|
+
await coordination.close();
|
|
124
|
+
});
|
|
125
|
+
it("propagates committed mutations between coordinated contexts", async () => {
|
|
126
|
+
const adapter = memoryAdapter();
|
|
127
|
+
const coordination = new SingleProcessCoordination({
|
|
128
|
+
scope: "local-collection-test",
|
|
129
|
+
});
|
|
130
|
+
const firstRuntime = coordinatedRuntime({
|
|
131
|
+
adapter,
|
|
132
|
+
coordination,
|
|
133
|
+
});
|
|
134
|
+
const secondRuntime = coordinatedRuntime({
|
|
135
|
+
adapter,
|
|
136
|
+
coordination,
|
|
137
|
+
});
|
|
138
|
+
const createItems = ({ runtime }) => createLocalCollection({
|
|
139
|
+
name: "shared-items",
|
|
140
|
+
getKey: (item) => item.id,
|
|
141
|
+
runtime,
|
|
142
|
+
});
|
|
143
|
+
const first = createItems(firstRuntime);
|
|
144
|
+
const second = createItems(secondRuntime);
|
|
145
|
+
await Promise.all([first.preload(), second.preload()]);
|
|
146
|
+
await second.insert({
|
|
147
|
+
id: "one",
|
|
148
|
+
title: "Shared",
|
|
149
|
+
}).isPersisted.promise;
|
|
150
|
+
await vi.waitFor(() => {
|
|
151
|
+
expect(first.get("one")?.title).toBe("Shared");
|
|
152
|
+
expect(second.get("one")?.title).toBe("Shared");
|
|
153
|
+
});
|
|
154
|
+
await first.cleanup();
|
|
155
|
+
await second.cleanup();
|
|
156
|
+
await coordination.close();
|
|
157
|
+
});
|
|
158
|
+
it("removes non-cloneable subscription state from remote subset requests", async () => {
|
|
159
|
+
const adapter = memoryAdapter();
|
|
160
|
+
const coordination = new SingleProcessCoordination({
|
|
161
|
+
scope: "remote-subset-test",
|
|
162
|
+
});
|
|
163
|
+
const first = coordinatedRuntime({
|
|
164
|
+
adapter,
|
|
165
|
+
coordination,
|
|
166
|
+
});
|
|
167
|
+
const second = coordinatedRuntime({
|
|
168
|
+
adapter,
|
|
169
|
+
coordination,
|
|
170
|
+
});
|
|
171
|
+
const firstCoordinator = createPersistedCollectionCoordinator(first.coordination, adapter);
|
|
172
|
+
const secondCoordinator = createPersistedCollectionCoordinator(second.coordination, adapter);
|
|
173
|
+
await expect(secondCoordinator.requestEnsureRemoteSubset?.("items", {
|
|
174
|
+
subscription: {
|
|
175
|
+
callback: () => undefined,
|
|
176
|
+
},
|
|
177
|
+
})).resolves.toBeUndefined();
|
|
178
|
+
await expect(firstCoordinator.requestEnsurePersistedIndex("items", "index", {
|
|
179
|
+
expressionSql: [],
|
|
180
|
+
})).resolves.toBeUndefined();
|
|
181
|
+
await coordination.close();
|
|
182
|
+
});
|
|
183
|
+
it("routes client-only persistence through a SharedWorker host", async () => {
|
|
184
|
+
const adapter = memoryAdapter();
|
|
185
|
+
const channel = new MessageChannel();
|
|
186
|
+
const hostCoordination = new SharedWorkerCoordinationHost({
|
|
187
|
+
scope: "shared-worker-persistence",
|
|
188
|
+
});
|
|
189
|
+
const disconnect = hostCoordination.connect(channel.port1);
|
|
190
|
+
const clientCoordination = new SharedWorkerCoordinationClient({
|
|
191
|
+
scope: "shared-worker-persistence",
|
|
192
|
+
worker: channel.port2,
|
|
193
|
+
});
|
|
194
|
+
const host = createLocalCollection({
|
|
195
|
+
name: "worker-items",
|
|
196
|
+
getKey: (item) => item.id,
|
|
197
|
+
runtime: {
|
|
198
|
+
owner: "test-owner",
|
|
199
|
+
namespace: "worker",
|
|
200
|
+
blobBytes: new MemoryBlobBytesStore(),
|
|
201
|
+
persistence: adapter,
|
|
202
|
+
coordination: hostCoordination,
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
const client = createLocalCollection({
|
|
206
|
+
name: "worker-items",
|
|
207
|
+
getKey: (item) => item.id,
|
|
208
|
+
runtime: {
|
|
209
|
+
owner: "test-owner",
|
|
210
|
+
namespace: "worker",
|
|
211
|
+
blobBytes: new MemoryBlobBytesStore(),
|
|
212
|
+
persistence: adapter,
|
|
213
|
+
coordination: clientCoordination,
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
await Promise.all([
|
|
217
|
+
host.preload(),
|
|
218
|
+
client.preload(),
|
|
219
|
+
]);
|
|
220
|
+
await client.insert({
|
|
221
|
+
id: "one",
|
|
222
|
+
title: "From client",
|
|
223
|
+
}).isPersisted.promise;
|
|
224
|
+
await vi.waitFor(() => {
|
|
225
|
+
expect(host.get("one")?.title).toBe("From client");
|
|
226
|
+
expect(client.get("one")?.title).toBe("From client");
|
|
227
|
+
});
|
|
228
|
+
expect(clientCoordination.role).toBe("client");
|
|
229
|
+
await client.cleanup();
|
|
230
|
+
await host.cleanup();
|
|
231
|
+
await clientCoordination.close();
|
|
232
|
+
disconnect();
|
|
233
|
+
await hostCoordination.close();
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
//# sourceMappingURL=createLocalCollection.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createLocalCollection.test.js","sourceRoot":"","sources":["../../src/utils/createLocalCollection.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,yBAAyB,GAE5B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACH,8BAA8B,EAC9B,4BAA4B,GAE/B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACH,QAAQ,EACR,MAAM,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"@party-stack/runtime",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./lib/index.d.ts",
|
|
8
|
+
"default": "./lib/index.js"
|
|
9
|
+
},
|
|
10
|
+
"./effection": {
|
|
11
|
+
"types": "./lib/effection/index.d.ts",
|
|
12
|
+
"default": "./lib/effection/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"lib"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"effection": "^4.0.2",
|
|
20
|
+
"@party-stack/coordination": "0.2.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@bobbyfidz/universal-build-config": "^0.1.1",
|
|
24
|
+
"@tanstack/db": "^0.6.14",
|
|
25
|
+
"@tanstack/db-sqlite-persistence-core": "^0.2.6",
|
|
26
|
+
"eslint": "^9.25.0",
|
|
27
|
+
"typescript": "~5.8.3",
|
|
28
|
+
"vitest": "^3.1.1"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@tanstack/db": "^0.6.14",
|
|
32
|
+
"@tanstack/db-sqlite-persistence-core": "^0.2.6"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc",
|
|
36
|
+
"lint": "eslint",
|
|
37
|
+
"test": "vitest run"
|
|
38
|
+
}
|
|
39
|
+
}
|