@evenicanpm/admin-integrate 2.3.1 → 2.4.1

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.
Files changed (37) hide show
  1. package/.turbo/turbo-biome$colon$format.log +7 -0
  2. package/CHANGELOG.md +9 -0
  3. package/documents/Process/get-process-details.ts +0 -2
  4. package/documents/ProcessConfig/fragments.ts +2 -2
  5. package/documents/ProcessExport/read.ts +0 -2
  6. package/documents/ProcessTemplate/fragments.ts +0 -8
  7. package/package.json +43 -24
  8. package/src/components/integration-view/edges/default-edge.tsx +2 -1
  9. package/src/components/integration-view/integration-view.tsx +2 -2
  10. package/src/components/integration-view/nodes/add-node.tsx +2 -1
  11. package/src/components/integration-view/nodes/connection-node.tsx +2 -1
  12. package/src/components/integration-view/nodes/empty-node.tsx +2 -1
  13. package/src/components/integration-view/nodes/entry-node.tsx +2 -1
  14. package/src/components/integration-view/nodes/execution-entry-node.tsx +2 -1
  15. package/src/components/integration-view/nodes/execution-task-node.tsx +2 -1
  16. package/src/components/integration-view/nodes/group-node.tsx +2 -1
  17. package/src/components/integration-view/nodes/row-node.tsx +2 -1
  18. package/src/components/integration-view/nodes/task-node.tsx +2 -1
  19. package/src/components/list-filter/list-filter.tsx +0 -2
  20. package/src/components/templatesV2/inputs/FormikPageBody.tsx +0 -1
  21. package/src/components/templatesV2/inputs/primitives/TextWithQueryInput.tsx +1 -20
  22. package/src/components/templatesV2/inputs/renderers/renderFormControl.tsx +0 -4
  23. package/src/components/templatesV2/pageForm.tsx +1 -1
  24. package/src/components/templatesV2/types.tsx +2 -2
  25. package/src/components/templatesV2/wizard.tsx +12 -61
  26. package/src/global.d.ts +3 -0
  27. package/src/pages/integration-create/integration-create.tsx +33 -41
  28. package/src/pages/integration-create/pre-creation-step.tsx +1 -1
  29. package/src/pages/integration-create/template-list-step.tsx +13 -8
  30. package/src/pages/integration-create/template-options-step.tsx +10 -30
  31. package/src/pages/integration-create/wizard-step.tsx +1 -15
  32. package/src/pages/integration-details/integration-details.tsx +13 -42
  33. package/src/pages/integration-details/task-drawer/add-task.tsx +0 -1
  34. package/src/pages/integration-details/task-drawer/edit-task.tsx +6 -25
  35. package/src/pages/integration-details/task-drawer/task-reducer.ts +0 -6
  36. package/tsconfig.json +6 -20
  37. package/src/components/templatesV2/utils/parseTemplateValuesFromConfig.ts +0 -311
@@ -1,311 +0,0 @@
1
- export interface Mapping {
2
- fieldName: string;
3
- jsonPath: string;
4
- jsonValuePath: string;
5
- format: string;
6
- inputTypeCode?: string;
7
- }
8
-
9
- export function parseWithMappings(
10
- input: { json: Record<string, unknown> },
11
- mappings: Mapping[],
12
- ): Record<string, unknown> {
13
- const result: Record<string, unknown> = {};
14
-
15
- for (const mapping of mappings) {
16
- const { fieldName, jsonPath, format } = mapping;
17
-
18
- const pathValue = resolvePath(input.json, jsonPath);
19
- if (pathValue === undefined || pathValue === null) {
20
- result[fieldName] = mapping.inputTypeCode === "input-table" ? [] : null;
21
- continue;
22
- }
23
-
24
- const parsed = parseValueFromFormat(format, fieldName, pathValue);
25
- const isEmptyForInputTable =
26
- mapping.inputTypeCode === "input-table" &&
27
- (parsed === "" ||
28
- (typeof parsed === "object" &&
29
- parsed !== null &&
30
- !Array.isArray(parsed) &&
31
- Object.keys(parsed).length === 0));
32
- result[fieldName] = isEmptyForInputTable ? [] : parsed;
33
- }
34
-
35
- return result;
36
- }
37
-
38
- function stripPathPrefix(path: string): string {
39
- if (path.startsWith("$.")) return path.slice(2);
40
- if (path.startsWith("$")) return path.slice(1);
41
- return path;
42
- }
43
-
44
- function walkSegment(current: unknown, segment: string | number): unknown {
45
- if (typeof segment === "number") {
46
- if (!Array.isArray(current)) return undefined;
47
- return current[segment];
48
- }
49
- if (typeof current !== "object" || Array.isArray(current)) return undefined;
50
- return (current as Record<string, unknown>)[segment];
51
- }
52
-
53
- /** Walks an object/array using a simple JSONPath expression (dot + bracket notation). */
54
- function resolvePath(obj: unknown, path: string): unknown {
55
- if (path === "$") return obj;
56
-
57
- const stripped = stripPathPrefix(path);
58
- if (!stripped) return obj;
59
-
60
- let current: unknown = obj;
61
- for (const segment of parsePathSegments(stripped)) {
62
- if (current === null || current === undefined) return undefined;
63
- current = walkSegment(current, segment);
64
- }
65
- return current;
66
- }
67
-
68
- /** Splits a stripped JSONPath string into typed segments, e.g. "Processes[0].ProcessTasks[1].Name" */
69
- function parsePathSegments(path: string): (string | number)[] {
70
- const segments: (string | number)[] = [];
71
- const regex = /([^.[\]]+)|\[(\d+)\]/g;
72
- let match: RegExpExecArray | null;
73
- while ((match = regex.exec(path)) !== null) {
74
- if (match[1] !== undefined) segments.push(match[1]);
75
- else if (match[2] !== undefined)
76
- segments.push(Number.parseInt(match[2], 10));
77
- }
78
- return segments;
79
- }
80
-
81
- /**
82
- * Applies the format string to the extracted value.
83
- * - If format is exactly `{0}` or `{fieldName}`, the raw value is returned as-is.
84
- * - Otherwise `{0}` / `{fieldName}` tokens are replaced with the stringified value.
85
- * If the result is valid JSON it is parsed back to an object.
86
- */
87
- function toValueString(value: unknown): string {
88
- if (value == null) return "";
89
- if (typeof value === "string") return value;
90
- if (
91
- typeof value === "number" ||
92
- typeof value === "boolean" ||
93
- typeof value === "bigint"
94
- )
95
- return String(value);
96
- if (typeof value === "object") return JSON.stringify(value);
97
- return "";
98
- }
99
-
100
- function escapeRegex(str: string): string {
101
- return str.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
102
- }
103
-
104
- function findPlaceholderInArray(
105
- arr: unknown[],
106
- placeholder: string,
107
- ): string[] | null {
108
- for (let i = 0; i < arr.length; i++) {
109
- const path = findPlaceholderPath(arr[i], placeholder);
110
- if (path !== null) return [String(i), ...path];
111
- }
112
- return null;
113
- }
114
-
115
- function findPlaceholderInObject(
116
- obj: Record<string, unknown>,
117
- placeholder: string,
118
- ): string[] | null {
119
- for (const [key, val] of Object.entries(obj)) {
120
- const path = findPlaceholderPath(val, placeholder);
121
- if (path !== null) return [key, ...path];
122
- }
123
- return null;
124
- }
125
-
126
- /**
127
- * Recursively searches an object/array for the first occurrence of `placeholder`
128
- * as a string value, returning the key path to it, or `null` if not found.
129
- */
130
- function findPlaceholderPath(
131
- obj: unknown,
132
- placeholder: string,
133
- ): string[] | null {
134
- if (typeof obj === "string") return obj === placeholder ? [] : null;
135
- if (Array.isArray(obj)) return findPlaceholderInArray(obj, placeholder);
136
- if (typeof obj === "object" && obj !== null) {
137
- return findPlaceholderInObject(obj as Record<string, unknown>, placeholder);
138
- }
139
- return null;
140
- }
141
-
142
- function navigatePath(obj: unknown, path: string[]): unknown {
143
- let current: unknown = obj;
144
- for (const key of path) {
145
- if (current === null || current === undefined) return undefined;
146
- if (Array.isArray(current)) {
147
- current = current[Number(key)];
148
- } else if (typeof current === "object") {
149
- current = (current as Record<string, unknown>)[key];
150
- } else {
151
- return undefined;
152
- }
153
- }
154
- return current;
155
- }
156
-
157
- /**
158
- * Like findPlaceholderPath but matches any string leaf that CONTAINS the placeholder
159
- * as a substring rather than being exactly equal to it.
160
- */
161
- function findContainingInArray(
162
- arr: unknown[],
163
- placeholder: string,
164
- ): string[] | null {
165
- for (let i = 0; i < arr.length; i++) {
166
- const path = findContainingPath(arr[i], placeholder);
167
- if (path !== null) return [String(i), ...path];
168
- }
169
- return null;
170
- }
171
-
172
- function findContainingInObject(
173
- obj: Record<string, unknown>,
174
- placeholder: string,
175
- ): string[] | null {
176
- for (const [key, val] of Object.entries(obj)) {
177
- const path = findContainingPath(val, placeholder);
178
- if (path !== null) return [key, ...path];
179
- }
180
- return null;
181
- }
182
-
183
- function findContainingPath(
184
- obj: unknown,
185
- placeholder: string,
186
- ): string[] | null {
187
- if (typeof obj === "string") return obj.includes(placeholder) ? [] : null;
188
- if (Array.isArray(obj)) return findContainingInArray(obj, placeholder);
189
- if (typeof obj === "object" && obj !== null)
190
- return findContainingInObject(obj as Record<string, unknown>, placeholder);
191
- return null;
192
- }
193
-
194
- /**
195
- * Reverse of `applyFormat`: given a format string containing `{0}` and a value
196
- * that was produced by that format, extracts and returns the original `{0}` value.
197
- *
198
- * For JSON formats (e.g. `{ "ConnectionName": "{0}" }`): parses both the format and
199
- * the value as JSON, locates the key path of `{0}` in the format structure, then
200
- * extracts the value at that same path from the actual value. This correctly handles
201
- * values with extra keys not present in the format template.
202
- *
203
- * When the placeholder is embedded within a format leaf string
204
- * (e.g. `{ "Sql": "exec {0}" }`), navigates to that leaf in the actual value
205
- * and applies regex capture within that field.
206
- *
207
- * For non-JSON formats (e.g. `"{0}_entity"`): falls back to regex capture.
208
- *
209
- * Returns `null` when no match is found.
210
- */
211
- function extractViaJsonFormat(
212
- format: string,
213
- placeholder0: string,
214
- placeholderField: string,
215
- formattedValue: unknown,
216
- ): unknown {
217
- let parsedFormat: unknown;
218
- try {
219
- parsedFormat = JSON.parse(format);
220
- } catch {
221
- return undefined;
222
- }
223
-
224
- let parsedValue: unknown = formattedValue;
225
- if (typeof formattedValue === "string") {
226
- try {
227
- parsedValue = JSON.parse(formattedValue);
228
- } catch {
229
- /* use as-is */
230
- }
231
- }
232
-
233
- // Exact match: the format leaf IS the placeholder
234
- const exactPath =
235
- findPlaceholderPath(parsedFormat, placeholder0) ??
236
- findPlaceholderPath(parsedFormat, placeholderField);
237
- if (exactPath !== null) {
238
- return navigatePath(parsedValue, exactPath);
239
- }
240
-
241
- // Embedded match: the placeholder appears inside a format leaf string
242
- const containingPath =
243
- findContainingPath(parsedFormat, placeholder0) ??
244
- findContainingPath(parsedFormat, placeholderField);
245
- if (containingPath === null) return undefined;
246
-
247
- const formatLeaf = navigatePath(parsedFormat, containingPath);
248
- if (typeof formatLeaf !== "string") return undefined;
249
-
250
- return extractViaRegex(
251
- formatLeaf,
252
- placeholder0,
253
- placeholderField,
254
- navigatePath(parsedValue, containingPath),
255
- );
256
- }
257
-
258
- function extractViaRegex(
259
- format: string,
260
- placeholder0: string,
261
- placeholderField: string,
262
- formattedValue: unknown,
263
- ): unknown {
264
- const segments = format.includes(placeholder0)
265
- ? format.split(placeholder0)
266
- : format.split(placeholderField);
267
-
268
- if (segments.length === 1) return null;
269
-
270
- const captureGroup = String.raw`([\s\S]*?)`;
271
- const regexSource = segments.map(escapeRegex).join(captureGroup);
272
- const match = new RegExp(`^${regexSource}$`).exec(
273
- toValueString(formattedValue).trim(),
274
- );
275
- if (!match) return null;
276
-
277
- const captured = match[1];
278
- try {
279
- return JSON.parse(captured);
280
- } catch {
281
- return captured;
282
- }
283
- }
284
-
285
- export function parseValueFromFormat(
286
- format: string,
287
- fieldName: string,
288
- formattedValue: unknown,
289
- ): unknown {
290
- if (format === "{0}" || format === `{${fieldName}}`) {
291
- return formattedValue;
292
- }
293
-
294
- const placeholder0 = "{0}";
295
- const placeholderField = `{${fieldName}}`;
296
-
297
- const jsonResult = extractViaJsonFormat(
298
- format,
299
- placeholder0,
300
- placeholderField,
301
- formattedValue,
302
- );
303
- if (jsonResult !== undefined) return jsonResult;
304
-
305
- return extractViaRegex(
306
- format,
307
- placeholder0,
308
- placeholderField,
309
- formattedValue,
310
- );
311
- }