@onyx.dev/onyx-database 2.0.0 → 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.
- package/README.md +58 -43
- package/dist/{aggregates-BJT5DGGX.d.cts → aggregates-BPpzRHGH.d.cts} +5 -1
- package/dist/{aggregates-BJT5DGGX.d.ts → aggregates-BPpzRHGH.d.ts} +5 -1
- package/dist/edge.cjs +41 -39
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.d.cts +3 -6
- package/dist/edge.d.ts +3 -6
- package/dist/edge.js +39 -38
- package/dist/edge.js.map +1 -1
- package/dist/index.cjs +41 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -6
- package/dist/index.d.ts +3 -6
- package/dist/index.js +39 -38
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,20 +63,16 @@ npm i @onyx.dev/onyx-database
|
|
|
63
63
|
|
|
64
64
|
The package is dual-module (ESM + CJS) and has **no runtime or peer dependencies**.
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
CLI tooling and schema codegen now live in the dedicated **Onyx CLI** repo:
|
|
67
|
+
<https://github.com/OnyxDevTools/onyx-cli>. Install it via the official install
|
|
68
|
+
script or Homebrew (macOS):
|
|
67
69
|
|
|
68
70
|
```bash
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
To install the CLI globally from this repo checkout (useful for local development and testing):
|
|
71
|
+
curl -fsSL https://raw.githubusercontent.com/OnyxDevTools/onyx-cli/main/scripts/install.sh | bash
|
|
73
72
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
npm run build
|
|
78
|
-
npm uninstall -g @onyx.dev/onyx-database # optional: clear older global versions
|
|
79
|
-
npm install -g . # installs the built onyx-schema and onyx-gen
|
|
73
|
+
# macOS (Homebrew)
|
|
74
|
+
brew tap OnyxDevTools/onyx-cli
|
|
75
|
+
brew install onyx-cli
|
|
80
76
|
```
|
|
81
77
|
|
|
82
78
|
---
|
|
@@ -295,15 +291,19 @@ if (approval.requiresApproval) {
|
|
|
295
291
|
|
|
296
292
|
## Optional: generate TypeScript types from your schema
|
|
297
293
|
|
|
298
|
-
|
|
294
|
+
Use the **Onyx CLI** (`onyx`) from <https://github.com/OnyxDevTools/onyx-cli> to
|
|
295
|
+
emit per-table interfaces, a `tables` enum, and a `Schema` mapping for
|
|
296
|
+
compile-time safety and IntelliSense. Each generated interface also includes an
|
|
297
|
+
index signature so extra properties (for graph attachments in cascade saves)
|
|
298
|
+
don't trigger type errors.
|
|
299
299
|
|
|
300
300
|
Generate directly from the API (using the same credential resolver as `init()`):
|
|
301
301
|
|
|
302
302
|
```bash
|
|
303
|
-
|
|
303
|
+
onyx gen --ts --source api --out ./src/onyx/types.ts --name OnyxSchema
|
|
304
304
|
```
|
|
305
305
|
|
|
306
|
-
With `--source api`, `onyx
|
|
306
|
+
With `--source api`, `onyx gen` calls the Schema API (same as `onyx schema get`) using the
|
|
307
307
|
standard config chain (env, project file, home profile).
|
|
308
308
|
|
|
309
309
|
Timestamp attributes are emitted as `Date` fields by default. When saving,
|
|
@@ -313,30 +313,30 @@ Timestamp attributes are emitted as `Date` fields by default. When saving,
|
|
|
313
313
|
Or from a local schema file you export from the console:
|
|
314
314
|
|
|
315
315
|
```bash
|
|
316
|
-
|
|
316
|
+
onyx gen --ts --source file --schema ./onyx.schema.json --out ./src/onyx/types.ts --name OnyxSchema
|
|
317
317
|
```
|
|
318
318
|
|
|
319
|
-
Run it with no flags to use the defaults: `onyx
|
|
319
|
+
Run it with no flags to use the defaults: `onyx gen` reads `./onyx.schema.json` and writes to `./onyx/types.ts`.
|
|
320
320
|
|
|
321
321
|
### Manage schemas from the CLI
|
|
322
322
|
|
|
323
|
-
Publish or download schema JSON directly via API using the `onyx
|
|
323
|
+
Publish or download schema JSON directly via API using the `onyx schema` helper:
|
|
324
324
|
|
|
325
325
|
```bash
|
|
326
326
|
# Publish ./onyx.schema.json with publish=true by default
|
|
327
|
-
onyx
|
|
327
|
+
onyx schema publish
|
|
328
328
|
|
|
329
329
|
# Overwrite ./onyx.schema.json with the remote schema
|
|
330
|
-
onyx
|
|
330
|
+
onyx schema get
|
|
331
331
|
|
|
332
332
|
# Print the remote schema without writing a file
|
|
333
|
-
onyx
|
|
333
|
+
onyx schema get --print
|
|
334
334
|
|
|
335
335
|
# Fetch only selected tables (prints to stdout; does not overwrite files)
|
|
336
|
-
onyx
|
|
336
|
+
onyx schema get --tables=User,Profile
|
|
337
337
|
|
|
338
338
|
# Example subset output
|
|
339
|
-
onyx
|
|
339
|
+
onyx schema get --tables=User,Profile
|
|
340
340
|
# {
|
|
341
341
|
# "tables": [
|
|
342
342
|
# {
|
|
@@ -357,10 +357,10 @@ onyx-schema get --tables=User,Profile
|
|
|
357
357
|
# }
|
|
358
358
|
|
|
359
359
|
# Validate a schema file without publishing
|
|
360
|
-
onyx
|
|
360
|
+
onyx schema validate ./onyx.schema.json
|
|
361
361
|
|
|
362
362
|
# Diff local schema vs API
|
|
363
|
-
onyx
|
|
363
|
+
onyx schema diff ./onyx.schema.json
|
|
364
364
|
# Prints YAML with added/removed/changed tables and attribute differences between the API schema and your local file.
|
|
365
365
|
```
|
|
366
366
|
|
|
@@ -391,7 +391,7 @@ console.log(diff.changedTables);
|
|
|
391
391
|
You can also emit to multiple paths in one run (comma-separated or by repeating `--out`):
|
|
392
392
|
|
|
393
393
|
```bash
|
|
394
|
-
onyx
|
|
394
|
+
onyx gen --ts --out ./src/onyx/types.ts,./apps/admin/src/onyx/types.ts
|
|
395
395
|
```
|
|
396
396
|
|
|
397
397
|
Use in code:
|
|
@@ -411,12 +411,12 @@ const User = await db
|
|
|
411
411
|
```
|
|
412
412
|
|
|
413
413
|
For a schema with `User`, `UserProfile`, `Role`, and `Permission` tables,
|
|
414
|
-
`onyx
|
|
414
|
+
`onyx gen` emits plain interfaces keyed by IDs. Each interface includes an
|
|
415
415
|
index signature so resolver-attached fields or embedded objects remain
|
|
416
416
|
type-safe:
|
|
417
417
|
|
|
418
418
|
```ts
|
|
419
|
-
// AUTO-GENERATED BY onyx
|
|
419
|
+
// AUTO-GENERATED BY onyx gen. DO NOT EDIT.
|
|
420
420
|
export interface User {
|
|
421
421
|
id?: string;
|
|
422
422
|
name: string;
|
|
@@ -535,6 +535,26 @@ import {
|
|
|
535
535
|
- `inOp`/`notIn` remain available for backward compatibility and are exact aliases.
|
|
536
536
|
- `search(text, minScore?)` builds a Lucene `MATCHES` predicate on `__full_text__` and always serializes `minScore` (null when omitted).
|
|
537
537
|
|
|
538
|
+
### Aggregate helpers
|
|
539
|
+
|
|
540
|
+
```ts
|
|
541
|
+
import {
|
|
542
|
+
avg, sum, count, min, max,
|
|
543
|
+
std, variance, median,
|
|
544
|
+
upper, lower,
|
|
545
|
+
substring, replace, percentile,
|
|
546
|
+
format
|
|
547
|
+
} from '@onyx.dev/onyx-database';
|
|
548
|
+
|
|
549
|
+
const rows = await db
|
|
550
|
+
.select(format('createdAt', 'yyyy-MM-dd'))
|
|
551
|
+
.from('User')
|
|
552
|
+
.list();
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
- `format(field, formatter)` uses Java-style format strings for dates and numbers.
|
|
556
|
+
- Example: `examples/query/format.ts`
|
|
557
|
+
|
|
538
558
|
### Inner queries (IN/NOT IN with sub-selects)
|
|
539
559
|
|
|
540
560
|
You can pass another query builder to `within` or `notWithin` to create nested filters. The SDK serializes the inner query (including its table) before sending the request.
|
|
@@ -889,36 +909,31 @@ const db = onyx.init({
|
|
|
889
909
|
+----------------------+-----------------------------------------------+--------------------------------------------------------------+
|
|
890
910
|
| Command | Flags | Defaults / notes |
|
|
891
911
|
+----------------------+-----------------------------------------------+--------------------------------------------------------------+
|
|
892
|
-
| onyx
|
|
893
|
-
| | --
|
|
894
|
-
| | --
|
|
895
|
-
| | --
|
|
896
|
-
| | --
|
|
897
|
-
| | --
|
|
898
|
-
| | --prefix <Prefix> | |
|
|
899
|
-
| | --optional non-null|nullable|none | |
|
|
900
|
-
| | --emit-json / --no-emit-json | |
|
|
901
|
-
| | --json-out <dir> | |
|
|
902
|
-
| | --api-path <path> (repeatable) | |
|
|
912
|
+
| onyx gen | --ts/--typescript | Default: --source file; --schema ./onyx.schema.json; |
|
|
913
|
+
| | --source auto|api|file | --out ./onyx/types.ts (file or dir; repeatable); |
|
|
914
|
+
| | --schema <path> | schema type name: OnyxSchema; timestamps default: date. |
|
|
915
|
+
| | --out <dir|file> | Use --overwrite to force output; quiet=false. |
|
|
916
|
+
| | --name <T> | |
|
|
917
|
+
| | --timestamps string|date|number | |
|
|
903
918
|
| | --overwrite / --no-overwrite | |
|
|
904
919
|
| | -q / --quiet | |
|
|
905
920
|
| | -h / --help | |
|
|
906
921
|
+----------------------+-----------------------------------------------+--------------------------------------------------------------+
|
|
907
|
-
| onyx
|
|
922
|
+
| onyx schema get | [file] (positional) | Default file: ./onyx.schema.json; writes file unless |
|
|
908
923
|
| | --tables a,b | --tables or --print (then prints to stdout). |
|
|
909
924
|
| | --print | |
|
|
910
925
|
| | -h / --help | |
|
|
911
926
|
+----------------------+-----------------------------------------------+--------------------------------------------------------------+
|
|
912
|
-
| onyx
|
|
927
|
+
| onyx schema publish | [file] (positional) | Default file: ./onyx.schema.json; validates before publishing; |
|
|
913
928
|
| | -h / --help | uses onyx.init credential resolver. |
|
|
914
929
|
+----------------------+-----------------------------------------------+--------------------------------------------------------------+
|
|
915
|
-
| onyx
|
|
930
|
+
| onyx schema validate | [file] (positional) | Default file: ./onyx.schema.json; exits non-zero on errors. |
|
|
916
931
|
| | -h / --help | |
|
|
917
932
|
+----------------------+-----------------------------------------------+--------------------------------------------------------------+
|
|
918
|
-
| onyx
|
|
933
|
+
| onyx schema diff | [file] (positional) | Default file: ./onyx.schema.json; prints YAML diff vs API. |
|
|
919
934
|
| | -h / --help | |
|
|
920
935
|
+----------------------+-----------------------------------------------+--------------------------------------------------------------+
|
|
921
|
-
| onyx
|
|
936
|
+
| onyx schema info | -h / --help | Shows resolved config sources, config path, connection check.|
|
|
922
937
|
+----------------------+-----------------------------------------------+--------------------------------------------------------------+
|
|
923
938
|
```
|
|
924
939
|
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
var name = "@onyx.dev/onyx-database";
|
|
2
|
+
var version = "2.0.1";
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Supported operators for building query criteria.
|
|
3
6
|
*
|
|
@@ -1755,6 +1758,7 @@ declare const upper: (attribute: string) => string;
|
|
|
1755
1758
|
declare const lower: (attribute: string) => string;
|
|
1756
1759
|
declare const substring: (attribute: string, from: number, length: number) => string;
|
|
1757
1760
|
declare const replace: (attribute: string, pattern: string, repl: string) => string;
|
|
1761
|
+
declare const format: (attribute: string, formatter: string) => string;
|
|
1758
1762
|
declare const percentile: (attribute: string, p: number) => string;
|
|
1759
1763
|
|
|
1760
|
-
export { type
|
|
1764
|
+
export { type SchemaIndexChange as $, type AiRequestOptions as A, type AiClient as B, type SecretRecord as C, type SecretsListResponse as D, type SecretSaveRequest as E, type FullTextQuery as F, type SchemaDataType as G, type SchemaIdentifierGenerator as H, type IOnyxDatabase as I, type SchemaIdentifier as J, type SchemaAttribute as K, type SchemaIndexType as L, type SchemaIndex as M, type SchemaResolver as N, type OnyxFacade as O, type SchemaTriggerEvent as P, QueryResults as Q, type RetryOptions as R, type SecretMetadata as S, type SchemaTrigger as T, type SchemaEntity as U, type SchemaRevisionMetadata as V, type SchemaRevision as W, type SchemaHistoryEntry as X, type SchemaUpsertRequest as Y, type SchemaValidationResult as Z, type SchemaAttributeChange as _, type QueryResultsPromise as a, type SchemaResolverChange as a0, type SchemaTriggerChange as a1, type SchemaTableDiff as a2, type SchemaDiff as a3, type QueryCriteriaOperator as a4, type LogicalOperator as a5, type Sort as a6, type StreamAction as a7, type OnyxDocument as a8, type FetchResponse as a9, notMatches as aA, like as aB, notLike as aC, contains as aD, containsIgnoreCase as aE, notContains as aF, notContainsIgnoreCase as aG, startsWith as aH, notStartsWith as aI, isNull as aJ, notNull as aK, avg as aL, sum as aM, count as aN, min as aO, max as aP, std as aQ, variance as aR, median as aS, upper as aT, lower as aU, substring as aV, replace as aW, format as aX, percentile as aY, type FetchImpl as aa, type QueryCriteria as ab, type QueryCondition as ac, type SelectQuery as ad, type UpdateQuery as ae, type QueryPage as af, type IConditionBuilder as ag, type IQueryBuilder as ah, type ISaveBuilder as ai, type ICascadeBuilder as aj, type ICascadeRelationshipBuilder as ak, asc as al, desc as am, eq as an, neq as ao, inOp as ap, within as aq, notIn as ar, notWithin as as, between as at, gt as au, gte as av, lt as aw, lte as ax, matches as ay, search as az, type OnyxConfig as b, type AiChatRole as c, type AiToolCallFunction as d, type AiToolCall as e, type AiChatMessage as f, type AiToolFunction as g, type AiTool as h, type AiToolChoice as i, type AiChatCompletionRequest as j, type AiChatCompletionUsage as k, type AiChatCompletionChoice as l, type AiChatCompletionResponse as m, name as n, type AiChatCompletionChunkDelta as o, type AiChatCompletionChunkChoice as p, type AiChatCompletionChunk as q, type AiChatCompletionStream as r, type AiChatOptions as s, type AiChatClient as t, type AiScriptApprovalRequest as u, version as v, type AiScriptApprovalResponse as w, type AiModelsResponse as x, type AiModel as y, type AiErrorResponse as z };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
var name = "@onyx.dev/onyx-database";
|
|
2
|
+
var version = "2.0.1";
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Supported operators for building query criteria.
|
|
3
6
|
*
|
|
@@ -1755,6 +1758,7 @@ declare const upper: (attribute: string) => string;
|
|
|
1755
1758
|
declare const lower: (attribute: string) => string;
|
|
1756
1759
|
declare const substring: (attribute: string, from: number, length: number) => string;
|
|
1757
1760
|
declare const replace: (attribute: string, pattern: string, repl: string) => string;
|
|
1761
|
+
declare const format: (attribute: string, formatter: string) => string;
|
|
1758
1762
|
declare const percentile: (attribute: string, p: number) => string;
|
|
1759
1763
|
|
|
1760
|
-
export { type
|
|
1764
|
+
export { type SchemaIndexChange as $, type AiRequestOptions as A, type AiClient as B, type SecretRecord as C, type SecretsListResponse as D, type SecretSaveRequest as E, type FullTextQuery as F, type SchemaDataType as G, type SchemaIdentifierGenerator as H, type IOnyxDatabase as I, type SchemaIdentifier as J, type SchemaAttribute as K, type SchemaIndexType as L, type SchemaIndex as M, type SchemaResolver as N, type OnyxFacade as O, type SchemaTriggerEvent as P, QueryResults as Q, type RetryOptions as R, type SecretMetadata as S, type SchemaTrigger as T, type SchemaEntity as U, type SchemaRevisionMetadata as V, type SchemaRevision as W, type SchemaHistoryEntry as X, type SchemaUpsertRequest as Y, type SchemaValidationResult as Z, type SchemaAttributeChange as _, type QueryResultsPromise as a, type SchemaResolverChange as a0, type SchemaTriggerChange as a1, type SchemaTableDiff as a2, type SchemaDiff as a3, type QueryCriteriaOperator as a4, type LogicalOperator as a5, type Sort as a6, type StreamAction as a7, type OnyxDocument as a8, type FetchResponse as a9, notMatches as aA, like as aB, notLike as aC, contains as aD, containsIgnoreCase as aE, notContains as aF, notContainsIgnoreCase as aG, startsWith as aH, notStartsWith as aI, isNull as aJ, notNull as aK, avg as aL, sum as aM, count as aN, min as aO, max as aP, std as aQ, variance as aR, median as aS, upper as aT, lower as aU, substring as aV, replace as aW, format as aX, percentile as aY, type FetchImpl as aa, type QueryCriteria as ab, type QueryCondition as ac, type SelectQuery as ad, type UpdateQuery as ae, type QueryPage as af, type IConditionBuilder as ag, type IQueryBuilder as ah, type ISaveBuilder as ai, type ICascadeBuilder as aj, type ICascadeRelationshipBuilder as ak, asc as al, desc as am, eq as an, neq as ao, inOp as ap, within as aq, notIn as ar, notWithin as as, between as at, gt as au, gte as av, lt as aw, lte as ax, matches as ay, search as az, type OnyxConfig as b, type AiChatRole as c, type AiToolCallFunction as d, type AiToolCall as e, type AiChatMessage as f, type AiToolFunction as g, type AiTool as h, type AiToolChoice as i, type AiChatCompletionRequest as j, type AiChatCompletionUsage as k, type AiChatCompletionChoice as l, type AiChatCompletionResponse as m, name as n, type AiChatCompletionChunkDelta as o, type AiChatCompletionChunkChoice as p, type AiChatCompletionChunk as q, type AiChatCompletionStream as r, type AiChatOptions as s, type AiChatClient as t, type AiScriptApprovalRequest as u, version as v, type AiScriptApprovalResponse as w, type AiModelsResponse as x, type AiModel as y, type AiErrorResponse as z };
|
package/dist/edge.cjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// package.json
|
|
4
|
+
var name = "@onyx.dev/onyx-database";
|
|
5
|
+
var version = "2.0.1";
|
|
6
|
+
|
|
3
7
|
// src/config/defaults.ts
|
|
4
8
|
var DEFAULT_BASE_URL = "https://api.onyx.dev";
|
|
5
9
|
var DEFAULT_AI_BASE_URL = "https://ai.onyx.dev";
|
|
@@ -803,8 +807,8 @@ var CascadeRelationshipBuilder = class {
|
|
|
803
807
|
* builder.graph('programs');
|
|
804
808
|
* ```
|
|
805
809
|
*/
|
|
806
|
-
graph(
|
|
807
|
-
this.graphName =
|
|
810
|
+
graph(name2) {
|
|
811
|
+
this.graphName = name2;
|
|
808
812
|
return this;
|
|
809
813
|
}
|
|
810
814
|
/**
|
|
@@ -891,24 +895,24 @@ function diffAttributes(apiAttrs, localAttrs) {
|
|
|
891
895
|
const added = [];
|
|
892
896
|
const removed = [];
|
|
893
897
|
const changed = [];
|
|
894
|
-
for (const [
|
|
895
|
-
if (!apiMap.has(
|
|
898
|
+
for (const [name2, local] of localMap.entries()) {
|
|
899
|
+
if (!apiMap.has(name2)) {
|
|
896
900
|
added.push(local);
|
|
897
901
|
continue;
|
|
898
902
|
}
|
|
899
|
-
const api = apiMap.get(
|
|
903
|
+
const api = apiMap.get(name2);
|
|
900
904
|
const apiNull = Boolean(api.isNullable);
|
|
901
905
|
const localNull = Boolean(local.isNullable);
|
|
902
906
|
if (api.type !== local.type || apiNull !== localNull) {
|
|
903
907
|
changed.push({
|
|
904
|
-
name,
|
|
908
|
+
name: name2,
|
|
905
909
|
from: { type: api.type, isNullable: apiNull },
|
|
906
910
|
to: { type: local.type, isNullable: localNull }
|
|
907
911
|
});
|
|
908
912
|
}
|
|
909
913
|
}
|
|
910
|
-
for (const
|
|
911
|
-
if (!localMap.has(
|
|
914
|
+
for (const name2 of apiMap.keys()) {
|
|
915
|
+
if (!localMap.has(name2)) removed.push(name2);
|
|
912
916
|
}
|
|
913
917
|
added.sort((a, b) => a.name.localeCompare(b.name));
|
|
914
918
|
removed.sort();
|
|
@@ -922,22 +926,22 @@ function diffIndexes(apiIndexes, localIndexes) {
|
|
|
922
926
|
const added = [];
|
|
923
927
|
const removed = [];
|
|
924
928
|
const changed = [];
|
|
925
|
-
for (const [
|
|
926
|
-
if (!apiMap.has(
|
|
929
|
+
for (const [name2, local] of localMap.entries()) {
|
|
930
|
+
if (!apiMap.has(name2)) {
|
|
927
931
|
added.push(local);
|
|
928
932
|
continue;
|
|
929
933
|
}
|
|
930
|
-
const api = apiMap.get(
|
|
934
|
+
const api = apiMap.get(name2);
|
|
931
935
|
const apiType = api.type ?? "DEFAULT";
|
|
932
936
|
const localType = local.type ?? "DEFAULT";
|
|
933
937
|
const apiScore = api.minimumScore;
|
|
934
938
|
const localScore = local.minimumScore;
|
|
935
939
|
if (apiType !== localType || apiScore !== localScore) {
|
|
936
|
-
changed.push({ name, from: api, to: local });
|
|
940
|
+
changed.push({ name: name2, from: api, to: local });
|
|
937
941
|
}
|
|
938
942
|
}
|
|
939
|
-
for (const
|
|
940
|
-
if (!localMap.has(
|
|
943
|
+
for (const name2 of apiMap.keys()) {
|
|
944
|
+
if (!localMap.has(name2)) removed.push(name2);
|
|
941
945
|
}
|
|
942
946
|
added.sort((a, b) => a.name.localeCompare(b.name));
|
|
943
947
|
removed.sort();
|
|
@@ -951,18 +955,18 @@ function diffResolvers(apiResolvers, localResolvers) {
|
|
|
951
955
|
const added = [];
|
|
952
956
|
const removed = [];
|
|
953
957
|
const changed = [];
|
|
954
|
-
for (const [
|
|
955
|
-
if (!apiMap.has(
|
|
958
|
+
for (const [name2, local] of localMap.entries()) {
|
|
959
|
+
if (!apiMap.has(name2)) {
|
|
956
960
|
added.push(local);
|
|
957
961
|
continue;
|
|
958
962
|
}
|
|
959
|
-
const api = apiMap.get(
|
|
963
|
+
const api = apiMap.get(name2);
|
|
960
964
|
if (api.resolver !== local.resolver) {
|
|
961
|
-
changed.push({ name, from: api, to: local });
|
|
965
|
+
changed.push({ name: name2, from: api, to: local });
|
|
962
966
|
}
|
|
963
967
|
}
|
|
964
|
-
for (const
|
|
965
|
-
if (!localMap.has(
|
|
968
|
+
for (const name2 of apiMap.keys()) {
|
|
969
|
+
if (!localMap.has(name2)) removed.push(name2);
|
|
966
970
|
}
|
|
967
971
|
added.sort((a, b) => a.name.localeCompare(b.name));
|
|
968
972
|
removed.sort();
|
|
@@ -976,18 +980,18 @@ function diffTriggers(apiTriggers, localTriggers) {
|
|
|
976
980
|
const added = [];
|
|
977
981
|
const removed = [];
|
|
978
982
|
const changed = [];
|
|
979
|
-
for (const [
|
|
980
|
-
if (!apiMap.has(
|
|
983
|
+
for (const [name2, local] of localMap.entries()) {
|
|
984
|
+
if (!apiMap.has(name2)) {
|
|
981
985
|
added.push(local);
|
|
982
986
|
continue;
|
|
983
987
|
}
|
|
984
|
-
const api = apiMap.get(
|
|
988
|
+
const api = apiMap.get(name2);
|
|
985
989
|
if (api.event !== local.event || api.trigger !== local.trigger) {
|
|
986
|
-
changed.push({ name, from: api, to: local });
|
|
990
|
+
changed.push({ name: name2, from: api, to: local });
|
|
987
991
|
}
|
|
988
992
|
}
|
|
989
|
-
for (const
|
|
990
|
-
if (!localMap.has(
|
|
993
|
+
for (const name2 of apiMap.keys()) {
|
|
994
|
+
if (!localMap.has(name2)) removed.push(name2);
|
|
991
995
|
}
|
|
992
996
|
added.sort((a, b) => a.name.localeCompare(b.name));
|
|
993
997
|
removed.sort();
|
|
@@ -1003,13 +1007,13 @@ function computeSchemaDiff(apiSchema, localSchema) {
|
|
|
1003
1007
|
const newTables = [];
|
|
1004
1008
|
const removedTables = [];
|
|
1005
1009
|
const changedTables = [];
|
|
1006
|
-
for (const [
|
|
1007
|
-
if (!apiMap.has(
|
|
1008
|
-
newTables.push(
|
|
1010
|
+
for (const [name2, localEntity] of localMap.entries()) {
|
|
1011
|
+
if (!apiMap.has(name2)) {
|
|
1012
|
+
newTables.push(name2);
|
|
1009
1013
|
continue;
|
|
1010
1014
|
}
|
|
1011
|
-
const apiEntity = apiMap.get(
|
|
1012
|
-
const tableDiff = { name };
|
|
1015
|
+
const apiEntity = apiMap.get(name2);
|
|
1016
|
+
const tableDiff = { name: name2 };
|
|
1013
1017
|
const partitionFrom = normalizePartition(apiEntity.partition);
|
|
1014
1018
|
const partitionTo = normalizePartition(localEntity.partition);
|
|
1015
1019
|
if (partitionFrom !== partitionTo) {
|
|
@@ -1034,8 +1038,8 @@ function computeSchemaDiff(apiSchema, localSchema) {
|
|
|
1034
1038
|
changedTables.push(tableDiff);
|
|
1035
1039
|
}
|
|
1036
1040
|
}
|
|
1037
|
-
for (const
|
|
1038
|
-
if (!localMap.has(
|
|
1041
|
+
for (const name2 of apiMap.keys()) {
|
|
1042
|
+
if (!localMap.has(name2)) removedTables.push(name2);
|
|
1039
1043
|
}
|
|
1040
1044
|
newTables.sort();
|
|
1041
1045
|
removedTables.sort();
|
|
@@ -2179,12 +2183,9 @@ var upper = (attribute) => `upper(${attribute})`;
|
|
|
2179
2183
|
var lower = (attribute) => `lower(${attribute})`;
|
|
2180
2184
|
var substring = (attribute, from, length) => `substring(${attribute},${from},${length})`;
|
|
2181
2185
|
var replace = (attribute, pattern, repl) => `replace(${attribute}, '${pattern.replace(/'/g, "\\'")}', '${repl.replace(/'/g, "\\'")}')`;
|
|
2186
|
+
var format = (attribute, formatter) => `format(${attribute}, '${formatter.replace(/'/g, "\\'")}')`;
|
|
2182
2187
|
var percentile = (attribute, p) => `percentile(${attribute}, ${p})`;
|
|
2183
2188
|
|
|
2184
|
-
// src/edge.ts
|
|
2185
|
-
var sdkName = "@onyx.dev/onyx-database";
|
|
2186
|
-
var sdkVersion = "0.1.0";
|
|
2187
|
-
|
|
2188
2189
|
exports.QueryResults = QueryResults;
|
|
2189
2190
|
exports.asc = asc;
|
|
2190
2191
|
exports.avg = avg;
|
|
@@ -2194,6 +2195,7 @@ exports.containsIgnoreCase = containsIgnoreCase;
|
|
|
2194
2195
|
exports.count = count;
|
|
2195
2196
|
exports.desc = desc;
|
|
2196
2197
|
exports.eq = eq;
|
|
2198
|
+
exports.format = format;
|
|
2197
2199
|
exports.gt = gt;
|
|
2198
2200
|
exports.gte = gte;
|
|
2199
2201
|
exports.inOp = inOp;
|
|
@@ -2218,8 +2220,8 @@ exports.notWithin = notWithin;
|
|
|
2218
2220
|
exports.onyx = onyx;
|
|
2219
2221
|
exports.percentile = percentile;
|
|
2220
2222
|
exports.replace = replace;
|
|
2221
|
-
exports.sdkName =
|
|
2222
|
-
exports.sdkVersion =
|
|
2223
|
+
exports.sdkName = name;
|
|
2224
|
+
exports.sdkVersion = version;
|
|
2223
2225
|
exports.search = search;
|
|
2224
2226
|
exports.startsWith = startsWith;
|
|
2225
2227
|
exports.std = std;
|