@punks/backend-entity-manager 0.0.70 → 0.0.72
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/dist/cjs/index.js +604 -30
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/__test__/entity/foo.d.ts +7 -2
- package/dist/cjs/types/__test__/providers/typeorm/entity/foo.d.ts +14 -2
- package/dist/cjs/types/abstractions/actions.d.ts +21 -8
- package/dist/cjs/types/abstractions/adapters.d.ts +3 -2
- package/dist/cjs/types/abstractions/authorization.d.ts +6 -4
- package/dist/cjs/types/abstractions/commands.d.ts +11 -0
- package/dist/cjs/types/abstractions/errors.d.ts +3 -2
- package/dist/cjs/types/abstractions/index.d.ts +2 -1
- package/dist/cjs/types/abstractions/manager.d.ts +12 -9
- package/dist/cjs/types/abstractions/pipelines.d.ts +10 -0
- package/dist/cjs/types/abstractions/queries.d.ts +11 -1
- package/dist/cjs/types/abstractions/repository.d.ts +9 -5
- package/dist/cjs/types/actions/count.d.ts +8 -0
- package/dist/cjs/types/actions/deleteItems.d.ts +8 -0
- package/dist/cjs/types/actions/exists.d.ts +8 -0
- package/dist/cjs/types/authorization/allowAll.d.ts +1 -0
- package/dist/cjs/types/commands/deleteItems.d.ts +9 -0
- package/dist/cjs/types/concrete/index.d.ts +23 -17
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/cjs/types/integrations/repository/typeorm/queryBuilder.d.ts +4 -0
- package/dist/cjs/types/integrations/repository/typeorm/repository.d.ts +4 -4
- package/dist/cjs/types/platforms/nest/__test__/server/app/companies/company.actions.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/app/divisions/division.actions.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/app/organizations/organization.actions.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/app/organizations/templates/index.d.ts +2 -0
- package/dist/cjs/types/platforms/nest/__test__/server/app/organizations/templates/organization-register/index.d.ts +34 -0
- package/dist/cjs/types/platforms/nest/__test__/server/app/roles/role.actions.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/app/tenants/tenant.actions.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/app/userGroupMembers/userGroupMember.actions.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/app/userGroups/userGroup.actions.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/app/userProfiles/userProfile.actions.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/app/userRoles/userRole.actions.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/app/users/user.actions.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/entities/companies/company.adapter.d.ts +3 -3
- package/dist/cjs/types/platforms/nest/__test__/server/entities/companies/company.authentication.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/companies/company.manager.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/entities/companies/company.models.d.ts +8 -3
- package/dist/cjs/types/platforms/nest/__test__/server/entities/divisions/division.adapter.d.ts +3 -3
- package/dist/cjs/types/platforms/nest/__test__/server/entities/divisions/division.authentication.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/divisions/division.manager.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/entities/divisions/division.models.d.ts +8 -3
- package/dist/cjs/types/platforms/nest/__test__/server/entities/foo/actions.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/entities/foo/authentication.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/foo/manager.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/entities/foo/models.d.ts +13 -1
- package/dist/cjs/types/platforms/nest/__test__/server/entities/organizations/organization.adapter.d.ts +3 -3
- package/dist/cjs/types/platforms/nest/__test__/server/entities/organizations/organization.authentication.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/organizations/organization.manager.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/entities/organizations/organization.models.d.ts +8 -3
- package/dist/cjs/types/platforms/nest/__test__/server/entities/roles/role.adapter.d.ts +3 -3
- package/dist/cjs/types/platforms/nest/__test__/server/entities/roles/role.authentication.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/roles/role.manager.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/entities/roles/role.models.d.ts +8 -3
- package/dist/cjs/types/platforms/nest/__test__/server/entities/tenants/tenant.adapter.d.ts +3 -3
- package/dist/cjs/types/platforms/nest/__test__/server/entities/tenants/tenant.authentication.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/tenants/tenant.manager.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/entities/tenants/tenant.models.d.ts +10 -3
- package/dist/cjs/types/platforms/nest/__test__/server/entities/userGroupMembers/userGroupMember.authentication.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/userGroupMembers/userGroupMember.manager.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/entities/userGroupMembers/userGroupMember.models.d.ts +5 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/userGroups/userGroup.adapter.d.ts +3 -3
- package/dist/cjs/types/platforms/nest/__test__/server/entities/userGroups/userGroup.authentication.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/userGroups/userGroup.manager.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/entities/userGroups/userGroup.models.d.ts +8 -3
- package/dist/cjs/types/platforms/nest/__test__/server/entities/userProfiles/userProfile.adapter.d.ts +3 -3
- package/dist/cjs/types/platforms/nest/__test__/server/entities/userProfiles/userProfile.authentication.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/userProfiles/userProfile.manager.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/entities/userProfiles/userProfile.models.d.ts +8 -3
- package/dist/cjs/types/platforms/nest/__test__/server/entities/userRoles/userRole.adapter.d.ts +3 -3
- package/dist/cjs/types/platforms/nest/__test__/server/entities/userRoles/userRole.authentication.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/userRoles/userRole.manager.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/entities/userRoles/userRole.models.d.ts +8 -3
- package/dist/cjs/types/platforms/nest/__test__/server/entities/users/user.adapter.d.ts +3 -3
- package/dist/cjs/types/platforms/nest/__test__/server/entities/users/user.authentication.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/users/user.manager.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/entities/users/user.models.d.ts +8 -3
- package/dist/cjs/types/platforms/nest/__test__/server/infrastructure/authentication/processors/entity-auth/index.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/tests/pipelines/test_crud_pipeline.test.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/tests/pipelines/test_simple_pipeline.test.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/authentication/entityAuthorizationMiddleware.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/base/entityActions.d.ts +3 -2
- package/dist/cjs/types/platforms/nest/base/entityManager.d.ts +3 -2
- package/dist/cjs/types/platforms/nest/decorators/index.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/decorators/pipelines.d.ts +4 -0
- package/dist/cjs/types/platforms/nest/decorators/symbols.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/index.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/pipelines/builder/concrete.d.ts +4 -0
- package/dist/cjs/types/platforms/nest/pipelines/builder/index.d.ts +7 -0
- package/dist/cjs/types/platforms/nest/pipelines/builder/types.d.ts +14 -0
- package/dist/cjs/types/platforms/nest/pipelines/index.d.ts +2 -0
- package/dist/cjs/types/platforms/nest/pipelines/providers.d.ts +3 -0
- package/dist/cjs/types/platforms/nest/pipelines/runner/index.d.ts +11 -0
- package/dist/cjs/types/platforms/nest/pipelines/template/index.d.ts +17 -0
- package/dist/cjs/types/platforms/nest/processors/initializer/index.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/services/manager/index.d.ts +2 -2
- package/dist/cjs/types/providers/services.d.ts +31 -10
- package/dist/cjs/types/queries/count.d.ts +10 -0
- package/dist/cjs/types/queries/exists.d.ts +10 -0
- package/dist/cjs/types/symbols/ioc.d.ts +9 -0
- package/dist/cjs/types/templates/index.d.ts +1 -0
- package/dist/cjs/types/templates/pipelines/controller/index.d.ts +5 -0
- package/dist/cjs/types/templates/pipelines/converters/index.d.ts +4 -0
- package/dist/cjs/types/templates/pipelines/index.d.ts +1 -0
- package/dist/cjs/types/templates/pipelines/instance/index.d.ts +19 -0
- package/dist/cjs/types/templates/{queryBuilder.d.ts → queryBuilder/index.d.ts} +7 -3
- package/dist/cjs/types/testing/mocks/repository.d.ts +2 -2
- package/dist/cjs/types/types/index.d.ts +2 -0
- package/dist/cjs/types/types/objects.d.ts +4 -0
- package/dist/cjs/types/types/pipelines.d.ts +95 -0
- package/dist/esm/index.js +603 -31
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/__test__/entity/foo.d.ts +7 -2
- package/dist/esm/types/__test__/providers/typeorm/entity/foo.d.ts +14 -2
- package/dist/esm/types/abstractions/actions.d.ts +21 -8
- package/dist/esm/types/abstractions/adapters.d.ts +3 -2
- package/dist/esm/types/abstractions/authorization.d.ts +6 -4
- package/dist/esm/types/abstractions/commands.d.ts +11 -0
- package/dist/esm/types/abstractions/errors.d.ts +3 -2
- package/dist/esm/types/abstractions/index.d.ts +2 -1
- package/dist/esm/types/abstractions/manager.d.ts +12 -9
- package/dist/esm/types/abstractions/pipelines.d.ts +10 -0
- package/dist/esm/types/abstractions/queries.d.ts +11 -1
- package/dist/esm/types/abstractions/repository.d.ts +9 -5
- package/dist/esm/types/actions/count.d.ts +8 -0
- package/dist/esm/types/actions/deleteItems.d.ts +8 -0
- package/dist/esm/types/actions/exists.d.ts +8 -0
- package/dist/esm/types/authorization/allowAll.d.ts +1 -0
- package/dist/esm/types/commands/deleteItems.d.ts +9 -0
- package/dist/esm/types/concrete/index.d.ts +23 -17
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/types/integrations/repository/typeorm/queryBuilder.d.ts +4 -0
- package/dist/esm/types/integrations/repository/typeorm/repository.d.ts +4 -4
- package/dist/esm/types/platforms/nest/__test__/server/app/companies/company.actions.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/app/divisions/division.actions.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/app/organizations/organization.actions.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/app/organizations/templates/index.d.ts +2 -0
- package/dist/esm/types/platforms/nest/__test__/server/app/organizations/templates/organization-register/index.d.ts +34 -0
- package/dist/esm/types/platforms/nest/__test__/server/app/roles/role.actions.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/app/tenants/tenant.actions.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/app/userGroupMembers/userGroupMember.actions.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/app/userGroups/userGroup.actions.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/app/userProfiles/userProfile.actions.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/app/userRoles/userRole.actions.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/app/users/user.actions.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/entities/companies/company.adapter.d.ts +3 -3
- package/dist/esm/types/platforms/nest/__test__/server/entities/companies/company.authentication.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/companies/company.manager.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/entities/companies/company.models.d.ts +8 -3
- package/dist/esm/types/platforms/nest/__test__/server/entities/divisions/division.adapter.d.ts +3 -3
- package/dist/esm/types/platforms/nest/__test__/server/entities/divisions/division.authentication.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/divisions/division.manager.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/entities/divisions/division.models.d.ts +8 -3
- package/dist/esm/types/platforms/nest/__test__/server/entities/foo/actions.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/entities/foo/authentication.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/foo/manager.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/entities/foo/models.d.ts +13 -1
- package/dist/esm/types/platforms/nest/__test__/server/entities/organizations/organization.adapter.d.ts +3 -3
- package/dist/esm/types/platforms/nest/__test__/server/entities/organizations/organization.authentication.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/organizations/organization.manager.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/entities/organizations/organization.models.d.ts +8 -3
- package/dist/esm/types/platforms/nest/__test__/server/entities/roles/role.adapter.d.ts +3 -3
- package/dist/esm/types/platforms/nest/__test__/server/entities/roles/role.authentication.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/roles/role.manager.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/entities/roles/role.models.d.ts +8 -3
- package/dist/esm/types/platforms/nest/__test__/server/entities/tenants/tenant.adapter.d.ts +3 -3
- package/dist/esm/types/platforms/nest/__test__/server/entities/tenants/tenant.authentication.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/tenants/tenant.manager.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/entities/tenants/tenant.models.d.ts +10 -3
- package/dist/esm/types/platforms/nest/__test__/server/entities/userGroupMembers/userGroupMember.authentication.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/userGroupMembers/userGroupMember.manager.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/entities/userGroupMembers/userGroupMember.models.d.ts +5 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/userGroups/userGroup.adapter.d.ts +3 -3
- package/dist/esm/types/platforms/nest/__test__/server/entities/userGroups/userGroup.authentication.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/userGroups/userGroup.manager.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/entities/userGroups/userGroup.models.d.ts +8 -3
- package/dist/esm/types/platforms/nest/__test__/server/entities/userProfiles/userProfile.adapter.d.ts +3 -3
- package/dist/esm/types/platforms/nest/__test__/server/entities/userProfiles/userProfile.authentication.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/userProfiles/userProfile.manager.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/entities/userProfiles/userProfile.models.d.ts +8 -3
- package/dist/esm/types/platforms/nest/__test__/server/entities/userRoles/userRole.adapter.d.ts +3 -3
- package/dist/esm/types/platforms/nest/__test__/server/entities/userRoles/userRole.authentication.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/userRoles/userRole.manager.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/entities/userRoles/userRole.models.d.ts +8 -3
- package/dist/esm/types/platforms/nest/__test__/server/entities/users/user.adapter.d.ts +3 -3
- package/dist/esm/types/platforms/nest/__test__/server/entities/users/user.authentication.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/users/user.manager.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/entities/users/user.models.d.ts +8 -3
- package/dist/esm/types/platforms/nest/__test__/server/infrastructure/authentication/processors/entity-auth/index.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/tests/pipelines/test_crud_pipeline.test.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/tests/pipelines/test_simple_pipeline.test.d.ts +1 -0
- package/dist/esm/types/platforms/nest/authentication/entityAuthorizationMiddleware.d.ts +1 -0
- package/dist/esm/types/platforms/nest/base/entityActions.d.ts +3 -2
- package/dist/esm/types/platforms/nest/base/entityManager.d.ts +3 -2
- package/dist/esm/types/platforms/nest/decorators/index.d.ts +1 -0
- package/dist/esm/types/platforms/nest/decorators/pipelines.d.ts +4 -0
- package/dist/esm/types/platforms/nest/decorators/symbols.d.ts +1 -0
- package/dist/esm/types/platforms/nest/index.d.ts +1 -0
- package/dist/esm/types/platforms/nest/pipelines/builder/concrete.d.ts +4 -0
- package/dist/esm/types/platforms/nest/pipelines/builder/index.d.ts +7 -0
- package/dist/esm/types/platforms/nest/pipelines/builder/types.d.ts +14 -0
- package/dist/esm/types/platforms/nest/pipelines/index.d.ts +2 -0
- package/dist/esm/types/platforms/nest/pipelines/providers.d.ts +3 -0
- package/dist/esm/types/platforms/nest/pipelines/runner/index.d.ts +11 -0
- package/dist/esm/types/platforms/nest/pipelines/template/index.d.ts +17 -0
- package/dist/esm/types/platforms/nest/processors/initializer/index.d.ts +1 -0
- package/dist/esm/types/platforms/nest/services/manager/index.d.ts +2 -2
- package/dist/esm/types/providers/services.d.ts +31 -10
- package/dist/esm/types/queries/count.d.ts +10 -0
- package/dist/esm/types/queries/exists.d.ts +10 -0
- package/dist/esm/types/symbols/ioc.d.ts +9 -0
- package/dist/esm/types/templates/index.d.ts +1 -0
- package/dist/esm/types/templates/pipelines/controller/index.d.ts +5 -0
- package/dist/esm/types/templates/pipelines/converters/index.d.ts +4 -0
- package/dist/esm/types/templates/pipelines/index.d.ts +1 -0
- package/dist/esm/types/templates/pipelines/instance/index.d.ts +19 -0
- package/dist/esm/types/templates/{queryBuilder.d.ts → queryBuilder/index.d.ts} +7 -3
- package/dist/esm/types/testing/mocks/repository.d.ts +2 -2
- package/dist/esm/types/types/index.d.ts +2 -0
- package/dist/esm/types/types/objects.d.ts +4 -0
- package/dist/esm/types/types/pipelines.d.ts +95 -0
- package/dist/index.d.ts +278 -64
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -122,12 +122,11 @@ class NestEntityActions {
|
|
|
122
122
|
constructor(entityName, registry) {
|
|
123
123
|
this.services = registry.resolveEntityServicesCollection(entityName);
|
|
124
124
|
}
|
|
125
|
-
get
|
|
125
|
+
get manager() {
|
|
126
126
|
if (!this.actionsInstance) {
|
|
127
127
|
this.actionsInstance =
|
|
128
128
|
this.services.resolveEntityActions();
|
|
129
129
|
}
|
|
130
|
-
this.services.resolveEntityActions;
|
|
131
130
|
return this.actionsInstance;
|
|
132
131
|
}
|
|
133
132
|
}
|
|
@@ -137,7 +136,7 @@ class NestEntityManager {
|
|
|
137
136
|
constructor(entityName, registry) {
|
|
138
137
|
this.services = registry.resolveEntityServicesCollection(entityName);
|
|
139
138
|
}
|
|
140
|
-
get
|
|
139
|
+
get manager() {
|
|
141
140
|
if (!this.managerInstance) {
|
|
142
141
|
this.managerInstance =
|
|
143
142
|
this.services.resolveEntityManager();
|
|
@@ -161,6 +160,7 @@ const EntityManagerSymbols = {
|
|
|
161
160
|
EntitySeeder: Symbol.for("WP:ENTITY_SEEDER"),
|
|
162
161
|
EmailProvider: Symbol.for("WP:EMAIL_PROVIDER"),
|
|
163
162
|
EmailTemplate: Symbol.for("WP:EMAIL_TEMPLATE"),
|
|
163
|
+
PipelineTemplate: Symbol.for("WP:PIPELINE_TEMPLATE"),
|
|
164
164
|
};
|
|
165
165
|
|
|
166
166
|
const WpEntityAuthMiddleware = (entityName, props = {}) => common.applyDecorators(common.Injectable(), common.SetMetadata(EntityManagerSymbols.EntityAuthMiddleware, {
|
|
@@ -217,6 +217,11 @@ const WpEntityQueryBuilder = (entityName, props = {}) => common.applyDecorators(
|
|
|
217
217
|
...props,
|
|
218
218
|
}));
|
|
219
219
|
|
|
220
|
+
const WpPipeline = (name, props = {}) => common.applyDecorators(common.Injectable(), common.SetMetadata(EntityManagerSymbols.PipelineTemplate, {
|
|
221
|
+
name,
|
|
222
|
+
...props,
|
|
223
|
+
}));
|
|
224
|
+
|
|
220
225
|
const WpEntitySeeder = (entityName, props = {}) => common.applyDecorators(common.Injectable(), common.SetMetadata(EntityManagerSymbols.EntitySeeder, {
|
|
221
226
|
entityName,
|
|
222
227
|
...props,
|
|
@@ -467,6 +472,15 @@ exports.AppHashingService = __decorate([
|
|
|
467
472
|
common.Injectable()
|
|
468
473
|
], exports.AppHashingService);
|
|
469
474
|
|
|
475
|
+
class EntitiesCountAction {
|
|
476
|
+
constructor(services) {
|
|
477
|
+
this.services = services;
|
|
478
|
+
}
|
|
479
|
+
async execute(filters) {
|
|
480
|
+
return await this.services.resolveCountQuery().execute(filters);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
470
484
|
class EntityCreateAction {
|
|
471
485
|
constructor(services) {
|
|
472
486
|
this.services = services;
|
|
@@ -494,6 +508,24 @@ class EntityDeleteAction {
|
|
|
494
508
|
}
|
|
495
509
|
}
|
|
496
510
|
|
|
511
|
+
class EntitiesDeleteAction {
|
|
512
|
+
constructor(services) {
|
|
513
|
+
this.services = services;
|
|
514
|
+
}
|
|
515
|
+
async execute(params) {
|
|
516
|
+
await this.services.resolveDeleteItemsCommand().execute(params);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
class EntityExistsAction {
|
|
521
|
+
constructor(services) {
|
|
522
|
+
this.services = services;
|
|
523
|
+
}
|
|
524
|
+
async execute(filters) {
|
|
525
|
+
return await this.services.resolveExistsQuery().execute(filters);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
497
529
|
class EntityGetAction {
|
|
498
530
|
constructor(services) {
|
|
499
531
|
this.services = services;
|
|
@@ -611,6 +643,40 @@ class EntityDeleteCommand {
|
|
|
611
643
|
}
|
|
612
644
|
}
|
|
613
645
|
|
|
646
|
+
class EntitiesDeleteCommand {
|
|
647
|
+
constructor(services) {
|
|
648
|
+
this.services = services;
|
|
649
|
+
}
|
|
650
|
+
async execute(params) {
|
|
651
|
+
await this.authorize();
|
|
652
|
+
const context = await this.getContext();
|
|
653
|
+
const deleteResult = await this.services
|
|
654
|
+
.resolveQueryBuilder()
|
|
655
|
+
.delete(params.filters, context);
|
|
656
|
+
// todo: add entities deleted event
|
|
657
|
+
return deleteResult;
|
|
658
|
+
}
|
|
659
|
+
async getContext() {
|
|
660
|
+
const authorization = this.services.resolveAuthorizationMiddleware();
|
|
661
|
+
if (!authorization) {
|
|
662
|
+
return undefined;
|
|
663
|
+
}
|
|
664
|
+
const contextService = this.services.resolveAuthenticationContextProvider();
|
|
665
|
+
return await contextService.getContext();
|
|
666
|
+
}
|
|
667
|
+
async authorize() {
|
|
668
|
+
const authorization = this.services.resolveAuthorizationMiddleware();
|
|
669
|
+
if (!authorization) {
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
const contextService = this.services.resolveAuthenticationContextProvider();
|
|
673
|
+
const context = await contextService.getContext();
|
|
674
|
+
const authorizationResult = await authorization.canDeleteItems(context);
|
|
675
|
+
if (!authorizationResult.isAuthorized)
|
|
676
|
+
throw new EntityOperationUnauthorizedException(exports.EntityOperationType.Delete, this.services.getEntityName());
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
614
680
|
class EntityUpdateCommand {
|
|
615
681
|
constructor(services) {
|
|
616
682
|
this.services = services;
|
|
@@ -695,23 +761,31 @@ class EntityManager {
|
|
|
695
761
|
constructor(services) {
|
|
696
762
|
this.services = services;
|
|
697
763
|
}
|
|
698
|
-
get() {
|
|
764
|
+
get exists() {
|
|
765
|
+
return this.services.resolveExistsQuery();
|
|
766
|
+
}
|
|
767
|
+
get count() {
|
|
768
|
+
return this.services.resolveCountQuery();
|
|
769
|
+
}
|
|
770
|
+
get deleteItems() {
|
|
771
|
+
return this.services.resolveDeleteItemsCommand();
|
|
772
|
+
}
|
|
773
|
+
get get() {
|
|
699
774
|
return this.services.resolveGetQuery();
|
|
700
775
|
}
|
|
701
|
-
|
|
702
|
-
search() {
|
|
776
|
+
get search() {
|
|
703
777
|
return this.services.resolveSearchQuery();
|
|
704
778
|
}
|
|
705
|
-
create() {
|
|
779
|
+
get create() {
|
|
706
780
|
return this.services.resolveCreateCommand();
|
|
707
781
|
}
|
|
708
|
-
update() {
|
|
782
|
+
get update() {
|
|
709
783
|
return this.services.resolveUpdateCommand();
|
|
710
784
|
}
|
|
711
|
-
upsert() {
|
|
785
|
+
get upsert() {
|
|
712
786
|
return this.services.resolveUpsertCommand();
|
|
713
787
|
}
|
|
714
|
-
delete() {
|
|
788
|
+
get delete() {
|
|
715
789
|
return this.services.resolveDeleteCommand();
|
|
716
790
|
}
|
|
717
791
|
}
|
|
@@ -719,22 +793,31 @@ class EntityActions {
|
|
|
719
793
|
constructor(services) {
|
|
720
794
|
this.services = services;
|
|
721
795
|
}
|
|
722
|
-
get() {
|
|
796
|
+
get exists() {
|
|
797
|
+
return this.services.resolveExistsAction();
|
|
798
|
+
}
|
|
799
|
+
get count() {
|
|
800
|
+
return this.services.resolveCountAction();
|
|
801
|
+
}
|
|
802
|
+
get deleteItems() {
|
|
803
|
+
return this.services.resolveDeleteItemsAction();
|
|
804
|
+
}
|
|
805
|
+
get get() {
|
|
723
806
|
return this.services.resolveGetAction();
|
|
724
807
|
}
|
|
725
|
-
search() {
|
|
808
|
+
get search() {
|
|
726
809
|
return this.services.resolveSearchAction();
|
|
727
810
|
}
|
|
728
|
-
create() {
|
|
811
|
+
get create() {
|
|
729
812
|
return this.services.resolveCreateAction();
|
|
730
813
|
}
|
|
731
|
-
update() {
|
|
814
|
+
get update() {
|
|
732
815
|
return this.services.resolveUpdateAction();
|
|
733
816
|
}
|
|
734
|
-
upsert() {
|
|
817
|
+
get upsert() {
|
|
735
818
|
return this.services.resolveUpsertAction();
|
|
736
819
|
}
|
|
737
|
-
delete() {
|
|
820
|
+
get delete() {
|
|
738
821
|
return this.services.resolveDeleteAction();
|
|
739
822
|
}
|
|
740
823
|
}
|
|
@@ -780,6 +863,9 @@ class ServiceLocator {
|
|
|
780
863
|
const EntityServices = {
|
|
781
864
|
Actions: {
|
|
782
865
|
IEntityGetAction: "IEntityGetAction",
|
|
866
|
+
IEntityExistsAction: "IEntityExistsAction",
|
|
867
|
+
IEntitiesCountAction: "IEntitiesCountAction",
|
|
868
|
+
IEntitiesDeleteAction: "IEntitiesDeleteAction",
|
|
783
869
|
IEntitiesSearchAction: "IEntitiesSearchAction",
|
|
784
870
|
IEntityCreateAction: "IEntityCreateAction",
|
|
785
871
|
IEntityUpdateAction: "IEntityUpdateAction",
|
|
@@ -796,6 +882,7 @@ const EntityServices = {
|
|
|
796
882
|
IEntityUpsertCommand: "IEntityUpsertCommand",
|
|
797
883
|
IEntityMergeCommand: "IEntityMergeCommand",
|
|
798
884
|
IEntityDeleteCommand: "IEntityDeleteCommand",
|
|
885
|
+
IEntitiesDeleteCommand: "IEntitiesDeleteCommand",
|
|
799
886
|
},
|
|
800
887
|
Converters: {
|
|
801
888
|
IEntityAdapter: "IEntityAdapter",
|
|
@@ -810,6 +897,8 @@ const EntityServices = {
|
|
|
810
897
|
IEntityEventsManager: "IEntityEventsManager",
|
|
811
898
|
},
|
|
812
899
|
Queries: {
|
|
900
|
+
IEntityCountQuery: "IEntityCountQuery",
|
|
901
|
+
IEntityExistsQuery: "IEntityExistsQuery",
|
|
813
902
|
IEntityGetQuery: "IEntityGetQuery",
|
|
814
903
|
IEntitiesSearchQuery: "IEntitiesSearchQuery",
|
|
815
904
|
IEntitiesQueryBuilder: "IEntitiesQueryBuilder",
|
|
@@ -839,6 +928,9 @@ const GlobalServices = {
|
|
|
839
928
|
IEmailProvider: "IEmailProvider",
|
|
840
929
|
IEmailTemplatesCollection: "IEmailTemplatesCollection",
|
|
841
930
|
},
|
|
931
|
+
Pipelines: {
|
|
932
|
+
IPipelineController: "IPipelineController",
|
|
933
|
+
},
|
|
842
934
|
};
|
|
843
935
|
|
|
844
936
|
class EntityServiceLocator {
|
|
@@ -894,6 +986,12 @@ class EntityServiceLocator {
|
|
|
894
986
|
resolveGetQuery() {
|
|
895
987
|
return this.services.resolveGetQuery(this.entityName);
|
|
896
988
|
}
|
|
989
|
+
resolveExistsQuery() {
|
|
990
|
+
return this.services.resolveExistsQuery(this.entityName);
|
|
991
|
+
}
|
|
992
|
+
resolveCountQuery() {
|
|
993
|
+
return this.services.resolveCountQuery(this.entityName);
|
|
994
|
+
}
|
|
897
995
|
resolveSearchQuery() {
|
|
898
996
|
return this.services.resolveSearchQuery(this.entityName);
|
|
899
997
|
}
|
|
@@ -912,9 +1010,18 @@ class EntityServiceLocator {
|
|
|
912
1010
|
resolveDeleteCommand() {
|
|
913
1011
|
return this.services.resolveDeleteCommand(this.entityName);
|
|
914
1012
|
}
|
|
1013
|
+
resolveDeleteItemsCommand() {
|
|
1014
|
+
return this.services.resolveDeleteItemsCommand(this.entityName);
|
|
1015
|
+
}
|
|
915
1016
|
resolveGetAction() {
|
|
916
1017
|
return this.services.resolveGetAction(this.entityName);
|
|
917
1018
|
}
|
|
1019
|
+
resolveExistsAction() {
|
|
1020
|
+
return this.services.resolveExistsAction(this.entityName);
|
|
1021
|
+
}
|
|
1022
|
+
resolveCountAction() {
|
|
1023
|
+
return this.services.resolveCountAction(this.entityName);
|
|
1024
|
+
}
|
|
918
1025
|
resolveSearchAction() {
|
|
919
1026
|
return this.services.resolveSearchAction(this.entityName);
|
|
920
1027
|
}
|
|
@@ -930,6 +1037,9 @@ class EntityServiceLocator {
|
|
|
930
1037
|
resolveDeleteAction() {
|
|
931
1038
|
return this.services.resolveDeleteAction(this.entityName);
|
|
932
1039
|
}
|
|
1040
|
+
resolveDeleteItemsAction() {
|
|
1041
|
+
return this.services.resolveDeleteItemsAction(this.entityName);
|
|
1042
|
+
}
|
|
933
1043
|
resolveQueryBuilder() {
|
|
934
1044
|
return this.services.resolveQueryBuilder(this.entityName);
|
|
935
1045
|
}
|
|
@@ -970,6 +1080,12 @@ class EntitiesServiceLocator {
|
|
|
970
1080
|
registerEmailTemplatesCollection(instance) {
|
|
971
1081
|
this.provider.register(GlobalServices.Messaging.IEmailTemplatesCollection, instance);
|
|
972
1082
|
}
|
|
1083
|
+
resolvePipelinesController() {
|
|
1084
|
+
return this.provider.resolve(GlobalServices.Pipelines.IPipelineController);
|
|
1085
|
+
}
|
|
1086
|
+
registerPipelinesController(instance) {
|
|
1087
|
+
this.provider.register(GlobalServices.Pipelines.IPipelineController, instance);
|
|
1088
|
+
}
|
|
973
1089
|
resolveAuthenticationContextProvider() {
|
|
974
1090
|
return this.provider.resolve(GlobalServices.Authentication.IAuthenticationContextProvider);
|
|
975
1091
|
}
|
|
@@ -1072,6 +1188,18 @@ class EntitiesServiceLocator {
|
|
|
1072
1188
|
registerSearchQuery(entityName, instance) {
|
|
1073
1189
|
this.provider.registerEntityService(EntityServices.Queries.IEntitiesSearchQuery, entityName, instance);
|
|
1074
1190
|
}
|
|
1191
|
+
resolveExistsQuery(entityName) {
|
|
1192
|
+
return this.provider.resolveEntityService(EntityServices.Queries.IEntityExistsQuery, entityName);
|
|
1193
|
+
}
|
|
1194
|
+
registerExistsQuery(entityName, instance) {
|
|
1195
|
+
this.provider.registerEntityService(EntityServices.Queries.IEntityExistsQuery, entityName, instance);
|
|
1196
|
+
}
|
|
1197
|
+
resolveCountQuery(entityName) {
|
|
1198
|
+
return this.provider.resolveEntityService(EntityServices.Queries.IEntityCountQuery, entityName);
|
|
1199
|
+
}
|
|
1200
|
+
registerCountQuery(entityName, instance) {
|
|
1201
|
+
this.provider.registerEntityService(EntityServices.Queries.IEntityCountQuery, entityName, instance);
|
|
1202
|
+
}
|
|
1075
1203
|
resolveCreateCommand(entityName) {
|
|
1076
1204
|
return this.provider.resolveEntityService(EntityServices.Commands.IEntityCreateCommand, entityName);
|
|
1077
1205
|
}
|
|
@@ -1090,6 +1218,12 @@ class EntitiesServiceLocator {
|
|
|
1090
1218
|
registerUpsertCommand(entityName, instance) {
|
|
1091
1219
|
this.provider.registerEntityService(EntityServices.Commands.IEntityUpsertCommand, entityName, instance);
|
|
1092
1220
|
}
|
|
1221
|
+
resolveDeleteItemsCommand(entityName) {
|
|
1222
|
+
return this.provider.resolveEntityService(EntityServices.Commands.IEntitiesDeleteCommand, entityName);
|
|
1223
|
+
}
|
|
1224
|
+
registerDeleteItemsCommand(entityName, instance) {
|
|
1225
|
+
this.provider.registerEntityService(EntityServices.Commands.IEntitiesDeleteCommand, entityName, instance);
|
|
1226
|
+
}
|
|
1093
1227
|
// resolveMergeCommand<TEntity>(
|
|
1094
1228
|
// entityName: string
|
|
1095
1229
|
// ): IEntityMergeCommand<TEntity> {
|
|
@@ -1130,6 +1264,18 @@ class EntitiesServiceLocator {
|
|
|
1130
1264
|
registerGetAction(entityName, instance) {
|
|
1131
1265
|
this.provider.registerEntityService(EntityServices.Actions.IEntityGetAction, entityName, instance);
|
|
1132
1266
|
}
|
|
1267
|
+
resolveExistsAction(entityName) {
|
|
1268
|
+
return this.provider.resolveEntityService(EntityServices.Actions.IEntityExistsAction, entityName);
|
|
1269
|
+
}
|
|
1270
|
+
registerExistsAction(entityName, instance) {
|
|
1271
|
+
this.provider.registerEntityService(EntityServices.Actions.IEntityExistsAction, entityName, instance);
|
|
1272
|
+
}
|
|
1273
|
+
resolveCountAction(entityName) {
|
|
1274
|
+
return this.provider.resolveEntityService(EntityServices.Actions.IEntitiesCountAction, entityName);
|
|
1275
|
+
}
|
|
1276
|
+
registerCountAction(entityName, instance) {
|
|
1277
|
+
this.provider.registerEntityService(EntityServices.Actions.IEntitiesCountAction, entityName, instance);
|
|
1278
|
+
}
|
|
1133
1279
|
resolveSearchAction(entityName) {
|
|
1134
1280
|
return this.provider.resolveEntityService(EntityServices.Actions.IEntitiesSearchAction, entityName);
|
|
1135
1281
|
}
|
|
@@ -1160,6 +1306,12 @@ class EntitiesServiceLocator {
|
|
|
1160
1306
|
registerDeleteAction(entityName, instance) {
|
|
1161
1307
|
this.provider.registerEntityService(EntityServices.Actions.IEntityDeleteAction, entityName, instance);
|
|
1162
1308
|
}
|
|
1309
|
+
resolveDeleteItemsAction(entityName) {
|
|
1310
|
+
return this.provider.resolveEntityService(EntityServices.Actions.IEntitiesDeleteAction, entityName);
|
|
1311
|
+
}
|
|
1312
|
+
registerDeleteItemsAction(entityName, instance) {
|
|
1313
|
+
this.provider.registerEntityService(EntityServices.Actions.IEntitiesDeleteAction, entityName, instance);
|
|
1314
|
+
}
|
|
1163
1315
|
resolveQueryBuilder(entityName) {
|
|
1164
1316
|
return this.provider.resolveEntityService(EntityServices.Queries.IEntitiesQueryBuilder, entityName);
|
|
1165
1317
|
}
|
|
@@ -1168,12 +1320,74 @@ class EntitiesServiceLocator {
|
|
|
1168
1320
|
}
|
|
1169
1321
|
}
|
|
1170
1322
|
|
|
1323
|
+
class EntitiesCountQuery {
|
|
1324
|
+
constructor(services) {
|
|
1325
|
+
this.services = services;
|
|
1326
|
+
}
|
|
1327
|
+
async execute(filters) {
|
|
1328
|
+
const context = await this.getContext();
|
|
1329
|
+
await this.authorizeSearch(context);
|
|
1330
|
+
return await this.services
|
|
1331
|
+
.resolveQueryBuilder()
|
|
1332
|
+
.count(filters, context);
|
|
1333
|
+
}
|
|
1334
|
+
async getContext() {
|
|
1335
|
+
const authorization = this.services.resolveAuthorizationMiddleware();
|
|
1336
|
+
if (!authorization) {
|
|
1337
|
+
return undefined;
|
|
1338
|
+
}
|
|
1339
|
+
const contextService = this.services.resolveAuthenticationContextProvider();
|
|
1340
|
+
return await contextService.getContext();
|
|
1341
|
+
}
|
|
1342
|
+
async authorizeSearch(context) {
|
|
1343
|
+
const authorization = this.services.resolveAuthorizationMiddleware();
|
|
1344
|
+
if (!authorization) {
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
const { isAuthorized } = await authorization.canSearch(context);
|
|
1348
|
+
if (!isAuthorized) {
|
|
1349
|
+
throw new EntityOperationUnauthorizedException(exports.EntityOperationType.Search, this.services.getEntityName());
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
class EntityExistsQuery {
|
|
1355
|
+
constructor(services) {
|
|
1356
|
+
this.services = services;
|
|
1357
|
+
}
|
|
1358
|
+
async execute(filters) {
|
|
1359
|
+
const context = await this.getContext();
|
|
1360
|
+
await this.authorizeSearch(context);
|
|
1361
|
+
return await this.services
|
|
1362
|
+
.resolveQueryBuilder()
|
|
1363
|
+
.exists(filters, context);
|
|
1364
|
+
}
|
|
1365
|
+
async getContext() {
|
|
1366
|
+
const authorization = this.services.resolveAuthorizationMiddleware();
|
|
1367
|
+
if (!authorization) {
|
|
1368
|
+
return undefined;
|
|
1369
|
+
}
|
|
1370
|
+
const contextService = this.services.resolveAuthenticationContextProvider();
|
|
1371
|
+
return await contextService.getContext();
|
|
1372
|
+
}
|
|
1373
|
+
async authorizeSearch(context) {
|
|
1374
|
+
const authorization = this.services.resolveAuthorizationMiddleware();
|
|
1375
|
+
if (!authorization) {
|
|
1376
|
+
return;
|
|
1377
|
+
}
|
|
1378
|
+
const { isAuthorized } = await authorization.canSearch(context);
|
|
1379
|
+
if (!isAuthorized) {
|
|
1380
|
+
throw new EntityOperationUnauthorizedException(exports.EntityOperationType.Search, this.services.getEntityName());
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1171
1385
|
class EntityGetQuery {
|
|
1172
1386
|
constructor(services) {
|
|
1173
1387
|
this.services = services;
|
|
1174
1388
|
}
|
|
1175
1389
|
async execute(id) {
|
|
1176
|
-
|
|
1390
|
+
const entity = await this.services.resolveRepository().get(id);
|
|
1177
1391
|
if (entity) {
|
|
1178
1392
|
await this.authorize(entity);
|
|
1179
1393
|
}
|
|
@@ -1196,7 +1410,6 @@ class EntitiesSearchQuery {
|
|
|
1196
1410
|
constructor(services) {
|
|
1197
1411
|
this.services = services;
|
|
1198
1412
|
}
|
|
1199
|
-
// @ts-ignore
|
|
1200
1413
|
async execute(request) {
|
|
1201
1414
|
const context = await this.getContext();
|
|
1202
1415
|
await this.authorizeSearch(context);
|
|
@@ -1491,6 +1704,8 @@ class EntityManagerServiceCollection {
|
|
|
1491
1704
|
}
|
|
1492
1705
|
mapCrudOperations({ queryBuilder, }) {
|
|
1493
1706
|
this.mapGet();
|
|
1707
|
+
this.mapCount();
|
|
1708
|
+
this.mapExists();
|
|
1494
1709
|
this.mapSearch({
|
|
1495
1710
|
queryBuilder,
|
|
1496
1711
|
});
|
|
@@ -1504,6 +1719,16 @@ class EntityManagerServiceCollection {
|
|
|
1504
1719
|
this.locator.registerGetAction(this.entityName, new EntityGetAction(this.resolver));
|
|
1505
1720
|
return this;
|
|
1506
1721
|
}
|
|
1722
|
+
mapCount() {
|
|
1723
|
+
this.locator.registerCountQuery(this.entityName, new EntitiesCountQuery(this.resolver));
|
|
1724
|
+
this.locator.registerCountAction(this.entityName, new EntitiesCountAction(this.resolver));
|
|
1725
|
+
return this;
|
|
1726
|
+
}
|
|
1727
|
+
mapExists() {
|
|
1728
|
+
this.locator.registerExistsQuery(this.entityName, new EntityExistsQuery(this.resolver));
|
|
1729
|
+
this.locator.registerExistsAction(this.entityName, new EntityExistsAction(this.resolver));
|
|
1730
|
+
return this;
|
|
1731
|
+
}
|
|
1507
1732
|
mapSearch({ queryBuilder, }) {
|
|
1508
1733
|
this.locator.registerSearchQuery(this.entityName, new EntitiesSearchQuery(this.resolver));
|
|
1509
1734
|
this.locator.registerSearchAction(this.entityName, new EntitiesSearchAction(this.resolver));
|
|
@@ -1533,6 +1758,8 @@ class EntityManagerServiceCollection {
|
|
|
1533
1758
|
mapDelete() {
|
|
1534
1759
|
this.locator.registerDeleteCommand(this.entityName, new EntityDeleteCommand(this.resolver));
|
|
1535
1760
|
this.locator.registerDeleteAction(this.entityName, new EntityDeleteAction(this.resolver));
|
|
1761
|
+
this.locator.registerDeleteItemsCommand(this.entityName, new EntitiesDeleteCommand(this.resolver));
|
|
1762
|
+
this.locator.registerDeleteAction(this.entityName, new EntitiesDeleteAction(this.resolver));
|
|
1536
1763
|
return this;
|
|
1537
1764
|
}
|
|
1538
1765
|
addAdapter(adapter) {
|
|
@@ -19779,6 +20006,209 @@ const orderByPriority = (items, priorityFieldSelector, nameFieldSelector) => {
|
|
|
19779
20006
|
return backendCore.sort(items, backendCore.byField((x) => priorityFieldSelector(x) ?? Number.MAX_VALUE), backendCore.byField((x) => nameFieldSelector(x)));
|
|
19780
20007
|
};
|
|
19781
20008
|
|
|
20009
|
+
exports.PipelineStatus = void 0;
|
|
20010
|
+
(function (PipelineStatus) {
|
|
20011
|
+
PipelineStatus["Initializing"] = "initializing";
|
|
20012
|
+
PipelineStatus["Running"] = "running";
|
|
20013
|
+
PipelineStatus["RollbackInProgress"] = "rollbackInProgress";
|
|
20014
|
+
PipelineStatus["Completed"] = "completed";
|
|
20015
|
+
PipelineStatus["Failed"] = "failed";
|
|
20016
|
+
})(exports.PipelineStatus || (exports.PipelineStatus = {}));
|
|
20017
|
+
|
|
20018
|
+
const toPipelineOperationError = (error) => ({
|
|
20019
|
+
message: error.message,
|
|
20020
|
+
exception: error,
|
|
20021
|
+
});
|
|
20022
|
+
const getStepOutput = (result) => {
|
|
20023
|
+
return result.type === "success" ? result.output : undefined;
|
|
20024
|
+
};
|
|
20025
|
+
const getOperationOutput = (result) => {
|
|
20026
|
+
return result.type === "success" ? result.output : undefined;
|
|
20027
|
+
};
|
|
20028
|
+
|
|
20029
|
+
class PipelineInstance {
|
|
20030
|
+
constructor(definition, input, context) {
|
|
20031
|
+
this.definition = definition;
|
|
20032
|
+
this.input = input;
|
|
20033
|
+
this.context = context;
|
|
20034
|
+
this.status = exports.PipelineStatus.Initializing;
|
|
20035
|
+
}
|
|
20036
|
+
async execute() {
|
|
20037
|
+
this.status = exports.PipelineStatus.Running;
|
|
20038
|
+
const executedSteps = [];
|
|
20039
|
+
const stepResults = [];
|
|
20040
|
+
let state = this.buildInitialStepState();
|
|
20041
|
+
for (const [i, step] of this.definition.steps.entries()) {
|
|
20042
|
+
executedSteps.push(step);
|
|
20043
|
+
const stepResult = await this.executeStep(step, i > 0 ? getStepOutput(stepResults[i - 1]) : this.input, state);
|
|
20044
|
+
stepResults.push(stepResult);
|
|
20045
|
+
state = this.buildNextStepState(state, stepResult);
|
|
20046
|
+
if (stepResult.type !== "success") {
|
|
20047
|
+
this.status = exports.PipelineStatus.RollbackInProgress;
|
|
20048
|
+
await this.rollbackSteps(executedSteps, stepResults, state);
|
|
20049
|
+
return {
|
|
20050
|
+
type: "error",
|
|
20051
|
+
input: this.input,
|
|
20052
|
+
stepResults,
|
|
20053
|
+
};
|
|
20054
|
+
}
|
|
20055
|
+
}
|
|
20056
|
+
this.status = exports.PipelineStatus.Completed;
|
|
20057
|
+
return {
|
|
20058
|
+
type: "success",
|
|
20059
|
+
input: this.input,
|
|
20060
|
+
output: getStepOutput(stepResults[stepResults.length - 1]),
|
|
20061
|
+
stepResults,
|
|
20062
|
+
};
|
|
20063
|
+
}
|
|
20064
|
+
buildInitialStepState() {
|
|
20065
|
+
return {
|
|
20066
|
+
stepInput: this.input,
|
|
20067
|
+
context: this.context,
|
|
20068
|
+
pipelineInput: this.input,
|
|
20069
|
+
};
|
|
20070
|
+
}
|
|
20071
|
+
buildNextStepState(state, stepResult) {
|
|
20072
|
+
return {
|
|
20073
|
+
stepInput: getStepOutput(stepResult),
|
|
20074
|
+
context: this.context,
|
|
20075
|
+
pipelineInput: this.input,
|
|
20076
|
+
previousStep: {
|
|
20077
|
+
stepInput: state.stepInput,
|
|
20078
|
+
stepOutput: getStepOutput(stepResult),
|
|
20079
|
+
context: this.context,
|
|
20080
|
+
pipelineInput: this.input,
|
|
20081
|
+
previousStep: state.previousStep,
|
|
20082
|
+
},
|
|
20083
|
+
};
|
|
20084
|
+
}
|
|
20085
|
+
async rollbackSteps(executedSteps, stepsResults, state) {
|
|
20086
|
+
const rollbackSteps = executedSteps
|
|
20087
|
+
.map((x, i) => ({
|
|
20088
|
+
step: x,
|
|
20089
|
+
result: stepsResults[i],
|
|
20090
|
+
}))
|
|
20091
|
+
.reverse();
|
|
20092
|
+
let rollbackState = state;
|
|
20093
|
+
for (const step of rollbackSteps) {
|
|
20094
|
+
await this.rollbackStep(step.step, step.result, rollbackState);
|
|
20095
|
+
rollbackState = state.previousStep;
|
|
20096
|
+
}
|
|
20097
|
+
}
|
|
20098
|
+
async rollbackStep(step, stepResults, state) {
|
|
20099
|
+
const completedOperations = stepResults.operationResults.map((x, i) => ({
|
|
20100
|
+
result: x,
|
|
20101
|
+
operation: step.operations[i],
|
|
20102
|
+
}));
|
|
20103
|
+
// .filter((x) => x.result.type === "success")
|
|
20104
|
+
const rollbackOperations = completedOperations.map((x) => this.rollbackOperations(x.operation, x.result.input, getOperationOutput(x.result), state));
|
|
20105
|
+
const rollbackResults = await Promise.all(rollbackOperations);
|
|
20106
|
+
const isRollbackError = rollbackResults.some((x) => x.type === "error");
|
|
20107
|
+
if (isRollbackError) {
|
|
20108
|
+
return {
|
|
20109
|
+
type: "error",
|
|
20110
|
+
};
|
|
20111
|
+
}
|
|
20112
|
+
return {
|
|
20113
|
+
type: "success",
|
|
20114
|
+
};
|
|
20115
|
+
}
|
|
20116
|
+
async validateStepPrecondition(step, input, state) {
|
|
20117
|
+
const preconditionOperations = step.operations
|
|
20118
|
+
.filter((x) => x.operation.precondition)
|
|
20119
|
+
.map((x) => x.operation.precondition(input, state));
|
|
20120
|
+
const preconditionResults = await Promise.all(preconditionOperations);
|
|
20121
|
+
return {
|
|
20122
|
+
hasValidPrecondition: preconditionResults.every((x) => x),
|
|
20123
|
+
};
|
|
20124
|
+
}
|
|
20125
|
+
async executeStep(step, input, state) {
|
|
20126
|
+
const preconditionResult = await this.validateStepPrecondition(step, input, state);
|
|
20127
|
+
if (!preconditionResult.hasValidPrecondition) {
|
|
20128
|
+
return {
|
|
20129
|
+
operationResults: [],
|
|
20130
|
+
type: "preconditionFailed",
|
|
20131
|
+
input,
|
|
20132
|
+
};
|
|
20133
|
+
}
|
|
20134
|
+
const stepOperations = step.operations.map((x) => this.executeOperation(x, input, state));
|
|
20135
|
+
const operationResults = await Promise.all(stepOperations);
|
|
20136
|
+
const isSuccess = operationResults.every((x) => x.type === "success");
|
|
20137
|
+
if (isSuccess) {
|
|
20138
|
+
const output = step.outputsReducer
|
|
20139
|
+
? step.outputsReducer(operationResults.map((x) => getOperationOutput(x)))
|
|
20140
|
+
: operationResults.map((x) => getOperationOutput(x));
|
|
20141
|
+
return {
|
|
20142
|
+
type: "success",
|
|
20143
|
+
operationResults,
|
|
20144
|
+
input,
|
|
20145
|
+
output: output,
|
|
20146
|
+
};
|
|
20147
|
+
}
|
|
20148
|
+
return {
|
|
20149
|
+
type: "error",
|
|
20150
|
+
operationResults,
|
|
20151
|
+
input,
|
|
20152
|
+
};
|
|
20153
|
+
}
|
|
20154
|
+
async executeOperation(operation, input, state) {
|
|
20155
|
+
try {
|
|
20156
|
+
const operationResult = await operation.operation.action(input, state);
|
|
20157
|
+
return {
|
|
20158
|
+
type: "success",
|
|
20159
|
+
input,
|
|
20160
|
+
output: operationResult,
|
|
20161
|
+
};
|
|
20162
|
+
}
|
|
20163
|
+
catch (error) {
|
|
20164
|
+
return {
|
|
20165
|
+
type: "error",
|
|
20166
|
+
input,
|
|
20167
|
+
error: toPipelineOperationError(error),
|
|
20168
|
+
};
|
|
20169
|
+
}
|
|
20170
|
+
}
|
|
20171
|
+
async rollbackOperations(operation, operationInput, operationOutput, state) {
|
|
20172
|
+
if (!operation.rollbackOperations?.length) {
|
|
20173
|
+
return {
|
|
20174
|
+
type: "skipped",
|
|
20175
|
+
};
|
|
20176
|
+
}
|
|
20177
|
+
for (const rollbackOperation of operation.rollbackOperations) {
|
|
20178
|
+
const rollbackResult = await this.rollbackOperation(rollbackOperation, operationInput, operationOutput, state);
|
|
20179
|
+
if (rollbackResult.type === "error") {
|
|
20180
|
+
return {
|
|
20181
|
+
type: "error",
|
|
20182
|
+
error: rollbackResult.error,
|
|
20183
|
+
};
|
|
20184
|
+
}
|
|
20185
|
+
}
|
|
20186
|
+
return {
|
|
20187
|
+
type: "success",
|
|
20188
|
+
};
|
|
20189
|
+
}
|
|
20190
|
+
async rollbackOperation(rollbackOperation, operationInput, operationOutput, state) {
|
|
20191
|
+
try {
|
|
20192
|
+
await rollbackOperation.action(operationInput, operationOutput, state);
|
|
20193
|
+
return {
|
|
20194
|
+
type: "success",
|
|
20195
|
+
};
|
|
20196
|
+
}
|
|
20197
|
+
catch (error) {
|
|
20198
|
+
return {
|
|
20199
|
+
type: "error",
|
|
20200
|
+
error: toPipelineOperationError(error),
|
|
20201
|
+
};
|
|
20202
|
+
}
|
|
20203
|
+
}
|
|
20204
|
+
}
|
|
20205
|
+
|
|
20206
|
+
class PipelineController {
|
|
20207
|
+
async createInstance(definition, input, context) {
|
|
20208
|
+
return new PipelineInstance(definition, input, context);
|
|
20209
|
+
}
|
|
20210
|
+
}
|
|
20211
|
+
|
|
19782
20212
|
var EntityManagerInitializer_1;
|
|
19783
20213
|
exports.EntityManagerInitializer = EntityManagerInitializer_1 = class EntityManagerInitializer {
|
|
19784
20214
|
constructor(discover, registry, eventEmitter) {
|
|
@@ -19800,6 +20230,7 @@ exports.EntityManagerInitializer = EntityManagerInitializer_1 = class EntityMana
|
|
|
19800
20230
|
await this.registerAuthentication(staticProviders.authenticationProvider);
|
|
19801
20231
|
this.logger.log("Entity manager authentication initialized 🔑");
|
|
19802
20232
|
}
|
|
20233
|
+
await this.registerPipelinesServices();
|
|
19803
20234
|
await this.registerEmailTemplates();
|
|
19804
20235
|
await this.registerEmailProviders();
|
|
19805
20236
|
await this.registerEventTrackingProviders();
|
|
@@ -19904,6 +20335,12 @@ exports.EntityManagerInitializer = EntityManagerInitializer_1 = class EntityMana
|
|
|
19904
20335
|
.getEntitiesServicesLocator()
|
|
19905
20336
|
.registerEmailTemplatesCollection(collection);
|
|
19906
20337
|
}
|
|
20338
|
+
async registerPipelinesServices() {
|
|
20339
|
+
this.registry
|
|
20340
|
+
.getContainer()
|
|
20341
|
+
.getEntitiesServicesLocator()
|
|
20342
|
+
.registerPipelinesController(new PipelineController());
|
|
20343
|
+
}
|
|
19907
20344
|
async initializeProviders(app, staticProviders) {
|
|
19908
20345
|
app
|
|
19909
20346
|
.get(exports.ModulesContainerProvider)
|
|
@@ -19951,12 +20388,127 @@ const Processors = [exports.EntityManagerInitializer];
|
|
|
19951
20388
|
|
|
19952
20389
|
const Providers = [NestEventEmitter];
|
|
19953
20390
|
|
|
20391
|
+
class PipelineStepOperationOptionsBuilder {
|
|
20392
|
+
constructor(operation) {
|
|
20393
|
+
this.operation = operation;
|
|
20394
|
+
this.rollbackOperations = [];
|
|
20395
|
+
}
|
|
20396
|
+
withRollback(definition) {
|
|
20397
|
+
this.rollbackOperations.push(definition);
|
|
20398
|
+
return this;
|
|
20399
|
+
}
|
|
20400
|
+
build() {
|
|
20401
|
+
return {
|
|
20402
|
+
name: this.operation.name,
|
|
20403
|
+
operation: this.operation,
|
|
20404
|
+
rollbackOperations: this.rollbackOperations,
|
|
20405
|
+
};
|
|
20406
|
+
}
|
|
20407
|
+
}
|
|
20408
|
+
class PipelineStepOperationsBuilder {
|
|
20409
|
+
constructor() {
|
|
20410
|
+
this.operationBuilders = [];
|
|
20411
|
+
}
|
|
20412
|
+
addOperation(operation) {
|
|
20413
|
+
const operationBuilder = new PipelineStepOperationOptionsBuilder(operation);
|
|
20414
|
+
this.operationBuilders.push(operationBuilder);
|
|
20415
|
+
return operationBuilder;
|
|
20416
|
+
}
|
|
20417
|
+
buildOperations() {
|
|
20418
|
+
return this.operationBuilders.map((builder) => builder.build());
|
|
20419
|
+
}
|
|
20420
|
+
}
|
|
20421
|
+
class PipelineStepBuilder {
|
|
20422
|
+
constructor(previousSteps, currentStepOperationsBuilder) {
|
|
20423
|
+
this.previousSteps = previousSteps;
|
|
20424
|
+
this.currentStep = this.buildCurrentStep(currentStepOperationsBuilder);
|
|
20425
|
+
}
|
|
20426
|
+
addStep(builder) {
|
|
20427
|
+
return new PipelineStepBuilder(this.currentSteps, builder);
|
|
20428
|
+
}
|
|
20429
|
+
buildCurrentStep(currentStepOperationsBuilder) {
|
|
20430
|
+
const operationsBuilder = new PipelineStepOperationsBuilder();
|
|
20431
|
+
currentStepOperationsBuilder(operationsBuilder);
|
|
20432
|
+
return {
|
|
20433
|
+
name: `Step ${this.previousSteps.length + 1}`,
|
|
20434
|
+
operations: operationsBuilder.buildOperations(),
|
|
20435
|
+
// TODO: add support for multiple operation outputs
|
|
20436
|
+
outputsReducer: (outputs) => {
|
|
20437
|
+
if (outputs.length === 0) {
|
|
20438
|
+
throw new Error("Empty pipeline step found");
|
|
20439
|
+
}
|
|
20440
|
+
if (outputs.length !== 1) {
|
|
20441
|
+
throw new Error("Multiple outputs are not supported yet");
|
|
20442
|
+
}
|
|
20443
|
+
return outputs[0];
|
|
20444
|
+
},
|
|
20445
|
+
};
|
|
20446
|
+
}
|
|
20447
|
+
build() {
|
|
20448
|
+
return {
|
|
20449
|
+
steps: this.currentSteps,
|
|
20450
|
+
};
|
|
20451
|
+
}
|
|
20452
|
+
get currentSteps() {
|
|
20453
|
+
return [
|
|
20454
|
+
...this.previousSteps,
|
|
20455
|
+
this.currentStep,
|
|
20456
|
+
];
|
|
20457
|
+
}
|
|
20458
|
+
}
|
|
20459
|
+
class PipelineTemplateBuilder {
|
|
20460
|
+
addStep(builder) {
|
|
20461
|
+
return new PipelineStepBuilder([], builder);
|
|
20462
|
+
}
|
|
20463
|
+
}
|
|
20464
|
+
|
|
20465
|
+
exports.PipelinesBuilder = class PipelinesBuilder {
|
|
20466
|
+
constructor(registry) {
|
|
20467
|
+
this.registry = registry;
|
|
20468
|
+
}
|
|
20469
|
+
createTemplate() {
|
|
20470
|
+
return new PipelineTemplateBuilder();
|
|
20471
|
+
}
|
|
20472
|
+
};
|
|
20473
|
+
exports.PipelinesBuilder = __decorate([
|
|
20474
|
+
common.Injectable(),
|
|
20475
|
+
__metadata("design:paramtypes", [exports.EntityManagerRegistry])
|
|
20476
|
+
], exports.PipelinesBuilder);
|
|
20477
|
+
|
|
20478
|
+
exports.PipelinesRunner = class PipelinesRunner {
|
|
20479
|
+
constructor(registry) {
|
|
20480
|
+
this.registry = registry;
|
|
20481
|
+
}
|
|
20482
|
+
async invokePipeline(definition, data) {
|
|
20483
|
+
const instance = await this.controller.createInstance(definition, data.input, data.context);
|
|
20484
|
+
return await instance.execute();
|
|
20485
|
+
}
|
|
20486
|
+
get controller() {
|
|
20487
|
+
return this.registry
|
|
20488
|
+
.getContainer()
|
|
20489
|
+
.getEntitiesServicesLocator()
|
|
20490
|
+
.resolvePipelinesController();
|
|
20491
|
+
}
|
|
20492
|
+
};
|
|
20493
|
+
exports.PipelinesRunner = __decorate([
|
|
20494
|
+
common.Injectable(),
|
|
20495
|
+
__metadata("design:paramtypes", [exports.EntityManagerRegistry])
|
|
20496
|
+
], exports.PipelinesRunner);
|
|
20497
|
+
|
|
20498
|
+
const PipelineProviders = [exports.PipelinesBuilder, exports.PipelinesRunner];
|
|
20499
|
+
|
|
19954
20500
|
exports.EntityManagerModule = class EntityManagerModule {
|
|
19955
20501
|
};
|
|
19956
20502
|
exports.EntityManagerModule = __decorate([
|
|
19957
20503
|
common.Module({
|
|
19958
20504
|
imports: [CustomDiscoveryModule, eventEmitter.EventEmitterModule],
|
|
19959
|
-
providers: [
|
|
20505
|
+
providers: [
|
|
20506
|
+
...IoC,
|
|
20507
|
+
...Providers,
|
|
20508
|
+
...Processors,
|
|
20509
|
+
...Services$1,
|
|
20510
|
+
...PipelineProviders,
|
|
20511
|
+
],
|
|
19960
20512
|
exports: [exports.EntityManagerRegistry, ...Services$1],
|
|
19961
20513
|
})
|
|
19962
20514
|
], exports.EntityManagerModule);
|
|
@@ -20203,6 +20755,24 @@ class TypeOrmQueryBuilder extends QueryBuilderBase {
|
|
|
20203
20755
|
super();
|
|
20204
20756
|
this.services = services;
|
|
20205
20757
|
}
|
|
20758
|
+
async exists(filters, context) {
|
|
20759
|
+
return (await this.count(filters, context)) > 0;
|
|
20760
|
+
}
|
|
20761
|
+
async count(filters, context) {
|
|
20762
|
+
const request = {
|
|
20763
|
+
filters,
|
|
20764
|
+
};
|
|
20765
|
+
return await this.countQueryResults(request, context);
|
|
20766
|
+
}
|
|
20767
|
+
async delete(filters, context) {
|
|
20768
|
+
const request = {
|
|
20769
|
+
filters,
|
|
20770
|
+
};
|
|
20771
|
+
return await this.getRepository().deleteBy({
|
|
20772
|
+
...(context ? this.buildContextFilter(context) : {}),
|
|
20773
|
+
...this.buildWhereClause(request),
|
|
20774
|
+
});
|
|
20775
|
+
}
|
|
20206
20776
|
async search(request, context) {
|
|
20207
20777
|
// todo: execute inside read transaction in order to perform the three queries on the same dataset
|
|
20208
20778
|
const queryResults = await this.countQueryResults(request, context);
|
|
@@ -20320,7 +20890,10 @@ class TypeOrmRepository {
|
|
|
20320
20890
|
});
|
|
20321
20891
|
}
|
|
20322
20892
|
async deleteBy(condition) {
|
|
20323
|
-
await this.innerRepository.delete(condition);
|
|
20893
|
+
const result = await this.innerRepository.delete(condition);
|
|
20894
|
+
return {
|
|
20895
|
+
deletedCount: result.affected,
|
|
20896
|
+
};
|
|
20324
20897
|
}
|
|
20325
20898
|
async create(entity) {
|
|
20326
20899
|
const createResult = await this.innerRepository.insert(entity);
|
|
@@ -20403,19 +20976,18 @@ class NestTypeOrmEntitySeeder extends TypeOrmEntitySeeder {
|
|
|
20403
20976
|
|
|
20404
20977
|
class AppExceptionsFilterBase {
|
|
20405
20978
|
catch(exception, host) {
|
|
20406
|
-
if (exception instanceof common.HttpException) {
|
|
20407
|
-
return;
|
|
20408
|
-
}
|
|
20409
20979
|
const ctx = host.switchToHttp();
|
|
20410
20980
|
const response = ctx.getResponse();
|
|
20411
20981
|
const request = ctx.getRequest();
|
|
20412
|
-
|
|
20413
|
-
|
|
20414
|
-
|
|
20415
|
-
|
|
20416
|
-
|
|
20417
|
-
|
|
20418
|
-
|
|
20982
|
+
if (!(exception instanceof common.HttpException)) {
|
|
20983
|
+
this.logError({
|
|
20984
|
+
exception,
|
|
20985
|
+
request,
|
|
20986
|
+
response,
|
|
20987
|
+
}).catch((error) => {
|
|
20988
|
+
backendCore.Log.getLogger("AllExceptionsFilter").error("Error logging failed", error);
|
|
20989
|
+
});
|
|
20990
|
+
}
|
|
20419
20991
|
const status = this.getErrorStatusCode(exception);
|
|
20420
20992
|
response.status(status).json({
|
|
20421
20993
|
statusCode: status,
|
|
@@ -25686,6 +26258,7 @@ exports.NumericFacet = NumericFacet;
|
|
|
25686
26258
|
exports.NumericFacetItem = NumericFacetItem;
|
|
25687
26259
|
exports.OperationTokenMismatchError = OperationTokenMismatchError;
|
|
25688
26260
|
exports.PLATFORM_EVENT_NAMESPACE = PLATFORM_EVENT_NAMESPACE;
|
|
26261
|
+
exports.PipelineController = PipelineController;
|
|
25689
26262
|
exports.PlatformEvents = PlatformEvents;
|
|
25690
26263
|
exports.Public = Public;
|
|
25691
26264
|
exports.QueryBuilderBase = QueryBuilderBase;
|
|
@@ -25707,6 +26280,7 @@ exports.WpEntityQueryBuilder = WpEntityQueryBuilder;
|
|
|
25707
26280
|
exports.WpEntityRepository = WpEntityRepository;
|
|
25708
26281
|
exports.WpEntitySeeder = WpEntitySeeder;
|
|
25709
26282
|
exports.WpEventsTracker = WpEventsTracker;
|
|
26283
|
+
exports.WpPipeline = WpPipeline;
|
|
25710
26284
|
exports.WpRolesService = WpRolesService;
|
|
25711
26285
|
exports.WpSendgridEmailTemplate = WpSendgridEmailTemplate;
|
|
25712
26286
|
exports.WpUserRolesService = WpUserRolesService;
|