typeorm 0.3.6-dev.7dfb69f → 0.3.6-dev.862a402
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/browser/decorator/options/ColumnOptions.d.ts +8 -0
- package/browser/decorator/options/ColumnOptions.js.map +1 -1
- package/browser/decorator/options/JoinColumnOptions.d.ts +4 -0
- package/browser/decorator/options/JoinColumnOptions.js.map +1 -1
- package/browser/decorator/options/PrimaryGeneratedColumnIdentityOptions.d.ts +4 -0
- package/browser/decorator/options/PrimaryGeneratedColumnIdentityOptions.js.map +1 -1
- package/browser/decorator/options/PrimaryGeneratedColumnNumericOptions.d.ts +4 -0
- package/browser/decorator/options/PrimaryGeneratedColumnNumericOptions.js.map +1 -1
- package/browser/decorator/options/PrimaryGeneratedColumnUUIDOptions.d.ts +4 -0
- package/browser/decorator/options/PrimaryGeneratedColumnUUIDOptions.js.map +1 -1
- package/browser/decorator/relations/JoinColumn.js +1 -0
- package/browser/decorator/relations/JoinColumn.js.map +1 -1
- package/browser/driver/aurora-mysql/AuroraMysqlDriver.d.ts +1 -1
- package/browser/driver/aurora-mysql/AuroraMysqlDriver.js.map +1 -1
- package/browser/driver/cockroachdb/CockroachQueryRunner.d.ts +3 -3
- package/browser/driver/cockroachdb/CockroachQueryRunner.js +100 -22
- package/browser/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/browser/driver/mongodb/typings.d.ts +5 -5
- package/browser/driver/mongodb/typings.js.map +1 -1
- package/browser/driver/mysql/MysqlQueryRunner.js +16 -0
- package/browser/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/browser/driver/oracle/OracleQueryRunner.d.ts +3 -3
- package/browser/driver/oracle/OracleQueryRunner.js +98 -21
- package/browser/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/browser/driver/postgres/PostgresQueryRunner.d.ts +3 -3
- package/browser/driver/postgres/PostgresQueryRunner.js +99 -21
- package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js +59 -15
- package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +53 -12
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/browser/driver/sqlserver/SqlServerQueryRunner.d.ts +3 -3
- package/browser/driver/sqlserver/SqlServerQueryRunner.js +100 -22
- package/browser/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/browser/driver/sqlserver/authentication/AzureActiveDirectoryAccessTokenAuthentication.d.ts +1 -1
- package/browser/driver/sqlserver/authentication/AzureActiveDirectoryAccessTokenAuthentication.js.map +1 -1
- package/browser/driver/sqlserver/authentication/AzureActiveDirectoryMsiAppServiceAuthentication.d.ts +2 -2
- package/browser/driver/sqlserver/authentication/AzureActiveDirectoryMsiAppServiceAuthentication.js.map +1 -1
- package/browser/driver/sqlserver/authentication/AzureActiveDirectoryMsiVmAuthentication.d.ts +2 -2
- package/browser/driver/sqlserver/authentication/AzureActiveDirectoryMsiVmAuthentication.js.map +1 -1
- package/browser/driver/sqlserver/authentication/AzureActiveDirectoryPasswordAuthentication.d.ts +2 -2
- package/browser/driver/sqlserver/authentication/AzureActiveDirectoryPasswordAuthentication.js.map +1 -1
- package/browser/entity-manager/EntityManager.js +1 -1
- package/browser/entity-manager/EntityManager.js.map +1 -1
- package/browser/entity-schema/EntitySchemaColumnOptions.d.ts +4 -0
- package/browser/entity-schema/EntitySchemaColumnOptions.js.map +1 -1
- package/browser/entity-schema/EntitySchemaTransformer.js +2 -0
- package/browser/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/browser/metadata/ColumnMetadata.d.ts +8 -0
- package/browser/metadata/ColumnMetadata.js +8 -0
- package/browser/metadata/ColumnMetadata.js.map +1 -1
- package/browser/metadata/EntityMetadata.js +1 -1
- package/browser/metadata/EntityMetadata.js.map +1 -1
- package/browser/metadata/ForeignKeyMetadata.d.ts +7 -0
- package/browser/metadata/ForeignKeyMetadata.js +4 -1
- package/browser/metadata/ForeignKeyMetadata.js.map +1 -1
- package/browser/metadata-args/JoinColumnMetadataArgs.d.ts +4 -0
- package/browser/metadata-args/JoinColumnMetadataArgs.js.map +1 -1
- package/browser/metadata-builder/EntityMetadataValidator.js +9 -0
- package/browser/metadata-builder/EntityMetadataValidator.js.map +1 -1
- package/browser/metadata-builder/JunctionEntityMetadataBuilder.js +5 -0
- package/browser/metadata-builder/JunctionEntityMetadataBuilder.js.map +1 -1
- package/browser/metadata-builder/RelationJoinColumnBuilder.js +2 -0
- package/browser/metadata-builder/RelationJoinColumnBuilder.js.map +1 -1
- package/browser/migration/MigrationExecutor.js +1 -1
- package/browser/migration/MigrationExecutor.js.map +1 -1
- package/browser/persistence/SubjectDatabaseEntityLoader.d.ts +1 -1
- package/browser/persistence/SubjectDatabaseEntityLoader.js +1 -1
- package/browser/persistence/SubjectDatabaseEntityLoader.js.map +1 -1
- package/browser/persistence/SubjectExecutor.js +1 -1
- package/browser/persistence/SubjectExecutor.js.map +1 -1
- package/browser/persistence/subject-builder/CascadesSubjectBuilder.d.ts +1 -1
- package/browser/persistence/subject-builder/CascadesSubjectBuilder.js +1 -1
- package/browser/persistence/subject-builder/CascadesSubjectBuilder.js.map +1 -1
- package/browser/persistence/subject-builder/ManyToManySubjectBuilder.js +1 -1
- package/browser/persistence/subject-builder/ManyToManySubjectBuilder.js.map +1 -1
- package/browser/persistence/subject-builder/OneToOneInverseSideSubjectBuilder.js +1 -1
- package/browser/persistence/subject-builder/OneToOneInverseSideSubjectBuilder.js.map +1 -1
- package/browser/query-builder/QueryBuilder.d.ts +1 -1
- package/browser/query-builder/QueryBuilder.js +3 -5
- package/browser/query-builder/QueryBuilder.js.map +1 -1
- package/browser/query-builder/QueryExpressionMap.d.ts +1 -1
- package/browser/query-builder/QueryExpressionMap.js +1 -1
- package/browser/query-builder/QueryExpressionMap.js.map +1 -1
- package/browser/query-builder/ReturningResultsEntityUpdator.js +2 -2
- package/browser/query-builder/ReturningResultsEntityUpdator.js.map +1 -1
- package/browser/query-runner/QueryRunner.d.ts +2 -2
- package/browser/query-runner/QueryRunner.js.map +1 -1
- package/browser/schema-builder/options/TableColumnOptions.d.ts +8 -0
- package/browser/schema-builder/options/TableColumnOptions.js.map +1 -1
- package/browser/schema-builder/options/TableForeignKeyOptions.d.ts +1 -1
- package/browser/schema-builder/options/TableForeignKeyOptions.js.map +1 -1
- package/browser/schema-builder/table/TableColumn.d.ts +4 -0
- package/browser/schema-builder/table/TableColumn.js +2 -0
- package/browser/schema-builder/table/TableColumn.js.map +1 -1
- package/browser/schema-builder/util/TableUtils.js +1 -0
- package/browser/schema-builder/util/TableUtils.js.map +1 -1
- package/browser/util/OrmUtils.d.ts +1 -1
- package/browser/util/OrmUtils.js +4 -4
- package/browser/util/OrmUtils.js.map +1 -1
- package/browser/util/escapeRegExp.d.ts +1 -0
- package/browser/util/escapeRegExp.js +6 -0
- package/browser/util/escapeRegExp.js.map +1 -0
- package/commands/InitCommand.js +1 -1
- package/commands/InitCommand.js.map +1 -1
- package/commands/MigrationGenerateCommand.js +3 -2
- package/commands/MigrationGenerateCommand.js.map +1 -1
- package/decorator/options/ColumnOptions.d.ts +8 -0
- package/decorator/options/ColumnOptions.js.map +1 -1
- package/decorator/options/JoinColumnOptions.d.ts +4 -0
- package/decorator/options/JoinColumnOptions.js.map +1 -1
- package/decorator/options/PrimaryGeneratedColumnIdentityOptions.d.ts +4 -0
- package/decorator/options/PrimaryGeneratedColumnIdentityOptions.js.map +1 -1
- package/decorator/options/PrimaryGeneratedColumnNumericOptions.d.ts +4 -0
- package/decorator/options/PrimaryGeneratedColumnNumericOptions.js.map +1 -1
- package/decorator/options/PrimaryGeneratedColumnUUIDOptions.d.ts +4 -0
- package/decorator/options/PrimaryGeneratedColumnUUIDOptions.js.map +1 -1
- package/decorator/relations/JoinColumn.js +1 -0
- package/decorator/relations/JoinColumn.js.map +1 -1
- package/driver/aurora-mysql/AuroraMysqlDriver.d.ts +1 -1
- package/driver/aurora-mysql/AuroraMysqlDriver.js.map +1 -1
- package/driver/cockroachdb/CockroachQueryRunner.d.ts +3 -3
- package/driver/cockroachdb/CockroachQueryRunner.js +100 -22
- package/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/driver/mongodb/typings.d.ts +5 -5
- package/driver/mongodb/typings.js.map +1 -1
- package/driver/mysql/MysqlQueryRunner.js +16 -0
- package/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/driver/oracle/OracleQueryRunner.d.ts +3 -3
- package/driver/oracle/OracleQueryRunner.js +98 -21
- package/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/driver/postgres/PostgresQueryRunner.d.ts +3 -3
- package/driver/postgres/PostgresQueryRunner.js +99 -21
- package/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteDriver.js +59 -15
- package/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +53 -12
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/driver/sqlserver/SqlServerQueryRunner.d.ts +3 -3
- package/driver/sqlserver/SqlServerQueryRunner.js +100 -22
- package/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/driver/sqlserver/authentication/AzureActiveDirectoryAccessTokenAuthentication.d.ts +1 -1
- package/driver/sqlserver/authentication/AzureActiveDirectoryAccessTokenAuthentication.js.map +1 -1
- package/driver/sqlserver/authentication/AzureActiveDirectoryMsiAppServiceAuthentication.d.ts +2 -2
- package/driver/sqlserver/authentication/AzureActiveDirectoryMsiAppServiceAuthentication.js.map +1 -1
- package/driver/sqlserver/authentication/AzureActiveDirectoryMsiVmAuthentication.d.ts +2 -2
- package/driver/sqlserver/authentication/AzureActiveDirectoryMsiVmAuthentication.js.map +1 -1
- package/driver/sqlserver/authentication/AzureActiveDirectoryPasswordAuthentication.d.ts +2 -2
- package/driver/sqlserver/authentication/AzureActiveDirectoryPasswordAuthentication.js.map +1 -1
- package/entity-manager/EntityManager.js +1 -1
- package/entity-manager/EntityManager.js.map +1 -1
- package/entity-schema/EntitySchemaColumnOptions.d.ts +4 -0
- package/entity-schema/EntitySchemaColumnOptions.js.map +1 -1
- package/entity-schema/EntitySchemaTransformer.js +2 -0
- package/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/metadata/ColumnMetadata.d.ts +8 -0
- package/metadata/ColumnMetadata.js +8 -0
- package/metadata/ColumnMetadata.js.map +1 -1
- package/metadata/EntityMetadata.js +1 -1
- package/metadata/EntityMetadata.js.map +1 -1
- package/metadata/ForeignKeyMetadata.d.ts +7 -0
- package/metadata/ForeignKeyMetadata.js +4 -1
- package/metadata/ForeignKeyMetadata.js.map +1 -1
- package/metadata-args/JoinColumnMetadataArgs.d.ts +4 -0
- package/metadata-args/JoinColumnMetadataArgs.js.map +1 -1
- package/metadata-builder/EntityMetadataValidator.js +9 -0
- package/metadata-builder/EntityMetadataValidator.js.map +1 -1
- package/metadata-builder/JunctionEntityMetadataBuilder.js +5 -0
- package/metadata-builder/JunctionEntityMetadataBuilder.js.map +1 -1
- package/metadata-builder/RelationJoinColumnBuilder.js +2 -0
- package/metadata-builder/RelationJoinColumnBuilder.js.map +1 -1
- package/migration/MigrationExecutor.js +1 -1
- package/migration/MigrationExecutor.js.map +1 -1
- package/package.json +1 -1
- package/persistence/SubjectDatabaseEntityLoader.d.ts +1 -1
- package/persistence/SubjectDatabaseEntityLoader.js +1 -1
- package/persistence/SubjectDatabaseEntityLoader.js.map +1 -1
- package/persistence/SubjectExecutor.js +1 -1
- package/persistence/SubjectExecutor.js.map +1 -1
- package/persistence/subject-builder/CascadesSubjectBuilder.d.ts +1 -1
- package/persistence/subject-builder/CascadesSubjectBuilder.js +1 -1
- package/persistence/subject-builder/CascadesSubjectBuilder.js.map +1 -1
- package/persistence/subject-builder/ManyToManySubjectBuilder.js +1 -1
- package/persistence/subject-builder/ManyToManySubjectBuilder.js.map +1 -1
- package/persistence/subject-builder/OneToOneInverseSideSubjectBuilder.js +1 -1
- package/persistence/subject-builder/OneToOneInverseSideSubjectBuilder.js.map +1 -1
- package/query-builder/QueryBuilder.d.ts +1 -1
- package/query-builder/QueryBuilder.js +5 -7
- package/query-builder/QueryBuilder.js.map +1 -1
- package/query-builder/QueryExpressionMap.d.ts +1 -1
- package/query-builder/QueryExpressionMap.js +1 -1
- package/query-builder/QueryExpressionMap.js.map +1 -1
- package/query-builder/ReturningResultsEntityUpdator.js +2 -2
- package/query-builder/ReturningResultsEntityUpdator.js.map +1 -1
- package/query-runner/QueryRunner.d.ts +2 -2
- package/query-runner/QueryRunner.js.map +1 -1
- package/schema-builder/options/TableColumnOptions.d.ts +8 -0
- package/schema-builder/options/TableColumnOptions.js.map +1 -1
- package/schema-builder/options/TableForeignKeyOptions.d.ts +1 -1
- package/schema-builder/options/TableForeignKeyOptions.js.map +1 -1
- package/schema-builder/table/TableColumn.d.ts +4 -0
- package/schema-builder/table/TableColumn.js +2 -0
- package/schema-builder/table/TableColumn.js.map +1 -1
- package/schema-builder/util/TableUtils.js +1 -0
- package/schema-builder/util/TableUtils.js.map +1 -1
- package/util/OrmUtils.d.ts +1 -1
- package/util/OrmUtils.js +4 -4
- package/util/OrmUtils.js.map +1 -1
- package/util/escapeRegExp.d.ts +1 -0
- package/util/escapeRegExp.js +10 -0
- package/util/escapeRegExp.js.map +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/util/OrmUtils.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,QAAQ;IACjB,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,MAAM,CAAC,KAAK,CAAI,KAAU,EAAE,IAAY;QACpC,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC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C,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAC1D;wBACE,OAAO,KAAK,CAAA;qBACf;oBAED,SAAS,CAAC,GAAG,EAAE,CAAA;oBACf,UAAU,CAAC,GAAG,EAAE,CAAA;oBAChB,MAAK;gBAET;oBACI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;wBACf,OAAO,KAAK,CAAA;qBACf;oBACD,MAAK;aACZ;SACJ;QAED,OAAO,IAAI,CAAA;IACf,CAAC;CACJ","file":"OrmUtils.js","sourcesContent":["import { ObjectLiteral } from \"../common/ObjectLiteral\"\n\nexport class OrmUtils {\n // -------------------------------------------------------------------------\n // Public methods\n // -------------------------------------------------------------------------\n\n /**\n * Chunks array into pieces.\n */\n static chunk<T>(array: T[], size: number): T[][] {\n return Array.from(Array(Math.ceil(array.length / size)), (_, i) => {\n return array.slice(i * size, i * size + size)\n })\n }\n\n static splitClassesAndStrings<T>(\n clsesAndStrings: (string | T)[],\n ): [T[], string[]] {\n return [\n clsesAndStrings.filter((cls): cls is T => typeof cls !== \"string\"),\n clsesAndStrings.filter(\n (str): str is string => typeof str === \"string\",\n ),\n ]\n }\n\n static groupBy<T, R>(\n array: T[],\n propertyCallback: (item: T) => R,\n ): { id: R; items: T[] }[] {\n return array.reduce((groupedArray, value) => {\n const key = propertyCallback(value)\n let grouped = groupedArray.find((i) => i.id === key)\n if (!grouped) {\n grouped = { id: key, items: [] }\n groupedArray.push(grouped)\n }\n grouped.items.push(value)\n return groupedArray\n }, [] as Array<{ id: R; items: T[] }>)\n }\n\n static uniq<T>(array: T[], criteria?: (item: T) => any): T[]\n static uniq<T, K extends keyof T>(array: T[], property: K): T[]\n static uniq<T, K extends keyof T>(\n array: T[],\n criteriaOrProperty?: ((item: T) => any) | K,\n ): T[] {\n return array.reduce((uniqueArray, item) => {\n let found: boolean = false\n if (typeof criteriaOrProperty === \"function\") {\n const itemValue = criteriaOrProperty(item)\n found = !!uniqueArray.find(\n (uniqueItem) =>\n criteriaOrProperty(uniqueItem) === itemValue,\n )\n } else if (typeof criteriaOrProperty === \"string\") {\n found = !!uniqueArray.find(\n (uniqueItem) =>\n uniqueItem[criteriaOrProperty] ===\n item[criteriaOrProperty],\n )\n } else {\n found = uniqueArray.indexOf(item) !== -1\n }\n\n if (!found) uniqueArray.push(item)\n\n return uniqueArray\n }, [] as T[])\n }\n\n // Checks if it's an object made by Object.create(null), {} or new Object()\n private static isPlainObject(item: any) {\n if (item === null || item === undefined) {\n return false\n }\n\n return !item.constructor || item.constructor === Object\n }\n\n private static mergeArrayKey(\n target: any,\n key: number,\n value: any,\n memo: Map<any, any>,\n ) {\n // Have we seen this before? Prevent infinite recursion.\n if (memo.has(value)) {\n target[key] = memo.get(value)\n return\n }\n\n if (value instanceof Promise) {\n // Skip promises entirely.\n // This is a hold-over from the old code & is because we don't want to pull in\n // the lazy fields. Ideally we'd remove these promises via another function first\n // but for now we have to do it here.\n return\n }\n\n if (!this.isPlainObject(value) && !Array.isArray(value)) {\n target[key] = value\n return\n }\n\n if (!target[key]) {\n target[key] = Array.isArray(value) ? [] : {}\n }\n\n memo.set(value, target[key])\n this.merge(target[key], value, memo)\n memo.delete(value)\n }\n\n private static mergeObjectKey(\n target: any,\n key: string,\n value: any,\n memo: Map<any, any>,\n ) {\n // Have we seen this before? Prevent infinite recursion.\n if (memo.has(value)) {\n Object.assign(target, { [key]: memo.get(value) })\n return\n }\n\n if (value instanceof Promise) {\n // Skip promises entirely.\n // This is a hold-over from the old code & is because we don't want to pull in\n // the lazy fields. Ideally we'd remove these promises via another function first\n // but for now we have to do it here.\n return\n }\n\n if (!this.isPlainObject(value) && !Array.isArray(value)) {\n Object.assign(target, { [key]: value })\n return\n }\n\n if (!target[key]) {\n Object.assign(target, { [key]: Array.isArray(value) ? [] : {} })\n }\n\n memo.set(value, target[key])\n this.merge(target[key], value, memo)\n memo.delete(value)\n }\n\n private static merge(\n target: any,\n source: any,\n memo: Map<any, any> = new Map(),\n ): any {\n if (this.isPlainObject(target) && this.isPlainObject(source)) {\n for (const key of Object.keys(source)) {\n this.mergeObjectKey(target, key, source[key], memo)\n }\n }\n\n if (Array.isArray(target) && Array.isArray(source)) {\n for (let key = 0; key < source.length; key++) {\n this.mergeArrayKey(target, key, source[key], memo)\n }\n }\n }\n\n /**\n * Deep Object.assign.\n */\n static mergeDeep(target: any, ...sources: any[]): any {\n if (!sources.length) {\n return target\n }\n\n for (const source of sources) {\n OrmUtils.merge(target, source)\n }\n\n return target\n }\n\n /**\n * Deep compare objects.\n *\n * @see http://stackoverflow.com/a/1144249\n */\n static deepCompare(...args: any[]): boolean {\n let i: any, l: any, leftChain: any, rightChain: any\n\n if (arguments.length < 1) {\n return true // Die silently? Don't know how to handle such case, please help...\n // throw \"Need two or more arguments to compare\";\n }\n\n for (i = 1, l = arguments.length; i < l; i++) {\n leftChain = [] // Todo: this can be cached\n rightChain = []\n\n if (\n !this.compare2Objects(\n leftChain,\n rightChain,\n arguments[0],\n arguments[i],\n )\n ) {\n return false\n }\n }\n\n return true\n }\n\n /**\n * Gets deeper value of object.\n */\n static deepValue(obj: ObjectLiteral, path: string) {\n const segments = path.split(\".\")\n for (let i = 0, len = segments.length; i < len; i++) {\n obj = obj[segments[i]]\n }\n return obj\n }\n\n static replaceEmptyObjectsWithBooleans(obj: any) {\n for (let key in obj) {\n if (obj[key] && typeof obj[key] === \"object\") {\n if (Object.keys(obj[key]).length === 0) {\n obj[key] = true\n } else {\n this.replaceEmptyObjectsWithBooleans(obj[key])\n }\n }\n }\n }\n\n static propertyPathsToTruthyObject(paths: string[]) {\n let obj: any = {}\n for (let path of paths) {\n const props = path.split(\".\")\n if (!props.length) continue\n\n if (!obj[props[0]] || obj[props[0]] === true) {\n obj[props[0]] = {}\n }\n let recursiveChild = obj[props[0]]\n for (let [key, prop] of props.entries()) {\n if (key === 0) continue\n\n if (recursiveChild[prop]) {\n recursiveChild = recursiveChild[prop]\n } else if (key === props.length - 1) {\n recursiveChild[prop] = {}\n recursiveChild = null\n } else {\n recursiveChild[prop] = {}\n recursiveChild = recursiveChild[prop]\n }\n }\n }\n this.replaceEmptyObjectsWithBooleans(obj)\n return obj\n }\n\n /**\n * Check if two entity-id-maps are the same\n */\n static compareIds(\n firstId: ObjectLiteral | undefined,\n secondId: ObjectLiteral | undefined,\n ): boolean {\n if (\n firstId === undefined ||\n firstId === null ||\n secondId === undefined ||\n secondId === null\n )\n return false\n\n // Optimized version for the common case\n if (\n ((typeof firstId.id === \"string\" &&\n typeof secondId.id === \"string\") ||\n (typeof firstId.id === \"number\" &&\n typeof secondId.id === \"number\")) &&\n Object.keys(firstId).length === 1 &&\n Object.keys(secondId).length === 1\n ) {\n return firstId.id === secondId.id\n }\n\n return OrmUtils.deepCompare(firstId, secondId)\n }\n\n /**\n * Transforms given value into boolean value.\n */\n static toBoolean(value: any): boolean {\n if (typeof value === \"boolean\") return value\n\n if (typeof value === \"string\") return value === \"true\" || value === \"1\"\n\n if (typeof value === \"number\") return value > 0\n\n return false\n }\n\n /**\n * Composes an object from the given array of keys and values.\n */\n static zipObject(keys: any[], values: any[]): ObjectLiteral {\n return keys.reduce((object, column, index) => {\n object[column] = values[index]\n return object\n }, {} as ObjectLiteral)\n }\n\n /**\n * Compares two arrays.\n */\n static isArraysEqual(arr1: any[], arr2: any[]): boolean {\n if (arr1.length !== arr2.length) return false\n return arr1.every((element) => {\n return arr2.indexOf(element) !== -1\n })\n }\n\n static areMutuallyExclusive<T>(...lists: T[][]): boolean {\n const haveSharedObjects = lists.some((list) => {\n const otherLists = lists.filter((otherList) => otherList !== list)\n return list.some((item) =>\n otherLists.some((otherList) => otherList.includes(item)),\n )\n })\n return !haveSharedObjects\n }\n\n // -------------------------------------------------------------------------\n // Private methods\n // -------------------------------------------------------------------------\n\n private static compare2Objects(\n leftChain: any,\n rightChain: any,\n x: any,\n y: any,\n ) {\n let p\n\n // remember that NaN === NaN returns false\n // and isNaN(undefined) returns true\n if (Number.isNaN(x) && Number.isNaN(y)) return true\n\n // Compare primitives and functions.\n // Check if both arguments link to the same object.\n // Especially useful on the step where we compare prototypes\n if (x === y) return true\n\n // Unequal, but either is null or undefined (use case: jsonb comparasion)\n // PR #3776, todo: add tests\n if (x === null || y === null || x === undefined || y === undefined)\n return false\n\n // Fix the buffer compare bug.\n // See: https://github.com/typeorm/typeorm/issues/3654\n if (\n (typeof x.equals === \"function\" ||\n typeof x.equals === \"function\") &&\n x.equals(y)\n )\n return true\n\n // Works in case when functions are created in constructor.\n // Comparing dates is a common scenario. Another built-ins?\n // We can even handle functions passed across iframes\n if (\n (typeof x === \"function\" && typeof y === \"function\") ||\n (x instanceof Date && y instanceof Date) ||\n (x instanceof RegExp && y instanceof RegExp) ||\n (typeof x === \"string\" && typeof y === \"string\") ||\n (typeof x === \"number\" && typeof y === \"number\")\n )\n return x.toString() === y.toString()\n\n // At last checking prototypes as good as we can\n if (!(typeof x === \"object\" && typeof y === \"object\")) return false\n\n if (x.isPrototypeOf(y) || y.isPrototypeOf(x)) return false\n\n if (x.constructor !== y.constructor) return false\n\n if (x.prototype !== y.prototype) return false\n\n // Check for infinitive linking loops\n if (leftChain.indexOf(x) > -1 || rightChain.indexOf(y) > -1)\n return false\n\n // Quick checking of one object being a subset of another.\n // todo: cache the structure of arguments[0] for performance\n for (p in y) {\n if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {\n return false\n } else if (typeof y[p] !== typeof x[p]) {\n return false\n }\n }\n\n for (p in x) {\n if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {\n return false\n } else if (typeof y[p] !== typeof x[p]) {\n return false\n }\n\n switch (typeof x[p]) {\n case \"object\":\n case \"function\":\n leftChain.push(x)\n rightChain.push(y)\n\n if (\n !this.compare2Objects(leftChain, rightChain, x[p], y[p])\n ) {\n return false\n }\n\n leftChain.pop()\n rightChain.pop()\n break\n\n default:\n if (x[p] !== y[p]) {\n return false\n }\n break\n }\n }\n\n return true\n }\n}\n"],"sourceRoot":".."}
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AE;gBACpC,OAAO,KAAK,CAAA;aACf;YAED,QAAQ,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;gBACjB,KAAK,QAAQ,CAAC;gBACd,KAAK,UAAU;oBACX,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;oBACjB,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;oBAElB,IACI,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAC1D;wBACE,OAAO,KAAK,CAAA;qBACf;oBAED,SAAS,CAAC,GAAG,EAAE,CAAA;oBACf,UAAU,CAAC,GAAG,EAAE,CAAA;oBAChB,MAAK;gBAET;oBACI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;wBACf,OAAO,KAAK,CAAA;qBACf;oBACD,MAAK;aACZ;SACJ;QAED,OAAO,IAAI,CAAA;IACf,CAAC;CACJ","file":"OrmUtils.js","sourcesContent":["import { ObjectLiteral } from \"../common/ObjectLiteral\"\n\nexport class OrmUtils {\n // -------------------------------------------------------------------------\n // Public methods\n // -------------------------------------------------------------------------\n\n /**\n * Chunks array into pieces.\n */\n static chunk<T>(array: T[], size: number): T[][] {\n return Array.from(Array(Math.ceil(array.length / size)), (_, i) => {\n return array.slice(i * size, i * size + size)\n })\n }\n\n static splitClassesAndStrings<T>(\n classesAndStrings: (string | T)[],\n ): [T[], string[]] {\n return [\n classesAndStrings.filter(\n (cls): cls is T => typeof cls !== \"string\",\n ),\n classesAndStrings.filter(\n (str): str is string => typeof str === \"string\",\n ),\n ]\n }\n\n static groupBy<T, R>(\n array: T[],\n propertyCallback: (item: T) => R,\n ): { id: R; items: T[] }[] {\n return array.reduce((groupedArray, value) => {\n const key = propertyCallback(value)\n let grouped = groupedArray.find((i) => i.id === key)\n if (!grouped) {\n grouped = { id: key, items: [] }\n groupedArray.push(grouped)\n }\n grouped.items.push(value)\n return groupedArray\n }, [] as Array<{ id: R; items: T[] }>)\n }\n\n static uniq<T>(array: T[], criteria?: (item: T) => any): T[]\n static uniq<T, K extends keyof T>(array: T[], property: K): T[]\n static uniq<T, K extends keyof T>(\n array: T[],\n criteriaOrProperty?: ((item: T) => any) | K,\n ): T[] {\n return array.reduce((uniqueArray, item) => {\n let found: boolean = false\n if (typeof criteriaOrProperty === \"function\") {\n const itemValue = criteriaOrProperty(item)\n found = !!uniqueArray.find(\n (uniqueItem) =>\n criteriaOrProperty(uniqueItem) === itemValue,\n )\n } else if (typeof criteriaOrProperty === \"string\") {\n found = !!uniqueArray.find(\n (uniqueItem) =>\n uniqueItem[criteriaOrProperty] ===\n item[criteriaOrProperty],\n )\n } else {\n found = uniqueArray.indexOf(item) !== -1\n }\n\n if (!found) uniqueArray.push(item)\n\n return uniqueArray\n }, [] as T[])\n }\n\n // Checks if it's an object made by Object.create(null), {} or new Object()\n private static isPlainObject(item: any) {\n if (item === null || item === undefined) {\n return false\n }\n\n return !item.constructor || item.constructor === Object\n }\n\n private static mergeArrayKey(\n target: any,\n key: number,\n value: any,\n memo: Map<any, any>,\n ) {\n // Have we seen this before? Prevent infinite recursion.\n if (memo.has(value)) {\n target[key] = memo.get(value)\n return\n }\n\n if (value instanceof Promise) {\n // Skip promises entirely.\n // This is a hold-over from the old code & is because we don't want to pull in\n // the lazy fields. Ideally we'd remove these promises via another function first\n // but for now we have to do it here.\n return\n }\n\n if (!this.isPlainObject(value) && !Array.isArray(value)) {\n target[key] = value\n return\n }\n\n if (!target[key]) {\n target[key] = Array.isArray(value) ? [] : {}\n }\n\n memo.set(value, target[key])\n this.merge(target[key], value, memo)\n memo.delete(value)\n }\n\n private static mergeObjectKey(\n target: any,\n key: string,\n value: any,\n memo: Map<any, any>,\n ) {\n // Have we seen this before? Prevent infinite recursion.\n if (memo.has(value)) {\n Object.assign(target, { [key]: memo.get(value) })\n return\n }\n\n if (value instanceof Promise) {\n // Skip promises entirely.\n // This is a hold-over from the old code & is because we don't want to pull in\n // the lazy fields. Ideally we'd remove these promises via another function first\n // but for now we have to do it here.\n return\n }\n\n if (!this.isPlainObject(value) && !Array.isArray(value)) {\n Object.assign(target, { [key]: value })\n return\n }\n\n if (!target[key]) {\n Object.assign(target, { [key]: Array.isArray(value) ? [] : {} })\n }\n\n memo.set(value, target[key])\n this.merge(target[key], value, memo)\n memo.delete(value)\n }\n\n private static merge(\n target: any,\n source: any,\n memo: Map<any, any> = new Map(),\n ): any {\n if (this.isPlainObject(target) && this.isPlainObject(source)) {\n for (const key of Object.keys(source)) {\n this.mergeObjectKey(target, key, source[key], memo)\n }\n }\n\n if (Array.isArray(target) && Array.isArray(source)) {\n for (let key = 0; key < source.length; key++) {\n this.mergeArrayKey(target, key, source[key], memo)\n }\n }\n }\n\n /**\n * Deep Object.assign.\n */\n static mergeDeep(target: any, ...sources: any[]): any {\n if (!sources.length) {\n return target\n }\n\n for (const source of sources) {\n OrmUtils.merge(target, source)\n }\n\n return target\n }\n\n /**\n * Deep compare objects.\n *\n * @see http://stackoverflow.com/a/1144249\n */\n static deepCompare(...args: any[]): boolean {\n let i: any, l: any, leftChain: any, rightChain: any\n\n if (arguments.length < 1) {\n return true // Die silently? Don't know how to handle such case, please help...\n // throw \"Need two or more arguments to compare\";\n }\n\n for (i = 1, l = arguments.length; i < l; i++) {\n leftChain = [] // Todo: this can be cached\n rightChain = []\n\n if (\n !this.compare2Objects(\n leftChain,\n rightChain,\n arguments[0],\n arguments[i],\n )\n ) {\n return false\n }\n }\n\n return true\n }\n\n /**\n * Gets deeper value of object.\n */\n static deepValue(obj: ObjectLiteral, path: string) {\n const segments = path.split(\".\")\n for (let i = 0, len = segments.length; i < len; i++) {\n obj = obj[segments[i]]\n }\n return obj\n }\n\n static replaceEmptyObjectsWithBooleans(obj: any) {\n for (let key in obj) {\n if (obj[key] && typeof obj[key] === \"object\") {\n if (Object.keys(obj[key]).length === 0) {\n obj[key] = true\n } else {\n this.replaceEmptyObjectsWithBooleans(obj[key])\n }\n }\n }\n }\n\n static propertyPathsToTruthyObject(paths: string[]) {\n let obj: any = {}\n for (let path of paths) {\n const props = path.split(\".\")\n if (!props.length) continue\n\n if (!obj[props[0]] || obj[props[0]] === true) {\n obj[props[0]] = {}\n }\n let recursiveChild = obj[props[0]]\n for (let [key, prop] of props.entries()) {\n if (key === 0) continue\n\n if (recursiveChild[prop]) {\n recursiveChild = recursiveChild[prop]\n } else if (key === props.length - 1) {\n recursiveChild[prop] = {}\n recursiveChild = null\n } else {\n recursiveChild[prop] = {}\n recursiveChild = recursiveChild[prop]\n }\n }\n }\n this.replaceEmptyObjectsWithBooleans(obj)\n return obj\n }\n\n /**\n * Check if two entity-id-maps are the same\n */\n static compareIds(\n firstId: ObjectLiteral | undefined,\n secondId: ObjectLiteral | undefined,\n ): boolean {\n if (\n firstId === undefined ||\n firstId === null ||\n secondId === undefined ||\n secondId === null\n )\n return false\n\n // Optimized version for the common case\n if (\n ((typeof firstId.id === \"string\" &&\n typeof secondId.id === \"string\") ||\n (typeof firstId.id === \"number\" &&\n typeof secondId.id === \"number\")) &&\n Object.keys(firstId).length === 1 &&\n Object.keys(secondId).length === 1\n ) {\n return firstId.id === secondId.id\n }\n\n return OrmUtils.deepCompare(firstId, secondId)\n }\n\n /**\n * Transforms given value into boolean value.\n */\n static toBoolean(value: any): boolean {\n if (typeof value === \"boolean\") return value\n\n if (typeof value === \"string\") return value === \"true\" || value === \"1\"\n\n if (typeof value === \"number\") return value > 0\n\n return false\n }\n\n /**\n * Composes an object from the given array of keys and values.\n */\n static zipObject(keys: any[], values: any[]): ObjectLiteral {\n return keys.reduce((object, column, index) => {\n object[column] = values[index]\n return object\n }, {} as ObjectLiteral)\n }\n\n /**\n * Compares two arrays.\n */\n static isArraysEqual(arr1: any[], arr2: any[]): boolean {\n if (arr1.length !== arr2.length) return false\n return arr1.every((element) => {\n return arr2.indexOf(element) !== -1\n })\n }\n\n static areMutuallyExclusive<T>(...lists: T[][]): boolean {\n const haveSharedObjects = lists.some((list) => {\n const otherLists = lists.filter((otherList) => otherList !== list)\n return list.some((item) =>\n otherLists.some((otherList) => otherList.includes(item)),\n )\n })\n return !haveSharedObjects\n }\n\n // -------------------------------------------------------------------------\n // Private methods\n // -------------------------------------------------------------------------\n\n private static compare2Objects(\n leftChain: any,\n rightChain: any,\n x: any,\n y: any,\n ) {\n let p\n\n // remember that NaN === NaN returns false\n // and isNaN(undefined) returns true\n if (Number.isNaN(x) && Number.isNaN(y)) return true\n\n // Compare primitives and functions.\n // Check if both arguments link to the same object.\n // Especially useful on the step where we compare prototypes\n if (x === y) return true\n\n // Unequal, but either is null or undefined (use case: jsonb comparison)\n // PR #3776, todo: add tests\n if (x === null || y === null || x === undefined || y === undefined)\n return false\n\n // Fix the buffer compare bug.\n // See: https://github.com/typeorm/typeorm/issues/3654\n if (\n (typeof x.equals === \"function\" ||\n typeof x.equals === \"function\") &&\n x.equals(y)\n )\n return true\n\n // Works in case when functions are created in constructor.\n // Comparing dates is a common scenario. Another built-ins?\n // We can even handle functions passed across iframes\n if (\n (typeof x === \"function\" && typeof y === \"function\") ||\n (x instanceof Date && y instanceof Date) ||\n (x instanceof RegExp && y instanceof RegExp) ||\n (typeof x === \"string\" && typeof y === \"string\") ||\n (typeof x === \"number\" && typeof y === \"number\")\n )\n return x.toString() === y.toString()\n\n // At last checking prototypes as good as we can\n if (!(typeof x === \"object\" && typeof y === \"object\")) return false\n\n if (x.isPrototypeOf(y) || y.isPrototypeOf(x)) return false\n\n if (x.constructor !== y.constructor) return false\n\n if (x.prototype !== y.prototype) return false\n\n // Check for infinitive linking loops\n if (leftChain.indexOf(x) > -1 || rightChain.indexOf(y) > -1)\n return false\n\n // Quick checking of one object being a subset of another.\n // todo: cache the structure of arguments[0] for performance\n for (p in y) {\n if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {\n return false\n } else if (typeof y[p] !== typeof x[p]) {\n return false\n }\n }\n\n for (p in x) {\n if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) {\n return false\n } else if (typeof y[p] !== typeof x[p]) {\n return false\n }\n\n switch (typeof x[p]) {\n case \"object\":\n case \"function\":\n leftChain.push(x)\n rightChain.push(y)\n\n if (\n !this.compare2Objects(leftChain, rightChain, x[p], y[p])\n ) {\n return false\n }\n\n leftChain.pop()\n rightChain.pop()\n break\n\n default:\n if (x[p] !== y[p]) {\n return false\n }\n break\n }\n }\n\n return true\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const escapeRegExp: (s: String) => string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Escape special characters in regular expressions
|
|
2
|
+
// Per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
|
|
3
|
+
const ESCAPE_REGEXP = /[.*+\-?^${}()|[\]\\]/g;
|
|
4
|
+
export const escapeRegExp = (s) => s.replace(ESCAPE_REGEXP, "\\$&");
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=escapeRegExp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../browser/src/util/escapeRegExp.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,iGAAiG;AACjG,MAAM,aAAa,GAAG,uBAAuB,CAAA;AAC7C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA","file":"escapeRegExp.js","sourcesContent":["// Escape special characters in regular expressions\n// Per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping\nconst ESCAPE_REGEXP = /[.*+\\-?^${}()|[\\]\\\\]/g\nexport const escapeRegExp = (s: String) => s.replace(ESCAPE_REGEXP, \"\\\\$&\")\n"],"sourceRoot":".."}
|
package/commands/InitCommand.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"s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ils\"\nimport * as path from \"path\"\nimport * as yargs from \"yargs\"\nimport chalk from \"chalk\"\nimport { exec } from \"child_process\"\nimport { TypeORMError } from \"../error\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\n\n/**\n * Generates a new project with TypeORM.\n */\nexport class InitCommand implements yargs.CommandModule {\n command = \"init\"\n describe =\n \"Generates initial TypeORM project structure. \" +\n \"If name specified then creates files inside directory called as name. \" +\n \"If its not specified then creates files inside current directory.\"\n\n builder(args: yargs.Argv) {\n return args\n .option(\"n\", {\n alias: \"name\",\n describe: \"Name of the project directory.\",\n })\n .option(\"db\", {\n alias: \"database\",\n describe: \"Database type you'll use in your project.\",\n })\n .option(\"express\", {\n describe:\n \"Indicates if express server sample code should be included in the project. False by default.\",\n })\n .option(\"docker\", {\n describe:\n \"Set to true if docker-compose must be generated as well. False by default.\",\n })\n .option(\"pm\", {\n alias: \"manager\",\n choices: [\"npm\", \"yarn\"],\n default: \"npm\",\n describe: \"Install packages, expected values are npm or yarn.\",\n })\n .option(\"ms\", {\n alias: \"module\",\n choices: [\"commonjs\", \"esm\"],\n default: \"commonjs\",\n describe:\n \"Module system to use for project, expected values are commonjs or esm.\",\n })\n }\n\n async handler(args: yargs.Arguments) {\n try {\n const database: string = (args.database as any) || \"postgres\"\n const isExpress = args.express !== undefined ? true : false\n const isDocker = args.docker !== undefined ? true : false\n const basePath = process.cwd() + (args.name ? \"/\" + args.name : \"\")\n const projectName = args.name\n ? path.basename(args.name as any)\n : undefined\n const installNpm = args.pm === \"yarn\" ? false : true\n const projectIsEsm = args.ms === \"esm\"\n await CommandUtils.createFile(\n basePath + \"/package.json\",\n InitCommand.getPackageJsonTemplate(projectName, projectIsEsm),\n false,\n )\n if (isDocker)\n await CommandUtils.createFile(\n basePath + \"/docker-compose.yml\",\n InitCommand.getDockerComposeTemplate(database),\n false,\n )\n await CommandUtils.createFile(\n basePath + \"/.gitignore\",\n InitCommand.getGitIgnoreFile(),\n )\n await CommandUtils.createFile(\n basePath + \"/README.md\",\n InitCommand.getReadmeTemplate({ docker: isDocker }),\n false,\n )\n await CommandUtils.createFile(\n basePath + \"/tsconfig.json\",\n InitCommand.getTsConfigTemplate(projectIsEsm),\n )\n await CommandUtils.createFile(\n basePath + \"/src/entity/User.ts\",\n InitCommand.getUserEntityTemplate(database),\n )\n await CommandUtils.createFile(\n basePath + \"/src/data-source.ts\",\n InitCommand.getAppDataSourceTemplate(projectIsEsm, database),\n )\n await CommandUtils.createFile(\n basePath + \"/src/index.ts\",\n InitCommand.getAppIndexTemplate(isExpress, projectIsEsm),\n )\n await CommandUtils.createDirectories(basePath + \"/src/migration\")\n\n // generate extra files for express application\n if (isExpress) {\n await CommandUtils.createFile(\n basePath + \"/src/routes.ts\",\n InitCommand.getRoutesTemplate(projectIsEsm),\n )\n await CommandUtils.createFile(\n basePath + \"/src/controller/UserController.ts\",\n InitCommand.getControllerTemplate(projectIsEsm),\n )\n }\n\n const packageJsonContents = await CommandUtils.readFile(\n basePath + \"/package.json\",\n )\n await CommandUtils.createFile(\n basePath + \"/package.json\",\n InitCommand.appendPackageJson(\n packageJsonContents,\n database,\n isExpress,\n projectIsEsm,\n ),\n )\n\n if (args.name) {\n console.log(\n chalk.green(\n `Project created inside ${chalk.blue(\n basePath,\n )} directory.`,\n ),\n )\n } else {\n console.log(\n chalk.green(`Project created inside current directory.`),\n )\n }\n\n console.log(chalk.green(`Please wait, installing dependencies...`))\n if (args.pm && installNpm) {\n await InitCommand.executeCommand(\"npm install\", basePath)\n } else {\n await InitCommand.executeCommand(\"yarn install\", basePath)\n }\n\n console.log(chalk.green(`Done! Start playing with a new project!`))\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during project initialization:\", err)\n process.exit(1)\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n protected static executeCommand(command: string, cwd: string) {\n return new Promise<string>((ok, fail) => {\n exec(command, { cwd }, (error: any, stdout: any, stderr: any) => {\n if (stdout) return ok(stdout)\n if (stderr) return fail(stderr)\n if (error) return fail(error)\n ok(\"\")\n })\n })\n }\n\n /**\n * Gets contents of the ormconfig file.\n */\n protected static getAppDataSourceTemplate(\n isEsm: boolean,\n database: string,\n ): string {\n let dbSettings = \"\"\n switch (database) {\n case \"mysql\":\n dbSettings = `type: \"mysql\",\n host: \"localhost\",\n port: 3306,\n username: \"test\",\n password: \"test\",\n database: \"test\",`\n break\n case \"mariadb\":\n dbSettings = `type: \"mariadb\",\n host: \"localhost\",\n port: 3306,\n username: \"test\",\n password: \"test\",\n database: \"test\",`\n break\n case \"sqlite\":\n dbSettings = `type: \"sqlite\",\n database: \"database.sqlite\",`\n break\n case \"better-sqlite3\":\n dbSettings = `type: \"better-sqlite3\",\n database: \"database.sqlite\",`\n break\n case \"postgres\":\n dbSettings = `type: \"postgres\",\n host: \"localhost\",\n port: 5432,\n username: \"test\",\n password: \"test\",\n database: \"test\",`\n break\n case \"cockroachdb\":\n dbSettings = `type: \"cockroachdb\",\n host: \"localhost\",\n port: 26257,\n username: \"root\",\n password: \"\",\n database: \"defaultdb\",`\n break\n case \"mssql\":\n dbSettings = `type: \"mssql\",\n host: \"localhost\",\n username: \"sa\",\n password: \"Admin12345\",\n database: \"tempdb\",`\n break\n case \"oracle\":\n dbSettings = `type: \"oracle\",\nhost: \"localhost\",\nusername: \"system\",\npassword: \"oracle\",\nport: 1521,\nsid: \"xe.oracle.docker\",`\n break\n case \"mongodb\":\n dbSettings = `type: \"mongodb\",\ndatabase: \"test\",`\n break\n }\n return `import \"reflect-metadata\"\nimport { DataSource } from \"typeorm\"\nimport { User } from \"./entity/User${isEsm ? \".js\" : \"\"}\"\n\nexport const AppDataSource = new DataSource({\n ${dbSettings}\n synchronize: true,\n logging: false,\n entities: [User],\n migrations: [],\n subscribers: [],\n})\n`\n }\n\n /**\n * Gets contents of the ormconfig file.\n */\n protected static getTsConfigTemplate(esmModule: boolean): string {\n if (esmModule)\n return JSON.stringify(\n {\n compilerOptions: {\n lib: [\"es2021\"],\n target: \"es2021\",\n module: \"es2022\",\n moduleResolution: \"node\",\n allowSyntheticDefaultImports: true,\n outDir: \"./build\",\n emitDecoratorMetadata: true,\n experimentalDecorators: true,\n sourceMap: true,\n },\n },\n undefined,\n 3,\n )\n else\n return JSON.stringify(\n {\n compilerOptions: {\n lib: [\"es5\", \"es6\"],\n target: \"es5\",\n module: \"commonjs\",\n moduleResolution: \"node\",\n outDir: \"./build\",\n emitDecoratorMetadata: true,\n experimentalDecorators: true,\n sourceMap: true,\n },\n },\n undefined,\n 3,\n )\n }\n\n /**\n * Gets contents of the .gitignore file.\n */\n protected static getGitIgnoreFile(): string {\n return `.idea/\n.vscode/\nnode_modules/\nbuild/\ntmp/\ntemp/`\n }\n\n /**\n * Gets contents of the user entity.\n */\n protected static getUserEntityTemplate(database: string): string {\n return `import { Entity, ${\n database === \"mongodb\"\n ? \"ObjectIdColumn, ObjectID\"\n : \"PrimaryGeneratedColumn\"\n }, Column } from \"typeorm\"\n\n@Entity()\nexport class User {\n\n ${\n database === \"mongodb\"\n ? \"@ObjectIdColumn()\"\n : \"@PrimaryGeneratedColumn()\"\n }\n id: ${database === \"mongodb\" ? \"ObjectID\" : \"number\"}\n\n @Column()\n firstName: string\n\n @Column()\n lastName: string\n\n @Column()\n age: number\n\n}\n`\n }\n\n /**\n * Gets contents of the route file (used when express is enabled).\n */\n protected static getRoutesTemplate(isEsm: boolean): string {\n return `import { UserController } from \"./controller/UserController${\n isEsm ? \".js\" : \"\"\n }\"\n\nexport const Routes = [{\n method: \"get\",\n route: \"/users\",\n controller: UserController,\n action: \"all\"\n}, {\n method: \"get\",\n route: \"/users/:id\",\n controller: UserController,\n action: \"one\"\n}, {\n method: \"post\",\n route: \"/users\",\n controller: UserController,\n action: \"save\"\n}, {\n method: \"delete\",\n route: \"/users/:id\",\n controller: UserController,\n action: \"remove\"\n}]`\n }\n\n /**\n * Gets contents of the user controller file (used when express is enabled).\n */\n protected static getControllerTemplate(isEsm: boolean): string {\n return `import { getRepository } from \"typeorm\"\nimport { NextFunction, Request, Response } from \"express\"\nimport { User } from \"../entity/User${isEsm ? \".js\" : \"\"}\"\n\nexport class UserController {\n\n private userRepository = getRepository(User)\n\n async all(request: Request, response: Response, next: NextFunction) {\n return this.userRepository.find()\n }\n\n async one(request: Request, response: Response, next: NextFunction) {\n return this.userRepository.findOne(request.params.id)\n }\n\n async save(request: Request, response: Response, next: NextFunction) {\n return this.userRepository.save(request.body)\n }\n\n async remove(request: Request, response: Response, next: NextFunction) {\n let userToRemove = await this.userRepository.findOneBy({ id: request.params.id })\n await this.userRepository.remove(userToRemove)\n }\n\n}`\n }\n\n /**\n * Gets contents of the main (index) application file.\n */\n protected static getAppIndexTemplate(\n express: boolean,\n isEsm: boolean,\n ): string {\n if (express) {\n return `import ${!isEsm ? \"* as \" : \"\"}express from \"express\"\nimport ${!isEsm ? \"* as \" : \"\"}bodyParser from \"body-parser\"\nimport { Request, Response } from \"express\"\nimport { AppDataSource } from \"./data-source${isEsm ? \".js\" : \"\"}\"\nimport { Routes } from \"./routes${isEsm ? \".js\" : \"\"}\"\nimport { User } from \"./entity/User${isEsm ? \".js\" : \"\"}\"\n\nAppDataSource.initialize().then(async () => {\n\n // create express app\n const app = express()\n app.use(bodyParser.json())\n\n // register express routes from defined application routes\n Routes.forEach(route => {\n (app as any)[route.method](route.route, (req: Request, res: Response, next: Function) => {\n const result = (new (route.controller as any))[route.action](req, res, next)\n if (result instanceof Promise) {\n result.then(result => result !== null && result !== undefined ? res.send(result) : undefined)\n\n } else if (result !== null && result !== undefined) {\n res.json(result)\n }\n })\n })\n\n // setup express app here\n // ...\n\n // start express server\n app.listen(3000)\n\n // insert new users for test\n await AppDataSource.manager.save(\n AppDataSource.manager.create(User, {\n firstName: \"Timber\",\n lastName: \"Saw\",\n age: 27\n })\n )\n\n await AppDataSource.manager.save(\n dataSource.manager.create(User, {\n firstName: \"Phantom\",\n lastName: \"Assassin\",\n age: 24\n })\n )\n\n console.log(\"Express server has started on port 3000. Open http://localhost:3000/users to see results\")\n\n}).catch(error => console.log(error))\n`\n } else {\n return `import { AppDataSource } from \"./data-source${\n isEsm ? \".js\" : \"\"\n }\"\nimport { User } from \"./entity/User${isEsm ? \".js\" : \"\"}\"\n\nAppDataSource.initialize().then(async () => {\n\n console.log(\"Inserting a new user into the database...\")\n const user = new User()\n user.firstName = \"Timber\"\n user.lastName = \"Saw\"\n user.age = 25\n await AppDataSource.manager.save(user)\n console.log(\"Saved a new user with id: \" + user.id)\n\n console.log(\"Loading users from the database...\")\n const users = await AppDataSource.manager.find(User)\n console.log(\"Loaded users: \", users)\n\n console.log(\"Here you can setup and run express / fastify / any other framework.\")\n\n}).catch(error => console.log(error))\n`\n }\n }\n\n /**\n * Gets contents of the new package.json file.\n */\n protected static getPackageJsonTemplate(\n projectName?: string,\n projectIsEsm?: boolean,\n ): string {\n return JSON.stringify(\n {\n name: projectName || \"typeorm-sample\",\n version: \"0.0.1\",\n description: \"Awesome project developed with TypeORM.\",\n type: projectIsEsm ? \"module\" : \"commonjs\",\n devDependencies: {},\n dependencies: {},\n scripts: {},\n },\n undefined,\n 3,\n )\n }\n\n /**\n * Gets contents of the new docker-compose.yml file.\n */\n protected static getDockerComposeTemplate(database: string): string {\n switch (database) {\n case \"mysql\":\n return `version: '3'\nservices:\n\n mysql:\n image: \"mysql:5.7.10\"\n ports:\n - \"3306:3306\"\n environment:\n MYSQL_ROOT_PASSWORD: \"admin\"\n MYSQL_USER: \"test\"\n MYSQL_PASSWORD: \"test\"\n MYSQL_DATABASE: \"test\"\n\n`\n case \"mariadb\":\n return `version: '3'\nservices:\n\n mariadb:\n image: \"mariadb:10.1.16\"\n ports:\n - \"3306:3306\"\n environment:\n MYSQL_ROOT_PASSWORD: \"admin\"\n MYSQL_USER: \"test\"\n MYSQL_PASSWORD: \"test\"\n MYSQL_DATABASE: \"test\"\n\n`\n case \"postgres\":\n return `version: '3'\nservices:\n\n postgres:\n image: \"postgres:9.6.1\"\n ports:\n - \"5432:5432\"\n environment:\n POSTGRES_USER: \"test\"\n POSTGRES_PASSWORD: \"test\"\n POSTGRES_DB: \"test\"\n\n`\n case \"cockroachdb\":\n return `version: '3'\nservices:\n\n cockroachdb:\n image: \"cockroachdb/cockroach:v2.1.4\"\n command: start --insecure\n ports:\n - \"26257:26257\"\n\n`\n case \"sqlite\":\n case \"better-sqlite3\":\n return `version: '3'\nservices:\n`\n case \"oracle\":\n throw new TypeORMError(\n `You cannot initialize a project with docker for Oracle driver yet.`,\n ) // todo: implement for oracle as well\n\n case \"mssql\":\n return `version: '3'\nservices:\n\n mssql:\n image: \"microsoft/mssql-server-linux:rc2\"\n ports:\n - \"1433:1433\"\n environment:\n SA_PASSWORD: \"Admin12345\"\n ACCEPT_EULA: \"Y\"\n\n`\n case \"mongodb\":\n return `version: '3'\nservices:\n\n mongodb:\n image: \"mongo:4.0.6\"\n container_name: \"typeorm-mongodb\"\n ports:\n - \"27017:27017\"\n\n`\n }\n return \"\"\n }\n\n /**\n * Gets contents of the new readme.md file.\n */\n protected static getReadmeTemplate(options: { docker: boolean }): string {\n let template = `# Awesome Project Build with TypeORM\n\nSteps to run this project:\n\n1. Run \\`npm i\\` command\n`\n\n if (options.docker) {\n template += `2. Run \\`docker-compose up\\` command\n`\n } else {\n template += `2. Setup database settings inside \\`data-source.ts\\` file\n`\n }\n\n template += `3. Run \\`npm start\\` command\n`\n return template\n }\n\n /**\n * Appends to a given package.json template everything needed.\n */\n protected static appendPackageJson(\n packageJsonContents: string,\n database: string,\n express: boolean,\n projectIsEsm: boolean /*, docker: boolean*/,\n ): string {\n const packageJson = JSON.parse(packageJsonContents)\n\n if (!packageJson.devDependencies) packageJson.devDependencies = {}\n Object.assign(packageJson.devDependencies, {\n \"ts-node\": \"10.7.0\",\n \"@types/node\": \"^16.11.10\",\n typescript: \"4.5.2\",\n })\n\n if (!packageJson.dependencies) packageJson.dependencies = {}\n Object.assign(packageJson.dependencies, {\n typeorm: require(\"../package.json\").version,\n \"reflect-metadata\": \"^0.1.13\",\n })\n\n switch (database) {\n case \"mysql\":\n case \"mariadb\":\n packageJson.dependencies[\"mysql\"] = \"^2.14.1\"\n break\n case \"postgres\":\n case \"cockroachdb\":\n packageJson.dependencies[\"pg\"] = \"^8.4.0\"\n break\n case \"sqlite\":\n packageJson.dependencies[\"sqlite3\"] = \"^4.0.3\"\n break\n case \"better-sqlite3\":\n packageJson.dependencies[\"better-sqlite3\"] = \"^7.0.0\"\n break\n case \"oracle\":\n packageJson.dependencies[\"oracledb\"] = \"^1.13.1\"\n break\n case \"mssql\":\n packageJson.dependencies[\"mssql\"] = \"^4.0.4\"\n break\n case \"mongodb\":\n packageJson.dependencies[\"mongodb\"] = \"^3.0.8\"\n break\n }\n\n if (express) {\n packageJson.dependencies[\"express\"] = \"^4.17.2\"\n packageJson.dependencies[\"body-parser\"] = \"^1.19.1\"\n }\n\n if (!packageJson.scripts) packageJson.scripts = {}\n\n if (projectIsEsm)\n Object.assign(packageJson.scripts, {\n start: /*(docker ? \"docker-compose up && \" : \"\") + */ \"node --loader ts-node/esm src/index.ts\",\n typeorm: \"typeorm-ts-node-esm\",\n })\n else\n Object.assign(packageJson.scripts, {\n start: /*(docker ? \"docker-compose up && \" : \"\") + */ \"ts-node src/index.ts\",\n typeorm: \"typeorm-ts-node-commonjs\",\n })\n\n return JSON.stringify(packageJson, undefined, 3)\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/commands/InitCommand.ts"],"names":[],"mappings":";;;;AAAA,iDAA6C;AAC7C,mDAA4B;AAE5B,0DAAyB;AACzB,iDAAoC;AACpC,oCAAuC;AACvC,6DAAyD;AAEzD;;GAEG;AACH,MAAa,WAAW;IAAxB;QACI,YAAO,GAAG,MAAM,CAAA;QAChB,aAAQ,GACJ,+CAA+C;YAC/C,wEAAwE;YACxE,mEAAmE,CAAA;IA+qB3E,CAAC;IA7qBG,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI;aACN,MAAM,CAAC,GAAG,E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AK;YACT,KAAK,OAAO;gBACR,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAA;gBAC5C,MAAK;YACT,KAAK,SAAS;gBACV,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAA;gBAC9C,MAAK;SACZ;QAED,IAAI,OAAO,EAAE;YACT,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,SAAS,CAAA;YAC/C,WAAW,CAAC,YAAY,CAAC,aAAa,CAAC,GAAG,SAAS,CAAA;SACtD;QAED,IAAI,CAAC,WAAW,CAAC,OAAO;YAAE,WAAW,CAAC,OAAO,GAAG,EAAE,CAAA;QAElD,IAAI,YAAY;YACZ,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE;gBAC/B,KAAK,EAAE,8CAA8C,CAAC,wCAAwC;gBAC9F,OAAO,EAAE,qBAAqB;aACjC,CAAC,CAAA;;YAEF,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE;gBAC/B,KAAK,EAAE,8CAA8C,CAAC,sBAAsB;gBAC5E,OAAO,EAAE,0BAA0B;aACtC,CAAC,CAAA;QAEN,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC,CAAA;IACpD,CAAC;CACJ;AAprBD,kCAorBC","file":"InitCommand.js","sourcesContent":["import { CommandUtils } from \"./CommandUtils\"\nimport * as path from \"path\"\nimport * as yargs from \"yargs\"\nimport chalk from \"chalk\"\nimport { exec } from \"child_process\"\nimport { TypeORMError } from \"../error\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\n\n/**\n * Generates a new project with TypeORM.\n */\nexport class InitCommand implements yargs.CommandModule {\n command = \"init\"\n describe =\n \"Generates initial TypeORM project structure. \" +\n \"If name specified then creates files inside directory called as name. \" +\n \"If its not specified then creates files inside current directory.\"\n\n builder(args: yargs.Argv) {\n return args\n .option(\"n\", {\n alias: \"name\",\n describe: \"Name of the project directory.\",\n })\n .option(\"db\", {\n alias: \"database\",\n describe: \"Database type you'll use in your project.\",\n })\n .option(\"express\", {\n describe:\n \"Indicates if express server sample code should be included in the project. False by default.\",\n })\n .option(\"docker\", {\n describe:\n \"Set to true if docker-compose must be generated as well. False by default.\",\n })\n .option(\"pm\", {\n alias: \"manager\",\n choices: [\"npm\", \"yarn\"],\n default: \"npm\",\n describe: \"Install packages, expected values are npm or yarn.\",\n })\n .option(\"ms\", {\n alias: \"module\",\n choices: [\"commonjs\", \"esm\"],\n default: \"commonjs\",\n describe:\n \"Module system to use for project, expected values are commonjs or esm.\",\n })\n }\n\n async handler(args: yargs.Arguments) {\n try {\n const database: string = (args.database as any) || \"postgres\"\n const isExpress = args.express !== undefined ? true : false\n const isDocker = args.docker !== undefined ? true : false\n const basePath = process.cwd() + (args.name ? \"/\" + args.name : \"\")\n const projectName = args.name\n ? path.basename(args.name as any)\n : undefined\n const installNpm = args.pm === \"yarn\" ? false : true\n const projectIsEsm = args.ms === \"esm\"\n await CommandUtils.createFile(\n basePath + \"/package.json\",\n InitCommand.getPackageJsonTemplate(projectName, projectIsEsm),\n false,\n )\n if (isDocker)\n await CommandUtils.createFile(\n basePath + \"/docker-compose.yml\",\n InitCommand.getDockerComposeTemplate(database),\n false,\n )\n await CommandUtils.createFile(\n basePath + \"/.gitignore\",\n InitCommand.getGitIgnoreFile(),\n )\n await CommandUtils.createFile(\n basePath + \"/README.md\",\n InitCommand.getReadmeTemplate({ docker: isDocker }),\n false,\n )\n await CommandUtils.createFile(\n basePath + \"/tsconfig.json\",\n InitCommand.getTsConfigTemplate(projectIsEsm),\n )\n await CommandUtils.createFile(\n basePath + \"/src/entity/User.ts\",\n InitCommand.getUserEntityTemplate(database),\n )\n await CommandUtils.createFile(\n basePath + \"/src/data-source.ts\",\n InitCommand.getAppDataSourceTemplate(projectIsEsm, database),\n )\n await CommandUtils.createFile(\n basePath + \"/src/index.ts\",\n InitCommand.getAppIndexTemplate(isExpress, projectIsEsm),\n )\n await CommandUtils.createDirectories(basePath + \"/src/migration\")\n\n // generate extra files for express application\n if (isExpress) {\n await CommandUtils.createFile(\n basePath + \"/src/routes.ts\",\n InitCommand.getRoutesTemplate(projectIsEsm),\n )\n await CommandUtils.createFile(\n basePath + \"/src/controller/UserController.ts\",\n InitCommand.getControllerTemplate(projectIsEsm),\n )\n }\n\n const packageJsonContents = await CommandUtils.readFile(\n basePath + \"/package.json\",\n )\n await CommandUtils.createFile(\n basePath + \"/package.json\",\n InitCommand.appendPackageJson(\n packageJsonContents,\n database,\n isExpress,\n projectIsEsm,\n ),\n )\n\n if (args.name) {\n console.log(\n chalk.green(\n `Project created inside ${chalk.blue(\n basePath,\n )} directory.`,\n ),\n )\n } else {\n console.log(\n chalk.green(`Project created inside current directory.`),\n )\n }\n\n console.log(chalk.green(`Please wait, installing dependencies...`))\n if (args.pm && installNpm) {\n await InitCommand.executeCommand(\"npm install\", basePath)\n } else {\n await InitCommand.executeCommand(\"yarn install\", basePath)\n }\n\n console.log(chalk.green(`Done! Start playing with a new project!`))\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during project initialization:\", err)\n process.exit(1)\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n protected static executeCommand(command: string, cwd: string) {\n return new Promise<string>((ok, fail) => {\n exec(command, { cwd }, (error: any, stdout: any, stderr: any) => {\n if (stdout) return ok(stdout)\n if (stderr) return fail(stderr)\n if (error) return fail(error)\n ok(\"\")\n })\n })\n }\n\n /**\n * Gets contents of the ormconfig file.\n */\n protected static getAppDataSourceTemplate(\n isEsm: boolean,\n database: string,\n ): string {\n let dbSettings = \"\"\n switch (database) {\n case \"mysql\":\n dbSettings = `type: \"mysql\",\n host: \"localhost\",\n port: 3306,\n username: \"test\",\n password: \"test\",\n database: \"test\",`\n break\n case \"mariadb\":\n dbSettings = `type: \"mariadb\",\n host: \"localhost\",\n port: 3306,\n username: \"test\",\n password: \"test\",\n database: \"test\",`\n break\n case \"sqlite\":\n dbSettings = `type: \"sqlite\",\n database: \"database.sqlite\",`\n break\n case \"better-sqlite3\":\n dbSettings = `type: \"better-sqlite3\",\n database: \"database.sqlite\",`\n break\n case \"postgres\":\n dbSettings = `type: \"postgres\",\n host: \"localhost\",\n port: 5432,\n username: \"test\",\n password: \"test\",\n database: \"test\",`\n break\n case \"cockroachdb\":\n dbSettings = `type: \"cockroachdb\",\n host: \"localhost\",\n port: 26257,\n username: \"root\",\n password: \"\",\n database: \"defaultdb\",`\n break\n case \"mssql\":\n dbSettings = `type: \"mssql\",\n host: \"localhost\",\n username: \"sa\",\n password: \"Admin12345\",\n database: \"tempdb\",`\n break\n case \"oracle\":\n dbSettings = `type: \"oracle\",\nhost: \"localhost\",\nusername: \"system\",\npassword: \"oracle\",\nport: 1521,\nsid: \"xe.oracle.docker\",`\n break\n case \"mongodb\":\n dbSettings = `type: \"mongodb\",\ndatabase: \"test\",`\n break\n }\n return `import \"reflect-metadata\"\nimport { DataSource } from \"typeorm\"\nimport { User } from \"./entity/User${isEsm ? \".js\" : \"\"}\"\n\nexport const AppDataSource = new DataSource({\n ${dbSettings}\n synchronize: true,\n logging: false,\n entities: [User],\n migrations: [],\n subscribers: [],\n})\n`\n }\n\n /**\n * Gets contents of the ormconfig file.\n */\n protected static getTsConfigTemplate(esmModule: boolean): string {\n if (esmModule)\n return JSON.stringify(\n {\n compilerOptions: {\n lib: [\"es2021\"],\n target: \"es2021\",\n module: \"es2022\",\n moduleResolution: \"node\",\n allowSyntheticDefaultImports: true,\n outDir: \"./build\",\n emitDecoratorMetadata: true,\n experimentalDecorators: true,\n sourceMap: true,\n },\n },\n undefined,\n 3,\n )\n else\n return JSON.stringify(\n {\n compilerOptions: {\n lib: [\"es5\", \"es6\"],\n target: \"es5\",\n module: \"commonjs\",\n moduleResolution: \"node\",\n outDir: \"./build\",\n emitDecoratorMetadata: true,\n experimentalDecorators: true,\n sourceMap: true,\n },\n },\n undefined,\n 3,\n )\n }\n\n /**\n * Gets contents of the .gitignore file.\n */\n protected static getGitIgnoreFile(): string {\n return `.idea/\n.vscode/\nnode_modules/\nbuild/\ntmp/\ntemp/`\n }\n\n /**\n * Gets contents of the user entity.\n */\n protected static getUserEntityTemplate(database: string): string {\n return `import { Entity, ${\n database === \"mongodb\"\n ? \"ObjectIdColumn, ObjectID\"\n : \"PrimaryGeneratedColumn\"\n }, Column } from \"typeorm\"\n\n@Entity()\nexport class User {\n\n ${\n database === \"mongodb\"\n ? \"@ObjectIdColumn()\"\n : \"@PrimaryGeneratedColumn()\"\n }\n id: ${database === \"mongodb\" ? \"ObjectID\" : \"number\"}\n\n @Column()\n firstName: string\n\n @Column()\n lastName: string\n\n @Column()\n age: number\n\n}\n`\n }\n\n /**\n * Gets contents of the route file (used when express is enabled).\n */\n protected static getRoutesTemplate(isEsm: boolean): string {\n return `import { UserController } from \"./controller/UserController${\n isEsm ? \".js\" : \"\"\n }\"\n\nexport const Routes = [{\n method: \"get\",\n route: \"/users\",\n controller: UserController,\n action: \"all\"\n}, {\n method: \"get\",\n route: \"/users/:id\",\n controller: UserController,\n action: \"one\"\n}, {\n method: \"post\",\n route: \"/users\",\n controller: UserController,\n action: \"save\"\n}, {\n method: \"delete\",\n route: \"/users/:id\",\n controller: UserController,\n action: \"remove\"\n}]`\n }\n\n /**\n * Gets contents of the user controller file (used when express is enabled).\n */\n protected static getControllerTemplate(isEsm: boolean): string {\n return `import { getRepository } from \"typeorm\"\nimport { NextFunction, Request, Response } from \"express\"\nimport { User } from \"../entity/User${isEsm ? \".js\" : \"\"}\"\n\nexport class UserController {\n\n private userRepository = getRepository(User)\n\n async all(request: Request, response: Response, next: NextFunction) {\n return this.userRepository.find()\n }\n\n async one(request: Request, response: Response, next: NextFunction) {\n return this.userRepository.findOne(request.params.id)\n }\n\n async save(request: Request, response: Response, next: NextFunction) {\n return this.userRepository.save(request.body)\n }\n\n async remove(request: Request, response: Response, next: NextFunction) {\n let userToRemove = await this.userRepository.findOneBy({ id: request.params.id })\n await this.userRepository.remove(userToRemove)\n }\n\n}`\n }\n\n /**\n * Gets contents of the main (index) application file.\n */\n protected static getAppIndexTemplate(\n express: boolean,\n isEsm: boolean,\n ): string {\n if (express) {\n return `import ${!isEsm ? \"* as \" : \"\"}express from \"express\"\nimport ${!isEsm ? \"* as \" : \"\"}bodyParser from \"body-parser\"\nimport { Request, Response } from \"express\"\nimport { AppDataSource } from \"./data-source${isEsm ? \".js\" : \"\"}\"\nimport { Routes } from \"./routes${isEsm ? \".js\" : \"\"}\"\nimport { User } from \"./entity/User${isEsm ? \".js\" : \"\"}\"\n\nAppDataSource.initialize().then(async () => {\n\n // create express app\n const app = express()\n app.use(bodyParser.json())\n\n // register express routes from defined application routes\n Routes.forEach(route => {\n (app as any)[route.method](route.route, (req: Request, res: Response, next: Function) => {\n const result = (new (route.controller as any))[route.action](req, res, next)\n if (result instanceof Promise) {\n result.then(result => result !== null && result !== undefined ? res.send(result) : undefined)\n\n } else if (result !== null && result !== undefined) {\n res.json(result)\n }\n })\n })\n\n // setup express app here\n // ...\n\n // start express server\n app.listen(3000)\n\n // insert new users for test\n await AppDataSource.manager.save(\n AppDataSource.manager.create(User, {\n firstName: \"Timber\",\n lastName: \"Saw\",\n age: 27\n })\n )\n\n await AppDataSource.manager.save(\n AppDataSource.manager.create(User, {\n firstName: \"Phantom\",\n lastName: \"Assassin\",\n age: 24\n })\n )\n\n console.log(\"Express server has started on port 3000. Open http://localhost:3000/users to see results\")\n\n}).catch(error => console.log(error))\n`\n } else {\n return `import { AppDataSource } from \"./data-source${\n isEsm ? \".js\" : \"\"\n }\"\nimport { User } from \"./entity/User${isEsm ? \".js\" : \"\"}\"\n\nAppDataSource.initialize().then(async () => {\n\n console.log(\"Inserting a new user into the database...\")\n const user = new User()\n user.firstName = \"Timber\"\n user.lastName = \"Saw\"\n user.age = 25\n await AppDataSource.manager.save(user)\n console.log(\"Saved a new user with id: \" + user.id)\n\n console.log(\"Loading users from the database...\")\n const users = await AppDataSource.manager.find(User)\n console.log(\"Loaded users: \", users)\n\n console.log(\"Here you can setup and run express / fastify / any other framework.\")\n\n}).catch(error => console.log(error))\n`\n }\n }\n\n /**\n * Gets contents of the new package.json file.\n */\n protected static getPackageJsonTemplate(\n projectName?: string,\n projectIsEsm?: boolean,\n ): string {\n return JSON.stringify(\n {\n name: projectName || \"typeorm-sample\",\n version: \"0.0.1\",\n description: \"Awesome project developed with TypeORM.\",\n type: projectIsEsm ? \"module\" : \"commonjs\",\n devDependencies: {},\n dependencies: {},\n scripts: {},\n },\n undefined,\n 3,\n )\n }\n\n /**\n * Gets contents of the new docker-compose.yml file.\n */\n protected static getDockerComposeTemplate(database: string): string {\n switch (database) {\n case \"mysql\":\n return `version: '3'\nservices:\n\n mysql:\n image: \"mysql:5.7.10\"\n ports:\n - \"3306:3306\"\n environment:\n MYSQL_ROOT_PASSWORD: \"admin\"\n MYSQL_USER: \"test\"\n MYSQL_PASSWORD: \"test\"\n MYSQL_DATABASE: \"test\"\n\n`\n case \"mariadb\":\n return `version: '3'\nservices:\n\n mariadb:\n image: \"mariadb:10.1.16\"\n ports:\n - \"3306:3306\"\n environment:\n MYSQL_ROOT_PASSWORD: \"admin\"\n MYSQL_USER: \"test\"\n MYSQL_PASSWORD: \"test\"\n MYSQL_DATABASE: \"test\"\n\n`\n case \"postgres\":\n return `version: '3'\nservices:\n\n postgres:\n image: \"postgres:9.6.1\"\n ports:\n - \"5432:5432\"\n environment:\n POSTGRES_USER: \"test\"\n POSTGRES_PASSWORD: \"test\"\n POSTGRES_DB: \"test\"\n\n`\n case \"cockroachdb\":\n return `version: '3'\nservices:\n\n cockroachdb:\n image: \"cockroachdb/cockroach:v2.1.4\"\n command: start --insecure\n ports:\n - \"26257:26257\"\n\n`\n case \"sqlite\":\n case \"better-sqlite3\":\n return `version: '3'\nservices:\n`\n case \"oracle\":\n throw new TypeORMError(\n `You cannot initialize a project with docker for Oracle driver yet.`,\n ) // todo: implement for oracle as well\n\n case \"mssql\":\n return `version: '3'\nservices:\n\n mssql:\n image: \"microsoft/mssql-server-linux:rc2\"\n ports:\n - \"1433:1433\"\n environment:\n SA_PASSWORD: \"Admin12345\"\n ACCEPT_EULA: \"Y\"\n\n`\n case \"mongodb\":\n return `version: '3'\nservices:\n\n mongodb:\n image: \"mongo:4.0.6\"\n container_name: \"typeorm-mongodb\"\n ports:\n - \"27017:27017\"\n\n`\n }\n return \"\"\n }\n\n /**\n * Gets contents of the new readme.md file.\n */\n protected static getReadmeTemplate(options: { docker: boolean }): string {\n let template = `# Awesome Project Build with TypeORM\n\nSteps to run this project:\n\n1. Run \\`npm i\\` command\n`\n\n if (options.docker) {\n template += `2. Run \\`docker-compose up\\` command\n`\n } else {\n template += `2. Setup database settings inside \\`data-source.ts\\` file\n`\n }\n\n template += `3. Run \\`npm start\\` command\n`\n return template\n }\n\n /**\n * Appends to a given package.json template everything needed.\n */\n protected static appendPackageJson(\n packageJsonContents: string,\n database: string,\n express: boolean,\n projectIsEsm: boolean /*, docker: boolean*/,\n ): string {\n const packageJson = JSON.parse(packageJsonContents)\n\n if (!packageJson.devDependencies) packageJson.devDependencies = {}\n Object.assign(packageJson.devDependencies, {\n \"ts-node\": \"10.7.0\",\n \"@types/node\": \"^16.11.10\",\n typescript: \"4.5.2\",\n })\n\n if (!packageJson.dependencies) packageJson.dependencies = {}\n Object.assign(packageJson.dependencies, {\n typeorm: require(\"../package.json\").version,\n \"reflect-metadata\": \"^0.1.13\",\n })\n\n switch (database) {\n case \"mysql\":\n case \"mariadb\":\n packageJson.dependencies[\"mysql\"] = \"^2.14.1\"\n break\n case \"postgres\":\n case \"cockroachdb\":\n packageJson.dependencies[\"pg\"] = \"^8.4.0\"\n break\n case \"sqlite\":\n packageJson.dependencies[\"sqlite3\"] = \"^4.0.3\"\n break\n case \"better-sqlite3\":\n packageJson.dependencies[\"better-sqlite3\"] = \"^7.0.0\"\n break\n case \"oracle\":\n packageJson.dependencies[\"oracledb\"] = \"^1.13.1\"\n break\n case \"mssql\":\n packageJson.dependencies[\"mssql\"] = \"^4.0.4\"\n break\n case \"mongodb\":\n packageJson.dependencies[\"mongodb\"] = \"^3.0.8\"\n break\n }\n\n if (express) {\n packageJson.dependencies[\"express\"] = \"^4.17.2\"\n packageJson.dependencies[\"body-parser\"] = \"^1.19.1\"\n }\n\n if (!packageJson.scripts) packageJson.scripts = {}\n\n if (projectIsEsm)\n Object.assign(packageJson.scripts, {\n start: /*(docker ? \"docker-compose up && \" : \"\") + */ \"node --loader ts-node/esm src/index.ts\",\n typeorm: \"typeorm-ts-node-esm\",\n })\n else\n Object.assign(packageJson.scripts, {\n start: /*(docker ? \"docker-compose up && \" : \"\") + */ \"ts-node src/index.ts\",\n typeorm: \"typeorm-ts-node-commonjs\",\n })\n\n return JSON.stringify(packageJson, undefined, 3)\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -130,8 +130,9 @@ class MigrationGenerateCommand {
|
|
|
130
130
|
console.log(chalk_1.default.green(`Migration ${chalk_1.default.blue(fullPath + extension)} has content:\n\n${chalk_1.default.white(fileContent)}`));
|
|
131
131
|
}
|
|
132
132
|
else {
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
const migrationFileName = path.dirname(fullPath) + "/" + filename;
|
|
134
|
+
await CommandUtils_1.CommandUtils.createFile(migrationFileName, fileContent);
|
|
135
|
+
console.log(chalk_1.default.green(`Migration ${chalk_1.default.blue(migrationFileName)} has been generated successfully.`));
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/MigrationGenerateCommand.ts"],"names":[],"mappings":";;;;AAAA,iDAA6C;AAC7C,qDAA+C;AAE/C,0DAAyB;AACzB,uEAA6D;AAC7D,6DAAyD;AAEzD,mDAA4B;AAC5B,8DAA6B;AAE7B;;GAEG;AACH,MAAa,wBAAwB;IAArC;QACI,YAAO,GAAG,2BAA2B,CAAA;QACrC,aAAQ,GACJ,gFAAgF,CAAA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W,CAAC,UAA6B;QACtD,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;YACnC,OAAO,EAAE,CAAA;SACZ;QAED,OAAO,KAAK,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAA;IAC5C,CAAC;IAED;;OAEG;IACO,MAAM,CAAC,WAAW,CACxB,IAAY,EACZ,SAAiB,EACjB,MAAgB,EAChB,QAAkB;QAElB,MAAM,aAAa,GAAG,GAAG,IAAA,uBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,GAAG,SAAS,EAAE,CAAA;QAE5D,OAAO;;eAEA,aAAa;cACd,aAAa;;;EAGzB,MAAM,CAAC,IAAI,CAAC;CACb,CAAC;;;;EAIA,QAAQ,CAAC,IAAI,CAAC;CACf,CAAC;;;;CAID,CAAA;IACG,CAAC;IAED;;OAEG;IACO,MAAM,CAAC,qBAAqB,CAClC,IAAY,EACZ,SAAiB,EACjB,MAAgB,EAChB,QAAkB;QAElB,MAAM,aAAa,GAAG,GAAG,IAAA,uBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,GAAG,SAAS,EAAE,CAAA;QAE5D,OAAO;;yBAEU,aAAa;cACxB,aAAa;;;EAGzB,MAAM,CAAC,IAAI,CAAC;CACb,CAAC;;;;EAIA,QAAQ,CAAC,IAAI,CAAC;CACf,CAAC;;;CAGD,CAAA;IACG,CAAC;IAED;;OAEG;IACO,MAAM,CAAC,aAAa,CAAC,KAAa;QACxC,MAAM,cAAc,GAAG,IAAA,qBAAM,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;QACxD,OAAO,CACH,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,YAAY,CACtE,CAAA;IACL,CAAC;CACJ;AApRD,4DAoRC","file":"MigrationGenerateCommand.js","sourcesContent":["import { CommandUtils } from \"./CommandUtils\"\nimport { camelCase } from \"../util/StringUtils\"\nimport * as yargs from \"yargs\"\nimport chalk from \"chalk\"\nimport { format } from \"@sqltools/formatter/lib/sqlFormatter\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { DataSource } from \"../data-source\"\nimport * as path from \"path\"\nimport process from \"process\"\n\n/**\n * Generates a new migration file with sql needs to be executed to update schema.\n */\nexport class MigrationGenerateCommand implements yargs.CommandModule {\n command = \"migration:generate <path>\"\n describe =\n \"Generates a new migration file with sql needs to be executed to update schema.\"\n\n builder(args: yargs.Argv) {\n return args\n .option(\"dataSource\", {\n alias: \"d\",\n type: \"string\",\n describe:\n \"Path to the file where your DataSource instance is defined.\",\n demandOption: true,\n })\n .option(\"p\", {\n alias: \"pretty\",\n type: \"boolean\",\n default: false,\n describe: \"Pretty-print generated SQL\",\n })\n .option(\"o\", {\n alias: \"outputJs\",\n type: \"boolean\",\n default: false,\n describe:\n \"Generate a migration file on Javascript instead of Typescript\",\n })\n .option(\"dr\", {\n alias: \"dryrun\",\n type: \"boolean\",\n default: false,\n describe:\n \"Prints out the contents of the migration instead of writing it to a file\",\n })\n .option(\"ch\", {\n alias: \"check\",\n type: \"boolean\",\n default: false,\n describe:\n \"Verifies that the current database is up to date and that no migrations are needed. Otherwise exits with code 1.\",\n })\n .option(\"t\", {\n alias: \"timestamp\",\n type: \"number\",\n default: false,\n describe: \"Custom timestamp for the migration name\",\n })\n }\n\n async handler(args: yargs.Arguments) {\n const timestamp = CommandUtils.getTimestamp(args.timestamp)\n const extension = args.outputJs ? \".js\" : \".ts\"\n const fullPath = (args.path as string).startsWith(\"/\")\n ? (args.path as string)\n : path.resolve(process.cwd(), args.path as string)\n const filename = timestamp + \"-\" + path.basename(fullPath) + extension\n\n let dataSource: DataSource | undefined = undefined\n try {\n dataSource = await CommandUtils.loadDataSource(\n path.resolve(process.cwd(), args.dataSource as string),\n )\n dataSource.setOptions({\n synchronize: false,\n migrationsRun: false,\n dropSchema: false,\n logging: false,\n })\n await dataSource.initialize()\n\n const upSqls: string[] = [],\n downSqls: string[] = []\n\n try {\n const sqlInMemory = await dataSource.driver\n .createSchemaBuilder()\n .log()\n\n if (args.pretty) {\n sqlInMemory.upQueries.forEach((upQuery) => {\n upQuery.query = MigrationGenerateCommand.prettifyQuery(\n upQuery.query,\n )\n })\n sqlInMemory.downQueries.forEach((downQuery) => {\n downQuery.query =\n MigrationGenerateCommand.prettifyQuery(\n downQuery.query,\n )\n })\n }\n\n sqlInMemory.upQueries.forEach((upQuery) => {\n upSqls.push(\n \" await queryRunner.query(`\" +\n upQuery.query.replace(new RegExp(\"`\", \"g\"), \"\\\\`\") +\n \"`\" +\n MigrationGenerateCommand.queryParams(\n upQuery.parameters,\n ) +\n \");\",\n )\n })\n sqlInMemory.downQueries.forEach((downQuery) => {\n downSqls.push(\n \" await queryRunner.query(`\" +\n downQuery.query.replace(\n new RegExp(\"`\", \"g\"),\n \"\\\\`\",\n ) +\n \"`\" +\n MigrationGenerateCommand.queryParams(\n downQuery.parameters,\n ) +\n \");\",\n )\n })\n } finally {\n await dataSource.destroy()\n }\n\n if (!upSqls.length) {\n if (args.check) {\n console.log(\n chalk.green(`No changes in database schema were found`),\n )\n process.exit(0)\n } else {\n console.log(\n chalk.yellow(\n `No changes in database schema were found - cannot generate a migration. To create a new empty migration use \"typeorm migration:create\" command`,\n ),\n )\n process.exit(1)\n }\n } else if (!args.path) {\n console.log(chalk.yellow(\"Please specify a migration path\"))\n process.exit(1)\n }\n\n const fileContent = args.outputJs\n ? MigrationGenerateCommand.getJavascriptTemplate(\n path.basename(fullPath),\n timestamp,\n upSqls,\n downSqls.reverse(),\n )\n : MigrationGenerateCommand.getTemplate(\n path.basename(fullPath),\n timestamp,\n upSqls,\n downSqls.reverse(),\n )\n\n if (args.check) {\n console.log(\n chalk.yellow(\n `Unexpected changes in database schema were found in check mode:\\n\\n${chalk.white(\n fileContent,\n )}`,\n ),\n )\n process.exit(1)\n }\n\n if (args.dryrun) {\n console.log(\n chalk.green(\n `Migration ${chalk.blue(\n fullPath + extension,\n )} has content:\\n\\n${chalk.white(fileContent)}`,\n ),\n )\n } else {\n await CommandUtils.createFile(\n path.dirname(fullPath) + \"/\" + filename,\n fileContent,\n )\n\n console.log(\n chalk.green(\n `Migration ${chalk.blue(\n fullPath + extension,\n )} has been generated successfully.`,\n ),\n )\n }\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during migration generation:\", err)\n process.exit(1)\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Formats query parameters for migration queries if parameters actually exist\n */\n protected static queryParams(parameters: any[] | undefined): string {\n if (!parameters || !parameters.length) {\n return \"\"\n }\n\n return `, ${JSON.stringify(parameters)}`\n }\n\n /**\n * Gets contents of the migration file.\n */\n protected static getTemplate(\n name: string,\n timestamp: number,\n upSqls: string[],\n downSqls: string[],\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n return `import { MigrationInterface, QueryRunner } from \"typeorm\";\n\nexport class ${migrationName} implements MigrationInterface {\n name = '${migrationName}'\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n${upSqls.join(`\n`)}\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n${downSqls.join(`\n`)}\n }\n\n}\n`\n }\n\n /**\n * Gets contents of the migration file in Javascript.\n */\n protected static getJavascriptTemplate(\n name: string,\n timestamp: number,\n upSqls: string[],\n downSqls: string[],\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n return `const { MigrationInterface, QueryRunner } = require(\"typeorm\");\n\nmodule.exports = class ${migrationName} {\n name = '${migrationName}'\n\n async up(queryRunner) {\n${upSqls.join(`\n`)}\n }\n\n async down(queryRunner) {\n${downSqls.join(`\n`)}\n }\n}\n`\n }\n\n /**\n *\n */\n protected static prettifyQuery(query: string) {\n const formattedQuery = format(query, { indent: \" \" })\n return (\n \"\\n\" + formattedQuery.replace(/^/gm, \" \") + \"\\n \"\n )\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["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BAAM,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;QACxD,OAAO,CACH,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,YAAY,CACtE,CAAA;IACL,CAAC;CACJ;AAnRD,4DAmRC","file":"MigrationGenerateCommand.js","sourcesContent":["import { CommandUtils } from \"./CommandUtils\"\nimport { camelCase } from \"../util/StringUtils\"\nimport * as yargs from \"yargs\"\nimport chalk from \"chalk\"\nimport { format } from \"@sqltools/formatter/lib/sqlFormatter\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { DataSource } from \"../data-source\"\nimport * as path from \"path\"\nimport process from \"process\"\n\n/**\n * Generates a new migration file with sql needs to be executed to update schema.\n */\nexport class MigrationGenerateCommand implements yargs.CommandModule {\n command = \"migration:generate <path>\"\n describe =\n \"Generates a new migration file with sql needs to be executed to update schema.\"\n\n builder(args: yargs.Argv) {\n return args\n .option(\"dataSource\", {\n alias: \"d\",\n type: \"string\",\n describe:\n \"Path to the file where your DataSource instance is defined.\",\n demandOption: true,\n })\n .option(\"p\", {\n alias: \"pretty\",\n type: \"boolean\",\n default: false,\n describe: \"Pretty-print generated SQL\",\n })\n .option(\"o\", {\n alias: \"outputJs\",\n type: \"boolean\",\n default: false,\n describe:\n \"Generate a migration file on Javascript instead of Typescript\",\n })\n .option(\"dr\", {\n alias: \"dryrun\",\n type: \"boolean\",\n default: false,\n describe:\n \"Prints out the contents of the migration instead of writing it to a file\",\n })\n .option(\"ch\", {\n alias: \"check\",\n type: \"boolean\",\n default: false,\n describe:\n \"Verifies that the current database is up to date and that no migrations are needed. Otherwise exits with code 1.\",\n })\n .option(\"t\", {\n alias: \"timestamp\",\n type: \"number\",\n default: false,\n describe: \"Custom timestamp for the migration name\",\n })\n }\n\n async handler(args: yargs.Arguments) {\n const timestamp = CommandUtils.getTimestamp(args.timestamp)\n const extension = args.outputJs ? \".js\" : \".ts\"\n const fullPath = (args.path as string).startsWith(\"/\")\n ? (args.path as string)\n : path.resolve(process.cwd(), args.path as string)\n const filename = timestamp + \"-\" + path.basename(fullPath) + extension\n\n let dataSource: DataSource | undefined = undefined\n try {\n dataSource = await CommandUtils.loadDataSource(\n path.resolve(process.cwd(), args.dataSource as string),\n )\n dataSource.setOptions({\n synchronize: false,\n migrationsRun: false,\n dropSchema: false,\n logging: false,\n })\n await dataSource.initialize()\n\n const upSqls: string[] = [],\n downSqls: string[] = []\n\n try {\n const sqlInMemory = await dataSource.driver\n .createSchemaBuilder()\n .log()\n\n if (args.pretty) {\n sqlInMemory.upQueries.forEach((upQuery) => {\n upQuery.query = MigrationGenerateCommand.prettifyQuery(\n upQuery.query,\n )\n })\n sqlInMemory.downQueries.forEach((downQuery) => {\n downQuery.query =\n MigrationGenerateCommand.prettifyQuery(\n downQuery.query,\n )\n })\n }\n\n sqlInMemory.upQueries.forEach((upQuery) => {\n upSqls.push(\n \" await queryRunner.query(`\" +\n upQuery.query.replace(new RegExp(\"`\", \"g\"), \"\\\\`\") +\n \"`\" +\n MigrationGenerateCommand.queryParams(\n upQuery.parameters,\n ) +\n \");\",\n )\n })\n sqlInMemory.downQueries.forEach((downQuery) => {\n downSqls.push(\n \" await queryRunner.query(`\" +\n downQuery.query.replace(\n new RegExp(\"`\", \"g\"),\n \"\\\\`\",\n ) +\n \"`\" +\n MigrationGenerateCommand.queryParams(\n downQuery.parameters,\n ) +\n \");\",\n )\n })\n } finally {\n await dataSource.destroy()\n }\n\n if (!upSqls.length) {\n if (args.check) {\n console.log(\n chalk.green(`No changes in database schema were found`),\n )\n process.exit(0)\n } else {\n console.log(\n chalk.yellow(\n `No changes in database schema were found - cannot generate a migration. To create a new empty migration use \"typeorm migration:create\" command`,\n ),\n )\n process.exit(1)\n }\n } else if (!args.path) {\n console.log(chalk.yellow(\"Please specify a migration path\"))\n process.exit(1)\n }\n\n const fileContent = args.outputJs\n ? MigrationGenerateCommand.getJavascriptTemplate(\n path.basename(fullPath),\n timestamp,\n upSqls,\n downSqls.reverse(),\n )\n : MigrationGenerateCommand.getTemplate(\n path.basename(fullPath),\n timestamp,\n upSqls,\n downSqls.reverse(),\n )\n\n if (args.check) {\n console.log(\n chalk.yellow(\n `Unexpected changes in database schema were found in check mode:\\n\\n${chalk.white(\n fileContent,\n )}`,\n ),\n )\n process.exit(1)\n }\n\n if (args.dryrun) {\n console.log(\n chalk.green(\n `Migration ${chalk.blue(\n fullPath + extension,\n )} has content:\\n\\n${chalk.white(fileContent)}`,\n ),\n )\n } else {\n const migrationFileName =\n path.dirname(fullPath) + \"/\" + filename\n await CommandUtils.createFile(migrationFileName, fileContent)\n\n console.log(\n chalk.green(\n `Migration ${chalk.blue(\n migrationFileName,\n )} has been generated successfully.`,\n ),\n )\n }\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during migration generation:\", err)\n process.exit(1)\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Formats query parameters for migration queries if parameters actually exist\n */\n protected static queryParams(parameters: any[] | undefined): string {\n if (!parameters || !parameters.length) {\n return \"\"\n }\n\n return `, ${JSON.stringify(parameters)}`\n }\n\n /**\n * Gets contents of the migration file.\n */\n protected static getTemplate(\n name: string,\n timestamp: number,\n upSqls: string[],\n downSqls: string[],\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n return `import { MigrationInterface, QueryRunner } from \"typeorm\";\n\nexport class ${migrationName} implements MigrationInterface {\n name = '${migrationName}'\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n${upSqls.join(`\n`)}\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n${downSqls.join(`\n`)}\n }\n\n}\n`\n }\n\n /**\n * Gets contents of the migration file in Javascript.\n */\n protected static getJavascriptTemplate(\n name: string,\n timestamp: number,\n upSqls: string[],\n downSqls: string[],\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n return `const { MigrationInterface, QueryRunner } = require(\"typeorm\");\n\nmodule.exports = class ${migrationName} {\n name = '${migrationName}'\n\n async up(queryRunner) {\n${upSqls.join(`\n`)}\n }\n\n async down(queryRunner) {\n${downSqls.join(`\n`)}\n }\n}\n`\n }\n\n /**\n *\n */\n protected static prettifyQuery(query: string) {\n const formattedQuery = format(query, { indent: \" \" })\n return (\n \"\\n\" + formattedQuery.replace(/^/gm, \" \") + \"\\n \"\n )\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -111,6 +111,14 @@ export interface ColumnOptions extends ColumnCommonOptions {
|
|
|
111
111
|
* Exact name of enum
|
|
112
112
|
*/
|
|
113
113
|
enumName?: string;
|
|
114
|
+
/**
|
|
115
|
+
* If this column is primary key then this specifies the name for it.
|
|
116
|
+
*/
|
|
117
|
+
primaryKeyConstraintName?: string;
|
|
118
|
+
/**
|
|
119
|
+
* If this column is foreign key then this specifies the name for it.
|
|
120
|
+
*/
|
|
121
|
+
foreignKeyConstraintName?: string;
|
|
114
122
|
/**
|
|
115
123
|
* Generated column expression.
|
|
116
124
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/decorator/options/ColumnOptions.ts"],"names":[],"mappings":"","file":"ColumnOptions.js","sourcesContent":["import { ColumnType } from \"../../driver/types/ColumnTypes\"\nimport { ValueTransformer } from \"./ValueTransformer\"\nimport { ColumnCommonOptions } from \"./ColumnCommonOptions\"\n\n/**\n * Describes all column's options.\n */\nexport interface ColumnOptions extends ColumnCommonOptions {\n /**\n * Column type. Must be one of the value from the ColumnTypes class.\n */\n type?: ColumnType\n\n /**\n * Column name in the database.\n */\n name?: string\n\n /**\n * Column type's length. Used only on some column types.\n * For example type = \"string\" and length = \"100\" means that ORM will create a column with type varchar(100).\n */\n length?: string | number\n\n /**\n * Column type's display width. Used only on some column types in MySQL.\n * For example, INT(4) specifies an INT with a display width of four digits.\n */\n width?: number\n\n /**\n * Indicates if column's value can be set to NULL.\n * Default value is \"false\".\n */\n nullable?: boolean\n\n /**\n * Indicates if column value is not updated by \"save\" operation.\n * It means you'll be able to write this value only when you first time insert the object.\n * Default value is \"false\".\n *\n * @deprecated Please use the `update` option instead. Careful, it takes\n * the opposite value to readonly.\n *\n */\n readonly?: boolean\n\n /**\n * Indicates if column value is updated by \"save\" operation.\n * If false, you'll be able to write this value only when you first time insert the object.\n * Default value is \"true\".\n */\n update?: boolean\n\n /**\n * Indicates if column is always selected by QueryBuilder and find operations.\n * Default value is \"true\".\n */\n select?: boolean\n\n /**\n * Indicates if column is inserted by default.\n * Default value is \"true\".\n */\n insert?: boolean\n\n /**\n * Default database value.\n */\n default?: any\n\n /**\n * ON UPDATE trigger. Works only for MySQL.\n */\n onUpdate?: string\n\n /**\n * Indicates if this column is a primary key.\n * Same can be achieved when @PrimaryColumn decorator is used.\n */\n primary?: boolean\n\n /**\n * Specifies if column's value must be unique or not.\n */\n unique?: boolean\n\n /**\n * Column comment. Not supported by all database types.\n */\n comment?: string\n\n /**\n * The precision for a decimal (exact numeric) column (applies only for decimal column), which is the maximum\n * number of digits that are stored for the values.\n */\n precision?: number | null\n\n /**\n * The scale for a decimal (exact numeric) column (applies only for decimal column), which represents the number\n * of digits to the right of the decimal point and must not be greater than precision.\n */\n scale?: number\n\n /**\n * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.\n * If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to this column\n */\n zerofill?: boolean\n\n /**\n * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.\n */\n unsigned?: boolean\n\n /**\n * Defines a column character set.\n * Not supported by all database types.\n */\n charset?: string\n\n /**\n * Defines a column collation.\n */\n collation?: string\n\n /**\n * Array of possible enumerated values.\n */\n enum?: (string | number)[] | Object\n /**\n * Exact name of enum\n */\n enumName?: string\n\n /**\n * Generated column expression.\n */\n asExpression?: string\n\n /**\n * Generated column type.\n */\n generatedType?: \"VIRTUAL\" | \"STORED\"\n\n /**\n * Identity column type. Supports only in Postgres 10+.\n */\n generatedIdentity?: \"ALWAYS\" | \"BY DEFAULT\"\n\n /**\n * Return type of HSTORE column.\n * Returns value as string or as object.\n */\n hstoreType?: \"object\" | \"string\"\n\n /**\n * Indicates if this column is an array.\n * Can be simply set to true or array length can be specified.\n * Supported only by postgres.\n */\n array?: boolean\n\n /**\n * Specifies a value transformer that is to be used to (un)marshal\n * this column when reading or writing to the database.\n */\n transformer?: ValueTransformer | ValueTransformer[]\n\n /**\n * Spatial Feature Type (Geometry, Point, Polygon, etc.)\n */\n spatialFeatureType?: string\n\n /**\n * SRID (Spatial Reference ID (EPSG code))\n */\n srid?: number\n}\n"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../../src/decorator/options/ColumnOptions.ts"],"names":[],"mappings":"","file":"ColumnOptions.js","sourcesContent":["import { ColumnType } from \"../../driver/types/ColumnTypes\"\nimport { ValueTransformer } from \"./ValueTransformer\"\nimport { ColumnCommonOptions } from \"./ColumnCommonOptions\"\n\n/**\n * Describes all column's options.\n */\nexport interface ColumnOptions extends ColumnCommonOptions {\n /**\n * Column type. Must be one of the value from the ColumnTypes class.\n */\n type?: ColumnType\n\n /**\n * Column name in the database.\n */\n name?: string\n\n /**\n * Column type's length. Used only on some column types.\n * For example type = \"string\" and length = \"100\" means that ORM will create a column with type varchar(100).\n */\n length?: string | number\n\n /**\n * Column type's display width. Used only on some column types in MySQL.\n * For example, INT(4) specifies an INT with a display width of four digits.\n */\n width?: number\n\n /**\n * Indicates if column's value can be set to NULL.\n * Default value is \"false\".\n */\n nullable?: boolean\n\n /**\n * Indicates if column value is not updated by \"save\" operation.\n * It means you'll be able to write this value only when you first time insert the object.\n * Default value is \"false\".\n *\n * @deprecated Please use the `update` option instead. Careful, it takes\n * the opposite value to readonly.\n *\n */\n readonly?: boolean\n\n /**\n * Indicates if column value is updated by \"save\" operation.\n * If false, you'll be able to write this value only when you first time insert the object.\n * Default value is \"true\".\n */\n update?: boolean\n\n /**\n * Indicates if column is always selected by QueryBuilder and find operations.\n * Default value is \"true\".\n */\n select?: boolean\n\n /**\n * Indicates if column is inserted by default.\n * Default value is \"true\".\n */\n insert?: boolean\n\n /**\n * Default database value.\n */\n default?: any\n\n /**\n * ON UPDATE trigger. Works only for MySQL.\n */\n onUpdate?: string\n\n /**\n * Indicates if this column is a primary key.\n * Same can be achieved when @PrimaryColumn decorator is used.\n */\n primary?: boolean\n\n /**\n * Specifies if column's value must be unique or not.\n */\n unique?: boolean\n\n /**\n * Column comment. Not supported by all database types.\n */\n comment?: string\n\n /**\n * The precision for a decimal (exact numeric) column (applies only for decimal column), which is the maximum\n * number of digits that are stored for the values.\n */\n precision?: number | null\n\n /**\n * The scale for a decimal (exact numeric) column (applies only for decimal column), which represents the number\n * of digits to the right of the decimal point and must not be greater than precision.\n */\n scale?: number\n\n /**\n * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.\n * If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to this column\n */\n zerofill?: boolean\n\n /**\n * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.\n */\n unsigned?: boolean\n\n /**\n * Defines a column character set.\n * Not supported by all database types.\n */\n charset?: string\n\n /**\n * Defines a column collation.\n */\n collation?: string\n\n /**\n * Array of possible enumerated values.\n */\n enum?: (string | number)[] | Object\n\n /**\n * Exact name of enum\n */\n enumName?: string\n\n /**\n * If this column is primary key then this specifies the name for it.\n */\n primaryKeyConstraintName?: string\n\n /**\n * If this column is foreign key then this specifies the name for it.\n */\n foreignKeyConstraintName?: string\n\n /**\n * Generated column expression.\n */\n asExpression?: string\n\n /**\n * Generated column type.\n */\n generatedType?: \"VIRTUAL\" | \"STORED\"\n\n /**\n * Identity column type. Supports only in Postgres 10+.\n */\n generatedIdentity?: \"ALWAYS\" | \"BY DEFAULT\"\n\n /**\n * Return type of HSTORE column.\n * Returns value as string or as object.\n */\n hstoreType?: \"object\" | \"string\"\n\n /**\n * Indicates if this column is an array.\n * Can be simply set to true or array length can be specified.\n * Supported only by postgres.\n */\n array?: boolean\n\n /**\n * Specifies a value transformer that is to be used to (un)marshal\n * this column when reading or writing to the database.\n */\n transformer?: ValueTransformer | ValueTransformer[]\n\n /**\n * Spatial Feature Type (Geometry, Point, Polygon, etc.)\n */\n spatialFeatureType?: string\n\n /**\n * SRID (Spatial Reference ID (EPSG code))\n */\n srid?: number\n}\n"],"sourceRoot":"../.."}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/decorator/options/JoinColumnOptions.ts"],"names":[],"mappings":"","file":"JoinColumnOptions.js","sourcesContent":["/**\n * Describes join column options.\n */\nexport interface JoinColumnOptions {\n /**\n * Name of the column.\n */\n name?: string\n\n /**\n * Name of the column in the entity to which this column is referenced.\n */\n referencedColumnName?: string // TODO rename to referencedColumn\n}\n"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../../src/decorator/options/JoinColumnOptions.ts"],"names":[],"mappings":"","file":"JoinColumnOptions.js","sourcesContent":["/**\n * Describes join column options.\n */\nexport interface JoinColumnOptions {\n /**\n * Name of the column.\n */\n name?: string\n\n /**\n * Name of the column in the entity to which this column is referenced.\n */\n referencedColumnName?: string // TODO rename to referencedColumn\n\n /**\n * Name of the foreign key constraint.\n */\n foreignKeyConstraintName?: string\n}\n"],"sourceRoot":"../.."}
|
|
@@ -19,4 +19,8 @@ export interface PrimaryGeneratedColumnIdentityOptions {
|
|
|
19
19
|
* Identity column type. Supports only in Postgres 10+.
|
|
20
20
|
*/
|
|
21
21
|
generatedIdentity?: "ALWAYS" | "BY DEFAULT";
|
|
22
|
+
/**
|
|
23
|
+
* Name of the primary key constraint.
|
|
24
|
+
*/
|
|
25
|
+
primaryKeyConstraintName?: string;
|
|
22
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/decorator/options/PrimaryGeneratedColumnIdentityOptions.ts"],"names":[],"mappings":"","file":"PrimaryGeneratedColumnIdentityOptions.js","sourcesContent":["import { PrimaryGeneratedColumnType } from \"../../driver/types/ColumnTypes\"\n\n/**\n * Describes all options for PrimaryGeneratedColumn decorator with identity generation strategy.\n */\nexport interface PrimaryGeneratedColumnIdentityOptions {\n /**\n * Column type. Must be one of the value from the ColumnTypes class.\n */\n type?: PrimaryGeneratedColumnType\n\n /**\n * Column name in the database.\n */\n name?: string\n\n /**\n * Column comment. Not supported by all database types.\n */\n comment?: string\n\n /**\n * Identity column type. Supports only in Postgres 10+.\n */\n generatedIdentity?: \"ALWAYS\" | \"BY DEFAULT\"\n}\n"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../../src/decorator/options/PrimaryGeneratedColumnIdentityOptions.ts"],"names":[],"mappings":"","file":"PrimaryGeneratedColumnIdentityOptions.js","sourcesContent":["import { PrimaryGeneratedColumnType } from \"../../driver/types/ColumnTypes\"\n\n/**\n * Describes all options for PrimaryGeneratedColumn decorator with identity generation strategy.\n */\nexport interface PrimaryGeneratedColumnIdentityOptions {\n /**\n * Column type. Must be one of the value from the ColumnTypes class.\n */\n type?: PrimaryGeneratedColumnType\n\n /**\n * Column name in the database.\n */\n name?: string\n\n /**\n * Column comment. Not supported by all database types.\n */\n comment?: string\n\n /**\n * Identity column type. Supports only in Postgres 10+.\n */\n generatedIdentity?: \"ALWAYS\" | \"BY DEFAULT\"\n\n /**\n * Name of the primary key constraint.\n */\n primaryKeyConstraintName?: string\n}\n"],"sourceRoot":"../.."}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/decorator/options/PrimaryGeneratedColumnNumericOptions.ts"],"names":[],"mappings":"","file":"PrimaryGeneratedColumnNumericOptions.js","sourcesContent":["import { PrimaryGeneratedColumnType } from \"../../driver/types/ColumnTypes\"\n\n/**\n * Describes all options for PrimaryGeneratedColumn decorator with numeric generation strategy.\n */\nexport interface PrimaryGeneratedColumnNumericOptions {\n /**\n * Column type. Must be one of the value from the ColumnTypes class.\n */\n type?: PrimaryGeneratedColumnType\n\n /**\n * Column name in the database.\n */\n name?: string\n\n /**\n * Column comment. Not supported by all database types.\n */\n comment?: string\n\n /**\n * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.\n * If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column\n */\n zerofill?: boolean\n\n /**\n * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.\n */\n unsigned?: boolean\n}\n"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../../src/decorator/options/PrimaryGeneratedColumnNumericOptions.ts"],"names":[],"mappings":"","file":"PrimaryGeneratedColumnNumericOptions.js","sourcesContent":["import { PrimaryGeneratedColumnType } from \"../../driver/types/ColumnTypes\"\n\n/**\n * Describes all options for PrimaryGeneratedColumn decorator with numeric generation strategy.\n */\nexport interface PrimaryGeneratedColumnNumericOptions {\n /**\n * Column type. Must be one of the value from the ColumnTypes class.\n */\n type?: PrimaryGeneratedColumnType\n\n /**\n * Column name in the database.\n */\n name?: string\n\n /**\n * Column comment. Not supported by all database types.\n */\n comment?: string\n\n /**\n * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.\n * If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column\n */\n zerofill?: boolean\n\n /**\n * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.\n */\n unsigned?: boolean\n\n /**\n * Name of the primary key constraint.\n */\n primaryKeyConstraintName?: string\n}\n"],"sourceRoot":"../.."}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/decorator/options/PrimaryGeneratedColumnUUIDOptions.ts"],"names":[],"mappings":"","file":"PrimaryGeneratedColumnUUIDOptions.js","sourcesContent":["/**\n * Describes all options for PrimaryGeneratedColumn decorator with numeric uuid strategy.\n */\nexport interface PrimaryGeneratedColumnUUIDOptions {\n /**\n * Column name in the database.\n */\n name?: string\n\n /**\n * Column comment. Not supported by all database types.\n */\n comment?: string\n}\n"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../../src/decorator/options/PrimaryGeneratedColumnUUIDOptions.ts"],"names":[],"mappings":"","file":"PrimaryGeneratedColumnUUIDOptions.js","sourcesContent":["/**\n * Describes all options for PrimaryGeneratedColumn decorator with numeric uuid strategy.\n */\nexport interface PrimaryGeneratedColumnUUIDOptions {\n /**\n * Column name in the database.\n */\n name?: string\n\n /**\n * Column comment. Not supported by all database types.\n */\n comment?: string\n\n /**\n * Name of the primary key constraint.\n */\n primaryKeyConstraintName?: string\n}\n"],"sourceRoot":"../.."}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/decorator/relations/JoinColumn.ts"],"names":[],"mappings":";;;AAAA,2CAAsD;AAyBtD;;;;GAIG;AACH,SAAgB,UAAU,CACtB,qBAA+D;IAE/D,OAAO,UAAU,MAAc,EAAE,YAAoB;QACjD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC;YAChD,CAAC,CAAC,qBAAqB;YACvB,CAAC,CAAC,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAA;QACnC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACxB,IAAA,gCAAsB,GAAE,CAAC,WAAW,CAAC,IAAI,CAAC;gBACtC,MAAM,EAAE,MAAM,CAAC,WAAW;gBAC1B,YAAY,EAAE,YAAY;gBAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;
|
|
1
|
+
{"version":3,"sources":["../../src/decorator/relations/JoinColumn.ts"],"names":[],"mappings":";;;AAAA,2CAAsD;AAyBtD;;;;GAIG;AACH,SAAgB,UAAU,CACtB,qBAA+D;IAE/D,OAAO,UAAU,MAAc,EAAE,YAAoB;QACjD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC;YAChD,CAAC,CAAC,qBAAqB;YACvB,CAAC,CAAC,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAA;QACnC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACxB,IAAA,gCAAsB,GAAE,CAAC,WAAW,CAAC,IAAI,CAAC;gBACtC,MAAM,EAAE,MAAM,CAAC,WAAW;gBAC1B,YAAY,EAAE,YAAY;gBAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;gBAClD,wBAAwB,EAAE,OAAO,CAAC,wBAAwB;aACnC,CAAC,CAAA;QAChC,CAAC,CAAC,CAAA;IACN,CAAC,CAAA;AACL,CAAC;AAjBD,gCAiBC","file":"JoinColumn.js","sourcesContent":["import { getMetadataArgsStorage } from \"../../globals\"\nimport { JoinColumnMetadataArgs } from \"../../metadata-args/JoinColumnMetadataArgs\"\nimport { JoinColumnOptions } from \"../options/JoinColumnOptions\"\n\n/**\n * JoinColumn decorator used on one-to-one relations to specify owner side of relationship.\n * It also can be used on both one-to-one and many-to-one relations to specify custom column name\n * or custom referenced column.\n */\nexport function JoinColumn(): PropertyDecorator\n\n/**\n * JoinColumn decorator used on one-to-one relations to specify owner side of relationship.\n * It also can be used on both one-to-one and many-to-one relations to specify custom column name\n * or custom referenced column.\n */\nexport function JoinColumn(options: JoinColumnOptions): PropertyDecorator\n\n/**\n * JoinColumn decorator used on one-to-one relations to specify owner side of relationship.\n * It also can be used on both one-to-one and many-to-one relations to specify custom column name\n * or custom referenced column.\n */\nexport function JoinColumn(options: JoinColumnOptions[]): PropertyDecorator\n\n/**\n * JoinColumn decorator used on one-to-one relations to specify owner side of relationship.\n * It also can be used on both one-to-one and many-to-one relations to specify custom column name\n * or custom referenced column.\n */\nexport function JoinColumn(\n optionsOrOptionsArray?: JoinColumnOptions | JoinColumnOptions[],\n): PropertyDecorator {\n return function (object: Object, propertyName: string) {\n const options = Array.isArray(optionsOrOptionsArray)\n ? optionsOrOptionsArray\n : [optionsOrOptionsArray || {}]\n options.forEach((options) => {\n getMetadataArgsStorage().joinColumns.push({\n target: object.constructor,\n propertyName: propertyName,\n name: options.name,\n referencedColumnName: options.referencedColumnName,\n foreignKeyConstraintName: options.foreignKeyConstraintName,\n } as JoinColumnMetadataArgs)\n })\n }\n}\n"],"sourceRoot":"../.."}
|