@onyx.dev/onyx-database 2.1.1 → 2.4.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.
- package/README.md +44 -1
- package/dist/{aggregates-BFOBBZkW.d.cts → aggregates-COLPYBfv.d.cts} +174 -2
- package/dist/{aggregates-BFOBBZkW.d.ts → aggregates-COLPYBfv.d.ts} +174 -2
- package/dist/edge.cjs +428 -7
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.d.cts +2 -2
- package/dist/edge.d.ts +2 -2
- package/dist/edge.js +428 -7
- package/dist/edge.js.map +1 -1
- package/dist/gen/cli/generate.cjs +427 -6
- package/dist/gen/cli/generate.cjs.map +1 -1
- package/dist/index.cjs +428 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +428 -7
- package/dist/index.js.map +1 -1
- package/dist/schema/cli/schema.cjs +427 -6
- package/dist/schema/cli/schema.cjs.map +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@ TypeScript client SDK for **Onyx Cloud Database** — a zero-dependency, strict-
|
|
|
19
19
|
- [Install](#install)
|
|
20
20
|
- [Initialize the client](#initialize-the-client)
|
|
21
21
|
- [Onyx AI (chat & models)](#onyx-ai-chat--models)
|
|
22
|
+
- [Published model predictions](#published-model-predictions)
|
|
22
23
|
- [Generate schema types](#optional-generate-typescript-types-from-your-schema)
|
|
23
24
|
- [Query helpers](#query-helpers-at-a-glance)
|
|
24
25
|
- [Full-text search](#full-text-search-lucene)
|
|
@@ -317,6 +318,31 @@ if (approval.requiresApproval) {
|
|
|
317
318
|
|
|
318
319
|
---
|
|
319
320
|
|
|
321
|
+
## Published model predictions
|
|
322
|
+
|
|
323
|
+
Use a published model key with raw input rows, or let a saved script provide the
|
|
324
|
+
input rows for prediction.
|
|
325
|
+
|
|
326
|
+
```ts
|
|
327
|
+
const rawPrediction = await db.predict('churn-model', [
|
|
328
|
+
{ age: 42, country: 'US', usageScore: 0.87 },
|
|
329
|
+
{ age: 31, country: 'CA', usageScore: 0.42 },
|
|
330
|
+
]);
|
|
331
|
+
|
|
332
|
+
console.log(rawPrediction.predictions);
|
|
333
|
+
console.log(rawPrediction.rawPredictions);
|
|
334
|
+
|
|
335
|
+
const scriptPrediction = await db.predictFromScript(
|
|
336
|
+
'churn-model',
|
|
337
|
+
'score-active-users',
|
|
338
|
+
{ segment: 'enterprise' },
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
console.log(scriptPrediction.inputCount);
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
320
346
|
## Optional: generate TypeScript types from your schema
|
|
321
347
|
|
|
322
348
|
Use the **Onyx CLI** (`onyx`) from <https://github.com/OnyxDevTools/onyx-cli> to
|
|
@@ -697,6 +723,22 @@ const maybeUser = await db
|
|
|
697
723
|
.firstOrNull(); // or .one()
|
|
698
724
|
```
|
|
699
725
|
|
|
726
|
+
### 1c) Terminal formatters
|
|
727
|
+
|
|
728
|
+
```ts
|
|
729
|
+
const table = await db.from('User').select('id', 'email').table();
|
|
730
|
+
const tree = await db.from('User').select('id', 'email').tree({ rootLabel: 'users' });
|
|
731
|
+
const csv = await db.from('User').select('id', 'email').csv({ headers: false });
|
|
732
|
+
const json = await db.from('User').select('id', 'email').json();
|
|
733
|
+
|
|
734
|
+
console.log(table);
|
|
735
|
+
console.log(tree);
|
|
736
|
+
console.log(csv);
|
|
737
|
+
console.log(json);
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
`table()` renders readable box-drawing output, `tree()` expands nested objects hierarchically, `csv()` flattens nested objects with dot notation by default, and `json()` preserves the original nested structure.
|
|
741
|
+
|
|
700
742
|
### 2) Save (create/update)
|
|
701
743
|
|
|
702
744
|
```ts
|
|
@@ -991,7 +1033,8 @@ This repository uses [Changesets](https://github.com/changesets/changesets) for
|
|
|
991
1033
|
|
|
992
1034
|
1. Run `npm run changeset` to create a changeset entry.
|
|
993
1035
|
2. Push to `main` and the **Release** workflow opens a version PR.
|
|
994
|
-
3.
|
|
1036
|
+
3. Push the version commit and create a `v*` tag to trigger the publish job.
|
|
1037
|
+
4. The publish job uses npm trusted publishing from GitHub Actions (OIDC), so npm must be configured with a trusted publisher for `OnyxDevTools/onyx-database` and the `Release` workflow file.
|
|
995
1038
|
|
|
996
1039
|
---
|
|
997
1040
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var name = "@onyx.dev/onyx-database";
|
|
2
|
-
var version = "2.
|
|
2
|
+
var version = "2.4.1";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Supported operators for building query criteria.
|
|
@@ -420,6 +420,98 @@ declare class QueryResults<T> extends Array<T> {
|
|
|
420
420
|
forEachPageParallel(action: (item: T) => void | Promise<void>): Promise<void>;
|
|
421
421
|
}
|
|
422
422
|
|
|
423
|
+
interface TableFormatOptions {
|
|
424
|
+
/**
|
|
425
|
+
* Whether to render a header row. Defaults to `true`.
|
|
426
|
+
*/
|
|
427
|
+
headers?: boolean;
|
|
428
|
+
/**
|
|
429
|
+
* Maximum width for each rendered column. Defaults to `80`.
|
|
430
|
+
*/
|
|
431
|
+
maxColumnWidth?: number;
|
|
432
|
+
/**
|
|
433
|
+
* When true, nested objects expand into additional dot-notated columns.
|
|
434
|
+
* Defaults to `false`.
|
|
435
|
+
*/
|
|
436
|
+
flattenNestedObjects?: boolean;
|
|
437
|
+
/**
|
|
438
|
+
* Separator used when flattening nested object keys. Defaults to `.`.
|
|
439
|
+
*/
|
|
440
|
+
nestedSeparator?: string;
|
|
441
|
+
/**
|
|
442
|
+
* Display value used for `null` and `undefined`. Defaults to an empty string.
|
|
443
|
+
*/
|
|
444
|
+
nullValue?: string;
|
|
445
|
+
}
|
|
446
|
+
interface TreeFormatOptions {
|
|
447
|
+
/**
|
|
448
|
+
* Label used for the root node when `includeRoot` is true. Defaults to `results`.
|
|
449
|
+
*/
|
|
450
|
+
rootLabel?: string;
|
|
451
|
+
/**
|
|
452
|
+
* Field whose value should label each record node.
|
|
453
|
+
*/
|
|
454
|
+
keyField?: string;
|
|
455
|
+
/**
|
|
456
|
+
* Whether to include a root node. Defaults to `true`.
|
|
457
|
+
*/
|
|
458
|
+
includeRoot?: boolean;
|
|
459
|
+
/**
|
|
460
|
+
* Maximum nesting depth to expand before rendering remaining values inline.
|
|
461
|
+
* Defaults to `Infinity`.
|
|
462
|
+
*/
|
|
463
|
+
maxDepth?: number;
|
|
464
|
+
/**
|
|
465
|
+
* Display value used for `null` and `undefined`. Defaults to an empty string.
|
|
466
|
+
*/
|
|
467
|
+
nullValue?: string;
|
|
468
|
+
}
|
|
469
|
+
interface CsvFormatOptions {
|
|
470
|
+
/**
|
|
471
|
+
* Whether to render a header row. Defaults to `true`.
|
|
472
|
+
*/
|
|
473
|
+
headers?: boolean;
|
|
474
|
+
/**
|
|
475
|
+
* Field delimiter. Defaults to `,`.
|
|
476
|
+
*/
|
|
477
|
+
delimiter?: string;
|
|
478
|
+
/**
|
|
479
|
+
* Quote character. Defaults to `"`.
|
|
480
|
+
*/
|
|
481
|
+
quote?: string;
|
|
482
|
+
/**
|
|
483
|
+
* Escape character used to escape embedded quotes. Defaults to `"`.
|
|
484
|
+
*/
|
|
485
|
+
escape?: string;
|
|
486
|
+
/**
|
|
487
|
+
* Line ending. Defaults to `\n`.
|
|
488
|
+
*/
|
|
489
|
+
newline?: '\n' | '\r\n';
|
|
490
|
+
/**
|
|
491
|
+
* When true, nested objects expand into additional dot-notated columns.
|
|
492
|
+
* Defaults to `true`.
|
|
493
|
+
*/
|
|
494
|
+
flattenNestedObjects?: boolean;
|
|
495
|
+
/**
|
|
496
|
+
* Separator used when flattening nested object keys. Defaults to `.`.
|
|
497
|
+
*/
|
|
498
|
+
nestedSeparator?: string;
|
|
499
|
+
/**
|
|
500
|
+
* Display value used for `null` and `undefined`. Defaults to an empty string.
|
|
501
|
+
*/
|
|
502
|
+
nullValue?: string;
|
|
503
|
+
}
|
|
504
|
+
interface JsonFormatOptions {
|
|
505
|
+
/**
|
|
506
|
+
* Whether to pretty-print the JSON output. Defaults to `true`.
|
|
507
|
+
*/
|
|
508
|
+
pretty?: boolean;
|
|
509
|
+
/**
|
|
510
|
+
* Indentation size used when `pretty` is true. Defaults to `2`.
|
|
511
|
+
*/
|
|
512
|
+
indent?: number;
|
|
513
|
+
}
|
|
514
|
+
|
|
423
515
|
/**
|
|
424
516
|
* Builder used to compose query conditions.
|
|
425
517
|
*/
|
|
@@ -618,6 +710,42 @@ interface IQueryBuilder<T = unknown> {
|
|
|
618
710
|
records: T[];
|
|
619
711
|
nextPage?: string | null;
|
|
620
712
|
}>;
|
|
713
|
+
/**
|
|
714
|
+
* Executes the query and renders all matching results as a table string.
|
|
715
|
+
* @example
|
|
716
|
+
* ```ts
|
|
717
|
+
* const output = await db.from('User').select('id', 'email').table();
|
|
718
|
+
* console.log(output);
|
|
719
|
+
* ```
|
|
720
|
+
*/
|
|
721
|
+
table(options?: TableFormatOptions): Promise<string>;
|
|
722
|
+
/**
|
|
723
|
+
* Executes the query and renders all matching results as a tree string.
|
|
724
|
+
* @example
|
|
725
|
+
* ```ts
|
|
726
|
+
* const output = await db.from('User').select('id', 'email').tree();
|
|
727
|
+
* console.log(output);
|
|
728
|
+
* ```
|
|
729
|
+
*/
|
|
730
|
+
tree(options?: TreeFormatOptions): Promise<string>;
|
|
731
|
+
/**
|
|
732
|
+
* Executes the query and renders all matching results as CSV.
|
|
733
|
+
* @example
|
|
734
|
+
* ```ts
|
|
735
|
+
* const output = await db.from('User').select('id', 'email').csv();
|
|
736
|
+
* console.log(output);
|
|
737
|
+
* ```
|
|
738
|
+
*/
|
|
739
|
+
csv(options?: CsvFormatOptions): Promise<string>;
|
|
740
|
+
/**
|
|
741
|
+
* Executes the query and renders all matching results as JSON.
|
|
742
|
+
* @example
|
|
743
|
+
* ```ts
|
|
744
|
+
* const output = await db.from('User').select('id', 'email').json();
|
|
745
|
+
* console.log(output);
|
|
746
|
+
* ```
|
|
747
|
+
*/
|
|
748
|
+
json(options?: JsonFormatOptions): Promise<string>;
|
|
621
749
|
/**
|
|
622
750
|
* Sets field updates for an update query.
|
|
623
751
|
* @example
|
|
@@ -997,6 +1125,25 @@ interface AiErrorResponse {
|
|
|
997
1125
|
[key: string]: unknown;
|
|
998
1126
|
} | null;
|
|
999
1127
|
}
|
|
1128
|
+
type PublishedModelPredictionInput = Record<string, unknown>;
|
|
1129
|
+
type PublishedModelPredictionInputs = PublishedModelPredictionInput | PublishedModelPredictionInput[];
|
|
1130
|
+
interface PublishedModelRawPredictionRequest {
|
|
1131
|
+
inputs: PublishedModelPredictionInputs;
|
|
1132
|
+
}
|
|
1133
|
+
interface PublishedModelScriptPredictionRequest {
|
|
1134
|
+
scriptId: string;
|
|
1135
|
+
scriptParameters?: Record<string, string>;
|
|
1136
|
+
}
|
|
1137
|
+
interface PublishedModelPredictionResponse {
|
|
1138
|
+
publishedModelId: string;
|
|
1139
|
+
modelId: string;
|
|
1140
|
+
inputCount: number;
|
|
1141
|
+
inputs: PublishedModelPredictionInput[];
|
|
1142
|
+
predictions: PublishedModelPredictionInput[];
|
|
1143
|
+
rawPredictions: number[][];
|
|
1144
|
+
scriptId?: string | null;
|
|
1145
|
+
scriptParameters: Record<string, string>;
|
|
1146
|
+
}
|
|
1000
1147
|
interface AiClient {
|
|
1001
1148
|
/**
|
|
1002
1149
|
* Run a chat completion. Accepts shorthand strings or full requests.
|
|
@@ -1151,6 +1298,31 @@ interface IOnyxDatabase<Schema = Record<string, unknown>> {
|
|
|
1151
1298
|
* ```
|
|
1152
1299
|
*/
|
|
1153
1300
|
requestScriptApproval(input: AiScriptApprovalRequest): Promise<AiScriptApprovalResponse>;
|
|
1301
|
+
/**
|
|
1302
|
+
* Predict with a published model using raw input data.
|
|
1303
|
+
*
|
|
1304
|
+
* @example
|
|
1305
|
+
* ```ts
|
|
1306
|
+
* const prediction = await db.predict('churn-model', {
|
|
1307
|
+
* age: 42,
|
|
1308
|
+
* country: 'US'
|
|
1309
|
+
* });
|
|
1310
|
+
* ```
|
|
1311
|
+
*/
|
|
1312
|
+
predict(publishedModelId: string, inputs: PublishedModelPredictionInputs): Promise<PublishedModelPredictionResponse>;
|
|
1313
|
+
/**
|
|
1314
|
+
* Predict with a published model using rows returned from a saved script.
|
|
1315
|
+
*
|
|
1316
|
+
* @example
|
|
1317
|
+
* ```ts
|
|
1318
|
+
* const prediction = await db.predictFromScript(
|
|
1319
|
+
* 'churn-model',
|
|
1320
|
+
* 'score-active-users',
|
|
1321
|
+
* { segment: 'enterprise' }
|
|
1322
|
+
* );
|
|
1323
|
+
* ```
|
|
1324
|
+
*/
|
|
1325
|
+
predictFromScript(publishedModelId: string, scriptId: string, scriptParameters?: Record<string, string>): Promise<PublishedModelPredictionResponse>;
|
|
1154
1326
|
/**
|
|
1155
1327
|
* Begin a query against a table.
|
|
1156
1328
|
*
|
|
@@ -1761,4 +1933,4 @@ declare const replace: (attribute: string, pattern: string, repl: string) => str
|
|
|
1761
1933
|
declare const format: (attribute: string, formatter: string) => string;
|
|
1762
1934
|
declare const percentile: (attribute: string, p: number) => string;
|
|
1763
1935
|
|
|
1764
|
-
export { type
|
|
1936
|
+
export { type SchemaDataType as $, type AiChatClient as A, type IConditionBuilder as B, type CsvFormatOptions as C, type IOnyxDatabase as D, type IQueryBuilder as E, type FetchImpl as F, type ISaveBuilder as G, type OnyxConfig as H, type ICascadeBuilder as I, type JsonFormatOptions as J, type OnyxDocument as K, type LogicalOperator as L, type PublishedModelPredictionInputs as M, type PublishedModelPredictionResponse as N, type OnyxFacade as O, type PublishedModelPredictionInput as P, type PublishedModelRawPredictionRequest as Q, type PublishedModelScriptPredictionRequest as R, type QueryCondition as S, type QueryCriteria as T, type QueryCriteriaOperator as U, type QueryPage as V, QueryResults as W, type QueryResultsPromise as X, type RetryOptions as Y, type SchemaAttribute as Z, type SchemaAttributeChange as _, type AiChatCompletionChoice as a, startsWith as a$, type SchemaDiff as a0, type SchemaEntity as a1, type SchemaHistoryEntry as a2, type SchemaIdentifier as a3, type SchemaIdentifierGenerator as a4, type SchemaIndex as a5, type SchemaIndexChange as a6, type SchemaIndexType as a7, type SchemaResolver as a8, type SchemaResolverChange as a9, format as aA, gt as aB, gte as aC, inOp as aD, isNull as aE, like as aF, lower as aG, lt as aH, lte as aI, matches as aJ, max as aK, median as aL, min as aM, neq as aN, notContains as aO, notContainsIgnoreCase as aP, notIn as aQ, notLike as aR, notMatches as aS, notNull as aT, notStartsWith as aU, notWithin as aV, percentile as aW, replace as aX, name as aY, version as aZ, search as a_, type SchemaRevision as aa, type SchemaRevisionMetadata as ab, type SchemaTableDiff as ac, type SchemaTrigger as ad, type SchemaTriggerChange as ae, type SchemaTriggerEvent as af, type SchemaUpsertRequest as ag, type SchemaValidationResult as ah, type SecretMetadata as ai, type SecretRecord as aj, type SecretSaveRequest as ak, type SecretsListResponse as al, type SelectQuery as am, type Sort as an, type StreamAction as ao, type TableFormatOptions as ap, type TreeFormatOptions as aq, type UpdateQuery as ar, asc as as, avg as at, between as au, contains as av, containsIgnoreCase as aw, count as ax, desc as ay, eq as az, type AiChatCompletionChunk as b, std as b0, substring as b1, sum as b2, upper as b3, variance as b4, within as b5, type AiChatCompletionChunkChoice as c, type AiChatCompletionChunkDelta as d, type AiChatCompletionRequest as e, type AiChatCompletionResponse as f, type AiChatCompletionStream as g, type AiChatCompletionUsage as h, type AiChatMessage as i, type AiChatOptions as j, type AiChatRole as k, type AiClient as l, type AiErrorResponse as m, type AiModel as n, type AiModelsResponse as o, type AiRequestOptions as p, type AiScriptApprovalRequest as q, type AiScriptApprovalResponse as r, type AiTool as s, type AiToolCall as t, type AiToolCallFunction as u, type AiToolChoice as v, type AiToolFunction as w, type FetchResponse as x, type FullTextQuery as y, type ICascadeRelationshipBuilder as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var name = "@onyx.dev/onyx-database";
|
|
2
|
-
var version = "2.
|
|
2
|
+
var version = "2.4.1";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Supported operators for building query criteria.
|
|
@@ -420,6 +420,98 @@ declare class QueryResults<T> extends Array<T> {
|
|
|
420
420
|
forEachPageParallel(action: (item: T) => void | Promise<void>): Promise<void>;
|
|
421
421
|
}
|
|
422
422
|
|
|
423
|
+
interface TableFormatOptions {
|
|
424
|
+
/**
|
|
425
|
+
* Whether to render a header row. Defaults to `true`.
|
|
426
|
+
*/
|
|
427
|
+
headers?: boolean;
|
|
428
|
+
/**
|
|
429
|
+
* Maximum width for each rendered column. Defaults to `80`.
|
|
430
|
+
*/
|
|
431
|
+
maxColumnWidth?: number;
|
|
432
|
+
/**
|
|
433
|
+
* When true, nested objects expand into additional dot-notated columns.
|
|
434
|
+
* Defaults to `false`.
|
|
435
|
+
*/
|
|
436
|
+
flattenNestedObjects?: boolean;
|
|
437
|
+
/**
|
|
438
|
+
* Separator used when flattening nested object keys. Defaults to `.`.
|
|
439
|
+
*/
|
|
440
|
+
nestedSeparator?: string;
|
|
441
|
+
/**
|
|
442
|
+
* Display value used for `null` and `undefined`. Defaults to an empty string.
|
|
443
|
+
*/
|
|
444
|
+
nullValue?: string;
|
|
445
|
+
}
|
|
446
|
+
interface TreeFormatOptions {
|
|
447
|
+
/**
|
|
448
|
+
* Label used for the root node when `includeRoot` is true. Defaults to `results`.
|
|
449
|
+
*/
|
|
450
|
+
rootLabel?: string;
|
|
451
|
+
/**
|
|
452
|
+
* Field whose value should label each record node.
|
|
453
|
+
*/
|
|
454
|
+
keyField?: string;
|
|
455
|
+
/**
|
|
456
|
+
* Whether to include a root node. Defaults to `true`.
|
|
457
|
+
*/
|
|
458
|
+
includeRoot?: boolean;
|
|
459
|
+
/**
|
|
460
|
+
* Maximum nesting depth to expand before rendering remaining values inline.
|
|
461
|
+
* Defaults to `Infinity`.
|
|
462
|
+
*/
|
|
463
|
+
maxDepth?: number;
|
|
464
|
+
/**
|
|
465
|
+
* Display value used for `null` and `undefined`. Defaults to an empty string.
|
|
466
|
+
*/
|
|
467
|
+
nullValue?: string;
|
|
468
|
+
}
|
|
469
|
+
interface CsvFormatOptions {
|
|
470
|
+
/**
|
|
471
|
+
* Whether to render a header row. Defaults to `true`.
|
|
472
|
+
*/
|
|
473
|
+
headers?: boolean;
|
|
474
|
+
/**
|
|
475
|
+
* Field delimiter. Defaults to `,`.
|
|
476
|
+
*/
|
|
477
|
+
delimiter?: string;
|
|
478
|
+
/**
|
|
479
|
+
* Quote character. Defaults to `"`.
|
|
480
|
+
*/
|
|
481
|
+
quote?: string;
|
|
482
|
+
/**
|
|
483
|
+
* Escape character used to escape embedded quotes. Defaults to `"`.
|
|
484
|
+
*/
|
|
485
|
+
escape?: string;
|
|
486
|
+
/**
|
|
487
|
+
* Line ending. Defaults to `\n`.
|
|
488
|
+
*/
|
|
489
|
+
newline?: '\n' | '\r\n';
|
|
490
|
+
/**
|
|
491
|
+
* When true, nested objects expand into additional dot-notated columns.
|
|
492
|
+
* Defaults to `true`.
|
|
493
|
+
*/
|
|
494
|
+
flattenNestedObjects?: boolean;
|
|
495
|
+
/**
|
|
496
|
+
* Separator used when flattening nested object keys. Defaults to `.`.
|
|
497
|
+
*/
|
|
498
|
+
nestedSeparator?: string;
|
|
499
|
+
/**
|
|
500
|
+
* Display value used for `null` and `undefined`. Defaults to an empty string.
|
|
501
|
+
*/
|
|
502
|
+
nullValue?: string;
|
|
503
|
+
}
|
|
504
|
+
interface JsonFormatOptions {
|
|
505
|
+
/**
|
|
506
|
+
* Whether to pretty-print the JSON output. Defaults to `true`.
|
|
507
|
+
*/
|
|
508
|
+
pretty?: boolean;
|
|
509
|
+
/**
|
|
510
|
+
* Indentation size used when `pretty` is true. Defaults to `2`.
|
|
511
|
+
*/
|
|
512
|
+
indent?: number;
|
|
513
|
+
}
|
|
514
|
+
|
|
423
515
|
/**
|
|
424
516
|
* Builder used to compose query conditions.
|
|
425
517
|
*/
|
|
@@ -618,6 +710,42 @@ interface IQueryBuilder<T = unknown> {
|
|
|
618
710
|
records: T[];
|
|
619
711
|
nextPage?: string | null;
|
|
620
712
|
}>;
|
|
713
|
+
/**
|
|
714
|
+
* Executes the query and renders all matching results as a table string.
|
|
715
|
+
* @example
|
|
716
|
+
* ```ts
|
|
717
|
+
* const output = await db.from('User').select('id', 'email').table();
|
|
718
|
+
* console.log(output);
|
|
719
|
+
* ```
|
|
720
|
+
*/
|
|
721
|
+
table(options?: TableFormatOptions): Promise<string>;
|
|
722
|
+
/**
|
|
723
|
+
* Executes the query and renders all matching results as a tree string.
|
|
724
|
+
* @example
|
|
725
|
+
* ```ts
|
|
726
|
+
* const output = await db.from('User').select('id', 'email').tree();
|
|
727
|
+
* console.log(output);
|
|
728
|
+
* ```
|
|
729
|
+
*/
|
|
730
|
+
tree(options?: TreeFormatOptions): Promise<string>;
|
|
731
|
+
/**
|
|
732
|
+
* Executes the query and renders all matching results as CSV.
|
|
733
|
+
* @example
|
|
734
|
+
* ```ts
|
|
735
|
+
* const output = await db.from('User').select('id', 'email').csv();
|
|
736
|
+
* console.log(output);
|
|
737
|
+
* ```
|
|
738
|
+
*/
|
|
739
|
+
csv(options?: CsvFormatOptions): Promise<string>;
|
|
740
|
+
/**
|
|
741
|
+
* Executes the query and renders all matching results as JSON.
|
|
742
|
+
* @example
|
|
743
|
+
* ```ts
|
|
744
|
+
* const output = await db.from('User').select('id', 'email').json();
|
|
745
|
+
* console.log(output);
|
|
746
|
+
* ```
|
|
747
|
+
*/
|
|
748
|
+
json(options?: JsonFormatOptions): Promise<string>;
|
|
621
749
|
/**
|
|
622
750
|
* Sets field updates for an update query.
|
|
623
751
|
* @example
|
|
@@ -997,6 +1125,25 @@ interface AiErrorResponse {
|
|
|
997
1125
|
[key: string]: unknown;
|
|
998
1126
|
} | null;
|
|
999
1127
|
}
|
|
1128
|
+
type PublishedModelPredictionInput = Record<string, unknown>;
|
|
1129
|
+
type PublishedModelPredictionInputs = PublishedModelPredictionInput | PublishedModelPredictionInput[];
|
|
1130
|
+
interface PublishedModelRawPredictionRequest {
|
|
1131
|
+
inputs: PublishedModelPredictionInputs;
|
|
1132
|
+
}
|
|
1133
|
+
interface PublishedModelScriptPredictionRequest {
|
|
1134
|
+
scriptId: string;
|
|
1135
|
+
scriptParameters?: Record<string, string>;
|
|
1136
|
+
}
|
|
1137
|
+
interface PublishedModelPredictionResponse {
|
|
1138
|
+
publishedModelId: string;
|
|
1139
|
+
modelId: string;
|
|
1140
|
+
inputCount: number;
|
|
1141
|
+
inputs: PublishedModelPredictionInput[];
|
|
1142
|
+
predictions: PublishedModelPredictionInput[];
|
|
1143
|
+
rawPredictions: number[][];
|
|
1144
|
+
scriptId?: string | null;
|
|
1145
|
+
scriptParameters: Record<string, string>;
|
|
1146
|
+
}
|
|
1000
1147
|
interface AiClient {
|
|
1001
1148
|
/**
|
|
1002
1149
|
* Run a chat completion. Accepts shorthand strings or full requests.
|
|
@@ -1151,6 +1298,31 @@ interface IOnyxDatabase<Schema = Record<string, unknown>> {
|
|
|
1151
1298
|
* ```
|
|
1152
1299
|
*/
|
|
1153
1300
|
requestScriptApproval(input: AiScriptApprovalRequest): Promise<AiScriptApprovalResponse>;
|
|
1301
|
+
/**
|
|
1302
|
+
* Predict with a published model using raw input data.
|
|
1303
|
+
*
|
|
1304
|
+
* @example
|
|
1305
|
+
* ```ts
|
|
1306
|
+
* const prediction = await db.predict('churn-model', {
|
|
1307
|
+
* age: 42,
|
|
1308
|
+
* country: 'US'
|
|
1309
|
+
* });
|
|
1310
|
+
* ```
|
|
1311
|
+
*/
|
|
1312
|
+
predict(publishedModelId: string, inputs: PublishedModelPredictionInputs): Promise<PublishedModelPredictionResponse>;
|
|
1313
|
+
/**
|
|
1314
|
+
* Predict with a published model using rows returned from a saved script.
|
|
1315
|
+
*
|
|
1316
|
+
* @example
|
|
1317
|
+
* ```ts
|
|
1318
|
+
* const prediction = await db.predictFromScript(
|
|
1319
|
+
* 'churn-model',
|
|
1320
|
+
* 'score-active-users',
|
|
1321
|
+
* { segment: 'enterprise' }
|
|
1322
|
+
* );
|
|
1323
|
+
* ```
|
|
1324
|
+
*/
|
|
1325
|
+
predictFromScript(publishedModelId: string, scriptId: string, scriptParameters?: Record<string, string>): Promise<PublishedModelPredictionResponse>;
|
|
1154
1326
|
/**
|
|
1155
1327
|
* Begin a query against a table.
|
|
1156
1328
|
*
|
|
@@ -1761,4 +1933,4 @@ declare const replace: (attribute: string, pattern: string, repl: string) => str
|
|
|
1761
1933
|
declare const format: (attribute: string, formatter: string) => string;
|
|
1762
1934
|
declare const percentile: (attribute: string, p: number) => string;
|
|
1763
1935
|
|
|
1764
|
-
export { type
|
|
1936
|
+
export { type SchemaDataType as $, type AiChatClient as A, type IConditionBuilder as B, type CsvFormatOptions as C, type IOnyxDatabase as D, type IQueryBuilder as E, type FetchImpl as F, type ISaveBuilder as G, type OnyxConfig as H, type ICascadeBuilder as I, type JsonFormatOptions as J, type OnyxDocument as K, type LogicalOperator as L, type PublishedModelPredictionInputs as M, type PublishedModelPredictionResponse as N, type OnyxFacade as O, type PublishedModelPredictionInput as P, type PublishedModelRawPredictionRequest as Q, type PublishedModelScriptPredictionRequest as R, type QueryCondition as S, type QueryCriteria as T, type QueryCriteriaOperator as U, type QueryPage as V, QueryResults as W, type QueryResultsPromise as X, type RetryOptions as Y, type SchemaAttribute as Z, type SchemaAttributeChange as _, type AiChatCompletionChoice as a, startsWith as a$, type SchemaDiff as a0, type SchemaEntity as a1, type SchemaHistoryEntry as a2, type SchemaIdentifier as a3, type SchemaIdentifierGenerator as a4, type SchemaIndex as a5, type SchemaIndexChange as a6, type SchemaIndexType as a7, type SchemaResolver as a8, type SchemaResolverChange as a9, format as aA, gt as aB, gte as aC, inOp as aD, isNull as aE, like as aF, lower as aG, lt as aH, lte as aI, matches as aJ, max as aK, median as aL, min as aM, neq as aN, notContains as aO, notContainsIgnoreCase as aP, notIn as aQ, notLike as aR, notMatches as aS, notNull as aT, notStartsWith as aU, notWithin as aV, percentile as aW, replace as aX, name as aY, version as aZ, search as a_, type SchemaRevision as aa, type SchemaRevisionMetadata as ab, type SchemaTableDiff as ac, type SchemaTrigger as ad, type SchemaTriggerChange as ae, type SchemaTriggerEvent as af, type SchemaUpsertRequest as ag, type SchemaValidationResult as ah, type SecretMetadata as ai, type SecretRecord as aj, type SecretSaveRequest as ak, type SecretsListResponse as al, type SelectQuery as am, type Sort as an, type StreamAction as ao, type TableFormatOptions as ap, type TreeFormatOptions as aq, type UpdateQuery as ar, asc as as, avg as at, between as au, contains as av, containsIgnoreCase as aw, count as ax, desc as ay, eq as az, type AiChatCompletionChunk as b, std as b0, substring as b1, sum as b2, upper as b3, variance as b4, within as b5, type AiChatCompletionChunkChoice as c, type AiChatCompletionChunkDelta as d, type AiChatCompletionRequest as e, type AiChatCompletionResponse as f, type AiChatCompletionStream as g, type AiChatCompletionUsage as h, type AiChatMessage as i, type AiChatOptions as j, type AiChatRole as k, type AiClient as l, type AiErrorResponse as m, type AiModel as n, type AiModelsResponse as o, type AiRequestOptions as p, type AiScriptApprovalRequest as q, type AiScriptApprovalResponse as r, type AiTool as s, type AiToolCall as t, type AiToolCallFunction as u, type AiToolChoice as v, type AiToolFunction as w, type FetchResponse as x, type FullTextQuery as y, type ICascadeRelationshipBuilder as z };
|