@m1212e/rumble 0.5.5 → 0.6.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/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../node_modules/graphql/jsutils/isObjectLike.mjs","../node_modules/graphql/jsutils/invariant.mjs","../node_modules/graphql/language/location.mjs","../node_modules/graphql/language/printLocation.mjs","../node_modules/graphql/error/GraphQLError.mjs","../lib/types/rumbleError.ts","../lib/helpers/sqlTypes/types.ts","../lib/helpers/sqlTypes/distinctValuesFromSQLType.ts","../lib/abilityBuilder.ts","../lib/context.ts","../lib/enum.ts","../lib/helpers/capitalize.ts","../lib/helpers/sqlTypes/mapSQLTypeToTSType.ts","../lib/pubsub.ts","../lib/object.ts","../lib/helpers/helper.ts","../lib/query.ts","../lib/explicitFiltersPlugin/explicitFiltersPlugin.ts","../lib/schemaBuilder.ts","../lib/whereArg.ts","../lib/rumble.ts"],"names":["isObjectLike","value","invariant","condition","message","LineRegExp","getLocation","source","position","lastLineStart","line","match","printLocation","location","printSourceLocation","sourceLocation","firstLineColumnOffset","body","lineIndex","lineOffset","lineNum","columnOffset","columnNum","locationStr","lines","locationLine","subLineIndex","subLineColumnNum","subLines","i","printPrefixedLines","subLine","existingLines","_","padLen","prefix","toNormalizedOptions","args","firstArg","GraphQLError","_GraphQLError","rawArgs","_this$nodes","_nodeLocations$","_ref","nodes","positions","path","originalError","extensions","undefinedIfEmpty","nodeLocations","node","loc","pos","originalExtensions","output","formattedError","array","RumbleError","RumbleErrorSafe","UnknownTypeRumbleError","sqlType","additionalInfo","createDistinctValuesFromSQLType","isSimpleCondition","isSyncFunctionCondition","createAbilityBuilder","db","actions","defaultLimit","schema","registrators","registeredConditions","registeredFilters","createRegistrator","entityKey","action","conditionsPerEntity","conditionsPerEntityAndAction","explicitFilter","userContext","builder","createEntityObject","options","getBlockEverythingFilter","primaryKeyField","distinctValues","and","eq","simpleConditions","syncFunctionConditions","someWildcardFound","c","allConditionObjects","o","highestLimit","conditionObject","combinedAllowedColumns","accumulatedWhereConditions","combinedWhere","or","createContextFunction","makeUserContext","abilityBuilder","req","capitalizeFirstLetter","val","isRuntimeEnumSchemaType","schemaType","enumSchema","mapRuntimeEnumSchemaType","createEnumImplementer","schemaBuilder","referenceStorage","enumVariableName","name","enumName","fullSchema","e","graphqlImplementationName","toCamelCase","ret","mapSQLTypeToGraphQLType","SUBSCRIPTION_NOTIFIER_RUMBLE_PREFIX","SUBSCRIPTION_NOTIFIER_REMOVED","SUBSCRIPTION_NOTIFIER_UPDATED","SUBSCRIPTION_NOTIFIER_CREATED","createPubSubInstance","subscriptions","pubsub","createPubSub","tableName","makePubSubKey","primaryKeyValue","actionKey","instance","key","keys","uniqueKeys","createObjectImplementer","makePubSubInstance","argImplementer","enumImplementer","readAction","extend","tableSchema","primaryKey","registerOnInstance","element","context","t","mapSQLTypeStringToExposedPothosType","columnName","nullable","gqlType","fields","acc","enumVal","enumImpl","relations","WhereArg","transformWhere","filterSpecifier","One","isMany","ctx","found","v","assertFindFirstExists","assertFirstEntryExists","applyFilters","filters","entities","f","createQueryImplementer","listAction","root","info","query","filter","queryInstance","pluginName","explicitFiltersPlugin_default","applyFiltersKey","ManualFiltersPlugin","BasePlugin","resolver","fieldConfig","parent","resolved","allResolvedValues","allFilters","allowed","SchemaBuilder","createSchemaBuilder","disableDefaultObjects","pothosConfig","DrizzlePlugin","SmartSubscriptionsPlugin","subscribeOptionsFromIterator","JSONResolver","DateResolver","DateTimeISOResolver","makeDefaultName","dbName","createArgImplementer","nativeTableName","inputTypeName","mapSQLTypeStringToInputPothosType","referenceModel","arg","mapColumnToQueryCondition","columnname","column","filterValue","mapRelationToQueryCondition","relationColumnName","relationColumn","transformer","conditions","rumble","rumbleInput","enum_","object","nativeCreateYoga"],"mappings":"qXAIO,SAASA,CAAaC,CAAAA,CAAAA,CAAO,CAClC,OAAO,OAAOA,CAAS,EAAA,QAAA,EAAYA,IAAU,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AA+B,CAC9B,GAAG5L,EACH,MAAQ4E,CAAAA,CAAAA,CAAc,UACtB,CAAA,OAAA,CAAAqC,CACD,CAAC,CAAA,CAyCD,OAAA0E,CAIA,CAAA,GAAA,CAAAb,EAKA,KAAAhC,CAAAA,CAAAA,CAIA,OAAQtC,CAMR,CAAA,KAAA,CAAAkF,CACD,CACD","file":"index.js","sourcesContent":["/**\n * Return true if `value` is object-like. A value is object-like if it's not\n * `null` and has a `typeof` result of \"object\".\n */\nexport function isObjectLike(value) {\n return typeof value == 'object' && value !== null;\n}\n","export function invariant(condition, message) {\n const booleanCondition = Boolean(condition);\n\n if (!booleanCondition) {\n throw new Error(\n message != null ? message : 'Unexpected invariant triggered.',\n );\n }\n}\n","import { invariant } from '../jsutils/invariant.mjs';\nconst LineRegExp = /\\r\\n|[\\n\\r]/g;\n/**\n * Represents a location in a Source.\n */\n\n/**\n * Takes a Source and a UTF-8 character offset, and returns the corresponding\n * line and column as a SourceLocation.\n */\nexport function getLocation(source, position) {\n let lastLineStart = 0;\n let line = 1;\n\n for (const match of source.body.matchAll(LineRegExp)) {\n typeof match.index === 'number' || invariant(false);\n\n if (match.index >= position) {\n break;\n }\n\n lastLineStart = match.index + match[0].length;\n line += 1;\n }\n\n return {\n line,\n column: position + 1 - lastLineStart,\n };\n}\n","import { getLocation } from './location.mjs';\n\n/**\n * Render a helpful description of the location in the GraphQL Source document.\n */\nexport function printLocation(location) {\n return printSourceLocation(\n location.source,\n getLocation(location.source, location.start),\n );\n}\n/**\n * Render a helpful description of the location in the GraphQL Source document.\n */\n\nexport function printSourceLocation(source, sourceLocation) {\n const firstLineColumnOffset = source.locationOffset.column - 1;\n const body = ''.padStart(firstLineColumnOffset) + source.body;\n const lineIndex = sourceLocation.line - 1;\n const lineOffset = source.locationOffset.line - 1;\n const lineNum = sourceLocation.line + lineOffset;\n const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0;\n const columnNum = sourceLocation.column + columnOffset;\n const locationStr = `${source.name}:${lineNum}:${columnNum}\\n`;\n const lines = body.split(/\\r\\n|[\\n\\r]/g);\n const locationLine = lines[lineIndex]; // Special case for minified documents\n\n if (locationLine.length > 120) {\n const subLineIndex = Math.floor(columnNum / 80);\n const subLineColumnNum = columnNum % 80;\n const subLines = [];\n\n for (let i = 0; i < locationLine.length; i += 80) {\n subLines.push(locationLine.slice(i, i + 80));\n }\n\n return (\n locationStr +\n printPrefixedLines([\n [`${lineNum} |`, subLines[0]],\n ...subLines.slice(1, subLineIndex + 1).map((subLine) => ['|', subLine]),\n ['|', '^'.padStart(subLineColumnNum)],\n ['|', subLines[subLineIndex + 1]],\n ])\n );\n }\n\n return (\n locationStr +\n printPrefixedLines([\n // Lines specified like this: [\"prefix\", \"string\"],\n [`${lineNum - 1} |`, lines[lineIndex - 1]],\n [`${lineNum} |`, locationLine],\n ['|', '^'.padStart(columnNum)],\n [`${lineNum + 1} |`, lines[lineIndex + 1]],\n ])\n );\n}\n\nfunction printPrefixedLines(lines) {\n const existingLines = lines.filter(([_, line]) => line !== undefined);\n const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));\n return existingLines\n .map(([prefix, line]) => prefix.padStart(padLen) + (line ? ' ' + line : ''))\n .join('\\n');\n}\n","import { isObjectLike } from '../jsutils/isObjectLike.mjs';\nimport { getLocation } from '../language/location.mjs';\nimport {\n printLocation,\n printSourceLocation,\n} from '../language/printLocation.mjs';\n\nfunction toNormalizedOptions(args) {\n const firstArg = args[0];\n\n if (firstArg == null || 'kind' in firstArg || 'length' in firstArg) {\n return {\n nodes: firstArg,\n source: args[1],\n positions: args[2],\n path: args[3],\n originalError: args[4],\n extensions: args[5],\n };\n }\n\n return firstArg;\n}\n/**\n * A GraphQLError describes an Error found during the parse, validate, or\n * execute phases of performing a GraphQL operation. In addition to a message\n * and stack trace, it also includes information about the locations in a\n * GraphQL document and/or execution result that correspond to the Error.\n */\n\nexport class GraphQLError extends Error {\n /**\n * An array of `{ line, column }` locations within the source GraphQL document\n * which correspond to this error.\n *\n * Errors during validation often contain multiple locations, for example to\n * point out two things with the same name. Errors during execution include a\n * single location, the field which produced the error.\n *\n * Enumerable, and appears in the result of JSON.stringify().\n */\n\n /**\n * An array describing the JSON-path into the execution response which\n * corresponds to this error. Only included for errors during execution.\n *\n * Enumerable, and appears in the result of JSON.stringify().\n */\n\n /**\n * An array of GraphQL AST Nodes corresponding to this error.\n */\n\n /**\n * The source GraphQL document for the first location of this error.\n *\n * Note that if this Error represents more than one node, the source may not\n * represent nodes after the first node.\n */\n\n /**\n * An array of character offsets within the source GraphQL document\n * which correspond to this error.\n */\n\n /**\n * The original error thrown from a field resolver during execution.\n */\n\n /**\n * Extension fields to add to the formatted error.\n */\n\n /**\n * @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.\n */\n constructor(message, ...rawArgs) {\n var _this$nodes, _nodeLocations$, _ref;\n\n const { nodes, source, positions, path, originalError, extensions } =\n toNormalizedOptions(rawArgs);\n super(message);\n this.name = 'GraphQLError';\n this.path = path !== null && path !== void 0 ? path : undefined;\n this.originalError =\n originalError !== null && originalError !== void 0\n ? originalError\n : undefined; // Compute list of blame nodes.\n\n this.nodes = undefinedIfEmpty(\n Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined,\n );\n const nodeLocations = undefinedIfEmpty(\n (_this$nodes = this.nodes) === null || _this$nodes === void 0\n ? void 0\n : _this$nodes.map((node) => node.loc).filter((loc) => loc != null),\n ); // Compute locations in the source for the given nodes/positions.\n\n this.source =\n source !== null && source !== void 0\n ? source\n : nodeLocations === null || nodeLocations === void 0\n ? void 0\n : (_nodeLocations$ = nodeLocations[0]) === null ||\n _nodeLocations$ === void 0\n ? void 0\n : _nodeLocations$.source;\n this.positions =\n positions !== null && positions !== void 0\n ? positions\n : nodeLocations === null || nodeLocations === void 0\n ? void 0\n : nodeLocations.map((loc) => loc.start);\n this.locations =\n positions && source\n ? positions.map((pos) => getLocation(source, pos))\n : nodeLocations === null || nodeLocations === void 0\n ? void 0\n : nodeLocations.map((loc) => getLocation(loc.source, loc.start));\n const originalExtensions = isObjectLike(\n originalError === null || originalError === void 0\n ? void 0\n : originalError.extensions,\n )\n ? originalError === null || originalError === void 0\n ? void 0\n : originalError.extensions\n : undefined;\n this.extensions =\n (_ref =\n extensions !== null && extensions !== void 0\n ? extensions\n : originalExtensions) !== null && _ref !== void 0\n ? _ref\n : Object.create(null); // Only properties prescribed by the spec should be enumerable.\n // Keep the rest as non-enumerable.\n\n Object.defineProperties(this, {\n message: {\n writable: true,\n enumerable: true,\n },\n name: {\n enumerable: false,\n },\n nodes: {\n enumerable: false,\n },\n source: {\n enumerable: false,\n },\n positions: {\n enumerable: false,\n },\n originalError: {\n enumerable: false,\n },\n }); // Include (non-enumerable) stack trace.\n\n /* c8 ignore start */\n // FIXME: https://github.com/graphql/graphql-js/issues/2317\n\n if (\n originalError !== null &&\n originalError !== void 0 &&\n originalError.stack\n ) {\n Object.defineProperty(this, 'stack', {\n value: originalError.stack,\n writable: true,\n configurable: true,\n });\n } else if (Error.captureStackTrace) {\n Error.captureStackTrace(this, GraphQLError);\n } else {\n Object.defineProperty(this, 'stack', {\n value: Error().stack,\n writable: true,\n configurable: true,\n });\n }\n /* c8 ignore stop */\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLError';\n }\n\n toString() {\n let output = this.message;\n\n if (this.nodes) {\n for (const node of this.nodes) {\n if (node.loc) {\n output += '\\n\\n' + printLocation(node.loc);\n }\n }\n } else if (this.source && this.locations) {\n for (const location of this.locations) {\n output += '\\n\\n' + printSourceLocation(this.source, location);\n }\n }\n\n return output;\n }\n\n toJSON() {\n const formattedError = {\n message: this.message,\n };\n\n if (this.locations != null) {\n formattedError.locations = this.locations;\n }\n\n if (this.path != null) {\n formattedError.path = this.path;\n }\n\n if (this.extensions != null && Object.keys(this.extensions).length > 0) {\n formattedError.extensions = this.extensions;\n }\n\n return formattedError;\n }\n}\n\nfunction undefinedIfEmpty(array) {\n return array === undefined || array.length === 0 ? undefined : array;\n}\n/**\n * See: https://spec.graphql.org/draft/#sec-Errors\n */\n\n/**\n * Prints a GraphQLError to a string, representing useful location information\n * about the error's position in the source.\n *\n * @deprecated Please use `error.toString` instead. Will be removed in v17\n */\nexport function printError(error) {\n return error.toString();\n}\n/**\n * Given a GraphQLError, format it according to the rules described by the\n * Response Format, Errors section of the GraphQL Specification.\n *\n * @deprecated Please use `error.toJSON` instead. Will be removed in v17\n */\n\nexport function formatError(error) {\n return error.toJSON();\n}\n","import { GraphQLError } from \"graphql\";\n/**\n * An error that gets raised by rumble whenever something does not go according to plan.\n * Mostly internals, configuration errors or other unexpected things.\n */\nexport class RumbleError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"RumbleError\";\n\t}\n}\n\n/**\n * An error that gets raised by rumble whenever an error occurs in a resolver, containing\n * information safely exposeable to the user.\n * E.g. the assert helpers issue these.\n */\nexport class RumbleErrorSafe extends GraphQLError {}\n","import { RumbleError } from \"../../types/rumbleError\";\n\nexport const possibleSQLTypesStrings = [\n\t\"serial\",\n\t\"int\",\n\t\"integer\",\n\t\"tinyint\",\n\t\"smallint\",\n\t\"mediumint\",\n\t\"real\",\n\t\"decimal\",\n\t\"double\",\n\t\"float\",\n\t\"string\",\n\t\"text\",\n\t\"varchar\",\n\t\"char\",\n\t\"text(256)\",\n\t\"uuid\",\n\t\"boolean\",\n\t\"date\",\n\t\"datetime\",\n\t\"timestamp\",\n\t\"json\",\n] as const;\n\nexport type PossibleSQLType = (typeof possibleSQLTypesStrings)[number];\n\nexport const UnknownTypeRumbleError = (\n\tsqlType: string,\n\tadditionalInfo?: string,\n) =>\n\tnew RumbleError(\n\t\t`RumbleError: Unknown SQL type '${sqlType}'. Please open an issue (https://github.com/m1212e/rumble/issues) so it can be added. (${additionalInfo})`,\n\t);\n","import { type PossibleSQLType, UnknownTypeRumbleError } from \"./types\";\n\nexport function createDistinctValuesFromSQLType(sqlType: PossibleSQLType): {\n\tvalue1: any;\n\tvalue2: any;\n} {\n\tif (\n\t\t[\"serial\", \"int\", \"integer\", \"tinyint\", \"smallint\", \"mediumint\"].includes(\n\t\t\tsqlType,\n\t\t)\n\t) {\n\t\treturn {\n\t\t\tvalue1: 1,\n\t\t\tvalue2: 2,\n\t\t};\n\t}\n\n\tif ([\"real\", \"decimal\", \"double\", \"float\"].includes(sqlType)) {\n\t\treturn {\n\t\t\tvalue1: 1.1,\n\t\t\tvalue2: 2.2,\n\t\t};\n\t}\n\n\tif ([\"string\", \"text\", \"varchar\", \"char\", \"text(256)\"].includes(sqlType)) {\n\t\treturn {\n\t\t\tvalue1: \"a\",\n\t\t\tvalue2: \"b\",\n\t\t};\n\t}\n\n\tif ([\"uuid\"].includes(sqlType)) {\n\t\treturn {\n\t\t\tvalue1: \"fba31870-5528-42d7-b27e-2e5ee657aea5\",\n\t\t\tvalue2: \"fc65db81-c2d1-483d-8a25-a30e2cf6e02d\",\n\t\t};\n\t}\n\n\tif ([\"boolean\"].includes(sqlType)) {\n\t\treturn {\n\t\t\tvalue1: true,\n\t\t\tvalue2: false,\n\t\t};\n\t}\n\n\tif ([\"timestamp\", \"datetime\"].includes(sqlType)) {\n\t\treturn {\n\t\t\tvalue1: new Date(2022, 1, 1),\n\t\t\tvalue2: new Date(2022, 1, 2),\n\t\t};\n\t}\n\n\tif ([\"date\"].includes(sqlType)) {\n\t\treturn {\n\t\t\tvalue1: new Date(2022, 1, 1),\n\t\t\tvalue2: new Date(2022, 1, 2),\n\t\t};\n\t}\n\n\tif ([\"json\"].includes(sqlType)) {\n\t\treturn {\n\t\t\tvalue1: { a: 1 },\n\t\t\tvalue2: { b: 2 },\n\t\t};\n\t}\n\n\tthrow UnknownTypeRumbleError(sqlType, \"Distinct\");\n}\n","import { and, eq, or } from \"drizzle-orm\";\nimport type { Filter } from \"./explicitFiltersPlugin/pluginTypes\";\nimport { createDistinctValuesFromSQLType } from \"./helpers/sqlTypes/distinctValuesFromSQLType\";\nimport type {\n\tGenericDrizzleDbTypeConstraints,\n\tQueryConditionObject,\n} from \"./types/genericDrizzleDbType\";\nimport { RumbleError } from \"./types/rumbleError\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\n\nexport type AbilityBuilderType<\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n> = ReturnType<\n\ttypeof createAbilityBuilder<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>\n>;\n\ntype Condition<DBParameters, UserContext> =\n\t| SimpleCondition<DBParameters>\n\t| SyncFunctionCondition<DBParameters, UserContext>;\n// | AsyncFunctionCondition<DBParameters, UserContext>;\n\ntype SimpleCondition<DBParameters> = DBParameters;\ntype SyncFunctionCondition<DBParameters, UserContext> = (\n\tcontext: UserContext,\n) => DBParameters | undefined | \"allow\";\n// type AsyncFunctionCondition<DBParameters, UserContext> = (\n// \tcontext: UserContext,\n// ) => Promise<DBParameters>;\n\n// type guards for the condition types\nfunction isSimpleCondition<DBParameters, UserContext>(\n\tcondition: Condition<DBParameters, UserContext>,\n): condition is SimpleCondition<DBParameters> {\n\treturn typeof condition !== \"function\";\n}\n\nfunction isSyncFunctionCondition<DBParameters, UserContext>(\n\tcondition: Condition<DBParameters, UserContext>,\n): condition is SyncFunctionCondition<DBParameters, UserContext> {\n\treturn (\n\t\ttypeof condition === \"function\" &&\n\t\tcondition.constructor.name !== \"AsyncFunction\"\n\t);\n}\n\n// function isAsyncFunctionCondition<DBParameters, UserContext>(\n// \tcondition: Condition<DBParameters, UserContext>,\n// ): condition is AsyncFunctionCondition<DBParameters, UserContext> {\n// \treturn (\n// \t\ttypeof condition === \"function\" &&\n// \t\tcondition.constructor.name === \"AsyncFunction\"\n// \t);\n// }\n\nexport const createAbilityBuilder = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n>({\n\tdb,\n\tactions,\n\tdefaultLimit,\n}: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig>) => {\n\ttype DBQueryKey = keyof DB[\"query\"];\n\ttype DBParameters = Parameters<DB[\"query\"][DBQueryKey][\"findMany\"]>[0];\n\n\tconst schema = db._.schema as NonNullable<DB[\"_\"][\"schema\"]>;\n\n\tconst registrators: {\n\t\t[key in DBQueryKey]: ReturnType<typeof createRegistrator<key>>;\n\t} = {} as any;\n\n\tconst registeredConditions: {\n\t\t[key in DBQueryKey]: {\n\t\t\t[key in Action]:\n\t\t\t\t| (\n\t\t\t\t\t\t| QueryConditionObject\n\t\t\t\t\t\t| ((\n\t\t\t\t\t\t\t\tcontext: UserContext,\n\t\t\t\t\t\t ) => QueryConditionObject | undefined | \"allow\")\n\t\t\t\t )[]\n\t\t\t\t| \"wildcard\";\n\t\t\t// | ((context: UserContext) => Promise<QueryConditionObject>)\n\t\t};\n\t} = {} as any;\n\n\tconst registeredFilters: {\n\t\t[key in DBQueryKey]: {\n\t\t\t//TODO add a run all helper\n\t\t\t[key in Action]: Filter<UserContext, any>[];\n\t\t};\n\t} = {} as any;\n\n\tconst createRegistrator = <EntityKey extends DBQueryKey>(\n\t\tentityKey: EntityKey,\n\t) => {\n\t\t// we want to init all possible application level filters since we want to ensure\n\t\t// that the implementaiton helpers pass an object by reference when creating\n\t\t// the implementation, instead of a copy like it would be the case with undefined\n\t\tfor (const action of actions!) {\n\t\t\tif (!registeredFilters[entityKey]) {\n\t\t\t\tregisteredFilters[entityKey] = {} as any;\n\t\t\t}\n\t\t\tif (!registeredFilters[entityKey][action]) {\n\t\t\t\tregisteredFilters[entityKey][action] = [];\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tallow: (action: Action | Action[]) => {\n\t\t\t\tlet conditionsPerEntity = registeredConditions[entityKey];\n\t\t\t\tif (!conditionsPerEntity) {\n\t\t\t\t\tconditionsPerEntity = {} as any;\n\t\t\t\t\tregisteredConditions[entityKey] = conditionsPerEntity;\n\t\t\t\t}\n\n\t\t\t\tconst actions = Array.isArray(action) ? action : [action];\n\t\t\t\tfor (const action of actions) {\n\t\t\t\t\tlet conditionsPerEntityAndAction = conditionsPerEntity[action];\n\t\t\t\t\tif (!conditionsPerEntityAndAction) {\n\t\t\t\t\t\tconditionsPerEntityAndAction = \"wildcard\";\n\t\t\t\t\t\tconditionsPerEntity[action] = conditionsPerEntityAndAction;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\twhen: (condition: Condition<DBParameters, UserContext>) => {\n\t\t\t\t\t\tfor (const action of actions) {\n\t\t\t\t\t\t\tif (conditionsPerEntity[action] === \"wildcard\") {\n\t\t\t\t\t\t\t\tconditionsPerEntity[action] = [];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst conditionsPerEntityAndAction = conditionsPerEntity[action];\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tconditionsPerEntityAndAction as Exclude<\n\t\t\t\t\t\t\t\t\ttypeof conditionsPerEntityAndAction,\n\t\t\t\t\t\t\t\t\t\"wildcard\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t).push(condition);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t\tfilter: (action: Action | Action[]) => {\n\t\t\t\tconst actions = Array.isArray(action) ? action : [action];\n\t\t\t\treturn {\n\t\t\t\t\tby: (\n\t\t\t\t\t\texplicitFilter: Filter<\n\t\t\t\t\t\t\tUserContext,\n\t\t\t\t\t\t\tNonNullable<\n\t\t\t\t\t\t\t\tAwaited<ReturnType<DB[\"query\"][EntityKey][\"findFirst\"]>>\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t>,\n\t\t\t\t\t) => {\n\t\t\t\t\t\tfor (const action of actions) {\n\t\t\t\t\t\t\tregisteredFilters[entityKey][action].push(explicitFilter);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t};\n\n\tfor (const entityKey of Object.keys(db.query) as DBQueryKey[]) {\n\t\tregistrators[entityKey] = createRegistrator(entityKey);\n\t}\n\treturn {\n\t\t...registrators,\n\t\tregisteredConditions,\n\t\tregisteredFilters,\n\t\tbuildWithUserContext: (userContext: UserContext) => {\n\t\t\tconst builder: {\n\t\t\t\t[key in DBQueryKey]: ReturnType<typeof createEntityObject<key>>;\n\t\t\t} = {} as any;\n\n\t\t\tconst createEntityObject = <Key extends DBQueryKey>(entityKey: Key) => ({\n\t\t\t\tfilter: (\n\t\t\t\t\taction: Action,\n\t\t\t\t\toptions?: {\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Additional conditions applied only for this call. Useful for injecting one time additional filters\n\t\t\t\t\t\t * for e.g. user args in a handler.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tinject?: QueryConditionObject;\n\t\t\t\t\t},\n\t\t\t\t) => {\n\t\t\t\t\tlet conditionsPerEntity = registeredConditions[entityKey];\n\t\t\t\t\tif (!conditionsPerEntity) {\n\t\t\t\t\t\tconditionsPerEntity = {} as any;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet conditionsPerEntityAndAction = conditionsPerEntity[action];\n\n\t\t\t\t\t// in case we have a wildcard ability, skip the rest and only apply the injected\n\t\t\t\t\t// filters, if any\n\t\t\t\t\tif (conditionsPerEntityAndAction === \"wildcard\") {\n\t\t\t\t\t\t// the undefined type casts are not exactly correct\n\t\t\t\t\t\t// but prevent TS from doing weird things with the return\n\t\t\t\t\t\t// types of the query function with these filters applied\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tsingle: {\n\t\t\t\t\t\t\t\twhere: options?.inject?.where as undefined,\n\t\t\t\t\t\t\t\tcolumns: options?.inject?.columns as undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmany: {\n\t\t\t\t\t\t\t\twhere: options?.inject?.where as undefined,\n\t\t\t\t\t\t\t\tcolumns: options?.inject?.columns as undefined,\n\t\t\t\t\t\t\t\tlimit: (options?.inject?.limit ??\n\t\t\t\t\t\t\t\t\tdefaultLimit ??\n\t\t\t\t\t\t\t\t\tundefined) as undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst getBlockEverythingFilter = () => {\n\t\t\t\t\t\tconst primaryKeyField = schema[entityKey].primaryKey.at(0);\n\t\t\t\t\t\tif (!primaryKeyField) {\n\t\t\t\t\t\t\tthrow new RumbleError(\n\t\t\t\t\t\t\t\t`No primary key found for entity ${entityKey.toString()}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// we want a filter that excludes everything\n\t\t\t\t\t\tconst distinctValues = createDistinctValuesFromSQLType(\n\t\t\t\t\t\t\tprimaryKeyField.getSQLType(),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// when the user has no permission for anything, ensure returns nothing\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\twhere: and(\n\t\t\t\t\t\t\t\teq(primaryKeyField, distinctValues.value1),\n\t\t\t\t\t\t\t\teq(primaryKeyField, distinctValues.value2),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t};\n\t\t\t\t\t};\n\n\t\t\t\t\tif (!conditionsPerEntity || !conditionsPerEntityAndAction) {\n\t\t\t\t\t\tconditionsPerEntityAndAction = [getBlockEverythingFilter()];\n\t\t\t\t\t}\n\n\t\t\t\t\t//TODO: we could maybe improve performance by not filtering at each creation\n\t\t\t\t\t// but instead while the user sets the abilities\n\t\t\t\t\tconst simpleConditions =\n\t\t\t\t\t\tconditionsPerEntityAndAction.filter(isSimpleCondition);\n\n\t\t\t\t\tconst syncFunctionConditions = conditionsPerEntityAndAction\n\t\t\t\t\t\t.filter(isSyncFunctionCondition)\n\t\t\t\t\t\t.map((condition) => condition(userContext));\n\n\t\t\t\t\tconst someWildcardFound = syncFunctionConditions.some(\n\t\t\t\t\t\t(c) => c === \"allow\",\n\t\t\t\t\t);\n\n\t\t\t\t\t// const asyncFunctionConditions = await Promise.all(\n\t\t\t\t\t// \tconditionsPerEntityAndAction\n\t\t\t\t\t// \t\t.filter(isAsyncFunctionCondition)\n\t\t\t\t\t// \t\t.map((condition) => condition(userContext)),\n\t\t\t\t\t// );\n\n\t\t\t\t\tconst allConditionObjects = [\n\t\t\t\t\t\t...simpleConditions,\n\t\t\t\t\t\t...syncFunctionConditions,\n\t\t\t\t\t\t// ...asyncFunctionConditions,\n\t\t\t\t\t];\n\n\t\t\t\t\t// if we don't have any permitted filters and don't have a wildcard, then block everything\n\t\t\t\t\tif (allConditionObjects.filter((o) => o !== undefined).length === 0) {\n\t\t\t\t\t\tallConditionObjects.push(getBlockEverythingFilter());\n\t\t\t\t\t}\n\n\t\t\t\t\tlet highestLimit: number | undefined = undefined;\n\t\t\t\t\tfor (const conditionObject of allConditionObjects) {\n\t\t\t\t\t\tif (conditionObject !== \"allow\" && conditionObject?.limit) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\thighestLimit === undefined ||\n\t\t\t\t\t\t\t\tconditionObject.limit > highestLimit\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\thighestLimit = conditionObject.limit;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\toptions?.inject?.limit &&\n\t\t\t\t\t\thighestLimit &&\n\t\t\t\t\t\thighestLimit < options.inject.limit\n\t\t\t\t\t) {\n\t\t\t\t\t\thighestLimit = options.inject.limit;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet combinedAllowedColumns: Record<string, any> | undefined =\n\t\t\t\t\t\tundefined;\n\t\t\t\t\tfor (const conditionObject of [\n\t\t\t\t\t\t...allConditionObjects,\n\t\t\t\t\t\toptions?.inject ?? {},\n\t\t\t\t\t]) {\n\t\t\t\t\t\tif (conditionObject !== \"allow\" && conditionObject?.columns) {\n\t\t\t\t\t\t\tif (combinedAllowedColumns === undefined) {\n\t\t\t\t\t\t\t\tcombinedAllowedColumns = conditionObject.columns;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcombinedAllowedColumns = {\n\t\t\t\t\t\t\t\t\t...combinedAllowedColumns,\n\t\t\t\t\t\t\t\t\t...conditionObject.columns,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// in case we have a wildcard, we don't want to apply any where conditions\n\t\t\t\t\tconst accumulatedWhereConditions = someWildcardFound\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: allConditionObjects\n\t\t\t\t\t\t\t\t.filter((o) => o !== \"allow\" && o?.where)\n\t\t\t\t\t\t\t\t.map((o) => (o as Exclude<typeof o, \"allow\">)?.where);\n\n\t\t\t\t\tlet combinedWhere =\n\t\t\t\t\t\taccumulatedWhereConditions.length > 0\n\t\t\t\t\t\t\t? or(...accumulatedWhereConditions)\n\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\tif (options?.inject?.where) {\n\t\t\t\t\t\tcombinedWhere = combinedWhere\n\t\t\t\t\t\t\t? and(combinedWhere, options.inject.where)\n\t\t\t\t\t\t\t: options.inject.where;\n\t\t\t\t\t}\n\n\t\t\t\t\t//TODO make this actually typesafe\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsingle: {\n\t\t\t\t\t\t\twhere: combinedWhere,\n\t\t\t\t\t\t\tcolumns: combinedAllowedColumns,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmany: {\n\t\t\t\t\t\t\twhere: combinedWhere,\n\t\t\t\t\t\t\tcolumns: combinedAllowedColumns,\n\t\t\t\t\t\t\tlimit: highestLimit ?? defaultLimit ?? undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\texplicitFilters: (action: Action) => {\n\t\t\t\t\treturn registeredFilters[entityKey][action];\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tfor (const entityKey of Object.keys(db.query) as DBQueryKey[]) {\n\t\t\t\tbuilder[entityKey] = createEntityObject(entityKey);\n\t\t\t}\n\n\t\t\treturn builder;\n\t\t},\n\t};\n};\n","import type SchemaBuilder from \"@pothos/core\";\nimport type {\n\tAbilityBuilderType,\n\tcreateAbilityBuilder,\n} from \"./abilityBuilder\";\nimport type { GenericDrizzleDbTypeConstraints } from \"./types/genericDrizzleDbType\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\n\nexport type ContextFunctionType<\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n> = ReturnType<\n\ttypeof createContextFunction<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig,\n\t\tAbilityBuilderType<UserContext, DB, RequestEvent, Action, PothosConfig>\n\t>\n>;\n\nexport type ContextType<\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n> = Awaited<\n\tReturnType<\n\t\tContextFunctionType<UserContext, DB, RequestEvent, Action, PothosConfig>\n\t>\n>;\n\nexport const createContextFunction = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n\tAbilityBuilder extends ReturnType<\n\t\ttypeof createAbilityBuilder<\n\t\t\tUserContext,\n\t\t\tDB,\n\t\t\tRequestEvent,\n\t\t\tAction,\n\t\t\tPothosConfig\n\t\t>\n\t>,\n>({\n\tcontext: makeUserContext,\n\tabilityBuilder,\n}: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig> & {\n\tabilityBuilder: AbilityBuilder;\n}) => {\n\treturn async (req: RequestEvent) => {\n\t\tconst userContext = makeUserContext\n\t\t\t? await makeUserContext(req)\n\t\t\t: ({} as UserContext);\n\t\treturn {\n\t\t\t...userContext,\n\t\t\tabilities: abilityBuilder.buildWithUserContext(userContext),\n\t\t};\n\t};\n};\n","import { toCamelCase } from \"drizzle-orm/casing\";\nimport type { MySqlEnumColumnBuilderInitial } from \"drizzle-orm/mysql-core\";\nimport type { PgEnum } from \"drizzle-orm/pg-core\";\nimport type { SingleStoreEnumColumnBuilderInitial } from \"drizzle-orm/singlestore-core\";\nimport { capitalizeFirstLetter } from \"./helpers/capitalize\";\nimport type { SchemaBuilderType } from \"./schemaBuilder\";\nimport type { GenericDrizzleDbTypeConstraints } from \"./types/genericDrizzleDbType\";\nimport { RumbleError } from \"./types/rumbleError\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\n\n/**\n * Checks if a schema type is an enum\n */\nexport function isRuntimeEnumSchemaType(schemaType: any): boolean {\n\tconst enumSchema = mapRuntimeEnumSchemaType(schemaType);\n\treturn (\n\t\tenumSchema.enumValues !== undefined &&\n\t\tenumSchema.enumName !== undefined &&\n\t\ttypeof enumSchema.enumName === \"string\" &&\n\t\tArray.isArray(enumSchema.enumValues)\n\t);\n}\n\n/**\n * Puts an enum schema object in a uniform shape\n */\nexport function mapRuntimeEnumSchemaType(schemaType: any) {\n\treturn schemaType.enum ?? schemaType;\n}\n\ntype EnumTypes =\n\t| PgEnum<any>\n\t| SingleStoreEnumColumnBuilderInitial<any, any>\n\t| MySqlEnumColumnBuilderInitial<any, any>;\n\ntype EnumFields<T> = {\n\t[K in keyof T as T[K] extends EnumTypes ? K : never]: T[K];\n};\n\nexport type EnumImplementerType<\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n> = ReturnType<\n\ttypeof createEnumImplementer<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig,\n\t\tSchemaBuilderType<UserContext, DB, RequestEvent, Action, PothosConfig>\n\t>\n>;\n\nexport const createEnumImplementer = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n\tSchemaBuilder extends SchemaBuilderType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n>({\n\tdb,\n\tschemaBuilder,\n}: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig> & {\n\tschemaBuilder: SchemaBuilder;\n}) => {\n\tconst referenceStorage = new Map<string, any>();\n\n\tconst enumImplementer = <\n\t\tExplicitEnumVariableName extends keyof EnumFields<\n\t\t\tNonNullable<DB[\"_\"][\"fullSchema\"]>\n\t\t>,\n\t\tRefName extends string,\n\t\t// EnumValues,\n\t\tEnumName extends string,\n\t>({\n\t\tenumVariableName,\n\t\tname,\n\t\t// enumValues: enumValuesParam,\n\t\tenumName,\n\t}: Partial<\n\t\t{\n\t\t\t/**\n\t\t\t * The name of the enum as the TS variable is defined in your schema export.\n\t\t\t * @example\n\t\t\t * ```ts\n\t\t\t * export const committeeStatus = pgEnum('committee_status', [\n\t\t\t * //\t ^^^^^^^^^^^^^^^\n\t\t\t * //\t This is what you would put here (\"committeeStatus\")\n\t\t\t *\n\t\t\t *\n\t\t\t * \t\t'FORMAL',\n\t\t\t * \t\t'INFORMAL',\n\t\t\t * \t\t'PAUSE',\n\t\t\t * \t\t'SUSPENSION'\n\t\t\t * \t]);\n\t\t\t * ```\n\t\t\t */\n\t\t\tenumVariableName: ExplicitEnumVariableName;\n\t\t\t/*\n\t\t\t * The value object reference (array) that defines the enum values.\n\t\t\t * Be sure to pass this by reference, the values are not checked by comparison.\n\t\t\t * @example\n\t\t\t * ```ts\n\t\t\t *\n\t\t\t * const enumValues\n\t\t\t * export const committeeStatus = pgEnum('committee_status',\n\t\t\t *\n\t\t\t *\n\t\t\t * );\n\t\t\t * ```\n\t\t\t */\n\t\t\t// enumValues: EnumValues[];\n\n\t\t\t/**\n\t\t\t * The name of the enum at the database.\n\t\t\t * @example\n\t\t\t * ```ts\n\t\t\t * export const committeeStatus = pgEnum('committee_status', [\n\t\t\t * //\t \t\t\t ^^^^^^^^^^^^^^^^\n\t\t\t * //\t This is what you would put here (\"committee_status\")\n\t\t\t *\n\t\t\t *\n\t\t\t * \t\t'FORMAL',\n\t\t\t * \t\t'INFORMAL',\n\t\t\t * \t\t'PAUSE',\n\t\t\t * \t\t'SUSPENSION'\n\t\t\t * \t]);\n\t\t\t * ```\n\t\t\t */\n\t\t\tenumName: EnumName;\n\t\t\t/**\n\t\t\t * The name of the about to be generated graphql enum reference.\n\t\t\t */\n\t\t\tname: RefName | undefined;\n\t\t} & (\n\t\t\t| { enumVariableName: ExplicitEnumVariableName }\n\t\t\t// | { enumValues: EnumValues[] }\n\t\t\t| { enumName: EnumName }\n\t\t)\n\t>) => {\n\t\tconst fullSchema = db._.fullSchema!;\n\t\t//TODO check if this can be done typesafe\n\n\t\tlet enumSchema: any | undefined = undefined;\n\n\t\tif (enumVariableName) {\n\t\t\tenumSchema = fullSchema[enumVariableName];\n\t\t\t// } else if (enumValuesParam) {\n\t\t\t// \tenumSchema = Object.values(fullSchema)\n\t\t\t// \t\t.filter(isRuntimeEnumSchemaType)\n\t\t\t// \t\t.map(mapRuntimeEnumSchemaType)\n\t\t\t// \t\t.find((e: any) => e.enumValues === enumValuesParam) as any;\n\t\t} else if (enumName) {\n\t\t\tenumSchema = Object.values(fullSchema)\n\t\t\t\t.filter(isRuntimeEnumSchemaType)\n\t\t\t\t.map(mapRuntimeEnumSchemaType)\n\t\t\t\t.find((e: any) => e.enumName === enumName) as any;\n\t\t}\n\n\t\tif (!enumSchema) {\n\t\t\tthrow new RumbleError(\n\t\t\t\t`Could not determine enum structure! (${String(enumVariableName)}, ${enumValuesParam}, ${enumName})`,\n\t\t\t);\n\t\t}\n\n\t\tconst graphqlImplementationName =\n\t\t\tname ??\n\t\t\t`${capitalizeFirstLetter(toCamelCase(enumSchema.enumName.toString()))}Enum`;\n\n\t\tlet ret: ReturnType<typeof implement> | undefined = referenceStorage.get(\n\t\t\tgraphqlImplementationName,\n\t\t);\n\t\tif (ret) {\n\t\t\treturn ret;\n\t\t}\n\n\t\tconst implement = () =>\n\t\t\tschemaBuilder.enumType(graphqlImplementationName, {\n\t\t\t\tvalues: enumSchema.enumValues,\n\t\t\t});\n\n\t\tret = implement();\n\t\treferenceStorage.set(graphqlImplementationName, ret);\n\t\treturn ret;\n\t};\n\n\treturn enumImplementer;\n};\n","// https://stackoverflow.com/a/1026087/11988368\nexport function capitalizeFirstLetter(val: string) {\n\treturn String(val).charAt(0).toUpperCase() + String(val).slice(1);\n}\n","import type SchemaBuilder from \"@pothos/core\";\nimport type { SchemaBuilderType } from \"../../schemaBuilder\";\nimport type { GenericDrizzleDbTypeConstraints } from \"../../types/genericDrizzleDbType\";\nimport type { CustomRumblePothosConfig } from \"../../types/rumbleInput\";\nimport { type PossibleSQLType, UnknownTypeRumbleError } from \"./types\";\n\nexport function mapSQLTypeToGraphQLType<\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n\tSchemaBuilder extends SchemaBuilderType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n>(sqlType: PossibleSQLType) {\n\ttype ReturnType = Parameters<\n\t\tParameters<Parameters<SchemaBuilder[\"queryField\"]>[1]>[0][\"field\"]\n\t>[0][\"type\"];\n\n\tlet ret: ReturnType | undefined = undefined;\n\n\tif (\n\t\t[\"serial\", \"int\", \"integer\", \"tinyint\", \"smallint\", \"mediumint\"].includes(\n\t\t\tsqlType,\n\t\t)\n\t) {\n\t\tret = \"Int\";\n\t}\n\n\tif ([\"real\", \"decimal\", \"double\", \"float\"].includes(sqlType)) {\n\t\tret = \"Float\";\n\t}\n\n\tif ([\"string\", \"text\", \"varchar\", \"char\", \"text(256)\"].includes(sqlType)) {\n\t\tret = \"String\";\n\t}\n\n\tif ([\"uuid\"].includes(sqlType)) {\n\t\tret = \"ID\";\n\t}\n\n\tif ([\"boolean\"].includes(sqlType)) {\n\t\tret = \"Boolean\";\n\t}\n\n\tif ([\"timestamp\", \"datetime\"].includes(sqlType)) {\n\t\tret = \"DateTime\";\n\t}\n\n\tif ([\"date\"].includes(sqlType)) {\n\t\tret = \"Date\";\n\t}\n\n\tif ([\"json\"].includes(sqlType)) {\n\t\tret = \"JSON\";\n\t}\n\n\tif (ret !== undefined) {\n\t\treturn ret;\n\t}\n\n\tthrow UnknownTypeRumbleError(sqlType, \"SQL to GQL\");\n}\n","import type { GetColumnData } from \"drizzle-orm\";\nimport { createPubSub } from \"graphql-yoga\";\nimport type { GenericDrizzleDbTypeConstraints } from \"./types/genericDrizzleDbType\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\n\ntype PubSubAction = \"created\" | \"removed\" | \"updated\";\n\nconst SUBSCRIPTION_NOTIFIER_RUMBLE_PREFIX = \"RUMBLE_SUBSCRIPTION_NOTIFICATION\";\nconst SUBSCRIPTION_NOTIFIER_REMOVED = \"REMOVED\";\nconst SUBSCRIPTION_NOTIFIER_UPDATED = \"UPDATED\";\nconst SUBSCRIPTION_NOTIFIER_CREATED = \"CREATED\";\n\nexport type MakePubSubInstanceType<\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n> = ReturnType<\n\ttypeof createPubSubInstance<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>\n>[\"makePubSubInstance\"];\n\nexport const createPubSubInstance = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n>({\n\tsubscriptions,\n\tdb,\n}: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig>) => {\n\tconst pubsub = subscriptions\n\t\t? createPubSub(...subscriptions)\n\t\t: createPubSub();\n\n\tconst makePubSubInstance = <\n\t\tExplicitTableName extends keyof NonNullable<DB[\"_\"][\"schema\"]>,\n\t>({\n\t\ttableName,\n\t}: {\n\t\ttableName: ExplicitTableName;\n\t}) => {\n\t\ttype TablePrimaryKeyColumn = NonNullable<\n\t\t\tDB[\"_\"][\"schema\"]\n\t\t>[ExplicitTableName][\"primaryKey\"][number];\n\t\ttype PrimaryKeyType = GetColumnData<TablePrimaryKeyColumn, \"raw\">;\n\n\t\tfunction makePubSubKey({\n\t\t\taction,\n\t\t\ttableName,\n\t\t\tprimaryKeyValue,\n\t\t}: {\n\t\t\ttableName: string;\n\t\t\taction: PubSubAction;\n\t\t\tprimaryKeyValue?: PrimaryKeyType;\n\t\t}) {\n\t\t\tlet actionKey: string;\n\n\t\t\tswitch (action) {\n\t\t\t\tcase \"created\":\n\t\t\t\t\tactionKey = SUBSCRIPTION_NOTIFIER_CREATED;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"removed\":\n\t\t\t\t\tactionKey = SUBSCRIPTION_NOTIFIER_REMOVED;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"updated\":\n\t\t\t\t\tactionKey = SUBSCRIPTION_NOTIFIER_UPDATED;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error(`Unknown action: ${action}`);\n\t\t\t}\n\n\t\t\treturn `${SUBSCRIPTION_NOTIFIER_RUMBLE_PREFIX}/${tableName}${\n\t\t\t\tprimaryKeyValue ? `/${primaryKeyValue}` : \"\"\n\t\t\t}/${actionKey}`;\n\t\t}\n\n\t\treturn {\n\t\t\t/**\n\t\t\t * Call this when you want to register a subscription on an instance to this table\n\t\t\t */\n\t\t\tregisterOnInstance({\n\t\t\t\tinstance,\n\t\t\t\taction,\n\t\t\t\tprimaryKeyValue,\n\t\t\t}: {\n\t\t\t\tinstance: { register: (id: string) => void };\n\t\t\t\taction: PubSubAction;\n\t\t\t\tprimaryKeyValue?: string;\n\t\t\t}) {\n\t\t\t\tconst key = makePubSubKey({\n\t\t\t\t\ttableName: tableName.toString(),\n\t\t\t\t\taction,\n\t\t\t\t\tprimaryKeyValue,\n\t\t\t\t});\n\t\t\t\tinstance.register(key);\n\t\t\t},\n\t\t\t/**\n\t\t\t * Call this when you created an entity of this table\n\t\t\t */\n\t\t\tcreated() {\n\t\t\t\tconst key = makePubSubKey({\n\t\t\t\t\ttableName: tableName.toString(),\n\t\t\t\t\taction: \"created\",\n\t\t\t\t});\n\t\t\t\treturn pubsub.publish(key);\n\t\t\t},\n\t\t\t/**\n\t\t\t * Call this when you removed one or more entities of this table\n\t\t\t */\n\t\t\tremoved(primaryKeyValue?: PrimaryKeyType | PrimaryKeyType[]) {\n\t\t\t\tconst key = makePubSubKey({\n\t\t\t\t\ttableName: tableName.toString(),\n\t\t\t\t\taction: \"removed\",\n\t\t\t\t\t//TODO would it make sense to use specific sub topics here?\n\t\t\t\t\t// primaryKeyValue,\n\t\t\t\t});\n\t\t\t\treturn pubsub.publish(key);\n\t\t\t},\n\t\t\t/**\n\t\t\t * Call this when you updated one or more entities of this table\n\t\t\t */\n\t\t\tupdated(primaryKeyValue?: PrimaryKeyType | PrimaryKeyType[]) {\n\t\t\t\tconst primaryKeys = Array.isArray(primaryKeyValue)\n\t\t\t\t\t? primaryKeyValue\n\t\t\t\t\t: [primaryKeyValue];\n\t\t\t\tconst keys = primaryKeys.map((primaryKeyValue) =>\n\t\t\t\t\tmakePubSubKey({\n\t\t\t\t\t\ttableName: tableName.toString(),\n\t\t\t\t\t\taction: \"updated\",\n\t\t\t\t\t\tprimaryKeyValue,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tconst uniqueKeys = Array.from(new Set(keys));\n\t\t\t\tfor (const key of uniqueKeys) {\n\t\t\t\t\tpubsub.publish(key);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t};\n\n\treturn {\n\t\tpubsub,\n\t\tmakePubSubInstance,\n\t};\n};\n","import type SchemaBuilder from \"@pothos/core\";\nimport type { FieldMap } from \"@pothos/core\";\nimport { One } from \"drizzle-orm\";\nimport type { AbilityBuilderType } from \"./abilityBuilder\";\nimport {\n\ttype EnumImplementerType,\n\tisRuntimeEnumSchemaType,\n\tmapRuntimeEnumSchemaType,\n} from \"./enum\";\nimport { capitalizeFirstLetter } from \"./helpers/capitalize\";\nimport { mapSQLTypeToGraphQLType } from \"./helpers/sqlTypes/mapSQLTypeToTSType\";\nimport type { PossibleSQLType } from \"./helpers/sqlTypes/types\";\nimport { type MakePubSubInstanceType, createPubSubInstance } from \"./pubsub\";\nimport type { SchemaBuilderType } from \"./schemaBuilder\";\nimport type { GenericDrizzleDbTypeConstraints } from \"./types/genericDrizzleDbType\";\nimport { RumbleError } from \"./types/rumbleError\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\nimport type { ArgImplementerType } from \"./whereArg\";\n// import type { Field } from \"@pothos/plugin-drizzle\";\n\nexport const createObjectImplementer = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n\tSchemaBuilder extends SchemaBuilderType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n\tArgImplementer extends ArgImplementerType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n\tEnumImplementer extends EnumImplementerType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n\tMakePubSubInstance extends MakePubSubInstanceType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n\tAbilityBuilderInstance extends AbilityBuilderType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n>({\n\tdb,\n\tschemaBuilder,\n\tmakePubSubInstance,\n\targImplementer,\n\tenumImplementer,\n\tabilityBuilder,\n}: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig> & {\n\tschemaBuilder: SchemaBuilder;\n\targImplementer: ArgImplementer;\n\tenumImplementer: EnumImplementer;\n\tmakePubSubInstance: MakePubSubInstance;\n\tabilityBuilder: AbilityBuilderInstance;\n}) => {\n\treturn <\n\t\tExplicitTableName extends keyof NonNullable<DB[\"_\"][\"schema\"]>,\n\t\tRefName extends string,\n\t\tExtender extends\n\t\t\t| ((\n\t\t\t\t\tt: // TODO type this\n\t\t\t\t\tany,\n\t\t\t\t\t// Parameters<\n\t\t\t\t\t// \tNonNullable<Parameters<SchemaBuilder[\"drizzleObject\"]>[1][\"fields\"]>\n\t\t\t\t\t// >[0],\n\t\t\t ) => FieldMap)\n\t\t\t| undefined,\n\t>({\n\t\ttableName,\n\t\tname,\n\t\treadAction = \"read\" as Action,\n\t\textend,\n\t}: {\n\t\ttableName: ExplicitTableName;\n\t\tname?: RefName;\n\t\treadAction?: Action;\n\t\textend?: Extender;\n\t}) => {\n\t\tconst tableSchema = (db._.schema as NonNullable<DB[\"_\"][\"schema\"]>)[\n\t\t\ttableName\n\t\t];\n\t\tif (!tableSchema) {\n\t\t\tthrow new RumbleError(\n\t\t\t\t`Could not find schema for ${tableName.toString()} (object)`,\n\t\t\t);\n\t\t}\n\t\tconst primaryKey = tableSchema.primaryKey.at(0)?.name;\n\t\tif (!primaryKey)\n\t\t\tconsole.warn(\n\t\t\t\t`Could not find primary key for ${tableName.toString()}. Cannot register subscriptions!`,\n\t\t\t);\n\n\t\tconst { registerOnInstance } = makePubSubInstance({ tableName });\n\n\t\treturn schemaBuilder.drizzleObject(tableName, {\n\t\t\tname: name ?? capitalizeFirstLetter(tableName.toString()),\n\t\t\tsubscribe: (subscriptions, element, context) => {\n\t\t\t\tif (!primaryKey) return;\n\t\t\t\tconst primaryKeyValue = (element as any)[primaryKey];\n\t\t\t\tif (!primaryKeyValue) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`Could not find primary key value for ${JSON.stringify(\n\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t)}. Cannot register subscription!`,\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t//TODO maybe register non specific update calls aswell?\n\t\t\t\tregisterOnInstance({\n\t\t\t\t\tinstance: subscriptions,\n\t\t\t\t\taction: \"updated\",\n\t\t\t\t\tprimaryKeyValue: primaryKeyValue,\n\t\t\t\t});\n\t\t\t},\n\t\t\tapplyFilters:\n\t\t\t\tabilityBuilder?.registeredFilters?.[tableName as any]?.[readAction],\n\t\t\tfields: (t) => {\n\t\t\t\tconst mapSQLTypeStringToExposedPothosType = <\n\t\t\t\t\tColumn extends keyof typeof tableSchema.columns,\n\t\t\t\t\tSQLType extends ReturnType<\n\t\t\t\t\t\t(typeof tableSchema.columns)[Column][\"getSQLType\"]\n\t\t\t\t\t>,\n\t\t\t\t>(\n\t\t\t\t\tsqlType: SQLType,\n\t\t\t\t\tcolumnName: Column,\n\t\t\t\t\tnullable: boolean,\n\t\t\t\t) => {\n\t\t\t\t\tconst gqlType = mapSQLTypeToGraphQLType(sqlType as PossibleSQLType);\n\t\t\t\t\tswitch (gqlType) {\n\t\t\t\t\t\tcase \"Int\":\n\t\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t\treturn t.exposeInt(columnName, { nullable });\n\t\t\t\t\t\tcase \"String\":\n\t\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t\treturn t.exposeString(columnName, { nullable });\n\t\t\t\t\t\tcase \"Boolean\":\n\t\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t\treturn t.exposeBoolean(columnName, { nullable });\n\t\t\t\t\t\tcase \"Date\":\n\t\t\t\t\t\t\treturn t.field({\n\t\t\t\t\t\t\t\ttype: \"Date\",\n\t\t\t\t\t\t\t\tresolve: (element) => (element as any)[columnName] as Date,\n\t\t\t\t\t\t\t\tnullable,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\tcase \"DateTime\":\n\t\t\t\t\t\t\treturn t.field({\n\t\t\t\t\t\t\t\ttype: \"DateTime\",\n\t\t\t\t\t\t\t\tresolve: (element) => (element as any)[columnName] as Date,\n\t\t\t\t\t\t\t\tnullable,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\tcase \"Float\":\n\t\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t\treturn t.exposeFloat(columnName, { nullable });\n\t\t\t\t\t\tcase \"ID\":\n\t\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t\treturn t.exposeID(columnName, { nullable });\n\t\t\t\t\t\tcase \"JSON\":\n\t\t\t\t\t\t\treturn t.field({\n\t\t\t\t\t\t\t\ttype: \"JSON\",\n\t\t\t\t\t\t\t\tresolve: (element) => (element as any)[columnName] as unknown,\n\t\t\t\t\t\t\t\tnullable,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow new RumbleError(\n\t\t\t\t\t\t\t\t`Unsupported object type ${gqlType} for column ${columnName}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\tconst fields = Object.entries(tableSchema.columns).reduce(\n\t\t\t\t\t(acc, [key, value]) => {\n\t\t\t\t\t\tif (isRuntimeEnumSchemaType(value)) {\n\t\t\t\t\t\t\tconst enumVal = mapRuntimeEnumSchemaType(value);\n\t\t\t\t\t\t\tconst enumImpl = enumImplementer({\n\t\t\t\t\t\t\t\tenumName: enumVal.enumName as any,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tacc[key] = t.field({\n\t\t\t\t\t\t\t\ttype: enumImpl,\n\t\t\t\t\t\t\t\tresolve: (element) => (element as any)[key] as unknown,\n\t\t\t\t\t\t\t\tnullable: !value.notNull,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tacc[key] = mapSQLTypeStringToExposedPothosType(\n\t\t\t\t\t\t\t\tvalue.getSQLType(),\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t!value.notNull,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t},\n\t\t\t\t\t{} as Record<\n\t\t\t\t\t\tkeyof typeof tableSchema.columns,\n\t\t\t\t\t\tReturnType<typeof mapSQLTypeStringToExposedPothosType>\n\t\t\t\t\t>,\n\t\t\t\t);\n\n\t\t\t\tconst relations = Object.entries(tableSchema.relations).reduce(\n\t\t\t\t\t(acc, [key, value]) => {\n\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\tinputType: WhereArg,\n\t\t\t\t\t\t\ttransformArgumentToQueryCondition: transformWhere,\n\t\t\t\t\t\t} = argImplementer({\n\t\t\t\t\t\t\ttableName: value.referencedTableName,\n\t\t\t\t\t\t\tnativeTableName: value.referencedTableName,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\t// many relations will return an empty array so we just don't set them nullable\n\t\t\t\t\t\tlet nullable = false;\n\t\t\t\t\t\tlet isMany = true;\n\t\t\t\t\t\tlet filterSpecifier = \"many\";\n\t\t\t\t\t\tif (value instanceof One) {\n\t\t\t\t\t\t\tisMany = false;\n\t\t\t\t\t\t\t// we invert this for now\n\t\t\t\t\t\t\t// TODO: https://github.com/drizzle-team/drizzle-orm/issues/2365#issuecomment-2781607008\n\t\t\t\t\t\t\tnullable = !value.isNullable;\n\t\t\t\t\t\t\tfilterSpecifier = \"single\";\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tacc[key] = t.relation(key, {\n\t\t\t\t\t\t\targs: {\n\t\t\t\t\t\t\t\twhere: t.arg({ type: WhereArg, required: false }),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tnullable,\n\t\t\t\t\t\t\tquery: (args: any, ctx: any) => {\n\t\t\t\t\t\t\t\t//TODO: streamline naming & logic of when what is used: table name or schema object name\n\t\t\t\t\t\t\t\t// also we should adjust naming of the user facing functions accordingly\n\t\t\t\t\t\t\t\tconst found = Object.entries(db._.schema)\n\t\t\t\t\t\t\t\t\t.find(([key, v]) => v.dbName === value.referencedTableName)\n\t\t\t\t\t\t\t\t\t?.at(0);\n\t\t\t\t\t\t\t\tif (!found) {\n\t\t\t\t\t\t\t\t\tthrow new RumbleError(\n\t\t\t\t\t\t\t\t\t\t`Could not find table ${value.referencedTableName} in schema object`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn ctx.abilities[found].filter(readAction, {\n\t\t\t\t\t\t\t\t\tinject: { where: transformWhere(args.where) },\n\t\t\t\t\t\t\t\t})[filterSpecifier];\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} as any) as any;\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t},\n\t\t\t\t\t{} as Record<\n\t\t\t\t\t\tkeyof typeof tableSchema.relations,\n\t\t\t\t\t\tReturnType<typeof mapSQLTypeStringToExposedPothosType>\n\t\t\t\t\t>,\n\t\t\t\t);\n\n\t\t\t\treturn extend\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t...relations,\n\t\t\t\t\t\t\t...(extend(t as any) ?? {}),\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t...relations,\n\t\t\t\t\t\t};\n\t\t\t},\n\t\t});\n\t};\n};\n","import type { Filter } from \"../explicitFiltersPlugin/pluginTypes\";\nimport { RumbleErrorSafe } from \"../types/rumbleError\";\n\n/**\n * \n * Helper function to map a drizzle findFirst query result,\n * which may be optional, to a correct drizzle type.\n * \n * @throws RumbleError\n * \n * @example\n * \n * ```ts\n * schemaBuilder.queryFields((t) => {\n return {\n findFirstUser: t.drizzleField({\n type: UserRef,\n resolve: (query, root, args, ctx, info) => {\n return (\n db.query.users\n .findFirst({\n ...query,\n where: ctx.abilities.users.filter(\"read\").single.where,\n })\n // note that we need to manually raise an error if the value is not found\n .then(assertFindFirstExists)\n );\n },\n }),\n };\n });\n * ```\n */\nexport const assertFindFirstExists = <T>(value: T | undefined): T => {\n\tif (!value)\n\t\tthrow new RumbleErrorSafe(\"Value not found but required (findFirst)\");\n\treturn value;\n};\n\n/**\n * \n * Helper function to map a drizzle findFirst query result,\n * which may be optional, to a correct drizzle type.\n * \n * @throws RumbleError\n * \n * @example\n * \n * ```ts\n schemaBuilder.mutationFields((t) => {\n return {\n updateUsername: t.drizzleField({\n type: UserRef,\n args: {\n userId: t.arg.int({ required: true }),\n newName: t.arg.string({ required: true }),\n },\n resolve: (query, root, args, ctx, info) => {\n return db\n .update(schema.users)\n .set({\n name: args.newName,\n })\n .where(\n and(\n eq(schema.users.id, args.userId),\n ctx.abilities.users.filter(\"update\").single.where\n )\n )\n .returning({ id: schema.users.id, name: schema.users.name })\n // note that we need to manually raise an error if the value is not found\n .then(assertFirstEntryExists);\n },\n }),\n };\n });\n * ```\n */\nexport const assertFirstEntryExists = <T>(value: T[]): T => {\n\tconst v = value.at(0);\n\tif (!v)\n\t\tthrow new RumbleErrorSafe(\"Value not found but required (firstEntry)\");\n\treturn v;\n};\n\n/**\n * A helper to apply a list of filters to a given list of entities.\n * \n * @example\n * \n * ```ts\n * const filtered = await applyFilters({\n filters: abilityBuilder.registeredFilters.posts.update,\n entities: entitiesToFilter,\n context: ctx,\n });\n * ```\n */\nexport const applyFilters = async <Context, T, H extends T>({\n\tfilters,\n\tentities,\n\tcontext,\n}: { entities: T[]; filters: Filter<Context, H>[]; context: Context }) => {\n\treturn (\n\t\tawait Promise.all(\n\t\t\tfilters.map((f) =>\n\t\t\t\tf({\n\t\t\t\t\tcontext,\n\t\t\t\t\tentities: entities as H[],\n\t\t\t\t}),\n\t\t\t),\n\t\t)\n\t).reduce((acc, val) => {\n\t\tacc.push(...val);\n\t\treturn acc;\n\t}, []) as T[];\n};\n","import type SchemaBuilder from \"@pothos/core\";\nimport { capitalizeFirstLetter } from \"./helpers/capitalize\";\nimport { assertFindFirstExists } from \"./helpers/helper\";\nimport type { MakePubSubInstanceType } from \"./pubsub\";\nimport type { SchemaBuilderType } from \"./schemaBuilder\";\nimport type { GenericDrizzleDbTypeConstraints } from \"./types/genericDrizzleDbType\";\nimport { RumbleError } from \"./types/rumbleError\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\nimport type { ArgImplementerType } from \"./whereArg\";\n\nexport const createQueryImplementer = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n\tSchemaBuilder extends SchemaBuilderType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n\tArgImplementer extends ArgImplementerType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n\tMakePubSubInstance extends MakePubSubInstanceType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n>({\n\tdb,\n\tschemaBuilder,\n\targImplementer,\n\tmakePubSubInstance,\n}: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig> & {\n\tschemaBuilder: SchemaBuilder;\n\targImplementer: ArgImplementer;\n\tmakePubSubInstance: MakePubSubInstance;\n}) => {\n\treturn <ExplicitTableName extends keyof NonNullable<DB[\"_\"][\"schema\"]>>({\n\t\ttableName,\n\t\treadAction = \"read\" as Action,\n\t\tlistAction = \"read\" as Action,\n\t}: {\n\t\t/**\n\t\t * The table for which to implement the query\n\t\t */\n\t\ttableName: ExplicitTableName;\n\t\t/**\n\t\t * Which action should be used for reading single entities\n\t\t * @default \"read\"\n\t\t */\n\t\treadAction?: Action;\n\t\t/**\n\t\t * Which action should be used for listing many entities\n\t\t * @default \"read\"\n\t\t */\n\t\tlistAction?: Action;\n\t}) => {\n\t\tconst tableSchema = (db._.schema as NonNullable<DB[\"_\"][\"schema\"]>)[\n\t\t\ttableName\n\t\t];\n\t\tif (!tableSchema) {\n\t\t\tthrow new RumbleError(\n\t\t\t\t`Could not find schema for ${tableName.toString()} (query)`,\n\t\t\t);\n\t\t}\n\t\tconst primaryKey = tableSchema.primaryKey.at(0)?.name;\n\t\tif (!primaryKey)\n\t\t\tconsole.warn(\n\t\t\t\t`Could not find primary key for ${tableName.toString()}. Cannot register subscriptions!`,\n\t\t\t);\n\n\t\tconst {\n\t\t\tinputType: WhereArg,\n\t\t\ttransformArgumentToQueryCondition: transformWhere,\n\t\t} = argImplementer({\n\t\t\ttableName: tableName,\n\t\t});\n\n\t\tconst { registerOnInstance } = makePubSubInstance({ tableName });\n\n\t\treturn schemaBuilder.queryFields((t) => {\n\t\t\treturn {\n\t\t\t\t[`findMany${capitalizeFirstLetter(tableName.toString())}`]:\n\t\t\t\t\tt.drizzleField({\n\t\t\t\t\t\ttype: [tableName],\n\t\t\t\t\t\tnullable: false,\n\t\t\t\t\t\tsmartSubscription: true,\n\t\t\t\t\t\tsubscribe: (subscriptions, root, args, ctx, info) => {\n\t\t\t\t\t\t\tregisterOnInstance({\n\t\t\t\t\t\t\t\tinstance: subscriptions,\n\t\t\t\t\t\t\t\taction: \"created\",\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tregisterOnInstance({\n\t\t\t\t\t\t\t\tinstance: subscriptions,\n\t\t\t\t\t\t\t\taction: \"removed\",\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t},\n\t\t\t\t\t\targs: {\n\t\t\t\t\t\t\twhere: t.arg({ type: WhereArg, required: false }),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresolve: (query, root, args, ctx, info) => {\n\t\t\t\t\t\t\tconst filter = ctx.abilities[tableName as any].filter(\n\t\t\t\t\t\t\t\tlistAction,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tinject: { where: transformWhere(args.where) },\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t).many;\n\n\t\t\t\t\t\t\tconst queryInstance = query(filter as any);\n\n\t\t\t\t\t\t\tif (filter.columns) {\n\t\t\t\t\t\t\t\tqueryInstance.columns = filter.columns;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn db.query[tableName as any].findMany(queryInstance);\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t[`findFirst${capitalizeFirstLetter(tableName.toString())}`]:\n\t\t\t\t\tt.drizzleField({\n\t\t\t\t\t\ttype: tableName,\n\t\t\t\t\t\tnullable: false,\n\t\t\t\t\t\tsmartSubscription: true,\n\t\t\t\t\t\targs: {\n\t\t\t\t\t\t\twhere: t.arg({ type: WhereArg, required: false }),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresolve: (query, root, args, ctx, info) => {\n\t\t\t\t\t\t\tconst filter = ctx.abilities[tableName as any].filter(\n\t\t\t\t\t\t\t\treadAction,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tinject: { where: transformWhere(args.where) },\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t).single;\n\n\t\t\t\t\t\t\tconst queryInstance = query(filter as any);\n\n\t\t\t\t\t\t\tif (filter.columns) {\n\t\t\t\t\t\t\t\tqueryInstance.columns = filter.columns;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn db.query[tableName as any]\n\t\t\t\t\t\t\t\t.findFirst(queryInstance)\n\t\t\t\t\t\t\t\t.then(assertFindFirstExists);\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t};\n\t\t});\n\t};\n};\n","import \"./pluginTypes\";\nimport SchemaBuilder, {\n\tBasePlugin,\n\ttype PothosEnumValueConfig,\n\ttype PothosInputFieldConfig,\n\ttype PothosInterfaceTypeConfig,\n\ttype PothosOutputFieldConfig,\n\ttype PothosTypeConfig,\n\ttype PothosUnionTypeConfig,\n\ttype SchemaTypes,\n} from \"@pothos/core\";\nimport type {\n\tGraphQLFieldResolver,\n\tGraphQLSchema,\n\tGraphQLTypeResolver,\n} from \"graphql\";\nimport { applyFilters } from \"../helpers/helper\";\nimport type { ApplyFiltersField } from \"./pluginTypes\";\n\nconst pluginName = \"ManualFiltersPlugin\";\n\nexport default pluginName;\n\nexport const applyFiltersKey = \"applyFilters\";\n\nexport class ManualFiltersPlugin<\n\tTypes extends SchemaTypes,\n> extends BasePlugin<Types> {\n\t// override onTypeConfig(typeConfig: PothosTypeConfig) {\n\t// // console.log(this.builder.options.nestedOptionsObject?.exampleOption);\n\t// // console.log(this.options.customBuildTimeOptions);\n\n\t// if (typeConfig.kind === 'Object') {\n\t// console.log(typeConfig.pothosOptions.optionOnObject);\n\t// }\n\n\t// return typeConfig;\n\t// }\n\n\t// override onOutputFieldConfig(fieldConfig: PothosOutputFieldConfig<Types>) {\n\t// if (fieldConfig.kind === 'Mutation') {\n\t// console.log(fieldConfig.pothosOptions.customMutationFieldOption);\n\t// }\n\n\t// return fieldConfig;\n\t// }\n\n\t// override onInputFieldConfig(fieldConfig: PothosInputFieldConfig<Types>) {\n\t// return fieldConfig;\n\t// }\n\n\t// override onEnumValueConfig(valueConfig: PothosEnumValueConfig<Types>) {\n\t// return valueConfig;\n\t// }\n\n\t// override beforeBuild() {}\n\n\t// override afterBuild(schema: GraphQLSchema): GraphQLSchema {\n\t// return schema;\n\t// }\n\n\toverride wrapResolve(\n\t\tresolver: GraphQLFieldResolver<unknown, Types[\"Context\"], object>,\n\t\tfieldConfig: PothosOutputFieldConfig<Types>,\n\t): GraphQLFieldResolver<unknown, Types[\"Context\"], object> {\n\t\treturn async (parent, args, context, info) => {\n\t\t\t//TODO: https://github.com/hayes/pothos/discussions/1431#discussioncomment-12974130\n\t\t\tconst filters: ApplyFiltersField<Types[\"Context\"], any> = (\n\t\t\t\tfieldConfig?.type as any\n\t\t\t).type?.ref.currentConfig.pothosOptions[applyFiltersKey];\n\n\t\t\t// if no filter should be applied, just continue\n\t\t\tif (!filters || !Array.isArray(filters) || filters.length === 0) {\n\t\t\t\treturn resolver(parent, args, context, info);\n\t\t\t}\n\n\t\t\tconst resolved = await resolver(parent, args, context, info);\n\t\t\tconst allResolvedValues = Array.isArray(resolved) ? resolved : [resolved];\n\t\t\tconst allFilters = Array.isArray(filters) ? filters : [filters];\n\n\t\t\tconst allowed = await applyFilters({\n\t\t\t\tfilters: allFilters,\n\t\t\t\tentities: allResolvedValues,\n\t\t\t\tcontext,\n\t\t\t});\n\n\t\t\t// if the original value was an array, return an array\n\t\t\tif (Array.isArray(resolved)) {\n\t\t\t\treturn allowed;\n\t\t\t}\n\n\t\t\t// if the original value was a single value, return the first allowed\n\t\t\t// or null if not allowed\n\t\t\treturn allowed[0] ?? null;\n\t\t};\n\t}\n\n\t// override wrapSubscribe(\n\t// subscribe: GraphQLFieldResolver<unknown, Types['Context'], object> | undefined,\n\t// fieldConfig: PothosOutputFieldConfig<Types>,\n\t// ) {\n\t// return subscribe;\n\t// }\n\n\t// override wrapResolveType(\n\t// resolveType: GraphQLTypeResolver<unknown, Types['Context']>,\n\t// typeConfig: PothosInterfaceTypeConfig | PothosUnionTypeConfig,\n\t// ) {\n\t// return resolveType;\n\t// }\n}\n\nSchemaBuilder.registerPlugin(pluginName, ManualFiltersPlugin);\n","import SchemaBuilder from \"@pothos/core\";\nimport DrizzlePlugin from \"@pothos/plugin-drizzle\";\nimport SmartSubscriptionsPlugin, {\n\tsubscribeOptionsFromIterator,\n} from \"@pothos/plugin-smart-subscriptions\";\nimport {\n\tDateResolver,\n\tDateTimeISOResolver,\n\tJSONResolver,\n} from \"graphql-scalars\";\nimport type { createPubSub } from \"graphql-yoga\";\nimport type { ContextType } from \"./context\";\nimport ExplicitChecksPlugin from \"./explicitFiltersPlugin/explicitFiltersPlugin\";\nimport type { GenericDrizzleDbTypeConstraints } from \"./types/genericDrizzleDbType\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\n\nexport type SchemaBuilderType<\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n> = ReturnType<\n\ttypeof createSchemaBuilder<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>\n>[\"schemaBuilder\"];\n\nexport const createSchemaBuilder = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n>({\n\tdb,\n\tdisableDefaultObjects,\n\tpubsub,\n\tpothosConfig,\n}: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig> & {\n\tpubsub: ReturnType<typeof createPubSub>;\n}) => {\n\tconst schemaBuilder = new SchemaBuilder<{\n\t\tContext: ContextType<UserContext, DB, RequestEvent, Action, PothosConfig>;\n\t\tDrizzleSchema: DB[\"_\"][\"fullSchema\"];\n\t\tScalars: {\n\t\t\tJSON: {\n\t\t\t\tInput: unknown;\n\t\t\t\tOutput: unknown;\n\t\t\t};\n\t\t\tDate: {\n\t\t\t\tInput: Date;\n\t\t\t\tOutput: Date;\n\t\t\t};\n\t\t\tDateTime: {\n\t\t\t\tInput: Date;\n\t\t\t\tOutput: Date;\n\t\t\t};\n\t\t};\n\t}>({\n\t\tplugins: [\n\t\t\tExplicitChecksPlugin,\n\t\t\tDrizzlePlugin,\n\t\t\tSmartSubscriptionsPlugin,\n\t\t\t...(pothosConfig?.plugins ?? []),\n\t\t],\n\t\t...pothosConfig,\n\t\tdrizzle: {\n\t\t\tclient: db,\n\t\t},\n\t\tsmartSubscriptions: {\n\t\t\t...subscribeOptionsFromIterator((name, context) => {\n\t\t\t\treturn pubsub.subscribe(name);\n\t\t\t}),\n\t\t},\n\t});\n\n\tschemaBuilder.addScalarType(\"JSON\", JSONResolver);\n\tschemaBuilder.addScalarType(\"Date\", DateResolver);\n\tschemaBuilder.addScalarType(\"DateTime\", DateTimeISOResolver);\n\n\tif (!disableDefaultObjects?.query) {\n\t\tschemaBuilder.queryType({});\n\t}\n\n\tif (!disableDefaultObjects?.subscription) {\n\t\tschemaBuilder.subscriptionType({});\n\t}\n\n\tif (!disableDefaultObjects?.mutation) {\n\t\tschemaBuilder.mutationType({});\n\t}\n\n\treturn { schemaBuilder };\n};\n","import type SchemaBuilder from \"@pothos/core\";\nimport { SQL, and, eq } from \"drizzle-orm\";\nimport { toCamelCase } from \"drizzle-orm/casing\";\nimport {\n\ttype EnumImplementerType,\n\tisRuntimeEnumSchemaType,\n\tmapRuntimeEnumSchemaType,\n} from \"./enum\";\nimport { capitalizeFirstLetter } from \"./helpers/capitalize\";\nimport { mapSQLTypeToGraphQLType } from \"./helpers/sqlTypes/mapSQLTypeToTSType\";\nimport type { PossibleSQLType } from \"./helpers/sqlTypes/types\";\nimport type { SchemaBuilderType } from \"./schemaBuilder\";\nimport type { GenericDrizzleDbTypeConstraints } from \"./types/genericDrizzleDbType\";\nimport { RumbleError } from \"./types/rumbleError\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\n\nexport type ArgImplementerType<\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n> = ReturnType<\n\ttypeof createArgImplementer<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig,\n\t\tSchemaBuilderType<UserContext, DB, RequestEvent, Action, PothosConfig>,\n\t\tEnumImplementerType<UserContext, DB, RequestEvent, Action, PothosConfig>\n\t>\n>;\n\nconst makeDefaultName = (dbName: string) =>\n\t`${capitalizeFirstLetter(toCamelCase(dbName.toString()))}WhereInputArgument`;\n\nexport const createArgImplementer = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n\tSchemaBuilder extends SchemaBuilderType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n\tEnumImplementer extends EnumImplementerType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n>({\n\tdb,\n\tschemaBuilder,\n\tenumImplementer,\n}: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig> & {\n\tenumImplementer: EnumImplementer;\n\tschemaBuilder: SchemaBuilder;\n}) => {\n\tconst referenceStorage = new Map<string, any>();\n\n\tconst argImplementer = <\n\t\tExplicitTableName extends keyof NonNullable<DB[\"_\"][\"schema\"]>,\n\t\tRefName extends string,\n\t>({\n\t\ttableName,\n\t\tname,\n\t\tnativeTableName,\n\t}: {\n\t\ttableName: ExplicitTableName;\n\t\tname?: RefName | undefined;\n\t\tnativeTableName?: string;\n\t}) => {\n\t\tlet tableSchema = (db._.schema as NonNullable<DB[\"_\"][\"schema\"]>)[\n\t\t\ttableName\n\t\t];\n\t\tif (nativeTableName) {\n\t\t\tconst found: any = Object.values(db._.schema as any).find(\n\t\t\t\t(schema: any) => schema.dbName === nativeTableName,\n\t\t\t);\n\t\t\tif (found) {\n\t\t\t\ttableSchema = found;\n\t\t\t}\n\t\t}\n\t\tif (!tableSchema) {\n\t\t\tthrow new RumbleError(\n\t\t\t\t`Could not find schema for ${tableName.toString()} (whereArg)`,\n\t\t\t);\n\t\t}\n\t\tconst inputTypeName = name ?? makeDefaultName(tableSchema.dbName);\n\n\t\tlet ret: ReturnType<typeof implement> | undefined =\n\t\t\treferenceStorage.get(inputTypeName);\n\t\tif (ret) {\n\t\t\treturn ret;\n\t\t}\n\n\t\tconst implement = () => {\n\t\t\tconst inputType = schemaBuilder.inputType(inputTypeName, {\n\t\t\t\tfields: (t) => {\n\t\t\t\t\tconst mapSQLTypeStringToInputPothosType = <\n\t\t\t\t\t\tColumn extends keyof typeof tableSchema.columns,\n\t\t\t\t\t\tSQLType extends ReturnType<\n\t\t\t\t\t\t\t(typeof tableSchema.columns)[Column][\"getSQLType\"]\n\t\t\t\t\t\t>,\n\t\t\t\t\t>(\n\t\t\t\t\t\tsqlType: SQLType,\n\t\t\t\t\t) => {\n\t\t\t\t\t\tconst gqlType = mapSQLTypeToGraphQLType(sqlType as PossibleSQLType);\n\t\t\t\t\t\tswitch (gqlType) {\n\t\t\t\t\t\t\tcase \"Int\":\n\t\t\t\t\t\t\t\treturn t.int({ required: false });\n\t\t\t\t\t\t\t//TOOD: add support for non equality matching filters\n\t\t\t\t\t\t\tcase \"String\":\n\t\t\t\t\t\t\t\treturn t.string({ required: false });\n\t\t\t\t\t\t\tcase \"Boolean\":\n\t\t\t\t\t\t\t\treturn t.boolean({ required: false });\n\t\t\t\t\t\t\tcase \"Date\":\n\t\t\t\t\t\t\t\treturn t.field({\n\t\t\t\t\t\t\t\t\ttype: \"Date\",\n\t\t\t\t\t\t\t\t\trequired: false,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcase \"DateTime\":\n\t\t\t\t\t\t\t\treturn t.field({\n\t\t\t\t\t\t\t\t\ttype: \"DateTime\",\n\t\t\t\t\t\t\t\t\trequired: false,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcase \"Float\":\n\t\t\t\t\t\t\t\treturn t.float({ required: false });\n\t\t\t\t\t\t\tcase \"ID\":\n\t\t\t\t\t\t\t\treturn t.id({ required: false });\n\t\t\t\t\t\t\tcase \"JSON\":\n\t\t\t\t\t\t\t\treturn t.field({\n\t\t\t\t\t\t\t\t\ttype: \"JSON\",\n\t\t\t\t\t\t\t\t\trequired: false,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tthrow new RumbleError(\n\t\t\t\t\t\t\t\t\t`Unsupported argument type ${gqlType} for column ${sqlType}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\tconst fields = Object.entries(tableSchema.columns).reduce(\n\t\t\t\t\t\t(acc, [key, value]) => {\n\t\t\t\t\t\t\tif (isRuntimeEnumSchemaType(value)) {\n\t\t\t\t\t\t\t\tconst enumVal = mapRuntimeEnumSchemaType(value);\n\t\t\t\t\t\t\t\tconst enumImpl = enumImplementer({\n\t\t\t\t\t\t\t\t\tenumName: enumVal.enumName as any,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tacc[key] = t.field({\n\t\t\t\t\t\t\t\t\ttype: enumImpl,\n\t\t\t\t\t\t\t\t\trequired: false,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tacc[key] = mapSQLTypeStringToInputPothosType(\n\t\t\t\t\t\t\t\t\tvalue.getSQLType(),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{} as Record<\n\t\t\t\t\t\t\tkeyof typeof tableSchema.columns,\n\t\t\t\t\t\t\tReturnType<typeof mapSQLTypeStringToInputPothosType>\n\t\t\t\t\t\t>,\n\t\t\t\t\t);\n\n\t\t\t\t\tconst relations = Object.entries(tableSchema.relations).reduce(\n\t\t\t\t\t\t(acc, [key, value]) => {\n\t\t\t\t\t\t\tconst referenceModel = argImplementer({\n\t\t\t\t\t\t\t\ttableName: value.referencedTableName,\n\t\t\t\t\t\t\t\tnativeTableName: value.referencedTableName,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tacc[key] = t.field({\n\t\t\t\t\t\t\t\ttype: referenceModel.inputType,\n\t\t\t\t\t\t\t\trequired: false,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{} as Record<\n\t\t\t\t\t\t\tkeyof typeof tableSchema.columns,\n\t\t\t\t\t\t\tReturnType<typeof mapSQLTypeStringToInputPothosType>\n\t\t\t\t\t\t>,\n\t\t\t\t\t);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t...relations,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tconst transformArgumentToQueryCondition = <\n\t\t\t\tT extends typeof inputType.$inferInput,\n\t\t\t>(\n\t\t\t\targ: T | null | undefined,\n\t\t\t) => {\n\t\t\t\tif (!arg) return undefined;\n\t\t\t\tconst mapColumnToQueryCondition = <\n\t\t\t\t\tColumnName extends keyof typeof tableSchema.columns,\n\t\t\t\t>(\n\t\t\t\t\tcolumnname: ColumnName,\n\t\t\t\t) => {\n\t\t\t\t\tconst column = tableSchema.columns[columnname];\n\t\t\t\t\tconst filterValue = arg[columnname];\n\t\t\t\t\tif (!filterValue) return;\n\t\t\t\t\treturn eq(column, filterValue);\n\t\t\t\t};\n\t\t\t\tconst mapRelationToQueryCondition = <\n\t\t\t\t\tRelationColumnName extends keyof typeof tableSchema.relations,\n\t\t\t\t>(\n\t\t\t\t\trelationColumnName: RelationColumnName,\n\t\t\t\t): any => {\n\t\t\t\t\tconst relationColumn = tableSchema.relations[relationColumnName];\n\t\t\t\t\tconst filterValue = arg[relationColumnName];\n\t\t\t\t\tif (!filterValue) return;\n\t\t\t\t\tconst transformer = argImplementer({\n\t\t\t\t\t\ttableName: relationColumn.referencedTableName,\n\t\t\t\t\t\tnativeTableName: relationColumn.referencedTableName,\n\t\t\t\t\t}).transformArgumentToQueryCondition;\n\t\t\t\t\treturn transformer(filterValue);\n\t\t\t\t};\n\t\t\t\tconst conditions = [\n\t\t\t\t\t...Object.keys(tableSchema.columns).map(mapColumnToQueryCondition),\n\t\t\t\t\t...Object.keys(tableSchema.relations).map(\n\t\t\t\t\t\tmapRelationToQueryCondition,\n\t\t\t\t\t),\n\t\t\t\t];\n\t\t\t\treturn and(...conditions);\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\t/**\n\t\t\t\t * The input type used to pass arguments to resolvers\n\t\t\t\t */\n\t\t\t\tinputType,\n\t\t\t\t/**\n\t\t\t\t * Performs a conversion of an input argument passed to a resolver to a drizzle filter.\n\t\t\t\t * Make sure you use the correct converter for the input type.\n\t\t\t\t */\n\t\t\t\ttransformArgumentToQueryCondition,\n\t\t\t};\n\t\t};\n\n\t\tret = implement();\n\t\treferenceStorage.set(inputTypeName, ret);\n\t\treturn ret;\n\t};\n\n\treturn argImplementer;\n};\n","import type SchemaBuilder from \"@pothos/core\";\nimport {\n\ttype YogaServerOptions,\n\tcreateYoga as nativeCreateYoga,\n} from \"graphql-yoga\";\nimport { createAbilityBuilder } from \"./abilityBuilder\";\nimport { createContextFunction } from \"./context\";\nimport { createEnumImplementer } from \"./enum\";\nimport { createObjectImplementer } from \"./object\";\nimport { createPubSubInstance } from \"./pubsub\";\nimport { createQueryImplementer } from \"./query\";\nimport { createSchemaBuilder } from \"./schemaBuilder\";\nimport type { GenericDrizzleDbTypeConstraints } from \"./types/genericDrizzleDbType\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\nimport { createArgImplementer } from \"./whereArg\";\n\nexport const rumble = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tPothosConfig extends CustomRumblePothosConfig,\n\tAction extends string = \"read\" | \"update\" | \"delete\",\n>(\n\trumbleInput: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig>,\n) => {\n\t// to be able to iterate over the actions, we populate the actions array in case the user does not\n\tif (!rumbleInput.actions) {\n\t\trumbleInput.actions = [\"read\", \"update\", \"delete\"] as Action[];\n\t}\n\n\tif (rumbleInput.defaultLimit === undefined) {\n\t\trumbleInput.defaultLimit = 100;\n\t}\n\n\tconst abilityBuilder = createAbilityBuilder<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>(rumbleInput);\n\n\tconst context = createContextFunction<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig,\n\t\ttypeof abilityBuilder\n\t>({\n\t\t...rumbleInput,\n\t\tabilityBuilder,\n\t});\n\n\tconst { makePubSubInstance, pubsub } = createPubSubInstance<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>({\n\t\t...rumbleInput,\n\t});\n\n\tconst { schemaBuilder } = createSchemaBuilder<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>({ ...rumbleInput, pubsub });\n\tconst enum_ = createEnumImplementer<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig,\n\t\ttypeof schemaBuilder\n\t>({\n\t\t...rumbleInput,\n\t\tschemaBuilder,\n\t});\n\tconst arg = createArgImplementer<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig,\n\t\ttypeof schemaBuilder,\n\t\ttypeof enum_\n\t>({\n\t\t...rumbleInput,\n\t\tschemaBuilder,\n\t\tenumImplementer: enum_,\n\t});\n\tconst object = createObjectImplementer<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig,\n\t\ttypeof schemaBuilder,\n\t\ttypeof arg,\n\t\ttypeof enum_,\n\t\ttypeof makePubSubInstance,\n\t\ttypeof abilityBuilder\n\t>({\n\t\t...rumbleInput,\n\t\tschemaBuilder,\n\t\tmakePubSubInstance,\n\t\targImplementer: arg,\n\t\tenumImplementer: enum_,\n\t\tabilityBuilder,\n\t});\n\tconst query = createQueryImplementer<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig,\n\t\ttypeof schemaBuilder,\n\t\ttypeof arg,\n\t\ttypeof makePubSubInstance\n\t>({\n\t\t...rumbleInput,\n\t\tschemaBuilder,\n\t\targImplementer: arg,\n\t\tmakePubSubInstance,\n\t});\n\n\tconst createYoga = (\n\t\targs?:\n\t\t\t| Omit<YogaServerOptions<RequestEvent, any>, \"schema\" | \"context\">\n\t\t\t| undefined,\n\t) =>\n\t\tnativeCreateYoga<RequestEvent>({\n\t\t\t...args,\n\t\t\tschema: schemaBuilder.toSchema(),\n\t\t\tcontext,\n\t\t});\n\n\treturn {\n\t\t/**\n * The ability builder. Use it to declare whats allowed for each entity in your DB.\n * \n * @example\n * \n * ```ts\n * // users can edit themselves\n abilityBuilder.users\n .allow([\"read\", \"update\", \"delete\"])\n .when(({ userId }) => ({ where: eq(schema.users.id, userId) }));\n \n // everyone can read posts\n abilityBuilder.posts.allow(\"read\");\n * \n * ```\n */\n\t\tabilityBuilder,\n\t\t/**\n\t\t * The pothos schema builder. See https://pothos-graphql.dev/docs/plugins/drizzle\n\t\t */\n\t\tschemaBuilder,\n\t\t/**\n * Creates the native yoga instance. Can be used to run an actual HTTP server.\n * \n * @example\n * \n * ```ts\n import { createServer } from \"node:http\";\n * const server = createServer(createYoga());\n server.listen(3000, () => {\n console.info(\"Visit http://localhost:3000/graphql\");\n });\n * ```\n */\n\t\tcreateYoga,\n\t\t/**\n\t\t * A function for creating default objects for your schema\n\t\t */\n\t\tobject,\n\t\t/**\n\t\t * A function for creating where args to filter entities\n\t\t */\n\t\targ,\n\t\t/**\n\t\t * A function for creating default READ queries.\n\t\t * Make sure the objects for the table you are creating the queries for are implemented\n\t\t */\n\t\tquery,\n\t\t/**\n\t\t * A function for creating a pubsub instance for a table. Use this to publish or subscribe events\n\t\t */\n\t\tpubsub: makePubSubInstance,\n\t\t/**\n\t\t * A function to implement enums for graphql usage.\n\t\t * The other helpers use this helper internally so in most cases you do not have to\n\t\t * call this helper directly, unless you need the reference to an enum type\n\t\t */\n\t\tenum_,\n\t};\n};\n"]}
1
+ {"version":3,"sources":["../lib/helpers/lazy.ts","../node_modules/graphql/jsutils/isObjectLike.mjs","../node_modules/graphql/jsutils/invariant.mjs","../node_modules/graphql/language/location.mjs","../node_modules/graphql/language/printLocation.mjs","../node_modules/graphql/error/GraphQLError.mjs","../lib/types/rumbleError.ts","../lib/helpers/sqlTypes/types.ts","../lib/helpers/sqlTypes/distinctValuesFromSQLType.ts","../lib/helpers/tableHelpers.ts","../lib/abilityBuilder.ts","../lib/context.ts","../lib/helpers/capitalize.ts","../lib/enum.ts","../lib/object.ts","../lib/helpers/sqlTypes/mapSQLTypeToTSType.ts","../lib/pubsub.ts","../lib/helpers/helper.ts","../lib/query.ts","../lib/explicitFiltersPlugin/explicitFiltersPlugin.ts","../lib/schemaBuilder.ts","../lib/whereArg.ts","../lib/rumble.ts"],"names":["lazy","initializer","value","initialized","isObjectLike","invariant","condition","message","LineRegExp","getLocation","source","position","lastLineStart","line","match","printLocation","location","printSourceLocation","sourceLocation","firstLineColumnOffset","body","lineIndex","lineOffset","lineNum","columnOffset","columnNum","locationStr","lines","locationLine","subLineIndex","subLineColumnNum","subLines","i","printPrefixedLines","subLine","existingLines","_","padLen","prefix","toNormalizedOptions","args","firstArg","GraphQLError","_GraphQLError","rawArgs","_this$nodes","_nodeLocations$","_ref","nodes","positions","path","originalError","extensions","undefinedIfEmpty","nodeLocations","node","loc","pos","originalExtensions","output","formattedError","array","RumbleError","RumbleErrorSafe","UnknownTypeRumbleError","sqlType","additionalInfo","createDistinctValuesFromSQLType","nameSymbol","columnsSymbol","tableHelper","dbName","tsName","table","db","tableSchema","schema","k","v","acc","key","isSimpleQueryFilter","filter","isFunctionFilter","createAbilityBuilder","actions","defaultLimit","registrators","registeredQueryFilters","registeredFilters","createRegistrator","tableName","action","queryFiltersPerEntity","queryFiltersPerEntityAndAction","queryFilter","explicitFilter","entityKey","userContext","builder","createEntityObject","options","transformToResponse","queryFilters","where","transformedWhere","w","relationsFilterToSQL","limit","columns","getBlockEverythingFilter","primaryKeyField","distinctValues","simpleQueryFilters","functionQueryFilters","someWildcardFound","c","allQueryFilters","e","highestLimit","conditionObject","combinedAllowedColumns","accumulatedWhereConditions","o","combinedWhere","createContextFunction","makeUserContext","abilityBuilder","req","capitalizeFirstLetter","val","isEnumSchema","schemaType","PgEnumColumn","createEnumImplementer","schemaBuilder","referenceStorage","enumColumn","refName","enumSchemaName","enumValues","schemaEnum","enumCol","s","schemaEnumEntry","graphqlImplementationName","toCamelCase","ret","mapSQLTypeToGraphQLType","createObjectImplementer","makePubSubInstance","argImplementer","enumImplementer","readAction","extend","primaryKey","registerOnInstance","subscriptions","element","context","primaryKeyValue","t","mapSQLTypeStringToExposedPothosType","columnName","nullable","gqlType","fields","enumImpl","relations","relationSchema","WhereArg","isMany","filterSpecifier","One","ctx","SUBSCRIPTION_NOTIFIER_RUMBLE_PREFIX","SUBSCRIPTION_NOTIFIER_REMOVED","SUBSCRIPTION_NOTIFIER_UPDATED","SUBSCRIPTION_NOTIFIER_CREATED","createPubSubInstance","pubsub","createPubSub","makePubSubKey","actionKey","instance","keys","uniqueKeys","assertFindFirstExists","assertFirstEntryExists","applyFilters","filters","entities","f","createQueryImplementer","listAction","root","info","query","queryInstance","pluginName","explicitFiltersPlugin_default","applyFiltersKey","ManualFiltersPlugin","BasePlugin","resolver","fieldConfig","parent","resolved","allResolvedValues","allFilters","allowed","SchemaBuilder","createSchemaBuilder","disableDefaultObjects","pothosConfig","DrizzlePlugin","SmartSubscriptionsPlugin","subscribeOptionsFromIterator","name","JSONResolver","DateResolver","DateTimeISOResolver","makeDefaultName","createArgImplementer","inputTypeName","mapSQLTypeStringToInputPothosType","referenceModel","rumble","rumbleInput","enum_","arg","object","nativeCreateYoga"],"mappings":"+aAUO,SAASA,CAAQC,CAAAA,CAAAA,CAA+B,CACtD,IAAIC,CAAAA,CACAC,EAAc,KAElB,CAAA,OAAO,KACDA,CACJD,GAAAA,CAAAA,CAAQD,CAAY,EAAA,CACpBE,EAAc,IAERD,CAAAA,CAAAA,CAAAA,CAET,CCjBO,SAASE,CAAAA,CAAaF,EAAO,CAClC,OAAO,OAAOA,CAAAA,EAAS,UAAYA,CAAU,GAAA,IAC/C,CCNO,SAASG,CAAAA,CAAUC,EAAWC,CAAS,CAAA,CAI1C,MAAM,IAAI,KAAA,CACoB,iCAC9B,CAEJ,CCPA,IAAMC,GAAa,cASZ,CAAA,SAASC,EAAYC,CAAQC,CAAAA,CAAAA,CAAU,CAC5C,IAAIC,CAAAA,CAAgB,CAChBC,CAAAA,CAAAA,CAAO,EAEX,IAAWC,IAAAA,CAAAA,IAASJ,EAAO,IAAK,CAAA,QAAA,CAASF,EAAU,CAAG,CAAA,CAGpD,GAFA,OAAOM,EAAM,KAAU,EAAA,QAAA,EAAYT,EAAe,CAAA,CAE9CS,EAAM,KAASH,EAAAA,CAAAA,CACjB,MAGFC,CAAAA,CAAgBE,EAAM,KAAQA,CAAAA,CAAAA,CAAM,CAAC,CAAA,CAAE,OACvCD,CAAQ,EAAA,EACV,CAEA,OAAO,CACL,IAAAA,CAAAA,CAAAA,CACA,OAAQF,CAAW,CAAA,CAAA,CAAIC,CACzB,CACF,CCxBO,SAASG,CAAAA,CAAcC,EAAU,CACtC,OAAOC,EAC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CACtBiD,CAAAA,CAAAA,CAAQ/F,CAOZ,CAAA,CACD,GAAG8F,CAAAA,CACH,aAAA7F,CAAAA,CACD,CAAC,CACK+F,CAAAA,CAAAA,CAAMP,EAQV,CAAA,CACD,GAAGK,CAAAA,CACH,aAAA7F,CAAAA,CAAAA,CACA,eAAiB8F,CAAAA,CAClB,CAAC,CAAA,CACKE,CAASlF,CAAAA,EAAAA,CAWb,CACD,GAAG+E,CAAAA,CACH,aAAA7F,CAAAA,CAAAA,CACA,kBAAAe,CAAAA,CAAAA,CACA,cAAgBgF,CAAAA,CAAAA,CAChB,eAAiBD,CAAAA,CAAAA,CACjB,cAAAtG,CAAAA,CACD,CAAC,CAAA,CACKsE,EAAQJ,EASZ,CAAA,CACD,GAAGmC,CAAAA,CACH,aAAA7F,CAAAA,CAAAA,CACA,cAAgB+F,CAAAA,CAAAA,CAChB,kBAAAhF,CAAAA,CACD,CAAC,CAAA,CAaD,OAAO,CAiBN,eAAAvB,CAIA,CAAA,aAAA,CAAAQ,CAcA,CAAA,UAAA,CA7CA/F,CAIAgM,EAAAA,UAAAA,CAA+B,CAC9B,GAAGhM,CACH,CAAA,MAAA,CAAQ+F,CAAc,CAAA,QAAA,EACtB,CAAA,OAAA,CAAAwB,CACD,CAAC,CAAA,CAyCD,MAAAwE,CAAAA,CAAAA,CAIA,GAAAD,CAAAA,CAAAA,CAKA,KAAAjC,CAAAA,CAAAA,CAIA,MAAQ/C,CAAAA,CAAAA,CAMR,KAAA+E,CAAAA,CACD,CACD","file":"index.js","sourcesContent":["/**\n * Creates a lazily initialized function.\n *\n * The returned function will call the initializer function on its first call and\n * store the result. On subsequent calls, it will return the stored result.\n *\n * @param initializer The function to be called for initialization.\n * @returns A function that calls the initializer function on its first call and\n * returns the stored result on subsequent calls.\n */\nexport function lazy<T>(initializer: () => T): () => T {\n\tlet value: T | undefined;\n\tlet initialized = false;\n\n\treturn () => {\n\t\tif (!initialized) {\n\t\t\tvalue = initializer();\n\t\t\tinitialized = true;\n\t\t}\n\t\treturn value!;\n\t};\n}\n","/**\n * Return true if `value` is object-like. A value is object-like if it's not\n * `null` and has a `typeof` result of \"object\".\n */\nexport function isObjectLike(value) {\n return typeof value == 'object' && value !== null;\n}\n","export function invariant(condition, message) {\n const booleanCondition = Boolean(condition);\n\n if (!booleanCondition) {\n throw new Error(\n message != null ? message : 'Unexpected invariant triggered.',\n );\n }\n}\n","import { invariant } from '../jsutils/invariant.mjs';\nconst LineRegExp = /\\r\\n|[\\n\\r]/g;\n/**\n * Represents a location in a Source.\n */\n\n/**\n * Takes a Source and a UTF-8 character offset, and returns the corresponding\n * line and column as a SourceLocation.\n */\nexport function getLocation(source, position) {\n let lastLineStart = 0;\n let line = 1;\n\n for (const match of source.body.matchAll(LineRegExp)) {\n typeof match.index === 'number' || invariant(false);\n\n if (match.index >= position) {\n break;\n }\n\n lastLineStart = match.index + match[0].length;\n line += 1;\n }\n\n return {\n line,\n column: position + 1 - lastLineStart,\n };\n}\n","import { getLocation } from './location.mjs';\n\n/**\n * Render a helpful description of the location in the GraphQL Source document.\n */\nexport function printLocation(location) {\n return printSourceLocation(\n location.source,\n getLocation(location.source, location.start),\n );\n}\n/**\n * Render a helpful description of the location in the GraphQL Source document.\n */\n\nexport function printSourceLocation(source, sourceLocation) {\n const firstLineColumnOffset = source.locationOffset.column - 1;\n const body = ''.padStart(firstLineColumnOffset) + source.body;\n const lineIndex = sourceLocation.line - 1;\n const lineOffset = source.locationOffset.line - 1;\n const lineNum = sourceLocation.line + lineOffset;\n const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0;\n const columnNum = sourceLocation.column + columnOffset;\n const locationStr = `${source.name}:${lineNum}:${columnNum}\\n`;\n const lines = body.split(/\\r\\n|[\\n\\r]/g);\n const locationLine = lines[lineIndex]; // Special case for minified documents\n\n if (locationLine.length > 120) {\n const subLineIndex = Math.floor(columnNum / 80);\n const subLineColumnNum = columnNum % 80;\n const subLines = [];\n\n for (let i = 0; i < locationLine.length; i += 80) {\n subLines.push(locationLine.slice(i, i + 80));\n }\n\n return (\n locationStr +\n printPrefixedLines([\n [`${lineNum} |`, subLines[0]],\n ...subLines.slice(1, subLineIndex + 1).map((subLine) => ['|', subLine]),\n ['|', '^'.padStart(subLineColumnNum)],\n ['|', subLines[subLineIndex + 1]],\n ])\n );\n }\n\n return (\n locationStr +\n printPrefixedLines([\n // Lines specified like this: [\"prefix\", \"string\"],\n [`${lineNum - 1} |`, lines[lineIndex - 1]],\n [`${lineNum} |`, locationLine],\n ['|', '^'.padStart(columnNum)],\n [`${lineNum + 1} |`, lines[lineIndex + 1]],\n ])\n );\n}\n\nfunction printPrefixedLines(lines) {\n const existingLines = lines.filter(([_, line]) => line !== undefined);\n const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));\n return existingLines\n .map(([prefix, line]) => prefix.padStart(padLen) + (line ? ' ' + line : ''))\n .join('\\n');\n}\n","import { isObjectLike } from '../jsutils/isObjectLike.mjs';\nimport { getLocation } from '../language/location.mjs';\nimport {\n printLocation,\n printSourceLocation,\n} from '../language/printLocation.mjs';\n\nfunction toNormalizedOptions(args) {\n const firstArg = args[0];\n\n if (firstArg == null || 'kind' in firstArg || 'length' in firstArg) {\n return {\n nodes: firstArg,\n source: args[1],\n positions: args[2],\n path: args[3],\n originalError: args[4],\n extensions: args[5],\n };\n }\n\n return firstArg;\n}\n/**\n * A GraphQLError describes an Error found during the parse, validate, or\n * execute phases of performing a GraphQL operation. In addition to a message\n * and stack trace, it also includes information about the locations in a\n * GraphQL document and/or execution result that correspond to the Error.\n */\n\nexport class GraphQLError extends Error {\n /**\n * An array of `{ line, column }` locations within the source GraphQL document\n * which correspond to this error.\n *\n * Errors during validation often contain multiple locations, for example to\n * point out two things with the same name. Errors during execution include a\n * single location, the field which produced the error.\n *\n * Enumerable, and appears in the result of JSON.stringify().\n */\n\n /**\n * An array describing the JSON-path into the execution response which\n * corresponds to this error. Only included for errors during execution.\n *\n * Enumerable, and appears in the result of JSON.stringify().\n */\n\n /**\n * An array of GraphQL AST Nodes corresponding to this error.\n */\n\n /**\n * The source GraphQL document for the first location of this error.\n *\n * Note that if this Error represents more than one node, the source may not\n * represent nodes after the first node.\n */\n\n /**\n * An array of character offsets within the source GraphQL document\n * which correspond to this error.\n */\n\n /**\n * The original error thrown from a field resolver during execution.\n */\n\n /**\n * Extension fields to add to the formatted error.\n */\n\n /**\n * @deprecated Please use the `GraphQLErrorOptions` constructor overload instead.\n */\n constructor(message, ...rawArgs) {\n var _this$nodes, _nodeLocations$, _ref;\n\n const { nodes, source, positions, path, originalError, extensions } =\n toNormalizedOptions(rawArgs);\n super(message);\n this.name = 'GraphQLError';\n this.path = path !== null && path !== void 0 ? path : undefined;\n this.originalError =\n originalError !== null && originalError !== void 0\n ? originalError\n : undefined; // Compute list of blame nodes.\n\n this.nodes = undefinedIfEmpty(\n Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined,\n );\n const nodeLocations = undefinedIfEmpty(\n (_this$nodes = this.nodes) === null || _this$nodes === void 0\n ? void 0\n : _this$nodes.map((node) => node.loc).filter((loc) => loc != null),\n ); // Compute locations in the source for the given nodes/positions.\n\n this.source =\n source !== null && source !== void 0\n ? source\n : nodeLocations === null || nodeLocations === void 0\n ? void 0\n : (_nodeLocations$ = nodeLocations[0]) === null ||\n _nodeLocations$ === void 0\n ? void 0\n : _nodeLocations$.source;\n this.positions =\n positions !== null && positions !== void 0\n ? positions\n : nodeLocations === null || nodeLocations === void 0\n ? void 0\n : nodeLocations.map((loc) => loc.start);\n this.locations =\n positions && source\n ? positions.map((pos) => getLocation(source, pos))\n : nodeLocations === null || nodeLocations === void 0\n ? void 0\n : nodeLocations.map((loc) => getLocation(loc.source, loc.start));\n const originalExtensions = isObjectLike(\n originalError === null || originalError === void 0\n ? void 0\n : originalError.extensions,\n )\n ? originalError === null || originalError === void 0\n ? void 0\n : originalError.extensions\n : undefined;\n this.extensions =\n (_ref =\n extensions !== null && extensions !== void 0\n ? extensions\n : originalExtensions) !== null && _ref !== void 0\n ? _ref\n : Object.create(null); // Only properties prescribed by the spec should be enumerable.\n // Keep the rest as non-enumerable.\n\n Object.defineProperties(this, {\n message: {\n writable: true,\n enumerable: true,\n },\n name: {\n enumerable: false,\n },\n nodes: {\n enumerable: false,\n },\n source: {\n enumerable: false,\n },\n positions: {\n enumerable: false,\n },\n originalError: {\n enumerable: false,\n },\n }); // Include (non-enumerable) stack trace.\n\n /* c8 ignore start */\n // FIXME: https://github.com/graphql/graphql-js/issues/2317\n\n if (\n originalError !== null &&\n originalError !== void 0 &&\n originalError.stack\n ) {\n Object.defineProperty(this, 'stack', {\n value: originalError.stack,\n writable: true,\n configurable: true,\n });\n } else if (Error.captureStackTrace) {\n Error.captureStackTrace(this, GraphQLError);\n } else {\n Object.defineProperty(this, 'stack', {\n value: Error().stack,\n writable: true,\n configurable: true,\n });\n }\n /* c8 ignore stop */\n }\n\n get [Symbol.toStringTag]() {\n return 'GraphQLError';\n }\n\n toString() {\n let output = this.message;\n\n if (this.nodes) {\n for (const node of this.nodes) {\n if (node.loc) {\n output += '\\n\\n' + printLocation(node.loc);\n }\n }\n } else if (this.source && this.locations) {\n for (const location of this.locations) {\n output += '\\n\\n' + printSourceLocation(this.source, location);\n }\n }\n\n return output;\n }\n\n toJSON() {\n const formattedError = {\n message: this.message,\n };\n\n if (this.locations != null) {\n formattedError.locations = this.locations;\n }\n\n if (this.path != null) {\n formattedError.path = this.path;\n }\n\n if (this.extensions != null && Object.keys(this.extensions).length > 0) {\n formattedError.extensions = this.extensions;\n }\n\n return formattedError;\n }\n}\n\nfunction undefinedIfEmpty(array) {\n return array === undefined || array.length === 0 ? undefined : array;\n}\n/**\n * See: https://spec.graphql.org/draft/#sec-Errors\n */\n\n/**\n * Prints a GraphQLError to a string, representing useful location information\n * about the error's position in the source.\n *\n * @deprecated Please use `error.toString` instead. Will be removed in v17\n */\nexport function printError(error) {\n return error.toString();\n}\n/**\n * Given a GraphQLError, format it according to the rules described by the\n * Response Format, Errors section of the GraphQL Specification.\n *\n * @deprecated Please use `error.toJSON` instead. Will be removed in v17\n */\n\nexport function formatError(error) {\n return error.toJSON();\n}\n","import { GraphQLError } from \"graphql\";\n/**\n * An error that gets raised by rumble whenever something does not go according to plan.\n * Mostly internals, configuration errors or other unexpected things.\n */\nexport class RumbleError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"RumbleError\";\n\t}\n}\n\n/**\n * An error that gets raised by rumble whenever an error occurs in a resolver, containing\n * information safely exposeable to the user.\n * E.g. the assert helpers issue these.\n */\nexport class RumbleErrorSafe extends GraphQLError {}\n","import { RumbleError } from \"../../types/rumbleError\";\n\nexport const possibleSQLTypesStrings = [\n\t\"serial\",\n\t\"int\",\n\t\"integer\",\n\t\"tinyint\",\n\t\"smallint\",\n\t\"mediumint\",\n\t\"real\",\n\t\"decimal\",\n\t\"double\",\n\t\"float\",\n\t\"string\",\n\t\"text\",\n\t\"varchar\",\n\t\"char\",\n\t\"text(256)\",\n\t\"uuid\",\n\t\"boolean\",\n\t\"date\",\n\t\"datetime\",\n\t\"timestamp\",\n\t\"json\",\n] as const;\n\nexport type PossibleSQLType = (typeof possibleSQLTypesStrings)[number];\n\nexport const UnknownTypeRumbleError = (\n\tsqlType: string,\n\tadditionalInfo?: string,\n) =>\n\tnew RumbleError(\n\t\t`RumbleError: Unknown SQL type '${sqlType}'. Please open an issue (https://github.com/m1212e/rumble/issues) so it can be added. (${additionalInfo})`,\n\t);\n","import { type PossibleSQLType, UnknownTypeRumbleError } from \"./types\";\n\nexport function createDistinctValuesFromSQLType(sqlType: PossibleSQLType): {\n\tvalue1: any;\n\tvalue2: any;\n} {\n\tif (\n\t\t[\"serial\", \"int\", \"integer\", \"tinyint\", \"smallint\", \"mediumint\"].includes(\n\t\t\tsqlType,\n\t\t)\n\t) {\n\t\treturn {\n\t\t\tvalue1: 1,\n\t\t\tvalue2: 2,\n\t\t};\n\t}\n\n\tif ([\"real\", \"decimal\", \"double\", \"float\"].includes(sqlType)) {\n\t\treturn {\n\t\t\tvalue1: 1.1,\n\t\t\tvalue2: 2.2,\n\t\t};\n\t}\n\n\tif ([\"string\", \"text\", \"varchar\", \"char\", \"text(256)\"].includes(sqlType)) {\n\t\treturn {\n\t\t\tvalue1: \"a\",\n\t\t\tvalue2: \"b\",\n\t\t};\n\t}\n\n\tif ([\"uuid\"].includes(sqlType)) {\n\t\treturn {\n\t\t\tvalue1: \"fba31870-5528-42d7-b27e-2e5ee657aea5\",\n\t\t\tvalue2: \"fc65db81-c2d1-483d-8a25-a30e2cf6e02d\",\n\t\t};\n\t}\n\n\tif ([\"boolean\"].includes(sqlType)) {\n\t\treturn {\n\t\t\tvalue1: true,\n\t\t\tvalue2: false,\n\t\t};\n\t}\n\n\tif ([\"timestamp\", \"datetime\"].includes(sqlType)) {\n\t\treturn {\n\t\t\tvalue1: new Date(2022, 1, 1),\n\t\t\tvalue2: new Date(2022, 1, 2),\n\t\t};\n\t}\n\n\tif ([\"date\"].includes(sqlType)) {\n\t\treturn {\n\t\t\tvalue1: new Date(2022, 1, 1),\n\t\t\tvalue2: new Date(2022, 1, 2),\n\t\t};\n\t}\n\n\tif ([\"json\"].includes(sqlType)) {\n\t\treturn {\n\t\t\tvalue1: { a: 1 },\n\t\t\tvalue2: { b: 2 },\n\t\t};\n\t}\n\n\tthrow UnknownTypeRumbleError(sqlType, \"Distinct\");\n}\n","import type { Column, Many, One, Table } from \"drizzle-orm\";\nimport type { GenericDrizzleDbTypeConstraints } from \"../types/genericDrizzleDbType\";\nimport { RumbleError } from \"../types/rumbleError\";\n\nexport type TableIdentifierTSName<DB extends GenericDrizzleDbTypeConstraints> =\n\tkeyof NonNullable<DB[\"_\"][\"relations\"][\"schema\"]>;\n\nconst nameSymbol = Symbol.for(\"drizzle:Name\");\nconst columnsSymbol = Symbol.for(\"drizzle:Columns\");\n\nexport function tableHelper<\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tTSVariable extends TableIdentifierTSName<DB>,\n\tDBVariable extends string,\n\tT extends Table,\n>({\n\tdbName,\n\ttsName,\n\ttable,\n\tdb,\n}: Partial<{\n\ttsName: TSVariable;\n\tdbName: DBVariable;\n\ttable: T;\n}> &\n\t(\n\t\t| {\n\t\t\t\tdbName: DBVariable;\n\t\t }\n\t\t| {\n\t\t\t\ttsName: TSVariable;\n\t\t }\n\t\t| {\n\t\t\t\ttable: T;\n\t\t }\n\t) & { db: DB }) {\n\tlet tableSchema: Table | undefined = table;\n\n\tif (tsName) {\n\t\ttableSchema = db._.relations.schema[tsName as string];\n\t}\n\n\tif (dbName) {\n\t\ttableSchema = Object.values(db._.relations.schema).find(\n\t\t\t(schema: any) => schema[nameSymbol] === dbName,\n\t\t);\n\t}\n\n\tif (!tableSchema) {\n\t\tthrow new RumbleError(\n\t\t\t`Could not find schema for ${JSON.stringify({ tsName, dbName, table: (table as any)?.[nameSymbol] }).toString()}`,\n\t\t);\n\t}\n\n\treturn {\n\t\ttableSchema,\n\t\tcolumns: (tableSchema as any)[columnsSymbol] as Record<string, Column>,\n\t\tget primaryColumns() {\n\t\t\treturn Object.entries((tableSchema as any)[columnsSymbol])\n\t\t\t\t.filter(([k, v]) => (v as Column).primary)\n\t\t\t\t.reduce((acc, [k, v]) => {\n\t\t\t\t\t(acc as any)[k] = v;\n\t\t\t\t\treturn acc;\n\t\t\t\t}, {}) as Record<string, Column>;\n\t\t},\n\t\trelations: db._.relations.config[tsName as string] as {\n\t\t\t[key: string]: One<any, any> | Many<any, any>;\n\t\t},\n\t\tdbName: (tableSchema as any)[nameSymbol] as string,\n\t\tget tsName() {\n\t\t\treturn Object.entries(db._.relations.schema)\n\t\t\t\t.find(([key, v]) => v === tableSchema)!\n\t\t\t\t.at(0) as string;\n\t\t},\n\t};\n}\n","import { relationsFilterToSQL } from \"drizzle-orm\";\nimport type { Filter } from \"./explicitFiltersPlugin/pluginTypes\";\nimport { lazy } from \"./helpers/lazy\";\nimport { createDistinctValuesFromSQLType } from \"./helpers/sqlTypes/distinctValuesFromSQLType\";\nimport { tableHelper } from \"./helpers/tableHelpers\";\nimport type { GenericDrizzleDbTypeConstraints } from \"./types/genericDrizzleDbType\";\nimport { RumbleError } from \"./types/rumbleError\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\n\nexport type AbilityBuilderType<\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n> = ReturnType<\n\ttypeof createAbilityBuilder<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>\n>;\n\ntype TableName<DB extends GenericDrizzleDbTypeConstraints> = keyof DB[\"query\"];\n\ntype QueryFilterInput<\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tTableKey extends TableName<DB>,\n> = Parameters<DB[\"query\"][TableKey][\"findMany\"]>[0];\n\ntype SimpleQueryFilter<\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tTableKey extends keyof DB[\"query\"],\n\tFilter extends QueryFilterInput<DB, TableKey>,\n> = Filter;\n\ntype FunctionQueryFilter<\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tTableKey extends keyof DB[\"query\"],\n\tFilter extends QueryFilterInput<DB, TableKey>,\n\tContext,\n> = (context: Context) => Filter | undefined | \"allow\";\n\nfunction isSimpleQueryFilter<\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tTableKey extends keyof DB[\"query\"],\n\tFilter extends QueryFilterInput<DB, TableKey>,\n\tContext,\n>(\n\tfilter: QueryFilter<DB, TableKey, Filter, Context>,\n): filter is SimpleQueryFilter<DB, TableKey, Filter> {\n\treturn typeof filter !== \"function\";\n}\n\ntype QueryFilter<\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tTableName extends keyof DB[\"query\"],\n\tFilter extends QueryFilterInput<DB, TableName>,\n\tContext,\n> =\n\t| SimpleQueryFilter<DB, TableName, Filter>\n\t| FunctionQueryFilter<DB, TableName, Filter, Context>;\n\nfunction isFunctionFilter<\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tTableKey extends keyof DB[\"query\"],\n\tFilter extends QueryFilterInput<DB, TableKey>,\n\tContext,\n>(\n\tfilter: QueryFilter<DB, TableKey, Filter, Context>,\n): filter is FunctionQueryFilter<DB, TableKey, Filter, Context> {\n\treturn (\n\t\ttypeof filter === \"function\" && filter.constructor.name !== \"AsyncFunction\"\n\t);\n}\n\nexport const createAbilityBuilder = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n>({\n\tdb,\n\tactions,\n\tdefaultLimit,\n}: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig>) => {\n\tconst registrators: {\n\t\t[key in TableName<DB>]: ReturnType<typeof createRegistrator<key>>;\n\t} = {} as any;\n\n\tconst registeredQueryFilters: {\n\t\t[key in TableName<DB>]: {\n\t\t\t[key in Action]: QueryFilter<DB, key, any, UserContext>[] | \"unspecified\";\n\t\t};\n\t} = {} as any;\n\n\tconst registeredFilters: {\n\t\t[key in TableName<DB>]: {\n\t\t\t//TODO add a run all helper\n\t\t\t[key in Action]: Filter<UserContext, any>[];\n\t\t};\n\t} = {} as any;\n\n\tconst createRegistrator = <TableNameT extends TableName<DB>>(\n\t\ttableName: TableNameT,\n\t) => {\n\t\t// we want to init all possible application level filters since we want to ensure\n\t\t// that the implementaiton helpers pass an object by reference when creating\n\t\t// the implementation, instead of a copy like it would be the case with undefined\n\t\tfor (const action of actions!) {\n\t\t\tif (!registeredFilters[tableName]) {\n\t\t\t\tregisteredFilters[tableName] = {} as any;\n\t\t\t}\n\t\t\tif (!registeredFilters[tableName][action]) {\n\t\t\t\tregisteredFilters[tableName][action] = [];\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\t/**\n\t\t\t * Allows to perform a specific action on a specific entity\n\t\t\t */\n\t\t\tallow: (action: Action | Action[]) => {\n\t\t\t\tlet queryFiltersPerEntity = registeredQueryFilters[tableName];\n\t\t\t\tif (!queryFiltersPerEntity) {\n\t\t\t\t\tqueryFiltersPerEntity = {} as any;\n\t\t\t\t\tregisteredQueryFilters[tableName] = queryFiltersPerEntity;\n\t\t\t\t}\n\n\t\t\t\tconst actions = Array.isArray(action) ? action : [action];\n\t\t\t\tfor (const action of actions) {\n\t\t\t\t\tlet queryFiltersPerEntityAndAction = queryFiltersPerEntity[action];\n\t\t\t\t\tif (!queryFiltersPerEntityAndAction) {\n\t\t\t\t\t\tqueryFiltersPerEntityAndAction = \"unspecified\";\n\t\t\t\t\t\tqueryFiltersPerEntity[action] = queryFiltersPerEntityAndAction;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t/**\n\t\t\t\t\t * Restricts the allowed actions to a filter\n\t\t\t\t\t * @example\n\t\t\t\t\t * ```ts\n\t\t\t\t\t * abilityBuilder.users.allow([\"read\", \"update\", \"delete\"]).when(({ userId }) => ({\n\t\t\t\t\t * where: {\n\t\t\t\t\t * id: userId,\n\t\t\t\t\t * },\n\t\t\t\t\t * }));\n\t\t\t\t\t * ```\n\t\t\t\t\t */\n\t\t\t\t\twhen: (\n\t\t\t\t\t\tqueryFilter: QueryFilter<\n\t\t\t\t\t\t\tDB,\n\t\t\t\t\t\t\tTableNameT,\n\t\t\t\t\t\t\tQueryFilterInput<DB, TableNameT>,\n\t\t\t\t\t\t\tUserContext\n\t\t\t\t\t\t>,\n\t\t\t\t\t) => {\n\t\t\t\t\t\tfor (const action of actions) {\n\t\t\t\t\t\t\tif (queryFiltersPerEntity[action] === \"unspecified\") {\n\t\t\t\t\t\t\t\tqueryFiltersPerEntity[action] = [];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst queryFiltersPerEntityAndAction =\n\t\t\t\t\t\t\t\tqueryFiltersPerEntity[action];\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tqueryFiltersPerEntityAndAction as Exclude<\n\t\t\t\t\t\t\t\t\ttypeof queryFiltersPerEntityAndAction,\n\t\t\t\t\t\t\t\t\t\"unspecified\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t).push(queryFilter);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t\t/**\n\t\t\t * Allows to register an application level filter to restrict some results\n\t\t\t * which were returned by a query\n\t\t\t */\n\t\t\tfilter: (action: Action | Action[]) => {\n\t\t\t\tconst actions = Array.isArray(action) ? action : [action];\n\t\t\t\treturn {\n\t\t\t\t\t/**\n\t\t\t\t\t * The actual filter function to apply. Returns the allowed values\n\t\t\t\t\t */\n\t\t\t\t\tby: (\n\t\t\t\t\t\texplicitFilter: Filter<\n\t\t\t\t\t\t\tUserContext,\n\t\t\t\t\t\t\tNonNullable<\n\t\t\t\t\t\t\t\tAwaited<ReturnType<DB[\"query\"][TableNameT][\"findFirst\"]>>\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t>,\n\t\t\t\t\t) => {\n\t\t\t\t\t\tfor (const action of actions) {\n\t\t\t\t\t\t\tregisteredFilters[tableName][action].push(explicitFilter);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t};\n\n\tfor (const entityKey of Object.keys(db.query) as TableName<DB>[]) {\n\t\tregistrators[entityKey] = createRegistrator(entityKey);\n\t}\n\n\treturn {\n\t\t...registrators,\n\t\t/** @internal */\n\t\tregisteredQueryFilters: registeredQueryFilters,\n\t\t/** @internal */\n\t\tregisteredFilters,\n\t\t/** @internal */\n\t\tbuildWithUserContext: (userContext: UserContext) => {\n\t\t\tconst builder: {\n\t\t\t\t[key in TableName<DB>]: ReturnType<typeof createEntityObject<key>>;\n\t\t\t} = {} as any;\n\n\t\t\tconst createEntityObject = <TableNameT extends TableName<DB>>(\n\t\t\t\ttableName: TableNameT,\n\t\t\t) => {\n\t\t\t\treturn {\n\t\t\t\t\tfilter: <\n\t\t\t\t\t\tInjection extends SimpleQueryFilter<\n\t\t\t\t\t\t\tDB,\n\t\t\t\t\t\t\tTableNameT,\n\t\t\t\t\t\t\tQueryFilterInput<DB, TableNameT>\n\t\t\t\t\t\t>,\n\t\t\t\t\t>(\n\t\t\t\t\t\taction: Action,\n\t\t\t\t\t\toptions?: {\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * Additional query filters applied only for this call. Useful for injecting one time additional filters\n\t\t\t\t\t\t\t * for e.g. user args in a handler.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tinject?: Injection;\n\t\t\t\t\t\t},\n\t\t\t\t\t) => {\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Packs the fitlers into a response object that can be applied for queries by the user\n\t\t\t\t\t\t */\n\t\t\t\t\t\tconst transformToResponse = <\n\t\t\t\t\t\t\tF extends QueryFilterInput<DB, TableNameT>,\n\t\t\t\t\t\t>(\n\t\t\t\t\t\t\tqueryFilters?: F,\n\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\tconst where = lazy(() => {\n\t\t\t\t\t\t\t\tif (!queryFilters?.where && !options?.inject?.where) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn options?.inject?.where\n\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\tAND: [queryFilters?.where, options?.inject?.where],\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t: queryFilters?.where;\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst transformedWhere = lazy(() => {\n\t\t\t\t\t\t\t\tconst w = where();\n\t\t\t\t\t\t\t\tif (!w) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst table = tableHelper({\n\t\t\t\t\t\t\t\t\ttsName: tableName,\n\t\t\t\t\t\t\t\t\tdb,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\treturn relationsFilterToSQL(table.tableSchema, w);\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst limit = lazy(() => {\n\t\t\t\t\t\t\t\tlet limit =\n\t\t\t\t\t\t\t\t\tqueryFilters?.limit ?? (defaultLimit as undefined | number);\n\n\t\t\t\t\t\t\t\t// only apply limit if neither default limit or ability limit are set\n\t\t\t\t\t\t\t\t// or lower amount is set\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\toptions?.inject?.limit &&\n\t\t\t\t\t\t\t\t\t(!limit || limit > options.inject.limit)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tlimit = options.inject.limit;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tqueryFilters?.limit &&\n\t\t\t\t\t\t\t\t\t(!limit || queryFilters.limit > limit)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tlimit = queryFilters.limit;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// ensure that null is converted to undefined\n\t\t\t\t\t\t\t\treturn limit ?? undefined;\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst columns = lazy(() => {\n\t\t\t\t\t\t\t\tif (!queryFilters?.columns && !options?.inject?.columns) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...queryFilters?.columns,\n\t\t\t\t\t\t\t\t\t...options?.inject?.columns,\n\t\t\t\t\t\t\t\t} as undefined;\n\t\t\t\t\t\t\t\t// we need to type this as undefined because TS would\n\t\t\t\t\t\t\t\t// do some funky stuff with query resolve typing otherwise\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * Query filters for the drizzle query API.\n\t\t\t\t\t\t\t\t * @example\n\t\t\t\t\t\t\t\t * ```ts\n\t\t\t\t\t\t\t\t * author: t.relation(\"author\", {\n\t\t\t\t\t\t\t\t * query: (_args, ctx) => ctx.abilities.users.filter(\"read\").query.single,\n\t\t\t\t\t\t\t\t * }),\n\t\t\t\t\t\t\t\t * ´´´\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t\t * For find first calls\n\t\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\t\tsingle: {\n\t\t\t\t\t\t\t\t\t\tget where() {\n\t\t\t\t\t\t\t\t\t\t\treturn where();\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tget columns() {\n\t\t\t\t\t\t\t\t\t\t\treturn columns();\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t\t * For find many calls\n\t\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\t\tmany: {\n\t\t\t\t\t\t\t\t\t\tget where() {\n\t\t\t\t\t\t\t\t\t\t\treturn where();\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tget columns() {\n\t\t\t\t\t\t\t\t\t\t\treturn columns();\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tget limit() {\n\t\t\t\t\t\t\t\t\t\t\treturn limit();\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t\t * Query filters for the drizzle SQL API as used in e.g. updates.\n\t\t\t\t\t\t\t\t * @example\n\t\t\t\t\t\t\t\t *\n\t\t\t\t\t\t\t\t * ```ts\n\t\t\t\t\t\t\t\t * await db\n\t\t\t\t\t\t\t\t *\t.update(schema.users)\n\t\t\t\t\t\t\t\t *\t.set({\n\t\t\t\t\t\t\t\t *\t name: args.newName,\n\t\t\t\t\t\t\t\t * \t})\n\t\t\t\t\t\t\t\t *\t.where(\n\t\t\t\t\t\t\t\t *\t and(\n\t\t\t\t\t\t\t\t *\t eq(schema.users.id, args.userId),\n\t\t\t\t\t\t\t\t *\t ctx.abilities.users.filter(\"update\").sql.where,\n\t\t\t\t\t\t\t\t *\t ),\n\t\t\t\t\t\t\t\t *\t);\n\t\t\t\t\t\t\t\t * ```\n\t\t\t\t\t\t\t\t *\n\t\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\t\tsql: {\n\t\t\t\t\t\t\t\t\tget where() {\n\t\t\t\t\t\t\t\t\t\treturn transformedWhere();\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tget columns() {\n\t\t\t\t\t\t\t\t\t\treturn columns();\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tget limit() {\n\t\t\t\t\t\t\t\t\t\treturn limit();\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Creates a filter that will never return any result\n\t\t\t\t\t\t */\n\t\t\t\t\t\tconst getBlockEverythingFilter = () => {\n\t\t\t\t\t\t\tconst tableSchema = tableHelper({\n\t\t\t\t\t\t\t\tdb,\n\t\t\t\t\t\t\t\ttsName: tableName,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tif (Object.keys(tableSchema.primaryColumns).length === 0) {\n\t\t\t\t\t\t\t\tthrow new RumbleError(\n\t\t\t\t\t\t\t\t\t`No primary key found for entity ${tableName.toString()}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst primaryKeyField = Object.values(\n\t\t\t\t\t\t\t\ttableSchema.primaryColumns,\n\t\t\t\t\t\t\t)[0];\n\t\t\t\t\t\t\t// we want a filter that excludes everything\n\t\t\t\t\t\t\tconst distinctValues = createDistinctValuesFromSQLType(\n\t\t\t\t\t\t\t\tprimaryKeyField.getSQLType() as any,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t// when the user has no permission for anything, ensure returns nothing\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\twhere: {\n\t\t\t\t\t\t\t\t\tAND: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t[primaryKeyField.name]: distinctValues.value1,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t[primaryKeyField.name]: distinctValues.value2,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tlet queryFiltersPerEntityAndAction =\n\t\t\t\t\t\t\tregisteredQueryFilters?.[tableName]?.[action];\n\n\t\t\t\t\t\t// in case we have a wildcard ability, skip the rest and only apply the injected\n\t\t\t\t\t\t// filters, if any\n\t\t\t\t\t\tif (queryFiltersPerEntityAndAction === \"unspecified\") {\n\t\t\t\t\t\t\treturn transformToResponse();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// if nothing has been allowed, block everything\n\t\t\t\t\t\tif (!queryFiltersPerEntityAndAction) {\n\t\t\t\t\t\t\tqueryFiltersPerEntityAndAction = [getBlockEverythingFilter()];\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t//TODO: we could maybe improve performance by not filtering at each creation\n\t\t\t\t\t\t// but instead while the user sets the abilities\n\t\t\t\t\t\tconst simpleQueryFilters: SimpleQueryFilter<\n\t\t\t\t\t\t\tDB,\n\t\t\t\t\t\t\tTableNameT,\n\t\t\t\t\t\t\tQueryFilterInput<DB, TableNameT>\n\t\t\t\t\t\t>[] = queryFiltersPerEntityAndAction.filter(isSimpleQueryFilter);\n\n\t\t\t\t\t\tconst functionQueryFilters: ReturnType<\n\t\t\t\t\t\t\tFunctionQueryFilter<\n\t\t\t\t\t\t\t\tDB,\n\t\t\t\t\t\t\t\tTableNameT,\n\t\t\t\t\t\t\t\tQueryFilterInput<DB, TableNameT>,\n\t\t\t\t\t\t\t\tUserContext\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t>[] = queryFiltersPerEntityAndAction\n\t\t\t\t\t\t\t.filter(isFunctionFilter)\n\t\t\t\t\t\t\t.map((queryFilter) => queryFilter(userContext));\n\n\t\t\t\t\t\t//TODO: we could save some work by not running all the filters at each request\n\t\t\t\t\t\t// whenever one already returned \"allowed\"\n\t\t\t\t\t\tconst someWildcardFound = functionQueryFilters.some(\n\t\t\t\t\t\t\t(c) => c === \"allow\",\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tlet allQueryFilters = [\n\t\t\t\t\t\t\t...simpleQueryFilters,\n\t\t\t\t\t\t\t...functionQueryFilters,\n\t\t\t\t\t\t]\n\t\t\t\t\t\t\t// we just ignore the ones who did return undefined, since that evaluates to \"allow nothing\"\n\t\t\t\t\t\t\t.filter((e) => e !== undefined)\n\t\t\t\t\t\t\t// we already checked if we have some wildcard, so we can ignore the wildcard entries from now on\n\t\t\t\t\t\t\t.filter((e) => e !== \"allow\");\n\n\t\t\t\t\t\t// if we don't have any permitted filters and don't have a wildcard, then block everything\n\t\t\t\t\t\tif (!someWildcardFound && allQueryFilters.length === 0) {\n\t\t\t\t\t\t\tallQueryFilters = [getBlockEverythingFilter()];\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet highestLimit: number | undefined = undefined;\n\t\t\t\t\t\tfor (const conditionObject of allQueryFilters) {\n\t\t\t\t\t\t\tif (conditionObject?.limit) {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\thighestLimit === undefined ||\n\t\t\t\t\t\t\t\t\tconditionObject.limit > highestLimit\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\thighestLimit = conditionObject.limit;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet combinedAllowedColumns: Record<string, any> | undefined =\n\t\t\t\t\t\t\tundefined;\n\t\t\t\t\t\tfor (const conditionObject of [\n\t\t\t\t\t\t\t...allQueryFilters,\n\t\t\t\t\t\t\toptions?.inject,\n\t\t\t\t\t\t]) {\n\t\t\t\t\t\t\tif (conditionObject?.columns) {\n\t\t\t\t\t\t\t\tif (combinedAllowedColumns === undefined) {\n\t\t\t\t\t\t\t\t\tcombinedAllowedColumns = conditionObject.columns;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tcombinedAllowedColumns = {\n\t\t\t\t\t\t\t\t\t\t...combinedAllowedColumns,\n\t\t\t\t\t\t\t\t\t\t...conditionObject.columns,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// in case we have a wildcard, we don't want to apply any where conditions\n\t\t\t\t\t\tconst accumulatedWhereConditions = someWildcardFound\n\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t: allQueryFilters.filter((o) => o?.where).map((o) => o.where);\n\n\t\t\t\t\t\tconst combinedWhere =\n\t\t\t\t\t\t\taccumulatedWhereConditions.length > 0\n\t\t\t\t\t\t\t\t? { OR: accumulatedWhereConditions }\n\t\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\t\t//TODO make this actually typesafe\n\t\t\t\t\t\treturn transformToResponse({\n\t\t\t\t\t\t\twhere: combinedWhere,\n\t\t\t\t\t\t\tcolumns: combinedAllowedColumns,\n\t\t\t\t\t\t\tlimit: highestLimit,\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\texplicitFilters: (action: Action) => {\n\t\t\t\t\t\treturn registeredFilters[tableName][action];\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t};\n\n\t\t\tfor (const entityKey of Object.keys(db.query) as TableName<DB>[]) {\n\t\t\t\tbuilder[entityKey] = createEntityObject(entityKey);\n\t\t\t}\n\n\t\t\treturn builder;\n\t\t},\n\t};\n};\n","import type {\n\tAbilityBuilderType,\n\tcreateAbilityBuilder,\n} from \"./abilityBuilder\";\nimport type { GenericDrizzleDbTypeConstraints } from \"./types/genericDrizzleDbType\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\n\nexport type ContextFunctionType<\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n> = ReturnType<\n\ttypeof createContextFunction<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig,\n\t\tAbilityBuilderType<UserContext, DB, RequestEvent, Action, PothosConfig>\n\t>\n>;\n\nexport type ContextType<\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n> = Awaited<\n\tReturnType<\n\t\tContextFunctionType<UserContext, DB, RequestEvent, Action, PothosConfig>\n\t>\n>;\n\nexport const createContextFunction = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n\tAbilityBuilder extends ReturnType<\n\t\ttypeof createAbilityBuilder<\n\t\t\tUserContext,\n\t\t\tDB,\n\t\t\tRequestEvent,\n\t\t\tAction,\n\t\t\tPothosConfig\n\t\t>\n\t>,\n>({\n\tcontext: makeUserContext,\n\tabilityBuilder,\n}: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig> & {\n\tabilityBuilder: AbilityBuilder;\n}) => {\n\treturn async (req: RequestEvent) => {\n\t\tconst userContext = makeUserContext\n\t\t\t? await makeUserContext(req)\n\t\t\t: ({} as UserContext);\n\t\treturn {\n\t\t\t...userContext,\n\t\t\tabilities: abilityBuilder.buildWithUserContext(userContext),\n\t\t};\n\t};\n};\n","// https://stackoverflow.com/a/1026087/11988368\nexport function capitalizeFirstLetter(val: string) {\n\treturn String(val).charAt(0).toUpperCase() + String(val).slice(1);\n}\n","import { toCamelCase } from \"drizzle-orm/casing\";\nimport { type PgEnum, PgEnumColumn } from \"drizzle-orm/pg-core\";\nimport { capitalizeFirstLetter } from \"./helpers/capitalize\";\nimport { tableHelper } from \"./helpers/tableHelpers\";\nimport type { SchemaBuilderType } from \"./schemaBuilder\";\nimport type { GenericDrizzleDbTypeConstraints } from \"./types/genericDrizzleDbType\";\nimport { RumbleError } from \"./types/rumbleError\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\n\n/**\n * Checks if a schema type is an enum\n */\nexport function isEnumSchema(schemaType: any): schemaType is PgEnum<any> {\n\t// TODO make this compatible with other db drivers\n\treturn schemaType instanceof PgEnumColumn;\n}\n\n// TODO make this compatible with other db drivers\ntype EnumTypes = PgEnum<any>;\n\ntype EnumFields<T> = {\n\t[K in keyof T as T[K] extends EnumTypes ? K : never]: T[K];\n};\n\nexport type EnumImplementerType<\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n> = ReturnType<\n\ttypeof createEnumImplementer<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig,\n\t\tSchemaBuilderType<UserContext, DB, RequestEvent, Action, PothosConfig>\n\t>\n>;\n\nexport const createEnumImplementer = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n\tSchemaBuilder extends SchemaBuilderType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n>({\n\tdb,\n\tschemaBuilder,\n}: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig> & {\n\tschemaBuilder: SchemaBuilder;\n}) => {\n\tconst referenceStorage = new Map<string, any>();\n\n\tconst enumImplementer = <\n\t\tExplicitEnumVariableName extends keyof EnumFields<\n\t\t\tNonNullable<DB[\"_\"][\"relations\"][\"schema\"]>\n\t\t>,\n\t\tEnumColumn extends EnumTypes,\n\t\tRefName extends string,\n\t>({\n\t\ttsName,\n\t\tenumColumn,\n\t\trefName,\n\t}: Partial<{\n\t\ttsName: ExplicitEnumVariableName;\n\t\tenumColumn: EnumColumn;\n\t\trefName?: RefName | undefined;\n\t}> &\n\t\t(\n\t\t\t| {\n\t\t\t\t\ttsName: ExplicitEnumVariableName;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tenumColumn: EnumColumn;\n\t\t\t }\n\t\t)) => {\n\t\t//TODO check if this can be done typesafe\n\n\t\tlet enumSchemaName: string | undefined = undefined;\n\t\tlet enumValues: any[] | undefined = undefined;\n\n\t\tif (tsName) {\n\t\t\tconst schemaEnum = tableHelper({\n\t\t\t\tdb,\n\t\t\t\ttsName,\n\t\t\t});\n\n\t\t\tenumSchemaName = tsName.toString();\n\n\t\t\tconst enumCol = Object.values(db._.relations.schema)\n\t\t\t\t.filter((s) => typeof s === \"object\")\n\t\t\t\t.map((s) => Object.values(s[Symbol.for(\"drizzle:Columns\")]))\n\t\t\t\t.flat(2)\n\t\t\t\t.find((s: any) => s.config?.enum === schemaEnum);\n\n\t\t\tif (!enumCol) {\n\t\t\t\tthrow new RumbleError(`Could not find applied enum column for ${tsName.toString()}.\nPlease ensure that you use the enum at least once as a column of a table!`);\n\t\t\t}\n\n\t\t\tenumValues = (enumCol as any).enumValues;\n\t\t} else if (enumColumn) {\n\t\t\tconst schemaEnumEntry = Object.entries(db._.relations.schema).find(\n\t\t\t\t([key, value]) => value === (enumColumn as any).config.enum,\n\t\t\t);\n\n\t\t\tif (!schemaEnumEntry) {\n\t\t\t\tthrow new RumbleError(\n\t\t\t\t\t`Could not find enum in schema for ${enumColumn.name}!`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tenumSchemaName = schemaEnumEntry[0];\n\t\t\tenumValues = enumColumn.enumValues;\n\t\t}\n\n\t\tif (!enumSchemaName || !enumValues) {\n\t\t\tthrow new RumbleError(\"Could not determine enum structure!\");\n\t\t}\n\n\t\tconst graphqlImplementationName =\n\t\t\trefName ?? `${capitalizeFirstLetter(toCamelCase(enumSchemaName))}Enum`;\n\n\t\tlet ret: ReturnType<typeof implement> | undefined = referenceStorage.get(\n\t\t\tgraphqlImplementationName,\n\t\t);\n\t\tif (ret) {\n\t\t\treturn ret;\n\t\t}\n\n\t\tconst implement = () =>\n\t\t\tschemaBuilder.enumType(graphqlImplementationName, {\n\t\t\t\tvalues: enumValues,\n\t\t\t});\n\n\t\tret = implement();\n\t\treferenceStorage.set(graphqlImplementationName, ret);\n\t\treturn ret;\n\t};\n\n\treturn enumImplementer;\n};\n","import type { FieldMap } from \"@pothos/core\";\nimport type { DrizzleObjectFieldBuilder } from \"@pothos/plugin-drizzle\";\nimport { One, type Table } from \"drizzle-orm\";\nimport type { AbilityBuilderType } from \"./abilityBuilder\";\nimport { type EnumImplementerType, isEnumSchema } from \"./enum\";\nimport { capitalizeFirstLetter } from \"./helpers/capitalize\";\nimport { mapSQLTypeToGraphQLType } from \"./helpers/sqlTypes/mapSQLTypeToTSType\";\nimport type { PossibleSQLType } from \"./helpers/sqlTypes/types\";\nimport {\n\ttype TableIdentifierTSName,\n\ttableHelper,\n} from \"./helpers/tableHelpers\";\nimport type { MakePubSubInstanceType } from \"./pubsub\";\nimport type { SchemaBuilderType } from \"./schemaBuilder\";\nimport type { GenericDrizzleDbTypeConstraints } from \"./types/genericDrizzleDbType\";\nimport { RumbleError } from \"./types/rumbleError\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\nimport type { ArgImplementerType } from \"./whereArg\";\n\nexport const createObjectImplementer = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n\tSchemaBuilder extends SchemaBuilderType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n\tArgImplementer extends ArgImplementerType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n\tEnumImplementer extends EnumImplementerType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n\tMakePubSubInstance extends MakePubSubInstanceType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n\tAbilityBuilderInstance extends AbilityBuilderType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n>({\n\tdb,\n\tschemaBuilder,\n\tmakePubSubInstance,\n\targImplementer,\n\tenumImplementer,\n\tabilityBuilder,\n}: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig> & {\n\tschemaBuilder: SchemaBuilder;\n\targImplementer: ArgImplementer;\n\tenumImplementer: EnumImplementer;\n\tmakePubSubInstance: MakePubSubInstance;\n\tabilityBuilder: AbilityBuilderInstance;\n}) => {\n\treturn <\n\t\tExplicitTableName extends TableIdentifierTSName<DB>,\n\t\tRefName extends string,\n\t>({\n\t\ttable,\n\t\trefName,\n\t\treadAction = \"read\" as Action,\n\t\textend,\n\t}: {\n\t\ttable: ExplicitTableName;\n\t\trefName?: RefName;\n\t\treadAction?: Action;\n\t\textend?:\n\t\t\t| ((\n\t\t\t\t\tt: DrizzleObjectFieldBuilder<\n\t\t\t\t\t\tSchemaBuilder[\"$inferSchemaTypes\"],\n\t\t\t\t\t\tany,\n\t\t\t\t\t\tany,\n\t\t\t\t\t\tany\n\t\t\t\t\t>,\n\t\t\t ) => FieldMap)\n\t\t\t| undefined;\n\t}) => {\n\t\tconst tableSchema = tableHelper({ db, tsName: table });\n\t\tif (Object.keys(tableSchema.primaryColumns).length === 0) {\n\t\t\tconsole.warn(\n\t\t\t\t`Could not find primary key for ${table.toString()}. Cannot register subscriptions!`,\n\t\t\t);\n\t\t}\n\t\tconst primaryKey = Object.values(tableSchema.primaryColumns)[0];\n\n\t\tconst { registerOnInstance } = makePubSubInstance({ table: table });\n\n\t\treturn schemaBuilder.drizzleObject(table, {\n\t\t\tname: refName ?? capitalizeFirstLetter(table.toString()),\n\t\t\tsubscribe: (subscriptions, element, context) => {\n\t\t\t\tif (!primaryKey) return;\n\t\t\t\tconst primaryKeyValue = (element as any)[primaryKey.name];\n\t\t\t\tif (!primaryKeyValue) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`Could not find primary key value for ${JSON.stringify(\n\t\t\t\t\t\t\telement,\n\t\t\t\t\t\t)}. Cannot register subscription!`,\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t//TODO maybe register non specific update calls aswell?\n\t\t\t\tregisterOnInstance({\n\t\t\t\t\tinstance: subscriptions,\n\t\t\t\t\taction: \"updated\",\n\t\t\t\t\tprimaryKeyValue: primaryKeyValue,\n\t\t\t\t});\n\t\t\t},\n\t\t\tapplyFilters:\n\t\t\t\tabilityBuilder?.registeredFilters?.[table as any]?.[readAction],\n\t\t\tfields: (t) => {\n\t\t\t\tconst columns = tableSchema.columns;\n\t\t\t\tconst mapSQLTypeStringToExposedPothosType = <\n\t\t\t\t\tColumn extends keyof typeof columns,\n\t\t\t\t\tSQLType extends ReturnType<(typeof columns)[Column][\"getSQLType\"]>,\n\t\t\t\t>(\n\t\t\t\t\tsqlType: SQLType,\n\t\t\t\t\tcolumnName: Column,\n\t\t\t\t\tnullable: boolean,\n\t\t\t\t) => {\n\t\t\t\t\tconst gqlType = mapSQLTypeToGraphQLType(sqlType as PossibleSQLType);\n\t\t\t\t\tswitch (gqlType) {\n\t\t\t\t\t\tcase \"Int\":\n\t\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t\treturn t.exposeInt(columnName, { nullable });\n\t\t\t\t\t\tcase \"String\":\n\t\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t\treturn t.exposeString(columnName, { nullable });\n\t\t\t\t\t\tcase \"Boolean\":\n\t\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t\treturn t.exposeBoolean(columnName, { nullable });\n\t\t\t\t\t\tcase \"Date\":\n\t\t\t\t\t\t\treturn t.field({\n\t\t\t\t\t\t\t\ttype: \"Date\",\n\t\t\t\t\t\t\t\tresolve: (element) => (element as any)[columnName] as Date,\n\t\t\t\t\t\t\t\tnullable,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\tcase \"DateTime\":\n\t\t\t\t\t\t\treturn t.field({\n\t\t\t\t\t\t\t\ttype: \"DateTime\",\n\t\t\t\t\t\t\t\tresolve: (element) => (element as any)[columnName] as Date,\n\t\t\t\t\t\t\t\tnullable,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\tcase \"Float\":\n\t\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t\treturn t.exposeFloat(columnName, { nullable });\n\t\t\t\t\t\tcase \"ID\":\n\t\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t\treturn t.exposeID(columnName, { nullable });\n\t\t\t\t\t\tcase \"JSON\":\n\t\t\t\t\t\t\treturn t.field({\n\t\t\t\t\t\t\t\ttype: \"JSON\",\n\t\t\t\t\t\t\t\tresolve: (element) => (element as any)[columnName] as unknown,\n\t\t\t\t\t\t\t\tnullable,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow new RumbleError(\n\t\t\t\t\t\t\t\t`Unsupported object type ${gqlType} for column ${columnName}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\tconst fields = Object.entries(columns).reduce(\n\t\t\t\t\t(acc, [key, value]) => {\n\t\t\t\t\t\tif (isEnumSchema(value)) {\n\t\t\t\t\t\t\tconst enumImpl = enumImplementer({\n\t\t\t\t\t\t\t\tenumColumn: value,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tacc[key] = t.field({\n\t\t\t\t\t\t\t\ttype: enumImpl,\n\t\t\t\t\t\t\t\tresolve: (element) => (element as any)[key],\n\t\t\t\t\t\t\t\tnullable: !value.notNull,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tacc[key] = mapSQLTypeStringToExposedPothosType(\n\t\t\t\t\t\t\t\tvalue.getSQLType(),\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t!value.notNull,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t},\n\t\t\t\t\t{} as Record<\n\t\t\t\t\t\tkeyof typeof columns,\n\t\t\t\t\t\tReturnType<typeof mapSQLTypeStringToExposedPothosType>\n\t\t\t\t\t>,\n\t\t\t\t);\n\n\t\t\t\tconst relations = Object.entries(tableSchema.relations).reduce(\n\t\t\t\t\t(acc, [key, value]) => {\n\t\t\t\t\t\tconst relationSchema = tableHelper({\n\t\t\t\t\t\t\tdb,\n\t\t\t\t\t\t\ttable: value.targetTable as Table,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst WhereArg = argImplementer({\n\t\t\t\t\t\t\tdbName: relationSchema.dbName,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\t// many relations will return an empty array so we just don't set them nullable\n\t\t\t\t\t\tlet nullable = false;\n\t\t\t\t\t\tlet isMany = true;\n\t\t\t\t\t\tlet filterSpecifier = \"many\";\n\t\t\t\t\t\tif (value instanceof One) {\n\t\t\t\t\t\t\tisMany = false;\n\t\t\t\t\t\t\tnullable = value.optional;\n\t\t\t\t\t\t\tfilterSpecifier = \"single\";\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tacc[key] = t.relation(key, {\n\t\t\t\t\t\t\targs: {\n\t\t\t\t\t\t\t\twhere: t.arg({ type: WhereArg, required: false }),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tnullable,\n\t\t\t\t\t\t\tquery: (args: any, ctx: any) => {\n\t\t\t\t\t\t\t\treturn ctx.abilities[relationSchema.tsName].filter(readAction, {\n\t\t\t\t\t\t\t\t\tinject: { where: args.where },\n\t\t\t\t\t\t\t\t}).query[filterSpecifier];\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} as any) as any;\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t},\n\t\t\t\t\t{} as Record<\n\t\t\t\t\t\tkeyof typeof tableSchema.relations,\n\t\t\t\t\t\tReturnType<typeof mapSQLTypeStringToExposedPothosType>\n\t\t\t\t\t>,\n\t\t\t\t);\n\n\t\t\t\treturn extend\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t...relations,\n\t\t\t\t\t\t\t...(extend(t as any) ?? {}),\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t\t...relations,\n\t\t\t\t\t\t};\n\t\t\t},\n\t\t});\n\t};\n};\n","import type SchemaBuilder from \"@pothos/core\";\nimport type { SchemaBuilderType } from \"../../schemaBuilder\";\nimport type { GenericDrizzleDbTypeConstraints } from \"../../types/genericDrizzleDbType\";\nimport type { CustomRumblePothosConfig } from \"../../types/rumbleInput\";\nimport { type PossibleSQLType, UnknownTypeRumbleError } from \"./types\";\n\nexport function mapSQLTypeToGraphQLType<\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n\tSchemaBuilder extends SchemaBuilderType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n>(sqlType: PossibleSQLType) {\n\ttype ReturnType = Parameters<\n\t\tParameters<Parameters<SchemaBuilder[\"queryField\"]>[1]>[0][\"field\"]\n\t>[0][\"type\"];\n\n\tlet ret: ReturnType | undefined = undefined;\n\n\tif (\n\t\t[\"serial\", \"int\", \"integer\", \"tinyint\", \"smallint\", \"mediumint\"].includes(\n\t\t\tsqlType,\n\t\t)\n\t) {\n\t\tret = \"Int\";\n\t}\n\n\tif ([\"real\", \"decimal\", \"double\", \"float\"].includes(sqlType)) {\n\t\tret = \"Float\";\n\t}\n\n\tif ([\"string\", \"text\", \"varchar\", \"char\", \"text(256)\"].includes(sqlType)) {\n\t\tret = \"String\";\n\t}\n\n\tif ([\"uuid\"].includes(sqlType)) {\n\t\tret = \"ID\";\n\t}\n\n\tif ([\"boolean\"].includes(sqlType)) {\n\t\tret = \"Boolean\";\n\t}\n\n\tif ([\"timestamp\", \"datetime\"].includes(sqlType)) {\n\t\tret = \"DateTime\";\n\t}\n\n\tif ([\"date\"].includes(sqlType)) {\n\t\tret = \"Date\";\n\t}\n\n\tif ([\"json\"].includes(sqlType)) {\n\t\tret = \"JSON\";\n\t}\n\n\tif (ret !== undefined) {\n\t\treturn ret;\n\t}\n\n\tthrow UnknownTypeRumbleError(sqlType, \"SQL to GQL\");\n}\n","import type { GetColumnData } from \"drizzle-orm\";\nimport { createPubSub } from \"graphql-yoga\";\nimport type { TableIdentifierTSName } from \"./helpers/tableHelpers\";\nimport type { GenericDrizzleDbTypeConstraints } from \"./types/genericDrizzleDbType\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\n\ntype PubSubAction = \"created\" | \"removed\" | \"updated\";\n\nconst SUBSCRIPTION_NOTIFIER_RUMBLE_PREFIX = \"RUMBLE_SUBSCRIPTION_NOTIFICATION\";\nconst SUBSCRIPTION_NOTIFIER_REMOVED = \"REMOVED\";\nconst SUBSCRIPTION_NOTIFIER_UPDATED = \"UPDATED\";\nconst SUBSCRIPTION_NOTIFIER_CREATED = \"CREATED\";\n\nexport type MakePubSubInstanceType<\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n> = ReturnType<\n\ttypeof createPubSubInstance<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>\n>[\"makePubSubInstance\"];\n\nexport const createPubSubInstance = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n>({\n\tsubscriptions,\n\tdb,\n}: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig>) => {\n\tconst pubsub = subscriptions\n\t\t? createPubSub(...subscriptions)\n\t\t: createPubSub();\n\n\tconst makePubSubInstance = <\n\t\tExplicitTableName extends TableIdentifierTSName<DB>,\n\t>({\n\t\ttable,\n\t}: {\n\t\ttable: ExplicitTableName;\n\t}) => {\n\t\ttype PrimaryKeyType = any;\n\n\t\tfunction makePubSubKey({\n\t\t\taction,\n\t\t\ttableName,\n\t\t\tprimaryKeyValue,\n\t\t}: {\n\t\t\ttableName: string;\n\t\t\taction: PubSubAction;\n\t\t\tprimaryKeyValue?: PrimaryKeyType;\n\t\t}) {\n\t\t\tlet actionKey: string;\n\n\t\t\tswitch (action) {\n\t\t\t\tcase \"created\":\n\t\t\t\t\tactionKey = SUBSCRIPTION_NOTIFIER_CREATED;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"removed\":\n\t\t\t\t\tactionKey = SUBSCRIPTION_NOTIFIER_REMOVED;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"updated\":\n\t\t\t\t\tactionKey = SUBSCRIPTION_NOTIFIER_UPDATED;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error(`Unknown action: ${action}`);\n\t\t\t}\n\n\t\t\treturn `${SUBSCRIPTION_NOTIFIER_RUMBLE_PREFIX}/${tableName}${\n\t\t\t\tprimaryKeyValue ? `/${primaryKeyValue}` : \"\"\n\t\t\t}/${actionKey}`;\n\t\t}\n\n\t\treturn {\n\t\t\t/**\n\t\t\t * Call this when you want to register a subscription on an instance to this table\n\t\t\t */\n\t\t\tregisterOnInstance({\n\t\t\t\tinstance,\n\t\t\t\taction,\n\t\t\t\tprimaryKeyValue,\n\t\t\t}: {\n\t\t\t\tinstance: { register: (id: string) => void };\n\t\t\t\taction: PubSubAction;\n\t\t\t\tprimaryKeyValue?: string;\n\t\t\t}) {\n\t\t\t\tconst key = makePubSubKey({\n\t\t\t\t\ttableName: table.toString(),\n\t\t\t\t\taction,\n\t\t\t\t\tprimaryKeyValue,\n\t\t\t\t});\n\t\t\t\tinstance.register(key);\n\t\t\t},\n\t\t\t/**\n\t\t\t * Call this when you created an entity of this table\n\t\t\t */\n\t\t\tcreated() {\n\t\t\t\tconst key = makePubSubKey({\n\t\t\t\t\ttableName: table.toString(),\n\t\t\t\t\taction: \"created\",\n\t\t\t\t});\n\t\t\t\treturn pubsub.publish(key);\n\t\t\t},\n\t\t\t/**\n\t\t\t * Call this when you removed one or more entities of this table\n\t\t\t */\n\t\t\tremoved(primaryKeyValue?: PrimaryKeyType | PrimaryKeyType[]) {\n\t\t\t\tconst key = makePubSubKey({\n\t\t\t\t\ttableName: table.toString(),\n\t\t\t\t\taction: \"removed\",\n\t\t\t\t\t//TODO would it make sense to use specific sub topics here?\n\t\t\t\t\t// primaryKeyValue,\n\t\t\t\t});\n\t\t\t\treturn pubsub.publish(key);\n\t\t\t},\n\t\t\t/**\n\t\t\t * Call this when you updated one or more entities of this table\n\t\t\t */\n\t\t\tupdated(primaryKeyValue?: PrimaryKeyType | PrimaryKeyType[]) {\n\t\t\t\tconst primaryKeys = Array.isArray(primaryKeyValue)\n\t\t\t\t\t? primaryKeyValue\n\t\t\t\t\t: [primaryKeyValue];\n\t\t\t\tconst keys = primaryKeys.map((primaryKeyValue) =>\n\t\t\t\t\tmakePubSubKey({\n\t\t\t\t\t\ttableName: table.toString(),\n\t\t\t\t\t\taction: \"updated\",\n\t\t\t\t\t\tprimaryKeyValue,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tconst uniqueKeys = Array.from(new Set(keys));\n\t\t\t\tfor (const key of uniqueKeys) {\n\t\t\t\t\tpubsub.publish(key);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t};\n\n\treturn {\n\t\tpubsub,\n\t\tmakePubSubInstance,\n\t};\n};\n","import type { Filter } from \"../explicitFiltersPlugin/pluginTypes\";\nimport { RumbleErrorSafe } from \"../types/rumbleError\";\n\n/**\n * \n * Helper function to map a drizzle findFirst query result,\n * which may be optional, to a correct drizzle type.\n * \n * @throws RumbleError\n * \n * @example\n * \n * ```ts\n * schemaBuilder.queryFields((t) => {\n return {\n findFirstUser: t.drizzleField({\n type: UserRef,\n resolve: (query, root, args, ctx, info) => {\n return (\n db.query.users\n .findFirst({\n ...query,\n where: ctx.abilities.users.filter(\"read\").single.where,\n })\n // note that we need to manually raise an error if the value is not found\n .then(assertFindFirstExists)\n );\n },\n }),\n };\n });\n * ```\n */\nexport const assertFindFirstExists = <T>(value: T | undefined): T => {\n\tif (!value)\n\t\tthrow new RumbleErrorSafe(\"Value not found but required (findFirst)\");\n\treturn value;\n};\n\n/**\n * \n * Helper function to map a drizzle findFirst query result,\n * which may be optional, to a correct drizzle type.\n * \n * @throws RumbleError\n * \n * @example\n * \n * ```ts\n schemaBuilder.mutationFields((t) => {\n return {\n updateUsername: t.drizzleField({\n type: UserRef,\n args: {\n userId: t.arg.int({ required: true }),\n newName: t.arg.string({ required: true }),\n },\n resolve: (query, root, args, ctx, info) => {\n return db\n .update(schema.users)\n .set({\n name: args.newName,\n })\n .where(\n and(\n eq(schema.users.id, args.userId),\n ctx.abilities.users.filter(\"update\").single.where\n )\n )\n .returning({ id: schema.users.id, name: schema.users.name })\n // note that we need to manually raise an error if the value is not found\n .then(assertFirstEntryExists);\n },\n }),\n };\n });\n * ```\n */\nexport const assertFirstEntryExists = <T>(value: T[]): T => {\n\tconst v = value.at(0);\n\tif (!v)\n\t\tthrow new RumbleErrorSafe(\"Value not found but required (firstEntry)\");\n\treturn v;\n};\n\n/**\n * A helper to apply a list of filters to a given list of entities.\n * \n * @example\n * \n * ```ts\n * const filtered = await applyFilters({\n filters: abilityBuilder.registeredFilters.posts.update,\n entities: entitiesToFilter,\n context: ctx,\n });\n * ```\n */\nexport const applyFilters = async <Context, T, H extends T>({\n\tfilters,\n\tentities,\n\tcontext,\n}: { entities: T[]; filters: Filter<Context, H>[]; context: Context }) => {\n\treturn (\n\t\tawait Promise.all(\n\t\t\tfilters.map((f) =>\n\t\t\t\tf({\n\t\t\t\t\tcontext,\n\t\t\t\t\tentities: entities as H[],\n\t\t\t\t}),\n\t\t\t),\n\t\t)\n\t).reduce((acc, val) => {\n\t\tacc.push(...val);\n\t\treturn acc;\n\t}, []) as T[];\n};\n","import { capitalizeFirstLetter } from \"./helpers/capitalize\";\nimport { assertFindFirstExists } from \"./helpers/helper\";\nimport {\n\ttype TableIdentifierTSName,\n\ttableHelper,\n} from \"./helpers/tableHelpers\";\nimport type { MakePubSubInstanceType } from \"./pubsub\";\nimport type { SchemaBuilderType } from \"./schemaBuilder\";\nimport type { GenericDrizzleDbTypeConstraints } from \"./types/genericDrizzleDbType\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\nimport type { ArgImplementerType } from \"./whereArg\";\n\nexport const createQueryImplementer = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n\tSchemaBuilder extends SchemaBuilderType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n\tArgImplementer extends ArgImplementerType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n\tMakePubSubInstance extends MakePubSubInstanceType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n>({\n\tdb,\n\tschemaBuilder,\n\targImplementer,\n\tmakePubSubInstance,\n}: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig> & {\n\tschemaBuilder: SchemaBuilder;\n\targImplementer: ArgImplementer;\n\tmakePubSubInstance: MakePubSubInstance;\n}) => {\n\treturn <ExplicitTableName extends TableIdentifierTSName<DB>>({\n\t\ttable,\n\t\treadAction = \"read\" as Action,\n\t\tlistAction = \"read\" as Action,\n\t}: {\n\t\t/**\n\t\t * The table for which to implement the query\n\t\t */\n\t\ttable: ExplicitTableName;\n\t\t/**\n\t\t * Which action should be used for reading single entities\n\t\t * @default \"read\"\n\t\t */\n\t\treadAction?: Action;\n\t\t/**\n\t\t * Which action should be used for listing many entities\n\t\t * @default \"read\"\n\t\t */\n\t\tlistAction?: Action;\n\t}) => {\n\t\tconst WhereArg = argImplementer({\n\t\t\ttable: table,\n\t\t});\n\n\t\tconst { registerOnInstance } = makePubSubInstance({ table: table });\n\n\t\treturn schemaBuilder.queryFields((t) => {\n\t\t\treturn {\n\t\t\t\t[`findMany${capitalizeFirstLetter(table.toString())}`]: t.drizzleField({\n\t\t\t\t\ttype: [table],\n\t\t\t\t\tnullable: false,\n\t\t\t\t\tsmartSubscription: true,\n\t\t\t\t\tsubscribe: (subscriptions, root, args, ctx, info) => {\n\t\t\t\t\t\tregisterOnInstance({\n\t\t\t\t\t\t\tinstance: subscriptions,\n\t\t\t\t\t\t\taction: \"created\",\n\t\t\t\t\t\t});\n\t\t\t\t\t\tregisterOnInstance({\n\t\t\t\t\t\t\tinstance: subscriptions,\n\t\t\t\t\t\t\taction: \"removed\",\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\targs: {\n\t\t\t\t\t\twhere: t.arg({ type: WhereArg, required: false }),\n\t\t\t\t\t},\n\t\t\t\t\tresolve: (query, root, args, ctx, info) => {\n\t\t\t\t\t\tconst filter = ctx.abilities[table as any].filter(listAction, {\n\t\t\t\t\t\t\tinject: { where: args.where },\n\t\t\t\t\t\t}).query.many;\n\n\t\t\t\t\t\tconst queryInstance = query(filter as any);\n\n\t\t\t\t\t\tif (filter.columns) {\n\t\t\t\t\t\t\tqueryInstance.columns = filter.columns;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn db.query[table as any].findMany(queryInstance);\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t\t[`findFirst${capitalizeFirstLetter(table.toString())}`]: t.drizzleField(\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: table,\n\t\t\t\t\t\tnullable: false,\n\t\t\t\t\t\tsmartSubscription: true,\n\t\t\t\t\t\targs: {\n\t\t\t\t\t\t\twhere: t.arg({ type: WhereArg, required: false }),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresolve: (query, root, args, ctx, info) => {\n\t\t\t\t\t\t\tconst filter = ctx.abilities[table as any].filter(readAction, {\n\t\t\t\t\t\t\t\tinject: { where: args.where },\n\t\t\t\t\t\t\t}).query.single;\n\n\t\t\t\t\t\t\tconst queryInstance = query(filter as any);\n\n\t\t\t\t\t\t\tif (filter.columns) {\n\t\t\t\t\t\t\t\tqueryInstance.columns = filter.columns;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn db.query[table as any]\n\t\t\t\t\t\t\t\t.findFirst(queryInstance)\n\t\t\t\t\t\t\t\t.then(assertFindFirstExists);\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t};\n\t\t});\n\t};\n};\n","import \"./pluginTypes\";\nimport SchemaBuilder, {\n\tBasePlugin,\n\ttype PothosEnumValueConfig,\n\ttype PothosInputFieldConfig,\n\ttype PothosInterfaceTypeConfig,\n\ttype PothosOutputFieldConfig,\n\ttype PothosTypeConfig,\n\ttype PothosUnionTypeConfig,\n\ttype SchemaTypes,\n} from \"@pothos/core\";\nimport type {\n\tGraphQLFieldResolver,\n\tGraphQLSchema,\n\tGraphQLTypeResolver,\n} from \"graphql\";\nimport { applyFilters } from \"../helpers/helper\";\nimport type { ApplyFiltersField } from \"./pluginTypes\";\n\nconst pluginName = \"ManualFiltersPlugin\";\n\nexport default pluginName;\n\nexport const applyFiltersKey = \"applyFilters\";\n\nexport class ManualFiltersPlugin<\n\tTypes extends SchemaTypes,\n> extends BasePlugin<Types> {\n\toverride wrapResolve(\n\t\tresolver: GraphQLFieldResolver<unknown, Types[\"Context\"], object>,\n\t\tfieldConfig: PothosOutputFieldConfig<Types>,\n\t): GraphQLFieldResolver<unknown, Types[\"Context\"], object> {\n\t\treturn async (parent, args, context, info) => {\n\t\t\t//TODO: https://github.com/hayes/pothos/discussions/1431#discussioncomment-12974130\n\t\t\tconst filters: ApplyFiltersField<Types[\"Context\"], any> = (\n\t\t\t\tfieldConfig?.type as any\n\t\t\t).type?.ref.currentConfig.pothosOptions[applyFiltersKey];\n\n\t\t\t// if no filter should be applied, just continue\n\t\t\tif (!filters || !Array.isArray(filters) || filters.length === 0) {\n\t\t\t\treturn resolver(parent, args, context, info);\n\t\t\t}\n\n\t\t\tconst resolved = await resolver(parent, args, context, info);\n\t\t\tconst allResolvedValues = Array.isArray(resolved) ? resolved : [resolved];\n\t\t\tconst allFilters = Array.isArray(filters) ? filters : [filters];\n\n\t\t\tconst allowed = await applyFilters({\n\t\t\t\tfilters: allFilters,\n\t\t\t\tentities: allResolvedValues,\n\t\t\t\tcontext,\n\t\t\t});\n\n\t\t\t// if the original value was an array, return an array\n\t\t\tif (Array.isArray(resolved)) {\n\t\t\t\treturn allowed;\n\t\t\t}\n\n\t\t\t// if the original value was a single value, return the first allowed\n\t\t\t// or null if not allowed\n\t\t\treturn allowed[0] ?? null;\n\t\t};\n\t}\n}\n\nSchemaBuilder.registerPlugin(pluginName, ManualFiltersPlugin);\n","import SchemaBuilder from \"@pothos/core\";\nimport DrizzlePlugin from \"@pothos/plugin-drizzle\";\nimport SmartSubscriptionsPlugin, {\n\tsubscribeOptionsFromIterator,\n} from \"@pothos/plugin-smart-subscriptions\";\nimport {\n\tDateResolver,\n\tDateTimeISOResolver,\n\tJSONResolver,\n} from \"graphql-scalars\";\nimport type { createPubSub } from \"graphql-yoga\";\nimport type { ContextType } from \"./context\";\nimport ExplicitChecksPlugin from \"./explicitFiltersPlugin/explicitFiltersPlugin\";\nimport type { GenericDrizzleDbTypeConstraints } from \"./types/genericDrizzleDbType\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\n\nexport type SchemaBuilderType<\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n> = ReturnType<\n\ttypeof createSchemaBuilder<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>\n>[\"schemaBuilder\"];\n\nexport const createSchemaBuilder = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n>({\n\tdb,\n\tdisableDefaultObjects,\n\tpubsub,\n\tpothosConfig,\n}: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig> & {\n\tpubsub: ReturnType<typeof createPubSub>;\n}) => {\n\tconst schemaBuilder = new SchemaBuilder<{\n\t\tContext: ContextType<UserContext, DB, RequestEvent, Action, PothosConfig>;\n\t\tDrizzleRelations: DB[\"_\"][\"relations\"];\n\t\tScalars: {\n\t\t\tJSON: {\n\t\t\t\tInput: unknown;\n\t\t\t\tOutput: unknown;\n\t\t\t};\n\t\t\tDate: {\n\t\t\t\tInput: Date;\n\t\t\t\tOutput: Date;\n\t\t\t};\n\t\t\tDateTime: {\n\t\t\t\tInput: Date;\n\t\t\t\tOutput: Date;\n\t\t\t};\n\t\t};\n\t}>({\n\t\tplugins: [\n\t\t\tExplicitChecksPlugin,\n\t\t\tDrizzlePlugin,\n\t\t\tSmartSubscriptionsPlugin,\n\t\t\t...(pothosConfig?.plugins ?? []),\n\t\t],\n\t\t...pothosConfig,\n\t\tdrizzle: {\n\t\t\tclient: db,\n\t\t\trelations: db._.relations,\n\t\t\tgetTableConfig(table) {\n\t\t\t\t//TODO support composite primary keys\n\t\t\t\treturn {\n\t\t\t\t\tcolumns: Object.values((table as any)[Symbol.for(\"drizzle:Columns\")]),\n\t\t\t\t\tprimaryKeys: Object.values(\n\t\t\t\t\t\t(table as any)[Symbol.for(\"drizzle:Columns\")],\n\t\t\t\t\t).filter((v: any) => v.primary),\n\t\t\t\t} as any;\n\t\t\t},\n\t\t},\n\t\tsmartSubscriptions: {\n\t\t\t...subscribeOptionsFromIterator((name, context) => {\n\t\t\t\treturn pubsub.subscribe(name);\n\t\t\t}),\n\t\t},\n\t});\n\n\tschemaBuilder.addScalarType(\"JSON\", JSONResolver);\n\tschemaBuilder.addScalarType(\"Date\", DateResolver);\n\tschemaBuilder.addScalarType(\"DateTime\", DateTimeISOResolver);\n\n\tif (!disableDefaultObjects?.query) {\n\t\tschemaBuilder.queryType({});\n\t}\n\n\tif (!disableDefaultObjects?.subscription) {\n\t\tschemaBuilder.subscriptionType({});\n\t}\n\n\tif (!disableDefaultObjects?.mutation) {\n\t\tschemaBuilder.mutationType({});\n\t}\n\n\treturn { schemaBuilder };\n};\n","import type { Table } from \"drizzle-orm\";\nimport { toCamelCase } from \"drizzle-orm/casing\";\nimport { type EnumImplementerType, isEnumSchema } from \"./enum\";\nimport { capitalizeFirstLetter } from \"./helpers/capitalize\";\nimport { mapSQLTypeToGraphQLType } from \"./helpers/sqlTypes/mapSQLTypeToTSType\";\nimport type { PossibleSQLType } from \"./helpers/sqlTypes/types\";\nimport {\n\ttype TableIdentifierTSName,\n\ttableHelper,\n} from \"./helpers/tableHelpers\";\nimport type { SchemaBuilderType } from \"./schemaBuilder\";\nimport type { GenericDrizzleDbTypeConstraints } from \"./types/genericDrizzleDbType\";\nimport { RumbleError } from \"./types/rumbleError\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\n\nexport type ArgImplementerType<\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n> = ReturnType<\n\ttypeof createArgImplementer<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig,\n\t\tSchemaBuilderType<UserContext, DB, RequestEvent, Action, PothosConfig>,\n\t\tEnumImplementerType<UserContext, DB, RequestEvent, Action, PothosConfig>\n\t>\n>;\n\nconst makeDefaultName = (dbName: string) =>\n\t`${capitalizeFirstLetter(toCamelCase(dbName.toString()))}WhereInputArgument`;\n\nexport const createArgImplementer = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tAction extends string,\n\tPothosConfig extends CustomRumblePothosConfig,\n\tSchemaBuilder extends SchemaBuilderType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n\tEnumImplementer extends EnumImplementerType<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>,\n>({\n\tdb,\n\tschemaBuilder,\n\tenumImplementer,\n}: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig> & {\n\tenumImplementer: EnumImplementer;\n\tschemaBuilder: SchemaBuilder;\n}) => {\n\tconst referenceStorage = new Map<string, any>();\n\n\tconst argImplementer = <\n\t\tExplicitTableName extends TableIdentifierTSName<DB>,\n\t\tRefName extends string,\n\t>({\n\t\ttable,\n\t\trefName,\n\t\tdbName,\n\t}: Partial<{\n\t\ttable: ExplicitTableName;\n\t\trefName: RefName | undefined;\n\t\tdbName: string;\n\t}> &\n\t\t(\n\t\t\t| {\n\t\t\t\t\ttable: ExplicitTableName;\n\t\t\t }\n\t\t\t| {\n\t\t\t\t\tdbName: string;\n\t\t\t }\n\t\t)) => {\n\t\tconst tableSchema = tableHelper({\n\t\t\tdb,\n\t\t\tdbName,\n\t\t\ttsName: table!,\n\t\t});\n\n\t\tconst inputTypeName = refName ?? makeDefaultName(tableSchema.tsName);\n\n\t\tlet ret: ReturnType<typeof implement> | undefined =\n\t\t\treferenceStorage.get(inputTypeName);\n\t\tif (ret) {\n\t\t\treturn ret;\n\t\t}\n\n\t\tconst implement = () => {\n\t\t\treturn schemaBuilder.inputType(inputTypeName, {\n\t\t\t\tfields: (t) => {\n\t\t\t\t\tconst mapSQLTypeStringToInputPothosType = <\n\t\t\t\t\t\tColumn extends keyof typeof tableSchema.columns,\n\t\t\t\t\t\tSQLType extends ReturnType<\n\t\t\t\t\t\t\t(typeof tableSchema.columns)[Column][\"getSQLType\"]\n\t\t\t\t\t\t>,\n\t\t\t\t\t>(\n\t\t\t\t\t\tsqlType: SQLType,\n\t\t\t\t\t) => {\n\t\t\t\t\t\tconst gqlType = mapSQLTypeToGraphQLType(sqlType as PossibleSQLType);\n\t\t\t\t\t\tswitch (gqlType) {\n\t\t\t\t\t\t\tcase \"Int\":\n\t\t\t\t\t\t\t\treturn t.int({ required: false });\n\t\t\t\t\t\t\t//TOOD: add support for non equality matching filters\n\t\t\t\t\t\t\tcase \"String\":\n\t\t\t\t\t\t\t\treturn t.string({ required: false });\n\t\t\t\t\t\t\tcase \"Boolean\":\n\t\t\t\t\t\t\t\treturn t.boolean({ required: false });\n\t\t\t\t\t\t\tcase \"Date\":\n\t\t\t\t\t\t\t\treturn t.field({\n\t\t\t\t\t\t\t\t\ttype: \"Date\",\n\t\t\t\t\t\t\t\t\trequired: false,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcase \"DateTime\":\n\t\t\t\t\t\t\t\treturn t.field({\n\t\t\t\t\t\t\t\t\ttype: \"DateTime\",\n\t\t\t\t\t\t\t\t\trequired: false,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcase \"Float\":\n\t\t\t\t\t\t\t\treturn t.float({ required: false });\n\t\t\t\t\t\t\tcase \"ID\":\n\t\t\t\t\t\t\t\treturn t.id({ required: false });\n\t\t\t\t\t\t\tcase \"JSON\":\n\t\t\t\t\t\t\t\treturn t.field({\n\t\t\t\t\t\t\t\t\ttype: \"JSON\",\n\t\t\t\t\t\t\t\t\trequired: false,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tthrow new RumbleError(\n\t\t\t\t\t\t\t\t\t`Unsupported argument type ${gqlType} for column ${sqlType}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\tconst fields = Object.entries(tableSchema.columns).reduce(\n\t\t\t\t\t\t(acc, [key, value]) => {\n\t\t\t\t\t\t\tif (isEnumSchema(value)) {\n\t\t\t\t\t\t\t\tconst enumImpl = enumImplementer({\n\t\t\t\t\t\t\t\t\tenumColumn: value,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tacc[key] = t.field({\n\t\t\t\t\t\t\t\t\ttype: enumImpl,\n\t\t\t\t\t\t\t\t\trequired: false,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tacc[key] = mapSQLTypeStringToInputPothosType(\n\t\t\t\t\t\t\t\t\tvalue.getSQLType(),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{} as Record<\n\t\t\t\t\t\t\tkeyof typeof tableSchema.columns,\n\t\t\t\t\t\t\tReturnType<typeof mapSQLTypeStringToInputPothosType>\n\t\t\t\t\t\t>,\n\t\t\t\t\t);\n\n\t\t\t\t\tconst relations = Object.entries(tableSchema.relations).reduce(\n\t\t\t\t\t\t(acc, [key, value]) => {\n\t\t\t\t\t\t\tconst relationSchema = tableHelper({\n\t\t\t\t\t\t\t\tdb,\n\t\t\t\t\t\t\t\ttable: value.targetTable as Table,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst referenceModel = argImplementer({\n\t\t\t\t\t\t\t\tdbName: relationSchema.dbName,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tacc[key] = t.field({\n\t\t\t\t\t\t\t\ttype: referenceModel,\n\t\t\t\t\t\t\t\trequired: false,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{} as Record<\n\t\t\t\t\t\t\tkeyof typeof tableSchema.columns,\n\t\t\t\t\t\t\tReturnType<typeof mapSQLTypeStringToInputPothosType>\n\t\t\t\t\t\t>,\n\t\t\t\t\t);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...fields,\n\t\t\t\t\t\t...relations,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t});\n\t\t};\n\n\t\tret = implement();\n\t\treferenceStorage.set(inputTypeName, ret);\n\t\treturn ret;\n\t};\n\n\treturn argImplementer;\n};\n","import {\n\ttype YogaServerOptions,\n\tcreateYoga as nativeCreateYoga,\n} from \"graphql-yoga\";\nimport { createAbilityBuilder } from \"./abilityBuilder\";\nimport { createContextFunction } from \"./context\";\nimport { createEnumImplementer } from \"./enum\";\nimport { createObjectImplementer } from \"./object\";\nimport { createPubSubInstance } from \"./pubsub\";\nimport { createQueryImplementer } from \"./query\";\nimport { createSchemaBuilder } from \"./schemaBuilder\";\nimport type { GenericDrizzleDbTypeConstraints } from \"./types/genericDrizzleDbType\";\nimport type {\n\tCustomRumblePothosConfig,\n\tRumbleInput,\n} from \"./types/rumbleInput\";\nimport { createArgImplementer } from \"./whereArg\";\n\nexport const rumble = <\n\tUserContext extends Record<string, any>,\n\tDB extends GenericDrizzleDbTypeConstraints,\n\tRequestEvent extends Record<string, any>,\n\tPothosConfig extends CustomRumblePothosConfig,\n\tAction extends string = \"read\" | \"update\" | \"delete\",\n>(\n\trumbleInput: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig>,\n) => {\n\t// to be able to iterate over the actions, we populate the actions array in case the user does not\n\tif (!rumbleInput.actions) {\n\t\trumbleInput.actions = [\"read\", \"update\", \"delete\"] as Action[];\n\t}\n\n\tif (rumbleInput.defaultLimit === undefined) {\n\t\trumbleInput.defaultLimit = 100;\n\t}\n\n\tconst abilityBuilder = createAbilityBuilder<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>(rumbleInput);\n\n\tconst context = createContextFunction<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig,\n\t\ttypeof abilityBuilder\n\t>({\n\t\t...rumbleInput,\n\t\tabilityBuilder,\n\t});\n\n\tconst { makePubSubInstance, pubsub } = createPubSubInstance<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>({\n\t\t...rumbleInput,\n\t});\n\n\tconst { schemaBuilder } = createSchemaBuilder<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig\n\t>({ ...rumbleInput, pubsub });\n\tconst enum_ = createEnumImplementer<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig,\n\t\ttypeof schemaBuilder\n\t>({\n\t\t...rumbleInput,\n\t\tschemaBuilder,\n\t});\n\tconst arg = createArgImplementer<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig,\n\t\ttypeof schemaBuilder,\n\t\ttypeof enum_\n\t>({\n\t\t...rumbleInput,\n\t\tschemaBuilder,\n\t\tenumImplementer: enum_,\n\t});\n\tconst object = createObjectImplementer<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig,\n\t\ttypeof schemaBuilder,\n\t\ttypeof arg,\n\t\ttypeof enum_,\n\t\ttypeof makePubSubInstance,\n\t\ttypeof abilityBuilder\n\t>({\n\t\t...rumbleInput,\n\t\tschemaBuilder,\n\t\tmakePubSubInstance,\n\t\targImplementer: arg,\n\t\tenumImplementer: enum_,\n\t\tabilityBuilder,\n\t});\n\tconst query = createQueryImplementer<\n\t\tUserContext,\n\t\tDB,\n\t\tRequestEvent,\n\t\tAction,\n\t\tPothosConfig,\n\t\ttypeof schemaBuilder,\n\t\ttypeof arg,\n\t\ttypeof makePubSubInstance\n\t>({\n\t\t...rumbleInput,\n\t\tschemaBuilder,\n\t\targImplementer: arg,\n\t\tmakePubSubInstance,\n\t});\n\n\tconst createYoga = (\n\t\targs?:\n\t\t\t| Omit<YogaServerOptions<RequestEvent, any>, \"schema\" | \"context\">\n\t\t\t| undefined,\n\t) =>\n\t\tnativeCreateYoga<RequestEvent>({\n\t\t\t...args,\n\t\t\tschema: schemaBuilder.toSchema(),\n\t\t\tcontext,\n\t\t});\n\n\treturn {\n\t\t/**\n * The ability builder. Use it to declare whats allowed for each entity in your DB.\n * \n * @example\n * \n * ```ts\n * // users can edit themselves\n abilityBuilder.users\n .allow([\"read\", \"update\", \"delete\"])\n .when(({ userId }) => ({ where: eq(schema.users.id, userId) }));\n \n // everyone can read posts\n abilityBuilder.posts.allow(\"read\");\n * \n * ```\n */\n\t\tabilityBuilder,\n\t\t/**\n\t\t * The pothos schema builder. See https://pothos-graphql.dev/docs/plugins/drizzle\n\t\t */\n\t\tschemaBuilder,\n\t\t/**\n * Creates the native yoga instance. Can be used to run an actual HTTP server.\n * \n * @example\n * \n * ```ts\n import { createServer } from \"node:http\";\n * const server = createServer(createYoga());\n server.listen(3000, () => {\n console.info(\"Visit http://localhost:3000/graphql\");\n });\n * ```\n */\n\t\tcreateYoga,\n\t\t/**\n\t\t * A function for creating default objects for your schema\n\t\t */\n\t\tobject,\n\t\t/**\n\t\t * A function for creating where args to filter entities\n\t\t */\n\t\targ,\n\t\t/**\n\t\t * A function for creating default READ queries.\n\t\t * Make sure the objects for the table you are creating the queries for are implemented\n\t\t */\n\t\tquery,\n\t\t/**\n\t\t * A function for creating a pubsub instance for a table. Use this to publish or subscribe events\n\t\t */\n\t\tpubsub: makePubSubInstance,\n\t\t/**\n\t\t * A function to implement enums for graphql usage.\n\t\t * The other helpers use this helper internally so in most cases you do not have to\n\t\t * call this helper directly, unless you need the reference to an enum type\n\t\t */\n\t\tenum_,\n\t};\n};\n"]}
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@m1212e/rumble","module":"index.ts","type":"module","repository":"https://github.com/m1212e/rumble","peerDependencies":{"typescript":"^5","drizzle-orm":"^0"},"dependencies":{"@pothos/core":"^4.6.0","@pothos/plugin-drizzle":"^0.7.2","@pothos/plugin-smart-subscriptions":"^4.1.1","graphql-scalars":"^1.24.2","graphql-yoga":"^5.13.4"},"version":"0.5.5","exports":{"./package.json":"./package.json",".":{"require":"./index.cjs","import":"./index.js","node":"./index.cjs","default":"./index.cjs"}}}
1
+ {"name":"@m1212e/rumble","module":"index.ts","type":"module","repository":"https://github.com/m1212e/rumble","peerDependencies":{"typescript":"^5","drizzle-orm":"^1"},"dependencies":{"@pothos/core":"^4.6.2","@pothos/plugin-drizzle":"^0.10.2","@pothos/plugin-smart-subscriptions":"^4.1.2","graphql-scalars":"^1.24.2","graphql-yoga":"^5.13.4"},"version":"0.6.0","exports":{"./package.json":"./package.json",".":{"require":"./index.cjs","import":"./index.js","node":"./index.cjs","default":"./index.cjs"}}}