@uipath/case-tool 1.201.0 → 1.202.0-preview.136
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{authoring-aaaqwck3.js → authoring-cvjhkfxp.js} +74 -48
- package/dist/{browser-strategy-rkcvc6tn.js → browser-strategy-6atc7v8s.js} +3 -3
- package/dist/case-api-bwcxsbxe.js +381 -0
- package/dist/case-debug-studio-web-service-qcb328bt.js +335 -0
- package/dist/{case-pack-service-bxas5bxz.js → case-pack-service-txby2znw.js} +11 -18
- package/dist/case-validate-service-0q8krj2a.js +2114 -0
- package/dist/connector-enrichment-service-agqxam5y.js +60 -0
- package/dist/connector-lookup-service-ycgk77n0.js +22 -0
- package/dist/connector-task-spec-kdx5bv87.js +1250 -0
- package/dist/{de-5KVP66U6-t37qr521.js → de-5KVP66U6-1bnf4zt5.js} +54 -54
- package/dist/{de-5HU6GFWV-zheyw6d2.js → de-7XQXX2DK-tqdy5n2b.js} +857 -845
- package/dist/debug-service-dxx5pfev.js +57 -0
- package/dist/{en-MABQK6C4-nkzq2j8t.js → en-5ZGC5VQ3-h581y30k.js} +897 -897
- package/dist/{en-4KXU7N7B-24v330b5.js → en-X3S6IZ5J-nhkg6pwn.js} +55 -61
- package/dist/enrichment-service-ebz1f4ds.js +421 -0
- package/dist/{es-MX-POESXYP2-9538722k.js → es-MX-U2VN3SZW-anynsmd8.js} +857 -845
- package/dist/{es-MX-XAVLOQW3-47a405kf.js → es-MX-XAVLOQW3-q00km2y7.js} +54 -54
- package/dist/{es-VFPNVMP5-6sftsdxe.js → es-VFPNVMP5-bx2c337j.js} +54 -54
- package/dist/{es-LUTYN7U7-ye5zn4sn.js → es-ZGCPPOME-8gazspjj.js} +857 -845
- package/dist/{fr-E5MDO4EG-f3x1jeqw.js → fr-E5MDO4EG-c3mkty2t.js} +54 -54
- package/dist/{fr-LJIK56LW-xf3xf2kh.js → fr-T3G5GZCT-y3f7xb1q.js} +857 -845
- package/dist/{index-cncq089f.js → index-7s201ka0.js} +163 -80
- package/dist/{index-hsadteg4.js → index-h8cph72k.js} +4 -4
- package/dist/index-k4xz16db.js +63712 -0
- package/dist/{index-p50kx6jv.js → index-k5tbd184.js} +276 -276
- package/dist/index-kwxe1vep.js +143 -0
- package/dist/{index-9f8q2ege.js → index-p3vk57z7.js} +27 -27
- package/dist/index-qyf1dee9.js +630 -0
- package/dist/index.js +16 -17
- package/dist/{index.umd.min-drpc57vn.js → index.umd.min-fqefd9kn.js} +3 -3
- package/dist/input-reader-xb9vecxv.js +11 -0
- package/dist/{ja-FGEGLBJ3-w9byjhze.js → ja-BI5K3JDZ-77zat4z2.js} +857 -845
- package/dist/{ja-DPO5PPLO-fmbg7zt2.js → ja-DPO5PPLO-mysfmznx.js} +54 -54
- package/dist/{js-yaml-cggj6w7q.js → js-yaml-87cdx6bm.js} +27 -19
- package/dist/known-types-qryebm95.js +15 -0
- package/dist/{ko-ITOPNIYI-aqy82jk8.js → ko-ITOPNIYI-hmxd2asd.js} +54 -54
- package/dist/{ko-TUAK3G3A-s25w0ckg.js → ko-JOBF5V7N-4bv0mjje.js} +857 -845
- package/dist/{node-strategy-8gzp67xs.js → node-strategy-0267x5e5.js} +130 -14
- package/dist/node-sync-service-9a9ksj9s.js +38 -0
- package/dist/{packager-tool-9qecd4wb.js → packager-tool-0gctz400.js} +5 -2
- package/dist/packager-tool-0mj06yen.js +65 -0
- package/dist/{packager-tool-1cb0d5e0.js → packager-tool-0v3s8r01.js} +2 -2
- package/dist/packager-tool-134mvmcm.js +3040 -0
- package/dist/{packager-tool-wckvcay0.js → packager-tool-1yh8g550.js} +9 -7
- package/dist/{packager-tool-zqa5k9f7.js → packager-tool-37zvccmt.js} +990 -2287
- package/dist/packager-tool-3ze5vt52.js +54 -0
- package/dist/{packager-tool-w3h8xrnv.js → packager-tool-56j6keqr.js} +71 -3
- package/dist/{packager-tool-3wygxefb.js → packager-tool-58q3tvh7.js} +10 -10
- package/dist/{packager-tool-zx48pq4v.js → packager-tool-5ax2ywcg.js} +1997 -1174
- package/dist/{packager-tool-we1phz71.js → packager-tool-885mmrvr.js} +31 -3
- package/dist/packager-tool-9scn4b15.js +852 -0
- package/dist/{packager-tool-p9j43p8h.js → packager-tool-a42jnpy5.js} +3 -9
- package/dist/packager-tool-ajvse9r3.js +356 -0
- package/dist/{packager-tool-jysvpt8p.js → packager-tool-c23zrhj8.js} +2 -2
- package/dist/packager-tool-dqs5qy9s.js +2327 -0
- package/dist/packager-tool-ee5dhff3.js +6717 -0
- package/dist/{packager-tool-wvqz81mx.js → packager-tool-gtzs471w.js} +3 -2
- package/dist/packager-tool-hrr0efqc.js +546 -0
- package/dist/packager-tool-j9rfdrdm.js +1125 -0
- package/dist/{packager-tool-gq6952nc.js → packager-tool-jhdf8gt1.js} +5054 -17851
- package/dist/packager-tool-mp59jtpm.js +6865 -0
- package/dist/packager-tool-njzcfve1.js +77 -0
- package/dist/packager-tool-p7jgrm5r.js +15 -0
- package/dist/packager-tool-r84ng21s.js +57 -0
- package/dist/packager-tool-rqvr63x5.js +1217 -0
- package/dist/packager-tool-s12392rd.js +80 -0
- package/dist/packager-tool-sv0d6wb6.js +173 -0
- package/dist/packager-tool-ty1t2byf.js +27 -0
- package/dist/packager-tool-vepqrsse.js +23 -0
- package/dist/packager-tool-w5ek334f.js +4892 -0
- package/dist/{packager-tool-5arsyj36.js → packager-tool-yc4kw997.js} +4 -2
- package/dist/packager-tool.js +91 -5
- package/dist/project-artifacts-vhanbtw5.js +14 -0
- package/dist/{pt-BR-7XGDXRDJ-espnkgrj.js → pt-BR-7DYX2YPT-fqxqzqtf.js} +857 -845
- package/dist/{pt-BR-BXURWX4W-xzyndmrx.js → pt-BR-BXURWX4W-bwfcwhk1.js} +54 -54
- package/dist/{pt-TMVOOITK-myha14p9.js → pt-HTXGGX6Y-97t21dty.js} +857 -845
- package/dist/{pt-YI4VE4YQ-521681zf.js → pt-YI4VE4YQ-wdkn2dcf.js} +54 -54
- package/dist/resourcesSyncService-mrmmwaqr.js +683 -0
- package/dist/{ro-2VALF3S5-cdz5afkr.js → ro-KTNQ3MNU-y08n1x5g.js} +857 -845
- package/dist/{ro-RKXZUG7Z-pdztdafr.js → ro-RKXZUG7Z-nndrrsq7.js} +54 -54
- package/dist/{ru-GSCT4ARZ-qj8dm4dp.js → ru-GSCT4ARZ-1sa9wbr8.js} +1 -1
- package/dist/ru-WBLQ5B2U-8r3c7v6d.js +10 -0
- package/dist/strict-case-rules-303vjvas.js +377 -0
- package/dist/strict-sdd-audit-qdmc9e1y.js +1024 -0
- package/dist/tool.js +17 -18
- package/dist/{tr-AA6O2WSR-bj9n80k8.js → tr-AA6O2WSR-86ba4bdf.js} +54 -54
- package/dist/{tr-RIFCEXFH-hgkb4g8y.js → tr-XHSSPNK7-cmqyc4wd.js} +857 -845
- package/dist/trigger-enrichment-service-zdx4x92j.js +340 -0
- package/dist/{zh-CN-IP3FMXWM-1cfarhcp.js → zh-CN-2EHQT23P-mr63c4xz.js} +857 -845
- package/dist/{zh-CN-R2KLHXQV-x6gnk2n0.js → zh-CN-R2KLHXQV-agqr45ds.js} +54 -54
- package/dist/{zh-TW-AGIDXIPF-n6r6w7vy.js → zh-TW-MGZCE5BT-c4ekmrz9.js} +857 -845
- package/dist/{zh-TW-RJGCQANM-tt8j5wv2.js → zh-TW-RJGCQANM-w0x3qc1p.js} +54 -54
- package/package.json +2 -2
- package/dist/index-8bsngk9y.js +0 -247140
- package/dist/packager-tool-axcdppp9.js +0 -13607
- package/dist/ru-WBLQ5B2U-8xd4gpv2.js +0 -10
|
@@ -0,0 +1,1250 @@
|
|
|
1
|
+
import {
|
|
2
|
+
nestDottedKeys
|
|
3
|
+
} from "./packager-tool-hrr0efqc.js";
|
|
4
|
+
import"./packager-tool-134mvmcm.js";
|
|
5
|
+
import {
|
|
6
|
+
extractActivityFilterFields,
|
|
7
|
+
extractTriggerEventParameters,
|
|
8
|
+
extractTriggerFilterFields,
|
|
9
|
+
fetchConnectionInfo,
|
|
10
|
+
fetchConnectorMetadata,
|
|
11
|
+
fetchConnectorTriggerMetadata
|
|
12
|
+
} from "./packager-tool-rqvr63x5.js";
|
|
13
|
+
import"./packager-tool-885mmrvr.js";
|
|
14
|
+
import {
|
|
15
|
+
lookupConnectorDisplayName,
|
|
16
|
+
lookupTypeCacheEntry
|
|
17
|
+
} from "./packager-tool-njzcfve1.js";
|
|
18
|
+
import {
|
|
19
|
+
assertActivityMetadataResolved,
|
|
20
|
+
buildActivityEssentialConfiguration,
|
|
21
|
+
buildInputMetadata,
|
|
22
|
+
createConfiguredActivityClient,
|
|
23
|
+
extractMultipartParameters,
|
|
24
|
+
getEventOperationObjects
|
|
25
|
+
} from "./packager-tool-mp59jtpm.js";
|
|
26
|
+
import"./packager-tool-ajvse9r3.js";
|
|
27
|
+
import"./packager-tool-s12392rd.js";
|
|
28
|
+
import"./packager-tool-jhdf8gt1.js";
|
|
29
|
+
import"./packager-tool-58q3tvh7.js";
|
|
30
|
+
import"./packager-tool-sc961w0q.js";
|
|
31
|
+
import"./packager-tool-a42jnpy5.js";
|
|
32
|
+
import"./packager-tool-c23zrhj8.js";
|
|
33
|
+
import"./packager-tool-37zvccmt.js";
|
|
34
|
+
import"./packager-tool-0mj06yen.js";
|
|
35
|
+
import"./packager-tool-j9rfdrdm.js";
|
|
36
|
+
import {
|
|
37
|
+
TYPECACHE_ACTIVITY_INDEX_TYPES,
|
|
38
|
+
TYPECACHE_TRIGGER_INDEX_TYPES
|
|
39
|
+
} from "./packager-tool-r84ng21s.js";
|
|
40
|
+
import"./packager-tool-9scn4b15.js";
|
|
41
|
+
import"./packager-tool-3ze5vt52.js";
|
|
42
|
+
import"./packager-tool-vepqrsse.js";
|
|
43
|
+
import"./packager-tool-dqs5qy9s.js";
|
|
44
|
+
import"./packager-tool-qa9gftnj.js";
|
|
45
|
+
import {
|
|
46
|
+
catchError
|
|
47
|
+
} from "./packager-tool-5ax2ywcg.js";
|
|
48
|
+
import"./packager-tool-0v3s8r01.js";
|
|
49
|
+
import"./packager-tool-0gctz400.js";
|
|
50
|
+
import"./packager-tool-yc4kw997.js";
|
|
51
|
+
import"./packager-tool-1yh8g550.js";
|
|
52
|
+
|
|
53
|
+
// src/services/case-spec-input-validator.ts
|
|
54
|
+
class InvalidInputDetailsError extends Error {
|
|
55
|
+
constructor(message) {
|
|
56
|
+
super(message);
|
|
57
|
+
this.name = "InvalidInputDetailsError";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
var ACTIVITY_VALID_KEYS = new Set([
|
|
61
|
+
"bodyParameters",
|
|
62
|
+
"queryParameters",
|
|
63
|
+
"pathParameters",
|
|
64
|
+
"filter"
|
|
65
|
+
]);
|
|
66
|
+
var TRIGGER_VALID_KEYS = new Set(["eventParameters", "filter"]);
|
|
67
|
+
function validateActivityInputDetails(raw, isHttpRequest) {
|
|
68
|
+
if (raw === undefined || raw === null)
|
|
69
|
+
return {};
|
|
70
|
+
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
71
|
+
throw new InvalidInputDetailsError("--input-details must be a JSON object");
|
|
72
|
+
}
|
|
73
|
+
const config = raw;
|
|
74
|
+
const errors = [];
|
|
75
|
+
if ("ceqlExpression" in config) {
|
|
76
|
+
errors.push("ceqlExpression is derived from the filter tree and cannot be provided directly");
|
|
77
|
+
}
|
|
78
|
+
const unknownKeys = Object.keys(config).filter((k) => !ACTIVITY_VALID_KEYS.has(k) && k !== "ceqlExpression");
|
|
79
|
+
if (unknownKeys.length > 0) {
|
|
80
|
+
errors.push(`Unknown keys: ${unknownKeys.join(", ")}. Valid keys for activity: ${[...ACTIVITY_VALID_KEYS].join(", ")}`);
|
|
81
|
+
}
|
|
82
|
+
for (const key of [
|
|
83
|
+
"bodyParameters",
|
|
84
|
+
"queryParameters",
|
|
85
|
+
"pathParameters"
|
|
86
|
+
]) {
|
|
87
|
+
const val = config[key];
|
|
88
|
+
if (val !== undefined && (typeof val !== "object" || val === null || Array.isArray(val))) {
|
|
89
|
+
errors.push(`${key} must be a JSON object`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (config.filter !== undefined && (typeof config.filter !== "object" || config.filter === null || Array.isArray(config.filter))) {
|
|
93
|
+
errors.push("filter must be a JSON object (FilterTree)");
|
|
94
|
+
}
|
|
95
|
+
if (config.filter !== undefined && typeof config.queryParameters === "object" && config.queryParameters !== null && !Array.isArray(config.queryParameters) && "where" in config.queryParameters) {
|
|
96
|
+
errors.push("queryParameters.where is derived from `filter` and cannot be set alongside it. " + 'Drop one of the two — prefer "filter" so Studio Web can re-render the filter widget.');
|
|
97
|
+
}
|
|
98
|
+
if (isHttpRequest) {
|
|
99
|
+
if (config.bodyParameters !== undefined) {
|
|
100
|
+
errors.push("bodyParameters is not supported for synthetic HTTP request activities. " + "Pass body via --input-details.queryParameters or omit.");
|
|
101
|
+
}
|
|
102
|
+
if (config.filter !== undefined) {
|
|
103
|
+
errors.push("filter is not supported for synthetic HTTP request activities " + "(no curated filterable fields).");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (errors.length > 0) {
|
|
107
|
+
throw new InvalidInputDetailsError(`Invalid --input-details:
|
|
108
|
+
- ${errors.join(`
|
|
109
|
+
- `)}`);
|
|
110
|
+
}
|
|
111
|
+
return config;
|
|
112
|
+
}
|
|
113
|
+
function validateTriggerInputDetails(raw) {
|
|
114
|
+
if (raw === undefined || raw === null)
|
|
115
|
+
return {};
|
|
116
|
+
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
117
|
+
throw new InvalidInputDetailsError("--input-details must be a JSON object");
|
|
118
|
+
}
|
|
119
|
+
const config = raw;
|
|
120
|
+
const errors = [];
|
|
121
|
+
if ("filterExpression" in config) {
|
|
122
|
+
errors.push("filterExpression is derived from the filter tree and cannot be provided directly. " + 'Pass a structured "filter" (FilterTree) instead.');
|
|
123
|
+
}
|
|
124
|
+
const unknownKeys = Object.keys(config).filter((k) => !TRIGGER_VALID_KEYS.has(k) && k !== "filterExpression");
|
|
125
|
+
if (unknownKeys.length > 0) {
|
|
126
|
+
errors.push(`Unknown keys: ${unknownKeys.join(", ")}. Valid keys for trigger: ${[...TRIGGER_VALID_KEYS].join(", ")}`);
|
|
127
|
+
}
|
|
128
|
+
if (config.eventParameters !== undefined && (typeof config.eventParameters !== "object" || config.eventParameters === null || Array.isArray(config.eventParameters))) {
|
|
129
|
+
errors.push("eventParameters must be a JSON object");
|
|
130
|
+
}
|
|
131
|
+
if (config.filter !== undefined && (typeof config.filter !== "object" || config.filter === null || Array.isArray(config.filter))) {
|
|
132
|
+
errors.push("filter must be a JSON object (FilterTree)");
|
|
133
|
+
}
|
|
134
|
+
if (errors.length > 0) {
|
|
135
|
+
throw new InvalidInputDetailsError(`Invalid --input-details:
|
|
136
|
+
- ${errors.join(`
|
|
137
|
+
- `)}`);
|
|
138
|
+
}
|
|
139
|
+
return config;
|
|
140
|
+
}
|
|
141
|
+
function normalizeFilterTree(tree) {
|
|
142
|
+
if (!tree || typeof tree !== "object" || Array.isArray(tree))
|
|
143
|
+
return tree;
|
|
144
|
+
const t = tree;
|
|
145
|
+
const normalized = { ...t };
|
|
146
|
+
if (t.groupOperator !== undefined) {
|
|
147
|
+
normalized.groupOperator = normalizeGroupOperator(t.groupOperator);
|
|
148
|
+
}
|
|
149
|
+
if (Array.isArray(t.groups)) {
|
|
150
|
+
normalized.groups = t.groups.map(normalizeFilterTree);
|
|
151
|
+
}
|
|
152
|
+
return normalized;
|
|
153
|
+
}
|
|
154
|
+
function normalizeGroupOperator(value) {
|
|
155
|
+
if (value === "And")
|
|
156
|
+
return 0;
|
|
157
|
+
if (value === "Or")
|
|
158
|
+
return 1;
|
|
159
|
+
return value;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// src/services/connector-task-spec.types.ts
|
|
163
|
+
var CONN_BINDING_ID_PLACEHOLDER = "{{CONN_BINDING_ID}}";
|
|
164
|
+
var FOLDER_BINDING_ID_PLACEHOLDER = "{{FOLDER_BINDING_ID}}";
|
|
165
|
+
|
|
166
|
+
// src/services/connector-task-spec.ts
|
|
167
|
+
async function fetchConnectorTaskSpec(type, activityTypeId, connectionId, opts = {}) {
|
|
168
|
+
if (opts.inputDetails !== undefined && opts.skipCaseShape === true) {
|
|
169
|
+
throw new InvalidInputDetailsError("--input-details has no effect when --skip-case-shape is set; remove one of the two flags.");
|
|
170
|
+
}
|
|
171
|
+
const diagnostics = {
|
|
172
|
+
fetched: [],
|
|
173
|
+
fallbacks: [],
|
|
174
|
+
timestamp: new Date().toISOString()
|
|
175
|
+
};
|
|
176
|
+
const typecache = await resolveTypeCacheEntry(type, activityTypeId);
|
|
177
|
+
diagnostics.fetched.push(`TypeCache(${typecache.source})`);
|
|
178
|
+
const { connectorKey } = typecache.config;
|
|
179
|
+
const objectName = opts.objectNameOverride ?? typecache.config.objectName;
|
|
180
|
+
if (typecache.config.activityType === "Generic" && opts.objectNameOverride === undefined) {
|
|
181
|
+
throw new Error(`Generic ${type} (${activityTypeId}, "${typecache.entry.displayName}") requires --object-name. ` + `Discover available objects via:
|
|
182
|
+
` + ` uip is resources list --connector-key ${connectorKey}
|
|
183
|
+
` + ` uip is resources describe --connector-key ${connectorKey} --object-name <name>`);
|
|
184
|
+
}
|
|
185
|
+
const connection = await fetchConnectionContext(connectionId, diagnostics);
|
|
186
|
+
if (type === "activity") {
|
|
187
|
+
if (!typecache.config.httpMethod) {
|
|
188
|
+
throw new Error(`TypeCache entry ${activityTypeId} ("${typecache.entry.displayName}") has no httpMethod — not a connector activity. Verify the id is for a connector activity (Curated/Generic), not a non-connector activity (process/agent/etc.).`);
|
|
189
|
+
}
|
|
190
|
+
const validatedDetails = validateActivityInputDetails(opts.inputDetails, isHttpRequestObject(objectName));
|
|
191
|
+
const optsForActivity = {
|
|
192
|
+
...opts,
|
|
193
|
+
inputDetails: validatedDetails
|
|
194
|
+
};
|
|
195
|
+
return buildActivitySpec(connectorKey, objectName, typecache.config.httpMethod, connection, diagnostics, optsForActivity, {
|
|
196
|
+
activityTypeId,
|
|
197
|
+
entry: typecache.entry,
|
|
198
|
+
parsedConfig: typecache.config
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (!typecache.config.eventOperation) {
|
|
202
|
+
throw new Error(`TypeCache entry ${activityTypeId} ("${typecache.entry.displayName}") has no eventOperation — not a connector trigger.`);
|
|
203
|
+
}
|
|
204
|
+
const validatedTriggerDetails = validateTriggerInputDetails(opts.inputDetails);
|
|
205
|
+
const optsForTrigger = {
|
|
206
|
+
...opts,
|
|
207
|
+
inputDetails: validatedTriggerDetails
|
|
208
|
+
};
|
|
209
|
+
return buildTriggerSpec(connectorKey, objectName, typecache.config.eventOperation, connection, diagnostics, optsForTrigger, {
|
|
210
|
+
activityTypeId,
|
|
211
|
+
entry: typecache.entry,
|
|
212
|
+
parsedConfig: typecache.config
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
async function resolveTypeCacheEntry(type, activityTypeId) {
|
|
216
|
+
const sources = type === "activity" ? TYPECACHE_ACTIVITY_INDEX_TYPES : TYPECACHE_TRIGGER_INDEX_TYPES;
|
|
217
|
+
const [err, result] = await catchError(lookupTypeCacheEntry(activityTypeId, sources));
|
|
218
|
+
if (err) {
|
|
219
|
+
throw new Error(`No TypeCache entry found in ${sources.join(", ")} for uiPathActivityTypeId "${activityTypeId}". ` + `If the id is correct, run 'uip maestro case registry pull' to refresh the local cache. ` + `If you're looking up the other kind, pass --type ${type === "activity" ? "trigger" : "activity"}.`);
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
source: result.source,
|
|
223
|
+
entry: result.entry,
|
|
224
|
+
config: result.config
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
var ERROR_OUTPUT_SCHEMA = {
|
|
228
|
+
type: "object",
|
|
229
|
+
properties: {
|
|
230
|
+
code: { type: "string" },
|
|
231
|
+
message: { type: "string" },
|
|
232
|
+
detail: { type: "string" },
|
|
233
|
+
category: { type: "string" },
|
|
234
|
+
status: { type: "number" },
|
|
235
|
+
element: { type: "string" }
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
var RESPONSE_NAME = "response";
|
|
239
|
+
var RESPONSE_SOURCE = "=response";
|
|
240
|
+
var JOB_ATTACHMENT_PREFIX = "=orchestrator.JobAttachments";
|
|
241
|
+
var FILE_TYPE_JSON_SCHEMA = {
|
|
242
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
243
|
+
type: "object",
|
|
244
|
+
properties: {
|
|
245
|
+
ID: {
|
|
246
|
+
type: "string",
|
|
247
|
+
description: "Orchestrator attachment key"
|
|
248
|
+
},
|
|
249
|
+
FullName: {
|
|
250
|
+
type: "string",
|
|
251
|
+
description: "File name"
|
|
252
|
+
},
|
|
253
|
+
MimeType: {
|
|
254
|
+
type: "string",
|
|
255
|
+
description: "The MIME type of the content, such as application/json or image/png"
|
|
256
|
+
},
|
|
257
|
+
Metadata: {
|
|
258
|
+
type: "object",
|
|
259
|
+
description: "Dictionary<string, string> of metadata",
|
|
260
|
+
additionalProperties: {
|
|
261
|
+
type: "string"
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
required: ["ID"],
|
|
266
|
+
"x-uipath-resource-kind": "JobAttachment"
|
|
267
|
+
};
|
|
268
|
+
function humanizeSegment(name) {
|
|
269
|
+
const clean = name.replace(/\[\*\]/g, "");
|
|
270
|
+
if (!clean)
|
|
271
|
+
return "";
|
|
272
|
+
const spaced = clean.replace(/([A-Z])/g, " $1").toLowerCase().trim();
|
|
273
|
+
return spaced.charAt(0).toUpperCase() + spaced.slice(1);
|
|
274
|
+
}
|
|
275
|
+
function buildResponseJsonSchema(fields) {
|
|
276
|
+
const properties = {};
|
|
277
|
+
const definitions = {};
|
|
278
|
+
for (const field of fields) {
|
|
279
|
+
insertResponseField(field, properties, definitions);
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
283
|
+
type: "object",
|
|
284
|
+
properties,
|
|
285
|
+
definitions
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function insertResponseField(field, properties, definitions) {
|
|
289
|
+
const segments = field.name.split(".");
|
|
290
|
+
if (segments.length === 0)
|
|
291
|
+
return;
|
|
292
|
+
if (segments.length === 1) {
|
|
293
|
+
properties[segments[0]] = makeLeaf(segments[0], field);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
let currentProps = properties;
|
|
297
|
+
let defName = "";
|
|
298
|
+
for (let i = 0;i < segments.length - 1; i++) {
|
|
299
|
+
const seg = segments[i];
|
|
300
|
+
defName = i === 0 ? seg : defName + capitalizeForDefName(seg);
|
|
301
|
+
if (!definitions[defName]) {
|
|
302
|
+
definitions[defName] = { type: "object", properties: {} };
|
|
303
|
+
currentProps[seg] = makeRef(seg, defName);
|
|
304
|
+
}
|
|
305
|
+
currentProps = definitions[defName].properties;
|
|
306
|
+
}
|
|
307
|
+
const leaf = segments[segments.length - 1];
|
|
308
|
+
currentProps[leaf] = makeLeaf(leaf, field);
|
|
309
|
+
}
|
|
310
|
+
function makeLeaf(segmentName, field) {
|
|
311
|
+
if (segmentName.endsWith("[*]")) {
|
|
312
|
+
return {
|
|
313
|
+
title: field.displayName ?? humanizeSegment(segmentName),
|
|
314
|
+
type: "array",
|
|
315
|
+
items: { type: field.type }
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
return {
|
|
319
|
+
title: field.displayName ?? humanizeSegment(segmentName),
|
|
320
|
+
type: field.type
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
function makeRef(segmentName, defName) {
|
|
324
|
+
if (segmentName.endsWith("[*]")) {
|
|
325
|
+
return {
|
|
326
|
+
title: humanizeSegment(segmentName),
|
|
327
|
+
type: "array",
|
|
328
|
+
items: { $ref: `#/definitions/${defName}` }
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
return {
|
|
332
|
+
title: humanizeSegment(segmentName),
|
|
333
|
+
$ref: `#/definitions/${defName}`
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
function capitalizeForDefName(seg) {
|
|
337
|
+
if (!seg)
|
|
338
|
+
return seg;
|
|
339
|
+
return seg.charAt(0).toUpperCase() + seg.slice(1);
|
|
340
|
+
}
|
|
341
|
+
function isFileType(type) {
|
|
342
|
+
return type === "file" || type === "octet-stream";
|
|
343
|
+
}
|
|
344
|
+
function isHttpRequestObject(objectName) {
|
|
345
|
+
return objectName === "http-request" || objectName === "httpRequest";
|
|
346
|
+
}
|
|
347
|
+
var HTTP_OUTPUT_FIELDS = [
|
|
348
|
+
{
|
|
349
|
+
name: "code",
|
|
350
|
+
displayName: "Code",
|
|
351
|
+
type: "number",
|
|
352
|
+
responseCurated: true
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
name: "headers",
|
|
356
|
+
displayName: "Headers",
|
|
357
|
+
type: "object",
|
|
358
|
+
responseCurated: true
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
name: "body",
|
|
362
|
+
displayName: "Body",
|
|
363
|
+
type: "object",
|
|
364
|
+
responseCurated: true
|
|
365
|
+
}
|
|
366
|
+
];
|
|
367
|
+
function buildJsonSchemaResponseOutput(displayName, responseFields) {
|
|
368
|
+
return {
|
|
369
|
+
name: RESPONSE_NAME,
|
|
370
|
+
displayName,
|
|
371
|
+
type: "jsonSchema",
|
|
372
|
+
source: RESPONSE_SOURCE,
|
|
373
|
+
body: responseFields.length > 0 ? buildResponseJsonSchema(responseFields) : null
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
function buildFileResponseOutput(displayName) {
|
|
377
|
+
return {
|
|
378
|
+
name: RESPONSE_NAME,
|
|
379
|
+
displayName,
|
|
380
|
+
type: "file",
|
|
381
|
+
source: RESPONSE_SOURCE,
|
|
382
|
+
target: JOB_ATTACHMENT_PREFIX,
|
|
383
|
+
body: FILE_TYPE_JSON_SCHEMA
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
function buildCuratedOutputs(responseFields) {
|
|
387
|
+
return responseFields.filter((f) => (f.responseCurated === true || f.primaryKey === true) && f.name !== RESPONSE_NAME).map((f) => {
|
|
388
|
+
const out = {
|
|
389
|
+
name: f.name,
|
|
390
|
+
displayName: f.displayName,
|
|
391
|
+
type: f.type,
|
|
392
|
+
source: `${RESPONSE_SOURCE}.${f.name}`,
|
|
393
|
+
body: null
|
|
394
|
+
};
|
|
395
|
+
if (isFileType(f.type)) {
|
|
396
|
+
out.target = JOB_ATTACHMENT_PREFIX;
|
|
397
|
+
}
|
|
398
|
+
return out;
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
function buildErrorOutput() {
|
|
402
|
+
return {
|
|
403
|
+
name: "Error",
|
|
404
|
+
displayName: "Error",
|
|
405
|
+
type: "jsonSchema",
|
|
406
|
+
source: "=Error",
|
|
407
|
+
_jsonSchema: ERROR_OUTPUT_SCHEMA,
|
|
408
|
+
body: ERROR_OUTPUT_SCHEMA
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
function buildOutputs(objectName, responseDisplayName, responseFields) {
|
|
412
|
+
const outputs = [];
|
|
413
|
+
const fileField = responseFields.find((f) => isFileType(f.type));
|
|
414
|
+
if (fileField) {
|
|
415
|
+
outputs.push(buildFileResponseOutput(fileField.displayName ?? fileField.name));
|
|
416
|
+
} else if (isHttpRequestObject(objectName)) {
|
|
417
|
+
for (const f of HTTP_OUTPUT_FIELDS) {
|
|
418
|
+
outputs.push({
|
|
419
|
+
name: f.name,
|
|
420
|
+
displayName: f.displayName,
|
|
421
|
+
type: f.type,
|
|
422
|
+
source: `${RESPONSE_SOURCE}.${f.name}`,
|
|
423
|
+
body: null
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
} else {
|
|
427
|
+
outputs.push(buildJsonSchemaResponseOutput(responseDisplayName, responseFields));
|
|
428
|
+
outputs.push(...buildCuratedOutputs(responseFields));
|
|
429
|
+
}
|
|
430
|
+
outputs.push(buildErrorOutput());
|
|
431
|
+
return outputs;
|
|
432
|
+
}
|
|
433
|
+
function buildActivityCaseShape(objectName, _pathParameters, _queryParameters, bodyFields, responseFields, multipart) {
|
|
434
|
+
const inputs = [];
|
|
435
|
+
inputs.push({
|
|
436
|
+
name: "pathParameters",
|
|
437
|
+
type: "json",
|
|
438
|
+
target: "pathParameters",
|
|
439
|
+
body: {}
|
|
440
|
+
});
|
|
441
|
+
inputs.push({
|
|
442
|
+
name: "queryParameters",
|
|
443
|
+
type: "json",
|
|
444
|
+
target: "queryParameters",
|
|
445
|
+
body: {}
|
|
446
|
+
});
|
|
447
|
+
if (bodyFields.length > 0) {
|
|
448
|
+
inputs.push({
|
|
449
|
+
name: "body",
|
|
450
|
+
type: "json",
|
|
451
|
+
target: "body",
|
|
452
|
+
body: {}
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
if (multipart) {
|
|
456
|
+
for (const param of multipart.parameters) {
|
|
457
|
+
if (!param.isFile)
|
|
458
|
+
continue;
|
|
459
|
+
inputs.push({
|
|
460
|
+
name: param.name,
|
|
461
|
+
type: "file",
|
|
462
|
+
target: "file"
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
const outputs = buildOutputs(objectName, "Response", responseFields);
|
|
467
|
+
return { inputs, outputs };
|
|
468
|
+
}
|
|
469
|
+
function buildActivityContext(args) {
|
|
470
|
+
const entries = [
|
|
471
|
+
{ name: "connectorKey", type: "string", value: args.connectorKey },
|
|
472
|
+
{
|
|
473
|
+
name: "connection",
|
|
474
|
+
type: "string",
|
|
475
|
+
value: `=bindings.${CONN_BINDING_ID_PLACEHOLDER}`
|
|
476
|
+
},
|
|
477
|
+
{ name: "resourceKey", type: "string", value: args.connectionId }
|
|
478
|
+
];
|
|
479
|
+
if (args.hasFolderKey) {
|
|
480
|
+
entries.push({
|
|
481
|
+
name: "folderKey",
|
|
482
|
+
type: "string",
|
|
483
|
+
value: `=bindings.${FOLDER_BINDING_ID_PLACEHOLDER}`
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
entries.push({ name: "objectName", type: "string", value: args.objectName }, { name: "method", type: "string", value: args.httpMethod }, { name: "path", type: "string", value: args.path });
|
|
487
|
+
const activityPropertyConfiguration = {};
|
|
488
|
+
if (args.multipart && args.multipart.parameters.length > 0) {
|
|
489
|
+
activityPropertyConfiguration.multipartParameters = args.multipart.parameters.map((p) => ({
|
|
490
|
+
name: p.name,
|
|
491
|
+
dataType: p.dataType
|
|
492
|
+
}));
|
|
493
|
+
}
|
|
494
|
+
activityPropertyConfiguration.configuration = `=jsonString:${JSON.stringify(args.essentialConfiguration)}`;
|
|
495
|
+
activityPropertyConfiguration.uiPathActivityTypeId = args.uiPathActivityTypeId;
|
|
496
|
+
activityPropertyConfiguration.errorState = { issues: [] };
|
|
497
|
+
const multipartParams = args.multipart?.parameters.map((p) => ({
|
|
498
|
+
name: p.name,
|
|
499
|
+
dataType: p.dataType
|
|
500
|
+
})) ?? [];
|
|
501
|
+
const inputMetadata = buildInputMetadata(multipartParams, args.verb, args.maxPageSize) ?? {};
|
|
502
|
+
const activity = args.connectorDisplayName !== null ? { ...args.typecacheEntry, category: args.connectorDisplayName } : args.typecacheEntry;
|
|
503
|
+
const metadataBody = {
|
|
504
|
+
activityPropertyConfiguration,
|
|
505
|
+
activityMetadata: { activity },
|
|
506
|
+
inputMetadata,
|
|
507
|
+
telemetryData: {
|
|
508
|
+
connectorKey: args.connectorKey,
|
|
509
|
+
connectorName: args.connectorName,
|
|
510
|
+
operationType: args.verb,
|
|
511
|
+
objectName: args.objectName,
|
|
512
|
+
objectDisplayName: args.objectDisplayName,
|
|
513
|
+
primaryKeyName: args.primaryKeyName
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
entries.push({ name: "metadata", type: "json", body: metadataBody });
|
|
517
|
+
return entries;
|
|
518
|
+
}
|
|
519
|
+
function buildTriggerContext(args) {
|
|
520
|
+
const entries = [
|
|
521
|
+
{ name: "connectorKey", type: "string", value: args.connectorKey },
|
|
522
|
+
{
|
|
523
|
+
name: "connection",
|
|
524
|
+
type: "string",
|
|
525
|
+
value: `=bindings.${CONN_BINDING_ID_PLACEHOLDER}`
|
|
526
|
+
},
|
|
527
|
+
{ name: "resourceKey", type: "string", value: args.connectionId }
|
|
528
|
+
];
|
|
529
|
+
if (args.hasFolderKey) {
|
|
530
|
+
entries.push({
|
|
531
|
+
name: "folderKey",
|
|
532
|
+
type: "string",
|
|
533
|
+
value: `=bindings.${FOLDER_BINDING_ID_PLACEHOLDER}`
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
entries.push({ name: "method", type: "string" }, { name: "path", type: "string" }, { name: "objectName", type: "string", value: args.objectName }, { name: "operation", type: "string", value: args.eventOperation });
|
|
537
|
+
const activity = args.connectorDisplayName !== null ? { ...args.typecacheEntry, category: args.connectorDisplayName } : args.typecacheEntry;
|
|
538
|
+
const activityPropertyConfiguration = {
|
|
539
|
+
objectName: args.objectName,
|
|
540
|
+
eventType: args.eventOperation,
|
|
541
|
+
eventMode: args.eventMode,
|
|
542
|
+
configuration: `=jsonString:${JSON.stringify(args.essentialConfiguration)}`,
|
|
543
|
+
uiPathActivityTypeId: args.uiPathActivityTypeId,
|
|
544
|
+
errorState: { issues: [] },
|
|
545
|
+
...args.filterExpression && args.filterExpression.length > 0 ? { filterExpression: args.filterExpression } : {}
|
|
546
|
+
};
|
|
547
|
+
const telemetryData = {
|
|
548
|
+
connectorKey: args.connectorKey,
|
|
549
|
+
connectorName: args.connectorName,
|
|
550
|
+
objectName: args.objectName,
|
|
551
|
+
objectDisplayName: args.objectDisplayName,
|
|
552
|
+
primaryKeyName: ""
|
|
553
|
+
};
|
|
554
|
+
const metadataBody = {
|
|
555
|
+
activityPropertyConfiguration,
|
|
556
|
+
activityMetadata: { activity },
|
|
557
|
+
inputMetadata: {},
|
|
558
|
+
telemetryData
|
|
559
|
+
};
|
|
560
|
+
entries.push({ name: "metadata", type: "json", body: metadataBody });
|
|
561
|
+
return entries;
|
|
562
|
+
}
|
|
563
|
+
function buildTriggerCaseShape(objectName, _eventParameters, responseFields, responseDisplayName) {
|
|
564
|
+
const inputs = [
|
|
565
|
+
{
|
|
566
|
+
name: "body",
|
|
567
|
+
type: "json",
|
|
568
|
+
target: "body",
|
|
569
|
+
body: {}
|
|
570
|
+
}
|
|
571
|
+
];
|
|
572
|
+
const outputs = buildOutputs(objectName, responseDisplayName, responseFields);
|
|
573
|
+
return { inputs, outputs };
|
|
574
|
+
}
|
|
575
|
+
async function fetchConnectionContext(connectionId, diagnostics) {
|
|
576
|
+
const [err, info] = await catchError(fetchConnectionInfo(connectionId));
|
|
577
|
+
if (err) {
|
|
578
|
+
diagnostics.fallbacks.push({
|
|
579
|
+
endpoint: "fetchConnectionInfo",
|
|
580
|
+
reason: err.message
|
|
581
|
+
});
|
|
582
|
+
throw new Error(`Connection "${connectionId}" not found or inaccessible: ${err.message}`);
|
|
583
|
+
}
|
|
584
|
+
diagnostics.fetched.push("fetchConnectionInfo");
|
|
585
|
+
return {
|
|
586
|
+
context: {
|
|
587
|
+
id: info.id,
|
|
588
|
+
name: info.name,
|
|
589
|
+
folderKey: info.folderKey,
|
|
590
|
+
elementInstanceId: info.elementInstanceId,
|
|
591
|
+
byoaConnection: info.byoaConnection,
|
|
592
|
+
pollingIntervalMinutes: info.pollingInterval,
|
|
593
|
+
supportedAuths: []
|
|
594
|
+
},
|
|
595
|
+
connectorName: info.connectorName,
|
|
596
|
+
elementVersion: info.connectorVersion
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
function applyActivityInputDetails(caseShape, inputDetails, filter) {
|
|
600
|
+
if (inputDetails.bodyParameters !== undefined) {
|
|
601
|
+
const nested = nestDottedKeys(inputDetails.bodyParameters);
|
|
602
|
+
let bodyInput = caseShape.inputs.find((i) => i.name === "body");
|
|
603
|
+
if (!bodyInput) {
|
|
604
|
+
bodyInput = {
|
|
605
|
+
name: "body",
|
|
606
|
+
type: "json",
|
|
607
|
+
target: "body",
|
|
608
|
+
body: {}
|
|
609
|
+
};
|
|
610
|
+
caseShape.inputs.push(bodyInput);
|
|
611
|
+
}
|
|
612
|
+
bodyInput.body = mergeShallow(bodyInput.body ?? {}, nested);
|
|
613
|
+
}
|
|
614
|
+
if (inputDetails.queryParameters !== undefined) {
|
|
615
|
+
const queryInput = caseShape.inputs.find((i) => i.name === "queryParameters");
|
|
616
|
+
if (queryInput) {
|
|
617
|
+
queryInput.body = mergeShallow(queryInput.body ?? {}, inputDetails.queryParameters);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
if (inputDetails.pathParameters !== undefined) {
|
|
621
|
+
const pathInput = caseShape.inputs.find((i) => i.name === "pathParameters");
|
|
622
|
+
if (pathInput) {
|
|
623
|
+
pathInput.body = mergeShallow(pathInput.body ?? {}, inputDetails.pathParameters);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
if (filter.filterParamName !== null && filter.ceqlExpression !== null) {
|
|
627
|
+
const queryInput = caseShape.inputs.find((i) => i.name === "queryParameters");
|
|
628
|
+
if (queryInput) {
|
|
629
|
+
const existing = queryInput.body ?? {};
|
|
630
|
+
queryInput.body = {
|
|
631
|
+
...existing,
|
|
632
|
+
[filter.filterParamName]: filter.ceqlExpression
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
function mergeShallow(base, overlay) {
|
|
638
|
+
return { ...base, ...overlay };
|
|
639
|
+
}
|
|
640
|
+
function applyTriggerInputDetails(caseShape, inputDetails, filterExpression) {
|
|
641
|
+
let bodyInput = caseShape.inputs.find((i) => i.name === "body");
|
|
642
|
+
if (!bodyInput) {
|
|
643
|
+
bodyInput = {
|
|
644
|
+
name: "body",
|
|
645
|
+
type: "json",
|
|
646
|
+
target: "body",
|
|
647
|
+
body: {}
|
|
648
|
+
};
|
|
649
|
+
caseShape.inputs.push(bodyInput);
|
|
650
|
+
}
|
|
651
|
+
const body = bodyInput.body ?? {};
|
|
652
|
+
const eventParameters = inputDetails.eventParameters;
|
|
653
|
+
const hasEventParams = eventParameters !== undefined && Object.keys(eventParameters).length > 0;
|
|
654
|
+
if (filterExpression.length > 0) {
|
|
655
|
+
const existingFilters = body.filters ?? {};
|
|
656
|
+
body.filters = { ...existingFilters, expression: filterExpression };
|
|
657
|
+
}
|
|
658
|
+
if (hasEventParams && eventParameters) {
|
|
659
|
+
body.queryParams = { ...eventParameters };
|
|
660
|
+
}
|
|
661
|
+
bodyInput.body = body;
|
|
662
|
+
}
|
|
663
|
+
function buildActivityPagination(verb, methodInfo) {
|
|
664
|
+
if (verb !== "list")
|
|
665
|
+
return null;
|
|
666
|
+
const declared = methodInfo.pagination?.maxPageSize;
|
|
667
|
+
return { maxPageSize: declared ? declared : 1000 };
|
|
668
|
+
}
|
|
669
|
+
async function buildActivitySpec(connectorKey, objectName, httpMethod, resolvedConnection, diagnostics, opts, typecacheCtx) {
|
|
670
|
+
if (isHttpRequestObject(objectName)) {
|
|
671
|
+
return buildHttpActivitySpec(connectorKey, objectName, httpMethod, resolvedConnection, diagnostics, opts, typecacheCtx);
|
|
672
|
+
}
|
|
673
|
+
const [metaErr, metadata] = await catchError(fetchActivityMetadata(connectorKey, objectName, resolvedConnection.context.id));
|
|
674
|
+
if (metaErr) {
|
|
675
|
+
diagnostics.fallbacks.push({
|
|
676
|
+
endpoint: "fetchConnectorMetadata",
|
|
677
|
+
reason: metaErr.message
|
|
678
|
+
});
|
|
679
|
+
throw new Error(`Failed to fetch metadata for ${connectorKey}/${objectName}: ${metaErr.message}`);
|
|
680
|
+
}
|
|
681
|
+
diagnostics.fetched.push("fetchConnectorMetadata");
|
|
682
|
+
const methodInfo = extractMethodInfo(metadata, httpMethod);
|
|
683
|
+
if (!methodInfo) {
|
|
684
|
+
throw new Error(`Object "${objectName}" does not expose method "${httpMethod}". Available: ${listMethods(metadata).join(", ")}`);
|
|
685
|
+
}
|
|
686
|
+
const verb = methodInfo.operation.toLowerCase();
|
|
687
|
+
const objectDisplayName = metadata.displayName ?? objectName;
|
|
688
|
+
const params = methodInfo.parameters ?? [];
|
|
689
|
+
const pathParameters = params.filter((p) => p.type === "path").map(parameterFromIS);
|
|
690
|
+
const queryParameters = params.filter((p) => p.type === "query").map(parameterFromIS);
|
|
691
|
+
const multipart = buildMultipartSpec(params);
|
|
692
|
+
const fields = collectFields(metadata);
|
|
693
|
+
const bodyFields = filterFieldsByMethod(fields, httpMethod, "request");
|
|
694
|
+
const responseFields = filterFieldsByMethod(fields, httpMethod, "response");
|
|
695
|
+
const filter = buildActivityFilter(metadata, httpMethod, verb);
|
|
696
|
+
const pagination = buildActivityPagination(verb, methodInfo);
|
|
697
|
+
const references = collectReferences(connectorKey, resolvedConnection.context.id, [
|
|
698
|
+
...pathParameters.map((p) => ({ p, slot: "pathParameters" })),
|
|
699
|
+
...queryParameters.map((p) => ({ p, slot: "queryParameters" })),
|
|
700
|
+
...bodyFields.map((p) => ({ p, slot: "bodyFields" }))
|
|
701
|
+
]);
|
|
702
|
+
const inputDetails = opts.inputDetails;
|
|
703
|
+
let savedFilterTrees = null;
|
|
704
|
+
let activityFilterParamName = null;
|
|
705
|
+
if (inputDetails?.filter !== undefined) {
|
|
706
|
+
const filterBuilderParam = (methodInfo.parameters ?? []).find((p) => p.design?.component === "FilterBuilder");
|
|
707
|
+
if (!filterBuilderParam) {
|
|
708
|
+
throw new InvalidInputDetailsError(`Activity "${connectorKey}/${objectName}" does not declare a FilterBuilder parameter — server-side filtering is not supported by this operation. Drop "filter" from --input-details.`);
|
|
709
|
+
}
|
|
710
|
+
activityFilterParamName = filterBuilderParam.name;
|
|
711
|
+
savedFilterTrees = {
|
|
712
|
+
[activityFilterParamName]: normalizeFilterTree(inputDetails.filter)
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
const instanceParameters = {
|
|
716
|
+
...typecacheCtx.parsedConfig,
|
|
717
|
+
connectorKey,
|
|
718
|
+
objectName,
|
|
719
|
+
httpMethod
|
|
720
|
+
};
|
|
721
|
+
const activityClient = await createConfiguredActivityClient({
|
|
722
|
+
instanceParameters,
|
|
723
|
+
connectionId: resolvedConnection.context.id,
|
|
724
|
+
savedFilterTrees
|
|
725
|
+
});
|
|
726
|
+
const { essentialConfiguration: essentialConfig } = activityClient.getEssentialConfiguration();
|
|
727
|
+
assertActivityMetadataResolved(essentialConfig, resolvedConnection.context.id);
|
|
728
|
+
const activityCeqlExpression = activityFilterParamName ? activityClient.getCompiledFilter(activityFilterParamName) : null;
|
|
729
|
+
const essentialConfiguration = { essentialConfiguration: essentialConfig };
|
|
730
|
+
const primaryKeyName = responseFields.filter((f) => f.primaryKey === true).map((f) => f.name).join(",");
|
|
731
|
+
let caseShape;
|
|
732
|
+
if (!opts.skipCaseShape) {
|
|
733
|
+
const connectorDisplayName = await lookupConnectorDisplayName(typecacheCtx.entry.packageId);
|
|
734
|
+
caseShape = buildActivityCaseShape(objectName, pathParameters, queryParameters, bodyFields, responseFields, multipart);
|
|
735
|
+
if (inputDetails) {
|
|
736
|
+
applyActivityInputDetails(caseShape, inputDetails, {
|
|
737
|
+
filterParamName: activityFilterParamName,
|
|
738
|
+
ceqlExpression: activityCeqlExpression
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
caseShape.context = buildActivityContext({
|
|
742
|
+
connectorKey,
|
|
743
|
+
connectorName: resolvedConnection.connectorName,
|
|
744
|
+
objectName,
|
|
745
|
+
objectDisplayName,
|
|
746
|
+
uiPathActivityTypeId: typecacheCtx.activityTypeId,
|
|
747
|
+
httpMethod: methodInfo.method,
|
|
748
|
+
verb,
|
|
749
|
+
path: methodInfo.path,
|
|
750
|
+
connectionId: resolvedConnection.context.id,
|
|
751
|
+
hasFolderKey: resolvedConnection.context.folderKey !== null,
|
|
752
|
+
typecacheEntry: typecacheCtx.entry,
|
|
753
|
+
connectorDisplayName,
|
|
754
|
+
multipart,
|
|
755
|
+
maxPageSize: pagination?.maxPageSize,
|
|
756
|
+
primaryKeyName,
|
|
757
|
+
essentialConfiguration
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
return {
|
|
761
|
+
specVersion: 1,
|
|
762
|
+
identity: {
|
|
763
|
+
target: "activity",
|
|
764
|
+
uiPathActivityTypeId: typecacheCtx.activityTypeId,
|
|
765
|
+
connectorKey,
|
|
766
|
+
connectorName: resolvedConnection.connectorName,
|
|
767
|
+
connectorVersion: extractElementVersion(resolvedConnection),
|
|
768
|
+
objectName,
|
|
769
|
+
objectDisplayName,
|
|
770
|
+
typecacheEntry: typecacheCtx.entry
|
|
771
|
+
},
|
|
772
|
+
operation: {
|
|
773
|
+
name: httpMethod,
|
|
774
|
+
verb,
|
|
775
|
+
description: methodInfo.description ?? "",
|
|
776
|
+
httpMethod,
|
|
777
|
+
path: methodInfo.path
|
|
778
|
+
},
|
|
779
|
+
connection: resolvedConnection.context,
|
|
780
|
+
inputs: {
|
|
781
|
+
pathParameters,
|
|
782
|
+
queryParameters,
|
|
783
|
+
bodyFields,
|
|
784
|
+
multipart,
|
|
785
|
+
eventParameters: []
|
|
786
|
+
},
|
|
787
|
+
outputs: {
|
|
788
|
+
responseFields,
|
|
789
|
+
pagination
|
|
790
|
+
},
|
|
791
|
+
...filter ? { filter } : {},
|
|
792
|
+
essentialConfiguration,
|
|
793
|
+
references,
|
|
794
|
+
diagnostics,
|
|
795
|
+
...caseShape ? { caseShape } : {}
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
async function buildHttpActivitySpec(connectorKey, objectName, httpMethod, resolvedConnection, diagnostics, opts, typecacheCtx) {
|
|
799
|
+
diagnostics.fetched.push("synthetic.HttpRequest");
|
|
800
|
+
const verb = httpMethodToVerb(httpMethod);
|
|
801
|
+
const objectDisplayName = typecacheCtx.entry.displayName ?? objectName;
|
|
802
|
+
const instanceParameters = {
|
|
803
|
+
...typecacheCtx.parsedConfig,
|
|
804
|
+
connectorKey,
|
|
805
|
+
objectName,
|
|
806
|
+
httpMethod
|
|
807
|
+
};
|
|
808
|
+
const essentialConfiguration = buildActivityEssentialConfiguration(instanceParameters, {
|
|
809
|
+
operation: verb,
|
|
810
|
+
description: "",
|
|
811
|
+
method: httpMethod,
|
|
812
|
+
parameters: [],
|
|
813
|
+
path: "",
|
|
814
|
+
operationId: ""
|
|
815
|
+
});
|
|
816
|
+
const httpInputDetails = opts.inputDetails;
|
|
817
|
+
let caseShape;
|
|
818
|
+
if (!opts.skipCaseShape) {
|
|
819
|
+
const connectorDisplayName = await lookupConnectorDisplayName(typecacheCtx.entry.packageId);
|
|
820
|
+
caseShape = buildActivityCaseShape(objectName, [], [], [], [], null);
|
|
821
|
+
if (httpInputDetails) {
|
|
822
|
+
applyActivityInputDetails(caseShape, httpInputDetails, {
|
|
823
|
+
filterParamName: null,
|
|
824
|
+
ceqlExpression: null
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
caseShape.context = buildActivityContext({
|
|
828
|
+
connectorKey,
|
|
829
|
+
connectorName: resolvedConnection.connectorName,
|
|
830
|
+
objectName,
|
|
831
|
+
objectDisplayName,
|
|
832
|
+
uiPathActivityTypeId: typecacheCtx.activityTypeId,
|
|
833
|
+
httpMethod,
|
|
834
|
+
verb,
|
|
835
|
+
path: "",
|
|
836
|
+
connectionId: resolvedConnection.context.id,
|
|
837
|
+
hasFolderKey: resolvedConnection.context.folderKey !== null,
|
|
838
|
+
typecacheEntry: typecacheCtx.entry,
|
|
839
|
+
connectorDisplayName,
|
|
840
|
+
multipart: null,
|
|
841
|
+
maxPageSize: undefined,
|
|
842
|
+
primaryKeyName: "",
|
|
843
|
+
essentialConfiguration
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
return {
|
|
847
|
+
specVersion: 1,
|
|
848
|
+
identity: {
|
|
849
|
+
target: "activity",
|
|
850
|
+
uiPathActivityTypeId: typecacheCtx.activityTypeId,
|
|
851
|
+
connectorKey,
|
|
852
|
+
connectorName: resolvedConnection.connectorName,
|
|
853
|
+
connectorVersion: extractElementVersion(resolvedConnection),
|
|
854
|
+
objectName,
|
|
855
|
+
objectDisplayName,
|
|
856
|
+
typecacheEntry: typecacheCtx.entry
|
|
857
|
+
},
|
|
858
|
+
operation: {
|
|
859
|
+
name: httpMethod,
|
|
860
|
+
verb,
|
|
861
|
+
description: "Generic HTTP request — outputs are synthetic (code, headers, body) per FE's getHttpOutputResponse",
|
|
862
|
+
httpMethod,
|
|
863
|
+
path: ""
|
|
864
|
+
},
|
|
865
|
+
connection: resolvedConnection.context,
|
|
866
|
+
inputs: {
|
|
867
|
+
pathParameters: [],
|
|
868
|
+
queryParameters: [],
|
|
869
|
+
bodyFields: [],
|
|
870
|
+
multipart: null,
|
|
871
|
+
eventParameters: []
|
|
872
|
+
},
|
|
873
|
+
outputs: {
|
|
874
|
+
responseFields: [],
|
|
875
|
+
pagination: null
|
|
876
|
+
},
|
|
877
|
+
essentialConfiguration,
|
|
878
|
+
references: [],
|
|
879
|
+
diagnostics,
|
|
880
|
+
...caseShape ? { caseShape } : {}
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
async function fetchActivityMetadata(connectorKey, objectName, connectionId) {
|
|
884
|
+
return fetchConnectorMetadata(connectorKey, objectName, connectionId);
|
|
885
|
+
}
|
|
886
|
+
function extractMethodInfo(metadata, httpMethod) {
|
|
887
|
+
const methodMap = metadata.metadata;
|
|
888
|
+
const map = methodMap?.method ?? {};
|
|
889
|
+
return map[httpMethod] ?? Object.values(map).find((m) => m.method === httpMethod);
|
|
890
|
+
}
|
|
891
|
+
function listMethods(metadata) {
|
|
892
|
+
const methodMap = metadata.metadata;
|
|
893
|
+
return Object.keys(methodMap?.method ?? {});
|
|
894
|
+
}
|
|
895
|
+
async function buildTriggerSpec(connectorKey, objectName, eventOperation, resolvedConnection, diagnostics, opts, typecacheCtx) {
|
|
896
|
+
const [metaErr, triggerMeta] = await catchError(fetchTriggerMetadata(connectorKey, objectName, eventOperation, resolvedConnection.context.id));
|
|
897
|
+
if (metaErr) {
|
|
898
|
+
diagnostics.fallbacks.push({
|
|
899
|
+
endpoint: "fetchConnectorTriggerMetadata",
|
|
900
|
+
reason: metaErr.message
|
|
901
|
+
});
|
|
902
|
+
throw new Error(`Failed to fetch trigger metadata for ${connectorKey}/${eventOperation}/${objectName}: ${metaErr.message}`);
|
|
903
|
+
}
|
|
904
|
+
diagnostics.fetched.push("fetchConnectorTriggerMetadata");
|
|
905
|
+
const elementInstanceId = resolvedConnection.context.elementInstanceId;
|
|
906
|
+
let eventOpFlags = null;
|
|
907
|
+
if (elementInstanceId !== null) {
|
|
908
|
+
const [flagsErr, flags] = await catchError(getEventOperationObjects(undefined, elementInstanceId, connectorKey, eventOperation));
|
|
909
|
+
if (flagsErr) {
|
|
910
|
+
diagnostics.fallbacks.push({
|
|
911
|
+
endpoint: "client-factory.getEventOperationObjects",
|
|
912
|
+
reason: flagsErr.message
|
|
913
|
+
});
|
|
914
|
+
} else {
|
|
915
|
+
diagnostics.fetched.push("client-factory.getEventOperationObjects");
|
|
916
|
+
const match = flags.find((f) => f.name === objectName);
|
|
917
|
+
if (match) {
|
|
918
|
+
eventOpFlags = match;
|
|
919
|
+
if (Array.isArray(match.supportedAuths)) {
|
|
920
|
+
resolvedConnection.context.supportedAuths = [
|
|
921
|
+
...match.supportedAuths
|
|
922
|
+
];
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
const eventMode = triggerMeta.eventMode === "webhooks" ? "webhooks" : "polling";
|
|
928
|
+
const objectDisplayName = triggerMeta.displayName ?? objectName;
|
|
929
|
+
const fieldsMap = triggerMeta.fields ?? {};
|
|
930
|
+
const allFields = Object.values(fieldsMap);
|
|
931
|
+
const eventParamCompacts = extractTriggerEventParameters(triggerMeta, eventOperation);
|
|
932
|
+
const eventParameters = eventParamCompacts.map(compactToFieldSpec);
|
|
933
|
+
const filterFieldDefs = extractTriggerFilterFieldsLocal(triggerMeta);
|
|
934
|
+
const responseFields = allFields.map((f) => triggerFieldToFieldSpec(f, false));
|
|
935
|
+
const references = collectReferences(connectorKey, resolvedConnection.context.id, [
|
|
936
|
+
...eventParameters.map((p) => ({ p, slot: "eventParameters" })),
|
|
937
|
+
...responseFields.map((p) => ({ p, slot: "responseFields" }))
|
|
938
|
+
]);
|
|
939
|
+
const triggerInputDetails = opts.inputDetails;
|
|
940
|
+
let triggerFilterTree = null;
|
|
941
|
+
if (triggerInputDetails?.filter !== undefined) {
|
|
942
|
+
triggerFilterTree = normalizeFilterTree(triggerInputDetails.filter);
|
|
943
|
+
}
|
|
944
|
+
const baseActivityType = typecacheCtx.parsedConfig.activityType ?? "CuratedTrigger";
|
|
945
|
+
const overriddenActivityType = baseActivityType.startsWith("Generic") ? "GenericWaitFor" : "CuratedWaitFor";
|
|
946
|
+
const instanceParameters = {
|
|
947
|
+
...typecacheCtx.parsedConfig,
|
|
948
|
+
connectorKey,
|
|
949
|
+
objectName,
|
|
950
|
+
eventOperation,
|
|
951
|
+
eventMode,
|
|
952
|
+
activityType: overriddenActivityType
|
|
953
|
+
};
|
|
954
|
+
const triggerClient = await createConfiguredActivityClient({
|
|
955
|
+
instanceParameters,
|
|
956
|
+
connectionId: resolvedConnection.context.id,
|
|
957
|
+
savedFilterTrees: triggerFilterTree ? { filter: triggerFilterTree } : null,
|
|
958
|
+
fieldValues: triggerInputDetails?.eventParameters ?? {}
|
|
959
|
+
});
|
|
960
|
+
const { essentialConfiguration: triggerEssentialConfig } = triggerClient.getEssentialConfiguration();
|
|
961
|
+
assertActivityMetadataResolved(triggerEssentialConfig, resolvedConnection.context.id);
|
|
962
|
+
const combinedFilterExpression = triggerClient.getCompiledFilter("filter");
|
|
963
|
+
const essentialConfiguration = {
|
|
964
|
+
essentialConfiguration: triggerEssentialConfig
|
|
965
|
+
};
|
|
966
|
+
const filter = filterFieldDefs.length > 0 ? { builder: "jmes", fields: filterFieldDefs } : undefined;
|
|
967
|
+
const byoaConnection = eventOpFlags?.byoaConnection ?? resolvedConnection.context.byoaConnection;
|
|
968
|
+
resolvedConnection.context.byoaConnection = byoaConnection;
|
|
969
|
+
const responseDisplayName = typecacheCtx.entry.displayName ?? objectDisplayName ?? "Response";
|
|
970
|
+
let caseShape;
|
|
971
|
+
if (!opts.skipCaseShape) {
|
|
972
|
+
caseShape = buildTriggerCaseShape(objectName, eventParameters, responseFields, responseDisplayName);
|
|
973
|
+
if (triggerInputDetails) {
|
|
974
|
+
applyTriggerInputDetails(caseShape, triggerInputDetails, combinedFilterExpression);
|
|
975
|
+
}
|
|
976
|
+
const connectorDisplayName = await lookupConnectorDisplayName(typecacheCtx.entry.packageId);
|
|
977
|
+
caseShape.context = buildTriggerContext({
|
|
978
|
+
connectorKey,
|
|
979
|
+
connectorName: resolvedConnection.connectorName,
|
|
980
|
+
objectName,
|
|
981
|
+
objectDisplayName,
|
|
982
|
+
eventOperation,
|
|
983
|
+
eventMode,
|
|
984
|
+
connectionId: resolvedConnection.context.id,
|
|
985
|
+
hasFolderKey: resolvedConnection.context.folderKey !== null,
|
|
986
|
+
uiPathActivityTypeId: typecacheCtx.activityTypeId,
|
|
987
|
+
essentialConfiguration,
|
|
988
|
+
typecacheEntry: typecacheCtx.entry,
|
|
989
|
+
connectorDisplayName,
|
|
990
|
+
filterExpression: combinedFilterExpression
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
return {
|
|
994
|
+
specVersion: 1,
|
|
995
|
+
identity: {
|
|
996
|
+
target: "trigger",
|
|
997
|
+
uiPathActivityTypeId: typecacheCtx.activityTypeId,
|
|
998
|
+
connectorKey,
|
|
999
|
+
connectorName: resolvedConnection.connectorName,
|
|
1000
|
+
connectorVersion: extractElementVersion(resolvedConnection),
|
|
1001
|
+
objectName,
|
|
1002
|
+
objectDisplayName,
|
|
1003
|
+
typecacheEntry: typecacheCtx.entry
|
|
1004
|
+
},
|
|
1005
|
+
operation: {
|
|
1006
|
+
name: eventOperation,
|
|
1007
|
+
verb: eventOperation,
|
|
1008
|
+
description: "",
|
|
1009
|
+
eventMode
|
|
1010
|
+
},
|
|
1011
|
+
connection: resolvedConnection.context,
|
|
1012
|
+
inputs: {
|
|
1013
|
+
pathParameters: [],
|
|
1014
|
+
queryParameters: [],
|
|
1015
|
+
bodyFields: [],
|
|
1016
|
+
multipart: null,
|
|
1017
|
+
eventParameters
|
|
1018
|
+
},
|
|
1019
|
+
outputs: {
|
|
1020
|
+
responseFields,
|
|
1021
|
+
pagination: null
|
|
1022
|
+
},
|
|
1023
|
+
...filter ? { filter } : {},
|
|
1024
|
+
essentialConfiguration,
|
|
1025
|
+
references,
|
|
1026
|
+
diagnostics,
|
|
1027
|
+
...caseShape ? { caseShape } : {}
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
async function fetchTriggerMetadata(connectorKey, objectName, operationName, connectionId) {
|
|
1031
|
+
return fetchConnectorTriggerMetadata(connectorKey, operationName, objectName, connectionId);
|
|
1032
|
+
}
|
|
1033
|
+
function collectFields(metadata) {
|
|
1034
|
+
const direct = metadata.fields;
|
|
1035
|
+
if (direct) {
|
|
1036
|
+
return Array.isArray(direct) ? direct : Object.values(direct);
|
|
1037
|
+
}
|
|
1038
|
+
const nested = metadata.metadata;
|
|
1039
|
+
if (nested?.fields) {
|
|
1040
|
+
return Array.isArray(nested.fields) ? nested.fields : Object.values(nested.fields);
|
|
1041
|
+
}
|
|
1042
|
+
return [];
|
|
1043
|
+
}
|
|
1044
|
+
function filterFieldsByMethod(fields, httpMethod, direction) {
|
|
1045
|
+
const out = [];
|
|
1046
|
+
for (const f of fields) {
|
|
1047
|
+
const mc = f.method?.[httpMethod];
|
|
1048
|
+
const isResponsePrimaryKey = direction === "response" && f.primaryKey === true;
|
|
1049
|
+
if (!mc && !isResponsePrimaryKey)
|
|
1050
|
+
continue;
|
|
1051
|
+
const include = direction === "request" ? mc?.request === true || mc?.requestCurated === true : mc?.response === true || mc?.responseCurated === true || isResponsePrimaryKey;
|
|
1052
|
+
if (!include)
|
|
1053
|
+
continue;
|
|
1054
|
+
out.push(fieldToFieldSpec(f, mc, direction));
|
|
1055
|
+
}
|
|
1056
|
+
return out;
|
|
1057
|
+
}
|
|
1058
|
+
function fieldToFieldSpec(field, methodConfig, direction) {
|
|
1059
|
+
const spec = {
|
|
1060
|
+
name: field.name,
|
|
1061
|
+
displayName: field.displayName,
|
|
1062
|
+
description: field.description ?? "",
|
|
1063
|
+
dataType: field.type,
|
|
1064
|
+
type: field.type,
|
|
1065
|
+
required: direction === "request" ? methodConfig?.required === true : false
|
|
1066
|
+
};
|
|
1067
|
+
if (Array.isArray(field.enum) && field.enum.length > 0) {
|
|
1068
|
+
spec.enum = field.enum;
|
|
1069
|
+
}
|
|
1070
|
+
if (field.reference) {
|
|
1071
|
+
spec.reference = referenceToPointer(field.reference);
|
|
1072
|
+
}
|
|
1073
|
+
if (field.searchable === true) {
|
|
1074
|
+
spec.searchable = true;
|
|
1075
|
+
if (field.searchableOperators?.length) {
|
|
1076
|
+
spec.searchableOperators = [...field.searchableOperators];
|
|
1077
|
+
}
|
|
1078
|
+
if (field.searchableNames?.length) {
|
|
1079
|
+
spec.searchableNames = [...field.searchableNames];
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
if (direction === "response") {
|
|
1083
|
+
if (methodConfig?.responseCurated === true) {
|
|
1084
|
+
spec.responseCurated = true;
|
|
1085
|
+
}
|
|
1086
|
+
if (field.primaryKey === true) {
|
|
1087
|
+
spec.primaryKey = true;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
return spec;
|
|
1091
|
+
}
|
|
1092
|
+
function triggerFieldToFieldSpec(field, required) {
|
|
1093
|
+
const spec = {
|
|
1094
|
+
name: field.name,
|
|
1095
|
+
displayName: field.displayName,
|
|
1096
|
+
description: field.description ?? "",
|
|
1097
|
+
dataType: field.type,
|
|
1098
|
+
type: field.type,
|
|
1099
|
+
required
|
|
1100
|
+
};
|
|
1101
|
+
if (Array.isArray(field.enum) && field.enum.length > 0) {
|
|
1102
|
+
spec.enum = field.enum;
|
|
1103
|
+
}
|
|
1104
|
+
if (field.reference) {
|
|
1105
|
+
spec.reference = referenceToPointer(field.reference);
|
|
1106
|
+
}
|
|
1107
|
+
return spec;
|
|
1108
|
+
}
|
|
1109
|
+
function compactToFieldSpec(c) {
|
|
1110
|
+
const spec = {
|
|
1111
|
+
name: c.name,
|
|
1112
|
+
displayName: c.displayName,
|
|
1113
|
+
description: c.description ?? "",
|
|
1114
|
+
dataType: c.dataType,
|
|
1115
|
+
type: c.type,
|
|
1116
|
+
required: c.required
|
|
1117
|
+
};
|
|
1118
|
+
if (c.enum && c.enum.length > 0)
|
|
1119
|
+
spec.enum = c.enum;
|
|
1120
|
+
if (c.reference) {
|
|
1121
|
+
spec.reference = referenceToPointer(c.reference);
|
|
1122
|
+
}
|
|
1123
|
+
return spec;
|
|
1124
|
+
}
|
|
1125
|
+
function toFilterFieldSpec(cf) {
|
|
1126
|
+
const ff = {
|
|
1127
|
+
name: cf.name,
|
|
1128
|
+
displayName: cf.displayName,
|
|
1129
|
+
type: normalizeFilterType(cf.type)
|
|
1130
|
+
};
|
|
1131
|
+
if (cf.enum && cf.enum.length > 0)
|
|
1132
|
+
ff.enum = cf.enum;
|
|
1133
|
+
if (cf.searchableOperators?.length) {
|
|
1134
|
+
ff.searchableOperators = [...cf.searchableOperators];
|
|
1135
|
+
}
|
|
1136
|
+
if (cf.searchableNames?.length) {
|
|
1137
|
+
ff.searchableNames = [...cf.searchableNames];
|
|
1138
|
+
}
|
|
1139
|
+
return ff;
|
|
1140
|
+
}
|
|
1141
|
+
function extractTriggerFilterFieldsLocal(triggerMeta) {
|
|
1142
|
+
return extractTriggerFilterFields(triggerMeta).map(toFilterFieldSpec);
|
|
1143
|
+
}
|
|
1144
|
+
function buildActivityFilter(metadata, method, verb) {
|
|
1145
|
+
if (verb !== "list" && verb !== "read")
|
|
1146
|
+
return;
|
|
1147
|
+
const filterFields = extractActivityFilterFields(metadata, method).map(toFilterFieldSpec);
|
|
1148
|
+
return filterFields.length > 0 ? { builder: "ceql", fields: filterFields } : undefined;
|
|
1149
|
+
}
|
|
1150
|
+
function normalizeFilterType(raw) {
|
|
1151
|
+
switch ((raw ?? "").toLowerCase()) {
|
|
1152
|
+
case "number":
|
|
1153
|
+
return "number";
|
|
1154
|
+
case "integer":
|
|
1155
|
+
return "integer";
|
|
1156
|
+
case "boolean":
|
|
1157
|
+
return "boolean";
|
|
1158
|
+
case "date-time":
|
|
1159
|
+
case "datetime":
|
|
1160
|
+
case "date":
|
|
1161
|
+
return "date-time";
|
|
1162
|
+
default:
|
|
1163
|
+
return "string";
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
function parameterFromIS(p) {
|
|
1167
|
+
const spec = {
|
|
1168
|
+
name: p.name,
|
|
1169
|
+
displayName: p.displayName,
|
|
1170
|
+
description: p.description ?? "",
|
|
1171
|
+
dataType: p.dataType,
|
|
1172
|
+
required: p.required === true
|
|
1173
|
+
};
|
|
1174
|
+
if (p.defaultValue !== undefined)
|
|
1175
|
+
spec.defaultValue = p.defaultValue;
|
|
1176
|
+
if (p.reference) {
|
|
1177
|
+
spec.reference = referenceToPointer(p.reference);
|
|
1178
|
+
}
|
|
1179
|
+
return spec;
|
|
1180
|
+
}
|
|
1181
|
+
function buildMultipartSpec(params) {
|
|
1182
|
+
const multiparts = extractMultipartParameters(params);
|
|
1183
|
+
if (multiparts.length === 0)
|
|
1184
|
+
return null;
|
|
1185
|
+
const inputMeta = buildInputMetadata(multiparts, "create");
|
|
1186
|
+
return {
|
|
1187
|
+
bodyFieldName: inputMeta?.multipart?.bodyFieldName ?? null,
|
|
1188
|
+
parameters: multiparts.map((m) => ({
|
|
1189
|
+
name: m.name,
|
|
1190
|
+
dataType: m.dataType,
|
|
1191
|
+
isFile: m.dataType === "file"
|
|
1192
|
+
}))
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
function referenceToPointer(reference) {
|
|
1196
|
+
return {
|
|
1197
|
+
objectName: reference.objectName ?? "",
|
|
1198
|
+
lookupValue: reference.lookupValue ?? "",
|
|
1199
|
+
lookupNames: Array.isArray(reference.lookupNames) ? reference.lookupNames : [],
|
|
1200
|
+
discoverCommand: ""
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
function collectReferences(connectorKey, connectionId, sources) {
|
|
1204
|
+
const seen = new Set;
|
|
1205
|
+
const out = [];
|
|
1206
|
+
for (const { p, slot } of sources) {
|
|
1207
|
+
if (!p.reference?.objectName)
|
|
1208
|
+
continue;
|
|
1209
|
+
const key = `${slot}:${p.name}:${p.reference.objectName}`;
|
|
1210
|
+
if (seen.has(key))
|
|
1211
|
+
continue;
|
|
1212
|
+
seen.add(key);
|
|
1213
|
+
const cmd = `uip is resources run list ${connectorKey} ${p.reference.objectName} --connection-id ${connectionId}`;
|
|
1214
|
+
const ref = {
|
|
1215
|
+
...p.reference,
|
|
1216
|
+
discoverCommand: cmd,
|
|
1217
|
+
consumedBy: `${slot}.${p.name}`
|
|
1218
|
+
};
|
|
1219
|
+
out.push(ref);
|
|
1220
|
+
p.reference.discoverCommand = cmd;
|
|
1221
|
+
}
|
|
1222
|
+
return out;
|
|
1223
|
+
}
|
|
1224
|
+
function httpMethodToVerb(method) {
|
|
1225
|
+
switch (method) {
|
|
1226
|
+
case "GET":
|
|
1227
|
+
return "list";
|
|
1228
|
+
case "POST":
|
|
1229
|
+
return "create";
|
|
1230
|
+
case "PUT":
|
|
1231
|
+
return "replace";
|
|
1232
|
+
case "PATCH":
|
|
1233
|
+
return "update";
|
|
1234
|
+
case "DELETE":
|
|
1235
|
+
return "delete";
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
function extractElementVersion(rc) {
|
|
1239
|
+
return rc.elementVersion;
|
|
1240
|
+
}
|
|
1241
|
+
export {
|
|
1242
|
+
applyActivityInputDetails,
|
|
1243
|
+
applyTriggerInputDetails,
|
|
1244
|
+
buildActivityContext,
|
|
1245
|
+
buildResponseJsonSchema,
|
|
1246
|
+
buildTriggerContext,
|
|
1247
|
+
fetchConnectorTaskSpec
|
|
1248
|
+
};
|
|
1249
|
+
|
|
1250
|
+
//# debugId=ACFD551E64F8716264756E2164756E21
|