aws-service-stack 0.18.419 → 0.18.421
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/_examples/controller/profile/profile.config.js +1 -1
- package/dist/_examples/controller/profile/profile.config.js.map +1 -1
- package/dist/_examples/controller/profile/profile.controller.d.ts +1 -1
- package/dist/_examples/controller/profile/profile.controller.js +1 -0
- package/dist/_examples/controller/profile/profile.controller.js.map +1 -1
- package/dist/_examples/model-shared/example.model.d.ts +0 -12
- package/dist/_examples/model-shared/example.model.js.map +1 -1
- package/dist/controller/base-controller.js +5 -2
- package/dist/controller/base-controller.js.map +1 -1
- package/dist/controller/controller-api.d.ts +2 -2
- package/dist/controller/controller-api.js +10 -12
- package/dist/controller/controller-api.js.map +1 -1
- package/dist/controller/controller-request.d.ts +2 -2
- package/dist/controller/controller-request.js +7 -7
- package/dist/controller/controller-request.js.map +1 -1
- package/dist/exception/errors.d.ts +5 -5
- package/dist/exception/errors.js +9 -5
- package/dist/exception/errors.js.map +1 -1
- package/dist/exception/exception-handler.d.ts +62 -60
- package/dist/exception/exception-handler.js +87 -98
- package/dist/exception/exception-handler.js.map +1 -1
- package/dist/service/crud.service.d.ts +7 -0
- package/dist/service/crud.service.interface.d.ts +15 -0
- package/dist/service/crud.service.interface.js.map +1 -1
- package/dist/service/crud.service.js +34 -0
- package/dist/service/crud.service.js.map +1 -1
- package/package.json +6 -6
- package/dist/_examples/controller/branch/branch-config.d.ts +0 -6
- package/dist/_examples/controller/branch/branch-config.js +0 -47
- package/dist/_examples/controller/branch/branch-config.js.map +0 -1
- package/dist/_examples/controller/branch/branch-controller.d.ts +0 -16
- package/dist/_examples/controller/branch/branch-controller.js +0 -77
- package/dist/_examples/controller/branch/branch-controller.js.map +0 -1
- package/dist/_examples/controller/branch/branch-crud.d.ts +0 -4
- package/dist/_examples/controller/branch/branch-crud.js +0 -57
- package/dist/_examples/controller/branch/branch-crud.js.map +0 -1
- package/dist/_examples/controller/commission/commission-controller.d.ts +0 -9
- package/dist/_examples/controller/commission/commission-controller.js +0 -66
- package/dist/_examples/controller/commission/commission-controller.js.map +0 -1
- package/dist/_examples/controller/commission/commission-crud.d.ts +0 -4
- package/dist/_examples/controller/commission/commission-crud.js +0 -57
- package/dist/_examples/controller/commission/commission-crud.js.map +0 -1
- package/dist/_examples/controller/commission/commission.config.d.ts +0 -6
- package/dist/_examples/controller/commission/commission.config.js +0 -46
- package/dist/_examples/controller/commission/commission.config.js.map +0 -1
- package/dist/_examples/controller/e-order/e-order-crud-simple.d.ts +0 -2
- package/dist/_examples/controller/e-order/e-order-crud-simple.js +0 -294
- package/dist/_examples/controller/e-order/e-order-crud-simple.js.map +0 -1
- package/dist/_examples/controller/e-order/e-order-crud.d.ts +0 -4
- package/dist/_examples/controller/e-order/e-order-crud.js +0 -58
- package/dist/_examples/controller/e-order/e-order-crud.js.map +0 -1
- package/dist/_examples/controller/e-order/e-order.config.d.ts +0 -10
- package/dist/_examples/controller/e-order/e-order.config.js +0 -53
- package/dist/_examples/controller/e-order/e-order.config.js.map +0 -1
- package/dist/_examples/controller/e-order/e-order.controller.d.ts +0 -13
- package/dist/_examples/controller/e-order/e-order.controller.js +0 -68
- package/dist/_examples/controller/e-order/e-order.controller.js.map +0 -1
- package/dist/_examples/controller/entity/entity-config.d.ts +0 -10
- package/dist/_examples/controller/entity/entity-config.js +0 -49
- package/dist/_examples/controller/entity/entity-config.js.map +0 -1
- package/dist/_examples/controller/entity/entity-controller.d.ts +0 -13
- package/dist/_examples/controller/entity/entity-controller.js +0 -74
- package/dist/_examples/controller/entity/entity-controller.js.map +0 -1
- package/dist/_examples/controller/entity/entity-crud.d.ts +0 -4
- package/dist/_examples/controller/entity/entity-crud.js +0 -60
- package/dist/_examples/controller/entity/entity-crud.js.map +0 -1
- package/dist/_examples/controller/index.d.ts +0 -3
- package/dist/_examples/controller/index.js +0 -74
- package/dist/_examples/controller/index.js.map +0 -1
- package/dist/_examples/controller/local-task-controller.d.ts +0 -2
- package/dist/_examples/controller/local-task-controller.js +0 -23
- package/dist/_examples/controller/local-task-controller.js.map +0 -1
- package/dist/_examples/controller/product/product.config.d.ts +0 -12
- package/dist/_examples/controller/product/product.config.js +0 -33
- package/dist/_examples/controller/product/product.config.js.map +0 -1
- package/dist/_examples/controller/properties/properties-crud.d.ts +0 -4
- package/dist/_examples/controller/properties/properties-crud.js +0 -58
- package/dist/_examples/controller/properties/properties-crud.js.map +0 -1
- package/dist/_examples/controller/properties/property.config.d.ts +0 -10
- package/dist/_examples/controller/properties/property.config.js +0 -51
- package/dist/_examples/controller/properties/property.config.js.map +0 -1
- package/dist/_examples/controller/properties/property.controller.d.ts +0 -13
- package/dist/_examples/controller/properties/property.controller.js +0 -68
- package/dist/_examples/controller/properties/property.controller.js.map +0 -1
- package/dist/_examples/controller/raccount/raccount-config.d.ts +0 -6
- package/dist/_examples/controller/raccount/raccount-config.js +0 -60
- package/dist/_examples/controller/raccount/raccount-config.js.map +0 -1
- package/dist/_examples/controller/raccount/raccount-controller.d.ts +0 -14
- package/dist/_examples/controller/raccount/raccount-controller.js +0 -73
- package/dist/_examples/controller/raccount/raccount-controller.js.map +0 -1
- package/dist/_examples/controller/raccount/raccount-crud.d.ts +0 -4
- package/dist/_examples/controller/raccount/raccount-crud.js +0 -57
- package/dist/_examples/controller/raccount/raccount-crud.js.map +0 -1
- package/dist/_examples/controller/rorder/order-config.d.ts +0 -6
- package/dist/_examples/controller/rorder/order-config.js +0 -48
- package/dist/_examples/controller/rorder/order-config.js.map +0 -1
- package/dist/_examples/controller/rorder/order-controller.d.ts +0 -9
- package/dist/_examples/controller/rorder/order-controller.js +0 -66
- package/dist/_examples/controller/rorder/order-controller.js.map +0 -1
- package/dist/_examples/controller/rorder/order-crud.d.ts +0 -4
- package/dist/_examples/controller/rorder/order-crud.js +0 -57
- package/dist/_examples/controller/rorder/order-crud.js.map +0 -1
- package/dist/_examples/controller/supplier/supplier-config.d.ts +0 -10
- package/dist/_examples/controller/supplier/supplier-config.js +0 -70
- package/dist/_examples/controller/supplier/supplier-config.js.map +0 -1
- package/dist/_examples/controller/supplier/supplier-controller-api.d.ts +0 -9
- package/dist/_examples/controller/supplier/supplier-controller-api.js +0 -69
- package/dist/_examples/controller/supplier/supplier-controller-api.js.map +0 -1
- package/dist/_examples/controller/supplier/supplier-controller-stream.d.ts +0 -12
- package/dist/_examples/controller/supplier/supplier-controller-stream.js +0 -67
- package/dist/_examples/controller/supplier/supplier-controller-stream.js.map +0 -1
- package/dist/_examples/controller/supplier/supplier-crud.d.ts +0 -4
- package/dist/_examples/controller/supplier/supplier-crud.js +0 -60
- package/dist/_examples/controller/supplier/supplier-crud.js.map +0 -1
- package/dist/_examples/controller/supplier/supplier-streamer.d.ts +0 -4
- package/dist/_examples/controller/supplier/supplier-streamer.js +0 -58
- package/dist/_examples/controller/supplier/supplier-streamer.js.map +0 -1
- package/dist/_examples/controller/user/user.config.d.ts +0 -12
- package/dist/_examples/controller/user/user.config.js +0 -30
- package/dist/_examples/controller/user/user.config.js.map +0 -1
- package/dist/_examples/controller/user.controller.d.ts +0 -15
- package/dist/_examples/controller/user.controller.js +0 -30
- package/dist/_examples/controller/user.controller.js.map +0 -1
- package/dist/_examples/controller/users/users-crud.d.ts +0 -4
- package/dist/_examples/controller/users/users-crud.js +0 -58
- package/dist/_examples/controller/users/users-crud.js.map +0 -1
- package/dist/_examples/controller/users/users.config.d.ts +0 -10
- package/dist/_examples/controller/users/users.config.js +0 -51
- package/dist/_examples/controller/users/users.config.js.map +0 -1
- package/dist/_examples/controller/users/users.controller.d.ts +0 -13
- package/dist/_examples/controller/users/users.controller.js +0 -68
- package/dist/_examples/controller/users/users.controller.js.map +0 -1
- package/dist/_examples/model/user.model.d.ts +0 -1
- package/dist/_examples/model/user.model.js +0 -3
- package/dist/_examples/model/user.model.js.map +0 -1
- package/dist/_examples/model-shared/address.model.d.ts +0 -18
- package/dist/_examples/model-shared/address.model.js +0 -3
- package/dist/_examples/model-shared/address.model.js.map +0 -1
- package/dist/_examples/model-shared/branch.model.d.ts +0 -72
- package/dist/_examples/model-shared/branch.model.js +0 -64
- package/dist/_examples/model-shared/branch.model.js.map +0 -1
- package/dist/_examples/model-shared/commission.model.d.ts +0 -30
- package/dist/_examples/model-shared/commission.model.js +0 -38
- package/dist/_examples/model-shared/commission.model.js.map +0 -1
- package/dist/_examples/model-shared/raccount.model.d.ts +0 -134
- package/dist/_examples/model-shared/raccount.model.js +0 -187
- package/dist/_examples/model-shared/raccount.model.js.map +0 -1
- package/dist/_examples/model-shared/suppler.model-to-remove.d.ts +0 -119
- package/dist/_examples/model-shared/suppler.model-to-remove.js +0 -103
- package/dist/_examples/model-shared/suppler.model-to-remove.js.map +0 -1
- package/dist/_examples/model-shared/supplier-portal.model.d.ts +0 -22862
- package/dist/_examples/model-shared/supplier-portal.model.js +0 -1035
- package/dist/_examples/model-shared/supplier-portal.model.js.map +0 -1
- package/dist/_examples/model-shared/supplier.model.d.ts +0 -77
- package/dist/_examples/model-shared/supplier.model.js +0 -124
- package/dist/_examples/model-shared/supplier.model.js.map +0 -1
- package/dist/_examples/repositories/branch/branch-db.repo.d.ts +0 -6
- package/dist/_examples/repositories/branch/branch-db.repo.interface.d.ts +0 -4
- package/dist/_examples/repositories/branch/branch-db.repo.interface.js +0 -3
- package/dist/_examples/repositories/branch/branch-db.repo.interface.js.map +0 -1
- package/dist/_examples/repositories/branch/branch-db.repo.js +0 -19
- package/dist/_examples/repositories/branch/branch-db.repo.js.map +0 -1
- package/dist/_examples/repositories/commission/commission-repo-db.d.ts +0 -5
- package/dist/_examples/repositories/commission/commission-repo-db.interface.d.ts +0 -4
- package/dist/_examples/repositories/commission/commission-repo-db.interface.js +0 -3
- package/dist/_examples/repositories/commission/commission-repo-db.interface.js.map +0 -1
- package/dist/_examples/repositories/commission/commission-repo-db.js +0 -18
- package/dist/_examples/repositories/commission/commission-repo-db.js.map +0 -1
- package/dist/_examples/repositories/entity/entity-repo-db.d.ts +0 -6
- package/dist/_examples/repositories/entity/entity-repo-db.interface.d.ts +0 -4
- package/dist/_examples/repositories/entity/entity-repo-db.interface.js +0 -3
- package/dist/_examples/repositories/entity/entity-repo-db.interface.js.map +0 -1
- package/dist/_examples/repositories/entity/entity-repo-db.js +0 -19
- package/dist/_examples/repositories/entity/entity-repo-db.js.map +0 -1
- package/dist/_examples/repositories/entity/entity-repo-erp-acs.interface.d.ts +0 -3
- package/dist/_examples/repositories/entity/entity-repo-erp-acs.interface.js +0 -3
- package/dist/_examples/repositories/entity/entity-repo-erp-acs.interface.js.map +0 -1
- package/dist/_examples/repositories/entity/entity-repo-erp-coremind.d.ts +0 -0
- package/dist/_examples/repositories/entity/entity-repo-erp-coremind.js +0 -2
- package/dist/_examples/repositories/entity/entity-repo-erp-coremind.js.map +0 -1
- package/dist/_examples/repositories/entity/entity-repo-es.d.ts +0 -6
- package/dist/_examples/repositories/entity/entity-repo-es.interface.d.ts +0 -4
- package/dist/_examples/repositories/entity/entity-repo-es.interface.js +0 -3
- package/dist/_examples/repositories/entity/entity-repo-es.interface.js.map +0 -1
- package/dist/_examples/repositories/entity/entity-repo-es.js +0 -19
- package/dist/_examples/repositories/entity/entity-repo-es.js.map +0 -1
- package/dist/_examples/repositories/order/order-es.repo.d.ts +0 -12
- package/dist/_examples/repositories/order/order-es.repo.interface.d.ts +0 -7
- package/dist/_examples/repositories/order/order-es.repo.interface.js +0 -3
- package/dist/_examples/repositories/order/order-es.repo.interface.js.map +0 -1
- package/dist/_examples/repositories/order/order-es.repo.js +0 -64
- package/dist/_examples/repositories/order/order-es.repo.js.map +0 -1
- package/dist/_examples/repositories/order/order-repo-db.d.ts +0 -6
- package/dist/_examples/repositories/order/order-repo-db.interface.d.ts +0 -17
- package/dist/_examples/repositories/order/order-repo-db.interface.js +0 -22
- package/dist/_examples/repositories/order/order-repo-db.interface.js.map +0 -1
- package/dist/_examples/repositories/order/order-repo-db.js +0 -19
- package/dist/_examples/repositories/order/order-repo-db.js.map +0 -1
- package/dist/_examples/repositories/raccount/raccount-db.repo.d.ts +0 -5
- package/dist/_examples/repositories/raccount/raccount-db.repo.interface.d.ts +0 -4
- package/dist/_examples/repositories/raccount/raccount-db.repo.interface.js +0 -3
- package/dist/_examples/repositories/raccount/raccount-db.repo.interface.js.map +0 -1
- package/dist/_examples/repositories/raccount/raccount-db.repo.js +0 -18
- package/dist/_examples/repositories/raccount/raccount-db.repo.js.map +0 -1
- package/dist/_examples/repositories/raccount/raccount-es.repo.d.ts +0 -6
- package/dist/_examples/repositories/raccount/raccount-es.repo.interface.d.ts +0 -4
- package/dist/_examples/repositories/raccount/raccount-es.repo.interface.js +0 -3
- package/dist/_examples/repositories/raccount/raccount-es.repo.interface.js.map +0 -1
- package/dist/_examples/repositories/raccount/raccount-es.repo.js +0 -19
- package/dist/_examples/repositories/raccount/raccount-es.repo.js.map +0 -1
- package/dist/_examples/repositories/rorder/rorder-db.repo.d.ts +0 -5
- package/dist/_examples/repositories/rorder/rorder-db.repo.interface.d.ts +0 -4
- package/dist/_examples/repositories/rorder/rorder-db.repo.interface.js +0 -3
- package/dist/_examples/repositories/rorder/rorder-db.repo.interface.js.map +0 -1
- package/dist/_examples/repositories/rorder/rorder-db.repo.js +0 -18
- package/dist/_examples/repositories/rorder/rorder-db.repo.js.map +0 -1
- package/dist/_examples/repositories/rorder/rorder-es.repo.d.ts +0 -7
- package/dist/_examples/repositories/rorder/rorder-es.repo.interface.d.ts +0 -5
- package/dist/_examples/repositories/rorder/rorder-es.repo.interface.js +0 -3
- package/dist/_examples/repositories/rorder/rorder-es.repo.interface.js.map +0 -1
- package/dist/_examples/repositories/rorder/rorder-es.repo.js +0 -22
- package/dist/_examples/repositories/rorder/rorder-es.repo.js.map +0 -1
- package/dist/_examples/repositories/supplier/supplier-repo-db.d.ts +0 -6
- package/dist/_examples/repositories/supplier/supplier-repo-db.interface.d.ts +0 -4
- package/dist/_examples/repositories/supplier/supplier-repo-db.interface.js +0 -3
- package/dist/_examples/repositories/supplier/supplier-repo-db.interface.js.map +0 -1
- package/dist/_examples/repositories/supplier/supplier-repo-db.js +0 -19
- package/dist/_examples/repositories/supplier/supplier-repo-db.js.map +0 -1
- package/dist/_examples/repositories/supplier/supplier-repo-es.d.ts +0 -6
- package/dist/_examples/repositories/supplier/supplier-repo-es.interface.d.ts +0 -4
- package/dist/_examples/repositories/supplier/supplier-repo-es.interface.js +0 -3
- package/dist/_examples/repositories/supplier/supplier-repo-es.interface.js.map +0 -1
- package/dist/_examples/repositories/supplier/supplier-repo-es.js +0 -19
- package/dist/_examples/repositories/supplier/supplier-repo-es.js.map +0 -1
- package/dist/_examples/repositories/user-repo-db.d.ts +0 -7
- package/dist/_examples/repositories/user-repo-db.interface.d.ts +0 -5
- package/dist/_examples/repositories/user-repo-db.interface.js +0 -3
- package/dist/_examples/repositories/user-repo-db.interface.js.map +0 -1
- package/dist/_examples/repositories/user-repo-db.js +0 -24
- package/dist/_examples/repositories/user-repo-db.js.map +0 -1
- package/dist/_examples/service/branch/branch-service.d.ts +0 -13
- package/dist/_examples/service/branch/branch-service.interface.d.ts +0 -4
- package/dist/_examples/service/branch/branch-service.interface.js +0 -3
- package/dist/_examples/service/branch/branch-service.interface.js.map +0 -1
- package/dist/_examples/service/branch/branch-service.js +0 -70
- package/dist/_examples/service/branch/branch-service.js.map +0 -1
- package/dist/_examples/service/commission/commission-service.d.ts +0 -15
- package/dist/_examples/service/commission/commission-service.interface.d.ts +0 -6
- package/dist/_examples/service/commission/commission-service.interface.js +0 -3
- package/dist/_examples/service/commission/commission-service.interface.js.map +0 -1
- package/dist/_examples/service/commission/commission-service.js +0 -116
- package/dist/_examples/service/commission/commission-service.js.map +0 -1
- package/dist/_examples/service/entity/entity-service.d.ts +0 -13
- package/dist/_examples/service/entity/entity-service.interface.d.ts +0 -5
- package/dist/_examples/service/entity/entity-service.interface.js +0 -3
- package/dist/_examples/service/entity/entity-service.interface.js.map +0 -1
- package/dist/_examples/service/entity/entity-service.js +0 -92
- package/dist/_examples/service/entity/entity-service.js.map +0 -1
- package/dist/_examples/service/order-service.d.ts +0 -12
- package/dist/_examples/service/order-service.interface.d.ts +0 -5
- package/dist/_examples/service/order-service.interface.js +0 -4
- package/dist/_examples/service/order-service.interface.js.map +0 -1
- package/dist/_examples/service/order-service.js +0 -31
- package/dist/_examples/service/order-service.js.map +0 -1
- package/dist/_examples/service/raccount/raccount-service.d.ts +0 -10
- package/dist/_examples/service/raccount/raccount-service.interface.d.ts +0 -4
- package/dist/_examples/service/raccount/raccount-service.interface.js +0 -3
- package/dist/_examples/service/raccount/raccount-service.interface.js.map +0 -1
- package/dist/_examples/service/raccount/raccount-service.js +0 -64
- package/dist/_examples/service/raccount/raccount-service.js.map +0 -1
- package/dist/_examples/service/rorder/rorder-service.d.ts +0 -11
- package/dist/_examples/service/rorder/rorder-service.interface.d.ts +0 -10
- package/dist/_examples/service/rorder/rorder-service.interface.js +0 -3
- package/dist/_examples/service/rorder/rorder-service.interface.js.map +0 -1
- package/dist/_examples/service/rorder/rorder-service.js +0 -65
- package/dist/_examples/service/rorder/rorder-service.js.map +0 -1
- package/dist/_examples/service/supplier/supplier-service-crud.d.ts +0 -25
- package/dist/_examples/service/supplier/supplier-service-crud.interface.d.ts +0 -14
- package/dist/_examples/service/supplier/supplier-service-crud.interface.js +0 -3
- package/dist/_examples/service/supplier/supplier-service-crud.interface.js.map +0 -1
- package/dist/_examples/service/supplier/supplier-service-crud.js +0 -129
- package/dist/_examples/service/supplier/supplier-service-crud.js.map +0 -1
- package/dist/_examples/service/supplier/supplier-service-stream.d.ts +0 -13
- package/dist/_examples/service/supplier/supplier-service-stream.interface.d.ts +0 -5
- package/dist/_examples/service/supplier/supplier-service-stream.interface.js +0 -4
- package/dist/_examples/service/supplier/supplier-service-stream.interface.js.map +0 -1
- package/dist/_examples/service/supplier/supplier-service-stream.js +0 -72
- package/dist/_examples/service/supplier/supplier-service-stream.js.map +0 -1
- package/dist/_examples/service/user-service.d.ts +0 -11
- package/dist/_examples/service/user-service.interface.d.ts +0 -5
- package/dist/_examples/service/user-service.interface.js +0 -3
- package/dist/_examples/service/user-service.interface.js.map +0 -1
- package/dist/_examples/service/user-service.js +0 -41
- package/dist/_examples/service/user-service.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crud.service.interface.js","sourceRoot":"","sources":["../../src/service/crud.service.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { BaseEntity, CognitoUser, DynamoIndexMap, Filter, List } from \"../index\";\nimport { EntityConfig } from \"@chinggis/types\";\n\n/**\n * Defines a generic base service interface for working with entities in both\n * DynamoDB and OpenSearch.\n */\nexport interface CrudService<T extends BaseEntity> {\n setConfig(config: EntityConfig): void;\n\n getTableName(): string;\n /**\n * Creates a new entity for the given user.\n * @param ownerId - The ID of the user who owns the entity.\n * @param entity - The entity to be created.\n * @param parentId\n * @param createdByUser - The created user.\n * @returns The created entity.\n */\n save(entity: Partial<T>, ownerId: string, parentId?: string, createdByUser?: CognitoUser): Promise<T>;\n\n /**\n * Creates multiple new entities for the given user.\n * @param ownerId - The ID of the user who owns the entities.\n * @param entity - An array of entities to be created.\n * @param parentId\n * @param createdByUser - The created user.\n * @param isTransactional - Whether to perform the operation in a transaction.\n * @returns An array of created entities.\n */\n saveAll(\n entity: Partial<T>[],\n ownerId: string,\n parentId?: string,\n createdByUser?: CognitoUser,\n isTransactional?: boolean,\n ): Promise<Partial<T>[]>;\n\n /**\n * Applies partial updates to an entity for the given user.\n * Only the specified fields will be updated.\n * @param requestUser - Cognito user, system if not exist\n * @param entity - The entity with updated fields.\n * @returns The updated entity.\n */\n update(entity: Partial<T>, requestUser?: CognitoUser, fields?: string[]): Promise<T>;\n\n /**\n * Applies partial updates to multiple entities for the given user.\n * Only the specified fields will be updated for each entity.\n * @param requestUser - Cognito user, system if not exist\n * @param entity - An array of entities with updated fields.\n * @param fields - The list of field names to update in each entity. Supports dot paths (e.g. `author.name`).\n * @param isTransactional - Whether to perform the operation in a transaction.\n * @returns True if all entities were successfully updated.\n */\n updateAll(entity: T[], fields: string[], requestUser?: CognitoUser, isTransactional?: boolean): Promise<boolean>;\n\n /**\n * Updates selected fields for one entity. The entity object provides both the\n * partition-key value (to identify the item) and the new field values to write.\n * Supports dot paths (e.g. `author.name`).\n */\n updateFields(entity: Partial<T>, fields: string[], requestUser?: CognitoUser): Promise<Partial<T>>;\n\n /**\n * Deletes an entity by ID for the given user.\n * @param requestUser - Cognito user, system if not exist\n * @param entityId - The ID of the entity to delete.\n * @returns True if the entity was successfully deleted.\n */\n remove(entityId: string, requestUser?: CognitoUser): Promise<boolean>;\n\n deleteFields(entityId: string, fields: string[]): Promise<Partial<T>>;\n\n /**\n * Deletes multiple entities by their IDs for the given user.\n * @param requestUser - Cognito user, system if not exist\n * @param entityIds - An array of entity IDs to delete.\n * @returns True if all entities were successfully deleted.\n */\n removeAll(entityIds: string[], requestUser?: CognitoUser): Promise<boolean>;\n\n removeMatch(filter: Filter | string, requestUser?: CognitoUser): Promise<boolean>;\n\n /**\n * Retrieves an entity by its ID for the given user.\n * @param requestUser - Cognito user, system if not exist\n * @param entityId - The ID of the entity to retrieve.\n * @returns The requested entity.\n */\n findById(entityId: string, requestUser?: CognitoUser): Promise<T>;\n\n /**\n * Retrieves multiple entities by their IDs for the given user.\n * @param requestUser - Cognito user, system if not exist\n * @param entityIds - An array of entity IDs to retrieve.\n * @returns An array of found entities.\n */\n findByIds(entityIds: string[], requestUser?: CognitoUser): Promise<T[]>;\n\n /**\n * Retrieves a paginated and filtered list of entities from DynamoDB.\n *\n * @param filter - Filtering and sorting options.\n * @returns A promise resolving to a paginated list of entities.\n */\n find(filter: Filter | string): Promise<List<Partial<T>>>;\n\n /**\n * Scans the table with non-index filters. Expensive; avoid it for hot paths.\n */\n scan(filter: Filter): Promise<List<Partial<T>>>;\n\n findQuery(queryParams: string): Promise<List<Partial<T>>>;\n\n searchQuery(\n queryParams: any,\n debug?: boolean,\n ): Promise<{ items: Partial<T>[]; total: number; aggs?: Record<string, any> }>;\n\n searchQueryTotalCount(queryParams: any): Promise<number>;\n\n findAll(): Promise<T[]>;\n\n findAllMatch(filter: Filter | string): Promise<T[]>;\n\n findAllByIndex(indexName: string, indexValue: any): Promise<T[]>;\n\n findByField(fieldName: string, fieldValue: any): Promise<List<T>>;\n\n findFirst(fieldName: string, fieldValue: string | boolean | number | Date): Promise<T>;\n\n throwError(code: number, message: string, errorContent?: any): void;\n\n throwErrorHttp(error: { message: string; code: number }, message: string, errorContent?: any): void;\n\n throwErrorsHttp(code: number, message: string, errorContent?: any): void;\n\n throwErrorDatabase(tableName: string, command: any, errorContent?: any): void;\n\n throwErrorValidation(entityName: string, validation: Map<string, any>, errorContent?: any): void;\n\n // throwError(httpStatus: number, message: string): void;\n /**\n * Retrieves a filtered and sorted list of entities from OpenSearch.\n *\n * @param filter - Filtering and sorting options.\n * @returns A promise resolving to the list of matching entities.\n */\n search(filter: Filter | string): Promise<List<Partial<T>>>;\n\n searchFieldNotExist(fieldName: string, from: number, size: number): Promise<Partial<T>[]>;\n\n /**\n * Changes the owner of an entity.\n * @param ownerId - The new owner's ID.\n * @param entityId - The ID of the entity to transfer.\n * @returns The updated entity with the new owner.\n */\n changeOwner(entityId: string, ownerId: string): Promise<T>;\n\n setTable(tableName: string, dynamoIndexMap: DynamoIndexMap): boolean;\n\n setOpensearch(indexName: string, opensearchEndpoint: string): boolean;\n\n getIndexES(): string;\n\n getIndexMapDB(): DynamoIndexMap;\n\n setIndexMapDB(indexMap: DynamoIndexMap): boolean;\n\n incrementValueByField(entityId: string, fieldName: string, value?: number): Promise<T>;\n\n decrementValueByField(entityId: string, fieldName: string, value?: number): Promise<T>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"crud.service.interface.js","sourceRoot":"","sources":["../../src/service/crud.service.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { BaseEntity, CognitoUser, DynamoIndexMap, Filter, List } from \"../index\";\nimport { EntityConfig } from \"@chinggis/types\";\n\n/**\n * Defines a generic base service interface for working with entities in both\n * DynamoDB and OpenSearch.\n */\nexport interface CrudService<T extends BaseEntity> {\n setConfig(config: EntityConfig): void;\n\n getTableName(): string;\n /**\n * Creates a new entity for the given user.\n * @param ownerId - The ID of the user who owns the entity.\n * @param entity - The entity to be created.\n * @param parentId\n * @param createdByUser - The created user.\n * @returns The created entity.\n */\n save(entity: Partial<T>, ownerId: string, parentId?: string, createdByUser?: CognitoUser): Promise<T>;\n\n /**\n * Creates multiple new entities for the given user.\n * @param ownerId - The ID of the user who owns the entities.\n * @param entity - An array of entities to be created.\n * @param parentId\n * @param createdByUser - The created user.\n * @param isTransactional - Whether to perform the operation in a transaction.\n * @returns An array of created entities.\n */\n saveAll(\n entity: Partial<T>[],\n ownerId: string,\n parentId?: string,\n createdByUser?: CognitoUser,\n isTransactional?: boolean,\n ): Promise<Partial<T>[]>;\n\n /**\n * Applies partial updates to an entity for the given user.\n * Only the specified fields will be updated.\n * @param requestUser - Cognito user, system if not exist\n * @param entity - The entity with updated fields.\n * @returns The updated entity.\n */\n update(entity: Partial<T>, requestUser?: CognitoUser, fields?: string[]): Promise<T>;\n\n /**\n * Applies partial updates to multiple entities for the given user.\n * Only the specified fields will be updated for each entity.\n * @param requestUser - Cognito user, system if not exist\n * @param entity - An array of entities with updated fields.\n * @param fields - The list of field names to update in each entity. Supports dot paths (e.g. `author.name`).\n * @param isTransactional - Whether to perform the operation in a transaction.\n * @returns True if all entities were successfully updated.\n */\n updateAll(entity: T[], fields: string[], requestUser?: CognitoUser, isTransactional?: boolean): Promise<boolean>;\n\n /**\n * Updates selected fields for one entity. The entity object provides both the\n * partition-key value (to identify the item) and the new field values to write.\n * Supports dot paths (e.g. `author.name`).\n */\n updateFields(entity: Partial<T>, fields: string[], requestUser?: CognitoUser): Promise<Partial<T>>;\n\n /**\n * Deletes an entity by ID for the given user.\n * @param requestUser - Cognito user, system if not exist\n * @param entityId - The ID of the entity to delete.\n * @returns True if the entity was successfully deleted.\n */\n remove(entityId: string, requestUser?: CognitoUser): Promise<boolean>;\n\n deleteFields(entityId: string, fields: string[]): Promise<Partial<T>>;\n\n /**\n * Deletes multiple entities by their IDs for the given user.\n * @param requestUser - Cognito user, system if not exist\n * @param entityIds - An array of entity IDs to delete.\n * @returns True if all entities were successfully deleted.\n */\n removeAll(entityIds: string[], requestUser?: CognitoUser): Promise<boolean>;\n\n removeMatch(filter: Filter | string, requestUser?: CognitoUser): Promise<boolean>;\n\n /**\n * Retrieves an entity by its ID for the given user.\n * @param requestUser - Cognito user, system if not exist\n * @param entityId - The ID of the entity to retrieve.\n * @returns The requested entity.\n */\n findById(entityId: string, requestUser?: CognitoUser): Promise<T>;\n\n /**\n * Retrieves multiple entities by their IDs for the given user.\n * @param requestUser - Cognito user, system if not exist\n * @param entityIds - An array of entity IDs to retrieve.\n * @returns An array of found entities.\n */\n findByIds(entityIds: string[], requestUser?: CognitoUser): Promise<T[]>;\n\n /**\n * Retrieves a paginated and filtered list of entities from DynamoDB.\n *\n * @param filter - Filtering and sorting options.\n * @returns A promise resolving to a paginated list of entities.\n */\n find(filter: Filter | string): Promise<List<Partial<T>>>;\n\n /**\n * Scans the table with non-index filters. Expensive; avoid it for hot paths.\n */\n scan(filter: Filter): Promise<List<Partial<T>>>;\n\n findQuery(queryParams: string): Promise<List<Partial<T>>>;\n\n searchQuery(\n queryParams: any,\n debug?: boolean,\n ): Promise<{ items: Partial<T>[]; total: number; aggs?: Record<string, any> }>;\n\n /**\n * Returns a lazy async iterator over paginated DynamoDB query results.\n * Each `next()` call loads the next page only when the current buffer is empty.\n */\n findStream(filter: string, size?: number): AsyncGenerator<T>;\n\n /**\n * Returns a lazy async iterator over paginated OpenSearch query results.\n * Each `next()` call loads the next page only when the current buffer is empty.\n */\n searchStream(filter: string, size?: number): AsyncGenerator<T>;\n\n searchStreamAggr(\n filter: Filter | string,\n size?: number,\n ): AsyncGenerator<{ items: Partial<T>[]; total: number; aggs?: Record<string, any> }>;\n\n searchQueryTotalCount(queryParams: any): Promise<number>;\n\n findAll(): Promise<T[]>;\n\n findAllMatch(filter: Filter | string): Promise<T[]>;\n\n findAllByIndex(indexName: string, indexValue: any): Promise<T[]>;\n\n findByField(fieldName: string, fieldValue: any): Promise<List<T>>;\n\n findFirst(fieldName: string, fieldValue: string | boolean | number | Date): Promise<T>;\n\n throwError(code: number, message: string, errorContent?: any): void;\n\n throwErrorHttp(error: { message: string; code: number }, message: string, errorContent?: any): void;\n\n throwErrorsHttp(code: number, message: string, errorContent?: any): void;\n\n throwErrorDatabase(tableName: string, command: any, errorContent?: any): void;\n\n throwErrorValidation(entityName: string, validation: Map<string, any>, errorContent?: any): void;\n\n // throwError(httpStatus: number, message: string): void;\n /**\n * Retrieves a filtered and sorted list of entities from OpenSearch.\n *\n * @param filter - Filtering and sorting options.\n * @returns A promise resolving to the list of matching entities.\n */\n search(filter: Filter | string): Promise<List<Partial<T>>>;\n\n searchFieldNotExist(fieldName: string, from: number, size: number): Promise<Partial<T>[]>;\n\n /**\n * Changes the owner of an entity.\n * @param ownerId - The new owner's ID.\n * @param entityId - The ID of the entity to transfer.\n * @returns The updated entity with the new owner.\n */\n changeOwner(entityId: string, ownerId: string): Promise<T>;\n\n setTable(tableName: string, dynamoIndexMap: DynamoIndexMap): boolean;\n\n setOpensearch(indexName: string, opensearchEndpoint: string): boolean;\n\n getIndexES(): string;\n\n getIndexMapDB(): DynamoIndexMap;\n\n setIndexMapDB(indexMap: DynamoIndexMap): boolean;\n\n incrementValueByField(entityId: string, fieldName: string, value?: number): Promise<T>;\n\n decrementValueByField(entityId: string, fieldName: string, value?: number): Promise<T>;\n}\n"]}
|
|
@@ -206,6 +206,38 @@ class CrudServiceImpl {
|
|
|
206
206
|
parsedFilter = (0, index_1.parseIndexFilter)(filter, this.getIndexMapDB());
|
|
207
207
|
return await this.repoDB.find(parsedFilter);
|
|
208
208
|
}
|
|
209
|
+
async *findStream(filter, size) {
|
|
210
|
+
let lastKey = "";
|
|
211
|
+
const pageSize = size ?? 50;
|
|
212
|
+
do {
|
|
213
|
+
const filterStr = `lastkey=${lastKey}&size=${pageSize}&${filter}`;
|
|
214
|
+
const itemList = await this.findQuery(filterStr);
|
|
215
|
+
yield* itemList.items;
|
|
216
|
+
lastKey = itemList.lastKey;
|
|
217
|
+
} while (lastKey);
|
|
218
|
+
}
|
|
219
|
+
async *searchStream(filter, size) {
|
|
220
|
+
let pageNumber = 1;
|
|
221
|
+
const pageSize = size ?? 50;
|
|
222
|
+
while (true) {
|
|
223
|
+
const filterStr = `page=${pageNumber++}&size=${pageSize}&${filter}`;
|
|
224
|
+
const resultList = await this.searchQuery(filterStr);
|
|
225
|
+
yield* resultList.items;
|
|
226
|
+
if (resultList.items.length < pageSize)
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
async *searchStreamAggr(filter, size) {
|
|
231
|
+
let pageNumber = 1;
|
|
232
|
+
const pageSize = size ?? 50;
|
|
233
|
+
while (true) {
|
|
234
|
+
const filterStr = `page=${pageNumber++}&size=${pageSize}&${filter}`;
|
|
235
|
+
const resultList = await this.searchQuery(filterStr);
|
|
236
|
+
yield resultList;
|
|
237
|
+
if (resultList.items.length < pageSize)
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
209
241
|
async findById(entityId, requestUser) {
|
|
210
242
|
const entity = await this.repoDB.findById(entityId);
|
|
211
243
|
if (!entity)
|
|
@@ -332,6 +364,8 @@ class CrudServiceImpl {
|
|
|
332
364
|
return result;
|
|
333
365
|
}
|
|
334
366
|
parseOwnerFields(filter, entityConfig) {
|
|
367
|
+
if (!filter)
|
|
368
|
+
return null;
|
|
335
369
|
const parsedFilter = filter;
|
|
336
370
|
log.debug("input filter", parsedFilter);
|
|
337
371
|
if (parsedFilter.ownerParentId && !entityConfig.OWNER_PARENT_ID_FIELD_NAME) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crud.service.js","sourceRoot":"","sources":["../../src/service/crud.service.ts"],"names":[],"mappings":";;;;;;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BaseEntity,\n BaseRepoDB,\n BaseRepoDBImpl,\n BaseRepoES,\n BaseRepoESImpl,\n ChangeHistory,\n CognitoUser,\n computeChangedFields,\n DynamoIndexMap,\n Filter,\n List,\n parseFilter,\n parseIndexFilter,\n removeFields,\n} from \"../index\";\nimport { ErrorBase, ErrorDynamoDB, ErrorHttp, ErrorValidation } from \"../exception\";\n\nimport { EntityConfig } from \"@chinggis/types\";\nimport { CrudService } from \"./crud.service.interface\";\nimport dayjs from \"dayjs\";\nimport { buildSearchQueryOS } from \"../utils/opensearch/opensearch.parser\";\n\nexport abstract class CrudServiceImpl<\n T extends BaseEntity,\n D extends BaseRepoDB<T>,\n S extends BaseRepoES<T>,\n> implements CrudService<T> {\n protected repoDB: D;\n protected repoES: S;\n protected config: EntityConfig;\n\n protected constructor(repoDB: D, repoES: S) {\n if (repoDB != null && !(repoDB instanceof BaseRepoDBImpl))\n console.error(\"repoDB is not an instance of BaseRepoDBImpl\");\n\n if (repoES != null && !(repoES instanceof BaseRepoESImpl))\n console.error(\"repoES is not an instance of BaseRepoESImpl\");\n\n if (repoDB == null && repoES == null) console.error(\"repo initialization is required\");\n\n this.repoDB = repoDB;\n this.repoES = repoES;\n }\n\n getTableName(): string {\n return this.repoDB.getTableName();\n }\n\n async findQuery(queryParams: string): Promise<List<Partial<T>>> {\n const filter = parseIndexFilter(queryParams, this.getIndexMapDB());\n this.checkIsIndexedField(filter);\n return await this.find(filter);\n }\n\n async deleteFields(entityId: string, fields: string[]): Promise<Partial<T>> {\n return this.repoDB.deleteFields(entityId, fields);\n }\n\n async searchQuery(\n queryParams: any,\n debug?: boolean,\n ): Promise<{ items: Partial<T>[]; total: number; aggs?: Record<string, any> }> {\n const query = buildSearchQueryOS(queryParams, this.config);\n\n return await this.repoES.search(query, debug);\n }\n\n async searchQueryTotalCount(queryParams: any): Promise<number> {\n const query = buildSearchQueryOS(queryParams, this.config);\n\n return this.repoES.count(query);\n }\n\n async incrementValueByField(entityId: string, fieldName: string, value?: number): Promise<T> {\n return await this.repoDB.incrementValueByField(entityId, fieldName, value);\n }\n\n async decrementValueByField(entityId: string, fieldName: string, value?: number): Promise<T> {\n return await this.repoDB.decrementValueByField(entityId, fieldName, value);\n }\n\n async search(filter: Filter | string): Promise<List<Partial<T>>> {\n if (typeof filter === \"string\") filter = parseIndexFilter(filter, this.getIndexMapDB());\n\n let parsedFilter = this.parseOwnerFields(filter, this.config);\n parsedFilter = this.setIndexField(parsedFilter, this.config);\n\n return this.repoES.find(parsedFilter);\n }\n\n async searchFieldNotExist(fieldName: string, from: number, size: number): Promise<Partial<T>[]> {\n return await this.repoES.fieldNotExists(fieldName, from, size);\n }\n\n async save(entity: Partial<T>, ownerId: string, parentId?: string, createdByUser?: string | CognitoUser): Promise<T> {\n entity = this.setSystemData(entity, Action.CREATE, createdByUser);\n\n if (ownerId && this.config.OWNER_ID_FIELD_NAME) entity[this.config.OWNER_ID_FIELD_NAME] = ownerId;\n\n if (parentId && this.config.OWNER_PARENT_ID_FIELD_NAME) entity[this.config.OWNER_PARENT_ID_FIELD_NAME] = parentId;\n\n return await this.repoDB.save(entity);\n }\n\n async saveAll(\n entities: Partial<T>[],\n ownerId: string,\n parentId?: string,\n createdByUser?: string | CognitoUser,\n isTransactional?: boolean,\n ): Promise<Partial<T>[]> {\n const entitiesUpdated = [];\n\n for (const item of entities) {\n // const entity = addDatesAndId(item);\n const entity = this.setSystemData(item, Action.CREATE, createdByUser || ownerId);\n\n if (parentId && this.config.OWNER_PARENT_ID_FIELD_NAME) entity[this.config.OWNER_PARENT_ID_FIELD_NAME] = parentId;\n\n if (ownerId && this.config.OWNER_ID_FIELD_NAME) entity[this.config.OWNER_ID_FIELD_NAME] = ownerId;\n\n entitiesUpdated.push(entity);\n }\n\n return await this.repoDB.saveMany(entitiesUpdated, isTransactional);\n }\n\n async update(entity: Partial<T>, requestUser?: CognitoUser, fields?: string[]): Promise<T> {\n const fieldName = this.config.DYNAMO_DB?.MAP?.partitionKey ?? \"id\";\n if (fields && fields.length > 0) fields.push(fieldName);\n if (fields && fields.length > 0) entity = removeFields([entity], fields)[0];\n\n if (!entity || !entity[fieldName]) throw new ErrorHttp({ code: 400, error: \"BadRequest\" }, `id required`);\n\n const item = await this.repoDB.findById(entity[fieldName]);\n\n if (!entity || !item) throw new ErrorHttp({ code: 400, error: \"BadRequest\" }, `id not found`);\n\n if (\n requestUser &&\n !requestUser.isScope &&\n !requestUser.isAdmin &&\n (item[this.config.OWNER_ID_FIELD_NAME] !== requestUser.profile ||\n item[this.config.OWNER_PARENT_ID_FIELD_NAME] !== requestUser.parentId)\n )\n throw new ErrorHttp({ code: 403, error: \"PermissionDenied\" }, `No permission to resource: ${entity.id}`);\n\n entity = this.setSystemData(entity, Action.UPDATE, requestUser, item);\n\n // if (!hasPermission(entity, userId, Permission.UPDATE)) throw new Error(\"Unauthorized access\");\n return this.repoDB.update(entity);\n }\n\n async updateAll(\n entities: Partial<T>[],\n fields: string[],\n requestUser?: CognitoUser,\n isTransactional?: boolean,\n ): Promise<boolean> {\n if (requestUser) log.warn(\"this methode is under development, cannot check ownership by updateAll\");\n\n return this.repoDB.updateMany(entities, fields, isTransactional);\n }\n\n async updateFields(entity: Partial<T>, fields: string[], requestUser?: CognitoUser): Promise<Partial<T>> {\n if (!entity || !fields?.length) return entity;\n return this.repoDB.updateFields(entity, [...fields]);\n }\n\n async remove(entityId: string, requestUser?: CognitoUser): Promise<boolean> {\n if (!entityId) throw new Error(\"Entity id required\");\n\n if (requestUser && requestUser.isAdmin) return await this.repoDB.delete(entityId);\n\n const entity = await this.repoDB.findById(entityId);\n if (!entity) throw new Error(\"Entity not found\");\n\n if (\n requestUser &&\n !requestUser.isScope &&\n (entity[this.config.OWNER_ID_FIELD_NAME] !== requestUser.profile ||\n entity[this.config.OWNER_PARENT_ID_FIELD_NAME] !== requestUser.parentId)\n )\n throw new ErrorHttp({ code: 403, error: \"PermissionDenied\" }, `No permission to resource: ${entity.id}`);\n\n return await this.repoDB.delete(entityId);\n }\n\n async removeAll(entityIds: string[], requestUser?: CognitoUser): Promise<boolean> {\n if (requestUser) log.warn(\"this methode is under development, cannot check ownership by removeAll\");\n return await this.repoDB.deleteMany(entityIds);\n }\n\n async removeMatch(filter: Filter | string, requestUser?: CognitoUser): Promise<boolean> {\n const { items } = await this.find(filter);\n if (items.length === 0) return true;\n\n return this.removeAll(\n items.map((item) => item.id),\n requestUser,\n );\n }\n\n async changeOwner(entityId: string, ownerId: string): Promise<T> {\n const entity = await this.repoDB.findById(entityId);\n entity[this.config.OWNER_ID_FIELD_NAME] = ownerId;\n return this.repoDB.update(entity);\n }\n\n setTable(tableName: string, dynamoIndexMap: DynamoIndexMap): boolean {\n this.repoDB.setTable(tableName);\n this.repoDB.setIndexMap(dynamoIndexMap);\n return true;\n }\n\n setOpensearch(indexName: string, opensearchEndpoint: string): boolean {\n this.repoES.setIndexName(indexName);\n this.repoES.setEndpoint(opensearchEndpoint);\n return true;\n }\n\n getIndexES(): string {\n return this.repoES.getIndexName();\n }\n\n getIndexMapDB(): DynamoIndexMap {\n return this.repoDB.getIndexMap();\n }\n\n setIndexMapDB(indexMap: DynamoIndexMap): boolean {\n this.repoDB.setIndexMap(indexMap);\n return true;\n }\n\n async findAll(): Promise<T[]> {\n const result: T[] = [];\n\n const filter = parseIndexFilter(\"size=250\");\n\n do {\n const response = await this.repoDB.find(filter);\n result.push(...(response.items as T[]));\n filter.lastKey = response.lastKey;\n } while (filter.lastKey);\n\n return result;\n }\n\n async findAllMatch(filter: Filter | string): Promise<T[]> {\n if (typeof filter === \"string\") filter = parseIndexFilter(filter, this.getIndexMapDB());\n this.checkIsIndexedField(filter);\n return await this.fetchAll(filter);\n }\n\n async findAllByIndex(indexName: string, indexValue: any): Promise<T[]> {\n // Create a filter object for validation\n const filter = { indexName: indexName, indexValue: indexValue };\n this.checkIsIndexedField(filter);\n\n const parsedFilter = parseIndexFilter(filter, this.getIndexMapDB());\n return this.fetchAll(parsedFilter);\n }\n\n async findByField(fieldName: string, fieldValue: any): Promise<List<T>> {\n // Create a filter object for validation\n const filter = { [fieldName]: fieldValue, size: 100 };\n this.checkIsIndexedField(filter);\n const parsedFilter = parseIndexFilter(fieldName + \"=\" + fieldValue + \"&size=100\", this.getIndexMapDB());\n return (await this.find(parsedFilter)) as List<T>;\n }\n\n async findFirst(fieldName: string, fieldValue: string | boolean | number | Date): Promise<T> {\n // Validate that the field name exists in the index map\n const filter = { [fieldName]: fieldValue };\n this.checkIsIndexedField(filter);\n\n const result = await this.findByField(fieldName, fieldValue);\n return result.items.length > 0 ? result.items[0] : null;\n }\n\n async find(filter: Filter | string): Promise<List<Partial<T>>> {\n if (typeof filter === \"string\") filter = parseIndexFilter(filter, this.getIndexMapDB());\n // Validate that all field names in the filter exist in the index map\n let parsedFilter = this.parseOwnerFields(filter, this.config);\n\n this.checkIsIndexedField(parsedFilter);\n\n parsedFilter = parseIndexFilter(filter, this.getIndexMapDB());\n return await this.repoDB.find(parsedFilter);\n }\n\n async findById(entityId: string, requestUser?: CognitoUser): Promise<T> {\n const entity = await this.repoDB.findById(entityId);\n\n if (!entity) return null;\n\n if (!requestUser || requestUser.isAdmin) return entity;\n\n const isOwnerParent = entity[this.config.OWNER_PARENT_ID_FIELD_NAME] == requestUser.profile;\n const isParent = entity[this.config.OWNER_ID_FIELD_NAME] == requestUser.profile;\n\n if (!requestUser.profile || isOwnerParent || isParent) {\n return entity;\n }\n\n return null;\n }\n\n async findByIds(entityIds: string[], requestUser?: CognitoUser): Promise<T[]> {\n if (entityIds.length > 25) throw new ErrorDynamoDB(this.getTableName(), \"findByIds\", \"Too many entities\");\n\n const entities = await this.repoDB.findByIds(entityIds);\n\n if (!requestUser || requestUser.isAdmin) return entities;\n\n const ownEntities = [];\n for (const entity of entities) {\n if (\n entity[this.config.OWNER_PARENT_ID_FIELD_NAME] == requestUser.profile ||\n entity[this.config.OWNER_ID_FIELD_NAME] == requestUser.profile\n ) {\n ownEntities.push(entity);\n }\n }\n return ownEntities;\n }\n\n async scan(filter: Filter): Promise<List<Partial<T>>> {\n this.checkIsIndexedField(filter);\n const parsedFilter = parseIndexFilter(filter, this.getIndexMapDB());\n return await this.repoDB.scan(parsedFilter);\n }\n\n throwErrorHttp(error: { message: string; code: number }, message?: string, errorContent?: any): void {\n throw new ErrorHttp({ code: error.code, error: error.message }, message, errorContent);\n }\n\n throwErrorsHttp(code: number, message: string, errorContent?: any): void {\n throw new ErrorHttp({ code, error: message }, message, errorContent);\n }\n\n throwErrorDatabase(tableName: string, command: any, errorContent?: any): void {\n throw new ErrorDynamoDB(tableName, command, errorContent);\n }\n\n throwErrorValidation(entityName: string, validation: Map<string, any>, errorContent?: any): void {\n throw new ErrorValidation(entityName, validation, errorContent);\n }\n\n throwError(code: number, message: string, errorContent?: any): void {\n throw new ErrorBase(code, message, errorContent);\n }\n\n setConfig(config: EntityConfig) {\n this.config = config;\n\n if (this.repoDB) {\n this.repoDB.setIndexMap(config.DYNAMO_DB?.MAP);\n this.repoDB.setTable(config.DYNAMO_DB?.NAME);\n }\n\n if (this.repoES) {\n this.repoES.setEndpoint(config.OPEN_SEARCH.DOMAIN);\n this.repoES.setIndexName(config.OPEN_SEARCH.INDEX);\n }\n }\n\n /**\n * Validates that all field names in the filter exist in the index map.\n * Throws a Bad Request error if any field is not found in the available indexes.\n *\n * @param filter - The filter object containing field names to validate\n * @throws ErrorHttp with status 400 if validation fails\n */\n private checkIsIndexedField(filter: Filter): void {\n if (!filter || typeof filter !== \"object\") {\n return; // Skip validation for invalid filters\n }\n\n const indexMap = this.getIndexMapDB();\n if (!indexMap || indexMap.size === 0) {\n throw new ErrorHttp({ code: 400, error: \"Bad Request\" }, \"No indexes configured for this table\");\n }\n\n // Get all valid field names from all indexes\n const validFields = new Set<string>();\n\n // Add a partition key\n if (indexMap.partitionKey) {\n validFields.add(indexMap.partitionKey);\n }\n\n // Add fields from all indexes\n for (const [indexName, indexConfig] of indexMap.entries()) {\n if (indexConfig.field) {\n validFields.add(indexConfig.field);\n }\n if (indexConfig.rFields) {\n indexConfig.rFields.forEach((field) => validFields.add(field));\n }\n if (indexConfig.sortKeyField) {\n validFields.add(indexConfig.sortKeyField);\n }\n }\n\n // Check each field in the filter\n const invalidFields: string[] = [];\n for (const fieldName of Object.keys(filter)) {\n // Skip special filter properties that are not field names\n if (\n [\"indexName\", \"indexValue\", \"size\", \"lastKey\", \"fieldsInclude\", \"fieldsExclude\", \"rangeFilters\"].includes(\n fieldName,\n )\n ) {\n continue;\n }\n\n // Skip range filter fields (ageMin, ageMax, etc.)\n const rangeSuffixes = [\"Min\", \"Max\", \"From\", \"To\", \"Start\", \"End\"];\n const isRangeField = rangeSuffixes.some((suffix) => fieldName.endsWith(suffix));\n if (isRangeField) {\n continue;\n }\n\n if (!validFields.has(fieldName)) {\n invalidFields.push(fieldName);\n }\n }\n\n if (invalidFields.length > 0) {\n const availableFields = Array.from(validFields).sort();\n throw new ErrorHttp(\n { code: 400, error: \"Bad Request\" },\n `Invalid field names in filter: ${invalidFields.join(\", \")}. Available fields: ${availableFields.join(\", \")}`,\n );\n }\n }\n\n private async fetchAll(filter: Filter | string): Promise<T[]> {\n if (typeof filter === \"string\") filter = parseFilter(filter);\n\n const result: Partial<T>[] = [];\n do {\n const response = await this.repoDB.find(filter);\n result.push(...response.items);\n filter.lastKey = response.lastKey;\n } while (filter.lastKey);\n\n return result as T[];\n }\n\n private parseOwnerFields(filter: Filter, entityConfig: EntityConfig) {\n const parsedFilter = filter;\n\n log.debug(\"input filter\", parsedFilter);\n\n if (parsedFilter.ownerParentId && !entityConfig.OWNER_PARENT_ID_FIELD_NAME) {\n parsedFilter.profileId = parsedFilter.ownerParentId;\n delete parsedFilter.ownerParentId;\n }\n if (!parsedFilter.profileId) delete parsedFilter.profileId;\n\n if (parsedFilter.ownerParentId && entityConfig.OWNER_PARENT_ID_FIELD_NAME) {\n parsedFilter[entityConfig.OWNER_PARENT_ID_FIELD_NAME] = parsedFilter.ownerParentId;\n if (entityConfig.OWNER_PARENT_ID_FIELD_NAME !== \"ownerParentId\") delete parsedFilter.ownerParentId;\n }\n\n if (parsedFilter.profileId && entityConfig.OWNER_ID_FIELD_NAME) {\n parsedFilter[entityConfig.OWNER_ID_FIELD_NAME] = parsedFilter.profileId;\n if (entityConfig.OWNER_ID_FIELD_NAME !== \"profileId\") delete parsedFilter.profileId;\n }\n\n if (parsedFilter.ownerId && entityConfig.OWNER_ID_FIELD_NAME) {\n parsedFilter[entityConfig.OWNER_ID_FIELD_NAME] = parsedFilter.ownerId;\n if (entityConfig.OWNER_ID_FIELD_NAME !== \"ownerId\") delete parsedFilter.ownerId;\n }\n log.debug(\"parsedFilter\", parsedFilter);\n\n return parsedFilter;\n }\n private setSystemData(itemNew: Partial<T>, action: Action, requestUser?: string | CognitoUser, itemOld?: T): T {\n if (!action || action === Action.DELETE || action === Action.READ) return itemNew as T;\n\n const date = dayjs().toISOString();\n const user = this.extractUser(requestUser);\n\n switch (action) {\n case Action.CREATE:\n return this.handleCreate(itemNew, user, date);\n case Action.UPDATE:\n return this.handleUpdate(itemNew, itemOld, user, date);\n default:\n return itemNew as T;\n }\n }\n\n private extractUser(requestUser: string | CognitoUser): string {\n if (!requestUser) return undefined;\n\n if (typeof requestUser === \"string\") return requestUser;\n\n return requestUser.username;\n }\n\n private handleCreate(entity: Partial<T>, user: string, date: string): T {\n const dayjsData = dayjs(new Date(date));\n\n const noIdExist = entity[this.config.DYNAMO_DB.MAP.partitionKey ?? \"id\"] === undefined;\n if (noIdExist) entity[this.config.DYNAMO_DB.MAP.partitionKey ?? \"id\"] = crypto.randomUUID();\n\n entity.createdAt = date;\n if (user) entity.createdBy = user;\n entity.year = dayjsData.year().toString();\n entity.yearMonth = dayjsData.format(\"YYYY-MM\");\n\n if (!entity.updatedAt) {\n entity.updatedAt = entity.createdAt;\n }\n\n if (!this.config.TRACE_CHANGE?.fields) return entity as T;\n\n entity.history = this.addHistory(entity.history, { action: Action.CREATE, user, date });\n return entity as T;\n }\n\n private handleUpdate(entity: Partial<T>, itemOld: T | undefined, user: string, date: string): T {\n if (user) entity.updatedBy = user;\n entity.history = entity.history || itemOld?.history;\n\n entity.updatedAt = date;\n\n if (!this.config.TRACE_CHANGE?.fields || !itemOld) {\n return entity as T;\n }\n\n const changes = computeChangedFields(itemOld, entity, this.config.TRACE_CHANGE);\n if (changes.length > 0) {\n entity.history = this.addHistory(entity.history, {\n action: Action.UPDATE,\n user,\n date,\n changes,\n });\n }\n\n return entity as T;\n }\n\n private addHistory(history: ChangeHistory[] | undefined, entry: ChangeHistory): ChangeHistory[] {\n // skip empty or invalid history entries\n if (!entry.changes || entry.changes.length === 0) {\n return history || [];\n }\n\n // clone to avoid accidental mutation\n const newHistory = [...(history || [])];\n\n // optional: limit max history size (e.g., last 100 changes)\n const MAX_HISTORY_ENTRIES = 100;\n if (newHistory.length >= MAX_HISTORY_ENTRIES) {\n newHistory.shift(); // remove oldest\n }\n\n newHistory.push(entry);\n return newHistory;\n }\n\n private setIndexField(filter: Filter, config: EntityConfig) {\n if (!filter.indexName || !filter.indexValue) return filter;\n\n const indexMap = config.DYNAMO_DB.MAP;\n if (!indexMap || indexMap.size === 0) return filter;\n\n const indexConfig = indexMap.get(filter.indexName);\n if (!indexConfig) return filter;\n\n filter.indexName = indexConfig.field;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"crud.service.js","sourceRoot":"","sources":["../../src/service/crud.service.ts"],"names":[],"mappings":";;;;;;AAAA,oCAgBkB;AAClB,4CAAoF;AAIpF,kDAA0B;AAC1B,6EAA2E;AAE3E,MAAsB,eAAe;IAKzB,MAAM,CAAI;IACV,MAAM,CAAI;IACV,MAAM,CAAe;IAE/B,YAAsB,MAAS,EAAE,MAAS;QACxC,IAAI,MAAM,IAAI,IAAI,IAAI,CAAC,CAAC,MAAM,YAAY,sBAAc,CAAC;YACvD,OAAO,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;QAE/D,IAAI,MAAM,IAAI,IAAI,IAAI,CAAC,CAAC,MAAM,YAAY,sB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oC,EAAE,KAAoB;QAC3E,wCAAwC;QACxC,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjD,OAAO,OAAO,IAAI,EAAE,CAAC;QACvB,CAAC;QAED,qCAAqC;QACrC,MAAM,UAAU,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;QAExC,4DAA4D;QAC5D,MAAM,mBAAmB,GAAG,GAAG,CAAC;QAChC,IAAI,UAAU,CAAC,MAAM,IAAI,mBAAmB,EAAE,CAAC;YAC7C,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,gBAAgB;QACtC,CAAC;QAED,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,OAAO,UAAU,CAAC;IACpB,CAAC;IAEO,aAAa,CAAC,MAAc,EAAE,MAAoB;QACxD,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,UAAU;YAAE,OAAO,MAAM,CAAC;QAE3D,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC;QACtC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC;YAAE,OAAO,MAAM,CAAC;QAEpD,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACnD,IAAI,CAAC,WAAW;YAAE,OAAO,MAAM,CAAC;QAEhC,MAAM,CAAC,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC;IACvC,CAAC;CACF;AAvlBD,0CAulBC","sourcesContent":["import {\n Action,\n BaseEntity,\n BaseRepoDB,\n BaseRepoDBImpl,\n BaseRepoES,\n BaseRepoESImpl,\n ChangeHistory,\n CognitoUser,\n computeChangedFields,\n DynamoIndexMap,\n Filter,\n List,\n parseFilter,\n parseIndexFilter,\n removeFields,\n} from \"../index\";\nimport { ErrorBase, ErrorDynamoDB, ErrorHttp, ErrorValidation } from \"../exception\";\n\nimport { EntityConfig } from \"@chinggis/types\";\nimport { CrudService } from \"./crud.service.interface\";\nimport dayjs from \"dayjs\";\nimport { buildSearchQueryOS } from \"../utils/opensearch/opensearch.parser\";\n\nexport abstract class CrudServiceImpl<\n T extends BaseEntity,\n D extends BaseRepoDB<T>,\n S extends BaseRepoES<T>,\n> implements CrudService<T> {\n protected repoDB: D;\n protected repoES: S;\n protected config: EntityConfig;\n\n protected constructor(repoDB: D, repoES: S) {\n if (repoDB != null && !(repoDB instanceof BaseRepoDBImpl))\n console.error(\"repoDB is not an instance of BaseRepoDBImpl\");\n\n if (repoES != null && !(repoES instanceof BaseRepoESImpl))\n console.error(\"repoES is not an instance of BaseRepoESImpl\");\n\n if (repoDB == null && repoES == null) console.error(\"repo initialization is required\");\n\n this.repoDB = repoDB;\n this.repoES = repoES;\n }\n\n getTableName(): string {\n return this.repoDB.getTableName();\n }\n\n async findQuery(queryParams: string): Promise<List<Partial<T>>> {\n const filter = parseIndexFilter(queryParams, this.getIndexMapDB());\n this.checkIsIndexedField(filter);\n return await this.find(filter);\n }\n\n async deleteFields(entityId: string, fields: string[]): Promise<Partial<T>> {\n return this.repoDB.deleteFields(entityId, fields);\n }\n\n async searchQuery(\n queryParams: any,\n debug?: boolean,\n ): Promise<{ items: Partial<T>[]; total: number; aggs?: Record<string, any> }> {\n const query = buildSearchQueryOS(queryParams, this.config);\n\n return await this.repoES.search(query, debug);\n }\n\n async searchQueryTotalCount(queryParams: any): Promise<number> {\n const query = buildSearchQueryOS(queryParams, this.config);\n\n return this.repoES.count(query);\n }\n\n async incrementValueByField(entityId: string, fieldName: string, value?: number): Promise<T> {\n return await this.repoDB.incrementValueByField(entityId, fieldName, value);\n }\n\n async decrementValueByField(entityId: string, fieldName: string, value?: number): Promise<T> {\n return await this.repoDB.decrementValueByField(entityId, fieldName, value);\n }\n\n async search(filter: Filter | string): Promise<List<Partial<T>>> {\n if (typeof filter === \"string\") filter = parseIndexFilter(filter, this.getIndexMapDB());\n\n let parsedFilter = this.parseOwnerFields(filter, this.config);\n parsedFilter = this.setIndexField(parsedFilter, this.config);\n\n return this.repoES.find(parsedFilter);\n }\n\n async searchFieldNotExist(fieldName: string, from: number, size: number): Promise<Partial<T>[]> {\n return await this.repoES.fieldNotExists(fieldName, from, size);\n }\n\n async save(entity: Partial<T>, ownerId: string, parentId?: string, createdByUser?: string | CognitoUser): Promise<T> {\n entity = this.setSystemData(entity, Action.CREATE, createdByUser);\n\n if (ownerId && this.config.OWNER_ID_FIELD_NAME) entity[this.config.OWNER_ID_FIELD_NAME] = ownerId;\n\n if (parentId && this.config.OWNER_PARENT_ID_FIELD_NAME) entity[this.config.OWNER_PARENT_ID_FIELD_NAME] = parentId;\n\n return await this.repoDB.save(entity);\n }\n\n async saveAll(\n entities: Partial<T>[],\n ownerId: string,\n parentId?: string,\n createdByUser?: string | CognitoUser,\n isTransactional?: boolean,\n ): Promise<Partial<T>[]> {\n const entitiesUpdated = [];\n\n for (const item of entities) {\n // const entity = addDatesAndId(item);\n const entity = this.setSystemData(item, Action.CREATE, createdByUser || ownerId);\n\n if (parentId && this.config.OWNER_PARENT_ID_FIELD_NAME) entity[this.config.OWNER_PARENT_ID_FIELD_NAME] = parentId;\n\n if (ownerId && this.config.OWNER_ID_FIELD_NAME) entity[this.config.OWNER_ID_FIELD_NAME] = ownerId;\n\n entitiesUpdated.push(entity);\n }\n\n return await this.repoDB.saveMany(entitiesUpdated, isTransactional);\n }\n\n async update(entity: Partial<T>, requestUser?: CognitoUser, fields?: string[]): Promise<T> {\n const fieldName = this.config.DYNAMO_DB?.MAP?.partitionKey ?? \"id\";\n if (fields && fields.length > 0) fields.push(fieldName);\n if (fields && fields.length > 0) entity = removeFields([entity], fields)[0];\n\n if (!entity || !entity[fieldName]) throw new ErrorHttp({ code: 400, error: \"BadRequest\" }, `id required`);\n\n const item = await this.repoDB.findById(entity[fieldName]);\n\n if (!entity || !item) throw new ErrorHttp({ code: 400, error: \"BadRequest\" }, `id not found`);\n\n if (\n requestUser &&\n !requestUser.isScope &&\n !requestUser.isAdmin &&\n (item[this.config.OWNER_ID_FIELD_NAME] !== requestUser.profile ||\n item[this.config.OWNER_PARENT_ID_FIELD_NAME] !== requestUser.parentId)\n )\n throw new ErrorHttp({ code: 403, error: \"PermissionDenied\" }, `No permission to resource: ${entity.id}`);\n\n entity = this.setSystemData(entity, Action.UPDATE, requestUser, item);\n\n // if (!hasPermission(entity, userId, Permission.UPDATE)) throw new Error(\"Unauthorized access\");\n return this.repoDB.update(entity);\n }\n\n async updateAll(\n entities: Partial<T>[],\n fields: string[],\n requestUser?: CognitoUser,\n isTransactional?: boolean,\n ): Promise<boolean> {\n if (requestUser) log.warn(\"this methode is under development, cannot check ownership by updateAll\");\n\n return this.repoDB.updateMany(entities, fields, isTransactional);\n }\n\n async updateFields(entity: Partial<T>, fields: string[], requestUser?: CognitoUser): Promise<Partial<T>> {\n if (!entity || !fields?.length) return entity;\n return this.repoDB.updateFields(entity, [...fields]);\n }\n\n async remove(entityId: string, requestUser?: CognitoUser): Promise<boolean> {\n if (!entityId) throw new Error(\"Entity id required\");\n\n if (requestUser && requestUser.isAdmin) return await this.repoDB.delete(entityId);\n\n const entity = await this.repoDB.findById(entityId);\n if (!entity) throw new Error(\"Entity not found\");\n\n if (\n requestUser &&\n !requestUser.isScope &&\n (entity[this.config.OWNER_ID_FIELD_NAME] !== requestUser.profile ||\n entity[this.config.OWNER_PARENT_ID_FIELD_NAME] !== requestUser.parentId)\n )\n throw new ErrorHttp({ code: 403, error: \"PermissionDenied\" }, `No permission to resource: ${entity.id}`);\n\n return await this.repoDB.delete(entityId);\n }\n\n async removeAll(entityIds: string[], requestUser?: CognitoUser): Promise<boolean> {\n if (requestUser) log.warn(\"this methode is under development, cannot check ownership by removeAll\");\n return await this.repoDB.deleteMany(entityIds);\n }\n\n async removeMatch(filter: Filter | string, requestUser?: CognitoUser): Promise<boolean> {\n const { items } = await this.find(filter);\n if (items.length === 0) return true;\n\n return this.removeAll(\n items.map((item) => item.id),\n requestUser,\n );\n }\n\n async changeOwner(entityId: string, ownerId: string): Promise<T> {\n const entity = await this.repoDB.findById(entityId);\n entity[this.config.OWNER_ID_FIELD_NAME] = ownerId;\n return this.repoDB.update(entity);\n }\n\n setTable(tableName: string, dynamoIndexMap: DynamoIndexMap): boolean {\n this.repoDB.setTable(tableName);\n this.repoDB.setIndexMap(dynamoIndexMap);\n return true;\n }\n\n setOpensearch(indexName: string, opensearchEndpoint: string): boolean {\n this.repoES.setIndexName(indexName);\n this.repoES.setEndpoint(opensearchEndpoint);\n return true;\n }\n\n getIndexES(): string {\n return this.repoES.getIndexName();\n }\n\n getIndexMapDB(): DynamoIndexMap {\n return this.repoDB.getIndexMap();\n }\n\n setIndexMapDB(indexMap: DynamoIndexMap): boolean {\n this.repoDB.setIndexMap(indexMap);\n return true;\n }\n\n async findAll(): Promise<T[]> {\n const result: T[] = [];\n\n const filter = parseIndexFilter(\"size=250\");\n\n do {\n const response = await this.repoDB.find(filter);\n result.push(...(response.items as T[]));\n filter.lastKey = response.lastKey;\n } while (filter.lastKey);\n\n return result;\n }\n\n async findAllMatch(filter: Filter | string): Promise<T[]> {\n if (typeof filter === \"string\") filter = parseIndexFilter(filter, this.getIndexMapDB());\n this.checkIsIndexedField(filter);\n return await this.fetchAll(filter);\n }\n\n async findAllByIndex(indexName: string, indexValue: any): Promise<T[]> {\n // Create a filter object for validation\n const filter = { indexName: indexName, indexValue: indexValue };\n this.checkIsIndexedField(filter);\n\n const parsedFilter = parseIndexFilter(filter, this.getIndexMapDB());\n return this.fetchAll(parsedFilter);\n }\n\n async findByField(fieldName: string, fieldValue: any): Promise<List<T>> {\n // Create a filter object for validation\n const filter = { [fieldName]: fieldValue, size: 100 };\n this.checkIsIndexedField(filter);\n const parsedFilter = parseIndexFilter(fieldName + \"=\" + fieldValue + \"&size=100\", this.getIndexMapDB());\n return (await this.find(parsedFilter)) as List<T>;\n }\n\n async findFirst(fieldName: string, fieldValue: string | boolean | number | Date): Promise<T> {\n // Validate that the field name exists in the index map\n const filter = { [fieldName]: fieldValue };\n this.checkIsIndexedField(filter);\n\n const result = await this.findByField(fieldName, fieldValue);\n return result.items.length > 0 ? result.items[0] : null;\n }\n\n async find(filter: Filter | string): Promise<List<Partial<T>>> {\n if (typeof filter === \"string\") filter = parseIndexFilter(filter, this.getIndexMapDB());\n // Validate that all field names in the filter exist in the index map\n let parsedFilter = this.parseOwnerFields(filter, this.config);\n\n this.checkIsIndexedField(parsedFilter);\n\n parsedFilter = parseIndexFilter(filter, this.getIndexMapDB());\n return await this.repoDB.find(parsedFilter);\n }\n\n async *findStream(filter: string, size?: number): AsyncGenerator<T> {\n let lastKey: string = \"\";\n const pageSize = size ?? 50;\n\n do {\n const filterStr = `lastkey=${lastKey}&size=${pageSize}&${filter}`;\n const itemList = await this.findQuery(filterStr);\n\n yield* itemList.items as T[];\n\n lastKey = itemList.lastKey;\n } while (lastKey);\n }\n\n async *searchStream(filter: string, size?: number): AsyncGenerator<T> {\n let pageNumber = 1;\n const pageSize = size ?? 50;\n\n while (true) {\n const filterStr = `page=${pageNumber++}&size=${pageSize}&${filter}`;\n const resultList = await this.searchQuery(filterStr);\n yield* resultList.items as T[];\n if (resultList.items.length < pageSize) break;\n }\n }\n\n async *searchStreamAggr(\n filter: string,\n size?: number,\n ): AsyncGenerator<{ items: Partial<T>[]; total: number; aggs?: Record<string, any> }> {\n let pageNumber = 1;\n const pageSize = size ?? 50;\n\n while (true) {\n const filterStr = `page=${pageNumber++}&size=${pageSize}&${filter}`;\n const resultList = await this.searchQuery(filterStr);\n yield resultList;\n if (resultList.items.length < pageSize) break;\n }\n }\n\n async findById(entityId: string, requestUser?: CognitoUser): Promise<T> {\n const entity = await this.repoDB.findById(entityId);\n\n if (!entity) return null;\n\n if (!requestUser || requestUser.isAdmin) return entity;\n\n const isOwnerParent = entity[this.config.OWNER_PARENT_ID_FIELD_NAME] == requestUser.profile;\n const isParent = entity[this.config.OWNER_ID_FIELD_NAME] == requestUser.profile;\n\n if (!requestUser.profile || isOwnerParent || isParent) {\n return entity;\n }\n\n return null;\n }\n\n async findByIds(entityIds: string[], requestUser?: CognitoUser): Promise<T[]> {\n if (entityIds.length > 25) throw new ErrorDynamoDB(this.getTableName(), \"findByIds\", \"Too many entities\");\n\n const entities = await this.repoDB.findByIds(entityIds);\n\n if (!requestUser || requestUser.isAdmin) return entities;\n\n const ownEntities = [];\n for (const entity of entities) {\n if (\n entity[this.config.OWNER_PARENT_ID_FIELD_NAME] == requestUser.profile ||\n entity[this.config.OWNER_ID_FIELD_NAME] == requestUser.profile\n ) {\n ownEntities.push(entity);\n }\n }\n return ownEntities;\n }\n\n async scan(filter: Filter): Promise<List<Partial<T>>> {\n this.checkIsIndexedField(filter);\n const parsedFilter = parseIndexFilter(filter, this.getIndexMapDB());\n return await this.repoDB.scan(parsedFilter);\n }\n\n throwErrorHttp(error: { message: string; code: number }, message?: string, errorContent?: any): void {\n throw new ErrorHttp({ code: error.code, error: error.message }, message, errorContent);\n }\n\n throwErrorsHttp(code: number, message: string, errorContent?: any): void {\n throw new ErrorHttp({ code, error: message }, message, errorContent);\n }\n\n throwErrorDatabase(tableName: string, command: any, errorContent?: any): void {\n throw new ErrorDynamoDB(tableName, command, errorContent);\n }\n\n throwErrorValidation(entityName: string, validation: Map<string, any>, errorContent?: any): void {\n throw new ErrorValidation(entityName, validation, errorContent);\n }\n\n throwError(code: number, message: string, errorContent?: any): void {\n throw new ErrorBase(code, message, errorContent);\n }\n\n setConfig(config: EntityConfig) {\n this.config = config;\n\n if (this.repoDB) {\n this.repoDB.setIndexMap(config.DYNAMO_DB?.MAP);\n this.repoDB.setTable(config.DYNAMO_DB?.NAME);\n }\n\n if (this.repoES) {\n this.repoES.setEndpoint(config.OPEN_SEARCH.DOMAIN);\n this.repoES.setIndexName(config.OPEN_SEARCH.INDEX);\n }\n }\n\n /**\n * Validates that all field names in the filter exist in the index map.\n * Throws a Bad Request error if any field is not found in the available indexes.\n *\n * @param filter - The filter object containing field names to validate\n * @throws ErrorHttp with status 400 if validation fails\n */\n private checkIsIndexedField(filter: Filter): void {\n if (!filter || typeof filter !== \"object\") {\n return; // Skip validation for invalid filters\n }\n\n const indexMap = this.getIndexMapDB();\n if (!indexMap || indexMap.size === 0) {\n throw new ErrorHttp({ code: 400, error: \"Bad Request\" }, \"No indexes configured for this table\");\n }\n\n // Get all valid field names from all indexes\n const validFields = new Set<string>();\n\n // Add a partition key\n if (indexMap.partitionKey) {\n validFields.add(indexMap.partitionKey);\n }\n\n // Add fields from all indexes\n for (const [indexName, indexConfig] of indexMap.entries()) {\n if (indexConfig.field) {\n validFields.add(indexConfig.field);\n }\n if (indexConfig.rFields) {\n indexConfig.rFields.forEach((field) => validFields.add(field));\n }\n if (indexConfig.sortKeyField) {\n validFields.add(indexConfig.sortKeyField);\n }\n }\n\n // Check each field in the filter\n const invalidFields: string[] = [];\n for (const fieldName of Object.keys(filter)) {\n // Skip special filter properties that are not field names\n if (\n [\"indexName\", \"indexValue\", \"size\", \"lastKey\", \"fieldsInclude\", \"fieldsExclude\", \"rangeFilters\"].includes(\n fieldName,\n )\n ) {\n continue;\n }\n\n // Skip range filter fields (ageMin, ageMax, etc.)\n const rangeSuffixes = [\"Min\", \"Max\", \"From\", \"To\", \"Start\", \"End\"];\n const isRangeField = rangeSuffixes.some((suffix) => fieldName.endsWith(suffix));\n if (isRangeField) {\n continue;\n }\n\n if (!validFields.has(fieldName)) {\n invalidFields.push(fieldName);\n }\n }\n\n if (invalidFields.length > 0) {\n const availableFields = Array.from(validFields).sort();\n throw new ErrorHttp(\n { code: 400, error: \"Bad Request\" },\n `Invalid field names in filter: ${invalidFields.join(\", \")}. Available fields: ${availableFields.join(\", \")}`,\n );\n }\n }\n\n private async fetchAll(filter: Filter | string): Promise<T[]> {\n if (typeof filter === \"string\") filter = parseFilter(filter);\n\n const result: Partial<T>[] = [];\n do {\n const response = await this.repoDB.find(filter);\n result.push(...response.items);\n filter.lastKey = response.lastKey;\n } while (filter.lastKey);\n\n return result as T[];\n }\n\n private parseOwnerFields(filter: Filter, entityConfig: EntityConfig) {\n if (!filter) return null;\n\n const parsedFilter = filter;\n\n log.debug(\"input filter\", parsedFilter);\n\n if (parsedFilter.ownerParentId && !entityConfig.OWNER_PARENT_ID_FIELD_NAME) {\n parsedFilter.profileId = parsedFilter.ownerParentId;\n delete parsedFilter.ownerParentId;\n }\n if (!parsedFilter.profileId) delete parsedFilter.profileId;\n\n if (parsedFilter.ownerParentId && entityConfig.OWNER_PARENT_ID_FIELD_NAME) {\n parsedFilter[entityConfig.OWNER_PARENT_ID_FIELD_NAME] = parsedFilter.ownerParentId;\n if (entityConfig.OWNER_PARENT_ID_FIELD_NAME !== \"ownerParentId\") delete parsedFilter.ownerParentId;\n }\n\n if (parsedFilter.profileId && entityConfig.OWNER_ID_FIELD_NAME) {\n parsedFilter[entityConfig.OWNER_ID_FIELD_NAME] = parsedFilter.profileId;\n if (entityConfig.OWNER_ID_FIELD_NAME !== \"profileId\") delete parsedFilter.profileId;\n }\n\n if (parsedFilter.ownerId && entityConfig.OWNER_ID_FIELD_NAME) {\n parsedFilter[entityConfig.OWNER_ID_FIELD_NAME] = parsedFilter.ownerId;\n if (entityConfig.OWNER_ID_FIELD_NAME !== \"ownerId\") delete parsedFilter.ownerId;\n }\n log.debug(\"parsedFilter\", parsedFilter);\n\n return parsedFilter;\n }\n private setSystemData(itemNew: Partial<T>, action: Action, requestUser?: string | CognitoUser, itemOld?: T): T {\n if (!action || action === Action.DELETE || action === Action.READ) return itemNew as T;\n\n const date = dayjs().toISOString();\n const user = this.extractUser(requestUser);\n\n switch (action) {\n case Action.CREATE:\n return this.handleCreate(itemNew, user, date);\n case Action.UPDATE:\n return this.handleUpdate(itemNew, itemOld, user, date);\n default:\n return itemNew as T;\n }\n }\n\n private extractUser(requestUser: string | CognitoUser): string {\n if (!requestUser) return undefined;\n\n if (typeof requestUser === \"string\") return requestUser;\n\n return requestUser.username;\n }\n\n private handleCreate(entity: Partial<T>, user: string, date: string): T {\n const dayjsData = dayjs(new Date(date));\n\n const noIdExist = entity[this.config.DYNAMO_DB.MAP.partitionKey ?? \"id\"] === undefined;\n if (noIdExist) entity[this.config.DYNAMO_DB.MAP.partitionKey ?? \"id\"] = crypto.randomUUID();\n\n entity.createdAt = date;\n if (user) entity.createdBy = user;\n entity.year = dayjsData.year().toString();\n entity.yearMonth = dayjsData.format(\"YYYY-MM\");\n\n if (!entity.updatedAt) {\n entity.updatedAt = entity.createdAt;\n }\n\n if (!this.config.TRACE_CHANGE?.fields) return entity as T;\n\n entity.history = this.addHistory(entity.history, { action: Action.CREATE, user, date });\n return entity as T;\n }\n\n private handleUpdate(entity: Partial<T>, itemOld: T | undefined, user: string, date: string): T {\n if (user) entity.updatedBy = user;\n entity.history = entity.history || itemOld?.history;\n\n entity.updatedAt = date;\n\n if (!this.config.TRACE_CHANGE?.fields || !itemOld) {\n return entity as T;\n }\n\n const changes = computeChangedFields(itemOld, entity, this.config.TRACE_CHANGE);\n if (changes.length > 0) {\n entity.history = this.addHistory(entity.history, {\n action: Action.UPDATE,\n user,\n date,\n changes,\n });\n }\n\n return entity as T;\n }\n\n private addHistory(history: ChangeHistory[] | undefined, entry: ChangeHistory): ChangeHistory[] {\n // skip empty or invalid history entries\n if (!entry.changes || entry.changes.length === 0) {\n return history || [];\n }\n\n // clone to avoid accidental mutation\n const newHistory = [...(history || [])];\n\n // optional: limit max history size (e.g., last 100 changes)\n const MAX_HISTORY_ENTRIES = 100;\n if (newHistory.length >= MAX_HISTORY_ENTRIES) {\n newHistory.shift(); // remove oldest\n }\n\n newHistory.push(entry);\n return newHistory;\n }\n\n private setIndexField(filter: Filter, config: EntityConfig) {\n if (!filter.indexName || !filter.indexValue) return filter;\n\n const indexMap = config.DYNAMO_DB.MAP;\n if (!indexMap || indexMap.size === 0) return filter;\n\n const indexConfig = indexMap.get(filter.indexName);\n if (!indexConfig) return filter;\n\n filter.indexName = indexConfig.field;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aws-service-stack",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.421",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"author": "chinggis.systems",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"reflect-metadata": "^0.2.2"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@aws-sdk/client-apigatewaymanagementapi": "^3.
|
|
30
|
-
"@aws-sdk/client-cognito-identity-provider": "^3.
|
|
31
|
-
"@aws-sdk/client-dynamodb": "^3.
|
|
32
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
|
29
|
+
"@aws-sdk/client-apigatewaymanagementapi": "^3.1030.0",
|
|
30
|
+
"@aws-sdk/client-cognito-identity-provider": "^3.1030.0",
|
|
31
|
+
"@aws-sdk/client-dynamodb": "^3.1030.0",
|
|
32
|
+
"@aws-sdk/client-secrets-manager": "^3.1030.0",
|
|
33
33
|
"@aws-sdk/credential-provider-node": "^3.972.30",
|
|
34
|
-
"@aws-sdk/lib-dynamodb": "^3.
|
|
34
|
+
"@aws-sdk/lib-dynamodb": "^3.1030.0",
|
|
35
35
|
"@aws-sdk/util-dynamodb": "^3.996.2",
|
|
36
36
|
"@opensearch-project/opensearch": "^3.5.1",
|
|
37
37
|
"axios": "^1.15.0",
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CONFIG_BRANCH = exports.BranchConfig = exports.path = void 0;
|
|
4
|
-
const core_1 = require("../../../index.js");
|
|
5
|
-
const branch_model_1 = require("src/_examples/model-shared/branch.model");
|
|
6
|
-
exports.path = "retailer/branches"; // url path base
|
|
7
|
-
// Branch configuration
|
|
8
|
-
class BranchConfig extends core_1.EntityConfigImpl {
|
|
9
|
-
constructor() {
|
|
10
|
-
// DYNAMODB
|
|
11
|
-
const tableName = "retailer-branch_DEV";
|
|
12
|
-
const indexMap = new core_1.DynamoIndexMap().set("byAccount", {
|
|
13
|
-
field: "accountId",
|
|
14
|
-
rFields: ["accountId"],
|
|
15
|
-
});
|
|
16
|
-
// PERMISSIONS
|
|
17
|
-
const ownerParentFieldName = "accountId";
|
|
18
|
-
const ownerFieldName = "username";
|
|
19
|
-
const adminGroupName = ["adminUsers"];
|
|
20
|
-
const policies = [
|
|
21
|
-
{
|
|
22
|
-
method: core_1.HttpMethod.GET,
|
|
23
|
-
path: `/${exports.path}`,
|
|
24
|
-
access: [core_1.Access.PUBLIC, core_1.Access.USER, core_1.Access.OWNER, core_1.Access.ADMIN],
|
|
25
|
-
response: branch_model_1.RESPONSE_FIELDS_LIST_BRANCH,
|
|
26
|
-
},
|
|
27
|
-
{ method: core_1.HttpMethod.GET, path: `/${exports.path}/{id}`, access: [core_1.Access.OWNER, core_1.Access.ADMIN], response: branch_model_1.RESPONSE_FIELDS_DETAILS_BRANCH },
|
|
28
|
-
{ method: core_1.HttpMethod.POST, path: `/${exports.path}`, access: [core_1.Access.USER, core_1.Access.ADMIN], validator: branch_model_1.CREATE_BRANCH },
|
|
29
|
-
{
|
|
30
|
-
method: core_1.HttpMethod.PUT,
|
|
31
|
-
path: `/${exports.path}/{id}`,
|
|
32
|
-
access: [core_1.Access.ADMIN],
|
|
33
|
-
validator: branch_model_1.REPLACE_BRANCH,
|
|
34
|
-
response: branch_model_1.RESPONSE_FIELDS_DETAILS_BRANCH,
|
|
35
|
-
},
|
|
36
|
-
{ method: core_1.HttpMethod.PATCH, path: `/${exports.path}/{id}`, access: [core_1.Access.USER, core_1.Access.ADMIN], validator: branch_model_1.UPDATE_BRANCH },
|
|
37
|
-
{ method: core_1.HttpMethod.DELETE, path: `/${exports.path}/{id}`, access: [core_1.Access.USER, core_1.Access.ADMIN] },
|
|
38
|
-
];
|
|
39
|
-
// INIT
|
|
40
|
-
super(exports.path, adminGroupName);
|
|
41
|
-
this.setDynamoDB(tableName, ownerFieldName, indexMap, ownerParentFieldName).setPolicies(policies);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.BranchConfig = BranchConfig;
|
|
45
|
-
// Export default Branch configuration
|
|
46
|
-
exports.CONFIG_BRANCH = new BranchConfig();
|
|
47
|
-
//# sourceMappingURL=branch-config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"branch-config.js","sourceRoot":"","sources":["../../../../src/_examples/controller/branch/branch-config.ts"],"names":[],"mappings":";;;AAAA,yCAAgH;AAChH,0EAMiD;AAEpC,QAAA,IAAI,GAAG,mBAAmB,CAAC,CAAC,gBAAgB;AAEzD,uBAAuB;AACvB,MAAa,YAAa,SAAQ,uBAAgB;IAChD;QACE,WAAW;QACX,MAAM,SAAS,GAAG,qBAAqB,CAAC;QACxC,MAAM,QAAQ,GAAG,IAAI,qBAAc,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE;YACrD,KAAK,EAAE,WAAW;YAClB,OAAO,EAAE,CAAC,WAAW,CAAC;SACvB,CAAC,CAAC;QAEH,cAAc;QACd,MAAM,oBAAoB,GAAG,WAAW,CAAC;QACzC,MAAM,cAAc,GAAG,UAAU,CAAC;QAClC,MAAM,cAAc,GAAG,CAAC,YAAY,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAqB;YACjC;gBACE,MAAM,EAAE,iBAAC,CAAC,GAAG;gBACb,IAAI,EAAE,IAAI,YAAI,EAAE;gBAChB,MAAM,EAAE,CAAC,aAAC,CAAC,MAAM,EAAE,aAAC,CAAC,IAAI,EAAE,aAAC,CAAC,KAAK,EAAE,aAAC,CAAC,KAAK,CAAC;gBAC5C,QAAQ,EAAE,0CAAQ;aACnB;YACD,EAAE,MAAM,EAAE,iBAAC,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,YAAI,OAAO,EAAE,MAAM,EAAE,CAAC,aAAC,CAAC,KAAK,EAAE,aAAC,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,6CAAQ,EAAE;YACxF,EAAE,MAAM,EAAE,iBAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,YAAI,EAAE,EAAE,MAAM,EAAE,CAAC,aAAC,CAAC,IAAI,EAAE,aAAC,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,4BAAM,EAAE;YAClF;gBACE,MAAM,EAAE,iBAAC,CAAC,GAAG;gBACb,IAAI,EAAE,IAAI,YAAI,OAAO;gBACrB,MAAM,EAAE,CAAC,aAAC,CAAC,KAAK,CAAC;gBACjB,SAAS,EAAE,6BAAO;gBAClB,QAAQ,EAAE,6CAAQ;aACnB;YACD,EAAE,MAAM,EAAE,iBAAC,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,YAAI,OAAO,EAAE,MAAM,EAAE,CAAC,aAAC,CAAC,IAAI,EAAE,aAAC,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,4BAAM,EAAE;YACxF,EAAE,MAAM,EAAE,iBAAC,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,YAAI,OAAO,EAAE,MAAM,EAAE,CAAC,aAAC,CAAC,IAAI,EAAE,aAAC,CAAC,KAAK,CAAC,EAAE;SACvE,CAAC;QAEF,OAAO;QACP,KAAK,CAAC,YAAI,EAAE,cAAc,CAAC,CAAC;QAC5B,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACpG,CAAC;CACF;AArCD,oCAqCC;AAED,sCAAsC;AACzB,QAAA,aAAa,GAAG,IAAI,YAAY,EAAE,CAAC","sourcesContent":["import { Access as a, DynamoIndexMap, EndpointPolicy, EntityConfigImpl, HttpMethod as m } from \"@chinggis/core\";\nimport {\n CREATE_BRANCH as CREATE,\n REPLACE_BRANCH as REPLACE,\n RESPONSE_FIELDS_DETAILS_BRANCH as FIELDS_D,\n RESPONSE_FIELDS_LIST_BRANCH as FIELDS_L,\n UPDATE_BRANCH as UPDATE,\n} from \"src/_examples/model-shared/branch.model\";\n\nexport const path = \"retailer/branches\"; // url path base\n\n// Branch configuration\nexport class BranchConfig extends EntityConfigImpl {\n constructor() {\n // DYNAMODB\n const tableName = \"retailer-branch_DEV\";\n const indexMap = new DynamoIndexMap().set(\"byAccount\", {\n field: \"accountId\",\n rFields: [\"accountId\"],\n });\n\n // PERMISSIONS\n const ownerParentFieldName = \"accountId\";\n const ownerFieldName = \"username\";\n const adminGroupName = [\"adminUsers\"];\n const policies: EndpointPolicy[] = [\n {\n method: m.GET,\n path: `/${path}`,\n access: [a.PUBLIC, a.USER, a.OWNER, a.ADMIN],\n response: FIELDS_L,\n },\n { method: m.GET, path: `/${path}/{id}`, access: [a.OWNER, a.ADMIN], response: FIELDS_D },\n { method: m.POST, path: `/${path}`, access: [a.USER, a.ADMIN], validator: CREATE },\n {\n method: m.PUT,\n path: `/${path}/{id}`,\n access: [a.ADMIN],\n validator: REPLACE,\n response: FIELDS_D,\n },\n { method: m.PATCH, path: `/${path}/{id}`, access: [a.USER, a.ADMIN], validator: UPDATE },\n { method: m.DELETE, path: `/${path}/{id}`, access: [a.USER, a.ADMIN] },\n ];\n\n // INIT\n super(path, adminGroupName);\n this.setDynamoDB(tableName, ownerFieldName, indexMap, ownerParentFieldName).setPolicies(policies);\n }\n}\n\n// Export default Branch configuration\nexport const CONFIG_BRANCH = new BranchConfig();\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { APIGatewayProxyWebsocketEventV2, DynamoDBStreamEvent, ScheduledEvent, SQSEvent } from "aws-lambda";
|
|
2
|
-
import { ControllerApi } from "src/controller";
|
|
3
|
-
import { HttpRequest } from "src/utils";
|
|
4
|
-
import { RBranch } from "src/_examples/model-shared/branch.model";
|
|
5
|
-
import "src/_examples/service/raccount/raccount-service";
|
|
6
|
-
import { RBranchService } from "src/_examples/service/branch/branch-service.interface";
|
|
7
|
-
import "src/_examples/service/branch/branch-service";
|
|
8
|
-
export declare class RBranchController extends ControllerApi<RBranch, RBranchService> {
|
|
9
|
-
private readonly rAccountService;
|
|
10
|
-
constructor();
|
|
11
|
-
protected processCrudRequest(event: HttpRequest): Promise<any>;
|
|
12
|
-
protected processSQSEvent(sqsEvent: SQSEvent): Promise<any>;
|
|
13
|
-
protected processStreamEvent(event: DynamoDBStreamEvent): Promise<void>;
|
|
14
|
-
protected processScheduledEvent(event: ScheduledEvent): Promise<void>;
|
|
15
|
-
protected processWebSocketEvent(event: APIGatewayProxyWebsocketEventV2): Promise<void>;
|
|
16
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.RBranchController = void 0;
|
|
46
|
-
const controller_1 = require("src/controller");
|
|
47
|
-
const typedi_1 = __importStar(require("typedi"));
|
|
48
|
-
const branch_config_1 = require("./branch-config");
|
|
49
|
-
require("src/_examples/service/raccount/raccount-service");
|
|
50
|
-
require("src/_examples/service/branch/branch-service");
|
|
51
|
-
let RBranchController = class RBranchController extends controller_1.ControllerApi {
|
|
52
|
-
rAccountService = typedi_1.default.get("RAccountService");
|
|
53
|
-
constructor() {
|
|
54
|
-
super(typedi_1.default.get("RBranchService"), branch_config_1.CONFIG_BRANCH.toObject());
|
|
55
|
-
}
|
|
56
|
-
processCrudRequest(event) {
|
|
57
|
-
throw new Error("Method not implemented.");
|
|
58
|
-
}
|
|
59
|
-
processSQSEvent(sqsEvent) {
|
|
60
|
-
throw new Error("Method not implemented.");
|
|
61
|
-
}
|
|
62
|
-
async processStreamEvent(event) {
|
|
63
|
-
throw new Error("Method not implemented.");
|
|
64
|
-
}
|
|
65
|
-
async processScheduledEvent(event) {
|
|
66
|
-
throw new Error("Method not implemented.");
|
|
67
|
-
}
|
|
68
|
-
async processWebSocketEvent(event) {
|
|
69
|
-
throw new Error("Method not implemented.");
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
exports.RBranchController = RBranchController;
|
|
73
|
-
exports.RBranchController = RBranchController = __decorate([
|
|
74
|
-
(0, typedi_1.Service)("RBranchController"),
|
|
75
|
-
__metadata("design:paramtypes", [])
|
|
76
|
-
], RBranchController);
|
|
77
|
-
//# sourceMappingURL=branch-controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"branch-controller.js","sourceRoot":"","sources":["../../../../src/_examples/controller/branch/branch-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAA+C;AAE/C,iDAA4C;AAC5C,mDAAgD;AAQhD,2DAAyD;AAGzD,uDAAqD;AAG9C,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,0BAAsC;IAC1D,eAAe,GAAoB,gBAAS,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAErF;QACE,KAAK,CAAC,gBAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,6BAAa,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnE,CAAC;IAES,kBAAkB,CAAC,KAAkB;QAC7C,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAES,eAAe,CAAC,QAAkB;QAC1C,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAES,KAAK,CAAC,kBAAkB,CAAC,KAA0B;QAC3D,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAES,KAAK,CAAC,qBAAqB,CAAC,KAAqB;QACzD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAES,KAAK,CAAC,qBAAqB,CAAC,KAAsC;QAC1E,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;CACF,CAAA;AA1BY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,gBAAO,EAAC,mBAAmB,CAAC;;GAChB,iBAAiB,CA0B7B","sourcesContent":["import { APIGatewayProxyWebsocketEventV2, DynamoDBStreamEvent, ScheduledEvent, SQSEvent } from \"aws-lambda\";\nimport { ControllerApi } from \"src/controller\";\nimport { HttpRequest } from \"src/utils\";\nimport Container, { Service } from \"typedi\";\nimport { CONFIG_BRANCH } from \"./branch-config\";\n\nimport { RBranch } from \"src/_examples/model-shared/branch.model\";\n\n// import \"@retailer/services/raccount/raccount-service\";\n// import { RAccountService } from \"@retailer/services/raccount/raccount-service.interface\";\n\nimport { RAccountService } from \"src/_examples/service/raccount/raccount-service.interface\";\nimport \"src/_examples/service/raccount/raccount-service\";\n\nimport { RBranchService } from \"src/_examples/service/branch/branch-service.interface\";\nimport \"src/_examples/service/branch/branch-service\";\n\n@Service(\"RBranchController\")\nexport class RBranchController extends ControllerApi<RBranch, RBranchService> {\n private readonly rAccountService: RAccountService = Container.get(\"RAccountService\");\n\n constructor() {\n super(Container.get(\"RBranchService\"), CONFIG_BRANCH.toObject());\n }\n\n protected processCrudRequest(event: HttpRequest): Promise<any> {\n throw new Error(\"Method not implemented.\");\n }\n\n protected processSQSEvent(sqsEvent: SQSEvent): Promise<any> {\n throw new Error(\"Method not implemented.\");\n }\n\n protected async processStreamEvent(event: DynamoDBStreamEvent): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n protected async processScheduledEvent(event: ScheduledEvent): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n protected async processWebSocketEvent(event: APIGatewayProxyWebsocketEventV2): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n}\n"]}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.handler = void 0;
|
|
43
|
-
require("reflect-metadata");
|
|
44
|
-
const typedi_1 = __importStar(require("typedi"));
|
|
45
|
-
require("./branch-controller");
|
|
46
|
-
const handler = (event) => typedi_1.default.get(HelperCDI).process(event);
|
|
47
|
-
exports.handler = handler;
|
|
48
|
-
let HelperCDI = class HelperCDI {
|
|
49
|
-
controller = typedi_1.default.get("RBranchController");
|
|
50
|
-
async process(event) {
|
|
51
|
-
return this.controller.resolveCrudRequest(event);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
HelperCDI = __decorate([
|
|
55
|
-
(0, typedi_1.Service)()
|
|
56
|
-
], HelperCDI);
|
|
57
|
-
//# sourceMappingURL=branch-crud.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"branch-crud.js","sourceRoot":"","sources":["../../../../src/_examples/controller/branch/branch-crud.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA0B;AAC1B,iDAA4C;AAK5C,+BAA6B;AAEtB,MAAM,OAAO,GAAG,CAAC,KAA2B,EAAE,EAAE,CAAC,gBAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAAnF,QAAA,OAAO,WAA4E;AAGhG,IAAM,SAAS,GAAf,MAAM,SAAS;IACI,UAAU,GAAsB,gBAAS,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAEpF,KAAK,CAAC,OAAO,CAAC,KAA2B;QACvC,OAAO,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACnD,CAAC;CACF,CAAA;AANK,SAAS;IADd,IAAA,gBAAO,GAAE;GACJ,SAAS,CAMd","sourcesContent":["import \"reflect-metadata\";\nimport Container, { Service } from \"typedi\";\nimport { APIGatewayProxyEvent } from \"aws-lambda\";\n\n// Controller\nimport { RBranchController } from \"./branch-controller\";\nimport \"./branch-controller\";\n\nexport const handler = (event: APIGatewayProxyEvent) => Container.get(HelperCDI).process(event);\n\n@Service()\nclass HelperCDI {\n private readonly controller: RBranchController = Container.get(\"RBranchController\");\n\n async process(event: APIGatewayProxyEvent) {\n return this.controller.resolveCrudRequest(event);\n }\n}\n"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ControllerApi } from "src/controller";
|
|
2
|
-
import { HttpRequest } from "src/utils";
|
|
3
|
-
import { Commission } from "src/_examples/model-shared/commission.model";
|
|
4
|
-
import { CommissionService } from "src/_examples/service/commission/commission-service.interface";
|
|
5
|
-
import "src/_examples/service/commission/commission-service";
|
|
6
|
-
export declare class CommissionController extends ControllerApi<Commission, CommissionService> {
|
|
7
|
-
constructor();
|
|
8
|
-
protected processCrudRequest(req: HttpRequest): Promise<any>;
|
|
9
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.CommissionController = void 0;
|
|
46
|
-
const typedi_1 = __importStar(require("typedi"));
|
|
47
|
-
const controller_1 = require("src/controller");
|
|
48
|
-
const commission_config_1 = require("./commission.config");
|
|
49
|
-
require("src/_examples/service/commission/commission-service");
|
|
50
|
-
let CommissionController = class CommissionController extends controller_1.ControllerApi {
|
|
51
|
-
constructor() {
|
|
52
|
-
super(typedi_1.default.get("CommissionService"), commission_config_1.CONFIG_COMMISSION.toObject());
|
|
53
|
-
}
|
|
54
|
-
async processCrudRequest(req) {
|
|
55
|
-
if (req.resourcePath === `POST ${commission_config_1.path}/create`) {
|
|
56
|
-
const { supplierUsername, retailerUsername, toRetailerPercent } = req.body;
|
|
57
|
-
return await this.service.create(supplierUsername, retailerUsername, toRetailerPercent);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
exports.CommissionController = CommissionController;
|
|
62
|
-
exports.CommissionController = CommissionController = __decorate([
|
|
63
|
-
(0, typedi_1.Service)("CommissionController"),
|
|
64
|
-
__metadata("design:paramtypes", [])
|
|
65
|
-
], CommissionController);
|
|
66
|
-
//# sourceMappingURL=commission-controller.js.map
|