@onyx.dev/onyx-database 2.0.0 → 2.1.0
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 +100 -57
- package/dist/{aggregates-BJT5DGGX.d.cts → aggregates-DREvey7b.d.cts} +5 -1
- package/dist/{aggregates-BJT5DGGX.d.ts → aggregates-DREvey7b.d.ts} +5 -1
- package/dist/edge.cjs +65 -45
- 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 +63 -44
- package/dist/edge.js.map +1 -1
- package/dist/gen/cli/generate.cjs +24 -6
- package/dist/gen/cli/generate.cjs.map +1 -1
- package/dist/index.cjs +65 -45
- 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 +63 -44
- package/dist/index.js.map +1 -1
- package/dist/schema/cli/schema.cjs +24 -6
- package/dist/schema/cli/schema.cjs.map +1 -1
- package/package.json +1 -1
package/dist/edge.d.cts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { O as OnyxFacade } from './aggregates-
|
|
2
|
-
export {
|
|
1
|
+
import { O as OnyxFacade } from './aggregates-DREvey7b.cjs';
|
|
2
|
+
export { t as AiChatClient, l as AiChatCompletionChoice, q as AiChatCompletionChunk, p as AiChatCompletionChunkChoice, o as AiChatCompletionChunkDelta, j as AiChatCompletionRequest, m as AiChatCompletionResponse, r as AiChatCompletionStream, k as AiChatCompletionUsage, f as AiChatMessage, s as AiChatOptions, c as AiChatRole, B as AiClient, z as AiErrorResponse, y as AiModel, x as AiModelsResponse, A as AiRequestOptions, u as AiScriptApprovalRequest, w as AiScriptApprovalResponse, h as AiTool, e as AiToolCall, d as AiToolCallFunction, i as AiToolChoice, g as AiToolFunction, aa as FetchImpl, a9 as FetchResponse, F as FullTextQuery, aj as ICascadeBuilder, ak as ICascadeRelationshipBuilder, ag as IConditionBuilder, I as IOnyxDatabase, ah as IQueryBuilder, ai as ISaveBuilder, a5 as LogicalOperator, b as OnyxConfig, a8 as OnyxDocument, ac as QueryCondition, ab as QueryCriteria, a4 as QueryCriteriaOperator, af as QueryPage, Q as QueryResults, a as QueryResultsPromise, R as RetryOptions, K as SchemaAttribute, _ as SchemaAttributeChange, G as SchemaDataType, a3 as SchemaDiff, U as SchemaEntity, X as SchemaHistoryEntry, J as SchemaIdentifier, H as SchemaIdentifierGenerator, M as SchemaIndex, $ as SchemaIndexChange, L as SchemaIndexType, N as SchemaResolver, a0 as SchemaResolverChange, W as SchemaRevision, V as SchemaRevisionMetadata, a2 as SchemaTableDiff, T as SchemaTrigger, a1 as SchemaTriggerChange, P as SchemaTriggerEvent, Y as SchemaUpsertRequest, Z as SchemaValidationResult, S as SecretMetadata, C as SecretRecord, E as SecretSaveRequest, D as SecretsListResponse, ad as SelectQuery, a6 as Sort, a7 as StreamAction, ae as UpdateQuery, al as asc, aL as avg, at as between, aD as contains, aE as containsIgnoreCase, aN as count, am as desc, an as eq, aX as format, au as gt, av as gte, ap as inOp, aJ as isNull, aB as like, aU as lower, aw as lt, ax as lte, ay as matches, aP as max, aS as median, aO as min, ao as neq, aF as notContains, aG as notContainsIgnoreCase, ar as notIn, aC as notLike, aA as notMatches, aK as notNull, aI as notStartsWith, as as notWithin, aY as percentile, aW as replace, n as sdkName, v as sdkVersion, az as search, aH as startsWith, aQ as std, aV as substring, aM as sum, aT as upper, aR as variance, aq as within } from './aggregates-DREvey7b.cjs';
|
|
3
3
|
|
|
4
4
|
declare const onyx: OnyxFacade;
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
declare const sdkVersion = "0.1.0";
|
|
8
|
-
|
|
9
|
-
export { OnyxFacade, onyx, sdkName, sdkVersion };
|
|
6
|
+
export { OnyxFacade, onyx };
|
package/dist/edge.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { O as OnyxFacade } from './aggregates-
|
|
2
|
-
export {
|
|
1
|
+
import { O as OnyxFacade } from './aggregates-DREvey7b.js';
|
|
2
|
+
export { t as AiChatClient, l as AiChatCompletionChoice, q as AiChatCompletionChunk, p as AiChatCompletionChunkChoice, o as AiChatCompletionChunkDelta, j as AiChatCompletionRequest, m as AiChatCompletionResponse, r as AiChatCompletionStream, k as AiChatCompletionUsage, f as AiChatMessage, s as AiChatOptions, c as AiChatRole, B as AiClient, z as AiErrorResponse, y as AiModel, x as AiModelsResponse, A as AiRequestOptions, u as AiScriptApprovalRequest, w as AiScriptApprovalResponse, h as AiTool, e as AiToolCall, d as AiToolCallFunction, i as AiToolChoice, g as AiToolFunction, aa as FetchImpl, a9 as FetchResponse, F as FullTextQuery, aj as ICascadeBuilder, ak as ICascadeRelationshipBuilder, ag as IConditionBuilder, I as IOnyxDatabase, ah as IQueryBuilder, ai as ISaveBuilder, a5 as LogicalOperator, b as OnyxConfig, a8 as OnyxDocument, ac as QueryCondition, ab as QueryCriteria, a4 as QueryCriteriaOperator, af as QueryPage, Q as QueryResults, a as QueryResultsPromise, R as RetryOptions, K as SchemaAttribute, _ as SchemaAttributeChange, G as SchemaDataType, a3 as SchemaDiff, U as SchemaEntity, X as SchemaHistoryEntry, J as SchemaIdentifier, H as SchemaIdentifierGenerator, M as SchemaIndex, $ as SchemaIndexChange, L as SchemaIndexType, N as SchemaResolver, a0 as SchemaResolverChange, W as SchemaRevision, V as SchemaRevisionMetadata, a2 as SchemaTableDiff, T as SchemaTrigger, a1 as SchemaTriggerChange, P as SchemaTriggerEvent, Y as SchemaUpsertRequest, Z as SchemaValidationResult, S as SecretMetadata, C as SecretRecord, E as SecretSaveRequest, D as SecretsListResponse, ad as SelectQuery, a6 as Sort, a7 as StreamAction, ae as UpdateQuery, al as asc, aL as avg, at as between, aD as contains, aE as containsIgnoreCase, aN as count, am as desc, an as eq, aX as format, au as gt, av as gte, ap as inOp, aJ as isNull, aB as like, aU as lower, aw as lt, ax as lte, ay as matches, aP as max, aS as median, aO as min, ao as neq, aF as notContains, aG as notContainsIgnoreCase, ar as notIn, aC as notLike, aA as notMatches, aK as notNull, aI as notStartsWith, as as notWithin, aY as percentile, aW as replace, n as sdkName, v as sdkVersion, az as search, aH as startsWith, aQ as std, aV as substring, aM as sum, aT as upper, aR as variance, aq as within } from './aggregates-DREvey7b.js';
|
|
3
3
|
|
|
4
4
|
declare const onyx: OnyxFacade;
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
declare const sdkVersion = "0.1.0";
|
|
8
|
-
|
|
9
|
-
export { OnyxFacade, onyx, sdkName, sdkVersion };
|
|
6
|
+
export { OnyxFacade, onyx };
|
package/dist/edge.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// package.json
|
|
2
|
+
var name = "@onyx.dev/onyx-database";
|
|
3
|
+
var version = "2.1.0";
|
|
4
|
+
|
|
1
5
|
// src/config/defaults.ts
|
|
2
6
|
var DEFAULT_BASE_URL = "https://api.onyx.dev";
|
|
3
7
|
var DEFAULT_AI_BASE_URL = "https://ai.onyx.dev";
|
|
@@ -801,8 +805,8 @@ var CascadeRelationshipBuilder = class {
|
|
|
801
805
|
* builder.graph('programs');
|
|
802
806
|
* ```
|
|
803
807
|
*/
|
|
804
|
-
graph(
|
|
805
|
-
this.graphName =
|
|
808
|
+
graph(name2) {
|
|
809
|
+
this.graphName = name2;
|
|
806
810
|
return this;
|
|
807
811
|
}
|
|
808
812
|
/**
|
|
@@ -889,24 +893,24 @@ function diffAttributes(apiAttrs, localAttrs) {
|
|
|
889
893
|
const added = [];
|
|
890
894
|
const removed = [];
|
|
891
895
|
const changed = [];
|
|
892
|
-
for (const [
|
|
893
|
-
if (!apiMap.has(
|
|
896
|
+
for (const [name2, local] of localMap.entries()) {
|
|
897
|
+
if (!apiMap.has(name2)) {
|
|
894
898
|
added.push(local);
|
|
895
899
|
continue;
|
|
896
900
|
}
|
|
897
|
-
const api = apiMap.get(
|
|
901
|
+
const api = apiMap.get(name2);
|
|
898
902
|
const apiNull = Boolean(api.isNullable);
|
|
899
903
|
const localNull = Boolean(local.isNullable);
|
|
900
904
|
if (api.type !== local.type || apiNull !== localNull) {
|
|
901
905
|
changed.push({
|
|
902
|
-
name,
|
|
906
|
+
name: name2,
|
|
903
907
|
from: { type: api.type, isNullable: apiNull },
|
|
904
908
|
to: { type: local.type, isNullable: localNull }
|
|
905
909
|
});
|
|
906
910
|
}
|
|
907
911
|
}
|
|
908
|
-
for (const
|
|
909
|
-
if (!localMap.has(
|
|
912
|
+
for (const name2 of apiMap.keys()) {
|
|
913
|
+
if (!localMap.has(name2)) removed.push(name2);
|
|
910
914
|
}
|
|
911
915
|
added.sort((a, b) => a.name.localeCompare(b.name));
|
|
912
916
|
removed.sort();
|
|
@@ -920,22 +924,22 @@ function diffIndexes(apiIndexes, localIndexes) {
|
|
|
920
924
|
const added = [];
|
|
921
925
|
const removed = [];
|
|
922
926
|
const changed = [];
|
|
923
|
-
for (const [
|
|
924
|
-
if (!apiMap.has(
|
|
927
|
+
for (const [name2, local] of localMap.entries()) {
|
|
928
|
+
if (!apiMap.has(name2)) {
|
|
925
929
|
added.push(local);
|
|
926
930
|
continue;
|
|
927
931
|
}
|
|
928
|
-
const api = apiMap.get(
|
|
932
|
+
const api = apiMap.get(name2);
|
|
929
933
|
const apiType = api.type ?? "DEFAULT";
|
|
930
934
|
const localType = local.type ?? "DEFAULT";
|
|
931
935
|
const apiScore = api.minimumScore;
|
|
932
936
|
const localScore = local.minimumScore;
|
|
933
937
|
if (apiType !== localType || apiScore !== localScore) {
|
|
934
|
-
changed.push({ name, from: api, to: local });
|
|
938
|
+
changed.push({ name: name2, from: api, to: local });
|
|
935
939
|
}
|
|
936
940
|
}
|
|
937
|
-
for (const
|
|
938
|
-
if (!localMap.has(
|
|
941
|
+
for (const name2 of apiMap.keys()) {
|
|
942
|
+
if (!localMap.has(name2)) removed.push(name2);
|
|
939
943
|
}
|
|
940
944
|
added.sort((a, b) => a.name.localeCompare(b.name));
|
|
941
945
|
removed.sort();
|
|
@@ -949,18 +953,18 @@ function diffResolvers(apiResolvers, localResolvers) {
|
|
|
949
953
|
const added = [];
|
|
950
954
|
const removed = [];
|
|
951
955
|
const changed = [];
|
|
952
|
-
for (const [
|
|
953
|
-
if (!apiMap.has(
|
|
956
|
+
for (const [name2, local] of localMap.entries()) {
|
|
957
|
+
if (!apiMap.has(name2)) {
|
|
954
958
|
added.push(local);
|
|
955
959
|
continue;
|
|
956
960
|
}
|
|
957
|
-
const api = apiMap.get(
|
|
961
|
+
const api = apiMap.get(name2);
|
|
958
962
|
if (api.resolver !== local.resolver) {
|
|
959
|
-
changed.push({ name, from: api, to: local });
|
|
963
|
+
changed.push({ name: name2, from: api, to: local });
|
|
960
964
|
}
|
|
961
965
|
}
|
|
962
|
-
for (const
|
|
963
|
-
if (!localMap.has(
|
|
966
|
+
for (const name2 of apiMap.keys()) {
|
|
967
|
+
if (!localMap.has(name2)) removed.push(name2);
|
|
964
968
|
}
|
|
965
969
|
added.sort((a, b) => a.name.localeCompare(b.name));
|
|
966
970
|
removed.sort();
|
|
@@ -974,18 +978,18 @@ function diffTriggers(apiTriggers, localTriggers) {
|
|
|
974
978
|
const added = [];
|
|
975
979
|
const removed = [];
|
|
976
980
|
const changed = [];
|
|
977
|
-
for (const [
|
|
978
|
-
if (!apiMap.has(
|
|
981
|
+
for (const [name2, local] of localMap.entries()) {
|
|
982
|
+
if (!apiMap.has(name2)) {
|
|
979
983
|
added.push(local);
|
|
980
984
|
continue;
|
|
981
985
|
}
|
|
982
|
-
const api = apiMap.get(
|
|
986
|
+
const api = apiMap.get(name2);
|
|
983
987
|
if (api.event !== local.event || api.trigger !== local.trigger) {
|
|
984
|
-
changed.push({ name, from: api, to: local });
|
|
988
|
+
changed.push({ name: name2, from: api, to: local });
|
|
985
989
|
}
|
|
986
990
|
}
|
|
987
|
-
for (const
|
|
988
|
-
if (!localMap.has(
|
|
991
|
+
for (const name2 of apiMap.keys()) {
|
|
992
|
+
if (!localMap.has(name2)) removed.push(name2);
|
|
989
993
|
}
|
|
990
994
|
added.sort((a, b) => a.name.localeCompare(b.name));
|
|
991
995
|
removed.sort();
|
|
@@ -1001,13 +1005,13 @@ function computeSchemaDiff(apiSchema, localSchema) {
|
|
|
1001
1005
|
const newTables = [];
|
|
1002
1006
|
const removedTables = [];
|
|
1003
1007
|
const changedTables = [];
|
|
1004
|
-
for (const [
|
|
1005
|
-
if (!apiMap.has(
|
|
1006
|
-
newTables.push(
|
|
1008
|
+
for (const [name2, localEntity] of localMap.entries()) {
|
|
1009
|
+
if (!apiMap.has(name2)) {
|
|
1010
|
+
newTables.push(name2);
|
|
1007
1011
|
continue;
|
|
1008
1012
|
}
|
|
1009
|
-
const apiEntity = apiMap.get(
|
|
1010
|
-
const tableDiff = { name };
|
|
1013
|
+
const apiEntity = apiMap.get(name2);
|
|
1014
|
+
const tableDiff = { name: name2 };
|
|
1011
1015
|
const partitionFrom = normalizePartition(apiEntity.partition);
|
|
1012
1016
|
const partitionTo = normalizePartition(localEntity.partition);
|
|
1013
1017
|
if (partitionFrom !== partitionTo) {
|
|
@@ -1032,8 +1036,8 @@ function computeSchemaDiff(apiSchema, localSchema) {
|
|
|
1032
1036
|
changedTables.push(tableDiff);
|
|
1033
1037
|
}
|
|
1034
1038
|
}
|
|
1035
|
-
for (const
|
|
1036
|
-
if (!localMap.has(
|
|
1039
|
+
for (const name2 of apiMap.keys()) {
|
|
1040
|
+
if (!localMap.has(name2)) removedTables.push(name2);
|
|
1037
1041
|
}
|
|
1038
1042
|
newTables.sort();
|
|
1039
1043
|
removedTables.sort();
|
|
@@ -1971,20 +1975,38 @@ var AiChatClientImpl = class {
|
|
|
1971
1975
|
}
|
|
1972
1976
|
};
|
|
1973
1977
|
function createOnyxFacade(resolveConfig2) {
|
|
1974
|
-
|
|
1978
|
+
const cachedCfgs = /* @__PURE__ */ new Map();
|
|
1979
|
+
const cacheKey = (databaseId, apiKey) => {
|
|
1980
|
+
const id = typeof databaseId === "string" && databaseId.trim() !== "" ? databaseId.trim() : null;
|
|
1981
|
+
const key = typeof apiKey === "string" && apiKey.trim() !== "" ? apiKey.trim() : null;
|
|
1982
|
+
return id && key ? `${id}-${key}` : null;
|
|
1983
|
+
};
|
|
1975
1984
|
function resolveConfigWithCache(config) {
|
|
1976
1985
|
const ttl = config?.ttl ?? DEFAULT_CACHE_TTL;
|
|
1977
1986
|
const now = Date.now();
|
|
1978
|
-
|
|
1979
|
-
|
|
1987
|
+
const hintKey = cacheKey(config?.databaseId, config?.apiKey) ?? "__default__";
|
|
1988
|
+
const existing = cachedCfgs.get(hintKey);
|
|
1989
|
+
if (existing && existing.expires > now) {
|
|
1990
|
+
return existing.promise;
|
|
1980
1991
|
}
|
|
1992
|
+
if (existing) cachedCfgs.delete(hintKey);
|
|
1981
1993
|
const { ttl: _ttl, requestLoggingEnabled: _reqLog, responseLoggingEnabled: _resLog, ...rest } = config ?? {};
|
|
1982
|
-
const
|
|
1983
|
-
|
|
1994
|
+
const expires = now + ttl;
|
|
1995
|
+
const promise = resolveConfig2(rest).then((resolved) => {
|
|
1996
|
+
const resolvedKey = cacheKey(resolved.databaseId, resolved.apiKey) ?? hintKey;
|
|
1997
|
+
const nextExpires = Date.now() + ttl;
|
|
1998
|
+
cachedCfgs.set(resolvedKey, { promise, expires: nextExpires });
|
|
1999
|
+
if (resolvedKey !== hintKey) {
|
|
2000
|
+
const stale = cachedCfgs.get(hintKey);
|
|
2001
|
+
if (stale && stale.promise === promise) cachedCfgs.delete(hintKey);
|
|
2002
|
+
}
|
|
2003
|
+
return resolved;
|
|
2004
|
+
});
|
|
2005
|
+
cachedCfgs.set(hintKey, { promise, expires });
|
|
1984
2006
|
return promise;
|
|
1985
2007
|
}
|
|
1986
2008
|
function clearCacheConfig() {
|
|
1987
|
-
|
|
2009
|
+
cachedCfgs.clear();
|
|
1988
2010
|
}
|
|
1989
2011
|
return {
|
|
1990
2012
|
init(config) {
|
|
@@ -2177,12 +2199,9 @@ var upper = (attribute) => `upper(${attribute})`;
|
|
|
2177
2199
|
var lower = (attribute) => `lower(${attribute})`;
|
|
2178
2200
|
var substring = (attribute, from, length) => `substring(${attribute},${from},${length})`;
|
|
2179
2201
|
var replace = (attribute, pattern, repl) => `replace(${attribute}, '${pattern.replace(/'/g, "\\'")}', '${repl.replace(/'/g, "\\'")}')`;
|
|
2202
|
+
var format = (attribute, formatter) => `format(${attribute}, '${formatter.replace(/'/g, "\\'")}')`;
|
|
2180
2203
|
var percentile = (attribute, p) => `percentile(${attribute}, ${p})`;
|
|
2181
2204
|
|
|
2182
|
-
|
|
2183
|
-
var sdkName = "@onyx.dev/onyx-database";
|
|
2184
|
-
var sdkVersion = "0.1.0";
|
|
2185
|
-
|
|
2186
|
-
export { QueryResults, 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, search, startsWith, std, substring, sum, upper, variance, within };
|
|
2205
|
+
export { QueryResults, asc, avg, between, contains, containsIgnoreCase, count, desc, eq, format, gt, gte, inOp, isNull, like, lower, lt, lte, matches, max, median, min, neq, notContains, notContainsIgnoreCase, notIn, notLike, notMatches, notNull, notStartsWith, notWithin, onyx, percentile, replace, name as sdkName, version as sdkVersion, search, startsWith, std, substring, sum, upper, variance, within };
|
|
2187
2206
|
//# sourceMappingURL=edge.js.map
|
|
2188
2207
|
//# sourceMappingURL=edge.js.map
|