@m1212e/rumble 0.18.9 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/client/generate.cjs +1 -1
- package/out/client/generate.d.cts.map +1 -1
- package/out/client/generate.d.mts.map +1 -1
- package/out/client/generate.mjs +1 -1
- package/out/client.cjs +2 -3
- package/out/client.cjs.map +1 -1
- package/out/client.d.cts.map +1 -1
- package/out/client.d.mts.map +1 -1
- package/out/client.mjs +2 -2
- package/out/client.mjs.map +1 -1
- package/out/{generate-BxAyU8HE.mjs → generate-B4w-hX0K.mjs} +1 -1
- package/out/{generate-BxAyU8HE.mjs.map → generate-B4w-hX0K.mjs.map} +1 -1
- package/out/{generate-v10zBoUq.cjs → generate-Ch5LEiBr.cjs} +1 -2
- package/out/{generate-v10zBoUq.cjs.map → generate-Ch5LEiBr.cjs.map} +1 -1
- package/out/index.cjs +40 -47
- package/out/index.cjs.map +1 -1
- package/out/index.d.cts +35 -41
- package/out/index.d.cts.map +1 -1
- package/out/index.d.mts +33 -39
- package/out/index.d.mts.map +1 -1
- package/out/index.mjs +41 -47
- package/out/index.mjs.map +1 -1
- package/out/{lazy-BgeBy3-B.mjs → lazy-C7IyM4M4.mjs} +1 -1
- package/out/{lazy-BgeBy3-B.mjs.map → lazy-C7IyM4M4.mjs.map} +1 -1
- package/out/{lazy-DT--QoPa.cjs → lazy-CAN0oaXD.cjs} +1 -1
- package/out/{lazy-DT--QoPa.cjs.map → lazy-CAN0oaXD.cjs.map} +1 -1
- package/package.json +20 -20
package/out/index.cjs
CHANGED
|
@@ -21,8 +21,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
|
-
const require_lazy = require("./lazy-
|
|
25
|
-
const require_generate = require("./generate-
|
|
24
|
+
const require_lazy = require("./lazy-CAN0oaXD.cjs");
|
|
25
|
+
const require_generate = require("./generate-Ch5LEiBr.cjs");
|
|
26
26
|
let graphql = require("graphql");
|
|
27
27
|
let _escape_tech_graphql_armor = require("@escape.tech/graphql-armor");
|
|
28
28
|
let _graphql_yoga_plugin_disable_introspection = require("@graphql-yoga/plugin-disable-introspection");
|
|
@@ -208,7 +208,7 @@ function mapNullFieldsToUndefined(obj) {
|
|
|
208
208
|
}
|
|
209
209
|
//#endregion
|
|
210
210
|
//#region package.json
|
|
211
|
-
var version = "0.
|
|
211
|
+
var version = "0.20.0";
|
|
212
212
|
//#endregion
|
|
213
213
|
//#region lib/helpers/mergeFilters.ts
|
|
214
214
|
function mergeFilters(filterA, filterB, mode = "AND") {
|
|
@@ -331,23 +331,28 @@ function createDistinctValuesFromSQLType(sqlType) {
|
|
|
331
331
|
const drizzleNameSymbol = Symbol.for("drizzle:Name");
|
|
332
332
|
const drizzleOriginalNameSymbol = Symbol.for("drizzle:OriginalName");
|
|
333
333
|
const drizzleBaseNameSymbol = Symbol.for("drizzle:BaseName");
|
|
334
|
+
const drizzleColumnsSymbol = Symbol.for("drizzle:Columns");
|
|
334
335
|
function tableHelper({ db, table }) {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
if (!
|
|
336
|
+
let tableName;
|
|
337
|
+
if (typeof table !== "string") {
|
|
338
|
+
const t = table;
|
|
339
|
+
tableName = t.name ?? t[drizzleNameSymbol] ?? t[drizzleOriginalNameSymbol] ?? t[drizzleBaseNameSymbol];
|
|
340
|
+
} else tableName = table;
|
|
341
|
+
const foundRelation = Object.values(db._.relations).find((entry) => entry.name === tableName || entry.table[drizzleNameSymbol] === tableName || entry.table[drizzleOriginalNameSymbol] === tableName || entry.table[drizzleBaseNameSymbol] === tableName);
|
|
342
|
+
if (!foundRelation) throw new RumbleError(`Could not find schema for ${JSON.stringify(tableName)}`);
|
|
343
|
+
const tableObj = foundRelation.table;
|
|
344
|
+
const columns = tableObj[drizzleColumnsSymbol] ?? {};
|
|
345
|
+
const primaryKey = Object.fromEntries(Object.entries(columns).filter(([_, col]) => col.primary));
|
|
346
|
+
const dbName = tableObj[drizzleOriginalNameSymbol] ?? tableObj[drizzleBaseNameSymbol] ?? tableObj[drizzleNameSymbol] ?? foundRelation.name;
|
|
347
|
+
const tsName = foundRelation.name;
|
|
342
348
|
return {
|
|
343
|
-
columns
|
|
344
|
-
primaryKey
|
|
349
|
+
columns,
|
|
350
|
+
primaryKey,
|
|
345
351
|
relations: foundRelation.relations,
|
|
346
|
-
dbName
|
|
347
|
-
tsName
|
|
348
|
-
|
|
349
|
-
foundRelation
|
|
350
|
-
fullSchema
|
|
352
|
+
dbName,
|
|
353
|
+
tsName,
|
|
354
|
+
table: tableObj,
|
|
355
|
+
foundRelation
|
|
351
356
|
};
|
|
352
357
|
}
|
|
353
358
|
//#endregion
|
|
@@ -500,7 +505,7 @@ by: (explicitFilter) => {
|
|
|
500
505
|
return limit ?? void 0;
|
|
501
506
|
});
|
|
502
507
|
const sqlTransformedWhere = require_lazy.lazy(() => {
|
|
503
|
-
const casing = db._.session?.dialect?.casing
|
|
508
|
+
const casing = db._.session?.dialect?.casing;
|
|
504
509
|
return filters?.where ? (0, drizzle_orm.relationsFilterToSQL)(tableSchema.foundRelation.table, filters.where, tableSchema.relations, db._.relations, casing) : void 0;
|
|
505
510
|
});
|
|
506
511
|
if (filters?.columns) return {
|
|
@@ -726,27 +731,30 @@ const createOrderArgImplementer = ({ db, schemaBuilder }) => {
|
|
|
726
731
|
//#endregion
|
|
727
732
|
//#region lib/enum.ts
|
|
728
733
|
/**
|
|
729
|
-
* Checks if a
|
|
734
|
+
* Checks if a column is a PgEnumColumn
|
|
730
735
|
*/
|
|
731
736
|
function isEnumSchema(schemaType) {
|
|
732
737
|
return schemaType instanceof drizzle_orm_pg_core.PgEnumColumn;
|
|
733
738
|
}
|
|
734
|
-
const createEnumImplementer = ({
|
|
739
|
+
const createEnumImplementer = ({ schemaBuilder }) => {
|
|
735
740
|
const referenceStorage = /* @__PURE__ */ new Map();
|
|
736
|
-
|
|
741
|
+
/**
|
|
742
|
+
* Registers a Postgres enum as a GraphQL enum type.
|
|
743
|
+
*
|
|
744
|
+
* Pass the `enum` option with the pgEnum object (e.g. `moodEnum`),
|
|
745
|
+
* or pass the `enumColumn` option with a column that uses the enum.
|
|
746
|
+
* Use `refName` to override the auto-generated GraphQL type name.
|
|
747
|
+
*/
|
|
748
|
+
const enumImplementer = ({ enum: enumObject, enumColumn, refName }) => {
|
|
737
749
|
let enumSchemaName;
|
|
738
750
|
let enumValues;
|
|
739
|
-
if (
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
const enumCol = Object.values(db._.schema).filter((s) => typeof s === "object").map((s) => Object.values(s.columns)).flat(2).filter(isEnumSchema).find((e) => e.config.enum === schemaEnum);
|
|
743
|
-
if (!enumCol) throw new RumbleError(`Could not find applied enum column for ${tsName.toString()}.
|
|
744
|
-
Please ensure that you use the enum at least once as a column of a table!`);
|
|
745
|
-
enumValues = enumCol.enumValues;
|
|
751
|
+
if (enumObject) {
|
|
752
|
+
enumSchemaName = enumObject.enumName;
|
|
753
|
+
enumValues = enumObject.enumValues;
|
|
746
754
|
} else if (enumColumn) {
|
|
747
|
-
const
|
|
748
|
-
if (!
|
|
749
|
-
enumSchemaName =
|
|
755
|
+
const pgEnum = enumColumn.enum;
|
|
756
|
+
if (!pgEnum) throw new RumbleError(`Could not find enum definition on column. Make sure the column is a pgEnum column.`);
|
|
757
|
+
enumSchemaName = pgEnum.enumName;
|
|
750
758
|
enumValues = enumColumn.enumValues;
|
|
751
759
|
}
|
|
752
760
|
if (!enumSchemaName || !enumValues) throw new RumbleError("Could not determine enum structure!");
|
|
@@ -922,7 +930,7 @@ const createCountQueryImplementer = ({ db, schemaBuilder, whereArgImplementer, m
|
|
|
922
930
|
resolve: async (root, args, ctx, info) => {
|
|
923
931
|
if (isAllowed && !await isAllowed(ctx)) throw new RumbleErrorSafe("Not allowed to perform this action");
|
|
924
932
|
deepSetProto(args);
|
|
925
|
-
return db.select({ count: (0, drizzle_orm.count)() }).from(tableSchema.
|
|
933
|
+
return db.select({ count: (0, drizzle_orm.count)() }).from(tableSchema.table).where(ctx.abilities[table].filter(listAction).merge(mapNullFieldsToUndefined(args)).sql.where).then(assertFirstEntryExists).then((r) => r.count);
|
|
926
934
|
}
|
|
927
935
|
}) };
|
|
928
936
|
});
|
|
@@ -1667,19 +1675,6 @@ const createSchemaBuilder = ({ db, disableDefaultObjects, pubsub, pothosConfig,
|
|
|
1667
1675
|
//#endregion
|
|
1668
1676
|
//#region lib/rumble.ts
|
|
1669
1677
|
const rumble = (rumbleInput) => {
|
|
1670
|
-
if (!rumbleInput.db._.schema) throw new RumbleError(`
|
|
1671
|
-
rumble could not find any schema in the provided drizzle instance.
|
|
1672
|
-
Make sure you import the schema and pass it to the drizzle instance:
|
|
1673
|
-
|
|
1674
|
-
export const db = drizzle(
|
|
1675
|
-
"postgres://postgres:postgres@localhost:5432/postgres",
|
|
1676
|
-
{
|
|
1677
|
-
relations,
|
|
1678
|
-
schema, // <--- add this line
|
|
1679
|
-
},
|
|
1680
|
-
);
|
|
1681
|
-
|
|
1682
|
-
`);
|
|
1683
1678
|
if (!rumbleInput.db._.relations) throw new RumbleError(`
|
|
1684
1679
|
rumble could not find any relations in the provided drizzle instance.
|
|
1685
1680
|
Make sure you import the relations and pass them to the drizzle instance:
|
|
@@ -1688,7 +1683,6 @@ export const db = drizzle(
|
|
|
1688
1683
|
"postgres://postgres:postgres@localhost:5432/postgres",
|
|
1689
1684
|
{
|
|
1690
1685
|
relations, // <--- add this line
|
|
1691
|
-
schema,
|
|
1692
1686
|
},
|
|
1693
1687
|
);
|
|
1694
1688
|
|
|
@@ -1933,7 +1927,6 @@ export const db = drizzle(
|
|
|
1933
1927
|
//#endregion
|
|
1934
1928
|
exports.RumbleError = RumbleError;
|
|
1935
1929
|
exports.RumbleErrorSafe = RumbleErrorSafe;
|
|
1936
|
-
exports.__toESM = __toESM;
|
|
1937
1930
|
exports.assertFindFirstExists = assertFindFirstExists;
|
|
1938
1931
|
exports.assertFirstEntryExists = assertFirstEntryExists;
|
|
1939
1932
|
exports.mapNullFieldsToUndefined = mapNullFieldsToUndefined;
|