deploy-webapp 1.0.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/README.md +338 -0
- package/dist/0.1_migrator.js +101 -0
- package/dist/0_index.js +16 -0
- package/dist/apis/prod-client.js +242 -0
- package/dist/apis/qa-client.js +88 -0
- package/dist/functions/1.1_workflow_group.js +47 -0
- package/dist/functions/1.2_workflow_group_item.js +33 -0
- package/dist/functions/1_workflow.js +39 -0
- package/dist/functions/2.1.1_workflow_forms.js +41 -0
- package/dist/functions/2.1_workflow_step_forms.js +32 -0
- package/dist/functions/2_workflow_step.js +40 -0
- package/dist/functions/3_client_function.js +31 -0
- package/dist/functions/4_workflow_form_groups.js +37 -0
- package/dist/utils/constants.js +118 -0
- package/dist/utils/data-processing.js +42 -0
- package/dist/utils/replace-utils.js +24 -0
- package/dist/utils/types.js +2 -0
- package/package.json +33 -0
- package/src/utils/ids.csv +3 -0
- package/src/utils/updateWorkflow.json +4 -0
- package/src/utils/updateWorkflowFrotas.json +4 -0
- package/src/utils/updateWorkflowOuvidoria.json +4 -0
- package/src/utils/updateWorkflowParceiros.json +4 -0
- package/src/utils/updateWorkflowVida.json +4 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.publishWorkflowPROD = exports.deletePROD = exports.updatePROD = exports.createPROD = exports.getPROD = exports.loginPROD = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const console_1 = require("console");
|
|
9
|
+
const constants_1 = require("../utils/constants");
|
|
10
|
+
const data_processing_1 = require("../utils/data-processing");
|
|
11
|
+
const replace_utils_1 = require("../utils/replace-utils");
|
|
12
|
+
const loginPROD = async (client, Service_key, emailLogin, passwordLogin) => {
|
|
13
|
+
var _a, _b, _c, _d;
|
|
14
|
+
try {
|
|
15
|
+
let { data: loginData } = await axios_1.default.post(`${constants_1.urlPROD}/${client}/${Service_key}/authentication/access-session/password`, {
|
|
16
|
+
"login": emailLogin,
|
|
17
|
+
"password": passwordLogin
|
|
18
|
+
}, {
|
|
19
|
+
headers: {
|
|
20
|
+
"Content-Type": "application/json",
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
(0, console_1.log)(`${constants_1.cor.Green}Login in PROD Success${constants_1.cor.Reset}`);
|
|
24
|
+
return loginData.access_token;
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
(0, console_1.log)(`${constants_1.cor.Red}Login in PROD Error: ${((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.error)}${constants_1.cor.Reset}`);
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.loginPROD = loginPROD;
|
|
32
|
+
const getPROD = async (access_token, data, client, Service_key, params, type, id) => {
|
|
33
|
+
var _a, _b, _c, _d;
|
|
34
|
+
try {
|
|
35
|
+
let { data } = await axios_1.default.get(`${constants_1.urlPROD}/${client}/${Service_key}/${params}`, {
|
|
36
|
+
headers: {
|
|
37
|
+
Authorization: `Bearer ${access_token}`,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
if (type === "workflow-form" && data === "") {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
(0, data_processing_1.deleteKeys)(data, [
|
|
44
|
+
"created_at",
|
|
45
|
+
"updated_at",
|
|
46
|
+
"deleted_at",
|
|
47
|
+
"customer_view_form_id",
|
|
48
|
+
"sla",
|
|
49
|
+
"client_service",
|
|
50
|
+
"workflow_group_item",
|
|
51
|
+
"client_service",
|
|
52
|
+
"icon_id",
|
|
53
|
+
"icon",
|
|
54
|
+
"max_responses",
|
|
55
|
+
"workflow_group",
|
|
56
|
+
"workflow",
|
|
57
|
+
"format_payload_function"
|
|
58
|
+
]);
|
|
59
|
+
data = (0, replace_utils_1.replaceStringsRecursively)(data, constants_1.replacementRules);
|
|
60
|
+
(0, console_1.log)(`${constants_1.cor.Yellow}Get ${type} ${id} in PROD Success${constants_1.cor.Reset}`);
|
|
61
|
+
if (!data) {
|
|
62
|
+
throw {
|
|
63
|
+
status: 404,
|
|
64
|
+
error: "Data not found",
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return data;
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
(0, console_1.log)(`${constants_1.cor.Red}Get ${type} ${id} in PROD Error: ${((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.error)}${constants_1.cor.Reset}`);
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
exports.getPROD = getPROD;
|
|
75
|
+
const createPROD = async (access_token, data, client, Service_key, params, type, id, jsonData) => {
|
|
76
|
+
var _a, _b, _c;
|
|
77
|
+
try {
|
|
78
|
+
let payload;
|
|
79
|
+
if (type === "workflow-form") {
|
|
80
|
+
payload = (0, data_processing_1.sanitizeWorkflowFormData)(data);
|
|
81
|
+
// payload.client = client;
|
|
82
|
+
if (payload.title == null || (typeof payload.title === "string" && payload.title.trim().length === 0)) {
|
|
83
|
+
payload.title = " ";
|
|
84
|
+
}
|
|
85
|
+
if (payload.description == null || (typeof payload.description === "string" && payload.description.trim().length === 0)) {
|
|
86
|
+
payload.description = " ";
|
|
87
|
+
}
|
|
88
|
+
if (payload.placeholder == null || (typeof payload.placeholder === "string" && payload.placeholder.trim().length === 0)) {
|
|
89
|
+
payload.placeholder = " ";
|
|
90
|
+
}
|
|
91
|
+
if (payload.required == null || payload.required === undefined || !payload.required) {
|
|
92
|
+
payload.required = false;
|
|
93
|
+
}
|
|
94
|
+
if (payload.index == null || payload.index === undefined) {
|
|
95
|
+
payload.index = 1;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else if (type === "update-workflow-protocol-function") {
|
|
99
|
+
data.function = jsonData.updateWorkflowProtocolFunction || data.function;
|
|
100
|
+
payload = data;
|
|
101
|
+
}
|
|
102
|
+
else if (type === "workflow") {
|
|
103
|
+
data.flow_form_id = jsonData.flow_form_id || data.flow_form_id;
|
|
104
|
+
data.pendency_custom_filters = jsonData.pendency_custom_filters || data.pendency_custom_filters;
|
|
105
|
+
data.client_service_id = data.client_service_id;
|
|
106
|
+
payload = data;
|
|
107
|
+
}
|
|
108
|
+
else if (type === "workflow-step-form") {
|
|
109
|
+
if (data.has_next_workflow_form === null || data.has_previous_workflow_form === null) {
|
|
110
|
+
data.has_next_workflow_form = false;
|
|
111
|
+
}
|
|
112
|
+
payload = data;
|
|
113
|
+
}
|
|
114
|
+
else if (type === "workflow-step") {
|
|
115
|
+
payload = data;
|
|
116
|
+
if (payload.description == null || (typeof payload.description === "string" && payload.description.trim().length === 0)) {
|
|
117
|
+
payload.description = " ";
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
payload = data;
|
|
122
|
+
}
|
|
123
|
+
payload = (0, replace_utils_1.replaceStringsRecursively)(payload, constants_1.replacementRules);
|
|
124
|
+
let { data: createData } = await axios_1.default.post(`${constants_1.urlPROD}/${client}/${Service_key}/${params}`, payload, {
|
|
125
|
+
headers: {
|
|
126
|
+
Authorization: `Bearer ${access_token}`,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
(0, console_1.log)(`${constants_1.cor.Cyan}Created ${type} ${id} in PROD Success${constants_1.cor.Reset}`);
|
|
130
|
+
(0, constants_1.addIdsCreated)(id, type);
|
|
131
|
+
return createData;
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
(0, console_1.log)(`${constants_1.cor.Red}Created ${type} ${id} in PROD Error: ${JSON.stringify(((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || ((_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error) || error.message || error.stack || error)}${constants_1.cor.Reset}`);
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
exports.createPROD = createPROD;
|
|
139
|
+
const updatePROD = async (access_token, data, client, Service_key, params, type, id, jsonData) => {
|
|
140
|
+
var _a, _b, _c;
|
|
141
|
+
try {
|
|
142
|
+
if (!(0, constants_1.checkIdUpdated)(id)) {
|
|
143
|
+
let payload;
|
|
144
|
+
if (type === "workflow-form") {
|
|
145
|
+
payload = (0, data_processing_1.sanitizeWorkflowFormData)(data);
|
|
146
|
+
// payload.client = client;
|
|
147
|
+
if (payload.title == null || (typeof payload.title === "string" && payload.title.trim().length === 0)) {
|
|
148
|
+
payload.title = " ";
|
|
149
|
+
}
|
|
150
|
+
if (payload.description == null || (typeof payload.description === "string" && payload.description.trim().length === 0)) {
|
|
151
|
+
payload.description = " ";
|
|
152
|
+
}
|
|
153
|
+
if (payload.placeholder == null || (typeof payload.placeholder === "string" && payload.placeholder.trim().length === 0)) {
|
|
154
|
+
payload.placeholder = " ";
|
|
155
|
+
}
|
|
156
|
+
if (payload.required == null || payload.required === undefined || !payload.required) {
|
|
157
|
+
payload.required = false;
|
|
158
|
+
}
|
|
159
|
+
if (payload.index == null || payload.index === undefined) {
|
|
160
|
+
payload.index = 1;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else if (type === "update-workflow-protocol-function") {
|
|
164
|
+
data.function = jsonData.updateWorkflowProtocolFunction;
|
|
165
|
+
payload = data;
|
|
166
|
+
}
|
|
167
|
+
else if (type === "workflow") {
|
|
168
|
+
data.flow_form_id = jsonData.flow_form_id || data.flow_form_id;
|
|
169
|
+
data.pendency_custom_filters = jsonData.pendency_custom_filters || data.pendency_custom_filters;
|
|
170
|
+
data.client_service_id = data.client_service_id;
|
|
171
|
+
payload = data;
|
|
172
|
+
}
|
|
173
|
+
else if (type === "workflow-step-form") {
|
|
174
|
+
if (data.has_next_workflow_form === null || data.has_previous_workflow_form === null) {
|
|
175
|
+
data.has_next_workflow_form = false;
|
|
176
|
+
}
|
|
177
|
+
payload = data;
|
|
178
|
+
}
|
|
179
|
+
else if (type === "workflow-step") {
|
|
180
|
+
payload = data;
|
|
181
|
+
if (payload.description == null || (typeof payload.description === "string" && payload.description.trim().length === 0)) {
|
|
182
|
+
payload.description = " ";
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
payload = data;
|
|
187
|
+
}
|
|
188
|
+
let { data: updateData } = await axios_1.default.put(`${constants_1.urlPROD}/${client}/${Service_key}/${params}`, payload, {
|
|
189
|
+
headers: {
|
|
190
|
+
Authorization: `Bearer ${access_token}`,
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
payload = (0, replace_utils_1.replaceStringsRecursively)(payload, constants_1.replacementRules);
|
|
194
|
+
(0, console_1.log)(`${constants_1.cor.Green}Updated ${type} ${id} in PROD Success${constants_1.cor.Reset}`);
|
|
195
|
+
(0, constants_1.addIdUpdated)(id, type);
|
|
196
|
+
return updateData;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
(0, console_1.log)(`${constants_1.cor.Red}Update ${type} ${id} in PROD Error: ${JSON.stringify(((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || ((_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error) || error.message || error.stack || error)}${constants_1.cor.Reset}`);
|
|
201
|
+
if ((error === null || error === void 0 ? void 0 : error.status) === 404) {
|
|
202
|
+
(0, exports.createPROD)(access_token, data, client, Service_key, params, type, id, data);
|
|
203
|
+
}
|
|
204
|
+
throw error;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
exports.updatePROD = updatePROD;
|
|
208
|
+
const deletePROD = async (access_token, data, client, Service_key, params, type, id) => {
|
|
209
|
+
var _a, _b, _c, _d;
|
|
210
|
+
try {
|
|
211
|
+
await axios_1.default.delete(`${constants_1.urlPROD}/${client}/${Service_key}/${params}`, {
|
|
212
|
+
headers: {
|
|
213
|
+
Authorization: `Bearer ${access_token}`,
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
(0, console_1.log)(`${constants_1.cor.Red}Deleted${constants_1.cor.Reset} ${constants_1.cor.Green} ${type} ${id} in PROD Success${constants_1.cor.Reset}`);
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
(0, console_1.log)(`${constants_1.cor.Red}Delete Workflow Form Group ${id} in PROD Error: ${((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.error)}${constants_1.cor.Reset}`);
|
|
220
|
+
throw error;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
exports.deletePROD = deletePROD;
|
|
224
|
+
const publishWorkflowPROD = async (access_token, id, client, Service_key, params, type) => {
|
|
225
|
+
var _a, _b, _c, _d;
|
|
226
|
+
try {
|
|
227
|
+
await axios_1.default.post(`${constants_1.urlPROD}/${client}/${Service_key}/${params}/publish`, {
|
|
228
|
+
commentary: "Publicação de esteira"
|
|
229
|
+
}, {
|
|
230
|
+
headers: {
|
|
231
|
+
Authorization: `Bearer ${access_token}`,
|
|
232
|
+
"Content-Type": "application/json",
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
(0, console_1.log)(`${constants_1.cor.Orange}Publish ${type} ${id} in PROD Success${constants_1.cor.Reset}`);
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
(0, console_1.log)(`${constants_1.cor.Red}Publish ${type} ${id} in PROD Error: ${((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.error)}${constants_1.cor.Reset}`);
|
|
239
|
+
throw error;
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
exports.publishWorkflowPROD = publishWorkflowPROD;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.publishWorkflowQA = exports.getQA = exports.loginQA = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const console_1 = require("console");
|
|
9
|
+
const constants_1 = require("../utils/constants");
|
|
10
|
+
const data_processing_1 = require("../utils/data-processing");
|
|
11
|
+
const replace_utils_1 = require("../utils/replace-utils");
|
|
12
|
+
const loginQA = async (client, Service_key, emailLogin, passwordLogin) => {
|
|
13
|
+
var _a, _b, _c, _d;
|
|
14
|
+
try {
|
|
15
|
+
let { data: loginData } = await axios_1.default.post(`${constants_1.urlQA}/${client}/${Service_key}/authentication/access-session/password`, {
|
|
16
|
+
"login": emailLogin,
|
|
17
|
+
"password": passwordLogin
|
|
18
|
+
}, {
|
|
19
|
+
headers: {
|
|
20
|
+
"Content-Type": "application/json",
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
(0, console_1.log)(`${constants_1.cor.Green}Login in QA Success${constants_1.cor.Reset}`);
|
|
24
|
+
return loginData.access_token;
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
(0, console_1.log)(`${constants_1.cor.Red}Login in QA Error: ${((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.error)}${constants_1.cor.Reset}`);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.loginQA = loginQA;
|
|
32
|
+
const getQA = async (access_token, data, client, Service_key, params, type, id) => {
|
|
33
|
+
var _a, _b, _c, _d;
|
|
34
|
+
try {
|
|
35
|
+
let { data } = await axios_1.default.get(`${constants_1.urlQA}/${client}/${Service_key}/${params}`, {
|
|
36
|
+
headers: {
|
|
37
|
+
Authorization: `Bearer ${access_token}`,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
(0, data_processing_1.deleteKeys)(data, [
|
|
41
|
+
"created_at",
|
|
42
|
+
"updated_at",
|
|
43
|
+
"deleted_at",
|
|
44
|
+
"customer_view_form_id",
|
|
45
|
+
"sla",
|
|
46
|
+
"client_service",
|
|
47
|
+
"client_service",
|
|
48
|
+
"icon_id",
|
|
49
|
+
"icon",
|
|
50
|
+
"max_responses",
|
|
51
|
+
"workflow_group",
|
|
52
|
+
"workflow",
|
|
53
|
+
"workflow_form",
|
|
54
|
+
"default_workflow_form",
|
|
55
|
+
"format_payload_function"
|
|
56
|
+
]);
|
|
57
|
+
data = (0, replace_utils_1.replaceStringsRecursively)(data, constants_1.replacementRules);
|
|
58
|
+
if (data.filters === null) {
|
|
59
|
+
data.filters = {};
|
|
60
|
+
}
|
|
61
|
+
(0, console_1.log)(`${constants_1.cor.White}Get ${type} ${id} in QA Success${constants_1.cor.Reset}`);
|
|
62
|
+
return data;
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
(0, console_1.log)(`${constants_1.cor.Red}Get ${type} ${id} in QA Error: ${((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.error)}${constants_1.cor.Reset}`);
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
exports.getQA = getQA;
|
|
70
|
+
const publishWorkflowQA = async (access_token, id, client, Service_key, params, type) => {
|
|
71
|
+
var _a, _b, _c, _d;
|
|
72
|
+
try {
|
|
73
|
+
await axios_1.default.post(`${constants_1.urlQA}/${client}/${Service_key}/${params}/publish`, {
|
|
74
|
+
commentary: "Publicação de esteira"
|
|
75
|
+
}, {
|
|
76
|
+
headers: {
|
|
77
|
+
Authorization: `Bearer ${access_token}`,
|
|
78
|
+
"Content-Type": "application/json",
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
(0, console_1.log)(`${constants_1.cor.Purple}Publish ${type} ${id} in QA Success${constants_1.cor.Reset}`);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
(0, console_1.log)(`${constants_1.cor.Red}Publish ${type} ${id} in QA Error: ${((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.error)}${constants_1.cor.Reset}`);
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
exports.publishWorkflowQA = publishWorkflowQA;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkflowGroup = WorkflowGroup;
|
|
4
|
+
const console_1 = require("console");
|
|
5
|
+
const prod_client_1 = require("../apis/prod-client");
|
|
6
|
+
const qa_client_1 = require("../apis/qa-client");
|
|
7
|
+
const constants_1 = require("../utils/constants");
|
|
8
|
+
async function WorkflowGroup(groupId, access_token_qa, access_token_prod, client, serviceKey, workflow_id, updateWorkflowData, workflowProd, workflow) {
|
|
9
|
+
var _a;
|
|
10
|
+
if (groupId && client && serviceKey && workflow_id) {
|
|
11
|
+
const workflowGroup = await (0, qa_client_1.getQA)(access_token_qa, undefined, client, serviceKey, `techforms/workflow-group/${groupId}`, "workflow-group", groupId);
|
|
12
|
+
//////////////////////// WORKFLOW-GROUP ////////////////////////
|
|
13
|
+
let groupExistsInProd = true;
|
|
14
|
+
try {
|
|
15
|
+
await (0, prod_client_1.getPROD)(access_token_prod, undefined, client, serviceKey, `techforms/workflow-group/${groupId}`, "workflow-group", groupId);
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
if (((_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
19
|
+
groupExistsInProd = false;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
throw err;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (groupExistsInProd) {
|
|
26
|
+
await (0, prod_client_1.updatePROD)(access_token_prod, workflowGroup, client, serviceKey, `techforms/workflow-group/${groupId}`, "workflow-group", groupId, updateWorkflowData);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
await (0, prod_client_1.createPROD)(access_token_prod, workflowGroup, client, serviceKey, `techforms/workflow-group/${groupId}`, "workflow-group", groupId, updateWorkflowData);
|
|
30
|
+
if (workflowProd) {
|
|
31
|
+
await (0, prod_client_1.updatePROD)(access_token_prod, workflow, client, serviceKey, `techforms/workflow/${workflow_id}`, "workflow", workflow_id, updateWorkflowData);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
await (0, prod_client_1.createPROD)(access_token_prod, workflow, client, serviceKey, `techforms/workflow/${workflow_id}`, "workflow", workflow_id, updateWorkflowData);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
if (workflowProd) {
|
|
40
|
+
await (0, prod_client_1.updatePROD)(access_token_prod, workflow, client, serviceKey, `techforms/workflow/${workflow_id}`, "workflow", workflow_id, updateWorkflowData);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
await (0, prod_client_1.createPROD)(access_token_prod, workflow, client, serviceKey, `techforms/workflow/${workflow_id}`, "workflow", workflow_id, updateWorkflowData);
|
|
44
|
+
}
|
|
45
|
+
(0, console_1.log)(`${constants_1.cor.Blue}Not exists workflow_group_id in workflow ${workflow_id} ${constants_1.cor.Reset}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkflowGroupItem = WorkflowGroupItem;
|
|
4
|
+
const qa_client_1 = require("../apis/qa-client");
|
|
5
|
+
const prod_client_1 = require("../apis/prod-client");
|
|
6
|
+
async function WorkflowGroupItem(workflowGroupItems, access_token_qa, access_token_prod, client, serviceKey, workflow_id, updateWorkflowData) {
|
|
7
|
+
var _a;
|
|
8
|
+
if (workflowGroupItems.length > 0 && client && serviceKey && workflow_id) {
|
|
9
|
+
//////////////////////// WORKFLOW-GROUP-ITEM ////////////////////////
|
|
10
|
+
for (const groupItem of workflowGroupItems) {
|
|
11
|
+
const groupItemData = await (0, qa_client_1.getQA)(access_token_qa, undefined, client, serviceKey, `techforms/workflow-group/${workflow_id}/workflow-group-item/${groupItem.id}`, "workflow-group-item", groupItem.id);
|
|
12
|
+
const groupId = groupItem.workflow_group_id;
|
|
13
|
+
let existsInProd = true;
|
|
14
|
+
try {
|
|
15
|
+
await (0, prod_client_1.getPROD)(access_token_prod, undefined, client, serviceKey, `techforms/workflow-group/${workflow_id}/workflow-group-item/${groupItem.id}`, "workflow-group-item", groupItem.id);
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
if (((_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
19
|
+
existsInProd = false;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
throw err;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (existsInProd) {
|
|
26
|
+
await (0, prod_client_1.updatePROD)(access_token_prod, groupItemData, client, serviceKey, `techforms/workflow-group/${groupId}/workflow-group-item/${groupItem.id}`, "workflow-group-item", groupItem.id, updateWorkflowData);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
await (0, prod_client_1.createPROD)(access_token_prod, groupItemData, client, serviceKey, `techforms/workflow-group/${groupId}/workflow-group-item/${groupItem.id}`, "workflow-group-item", groupItem.id, updateWorkflowData);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Workflow = Workflow;
|
|
4
|
+
const prod_client_1 = require("../apis/prod-client");
|
|
5
|
+
const _1_1_workflow_group_1 = require("./1.1_workflow_group");
|
|
6
|
+
const _1_2_workflow_group_item_1 = require("./1.2_workflow_group_item");
|
|
7
|
+
async function Workflow(access_token_qa, access_token_prod, workflow, client, serviceKey, id, updateWorkflowData) {
|
|
8
|
+
var _a;
|
|
9
|
+
if (workflow && client && serviceKey) {
|
|
10
|
+
//////////////////////// WORKFLOW ////////////////////////
|
|
11
|
+
let workflowProd = true;
|
|
12
|
+
try {
|
|
13
|
+
await (0, prod_client_1.getPROD)(access_token_prod, undefined, client, serviceKey, `techforms/workflow/${id}`, "workflow", id);
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
if (((_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
17
|
+
workflowProd = false;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
throw err;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (workflowProd) {
|
|
24
|
+
await (0, prod_client_1.updatePROD)(access_token_prod, workflow, client, serviceKey, `techforms/workflow/${id}`, "workflow", id, updateWorkflowData);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
await (0, prod_client_1.createPROD)(access_token_prod, workflow, client, serviceKey, `techforms/workflow/${id}`, "workflow", id, updateWorkflowData);
|
|
28
|
+
}
|
|
29
|
+
//////////////////////// WORKFLOW-GROUP ////////////////////////
|
|
30
|
+
const groupId = workflow.workflow_group_id;
|
|
31
|
+
if (groupId) {
|
|
32
|
+
await (0, _1_1_workflow_group_1.WorkflowGroup)(groupId, access_token_qa, access_token_prod, client, serviceKey, id, updateWorkflowData, workflowProd, workflow);
|
|
33
|
+
}
|
|
34
|
+
const workflowGroupItems = workflow.workflow_group_item || [];
|
|
35
|
+
if (workflowGroupItems.length > 0) {
|
|
36
|
+
await (0, _1_2_workflow_group_item_1.WorkflowGroupItem)(workflowGroupItems, access_token_qa, access_token_prod, client, serviceKey, id, updateWorkflowData);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkflowForms = WorkflowForms;
|
|
4
|
+
const prod_client_1 = require("../apis/prod-client");
|
|
5
|
+
const qa_client_1 = require("../apis/qa-client");
|
|
6
|
+
const _3_client_function_1 = require("./3_client_function");
|
|
7
|
+
async function WorkflowForms(workflowForm, access_token_qa, access_token_prod, client, serviceKey, workflow_id, updateWorkflowData) {
|
|
8
|
+
var _a;
|
|
9
|
+
//////////////////////// WORKFLOW FORMS ////////////////////////
|
|
10
|
+
// Sempre faz GET em QA primeiro para garantir a sequência correta
|
|
11
|
+
const workflowFormId = workflowForm === null || workflowForm === void 0 ? void 0 : workflowForm.id;
|
|
12
|
+
if (!workflowFormId) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const workflowFormData = await (0, qa_client_1.getQA)(access_token_qa, undefined, client, serviceKey, `techforms/workflow-form/${workflowFormId}`, "workflow-form", workflowFormId);
|
|
16
|
+
// Depois faz GET em PROD para verificar se existe
|
|
17
|
+
let workflowFormExistsInProd = true;
|
|
18
|
+
try {
|
|
19
|
+
await (0, prod_client_1.getPROD)(access_token_prod, undefined, client, serviceKey, `techforms/workflow-form/${workflowFormId}`, "workflow-form", workflowFormId);
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
if (((_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
23
|
+
workflowFormExistsInProd = false;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
throw err;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Finalmente faz CREATE ou UPDATE em PROD
|
|
30
|
+
if (workflowFormExistsInProd) {
|
|
31
|
+
await (0, prod_client_1.updatePROD)(access_token_prod, workflowFormData, client, serviceKey, `techforms/workflow-form/${workflowFormId}`, "workflow-form", workflowFormId, updateWorkflowData);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
await (0, prod_client_1.createPROD)(access_token_prod, workflowFormData, client, serviceKey, `techforms/workflow-form/${workflowFormId}`, "workflow-form", workflowFormId, updateWorkflowData);
|
|
35
|
+
}
|
|
36
|
+
//////////////////////// CLIENT FUNCTION ////////////////////////
|
|
37
|
+
const formatPayloadFunctionId = workflowFormData === null || workflowFormData === void 0 ? void 0 : workflowFormData.format_payload_function_id;
|
|
38
|
+
if (formatPayloadFunctionId) {
|
|
39
|
+
await (0, _3_client_function_1.ClientFunction)(formatPayloadFunctionId, access_token_qa, access_token_prod, client, serviceKey, updateWorkflowData);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkflowStepForms = WorkflowStepForms;
|
|
4
|
+
const prod_client_1 = require("../apis/prod-client");
|
|
5
|
+
const _2_1_1_workflow_forms_1 = require("./2.1.1_workflow_forms");
|
|
6
|
+
async function WorkflowStepForms(workflowStepFormData, access_token_qa, access_token_prod, client, serviceKey, workflow_id, step_id, updateWorkflowData) {
|
|
7
|
+
var _a;
|
|
8
|
+
//////////////////////// WORKFLOW STEPS FORMS ////////////////////////
|
|
9
|
+
let workflowStepFormExistsInProd = true;
|
|
10
|
+
//////////////////////// WORKFLOW FORMS ////////////////////////
|
|
11
|
+
const workflowFormId = workflowStepFormData === null || workflowStepFormData === void 0 ? void 0 : workflowStepFormData.workflow_form_id;
|
|
12
|
+
if (workflowFormId) {
|
|
13
|
+
await (0, _2_1_1_workflow_forms_1.WorkflowForms)({ id: workflowFormId }, access_token_qa, access_token_prod, client, serviceKey, workflow_id, updateWorkflowData);
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
await (0, prod_client_1.getPROD)(access_token_prod, undefined, client, serviceKey, `techforms/workflow/${workflow_id}/workflow-step/${step_id}/workflow-step-form/${workflowStepFormData.id}`, "workflow-step-form", workflowStepFormData.id);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
if (((_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
20
|
+
workflowStepFormExistsInProd = false;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (workflowStepFormExistsInProd) {
|
|
27
|
+
await (0, prod_client_1.updatePROD)(access_token_prod, workflowStepFormData, client, serviceKey, `techforms/workflow/${workflow_id}/workflow-step/${step_id}/workflow-step-form/${workflowStepFormData.id}`, "workflow-step-form", workflowStepFormData.id, updateWorkflowData);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
await (0, prod_client_1.createPROD)(access_token_prod, workflowStepFormData, client, serviceKey, `techforms/workflow/${workflow_id}/workflow-step/${step_id}/workflow-step-form`, "workflow-step-form", workflowStepFormData.id, updateWorkflowData);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkflowSteps = WorkflowSteps;
|
|
4
|
+
const prod_client_1 = require("../apis/prod-client");
|
|
5
|
+
const qa_client_1 = require("../apis/qa-client");
|
|
6
|
+
const _2_1_workflow_step_forms_1 = require("./2.1_workflow_step_forms");
|
|
7
|
+
async function WorkflowSteps(workflowSteps, access_token_qa, access_token_prod, client, serviceKey, workflow_id, step_id, updateWorkflowData) {
|
|
8
|
+
var _a;
|
|
9
|
+
if (workflowSteps) {
|
|
10
|
+
// console.log(workflowSteps.map((step: any) => step.id));
|
|
11
|
+
for (const step of workflowSteps) {
|
|
12
|
+
//////////////////////// WORKFLOW STEPS ////////////////////////
|
|
13
|
+
const workflowStepData = await (0, qa_client_1.getQA)(access_token_qa, undefined, client, serviceKey, `techforms/workflow/${workflow_id}/workflow-step/${step.id}`, "workflow-step", step.id);
|
|
14
|
+
let workflowStepExistsInProd = true;
|
|
15
|
+
try {
|
|
16
|
+
await (0, prod_client_1.getPROD)(access_token_prod, undefined, client, serviceKey, `techforms/workflow/${workflow_id}/workflow-step/${step.id}`, "workflow-step", step.id);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
if (((_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
20
|
+
workflowStepExistsInProd = false;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (workflowStepExistsInProd) {
|
|
27
|
+
await (0, prod_client_1.updatePROD)(access_token_prod, workflowStepData, client, serviceKey, `techforms/workflow/${workflow_id}/workflow-step/${step.id}`, "workflow-step", step.id, updateWorkflowData);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
await (0, prod_client_1.createPROD)(access_token_prod, workflowStepData, client, serviceKey, `techforms/workflow/${workflow_id}/workflow-step/${step.id}`, "workflow-step", step.id, updateWorkflowData);
|
|
31
|
+
}
|
|
32
|
+
//////////////////////// WORKFLOW STEPS FORMS ////////////////////////
|
|
33
|
+
const workflowStepsForms = workflowStepData === null || workflowStepData === void 0 ? void 0 : workflowStepData.workflow_step_forms;
|
|
34
|
+
for (const stepForm of workflowStepsForms) {
|
|
35
|
+
const workflowStepFormData = await (0, qa_client_1.getQA)(access_token_qa, undefined, client, serviceKey, `techforms/workflow/${workflow_id}/workflow-step/${step.id}/workflow-step-form/${stepForm.id}`, "workflow-step-form", stepForm.id);
|
|
36
|
+
await (0, _2_1_workflow_step_forms_1.WorkflowStepForms)(workflowStepFormData, access_token_qa, access_token_prod, client, serviceKey, workflow_id, step.id, updateWorkflowData);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientFunction = ClientFunction;
|
|
4
|
+
const prod_client_1 = require("../apis/prod-client");
|
|
5
|
+
const qa_client_1 = require("../apis/qa-client");
|
|
6
|
+
const constants_1 = require("../utils/constants");
|
|
7
|
+
async function ClientFunction(function_id, access_token_qa, access_token_prod, client, serviceKey, updateWorkflowData) {
|
|
8
|
+
var _a;
|
|
9
|
+
if (function_id && client && serviceKey) {
|
|
10
|
+
//////////////////////// CLIENT FUNCTION ////////////////////////
|
|
11
|
+
const update_workflow_protocol_functionData = await (0, qa_client_1.getQA)(access_token_qa, undefined, client, serviceKey, `client/${constants_1.clientIdQA}/client-function/${function_id}`, "update-workflow-protocol-function", function_id);
|
|
12
|
+
let protocolFunctionExistsInProd = true;
|
|
13
|
+
try {
|
|
14
|
+
await (0, prod_client_1.getPROD)(access_token_prod, update_workflow_protocol_functionData, client, serviceKey, `client/${constants_1.clientIdPROD}/client-function/${function_id}`, "update-workflow-protocol-function", function_id);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
if (((_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
18
|
+
protocolFunctionExistsInProd = false;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (protocolFunctionExistsInProd) {
|
|
25
|
+
await (0, prod_client_1.updatePROD)(access_token_prod, update_workflow_protocol_functionData, client, serviceKey, `client/${constants_1.clientIdPROD}/client-function/${function_id}`, "update-workflow-protocol-function", function_id, updateWorkflowData);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
await (0, prod_client_1.createPROD)(access_token_prod, update_workflow_protocol_functionData, client, serviceKey, `client/${constants_1.clientIdPROD}/client-function/${function_id}`, "update-workflow-protocol-function", function_id, updateWorkflowData);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkflowFormGroups = WorkflowFormGroups;
|
|
4
|
+
const prod_client_1 = require("../apis/prod-client");
|
|
5
|
+
const qa_client_1 = require("../apis/qa-client");
|
|
6
|
+
const _2_1_1_workflow_forms_1 = require("./2.1.1_workflow_forms");
|
|
7
|
+
async function WorkflowFormGroups(workflowFormGroupQA, access_token_qa, access_token_prod, client, serviceKey, workflow_id, updateWorkflowData) {
|
|
8
|
+
var _a;
|
|
9
|
+
if (workflowFormGroupQA.length > 0 && client && serviceKey && workflow_id) {
|
|
10
|
+
for (const formGroup of workflowFormGroupQA) {
|
|
11
|
+
const workflowFormGroupData = await (0, qa_client_1.getQA)(access_token_qa, undefined, client, serviceKey, `techforms/workflow/${workflow_id}/workflow-form/null/workflow-form-group/${formGroup.id}`, "workflow-form-group", formGroup.id);
|
|
12
|
+
let workflowFormGroupExistsInProd = true;
|
|
13
|
+
try {
|
|
14
|
+
await (0, prod_client_1.getPROD)(access_token_prod, undefined, client, serviceKey, `techforms/workflow/${workflow_id}/workflow-form/null/workflow-form-group/${formGroup.id}`, "workflow-form-group", formGroup.id);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
if (((_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
|
|
18
|
+
workflowFormGroupExistsInProd = false;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (workflowFormGroupExistsInProd) {
|
|
25
|
+
await (0, prod_client_1.updatePROD)(access_token_prod, workflowFormGroupData, client, serviceKey, `techforms/workflow/${workflow_id}/workflow-form/null/workflow-form-group/${formGroup.id}`, "workflow-form-group", formGroup.id, updateWorkflowData);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
await (0, prod_client_1.createPROD)(access_token_prod, workflowFormGroupData, client, serviceKey, `techforms/workflow/${workflow_id}/workflow-form/null/workflow-form-group`, "workflow-form-group", formGroup.id, updateWorkflowData);
|
|
29
|
+
}
|
|
30
|
+
//////////////////////// WORKFLOW FORMS IN FORM GROUP ////////////////////////
|
|
31
|
+
const workflowForms = workflowFormGroupData === null || workflowFormGroupData === void 0 ? void 0 : workflowFormGroupData.workflow_form_id;
|
|
32
|
+
if (workflowForms) {
|
|
33
|
+
await (0, _2_1_1_workflow_forms_1.WorkflowForms)({ id: workflowForms }, access_token_qa, access_token_prod, client, serviceKey, workflow_id, updateWorkflowData);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|