typeorm 0.3.13-dev.f7b210b → 0.3.13
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/driver/postgres/PostgresQueryRunner.js +1 -1
- package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js +7 -0
- package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/browser/driver/sqlserver/SqlServerDriver.js +7 -2
- package/browser/driver/sqlserver/SqlServerDriver.js.map +1 -1
- package/browser/driver/sqlserver/SqlServerQueryRunner.d.ts +2 -1
- package/browser/driver/sqlserver/SqlServerQueryRunner.js +31 -9
- package/browser/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/browser/entity-schema/EntitySchemaInheritanceOptions.d.ts +11 -0
- package/browser/entity-schema/EntitySchemaInheritanceOptions.js +3 -0
- package/browser/entity-schema/EntitySchemaInheritanceOptions.js.map +1 -0
- package/browser/entity-schema/EntitySchemaOptions.d.ts +5 -4
- package/browser/entity-schema/EntitySchemaOptions.js.map +1 -1
- package/browser/entity-schema/EntitySchemaTransformer.js +13 -0
- package/browser/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/browser/find-options/FindOperator.d.ts +2 -0
- package/browser/find-options/FindOperator.js +13 -0
- package/browser/find-options/FindOperator.js.map +1 -1
- package/browser/find-options/FindOptionsOrder.d.ts +1 -1
- package/browser/find-options/FindOptionsOrder.js.map +1 -1
- package/browser/find-options/FindOptionsUtils.js +45 -15
- package/browser/find-options/FindOptionsUtils.js.map +1 -1
- package/browser/metadata/EmbeddedMetadata.js +3 -3
- package/browser/metadata/EmbeddedMetadata.js.map +1 -1
- package/browser/migration/MigrationExecutor.js +8 -2
- package/browser/migration/MigrationExecutor.js.map +1 -1
- package/browser/persistence/SubjectExecutor.js +6 -6
- package/browser/persistence/SubjectExecutor.js.map +1 -1
- package/browser/query-builder/JoinAttribute.d.ts +4 -0
- package/browser/query-builder/JoinAttribute.js +4 -0
- package/browser/query-builder/JoinAttribute.js.map +1 -1
- package/browser/query-builder/SelectQueryBuilder.d.ts +4 -3
- package/browser/query-builder/SelectQueryBuilder.js +17 -9
- package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
- package/browser/query-runner/BaseQueryRunner.d.ts +2 -1
- package/browser/query-runner/BaseQueryRunner.js +5 -2
- package/browser/query-runner/BaseQueryRunner.js.map +1 -1
- package/browser/subscriber/Broadcaster.d.ts +6 -6
- package/browser/subscriber/Broadcaster.js +12 -12
- package/browser/subscriber/Broadcaster.js.map +1 -1
- package/browser/util/DateUtils.d.ts +12 -0
- package/browser/util/DateUtils.js +20 -16
- package/browser/util/DateUtils.js.map +1 -1
- package/browser/util/StringUtils.js +3 -3
- package/browser/util/StringUtils.js.map +1 -1
- package/driver/postgres/PostgresQueryRunner.js +1 -1
- package/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteDriver.js +7 -0
- package/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +1 -1
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/driver/sqlserver/SqlServerDriver.js +7 -2
- package/driver/sqlserver/SqlServerDriver.js.map +1 -1
- package/driver/sqlserver/SqlServerQueryRunner.d.ts +2 -1
- package/driver/sqlserver/SqlServerQueryRunner.js +31 -9
- package/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/entity-schema/EntitySchemaInheritanceOptions.d.ts +11 -0
- package/entity-schema/EntitySchemaInheritanceOptions.js +4 -0
- package/entity-schema/EntitySchemaInheritanceOptions.js.map +1 -0
- package/entity-schema/EntitySchemaOptions.d.ts +5 -4
- package/entity-schema/EntitySchemaOptions.js.map +1 -1
- package/entity-schema/EntitySchemaTransformer.js +13 -0
- package/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/find-options/FindOperator.d.ts +2 -0
- package/find-options/FindOperator.js +13 -0
- package/find-options/FindOperator.js.map +1 -1
- package/find-options/FindOptionsOrder.d.ts +1 -1
- package/find-options/FindOptionsOrder.js.map +1 -1
- package/find-options/FindOptionsUtils.js +46 -16
- package/find-options/FindOptionsUtils.js.map +1 -1
- package/metadata/EmbeddedMetadata.js +3 -3
- package/metadata/EmbeddedMetadata.js.map +1 -1
- package/migration/MigrationExecutor.js +8 -2
- package/migration/MigrationExecutor.js.map +1 -1
- package/package.json +272 -1
- package/persistence/SubjectExecutor.js +6 -6
- package/persistence/SubjectExecutor.js.map +1 -1
- package/query-builder/JoinAttribute.d.ts +4 -0
- package/query-builder/JoinAttribute.js +4 -0
- package/query-builder/JoinAttribute.js.map +1 -1
- package/query-builder/SelectQueryBuilder.d.ts +4 -3
- package/query-builder/SelectQueryBuilder.js +17 -9
- package/query-builder/SelectQueryBuilder.js.map +1 -1
- package/query-runner/BaseQueryRunner.d.ts +2 -1
- package/query-runner/BaseQueryRunner.js +5 -2
- package/query-runner/BaseQueryRunner.js.map +1 -1
- package/subscriber/Broadcaster.d.ts +6 -6
- package/subscriber/Broadcaster.js +12 -12
- package/subscriber/Broadcaster.js.map +1 -1
- package/util/DateUtils.d.ts +12 -0
- package/util/DateUtils.js +20 -16
- package/util/DateUtils.js.map +1 -1
- package/util/StringUtils.js +3 -3
- package/util/StringUtils.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/subscriber/Broadcaster.ts"],"names":[],"mappings":";;;AAIA,2DAAuD;AAGvD,qDAAiD;AAsEjD;;GAEG;AACH,MAAa,WAAW;IACpB,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAEhD,4EAA4E;IA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,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,CAC9C,CAAA;IACL,CAAC;CACJ;AAxuBD,kCAwuBC","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\"\nimport { ObjectUtils } from \"../util/ObjectUtils\"\n\ninterface BroadcasterEvents {\n BeforeTransactionCommit: () => void\n AfterTransactionCommit: () => void\n BeforeTransactionStart: () => void\n AfterTransactionStart: () => void\n BeforeTransactionRollback: () => void\n AfterTransactionRollback: () => void\n\n BeforeUpdate: (\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n updatedColumns?: ColumnMetadata[],\n updatedRelations?: RelationMetadata[],\n ) => void\n AfterUpdate: (\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n updatedColumns?: ColumnMetadata[],\n updatedRelations?: RelationMetadata[],\n ) => void\n\n BeforeInsert: (\n metadata: EntityMetadata,\n entity: ObjectLiteral | undefined,\n ) => void\n AfterInsert: (\n metadata: EntityMetadata,\n entity: ObjectLiteral | undefined,\n ) => void\n\n BeforeRemove: (\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ) => void\n AfterRemove: (\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ) => void\n\n BeforeSoftRemove: (\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ) => void\n AfterSoftRemove: (\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ) => void\n\n BeforeRecover: (\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ) => void\n AfterRecover: (\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ) => void\n\n Load: (metadata: EntityMetadata, entities: ObjectLiteral[]) => void\n}\n\n/**\n * Broadcaster provides a helper methods to broadcast events to the subscribers.\n */\nexport class Broadcaster {\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(private queryRunner: QueryRunner) {}\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n async broadcast<U extends keyof BroadcasterEvents>(\n event: U,\n ...args: Parameters<BroadcasterEvents[U]>\n ): 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(this, result, ...args)\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity: undefined | ObjectLiteral,\n ): void {\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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.beforeInsert\n ) {\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n updatedColumns?: ColumnMetadata[],\n updatedRelations?: RelationMetadata[],\n ): void {\n // 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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.beforeUpdate\n ) {\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ): 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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.beforeRemove\n ) {\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ): 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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.beforeSoftRemove\n ) {\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ): 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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.beforeRecover\n ) {\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n ): void {\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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.afterInsert\n ) {\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 =\n 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 {\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n },\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n updatedColumns?: ColumnMetadata[],\n updatedRelations?: RelationMetadata[],\n ): void {\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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.afterUpdate\n ) {\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ): void {\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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.afterRemove\n ) {\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ): void {\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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.afterSoftRemove\n ) {\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ): void {\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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.afterRecover\n ) {\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entities: ObjectLiteral[],\n ): 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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entities: ObjectLiteral[],\n ): void {\n // Calculate which subscribers are fitting for the given entity type\n const fittingSubscribers =\n this.queryRunner.connection.subscribers.filter(\n (subscriber) =>\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.afterLoad,\n )\n\n if (\n metadata.relations.length ||\n metadata.afterLoadListeners.length ||\n fittingSubscribers.length\n ) {\n // todo: check why need this?\n const nonPromiseEntities = entities.filter(\n (entity) => !(entity instanceof Promise),\n )\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 nonPromiseEntities.forEach((entity) => {\n // in lazy relations we cannot simply access to entity property because it will cause a getter and a database query\n if (\n relation.isLazy &&\n !entity.hasOwnProperty(relation.propertyName)\n )\n return\n\n const value = relation.getEntityValue(entity)\n if (ObjectUtils.isObject(value))\n this.broadcastLoadEvent(\n result,\n relation.inverseEntityMetadata,\n Array.isArray(value) ? value : [value],\n )\n })\n })\n }\n\n if (metadata.afterLoadListeners.length) {\n metadata.afterLoadListeners.forEach((listener) => {\n nonPromiseEntities.forEach((entity) => {\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\n fittingSubscribers.forEach((subscriber) => {\n nonPromiseEntities.forEach((entity) => {\n const executionResult = subscriber.afterLoad!(entity, {\n entity,\n metadata,\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 // 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(\n subscriber: EntitySubscriberInterface<any>,\n target: Function | string,\n ): boolean {\n return (\n !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":["../../src/subscriber/Broadcaster.ts"],"names":[],"mappings":";;;AAIA,2DAAuD;AAGvD,qDAAiD;AAsEjD;;GAEG;AACH,MAAa,WAAW;IACpB,4EAA4E;IAC5E,cAAc;IACd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,IAAI,CAAC,WAAW,CAAC,OAAO;qBACpC,CAAC,CAAA;oBACF,IAAI,eAAe,YAAY,OAAO;wBAClC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;oBACzC,MAAM,CAAC,KAAK,EAAE,CAAA;gBAClB,CAAC,CAAC,CAAA;YACN,CAAC,CAAC,CAAA;SACL;IACL,CAAC;IAED,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;;OAGG;IACO,mBAAmB,CACzB,UAA0C,EAC1C,MAAyB;QAEzB,OAAO,CACH,CAAC,UAAU,CAAC,QAAQ;YACpB,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,CAC9C,CAAA;IACL,CAAC;CACJ;AA1vBD,kCA0vBC","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\"\nimport { ObjectUtils } from \"../util/ObjectUtils\"\n\ninterface BroadcasterEvents {\n BeforeTransactionCommit: () => void\n AfterTransactionCommit: () => void\n BeforeTransactionStart: () => void\n AfterTransactionStart: () => void\n BeforeTransactionRollback: () => void\n AfterTransactionRollback: () => void\n\n BeforeUpdate: (\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n updatedColumns?: ColumnMetadata[],\n updatedRelations?: RelationMetadata[],\n ) => void\n AfterUpdate: (\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n updatedColumns?: ColumnMetadata[],\n updatedRelations?: RelationMetadata[],\n ) => void\n\n BeforeInsert: (\n metadata: EntityMetadata,\n entity: ObjectLiteral | undefined,\n ) => void\n AfterInsert: (\n metadata: EntityMetadata,\n entity: ObjectLiteral | undefined,\n ) => void\n\n BeforeRemove: (\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ) => void\n AfterRemove: (\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ) => void\n\n BeforeSoftRemove: (\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ) => void\n AfterSoftRemove: (\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ) => void\n\n BeforeRecover: (\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ) => void\n AfterRecover: (\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n ) => void\n\n Load: (metadata: EntityMetadata, entities: ObjectLiteral[]) => void\n}\n\n/**\n * Broadcaster provides a helper methods to broadcast events to the subscribers.\n */\nexport class Broadcaster {\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(private queryRunner: QueryRunner) {}\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n async broadcast<U extends keyof BroadcasterEvents>(\n event: U,\n ...args: Parameters<BroadcasterEvents[U]>\n ): 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(this, result, ...args)\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity: undefined | ObjectLiteral,\n ): void {\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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.beforeInsert\n ) {\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n updatedColumns?: ColumnMetadata[],\n updatedRelations?: RelationMetadata[],\n ): void {\n // 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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.beforeUpdate\n ) {\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n identifier?: ObjectLiteral,\n ): 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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.beforeRemove\n ) {\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(\n databaseEntity ?? identifier,\n ),\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n identifier?: ObjectLiteral,\n ): 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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.beforeSoftRemove\n ) {\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(\n databaseEntity ?? identifier,\n ),\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n identifier?: ObjectLiteral,\n ): 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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.beforeRecover\n ) {\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(\n databaseEntity ?? identifier,\n ),\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n ): void {\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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.afterInsert\n ) {\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 =\n 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 {\n connection: this.queryRunner.connection,\n queryRunner: this.queryRunner,\n manager: this.queryRunner.manager,\n },\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n updatedColumns?: ColumnMetadata[],\n updatedRelations?: RelationMetadata[],\n ): void {\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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.afterUpdate\n ) {\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n identifier?: ObjectLiteral,\n ): void {\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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.afterRemove\n ) {\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(\n databaseEntity ?? identifier,\n ),\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n identifier?: ObjectLiteral,\n ): void {\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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.afterSoftRemove\n ) {\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(\n databaseEntity ?? identifier,\n ),\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entity?: ObjectLiteral,\n databaseEntity?: ObjectLiteral,\n identifier?: ObjectLiteral,\n ): void {\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 (\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.afterRecover\n ) {\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(\n databaseEntity ?? identifier,\n ),\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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entities: ObjectLiteral[],\n ): 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(\n result: BroadcasterResult,\n metadata: EntityMetadata,\n entities: ObjectLiteral[],\n ): void {\n // Calculate which subscribers are fitting for the given entity type\n const fittingSubscribers =\n this.queryRunner.connection.subscribers.filter(\n (subscriber) =>\n this.isAllowedSubscriber(subscriber, metadata.target) &&\n subscriber.afterLoad,\n )\n\n if (\n metadata.relations.length ||\n metadata.afterLoadListeners.length ||\n fittingSubscribers.length\n ) {\n // todo: check why need this?\n const nonPromiseEntities = entities.filter(\n (entity) => !(entity instanceof Promise),\n )\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 nonPromiseEntities.forEach((entity) => {\n // in lazy relations we cannot simply access to entity property because it will cause a getter and a database query\n if (\n relation.isLazy &&\n !entity.hasOwnProperty(relation.propertyName)\n )\n return\n\n const value = relation.getEntityValue(entity)\n if (ObjectUtils.isObject(value))\n this.broadcastLoadEvent(\n result,\n relation.inverseEntityMetadata,\n Array.isArray(value) ? value : [value],\n )\n })\n })\n }\n\n if (metadata.afterLoadListeners.length) {\n metadata.afterLoadListeners.forEach((listener) => {\n nonPromiseEntities.forEach((entity) => {\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\n fittingSubscribers.forEach((subscriber) => {\n nonPromiseEntities.forEach((entity) => {\n const executionResult = subscriber.afterLoad!(entity, {\n entity,\n metadata,\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 // 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(\n subscriber: EntitySubscriberInterface<any>,\n target: Function | string,\n ): boolean {\n return (\n !subscriber.listenTo ||\n !subscriber.listenTo() ||\n subscriber.listenTo() === Object ||\n subscriber.listenTo() === target ||\n subscriber.listenTo().isPrototypeOf(target)\n )\n }\n}\n"],"sourceRoot":".."}
|
package/util/DateUtils.d.ts
CHANGED
|
@@ -55,4 +55,16 @@ export declare class DateUtils {
|
|
|
55
55
|
* Formats given number to "0x" format, e.g. if it is 1 then it will return "01".
|
|
56
56
|
*/
|
|
57
57
|
private static formatMilliseconds;
|
|
58
|
+
/**
|
|
59
|
+
* Parse a date without the UTC-offset of the device
|
|
60
|
+
*
|
|
61
|
+
* The problem here is with wrong timezone.
|
|
62
|
+
*
|
|
63
|
+
* For example:
|
|
64
|
+
*
|
|
65
|
+
* ``new Date('2021-04-28')`` will generate `2021-04-28T00:00:00.000Z`
|
|
66
|
+
* in my timezone, which is not true for my timezone (GMT-0300). It should
|
|
67
|
+
* be `2021-04-28T03:00:00.000Z` as `new Date(2021, 3, 28)` generates.
|
|
68
|
+
*/
|
|
69
|
+
private static parseDateAsISO;
|
|
58
70
|
}
|
package/util/DateUtils.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DateUtils = void 0;
|
|
4
|
-
const date_fns_1 = require("date-fns");
|
|
5
4
|
/**
|
|
6
5
|
* Provides utilities to transform hydrated and persisted data.
|
|
7
6
|
*/
|
|
@@ -36,21 +35,9 @@ class DateUtils {
|
|
|
36
35
|
* Converts given value into date object.
|
|
37
36
|
*/
|
|
38
37
|
static mixedDateToDate(mixedDate, toUtc = false, useMilliseconds = true) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*
|
|
43
|
-
* The problem here is with wrong timezone.
|
|
44
|
-
*
|
|
45
|
-
* For example:
|
|
46
|
-
*
|
|
47
|
-
* ``new Date('2021-04-28')`` will generate `2021-04-28T00:00:00.000Z`
|
|
48
|
-
* in my timezone, which is not true for my timezone (GMT-0300). It should
|
|
49
|
-
* be `2021-04-28T03:00:00.000Z` as `new Date(2021, 3, 28)` generates.
|
|
50
|
-
*
|
|
51
|
-
* https://stackoverflow.com/a/2587398
|
|
52
|
-
*/
|
|
53
|
-
let date = typeof mixedDate === "string" ? (0, date_fns_1.parseISO)(mixedDate) : mixedDate;
|
|
38
|
+
let date = typeof mixedDate === "string"
|
|
39
|
+
? DateUtils.parseDateAsISO(mixedDate)
|
|
40
|
+
: mixedDate;
|
|
54
41
|
if (toUtc)
|
|
55
42
|
date = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.getUTCMilliseconds());
|
|
56
43
|
if (!useMilliseconds)
|
|
@@ -220,6 +207,23 @@ class DateUtils {
|
|
|
220
207
|
return String(value);
|
|
221
208
|
}
|
|
222
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Parse a date without the UTC-offset of the device
|
|
212
|
+
*
|
|
213
|
+
* The problem here is with wrong timezone.
|
|
214
|
+
*
|
|
215
|
+
* For example:
|
|
216
|
+
*
|
|
217
|
+
* ``new Date('2021-04-28')`` will generate `2021-04-28T00:00:00.000Z`
|
|
218
|
+
* in my timezone, which is not true for my timezone (GMT-0300). It should
|
|
219
|
+
* be `2021-04-28T03:00:00.000Z` as `new Date(2021, 3, 28)` generates.
|
|
220
|
+
*/
|
|
221
|
+
static parseDateAsISO(dateString) {
|
|
222
|
+
const date = new Date(dateString);
|
|
223
|
+
const offset = date.getTimezoneOffset() * 60 * 1000;
|
|
224
|
+
const utc = date.getTime() + offset;
|
|
225
|
+
return new Date(utc);
|
|
226
|
+
}
|
|
223
227
|
}
|
|
224
228
|
exports.DateUtils = DateUtils;
|
|
225
229
|
|
package/util/DateUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/DateUtils.ts"],"names":[],"mappings":";;;AACA,uCAAmC;AAEnC;;GAEG;AACH,MAAa,SAAS;IAClB,4EAA4E;IAC5E,wBAAwB;IACxB,4EAA4E;IAE5E;;OAEG;IACH,MAAM,CAAC,qBAAqB,CACxB,SAAoC;QAEpC,IAAI,CAAC,SAAS;YAAE,OAAO,SAAS,CAAA;QAEhC,OAAO,OAAO,SAAS,KAAK,QAAQ;YAChC,CAAC,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC;YACrB,CAAC,CAAE,SAAkB,CAAA;IAC7B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAAC,KAAoB;QAC7C,IAAI,KAAK,YAAY,IAAI,EAAE;YACvB,OAAO,CACH,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;gBAChD,GAAG;gBACH,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;gBAC9C,GAAG;gBACH,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAC5C,CAAA;SACJ;QAED,OAAO,KAAK,CAAA;IAChB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,eAAe,CAClB,SAAwB,EACxB,QAAiB,KAAK,EACtB,eAAe,GAAG,IAAI;QAEtB;;;;;;;;;;;;;WAaG;QACH,IAAI,IAAI,GACJ,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAA,mBAAQ,EAAC,SAAS,CAAC,CAAC,CAAC,CA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5D,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;SAC1B;QAED,OAAO,KAAK,CAAA;IAChB,CAAC;IAED,4EAA4E;IAC5E,yBAAyB;IACzB,4EAA4E;IAE5E;;OAEG;IACK,MAAM,CAAC,mBAAmB,CAAC,KAAa,EAAE,WAAW,GAAG,CAAC;QAC7D,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;QAEnC,OAAO,MAAM,CAAC,GAAG,GAAG,GAAG,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAA;IACvD,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,kBAAkB,CAAC,KAAa;QAC3C,IAAI,KAAK,GAAG,EAAE,EAAE;YACZ,OAAO,IAAI,GAAG,KAAK,CAAA;SACtB;aAAM,IAAI,KAAK,GAAG,GAAG,EAAE;YACpB,OAAO,GAAG,GAAG,KAAK,CAAA;SACrB;aAAM;YACH,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;SACvB;IACL,CAAC;CACJ;AAnRD,8BAmRC","file":"DateUtils.js","sourcesContent":["import { ColumnMetadata } from \"../metadata/ColumnMetadata\"\nimport { parseISO } from \"date-fns\"\n\n/**\n * Provides utilities to transform hydrated and persisted data.\n */\nexport class DateUtils {\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Normalizes date object hydrated from the database.\n */\n static normalizeHydratedDate(\n mixedDate: Date | string | undefined,\n ): Date | string | undefined {\n if (!mixedDate) return mixedDate\n\n return typeof mixedDate === \"string\"\n ? new Date(mixedDate)\n : (mixedDate as Date)\n }\n\n /**\n * Converts given value into date string in a \"YYYY-MM-DD\" format.\n */\n static mixedDateToDateString(value: string | Date): string {\n if (value instanceof Date) {\n return (\n this.formatZerolessValue(value.getFullYear(), 4) +\n \"-\" +\n this.formatZerolessValue(value.getMonth() + 1) +\n \"-\" +\n this.formatZerolessValue(value.getDate())\n )\n }\n\n return value\n }\n\n /**\n * Converts given value into date object.\n */\n static mixedDateToDate(\n mixedDate: Date | string,\n toUtc: boolean = false,\n useMilliseconds = true,\n ): Date {\n /**\n * new Date(ISOString) is not a reliable parser to date strings.\n * It's better to use 'date-fns' parser to parser string in ISO Format.\n *\n * The problem here is with wrong timezone.\n *\n * For example:\n *\n * ``new Date('2021-04-28')`` will generate `2021-04-28T00:00:00.000Z`\n * in my timezone, which is not true for my timezone (GMT-0300). It should\n * be `2021-04-28T03:00:00.000Z` as `new Date(2021, 3, 28)` generates.\n *\n * https://stackoverflow.com/a/2587398\n */\n let date =\n typeof mixedDate === \"string\" ? parseISO(mixedDate) : mixedDate\n\n if (toUtc)\n date = new Date(\n date.getUTCFullYear(),\n date.getUTCMonth(),\n date.getUTCDate(),\n date.getUTCHours(),\n date.getUTCMinutes(),\n date.getUTCSeconds(),\n date.getUTCMilliseconds(),\n )\n\n if (!useMilliseconds) date.setUTCMilliseconds(0)\n\n return date\n }\n\n /**\n * Converts given value into time string in a \"HH:mm:ss\" format.\n */\n static mixedDateToTimeString(\n value: Date | any,\n skipSeconds: boolean = false,\n ): string | any {\n if (value instanceof Date)\n return (\n this.formatZerolessValue(value.getHours()) +\n \":\" +\n this.formatZerolessValue(value.getMinutes()) +\n (!skipSeconds\n ? \":\" + this.formatZerolessValue(value.getSeconds())\n : \"\")\n )\n\n return value\n }\n\n /**\n * Converts given value into time string in a \"HH:mm:ss\" format.\n */\n static mixedTimeToDate(value: Date | any): string | any {\n if (typeof value === \"string\") {\n const [hours, minutes, seconds] = value.split(\":\")\n const date = new Date()\n if (hours) date.setHours(parseInt(hours))\n if (minutes) date.setMinutes(parseInt(minutes))\n if (seconds) date.setSeconds(parseInt(seconds))\n return date\n }\n\n return value\n }\n\n /**\n * Converts given string value with \"-\" separator into a \"HH:mm:ss\" format.\n */\n static mixedTimeToString(\n value: string | any,\n skipSeconds: boolean = false,\n ): string | any {\n value =\n value instanceof Date\n ? value.getHours() +\n \":\" +\n value.getMinutes() +\n (!skipSeconds ? \":\" + value.getSeconds() : \"\")\n : value\n if (typeof value === \"string\") {\n return value\n .split(\":\")\n .map((v) => (v.length === 1 ? \"0\" + v : v)) // append zero at beginning if we have a first-zero-less number\n .join(\":\")\n }\n\n return value\n }\n\n /**\n * Converts given value into datetime string in a \"YYYY-MM-DD HH-mm-ss\" format.\n */\n static mixedDateToDatetimeString(\n value: Date | any,\n useMilliseconds?: boolean,\n ): string | any {\n if (typeof value === \"string\") {\n value = new Date(value)\n }\n if (value instanceof Date) {\n let finalValue =\n this.formatZerolessValue(value.getFullYear(), 4) +\n \"-\" +\n this.formatZerolessValue(value.getMonth() + 1) +\n \"-\" +\n this.formatZerolessValue(value.getDate()) +\n \" \" +\n this.formatZerolessValue(value.getHours()) +\n \":\" +\n this.formatZerolessValue(value.getMinutes()) +\n \":\" +\n this.formatZerolessValue(value.getSeconds())\n\n if (useMilliseconds)\n finalValue += `.${this.formatMilliseconds(\n value.getMilliseconds(),\n )}`\n\n value = finalValue\n }\n\n return value\n }\n\n /**\n * Converts given value into utc datetime string in a \"YYYY-MM-DD HH-mm-ss.sss\" format.\n */\n static mixedDateToUtcDatetimeString(value: Date | any): string | any {\n if (typeof value === \"string\") {\n value = new Date(value)\n }\n if (value instanceof Date) {\n return (\n this.formatZerolessValue(value.getUTCFullYear(), 4) +\n \"-\" +\n this.formatZerolessValue(value.getUTCMonth() + 1) +\n \"-\" +\n this.formatZerolessValue(value.getUTCDate()) +\n \" \" +\n this.formatZerolessValue(value.getUTCHours()) +\n \":\" +\n this.formatZerolessValue(value.getUTCMinutes()) +\n \":\" +\n this.formatZerolessValue(value.getUTCSeconds()) +\n \".\" +\n this.formatMilliseconds(value.getUTCMilliseconds())\n )\n }\n\n return value\n }\n\n /**\n * Converts each item in the given array to string joined by \",\" separator.\n */\n static simpleArrayToString(value: any[] | any): string[] | any {\n if (Array.isArray(value)) {\n return (value as any[]).map((i) => String(i)).join(\",\")\n }\n\n return value\n }\n\n /**\n * Converts given string to simple array split by \",\" separator.\n */\n static stringToSimpleArray(value: string | any): string | any {\n if (typeof value === \"string\") {\n if (value.length > 0) {\n return value.split(\",\")\n } else {\n return []\n }\n }\n\n return value\n }\n\n static simpleJsonToString(value: any): string {\n return JSON.stringify(value)\n }\n\n static stringToSimpleJson(value: any) {\n return typeof value === \"string\" ? JSON.parse(value) : value\n }\n\n static simpleEnumToString(value: any) {\n return \"\" + value\n }\n\n static stringToSimpleEnum(value: any, columnMetadata: ColumnMetadata) {\n if (\n columnMetadata.enum &&\n !isNaN(value) &&\n columnMetadata.enum.indexOf(parseInt(value)) >= 0\n ) {\n // convert to number if that exists in poosible enum options\n value = parseInt(value)\n }\n\n return value\n }\n\n // -------------------------------------------------------------------------\n // Private Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Formats given number to \"0x\" format, e.g. if the totalLength = 2 and the value is 1 then it will return \"01\".\n */\n private static formatZerolessValue(value: number, totalLength = 2): string {\n const pad = \"0\".repeat(totalLength)\n\n return String(`${pad}${value}`).slice(-totalLength)\n }\n\n /**\n * Formats given number to \"0x\" format, e.g. if it is 1 then it will return \"01\".\n */\n private static formatMilliseconds(value: number): string {\n if (value < 10) {\n return \"00\" + value\n } else if (value < 100) {\n return \"0\" + value\n } else {\n return String(value)\n }\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/util/DateUtils.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,SAAS;IAClB,4EAA4E;IAC5E,wBAAwB;IACxB,4EAA4E;IAE5E;;OAEG;IACH,MAAM,CAAC,qBAAqB,CACxB,SAAoC;QAEpC,IAAI,CAAC,SAAS;YAAE,OAAO,SAAS,CAAA;QAEhC,OAAO,OAAO,SAAS,KAAK,QAAQ;YAChC,CAAC,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC;YACrB,CAAC,CAAE,SAAkB,CAAA;IAC7B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAAC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;;;;;;OAUG;IACK,MAAM,CAAC,cAAc,CAAC,UAAkB;QAC5C,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,CAAA;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;QACnD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,MAAM,CAAA;QAEnC,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;CACJ;AA1RD,8BA0RC","file":"DateUtils.js","sourcesContent":["import { ColumnMetadata } from \"../metadata/ColumnMetadata\"\n\n/**\n * Provides utilities to transform hydrated and persisted data.\n */\nexport class DateUtils {\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Normalizes date object hydrated from the database.\n */\n static normalizeHydratedDate(\n mixedDate: Date | string | undefined,\n ): Date | string | undefined {\n if (!mixedDate) return mixedDate\n\n return typeof mixedDate === \"string\"\n ? new Date(mixedDate)\n : (mixedDate as Date)\n }\n\n /**\n * Converts given value into date string in a \"YYYY-MM-DD\" format.\n */\n static mixedDateToDateString(value: string | Date): string {\n if (value instanceof Date) {\n return (\n this.formatZerolessValue(value.getFullYear(), 4) +\n \"-\" +\n this.formatZerolessValue(value.getMonth() + 1) +\n \"-\" +\n this.formatZerolessValue(value.getDate())\n )\n }\n\n return value\n }\n\n /**\n * Converts given value into date object.\n */\n static mixedDateToDate(\n mixedDate: Date | string,\n toUtc: boolean = false,\n useMilliseconds = true,\n ): Date {\n let date =\n typeof mixedDate === \"string\"\n ? DateUtils.parseDateAsISO(mixedDate)\n : mixedDate\n\n if (toUtc)\n date = new Date(\n date.getUTCFullYear(),\n date.getUTCMonth(),\n date.getUTCDate(),\n date.getUTCHours(),\n date.getUTCMinutes(),\n date.getUTCSeconds(),\n date.getUTCMilliseconds(),\n )\n\n if (!useMilliseconds) date.setUTCMilliseconds(0)\n\n return date\n }\n\n /**\n * Converts given value into time string in a \"HH:mm:ss\" format.\n */\n static mixedDateToTimeString(\n value: Date | any,\n skipSeconds: boolean = false,\n ): string | any {\n if (value instanceof Date)\n return (\n this.formatZerolessValue(value.getHours()) +\n \":\" +\n this.formatZerolessValue(value.getMinutes()) +\n (!skipSeconds\n ? \":\" + this.formatZerolessValue(value.getSeconds())\n : \"\")\n )\n\n return value\n }\n\n /**\n * Converts given value into time string in a \"HH:mm:ss\" format.\n */\n static mixedTimeToDate(value: Date | any): string | any {\n if (typeof value === \"string\") {\n const [hours, minutes, seconds] = value.split(\":\")\n const date = new Date()\n if (hours) date.setHours(parseInt(hours))\n if (minutes) date.setMinutes(parseInt(minutes))\n if (seconds) date.setSeconds(parseInt(seconds))\n return date\n }\n\n return value\n }\n\n /**\n * Converts given string value with \"-\" separator into a \"HH:mm:ss\" format.\n */\n static mixedTimeToString(\n value: string | any,\n skipSeconds: boolean = false,\n ): string | any {\n value =\n value instanceof Date\n ? value.getHours() +\n \":\" +\n value.getMinutes() +\n (!skipSeconds ? \":\" + value.getSeconds() : \"\")\n : value\n if (typeof value === \"string\") {\n return value\n .split(\":\")\n .map((v) => (v.length === 1 ? \"0\" + v : v)) // append zero at beginning if we have a first-zero-less number\n .join(\":\")\n }\n\n return value\n }\n\n /**\n * Converts given value into datetime string in a \"YYYY-MM-DD HH-mm-ss\" format.\n */\n static mixedDateToDatetimeString(\n value: Date | any,\n useMilliseconds?: boolean,\n ): string | any {\n if (typeof value === \"string\") {\n value = new Date(value)\n }\n if (value instanceof Date) {\n let finalValue =\n this.formatZerolessValue(value.getFullYear(), 4) +\n \"-\" +\n this.formatZerolessValue(value.getMonth() + 1) +\n \"-\" +\n this.formatZerolessValue(value.getDate()) +\n \" \" +\n this.formatZerolessValue(value.getHours()) +\n \":\" +\n this.formatZerolessValue(value.getMinutes()) +\n \":\" +\n this.formatZerolessValue(value.getSeconds())\n\n if (useMilliseconds)\n finalValue += `.${this.formatMilliseconds(\n value.getMilliseconds(),\n )}`\n\n value = finalValue\n }\n\n return value\n }\n\n /**\n * Converts given value into utc datetime string in a \"YYYY-MM-DD HH-mm-ss.sss\" format.\n */\n static mixedDateToUtcDatetimeString(value: Date | any): string | any {\n if (typeof value === \"string\") {\n value = new Date(value)\n }\n if (value instanceof Date) {\n return (\n this.formatZerolessValue(value.getUTCFullYear(), 4) +\n \"-\" +\n this.formatZerolessValue(value.getUTCMonth() + 1) +\n \"-\" +\n this.formatZerolessValue(value.getUTCDate()) +\n \" \" +\n this.formatZerolessValue(value.getUTCHours()) +\n \":\" +\n this.formatZerolessValue(value.getUTCMinutes()) +\n \":\" +\n this.formatZerolessValue(value.getUTCSeconds()) +\n \".\" +\n this.formatMilliseconds(value.getUTCMilliseconds())\n )\n }\n\n return value\n }\n\n /**\n * Converts each item in the given array to string joined by \",\" separator.\n */\n static simpleArrayToString(value: any[] | any): string[] | any {\n if (Array.isArray(value)) {\n return (value as any[]).map((i) => String(i)).join(\",\")\n }\n\n return value\n }\n\n /**\n * Converts given string to simple array split by \",\" separator.\n */\n static stringToSimpleArray(value: string | any): string | any {\n if (typeof value === \"string\") {\n if (value.length > 0) {\n return value.split(\",\")\n } else {\n return []\n }\n }\n\n return value\n }\n\n static simpleJsonToString(value: any): string {\n return JSON.stringify(value)\n }\n\n static stringToSimpleJson(value: any) {\n return typeof value === \"string\" ? JSON.parse(value) : value\n }\n\n static simpleEnumToString(value: any) {\n return \"\" + value\n }\n\n static stringToSimpleEnum(value: any, columnMetadata: ColumnMetadata) {\n if (\n columnMetadata.enum &&\n !isNaN(value) &&\n columnMetadata.enum.indexOf(parseInt(value)) >= 0\n ) {\n // convert to number if that exists in poosible enum options\n value = parseInt(value)\n }\n\n return value\n }\n\n // -------------------------------------------------------------------------\n // Private Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Formats given number to \"0x\" format, e.g. if the totalLength = 2 and the value is 1 then it will return \"01\".\n */\n private static formatZerolessValue(value: number, totalLength = 2): string {\n const pad = \"0\".repeat(totalLength)\n\n return String(`${pad}${value}`).slice(-totalLength)\n }\n\n /**\n * Formats given number to \"0x\" format, e.g. if it is 1 then it will return \"01\".\n */\n private static formatMilliseconds(value: number): string {\n if (value < 10) {\n return \"00\" + value\n } else if (value < 100) {\n return \"0\" + value\n } else {\n return String(value)\n }\n }\n\n /**\n * Parse a date without the UTC-offset of the device\n *\n * The problem here is with wrong timezone.\n *\n * For example:\n *\n * ``new Date('2021-04-28')`` will generate `2021-04-28T00:00:00.000Z`\n * in my timezone, which is not true for my timezone (GMT-0300). It should\n * be `2021-04-28T03:00:00.000Z` as `new Date(2021, 3, 28)` generates.\n */\n private static parseDateAsISO(dateString: string): Date {\n const date = new Date(dateString)\n const offset = date.getTimezoneOffset() * 60 * 1000\n const utc = date.getTime() + offset\n\n return new Date(utc)\n }\n}\n"],"sourceRoot":".."}
|
package/util/StringUtils.js
CHANGED
|
@@ -9,9 +9,9 @@ const sha_js_1 = tslib_1.__importDefault(require("sha.js"));
|
|
|
9
9
|
* @see http://stackoverflow.com/questions/2970525/converting-any-string-into-camel-case
|
|
10
10
|
*/
|
|
11
11
|
function camelCase(str, firstCapital = false) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
if (firstCapital)
|
|
13
|
+
str = " " + str;
|
|
14
|
+
return str.replace(/^([A-Z])|[\s-_](\w)/g, function (match, p1, p2) {
|
|
15
15
|
if (p2)
|
|
16
16
|
return p2.toUpperCase();
|
|
17
17
|
return p1.toLowerCase();
|
package/util/StringUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/StringUtils.ts"],"names":[],"mappings":";;;;AAAA,4DAA0B;AAE1B;;;;GAIG;AACH,SAAgB,SAAS,CAAC,GAAW,EAAE,eAAwB,KAAK;IAChE,OAAO,GAAG,CAAC,OAAO,
|
|
1
|
+
{"version":3,"sources":["../../src/util/StringUtils.ts"],"names":[],"mappings":";;;;AAAA,4DAA0B;AAE1B;;;;GAIG;AACH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IAAI,OAAO,CAAC,MAAM,EAAE;QAChB,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;KAC9C;IAED,OAAO,WAAW,CAAA;AACtB,CAAC;AAZD,oBAYC","file":"StringUtils.js","sourcesContent":["import shajs from \"sha.js\"\n\n/**\n * Converts string into camelCase.\n *\n * @see http://stackoverflow.com/questions/2970525/converting-any-string-into-camel-case\n */\nexport function camelCase(str: string, firstCapital: boolean = false): string {\n if (firstCapital) str = \" \" + str\n return str.replace(/^([A-Z])|[\\s-_](\\w)/g, function (match, p1, p2) {\n if (p2) return p2.toUpperCase()\n return p1.toLowerCase()\n })\n}\n\n/**\n * Converts string into snake_case.\n *\n */\nexport function snakeCase(str: string): string {\n return (\n str\n // ABc -> a_bc\n .replace(/([A-Z])([A-Z])([a-z])/g, \"$1_$2$3\")\n // aC -> a_c\n .replace(/([a-z0-9])([A-Z])/g, \"$1_$2\")\n .toLowerCase()\n )\n}\n\n/**\n * Converts string into Title Case.\n *\n * @see http://stackoverflow.com/questions/196972/convert-string-to-title-case-with-javascript\n */\nexport function titleCase(str: string): string {\n return str.replace(\n /\\w\\S*/g,\n (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(),\n )\n}\n\n/**\n * Builds abbreviated string from given string;\n */\nexport function abbreviate(str: string, abbrLettersCount: number = 1): string {\n const words = str\n .replace(/([a-z\\xE0-\\xFF])([A-Z\\xC0\\xDF])/g, \"$1 $2\")\n .split(\" \")\n return words.reduce((res, word) => {\n res += word.substr(0, abbrLettersCount)\n return res\n }, \"\")\n}\n\nexport interface IShortenOptions {\n /** String used to split \"segments\" of the alias/column name */\n separator?: string\n /** Maximum length of any \"segment\" */\n segmentLength?: number\n /** Length of any \"term\" in a \"segment\"; \"OrderItem\" is a segment, \"Order\" and \"Items\" are terms */\n termLength?: number\n}\n\n/**\n * Shorten a given `input`. Useful for RDBMS imposing a limit on the\n * maximum length of aliases and column names in SQL queries.\n *\n * @param input String to be shortened.\n * @param options Default to `4` for segments length, `2` for terms length, `'__'` as a separator.\n *\n * @return Shortened `input`.\n *\n * @example\n * // returns: \"UsShCa__orde__mark__dire\"\n * shorten('UserShoppingCart__order__market__director')\n *\n * // returns: \"cat_wit_ver_lon_nam_pos_wit_ver_lon_nam_pos_wit_ver_lon_nam\"\n * shorten(\n * 'category_with_very_long_name_posts_with_very_long_name_post_with_very_long_name',\n * { separator: '_', segmentLength: 3 }\n * )\n *\n * // equals: UsShCa__orde__mark_market_id\n * `${shorten('UserShoppingCart__order__market')}_market_id`\n */\nexport function shorten(input: string, options: IShortenOptions = {}): string {\n const { segmentLength = 4, separator = \"__\", termLength = 2 } = options\n\n const segments = input.split(separator)\n const shortSegments = segments.reduce((acc: string[], val: string) => {\n // split the given segment into many terms based on an eventual camel cased name\n const segmentTerms = val\n .replace(/([a-z\\xE0-\\xFF])([A-Z\\xC0-\\xDF])/g, \"$1 $2\")\n .split(\" \")\n // \"OrderItemList\" becomes \"OrItLi\", while \"company\" becomes \"comp\"\n const length = segmentTerms.length > 1 ? termLength : segmentLength\n const shortSegment = segmentTerms\n .map((term) => term.substr(0, length))\n .join(\"\")\n\n acc.push(shortSegment)\n return acc\n }, [])\n\n return shortSegments.join(separator)\n}\n\ninterface IHashOptions {\n length?: number\n}\n\n/**\n * Returns a hashed input.\n *\n * @param input String to be hashed.\n * @param options.length Optionally, shorten the output to desired length.\n */\nexport function hash(input: string, options: IHashOptions = {}): string {\n const hashFunction = shajs(\"sha256\")\n\n hashFunction.update(input, \"utf8\")\n\n const hashedInput = hashFunction.digest(\"hex\")\n\n if (options.length) {\n return hashedInput.slice(0, options.length)\n }\n\n return hashedInput\n}\n"],"sourceRoot":".."}
|