@affectively/dash 5.3.0 → 5.3.1

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 (71) hide show
  1. package/dist/index.d.ts +62 -0
  2. package/dist/index.js +31 -0
  3. package/dist/sync/index.d.ts +6 -0
  4. package/dist/sync/index.js +4 -0
  5. package/package.json +45 -66
  6. package/README.md +0 -193
  7. package/dist/src/api/firebase/auth/index.d.ts +0 -137
  8. package/dist/src/api/firebase/auth/index.js +0 -352
  9. package/dist/src/api/firebase/auth/providers.d.ts +0 -254
  10. package/dist/src/api/firebase/auth/providers.js +0 -518
  11. package/dist/src/api/firebase/database/index.d.ts +0 -108
  12. package/dist/src/api/firebase/database/index.js +0 -368
  13. package/dist/src/api/firebase/errors.d.ts +0 -15
  14. package/dist/src/api/firebase/errors.js +0 -215
  15. package/dist/src/api/firebase/firestore/data-types.d.ts +0 -116
  16. package/dist/src/api/firebase/firestore/data-types.js +0 -280
  17. package/dist/src/api/firebase/firestore/index.d.ts +0 -7
  18. package/dist/src/api/firebase/firestore/index.js +0 -13
  19. package/dist/src/api/firebase/firestore/listeners.d.ts +0 -20
  20. package/dist/src/api/firebase/firestore/listeners.js +0 -50
  21. package/dist/src/api/firebase/firestore/operations.d.ts +0 -123
  22. package/dist/src/api/firebase/firestore/operations.js +0 -490
  23. package/dist/src/api/firebase/firestore/query.d.ts +0 -118
  24. package/dist/src/api/firebase/firestore/query.js +0 -418
  25. package/dist/src/api/firebase/index.d.ts +0 -11
  26. package/dist/src/api/firebase/index.js +0 -17
  27. package/dist/src/api/firebase/storage/index.d.ts +0 -100
  28. package/dist/src/api/firebase/storage/index.js +0 -286
  29. package/dist/src/api/firebase/types.d.ts +0 -341
  30. package/dist/src/api/firebase/types.js +0 -4
  31. package/dist/src/auth/manager.d.ts +0 -182
  32. package/dist/src/auth/manager.js +0 -598
  33. package/dist/src/engine/ai.d.ts +0 -10
  34. package/dist/src/engine/ai.js +0 -76
  35. package/dist/src/engine/sqlite.d.ts +0 -346
  36. package/dist/src/engine/sqlite.js +0 -1325
  37. package/dist/src/engine/vec_extension.d.ts +0 -5
  38. package/dist/src/engine/vec_extension.js +0 -10
  39. package/dist/src/index.d.ts +0 -15
  40. package/dist/src/index.js +0 -24
  41. package/dist/src/mcp/server.d.ts +0 -8
  42. package/dist/src/mcp/server.js +0 -87
  43. package/dist/src/reactivity/signal.d.ts +0 -3
  44. package/dist/src/reactivity/signal.js +0 -31
  45. package/dist/src/schema/lens.d.ts +0 -29
  46. package/dist/src/schema/lens.js +0 -122
  47. package/dist/src/sync/aeon/config.d.ts +0 -21
  48. package/dist/src/sync/aeon/config.js +0 -14
  49. package/dist/src/sync/aeon/delta-adapter.d.ts +0 -62
  50. package/dist/src/sync/aeon/delta-adapter.js +0 -98
  51. package/dist/src/sync/aeon/index.d.ts +0 -18
  52. package/dist/src/sync/aeon/index.js +0 -19
  53. package/dist/src/sync/aeon/offline-adapter.d.ts +0 -110
  54. package/dist/src/sync/aeon/offline-adapter.js +0 -227
  55. package/dist/src/sync/aeon/presence-adapter.d.ts +0 -114
  56. package/dist/src/sync/aeon/presence-adapter.js +0 -157
  57. package/dist/src/sync/aeon/schema-adapter.d.ts +0 -95
  58. package/dist/src/sync/aeon/schema-adapter.js +0 -163
  59. package/dist/src/sync/backup.d.ts +0 -12
  60. package/dist/src/sync/backup.js +0 -44
  61. package/dist/src/sync/connection.d.ts +0 -20
  62. package/dist/src/sync/connection.js +0 -50
  63. package/dist/src/sync/d1-provider.d.ts +0 -97
  64. package/dist/src/sync/d1-provider.js +0 -345
  65. package/dist/src/sync/hybrid-provider.d.ts +0 -172
  66. package/dist/src/sync/hybrid-provider.js +0 -477
  67. package/dist/src/sync/provider.d.ts +0 -11
  68. package/dist/src/sync/provider.js +0 -67
  69. package/dist/src/sync/verify.d.ts +0 -1
  70. package/dist/src/sync/verify.js +0 -23
  71. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,346 +0,0 @@
1
- import { LensEngine } from '../schema/lens.js';
2
- /**
3
- * Cloud sync configuration - enables automatic D1/R2 AND Relay sync
4
- *
5
- * Dash uses DUAL SYNC by default:
6
- * - Relay: Real-time sync to other connected clients (WebSocket/WebTransport)
7
- * - D1: Persistent cloud storage (HTTP, batched)
8
- *
9
- * Both run simultaneously - Relay for speed, D1 for durability.
10
- * Gracefully degrades if either fails - local data always works.
11
- */
12
- export interface CloudConfig {
13
- /** Base URL for D1 sync endpoint (e.g., 'https://api.example.com'). Auto-detected from env if not provided. */
14
- baseUrl?: string;
15
- /** D1 sync interval in ms (default: 30000 = 30s). Set to 0 to disable. */
16
- syncInterval?: number;
17
- /** Relay WebSocket URL (e.g., 'wss://relay.example.com'). Auto-detected from env if not provided. */
18
- relayUrl?: string;
19
- /** Relay room name. Defaults to 'dash-{userId}' */
20
- relayRoom?: string;
21
- /** Enable high-frequency mode for Relay (uses WebTransport if available) */
22
- relayHighFrequency?: boolean;
23
- /** Auth token getter - called before each sync */
24
- getAuthToken?: () => Promise<string | null>;
25
- /** User ID for relay room naming */
26
- userId?: string;
27
- /** Tables to exclude from sync (internal tables are always excluded) */
28
- excludeTables?: string[];
29
- /** Callback when sync completes (D1 or Relay) */
30
- onSyncComplete?: (result: CloudSyncResult) => void;
31
- /** Callback when sync fails */
32
- onSyncError?: (error: Error) => void;
33
- /** Explicitly disable all cloud sync (default: false) */
34
- disabled?: boolean;
35
- /** Disable D1 sync only (default: false) */
36
- disableD1?: boolean;
37
- /** Disable Relay sync only (default: false) */
38
- disableRelay?: boolean;
39
- }
40
- export interface CloudSyncResult {
41
- pushed: number;
42
- pulled: number;
43
- errors: string[];
44
- timestamp: number;
45
- }
46
- export declare class DashEngine {
47
- private db;
48
- private readyPromise;
49
- private listeners;
50
- lens: LensEngine;
51
- currentSchemaVersion: number;
52
- private cloudConfig;
53
- private cloudSyncTimer;
54
- private isCloudSyncing;
55
- private lastCloudSyncTime;
56
- private cloudSyncEnabled;
57
- private syncedTables;
58
- private relayProvider;
59
- private relayDoc;
60
- private relaySyncEnabled;
61
- private readonly INTERNAL_TABLES;
62
- constructor();
63
- private init;
64
- /**
65
- * Try to auto-enable cloud sync from environment
66
- * Cloud sync is ON BY DEFAULT when a sync endpoint is detected
67
- */
68
- private tryAutoEnableCloudSync;
69
- /**
70
- * Detect sync endpoint from environment variables or same-origin
71
- */
72
- private detectSyncEndpoint;
73
- /**
74
- * Detect relay endpoint from environment variables
75
- */
76
- private detectRelayEndpoint;
77
- /**
78
- * Get default auth token from common auth patterns
79
- */
80
- private getDefaultAuthToken;
81
- private initializeSchema;
82
- ready(): Promise<void>;
83
- private tableListeners;
84
- subscribe(table: string, callback: () => void): () => void;
85
- private notify;
86
- private notifyChanges;
87
- execute(sql: string, bind?: any[]): any[];
88
- getFloat32(sql: string, bind?: any[]): Float32Array | null;
89
- addWithEmbedding(id: string, content: string, spatial?: {
90
- x: number;
91
- y: number;
92
- z: number;
93
- }): Promise<never[]>;
94
- search(query: string, limit?: number): Promise<any[]>;
95
- spatialQuery(bounds: {
96
- minX: number;
97
- maxX: number;
98
- minY: number;
99
- maxY: number;
100
- minZ: number;
101
- maxZ: number;
102
- }): Promise<any[]>;
103
- close(): void;
104
- /**
105
- * Stop Relay sync
106
- */
107
- stopRelaySync(): void;
108
- /**
109
- * Enable cloud sync - changes automatically sync to D1/R2
110
- * Just call this once with your config, and sync happens magically.
111
- *
112
- * Cloud sync is ON BY DEFAULT when running in a Cloudflare environment.
113
- * Call this to customize the config or explicitly enable/disable.
114
- *
115
- * @example
116
- * ```ts
117
- * await dash.ready();
118
- * // Option 1: Use auto-detected endpoint (default)
119
- * // Cloud sync is already enabled if DASH_SYNC_URL env var is set
120
- *
121
- * // Option 2: Explicit config
122
- * dash.enableCloudSync({
123
- * baseUrl: 'https://api.example.com',
124
- * getAuthToken: async () => auth.token,
125
- * });
126
- *
127
- * // Option 3: Disable cloud sync
128
- * dash.enableCloudSync({ disabled: true });
129
- * ```
130
- */
131
- enableCloudSync(config?: CloudConfig): void;
132
- /**
133
- * Initialize Relay sync for real-time updates
134
- */
135
- private initializeRelaySync;
136
- /**
137
- * Apply an update from Relay to local SQLite
138
- */
139
- private applyRelayUpdate;
140
- /**
141
- * Broadcast a local change to Relay
142
- */
143
- private broadcastToRelay;
144
- /**
145
- * Initialize cloud sync schema (queue and metadata tables)
146
- */
147
- private initializeCloudSyncSchema;
148
- /**
149
- * Set up sync triggers for all user tables
150
- */
151
- private setupAllTableTriggers;
152
- /**
153
- * Check if a table should be synced
154
- */
155
- private shouldSyncTable;
156
- /**
157
- * Set up sync triggers for a specific table
158
- */
159
- private setupTableSyncTriggers;
160
- /**
161
- * Build json_object() arguments for a table's columns
162
- */
163
- private buildJsonObjectArgs;
164
- /**
165
- * Start automatic cloud sync
166
- */
167
- private startCloudSync;
168
- /**
169
- * Stop automatic cloud sync
170
- */
171
- stopCloudSync(): void;
172
- /**
173
- * Perform a sync to cloud (D1/R2)
174
- */
175
- syncToCloud(): Promise<CloudSyncResult>;
176
- /**
177
- * Apply a single server change locally
178
- */
179
- private applyServerChange;
180
- /**
181
- * Force a full cloud sync (reset last sync time)
182
- */
183
- forceCloudSync(): Promise<CloudSyncResult>;
184
- /**
185
- * Get cloud sync status (D1 and Relay)
186
- */
187
- getCloudSyncStatus(): {
188
- enabled: boolean;
189
- syncing: boolean;
190
- lastSyncTime: number;
191
- pendingChanges: number;
192
- syncedTables: string[];
193
- d1: {
194
- enabled: boolean;
195
- syncing: boolean;
196
- lastSyncTime: number;
197
- pendingChanges: number;
198
- };
199
- relay: {
200
- enabled: boolean;
201
- connected: boolean;
202
- roomName: string | null;
203
- peerCount: number;
204
- };
205
- };
206
- /**
207
- * Disable cloud sync (both D1 and Relay)
208
- */
209
- disableCloudSync(): void;
210
- /**
211
- * Get information about all tables in the database
212
- */
213
- getAllTables(): TableInfo[];
214
- /**
215
- * Get detailed schema information for a specific table
216
- */
217
- getTableSchema(tableName: string): TableSchema | null;
218
- /**
219
- * Get the row count for a specific table
220
- */
221
- getTableRowCount(tableName: string): number;
222
- /**
223
- * Get statistics about the vector index
224
- */
225
- getVectorIndexStats(): VectorIndexStats;
226
- /**
227
- * Get all embeddings from the vector index
228
- */
229
- getAllEmbeddings(limit?: number, offset?: number): EmbeddingEntry[];
230
- /**
231
- * Search for similar vectors given a raw vector
232
- */
233
- searchSimilarByVector(vector: number[], k?: number): SimilarityResult[];
234
- /**
235
- * Get statistics about the spatial R-Tree index
236
- */
237
- getSpatialIndexStats(): SpatialIndexStats;
238
- /**
239
- * Get all spatial bounds from the R-Tree index
240
- */
241
- getAllSpatialBounds(limit?: number, offset?: number): SpatialBound[];
242
- /**
243
- * Get information about active table subscriptions
244
- */
245
- getActiveSubscriptions(): SubscriptionInfo[];
246
- /**
247
- * Get table listener counts as a map
248
- */
249
- getTableListenerCounts(): Record<string, number>;
250
- /**
251
- * Check if the database is ready
252
- */
253
- isReady(): boolean;
254
- /**
255
- * Get database metadata
256
- */
257
- getDatabaseInfo(): DatabaseInfo;
258
- }
259
- export interface TableInfo {
260
- name: string;
261
- type: 'table' | 'virtual';
262
- rowCount: number;
263
- isVirtual: boolean;
264
- }
265
- export interface TableSchema {
266
- name: string;
267
- columns: ColumnInfo[];
268
- indexes: IndexInfo[];
269
- foreignKeys: ForeignKeyInfo[];
270
- rowCount: number;
271
- }
272
- export interface ColumnInfo {
273
- cid: number;
274
- name: string;
275
- type: string;
276
- notNull: boolean;
277
- defaultValue: string | null;
278
- isPrimaryKey: boolean;
279
- }
280
- export interface IndexInfo {
281
- name: string;
282
- unique: boolean;
283
- origin: string;
284
- }
285
- export interface ForeignKeyInfo {
286
- id: number;
287
- table: string;
288
- from: string;
289
- to: string;
290
- }
291
- export interface VectorIndexStats {
292
- totalEmbeddings: number;
293
- dimensions: number;
294
- indexExists: boolean;
295
- tableName?: string;
296
- error?: string;
297
- }
298
- export interface EmbeddingEntry {
299
- id: string;
300
- content: string | null;
301
- embedding: number[] | null;
302
- }
303
- export interface SimilarityResult {
304
- id: string;
305
- content: string | null;
306
- distance: number;
307
- score: number;
308
- }
309
- export interface SpatialIndexStats {
310
- totalEntries: number;
311
- indexExists: boolean;
312
- tableName?: string;
313
- globalBounds?: {
314
- minX: number;
315
- maxX: number;
316
- minY: number;
317
- maxY: number;
318
- minZ: number;
319
- maxZ: number;
320
- };
321
- error?: string;
322
- }
323
- export interface SpatialBound {
324
- id: string;
325
- rowid: number;
326
- bounds: {
327
- minX: number;
328
- maxX: number;
329
- minY: number;
330
- maxY: number;
331
- minZ: number;
332
- maxZ: number;
333
- };
334
- content: string | null;
335
- }
336
- export interface SubscriptionInfo {
337
- table: string;
338
- listenerCount: number;
339
- }
340
- export interface DatabaseInfo {
341
- ready: boolean;
342
- schemaVersion: number;
343
- tableCount: number;
344
- tables?: string[];
345
- }
346
- export declare const dash: DashEngine;