aws-service-stack 0.18.421 → 0.18.425
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/local-task-controller.d.ts +17 -0
- package/dist/_examples/controller/local-task-controller.d.ts.map +1 -0
- package/dist/_examples/controller/local-task-controller.js +87 -0
- package/dist/_examples/controller/local-task-controller.js.map +1 -0
- package/dist/_examples/controller/order/order-config.d.ts +7 -0
- package/dist/_examples/controller/order/order-config.d.ts.map +1 -0
- package/dist/_examples/controller/order/order-config.js +54 -0
- package/dist/_examples/controller/order/order-config.js.map +1 -0
- package/dist/_examples/controller/order/order-controller-cron.d.ts +8 -0
- package/dist/_examples/controller/order/order-controller-cron.d.ts.map +1 -0
- package/dist/_examples/controller/order/order-controller-cron.js +58 -0
- package/dist/_examples/controller/order/order-controller-cron.js.map +1 -0
- package/dist/_examples/controller/order/order-controller-streamer.d.ts +7 -0
- package/dist/_examples/controller/order/order-controller-streamer.d.ts.map +1 -0
- package/dist/_examples/controller/order/order-controller-streamer.js +60 -0
- package/dist/_examples/controller/order/order-controller-streamer.js.map +1 -0
- package/dist/_examples/controller/order/order-controller.d.ts +15 -0
- package/dist/_examples/controller/order/order-controller.d.ts.map +1 -0
- package/dist/_examples/controller/order/order-controller.js +121 -0
- package/dist/_examples/controller/order/order-controller.js.map +1 -0
- package/dist/_examples/controller/order/order-cron.d.ts +6 -0
- package/dist/_examples/controller/order/order-cron.d.ts.map +1 -0
- package/dist/_examples/controller/order/order-cron.js +57 -0
- package/dist/_examples/controller/order/order-cron.js.map +1 -0
- package/dist/_examples/controller/order/order-crud.d.ts +5 -0
- package/dist/_examples/controller/order/order-crud.d.ts.map +1 -0
- package/dist/_examples/controller/order/order-crud.js +57 -0
- package/dist/_examples/controller/order/order-crud.js.map +1 -0
- package/dist/_examples/controller/order/order-streamer.d.ts +5 -0
- package/dist/_examples/controller/order/order-streamer.d.ts.map +1 -0
- package/dist/_examples/controller/order/order-streamer.js +57 -0
- package/dist/_examples/controller/order/order-streamer.js.map +1 -0
- package/dist/_examples/controller/order-item/order-item-config.d.ts +7 -0
- package/dist/_examples/controller/order-item/order-item-config.d.ts.map +1 -0
- package/dist/_examples/controller/order-item/order-item-config.js +43 -0
- package/dist/_examples/controller/order-item/order-item-config.js.map +1 -0
- package/dist/_examples/controller/order-item/order-item-controller-streamer.d.ts +7 -0
- package/dist/_examples/controller/order-item/order-item-controller-streamer.d.ts.map +1 -0
- package/dist/_examples/controller/order-item/order-item-controller-streamer.js +60 -0
- package/dist/_examples/controller/order-item/order-item-controller-streamer.js.map +1 -0
- package/dist/_examples/controller/order-item/order-item-controller.d.ts +12 -0
- package/dist/_examples/controller/order-item/order-item-controller.d.ts.map +1 -0
- package/dist/_examples/controller/order-item/order-item-controller.js +78 -0
- package/dist/_examples/controller/order-item/order-item-controller.js.map +1 -0
- package/dist/_examples/controller/order-item/order-item-crud.d.ts +5 -0
- package/dist/_examples/controller/order-item/order-item-crud.d.ts.map +1 -0
- package/dist/_examples/controller/order-item/order-item-crud.js +57 -0
- package/dist/_examples/controller/order-item/order-item-crud.js.map +1 -0
- package/dist/_examples/controller/order-item/order-item-streamer.d.ts +5 -0
- package/dist/_examples/controller/order-item/order-item-streamer.d.ts.map +1 -0
- package/dist/_examples/controller/order-item/order-item-streamer.js +57 -0
- package/dist/_examples/controller/order-item/order-item-streamer.js.map +1 -0
- package/dist/_examples/controller/profile/profile-crud-simple.d.ts +1 -0
- package/dist/_examples/controller/profile/profile-crud-simple.d.ts.map +1 -0
- package/dist/_examples/controller/profile/profile-crud.d.ts +2 -1
- package/dist/_examples/controller/profile/profile-crud.d.ts.map +1 -0
- package/dist/_examples/controller/profile/profile.config.d.ts +1 -0
- package/dist/_examples/controller/profile/profile.config.d.ts.map +1 -0
- package/dist/_examples/controller/profile/profile.config.js +20 -45
- package/dist/_examples/controller/profile/profile.config.js.map +1 -1
- package/dist/_examples/controller/profile/profile.controller.d.ts +4 -3
- package/dist/_examples/controller/profile/profile.controller.d.ts.map +1 -0
- package/dist/_examples/controller/profile/profile.controller.js +10 -3
- package/dist/_examples/controller/profile/profile.controller.js.map +1 -1
- package/dist/_examples/model-shared/example.model.d.ts +1 -0
- package/dist/_examples/model-shared/example.model.d.ts.map +1 -0
- package/dist/_examples/model-shared/order.model.d.ts +74 -0
- package/dist/_examples/model-shared/order.model.d.ts.map +1 -0
- package/dist/_examples/model-shared/order.model.js +12 -0
- package/dist/_examples/model-shared/order.model.js.map +1 -0
- package/dist/_examples/repositories/order/order-db.repo.d.ts +8 -0
- package/dist/_examples/repositories/order/order-db.repo.d.ts.map +1 -0
- package/dist/_examples/repositories/order/order-db.repo.interface.d.ts +5 -0
- package/dist/_examples/repositories/order/order-db.repo.interface.d.ts.map +1 -0
- package/dist/_examples/repositories/order/order-db.repo.interface.js +3 -0
- package/dist/_examples/repositories/order/order-db.repo.interface.js.map +1 -0
- package/dist/_examples/repositories/order/order-db.repo.js +20 -0
- package/dist/_examples/repositories/order/order-db.repo.js.map +1 -0
- package/dist/_examples/repositories/order/order-item-db.repo.d.ts +8 -0
- package/dist/_examples/repositories/order/order-item-db.repo.d.ts.map +1 -0
- package/dist/_examples/repositories/order/order-item-db.repo.interface.d.ts +5 -0
- package/dist/_examples/repositories/order/order-item-db.repo.interface.d.ts.map +1 -0
- package/dist/_examples/repositories/order/order-item-db.repo.interface.js +3 -0
- package/dist/_examples/repositories/order/order-item-db.repo.interface.js.map +1 -0
- package/dist/_examples/repositories/order/order-item-db.repo.js +20 -0
- package/dist/_examples/repositories/order/order-item-db.repo.js.map +1 -0
- package/dist/_examples/repositories/profile/profile-repo-db.d.ts +1 -0
- package/dist/_examples/repositories/profile/profile-repo-db.d.ts.map +1 -0
- package/dist/_examples/repositories/profile/profile-repo-db.interface.d.ts +1 -0
- package/dist/_examples/repositories/profile/profile-repo-db.interface.d.ts.map +1 -0
- package/dist/_examples/service/order/order-item-service-stream.d.ts +13 -0
- package/dist/_examples/service/order/order-item-service-stream.d.ts.map +1 -0
- package/dist/_examples/service/order/order-item-service-stream.interface.d.ts +5 -0
- package/dist/_examples/service/order/order-item-service-stream.interface.d.ts.map +1 -0
- package/dist/_examples/service/order/order-item-service-stream.interface.js +3 -0
- package/dist/_examples/service/order/order-item-service-stream.interface.js.map +1 -0
- package/dist/_examples/service/order/order-item-service-stream.js +81 -0
- package/dist/_examples/service/order/order-item-service-stream.js.map +1 -0
- package/dist/_examples/service/order/order-item-service.d.ts +16 -0
- package/dist/_examples/service/order/order-item-service.d.ts.map +1 -0
- package/dist/_examples/service/order/order-item-service.interface.d.ts +14 -0
- package/dist/_examples/service/order/order-item-service.interface.d.ts.map +1 -0
- package/dist/_examples/service/order/order-item-service.interface.js +3 -0
- package/dist/_examples/service/order/order-item-service.interface.js.map +1 -0
- package/dist/_examples/service/order/order-item-service.js +120 -0
- package/dist/_examples/service/order/order-item-service.js.map +1 -0
- package/dist/_examples/service/order/order-service-stream.d.ts +12 -0
- package/dist/_examples/service/order/order-service-stream.d.ts.map +1 -0
- package/dist/_examples/service/order/order-service-stream.interface.d.ts +5 -0
- package/dist/_examples/service/order/order-service-stream.interface.d.ts.map +1 -0
- package/dist/_examples/service/order/order-service-stream.interface.js +3 -0
- package/dist/_examples/service/order/order-service-stream.interface.js.map +1 -0
- package/dist/_examples/service/order/order-service-stream.js +80 -0
- package/dist/_examples/service/order/order-service-stream.js.map +1 -0
- package/dist/_examples/service/order/order-service.d.ts +19 -0
- package/dist/_examples/service/order/order-service.d.ts.map +1 -0
- package/dist/_examples/service/order/order-service.interface.d.ts +14 -0
- package/dist/_examples/service/order/order-service.interface.d.ts.map +1 -0
- package/dist/_examples/service/order/order-service.interface.js +3 -0
- package/dist/_examples/service/order/order-service.interface.js.map +1 -0
- package/dist/_examples/service/order/order-service.js +127 -0
- package/dist/_examples/service/order/order-service.js.map +1 -0
- package/dist/_examples/service/profile-service.d.ts +3 -3
- package/dist/_examples/service/profile-service.d.ts.map +1 -0
- package/dist/_examples/service/profile-service.interface.d.ts +2 -1
- package/dist/_examples/service/profile-service.interface.d.ts.map +1 -0
- package/dist/_examples/service/profile-service.interface.js.map +1 -1
- package/dist/_examples/service/profile-service.js +14 -14
- package/dist/_examples/service/profile-service.js.map +1 -1
- package/dist/controller/base-controller.d.ts +1 -0
- package/dist/controller/base-controller.d.ts.map +1 -0
- package/dist/controller/base-controller.js +14 -13
- package/dist/controller/base-controller.js.map +1 -1
- package/dist/controller/controller-api.d.ts +1 -0
- package/dist/controller/controller-api.d.ts.map +1 -0
- package/dist/controller/controller-api.js +14 -14
- package/dist/controller/controller-api.js.map +1 -1
- package/dist/controller/controller-request.d.ts +1 -0
- package/dist/controller/controller-request.d.ts.map +1 -0
- package/dist/controller/controller-request.js +2 -2
- package/dist/controller/controller-request.js.map +1 -1
- package/dist/controller/controller-role.d.ts +1 -0
- package/dist/controller/controller-role.d.ts.map +1 -0
- package/dist/controller/controller-role.js +7 -5
- package/dist/controller/controller-role.js.map +1 -1
- package/dist/controller/controller-stream.d.ts +1 -0
- package/dist/controller/controller-stream.d.ts.map +1 -0
- package/dist/controller/index.d.ts +1 -0
- package/dist/controller/index.d.ts.map +1 -0
- package/dist/exception/errors.d.ts +28 -11
- package/dist/exception/errors.d.ts.map +1 -0
- package/dist/exception/errors.js +35 -8
- package/dist/exception/errors.js.map +1 -1
- package/dist/exception/exception-handler.d.ts +6 -0
- package/dist/exception/exception-handler.d.ts.map +1 -0
- package/dist/exception/exception-handler.js +3 -1
- package/dist/exception/exception-handler.js.map +1 -1
- package/dist/exception/index.d.ts +1 -0
- package/dist/exception/index.d.ts.map +1 -0
- package/dist/function/cognito/cognito.function.d.ts +1 -0
- package/dist/function/cognito/cognito.function.d.ts.map +1 -0
- package/dist/function/cognito/index.d.ts +1 -0
- package/dist/function/cognito/index.d.ts.map +1 -0
- package/dist/function/index.d.ts +1 -0
- package/dist/function/index.d.ts.map +1 -0
- package/dist/function/logger.d.ts +1 -0
- package/dist/function/logger.d.ts.map +1 -0
- package/dist/function/s3/index.d.ts +1 -0
- package/dist/function/s3/index.d.ts.map +1 -0
- package/dist/function/s3/s3.function.d.ts +1 -0
- package/dist/function/s3/s3.function.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/model/base.config.d.ts +1 -0
- package/dist/model/base.config.d.ts.map +1 -0
- package/dist/model/base.model.d.ts +1 -0
- package/dist/model/base.model.d.ts.map +1 -0
- package/dist/model/cognito-user.model.d.ts +1 -0
- package/dist/model/cognito-user.model.d.ts.map +1 -0
- package/dist/model/dynamodb.model.d.ts +1 -0
- package/dist/model/dynamodb.model.d.ts.map +1 -0
- package/dist/model/filter.model.d.ts +2 -0
- package/dist/model/filter.model.d.ts.map +1 -0
- package/dist/model/filter.model.js.map +1 -1
- package/dist/model/http.model.d.ts +1 -0
- package/dist/model/http.model.d.ts.map +1 -0
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/role.model.d.ts +6 -5
- package/dist/model/role.model.d.ts.map +1 -0
- package/dist/model/role.model.js.map +1 -1
- package/dist/model/validation.model.d.ts +1 -0
- package/dist/model/validation.model.d.ts.map +1 -0
- package/dist/provider/apigateway.d.ts +1 -0
- package/dist/provider/apigateway.d.ts.map +1 -0
- package/dist/provider/dynamodb.d.ts +1 -0
- package/dist/provider/dynamodb.d.ts.map +1 -0
- package/dist/provider/index.d.ts +1 -0
- package/dist/provider/index.d.ts.map +1 -0
- package/dist/provider/opensearch.d.ts +1 -0
- package/dist/provider/opensearch.d.ts.map +1 -0
- package/dist/repositories/base-core.repo.interface.d.ts +10 -4
- package/dist/repositories/base-core.repo.interface.d.ts.map +1 -0
- package/dist/repositories/base-core.repo.interface.js.map +1 -1
- package/dist/repositories/base-db.repo.d.ts +14 -8
- package/dist/repositories/base-db.repo.d.ts.map +1 -0
- package/dist/repositories/base-db.repo.interface.d.ts +25 -4
- package/dist/repositories/base-db.repo.interface.d.ts.map +1 -0
- package/dist/repositories/base-db.repo.interface.js.map +1 -1
- package/dist/repositories/base-db.repo.js +70 -26
- package/dist/repositories/base-db.repo.js.map +1 -1
- package/dist/repositories/base-es.repo.d.ts +2 -1
- package/dist/repositories/base-es.repo.d.ts.map +1 -0
- package/dist/repositories/base-es.repo.interface.d.ts +1 -0
- package/dist/repositories/base-es.repo.interface.d.ts.map +1 -0
- package/dist/repositories/base-es.repo.js +2 -2
- package/dist/repositories/base-es.repo.js.map +1 -1
- package/dist/repositories/index.d.ts +1 -0
- package/dist/repositories/index.d.ts.map +1 -0
- package/dist/service/api.services/api.service.d.ts +1 -0
- package/dist/service/api.services/api.service.d.ts.map +1 -0
- package/dist/service/api.services/api.service.interface.d.ts +1 -0
- package/dist/service/api.services/api.service.interface.d.ts.map +1 -0
- package/dist/service/api.services/index.d.ts +1 -0
- package/dist/service/api.services/index.d.ts.map +1 -0
- package/dist/service/auth.service.d.ts +1 -0
- package/dist/service/auth.service.d.ts.map +1 -0
- package/dist/service/auth.service.interface.d.ts +1 -0
- package/dist/service/auth.service.interface.d.ts.map +1 -0
- package/dist/service/base.service.d.ts +5 -3
- package/dist/service/base.service.d.ts.map +1 -0
- package/dist/service/base.service.interface.d.ts +21 -10
- package/dist/service/base.service.interface.d.ts.map +1 -0
- package/dist/service/base.service.interface.js.map +1 -1
- package/dist/service/base.service.js +14 -11
- package/dist/service/base.service.js.map +1 -1
- package/dist/service/crud-operations.d.ts +103 -0
- package/dist/service/crud-operations.d.ts.map +1 -0
- package/dist/service/crud-operations.js +459 -0
- package/dist/service/crud-operations.js.map +1 -0
- package/dist/service/crud.service.d.ts +12 -18
- package/dist/service/crud.service.d.ts.map +1 -0
- package/dist/service/crud.service.interface.d.ts +55 -13
- package/dist/service/crud.service.interface.d.ts.map +1 -0
- package/dist/service/crud.service.interface.js.map +1 -1
- package/dist/service/crud.service.js +53 -351
- package/dist/service/crud.service.js.map +1 -1
- package/dist/service/index.d.ts +2 -0
- package/dist/service/index.d.ts.map +1 -0
- package/dist/service/index.js +1 -0
- package/dist/service/index.js.map +1 -1
- package/dist/service/key-aws.services.d.ts +1 -0
- package/dist/service/key-aws.services.d.ts.map +1 -0
- package/dist/service/key.services.interface.d.ts +1 -0
- package/dist/service/key.services.interface.d.ts.map +1 -0
- package/dist/service/permission.cache.d.ts +1 -0
- package/dist/service/permission.cache.d.ts.map +1 -0
- package/dist/service/permission.repo.d.ts +1 -0
- package/dist/service/permission.repo.d.ts.map +1 -0
- package/dist/service/permission.service.d.ts +3 -0
- package/dist/service/permission.service.d.ts.map +1 -0
- package/dist/service/permission.service.js +30 -14
- package/dist/service/permission.service.js.map +1 -1
- package/dist/service/socket.service.d.ts +1 -0
- package/dist/service/socket.service.d.ts.map +1 -0
- package/dist/service/socket.service.interface.d.ts +1 -0
- package/dist/service/socket.service.interface.d.ts.map +1 -0
- package/dist/service/stream.service.d.ts +1 -0
- package/dist/service/stream.service.d.ts.map +1 -0
- package/dist/service/stream.service.interface.d.ts +1 -0
- package/dist/service/stream.service.interface.d.ts.map +1 -0
- package/dist/service/validation.service.interface.d.ts +1 -0
- package/dist/service/validation.service.interface.d.ts.map +1 -0
- package/dist/utils/array.util.d.ts +1 -0
- package/dist/utils/array.util.d.ts.map +1 -0
- package/dist/utils/auth.util.d.ts +1 -0
- package/dist/utils/auth.util.d.ts.map +1 -0
- package/dist/utils/data.util.d.ts +1 -0
- package/dist/utils/data.util.d.ts.map +1 -0
- package/dist/utils/date.util.d.ts +1 -0
- package/dist/utils/date.util.d.ts.map +1 -0
- package/dist/utils/dynamodb.utils.d.ts +2 -1
- package/dist/utils/dynamodb.utils.d.ts.map +1 -0
- package/dist/utils/dynamodb.utils.js +105 -30
- package/dist/utils/dynamodb.utils.js.map +1 -1
- package/dist/utils/env.util.d.ts +1 -0
- package/dist/utils/env.util.d.ts.map +1 -0
- package/dist/utils/error.util.d.ts +1 -0
- package/dist/utils/error.util.d.ts.map +1 -0
- package/dist/utils/http/http-request.d.ts +1 -0
- package/dist/utils/http/http-request.d.ts.map +1 -0
- package/dist/utils/http/http.util.d.ts +1 -0
- package/dist/utils/http/http.util.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/json.util.d.ts +1 -0
- package/dist/utils/json.util.d.ts.map +1 -0
- package/dist/utils/opensearch/opensearch.parser.aggs.d.ts +1 -0
- package/dist/utils/opensearch/opensearch.parser.aggs.d.ts.map +1 -0
- package/dist/utils/opensearch/opensearch.parser.d.ts +1 -0
- package/dist/utils/opensearch/opensearch.parser.d.ts.map +1 -0
- package/dist/utils/opensearch/opensearch.parser.keyword.d.ts +1 -0
- package/dist/utils/opensearch/opensearch.parser.keyword.d.ts.map +1 -0
- package/dist/utils/opensearch/opensearch.parser.query.map.d.ts +1 -0
- package/dist/utils/opensearch/opensearch.parser.query.map.d.ts.map +1 -0
- package/dist/utils/opensearch/opensearch.parser.sort.d.ts +1 -0
- package/dist/utils/opensearch/opensearch.parser.sort.d.ts.map +1 -0
- package/dist/utils/opensearch/opensearch.parser.utils.d.ts +1 -0
- package/dist/utils/opensearch/opensearch.parser.utils.d.ts.map +1 -0
- package/dist/utils/opensearch/opensearch.transform.d.ts +1 -0
- package/dist/utils/opensearch/opensearch.transform.d.ts.map +1 -0
- package/dist/utils/opensearch.utils.d.ts +1 -0
- package/dist/utils/opensearch.utils.d.ts.map +1 -0
- package/dist/utils/reflection.util.d.ts +1 -0
- package/dist/utils/reflection.util.d.ts.map +1 -0
- package/dist/utils/reflection.util.js +7 -8
- package/dist/utils/reflection.util.js.map +1 -1
- package/dist/utils/string.util.d.ts +1 -0
- package/dist/utils/string.util.d.ts.map +1 -0
- package/dist/utils/validation.util.d.ts +1 -0
- package/dist/utils/validation.util.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC"}
|
package/dist/service/index.js
CHANGED
|
@@ -21,6 +21,7 @@ __exportStar(require("./socket.service"), exports);
|
|
|
21
21
|
__exportStar(require("./socket.service.interface"), exports);
|
|
22
22
|
__exportStar(require("./crud.service"), exports);
|
|
23
23
|
__exportStar(require("./crud.service.interface"), exports);
|
|
24
|
+
__exportStar(require("./crud-operations"), exports);
|
|
24
25
|
__exportStar(require("./stream.service"), exports);
|
|
25
26
|
__exportStar(require("./stream.service.interface"), exports);
|
|
26
27
|
__exportStar(require("./permission.cache"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,iDAA+B;AAC/B,2DAAyC;AACzC,mDAAiC;AACjC,6DAA2C;AAC3C,iDAA+B;AAC/B,2DAAyC;AACzC,mDAAiC;AACjC,6DAA2C;AAC3C,qDAAmC;AACnC,oDAAkC;AAClC,uDAAqC","sourcesContent":["export * from \"./api.services\";\nexport * from \"./base.service\";\nexport * from \"./base.service.interface\";\nexport * from \"./socket.service\";\nexport * from \"./socket.service.interface\";\nexport * from \"./crud.service\";\nexport * from \"./crud.service.interface\";\nexport * from \"./stream.service\";\nexport * from \"./stream.service.interface\";\nexport * from \"./permission.cache\";\nexport * from \"./permission.repo\";\nexport * from \"./permission.service\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,iDAA+B;AAC/B,2DAAyC;AACzC,mDAAiC;AACjC,6DAA2C;AAC3C,iDAA+B;AAC/B,2DAAyC;AACzC,oDAAkC;AAClC,mDAAiC;AACjC,6DAA2C;AAC3C,qDAAmC;AACnC,oDAAkC;AAClC,uDAAqC","sourcesContent":["export * from \"./api.services\";\nexport * from \"./base.service\";\nexport * from \"./base.service.interface\";\nexport * from \"./socket.service\";\nexport * from \"./socket.service.interface\";\nexport * from \"./crud.service\";\nexport * from \"./crud.service.interface\";\nexport * from \"./crud-operations\";\nexport * from \"./stream.service\";\nexport * from \"./stream.service.interface\";\nexport * from \"./permission.cache\";\nexport * from \"./permission.repo\";\nexport * from \"./permission.service\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-aws.services.d.ts","sourceRoot":"","sources":["../../src/service/key-aws.services.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,qBACa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuB;gBAElC,MAAM,EAAE,MAAM;IAIpB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAW1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key.services.interface.d.ts","sourceRoot":"","sources":["../../src/service/key.services.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission.cache.d.ts","sourceRoot":"","sources":["../../src/service/permission.cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AASjD;;;;;;;GAOG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AAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAe1D,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAW5D,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIpC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;CAGjD"}
|
|
@@ -37,4 +37,7 @@ export declare class PermissionService {
|
|
|
37
37
|
deletePermission(id: string): Promise<boolean>;
|
|
38
38
|
listPermissions(filter?: Filter): Promise<List<Partial<Permission>>>;
|
|
39
39
|
clearCache(): void;
|
|
40
|
+
/** Normalize method keys to uppercase. */
|
|
41
|
+
private normalizeMethodKeys;
|
|
40
42
|
}
|
|
43
|
+
//# sourceMappingURL=permission.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission.service.d.ts","sourceRoot":"","sources":["../../src/service/permission.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIjD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;;;;;;;;GASG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiB;IACtC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkB;gBAE5B,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;IASlD,oFAAoF;IAC9E,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAM3E,mDAAmD;IAC7C,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAU/D;;;;;;;OAOG;IACG,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAgB9F,gBAAgB,CAAC,KAAK,EAAE;QAC5B,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;KAC9B,GAAG,OAAO,CAAC,UAAU,CAAC;IAkCjB,gBAAgB,CACpB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC,CAAC,GAC3E,OAAO,CAAC,UAAU,CAAC;IAoChB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAgB9C,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IAW1E,UAAU,IAAI,IAAI;IAQlB,0CAA0C;IAC1C,OAAO,CAAC,mBAAmB;CAS5B"}
|
|
@@ -54,33 +54,33 @@ class PermissionService {
|
|
|
54
54
|
const permission = await this.getPermissionByKey(permissionKey);
|
|
55
55
|
if (!permission?.method)
|
|
56
56
|
return false;
|
|
57
|
-
const
|
|
58
|
-
return permission.method[
|
|
57
|
+
const methodKey = method.toUpperCase();
|
|
58
|
+
return permission.method[methodKey] === true;
|
|
59
59
|
}
|
|
60
60
|
// ---------------------------------------------------------------------------
|
|
61
61
|
// CRUD — create
|
|
62
62
|
// ---------------------------------------------------------------------------
|
|
63
63
|
async createPermission(input) {
|
|
64
64
|
if (!input.role?.trim()) {
|
|
65
|
-
throw new exception_1.ErrorHttp(
|
|
65
|
+
throw new exception_1.ErrorHttp(exception_1.HTTP.BAD_REQUEST, "Role is required");
|
|
66
66
|
}
|
|
67
67
|
if (!input.resource?.trim()) {
|
|
68
|
-
throw new exception_1.ErrorHttp(
|
|
68
|
+
throw new exception_1.ErrorHttp(exception_1.HTTP.BAD_REQUEST, "Resource is required");
|
|
69
69
|
}
|
|
70
70
|
if (!input.scope?.trim()) {
|
|
71
|
-
throw new exception_1.ErrorHttp(
|
|
71
|
+
throw new exception_1.ErrorHttp(exception_1.HTTP.BAD_REQUEST, "Scope is required");
|
|
72
72
|
}
|
|
73
73
|
// Duplicate check
|
|
74
|
-
const permissionKey = `${input.role}#${input.resource}#${input.scope}`;
|
|
74
|
+
const permissionKey = `${input.role.trim()}#${input.resource.trim()}#${input.scope.trim()}`;
|
|
75
75
|
const existing = await this.repo.findByPermissionKey(permissionKey);
|
|
76
76
|
if (existing) {
|
|
77
|
-
throw new exception_1.ErrorHttp(
|
|
77
|
+
throw new exception_1.ErrorHttp(exception_1.HTTP.CONFLICT, `Permission "${permissionKey}" already exists`);
|
|
78
78
|
}
|
|
79
79
|
const saved = await this.repo.save({
|
|
80
80
|
role: input.role.trim(),
|
|
81
81
|
resource: input.resource.trim(),
|
|
82
82
|
scope: input.scope.trim(),
|
|
83
|
-
method: input.method ?? {},
|
|
83
|
+
method: this.normalizeMethodKeys(input.method ?? {}),
|
|
84
84
|
permissionKey,
|
|
85
85
|
});
|
|
86
86
|
this.cache.clear();
|
|
@@ -91,10 +91,10 @@ class PermissionService {
|
|
|
91
91
|
// ---------------------------------------------------------------------------
|
|
92
92
|
async updatePermission(id, updates) {
|
|
93
93
|
if (!id)
|
|
94
|
-
throw new exception_1.ErrorHttp(
|
|
94
|
+
throw new exception_1.ErrorHttp(exception_1.HTTP.BAD_REQUEST, "Permission id is required");
|
|
95
95
|
const existing = await this.repo.findById(id);
|
|
96
96
|
if (!existing)
|
|
97
|
-
throw new exception_1.ErrorHttp(
|
|
97
|
+
throw new exception_1.ErrorHttp(exception_1.HTTP.NOT_FOUND, `Permission "${id}" not found`);
|
|
98
98
|
const data = { id };
|
|
99
99
|
if (updates.role !== undefined)
|
|
100
100
|
data.role = updates.role.trim();
|
|
@@ -103,7 +103,7 @@ class PermissionService {
|
|
|
103
103
|
if (updates.scope !== undefined)
|
|
104
104
|
data.scope = updates.scope.trim();
|
|
105
105
|
if (updates.method !== undefined)
|
|
106
|
-
data.method = updates.method;
|
|
106
|
+
data.method = this.normalizeMethodKeys(updates.method);
|
|
107
107
|
// Rebuild key if any key component changed
|
|
108
108
|
const role = data.role ?? existing.role;
|
|
109
109
|
const resource = data.resource ?? existing.resource;
|
|
@@ -113,7 +113,7 @@ class PermissionService {
|
|
|
113
113
|
if (data.permissionKey !== existing.permissionKey) {
|
|
114
114
|
const conflict = await this.repo.findByPermissionKey(data.permissionKey);
|
|
115
115
|
if (conflict) {
|
|
116
|
-
throw new exception_1.ErrorHttp(
|
|
116
|
+
throw new exception_1.ErrorHttp(exception_1.HTTP.CONFLICT, `Permission "${data.permissionKey}" already exists`);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
const updated = await this.repo.update(data);
|
|
@@ -125,10 +125,10 @@ class PermissionService {
|
|
|
125
125
|
// ---------------------------------------------------------------------------
|
|
126
126
|
async deletePermission(id) {
|
|
127
127
|
if (!id)
|
|
128
|
-
throw new exception_1.ErrorHttp(
|
|
128
|
+
throw new exception_1.ErrorHttp(exception_1.HTTP.BAD_REQUEST, "Permission id is required");
|
|
129
129
|
const existing = await this.repo.findById(id);
|
|
130
130
|
if (!existing)
|
|
131
|
-
throw new exception_1.ErrorHttp(
|
|
131
|
+
throw new exception_1.ErrorHttp(exception_1.HTTP.NOT_FOUND, `Permission "${id}" not found`);
|
|
132
132
|
const result = await this.repo.delete(id);
|
|
133
133
|
this.cache.clear();
|
|
134
134
|
return result;
|
|
@@ -137,6 +137,9 @@ class PermissionService {
|
|
|
137
137
|
// CRUD — list
|
|
138
138
|
// ---------------------------------------------------------------------------
|
|
139
139
|
async listPermissions(filter) {
|
|
140
|
+
if (!filter) {
|
|
141
|
+
return this.repo.scan();
|
|
142
|
+
}
|
|
140
143
|
return this.repo.findByIndex(filter);
|
|
141
144
|
}
|
|
142
145
|
// ---------------------------------------------------------------------------
|
|
@@ -145,6 +148,19 @@ class PermissionService {
|
|
|
145
148
|
clearCache() {
|
|
146
149
|
this.cache.clear();
|
|
147
150
|
}
|
|
151
|
+
// ---------------------------------------------------------------------------
|
|
152
|
+
// Utils
|
|
153
|
+
// ---------------------------------------------------------------------------
|
|
154
|
+
/** Normalize method keys to uppercase. */
|
|
155
|
+
normalizeMethodKeys(method) {
|
|
156
|
+
const normalized = {};
|
|
157
|
+
for (const key in method) {
|
|
158
|
+
if (method[key] === true) {
|
|
159
|
+
normalized[key.toUpperCase()] = true;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return normalized;
|
|
163
|
+
}
|
|
148
164
|
}
|
|
149
165
|
exports.PermissionService = PermissionService;
|
|
150
166
|
//# sourceMappingURL=permission.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission.service.js","sourceRoot":"","sources":["../../src/service/permission.service.ts"],"names":[],"mappings":";;;AACA,4CAAyC;AACzC,yDAAqD;AACrD,uDAAmD;AAGnD;;;;;;;;;GASG;AACH,MAAa,iBAAiB;IACX,IAAI,CAAiB;IACrB,KAAK,CAAkB;IAExC,YAAY,SAAiB,EAAE,UAAmB;QAChD,IAAI,CAAC,IAAI,GAAG,IAAI,gCAAc,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,IAAI,kCAAe,CAAC,UAAU,CAAC,CAAC;IAC/C,CAAC;IAED,8EAA8E;IAC9E,cAAc;IACd,8EAA8E;IAE9E,oFAAoF;IACpF,KAAK,CAAC,kBAAkB,CAAC,aAAqB;QAC5C,IAAI,CAAC,aAAa;YAAE,OAAO,IAAI,CAAC;QAEhC,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,aAAa,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,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8EAA8E;IAC9E,8BAA8B;IAC9B,8EAA8E;IAE9E,UAAU;QACR,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF;AAhKD,8CAgKC","sourcesContent":["import { Permission } from \"../model/role.model\";\nimport { ErrorHttp } from \"../exception\";\nimport { PermissionCache } from \"./permission.cache\";\nimport { PermissionRepo } from \"./permission.repo\";\nimport { Filter, List } from \"@chinggis/types\";\n\n/**\n * PermissionService — cache + orchestration layer for Permission entities.\n *\n * Design decisions:\n * - Read-through cache via PermissionCache (in-flight dedup, TTL).\n * - Repository handles only DB I/O.\n * - Cache invalidation on every mutation.\n * - ~100 roles total, read-heavy → caching makes sense.\n * - Cache keyed by `perm:{permissionKey}` for deterministic, namespaced lookup.\n */\nexport class PermissionService {\n private readonly repo: PermissionRepo;\n private readonly cache: PermissionCache;\n\n constructor(tableName: string, cacheTtlMs?: number) {\n this.repo = new PermissionRepo(tableName);\n this.cache = new PermissionCache(cacheTtlMs);\n }\n\n // ---------------------------------------------------------------------------\n // Core lookup\n // ---------------------------------------------------------------------------\n\n /** Fetch Permission by composite key (role#resource#scope). Read-through cached. */\n async getPermissionByKey(permissionKey: string): Promise<Permission | null> {\n if (!permissionKey) return null;\n\n return this.cache.getOrFetch(`perm:${permissionKey}`, () => this.repo.findByPermissionKey(permissionKey));\n }\n\n /** Fetch Permission by id. Read-through cached. */\n async getPermissionById(id: string): Promise<Permission | null> {\n if (!id) return null;\n\n return this.cache.getOrFetch(`id:${id}`, () => this.repo.findById(id));\n }\n\n // ---------------------------------------------------------------------------\n // Permission check\n // ---------------------------------------------------------------------------\n\n /**\n * Check if the given role+resource+scope has a specific HTTP method allowed.\n *\n * Builds the permissionKey `role#resource#scope`, fetches the Permission,\n * and checks the method map.\n *\n * @returns `true` if allowed, `false` otherwise.\n */\n async hasPermission(role: string, resource: string, scope: string, method: string): Promise<boolean> {\n if (!role || !resource || !scope || !method) return false;\n\n const permissionKey = `${role}#${resource}#${scope}`;\n const permission = await this.getPermissionByKey(permissionKey);\n if (!permission?.method) return false;\n\n const methodLower = method.toUpperCase() as keyof Permission[\"method\"];\n\n return permission.method[methodLower] === true;\n }\n\n // ---------------------------------------------------------------------------\n // CRUD — create\n // ---------------------------------------------------------------------------\n\n async createPermission(input: {\n role: string;\n resource: string;\n scope: string;\n method: Permission[\"method\"];\n }): Promise<Permission> {\n if (!input.role?.trim()) {\n throw new ErrorHttp({ code: 400, error: \"BadRequest\" }, \"Role is required\");\n }\n if (!input.resource?.trim()) {\n throw new ErrorHttp({ code: 400, error: \"BadRequest\" }, \"Resource is required\");\n }\n if (!input.scope?.trim()) {\n throw new ErrorHttp({ code: 400, error: \"BadRequest\" }, \"Scope is required\");\n }\n\n // Duplicate check\n const permissionKey = `${input.role}#${input.resource}#${input.scope}`;\n const existing = await this.repo.findByPermissionKey(permissionKey);\n if (existing) {\n throw new ErrorHttp({ code: 409, error: \"Conflict\" }, `Permission \"${permissionKey}\" already exists`);\n }\n\n const saved = await this.repo.save({\n role: input.role.trim(),\n resource: input.resource.trim(),\n scope: input.scope.trim(),\n method: input.method ?? {},\n permissionKey,\n });\n\n this.cache.clear();\n return saved;\n }\n\n // ---------------------------------------------------------------------------\n // CRUD — update\n // ---------------------------------------------------------------------------\n\n async updatePermission(\n id: string,\n updates: Partial<Pick<Permission, \"role\" | \"resource\" | \"scope\" | \"method\">>,\n ): Promise<Permission> {\n if (!id) throw new ErrorHttp({ code: 400, error: \"BadRequest\" }, \"Permission id is required\");\n\n const existing = await this.repo.findById(id);\n if (!existing) throw new ErrorHttp({ code: 404, error: \"NotFound\" }, `Permission \"${id}\" not found`);\n\n const data: Partial<Permission> = { id };\n if (updates.role !== undefined) data.role = updates.role.trim();\n if (updates.resource !== undefined) data.resource = updates.resource.trim();\n if (updates.scope !== undefined) data.scope = updates.scope.trim();\n if (updates.method !== undefined) data.method = updates.method;\n\n // Rebuild key if any key component changed\n const role = data.role ?? existing.role;\n const resource = data.resource ?? existing.resource;\n const scope = data.scope ?? existing.scope;\n data.permissionKey = `${role}#${resource}#${scope}`;\n\n // Check for duplicate key if components changed\n if (data.permissionKey !== existing.permissionKey) {\n const conflict = await this.repo.findByPermissionKey(data.permissionKey);\n if (conflict) {\n throw new ErrorHttp({ code: 409, error: \"Conflict\" }, `Permission \"${data.permissionKey}\" already exists`);\n }\n }\n\n const updated = await this.repo.update(data);\n\n this.cache.clear();\n return updated;\n }\n\n // ---------------------------------------------------------------------------\n // CRUD — delete\n // ---------------------------------------------------------------------------\n\n async deletePermission(id: string): Promise<boolean> {\n if (!id) throw new ErrorHttp({ code: 400, error: \"BadRequest\" }, \"Permission id is required\");\n\n const existing = await this.repo.findById(id);\n if (!existing) throw new ErrorHttp({ code: 404, error: \"NotFound\" }, `Permission \"${id}\" not found`);\n\n const result = await this.repo.delete(id);\n\n this.cache.clear();\n return result;\n }\n\n // ---------------------------------------------------------------------------\n // CRUD — list\n // ---------------------------------------------------------------------------\n\n async listPermissions(filter?: Filter): Promise<List<Partial<Permission>>> {\n return this.repo.findByIndex(filter);\n }\n\n // ---------------------------------------------------------------------------\n // Cache control (for testing)\n // ---------------------------------------------------------------------------\n\n clearCache(): void {\n this.cache.clear();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"permission.service.js","sourceRoot":"","sources":["../../src/service/permission.service.ts"],"names":[],"mappings":";;;AACA,4CAA+C;AAC/C,yDAAqD;AACrD,uDAAmD;AAGnD;;;;;;;;;GASG;AACH,MAAa,iBAAiB;IACX,IAAI,CAAiB;IACrB,KAAK,CAAkB;IAExC,YAAY,SAAiB,EAAE,UAAmB;QAChD,IAAI,CAAC,IAAI,GAAG,IAAI,gCAAc,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,IAAI,kCAAe,CAAC,UAAU,CAAC,CAAC;IAC/C,CAAC;IAED,8EAA8E;IAC9E,cAAc;IACd,8EAA8E;IAE9E,oFAAoF;IACpF,KAAK,CAAC,kBAAkB,CAAC,aAA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B,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,8EAA8E;IAC9E,8BAA8B;IAC9B,8EAA8E;IAE9E,UAAU;QACR,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED,8EAA8E;IAC9E,QAAQ;IACR,8EAA8E;IAE9E,0CAA0C;IAClC,mBAAmB,CAAC,MAA4B;QACtD,MAAM,UAAU,GAAyB,EAAS,CAAC;QACnD,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACzB,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;gBACzB,UAAU,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,IAAI,CAAC;YACvC,CAAC;QACH,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAlLD,8CAkLC","sourcesContent":["import { Permission } from \"../model/role.model\";\nimport { ErrorHttp, HTTP } from \"../exception\";\nimport { PermissionCache } from \"./permission.cache\";\nimport { PermissionRepo } from \"./permission.repo\";\nimport { Filter, List } from \"@chinggis/types\";\n\n/**\n * PermissionService — cache + orchestration layer for Permission entities.\n *\n * Design decisions:\n * - Read-through cache via PermissionCache (in-flight dedup, TTL).\n * - Repository handles only DB I/O.\n * - Cache invalidation on every mutation.\n * - ~100 roles total, read-heavy → caching makes sense.\n * - Cache keyed by `perm:{permissionKey}` for deterministic, namespaced lookup.\n */\nexport class PermissionService {\n private readonly repo: PermissionRepo;\n private readonly cache: PermissionCache;\n\n constructor(tableName: string, cacheTtlMs?: number) {\n this.repo = new PermissionRepo(tableName);\n this.cache = new PermissionCache(cacheTtlMs);\n }\n\n // ---------------------------------------------------------------------------\n // Core lookup\n // ---------------------------------------------------------------------------\n\n /** Fetch Permission by composite key (role#resource#scope). Read-through cached. */\n async getPermissionByKey(permissionKey: string): Promise<Permission | null> {\n if (!permissionKey) return null;\n\n return this.cache.getOrFetch(`perm:${permissionKey}`, () => this.repo.findByPermissionKey(permissionKey));\n }\n\n /** Fetch Permission by id. Read-through cached. */\n async getPermissionById(id: string): Promise<Permission | null> {\n if (!id) return null;\n\n return this.cache.getOrFetch(`id:${id}`, () => this.repo.findById(id));\n }\n\n // ---------------------------------------------------------------------------\n // Permission check\n // ---------------------------------------------------------------------------\n\n /**\n * Check if the given role+resource+scope has a specific HTTP method allowed.\n *\n * Builds the permissionKey `role#resource#scope`, fetches the Permission,\n * and checks the method map.\n *\n * @returns `true` if allowed, `false` otherwise.\n */\n async hasPermission(role: string, resource: string, scope: string, method: string): Promise<boolean> {\n if (!role || !resource || !scope || !method) return false;\n\n const permissionKey = `${role}#${resource}#${scope}`;\n const permission = await this.getPermissionByKey(permissionKey);\n if (!permission?.method) return false;\n\n const methodKey = method.toUpperCase() as keyof Permission[\"method\"];\n\n return permission.method[methodKey] === true;\n }\n\n // ---------------------------------------------------------------------------\n // CRUD — create\n // ---------------------------------------------------------------------------\n\n async createPermission(input: {\n role: string;\n resource: string;\n scope: string;\n method: Permission[\"method\"];\n }): Promise<Permission> {\n if (!input.role?.trim()) {\n throw new ErrorHttp(HTTP.BAD_REQUEST, \"Role is required\");\n }\n if (!input.resource?.trim()) {\n throw new ErrorHttp(HTTP.BAD_REQUEST, \"Resource is required\");\n }\n if (!input.scope?.trim()) {\n throw new ErrorHttp(HTTP.BAD_REQUEST, \"Scope is required\");\n }\n\n // Duplicate check\n const permissionKey = `${input.role.trim()}#${input.resource.trim()}#${input.scope.trim()}`;\n const existing = await this.repo.findByPermissionKey(permissionKey);\n if (existing) {\n throw new ErrorHttp(HTTP.CONFLICT, `Permission \"${permissionKey}\" already exists`);\n }\n\n const saved = await this.repo.save({\n role: input.role.trim(),\n resource: input.resource.trim(),\n scope: input.scope.trim(),\n method: this.normalizeMethodKeys(input.method ?? {}),\n permissionKey,\n });\n\n this.cache.clear();\n return saved;\n }\n\n // ---------------------------------------------------------------------------\n // CRUD — update\n // ---------------------------------------------------------------------------\n\n async updatePermission(\n id: string,\n updates: Partial<Pick<Permission, \"role\" | \"resource\" | \"scope\" | \"method\">>,\n ): Promise<Permission> {\n if (!id) throw new ErrorHttp(HTTP.BAD_REQUEST, \"Permission id is required\");\n\n const existing = await this.repo.findById(id);\n if (!existing) throw new ErrorHttp(HTTP.NOT_FOUND, `Permission \"${id}\" not found`);\n\n const data: Partial<Permission> = { id };\n if (updates.role !== undefined) data.role = updates.role.trim();\n if (updates.resource !== undefined) data.resource = updates.resource.trim();\n if (updates.scope !== undefined) data.scope = updates.scope.trim();\n if (updates.method !== undefined) data.method = this.normalizeMethodKeys(updates.method);\n\n // Rebuild key if any key component changed\n const role = data.role ?? existing.role;\n const resource = data.resource ?? existing.resource;\n const scope = data.scope ?? existing.scope;\n data.permissionKey = `${role}#${resource}#${scope}`;\n\n // Check for duplicate key if components changed\n if (data.permissionKey !== existing.permissionKey) {\n const conflict = await this.repo.findByPermissionKey(data.permissionKey);\n if (conflict) {\n throw new ErrorHttp(HTTP.CONFLICT, `Permission \"${data.permissionKey}\" already exists`);\n }\n }\n\n const updated = await this.repo.update(data);\n\n this.cache.clear();\n return updated;\n }\n\n // ---------------------------------------------------------------------------\n // CRUD — delete\n // ---------------------------------------------------------------------------\n\n async deletePermission(id: string): Promise<boolean> {\n if (!id) throw new ErrorHttp(HTTP.BAD_REQUEST, \"Permission id is required\");\n\n const existing = await this.repo.findById(id);\n if (!existing) throw new ErrorHttp(HTTP.NOT_FOUND, `Permission \"${id}\" not found`);\n\n const result = await this.repo.delete(id);\n\n this.cache.clear();\n return result;\n }\n\n // ---------------------------------------------------------------------------\n // CRUD — list\n // ---------------------------------------------------------------------------\n\n async listPermissions(filter?: Filter): Promise<List<Partial<Permission>>> {\n if (!filter) {\n return this.repo.scan();\n }\n return this.repo.findByIndex(filter);\n }\n\n // ---------------------------------------------------------------------------\n // Cache control (for testing)\n // ---------------------------------------------------------------------------\n\n clearCache(): void {\n this.cache.clear();\n }\n\n // ---------------------------------------------------------------------------\n // Utils\n // ---------------------------------------------------------------------------\n\n /** Normalize method keys to uppercase. */\n private normalizeMethodKeys(method: Permission[\"method\"]): Permission[\"method\"] {\n const normalized: Permission[\"method\"] = {} as any;\n for (const key in method) {\n if (method[key] === true) {\n normalized[key.toUpperCase()] = true;\n }\n }\n return normalized;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket.service.d.ts","sourceRoot":"","sources":["../../src/service/socket.service.ts"],"names":[],"mappings":"AAEA,OAAO,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D,qBACa,oBAAoB,CAAC,CAAC,CAAE,YAAW,iBAAiB,CAAC,CAAC,CAAC;IAClC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAuB;IAE5F,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;CAQ/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket.service.interface.d.ts","sourceRoot":"","sources":["../../src/service/socket.service.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CAChE"}
|
|
@@ -15,3 +15,4 @@ export declare abstract class StreamServiceImpl<T extends BaseEntity, D extends
|
|
|
15
15
|
abstract processDeletion(oldItem: T, newItem: T, tableName?: string): Promise<any>;
|
|
16
16
|
abstract processInsertion(newItem: T, tableName: string): Promise<any>;
|
|
17
17
|
}
|
|
18
|
+
//# sourceMappingURL=stream.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.service.d.ts","sourceRoot":"","sources":["../../src/service/stream.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;;GAGG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,UAAU;IACjD,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAEtC,YAAY,IAAI,MAAM,CAAC;IAEvB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC;IAErE,eAAe,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE1E,gBAAgB,CAAC,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE9D,mBAAmB,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CAC/E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.service.interface.d.ts","sourceRoot":"","sources":["../../src/service/validation.service.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.util.d.ts","sourceRoot":"","sources":["../../src/utils/array.util.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,WAAW,MAAM,KAAG,CAAC,EAAE,EAMhE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.util.d.ts","sourceRoot":"","sources":["../../src/utils/auth.util.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,QAAO;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CAKzB,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE;QACZ,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.util.d.ts","sourceRoot":"","sources":["../../src/utils/data.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAmF,OAAO,EAAE,MAAM,KAAK,CAAC;AAElH,KAAK,aAAa,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC;AAExC;;;;;;GAMG;AACH,qBAAa,aAAa,CAAC,CAAC,SAAS,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;IAIvD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAL9B,OAAO,CAAC,IAAI,CAAK;gBAGE,MAAM,EAAE,CAAC,EACT,OAAO,GAAE,aAAoB,EAC7B,WAAW,GAAE,MAAU;IAG1C,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAInB,OAAO,CAAC,YAAY;IAyCpB,OAAO,CAAC,gBAAgB;CAYzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.util.d.ts","sourceRoot":"","sources":["../../src/utils/date.util.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAErC,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAGpD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,OAAO,CAInG;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,OAAO,CAEnE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAYnD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,CAElE;AACD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,GAAG,EAAE,GAAG,MAAM,CAErD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,GAAG,EAAE,GAAG,MAAM,CAErD"}
|
|
@@ -3,7 +3,7 @@ import { Filter } from "../model";
|
|
|
3
3
|
import { ActionDynamoDB, DynamoIndexMap } from "../model/dynamodb.model";
|
|
4
4
|
export declare const generateUUID: () => string;
|
|
5
5
|
export declare const buildDynamoDBFilterConditions: (filter: Filter, indexMap: DynamoIndexMap) => FilterExpression;
|
|
6
|
-
export declare const buildQueryDB: (tableName: string, filter: Filter, indexMap: DynamoIndexMap) => QueryCommandInput
|
|
6
|
+
export declare const buildQueryDB: (tableName: string, filter: Filter, indexMap: DynamoIndexMap) => QueryCommandInput;
|
|
7
7
|
export declare const buildDynamoDBScanCommand: ({ tableName, filter, expression, }: {
|
|
8
8
|
tableName: string;
|
|
9
9
|
filter?: Filter;
|
|
@@ -46,3 +46,4 @@ export declare function toBase64(inputStr: any): string;
|
|
|
46
46
|
export declare function getTableName(eventSourceARN: any): string;
|
|
47
47
|
export declare function parseImage(image: any): Record<string, any>;
|
|
48
48
|
export declare function parseEventToAction(action: "INSERT" | "MODIFY" | "REMOVE"): ActionDynamoDB;
|
|
49
|
+
//# sourceMappingURL=dynamodb.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamodb.utils.d.ts","sourceRoot":"","sources":["../../src/utils/dynamodb.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,i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E,GAAG,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAUtG;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,GAAG,GAAG,MAAM,CAE9C;AAED,wBAAgB,YAAY,CAAC,cAAc,EAAE,GAAG,GAAG,MAAM,CAMxD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,GAAG,uBASpC;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,cAAc,CAWzF"}
|
|
@@ -21,9 +21,12 @@ exports.generateUUID = generateUUID;
|
|
|
21
21
|
const buildDynamoDBFilterConditions = (filter, indexMap) => {
|
|
22
22
|
if (!filter)
|
|
23
23
|
throw new errors_1.MissingParameterError("filter");
|
|
24
|
-
const
|
|
24
|
+
const indexInfo = indexMap.get(filter.indexName);
|
|
25
|
+
const rFields = indexInfo?.rFields ?? [];
|
|
26
|
+
const sortKeyField = indexInfo?.sortKeyField;
|
|
25
27
|
const ignoredKeys = [
|
|
26
28
|
...rFields,
|
|
29
|
+
sortKeyField,
|
|
27
30
|
"page",
|
|
28
31
|
"size",
|
|
29
32
|
"sortBy",
|
|
@@ -33,14 +36,16 @@ const buildDynamoDBFilterConditions = (filter, indexMap) => {
|
|
|
33
36
|
"rangeFilterBy",
|
|
34
37
|
"rangeFilterMin",
|
|
35
38
|
"rangeFilterMax",
|
|
39
|
+
"queryCountLimit",
|
|
36
40
|
"lastKey",
|
|
37
41
|
"indexName",
|
|
38
42
|
"indexValue",
|
|
39
43
|
"indexSortName",
|
|
40
44
|
"indexSortValue",
|
|
45
|
+
"rangeFilters",
|
|
41
46
|
"fieldsInclude",
|
|
42
47
|
"fieldsExclude",
|
|
43
|
-
];
|
|
48
|
+
].filter(Boolean);
|
|
44
49
|
const dynamicFilters = (0, reflection_util_1.excludeKeys)(filter, ignoredKeys);
|
|
45
50
|
const expressions = [];
|
|
46
51
|
const attrNames = {};
|
|
@@ -54,7 +59,7 @@ const buildDynamoDBFilterConditions = (filter, indexMap) => {
|
|
|
54
59
|
};
|
|
55
60
|
};
|
|
56
61
|
// Range Filter
|
|
57
|
-
if (filter.rangeFilterBy) {
|
|
62
|
+
if (filter.rangeFilterBy && filter.rangeFilterBy !== sortKeyField) {
|
|
58
63
|
const key = filter.rangeFilterBy;
|
|
59
64
|
const { name, value } = genPlaceholder(key);
|
|
60
65
|
attrNames[name] = key;
|
|
@@ -129,28 +134,30 @@ const marshallExpressionValue = (value) => (0, util_dynamodb_1.marshall)({ val:
|
|
|
129
134
|
convertClassInstanceToMap: true,
|
|
130
135
|
removeUndefinedValues: true,
|
|
131
136
|
}).val;
|
|
137
|
+
const marshallKeyConditionValue = (value) => {
|
|
138
|
+
if (value instanceof Date) {
|
|
139
|
+
return marshallExpressionValue(value.toISOString().slice(0, 10));
|
|
140
|
+
}
|
|
141
|
+
return marshallExpressionValue(value);
|
|
142
|
+
};
|
|
132
143
|
const buildQueryDB = (tableName, filter, indexMap) => {
|
|
133
144
|
if (!tableName || !filter)
|
|
134
145
|
throw new errors_1.MissingParameterError("tableName or filter");
|
|
135
146
|
const filterCondition = (0, exports.buildDynamoDBFilterConditions)(filter, indexMap);
|
|
136
147
|
const indexField = indexMap.get(filter.indexName)?.field;
|
|
137
|
-
if (indexField) {
|
|
138
|
-
|
|
139
|
-
filterCondition,
|
|
140
|
-
tableName,
|
|
141
|
-
filter,
|
|
142
|
-
indexMap,
|
|
143
|
-
});
|
|
148
|
+
if (!indexField) {
|
|
149
|
+
throw new errors_1.ErrorDynamoDB(tableName, "buildQueryDB", "find requires indexName and indexValue; use scan() otherwise");
|
|
144
150
|
}
|
|
145
|
-
return (0, exports.
|
|
146
|
-
|
|
151
|
+
return (0, exports.buildDynamoDBQueryCommand)({
|
|
152
|
+
filterCondition,
|
|
147
153
|
filter,
|
|
148
|
-
|
|
154
|
+
tableName,
|
|
155
|
+
indexMap,
|
|
149
156
|
});
|
|
150
157
|
};
|
|
151
158
|
exports.buildQueryDB = buildQueryDB;
|
|
152
159
|
const buildDynamoDBScanCommand = ({ tableName, filter, expression, }) => {
|
|
153
|
-
const scanCommand = { TableName: tableName
|
|
160
|
+
const scanCommand = { TableName: tableName };
|
|
154
161
|
if (filter?.lastKey && filter.lastKey != "undefined")
|
|
155
162
|
scanCommand.ExclusiveStartKey = (0, exports.parseLastEvaluatedKey)(filter.lastKey);
|
|
156
163
|
if (isEmptyExpressions(expression))
|
|
@@ -181,17 +188,13 @@ const buildDynamoDBQueryCommand = ({ filter, tableName, filterCondition, indexMa
|
|
|
181
188
|
[attrKey]: attr,
|
|
182
189
|
};
|
|
183
190
|
let expressionAttributeValues = {
|
|
184
|
-
[valueKey]:
|
|
191
|
+
[valueKey]: marshallKeyConditionValue(value),
|
|
185
192
|
};
|
|
186
|
-
|
|
187
|
-
if (
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const sortAttrValueKey = `:${sortAttr}`;
|
|
192
|
-
keyConditionExpression += ` AND ${sortAttrKey} = ${sortAttrValueKey}`;
|
|
193
|
-
expressionAttributeNames[sortAttrKey] = sortAttr;
|
|
194
|
-
expressionAttributeValues[sortAttrValueKey] = marshallExpressionValue(sortValue);
|
|
193
|
+
const sortKeyCondition = buildSortKeyCondition(filter, indexInfo.sortKeyField);
|
|
194
|
+
if (sortKeyCondition) {
|
|
195
|
+
keyConditionExpression += ` AND ${sortKeyCondition.expression}`;
|
|
196
|
+
Object.assign(expressionAttributeNames, sortKeyCondition.attributeNames);
|
|
197
|
+
Object.assign(expressionAttributeValues, sortKeyCondition.attributeValues);
|
|
195
198
|
}
|
|
196
199
|
if (filterCondition?.filter) {
|
|
197
200
|
if (filterCondition.attributeNames) {
|
|
@@ -221,6 +224,76 @@ const buildDynamoDBQueryCommand = ({ filter, tableName, filterCondition, indexMa
|
|
|
221
224
|
return queryCommand;
|
|
222
225
|
};
|
|
223
226
|
exports.buildDynamoDBQueryCommand = buildDynamoDBQueryCommand;
|
|
227
|
+
const hasValue = (value) => value !== undefined && value !== null && value !== "";
|
|
228
|
+
const buildSortKeyCondition = (filter, sortKeyField) => {
|
|
229
|
+
if (!sortKeyField)
|
|
230
|
+
return undefined;
|
|
231
|
+
const sortAttrKey = `#${sortKeyField}`;
|
|
232
|
+
const sortValueKey = `:${sortKeyField}`;
|
|
233
|
+
const attributeNames = { [sortAttrKey]: sortKeyField };
|
|
234
|
+
const rangeFilter = filter.rangeFilters?.find((item) => item.fieldName === sortKeyField);
|
|
235
|
+
if (rangeFilter && (hasValue(rangeFilter.minValue) || hasValue(rangeFilter.maxValue))) {
|
|
236
|
+
return buildSortKeyRangeCondition(sortAttrKey, sortValueKey, attributeNames, rangeFilter);
|
|
237
|
+
}
|
|
238
|
+
if (filter.rangeFilterBy === sortKeyField && (hasValue(filter.rangeFilterMin) || hasValue(filter.rangeFilterMax))) {
|
|
239
|
+
return buildSortKeyRangeCondition(sortAttrKey, sortValueKey, attributeNames, {
|
|
240
|
+
fieldName: sortKeyField,
|
|
241
|
+
minValue: filter.rangeFilterMin,
|
|
242
|
+
maxValue: filter.rangeFilterMax,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
const explicitSortValue = (!filter.indexSortName || filter.indexSortName === sortKeyField) && hasValue(filter.indexSortValue)
|
|
246
|
+
? filter.indexSortValue
|
|
247
|
+
: undefined;
|
|
248
|
+
const directSortValue = hasValue(filter[sortKeyField]) ? filter[sortKeyField] : undefined;
|
|
249
|
+
const sortValue = explicitSortValue ?? directSortValue;
|
|
250
|
+
if (!hasValue(sortValue))
|
|
251
|
+
return undefined;
|
|
252
|
+
return {
|
|
253
|
+
expression: `${sortAttrKey} = ${sortValueKey}`,
|
|
254
|
+
attributeNames,
|
|
255
|
+
attributeValues: {
|
|
256
|
+
[sortValueKey]: marshallKeyConditionValue(sortValue),
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
const buildSortKeyRangeCondition = (sortAttrKey, sortValueKey, attributeNames, rangeFilter) => {
|
|
261
|
+
const attributeValues = {};
|
|
262
|
+
const hasMin = hasValue(rangeFilter.minValue);
|
|
263
|
+
const hasMax = hasValue(rangeFilter.maxValue);
|
|
264
|
+
if (hasMin && hasMax) {
|
|
265
|
+
if (!rangeFilter.minExclude && !rangeFilter.maxExclude) {
|
|
266
|
+
attributeValues[`${sortValueKey}_min`] = marshallKeyConditionValue(rangeFilter.minValue);
|
|
267
|
+
attributeValues[`${sortValueKey}_max`] = marshallKeyConditionValue(rangeFilter.maxValue);
|
|
268
|
+
return {
|
|
269
|
+
expression: `${sortAttrKey} BETWEEN ${sortValueKey}_min AND ${sortValueKey}_max`,
|
|
270
|
+
attributeNames,
|
|
271
|
+
attributeValues,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
attributeValues[`${sortValueKey}_min`] = marshallKeyConditionValue(rangeFilter.minValue);
|
|
275
|
+
attributeValues[`${sortValueKey}_max`] = marshallKeyConditionValue(rangeFilter.maxValue);
|
|
276
|
+
return {
|
|
277
|
+
expression: `${sortAttrKey} ${rangeFilter.minExclude ? ">" : ">="} ${sortValueKey}_min AND ${sortAttrKey} ${rangeFilter.maxExclude ? "<" : "<="} ${sortValueKey}_max`,
|
|
278
|
+
attributeNames,
|
|
279
|
+
attributeValues,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
if (hasMin) {
|
|
283
|
+
attributeValues[sortValueKey] = marshallKeyConditionValue(rangeFilter.minValue);
|
|
284
|
+
return {
|
|
285
|
+
expression: `${sortAttrKey} ${rangeFilter.minExclude ? ">" : ">="} ${sortValueKey}`,
|
|
286
|
+
attributeNames,
|
|
287
|
+
attributeValues,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
attributeValues[sortValueKey] = marshallKeyConditionValue(rangeFilter.maxValue);
|
|
291
|
+
return {
|
|
292
|
+
expression: `${sortAttrKey} ${rangeFilter.maxExclude ? "<" : "<="} ${sortValueKey}`,
|
|
293
|
+
attributeNames,
|
|
294
|
+
attributeValues,
|
|
295
|
+
};
|
|
296
|
+
};
|
|
224
297
|
const generateIndexValues = (input, indexMap) => {
|
|
225
298
|
const result = { ...input };
|
|
226
299
|
for (const [, { field, rFields, fieldSeparator }] of indexMap.entries()) {
|
|
@@ -406,13 +479,15 @@ const parseLastEvaluatedKey = (lastKey) => {
|
|
|
406
479
|
};
|
|
407
480
|
exports.parseLastEvaluatedKey = parseLastEvaluatedKey;
|
|
408
481
|
function generateLastEvaluatedKey(item, indexField, sortField) {
|
|
409
|
-
if (!item?.id && !indexField)
|
|
482
|
+
if (!item?.id && (!indexField || !item?.[indexField]))
|
|
410
483
|
throw new Error("id or indexField not found");
|
|
411
|
-
const result = {
|
|
412
|
-
if (
|
|
413
|
-
|
|
414
|
-
if (
|
|
415
|
-
|
|
484
|
+
const result = {};
|
|
485
|
+
if (item?.id)
|
|
486
|
+
result.id = item.id;
|
|
487
|
+
if (indexField && item[indexField])
|
|
488
|
+
result[indexField] = item[indexField];
|
|
489
|
+
if (sortField && item[sortField])
|
|
490
|
+
result[sortField] = item[sortField];
|
|
416
491
|
return toBase64(JSON.stringify(result));
|
|
417
492
|
}
|
|
418
493
|
function toBase64(inputStr) {
|