@memberjunction/scheduling-actions 2.107.0
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/BaseJobAction.d.ts +99 -0
- package/dist/BaseJobAction.d.ts.map +1 -0
- package/dist/BaseJobAction.js +217 -0
- package/dist/BaseJobAction.js.map +1 -0
- package/dist/CreateJobAction.d.ts +45 -0
- package/dist/CreateJobAction.d.ts.map +1 -0
- package/dist/CreateJobAction.js +153 -0
- package/dist/CreateJobAction.js.map +1 -0
- package/dist/DeleteJobAction.d.ts +36 -0
- package/dist/DeleteJobAction.d.ts.map +1 -0
- package/dist/DeleteJobAction.js +103 -0
- package/dist/DeleteJobAction.js.map +1 -0
- package/dist/ExecuteJobNowAction.d.ts +36 -0
- package/dist/ExecuteJobNowAction.d.ts.map +1 -0
- package/dist/ExecuteJobNowAction.js +111 -0
- package/dist/ExecuteJobNowAction.js.map +1 -0
- package/dist/GetJobStatisticsAction.d.ts +38 -0
- package/dist/GetJobStatisticsAction.d.ts.map +1 -0
- package/dist/GetJobStatisticsAction.js +162 -0
- package/dist/GetJobStatisticsAction.js.map +1 -0
- package/dist/QueryJobsAction.d.ts +43 -0
- package/dist/QueryJobsAction.d.ts.map +1 -0
- package/dist/QueryJobsAction.js +125 -0
- package/dist/QueryJobsAction.js.map +1 -0
- package/dist/UpdateJobAction.d.ts +45 -0
- package/dist/UpdateJobAction.d.ts.map +1 -0
- package/dist/UpdateJobAction.js +152 -0
- package/dist/UpdateJobAction.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/package.json +29 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.LoadDeleteScheduledJobAction = exports.DeleteScheduledJobAction = void 0;
|
|
10
|
+
const global_1 = require("@memberjunction/global");
|
|
11
|
+
const actions_1 = require("@memberjunction/actions");
|
|
12
|
+
const BaseJobAction_1 = require("./BaseJobAction");
|
|
13
|
+
/**
|
|
14
|
+
* Delete Scheduled Job action.
|
|
15
|
+
* Deletes an existing scheduled job from the system.
|
|
16
|
+
* Will fail if the job has related records that prevent deletion.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* await RunAction({
|
|
21
|
+
* ActionName: 'Delete Scheduled Job',
|
|
22
|
+
* Params: [
|
|
23
|
+
* { Name: 'JobID', Value: 'F3C4A5B6-...' }
|
|
24
|
+
* ]
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
let DeleteScheduledJobAction = class DeleteScheduledJobAction extends BaseJobAction_1.BaseJobAction {
|
|
29
|
+
/**
|
|
30
|
+
* Deletes a scheduled job record
|
|
31
|
+
*
|
|
32
|
+
* @param params - The action parameters containing:
|
|
33
|
+
* - JobID (required): ID of the job to delete
|
|
34
|
+
*
|
|
35
|
+
* @returns ActionResultSimple with:
|
|
36
|
+
* - Success: true if job was deleted successfully
|
|
37
|
+
* - ResultCode: SUCCESS, VALIDATION_ERROR, NOT_FOUND, REFERENCE_CONSTRAINT, or FAILED
|
|
38
|
+
* - Message: Description of the result
|
|
39
|
+
*/
|
|
40
|
+
async InternalRunAction(params) {
|
|
41
|
+
try {
|
|
42
|
+
const jobId = this.getParamValue(params, 'JobID');
|
|
43
|
+
if (!jobId) {
|
|
44
|
+
return {
|
|
45
|
+
Success: false,
|
|
46
|
+
ResultCode: 'VALIDATION_ERROR',
|
|
47
|
+
Message: 'JobID parameter is required'
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
// Load the job
|
|
51
|
+
const loadResult = await this.loadJob(jobId, params.ContextUser);
|
|
52
|
+
if (loadResult.error) {
|
|
53
|
+
return loadResult.error;
|
|
54
|
+
}
|
|
55
|
+
const job = loadResult.job;
|
|
56
|
+
const jobName = job.Name;
|
|
57
|
+
// Delete the job
|
|
58
|
+
const deleteResult = await job.Delete();
|
|
59
|
+
if (!deleteResult) {
|
|
60
|
+
const errorMsg = job.LatestResult?.Message || 'Unknown error';
|
|
61
|
+
// Check for cascade/reference errors
|
|
62
|
+
if (errorMsg.toLowerCase().includes('reference') ||
|
|
63
|
+
errorMsg.toLowerCase().includes('constraint') ||
|
|
64
|
+
errorMsg.toLowerCase().includes('foreign key')) {
|
|
65
|
+
return {
|
|
66
|
+
Success: false,
|
|
67
|
+
ResultCode: 'REFERENCE_CONSTRAINT',
|
|
68
|
+
Message: `Cannot delete scheduled job '${jobName}': It is referenced by other records (such as job runs)`
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
Success: false,
|
|
73
|
+
ResultCode: 'FAILED',
|
|
74
|
+
Message: `Failed to delete scheduled job: ${errorMsg}`
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
Success: true,
|
|
79
|
+
ResultCode: 'SUCCESS',
|
|
80
|
+
Message: `Successfully deleted scheduled job '${jobName}' (ID: ${jobId})`
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
return {
|
|
85
|
+
Success: false,
|
|
86
|
+
ResultCode: 'FAILED',
|
|
87
|
+
Message: `Error deleting scheduled job: ${error instanceof Error ? error.message : String(error)}`
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
exports.DeleteScheduledJobAction = DeleteScheduledJobAction;
|
|
93
|
+
exports.DeleteScheduledJobAction = DeleteScheduledJobAction = __decorate([
|
|
94
|
+
(0, global_1.RegisterClass)(actions_1.BaseAction, 'Delete Scheduled Job')
|
|
95
|
+
], DeleteScheduledJobAction);
|
|
96
|
+
/**
|
|
97
|
+
* Loader function to prevent tree shaking
|
|
98
|
+
*/
|
|
99
|
+
function LoadDeleteScheduledJobAction() {
|
|
100
|
+
// Stub function - ensures class is included in bundle
|
|
101
|
+
}
|
|
102
|
+
exports.LoadDeleteScheduledJobAction = LoadDeleteScheduledJobAction;
|
|
103
|
+
//# sourceMappingURL=DeleteJobAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeleteJobAction.js","sourceRoot":"","sources":["../src/DeleteJobAction.ts"],"names":[],"mappings":";;;;;;;;;AACA,mDAAuD;AACvD,qDAAqD;AACrD,mDAAgD;AAEhD;;;;;;;;;;;;;;GAcG;AAEI,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,6BAAa;IACvD;;;;;;;;;;OAUG;IACO,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAElD,IAAI,CAAC,KAAK,EAAE,CAAC;gBACT,OAAO;oBACH,OAAO,EAAE,KAAK;oBACd,UAAU,EAAE,kBAAkB;oBAC9B,OAAO,EAAE,6BAA6B;iBACzC,CAAC;YACN,CAAC;YAED,eAAe;YACf,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;YACjE,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;gBACnB,OAAO,UAAU,CAAC,KAAK,CAAC;YAC5B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AAC,oBAAU,EAAE,sBAAsB,CAAC;GACrC,wBAAwB,CAuEpC;AAED;;GAEG;AACH,SAAgB,4BAA4B;IACxC,sDAAsD;AAC1D,CAAC;AAFD,oEAEC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
2
|
+
import { BaseJobAction } from './BaseJobAction';
|
|
3
|
+
/**
|
|
4
|
+
* Execute Scheduled Job Now action.
|
|
5
|
+
* Triggers immediate execution of a scheduled job, bypassing its normal schedule.
|
|
6
|
+
* Creates a job run record with "Pending" status for the scheduling engine to pick up.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* await RunAction({
|
|
11
|
+
* ActionName: 'Execute Scheduled Job Now',
|
|
12
|
+
* Params: [
|
|
13
|
+
* { Name: 'JobID', Value: 'F3C4A5B6-...' }
|
|
14
|
+
* ]
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class ExecuteScheduledJobNowAction extends BaseJobAction {
|
|
19
|
+
/**
|
|
20
|
+
* Triggers immediate execution of a scheduled job
|
|
21
|
+
*
|
|
22
|
+
* @param params - The action parameters containing:
|
|
23
|
+
* - JobID (required): ID of the job to execute
|
|
24
|
+
*
|
|
25
|
+
* @returns ActionResultSimple with:
|
|
26
|
+
* - Success: true if job execution was queued successfully
|
|
27
|
+
* - ResultCode: SUCCESS, VALIDATION_ERROR, NOT_FOUND, or FAILED
|
|
28
|
+
* - Params: Output parameter 'RunID' contains the ID of the created job run
|
|
29
|
+
*/
|
|
30
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Loader function to prevent tree shaking
|
|
34
|
+
*/
|
|
35
|
+
export declare function LoadExecuteScheduledJobNowAction(): void;
|
|
36
|
+
//# sourceMappingURL=ExecuteJobNowAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExecuteJobNowAction.d.ts","sourceRoot":"","sources":["../src/ExecuteJobNowAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAKnF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;;;;;;;GAcG;AACH,qBACa,4BAA6B,SAAQ,aAAa;IAC3D;;;;;;;;;;OAUG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAoE1F;AAED;;GAEG;AACH,wBAAgB,gCAAgC,SAE/C"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.LoadExecuteScheduledJobNowAction = exports.ExecuteScheduledJobNowAction = void 0;
|
|
10
|
+
const global_1 = require("@memberjunction/global");
|
|
11
|
+
const actions_1 = require("@memberjunction/actions");
|
|
12
|
+
const core_1 = require("@memberjunction/core");
|
|
13
|
+
const BaseJobAction_1 = require("./BaseJobAction");
|
|
14
|
+
/**
|
|
15
|
+
* Execute Scheduled Job Now action.
|
|
16
|
+
* Triggers immediate execution of a scheduled job, bypassing its normal schedule.
|
|
17
|
+
* Creates a job run record with "Pending" status for the scheduling engine to pick up.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* await RunAction({
|
|
22
|
+
* ActionName: 'Execute Scheduled Job Now',
|
|
23
|
+
* Params: [
|
|
24
|
+
* { Name: 'JobID', Value: 'F3C4A5B6-...' }
|
|
25
|
+
* ]
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
let ExecuteScheduledJobNowAction = class ExecuteScheduledJobNowAction extends BaseJobAction_1.BaseJobAction {
|
|
30
|
+
/**
|
|
31
|
+
* Triggers immediate execution of a scheduled job
|
|
32
|
+
*
|
|
33
|
+
* @param params - The action parameters containing:
|
|
34
|
+
* - JobID (required): ID of the job to execute
|
|
35
|
+
*
|
|
36
|
+
* @returns ActionResultSimple with:
|
|
37
|
+
* - Success: true if job execution was queued successfully
|
|
38
|
+
* - ResultCode: SUCCESS, VALIDATION_ERROR, NOT_FOUND, or FAILED
|
|
39
|
+
* - Params: Output parameter 'RunID' contains the ID of the created job run
|
|
40
|
+
*/
|
|
41
|
+
async InternalRunAction(params) {
|
|
42
|
+
try {
|
|
43
|
+
const jobId = this.getParamValue(params, 'JobID');
|
|
44
|
+
if (!jobId) {
|
|
45
|
+
return {
|
|
46
|
+
Success: false,
|
|
47
|
+
ResultCode: 'VALIDATION_ERROR',
|
|
48
|
+
Message: 'JobID parameter is required'
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// Load the job to verify it exists
|
|
52
|
+
const loadResult = await this.loadJob(jobId, params.ContextUser);
|
|
53
|
+
if (loadResult.error) {
|
|
54
|
+
return loadResult.error;
|
|
55
|
+
}
|
|
56
|
+
const job = loadResult.job;
|
|
57
|
+
// Check if job status allows execution
|
|
58
|
+
if (job.Status !== 'Active') {
|
|
59
|
+
return {
|
|
60
|
+
Success: false,
|
|
61
|
+
ResultCode: 'VALIDATION_ERROR',
|
|
62
|
+
Message: `Cannot execute job '${job.Name}' with status '${job.Status}'. Job must be Active.`
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// Create a job run record
|
|
66
|
+
const md = new core_1.Metadata();
|
|
67
|
+
const jobRun = await md.GetEntityObject('MJ: Scheduled Job Runs', params.ContextUser);
|
|
68
|
+
jobRun.NewRecord();
|
|
69
|
+
jobRun.ScheduledJobID = job.ID;
|
|
70
|
+
jobRun.Status = 'Running';
|
|
71
|
+
jobRun.StartedAt = new Date();
|
|
72
|
+
jobRun.QueuedAt = new Date();
|
|
73
|
+
// Save the job run
|
|
74
|
+
const saveResult = await jobRun.Save();
|
|
75
|
+
if (!saveResult) {
|
|
76
|
+
return {
|
|
77
|
+
Success: false,
|
|
78
|
+
ResultCode: 'FAILED',
|
|
79
|
+
Message: `Failed to create job run: ${jobRun.LatestResult?.Message || 'Unknown error'}`
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
// Add output parameter with run ID
|
|
83
|
+
this.addOutputParam(params, 'RunID', jobRun.ID);
|
|
84
|
+
return {
|
|
85
|
+
Success: true,
|
|
86
|
+
ResultCode: 'SUCCESS',
|
|
87
|
+
Message: `Scheduled job '${job.Name}' queued for immediate execution (Run ID: ${jobRun.ID})`,
|
|
88
|
+
Params: params.Params
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
return {
|
|
93
|
+
Success: false,
|
|
94
|
+
ResultCode: 'FAILED',
|
|
95
|
+
Message: `Error executing scheduled job: ${error instanceof Error ? error.message : String(error)}`
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
exports.ExecuteScheduledJobNowAction = ExecuteScheduledJobNowAction;
|
|
101
|
+
exports.ExecuteScheduledJobNowAction = ExecuteScheduledJobNowAction = __decorate([
|
|
102
|
+
(0, global_1.RegisterClass)(actions_1.BaseAction, 'Execute Scheduled Job Now')
|
|
103
|
+
], ExecuteScheduledJobNowAction);
|
|
104
|
+
/**
|
|
105
|
+
* Loader function to prevent tree shaking
|
|
106
|
+
*/
|
|
107
|
+
function LoadExecuteScheduledJobNowAction() {
|
|
108
|
+
// Stub function - ensures class is included in bundle
|
|
109
|
+
}
|
|
110
|
+
exports.LoadExecuteScheduledJobNowAction = LoadExecuteScheduledJobNowAction;
|
|
111
|
+
//# sourceMappingURL=ExecuteJobNowAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExecuteJobNowAction.js","sourceRoot":"","sources":["../src/ExecuteJobNowAction.ts"],"names":[],"mappings":";;;;;;;;;AACA,mDAAuD;AACvD,qDAAqD;AACrD,+CAAgD;AAEhD,mDAAgD;AAEhD;;;;;;;;;;;;;;GAcG;AAEI,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,6BAAa;IAC3D;;;;;;;;;;OAUG;IACO,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAElD,IAAI,CAAC,KAAK,EAAE,CAAC;gBACT,OAAO;oBACH,OAAO,EAAE,KAAK;oBACd,UAAU,EAAE,kBAAkB;oBAC9B,OAAO,EAAE,6BAA6B;iBACzC,CAAC;YACN,CAAC;YAED,mCAAmC;YACnC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;YACjE,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;gBACnB,OAAO,UAAU,CAAC,KAAK,CAAC;YAC5B,CAAC;YAED,MAAM,GAAG,GAAG,UAAU,CAAC,GAAI,CAAC;YAE5B,uCAAuC;YACvC,IAAI,GAAG,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC1B,OAAO;oBACH,OAAO,EAAE,KAAK;oBACd,UAAU,EAAE,kBAAkB;oBAC9B,OAAO,EAAE,uBAAuB,GAAG,CAAC,IAAI,kBAAkB,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M,CAAC,KAAK,CAAC,EAAE;aACtG,CAAC;QACN,CAAC;IACL,CAAC;CACJ,CAAA;AAhFY,oEAA4B;uCAA5B,4BAA4B;IADxC,IAAA,sBAAa,EAAC,oBAAU,EAAE,2BAA2B,CAAC;GAC1C,4BAA4B,CAgFxC;AAED;;GAEG;AACH,SAAgB,gCAAgC;IAC5C,sDAAsD;AAC1D,CAAC;AAFD,4EAEC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
2
|
+
import { BaseJobAction } from './BaseJobAction';
|
|
3
|
+
/**
|
|
4
|
+
* Get Scheduled Job Statistics action.
|
|
5
|
+
* Retrieves execution statistics for one or more scheduled jobs, including
|
|
6
|
+
* total runs, success/failure counts, success rate, and average duration.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* await RunAction({
|
|
11
|
+
* ActionName: 'Get Scheduled Job Statistics',
|
|
12
|
+
* Params: [
|
|
13
|
+
* { Name: 'JobID', Value: 'F3C4A5B6-...' },
|
|
14
|
+
* { Name: 'DaysBack', Value: '30' }
|
|
15
|
+
* ]
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare class GetScheduledJobStatisticsAction extends BaseJobAction {
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves execution statistics for scheduled jobs
|
|
22
|
+
*
|
|
23
|
+
* @param params - The action parameters containing:
|
|
24
|
+
* - JobID (optional): ID of specific job to get stats for (if omitted, gets stats for all jobs)
|
|
25
|
+
* - DaysBack (optional): Number of days to include in statistics (default: 30)
|
|
26
|
+
*
|
|
27
|
+
* @returns ActionResultSimple with:
|
|
28
|
+
* - Success: true if statistics were retrieved successfully
|
|
29
|
+
* - ResultCode: SUCCESS or FAILED
|
|
30
|
+
* - Params: Output parameter 'Statistics' contains array of JobStatistics objects
|
|
31
|
+
*/
|
|
32
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Loader function to prevent tree shaking
|
|
36
|
+
*/
|
|
37
|
+
export declare function LoadGetScheduledJobStatisticsAction(): void;
|
|
38
|
+
//# sourceMappingURL=GetJobStatisticsAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetJobStatisticsAction.d.ts","sourceRoot":"","sources":["../src/GetJobStatisticsAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAKnF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAiBhD;;;;;;;;;;;;;;;GAeG;AACH,qBACa,+BAAgC,SAAQ,aAAa;IAC9D;;;;;;;;;;;OAWG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAmI1F;AAED;;GAEG;AACH,wBAAgB,mCAAmC,SAElD"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.LoadGetScheduledJobStatisticsAction = exports.GetScheduledJobStatisticsAction = void 0;
|
|
10
|
+
const global_1 = require("@memberjunction/global");
|
|
11
|
+
const actions_1 = require("@memberjunction/actions");
|
|
12
|
+
const core_1 = require("@memberjunction/core");
|
|
13
|
+
const BaseJobAction_1 = require("./BaseJobAction");
|
|
14
|
+
/**
|
|
15
|
+
* Get Scheduled Job Statistics action.
|
|
16
|
+
* Retrieves execution statistics for one or more scheduled jobs, including
|
|
17
|
+
* total runs, success/failure counts, success rate, and average duration.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* await RunAction({
|
|
22
|
+
* ActionName: 'Get Scheduled Job Statistics',
|
|
23
|
+
* Params: [
|
|
24
|
+
* { Name: 'JobID', Value: 'F3C4A5B6-...' },
|
|
25
|
+
* { Name: 'DaysBack', Value: '30' }
|
|
26
|
+
* ]
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
let GetScheduledJobStatisticsAction = class GetScheduledJobStatisticsAction extends BaseJobAction_1.BaseJobAction {
|
|
31
|
+
/**
|
|
32
|
+
* Retrieves execution statistics for scheduled jobs
|
|
33
|
+
*
|
|
34
|
+
* @param params - The action parameters containing:
|
|
35
|
+
* - JobID (optional): ID of specific job to get stats for (if omitted, gets stats for all jobs)
|
|
36
|
+
* - DaysBack (optional): Number of days to include in statistics (default: 30)
|
|
37
|
+
*
|
|
38
|
+
* @returns ActionResultSimple with:
|
|
39
|
+
* - Success: true if statistics were retrieved successfully
|
|
40
|
+
* - ResultCode: SUCCESS or FAILED
|
|
41
|
+
* - Params: Output parameter 'Statistics' contains array of JobStatistics objects
|
|
42
|
+
*/
|
|
43
|
+
async InternalRunAction(params) {
|
|
44
|
+
try {
|
|
45
|
+
const jobId = this.getParamValue(params, 'JobID');
|
|
46
|
+
const daysBack = this.getNumericParam(params, 'DaysBack', 30);
|
|
47
|
+
// Calculate date threshold
|
|
48
|
+
const dateThreshold = new Date();
|
|
49
|
+
dateThreshold.setDate(dateThreshold.getDate() - daysBack);
|
|
50
|
+
// Build filter for job runs
|
|
51
|
+
const filters = [
|
|
52
|
+
`StartedAt >= '${dateThreshold.toISOString()}'`
|
|
53
|
+
];
|
|
54
|
+
if (jobId) {
|
|
55
|
+
filters.push(`ScheduledJobID = '${jobId}'`);
|
|
56
|
+
}
|
|
57
|
+
const filterExpression = filters.join(' AND ');
|
|
58
|
+
// Load all job runs within the time period
|
|
59
|
+
const rv = new core_1.RunView();
|
|
60
|
+
const result = await rv.RunView({
|
|
61
|
+
EntityName: 'MJ: Scheduled Job Runs',
|
|
62
|
+
ExtraFilter: filterExpression,
|
|
63
|
+
OrderBy: 'StartedAt DESC',
|
|
64
|
+
ResultType: 'entity_object'
|
|
65
|
+
}, params.ContextUser);
|
|
66
|
+
if (!result.Success) {
|
|
67
|
+
return {
|
|
68
|
+
Success: false,
|
|
69
|
+
ResultCode: 'FAILED',
|
|
70
|
+
Message: `Failed to load job runs: ${result.ErrorMessage}`
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const jobRuns = result.Results || [];
|
|
74
|
+
// Group runs by job and calculate statistics
|
|
75
|
+
const jobStatsMap = new Map();
|
|
76
|
+
for (const run of jobRuns) {
|
|
77
|
+
const runJobId = run.ScheduledJobID;
|
|
78
|
+
const runJobName = run.ScheduledJob || 'Unknown Job';
|
|
79
|
+
if (!jobStatsMap.has(runJobId)) {
|
|
80
|
+
jobStatsMap.set(runJobId, {
|
|
81
|
+
JobID: runJobId,
|
|
82
|
+
JobName: runJobName,
|
|
83
|
+
TotalRuns: 0,
|
|
84
|
+
SuccessfulRuns: 0,
|
|
85
|
+
FailedRuns: 0,
|
|
86
|
+
SuccessRate: 0,
|
|
87
|
+
AverageDurationSeconds: 0,
|
|
88
|
+
LastRunAt: null,
|
|
89
|
+
LastRunStatus: null
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const stats = jobStatsMap.get(runJobId);
|
|
93
|
+
stats.TotalRuns++;
|
|
94
|
+
// Count success/failure
|
|
95
|
+
if (run.Status === 'Completed') {
|
|
96
|
+
stats.SuccessfulRuns++;
|
|
97
|
+
}
|
|
98
|
+
else if (run.Status === 'Failed') {
|
|
99
|
+
stats.FailedRuns++;
|
|
100
|
+
}
|
|
101
|
+
// Track last run
|
|
102
|
+
if (!stats.LastRunAt || (run.StartedAt && run.StartedAt > stats.LastRunAt)) {
|
|
103
|
+
stats.LastRunAt = run.StartedAt || null;
|
|
104
|
+
stats.LastRunStatus = run.Status;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Calculate derived statistics
|
|
108
|
+
const statistics = [];
|
|
109
|
+
for (const stats of jobStatsMap.values()) {
|
|
110
|
+
// Calculate success rate
|
|
111
|
+
if (stats.TotalRuns > 0) {
|
|
112
|
+
stats.SuccessRate = Math.round((stats.SuccessfulRuns / stats.TotalRuns) * 100);
|
|
113
|
+
}
|
|
114
|
+
// Calculate average duration
|
|
115
|
+
const completedRuns = jobRuns.filter(r => r.ScheduledJobID === stats.JobID &&
|
|
116
|
+
r.Status === 'Completed' &&
|
|
117
|
+
r.StartedAt &&
|
|
118
|
+
r.CompletedAt);
|
|
119
|
+
if (completedRuns.length > 0) {
|
|
120
|
+
const totalDuration = completedRuns.reduce((sum, run) => {
|
|
121
|
+
const duration = run.CompletedAt.getTime() - run.StartedAt.getTime();
|
|
122
|
+
return sum + duration;
|
|
123
|
+
}, 0);
|
|
124
|
+
stats.AverageDurationSeconds = Math.round((totalDuration / completedRuns.length) / 1000);
|
|
125
|
+
}
|
|
126
|
+
statistics.push(stats);
|
|
127
|
+
}
|
|
128
|
+
// Sort by job name
|
|
129
|
+
statistics.sort((a, b) => a.JobName.localeCompare(b.JobName));
|
|
130
|
+
// Add output parameter
|
|
131
|
+
this.addOutputParam(params, 'Statistics', statistics);
|
|
132
|
+
const summaryMessage = jobId
|
|
133
|
+
? `Retrieved statistics for job (${statistics.length} job found, ${jobRuns.length} runs in last ${daysBack} days)`
|
|
134
|
+
: `Retrieved statistics for ${statistics.length} job(s) (${jobRuns.length} total runs in last ${daysBack} days)`;
|
|
135
|
+
return {
|
|
136
|
+
Success: true,
|
|
137
|
+
ResultCode: 'SUCCESS',
|
|
138
|
+
Message: summaryMessage,
|
|
139
|
+
Params: params.Params
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
return {
|
|
144
|
+
Success: false,
|
|
145
|
+
ResultCode: 'FAILED',
|
|
146
|
+
Message: `Error retrieving job statistics: ${error instanceof Error ? error.message : String(error)}`
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
exports.GetScheduledJobStatisticsAction = GetScheduledJobStatisticsAction;
|
|
152
|
+
exports.GetScheduledJobStatisticsAction = GetScheduledJobStatisticsAction = __decorate([
|
|
153
|
+
(0, global_1.RegisterClass)(actions_1.BaseAction, 'Get Scheduled Job Statistics')
|
|
154
|
+
], GetScheduledJobStatisticsAction);
|
|
155
|
+
/**
|
|
156
|
+
* Loader function to prevent tree shaking
|
|
157
|
+
*/
|
|
158
|
+
function LoadGetScheduledJobStatisticsAction() {
|
|
159
|
+
// Stub function - ensures class is included in bundle
|
|
160
|
+
}
|
|
161
|
+
exports.LoadGetScheduledJobStatisticsAction = LoadGetScheduledJobStatisticsAction;
|
|
162
|
+
//# sourceMappingURL=GetJobStatisticsAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetJobStatisticsAction.js","sourceRoot":"","sources":["../src/GetJobStatisticsAction.ts"],"names":[],"mappings":";;;;;;;;;AACA,mDAAuD;AACvD,qDAAqD;AACrD,+CAA+C;AAE/C,mDAAgD;AAiBhD;;;;;;;;;;;;;;;GAeG;AAEI,IAAM,+BAA+B,GAArC,MAAM,+BAAgC,SAAQ,6BAAa;IAC9D;;;;;;;;;;;OAWG;IACO,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAClD,MAAM,QAAQ,GA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;gBAClH,CAAC,CAAC,4BAA4B,UAAU,CAAC,MAAM,YAAY,OAAO,CAAC,MAAM,uBAAuB,QAAQ,QAAQ,CAAC;YAErH,OAAO;gBACH,OAAO,EAAE,IAAI;gBACb,UAAU,EAAE,SAAS;gBACrB,OAAO,EAAE,cAAc;gBACvB,MAAM,EAAE,MAAM,CAAC,MAAM;aACxB,CAAC;QAEN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO;gBACH,OAAO,EAAE,KAAK;gBACd,UAAU,EAAE,QAAQ;gBACpB,OAAO,EAAE,oCAAoC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;aACxG,CAAC;QACN,CAAC;IACL,CAAC;CACJ,CAAA;AAhJY,0EAA+B;0CAA/B,+BAA+B;IAD3C,IAAA,sBAAa,EAAC,oBAAU,EAAE,8BAA8B,CAAC;GAC7C,+BAA+B,CAgJ3C;AAED;;GAEG;AACH,SAAgB,mCAAmC;IAC/C,sDAAsD;AAC1D,CAAC;AAFD,kFAEC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
2
|
+
import { BaseJobAction } from './BaseJobAction';
|
|
3
|
+
/**
|
|
4
|
+
* Query Scheduled Jobs action.
|
|
5
|
+
* Searches for scheduled jobs based on filter criteria including Status, JobTypeID,
|
|
6
|
+
* IsActive flag, and creation date ranges.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* await RunAction({
|
|
11
|
+
* ActionName: 'Query Scheduled Jobs',
|
|
12
|
+
* Params: [
|
|
13
|
+
* { Name: 'Status', Value: 'Active' },
|
|
14
|
+
* { Name: 'IsActive', Value: 'true' },
|
|
15
|
+
* { Name: 'MaxResults', Value: '50' }
|
|
16
|
+
* ]
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare class QueryScheduledJobsAction extends BaseJobAction {
|
|
21
|
+
/**
|
|
22
|
+
* Executes the scheduled job query with the provided filter parameters
|
|
23
|
+
*
|
|
24
|
+
* @param params - The action parameters containing:
|
|
25
|
+
* - Status (optional): Job status filter (Active, Disabled)
|
|
26
|
+
* - JobTypeID (optional): Filter by job type
|
|
27
|
+
* - IsActive (optional): Filter by active flag
|
|
28
|
+
* - CreatedAfter (optional): Filter jobs created after this date
|
|
29
|
+
* - CreatedBefore (optional): Filter jobs created before this date
|
|
30
|
+
* - MaxResults (optional): Limit number of results (default: 100)
|
|
31
|
+
*
|
|
32
|
+
* @returns ActionResultSimple with:
|
|
33
|
+
* - Success: true if query executed successfully
|
|
34
|
+
* - ResultCode: SUCCESS or FAILED
|
|
35
|
+
* - Params: Output parameter 'Jobs' contains array of ScheduledJobEntity records
|
|
36
|
+
*/
|
|
37
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Loader function to prevent tree shaking
|
|
41
|
+
*/
|
|
42
|
+
export declare function LoadQueryScheduledJobsAction(): void;
|
|
43
|
+
//# sourceMappingURL=QueryJobsAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryJobsAction.d.ts","sourceRoot":"","sources":["../src/QueryJobsAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAKnF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;;;;;;;;;GAgBG;AACH,qBACa,wBAAyB,SAAQ,aAAa;IACvD;;;;;;;;;;;;;;;OAeG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAyE1F;AAED;;GAEG;AACH,wBAAgB,4BAA4B,SAE3C"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.LoadQueryScheduledJobsAction = exports.QueryScheduledJobsAction = void 0;
|
|
10
|
+
const global_1 = require("@memberjunction/global");
|
|
11
|
+
const actions_1 = require("@memberjunction/actions");
|
|
12
|
+
const core_1 = require("@memberjunction/core");
|
|
13
|
+
const BaseJobAction_1 = require("./BaseJobAction");
|
|
14
|
+
/**
|
|
15
|
+
* Query Scheduled Jobs action.
|
|
16
|
+
* Searches for scheduled jobs based on filter criteria including Status, JobTypeID,
|
|
17
|
+
* IsActive flag, and creation date ranges.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* await RunAction({
|
|
22
|
+
* ActionName: 'Query Scheduled Jobs',
|
|
23
|
+
* Params: [
|
|
24
|
+
* { Name: 'Status', Value: 'Active' },
|
|
25
|
+
* { Name: 'IsActive', Value: 'true' },
|
|
26
|
+
* { Name: 'MaxResults', Value: '50' }
|
|
27
|
+
* ]
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
let QueryScheduledJobsAction = class QueryScheduledJobsAction extends BaseJobAction_1.BaseJobAction {
|
|
32
|
+
/**
|
|
33
|
+
* Executes the scheduled job query with the provided filter parameters
|
|
34
|
+
*
|
|
35
|
+
* @param params - The action parameters containing:
|
|
36
|
+
* - Status (optional): Job status filter (Active, Disabled)
|
|
37
|
+
* - JobTypeID (optional): Filter by job type
|
|
38
|
+
* - IsActive (optional): Filter by active flag
|
|
39
|
+
* - CreatedAfter (optional): Filter jobs created after this date
|
|
40
|
+
* - CreatedBefore (optional): Filter jobs created before this date
|
|
41
|
+
* - MaxResults (optional): Limit number of results (default: 100)
|
|
42
|
+
*
|
|
43
|
+
* @returns ActionResultSimple with:
|
|
44
|
+
* - Success: true if query executed successfully
|
|
45
|
+
* - ResultCode: SUCCESS or FAILED
|
|
46
|
+
* - Params: Output parameter 'Jobs' contains array of ScheduledJobEntity records
|
|
47
|
+
*/
|
|
48
|
+
async InternalRunAction(params) {
|
|
49
|
+
try {
|
|
50
|
+
// Extract filter parameters
|
|
51
|
+
const status = this.getParamValue(params, 'Status');
|
|
52
|
+
const jobTypeId = this.getParamValue(params, 'JobTypeID');
|
|
53
|
+
const isActiveStr = this.getParamValue(params, 'IsActive');
|
|
54
|
+
const createdAfter = this.getDateParam(params, 'CreatedAfter');
|
|
55
|
+
const createdBefore = this.getDateParam(params, 'CreatedBefore');
|
|
56
|
+
const maxResults = this.getNumericParam(params, 'MaxResults', 100);
|
|
57
|
+
// Validate status if provided
|
|
58
|
+
if (status && !this.isValidStatus(status)) {
|
|
59
|
+
return {
|
|
60
|
+
Success: false,
|
|
61
|
+
ResultCode: 'VALIDATION_ERROR',
|
|
62
|
+
Message: `Invalid status: ${status}. Valid values are: Active, Disabled`
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// Parse IsActive
|
|
66
|
+
let isActive;
|
|
67
|
+
if (isActiveStr !== undefined && isActiveStr !== null) {
|
|
68
|
+
isActive = this.getBooleanParam(params, 'IsActive', true);
|
|
69
|
+
}
|
|
70
|
+
// Build filter expression
|
|
71
|
+
const filterExpression = this.buildJobFilter({
|
|
72
|
+
status,
|
|
73
|
+
jobTypeId,
|
|
74
|
+
isActive,
|
|
75
|
+
createdAfter,
|
|
76
|
+
createdBefore
|
|
77
|
+
});
|
|
78
|
+
// Execute query
|
|
79
|
+
const rv = new core_1.RunView();
|
|
80
|
+
const result = await rv.RunView({
|
|
81
|
+
EntityName: 'MJ: Scheduled Jobs',
|
|
82
|
+
ExtraFilter: filterExpression,
|
|
83
|
+
OrderBy: '__mj_CreatedAt DESC',
|
|
84
|
+
MaxRows: maxResults,
|
|
85
|
+
ResultType: 'entity_object'
|
|
86
|
+
}, params.ContextUser);
|
|
87
|
+
// Check for query errors
|
|
88
|
+
if (!result.Success) {
|
|
89
|
+
return {
|
|
90
|
+
Success: false,
|
|
91
|
+
ResultCode: 'FAILED',
|
|
92
|
+
Message: `Failed to query scheduled jobs: ${result.ErrorMessage}`
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const jobs = result.Results || [];
|
|
96
|
+
// Add output parameter with the job array
|
|
97
|
+
this.addOutputParam(params, 'Jobs', jobs);
|
|
98
|
+
return {
|
|
99
|
+
Success: true,
|
|
100
|
+
ResultCode: 'SUCCESS',
|
|
101
|
+
Message: `Found ${jobs.length} scheduled job(s)`,
|
|
102
|
+
Params: params.Params
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
return {
|
|
107
|
+
Success: false,
|
|
108
|
+
ResultCode: 'FAILED',
|
|
109
|
+
Message: `Error querying scheduled jobs: ${error instanceof Error ? error.message : String(error)}`
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
exports.QueryScheduledJobsAction = QueryScheduledJobsAction;
|
|
115
|
+
exports.QueryScheduledJobsAction = QueryScheduledJobsAction = __decorate([
|
|
116
|
+
(0, global_1.RegisterClass)(actions_1.BaseAction, 'Query Scheduled Jobs')
|
|
117
|
+
], QueryScheduledJobsAction);
|
|
118
|
+
/**
|
|
119
|
+
* Loader function to prevent tree shaking
|
|
120
|
+
*/
|
|
121
|
+
function LoadQueryScheduledJobsAction() {
|
|
122
|
+
// Stub function - ensures class is included in bundle
|
|
123
|
+
}
|
|
124
|
+
exports.LoadQueryScheduledJobsAction = LoadQueryScheduledJobsAction;
|
|
125
|
+
//# sourceMappingURL=QueryJobsAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryJobsAction.js","sourceRoot":"","sources":["../src/QueryJobsAction.ts"],"names":[],"mappings":";;;;;;;;;AACA,mDAAuD;AACvD,qDAAqD;AACrD,+CAA+C;AAE/C,mDAAgD;AAEhD;;;;;;;;;;;;;;;;GAgBG;AAEI,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,6BAAa;IACvD;;;;;;;;;;;;;;;OAeG;IACO,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,IAAI,CAAC;YACD,4BAA4B;YAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACpD,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YAC1D,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YAC3D,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;YAC/D,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;YACjE,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,CAAC,CAAC;YAEnE,8BAA8B;YAC9B,IAAI,MAAM,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;gBACxC,OAAO;oBACH,OAAO,EAAE,KAAK;oBACd,UAAU,EAAE,kBAAkB;oBAC9B,OAAO,EAAE,mBAAmB,MAAM,sCAAsC;iBAC3E,CAAC;YACN,CAAC;YAED,iB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