@concavejs/docstore-cf-hyperdrive 0.0.1-alpha.7 → 0.0.1-alpha.8
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.js +891 -738
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -853,237 +853,6 @@ function deserializeDeveloperId(developerId) {
|
|
|
853
853
|
}
|
|
854
854
|
var DOC_ID_SEPARATOR = ":", LEGACY_DOC_ID_SEPARATOR = ";";
|
|
855
855
|
|
|
856
|
-
// ../core/dist/queryengine/indexing/index-key-codec.js
|
|
857
|
-
function encodeNumber(n) {
|
|
858
|
-
const buffer = new ArrayBuffer(8);
|
|
859
|
-
const view = new DataView(buffer);
|
|
860
|
-
view.setFloat64(0, n, false);
|
|
861
|
-
const bytes = new Uint8Array(buffer);
|
|
862
|
-
if (n >= 0) {
|
|
863
|
-
bytes[0] ^= 128;
|
|
864
|
-
} else {
|
|
865
|
-
for (let i2 = 0;i2 < 8; i2++) {
|
|
866
|
-
bytes[i2] ^= 255;
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
return bytes;
|
|
870
|
-
}
|
|
871
|
-
function encodeBigInt(n) {
|
|
872
|
-
const INT64_MIN = -(2n ** 63n);
|
|
873
|
-
const INT64_MAX = 2n ** 63n - 1n;
|
|
874
|
-
if (n < INT64_MIN)
|
|
875
|
-
n = INT64_MIN;
|
|
876
|
-
if (n > INT64_MAX)
|
|
877
|
-
n = INT64_MAX;
|
|
878
|
-
const buffer = new ArrayBuffer(8);
|
|
879
|
-
const view = new DataView(buffer);
|
|
880
|
-
const unsigned = n < 0n ? n + 2n ** 64n : n;
|
|
881
|
-
view.setBigUint64(0, unsigned, false);
|
|
882
|
-
const bytes = new Uint8Array(buffer);
|
|
883
|
-
bytes[0] ^= 128;
|
|
884
|
-
return bytes;
|
|
885
|
-
}
|
|
886
|
-
function encodeString(s) {
|
|
887
|
-
const encoder = new TextEncoder;
|
|
888
|
-
const raw = encoder.encode(s);
|
|
889
|
-
let nullCount = 0;
|
|
890
|
-
for (const byte of raw) {
|
|
891
|
-
if (byte === 0)
|
|
892
|
-
nullCount++;
|
|
893
|
-
}
|
|
894
|
-
const result = new Uint8Array(raw.length + nullCount + 2);
|
|
895
|
-
let writeIndex = 0;
|
|
896
|
-
for (const byte of raw) {
|
|
897
|
-
if (byte === 0) {
|
|
898
|
-
result[writeIndex++] = 0;
|
|
899
|
-
result[writeIndex++] = 1;
|
|
900
|
-
} else {
|
|
901
|
-
result[writeIndex++] = byte;
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
result[writeIndex++] = 0;
|
|
905
|
-
result[writeIndex++] = 0;
|
|
906
|
-
return result;
|
|
907
|
-
}
|
|
908
|
-
function encodeValue(value) {
|
|
909
|
-
if (value === null || value === undefined) {
|
|
910
|
-
return new Uint8Array([TypeTag.Null]);
|
|
911
|
-
}
|
|
912
|
-
if (typeof value === "boolean") {
|
|
913
|
-
return new Uint8Array([value ? TypeTag.True : TypeTag.False]);
|
|
914
|
-
}
|
|
915
|
-
if (typeof value === "number") {
|
|
916
|
-
if (Number.isNaN(value)) {
|
|
917
|
-
return new Uint8Array([TypeTag.NaN]);
|
|
918
|
-
}
|
|
919
|
-
if (!Number.isFinite(value)) {
|
|
920
|
-
return new Uint8Array([value === -Infinity ? TypeTag.NegativeInfinity : TypeTag.PositiveInfinity]);
|
|
921
|
-
}
|
|
922
|
-
if (value === 0) {
|
|
923
|
-
return new Uint8Array([Object.is(value, -0) ? TypeTag.NegativeZero : TypeTag.Zero]);
|
|
924
|
-
}
|
|
925
|
-
const tag = value > 0 ? TypeTag.PositiveNumber : TypeTag.NegativeNumber;
|
|
926
|
-
const encoded = encodeNumber(value);
|
|
927
|
-
const result = new Uint8Array(1 + encoded.length);
|
|
928
|
-
result[0] = tag;
|
|
929
|
-
result.set(encoded, 1);
|
|
930
|
-
return result;
|
|
931
|
-
}
|
|
932
|
-
if (typeof value === "bigint") {
|
|
933
|
-
if (value === 0n) {
|
|
934
|
-
return new Uint8Array([TypeTag.ZeroBigInt]);
|
|
935
|
-
}
|
|
936
|
-
const tag = value > 0n ? TypeTag.PositiveBigInt : TypeTag.NegativeBigInt;
|
|
937
|
-
const encoded = encodeBigInt(value);
|
|
938
|
-
const result = new Uint8Array(1 + encoded.length);
|
|
939
|
-
result[0] = tag;
|
|
940
|
-
result.set(encoded, 1);
|
|
941
|
-
return result;
|
|
942
|
-
}
|
|
943
|
-
if (typeof value === "string") {
|
|
944
|
-
const encoded = encodeString(value);
|
|
945
|
-
const result = new Uint8Array(1 + encoded.length);
|
|
946
|
-
result[0] = TypeTag.String;
|
|
947
|
-
result.set(encoded, 1);
|
|
948
|
-
return result;
|
|
949
|
-
}
|
|
950
|
-
if (value instanceof ArrayBuffer || value instanceof Uint8Array) {
|
|
951
|
-
const bytes = value instanceof Uint8Array ? value : new Uint8Array(value);
|
|
952
|
-
const result = new Uint8Array(1 + bytes.length + 2);
|
|
953
|
-
result[0] = TypeTag.Bytes;
|
|
954
|
-
result.set(bytes, 1);
|
|
955
|
-
result[result.length - 2] = 0;
|
|
956
|
-
result[result.length - 1] = 0;
|
|
957
|
-
return result;
|
|
958
|
-
}
|
|
959
|
-
throw new Error(`Cannot encode value of type ${typeof value} in index key`);
|
|
960
|
-
}
|
|
961
|
-
function encodeIndexKey(values) {
|
|
962
|
-
if (values.length === 0) {
|
|
963
|
-
return new ArrayBuffer(0);
|
|
964
|
-
}
|
|
965
|
-
const encoded = values.map(encodeValue);
|
|
966
|
-
const totalLength = encoded.reduce((sum, arr) => sum + arr.length, 0);
|
|
967
|
-
const result = new Uint8Array(totalLength);
|
|
968
|
-
let offset = 0;
|
|
969
|
-
for (const chunk of encoded) {
|
|
970
|
-
result.set(chunk, offset);
|
|
971
|
-
offset += chunk.length;
|
|
972
|
-
}
|
|
973
|
-
return result.buffer;
|
|
974
|
-
}
|
|
975
|
-
function compareIndexKeys(a, b) {
|
|
976
|
-
const viewA = new Uint8Array(a);
|
|
977
|
-
const viewB = new Uint8Array(b);
|
|
978
|
-
const minLen = Math.min(viewA.length, viewB.length);
|
|
979
|
-
for (let i2 = 0;i2 < minLen; i2++) {
|
|
980
|
-
if (viewA[i2] < viewB[i2])
|
|
981
|
-
return -1;
|
|
982
|
-
if (viewA[i2] > viewB[i2])
|
|
983
|
-
return 1;
|
|
984
|
-
}
|
|
985
|
-
if (viewA.length < viewB.length)
|
|
986
|
-
return -1;
|
|
987
|
-
if (viewA.length > viewB.length)
|
|
988
|
-
return 1;
|
|
989
|
-
return 0;
|
|
990
|
-
}
|
|
991
|
-
function indexKeysEqual(a, b) {
|
|
992
|
-
return compareIndexKeys(a, b) === 0;
|
|
993
|
-
}
|
|
994
|
-
var TypeTag;
|
|
995
|
-
var init_index_key_codec = __esm(() => {
|
|
996
|
-
(function(TypeTag2) {
|
|
997
|
-
TypeTag2[TypeTag2["Null"] = 0] = "Null";
|
|
998
|
-
TypeTag2[TypeTag2["False"] = 16] = "False";
|
|
999
|
-
TypeTag2[TypeTag2["True"] = 17] = "True";
|
|
1000
|
-
TypeTag2[TypeTag2["NegativeInfinity"] = 32] = "NegativeInfinity";
|
|
1001
|
-
TypeTag2[TypeTag2["NegativeNumber"] = 33] = "NegativeNumber";
|
|
1002
|
-
TypeTag2[TypeTag2["NegativeZero"] = 34] = "NegativeZero";
|
|
1003
|
-
TypeTag2[TypeTag2["Zero"] = 35] = "Zero";
|
|
1004
|
-
TypeTag2[TypeTag2["PositiveNumber"] = 36] = "PositiveNumber";
|
|
1005
|
-
TypeTag2[TypeTag2["PositiveInfinity"] = 37] = "PositiveInfinity";
|
|
1006
|
-
TypeTag2[TypeTag2["NaN"] = 38] = "NaN";
|
|
1007
|
-
TypeTag2[TypeTag2["NegativeBigInt"] = 48] = "NegativeBigInt";
|
|
1008
|
-
TypeTag2[TypeTag2["ZeroBigInt"] = 49] = "ZeroBigInt";
|
|
1009
|
-
TypeTag2[TypeTag2["PositiveBigInt"] = 50] = "PositiveBigInt";
|
|
1010
|
-
TypeTag2[TypeTag2["String"] = 64] = "String";
|
|
1011
|
-
TypeTag2[TypeTag2["Bytes"] = 80] = "Bytes";
|
|
1012
|
-
})(TypeTag || (TypeTag = {}));
|
|
1013
|
-
});
|
|
1014
|
-
|
|
1015
|
-
// ../core/dist/queryengine/indexing/index-manager.js
|
|
1016
|
-
function getFieldValue(doc, fieldPath) {
|
|
1017
|
-
const parts = fieldPath.split(".");
|
|
1018
|
-
let current = doc;
|
|
1019
|
-
for (const part of parts) {
|
|
1020
|
-
if (current === null || current === undefined) {
|
|
1021
|
-
return;
|
|
1022
|
-
}
|
|
1023
|
-
if (typeof current !== "object" || Array.isArray(current)) {
|
|
1024
|
-
return;
|
|
1025
|
-
}
|
|
1026
|
-
current = current[part];
|
|
1027
|
-
}
|
|
1028
|
-
return current;
|
|
1029
|
-
}
|
|
1030
|
-
function extractIndexKey(doc, fields) {
|
|
1031
|
-
const values = [];
|
|
1032
|
-
for (const field of fields) {
|
|
1033
|
-
const value = getFieldValue(doc, field);
|
|
1034
|
-
if (value === undefined) {
|
|
1035
|
-
return null;
|
|
1036
|
-
}
|
|
1037
|
-
values.push(value);
|
|
1038
|
-
}
|
|
1039
|
-
return encodeIndexKey(values);
|
|
1040
|
-
}
|
|
1041
|
-
function generateIndexUpdates(tableName, docId, newValue, oldValue, indexes) {
|
|
1042
|
-
const updates = [];
|
|
1043
|
-
for (const index of indexes) {
|
|
1044
|
-
const indexId = stringToHex(`${tableName}:${index.name}`);
|
|
1045
|
-
const oldKey = oldValue !== null ? extractIndexKey(oldValue, index.fields) : null;
|
|
1046
|
-
const newKey = newValue !== null ? extractIndexKey(newValue, index.fields) : null;
|
|
1047
|
-
const keyChanged = oldKey === null && newKey !== null || oldKey !== null && newKey === null || oldKey !== null && newKey !== null && !indexKeysEqual(oldKey, newKey);
|
|
1048
|
-
if (!keyChanged) {
|
|
1049
|
-
continue;
|
|
1050
|
-
}
|
|
1051
|
-
if (oldKey !== null) {
|
|
1052
|
-
updates.push({
|
|
1053
|
-
index_id: indexId,
|
|
1054
|
-
key: oldKey,
|
|
1055
|
-
value: { type: "Deleted" }
|
|
1056
|
-
});
|
|
1057
|
-
}
|
|
1058
|
-
if (newKey !== null) {
|
|
1059
|
-
updates.push({
|
|
1060
|
-
index_id: indexId,
|
|
1061
|
-
key: newKey,
|
|
1062
|
-
value: {
|
|
1063
|
-
type: "NonClustered",
|
|
1064
|
-
doc_id: docId
|
|
1065
|
-
}
|
|
1066
|
-
});
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
return updates;
|
|
1070
|
-
}
|
|
1071
|
-
function getStandardIndexes() {
|
|
1072
|
-
return [
|
|
1073
|
-
{
|
|
1074
|
-
name: "by_creation_time",
|
|
1075
|
-
fields: ["_creationTime", "_id"]
|
|
1076
|
-
},
|
|
1077
|
-
{
|
|
1078
|
-
name: "by_id",
|
|
1079
|
-
fields: ["_id"]
|
|
1080
|
-
}
|
|
1081
|
-
];
|
|
1082
|
-
}
|
|
1083
|
-
var init_index_manager = __esm(() => {
|
|
1084
|
-
init_index_key_codec();
|
|
1085
|
-
});
|
|
1086
|
-
|
|
1087
856
|
// ../core/dist/tables/interface.js
|
|
1088
857
|
function getFullTableName(tableName, componentPath) {
|
|
1089
858
|
if (!componentPath || componentPath === "") {
|
|
@@ -1114,6 +883,70 @@ var init_interface = __esm(() => {
|
|
|
1114
883
|
};
|
|
1115
884
|
});
|
|
1116
885
|
|
|
886
|
+
// ../core/dist/kernel/context-storage.js
|
|
887
|
+
function resolveFromRequire(req) {
|
|
888
|
+
for (const specifier of ["node:async_hooks", "async_hooks"]) {
|
|
889
|
+
try {
|
|
890
|
+
const mod = req(specifier);
|
|
891
|
+
if (mod?.AsyncLocalStorage) {
|
|
892
|
+
return mod.AsyncLocalStorage;
|
|
893
|
+
}
|
|
894
|
+
} catch {}
|
|
895
|
+
}
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
class ContextStorage {
|
|
900
|
+
als;
|
|
901
|
+
stack = [];
|
|
902
|
+
constructor() {
|
|
903
|
+
if (AsyncLocalStorageCtor) {
|
|
904
|
+
this.als = new AsyncLocalStorageCtor;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
getStore() {
|
|
908
|
+
if (this.als) {
|
|
909
|
+
return this.als.getStore() ?? undefined;
|
|
910
|
+
}
|
|
911
|
+
return this.stack.length > 0 ? this.stack[this.stack.length - 1] : undefined;
|
|
912
|
+
}
|
|
913
|
+
run(value, callback) {
|
|
914
|
+
if (this.als) {
|
|
915
|
+
return this.als.run(value, callback);
|
|
916
|
+
}
|
|
917
|
+
this.stack.push(value);
|
|
918
|
+
const result = callback();
|
|
919
|
+
if (result && typeof result.then === "function") {
|
|
920
|
+
return result.finally(() => {
|
|
921
|
+
this.stack.pop();
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
this.stack.pop();
|
|
925
|
+
return result;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
var resolveAsyncLocalStorage = () => {
|
|
929
|
+
const globalCtor = globalThis?.AsyncLocalStorage;
|
|
930
|
+
if (globalCtor) {
|
|
931
|
+
return globalCtor;
|
|
932
|
+
}
|
|
933
|
+
const runtimeRequire = __require;
|
|
934
|
+
if (runtimeRequire) {
|
|
935
|
+
const ctor = resolveFromRequire(runtimeRequire);
|
|
936
|
+
if (ctor) {
|
|
937
|
+
return ctor;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
const globalRequire = globalThis?.require;
|
|
941
|
+
if (typeof globalRequire === "function") {
|
|
942
|
+
return resolveFromRequire(globalRequire);
|
|
943
|
+
}
|
|
944
|
+
return;
|
|
945
|
+
}, AsyncLocalStorageCtor;
|
|
946
|
+
var init_context_storage = __esm(() => {
|
|
947
|
+
AsyncLocalStorageCtor = resolveAsyncLocalStorage();
|
|
948
|
+
});
|
|
949
|
+
|
|
1117
950
|
// ../../node_modules/convex/dist/esm/index.js
|
|
1118
951
|
var version = "1.31.7";
|
|
1119
952
|
|
|
@@ -2115,8 +1948,27 @@ var init_server = __esm(() => {
|
|
|
2115
1948
|
init_search_filter_builder();
|
|
2116
1949
|
});
|
|
2117
1950
|
|
|
2118
|
-
// ../core/dist/
|
|
2119
|
-
function
|
|
1951
|
+
// ../core/dist/kernel/missing-schema-error.js
|
|
1952
|
+
function isMissingSchemaModuleError(error) {
|
|
1953
|
+
if (!error)
|
|
1954
|
+
return false;
|
|
1955
|
+
const errorString = String(error);
|
|
1956
|
+
const isMissing = errorString.includes('Unable to resolve module "schema"') || errorString.includes("Module not found: schema") || errorString.includes('Unable to resolve module "convex/schema"');
|
|
1957
|
+
if (isMissing)
|
|
1958
|
+
return true;
|
|
1959
|
+
const causes = error.causes;
|
|
1960
|
+
if (Array.isArray(causes)) {
|
|
1961
|
+
return causes.some(isMissingSchemaModuleError);
|
|
1962
|
+
}
|
|
1963
|
+
const cause = error.cause;
|
|
1964
|
+
if (cause) {
|
|
1965
|
+
return isMissingSchemaModuleError(cause);
|
|
1966
|
+
}
|
|
1967
|
+
return false;
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
// ../core/dist/udf/analysis/udf-analyze.js
|
|
1971
|
+
function invalidUdfError(message) {
|
|
2120
1972
|
return new UdfAnalysisError(message);
|
|
2121
1973
|
}
|
|
2122
1974
|
function analyzeFunction(exported_function, exportName, modulePath) {
|
|
@@ -2923,8 +2775,9 @@ function createSystemFunctions(deps) {
|
|
|
2923
2775
|
systemListFunctions: query({
|
|
2924
2776
|
args: { componentPath: v.optional(v.string()) },
|
|
2925
2777
|
handler: async (ctx, args) => {
|
|
2926
|
-
const
|
|
2927
|
-
const
|
|
2778
|
+
const requestedComponentPath = args.componentPath ?? ctx?.componentPath ?? undefined;
|
|
2779
|
+
const normalizedComponentPath = typeof requestedComponentPath === "string" && requestedComponentPath.trim().length === 0 ? undefined : requestedComponentPath;
|
|
2780
|
+
const functions = await listSystemFunctions({ componentPath: normalizedComponentPath });
|
|
2928
2781
|
return functions.map((fn) => ({
|
|
2929
2782
|
name: fn.name,
|
|
2930
2783
|
path: fn.path,
|
|
@@ -3123,13 +2976,16 @@ function describeFieldType(node) {
|
|
|
3123
2976
|
var init_internal = __esm(() => {
|
|
3124
2977
|
init_values();
|
|
3125
2978
|
init_module_loader();
|
|
3126
|
-
init_schema_service();
|
|
3127
2979
|
init_function_introspection();
|
|
3128
2980
|
init_interface();
|
|
3129
2981
|
init_execution_log();
|
|
3130
2982
|
});
|
|
3131
2983
|
|
|
3132
2984
|
// ../core/dist/system/system-functions-module.js
|
|
2985
|
+
var exports_system_functions_module = {};
|
|
2986
|
+
__export(exports_system_functions_module, {
|
|
2987
|
+
getSystemFunctionsModule: () => getSystemFunctionsModule
|
|
2988
|
+
});
|
|
3133
2989
|
function getSystemFunctionsModule() {
|
|
3134
2990
|
return systemFunctions;
|
|
3135
2991
|
}
|
|
@@ -3162,7 +3018,23 @@ __export(exports_module_loader, {
|
|
|
3162
3018
|
clearModuleLoader: () => clearModuleLoader,
|
|
3163
3019
|
ModuleRegistry: () => ModuleRegistry
|
|
3164
3020
|
});
|
|
3165
|
-
|
|
3021
|
+
function allowConvexFunctionsInBrowser() {
|
|
3022
|
+
if (browserConvexFunctionsAllowed) {
|
|
3023
|
+
return;
|
|
3024
|
+
}
|
|
3025
|
+
browserConvexFunctionsAllowed = true;
|
|
3026
|
+
const globalAny = globalThis;
|
|
3027
|
+
if (globalAny.window && typeof globalAny.window === "object") {
|
|
3028
|
+
globalAny.window.__convexAllowFunctionsInBrowser = true;
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
async function getBuiltInSystemFunctionsModule() {
|
|
3032
|
+
if (!builtInSystemFunctionsModulePromise) {
|
|
3033
|
+
allowConvexFunctionsInBrowser();
|
|
3034
|
+
builtInSystemFunctionsModulePromise = Promise.resolve().then(() => (init_system_functions_module(), exports_system_functions_module)).then((mod) => mod.getSystemFunctionsModule());
|
|
3035
|
+
}
|
|
3036
|
+
return builtInSystemFunctionsModulePromise;
|
|
3037
|
+
}
|
|
3166
3038
|
|
|
3167
3039
|
class ModuleRegistry {
|
|
3168
3040
|
scopedLoaders = new Map;
|
|
@@ -3215,6 +3087,7 @@ class ModuleRegistry {
|
|
|
3215
3087
|
};
|
|
3216
3088
|
}
|
|
3217
3089
|
async load(request) {
|
|
3090
|
+
allowConvexFunctionsInBrowser();
|
|
3218
3091
|
const scopes = expandComponentScopes(request.componentPath);
|
|
3219
3092
|
const errors2 = [];
|
|
3220
3093
|
let attempted = false;
|
|
@@ -3306,6 +3179,8 @@ function getModuleState() {
|
|
|
3306
3179
|
function resetModuleState() {
|
|
3307
3180
|
const globalAny = globalThis;
|
|
3308
3181
|
delete globalAny[MODULE_STATE_SYMBOL];
|
|
3182
|
+
builtInSystemFunctionsModulePromise = undefined;
|
|
3183
|
+
browserConvexFunctionsAllowed = false;
|
|
3309
3184
|
}
|
|
3310
3185
|
function getModuleRegistry() {
|
|
3311
3186
|
return MODULE_REGISTRY_CONTEXT.getStore() ?? getModuleState().registry;
|
|
@@ -3340,7 +3215,7 @@ async function loadConvexModule(specifier, options = {}) {
|
|
|
3340
3215
|
return await getModuleRegistry().load(request);
|
|
3341
3216
|
} catch (error) {
|
|
3342
3217
|
if (error?.message?.includes("Unable to resolve")) {
|
|
3343
|
-
return
|
|
3218
|
+
return await getBuiltInSystemFunctionsModule();
|
|
3344
3219
|
}
|
|
3345
3220
|
throw error;
|
|
3346
3221
|
}
|
|
@@ -3569,12 +3444,12 @@ function isIterable(value) {
|
|
|
3569
3444
|
function isAsyncIterable(value) {
|
|
3570
3445
|
return value && typeof value[Symbol.asyncIterator] === "function";
|
|
3571
3446
|
}
|
|
3572
|
-
var MODULE_STATE_SYMBOL, MODULE_LOADER_METADATA_SYMBOL, MODULE_REGISTRY_CONTEXT;
|
|
3447
|
+
var MODULE_STATE_SYMBOL, MODULE_LOADER_METADATA_SYMBOL, MODULE_REGISTRY_CONTEXT, builtInSystemFunctionsModulePromise, browserConvexFunctionsAllowed = false;
|
|
3573
3448
|
var init_module_loader = __esm(() => {
|
|
3574
|
-
|
|
3449
|
+
init_context_storage();
|
|
3575
3450
|
MODULE_STATE_SYMBOL = Symbol.for("concave.moduleLoader.state");
|
|
3576
3451
|
MODULE_LOADER_METADATA_SYMBOL = Symbol.for("concave.moduleLoader.metadata");
|
|
3577
|
-
MODULE_REGISTRY_CONTEXT = new
|
|
3452
|
+
MODULE_REGISTRY_CONTEXT = new ContextStorage;
|
|
3578
3453
|
});
|
|
3579
3454
|
|
|
3580
3455
|
// ../core/dist/udf/analysis/validator.js
|
|
@@ -3829,7 +3704,6 @@ var ValidatorError;
|
|
|
3829
3704
|
var init_validator2 = __esm(() => {
|
|
3830
3705
|
init_interface();
|
|
3831
3706
|
init_module_loader();
|
|
3832
|
-
init_schema_service();
|
|
3833
3707
|
ValidatorError = class ValidatorError extends Error {
|
|
3834
3708
|
path;
|
|
3835
3709
|
constructor(message, path = "") {
|
|
@@ -3840,162 +3714,6 @@ var init_validator2 = __esm(() => {
|
|
|
3840
3714
|
};
|
|
3841
3715
|
});
|
|
3842
3716
|
|
|
3843
|
-
// ../core/dist/kernel/schema-service.js
|
|
3844
|
-
class SchemaService {
|
|
3845
|
-
cachedSchemaDefinition = undefined;
|
|
3846
|
-
tableCache = new Map;
|
|
3847
|
-
schemaValidator;
|
|
3848
|
-
componentPath;
|
|
3849
|
-
constructor(componentPath) {
|
|
3850
|
-
this.componentPath = componentPath;
|
|
3851
|
-
this.schemaValidator = new SchemaValidator(componentPath);
|
|
3852
|
-
}
|
|
3853
|
-
async validate(tableName, document) {
|
|
3854
|
-
try {
|
|
3855
|
-
await this.schemaValidator.validateDocument(tableName, document);
|
|
3856
|
-
} catch (error) {
|
|
3857
|
-
if (error instanceof ValidatorError) {
|
|
3858
|
-
throw new Error(error.message);
|
|
3859
|
-
}
|
|
3860
|
-
throw error;
|
|
3861
|
-
}
|
|
3862
|
-
}
|
|
3863
|
-
async getTableSchema(tableName) {
|
|
3864
|
-
if (this.tableCache.has(tableName)) {
|
|
3865
|
-
return this.tableCache.get(tableName) ?? null;
|
|
3866
|
-
}
|
|
3867
|
-
const schemaDefinition = await this.getSchemaDefinition();
|
|
3868
|
-
const tableSchema = schemaDefinition?.tables?.[tableName] ?? null;
|
|
3869
|
-
this.tableCache.set(tableName, tableSchema);
|
|
3870
|
-
return tableSchema;
|
|
3871
|
-
}
|
|
3872
|
-
async getIndexFieldsForTable(tableName, indexDescriptor) {
|
|
3873
|
-
if (indexDescriptor === "by_creation_time") {
|
|
3874
|
-
return ["_creationTime", "_id"];
|
|
3875
|
-
}
|
|
3876
|
-
if (indexDescriptor === "by_id") {
|
|
3877
|
-
return ["_id"];
|
|
3878
|
-
}
|
|
3879
|
-
const tableSchema = await this.getTableSchema(tableName);
|
|
3880
|
-
const dbIndexes = tableSchema?.indexes;
|
|
3881
|
-
const matchingIndex = dbIndexes?.find((idx) => idx.indexDescriptor === indexDescriptor);
|
|
3882
|
-
if (!matchingIndex) {
|
|
3883
|
-
return null;
|
|
3884
|
-
}
|
|
3885
|
-
return [...matchingIndex.fields, "_creationTime", "_id"];
|
|
3886
|
-
}
|
|
3887
|
-
async getAllIndexesForTable(tableName) {
|
|
3888
|
-
const indexes = [...getStandardIndexes()];
|
|
3889
|
-
const tableSchema = await this.getTableSchema(tableName);
|
|
3890
|
-
const schemaIndexes = tableSchema?.indexes;
|
|
3891
|
-
if (schemaIndexes) {
|
|
3892
|
-
for (const idx of schemaIndexes) {
|
|
3893
|
-
indexes.push({
|
|
3894
|
-
name: idx.indexDescriptor,
|
|
3895
|
-
fields: [...idx.fields, "_creationTime", "_id"]
|
|
3896
|
-
});
|
|
3897
|
-
}
|
|
3898
|
-
}
|
|
3899
|
-
return indexes;
|
|
3900
|
-
}
|
|
3901
|
-
async getSearchIndexConfig(tableName, indexDescriptor) {
|
|
3902
|
-
const tableSchema = await this.getTableSchema(tableName);
|
|
3903
|
-
const searchIndexes = tableSchema?.searchIndexes;
|
|
3904
|
-
return searchIndexes?.find((idx) => idx.indexDescriptor === indexDescriptor) ?? null;
|
|
3905
|
-
}
|
|
3906
|
-
async getVectorIndexConfig(tableName, indexDescriptor) {
|
|
3907
|
-
const tableSchema = await this.getTableSchema(tableName);
|
|
3908
|
-
const vectorIndexes = tableSchema?.vectorIndexes;
|
|
3909
|
-
return vectorIndexes?.find((idx) => idx.indexDescriptor === indexDescriptor) ?? null;
|
|
3910
|
-
}
|
|
3911
|
-
async getAllVectorIndexes() {
|
|
3912
|
-
const schemaDefinition = await this.getSchemaDefinition();
|
|
3913
|
-
if (!schemaDefinition?.tables) {
|
|
3914
|
-
return [];
|
|
3915
|
-
}
|
|
3916
|
-
const allVectorIndexes = [];
|
|
3917
|
-
for (const [tableName, tableSchema] of Object.entries(schemaDefinition.tables)) {
|
|
3918
|
-
const vectorIndexes = tableSchema?.vectorIndexes;
|
|
3919
|
-
if (vectorIndexes) {
|
|
3920
|
-
for (const vectorIndex of vectorIndexes) {
|
|
3921
|
-
allVectorIndexes.push({
|
|
3922
|
-
tableName,
|
|
3923
|
-
indexDescriptor: vectorIndex.indexDescriptor,
|
|
3924
|
-
vectorField: vectorIndex.vectorField,
|
|
3925
|
-
filterFields: vectorIndex.filterFields ?? []
|
|
3926
|
-
});
|
|
3927
|
-
}
|
|
3928
|
-
}
|
|
3929
|
-
}
|
|
3930
|
-
return allVectorIndexes;
|
|
3931
|
-
}
|
|
3932
|
-
async getAllSearchIndexes() {
|
|
3933
|
-
const schemaDefinition = await this.getSchemaDefinition();
|
|
3934
|
-
if (!schemaDefinition?.tables) {
|
|
3935
|
-
return [];
|
|
3936
|
-
}
|
|
3937
|
-
const allSearchIndexes = [];
|
|
3938
|
-
for (const [tableName, tableSchema] of Object.entries(schemaDefinition.tables)) {
|
|
3939
|
-
const searchIndexes = tableSchema?.searchIndexes;
|
|
3940
|
-
if (searchIndexes) {
|
|
3941
|
-
for (const searchIndex of searchIndexes) {
|
|
3942
|
-
allSearchIndexes.push({
|
|
3943
|
-
tableName,
|
|
3944
|
-
indexDescriptor: searchIndex.indexDescriptor,
|
|
3945
|
-
searchField: searchIndex.searchField,
|
|
3946
|
-
filterFields: searchIndex.filterFields ?? []
|
|
3947
|
-
});
|
|
3948
|
-
}
|
|
3949
|
-
}
|
|
3950
|
-
}
|
|
3951
|
-
return allSearchIndexes;
|
|
3952
|
-
}
|
|
3953
|
-
async getTableNames() {
|
|
3954
|
-
const schemaDefinition = await this.getSchemaDefinition();
|
|
3955
|
-
if (!schemaDefinition?.tables) {
|
|
3956
|
-
return [];
|
|
3957
|
-
}
|
|
3958
|
-
return Object.keys(schemaDefinition.tables);
|
|
3959
|
-
}
|
|
3960
|
-
async getSchemaDefinition() {
|
|
3961
|
-
if (this.cachedSchemaDefinition !== undefined) {
|
|
3962
|
-
return this.cachedSchemaDefinition;
|
|
3963
|
-
}
|
|
3964
|
-
try {
|
|
3965
|
-
const schemaModule = await loadConvexModule("schema", { hint: "schema", componentPath: this.componentPath });
|
|
3966
|
-
this.cachedSchemaDefinition = schemaModule.default ?? null;
|
|
3967
|
-
} catch (error) {
|
|
3968
|
-
if (!isMissingSchemaModuleError(error)) {
|
|
3969
|
-
console.warn("Failed to load Convex schema definition:", error);
|
|
3970
|
-
}
|
|
3971
|
-
this.cachedSchemaDefinition = null;
|
|
3972
|
-
}
|
|
3973
|
-
return this.cachedSchemaDefinition;
|
|
3974
|
-
}
|
|
3975
|
-
}
|
|
3976
|
-
function isMissingSchemaModuleError(error) {
|
|
3977
|
-
if (!error)
|
|
3978
|
-
return false;
|
|
3979
|
-
const errorString = String(error);
|
|
3980
|
-
const isMissing = errorString.includes('Unable to resolve module "schema"') || errorString.includes("Module not found: schema") || errorString.includes('Unable to resolve module "convex/schema"');
|
|
3981
|
-
if (isMissing)
|
|
3982
|
-
return true;
|
|
3983
|
-
const causes = error.causes;
|
|
3984
|
-
if (Array.isArray(causes)) {
|
|
3985
|
-
return causes.some(isMissingSchemaModuleError);
|
|
3986
|
-
}
|
|
3987
|
-
const cause = error.cause;
|
|
3988
|
-
if (cause) {
|
|
3989
|
-
return isMissingSchemaModuleError(cause);
|
|
3990
|
-
}
|
|
3991
|
-
return false;
|
|
3992
|
-
}
|
|
3993
|
-
var init_schema_service = __esm(() => {
|
|
3994
|
-
init_index_manager();
|
|
3995
|
-
init_validator2();
|
|
3996
|
-
init_module_loader();
|
|
3997
|
-
});
|
|
3998
|
-
|
|
3999
3717
|
// ../core/dist/id-codec/base32.js
|
|
4000
3718
|
function base32Encode(data) {
|
|
4001
3719
|
if (data.length === 0)
|
|
@@ -4159,6 +3877,12 @@ function verifyFletcher16(data, checksum) {
|
|
|
4159
3877
|
return computed[0] === checksum[0] && computed[1] === checksum[1];
|
|
4160
3878
|
}
|
|
4161
3879
|
|
|
3880
|
+
// ../core/dist/utils/crypto.js
|
|
3881
|
+
var weakRandomState;
|
|
3882
|
+
var init_crypto = __esm(() => {
|
|
3883
|
+
weakRandomState = (Date.now() ^ 2654435769) >>> 0;
|
|
3884
|
+
});
|
|
3885
|
+
|
|
4162
3886
|
// ../core/dist/id-codec/document-id.js
|
|
4163
3887
|
function encodeDocumentId(tableNumber, internalId) {
|
|
4164
3888
|
if (internalId.length !== INTERNAL_ID_LENGTH) {
|
|
@@ -4215,10 +3939,10 @@ function internalIdToHex(internalId) {
|
|
|
4215
3939
|
}
|
|
4216
3940
|
return hex;
|
|
4217
3941
|
}
|
|
4218
|
-
var INTERNAL_ID_LENGTH = 16, MIN_ENCODED_LENGTH = 31, MAX_ENCODED_LENGTH = 37
|
|
3942
|
+
var INTERNAL_ID_LENGTH = 16, MIN_ENCODED_LENGTH = 31, MAX_ENCODED_LENGTH = 37;
|
|
4219
3943
|
var init_document_id = __esm(() => {
|
|
4220
3944
|
init_base32();
|
|
4221
|
-
|
|
3945
|
+
init_crypto();
|
|
4222
3946
|
});
|
|
4223
3947
|
|
|
4224
3948
|
// ../../node_modules/postgres/src/query.js
|
|
@@ -6211,12 +5935,17 @@ var init_src = __esm(() => {
|
|
|
6211
5935
|
src_default = Postgres;
|
|
6212
5936
|
});
|
|
6213
5937
|
|
|
6214
|
-
// ../../node_modules/
|
|
6215
|
-
var
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
var
|
|
6219
|
-
var
|
|
5938
|
+
// ../../node_modules/sql-escaper/lib/index.js
|
|
5939
|
+
var require_lib = __commonJS((exports) => {
|
|
5940
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5941
|
+
exports.raw = exports.format = exports.escape = exports.arrayToList = exports.bufferToString = exports.objectToValues = exports.escapeId = exports.dateToString = undefined;
|
|
5942
|
+
var node_buffer_1 = __require("buffer");
|
|
5943
|
+
var regex = {
|
|
5944
|
+
backtick: /`/g,
|
|
5945
|
+
dot: /\./g,
|
|
5946
|
+
timezone: /([+\-\s])(\d\d):?(\d\d)?/,
|
|
5947
|
+
escapeChars: /[\0\b\t\n\r\x1a"'\\]/g
|
|
5948
|
+
};
|
|
6220
5949
|
var CHARS_ESCAPE_MAP = {
|
|
6221
5950
|
"\x00": "\\0",
|
|
6222
5951
|
"\b": "\\b",
|
|
@@ -6228,185 +5957,311 @@ var require_SqlString = __commonJS((exports) => {
|
|
|
6228
5957
|
"'": "\\'",
|
|
6229
5958
|
"\\": "\\\\"
|
|
6230
5959
|
};
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
}
|
|
5960
|
+
var charCode = {
|
|
5961
|
+
singleQuote: 39,
|
|
5962
|
+
backslash: 92,
|
|
5963
|
+
dash: 45,
|
|
5964
|
+
slash: 47,
|
|
5965
|
+
asterisk: 42,
|
|
5966
|
+
questionMark: 63,
|
|
5967
|
+
newline: 10,
|
|
5968
|
+
space: 32,
|
|
5969
|
+
tab: 9,
|
|
5970
|
+
carriageReturn: 13
|
|
6243
5971
|
};
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
5972
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5973
|
+
var isWordChar = (code2) => code2 >= 65 && code2 <= 90 || code2 >= 97 && code2 <= 122 || code2 >= 48 && code2 <= 57 || code2 === 95;
|
|
5974
|
+
var isWhitespace = (code2) => code2 === charCode.space || code2 === charCode.tab || code2 === charCode.newline || code2 === charCode.carriageReturn;
|
|
5975
|
+
var hasOnlyWhitespaceBetween = (sql, start, end) => {
|
|
5976
|
+
if (start >= end)
|
|
5977
|
+
return true;
|
|
5978
|
+
for (let i2 = start;i2 < end; i2++) {
|
|
5979
|
+
const code2 = sql.charCodeAt(i2);
|
|
5980
|
+
if (code2 !== charCode.space && code2 !== charCode.tab && code2 !== charCode.newline && code2 !== charCode.carriageReturn)
|
|
5981
|
+
return false;
|
|
6247
5982
|
}
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
return
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
5983
|
+
return true;
|
|
5984
|
+
};
|
|
5985
|
+
var toLower = (code2) => code2 | 32;
|
|
5986
|
+
var matchesWord = (sql, position, word, length) => {
|
|
5987
|
+
for (let offset = 0;offset < word.length; offset++)
|
|
5988
|
+
if (toLower(sql.charCodeAt(position + offset)) !== word.charCodeAt(offset))
|
|
5989
|
+
return false;
|
|
5990
|
+
return (position === 0 || !isWordChar(sql.charCodeAt(position - 1))) && (position + word.length >= length || !isWordChar(sql.charCodeAt(position + word.length)));
|
|
5991
|
+
};
|
|
5992
|
+
var skipSqlContext = (sql, position) => {
|
|
5993
|
+
const currentChar = sql.charCodeAt(position);
|
|
5994
|
+
const nextChar = sql.charCodeAt(position + 1);
|
|
5995
|
+
if (currentChar === charCode.singleQuote) {
|
|
5996
|
+
for (let cursor2 = position + 1;cursor2 < sql.length; cursor2++) {
|
|
5997
|
+
if (sql.charCodeAt(cursor2) === charCode.backslash)
|
|
5998
|
+
cursor2++;
|
|
5999
|
+
else if (sql.charCodeAt(cursor2) === charCode.singleQuote)
|
|
6000
|
+
return cursor2 + 1;
|
|
6001
|
+
}
|
|
6002
|
+
return sql.length;
|
|
6003
|
+
}
|
|
6004
|
+
if (currentChar === charCode.dash && nextChar === charCode.dash) {
|
|
6005
|
+
const lineBreak = sql.indexOf(`
|
|
6006
|
+
`, position + 2);
|
|
6007
|
+
return lineBreak === -1 ? sql.length : lineBreak + 1;
|
|
6008
|
+
}
|
|
6009
|
+
if (currentChar === charCode.slash && nextChar === charCode.asterisk) {
|
|
6010
|
+
const commentEnd = sql.indexOf("*/", position + 2);
|
|
6011
|
+
return commentEnd === -1 ? sql.length : commentEnd + 2;
|
|
6269
6012
|
}
|
|
6013
|
+
return -1;
|
|
6270
6014
|
};
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
for (
|
|
6274
|
-
|
|
6275
|
-
if (
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6015
|
+
var findNextPlaceholder = (sql, start) => {
|
|
6016
|
+
const sqlLength = sql.length;
|
|
6017
|
+
for (let position = start;position < sqlLength; position++) {
|
|
6018
|
+
const code2 = sql.charCodeAt(position);
|
|
6019
|
+
if (code2 === charCode.questionMark)
|
|
6020
|
+
return position;
|
|
6021
|
+
if (code2 === charCode.singleQuote || code2 === charCode.dash || code2 === charCode.slash) {
|
|
6022
|
+
const contextEnd = skipSqlContext(sql, position);
|
|
6023
|
+
if (contextEnd !== -1)
|
|
6024
|
+
position = contextEnd - 1;
|
|
6279
6025
|
}
|
|
6280
6026
|
}
|
|
6281
|
-
return
|
|
6027
|
+
return -1;
|
|
6282
6028
|
};
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
if (
|
|
6298
|
-
|
|
6029
|
+
var findSetKeyword = (sql, startFrom = 0) => {
|
|
6030
|
+
const length = sql.length;
|
|
6031
|
+
for (let position = startFrom;position < length; position++) {
|
|
6032
|
+
const code2 = sql.charCodeAt(position);
|
|
6033
|
+
const lower = code2 | 32;
|
|
6034
|
+
if (code2 === charCode.singleQuote || code2 === charCode.dash || code2 === charCode.slash) {
|
|
6035
|
+
const contextEnd = skipSqlContext(sql, position);
|
|
6036
|
+
if (contextEnd !== -1) {
|
|
6037
|
+
position = contextEnd - 1;
|
|
6038
|
+
continue;
|
|
6039
|
+
}
|
|
6040
|
+
}
|
|
6041
|
+
if (lower === 115 && matchesWord(sql, position, "set", length))
|
|
6042
|
+
return position + 3;
|
|
6043
|
+
if (lower === 107 && matchesWord(sql, position, "key", length)) {
|
|
6044
|
+
let cursor2 = position + 3;
|
|
6045
|
+
while (cursor2 < length && isWhitespace(sql.charCodeAt(cursor2)))
|
|
6046
|
+
cursor2++;
|
|
6047
|
+
if (matchesWord(sql, cursor2, "update", length))
|
|
6048
|
+
return cursor2 + 6;
|
|
6299
6049
|
}
|
|
6300
|
-
var value = len2 === 2 ? SqlString.escapeId(values2[valuesIndex]) : SqlString.escape(values2[valuesIndex], stringifyObjects, timeZone);
|
|
6301
|
-
result += sql.slice(chunkIndex, match.index) + value;
|
|
6302
|
-
chunkIndex = placeholdersRegex.lastIndex;
|
|
6303
|
-
valuesIndex++;
|
|
6304
6050
|
}
|
|
6305
|
-
|
|
6306
|
-
|
|
6051
|
+
return -1;
|
|
6052
|
+
};
|
|
6053
|
+
var isDate = (value) => Object.prototype.toString.call(value) === "[object Date]";
|
|
6054
|
+
var hasSqlString = (value) => typeof value === "object" && value !== null && ("toSqlString" in value) && typeof value.toSqlString === "function";
|
|
6055
|
+
var escapeString = (value) => {
|
|
6056
|
+
regex.escapeChars.lastIndex = 0;
|
|
6057
|
+
let chunkIndex = 0;
|
|
6058
|
+
let escapedValue = "";
|
|
6059
|
+
let match;
|
|
6060
|
+
for (match = regex.escapeChars.exec(value);match !== null; match = regex.escapeChars.exec(value)) {
|
|
6061
|
+
escapedValue += value.slice(chunkIndex, match.index);
|
|
6062
|
+
escapedValue += CHARS_ESCAPE_MAP[match[0]];
|
|
6063
|
+
chunkIndex = regex.escapeChars.lastIndex;
|
|
6064
|
+
}
|
|
6065
|
+
if (chunkIndex === 0)
|
|
6066
|
+
return `'${value}'`;
|
|
6067
|
+
if (chunkIndex < value.length)
|
|
6068
|
+
return `'${escapedValue}${value.slice(chunkIndex)}'`;
|
|
6069
|
+
return `'${escapedValue}'`;
|
|
6070
|
+
};
|
|
6071
|
+
var pad2 = (value) => value < 10 ? "0" + value : "" + value;
|
|
6072
|
+
var pad3 = (value) => value < 10 ? "00" + value : value < 100 ? "0" + value : "" + value;
|
|
6073
|
+
var pad4 = (value) => value < 10 ? "000" + value : value < 100 ? "00" + value : value < 1000 ? "0" + value : "" + value;
|
|
6074
|
+
var convertTimezone = (tz) => {
|
|
6075
|
+
if (tz === "Z")
|
|
6076
|
+
return 0;
|
|
6077
|
+
const timezoneMatch = tz.match(regex.timezone);
|
|
6078
|
+
if (timezoneMatch)
|
|
6079
|
+
return (timezoneMatch[1] === "-" ? -1 : 1) * (Number.parseInt(timezoneMatch[2], 10) + (timezoneMatch[3] ? Number.parseInt(timezoneMatch[3], 10) : 0) / 60) * 60;
|
|
6080
|
+
return false;
|
|
6081
|
+
};
|
|
6082
|
+
var dateToString = (date, timezone) => {
|
|
6083
|
+
if (Number.isNaN(date.getTime()))
|
|
6084
|
+
return "NULL";
|
|
6085
|
+
let year;
|
|
6086
|
+
let month;
|
|
6087
|
+
let day;
|
|
6088
|
+
let hour;
|
|
6089
|
+
let minute;
|
|
6090
|
+
let second;
|
|
6091
|
+
let millisecond;
|
|
6092
|
+
if (timezone === "local") {
|
|
6093
|
+
year = date.getFullYear();
|
|
6094
|
+
month = date.getMonth() + 1;
|
|
6095
|
+
day = date.getDate();
|
|
6096
|
+
hour = date.getHours();
|
|
6097
|
+
minute = date.getMinutes();
|
|
6098
|
+
second = date.getSeconds();
|
|
6099
|
+
millisecond = date.getMilliseconds();
|
|
6100
|
+
} else {
|
|
6101
|
+
const timezoneOffsetMinutes = convertTimezone(timezone);
|
|
6102
|
+
let time = date.getTime();
|
|
6103
|
+
if (timezoneOffsetMinutes !== false && timezoneOffsetMinutes !== 0)
|
|
6104
|
+
time += timezoneOffsetMinutes * 60000;
|
|
6105
|
+
const adjustedDate = new Date(time);
|
|
6106
|
+
year = adjustedDate.getUTCFullYear();
|
|
6107
|
+
month = adjustedDate.getUTCMonth() + 1;
|
|
6108
|
+
day = adjustedDate.getUTCDate();
|
|
6109
|
+
hour = adjustedDate.getUTCHours();
|
|
6110
|
+
minute = adjustedDate.getUTCMinutes();
|
|
6111
|
+
second = adjustedDate.getUTCSeconds();
|
|
6112
|
+
millisecond = adjustedDate.getUTCMilliseconds();
|
|
6113
|
+
}
|
|
6114
|
+
return escapeString(pad4(year) + "-" + pad2(month) + "-" + pad2(day) + " " + pad2(hour) + ":" + pad2(minute) + ":" + pad2(second) + "." + pad3(millisecond));
|
|
6115
|
+
};
|
|
6116
|
+
exports.dateToString = dateToString;
|
|
6117
|
+
var escapeId = (value, forbidQualified) => {
|
|
6118
|
+
if (Array.isArray(value)) {
|
|
6119
|
+
const length = value.length;
|
|
6120
|
+
const parts = new Array(length);
|
|
6121
|
+
for (let i2 = 0;i2 < length; i2++)
|
|
6122
|
+
parts[i2] = (0, exports.escapeId)(value[i2], forbidQualified);
|
|
6123
|
+
return parts.join(", ");
|
|
6124
|
+
}
|
|
6125
|
+
const identifier = String(value);
|
|
6126
|
+
const hasJsonOperator = identifier.indexOf("->") !== -1;
|
|
6127
|
+
if (forbidQualified || hasJsonOperator) {
|
|
6128
|
+
if (identifier.indexOf("`") === -1)
|
|
6129
|
+
return `\`${identifier}\``;
|
|
6130
|
+
return `\`${identifier.replace(regex.backtick, "``")}\``;
|
|
6131
|
+
}
|
|
6132
|
+
if (identifier.indexOf("`") === -1 && identifier.indexOf(".") === -1)
|
|
6133
|
+
return `\`${identifier}\``;
|
|
6134
|
+
return `\`${identifier.replace(regex.backtick, "``").replace(regex.dot, "`.`")}\``;
|
|
6135
|
+
};
|
|
6136
|
+
exports.escapeId = escapeId;
|
|
6137
|
+
var objectToValues = (object, timezone) => {
|
|
6138
|
+
const keys = Object.keys(object);
|
|
6139
|
+
const keysLength = keys.length;
|
|
6140
|
+
if (keysLength === 0)
|
|
6141
|
+
return "";
|
|
6142
|
+
let sql = "";
|
|
6143
|
+
for (let i2 = 0;i2 < keysLength; i2++) {
|
|
6144
|
+
const key = keys[i2];
|
|
6145
|
+
const value = object[key];
|
|
6146
|
+
if (typeof value === "function")
|
|
6147
|
+
continue;
|
|
6148
|
+
if (sql.length > 0)
|
|
6149
|
+
sql += ", ";
|
|
6150
|
+
sql += (0, exports.escapeId)(key);
|
|
6151
|
+
sql += " = ";
|
|
6152
|
+
sql += (0, exports.escape)(value, true, timezone);
|
|
6307
6153
|
}
|
|
6308
|
-
|
|
6309
|
-
|
|
6154
|
+
return sql;
|
|
6155
|
+
};
|
|
6156
|
+
exports.objectToValues = objectToValues;
|
|
6157
|
+
var bufferToString = (buffer2) => `X${escapeString(buffer2.toString("hex"))}`;
|
|
6158
|
+
exports.bufferToString = bufferToString;
|
|
6159
|
+
var arrayToList = (array, timezone) => {
|
|
6160
|
+
const length = array.length;
|
|
6161
|
+
const parts = new Array(length);
|
|
6162
|
+
for (let i2 = 0;i2 < length; i2++) {
|
|
6163
|
+
const value = array[i2];
|
|
6164
|
+
if (Array.isArray(value))
|
|
6165
|
+
parts[i2] = `(${(0, exports.arrayToList)(value, timezone)})`;
|
|
6166
|
+
else
|
|
6167
|
+
parts[i2] = (0, exports.escape)(value, true, timezone);
|
|
6310
6168
|
}
|
|
6311
|
-
return
|
|
6169
|
+
return parts.join(", ");
|
|
6312
6170
|
};
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
if (
|
|
6171
|
+
exports.arrayToList = arrayToList;
|
|
6172
|
+
var escape2 = (value, stringifyObjects, timezone) => {
|
|
6173
|
+
if (value === undefined || value === null)
|
|
6316
6174
|
return "NULL";
|
|
6175
|
+
switch (typeof value) {
|
|
6176
|
+
case "boolean":
|
|
6177
|
+
return value ? "true" : "false";
|
|
6178
|
+
case "number":
|
|
6179
|
+
case "bigint":
|
|
6180
|
+
return value + "";
|
|
6181
|
+
case "object": {
|
|
6182
|
+
if (isDate(value))
|
|
6183
|
+
return (0, exports.dateToString)(value, timezone || "local");
|
|
6184
|
+
if (Array.isArray(value))
|
|
6185
|
+
return (0, exports.arrayToList)(value, timezone);
|
|
6186
|
+
if (node_buffer_1.Buffer.isBuffer(value))
|
|
6187
|
+
return (0, exports.bufferToString)(value);
|
|
6188
|
+
if (value instanceof Uint8Array)
|
|
6189
|
+
return (0, exports.bufferToString)(node_buffer_1.Buffer.from(value));
|
|
6190
|
+
if (hasSqlString(value))
|
|
6191
|
+
return String(value.toSqlString());
|
|
6192
|
+
if (!(stringifyObjects === undefined || stringifyObjects === null))
|
|
6193
|
+
return escapeString(String(value));
|
|
6194
|
+
if (isRecord(value))
|
|
6195
|
+
return (0, exports.objectToValues)(value, timezone);
|
|
6196
|
+
return escapeString(String(value));
|
|
6197
|
+
}
|
|
6198
|
+
case "string":
|
|
6199
|
+
return escapeString(value);
|
|
6200
|
+
default:
|
|
6201
|
+
return escapeString(String(value));
|
|
6317
6202
|
}
|
|
6318
|
-
var year;
|
|
6319
|
-
var month;
|
|
6320
|
-
var day;
|
|
6321
|
-
var hour;
|
|
6322
|
-
var minute;
|
|
6323
|
-
var second;
|
|
6324
|
-
var millisecond;
|
|
6325
|
-
if (timeZone === "local") {
|
|
6326
|
-
year = dt.getFullYear();
|
|
6327
|
-
month = dt.getMonth() + 1;
|
|
6328
|
-
day = dt.getDate();
|
|
6329
|
-
hour = dt.getHours();
|
|
6330
|
-
minute = dt.getMinutes();
|
|
6331
|
-
second = dt.getSeconds();
|
|
6332
|
-
millisecond = dt.getMilliseconds();
|
|
6333
|
-
} else {
|
|
6334
|
-
var tz = convertTimezone(timeZone);
|
|
6335
|
-
if (tz !== false && tz !== 0) {
|
|
6336
|
-
dt.setTime(dt.getTime() + tz * 60000);
|
|
6337
|
-
}
|
|
6338
|
-
year = dt.getUTCFullYear();
|
|
6339
|
-
month = dt.getUTCMonth() + 1;
|
|
6340
|
-
day = dt.getUTCDate();
|
|
6341
|
-
hour = dt.getUTCHours();
|
|
6342
|
-
minute = dt.getUTCMinutes();
|
|
6343
|
-
second = dt.getUTCSeconds();
|
|
6344
|
-
millisecond = dt.getUTCMilliseconds();
|
|
6345
|
-
}
|
|
6346
|
-
var str = zeroPad(year, 4) + "-" + zeroPad(month, 2) + "-" + zeroPad(day, 2) + " " + zeroPad(hour, 2) + ":" + zeroPad(minute, 2) + ":" + zeroPad(second, 2) + "." + zeroPad(millisecond, 3);
|
|
6347
|
-
return escapeString(str);
|
|
6348
6203
|
};
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6204
|
+
exports.escape = escape2;
|
|
6205
|
+
var format = (sql, values2, stringifyObjects, timezone) => {
|
|
6206
|
+
if (values2 === undefined || values2 === null)
|
|
6207
|
+
return sql;
|
|
6208
|
+
const valuesArray = Array.isArray(values2) ? values2 : [values2];
|
|
6209
|
+
const length = valuesArray.length;
|
|
6210
|
+
let setIndex = -2;
|
|
6211
|
+
let result = "";
|
|
6212
|
+
let chunkIndex = 0;
|
|
6213
|
+
let valuesIndex = 0;
|
|
6214
|
+
let placeholderPosition = findNextPlaceholder(sql, 0);
|
|
6215
|
+
while (valuesIndex < length && placeholderPosition !== -1) {
|
|
6216
|
+
let placeholderEnd = placeholderPosition + 1;
|
|
6217
|
+
let escapedValue;
|
|
6218
|
+
while (sql.charCodeAt(placeholderEnd) === 63)
|
|
6219
|
+
placeholderEnd++;
|
|
6220
|
+
const placeholderLength = placeholderEnd - placeholderPosition;
|
|
6221
|
+
const currentValue = valuesArray[valuesIndex];
|
|
6222
|
+
if (placeholderLength > 2) {
|
|
6223
|
+
placeholderPosition = findNextPlaceholder(sql, placeholderEnd);
|
|
6357
6224
|
continue;
|
|
6358
6225
|
}
|
|
6359
|
-
|
|
6226
|
+
if (placeholderLength === 2)
|
|
6227
|
+
escapedValue = (0, exports.escapeId)(currentValue);
|
|
6228
|
+
else if (typeof currentValue === "number")
|
|
6229
|
+
escapedValue = `${currentValue}`;
|
|
6230
|
+
else if (typeof currentValue === "object" && currentValue !== null && !stringifyObjects) {
|
|
6231
|
+
if (setIndex === -2)
|
|
6232
|
+
setIndex = findSetKeyword(sql);
|
|
6233
|
+
if (setIndex !== -1 && setIndex <= placeholderPosition && hasOnlyWhitespaceBetween(sql, setIndex, placeholderPosition) && !hasSqlString(currentValue) && !Array.isArray(currentValue) && !node_buffer_1.Buffer.isBuffer(currentValue) && !(currentValue instanceof Uint8Array) && !isDate(currentValue) && isRecord(currentValue)) {
|
|
6234
|
+
escapedValue = (0, exports.objectToValues)(currentValue, timezone);
|
|
6235
|
+
setIndex = findSetKeyword(sql, placeholderEnd);
|
|
6236
|
+
} else
|
|
6237
|
+
escapedValue = (0, exports.escape)(currentValue, true, timezone);
|
|
6238
|
+
} else
|
|
6239
|
+
escapedValue = (0, exports.escape)(currentValue, stringifyObjects, timezone);
|
|
6240
|
+
result += sql.slice(chunkIndex, placeholderPosition);
|
|
6241
|
+
result += escapedValue;
|
|
6242
|
+
chunkIndex = placeholderEnd;
|
|
6243
|
+
valuesIndex++;
|
|
6244
|
+
placeholderPosition = findNextPlaceholder(sql, placeholderEnd);
|
|
6360
6245
|
}
|
|
6361
|
-
|
|
6246
|
+
if (chunkIndex === 0)
|
|
6247
|
+
return sql;
|
|
6248
|
+
if (chunkIndex < sql.length)
|
|
6249
|
+
return result + sql.slice(chunkIndex);
|
|
6250
|
+
return result;
|
|
6362
6251
|
};
|
|
6363
|
-
|
|
6364
|
-
|
|
6252
|
+
exports.format = format;
|
|
6253
|
+
var raw = (sql) => {
|
|
6254
|
+
if (typeof sql !== "string")
|
|
6365
6255
|
throw new TypeError("argument sql must be a string");
|
|
6366
|
-
}
|
|
6367
6256
|
return {
|
|
6368
|
-
toSqlString:
|
|
6369
|
-
return sql;
|
|
6370
|
-
}
|
|
6257
|
+
toSqlString: () => sql
|
|
6371
6258
|
};
|
|
6372
6259
|
};
|
|
6373
|
-
|
|
6374
|
-
var chunkIndex = CHARS_GLOBAL_REGEXP.lastIndex = 0;
|
|
6375
|
-
var escapedVal = "";
|
|
6376
|
-
var match;
|
|
6377
|
-
while (match = CHARS_GLOBAL_REGEXP.exec(val)) {
|
|
6378
|
-
escapedVal += val.slice(chunkIndex, match.index) + CHARS_ESCAPE_MAP[match[0]];
|
|
6379
|
-
chunkIndex = CHARS_GLOBAL_REGEXP.lastIndex;
|
|
6380
|
-
}
|
|
6381
|
-
if (chunkIndex === 0) {
|
|
6382
|
-
return "'" + val + "'";
|
|
6383
|
-
}
|
|
6384
|
-
if (chunkIndex < val.length) {
|
|
6385
|
-
return "'" + escapedVal + val.slice(chunkIndex) + "'";
|
|
6386
|
-
}
|
|
6387
|
-
return "'" + escapedVal + "'";
|
|
6388
|
-
}
|
|
6389
|
-
function zeroPad(number, length) {
|
|
6390
|
-
number = number.toString();
|
|
6391
|
-
while (number.length < length) {
|
|
6392
|
-
number = "0" + number;
|
|
6393
|
-
}
|
|
6394
|
-
return number;
|
|
6395
|
-
}
|
|
6396
|
-
function convertTimezone(tz) {
|
|
6397
|
-
if (tz === "Z") {
|
|
6398
|
-
return 0;
|
|
6399
|
-
}
|
|
6400
|
-
var m = tz.match(/([\+\-\s])(\d\d):?(\d\d)?/);
|
|
6401
|
-
if (m) {
|
|
6402
|
-
return (m[1] === "-" ? -1 : 1) * (parseInt(m[2], 10) + (m[3] ? parseInt(m[3], 10) : 0) / 60) * 60;
|
|
6403
|
-
}
|
|
6404
|
-
return false;
|
|
6405
|
-
}
|
|
6260
|
+
exports.raw = raw;
|
|
6406
6261
|
});
|
|
6407
6262
|
|
|
6408
6263
|
// ../../node_modules/lru.min/lib/index.js
|
|
6409
|
-
var
|
|
6264
|
+
var require_lib2 = __commonJS((exports) => {
|
|
6410
6265
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6411
6266
|
exports.createLRU = undefined;
|
|
6412
6267
|
var createLRU = (options) => {
|
|
@@ -6641,7 +6496,7 @@ var require_lib = __commonJS((exports) => {
|
|
|
6641
6496
|
|
|
6642
6497
|
// ../../node_modules/mysql2/lib/parsers/parser_cache.js
|
|
6643
6498
|
var require_parser_cache = __commonJS((exports, module) => {
|
|
6644
|
-
var { createLRU } =
|
|
6499
|
+
var { createLRU } = require_lib2();
|
|
6645
6500
|
var parserCache = createLRU({
|
|
6646
6501
|
max: 15000
|
|
6647
6502
|
});
|
|
@@ -15436,7 +15291,7 @@ var require_streams = __commonJS((exports, module) => {
|
|
|
15436
15291
|
});
|
|
15437
15292
|
|
|
15438
15293
|
// ../../node_modules/iconv-lite/lib/index.js
|
|
15439
|
-
var
|
|
15294
|
+
var require_lib3 = __commonJS((exports, module) => {
|
|
15440
15295
|
var Buffer2 = require_safer().Buffer;
|
|
15441
15296
|
var bomHandling = require_bom_handling();
|
|
15442
15297
|
var mergeModules = require_merge_exports();
|
|
@@ -15563,8 +15418,8 @@ var require_lib2 = __commonJS((exports, module) => {
|
|
|
15563
15418
|
|
|
15564
15419
|
// ../../node_modules/mysql2/lib/parsers/string.js
|
|
15565
15420
|
var require_string = __commonJS((exports) => {
|
|
15566
|
-
var Iconv =
|
|
15567
|
-
var { createLRU } =
|
|
15421
|
+
var Iconv = require_lib3();
|
|
15422
|
+
var { createLRU } = require_lib2();
|
|
15568
15423
|
var decoderCache = createLRU({
|
|
15569
15424
|
max: 500
|
|
15570
15425
|
});
|
|
@@ -21283,7 +21138,7 @@ var require_commands2 = __commonJS((exports, module) => {
|
|
|
21283
21138
|
var require_package = __commonJS((exports, module) => {
|
|
21284
21139
|
module.exports = {
|
|
21285
21140
|
name: "mysql2",
|
|
21286
|
-
version: "3.
|
|
21141
|
+
version: "3.17.1",
|
|
21287
21142
|
description: "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",
|
|
21288
21143
|
main: "index.js",
|
|
21289
21144
|
typings: "typings/mysql/index",
|
|
@@ -21343,7 +21198,7 @@ var require_package = __commonJS((exports, module) => {
|
|
|
21343
21198
|
"lru.min": "^1.1.3",
|
|
21344
21199
|
"named-placeholders": "^1.1.6",
|
|
21345
21200
|
"seq-queue": "^0.0.5",
|
|
21346
|
-
|
|
21201
|
+
"sql-escaper": "^1.3.2"
|
|
21347
21202
|
},
|
|
21348
21203
|
devDependencies: {
|
|
21349
21204
|
"@eslint/eslintrc": "^3.3.3",
|
|
@@ -24482,7 +24337,7 @@ var require_proxies = __commonJS((exports) => {
|
|
|
24482
24337
|
});
|
|
24483
24338
|
|
|
24484
24339
|
// ../../node_modules/aws-ssl-profiles/lib/index.js
|
|
24485
|
-
var
|
|
24340
|
+
var require_lib4 = __commonJS((exports, module) => {
|
|
24486
24341
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24487
24342
|
var defaults_js_1 = require_defaults();
|
|
24488
24343
|
var proxies_js_1 = require_proxies();
|
|
@@ -24499,7 +24354,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
24499
24354
|
|
|
24500
24355
|
// ../../node_modules/mysql2/lib/constants/ssl_profiles.js
|
|
24501
24356
|
var require_ssl_profiles = __commonJS((exports) => {
|
|
24502
|
-
var awsCaBundle =
|
|
24357
|
+
var awsCaBundle = require_lib4();
|
|
24503
24358
|
exports["Amazon RDS"] = {
|
|
24504
24359
|
ca: awsCaBundle.ca
|
|
24505
24360
|
};
|
|
@@ -24815,7 +24670,7 @@ var require_named_placeholders = __commonJS((exports, module) => {
|
|
|
24815
24670
|
cache = config.cache;
|
|
24816
24671
|
}
|
|
24817
24672
|
if (config.cache !== false && !cache) {
|
|
24818
|
-
cache =
|
|
24673
|
+
cache = require_lib2().createLRU({ max: ncache });
|
|
24819
24674
|
}
|
|
24820
24675
|
function toArrayParams(tree, params) {
|
|
24821
24676
|
const arr = [];
|
|
@@ -24909,8 +24764,8 @@ var require_connection = __commonJS((exports, module) => {
|
|
|
24909
24764
|
var EventEmitter = __require("events").EventEmitter;
|
|
24910
24765
|
var Readable = __require("stream").Readable;
|
|
24911
24766
|
var Queue2 = require_denque();
|
|
24912
|
-
var SqlString =
|
|
24913
|
-
var { createLRU } =
|
|
24767
|
+
var SqlString = require_lib();
|
|
24768
|
+
var { createLRU } = require_lib2();
|
|
24914
24769
|
var PacketParser = require_packet_parser();
|
|
24915
24770
|
var Packets = require_packets();
|
|
24916
24771
|
var Commands = require_commands2();
|
|
@@ -25974,7 +25829,7 @@ var require_pool_connection3 = __commonJS((exports, module) => {
|
|
|
25974
25829
|
// ../../node_modules/mysql2/lib/base/pool.js
|
|
25975
25830
|
var require_pool = __commonJS((exports, module) => {
|
|
25976
25831
|
var process2 = __require("process");
|
|
25977
|
-
var SqlString =
|
|
25832
|
+
var SqlString = require_lib();
|
|
25978
25833
|
var EventEmitter = __require("events").EventEmitter;
|
|
25979
25834
|
var PoolConnection = require_pool_connection3();
|
|
25980
25835
|
var Queue2 = require_denque();
|
|
@@ -26678,7 +26533,7 @@ var require_pool_cluster2 = __commonJS((exports, module) => {
|
|
|
26678
26533
|
|
|
26679
26534
|
// ../../node_modules/mysql2/promise.js
|
|
26680
26535
|
var require_promise = __commonJS((exports) => {
|
|
26681
|
-
var SqlString =
|
|
26536
|
+
var SqlString = require_lib();
|
|
26682
26537
|
var EventEmitter = __require("events").EventEmitter;
|
|
26683
26538
|
var parserCache = require_parser_cache();
|
|
26684
26539
|
var PoolCluster = require_pool_cluster();
|
|
@@ -26745,125 +26600,481 @@ var require_promise = __commonJS((exports) => {
|
|
|
26745
26600
|
if (typeof args === "function") {
|
|
26746
26601
|
throw new Error("Callback function is not available with promise clients.");
|
|
26747
26602
|
}
|
|
26748
|
-
return new this.Promise((resolve, reject) => {
|
|
26749
|
-
const done = makeDoneCb(resolve, reject, localErr);
|
|
26750
|
-
corePoolCluster.query(sql, args, done);
|
|
26751
|
-
});
|
|
26603
|
+
return new this.Promise((resolve, reject) => {
|
|
26604
|
+
const done = makeDoneCb(resolve, reject, localErr);
|
|
26605
|
+
corePoolCluster.query(sql, args, done);
|
|
26606
|
+
});
|
|
26607
|
+
}
|
|
26608
|
+
execute(sql, args) {
|
|
26609
|
+
const corePoolCluster = this.poolCluster;
|
|
26610
|
+
const localErr = new Error;
|
|
26611
|
+
if (typeof args === "function") {
|
|
26612
|
+
throw new Error("Callback function is not available with promise clients.");
|
|
26613
|
+
}
|
|
26614
|
+
return new this.Promise((resolve, reject) => {
|
|
26615
|
+
const done = makeDoneCb(resolve, reject, localErr);
|
|
26616
|
+
corePoolCluster.execute(sql, args, done);
|
|
26617
|
+
});
|
|
26618
|
+
}
|
|
26619
|
+
of(pattern, selector) {
|
|
26620
|
+
return new PromisePoolNamespace(this.poolCluster.of(pattern, selector), this.Promise);
|
|
26621
|
+
}
|
|
26622
|
+
end() {
|
|
26623
|
+
const corePoolCluster = this.poolCluster;
|
|
26624
|
+
const localErr = new Error;
|
|
26625
|
+
return new this.Promise((resolve, reject) => {
|
|
26626
|
+
corePoolCluster.end((err) => {
|
|
26627
|
+
if (err) {
|
|
26628
|
+
localErr.message = err.message;
|
|
26629
|
+
localErr.code = err.code;
|
|
26630
|
+
localErr.errno = err.errno;
|
|
26631
|
+
localErr.sqlState = err.sqlState;
|
|
26632
|
+
localErr.sqlMessage = err.sqlMessage;
|
|
26633
|
+
reject(localErr);
|
|
26634
|
+
} else {
|
|
26635
|
+
resolve();
|
|
26636
|
+
}
|
|
26637
|
+
});
|
|
26638
|
+
});
|
|
26639
|
+
}
|
|
26640
|
+
}
|
|
26641
|
+
(function(functionsToWrap) {
|
|
26642
|
+
for (let i2 = 0;functionsToWrap && i2 < functionsToWrap.length; i2++) {
|
|
26643
|
+
const func = functionsToWrap[i2];
|
|
26644
|
+
if (typeof PoolCluster.prototype[func] === "function" && PromisePoolCluster.prototype[func] === undefined) {
|
|
26645
|
+
PromisePoolCluster.prototype[func] = function factory(funcName) {
|
|
26646
|
+
return function() {
|
|
26647
|
+
return PoolCluster.prototype[funcName].apply(this.poolCluster, arguments);
|
|
26648
|
+
};
|
|
26649
|
+
}(func);
|
|
26650
|
+
}
|
|
26651
|
+
}
|
|
26652
|
+
})(["add", "remove"]);
|
|
26653
|
+
function createPromisePoolCluster(opts) {
|
|
26654
|
+
const corePoolCluster = createPoolCluster(opts);
|
|
26655
|
+
const thePromise = opts && opts.Promise || Promise;
|
|
26656
|
+
if (!thePromise) {
|
|
26657
|
+
throw new Error("no Promise implementation available." + "Use promise-enabled node version or pass userland Promise" + " implementation as parameter, for example: { Promise: require('bluebird') }");
|
|
26658
|
+
}
|
|
26659
|
+
return new PromisePoolCluster(corePoolCluster, thePromise);
|
|
26660
|
+
}
|
|
26661
|
+
exports.createConnection = createConnectionPromise;
|
|
26662
|
+
exports.createPool = createPromisePool;
|
|
26663
|
+
exports.createPoolCluster = createPromisePoolCluster;
|
|
26664
|
+
exports.escape = SqlString.escape;
|
|
26665
|
+
exports.escapeId = SqlString.escapeId;
|
|
26666
|
+
exports.format = SqlString.format;
|
|
26667
|
+
exports.raw = SqlString.raw;
|
|
26668
|
+
exports.PromisePool = PromisePool;
|
|
26669
|
+
exports.PromiseConnection = PromiseConnection;
|
|
26670
|
+
exports.PromisePoolConnection = PromisePoolConnection;
|
|
26671
|
+
exports.__defineGetter__("Types", () => require_types());
|
|
26672
|
+
exports.__defineGetter__("Charsets", () => require_charsets());
|
|
26673
|
+
exports.__defineGetter__("CharsetToEncoding", () => require_charset_encodings());
|
|
26674
|
+
exports.setMaxParserCache = function(max) {
|
|
26675
|
+
parserCache.setMaxCache(max);
|
|
26676
|
+
};
|
|
26677
|
+
exports.clearParserCache = function() {
|
|
26678
|
+
parserCache.clearCache();
|
|
26679
|
+
};
|
|
26680
|
+
});
|
|
26681
|
+
|
|
26682
|
+
// src/hyperdrive-docstore.ts
|
|
26683
|
+
init_values();
|
|
26684
|
+
|
|
26685
|
+
// ../core/dist/docstore/interface.js
|
|
26686
|
+
function documentIdKey(id) {
|
|
26687
|
+
return `${id.table}:${id.internalId}`;
|
|
26688
|
+
}
|
|
26689
|
+
var Order;
|
|
26690
|
+
(function(Order2) {
|
|
26691
|
+
Order2["Asc"] = "Asc";
|
|
26692
|
+
Order2["Desc"] = "Desc";
|
|
26693
|
+
})(Order || (Order = {}));
|
|
26694
|
+
function getPrevRevQueryKey(query) {
|
|
26695
|
+
return `${documentIdKey(query.id)}:${query.ts}`;
|
|
26696
|
+
}
|
|
26697
|
+
function getExactRevQueryKey(query) {
|
|
26698
|
+
return `${documentIdKey(query.id)}:${query.ts}:${query.prev_ts}`;
|
|
26699
|
+
}
|
|
26700
|
+
// ../core/dist/docstore/sql/search-schema.js
|
|
26701
|
+
function extractSearchContent(docValue, searchField) {
|
|
26702
|
+
const parts = searchField.split(".");
|
|
26703
|
+
let value = docValue;
|
|
26704
|
+
for (const part of parts) {
|
|
26705
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
26706
|
+
value = value[part];
|
|
26707
|
+
} else {
|
|
26708
|
+
return null;
|
|
26709
|
+
}
|
|
26710
|
+
}
|
|
26711
|
+
if (typeof value === "string") {
|
|
26712
|
+
return value;
|
|
26713
|
+
}
|
|
26714
|
+
return null;
|
|
26715
|
+
}
|
|
26716
|
+
// ../core/dist/queryengine/indexing/index-key-codec.js
|
|
26717
|
+
var TypeTag;
|
|
26718
|
+
(function(TypeTag2) {
|
|
26719
|
+
TypeTag2[TypeTag2["Null"] = 0] = "Null";
|
|
26720
|
+
TypeTag2[TypeTag2["False"] = 16] = "False";
|
|
26721
|
+
TypeTag2[TypeTag2["True"] = 17] = "True";
|
|
26722
|
+
TypeTag2[TypeTag2["NegativeInfinity"] = 32] = "NegativeInfinity";
|
|
26723
|
+
TypeTag2[TypeTag2["NegativeNumber"] = 33] = "NegativeNumber";
|
|
26724
|
+
TypeTag2[TypeTag2["NegativeZero"] = 34] = "NegativeZero";
|
|
26725
|
+
TypeTag2[TypeTag2["Zero"] = 35] = "Zero";
|
|
26726
|
+
TypeTag2[TypeTag2["PositiveNumber"] = 36] = "PositiveNumber";
|
|
26727
|
+
TypeTag2[TypeTag2["PositiveInfinity"] = 37] = "PositiveInfinity";
|
|
26728
|
+
TypeTag2[TypeTag2["NaN"] = 38] = "NaN";
|
|
26729
|
+
TypeTag2[TypeTag2["NegativeBigInt"] = 48] = "NegativeBigInt";
|
|
26730
|
+
TypeTag2[TypeTag2["ZeroBigInt"] = 49] = "ZeroBigInt";
|
|
26731
|
+
TypeTag2[TypeTag2["PositiveBigInt"] = 50] = "PositiveBigInt";
|
|
26732
|
+
TypeTag2[TypeTag2["String"] = 64] = "String";
|
|
26733
|
+
TypeTag2[TypeTag2["Bytes"] = 80] = "Bytes";
|
|
26734
|
+
})(TypeTag || (TypeTag = {}));
|
|
26735
|
+
function encodeNumber(n) {
|
|
26736
|
+
const buffer = new ArrayBuffer(8);
|
|
26737
|
+
const view = new DataView(buffer);
|
|
26738
|
+
view.setFloat64(0, n, false);
|
|
26739
|
+
const bytes = new Uint8Array(buffer);
|
|
26740
|
+
if (n >= 0) {
|
|
26741
|
+
bytes[0] ^= 128;
|
|
26742
|
+
} else {
|
|
26743
|
+
for (let i2 = 0;i2 < 8; i2++) {
|
|
26744
|
+
bytes[i2] ^= 255;
|
|
26745
|
+
}
|
|
26746
|
+
}
|
|
26747
|
+
return bytes;
|
|
26748
|
+
}
|
|
26749
|
+
function encodeBigInt(n) {
|
|
26750
|
+
const INT64_MIN = -(2n ** 63n);
|
|
26751
|
+
const INT64_MAX = 2n ** 63n - 1n;
|
|
26752
|
+
if (n < INT64_MIN)
|
|
26753
|
+
n = INT64_MIN;
|
|
26754
|
+
if (n > INT64_MAX)
|
|
26755
|
+
n = INT64_MAX;
|
|
26756
|
+
const buffer = new ArrayBuffer(8);
|
|
26757
|
+
const view = new DataView(buffer);
|
|
26758
|
+
const unsigned = n < 0n ? n + 2n ** 64n : n;
|
|
26759
|
+
view.setBigUint64(0, unsigned, false);
|
|
26760
|
+
const bytes = new Uint8Array(buffer);
|
|
26761
|
+
bytes[0] ^= 128;
|
|
26762
|
+
return bytes;
|
|
26763
|
+
}
|
|
26764
|
+
function encodeString(s) {
|
|
26765
|
+
const encoder = new TextEncoder;
|
|
26766
|
+
const raw = encoder.encode(s);
|
|
26767
|
+
let nullCount = 0;
|
|
26768
|
+
for (const byte of raw) {
|
|
26769
|
+
if (byte === 0)
|
|
26770
|
+
nullCount++;
|
|
26771
|
+
}
|
|
26772
|
+
const result = new Uint8Array(raw.length + nullCount + 2);
|
|
26773
|
+
let writeIndex = 0;
|
|
26774
|
+
for (const byte of raw) {
|
|
26775
|
+
if (byte === 0) {
|
|
26776
|
+
result[writeIndex++] = 0;
|
|
26777
|
+
result[writeIndex++] = 1;
|
|
26778
|
+
} else {
|
|
26779
|
+
result[writeIndex++] = byte;
|
|
26780
|
+
}
|
|
26781
|
+
}
|
|
26782
|
+
result[writeIndex++] = 0;
|
|
26783
|
+
result[writeIndex++] = 0;
|
|
26784
|
+
return result;
|
|
26785
|
+
}
|
|
26786
|
+
function encodeValue(value) {
|
|
26787
|
+
if (value === null || value === undefined) {
|
|
26788
|
+
return new Uint8Array([TypeTag.Null]);
|
|
26789
|
+
}
|
|
26790
|
+
if (typeof value === "boolean") {
|
|
26791
|
+
return new Uint8Array([value ? TypeTag.True : TypeTag.False]);
|
|
26792
|
+
}
|
|
26793
|
+
if (typeof value === "number") {
|
|
26794
|
+
if (Number.isNaN(value)) {
|
|
26795
|
+
return new Uint8Array([TypeTag.NaN]);
|
|
26796
|
+
}
|
|
26797
|
+
if (!Number.isFinite(value)) {
|
|
26798
|
+
return new Uint8Array([value === -Infinity ? TypeTag.NegativeInfinity : TypeTag.PositiveInfinity]);
|
|
26799
|
+
}
|
|
26800
|
+
if (value === 0) {
|
|
26801
|
+
return new Uint8Array([Object.is(value, -0) ? TypeTag.NegativeZero : TypeTag.Zero]);
|
|
26802
|
+
}
|
|
26803
|
+
const tag = value > 0 ? TypeTag.PositiveNumber : TypeTag.NegativeNumber;
|
|
26804
|
+
const encoded = encodeNumber(value);
|
|
26805
|
+
const result = new Uint8Array(1 + encoded.length);
|
|
26806
|
+
result[0] = tag;
|
|
26807
|
+
result.set(encoded, 1);
|
|
26808
|
+
return result;
|
|
26809
|
+
}
|
|
26810
|
+
if (typeof value === "bigint") {
|
|
26811
|
+
if (value === 0n) {
|
|
26812
|
+
return new Uint8Array([TypeTag.ZeroBigInt]);
|
|
26813
|
+
}
|
|
26814
|
+
const tag = value > 0n ? TypeTag.PositiveBigInt : TypeTag.NegativeBigInt;
|
|
26815
|
+
const encoded = encodeBigInt(value);
|
|
26816
|
+
const result = new Uint8Array(1 + encoded.length);
|
|
26817
|
+
result[0] = tag;
|
|
26818
|
+
result.set(encoded, 1);
|
|
26819
|
+
return result;
|
|
26820
|
+
}
|
|
26821
|
+
if (typeof value === "string") {
|
|
26822
|
+
const encoded = encodeString(value);
|
|
26823
|
+
const result = new Uint8Array(1 + encoded.length);
|
|
26824
|
+
result[0] = TypeTag.String;
|
|
26825
|
+
result.set(encoded, 1);
|
|
26826
|
+
return result;
|
|
26827
|
+
}
|
|
26828
|
+
if (value instanceof ArrayBuffer || value instanceof Uint8Array) {
|
|
26829
|
+
const bytes = value instanceof Uint8Array ? value : new Uint8Array(value);
|
|
26830
|
+
const result = new Uint8Array(1 + bytes.length + 2);
|
|
26831
|
+
result[0] = TypeTag.Bytes;
|
|
26832
|
+
result.set(bytes, 1);
|
|
26833
|
+
result[result.length - 2] = 0;
|
|
26834
|
+
result[result.length - 1] = 0;
|
|
26835
|
+
return result;
|
|
26836
|
+
}
|
|
26837
|
+
throw new Error(`Cannot encode value of type ${typeof value} in index key`);
|
|
26838
|
+
}
|
|
26839
|
+
function encodeIndexKey(values) {
|
|
26840
|
+
if (values.length === 0) {
|
|
26841
|
+
return new ArrayBuffer(0);
|
|
26842
|
+
}
|
|
26843
|
+
const encoded = values.map(encodeValue);
|
|
26844
|
+
const totalLength = encoded.reduce((sum, arr) => sum + arr.length, 0);
|
|
26845
|
+
const result = new Uint8Array(totalLength);
|
|
26846
|
+
let offset = 0;
|
|
26847
|
+
for (const chunk of encoded) {
|
|
26848
|
+
result.set(chunk, offset);
|
|
26849
|
+
offset += chunk.length;
|
|
26850
|
+
}
|
|
26851
|
+
return result.buffer;
|
|
26852
|
+
}
|
|
26853
|
+
function compareIndexKeys(a, b) {
|
|
26854
|
+
const viewA = new Uint8Array(a);
|
|
26855
|
+
const viewB = new Uint8Array(b);
|
|
26856
|
+
const minLen = Math.min(viewA.length, viewB.length);
|
|
26857
|
+
for (let i2 = 0;i2 < minLen; i2++) {
|
|
26858
|
+
if (viewA[i2] < viewB[i2])
|
|
26859
|
+
return -1;
|
|
26860
|
+
if (viewA[i2] > viewB[i2])
|
|
26861
|
+
return 1;
|
|
26862
|
+
}
|
|
26863
|
+
if (viewA.length < viewB.length)
|
|
26864
|
+
return -1;
|
|
26865
|
+
if (viewA.length > viewB.length)
|
|
26866
|
+
return 1;
|
|
26867
|
+
return 0;
|
|
26868
|
+
}
|
|
26869
|
+
function indexKeysEqual(a, b) {
|
|
26870
|
+
return compareIndexKeys(a, b) === 0;
|
|
26871
|
+
}
|
|
26872
|
+
|
|
26873
|
+
// ../core/dist/queryengine/indexing/index-manager.js
|
|
26874
|
+
function getFieldValue(doc, fieldPath) {
|
|
26875
|
+
const parts = fieldPath.split(".");
|
|
26876
|
+
let current = doc;
|
|
26877
|
+
for (const part of parts) {
|
|
26878
|
+
if (current === null || current === undefined) {
|
|
26879
|
+
return;
|
|
26880
|
+
}
|
|
26881
|
+
if (typeof current !== "object" || Array.isArray(current)) {
|
|
26882
|
+
return;
|
|
26883
|
+
}
|
|
26884
|
+
current = current[part];
|
|
26885
|
+
}
|
|
26886
|
+
return current;
|
|
26887
|
+
}
|
|
26888
|
+
function extractIndexKey(doc, fields) {
|
|
26889
|
+
const values = [];
|
|
26890
|
+
for (const field of fields) {
|
|
26891
|
+
const value = getFieldValue(doc, field);
|
|
26892
|
+
if (value === undefined) {
|
|
26893
|
+
return null;
|
|
26894
|
+
}
|
|
26895
|
+
values.push(value);
|
|
26896
|
+
}
|
|
26897
|
+
return encodeIndexKey(values);
|
|
26898
|
+
}
|
|
26899
|
+
function generateIndexUpdates(tableName, docId, newValue, oldValue, indexes) {
|
|
26900
|
+
const updates = [];
|
|
26901
|
+
for (const index of indexes) {
|
|
26902
|
+
const indexId = stringToHex(`${tableName}:${index.name}`);
|
|
26903
|
+
const oldKey = oldValue !== null ? extractIndexKey(oldValue, index.fields) : null;
|
|
26904
|
+
const newKey = newValue !== null ? extractIndexKey(newValue, index.fields) : null;
|
|
26905
|
+
const keyChanged = oldKey === null && newKey !== null || oldKey !== null && newKey === null || oldKey !== null && newKey !== null && !indexKeysEqual(oldKey, newKey);
|
|
26906
|
+
if (!keyChanged) {
|
|
26907
|
+
continue;
|
|
26908
|
+
}
|
|
26909
|
+
if (oldKey !== null) {
|
|
26910
|
+
updates.push({
|
|
26911
|
+
index_id: indexId,
|
|
26912
|
+
key: oldKey,
|
|
26913
|
+
value: { type: "Deleted" }
|
|
26914
|
+
});
|
|
26915
|
+
}
|
|
26916
|
+
if (newKey !== null) {
|
|
26917
|
+
updates.push({
|
|
26918
|
+
index_id: indexId,
|
|
26919
|
+
key: newKey,
|
|
26920
|
+
value: {
|
|
26921
|
+
type: "NonClustered",
|
|
26922
|
+
doc_id: docId
|
|
26923
|
+
}
|
|
26924
|
+
});
|
|
26925
|
+
}
|
|
26926
|
+
}
|
|
26927
|
+
return updates;
|
|
26928
|
+
}
|
|
26929
|
+
function getStandardIndexes() {
|
|
26930
|
+
return [
|
|
26931
|
+
{
|
|
26932
|
+
name: "by_creation_time",
|
|
26933
|
+
fields: ["_creationTime", "_id"]
|
|
26934
|
+
},
|
|
26935
|
+
{
|
|
26936
|
+
name: "by_id",
|
|
26937
|
+
fields: ["_id"]
|
|
26938
|
+
}
|
|
26939
|
+
];
|
|
26940
|
+
}
|
|
26941
|
+
|
|
26942
|
+
// ../core/dist/kernel/schema-service.js
|
|
26943
|
+
init_validator2();
|
|
26944
|
+
init_module_loader();
|
|
26945
|
+
|
|
26946
|
+
class SchemaService {
|
|
26947
|
+
cachedSchemaDefinition = undefined;
|
|
26948
|
+
tableCache = new Map;
|
|
26949
|
+
schemaValidator;
|
|
26950
|
+
componentPath;
|
|
26951
|
+
constructor(componentPath) {
|
|
26952
|
+
this.componentPath = componentPath;
|
|
26953
|
+
this.schemaValidator = new SchemaValidator(componentPath);
|
|
26954
|
+
}
|
|
26955
|
+
async validate(tableName, document) {
|
|
26956
|
+
try {
|
|
26957
|
+
await this.schemaValidator.validateDocument(tableName, document);
|
|
26958
|
+
} catch (error) {
|
|
26959
|
+
if (error instanceof ValidatorError) {
|
|
26960
|
+
throw new Error(error.message);
|
|
26961
|
+
}
|
|
26962
|
+
throw error;
|
|
26752
26963
|
}
|
|
26753
|
-
|
|
26754
|
-
|
|
26755
|
-
|
|
26756
|
-
|
|
26757
|
-
throw new Error("Callback function is not available with promise clients.");
|
|
26758
|
-
}
|
|
26759
|
-
return new this.Promise((resolve, reject) => {
|
|
26760
|
-
const done = makeDoneCb(resolve, reject, localErr);
|
|
26761
|
-
corePoolCluster.execute(sql, args, done);
|
|
26762
|
-
});
|
|
26964
|
+
}
|
|
26965
|
+
async getTableSchema(tableName) {
|
|
26966
|
+
if (this.tableCache.has(tableName)) {
|
|
26967
|
+
return this.tableCache.get(tableName) ?? null;
|
|
26763
26968
|
}
|
|
26764
|
-
|
|
26765
|
-
|
|
26969
|
+
const schemaDefinition = await this.getSchemaDefinition();
|
|
26970
|
+
const tableSchema = schemaDefinition?.tables?.[tableName] ?? null;
|
|
26971
|
+
this.tableCache.set(tableName, tableSchema);
|
|
26972
|
+
return tableSchema;
|
|
26973
|
+
}
|
|
26974
|
+
async getIndexFieldsForTable(tableName, indexDescriptor) {
|
|
26975
|
+
if (indexDescriptor === "by_creation_time") {
|
|
26976
|
+
return ["_creationTime", "_id"];
|
|
26766
26977
|
}
|
|
26767
|
-
|
|
26768
|
-
|
|
26769
|
-
|
|
26770
|
-
|
|
26771
|
-
|
|
26772
|
-
|
|
26773
|
-
|
|
26774
|
-
|
|
26775
|
-
|
|
26776
|
-
|
|
26777
|
-
|
|
26778
|
-
|
|
26779
|
-
|
|
26780
|
-
|
|
26781
|
-
|
|
26978
|
+
if (indexDescriptor === "by_id") {
|
|
26979
|
+
return ["_id"];
|
|
26980
|
+
}
|
|
26981
|
+
const tableSchema = await this.getTableSchema(tableName);
|
|
26982
|
+
const dbIndexes = tableSchema?.indexes;
|
|
26983
|
+
const matchingIndex = dbIndexes?.find((idx) => idx.indexDescriptor === indexDescriptor);
|
|
26984
|
+
if (!matchingIndex) {
|
|
26985
|
+
return null;
|
|
26986
|
+
}
|
|
26987
|
+
return [...matchingIndex.fields, "_creationTime", "_id"];
|
|
26988
|
+
}
|
|
26989
|
+
async getAllIndexesForTable(tableName) {
|
|
26990
|
+
const indexes = [...getStandardIndexes()];
|
|
26991
|
+
const tableSchema = await this.getTableSchema(tableName);
|
|
26992
|
+
const schemaIndexes = tableSchema?.indexes;
|
|
26993
|
+
if (schemaIndexes) {
|
|
26994
|
+
for (const idx of schemaIndexes) {
|
|
26995
|
+
indexes.push({
|
|
26996
|
+
name: idx.indexDescriptor,
|
|
26997
|
+
fields: [...idx.fields, "_creationTime", "_id"]
|
|
26782
26998
|
});
|
|
26783
|
-
}
|
|
26999
|
+
}
|
|
26784
27000
|
}
|
|
27001
|
+
return indexes;
|
|
26785
27002
|
}
|
|
26786
|
-
(
|
|
26787
|
-
|
|
26788
|
-
|
|
26789
|
-
|
|
26790
|
-
|
|
26791
|
-
|
|
26792
|
-
|
|
26793
|
-
|
|
26794
|
-
|
|
27003
|
+
async getSearchIndexConfig(tableName, indexDescriptor) {
|
|
27004
|
+
const tableSchema = await this.getTableSchema(tableName);
|
|
27005
|
+
const searchIndexes = tableSchema?.searchIndexes;
|
|
27006
|
+
return searchIndexes?.find((idx) => idx.indexDescriptor === indexDescriptor) ?? null;
|
|
27007
|
+
}
|
|
27008
|
+
async getVectorIndexConfig(tableName, indexDescriptor) {
|
|
27009
|
+
const tableSchema = await this.getTableSchema(tableName);
|
|
27010
|
+
const vectorIndexes = tableSchema?.vectorIndexes;
|
|
27011
|
+
return vectorIndexes?.find((idx) => idx.indexDescriptor === indexDescriptor) ?? null;
|
|
27012
|
+
}
|
|
27013
|
+
async getAllVectorIndexes() {
|
|
27014
|
+
const schemaDefinition = await this.getSchemaDefinition();
|
|
27015
|
+
if (!schemaDefinition?.tables) {
|
|
27016
|
+
return [];
|
|
27017
|
+
}
|
|
27018
|
+
const allVectorIndexes = [];
|
|
27019
|
+
for (const [tableName, tableSchema] of Object.entries(schemaDefinition.tables)) {
|
|
27020
|
+
const vectorIndexes = tableSchema?.vectorIndexes;
|
|
27021
|
+
if (vectorIndexes) {
|
|
27022
|
+
for (const vectorIndex of vectorIndexes) {
|
|
27023
|
+
allVectorIndexes.push({
|
|
27024
|
+
tableName,
|
|
27025
|
+
indexDescriptor: vectorIndex.indexDescriptor,
|
|
27026
|
+
vectorField: vectorIndex.vectorField,
|
|
27027
|
+
filterFields: vectorIndex.filterFields ?? []
|
|
27028
|
+
});
|
|
27029
|
+
}
|
|
26795
27030
|
}
|
|
26796
27031
|
}
|
|
26797
|
-
|
|
26798
|
-
|
|
26799
|
-
|
|
26800
|
-
const
|
|
26801
|
-
if (!
|
|
26802
|
-
|
|
27032
|
+
return allVectorIndexes;
|
|
27033
|
+
}
|
|
27034
|
+
async getAllSearchIndexes() {
|
|
27035
|
+
const schemaDefinition = await this.getSchemaDefinition();
|
|
27036
|
+
if (!schemaDefinition?.tables) {
|
|
27037
|
+
return [];
|
|
26803
27038
|
}
|
|
26804
|
-
|
|
27039
|
+
const allSearchIndexes = [];
|
|
27040
|
+
for (const [tableName, tableSchema] of Object.entries(schemaDefinition.tables)) {
|
|
27041
|
+
const searchIndexes = tableSchema?.searchIndexes;
|
|
27042
|
+
if (searchIndexes) {
|
|
27043
|
+
for (const searchIndex of searchIndexes) {
|
|
27044
|
+
allSearchIndexes.push({
|
|
27045
|
+
tableName,
|
|
27046
|
+
indexDescriptor: searchIndex.indexDescriptor,
|
|
27047
|
+
searchField: searchIndex.searchField,
|
|
27048
|
+
filterFields: searchIndex.filterFields ?? []
|
|
27049
|
+
});
|
|
27050
|
+
}
|
|
27051
|
+
}
|
|
27052
|
+
}
|
|
27053
|
+
return allSearchIndexes;
|
|
26805
27054
|
}
|
|
26806
|
-
|
|
26807
|
-
|
|
26808
|
-
|
|
26809
|
-
|
|
26810
|
-
exports.escapeId = SqlString.escapeId;
|
|
26811
|
-
exports.format = SqlString.format;
|
|
26812
|
-
exports.raw = SqlString.raw;
|
|
26813
|
-
exports.PromisePool = PromisePool;
|
|
26814
|
-
exports.PromiseConnection = PromiseConnection;
|
|
26815
|
-
exports.PromisePoolConnection = PromisePoolConnection;
|
|
26816
|
-
exports.__defineGetter__("Types", () => require_types());
|
|
26817
|
-
exports.__defineGetter__("Charsets", () => require_charsets());
|
|
26818
|
-
exports.__defineGetter__("CharsetToEncoding", () => require_charset_encodings());
|
|
26819
|
-
exports.setMaxParserCache = function(max) {
|
|
26820
|
-
parserCache.setMaxCache(max);
|
|
26821
|
-
};
|
|
26822
|
-
exports.clearParserCache = function() {
|
|
26823
|
-
parserCache.clearCache();
|
|
26824
|
-
};
|
|
26825
|
-
});
|
|
26826
|
-
|
|
26827
|
-
// src/hyperdrive-docstore.ts
|
|
26828
|
-
init_values();
|
|
26829
|
-
|
|
26830
|
-
// ../core/dist/docstore/interface.js
|
|
26831
|
-
function documentIdKey(id) {
|
|
26832
|
-
return `${id.table}:${id.internalId}`;
|
|
26833
|
-
}
|
|
26834
|
-
var Order;
|
|
26835
|
-
(function(Order2) {
|
|
26836
|
-
Order2["Asc"] = "Asc";
|
|
26837
|
-
Order2["Desc"] = "Desc";
|
|
26838
|
-
})(Order || (Order = {}));
|
|
26839
|
-
function getPrevRevQueryKey(query) {
|
|
26840
|
-
return `${documentIdKey(query.id)}:${query.ts}`;
|
|
26841
|
-
}
|
|
26842
|
-
function getExactRevQueryKey(query) {
|
|
26843
|
-
return `${documentIdKey(query.id)}:${query.ts}:${query.prev_ts}`;
|
|
26844
|
-
}
|
|
26845
|
-
// ../core/dist/docstore/sql/search-schema.js
|
|
26846
|
-
function extractSearchContent(docValue, searchField) {
|
|
26847
|
-
const parts = searchField.split(".");
|
|
26848
|
-
let value = docValue;
|
|
26849
|
-
for (const part of parts) {
|
|
26850
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
26851
|
-
value = value[part];
|
|
26852
|
-
} else {
|
|
26853
|
-
return null;
|
|
27055
|
+
async getTableNames() {
|
|
27056
|
+
const schemaDefinition = await this.getSchemaDefinition();
|
|
27057
|
+
if (!schemaDefinition?.tables) {
|
|
27058
|
+
return [];
|
|
26854
27059
|
}
|
|
27060
|
+
return Object.keys(schemaDefinition.tables);
|
|
26855
27061
|
}
|
|
26856
|
-
|
|
26857
|
-
|
|
27062
|
+
async getSchemaDefinition() {
|
|
27063
|
+
if (this.cachedSchemaDefinition !== undefined) {
|
|
27064
|
+
return this.cachedSchemaDefinition;
|
|
27065
|
+
}
|
|
27066
|
+
try {
|
|
27067
|
+
const schemaModule = await loadConvexModule("schema", { hint: "schema", componentPath: this.componentPath });
|
|
27068
|
+
this.cachedSchemaDefinition = schemaModule.default ?? null;
|
|
27069
|
+
} catch (error) {
|
|
27070
|
+
if (!isMissingSchemaModuleError(error)) {
|
|
27071
|
+
console.warn("Failed to load Convex schema definition:", error);
|
|
27072
|
+
}
|
|
27073
|
+
this.cachedSchemaDefinition = null;
|
|
27074
|
+
}
|
|
27075
|
+
return this.cachedSchemaDefinition;
|
|
26858
27076
|
}
|
|
26859
|
-
return null;
|
|
26860
27077
|
}
|
|
26861
|
-
// ../core/dist/kernel/udf-kernel.js
|
|
26862
|
-
init_schema_service();
|
|
26863
|
-
|
|
26864
|
-
// ../core/dist/queryengine/index-query.js
|
|
26865
|
-
init_index_key_codec();
|
|
26866
|
-
|
|
26867
27078
|
// ../core/dist/queryengine/filters.js
|
|
26868
27079
|
function isSimpleObject3(value) {
|
|
26869
27080
|
const isObject = typeof value === "object" && value !== null;
|
|
@@ -26930,9 +27141,6 @@ init_interface();
|
|
|
26930
27141
|
// ../core/dist/query/actions.js
|
|
26931
27142
|
init_interface();
|
|
26932
27143
|
|
|
26933
|
-
// ../core/dist/queryengine/indexing/read-write-set.js
|
|
26934
|
-
init_index_key_codec();
|
|
26935
|
-
|
|
26936
27144
|
// ../core/dist/utils/keyspace.js
|
|
26937
27145
|
var TABLE_PREFIX = "table";
|
|
26938
27146
|
var INDEX_PREFIX = "index";
|
|
@@ -27317,55 +27525,8 @@ class KernelContext {
|
|
|
27317
27525
|
}
|
|
27318
27526
|
}
|
|
27319
27527
|
|
|
27320
|
-
// ../core/dist/kernel/context-storage.js
|
|
27321
|
-
var resolveAsyncLocalStorage = () => {
|
|
27322
|
-
if (typeof globalThis !== "undefined" && globalThis.AsyncLocalStorage) {
|
|
27323
|
-
return globalThis.AsyncLocalStorage;
|
|
27324
|
-
}
|
|
27325
|
-
try {
|
|
27326
|
-
const req = Function("return typeof require !== 'undefined' ? require : undefined")();
|
|
27327
|
-
if (!req) {
|
|
27328
|
-
return;
|
|
27329
|
-
}
|
|
27330
|
-
const mod = req("node:async_hooks");
|
|
27331
|
-
return mod.AsyncLocalStorage;
|
|
27332
|
-
} catch {
|
|
27333
|
-
return;
|
|
27334
|
-
}
|
|
27335
|
-
};
|
|
27336
|
-
var AsyncLocalStorageCtor = resolveAsyncLocalStorage();
|
|
27337
|
-
|
|
27338
|
-
class ContextStorage {
|
|
27339
|
-
als;
|
|
27340
|
-
stack = [];
|
|
27341
|
-
constructor() {
|
|
27342
|
-
if (AsyncLocalStorageCtor) {
|
|
27343
|
-
this.als = new AsyncLocalStorageCtor;
|
|
27344
|
-
}
|
|
27345
|
-
}
|
|
27346
|
-
getStore() {
|
|
27347
|
-
if (this.als) {
|
|
27348
|
-
return this.als.getStore() ?? undefined;
|
|
27349
|
-
}
|
|
27350
|
-
return this.stack.length > 0 ? this.stack[this.stack.length - 1] : undefined;
|
|
27351
|
-
}
|
|
27352
|
-
run(value, callback) {
|
|
27353
|
-
if (this.als) {
|
|
27354
|
-
return this.als.run(value, callback);
|
|
27355
|
-
}
|
|
27356
|
-
this.stack.push(value);
|
|
27357
|
-
const result = callback();
|
|
27358
|
-
if (result && typeof result.then === "function") {
|
|
27359
|
-
return result.finally(() => {
|
|
27360
|
-
this.stack.pop();
|
|
27361
|
-
});
|
|
27362
|
-
}
|
|
27363
|
-
this.stack.pop();
|
|
27364
|
-
return result;
|
|
27365
|
-
}
|
|
27366
|
-
}
|
|
27367
|
-
|
|
27368
27528
|
// ../core/dist/kernel/contexts.js
|
|
27529
|
+
init_context_storage();
|
|
27369
27530
|
var snapshotContext = new ContextStorage;
|
|
27370
27531
|
var transactionContext = new ContextStorage;
|
|
27371
27532
|
var idGeneratorContext = new ContextStorage;
|
|
@@ -27686,10 +27847,10 @@ class SchedulerGateway {
|
|
|
27686
27847
|
}
|
|
27687
27848
|
|
|
27688
27849
|
// ../core/dist/udf/module-loader/call-context.js
|
|
27689
|
-
|
|
27850
|
+
init_context_storage();
|
|
27690
27851
|
var CALL_CONTEXT_SYMBOL = Symbol.for("@concavejs/core/call-context");
|
|
27691
27852
|
var globalCallContext = globalThis;
|
|
27692
|
-
var callContext = globalCallContext[CALL_CONTEXT_SYMBOL] ?? new
|
|
27853
|
+
var callContext = globalCallContext[CALL_CONTEXT_SYMBOL] ?? new ContextStorage;
|
|
27693
27854
|
if (!globalCallContext[CALL_CONTEXT_SYMBOL]) {
|
|
27694
27855
|
globalCallContext[CALL_CONTEXT_SYMBOL] = callContext;
|
|
27695
27856
|
}
|
|
@@ -27777,7 +27938,6 @@ class ActionSyscalls {
|
|
|
27777
27938
|
|
|
27778
27939
|
// ../core/dist/kernel/syscalls/database-syscalls.js
|
|
27779
27940
|
init_values();
|
|
27780
|
-
init_index_manager();
|
|
27781
27941
|
init_interface();
|
|
27782
27942
|
|
|
27783
27943
|
class DatabaseSyscalls {
|
|
@@ -28403,10 +28563,6 @@ class KernelSyscalls {
|
|
|
28403
28563
|
return this.jsRouter.dispatch(op, args);
|
|
28404
28564
|
}
|
|
28405
28565
|
}
|
|
28406
|
-
|
|
28407
|
-
// ../core/dist/queryengine/index.js
|
|
28408
|
-
init_schema_service();
|
|
28409
|
-
|
|
28410
28566
|
// ../core/dist/queryengine/convex-ops.js
|
|
28411
28567
|
var debug = () => {};
|
|
28412
28568
|
class CfConvex {
|
|
@@ -28428,9 +28584,6 @@ class CfConvex {
|
|
|
28428
28584
|
}
|
|
28429
28585
|
}
|
|
28430
28586
|
var Convex2 = new CfConvex;
|
|
28431
|
-
// ../core/dist/queryengine/indexing/index.js
|
|
28432
|
-
init_index_manager();
|
|
28433
|
-
init_index_key_codec();
|
|
28434
28587
|
// ../core/dist/utils/long.js
|
|
28435
28588
|
class Long {
|
|
28436
28589
|
low;
|