@workglow/storage 0.0.57 → 0.0.59

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 (46) hide show
  1. package/dist/browser.js +1266 -121
  2. package/dist/browser.js.map +15 -10
  3. package/dist/bun.js +2132 -267
  4. package/dist/bun.js.map +20 -13
  5. package/dist/common-server.d.ts +4 -0
  6. package/dist/common-server.d.ts.map +1 -1
  7. package/dist/common.d.ts +2 -0
  8. package/dist/common.d.ts.map +1 -1
  9. package/dist/limiter/IRateLimiterStorage.d.ts +81 -0
  10. package/dist/limiter/IRateLimiterStorage.d.ts.map +1 -0
  11. package/dist/limiter/InMemoryRateLimiterStorage.d.ts +32 -0
  12. package/dist/limiter/InMemoryRateLimiterStorage.d.ts.map +1 -0
  13. package/dist/limiter/IndexedDbRateLimiterStorage.d.ts +52 -0
  14. package/dist/limiter/IndexedDbRateLimiterStorage.d.ts.map +1 -0
  15. package/dist/limiter/PostgresRateLimiterStorage.d.ts +54 -0
  16. package/dist/limiter/PostgresRateLimiterStorage.d.ts.map +1 -0
  17. package/dist/limiter/SqliteRateLimiterStorage.d.ts +53 -0
  18. package/dist/limiter/SqliteRateLimiterStorage.d.ts.map +1 -0
  19. package/dist/limiter/SupabaseRateLimiterStorage.d.ts +53 -0
  20. package/dist/limiter/SupabaseRateLimiterStorage.d.ts.map +1 -0
  21. package/dist/node.js +2132 -267
  22. package/dist/node.js.map +20 -13
  23. package/dist/queue/IQueueStorage.d.ts +72 -1
  24. package/dist/queue/IQueueStorage.d.ts.map +1 -1
  25. package/dist/queue/InMemoryQueueStorage.d.ts +44 -11
  26. package/dist/queue/InMemoryQueueStorage.d.ts.map +1 -1
  27. package/dist/queue/IndexedDbQueueStorage.d.ts +70 -5
  28. package/dist/queue/IndexedDbQueueStorage.d.ts.map +1 -1
  29. package/dist/queue/PostgresQueueStorage.d.ts +80 -8
  30. package/dist/queue/PostgresQueueStorage.d.ts.map +1 -1
  31. package/dist/queue/SqliteQueueStorage.d.ts +90 -34
  32. package/dist/queue/SqliteQueueStorage.d.ts.map +1 -1
  33. package/dist/queue/SupabaseQueueStorage.d.ts +98 -4
  34. package/dist/queue/SupabaseQueueStorage.d.ts.map +1 -1
  35. package/dist/tabular/ITabularRepository.d.ts +18 -0
  36. package/dist/tabular/ITabularRepository.d.ts.map +1 -1
  37. package/dist/tabular/InMemoryTabularRepository.d.ts +9 -1
  38. package/dist/tabular/InMemoryTabularRepository.d.ts.map +1 -1
  39. package/dist/tabular/SqliteTabularRepository.d.ts.map +1 -1
  40. package/dist/tabular/SupabaseTabularRepository.d.ts +21 -1
  41. package/dist/tabular/SupabaseTabularRepository.d.ts.map +1 -1
  42. package/dist/tabular/TabularRepository.d.ts +10 -1
  43. package/dist/tabular/TabularRepository.d.ts.map +1 -1
  44. package/dist/util/PollingSubscriptionManager.d.ts +112 -0
  45. package/dist/util/PollingSubscriptionManager.d.ts.map +1 -0
  46. package/package.json +5 -5
@@ -0,0 +1,112 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Configuration options for the polling subscription manager
8
+ */
9
+ export interface PollingManagerOptions {
10
+ /** Default polling interval in milliseconds */
11
+ readonly defaultIntervalMs?: number;
12
+ }
13
+ /**
14
+ * A callback function that is called when changes are detected
15
+ */
16
+ export type ChangeCallback<T> = (change: T) => void;
17
+ /**
18
+ * A function that fetches the current state for comparison
19
+ */
20
+ export type StateFetcher<Item, Key> = () => Promise<Map<Key, Item>>;
21
+ /**
22
+ * A function that compares two items for equality
23
+ */
24
+ export type ItemComparator<Item> = (a: Item, b: Item) => boolean;
25
+ /**
26
+ * A factory function that creates change payloads
27
+ */
28
+ export interface ChangePayloadFactory<Item, ChangePayload> {
29
+ /** Create an INSERT change payload */
30
+ readonly insert: (item: Item) => ChangePayload;
31
+ /** Create an UPDATE change payload */
32
+ readonly update: (oldItem: Item, newItem: Item) => ChangePayload;
33
+ /** Create a DELETE change payload */
34
+ readonly delete: (item: Item) => ChangePayload;
35
+ }
36
+ /**
37
+ * Options for subscribing to changes
38
+ */
39
+ export interface PollingSubscriptionOptions {
40
+ /** Polling interval in milliseconds */
41
+ readonly intervalMs?: number;
42
+ }
43
+ /**
44
+ * Manages polling-based subscriptions efficiently by consolidating multiple
45
+ * subscribers into a single polling loop per interval tier.
46
+ *
47
+ * Instead of each subscription creating its own polling interval, this manager
48
+ * groups subscriptions by their requested polling interval and runs a single
49
+ * poll for each group, broadcasting changes to all subscribers in that group.
50
+ *
51
+ * @template Item - The type of items being tracked
52
+ * @template Key - The type of key used to identify items
53
+ * @template ChangePayload - The type of change payload sent to subscribers
54
+ */
55
+ export declare class PollingSubscriptionManager<Item, Key, ChangePayload> {
56
+ /** Map of interval (ms) to interval ID and subscriber list */
57
+ private readonly intervals;
58
+ /** Current known state from last poll */
59
+ private lastKnownState;
60
+ /** Whether the manager has been initialized with a state fetch */
61
+ private initialized;
62
+ /** Function to fetch current state */
63
+ private readonly fetchState;
64
+ /** Function to compare items for equality */
65
+ private readonly compareItems;
66
+ /** Factory for creating change payloads */
67
+ private readonly payloadFactory;
68
+ /** Default polling interval */
69
+ private readonly defaultIntervalMs;
70
+ /**
71
+ * Creates a new PollingSubscriptionManager
72
+ *
73
+ * @param fetchState - Function that returns the current state as a Map
74
+ * @param compareItems - Function that compares two items for equality
75
+ * @param payloadFactory - Factory for creating INSERT/UPDATE/DELETE payloads
76
+ * @param options - Configuration options
77
+ */
78
+ constructor(fetchState: StateFetcher<Item, Key>, compareItems: ItemComparator<Item>, payloadFactory: ChangePayloadFactory<Item, ChangePayload>, options?: PollingManagerOptions);
79
+ /**
80
+ * Subscribe to changes with a specific polling interval
81
+ *
82
+ * @param callback - Function called when changes are detected
83
+ * @param options - Subscription options including interval
84
+ * @returns Unsubscribe function
85
+ */
86
+ subscribe(callback: ChangeCallback<ChangePayload>, options?: PollingSubscriptionOptions): () => void;
87
+ /**
88
+ * Initialize state and run first poll
89
+ */
90
+ private initAndPoll;
91
+ /**
92
+ * Send current state to a new subscriber
93
+ */
94
+ private pollForNewSubscriber;
95
+ /**
96
+ * Poll for changes and notify all subscribers in the given set
97
+ */
98
+ private poll;
99
+ /**
100
+ * Get the number of active subscriptions across all intervals
101
+ */
102
+ get subscriptionCount(): number;
103
+ /**
104
+ * Check if there are any active subscriptions
105
+ */
106
+ get hasSubscriptions(): boolean;
107
+ /**
108
+ * Destroy the manager and clean up all intervals
109
+ */
110
+ destroy(): void;
111
+ }
112
+ //# sourceMappingURL=PollingSubscriptionManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PollingSubscriptionManager.d.ts","sourceRoot":"","sources":["../../src/util/PollingSubscriptionManager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,+CAA+C;IAC/C,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,IAAI,EAAE,GAAG,IAAI,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,KAAK,OAAO,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,IAAI,EAAE,aAAa;IACvD,sCAAsC;IACtC,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,aAAa,CAAC;IAC/C,sCAAsC;IACtC,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,KAAK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IACH,OAAO,IAAI,IAAI;CAQhB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@workglow/storage",
3
3
  "type": "module",
4
- "version": "0.0.57",
4
+ "version": "0.0.59",
5
5
  "description": "Storage abstraction layer for Workglow, supporting IndexedDB, PostgreSQL, and Supabase with unified interfaces.",
6
6
  "scripts": {
7
7
  "watch": "concurrently -c 'auto' 'bun:watch-*'",
@@ -20,8 +20,8 @@
20
20
  "prepare": "node -e \"const pkg=require('./package.json');pkg.exports['.'].bun='./dist/bun.js';pkg.exports['.'].types='./dist/types.d.ts';require('fs').writeFileSync('package.json',JSON.stringify(pkg,null,2))\""
21
21
  },
22
22
  "peerDependencies": {
23
- "@workglow/sqlite": "0.0.57",
24
- "@workglow/util": "0.0.57",
23
+ "@workglow/sqlite": "0.0.59",
24
+ "@workglow/util": "0.0.59",
25
25
  "pg": "^8.16.3",
26
26
  "@supabase/supabase-js": "^2.86.2"
27
27
  },
@@ -34,8 +34,8 @@
34
34
  }
35
35
  },
36
36
  "devDependencies": {
37
- "@workglow/sqlite": "0.0.57",
38
- "@workglow/util": "0.0.57",
37
+ "@workglow/sqlite": "0.0.59",
38
+ "@workglow/util": "0.0.59",
39
39
  "pg": "^8.16.3",
40
40
  "@types/pg": "^8.15.5",
41
41
  "@supabase/supabase-js": "^2.86.2",