@exogee/graphweaver-mikroorm 2.1.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -50,18 +50,29 @@ class IntrospectionError extends Error {
|
|
|
50
50
|
}
|
|
51
51
|
const hasErrorMessage = (error) => error.message;
|
|
52
52
|
const generateBidirectionalRelations = (metadata) => {
|
|
53
|
+
const nonPrimaryKeyReferenceErrors = [];
|
|
53
54
|
for (const meta of metadata.filter((m) => !m.pivotTable)) {
|
|
54
55
|
for (const prop of meta.relations) {
|
|
55
56
|
if (!prop.name.includes("Inverse")) {
|
|
56
57
|
const targetMeta = metadata.find((m) => m.className === prop.type);
|
|
58
|
+
const referencedTablePrimaryKeys = import_core.Utils.flatten(
|
|
59
|
+
(targetMeta?.getPrimaryProps() ?? []).map((pk) => pk.fieldNames)
|
|
60
|
+
);
|
|
61
|
+
if (prop.fieldNames?.length) {
|
|
62
|
+
for (const referencedColumn of prop.referencedColumnNames) {
|
|
63
|
+
if (!referencedTablePrimaryKeys.includes(referencedColumn)) {
|
|
64
|
+
nonPrimaryKeyReferenceErrors.push(
|
|
65
|
+
` - Relationship between ${meta.className}.${prop.fieldNames.join(", ")} and ${targetMeta?.className}.${referencedColumn} is not supported.`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
57
70
|
const newProp = {
|
|
58
71
|
name: prop.name + "Inverse",
|
|
59
72
|
type: meta.className,
|
|
60
73
|
joinColumns: prop.fieldNames,
|
|
61
74
|
referencedTableName: meta.tableName,
|
|
62
|
-
referencedColumnNames:
|
|
63
|
-
(targetMeta?.getPrimaryProps() ?? []).map((pk) => pk.fieldNames)
|
|
64
|
-
),
|
|
75
|
+
referencedColumnNames: referencedTablePrimaryKeys,
|
|
65
76
|
mappedBy: prop.name
|
|
66
77
|
};
|
|
67
78
|
const inverseMeta = metadata.find((m) => m.className === meta.className);
|
|
@@ -85,6 +96,15 @@ const generateBidirectionalRelations = (metadata) => {
|
|
|
85
96
|
}
|
|
86
97
|
}
|
|
87
98
|
}
|
|
99
|
+
if (nonPrimaryKeyReferenceErrors.length) {
|
|
100
|
+
throw new IntrospectionError(
|
|
101
|
+
`Unsupported Relationship${nonPrimaryKeyReferenceErrors.length === 1 ? "" : "s"} Detected`,
|
|
102
|
+
`
|
|
103
|
+
${nonPrimaryKeyReferenceErrors.join("\n")}
|
|
104
|
+
|
|
105
|
+
Foreign keys in Graphweaver currently need to reference the primary key of the other table.`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
88
108
|
};
|
|
89
109
|
const detectManyToManyRelations = (metadata) => {
|
|
90
110
|
for (const meta of metadata) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/introspection/generate.ts"],
|
|
4
|
-
"sourcesContent": ["import { DatabaseSchema, AbstractSqlPlatform, DatabaseTable } from '@mikro-orm/knex';\nimport {\n\tEntityMetadata,\n\tEntityProperty,\n\tNamingStrategy,\n\tReferenceKind,\n\tUtils,\n} from '@mikro-orm/core';\nimport pluralize from 'pluralize';\n\nimport { ConnectionManager, ConnectionOptions, DatabaseType } from '../database';\nimport {\n\tDataEntityFile,\n\tDataEntityIndexFile,\n\tDataSourceIndexFile,\n\tSchemaEntityFile,\n\tSchemaIndexFile,\n\tDatabaseFile,\n} from './files';\nimport { pascalToCamelCaseString } from './utils';\n\nconst CONNECTION_MANAGER_ID = 'generate';\n\nexport class IntrospectionError extends Error {\n\tprotected type: string;\n\tconstructor(\n\t\tprotected title = '',\n\t\tmessage = ''\n\t) {\n\t\tsuper(message);\n\t\tthis.type = 'IntrospectionError';\n\t\tthis.title = title;\n\t\tthis.message = message;\n\t}\n}\n\nconst hasErrorMessage = (error: any): error is { message: string } => error.message;\n\nconst generateBidirectionalRelations = (metadata: EntityMetadata[]): void => {\n\tfor (const meta of metadata.filter((m) => !m.pivotTable)) {\n\t\tfor (const prop of meta.relations) {\n\t\t\tif (!prop.name.includes('Inverse')) {\n\t\t\t\tconst targetMeta = metadata.find((m) => m.className === prop.type);\n\t\t\t\tconst newProp = {\n\t\t\t\t\tname: prop.name + 'Inverse',\n\t\t\t\t\ttype: meta.className,\n\t\t\t\t\tjoinColumns: prop.fieldNames,\n\t\t\t\t\treferencedTableName: meta.tableName,\n\t\t\t\t\treferencedColumnNames: Utils.flatten(\n\t\t\t\t\t\t(targetMeta?.getPrimaryProps() ?? []).map((pk) => pk.fieldNames)\n\t\t\t\t\t),\n\t\t\t\t\tmappedBy: prop.name,\n\t\t\t\t} as EntityProperty;\n\n\t\t\t\t// Add reference to the inverse entity\n\t\t\t\tconst inverseMeta = metadata.find((m) => m.className === meta.className);\n\t\t\t\tconst inverseProp = inverseMeta?.props.find((p) => p.name === newProp.mappedBy);\n\t\t\t\tif (inverseProp) inverseProp.inversedBy = newProp.name;\n\n\t\t\t\tif (prop.kind === ReferenceKind.MANY_TO_ONE) {\n\t\t\t\t\tconst name = pascalToCamelCaseString(meta.className);\n\t\t\t\t\tnewProp.name = pluralize(name);\n\t\t\t\t\tnewProp.kind = ReferenceKind.ONE_TO_MANY;\n\t\t\t\t} else if (prop.kind === ReferenceKind.ONE_TO_ONE && !prop.mappedBy) {\n\t\t\t\t\tnewProp.kind = ReferenceKind.ONE_TO_ONE;\n\t\t\t\t\tnewProp.nullable = true;\n\t\t\t\t} else if (prop.kind === ReferenceKind.MANY_TO_MANY && !prop.mappedBy) {\n\t\t\t\t\tconst name = pascalToCamelCaseString(meta.className);\n\t\t\t\t\tnewProp.name = pluralize(name);\n\t\t\t\t\tnewProp.kind = ReferenceKind.MANY_TO_MANY;\n\t\t\t\t} else {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\ttargetMeta?.addProperty(newProp);\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst detectManyToManyRelations = (metadata: EntityMetadata[]) => {\n\tfor (const meta of metadata) {\n\t\tif (\n\t\t\tmeta.compositePK && // needs to have composite PK\n\t\t\tmeta.primaryKeys.length === meta.relations.length && // all relations are PKs\n\t\t\tmeta.relations.length === 2 && // there are exactly two relation properties\n\t\t\tmeta.relations.length === meta.props.length && // all properties are relations\n\t\t\tmeta.relations.every((prop) => prop.kind === ReferenceKind.MANY_TO_ONE) // all relations are m:1\n\t\t) {\n\t\t\tmeta.pivotTable = true;\n\t\t\tconst owner = metadata.find((m) => m.className === meta.relations[0].type);\n\t\t\tif (!owner) throw new Error('No Owner');\n\t\t\tconst name = pascalToCamelCaseString(meta.relations?.[1]?.type);\n\t\t\towner.addProperty({\n\t\t\t\tname: pluralize(name),\n\t\t\t\tkind: ReferenceKind.MANY_TO_MANY,\n\t\t\t\tpivotTable: meta.tableName,\n\t\t\t\ttype: meta.relations[1].type,\n\t\t\t\tjoinColumns: meta.relations[0].fieldNames,\n\t\t\t\tinverseJoinColumns: meta.relations[1].fieldNames,\n\t\t\t} as EntityProperty);\n\t\t}\n\t}\n};\n\nconst generateIdentifiedReferences = (metadata: EntityMetadata[]): void => {\n\tfor (const meta of metadata.filter((m) => !m.pivotTable)) {\n\t\tfor (const prop of meta.relations) {\n\t\t\tif ([ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(prop.kind)) {\n\t\t\t\tconst name = pascalToCamelCaseString(prop.type);\n\t\t\t\tprop.name = pluralize.singular(name);\n\t\t\t\tprop.ref = true;\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst generateSingularTypeReferences = (metadata: EntityMetadata[]): void => {\n\tfor (const meta of metadata.filter((m) => !m.pivotTable)) {\n\t\tmeta.className = pluralize.singular(meta.className);\n\t\tfor (const prop of meta.relations) {\n\t\t\tprop.type = pluralize.singular(prop.type);\n\t\t}\n\t}\n};\n\n// Convert properties like FirstName to firstName\nconst convertToCamelCasePropertyNames = (metadata: EntityMetadata[]): void => {\n\tfor (const meta of metadata.filter((m) => !m.pivotTable)) {\n\t\tconst props = Object.values(meta.properties);\n\t\tprops.forEach((prop) => {\n\t\t\tprop.name = pascalToCamelCaseString(prop.name);\n\t\t});\n\t}\n};\n\nconst assertUniqueForeignKeys = (table: DatabaseTable): void => {\n\tconst uniqueForeignKeys = new Set();\n\tconst definedForeignKeys = Object.values(table.getForeignKeys());\n\n\tfor (const foreignKey of definedForeignKeys) {\n\t\tconst { localTableName, referencedTableName, columnNames, referencedColumnNames } = foreignKey;\n\t\tconst serializedValue = JSON.stringify({\n\t\t\tlocalTableName,\n\t\t\tcolumnNames: columnNames.sort(),\n\t\t\treferencedTableName,\n\t\t\treferencedColumnNames: referencedColumnNames.sort(),\n\t\t});\n\n\t\tif (uniqueForeignKeys.has(serializedValue)) {\n\t\t\tthrow new Error(\n\t\t\t\t`\\n\\nImport Failed: Duplicate foreign keys detected on column/s (${columnNames.toString()}) in table \"${\n\t\t\t\t\ttable.name\n\t\t\t\t}\".`\n\t\t\t);\n\t\t}\n\n\t\tuniqueForeignKeys.add(serializedValue);\n\t}\n};\n\nconst convertSchemaToMetadata = async (\n\tschema: DatabaseSchema,\n\tplatform: AbstractSqlPlatform,\n\tnamingStrategy: NamingStrategy\n) => {\n\tconst helper = platform.getSchemaHelper();\n\n\tif (!helper) throw new Error('cannot connect to database');\n\n\tconst metadata = schema\n\t\t.getTables()\n\t\t.sort((a, b) => a.name.localeCompare(b.name))\n\t\t.map((table) => {\n\t\t\tassertUniqueForeignKeys(table);\n\t\t\treturn table.getEntityDeclaration(namingStrategy, helper, 'never');\n\t\t});\n\n\tif (metadata.length === 0) {\n\t\tthrow new IntrospectionError(\n\t\t\t`Warning: No tables found, this database is empty.`,\n\t\t\t`Make sure you have tables in this database and then try again.`\n\t\t);\n\t}\n\n\tconvertToCamelCasePropertyNames(metadata);\n\tdetectManyToManyRelations(metadata);\n\tgenerateIdentifiedReferences(metadata);\n\tgenerateBidirectionalRelations(metadata);\n\tgenerateSingularTypeReferences(metadata);\n\n\treturn metadata;\n};\n\nconst openConnection = async (type: DatabaseType, options: ConnectionOptions) => {\n\t// eslint-disable-next-line @typescript-eslint/no-var-requires\n\tconst module = require(`@mikro-orm/${type}`);\n\tconst PLATFORMS = {\n\t\tmysql: 'MySqlDriver',\n\t\tpostgresql: 'PostgreSqlDriver',\n\t\tsqlite: 'SqliteDriver',\n\t};\n\tawait ConnectionManager.connect(CONNECTION_MANAGER_ID, {\n\t\tmikroOrmConfig: {\n\t\t\tdriver: module[PLATFORMS[type]],\n\t\t\t...options.mikroOrmConfig,\n\t\t},\n\t});\n};\n\nconst closeConnection = async () => {\n\tconsole.log('Closing database connection...');\n\tawait ConnectionManager.close(CONNECTION_MANAGER_ID);\n\tconsole.log('Database connection closed.');\n};\n\ntype File =\n\t| DataEntityFile\n\t| SchemaEntityFile\n\t| SchemaIndexFile\n\t| DataEntityIndexFile\n\t| DataSourceIndexFile\n\t| DatabaseFile;\n\nexport const generate = async (databaseType: DatabaseType, options: ConnectionOptions) => {\n\ttry {\n\t\tawait openConnection(databaseType, options);\n\n\t\tconst database = ConnectionManager.database(CONNECTION_MANAGER_ID);\n\t\tif (!database)\n\t\t\tthrow new IntrospectionError(\n\t\t\t\t`Warning: Unable to connect to database.`,\n\t\t\t\t'Please check the connection settings and try again'\n\t\t\t);\n\n\t\tconst config = database.em.config;\n\t\tconst driver = database.em.getDriver();\n\t\tconst platform = driver.getPlatform();\n\t\tconst namingStrategy = config.getNamingStrategy();\n\t\tconst connection = driver.getConnection();\n\n\t\tconsole.log('Fetching database schema...');\n\t\tconst schema = await DatabaseSchema.create(connection, platform, config);\n\t\tconsole.log('Building metadata...');\n\t\tconst metadata = await convertSchemaToMetadata(schema, platform, namingStrategy);\n\n\t\t// Build a lookup for efficient cross-referencing later.\n\t\tconst entityLookup = new Map<string, EntityMetadata<any>>();\n\t\tfor (const meta of metadata) {\n\t\t\tentityLookup.set(meta.className, meta);\n\t\t}\n\n\t\tconst source: File[] = [];\n\n\t\tconst summaryOfEntities: { name: string; entityFilePath: string; schemaFilePath: string }[] =\n\t\t\t[];\n\n\t\tfor (const meta of metadata) {\n\t\t\tif (!meta.pivotTable) {\n\t\t\t\tconst dataEntityFile = new DataEntityFile(meta, namingStrategy, platform, databaseType);\n\t\t\t\tconst schemaEntityFile = new SchemaEntityFile(meta, namingStrategy, platform, entityLookup);\n\t\t\t\tsource.push(dataEntityFile, schemaEntityFile);\n\t\t\t\tsummaryOfEntities.push({\n\t\t\t\t\tname: meta.className,\n\t\t\t\t\tentityFilePath: `${dataEntityFile.getBasePath()}${dataEntityFile.getBaseName()}`,\n\t\t\t\t\tschemaFilePath: `${schemaEntityFile.getBasePath()}${schemaEntityFile.getBaseName()}`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Export all the entities from the data source directory\n\t\tsource.push(new DataEntityIndexFile(metadata, databaseType));\n\t\t// Export the data source from the entities directory\n\t\tsource.push(new DataSourceIndexFile(databaseType));\n\t\t// Export the data source from the entities directory\n\t\tsource.push(new SchemaIndexFile(metadata));\n\t\t// Export the database connection to its own file\n\t\tsource.push(new DatabaseFile(databaseType, options));\n\n\t\tconst files = source.map((file) => {\n\t\t\treturn {\n\t\t\t\tpath: file.getBasePath(),\n\t\t\t\tname: file.getBaseName(),\n\t\t\t\tcontents: file.generate(),\n\t\t\t\tneedOverwriteWarning: !![DatabaseFile, SchemaIndexFile].some((cls) => file instanceof cls),\n\t\t\t};\n\t\t});\n\n\t\tawait closeConnection();\n\n\t\tconsole.log('\\nImport Summary:');\n\t\tconsole.table(summaryOfEntities);\n\t\tconsole.log(\n\t\t\t`\\nImported ${summaryOfEntities.length} entities, creating the above files in your Graphweaver project. \\n`\n\t\t);\n\n\t\treturn files;\n\t} catch (err) {\n\t\tif (err instanceof IntrospectionError) throw err;\n\n\t\tconsole.error('Got error during introspection:');\n\t\tconsole.error(err);\n\n\t\tthrow new IntrospectionError(\n\t\t\t`Warning: Unable to connect to database.`,\n\t\t\thasErrorMessage(err) ? err.message : 'Please check the connection settings and try again'\n\t\t);\n\t}\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmE;AACnE,kBAMO;AACP,uBAAsB;AAEtB,sBAAmE;AACnE,mBAOO;AACP,mBAAwC;AAExC,MAAM,wBAAwB;AAEvB,MAAM,2BAA2B,MAAM;AAAA,EAE7C,YACW,QAAQ,IAClB,UAAU,IACT;AACD,UAAM,OAAO;AAHH;AAIV,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,UAAU;AAAA,EAChB;AACD;AAEA,MAAM,kBAAkB,CAAC,UAA6C,MAAM;AAE5E,MAAM,iCAAiC,CAAC,aAAqC;AAC5E,aAAW,QAAQ,SAAS,OAAO,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG;AACzD,eAAW,QAAQ,KAAK,WAAW;AAClC,UAAI,CAAC,KAAK,KAAK,SAAS,SAAS,GAAG;AACnC,cAAM,aAAa,SAAS,KAAK,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI;AACjE,cAAM,
|
|
4
|
+
"sourcesContent": ["import { DatabaseSchema, AbstractSqlPlatform, DatabaseTable } from '@mikro-orm/knex';\nimport {\n\tEntityMetadata,\n\tEntityProperty,\n\tNamingStrategy,\n\tReferenceKind,\n\tUtils,\n} from '@mikro-orm/core';\nimport pluralize from 'pluralize';\n\nimport { ConnectionManager, ConnectionOptions, DatabaseType } from '../database';\nimport {\n\tDataEntityFile,\n\tDataEntityIndexFile,\n\tDataSourceIndexFile,\n\tSchemaEntityFile,\n\tSchemaIndexFile,\n\tDatabaseFile,\n} from './files';\nimport { pascalToCamelCaseString } from './utils';\n\nconst CONNECTION_MANAGER_ID = 'generate';\n\nexport class IntrospectionError extends Error {\n\tprotected type: string;\n\tconstructor(\n\t\tprotected title = '',\n\t\tmessage = ''\n\t) {\n\t\tsuper(message);\n\t\tthis.type = 'IntrospectionError';\n\t\tthis.title = title;\n\t\tthis.message = message;\n\t}\n}\n\nconst hasErrorMessage = (error: any): error is { message: string } => error.message;\n\nconst generateBidirectionalRelations = (metadata: EntityMetadata[]): void => {\n\tconst nonPrimaryKeyReferenceErrors: string[] = [];\n\n\tfor (const meta of metadata.filter((m) => !m.pivotTable)) {\n\t\tfor (const prop of meta.relations) {\n\t\t\tif (!prop.name.includes('Inverse')) {\n\t\t\t\tconst targetMeta = metadata.find((m) => m.className === prop.type);\n\t\t\t\tconst referencedTablePrimaryKeys = Utils.flatten(\n\t\t\t\t\t(targetMeta?.getPrimaryProps() ?? []).map((pk) => pk.fieldNames)\n\t\t\t\t);\n\n\t\t\t\t// Check any props that actually have fields in the database to store keys in for references to non-primary keys.\n\t\t\t\tif (prop.fieldNames?.length) {\n\t\t\t\t\tfor (const referencedColumn of prop.referencedColumnNames) {\n\t\t\t\t\t\tif (!referencedTablePrimaryKeys.includes(referencedColumn)) {\n\t\t\t\t\t\t\tnonPrimaryKeyReferenceErrors.push(\n\t\t\t\t\t\t\t\t` - Relationship between ${meta.className}.${prop.fieldNames.join(', ')} and ${targetMeta?.className}.${referencedColumn} is not supported.`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst newProp = {\n\t\t\t\t\tname: prop.name + 'Inverse',\n\t\t\t\t\ttype: meta.className,\n\t\t\t\t\tjoinColumns: prop.fieldNames,\n\t\t\t\t\treferencedTableName: meta.tableName,\n\t\t\t\t\treferencedColumnNames: referencedTablePrimaryKeys,\n\t\t\t\t\tmappedBy: prop.name,\n\t\t\t\t} as EntityProperty;\n\n\t\t\t\t// Add reference to the inverse entity\n\t\t\t\tconst inverseMeta = metadata.find((m) => m.className === meta.className);\n\t\t\t\tconst inverseProp = inverseMeta?.props.find((p) => p.name === newProp.mappedBy);\n\t\t\t\tif (inverseProp) inverseProp.inversedBy = newProp.name;\n\n\t\t\t\tif (prop.kind === ReferenceKind.MANY_TO_ONE) {\n\t\t\t\t\tconst name = pascalToCamelCaseString(meta.className);\n\t\t\t\t\tnewProp.name = pluralize(name);\n\t\t\t\t\tnewProp.kind = ReferenceKind.ONE_TO_MANY;\n\t\t\t\t} else if (prop.kind === ReferenceKind.ONE_TO_ONE && !prop.mappedBy) {\n\t\t\t\t\tnewProp.kind = ReferenceKind.ONE_TO_ONE;\n\t\t\t\t\tnewProp.nullable = true;\n\t\t\t\t} else if (prop.kind === ReferenceKind.MANY_TO_MANY && !prop.mappedBy) {\n\t\t\t\t\tconst name = pascalToCamelCaseString(meta.className);\n\t\t\t\t\tnewProp.name = pluralize(name);\n\t\t\t\t\tnewProp.kind = ReferenceKind.MANY_TO_MANY;\n\t\t\t\t} else {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\ttargetMeta?.addProperty(newProp);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (nonPrimaryKeyReferenceErrors.length) {\n\t\tthrow new IntrospectionError(\n\t\t\t`Unsupported Relationship${nonPrimaryKeyReferenceErrors.length === 1 ? '' : 's'} Detected`,\n\t\t\t`\\n${nonPrimaryKeyReferenceErrors.join('\\n')}\\n\\nForeign keys in Graphweaver currently need to reference the primary key of the other table.`\n\t\t);\n\t}\n};\n\nconst detectManyToManyRelations = (metadata: EntityMetadata[]) => {\n\tfor (const meta of metadata) {\n\t\tif (\n\t\t\tmeta.compositePK && // needs to have composite PK\n\t\t\tmeta.primaryKeys.length === meta.relations.length && // all relations are PKs\n\t\t\tmeta.relations.length === 2 && // there are exactly two relation properties\n\t\t\tmeta.relations.length === meta.props.length && // all properties are relations\n\t\t\tmeta.relations.every((prop) => prop.kind === ReferenceKind.MANY_TO_ONE) // all relations are m:1\n\t\t) {\n\t\t\tmeta.pivotTable = true;\n\t\t\tconst owner = metadata.find((m) => m.className === meta.relations[0].type);\n\t\t\tif (!owner) throw new Error('No Owner');\n\t\t\tconst name = pascalToCamelCaseString(meta.relations?.[1]?.type);\n\t\t\towner.addProperty({\n\t\t\t\tname: pluralize(name),\n\t\t\t\tkind: ReferenceKind.MANY_TO_MANY,\n\t\t\t\tpivotTable: meta.tableName,\n\t\t\t\ttype: meta.relations[1].type,\n\t\t\t\tjoinColumns: meta.relations[0].fieldNames,\n\t\t\t\tinverseJoinColumns: meta.relations[1].fieldNames,\n\t\t\t} as EntityProperty);\n\t\t}\n\t}\n};\n\nconst generateIdentifiedReferences = (metadata: EntityMetadata[]): void => {\n\tfor (const meta of metadata.filter((m) => !m.pivotTable)) {\n\t\tfor (const prop of meta.relations) {\n\t\t\tif ([ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(prop.kind)) {\n\t\t\t\tconst name = pascalToCamelCaseString(prop.type);\n\t\t\t\tprop.name = pluralize.singular(name);\n\t\t\t\tprop.ref = true;\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst generateSingularTypeReferences = (metadata: EntityMetadata[]): void => {\n\tfor (const meta of metadata.filter((m) => !m.pivotTable)) {\n\t\tmeta.className = pluralize.singular(meta.className);\n\t\tfor (const prop of meta.relations) {\n\t\t\tprop.type = pluralize.singular(prop.type);\n\t\t}\n\t}\n};\n\n// Convert properties like FirstName to firstName\nconst convertToCamelCasePropertyNames = (metadata: EntityMetadata[]): void => {\n\tfor (const meta of metadata.filter((m) => !m.pivotTable)) {\n\t\tconst props = Object.values(meta.properties);\n\t\tprops.forEach((prop) => {\n\t\t\tprop.name = pascalToCamelCaseString(prop.name);\n\t\t});\n\t}\n};\n\nconst assertUniqueForeignKeys = (table: DatabaseTable): void => {\n\tconst uniqueForeignKeys = new Set();\n\tconst definedForeignKeys = Object.values(table.getForeignKeys());\n\n\tfor (const foreignKey of definedForeignKeys) {\n\t\tconst { localTableName, referencedTableName, columnNames, referencedColumnNames } = foreignKey;\n\t\tconst serializedValue = JSON.stringify({\n\t\t\tlocalTableName,\n\t\t\tcolumnNames: columnNames.sort(),\n\t\t\treferencedTableName,\n\t\t\treferencedColumnNames: referencedColumnNames.sort(),\n\t\t});\n\n\t\tif (uniqueForeignKeys.has(serializedValue)) {\n\t\t\tthrow new Error(\n\t\t\t\t`\\n\\nImport Failed: Duplicate foreign keys detected on column/s (${columnNames.toString()}) in table \"${\n\t\t\t\t\ttable.name\n\t\t\t\t}\".`\n\t\t\t);\n\t\t}\n\n\t\tuniqueForeignKeys.add(serializedValue);\n\t}\n};\n\nconst convertSchemaToMetadata = async (\n\tschema: DatabaseSchema,\n\tplatform: AbstractSqlPlatform,\n\tnamingStrategy: NamingStrategy\n) => {\n\tconst helper = platform.getSchemaHelper();\n\n\tif (!helper) throw new Error('cannot connect to database');\n\n\tconst metadata = schema\n\t\t.getTables()\n\t\t.sort((a, b) => a.name.localeCompare(b.name))\n\t\t.map((table) => {\n\t\t\tassertUniqueForeignKeys(table);\n\t\t\treturn table.getEntityDeclaration(namingStrategy, helper, 'never');\n\t\t});\n\n\tif (metadata.length === 0) {\n\t\tthrow new IntrospectionError(\n\t\t\t`Warning: No tables found, this database is empty.`,\n\t\t\t`Make sure you have tables in this database and then try again.`\n\t\t);\n\t}\n\n\tconvertToCamelCasePropertyNames(metadata);\n\tdetectManyToManyRelations(metadata);\n\tgenerateIdentifiedReferences(metadata);\n\tgenerateBidirectionalRelations(metadata);\n\tgenerateSingularTypeReferences(metadata);\n\n\treturn metadata;\n};\n\nconst openConnection = async (type: DatabaseType, options: ConnectionOptions) => {\n\t// eslint-disable-next-line @typescript-eslint/no-var-requires\n\tconst module = require(`@mikro-orm/${type}`);\n\tconst PLATFORMS = {\n\t\tmysql: 'MySqlDriver',\n\t\tpostgresql: 'PostgreSqlDriver',\n\t\tsqlite: 'SqliteDriver',\n\t};\n\tawait ConnectionManager.connect(CONNECTION_MANAGER_ID, {\n\t\tmikroOrmConfig: {\n\t\t\tdriver: module[PLATFORMS[type]],\n\t\t\t...options.mikroOrmConfig,\n\t\t},\n\t});\n};\n\nconst closeConnection = async () => {\n\tconsole.log('Closing database connection...');\n\tawait ConnectionManager.close(CONNECTION_MANAGER_ID);\n\tconsole.log('Database connection closed.');\n};\n\ntype File =\n\t| DataEntityFile\n\t| SchemaEntityFile\n\t| SchemaIndexFile\n\t| DataEntityIndexFile\n\t| DataSourceIndexFile\n\t| DatabaseFile;\n\nexport const generate = async (databaseType: DatabaseType, options: ConnectionOptions) => {\n\ttry {\n\t\tawait openConnection(databaseType, options);\n\n\t\tconst database = ConnectionManager.database(CONNECTION_MANAGER_ID);\n\t\tif (!database)\n\t\t\tthrow new IntrospectionError(\n\t\t\t\t`Warning: Unable to connect to database.`,\n\t\t\t\t'Please check the connection settings and try again'\n\t\t\t);\n\n\t\tconst config = database.em.config;\n\t\tconst driver = database.em.getDriver();\n\t\tconst platform = driver.getPlatform();\n\t\tconst namingStrategy = config.getNamingStrategy();\n\t\tconst connection = driver.getConnection();\n\n\t\tconsole.log('Fetching database schema...');\n\t\tconst schema = await DatabaseSchema.create(connection, platform, config);\n\t\tconsole.log('Building metadata...');\n\t\tconst metadata = await convertSchemaToMetadata(schema, platform, namingStrategy);\n\n\t\t// Build a lookup for efficient cross-referencing later.\n\t\tconst entityLookup = new Map<string, EntityMetadata<any>>();\n\t\tfor (const meta of metadata) {\n\t\t\tentityLookup.set(meta.className, meta);\n\t\t}\n\n\t\tconst source: File[] = [];\n\n\t\tconst summaryOfEntities: { name: string; entityFilePath: string; schemaFilePath: string }[] =\n\t\t\t[];\n\n\t\tfor (const meta of metadata) {\n\t\t\tif (!meta.pivotTable) {\n\t\t\t\tconst dataEntityFile = new DataEntityFile(meta, namingStrategy, platform, databaseType);\n\t\t\t\tconst schemaEntityFile = new SchemaEntityFile(meta, namingStrategy, platform, entityLookup);\n\t\t\t\tsource.push(dataEntityFile, schemaEntityFile);\n\t\t\t\tsummaryOfEntities.push({\n\t\t\t\t\tname: meta.className,\n\t\t\t\t\tentityFilePath: `${dataEntityFile.getBasePath()}${dataEntityFile.getBaseName()}`,\n\t\t\t\t\tschemaFilePath: `${schemaEntityFile.getBasePath()}${schemaEntityFile.getBaseName()}`,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Export all the entities from the data source directory\n\t\tsource.push(new DataEntityIndexFile(metadata, databaseType));\n\t\t// Export the data source from the entities directory\n\t\tsource.push(new DataSourceIndexFile(databaseType));\n\t\t// Export the data source from the entities directory\n\t\tsource.push(new SchemaIndexFile(metadata));\n\t\t// Export the database connection to its own file\n\t\tsource.push(new DatabaseFile(databaseType, options));\n\n\t\tconst files = source.map((file) => {\n\t\t\treturn {\n\t\t\t\tpath: file.getBasePath(),\n\t\t\t\tname: file.getBaseName(),\n\t\t\t\tcontents: file.generate(),\n\t\t\t\tneedOverwriteWarning: !![DatabaseFile, SchemaIndexFile].some((cls) => file instanceof cls),\n\t\t\t};\n\t\t});\n\n\t\tawait closeConnection();\n\n\t\tconsole.log('\\nImport Summary:');\n\t\tconsole.table(summaryOfEntities);\n\t\tconsole.log(\n\t\t\t`\\nImported ${summaryOfEntities.length} entities, creating the above files in your Graphweaver project. \\n`\n\t\t);\n\n\t\treturn files;\n\t} catch (err) {\n\t\tif (err instanceof IntrospectionError) throw err;\n\n\t\tconsole.error('Got error during introspection:');\n\t\tconsole.error(err);\n\n\t\tthrow new IntrospectionError(\n\t\t\t`Warning: Unable to connect to database.`,\n\t\t\thasErrorMessage(err) ? err.message : 'Please check the connection settings and try again'\n\t\t);\n\t}\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmE;AACnE,kBAMO;AACP,uBAAsB;AAEtB,sBAAmE;AACnE,mBAOO;AACP,mBAAwC;AAExC,MAAM,wBAAwB;AAEvB,MAAM,2BAA2B,MAAM;AAAA,EAE7C,YACW,QAAQ,IAClB,UAAU,IACT;AACD,UAAM,OAAO;AAHH;AAIV,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,UAAU;AAAA,EAChB;AACD;AAEA,MAAM,kBAAkB,CAAC,UAA6C,MAAM;AAE5E,MAAM,iCAAiC,CAAC,aAAqC;AAC5E,QAAM,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CAAC;AAEnD,UAAM,QAAQ,OAAO,IAAI,CAAC,SAAS;AAClC,aAAO;AAAA,QACN,MAAM,KAAK,YAAY;AAAA,QACvB,MAAM,KAAK,YAAY;AAAA,QACvB,UAAU,KAAK,SAAS;AAAA,QACxB,sBAAsB,CAAC,CAAC,CAAC,2BAAc,4BAAe,EAAE,KAAK,CAAC,QAAQ,gBAAgB,GAAG;AAAA,MAC1F;AAAA,IACD,CAAC;AAED,UAAM,gBAAgB;AAEtB,YAAQ,IAAI,mBAAmB;AAC/B,YAAQ,MAAM,iBAAiB;AAC/B,YAAQ;AAAA,MACP;AAAA,WAAc,kBAAkB,MAAM;AAAA;AAAA,IACvC;AAEA,WAAO;AAAA,EACR,SAAS,KAAK;AACb,QAAI,eAAe,mBAAoB,OAAM;AAE7C,YAAQ,MAAM,iCAAiC;AAC/C,YAAQ,MAAM,GAAG;AAEjB,UAAM,IAAI;AAAA,MACT;AAAA,MACA,gBAAgB,GAAG,IAAI,IAAI,UAAU;AAAA,IACtC;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["pluralize", "module"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exogee/graphweaver-mikroorm",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "MikroORM backend for @exogee/graphweaver",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -12,40 +12,40 @@
|
|
|
12
12
|
"lib"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@apollo/server": "4.
|
|
16
|
-
"@aws-sdk/client-secrets-manager": "3.
|
|
15
|
+
"@apollo/server": "4.11.0",
|
|
16
|
+
"@aws-sdk/client-secrets-manager": "3.624.0",
|
|
17
17
|
"dataloader": "2.2.2",
|
|
18
18
|
"decimal.js": "10.4.3",
|
|
19
19
|
"dotenv": "16.4.5",
|
|
20
20
|
"graphql": "16.9.0",
|
|
21
21
|
"pluralize": "8.0.0",
|
|
22
22
|
"reflect-metadata": "0.2.2",
|
|
23
|
-
"@exogee/graphweaver": "2.1
|
|
24
|
-
"@exogee/graphweaver
|
|
25
|
-
"@exogee/logger": "2.1
|
|
23
|
+
"@exogee/graphweaver-server": "2.2.1",
|
|
24
|
+
"@exogee/graphweaver": "2.2.1",
|
|
25
|
+
"@exogee/logger": "2.2.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@mikro-orm/core": "6.3.
|
|
29
|
-
"@mikro-orm/knex": "6.3.
|
|
30
|
-
"@mikro-orm/mysql": "6.3.
|
|
31
|
-
"@mikro-orm/postgresql": "6.3.
|
|
32
|
-
"@mikro-orm/sqlite": "6.3.
|
|
33
|
-
"@types/node": "22.
|
|
28
|
+
"@mikro-orm/core": "6.3.5",
|
|
29
|
+
"@mikro-orm/knex": "6.3.5",
|
|
30
|
+
"@mikro-orm/mysql": "6.3.5",
|
|
31
|
+
"@mikro-orm/postgresql": "6.3.5",
|
|
32
|
+
"@mikro-orm/sqlite": "6.3.5",
|
|
33
|
+
"@types/node": "22.2.0",
|
|
34
34
|
"@types/pluralize": "0.0.33",
|
|
35
35
|
"esbuild": "0.23.0",
|
|
36
36
|
"glob": "10.4.3",
|
|
37
|
-
"
|
|
37
|
+
"tsx": "4.17.0",
|
|
38
38
|
"typescript": "5.5.4"
|
|
39
39
|
},
|
|
40
40
|
"optionalDependencies": {
|
|
41
|
-
"@mikro-orm/knex": "6.3.
|
|
42
|
-
"@mikro-orm/mysql": "6.3.
|
|
43
|
-
"@mikro-orm/postgresql": "6.3.
|
|
44
|
-
"@mikro-orm/sqlite": "6.3.
|
|
41
|
+
"@mikro-orm/knex": "6.3.5",
|
|
42
|
+
"@mikro-orm/mysql": "6.3.5",
|
|
43
|
+
"@mikro-orm/postgresql": "6.3.5",
|
|
44
|
+
"@mikro-orm/sqlite": "6.3.5"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@mikro-orm/core": "6.3.
|
|
48
|
-
"@mikro-orm/knex": "6.3.
|
|
47
|
+
"@mikro-orm/core": "6.3.5",
|
|
48
|
+
"@mikro-orm/knex": "6.3.5"
|
|
49
49
|
},
|
|
50
50
|
"keywords": [
|
|
51
51
|
"graphql",
|
|
@@ -61,9 +61,10 @@
|
|
|
61
61
|
"build": "npm run build:js && npm run build:types",
|
|
62
62
|
"build:js": "node build.js",
|
|
63
63
|
"build:types": "tsc --emitDeclarationOnly",
|
|
64
|
+
"generate:schema": "tsx ./src/utils/generate-db-schema.ts",
|
|
64
65
|
"package:pack": "pnpm pack",
|
|
65
66
|
"prettier": "prettier --write src/**/*.ts",
|
|
66
|
-
"
|
|
67
|
+
"test-introspection": "tsx scripts/test-introspection.ts",
|
|
67
68
|
"version": "npm version --no-git-tag-version"
|
|
68
69
|
}
|
|
69
70
|
}
|