@exogee/graphweaver-mikroorm 2.20.3 → 2.20.4

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.
@@ -201,6 +201,7 @@ ${file}`;
201
201
  return "ISODateStringScalar";
202
202
  }
203
203
  if (prop.columnTypes?.[0] === "date") {
204
+ this.scalarImports.add("DateScalar");
204
205
  return "DateScalar";
205
206
  }
206
207
  if (prop.runtimeType === "unknown") {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/introspection/files/schema-entity-file.ts"],
4
- "sourcesContent": ["import type {\n\tDictionary,\n\tEntityMetadata,\n\tEntityProperty,\n\tNamingStrategy,\n\tPlatform,\n} from '@mikro-orm/core';\nimport { ReferenceKind, Utils } from '@mikro-orm/core';\nimport pluralize from 'pluralize';\nimport { identifierForEnumValue, pascalToCamelCaseString, pascalToKebabCaseString } from '../utils';\nimport { BaseFile } from './base-file';\nimport { DatabaseType } from '../../database';\nimport { isEntityWithSinglePrimaryKey } from '../generate';\n\nconst friendlyNameForDatabaseType = (type: DatabaseType) => {\n\tif (type === 'mssql') return 'SQL Server';\n\tif (type === 'mysql') return 'MySQL';\n\tif (type === 'postgresql') return 'PostgreSQL';\n\tif (type === 'sqlite') return 'SQLite';\n\n\tthrow new Error('Unimplemented database type: ' + type);\n};\n\nexport class SchemaEntityFile extends BaseFile {\n\tprotected readonly coreImports = new Set<string>();\n\tprotected readonly scalarImports = new Set<string>();\n\tprotected readonly entityImports = new Set<string>();\n\tprotected readonly enumImports = new Set<string>();\n\tpublic readonly errors: string[] = [];\n\n\tconstructor(\n\t\tprotected readonly meta: EntityMetadata,\n\t\tprotected readonly namingStrategy: NamingStrategy,\n\t\tprotected readonly platform: Platform,\n\t\tprotected readonly databaseType: DatabaseType,\n\t\tprotected readonly entityLookup: Map<string, EntityMetadata<any>>\n\t) {\n\t\tsuper(meta, namingStrategy, platform);\n\t}\n\n\tgetBasePath() {\n\t\treturn `backend/schema/`;\n\t}\n\n\tgetBaseName() {\n\t\tconst fileName = pascalToKebabCaseString(this.meta.className);\n\t\treturn `${fileName}.ts`;\n\t}\n\n\tgenerate(): string {\n\t\tconst enumDefinitions: string[] = [];\n\t\tlet classBody = '';\n\t\tconst generatedPropertyNames = new Set<string>();\n\t\tconst props = Object.values(this.meta.properties);\n\t\tprops.forEach((prop) => {\n\t\t\tconst relatedEntity = this.entityLookup.get(prop.type);\n\t\t\tif (relatedEntity) {\n\t\t\t\t// These are not supported yet, just skip them.\n\t\t\t\tif (!isEntityWithSinglePrimaryKey(relatedEntity)) {\n\t\t\t\t\tthis.errors.push(\n\t\t\t\t\t\t` - Warning: Composite primary keys are not supported. ${this.meta.className} entity references ${prop.type} entity with composite primary key.`\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (generatedPropertyNames.has(prop.name)) {\n\t\t\t\tthis.errors.push(\n\t\t\t\t\t` - Warning: Property ${prop.name} on ${this.meta.className} entity is not unique. Additional instances of this property were ignored.`\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tgeneratedPropertyNames.add(prop.name);\n\n\t\t\tconst decorator = this.getPropertyDecorator(prop);\n\t\t\tconst definition = this.getPropertyDefinition(prop);\n\n\t\t\tif (classBody && !classBody.endsWith('\\n\\n')) {\n\t\t\t\tclassBody += '\\n';\n\t\t\t}\n\n\t\t\tclassBody += decorator;\n\t\t\tclassBody += definition;\n\n\t\t\tif (props[props.length - 1] !== prop) classBody += '\\n';\n\n\t\t\tif (prop.enum) {\n\t\t\t\tconst enumClassName = this.namingStrategy.getClassName(\n\t\t\t\t\tthis.meta.collection + '_' + prop.fieldNames[0],\n\t\t\t\t\t'_'\n\t\t\t\t);\n\t\t\t\tenumDefinitions.push(this.getEnumClassDefinition(enumClassName));\n\t\t\t}\n\t\t});\n\n\t\tlet file = '';\n\n\t\tif (enumDefinitions.length) {\n\t\t\tfile += enumDefinitions.join('\\n');\n\t\t\tfile += '\\n\\n';\n\t\t}\n\n\t\tthis.coreImports.add('Entity');\n\n\t\tfile += `@Entity<${this.meta.className}>(${this.quote(this.meta.className)}, {\\n\\tprovider: new MikroBackendProvider(Orm${this.meta.className}, connection, { backendDisplayName: '${friendlyNameForDatabaseType(this.databaseType)}'})`;\n\n\t\tif (props.length === 1 && props[0].primary) {\n\t\t\t// Special case. If there's a single primary key field in this entity, right now that requires that it's a client side generated primary key.\n\t\t\t// There's no reason this has to be the case, but it's a current limitation, so we should generate a working project for them.\n\t\t\t// We should be able to remove this in the future and allow users to use it both ways.\n\t\t\tfile += `,\\n\\tapiOptions: { clientGeneratedPrimaryKeys: true },\\n})\\n`;\n\t\t} else {\n\t\t\tfile += `\\n})\\n`;\n\t\t}\n\n\t\tfile += `export class ${this.meta.className} {\\n`;\n\t\tfile += `${classBody}}\\n`;\n\t\tconst imports = [\n\t\t\t`import { ${[...this.coreImports].sort().join(', ')} } from '@exogee/graphweaver';`,\n\t\t];\n\n\t\tif (this.scalarImports.size > 0) {\n\t\t\timports.push(\n\t\t\t\t`import { ${[...this.scalarImports]\n\t\t\t\t\t.sort()\n\t\t\t\t\t.join(', ')} } from '@exogee/graphweaver-scalars';`\n\t\t\t);\n\t\t}\n\n\t\timports.push(`import { MikroBackendProvider } from '@exogee/graphweaver-mikroorm';`);\n\n\t\tconst entityImports = [...this.entityImports].filter((e) => e !== this.meta.className);\n\t\tentityImports.sort().forEach((entity) => {\n\t\t\timports.push(`import { ${entity} } from './${pascalToKebabCaseString(entity)}';`);\n\t\t});\n\n\t\timports.push(\n\t\t\t`import { ${this.enumImports.size > 0 ? [...this.enumImports].sort().join(', ') + ', ' : ''}${\n\t\t\t\tthis.meta.className\n\t\t\t} as Orm${this.meta.className} } from '../entities';`,\n\t\t\t`import { connection } from '../database';`\n\t\t);\n\n\t\tfile = `${imports.join('\\n')}\\n\\n${file}`;\n\n\t\treturn file;\n\t}\n\n\tprotected getTypescriptPropertyType(prop: EntityProperty): string {\n\t\tif ([ReferenceKind.ONE_TO_ONE, ReferenceKind.MANY_TO_ONE].includes(prop.kind)) {\n\t\t\treturn prop.type.charAt(0).toUpperCase() + prop.type.slice(1);\n\t\t}\n\n\t\tif (['jsonb', 'json', 'any'].includes(prop.columnTypes?.[0])) {\n\t\t\treturn `Record<string, unknown>`;\n\t\t}\n\n\t\tif (prop.columnTypes?.[0] === 'date') {\n\t\t\treturn 'Date';\n\t\t}\n\n\t\tif (prop.type === 'unknown') {\n\t\t\t//fallback to string if unknown\n\t\t\treturn 'string';\n\t\t}\n\n\t\tif (prop.type === 'bigint') {\n\t\t\treturn 'string';\n\t\t}\n\n\t\treturn prop.runtimeType;\n\t}\n\n\tprotected getPropertyDefinition(prop: EntityProperty): string {\n\t\tconst padding = '\\t';\n\n\t\tif ([ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(prop.kind)) {\n\t\t\tthis.entityImports.add(prop.type);\n\t\t\treturn `${padding}${prop.name}!: ${prop.type}[];\\n`;\n\t\t}\n\n\t\t// string defaults are usually things like SQL functions, but can be also enums, for that `useDefault` should be true\n\t\tconst isEnumOrNonStringDefault = prop.enum || typeof prop.default !== 'string';\n\t\tconst useDefault = prop.default != null && isEnumOrNonStringDefault;\n\t\tconst optional = prop.nullable ? '?' : useDefault ? '' : '!';\n\n\t\tconst file = `${prop.name}${optional}: ${this.getTypescriptPropertyType(prop)}`;\n\n\t\tif (!useDefault) {\n\t\t\treturn `${padding + file};\\n`;\n\t\t}\n\n\t\tif (prop.enum && typeof prop.default === 'string') {\n\t\t\treturn `${padding}${file} = ${prop.runtimeType}.${identifierForEnumValue(prop.default)};\\n`;\n\t\t}\n\n\t\treturn `${padding}${prop.name} = ${prop.default};\\n`;\n\t}\n\n\tprotected getEnumClassDefinition(enumClassName: string): string {\n\t\tthis.coreImports.add('graphweaverMetadata');\n\t\tthis.enumImports.add(enumClassName);\n\t\treturn `graphweaverMetadata.collectEnumInformation({ target: ${enumClassName}, name: ${this.quote(enumClassName)} });`;\n\t}\n\n\tprivate getGraphQLPropertyType(prop: EntityProperty): string {\n\t\tif (prop.primary) {\n\t\t\tthis.coreImports.add('ID');\n\t\t\treturn 'ID';\n\t\t}\n\n\t\tif (prop.runtimeType === 'Date') {\n\t\t\tthis.scalarImports.add('ISODateStringScalar');\n\t\t\treturn 'ISODateStringScalar';\n\t\t}\n\n\t\tif (prop.columnTypes?.[0] === 'date') {\n\t\t\treturn 'DateScalar';\n\t\t}\n\n\t\tif (prop.runtimeType === 'unknown') {\n\t\t\treturn 'String';\n\t\t}\n\n\t\tif (prop.runtimeType === 'bigint') {\n\t\t\tthis.scalarImports.add('GraphQLBigInt');\n\t\t\treturn 'GraphQLBigInt';\n\t\t}\n\n\t\tif (prop.runtimeType === 'Buffer') {\n\t\t\tthis.scalarImports.add('GraphQLByte');\n\t\t\treturn 'GraphQLByte';\n\t\t}\n\n\t\tif (['jsonb', 'json', 'any'].includes(prop.columnTypes?.[0])) {\n\t\t\tthis.scalarImports.add('GraphQLJSON');\n\t\t\treturn `GraphQLJSON`;\n\t\t}\n\n\t\tif (prop.runtimeType?.includes('[]')) {\n\t\t\treturn `[${prop.type.charAt(0).toUpperCase() + prop.type.slice(1).replace('[]', '')}]`;\n\t\t}\n\n\t\tif ([ReferenceKind.ONE_TO_ONE, ReferenceKind.MANY_TO_ONE].includes(prop.kind)) {\n\t\t\treturn prop.type.charAt(0).toUpperCase() + prop.type.slice(1);\n\t\t}\n\n\t\tif ([ReferenceKind.MANY_TO_MANY, ReferenceKind.ONE_TO_MANY].includes(prop.kind)) {\n\t\t\treturn `[${prop.type.charAt(0).toUpperCase() + prop.type.slice(1).replace('[]', '')}]`;\n\t\t}\n\n\t\tif (prop.pivotTable) {\n\t\t\treturn `[${prop.type.charAt(0).toUpperCase() + prop.type.slice(1)}]`;\n\t\t}\n\n\t\tconst lastChanceType = prop.runtimeType ?? prop.type;\n\n\t\tif (!lastChanceType) {\n\t\t\tconsole.error(`Property is malformed, it has no type or runtimeType:`, prop);\n\t\t\tthrow new Error(`Property ${prop.name} on ${prop.entity} entity has no type or runtimeType.`);\n\t\t}\n\n\t\treturn lastChanceType.charAt(0).toUpperCase() + lastChanceType.slice(1);\n\t}\n\n\tprivate getPropertyDecorator(prop: EntityProperty): string {\n\t\tconst padding = '\\t';\n\t\tconst options = {} as Dictionary;\n\t\tlet decorator = this.getDecoratorType(prop);\n\n\t\tif (prop.kind === ReferenceKind.MANY_TO_MANY) {\n\t\t\tthis.getManyToManyDecoratorOptions(options, prop);\n\t\t} else if (prop.kind === ReferenceKind.ONE_TO_MANY) {\n\t\t\tthis.getOneToManyDecoratorOptions(options, prop);\n\t\t} else if (prop.kind !== ReferenceKind.SCALAR) {\n\t\t\tthis.getForeignKeyDecoratorOptions(options, prop);\n\t\t}\n\n\t\tthis.getCommonDecoratorOptions(options, prop);\n\t\tdecorator = [decorator].map((d) => padding + d).join('\\n');\n\n\t\tif (!Utils.hasObjectKeys(options)) {\n\t\t\treturn `${decorator}(() => ${this.getGraphQLPropertyType(prop)})\\n`;\n\t\t}\n\n\t\treturn `${decorator}(() => ${this.getGraphQLPropertyType(prop)}, { ${Object.entries(options)\n\t\t\t.map(([opt, val]) => `${opt}: ${JSON.stringify(val).replaceAll('\"', '')}`)\n\t\t\t.join(', ')} })\\n`;\n\t}\n\n\tprotected getCommonDecoratorOptions(options: Dictionary, prop: EntityProperty): void {\n\t\tif (prop.nullable && !prop.mappedBy) {\n\t\t\toptions.nullable = true;\n\t\t}\n\n\t\tif (prop.primary) {\n\t\t\toptions.primaryKeyField = true;\n\t\t}\n\n\t\t// If there's a property called 'name' it should be the summary field. If not, and there's a field called 'title'\n\t\t// then it should be the summary field.\n\t\tif (prop.name === 'name') {\n\t\t\toptions.adminUIOptions = { summaryField: true };\n\t\t} else if (prop.name === 'title' && !this.meta.props.find((prop) => prop.name === 'name')) {\n\t\t\toptions.adminUIOptions = { summaryField: true };\n\t\t}\n\t}\n\n\tprotected getManyToManyDecoratorOptions(options: Dictionary, prop: EntityProperty) {\n\t\tthis.entityImports.add(prop.type);\n\t\toptions.relatedField = this.quote(pluralize(pascalToCamelCaseString(this.meta.className)));\n\t}\n\n\tprotected getOneToManyDecoratorOptions(options: Dictionary, prop: EntityProperty) {\n\t\tthis.entityImports.add(prop.type);\n\t\toptions.relatedField = this.quote(prop.mappedBy);\n\t}\n\n\tprotected getForeignKeyDecoratorOptions(options: Dictionary, prop: EntityProperty) {\n\t\tthis.entityImports.add(prop.type);\n\n\t\tconst relatedEntity = this.entityLookup.get(prop.type);\n\t\tif (!relatedEntity) {\n\t\t\tthrow new Error(\n\t\t\t\t`Internal Error: Related entity ${prop.type} should exist but could not be found in the entity lookup.`\n\t\t\t);\n\t\t}\n\t\tif (!isEntityWithSinglePrimaryKey(relatedEntity)) {\n\t\t\tthrow new Error(`Composite primary keys are not supported.`);\n\t\t}\n\t\tconst [primaryKey] = relatedEntity.getPrimaryProps();\n\n\t\toptions.id = `(entity) => entity.${prop.name}?.${primaryKey.name}`;\n\t}\n\n\tprotected getDecoratorType(prop: EntityProperty): string {\n\t\tif ([ReferenceKind.ONE_TO_ONE, ReferenceKind.MANY_TO_ONE].includes(prop.kind)) {\n\t\t\tthis.coreImports.add('RelationshipField');\n\t\t\treturn `@RelationshipField<${this.meta.className}>`;\n\t\t}\n\n\t\tif ([ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(prop.kind)) {\n\t\t\tthis.coreImports.add('RelationshipField');\n\t\t\treturn `@RelationshipField<${prop.type}>`;\n\t\t}\n\n\t\tthis.coreImports.add('Field');\n\t\treturn '@Field';\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,kBAAqC;AACrC,uBAAsB;AACtB,mBAAyF;AACzF,uBAAyB;AAEzB,sBAA6C;AAE7C,MAAM,8BAA8B,CAAC,SAAuB;AAC3D,MAAI,SAAS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,QAAQ;AAAA,EAChD;AAAA,EAEU,8BAA8B,SAAqB,MAAsB;AAClF,SAAK,cAAc,IAAI,KAAK,IAAI;AAEhC,UAAM,gBAAgB,KAAK,aAAa,IAAI,KAAK,IAAI;AACrD,QAAI,CAAC,eAAe;AACnB,YAAM,IAAI;AAAA,QACT,kCAAkC,KAAK,IAAI;AAAA,MAC5C;AAAA,IACD;AACA,QAAI,KAAC,8CAA6B,aAAa,GAAG;AACjD,YAAM,IAAI,MAAM,2CAA2C;AAAA,IAC5D;AACA,UAAM,CAAC,UAAU,IAAI,cAAc,gBAAgB;AAEnD,YAAQ,KAAK,sBAAsB,KAAK,IAAI,KAAK,WAAW,IAAI;AAAA,EACjE;AAAA,EAEU,iBAAiB,MAA8B;AACxD,QAAI,CAAC,0BAAc,YAAY,0BAAc,WAAW,EAAE,SAAS,KAAK,IAAI,GAAG;AAC9E,WAAK,YAAY,IAAI,mBAAmB;AACxC,aAAO,sBAAsB,KAAK,KAAK,SAAS;AAAA,IACjD;AAEA,QAAI,CAAC,0BAAc,aAAa,0BAAc,YAAY,EAAE,SAAS,KAAK,IAAI,GAAG;AAChF,WAAK,YAAY,IAAI,mBAAmB;AACxC,aAAO,sBAAsB,KAAK,IAAI;AAAA,IACvC;AAEA,SAAK,YAAY,IAAI,OAAO;AAC5B,WAAO;AAAA,EACR;AACD;",
4
+ "sourcesContent": ["import type {\n\tDictionary,\n\tEntityMetadata,\n\tEntityProperty,\n\tNamingStrategy,\n\tPlatform,\n} from '@mikro-orm/core';\nimport { ReferenceKind, Utils } from '@mikro-orm/core';\nimport pluralize from 'pluralize';\nimport { identifierForEnumValue, pascalToCamelCaseString, pascalToKebabCaseString } from '../utils';\nimport { BaseFile } from './base-file';\nimport { DatabaseType } from '../../database';\nimport { isEntityWithSinglePrimaryKey } from '../generate';\n\nconst friendlyNameForDatabaseType = (type: DatabaseType) => {\n\tif (type === 'mssql') return 'SQL Server';\n\tif (type === 'mysql') return 'MySQL';\n\tif (type === 'postgresql') return 'PostgreSQL';\n\tif (type === 'sqlite') return 'SQLite';\n\n\tthrow new Error('Unimplemented database type: ' + type);\n};\n\nexport class SchemaEntityFile extends BaseFile {\n\tprotected readonly coreImports = new Set<string>();\n\tprotected readonly scalarImports = new Set<string>();\n\tprotected readonly entityImports = new Set<string>();\n\tprotected readonly enumImports = new Set<string>();\n\tpublic readonly errors: string[] = [];\n\n\tconstructor(\n\t\tprotected readonly meta: EntityMetadata,\n\t\tprotected readonly namingStrategy: NamingStrategy,\n\t\tprotected readonly platform: Platform,\n\t\tprotected readonly databaseType: DatabaseType,\n\t\tprotected readonly entityLookup: Map<string, EntityMetadata<any>>\n\t) {\n\t\tsuper(meta, namingStrategy, platform);\n\t}\n\n\tgetBasePath() {\n\t\treturn `backend/schema/`;\n\t}\n\n\tgetBaseName() {\n\t\tconst fileName = pascalToKebabCaseString(this.meta.className);\n\t\treturn `${fileName}.ts`;\n\t}\n\n\tgenerate(): string {\n\t\tconst enumDefinitions: string[] = [];\n\t\tlet classBody = '';\n\t\tconst generatedPropertyNames = new Set<string>();\n\t\tconst props = Object.values(this.meta.properties);\n\t\tprops.forEach((prop) => {\n\t\t\tconst relatedEntity = this.entityLookup.get(prop.type);\n\t\t\tif (relatedEntity) {\n\t\t\t\t// These are not supported yet, just skip them.\n\t\t\t\tif (!isEntityWithSinglePrimaryKey(relatedEntity)) {\n\t\t\t\t\tthis.errors.push(\n\t\t\t\t\t\t` - Warning: Composite primary keys are not supported. ${this.meta.className} entity references ${prop.type} entity with composite primary key.`\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (generatedPropertyNames.has(prop.name)) {\n\t\t\t\tthis.errors.push(\n\t\t\t\t\t` - Warning: Property ${prop.name} on ${this.meta.className} entity is not unique. Additional instances of this property were ignored.`\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tgeneratedPropertyNames.add(prop.name);\n\n\t\t\tconst decorator = this.getPropertyDecorator(prop);\n\t\t\tconst definition = this.getPropertyDefinition(prop);\n\n\t\t\tif (classBody && !classBody.endsWith('\\n\\n')) {\n\t\t\t\tclassBody += '\\n';\n\t\t\t}\n\n\t\t\tclassBody += decorator;\n\t\t\tclassBody += definition;\n\n\t\t\tif (props[props.length - 1] !== prop) classBody += '\\n';\n\n\t\t\tif (prop.enum) {\n\t\t\t\tconst enumClassName = this.namingStrategy.getClassName(\n\t\t\t\t\tthis.meta.collection + '_' + prop.fieldNames[0],\n\t\t\t\t\t'_'\n\t\t\t\t);\n\t\t\t\tenumDefinitions.push(this.getEnumClassDefinition(enumClassName));\n\t\t\t}\n\t\t});\n\n\t\tlet file = '';\n\n\t\tif (enumDefinitions.length) {\n\t\t\tfile += enumDefinitions.join('\\n');\n\t\t\tfile += '\\n\\n';\n\t\t}\n\n\t\tthis.coreImports.add('Entity');\n\n\t\tfile += `@Entity<${this.meta.className}>(${this.quote(this.meta.className)}, {\\n\\tprovider: new MikroBackendProvider(Orm${this.meta.className}, connection, { backendDisplayName: '${friendlyNameForDatabaseType(this.databaseType)}'})`;\n\n\t\tif (props.length === 1 && props[0].primary) {\n\t\t\t// Special case. If there's a single primary key field in this entity, right now that requires that it's a client side generated primary key.\n\t\t\t// There's no reason this has to be the case, but it's a current limitation, so we should generate a working project for them.\n\t\t\t// We should be able to remove this in the future and allow users to use it both ways.\n\t\t\tfile += `,\\n\\tapiOptions: { clientGeneratedPrimaryKeys: true },\\n})\\n`;\n\t\t} else {\n\t\t\tfile += `\\n})\\n`;\n\t\t}\n\n\t\tfile += `export class ${this.meta.className} {\\n`;\n\t\tfile += `${classBody}}\\n`;\n\t\tconst imports = [\n\t\t\t`import { ${[...this.coreImports].sort().join(', ')} } from '@exogee/graphweaver';`,\n\t\t];\n\n\t\tif (this.scalarImports.size > 0) {\n\t\t\timports.push(\n\t\t\t\t`import { ${[...this.scalarImports]\n\t\t\t\t\t.sort()\n\t\t\t\t\t.join(', ')} } from '@exogee/graphweaver-scalars';`\n\t\t\t);\n\t\t}\n\n\t\timports.push(`import { MikroBackendProvider } from '@exogee/graphweaver-mikroorm';`);\n\n\t\tconst entityImports = [...this.entityImports].filter((e) => e !== this.meta.className);\n\t\tentityImports.sort().forEach((entity) => {\n\t\t\timports.push(`import { ${entity} } from './${pascalToKebabCaseString(entity)}';`);\n\t\t});\n\n\t\timports.push(\n\t\t\t`import { ${this.enumImports.size > 0 ? [...this.enumImports].sort().join(', ') + ', ' : ''}${\n\t\t\t\tthis.meta.className\n\t\t\t} as Orm${this.meta.className} } from '../entities';`,\n\t\t\t`import { connection } from '../database';`\n\t\t);\n\n\t\tfile = `${imports.join('\\n')}\\n\\n${file}`;\n\n\t\treturn file;\n\t}\n\n\tprotected getTypescriptPropertyType(prop: EntityProperty): string {\n\t\tif ([ReferenceKind.ONE_TO_ONE, ReferenceKind.MANY_TO_ONE].includes(prop.kind)) {\n\t\t\treturn prop.type.charAt(0).toUpperCase() + prop.type.slice(1);\n\t\t}\n\n\t\tif (['jsonb', 'json', 'any'].includes(prop.columnTypes?.[0])) {\n\t\t\treturn `Record<string, unknown>`;\n\t\t}\n\n\t\tif (prop.columnTypes?.[0] === 'date') {\n\t\t\treturn 'Date';\n\t\t}\n\n\t\tif (prop.type === 'unknown') {\n\t\t\t//fallback to string if unknown\n\t\t\treturn 'string';\n\t\t}\n\n\t\tif (prop.type === 'bigint') {\n\t\t\treturn 'string';\n\t\t}\n\n\t\treturn prop.runtimeType;\n\t}\n\n\tprotected getPropertyDefinition(prop: EntityProperty): string {\n\t\tconst padding = '\\t';\n\n\t\tif ([ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(prop.kind)) {\n\t\t\tthis.entityImports.add(prop.type);\n\t\t\treturn `${padding}${prop.name}!: ${prop.type}[];\\n`;\n\t\t}\n\n\t\t// string defaults are usually things like SQL functions, but can be also enums, for that `useDefault` should be true\n\t\tconst isEnumOrNonStringDefault = prop.enum || typeof prop.default !== 'string';\n\t\tconst useDefault = prop.default != null && isEnumOrNonStringDefault;\n\t\tconst optional = prop.nullable ? '?' : useDefault ? '' : '!';\n\n\t\tconst file = `${prop.name}${optional}: ${this.getTypescriptPropertyType(prop)}`;\n\n\t\tif (!useDefault) {\n\t\t\treturn `${padding + file};\\n`;\n\t\t}\n\n\t\tif (prop.enum && typeof prop.default === 'string') {\n\t\t\treturn `${padding}${file} = ${prop.runtimeType}.${identifierForEnumValue(prop.default)};\\n`;\n\t\t}\n\n\t\treturn `${padding}${prop.name} = ${prop.default};\\n`;\n\t}\n\n\tprotected getEnumClassDefinition(enumClassName: string): string {\n\t\tthis.coreImports.add('graphweaverMetadata');\n\t\tthis.enumImports.add(enumClassName);\n\t\treturn `graphweaverMetadata.collectEnumInformation({ target: ${enumClassName}, name: ${this.quote(enumClassName)} });`;\n\t}\n\n\tprivate getGraphQLPropertyType(prop: EntityProperty): string {\n\t\tif (prop.primary) {\n\t\t\tthis.coreImports.add('ID');\n\t\t\treturn 'ID';\n\t\t}\n\n\t\tif (prop.runtimeType === 'Date') {\n\t\t\tthis.scalarImports.add('ISODateStringScalar');\n\t\t\treturn 'ISODateStringScalar';\n\t\t}\n\n\t\tif (prop.columnTypes?.[0] === 'date') {\n\t\t\tthis.scalarImports.add('DateScalar');\n\t\t\treturn 'DateScalar';\n\t\t}\n\n\t\tif (prop.runtimeType === 'unknown') {\n\t\t\treturn 'String';\n\t\t}\n\n\t\tif (prop.runtimeType === 'bigint') {\n\t\t\tthis.scalarImports.add('GraphQLBigInt');\n\t\t\treturn 'GraphQLBigInt';\n\t\t}\n\n\t\tif (prop.runtimeType === 'Buffer') {\n\t\t\tthis.scalarImports.add('GraphQLByte');\n\t\t\treturn 'GraphQLByte';\n\t\t}\n\n\t\tif (['jsonb', 'json', 'any'].includes(prop.columnTypes?.[0])) {\n\t\t\tthis.scalarImports.add('GraphQLJSON');\n\t\t\treturn `GraphQLJSON`;\n\t\t}\n\n\t\tif (prop.runtimeType?.includes('[]')) {\n\t\t\treturn `[${prop.type.charAt(0).toUpperCase() + prop.type.slice(1).replace('[]', '')}]`;\n\t\t}\n\n\t\tif ([ReferenceKind.ONE_TO_ONE, ReferenceKind.MANY_TO_ONE].includes(prop.kind)) {\n\t\t\treturn prop.type.charAt(0).toUpperCase() + prop.type.slice(1);\n\t\t}\n\n\t\tif ([ReferenceKind.MANY_TO_MANY, ReferenceKind.ONE_TO_MANY].includes(prop.kind)) {\n\t\t\treturn `[${prop.type.charAt(0).toUpperCase() + prop.type.slice(1).replace('[]', '')}]`;\n\t\t}\n\n\t\tif (prop.pivotTable) {\n\t\t\treturn `[${prop.type.charAt(0).toUpperCase() + prop.type.slice(1)}]`;\n\t\t}\n\n\t\tconst lastChanceType = prop.runtimeType ?? prop.type;\n\n\t\tif (!lastChanceType) {\n\t\t\tconsole.error(`Property is malformed, it has no type or runtimeType:`, prop);\n\t\t\tthrow new Error(`Property ${prop.name} on ${prop.entity} entity has no type or runtimeType.`);\n\t\t}\n\n\t\treturn lastChanceType.charAt(0).toUpperCase() + lastChanceType.slice(1);\n\t}\n\n\tprivate getPropertyDecorator(prop: EntityProperty): string {\n\t\tconst padding = '\\t';\n\t\tconst options = {} as Dictionary;\n\t\tlet decorator = this.getDecoratorType(prop);\n\n\t\tif (prop.kind === ReferenceKind.MANY_TO_MANY) {\n\t\t\tthis.getManyToManyDecoratorOptions(options, prop);\n\t\t} else if (prop.kind === ReferenceKind.ONE_TO_MANY) {\n\t\t\tthis.getOneToManyDecoratorOptions(options, prop);\n\t\t} else if (prop.kind !== ReferenceKind.SCALAR) {\n\t\t\tthis.getForeignKeyDecoratorOptions(options, prop);\n\t\t}\n\n\t\tthis.getCommonDecoratorOptions(options, prop);\n\t\tdecorator = [decorator].map((d) => padding + d).join('\\n');\n\n\t\tif (!Utils.hasObjectKeys(options)) {\n\t\t\treturn `${decorator}(() => ${this.getGraphQLPropertyType(prop)})\\n`;\n\t\t}\n\n\t\treturn `${decorator}(() => ${this.getGraphQLPropertyType(prop)}, { ${Object.entries(options)\n\t\t\t.map(([opt, val]) => `${opt}: ${JSON.stringify(val).replaceAll('\"', '')}`)\n\t\t\t.join(', ')} })\\n`;\n\t}\n\n\tprotected getCommonDecoratorOptions(options: Dictionary, prop: EntityProperty): void {\n\t\tif (prop.nullable && !prop.mappedBy) {\n\t\t\toptions.nullable = true;\n\t\t}\n\n\t\tif (prop.primary) {\n\t\t\toptions.primaryKeyField = true;\n\t\t}\n\n\t\t// If there's a property called 'name' it should be the summary field. If not, and there's a field called 'title'\n\t\t// then it should be the summary field.\n\t\tif (prop.name === 'name') {\n\t\t\toptions.adminUIOptions = { summaryField: true };\n\t\t} else if (prop.name === 'title' && !this.meta.props.find((prop) => prop.name === 'name')) {\n\t\t\toptions.adminUIOptions = { summaryField: true };\n\t\t}\n\t}\n\n\tprotected getManyToManyDecoratorOptions(options: Dictionary, prop: EntityProperty) {\n\t\tthis.entityImports.add(prop.type);\n\t\toptions.relatedField = this.quote(pluralize(pascalToCamelCaseString(this.meta.className)));\n\t}\n\n\tprotected getOneToManyDecoratorOptions(options: Dictionary, prop: EntityProperty) {\n\t\tthis.entityImports.add(prop.type);\n\t\toptions.relatedField = this.quote(prop.mappedBy);\n\t}\n\n\tprotected getForeignKeyDecoratorOptions(options: Dictionary, prop: EntityProperty) {\n\t\tthis.entityImports.add(prop.type);\n\n\t\tconst relatedEntity = this.entityLookup.get(prop.type);\n\t\tif (!relatedEntity) {\n\t\t\tthrow new Error(\n\t\t\t\t`Internal Error: Related entity ${prop.type} should exist but could not be found in the entity lookup.`\n\t\t\t);\n\t\t}\n\t\tif (!isEntityWithSinglePrimaryKey(relatedEntity)) {\n\t\t\tthrow new Error(`Composite primary keys are not supported.`);\n\t\t}\n\t\tconst [primaryKey] = relatedEntity.getPrimaryProps();\n\n\t\toptions.id = `(entity) => entity.${prop.name}?.${primaryKey.name}`;\n\t}\n\n\tprotected getDecoratorType(prop: EntityProperty): string {\n\t\tif ([ReferenceKind.ONE_TO_ONE, ReferenceKind.MANY_TO_ONE].includes(prop.kind)) {\n\t\t\tthis.coreImports.add('RelationshipField');\n\t\t\treturn `@RelationshipField<${this.meta.className}>`;\n\t\t}\n\n\t\tif ([ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(prop.kind)) {\n\t\t\tthis.coreImports.add('RelationshipField');\n\t\t\treturn `@RelationshipField<${prop.type}>`;\n\t\t}\n\n\t\tthis.coreImports.add('Field');\n\t\treturn '@Field';\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,kBAAqC;AACrC,uBAAsB;AACtB,mBAAyF;AACzF,uBAAyB;AAEzB,sBAA6C;AAE7C,MAAM,8BAA8B,CAAC,SAAuB;AAC3D,MAAI,SAAS,QAAS,QAAO;AAC7B,MAAI,SAAS,QAAS,QAAO;AAC7B,MAAI,SAAS,aAAc,QAAO;AAClC,MAAI,SAAS,SAAU,QAAO;AAE9B,QAAM,IAAI,MAAM,kCAAkC,IAAI;AACvD;AAEO,MAAM,yBAAyB,0BAAS;AAAA,EAO9C,YACoB,MACA,gBACA,UACA,cACA,cAClB;AACD,UAAM,MAAM,gBAAgB,QAAQ;AANjB;AACA;AACA;AACA;AACA;AAXpB,SAAmB,cAAc,oBAAI,IAAY;AACjD,SAAmB,gBAAgB,oBAAI,IAAY;AACnD,SAAmB,gBAAgB,oBAAI,IAAY;AACnD,SAAmB,cAAc,oBAAI,IAAY;AACjD,SAAgB,SAAmB,CAAC;AAAA,EAUpC;AAAA,EAEA,cAAc;AACb,WAAO;AAAA,EACR;AAAA,EAEA,cAAc;AACb,UAAM,eAAW,sCAAwB,KAAK,KAAK,SAAS;AAC5D,WAAO,GAAG,QAAQ;AAAA,EACnB;AAAA,EAEA,WAAmB;AAClB,UAAM,kBAA4B,CAAC;AACnC,QAAI,YAAY;AAChB,UAAM,yBAAyB,oBAAI,IAAY;AAC/C,UAAM,QAAQ,OAAO,OAAO,KAAK,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,WAAK,YAAY,IAAI,mBAAmB;AACxC,aAAO,sBAAsB,KAAK,IAAI;AAAA,IACvC;AAEA,SAAK,YAAY,IAAI,OAAO;AAC5B,WAAO;AAAA,EACR;AACD;",
6
6
  "names": ["prop", "pluralize"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exogee/graphweaver-mikroorm",
3
- "version": "2.20.3",
3
+ "version": "2.20.4",
4
4
  "description": "MikroORM backend for @exogee/graphweaver",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -14,15 +14,15 @@
14
14
  ],
15
15
  "dependencies": {
16
16
  "@apollo/server": "5.0.0",
17
- "@aws-sdk/client-secrets-manager": "3.910.0",
17
+ "@aws-sdk/client-secrets-manager": "3.911.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": "2.20.3",
24
- "@exogee/logger": "2.20.3",
25
- "@exogee/graphweaver-server": "2.20.3"
23
+ "@exogee/graphweaver-server": "2.20.4",
24
+ "@exogee/graphweaver": "2.20.4",
25
+ "@exogee/logger": "2.20.4"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@mikro-orm/core": "6",