@procedures/store 0.0.0-stage → 0.1.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.
Files changed (115) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE +21 -0
  3. package/README.md +65 -2
  4. package/dist/.tsbuildinfo +1 -0
  5. package/dist/errors.d.ts +16 -0
  6. package/dist/errors.d.ts.map +1 -0
  7. package/dist/errors.js +18 -0
  8. package/dist/errors.js.map +1 -0
  9. package/dist/index.d.ts +19 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +19 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/module.d.ts +15 -0
  14. package/dist/module.d.ts.map +1 -0
  15. package/dist/module.js +16 -0
  16. package/dist/module.js.map +1 -0
  17. package/dist/procedures.d.ts +13 -0
  18. package/dist/procedures.d.ts.map +1 -0
  19. package/dist/procedures.js +14 -0
  20. package/dist/procedures.js.map +1 -0
  21. package/dist/program-store/attach.d.ts +20 -0
  22. package/dist/program-store/attach.d.ts.map +1 -0
  23. package/dist/program-store/attach.js +36 -0
  24. package/dist/program-store/attach.js.map +1 -0
  25. package/dist/program-store/collection.d.ts +19 -0
  26. package/dist/program-store/collection.d.ts.map +1 -0
  27. package/dist/program-store/collection.js +34 -0
  28. package/dist/program-store/collection.js.map +1 -0
  29. package/dist/program-store/file.d.ts +29 -0
  30. package/dist/program-store/file.d.ts.map +1 -0
  31. package/dist/program-store/file.js +156 -0
  32. package/dist/program-store/file.js.map +1 -0
  33. package/dist/program-store/index.d.ts +11 -0
  34. package/dist/program-store/index.d.ts.map +1 -0
  35. package/dist/program-store/index.js +10 -0
  36. package/dist/program-store/index.js.map +1 -0
  37. package/dist/program-store/memory.d.ts +15 -0
  38. package/dist/program-store/memory.d.ts.map +1 -0
  39. package/dist/program-store/memory.js +25 -0
  40. package/dist/program-store/memory.js.map +1 -0
  41. package/dist/program-store/procedures.d.ts +23 -0
  42. package/dist/program-store/procedures.d.ts.map +1 -0
  43. package/dist/program-store/procedures.js +221 -0
  44. package/dist/program-store/procedures.js.map +1 -0
  45. package/dist/program-store/types.d.ts +50 -0
  46. package/dist/program-store/types.d.ts.map +1 -0
  47. package/dist/program-store/types.js +41 -0
  48. package/dist/program-store/types.js.map +1 -0
  49. package/dist/register.d.ts +8 -0
  50. package/dist/register.d.ts.map +1 -0
  51. package/dist/register.js +15 -0
  52. package/dist/register.js.map +1 -0
  53. package/dist/storage/adapter.d.ts +148 -0
  54. package/dist/storage/adapter.d.ts.map +1 -0
  55. package/dist/storage/adapter.js +214 -0
  56. package/dist/storage/adapter.js.map +1 -0
  57. package/dist/storage/api.d.ts +125 -0
  58. package/dist/storage/api.d.ts.map +1 -0
  59. package/dist/storage/api.js +220 -0
  60. package/dist/storage/api.js.map +1 -0
  61. package/dist/storage/factory.d.ts +134 -0
  62. package/dist/storage/factory.d.ts.map +1 -0
  63. package/dist/storage/factory.js +166 -0
  64. package/dist/storage/factory.js.map +1 -0
  65. package/dist/storage/hybrid.d.ts +193 -0
  66. package/dist/storage/hybrid.d.ts.map +1 -0
  67. package/dist/storage/hybrid.js +519 -0
  68. package/dist/storage/hybrid.js.map +1 -0
  69. package/dist/storage/index.d.ts +21 -0
  70. package/dist/storage/index.d.ts.map +1 -0
  71. package/dist/storage/index.js +20 -0
  72. package/dist/storage/index.js.map +1 -0
  73. package/dist/storage/procedures.d.ts +14 -0
  74. package/dist/storage/procedures.d.ts.map +1 -0
  75. package/dist/storage/procedures.js +98 -0
  76. package/dist/storage/procedures.js.map +1 -0
  77. package/dist/storage/serialization.d.ts +123 -0
  78. package/dist/storage/serialization.d.ts.map +1 -0
  79. package/dist/storage/serialization.js +216 -0
  80. package/dist/storage/serialization.js.map +1 -0
  81. package/dist/storage/synced-registry.d.ts +246 -0
  82. package/dist/storage/synced-registry.d.ts.map +1 -0
  83. package/dist/storage/synced-registry.js +575 -0
  84. package/dist/storage/synced-registry.js.map +1 -0
  85. package/dist/storage/types.d.ts +130 -0
  86. package/dist/storage/types.d.ts.map +1 -0
  87. package/dist/storage/types.js +8 -0
  88. package/dist/storage/types.js.map +1 -0
  89. package/dist/types.d.ts +7 -0
  90. package/dist/types.d.ts.map +1 -0
  91. package/dist/types.js +7 -0
  92. package/dist/types.js.map +1 -0
  93. package/package.json +79 -3
  94. package/src/errors.ts +20 -0
  95. package/src/index.ts +19 -0
  96. package/src/module.ts +18 -0
  97. package/src/procedures.ts +17 -0
  98. package/src/program-store/attach.ts +46 -0
  99. package/src/program-store/collection.ts +39 -0
  100. package/src/program-store/file.ts +157 -0
  101. package/src/program-store/index.ts +17 -0
  102. package/src/program-store/memory.ts +30 -0
  103. package/src/program-store/procedures.ts +344 -0
  104. package/src/program-store/types.ts +78 -0
  105. package/src/register.ts +18 -0
  106. package/src/storage/adapter.ts +273 -0
  107. package/src/storage/api.ts +335 -0
  108. package/src/storage/factory.ts +268 -0
  109. package/src/storage/hybrid.ts +676 -0
  110. package/src/storage/index.ts +61 -0
  111. package/src/storage/procedures.ts +146 -0
  112. package/src/storage/serialization.ts +283 -0
  113. package/src/storage/synced-registry.ts +698 -0
  114. package/src/storage/types.ts +180 -0
  115. package/src/types.ts +7 -0
@@ -0,0 +1,519 @@
1
+ /**
2
+ * Hybrid Storage Implementation
3
+ *
4
+ * Combines local cache (InMemoryStorage) with remote persistence (ApiStorage).
5
+ * Provides fast local reads with remote backup and sync.
6
+ *
7
+ * Features:
8
+ * - Local cache for fast reads, with a remote read on a miss
9
+ * - Write-through or write-back strategies
10
+ * - Automatic sync on initialization
11
+ * - Conflict resolution
12
+ * - Offline operation queue
13
+ */
14
+ import { InMemoryStorage } from "@procedures/collections";
15
+ /** The ids that an operation changes ("*" for clear). */
16
+ function idsOf(op) {
17
+ const data = op.data;
18
+ switch (op.type) {
19
+ case "set":
20
+ case "delete":
21
+ return data.id === undefined ? [] : [data.id];
22
+ case "setBatch":
23
+ return (data.items ?? []).map(([id]) => id);
24
+ case "deleteBatch":
25
+ return data.ids ?? [];
26
+ case "clear":
27
+ return ["*"];
28
+ }
29
+ }
30
+ const defaultKeyOf = (item) => {
31
+ const id = item?.id;
32
+ return typeof id === "string" && id.length > 0 ? id : undefined;
33
+ };
34
+ /**
35
+ * Hybrid storage combining local cache with remote persistence.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const client = new Client({
40
+ * transport: new HttpTransport({ baseUrl: "https://api.example.com" })
41
+ * });
42
+ *
43
+ * const remote = new ApiStorage(client, { collection: "users" });
44
+ * const hybrid = new HybridStorage(remote, {
45
+ * writeStrategy: "write-through",
46
+ * conflictResolution: "remote",
47
+ * syncInterval: 5000
48
+ * });
49
+ *
50
+ * // Fast local reads
51
+ * const user = await hybrid.get("123"); // From cache, or from the remote on a miss
52
+ *
53
+ * // Writes go to both local and remote
54
+ * await hybrid.set("123", { name: "John" });
55
+ * ```
56
+ */
57
+ export class HybridStorage {
58
+ local;
59
+ remote;
60
+ options;
61
+ offlineOps = [];
62
+ syncTimer = null;
63
+ isOnline = true;
64
+ /** A counter of local writes for each id, so a sync does not restore an older remote value */
65
+ writeVersions = new Map();
66
+ clearVersion = 0;
67
+ /** The running sync: syncs run one at a time */
68
+ syncChain = Promise.resolve();
69
+ stats = {
70
+ cacheHits: 0,
71
+ cacheMisses: 0,
72
+ syncCount: 0,
73
+ conflicts: 0,
74
+ };
75
+ constructor(remote, options = {}) {
76
+ this.local = new InMemoryStorage();
77
+ this.remote = remote;
78
+ this.options = {
79
+ writeStrategy: options.writeStrategy ?? "write-through",
80
+ conflictResolution: options.conflictResolution ?? "remote",
81
+ ...(options.mergeFn !== undefined && { mergeFn: options.mergeFn }),
82
+ keyOf: options.keyOf ?? defaultKeyOf,
83
+ syncInterval: options.syncInterval ?? 5000,
84
+ syncOnInit: options.syncOnInit ?? true,
85
+ maxOfflineOps: options.maxOfflineOps ?? 1000,
86
+ offlineQueue: options.offlineQueue ?? true,
87
+ };
88
+ // Initialize with remote data
89
+ if (this.options.syncOnInit) {
90
+ this.syncFromRemote().catch((err) => {
91
+ console.error("Failed to sync on init:", err);
92
+ });
93
+ }
94
+ // Start periodic sync for write-back mode
95
+ if (this.options.writeStrategy === "write-back" &&
96
+ this.options.syncInterval > 0) {
97
+ this.startPeriodicSync();
98
+ }
99
+ }
100
+ //
101
+ // ═══ Read Operations ═══
102
+ //
103
+ /**
104
+ * The local item, or else the remote item (which the cache then keeps). When the remote
105
+ * cannot answer, the storage is offline and the result is undefined.
106
+ */
107
+ async get(id) {
108
+ // Try local cache first
109
+ const cached = await this.local.get(id);
110
+ if (cached !== undefined) {
111
+ this.stats.cacheHits++;
112
+ return cached;
113
+ }
114
+ this.stats.cacheMisses++;
115
+ // A pending local delete means "no item": do not read it back from the remote
116
+ if (this.hasPendingOp(id)) {
117
+ return undefined;
118
+ }
119
+ const version = this.versionOf(id);
120
+ try {
121
+ const remote = await this.remote.get(id);
122
+ this.isOnline = true;
123
+ if (remote !== undefined && this.versionOf(id) === version) {
124
+ await this.local.set(id, remote);
125
+ }
126
+ return remote;
127
+ }
128
+ catch {
129
+ this.isOnline = false;
130
+ return undefined;
131
+ }
132
+ }
133
+ async getAll() {
134
+ // Return local cache
135
+ return this.local.getAll();
136
+ }
137
+ async find(predicate) {
138
+ // Search local cache
139
+ return this.local.find(predicate);
140
+ }
141
+ async has(id) {
142
+ return this.local.has(id);
143
+ }
144
+ async size() {
145
+ return this.local.size();
146
+ }
147
+ //
148
+ // ═══ Write Operations ═══
149
+ //
150
+ async set(id, value) {
151
+ this.bump(id);
152
+ // Always write to local immediately
153
+ await this.local.set(id, value);
154
+ if (this.options.writeStrategy === "write-through") {
155
+ // Write-through: sync to remote immediately
156
+ try {
157
+ await this.remote.set(id, value);
158
+ }
159
+ catch (error) {
160
+ this.handleRemoteFailure("set", { id, value });
161
+ throw error;
162
+ }
163
+ }
164
+ else {
165
+ // Write-back: queue for later sync
166
+ this.queueOperation({
167
+ type: "set",
168
+ data: { id, value },
169
+ timestamp: Date.now(),
170
+ });
171
+ }
172
+ }
173
+ async delete(id) {
174
+ this.bump(id);
175
+ const existed = await this.local.delete(id);
176
+ if (this.options.writeStrategy === "write-through") {
177
+ try {
178
+ await this.remote.delete(id);
179
+ }
180
+ catch (error) {
181
+ this.handleRemoteFailure("delete", { id });
182
+ throw error;
183
+ }
184
+ }
185
+ else {
186
+ this.queueOperation({
187
+ type: "delete",
188
+ data: { id },
189
+ timestamp: Date.now(),
190
+ });
191
+ }
192
+ return existed;
193
+ }
194
+ async clear() {
195
+ this.clearVersion++;
196
+ await this.local.clear();
197
+ if (this.options.writeStrategy === "write-through") {
198
+ try {
199
+ await this.remote.clear();
200
+ }
201
+ catch (error) {
202
+ this.handleRemoteFailure("clear", {});
203
+ throw error;
204
+ }
205
+ }
206
+ else {
207
+ this.queueOperation({
208
+ type: "clear",
209
+ data: {},
210
+ timestamp: Date.now(),
211
+ });
212
+ }
213
+ }
214
+ //
215
+ // ═══ Bulk Operations ═══
216
+ //
217
+ async setBatch(items) {
218
+ for (const [id] of items)
219
+ this.bump(id);
220
+ await this.local.setBatch(items);
221
+ if (this.options.writeStrategy === "write-through") {
222
+ try {
223
+ await this.remote.setBatch(items);
224
+ }
225
+ catch (error) {
226
+ this.handleRemoteFailure("setBatch", { items });
227
+ throw error;
228
+ }
229
+ }
230
+ else {
231
+ this.queueOperation({
232
+ type: "setBatch",
233
+ data: { items },
234
+ timestamp: Date.now(),
235
+ });
236
+ }
237
+ }
238
+ async deleteBatch(ids) {
239
+ for (const id of ids)
240
+ this.bump(id);
241
+ const deleted = await this.local.deleteBatch(ids);
242
+ if (this.options.writeStrategy === "write-through") {
243
+ try {
244
+ await this.remote.deleteBatch(ids);
245
+ }
246
+ catch (error) {
247
+ this.handleRemoteFailure("deleteBatch", { ids });
248
+ throw error;
249
+ }
250
+ }
251
+ else {
252
+ this.queueOperation({
253
+ type: "deleteBatch",
254
+ data: { ids },
255
+ timestamp: Date.now(),
256
+ });
257
+ }
258
+ return deleted;
259
+ }
260
+ getBatch(ids) {
261
+ return this.local.getBatch(ids);
262
+ }
263
+ //
264
+ // ═══ Sync Operations ═══
265
+ //
266
+ /**
267
+ * Sync all data from remote to local.
268
+ * Handles conflicts according to conflict resolution strategy.
269
+ *
270
+ * - Each remote item goes into the cache under `keyOf(item)`.
271
+ * - A local item that the remote does not have is removed, unless a queued local operation
272
+ * changes it (the remote deleted it).
273
+ * - An id that a local write changed during the sync keeps the local value: the remote value
274
+ * is older.
275
+ * - Syncs run one at a time.
276
+ */
277
+ syncFromRemote() {
278
+ return this.serialize(() => this.pullRemote());
279
+ }
280
+ /**
281
+ * Sync all pending offline operations to remote.
282
+ * Processes queued operations in order. When one fails, it and the later operations stay in
283
+ * the queue: the operations that reached the remote are not sent again.
284
+ */
285
+ syncToRemote() {
286
+ return this.serialize(() => this.pushQueue());
287
+ }
288
+ /**
289
+ * Force a full sync (both directions).
290
+ */
291
+ async sync() {
292
+ await this.syncToRemote();
293
+ await this.syncFromRemote();
294
+ }
295
+ //
296
+ // ═══ Lifecycle & Metadata ═══
297
+ //
298
+ async close() {
299
+ // Stop periodic sync
300
+ if (this.syncTimer) {
301
+ clearInterval(this.syncTimer);
302
+ this.syncTimer = null;
303
+ }
304
+ // Sync pending operations before closing
305
+ if (this.offlineOps.length > 0) {
306
+ try {
307
+ await this.syncToRemote();
308
+ }
309
+ catch (error) {
310
+ console.error("Failed to sync before close:", error);
311
+ }
312
+ }
313
+ // Close remote storage (an ApiStorage leaves the caller's client open)
314
+ await this.remote.close();
315
+ }
316
+ async getMetadata() {
317
+ const totalOps = this.stats.cacheHits + this.stats.cacheMisses;
318
+ const hitRate = totalOps > 0 ? (this.stats.cacheHits / totalOps) * 100 : 0;
319
+ const currentSize = await this.local.size();
320
+ return {
321
+ type: "hybrid",
322
+ size: currentSize,
323
+ stats: {
324
+ hitRate: Math.round(hitRate * 100) / 100,
325
+ cacheHits: this.stats.cacheHits,
326
+ cacheMisses: this.stats.cacheMisses,
327
+ syncCount: this.stats.syncCount,
328
+ conflicts: this.stats.conflicts,
329
+ pendingOps: this.offlineOps.length,
330
+ isOnline: this.isOnline,
331
+ writeStrategy: this.options.writeStrategy,
332
+ conflictResolution: this.options.conflictResolution,
333
+ },
334
+ };
335
+ }
336
+ //
337
+ // ═══ Internal Helpers ═══
338
+ //
339
+ async pullRemote() {
340
+ const versions = new Map(this.writeVersions);
341
+ const clearVersion = this.clearVersion;
342
+ // True when a local write changed the id after the sync started
343
+ const changedLocally = (id) => this.clearVersion !== clearVersion || (this.writeVersions.get(id) ?? 0) !== (versions.get(id) ?? 0);
344
+ let remoteData;
345
+ try {
346
+ remoteData = await this.remote.getAll();
347
+ }
348
+ catch (error) {
349
+ this.isOnline = false;
350
+ throw error;
351
+ }
352
+ const remoteIds = new Set();
353
+ for (const item of remoteData) {
354
+ const id = this.options.keyOf(item);
355
+ if (!id) {
356
+ console.warn("Item has no key, skipping:", item);
357
+ continue;
358
+ }
359
+ remoteIds.add(id);
360
+ if (changedLocally(id) || this.hasPendingOp(id)) {
361
+ continue;
362
+ }
363
+ const localItem = await this.local.get(id);
364
+ if (localItem === undefined) {
365
+ // No local version - just store remote
366
+ await this.local.set(id, item);
367
+ }
368
+ else if (JSON.stringify(localItem) !== JSON.stringify(item)) {
369
+ // Conflict - resolve according to strategy
370
+ const resolved = this.resolveConflict(localItem, item);
371
+ await this.local.set(id, resolved);
372
+ this.stats.conflicts++;
373
+ }
374
+ }
375
+ // The remote deleted these items
376
+ for (const id of await this.localIds()) {
377
+ if (!remoteIds.has(id) && !changedLocally(id) && !this.hasPendingOp(id)) {
378
+ await this.local.delete(id);
379
+ }
380
+ }
381
+ this.stats.syncCount++;
382
+ this.isOnline = true;
383
+ }
384
+ async pushQueue() {
385
+ while (this.offlineOps.length > 0) {
386
+ const op = this.offlineOps[0];
387
+ try {
388
+ await this.executeOperation(op);
389
+ }
390
+ catch (error) {
391
+ // This operation and the later ones stay queued
392
+ this.isOnline = false;
393
+ throw error;
394
+ }
395
+ // Remove the operation only after it reached the remote
396
+ if (this.offlineOps[0] === op) {
397
+ this.offlineOps.shift();
398
+ }
399
+ }
400
+ this.isOnline = true;
401
+ }
402
+ /** Run syncs one at a time. */
403
+ serialize(run) {
404
+ const next = this.syncChain.then(run, run);
405
+ this.syncChain = next.catch(() => undefined);
406
+ return next;
407
+ }
408
+ async localIds() {
409
+ return [...this.local.keys()];
410
+ }
411
+ bump(id) {
412
+ this.writeVersions.set(id, (this.writeVersions.get(id) ?? 0) + 1);
413
+ }
414
+ versionOf(id) {
415
+ return `${this.clearVersion}:${this.writeVersions.get(id) ?? 0}`;
416
+ }
417
+ hasPendingOp(id) {
418
+ return this.offlineOps.some((op) => {
419
+ const ids = idsOf(op);
420
+ return ids.includes(id) || ids.includes("*");
421
+ });
422
+ }
423
+ /**
424
+ * Resolve conflict between local and remote versions.
425
+ */
426
+ resolveConflict(local, remote) {
427
+ switch (this.options.conflictResolution) {
428
+ case "local":
429
+ return local;
430
+ case "remote":
431
+ return remote;
432
+ case "merge":
433
+ if (!this.options.mergeFn) {
434
+ throw new Error("Merge function required for conflict resolution strategy 'merge'");
435
+ }
436
+ return this.options.mergeFn(local, remote);
437
+ case "error":
438
+ throw new Error(`Conflict detected between local and remote versions`);
439
+ default:
440
+ return remote;
441
+ }
442
+ }
443
+ /**
444
+ * Queue operation for later sync.
445
+ */
446
+ queueOperation(op) {
447
+ if (!this.options.offlineQueue) {
448
+ return;
449
+ }
450
+ this.offlineOps.push(op);
451
+ // Enforce max queue size
452
+ if (this.offlineOps.length > this.options.maxOfflineOps) {
453
+ this.offlineOps.shift(); // Remove oldest
454
+ }
455
+ }
456
+ /**
457
+ * Execute a queued operation against remote storage.
458
+ */
459
+ async executeOperation(op) {
460
+ const data = op.data;
461
+ switch (op.type) {
462
+ case "set":
463
+ await this.remote.set(data.id, data.value);
464
+ break;
465
+ case "delete":
466
+ await this.remote.delete(data.id);
467
+ break;
468
+ case "setBatch":
469
+ await this.remote.setBatch(data.items);
470
+ break;
471
+ case "deleteBatch":
472
+ await this.remote.deleteBatch(data.ids);
473
+ break;
474
+ case "clear":
475
+ await this.remote.clear();
476
+ break;
477
+ }
478
+ }
479
+ /**
480
+ * Handle remote operation failure.
481
+ */
482
+ handleRemoteFailure(operation, data) {
483
+ console.error(`Remote ${operation} failed, marking offline`);
484
+ this.isOnline = false;
485
+ // Queue operation if offline queue enabled
486
+ if (this.options.offlineQueue) {
487
+ this.queueOperation({
488
+ type: operation,
489
+ data,
490
+ timestamp: Date.now(),
491
+ });
492
+ }
493
+ }
494
+ /**
495
+ * Start periodic background sync.
496
+ */
497
+ startPeriodicSync() {
498
+ this.syncTimer = setInterval(() => {
499
+ this.syncToRemote().catch((err) => {
500
+ console.error("Periodic sync failed:", err);
501
+ });
502
+ }, this.options.syncInterval);
503
+ // The timer must not keep the process alive (deep dive DATA-9)
504
+ this.syncTimer.unref?.();
505
+ }
506
+ /**
507
+ * Get current online status.
508
+ */
509
+ isRemoteOnline() {
510
+ return this.isOnline;
511
+ }
512
+ /**
513
+ * Get pending offline operations count.
514
+ */
515
+ getPendingOpsCount() {
516
+ return this.offlineOps.length;
517
+ }
518
+ }
519
+ //# sourceMappingURL=hybrid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hybrid.js","sourceRoot":"","sources":["../../src/storage/hybrid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAsF1D,yDAAyD;AACzD,SAAS,KAAK,CAAC,EAAoB;IACjC,MAAM,IAAI,GAAG,EAAE,CAAC,IAAyE,CAAC;IAC1F,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;QAChB,KAAK,KAAK,CAAC;QACX,KAAK,QAAQ;YACX,OAAO,IAAI,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChD,KAAK,UAAU;YACb,OAAO,CAAC,IAAI,CAAC,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;;OAEG;IACK,iBAAiB;QACvB,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE;YAChC,IAAI,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBAChC,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;QACL,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC9B,+DAA+D;QAC9D,IAAI,CAAC,SAAoC,CAAC,KAAK,EAAE,EAAE,CAAC;IACvD,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Procedure Storage Module
3
+ *
4
+ * Enables procedure registry to be backed by CollectionStorage.
5
+ * Provides persistence, sync, and remote registry capabilities.
6
+ */
7
+ export type { SerializedProcedure, HandlerReference, HandlerLoader, SyncDirection, ConflictResolution, WriteStrategy, SyncConflict, SyncResult, SyncStatus, SyncedRegistryOptions, ProcedureStorageConfig, } from "./types.js";
8
+ export { serializeProcedure, deserializeProcedure, deserializeProcedureSync, getProcedureKey, getSerializedKey, serializeProcedures, deserializeProcedures, createDynamicHandlerLoader, } from "./serialization.js";
9
+ export type { SerializeOptions, DeserializeOptions } from "./serialization.js";
10
+ export { ApiStorage } from "./api.js";
11
+ export type { ApiStorageOptions } from "./api.js";
12
+ export { HybridStorage } from "./hybrid.js";
13
+ export type { HybridStorageOptions } from "./hybrid.js";
14
+ export { ProcedureStorageAdapter } from "./adapter.js";
15
+ export type { ProcedureStorageAdapterOptions } from "./adapter.js";
16
+ export { SyncedProcedureRegistry, getProcedureStore } from "./synced-registry.js";
17
+ export type { SyncedRegistrationOptions } from "./synced-registry.js";
18
+ export { createSyncedRegistry, createMemorySyncedRegistry, createApiSyncedRegistry, createHybridSyncedRegistry, createCustomSyncedRegistry, } from "./factory.js";
19
+ export type { CreateSyncedRegistryConfig } from "./factory.js";
20
+ export { procedureRegisterProcedure } from "./procedures.js";
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EACV,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,UAAU,EACV,UAAU,EACV,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAG/E,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,YAAY,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAGnE,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAClF,YAAY,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAGtE,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAG/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Procedure Storage Module
3
+ *
4
+ * Enables procedure registry to be backed by CollectionStorage.
5
+ * Provides persistence, sync, and remote registry capabilities.
6
+ */
7
+ // Serialization
8
+ export { serializeProcedure, deserializeProcedure, deserializeProcedureSync, getProcedureKey, getSerializedKey, serializeProcedures, deserializeProcedures, createDynamicHandlerLoader, } from "./serialization.js";
9
+ // The collection storages that need a Client (before: "@procedures/client/collections")
10
+ export { ApiStorage } from "./api.js";
11
+ export { HybridStorage } from "./hybrid.js";
12
+ // Adapter
13
+ export { ProcedureStorageAdapter } from "./adapter.js";
14
+ // Synced Registry
15
+ export { SyncedProcedureRegistry, getProcedureStore } from "./synced-registry.js";
16
+ // Factory
17
+ export { createSyncedRegistry, createMemorySyncedRegistry, createApiSyncedRegistry, createHybridSyncedRegistry, createCustomSyncedRegistry, } from "./factory.js";
18
+ // procedure.register (the other store procedures are in ../program-store)
19
+ export { procedureRegisterProcedure } from "./procedures.js";
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiBH,gBAAgB;AAChB,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC;AAG5B,wFAAwF;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,UAAU;AACV,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAGvD,kBAAkB;AAClB,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGlF,UAAU;AACV,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,cAAc,CAAC;AAGtB,0EAA0E;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * procedure.register: register a procedure at run time, from a handler reference.
3
+ *
4
+ * With `persist`, the procedure goes into the store of a synced registry (`createSyncedRegistry()`),
5
+ * and only with a handler that the store's loader allows: never a stub (deep dive CORE-16). Without
6
+ * a store, `persist` fails with the code NOT_CONFIGURED.
7
+ *
8
+ * The programs of `procedure.define` have their own store: `procedure.store`, `load` and `sync`
9
+ * (../program-store/procedures.ts, roadmap 3.2).
10
+ */
11
+ import type { AnyProcedure } from "@procedures/client";
12
+ export { ProcedureStoreError } from "../errors.js";
13
+ export declare const procedureRegisterProcedure: AnyProcedure;
14
+ //# sourceMappingURL=procedures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"procedures.d.ts","sourceRoot":"","sources":["../../src/storage/procedures.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAmC,MAAM,oBAAoB,CAAC;AA0BxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AA8CnD,eAAO,MAAM,0BAA0B,EAAE,YA6DvC,CAAC"}