@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/index.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/index.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/index.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";
|
|
@@ -949,8 +953,8 @@ var CascadeRelationshipBuilder = class {
|
|
|
949
953
|
* builder.graph('programs');
|
|
950
954
|
* ```
|
|
951
955
|
*/
|
|
952
|
-
graph(
|
|
953
|
-
this.graphName =
|
|
956
|
+
graph(name2) {
|
|
957
|
+
this.graphName = name2;
|
|
954
958
|
return this;
|
|
955
959
|
}
|
|
956
960
|
/**
|
|
@@ -1037,24 +1041,24 @@ function diffAttributes(apiAttrs, localAttrs) {
|
|
|
1037
1041
|
const added = [];
|
|
1038
1042
|
const removed = [];
|
|
1039
1043
|
const changed = [];
|
|
1040
|
-
for (const [
|
|
1041
|
-
if (!apiMap.has(
|
|
1044
|
+
for (const [name2, local] of localMap.entries()) {
|
|
1045
|
+
if (!apiMap.has(name2)) {
|
|
1042
1046
|
added.push(local);
|
|
1043
1047
|
continue;
|
|
1044
1048
|
}
|
|
1045
|
-
const api = apiMap.get(
|
|
1049
|
+
const api = apiMap.get(name2);
|
|
1046
1050
|
const apiNull = Boolean(api.isNullable);
|
|
1047
1051
|
const localNull = Boolean(local.isNullable);
|
|
1048
1052
|
if (api.type !== local.type || apiNull !== localNull) {
|
|
1049
1053
|
changed.push({
|
|
1050
|
-
name,
|
|
1054
|
+
name: name2,
|
|
1051
1055
|
from: { type: api.type, isNullable: apiNull },
|
|
1052
1056
|
to: { type: local.type, isNullable: localNull }
|
|
1053
1057
|
});
|
|
1054
1058
|
}
|
|
1055
1059
|
}
|
|
1056
|
-
for (const
|
|
1057
|
-
if (!localMap.has(
|
|
1060
|
+
for (const name2 of apiMap.keys()) {
|
|
1061
|
+
if (!localMap.has(name2)) removed.push(name2);
|
|
1058
1062
|
}
|
|
1059
1063
|
added.sort((a, b) => a.name.localeCompare(b.name));
|
|
1060
1064
|
removed.sort();
|
|
@@ -1068,22 +1072,22 @@ function diffIndexes(apiIndexes, localIndexes) {
|
|
|
1068
1072
|
const added = [];
|
|
1069
1073
|
const removed = [];
|
|
1070
1074
|
const changed = [];
|
|
1071
|
-
for (const [
|
|
1072
|
-
if (!apiMap.has(
|
|
1075
|
+
for (const [name2, local] of localMap.entries()) {
|
|
1076
|
+
if (!apiMap.has(name2)) {
|
|
1073
1077
|
added.push(local);
|
|
1074
1078
|
continue;
|
|
1075
1079
|
}
|
|
1076
|
-
const api = apiMap.get(
|
|
1080
|
+
const api = apiMap.get(name2);
|
|
1077
1081
|
const apiType = api.type ?? "DEFAULT";
|
|
1078
1082
|
const localType = local.type ?? "DEFAULT";
|
|
1079
1083
|
const apiScore = api.minimumScore;
|
|
1080
1084
|
const localScore = local.minimumScore;
|
|
1081
1085
|
if (apiType !== localType || apiScore !== localScore) {
|
|
1082
|
-
changed.push({ name, from: api, to: local });
|
|
1086
|
+
changed.push({ name: name2, from: api, to: local });
|
|
1083
1087
|
}
|
|
1084
1088
|
}
|
|
1085
|
-
for (const
|
|
1086
|
-
if (!localMap.has(
|
|
1089
|
+
for (const name2 of apiMap.keys()) {
|
|
1090
|
+
if (!localMap.has(name2)) removed.push(name2);
|
|
1087
1091
|
}
|
|
1088
1092
|
added.sort((a, b) => a.name.localeCompare(b.name));
|
|
1089
1093
|
removed.sort();
|
|
@@ -1097,18 +1101,18 @@ function diffResolvers(apiResolvers, localResolvers) {
|
|
|
1097
1101
|
const added = [];
|
|
1098
1102
|
const removed = [];
|
|
1099
1103
|
const changed = [];
|
|
1100
|
-
for (const [
|
|
1101
|
-
if (!apiMap.has(
|
|
1104
|
+
for (const [name2, local] of localMap.entries()) {
|
|
1105
|
+
if (!apiMap.has(name2)) {
|
|
1102
1106
|
added.push(local);
|
|
1103
1107
|
continue;
|
|
1104
1108
|
}
|
|
1105
|
-
const api = apiMap.get(
|
|
1109
|
+
const api = apiMap.get(name2);
|
|
1106
1110
|
if (api.resolver !== local.resolver) {
|
|
1107
|
-
changed.push({ name, from: api, to: local });
|
|
1111
|
+
changed.push({ name: name2, from: api, to: local });
|
|
1108
1112
|
}
|
|
1109
1113
|
}
|
|
1110
|
-
for (const
|
|
1111
|
-
if (!localMap.has(
|
|
1114
|
+
for (const name2 of apiMap.keys()) {
|
|
1115
|
+
if (!localMap.has(name2)) removed.push(name2);
|
|
1112
1116
|
}
|
|
1113
1117
|
added.sort((a, b) => a.name.localeCompare(b.name));
|
|
1114
1118
|
removed.sort();
|
|
@@ -1122,18 +1126,18 @@ function diffTriggers(apiTriggers, localTriggers) {
|
|
|
1122
1126
|
const added = [];
|
|
1123
1127
|
const removed = [];
|
|
1124
1128
|
const changed = [];
|
|
1125
|
-
for (const [
|
|
1126
|
-
if (!apiMap.has(
|
|
1129
|
+
for (const [name2, local] of localMap.entries()) {
|
|
1130
|
+
if (!apiMap.has(name2)) {
|
|
1127
1131
|
added.push(local);
|
|
1128
1132
|
continue;
|
|
1129
1133
|
}
|
|
1130
|
-
const api = apiMap.get(
|
|
1134
|
+
const api = apiMap.get(name2);
|
|
1131
1135
|
if (api.event !== local.event || api.trigger !== local.trigger) {
|
|
1132
|
-
changed.push({ name, from: api, to: local });
|
|
1136
|
+
changed.push({ name: name2, from: api, to: local });
|
|
1133
1137
|
}
|
|
1134
1138
|
}
|
|
1135
|
-
for (const
|
|
1136
|
-
if (!localMap.has(
|
|
1139
|
+
for (const name2 of apiMap.keys()) {
|
|
1140
|
+
if (!localMap.has(name2)) removed.push(name2);
|
|
1137
1141
|
}
|
|
1138
1142
|
added.sort((a, b) => a.name.localeCompare(b.name));
|
|
1139
1143
|
removed.sort();
|
|
@@ -1149,13 +1153,13 @@ function computeSchemaDiff(apiSchema, localSchema) {
|
|
|
1149
1153
|
const newTables = [];
|
|
1150
1154
|
const removedTables = [];
|
|
1151
1155
|
const changedTables = [];
|
|
1152
|
-
for (const [
|
|
1153
|
-
if (!apiMap.has(
|
|
1154
|
-
newTables.push(
|
|
1156
|
+
for (const [name2, localEntity] of localMap.entries()) {
|
|
1157
|
+
if (!apiMap.has(name2)) {
|
|
1158
|
+
newTables.push(name2);
|
|
1155
1159
|
continue;
|
|
1156
1160
|
}
|
|
1157
|
-
const apiEntity = apiMap.get(
|
|
1158
|
-
const tableDiff = { name };
|
|
1161
|
+
const apiEntity = apiMap.get(name2);
|
|
1162
|
+
const tableDiff = { name: name2 };
|
|
1159
1163
|
const partitionFrom = normalizePartition(apiEntity.partition);
|
|
1160
1164
|
const partitionTo = normalizePartition(localEntity.partition);
|
|
1161
1165
|
if (partitionFrom !== partitionTo) {
|
|
@@ -1180,8 +1184,8 @@ function computeSchemaDiff(apiSchema, localSchema) {
|
|
|
1180
1184
|
changedTables.push(tableDiff);
|
|
1181
1185
|
}
|
|
1182
1186
|
}
|
|
1183
|
-
for (const
|
|
1184
|
-
if (!localMap.has(
|
|
1187
|
+
for (const name2 of apiMap.keys()) {
|
|
1188
|
+
if (!localMap.has(name2)) removedTables.push(name2);
|
|
1185
1189
|
}
|
|
1186
1190
|
newTables.sort();
|
|
1187
1191
|
removedTables.sort();
|
|
@@ -2119,20 +2123,38 @@ var AiChatClientImpl = class {
|
|
|
2119
2123
|
}
|
|
2120
2124
|
};
|
|
2121
2125
|
function createOnyxFacade(resolveConfig2) {
|
|
2122
|
-
|
|
2126
|
+
const cachedCfgs = /* @__PURE__ */ new Map();
|
|
2127
|
+
const cacheKey = (databaseId, apiKey) => {
|
|
2128
|
+
const id = typeof databaseId === "string" && databaseId.trim() !== "" ? databaseId.trim() : null;
|
|
2129
|
+
const key = typeof apiKey === "string" && apiKey.trim() !== "" ? apiKey.trim() : null;
|
|
2130
|
+
return id && key ? `${id}-${key}` : null;
|
|
2131
|
+
};
|
|
2123
2132
|
function resolveConfigWithCache(config) {
|
|
2124
2133
|
const ttl = config?.ttl ?? DEFAULT_CACHE_TTL;
|
|
2125
2134
|
const now = Date.now();
|
|
2126
|
-
|
|
2127
|
-
|
|
2135
|
+
const hintKey = cacheKey(config?.databaseId, config?.apiKey) ?? "__default__";
|
|
2136
|
+
const existing = cachedCfgs.get(hintKey);
|
|
2137
|
+
if (existing && existing.expires > now) {
|
|
2138
|
+
return existing.promise;
|
|
2128
2139
|
}
|
|
2140
|
+
if (existing) cachedCfgs.delete(hintKey);
|
|
2129
2141
|
const { ttl: _ttl, requestLoggingEnabled: _reqLog, responseLoggingEnabled: _resLog, ...rest } = config ?? {};
|
|
2130
|
-
const
|
|
2131
|
-
|
|
2142
|
+
const expires = now + ttl;
|
|
2143
|
+
const promise = resolveConfig2(rest).then((resolved) => {
|
|
2144
|
+
const resolvedKey = cacheKey(resolved.databaseId, resolved.apiKey) ?? hintKey;
|
|
2145
|
+
const nextExpires = Date.now() + ttl;
|
|
2146
|
+
cachedCfgs.set(resolvedKey, { promise, expires: nextExpires });
|
|
2147
|
+
if (resolvedKey !== hintKey) {
|
|
2148
|
+
const stale = cachedCfgs.get(hintKey);
|
|
2149
|
+
if (stale && stale.promise === promise) cachedCfgs.delete(hintKey);
|
|
2150
|
+
}
|
|
2151
|
+
return resolved;
|
|
2152
|
+
});
|
|
2153
|
+
cachedCfgs.set(hintKey, { promise, expires });
|
|
2132
2154
|
return promise;
|
|
2133
2155
|
}
|
|
2134
2156
|
function clearCacheConfig() {
|
|
2135
|
-
|
|
2157
|
+
cachedCfgs.clear();
|
|
2136
2158
|
}
|
|
2137
2159
|
return {
|
|
2138
2160
|
init(config) {
|
|
@@ -2325,12 +2347,9 @@ var upper = (attribute) => `upper(${attribute})`;
|
|
|
2325
2347
|
var lower = (attribute) => `lower(${attribute})`;
|
|
2326
2348
|
var substring = (attribute, from, length) => `substring(${attribute},${from},${length})`;
|
|
2327
2349
|
var replace = (attribute, pattern, repl) => `replace(${attribute}, '${pattern.replace(/'/g, "\\'")}', '${repl.replace(/'/g, "\\'")}')`;
|
|
2350
|
+
var format = (attribute, formatter) => `format(${attribute}, '${formatter.replace(/'/g, "\\'")}')`;
|
|
2328
2351
|
var percentile = (attribute, p) => `percentile(${attribute}, ${p})`;
|
|
2329
2352
|
|
|
2330
|
-
|
|
2331
|
-
var sdkName = "@onyx.dev/onyx-database";
|
|
2332
|
-
var sdkVersion = "0.1.0";
|
|
2333
|
-
|
|
2334
|
-
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 };
|
|
2353
|
+
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 };
|
|
2335
2354
|
//# sourceMappingURL=index.js.map
|
|
2336
2355
|
//# sourceMappingURL=index.js.map
|