@onyx.dev/onyx-database 1.0.2 → 1.0.3

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.
package/dist/index.d.cts CHANGED
@@ -1,1413 +1,9 @@
1
- /**
2
- * Supported operators for building query criteria.
3
- *
4
- * @example
5
- * ```ts
6
- * const criteria = { field: 'age', operator: 'GREATER_THAN', value: 21 };
7
- * ```
8
- */
9
- type QueryCriteriaOperator = 'EQUAL' | 'NOT_EQUAL' | 'IN' | 'NOT_IN' | 'GREATER_THAN' | 'GREATER_THAN_EQUAL' | 'LESS_THAN' | 'LESS_THAN_EQUAL' | 'MATCHES' | 'NOT_MATCHES' | 'BETWEEN' | 'LIKE' | 'NOT_LIKE' | 'CONTAINS' | 'CONTAINS_IGNORE_CASE' | 'NOT_CONTAINS' | 'NOT_CONTAINS_IGNORE_CASE' | 'STARTS_WITH' | 'NOT_STARTS_WITH' | 'IS_NULL' | 'NOT_NULL';
10
- /** Logical operator used to join conditions in a query. */
11
- type LogicalOperator = 'AND' | 'OR';
12
- /**
13
- * Sorting instruction for query results.
14
- *
15
- * @property field - Field name to order by.
16
- * @property order - Sort direction.
17
- * @example
18
- * ```ts
19
- * const sort: Sort = { field: 'name', order: 'ASC' };
20
- * ```
21
- */
22
- interface Sort {
23
- field: string;
24
- order: 'ASC' | 'DESC';
25
- }
26
- /** Actions emitted by real-time data streams. */
27
- type StreamAction = 'CREATE' | 'UPDATE' | 'DELETE' | 'QUERY_RESPONSE' | 'KEEP_ALIVE';
28
- /**
29
- * Basic document representation used by the SDK.
30
- *
31
- * @example
32
- * ```ts
33
- * const doc: OnyxDocument = { documentId: '1', content: 'hello' };
34
- * ```
35
- */
36
- interface OnyxDocument {
37
- /** Unique document identifier. */
38
- documentId?: string;
39
- /** Path within the Onyx database. */
40
- path?: string;
41
- /** Creation timestamp. */
42
- created?: Date;
43
- /** Last update timestamp. */
44
- updated?: Date;
45
- /** MIME type of the content. */
46
- mimeType?: string;
47
- /** Raw document content. */
48
- content?: string;
49
- }
50
- /** Minimal fetch typing to avoid DOM lib dependency */
51
- interface FetchResponse {
52
- /** Whether the request succeeded (status in the range 200–299). */
53
- ok: boolean;
54
- /** HTTP status code. */
55
- status: number;
56
- /** HTTP status text. */
57
- statusText: string;
58
- /** Response headers getter. */
59
- headers: {
60
- get(name: string): string | null;
61
- };
62
- /** Reads the body as text. */
63
- text(): Promise<string>;
64
- /** Raw body for streams; left as unknown to avoid DOM typings */
65
- body?: unknown;
66
- }
67
- /**
68
- * Fetch implementation signature used by the SDK.
69
- *
70
- * @param url - Resource URL.
71
- * @param init - Optional init parameters.
72
- * @example
73
- * ```ts
74
- * const res = await fetchImpl('https://api.onyx.dev');
75
- * ```
76
- */
77
- type FetchImpl = (url: string, init?: {
78
- method?: string;
79
- headers?: Record<string, string>;
80
- body?: string;
81
- }) => Promise<FetchResponse>;
1
+ import { O as OnyxFacade } from './aggregates-BGXzij4U.cjs';
2
+ export { E as FetchImpl, F as FetchResponse, T as ICascadeBuilder, V as ICascadeRelationshipBuilder, M as IConditionBuilder, I as IOnyxDatabase, N as IQueryBuilder, P as ISaveBuilder, L as LogicalOperator, b as OnyxConfig, D as OnyxDocument, H as QueryCondition, G as QueryCriteria, A as QueryCriteriaOperator, K as QueryPage, Q as QueryResults, a as QueryResultsPromise, R as RetryOptions, i as SchemaAttribute, u as SchemaAttributeChange, f as SchemaDataType, z as SchemaDiff, o as SchemaEntity, r as SchemaHistoryEntry, h as SchemaIdentifier, g as SchemaIdentifierGenerator, k as SchemaIndex, v as SchemaIndexChange, j as SchemaIndexType, l as SchemaResolver, w as SchemaResolverChange, q as SchemaRevision, p as SchemaRevisionMetadata, y as SchemaTableDiff, n as SchemaTrigger, x as SchemaTriggerChange, m as SchemaTriggerEvent, s as SchemaUpsertRequest, t as SchemaValidationResult, S as SecretMetadata, c as SecretRecord, e as SecretSaveRequest, d as SecretsListResponse, J as SelectQuery, B as Sort, C as StreamAction, U as UpdateQuery, W as asc, aj as avg, a2 as between, ab as contains, ac as containsIgnoreCase, al as count, X as desc, Y as eq, a3 as gt, a4 as gte, _ as inOp, ah as isNull, a9 as like, as as lower, a5 as lt, a6 as lte, a7 as matches, an as max, aq as median, am as min, Z as neq, ad as notContains, ae as notContainsIgnoreCase, a0 as notIn, aa as notLike, a8 as notMatches, ai as notNull, ag as notStartsWith, a1 as notWithin, av as percentile, au as replace, af as startsWith, ao as std, at as substring, ak as sum, ar as upper, ap as variance, $ as within } from './aggregates-BGXzij4U.cjs';
82
3
 
83
- /**
84
- * Represents a single field comparison in a query.
85
- *
86
- * @property field - Field name to evaluate.
87
- * @property operator - Comparison operator.
88
- * @property value - Value to compare against.
89
- * @example
90
- * ```ts
91
- * const criteria: QueryCriteria = { field: 'age', operator: 'GREATER_THAN', value: 18 };
92
- * ```
93
- */
94
- interface QueryCriteria {
95
- field: string;
96
- operator: QueryCriteriaOperator;
97
- value?: unknown;
98
- }
99
- /**
100
- * Recursive condition structure used to express complex WHERE clauses.
101
- *
102
- * @example
103
- * ```ts
104
- * const condition: QueryCondition = {
105
- * conditionType: 'CompoundCondition',
106
- * operator: 'AND',
107
- * conditions: [
108
- * { conditionType: 'SingleCondition', criteria: { field: 'age', operator: 'GREATER_THAN', value: 18 } },
109
- * { conditionType: 'SingleCondition', criteria: { field: 'status', operator: 'EQUAL', value: 'ACTIVE' } }
110
- * ]
111
- * };
112
- * ```
113
- */
114
- type QueryCondition = {
115
- conditionType: 'SingleCondition';
116
- criteria: QueryCriteria;
117
- } | {
118
- conditionType: 'CompoundCondition';
119
- operator: LogicalOperator;
120
- conditions: QueryCondition[];
121
- };
122
- /**
123
- * Wire format for select queries sent to the server.
124
- *
125
- * @example
126
- * ```ts
127
- * const query: SelectQuery = {
128
- * type: 'SelectQuery',
129
- * fields: ['id', 'name'],
130
- * limit: 10
131
- * };
132
- * ```
133
- */
134
- interface SelectQuery {
135
- type: 'SelectQuery';
136
- fields?: string[] | null;
137
- conditions?: QueryCondition | null;
138
- sort?: Sort[] | null;
139
- limit?: number | null;
140
- distinct?: boolean | null;
141
- groupBy?: string[] | null;
142
- partition?: string | null;
143
- resolvers?: string[] | null;
144
- }
145
- /**
146
- * Wire format for update queries sent to the server.
147
- *
148
- * @example
149
- * ```ts
150
- * const update: UpdateQuery = {
151
- * type: 'UpdateQuery',
152
- * updates: { name: 'New Name' }
153
- * };
154
- * ```
155
- */
156
- interface UpdateQuery {
157
- type: 'UpdateQuery';
158
- conditions?: QueryCondition | null;
159
- updates: Record<string, unknown>;
160
- sort?: Sort[] | null;
161
- limit?: number | null;
162
- partition?: string | null;
163
- }
164
- /**
165
- * A single page of query results.
166
- *
167
- * @example
168
- * ```ts
169
- * const page: QueryPage<User> = { records: users, nextPage: token };
170
- * ```
171
- */
172
- interface QueryPage<T> {
173
- /** Records in the current page. */
174
- records: T[];
175
- /** Token for the next page or null if none. */
176
- nextPage?: string | null;
177
- }
178
-
179
- /**
180
- * Array-like container for paginated query results. Provides helper methods
181
- * to traverse and aggregate records across pages.
182
- *
183
- * @example
184
- * ```ts
185
- * const results = new QueryResults(users, nextToken, fetchNext);
186
- * const firstUser = results.first();
187
- * ```
188
- */
189
- type QueryResultsPromise<T> = Promise<QueryResults<T>> & {
190
- [K in keyof QueryResults<T> as QueryResults<T>[K] extends (...args: any[]) => any ? K : never]: QueryResults<T>[K] extends (...args: infer P) => infer R ? (...args: P) => Promise<Awaited<R>> : never;
191
- };
192
- declare class QueryResults<T> extends Array<T> {
193
- /** Token for the next page of results or null. */
194
- nextPage: string | null;
195
- private readonly fetcher?;
196
- /**
197
- * @param records - Records in the current page.
198
- * @param nextPage - Token representing the next page.
199
- * @param fetcher - Function used to fetch the next page when needed.
200
- * @example
201
- * ```ts
202
- * const results = new QueryResults(users, token, t => fetchMore(t));
203
- * ```
204
- */
205
- constructor(records: Iterable<T> | ArrayLike<T> | T | null | undefined, nextPage: string | null, fetcher?: (token: string) => Promise<QueryResults<T>>);
206
- /**
207
- * Returns the first record in the result set.
208
- * @throws Error if the result set is empty.
209
- * @example
210
- * ```ts
211
- * const user = results.first();
212
- * ```
213
- */
214
- first(): T;
215
- /**
216
- * Returns the first record or `null` if the result set is empty.
217
- * @example
218
- * ```ts
219
- * const user = results.firstOrNull();
220
- * ```
221
- */
222
- firstOrNull(): T | null;
223
- /**
224
- * Checks whether the current page has no records.
225
- * @example
226
- * ```ts
227
- * if (results.isEmpty()) console.log('no data');
228
- * ```
229
- */
230
- isEmpty(): boolean;
231
- /**
232
- * Number of records on the current page.
233
- * @example
234
- * ```ts
235
- * console.log(results.size());
236
- * ```
237
- */
238
- size(): number;
239
- /**
240
- * Iterates over each record on the current page only.
241
- * @param action - Function to invoke for each record.
242
- * @param thisArg - Optional `this` binding for the callback.
243
- * @example
244
- * ```ts
245
- * results.forEachOnPage(u => console.log(u.id));
246
- * ```
247
- */
248
- forEachOnPage(action: (item: T, index: number, array: QueryResults<T>) => void, thisArg?: unknown): void;
249
- /**
250
- * Iterates over every record across all pages sequentially.
251
- * @param action - Function executed for each record. Returning `false`
252
- * stops iteration early.
253
- * @param thisArg - Optional `this` binding for the callback.
254
- * @example
255
- * ```ts
256
- * await results.forEach(u => {
257
- * console.log(u.id);
258
- * });
259
- * ```
260
- */
261
- forEach(action: (item: T, index: number, array: T[]) => void, thisArg?: unknown): Promise<void>;
262
- /**
263
- * Iterates over every record across all pages sequentially.
264
- * @param action - Function executed for each record. Returning `false`
265
- * stops iteration early.
266
- * @example
267
- * ```ts
268
- * await results.forEachAll(u => {
269
- * if (u.disabled) return false;
270
- * });
271
- * ```
272
- */
273
- forEachAll(action: (item: T) => boolean | void | Promise<boolean | void>): Promise<void>;
274
- /**
275
- * Iterates page by page across the result set.
276
- * @param action - Function invoked with each page of records. Returning
277
- * `false` stops iteration.
278
- * @example
279
- * ```ts
280
- * await results.forEachPage(page => {
281
- * console.log(page.length);
282
- * });
283
- * ```
284
- */
285
- forEachPage(action: (records: T[]) => boolean | void | Promise<boolean | void>): Promise<void>;
286
- /**
287
- * Collects all records from every page into a single array.
288
- * @returns All records.
289
- * @example
290
- * ```ts
291
- * const allUsers = await results.getAllRecords();
292
- * ```
293
- */
294
- getAllRecords(): Promise<T[]>;
295
- /**
296
- * Filters all records using the provided predicate.
297
- * @param predicate - Function used to test each record.
298
- * @example
299
- * ```ts
300
- * const enabled = await results.filterAll(u => u.enabled);
301
- * ```
302
- */
303
- filterAll(predicate: (record: T) => boolean): Promise<T[]>;
304
- /**
305
- * Maps all records using the provided transform.
306
- * @param transform - Mapping function.
307
- * @example
308
- * ```ts
309
- * const names = await results.mapAll(u => u.name);
310
- * ```
311
- */
312
- mapAll<R>(transform: (record: T) => R): Promise<R[]>;
313
- /**
314
- * Extracts values for a field across all records.
315
- * @param field - Name of the field to pluck.
316
- * @example
317
- * ```ts
318
- * const ids = await results.values('id');
319
- * ```
320
- */
321
- values<K extends keyof T>(field: K): Promise<Array<T[K]>>;
322
- /**
323
- * Maximum value produced by the selector across all records.
324
- * @param selector - Function extracting a numeric value.
325
- * @example
326
- * ```ts
327
- * const maxAge = await results.maxOfDouble(u => u.age);
328
- * ```
329
- */
330
- maxOfDouble(selector: (record: T) => number): Promise<number>;
331
- /**
332
- * Minimum value produced by the selector across all records.
333
- * @param selector - Function extracting a numeric value.
334
- * @example
335
- * ```ts
336
- * const minAge = await results.minOfDouble(u => u.age);
337
- * ```
338
- */
339
- minOfDouble(selector: (record: T) => number): Promise<number>;
340
- /**
341
- * Sum of values produced by the selector across all records.
342
- * @param selector - Function extracting a numeric value.
343
- * @example
344
- * ```ts
345
- * const total = await results.sumOfDouble(u => u.score);
346
- * ```
347
- */
348
- sumOfDouble(selector: (record: T) => number): Promise<number>;
349
- /**
350
- * Maximum float value from the selector.
351
- * @param selector - Function extracting a numeric value.
352
- */
353
- maxOfFloat(selector: (record: T) => number): Promise<number>;
354
- /**
355
- * Minimum float value from the selector.
356
- * @param selector - Function extracting a numeric value.
357
- */
358
- minOfFloat(selector: (record: T) => number): Promise<number>;
359
- /**
360
- * Sum of float values from the selector.
361
- * @param selector - Function extracting a numeric value.
362
- */
363
- sumOfFloat(selector: (record: T) => number): Promise<number>;
364
- /**
365
- * Maximum integer value from the selector.
366
- * @param selector - Function extracting a numeric value.
367
- */
368
- maxOfInt(selector: (record: T) => number): Promise<number>;
369
- /**
370
- * Minimum integer value from the selector.
371
- * @param selector - Function extracting a numeric value.
372
- */
373
- minOfInt(selector: (record: T) => number): Promise<number>;
374
- /**
375
- * Sum of integer values from the selector.
376
- * @param selector - Function extracting a numeric value.
377
- */
378
- sumOfInt(selector: (record: T) => number): Promise<number>;
379
- /**
380
- * Maximum long value from the selector.
381
- * @param selector - Function extracting a numeric value.
382
- */
383
- maxOfLong(selector: (record: T) => number): Promise<number>;
384
- /**
385
- * Minimum long value from the selector.
386
- * @param selector - Function extracting a numeric value.
387
- */
388
- minOfLong(selector: (record: T) => number): Promise<number>;
389
- /**
390
- * Sum of long values from the selector.
391
- * @param selector - Function extracting a numeric value.
392
- */
393
- sumOfLong(selector: (record: T) => number): Promise<number>;
394
- /**
395
- * Sum of bigint values from the selector.
396
- * @param selector - Function extracting a bigint value.
397
- * @example
398
- * ```ts
399
- * const total = await results.sumOfBigInt(u => u.balance);
400
- * ```
401
- */
402
- sumOfBigInt(selector: (record: T) => bigint): Promise<bigint>;
403
- /**
404
- * Executes an action for each page in parallel.
405
- * @param action - Function executed for each record concurrently.
406
- * @example
407
- * ```ts
408
- * await results.forEachPageParallel(async u => sendEmail(u));
409
- * ```
410
- */
411
- forEachPageParallel(action: (item: T) => void | Promise<void>): Promise<void>;
412
- }
413
-
414
- /**
415
- * Builder used to compose query conditions.
416
- */
417
- interface IConditionBuilder {
418
- /**
419
- * Combines the current condition with another using `AND`.
420
- * @param condition - Additional condition or builder.
421
- * @example
422
- * ```ts
423
- * cb.and({ field: 'age', operator: 'GREATER_THAN', value: 18 });
424
- * ```
425
- */
426
- and(condition: IConditionBuilder | QueryCriteria): IConditionBuilder;
427
- /**
428
- * Combines the current condition with another using `OR`.
429
- * @param condition - Additional condition or builder.
430
- * @example
431
- * ```ts
432
- * cb.or({ field: 'status', operator: 'EQUAL', value: 'ACTIVE' });
433
- * ```
434
- */
435
- or(condition: IConditionBuilder | QueryCriteria): IConditionBuilder;
436
- /**
437
- * Materializes the composed condition into a `QueryCondition` object.
438
- * @example
439
- * ```ts
440
- * const cond = cb.toCondition();
441
- * ```
442
- */
443
- toCondition(): QueryCondition;
444
- }
445
- /**
446
- * Fluent query builder for constructing and executing select/update/delete operations.
447
- */
448
- interface IQueryBuilder<T = unknown> {
449
- /**
450
- * Sets the table to query.
451
- * @example
452
- * ```ts
453
- * const users = await db.from('User').list();
454
- * ```
455
- */
456
- from(table: string): IQueryBuilder<T>;
457
- /**
458
- * Selects a subset of fields to return.
459
- * @example
460
- * ```ts
461
- * const emails = await db.from('User').select('email').list();
462
- * ```
463
- */
464
- select(...fields: Array<string | string[]>): IQueryBuilder<T>;
465
- /**
466
- * Resolves related values by name.
467
- * @example
468
- * ```ts
469
- * const users = await db
470
- * .from('User')
471
- * .resolve('profile', 'roles')
472
- * .list();
473
- * ```
474
- */
475
- resolve(...values: Array<string | string[]>): IQueryBuilder<T>;
476
- /**
477
- * Adds a filter condition.
478
- * @example
479
- * ```ts
480
- * const active = await db.from('User').where(eq('status', 'active')).list();
481
- * ```
482
- */
483
- where(condition: IConditionBuilder | QueryCriteria): IQueryBuilder<T>;
484
- /**
485
- * Adds an additional filter with `AND`.
486
- * @example
487
- * ```ts
488
- * qb.where(eq('status', 'active')).and(eq('role', 'admin'));
489
- * ```
490
- */
491
- and(condition: IConditionBuilder | QueryCriteria): IQueryBuilder<T>;
492
- /**
493
- * Adds an additional filter with `OR`.
494
- * @example
495
- * ```ts
496
- * qb.where(eq('status', 'active')).or(eq('status', 'invited'));
497
- * ```
498
- */
499
- or(condition: IConditionBuilder | QueryCriteria): IQueryBuilder<T>;
500
- /**
501
- * Orders results by the provided fields.
502
- * @example
503
- * ```ts
504
- * const users = await db.from('User').orderBy(asc('createdAt')).list();
505
- * ```
506
- */
507
- orderBy(...sorts: Sort[]): IQueryBuilder<T>;
508
- /**
509
- * Groups results by the provided fields.
510
- * @example
511
- * ```ts
512
- * const stats = await db.from('User').groupBy('status').list();
513
- * ```
514
- */
515
- groupBy(...fields: string[]): IQueryBuilder<T>;
516
- /**
517
- * Ensures only distinct records are returned.
518
- * @example
519
- * ```ts
520
- * const roles = await db.from('User').select('role').distinct().list();
521
- * ```
522
- */
523
- distinct(): IQueryBuilder<T>;
524
- /**
525
- * Limits the number of records returned.
526
- * @example
527
- * ```ts
528
- * const few = await db.from('User').limit(5).list();
529
- * ```
530
- */
531
- limit(n: number): IQueryBuilder<T>;
532
- /**
533
- * Restricts the query to a specific partition.
534
- * @example
535
- * ```ts
536
- * const tenantUsers = await db.from('User').inPartition('tenantA').list();
537
- * ```
538
- */
539
- inPartition(partition: string): IQueryBuilder<T>;
540
- /** Sets the page size for subsequent `list` or `page` calls. */
541
- pageSize(n: number): IQueryBuilder<T>;
542
- /**
543
- * Continues a paged query using a next-page token.
544
- * @example
545
- * ```ts
546
- * const page2 = await db.from('User').nextPage(token).list();
547
- * ```
548
- */
549
- nextPage(token: string): IQueryBuilder<T>;
550
- /**
551
- * Counts matching records.
552
- * @example
553
- * ```ts
554
- * const total = await db.from('User').count();
555
- * ```
556
- */
557
- count(): Promise<number>;
558
- /**
559
- * Lists records with optional pagination.
560
- * @example
561
- * ```ts
562
- * const users = await db.from('User').list({ pageSize: 10 });
563
- * ```
564
- */
565
- list(options?: {
566
- pageSize?: number;
567
- nextPage?: string;
568
- }): QueryResultsPromise<T>;
569
- /**
570
- * Retrieves the first record or null.
571
- * @example
572
- * ```ts
573
- * const user = await db.from('User').firstOrNull();
574
- * ```
575
- */
576
- firstOrNull(): Promise<T | null>;
577
- /**
578
- * Retrieves exactly one record or null.
579
- * @example
580
- * ```ts
581
- * const user = await db
582
- * .from('User')
583
- * .where(eq('email', 'a@b.com'))
584
- * .one();
585
- * ```
586
- */
587
- one(): Promise<T | null>;
588
- /**
589
- * Retrieves a single page of records with optional next token.
590
- * @example
591
- * ```ts
592
- * const { records, nextPage } = await db.from('User').page({ pageSize: 25 });
593
- * ```
594
- */
595
- page(options?: {
596
- pageSize?: number;
597
- nextPage?: string;
598
- }): Promise<{
599
- records: T[];
600
- nextPage?: string | null;
601
- }>;
602
- /**
603
- * Sets field updates for an update query.
604
- * @example
605
- * ```ts
606
- * await db
607
- * .from('User')
608
- * .where(eq('id', 'u1'))
609
- * .setUpdates({ status: 'active' })
610
- * .update();
611
- * ```
612
- */
613
- setUpdates(updates: Partial<T>): IQueryBuilder<T>;
614
- /**
615
- * Executes an update operation.
616
- * @example
617
- * ```ts
618
- * await db.from('User').where(eq('id', 'u1')).setUpdates({ status: 'active' }).update();
619
- * ```
620
- */
621
- update(): Promise<unknown>;
622
- /**
623
- * Executes a delete operation.
624
- * @example
625
- * ```ts
626
- * await db.from('User').where(eq('status', 'inactive')).delete();
627
- * ```
628
- */
629
- delete(): Promise<unknown>;
630
- /**
631
- * Registers a listener for added items on a stream.
632
- * @example
633
- * ```ts
634
- * db.from('User').onItemAdded(u => console.log('added', u));
635
- * ```
636
- */
637
- onItemAdded(listener: (entity: T) => void): IQueryBuilder<T>;
638
- /**
639
- * Registers a listener for updated items on a stream.
640
- * @example
641
- * ```ts
642
- * db.from('User').onItemUpdated(u => console.log('updated', u));
643
- * ```
644
- */
645
- onItemUpdated(listener: (entity: T) => void): IQueryBuilder<T>;
646
- /**
647
- * Registers a listener for deleted items on a stream.
648
- * @example
649
- * ```ts
650
- * db.from('User').onItemDeleted(u => console.log('deleted', u));
651
- * ```
652
- */
653
- onItemDeleted(listener: (entity: T) => void): IQueryBuilder<T>;
654
- /**
655
- * Registers a listener for any stream item with its action.
656
- * @example
657
- * ```ts
658
- * db.from('User').onItem((u, action) => console.log(action, u));
659
- * ```
660
- */
661
- onItem(listener: (entity: T | null, action: StreamAction) => void): IQueryBuilder<T>;
662
- /**
663
- * Starts a stream including query results.
664
- * @example
665
- * ```ts
666
- * const { cancel } = await db.from('User').stream();
667
- * ```
668
- */
669
- stream(includeQueryResults?: boolean, keepAlive?: boolean): Promise<{
670
- cancel: () => void;
671
- }>;
672
- /**
673
- * Starts a stream emitting only events.
674
- * @example
675
- * ```ts
676
- * const { cancel } = await db.from('User').streamEventsOnly();
677
- * ```
678
- */
679
- streamEventsOnly(keepAlive?: boolean): Promise<{
680
- cancel: () => void;
681
- }>;
682
- /**
683
- * Starts a stream that returns events alongside query results.
684
- * @example
685
- * ```ts
686
- * const { cancel } = await db.from('User').streamWithQueryResults();
687
- * ```
688
- */
689
- streamWithQueryResults(keepAlive?: boolean): Promise<{
690
- cancel: () => void;
691
- }>;
692
- }
693
-
694
- /** Builder for save operations. */
695
- interface ISaveBuilder<T = unknown> {
696
- /**
697
- * Cascades specified relationships when saving.
698
- * @example
699
- * ```ts
700
- * await db.save('User').cascade('role').one(user);
701
- * ```
702
- */
703
- cascade(...relationships: Array<string | string[]>): ISaveBuilder<T>;
704
- /**
705
- * Persists a single entity.
706
- * @example
707
- * ```ts
708
- * await db.save('User').one({ id: 'u1' });
709
- * ```
710
- */
711
- one(entity: Partial<T>): Promise<unknown>;
712
- /**
713
- * Persists multiple entities.
714
- * @example
715
- * ```ts
716
- * await db.save('User').many([{ id: 'u1' }, { id: 'u2' }]);
717
- * ```
718
- */
719
- many(entities: Array<Partial<T>>): Promise<unknown>;
720
- }
721
- /** Builder for cascading save/delete operations across multiple tables. */
722
- interface ICascadeBuilder<Schema = Record<string, unknown>> {
723
- /**
724
- * Specifies relationships to cascade through.
725
- * @example
726
- * ```ts
727
- * const builder = db.cascade('permissions');
728
- * ```
729
- */
730
- cascade(...relationships: Array<string | string[]>): ICascadeBuilder<Schema>;
731
- /**
732
- * Saves one or many entities for a given table.
733
- * @example
734
- * ```ts
735
- * await db.cascade('permissions').save('Role', role);
736
- * ```
737
- */
738
- save<Table extends keyof Schema & string>(table: Table, entityOrEntities: Partial<Schema[Table]> | Array<Partial<Schema[Table]>>): Promise<unknown>;
739
- /**
740
- * Deletes an entity by primary key.
741
- * @example
742
- * ```ts
743
- * await db.cascade('permissions').delete('Role', 'admin');
744
- * ```
745
- */
746
- delete<Table extends keyof Schema & string>(table: Table, primaryKey: string): Promise<boolean>;
747
- }
748
- /** Builder for describing cascade relationship metadata. */
749
- interface ICascadeRelationshipBuilder {
750
- /**
751
- * Names the relationship graph.
752
- * @example
753
- * ```ts
754
- * builder.graph('permissions');
755
- * ```
756
- */
757
- graph(name: string): ICascadeRelationshipBuilder;
758
- /**
759
- * Sets the graph type.
760
- * @example
761
- * ```ts
762
- * builder.graphType('Permission');
763
- * ```
764
- */
765
- graphType(type: string): ICascadeRelationshipBuilder;
766
- /**
767
- * Field on the target entity.
768
- * @example
769
- * ```ts
770
- * builder.targetField('roleId');
771
- * ```
772
- */
773
- targetField(field: string): ICascadeRelationshipBuilder;
774
- /**
775
- * Field on the source entity.
776
- * @example
777
- * ```ts
778
- * const rel = builder.sourceField('id');
779
- * ```
780
- */
781
- sourceField(field: string): string;
782
- }
783
-
784
- interface OnyxConfig {
785
- baseUrl?: string;
786
- databaseId?: string;
787
- apiKey?: string;
788
- apiSecret?: string;
789
- fetch?: FetchImpl;
790
- /**
791
- * Default partition for queries, `findById`, and deletes when removing by
792
- * primary key. Saves rely on the entity's partition field instead.
793
- */
794
- partition?: string;
795
- /**
796
- * When true, log HTTP requests and bodies to the console.
797
- */
798
- requestLoggingEnabled?: boolean;
799
- /**
800
- * When true, log HTTP responses and bodies to the console.
801
- */
802
- responseLoggingEnabled?: boolean;
803
- /**
804
- * Milliseconds to cache resolved credentials; defaults to 5 minutes.
805
- */
806
- ttl?: number;
807
- }
808
- interface IOnyxDatabase<Schema = Record<string, unknown>> {
809
- /**
810
- * Begin a query against a table.
811
- *
812
- * @example
813
- * ```ts
814
- * const maybeUser = await db
815
- * .from('User')
816
- * .where(eq('email', 'a@b.com'))
817
- * .firstOrNull(); // or .one()
818
- * ```
819
- *
820
- * @example
821
- * ```ts
822
- * const users = await db
823
- * .select('id', 'email')
824
- * .from('User')
825
- * .list();
826
- * ```
827
- *
828
- * @param table Table name to query.
829
- */
830
- from<Table extends keyof Schema & string>(table: Table): IQueryBuilder<Schema[Table]>;
831
- /**
832
- * Select specific fields for a query.
833
- *
834
- * @example
835
- * ```ts
836
- * const users = await db
837
- * .select('id', 'name')
838
- * .from('User')
839
- * .list();
840
- * ```
841
- *
842
- * @param fields Field names to project; omit to select all.
843
- */
844
- select(...fields: string[]): IQueryBuilder<Record<string, unknown>>;
845
- /**
846
- * Include related records in the next save or delete.
847
- *
848
- * @example
849
- * ```ts
850
- * // Save a role and its permissions
851
- * await db
852
- * .cascade('permissions:Permission(roleId, id)')
853
- * .save('Role', role);
854
- *
855
- * // Delete a role and all of its permissions via resolver
856
- * await db
857
- * .cascade('permissions')
858
- * .delete('Role', 'admin');
859
- * ```
860
- *
861
- * @param relationships Cascade relationship strings using
862
- * `graph:Type(targetField, sourceField)` syntax when saving.
863
- * When deleting, pass resolver attribute names only.
864
- */
865
- cascade(...relationships: Array<string | string[]>): ICascadeBuilder<Schema>;
866
- /**
867
- * Build cascade relationship strings programmatically.
868
- *
869
- * @example
870
- * ```ts
871
- * const rel = db
872
- * .cascadeBuilder()
873
- * .graph('permissions')
874
- * .graphType('Permission')
875
- * .targetField('roleId')
876
- * .sourceField('id');
877
- * await db.cascade(rel).save('Role', role);
878
- * ```
879
- *
880
- * @returns Builder that emits strings like
881
- * `graphName:TypeName(targetField, sourceField)`.
882
- */
883
- cascadeBuilder(): ICascadeRelationshipBuilder;
884
- /**
885
- * Start a save builder for inserting or updating entities.
886
- *
887
- * @example
888
- * ```ts
889
- * await db
890
- * .save('User')
891
- * .cascade('role:Role(userId, id)')
892
- * .one({
893
- * id: 'u1',
894
- * email: 'a@b.com',
895
- * role: { id: 'admin', userId: 'u1' }
896
- * });
897
- * ```
898
- *
899
- * @param table Table to save into.
900
- */
901
- save<Table extends keyof Schema & string>(table: Table): ISaveBuilder<Schema[Table]>;
902
- /**
903
- * Save one or many entities immediately.
904
- *
905
- * @example
906
- * ```ts
907
- * await db.save(
908
- * 'Role',
909
- * [{ id: 'admin', permissions: [{ id: 'perm1', roleId: 'admin' }] }],
910
- * { relationships: ['permissions:Permission(roleId, id)'] }
911
- * );
912
- * ```
913
- *
914
- * The `relationships` option accepts cascade strings in the form
915
- * `graphName:TypeName(targetField, sourceField)` describing how child records relate to the
916
- * parent. Use {@link cascadeBuilder} to construct them safely.
917
- *
918
- * @param table Table to save into.
919
- * @param entityOrEntities Object or array of objects to persist.
920
- * @param options Optional settings for the save operation.
921
- * @param options.relationships Cascade relationships to include.
922
- */
923
- save<Table extends keyof Schema & string>(table: Table, entityOrEntities: Partial<Schema[Table]> | Array<Partial<Schema[Table]>>, options?: {
924
- relationships?: string[];
925
- }): Promise<unknown>;
926
- /**
927
- * Save many entities in configurable batches.
928
- *
929
- * @example
930
- * ```ts
931
- * await db.batchSave('User', users, 500);
932
- * ```
933
- *
934
- * @param table Table to save into.
935
- * @param entities Array of entities to persist.
936
- * @param batchSize Number of entities per batch; defaults to 1000.
937
- */
938
- batchSave<Table extends keyof Schema & string>(table: Table, entities: Array<Partial<Schema[Table]>>, batchSize?: number, options?: {
939
- relationships?: string[];
940
- }): Promise<void>;
941
- /**
942
- * Retrieve an entity by its primary key.
943
- *
944
- * @example
945
- * ```ts
946
- * const user = await db.findById('User', 'user_1', {
947
- * partition: 'tenantA',
948
- * resolvers: ['profile']
949
- * });
950
- * ```
951
- *
952
- * @param table Table to search.
953
- * @param primaryKey Primary key value.
954
- * @param options Optional partition and resolver settings.
955
- */
956
- findById<Table extends keyof Schema & string, T = Schema[Table]>(table: Table, primaryKey: string, options?: {
957
- partition?: string;
958
- resolvers?: string[];
959
- }): Promise<T | null>;
960
- /**
961
- * Delete an entity by primary key.
962
- *
963
- * @example
964
- * ```ts
965
- * const deleted = await db.delete('Role', 'admin', {
966
- * relationships: ['permissions']
967
- * });
968
- * ```
969
- *
970
- * @param table Table containing the entity.
971
- * @param primaryKey Primary key value.
972
- * @param options Optional partition and cascade relationships.
973
- * @returns `true` when the delete request succeeds.
974
- */
975
- delete<Table extends keyof Schema & string>(table: Table, primaryKey: string, options?: {
976
- partition?: string;
977
- relationships?: string[];
978
- }): Promise<boolean>;
979
- /**
980
- * Store a document (file blob) for later retrieval.
981
- *
982
- * @example
983
- * ```ts
984
- * const id = await db.saveDocument({
985
- * path: '/docs/note.txt',
986
- * mimeType: 'text/plain',
987
- * content: 'hello world'
988
- * });
989
- * ```
990
- */
991
- saveDocument(doc: OnyxDocument): Promise<unknown>;
992
- /**
993
- * Fetch a previously saved document.
994
- *
995
- * @example
996
- * ```ts
997
- * const doc = await db.getDocument('doc123', { width: 640, height: 480 });
998
- * ```
999
- *
1000
- * @param documentId ID of the document to fetch.
1001
- * @param options Optional image resize settings.
1002
- */
1003
- getDocument(documentId: string, options?: {
1004
- width?: number;
1005
- height?: number;
1006
- }): Promise<unknown>;
1007
- /**
1008
- * Remove a stored document permanently.
1009
- *
1010
- * @example
1011
- * ```ts
1012
- * await db.deleteDocument('doc123');
1013
- * ```
1014
- *
1015
- * @param documentId ID of the document to delete.
1016
- */
1017
- deleteDocument(documentId: string): Promise<unknown>;
1018
- /**
1019
- * Fetch the current schema for the configured database.
1020
- *
1021
- * @example
1022
- * ```ts
1023
- * const schema = await db.getSchema();
1024
- * const userOnly = await db.getSchema({ tables: ['User'] });
1025
- * ```
1026
- */
1027
- getSchema(options?: {
1028
- tables?: string | string[];
1029
- }): Promise<SchemaRevision>;
1030
- /**
1031
- * Retrieve the schema revision history for the configured database.
1032
- */
1033
- getSchemaHistory(): Promise<SchemaHistoryEntry[]>;
1034
- /**
1035
- * Compare the current API schema with a local schema definition.
1036
- *
1037
- * @example
1038
- * ```ts
1039
- * const diff = await db.diffSchema(localSchema);
1040
- * if (!diff.newTables.length && !diff.removedTables.length && !diff.changedTables.length) {
1041
- * console.log('Schemas match');
1042
- * }
1043
- * ```
1044
- */
1045
- diffSchema(localSchema: SchemaUpsertRequest): Promise<SchemaDiff>;
1046
- /**
1047
- * Update the schema for the configured database.
1048
- *
1049
- * @example
1050
- * ```ts
1051
- * await db.updateSchema({
1052
- * revisionDescription: 'Add profile table',
1053
- * entities: [
1054
- * {
1055
- * name: 'Profile',
1056
- * identifier: { name: 'id', generator: 'UUID' },
1057
- * attributes: [
1058
- * { name: 'displayName', type: 'String', isNullable: false }
1059
- * ]
1060
- * }
1061
- * ]
1062
- * }, { publish: true });
1063
- * ```
1064
- */
1065
- updateSchema(schema: SchemaUpsertRequest, options?: {
1066
- publish?: boolean;
1067
- }): Promise<SchemaRevision>;
1068
- /**
1069
- * Validate a schema definition without applying it to the database.
1070
- */
1071
- validateSchema(schema: SchemaUpsertRequest): Promise<SchemaValidationResult>;
1072
- /**
1073
- * List stored secrets for the configured database.
1074
- */
1075
- listSecrets(): Promise<SecretsListResponse>;
1076
- /**
1077
- * Fetch a decrypted secret value by key.
1078
- */
1079
- getSecret(key: string): Promise<SecretRecord>;
1080
- /**
1081
- * Create or update a secret.
1082
- */
1083
- putSecret(key: string, input: SecretSaveRequest): Promise<SecretMetadata>;
1084
- /**
1085
- * Delete a secret by key.
1086
- */
1087
- deleteSecret(key: string): Promise<{
1088
- key: string;
1089
- }>;
1090
- /**
1091
- * Cancels active streams; safe to call multiple times.
1092
- * @example
1093
- * ```ts
1094
- * const stream = await db.from('User').stream();
1095
- * stream.cancel();
1096
- * db.close();
1097
- * ```
1098
- */
1099
- close(): void;
1100
- }
1101
- interface OnyxFacade {
1102
- /**
1103
- * Initialize a database client.
1104
- *
1105
- * @example
1106
- * ```ts
1107
- * const db = onyx.init({
1108
- * baseUrl: 'https://api.onyx.dev',
1109
- * databaseId: 'my-db',
1110
- * apiKey: 'key',
1111
- * apiSecret: 'secret'
1112
- * });
1113
- * ```
1114
- *
1115
- * @param config Connection settings and optional custom fetch.
1116
- * @remarks
1117
- * Each `db` instance resolves configuration once and holds a single internal
1118
- * HTTP client. Requests leverage Node's built-in `fetch`, which reuses and
1119
- * pools connections for keep-alive, so additional connection caching or
1120
- * pooling is rarely necessary.
1121
- */
1122
- init<Schema = Record<string, unknown>>(config?: OnyxConfig): IOnyxDatabase<Schema>;
1123
- /**
1124
- * Clear cached configuration so the next {@link init} call re-resolves
1125
- * credentials immediately.
1126
- */
1127
- clearCacheConfig(): void;
1128
- }
1129
- interface SecretMetadata {
1130
- key: string;
1131
- purpose?: string;
1132
- updatedAt: Date;
1133
- }
1134
- interface SecretRecord extends SecretMetadata {
1135
- value: string;
1136
- }
1137
- interface SecretsListResponse {
1138
- records: SecretMetadata[];
1139
- meta: {
1140
- totalRecords: number;
1141
- };
1142
- }
1143
- interface SecretSaveRequest {
1144
- purpose?: string;
1145
- value?: string;
1146
- }
1147
- type SchemaDataType = 'String' | 'Boolean' | 'Char' | 'Byte' | 'Short' | 'Int' | 'Float' | 'Double' | 'Long' | 'Timestamp' | 'EmbeddedObject' | 'EmbeddedList';
1148
- type SchemaIdentifierGenerator = 'None' | 'Sequence' | 'UUID';
1149
- interface SchemaIdentifier {
1150
- name: string;
1151
- generator?: SchemaIdentifierGenerator;
1152
- type?: SchemaDataType | string;
1153
- }
1154
- interface SchemaAttribute {
1155
- name: string;
1156
- type: SchemaDataType | string;
1157
- isNullable?: boolean;
1158
- }
1159
- type SchemaIndexType = 'DEFAULT' | 'LUCENE' | string;
1160
- interface SchemaIndex {
1161
- name: string;
1162
- type?: SchemaIndexType;
1163
- minimumScore?: number;
1164
- [key: string]: unknown;
1165
- }
1166
- interface SchemaResolver {
1167
- name: string;
1168
- resolver: string;
1169
- [key: string]: unknown;
1170
- }
1171
- type SchemaTriggerEvent = 'PreInsert' | 'PostInsert' | 'PrePersist' | 'PostPersist' | 'PreUpdate' | 'PostUpdate' | 'PreDelete' | 'PostDelete' | string;
1172
- interface SchemaTrigger {
1173
- name: string;
1174
- event: SchemaTriggerEvent;
1175
- trigger: string;
1176
- [key: string]: unknown;
1177
- }
1178
- interface SchemaEntity {
1179
- name: string;
1180
- identifier?: SchemaIdentifier;
1181
- partition?: string;
1182
- attributes?: SchemaAttribute[];
1183
- indexes?: SchemaIndex[];
1184
- resolvers?: SchemaResolver[];
1185
- triggers?: SchemaTrigger[];
1186
- [key: string]: unknown;
1187
- }
1188
- interface SchemaRevisionMetadata {
1189
- revisionId?: string;
1190
- createdAt?: Date;
1191
- publishedAt?: Date;
1192
- [key: string]: unknown;
1193
- }
1194
- interface SchemaRevision {
1195
- databaseId: string;
1196
- revisionDescription?: string;
1197
- entities: SchemaEntity[];
1198
- meta?: SchemaRevisionMetadata;
1199
- [key: string]: unknown;
1200
- }
1201
- type SchemaHistoryEntry = SchemaRevision;
1202
- type SchemaUpsertRequest = Omit<SchemaRevision, 'databaseId' | 'meta'> & {
1203
- databaseId?: string;
1204
- [key: string]: unknown;
1205
- };
1206
- interface SchemaValidationResult {
1207
- valid?: boolean;
1208
- schema?: SchemaRevision;
1209
- errors?: Array<{
1210
- message: string;
1211
- }>;
1212
- }
1213
- interface SchemaAttributeChange {
1214
- name: string;
1215
- from: {
1216
- type?: string;
1217
- isNullable?: boolean;
1218
- };
1219
- to: {
1220
- type?: string;
1221
- isNullable?: boolean;
1222
- };
1223
- }
1224
- interface SchemaIndexChange {
1225
- name: string;
1226
- from: SchemaIndex;
1227
- to: SchemaIndex;
1228
- }
1229
- interface SchemaResolverChange {
1230
- name: string;
1231
- from: SchemaResolver;
1232
- to: SchemaResolver;
1233
- }
1234
- interface SchemaTriggerChange {
1235
- name: string;
1236
- from: SchemaTrigger;
1237
- to: SchemaTrigger;
1238
- }
1239
- interface SchemaTableDiff {
1240
- name: string;
1241
- partition?: {
1242
- from: string | null;
1243
- to: string | null;
1244
- } | null;
1245
- identifier?: {
1246
- from: SchemaIdentifier | null;
1247
- to: SchemaIdentifier | null;
1248
- } | null;
1249
- attributes?: {
1250
- added: SchemaAttribute[];
1251
- removed: string[];
1252
- changed: SchemaAttributeChange[];
1253
- };
1254
- indexes?: {
1255
- added: SchemaIndex[];
1256
- removed: string[];
1257
- changed: SchemaIndexChange[];
1258
- };
1259
- resolvers?: {
1260
- added: SchemaResolver[];
1261
- removed: string[];
1262
- changed: SchemaResolverChange[];
1263
- };
1264
- triggers?: {
1265
- added: SchemaTrigger[];
1266
- removed: string[];
1267
- changed: SchemaTriggerChange[];
1268
- };
1269
- }
1270
- interface SchemaDiff {
1271
- newTables: string[];
1272
- removedTables: string[];
1273
- changedTables: SchemaTableDiff[];
1274
- }
1275
-
1276
- /** -------------------------
1277
- * Facade export
1278
- * --------------------------*/
1279
4
  declare const onyx: OnyxFacade;
1280
5
 
1281
- declare const asc: (field: string) => Sort;
1282
- declare const desc: (field: string) => Sort;
1283
-
1284
- /** Builder for combining query conditions with logical operators. */
1285
- declare class ConditionBuilderImpl implements IConditionBuilder {
1286
- private condition;
1287
- /**
1288
- * Initialize with an optional starting criteria.
1289
- *
1290
- * @param criteria Initial query criteria to seed the builder.
1291
- * @example
1292
- * ```ts
1293
- * const builder = new ConditionBuilderImpl({ field: 'id', operator: 'eq', value: '1' });
1294
- * ```
1295
- */
1296
- constructor(criteria?: QueryCriteria | null);
1297
- /**
1298
- * Add a criteria combined with AND.
1299
- *
1300
- * @param condition Another builder or raw criteria to AND.
1301
- * @example
1302
- * ```ts
1303
- * builder.and({ field: 'name', operator: 'eq', value: 'Ada' });
1304
- * ```
1305
- */
1306
- and(condition: IConditionBuilder | QueryCriteria): IConditionBuilder;
1307
- /**
1308
- * Add a criteria combined with OR.
1309
- *
1310
- * @param condition Another builder or raw criteria to OR.
1311
- * @example
1312
- * ```ts
1313
- * builder.or({ field: 'status', operator: 'eq', value: 'active' });
1314
- * ```
1315
- */
1316
- or(condition: IConditionBuilder | QueryCriteria): IConditionBuilder;
1317
- /**
1318
- * Produce the composed QueryCondition.
1319
- *
1320
- * @example
1321
- * ```ts
1322
- * const condition = builder.toCondition();
1323
- * ```
1324
- */
1325
- toCondition(): QueryCondition;
1326
- /**
1327
- * Wrap raw criteria into a single condition object.
1328
- *
1329
- * @param criteria Criteria to wrap.
1330
- * @example
1331
- * ```ts
1332
- * builder['single']({ field: 'id', operator: 'eq', value: '1' });
1333
- * ```
1334
- */
1335
- private single;
1336
- /**
1337
- * Create a compound condition using the provided operator.
1338
- *
1339
- * @param operator Logical operator to apply.
1340
- * @param conditions Child conditions to combine.
1341
- * @example
1342
- * ```ts
1343
- * builder['compound']('AND', [condA, condB]);
1344
- * ```
1345
- */
1346
- private compound;
1347
- /**
1348
- * Merge the next condition into the existing tree using the operator.
1349
- *
1350
- * @param operator Logical operator for the merge.
1351
- * @param next Condition to merge into the tree.
1352
- * @example
1353
- * ```ts
1354
- * builder['addCompound']('AND', someCondition);
1355
- * ```
1356
- */
1357
- private addCompound;
1358
- /**
1359
- * Normalize input into a QueryCondition instance.
1360
- *
1361
- * @param condition Builder or raw criteria to normalize.
1362
- * @example
1363
- * ```ts
1364
- * const qc = builder['prepare']({ field: 'id', operator: 'eq', value: '1' });
1365
- * ```
1366
- */
1367
- private prepare;
1368
- }
1369
-
1370
- declare const eq: (field: string, value: unknown) => ConditionBuilderImpl;
1371
- declare const neq: (field: string, value: unknown) => ConditionBuilderImpl;
1372
- declare function inOp(field: string, values: string): ConditionBuilderImpl;
1373
- declare function inOp<T>(field: string, values: unknown[] | IQueryBuilder<T>): ConditionBuilderImpl;
1374
- declare function within<T>(field: string, values: string | unknown[] | IQueryBuilder<T>): ConditionBuilderImpl;
1375
- declare function notIn(field: string, values: string): ConditionBuilderImpl;
1376
- declare function notIn<T>(field: string, values: unknown[] | IQueryBuilder<T>): ConditionBuilderImpl;
1377
- declare function notWithin<T>(field: string, values: string | unknown[] | IQueryBuilder<T>): ConditionBuilderImpl;
1378
- declare const between: (field: string, lower: unknown, upper: unknown) => ConditionBuilderImpl;
1379
- declare const gt: (field: string, value: unknown) => ConditionBuilderImpl;
1380
- declare const gte: (field: string, value: unknown) => ConditionBuilderImpl;
1381
- declare const lt: (field: string, value: unknown) => ConditionBuilderImpl;
1382
- declare const lte: (field: string, value: unknown) => ConditionBuilderImpl;
1383
- declare const matches: (field: string, regex: string) => ConditionBuilderImpl;
1384
- declare const notMatches: (field: string, regex: string) => ConditionBuilderImpl;
1385
- declare const like: (field: string, pattern: string) => ConditionBuilderImpl;
1386
- declare const notLike: (field: string, pattern: string) => ConditionBuilderImpl;
1387
- declare const contains: (field: string, value: unknown) => ConditionBuilderImpl;
1388
- declare const containsIgnoreCase: (field: string, value: unknown) => ConditionBuilderImpl;
1389
- declare const notContains: (field: string, value: unknown) => ConditionBuilderImpl;
1390
- declare const notContainsIgnoreCase: (field: string, value: unknown) => ConditionBuilderImpl;
1391
- declare const startsWith: (field: string, prefix: string) => ConditionBuilderImpl;
1392
- declare const notStartsWith: (field: string, prefix: string) => ConditionBuilderImpl;
1393
- declare const isNull: (field: string) => ConditionBuilderImpl;
1394
- declare const notNull: (field: string) => ConditionBuilderImpl;
1395
-
1396
- declare const avg: (attribute: string) => string;
1397
- declare const sum: (attribute: string) => string;
1398
- declare const count: (attribute: string) => string;
1399
- declare const min: (attribute: string) => string;
1400
- declare const max: (attribute: string) => string;
1401
- declare const std: (attribute: string) => string;
1402
- declare const variance: (attribute: string) => string;
1403
- declare const median: (attribute: string) => string;
1404
- declare const upper: (attribute: string) => string;
1405
- declare const lower: (attribute: string) => string;
1406
- declare const substring: (attribute: string, from: number, length: number) => string;
1407
- declare const replace: (attribute: string, pattern: string, repl: string) => string;
1408
- declare const percentile: (attribute: string, p: number) => string;
1409
-
1410
6
  declare const sdkName = "@onyx.dev/onyx-database";
1411
7
  declare const sdkVersion = "0.1.0";
1412
8
 
1413
- export { type FetchImpl, type FetchResponse, type ICascadeBuilder, type ICascadeRelationshipBuilder, type IConditionBuilder, type IOnyxDatabase, type IQueryBuilder, type ISaveBuilder, type LogicalOperator, type OnyxConfig, type OnyxDocument, type OnyxFacade, type QueryCondition, type QueryCriteria, type QueryCriteriaOperator, type QueryPage, QueryResults, type QueryResultsPromise, type SchemaAttribute, type SchemaAttributeChange, type SchemaDataType, type SchemaDiff, type SchemaEntity, type SchemaHistoryEntry, type SchemaIdentifier, type SchemaIdentifierGenerator, type SchemaIndex, type SchemaIndexChange, type SchemaIndexType, type SchemaResolver, type SchemaResolverChange, type SchemaRevision, type SchemaRevisionMetadata, type SchemaTableDiff, type SchemaTrigger, type SchemaTriggerChange, type SchemaTriggerEvent, type SchemaUpsertRequest, type SchemaValidationResult, type SecretMetadata, type SecretRecord, type SecretSaveRequest, type SecretsListResponse, type SelectQuery, type Sort, type StreamAction, type UpdateQuery, asc, avg, between, contains, containsIgnoreCase, count, desc, eq, gt, gte, inOp, isNull, like, lower, lt, lte, matches, max, median, min, neq, notContains, notContainsIgnoreCase, notIn, notLike, notMatches, notNull, notStartsWith, notWithin, onyx, percentile, replace, sdkName, sdkVersion, startsWith, std, substring, sum, upper, variance, within };
9
+ export { OnyxFacade, onyx, sdkName, sdkVersion };