@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.cjs
CHANGED
|
@@ -417,7 +417,9 @@ __export(lib_exports, {
|
|
|
417
417
|
X12ConnectorRecordGroupingExpression: () => X12ConnectorRecordGroupingExpression,
|
|
418
418
|
X12ConnectorRecordService: () => X12ConnectorRecordService,
|
|
419
419
|
X12ConnectorRecordSimpleExpression: () => X12ConnectorRecordSimpleExpression,
|
|
420
|
-
X12Options: () => X12Options
|
|
420
|
+
X12Options: () => X12Options,
|
|
421
|
+
redactBody: () => redactBody,
|
|
422
|
+
redactHeaders: () => redactHeaders
|
|
421
423
|
});
|
|
422
424
|
module.exports = __toCommonJS(lib_exports);
|
|
423
425
|
|
|
@@ -545,6 +547,35 @@ _promise = new WeakMap();
|
|
|
545
547
|
_resolve = new WeakMap();
|
|
546
548
|
_reject = new WeakMap();
|
|
547
549
|
|
|
550
|
+
// lib/utils/redact.ts
|
|
551
|
+
function redactHeaders(h) {
|
|
552
|
+
if (!h) return h;
|
|
553
|
+
const lower = {};
|
|
554
|
+
for (const [k, v] of Object.entries(h)) lower[k.toLowerCase()] = String(v);
|
|
555
|
+
if (lower["authorization"]) lower["authorization"] = "[REDACTED]";
|
|
556
|
+
if (lower["cookie"]) lower["cookie"] = "[REDACTED]";
|
|
557
|
+
if (lower["set-cookie"]) lower["set-cookie"] = "[REDACTED]";
|
|
558
|
+
return lower;
|
|
559
|
+
}
|
|
560
|
+
function redactBody(body) {
|
|
561
|
+
if (!body || typeof body !== "object") return body;
|
|
562
|
+
try {
|
|
563
|
+
const clone = JSON.parse(JSON.stringify(body));
|
|
564
|
+
const scrubKeys = ["password", "token", "accessToken", "refreshToken", "clientSecret", "secret"];
|
|
565
|
+
const walk = (o) => {
|
|
566
|
+
if (!o || typeof o !== "object") return;
|
|
567
|
+
for (const k of Object.keys(o)) {
|
|
568
|
+
if (scrubKeys.includes(k)) o[k] = "[REDACTED]";
|
|
569
|
+
else walk(o[k]);
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
walk(clone);
|
|
573
|
+
return clone;
|
|
574
|
+
} catch {
|
|
575
|
+
return "[Unserializable body]";
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
548
579
|
// lib/core/request.ts
|
|
549
580
|
var isDefined = (value) => {
|
|
550
581
|
return value !== void 0 && value !== null;
|
|
@@ -599,23 +630,6 @@ var getQueryString = (params) => {
|
|
|
599
630
|
}
|
|
600
631
|
return "";
|
|
601
632
|
};
|
|
602
|
-
var getUrl = (config, options) => {
|
|
603
|
-
const encoder = config.ENCODE_PATH || encodeURI;
|
|
604
|
-
const path = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
605
|
-
if (options.path?.hasOwnProperty(group)) {
|
|
606
|
-
return encoder(String(options.path[group]));
|
|
607
|
-
}
|
|
608
|
-
return substring;
|
|
609
|
-
});
|
|
610
|
-
const url = `${config.BASE}${path}`;
|
|
611
|
-
if (options.query) {
|
|
612
|
-
return `${url}${getQueryString(options.query)}`;
|
|
613
|
-
}
|
|
614
|
-
if (config.OVERRIDE_ACCOUNT) {
|
|
615
|
-
return `${url}?overrideAccount=${config.OVERRIDE_ACCOUNT_ID}`;
|
|
616
|
-
}
|
|
617
|
-
return url;
|
|
618
|
-
};
|
|
619
633
|
var getFormData = (options) => {
|
|
620
634
|
if (options.formData) {
|
|
621
635
|
const formData = new FormData();
|
|
@@ -650,7 +664,7 @@ var getHeaders = async (config, options, formData) => {
|
|
|
650
664
|
resolve(options, config.PASSWORD),
|
|
651
665
|
resolve(options, config.HEADERS)
|
|
652
666
|
]);
|
|
653
|
-
const formHeaders = typeof formData
|
|
667
|
+
const formHeaders = formData && typeof formData.getHeaders === "function" ? formData.getHeaders() : {};
|
|
654
668
|
const headers = Object.entries({
|
|
655
669
|
Accept: "application/json",
|
|
656
670
|
...additionalHeaders,
|
|
@@ -755,15 +769,79 @@ var catchErrorCodes = (options, result) => {
|
|
|
755
769
|
);
|
|
756
770
|
}
|
|
757
771
|
};
|
|
772
|
+
var mergeQuery = (base, extra) => ({ ...base ?? {}, ...extra });
|
|
773
|
+
async function resolveChildOverrideId(config, options) {
|
|
774
|
+
if (options.overrideAccountId) return options.overrideAccountId;
|
|
775
|
+
if (config.OVERRIDE_ACCOUNT) {
|
|
776
|
+
const maybeId = await resolve(options, config.OVERRIDE_ACCOUNT_ID);
|
|
777
|
+
return isStringWithValue(maybeId) ? maybeId : void 0;
|
|
778
|
+
}
|
|
779
|
+
return void 0;
|
|
780
|
+
}
|
|
781
|
+
var getUrl = (config, options) => {
|
|
782
|
+
const encoder = config.ENCODE_PATH || encodeURI;
|
|
783
|
+
const path = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
784
|
+
if (options.path?.hasOwnProperty(group)) {
|
|
785
|
+
return encoder(String(options.path[group]));
|
|
786
|
+
}
|
|
787
|
+
return substring;
|
|
788
|
+
});
|
|
789
|
+
const base = `${config.BASE}${path}`;
|
|
790
|
+
return options.query ? `${base}${getQueryString(options.query)}` : base;
|
|
791
|
+
};
|
|
792
|
+
function getLogger(config) {
|
|
793
|
+
return config.LOGGER;
|
|
794
|
+
}
|
|
795
|
+
function reqId() {
|
|
796
|
+
return Math.random().toString(36).slice(2, 10);
|
|
797
|
+
}
|
|
758
798
|
var request = (config, options, axiosClient = import_axios.default) => {
|
|
759
|
-
return new CancelablePromise(async (
|
|
799
|
+
return new CancelablePromise(async (resolvePromise, reject, onCancel) => {
|
|
800
|
+
const logger = getLogger(config);
|
|
801
|
+
const id = options.requestId ?? reqId();
|
|
760
802
|
try {
|
|
761
|
-
const url = getUrl(config, options);
|
|
762
803
|
const formData = getFormData(options);
|
|
763
804
|
const body = getRequestBody(options);
|
|
764
805
|
const headers = await getHeaders(config, options, formData);
|
|
806
|
+
const mode = options.overrideMode ?? "auto";
|
|
807
|
+
let effectiveOverrideId;
|
|
808
|
+
switch (mode) {
|
|
809
|
+
case "force-parent":
|
|
810
|
+
case "suppress":
|
|
811
|
+
effectiveOverrideId = void 0;
|
|
812
|
+
break;
|
|
813
|
+
case "force-child":
|
|
814
|
+
case "auto":
|
|
815
|
+
default:
|
|
816
|
+
effectiveOverrideId = await resolveChildOverrideId(config, options);
|
|
817
|
+
break;
|
|
818
|
+
}
|
|
819
|
+
const urlOptions = effectiveOverrideId ? { ...options, query: mergeQuery(options.query, { overrideAccount: effectiveOverrideId }) } : options;
|
|
820
|
+
const url = getUrl(config, urlOptions);
|
|
821
|
+
const child = logger?.child?.({
|
|
822
|
+
component: "embedkit-sdk",
|
|
823
|
+
reqId: id,
|
|
824
|
+
overrideAccount: effectiveOverrideId
|
|
825
|
+
}) ?? logger;
|
|
826
|
+
const start = Date.now();
|
|
827
|
+
child?.info?.({
|
|
828
|
+
req: {
|
|
829
|
+
method: (options.method || "GET").toUpperCase(),
|
|
830
|
+
url,
|
|
831
|
+
headers: redactHeaders(headers),
|
|
832
|
+
body: redactBody(body ?? formData)
|
|
833
|
+
}
|
|
834
|
+
}, "http.request");
|
|
765
835
|
if (!onCancel.isCancelled) {
|
|
766
836
|
const response = await sendRequest(config, options, url, body, formData, headers, onCancel, axiosClient);
|
|
837
|
+
const ms = Date.now() - start;
|
|
838
|
+
child?.info?.({
|
|
839
|
+
res: {
|
|
840
|
+
statusCode: response.status,
|
|
841
|
+
headers: redactHeaders(response.headers)
|
|
842
|
+
},
|
|
843
|
+
responseTime: ms
|
|
844
|
+
}, "http.response");
|
|
767
845
|
const responseBody = getResponseBody(response);
|
|
768
846
|
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
769
847
|
const result = {
|
|
@@ -774,9 +852,16 @@ var request = (config, options, axiosClient = import_axios.default) => {
|
|
|
774
852
|
body: responseHeader ?? responseBody
|
|
775
853
|
};
|
|
776
854
|
catchErrorCodes(options, result);
|
|
777
|
-
|
|
855
|
+
resolvePromise(result.body);
|
|
778
856
|
}
|
|
779
857
|
} catch (error) {
|
|
858
|
+
const ms = typeof error?.config === "object" && error.config?._start ? Date.now() - error.config._start : void 0;
|
|
859
|
+
const errObj = {
|
|
860
|
+
err: error,
|
|
861
|
+
responseTime: ms
|
|
862
|
+
};
|
|
863
|
+
const logger2 = getLogger(config);
|
|
864
|
+
logger2?.error?.(errObj, "http.error");
|
|
780
865
|
reject(error);
|
|
781
866
|
}
|
|
782
867
|
});
|
|
@@ -4269,6 +4354,50 @@ var EdifactConnectorRecordService = class {
|
|
|
4269
4354
|
}
|
|
4270
4355
|
};
|
|
4271
4356
|
|
|
4357
|
+
// lib/helpers/queryFilter.ts
|
|
4358
|
+
function queryFilter(property, operator, values) {
|
|
4359
|
+
if (values.length === 0) {
|
|
4360
|
+
throw new Error("Values array cannot be empty.");
|
|
4361
|
+
}
|
|
4362
|
+
for (const value of values) {
|
|
4363
|
+
if (typeof value !== "string") {
|
|
4364
|
+
throw new Error("All values must be strings.");
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4367
|
+
const expression = {
|
|
4368
|
+
operator,
|
|
4369
|
+
property,
|
|
4370
|
+
argument: values
|
|
4371
|
+
};
|
|
4372
|
+
return {
|
|
4373
|
+
QueryFilter: { expression }
|
|
4374
|
+
};
|
|
4375
|
+
}
|
|
4376
|
+
function nestedQueryFilter(filters, logicalOperator = "and") {
|
|
4377
|
+
const nestedExpression = filters.map((f) => ({
|
|
4378
|
+
operator: f.operator,
|
|
4379
|
+
property: f.property,
|
|
4380
|
+
argument: Array.isArray(f.value) ? f.value : [f.value]
|
|
4381
|
+
}));
|
|
4382
|
+
return {
|
|
4383
|
+
QueryFilter: {
|
|
4384
|
+
expression: {
|
|
4385
|
+
operator: logicalOperator,
|
|
4386
|
+
nestedExpression
|
|
4387
|
+
}
|
|
4388
|
+
}
|
|
4389
|
+
};
|
|
4390
|
+
}
|
|
4391
|
+
function bulkFilter(type, requestValues) {
|
|
4392
|
+
if (requestValues.length === 0) {
|
|
4393
|
+
throw new Error("Request values array cannot be empty.");
|
|
4394
|
+
}
|
|
4395
|
+
return {
|
|
4396
|
+
type,
|
|
4397
|
+
request: requestValues.map((id) => ({ id }))
|
|
4398
|
+
};
|
|
4399
|
+
}
|
|
4400
|
+
|
|
4272
4401
|
// lib/services/EnvironmentService.ts
|
|
4273
4402
|
var EnvironmentService = class {
|
|
4274
4403
|
constructor(httpRequest) {
|
|
@@ -4436,6 +4565,69 @@ var EnvironmentService = class {
|
|
|
4436
4565
|
}
|
|
4437
4566
|
});
|
|
4438
4567
|
}
|
|
4568
|
+
/**
|
|
4569
|
+
* Browse Environments with runtime/attachment enrichment.
|
|
4570
|
+
* - classification: 'ALL' | 'PROD' | 'TEST'
|
|
4571
|
+
* - environmentId: optional direct lookup
|
|
4572
|
+
* Returns each environment with:
|
|
4573
|
+
* - installed: boolean (true if any runtime attachment exists)
|
|
4574
|
+
* - isActive: boolean (true if any attached atom is ONLINE; set to false if attachments exist but none online)
|
|
4575
|
+
*/
|
|
4576
|
+
async fetchEnvironments(params) {
|
|
4577
|
+
const { classification, environmentId } = params ?? {};
|
|
4578
|
+
let filter;
|
|
4579
|
+
if (classification === "ALL") {
|
|
4580
|
+
filter = nestedQueryFilter(
|
|
4581
|
+
[
|
|
4582
|
+
{ property: "classification", operator: "EQUALS", value: "PROD" },
|
|
4583
|
+
{ property: "classification", operator: "EQUALS", value: "TEST" }
|
|
4584
|
+
],
|
|
4585
|
+
"or"
|
|
4586
|
+
);
|
|
4587
|
+
} else if (classification === "PROD" || classification === "TEST") {
|
|
4588
|
+
filter = queryFilter("classification", "EQUALS", [classification]);
|
|
4589
|
+
} else if (environmentId) {
|
|
4590
|
+
filter = queryFilter("id", "EQUALS", [environmentId]);
|
|
4591
|
+
}
|
|
4592
|
+
const envResp = await this.queryEnvironment(filter);
|
|
4593
|
+
const baseItems = envResp?.result ?? [];
|
|
4594
|
+
if (!baseItems.length) {
|
|
4595
|
+
return { numberOfResults: 0, result: [] };
|
|
4596
|
+
}
|
|
4597
|
+
const enriched = await Promise.all(
|
|
4598
|
+
baseItems.map(async (env) => {
|
|
4599
|
+
env.installed = false;
|
|
4600
|
+
env.isActive = false;
|
|
4601
|
+
try {
|
|
4602
|
+
const aFilter = queryFilter("environmentId", "EQUALS", [env.id]);
|
|
4603
|
+
const attachResp = await this.httpRequest.request({
|
|
4604
|
+
method: "POST",
|
|
4605
|
+
url: "/EnvironmentAtomAttachment/query",
|
|
4606
|
+
mediaType: "application/json",
|
|
4607
|
+
body: aFilter
|
|
4608
|
+
});
|
|
4609
|
+
const attachments = attachResp?.result ?? [];
|
|
4610
|
+
if (!attachments.length) return env;
|
|
4611
|
+
env.installed = true;
|
|
4612
|
+
const atomIds = attachments.map((att) => att?.atomId).filter(Boolean);
|
|
4613
|
+
if (!atomIds.length) return env;
|
|
4614
|
+
const atoms = await Promise.all(
|
|
4615
|
+
atomIds.map(
|
|
4616
|
+
(atomId) => this.httpRequest.request({ method: "GET", url: "/Atom/{id}", path: { id: atomId } }).catch(() => null)
|
|
4617
|
+
)
|
|
4618
|
+
);
|
|
4619
|
+
const anyOnline = atoms.filter(Boolean).some((a) => a?.status === "ONLINE");
|
|
4620
|
+
env.isActive = anyOnline;
|
|
4621
|
+
} catch {
|
|
4622
|
+
}
|
|
4623
|
+
return env;
|
|
4624
|
+
})
|
|
4625
|
+
);
|
|
4626
|
+
return {
|
|
4627
|
+
numberOfResults: enriched.length,
|
|
4628
|
+
result: enriched
|
|
4629
|
+
};
|
|
4630
|
+
}
|
|
4439
4631
|
};
|
|
4440
4632
|
|
|
4441
4633
|
// lib/services/EnvironmentAtomAttachmentService.ts
|
|
@@ -4569,6 +4761,393 @@ var EnvironmentConnectionFieldExtensionSummaryService = class {
|
|
|
4569
4761
|
}
|
|
4570
4762
|
};
|
|
4571
4763
|
|
|
4764
|
+
// lib/helpers/fetchProcesses.ts
|
|
4765
|
+
async function fetchProcesses(httpRequest, integrationPackInstanceId) {
|
|
4766
|
+
return await httpRequest.request({
|
|
4767
|
+
method: "POST",
|
|
4768
|
+
url: "/Process/query",
|
|
4769
|
+
mediaType: "application/json",
|
|
4770
|
+
body: queryFilter("integrationPackInstanceId", "EQUALS", [integrationPackInstanceId]),
|
|
4771
|
+
overrideMode: "force-child"
|
|
4772
|
+
});
|
|
4773
|
+
}
|
|
4774
|
+
|
|
4775
|
+
// lib/helpers/fetchEnvironmentExtensions.ts
|
|
4776
|
+
async function fetchEnvironmentExtensions(httpRequest, requestBody) {
|
|
4777
|
+
return httpRequest.request({
|
|
4778
|
+
method: "POST",
|
|
4779
|
+
url: "/EnvironmentExtensions/query",
|
|
4780
|
+
body: requestBody,
|
|
4781
|
+
mediaType: "application/json",
|
|
4782
|
+
errors: {
|
|
4783
|
+
403: `Missing or incorrect authentication credentials.
|
|
4784
|
+
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)`
|
|
4785
|
+
}
|
|
4786
|
+
});
|
|
4787
|
+
}
|
|
4788
|
+
|
|
4789
|
+
// lib/helpers/fetchExtensionsForPair.ts
|
|
4790
|
+
async function fetchExtensionsForPair(httpRequest, processId, envId) {
|
|
4791
|
+
const extensionFilter = nestedQueryFilter(
|
|
4792
|
+
[
|
|
4793
|
+
{ property: "environmentId", operator: "EQUALS", value: envId },
|
|
4794
|
+
{ property: "extensionGroupId", operator: "EQUALS", value: processId }
|
|
4795
|
+
],
|
|
4796
|
+
"and"
|
|
4797
|
+
);
|
|
4798
|
+
const extResponse = await fetchEnvironmentExtensions(httpRequest, extensionFilter);
|
|
4799
|
+
return extResponse?.result || [];
|
|
4800
|
+
}
|
|
4801
|
+
|
|
4802
|
+
// lib/helpers/fetchExtensions.ts
|
|
4803
|
+
async function fetchExtensions(httpRequest, integrationPackInstanceId, environmentId, environments) {
|
|
4804
|
+
const resp = await fetchProcesses(httpRequest, integrationPackInstanceId);
|
|
4805
|
+
if (!resp?.result) {
|
|
4806
|
+
throw new Error(
|
|
4807
|
+
`No processes found for integrationPackInstanceId: ${integrationPackInstanceId}`
|
|
4808
|
+
);
|
|
4809
|
+
}
|
|
4810
|
+
const processes = resp.result;
|
|
4811
|
+
const allExtensions = [];
|
|
4812
|
+
const targetEnvs = resolveTargetEnvironments(environments, environmentId);
|
|
4813
|
+
for (const process of processes) {
|
|
4814
|
+
if (!process.id) {
|
|
4815
|
+
throw new Error(
|
|
4816
|
+
`Missing process ID for integrationPackInstanceId: ${integrationPackInstanceId}`
|
|
4817
|
+
);
|
|
4818
|
+
}
|
|
4819
|
+
if (!targetEnvs?.length) {
|
|
4820
|
+
const exts = await fetchExtensionsForPair(httpRequest, process.id, environmentId);
|
|
4821
|
+
allExtensions.push(...exts);
|
|
4822
|
+
} else {
|
|
4823
|
+
for (const env of targetEnvs) {
|
|
4824
|
+
const envId = env.id || "";
|
|
4825
|
+
const exts = await fetchExtensionsForPair(httpRequest, process.id, envId);
|
|
4826
|
+
allExtensions.push(...exts);
|
|
4827
|
+
}
|
|
4828
|
+
}
|
|
4829
|
+
}
|
|
4830
|
+
return allExtensions;
|
|
4831
|
+
}
|
|
4832
|
+
function resolveTargetEnvironments(environments, environmentId) {
|
|
4833
|
+
return environmentId ? [{ id: environmentId }] : environments;
|
|
4834
|
+
}
|
|
4835
|
+
|
|
4836
|
+
// lib/helpers/combineEnvironmentExtensions.ts
|
|
4837
|
+
function combineEnvironmentExtensions(exts) {
|
|
4838
|
+
const hasId = (x) => typeof x.id === "string" && x.id.length > 0;
|
|
4839
|
+
const hasKey = (x) => typeof x.key === "string" && x.key.length > 0;
|
|
4840
|
+
const byEnv = /* @__PURE__ */ new Map();
|
|
4841
|
+
const conflicts = { connections: [], processProperties: [] };
|
|
4842
|
+
const ensureEnv = (envId) => {
|
|
4843
|
+
if (!byEnv.has(envId)) {
|
|
4844
|
+
byEnv.set(envId, {
|
|
4845
|
+
env: {
|
|
4846
|
+
environmentId: envId,
|
|
4847
|
+
extensionGroupId: "combined",
|
|
4848
|
+
id: `combined:${envId}`,
|
|
4849
|
+
connections: { connection: [] },
|
|
4850
|
+
processProperties: {
|
|
4851
|
+
ProcessProperty: [{
|
|
4852
|
+
id: "combined",
|
|
4853
|
+
name: "Process Properties",
|
|
4854
|
+
ProcessPropertyValue: []
|
|
4855
|
+
}]
|
|
4856
|
+
}
|
|
4857
|
+
},
|
|
4858
|
+
connMap: /* @__PURE__ */ new Map(),
|
|
4859
|
+
propMap: /* @__PURE__ */ new Map()
|
|
4860
|
+
});
|
|
4861
|
+
}
|
|
4862
|
+
return byEnv.get(envId);
|
|
4863
|
+
};
|
|
4864
|
+
const coalesceField = (envId, connId, existing, incoming) => {
|
|
4865
|
+
const a = existing?.value ?? "";
|
|
4866
|
+
const b = incoming?.value ?? "";
|
|
4867
|
+
if (a && !b) return existing;
|
|
4868
|
+
if (!a && b) return incoming;
|
|
4869
|
+
if (a && b && a !== b) {
|
|
4870
|
+
conflicts.connections.push({
|
|
4871
|
+
environmentId: envId,
|
|
4872
|
+
connectionId: connId,
|
|
4873
|
+
fieldId: String(existing.id ?? incoming.id ?? ""),
|
|
4874
|
+
values: [a, b]
|
|
4875
|
+
});
|
|
4876
|
+
return incoming;
|
|
4877
|
+
}
|
|
4878
|
+
if (!a && !b && (existing.encryptedValueSet || incoming.encryptedValueSet)) {
|
|
4879
|
+
return {
|
|
4880
|
+
...existing,
|
|
4881
|
+
encryptedValueSet: !!((existing.encryptedValueSet ?? false) || (incoming.encryptedValueSet ?? false))
|
|
4882
|
+
};
|
|
4883
|
+
}
|
|
4884
|
+
return existing || incoming;
|
|
4885
|
+
};
|
|
4886
|
+
for (const ext of exts) {
|
|
4887
|
+
const envId = ext.environmentId;
|
|
4888
|
+
if (!envId) continue;
|
|
4889
|
+
const target = ensureEnv(envId);
|
|
4890
|
+
const conns = ext.connections?.connection ?? [];
|
|
4891
|
+
for (const conn of conns) {
|
|
4892
|
+
const connKey = conn.id ?? `name:${conn.name}`;
|
|
4893
|
+
if (!target.connMap.has(connKey)) {
|
|
4894
|
+
target.connMap.set(connKey, {
|
|
4895
|
+
...conn,
|
|
4896
|
+
field: Array.isArray(conn.field) ? [...conn.field] : []
|
|
4897
|
+
});
|
|
4898
|
+
} else {
|
|
4899
|
+
const merged = { ...target.connMap.get(connKey) };
|
|
4900
|
+
const fieldMap = /* @__PURE__ */ new Map();
|
|
4901
|
+
for (const f of merged.field ?? []) if (hasId(f)) fieldMap.set(f.id, { ...f });
|
|
4902
|
+
for (const f of conn.field ?? []) {
|
|
4903
|
+
if (!hasId(f)) continue;
|
|
4904
|
+
const prev = fieldMap.get(f.id);
|
|
4905
|
+
fieldMap.set(f.id, prev ? coalesceField(envId, connKey, prev, f) : { ...f });
|
|
4906
|
+
}
|
|
4907
|
+
merged.field = Array.from(fieldMap.values());
|
|
4908
|
+
target.connMap.set(connKey, merged);
|
|
4909
|
+
}
|
|
4910
|
+
}
|
|
4911
|
+
const ppGroups = ext.processProperties?.ProcessProperty ?? [];
|
|
4912
|
+
for (const group of ppGroups) {
|
|
4913
|
+
for (const v of group.ProcessPropertyValue ?? []) {
|
|
4914
|
+
if (!hasKey(v)) continue;
|
|
4915
|
+
const existing = target.propMap.get(v.key);
|
|
4916
|
+
if (!existing) {
|
|
4917
|
+
target.propMap.set(v.key, { ...v });
|
|
4918
|
+
} else {
|
|
4919
|
+
const a = existing.value ?? "";
|
|
4920
|
+
const b = v.value ?? "";
|
|
4921
|
+
if (a && b && a !== b) {
|
|
4922
|
+
conflicts.processProperties.push({
|
|
4923
|
+
environmentId: envId,
|
|
4924
|
+
key: v.key,
|
|
4925
|
+
...v.label !== void 0 ? { label: v.label } : {},
|
|
4926
|
+
values: [a, b]
|
|
4927
|
+
});
|
|
4928
|
+
target.propMap.set(v.key, { ...v });
|
|
4929
|
+
} else if (!a && b) {
|
|
4930
|
+
target.propMap.set(v.key, { ...v });
|
|
4931
|
+
}
|
|
4932
|
+
}
|
|
4933
|
+
}
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4936
|
+
const combined = [];
|
|
4937
|
+
for (const { env, connMap, propMap } of byEnv.values()) {
|
|
4938
|
+
env.connections = { connection: Array.from(connMap.values()) };
|
|
4939
|
+
env.processProperties = {
|
|
4940
|
+
ProcessProperty: [{
|
|
4941
|
+
id: "combined",
|
|
4942
|
+
name: "Process Properties",
|
|
4943
|
+
ProcessPropertyValue: Array.from(propMap.values())
|
|
4944
|
+
}]
|
|
4945
|
+
};
|
|
4946
|
+
combined.push(env);
|
|
4947
|
+
}
|
|
4948
|
+
return { combined, conflicts };
|
|
4949
|
+
}
|
|
4950
|
+
|
|
4951
|
+
// lib/helpers/normalizeConnections.ts
|
|
4952
|
+
function normalizeConnections(c) {
|
|
4953
|
+
const list = c?.connection ?? [];
|
|
4954
|
+
return { connection: [...list] };
|
|
4955
|
+
}
|
|
4956
|
+
|
|
4957
|
+
// lib/helpers/normalizeProcessProperties.ts
|
|
4958
|
+
function normalizeProcessProperties(p) {
|
|
4959
|
+
const src = p?.ProcessProperty;
|
|
4960
|
+
const groups = Array.isArray(src) ? src : [];
|
|
4961
|
+
return {
|
|
4962
|
+
ProcessProperty: groups.map((g) => ({
|
|
4963
|
+
...g,
|
|
4964
|
+
ProcessPropertyValue: [...g?.ProcessPropertyValue ?? []]
|
|
4965
|
+
}))
|
|
4966
|
+
};
|
|
4967
|
+
}
|
|
4968
|
+
|
|
4969
|
+
// lib/helpers/indexCombined.ts
|
|
4970
|
+
function indexCombined(combined) {
|
|
4971
|
+
const connKeyOf = (c, i) => c.id || (c.name ? `name:${c.name}` : `__conn_${i}`);
|
|
4972
|
+
const hasId = (x) => typeof x.id === "string" && x.id.length > 0;
|
|
4973
|
+
const hasKey = (x) => typeof x.key === "string" && x.key.length > 0;
|
|
4974
|
+
const byEnvConnField = /* @__PURE__ */ new Map();
|
|
4975
|
+
const byEnvPropKey = /* @__PURE__ */ new Map();
|
|
4976
|
+
for (const envExt of combined) {
|
|
4977
|
+
const envId = envExt.environmentId;
|
|
4978
|
+
if (!envId) continue;
|
|
4979
|
+
const connIndex = byEnvConnField.get(envId) ?? /* @__PURE__ */ new Map();
|
|
4980
|
+
(envExt.connections?.connection ?? []).forEach((c, i) => {
|
|
4981
|
+
const k = connKeyOf(c, i);
|
|
4982
|
+
const fieldIndex = connIndex.get(k) ?? /* @__PURE__ */ new Map();
|
|
4983
|
+
(c.field ?? []).forEach((f) => {
|
|
4984
|
+
if (hasId(f)) fieldIndex.set(f.id, f);
|
|
4985
|
+
});
|
|
4986
|
+
connIndex.set(k, fieldIndex);
|
|
4987
|
+
});
|
|
4988
|
+
byEnvConnField.set(envId, connIndex);
|
|
4989
|
+
const propIndex = byEnvPropKey.get(envId) ?? /* @__PURE__ */ new Map();
|
|
4990
|
+
(envExt.processProperties?.ProcessProperty ?? []).forEach((grp) => {
|
|
4991
|
+
(grp.ProcessPropertyValue ?? []).forEach((v) => {
|
|
4992
|
+
if (hasKey(v)) propIndex.set(v.key, v);
|
|
4993
|
+
});
|
|
4994
|
+
});
|
|
4995
|
+
byEnvPropKey.set(envId, propIndex);
|
|
4996
|
+
}
|
|
4997
|
+
return { byEnvConnField, byEnvPropKey };
|
|
4998
|
+
}
|
|
4999
|
+
|
|
5000
|
+
// lib/helpers/applyFieldEdit.ts
|
|
5001
|
+
function applyFieldEdit(orig, edited) {
|
|
5002
|
+
const sameStr = (a, b) => (a ?? "") === (b ?? "");
|
|
5003
|
+
if (!edited) return orig;
|
|
5004
|
+
const out = { ...orig };
|
|
5005
|
+
if (orig.usesEncryption) {
|
|
5006
|
+
const newVal = edited.value ?? "";
|
|
5007
|
+
if (newVal.trim().length) {
|
|
5008
|
+
out.value = newVal;
|
|
5009
|
+
out.encryptedValueSet = true;
|
|
5010
|
+
out.useDefault = false;
|
|
5011
|
+
}
|
|
5012
|
+
return out;
|
|
5013
|
+
}
|
|
5014
|
+
if (!sameStr(orig.value, edited.value)) {
|
|
5015
|
+
out.value = edited.value ?? "";
|
|
5016
|
+
out.useDefault = false;
|
|
5017
|
+
}
|
|
5018
|
+
return out;
|
|
5019
|
+
}
|
|
5020
|
+
|
|
5021
|
+
// lib/helpers/planBackport.ts
|
|
5022
|
+
function planBackport(originals, combinedEdited) {
|
|
5023
|
+
const sameStr = (a, b) => (a ?? "") === (b ?? "");
|
|
5024
|
+
const connKeyOf = (c, i) => c.id || (c.name ? `name:${c.name}` : `__conn_${i}`);
|
|
5025
|
+
const hasId = (x) => typeof x.id === "string" && x.id.length > 0;
|
|
5026
|
+
const hasKey = (x) => typeof x.key === "string" && x.key.length > 0;
|
|
5027
|
+
const idx = indexCombined(combinedEdited);
|
|
5028
|
+
const plans = [];
|
|
5029
|
+
for (const ext of originals) {
|
|
5030
|
+
const envId = ext.environmentId;
|
|
5031
|
+
if (!envId) continue;
|
|
5032
|
+
const editedConnIndex = idx.byEnvConnField.get(envId) ?? /* @__PURE__ */ new Map();
|
|
5033
|
+
const editedPropIndex = idx.byEnvPropKey.get(envId) ?? /* @__PURE__ */ new Map();
|
|
5034
|
+
let connChanges = 0;
|
|
5035
|
+
let propChanges = 0;
|
|
5036
|
+
const next = {
|
|
5037
|
+
...ext,
|
|
5038
|
+
connections: normalizeConnections(ext.connections),
|
|
5039
|
+
processProperties: normalizeProcessProperties(ext.processProperties)
|
|
5040
|
+
};
|
|
5041
|
+
const connsArr = next.connections.connection ?? [];
|
|
5042
|
+
connsArr.forEach((c, ci) => {
|
|
5043
|
+
const k = connKeyOf(c, ci);
|
|
5044
|
+
const editedFields = editedConnIndex.get(k);
|
|
5045
|
+
if (!editedFields) return;
|
|
5046
|
+
const fields = c.field ?? [];
|
|
5047
|
+
const updatedFields = fields.map((f) => {
|
|
5048
|
+
if (!hasId(f)) return f;
|
|
5049
|
+
const edited = editedFields.get(f.id);
|
|
5050
|
+
if (!edited) return f;
|
|
5051
|
+
const after = applyFieldEdit(f, edited);
|
|
5052
|
+
if (after !== f && !sameStr(f.value, after.value)) connChanges++;
|
|
5053
|
+
return after;
|
|
5054
|
+
});
|
|
5055
|
+
c.field = updatedFields;
|
|
5056
|
+
});
|
|
5057
|
+
const groups = next.processProperties.ProcessProperty ?? [];
|
|
5058
|
+
groups.forEach((grp) => {
|
|
5059
|
+
const vals = grp.ProcessPropertyValue ?? [];
|
|
5060
|
+
const updatedVals = vals.map((v) => {
|
|
5061
|
+
if (!hasKey(v)) return v;
|
|
5062
|
+
const edited = editedPropIndex.get(v.key);
|
|
5063
|
+
if (!edited) return v;
|
|
5064
|
+
const a = v.value ?? "";
|
|
5065
|
+
const b = edited.value ?? "";
|
|
5066
|
+
if (!sameStr(a, b)) {
|
|
5067
|
+
propChanges++;
|
|
5068
|
+
return { ...v, value: b, useDefault: false };
|
|
5069
|
+
}
|
|
5070
|
+
return v;
|
|
5071
|
+
});
|
|
5072
|
+
grp.ProcessPropertyValue = updatedVals;
|
|
5073
|
+
});
|
|
5074
|
+
const changed = connChanges + propChanges > 0;
|
|
5075
|
+
plans.push({
|
|
5076
|
+
original: ext,
|
|
5077
|
+
payload: changed ? { ...next, partial: true } : null,
|
|
5078
|
+
changes: { connections: connChanges, properties: propChanges }
|
|
5079
|
+
});
|
|
5080
|
+
}
|
|
5081
|
+
return plans;
|
|
5082
|
+
}
|
|
5083
|
+
|
|
5084
|
+
// lib/helpers/updateEnvironmentExtensionsPartial.ts
|
|
5085
|
+
async function updateEnvironmentExtensionsPartial(httpRequest, extension) {
|
|
5086
|
+
const extensionId = extension?.id ?? "";
|
|
5087
|
+
if (!extensionId) {
|
|
5088
|
+
throw Object.assign(new Error("Code [3004] - extension.id is required for update"), { status: 400 });
|
|
5089
|
+
}
|
|
5090
|
+
const payload = { ...extension, partial: true };
|
|
5091
|
+
return updateEnvironmentExtensions(httpRequest, extensionId, payload);
|
|
5092
|
+
}
|
|
5093
|
+
async function updateEnvironmentExtensions(httpRequest, id, requestBody) {
|
|
5094
|
+
return httpRequest.request({
|
|
5095
|
+
method: "POST",
|
|
5096
|
+
url: "/EnvironmentExtensions/{id}",
|
|
5097
|
+
path: {
|
|
5098
|
+
"id": id
|
|
5099
|
+
},
|
|
5100
|
+
body: requestBody,
|
|
5101
|
+
mediaType: "application/json",
|
|
5102
|
+
errors: {
|
|
5103
|
+
403: `Missing or incorrect authentication credentials.
|
|
5104
|
+
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)`
|
|
5105
|
+
}
|
|
5106
|
+
});
|
|
5107
|
+
}
|
|
5108
|
+
|
|
5109
|
+
// lib/helpers/updateEnvironmentExtensionsBatch.ts
|
|
5110
|
+
async function updateEnvironmentExtensionsBatch(httpRequest, plans) {
|
|
5111
|
+
let updated = 0;
|
|
5112
|
+
let skipped = 0;
|
|
5113
|
+
let result = {};
|
|
5114
|
+
const failures = [];
|
|
5115
|
+
for (const plan of plans) {
|
|
5116
|
+
const { payload, original } = plan;
|
|
5117
|
+
if (!payload) {
|
|
5118
|
+
skipped++;
|
|
5119
|
+
continue;
|
|
5120
|
+
}
|
|
5121
|
+
try {
|
|
5122
|
+
result = await updateEnvironmentExtensionsPartial(httpRequest, payload);
|
|
5123
|
+
updated++;
|
|
5124
|
+
} catch (e) {
|
|
5125
|
+
failures.push({
|
|
5126
|
+
id: original?.id,
|
|
5127
|
+
groupId: original?.extensionGroupId,
|
|
5128
|
+
error: e?.message ?? "Unknown update error"
|
|
5129
|
+
});
|
|
5130
|
+
}
|
|
5131
|
+
}
|
|
5132
|
+
return { updated, skipped, failed: failures.length, failures, updatedExtensions: result };
|
|
5133
|
+
}
|
|
5134
|
+
|
|
5135
|
+
// lib/helpers/generateOauth2UrlRequestSoap.ts
|
|
5136
|
+
var esc = (s) => s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
5137
|
+
function generateOauth2UrlSoapXml(environmentId, connectionId, extensionGroupId, oAuthFieldId, clientId, clientSecret) {
|
|
5138
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
5139
|
+
<bns:EnvironmentOAuth2AccessTokenExtensionGenerationRequest
|
|
5140
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
5141
|
+
xmlns:bns="http://api.platform.boomi.com/"
|
|
5142
|
+
environmentId="${esc(environmentId)}"
|
|
5143
|
+
connectionId="${esc(connectionId)}"
|
|
5144
|
+
extensionGroupId="${esc(extensionGroupId)}"
|
|
5145
|
+
oAuthFieldId="${esc(oAuthFieldId)}"
|
|
5146
|
+
clientId="${esc(clientId)}"
|
|
5147
|
+
clientSecret="${esc(clientSecret)}"
|
|
5148
|
+
/>`;
|
|
5149
|
+
}
|
|
5150
|
+
|
|
4572
5151
|
// lib/services/EnvironmentExtensionsService.ts
|
|
4573
5152
|
var EnvironmentExtensionsService = class {
|
|
4574
5153
|
constructor(httpRequest) {
|
|
@@ -4701,20 +5280,454 @@ var EnvironmentExtensionsService = class {
|
|
|
4701
5280
|
* @returns EnvironmentExtensionsQueryResponse Successful request and response.
|
|
4702
5281
|
* @throws ApiError
|
|
4703
5282
|
*/
|
|
4704
|
-
|
|
4705
|
-
|
|
5283
|
+
async fetchOauth2Url(integrationPackInstanceId, environmentId, connectionId, oAuthFieldId, clientId, clientSecret) {
|
|
5284
|
+
const procResp = await fetchProcesses(this.httpRequest, integrationPackInstanceId);
|
|
5285
|
+
const firstProcessId = procResp.result?.[0]?.id;
|
|
5286
|
+
if (!firstProcessId) {
|
|
5287
|
+
throw new Error(`No processes found for integrationPackInstanceId: ${integrationPackInstanceId}`);
|
|
5288
|
+
}
|
|
5289
|
+
const requestXml = generateOauth2UrlSoapXml(
|
|
5290
|
+
environmentId,
|
|
5291
|
+
connectionId,
|
|
5292
|
+
firstProcessId,
|
|
5293
|
+
oAuthFieldId,
|
|
5294
|
+
clientId,
|
|
5295
|
+
clientSecret
|
|
5296
|
+
);
|
|
5297
|
+
const resp = await this.httpRequest.request({
|
|
4706
5298
|
method: "POST",
|
|
4707
5299
|
url: "/EnvironmentOAuth2AccessTokenExtensionGenerationRequest/execute",
|
|
4708
|
-
body:
|
|
4709
|
-
mediaType: "application/
|
|
5300
|
+
body: requestXml,
|
|
5301
|
+
mediaType: "application/soap+xml",
|
|
4710
5302
|
errors: {
|
|
4711
5303
|
403: `Missing or incorrect authentication credentials.
|
|
4712
5304
|
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)`
|
|
4713
5305
|
}
|
|
4714
5306
|
});
|
|
5307
|
+
if (!resp || !resp.authorizationCodeRequestUrl) {
|
|
5308
|
+
throw new Error(`No authorization URL found in SOAP response for integrationPackInstanceId: ${integrationPackInstanceId}`);
|
|
5309
|
+
}
|
|
5310
|
+
return {
|
|
5311
|
+
numberOfResults: 1,
|
|
5312
|
+
result: {
|
|
5313
|
+
authorizationCodeRequestUrl: resp.authorizationCodeRequestUrl
|
|
5314
|
+
}
|
|
5315
|
+
};
|
|
5316
|
+
}
|
|
5317
|
+
/**
|
|
5318
|
+
* High-level: create plans from combined edits and apply them ---
|
|
5319
|
+
* Uses the SDK’s own planBackport() already in this class.
|
|
5320
|
+
*/
|
|
5321
|
+
async updateEnvironmentExtensionsFromCombined(originals, combinedEdited) {
|
|
5322
|
+
const plans = planBackport(originals, combinedEdited);
|
|
5323
|
+
return updateEnvironmentExtensionsBatch(this.httpRequest, plans);
|
|
5324
|
+
}
|
|
5325
|
+
/**
|
|
5326
|
+
* Browse environment extensions for given environments
|
|
5327
|
+
* @param requestBody Possible properties include: environmentId, environmentIds, integrationPackInstanceId
|
|
5328
|
+
* @returns EnvironmentExtensionQueryResponse Successful request and response.
|
|
5329
|
+
* @throws ApiError
|
|
5330
|
+
*/
|
|
5331
|
+
async fetchEnvironmentExtensions(params) {
|
|
5332
|
+
const { integrationPackInstanceId, environmentId, environmentIds } = params;
|
|
5333
|
+
if (!integrationPackInstanceId) {
|
|
5334
|
+
throw Object.assign(new Error("integrationPackInstanceId is required"), { status: 400 });
|
|
5335
|
+
}
|
|
5336
|
+
const targets = environmentId ? [environmentId] : Array.isArray(environmentIds) && environmentIds.length ? environmentIds : [];
|
|
5337
|
+
if (!targets.length) {
|
|
5338
|
+
throw Object.assign(
|
|
5339
|
+
new Error("environmentId or environmentIds must be provided"),
|
|
5340
|
+
{ status: 400 }
|
|
5341
|
+
);
|
|
5342
|
+
}
|
|
5343
|
+
const chunks = [];
|
|
5344
|
+
for (const envId of targets) {
|
|
5345
|
+
const list = await fetchExtensions(this.httpRequest, integrationPackInstanceId, envId);
|
|
5346
|
+
chunks.push(list ?? []);
|
|
5347
|
+
}
|
|
5348
|
+
const items = [].concat(...chunks);
|
|
5349
|
+
const { combined } = combineEnvironmentExtensions(items);
|
|
5350
|
+
return {
|
|
5351
|
+
numberOfResults: items?.length || 0,
|
|
5352
|
+
result: items || [],
|
|
5353
|
+
combined: combined || []
|
|
5354
|
+
};
|
|
5355
|
+
}
|
|
5356
|
+
/** Fetch EnvironmentExtensionConnectionStatus for a given connection and fieldId. */
|
|
5357
|
+
async fetchExtensionConnectionStatus(integrationPackInstanceId, environmentId, connectionId, fieldId) {
|
|
5358
|
+
let connected = false;
|
|
5359
|
+
const resp = await fetchProcesses(this.httpRequest, integrationPackInstanceId);
|
|
5360
|
+
if (!resp?.result) {
|
|
5361
|
+
throw new Error(
|
|
5362
|
+
`No processes found for integrationPackInstanceId: ${integrationPackInstanceId}`
|
|
5363
|
+
);
|
|
5364
|
+
}
|
|
5365
|
+
for (const process of resp.result) {
|
|
5366
|
+
if (!process.id) {
|
|
5367
|
+
throw new Error(
|
|
5368
|
+
`Missing process ID for integrationPackInstanceId: ${integrationPackInstanceId}`
|
|
5369
|
+
);
|
|
5370
|
+
}
|
|
5371
|
+
const exts = await fetchExtensionsForPair(this.httpRequest, process.id, environmentId);
|
|
5372
|
+
for (const ext of exts) {
|
|
5373
|
+
const conns = ext.connections?.connection ?? [];
|
|
5374
|
+
for (const conn of conns) {
|
|
5375
|
+
if (conn.id === connectionId) {
|
|
5376
|
+
const fields = conn.field ?? [];
|
|
5377
|
+
for (const field of fields) {
|
|
5378
|
+
if (field.id === fieldId) {
|
|
5379
|
+
if (field.encryptedValueSet) {
|
|
5380
|
+
connected = true;
|
|
5381
|
+
}
|
|
5382
|
+
break;
|
|
5383
|
+
}
|
|
5384
|
+
}
|
|
5385
|
+
}
|
|
5386
|
+
}
|
|
5387
|
+
}
|
|
5388
|
+
}
|
|
5389
|
+
return connected;
|
|
4715
5390
|
}
|
|
4716
5391
|
};
|
|
4717
5392
|
|
|
5393
|
+
// lib/helpers/buildOnePayload.ts
|
|
5394
|
+
function buildOnePayload(mapId, containerId, sourceFields, targetFields) {
|
|
5395
|
+
const srcArray = Array.from(sourceFields.values());
|
|
5396
|
+
const tgtArray = Array.from(targetFields.values());
|
|
5397
|
+
const BrowseSettings = { containerId };
|
|
5398
|
+
if (srcArray.length) {
|
|
5399
|
+
BrowseSettings.SourceBrowse = { BrowseFields: srcArray };
|
|
5400
|
+
}
|
|
5401
|
+
if (tgtArray.length) {
|
|
5402
|
+
BrowseSettings.DestinationBrowse = { BrowseFields: tgtArray };
|
|
5403
|
+
}
|
|
5404
|
+
return {
|
|
5405
|
+
id: mapId,
|
|
5406
|
+
Map: { BrowseSettings }
|
|
5407
|
+
};
|
|
5408
|
+
}
|
|
5409
|
+
|
|
5410
|
+
// lib/helpers/buildBrowseRequests.ts
|
|
5411
|
+
async function buildBrowseRequests(candidates, opts = {}) {
|
|
5412
|
+
const { includeSessions = false, defaultValueForEmpty } = opts;
|
|
5413
|
+
const groups = /* @__PURE__ */ new Map();
|
|
5414
|
+
for (const c of candidates) {
|
|
5415
|
+
const mapId = c.mapId;
|
|
5416
|
+
const containerId = c.containerId;
|
|
5417
|
+
if (!mapId || !containerId || !c.paramName) continue;
|
|
5418
|
+
const key = `${mapId}|${containerId}`;
|
|
5419
|
+
let g = groups.get(key);
|
|
5420
|
+
if (!g) {
|
|
5421
|
+
g = {
|
|
5422
|
+
candidate: c,
|
|
5423
|
+
mapId,
|
|
5424
|
+
containerId,
|
|
5425
|
+
sourceFields: /* @__PURE__ */ new Map(),
|
|
5426
|
+
targetFields: /* @__PURE__ */ new Map()
|
|
5427
|
+
};
|
|
5428
|
+
groups.set(key, g);
|
|
5429
|
+
}
|
|
5430
|
+
const value = c.paramValue ?? (defaultValueForEmpty ? defaultValueForEmpty(c) : void 0);
|
|
5431
|
+
const field = { name: c.paramName, value };
|
|
5432
|
+
if (c.candidateSource === "source") {
|
|
5433
|
+
g.sourceFields.set(c.paramName, field);
|
|
5434
|
+
} else {
|
|
5435
|
+
g.targetFields.set(c.paramName, field);
|
|
5436
|
+
}
|
|
5437
|
+
}
|
|
5438
|
+
const out = [];
|
|
5439
|
+
for (const g of groups.values()) {
|
|
5440
|
+
out.push({
|
|
5441
|
+
candidate: g.candidate,
|
|
5442
|
+
request: buildOnePayload(
|
|
5443
|
+
g.mapId,
|
|
5444
|
+
g.containerId,
|
|
5445
|
+
g.sourceFields,
|
|
5446
|
+
g.targetFields
|
|
5447
|
+
)
|
|
5448
|
+
});
|
|
5449
|
+
}
|
|
5450
|
+
return out;
|
|
5451
|
+
}
|
|
5452
|
+
|
|
5453
|
+
// lib/helpers/executeEnvironmentMapExtension.ts
|
|
5454
|
+
async function executeEnvironmentMapExtension(httpRequest, id, requestBody) {
|
|
5455
|
+
return httpRequest.request({
|
|
5456
|
+
method: "POST",
|
|
5457
|
+
url: "/EnvironmentMapExtension/execute/{id}",
|
|
5458
|
+
path: {
|
|
5459
|
+
"id": id
|
|
5460
|
+
},
|
|
5461
|
+
body: requestBody,
|
|
5462
|
+
mediaType: "application/json",
|
|
5463
|
+
overrideMode: "force-child",
|
|
5464
|
+
errors: {
|
|
5465
|
+
403: `Missing or incorrect authentication credentials.
|
|
5466
|
+
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)`
|
|
5467
|
+
}
|
|
5468
|
+
});
|
|
5469
|
+
}
|
|
5470
|
+
|
|
5471
|
+
// lib/helpers/extractBrowseSessionId.ts
|
|
5472
|
+
function extractBrowseSessionId(resp) {
|
|
5473
|
+
const src = resp?.Map?.BrowseSettings?.SourceBrowse?.sessionId;
|
|
5474
|
+
if (typeof src === "string" && src.length > 0) {
|
|
5475
|
+
return { sessionId: src, kind: "source" };
|
|
5476
|
+
}
|
|
5477
|
+
const dest = resp?.Map?.BrowseSettings?.DestinationBrowse?.sessionId;
|
|
5478
|
+
if (typeof dest === "string" && dest.length > 0) {
|
|
5479
|
+
return { sessionId: dest, kind: "target" };
|
|
5480
|
+
}
|
|
5481
|
+
return { sessionId: "", kind: null };
|
|
5482
|
+
}
|
|
5483
|
+
|
|
5484
|
+
// lib/helpers/executeMapExtension.ts
|
|
5485
|
+
async function executeMapExtension(httpRequest, request2) {
|
|
5486
|
+
const response = await executeEnvironmentMapExtension(
|
|
5487
|
+
httpRequest,
|
|
5488
|
+
request2.id,
|
|
5489
|
+
request2
|
|
5490
|
+
);
|
|
5491
|
+
console.log("Execute map extension response:", JSON.stringify(response, null, 2));
|
|
5492
|
+
return extractBrowseSessionId(response);
|
|
5493
|
+
}
|
|
5494
|
+
|
|
5495
|
+
// lib/helpers/fetchEnvironmentMapExtensionSummary.ts
|
|
5496
|
+
async function fetchEnvironmentMapExtensionsSummary(httpRequest, requestBody) {
|
|
5497
|
+
return httpRequest.request({
|
|
5498
|
+
method: "POST",
|
|
5499
|
+
url: "/EnvironmentMapExtensionsSummary/query",
|
|
5500
|
+
body: requestBody,
|
|
5501
|
+
mediaType: "application/json",
|
|
5502
|
+
errors: {
|
|
5503
|
+
403: `Missing or incorrect authentication credentials.
|
|
5504
|
+
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)`
|
|
5505
|
+
}
|
|
5506
|
+
});
|
|
5507
|
+
}
|
|
5508
|
+
|
|
5509
|
+
// lib/helpers/fetchMapExtensionSummaries.ts
|
|
5510
|
+
async function fetchMapExtensionSummaries(httpRequest, processId, environmentId) {
|
|
5511
|
+
const summaryMap = /* @__PURE__ */ new Map();
|
|
5512
|
+
const summaryFilter = nestedQueryFilter(
|
|
5513
|
+
[
|
|
5514
|
+
{ property: "environmentId", operator: "EQUALS", value: environmentId },
|
|
5515
|
+
{ property: "extensionGroupId", operator: "EQUALS", value: processId }
|
|
5516
|
+
],
|
|
5517
|
+
"and"
|
|
5518
|
+
);
|
|
5519
|
+
const summaryResponse = await fetchEnvironmentMapExtensionsSummary(
|
|
5520
|
+
httpRequest,
|
|
5521
|
+
summaryFilter
|
|
5522
|
+
);
|
|
5523
|
+
let summaries = summaryResponse?.result || [];
|
|
5524
|
+
return summaries;
|
|
5525
|
+
}
|
|
5526
|
+
|
|
5527
|
+
// lib/helpers/fetchExtensionsSummariesByProcessAndEnvironment.ts
|
|
5528
|
+
async function fetchExtensionsSummariesByProcessAndEnvironment(httpRequest, processId, environmentId) {
|
|
5529
|
+
const summaryMap = /* @__PURE__ */ new Map();
|
|
5530
|
+
let summaries = await fetchMapExtensionSummaries(httpRequest, processId, environmentId);
|
|
5531
|
+
for (const summary of summaries) {
|
|
5532
|
+
if (summary.id && !summaryMap.has(summary.id)) {
|
|
5533
|
+
summaryMap.set(summary.id, summary);
|
|
5534
|
+
}
|
|
5535
|
+
}
|
|
5536
|
+
summaries = Array.from(summaryMap.values());
|
|
5537
|
+
return summaries || [];
|
|
5538
|
+
}
|
|
5539
|
+
|
|
5540
|
+
// lib/helpers/fetchAllSummaries.ts
|
|
5541
|
+
async function fetchAllSummaries(httpRequest, integrationPackInstanceId, environmentId) {
|
|
5542
|
+
const resp = await fetchProcesses(httpRequest, integrationPackInstanceId);
|
|
5543
|
+
const allSummaries = [];
|
|
5544
|
+
if (!resp?.result) {
|
|
5545
|
+
throw new Error(
|
|
5546
|
+
`Code [2002] - No processes found for integrationPackInstanceId: ${integrationPackInstanceId}`
|
|
5547
|
+
);
|
|
5548
|
+
}
|
|
5549
|
+
const processes = resp.result;
|
|
5550
|
+
for (const process of processes) {
|
|
5551
|
+
if (!process.id) continue;
|
|
5552
|
+
const mapSummaries = await fetchExtensionsSummariesByProcessAndEnvironment(httpRequest, process.id, environmentId);
|
|
5553
|
+
allSummaries.push(...mapSummaries.filter(Boolean));
|
|
5554
|
+
}
|
|
5555
|
+
const deduped = Array.from(new Map(allSummaries.map((s) => [s.id, s])).values());
|
|
5556
|
+
return deduped;
|
|
5557
|
+
}
|
|
5558
|
+
|
|
5559
|
+
// lib/helpers/fetchContainerId.ts
|
|
5560
|
+
async function fetchContainerId(httpRequest, environmentId) {
|
|
5561
|
+
const aFilter = queryFilter(
|
|
5562
|
+
"environmentId",
|
|
5563
|
+
"EQUALS",
|
|
5564
|
+
[environmentId]
|
|
5565
|
+
);
|
|
5566
|
+
const resp = await httpRequest.request({
|
|
5567
|
+
method: "POST",
|
|
5568
|
+
url: "/EnvironmentAtomAttachment/query",
|
|
5569
|
+
mediaType: "application/json",
|
|
5570
|
+
body: aFilter
|
|
5571
|
+
});
|
|
5572
|
+
return resp?.result?.[0]?.atomId ?? resp?.result?.[0]?.containerId ?? "";
|
|
5573
|
+
}
|
|
5574
|
+
|
|
5575
|
+
// lib/helpers/findConnectionName.ts
|
|
5576
|
+
function findConnectionName(connectionId, exts) {
|
|
5577
|
+
const list = Array.isArray(exts) ? exts : [exts];
|
|
5578
|
+
for (const e of list) {
|
|
5579
|
+
const match = e?.connections?.connection?.find((c) => c?.id === connectionId);
|
|
5580
|
+
if (match?.name) return match.name;
|
|
5581
|
+
}
|
|
5582
|
+
return null;
|
|
5583
|
+
}
|
|
5584
|
+
|
|
5585
|
+
// lib/helpers/findConnectionFieldValue.ts
|
|
5586
|
+
function findConnectionFieldValue(connectionId, paramName, exts) {
|
|
5587
|
+
const list = Array.isArray(exts) ? exts : [exts];
|
|
5588
|
+
for (const e of list) {
|
|
5589
|
+
const conns = e?.connections?.connection ?? [];
|
|
5590
|
+
for (const c of conns) {
|
|
5591
|
+
if (!c || c.id !== connectionId) continue;
|
|
5592
|
+
const fields = c.field ?? [];
|
|
5593
|
+
const match = fields.find((f) => {
|
|
5594
|
+
const fid = f?.id ?? f?.["@id"];
|
|
5595
|
+
const fname = f?.name ?? f?.["@name"];
|
|
5596
|
+
return fid === paramName || fname === paramName;
|
|
5597
|
+
});
|
|
5598
|
+
if (match) {
|
|
5599
|
+
const raw = match.value ?? "";
|
|
5600
|
+
return raw != null ? String(raw) : void 0;
|
|
5601
|
+
}
|
|
5602
|
+
}
|
|
5603
|
+
}
|
|
5604
|
+
return void 0;
|
|
5605
|
+
}
|
|
5606
|
+
|
|
5607
|
+
// lib/helpers/sessionFromSet.ts
|
|
5608
|
+
function sessionsFromSet(sets, sourceName, summary, containerId, environmentId, processId, originalExtensions, exts) {
|
|
5609
|
+
const asArray = (x) => x == null ? [] : Array.isArray(x) ? x : [x];
|
|
5610
|
+
return asArray(sets).filter((s) => !!s?.connectionId).flatMap((s) => {
|
|
5611
|
+
const connectionId = s.connectionId;
|
|
5612
|
+
const connectionName = findConnectionName(connectionId, originalExtensions) ?? "";
|
|
5613
|
+
const fieldNames = asArray(s?.BrowseField).map((bf) => bf?.name).filter((n) => !!n);
|
|
5614
|
+
return fieldNames.map((paramName) => {
|
|
5615
|
+
return {
|
|
5616
|
+
containerId,
|
|
5617
|
+
environmentId,
|
|
5618
|
+
processId,
|
|
5619
|
+
connectionId,
|
|
5620
|
+
connectionName,
|
|
5621
|
+
candidateSource: sourceName,
|
|
5622
|
+
paramName,
|
|
5623
|
+
mapId: summary.id ?? "",
|
|
5624
|
+
paramValue: exts ? findConnectionFieldValue(connectionId, paramName, exts) ?? "" : ""
|
|
5625
|
+
};
|
|
5626
|
+
});
|
|
5627
|
+
});
|
|
5628
|
+
}
|
|
5629
|
+
|
|
5630
|
+
// lib/helpers/extractBrowseCandidateFromSummary.ts
|
|
5631
|
+
function extractBrowseCandidateFromSummary(s, containerId, environmentId, processId, originalExtensions, extensions) {
|
|
5632
|
+
return [
|
|
5633
|
+
...sessionsFromSet(s.SourceFieldSet, "source", s, containerId, environmentId, processId, originalExtensions, extensions),
|
|
5634
|
+
...sessionsFromSet(s.DestinationFieldSet, "target", s, containerId, environmentId, processId, originalExtensions, extensions)
|
|
5635
|
+
];
|
|
5636
|
+
}
|
|
5637
|
+
|
|
5638
|
+
// lib/helpers/buildBrowseCandidates.ts
|
|
5639
|
+
async function buildBrowseCandidates(httpRequest, summaries, originalExtensions, updatedExtensions, environmentId) {
|
|
5640
|
+
const containerId = await fetchContainerId(httpRequest, environmentId);
|
|
5641
|
+
if (!containerId) {
|
|
5642
|
+
throw new Error(`Atom attachment not found for environment: ${environmentId}`);
|
|
5643
|
+
}
|
|
5644
|
+
const candidates = [];
|
|
5645
|
+
for (const s of summaries) {
|
|
5646
|
+
candidates.push(
|
|
5647
|
+
...extractBrowseCandidateFromSummary(
|
|
5648
|
+
s,
|
|
5649
|
+
containerId,
|
|
5650
|
+
environmentId,
|
|
5651
|
+
s.processId || "",
|
|
5652
|
+
originalExtensions,
|
|
5653
|
+
updatedExtensions
|
|
5654
|
+
)
|
|
5655
|
+
);
|
|
5656
|
+
}
|
|
5657
|
+
return candidates;
|
|
5658
|
+
}
|
|
5659
|
+
|
|
5660
|
+
// lib/helpers/fetchBrowseCandidateForPair.ts
|
|
5661
|
+
async function fetchBrowseCandidatesForPair(httpRequest, summary, environmentId, integrationPackInstanceId) {
|
|
5662
|
+
const candidates = [];
|
|
5663
|
+
const extensions = await fetchExtensions(httpRequest, integrationPackInstanceId, environmentId);
|
|
5664
|
+
const containerId = await fetchContainerId(httpRequest, environmentId);
|
|
5665
|
+
if (!containerId) {
|
|
5666
|
+
throw new Error(`Atom attachment not found for environment: ${environmentId}`);
|
|
5667
|
+
}
|
|
5668
|
+
candidates.push(
|
|
5669
|
+
...extractBrowseCandidateFromSummary(
|
|
5670
|
+
summary,
|
|
5671
|
+
containerId,
|
|
5672
|
+
environmentId,
|
|
5673
|
+
summary.processId || "",
|
|
5674
|
+
extensions
|
|
5675
|
+
)
|
|
5676
|
+
);
|
|
5677
|
+
return candidates;
|
|
5678
|
+
}
|
|
5679
|
+
|
|
5680
|
+
// lib/helpers/fetchEnvironmentMapExtension.ts
|
|
5681
|
+
async function fetchEnvironmentMapExtension(httpRequest, id) {
|
|
5682
|
+
return httpRequest.request({
|
|
5683
|
+
method: "GET",
|
|
5684
|
+
url: "/EnvironmentMapExtension/{id}",
|
|
5685
|
+
path: {
|
|
5686
|
+
"id": id
|
|
5687
|
+
},
|
|
5688
|
+
errors: {
|
|
5689
|
+
403: `Missing or incorrect authentication credentials.
|
|
5690
|
+
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)`
|
|
5691
|
+
}
|
|
5692
|
+
});
|
|
5693
|
+
}
|
|
5694
|
+
|
|
5695
|
+
// lib/helpers/fetchExtensionsByProcessAndEnvironment.ts
|
|
5696
|
+
async function fetchExtensionsByProcessAndEnvironment(httpRequest, processId, environmentId, integrationPackInstanceId) {
|
|
5697
|
+
let summaries = await fetchExtensionsSummariesByProcessAndEnvironment(httpRequest, processId, environmentId);
|
|
5698
|
+
const allMaps = [];
|
|
5699
|
+
const missingCandidates = [];
|
|
5700
|
+
let requiresBrowseSession = false;
|
|
5701
|
+
const mapExtensions = await Promise.all(
|
|
5702
|
+
summaries.map(async (summary) => {
|
|
5703
|
+
const hasBrowse = !!summary?.SourceFieldSet?.BrowseField?.length || !!summary?.DestinationFieldSet?.BrowseField?.length;
|
|
5704
|
+
const map = await fetchEnvironmentMapExtension(
|
|
5705
|
+
httpRequest,
|
|
5706
|
+
summary.id
|
|
5707
|
+
);
|
|
5708
|
+
if (hasBrowse) {
|
|
5709
|
+
requiresBrowseSession = true;
|
|
5710
|
+
const candidates = await fetchBrowseCandidatesForPair(
|
|
5711
|
+
httpRequest,
|
|
5712
|
+
summary,
|
|
5713
|
+
environmentId,
|
|
5714
|
+
integrationPackInstanceId
|
|
5715
|
+
);
|
|
5716
|
+
const missing = candidates.filter((c) => !c.sessionId);
|
|
5717
|
+
if (missing.length) {
|
|
5718
|
+
missingCandidates.push(...missing);
|
|
5719
|
+
}
|
|
5720
|
+
}
|
|
5721
|
+
allMaps.push({
|
|
5722
|
+
map,
|
|
5723
|
+
requiresBrowseSession,
|
|
5724
|
+
candidates: missingCandidates.length ? missingCandidates : []
|
|
5725
|
+
});
|
|
5726
|
+
})
|
|
5727
|
+
);
|
|
5728
|
+
return allMaps;
|
|
5729
|
+
}
|
|
5730
|
+
|
|
4718
5731
|
// lib/services/EnvironmentMapExtensionService.ts
|
|
4719
5732
|
var EnvironmentMapExtensionService = class {
|
|
4720
5733
|
constructor(httpRequest) {
|
|
@@ -4790,6 +5803,73 @@ var EnvironmentMapExtensionService = class {
|
|
|
4790
5803
|
}
|
|
4791
5804
|
});
|
|
4792
5805
|
}
|
|
5806
|
+
/** fetch all maps for an environment and integrationPackInstance */
|
|
5807
|
+
async fetchAllMaps(integrationPackInstanceId, environmentId) {
|
|
5808
|
+
const resp = await fetchProcesses(this.httpRequest, integrationPackInstanceId);
|
|
5809
|
+
const allMaps = [];
|
|
5810
|
+
if (!resp?.result) {
|
|
5811
|
+
throw new Error(
|
|
5812
|
+
`No processes found for integrationPackInstanceId: ${integrationPackInstanceId}`
|
|
5813
|
+
);
|
|
5814
|
+
}
|
|
5815
|
+
const processes = resp.result;
|
|
5816
|
+
for (const process of processes) {
|
|
5817
|
+
if (!process.id) continue;
|
|
5818
|
+
const mapExtensions = await fetchExtensionsByProcessAndEnvironment(this.httpRequest, process.id, environmentId, integrationPackInstanceId);
|
|
5819
|
+
allMaps.push(...mapExtensions.filter(Boolean));
|
|
5820
|
+
}
|
|
5821
|
+
const deduped = Array.from(new Map(allMaps.map((s) => [s.map.id, s])).values());
|
|
5822
|
+
return deduped;
|
|
5823
|
+
}
|
|
5824
|
+
/** fetch all maps for an environment and integrationPackInstance */
|
|
5825
|
+
updateEnvironmentMapExtension(requestBody) {
|
|
5826
|
+
return this.httpRequest.request({
|
|
5827
|
+
method: "POST",
|
|
5828
|
+
url: `/EnvironmentMapExtension/${requestBody.id}`,
|
|
5829
|
+
body: requestBody,
|
|
5830
|
+
mediaType: "application/json",
|
|
5831
|
+
errors: {
|
|
5832
|
+
403: `Missing or incorrect authentication credentials.
|
|
5833
|
+
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)`
|
|
5834
|
+
}
|
|
5835
|
+
});
|
|
5836
|
+
}
|
|
5837
|
+
/** try to authenticate the maps for dynamic browsing
|
|
5838
|
+
* Todo: return both failed and succeeded candidates
|
|
5839
|
+
*/
|
|
5840
|
+
async executeDynamicBrowse(candidates) {
|
|
5841
|
+
const failedCandidates = [];
|
|
5842
|
+
const successCandidates = [];
|
|
5843
|
+
const filteredCandidates = candidates.filter((c) => c.paramValue?.trim());
|
|
5844
|
+
const resp = await buildBrowseRequests(filteredCandidates, { includeSessions: true });
|
|
5845
|
+
if (!resp) {
|
|
5846
|
+
return { failedCandidates, successCandidates };
|
|
5847
|
+
}
|
|
5848
|
+
for (const r of resp) {
|
|
5849
|
+
try {
|
|
5850
|
+
const { sessionId } = await executeMapExtension(this.httpRequest, r.request);
|
|
5851
|
+
if (!sessionId) {
|
|
5852
|
+
failedCandidates.push(r.candidate);
|
|
5853
|
+
}
|
|
5854
|
+
r.candidate.sessionId = sessionId;
|
|
5855
|
+
successCandidates.push(r.candidate);
|
|
5856
|
+
} catch (e) {
|
|
5857
|
+
failedCandidates.push(r.candidate);
|
|
5858
|
+
}
|
|
5859
|
+
}
|
|
5860
|
+
return { failedCandidates, successCandidates };
|
|
5861
|
+
}
|
|
5862
|
+
/** call execute on each map extension that contains a source or target browse */
|
|
5863
|
+
async executeMapFunctionBrowse(originals, updated, integrationPackInstanceId, environmentId) {
|
|
5864
|
+
const allSummaries = await fetchAllSummaries(
|
|
5865
|
+
this.httpRequest,
|
|
5866
|
+
integrationPackInstanceId,
|
|
5867
|
+
environmentId
|
|
5868
|
+
);
|
|
5869
|
+
const candidates = await buildBrowseCandidates(this.httpRequest, allSummaries, originals, updated, environmentId);
|
|
5870
|
+
const response = await this.executeDynamicBrowse(candidates);
|
|
5871
|
+
return response;
|
|
5872
|
+
}
|
|
4793
5873
|
};
|
|
4794
5874
|
|
|
4795
5875
|
// lib/services/EnvironmentMapExtensionExternalComponentService.ts
|
|
@@ -5488,6 +6568,59 @@ var ExecutionRequestService = class {
|
|
|
5488
6568
|
}
|
|
5489
6569
|
};
|
|
5490
6570
|
|
|
6571
|
+
// lib/helpers/withBackOff.ts
|
|
6572
|
+
async function withBackoff(fn, opts = {}) {
|
|
6573
|
+
const tries = opts.tries ?? 4;
|
|
6574
|
+
const baseMs = opts.baseMs ?? 200;
|
|
6575
|
+
const jitterMs = opts.jitterMs ?? 100;
|
|
6576
|
+
let attempt = 0;
|
|
6577
|
+
let lastError;
|
|
6578
|
+
while (attempt < tries) {
|
|
6579
|
+
try {
|
|
6580
|
+
return await fn();
|
|
6581
|
+
} catch (err) {
|
|
6582
|
+
lastError = err;
|
|
6583
|
+
const delay = baseMs * Math.pow(2, attempt) + Math.floor(Math.random() * jitterMs);
|
|
6584
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
6585
|
+
attempt++;
|
|
6586
|
+
}
|
|
6587
|
+
}
|
|
6588
|
+
throw lastError;
|
|
6589
|
+
}
|
|
6590
|
+
|
|
6591
|
+
// lib/helpers/runWithConcurrency.ts
|
|
6592
|
+
async function runWithConcurrency(tasks, maxConcurrent = 4) {
|
|
6593
|
+
const results = [];
|
|
6594
|
+
let i = 0;
|
|
6595
|
+
async function worker() {
|
|
6596
|
+
while (i < tasks.length) {
|
|
6597
|
+
const idx = i++;
|
|
6598
|
+
try {
|
|
6599
|
+
results[idx] = await tasks[idx]();
|
|
6600
|
+
} catch (err) {
|
|
6601
|
+
results[idx] = void 0;
|
|
6602
|
+
}
|
|
6603
|
+
}
|
|
6604
|
+
}
|
|
6605
|
+
const n = Math.max(1, Math.min(maxConcurrent, tasks.length));
|
|
6606
|
+
await Promise.all(new Array(n).fill(0).map(() => worker()));
|
|
6607
|
+
return results;
|
|
6608
|
+
}
|
|
6609
|
+
|
|
6610
|
+
// lib/helpers/fetchExecutionRecord.ts
|
|
6611
|
+
async function fetchExecutionRecord(httpRequest, requestBody) {
|
|
6612
|
+
return httpRequest.request({
|
|
6613
|
+
method: "POST",
|
|
6614
|
+
url: "/ExecutionRecord/query",
|
|
6615
|
+
body: requestBody,
|
|
6616
|
+
mediaType: "application/json",
|
|
6617
|
+
errors: {
|
|
6618
|
+
403: `Missing or incorrect authentication credentials.
|
|
6619
|
+
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)`
|
|
6620
|
+
}
|
|
6621
|
+
});
|
|
6622
|
+
}
|
|
6623
|
+
|
|
5491
6624
|
// lib/services/ExecutionSummaryRecordService.ts
|
|
5492
6625
|
var ExecutionSummaryRecordService = class {
|
|
5493
6626
|
constructor(httpRequest) {
|
|
@@ -5531,6 +6664,55 @@ var ExecutionSummaryRecordService = class {
|
|
|
5531
6664
|
}
|
|
5532
6665
|
});
|
|
5533
6666
|
}
|
|
6667
|
+
async fetchExecutionRecordsByIntegrationPack(params) {
|
|
6668
|
+
const {
|
|
6669
|
+
integrationPackInstanceId,
|
|
6670
|
+
search = "",
|
|
6671
|
+
page = 1,
|
|
6672
|
+
pageSize = 20,
|
|
6673
|
+
maxRuns = 30,
|
|
6674
|
+
maxConcurrent = 4,
|
|
6675
|
+
backoff
|
|
6676
|
+
} = params;
|
|
6677
|
+
if (!integrationPackInstanceId) {
|
|
6678
|
+
throw new Error("Code [2002] - integrationPackInstanceId is required.");
|
|
6679
|
+
}
|
|
6680
|
+
const pResp = await withBackoff(
|
|
6681
|
+
() => fetchProcesses(this.httpRequest, integrationPackInstanceId),
|
|
6682
|
+
backoff
|
|
6683
|
+
);
|
|
6684
|
+
const processes = pResp?.result ?? [];
|
|
6685
|
+
if (!processes.length) {
|
|
6686
|
+
return { result: [], page, pageSize, numberOfResults: 0, totalPages: 1 };
|
|
6687
|
+
}
|
|
6688
|
+
const tasks = processes.filter((p) => !!p?.id).map((p) => {
|
|
6689
|
+
const rFilter = queryFilter("processId", "EQUALS", [String(p.id)]);
|
|
6690
|
+
return () => withBackoff(
|
|
6691
|
+
() => fetchExecutionRecord(this.httpRequest, rFilter).then((r) => r?.result ?? []),
|
|
6692
|
+
backoff
|
|
6693
|
+
).catch(() => []);
|
|
6694
|
+
});
|
|
6695
|
+
const perProcessLists = await runWithConcurrency(tasks, maxConcurrent);
|
|
6696
|
+
const all = perProcessLists.flat().filter(Boolean);
|
|
6697
|
+
if (!all.length) {
|
|
6698
|
+
return { result: [], page, pageSize, numberOfResults: 0, totalPages: 1 };
|
|
6699
|
+
}
|
|
6700
|
+
const needle = search.trim().toLowerCase();
|
|
6701
|
+
const filtered = needle ? all.filter((r) => (r?.message ?? "").toLowerCase().includes(needle)) : all;
|
|
6702
|
+
const toTs = (t) => t ? new Date(t).getTime() || 0 : 0;
|
|
6703
|
+
filtered.sort((a, b) => toTs(b.executionTime) - toTs(a.executionTime));
|
|
6704
|
+
const capped = filtered.slice(0, Math.max(1, maxRuns));
|
|
6705
|
+
const pages = Math.max(1, Math.ceil(capped.length / Math.max(1, pageSize)));
|
|
6706
|
+
const safePage = Math.min(Math.max(page, 1), pages);
|
|
6707
|
+
const start = (safePage - 1) * pageSize;
|
|
6708
|
+
const end = start + pageSize;
|
|
6709
|
+
return {
|
|
6710
|
+
result: capped.slice(start, end),
|
|
6711
|
+
numberOfResults: capped.length,
|
|
6712
|
+
page: safePage,
|
|
6713
|
+
totalPages: pages
|
|
6714
|
+
};
|
|
6715
|
+
}
|
|
5534
6716
|
};
|
|
5535
6717
|
|
|
5536
6718
|
// lib/services/FolderService.ts
|
|
@@ -6255,6 +7437,241 @@ var IntegrationPackInstanceService = class {
|
|
|
6255
7437
|
}
|
|
6256
7438
|
});
|
|
6257
7439
|
}
|
|
7440
|
+
/**
|
|
7441
|
+
* Browse Integration Pack Instances for an Account Group
|
|
7442
|
+
* @param requestBody Possible properties include: accountGroup (name), search (name/overrideName), page, pageSize
|
|
7443
|
+
* @returns IntegrationPackInstanceQueryResponse Successful request and response.
|
|
7444
|
+
* @throws ApiError
|
|
7445
|
+
*/
|
|
7446
|
+
async fetchIntegrationPackInstances(params) {
|
|
7447
|
+
const { accountGroup, search, page = 1, pageSize = 12 } = params;
|
|
7448
|
+
const agResp = await this.httpRequest.request({
|
|
7449
|
+
method: "POST",
|
|
7450
|
+
url: "/AccountGroup/query",
|
|
7451
|
+
mediaType: "application/json",
|
|
7452
|
+
body: queryFilter("name", "EQUALS", [accountGroup]),
|
|
7453
|
+
overrideMode: "force-parent"
|
|
7454
|
+
});
|
|
7455
|
+
const groupId = agResp?.result?.[0]?.id;
|
|
7456
|
+
if (!groupId) throw new Error(`Code [1005] - AccountGroup '${accountGroup}' not found.`);
|
|
7457
|
+
const agIpResp = await this.httpRequest.request({
|
|
7458
|
+
method: "POST",
|
|
7459
|
+
url: "/AccountGroupIntegrationPack/query",
|
|
7460
|
+
mediaType: "application/json",
|
|
7461
|
+
body: queryFilter("accountGroupId", "EQUALS", [groupId]),
|
|
7462
|
+
overrideMode: "force-parent"
|
|
7463
|
+
});
|
|
7464
|
+
const agRows = agIpResp?.result ?? [];
|
|
7465
|
+
const packIds = agRows.map((r) => r?.integrationPackId).filter(Boolean);
|
|
7466
|
+
const installationTypeById = /* @__PURE__ */ new Map();
|
|
7467
|
+
const packNameById = /* @__PURE__ */ new Map();
|
|
7468
|
+
for (const r of agRows) {
|
|
7469
|
+
if (r?.integrationPackId && r?.installationType) installationTypeById.set(r.integrationPackId, r.installationType);
|
|
7470
|
+
if (r?.integrationPackId && r?.integrationPackName) packNameById.set(r.integrationPackId, r.integrationPackName);
|
|
7471
|
+
}
|
|
7472
|
+
if (packIds.length === 0) {
|
|
7473
|
+
return { result: [], page, pageSize, numberOfResults: 0, totalPages: 0 };
|
|
7474
|
+
}
|
|
7475
|
+
const ipDetailsResp = await this.httpRequest.request({
|
|
7476
|
+
method: "POST",
|
|
7477
|
+
url: "/IntegrationPack/query",
|
|
7478
|
+
mediaType: "application/json",
|
|
7479
|
+
body: nestedQueryFilter(
|
|
7480
|
+
packIds.map((id) => ({ property: "id", operator: "EQUALS", value: id })),
|
|
7481
|
+
"or"
|
|
7482
|
+
)
|
|
7483
|
+
});
|
|
7484
|
+
const ipDetails = ipDetailsResp?.result ?? [];
|
|
7485
|
+
const packDescById = /* @__PURE__ */ new Map();
|
|
7486
|
+
for (const ip of ipDetails) {
|
|
7487
|
+
if (ip?.id && ip?.Description) packDescById.set(ip.id, ip.Description);
|
|
7488
|
+
}
|
|
7489
|
+
const instResp = await this.httpRequest.request({
|
|
7490
|
+
method: "POST",
|
|
7491
|
+
url: "/IntegrationPackInstance/query",
|
|
7492
|
+
mediaType: "application/json",
|
|
7493
|
+
body: nestedQueryFilter(
|
|
7494
|
+
packIds.map((id) => ({ property: "integrationPackId", operator: "EQUALS", value: id })),
|
|
7495
|
+
"or"
|
|
7496
|
+
)
|
|
7497
|
+
});
|
|
7498
|
+
const allInstances = instResp?.result ?? [];
|
|
7499
|
+
const searchLc = search?.toLowerCase();
|
|
7500
|
+
const filtered = searchLc ? allInstances.filter(
|
|
7501
|
+
(inst) => (inst?.integrationPackInstancName?.toLowerCase?.().includes(searchLc) ?? false) || (inst?.integrationPackOverrideName?.toLowerCase?.().includes(searchLc) ?? false)
|
|
7502
|
+
) : allInstances;
|
|
7503
|
+
const total = filtered.length;
|
|
7504
|
+
const totalPages = Math.max(1, Math.ceil(total / pageSize));
|
|
7505
|
+
const clampedPage = Math.min(Math.max(1, page), totalPages);
|
|
7506
|
+
const start = (clampedPage - 1) * pageSize;
|
|
7507
|
+
const slice = filtered.slice(start, start + pageSize);
|
|
7508
|
+
const enriched = await Promise.all(
|
|
7509
|
+
slice.map(async (instance) => {
|
|
7510
|
+
const inst = { ...instance };
|
|
7511
|
+
inst.installed = true;
|
|
7512
|
+
const ipId = inst.integrationPackId;
|
|
7513
|
+
const rawType = installationTypeById.get(ipId);
|
|
7514
|
+
inst.installationType = rawType === "SINGLE" || rawType === "MULTI" ? rawType : "SINGLE";
|
|
7515
|
+
inst.integrationPackName = packNameById.get(ipId);
|
|
7516
|
+
inst.integrationPackDescription = packDescById.get(ipId);
|
|
7517
|
+
const ipeResp = await this.httpRequest.request({
|
|
7518
|
+
method: "POST",
|
|
7519
|
+
url: "/IntegrationPackEnvironmentAttachment/query",
|
|
7520
|
+
mediaType: "application/json",
|
|
7521
|
+
body: queryFilter("integrationPackInstanceId", "EQUALS", [inst.id])
|
|
7522
|
+
});
|
|
7523
|
+
const attachments = ipeResp?.result ?? [];
|
|
7524
|
+
for (const att of attachments) {
|
|
7525
|
+
if (att?.environmentId) inst.environmentId = att.environmentId;
|
|
7526
|
+
}
|
|
7527
|
+
return inst;
|
|
7528
|
+
})
|
|
7529
|
+
);
|
|
7530
|
+
return {
|
|
7531
|
+
numberOfResults: total,
|
|
7532
|
+
result: enriched,
|
|
7533
|
+
page: clampedPage,
|
|
7534
|
+
pageSize,
|
|
7535
|
+
totalPages
|
|
7536
|
+
};
|
|
7537
|
+
}
|
|
7538
|
+
/**
|
|
7539
|
+
* Create and attach an Integration Pack Instance
|
|
7540
|
+
* @param requestBody Possible properties include: integrationPackId, isSingleInstall, environmentId, integrationPackOverrideName, accountGroupName (for AG-mapped display name)
|
|
7541
|
+
* @returns IntegrationPackInstanceQueryResponse Successful request and response.
|
|
7542
|
+
* @throws ApiError
|
|
7543
|
+
*/
|
|
7544
|
+
async createAndAttachIntegrationPackInstance(params) {
|
|
7545
|
+
const { integrationPackId, isSingleInstall, environmentId, integrationPackOverrideName, accountGroupName } = params;
|
|
7546
|
+
if (!integrationPackId) throw new Error("Code [2001] - integrationPackId is required");
|
|
7547
|
+
if (!environmentId) throw new Error("Code [2002] - environmentId is required");
|
|
7548
|
+
const instance = await this.httpRequest.request({
|
|
7549
|
+
method: "POST",
|
|
7550
|
+
url: "/IntegrationPackInstance",
|
|
7551
|
+
mediaType: "application/json",
|
|
7552
|
+
body: {
|
|
7553
|
+
integrationPackId,
|
|
7554
|
+
...isSingleInstall ? {} : { integrationPackOverrideName }
|
|
7555
|
+
}
|
|
7556
|
+
});
|
|
7557
|
+
if (!instance?.id) throw new Error("Code [1011] - Integration Pack Instance missing ID after creation.");
|
|
7558
|
+
const attachResp = await this.httpRequest.request({
|
|
7559
|
+
method: "POST",
|
|
7560
|
+
url: "/IntegrationPackEnvironmentAttachment",
|
|
7561
|
+
mediaType: "application/json",
|
|
7562
|
+
body: {
|
|
7563
|
+
environmentId,
|
|
7564
|
+
integrationPackInstanceId: instance.id
|
|
7565
|
+
}
|
|
7566
|
+
});
|
|
7567
|
+
if (!attachResp?.id) throw new Error("Code [1012] - Environment attachment failed, no ID returned.");
|
|
7568
|
+
let integrationPackDescription;
|
|
7569
|
+
let integrationPackName;
|
|
7570
|
+
try {
|
|
7571
|
+
const ipResp = await this.httpRequest.request({
|
|
7572
|
+
method: "POST",
|
|
7573
|
+
url: "/IntegrationPack/query",
|
|
7574
|
+
mediaType: "application/json",
|
|
7575
|
+
body: nestedQueryFilter(
|
|
7576
|
+
[{ property: "id", operator: "EQUALS", value: integrationPackId }],
|
|
7577
|
+
"or"
|
|
7578
|
+
)
|
|
7579
|
+
});
|
|
7580
|
+
const pack = ipResp?.result?.[0];
|
|
7581
|
+
if (pack?.Description) integrationPackDescription = pack.Description;
|
|
7582
|
+
if (!integrationPackOverrideName && accountGroupName) {
|
|
7583
|
+
integrationPackName = await this.resolvePackNameFromAccountGroup(accountGroupName, integrationPackId);
|
|
7584
|
+
if (!integrationPackName) integrationPackName = pack?.name || "";
|
|
7585
|
+
}
|
|
7586
|
+
} catch {
|
|
7587
|
+
}
|
|
7588
|
+
return {
|
|
7589
|
+
...instance,
|
|
7590
|
+
id: instance.id,
|
|
7591
|
+
integrationPackId,
|
|
7592
|
+
integrationPackOverrideName: instance.integrationPackOverrideName || integrationPackOverrideName || "",
|
|
7593
|
+
integrationPackName: instance.integrationPackOverrideName || integrationPackOverrideName || integrationPackName || "",
|
|
7594
|
+
integrationPackDescription: integrationPackDescription || "",
|
|
7595
|
+
installationType: isSingleInstall ? "SINGLE" : "MULTI",
|
|
7596
|
+
installed: true,
|
|
7597
|
+
environmentId
|
|
7598
|
+
};
|
|
7599
|
+
}
|
|
7600
|
+
/**
|
|
7601
|
+
* List Account Group Publisher Packs
|
|
7602
|
+
* @param requestBody Possible properties include: accountGroup (name)
|
|
7603
|
+
* @returns IntegrationPackInstanceQueryResponse Successful request and response.
|
|
7604
|
+
* @throws ApiError
|
|
7605
|
+
*/
|
|
7606
|
+
async listAccountGroupPublisherPacks(params) {
|
|
7607
|
+
const { accountGroup } = params;
|
|
7608
|
+
const agResp = await this.httpRequest.request({
|
|
7609
|
+
method: "POST",
|
|
7610
|
+
url: "/AccountGroup/query",
|
|
7611
|
+
mediaType: "application/json",
|
|
7612
|
+
body: queryFilter("name", "EQUALS", [accountGroup]),
|
|
7613
|
+
overrideMode: "force-parent"
|
|
7614
|
+
});
|
|
7615
|
+
const groupId = agResp?.result?.[0]?.id;
|
|
7616
|
+
if (!groupId) throw Object.assign(new Error(`Code [1005] - AccountGroup '${accountGroup}' not found.`), { status: 404 });
|
|
7617
|
+
const agIpResp = await this.httpRequest.request({
|
|
7618
|
+
method: "POST",
|
|
7619
|
+
url: "/AccountGroupIntegrationPack/query",
|
|
7620
|
+
mediaType: "application/json",
|
|
7621
|
+
body: queryFilter("accountGroupId", "EQUALS", [groupId]),
|
|
7622
|
+
overrideMode: "force-parent"
|
|
7623
|
+
});
|
|
7624
|
+
const agRows = agIpResp?.result ?? [];
|
|
7625
|
+
const packIds = agRows.map((r) => r.integrationPackId).filter(Boolean);
|
|
7626
|
+
if (packIds.length === 0) {
|
|
7627
|
+
throw Object.assign(new Error(`Code [1007] - No integration packs found for AccountGroupId[ ${groupId}]`), { status: 404 });
|
|
7628
|
+
}
|
|
7629
|
+
const typeById = /* @__PURE__ */ new Map();
|
|
7630
|
+
for (const r of agRows) {
|
|
7631
|
+
if (r?.integrationPackId && r?.installationType) typeById.set(r.integrationPackId, r.installationType);
|
|
7632
|
+
}
|
|
7633
|
+
const bulkResp = await this.httpRequest.request({
|
|
7634
|
+
method: "POST",
|
|
7635
|
+
url: "/PublisherIntegrationPack/bulk",
|
|
7636
|
+
mediaType: "application/json",
|
|
7637
|
+
body: bulkFilter("GET", packIds),
|
|
7638
|
+
overrideMode: "force-parent"
|
|
7639
|
+
});
|
|
7640
|
+
const fetched = bulkResp?.response?.filter((r) => r.statusCode === 200 && r.Result).map((r) => r.Result) ?? [];
|
|
7641
|
+
const instResp = await this.httpRequest.request({
|
|
7642
|
+
method: "POST",
|
|
7643
|
+
url: "/IntegrationPackInstance/query",
|
|
7644
|
+
mediaType: "application/json",
|
|
7645
|
+
body: nestedQueryFilter(
|
|
7646
|
+
packIds.map((id) => ({ property: "integrationPackId", operator: "EQUALS", value: id })),
|
|
7647
|
+
"or"
|
|
7648
|
+
)
|
|
7649
|
+
});
|
|
7650
|
+
const existing = instResp?.result ?? [];
|
|
7651
|
+
const existingIds = new Set(existing.map((i) => i.integrationPackId));
|
|
7652
|
+
return fetched.filter((pack) => !(typeById.get(pack.id) === "SINGLE" && existingIds.has(pack.id)));
|
|
7653
|
+
}
|
|
7654
|
+
/* =============== private =============== */
|
|
7655
|
+
async resolvePackNameFromAccountGroup(accountGroupName, integrationPackId) {
|
|
7656
|
+
const agResp = await this.httpRequest.request({
|
|
7657
|
+
method: "POST",
|
|
7658
|
+
url: "/AccountGroup/query",
|
|
7659
|
+
mediaType: "application/json",
|
|
7660
|
+
body: queryFilter("name", "EQUALS", [accountGroupName]),
|
|
7661
|
+
overrideMode: "force-parent"
|
|
7662
|
+
});
|
|
7663
|
+
const groupId = agResp?.result?.[0]?.id;
|
|
7664
|
+
if (!groupId) return void 0;
|
|
7665
|
+
const agIpResp = await this.httpRequest.request({
|
|
7666
|
+
method: "POST",
|
|
7667
|
+
url: "/AccountGroupIntegrationPack/query",
|
|
7668
|
+
mediaType: "application/json",
|
|
7669
|
+
body: queryFilter("accountGroupId", "EQUALS", [groupId]),
|
|
7670
|
+
overrideMode: "force-parent"
|
|
7671
|
+
});
|
|
7672
|
+
const row = (agIpResp?.result ?? []).find((r) => r?.integrationPackId === integrationPackId);
|
|
7673
|
+
return row?.integrationPackName;
|
|
7674
|
+
}
|
|
6258
7675
|
};
|
|
6259
7676
|
|
|
6260
7677
|
// lib/services/JavaRollbackService.ts
|
|
@@ -7169,6 +8586,31 @@ var PersistedProcessPropertiesService = class {
|
|
|
7169
8586
|
}
|
|
7170
8587
|
};
|
|
7171
8588
|
|
|
8589
|
+
// lib/helpers/fetchEnvironmentAtomAttachments.ts
|
|
8590
|
+
async function fetchEnvironmentAtomAttachments(httpRequest, environmentId) {
|
|
8591
|
+
return httpRequest.request({
|
|
8592
|
+
method: "POST",
|
|
8593
|
+
url: "/EnvironmentAtomAttachment/query",
|
|
8594
|
+
body: queryFilter("environmentId", "EQUALS", [environmentId]),
|
|
8595
|
+
mediaType: "application/json",
|
|
8596
|
+
overrideMode: "force-child"
|
|
8597
|
+
});
|
|
8598
|
+
}
|
|
8599
|
+
|
|
8600
|
+
// lib/helpers/createExecutionRequest.ts
|
|
8601
|
+
async function createExecutionRequest(httpRequest, request2) {
|
|
8602
|
+
return httpRequest.request({
|
|
8603
|
+
method: "POST",
|
|
8604
|
+
url: "/ExecutionRequest",
|
|
8605
|
+
body: request2,
|
|
8606
|
+
mediaType: "application/json",
|
|
8607
|
+
errors: {
|
|
8608
|
+
403: `Missing or incorrect authentication credentials.
|
|
8609
|
+
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)`
|
|
8610
|
+
}
|
|
8611
|
+
});
|
|
8612
|
+
}
|
|
8613
|
+
|
|
7172
8614
|
// lib/services/ProcessService.ts
|
|
7173
8615
|
var ProcessService = class {
|
|
7174
8616
|
constructor(httpRequest) {
|
|
@@ -7253,6 +8695,50 @@ var ProcessService = class {
|
|
|
7253
8695
|
}
|
|
7254
8696
|
});
|
|
7255
8697
|
}
|
|
8698
|
+
/**
|
|
8699
|
+
* Triggers execution of all processes for an Integration Pack Instance
|
|
8700
|
+
* This operation triggers the execution of all processes associated with the specified Integration Pack Instance ID across all atoms in the specified environment.
|
|
8701
|
+
* @param requestBody
|
|
8702
|
+
* @returns ProcessQueryResponse Successful request and response.
|
|
8703
|
+
* @throws ApiError
|
|
8704
|
+
*/
|
|
8705
|
+
async runAllProcesses(integrationPackInstanceId, environmentId) {
|
|
8706
|
+
const urls = [];
|
|
8707
|
+
const { result: attachments = [] } = await fetchEnvironmentAtomAttachments(this.httpRequest, environmentId);
|
|
8708
|
+
const atomIds = attachments.map((att) => att?.atomId).filter((id) => Boolean(id));
|
|
8709
|
+
if (!atomIds.length) {
|
|
8710
|
+
throw Object.assign(
|
|
8711
|
+
new Error(`No atoms found for environmentId: ${environmentId}`),
|
|
8712
|
+
{ status: 404 }
|
|
8713
|
+
);
|
|
8714
|
+
}
|
|
8715
|
+
const procResp = await fetchProcesses(this.httpRequest, integrationPackInstanceId);
|
|
8716
|
+
const processes = procResp?.result ?? [];
|
|
8717
|
+
if (!processes.length) {
|
|
8718
|
+
throw Object.assign(
|
|
8719
|
+
new Error(`No processes found for integrationPackInstanceId: ${integrationPackInstanceId}`),
|
|
8720
|
+
{ status: 404 }
|
|
8721
|
+
);
|
|
8722
|
+
}
|
|
8723
|
+
for (const proc of processes) {
|
|
8724
|
+
const processId = proc?.id;
|
|
8725
|
+
if (!processId) continue;
|
|
8726
|
+
for (const atomId of atomIds) {
|
|
8727
|
+
const executionRequest = {
|
|
8728
|
+
DynamicProcessProperties: { DynamicProcessProperty: [] },
|
|
8729
|
+
ProcessProperties: { ProcessProperty: [] },
|
|
8730
|
+
processId,
|
|
8731
|
+
atomId
|
|
8732
|
+
};
|
|
8733
|
+
const result = await createExecutionRequest(this.httpRequest, executionRequest);
|
|
8734
|
+
const recordUrl = result?.recordUrl;
|
|
8735
|
+
if (recordUrl) {
|
|
8736
|
+
urls.push(recordUrl);
|
|
8737
|
+
}
|
|
8738
|
+
}
|
|
8739
|
+
}
|
|
8740
|
+
return urls;
|
|
8741
|
+
}
|
|
7256
8742
|
};
|
|
7257
8743
|
|
|
7258
8744
|
// lib/services/ProcessAtomAttachmentService.ts
|
|
@@ -7508,6 +8994,127 @@ var ProcessSchedulesService = class {
|
|
|
7508
8994
|
}
|
|
7509
8995
|
});
|
|
7510
8996
|
}
|
|
8997
|
+
/**
|
|
8998
|
+
* Fetch the first ProcessSchedules that matches any process on any atom in the environment.
|
|
8999
|
+
* Returns { numberOfResults, result: ProcessSchedules[] }.
|
|
9000
|
+
*/
|
|
9001
|
+
async fetchProcessSchedules(integrationPackInstanceId, environmentId) {
|
|
9002
|
+
try {
|
|
9003
|
+
const { result: attachments = [] } = await fetchEnvironmentAtomAttachments(this.httpRequest, environmentId);
|
|
9004
|
+
const atomIds = attachments.map((att) => att?.atomId).filter((id) => Boolean(id));
|
|
9005
|
+
if (!atomIds.length) {
|
|
9006
|
+
throw Object.assign(
|
|
9007
|
+
new Error(`No atoms found for environmentId: ${environmentId}`),
|
|
9008
|
+
{ status: 404 }
|
|
9009
|
+
);
|
|
9010
|
+
}
|
|
9011
|
+
const procResp = await fetchProcesses(this.httpRequest, integrationPackInstanceId);
|
|
9012
|
+
const processes = procResp?.result ?? [];
|
|
9013
|
+
if (!processes.length) {
|
|
9014
|
+
throw Object.assign(
|
|
9015
|
+
new Error(`No processes found for integrationPackInstanceId: ${integrationPackInstanceId}`),
|
|
9016
|
+
{ status: 404 }
|
|
9017
|
+
);
|
|
9018
|
+
}
|
|
9019
|
+
for (const proc of processes) {
|
|
9020
|
+
const processId = proc?.id;
|
|
9021
|
+
if (!processId) continue;
|
|
9022
|
+
for (const atomId of atomIds) {
|
|
9023
|
+
const scheduleFilter = nestedQueryFilter(
|
|
9024
|
+
[
|
|
9025
|
+
{ property: "atomId", operator: "EQUALS", value: atomId },
|
|
9026
|
+
{ property: "processId", operator: "EQUALS", value: processId }
|
|
9027
|
+
],
|
|
9028
|
+
"and"
|
|
9029
|
+
);
|
|
9030
|
+
const qs = await this.queryProcessSchedules(scheduleFilter);
|
|
9031
|
+
const row = Array.isArray(qs?.result) ? qs.result[0] : void 0;
|
|
9032
|
+
if (row?.Schedule?.length) {
|
|
9033
|
+
return {
|
|
9034
|
+
numberOfResults: 1,
|
|
9035
|
+
result: [row]
|
|
9036
|
+
};
|
|
9037
|
+
}
|
|
9038
|
+
}
|
|
9039
|
+
}
|
|
9040
|
+
return {
|
|
9041
|
+
numberOfResults: 0,
|
|
9042
|
+
result: []
|
|
9043
|
+
};
|
|
9044
|
+
} catch (err) {
|
|
9045
|
+
throw Object.assign(
|
|
9046
|
+
new Error(
|
|
9047
|
+
`Unable to fetch process schedules for env=${environmentId} ipi=${integrationPackInstanceId}: ${err?.message ?? err}`
|
|
9048
|
+
),
|
|
9049
|
+
{ status: err?.status ?? 400 }
|
|
9050
|
+
);
|
|
9051
|
+
}
|
|
9052
|
+
}
|
|
9053
|
+
/**
|
|
9054
|
+
* Updates all ProcessSchedules for all processes on all atoms in the environment.
|
|
9055
|
+
*/
|
|
9056
|
+
async updateAllProcessSchedules(integrationPackInstanceId, environmentId, schedules) {
|
|
9057
|
+
try {
|
|
9058
|
+
const { result: attachments = [] } = await fetchEnvironmentAtomAttachments(this.httpRequest, environmentId);
|
|
9059
|
+
const atomIds = attachments.map((att) => att?.atomId).filter((id) => Boolean(id));
|
|
9060
|
+
if (!atomIds.length) {
|
|
9061
|
+
throw Object.assign(
|
|
9062
|
+
new Error(`No atoms found for environmentId: ${environmentId}`),
|
|
9063
|
+
{ status: 404 }
|
|
9064
|
+
);
|
|
9065
|
+
}
|
|
9066
|
+
const procResp = await fetchProcesses(this.httpRequest, integrationPackInstanceId);
|
|
9067
|
+
const processes = procResp?.result ?? [];
|
|
9068
|
+
if (!processes.length) {
|
|
9069
|
+
throw Object.assign(
|
|
9070
|
+
new Error(`No processes found for integrationPackInstanceId: ${integrationPackInstanceId}`),
|
|
9071
|
+
{ status: 404 }
|
|
9072
|
+
);
|
|
9073
|
+
}
|
|
9074
|
+
const retry = {
|
|
9075
|
+
Schedule: schedules,
|
|
9076
|
+
maxRetry: 5
|
|
9077
|
+
};
|
|
9078
|
+
const updated = [];
|
|
9079
|
+
for (const proc of processes) {
|
|
9080
|
+
const processId = proc?.id;
|
|
9081
|
+
if (!processId) continue;
|
|
9082
|
+
for (const atomId of atomIds) {
|
|
9083
|
+
if (!atomId) continue;
|
|
9084
|
+
const conceptualId = `${processId}:${atomId}`;
|
|
9085
|
+
const schedFilter = nestedQueryFilter(
|
|
9086
|
+
[
|
|
9087
|
+
{ property: "atomId", operator: "EQUALS", value: atomId },
|
|
9088
|
+
{ property: "processId", operator: "EQUALS", value: processId }
|
|
9089
|
+
],
|
|
9090
|
+
"and"
|
|
9091
|
+
);
|
|
9092
|
+
const { result: existingResults = [] } = await this.queryProcessSchedules(schedFilter);
|
|
9093
|
+
const existing = existingResults[0];
|
|
9094
|
+
const schedulePayload = {
|
|
9095
|
+
id: conceptualId,
|
|
9096
|
+
atomId,
|
|
9097
|
+
processId,
|
|
9098
|
+
Schedule: schedules,
|
|
9099
|
+
Retry: retry
|
|
9100
|
+
};
|
|
9101
|
+
const result = await this.updateProcessSchedules(
|
|
9102
|
+
conceptualId,
|
|
9103
|
+
schedulePayload
|
|
9104
|
+
);
|
|
9105
|
+
updated.push(result);
|
|
9106
|
+
}
|
|
9107
|
+
}
|
|
9108
|
+
return updated;
|
|
9109
|
+
} catch (err) {
|
|
9110
|
+
throw Object.assign(
|
|
9111
|
+
new Error(
|
|
9112
|
+
`Unable to fetch process schedules for env=${environmentId} ipi=${integrationPackInstanceId}: ${err?.message ?? err}`
|
|
9113
|
+
),
|
|
9114
|
+
{ status: err?.status ?? 400 }
|
|
9115
|
+
);
|
|
9116
|
+
}
|
|
9117
|
+
}
|
|
7511
9118
|
};
|
|
7512
9119
|
|
|
7513
9120
|
// lib/services/ProcessScheduleStatusService.ts
|
|
@@ -9095,7 +10702,8 @@ var Boomi = class {
|
|
|
9095
10702
|
USERNAME: config?.USERNAME,
|
|
9096
10703
|
PASSWORD: config?.PASSWORD,
|
|
9097
10704
|
HEADERS: config?.HEADERS,
|
|
9098
|
-
ENCODE_PATH: config?.ENCODE_PATH
|
|
10705
|
+
ENCODE_PATH: config?.ENCODE_PATH,
|
|
10706
|
+
LOGGER: config?.LOGGER
|
|
9099
10707
|
});
|
|
9100
10708
|
this.account = new AccountService(this.request);
|
|
9101
10709
|
this.accountCloudAttachmentProperties = new AccountCloudAttachmentPropertiesService(this.request);
|
|
@@ -9225,7 +10833,8 @@ var OpenAPI = {
|
|
|
9225
10833
|
USERNAME: void 0,
|
|
9226
10834
|
PASSWORD: void 0,
|
|
9227
10835
|
HEADERS: void 0,
|
|
9228
|
-
ENCODE_PATH: void 0
|
|
10836
|
+
ENCODE_PATH: void 0,
|
|
10837
|
+
LOGGER: void 0
|
|
9229
10838
|
};
|
|
9230
10839
|
|
|
9231
10840
|
// lib/models/Account.ts
|
|
@@ -14425,6 +16034,8 @@ var X12Options;
|
|
|
14425
16034
|
X12ConnectorRecordGroupingExpression,
|
|
14426
16035
|
X12ConnectorRecordService,
|
|
14427
16036
|
X12ConnectorRecordSimpleExpression,
|
|
14428
|
-
X12Options
|
|
16037
|
+
X12Options,
|
|
16038
|
+
redactBody,
|
|
16039
|
+
redactHeaders
|
|
14429
16040
|
});
|
|
14430
16041
|
//# sourceMappingURL=index.cjs.map
|