@m1212e/rumble 0.21.5 → 0.22.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/out/index.cjs +184 -53
- package/out/index.cjs.map +1 -1
- package/out/index.d.cts +66 -49
- package/out/index.d.cts.map +1 -1
- package/out/index.d.mts +66 -49
- package/out/index.d.mts.map +1 -1
- package/out/index.mjs +184 -53
- package/out/index.mjs.map +1 -1
- package/package.json +1 -1
package/out/index.mjs
CHANGED
|
@@ -180,7 +180,7 @@ function mapNullFieldsToUndefined(obj) {
|
|
|
180
180
|
}
|
|
181
181
|
//#endregion
|
|
182
182
|
//#region package.json
|
|
183
|
-
var version = "0.
|
|
183
|
+
var version = "0.22.2";
|
|
184
184
|
//#endregion
|
|
185
185
|
//#region lib/helpers/mergeFilters.ts
|
|
186
186
|
function mergeFilters(filterA, filterB, mode = "AND") {
|
|
@@ -815,66 +815,126 @@ function mapSQLTypeToGraphQLType({ sqlType, fieldName }) {
|
|
|
815
815
|
const makeDefaultName = (dbName) => `${capitalize(toCamelCase(dbName.toString()))}WhereInputArgument`;
|
|
816
816
|
const createWhereArgImplementer = ({ db, schemaBuilder, enumImplementer }) => {
|
|
817
817
|
const referenceStorage = /* @__PURE__ */ new Map();
|
|
818
|
+
const enumArrayWhereInputStorage = /* @__PURE__ */ new Map();
|
|
819
|
+
const getEnumArrayWhereInput = (enumImpl) => {
|
|
820
|
+
const typeName = `${enumImpl.name}WhereInputArgument`;
|
|
821
|
+
const existing = enumArrayWhereInputStorage.get(typeName);
|
|
822
|
+
if (existing) return existing;
|
|
823
|
+
const ret = schemaBuilder.inputRef(typeName);
|
|
824
|
+
enumArrayWhereInputStorage.set(typeName, ret);
|
|
825
|
+
ret.implement({ fields: (t) => ({
|
|
826
|
+
eq: t.field({
|
|
827
|
+
type: [enumImpl],
|
|
828
|
+
required: false
|
|
829
|
+
}),
|
|
830
|
+
ne: t.field({
|
|
831
|
+
type: [enumImpl],
|
|
832
|
+
required: false
|
|
833
|
+
}),
|
|
834
|
+
in: t.field({
|
|
835
|
+
type: [[enumImpl]],
|
|
836
|
+
required: false
|
|
837
|
+
}),
|
|
838
|
+
notIn: t.field({
|
|
839
|
+
type: [[enumImpl]],
|
|
840
|
+
required: false
|
|
841
|
+
}),
|
|
842
|
+
isNull: t.boolean({ required: false }),
|
|
843
|
+
isNotNull: t.boolean({ required: false }),
|
|
844
|
+
arrayOverlaps: t.field({
|
|
845
|
+
type: [enumImpl],
|
|
846
|
+
required: false
|
|
847
|
+
}),
|
|
848
|
+
arrayContained: t.field({
|
|
849
|
+
type: [enumImpl],
|
|
850
|
+
required: false
|
|
851
|
+
}),
|
|
852
|
+
arrayContains: t.field({
|
|
853
|
+
type: [enumImpl],
|
|
854
|
+
required: false
|
|
855
|
+
}),
|
|
856
|
+
AND: t.field({
|
|
857
|
+
type: [ret],
|
|
858
|
+
required: false
|
|
859
|
+
}),
|
|
860
|
+
OR: t.field({
|
|
861
|
+
type: [ret],
|
|
862
|
+
required: false
|
|
863
|
+
}),
|
|
864
|
+
NOT: t.field({
|
|
865
|
+
type: ret,
|
|
866
|
+
required: false
|
|
867
|
+
})
|
|
868
|
+
}) });
|
|
869
|
+
return ret;
|
|
870
|
+
};
|
|
818
871
|
const whereArgImplementer = ({ table, refName, dbName }) => {
|
|
819
872
|
const tableSchema = tableHelper({
|
|
820
873
|
db,
|
|
821
874
|
table: dbName ?? table
|
|
822
875
|
});
|
|
823
876
|
const inputTypeName = refName ?? makeDefaultName(tableSchema.tsName);
|
|
824
|
-
|
|
825
|
-
if (
|
|
826
|
-
const
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
if (isEnumSchema(value)) {
|
|
850
|
-
const enumImpl = enumImplementer({ enumColumn: value });
|
|
851
|
-
acc[key] = t.field({
|
|
852
|
-
type: enumImpl,
|
|
853
|
-
required: false
|
|
854
|
-
});
|
|
855
|
-
} else acc[key] = mapSQLTypeStringToInputPothosType(value.getSQLType(), key);
|
|
856
|
-
return acc;
|
|
857
|
-
}, {});
|
|
858
|
-
const relations = Object.entries(tableSchema.relations ?? {}).reduce((acc, [key, value]) => {
|
|
859
|
-
const targetTsName = value.targetTableName;
|
|
860
|
-
const referenceModel = whereArgImplementer({ dbName: tableHelper({
|
|
861
|
-
db,
|
|
862
|
-
table: targetTsName
|
|
863
|
-
}).dbName });
|
|
877
|
+
const existing = referenceStorage.get(inputTypeName);
|
|
878
|
+
if (existing) return existing;
|
|
879
|
+
const ret = schemaBuilder.inputRef(inputTypeName);
|
|
880
|
+
referenceStorage.set(inputTypeName, ret);
|
|
881
|
+
ret.implement({ fields: (t) => {
|
|
882
|
+
const mapSQLTypeStringToInputPothosType = (sqlType, fieldName) => {
|
|
883
|
+
const gqlType = mapSQLTypeToGraphQLType({
|
|
884
|
+
sqlType,
|
|
885
|
+
fieldName
|
|
886
|
+
});
|
|
887
|
+
switch (gqlType) {
|
|
888
|
+
case "Int": return t.field({ type: "IntWhereInputArgument" });
|
|
889
|
+
case "String": return t.field({ type: "StringWhereInputArgument" });
|
|
890
|
+
case "Boolean": return t.field({ type: "BooleanWhereInputArgument" });
|
|
891
|
+
case "Date": return t.field({ type: "DateWhereInputArgument" });
|
|
892
|
+
case "DateTime": return t.field({ type: "DateWhereInputArgument" });
|
|
893
|
+
case "Float": return t.field({ type: "FloatWhereInputArgument" });
|
|
894
|
+
case "ID": return t.field({ type: "IDWhereInputArgument" });
|
|
895
|
+
case "JSON": return t.field({ type: "JSONWhereInputArgument" });
|
|
896
|
+
default: throw new RumbleError(`Unsupported argument type ${gqlType} for column ${sqlType}`);
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
const fields = Object.entries(tableSchema.columns).reduce((acc, [key, value]) => {
|
|
900
|
+
if (isEnumSchema(value)) {
|
|
901
|
+
const enumImpl = enumImplementer({ enumColumn: value });
|
|
864
902
|
acc[key] = t.field({
|
|
865
|
-
type:
|
|
903
|
+
type: value.dimensions > 0 ? getEnumArrayWhereInput(enumImpl) : enumImpl,
|
|
866
904
|
required: false
|
|
867
905
|
});
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
906
|
+
} else acc[key] = mapSQLTypeStringToInputPothosType(value.getSQLType(), key);
|
|
907
|
+
return acc;
|
|
908
|
+
}, {});
|
|
909
|
+
const relations = Object.entries(tableSchema.relations ?? {}).reduce((acc, [key, value]) => {
|
|
910
|
+
const targetTsName = value.targetTableName;
|
|
911
|
+
const referenceModel = whereArgImplementer({ dbName: tableHelper({
|
|
912
|
+
db,
|
|
913
|
+
table: targetTsName
|
|
914
|
+
}).dbName });
|
|
915
|
+
acc[key] = t.field({
|
|
916
|
+
type: referenceModel,
|
|
917
|
+
required: false
|
|
918
|
+
});
|
|
919
|
+
return acc;
|
|
920
|
+
}, {});
|
|
921
|
+
return {
|
|
922
|
+
...fields,
|
|
923
|
+
...relations,
|
|
924
|
+
AND: t.field({
|
|
925
|
+
type: [ret],
|
|
926
|
+
required: false
|
|
927
|
+
}),
|
|
928
|
+
OR: t.field({
|
|
929
|
+
type: [ret],
|
|
930
|
+
required: false
|
|
931
|
+
}),
|
|
932
|
+
NOT: t.field({
|
|
933
|
+
type: ret,
|
|
934
|
+
required: false
|
|
935
|
+
})
|
|
936
|
+
};
|
|
937
|
+
} });
|
|
878
938
|
return ret;
|
|
879
939
|
};
|
|
880
940
|
return whereArgImplementer;
|
|
@@ -921,7 +981,7 @@ function deepSetProto(obj, proto = Object.prototype, seen = /* @__PURE__ */ new
|
|
|
921
981
|
if (obj === null || typeof obj !== "object") return;
|
|
922
982
|
if (seen.has(obj)) return;
|
|
923
983
|
seen.add(obj);
|
|
924
|
-
Object.setPrototypeOf(obj, proto);
|
|
984
|
+
if (!Array.isArray(obj)) Object.setPrototypeOf(obj, proto);
|
|
925
985
|
for (const key of Object.keys(obj)) deepSetProto(obj[key], proto, seen);
|
|
926
986
|
}
|
|
927
987
|
//#endregion
|
|
@@ -1592,6 +1652,77 @@ function implementDefaultWhereInputArgs(schemaBuilder) {
|
|
|
1592
1652
|
OR: t.field({ type: [DateWhereInputArgument] }),
|
|
1593
1653
|
NOT: t.field({ type: DateWhereInputArgument })
|
|
1594
1654
|
}) });
|
|
1655
|
+
const BooleanWhereInputArgument = schemaBuilder.inputRef("BooleanWhereInputArgument").implement({ fields: (t) => ({
|
|
1656
|
+
eq: t.boolean(),
|
|
1657
|
+
ne: t.boolean(),
|
|
1658
|
+
in: t.booleanList(),
|
|
1659
|
+
notIn: t.booleanList(),
|
|
1660
|
+
isNull: t.boolean(),
|
|
1661
|
+
isNotNull: t.boolean(),
|
|
1662
|
+
arrayOverlaps: t.booleanList(),
|
|
1663
|
+
arrayContained: t.booleanList(),
|
|
1664
|
+
arrayContains: t.booleanList(),
|
|
1665
|
+
AND: t.field({ type: [BooleanWhereInputArgument] }),
|
|
1666
|
+
OR: t.field({ type: [BooleanWhereInputArgument] }),
|
|
1667
|
+
NOT: t.field({ type: BooleanWhereInputArgument })
|
|
1668
|
+
}) });
|
|
1669
|
+
const IDWhereInputArgument = schemaBuilder.inputRef("IDWhereInputArgument").implement({ fields: (t) => ({
|
|
1670
|
+
eq: t.id(),
|
|
1671
|
+
ne: t.id(),
|
|
1672
|
+
gt: t.id(),
|
|
1673
|
+
gte: t.id(),
|
|
1674
|
+
lt: t.id(),
|
|
1675
|
+
lte: t.id(),
|
|
1676
|
+
in: t.idList(),
|
|
1677
|
+
notIn: t.idList(),
|
|
1678
|
+
like: t.string(),
|
|
1679
|
+
ilike: t.string(),
|
|
1680
|
+
notLike: t.string(),
|
|
1681
|
+
notIlike: t.string(),
|
|
1682
|
+
isNull: t.boolean(),
|
|
1683
|
+
isNotNull: t.boolean(),
|
|
1684
|
+
arrayOverlaps: t.idList(),
|
|
1685
|
+
arrayContained: t.idList(),
|
|
1686
|
+
arrayContains: t.idList(),
|
|
1687
|
+
AND: t.field({ type: [IDWhereInputArgument] }),
|
|
1688
|
+
OR: t.field({ type: [IDWhereInputArgument] }),
|
|
1689
|
+
NOT: t.field({ type: IDWhereInputArgument })
|
|
1690
|
+
}) });
|
|
1691
|
+
const JSONWhereInputArgument = schemaBuilder.inputRef("JSONWhereInputArgument").implement({ fields: (t) => ({
|
|
1692
|
+
eq: t.field({
|
|
1693
|
+
type: "JSON",
|
|
1694
|
+
required: false
|
|
1695
|
+
}),
|
|
1696
|
+
ne: t.field({
|
|
1697
|
+
type: "JSON",
|
|
1698
|
+
required: false
|
|
1699
|
+
}),
|
|
1700
|
+
in: t.field({
|
|
1701
|
+
type: ["JSON"],
|
|
1702
|
+
required: false
|
|
1703
|
+
}),
|
|
1704
|
+
notIn: t.field({
|
|
1705
|
+
type: ["JSON"],
|
|
1706
|
+
required: false
|
|
1707
|
+
}),
|
|
1708
|
+
isNull: t.boolean(),
|
|
1709
|
+
isNotNull: t.boolean(),
|
|
1710
|
+
arrayOverlaps: t.field({
|
|
1711
|
+
type: ["JSON"],
|
|
1712
|
+
required: false
|
|
1713
|
+
}),
|
|
1714
|
+
arrayContained: t.field({
|
|
1715
|
+
type: ["JSON"],
|
|
1716
|
+
required: false
|
|
1717
|
+
}),
|
|
1718
|
+
arrayContains: t.field({
|
|
1719
|
+
type: ["JSON"],
|
|
1720
|
+
required: false
|
|
1721
|
+
}),
|
|
1722
|
+
AND: t.field({ type: [JSONWhereInputArgument] }),
|
|
1723
|
+
OR: t.field({ type: [JSONWhereInputArgument] }),
|
|
1724
|
+
NOT: t.field({ type: JSONWhereInputArgument })
|
|
1725
|
+
}) });
|
|
1595
1726
|
}
|
|
1596
1727
|
//#endregion
|
|
1597
1728
|
//#region lib/runtimeFiltersPlugin/filterTypes.ts
|