@affectively/dash 5.2.1 → 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 -298
  36. package/dist/src/engine/sqlite.js +0 -1088
  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,418 +0,0 @@
1
- /**
2
- * Firestore query interface and SQL compiler
3
- */
4
- import { createFirebaseError } from '../errors.js';
5
- /**
6
- * Field path helper for nested fields
7
- */
8
- export class FieldPathClass {
9
- _segments;
10
- constructor(...segments) {
11
- if (segments.length === 0) {
12
- throw createFirebaseError('firestore/invalid-argument', 'Field path must contain at least one element');
13
- }
14
- this._segments = segments.flatMap(s => (typeof s === 'string' ? s.split('.') : s));
15
- }
16
- static documentId() {
17
- return new FieldPathClass('__name__');
18
- }
19
- toString() {
20
- return this._segments.join('.');
21
- }
22
- isEqual(other) {
23
- return JSON.stringify(this._segments) === JSON.stringify(other._segments);
24
- }
25
- }
26
- /**
27
- * Base Query class
28
- */
29
- export class QueryImpl {
30
- firestore;
31
- _query;
32
- type;
33
- constructor(firestore, constraints = []) {
34
- this.firestore = firestore;
35
- this._query = constraints;
36
- this.type = 'query';
37
- }
38
- _addConstraint(constraint) {
39
- return new QueryImpl(this.firestore, [...this._query, constraint]);
40
- }
41
- toJSON() {
42
- return `Query(constraints=${this._query.length})`;
43
- }
44
- }
45
- /**
46
- * Document reference class
47
- */
48
- export class DocumentReferenceImpl {
49
- firestore;
50
- _key;
51
- parent;
52
- id;
53
- path;
54
- type;
55
- constructor(firestore, path, parent) {
56
- this.firestore = firestore;
57
- this.path = path;
58
- this.parent = parent;
59
- this.type = 'document';
60
- // Extract document ID from path (last segment)
61
- const segments = path.split('/');
62
- this.id = segments[segments.length - 1];
63
- this._key = path;
64
- }
65
- toJSON() {
66
- return `DocumentReference(${this.path})`;
67
- }
68
- }
69
- /**
70
- * Collection reference class
71
- */
72
- export class CollectionReferenceImpl {
73
- firestore;
74
- _key;
75
- path;
76
- id;
77
- parent;
78
- type;
79
- _query = [];
80
- constructor(firestore, path, parent = null) {
81
- this.firestore = firestore;
82
- this.path = path;
83
- this.type = 'collection';
84
- this.parent = parent;
85
- // Extract collection ID from path (last segment)
86
- const segments = path.split('/');
87
- this.id = segments[segments.length - 1];
88
- this._key = path;
89
- }
90
- _addConstraint(constraint) {
91
- return new QueryImpl(this.firestore, [...this._query, constraint]);
92
- }
93
- toJSON() {
94
- return `CollectionReference(${this.path})`;
95
- }
96
- }
97
- /**
98
- * Create a collection reference
99
- */
100
- export function collection(firestore, path) {
101
- // Validate path
102
- if (!path || typeof path !== 'string') {
103
- throw createFirebaseError('firestore/invalid-argument', 'Collection path must be a non-empty string');
104
- }
105
- // Ensure path doesn't have odd number of segments (should be a collection, not a document)
106
- const segments = path.split('/').filter(s => s.length > 0);
107
- if (segments.length === 0) {
108
- throw createFirebaseError('firestore/invalid-argument', 'Collection path must not be empty');
109
- }
110
- return new CollectionReferenceImpl(firestore, path, null);
111
- }
112
- export function doc(firestoreOrReference, collectionPathOrDocId, documentId) {
113
- let firestore;
114
- let path;
115
- let parent = null;
116
- if (firestoreOrReference instanceof CollectionReferenceImpl) {
117
- // Variant: doc(collectionRef, docId)
118
- if (!collectionPathOrDocId) {
119
- throw createFirebaseError('firestore/invalid-argument', 'Document ID is required');
120
- }
121
- firestore = firestoreOrReference.firestore;
122
- parent = firestoreOrReference;
123
- path = `${firestoreOrReference.path}/${collectionPathOrDocId}`;
124
- }
125
- else {
126
- // Variant: doc(firestore, path) or doc(firestore, collectionPath, docId)
127
- firestore = firestoreOrReference;
128
- if (documentId && collectionPathOrDocId) {
129
- // doc(firestore, collectionPath, docId)
130
- path = `${collectionPathOrDocId}/${documentId}`;
131
- parent = new CollectionReferenceImpl(firestore, collectionPathOrDocId, null);
132
- }
133
- else if (collectionPathOrDocId) {
134
- // doc(firestore, path)
135
- path = collectionPathOrDocId;
136
- }
137
- else {
138
- throw createFirebaseError('firestore/invalid-argument', 'Document path is required');
139
- }
140
- }
141
- const segments = path.split('/').filter(s => s.length > 0);
142
- if (segments.length === 0 || segments.length % 2 === 1) {
143
- throw createFirebaseError('firestore/invalid-argument', 'Document path must be even number of segments');
144
- }
145
- return new DocumentReferenceImpl(firestore, path, parent);
146
- }
147
- /**
148
- * Build a where constraint
149
- */
150
- export function where(field, operator, value) {
151
- const fieldStr = typeof field === 'string' ? field : field.toString();
152
- // Validate operator
153
- const validOperators = [
154
- '<',
155
- '<=',
156
- '==',
157
- '!=',
158
- '>=',
159
- '>',
160
- 'array-contains',
161
- 'in',
162
- 'not-in',
163
- 'array-contains-any',
164
- ];
165
- if (!validOperators.includes(operator)) {
166
- throw createFirebaseError('firestore/invalid-argument', `Invalid operator: ${operator}`);
167
- }
168
- return {
169
- type: 'where',
170
- field: fieldStr,
171
- operator,
172
- value,
173
- };
174
- }
175
- /**
176
- * Build an orderBy constraint
177
- */
178
- export function orderBy(field, direction) {
179
- const fieldStr = typeof field === 'string' ? field : field.toString();
180
- const dir = direction || 'asc';
181
- if (dir !== 'asc' && dir !== 'desc') {
182
- throw createFirebaseError('firestore/invalid-argument', `Invalid direction: ${dir}`);
183
- }
184
- return {
185
- type: 'orderBy',
186
- field: fieldStr,
187
- direction: dir,
188
- };
189
- }
190
- /**
191
- * Build a limit constraint
192
- */
193
- export function limit(n) {
194
- if (typeof n !== 'number' || n < 0) {
195
- throw createFirebaseError('firestore/invalid-argument', 'Limit must be a non-negative number');
196
- }
197
- return {
198
- type: 'limit',
199
- count: n,
200
- };
201
- }
202
- /**
203
- * Build a limitToLast constraint
204
- */
205
- export function limitToLast(n) {
206
- if (typeof n !== 'number' || n <= 0) {
207
- throw createFirebaseError('firestore/invalid-argument', 'Limit must be a positive number');
208
- }
209
- return {
210
- type: 'limitToLast',
211
- count: n,
212
- };
213
- }
214
- /**
215
- * Build a startAt constraint
216
- */
217
- export function startAt(...values) {
218
- if (values.length === 0) {
219
- throw createFirebaseError('firestore/invalid-argument', 'startAt requires at least one value');
220
- }
221
- return {
222
- type: 'startAt',
223
- values,
224
- };
225
- }
226
- /**
227
- * Build a startAfter constraint
228
- */
229
- export function startAfter(...values) {
230
- if (values.length === 0) {
231
- throw createFirebaseError('firestore/invalid-argument', 'startAfter requires at least one value');
232
- }
233
- return {
234
- type: 'startAfter',
235
- values,
236
- };
237
- }
238
- /**
239
- * Build an endAt constraint
240
- */
241
- export function endAt(...values) {
242
- if (values.length === 0) {
243
- throw createFirebaseError('firestore/invalid-argument', 'endAt requires at least one value');
244
- }
245
- return {
246
- type: 'endAt',
247
- values,
248
- };
249
- }
250
- /**
251
- * Build an endBefore constraint
252
- */
253
- export function endBefore(...values) {
254
- if (values.length === 0) {
255
- throw createFirebaseError('firestore/invalid-argument', 'endBefore requires at least one value');
256
- }
257
- return {
258
- type: 'endBefore',
259
- values,
260
- };
261
- }
262
- /**
263
- * Build an offset constraint
264
- */
265
- export function offset(n) {
266
- if (typeof n !== 'number' || n < 0) {
267
- throw createFirebaseError('firestore/invalid-argument', 'Offset must be a non-negative number');
268
- }
269
- return {
270
- type: 'offset',
271
- count: n,
272
- };
273
- }
274
- /**
275
- * Create a new query by combining base query with constraints
276
- */
277
- export function query(base, ...constraints) {
278
- if (constraints.length === 0) {
279
- if (base instanceof QueryImpl) {
280
- return base;
281
- }
282
- return new QueryImpl(base.firestore, []);
283
- }
284
- const allConstraints = [...base._query, ...constraints];
285
- return new QueryImpl(base.firestore, allConstraints);
286
- }
287
- /**
288
- * Get table name from path
289
- */
290
- export function getTableFromPath(path) {
291
- const segments = path.split('/').filter(s => s.length > 0);
292
- // For collections, return the last segment
293
- // For documents, we need to find the collection name
294
- return segments[segments.length - 1] || 'documents';
295
- }
296
- /**
297
- * Compile a query to SQL
298
- */
299
- export function compileQuery(q, collectionPath) {
300
- const tableName = collectionPath ? getTableFromPath(collectionPath) : 'documents';
301
- let sql = `SELECT * FROM \`${tableName}\``;
302
- const params = [];
303
- const whereClauses = [];
304
- // Process constraints
305
- for (const constraint of q._query) {
306
- switch (constraint.type) {
307
- case 'where': {
308
- const field = constraint.field;
309
- const operator = constraint.operator;
310
- const value = constraint.value;
311
- let clause;
312
- switch (operator) {
313
- case '==':
314
- clause = `\`${field}\` = ?`;
315
- params.push(value);
316
- break;
317
- case '!=':
318
- clause = `\`${field}\` != ?`;
319
- params.push(value);
320
- break;
321
- case '<':
322
- clause = `\`${field}\` < ?`;
323
- params.push(value);
324
- break;
325
- case '<=':
326
- clause = `\`${field}\` <= ?`;
327
- params.push(value);
328
- break;
329
- case '>':
330
- clause = `\`${field}\` > ?`;
331
- params.push(value);
332
- break;
333
- case '>=':
334
- clause = `\`${field}\` >= ?`;
335
- params.push(value);
336
- break;
337
- case 'array-contains':
338
- clause = `json_extract(\`${field}\`, '$[*]') LIKE ?`;
339
- params.push(`%${JSON.stringify(value)}%`);
340
- break;
341
- case 'in':
342
- if (!Array.isArray(value)) {
343
- throw createFirebaseError('firestore/invalid-argument', '"in" operator requires array value');
344
- }
345
- const inPlaceholders = value.map(() => '?').join(', ');
346
- clause = `\`${field}\` IN (${inPlaceholders})`;
347
- params.push(...value);
348
- break;
349
- case 'not-in':
350
- if (!Array.isArray(value)) {
351
- throw createFirebaseError('firestore/invalid-argument', '"not-in" operator requires array value');
352
- }
353
- const notInPlaceholders = value.map(() => '?').join(', ');
354
- clause = `\`${field}\` NOT IN (${notInPlaceholders})`;
355
- params.push(...value);
356
- break;
357
- case 'array-contains-any':
358
- if (!Array.isArray(value)) {
359
- throw createFirebaseError('firestore/invalid-argument', '"array-contains-any" operator requires array value');
360
- }
361
- const anyPlaceholders = value.map(() => 'json_extract(?, "$[*]") LIKE ?').join(' OR ');
362
- clause = `(${anyPlaceholders})`;
363
- for (const v of value) {
364
- params.push(v);
365
- params.push(`%${JSON.stringify(v)}%`);
366
- }
367
- break;
368
- default:
369
- throw createFirebaseError('firestore/invalid-argument', `Unknown operator: ${operator}`);
370
- }
371
- whereClauses.push(clause);
372
- break;
373
- }
374
- case 'orderBy': {
375
- const field = constraint.field;
376
- const direction = constraint.direction || 'asc';
377
- sql += ` ORDER BY \`${field}\` ${direction.toUpperCase()}`;
378
- break;
379
- }
380
- case 'limit': {
381
- sql += ` LIMIT ${constraint.count}`;
382
- break;
383
- }
384
- case 'limitToLast': {
385
- // For limitToLast, we need to reverse order and take first N, then reverse again
386
- // For now, implement as regular limit (TODO: full implementation)
387
- sql += ` LIMIT ${constraint.count}`;
388
- break;
389
- }
390
- case 'offset': {
391
- sql += ` OFFSET ${constraint.count}`;
392
- break;
393
- }
394
- case 'startAt':
395
- case 'startAfter':
396
- case 'endAt':
397
- case 'endBefore':
398
- // These are typically used with orderBy and would need cursor-based pagination
399
- // For now, implement basic version
400
- if (constraint.values && constraint.values.length > 0) {
401
- const op = constraint.type === 'startAt' || constraint.type === 'startAfter' ? '>=' : '<=';
402
- whereClauses.push(`\`__cursor\` ${op} ?`);
403
- params.push(constraint.values[0]);
404
- }
405
- break;
406
- }
407
- }
408
- // Add WHERE clauses
409
- if (whereClauses.length > 0) {
410
- sql += ` WHERE ${whereClauses.join(' AND ')}`;
411
- }
412
- return {
413
- table: tableName,
414
- sql,
415
- params,
416
- constraints: q._query,
417
- };
418
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Firebase Compatibility API
3
- * Complete drop-in replacement for Firebase SDK
4
- */
5
- export * from './firestore/index.js';
6
- export * from './firestore/index.js';
7
- export * from './database/index.js';
8
- export * from './auth/index.js';
9
- export * as storage from './storage/index.js';
10
- export { FirebaseError, createFirebaseError } from './errors.js';
11
- export type { Firestore, RealtimeDatabase, FirebaseAuth, FirebaseStorage, FirebaseApp, FirebaseConfig, DocumentReference, CollectionReference, Query, DocumentSnapshot, QuerySnapshot, DatabaseReference, DataSnapshot, OnDisconnect, DocumentChange, SnapshotMetadata, SnapshotOptions, QueryConstraint, WhereFilterOp, FieldPath, FieldValue, Timestamp, GeoPoint, User, UserCredential, AuthProvider, AuthCredential, StorageReference, UploadMetadata, FullMetadata, ListResult, UploadTask, UploadTaskSnapshot, } from './types.js';
@@ -1,17 +0,0 @@
1
- /**
2
- * Firebase Compatibility API
3
- * Complete drop-in replacement for Firebase SDK
4
- */
5
- // Re-export all Firestore APIs
6
- export * from './firestore/index.js';
7
- // Re-export all Firestore listener APIs
8
- // Re-export Firestore APIs
9
- export * from './firestore/index.js';
10
- // Re-export Realtime Database APIs
11
- export * from './database/index.js';
12
- // Re-export all Authentication APIs
13
- export * from './auth/index.js';
14
- // Re-export Storage APIs with namespacing to avoid conflicts
15
- export * as storage from './storage/index.js';
16
- // Re-export error types
17
- export { FirebaseError, createFirebaseError } from './errors.js';
@@ -1,100 +0,0 @@
1
- /**
2
- * Firebase Cloud Storage API
3
- */
4
- import type { StorageReference, FirebaseStorage, UploadMetadata, FullMetadata, ListResult, UploadTask, UploadTaskSnapshot } from '../types.js';
5
- /**
6
- * Storage reference implementation
7
- */
8
- export declare class StorageReferenceImpl implements StorageReference {
9
- storage: FirebaseStorage;
10
- _location: {
11
- bucket: string;
12
- path: string;
13
- };
14
- bucket: string;
15
- fullPath: string;
16
- name: string;
17
- parent: StorageReferenceImpl | null;
18
- root: StorageReferenceImpl;
19
- constructor(storage: FirebaseStorage, bucket: string, path: string);
20
- toString(): string;
21
- }
22
- /**
23
- * Upload task implementation
24
- */
25
- export declare class UploadTaskImpl implements UploadTask {
26
- private _ref;
27
- private _data;
28
- private _metadata;
29
- private _paused;
30
- private _cancelled;
31
- private _progress;
32
- private _listeners;
33
- private _errorListeners;
34
- private _completeListeners;
35
- constructor(ref: StorageReferenceImpl, data: Blob | ArrayBuffer | string, metadata?: UploadMetadata);
36
- on(event: string, nextOrObserver?: any, error?: (error: Error) => void, complete?: () => void): () => void;
37
- then(onFulfilled?: (snapshot: UploadTaskSnapshot) => any, onRejected?: (error: Error) => any): Promise<any>;
38
- catch(onRejected: (error: Error) => any): Promise<any>;
39
- pause(): boolean;
40
- resume(): boolean;
41
- cancel(): boolean;
42
- private _performUpload;
43
- private _createSnapshot;
44
- private _notifyProgress;
45
- }
46
- /**
47
- * Get storage reference
48
- */
49
- export declare function ref(storage: FirebaseStorage, path?: string): StorageReferenceImpl;
50
- /**
51
- * Get reference from URL
52
- */
53
- export declare function refFromURL(storage: FirebaseStorage, url: string): StorageReferenceImpl;
54
- /**
55
- * Get child reference
56
- */
57
- export declare function child(parent: StorageReferenceImpl, path: string): StorageReferenceImpl;
58
- /**
59
- * Upload bytes
60
- */
61
- export declare function uploadBytes(reference: StorageReferenceImpl, data: Blob | ArrayBuffer | Uint8Array, metadata?: UploadMetadata): Promise<UploadTaskSnapshot>;
62
- /**
63
- * Upload resumable (with progress tracking)
64
- */
65
- export declare function uploadBytesResumable(reference: StorageReferenceImpl, data: Blob | ArrayBuffer | Uint8Array, metadata?: UploadMetadata): UploadTask;
66
- /**
67
- * Upload string
68
- */
69
- export declare function uploadString(reference: StorageReferenceImpl, value: string, format?: 'raw' | 'base64' | 'base64url' | 'data_url', metadata?: UploadMetadata): Promise<UploadTaskSnapshot>;
70
- /**
71
- * Download bytes
72
- */
73
- export declare function getBytes(reference: StorageReferenceImpl, maxDownloadSizeBytes?: number): Promise<ArrayBuffer>;
74
- /**
75
- * Get download URL
76
- */
77
- export declare function getDownloadURL(reference: StorageReferenceImpl): Promise<string>;
78
- /**
79
- * Get metadata
80
- */
81
- export declare function getMetadata(reference: StorageReferenceImpl): Promise<FullMetadata>;
82
- /**
83
- * Update metadata
84
- */
85
- export declare function updateMetadata(reference: StorageReferenceImpl, metadata: UploadMetadata): Promise<FullMetadata>;
86
- /**
87
- * Delete object
88
- */
89
- export declare function deleteObject(reference: StorageReferenceImpl): Promise<void>;
90
- /**
91
- * List files (with pagination)
92
- */
93
- export declare function list(reference: StorageReferenceImpl, options?: {
94
- maxResults?: number;
95
- pageToken?: string;
96
- }): Promise<ListResult>;
97
- /**
98
- * List all files
99
- */
100
- export declare function listAll(reference: StorageReferenceImpl): Promise<ListResult>;