hydrousdb 1.1.1 → 2.0.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.
@@ -1,466 +0,0 @@
1
- type FilterOp = '==' | '!=' | '>' | '<' | '>=' | '<=' | 'contains';
2
- interface Filter {
3
- field: string;
4
- op: FilterOp;
5
- value: string | number | boolean;
6
- }
7
- interface PaginationMeta {
8
- nextCursor: string | null;
9
- hasMore: boolean;
10
- limit?: number;
11
- }
12
- interface ApiMeta extends PaginationMeta {
13
- bucketKey?: string;
14
- projectId?: string;
15
- retrievedAt?: number;
16
- filters?: Filter[];
17
- timeScope?: string;
18
- year?: string;
19
- sortOrder?: 'asc' | 'desc';
20
- }
21
- interface RequestOptions {
22
- /** Abort signal for cancellation */
23
- signal?: AbortSignal;
24
- /** Additional headers merged into every request */
25
- headers?: Record<string, string>;
26
- }
27
- interface HydrousConfig {
28
- /** Your HydrousDB auth service key */
29
- authKey: string;
30
- /** Your bucket key (used for records, analytics, and buckets services) */
31
- bucketKey: string;
32
- /** Override the default base URL (advanced use) */
33
- baseUrl?: string;
34
- /** Request timeout in milliseconds (default: 30_000) */
35
- timeout?: number;
36
- /** Number of times to retry on network errors (default: 2) */
37
- retries?: number;
38
- }
39
- type RecordData = Record<string, unknown>;
40
- interface HydrousRecord {
41
- id: string;
42
- created_at?: number;
43
- updated_at?: number;
44
- [key: string]: unknown;
45
- }
46
- interface HistoryEntry {
47
- generation: string | null;
48
- savedAt: number | null;
49
- savedBy: string | null;
50
- sizeBytes: number | null;
51
- }
52
- interface GetRecordOptions {
53
- showHistory?: boolean;
54
- }
55
- interface GetRecordResponse {
56
- success: true;
57
- data: HydrousRecord;
58
- meta: {
59
- id: string;
60
- bucketKey: string;
61
- projectId: string;
62
- retrievedAt: number;
63
- historyCount?: number;
64
- };
65
- history?: HistoryEntry[];
66
- }
67
- interface GetSnapshotResponse {
68
- success: true;
69
- data: HydrousRecord;
70
- meta: {
71
- id: string;
72
- generation: string;
73
- historical: true;
74
- bucketKey: string;
75
- projectId: string;
76
- retrievedAt: number;
77
- };
78
- }
79
- interface QueryOptions {
80
- /** ISO date string or relative shorthand e.g. "7d", "30d" */
81
- timeScope?: string;
82
- /** Year restriction for monthly GCS walk e.g. "26" or "2026" */
83
- year?: string;
84
- filters?: Filter[];
85
- sortOrder?: 'asc' | 'desc';
86
- limit?: number;
87
- /** Opaque cursor from a previous response's meta.nextCursor */
88
- cursor?: string;
89
- /** Comma-separated field names to return */
90
- fields?: string;
91
- }
92
- interface QueryResponse<T extends RecordData = RecordData> {
93
- success: true;
94
- data: (T & HydrousRecord)[];
95
- meta: ApiMeta;
96
- }
97
- interface InsertRecordPayload {
98
- values: RecordData;
99
- /** Fields to index for querying */
100
- queryableFields?: string[];
101
- userEmail?: string;
102
- }
103
- interface InsertRecordResponse {
104
- success: true;
105
- data: HydrousRecord;
106
- meta: {
107
- id: string;
108
- bucketKey: string;
109
- projectId: string;
110
- };
111
- }
112
- interface UpdateRecordPayload {
113
- recordId: string;
114
- values: RecordData;
115
- userEmail?: string;
116
- reason?: string;
117
- track_record_history?: boolean;
118
- }
119
- interface UpdateRecordResponse {
120
- success: true;
121
- meta: {
122
- id: string;
123
- updatedAt: number;
124
- };
125
- }
126
- interface DeleteRecordResponse {
127
- success: true;
128
- meta: {
129
- id: string;
130
- deleted: true;
131
- deletedAt: number;
132
- deletedBy: string;
133
- bucketKey: string;
134
- projectId: string;
135
- };
136
- }
137
- interface RecordExistsInfo {
138
- exists: boolean;
139
- id: string;
140
- createdAt: string;
141
- updatedAt: string;
142
- sizeBytes: string;
143
- }
144
- interface BatchUpdateItem {
145
- recordId: string;
146
- values: RecordData;
147
- }
148
- interface BatchUpdatePayload {
149
- updates: BatchUpdateItem[];
150
- userEmail?: string;
151
- }
152
- interface BatchResult {
153
- successful: number;
154
- failed: number;
155
- errors?: Array<{
156
- recordId: string;
157
- error: string;
158
- }>;
159
- }
160
- interface BatchUpdateResponse {
161
- success: true;
162
- data: BatchResult;
163
- meta: {
164
- count: number;
165
- bucketKey: string;
166
- projectId: string;
167
- };
168
- }
169
- interface BatchDeletePayload {
170
- recordIds: string[];
171
- userEmail?: string;
172
- }
173
- interface BatchDeleteResponse {
174
- success: true;
175
- data: BatchResult;
176
- meta: {
177
- count: number;
178
- bucketKey: string;
179
- projectId: string;
180
- };
181
- }
182
- interface BatchInsertPayload {
183
- records: RecordData[];
184
- queryableFields?: string[];
185
- userEmail?: string;
186
- }
187
- interface BatchInsertResponse {
188
- success: boolean;
189
- data: HydrousRecord[];
190
- errors?: Array<{
191
- index: number;
192
- error: string;
193
- }>;
194
- meta: {
195
- totalProcessed: number;
196
- successful: number;
197
- failed: number;
198
- bucketKey: string;
199
- projectId: string;
200
- };
201
- }
202
- interface AuthUser {
203
- id: string;
204
- email: string;
205
- fullName?: string | null;
206
- role?: string;
207
- emailVerified?: boolean;
208
- accountStatus?: string;
209
- createdAt?: number;
210
- updatedAt?: number;
211
- lastLoginAt?: number | null;
212
- [key: string]: unknown;
213
- }
214
- interface SessionInfo {
215
- sessionId: string;
216
- refreshToken: string;
217
- expiresAt: number;
218
- }
219
- interface SignUpPayload {
220
- email: string;
221
- password: string;
222
- fullName?: string;
223
- [key: string]: unknown;
224
- }
225
- interface SignUpResponse {
226
- success: true;
227
- message: string;
228
- data: AuthUser;
229
- session: SessionInfo;
230
- meta: {
231
- userId: string;
232
- email: string;
233
- requiresVerification: boolean;
234
- requestId: string;
235
- };
236
- }
237
- interface SignInPayload {
238
- email: string;
239
- password: string;
240
- }
241
- interface SignInResponse {
242
- success: true;
243
- message: string;
244
- data: AuthUser;
245
- session: SessionInfo;
246
- meta: {
247
- userId: string;
248
- lastLogin: number | null;
249
- requestId: string;
250
- };
251
- }
252
- interface SignOutPayload {
253
- sessionId?: string;
254
- allDevices?: boolean;
255
- userId?: string;
256
- }
257
- interface ValidateSessionResponse {
258
- success: true;
259
- data: AuthUser;
260
- session: {
261
- sessionId: string;
262
- expiresAt: number;
263
- };
264
- requestId: string;
265
- }
266
- interface RefreshSessionResponse {
267
- success: true;
268
- data: AuthUser;
269
- session: SessionInfo;
270
- requestId: string;
271
- }
272
- interface GetUserResponse {
273
- success: true;
274
- data: AuthUser;
275
- meta: {
276
- userId: string;
277
- requestId: string;
278
- timestamp: number;
279
- };
280
- }
281
- interface ListUsersResponse {
282
- success: true;
283
- data: AuthUser[];
284
- meta: PaginationMeta & {
285
- requestId: string;
286
- };
287
- }
288
- interface UpdateUserPayload {
289
- userId: string;
290
- updates: Partial<AuthUser> & Record<string, unknown>;
291
- }
292
- interface UpdateUserResponse {
293
- success: true;
294
- message: string;
295
- data: AuthUser;
296
- meta: {
297
- userId: string;
298
- requestId: string;
299
- };
300
- }
301
- interface PasswordChangePayload {
302
- userId: string;
303
- oldPassword: string;
304
- newPassword: string;
305
- }
306
- interface PasswordResetRequestPayload {
307
- email: string;
308
- }
309
- interface PasswordResetConfirmPayload {
310
- resetToken: string;
311
- newPassword: string;
312
- }
313
- interface EmailVerifyRequestPayload {
314
- userId: string;
315
- }
316
- interface EmailVerifyConfirmPayload {
317
- verifyToken: string;
318
- }
319
- interface AccountLockPayload {
320
- userId: string;
321
- /** Duration in ms — defaults to 15 min */
322
- duration?: number;
323
- }
324
- interface AccountLockResponse {
325
- success: true;
326
- message: string;
327
- data: {
328
- lockedUntil: number;
329
- unlockTime: string;
330
- };
331
- meta: {
332
- userId: string;
333
- requestId: string;
334
- };
335
- }
336
- type AnalyticsQueryType = 'count' | 'distribution' | 'sum' | 'timeSeries' | 'fieldTimeSeries' | 'topN' | 'stats' | 'records' | 'multiMetric' | 'storageStats' | 'crossBucket';
337
- interface DateRange {
338
- /** ISO date string "YYYY-MM-DD", epoch ms, or year string "26"/"2026" */
339
- startDate?: string;
340
- endDate?: string;
341
- year?: string;
342
- month?: string;
343
- day?: string;
344
- }
345
- interface MultiMetricItem {
346
- name: string;
347
- field: string;
348
- aggregation: 'sum' | 'avg' | 'min' | 'max' | 'count';
349
- }
350
- interface AnalyticsQuery {
351
- queryType: AnalyticsQueryType;
352
- dateRange?: DateRange;
353
- field?: string;
354
- groupBy?: string;
355
- labelField?: string;
356
- aggregation?: 'sum' | 'avg' | 'min' | 'max' | 'count';
357
- granularity?: 'hour' | 'day' | 'week' | 'month';
358
- filters?: Filter[];
359
- selectFields?: string[];
360
- limit?: number;
361
- offset?: number;
362
- orderBy?: string;
363
- order?: 'asc' | 'desc';
364
- n?: number;
365
- /** For 'multiMetric' — array of { name, field, aggregation } */
366
- metrics?: MultiMetricItem[];
367
- /** For 'crossBucket' — list of bucket keys to compare */
368
- bucketKeys?: string[];
369
- }
370
- interface CountResult {
371
- count: number;
372
- }
373
- interface DistributionItem {
374
- value: string;
375
- count: number;
376
- }
377
- interface SumResult {
378
- total: number;
379
- groups?: Array<{
380
- group: string;
381
- total: number;
382
- }>;
383
- }
384
- interface TimeSeriesPoint {
385
- date: string;
386
- count: number;
387
- }
388
- interface FieldTimeSeriesPoint {
389
- date: string;
390
- value: number;
391
- }
392
- interface TopNItem {
393
- label: string;
394
- value: string;
395
- count: number;
396
- }
397
- interface FieldStatsResult {
398
- min: number;
399
- max: number;
400
- avg: number;
401
- stddev: number;
402
- count: number;
403
- sum: number;
404
- p50: number;
405
- p90: number;
406
- p99: number;
407
- }
408
- interface FilteredRecordsResult {
409
- data: RecordData[];
410
- hasMore: boolean;
411
- offset: number;
412
- limit: number;
413
- }
414
- interface StorageStatsResult {
415
- totalRecords: number;
416
- totalBytes: number;
417
- avgBytes: number;
418
- minBytes: number;
419
- maxBytes: number;
420
- }
421
- interface AnalyticsResponse {
422
- success: true;
423
- data: unknown;
424
- meta?: Record<string, unknown>;
425
- }
426
- interface HydrousErrorBody {
427
- success: false;
428
- error: string;
429
- code?: string;
430
- details?: string[];
431
- requestId?: string;
432
- }
433
-
434
- interface HttpClientConfig {
435
- authKey: string;
436
- bucketKey: string;
437
- baseUrl?: string;
438
- timeout?: number;
439
- retries?: number;
440
- }
441
- declare class HttpClient {
442
- readonly baseUrl: string;
443
- readonly bucketKey: string;
444
- readonly authKey: string;
445
- private readonly timeout;
446
- private readonly retries;
447
- constructor(config: HttpClientConfig);
448
- request<T>(method: string, path: string, options?: {
449
- body?: unknown;
450
- params?: Record<string, string | number | boolean | undefined | null>;
451
- signal?: AbortSignal;
452
- headers?: Record<string, string>;
453
- /** Return raw Response instead of parsed JSON (used by HEAD) */
454
- raw?: boolean;
455
- }): Promise<T>;
456
- get<T>(path: string, params?: Record<string, string | number | boolean | undefined | null>, opts?: RequestOptions): Promise<T>;
457
- post<T>(path: string, body?: unknown, opts?: RequestOptions): Promise<T>;
458
- patch<T>(path: string, body?: unknown, opts?: RequestOptions): Promise<T>;
459
- delete<T>(path: string, params?: Record<string, string | number | boolean | undefined | null>, opts?: RequestOptions): Promise<T>;
460
- head(path: string, params?: Record<string, string | number | boolean | undefined | null>, opts?: RequestOptions): Promise<Response>;
461
- private buildUrl;
462
- private buildSignal;
463
- private executeWithRetry;
464
- }
465
-
466
- export { type SignUpResponse as $, type AccountLockPayload as A, type BatchDeletePayload as B, type CountResult as C, type DateRange as D, type EmailVerifyConfirmPayload as E, type FieldStatsResult as F, type GetRecordOptions as G, type HydrousErrorBody as H, type InsertRecordPayload as I, type InsertRecordResponse as J, type PasswordChangePayload as K, type ListUsersResponse as L, type MultiMetricItem as M, type PasswordResetConfirmPayload as N, type PasswordResetRequestPayload as O, type PaginationMeta as P, type QueryOptions as Q, type QueryResponse as R, type RecordData as S, type RecordExistsInfo as T, type RefreshSessionResponse as U, type RequestOptions as V, type SessionInfo as W, type SignInPayload as X, type SignInResponse as Y, type SignOutPayload as Z, type SignUpPayload as _, type HydrousConfig as a, type StorageStatsResult as a0, type SumResult as a1, type TimeSeriesPoint as a2, type TopNItem as a3, type UpdateRecordPayload as a4, type UpdateRecordResponse as a5, type UpdateUserPayload as a6, type UpdateUserResponse as a7, type ValidateSessionResponse as a8, HttpClient as a9, type AccountLockResponse as b, type AnalyticsQuery as c, type AnalyticsQueryType as d, type AnalyticsResponse as e, type ApiMeta as f, type AuthUser as g, type BatchDeleteResponse as h, type BatchInsertPayload as i, type BatchInsertResponse as j, type BatchResult as k, type BatchUpdateItem as l, type BatchUpdatePayload as m, type BatchUpdateResponse as n, type DeleteRecordResponse as o, type DistributionItem as p, type EmailVerifyRequestPayload as q, type FieldTimeSeriesPoint as r, type Filter as s, type FilterOp as t, type FilteredRecordsResult as u, type GetRecordResponse as v, type GetSnapshotResponse as w, type GetUserResponse as x, type HistoryEntry as y, type HydrousRecord as z };
@@ -1,124 +0,0 @@
1
- import { a9 as HttpClient, G as GetRecordOptions, V as RequestOptions, v as GetRecordResponse, w as GetSnapshotResponse, S as RecordData, Q as QueryOptions, R as QueryResponse, I as InsertRecordPayload, J as InsertRecordResponse, a4 as UpdateRecordPayload, a5 as UpdateRecordResponse, o as DeleteRecordResponse, T as RecordExistsInfo, m as BatchUpdatePayload, n as BatchUpdateResponse, B as BatchDeletePayload, h as BatchDeleteResponse, i as BatchInsertPayload, j as BatchInsertResponse, z as HydrousRecord } from '../http-DbiqdKlw.mjs';
2
- export { s as Filter, t as FilterOp, y as HistoryEntry } from '../http-DbiqdKlw.mjs';
3
-
4
- declare class RecordsClient {
5
- private readonly http;
6
- constructor(http: HttpClient);
7
- private get path();
8
- /**
9
- * Fetch a single record by ID.
10
- *
11
- * @example
12
- * const { data } = await db.records.get('rec_abc123');
13
- * const { data, history } = await db.records.get('rec_abc123', { showHistory: true });
14
- */
15
- get(recordId: string, options?: GetRecordOptions & RequestOptions): Promise<GetRecordResponse>;
16
- /**
17
- * Fetch a specific historical version (generation) of a record.
18
- *
19
- * @example
20
- * const { data } = await db.records.getSnapshot('rec_abc123', '1700000000000000');
21
- */
22
- getSnapshot(recordId: string, generation: string, opts?: RequestOptions): Promise<GetSnapshotResponse>;
23
- /**
24
- * Query a collection with optional filters, sorting, and pagination.
25
- *
26
- * @example
27
- * // Simple query
28
- * const { data, meta } = await db.records.query({ limit: 50, sortOrder: 'desc' });
29
- *
30
- * // Filtered query
31
- * const { data } = await db.records.query({
32
- * filters: [{ field: 'status', op: '==', value: 'active' }],
33
- * timeScope: '7d',
34
- * });
35
- *
36
- * // Paginated
37
- * let cursor: string | null = null;
38
- * do {
39
- * const result = await db.records.query({ limit: 100, cursor: cursor ?? undefined });
40
- * cursor = result.meta.nextCursor;
41
- * } while (cursor);
42
- */
43
- query<T extends RecordData = RecordData>(options?: QueryOptions & RequestOptions): Promise<QueryResponse<T>>;
44
- /**
45
- * Insert a new record.
46
- *
47
- * @example
48
- * const { data, meta } = await db.records.insert({
49
- * values: { name: 'Alice', score: 99 },
50
- * queryableFields: ['name'],
51
- * userEmail: 'alice@example.com',
52
- * });
53
- */
54
- insert(payload: InsertRecordPayload, opts?: RequestOptions): Promise<InsertRecordResponse>;
55
- /**
56
- * Update an existing record.
57
- *
58
- * @example
59
- * await db.records.update({
60
- * recordId: 'rec_abc123',
61
- * values: { score: 100 },
62
- * track_record_history: true,
63
- * });
64
- */
65
- update(payload: UpdateRecordPayload, opts?: RequestOptions): Promise<UpdateRecordResponse>;
66
- /**
67
- * Delete a record permanently.
68
- *
69
- * @example
70
- * await db.records.delete('rec_abc123');
71
- */
72
- delete(recordId: string, opts?: RequestOptions): Promise<DeleteRecordResponse>;
73
- /**
74
- * Check whether a record exists without fetching its full data.
75
- * Returns `null` if the record is not found.
76
- *
77
- * @example
78
- * const info = await db.records.exists('rec_abc123');
79
- * if (info?.exists) console.log('found at', info.updatedAt);
80
- */
81
- exists(recordId: string, opts?: RequestOptions): Promise<RecordExistsInfo | null>;
82
- /**
83
- * Update up to 500 records in a single request.
84
- *
85
- * @example
86
- * await db.records.batchUpdate({
87
- * updates: [
88
- * { recordId: 'rec_1', values: { status: 'archived' } },
89
- * { recordId: 'rec_2', values: { status: 'archived' } },
90
- * ],
91
- * });
92
- */
93
- batchUpdate(payload: BatchUpdatePayload, opts?: RequestOptions): Promise<BatchUpdateResponse>;
94
- /**
95
- * Delete up to 500 records in a single request.
96
- *
97
- * @example
98
- * await db.records.batchDelete({ recordIds: ['rec_1', 'rec_2', 'rec_3'] });
99
- */
100
- batchDelete(payload: BatchDeletePayload, opts?: RequestOptions): Promise<BatchDeleteResponse>;
101
- /**
102
- * Insert up to 500 records in a single request.
103
- * Returns HTTP 207 (multi-status) — check `meta.failed` for partial failures.
104
- *
105
- * @example
106
- * const result = await db.records.batchInsert({
107
- * records: [{ name: 'Alice' }, { name: 'Bob' }],
108
- * queryableFields: ['name'],
109
- * });
110
- */
111
- batchInsert(payload: BatchInsertPayload, opts?: RequestOptions): Promise<BatchInsertResponse>;
112
- /**
113
- * Fetch ALL records matching a query, automatically following cursors.
114
- * Use with care on large collections — prefer `query()` with manual pagination.
115
- *
116
- * @example
117
- * const allRecords = await db.records.queryAll({
118
- * filters: [{ field: 'type', op: '==', value: 'invoice' }],
119
- * });
120
- */
121
- queryAll<T extends RecordData = RecordData>(options?: Omit<QueryOptions, 'cursor'> & RequestOptions): Promise<(T & HydrousRecord)[]>;
122
- }
123
-
124
- export { BatchDeletePayload, BatchDeleteResponse, BatchInsertPayload, BatchInsertResponse, BatchUpdatePayload, BatchUpdateResponse, DeleteRecordResponse, GetRecordOptions, GetRecordResponse, GetSnapshotResponse, HydrousRecord, InsertRecordPayload, InsertRecordResponse, QueryOptions, QueryResponse, RecordData, RecordExistsInfo, RecordsClient, UpdateRecordPayload, UpdateRecordResponse };