@nocobase/plugin-workflow 1.2.12-alpha → 1.3.0-alpha.20240710084543
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/package.json +3 -3
- package/dist/client/AddButton.d.ts +0 -16
- package/dist/client/Branch.d.ts +0 -17
- package/dist/client/CanvasContent.d.ts +0 -12
- package/dist/client/ExecutionCanvas.d.ts +0 -10
- package/dist/client/ExecutionContextProvider.d.ts +0 -15
- package/dist/client/ExecutionLink.d.ts +0 -10
- package/dist/client/ExecutionPage.d.ts +0 -10
- package/dist/client/ExecutionResourceProvider.d.ts +0 -14
- package/dist/client/FlowContext.d.ts +0 -11
- package/dist/client/WorkflowCanvas.d.ts +0 -10
- package/dist/client/WorkflowLink.d.ts +0 -10
- package/dist/client/WorkflowPage.d.ts +0 -10
- package/dist/client/WorkflowPane.d.ts +0 -10
- package/dist/client/components/AssignedFieldsFormSchemaConfig.d.ts +0 -10
- package/dist/client/components/CheckboxGroupWithTooltip.d.ts +0 -15
- package/dist/client/components/CollectionBlockInitializer.d.ts +0 -10
- package/dist/client/components/CollectionFieldset.d.ts +0 -14
- package/dist/client/components/DetailsBlockProvider.d.ts +0 -14
- package/dist/client/components/DrawerDescription.d.ts +0 -10
- package/dist/client/components/DrawerForm.d.ts +0 -13
- package/dist/client/components/ExecutionStatus.d.ts +0 -13
- package/dist/client/components/FieldsSelect.d.ts +0 -10
- package/dist/client/components/FilterDynamicComponent.d.ts +0 -14
- package/dist/client/components/OpenDrawer.d.ts +0 -14
- package/dist/client/components/RadioWithTooltip.d.ts +0 -15
- package/dist/client/components/SimpleDesigner.d.ts +0 -10
- package/dist/client/components/StatusButton.d.ts +0 -10
- package/dist/client/components/TriggerOptionRender.d.ts +0 -12
- package/dist/client/components/ValueBlock.d.ts +0 -14
- package/dist/client/components/index.d.ts +0 -16
- package/dist/client/components/renderEngineReference.d.ts +0 -10
- package/dist/client/constants.d.ts +0 -45
- package/dist/client/hooks/index.d.ts +0 -11
- package/dist/client/hooks/useGetAriaLabelOfAddButton.d.ts +0 -14
- package/dist/client/hooks/useRefreshActionProps.d.ts +0 -11
- package/dist/client/hooks/useTriggerWorkflowActionProps.d.ts +0 -20
- package/dist/client/hooks/useWorkflowExecuted.d.ts +0 -10
- package/dist/client/index.d.ts +0 -43
- package/dist/client/index.js +0 -569
- package/dist/client/locale/index.d.ts +0 -11
- package/dist/client/nodes/calculation.d.ts +0 -80
- package/dist/client/nodes/condition.d.ts +0 -108
- package/dist/client/nodes/create.d.ts +0 -110
- package/dist/client/nodes/destroy.d.ts +0 -54
- package/dist/client/nodes/end.d.ts +0 -30
- package/dist/client/nodes/index.d.ts +0 -76
- package/dist/client/nodes/query.d.ts +0 -236
- package/dist/client/nodes/update.d.ts +0 -114
- package/dist/client/schemas/collection.d.ts +0 -170
- package/dist/client/schemas/executions.d.ts +0 -282
- package/dist/client/schemas/workflows.d.ts +0 -10
- package/dist/client/settings/customizeSubmitToWorkflowActionSettings.d.ts +0 -10
- package/dist/client/style.d.ts +0 -30
- package/dist/client/triggers/collection.d.ts +0 -124
- package/dist/client/triggers/index.d.ts +0 -36
- package/dist/client/triggers/schedule/EndsByField.d.ts +0 -13
- package/dist/client/triggers/schedule/OnField.d.ts +0 -13
- package/dist/client/triggers/schedule/RepeatField.d.ts +0 -13
- package/dist/client/triggers/schedule/ScheduleConfig.d.ts +0 -10
- package/dist/client/triggers/schedule/constants.d.ts +0 -12
- package/dist/client/triggers/schedule/index.d.ts +0 -33
- package/dist/client/triggers/schedule/locale/Cron.zh-CN.d.ts +0 -42
- package/dist/client/utils.d.ts +0 -12
- package/dist/client/variable.d.ts +0 -93
- package/dist/externalVersion.js +0 -34
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -48
- package/dist/locale/en-US.json +0 -98
- package/dist/locale/es-ES.json +0 -98
- package/dist/locale/fr-FR.json +0 -98
- package/dist/locale/ja-JP.json +0 -82
- package/dist/locale/ko_KR.json +0 -168
- package/dist/locale/pt-BR.json +0 -98
- package/dist/locale/ru-RU.json +0 -82
- package/dist/locale/tr-TR.json +0 -82
- package/dist/locale/zh-CN.json +0 -205
- package/dist/node_modules/cron-parser/.eslintrc.json +0 -15
- package/dist/node_modules/cron-parser/.travis.yml +0 -7
- package/dist/node_modules/cron-parser/LICENSE +0 -21
- package/dist/node_modules/cron-parser/component.json +0 -11
- package/dist/node_modules/cron-parser/index.d.ts +0 -1
- package/dist/node_modules/cron-parser/lib/date.js +0 -252
- package/dist/node_modules/cron-parser/lib/expression.js +0 -983
- package/dist/node_modules/cron-parser/lib/field_compactor.js +0 -70
- package/dist/node_modules/cron-parser/lib/field_stringify.js +0 -38
- package/dist/node_modules/cron-parser/lib/parser.js +0 -1
- package/dist/node_modules/cron-parser/node_modules/luxon/build/amd/luxon.js +0 -8489
- package/dist/node_modules/cron-parser/node_modules/luxon/build/cjs-browser/luxon.js +0 -8487
- package/dist/node_modules/cron-parser/node_modules/luxon/build/global/luxon.js +0 -8490
- package/dist/node_modules/cron-parser/node_modules/luxon/build/global/luxon.min.js +0 -1
- package/dist/node_modules/cron-parser/node_modules/luxon/build/node/luxon.js +0 -7522
- package/dist/node_modules/cron-parser/node_modules/luxon/package.json +0 -96
- package/dist/node_modules/cron-parser/node_modules/luxon/src/datetime.js +0 -2169
- package/dist/node_modules/cron-parser/node_modules/luxon/src/duration.js +0 -880
- package/dist/node_modules/cron-parser/node_modules/luxon/src/errors.js +0 -61
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/conversions.js +0 -157
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/diff.js +0 -80
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/digits.js +0 -76
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/english.js +0 -233
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/formats.js +0 -191
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/formatter.js +0 -386
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/invalid.js +0 -14
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/locale.js +0 -482
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/regexParser.js +0 -335
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/tokenParser.js +0 -424
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/util.js +0 -292
- package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/zoneUtil.js +0 -36
- package/dist/node_modules/cron-parser/node_modules/luxon/src/info.js +0 -193
- package/dist/node_modules/cron-parser/node_modules/luxon/src/interval.js +0 -602
- package/dist/node_modules/cron-parser/node_modules/luxon/src/luxon.js +0 -26
- package/dist/node_modules/cron-parser/node_modules/luxon/src/luxonFilled.js +0 -13
- package/dist/node_modules/cron-parser/node_modules/luxon/src/settings.js +0 -137
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zone.js +0 -88
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/IANAZone.js +0 -191
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/fixedOffsetZone.js +0 -94
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/invalidZone.js +0 -53
- package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/localZone.js +0 -63
- package/dist/node_modules/cron-parser/package.json +0 -1
- package/dist/node_modules/cron-parser/test/31_of_month.js +0 -17
- package/dist/node_modules/cron-parser/test/bug.js +0 -29
- package/dist/node_modules/cron-parser/test/crondate.js +0 -16
- package/dist/node_modules/cron-parser/test/crontab.example +0 -7
- package/dist/node_modules/cron-parser/test/empty_around_comma.js +0 -22
- package/dist/node_modules/cron-parser/test/expression.js +0 -1489
- package/dist/node_modules/cron-parser/test/field_compactor.js +0 -250
- package/dist/node_modules/cron-parser/test/field_stringify.js +0 -84
- package/dist/node_modules/cron-parser/test/fields.js +0 -32
- package/dist/node_modules/cron-parser/test/increment_on_first_iteration.js +0 -22
- package/dist/node_modules/cron-parser/test/index-ts3.test-d.ts +0 -133
- package/dist/node_modules/cron-parser/test/index.test-d.ts +0 -138
- package/dist/node_modules/cron-parser/test/leap_year.js +0 -17
- package/dist/node_modules/cron-parser/test/parser.js +0 -46
- package/dist/node_modules/cron-parser/test/parser_crondate_formats.js +0 -145
- package/dist/node_modules/cron-parser/test/parser_day_of_month.js +0 -169
- package/dist/node_modules/cron-parser/test/prev_date.js +0 -32
- package/dist/node_modules/cron-parser/test/stringify.js +0 -402
- package/dist/node_modules/cron-parser/test/timezone.js +0 -422
- package/dist/node_modules/cron-parser/types/common.d.ts +0 -131
- package/dist/node_modules/cron-parser/types/index.d.ts +0 -45
- package/dist/node_modules/cron-parser/types/ts3/index.d.ts +0 -28
- package/dist/node_modules/lru-cache/LICENSE +0 -15
- package/dist/node_modules/lru-cache/dist/cjs/index-cjs.d.ts +0 -7
- package/dist/node_modules/lru-cache/dist/cjs/index-cjs.js +0 -1
- package/dist/node_modules/lru-cache/dist/cjs/index.d.ts +0 -807
- package/dist/node_modules/lru-cache/dist/cjs/index.js +0 -1334
- package/dist/node_modules/lru-cache/dist/cjs/index.min.js +0 -2
- package/dist/node_modules/lru-cache/dist/cjs/package.json +0 -3
- package/dist/node_modules/lru-cache/dist/mjs/index.d.ts +0 -807
- package/dist/node_modules/lru-cache/dist/mjs/index.js +0 -1330
- package/dist/node_modules/lru-cache/dist/mjs/index.min.js +0 -2
- package/dist/node_modules/lru-cache/dist/mjs/package.json +0 -3
- package/dist/node_modules/lru-cache/package.json +0 -1
- package/dist/server/Plugin.d.ts +0 -84
- package/dist/server/Plugin.js +0 -503
- package/dist/server/Processor.d.ts +0 -115
- package/dist/server/Processor.js +0 -363
- package/dist/server/actions/executions.d.ts +0 -11
- package/dist/server/actions/executions.js +0 -96
- package/dist/server/actions/index.d.ts +0 -11
- package/dist/server/actions/index.js +0 -66
- package/dist/server/actions/nodes.d.ts +0 -12
- package/dist/server/actions/nodes.js +0 -217
- package/dist/server/actions/workflows.d.ts +0 -14
- package/dist/server/actions/workflows.js +0 -184
- package/dist/server/collections/executions.d.ts +0 -11
- package/dist/server/collections/executions.js +0 -66
- package/dist/server/collections/flow_nodes.d.ts +0 -11
- package/dist/server/collections/flow_nodes.js +0 -87
- package/dist/server/collections/jobs.d.ts +0 -11
- package/dist/server/collections/jobs.js +0 -66
- package/dist/server/collections/workflows.d.ts +0 -10
- package/dist/server/collections/workflows.js +0 -126
- package/dist/server/constants.d.ts +0 -29
- package/dist/server/constants.js +0 -58
- package/dist/server/functions/index.d.ts +0 -17
- package/dist/server/functions/index.js +0 -40
- package/dist/server/index.d.ts +0 -15
- package/dist/server/index.js +0 -60
- package/dist/server/instructions/CalculationInstruction.d.ts +0 -25
- package/dist/server/instructions/CalculationInstruction.js +0 -59
- package/dist/server/instructions/ConditionInstruction.d.ts +0 -36
- package/dist/server/instructions/ConditionInstruction.js +0 -167
- package/dist/server/instructions/CreateInstruction.d.ts +0 -18
- package/dist/server/instructions/CreateInstruction.js +0 -75
- package/dist/server/instructions/DestroyInstruction.d.ts +0 -18
- package/dist/server/instructions/DestroyInstruction.js +0 -59
- package/dist/server/instructions/EndInstruction.d.ts +0 -14
- package/dist/server/instructions/EndInstruction.js +0 -55
- package/dist/server/instructions/QueryInstruction.d.ts +0 -21
- package/dist/server/instructions/QueryInstruction.js +0 -82
- package/dist/server/instructions/UpdateInstruction.d.ts +0 -18
- package/dist/server/instructions/UpdateInstruction.js +0 -59
- package/dist/server/instructions/index.d.ts +0 -31
- package/dist/server/instructions/index.js +0 -42
- package/dist/server/migrations/20221129153547-calculation-variables.d.ts +0 -14
- package/dist/server/migrations/20221129153547-calculation-variables.js +0 -92
- package/dist/server/migrations/20230221032941-change-request-body-type.d.ts +0 -14
- package/dist/server/migrations/20230221032941-change-request-body-type.js +0 -102
- package/dist/server/migrations/20230221071831-calculation-expression.d.ts +0 -13
- package/dist/server/migrations/20230221071831-calculation-expression.js +0 -121
- package/dist/server/migrations/20230221121203-condition-calculation.d.ts +0 -13
- package/dist/server/migrations/20230221121203-condition-calculation.js +0 -106
- package/dist/server/migrations/20230221162902-jsonb-to-json.d.ts +0 -13
- package/dist/server/migrations/20230221162902-jsonb-to-json.js +0 -63
- package/dist/server/migrations/20230411034722-manual-multi-form.d.ts +0 -13
- package/dist/server/migrations/20230411034722-manual-multi-form.js +0 -283
- package/dist/server/migrations/20230612021134-manual-collection-block.d.ts +0 -13
- package/dist/server/migrations/20230612021134-manual-collection-block.js +0 -152
- package/dist/server/migrations/20230710115902-manual-action-values.d.ts +0 -13
- package/dist/server/migrations/20230710115902-manual-action-values.js +0 -101
- package/dist/server/migrations/20230809113132-workflow-options.d.ts +0 -13
- package/dist/server/migrations/20230809113132-workflow-options.js +0 -64
- package/dist/server/migrations/20231024172342-add-node-key.d.ts +0 -13
- package/dist/server/migrations/20231024172342-add-node-key.js +0 -90
- package/dist/server/migrations/20231122143143-split-to-plugins.d.ts +0 -13
- package/dist/server/migrations/20231122143143-split-to-plugins.js +0 -67
- package/dist/server/migrations/20240115220721-add-node-key-to-job.d.ts +0 -14
- package/dist/server/migrations/20240115220721-add-node-key-to-job.js +0 -63
- package/dist/server/migrations/20240613222612-fix-assign-field-config.d.ts +0 -13
- package/dist/server/migrations/20240613222612-fix-assign-field-config.js +0 -62
- package/dist/server/triggers/CollectionTrigger.d.ts +0 -22
- package/dist/server/triggers/CollectionTrigger.js +0 -184
- package/dist/server/triggers/ScheduleTrigger/DateFieldScheduleTrigger.d.ts +0 -39
- package/dist/server/triggers/ScheduleTrigger/DateFieldScheduleTrigger.js +0 -356
- package/dist/server/triggers/ScheduleTrigger/StaticScheduleTrigger.d.ts +0 -21
- package/dist/server/triggers/ScheduleTrigger/StaticScheduleTrigger.js +0 -152
- package/dist/server/triggers/ScheduleTrigger/index.d.ts +0 -18
- package/dist/server/triggers/ScheduleTrigger/index.js +0 -84
- package/dist/server/triggers/ScheduleTrigger/utils.d.ts +0 -13
- package/dist/server/triggers/ScheduleTrigger/utils.js +0 -44
- package/dist/server/triggers/index.d.ts +0 -21
- package/dist/server/triggers/index.js +0 -46
- package/dist/server/types/Execution.d.ts +0 -25
- package/dist/server/types/Execution.js +0 -34
- package/dist/server/types/FlowNode.d.ts +0 -24
- package/dist/server/types/FlowNode.js +0 -34
- package/dist/server/types/Job.d.ts +0 -22
- package/dist/server/types/Job.js +0 -34
- package/dist/server/types/Workflow.d.ts +0 -35
- package/dist/server/types/Workflow.js +0 -34
- package/dist/server/types/index.d.ts +0 -12
- package/dist/server/types/index.js +0 -24
- package/dist/server/utils.d.ts +0 -9
- package/dist/server/utils.js +0 -51
- package/dist/swagger/index.d.ts +0 -762
- package/dist/swagger/index.js +0 -807
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
-
var DateFieldScheduleTrigger_exports = {};
|
|
38
|
-
__export(DateFieldScheduleTrigger_exports, {
|
|
39
|
-
default: () => ScheduleTrigger
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(DateFieldScheduleTrigger_exports);
|
|
42
|
-
var import_database = require("@nocobase/database");
|
|
43
|
-
var import_cron_parser = __toESM(require("cron-parser"));
|
|
44
|
-
var import_utils = require("./utils");
|
|
45
|
-
var import_data_source_manager = require("@nocobase/data-source-manager");
|
|
46
|
-
function getOnTimestampWithOffset({ field, offset = 0, unit = 1e3 }, now) {
|
|
47
|
-
if (!field) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
const timestamp = now.getTime();
|
|
51
|
-
return timestamp - offset * unit;
|
|
52
|
-
}
|
|
53
|
-
function getDataOptionTime(record, on, dir = 1) {
|
|
54
|
-
if (!on) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
switch (typeof on) {
|
|
58
|
-
case "string": {
|
|
59
|
-
const time = (0, import_utils.parseDateWithoutMs)(on);
|
|
60
|
-
return time ? time : null;
|
|
61
|
-
}
|
|
62
|
-
case "object": {
|
|
63
|
-
const { field, offset = 0, unit = 1e3 } = on;
|
|
64
|
-
if (!record.get(field)) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
const second = new Date(record.get(field).getTime());
|
|
68
|
-
second.setMilliseconds(0);
|
|
69
|
-
return second.getTime() + offset * unit * dir;
|
|
70
|
-
}
|
|
71
|
-
default:
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const DialectTimestampFnMap = {
|
|
76
|
-
postgres(col) {
|
|
77
|
-
return `CAST(FLOOR(extract(epoch from "${col}")) AS INTEGER)`;
|
|
78
|
-
},
|
|
79
|
-
mysql(col) {
|
|
80
|
-
return `CAST(FLOOR(UNIX_TIMESTAMP(\`${col}\`)) AS SIGNED INTEGER)`;
|
|
81
|
-
},
|
|
82
|
-
sqlite(col) {
|
|
83
|
-
return `CAST(FLOOR(unixepoch(${col})) AS INTEGER)`;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
DialectTimestampFnMap.mariadb = DialectTimestampFnMap.mysql;
|
|
87
|
-
function getCronNextTime(cron, currentDate) {
|
|
88
|
-
const interval = import_cron_parser.default.parseExpression(cron, { currentDate });
|
|
89
|
-
const next = interval.next();
|
|
90
|
-
return next.getTime();
|
|
91
|
-
}
|
|
92
|
-
function matchCronNextTime(cron, currentDate, range) {
|
|
93
|
-
return getCronNextTime(cron, currentDate) - currentDate.getTime() <= range;
|
|
94
|
-
}
|
|
95
|
-
function getHookId(workflow, type) {
|
|
96
|
-
return `${type}#${workflow.id}`;
|
|
97
|
-
}
|
|
98
|
-
class ScheduleTrigger {
|
|
99
|
-
constructor(workflow) {
|
|
100
|
-
this.workflow = workflow;
|
|
101
|
-
workflow.app.on("afterStart", async () => {
|
|
102
|
-
if (this.timer) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
this.timer = setInterval(() => this.reload(), this.cacheCycle);
|
|
106
|
-
this.reload();
|
|
107
|
-
});
|
|
108
|
-
workflow.app.on("beforeStop", () => {
|
|
109
|
-
if (this.timer) {
|
|
110
|
-
clearInterval(this.timer);
|
|
111
|
-
}
|
|
112
|
-
for (const [key, timer] of this.cache.entries()) {
|
|
113
|
-
clearTimeout(timer);
|
|
114
|
-
this.cache.delete(key);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
events = /* @__PURE__ */ new Map();
|
|
119
|
-
timer = null;
|
|
120
|
-
cache = /* @__PURE__ */ new Map();
|
|
121
|
-
// caching workflows in range, default to 5min
|
|
122
|
-
cacheCycle = 3e5;
|
|
123
|
-
async reload() {
|
|
124
|
-
const workflows = Array.from(this.workflow.enabledCache.values()).filter(
|
|
125
|
-
(item) => item.type === "schedule" && item.config.mode === import_utils.SCHEDULE_MODE.DATE_FIELD
|
|
126
|
-
);
|
|
127
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
128
|
-
this.inspect(workflows);
|
|
129
|
-
}
|
|
130
|
-
inspect(workflows) {
|
|
131
|
-
const now = /* @__PURE__ */ new Date();
|
|
132
|
-
workflows.forEach(async (workflow) => {
|
|
133
|
-
const records = await this.loadRecordsToSchedule(workflow, now);
|
|
134
|
-
records.forEach((record) => {
|
|
135
|
-
const nextTime = this.getRecordNextTime(workflow, record);
|
|
136
|
-
this.schedule(workflow, record, nextTime, Boolean(nextTime));
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
// 1. startsOn in range -> yes
|
|
141
|
-
// 2. startsOn before now, has no repeat -> no
|
|
142
|
-
// 3. startsOn before now, and has repeat:
|
|
143
|
-
// a. repeat out of range -> no
|
|
144
|
-
// b. repeat in range (number or cron):
|
|
145
|
-
// i. endsOn after now -> yes
|
|
146
|
-
// ii. endsOn before now -> no
|
|
147
|
-
async loadRecordsToSchedule({ config: { collection, limit, startsOn, repeat, endsOn }, allExecuted }, currentDate) {
|
|
148
|
-
const { db } = this.workflow.app;
|
|
149
|
-
if (limit && allExecuted >= limit) {
|
|
150
|
-
return [];
|
|
151
|
-
}
|
|
152
|
-
if (!startsOn) {
|
|
153
|
-
return [];
|
|
154
|
-
}
|
|
155
|
-
const timestamp = currentDate.getTime();
|
|
156
|
-
const startTimestamp = getOnTimestampWithOffset(startsOn, currentDate);
|
|
157
|
-
if (!startTimestamp) {
|
|
158
|
-
return [];
|
|
159
|
-
}
|
|
160
|
-
const range = this.cacheCycle * 2;
|
|
161
|
-
const conditions = [
|
|
162
|
-
{
|
|
163
|
-
[startsOn.field]: {
|
|
164
|
-
// cache next 2 cycles
|
|
165
|
-
[import_database.Op.lt]: new Date(startTimestamp + range)
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
];
|
|
169
|
-
if (repeat) {
|
|
170
|
-
if (typeof repeat === "number") {
|
|
171
|
-
const tsFn = DialectTimestampFnMap[db.options.dialect];
|
|
172
|
-
if (repeat > range && tsFn) {
|
|
173
|
-
const modExp = (0, import_database.fn)(
|
|
174
|
-
"MOD",
|
|
175
|
-
(0, import_database.literal)(`${Math.round(timestamp / 1e3)} - ${tsFn(startsOn.field)}`),
|
|
176
|
-
Math.round(repeat / 1e3)
|
|
177
|
-
);
|
|
178
|
-
conditions.push((0, import_database.where)(modExp, { [import_database.Op.lt]: Math.round(range / 1e3) }));
|
|
179
|
-
}
|
|
180
|
-
} else if (typeof repeat === "string") {
|
|
181
|
-
if (!matchCronNextTime(repeat, currentDate, range)) {
|
|
182
|
-
return [];
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (endsOn) {
|
|
186
|
-
const now = /* @__PURE__ */ new Date();
|
|
187
|
-
const endTimestamp = getOnTimestampWithOffset(endsOn, now);
|
|
188
|
-
if (!endTimestamp) {
|
|
189
|
-
return [];
|
|
190
|
-
}
|
|
191
|
-
if (typeof endsOn === "string") {
|
|
192
|
-
if (endTimestamp <= timestamp) {
|
|
193
|
-
return [];
|
|
194
|
-
}
|
|
195
|
-
} else {
|
|
196
|
-
conditions.push({
|
|
197
|
-
[endsOn.field]: {
|
|
198
|
-
[import_database.Op.gte]: new Date(endTimestamp)
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
} else {
|
|
204
|
-
conditions.push({
|
|
205
|
-
[startsOn.field]: {
|
|
206
|
-
[import_database.Op.gte]: new Date(startTimestamp)
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
const { model } = db.getCollection(collection);
|
|
211
|
-
return model.findAll({
|
|
212
|
-
where: {
|
|
213
|
-
[import_database.Op.and]: conditions
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
getRecordNextTime(workflow, record, nextSecond = false) {
|
|
218
|
-
const {
|
|
219
|
-
config: { startsOn, endsOn, repeat, limit },
|
|
220
|
-
allExecuted
|
|
221
|
-
} = workflow;
|
|
222
|
-
if (limit && allExecuted >= limit) {
|
|
223
|
-
return null;
|
|
224
|
-
}
|
|
225
|
-
const range = this.cacheCycle;
|
|
226
|
-
const now = /* @__PURE__ */ new Date();
|
|
227
|
-
now.setMilliseconds(nextSecond ? 1e3 : 0);
|
|
228
|
-
const timestamp = now.getTime();
|
|
229
|
-
const startTime = getDataOptionTime(record, startsOn);
|
|
230
|
-
const endTime = getDataOptionTime(record, endsOn);
|
|
231
|
-
let nextTime = null;
|
|
232
|
-
if (!startTime) {
|
|
233
|
-
return null;
|
|
234
|
-
}
|
|
235
|
-
if (startTime > timestamp + range) {
|
|
236
|
-
return null;
|
|
237
|
-
}
|
|
238
|
-
if (startTime >= timestamp) {
|
|
239
|
-
return !endTime || endTime >= startTime && endTime < timestamp + range ? startTime : null;
|
|
240
|
-
} else {
|
|
241
|
-
if (!repeat) {
|
|
242
|
-
return null;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
if (typeof repeat === "number") {
|
|
246
|
-
const nextRepeatTime = (startTime - timestamp) % repeat + repeat;
|
|
247
|
-
if (nextRepeatTime > range) {
|
|
248
|
-
return null;
|
|
249
|
-
}
|
|
250
|
-
if (endTime && endTime < timestamp + nextRepeatTime) {
|
|
251
|
-
return null;
|
|
252
|
-
}
|
|
253
|
-
nextTime = timestamp + nextRepeatTime;
|
|
254
|
-
} else if (typeof repeat === "string") {
|
|
255
|
-
nextTime = getCronNextTime(repeat, now);
|
|
256
|
-
if (nextTime - timestamp > range) {
|
|
257
|
-
return null;
|
|
258
|
-
}
|
|
259
|
-
if (endTime && endTime < nextTime) {
|
|
260
|
-
return null;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
if (endTime && endTime <= timestamp) {
|
|
264
|
-
return null;
|
|
265
|
-
}
|
|
266
|
-
return nextTime;
|
|
267
|
-
}
|
|
268
|
-
schedule(workflow, record, nextTime, toggle = true, options = {}) {
|
|
269
|
-
const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(workflow.config.collection);
|
|
270
|
-
const { filterTargetKey } = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager.getCollection(collectionName);
|
|
271
|
-
const recordPk = record.get(filterTargetKey);
|
|
272
|
-
if (toggle) {
|
|
273
|
-
const nextInterval = Math.max(0, nextTime - Date.now());
|
|
274
|
-
const key = `${workflow.id}:${recordPk}@${nextTime}`;
|
|
275
|
-
if (!this.cache.has(key)) {
|
|
276
|
-
if (nextInterval) {
|
|
277
|
-
this.cache.set(key, setTimeout(this.trigger.bind(this, workflow, record, nextTime), nextInterval));
|
|
278
|
-
} else {
|
|
279
|
-
return this.trigger(workflow, record, nextTime, options);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
} else {
|
|
283
|
-
for (const [key, timer] of this.cache.entries()) {
|
|
284
|
-
if (key.startsWith(`${workflow.id}:${recordPk}@`)) {
|
|
285
|
-
clearTimeout(timer);
|
|
286
|
-
this.cache.delete(key);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
async trigger(workflow, record, nextTime, { transaction } = {}) {
|
|
292
|
-
const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(workflow.config.collection);
|
|
293
|
-
const { repository, filterTargetKey } = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager.getCollection(collectionName);
|
|
294
|
-
const recordPk = record.get(filterTargetKey);
|
|
295
|
-
const data = await repository.findOne({
|
|
296
|
-
filterByTk: recordPk,
|
|
297
|
-
appends: workflow.config.appends,
|
|
298
|
-
transaction
|
|
299
|
-
});
|
|
300
|
-
const eventKey = `${workflow.id}:${recordPk}@${nextTime}`;
|
|
301
|
-
this.cache.delete(eventKey);
|
|
302
|
-
this.workflow.trigger(
|
|
303
|
-
workflow,
|
|
304
|
-
{
|
|
305
|
-
data: data.toJSON(),
|
|
306
|
-
date: new Date(nextTime)
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
eventKey
|
|
310
|
-
}
|
|
311
|
-
);
|
|
312
|
-
if (!workflow.config.repeat || workflow.config.limit && workflow.allExecuted >= workflow.config.limit - 1) {
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
const n = this.getRecordNextTime(workflow, data, true);
|
|
316
|
-
if (n) {
|
|
317
|
-
this.schedule(workflow, data, n, true);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
on(workflow) {
|
|
321
|
-
this.inspect([workflow]);
|
|
322
|
-
const { collection } = workflow.config;
|
|
323
|
-
const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
|
|
324
|
-
const event = `${collectionName}.afterSaveWithAssociations`;
|
|
325
|
-
const eventKey = `${collection}.afterSaveWithAssociations`;
|
|
326
|
-
const name = getHookId(workflow, event);
|
|
327
|
-
if (this.events.has(name)) {
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
const listener = async (data, { transaction }) => {
|
|
331
|
-
const nextTime = this.getRecordNextTime(workflow, data);
|
|
332
|
-
return this.schedule(workflow, data, nextTime, Boolean(nextTime), { transaction });
|
|
333
|
-
};
|
|
334
|
-
this.events.set(name, listener);
|
|
335
|
-
this.workflow.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager.db.on(event, listener);
|
|
336
|
-
}
|
|
337
|
-
off(workflow) {
|
|
338
|
-
for (const [key, timer] of this.cache.entries()) {
|
|
339
|
-
if (key.startsWith(`${workflow.id}:`)) {
|
|
340
|
-
clearTimeout(timer);
|
|
341
|
-
this.cache.delete(key);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
const { collection } = workflow.config;
|
|
345
|
-
const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
|
|
346
|
-
const event = `${collectionName}.afterSaveWithAssociations`;
|
|
347
|
-
const eventKey = `${collection}.afterSaveWithAssociations`;
|
|
348
|
-
const name = getHookId(workflow, event);
|
|
349
|
-
if (this.events.has(eventKey)) {
|
|
350
|
-
const listener = this.events.get(name);
|
|
351
|
-
const { db } = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager;
|
|
352
|
-
db.off(event, listener);
|
|
353
|
-
this.events.delete(eventKey);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import type Plugin from '../../Plugin';
|
|
10
|
-
import { WorkflowModel } from '../../types';
|
|
11
|
-
export default class StaticScheduleTrigger {
|
|
12
|
-
workflow: Plugin;
|
|
13
|
-
private timers;
|
|
14
|
-
constructor(workflow: Plugin);
|
|
15
|
-
inspect(workflows: WorkflowModel[]): void;
|
|
16
|
-
getNextTime({ config, allExecuted }: WorkflowModel, currentDate: Date, nextSecond?: boolean): number;
|
|
17
|
-
schedule(workflow: WorkflowModel, nextTime: number, toggle?: boolean): void;
|
|
18
|
-
trigger(workflow: WorkflowModel, time: number): Promise<void>;
|
|
19
|
-
on(workflow: any): void;
|
|
20
|
-
off(workflow: any): void;
|
|
21
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
-
var StaticScheduleTrigger_exports = {};
|
|
38
|
-
__export(StaticScheduleTrigger_exports, {
|
|
39
|
-
default: () => StaticScheduleTrigger
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(StaticScheduleTrigger_exports);
|
|
42
|
-
var import_cron_parser = __toESM(require("cron-parser"));
|
|
43
|
-
var import_utils = require("./utils");
|
|
44
|
-
const MAX_SAFE_INTERVAL = 2147483647;
|
|
45
|
-
class StaticScheduleTrigger {
|
|
46
|
-
constructor(workflow) {
|
|
47
|
-
this.workflow = workflow;
|
|
48
|
-
workflow.app.on("afterStart", async () => {
|
|
49
|
-
const workflows = Array.from(this.workflow.enabledCache.values()).filter(
|
|
50
|
-
(item) => item.type === "schedule" && item.config.mode === import_utils.SCHEDULE_MODE.STATIC
|
|
51
|
-
);
|
|
52
|
-
this.inspect(workflows);
|
|
53
|
-
});
|
|
54
|
-
workflow.app.on("beforeStop", () => {
|
|
55
|
-
for (const timer of this.timers.values()) {
|
|
56
|
-
clearInterval(timer);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
timers = /* @__PURE__ */ new Map();
|
|
61
|
-
inspect(workflows) {
|
|
62
|
-
const now = /* @__PURE__ */ new Date();
|
|
63
|
-
workflows.forEach((workflow) => {
|
|
64
|
-
const nextTime = this.getNextTime(workflow, now);
|
|
65
|
-
if (nextTime) {
|
|
66
|
-
this.workflow.getLogger(workflow.id).info(`caching scheduled workflow will run at: ${new Date(nextTime).toISOString()}`);
|
|
67
|
-
} else {
|
|
68
|
-
this.workflow.getLogger(workflow.id).info("workflow will not be scheduled");
|
|
69
|
-
}
|
|
70
|
-
this.schedule(workflow, nextTime, nextTime >= now.getTime());
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
getNextTime({ config, allExecuted }, currentDate, nextSecond = false) {
|
|
74
|
-
if (config.limit && allExecuted >= config.limit) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
if (!config.startsOn) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
currentDate.setMilliseconds(nextSecond ? 1e3 : 0);
|
|
81
|
-
const timestamp = currentDate.getTime();
|
|
82
|
-
const startTime = (0, import_utils.parseDateWithoutMs)(config.startsOn);
|
|
83
|
-
if (startTime > timestamp) {
|
|
84
|
-
return startTime;
|
|
85
|
-
}
|
|
86
|
-
if (config.repeat) {
|
|
87
|
-
const endTime = config.endsOn ? (0, import_utils.parseDateWithoutMs)(config.endsOn) : null;
|
|
88
|
-
if (endTime && endTime < timestamp) {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
if (typeof config.repeat === "string") {
|
|
92
|
-
const interval = import_cron_parser.default.parseExpression(config.repeat, { currentDate });
|
|
93
|
-
const next = interval.next();
|
|
94
|
-
return next.getTime();
|
|
95
|
-
} else if (typeof config.repeat === "number") {
|
|
96
|
-
const next = timestamp + config.repeat - (timestamp - startTime) % config.repeat;
|
|
97
|
-
return next;
|
|
98
|
-
} else {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
} else {
|
|
102
|
-
if (startTime < timestamp) {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
return timestamp;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
schedule(workflow, nextTime, toggle = true) {
|
|
109
|
-
if (toggle) {
|
|
110
|
-
const key = `${workflow.id}@${nextTime}`;
|
|
111
|
-
if (!this.timers.has(key)) {
|
|
112
|
-
const interval = Math.max(nextTime - Date.now(), 0);
|
|
113
|
-
if (interval > MAX_SAFE_INTERVAL) {
|
|
114
|
-
this.timers.set(
|
|
115
|
-
key,
|
|
116
|
-
setTimeout(() => {
|
|
117
|
-
this.timers.delete(key);
|
|
118
|
-
this.schedule(workflow, nextTime);
|
|
119
|
-
}, MAX_SAFE_INTERVAL)
|
|
120
|
-
);
|
|
121
|
-
} else {
|
|
122
|
-
this.timers.set(key, setTimeout(this.trigger.bind(this, workflow, nextTime), interval));
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
} else {
|
|
126
|
-
for (const [key, timer] of this.timers.entries()) {
|
|
127
|
-
if (key.startsWith(`${workflow.id}@`)) {
|
|
128
|
-
clearTimeout(timer);
|
|
129
|
-
this.timers.delete(key);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
async trigger(workflow, time) {
|
|
135
|
-
const eventKey = `${workflow.id}@${time}`;
|
|
136
|
-
this.timers.delete(eventKey);
|
|
137
|
-
this.workflow.trigger(workflow, { date: new Date(time) }, { eventKey });
|
|
138
|
-
if (!workflow.config.repeat || workflow.config.limit && workflow.allExecuted >= workflow.config.limit - 1) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
const nextTime = this.getNextTime(workflow, /* @__PURE__ */ new Date(), true);
|
|
142
|
-
if (nextTime) {
|
|
143
|
-
this.schedule(workflow, nextTime);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
on(workflow) {
|
|
147
|
-
this.inspect([workflow]);
|
|
148
|
-
}
|
|
149
|
-
off(workflow) {
|
|
150
|
-
this.schedule(workflow, null, false);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import Trigger from '..';
|
|
10
|
-
import type Plugin from '../../Plugin';
|
|
11
|
-
export default class ScheduleTrigger extends Trigger {
|
|
12
|
-
sync: boolean;
|
|
13
|
-
private modes;
|
|
14
|
-
constructor(workflow: Plugin);
|
|
15
|
-
private getTrigger;
|
|
16
|
-
on(workflow: any): void;
|
|
17
|
-
off(workflow: any): void;
|
|
18
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
-
var ScheduleTrigger_exports = {};
|
|
38
|
-
__export(ScheduleTrigger_exports, {
|
|
39
|
-
default: () => ScheduleTrigger
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(ScheduleTrigger_exports);
|
|
42
|
-
var import__ = __toESM(require(".."));
|
|
43
|
-
var import_DateFieldScheduleTrigger = __toESM(require("./DateFieldScheduleTrigger"));
|
|
44
|
-
var import_StaticScheduleTrigger = __toESM(require("./StaticScheduleTrigger"));
|
|
45
|
-
var import_utils = require("./utils");
|
|
46
|
-
class ScheduleTrigger extends import__.default {
|
|
47
|
-
sync = false;
|
|
48
|
-
modes = /* @__PURE__ */ new Map();
|
|
49
|
-
constructor(workflow) {
|
|
50
|
-
super(workflow);
|
|
51
|
-
this.modes.set(import_utils.SCHEDULE_MODE.STATIC, new import_StaticScheduleTrigger.default(workflow));
|
|
52
|
-
this.modes.set(import_utils.SCHEDULE_MODE.DATE_FIELD, new import_DateFieldScheduleTrigger.default(workflow));
|
|
53
|
-
}
|
|
54
|
-
getTrigger(mode) {
|
|
55
|
-
return this.modes.get(mode);
|
|
56
|
-
}
|
|
57
|
-
on(workflow) {
|
|
58
|
-
const mode = workflow.config.mode;
|
|
59
|
-
const trigger = this.getTrigger(mode);
|
|
60
|
-
if (trigger) {
|
|
61
|
-
trigger.on(workflow);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
off(workflow) {
|
|
65
|
-
const mode = workflow.config.mode;
|
|
66
|
-
const trigger = this.getTrigger(mode);
|
|
67
|
-
if (trigger) {
|
|
68
|
-
trigger.off(workflow);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// async validateEvent(workflow: WorkflowModel, context: any, options: Transactionable): Promise<boolean> {
|
|
72
|
-
// if (!context.date) {
|
|
73
|
-
// return false;
|
|
74
|
-
// }
|
|
75
|
-
// const existed = await workflow.getExecutions({
|
|
76
|
-
// attributes: ['id'],
|
|
77
|
-
// where: {
|
|
78
|
-
// 'context.date': context.date instanceof Date ? context.date.toISOString() : context.date,
|
|
79
|
-
// },
|
|
80
|
-
// transaction: options.transaction,
|
|
81
|
-
// });
|
|
82
|
-
// return !existed.length;
|
|
83
|
-
// }
|
|
84
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
export declare const SCHEDULE_MODE: {
|
|
10
|
-
readonly STATIC: 0;
|
|
11
|
-
readonly DATE_FIELD: 1;
|
|
12
|
-
};
|
|
13
|
-
export declare function parseDateWithoutMs(date: string): number;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all)
|
|
16
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
-
var utils_exports = {};
|
|
28
|
-
__export(utils_exports, {
|
|
29
|
-
SCHEDULE_MODE: () => SCHEDULE_MODE,
|
|
30
|
-
parseDateWithoutMs: () => parseDateWithoutMs
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(utils_exports);
|
|
33
|
-
const SCHEDULE_MODE = {
|
|
34
|
-
STATIC: 0,
|
|
35
|
-
DATE_FIELD: 1
|
|
36
|
-
};
|
|
37
|
-
function parseDateWithoutMs(date) {
|
|
38
|
-
return Math.floor(Date.parse(date) / 1e3) * 1e3;
|
|
39
|
-
}
|
|
40
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
-
0 && (module.exports = {
|
|
42
|
-
SCHEDULE_MODE,
|
|
43
|
-
parseDateWithoutMs
|
|
44
|
-
});
|