storemw-core-api 1.0.162 → 1.0.164
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/controllers/index.d.ts +1 -0
- package/dist/controllers/index.js +4 -2
- package/dist/controllers/index.js.map +1 -1
- package/dist/controllers/scheduler/schedulerSqlController.d.ts +5 -0
- package/dist/controllers/scheduler/schedulerSqlController.js +77 -0
- package/dist/controllers/scheduler/schedulerSqlController.js.map +1 -0
- package/dist/features/index.d.ts +3 -0
- package/dist/features/index.js +5 -1
- package/dist/features/index.js.map +1 -1
- package/dist/features/scheduler_sql/schedulerSqlRegister.d.ts +6 -0
- package/dist/features/scheduler_sql/schedulerSqlRegister.js +11 -0
- package/dist/features/scheduler_sql/schedulerSqlRegister.js.map +1 -0
- package/dist/features/scheduler_sql/schedulerSqlRegistry.d.ts +3 -0
- package/dist/features/scheduler_sql/schedulerSqlRegistry.js +50 -0
- package/dist/features/scheduler_sql/schedulerSqlRegistry.js.map +1 -0
- package/dist/features/scheduler_sql/schedulerSqlType.d.ts +31 -0
- package/dist/features/scheduler_sql/schedulerSqlType.js +3 -0
- package/dist/features/scheduler_sql/schedulerSqlType.js.map +1 -0
- package/dist/lib/model_factory/ModelFactory.d.ts +7 -6
- package/dist/lib/model_factory/ModelFactory.js +595 -197
- package/dist/lib/model_factory/ModelFactory.js.map +1 -1
- package/dist/middlewares/route/index.d.ts +1 -1
- package/dist/middlewares/route/index.js +2 -1
- package/dist/middlewares/route/index.js.map +1 -1
- package/dist/middlewares/route/validateScheduler.d.ts +1 -0
- package/dist/middlewares/route/validateScheduler.js +6 -1
- package/dist/middlewares/route/validateScheduler.js.map +1 -1
- package/dist/models/access_control/AccessControlRoleModel.d.ts +4 -5
- package/dist/models/access_control/AccessControlRolePolicyModel.d.ts +4 -5
- package/dist/models/access_control/AccessControlUserRoleModel.d.ts +4 -5
- package/dist/models/account/AccountModel.d.ts +4 -5
- package/dist/models/auth/AccessKeyModel.d.ts +4 -5
- package/dist/models/branch/UserBranchModel.d.ts +4 -5
- package/dist/models/branch_user/BranchUserModel.d.ts +4 -5
- package/dist/models/business/BusinessModel.d.ts +4 -5
- package/dist/models/document/DocumentAmountModel.d.ts +4 -5
- package/dist/models/document/DocumentDocumentModel.d.ts +4 -5
- package/dist/models/document/DocumentItemModel.d.ts +4 -5
- package/dist/models/document/DocumentLocationModel.d.ts +4 -5
- package/dist/models/document/DocumentModel.d.ts +4 -5
- package/dist/models/document/DocumentPaymentModel.d.ts +4 -5
- package/dist/models/document/DocumentProfileModel.d.ts +4 -5
- package/dist/models/document/DocumentTotalModel.d.ts +4 -5
- package/dist/models/file/FileModel.d.ts +4 -5
- package/dist/models/group/GroupModel.d.ts +4 -5
- package/dist/models/group/GroupOwnerModel.d.ts +4 -5
- package/dist/models/injection_field/DocumentInjectionFieldModel.d.ts +4 -5
- package/dist/models/injection_field/InjectionFieldModel.d.ts +4 -5
- package/dist/models/injection_field/ItemInjectionFieldModel.d.ts +4 -5
- package/dist/models/injection_field/LogisticInjectionFieldModel.d.ts +4 -5
- package/dist/models/injection_field/RepositoryInjectionFieldModel.d.ts +4 -5
- package/dist/models/injection_field/UserInjectionFieldModel.d.ts +4 -5
- package/dist/models/item/BrandModel.d.ts +4 -5
- package/dist/models/item/CategoryModel.d.ts +4 -5
- package/dist/models/item/ItemModel.d.ts +4 -5
- package/dist/models/item/ProductModel.d.ts +4 -5
- package/dist/models/item/UomModel.d.ts +4 -5
- package/dist/models/location/LocationModel.d.ts +4 -5
- package/dist/models/location/LocationRackModel.d.ts +4 -5
- package/dist/models/location/LocationSlotModel.d.ts +4 -5
- package/dist/models/others/NumberDateSequenceModel.d.ts +4 -5
- package/dist/models/others/OneTimeCodeModel.d.ts +4 -5
- package/dist/models/region/AreaModel.d.ts +4 -5
- package/dist/models/region/CountryModel.d.ts +4 -5
- package/dist/models/region/StateModel.d.ts +4 -5
- package/dist/models/repository/RepositoryCartonModel.d.ts +4 -5
- package/dist/models/repository/RepositoryContainerModel.d.ts +4 -5
- package/dist/models/repository/RepositoryModel.d.ts +4 -5
- package/dist/models/repository/RepositoryPackageItemModel.d.ts +4 -5
- package/dist/models/repository/RepositoryPackageModel.d.ts +4 -5
- package/dist/models/repository/RepositoryPalletModel.d.ts +4 -5
- package/dist/models/scheduler/SchedulerLogModel.d.ts +4 -5
- package/dist/models/scheduler/SchedulerRequestModel.d.ts +4 -5
- package/dist/models/subscription/account/AccountSubscribeModel.d.ts +4 -5
- package/dist/models/subscription/plan/SubscribePlanModel.d.ts +4 -5
- package/dist/models/user/AdministratorModel.d.ts +4 -5
- package/dist/models/user/AgentModel.d.ts +4 -5
- package/dist/models/user/CustomerModel.d.ts +4 -5
- package/dist/models/user/DriverModel.d.ts +4 -5
- package/dist/models/user/MemberModel.d.ts +4 -5
- package/dist/models/user/OperatorModel.d.ts +4 -5
- package/dist/models/user/RetailerModel.d.ts +4 -5
- package/dist/models/user/UserModel.d.ts +4 -5
- package/dist/models/user/UserPropModel.d.ts +4 -5
- package/dist/models/user/WorkerModel.d.ts +4 -5
- package/dist/routes/scheduler/schedulerSqlRoutes.d.ts +2 -0
- package/dist/routes/scheduler/schedulerSqlRoutes.js +11 -0
- package/dist/routes/scheduler/schedulerSqlRoutes.js.map +1 -0
- package/dist/routes/scheduler/schedulersRoutes.js +3 -0
- package/dist/routes/scheduler/schedulersRoutes.js.map +1 -1
- package/dist/schema/payload/document/schemaDocumentCashSales.d.ts +64 -64
- package/dist/schema/payload/document/schemaDocumentDeliveryOrder.d.ts +64 -64
- package/dist/schema/payload/document/schemaDocumentProformaSales.d.ts +64 -64
- package/dist/schema/payload/document/schemaDocumentReplacementDeliveryOrder.d.ts +64 -64
- package/dist/schema/payload/document/schemaDocumentSalesOrder.d.ts +64 -64
- package/dist/schema/payload/index.d.ts +2 -0
- package/dist/schema/payload/index.js +3 -1
- package/dist/schema/payload/index.js.map +1 -1
- package/dist/schema/payload/scheduler/schemaSchedulerSql.d.ts +69 -0
- package/dist/schema/payload/scheduler/schemaSchedulerSql.js +19 -0
- package/dist/schema/payload/scheduler/schemaSchedulerSql.js.map +1 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +3 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/scheduler/SchedulerSqlService.d.ts +24 -0
- package/dist/services/scheduler/SchedulerSqlService.js +170 -0
- package/dist/services/scheduler/SchedulerSqlService.js.map +1 -0
- package/dist/utils/serviceUtils.d.ts +2 -0
- package/dist/utils/serviceUtils.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.schemaSchedulerSqlExecutePayload = exports.schemaSchedulerSqlScope = exports.schemaSchedulerSql = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.schemaSchedulerSql = zod_1.z.object({
|
|
6
|
+
schedulerSqlKey: zod_1.z.string().min(1)
|
|
7
|
+
});
|
|
8
|
+
exports.schemaSchedulerSqlScope = zod_1.z.object({
|
|
9
|
+
target: zod_1.z.literal("scheduler_sql"),
|
|
10
|
+
action: zod_1.z.string(),
|
|
11
|
+
});
|
|
12
|
+
/** Execute */
|
|
13
|
+
exports.schemaSchedulerSqlExecutePayload = zod_1.z.object({
|
|
14
|
+
scope: exports.schemaSchedulerSqlScope,
|
|
15
|
+
payload: zod_1.z.object({
|
|
16
|
+
schedulerSql: exports.schemaSchedulerSql
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=schemaSchedulerSql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaSchedulerSql.js","sourceRoot":"","sources":["../../../../src/schema/payload/scheduler/schemaSchedulerSql.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAIX,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACrC,CAAC,CAAA;AAEW,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,MAAM,EAAE,OAAC,CAAC,OAAO,CAAC,eAAe,CAAC;IAClC,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;CACrB,CAAC,CAAA;AAEF,cAAc;AACD,QAAA,gCAAgC,GAAG,OAAC,CAAC,MAAM,CAAC;IACrD,KAAK,EAAE,+BAAuB;IAC9B,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QACd,YAAY,EAAE,0BAAkB;KACnC,CAAC;CACL,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport { _, dayjs } from \"@/utils\";\n\nexport const schemaSchedulerSql = z.object({\n schedulerSqlKey: z.string().min(1)\n})\n\nexport const schemaSchedulerSqlScope = z.object({\n target: z.literal(\"scheduler_sql\"),\n action: z.string(),\n})\n\n/** Execute */\nexport const schemaSchedulerSqlExecutePayload = z.object({\n scope: schemaSchedulerSqlScope,\n payload: z.object({\n schedulerSql: schemaSchedulerSql\n })\n});\n\nexport type SchemaSchedulerSqlExecutePayload = z.infer<typeof schemaSchedulerSqlExecutePayload>;"]}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -48,5 +48,7 @@ export { SchedulerLogService, schedulerLogTypes } from "../services/scheduler/Sc
|
|
|
48
48
|
export type { SchedulerLogServiceProps, SchedulerLogFlowType, SchedulerLogModuleRef, SchedulerLogRemoveProps, SchedulerLogCreateProps, SchedulerLogListProps, SchedulerLogGetProps } from "../services/scheduler/SchedulerLogService";
|
|
49
49
|
export { SchedulerRequestService } from "../services/scheduler/SchedulerRequestService";
|
|
50
50
|
export type { SchedulerRequestServiceProps, SchedulerRequestModuleRef, SchedulerRequestRemoveProps, SchedulerRequestCreateProps, SchedulerRequestExecuteProps, SchedulerRequestListProps, SchedulerRequestGetProps } from "../services/scheduler/SchedulerRequestService";
|
|
51
|
+
export { SchedulerSqlService } from "../services/scheduler/SchedulerSqlService";
|
|
52
|
+
export type { SchedulerSqlServiceProps, SchedulerSqlExecuteProps } from "../services/scheduler/SchedulerSqlService";
|
|
51
53
|
export { AccessKeyUtilService } from "../services/utils/AccessKeyUtilService";
|
|
52
54
|
export type { AccessKeyUtilServiceProps, AccessKeyUtilValidateProps, AccessKeyUtilAccountOwnerProps } from "../services/utils/AccessKeyUtilService";
|
package/dist/services/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AccessKeyUtilService = exports.SchedulerRequestService = exports.schedulerLogTypes = exports.SchedulerLogService = exports.SmtpEmailService = exports.oneTimeCodeStatus = exports.oneTimeCodePurposeTypes = exports.oneTimeCodeTypes = exports.OneTimeCodeService = exports.NumberDateSequenceService = exports.injectionFieldDataTypes = exports.injectionFieldTypes = exports.InjectionFieldService = exports.LocationService = exports.FileService = exports.repositoryTypes = exports.RepositoryService = exports.itemTypes = exports.ItemService = exports.DocumentService = exports.RegionService = exports.userBranchTypes = exports.UserBranchService = exports.AccessControlUserService = exports.AccessControlRoleService = exports.UserMeService = exports.userParentSqlSelect = exports.userTypes = exports.UserService = exports.AccountSubscribeService = exports.subscribePlanBillingCycles = exports.subscribeCurrencies = exports.SubscribePlanService = exports.BusinessService = exports.AccountService = exports.resetPasswordMethods = exports.ResetPasswordService = exports.AccessControlService = exports.accessKeyStatus = exports.accessKeyUserTypes = exports.AccessKeyService = exports.authTypes = exports.AuthService = void 0;
|
|
3
|
+
exports.AccessKeyUtilService = exports.SchedulerSqlService = exports.SchedulerRequestService = exports.schedulerLogTypes = exports.SchedulerLogService = exports.SmtpEmailService = exports.oneTimeCodeStatus = exports.oneTimeCodePurposeTypes = exports.oneTimeCodeTypes = exports.OneTimeCodeService = exports.NumberDateSequenceService = exports.injectionFieldDataTypes = exports.injectionFieldTypes = exports.InjectionFieldService = exports.LocationService = exports.FileService = exports.repositoryTypes = exports.RepositoryService = exports.itemTypes = exports.ItemService = exports.DocumentService = exports.RegionService = exports.userBranchTypes = exports.UserBranchService = exports.AccessControlUserService = exports.AccessControlRoleService = exports.UserMeService = exports.userParentSqlSelect = exports.userTypes = exports.UserService = exports.AccountSubscribeService = exports.subscribePlanBillingCycles = exports.subscribeCurrencies = exports.SubscribePlanService = exports.BusinessService = exports.AccountService = exports.resetPasswordMethods = exports.ResetPasswordService = exports.AccessControlService = exports.accessKeyStatus = exports.accessKeyUserTypes = exports.AccessKeyService = exports.authTypes = exports.AuthService = void 0;
|
|
4
4
|
var AuthService_1 = require("../services/auth/AuthService");
|
|
5
5
|
Object.defineProperty(exports, "AuthService", { enumerable: true, get: function () { return AuthService_1.AuthService; } });
|
|
6
6
|
Object.defineProperty(exports, "authTypes", { enumerable: true, get: function () { return AuthService_1.authTypes; } });
|
|
@@ -68,6 +68,8 @@ Object.defineProperty(exports, "SchedulerLogService", { enumerable: true, get: f
|
|
|
68
68
|
Object.defineProperty(exports, "schedulerLogTypes", { enumerable: true, get: function () { return SchedulerLogService_1.schedulerLogTypes; } });
|
|
69
69
|
var SchedulerRequestService_1 = require("../services/scheduler/SchedulerRequestService");
|
|
70
70
|
Object.defineProperty(exports, "SchedulerRequestService", { enumerable: true, get: function () { return SchedulerRequestService_1.SchedulerRequestService; } });
|
|
71
|
+
var SchedulerSqlService_1 = require("../services/scheduler/SchedulerSqlService");
|
|
72
|
+
Object.defineProperty(exports, "SchedulerSqlService", { enumerable: true, get: function () { return SchedulerSqlService_1.SchedulerSqlService; } });
|
|
71
73
|
// export { ChangePasswordUtilService } from "../services/utils/unuse/ChangePasswordUtilService"
|
|
72
74
|
// export type { ChangePasswordUtilServiceProps, ChangePasswordUtilChangeProps } from "../services/utils/unuse/ChangePasswordUtilService"
|
|
73
75
|
var AccessKeyUtilService_1 = require("../services/utils/AccessKeyUtilService");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources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,8GAAA,aAAa,OAAA;AAEtB,uEAAqE;AAA5D,kHAAA,eAAe,OAAA;AAExB,2DAAoE;AAA3D,0GAAA,WAAW,OAAA;AAAE,wGAAA,SAAS,OAAA;AAE/B,6EAA4F;AAAnF,sHAAA,iBAAiB,OAAA;AAAE,oHAAA,eAAe,OAAA;AAE3C,2DAAyD;AAAhD,0GAAA,WAAW,OAAA;AAEpB,uEAAqE;AAA5D,kHAAA,eAAe,OAAA;AAExB,0FAAsI;AAA7H,8HAAA,qBAAqB,OAAA;AAAE,4HAAA,mBAAmB,OAAA;AAAE,gIAAA,uBAAuB,OAAA;AAE5E,yFAAuF;AAA9E,sIAAA,yBAAyB,OAAA;AAElC,kFAA8I;AAArI,wHAAA,kBAAkB,OAAA;AAAE,sHAAA,gBAAgB,OAAA;AAAE,6HAAA,uBAAuB,OAAA;AAAE,uHAAA,iBAAiB,OAAA;AAEzF,wEAAsE;AAA7D,oHAAA,gBAAgB,OAAA;AAGzB,gFAAiG;AAAxF,0HAAA,mBAAmB,OAAA;AAAE,wHAAA,iBAAiB,OAAA;AAE/C,wFAAsF;AAA7E,kIAAA,uBAAuB,OAAA;AAEhC,gFAA8E;AAArE,0HAAA,mBAAmB,OAAA;AAG5B,+FAA+F;AAC/F,wIAAwI;AACxI,8EAA4E;AAAnE,4HAAA,oBAAoB,OAAA","sourcesContent":["export { AuthService, authTypes } from \"@/services/auth/AuthService\"\nexport type { AuthServiceProps, AuthType, AuthTokenResult, AuthJwtToken, AuthGetTokenProps } from \"@/services/auth/AuthService\"\nexport { AccessKeyService, accessKeyUserTypes, accessKeyStatus } from \"@/services/access_key/AccessKeyService\"\nexport type { AccessKeyServiceProps, AccessKeyStatus, AccessKeyUserType, AccessKeyCreateProps, AccessKeyRevokeProps } from \"@/services/access_key/AccessKeyService\"\nexport { AccessControlService } from \"@/services/access_control/AccessControlService\"\nexport type { AccessControlServiceProps, AccessControlScopeOrExtra, AccessControlListOptionsProps } from \"@/services/access_control/AccessControlService\"\nexport { ResetPasswordService, resetPasswordMethods } from \"@/services/reset_password/ResetPasswordService\"\nexport type { ResetPasswordServiceProps, ResetPasswordMethod, ResetPasswordRequestProps, ResetPasswordValidateCodeProps, ResetPasswordPerformProps } from \"@/services/reset_password/ResetPasswordService\"\nexport { AccountService } from \"@/services/account/AccountService\"\nexport type { AccountServiceProps, Account, AccountGetProps, AccountListProps, AccountCreateProps, AccountUpdateProps, AccountRemoveProps } from \"@/services/account/AccountService\"\nexport { BusinessService } from \"@/services/business/BusinessService\"\nexport type { BusinessServiceProps, Business, BusinessGetProps, BusinessListProps, BusinessCreateProps, BusinessUpdateProps } from \"@/services/business/BusinessService\"\n\nexport { SubscribePlanService, subscribeCurrencies, subscribePlanBillingCycles } from \"@/services/subscription/plan/SubscribePlanService\"\nexport type { SubscribePlanServiceProps, SubscribePlan, SubscribePlanBillingCycle, SubscribePlanCurrency, SubscribePlanGetProps, SubscribePlanListProps, SubscribePlanCreateProps, SubscribePlanUpdateProps } from \"@/services/subscription/plan/SubscribePlanService\"\nexport { AccountSubscribeService } from \"@/services/subscription/account/AccountSubscribeService\"\nexport type { AccountSubscribeServiceProps, AccountSubscribe, AccountSubscribeGetProps, AccountSubscribeListProps, AccountSubscribeCreateProps, AccountSubscribeCancelProps } from \"@/services/subscription/account/AccountSubscribeService\"\n\nexport { UserService, userTypes, userParentSqlSelect } from \"@/services/user/UserService\"\nexport type { UserServiceProps, UserType, UserGetProps, UserListProps, UserCreateProps, UserUpdateProps, UserRemoveProps, UserReplacePasswordProps } from \"@/services/user/UserService\"\n\nexport { UserMeService } from \"@/services/user/UserMeService\"\nexport type { UserMeServiceProps, UserMeUpdateProps, UserMeChangePasswordProps } from \"@/services/user/UserMeService\"\n\nexport { AccessControlRoleService } from \"@/services/access_control/AccessControlRoleService\"\nexport type { AccessControlRoleServiceProps, AccessControlRoleUserType, AccessControlRoleGetProps, AccessControlRoleListProps, AccessControlRoleCreateProps, AccessControlRoleUpdateProps, AccessControlRoleRemoveProps } from \"@/services/access_control/AccessControlRoleService\"\n\nexport { AccessControlUserService } from \"@/services/access_control/AccessControlUserService\"\nexport type { AccessControlUserServiceProps, AccessControlUserAssignRolesProps } from \"@/services/access_control/AccessControlUserService\"\n\nexport { UserBranchService, userBranchTypes } from \"@/services/branch/UserBranchService\"\nexport type { UserBranchServiceProps, UserBranchType, UserBranchGetProps, UserBranchListProps, UserBranchCreateProps, UserBranchUpdateProps, UserBranchRemoveProps } from \"@/services/branch/UserBranchService\"\nexport { RegionService } from \"@/services/region/RegionService\"\nexport type { RegionServiceProps, RegionType, RegionGetProps, RegionCreateProps, RegionListProps, RegionUpdateProps, RegionRemoveProps } from \"@/services/region/RegionService\"\nexport { DocumentService } from \"@/services/document/DocumentService\"\nexport type { DocumentServiceProps, DocumentType, DocumentGetProps, DocumentUpdateProps, DocumentCreateProps, DocumentListProps, DocumentRemoveProps } from \"@/services/document/DocumentService\"\nexport { ItemService, itemTypes } from \"@/services/item/ItemService\"\nexport type { ItemServiceProps, ItemType, ItemGetProps, ItemUpdateProps, ItemCreateProps, ItemListProps, ItemRemoveProps } from \"@/services/item/ItemService\"\nexport { RepositoryService, repositoryTypes } from \"@/services/repository/RepositoryService\"\nexport type { RepositoryServiceProps, RepositoryType, RepositoryGetProps, RepositoryUpdateProps, RepositoryCreateProps, RepositoryListProps, RepositoryRemoveProps } from \"@/services/repository/RepositoryService\"\nexport { FileService } from \"@/services/file/FileService\"\nexport type { FileImageCompressionOptions, FileVideoCompressionOptions, FileStorageProviderType, FileLocalProviderOptions, FileGoogleCloudProviderOptions, FileAwsS3ProviderOptions, FileCategoryName, FileUploadItem, FileServiceProps, FileGetProps, FileUploadProps, FileCreateProps, FileListProps, FileRemoveProps } from \"@/services/file/FileService\"\nexport { LocationService } from \"@/services/location/LocationService\"\nexport type { LocationServiceProps, LocationType, LocationGetProps, LocationUpdateProps, LocationCreateProps, LocationListProps, LocationRemoveProps } from \"@/services/location/LocationService\"\nexport { InjectionFieldService, injectionFieldTypes, injectionFieldDataTypes } from \"@/services/injection_field/InjectionFieldService\"\nexport type { InjectionFieldModuleRef, InjectionFieldServiceProps, InjectionFieldType, InjectionFieldDataType, InjectionFieldCreateProps, InjectionFieldListProps, InjectionFieldGetProps, InjectionFieldReplaceProps } from \"@/services/injection_field/InjectionFieldService\"\nexport { NumberDateSequenceService } from \"@/services/others/NumberDateSequenceService\"\nexport type { NumberDateSequenceModuleRef, NumberDateSequenceServiceProps, NumberDateSequenceInitProps, NumberDateSequenceCreateProps } from \"@/services/others/NumberDateSequenceService\"\nexport { OneTimeCodeService, oneTimeCodeTypes, oneTimeCodePurposeTypes, oneTimeCodeStatus } from \"@/services/one_time_code/OneTimeCodeService\"\nexport type { OneTimeCodeModuleRef, OneTimeCodeType, OneTimeCodePurposeType, OneTimeCodeStatus, OneTimeCodeServiceProps, OneTimeCodeCreateProps } from \"@/services/one_time_code/OneTimeCodeService\"\nexport { SmtpEmailService } from \"@/services/gateway/SmtpEmailService\"\nexport type { SmtpEmailServiceProps, SmtpEmailSendProps, SmtpEmailTransporterOptions } from \"@/services/gateway/SmtpEmailService\"\n\nexport { SchedulerLogService, schedulerLogTypes } from \"@/services/scheduler/SchedulerLogService\"\nexport type { SchedulerLogServiceProps, SchedulerLogFlowType, SchedulerLogModuleRef, SchedulerLogRemoveProps, SchedulerLogCreateProps, SchedulerLogListProps, SchedulerLogGetProps } from \"@/services/scheduler/SchedulerLogService\"\nexport { SchedulerRequestService } from \"@/services/scheduler/SchedulerRequestService\"\nexport type { SchedulerRequestServiceProps, SchedulerRequestModuleRef, SchedulerRequestRemoveProps, SchedulerRequestCreateProps, SchedulerRequestExecuteProps, SchedulerRequestListProps, SchedulerRequestGetProps } from \"@/services/scheduler/SchedulerRequestService\"\nexport { SchedulerSqlService } from \"@/services/scheduler/SchedulerSqlService\"\nexport type { SchedulerSqlServiceProps, SchedulerSqlExecuteProps } from \"@/services/scheduler/SchedulerSqlService\"\n\n// export { ChangePasswordUtilService } from \"@/services/utils/unuse/ChangePasswordUtilService\"\n// export type { ChangePasswordUtilServiceProps, ChangePasswordUtilChangeProps } from \"@/services/utils/unuse/ChangePasswordUtilService\"\nexport { AccessKeyUtilService } from \"@/services/utils/AccessKeyUtilService\"\nexport type { AccessKeyUtilServiceProps, AccessKeyUtilValidateProps, AccessKeyUtilAccountOwnerProps } from \"@/services/utils/AccessKeyUtilService\""]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { QueryList, QueryGet } from "../../schema/common";
|
|
2
|
+
import { DefaultServiceProps } from "../../utils";
|
|
3
|
+
import { InjectionFieldModuleRef } from "../../services";
|
|
4
|
+
export type SchedulerSqlModuleRef = InjectionFieldModuleRef;
|
|
5
|
+
export type SchedulerSqlServiceProps = DefaultServiceProps & {};
|
|
6
|
+
export type SchedulerSqlGetProps = Omit<QueryGet, "datatypes"> & {
|
|
7
|
+
id: number;
|
|
8
|
+
};
|
|
9
|
+
export type SchedulerSqlListProps = Omit<QueryList, "datatypes"> & {};
|
|
10
|
+
export type SchedulerSqlExecuteProps = {
|
|
11
|
+
schedulerSqlKey: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const SchedulerSqlService: (props: SchedulerSqlServiceProps) => {
|
|
14
|
+
getSchedulerSql: ({ id }: SchedulerSqlGetProps) => Promise<any>;
|
|
15
|
+
executeSchedulerSql: ({ schedulerSqlKey }: SchedulerSqlExecuteProps) => Promise<{
|
|
16
|
+
data: any;
|
|
17
|
+
scheduler_sql_key: string;
|
|
18
|
+
custom_connection: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
listSchedulerSqls: ({ limit, offset, filters, sortfield, sortorder }: SchedulerSqlListProps) => Promise<{
|
|
21
|
+
data: any;
|
|
22
|
+
total: number;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchedulerSqlService = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const models_1 = require("../../models");
|
|
6
|
+
const client_1 = require("@prisma/client");
|
|
7
|
+
const utils_2 = require("../../utils");
|
|
8
|
+
const lib_1 = require("../../lib");
|
|
9
|
+
const features_1 = require("../../features");
|
|
10
|
+
const lib_2 = require("../../lib");
|
|
11
|
+
const prismaCache = new Map();
|
|
12
|
+
const { relationKeys, sqlRelationMaps } = (0, lib_1.getSchedulerLogSqlRelationMaps)();
|
|
13
|
+
let mainSqlSelect = (0, lib_2.buildSchedulerLogMainSqlSelect)();
|
|
14
|
+
let defaultSqlSelect = (0, lib_2.buildSchedulerLogDefaultSqlSelect)();
|
|
15
|
+
const SchedulerSqlService = (props) => {
|
|
16
|
+
const { ...rest } = props;
|
|
17
|
+
const schedulerLogModel = (0, models_1.SchedulerLogModel)({ ...rest });
|
|
18
|
+
const buildPrismaUrl = (conn) => {
|
|
19
|
+
if (conn.provider === "mysql") {
|
|
20
|
+
return `mysql://${conn.username}:${conn.password}@${conn.host}:${conn.port}/${conn.database}`;
|
|
21
|
+
}
|
|
22
|
+
if (conn.provider === "postgresql") {
|
|
23
|
+
return `postgresql://${conn.username}:${conn.password}@${conn.host}:${conn.port}/${conn.database}`;
|
|
24
|
+
}
|
|
25
|
+
throw new Error(`Unsupported DB type: ${conn?.provider ?? "-"}`);
|
|
26
|
+
};
|
|
27
|
+
const getCustomPrismaClient = (connection) => {
|
|
28
|
+
const url = buildPrismaUrl(connection);
|
|
29
|
+
if (prismaCache.has(url)) {
|
|
30
|
+
return prismaCache.get(url);
|
|
31
|
+
}
|
|
32
|
+
const client = new client_1.PrismaClient({
|
|
33
|
+
datasources: {
|
|
34
|
+
db: { url },
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
prismaCache.set(url, client);
|
|
38
|
+
return client;
|
|
39
|
+
};
|
|
40
|
+
const executeSchedulerSql = async ({ schedulerSqlKey }) => {
|
|
41
|
+
const hookSetup = await features_1.SchedulerSqlHook.onSetup();
|
|
42
|
+
// validate the sql key is in the setup hook given
|
|
43
|
+
if (!(schedulerSqlKey in hookSetup)) {
|
|
44
|
+
(0, utils_1.throwError)(`Invalid Scheduler Sql Key in the feature config setup: ${schedulerSqlKey}`);
|
|
45
|
+
}
|
|
46
|
+
// console.log('hookSetup', hookSetup, schedulerSqlKey)
|
|
47
|
+
const selectedSqlConfig = hookSetup[schedulerSqlKey];
|
|
48
|
+
// console.log('selectedSqlConfig', selectedSqlConfig)
|
|
49
|
+
const sqlRaw = `${selectedSqlConfig.query.raw}`;
|
|
50
|
+
const connection = selectedSqlConfig.connection;
|
|
51
|
+
let responseData;
|
|
52
|
+
let response = {
|
|
53
|
+
scheduler_sql_key: `${schedulerSqlKey}`,
|
|
54
|
+
custom_connection: Boolean(connection),
|
|
55
|
+
data: null
|
|
56
|
+
};
|
|
57
|
+
try {
|
|
58
|
+
// use back the default prisma connection
|
|
59
|
+
if (!connection) {
|
|
60
|
+
responseData = await schedulerLogModel.raw(sqlRaw);
|
|
61
|
+
}
|
|
62
|
+
else { // direct connect to provider via prisma
|
|
63
|
+
const dbClient = getCustomPrismaClient(connection);
|
|
64
|
+
responseData = await dbClient.$queryRawUnsafe(sqlRaw);
|
|
65
|
+
}
|
|
66
|
+
let customResponseData = null;
|
|
67
|
+
// Call the consumer hook, if success
|
|
68
|
+
if (features_1.SchedulerSqlHook?.onSuccessExecute) {
|
|
69
|
+
customResponseData = await features_1.SchedulerSqlHook.onSuccessExecute((0, utils_2.buildFeatureCallbackProps)({
|
|
70
|
+
defaultServiceProps: rest,
|
|
71
|
+
callbackParams: {
|
|
72
|
+
schedulerSql: {
|
|
73
|
+
...response,
|
|
74
|
+
data: responseData,
|
|
75
|
+
selectedSqlConfig
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
...response,
|
|
82
|
+
data: customResponseData ? customResponseData : responseData
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
const err = error;
|
|
87
|
+
const errorMessage = err?.message ?? String(err) ?? "-";
|
|
88
|
+
// Call the consumer hook, if fail
|
|
89
|
+
if (features_1.SchedulerSqlHook?.onFailExecute) {
|
|
90
|
+
await features_1.SchedulerSqlHook.onFailExecute((0, utils_2.buildFeatureCallbackProps)({
|
|
91
|
+
defaultServiceProps: rest,
|
|
92
|
+
callbackParams: {
|
|
93
|
+
schedulerSql: {
|
|
94
|
+
...response,
|
|
95
|
+
selectedSqlConfig,
|
|
96
|
+
errorMessage
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const getSchedulerSql = async ({ id }) => {
|
|
105
|
+
let { data } = await listSchedulerSqls({
|
|
106
|
+
limit: 1,
|
|
107
|
+
offset: 0,
|
|
108
|
+
filters: [{ field: `${models_1.ModelSchedulerLogFields.scheduler_log_id}`, operator: "=", value: id }],
|
|
109
|
+
sortfield: `${models_1.ModelSchedulerLogFields.scheduler_log_id}`,
|
|
110
|
+
sortorder: "ASC",
|
|
111
|
+
});
|
|
112
|
+
return data[0] ?? null;
|
|
113
|
+
};
|
|
114
|
+
const listSchedulerSqls = async ({ limit, offset, filters = [], sortfield, sortorder }) => {
|
|
115
|
+
let sqlSelect = [
|
|
116
|
+
(0, lib_1.buildSqlSelect)(``, mainSqlSelect),
|
|
117
|
+
(0, lib_1.buildSqlSelect)(``, defaultSqlSelect)
|
|
118
|
+
];
|
|
119
|
+
let sqlRelation = [
|
|
120
|
+
(0, lib_1.buildSqlRelation)("left", "sreq", "users", "creator", ["sreq.createuserid = creator.user_id", "creator.isdelete = false", "creator.istrash = false"]),
|
|
121
|
+
(0, lib_1.buildSqlRelation)("left", "sreq", "users", "updater", ["sreq.updateuserid = updater.user_id", "updater.isdelete = false", "updater.istrash = false"])
|
|
122
|
+
];
|
|
123
|
+
let sqlGroupBy = [
|
|
124
|
+
...Object.keys(mainSqlSelect),
|
|
125
|
+
...Object.keys(defaultSqlSelect)
|
|
126
|
+
];
|
|
127
|
+
let filterColumns = {
|
|
128
|
+
...mainSqlSelect,
|
|
129
|
+
...defaultSqlSelect
|
|
130
|
+
};
|
|
131
|
+
let sqlWhere = [
|
|
132
|
+
`sreq.isdelete = false`,
|
|
133
|
+
`sreq.istrash = false`,
|
|
134
|
+
...(filters.length ? [(0, lib_1.buildSqlWhere)(filters, filterColumns)?.where] : []),
|
|
135
|
+
];
|
|
136
|
+
let sqlOrderby = (0, lib_1.buildSqlOrderBy)(sortfield, sortorder);
|
|
137
|
+
let sqlLimitOffset = (0, lib_1.buildSqlLimitOffset)(limit, offset);
|
|
138
|
+
// get the listing data & count
|
|
139
|
+
const { data, total } = await (0, lib_1.getListWithCount)({
|
|
140
|
+
model: schedulerLogModel,
|
|
141
|
+
tableName: "scheduler_requests",
|
|
142
|
+
mainAlias: "sreq",
|
|
143
|
+
countKey: `${models_1.ModelSchedulerLogFields.scheduler_log_id}`,
|
|
144
|
+
accountId: rest.accountId,
|
|
145
|
+
sqlRelationMaps,
|
|
146
|
+
filters,
|
|
147
|
+
filterColumns,
|
|
148
|
+
sqlSelect,
|
|
149
|
+
sqlSelectAgg: [],
|
|
150
|
+
sqlRelation,
|
|
151
|
+
sqlRelationAgg: [],
|
|
152
|
+
sqlWhere,
|
|
153
|
+
sqlGroupBy,
|
|
154
|
+
sqlOrderby,
|
|
155
|
+
sqlLimitOffset
|
|
156
|
+
});
|
|
157
|
+
const response = {
|
|
158
|
+
data,
|
|
159
|
+
total
|
|
160
|
+
};
|
|
161
|
+
return response;
|
|
162
|
+
};
|
|
163
|
+
return {
|
|
164
|
+
getSchedulerSql,
|
|
165
|
+
executeSchedulerSql,
|
|
166
|
+
listSchedulerSqls
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
exports.SchedulerSqlService = SchedulerSqlService;
|
|
170
|
+
//# sourceMappingURL=SchedulerSqlService.js.map
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AuB;YACvB,sBAAsB;YACtB,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAA,mBAAa,EAAC,OAAO,EAAE,aAAa,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5E,CAAA;QAED,IAAI,UAAU,GAAG,IAAA,qBAAe,EAAC,SAAS,EAAE,SAAS,CAAC,CAAA;QACtD,IAAI,cAAc,GAAG,IAAA,yBAAmB,EAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAEvD,+BAA+B;QAC/B,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,IAAA,sBAAgB,EAAC;YAC3C,KAAK,EAAE,iBAAiB;YACxB,SAAS,EAAE,oBAAoB;YAC/B,SAAS,EAAE,MAAM;YACjB,QAAQ,EAAE,GAAG,gCAAuB,CAAC,gBAAgB,EAAE;YACvD,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,eAAe;YACf,OAAO;YACP,aAAa;YACb,SAAS;YACT,YAAY,EAAE,EAAE;YAChB,WAAW;YACX,cAAc,EAAE,EAAE;YAClB,QAAQ;YACR,UAAU;YACV,UAAU;YACV,cAAc;SACjB,CAAC,CAAA;QAEF,MAAM,QAAQ,GAAG;YACb,IAAI;YACJ,KAAK;SACR,CAAA;QAED,OAAO,QAAQ,CAAA;IAEnB,CAAC,CAAC;IAEF,OAAO;QACH,eAAe;QACf,mBAAmB;QACnB,iBAAiB;KACpB,CAAA;AAEL,CAAC,CAAA;AAzMY,QAAA,mBAAmB,uBAyM/B","sourcesContent":["import { logError, throwError } from \"@/utils\";\n\nimport {\n SchedulerLogModel,\n ModelSchedulerLogFields\n} from \"@/models\";\n\nimport { PrismaClient } from \"@prisma/client\"\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\n\nimport { DefaultServiceProps, getCurrentDateTimeISO, buildFeatureCallbackProps } from \"@/utils\";\n\nimport { InjectionFieldModuleRef } from \"@/services\"\n\nimport { getSchedulerLogSqlRelationMaps, buildSqlRelation, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy, getListWithCount } from \"@/lib\";\n\nimport { SchedulerSqlHook, FeatureSchedulerSqlSetupItemConnection, FeatureSchedulerSqlSetupItemQuery } from \"@/features\"\n\nimport {\n buildSchedulerLogDefaultSqlSelect,\n buildSchedulerLogMainSqlSelect\n} from \"@/lib\";\n\nexport type SchedulerSqlModuleRef = InjectionFieldModuleRef\n\nexport type SchedulerSqlServiceProps = DefaultServiceProps & {};\n\nexport type SchedulerSqlGetProps = Omit<QueryGet, \"datatypes\"> & {\n id: number,\n};\n\nexport type SchedulerSqlListProps = Omit<QueryList, \"datatypes\"> & {\n};\n\nexport type SchedulerSqlExecuteProps = {\n schedulerSqlKey: string,\n}\n\nconst prismaCache = new Map<string, PrismaClient>()\n\nconst { relationKeys, sqlRelationMaps } = getSchedulerLogSqlRelationMaps()\n\nlet mainSqlSelect = buildSchedulerLogMainSqlSelect()\nlet defaultSqlSelect = buildSchedulerLogDefaultSqlSelect()\n\nexport const SchedulerSqlService = (props: SchedulerSqlServiceProps) => {\n\n const {\n ...rest\n } = props\n\n const schedulerLogModel = SchedulerLogModel({ ...rest })\n\n const buildPrismaUrl = (conn: FeatureSchedulerSqlSetupItemConnection) => {\n if (conn.provider === \"mysql\") {\n return `mysql://${conn.username}:${conn.password}@${conn.host}:${conn.port}/${conn.database}`\n }\n\n if (conn.provider === \"postgresql\") {\n return `postgresql://${conn.username}:${conn.password}@${conn.host}:${conn.port}/${conn.database}`\n }\n\n throw new Error(`Unsupported DB type: ${conn?.provider ?? \"-\"}`)\n }\n\n const getCustomPrismaClient = (connection: FeatureSchedulerSqlSetupItemConnection) => {\n\n const url = buildPrismaUrl(connection)\n\n if (prismaCache.has(url)) {\n return prismaCache.get(url)!\n }\n\n const client = new PrismaClient({\n datasources: {\n db: { url },\n },\n })\n\n prismaCache.set(url, client)\n\n return client\n }\n\n const executeSchedulerSql = async ({ schedulerSqlKey }: SchedulerSqlExecuteProps) => {\n\n const hookSetup = await SchedulerSqlHook.onSetup()\n\n // validate the sql key is in the setup hook given\n if (!(schedulerSqlKey in hookSetup)) {\n throwError(`Invalid Scheduler Sql Key in the feature config setup: ${schedulerSqlKey}`)\n }\n\n // console.log('hookSetup', hookSetup, schedulerSqlKey)\n\n const selectedSqlConfig = hookSetup[schedulerSqlKey as keyof typeof hookSetup]\n\n // console.log('selectedSqlConfig', selectedSqlConfig)\n\n const sqlRaw = `${selectedSqlConfig.query.raw}`\n\n const connection = selectedSqlConfig.connection\n\n let responseData: any\n let response = {\n scheduler_sql_key: `${schedulerSqlKey}`,\n custom_connection: Boolean(connection),\n data: null\n }\n\n try {\n\n // use back the default prisma connection\n if (!connection) {\n responseData = await schedulerLogModel.raw(sqlRaw)\n } else { // direct connect to provider via prisma\n const dbClient = getCustomPrismaClient(connection)\n responseData = await dbClient.$queryRawUnsafe(sqlRaw)\n }\n\n let customResponseData: any = null\n\n // Call the consumer hook, if success\n if (SchedulerSqlHook?.onSuccessExecute) {\n customResponseData = await SchedulerSqlHook.onSuccessExecute(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n schedulerSql: {\n ...response,\n data: responseData,\n selectedSqlConfig\n }\n }\n }))\n }\n\n return {\n ...response,\n data: customResponseData ? customResponseData : responseData\n }\n\n } catch (error: unknown) {\n\n const err = error as any\n\n const errorMessage =\n err?.message ?? String(err) ?? \"-\"\n\n // Call the consumer hook, if fail\n if (SchedulerSqlHook?.onFailExecute) {\n await SchedulerSqlHook.onFailExecute(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n schedulerSql: {\n ...response,\n selectedSqlConfig,\n errorMessage\n }\n }\n }))\n }\n\n throw error\n }\n }\n\n const getSchedulerSql = async ({ id }: SchedulerSqlGetProps) => {\n\n let { data } = await listSchedulerSqls({\n limit: 1,\n offset: 0,\n filters: [{ field: `${ModelSchedulerLogFields.scheduler_log_id}`, operator: \"=\", value: id }],\n sortfield: `${ModelSchedulerLogFields.scheduler_log_id}`,\n sortorder: \"ASC\",\n })\n\n return data[0] ?? null;\n\n };\n\n const listSchedulerSqls = async ({ limit, offset, filters = [], sortfield, sortorder }: SchedulerSqlListProps) => {\n\n let sqlSelect = [\n buildSqlSelect(``, mainSqlSelect),\n buildSqlSelect(``, defaultSqlSelect)\n ]\n\n let sqlRelation = [\n buildSqlRelation(\"left\", \"sreq\", \"users\", \"creator\", [\"sreq.createuserid = creator.user_id\", \"creator.isdelete = false\", \"creator.istrash = false\"]),\n buildSqlRelation(\"left\", \"sreq\", \"users\", \"updater\", [\"sreq.updateuserid = updater.user_id\", \"updater.isdelete = false\", \"updater.istrash = false\"])\n ]\n\n let sqlGroupBy: string[] = [\n ...Object.keys(mainSqlSelect),\n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n ...defaultSqlSelect\n }\n\n let sqlWhere = [\n `sreq.isdelete = false`,\n `sreq.istrash = false`,\n ...(filters.length ? [buildSqlWhere(filters, filterColumns)?.where] : []),\n ]\n\n let sqlOrderby = buildSqlOrderBy(sortfield, sortorder)\n let sqlLimitOffset = buildSqlLimitOffset(limit, offset)\n\n // get the listing data & count\n const { data, total } = await getListWithCount({\n model: schedulerLogModel,\n tableName: \"scheduler_requests\",\n mainAlias: \"sreq\",\n countKey: `${ModelSchedulerLogFields.scheduler_log_id}`,\n accountId: rest.accountId,\n sqlRelationMaps,\n filters,\n filterColumns,\n sqlSelect,\n sqlSelectAgg: [],\n sqlRelation,\n sqlRelationAgg: [],\n sqlWhere,\n sqlGroupBy,\n sqlOrderby,\n sqlLimitOffset\n })\n\n const response = {\n data,\n total\n }\n\n return response\n\n };\n\n return {\n getSchedulerSql,\n executeSchedulerSql,\n listSchedulerSqls\n }\n\n}\n\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Request } from "express";
|
|
2
|
+
import type { Prisma } from "@prisma/client";
|
|
2
3
|
export type DefaultServiceProps = {
|
|
3
4
|
accountId: number;
|
|
4
5
|
actionUserId: number;
|
|
@@ -8,6 +9,7 @@ export type DefaultServiceProps = {
|
|
|
8
9
|
accessKey?: string;
|
|
9
10
|
accessKeyId?: string;
|
|
10
11
|
req?: Request;
|
|
12
|
+
tx?: Prisma.TransactionClient;
|
|
11
13
|
};
|
|
12
14
|
export declare const getDefaultServiceProps: (req: Request) => DefaultServiceProps;
|
|
13
15
|
export declare const generateServiceProps: ({ buildType, accessKey }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceUtils.js","sourceRoot":"","sources":["../../src/utils/serviceUtils.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"serviceUtils.js","sourceRoot":"","sources":["../../src/utils/serviceUtils.ts"],"names":[],"mappings":";;;AAIA,yCAA6D;AAC7D,qDAA8C;AAE9C,uDAAyD;AAelD,MAAM,sBAAsB,GAAG,CAAC,GAAY,EAAuB,EAAE;IAExE,MAAM,kBAAkB,GAAI,GAAW,EAAE,IAAI,IAAI,EAAE,CAAA;IACnD,MAAM,SAAS,GAAI,GAAW,EAAE,SAAS,IAAI,EAAE,CAAA;IAC/C,MAAM,YAAY,GAAI,GAAW,EAAE,YAAY,IAAI,EAAE,CAAA;IACrD,MAAM,cAAc,GAAI,GAAW,EAAE,cAAc,IAAI,EAAE,CAAA;IAEzD,MAAM,EACF,SAAS,GAAG,EAAE,EACd,UAAU,GAAG,KAAK,EAClB,SAAS,GAAG,EAAE,EACd,WAAW,GAAG,EAAE,EACnB,GAAG,kBAAkB,CAAA;IAEtB,OAAO;QACH,SAAS;QACT,YAAY;QACZ,cAAc;QACd,SAAS;QACT,UAAU;QACV,SAAS;QACT,WAAW;QACX,GAAG;KACN,CAAA;AACL,CAAC,CAAA;AAxBY,QAAA,sBAAsB,0BAwBlC;AAEM,MAAM,oBAAoB,GAAG,KAAK,EAAE,EACvC,SAAS,GAAG,YAAY,EACxB,SAAS,EAIZ,EAAgC,EAAE;IAE/B,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,sCAAoB,GAAE,CAAA;IAEzC,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,IAAA,2BAAU,EAAC,kEAAkE,CAAC,CAAA;IAClF,CAAC;IAED,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,IAAA,2BAAU,EAAC,8DAA8D,CAAC,CAAA;IAC9E,CAAC;IAED,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,IAAA,2BAAU,EAAC,kEAAkE,CAAC,CAAA;IAClF,CAAC;IAED,MAAM,oBAAoB,GAAG,IAAA,+BAAoB,EAAC;QAC9C,SAAS,EAAE,CAAC;QACZ,YAAY,EAAE,CAAC;QACf,cAAc,EAAE,EAAE;QAClB,SAAS,EAAE,EAAE;QACb,UAAU,EAAE,IAAI;QAChB,SAAS,EAAE,EAAE;QACb,WAAW,EAAE,EAAE;QACf,iBAAiB,EAAE,UAAU;KAChC,CAAC,CAAA;IAEF,MAAM,kBAAkB,GAAG,MAAM,oBAAoB,CAAC,iBAAiB,CAAC;QACpE,IAAI,EAAE;YACF,SAAS;SACZ;KACJ,CAAC,CAAA;IAEF,8EAA8E;IAE9E,OAAO;QACH,SAAS,EAAE,MAAM,CAAC,kBAAkB,EAAE,SAAS,CAAC;QAChD,YAAY,EAAE,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC;QACjD,cAAc,EAAE,kBAAkB,EAAE,SAAS,IAAI,EAAE;QACnD,SAAS,EAAE,EAAE;QACb,SAAS;QACT,WAAW,EAAE,kBAAkB,EAAE,aAAa,IAAI,EAAE;QACpD,UAAU,EAAE,kBAAkB,EAAE,SAAS,KAAK,oBAAS,CAAC,QAAQ;KACnE,CAAA;AAEL,CAAC,CAAA;AAnDY,QAAA,oBAAoB,wBAmDhC","sourcesContent":["import { Request } from \"express\";\n\nimport type { Prisma } from \"@prisma/client\";\n\nimport { AccessKeyUtilService, userTypes } from \"@/services\";\nimport { throwError } from \"./exceptionUtils\";\n\nimport { getCoreConfiguration } from \"./coreConfigUtils\";\n\nexport type DefaultServiceProps = {\n accountId: number,\n actionUserId: number,\n actionUserType: string,\n authToken: string,\n isOperator: boolean,\n accessKey?: string,\n accessKeyId?: string\n req?: Request,\n // ✅ ADD THIS\n tx?: Prisma.TransactionClient\n}\n\nexport const getDefaultServiceProps = (req: Request): DefaultServiceProps => {\n\n const requestAuthContext = (req as any)?.auth ?? {}\n const accountId = (req as any)?.accountId ?? \"\"\n const actionUserId = (req as any)?.actionUserId ?? \"\"\n const actionUserType = (req as any)?.actionUserType ?? \"\"\n\n const {\n authToken = '',\n isOperator = false,\n accessKey = '',\n accessKeyId = ''\n } = requestAuthContext\n\n return {\n accountId,\n actionUserId,\n actionUserType,\n authToken,\n isOperator,\n accessKey,\n accessKeyId,\n req\n }\n}\n\nexport const generateServiceProps = async ({\n buildType = \"access_key\",\n accessKey\n}: {\n buildType?: \"access_key\",\n accessKey: string,\n}): Promise<DefaultServiceProps> => {\n\n const { prisma } = getCoreConfiguration()\n\n if (!buildType) {\n throwError(`Build Type is required in generate service props from access key`)\n }\n\n if (!prisma) {\n throwError(`Prisma is required in generate service props from access key`)\n }\n\n if (!accessKey) {\n throwError(`Access Key is required in generate service props from access key`)\n }\n\n const accessKeyUtilService = AccessKeyUtilService({\n accountId: 0,\n actionUserId: 0,\n actionUserType: \"\",\n authToken: '',\n isOperator: true,\n accessKey: '',\n accessKeyId: '',\n accessKeyUserType: \"operator\"\n })\n\n const validatedAccessKey = await accessKeyUtilService.validateAccessKey({\n data: {\n accessKey\n }\n })\n\n // console.log('defaultServiceProps', defaultServiceProps, validatedAccessKey)\n\n return {\n accountId: Number(validatedAccessKey?.accountid),\n actionUserId: Number(validatedAccessKey?.user_id),\n actionUserType: validatedAccessKey?.user_type ?? \"\",\n authToken: \"\",\n accessKey,\n accessKeyId: validatedAccessKey?.access_key_id ?? \"\",\n isOperator: validatedAccessKey?.user_type === userTypes.operator,\n }\n\n}"]}
|