@exogee/graphweaver-mikroorm 2.20.6 → 2.20.8

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.
@@ -245,18 +245,11 @@ class MikroBackendProvider {
245
245
  }
246
246
  getDbType() {
247
247
  const driver = this.em.getDriver().constructor.name;
248
- switch (driver) {
249
- case "MsSqlDriver":
250
- return "mssql";
251
- case "MySqlDriver":
252
- return "mysql";
253
- case "PostgreSqlDriver":
254
- return "postgresql";
255
- case "SqliteDriver":
256
- return "sqlite";
257
- default:
258
- throw new Error(`This driver (${driver}) is not supported!`);
259
- }
248
+ if (driver.startsWith("MsSqlDriver")) return "mssql";
249
+ if (driver.startsWith("MySqlDriver")) return "mysql";
250
+ if (driver.startsWith("PostgreSqlDriver")) return "postgresql";
251
+ if (driver.startsWith("SqliteDriver")) return "sqlite";
252
+ throw new Error(`This driver (${driver}) is not supported!`);
260
253
  }
261
254
  async find(filter, pagination, entityMetadata, trace) {
262
255
  trace?.span.updateName(`Mikro-Orm - Find ${this.entityType.name}`);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/provider/provider.ts"],
4
- "sourcesContent": ["import {\n\tAggregationType,\n\tBackendProvider,\n\tgraphweaverMetadata,\n\tGraphweaverPluginNextFunction,\n\tGraphweaverRequestEvent,\n\tSort,\n\ttrace as startTrace,\n\tTraceMethod,\n\ttraceSync,\n} from '@exogee/graphweaver';\nimport type {\n\tAggregationResult,\n\tBackendProviderConfig,\n\tEntityMetadata,\n\tFieldMetadata,\n\tFilter,\n\tPaginationOptions,\n\tTraceOptions,\n} from '@exogee/graphweaver';\nimport { logger, safeErrorLog } from '@exogee/logger';\nimport {\n\tAutoPath,\n\tLoadStrategy,\n\tPopulateHint,\n\tReference,\n\tRequestContext,\n\tsql,\n} from '@mikro-orm/core';\nimport { pluginManager, apolloPluginManager } from '@exogee/graphweaver-server';\n\nimport {\n\tLockMode,\n\tQueryFlag,\n\tReferenceKind,\n\tConnectionManager,\n\texternalIdFieldMap,\n\tAnyEntity,\n\tIsolationLevel,\n\tConnectionOptions,\n\tconnectToDatabase,\n\tDatabaseType,\n} from '..';\n\nimport { OptimisticLockError, sanitiseFilterForLogging } from '../utils';\nimport { assign } from './assign';\n\ntype PostgresError = {\n\tcode: string;\n\troutine: string;\n};\n\nconst objectOperations = new Set(['_and', '_or', '_not']);\nconst mikroObjectOperations = new Set(['$and', '$or', '$not']);\nconst nullBooleanOperations = new Set(['null', 'notnull']);\n\nconst appendPath = (path: string, newPath: string) =>\n\tpath.length ? `${path}.${newPath}` : newPath;\n\nexport const gqlToMikro = (filter: any, databaseType?: DatabaseType): any => {\n\tif (Array.isArray(filter)) {\n\t\treturn filter.map((element) => gqlToMikro(element, databaseType));\n\t} else if (typeof filter === 'object' && filter !== null) {\n\t\tfor (const key of Object.keys(filter)) {\n\t\t\t// A null here is a user-specified value and is valid to filter on\n\t\t\tif (filter[key] === null) continue;\n\n\t\t\tif (objectOperations.has(key)) {\n\t\t\t\t// { _not: '1' } => { $not: '1' }\n\t\t\t\tfilter[key.replace('_', '$')] = gqlToMikro(filter[key], databaseType);\n\t\t\t\tdelete filter[key];\n\t\t\t} else if (typeof filter[key] === 'object' && !Array.isArray(filter[key])) {\n\t\t\t\t// Recurse over nested filters only (arrays are an argument to a filter, not a nested filter)\n\t\t\t\tfilter[key] = gqlToMikro(filter[key], databaseType);\n\t\t\t} else if (key.indexOf('_') >= 0) {\n\t\t\t\tconst [newKey, operator] = key.split('_');\n\t\t\t\tlet newValue;\n\t\t\t\tif (nullBooleanOperations.has(operator) && typeof filter[key] === 'boolean') {\n\t\t\t\t\t// { firstName_null: true } => { firstName: { $eq: null } } or { firstName_null: false } => { firstName: { $ne: null } }\n\t\t\t\t\t// { firstName_notnull: true } => { firstName: { $ne: null } } or { firstName_notnull: false } => { firstName: { $eq: null } }\n\t\t\t\t\tnewValue =\n\t\t\t\t\t\t(filter[key] && operator === 'null') || (!filter[key] && operator === 'notnull')\n\t\t\t\t\t\t\t? { $eq: null }\n\t\t\t\t\t\t\t: { $ne: null };\n\t\t\t\t} else if (operator === 'ilike' && databaseType !== 'postgresql') {\n\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t`The $ilike operator is not supported by ${databaseType} databases. Operator coerced to $like.`\n\t\t\t\t\t);\n\t\t\t\t\tnewValue = { $like: filter[key] };\n\t\t\t\t} else {\n\t\t\t\t\t// { firstName_in: ['k', 'b'] } => { firstName: { $in: ['k', 'b'] } }\n\t\t\t\t\tnewValue = { [`$${operator}`]: gqlToMikro(filter[key], databaseType) };\n\t\t\t\t\t// They can construct multiple filters for the same key. In that case we need\n\t\t\t\t\t// to append them all into an object.\n\t\t\t\t}\n\n\t\t\t\tif (typeof filter[newKey] !== 'undefined') {\n\t\t\t\t\tif (typeof filter[newKey] !== 'object') {\n\t\t\t\t\t\tif (typeof newValue === 'object' && '$eq' in newValue) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`property ${newKey} on filter is ambiguous. There are two values for this property: ${filter[newKey]} and ${newValue.$eq}`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfilter[newKey] = { ...{ $eq: filter[newKey] }, ...newValue };\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (newValue && typeof newValue === 'object' && '$eq' in newValue) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`property ${newKey} on filter is ambiguous. There are two values for this property: ${JSON.stringify(\n\t\t\t\t\t\t\t\t\tfilter[newKey]\n\t\t\t\t\t\t\t\t)} and ${JSON.stringify(newValue)}`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfilter[newKey] = { ...filter[newKey], ...newValue };\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfilter[newKey] = newValue;\n\t\t\t\t}\n\n\t\t\t\tdelete filter[key];\n\t\t\t}\n\t\t}\n\t}\n\treturn filter;\n};\n\nexport interface AdditionalOptions {\n\ttransactionIsolationLevel?: IsolationLevel;\n\tbackendDisplayName?: string;\n}\n\nexport class MikroBackendProvider<D> implements BackendProvider<D> {\n\tprivate _backendId: string;\n\n\tprivate connection: ConnectionOptions;\n\n\tpublic entityType: new () => D;\n\tpublic connectionManagerId?: string;\n\tprivate transactionIsolationLevel!: IsolationLevel;\n\n\t// This is an optional setting that allows you to control how this provider is displayed in the Admin UI.\n\t// If you do not set a value, it will default to 'REST (hostname of baseUrl)'. Entities are grouped by\n\t// their backend's display name, so if you want to group them in a more specific way, this is the way to do it.\n\tpublic readonly backendDisplayName?: string;\n\n\tpublic readonly supportsInFilter = true;\n\n\t// Default backend provider config\n\tpublic readonly backendProviderConfig: BackendProviderConfig = {\n\t\tfilter: true,\n\t\tpagination: false,\n\t\torderBy: false,\n\t\tsupportedAggregationTypes: new Set<AggregationType>([AggregationType.COUNT]),\n\t\tsupportsPseudoCursorPagination: true,\n\t};\n\n\tget backendId() {\n\t\treturn this._backendId;\n\t}\n\n\tprivate get database() {\n\t\t// If we have a connection manager ID then use that else fallback to the Database\n\t\tif (!this.connectionManagerId) return ConnectionManager.default;\n\t\treturn ConnectionManager.database(this.connectionManagerId) || ConnectionManager.default;\n\t}\n\n\t// This is exposed for use in the RLS package\n\tpublic get transactional() {\n\t\treturn this.database.transactional;\n\t}\n\n\tpublic async withTransaction<T>(callback: () => Promise<T>) {\n\t\treturn this.database.transactional<T>(callback, this.transactionIsolationLevel);\n\t}\n\n\t// This is exposed for use in the RLS package\n\tpublic get em() {\n\t\treturn this.database.em;\n\t}\n\n\tpublic constructor(\n\t\tmikroType: new () => D,\n\t\tconnection: ConnectionOptions,\n\t\ttransactionIsolationLevel?: IsolationLevel\n\t);\n\tpublic constructor(\n\t\tmikroType: new () => D,\n\t\tconnection: ConnectionOptions,\n\t\tadditionalOptions?: AdditionalOptions\n\t);\n\tpublic constructor(\n\t\tmikroType: new () => D,\n\t\tconnection: ConnectionOptions,\n\t\toptionsOrIsolationLevel: AdditionalOptions | IsolationLevel = {\n\t\t\ttransactionIsolationLevel: IsolationLevel.REPEATABLE_READ,\n\t\t}\n\t) {\n\t\tconst options =\n\t\t\ttypeof optionsOrIsolationLevel === 'object'\n\t\t\t\t? optionsOrIsolationLevel\n\t\t\t\t: {\n\t\t\t\t\t\ttransactionIsolationLevel: optionsOrIsolationLevel,\n\t\t\t\t\t};\n\n\t\tthis.entityType = mikroType;\n\t\tthis.connectionManagerId = connection.connectionManagerId;\n\t\tthis._backendId = `mikro-orm-${connection.connectionManagerId || ''}`;\n\t\tthis.transactionIsolationLevel =\n\t\t\toptions.transactionIsolationLevel ?? IsolationLevel.REPEATABLE_READ;\n\t\tthis.backendDisplayName = options.backendDisplayName;\n\t\tthis.connection = connection;\n\t\tthis.addRequestContext();\n\t\tthis.connectToDatabase();\n\t}\n\tprivate getDbType(): DatabaseType {\n\t\tconst driver = this.em.getDriver().constructor.name;\n\t\t// This used to import the actual drivers, but since they're optional it makes more sense\n\t\t// to just use the strings.\n\t\tswitch (driver) {\n\t\t\tcase 'MsSqlDriver':\n\t\t\t\treturn 'mssql';\n\t\t\tcase 'MySqlDriver':\n\t\t\t\treturn 'mysql';\n\t\t\tcase 'PostgreSqlDriver':\n\t\t\t\treturn 'postgresql';\n\t\t\tcase 'SqliteDriver':\n\t\t\t\treturn 'sqlite';\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`This driver (${driver}) is not supported!`);\n\t\t}\n\t}\n\n\tprivate connectToDatabase = async () => {\n\t\tconst connectionManagerId = this.connectionManagerId;\n\t\tif (!connectionManagerId) {\n\t\t\tthrow new Error('Expected connectionManagerId to be defined when calling addRequestContext.');\n\t\t}\n\n\t\tapolloPluginManager.addPlugin(connectionManagerId, connectToDatabase(this.connection));\n\t};\n\n\tprivate addRequestContext = () => {\n\t\tconst connectionManagerId = this.connectionManagerId;\n\t\tif (!connectionManagerId) {\n\t\t\tthrow new Error('Expected connectionManagerId to be defined when calling addRequestContext.');\n\t\t}\n\n\t\tconst connectionPlugin = {\n\t\t\tname: connectionManagerId,\n\t\t\tevent: GraphweaverRequestEvent.OnRequest,\n\t\t\tnext: async (_: GraphweaverRequestEvent, _next: GraphweaverPluginNextFunction) => {\n\t\t\t\tlogger.trace(`Graphweaver OnRequest plugin called`);\n\n\t\t\t\tconst connection = await ConnectionManager.awaitableDatabase(connectionManagerId);\n\n\t\t\t\tif (!connection) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`No database connection found for connectionManagerId: ${connectionManagerId} after waiting for connection. This should not happen.`\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn RequestContext.create(connection.orm.em, _next, {});\n\t\t\t},\n\t\t};\n\t\tpluginManager.addPlugin(connectionPlugin);\n\t};\n\n\tprivate mapAndAssignKeys = (result: D, entityType: new () => D, inputArgs: Partial<D>) => {\n\t\t// Clean the input and remove any GraphQL classes from the object\n\t\tconst assignmentObj = this.applyExternalIdFields(entityType, inputArgs);\n\t\treturn assign(result, assignmentObj, undefined, undefined, this.database.em);\n\t};\n\n\tprivate applyExternalIdFields = (target: AnyEntity | string, values: any) => {\n\t\tconst targetName = typeof target === 'string' ? target : target.name;\n\t\tconst map = externalIdFieldMap.get(targetName);\n\n\t\tconst mapFieldNames = (partialFilterObj: any) => {\n\t\t\tfor (const [from, to] of Object.entries(map || {})) {\n\t\t\t\tif (partialFilterObj[from]) {\n\t\t\t\t\tconst keys = Object.keys(partialFilterObj[from]);\n\t\t\t\t\tif (keys.length > 1) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Expected precisely 1 key in queryObj.${from} on ${target}, got ${JSON.stringify(\n\t\t\t\t\t\t\t\tpartialFilterObj[from],\n\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t4\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\tpartialFilterObj[to] = partialFilterObj[from][keys[0]];\n\t\t\t\t\tdelete partialFilterObj[from];\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\t// Check for and/or/etc at the root level and handle correctly\n\t\tfor (const rootLevelKey of Object.keys(values)) {\n\t\t\tif (mikroObjectOperations.has(rootLevelKey)) {\n\t\t\t\tif (Array.isArray(values[rootLevelKey])) {\n\t\t\t\t\tfor (const field of values[rootLevelKey]) {\n\t\t\t\t\t\tmapFieldNames(field);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tmapFieldNames(values[rootLevelKey]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Map the rest of the field names as well\n\t\tmapFieldNames(values);\n\n\t\t// Traverse the nested entities\n\t\tconst { properties } = this.database.em.getMetadata().get(targetName);\n\t\tObject.values(properties)\n\t\t\t.filter((property) => typeof property.entity !== 'undefined' && values[property.name])\n\t\t\t.forEach((property) => {\n\t\t\t\tif (Array.isArray(values[property.name])) {\n\t\t\t\t\tvalues[property.name].forEach((value: any) =>\n\t\t\t\t\t\tthis.applyExternalIdFields(property.type, value)\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tvalues[property.name] = this.applyExternalIdFields(property.type, values[property.name]);\n\t\t\t\t}\n\t\t\t});\n\n\t\treturn values;\n\t};\n\n\t// Check if we have any keys that are a collection of entities\n\tpublic visitPathForPopulate = (entityName: string, updateArgBranch: any, populateBranch = '') => {\n\t\tconst { properties } = this.database.em.getMetadata().get(entityName);\n\t\tconst collectedPaths = populateBranch ? new Set<string>([populateBranch]) : new Set<string>([]);\n\n\t\tfor (const [key, value] of Object.entries(updateArgBranch ?? {})) {\n\t\t\tif (\n\t\t\t\t// If it's a relationship, go ahead and and '.' it in, recurse.\n\t\t\t\tproperties[key]?.kind === ReferenceKind.ONE_TO_ONE ||\n\t\t\t\tproperties[key]?.kind === ReferenceKind.ONE_TO_MANY ||\n\t\t\t\tproperties[key]?.kind === ReferenceKind.MANY_TO_ONE ||\n\t\t\t\tproperties[key]?.kind === ReferenceKind.MANY_TO_MANY\n\t\t\t) {\n\t\t\t\tif (Array.isArray(value)) {\n\t\t\t\t\t// In the case where the array is empty we also need to make sure we load the collection.\n\t\t\t\t\tcollectedPaths.add(appendPath(populateBranch, key));\n\n\t\t\t\t\tfor (const entry of value) {\n\t\t\t\t\t\t// Recurse\n\t\t\t\t\t\tconst newPaths = this.visitPathForPopulate(\n\t\t\t\t\t\t\tproperties[key].type,\n\t\t\t\t\t\t\tentry,\n\t\t\t\t\t\t\tappendPath(populateBranch, key)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tnewPaths.forEach((path) => collectedPaths.add(path));\n\t\t\t\t\t}\n\t\t\t\t} else if (typeof value === 'object') {\n\t\t\t\t\t// Recurse\n\t\t\t\t\tconst newPaths = this.visitPathForPopulate(\n\t\t\t\t\t\tproperties[key].type,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tappendPath(populateBranch, key)\n\t\t\t\t\t);\n\t\t\t\t\tnewPaths.forEach((path) => collectedPaths.add(path));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn collectedPaths;\n\t};\n\n\t@TraceMethod()\n\tpublic async find(\n\t\tfilter: Filter<D>,\n\t\tpagination?: PaginationOptions,\n\t\tentityMetadata?: EntityMetadata,\n\t\ttrace?: TraceOptions\n\t): Promise<D[]> {\n\t\t// If we have a span, update the name\n\t\ttrace?.span.updateName(`Mikro-Orm - Find ${this.entityType.name}`);\n\n\t\tlogger.trace(\n\t\t\t{ filter: sanitiseFilterForLogging(filter), entity: this.entityType.name },\n\t\t\t'Running find with filter'\n\t\t);\n\n\t\t// Strip custom types out of the equation.\n\t\t// This query only works if we JSON.parse(JSON.stringify(filter)):\n\t\tconst where = traceSync((trace?: TraceOptions) => {\n\t\t\ttrace?.span.updateName('Convert filter to Mikro-Orm format');\n\t\t\treturn filter ? gqlToMikro(JSON.parse(JSON.stringify(filter)), this.getDbType()) : undefined;\n\t\t})();\n\n\t\t// Convert from: { account: {id: '6' }}\n\t\t// to { accountId: '6' }\n\t\t// This conversion only works on root level objects\n\t\tconst whereWithAppliedExternalIdFields = where\n\t\t\t? this.applyExternalIdFields(this.entityType, where)\n\t\t\t: {};\n\n\t\t// Regions need some fancy handling with Query Builder. Process the where further\n\t\t// and return a Query Builder instance.\n\t\tconst query = this.em.createQueryBuilder(this.entityType);\n\t\tif (Object.keys(whereWithAppliedExternalIdFields).length > 0) {\n\t\t\tquery.andWhere(whereWithAppliedExternalIdFields);\n\t\t}\n\n\t\t// If we have specified a limit, offset or order then update the query\n\t\tif (pagination?.limit) query.limit(pagination.limit);\n\t\tif (pagination?.offset) query.offset(pagination.offset);\n\t\tif (pagination?.orderBy) query.orderBy({ ...pagination.orderBy });\n\n\t\t// Certain query filters can result in duplicate records once all joins are resolved\n\t\t// These duplicates can be discarded as related entities are returned to the\n\t\t// API consumer via field resolvers\n\t\tquery.setFlag(QueryFlag.DISTINCT);\n\n\t\t// 1:1 relations that aren't on the owning side need to get populated so the references get set.\n\t\t// This method is protected, but we need to use it from here, hence the `as any`.\n\t\tconst driver = this.database.em.getDriver();\n\t\tconst meta = this.database.em.getMetadata().get(this.entityType.name);\n\t\tquery.populate((driver as any).autoJoinOneToOneOwner(meta, []));\n\n\t\ttry {\n\t\t\tconst result = await startTrace(async (trace?: TraceOptions) => {\n\t\t\t\ttrace?.span.updateName('Mikro-Orm - Fetch Data');\n\t\t\t\treturn query.getResult();\n\t\t\t})();\n\n\t\t\tlogger.trace(`find ${this.entityType.name} result: ${result.length} rows`);\n\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tsafeErrorLog(logger, err, `find ${this.entityType.name} error`);\n\n\t\t\tif ((err as PostgresError)?.routine === 'InitializeSessionUserId') {\n\t\t\t\t// Throw if the user credentials are incorrect\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Database connection failed, please check you are using the correct user credentials for the database.'\n\t\t\t\t);\n\t\t\t} else if ((err as PostgresError)?.code === 'ECONNREFUSED') {\n\t\t\t\t// Throw if the database address or port is incorrect\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Database connection failed, please check you are using the correct address and port for the database.'\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t}\n\t}\n\n\t@TraceMethod()\n\tpublic async findOne(\n\t\tfilter: Filter<D>,\n\t\tentityMetadata?: EntityMetadata,\n\t\ttrace?: TraceOptions\n\t): Promise<D | null> {\n\t\ttrace?.span.updateName(`Mikro-Orm - FindOne ${this.entityType.name}`);\n\t\tlogger.trace(\n\t\t\t{ entity: this.entityType.name, filter: sanitiseFilterForLogging(filter) },\n\t\t\t'Running findOne with filter'\n\t\t);\n\n\t\tconst metadata = this.em.getMetadata().get(this.entityType.name);\n\t\tlet primaryKeyField = metadata.primaryKeys[0];\n\n\t\tif (!primaryKeyField && entityMetadata) {\n\t\t\t// When using virtual entities, MikroORM will have no primary keys.\n\t\t\t// In this scenario we actually know what the primary key is from\n\t\t\t// the GraphQL metadata, so we can go ahead and use it.\n\t\t\tprimaryKeyField = graphweaverMetadata.primaryKeyFieldForEntity(entityMetadata);\n\t\t}\n\n\t\tif (!primaryKeyField || metadata.primaryKeys.length > 1) {\n\t\t\tthrow new Error(\n\t\t\t\t`Entity ${this.entityType.name} has ${metadata.primaryKeys.length} primary keys. We only support entities with a single primary key at this stage.`\n\t\t\t);\n\t\t}\n\n\t\tconst [result] = await this.find(filter, {\n\t\t\torderBy: { [primaryKeyField]: Sort.DESC },\n\t\t\toffset: 0,\n\t\t\tlimit: 1,\n\t\t});\n\n\t\tlogger.trace({ result, entity: this.entityType.name }, 'findOne result');\n\n\t\treturn result;\n\t}\n\n\t@TraceMethod()\n\tpublic async findByRelatedId(\n\t\tentity: any,\n\t\trelatedField: string,\n\t\trelatedFieldIds: string[],\n\t\tfilter?: any,\n\t\ttrace?: TraceOptions\n\t): Promise<D[]> {\n\t\ttrace?.span.updateName(`Mikro-Orm - findByRelatedId ${this.entityType.name}`);\n\t\tlogger.trace(\n\t\t\t{\n\t\t\t\tentity: this.entityType.name,\n\t\t\t\trelatedField,\n\t\t\t\trelatedFieldIds,\n\t\t\t\tfilter: sanitiseFilterForLogging(filter),\n\t\t\t},\n\t\t\t'Running findByRelatedId'\n\t\t);\n\n\t\t// Any is the actual type from MikroORM, sorry folks.\n\t\tlet queryFilter: any = { [relatedField]: { $in: relatedFieldIds } };\n\n\t\tif (filter) {\n\t\t\t// JSON.parse(JSON.stringify()) is needed. See https://exogee.atlassian.net/browse/EXOGW-419\n\t\t\tconst gqlToMikroFilter = JSON.parse(JSON.stringify([gqlToMikro(filter, this.getDbType())]));\n\t\t\t// Since the user has supplied a filter, we need to and it in.\n\t\t\tqueryFilter = { $and: [queryFilter, ...gqlToMikroFilter] };\n\t\t}\n\n\t\tconst populate = [relatedField as AutoPath<typeof entity, PopulateHint>];\n\t\tconst result = await this.database.em.find(entity, queryFilter, {\n\t\t\t// We only need one result per entity.\n\t\t\tflags: [QueryFlag.DISTINCT],\n\n\t\t\t// We do want to populate the relation, however, see below.\n\t\t\tpopulate,\n\n\t\t\t// We'd love to use the default joined loading strategy, but it doesn't work with the populateWhere option.\n\t\t\tstrategy: LoadStrategy.SELECT_IN,\n\n\t\t\t// This tells MikroORM we only need to load the related entities if they match the filter specified above.\n\t\t\tpopulateWhere: PopulateHint.INFER,\n\t\t});\n\n\t\treturn result as D[];\n\t}\n\n\t@TraceMethod()\n\tpublic async updateOne(\n\t\tid: string | number,\n\t\tupdateArgs: Partial<D & { version?: number }>,\n\t\ttrace?: TraceOptions\n\t): Promise<D> {\n\t\ttrace?.span.updateName(`Mikro-Orm - updateOne ${this.entityType.name}`);\n\n\t\tlogger.trace(\n\t\t\t{\n\t\t\t\tid,\n\t\t\t\tupdateArgs: sanitiseFilterForLogging(updateArgs),\n\t\t\t\tentity: this.entityType.name,\n\t\t\t},\n\t\t\t'Running update with args'\n\t\t);\n\n\t\tconst entity = await this.database.em.findOne(this.entityType, id, {\n\t\t\t// This is an optimisation so that assign() doesn't have to go fetch everything one at a time.\n\t\t\tpopulate: [...this.visitPathForPopulate(this.entityType.name, updateArgs)] as `${string}.`[],\n\t\t});\n\n\t\tif (entity === null) {\n\t\t\tthrow new Error(`Unable to locate ${this.entityType.name} with ID: '${id}' for updating.`);\n\t\t}\n\n\t\tconst { version, ...updateArgsWithoutVersion } = updateArgs;\n\n\t\t// If a version has been sent, let's check it\n\t\tif (version) {\n\t\t\ttry {\n\t\t\t\tawait this.database.em.lock(entity, LockMode.OPTIMISTIC, version);\n\t\t\t} catch (err) {\n\t\t\t\tthrow new OptimisticLockError((err as Error)?.message, { entity });\n\t\t\t}\n\t\t}\n\n\t\t// For an update we also want to go ahead and remove the primary key if it's autoincremented, as\n\t\t// users should not be able to change the primary key. There are also scenarios like\n\t\t// GENERATED ALWAYS AS IDENTITY where even supplying the primary key in the update query will\n\t\t// cause an error.\n\t\tconst meta = this.database.em.getMetadata().get(this.entityType.name);\n\t\tfor (const key of meta.primaryKeys) {\n\t\t\tif (meta.properties[key].autoincrement) delete (updateArgsWithoutVersion as any)[key];\n\t\t}\n\n\t\tawait this.mapAndAssignKeys(entity, this.entityType, updateArgsWithoutVersion as Partial<D>);\n\t\tawait this.database.em.persistAndFlush(entity);\n\n\t\tlogger.trace(`update ${this.entityType.name} entity`, entity);\n\n\t\treturn entity;\n\t}\n\n\t@TraceMethod()\n\tpublic async updateMany(\n\t\tupdateItems: (Partial<D> & { id: string })[],\n\t\ttrace?: TraceOptions\n\t): Promise<D[]> {\n\t\ttrace?.span.updateName(`Mikro-Orm - updateMany ${this.entityType.name}`);\n\t\tlogger.trace(\n\t\t\t{ updateItems: sanitiseFilterForLogging(updateItems), entity: this.entityType.name },\n\t\t\t'Running update many with args'\n\t\t);\n\n\t\tconst meta = this.database.em.getMetadata().get(this.entityType.name);\n\n\t\tconst entities = await this.database.transactional<D[]>(async () => {\n\t\t\treturn Promise.all<D>(\n\t\t\t\tupdateItems.map(async (item) => {\n\t\t\t\t\tif (!item?.id) throw new Error('You must pass an ID for this entity to update it.');\n\n\t\t\t\t\t// Find the entity in the database\n\t\t\t\t\tconst entity = await this.database.em.findOneOrFail(this.entityType, item.id, {\n\t\t\t\t\t\tpopulate: [...this.visitPathForPopulate(this.entityType.name, item)] as `${string}.`[],\n\t\t\t\t\t});\n\n\t\t\t\t\t// For an update we also want to go ahead and remove the primary key if it's autoincremented, as\n\t\t\t\t\t// users should not be able to change the primary key. There are also scenarios like\n\t\t\t\t\t// GENERATED ALWAYS AS IDENTITY where even supplying the primary key in the update query will\n\t\t\t\t\t// cause an error.\n\t\t\t\t\tfor (const key of meta.primaryKeys) {\n\t\t\t\t\t\tif (meta.properties[key].autoincrement) delete (item as any)[key];\n\t\t\t\t\t}\n\n\t\t\t\t\tawait this.mapAndAssignKeys(entity, this.entityType, item);\n\t\t\t\t\tthis.database.em.persist(entity);\n\t\t\t\t\treturn entity;\n\t\t\t\t})\n\t\t\t);\n\t\t});\n\n\t\tlogger.trace({ entity: this.entityType.name, entities }, 'updated items');\n\n\t\treturn entities;\n\t}\n\n\t@TraceMethod()\n\tpublic async createOrUpdateMany(items: Partial<D>[], trace?: TraceOptions): Promise<D[]> {\n\t\ttrace?.span.updateName(`Mikro-Orm - createOrUpdateMany ${this.entityType.name}`);\n\t\tlogger.trace(\n\t\t\t{ items: sanitiseFilterForLogging(items), entity: this.entityType.name },\n\t\t\t'Running create or update many with args'\n\t\t);\n\n\t\tconst entities = await this.database.transactional<D[]>(async () => {\n\t\t\treturn Promise.all<D>(\n\t\t\t\titems.map(async (item) => {\n\t\t\t\t\tlet entity;\n\t\t\t\t\tconst { id } = item as any;\n\t\t\t\t\tif (id) {\n\t\t\t\t\t\tentity = await this.database.em.findOneOrFail(this.entityType, id, {\n\t\t\t\t\t\t\tpopulate: [\n\t\t\t\t\t\t\t\t...this.visitPathForPopulate(this.entityType.name, item),\n\t\t\t\t\t\t\t] as `${string}.`[],\n\t\t\t\t\t\t});\n\t\t\t\t\t\tlogger.trace({ item, entity: this.entityType.name }, 'Running update with item');\n\t\t\t\t\t\tawait this.mapAndAssignKeys(entity, this.entityType, item);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tentity = new this.entityType();\n\t\t\t\t\t\tawait this.mapAndAssignKeys(entity, this.entityType, item);\n\t\t\t\t\t\tlogger.trace({ item, entity: this.entityType.name }, 'Running create with item');\n\t\t\t\t\t}\n\t\t\t\t\tthis.database.em.persist(entity);\n\t\t\t\t\treturn entity;\n\t\t\t\t})\n\t\t\t);\n\t\t});\n\n\t\tlogger.trace(\n\t\t\t{ entity: this.entityType.name, entities: sanitiseFilterForLogging(entities) },\n\t\t\t'created or updated items'\n\t\t);\n\n\t\treturn entities;\n\t}\n\n\t@TraceMethod()\n\tpublic async createOne(createArgs: Partial<D>, trace?: TraceOptions): Promise<D> {\n\t\ttrace?.span.updateName(`Mikro-Orm - createOne ${this.entityType.name}`);\n\t\tlogger.trace(\n\t\t\t{ createArgs: sanitiseFilterForLogging(createArgs), entity: this.entityType.name },\n\t\t\t'Running create with args'\n\t\t);\n\n\t\tconst entity = new this.entityType();\n\t\tawait this.mapAndAssignKeys(entity, this.entityType, createArgs);\n\t\tawait this.database.em.persistAndFlush(entity as Partial<D>);\n\n\t\tlogger.trace(\n\t\t\t{ entity: this.entityType.name, result: sanitiseFilterForLogging(entity) },\n\t\t\t'create result'\n\t\t);\n\n\t\treturn entity;\n\t}\n\n\t@TraceMethod()\n\tpublic async createMany(createItems: Partial<D>[], trace?: TraceOptions): Promise<D[]> {\n\t\ttrace?.span.updateName(`Mikro-Orm - createMany ${this.entityType.name}`);\n\t\treturn this._createMany(createItems);\n\t}\n\n\tpublic async createTraces(createItems: Partial<D>[]): Promise<D[]> {\n\t\treturn this._createMany(createItems);\n\t}\n\n\tprivate async _createMany(createItems: Partial<D>[]) {\n\t\tlogger.trace(\n\t\t\t{ createItems: sanitiseFilterForLogging(createItems), entity: this.entityType.name },\n\t\t\t'Running create with args'\n\t\t);\n\n\t\tconst entities = await this.database.transactional<D[]>(async () => {\n\t\t\treturn Promise.all<D>(\n\t\t\t\tcreateItems.map(async (item) => {\n\t\t\t\t\tconst entity = new this.entityType();\n\t\t\t\t\tawait this.mapAndAssignKeys(entity, this.entityType, item);\n\t\t\t\t\tthis.database.em.persist(entity as Partial<D>);\n\t\t\t\t\treturn entity;\n\t\t\t\t})\n\t\t\t);\n\t\t});\n\n\t\tlogger.trace({ entity: this.entityType.name, entities }, 'created items');\n\n\t\treturn entities;\n\t}\n\n\t@TraceMethod()\n\tpublic async deleteOne(filter: Filter<D>, trace?: TraceOptions): Promise<boolean> {\n\t\ttrace?.span.updateName(`Mikro-Orm - deleteOne ${this.entityType.name}`);\n\t\tlogger.trace(\n\t\t\t{ filter: sanitiseFilterForLogging(filter), entity: this.entityType.name },\n\t\t\t'Running delete with filter.'\n\t\t);\n\t\tconst where = filter\n\t\t\t? gqlToMikro(JSON.parse(JSON.stringify(filter)), this.getDbType())\n\t\t\t: undefined;\n\t\tconst whereWithAppliedExternalIdFields =\n\t\t\twhere && this.applyExternalIdFields(this.entityType, where);\n\n\t\tconst deletedRows = await this.database.em.nativeDelete(\n\t\t\tthis.entityType,\n\t\t\twhereWithAppliedExternalIdFields\n\t\t);\n\n\t\tif (deletedRows > 1) {\n\t\t\tthrow new Error('Multiple deleted rows');\n\t\t}\n\n\t\tlogger.trace(`delete ${this.entityType.name} result: deleted ${deletedRows} row(s)`);\n\n\t\treturn deletedRows === 1;\n\t}\n\n\t@TraceMethod()\n\tpublic async deleteMany(filter: Filter<D>, trace?: TraceOptions): Promise<boolean> {\n\t\ttrace?.span.updateName(`Mikro-Orm - deleteMany ${this.entityType.name}`);\n\t\tlogger.trace(\n\t\t\t{ filter: sanitiseFilterForLogging(filter), entity: this.entityType.name },\n\t\t\t'Running delete'\n\t\t);\n\n\t\tconst deletedRows = await this.database.transactional<number>(async () => {\n\t\t\tconst where = filter\n\t\t\t\t? gqlToMikro(JSON.parse(JSON.stringify(filter)), this.getDbType())\n\t\t\t\t: undefined;\n\t\t\tconst whereWithAppliedExternalIdFields =\n\t\t\t\twhere && this.applyExternalIdFields(this.entityType, where);\n\n\t\t\tconst toDelete = await this.database.em.count(\n\t\t\t\tthis.entityType,\n\t\t\t\twhereWithAppliedExternalIdFields\n\t\t\t);\n\t\t\tconst deletedCount = await this.database.em.nativeDelete(\n\t\t\t\tthis.entityType,\n\t\t\t\twhereWithAppliedExternalIdFields\n\t\t\t);\n\n\t\t\tif (deletedCount !== toDelete) {\n\t\t\t\tthrow new Error('We did not delete any rows, rolling back.');\n\t\t\t}\n\n\t\t\treturn deletedCount;\n\t\t});\n\n\t\tlogger.trace(`delete ${this.entityType.name} result: deleted ${deletedRows} row(s)`);\n\n\t\treturn true;\n\t}\n\n\tpublic foreignKeyForRelationshipField?(field: FieldMetadata, dataEntity: D) {\n\t\tconst value = dataEntity[field.name as keyof D];\n\n\t\tif (Reference.isReference(value)) {\n\t\t\tconst { properties } = this.database.em.getMetadata().get(this.entityType);\n\t\t\tconst property = properties[field.name];\n\t\t\tconst [primaryKey] = property.targetMeta?.primaryKeys ?? [];\n\t\t\tif (!primaryKey) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Could not determine primary key for ${field.name} on ${this.entityType.name}`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst foreignKey = (value.unwrap() as any)[primaryKey];\n\t\t\tif (foreignKey === undefined || foreignKey === null) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Could not read foreign key from reference: ${value.unwrap()} with primary key name ${primaryKey}`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn foreignKey;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t@TraceMethod()\n\tpublic async aggregate(\n\t\tfilter: Filter<D>,\n\t\trequestedAggregations: Set<AggregationType>,\n\t\ttrace?: TraceOptions\n\t): Promise<AggregationResult> {\n\t\ttrace?.span.updateName(`Mikro-Orm - aggregate ${this.entityType.name}`);\n\t\tlogger.trace(\n\t\t\t{ filter: sanitiseFilterForLogging(filter), entity: this.entityType.name },\n\t\t\t'Running aggregate with filter'\n\t\t);\n\n\t\t// Strip custom types out of the equation.\n\t\t// This query only works if we JSON.parse(JSON.stringify(filter)):\n\t\t//\n\t\t// query {\n\t\t// drivers (filter: { region: { name: \"North Shore\" }}) {\n\t\t// id\n\t\t// }\n\t\t// }\n\t\tconst where = filter\n\t\t\t? gqlToMikro(JSON.parse(JSON.stringify(filter)), this.getDbType())\n\t\t\t: undefined;\n\n\t\t// Convert from: { account: {id: '6' }}\n\t\t// to { accountId: '6' }\n\t\t// This conversion only works on root level objects\n\t\tconst whereWithAppliedExternalIdFields = where\n\t\t\t? this.applyExternalIdFields(this.entityType, where)\n\t\t\t: {};\n\n\t\t// Regions need some fancy handling with Query Builder. Process the where further\n\t\t// and return a Query Builder instance.\n\t\tconst query = this.em.createQueryBuilder(this.entityType);\n\n\t\tif (Object.keys(whereWithAppliedExternalIdFields).length > 0) {\n\t\t\tquery.andWhere(whereWithAppliedExternalIdFields);\n\t\t}\n\n\t\tconst result: AggregationResult = {};\n\n\t\ttry {\n\t\t\tif (requestedAggregations.has(AggregationType.COUNT)) {\n\t\t\t\tconst meta = this.database.em.getMetadata().get(this.entityType.name);\n\t\t\t\tif (meta.primaryKeys.length) {\n\t\t\t\t\t// It's a standard entity with primary keys, we can do a full distinct\n\t\t\t\t\t// on these keys.\n\t\t\t\t\tresult.count = await query.getCount(meta.primaryKeys, true);\n\t\t\t\t} else {\n\t\t\t\t\t// It's either a virtual entity, or it's an entity without primary keys.\n\t\t\t\t\t// We just need to count * as a fallback, no distinct.\n\t\t\t\t\tconst [firstRow] = await query.select(sql`count(*)`.as('count')).execute();\n\t\t\t\t\tresult.count = firstRow.count;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tsafeErrorLog(logger, err, `find ${this.entityType.name} error`);\n\n\t\t\tif ((err as PostgresError)?.routine === 'InitializeSessionUserId') {\n\t\t\t\t// Throw if the user credentials are incorrect\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Database connection failed, please check you are using the correct user credentials for the database.'\n\t\t\t\t);\n\t\t\t} else if ((err as PostgresError)?.code === 'ECONNREFUSED') {\n\t\t\t\t// Throw if the database address or port is incorrect\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Database connection failed, please check you are using the correct address and port for the database.'\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAUO;AAUP,oBAAqC;AACrC,kBAOO;AACP,gCAAmD;AAEnD,eAWO;AAEP,mBAA8D;AAC9D,oBAAuB;AAOvB,MAAM,mBAAmB,oBAAI,IAAI,CAAC,QAAQ,OAAO,MAAM,CAAC;AACxD,MAAM,wBAAwB,oBAAI,IAAI,CAAC,QAAQ,OAAO,MAAM,CAAC;AAC7D,MAAM,wBAAwB,oBAAI,IAAI,CAAC,QAAQ,SAAS,CAAC;AAEzD,MAAM,aAAa,CAAC,MAAc,YACjC,KAAK,SAAS,GAAG,IAAI,IAAI,OAAO,KAAK;AAE/B,MAAM,aAAa,CAAC,QAAa,iBAAqC;AAC5E,MAAI,MAAM,QAAQ,MAAM,GAAG;AAC1B,WAAO,OAAO,IAAI,CAAC,YAAY,WAAW,SAAS,YAAY,CAAC;AAAA,EACjE,WAAW,OAAO,WAAW,YAAY,WAAW,MAAM;AACzD,eAAW,OAAO,OAAO,KAAK,MAAM,GAAG;AAEtC,UAAI,OAAO,GAAG,MAAM,KAAM;AAE1B,UAAI,iBAAiB,IAAI,GAAG,GAAG;AAE9B,eAAO,IAAI,QAAQ,KAAK,GAAG,CAAC,IAAI,WAAW,OAAO,GAAG,GAAG,YAAY;AACpE,eAAO,OAAO,GAAG;AAAA,MAClB,WAAW,OAAO,OAAO,GAAG,MAAM,YAAY,CAAC,MAAM,QAAQ,OAAO,GAAG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BD,qBA4qBC;",
4
+ "sourcesContent": ["import {\n\tAggregationType,\n\tBackendProvider,\n\tgraphweaverMetadata,\n\tGraphweaverPluginNextFunction,\n\tGraphweaverRequestEvent,\n\tSort,\n\ttrace as startTrace,\n\tTraceMethod,\n\ttraceSync,\n} from '@exogee/graphweaver';\nimport type {\n\tAggregationResult,\n\tBackendProviderConfig,\n\tEntityMetadata,\n\tFieldMetadata,\n\tFilter,\n\tPaginationOptions,\n\tTraceOptions,\n} from '@exogee/graphweaver';\nimport { logger, safeErrorLog } from '@exogee/logger';\nimport {\n\tAutoPath,\n\tLoadStrategy,\n\tPopulateHint,\n\tReference,\n\tRequestContext,\n\tsql,\n} from '@mikro-orm/core';\nimport { pluginManager, apolloPluginManager } from '@exogee/graphweaver-server';\n\nimport {\n\tLockMode,\n\tQueryFlag,\n\tReferenceKind,\n\tConnectionManager,\n\texternalIdFieldMap,\n\tAnyEntity,\n\tIsolationLevel,\n\tConnectionOptions,\n\tconnectToDatabase,\n\tDatabaseType,\n} from '..';\n\nimport { OptimisticLockError, sanitiseFilterForLogging } from '../utils';\nimport { assign } from './assign';\n\ntype PostgresError = {\n\tcode: string;\n\troutine: string;\n};\n\nconst objectOperations = new Set(['_and', '_or', '_not']);\nconst mikroObjectOperations = new Set(['$and', '$or', '$not']);\nconst nullBooleanOperations = new Set(['null', 'notnull']);\n\nconst appendPath = (path: string, newPath: string) =>\n\tpath.length ? `${path}.${newPath}` : newPath;\n\nexport const gqlToMikro = (filter: any, databaseType?: DatabaseType): any => {\n\tif (Array.isArray(filter)) {\n\t\treturn filter.map((element) => gqlToMikro(element, databaseType));\n\t} else if (typeof filter === 'object' && filter !== null) {\n\t\tfor (const key of Object.keys(filter)) {\n\t\t\t// A null here is a user-specified value and is valid to filter on\n\t\t\tif (filter[key] === null) continue;\n\n\t\t\tif (objectOperations.has(key)) {\n\t\t\t\t// { _not: '1' } => { $not: '1' }\n\t\t\t\tfilter[key.replace('_', '$')] = gqlToMikro(filter[key], databaseType);\n\t\t\t\tdelete filter[key];\n\t\t\t} else if (typeof filter[key] === 'object' && !Array.isArray(filter[key])) {\n\t\t\t\t// Recurse over nested filters only (arrays are an argument to a filter, not a nested filter)\n\t\t\t\tfilter[key] = gqlToMikro(filter[key], databaseType);\n\t\t\t} else if (key.indexOf('_') >= 0) {\n\t\t\t\tconst [newKey, operator] = key.split('_');\n\t\t\t\tlet newValue;\n\t\t\t\tif (nullBooleanOperations.has(operator) && typeof filter[key] === 'boolean') {\n\t\t\t\t\t// { firstName_null: true } => { firstName: { $eq: null } } or { firstName_null: false } => { firstName: { $ne: null } }\n\t\t\t\t\t// { firstName_notnull: true } => { firstName: { $ne: null } } or { firstName_notnull: false } => { firstName: { $eq: null } }\n\t\t\t\t\tnewValue =\n\t\t\t\t\t\t(filter[key] && operator === 'null') || (!filter[key] && operator === 'notnull')\n\t\t\t\t\t\t\t? { $eq: null }\n\t\t\t\t\t\t\t: { $ne: null };\n\t\t\t\t} else if (operator === 'ilike' && databaseType !== 'postgresql') {\n\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t`The $ilike operator is not supported by ${databaseType} databases. Operator coerced to $like.`\n\t\t\t\t\t);\n\t\t\t\t\tnewValue = { $like: filter[key] };\n\t\t\t\t} else {\n\t\t\t\t\t// { firstName_in: ['k', 'b'] } => { firstName: { $in: ['k', 'b'] } }\n\t\t\t\t\tnewValue = { [`$${operator}`]: gqlToMikro(filter[key], databaseType) };\n\t\t\t\t\t// They can construct multiple filters for the same key. In that case we need\n\t\t\t\t\t// to append them all into an object.\n\t\t\t\t}\n\n\t\t\t\tif (typeof filter[newKey] !== 'undefined') {\n\t\t\t\t\tif (typeof filter[newKey] !== 'object') {\n\t\t\t\t\t\tif (typeof newValue === 'object' && '$eq' in newValue) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`property ${newKey} on filter is ambiguous. There are two values for this property: ${filter[newKey]} and ${newValue.$eq}`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfilter[newKey] = { ...{ $eq: filter[newKey] }, ...newValue };\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (newValue && typeof newValue === 'object' && '$eq' in newValue) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`property ${newKey} on filter is ambiguous. There are two values for this property: ${JSON.stringify(\n\t\t\t\t\t\t\t\t\tfilter[newKey]\n\t\t\t\t\t\t\t\t)} and ${JSON.stringify(newValue)}`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfilter[newKey] = { ...filter[newKey], ...newValue };\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfilter[newKey] = newValue;\n\t\t\t\t}\n\n\t\t\t\tdelete filter[key];\n\t\t\t}\n\t\t}\n\t}\n\treturn filter;\n};\n\nexport interface AdditionalOptions {\n\ttransactionIsolationLevel?: IsolationLevel;\n\tbackendDisplayName?: string;\n}\n\nexport class MikroBackendProvider<D> implements BackendProvider<D> {\n\tprivate _backendId: string;\n\n\tprivate connection: ConnectionOptions;\n\n\tpublic entityType: new () => D;\n\tpublic connectionManagerId?: string;\n\tprivate transactionIsolationLevel!: IsolationLevel;\n\n\t// This is an optional setting that allows you to control how this provider is displayed in the Admin UI.\n\t// If you do not set a value, it will default to 'REST (hostname of baseUrl)'. Entities are grouped by\n\t// their backend's display name, so if you want to group them in a more specific way, this is the way to do it.\n\tpublic readonly backendDisplayName?: string;\n\n\tpublic readonly supportsInFilter = true;\n\n\t// Default backend provider config\n\tpublic readonly backendProviderConfig: BackendProviderConfig = {\n\t\tfilter: true,\n\t\tpagination: false,\n\t\torderBy: false,\n\t\tsupportedAggregationTypes: new Set<AggregationType>([AggregationType.COUNT]),\n\t\tsupportsPseudoCursorPagination: true,\n\t};\n\n\tget backendId() {\n\t\treturn this._backendId;\n\t}\n\n\tprivate get database() {\n\t\t// If we have a connection manager ID then use that else fallback to the Database\n\t\tif (!this.connectionManagerId) return ConnectionManager.default;\n\t\treturn ConnectionManager.database(this.connectionManagerId) || ConnectionManager.default;\n\t}\n\n\t// This is exposed for use in the RLS package\n\tpublic get transactional() {\n\t\treturn this.database.transactional;\n\t}\n\n\tpublic async withTransaction<T>(callback: () => Promise<T>) {\n\t\treturn this.database.transactional<T>(callback, this.transactionIsolationLevel);\n\t}\n\n\t// This is exposed for use in the RLS package\n\tpublic get em() {\n\t\treturn this.database.em;\n\t}\n\n\tpublic constructor(\n\t\tmikroType: new () => D,\n\t\tconnection: ConnectionOptions,\n\t\ttransactionIsolationLevel?: IsolationLevel\n\t);\n\tpublic constructor(\n\t\tmikroType: new () => D,\n\t\tconnection: ConnectionOptions,\n\t\tadditionalOptions?: AdditionalOptions\n\t);\n\tpublic constructor(\n\t\tmikroType: new () => D,\n\t\tconnection: ConnectionOptions,\n\t\toptionsOrIsolationLevel: AdditionalOptions | IsolationLevel = {\n\t\t\ttransactionIsolationLevel: IsolationLevel.REPEATABLE_READ,\n\t\t}\n\t) {\n\t\tconst options =\n\t\t\ttypeof optionsOrIsolationLevel === 'object'\n\t\t\t\t? optionsOrIsolationLevel\n\t\t\t\t: {\n\t\t\t\t\t\ttransactionIsolationLevel: optionsOrIsolationLevel,\n\t\t\t\t\t};\n\n\t\tthis.entityType = mikroType;\n\t\tthis.connectionManagerId = connection.connectionManagerId;\n\t\tthis._backendId = `mikro-orm-${connection.connectionManagerId || ''}`;\n\t\tthis.transactionIsolationLevel =\n\t\t\toptions.transactionIsolationLevel ?? IsolationLevel.REPEATABLE_READ;\n\t\tthis.backendDisplayName = options.backendDisplayName;\n\t\tthis.connection = connection;\n\t\tthis.addRequestContext();\n\t\tthis.connectToDatabase();\n\t}\n\tprivate getDbType(): DatabaseType {\n\t\tconst driver = this.em.getDriver().constructor.name;\n\t\t// This used to import the actual drivers, but since they're optional it makes more sense\n\t\t// to just use the strings. Using startsWith to handle ESBuild minification that may rename classes.\n\t\tif (driver.startsWith('MsSqlDriver')) return 'mssql';\n\t\tif (driver.startsWith('MySqlDriver')) return 'mysql';\n\t\tif (driver.startsWith('PostgreSqlDriver')) return 'postgresql';\n\t\tif (driver.startsWith('SqliteDriver')) return 'sqlite';\n\n\t\tthrow new Error(`This driver (${driver}) is not supported!`);\n\t}\n\n\tprivate connectToDatabase = async () => {\n\t\tconst connectionManagerId = this.connectionManagerId;\n\t\tif (!connectionManagerId) {\n\t\t\tthrow new Error('Expected connectionManagerId to be defined when calling addRequestContext.');\n\t\t}\n\n\t\tapolloPluginManager.addPlugin(connectionManagerId, connectToDatabase(this.connection));\n\t};\n\n\tprivate addRequestContext = () => {\n\t\tconst connectionManagerId = this.connectionManagerId;\n\t\tif (!connectionManagerId) {\n\t\t\tthrow new Error('Expected connectionManagerId to be defined when calling addRequestContext.');\n\t\t}\n\n\t\tconst connectionPlugin = {\n\t\t\tname: connectionManagerId,\n\t\t\tevent: GraphweaverRequestEvent.OnRequest,\n\t\t\tnext: async (_: GraphweaverRequestEvent, _next: GraphweaverPluginNextFunction) => {\n\t\t\t\tlogger.trace(`Graphweaver OnRequest plugin called`);\n\n\t\t\t\tconst connection = await ConnectionManager.awaitableDatabase(connectionManagerId);\n\n\t\t\t\tif (!connection) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`No database connection found for connectionManagerId: ${connectionManagerId} after waiting for connection. This should not happen.`\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn RequestContext.create(connection.orm.em, _next, {});\n\t\t\t},\n\t\t};\n\t\tpluginManager.addPlugin(connectionPlugin);\n\t};\n\n\tprivate mapAndAssignKeys = (result: D, entityType: new () => D, inputArgs: Partial<D>) => {\n\t\t// Clean the input and remove any GraphQL classes from the object\n\t\tconst assignmentObj = this.applyExternalIdFields(entityType, inputArgs);\n\t\treturn assign(result, assignmentObj, undefined, undefined, this.database.em);\n\t};\n\n\tprivate applyExternalIdFields = (target: AnyEntity | string, values: any) => {\n\t\tconst targetName = typeof target === 'string' ? target : target.name;\n\t\tconst map = externalIdFieldMap.get(targetName);\n\n\t\tconst mapFieldNames = (partialFilterObj: any) => {\n\t\t\tfor (const [from, to] of Object.entries(map || {})) {\n\t\t\t\tif (partialFilterObj[from]) {\n\t\t\t\t\tconst keys = Object.keys(partialFilterObj[from]);\n\t\t\t\t\tif (keys.length > 1) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Expected precisely 1 key in queryObj.${from} on ${target}, got ${JSON.stringify(\n\t\t\t\t\t\t\t\tpartialFilterObj[from],\n\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t4\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\tpartialFilterObj[to] = partialFilterObj[from][keys[0]];\n\t\t\t\t\tdelete partialFilterObj[from];\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\t// Check for and/or/etc at the root level and handle correctly\n\t\tfor (const rootLevelKey of Object.keys(values)) {\n\t\t\tif (mikroObjectOperations.has(rootLevelKey)) {\n\t\t\t\tif (Array.isArray(values[rootLevelKey])) {\n\t\t\t\t\tfor (const field of values[rootLevelKey]) {\n\t\t\t\t\t\tmapFieldNames(field);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tmapFieldNames(values[rootLevelKey]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Map the rest of the field names as well\n\t\tmapFieldNames(values);\n\n\t\t// Traverse the nested entities\n\t\tconst { properties } = this.database.em.getMetadata().get(targetName);\n\t\tObject.values(properties)\n\t\t\t.filter((property) => typeof property.entity !== 'undefined' && values[property.name])\n\t\t\t.forEach((property) => {\n\t\t\t\tif (Array.isArray(values[property.name])) {\n\t\t\t\t\tvalues[property.name].forEach((value: any) =>\n\t\t\t\t\t\tthis.applyExternalIdFields(property.type, value)\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tvalues[property.name] = this.applyExternalIdFields(property.type, values[property.name]);\n\t\t\t\t}\n\t\t\t});\n\n\t\treturn values;\n\t};\n\n\t// Check if we have any keys that are a collection of entities\n\tpublic visitPathForPopulate = (entityName: string, updateArgBranch: any, populateBranch = '') => {\n\t\tconst { properties } = this.database.em.getMetadata().get(entityName);\n\t\tconst collectedPaths = populateBranch ? new Set<string>([populateBranch]) : new Set<string>([]);\n\n\t\tfor (const [key, value] of Object.entries(updateArgBranch ?? {})) {\n\t\t\tif (\n\t\t\t\t// If it's a relationship, go ahead and and '.' it in, recurse.\n\t\t\t\tproperties[key]?.kind === ReferenceKind.ONE_TO_ONE ||\n\t\t\t\tproperties[key]?.kind === ReferenceKind.ONE_TO_MANY ||\n\t\t\t\tproperties[key]?.kind === ReferenceKind.MANY_TO_ONE ||\n\t\t\t\tproperties[key]?.kind === ReferenceKind.MANY_TO_MANY\n\t\t\t) {\n\t\t\t\tif (Array.isArray(value)) {\n\t\t\t\t\t// In the case where the array is empty we also need to make sure we load the collection.\n\t\t\t\t\tcollectedPaths.add(appendPath(populateBranch, key));\n\n\t\t\t\t\tfor (const entry of value) {\n\t\t\t\t\t\t// Recurse\n\t\t\t\t\t\tconst newPaths = this.visitPathForPopulate(\n\t\t\t\t\t\t\tproperties[key].type,\n\t\t\t\t\t\t\tentry,\n\t\t\t\t\t\t\tappendPath(populateBranch, key)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tnewPaths.forEach((path) => collectedPaths.add(path));\n\t\t\t\t\t}\n\t\t\t\t} else if (typeof value === 'object') {\n\t\t\t\t\t// Recurse\n\t\t\t\t\tconst newPaths = this.visitPathForPopulate(\n\t\t\t\t\t\tproperties[key].type,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tappendPath(populateBranch, key)\n\t\t\t\t\t);\n\t\t\t\t\tnewPaths.forEach((path) => collectedPaths.add(path));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn collectedPaths;\n\t};\n\n\t@TraceMethod()\n\tpublic async find(\n\t\tfilter: Filter<D>,\n\t\tpagination?: PaginationOptions,\n\t\tentityMetadata?: EntityMetadata,\n\t\ttrace?: TraceOptions\n\t): Promise<D[]> {\n\t\t// If we have a span, update the name\n\t\ttrace?.span.updateName(`Mikro-Orm - Find ${this.entityType.name}`);\n\n\t\tlogger.trace(\n\t\t\t{ filter: sanitiseFilterForLogging(filter), entity: this.entityType.name },\n\t\t\t'Running find with filter'\n\t\t);\n\n\t\t// Strip custom types out of the equation.\n\t\t// This query only works if we JSON.parse(JSON.stringify(filter)):\n\t\tconst where = traceSync((trace?: TraceOptions) => {\n\t\t\ttrace?.span.updateName('Convert filter to Mikro-Orm format');\n\t\t\treturn filter ? gqlToMikro(JSON.parse(JSON.stringify(filter)), this.getDbType()) : undefined;\n\t\t})();\n\n\t\t// Convert from: { account: {id: '6' }}\n\t\t// to { accountId: '6' }\n\t\t// This conversion only works on root level objects\n\t\tconst whereWithAppliedExternalIdFields = where\n\t\t\t? this.applyExternalIdFields(this.entityType, where)\n\t\t\t: {};\n\n\t\t// Regions need some fancy handling with Query Builder. Process the where further\n\t\t// and return a Query Builder instance.\n\t\tconst query = this.em.createQueryBuilder(this.entityType);\n\t\tif (Object.keys(whereWithAppliedExternalIdFields).length > 0) {\n\t\t\tquery.andWhere(whereWithAppliedExternalIdFields);\n\t\t}\n\n\t\t// If we have specified a limit, offset or order then update the query\n\t\tif (pagination?.limit) query.limit(pagination.limit);\n\t\tif (pagination?.offset) query.offset(pagination.offset);\n\t\tif (pagination?.orderBy) query.orderBy({ ...pagination.orderBy });\n\n\t\t// Certain query filters can result in duplicate records once all joins are resolved\n\t\t// These duplicates can be discarded as related entities are returned to the\n\t\t// API consumer via field resolvers\n\t\tquery.setFlag(QueryFlag.DISTINCT);\n\n\t\t// 1:1 relations that aren't on the owning side need to get populated so the references get set.\n\t\t// This method is protected, but we need to use it from here, hence the `as any`.\n\t\tconst driver = this.database.em.getDriver();\n\t\tconst meta = this.database.em.getMetadata().get(this.entityType.name);\n\t\tquery.populate((driver as any).autoJoinOneToOneOwner(meta, []));\n\n\t\ttry {\n\t\t\tconst result = await startTrace(async (trace?: TraceOptions) => {\n\t\t\t\ttrace?.span.updateName('Mikro-Orm - Fetch Data');\n\t\t\t\treturn query.getResult();\n\t\t\t})();\n\n\t\t\tlogger.trace(`find ${this.entityType.name} result: ${result.length} rows`);\n\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tsafeErrorLog(logger, err, `find ${this.entityType.name} error`);\n\n\t\t\tif ((err as PostgresError)?.routine === 'InitializeSessionUserId') {\n\t\t\t\t// Throw if the user credentials are incorrect\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Database connection failed, please check you are using the correct user credentials for the database.'\n\t\t\t\t);\n\t\t\t} else if ((err as PostgresError)?.code === 'ECONNREFUSED') {\n\t\t\t\t// Throw if the database address or port is incorrect\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Database connection failed, please check you are using the correct address and port for the database.'\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t}\n\t}\n\n\t@TraceMethod()\n\tpublic async findOne(\n\t\tfilter: Filter<D>,\n\t\tentityMetadata?: EntityMetadata,\n\t\ttrace?: TraceOptions\n\t): Promise<D | null> {\n\t\ttrace?.span.updateName(`Mikro-Orm - FindOne ${this.entityType.name}`);\n\t\tlogger.trace(\n\t\t\t{ entity: this.entityType.name, filter: sanitiseFilterForLogging(filter) },\n\t\t\t'Running findOne with filter'\n\t\t);\n\n\t\tconst metadata = this.em.getMetadata().get(this.entityType.name);\n\t\tlet primaryKeyField = metadata.primaryKeys[0];\n\n\t\tif (!primaryKeyField && entityMetadata) {\n\t\t\t// When using virtual entities, MikroORM will have no primary keys.\n\t\t\t// In this scenario we actually know what the primary key is from\n\t\t\t// the GraphQL metadata, so we can go ahead and use it.\n\t\t\tprimaryKeyField = graphweaverMetadata.primaryKeyFieldForEntity(entityMetadata);\n\t\t}\n\n\t\tif (!primaryKeyField || metadata.primaryKeys.length > 1) {\n\t\t\tthrow new Error(\n\t\t\t\t`Entity ${this.entityType.name} has ${metadata.primaryKeys.length} primary keys. We only support entities with a single primary key at this stage.`\n\t\t\t);\n\t\t}\n\n\t\tconst [result] = await this.find(filter, {\n\t\t\torderBy: { [primaryKeyField]: Sort.DESC },\n\t\t\toffset: 0,\n\t\t\tlimit: 1,\n\t\t});\n\n\t\tlogger.trace({ result, entity: this.entityType.name }, 'findOne result');\n\n\t\treturn result;\n\t}\n\n\t@TraceMethod()\n\tpublic async findByRelatedId(\n\t\tentity: any,\n\t\trelatedField: string,\n\t\trelatedFieldIds: string[],\n\t\tfilter?: any,\n\t\ttrace?: TraceOptions\n\t): Promise<D[]> {\n\t\ttrace?.span.updateName(`Mikro-Orm - findByRelatedId ${this.entityType.name}`);\n\t\tlogger.trace(\n\t\t\t{\n\t\t\t\tentity: this.entityType.name,\n\t\t\t\trelatedField,\n\t\t\t\trelatedFieldIds,\n\t\t\t\tfilter: sanitiseFilterForLogging(filter),\n\t\t\t},\n\t\t\t'Running findByRelatedId'\n\t\t);\n\n\t\t// Any is the actual type from MikroORM, sorry folks.\n\t\tlet queryFilter: any = { [relatedField]: { $in: relatedFieldIds } };\n\n\t\tif (filter) {\n\t\t\t// JSON.parse(JSON.stringify()) is needed. See https://exogee.atlassian.net/browse/EXOGW-419\n\t\t\tconst gqlToMikroFilter = JSON.parse(JSON.stringify([gqlToMikro(filter, this.getDbType())]));\n\t\t\t// Since the user has supplied a filter, we need to and it in.\n\t\t\tqueryFilter = { $and: [queryFilter, ...gqlToMikroFilter] };\n\t\t}\n\n\t\tconst populate = [relatedField as AutoPath<typeof entity, PopulateHint>];\n\t\tconst result = await this.database.em.find(entity, queryFilter, {\n\t\t\t// We only need one result per entity.\n\t\t\tflags: [QueryFlag.DISTINCT],\n\n\t\t\t// We do want to populate the relation, however, see below.\n\t\t\tpopulate,\n\n\t\t\t// We'd love to use the default joined loading strategy, but it doesn't work with the populateWhere option.\n\t\t\tstrategy: LoadStrategy.SELECT_IN,\n\n\t\t\t// This tells MikroORM we only need to load the related entities if they match the filter specified above.\n\t\t\tpopulateWhere: PopulateHint.INFER,\n\t\t});\n\n\t\treturn result as D[];\n\t}\n\n\t@TraceMethod()\n\tpublic async updateOne(\n\t\tid: string | number,\n\t\tupdateArgs: Partial<D & { version?: number }>,\n\t\ttrace?: TraceOptions\n\t): Promise<D> {\n\t\ttrace?.span.updateName(`Mikro-Orm - updateOne ${this.entityType.name}`);\n\n\t\tlogger.trace(\n\t\t\t{\n\t\t\t\tid,\n\t\t\t\tupdateArgs: sanitiseFilterForLogging(updateArgs),\n\t\t\t\tentity: this.entityType.name,\n\t\t\t},\n\t\t\t'Running update with args'\n\t\t);\n\n\t\tconst entity = await this.database.em.findOne(this.entityType, id, {\n\t\t\t// This is an optimisation so that assign() doesn't have to go fetch everything one at a time.\n\t\t\tpopulate: [...this.visitPathForPopulate(this.entityType.name, updateArgs)] as `${string}.`[],\n\t\t});\n\n\t\tif (entity === null) {\n\t\t\tthrow new Error(`Unable to locate ${this.entityType.name} with ID: '${id}' for updating.`);\n\t\t}\n\n\t\tconst { version, ...updateArgsWithoutVersion } = updateArgs;\n\n\t\t// If a version has been sent, let's check it\n\t\tif (version) {\n\t\t\ttry {\n\t\t\t\tawait this.database.em.lock(entity, LockMode.OPTIMISTIC, version);\n\t\t\t} catch (err) {\n\t\t\t\tthrow new OptimisticLockError((err as Error)?.message, { entity });\n\t\t\t}\n\t\t}\n\n\t\t// For an update we also want to go ahead and remove the primary key if it's autoincremented, as\n\t\t// users should not be able to change the primary key. There are also scenarios like\n\t\t// GENERATED ALWAYS AS IDENTITY where even supplying the primary key in the update query will\n\t\t// cause an error.\n\t\tconst meta = this.database.em.getMetadata().get(this.entityType.name);\n\t\tfor (const key of meta.primaryKeys) {\n\t\t\tif (meta.properties[key].autoincrement) delete (updateArgsWithoutVersion as any)[key];\n\t\t}\n\n\t\tawait this.mapAndAssignKeys(entity, this.entityType, updateArgsWithoutVersion as Partial<D>);\n\t\tawait this.database.em.persistAndFlush(entity);\n\n\t\tlogger.trace(`update ${this.entityType.name} entity`, entity);\n\n\t\treturn entity;\n\t}\n\n\t@TraceMethod()\n\tpublic async updateMany(\n\t\tupdateItems: (Partial<D> & { id: string })[],\n\t\ttrace?: TraceOptions\n\t): Promise<D[]> {\n\t\ttrace?.span.updateName(`Mikro-Orm - updateMany ${this.entityType.name}`);\n\t\tlogger.trace(\n\t\t\t{ updateItems: sanitiseFilterForLogging(updateItems), entity: this.entityType.name },\n\t\t\t'Running update many with args'\n\t\t);\n\n\t\tconst meta = this.database.em.getMetadata().get(this.entityType.name);\n\n\t\tconst entities = await this.database.transactional<D[]>(async () => {\n\t\t\treturn Promise.all<D>(\n\t\t\t\tupdateItems.map(async (item) => {\n\t\t\t\t\tif (!item?.id) throw new Error('You must pass an ID for this entity to update it.');\n\n\t\t\t\t\t// Find the entity in the database\n\t\t\t\t\tconst entity = await this.database.em.findOneOrFail(this.entityType, item.id, {\n\t\t\t\t\t\tpopulate: [...this.visitPathForPopulate(this.entityType.name, item)] as `${string}.`[],\n\t\t\t\t\t});\n\n\t\t\t\t\t// For an update we also want to go ahead and remove the primary key if it's autoincremented, as\n\t\t\t\t\t// users should not be able to change the primary key. There are also scenarios like\n\t\t\t\t\t// GENERATED ALWAYS AS IDENTITY where even supplying the primary key in the update query will\n\t\t\t\t\t// cause an error.\n\t\t\t\t\tfor (const key of meta.primaryKeys) {\n\t\t\t\t\t\tif (meta.properties[key].autoincrement) delete (item as any)[key];\n\t\t\t\t\t}\n\n\t\t\t\t\tawait this.mapAndAssignKeys(entity, this.entityType, item);\n\t\t\t\t\tthis.database.em.persist(entity);\n\t\t\t\t\treturn entity;\n\t\t\t\t})\n\t\t\t);\n\t\t});\n\n\t\tlogger.trace({ entity: this.entityType.name, entities }, 'updated items');\n\n\t\treturn entities;\n\t}\n\n\t@TraceMethod()\n\tpublic async createOrUpdateMany(items: Partial<D>[], trace?: TraceOptions): Promise<D[]> {\n\t\ttrace?.span.updateName(`Mikro-Orm - createOrUpdateMany ${this.entityType.name}`);\n\t\tlogger.trace(\n\t\t\t{ items: sanitiseFilterForLogging(items), entity: this.entityType.name },\n\t\t\t'Running create or update many with args'\n\t\t);\n\n\t\tconst entities = await this.database.transactional<D[]>(async () => {\n\t\t\treturn Promise.all<D>(\n\t\t\t\titems.map(async (item) => {\n\t\t\t\t\tlet entity;\n\t\t\t\t\tconst { id } = item as any;\n\t\t\t\t\tif (id) {\n\t\t\t\t\t\tentity = await this.database.em.findOneOrFail(this.entityType, id, {\n\t\t\t\t\t\t\tpopulate: [\n\t\t\t\t\t\t\t\t...this.visitPathForPopulate(this.entityType.name, item),\n\t\t\t\t\t\t\t] as `${string}.`[],\n\t\t\t\t\t\t});\n\t\t\t\t\t\tlogger.trace({ item, entity: this.entityType.name }, 'Running update with item');\n\t\t\t\t\t\tawait this.mapAndAssignKeys(entity, this.entityType, item);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tentity = new this.entityType();\n\t\t\t\t\t\tawait this.mapAndAssignKeys(entity, this.entityType, item);\n\t\t\t\t\t\tlogger.trace({ item, entity: this.entityType.name }, 'Running create with item');\n\t\t\t\t\t}\n\t\t\t\t\tthis.database.em.persist(entity);\n\t\t\t\t\treturn entity;\n\t\t\t\t})\n\t\t\t);\n\t\t});\n\n\t\tlogger.trace(\n\t\t\t{ entity: this.entityType.name, entities: sanitiseFilterForLogging(entities) },\n\t\t\t'created or updated items'\n\t\t);\n\n\t\treturn entities;\n\t}\n\n\t@TraceMethod()\n\tpublic async createOne(createArgs: Partial<D>, trace?: TraceOptions): Promise<D> {\n\t\ttrace?.span.updateName(`Mikro-Orm - createOne ${this.entityType.name}`);\n\t\tlogger.trace(\n\t\t\t{ createArgs: sanitiseFilterForLogging(createArgs), entity: this.entityType.name },\n\t\t\t'Running create with args'\n\t\t);\n\n\t\tconst entity = new this.entityType();\n\t\tawait this.mapAndAssignKeys(entity, this.entityType, createArgs);\n\t\tawait this.database.em.persistAndFlush(entity as Partial<D>);\n\n\t\tlogger.trace(\n\t\t\t{ entity: this.entityType.name, result: sanitiseFilterForLogging(entity) },\n\t\t\t'create result'\n\t\t);\n\n\t\treturn entity;\n\t}\n\n\t@TraceMethod()\n\tpublic async createMany(createItems: Partial<D>[], trace?: TraceOptions): Promise<D[]> {\n\t\ttrace?.span.updateName(`Mikro-Orm - createMany ${this.entityType.name}`);\n\t\treturn this._createMany(createItems);\n\t}\n\n\tpublic async createTraces(createItems: Partial<D>[]): Promise<D[]> {\n\t\treturn this._createMany(createItems);\n\t}\n\n\tprivate async _createMany(createItems: Partial<D>[]) {\n\t\tlogger.trace(\n\t\t\t{ createItems: sanitiseFilterForLogging(createItems), entity: this.entityType.name },\n\t\t\t'Running create with args'\n\t\t);\n\n\t\tconst entities = await this.database.transactional<D[]>(async () => {\n\t\t\treturn Promise.all<D>(\n\t\t\t\tcreateItems.map(async (item) => {\n\t\t\t\t\tconst entity = new this.entityType();\n\t\t\t\t\tawait this.mapAndAssignKeys(entity, this.entityType, item);\n\t\t\t\t\tthis.database.em.persist(entity as Partial<D>);\n\t\t\t\t\treturn entity;\n\t\t\t\t})\n\t\t\t);\n\t\t});\n\n\t\tlogger.trace({ entity: this.entityType.name, entities }, 'created items');\n\n\t\treturn entities;\n\t}\n\n\t@TraceMethod()\n\tpublic async deleteOne(filter: Filter<D>, trace?: TraceOptions): Promise<boolean> {\n\t\ttrace?.span.updateName(`Mikro-Orm - deleteOne ${this.entityType.name}`);\n\t\tlogger.trace(\n\t\t\t{ filter: sanitiseFilterForLogging(filter), entity: this.entityType.name },\n\t\t\t'Running delete with filter.'\n\t\t);\n\t\tconst where = filter\n\t\t\t? gqlToMikro(JSON.parse(JSON.stringify(filter)), this.getDbType())\n\t\t\t: undefined;\n\t\tconst whereWithAppliedExternalIdFields =\n\t\t\twhere && this.applyExternalIdFields(this.entityType, where);\n\n\t\tconst deletedRows = await this.database.em.nativeDelete(\n\t\t\tthis.entityType,\n\t\t\twhereWithAppliedExternalIdFields\n\t\t);\n\n\t\tif (deletedRows > 1) {\n\t\t\tthrow new Error('Multiple deleted rows');\n\t\t}\n\n\t\tlogger.trace(`delete ${this.entityType.name} result: deleted ${deletedRows} row(s)`);\n\n\t\treturn deletedRows === 1;\n\t}\n\n\t@TraceMethod()\n\tpublic async deleteMany(filter: Filter<D>, trace?: TraceOptions): Promise<boolean> {\n\t\ttrace?.span.updateName(`Mikro-Orm - deleteMany ${this.entityType.name}`);\n\t\tlogger.trace(\n\t\t\t{ filter: sanitiseFilterForLogging(filter), entity: this.entityType.name },\n\t\t\t'Running delete'\n\t\t);\n\n\t\tconst deletedRows = await this.database.transactional<number>(async () => {\n\t\t\tconst where = filter\n\t\t\t\t? gqlToMikro(JSON.parse(JSON.stringify(filter)), this.getDbType())\n\t\t\t\t: undefined;\n\t\t\tconst whereWithAppliedExternalIdFields =\n\t\t\t\twhere && this.applyExternalIdFields(this.entityType, where);\n\n\t\t\tconst toDelete = await this.database.em.count(\n\t\t\t\tthis.entityType,\n\t\t\t\twhereWithAppliedExternalIdFields\n\t\t\t);\n\t\t\tconst deletedCount = await this.database.em.nativeDelete(\n\t\t\t\tthis.entityType,\n\t\t\t\twhereWithAppliedExternalIdFields\n\t\t\t);\n\n\t\t\tif (deletedCount !== toDelete) {\n\t\t\t\tthrow new Error('We did not delete any rows, rolling back.');\n\t\t\t}\n\n\t\t\treturn deletedCount;\n\t\t});\n\n\t\tlogger.trace(`delete ${this.entityType.name} result: deleted ${deletedRows} row(s)`);\n\n\t\treturn true;\n\t}\n\n\tpublic foreignKeyForRelationshipField?(field: FieldMetadata, dataEntity: D) {\n\t\tconst value = dataEntity[field.name as keyof D];\n\n\t\tif (Reference.isReference(value)) {\n\t\t\tconst { properties } = this.database.em.getMetadata().get(this.entityType);\n\t\t\tconst property = properties[field.name];\n\t\t\tconst [primaryKey] = property.targetMeta?.primaryKeys ?? [];\n\t\t\tif (!primaryKey) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Could not determine primary key for ${field.name} on ${this.entityType.name}`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst foreignKey = (value.unwrap() as any)[primaryKey];\n\t\t\tif (foreignKey === undefined || foreignKey === null) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Could not read foreign key from reference: ${value.unwrap()} with primary key name ${primaryKey}`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn foreignKey;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t@TraceMethod()\n\tpublic async aggregate(\n\t\tfilter: Filter<D>,\n\t\trequestedAggregations: Set<AggregationType>,\n\t\ttrace?: TraceOptions\n\t): Promise<AggregationResult> {\n\t\ttrace?.span.updateName(`Mikro-Orm - aggregate ${this.entityType.name}`);\n\t\tlogger.trace(\n\t\t\t{ filter: sanitiseFilterForLogging(filter), entity: this.entityType.name },\n\t\t\t'Running aggregate with filter'\n\t\t);\n\n\t\t// Strip custom types out of the equation.\n\t\t// This query only works if we JSON.parse(JSON.stringify(filter)):\n\t\t//\n\t\t// query {\n\t\t// drivers (filter: { region: { name: \"North Shore\" }}) {\n\t\t// id\n\t\t// }\n\t\t// }\n\t\tconst where = filter\n\t\t\t? gqlToMikro(JSON.parse(JSON.stringify(filter)), this.getDbType())\n\t\t\t: undefined;\n\n\t\t// Convert from: { account: {id: '6' }}\n\t\t// to { accountId: '6' }\n\t\t// This conversion only works on root level objects\n\t\tconst whereWithAppliedExternalIdFields = where\n\t\t\t? this.applyExternalIdFields(this.entityType, where)\n\t\t\t: {};\n\n\t\t// Regions need some fancy handling with Query Builder. Process the where further\n\t\t// and return a Query Builder instance.\n\t\tconst query = this.em.createQueryBuilder(this.entityType);\n\n\t\tif (Object.keys(whereWithAppliedExternalIdFields).length > 0) {\n\t\t\tquery.andWhere(whereWithAppliedExternalIdFields);\n\t\t}\n\n\t\tconst result: AggregationResult = {};\n\n\t\ttry {\n\t\t\tif (requestedAggregations.has(AggregationType.COUNT)) {\n\t\t\t\tconst meta = this.database.em.getMetadata().get(this.entityType.name);\n\t\t\t\tif (meta.primaryKeys.length) {\n\t\t\t\t\t// It's a standard entity with primary keys, we can do a full distinct\n\t\t\t\t\t// on these keys.\n\t\t\t\t\tresult.count = await query.getCount(meta.primaryKeys, true);\n\t\t\t\t} else {\n\t\t\t\t\t// It's either a virtual entity, or it's an entity without primary keys.\n\t\t\t\t\t// We just need to count * as a fallback, no distinct.\n\t\t\t\t\tconst [firstRow] = await query.select(sql`count(*)`.as('count')).execute();\n\t\t\t\t\tresult.count = firstRow.count;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tsafeErrorLog(logger, err, `find ${this.entityType.name} error`);\n\n\t\t\tif ((err as PostgresError)?.routine === 'InitializeSessionUserId') {\n\t\t\t\t// Throw if the user credentials are incorrect\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Database connection failed, please check you are using the correct user credentials for the database.'\n\t\t\t\t);\n\t\t\t} else if ((err as PostgresError)?.code === 'ECONNREFUSED') {\n\t\t\t\t// Throw if the database address or port is incorrect\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Database connection failed, please check you are using the correct address and port for the database.'\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAUO;AAUP,oBAAqC;AACrC,kBAOO;AACP,gCAAmD;AAEnD,eAWO;AAEP,mBAA8D;AAC9D,oBAAuB;AAOvB,MAAM,mBAAmB,oBAAI,IAAI,CAAC,QAAQ,OAAO,MAAM,CAAC;AACxD,MAAM,wBAAwB,oBAAI,IAAI,CAAC,QAAQ,OAAO,MAAM,CAAC;AAC7D,MAAM,wBAAwB,oBAAI,IAAI,CAAC,QAAQ,SAAS,CAAC;AAEzD,MAAM,aAAa,CAAC,MAAc,YACjC,KAAK,SAAS,GAAG,IAAI,IAAI,OAAO,KAAK;AAE/B,MAAM,aAAa,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OD,qBA0OC;AAgFA;AAAA,MADZ,gCAAY;AAAA,GAzTD,qBA0TC;AAuCA;AAAA,MADZ,gCAAY;AAAA,GAhWD,qBAiWC;AA+CA;AAAA,MADZ,gCAAY;AAAA,GA/YD,qBAgZC;AAsDA;AAAA,MADZ,gCAAY;AAAA,GArcD,qBAscC;AA2CA;AAAA,MADZ,gCAAY;AAAA,GAhfD,qBAifC;AAwCA;AAAA,MADZ,gCAAY;AAAA,GAxhBD,qBAyhBC;AAoBA;AAAA,MADZ,gCAAY;AAAA,GA5iBD,qBA6iBC;AAgCA;AAAA,MADZ,gCAAY;AAAA,GA5kBD,qBA6kBC;AA2BA;AAAA,MADZ,gCAAY;AAAA,GAvmBD,qBAwmBC;AA8DA;AAAA,MADZ,gCAAY;AAAA,GArqBD,qBAsqBC;",
6
6
  "names": ["trace", "startTrace"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exogee/graphweaver-mikroorm",
3
- "version": "2.20.6",
3
+ "version": "2.20.8",
4
4
  "description": "MikroORM backend for @exogee/graphweaver",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -13,16 +13,16 @@
13
13
  "lib"
14
14
  ],
15
15
  "dependencies": {
16
- "@apollo/server": "5.0.0",
17
- "@aws-sdk/client-secrets-manager": "3.919.0",
16
+ "@apollo/server": "5.2.0",
17
+ "@aws-sdk/client-secrets-manager": "3.943.0",
18
18
  "dataloader": "2.2.3",
19
19
  "decimal.js": "10.6.0",
20
20
  "dotenv": "17.2.3",
21
21
  "pluralize": "8.0.0",
22
22
  "reflect-metadata": "0.2.2",
23
- "@exogee/graphweaver-server": "2.20.6",
24
- "@exogee/logger": "2.20.6",
25
- "@exogee/graphweaver": "2.20.6"
23
+ "@exogee/graphweaver": "2.20.8",
24
+ "@exogee/logger": "2.20.8",
25
+ "@exogee/graphweaver-server": "2.20.8"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@mikro-orm/core": "6",
@@ -57,10 +57,10 @@
57
57
  "@mikro-orm/mysql": "6.5.8",
58
58
  "@mikro-orm/postgresql": "6.5.8",
59
59
  "@mikro-orm/sqlite": "6.5.8",
60
- "@types/node": "24.9.1",
60
+ "@types/node": "24.10.0",
61
61
  "@types/pluralize": "0.0.33",
62
- "esbuild": "0.25.12",
63
- "glob": "11.0.3",
62
+ "esbuild": "0.27.0",
63
+ "glob": "11.1.0",
64
64
  "graphql": "16.11.0",
65
65
  "tsx": "4.20.6",
66
66
  "typescript": "5.9.3",