@haiiro/docuflow 0.0.12 → 0.0.13
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/README.md +38 -8
- package/manifest.json +99 -13
- package/package.json +6 -3
- package/public/app/docflow-app.css +2 -0
- package/public/app/docflow-app.js +94 -0
- package/src/front-components/docflow-documents.front-component.mjs +3 -3
- package/src/front-components/docflow-processes.front-component.mjs +19 -19
- package/src/front-components/docflow-processes.front-component.tsx +18 -2
- package/src/front-components/docflow-tasks.front-component.mjs +3 -3
- package/src/front-components/launch-process.front-component.mjs +75 -0
- package/src/front-components/launch-process.front-component.tsx +270 -0
- package/src/front-components/process-steps.front-component.mjs +24 -24
- package/src/front-components/process-steps.front-component.tsx +54 -9
- package/src/front-components/task-form.front-component.mjs +21 -21
- package/src/logic-functions/bitrix-app.logic-function.mjs +160 -87
- package/src/logic-functions/bitrix-app.logic-function.ts +22 -59
- package/src/logic-functions/bitrix-install.logic-function.mjs +0 -11
- package/src/logic-functions/bitrix-install.logic-function.ts +0 -3
- package/src/logic-functions/docflow-app-session.logic-function.mjs +60043 -0
- package/src/logic-functions/docflow-app-session.logic-function.ts +54 -0
- package/src/logic-functions/docflow-app.logic-function.mjs +60122 -0
- package/src/logic-functions/docflow-app.logic-function.ts +37 -0
- package/src/logic-functions/launch-process.logic-function.mjs +113 -29
- package/src/logic-functions/launch-process.logic-function.ts +83 -22
- package/src/logic-functions/save-launch-fields.logic-function.mjs +176 -9
- package/src/logic-functions/save-launch-fields.logic-function.ts +24 -6
|
@@ -2,37 +2,55 @@ import { defineLogicFunction } from 'twenty-sdk/define';
|
|
|
2
2
|
import { type RoutePayload } from 'twenty-sdk/logic-function';
|
|
3
3
|
|
|
4
4
|
import { CoreGraphqlError } from 'src/shared/api/core-graphql.util';
|
|
5
|
+
import { listLaunchObjects } from 'src/shared/api/object-summaries';
|
|
5
6
|
import { readRestRecord } from 'src/shared/api/rest-response.util';
|
|
6
7
|
import { getFormFieldsError } from 'src/shared/form/form-fields.util';
|
|
7
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
getLaunchFieldsError,
|
|
10
|
+
parseLaunchFields,
|
|
11
|
+
parseLaunchObject,
|
|
12
|
+
} from 'src/shared/workflow/launch-step.util';
|
|
8
13
|
import { syncLaunchTrigger } from 'src/server/launch-step';
|
|
9
14
|
import { jsonResponse, readJsonBody } from 'src/server/http-response';
|
|
10
15
|
import { restClient } from 'src/server/records';
|
|
11
16
|
import { logDocflow, logDocflowError } from 'src/shared/log.util';
|
|
12
17
|
import { SAVE_LAUNCH_FIELDS_LOGIC_FUNCTION_UNIVERSAL_IDENTIFIER } from 'src/universal-identifiers';
|
|
13
18
|
|
|
14
|
-
// Saves the parameters of a process and
|
|
15
|
-
// "Запуск с параметрами" trigger, whose
|
|
19
|
+
// Saves the parameters of a process and the object it is launched on, and
|
|
20
|
+
// puts them into its draft as the "Запуск с параметрами" trigger, whose
|
|
21
|
+
// fields and record later steps read as variables.
|
|
16
22
|
const handler = async (event: RoutePayload) => {
|
|
17
23
|
const body = readJsonBody(event.body);
|
|
18
24
|
const workflowId = body.workflowId;
|
|
19
25
|
const fields = parseLaunchFields(body.fields);
|
|
26
|
+
const launchObjectName = parseLaunchObject(body.launchObject);
|
|
20
27
|
|
|
21
28
|
if (typeof workflowId !== 'string' || workflowId.length === 0 || !Array.isArray(body.fields)) {
|
|
22
29
|
return jsonResponse(400, { message: 'Не указан процесс или поля' });
|
|
23
30
|
}
|
|
24
31
|
|
|
25
|
-
const fieldsError =
|
|
32
|
+
const fieldsError =
|
|
33
|
+
getFormFieldsError(fields) ?? (launchObjectName !== undefined ? getLaunchFieldsError(fields) : undefined);
|
|
26
34
|
|
|
27
35
|
if (fieldsError !== undefined) {
|
|
28
36
|
return jsonResponse(422, { message: fieldsError });
|
|
29
37
|
}
|
|
30
38
|
|
|
39
|
+
const launchObject =
|
|
40
|
+
launchObjectName !== undefined
|
|
41
|
+
? (await listLaunchObjects()).find(({ nameSingular }) => nameSingular === launchObjectName)
|
|
42
|
+
: undefined;
|
|
43
|
+
|
|
44
|
+
if (launchObjectName !== undefined && launchObject === undefined) {
|
|
45
|
+
return jsonResponse(422, { message: `Объект «${launchObjectName}» не найден` });
|
|
46
|
+
}
|
|
47
|
+
|
|
31
48
|
// Written as the person: who may not change the process gets the refusal
|
|
32
49
|
// of the API, not a half-saved draft.
|
|
33
50
|
const workflow = readRestRecord<{ id: string }>(
|
|
34
51
|
await restClient('person').patch(`/rest/workflows/${workflowId}`, {
|
|
35
52
|
smbLaunchFields: fields.length > 0 ? fields : null,
|
|
53
|
+
smbLaunchObject: launchObject?.nameSingular ?? null,
|
|
36
54
|
}),
|
|
37
55
|
);
|
|
38
56
|
|
|
@@ -41,7 +59,7 @@ const handler = async (event: RoutePayload) => {
|
|
|
41
59
|
}
|
|
42
60
|
|
|
43
61
|
try {
|
|
44
|
-
const result = await syncLaunchTrigger({ workflowId, fields });
|
|
62
|
+
const result = await syncLaunchTrigger({ workflowId, fields, launchObject });
|
|
45
63
|
|
|
46
64
|
logDocflow('launch fields: draft synced', { workflowId, result });
|
|
47
65
|
|
|
@@ -67,7 +85,7 @@ const handler = async (event: RoutePayload) => {
|
|
|
67
85
|
export default defineLogicFunction({
|
|
68
86
|
universalIdentifier: SAVE_LAUNCH_FIELDS_LOGIC_FUNCTION_UNIVERSAL_IDENTIFIER,
|
|
69
87
|
name: 'docflow-save-launch-fields',
|
|
70
|
-
description: 'Сохраняет параметры запуска и делает первым блоком процесса «Запуск с параметрами»',
|
|
88
|
+
description: 'Сохраняет параметры и объект запуска и делает первым блоком процесса «Запуск с параметрами»',
|
|
71
89
|
timeoutSeconds: 30,
|
|
72
90
|
handler,
|
|
73
91
|
httpRouteTriggerSettings: {
|