@peerbit/indexer-sqlite3 2.0.0 → 2.0.2
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.min.js +23 -16
- package/dist/index.min.js.map +2 -2
- package/dist/src/schema.d.ts.map +1 -1
- package/dist/src/schema.js +33 -17
- package/dist/src/schema.js.map +1 -1
- package/package.json +5 -5
- package/src/schema.ts +40 -18
package/dist/index.min.js
CHANGED
|
@@ -20357,7 +20357,7 @@ var toSQLType = (type, isOptional = false) => {
|
|
|
20357
20357
|
};
|
|
20358
20358
|
var getSQLTable = (ctor, path, primary, inline, addJoinField, fromOptionalField = false) => {
|
|
20359
20359
|
let clazzes = getDependencies(ctor, 0);
|
|
20360
|
-
if (!clazzes) {
|
|
20360
|
+
if (!clazzes || clazzes.length === 0) {
|
|
20361
20361
|
clazzes = [ctor];
|
|
20362
20362
|
}
|
|
20363
20363
|
let ret = [];
|
|
@@ -20692,21 +20692,28 @@ var getTableFromValue = (parentTable, tables, field2, value) => {
|
|
|
20692
20692
|
if (!isNestedType(field2.type)) {
|
|
20693
20693
|
clazzName = WRAPPED_SIMPLE_VALUE_VARIANT;
|
|
20694
20694
|
} else {
|
|
20695
|
-
const
|
|
20696
|
-
|
|
20697
|
-
|
|
20698
|
-
|
|
20699
|
-
|
|
20700
|
-
|
|
20701
|
-
|
|
20702
|
-
|
|
20703
|
-
const
|
|
20704
|
-
|
|
20705
|
-
|
|
20706
|
-
}
|
|
20707
|
-
if (
|
|
20708
|
-
clazzName =
|
|
20709
|
-
|
|
20695
|
+
const nestedType = unwrapNestedType(field2.type);
|
|
20696
|
+
const dependencies = getDependencies(nestedType, 0) || [];
|
|
20697
|
+
const candidatesFromSchema = [nestedType, ...dependencies].filter((x) => typeof x === "function");
|
|
20698
|
+
const runtimeCtor = value?.constructor;
|
|
20699
|
+
const runtimeSchema = runtimeCtor ? getSchema(runtimeCtor) : void 0;
|
|
20700
|
+
if (runtimeCtor && runtimeSchema?.variant !== void 0) {
|
|
20701
|
+
clazzName = runtimeCtor;
|
|
20702
|
+
} else {
|
|
20703
|
+
const tableCtors = candidatesFromSchema.filter((ctor) => {
|
|
20704
|
+
const schema = getSchema(ctor);
|
|
20705
|
+
return schema?.variant !== void 0;
|
|
20706
|
+
});
|
|
20707
|
+
if (tableCtors.length === 1) {
|
|
20708
|
+
clazzName = tableCtors[0];
|
|
20709
|
+
} else if (tableCtors.length > 1) {
|
|
20710
|
+
const declaredName = nestedType.name || "<anonymous>";
|
|
20711
|
+
const variants = tableCtors.map((ctor) => {
|
|
20712
|
+
const schema = getSchema(ctor);
|
|
20713
|
+
return `${ctor.name || "<anonymous>"}(${JSON.stringify(schema?.variant)})`;
|
|
20714
|
+
}).join(", ");
|
|
20715
|
+
const runtimeName = runtimeCtor?.name || (value == null ? "null" : typeof value);
|
|
20716
|
+
throw new Error(`Ambiguous polymorphic nested value for field "${field2.key}". Declared type ${declaredName} has multiple variants: ${variants}. Received ${runtimeName}. Pass an instance of the desired variant.`);
|
|
20710
20717
|
}
|
|
20711
20718
|
}
|
|
20712
20719
|
}
|