@boomi/embedkit-sdk 1.1.6 → 1.2.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.
- package/README.md +0 -1
- package/dist/index.cjs +1640 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +562 -83
- package/dist/index.d.ts +562 -83
- package/dist/index.js +1637 -28
- package/dist/index.js.map +1 -1
- package/dist/logger-J0TnVInB.d.cts +13 -0
- package/dist/logger-J0TnVInB.d.ts +13 -0
- package/dist/logger.node.cjs +44 -0
- package/dist/logger.node.cjs.map +1 -0
- package/dist/logger.node.d.cts +5 -0
- package/dist/logger.node.d.ts +5 -0
- package/dist/logger.node.js +9 -0
- package/dist/logger.node.js.map +1 -0
- package/package.json +26 -1
package/dist/index.js
CHANGED
|
@@ -130,6 +130,35 @@ _promise = new WeakMap();
|
|
|
130
130
|
_resolve = new WeakMap();
|
|
131
131
|
_reject = new WeakMap();
|
|
132
132
|
|
|
133
|
+
// lib/utils/redact.ts
|
|
134
|
+
function redactHeaders(h) {
|
|
135
|
+
if (!h) return h;
|
|
136
|
+
const lower = {};
|
|
137
|
+
for (const [k, v] of Object.entries(h)) lower[k.toLowerCase()] = String(v);
|
|
138
|
+
if (lower["authorization"]) lower["authorization"] = "[REDACTED]";
|
|
139
|
+
if (lower["cookie"]) lower["cookie"] = "[REDACTED]";
|
|
140
|
+
if (lower["set-cookie"]) lower["set-cookie"] = "[REDACTED]";
|
|
141
|
+
return lower;
|
|
142
|
+
}
|
|
143
|
+
function redactBody(body) {
|
|
144
|
+
if (!body || typeof body !== "object") return body;
|
|
145
|
+
try {
|
|
146
|
+
const clone = JSON.parse(JSON.stringify(body));
|
|
147
|
+
const scrubKeys = ["password", "token", "accessToken", "refreshToken", "clientSecret", "secret"];
|
|
148
|
+
const walk = (o) => {
|
|
149
|
+
if (!o || typeof o !== "object") return;
|
|
150
|
+
for (const k of Object.keys(o)) {
|
|
151
|
+
if (scrubKeys.includes(k)) o[k] = "[REDACTED]";
|
|
152
|
+
else walk(o[k]);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
walk(clone);
|
|
156
|
+
return clone;
|
|
157
|
+
} catch {
|
|
158
|
+
return "[Unserializable body]";
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
133
162
|
// lib/core/request.ts
|
|
134
163
|
var isDefined = (value) => {
|
|
135
164
|
return value !== void 0 && value !== null;
|
|
@@ -184,23 +213,6 @@ var getQueryString = (params) => {
|
|
|
184
213
|
}
|
|
185
214
|
return "";
|
|
186
215
|
};
|
|
187
|
-
var getUrl = (config, options) => {
|
|
188
|
-
const encoder = config.ENCODE_PATH || encodeURI;
|
|
189
|
-
const path = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
190
|
-
if (options.path?.hasOwnProperty(group)) {
|
|
191
|
-
return encoder(String(options.path[group]));
|
|
192
|
-
}
|
|
193
|
-
return substring;
|
|
194
|
-
});
|
|
195
|
-
const url = `${config.BASE}${path}`;
|
|
196
|
-
if (options.query) {
|
|
197
|
-
return `${url}${getQueryString(options.query)}`;
|
|
198
|
-
}
|
|
199
|
-
if (config.OVERRIDE_ACCOUNT) {
|
|
200
|
-
return `${url}?overrideAccount=${config.OVERRIDE_ACCOUNT_ID}`;
|
|
201
|
-
}
|
|
202
|
-
return url;
|
|
203
|
-
};
|
|
204
216
|
var getFormData = (options) => {
|
|
205
217
|
if (options.formData) {
|
|
206
218
|
const formData = new FormData();
|
|
@@ -235,7 +247,7 @@ var getHeaders = async (config, options, formData) => {
|
|
|
235
247
|
resolve(options, config.PASSWORD),
|
|
236
248
|
resolve(options, config.HEADERS)
|
|
237
249
|
]);
|
|
238
|
-
const formHeaders = typeof formData
|
|
250
|
+
const formHeaders = formData && typeof formData.getHeaders === "function" ? formData.getHeaders() : {};
|
|
239
251
|
const headers = Object.entries({
|
|
240
252
|
Accept: "application/json",
|
|
241
253
|
...additionalHeaders,
|
|
@@ -340,15 +352,79 @@ var catchErrorCodes = (options, result) => {
|
|
|
340
352
|
);
|
|
341
353
|
}
|
|
342
354
|
};
|
|
355
|
+
var mergeQuery = (base, extra) => ({ ...base ?? {}, ...extra });
|
|
356
|
+
async function resolveChildOverrideId(config, options) {
|
|
357
|
+
if (options.overrideAccountId) return options.overrideAccountId;
|
|
358
|
+
if (config.OVERRIDE_ACCOUNT) {
|
|
359
|
+
const maybeId = await resolve(options, config.OVERRIDE_ACCOUNT_ID);
|
|
360
|
+
return isStringWithValue(maybeId) ? maybeId : void 0;
|
|
361
|
+
}
|
|
362
|
+
return void 0;
|
|
363
|
+
}
|
|
364
|
+
var getUrl = (config, options) => {
|
|
365
|
+
const encoder = config.ENCODE_PATH || encodeURI;
|
|
366
|
+
const path = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
367
|
+
if (options.path?.hasOwnProperty(group)) {
|
|
368
|
+
return encoder(String(options.path[group]));
|
|
369
|
+
}
|
|
370
|
+
return substring;
|
|
371
|
+
});
|
|
372
|
+
const base = `${config.BASE}${path}`;
|
|
373
|
+
return options.query ? `${base}${getQueryString(options.query)}` : base;
|
|
374
|
+
};
|
|
375
|
+
function getLogger(config) {
|
|
376
|
+
return config.LOGGER;
|
|
377
|
+
}
|
|
378
|
+
function reqId() {
|
|
379
|
+
return Math.random().toString(36).slice(2, 10);
|
|
380
|
+
}
|
|
343
381
|
var request = (config, options, axiosClient = axios) => {
|
|
344
|
-
return new CancelablePromise(async (
|
|
382
|
+
return new CancelablePromise(async (resolvePromise, reject, onCancel) => {
|
|
383
|
+
const logger = getLogger(config);
|
|
384
|
+
const id = options.requestId ?? reqId();
|
|
345
385
|
try {
|
|
346
|
-
const url = getUrl(config, options);
|
|
347
386
|
const formData = getFormData(options);
|
|
348
387
|
const body = getRequestBody(options);
|
|
349
388
|
const headers = await getHeaders(config, options, formData);
|
|
389
|
+
const mode = options.overrideMode ?? "auto";
|
|
390
|
+
let effectiveOverrideId;
|
|
391
|
+
switch (mode) {
|
|
392
|
+
case "force-parent":
|
|
393
|
+
case "suppress":
|
|
394
|
+
effectiveOverrideId = void 0;
|
|
395
|
+
break;
|
|
396
|
+
case "force-child":
|
|
397
|
+
case "auto":
|
|
398
|
+
default:
|
|
399
|
+
effectiveOverrideId = await resolveChildOverrideId(config, options);
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
const urlOptions = effectiveOverrideId ? { ...options, query: mergeQuery(options.query, { overrideAccount: effectiveOverrideId }) } : options;
|
|
403
|
+
const url = getUrl(config, urlOptions);
|
|
404
|
+
const child = logger?.child?.({
|
|
405
|
+
component: "embedkit-sdk",
|
|
406
|
+
reqId: id,
|
|
407
|
+
overrideAccount: effectiveOverrideId
|
|
408
|
+
}) ?? logger;
|
|
409
|
+
const start = Date.now();
|
|
410
|
+
child?.info?.({
|
|
411
|
+
req: {
|
|
412
|
+
method: (options.method || "GET").toUpperCase(),
|
|
413
|
+
url,
|
|
414
|
+
headers: redactHeaders(headers),
|
|
415
|
+
body: redactBody(body ?? formData)
|
|
416
|
+
}
|
|
417
|
+
}, "http.request");
|
|
350
418
|
if (!onCancel.isCancelled) {
|
|
351
419
|
const response = await sendRequest(config, options, url, body, formData, headers, onCancel, axiosClient);
|
|
420
|
+
const ms = Date.now() - start;
|
|
421
|
+
child?.info?.({
|
|
422
|
+
res: {
|
|
423
|
+
statusCode: response.status,
|
|
424
|
+
headers: redactHeaders(response.headers)
|
|
425
|
+
},
|
|
426
|
+
responseTime: ms
|
|
427
|
+
}, "http.response");
|
|
352
428
|
const responseBody = getResponseBody(response);
|
|
353
429
|
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
354
430
|
const result = {
|
|
@@ -359,9 +435,16 @@ var request = (config, options, axiosClient = axios) => {
|
|
|
359
435
|
body: responseHeader ?? responseBody
|
|
360
436
|
};
|
|
361
437
|
catchErrorCodes(options, result);
|
|
362
|
-
|
|
438
|
+
resolvePromise(result.body);
|
|
363
439
|
}
|
|
364
440
|
} catch (error) {
|
|
441
|
+
const ms = typeof error?.config === "object" && error.config?._start ? Date.now() - error.config._start : void 0;
|
|
442
|
+
const errObj = {
|
|
443
|
+
err: error,
|
|
444
|
+
responseTime: ms
|
|
445
|
+
};
|
|
446
|
+
const logger2 = getLogger(config);
|
|
447
|
+
logger2?.error?.(errObj, "http.error");
|
|
365
448
|
reject(error);
|
|
366
449
|
}
|
|
367
450
|
});
|
|
@@ -3854,6 +3937,50 @@ var EdifactConnectorRecordService = class {
|
|
|
3854
3937
|
}
|
|
3855
3938
|
};
|
|
3856
3939
|
|
|
3940
|
+
// lib/helpers/queryFilter.ts
|
|
3941
|
+
function queryFilter(property, operator, values) {
|
|
3942
|
+
if (values.length === 0) {
|
|
3943
|
+
throw new Error("Values array cannot be empty.");
|
|
3944
|
+
}
|
|
3945
|
+
for (const value of values) {
|
|
3946
|
+
if (typeof value !== "string") {
|
|
3947
|
+
throw new Error("All values must be strings.");
|
|
3948
|
+
}
|
|
3949
|
+
}
|
|
3950
|
+
const expression = {
|
|
3951
|
+
operator,
|
|
3952
|
+
property,
|
|
3953
|
+
argument: values
|
|
3954
|
+
};
|
|
3955
|
+
return {
|
|
3956
|
+
QueryFilter: { expression }
|
|
3957
|
+
};
|
|
3958
|
+
}
|
|
3959
|
+
function nestedQueryFilter(filters, logicalOperator = "and") {
|
|
3960
|
+
const nestedExpression = filters.map((f) => ({
|
|
3961
|
+
operator: f.operator,
|
|
3962
|
+
property: f.property,
|
|
3963
|
+
argument: Array.isArray(f.value) ? f.value : [f.value]
|
|
3964
|
+
}));
|
|
3965
|
+
return {
|
|
3966
|
+
QueryFilter: {
|
|
3967
|
+
expression: {
|
|
3968
|
+
operator: logicalOperator,
|
|
3969
|
+
nestedExpression
|
|
3970
|
+
}
|
|
3971
|
+
}
|
|
3972
|
+
};
|
|
3973
|
+
}
|
|
3974
|
+
function bulkFilter(type, requestValues) {
|
|
3975
|
+
if (requestValues.length === 0) {
|
|
3976
|
+
throw new Error("Request values array cannot be empty.");
|
|
3977
|
+
}
|
|
3978
|
+
return {
|
|
3979
|
+
type,
|
|
3980
|
+
request: requestValues.map((id) => ({ id }))
|
|
3981
|
+
};
|
|
3982
|
+
}
|
|
3983
|
+
|
|
3857
3984
|
// lib/services/EnvironmentService.ts
|
|
3858
3985
|
var EnvironmentService = class {
|
|
3859
3986
|
constructor(httpRequest) {
|
|
@@ -4021,6 +4148,69 @@ var EnvironmentService = class {
|
|
|
4021
4148
|
}
|
|
4022
4149
|
});
|
|
4023
4150
|
}
|
|
4151
|
+
/**
|
|
4152
|
+
* Browse Environments with runtime/attachment enrichment.
|
|
4153
|
+
* - classification: 'ALL' | 'PROD' | 'TEST'
|
|
4154
|
+
* - environmentId: optional direct lookup
|
|
4155
|
+
* Returns each environment with:
|
|
4156
|
+
* - installed: boolean (true if any runtime attachment exists)
|
|
4157
|
+
* - isActive: boolean (true if any attached atom is ONLINE; set to false if attachments exist but none online)
|
|
4158
|
+
*/
|
|
4159
|
+
async fetchEnvironments(params) {
|
|
4160
|
+
const { classification, environmentId } = params ?? {};
|
|
4161
|
+
let filter;
|
|
4162
|
+
if (classification === "ALL") {
|
|
4163
|
+
filter = nestedQueryFilter(
|
|
4164
|
+
[
|
|
4165
|
+
{ property: "classification", operator: "EQUALS", value: "PROD" },
|
|
4166
|
+
{ property: "classification", operator: "EQUALS", value: "TEST" }
|
|
4167
|
+
],
|
|
4168
|
+
"or"
|
|
4169
|
+
);
|
|
4170
|
+
} else if (classification === "PROD" || classification === "TEST") {
|
|
4171
|
+
filter = queryFilter("classification", "EQUALS", [classification]);
|
|
4172
|
+
} else if (environmentId) {
|
|
4173
|
+
filter = queryFilter("id", "EQUALS", [environmentId]);
|
|
4174
|
+
}
|
|
4175
|
+
const envResp = await this.queryEnvironment(filter);
|
|
4176
|
+
const baseItems = envResp?.result ?? [];
|
|
4177
|
+
if (!baseItems.length) {
|
|
4178
|
+
return { numberOfResults: 0, result: [] };
|
|
4179
|
+
}
|
|
4180
|
+
const enriched = await Promise.all(
|
|
4181
|
+
baseItems.map(async (env) => {
|
|
4182
|
+
env.installed = false;
|
|
4183
|
+
env.isActive = false;
|
|
4184
|
+
try {
|
|
4185
|
+
const aFilter = queryFilter("environmentId", "EQUALS", [env.id]);
|
|
4186
|
+
const attachResp = await this.httpRequest.request({
|
|
4187
|
+
method: "POST",
|
|
4188
|
+
url: "/EnvironmentAtomAttachment/query",
|
|
4189
|
+
mediaType: "application/json",
|
|
4190
|
+
body: aFilter
|
|
4191
|
+
});
|
|
4192
|
+
const attachments = attachResp?.result ?? [];
|
|
4193
|
+
if (!attachments.length) return env;
|
|
4194
|
+
env.installed = true;
|
|
4195
|
+
const atomIds = attachments.map((att) => att?.atomId).filter(Boolean);
|
|
4196
|
+
if (!atomIds.length) return env;
|
|
4197
|
+
const atoms = await Promise.all(
|
|
4198
|
+
atomIds.map(
|
|
4199
|
+
(atomId) => this.httpRequest.request({ method: "GET", url: "/Atom/{id}", path: { id: atomId } }).catch(() => null)
|
|
4200
|
+
)
|
|
4201
|
+
);
|
|
4202
|
+
const anyOnline = atoms.filter(Boolean).some((a) => a?.status === "ONLINE");
|
|
4203
|
+
env.isActive = anyOnline;
|
|
4204
|
+
} catch {
|
|
4205
|
+
}
|
|
4206
|
+
return env;
|
|
4207
|
+
})
|
|
4208
|
+
);
|
|
4209
|
+
return {
|
|
4210
|
+
numberOfResults: enriched.length,
|
|
4211
|
+
result: enriched
|
|
4212
|
+
};
|
|
4213
|
+
}
|
|
4024
4214
|
};
|
|
4025
4215
|
|
|
4026
4216
|
// lib/services/EnvironmentAtomAttachmentService.ts
|
|
@@ -4154,6 +4344,393 @@ var EnvironmentConnectionFieldExtensionSummaryService = class {
|
|
|
4154
4344
|
}
|
|
4155
4345
|
};
|
|
4156
4346
|
|
|
4347
|
+
// lib/helpers/fetchProcesses.ts
|
|
4348
|
+
async function fetchProcesses(httpRequest, integrationPackInstanceId) {
|
|
4349
|
+
return await httpRequest.request({
|
|
4350
|
+
method: "POST",
|
|
4351
|
+
url: "/Process/query",
|
|
4352
|
+
mediaType: "application/json",
|
|
4353
|
+
body: queryFilter("integrationPackInstanceId", "EQUALS", [integrationPackInstanceId]),
|
|
4354
|
+
overrideMode: "force-child"
|
|
4355
|
+
});
|
|
4356
|
+
}
|
|
4357
|
+
|
|
4358
|
+
// lib/helpers/fetchEnvironmentExtensions.ts
|
|
4359
|
+
async function fetchEnvironmentExtensions(httpRequest, requestBody) {
|
|
4360
|
+
return httpRequest.request({
|
|
4361
|
+
method: "POST",
|
|
4362
|
+
url: "/EnvironmentExtensions/query",
|
|
4363
|
+
body: requestBody,
|
|
4364
|
+
mediaType: "application/json",
|
|
4365
|
+
errors: {
|
|
4366
|
+
403: `Missing or incorrect authentication credentials.
|
|
4367
|
+
To know the action to be taken for this and the other error responses (410, 503, etc), refer to [API Errors](#section/Introduction/API-errors)`
|
|
4368
|
+
}
|
|
4369
|
+
});
|
|
4370
|
+
}
|
|
4371
|
+
|
|
4372
|
+
// lib/helpers/fetchExtensionsForPair.ts
|
|
4373
|
+
async function fetchExtensionsForPair(httpRequest, processId, envId) {
|
|
4374
|
+
const extensionFilter = nestedQueryFilter(
|
|
4375
|
+
[
|
|
4376
|
+
{ property: "environmentId", operator: "EQUALS", value: envId },
|
|
4377
|
+
{ property: "extensionGroupId", operator: "EQUALS", value: processId }
|
|
4378
|
+
],
|
|
4379
|
+
"and"
|
|
4380
|
+
);
|
|
4381
|
+
const extResponse = await fetchEnvironmentExtensions(httpRequest, extensionFilter);
|
|
4382
|
+
return extResponse?.result || [];
|
|
4383
|
+
}
|
|
4384
|
+
|
|
4385
|
+
// lib/helpers/fetchExtensions.ts
|
|
4386
|
+
async function fetchExtensions(httpRequest, integrationPackInstanceId, environmentId, environments) {
|
|
4387
|
+
const resp = await fetchProcesses(httpRequest, integrationPackInstanceId);
|
|
4388
|
+
if (!resp?.result) {
|
|
4389
|
+
throw new Error(
|
|
4390
|
+
`No processes found for integrationPackInstanceId: ${integrationPackInstanceId}`
|
|
4391
|
+
);
|
|
4392
|
+
}
|
|
4393
|
+
const processes = resp.result;
|
|
4394
|
+
const allExtensions = [];
|
|
4395
|
+
const targetEnvs = resolveTargetEnvironments(environments, environmentId);
|
|
4396
|
+
for (const process of processes) {
|
|
4397
|
+
if (!process.id) {
|
|
4398
|
+
throw new Error(
|
|
4399
|
+
`Missing process ID for integrationPackInstanceId: ${integrationPackInstanceId}`
|
|
4400
|
+
);
|
|
4401
|
+
}
|
|
4402
|
+
if (!targetEnvs?.length) {
|
|
4403
|
+
const exts = await fetchExtensionsForPair(httpRequest, process.id, environmentId);
|
|
4404
|
+
allExtensions.push(...exts);
|
|
4405
|
+
} else {
|
|
4406
|
+
for (const env of targetEnvs) {
|
|
4407
|
+
const envId = env.id || "";
|
|
4408
|
+
const exts = await fetchExtensionsForPair(httpRequest, process.id, envId);
|
|
4409
|
+
allExtensions.push(...exts);
|
|
4410
|
+
}
|
|
4411
|
+
}
|
|
4412
|
+
}
|
|
4413
|
+
return allExtensions;
|
|
4414
|
+
}
|
|
4415
|
+
function resolveTargetEnvironments(environments, environmentId) {
|
|
4416
|
+
return environmentId ? [{ id: environmentId }] : environments;
|
|
4417
|
+
}
|
|
4418
|
+
|
|
4419
|
+
// lib/helpers/combineEnvironmentExtensions.ts
|
|
4420
|
+
function combineEnvironmentExtensions(exts) {
|
|
4421
|
+
const hasId = (x) => typeof x.id === "string" && x.id.length > 0;
|
|
4422
|
+
const hasKey = (x) => typeof x.key === "string" && x.key.length > 0;
|
|
4423
|
+
const byEnv = /* @__PURE__ */ new Map();
|
|
4424
|
+
const conflicts = { connections: [], processProperties: [] };
|
|
4425
|
+
const ensureEnv = (envId) => {
|
|
4426
|
+
if (!byEnv.has(envId)) {
|
|
4427
|
+
byEnv.set(envId, {
|
|
4428
|
+
env: {
|
|
4429
|
+
environmentId: envId,
|
|
4430
|
+
extensionGroupId: "combined",
|
|
4431
|
+
id: `combined:${envId}`,
|
|
4432
|
+
connections: { connection: [] },
|
|
4433
|
+
processProperties: {
|
|
4434
|
+
ProcessProperty: [{
|
|
4435
|
+
id: "combined",
|
|
4436
|
+
name: "Process Properties",
|
|
4437
|
+
ProcessPropertyValue: []
|
|
4438
|
+
}]
|
|
4439
|
+
}
|
|
4440
|
+
},
|
|
4441
|
+
connMap: /* @__PURE__ */ new Map(),
|
|
4442
|
+
propMap: /* @__PURE__ */ new Map()
|
|
4443
|
+
});
|
|
4444
|
+
}
|
|
4445
|
+
return byEnv.get(envId);
|
|
4446
|
+
};
|
|
4447
|
+
const coalesceField = (envId, connId, existing, incoming) => {
|
|
4448
|
+
const a = existing?.value ?? "";
|
|
4449
|
+
const b = incoming?.value ?? "";
|
|
4450
|
+
if (a && !b) return existing;
|
|
4451
|
+
if (!a && b) return incoming;
|
|
4452
|
+
if (a && b && a !== b) {
|
|
4453
|
+
conflicts.connections.push({
|
|
4454
|
+
environmentId: envId,
|
|
4455
|
+
connectionId: connId,
|
|
4456
|
+
fieldId: String(existing.id ?? incoming.id ?? ""),
|
|
4457
|
+
values: [a, b]
|
|
4458
|
+
});
|
|
4459
|
+
return incoming;
|
|
4460
|
+
}
|
|
4461
|
+
if (!a && !b && (existing.encryptedValueSet || incoming.encryptedValueSet)) {
|
|
4462
|
+
return {
|
|
4463
|
+
...existing,
|
|
4464
|
+
encryptedValueSet: !!((existing.encryptedValueSet ?? false) || (incoming.encryptedValueSet ?? false))
|
|
4465
|
+
};
|
|
4466
|
+
}
|
|
4467
|
+
return existing || incoming;
|
|
4468
|
+
};
|
|
4469
|
+
for (const ext of exts) {
|
|
4470
|
+
const envId = ext.environmentId;
|
|
4471
|
+
if (!envId) continue;
|
|
4472
|
+
const target = ensureEnv(envId);
|
|
4473
|
+
const conns = ext.connections?.connection ?? [];
|
|
4474
|
+
for (const conn of conns) {
|
|
4475
|
+
const connKey = conn.id ?? `name:${conn.name}`;
|
|
4476
|
+
if (!target.connMap.has(connKey)) {
|
|
4477
|
+
target.connMap.set(connKey, {
|
|
4478
|
+
...conn,
|
|
4479
|
+
field: Array.isArray(conn.field) ? [...conn.field] : []
|
|
4480
|
+
});
|
|
4481
|
+
} else {
|
|
4482
|
+
const merged = { ...target.connMap.get(connKey) };
|
|
4483
|
+
const fieldMap = /* @__PURE__ */ new Map();
|
|
4484
|
+
for (const f of merged.field ?? []) if (hasId(f)) fieldMap.set(f.id, { ...f });
|
|
4485
|
+
for (const f of conn.field ?? []) {
|
|
4486
|
+
if (!hasId(f)) continue;
|
|
4487
|
+
const prev = fieldMap.get(f.id);
|
|
4488
|
+
fieldMap.set(f.id, prev ? coalesceField(envId, connKey, prev, f) : { ...f });
|
|
4489
|
+
}
|
|
4490
|
+
merged.field = Array.from(fieldMap.values());
|
|
4491
|
+
target.connMap.set(connKey, merged);
|
|
4492
|
+
}
|
|
4493
|
+
}
|
|
4494
|
+
const ppGroups = ext.processProperties?.ProcessProperty ?? [];
|
|
4495
|
+
for (const group of ppGroups) {
|
|
4496
|
+
for (const v of group.ProcessPropertyValue ?? []) {
|
|
4497
|
+
if (!hasKey(v)) continue;
|
|
4498
|
+
const existing = target.propMap.get(v.key);
|
|
4499
|
+
if (!existing) {
|
|
4500
|
+
target.propMap.set(v.key, { ...v });
|
|
4501
|
+
} else {
|
|
4502
|
+
const a = existing.value ?? "";
|
|
4503
|
+
const b = v.value ?? "";
|
|
4504
|
+
if (a && b && a !== b) {
|
|
4505
|
+
conflicts.processProperties.push({
|
|
4506
|
+
environmentId: envId,
|
|
4507
|
+
key: v.key,
|
|
4508
|
+
...v.label !== void 0 ? { label: v.label } : {},
|
|
4509
|
+
values: [a, b]
|
|
4510
|
+
});
|
|
4511
|
+
target.propMap.set(v.key, { ...v });
|
|
4512
|
+
} else if (!a && b) {
|
|
4513
|
+
target.propMap.set(v.key, { ...v });
|
|
4514
|
+
}
|
|
4515
|
+
}
|
|
4516
|
+
}
|
|
4517
|
+
}
|
|
4518
|
+
}
|
|
4519
|
+
const combined = [];
|
|
4520
|
+
for (const { env, connMap, propMap } of byEnv.values()) {
|
|
4521
|
+
env.connections = { connection: Array.from(connMap.values()) };
|
|
4522
|
+
env.processProperties = {
|
|
4523
|
+
ProcessProperty: [{
|
|
4524
|
+
id: "combined",
|
|
4525
|
+
name: "Process Properties",
|
|
4526
|
+
ProcessPropertyValue: Array.from(propMap.values())
|
|
4527
|
+
}]
|
|
4528
|
+
};
|
|
4529
|
+
combined.push(env);
|
|
4530
|
+
}
|
|
4531
|
+
return { combined, conflicts };
|
|
4532
|
+
}
|
|
4533
|
+
|
|
4534
|
+
// lib/helpers/normalizeConnections.ts
|
|
4535
|
+
function normalizeConnections(c) {
|
|
4536
|
+
const list = c?.connection ?? [];
|
|
4537
|
+
return { connection: [...list] };
|
|
4538
|
+
}
|
|
4539
|
+
|
|
4540
|
+
// lib/helpers/normalizeProcessProperties.ts
|
|
4541
|
+
function normalizeProcessProperties(p) {
|
|
4542
|
+
const src = p?.ProcessProperty;
|
|
4543
|
+
const groups = Array.isArray(src) ? src : [];
|
|
4544
|
+
return {
|
|
4545
|
+
ProcessProperty: groups.map((g) => ({
|
|
4546
|
+
...g,
|
|
4547
|
+
ProcessPropertyValue: [...g?.ProcessPropertyValue ?? []]
|
|
4548
|
+
}))
|
|
4549
|
+
};
|
|
4550
|
+
}
|
|
4551
|
+
|
|
4552
|
+
// lib/helpers/indexCombined.ts
|
|
4553
|
+
function indexCombined(combined) {
|
|
4554
|
+
const connKeyOf = (c, i) => c.id || (c.name ? `name:${c.name}` : `__conn_${i}`);
|
|
4555
|
+
const hasId = (x) => typeof x.id === "string" && x.id.length > 0;
|
|
4556
|
+
const hasKey = (x) => typeof x.key === "string" && x.key.length > 0;
|
|
4557
|
+
const byEnvConnField = /* @__PURE__ */ new Map();
|
|
4558
|
+
const byEnvPropKey = /* @__PURE__ */ new Map();
|
|
4559
|
+
for (const envExt of combined) {
|
|
4560
|
+
const envId = envExt.environmentId;
|
|
4561
|
+
if (!envId) continue;
|
|
4562
|
+
const connIndex = byEnvConnField.get(envId) ?? /* @__PURE__ */ new Map();
|
|
4563
|
+
(envExt.connections?.connection ?? []).forEach((c, i) => {
|
|
4564
|
+
const k = connKeyOf(c, i);
|
|
4565
|
+
const fieldIndex = connIndex.get(k) ?? /* @__PURE__ */ new Map();
|
|
4566
|
+
(c.field ?? []).forEach((f) => {
|
|
4567
|
+
if (hasId(f)) fieldIndex.set(f.id, f);
|
|
4568
|
+
});
|
|
4569
|
+
connIndex.set(k, fieldIndex);
|
|
4570
|
+
});
|
|
4571
|
+
byEnvConnField.set(envId, connIndex);
|
|
4572
|
+
const propIndex = byEnvPropKey.get(envId) ?? /* @__PURE__ */ new Map();
|
|
4573
|
+
(envExt.processProperties?.ProcessProperty ?? []).forEach((grp) => {
|
|
4574
|
+
(grp.ProcessPropertyValue ?? []).forEach((v) => {
|
|
4575
|
+
if (hasKey(v)) propIndex.set(v.key, v);
|
|
4576
|
+
});
|
|
4577
|
+
});
|
|
4578
|
+
byEnvPropKey.set(envId, propIndex);
|
|
4579
|
+
}
|
|
4580
|
+
return { byEnvConnField, byEnvPropKey };
|
|
4581
|
+
}
|
|
4582
|
+
|
|
4583
|
+
// lib/helpers/applyFieldEdit.ts
|
|
4584
|
+
function applyFieldEdit(orig, edited) {
|
|
4585
|
+
const sameStr = (a, b) => (a ?? "") === (b ?? "");
|
|
4586
|
+
if (!edited) return orig;
|
|
4587
|
+
const out = { ...orig };
|
|
4588
|
+
if (orig.usesEncryption) {
|
|
4589
|
+
const newVal = edited.value ?? "";
|
|
4590
|
+
if (newVal.trim().length) {
|
|
4591
|
+
out.value = newVal;
|
|
4592
|
+
out.encryptedValueSet = true;
|
|
4593
|
+
out.useDefault = false;
|
|
4594
|
+
}
|
|
4595
|
+
return out;
|
|
4596
|
+
}
|
|
4597
|
+
if (!sameStr(orig.value, edited.value)) {
|
|
4598
|
+
out.value = edited.value ?? "";
|
|
4599
|
+
out.useDefault = false;
|
|
4600
|
+
}
|
|
4601
|
+
return out;
|
|
4602
|
+
}
|
|
4603
|
+
|
|
4604
|
+
// lib/helpers/planBackport.ts
|
|
4605
|
+
function planBackport(originals, combinedEdited) {
|
|
4606
|
+
const sameStr = (a, b) => (a ?? "") === (b ?? "");
|
|
4607
|
+
const connKeyOf = (c, i) => c.id || (c.name ? `name:${c.name}` : `__conn_${i}`);
|
|
4608
|
+
const hasId = (x) => typeof x.id === "string" && x.id.length > 0;
|
|
4609
|
+
const hasKey = (x) => typeof x.key === "string" && x.key.length > 0;
|
|
4610
|
+
const idx = indexCombined(combinedEdited);
|
|
4611
|
+
const plans = [];
|
|
4612
|
+
for (const ext of originals) {
|
|
4613
|
+
const envId = ext.environmentId;
|
|
4614
|
+
if (!envId) continue;
|
|
4615
|
+
const editedConnIndex = idx.byEnvConnField.get(envId) ?? /* @__PURE__ */ new Map();
|
|
4616
|
+
const editedPropIndex = idx.byEnvPropKey.get(envId) ?? /* @__PURE__ */ new Map();
|
|
4617
|
+
let connChanges = 0;
|
|
4618
|
+
let propChanges = 0;
|
|
4619
|
+
const next = {
|
|
4620
|
+
...ext,
|
|
4621
|
+
connections: normalizeConnections(ext.connections),
|
|
4622
|
+
processProperties: normalizeProcessProperties(ext.processProperties)
|
|
4623
|
+
};
|
|
4624
|
+
const connsArr = next.connections.connection ?? [];
|
|
4625
|
+
connsArr.forEach((c, ci) => {
|
|
4626
|
+
const k = connKeyOf(c, ci);
|
|
4627
|
+
const editedFields = editedConnIndex.get(k);
|
|
4628
|
+
if (!editedFields) return;
|
|
4629
|
+
const fields = c.field ?? [];
|
|
4630
|
+
const updatedFields = fields.map((f) => {
|
|
4631
|
+
if (!hasId(f)) return f;
|
|
4632
|
+
const edited = editedFields.get(f.id);
|
|
4633
|
+
if (!edited) return f;
|
|
4634
|
+
const after = applyFieldEdit(f, edited);
|
|
4635
|
+
if (after !== f && !sameStr(f.value, after.value)) connChanges++;
|
|
4636
|
+
return after;
|
|
4637
|
+
});
|
|
4638
|
+
c.field = updatedFields;
|
|
4639
|
+
});
|
|
4640
|
+
const groups = next.processProperties.ProcessProperty ?? [];
|
|
4641
|
+
groups.forEach((grp) => {
|
|
4642
|
+
const vals = grp.ProcessPropertyValue ?? [];
|
|
4643
|
+
const updatedVals = vals.map((v) => {
|
|
4644
|
+
if (!hasKey(v)) return v;
|
|
4645
|
+
const edited = editedPropIndex.get(v.key);
|
|
4646
|
+
if (!edited) return v;
|
|
4647
|
+
const a = v.value ?? "";
|
|
4648
|
+
const b = edited.value ?? "";
|
|
4649
|
+
if (!sameStr(a, b)) {
|
|
4650
|
+
propChanges++;
|
|
4651
|
+
return { ...v, value: b, useDefault: false };
|
|
4652
|
+
}
|
|
4653
|
+
return v;
|
|
4654
|
+
});
|
|
4655
|
+
grp.ProcessPropertyValue = updatedVals;
|
|
4656
|
+
});
|
|
4657
|
+
const changed = connChanges + propChanges > 0;
|
|
4658
|
+
plans.push({
|
|
4659
|
+
original: ext,
|
|
4660
|
+
payload: changed ? { ...next, partial: true } : null,
|
|
4661
|
+
changes: { connections: connChanges, properties: propChanges }
|
|
4662
|
+
});
|
|
4663
|
+
}
|
|
4664
|
+
return plans;
|
|
4665
|
+
}
|
|
4666
|
+
|
|
4667
|
+
// lib/helpers/updateEnvironmentExtensionsPartial.ts
|
|
4668
|
+
async function updateEnvironmentExtensionsPartial(httpRequest, extension) {
|
|
4669
|
+
const extensionId = extension?.id ?? "";
|
|
4670
|
+
if (!extensionId) {
|
|
4671
|
+
throw Object.assign(new Error("Code [3004] - extension.id is required for update"), { status: 400 });
|
|
4672
|
+
}
|
|
4673
|
+
const payload = { ...extension, partial: true };
|
|
4674
|
+
return updateEnvironmentExtensions(httpRequest, extensionId, payload);
|
|
4675
|
+
}
|
|
4676
|
+
async function updateEnvironmentExtensions(httpRequest, id, requestBody) {
|
|
4677
|
+
return httpRequest.request({
|
|
4678
|
+
method: "POST",
|
|
4679
|
+
url: "/EnvironmentExtensions/{id}",
|
|
4680
|
+
path: {
|
|
4681
|
+
"id": id
|
|
4682
|
+
},
|
|
4683
|
+
body: requestBody,
|
|
4684
|
+
mediaType: "application/json",
|
|
4685
|
+
errors: {
|
|
4686
|
+
403: `Missing or incorrect authentication credentials.
|
|
4687
|
+
To know the action to be taken for this and the other error responses (410, 503, etc), refer to [API Errors](#section/Introduction/API-errors)`
|
|
4688
|
+
}
|
|
4689
|
+
});
|
|
4690
|
+
}
|
|
4691
|
+
|
|
4692
|
+
// lib/helpers/updateEnvironmentExtensionsBatch.ts
|
|
4693
|
+
async function updateEnvironmentExtensionsBatch(httpRequest, plans) {
|
|
4694
|
+
let updated = 0;
|
|
4695
|
+
let skipped = 0;
|
|
4696
|
+
let result = {};
|
|
4697
|
+
const failures = [];
|
|
4698
|
+
for (const plan of plans) {
|
|
4699
|
+
const { payload, original } = plan;
|
|
4700
|
+
if (!payload) {
|
|
4701
|
+
skipped++;
|
|
4702
|
+
continue;
|
|
4703
|
+
}
|
|
4704
|
+
try {
|
|
4705
|
+
result = await updateEnvironmentExtensionsPartial(httpRequest, payload);
|
|
4706
|
+
updated++;
|
|
4707
|
+
} catch (e) {
|
|
4708
|
+
failures.push({
|
|
4709
|
+
id: original?.id,
|
|
4710
|
+
groupId: original?.extensionGroupId,
|
|
4711
|
+
error: e?.message ?? "Unknown update error"
|
|
4712
|
+
});
|
|
4713
|
+
}
|
|
4714
|
+
}
|
|
4715
|
+
return { updated, skipped, failed: failures.length, failures, updatedExtensions: result };
|
|
4716
|
+
}
|
|
4717
|
+
|
|
4718
|
+
// lib/helpers/generateOauth2UrlRequestSoap.ts
|
|
4719
|
+
var esc = (s) => s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
4720
|
+
function generateOauth2UrlSoapXml(environmentId, connectionId, extensionGroupId, oAuthFieldId, clientId, clientSecret) {
|
|
4721
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
4722
|
+
<bns:EnvironmentOAuth2AccessTokenExtensionGenerationRequest
|
|
4723
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
4724
|
+
xmlns:bns="http://api.platform.boomi.com/"
|
|
4725
|
+
environmentId="${esc(environmentId)}"
|
|
4726
|
+
connectionId="${esc(connectionId)}"
|
|
4727
|
+
extensionGroupId="${esc(extensionGroupId)}"
|
|
4728
|
+
oAuthFieldId="${esc(oAuthFieldId)}"
|
|
4729
|
+
clientId="${esc(clientId)}"
|
|
4730
|
+
clientSecret="${esc(clientSecret)}"
|
|
4731
|
+
/>`;
|
|
4732
|
+
}
|
|
4733
|
+
|
|
4157
4734
|
// lib/services/EnvironmentExtensionsService.ts
|
|
4158
4735
|
var EnvironmentExtensionsService = class {
|
|
4159
4736
|
constructor(httpRequest) {
|
|
@@ -4286,20 +4863,454 @@ var EnvironmentExtensionsService = class {
|
|
|
4286
4863
|
* @returns EnvironmentExtensionsQueryResponse Successful request and response.
|
|
4287
4864
|
* @throws ApiError
|
|
4288
4865
|
*/
|
|
4289
|
-
|
|
4290
|
-
|
|
4866
|
+
async fetchOauth2Url(integrationPackInstanceId, environmentId, connectionId, oAuthFieldId, clientId, clientSecret) {
|
|
4867
|
+
const procResp = await fetchProcesses(this.httpRequest, integrationPackInstanceId);
|
|
4868
|
+
const firstProcessId = procResp.result?.[0]?.id;
|
|
4869
|
+
if (!firstProcessId) {
|
|
4870
|
+
throw new Error(`No processes found for integrationPackInstanceId: ${integrationPackInstanceId}`);
|
|
4871
|
+
}
|
|
4872
|
+
const requestXml = generateOauth2UrlSoapXml(
|
|
4873
|
+
environmentId,
|
|
4874
|
+
connectionId,
|
|
4875
|
+
firstProcessId,
|
|
4876
|
+
oAuthFieldId,
|
|
4877
|
+
clientId,
|
|
4878
|
+
clientSecret
|
|
4879
|
+
);
|
|
4880
|
+
const resp = await this.httpRequest.request({
|
|
4291
4881
|
method: "POST",
|
|
4292
4882
|
url: "/EnvironmentOAuth2AccessTokenExtensionGenerationRequest/execute",
|
|
4293
|
-
body:
|
|
4294
|
-
mediaType: "application/
|
|
4883
|
+
body: requestXml,
|
|
4884
|
+
mediaType: "application/soap+xml",
|
|
4295
4885
|
errors: {
|
|
4296
4886
|
403: `Missing or incorrect authentication credentials.
|
|
4297
4887
|
To know the action to be taken for this and the other error responses (410, 503, etc), refer to [API Errors](#section/Introduction/API-errors)`
|
|
4298
4888
|
}
|
|
4299
4889
|
});
|
|
4890
|
+
if (!resp || !resp.authorizationCodeRequestUrl) {
|
|
4891
|
+
throw new Error(`No authorization URL found in SOAP response for integrationPackInstanceId: ${integrationPackInstanceId}`);
|
|
4892
|
+
}
|
|
4893
|
+
return {
|
|
4894
|
+
numberOfResults: 1,
|
|
4895
|
+
result: {
|
|
4896
|
+
authorizationCodeRequestUrl: resp.authorizationCodeRequestUrl
|
|
4897
|
+
}
|
|
4898
|
+
};
|
|
4899
|
+
}
|
|
4900
|
+
/**
|
|
4901
|
+
* High-level: create plans from combined edits and apply them ---
|
|
4902
|
+
* Uses the SDK’s own planBackport() already in this class.
|
|
4903
|
+
*/
|
|
4904
|
+
async updateEnvironmentExtensionsFromCombined(originals, combinedEdited) {
|
|
4905
|
+
const plans = planBackport(originals, combinedEdited);
|
|
4906
|
+
return updateEnvironmentExtensionsBatch(this.httpRequest, plans);
|
|
4907
|
+
}
|
|
4908
|
+
/**
|
|
4909
|
+
* Browse environment extensions for given environments
|
|
4910
|
+
* @param requestBody Possible properties include: environmentId, environmentIds, integrationPackInstanceId
|
|
4911
|
+
* @returns EnvironmentExtensionQueryResponse Successful request and response.
|
|
4912
|
+
* @throws ApiError
|
|
4913
|
+
*/
|
|
4914
|
+
async fetchEnvironmentExtensions(params) {
|
|
4915
|
+
const { integrationPackInstanceId, environmentId, environmentIds } = params;
|
|
4916
|
+
if (!integrationPackInstanceId) {
|
|
4917
|
+
throw Object.assign(new Error("integrationPackInstanceId is required"), { status: 400 });
|
|
4918
|
+
}
|
|
4919
|
+
const targets = environmentId ? [environmentId] : Array.isArray(environmentIds) && environmentIds.length ? environmentIds : [];
|
|
4920
|
+
if (!targets.length) {
|
|
4921
|
+
throw Object.assign(
|
|
4922
|
+
new Error("environmentId or environmentIds must be provided"),
|
|
4923
|
+
{ status: 400 }
|
|
4924
|
+
);
|
|
4925
|
+
}
|
|
4926
|
+
const chunks = [];
|
|
4927
|
+
for (const envId of targets) {
|
|
4928
|
+
const list = await fetchExtensions(this.httpRequest, integrationPackInstanceId, envId);
|
|
4929
|
+
chunks.push(list ?? []);
|
|
4930
|
+
}
|
|
4931
|
+
const items = [].concat(...chunks);
|
|
4932
|
+
const { combined } = combineEnvironmentExtensions(items);
|
|
4933
|
+
return {
|
|
4934
|
+
numberOfResults: items?.length || 0,
|
|
4935
|
+
result: items || [],
|
|
4936
|
+
combined: combined || []
|
|
4937
|
+
};
|
|
4938
|
+
}
|
|
4939
|
+
/** Fetch EnvironmentExtensionConnectionStatus for a given connection and fieldId. */
|
|
4940
|
+
async fetchExtensionConnectionStatus(integrationPackInstanceId, environmentId, connectionId, fieldId) {
|
|
4941
|
+
let connected = false;
|
|
4942
|
+
const resp = await fetchProcesses(this.httpRequest, integrationPackInstanceId);
|
|
4943
|
+
if (!resp?.result) {
|
|
4944
|
+
throw new Error(
|
|
4945
|
+
`No processes found for integrationPackInstanceId: ${integrationPackInstanceId}`
|
|
4946
|
+
);
|
|
4947
|
+
}
|
|
4948
|
+
for (const process of resp.result) {
|
|
4949
|
+
if (!process.id) {
|
|
4950
|
+
throw new Error(
|
|
4951
|
+
`Missing process ID for integrationPackInstanceId: ${integrationPackInstanceId}`
|
|
4952
|
+
);
|
|
4953
|
+
}
|
|
4954
|
+
const exts = await fetchExtensionsForPair(this.httpRequest, process.id, environmentId);
|
|
4955
|
+
for (const ext of exts) {
|
|
4956
|
+
const conns = ext.connections?.connection ?? [];
|
|
4957
|
+
for (const conn of conns) {
|
|
4958
|
+
if (conn.id === connectionId) {
|
|
4959
|
+
const fields = conn.field ?? [];
|
|
4960
|
+
for (const field of fields) {
|
|
4961
|
+
if (field.id === fieldId) {
|
|
4962
|
+
if (field.encryptedValueSet) {
|
|
4963
|
+
connected = true;
|
|
4964
|
+
}
|
|
4965
|
+
break;
|
|
4966
|
+
}
|
|
4967
|
+
}
|
|
4968
|
+
}
|
|
4969
|
+
}
|
|
4970
|
+
}
|
|
4971
|
+
}
|
|
4972
|
+
return connected;
|
|
4300
4973
|
}
|
|
4301
4974
|
};
|
|
4302
4975
|
|
|
4976
|
+
// lib/helpers/buildOnePayload.ts
|
|
4977
|
+
function buildOnePayload(mapId, containerId, sourceFields, targetFields) {
|
|
4978
|
+
const srcArray = Array.from(sourceFields.values());
|
|
4979
|
+
const tgtArray = Array.from(targetFields.values());
|
|
4980
|
+
const BrowseSettings = { containerId };
|
|
4981
|
+
if (srcArray.length) {
|
|
4982
|
+
BrowseSettings.SourceBrowse = { BrowseFields: srcArray };
|
|
4983
|
+
}
|
|
4984
|
+
if (tgtArray.length) {
|
|
4985
|
+
BrowseSettings.DestinationBrowse = { BrowseFields: tgtArray };
|
|
4986
|
+
}
|
|
4987
|
+
return {
|
|
4988
|
+
id: mapId,
|
|
4989
|
+
Map: { BrowseSettings }
|
|
4990
|
+
};
|
|
4991
|
+
}
|
|
4992
|
+
|
|
4993
|
+
// lib/helpers/buildBrowseRequests.ts
|
|
4994
|
+
async function buildBrowseRequests(candidates, opts = {}) {
|
|
4995
|
+
const { includeSessions = false, defaultValueForEmpty } = opts;
|
|
4996
|
+
const groups = /* @__PURE__ */ new Map();
|
|
4997
|
+
for (const c of candidates) {
|
|
4998
|
+
const mapId = c.mapId;
|
|
4999
|
+
const containerId = c.containerId;
|
|
5000
|
+
if (!mapId || !containerId || !c.paramName) continue;
|
|
5001
|
+
const key = `${mapId}|${containerId}`;
|
|
5002
|
+
let g = groups.get(key);
|
|
5003
|
+
if (!g) {
|
|
5004
|
+
g = {
|
|
5005
|
+
candidate: c,
|
|
5006
|
+
mapId,
|
|
5007
|
+
containerId,
|
|
5008
|
+
sourceFields: /* @__PURE__ */ new Map(),
|
|
5009
|
+
targetFields: /* @__PURE__ */ new Map()
|
|
5010
|
+
};
|
|
5011
|
+
groups.set(key, g);
|
|
5012
|
+
}
|
|
5013
|
+
const value = c.paramValue ?? (defaultValueForEmpty ? defaultValueForEmpty(c) : void 0);
|
|
5014
|
+
const field = { name: c.paramName, value };
|
|
5015
|
+
if (c.candidateSource === "source") {
|
|
5016
|
+
g.sourceFields.set(c.paramName, field);
|
|
5017
|
+
} else {
|
|
5018
|
+
g.targetFields.set(c.paramName, field);
|
|
5019
|
+
}
|
|
5020
|
+
}
|
|
5021
|
+
const out = [];
|
|
5022
|
+
for (const g of groups.values()) {
|
|
5023
|
+
out.push({
|
|
5024
|
+
candidate: g.candidate,
|
|
5025
|
+
request: buildOnePayload(
|
|
5026
|
+
g.mapId,
|
|
5027
|
+
g.containerId,
|
|
5028
|
+
g.sourceFields,
|
|
5029
|
+
g.targetFields
|
|
5030
|
+
)
|
|
5031
|
+
});
|
|
5032
|
+
}
|
|
5033
|
+
return out;
|
|
5034
|
+
}
|
|
5035
|
+
|
|
5036
|
+
// lib/helpers/executeEnvironmentMapExtension.ts
|
|
5037
|
+
async function executeEnvironmentMapExtension(httpRequest, id, requestBody) {
|
|
5038
|
+
return httpRequest.request({
|
|
5039
|
+
method: "POST",
|
|
5040
|
+
url: "/EnvironmentMapExtension/execute/{id}",
|
|
5041
|
+
path: {
|
|
5042
|
+
"id": id
|
|
5043
|
+
},
|
|
5044
|
+
body: requestBody,
|
|
5045
|
+
mediaType: "application/json",
|
|
5046
|
+
overrideMode: "force-child",
|
|
5047
|
+
errors: {
|
|
5048
|
+
403: `Missing or incorrect authentication credentials.
|
|
5049
|
+
To know the action to be taken for this and the other error responses (410, 503, etc), refer to [API Errors](#section/Introduction/API-errors)`
|
|
5050
|
+
}
|
|
5051
|
+
});
|
|
5052
|
+
}
|
|
5053
|
+
|
|
5054
|
+
// lib/helpers/extractBrowseSessionId.ts
|
|
5055
|
+
function extractBrowseSessionId(resp) {
|
|
5056
|
+
const src = resp?.Map?.BrowseSettings?.SourceBrowse?.sessionId;
|
|
5057
|
+
if (typeof src === "string" && src.length > 0) {
|
|
5058
|
+
return { sessionId: src, kind: "source" };
|
|
5059
|
+
}
|
|
5060
|
+
const dest = resp?.Map?.BrowseSettings?.DestinationBrowse?.sessionId;
|
|
5061
|
+
if (typeof dest === "string" && dest.length > 0) {
|
|
5062
|
+
return { sessionId: dest, kind: "target" };
|
|
5063
|
+
}
|
|
5064
|
+
return { sessionId: "", kind: null };
|
|
5065
|
+
}
|
|
5066
|
+
|
|
5067
|
+
// lib/helpers/executeMapExtension.ts
|
|
5068
|
+
async function executeMapExtension(httpRequest, request2) {
|
|
5069
|
+
const response = await executeEnvironmentMapExtension(
|
|
5070
|
+
httpRequest,
|
|
5071
|
+
request2.id,
|
|
5072
|
+
request2
|
|
5073
|
+
);
|
|
5074
|
+
console.log("Execute map extension response:", JSON.stringify(response, null, 2));
|
|
5075
|
+
return extractBrowseSessionId(response);
|
|
5076
|
+
}
|
|
5077
|
+
|
|
5078
|
+
// lib/helpers/fetchEnvironmentMapExtensionSummary.ts
|
|
5079
|
+
async function fetchEnvironmentMapExtensionsSummary(httpRequest, requestBody) {
|
|
5080
|
+
return httpRequest.request({
|
|
5081
|
+
method: "POST",
|
|
5082
|
+
url: "/EnvironmentMapExtensionsSummary/query",
|
|
5083
|
+
body: requestBody,
|
|
5084
|
+
mediaType: "application/json",
|
|
5085
|
+
errors: {
|
|
5086
|
+
403: `Missing or incorrect authentication credentials.
|
|
5087
|
+
To know the action to be taken for this and the other error responses (410, 503, etc), refer to [API Errors](#section/Introduction/API-errors)`
|
|
5088
|
+
}
|
|
5089
|
+
});
|
|
5090
|
+
}
|
|
5091
|
+
|
|
5092
|
+
// lib/helpers/fetchMapExtensionSummaries.ts
|
|
5093
|
+
async function fetchMapExtensionSummaries(httpRequest, processId, environmentId) {
|
|
5094
|
+
const summaryMap = /* @__PURE__ */ new Map();
|
|
5095
|
+
const summaryFilter = nestedQueryFilter(
|
|
5096
|
+
[
|
|
5097
|
+
{ property: "environmentId", operator: "EQUALS", value: environmentId },
|
|
5098
|
+
{ property: "extensionGroupId", operator: "EQUALS", value: processId }
|
|
5099
|
+
],
|
|
5100
|
+
"and"
|
|
5101
|
+
);
|
|
5102
|
+
const summaryResponse = await fetchEnvironmentMapExtensionsSummary(
|
|
5103
|
+
httpRequest,
|
|
5104
|
+
summaryFilter
|
|
5105
|
+
);
|
|
5106
|
+
let summaries = summaryResponse?.result || [];
|
|
5107
|
+
return summaries;
|
|
5108
|
+
}
|
|
5109
|
+
|
|
5110
|
+
// lib/helpers/fetchExtensionsSummariesByProcessAndEnvironment.ts
|
|
5111
|
+
async function fetchExtensionsSummariesByProcessAndEnvironment(httpRequest, processId, environmentId) {
|
|
5112
|
+
const summaryMap = /* @__PURE__ */ new Map();
|
|
5113
|
+
let summaries = await fetchMapExtensionSummaries(httpRequest, processId, environmentId);
|
|
5114
|
+
for (const summary of summaries) {
|
|
5115
|
+
if (summary.id && !summaryMap.has(summary.id)) {
|
|
5116
|
+
summaryMap.set(summary.id, summary);
|
|
5117
|
+
}
|
|
5118
|
+
}
|
|
5119
|
+
summaries = Array.from(summaryMap.values());
|
|
5120
|
+
return summaries || [];
|
|
5121
|
+
}
|
|
5122
|
+
|
|
5123
|
+
// lib/helpers/fetchAllSummaries.ts
|
|
5124
|
+
async function fetchAllSummaries(httpRequest, integrationPackInstanceId, environmentId) {
|
|
5125
|
+
const resp = await fetchProcesses(httpRequest, integrationPackInstanceId);
|
|
5126
|
+
const allSummaries = [];
|
|
5127
|
+
if (!resp?.result) {
|
|
5128
|
+
throw new Error(
|
|
5129
|
+
`Code [2002] - No processes found for integrationPackInstanceId: ${integrationPackInstanceId}`
|
|
5130
|
+
);
|
|
5131
|
+
}
|
|
5132
|
+
const processes = resp.result;
|
|
5133
|
+
for (const process of processes) {
|
|
5134
|
+
if (!process.id) continue;
|
|
5135
|
+
const mapSummaries = await fetchExtensionsSummariesByProcessAndEnvironment(httpRequest, process.id, environmentId);
|
|
5136
|
+
allSummaries.push(...mapSummaries.filter(Boolean));
|
|
5137
|
+
}
|
|
5138
|
+
const deduped = Array.from(new Map(allSummaries.map((s) => [s.id, s])).values());
|
|
5139
|
+
return deduped;
|
|
5140
|
+
}
|
|
5141
|
+
|
|
5142
|
+
// lib/helpers/fetchContainerId.ts
|
|
5143
|
+
async function fetchContainerId(httpRequest, environmentId) {
|
|
5144
|
+
const aFilter = queryFilter(
|
|
5145
|
+
"environmentId",
|
|
5146
|
+
"EQUALS",
|
|
5147
|
+
[environmentId]
|
|
5148
|
+
);
|
|
5149
|
+
const resp = await httpRequest.request({
|
|
5150
|
+
method: "POST",
|
|
5151
|
+
url: "/EnvironmentAtomAttachment/query",
|
|
5152
|
+
mediaType: "application/json",
|
|
5153
|
+
body: aFilter
|
|
5154
|
+
});
|
|
5155
|
+
return resp?.result?.[0]?.atomId ?? resp?.result?.[0]?.containerId ?? "";
|
|
5156
|
+
}
|
|
5157
|
+
|
|
5158
|
+
// lib/helpers/findConnectionName.ts
|
|
5159
|
+
function findConnectionName(connectionId, exts) {
|
|
5160
|
+
const list = Array.isArray(exts) ? exts : [exts];
|
|
5161
|
+
for (const e of list) {
|
|
5162
|
+
const match = e?.connections?.connection?.find((c) => c?.id === connectionId);
|
|
5163
|
+
if (match?.name) return match.name;
|
|
5164
|
+
}
|
|
5165
|
+
return null;
|
|
5166
|
+
}
|
|
5167
|
+
|
|
5168
|
+
// lib/helpers/findConnectionFieldValue.ts
|
|
5169
|
+
function findConnectionFieldValue(connectionId, paramName, exts) {
|
|
5170
|
+
const list = Array.isArray(exts) ? exts : [exts];
|
|
5171
|
+
for (const e of list) {
|
|
5172
|
+
const conns = e?.connections?.connection ?? [];
|
|
5173
|
+
for (const c of conns) {
|
|
5174
|
+
if (!c || c.id !== connectionId) continue;
|
|
5175
|
+
const fields = c.field ?? [];
|
|
5176
|
+
const match = fields.find((f) => {
|
|
5177
|
+
const fid = f?.id ?? f?.["@id"];
|
|
5178
|
+
const fname = f?.name ?? f?.["@name"];
|
|
5179
|
+
return fid === paramName || fname === paramName;
|
|
5180
|
+
});
|
|
5181
|
+
if (match) {
|
|
5182
|
+
const raw = match.value ?? "";
|
|
5183
|
+
return raw != null ? String(raw) : void 0;
|
|
5184
|
+
}
|
|
5185
|
+
}
|
|
5186
|
+
}
|
|
5187
|
+
return void 0;
|
|
5188
|
+
}
|
|
5189
|
+
|
|
5190
|
+
// lib/helpers/sessionFromSet.ts
|
|
5191
|
+
function sessionsFromSet(sets, sourceName, summary, containerId, environmentId, processId, originalExtensions, exts) {
|
|
5192
|
+
const asArray = (x) => x == null ? [] : Array.isArray(x) ? x : [x];
|
|
5193
|
+
return asArray(sets).filter((s) => !!s?.connectionId).flatMap((s) => {
|
|
5194
|
+
const connectionId = s.connectionId;
|
|
5195
|
+
const connectionName = findConnectionName(connectionId, originalExtensions) ?? "";
|
|
5196
|
+
const fieldNames = asArray(s?.BrowseField).map((bf) => bf?.name).filter((n) => !!n);
|
|
5197
|
+
return fieldNames.map((paramName) => {
|
|
5198
|
+
return {
|
|
5199
|
+
containerId,
|
|
5200
|
+
environmentId,
|
|
5201
|
+
processId,
|
|
5202
|
+
connectionId,
|
|
5203
|
+
connectionName,
|
|
5204
|
+
candidateSource: sourceName,
|
|
5205
|
+
paramName,
|
|
5206
|
+
mapId: summary.id ?? "",
|
|
5207
|
+
paramValue: exts ? findConnectionFieldValue(connectionId, paramName, exts) ?? "" : ""
|
|
5208
|
+
};
|
|
5209
|
+
});
|
|
5210
|
+
});
|
|
5211
|
+
}
|
|
5212
|
+
|
|
5213
|
+
// lib/helpers/extractBrowseCandidateFromSummary.ts
|
|
5214
|
+
function extractBrowseCandidateFromSummary(s, containerId, environmentId, processId, originalExtensions, extensions) {
|
|
5215
|
+
return [
|
|
5216
|
+
...sessionsFromSet(s.SourceFieldSet, "source", s, containerId, environmentId, processId, originalExtensions, extensions),
|
|
5217
|
+
...sessionsFromSet(s.DestinationFieldSet, "target", s, containerId, environmentId, processId, originalExtensions, extensions)
|
|
5218
|
+
];
|
|
5219
|
+
}
|
|
5220
|
+
|
|
5221
|
+
// lib/helpers/buildBrowseCandidates.ts
|
|
5222
|
+
async function buildBrowseCandidates(httpRequest, summaries, originalExtensions, updatedExtensions, environmentId) {
|
|
5223
|
+
const containerId = await fetchContainerId(httpRequest, environmentId);
|
|
5224
|
+
if (!containerId) {
|
|
5225
|
+
throw new Error(`Atom attachment not found for environment: ${environmentId}`);
|
|
5226
|
+
}
|
|
5227
|
+
const candidates = [];
|
|
5228
|
+
for (const s of summaries) {
|
|
5229
|
+
candidates.push(
|
|
5230
|
+
...extractBrowseCandidateFromSummary(
|
|
5231
|
+
s,
|
|
5232
|
+
containerId,
|
|
5233
|
+
environmentId,
|
|
5234
|
+
s.processId || "",
|
|
5235
|
+
originalExtensions,
|
|
5236
|
+
updatedExtensions
|
|
5237
|
+
)
|
|
5238
|
+
);
|
|
5239
|
+
}
|
|
5240
|
+
return candidates;
|
|
5241
|
+
}
|
|
5242
|
+
|
|
5243
|
+
// lib/helpers/fetchBrowseCandidateForPair.ts
|
|
5244
|
+
async function fetchBrowseCandidatesForPair(httpRequest, summary, environmentId, integrationPackInstanceId) {
|
|
5245
|
+
const candidates = [];
|
|
5246
|
+
const extensions = await fetchExtensions(httpRequest, integrationPackInstanceId, environmentId);
|
|
5247
|
+
const containerId = await fetchContainerId(httpRequest, environmentId);
|
|
5248
|
+
if (!containerId) {
|
|
5249
|
+
throw new Error(`Atom attachment not found for environment: ${environmentId}`);
|
|
5250
|
+
}
|
|
5251
|
+
candidates.push(
|
|
5252
|
+
...extractBrowseCandidateFromSummary(
|
|
5253
|
+
summary,
|
|
5254
|
+
containerId,
|
|
5255
|
+
environmentId,
|
|
5256
|
+
summary.processId || "",
|
|
5257
|
+
extensions
|
|
5258
|
+
)
|
|
5259
|
+
);
|
|
5260
|
+
return candidates;
|
|
5261
|
+
}
|
|
5262
|
+
|
|
5263
|
+
// lib/helpers/fetchEnvironmentMapExtension.ts
|
|
5264
|
+
async function fetchEnvironmentMapExtension(httpRequest, id) {
|
|
5265
|
+
return httpRequest.request({
|
|
5266
|
+
method: "GET",
|
|
5267
|
+
url: "/EnvironmentMapExtension/{id}",
|
|
5268
|
+
path: {
|
|
5269
|
+
"id": id
|
|
5270
|
+
},
|
|
5271
|
+
errors: {
|
|
5272
|
+
403: `Missing or incorrect authentication credentials.
|
|
5273
|
+
To know the action to be taken for this and the other error responses (410, 503, etc), refer to [API Errors](#section/Introduction/API-errors)`
|
|
5274
|
+
}
|
|
5275
|
+
});
|
|
5276
|
+
}
|
|
5277
|
+
|
|
5278
|
+
// lib/helpers/fetchExtensionsByProcessAndEnvironment.ts
|
|
5279
|
+
async function fetchExtensionsByProcessAndEnvironment(httpRequest, processId, environmentId, integrationPackInstanceId) {
|
|
5280
|
+
let summaries = await fetchExtensionsSummariesByProcessAndEnvironment(httpRequest, processId, environmentId);
|
|
5281
|
+
const allMaps = [];
|
|
5282
|
+
const missingCandidates = [];
|
|
5283
|
+
let requiresBrowseSession = false;
|
|
5284
|
+
const mapExtensions = await Promise.all(
|
|
5285
|
+
summaries.map(async (summary) => {
|
|
5286
|
+
const hasBrowse = !!summary?.SourceFieldSet?.BrowseField?.length || !!summary?.DestinationFieldSet?.BrowseField?.length;
|
|
5287
|
+
const map = await fetchEnvironmentMapExtension(
|
|
5288
|
+
httpRequest,
|
|
5289
|
+
summary.id
|
|
5290
|
+
);
|
|
5291
|
+
if (hasBrowse) {
|
|
5292
|
+
requiresBrowseSession = true;
|
|
5293
|
+
const candidates = await fetchBrowseCandidatesForPair(
|
|
5294
|
+
httpRequest,
|
|
5295
|
+
summary,
|
|
5296
|
+
environmentId,
|
|
5297
|
+
integrationPackInstanceId
|
|
5298
|
+
);
|
|
5299
|
+
const missing = candidates.filter((c) => !c.sessionId);
|
|
5300
|
+
if (missing.length) {
|
|
5301
|
+
missingCandidates.push(...missing);
|
|
5302
|
+
}
|
|
5303
|
+
}
|
|
5304
|
+
allMaps.push({
|
|
5305
|
+
map,
|
|
5306
|
+
requiresBrowseSession,
|
|
5307
|
+
candidates: missingCandidates.length ? missingCandidates : []
|
|
5308
|
+
});
|
|
5309
|
+
})
|
|
5310
|
+
);
|
|
5311
|
+
return allMaps;
|
|
5312
|
+
}
|
|
5313
|
+
|
|
4303
5314
|
// lib/services/EnvironmentMapExtensionService.ts
|
|
4304
5315
|
var EnvironmentMapExtensionService = class {
|
|
4305
5316
|
constructor(httpRequest) {
|
|
@@ -4375,6 +5386,73 @@ var EnvironmentMapExtensionService = class {
|
|
|
4375
5386
|
}
|
|
4376
5387
|
});
|
|
4377
5388
|
}
|
|
5389
|
+
/** fetch all maps for an environment and integrationPackInstance */
|
|
5390
|
+
async fetchAllMaps(integrationPackInstanceId, environmentId) {
|
|
5391
|
+
const resp = await fetchProcesses(this.httpRequest, integrationPackInstanceId);
|
|
5392
|
+
const allMaps = [];
|
|
5393
|
+
if (!resp?.result) {
|
|
5394
|
+
throw new Error(
|
|
5395
|
+
`No processes found for integrationPackInstanceId: ${integrationPackInstanceId}`
|
|
5396
|
+
);
|
|
5397
|
+
}
|
|
5398
|
+
const processes = resp.result;
|
|
5399
|
+
for (const process of processes) {
|
|
5400
|
+
if (!process.id) continue;
|
|
5401
|
+
const mapExtensions = await fetchExtensionsByProcessAndEnvironment(this.httpRequest, process.id, environmentId, integrationPackInstanceId);
|
|
5402
|
+
allMaps.push(...mapExtensions.filter(Boolean));
|
|
5403
|
+
}
|
|
5404
|
+
const deduped = Array.from(new Map(allMaps.map((s) => [s.map.id, s])).values());
|
|
5405
|
+
return deduped;
|
|
5406
|
+
}
|
|
5407
|
+
/** fetch all maps for an environment and integrationPackInstance */
|
|
5408
|
+
updateEnvironmentMapExtension(requestBody) {
|
|
5409
|
+
return this.httpRequest.request({
|
|
5410
|
+
method: "POST",
|
|
5411
|
+
url: `/EnvironmentMapExtension/${requestBody.id}`,
|
|
5412
|
+
body: requestBody,
|
|
5413
|
+
mediaType: "application/json",
|
|
5414
|
+
errors: {
|
|
5415
|
+
403: `Missing or incorrect authentication credentials.
|
|
5416
|
+
To know the action to be taken for this and the other error responses (410, 503, etc), refer to [API Errors](#section/Introduction/API-errors)`
|
|
5417
|
+
}
|
|
5418
|
+
});
|
|
5419
|
+
}
|
|
5420
|
+
/** try to authenticate the maps for dynamic browsing
|
|
5421
|
+
* Todo: return both failed and succeeded candidates
|
|
5422
|
+
*/
|
|
5423
|
+
async executeDynamicBrowse(candidates) {
|
|
5424
|
+
const failedCandidates = [];
|
|
5425
|
+
const successCandidates = [];
|
|
5426
|
+
const filteredCandidates = candidates.filter((c) => c.paramValue?.trim());
|
|
5427
|
+
const resp = await buildBrowseRequests(filteredCandidates, { includeSessions: true });
|
|
5428
|
+
if (!resp) {
|
|
5429
|
+
return { failedCandidates, successCandidates };
|
|
5430
|
+
}
|
|
5431
|
+
for (const r of resp) {
|
|
5432
|
+
try {
|
|
5433
|
+
const { sessionId } = await executeMapExtension(this.httpRequest, r.request);
|
|
5434
|
+
if (!sessionId) {
|
|
5435
|
+
failedCandidates.push(r.candidate);
|
|
5436
|
+
}
|
|
5437
|
+
r.candidate.sessionId = sessionId;
|
|
5438
|
+
successCandidates.push(r.candidate);
|
|
5439
|
+
} catch (e) {
|
|
5440
|
+
failedCandidates.push(r.candidate);
|
|
5441
|
+
}
|
|
5442
|
+
}
|
|
5443
|
+
return { failedCandidates, successCandidates };
|
|
5444
|
+
}
|
|
5445
|
+
/** call execute on each map extension that contains a source or target browse */
|
|
5446
|
+
async executeMapFunctionBrowse(originals, updated, integrationPackInstanceId, environmentId) {
|
|
5447
|
+
const allSummaries = await fetchAllSummaries(
|
|
5448
|
+
this.httpRequest,
|
|
5449
|
+
integrationPackInstanceId,
|
|
5450
|
+
environmentId
|
|
5451
|
+
);
|
|
5452
|
+
const candidates = await buildBrowseCandidates(this.httpRequest, allSummaries, originals, updated, environmentId);
|
|
5453
|
+
const response = await this.executeDynamicBrowse(candidates);
|
|
5454
|
+
return response;
|
|
5455
|
+
}
|
|
4378
5456
|
};
|
|
4379
5457
|
|
|
4380
5458
|
// lib/services/EnvironmentMapExtensionExternalComponentService.ts
|
|
@@ -5073,6 +6151,59 @@ var ExecutionRequestService = class {
|
|
|
5073
6151
|
}
|
|
5074
6152
|
};
|
|
5075
6153
|
|
|
6154
|
+
// lib/helpers/withBackOff.ts
|
|
6155
|
+
async function withBackoff(fn, opts = {}) {
|
|
6156
|
+
const tries = opts.tries ?? 4;
|
|
6157
|
+
const baseMs = opts.baseMs ?? 200;
|
|
6158
|
+
const jitterMs = opts.jitterMs ?? 100;
|
|
6159
|
+
let attempt = 0;
|
|
6160
|
+
let lastError;
|
|
6161
|
+
while (attempt < tries) {
|
|
6162
|
+
try {
|
|
6163
|
+
return await fn();
|
|
6164
|
+
} catch (err) {
|
|
6165
|
+
lastError = err;
|
|
6166
|
+
const delay = baseMs * Math.pow(2, attempt) + Math.floor(Math.random() * jitterMs);
|
|
6167
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
6168
|
+
attempt++;
|
|
6169
|
+
}
|
|
6170
|
+
}
|
|
6171
|
+
throw lastError;
|
|
6172
|
+
}
|
|
6173
|
+
|
|
6174
|
+
// lib/helpers/runWithConcurrency.ts
|
|
6175
|
+
async function runWithConcurrency(tasks, maxConcurrent = 4) {
|
|
6176
|
+
const results = [];
|
|
6177
|
+
let i = 0;
|
|
6178
|
+
async function worker() {
|
|
6179
|
+
while (i < tasks.length) {
|
|
6180
|
+
const idx = i++;
|
|
6181
|
+
try {
|
|
6182
|
+
results[idx] = await tasks[idx]();
|
|
6183
|
+
} catch (err) {
|
|
6184
|
+
results[idx] = void 0;
|
|
6185
|
+
}
|
|
6186
|
+
}
|
|
6187
|
+
}
|
|
6188
|
+
const n = Math.max(1, Math.min(maxConcurrent, tasks.length));
|
|
6189
|
+
await Promise.all(new Array(n).fill(0).map(() => worker()));
|
|
6190
|
+
return results;
|
|
6191
|
+
}
|
|
6192
|
+
|
|
6193
|
+
// lib/helpers/fetchExecutionRecord.ts
|
|
6194
|
+
async function fetchExecutionRecord(httpRequest, requestBody) {
|
|
6195
|
+
return httpRequest.request({
|
|
6196
|
+
method: "POST",
|
|
6197
|
+
url: "/ExecutionRecord/query",
|
|
6198
|
+
body: requestBody,
|
|
6199
|
+
mediaType: "application/json",
|
|
6200
|
+
errors: {
|
|
6201
|
+
403: `Missing or incorrect authentication credentials.
|
|
6202
|
+
To know the action to be taken for this and the other error responses (410, 503, etc), refer to [API Errors](#section/Introduction/API-errors)`
|
|
6203
|
+
}
|
|
6204
|
+
});
|
|
6205
|
+
}
|
|
6206
|
+
|
|
5076
6207
|
// lib/services/ExecutionSummaryRecordService.ts
|
|
5077
6208
|
var ExecutionSummaryRecordService = class {
|
|
5078
6209
|
constructor(httpRequest) {
|
|
@@ -5116,6 +6247,55 @@ var ExecutionSummaryRecordService = class {
|
|
|
5116
6247
|
}
|
|
5117
6248
|
});
|
|
5118
6249
|
}
|
|
6250
|
+
async fetchExecutionRecordsByIntegrationPack(params) {
|
|
6251
|
+
const {
|
|
6252
|
+
integrationPackInstanceId,
|
|
6253
|
+
search = "",
|
|
6254
|
+
page = 1,
|
|
6255
|
+
pageSize = 20,
|
|
6256
|
+
maxRuns = 30,
|
|
6257
|
+
maxConcurrent = 4,
|
|
6258
|
+
backoff
|
|
6259
|
+
} = params;
|
|
6260
|
+
if (!integrationPackInstanceId) {
|
|
6261
|
+
throw new Error("Code [2002] - integrationPackInstanceId is required.");
|
|
6262
|
+
}
|
|
6263
|
+
const pResp = await withBackoff(
|
|
6264
|
+
() => fetchProcesses(this.httpRequest, integrationPackInstanceId),
|
|
6265
|
+
backoff
|
|
6266
|
+
);
|
|
6267
|
+
const processes = pResp?.result ?? [];
|
|
6268
|
+
if (!processes.length) {
|
|
6269
|
+
return { result: [], page, pageSize, numberOfResults: 0, totalPages: 1 };
|
|
6270
|
+
}
|
|
6271
|
+
const tasks = processes.filter((p) => !!p?.id).map((p) => {
|
|
6272
|
+
const rFilter = queryFilter("processId", "EQUALS", [String(p.id)]);
|
|
6273
|
+
return () => withBackoff(
|
|
6274
|
+
() => fetchExecutionRecord(this.httpRequest, rFilter).then((r) => r?.result ?? []),
|
|
6275
|
+
backoff
|
|
6276
|
+
).catch(() => []);
|
|
6277
|
+
});
|
|
6278
|
+
const perProcessLists = await runWithConcurrency(tasks, maxConcurrent);
|
|
6279
|
+
const all = perProcessLists.flat().filter(Boolean);
|
|
6280
|
+
if (!all.length) {
|
|
6281
|
+
return { result: [], page, pageSize, numberOfResults: 0, totalPages: 1 };
|
|
6282
|
+
}
|
|
6283
|
+
const needle = search.trim().toLowerCase();
|
|
6284
|
+
const filtered = needle ? all.filter((r) => (r?.message ?? "").toLowerCase().includes(needle)) : all;
|
|
6285
|
+
const toTs = (t) => t ? new Date(t).getTime() || 0 : 0;
|
|
6286
|
+
filtered.sort((a, b) => toTs(b.executionTime) - toTs(a.executionTime));
|
|
6287
|
+
const capped = filtered.slice(0, Math.max(1, maxRuns));
|
|
6288
|
+
const pages = Math.max(1, Math.ceil(capped.length / Math.max(1, pageSize)));
|
|
6289
|
+
const safePage = Math.min(Math.max(page, 1), pages);
|
|
6290
|
+
const start = (safePage - 1) * pageSize;
|
|
6291
|
+
const end = start + pageSize;
|
|
6292
|
+
return {
|
|
6293
|
+
result: capped.slice(start, end),
|
|
6294
|
+
numberOfResults: capped.length,
|
|
6295
|
+
page: safePage,
|
|
6296
|
+
totalPages: pages
|
|
6297
|
+
};
|
|
6298
|
+
}
|
|
5119
6299
|
};
|
|
5120
6300
|
|
|
5121
6301
|
// lib/services/FolderService.ts
|
|
@@ -5840,6 +7020,241 @@ var IntegrationPackInstanceService = class {
|
|
|
5840
7020
|
}
|
|
5841
7021
|
});
|
|
5842
7022
|
}
|
|
7023
|
+
/**
|
|
7024
|
+
* Browse Integration Pack Instances for an Account Group
|
|
7025
|
+
* @param requestBody Possible properties include: accountGroup (name), search (name/overrideName), page, pageSize
|
|
7026
|
+
* @returns IntegrationPackInstanceQueryResponse Successful request and response.
|
|
7027
|
+
* @throws ApiError
|
|
7028
|
+
*/
|
|
7029
|
+
async fetchIntegrationPackInstances(params) {
|
|
7030
|
+
const { accountGroup, search, page = 1, pageSize = 12 } = params;
|
|
7031
|
+
const agResp = await this.httpRequest.request({
|
|
7032
|
+
method: "POST",
|
|
7033
|
+
url: "/AccountGroup/query",
|
|
7034
|
+
mediaType: "application/json",
|
|
7035
|
+
body: queryFilter("name", "EQUALS", [accountGroup]),
|
|
7036
|
+
overrideMode: "force-parent"
|
|
7037
|
+
});
|
|
7038
|
+
const groupId = agResp?.result?.[0]?.id;
|
|
7039
|
+
if (!groupId) throw new Error(`Code [1005] - AccountGroup '${accountGroup}' not found.`);
|
|
7040
|
+
const agIpResp = await this.httpRequest.request({
|
|
7041
|
+
method: "POST",
|
|
7042
|
+
url: "/AccountGroupIntegrationPack/query",
|
|
7043
|
+
mediaType: "application/json",
|
|
7044
|
+
body: queryFilter("accountGroupId", "EQUALS", [groupId]),
|
|
7045
|
+
overrideMode: "force-parent"
|
|
7046
|
+
});
|
|
7047
|
+
const agRows = agIpResp?.result ?? [];
|
|
7048
|
+
const packIds = agRows.map((r) => r?.integrationPackId).filter(Boolean);
|
|
7049
|
+
const installationTypeById = /* @__PURE__ */ new Map();
|
|
7050
|
+
const packNameById = /* @__PURE__ */ new Map();
|
|
7051
|
+
for (const r of agRows) {
|
|
7052
|
+
if (r?.integrationPackId && r?.installationType) installationTypeById.set(r.integrationPackId, r.installationType);
|
|
7053
|
+
if (r?.integrationPackId && r?.integrationPackName) packNameById.set(r.integrationPackId, r.integrationPackName);
|
|
7054
|
+
}
|
|
7055
|
+
if (packIds.length === 0) {
|
|
7056
|
+
return { result: [], page, pageSize, numberOfResults: 0, totalPages: 0 };
|
|
7057
|
+
}
|
|
7058
|
+
const ipDetailsResp = await this.httpRequest.request({
|
|
7059
|
+
method: "POST",
|
|
7060
|
+
url: "/IntegrationPack/query",
|
|
7061
|
+
mediaType: "application/json",
|
|
7062
|
+
body: nestedQueryFilter(
|
|
7063
|
+
packIds.map((id) => ({ property: "id", operator: "EQUALS", value: id })),
|
|
7064
|
+
"or"
|
|
7065
|
+
)
|
|
7066
|
+
});
|
|
7067
|
+
const ipDetails = ipDetailsResp?.result ?? [];
|
|
7068
|
+
const packDescById = /* @__PURE__ */ new Map();
|
|
7069
|
+
for (const ip of ipDetails) {
|
|
7070
|
+
if (ip?.id && ip?.Description) packDescById.set(ip.id, ip.Description);
|
|
7071
|
+
}
|
|
7072
|
+
const instResp = await this.httpRequest.request({
|
|
7073
|
+
method: "POST",
|
|
7074
|
+
url: "/IntegrationPackInstance/query",
|
|
7075
|
+
mediaType: "application/json",
|
|
7076
|
+
body: nestedQueryFilter(
|
|
7077
|
+
packIds.map((id) => ({ property: "integrationPackId", operator: "EQUALS", value: id })),
|
|
7078
|
+
"or"
|
|
7079
|
+
)
|
|
7080
|
+
});
|
|
7081
|
+
const allInstances = instResp?.result ?? [];
|
|
7082
|
+
const searchLc = search?.toLowerCase();
|
|
7083
|
+
const filtered = searchLc ? allInstances.filter(
|
|
7084
|
+
(inst) => (inst?.integrationPackInstancName?.toLowerCase?.().includes(searchLc) ?? false) || (inst?.integrationPackOverrideName?.toLowerCase?.().includes(searchLc) ?? false)
|
|
7085
|
+
) : allInstances;
|
|
7086
|
+
const total = filtered.length;
|
|
7087
|
+
const totalPages = Math.max(1, Math.ceil(total / pageSize));
|
|
7088
|
+
const clampedPage = Math.min(Math.max(1, page), totalPages);
|
|
7089
|
+
const start = (clampedPage - 1) * pageSize;
|
|
7090
|
+
const slice = filtered.slice(start, start + pageSize);
|
|
7091
|
+
const enriched = await Promise.all(
|
|
7092
|
+
slice.map(async (instance) => {
|
|
7093
|
+
const inst = { ...instance };
|
|
7094
|
+
inst.installed = true;
|
|
7095
|
+
const ipId = inst.integrationPackId;
|
|
7096
|
+
const rawType = installationTypeById.get(ipId);
|
|
7097
|
+
inst.installationType = rawType === "SINGLE" || rawType === "MULTI" ? rawType : "SINGLE";
|
|
7098
|
+
inst.integrationPackName = packNameById.get(ipId);
|
|
7099
|
+
inst.integrationPackDescription = packDescById.get(ipId);
|
|
7100
|
+
const ipeResp = await this.httpRequest.request({
|
|
7101
|
+
method: "POST",
|
|
7102
|
+
url: "/IntegrationPackEnvironmentAttachment/query",
|
|
7103
|
+
mediaType: "application/json",
|
|
7104
|
+
body: queryFilter("integrationPackInstanceId", "EQUALS", [inst.id])
|
|
7105
|
+
});
|
|
7106
|
+
const attachments = ipeResp?.result ?? [];
|
|
7107
|
+
for (const att of attachments) {
|
|
7108
|
+
if (att?.environmentId) inst.environmentId = att.environmentId;
|
|
7109
|
+
}
|
|
7110
|
+
return inst;
|
|
7111
|
+
})
|
|
7112
|
+
);
|
|
7113
|
+
return {
|
|
7114
|
+
numberOfResults: total,
|
|
7115
|
+
result: enriched,
|
|
7116
|
+
page: clampedPage,
|
|
7117
|
+
pageSize,
|
|
7118
|
+
totalPages
|
|
7119
|
+
};
|
|
7120
|
+
}
|
|
7121
|
+
/**
|
|
7122
|
+
* Create and attach an Integration Pack Instance
|
|
7123
|
+
* @param requestBody Possible properties include: integrationPackId, isSingleInstall, environmentId, integrationPackOverrideName, accountGroupName (for AG-mapped display name)
|
|
7124
|
+
* @returns IntegrationPackInstanceQueryResponse Successful request and response.
|
|
7125
|
+
* @throws ApiError
|
|
7126
|
+
*/
|
|
7127
|
+
async createAndAttachIntegrationPackInstance(params) {
|
|
7128
|
+
const { integrationPackId, isSingleInstall, environmentId, integrationPackOverrideName, accountGroupName } = params;
|
|
7129
|
+
if (!integrationPackId) throw new Error("Code [2001] - integrationPackId is required");
|
|
7130
|
+
if (!environmentId) throw new Error("Code [2002] - environmentId is required");
|
|
7131
|
+
const instance = await this.httpRequest.request({
|
|
7132
|
+
method: "POST",
|
|
7133
|
+
url: "/IntegrationPackInstance",
|
|
7134
|
+
mediaType: "application/json",
|
|
7135
|
+
body: {
|
|
7136
|
+
integrationPackId,
|
|
7137
|
+
...isSingleInstall ? {} : { integrationPackOverrideName }
|
|
7138
|
+
}
|
|
7139
|
+
});
|
|
7140
|
+
if (!instance?.id) throw new Error("Code [1011] - Integration Pack Instance missing ID after creation.");
|
|
7141
|
+
const attachResp = await this.httpRequest.request({
|
|
7142
|
+
method: "POST",
|
|
7143
|
+
url: "/IntegrationPackEnvironmentAttachment",
|
|
7144
|
+
mediaType: "application/json",
|
|
7145
|
+
body: {
|
|
7146
|
+
environmentId,
|
|
7147
|
+
integrationPackInstanceId: instance.id
|
|
7148
|
+
}
|
|
7149
|
+
});
|
|
7150
|
+
if (!attachResp?.id) throw new Error("Code [1012] - Environment attachment failed, no ID returned.");
|
|
7151
|
+
let integrationPackDescription;
|
|
7152
|
+
let integrationPackName;
|
|
7153
|
+
try {
|
|
7154
|
+
const ipResp = await this.httpRequest.request({
|
|
7155
|
+
method: "POST",
|
|
7156
|
+
url: "/IntegrationPack/query",
|
|
7157
|
+
mediaType: "application/json",
|
|
7158
|
+
body: nestedQueryFilter(
|
|
7159
|
+
[{ property: "id", operator: "EQUALS", value: integrationPackId }],
|
|
7160
|
+
"or"
|
|
7161
|
+
)
|
|
7162
|
+
});
|
|
7163
|
+
const pack = ipResp?.result?.[0];
|
|
7164
|
+
if (pack?.Description) integrationPackDescription = pack.Description;
|
|
7165
|
+
if (!integrationPackOverrideName && accountGroupName) {
|
|
7166
|
+
integrationPackName = await this.resolvePackNameFromAccountGroup(accountGroupName, integrationPackId);
|
|
7167
|
+
if (!integrationPackName) integrationPackName = pack?.name || "";
|
|
7168
|
+
}
|
|
7169
|
+
} catch {
|
|
7170
|
+
}
|
|
7171
|
+
return {
|
|
7172
|
+
...instance,
|
|
7173
|
+
id: instance.id,
|
|
7174
|
+
integrationPackId,
|
|
7175
|
+
integrationPackOverrideName: instance.integrationPackOverrideName || integrationPackOverrideName || "",
|
|
7176
|
+
integrationPackName: instance.integrationPackOverrideName || integrationPackOverrideName || integrationPackName || "",
|
|
7177
|
+
integrationPackDescription: integrationPackDescription || "",
|
|
7178
|
+
installationType: isSingleInstall ? "SINGLE" : "MULTI",
|
|
7179
|
+
installed: true,
|
|
7180
|
+
environmentId
|
|
7181
|
+
};
|
|
7182
|
+
}
|
|
7183
|
+
/**
|
|
7184
|
+
* List Account Group Publisher Packs
|
|
7185
|
+
* @param requestBody Possible properties include: accountGroup (name)
|
|
7186
|
+
* @returns IntegrationPackInstanceQueryResponse Successful request and response.
|
|
7187
|
+
* @throws ApiError
|
|
7188
|
+
*/
|
|
7189
|
+
async listAccountGroupPublisherPacks(params) {
|
|
7190
|
+
const { accountGroup } = params;
|
|
7191
|
+
const agResp = await this.httpRequest.request({
|
|
7192
|
+
method: "POST",
|
|
7193
|
+
url: "/AccountGroup/query",
|
|
7194
|
+
mediaType: "application/json",
|
|
7195
|
+
body: queryFilter("name", "EQUALS", [accountGroup]),
|
|
7196
|
+
overrideMode: "force-parent"
|
|
7197
|
+
});
|
|
7198
|
+
const groupId = agResp?.result?.[0]?.id;
|
|
7199
|
+
if (!groupId) throw Object.assign(new Error(`Code [1005] - AccountGroup '${accountGroup}' not found.`), { status: 404 });
|
|
7200
|
+
const agIpResp = await this.httpRequest.request({
|
|
7201
|
+
method: "POST",
|
|
7202
|
+
url: "/AccountGroupIntegrationPack/query",
|
|
7203
|
+
mediaType: "application/json",
|
|
7204
|
+
body: queryFilter("accountGroupId", "EQUALS", [groupId]),
|
|
7205
|
+
overrideMode: "force-parent"
|
|
7206
|
+
});
|
|
7207
|
+
const agRows = agIpResp?.result ?? [];
|
|
7208
|
+
const packIds = agRows.map((r) => r.integrationPackId).filter(Boolean);
|
|
7209
|
+
if (packIds.length === 0) {
|
|
7210
|
+
throw Object.assign(new Error(`Code [1007] - No integration packs found for AccountGroupId[ ${groupId}]`), { status: 404 });
|
|
7211
|
+
}
|
|
7212
|
+
const typeById = /* @__PURE__ */ new Map();
|
|
7213
|
+
for (const r of agRows) {
|
|
7214
|
+
if (r?.integrationPackId && r?.installationType) typeById.set(r.integrationPackId, r.installationType);
|
|
7215
|
+
}
|
|
7216
|
+
const bulkResp = await this.httpRequest.request({
|
|
7217
|
+
method: "POST",
|
|
7218
|
+
url: "/PublisherIntegrationPack/bulk",
|
|
7219
|
+
mediaType: "application/json",
|
|
7220
|
+
body: bulkFilter("GET", packIds),
|
|
7221
|
+
overrideMode: "force-parent"
|
|
7222
|
+
});
|
|
7223
|
+
const fetched = bulkResp?.response?.filter((r) => r.statusCode === 200 && r.Result).map((r) => r.Result) ?? [];
|
|
7224
|
+
const instResp = await this.httpRequest.request({
|
|
7225
|
+
method: "POST",
|
|
7226
|
+
url: "/IntegrationPackInstance/query",
|
|
7227
|
+
mediaType: "application/json",
|
|
7228
|
+
body: nestedQueryFilter(
|
|
7229
|
+
packIds.map((id) => ({ property: "integrationPackId", operator: "EQUALS", value: id })),
|
|
7230
|
+
"or"
|
|
7231
|
+
)
|
|
7232
|
+
});
|
|
7233
|
+
const existing = instResp?.result ?? [];
|
|
7234
|
+
const existingIds = new Set(existing.map((i) => i.integrationPackId));
|
|
7235
|
+
return fetched.filter((pack) => !(typeById.get(pack.id) === "SINGLE" && existingIds.has(pack.id)));
|
|
7236
|
+
}
|
|
7237
|
+
/* =============== private =============== */
|
|
7238
|
+
async resolvePackNameFromAccountGroup(accountGroupName, integrationPackId) {
|
|
7239
|
+
const agResp = await this.httpRequest.request({
|
|
7240
|
+
method: "POST",
|
|
7241
|
+
url: "/AccountGroup/query",
|
|
7242
|
+
mediaType: "application/json",
|
|
7243
|
+
body: queryFilter("name", "EQUALS", [accountGroupName]),
|
|
7244
|
+
overrideMode: "force-parent"
|
|
7245
|
+
});
|
|
7246
|
+
const groupId = agResp?.result?.[0]?.id;
|
|
7247
|
+
if (!groupId) return void 0;
|
|
7248
|
+
const agIpResp = await this.httpRequest.request({
|
|
7249
|
+
method: "POST",
|
|
7250
|
+
url: "/AccountGroupIntegrationPack/query",
|
|
7251
|
+
mediaType: "application/json",
|
|
7252
|
+
body: queryFilter("accountGroupId", "EQUALS", [groupId]),
|
|
7253
|
+
overrideMode: "force-parent"
|
|
7254
|
+
});
|
|
7255
|
+
const row = (agIpResp?.result ?? []).find((r) => r?.integrationPackId === integrationPackId);
|
|
7256
|
+
return row?.integrationPackName;
|
|
7257
|
+
}
|
|
5843
7258
|
};
|
|
5844
7259
|
|
|
5845
7260
|
// lib/services/JavaRollbackService.ts
|
|
@@ -6754,6 +8169,31 @@ var PersistedProcessPropertiesService = class {
|
|
|
6754
8169
|
}
|
|
6755
8170
|
};
|
|
6756
8171
|
|
|
8172
|
+
// lib/helpers/fetchEnvironmentAtomAttachments.ts
|
|
8173
|
+
async function fetchEnvironmentAtomAttachments(httpRequest, environmentId) {
|
|
8174
|
+
return httpRequest.request({
|
|
8175
|
+
method: "POST",
|
|
8176
|
+
url: "/EnvironmentAtomAttachment/query",
|
|
8177
|
+
body: queryFilter("environmentId", "EQUALS", [environmentId]),
|
|
8178
|
+
mediaType: "application/json",
|
|
8179
|
+
overrideMode: "force-child"
|
|
8180
|
+
});
|
|
8181
|
+
}
|
|
8182
|
+
|
|
8183
|
+
// lib/helpers/createExecutionRequest.ts
|
|
8184
|
+
async function createExecutionRequest(httpRequest, request2) {
|
|
8185
|
+
return httpRequest.request({
|
|
8186
|
+
method: "POST",
|
|
8187
|
+
url: "/ExecutionRequest",
|
|
8188
|
+
body: request2,
|
|
8189
|
+
mediaType: "application/json",
|
|
8190
|
+
errors: {
|
|
8191
|
+
403: `Missing or incorrect authentication credentials.
|
|
8192
|
+
To know the action to be taken for this and the other error responses (410, 503, etc), refer to [API Errors](#section/Introduction/API-errors)`
|
|
8193
|
+
}
|
|
8194
|
+
});
|
|
8195
|
+
}
|
|
8196
|
+
|
|
6757
8197
|
// lib/services/ProcessService.ts
|
|
6758
8198
|
var ProcessService = class {
|
|
6759
8199
|
constructor(httpRequest) {
|
|
@@ -6838,6 +8278,50 @@ var ProcessService = class {
|
|
|
6838
8278
|
}
|
|
6839
8279
|
});
|
|
6840
8280
|
}
|
|
8281
|
+
/**
|
|
8282
|
+
* Triggers execution of all processes for an Integration Pack Instance
|
|
8283
|
+
* This operation triggers the execution of all processes associated with the specified Integration Pack Instance ID across all atoms in the specified environment.
|
|
8284
|
+
* @param requestBody
|
|
8285
|
+
* @returns ProcessQueryResponse Successful request and response.
|
|
8286
|
+
* @throws ApiError
|
|
8287
|
+
*/
|
|
8288
|
+
async runAllProcesses(integrationPackInstanceId, environmentId) {
|
|
8289
|
+
const urls = [];
|
|
8290
|
+
const { result: attachments = [] } = await fetchEnvironmentAtomAttachments(this.httpRequest, environmentId);
|
|
8291
|
+
const atomIds = attachments.map((att) => att?.atomId).filter((id) => Boolean(id));
|
|
8292
|
+
if (!atomIds.length) {
|
|
8293
|
+
throw Object.assign(
|
|
8294
|
+
new Error(`No atoms found for environmentId: ${environmentId}`),
|
|
8295
|
+
{ status: 404 }
|
|
8296
|
+
);
|
|
8297
|
+
}
|
|
8298
|
+
const procResp = await fetchProcesses(this.httpRequest, integrationPackInstanceId);
|
|
8299
|
+
const processes = procResp?.result ?? [];
|
|
8300
|
+
if (!processes.length) {
|
|
8301
|
+
throw Object.assign(
|
|
8302
|
+
new Error(`No processes found for integrationPackInstanceId: ${integrationPackInstanceId}`),
|
|
8303
|
+
{ status: 404 }
|
|
8304
|
+
);
|
|
8305
|
+
}
|
|
8306
|
+
for (const proc of processes) {
|
|
8307
|
+
const processId = proc?.id;
|
|
8308
|
+
if (!processId) continue;
|
|
8309
|
+
for (const atomId of atomIds) {
|
|
8310
|
+
const executionRequest = {
|
|
8311
|
+
DynamicProcessProperties: { DynamicProcessProperty: [] },
|
|
8312
|
+
ProcessProperties: { ProcessProperty: [] },
|
|
8313
|
+
processId,
|
|
8314
|
+
atomId
|
|
8315
|
+
};
|
|
8316
|
+
const result = await createExecutionRequest(this.httpRequest, executionRequest);
|
|
8317
|
+
const recordUrl = result?.recordUrl;
|
|
8318
|
+
if (recordUrl) {
|
|
8319
|
+
urls.push(recordUrl);
|
|
8320
|
+
}
|
|
8321
|
+
}
|
|
8322
|
+
}
|
|
8323
|
+
return urls;
|
|
8324
|
+
}
|
|
6841
8325
|
};
|
|
6842
8326
|
|
|
6843
8327
|
// lib/services/ProcessAtomAttachmentService.ts
|
|
@@ -7093,6 +8577,127 @@ var ProcessSchedulesService = class {
|
|
|
7093
8577
|
}
|
|
7094
8578
|
});
|
|
7095
8579
|
}
|
|
8580
|
+
/**
|
|
8581
|
+
* Fetch the first ProcessSchedules that matches any process on any atom in the environment.
|
|
8582
|
+
* Returns { numberOfResults, result: ProcessSchedules[] }.
|
|
8583
|
+
*/
|
|
8584
|
+
async fetchProcessSchedules(integrationPackInstanceId, environmentId) {
|
|
8585
|
+
try {
|
|
8586
|
+
const { result: attachments = [] } = await fetchEnvironmentAtomAttachments(this.httpRequest, environmentId);
|
|
8587
|
+
const atomIds = attachments.map((att) => att?.atomId).filter((id) => Boolean(id));
|
|
8588
|
+
if (!atomIds.length) {
|
|
8589
|
+
throw Object.assign(
|
|
8590
|
+
new Error(`No atoms found for environmentId: ${environmentId}`),
|
|
8591
|
+
{ status: 404 }
|
|
8592
|
+
);
|
|
8593
|
+
}
|
|
8594
|
+
const procResp = await fetchProcesses(this.httpRequest, integrationPackInstanceId);
|
|
8595
|
+
const processes = procResp?.result ?? [];
|
|
8596
|
+
if (!processes.length) {
|
|
8597
|
+
throw Object.assign(
|
|
8598
|
+
new Error(`No processes found for integrationPackInstanceId: ${integrationPackInstanceId}`),
|
|
8599
|
+
{ status: 404 }
|
|
8600
|
+
);
|
|
8601
|
+
}
|
|
8602
|
+
for (const proc of processes) {
|
|
8603
|
+
const processId = proc?.id;
|
|
8604
|
+
if (!processId) continue;
|
|
8605
|
+
for (const atomId of atomIds) {
|
|
8606
|
+
const scheduleFilter = nestedQueryFilter(
|
|
8607
|
+
[
|
|
8608
|
+
{ property: "atomId", operator: "EQUALS", value: atomId },
|
|
8609
|
+
{ property: "processId", operator: "EQUALS", value: processId }
|
|
8610
|
+
],
|
|
8611
|
+
"and"
|
|
8612
|
+
);
|
|
8613
|
+
const qs = await this.queryProcessSchedules(scheduleFilter);
|
|
8614
|
+
const row = Array.isArray(qs?.result) ? qs.result[0] : void 0;
|
|
8615
|
+
if (row?.Schedule?.length) {
|
|
8616
|
+
return {
|
|
8617
|
+
numberOfResults: 1,
|
|
8618
|
+
result: [row]
|
|
8619
|
+
};
|
|
8620
|
+
}
|
|
8621
|
+
}
|
|
8622
|
+
}
|
|
8623
|
+
return {
|
|
8624
|
+
numberOfResults: 0,
|
|
8625
|
+
result: []
|
|
8626
|
+
};
|
|
8627
|
+
} catch (err) {
|
|
8628
|
+
throw Object.assign(
|
|
8629
|
+
new Error(
|
|
8630
|
+
`Unable to fetch process schedules for env=${environmentId} ipi=${integrationPackInstanceId}: ${err?.message ?? err}`
|
|
8631
|
+
),
|
|
8632
|
+
{ status: err?.status ?? 400 }
|
|
8633
|
+
);
|
|
8634
|
+
}
|
|
8635
|
+
}
|
|
8636
|
+
/**
|
|
8637
|
+
* Updates all ProcessSchedules for all processes on all atoms in the environment.
|
|
8638
|
+
*/
|
|
8639
|
+
async updateAllProcessSchedules(integrationPackInstanceId, environmentId, schedules) {
|
|
8640
|
+
try {
|
|
8641
|
+
const { result: attachments = [] } = await fetchEnvironmentAtomAttachments(this.httpRequest, environmentId);
|
|
8642
|
+
const atomIds = attachments.map((att) => att?.atomId).filter((id) => Boolean(id));
|
|
8643
|
+
if (!atomIds.length) {
|
|
8644
|
+
throw Object.assign(
|
|
8645
|
+
new Error(`No atoms found for environmentId: ${environmentId}`),
|
|
8646
|
+
{ status: 404 }
|
|
8647
|
+
);
|
|
8648
|
+
}
|
|
8649
|
+
const procResp = await fetchProcesses(this.httpRequest, integrationPackInstanceId);
|
|
8650
|
+
const processes = procResp?.result ?? [];
|
|
8651
|
+
if (!processes.length) {
|
|
8652
|
+
throw Object.assign(
|
|
8653
|
+
new Error(`No processes found for integrationPackInstanceId: ${integrationPackInstanceId}`),
|
|
8654
|
+
{ status: 404 }
|
|
8655
|
+
);
|
|
8656
|
+
}
|
|
8657
|
+
const retry = {
|
|
8658
|
+
Schedule: schedules,
|
|
8659
|
+
maxRetry: 5
|
|
8660
|
+
};
|
|
8661
|
+
const updated = [];
|
|
8662
|
+
for (const proc of processes) {
|
|
8663
|
+
const processId = proc?.id;
|
|
8664
|
+
if (!processId) continue;
|
|
8665
|
+
for (const atomId of atomIds) {
|
|
8666
|
+
if (!atomId) continue;
|
|
8667
|
+
const conceptualId = `${processId}:${atomId}`;
|
|
8668
|
+
const schedFilter = nestedQueryFilter(
|
|
8669
|
+
[
|
|
8670
|
+
{ property: "atomId", operator: "EQUALS", value: atomId },
|
|
8671
|
+
{ property: "processId", operator: "EQUALS", value: processId }
|
|
8672
|
+
],
|
|
8673
|
+
"and"
|
|
8674
|
+
);
|
|
8675
|
+
const { result: existingResults = [] } = await this.queryProcessSchedules(schedFilter);
|
|
8676
|
+
const existing = existingResults[0];
|
|
8677
|
+
const schedulePayload = {
|
|
8678
|
+
id: conceptualId,
|
|
8679
|
+
atomId,
|
|
8680
|
+
processId,
|
|
8681
|
+
Schedule: schedules,
|
|
8682
|
+
Retry: retry
|
|
8683
|
+
};
|
|
8684
|
+
const result = await this.updateProcessSchedules(
|
|
8685
|
+
conceptualId,
|
|
8686
|
+
schedulePayload
|
|
8687
|
+
);
|
|
8688
|
+
updated.push(result);
|
|
8689
|
+
}
|
|
8690
|
+
}
|
|
8691
|
+
return updated;
|
|
8692
|
+
} catch (err) {
|
|
8693
|
+
throw Object.assign(
|
|
8694
|
+
new Error(
|
|
8695
|
+
`Unable to fetch process schedules for env=${environmentId} ipi=${integrationPackInstanceId}: ${err?.message ?? err}`
|
|
8696
|
+
),
|
|
8697
|
+
{ status: err?.status ?? 400 }
|
|
8698
|
+
);
|
|
8699
|
+
}
|
|
8700
|
+
}
|
|
7096
8701
|
};
|
|
7097
8702
|
|
|
7098
8703
|
// lib/services/ProcessScheduleStatusService.ts
|
|
@@ -8680,7 +10285,8 @@ var Boomi = class {
|
|
|
8680
10285
|
USERNAME: config?.USERNAME,
|
|
8681
10286
|
PASSWORD: config?.PASSWORD,
|
|
8682
10287
|
HEADERS: config?.HEADERS,
|
|
8683
|
-
ENCODE_PATH: config?.ENCODE_PATH
|
|
10288
|
+
ENCODE_PATH: config?.ENCODE_PATH,
|
|
10289
|
+
LOGGER: config?.LOGGER
|
|
8684
10290
|
});
|
|
8685
10291
|
this.account = new AccountService(this.request);
|
|
8686
10292
|
this.accountCloudAttachmentProperties = new AccountCloudAttachmentPropertiesService(this.request);
|
|
@@ -8810,7 +10416,8 @@ var OpenAPI = {
|
|
|
8810
10416
|
USERNAME: void 0,
|
|
8811
10417
|
PASSWORD: void 0,
|
|
8812
10418
|
HEADERS: void 0,
|
|
8813
|
-
ENCODE_PATH: void 0
|
|
10419
|
+
ENCODE_PATH: void 0,
|
|
10420
|
+
LOGGER: void 0
|
|
8814
10421
|
};
|
|
8815
10422
|
|
|
8816
10423
|
// lib/models/Account.ts
|
|
@@ -14009,6 +15616,8 @@ export {
|
|
|
14009
15616
|
X12ConnectorRecordGroupingExpression,
|
|
14010
15617
|
X12ConnectorRecordService,
|
|
14011
15618
|
X12ConnectorRecordSimpleExpression,
|
|
14012
|
-
X12Options
|
|
15619
|
+
X12Options,
|
|
15620
|
+
redactBody,
|
|
15621
|
+
redactHeaders
|
|
14013
15622
|
};
|
|
14014
15623
|
//# sourceMappingURL=index.js.map
|