@m1212e/rumble 0.21.5 → 0.22.1

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 CHANGED
@@ -208,7 +208,7 @@ function mapNullFieldsToUndefined(obj) {
208
208
  }
209
209
  //#endregion
210
210
  //#region package.json
211
- var version = "0.21.5";
211
+ var version = "0.22.1";
212
212
  //#endregion
213
213
  //#region lib/helpers/mergeFilters.ts
214
214
  function mergeFilters(filterA, filterB, mode = "AND") {
@@ -843,66 +843,126 @@ function mapSQLTypeToGraphQLType({ sqlType, fieldName }) {
843
843
  const makeDefaultName = (dbName) => `${(0, es_toolkit.capitalize)((0, drizzle_orm_casing.toCamelCase)(dbName.toString()))}WhereInputArgument`;
844
844
  const createWhereArgImplementer = ({ db, schemaBuilder, enumImplementer }) => {
845
845
  const referenceStorage = /* @__PURE__ */ new Map();
846
+ const enumArrayWhereInputStorage = /* @__PURE__ */ new Map();
847
+ const getEnumArrayWhereInput = (enumImpl) => {
848
+ const typeName = `${enumImpl.name}WhereInputArgument`;
849
+ const existing = enumArrayWhereInputStorage.get(typeName);
850
+ if (existing) return existing;
851
+ const ret = schemaBuilder.inputRef(typeName);
852
+ enumArrayWhereInputStorage.set(typeName, ret);
853
+ ret.implement({ fields: (t) => ({
854
+ eq: t.field({
855
+ type: enumImpl,
856
+ required: false
857
+ }),
858
+ ne: t.field({
859
+ type: enumImpl,
860
+ required: false
861
+ }),
862
+ in: t.field({
863
+ type: [enumImpl],
864
+ required: false
865
+ }),
866
+ notIn: t.field({
867
+ type: [enumImpl],
868
+ required: false
869
+ }),
870
+ isNull: t.boolean({ required: false }),
871
+ isNotNull: t.boolean({ required: false }),
872
+ arrayOverlaps: t.field({
873
+ type: [enumImpl],
874
+ required: false
875
+ }),
876
+ arrayContained: t.field({
877
+ type: [enumImpl],
878
+ required: false
879
+ }),
880
+ arrayContains: t.field({
881
+ type: [enumImpl],
882
+ required: false
883
+ }),
884
+ AND: t.field({
885
+ type: [ret],
886
+ required: false
887
+ }),
888
+ OR: t.field({
889
+ type: [ret],
890
+ required: false
891
+ }),
892
+ NOT: t.field({
893
+ type: ret,
894
+ required: false
895
+ })
896
+ }) });
897
+ return ret;
898
+ };
846
899
  const whereArgImplementer = ({ table, refName, dbName }) => {
847
900
  const tableSchema = tableHelper({
848
901
  db,
849
902
  table: dbName ?? table
850
903
  });
851
904
  const inputTypeName = refName ?? makeDefaultName(tableSchema.tsName);
852
- let ret = referenceStorage.get(inputTypeName);
853
- if (ret) return ret;
854
- const implement = () => {
855
- return schemaBuilder.inputType(inputTypeName, { fields: (t) => {
856
- const mapSQLTypeStringToInputPothosType = (sqlType, fieldName) => {
857
- const gqlType = mapSQLTypeToGraphQLType({
858
- sqlType,
859
- fieldName
860
- });
861
- switch (gqlType) {
862
- case "Int": return t.field({ type: "IntWhereInputArgument" });
863
- case "String": return t.field({ type: "StringWhereInputArgument" });
864
- case "Boolean": return t.boolean({ required: false });
865
- case "Date": return t.field({ type: "DateWhereInputArgument" });
866
- case "DateTime": return t.field({ type: "DateWhereInputArgument" });
867
- case "Float": return t.field({ type: "FloatWhereInputArgument" });
868
- case "ID": return t.id({ required: false });
869
- case "JSON": return t.field({
870
- type: "JSON",
871
- required: false
872
- });
873
- default: throw new RumbleError(`Unsupported argument type ${gqlType} for column ${sqlType}`);
874
- }
875
- };
876
- const fields = Object.entries(tableSchema.columns).reduce((acc, [key, value]) => {
877
- if (isEnumSchema(value)) {
878
- const enumImpl = enumImplementer({ enumColumn: value });
879
- acc[key] = t.field({
880
- type: enumImpl,
881
- required: false
882
- });
883
- } else acc[key] = mapSQLTypeStringToInputPothosType(value.getSQLType(), key);
884
- return acc;
885
- }, {});
886
- const relations = Object.entries(tableSchema.relations ?? {}).reduce((acc, [key, value]) => {
887
- const targetTsName = value.targetTableName;
888
- const referenceModel = whereArgImplementer({ dbName: tableHelper({
889
- db,
890
- table: targetTsName
891
- }).dbName });
905
+ const existing = referenceStorage.get(inputTypeName);
906
+ if (existing) return existing;
907
+ const ret = schemaBuilder.inputRef(inputTypeName);
908
+ referenceStorage.set(inputTypeName, ret);
909
+ ret.implement({ fields: (t) => {
910
+ const mapSQLTypeStringToInputPothosType = (sqlType, fieldName) => {
911
+ const gqlType = mapSQLTypeToGraphQLType({
912
+ sqlType,
913
+ fieldName
914
+ });
915
+ switch (gqlType) {
916
+ case "Int": return t.field({ type: "IntWhereInputArgument" });
917
+ case "String": return t.field({ type: "StringWhereInputArgument" });
918
+ case "Boolean": return t.field({ type: "BooleanWhereInputArgument" });
919
+ case "Date": return t.field({ type: "DateWhereInputArgument" });
920
+ case "DateTime": return t.field({ type: "DateWhereInputArgument" });
921
+ case "Float": return t.field({ type: "FloatWhereInputArgument" });
922
+ case "ID": return t.field({ type: "IDWhereInputArgument" });
923
+ case "JSON": return t.field({ type: "JSONWhereInputArgument" });
924
+ default: throw new RumbleError(`Unsupported argument type ${gqlType} for column ${sqlType}`);
925
+ }
926
+ };
927
+ const fields = Object.entries(tableSchema.columns).reduce((acc, [key, value]) => {
928
+ if (isEnumSchema(value)) {
929
+ const enumImpl = enumImplementer({ enumColumn: value });
892
930
  acc[key] = t.field({
893
- type: referenceModel,
931
+ type: value.dimensions > 0 ? getEnumArrayWhereInput(enumImpl) : enumImpl,
894
932
  required: false
895
933
  });
896
- return acc;
897
- }, {});
898
- return {
899
- ...fields,
900
- ...relations
901
- };
902
- } });
903
- };
904
- ret = implement();
905
- referenceStorage.set(inputTypeName, ret);
934
+ } else acc[key] = mapSQLTypeStringToInputPothosType(value.getSQLType(), key);
935
+ return acc;
936
+ }, {});
937
+ const relations = Object.entries(tableSchema.relations ?? {}).reduce((acc, [key, value]) => {
938
+ const targetTsName = value.targetTableName;
939
+ const referenceModel = whereArgImplementer({ dbName: tableHelper({
940
+ db,
941
+ table: targetTsName
942
+ }).dbName });
943
+ acc[key] = t.field({
944
+ type: referenceModel,
945
+ required: false
946
+ });
947
+ return acc;
948
+ }, {});
949
+ return {
950
+ ...fields,
951
+ ...relations,
952
+ AND: t.field({
953
+ type: [ret],
954
+ required: false
955
+ }),
956
+ OR: t.field({
957
+ type: [ret],
958
+ required: false
959
+ }),
960
+ NOT: t.field({
961
+ type: ret,
962
+ required: false
963
+ })
964
+ };
965
+ } });
906
966
  return ret;
907
967
  };
908
968
  return whereArgImplementer;
@@ -949,7 +1009,7 @@ function deepSetProto(obj, proto = Object.prototype, seen = /* @__PURE__ */ new
949
1009
  if (obj === null || typeof obj !== "object") return;
950
1010
  if (seen.has(obj)) return;
951
1011
  seen.add(obj);
952
- Object.setPrototypeOf(obj, proto);
1012
+ if (!Array.isArray(obj)) Object.setPrototypeOf(obj, proto);
953
1013
  for (const key of Object.keys(obj)) deepSetProto(obj[key], proto, seen);
954
1014
  }
955
1015
  //#endregion
@@ -1620,6 +1680,77 @@ function implementDefaultWhereInputArgs(schemaBuilder) {
1620
1680
  OR: t.field({ type: [DateWhereInputArgument] }),
1621
1681
  NOT: t.field({ type: DateWhereInputArgument })
1622
1682
  }) });
1683
+ const BooleanWhereInputArgument = schemaBuilder.inputRef("BooleanWhereInputArgument").implement({ fields: (t) => ({
1684
+ eq: t.boolean(),
1685
+ ne: t.boolean(),
1686
+ in: t.booleanList(),
1687
+ notIn: t.booleanList(),
1688
+ isNull: t.boolean(),
1689
+ isNotNull: t.boolean(),
1690
+ arrayOverlaps: t.booleanList(),
1691
+ arrayContained: t.booleanList(),
1692
+ arrayContains: t.booleanList(),
1693
+ AND: t.field({ type: [BooleanWhereInputArgument] }),
1694
+ OR: t.field({ type: [BooleanWhereInputArgument] }),
1695
+ NOT: t.field({ type: BooleanWhereInputArgument })
1696
+ }) });
1697
+ const IDWhereInputArgument = schemaBuilder.inputRef("IDWhereInputArgument").implement({ fields: (t) => ({
1698
+ eq: t.id(),
1699
+ ne: t.id(),
1700
+ gt: t.id(),
1701
+ gte: t.id(),
1702
+ lt: t.id(),
1703
+ lte: t.id(),
1704
+ in: t.idList(),
1705
+ notIn: t.idList(),
1706
+ like: t.string(),
1707
+ ilike: t.string(),
1708
+ notLike: t.string(),
1709
+ notIlike: t.string(),
1710
+ isNull: t.boolean(),
1711
+ isNotNull: t.boolean(),
1712
+ arrayOverlaps: t.idList(),
1713
+ arrayContained: t.idList(),
1714
+ arrayContains: t.idList(),
1715
+ AND: t.field({ type: [IDWhereInputArgument] }),
1716
+ OR: t.field({ type: [IDWhereInputArgument] }),
1717
+ NOT: t.field({ type: IDWhereInputArgument })
1718
+ }) });
1719
+ const JSONWhereInputArgument = schemaBuilder.inputRef("JSONWhereInputArgument").implement({ fields: (t) => ({
1720
+ eq: t.field({
1721
+ type: "JSON",
1722
+ required: false
1723
+ }),
1724
+ ne: t.field({
1725
+ type: "JSON",
1726
+ required: false
1727
+ }),
1728
+ in: t.field({
1729
+ type: ["JSON"],
1730
+ required: false
1731
+ }),
1732
+ notIn: t.field({
1733
+ type: ["JSON"],
1734
+ required: false
1735
+ }),
1736
+ isNull: t.boolean(),
1737
+ isNotNull: t.boolean(),
1738
+ arrayOverlaps: t.field({
1739
+ type: ["JSON"],
1740
+ required: false
1741
+ }),
1742
+ arrayContained: t.field({
1743
+ type: ["JSON"],
1744
+ required: false
1745
+ }),
1746
+ arrayContains: t.field({
1747
+ type: ["JSON"],
1748
+ required: false
1749
+ }),
1750
+ AND: t.field({ type: [JSONWhereInputArgument] }),
1751
+ OR: t.field({ type: [JSONWhereInputArgument] }),
1752
+ NOT: t.field({ type: JSONWhereInputArgument })
1753
+ }) });
1623
1754
  }
1624
1755
  //#endregion
1625
1756
  //#region lib/runtimeFiltersPlugin/filterTypes.ts