typeorm 0.2.42-dev.8898a71 → 0.2.42-dev.93bf96e
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/browser/common/DeepPartial.d.ts +3 -3
- package/browser/common/DeepPartial.js.map +1 -1
- package/browser/decorator/listeners/AfterRecover.d.ts +4 -0
- package/browser/decorator/listeners/AfterRecover.js +16 -0
- package/browser/decorator/listeners/AfterRecover.js.map +1 -0
- package/browser/decorator/listeners/AfterSoftRemove.d.ts +4 -0
- package/browser/decorator/listeners/AfterSoftRemove.js +16 -0
- package/browser/decorator/listeners/AfterSoftRemove.js.map +1 -0
- package/browser/decorator/listeners/BeforeRecover.d.ts +4 -0
- package/browser/decorator/listeners/BeforeRecover.js +16 -0
- package/browser/decorator/listeners/BeforeRecover.js.map +1 -0
- package/browser/decorator/listeners/BeforeSoftRemove.d.ts +4 -0
- package/browser/decorator/listeners/BeforeSoftRemove.js +16 -0
- package/browser/decorator/listeners/BeforeSoftRemove.js.map +1 -0
- package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js +1 -1
- package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +2 -2
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/browser/entity-manager/EntityManager.js.map +1 -1
- package/browser/entity-manager/MongoEntityManager.d.ts +2 -0
- package/browser/entity-manager/MongoEntityManager.js +35 -4
- package/browser/entity-manager/MongoEntityManager.js.map +1 -1
- package/browser/index.d.ts +4 -0
- package/browser/index.js +4 -0
- package/browser/index.js.map +1 -1
- package/browser/metadata/EntityMetadata.d.ts +16 -0
- package/browser/metadata/EntityMetadata.js +16 -0
- package/browser/metadata/EntityMetadata.js.map +1 -1
- package/browser/metadata/types/EventListenerTypes.d.ts +5 -1
- package/browser/metadata/types/EventListenerTypes.js +4 -0
- package/browser/metadata/types/EventListenerTypes.js.map +1 -1
- package/browser/metadata-builder/EntityMetadataBuilder.js +4 -0
- package/browser/metadata-builder/EntityMetadataBuilder.js.map +1 -1
- package/browser/persistence/SubjectExecutor.d.ts +2 -2
- package/browser/persistence/SubjectExecutor.js +6 -6
- package/browser/persistence/SubjectExecutor.js.map +1 -1
- package/browser/platform/PlatformTools.d.ts +1 -0
- package/browser/platform/PlatformTools.js +5 -0
- package/browser/platform/PlatformTools.js.map +1 -1
- package/browser/query-builder/SoftDeleteQueryBuilder.js +44 -30
- package/browser/query-builder/SoftDeleteQueryBuilder.js.map +1 -1
- package/browser/repository/TreeRepository.js +2 -1
- package/browser/repository/TreeRepository.js.map +1 -1
- package/browser/subscriber/Broadcaster.d.ts +40 -0
- package/browser/subscriber/Broadcaster.js +156 -0
- package/browser/subscriber/Broadcaster.js.map +1 -1
- package/browser/subscriber/EntitySubscriberInterface.d.ts +18 -0
- package/browser/subscriber/EntitySubscriberInterface.js.map +1 -1
- package/browser/subscriber/event/RecoverEvent.d.ts +6 -0
- package/browser/subscriber/event/RecoverEvent.js +3 -0
- package/browser/subscriber/event/RecoverEvent.js.map +1 -0
- package/browser/subscriber/event/SoftRemoveEvent.d.ts +6 -0
- package/browser/subscriber/event/SoftRemoveEvent.js +3 -0
- package/browser/subscriber/event/SoftRemoveEvent.js.map +1 -0
- package/commands/CacheClearCommand.js +3 -3
- package/commands/CacheClearCommand.js.map +1 -1
- package/commands/EntityCreateCommand.js +2 -2
- package/commands/EntityCreateCommand.js.map +1 -1
- package/commands/InitCommand.js +2 -2
- package/commands/InitCommand.js.map +1 -1
- package/commands/MigrationCreateCommand.js +2 -2
- package/commands/MigrationCreateCommand.js.map +1 -1
- package/commands/MigrationGenerateCommand.js +2 -2
- package/commands/MigrationGenerateCommand.js.map +1 -1
- package/commands/MigrationRevertCommand.js +2 -3
- package/commands/MigrationRevertCommand.js.map +1 -1
- package/commands/MigrationRunCommand.js +2 -3
- package/commands/MigrationRunCommand.js.map +1 -1
- package/commands/MigrationShowCommand.js +5 -7
- package/commands/MigrationShowCommand.js.map +1 -1
- package/commands/QueryCommand.js +1 -2
- package/commands/QueryCommand.js.map +1 -1
- package/commands/SchemaDropCommand.js +2 -2
- package/commands/SchemaDropCommand.js.map +1 -1
- package/commands/SchemaLogCommand.js +2 -2
- package/commands/SchemaLogCommand.js.map +1 -1
- package/commands/SchemaSyncCommand.js +2 -2
- package/commands/SchemaSyncCommand.js.map +1 -1
- package/commands/SubscriberCreateCommand.js +3 -3
- package/commands/SubscriberCreateCommand.js.map +1 -1
- package/common/DeepPartial.d.ts +3 -3
- package/common/DeepPartial.js.map +1 -1
- package/decorator/listeners/AfterRecover.d.ts +4 -0
- package/decorator/listeners/AfterRecover.js +20 -0
- package/decorator/listeners/AfterRecover.js.map +1 -0
- package/decorator/listeners/AfterSoftRemove.d.ts +4 -0
- package/decorator/listeners/AfterSoftRemove.js +20 -0
- package/decorator/listeners/AfterSoftRemove.js.map +1 -0
- package/decorator/listeners/BeforeRecover.d.ts +4 -0
- package/decorator/listeners/BeforeRecover.js +20 -0
- package/decorator/listeners/BeforeRecover.js.map +1 -0
- package/decorator/listeners/BeforeSoftRemove.d.ts +4 -0
- package/decorator/listeners/BeforeSoftRemove.js +20 -0
- package/decorator/listeners/BeforeSoftRemove.js.map +1 -0
- package/driver/aurora-data-api/AuroraDataApiQueryRunner.js +1 -1
- package/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +2 -2
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/entity-manager/EntityManager.js.map +1 -1
- package/entity-manager/MongoEntityManager.d.ts +2 -0
- package/entity-manager/MongoEntityManager.js +35 -4
- package/entity-manager/MongoEntityManager.js.map +1 -1
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/index.js.map +1 -1
- package/index.mjs +8 -0
- package/metadata/EntityMetadata.d.ts +16 -0
- package/metadata/EntityMetadata.js +16 -0
- package/metadata/EntityMetadata.js.map +1 -1
- package/metadata/types/EventListenerTypes.d.ts +5 -1
- package/metadata/types/EventListenerTypes.js +4 -0
- package/metadata/types/EventListenerTypes.js.map +1 -1
- package/metadata-builder/EntityMetadataBuilder.js +4 -0
- package/metadata-builder/EntityMetadataBuilder.js.map +1 -1
- package/package.json +1 -1
- package/persistence/SubjectExecutor.d.ts +2 -2
- package/persistence/SubjectExecutor.js +6 -6
- package/persistence/SubjectExecutor.js.map +1 -1
- package/platform/PlatformTools.d.ts +1 -0
- package/platform/PlatformTools.js +5 -0
- package/platform/PlatformTools.js.map +1 -1
- package/query-builder/SoftDeleteQueryBuilder.js +44 -30
- package/query-builder/SoftDeleteQueryBuilder.js.map +1 -1
- package/repository/TreeRepository.js +2 -1
- package/repository/TreeRepository.js.map +1 -1
- package/subscriber/Broadcaster.d.ts +40 -0
- package/subscriber/Broadcaster.js +156 -0
- package/subscriber/Broadcaster.js.map +1 -1
- package/subscriber/EntitySubscriberInterface.d.ts +18 -0
- package/subscriber/EntitySubscriberInterface.js.map +1 -1
- package/subscriber/event/RecoverEvent.d.ts +6 -0
- package/subscriber/event/RecoverEvent.js +4 -0
- package/subscriber/event/RecoverEvent.js.map +1 -0
- package/subscriber/event/SoftRemoveEvent.d.ts +6 -0
- package/subscriber/event/SoftRemoveEvent.js +4 -0
- package/subscriber/event/SoftRemoveEvent.js.map +1 -0
- package/typeorm-class-transformer-shim.js +20 -0
- package/typeorm-model-shim.js +20 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/subscriber/Broadcaster.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAyBtD;;GAEG;AACH;IAEI,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,qBAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAC5C,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAEtE,+BA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AAC,SAAS,EAAE;wBAC/E,IAAM,eAAe,GAAG,UAAU,CAAC,SAAU,CAAC,MAAM,EAAE;4BAClD,UAAU,EAAE,KAAI,CAAC,WAAW,CAAC,UAAU;4BACvC,WAAW,EAAE,KAAI,CAAC,WAAW;4BAC7B,OAAO,EAAE,KAAI,CAAC,WAAW,CAAC,OAAO;4BACjC,MAAM,EAAE,MAAM;4BACd,QAAQ,EAAE,QAAQ;yBACrB,CAAC,CAAC;wBACH,IAAI,eAAe,YAAY,OAAO;4BAClC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;wBAC1C,MAAM,CAAC,KAAK,EAAE,CAAC;qBAClB;gBACL,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;;OAGG;IACO,yCAAmB,GAA7B,UAA8B,UAA0C,EAAE,MAAuB;QAC7F,OAAQ,CAAC,UAAU,CAAC,QAAQ;YACxB,CAAC,UAAU,CAAC,QAAQ,EAAE;YACtB,UAAU,CAAC,QAAQ,EAAE,KAAK,MAAM;YAChC,UAAU,CAAC,QAAQ,EAAE,KAAK,MAAM;YAChC,UAAU,CAAC,QAAQ,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACpD,CAAC;IAEL,kBAAC;AAAD,CAvdA,AAudC,IAAA","file":"Broadcaster.js","sourcesContent":["import {EntitySubscriberInterface} from \"./EntitySubscriberInterface\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {EntityMetadata} from \"../metadata/EntityMetadata\";\nimport {BroadcasterResult} from \"./BroadcasterResult\";\nimport {ColumnMetadata} from \"../metadata/ColumnMetadata\";\nimport {RelationMetadata} from \"../metadata/RelationMetadata\";\n\ninterface BroadcasterEvents {\n \"BeforeTransactionCommit\": () => void;\n \"AfterTransactionCommit\": () => void;\n \"BeforeTransactionStart\": () => void;\n \"AfterTransactionStart\": () => void;\n \"BeforeTransactionRollback\": () => void;\n \"AfterTransactionRollback\": () => void;\n\n \"BeforeUpdate\": (metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral, updatedColumns?: ColumnMetadata[], updatedRelations?: RelationMetadata[]) => void;\n \"AfterUpdate\": (metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral, updatedColumns?: ColumnMetadata[], updatedRelations?: RelationMetadata[]) => void;\n\n \"BeforeInsert\": (metadata: EntityMetadata, entity: ObjectLiteral | undefined) => void;\n \"AfterInsert\": (metadata: EntityMetadata, entity: ObjectLiteral | undefined) => void;\n\n \"BeforeRemove\": (metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral) => void;\n \"AfterRemove\": (metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral) => void;\n\n \"Load\": (metadata: EntityMetadata, entities: ObjectLiteral[]) => void;\n}\n\n\n/**\n * Broadcaster provides a helper methods to broadcast events to the subscribers.\n */\nexport class Broadcaster {\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(private queryRunner: QueryRunner) {\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n async broadcast<U extends keyof BroadcasterEvents>(event: U, ...args: Parameters<BroadcasterEvents[U]>): Promise<void> {\n const result = new BroadcasterResult();\n\n const broadcastFunction = this[`broadcast${event}Event` as keyof this];\n\n if (typeof broadcastFunction === \"function\") {\n (broadcastFunction as any).call(\n this,\n result,\n ...args\n );\n }\n\n await result.wait();\n }\n\n /**\n * Broadcasts \"BEFORE_INSERT\" event.\n * Before insert event is executed before entity is being inserted to the database for the first time.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastBeforeInsertEvent(result: BroadcasterResult, metadata: EntityMetadata, entity: undefined | ObjectLiteral): void {\n\n if (entity && metadata.beforeInsertListeners.length) {\n metadata.beforeInsertListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.beforeInsert) {\n const executionResult = subscriber.beforeInsert({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"BEFORE_UPDATE\" event.\n * Before update event is executed before entity is being updated in the database.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastBeforeUpdateEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral, updatedColumns?: ColumnMetadata[], updatedRelations?: RelationMetadata[]): void { // todo: send relations too?\n if (entity && metadata.beforeUpdateListeners.length) {\n metadata.beforeUpdateListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.beforeUpdate) {\n const executionResult = subscriber.beforeUpdate({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata,\n databaseEntity: databaseEntity,\n updatedColumns: updatedColumns || [],\n updatedRelations: updatedRelations || []\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"BEFORE_REMOVE\" event.\n * Before remove event is executed before entity is being removed from the database.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastBeforeRemoveEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral): void {\n if (entity && metadata.beforeRemoveListeners.length) {\n metadata.beforeRemoveListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.beforeRemove) {\n const executionResult = subscriber.beforeRemove({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata,\n databaseEntity: databaseEntity,\n entityId: metadata.getEntityIdMixedMap(databaseEntity)\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"AFTER_INSERT\" event.\n * After insert event is executed after entity is being persisted to the database for the first time.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastAfterInsertEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral): void {\n\n if (entity && metadata.afterInsertListeners.length) {\n metadata.afterInsertListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.afterInsert) {\n const executionResult = subscriber.afterInsert({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"BEFORE_TRANSACTION_START\" event.\n */\n broadcastBeforeTransactionStartEvent(result: BroadcasterResult): void {\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (subscriber.beforeTransactionStart) {\n const executionResult = subscriber.beforeTransactionStart({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"AFTER_TRANSACTION_START\" event.\n */\n broadcastAfterTransactionStartEvent(result: BroadcasterResult): void {\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (subscriber.afterTransactionStart) {\n const executionResult = subscriber.afterTransactionStart({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"BEFORE_TRANSACTION_COMMIT\" event.\n */\n broadcastBeforeTransactionCommitEvent(result: BroadcasterResult): void {\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (subscriber.beforeTransactionCommit) {\n const executionResult = subscriber.beforeTransactionCommit({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"AFTER_TRANSACTION_COMMIT\" event.\n */\n broadcastAfterTransactionCommitEvent(result: BroadcasterResult): void {\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (subscriber.afterTransactionCommit) {\n const executionResult = subscriber.afterTransactionCommit({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"BEFORE_TRANSACTION_ROLLBACK\" event.\n */\n broadcastBeforeTransactionRollbackEvent(result: BroadcasterResult): void {\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (subscriber.beforeTransactionRollback) {\n const executionResult = subscriber.beforeTransactionRollback({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"AFTER_TRANSACTION_ROLLBACK\" event.\n */\n broadcastAfterTransactionRollbackEvent(result: BroadcasterResult): void {\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (subscriber.afterTransactionRollback) {\n const executionResult = subscriber.afterTransactionRollback({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"AFTER_UPDATE\" event.\n * After update event is executed after entity is being updated in the database.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastAfterUpdateEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral, updatedColumns?: ColumnMetadata[], updatedRelations?: RelationMetadata[]): void {\n\n if (entity && metadata.afterUpdateListeners.length) {\n metadata.afterUpdateListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.afterUpdate) {\n const executionResult = subscriber.afterUpdate({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata,\n databaseEntity: databaseEntity,\n updatedColumns: updatedColumns || [],\n updatedRelations: updatedRelations || []\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"AFTER_REMOVE\" event.\n * After remove event is executed after entity is being removed from the database.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastAfterRemoveEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral): void {\n\n if (entity && metadata.afterRemoveListeners.length) {\n metadata.afterRemoveListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.afterRemove) {\n const executionResult = subscriber.afterRemove({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata,\n databaseEntity: databaseEntity,\n entityId: metadata.getEntityIdMixedMap(databaseEntity)\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * @deprecated Use `broadcastLoadForAllEvent`\n */\n broadcastLoadEventsForAll(result: BroadcasterResult, metadata: EntityMetadata, entities: ObjectLiteral[]): void {\n return this.broadcastLoadEvent(result, metadata, entities);\n }\n\n /**\n * Broadcasts \"AFTER_LOAD\" event for all given entities, and their sub-entities.\n * After load event is executed after entity has been loaded from the database.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastLoadEvent(result: BroadcasterResult, metadata: EntityMetadata, entities: ObjectLiteral[]): void {\n entities.forEach(entity => {\n if (entity instanceof Promise) // todo: check why need this?\n return;\n\n // collect load events for all children entities that were loaded with the main entity\n if (metadata.relations.length) {\n metadata.relations.forEach(relation => {\n\n // in lazy relations we cannot simply access to entity property because it will cause a getter and a database query\n if (relation.isLazy && !entity.hasOwnProperty(relation.propertyName))\n return;\n\n const value = relation.getEntityValue(entity);\n if (value instanceof Object)\n this.broadcastLoadEvent(result, relation.inverseEntityMetadata, Array.isArray(value) ? value : [value]);\n });\n }\n\n if (metadata.afterLoadListeners.length) {\n metadata.afterLoadListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.afterLoad) {\n const executionResult = subscriber.afterLoad!(entity, {\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n });\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Checks if subscriber's methods can be executed by checking if its don't listen to the particular entity,\n * or listens our entity.\n */\n protected isAllowedSubscriber(subscriber: EntitySubscriberInterface<any>, target: Function|string): boolean {\n return !subscriber.listenTo ||\n !subscriber.listenTo() ||\n subscriber.listenTo() === Object ||\n subscriber.listenTo() === target ||\n subscriber.listenTo().isPrototypeOf(target);\n }\n\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/subscriber/Broadcaster.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AA+BtD;;GAEG;AACH;IAEI,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,qBAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAC5C,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAEtE,+BAAS,GAAf,UAAmD,KAAQ;QAAE,cAAyC;aAAzC,UAAyC,EAAzC,qBAAyC,EAAzC,IAAyC;YAAzC,6BAAyC;;;;;;;;wBAC5F,MAAM,GAAG,IAAI,iBAAiB,EAAE,CAAC;wBAEjC,iBAAiB,GAAG,IAAI,CAAC,cAAY,KAAK,UAAqB,CAAC,CAAC;wBAEvE,IAAI,OAAO,iBAAiB,KAAK,UAAU,EAAE;4BACzC,CAAA,KAAC,iBAAyB,CAAA,CAAC,IAAI,0BAC3B,IAAI;gCACJ,MAAM,UACH,IAAI,WACT;yBACL;wBAED,qBAAM,MAAM,CAAC,IAAI,EAAE,EAAA;;wBAAnB,SAAmB,CAAC;;;;;KACvB;IAED;;;;;;;OAOG;IACH,gDAA0B,GAA1B,UAA2B,MAAyB,EAAE,QAAwB,EAAE,MAAiC;QAAjH,iBA6BC;QA3BG,IAAI,MAAM,IAAI,QAAQ,CAAC,qBAAqB,CAAC,MAAM,EAAE;YACjD,QAAQ,CAAC,qBAAqB,CAAC,OAAO,CAAC,UAAA,QAAQ;gBAC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Ae,CAAC,CAAC;wBAC1C,MAAM,CAAC,KAAK,EAAE,CAAC;qBAClB;gBACL,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;;OAGG;IACO,yCAAmB,GAA7B,UAA8B,UAA0C,EAAE,MAAuB;QAC7F,OAAQ,CAAC,UAAU,CAAC,QAAQ;YACxB,CAAC,UAAU,CAAC,QAAQ,EAAE;YACtB,UAAU,CAAC,QAAQ,EAAE,KAAK,MAAM;YAChC,UAAU,CAAC,QAAQ,EAAE,KAAK,MAAM;YAChC,UAAU,CAAC,QAAQ,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACpD,CAAC;IAEL,kBAAC;AAAD,CAznBA,AAynBC,IAAA","file":"Broadcaster.js","sourcesContent":["import {EntitySubscriberInterface} from \"./EntitySubscriberInterface\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {EntityMetadata} from \"../metadata/EntityMetadata\";\nimport {BroadcasterResult} from \"./BroadcasterResult\";\nimport {ColumnMetadata} from \"../metadata/ColumnMetadata\";\nimport {RelationMetadata} from \"../metadata/RelationMetadata\";\n\ninterface BroadcasterEvents {\n \"BeforeTransactionCommit\": () => void;\n \"AfterTransactionCommit\": () => void;\n \"BeforeTransactionStart\": () => void;\n \"AfterTransactionStart\": () => void;\n \"BeforeTransactionRollback\": () => void;\n \"AfterTransactionRollback\": () => void;\n\n \"BeforeUpdate\": (metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral, updatedColumns?: ColumnMetadata[], updatedRelations?: RelationMetadata[]) => void;\n \"AfterUpdate\": (metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral, updatedColumns?: ColumnMetadata[], updatedRelations?: RelationMetadata[]) => void;\n\n \"BeforeInsert\": (metadata: EntityMetadata, entity: ObjectLiteral | undefined) => void;\n \"AfterInsert\": (metadata: EntityMetadata, entity: ObjectLiteral | undefined) => void;\n\n \"BeforeRemove\": (metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral) => void;\n \"AfterRemove\": (metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral) => void;\n\n \"BeforeSoftRemove\": (metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral) => void;\n \"AfterSoftRemove\": (metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral) => void;\n\n \"BeforeRecover\": (metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral) => void;\n \"AfterRecover\": (metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral) => void;\n\n \"Load\": (metadata: EntityMetadata, entities: ObjectLiteral[]) => void;\n}\n\n\n/**\n * Broadcaster provides a helper methods to broadcast events to the subscribers.\n */\nexport class Broadcaster {\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(private queryRunner: QueryRunner) {\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n async broadcast<U extends keyof BroadcasterEvents>(event: U, ...args: Parameters<BroadcasterEvents[U]>): Promise<void> {\n const result = new BroadcasterResult();\n\n const broadcastFunction = this[`broadcast${event}Event` as keyof this];\n\n if (typeof broadcastFunction === \"function\") {\n (broadcastFunction as any).call(\n this,\n result,\n ...args\n );\n }\n\n await result.wait();\n }\n\n /**\n * Broadcasts \"BEFORE_INSERT\" event.\n * Before insert event is executed before entity is being inserted to the database for the first time.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastBeforeInsertEvent(result: BroadcasterResult, metadata: EntityMetadata, entity: undefined | ObjectLiteral): void {\n\n if (entity && metadata.beforeInsertListeners.length) {\n metadata.beforeInsertListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.beforeInsert) {\n const executionResult = subscriber.beforeInsert({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"BEFORE_UPDATE\" event.\n * Before update event is executed before entity is being updated in the database.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastBeforeUpdateEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral, updatedColumns?: ColumnMetadata[], updatedRelations?: RelationMetadata[]): void { // todo: send relations too?\n if (entity && metadata.beforeUpdateListeners.length) {\n metadata.beforeUpdateListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.beforeUpdate) {\n const executionResult = subscriber.beforeUpdate({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata,\n databaseEntity: databaseEntity,\n updatedColumns: updatedColumns || [],\n updatedRelations: updatedRelations || []\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"BEFORE_REMOVE\" event.\n * Before remove event is executed before entity is being removed from the database.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastBeforeRemoveEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral): void {\n if (entity && metadata.beforeRemoveListeners.length) {\n metadata.beforeRemoveListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.beforeRemove) {\n const executionResult = subscriber.beforeRemove({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata,\n databaseEntity: databaseEntity,\n entityId: metadata.getEntityIdMixedMap(databaseEntity)\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"BEFORE_SOFT_REMOVE\" event.\n * Before soft remove event is executed before entity is being soft removed from the database.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastBeforeSoftRemoveEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral): void {\n if (entity && metadata.beforeSoftRemoveListeners.length) {\n metadata.beforeSoftRemoveListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.beforeSoftRemove) {\n const executionResult = subscriber.beforeSoftRemove({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata,\n databaseEntity: databaseEntity,\n entityId: metadata.getEntityIdMixedMap(databaseEntity)\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"BEFORE_RECOVER\" event.\n * Before recover event is executed before entity is being recovered in the database.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastBeforeRecoverEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral): void {\n if (entity && metadata.beforeRecoverListeners.length) {\n metadata.beforeRecoverListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.beforeRecover) {\n const executionResult = subscriber.beforeRecover({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata,\n databaseEntity: databaseEntity,\n entityId: metadata.getEntityIdMixedMap(databaseEntity)\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"AFTER_INSERT\" event.\n * After insert event is executed after entity is being persisted to the database for the first time.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastAfterInsertEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral): void {\n\n if (entity && metadata.afterInsertListeners.length) {\n metadata.afterInsertListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.afterInsert) {\n const executionResult = subscriber.afterInsert({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"BEFORE_TRANSACTION_START\" event.\n */\n broadcastBeforeTransactionStartEvent(result: BroadcasterResult): void {\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (subscriber.beforeTransactionStart) {\n const executionResult = subscriber.beforeTransactionStart({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"AFTER_TRANSACTION_START\" event.\n */\n broadcastAfterTransactionStartEvent(result: BroadcasterResult): void {\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (subscriber.afterTransactionStart) {\n const executionResult = subscriber.afterTransactionStart({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"BEFORE_TRANSACTION_COMMIT\" event.\n */\n broadcastBeforeTransactionCommitEvent(result: BroadcasterResult): void {\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (subscriber.beforeTransactionCommit) {\n const executionResult = subscriber.beforeTransactionCommit({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"AFTER_TRANSACTION_COMMIT\" event.\n */\n broadcastAfterTransactionCommitEvent(result: BroadcasterResult): void {\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (subscriber.afterTransactionCommit) {\n const executionResult = subscriber.afterTransactionCommit({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"BEFORE_TRANSACTION_ROLLBACK\" event.\n */\n broadcastBeforeTransactionRollbackEvent(result: BroadcasterResult): void {\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (subscriber.beforeTransactionRollback) {\n const executionResult = subscriber.beforeTransactionRollback({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"AFTER_TRANSACTION_ROLLBACK\" event.\n */\n broadcastAfterTransactionRollbackEvent(result: BroadcasterResult): void {\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (subscriber.afterTransactionRollback) {\n const executionResult = subscriber.afterTransactionRollback({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"AFTER_UPDATE\" event.\n * After update event is executed after entity is being updated in the database.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastAfterUpdateEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral, updatedColumns?: ColumnMetadata[], updatedRelations?: RelationMetadata[]): void {\n\n if (entity && metadata.afterUpdateListeners.length) {\n metadata.afterUpdateListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.afterUpdate) {\n const executionResult = subscriber.afterUpdate({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata,\n databaseEntity: databaseEntity,\n updatedColumns: updatedColumns || [],\n updatedRelations: updatedRelations || []\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"AFTER_REMOVE\" event.\n * After remove event is executed after entity is being removed from the database.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastAfterRemoveEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral): void {\n\n if (entity && metadata.afterRemoveListeners.length) {\n metadata.afterRemoveListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.afterRemove) {\n const executionResult = subscriber.afterRemove({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata,\n databaseEntity: databaseEntity,\n entityId: metadata.getEntityIdMixedMap(databaseEntity)\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"AFTER_SOFT_REMOVE\" event.\n * After soft remove event is executed after entity is being soft removed from the database.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastAfterSoftRemoveEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral): void {\n\n if (entity && metadata.afterSoftRemoveListeners.length) {\n metadata.afterSoftRemoveListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.afterSoftRemove) {\n const executionResult = subscriber.afterSoftRemove({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata,\n databaseEntity: databaseEntity,\n entityId: metadata.getEntityIdMixedMap(databaseEntity)\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * Broadcasts \"AFTER_RECOVER\" event.\n * After recover event is executed after entity is being recovered in the database.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastAfterRecoverEvent(result: BroadcasterResult, metadata: EntityMetadata, entity?: ObjectLiteral, databaseEntity?: ObjectLiteral): void {\n\n if (entity && metadata.afterRecoverListeners.length) {\n metadata.afterRecoverListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.afterRecover) {\n const executionResult = subscriber.afterRecover({\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata,\n databaseEntity: databaseEntity,\n entityId: metadata.getEntityIdMixedMap(databaseEntity)\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n }\n\n /**\n * @deprecated Use `broadcastLoadForAllEvent`\n */\n broadcastLoadEventsForAll(result: BroadcasterResult, metadata: EntityMetadata, entities: ObjectLiteral[]): void {\n return this.broadcastLoadEvent(result, metadata, entities);\n }\n\n /**\n * Broadcasts \"AFTER_LOAD\" event for all given entities, and their sub-entities.\n * After load event is executed after entity has been loaded from the database.\n * All subscribers and entity listeners who listened to this event will be executed at this point.\n * Subscribers and entity listeners can return promises, it will wait until they are resolved.\n *\n * Note: this method has a performance-optimized code organization, do not change code structure.\n */\n broadcastLoadEvent(result: BroadcasterResult, metadata: EntityMetadata, entities: ObjectLiteral[]): void {\n entities.forEach(entity => {\n if (entity instanceof Promise) // todo: check why need this?\n return;\n\n // collect load events for all children entities that were loaded with the main entity\n if (metadata.relations.length) {\n metadata.relations.forEach(relation => {\n\n // in lazy relations we cannot simply access to entity property because it will cause a getter and a database query\n if (relation.isLazy && !entity.hasOwnProperty(relation.propertyName))\n return;\n\n const value = relation.getEntityValue(entity);\n if (value instanceof Object)\n this.broadcastLoadEvent(result, relation.inverseEntityMetadata, Array.isArray(value) ? value : [value]);\n });\n }\n\n if (metadata.afterLoadListeners.length) {\n metadata.afterLoadListeners.forEach(listener => {\n if (listener.isAllowed(entity)) {\n const executionResult = listener.execute(entity);\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n\n if (this.queryRunner.connection.subscribers.length) {\n this.queryRunner.connection.subscribers.forEach(subscriber => {\n if (this.isAllowedSubscriber(subscriber, metadata.target) && subscriber.afterLoad) {\n const executionResult = subscriber.afterLoad!(entity, {\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n entity: entity,\n metadata: metadata\n });\n if (executionResult instanceof Promise)\n result.promises.push(executionResult);\n result.count++;\n }\n });\n }\n });\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Checks if subscriber's methods can be executed by checking if its don't listen to the particular entity,\n * or listens our entity.\n */\n protected isAllowedSubscriber(subscriber: EntitySubscriberInterface<any>, target: Function|string): boolean {\n return !subscriber.listenTo ||\n !subscriber.listenTo() ||\n subscriber.listenTo() === Object ||\n subscriber.listenTo() === target ||\n subscriber.listenTo().isPrototypeOf(target);\n }\n\n}\n"],"sourceRoot":".."}
|
|
@@ -5,6 +5,8 @@ import { UpdateEvent } from "./event/UpdateEvent";
|
|
|
5
5
|
import { RemoveEvent } from "./event/RemoveEvent";
|
|
6
6
|
import { InsertEvent } from "./event/InsertEvent";
|
|
7
7
|
import { LoadEvent } from "./event/LoadEvent";
|
|
8
|
+
import { SoftRemoveEvent } from "./event/SoftRemoveEvent";
|
|
9
|
+
import { RecoverEvent } from "./event/RecoverEvent";
|
|
8
10
|
/**
|
|
9
11
|
* Classes that implement this interface are subscribers that subscribe for the specific events in the ORM.
|
|
10
12
|
*/
|
|
@@ -43,10 +45,26 @@ export interface EntitySubscriberInterface<Entity = any> {
|
|
|
43
45
|
* Called before entity is removed from the database.
|
|
44
46
|
*/
|
|
45
47
|
beforeRemove?(event: RemoveEvent<Entity>): Promise<any> | void;
|
|
48
|
+
/**
|
|
49
|
+
* Called before entity is soft removed from the database.
|
|
50
|
+
*/
|
|
51
|
+
beforeSoftRemove?(event: SoftRemoveEvent<Entity>): Promise<any> | void;
|
|
52
|
+
/**
|
|
53
|
+
* Called before entity is recovered in the database.
|
|
54
|
+
*/
|
|
55
|
+
beforeRecover?(event: RecoverEvent<Entity>): Promise<any> | void;
|
|
46
56
|
/**
|
|
47
57
|
* Called after entity is removed from the database.
|
|
48
58
|
*/
|
|
49
59
|
afterRemove?(event: RemoveEvent<Entity>): Promise<any> | void;
|
|
60
|
+
/**
|
|
61
|
+
* Called after entity is soft removed from the database.
|
|
62
|
+
*/
|
|
63
|
+
afterSoftRemove?(event: SoftRemoveEvent<Entity>): Promise<any> | void;
|
|
64
|
+
/**
|
|
65
|
+
* Called after entity is recovered in the database.
|
|
66
|
+
*/
|
|
67
|
+
afterRecover?(event: RecoverEvent<Entity>): Promise<any> | void;
|
|
50
68
|
/**
|
|
51
69
|
* Called before transaction is started.
|
|
52
70
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/subscriber/EntitySubscriberInterface.ts"],"names":[],"mappings":"","file":"EntitySubscriberInterface.js","sourcesContent":["import { TransactionCommitEvent } from \"./event/TransactionCommitEvent\";\nimport { TransactionRollbackEvent } from \"./event/TransactionRollbackEvent\";\nimport { TransactionStartEvent } from \"./event/TransactionStartEvent\";\nimport {UpdateEvent} from \"./event/UpdateEvent\";\nimport {RemoveEvent} from \"./event/RemoveEvent\";\nimport {InsertEvent} from \"./event/InsertEvent\";\nimport {LoadEvent} from \"./event/LoadEvent\";\n\n/**\n * Classes that implement this interface are subscribers that subscribe for the specific events in the ORM.\n */\nexport interface EntitySubscriberInterface<Entity = any> {\n\n /**\n * Returns the class of the entity to which events will listen.\n * If this method is omitted, then subscriber will listen to events of all entities.\n */\n listenTo?(): Function | string;\n\n /**\n * Called after entity is loaded from the database.\n *\n * For backward compatibility this signature is slightly different from the\n * others. `event` was added later but is always provided (it is only\n * optional in the signature so that its introduction does not break\n * compilation for existing subscribers).\n */\n afterLoad?(entity: Entity, event?: LoadEvent<Entity>): Promise<any>|void;\n\n /**\n * Called before entity is inserted to the database.\n */\n beforeInsert?(event: InsertEvent<Entity>): Promise<any>|void;\n\n /**\n * Called after entity is inserted to the database.\n */\n afterInsert?(event: InsertEvent<Entity>): Promise<any>|void;\n\n /**\n * Called before entity is updated in the database.\n */\n beforeUpdate?(event: UpdateEvent<Entity>): Promise<any>|void;\n\n /**\n * Called after entity is updated in the database.\n */\n afterUpdate?(event: UpdateEvent<Entity>): Promise<any>|void;\n\n /**\n * Called before entity is removed from the database.\n */\n beforeRemove?(event: RemoveEvent<Entity>): Promise<any>|void;\n\n /**\n * Called after entity is removed from the database.\n */\n afterRemove?(event: RemoveEvent<Entity>): Promise<any>|void;\n\n /**\n * Called before transaction is started.\n */\n beforeTransactionStart?(event: TransactionStartEvent): Promise<any>|void;\n\n /**\n * Called after transaction is started.\n */\n afterTransactionStart?(event: TransactionStartEvent): Promise<any>|void;\n\n /**\n * Called before transaction is committed.\n */\n beforeTransactionCommit?(event: TransactionCommitEvent): Promise<any>|void;\n\n /**\n * Called after transaction is committed.\n */\n afterTransactionCommit?(event: TransactionCommitEvent): Promise<any>|void;\n\n /**\n * Called before transaction rollback.\n */\n beforeTransactionRollback?(event: TransactionRollbackEvent): Promise<any>|void;\n\n /**\n * Called after transaction rollback.\n */\n afterTransactionRollback?(event: TransactionRollbackEvent): Promise<any>|void;\n\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/subscriber/EntitySubscriberInterface.ts"],"names":[],"mappings":"","file":"EntitySubscriberInterface.js","sourcesContent":["import { TransactionCommitEvent } from \"./event/TransactionCommitEvent\";\nimport { TransactionRollbackEvent } from \"./event/TransactionRollbackEvent\";\nimport { TransactionStartEvent } from \"./event/TransactionStartEvent\";\nimport {UpdateEvent} from \"./event/UpdateEvent\";\nimport {RemoveEvent} from \"./event/RemoveEvent\";\nimport {InsertEvent} from \"./event/InsertEvent\";\nimport {LoadEvent} from \"./event/LoadEvent\";\nimport { SoftRemoveEvent } from \"./event/SoftRemoveEvent\";\nimport { RecoverEvent } from \"./event/RecoverEvent\";\n\n/**\n * Classes that implement this interface are subscribers that subscribe for the specific events in the ORM.\n */\nexport interface EntitySubscriberInterface<Entity = any> {\n\n /**\n * Returns the class of the entity to which events will listen.\n * If this method is omitted, then subscriber will listen to events of all entities.\n */\n listenTo?(): Function | string;\n\n /**\n * Called after entity is loaded from the database.\n *\n * For backward compatibility this signature is slightly different from the\n * others. `event` was added later but is always provided (it is only\n * optional in the signature so that its introduction does not break\n * compilation for existing subscribers).\n */\n afterLoad?(entity: Entity, event?: LoadEvent<Entity>): Promise<any>|void;\n\n /**\n * Called before entity is inserted to the database.\n */\n beforeInsert?(event: InsertEvent<Entity>): Promise<any>|void;\n\n /**\n * Called after entity is inserted to the database.\n */\n afterInsert?(event: InsertEvent<Entity>): Promise<any>|void;\n\n /**\n * Called before entity is updated in the database.\n */\n beforeUpdate?(event: UpdateEvent<Entity>): Promise<any>|void;\n\n /**\n * Called after entity is updated in the database.\n */\n afterUpdate?(event: UpdateEvent<Entity>): Promise<any>|void;\n\n /**\n * Called before entity is removed from the database.\n */\n beforeRemove?(event: RemoveEvent<Entity>): Promise<any>|void;\n\n /**\n * Called before entity is soft removed from the database.\n */\n beforeSoftRemove?(event: SoftRemoveEvent<Entity>): Promise<any>|void;\n\n /**\n * Called before entity is recovered in the database.\n */\n beforeRecover?(event: RecoverEvent<Entity>): Promise<any>|void;\n\n /**\n * Called after entity is removed from the database.\n */\n afterRemove?(event: RemoveEvent<Entity>): Promise<any>|void;\n\n /**\n * Called after entity is soft removed from the database.\n */\n afterSoftRemove?(event: SoftRemoveEvent<Entity>): Promise<any>|void;\n\n /**\n * Called after entity is recovered in the database.\n */\n afterRecover?(event: RecoverEvent<Entity>): Promise<any>|void;\n\n /**\n * Called before transaction is started.\n */\n beforeTransactionStart?(event: TransactionStartEvent): Promise<any>|void;\n\n /**\n * Called after transaction is started.\n */\n afterTransactionStart?(event: TransactionStartEvent): Promise<any>|void;\n\n /**\n * Called before transaction is committed.\n */\n beforeTransactionCommit?(event: TransactionCommitEvent): Promise<any>|void;\n\n /**\n * Called after transaction is committed.\n */\n afterTransactionCommit?(event: TransactionCommitEvent): Promise<any>|void;\n\n /**\n * Called before transaction rollback.\n */\n beforeTransactionRollback?(event: TransactionRollbackEvent): Promise<any>|void;\n\n /**\n * Called after transaction rollback.\n */\n afterTransactionRollback?(event: TransactionRollbackEvent): Promise<any>|void;\n\n}\n"],"sourceRoot":".."}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../browser/src/subscriber/event/RecoverEvent.ts"],"names":[],"mappings":"","file":"RecoverEvent.js","sourcesContent":["import { RemoveEvent } from \"./RemoveEvent\";\n\n/**\n * RecoverEvent is an object that broadcaster sends to the entity subscriber when entity is being recovered in the database.\n */\nexport interface RecoverEvent<Entity> extends RemoveEvent<Entity> {}\n"],"sourceRoot":"../.."}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../browser/src/subscriber/event/SoftRemoveEvent.ts"],"names":[],"mappings":"","file":"SoftRemoveEvent.js","sourcesContent":["import { RemoveEvent } from \"./RemoveEvent\";\n\n/**\n * SoftRemoveEvent is an object that broadcaster sends to the entity subscriber when entity is being soft removed to the database.\n */\nexport interface SoftRemoveEvent<Entity> extends RemoveEvent<Entity> {}\n"],"sourceRoot":"../.."}
|
|
@@ -5,6 +5,7 @@ var tslib_1 = require("tslib");
|
|
|
5
5
|
var globals_1 = require("../globals");
|
|
6
6
|
var ConnectionOptionsReader_1 = require("../connection/ConnectionOptionsReader");
|
|
7
7
|
var chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
8
|
+
var PlatformTools_1 = require("../platform/PlatformTools");
|
|
8
9
|
/**
|
|
9
10
|
* Clear cache command.
|
|
10
11
|
*/
|
|
@@ -54,7 +55,7 @@ var CacheClearCommand = /** @class */ (function () {
|
|
|
54
55
|
case 3:
|
|
55
56
|
connection = _a.sent();
|
|
56
57
|
if (!connection.queryResultCache) {
|
|
57
|
-
|
|
58
|
+
PlatformTools_1.PlatformTools.logCmdErr("Cache is not enabled. To use cache enable it in connection configuration.");
|
|
58
59
|
return [2 /*return*/];
|
|
59
60
|
}
|
|
60
61
|
return [4 /*yield*/, connection.queryResultCache.clear()];
|
|
@@ -75,8 +76,7 @@ var CacheClearCommand = /** @class */ (function () {
|
|
|
75
76
|
_a.sent();
|
|
76
77
|
_a.label = 9;
|
|
77
78
|
case 9:
|
|
78
|
-
|
|
79
|
-
console.error(err_1);
|
|
79
|
+
PlatformTools_1.PlatformTools.logCmdErr("Error during cache clear.", err_1);
|
|
80
80
|
process.exit(1);
|
|
81
81
|
return [3 /*break*/, 10];
|
|
82
82
|
case 10: return [2 /*return*/];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/CacheClearCommand.ts"],"names":[],"mappings":";;;;AAAA,sCAA4C;AAC5C,iFAA8E;AAG9E,6DAA0B;
|
|
1
|
+
{"version":3,"sources":["../../src/commands/CacheClearCommand.ts"],"names":[],"mappings":";;;;AAAA,sCAA4C;AAC5C,iFAA8E;AAG9E,6DAA0B;AAC1B,2DAA0D;AAE1D;;GAEG;AACH;IAAA;QAEI,YAAO,GAAG,aAAa,CAAC;QACxB,aAAQ,GAAG,+CAA+C,CAAC;IAqD/D,CAAC;IAnDG,mCAAO,GAAP,UAAQ,IAAgB;QACpB,OAAO,IAAI;aACN,MAAM,CAAC,YAAY,EAAE;YAClB,KAAK,EAAE,GAAG;YACV,OAAO,EAAE,SAAS;YAClB,QAAQ,EAAE,8CAA8C;SAC3D,CAAC;aACD,MAAM,CAAC,QAAQ,EAAE;YACd,KAAK,EAAE,GAAG;YACV,OA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,CAAC;wBAE1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;;;;;;KAEvB;IAEL,wBAAC;AAAD,CAxDA,AAwDC,IAAA;AAxDY,8CAAiB","file":"CacheClearCommand.js","sourcesContent":["import {createConnection} from \"../globals\";\nimport {ConnectionOptionsReader} from \"../connection/ConnectionOptionsReader\";\nimport {Connection} from \"../connection/Connection\";\nimport * as yargs from \"yargs\";\nimport chalk from \"chalk\";\nimport { PlatformTools } from \"../platform/PlatformTools\";\n\n/**\n * Clear cache command.\n */\nexport class CacheClearCommand implements yargs.CommandModule {\n\n command = \"cache:clear\";\n describe = \"Clears all data stored in query runner cache.\";\n\n builder(args: yargs.Argv) {\n return args\n .option(\"connection\", {\n alias: \"c\",\n default: \"default\",\n describe: \"Name of the connection on which run a query.\"\n })\n .option(\"config\", {\n alias: \"f\",\n default: \"ormconfig\",\n describe: \"Name of the file with connection configuration.\"\n });\n }\n\n async handler(args: yargs.Arguments) {\n\n let connection: Connection|undefined = undefined;\n try {\n const connectionOptionsReader = new ConnectionOptionsReader({\n root: process.cwd(),\n configName: args.config as any\n });\n const connectionOptions = await connectionOptionsReader.get(args.connection as any);\n Object.assign(connectionOptions, {\n subscribers: [],\n synchronize: false,\n migrationsRun: false,\n dropSchema: false,\n logging: [\"schema\"]\n });\n connection = await createConnection(connectionOptions);\n\n if (!connection.queryResultCache) {\n PlatformTools.logCmdErr(\"Cache is not enabled. To use cache enable it in connection configuration.\");\n return;\n }\n\n await connection.queryResultCache.clear();\n console.log(chalk.green(\"Cache was successfully cleared\"));\n\n if (connection) await connection.close();\n\n } catch (err) {\n if (connection) await (connection as Connection).close();\n\n PlatformTools.logCmdErr(\"Error during cache clear.\", err);\n\n process.exit(1);\n }\n }\n\n}\n"],"sourceRoot":".."}
|
|
@@ -5,6 +5,7 @@ var tslib_1 = require("tslib");
|
|
|
5
5
|
var ConnectionOptionsReader_1 = require("../connection/ConnectionOptionsReader");
|
|
6
6
|
var CommandUtils_1 = require("./CommandUtils");
|
|
7
7
|
var chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
8
|
+
var PlatformTools_1 = require("../platform/PlatformTools");
|
|
8
9
|
/**
|
|
9
10
|
* Generates a new entity.
|
|
10
11
|
*/
|
|
@@ -79,8 +80,7 @@ var EntityCreateCommand = /** @class */ (function () {
|
|
|
79
80
|
return [3 /*break*/, 8];
|
|
80
81
|
case 7:
|
|
81
82
|
err_2 = _a.sent();
|
|
82
|
-
|
|
83
|
-
console.error(err_2);
|
|
83
|
+
PlatformTools_1.PlatformTools.logCmdErr("Error during entity creation:", err_2);
|
|
84
84
|
process.exit(1);
|
|
85
85
|
return [3 /*break*/, 8];
|
|
86
86
|
case 8: return [2 /*return*/];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/EntityCreateCommand.ts"],"names":[],"mappings":";;;;AAAA,iFAA8E;AAC9E,+CAA4C;AAE5C,6DAA0B;
|
|
1
|
+
{"version":3,"sources":["../../src/commands/EntityCreateCommand.ts"],"names":[],"mappings":";;;;AAAA,iFAA8E;AAC9E,+CAA4C;AAE5C,6DAA0B;AAC1B,2DAA0D;AAE1D;;GAEG;AACH;IAAA;QACI,YAAO,GAAG,eAAe,CAAC;QAC1B,aAAQ,GAAG,yBAAyB,CAAC;IA6EzC,CAAC;IA3EG,qCAAO,GAAP,UAAQ,IAAgB;QACpB,OAAO,IAAI;aACN,MAAM,CAAC,GAAG,EAAE;YACT,KAAK,EAAE,YAAY;YACnB,OAAO,EAAE,SAAS;YAClB,QAAQ,EAAE,gDAAgD;SAC7D,CAAC;aACD,MAAM,CAAC,GAAG,EAAE;YACT,KAAK,EAAE,MAAM;YACb,QAAQ,EAAE,2BAA2B;YACrC,MAAM,EAAE,IAAI;SACf,CAAC;aACD,MAAM,CAAC,GAAG,EAAE;YACT,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,2CAA2C;SACxD,CAAC;aACD,MAAM,CAAC,GAAG,EAAE;YACT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,qBAAM,2BAAY,CAAC,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC,EAAA;;wBAAhD,SAAgD,CAAC;wBACjD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,YAAU,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,oCAAiC,CAAC,CAAC,CAAC;;;;wBAGtF,6BAAa,CAAC,SAAS,CAAC,+BAA+B,EAAE,KAAG,CAAC,CAAC;wBAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;;;;;;KAEvB;IAED,4EAA4E;IAC5E,2BAA2B;IAC3B,4EAA4E;IAE5E;;OAEG;IACc,+BAAW,GAA5B,UAA6B,IAAY;QACrC,OAAO,kEAGA,IAAI,cAGlB,CAAC;IACE,CAAC;IAEL,0BAAC;AAAD,CA/EA,AA+EC,IAAA;AA/EY,kDAAmB","file":"EntityCreateCommand.js","sourcesContent":["import {ConnectionOptionsReader} from \"../connection/ConnectionOptionsReader\";\nimport {CommandUtils} from \"./CommandUtils\";\nimport * as yargs from \"yargs\";\nimport chalk from \"chalk\";\nimport { PlatformTools } from \"../platform/PlatformTools\";\n\n/**\n * Generates a new entity.\n */\nexport class EntityCreateCommand implements yargs.CommandModule {\n command = \"entity:create\";\n describe = \"Generates a new entity.\";\n\n builder(args: yargs.Argv) {\n return args\n .option(\"c\", {\n alias: \"connection\",\n default: \"default\",\n describe: \"Name of the connection on which to run a query\"\n })\n .option(\"n\", {\n alias: \"name\",\n describe: \"Name of the entity class.\",\n demand: true\n })\n .option(\"d\", {\n alias: \"dir\",\n describe: \"Directory where entity should be created.\"\n })\n .option(\"f\", {\n alias: \"config\",\n default: \"ormconfig\",\n describe: \"Name of the file with connection configuration.\"\n });\n }\n\n async handler(args: yargs.Arguments) {\n try {\n const fileContent = EntityCreateCommand.getTemplate(args.name as any);\n const filename = args.name + \".ts\";\n let directory = args.dir as string | undefined;\n\n // if directory is not set then try to open tsconfig and find default path there\n if (!directory) {\n try {\n const connectionOptionsReader = new ConnectionOptionsReader({\n root: process.cwd(),\n configName: args.config as any\n });\n const connectionOptions = await connectionOptionsReader.get(args.connection as any);\n directory = connectionOptions.cli ? (connectionOptions.cli.entitiesDir || \"\") : \"\";\n } catch (err) { }\n }\n\n if (directory && !directory.startsWith(\"/\")) {\n directory = process.cwd() + \"/\" + directory;\n }\n const path = (directory ? (directory + \"/\") : \"\") + filename;\n const fileExists = await CommandUtils.fileExists(path);\n if (fileExists) {\n throw `File ${chalk.blue(path)} already exists`;\n }\n await CommandUtils.createFile(path, fileContent);\n console.log(chalk.green(`Entity ${chalk.blue(path)} has been created successfully.`));\n\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during entity creation:\", err);\n process.exit(1);\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets contents of the entity file.\n */\n protected static getTemplate(name: string): string {\n return `import {Entity} from \"typeorm\";\n\n@Entity()\nexport class ${name} {\n\n}\n`;\n }\n\n}\n"],"sourceRoot":".."}
|
package/commands/InitCommand.js
CHANGED
|
@@ -7,6 +7,7 @@ var path = (0, tslib_1.__importStar)(require("path"));
|
|
|
7
7
|
var chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
|
|
8
8
|
var child_process_1 = require("child_process");
|
|
9
9
|
var TypeORMError_1 = require("../error/TypeORMError");
|
|
10
|
+
var PlatformTools_1 = require("../platform/PlatformTools");
|
|
10
11
|
/**
|
|
11
12
|
* Generates a new project with TypeORM.
|
|
12
13
|
*/
|
|
@@ -126,8 +127,7 @@ var InitCommand = /** @class */ (function () {
|
|
|
126
127
|
case 19: return [3 /*break*/, 21];
|
|
127
128
|
case 20:
|
|
128
129
|
err_1 = _a.sent();
|
|
129
|
-
|
|
130
|
-
console.error(err_1);
|
|
130
|
+
PlatformTools_1.PlatformTools.logCmdErr("Error during project initialization:", err_1);
|
|
131
131
|
process.exit(1);
|
|
132
132
|
return [3 /*break*/, 21];
|
|
133
133
|
case 21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OAAO,EAAE,yDAAyD;aACrE,CAAC,CAAC;;YAEH,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE;gBAC/B,KAAK,EAAE,8CAA8C,CAAA,sBAAsB;gBAC3E,OAAO,EAAE,+DAA+D;aAC3E,CAAC,CAAC;QAEP,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACrD,CAAC;IAEL,kBAAC;AAAD,CArnBA,AAqnBC,IAAA;AArnBY,kCAAW","file":"InitCommand.js","sourcesContent":["import { CommandUtils } from \"./CommandUtils\";\nimport { ObjectLiteral } from \"../common/ObjectLiteral\";\nimport * as path from \"path\";\nimport * as yargs from \"yargs\";\nimport chalk from \"chalk\";\nimport { exec } from \"child_process\";\nimport { TypeORMError } from \"../error/TypeORMError\";\n\n/**\n * Generates a new project with TypeORM.\n */\nexport class InitCommand implements yargs.CommandModule {\n command = \"init\";\n describe = \"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(\"c\", {\n alias: \"connection\",\n default: \"default\",\n describe: \"Name of the connection on which to run a query\"\n })\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: \"Indicates if express should be included in the project.\"\n })\n .option(\"docker\", {\n describe: \"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: \"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 || \"mysql\";\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 ? path.basename(args.name as any) : undefined;\n const installNpm = args.pm === \"yarn\" ? false : true;\n const projectIsEsm = args.ms === \"esm\";\n await CommandUtils.createFile(basePath + \"/package.json\", InitCommand.getPackageJsonTemplate(projectName, projectIsEsm), false);\n if (isDocker)\n await CommandUtils.createFile(basePath + \"/docker-compose.yml\", InitCommand.getDockerComposeTemplate(database), false);\n await CommandUtils.createFile(basePath + \"/.gitignore\", InitCommand.getGitIgnoreFile());\n await CommandUtils.createFile(basePath + \"/README.md\", InitCommand.getReadmeTemplate({ docker: isDocker }), false);\n await CommandUtils.createFile(basePath + \"/tsconfig.json\", InitCommand.getTsConfigTemplate(projectIsEsm));\n await CommandUtils.createFile(basePath + \"/ormconfig.json\", InitCommand.getOrmConfigTemplate(database));\n await CommandUtils.createFile(basePath + \"/src/entity/User.ts\", InitCommand.getUserEntityTemplate(database));\n await CommandUtils.createFile(basePath + \"/src/index.ts\", InitCommand.getAppIndexTemplate(isExpress, projectIsEsm));\n await CommandUtils.createDirectories(basePath + \"/src/migration\");\n\n // generate extra files for express application\n if (isExpress) {\n await CommandUtils.createFile(basePath + \"/src/routes.ts\", InitCommand.getRoutesTemplate(projectIsEsm));\n await CommandUtils.createFile(basePath + \"/src/controller/UserController.ts\", InitCommand.getControllerTemplate(projectIsEsm));\n }\n\n const packageJsonContents = await CommandUtils.readFile(basePath + \"/package.json\");\n await CommandUtils.createFile(basePath + \"/package.json\", InitCommand.appendPackageJson(packageJsonContents, database, isExpress, projectIsEsm));\n\n if (args.name) {\n console.log(chalk.green(`Project created inside ${chalk.blue(basePath)} directory.`));\n\n } else {\n console.log(chalk.green(`Project created inside current directory.`));\n }\n\n if (args.pm && installNpm) {\n await InitCommand.executeCommand(\"npm install\", basePath);\n } else {\n await InitCommand.executeCommand(\"yarn install\", basePath);\n }\n\n } catch (err) {\n console.log(chalk.black.bgRed(\"Error during project initialization:\"));\n console.error(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 getOrmConfigTemplate(database: string): string {\n const options: ObjectLiteral = {};\n switch (database) {\n case \"mysql\":\n Object.assign(options, {\n type: \"mysql\",\n host: \"localhost\",\n port: 3306,\n username: \"test\",\n password: \"test\",\n database: \"test\",\n });\n break;\n case \"mariadb\":\n Object.assign(options, {\n type: \"mariadb\",\n host: \"localhost\",\n port: 3306,\n username: \"test\",\n password: \"test\",\n database: \"test\",\n });\n break;\n case \"sqlite\":\n Object.assign(options, {\n type: \"sqlite\",\n \"database\": \"database.sqlite\",\n });\n break;\n case \"better-sqlite3\":\n Object.assign(options, {\n type: \"better-sqlite3\",\n \"database\": \"database.sqlite\",\n });\n break;\n case \"postgres\":\n Object.assign(options, {\n \"type\": \"postgres\",\n \"host\": \"localhost\",\n \"port\": 5432,\n \"username\": \"test\",\n \"password\": \"test\",\n \"database\": \"test\",\n });\n break;\n case \"cockroachdb\":\n Object.assign(options, {\n \"type\": \"cockroachdb\",\n \"host\": \"localhost\",\n \"port\": 26257,\n \"username\": \"root\",\n \"password\": \"\",\n \"database\": \"defaultdb\",\n });\n break;\n case \"mssql\":\n Object.assign(options, {\n \"type\": \"mssql\",\n \"host\": \"localhost\",\n \"username\": \"sa\",\n \"password\": \"Admin12345\",\n \"database\": \"tempdb\",\n });\n break;\n case \"oracle\":\n Object.assign(options, {\n \"type\": \"oracle\",\n \"host\": \"localhost\",\n \"username\": \"system\",\n \"password\": \"oracle\",\n \"port\": 1521,\n \"sid\": \"xe.oracle.docker\",\n });\n break;\n case \"mongodb\":\n Object.assign(options, {\n \"type\": \"mongodb\",\n \"database\": \"test\",\n });\n break;\n }\n Object.assign(options, {\n synchronize: true,\n logging: false,\n entities: [\n \"src/entity/**/*.ts\"\n ],\n migrations: [\n \"src/migration/**/*.ts\"\n ],\n subscribers: [\n \"src/subscriber/**/*.ts\"\n ],\n cli: {\n entitiesDir: \"src/entity\",\n migrationsDir: \"src/migration\",\n subscribersDir: \"src/subscriber\"\n }\n });\n return JSON.stringify(options, undefined, 3);\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 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, 3);\n else\n return JSON.stringify({\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, 3);\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, ${ database === \"mongodb\" ? \"ObjectIdColumn, ObjectID\" : \"PrimaryGeneratedColumn\" }, Column} from \"typeorm\";\n\n@Entity()\nexport class User {\n\n ${ database === \"mongodb\" ? \"@ObjectIdColumn()\" : \"@PrimaryGeneratedColumn()\" }\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${isEsm ? \".js\" : \"\"}\";\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.findOne(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(express: boolean, isEsm: boolean): string {\n if (express) {\n return `import \"reflect-metadata\";\nimport {createConnection} from \"typeorm\";\nimport ${!isEsm ? \"* as \" : \"\"}express from \"express\";\nimport ${!isEsm ? \"* as \" : \"\"}bodyParser from \"body-parser\";\nimport {Request, Response} from \"express\";\nimport {Routes} from \"./routes${isEsm ? \".js\" : \"\"}\";\nimport {User} from \"./entity/User${isEsm ? \".js\" : \"\"}\";\n\ncreateConnection().then(async connection => {\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 connection.manager.save(connection.manager.create(User, {\n firstName: \"Timber\",\n lastName: \"Saw\",\n age: 27\n }));\n await connection.manager.save(connection.manager.create(User, {\n firstName: \"Phantom\",\n lastName: \"Assassin\",\n age: 24\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\n } else {\n return `import \"reflect-metadata\";\nimport {createConnection} from \"typeorm\";\nimport {User} from \"./entity/User${isEsm ? \".js\" : \"\"}\";\n\ncreateConnection().then(async connection => {\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 connection.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 connection.manager.find(User);\n console.log(\"Loaded users: \", users);\n\n console.log(\"Here you can setup and run express/koa/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(projectName?: string, projectIsEsm?: boolean): string {\n return JSON.stringify({\n name: projectName || \"new-typeorm-project\",\n version: \"0.0.1\",\n description: \"Awesome project developed with TypeORM.\",\n type: projectIsEsm ? \"module\" : \"commonjs\",\n devDependencies: {\n },\n dependencies: {\n },\n scripts: {\n }\n }, undefined, 3);\n }\n\n /**\n * Gets contents of the new docker-compose.yml file.\n */\n protected static getDockerComposeTemplate(database: string): string {\n\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(`You cannot initialize a project with docker for Oracle driver yet.`); // 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 \\`ormconfig.json\\` 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(packageJsonContents: string, database: string, express: boolean, projectIsEsm: boolean /*, docker: boolean*/): string {\n const packageJson = JSON.parse(packageJsonContents);\n\n if (!packageJson.devDependencies) packageJson.devDependencies = {};\n Object.assign(packageJson.devDependencies, {\n \"ts-node\": \"10.4.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: \"node --loader ts-node/esm ./node_modules/typeorm/cli.js\"\n });\n else\n Object.assign(packageJson.scripts, {\n start: /*(docker ? \"docker-compose up && \" : \"\") + */\"ts-node src/index.ts\",\n typeorm: \"node --require ts-node/register ./node_modules/typeorm/cli.js\"\n });\n\n return JSON.stringify(packageJson, undefined, 3);\n }\n\n}\n"],"sourceRoot":".."}
|
|
1
|
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,EAAE,8CAA8C,CAAA,sBAAsB;gBAC3E,OAAO,EAAE,+DAA+D;aAC3E,CAAC,CAAC;QAEP,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACrD,CAAC;IAEL,kBAAC;AAAD,CApnBA,AAonBC,IAAA;AApnBY,kCAAW","file":"InitCommand.js","sourcesContent":["import { CommandUtils } from \"./CommandUtils\";\nimport { ObjectLiteral } from \"../common/ObjectLiteral\";\nimport * as path from \"path\";\nimport * as yargs from \"yargs\";\nimport chalk from \"chalk\";\nimport { exec } from \"child_process\";\nimport { TypeORMError } from \"../error/TypeORMError\";\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 = \"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(\"c\", {\n alias: \"connection\",\n default: \"default\",\n describe: \"Name of the connection on which to run a query\"\n })\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: \"Indicates if express should be included in the project.\"\n })\n .option(\"docker\", {\n describe: \"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: \"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 || \"mysql\";\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 ? path.basename(args.name as any) : undefined;\n const installNpm = args.pm === \"yarn\" ? false : true;\n const projectIsEsm = args.ms === \"esm\";\n await CommandUtils.createFile(basePath + \"/package.json\", InitCommand.getPackageJsonTemplate(projectName, projectIsEsm), false);\n if (isDocker)\n await CommandUtils.createFile(basePath + \"/docker-compose.yml\", InitCommand.getDockerComposeTemplate(database), false);\n await CommandUtils.createFile(basePath + \"/.gitignore\", InitCommand.getGitIgnoreFile());\n await CommandUtils.createFile(basePath + \"/README.md\", InitCommand.getReadmeTemplate({ docker: isDocker }), false);\n await CommandUtils.createFile(basePath + \"/tsconfig.json\", InitCommand.getTsConfigTemplate(projectIsEsm));\n await CommandUtils.createFile(basePath + \"/ormconfig.json\", InitCommand.getOrmConfigTemplate(database));\n await CommandUtils.createFile(basePath + \"/src/entity/User.ts\", InitCommand.getUserEntityTemplate(database));\n await CommandUtils.createFile(basePath + \"/src/index.ts\", InitCommand.getAppIndexTemplate(isExpress, projectIsEsm));\n await CommandUtils.createDirectories(basePath + \"/src/migration\");\n\n // generate extra files for express application\n if (isExpress) {\n await CommandUtils.createFile(basePath + \"/src/routes.ts\", InitCommand.getRoutesTemplate(projectIsEsm));\n await CommandUtils.createFile(basePath + \"/src/controller/UserController.ts\", InitCommand.getControllerTemplate(projectIsEsm));\n }\n\n const packageJsonContents = await CommandUtils.readFile(basePath + \"/package.json\");\n await CommandUtils.createFile(basePath + \"/package.json\", InitCommand.appendPackageJson(packageJsonContents, database, isExpress, projectIsEsm));\n\n if (args.name) {\n console.log(chalk.green(`Project created inside ${chalk.blue(basePath)} directory.`));\n\n } else {\n console.log(chalk.green(`Project created inside current directory.`));\n }\n\n if (args.pm && installNpm) {\n await InitCommand.executeCommand(\"npm install\", basePath);\n } else {\n await InitCommand.executeCommand(\"yarn install\", basePath);\n }\n\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 getOrmConfigTemplate(database: string): string {\n const options: ObjectLiteral = {};\n switch (database) {\n case \"mysql\":\n Object.assign(options, {\n type: \"mysql\",\n host: \"localhost\",\n port: 3306,\n username: \"test\",\n password: \"test\",\n database: \"test\",\n });\n break;\n case \"mariadb\":\n Object.assign(options, {\n type: \"mariadb\",\n host: \"localhost\",\n port: 3306,\n username: \"test\",\n password: \"test\",\n database: \"test\",\n });\n break;\n case \"sqlite\":\n Object.assign(options, {\n type: \"sqlite\",\n \"database\": \"database.sqlite\",\n });\n break;\n case \"better-sqlite3\":\n Object.assign(options, {\n type: \"better-sqlite3\",\n \"database\": \"database.sqlite\",\n });\n break;\n case \"postgres\":\n Object.assign(options, {\n \"type\": \"postgres\",\n \"host\": \"localhost\",\n \"port\": 5432,\n \"username\": \"test\",\n \"password\": \"test\",\n \"database\": \"test\",\n });\n break;\n case \"cockroachdb\":\n Object.assign(options, {\n \"type\": \"cockroachdb\",\n \"host\": \"localhost\",\n \"port\": 26257,\n \"username\": \"root\",\n \"password\": \"\",\n \"database\": \"defaultdb\",\n });\n break;\n case \"mssql\":\n Object.assign(options, {\n \"type\": \"mssql\",\n \"host\": \"localhost\",\n \"username\": \"sa\",\n \"password\": \"Admin12345\",\n \"database\": \"tempdb\",\n });\n break;\n case \"oracle\":\n Object.assign(options, {\n \"type\": \"oracle\",\n \"host\": \"localhost\",\n \"username\": \"system\",\n \"password\": \"oracle\",\n \"port\": 1521,\n \"sid\": \"xe.oracle.docker\",\n });\n break;\n case \"mongodb\":\n Object.assign(options, {\n \"type\": \"mongodb\",\n \"database\": \"test\",\n });\n break;\n }\n Object.assign(options, {\n synchronize: true,\n logging: false,\n entities: [\n \"src/entity/**/*.ts\"\n ],\n migrations: [\n \"src/migration/**/*.ts\"\n ],\n subscribers: [\n \"src/subscriber/**/*.ts\"\n ],\n cli: {\n entitiesDir: \"src/entity\",\n migrationsDir: \"src/migration\",\n subscribersDir: \"src/subscriber\"\n }\n });\n return JSON.stringify(options, undefined, 3);\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 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, 3);\n else\n return JSON.stringify({\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, 3);\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, ${ database === \"mongodb\" ? \"ObjectIdColumn, ObjectID\" : \"PrimaryGeneratedColumn\" }, Column} from \"typeorm\";\n\n@Entity()\nexport class User {\n\n ${ database === \"mongodb\" ? \"@ObjectIdColumn()\" : \"@PrimaryGeneratedColumn()\" }\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${isEsm ? \".js\" : \"\"}\";\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.findOne(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(express: boolean, isEsm: boolean): string {\n if (express) {\n return `import \"reflect-metadata\";\nimport {createConnection} from \"typeorm\";\nimport ${!isEsm ? \"* as \" : \"\"}express from \"express\";\nimport ${!isEsm ? \"* as \" : \"\"}bodyParser from \"body-parser\";\nimport {Request, Response} from \"express\";\nimport {Routes} from \"./routes${isEsm ? \".js\" : \"\"}\";\nimport {User} from \"./entity/User${isEsm ? \".js\" : \"\"}\";\n\ncreateConnection().then(async connection => {\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 connection.manager.save(connection.manager.create(User, {\n firstName: \"Timber\",\n lastName: \"Saw\",\n age: 27\n }));\n await connection.manager.save(connection.manager.create(User, {\n firstName: \"Phantom\",\n lastName: \"Assassin\",\n age: 24\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\n } else {\n return `import \"reflect-metadata\";\nimport {createConnection} from \"typeorm\";\nimport {User} from \"./entity/User${isEsm ? \".js\" : \"\"}\";\n\ncreateConnection().then(async connection => {\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 connection.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 connection.manager.find(User);\n console.log(\"Loaded users: \", users);\n\n console.log(\"Here you can setup and run express/koa/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(projectName?: string, projectIsEsm?: boolean): string {\n return JSON.stringify({\n name: projectName || \"new-typeorm-project\",\n version: \"0.0.1\",\n description: \"Awesome project developed with TypeORM.\",\n type: projectIsEsm ? \"module\" : \"commonjs\",\n devDependencies: {\n },\n dependencies: {\n },\n scripts: {\n }\n }, undefined, 3);\n }\n\n /**\n * Gets contents of the new docker-compose.yml file.\n */\n protected static getDockerComposeTemplate(database: string): string {\n\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(`You cannot initialize a project with docker for Oracle driver yet.`); // 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 \\`ormconfig.json\\` 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(packageJsonContents: string, database: string, express: boolean, projectIsEsm: boolean /*, docker: boolean*/): string {\n const packageJson = JSON.parse(packageJsonContents);\n\n if (!packageJson.devDependencies) packageJson.devDependencies = {};\n Object.assign(packageJson.devDependencies, {\n \"ts-node\": \"10.4.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: \"node --loader ts-node/esm ./node_modules/typeorm/cli.js\"\n });\n else\n Object.assign(packageJson.scripts, {\n start: /*(docker ? \"docker-compose up && \" : \"\") + */\"ts-node src/index.ts\",\n typeorm: \"node --require ts-node/register ./node_modules/typeorm/cli.js\"\n });\n\n return JSON.stringify(packageJson, undefined, 3);\n }\n\n}\n"],"sourceRoot":".."}
|