storemw-core-api 1.0.150 → 1.0.152
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/lib/index.d.ts +1 -0
- package/dist/lib/index.js +5 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/query_builder/queryScheduler.d.ts +13 -0
- package/dist/lib/query_builder/queryScheduler.js +56 -0
- package/dist/lib/query_builder/queryScheduler.js.map +1 -0
- package/dist/services/scheduler/SchedulerLogService.d.ts +1 -1
- package/dist/services/scheduler/SchedulerLogService.js +33 -35
- package/dist/services/scheduler/SchedulerLogService.js.map +1 -1
- package/package.json +1 -1
package/dist/lib/index.d.ts
CHANGED
|
@@ -8,3 +8,4 @@ export type { CustomizeTransformProps } from "./customize/CustomizeTransform";
|
|
|
8
8
|
export { toFieldMap, buildSqlRawSelect, buildSqlRawSelectCount, buildSqlRelation, buildSqlSelect, buildSqlWhere, buildSqlLimitOffset, buildSqlOrderBy, getFieldsByType, buildInjectionFieldsSqlSelect, getListWithCount } from "./query_builder/queryBuilder";
|
|
9
9
|
export { getDocumentSqlRelationMaps, buildDocumentMainSqlSelect, buildDocumentDefaultSqlSelect, buildDocumentProfileSqlSelect, buildDocumentLocationSqlSelect, buildDocumentTotalSqlSelect, buildDocumentItemSqlSelectAgg, buildDocumentItemSqlSelect, buildDocumentDocumentSqlSelectAgg, buildDocumentDocumentSqlSelect } from "./query_builder/queryDocument";
|
|
10
10
|
export { getFileSqlRelationMaps, buildFileMainSqlSelect, buildFileDefaultSqlSelect, } from "./query_builder/queryFile";
|
|
11
|
+
export { getSchedulerLogSqlRelationMaps, buildSchedulerLogMainSqlSelect, buildSchedulerLogDefaultSqlSelect, } from "./query_builder/queryScheduler";
|
package/dist/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildFileDefaultSqlSelect = exports.buildFileMainSqlSelect = exports.getFileSqlRelationMaps = exports.buildDocumentDocumentSqlSelect = exports.buildDocumentDocumentSqlSelectAgg = exports.buildDocumentItemSqlSelect = exports.buildDocumentItemSqlSelectAgg = exports.buildDocumentTotalSqlSelect = exports.buildDocumentLocationSqlSelect = exports.buildDocumentProfileSqlSelect = exports.buildDocumentDefaultSqlSelect = exports.buildDocumentMainSqlSelect = exports.getDocumentSqlRelationMaps = exports.getListWithCount = exports.buildInjectionFieldsSqlSelect = exports.getFieldsByType = exports.buildSqlOrderBy = exports.buildSqlLimitOffset = exports.buildSqlWhere = exports.buildSqlSelect = exports.buildSqlRelation = exports.buildSqlRawSelectCount = exports.buildSqlRawSelect = exports.toFieldMap = exports.CustomizeTransform = exports.serviceFactoryAllowUserTypes = exports.serviceFactoryNames = exports.ServiceFactory = exports.ModelFactory = exports.prisma = void 0;
|
|
3
|
+
exports.buildSchedulerLogDefaultSqlSelect = exports.buildSchedulerLogMainSqlSelect = exports.getSchedulerLogSqlRelationMaps = exports.buildFileDefaultSqlSelect = exports.buildFileMainSqlSelect = exports.getFileSqlRelationMaps = exports.buildDocumentDocumentSqlSelect = exports.buildDocumentDocumentSqlSelectAgg = exports.buildDocumentItemSqlSelect = exports.buildDocumentItemSqlSelectAgg = exports.buildDocumentTotalSqlSelect = exports.buildDocumentLocationSqlSelect = exports.buildDocumentProfileSqlSelect = exports.buildDocumentDefaultSqlSelect = exports.buildDocumentMainSqlSelect = exports.getDocumentSqlRelationMaps = exports.getListWithCount = exports.buildInjectionFieldsSqlSelect = exports.getFieldsByType = exports.buildSqlOrderBy = exports.buildSqlLimitOffset = exports.buildSqlWhere = exports.buildSqlSelect = exports.buildSqlRelation = exports.buildSqlRawSelectCount = exports.buildSqlRawSelect = exports.toFieldMap = exports.CustomizeTransform = exports.serviceFactoryAllowUserTypes = exports.serviceFactoryNames = exports.ServiceFactory = exports.ModelFactory = exports.prisma = void 0;
|
|
4
4
|
var prisma_1 = require("./prisma/prisma");
|
|
5
5
|
Object.defineProperty(exports, "prisma", { enumerable: true, get: function () { return prisma_1.prisma; } });
|
|
6
6
|
var ModelFactory_1 = require("./model_factory/ModelFactory");
|
|
@@ -39,4 +39,8 @@ var queryFile_1 = require("./query_builder/queryFile");
|
|
|
39
39
|
Object.defineProperty(exports, "getFileSqlRelationMaps", { enumerable: true, get: function () { return queryFile_1.getFileSqlRelationMaps; } });
|
|
40
40
|
Object.defineProperty(exports, "buildFileMainSqlSelect", { enumerable: true, get: function () { return queryFile_1.buildFileMainSqlSelect; } });
|
|
41
41
|
Object.defineProperty(exports, "buildFileDefaultSqlSelect", { enumerable: true, get: function () { return queryFile_1.buildFileDefaultSqlSelect; } });
|
|
42
|
+
var queryScheduler_1 = require("./query_builder/queryScheduler");
|
|
43
|
+
Object.defineProperty(exports, "getSchedulerLogSqlRelationMaps", { enumerable: true, get: function () { return queryScheduler_1.getSchedulerLogSqlRelationMaps; } });
|
|
44
|
+
Object.defineProperty(exports, "buildSchedulerLogMainSqlSelect", { enumerable: true, get: function () { return queryScheduler_1.buildSchedulerLogMainSqlSelect; } });
|
|
45
|
+
Object.defineProperty(exports, "buildSchedulerLogDefaultSqlSelect", { enumerable: true, get: function () { return queryScheduler_1.buildSchedulerLogDefaultSqlSelect; } });
|
|
42
46
|
//# sourceMappingURL=index.js.map
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;AAAA,0CAAwC;AAA/B,gGAAA,MAAM,OAAA;AAEf,6DAA2D;AAAlD,4GAAA,YAAY,OAAA;AAGrB,mEAAoH;AAA3G,gHAAA,cAAc,OAAA;AAAE,qHAAA,mBAAmB,OAAA;AAAE,8HAAA,4BAA4B,OAAA;AAG1E,qEAAmE;AAA1D,wHAAA,kBAAkB,OAAA;AAG3B,6DAA6P;AAApP,0GAAA,UAAU,OAAA;AAAE,iHAAA,iBAAiB,OAAA;AAAE,sHAAA,sBAAsB,OAAA;AAAE,gHAAA,gBAAgB,OAAA;AAAE,8GAAA,cAAc,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,mHAAA,mBAAmB,OAAA;AAAE,+GAAA,eAAe,OAAA;AAAE,+GAAA,eAAe,OAAA;AAAE,6HAAA,6BAA6B,OAAA;AAAE,gHAAA,gBAAgB,OAAA;AAEvN,+DAYsC;AAXlC,2HAAA,0BAA0B,OAAA;AAC1B,2HAAA,0BAA0B,OAAA;AAC1B,8HAAA,6BAA6B,OAAA;AAC7B,8HAAA,6BAA6B,OAAA;AAC7B,gCAAgC;AAChC,+HAAA,8BAA8B,OAAA;AAC9B,4HAAA,2BAA2B,OAAA;AAC3B,8HAAA,6BAA6B,OAAA;AAC7B,2HAAA,0BAA0B,OAAA;AAC1B,kIAAA,iCAAiC,OAAA;AACjC,+HAAA,8BAA8B,OAAA;AAGlC,uDAIkC;AAH9B,mHAAA,sBAAsB,OAAA;AACtB,mHAAA,sBAAsB,OAAA;AACtB,sHAAA,yBAAyB,OAAA","sourcesContent":["export { prisma } from \"./prisma/prisma\"\n\nexport { ModelFactory } from \"./model_factory/ModelFactory\"\nexport type { DefaultOmitFields } from \"./model_factory/default\"\n\nexport { ServiceFactory, serviceFactoryNames, serviceFactoryAllowUserTypes } from \"./service_factory/ServiceFactory\"\nexport type { ServiceFactoryName, ServiceFactoryAllowUserType } from \"./service_factory/ServiceFactory\"\n\nexport { CustomizeTransform } from \"./customize/CustomizeTransform\"\nexport type { CustomizeTransformProps } from \"./customize/CustomizeTransform\"\n\nexport { toFieldMap, buildSqlRawSelect, buildSqlRawSelectCount, buildSqlRelation, buildSqlSelect, buildSqlWhere, buildSqlLimitOffset, buildSqlOrderBy, getFieldsByType, buildInjectionFieldsSqlSelect, getListWithCount } from \"./query_builder/queryBuilder\"\n\nexport {\n getDocumentSqlRelationMaps,\n buildDocumentMainSqlSelect,\n buildDocumentDefaultSqlSelect,\n buildDocumentProfileSqlSelect,\n // buildDocumentAmountSqlSelect,\n buildDocumentLocationSqlSelect,\n buildDocumentTotalSqlSelect,\n buildDocumentItemSqlSelectAgg,\n buildDocumentItemSqlSelect,\n buildDocumentDocumentSqlSelectAgg,\n buildDocumentDocumentSqlSelect\n} from \"./query_builder/queryDocument\"\n\nexport {\n getFileSqlRelationMaps,\n buildFileMainSqlSelect,\n buildFileDefaultSqlSelect,\n} from \"./query_builder/queryFile\""]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;AAAA,0CAAwC;AAA/B,gGAAA,MAAM,OAAA;AAEf,6DAA2D;AAAlD,4GAAA,YAAY,OAAA;AAGrB,mEAAoH;AAA3G,gHAAA,cAAc,OAAA;AAAE,qHAAA,mBAAmB,OAAA;AAAE,8HAAA,4BAA4B,OAAA;AAG1E,qEAAmE;AAA1D,wHAAA,kBAAkB,OAAA;AAG3B,6DAA6P;AAApP,0GAAA,UAAU,OAAA;AAAE,iHAAA,iBAAiB,OAAA;AAAE,sHAAA,sBAAsB,OAAA;AAAE,gHAAA,gBAAgB,OAAA;AAAE,8GAAA,cAAc,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,mHAAA,mBAAmB,OAAA;AAAE,+GAAA,eAAe,OAAA;AAAE,+GAAA,eAAe,OAAA;AAAE,6HAAA,6BAA6B,OAAA;AAAE,gHAAA,gBAAgB,OAAA;AAEvN,+DAYsC;AAXlC,2HAAA,0BAA0B,OAAA;AAC1B,2HAAA,0BAA0B,OAAA;AAC1B,8HAAA,6BAA6B,OAAA;AAC7B,8HAAA,6BAA6B,OAAA;AAC7B,gCAAgC;AAChC,+HAAA,8BAA8B,OAAA;AAC9B,4HAAA,2BAA2B,OAAA;AAC3B,8HAAA,6BAA6B,OAAA;AAC7B,2HAAA,0BAA0B,OAAA;AAC1B,kIAAA,iCAAiC,OAAA;AACjC,+HAAA,8BAA8B,OAAA;AAGlC,uDAIkC;AAH9B,mHAAA,sBAAsB,OAAA;AACtB,mHAAA,sBAAsB,OAAA;AACtB,sHAAA,yBAAyB,OAAA;AAG7B,iEAIuC;AAHnC,gIAAA,8BAA8B,OAAA;AAC9B,gIAAA,8BAA8B,OAAA;AAC9B,mIAAA,iCAAiC,OAAA","sourcesContent":["export { prisma } from \"./prisma/prisma\"\n\nexport { ModelFactory } from \"./model_factory/ModelFactory\"\nexport type { DefaultOmitFields } from \"./model_factory/default\"\n\nexport { ServiceFactory, serviceFactoryNames, serviceFactoryAllowUserTypes } from \"./service_factory/ServiceFactory\"\nexport type { ServiceFactoryName, ServiceFactoryAllowUserType } from \"./service_factory/ServiceFactory\"\n\nexport { CustomizeTransform } from \"./customize/CustomizeTransform\"\nexport type { CustomizeTransformProps } from \"./customize/CustomizeTransform\"\n\nexport { toFieldMap, buildSqlRawSelect, buildSqlRawSelectCount, buildSqlRelation, buildSqlSelect, buildSqlWhere, buildSqlLimitOffset, buildSqlOrderBy, getFieldsByType, buildInjectionFieldsSqlSelect, getListWithCount } from \"./query_builder/queryBuilder\"\n\nexport {\n getDocumentSqlRelationMaps,\n buildDocumentMainSqlSelect,\n buildDocumentDefaultSqlSelect,\n buildDocumentProfileSqlSelect,\n // buildDocumentAmountSqlSelect,\n buildDocumentLocationSqlSelect,\n buildDocumentTotalSqlSelect,\n buildDocumentItemSqlSelectAgg,\n buildDocumentItemSqlSelect,\n buildDocumentDocumentSqlSelectAgg,\n buildDocumentDocumentSqlSelect\n} from \"./query_builder/queryDocument\"\n\nexport {\n getFileSqlRelationMaps,\n buildFileMainSqlSelect,\n buildFileDefaultSqlSelect,\n} from \"./query_builder/queryFile\"\n\nexport {\n getSchedulerLogSqlRelationMaps,\n buildSchedulerLogMainSqlSelect,\n buildSchedulerLogDefaultSqlSelect,\n} from \"./query_builder/queryScheduler\""]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const getSchedulerLogSqlRelationMaps: () => {
|
|
2
|
+
sqlRelationMaps: Record<"creator" | "updater", string>;
|
|
3
|
+
relationKeys: {
|
|
4
|
+
creator: string;
|
|
5
|
+
updater: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare const buildSchedulerLogMainSqlSelect: () => {
|
|
9
|
+
[x: string]: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const buildSchedulerLogDefaultSqlSelect: () => {
|
|
12
|
+
[x: string]: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildSchedulerLogDefaultSqlSelect = exports.buildSchedulerLogMainSqlSelect = exports.getSchedulerLogSqlRelationMaps = void 0;
|
|
4
|
+
const models_1 = require("../../models");
|
|
5
|
+
const queryBuilder_1 = require("./queryBuilder");
|
|
6
|
+
const getSchedulerLogSqlRelationMaps = () => {
|
|
7
|
+
let relationKeys = {
|
|
8
|
+
creator: "creator",
|
|
9
|
+
updater: "updater"
|
|
10
|
+
};
|
|
11
|
+
let sqlRelationMaps = {
|
|
12
|
+
creator: (0, queryBuilder_1.buildSqlRelation)("left", "slog", "users", "creator", ["slog.createuserid = creator.user_id", "creator.isdelete = false", "creator.istrash = false"]),
|
|
13
|
+
updater: (0, queryBuilder_1.buildSqlRelation)("left", "slog", "users", "updater", ["slog.updateuserid = updater.user_id", "updater.isdelete = false", "updater.istrash = false"])
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
sqlRelationMaps,
|
|
17
|
+
relationKeys
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.getSchedulerLogSqlRelationMaps = getSchedulerLogSqlRelationMaps;
|
|
21
|
+
const buildSchedulerLogMainSqlSelect = () => {
|
|
22
|
+
return {
|
|
23
|
+
[`slog.${models_1.ModelSchedulerLogFields.scheduler_log_id}`]: "scheduler_log_id",
|
|
24
|
+
[`slog.${models_1.ModelSchedulerLogFields.scheduler_task_id}`]: "scheduler_task_id",
|
|
25
|
+
[`slog.${models_1.ModelSchedulerLogFields.field_module}`]: "field_module",
|
|
26
|
+
[`slog.${models_1.ModelSchedulerLogFields.field_ref}`]: "field_ref",
|
|
27
|
+
[`slog.${models_1.ModelSchedulerLogFields.flow_type}`]: "flow_type",
|
|
28
|
+
[`slog.${models_1.ModelSchedulerLogFields.destination_type}`]: "destination_type",
|
|
29
|
+
[`slog.${models_1.ModelSchedulerLogFields.destination_entity_id}`]: "destination_entity_id",
|
|
30
|
+
[`slog.${models_1.ModelSchedulerLogFields.destination_entity_label}`]: "destination_entity_label",
|
|
31
|
+
[`slog.${models_1.ModelSchedulerLogFields.destination_submit_payload}`]: "destination_submit_payload",
|
|
32
|
+
[`slog.${models_1.ModelSchedulerLogFields.destination_submit_response}`]: "destination_submit_response",
|
|
33
|
+
[`slog.${models_1.ModelSchedulerLogFields.source_type}`]: "source_type",
|
|
34
|
+
[`slog.${models_1.ModelSchedulerLogFields.source_entity_id}`]: "source_entity_id",
|
|
35
|
+
[`slog.${models_1.ModelSchedulerLogFields.source_entity_label}`]: "source_entity_label",
|
|
36
|
+
[`slog.${models_1.ModelSchedulerLogFields.source_entity_data}`]: "source_entity_data",
|
|
37
|
+
[`slog.${models_1.ModelSchedulerLogFields.log_action}`]: "log_action",
|
|
38
|
+
[`slog.${models_1.ModelSchedulerLogFields.log_label}`]: "log_label",
|
|
39
|
+
[`slog.${models_1.ModelSchedulerLogFields.log_message}`]: "log_message",
|
|
40
|
+
[`slog.${models_1.ModelSchedulerLogFields.log_status}`]: "log_status",
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
exports.buildSchedulerLogMainSqlSelect = buildSchedulerLogMainSqlSelect;
|
|
44
|
+
const buildSchedulerLogDefaultSqlSelect = () => {
|
|
45
|
+
return {
|
|
46
|
+
[`slog.${models_1.ModelSchedulerLogFields.createdatetime}`]: "createdatetime",
|
|
47
|
+
[`creator.${models_1.ModelUserFields.login_username}`]: "createusername",
|
|
48
|
+
[`slog.${models_1.ModelSchedulerLogFields.updatedatetime}`]: "updatedatetime",
|
|
49
|
+
[`updater.${models_1.ModelUserFields.login_username}`]: "updateusername",
|
|
50
|
+
[`slog.${models_1.ModelSchedulerLogFields.isdelete}`]: "isdelete",
|
|
51
|
+
[`slog.${models_1.ModelSchedulerLogFields.istrash}`]: "istrash",
|
|
52
|
+
[`slog.${models_1.ModelSchedulerLogFields.accountid}`]: "accountid",
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
exports.buildSchedulerLogDefaultSqlSelect = buildSchedulerLogDefaultSqlSelect;
|
|
56
|
+
//# sourceMappingURL=queryScheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryScheduler.js","sourceRoot":"","sources":["../../../src/lib/query_builder/queryScheduler.ts"],"names":[],"mappings":";;;AAAA,qCAGiB;AAEjB,iDAAkD;AAE3C,MAAM,8BAA8B,GAAG,GAAG,EAAE;IAE/C,IAAI,YAAY,GAAG;QACf,OAAO,EAAE,SAAS;QAClB,OAAO,EAAE,SAAS;KACrB,CAAC;IAEF,IAAI,eAAe,GAA2E;QAC1F,OAAO,EAAE,IAAA,+BAAgB,EAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,qCAAqC,EAAE,0BAA0B,EAAE,yBAAyB,CAAC,CAAC;QAC7J,OAAO,EAAE,IAAA,+BAAgB,EAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,qCAAqC,EAAE,0BAA0B,EAAE,yBAAyB,CAAC,CAAC;KAChK,CAAC;IAEF,OAAO;QACH,eAAe;QACf,YAAY;KACf,CAAA;AAEL,CAAC,CAAA;AAjBY,QAAA,8BAA8B,kCAiB1C;AAEM,MAAM,8BAA8B,GAAG,GAAG,EAAE;IAC/C,OAAO;QACH,CAAC,QAAQ,gCAAuB,CAAC,gBAAgB,EAAE,CAAC,EAAE,kBAAkB;QACxE,CAAC,QAAQ,gCAAuB,CAAC,iBAAiB,EAAE,CAA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cAAc,EAAE,CAAC,EAAE,gBAAgB;QACpE,CAAC,WAAW,wBAAe,CAAC,cAAc,EAAE,CAAC,EAAE,gBAAgB;QAC/D,CAAC,QAAQ,gCAAuB,CAAC,cAAc,EAAE,CAAC,EAAE,gBAAgB;QACpE,CAAC,WAAW,wBAAe,CAAC,cAAc,EAAE,CAAC,EAAE,gBAAgB;QAC/D,CAAC,QAAQ,gCAAuB,CAAC,QAAQ,EAAE,CAAC,EAAE,UAAU;QACxD,CAAC,QAAQ,gCAAuB,CAAC,OAAO,EAAE,CAAC,EAAE,SAAS;QACtD,CAAC,QAAQ,gCAAuB,CAAC,SAAS,EAAE,CAAC,EAAE,WAAW;KAC7D,CAAA;AACL,CAAC,CAAA;AAVY,QAAA,iCAAiC,qCAU7C","sourcesContent":["import {\n ModelUserFields,\n ModelSchedulerLogFields\n} from \"@/models\"\n\nimport { buildSqlRelation } from \"./queryBuilder\";\n\nexport const getSchedulerLogSqlRelationMaps = () => {\n\n let relationKeys = {\n creator: \"creator\",\n updater: \"updater\"\n };\n\n let sqlRelationMaps: Record<keyof typeof relationKeys, ReturnType<typeof buildSqlRelation>> = {\n creator: buildSqlRelation(\"left\", \"slog\", \"users\", \"creator\", [\"slog.createuserid = creator.user_id\", \"creator.isdelete = false\", \"creator.istrash = false\"]),\n updater: buildSqlRelation(\"left\", \"slog\", \"users\", \"updater\", [\"slog.updateuserid = updater.user_id\", \"updater.isdelete = false\", \"updater.istrash = false\"])\n };\n\n return {\n sqlRelationMaps,\n relationKeys\n }\n\n}\n\nexport const buildSchedulerLogMainSqlSelect = () => {\n return {\n [`slog.${ModelSchedulerLogFields.scheduler_log_id}`]: \"scheduler_log_id\",\n [`slog.${ModelSchedulerLogFields.scheduler_task_id}`]: \"scheduler_task_id\",\n [`slog.${ModelSchedulerLogFields.field_module}`]: \"field_module\",\n [`slog.${ModelSchedulerLogFields.field_ref}`]: \"field_ref\",\n [`slog.${ModelSchedulerLogFields.flow_type}`]: \"flow_type\",\n [`slog.${ModelSchedulerLogFields.destination_type}`]: \"destination_type\",\n [`slog.${ModelSchedulerLogFields.destination_entity_id}`]: \"destination_entity_id\",\n [`slog.${ModelSchedulerLogFields.destination_entity_label}`]: \"destination_entity_label\",\n [`slog.${ModelSchedulerLogFields.destination_submit_payload}`]: \"destination_submit_payload\",\n [`slog.${ModelSchedulerLogFields.destination_submit_response}`]: \"destination_submit_response\",\n [`slog.${ModelSchedulerLogFields.source_type}`]: \"source_type\",\n [`slog.${ModelSchedulerLogFields.source_entity_id}`]: \"source_entity_id\",\n [`slog.${ModelSchedulerLogFields.source_entity_label}`]: \"source_entity_label\",\n [`slog.${ModelSchedulerLogFields.source_entity_data}`]: \"source_entity_data\",\n [`slog.${ModelSchedulerLogFields.log_action}`]: \"log_action\",\n [`slog.${ModelSchedulerLogFields.log_label}`]: \"log_label\",\n [`slog.${ModelSchedulerLogFields.log_message}`]: \"log_message\",\n [`slog.${ModelSchedulerLogFields.log_status}`]: \"log_status\",\n }\n}\n\nexport const buildSchedulerLogDefaultSqlSelect = () => {\n return {\n [`slog.${ModelSchedulerLogFields.createdatetime}`]: \"createdatetime\",\n [`creator.${ModelUserFields.login_username}`]: \"createusername\",\n [`slog.${ModelSchedulerLogFields.updatedatetime}`]: \"updatedatetime\",\n [`updater.${ModelUserFields.login_username}`]: \"updateusername\",\n [`slog.${ModelSchedulerLogFields.isdelete}`]: \"isdelete\",\n [`slog.${ModelSchedulerLogFields.istrash}`]: \"istrash\",\n [`slog.${ModelSchedulerLogFields.accountid}`]: \"accountid\",\n }\n}"]}
|
|
@@ -95,7 +95,7 @@ export declare const SchedulerLogService: (props: SchedulerLogServiceProps) => {
|
|
|
95
95
|
destination_submit_response: string | null;
|
|
96
96
|
}[]>;
|
|
97
97
|
listSchedulerLoges: ({ limit, offset, filters, sortfield, sortorder }: SchedulerLogListProps) => Promise<{
|
|
98
|
-
data: any
|
|
98
|
+
data: any;
|
|
99
99
|
total: number;
|
|
100
100
|
}>;
|
|
101
101
|
};
|
|
@@ -4,10 +4,12 @@ exports.SchedulerLogService = exports.schedulerLogTypes = void 0;
|
|
|
4
4
|
const utils_1 = require("../../utils");
|
|
5
5
|
const models_1 = require("../../models");
|
|
6
6
|
const lib_1 = require("../../lib");
|
|
7
|
+
const lib_2 = require("../../lib");
|
|
7
8
|
exports.schedulerLogTypes = {
|
|
8
9
|
in: "in",
|
|
9
10
|
out: "out"
|
|
10
11
|
};
|
|
12
|
+
const { relationKeys, sqlRelationMaps } = (0, lib_1.getSchedulerLogSqlRelationMaps)();
|
|
11
13
|
const getCreatePayload = (data) => {
|
|
12
14
|
return {
|
|
13
15
|
[`${models_1.ModelSchedulerLogFields.scheduler_task_id}`]: Number(data.schedulerTaskId),
|
|
@@ -29,35 +31,8 @@ const getCreatePayload = (data) => {
|
|
|
29
31
|
[`${models_1.ModelSchedulerLogFields.log_status}`]: Boolean(data.logStatus),
|
|
30
32
|
};
|
|
31
33
|
};
|
|
32
|
-
let mainSqlSelect =
|
|
33
|
-
|
|
34
|
-
[`slog.${models_1.ModelSchedulerLogFields.scheduler_task_id}`]: "scheduler_task_id",
|
|
35
|
-
[`slog.${models_1.ModelSchedulerLogFields.field_module}`]: "field_module",
|
|
36
|
-
[`slog.${models_1.ModelSchedulerLogFields.field_ref}`]: "field_ref",
|
|
37
|
-
[`slog.${models_1.ModelSchedulerLogFields.flow_type}`]: "flow_type",
|
|
38
|
-
[`slog.${models_1.ModelSchedulerLogFields.destination_type}`]: "destination_type",
|
|
39
|
-
[`slog.${models_1.ModelSchedulerLogFields.destination_entity_id}`]: "destination_entity_id",
|
|
40
|
-
[`slog.${models_1.ModelSchedulerLogFields.destination_entity_label}`]: "destination_entity_label",
|
|
41
|
-
[`slog.${models_1.ModelSchedulerLogFields.destination_submit_payload}`]: "destination_submit_payload",
|
|
42
|
-
[`slog.${models_1.ModelSchedulerLogFields.destination_submit_response}`]: "destination_submit_response",
|
|
43
|
-
[`slog.${models_1.ModelSchedulerLogFields.source_type}`]: "source_type",
|
|
44
|
-
[`slog.${models_1.ModelSchedulerLogFields.source_entity_id}`]: "source_entity_id",
|
|
45
|
-
[`slog.${models_1.ModelSchedulerLogFields.source_entity_label}`]: "source_entity_label",
|
|
46
|
-
[`slog.${models_1.ModelSchedulerLogFields.source_entity_data}`]: "source_entity_data",
|
|
47
|
-
[`slog.${models_1.ModelSchedulerLogFields.log_action}`]: "log_action",
|
|
48
|
-
[`slog.${models_1.ModelSchedulerLogFields.log_label}`]: "log_label",
|
|
49
|
-
[`slog.${models_1.ModelSchedulerLogFields.log_message}`]: "log_message",
|
|
50
|
-
[`slog.${models_1.ModelSchedulerLogFields.log_status}`]: "log_status",
|
|
51
|
-
};
|
|
52
|
-
let defaultSqlSelect = {
|
|
53
|
-
[`slog.${models_1.ModelSchedulerLogFields.createdatetime}`]: "createdatetime",
|
|
54
|
-
[`creator.${models_1.ModelUserFields.login_username}`]: "createusername",
|
|
55
|
-
[`slog.${models_1.ModelSchedulerLogFields.updatedatetime}`]: "updatedatetime",
|
|
56
|
-
[`updater.${models_1.ModelUserFields.login_username}`]: "updateusername",
|
|
57
|
-
[`slog.${models_1.ModelSchedulerLogFields.isdelete}`]: "isdelete",
|
|
58
|
-
[`slog.${models_1.ModelSchedulerLogFields.istrash}`]: "istrash",
|
|
59
|
-
[`slog.${models_1.ModelSchedulerLogFields.accountid}`]: "accountid",
|
|
60
|
-
};
|
|
34
|
+
let mainSqlSelect = (0, lib_2.buildSchedulerLogMainSqlSelect)();
|
|
35
|
+
let defaultSqlSelect = (0, lib_2.buildSchedulerLogDefaultSqlSelect)();
|
|
61
36
|
const SchedulerLogService = (props) => {
|
|
62
37
|
const { ...rest } = props;
|
|
63
38
|
const schedulerLogModel = (0, models_1.SchedulerLogModel)({ ...rest });
|
|
@@ -80,9 +55,9 @@ const SchedulerLogService = (props) => {
|
|
|
80
55
|
return data[0] ?? null;
|
|
81
56
|
};
|
|
82
57
|
const listSchedulerLoges = async ({ limit, offset, filters = [], sortfield, sortorder }) => {
|
|
83
|
-
let data = []
|
|
58
|
+
// let data = []
|
|
84
59
|
let sqlSelect = [
|
|
85
|
-
`COUNT(slog.*) OVER() as filtered_count`,
|
|
60
|
+
// `COUNT(slog.*) OVER() as filtered_count`,
|
|
86
61
|
(0, lib_1.buildSqlSelect)(``, mainSqlSelect),
|
|
87
62
|
// buildSqlSelect(``, regionSqlSelect),
|
|
88
63
|
(0, lib_1.buildSqlSelect)(``, defaultSqlSelect)
|
|
@@ -111,21 +86,44 @@ const SchedulerLogService = (props) => {
|
|
|
111
86
|
];
|
|
112
87
|
let sqlOrderby = (0, lib_1.buildSqlOrderBy)(sortfield, sortorder);
|
|
113
88
|
let sqlLimitOffset = (0, lib_1.buildSqlLimitOffset)(limit, offset);
|
|
114
|
-
const sqlRaw =
|
|
89
|
+
// const sqlRaw = buildSqlRawSelect({
|
|
90
|
+
// tableName: "scheduler_logs",
|
|
91
|
+
// mainAlias: "slog",
|
|
92
|
+
// accountId: rest.accountId,
|
|
93
|
+
// sqlSelect,
|
|
94
|
+
// sqlRelation,
|
|
95
|
+
// sqlWhere,
|
|
96
|
+
// sqlGroupBy,
|
|
97
|
+
// sqlOrderby,
|
|
98
|
+
// sqlLimitOffset
|
|
99
|
+
// })
|
|
100
|
+
// data = await schedulerLogModel.raw(sqlRaw)
|
|
101
|
+
// const response = {
|
|
102
|
+
// data: data.map(({ filtered_count, ...rest }) => rest),
|
|
103
|
+
// total: data.length ? Number(data[0].filtered_count) : 0
|
|
104
|
+
// }
|
|
105
|
+
// get the listing data & count
|
|
106
|
+
const { data, total } = await (0, lib_1.getListWithCount)({
|
|
107
|
+
model: schedulerLogModel,
|
|
115
108
|
tableName: "scheduler_logs",
|
|
116
109
|
mainAlias: "slog",
|
|
110
|
+
countKey: `${models_1.ModelSchedulerLogFields.scheduler_log_id}`,
|
|
117
111
|
accountId: rest.accountId,
|
|
112
|
+
sqlRelationMaps,
|
|
113
|
+
filters,
|
|
114
|
+
filterColumns,
|
|
118
115
|
sqlSelect,
|
|
116
|
+
sqlSelectAgg: [],
|
|
119
117
|
sqlRelation,
|
|
118
|
+
sqlRelationAgg: [],
|
|
120
119
|
sqlWhere,
|
|
121
120
|
sqlGroupBy,
|
|
122
121
|
sqlOrderby,
|
|
123
122
|
sqlLimitOffset
|
|
124
123
|
});
|
|
125
|
-
data = await schedulerLogModel.raw(sqlRaw);
|
|
126
124
|
const response = {
|
|
127
|
-
data
|
|
128
|
-
total
|
|
125
|
+
data,
|
|
126
|
+
total
|
|
129
127
|
};
|
|
130
128
|
return response;
|
|
131
129
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchedulerLogService.js","sourceRoot":"","sources":["../../../src/services/scheduler/SchedulerLogService.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAE/C,qCAIkB;AAQlB,+BAAiI;AAiBpH,QAAA,iBAAiB,GAAG;IAC7B,EAAE,EAAE,IAAI;IACR,GAAG,EAAE,KAAK;CACb,CAAA;AAgCD,MAAM,gBAAgB,GAAG,CAAC,IAAqC,EAAE,EAAE;IAE/D,OAAO;QACH,CAAC,GAAG,gCAAuB,CAAC,iBAAiB,EAAE,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC;QAC9E,CAAC,GAAG,gCAAuB,CAAC,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ;QACvD,CAAC,GAAG,gCAAuB,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS;QAEzD,CAAC,GAAG,gCAAuB,CAAC,YAAY,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ;QAC1D,CAAC,GAAG,gCAAuB,CAAC,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,WAAW;QAE1D,CAAC,GAAG,gCAAuB,CAAC,WAAW,EAAE,CAAC,EAAE,IAAI,CAAC,UAAU;QAC3D,CAAC,GAAG,gCAAuB,CAAC,gBAAgB,EAAE,CAAC,EAAE,IAAI,CAAC,cAAc;QACpE,CAA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AM,GAAG,IAAA,uBAAiB,EAAC;YAC7B,SAAS,EAAE,gBAAgB;YAC3B,SAAS,EAAE,MAAM;YACjB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS;YACT,WAAW;YACX,QAAQ;YACR,UAAU;YACV,UAAU;YACV,cAAc;SACjB,CAAC,CAAA;QAEF,IAAI,GAAG,MAAM,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QAE1C,MAAM,QAAQ,GAAG;YACb,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;YACrD,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;SAC1D,CAAA;QAED,OAAO,QAAQ,CAAA;IAEnB,CAAC,CAAC;IAEF,MAAM,oBAAoB,GAAG,KAAK,EAAE,EAAE,eAAe,EAA2B,EAAE,EAAE;QAEhF,IAAI,CAAC,eAAe,CAAC,MAAM;YAAE,IAAA,kBAAU,EAAC,6BAA6B,CAAC,CAAC;QAEvE,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,gCAAuB,CAAC,gBAAgB,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CAAC;QAEzI,OAAO,QAAQ,CAAA;IACnB,CAAC,CAAC;IAEF,OAAO;QACH,eAAe;QACf,kBAAkB;QAClB,oBAAoB;QACpB,kBAAkB;KACrB,CAAA;AAEL,CAAC,CAAA;AAlHY,QAAA,mBAAmB,uBAkH/B","sourcesContent":["import { logError, throwError } from \"@/utils\";\n\nimport {\n ModelUserFields,\n SchedulerLogModel,\n ModelSchedulerLogFields\n} from \"@/models\";\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\n\nimport { DefaultServiceProps } from \"@/utils\";\n\nimport { InjectionFieldModuleRef } from \"@/services\"\n\nimport { buildSqlRelation, buildSqlRawSelect, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy } from \"@/lib\";\n\nexport type SchedulerLogModuleRef = InjectionFieldModuleRef\n\nexport type SchedulerLogServiceProps = DefaultServiceProps & {};\n\nexport type SchedulerLogGetProps = Omit<QueryGet, \"datatypes\"> & {\n id: number,\n};\n\nexport type SchedulerLogListProps = Omit<QueryList, \"datatypes\"> & {\n};\n\nexport type SchedulerLogRemoveProps = {\n schedulerLogIds: BigInt[]\n};\n\nexport const schedulerLogTypes = {\n in: \"in\",\n out: \"out\"\n}\n\nexport type SchedulerLogFlowType = keyof typeof schedulerLogTypes\n\nexport type SchedulerLog = {\n schedulerTaskId: number;\n flowType: SchedulerLogFlowType;\n\n sourceType: string;\n sourceEntityId: string;\n sourceEntityLabel: string;\n sourceEntityData: string;\n\n destinationType: string;\n destinationEntityId: string;\n destinationEntityLabel: string;\n destinationSubmitPayload: string;\n destinationSubmitResponse: string;\n\n logAction: string;\n logLabel: string;\n logStatus: boolean;\n logMesssage: string;\n}\n\nexport type SchedulerLogCreateProps = {\n data: SchedulerLog & {\n fieldRef: SchedulerLogModuleRef[\"field_ref\"],\n fieldModule: SchedulerLogModuleRef[\"field_module\"]\n }\n}\n\nconst getCreatePayload = (data: SchedulerLogCreateProps[\"data\"]) => {\n\n return {\n [`${ModelSchedulerLogFields.scheduler_task_id}`]: Number(data.schedulerTaskId),\n [`${ModelSchedulerLogFields.flow_type}`]: data.flowType,\n [`${ModelSchedulerLogFields.log_action}`]: data.logAction,\n\n [`${ModelSchedulerLogFields.field_module}`]: data.fieldRef,\n [`${ModelSchedulerLogFields.field_ref}`]: data.fieldModule,\n\n [`${ModelSchedulerLogFields.source_type}`]: data.sourceType,\n [`${ModelSchedulerLogFields.source_entity_id}`]: data.sourceEntityId,\n [`${ModelSchedulerLogFields.source_entity_label}`]: data.sourceEntityLabel,\n [`${ModelSchedulerLogFields.source_entity_data}`]: data.sourceEntityData,\n\n [`${ModelSchedulerLogFields.destination_type}`]: data.destinationType,\n [`${ModelSchedulerLogFields.destination_entity_id}`]: data.destinationEntityId,\n [`${ModelSchedulerLogFields.destination_entity_label}`]: data.destinationEntityLabel,\n [`${ModelSchedulerLogFields.destination_submit_payload}`]: data.destinationSubmitPayload,\n [`${ModelSchedulerLogFields.destination_submit_response}`]: data.destinationSubmitResponse,\n\n [`${ModelSchedulerLogFields.log_label}`]: data.logLabel,\n [`${ModelSchedulerLogFields.log_message}`]: data.logMesssage,\n [`${ModelSchedulerLogFields.log_status}`]: Boolean(data.logStatus),\n }\n\n}\n\nlet mainSqlSelect = {\n [`slog.${ModelSchedulerLogFields.scheduler_log_id}`]: \"scheduler_log_id\",\n [`slog.${ModelSchedulerLogFields.scheduler_task_id}`]: \"scheduler_task_id\",\n [`slog.${ModelSchedulerLogFields.field_module}`]: \"field_module\",\n [`slog.${ModelSchedulerLogFields.field_ref}`]: \"field_ref\",\n [`slog.${ModelSchedulerLogFields.flow_type}`]: \"flow_type\",\n [`slog.${ModelSchedulerLogFields.destination_type}`]: \"destination_type\",\n [`slog.${ModelSchedulerLogFields.destination_entity_id}`]: \"destination_entity_id\",\n [`slog.${ModelSchedulerLogFields.destination_entity_label}`]: \"destination_entity_label\",\n [`slog.${ModelSchedulerLogFields.destination_submit_payload}`]: \"destination_submit_payload\",\n [`slog.${ModelSchedulerLogFields.destination_submit_response}`]: \"destination_submit_response\",\n [`slog.${ModelSchedulerLogFields.source_type}`]: \"source_type\",\n [`slog.${ModelSchedulerLogFields.source_entity_id}`]: \"source_entity_id\",\n [`slog.${ModelSchedulerLogFields.source_entity_label}`]: \"source_entity_label\",\n [`slog.${ModelSchedulerLogFields.source_entity_data}`]: \"source_entity_data\",\n [`slog.${ModelSchedulerLogFields.log_action}`]: \"log_action\",\n [`slog.${ModelSchedulerLogFields.log_label}`]: \"log_label\",\n [`slog.${ModelSchedulerLogFields.log_message}`]: \"log_message\",\n [`slog.${ModelSchedulerLogFields.log_status}`]: \"log_status\",\n}\n\nlet defaultSqlSelect = {\n [`slog.${ModelSchedulerLogFields.createdatetime}`]: \"createdatetime\",\n [`creator.${ModelUserFields.login_username}`]: \"createusername\",\n [`slog.${ModelSchedulerLogFields.updatedatetime}`]: \"updatedatetime\",\n [`updater.${ModelUserFields.login_username}`]: \"updateusername\",\n [`slog.${ModelSchedulerLogFields.isdelete}`]: \"isdelete\",\n [`slog.${ModelSchedulerLogFields.istrash}`]: \"istrash\",\n [`slog.${ModelSchedulerLogFields.accountid}`]: \"accountid\",\n}\n\nexport const SchedulerLogService = (props: SchedulerLogServiceProps) => {\n\n const {\n ...rest\n } = props\n\n const schedulerLogModel = SchedulerLogModel({ ...rest })\n\n const createSchedulerLog = async ({ data }: SchedulerLogCreateProps) => {\n\n const _data = getCreatePayload(data)\n\n if (!_data) {\n throw new Error(`Invalid create scheduler log payload: ${JSON.stringify(_data)}`);\n }\n\n let response = await schedulerLogModel.create({ data: _data })\n\n return response\n }\n\n const getSchedulerLog = async ({ id }: SchedulerLogGetProps) => {\n\n let { data } = await listSchedulerLoges({\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 listSchedulerLoges = async ({ limit, offset, filters = [], sortfield, sortorder }: SchedulerLogListProps) => {\n\n let data = []\n\n let sqlSelect = [\n `COUNT(slog.*) OVER() as filtered_count`,\n buildSqlSelect(``, mainSqlSelect),\n // buildSqlSelect(``, regionSqlSelect),\n buildSqlSelect(``, defaultSqlSelect)\n ]\n\n let sqlRelation = [\n // buildSqlRelation(\"left\", \"slog\", \"states\", \"slogstate\", [\"slog.state_id = slogstate.state_id\", \"slogstate.isdelete = false\", \"slogstate.istrash = false\"]),\n // buildSqlRelation(\"left\", \"slog\", \"countries\", \"slogcoun\", [\"slog.country_id = slogcoun.country_id\", \"slogcoun.isdelete = false\", \"slogcoun.istrash = false\"]),\n // buildSqlRelation(\"left\", \"slog\", \"areas\", \"slogarea\", [\"slog.area_id = slogarea.area_id\", \"slogarea.isdelete = false\", \"slogarea.istrash = false\"]),\n buildSqlRelation(\"left\", \"slog\", \"users\", \"creator\", [\"slog.createuserid = creator.user_id\", \"creator.isdelete = false\", \"creator.istrash = false\"]),\n buildSqlRelation(\"left\", \"slog\", \"users\", \"updater\", [\"slog.updateuserid = updater.user_id\", \"updater.isdelete = false\", \"updater.istrash = false\"])\n ]\n\n let sqlGroupBy: string[] = [\n ...Object.keys(mainSqlSelect),\n // ...Object.keys(regionSqlSelect), \n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n // ...regionSqlSelect, \n ...defaultSqlSelect\n }\n\n let sqlWhere = [\n `slog.isdelete = false`,\n `slog.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 const sqlRaw = buildSqlRawSelect({\n tableName: \"scheduler_logs\",\n mainAlias: \"slog\",\n accountId: rest.accountId,\n sqlSelect,\n sqlRelation,\n sqlWhere,\n sqlGroupBy,\n sqlOrderby,\n sqlLimitOffset\n })\n\n data = await schedulerLogModel.raw(sqlRaw)\n\n const response = {\n data: data.map(({ filtered_count, ...rest }) => rest),\n total: data.length ? Number(data[0].filtered_count) : 0\n }\n\n return response\n\n };\n\n const removeSchedulerLoges = async ({ schedulerLogIds }: SchedulerLogRemoveProps) => {\n\n if (!schedulerLogIds.length) throwError('schedulerLogIds is required');\n\n const response = await schedulerLogModel.remove({ where: { [`${ModelSchedulerLogFields.scheduler_log_id}`]: { in: schedulerLogIds } } });\n\n return response\n };\n\n return {\n getSchedulerLog,\n createSchedulerLog,\n removeSchedulerLoges,\n listSchedulerLoges\n }\n\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"SchedulerLogService.js","sourceRoot":"","sources":["../../../src/services/scheduler/SchedulerLogService.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAE/C,qCAIkB;AAQlB,+BAAgK;AAEhK,+BAGe;AAiBF,QAAA,iBAAiB,GAAG;IAC7B,EAAE,EAAE,IAAI;IACR,GAAG,EAAE,KAAK;CACb,CAAA;AAgCD,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,GAAG,IAAA,oCAA8B,GAAE,CAAA;AAE1E,MAAM,gBAAgB,GAAG,CAAC,IAAqC,EAAE,EAAE;IAE/D,OAAO;QACH,CAAC,GAAG,gCAAuB,CAAC,iBAAiB,EAAE,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC;QAC9E,CAAC,GAAG,gCAAuB,CAAC,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ;QACvD,CAAC,GAAG,gCAAuB,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS;QAEzD,CAAC,GAAG,gCAAuB,CAAC,YAAY,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ;QAC1D,CAAC,GAAG,gCAAuB,CAAC,SAAS,EAAE,CAAC,EAAE,IAAI,CAAC,WAAW;QAE1D,CAAC,GAAG,gCAAuB,CAAC,WAAW,EAAE,CAAC,EAAE,IAAI,CAAC,UAAU;QAC3D,CAAC,GAAG,gCAAuB,CAAC,gBAAgB,EAAE,CAAC,EAAE,IAAI,CAAC,cAAc;QACpE,CAAC,GAAG,gCAAuB,CAAC,mBAAmB,EAAE,CAAC,EAAE,IAAI,CAAC,iBAAiB;QAC1E,CAAC,GAAG,gCAAuB,CAAC,kBAAkB,EAAE,CAAC,EAAE,IAAI,CAAC,gBAAgB;QAExE,CAAC,GAAG,gCAAuB,CAAC,gBAAgB,EAAE,CAAC,EAAE,IAAI,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AAA;QAEF,MAAM,QAAQ,GAAG;YACb,IAAI;YACJ,KAAK;SACR,CAAA;QAED,OAAO,QAAQ,CAAA;IAEnB,CAAC,CAAC;IAEF,MAAM,oBAAoB,GAAG,KAAK,EAAE,EAAE,eAAe,EAA2B,EAAE,EAAE;QAEhF,IAAI,CAAC,eAAe,CAAC,MAAM;YAAE,IAAA,kBAAU,EAAC,6BAA6B,CAAC,CAAC;QAEvE,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,gCAAuB,CAAC,gBAAgB,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CAAC;QAEzI,OAAO,QAAQ,CAAA;IACnB,CAAC,CAAC;IAEF,OAAO;QACH,eAAe;QACf,kBAAkB;QAClB,oBAAoB;QACpB,kBAAkB;KACrB,CAAA;AAEL,CAAC,CAAA;AA3IY,QAAA,mBAAmB,uBA2I/B","sourcesContent":["import { logError, throwError } from \"@/utils\";\n\nimport {\n ModelUserFields,\n SchedulerLogModel,\n ModelSchedulerLogFields\n} from \"@/models\";\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\n\nimport { DefaultServiceProps } from \"@/utils\";\n\nimport { InjectionFieldModuleRef } from \"@/services\"\n\nimport { getSchedulerLogSqlRelationMaps, buildSqlRelation, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy, getListWithCount } from \"@/lib\";\n\nimport {\n buildSchedulerLogDefaultSqlSelect,\n buildSchedulerLogMainSqlSelect\n} from \"@/lib\";\n\nexport type SchedulerLogModuleRef = InjectionFieldModuleRef\n\nexport type SchedulerLogServiceProps = DefaultServiceProps & {};\n\nexport type SchedulerLogGetProps = Omit<QueryGet, \"datatypes\"> & {\n id: number,\n};\n\nexport type SchedulerLogListProps = Omit<QueryList, \"datatypes\"> & {\n};\n\nexport type SchedulerLogRemoveProps = {\n schedulerLogIds: BigInt[]\n};\n\nexport const schedulerLogTypes = {\n in: \"in\",\n out: \"out\"\n}\n\nexport type SchedulerLogFlowType = keyof typeof schedulerLogTypes\n\nexport type SchedulerLog = {\n schedulerTaskId: number;\n flowType: SchedulerLogFlowType;\n\n sourceType: string;\n sourceEntityId: string;\n sourceEntityLabel: string;\n sourceEntityData: string;\n\n destinationType: string;\n destinationEntityId: string;\n destinationEntityLabel: string;\n destinationSubmitPayload: string;\n destinationSubmitResponse: string;\n\n logAction: string;\n logLabel: string;\n logStatus: boolean;\n logMesssage: string;\n}\n\nexport type SchedulerLogCreateProps = {\n data: SchedulerLog & {\n fieldRef: SchedulerLogModuleRef[\"field_ref\"],\n fieldModule: SchedulerLogModuleRef[\"field_module\"]\n }\n}\n\nconst { relationKeys, sqlRelationMaps } = getSchedulerLogSqlRelationMaps()\n\nconst getCreatePayload = (data: SchedulerLogCreateProps[\"data\"]) => {\n\n return {\n [`${ModelSchedulerLogFields.scheduler_task_id}`]: Number(data.schedulerTaskId),\n [`${ModelSchedulerLogFields.flow_type}`]: data.flowType,\n [`${ModelSchedulerLogFields.log_action}`]: data.logAction,\n\n [`${ModelSchedulerLogFields.field_module}`]: data.fieldRef,\n [`${ModelSchedulerLogFields.field_ref}`]: data.fieldModule,\n\n [`${ModelSchedulerLogFields.source_type}`]: data.sourceType,\n [`${ModelSchedulerLogFields.source_entity_id}`]: data.sourceEntityId,\n [`${ModelSchedulerLogFields.source_entity_label}`]: data.sourceEntityLabel,\n [`${ModelSchedulerLogFields.source_entity_data}`]: data.sourceEntityData,\n\n [`${ModelSchedulerLogFields.destination_type}`]: data.destinationType,\n [`${ModelSchedulerLogFields.destination_entity_id}`]: data.destinationEntityId,\n [`${ModelSchedulerLogFields.destination_entity_label}`]: data.destinationEntityLabel,\n [`${ModelSchedulerLogFields.destination_submit_payload}`]: data.destinationSubmitPayload,\n [`${ModelSchedulerLogFields.destination_submit_response}`]: data.destinationSubmitResponse,\n\n [`${ModelSchedulerLogFields.log_label}`]: data.logLabel,\n [`${ModelSchedulerLogFields.log_message}`]: data.logMesssage,\n [`${ModelSchedulerLogFields.log_status}`]: Boolean(data.logStatus),\n }\n\n}\n\nlet mainSqlSelect = buildSchedulerLogMainSqlSelect()\nlet defaultSqlSelect = buildSchedulerLogDefaultSqlSelect()\n\nexport const SchedulerLogService = (props: SchedulerLogServiceProps) => {\n\n const {\n ...rest\n } = props\n\n const schedulerLogModel = SchedulerLogModel({ ...rest })\n\n const createSchedulerLog = async ({ data }: SchedulerLogCreateProps) => {\n\n const _data = getCreatePayload(data)\n\n if (!_data) {\n throw new Error(`Invalid create scheduler log payload: ${JSON.stringify(_data)}`);\n }\n\n let response = await schedulerLogModel.create({ data: _data })\n\n return response\n }\n\n const getSchedulerLog = async ({ id }: SchedulerLogGetProps) => {\n\n let { data } = await listSchedulerLoges({\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 listSchedulerLoges = async ({ limit, offset, filters = [], sortfield, sortorder }: SchedulerLogListProps) => {\n\n // let data = []\n\n let sqlSelect = [\n // `COUNT(slog.*) OVER() as filtered_count`,\n buildSqlSelect(``, mainSqlSelect),\n // buildSqlSelect(``, regionSqlSelect),\n buildSqlSelect(``, defaultSqlSelect)\n ]\n\n let sqlRelation = [\n // buildSqlRelation(\"left\", \"slog\", \"states\", \"slogstate\", [\"slog.state_id = slogstate.state_id\", \"slogstate.isdelete = false\", \"slogstate.istrash = false\"]),\n // buildSqlRelation(\"left\", \"slog\", \"countries\", \"slogcoun\", [\"slog.country_id = slogcoun.country_id\", \"slogcoun.isdelete = false\", \"slogcoun.istrash = false\"]),\n // buildSqlRelation(\"left\", \"slog\", \"areas\", \"slogarea\", [\"slog.area_id = slogarea.area_id\", \"slogarea.isdelete = false\", \"slogarea.istrash = false\"]),\n buildSqlRelation(\"left\", \"slog\", \"users\", \"creator\", [\"slog.createuserid = creator.user_id\", \"creator.isdelete = false\", \"creator.istrash = false\"]),\n buildSqlRelation(\"left\", \"slog\", \"users\", \"updater\", [\"slog.updateuserid = updater.user_id\", \"updater.isdelete = false\", \"updater.istrash = false\"])\n ]\n\n let sqlGroupBy: string[] = [\n ...Object.keys(mainSqlSelect),\n // ...Object.keys(regionSqlSelect), \n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n // ...regionSqlSelect, \n ...defaultSqlSelect\n }\n\n let sqlWhere = [\n `slog.isdelete = false`,\n `slog.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 // const sqlRaw = buildSqlRawSelect({\n // tableName: \"scheduler_logs\",\n // mainAlias: \"slog\",\n // accountId: rest.accountId,\n // sqlSelect,\n // sqlRelation,\n // sqlWhere,\n // sqlGroupBy,\n // sqlOrderby,\n // sqlLimitOffset\n // })\n\n // data = await schedulerLogModel.raw(sqlRaw)\n\n // const response = {\n // data: data.map(({ filtered_count, ...rest }) => rest),\n // total: data.length ? Number(data[0].filtered_count) : 0\n // }\n\n // get the listing data & count\n const { data, total } = await getListWithCount({\n model: schedulerLogModel,\n tableName: \"scheduler_logs\",\n mainAlias: \"slog\",\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 const removeSchedulerLoges = async ({ schedulerLogIds }: SchedulerLogRemoveProps) => {\n\n if (!schedulerLogIds.length) throwError('schedulerLogIds is required');\n\n const response = await schedulerLogModel.remove({ where: { [`${ModelSchedulerLogFields.scheduler_log_id}`]: { in: schedulerLogIds } } });\n\n return response\n };\n\n return {\n getSchedulerLog,\n createSchedulerLog,\n removeSchedulerLoges,\n listSchedulerLoges\n }\n\n}\n\n"]}
|