@uipath/integrationservice-tool 1.205.0-preview.284 → 1.206.0-preview.282
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 +5 -0
- package/dist/THIRD-PARTY-NOTICES.md +64 -3
- package/dist/applicationinsights-web-8m26566f.js +17209 -0
- package/dist/{embedded-file-reader-r66242ey.js → embedded-file-reader-0228j82a.js} +1 -4
- package/dist/first-party-service-ahcc6xc6.js +8 -0
- package/dist/{index-fyc0k5dd.js → index-5pzp2qeb.js} +5350 -3271
- package/dist/{index-xafcs9np.js → index-jc6qcbca.js} +254 -224
- package/dist/{index-h8cph72k.js → index-nzr4mx5p.js} +2 -22
- package/dist/index-z2qk2qn6.js +24 -0
- package/dist/index.js +9 -10
- package/dist/index.umd.min-ttg1qc0x.js +7814 -0
- package/dist/{jmespath-e4a59c8w.js → jmespath-wwym30dp.js} +1 -1
- package/dist/{js-yaml-87cdx6bm.js → js-yaml-a2bk27p6.js} +1 -3
- package/dist/solution-auth-w6edcwxb.js +9 -0
- package/dist/{tool-ffr7313v.js → tool-4p00zw06.js} +947 -1413
- package/dist/{tool-1yh8g550.js → tool-6an893wm.js} +12 -3
- package/dist/{tool-5yj9vsky.js → tool-b4505g49.js} +6 -7
- package/dist/{tool-gvcwm7sf.js → tool-fy6vakbq.js} +1504 -407
- package/dist/{tool-fj5zzmeh.js → tool-hdzdh357.js} +131 -65
- package/dist/{tool-gdtpsdn7.js → tool-mm1x18d6.js} +223 -28
- package/dist/tool.js +8 -9
- package/package.json +2 -2
- package/dist/first-party-service-srxaftkn.js +0 -27
- package/dist/index-kmp9fmhb.js +0 -25
- package/dist/index.umd.min-fqefd9kn.js +0 -7814
- package/dist/solution-auth-gyqtxa4n.js +0 -10
- package/dist/tool-53w8skv5.js +0 -262
|
@@ -1,45 +1,41 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
addSdkUserAgentHeader,
|
|
2
|
+
getFileSystem,
|
|
3
|
+
fetchTenantsAndOrganizations,
|
|
4
|
+
getLoginStatusAsync,
|
|
5
|
+
getAuthContext
|
|
6
|
+
} from "./tool-hdzdh357.js";
|
|
7
|
+
import {
|
|
9
8
|
catchError,
|
|
10
|
-
|
|
9
|
+
httpStatusOf,
|
|
10
|
+
classifyHttpStatus,
|
|
11
11
|
extractErrorDetails,
|
|
12
12
|
extractErrorMessage,
|
|
13
|
-
|
|
13
|
+
RESULTS,
|
|
14
|
+
Option,
|
|
14
15
|
getOutputSink,
|
|
15
|
-
getSdkUserAgentToken,
|
|
16
|
-
httpStatusOf,
|
|
17
|
-
installSdkUserAgentHeader,
|
|
18
16
|
logger,
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
EXIT_CODES,
|
|
18
|
+
OutputFormatter,
|
|
21
19
|
processContext,
|
|
22
20
|
requireConfirmation,
|
|
21
|
+
UIPATH_HOME_DIR,
|
|
22
|
+
getInteractivityMode,
|
|
23
23
|
resolveDeprecatedOptionAlias,
|
|
24
|
-
unzipSync,
|
|
25
24
|
warnDeprecatedOptionAlias,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} from "./tool-
|
|
34
|
-
import {
|
|
35
|
-
__require
|
|
36
|
-
} from "./tool-1yh8g550.js";
|
|
25
|
+
createHiddenDeprecatedTenantOption,
|
|
26
|
+
parsePositiveInteger,
|
|
27
|
+
PollOutcome,
|
|
28
|
+
pollUntil,
|
|
29
|
+
getSdkUserAgentToken,
|
|
30
|
+
addSdkUserAgentHeader,
|
|
31
|
+
installSdkUserAgentHeader
|
|
32
|
+
} from "./tool-4p00zw06.js";
|
|
37
33
|
// package.json
|
|
38
34
|
var package_default = {
|
|
39
35
|
name: "@uipath/integrationservice-tool",
|
|
40
36
|
author: "UiPath",
|
|
41
37
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
42
|
-
version: "1.
|
|
38
|
+
version: "1.206.0-preview.282",
|
|
43
39
|
description: "Manage Integration Service connectors, connections, and triggers.",
|
|
44
40
|
private: false,
|
|
45
41
|
repository: {
|
|
@@ -66,6 +62,7 @@ var package_default = {
|
|
|
66
62
|
],
|
|
67
63
|
scripts: {
|
|
68
64
|
build: "bun ../../tools/build-tool.ts",
|
|
65
|
+
typecheck: "tsc --noEmit",
|
|
69
66
|
package: "bun run build && bun pm pack",
|
|
70
67
|
lint: "biome check .",
|
|
71
68
|
"lint:fix": "biome check --write .",
|
|
@@ -616,7 +613,7 @@ var package_default2 = {
|
|
|
616
613
|
name: "@uipath/integrationservice-sdk",
|
|
617
614
|
author: "UiPath",
|
|
618
615
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
619
|
-
version: "1.
|
|
616
|
+
version: "1.206.0-preview.282",
|
|
620
617
|
repository: {
|
|
621
618
|
type: "git",
|
|
622
619
|
url: "https://github.com/UiPath/cli.git",
|
|
@@ -637,17 +634,26 @@ var package_default2 = {
|
|
|
637
634
|
".": {
|
|
638
635
|
types: "./dist/src/index.d.ts",
|
|
639
636
|
default: "./dist/index.js"
|
|
637
|
+
},
|
|
638
|
+
"./bindings": {
|
|
639
|
+
types: "./dist/src/bindings.d.ts",
|
|
640
|
+
default: "./dist/bindings.js"
|
|
641
|
+
},
|
|
642
|
+
"./connections": {
|
|
643
|
+
types: "./dist/src/connections.d.ts",
|
|
644
|
+
default: "./dist/connections.js"
|
|
640
645
|
}
|
|
641
646
|
},
|
|
642
647
|
files: [
|
|
643
648
|
"dist"
|
|
644
649
|
],
|
|
645
650
|
scripts: {
|
|
646
|
-
build: "bun build ./src/index.ts --outdir dist --format esm --target node --sourcemap=linked && tsc -p tsconfig.build.json --noCheck",
|
|
651
|
+
build: "bun build ./src/index.ts ./src/bindings.ts ./src/connections.ts --outdir dist --root ./src --format esm --target node --sourcemap=linked && tsc -p tsconfig.build.json --noCheck",
|
|
647
652
|
generate: "bun run src/scripts/generate-sdk.ts",
|
|
648
653
|
lint: "biome check .",
|
|
649
654
|
test: "vitest run",
|
|
650
|
-
"test:coverage": "vitest run --coverage"
|
|
655
|
+
"test:coverage": "vitest run --coverage",
|
|
656
|
+
typecheck: "tsc --noEmit"
|
|
651
657
|
},
|
|
652
658
|
devDependencies: {
|
|
653
659
|
"@uipath/auth": "workspace:*",
|
|
@@ -658,7 +664,7 @@ var package_default2 = {
|
|
|
658
664
|
typescript: "^7.0.2"
|
|
659
665
|
},
|
|
660
666
|
dependencies: {
|
|
661
|
-
"@uipath/integration-service-design-time": "
|
|
667
|
+
"@uipath/integration-service-design-time": "3.3.0"
|
|
662
668
|
}
|
|
663
669
|
};
|
|
664
670
|
|
|
@@ -6394,10 +6400,13 @@ async function getValidatedAuthContext(options) {
|
|
|
6394
6400
|
tenantName: ctx.tenantName
|
|
6395
6401
|
};
|
|
6396
6402
|
}
|
|
6403
|
+
function tenantServiceRoot(baseUrl, organizationId, tenantName) {
|
|
6404
|
+
return `${baseUrl}/${encodeURIComponent(organizationId)}/${encodeURIComponent(tenantName)}`;
|
|
6405
|
+
}
|
|
6397
6406
|
async function createConnectionsConfig(options) {
|
|
6398
6407
|
const { baseUrl, accessToken, organizationId, tenantName } = await getValidatedAuthContext(options);
|
|
6399
6408
|
return new Configuration({
|
|
6400
|
-
basePath: `${baseUrl
|
|
6409
|
+
basePath: `${tenantServiceRoot(baseUrl, organizationId, tenantName)}/connections_`,
|
|
6401
6410
|
accessToken: async () => accessToken,
|
|
6402
6411
|
headers: addSdkUserAgentHeader({
|
|
6403
6412
|
"x-uipath-source": "UiPath.CodingAgent"
|
|
@@ -6407,7 +6416,7 @@ async function createConnectionsConfig(options) {
|
|
|
6407
6416
|
async function createElementsConfig(options) {
|
|
6408
6417
|
const { baseUrl, accessToken, organizationId, tenantName } = await getValidatedAuthContext(options);
|
|
6409
6418
|
return new Configuration2({
|
|
6410
|
-
basePath: `${baseUrl
|
|
6419
|
+
basePath: `${tenantServiceRoot(baseUrl, organizationId, tenantName)}/elements_/v3/element`,
|
|
6411
6420
|
accessToken: async () => accessToken,
|
|
6412
6421
|
headers: addSdkUserAgentHeader({
|
|
6413
6422
|
"x-uipath-source": "UiPath.CodingAgent"
|
|
@@ -6419,12 +6428,16 @@ async function createApiClient(ApiClass, options) {
|
|
|
6419
6428
|
if (!domain) {
|
|
6420
6429
|
throw new Error(`Unknown API class: ${ApiClass.name}`);
|
|
6421
6430
|
}
|
|
6422
|
-
|
|
6431
|
+
if (domain === "connections") {
|
|
6432
|
+
const config = await createConnectionsConfig(options);
|
|
6433
|
+
return new ApiClass(config);
|
|
6434
|
+
}
|
|
6435
|
+
const config = await createElementsConfig(options);
|
|
6423
6436
|
return new ApiClass(config);
|
|
6424
6437
|
}
|
|
6425
6438
|
async function executeOperation(options, connectionId, objectName, httpMethod = "GET", body, queryParams, requestOptions) {
|
|
6426
6439
|
const { baseUrl, accessToken, organizationId, tenantName } = await getValidatedAuthContext(options);
|
|
6427
|
-
let url = `${baseUrl
|
|
6440
|
+
let url = `${tenantServiceRoot(baseUrl, organizationId, tenantName)}/elements_/v3/element/instances/${encodeURIComponent(connectionId)}/${objectName}`;
|
|
6428
6441
|
if (queryParams && Object.keys(queryParams).length > 0) {
|
|
6429
6442
|
const queryString = new URLSearchParams(queryParams).toString();
|
|
6430
6443
|
const separator = url.includes("?") ? "&" : "?";
|
|
@@ -6478,7 +6491,7 @@ var SUPPORTED_ACTIVITY_VERSIONS = [
|
|
|
6478
6491
|
];
|
|
6479
6492
|
async function getConnectorActivityMetadataV4(options, connectorKey, objectName) {
|
|
6480
6493
|
const { baseUrl, accessToken, organizationId, tenantName } = await getValidatedAuthContext(options);
|
|
6481
|
-
const url = `${baseUrl
|
|
6494
|
+
const url = `${tenantServiceRoot(baseUrl, organizationId, tenantName)}/elements_/v4/element/connectors/${encodeURIComponent(connectorKey)}/objects/${encodeURIComponent(objectName)}/metadata`;
|
|
6482
6495
|
const response = await fetch(url, {
|
|
6483
6496
|
headers: addSdkUserAgentHeader({
|
|
6484
6497
|
Authorization: `Bearer ${accessToken}`,
|
|
@@ -6494,7 +6507,7 @@ async function getConnectorActivityMetadataV4(options, connectorKey, objectName)
|
|
|
6494
6507
|
}
|
|
6495
6508
|
async function runInstanceDesignAction(options, connectionOrInstanceId, method, relativeUrl, body) {
|
|
6496
6509
|
const { baseUrl, accessToken, organizationId, tenantName } = await getValidatedAuthContext(options);
|
|
6497
|
-
const url = `${baseUrl
|
|
6510
|
+
const url = `${tenantServiceRoot(baseUrl, organizationId, tenantName)}/elements_/v3/element/instances/${encodeURIComponent(connectionOrInstanceId)}${relativeUrl}`;
|
|
6498
6511
|
const headers = addSdkUserAgentHeader({
|
|
6499
6512
|
Authorization: `Bearer ${accessToken}`,
|
|
6500
6513
|
Accept: "application/json",
|
|
@@ -6526,7 +6539,7 @@ async function getWebhookConfig(options, connectionId, elementInstanceId, connec
|
|
|
6526
6539
|
connectionInstanceId: String(elementInstanceId),
|
|
6527
6540
|
connectorKey
|
|
6528
6541
|
});
|
|
6529
|
-
const url = `${baseUrl
|
|
6542
|
+
const url = `${tenantServiceRoot(baseUrl, organizationId, tenantName)}/elements_/v1/webhooks/subscribers/${encodeURIComponent(connectionId)}/webhook/config?${params.toString()}`;
|
|
6530
6543
|
const response = await fetch(url, {
|
|
6531
6544
|
headers: addSdkUserAgentHeader({
|
|
6532
6545
|
Authorization: `Bearer ${accessToken}`,
|
|
@@ -6542,7 +6555,7 @@ async function getWebhookConfig(options, connectionId, elementInstanceId, connec
|
|
|
6542
6555
|
}
|
|
6543
6556
|
async function getHttpRequestPreview(options, connectionId) {
|
|
6544
6557
|
const { baseUrl, accessToken, organizationId, tenantName } = await getValidatedAuthContext(options);
|
|
6545
|
-
const url = `${baseUrl
|
|
6558
|
+
const url = `${tenantServiceRoot(baseUrl, organizationId, tenantName)}/elements_/v3/element/instances/${encodeURIComponent(connectionId)}/http-request-preview`;
|
|
6546
6559
|
const response = await fetch(url, {
|
|
6547
6560
|
method: "POST",
|
|
6548
6561
|
headers: addSdkUserAgentHeader({
|
|
@@ -6583,7 +6596,7 @@ function nextPageToken(response) {
|
|
|
6583
6596
|
return token && token.trim().length > 0 ? token : undefined;
|
|
6584
6597
|
}
|
|
6585
6598
|
function connectorsUrl(ctx, suffix = "") {
|
|
6586
|
-
return `${ctx.baseUrl
|
|
6599
|
+
return `${tenantServiceRoot(ctx.baseUrl, ctx.organizationId, ctx.tenantName)}/${CONNECTORS_PATH_SEGMENT}${suffix}`;
|
|
6587
6600
|
}
|
|
6588
6601
|
async function failFromResponse(response, action) {
|
|
6589
6602
|
if (response.type === "opaqueredirect" || response.status === 0) {
|
|
@@ -6712,7 +6725,7 @@ async function exportConnectorZip(options, connectorId) {
|
|
|
6712
6725
|
}
|
|
6713
6726
|
var PUBLISH_PATH_SEGMENT = "elements_/v3/element/publish";
|
|
6714
6727
|
function publishUrl(ctx, suffix = "") {
|
|
6715
|
-
return `${ctx.baseUrl
|
|
6728
|
+
return `${tenantServiceRoot(ctx.baseUrl, ctx.organizationId, ctx.tenantName)}/${PUBLISH_PATH_SEGMENT}${suffix}`;
|
|
6716
6729
|
}
|
|
6717
6730
|
async function publishConnector(options, args) {
|
|
6718
6731
|
const ctx = await getValidatedAuthContext(options);
|
|
@@ -6816,9 +6829,53 @@ async function listConnectors(options, params) {
|
|
|
6816
6829
|
}
|
|
6817
6830
|
// ../integrationservice-sdk/src/connection-lookup.ts
|
|
6818
6831
|
var CONNECTIONS_PAGE_SIZE = 200;
|
|
6819
|
-
var MAX_CONNECTION_PAGES =
|
|
6820
|
-
|
|
6821
|
-
|
|
6832
|
+
var MAX_CONNECTION_PAGES = 1000;
|
|
6833
|
+
|
|
6834
|
+
class ConnectionNotFoundError extends Error {
|
|
6835
|
+
connectionNotFound = true;
|
|
6836
|
+
}
|
|
6837
|
+
function isConnectionNotFoundError(error) {
|
|
6838
|
+
return typeof error === "object" && error !== null && error.connectionNotFound === true;
|
|
6839
|
+
}
|
|
6840
|
+
async function* connectionPages(api, scope) {
|
|
6841
|
+
const override = folderOverride(scope.folderKey);
|
|
6842
|
+
const seenIds = new Set;
|
|
6843
|
+
for (let pageIndex = 0;pageIndex < MAX_CONNECTION_PAGES; pageIndex++) {
|
|
6844
|
+
const request = {
|
|
6845
|
+
...scope.allFolders ? { allFolders: true } : {},
|
|
6846
|
+
mostRecentFirst: true,
|
|
6847
|
+
pageIndex,
|
|
6848
|
+
pageSize: CONNECTIONS_PAGE_SIZE
|
|
6849
|
+
};
|
|
6850
|
+
const page = override ? await api.apiV1ConnectionsGet(request, override) : await api.apiV1ConnectionsGet(request);
|
|
6851
|
+
const fresh = page.filter((connection) => {
|
|
6852
|
+
if (!connection.id) {
|
|
6853
|
+
return true;
|
|
6854
|
+
}
|
|
6855
|
+
if (seenIds.has(connection.id)) {
|
|
6856
|
+
return false;
|
|
6857
|
+
}
|
|
6858
|
+
seenIds.add(connection.id);
|
|
6859
|
+
return true;
|
|
6860
|
+
});
|
|
6861
|
+
yield fresh;
|
|
6862
|
+
if (page.length < CONNECTIONS_PAGE_SIZE) {
|
|
6863
|
+
return;
|
|
6864
|
+
}
|
|
6865
|
+
if (fresh.length === 0) {
|
|
6866
|
+
throw new Error(`The connection list returned a full page ${pageIndex} with no new connections, so it cannot be read to the end.`);
|
|
6867
|
+
}
|
|
6868
|
+
}
|
|
6869
|
+
throw new Error(`The connection list did not end within ${MAX_CONNECTION_PAGES} pages of ${CONNECTIONS_PAGE_SIZE}.`);
|
|
6870
|
+
}
|
|
6871
|
+
async function listAllConnections(api, scope = {}) {
|
|
6872
|
+
const all = [];
|
|
6873
|
+
for await (const page of connectionPages(api, scope)) {
|
|
6874
|
+
all.push(...page);
|
|
6875
|
+
}
|
|
6876
|
+
return all;
|
|
6877
|
+
}
|
|
6878
|
+
async function lookUpByConnectionId(api, connectionId) {
|
|
6822
6879
|
const connection = await api.apiV1ConnectionsConnectionIdGet({
|
|
6823
6880
|
connectionId,
|
|
6824
6881
|
allFolders: true
|
|
@@ -6826,35 +6883,24 @@ async function getConnectionElementInstanceId(options, connectionId) {
|
|
|
6826
6883
|
if (typeof connection.elementInstanceId !== "number") {
|
|
6827
6884
|
throw new Error(`Connection '${connectionId}' has no element instance id.`);
|
|
6828
6885
|
}
|
|
6829
|
-
return
|
|
6886
|
+
return {
|
|
6887
|
+
connectionId,
|
|
6888
|
+
elementInstanceId: connection.elementInstanceId,
|
|
6889
|
+
connectorKey: connection.connector?.key ?? undefined
|
|
6890
|
+
};
|
|
6830
6891
|
}
|
|
6831
|
-
async function
|
|
6832
|
-
const api
|
|
6833
|
-
let previousPageKey;
|
|
6834
|
-
for (let pageIndex = 0;pageIndex < MAX_CONNECTION_PAGES; pageIndex++) {
|
|
6835
|
-
const page = await api.apiV1ConnectionsGet({
|
|
6836
|
-
allFolders: true,
|
|
6837
|
-
mostRecentFirst: true,
|
|
6838
|
-
pageIndex,
|
|
6839
|
-
pageSize: CONNECTIONS_PAGE_SIZE
|
|
6840
|
-
});
|
|
6892
|
+
async function lookUpByElementInstanceId(api, elementInstanceId) {
|
|
6893
|
+
for await (const page of connectionPages(api, { allFolders: true })) {
|
|
6841
6894
|
const match = page.find((c) => c.elementInstanceId === elementInstanceId && c.id);
|
|
6842
6895
|
if (match?.id) {
|
|
6843
|
-
return
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
const pageKey = JSON.stringify(page.map((connection) => [
|
|
6849
|
-
connection.id,
|
|
6850
|
-
connection.elementInstanceId
|
|
6851
|
-
]));
|
|
6852
|
-
if (pageKey === previousPageKey) {
|
|
6853
|
-
throw new Error("Connection lookup received the same page twice.");
|
|
6896
|
+
return {
|
|
6897
|
+
connectionId: match.id,
|
|
6898
|
+
elementInstanceId,
|
|
6899
|
+
connectorKey: match.connector?.key ?? undefined
|
|
6900
|
+
};
|
|
6854
6901
|
}
|
|
6855
|
-
previousPageKey = pageKey;
|
|
6856
6902
|
}
|
|
6857
|
-
throw new
|
|
6903
|
+
throw new ConnectionNotFoundError(`No connection found with element instance id ${elementInstanceId}.`);
|
|
6858
6904
|
}
|
|
6859
6905
|
async function resolveConnectionInstanceIds(options, ids) {
|
|
6860
6906
|
const { connectionId, elementInstanceId } = ids;
|
|
@@ -6862,19 +6908,16 @@ async function resolveConnectionInstanceIds(options, ids) {
|
|
|
6862
6908
|
return { connectionId, elementInstanceId };
|
|
6863
6909
|
}
|
|
6864
6910
|
if (connectionId !== undefined) {
|
|
6865
|
-
return
|
|
6866
|
-
connectionId,
|
|
6867
|
-
elementInstanceId: await getConnectionElementInstanceId(options, connectionId)
|
|
6868
|
-
};
|
|
6911
|
+
return lookUpByConnectionId(await connectionsApi(options), connectionId);
|
|
6869
6912
|
}
|
|
6870
6913
|
if (elementInstanceId !== undefined) {
|
|
6871
|
-
return
|
|
6872
|
-
connectionId: await findConnectionIdByElementInstanceId(options, elementInstanceId),
|
|
6873
|
-
elementInstanceId
|
|
6874
|
-
};
|
|
6914
|
+
return lookUpByElementInstanceId(await connectionsApi(options), elementInstanceId);
|
|
6875
6915
|
}
|
|
6876
6916
|
throw new Error("Pass a connection id or an element instance id.");
|
|
6877
6917
|
}
|
|
6918
|
+
async function connectionsApi(options) {
|
|
6919
|
+
return new ConnectionsApi(await createConnectionsConfig(options));
|
|
6920
|
+
}
|
|
6878
6921
|
// ../integrationservice-sdk/src/connection-state.ts
|
|
6879
6922
|
var CONNECTION_STATE_NAMES = new Map([
|
|
6880
6923
|
[ConnectionState.Enabled, "Enabled"],
|
|
@@ -6904,6 +6947,28 @@ function normalizeConnectionStatus(status) {
|
|
|
6904
6947
|
}
|
|
6905
6948
|
return "Unknown";
|
|
6906
6949
|
}
|
|
6950
|
+
// ../integrationservice-sdk/src/dap/managed-http.ts
|
|
6951
|
+
var MANAGED_HTTP_METHODS = new Set([
|
|
6952
|
+
"GET",
|
|
6953
|
+
"POST",
|
|
6954
|
+
"PUT",
|
|
6955
|
+
"PATCH",
|
|
6956
|
+
"DELETE",
|
|
6957
|
+
"OPTIONS",
|
|
6958
|
+
"HEAD"
|
|
6959
|
+
]);
|
|
6960
|
+
var MANAGED_HTTP_KEYS = new Set([
|
|
6961
|
+
"authentication",
|
|
6962
|
+
"method",
|
|
6963
|
+
"url",
|
|
6964
|
+
"connectionId",
|
|
6965
|
+
"folderKey",
|
|
6966
|
+
"targetConnector",
|
|
6967
|
+
"headers",
|
|
6968
|
+
"query",
|
|
6969
|
+
"body"
|
|
6970
|
+
]);
|
|
6971
|
+
|
|
6907
6972
|
// ../integrationservice-sdk/src/dap/solution-resource-configurations.ts
|
|
6908
6973
|
var CATALOG_MISS = "was not found in the solution or in the resource catalog";
|
|
6909
6974
|
function createSolutionResourceConfigurationsProvider(solutionDir, namesByKey = new Map, openedEngine) {
|
|
@@ -6933,9 +6998,9 @@ function createSolutionResourceConfigurationsProvider(solutionDir, namesByKey =
|
|
|
6933
6998
|
};
|
|
6934
6999
|
}
|
|
6935
7000
|
async function openEngine() {
|
|
6936
|
-
const { getSolutionAuthContext } = await import("./solution-auth-
|
|
7001
|
+
const { getSolutionAuthContext } = await import("./solution-auth-w6edcwxb.js");
|
|
6937
7002
|
await getSolutionAuthContext({});
|
|
6938
|
-
const resources = await import("./index-
|
|
7003
|
+
const resources = await import("./index-jc6qcbca.js");
|
|
6939
7004
|
return {
|
|
6940
7005
|
resources,
|
|
6941
7006
|
services: await resources.createResourceBuilderServices()
|
|
@@ -7001,45 +7066,105 @@ function apiActionCandidates(metadata, httpMethod) {
|
|
|
7001
7066
|
candidates.push(action);
|
|
7002
7067
|
}
|
|
7003
7068
|
}
|
|
7004
|
-
|
|
7069
|
+
const seen = new Set;
|
|
7070
|
+
return candidates.filter((action) => {
|
|
7071
|
+
const name = actionNameOf(action);
|
|
7072
|
+
if (name === "")
|
|
7073
|
+
return true;
|
|
7074
|
+
if (seen.has(name))
|
|
7075
|
+
return false;
|
|
7076
|
+
seen.add(name);
|
|
7077
|
+
return true;
|
|
7078
|
+
});
|
|
7079
|
+
}
|
|
7080
|
+
function actionRefFieldNames(action) {
|
|
7081
|
+
const rules = action.rules ?? action.Rules ?? [];
|
|
7082
|
+
return rules.map((r) => r.refFieldName ?? r.RefFieldName).filter((n) => typeof n === "string");
|
|
7005
7083
|
}
|
|
7006
7084
|
function findApiAction(metadata, httpMethod, fieldValues, actionName) {
|
|
7007
|
-
return matchApiAction(apiActionCandidates(metadata, httpMethod), fieldValues, actionName);
|
|
7085
|
+
return matchApiAction(apiActionCandidates(metadata, httpMethod), fieldValues, actionName, buttonInputNames(metadata.fields, pickMethodParameters(metadata, httpMethod), (field) => field.method?.[httpMethod]?.designOverrides));
|
|
7008
7086
|
}
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7087
|
+
var BUTTON_COMPONENT = "Button";
|
|
7088
|
+
function buttonInputNames(fields, parameters, designOverrides) {
|
|
7089
|
+
const component = (design) => design?.component;
|
|
7090
|
+
const names = new Set;
|
|
7091
|
+
for (const [name, field] of Object.entries(fieldMap(fields))) {
|
|
7092
|
+
if ((component(designOverrides(field)) ?? component(field.design)) === BUTTON_COMPONENT) {
|
|
7093
|
+
names.add(name);
|
|
7094
|
+
}
|
|
7095
|
+
}
|
|
7096
|
+
for (const parameter of Array.isArray(parameters) ? parameters : []) {
|
|
7097
|
+
const { name, design } = parameter;
|
|
7098
|
+
if (typeof name === "string" && component(design) === BUTTON_COMPONENT) {
|
|
7099
|
+
names.add(name);
|
|
7100
|
+
}
|
|
7101
|
+
}
|
|
7102
|
+
return names;
|
|
7103
|
+
}
|
|
7104
|
+
|
|
7105
|
+
class ConflictingDesignActionsError extends Error {
|
|
7106
|
+
actionNames;
|
|
7107
|
+
fieldName;
|
|
7108
|
+
requirements;
|
|
7109
|
+
constructor(actionNames, fieldName, requirements = []) {
|
|
7110
|
+
super(`More than one design action runs on field '${fieldName}' with the supplied values: ${actionNames.map((name) => `'${name}'`).join(", ")}.`);
|
|
7111
|
+
this.name = "ConflictingDesignActionsError";
|
|
7112
|
+
this.actionNames = actionNames;
|
|
7113
|
+
this.fieldName = fieldName;
|
|
7114
|
+
this.requirements = requirements;
|
|
7115
|
+
}
|
|
7116
|
+
}
|
|
7117
|
+
function matchApiAction(actions, fieldValues, actionName, buttons) {
|
|
7118
|
+
const satisfied = actions.filter((candidate) => {
|
|
7012
7119
|
const type = candidate.actionType ?? candidate.ActionType;
|
|
7013
7120
|
if (typeof type !== "string" || type.toLowerCase() !== DESIGN_ACTION_TYPE) {
|
|
7014
|
-
|
|
7121
|
+
return false;
|
|
7015
7122
|
}
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
continue;
|
|
7123
|
+
if (actionName && actionNameOf(candidate) !== actionName)
|
|
7124
|
+
return false;
|
|
7019
7125
|
const rules = candidate.rules ?? candidate.Rules ?? [];
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7023
|
-
|
|
7126
|
+
return rules.every((rule) => ruleSatisfied(rule, fieldValues, buttons));
|
|
7127
|
+
});
|
|
7128
|
+
if (actionName)
|
|
7129
|
+
return satisfied[0] ? normalizeAction(satisfied[0]) : null;
|
|
7130
|
+
for (const field of Object.keys(fieldValues).reverse()) {
|
|
7131
|
+
const keyed = satisfied.filter((action) => actionRefFieldNames(action).includes(field));
|
|
7132
|
+
if (keyed.length > 1) {
|
|
7133
|
+
throw new ConflictingDesignActionsError(keyed.map(actionNameOf), field, keyed.map((action) => ({
|
|
7134
|
+
name: actionNameOf(action),
|
|
7135
|
+
refFieldNames: actionRefFieldNames(action)
|
|
7136
|
+
})));
|
|
7137
|
+
}
|
|
7138
|
+
if (keyed.length === 1)
|
|
7139
|
+
return normalizeAction(keyed[0]);
|
|
7024
7140
|
}
|
|
7025
|
-
|
|
7026
|
-
return null;
|
|
7027
|
-
return normalizeAction(matched);
|
|
7141
|
+
return null;
|
|
7028
7142
|
}
|
|
7029
|
-
function
|
|
7143
|
+
function actionNameOf(action) {
|
|
7144
|
+
return String(action.name ?? action.Name ?? "");
|
|
7145
|
+
}
|
|
7146
|
+
function ruleSatisfied(rule, fieldValues, buttons) {
|
|
7030
7147
|
const fieldName = rule.refFieldName ?? rule.RefFieldName;
|
|
7031
7148
|
if (typeof fieldName !== "string")
|
|
7032
|
-
return true;
|
|
7033
|
-
const value = fieldValues[fieldName];
|
|
7034
|
-
const isEmpty = value === undefined || value === "";
|
|
7035
|
-
if ((rule.isCleared ?? rule.IsCleared) === true)
|
|
7036
|
-
return isEmpty;
|
|
7037
|
-
if (isEmpty)
|
|
7038
7149
|
return false;
|
|
7150
|
+
const recordLevel = rule.customRecordLevelFields ?? rule.CustomRecordLevelFields;
|
|
7151
|
+
if (typeof recordLevel === "string" && recordLevel.toLowerCase() === "generated") {
|
|
7152
|
+
return false;
|
|
7153
|
+
}
|
|
7154
|
+
const value = fieldValues[fieldName];
|
|
7155
|
+
if (value === undefined || value.trim() === "") {
|
|
7156
|
+
return (rule.isCleared ?? rule.IsCleared) === true;
|
|
7157
|
+
}
|
|
7158
|
+
if (buttons.has(fieldName))
|
|
7159
|
+
return true;
|
|
7160
|
+
if ((rule.isConstantValue ?? rule.IsConstantValue) === true)
|
|
7161
|
+
return true;
|
|
7039
7162
|
const allowed = rule.refFieldValues ?? rule.RefFieldValues;
|
|
7040
|
-
if (!Array.isArray(allowed)
|
|
7163
|
+
if (!Array.isArray(allowed))
|
|
7164
|
+
return false;
|
|
7165
|
+
if (allowed.length === 1 && String(allowed[0]) === "*")
|
|
7041
7166
|
return true;
|
|
7042
|
-
return allowed.some((
|
|
7167
|
+
return allowed.some((refValue) => typeof refValue === "boolean" ? value.toLowerCase() === String(refValue) : String(refValue) === value);
|
|
7043
7168
|
}
|
|
7044
7169
|
function normalizeAction(action) {
|
|
7045
7170
|
const apiConfig = action.apiConfiguration ?? action.ApiConfiguration;
|
|
@@ -7073,7 +7198,7 @@ function normalizeAction(action) {
|
|
|
7073
7198
|
rules: ruleFieldNames
|
|
7074
7199
|
};
|
|
7075
7200
|
}
|
|
7076
|
-
var loadDesignTime = () => import("./index-
|
|
7201
|
+
var loadDesignTime = () => import("./index-5pzp2qeb.js");
|
|
7077
7202
|
var RESOURCE_KEY_EXPRESSION = "resourceKey";
|
|
7078
7203
|
var SAFE_RESOURCE_KEY = /^(?!\.+$)[A-Za-z0-9._:-]+$/;
|
|
7079
7204
|
function sentRequest(designTime, action) {
|
|
@@ -7148,15 +7273,10 @@ function applyDesignActionRemap(baseMeta, responseMeta, httpMethod, onSuccess) {
|
|
|
7148
7273
|
const outputMode = onSuccess.output?.toLowerCase() ?? "noop";
|
|
7149
7274
|
if (mode === "noop" && outputMode === "noop")
|
|
7150
7275
|
return baseMeta;
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
if (mode !== "noop" && responseParameters !== null) {
|
|
7156
|
-
const replaced = mode === "replace" ? responseParameters : mode === "prepend" ? [...responseParameters, ...baseParameters ?? []] : [...baseParameters ?? [], ...responseParameters];
|
|
7157
|
-
merged.metadata = setMethodParameters(merged.metadata, httpMethod, replaced);
|
|
7158
|
-
}
|
|
7159
|
-
return merged;
|
|
7276
|
+
return {
|
|
7277
|
+
...baseMeta,
|
|
7278
|
+
fields: remapFields(fieldMap(baseMeta.fields), fieldMap(responseMeta.fields), httpMethod, mode, outputMode)
|
|
7279
|
+
};
|
|
7160
7280
|
}
|
|
7161
7281
|
function fieldMap(fields) {
|
|
7162
7282
|
if (Array.isArray(fields)) {
|
|
@@ -7214,26 +7334,16 @@ function pickMethodParameters(metadata, httpMethod) {
|
|
|
7214
7334
|
const params = methodInfo?.parameters;
|
|
7215
7335
|
return Array.isArray(params) ? params : null;
|
|
7216
7336
|
}
|
|
7217
|
-
function setMethodParameters(metadataNode, httpMethod, parameters) {
|
|
7218
|
-
const cloned = metadataNode && typeof metadataNode === "object" ? { ...metadataNode } : {};
|
|
7219
|
-
const methods = cloned.method ?? {};
|
|
7220
|
-
const methodInfo = methods[httpMethod] ?? {};
|
|
7221
|
-
cloned.method = {
|
|
7222
|
-
...methods,
|
|
7223
|
-
[httpMethod]: { ...methodInfo, parameters }
|
|
7224
|
-
};
|
|
7225
|
-
return cloned;
|
|
7226
|
-
}
|
|
7227
7337
|
// ../integrationservice-sdk/src/metadata/resource-metadata.ts
|
|
7228
7338
|
async function fetchRawMetadata(api, connectorKey, objectName, connectionId) {
|
|
7229
7339
|
if (connectionId) {
|
|
7230
|
-
const
|
|
7340
|
+
const response = await api.getInstanceObjectMetadataRaw({
|
|
7231
7341
|
connectionOrInstanceId: connectionId,
|
|
7232
7342
|
elementKey: connectorKey,
|
|
7233
7343
|
objectName,
|
|
7234
7344
|
includeParentArray: true
|
|
7235
7345
|
});
|
|
7236
|
-
return await
|
|
7346
|
+
return await response.raw.json();
|
|
7237
7347
|
}
|
|
7238
7348
|
const response = await api.getObjectMetadataRaw({
|
|
7239
7349
|
elementKey: connectorKey,
|
|
@@ -7248,13 +7358,13 @@ function buildResourceCompactSummary(metadata, operation) {
|
|
|
7248
7358
|
const fields = metadata.fields || {};
|
|
7249
7359
|
if (!operation) {
|
|
7250
7360
|
const availableOperations = Object.entries(methods).map(([methodKey, methodVal]) => {
|
|
7251
|
-
const
|
|
7361
|
+
const curated = methodVal.curated;
|
|
7252
7362
|
return {
|
|
7253
7363
|
method: methodKey,
|
|
7254
7364
|
name: METHOD_TO_OPERATION[methodKey] || methodKey,
|
|
7255
7365
|
description: methodVal.description,
|
|
7256
7366
|
path: methodVal.path,
|
|
7257
|
-
curated:
|
|
7367
|
+
curated: curated?.displayName
|
|
7258
7368
|
};
|
|
7259
7369
|
});
|
|
7260
7370
|
return {
|
|
@@ -7442,7 +7552,7 @@ function buildTriggerCompactSummary(metadata, operationName) {
|
|
|
7442
7552
|
// ../integrationservice-sdk/src/metadata/trigger-design-actions.ts
|
|
7443
7553
|
async function findTriggerDesignAction(eventObject, fieldValues, target, actionName) {
|
|
7444
7554
|
const design = eventObject.design;
|
|
7445
|
-
const declared = matchApiAction(design?.actions ?? [], fieldValues, actionName);
|
|
7555
|
+
const declared = matchApiAction(design?.actions ?? [], fieldValues, actionName, buttonInputNames(eventObject.fields, eventObject.parameters, (field) => field.events?.[target.operation]?.designOverrides));
|
|
7446
7556
|
if (!declared)
|
|
7447
7557
|
return null;
|
|
7448
7558
|
const { routeTriggerObjectAction } = await loadDesignTime();
|
|
@@ -8245,8 +8355,8 @@ async function writeJson(filePath, data, schema, cachedAt) {
|
|
|
8245
8355
|
};
|
|
8246
8356
|
const [err] = await catchError(async () => {
|
|
8247
8357
|
const fs = getFileSystem();
|
|
8248
|
-
await fs.mkdir(fs.path.dirname(filePath)
|
|
8249
|
-
await fs.writeFile(filePath, JSON.stringify(envelope, null, 2)
|
|
8358
|
+
await fs.mkdir(fs.path.dirname(filePath));
|
|
8359
|
+
await fs.writeFile(filePath, JSON.stringify(envelope, null, 2));
|
|
8250
8360
|
});
|
|
8251
8361
|
if (err) {
|
|
8252
8362
|
logger.warn(`Failed to write IS metadata cache to ${filePath}:`, err);
|
|
@@ -8582,7 +8692,7 @@ var registerActivitiesCommand = (program) => {
|
|
|
8582
8692
|
if (error) {
|
|
8583
8693
|
OutputFormatter.error({
|
|
8584
8694
|
Result: RESULTS.Failure,
|
|
8585
|
-
ErrorCode: "
|
|
8695
|
+
ErrorCode: "invalid_argument",
|
|
8586
8696
|
Message: `Could not generate activity metadata: ${error.message}`,
|
|
8587
8697
|
Instructions: "Fix the minimal-metadata file and regenerate — never hand-edit the generated metadata."
|
|
8588
8698
|
});
|
|
@@ -8601,7 +8711,7 @@ var registerActivitiesCommand = (program) => {
|
|
|
8601
8711
|
if (error) {
|
|
8602
8712
|
OutputFormatter.error({
|
|
8603
8713
|
Result: RESULTS.Failure,
|
|
8604
|
-
ErrorCode: "
|
|
8714
|
+
ErrorCode: "invalid_argument",
|
|
8605
8715
|
Message: `Could not update the script's type header: ${error.message}`,
|
|
8606
8716
|
Instructions: "Check both paths exist and the metadata file is valid JSON."
|
|
8607
8717
|
});
|
|
@@ -8708,7 +8818,6 @@ var POLL_EXIT_CODES = {
|
|
|
8708
8818
|
[PollOutcome.Aborted]: 1
|
|
8709
8819
|
};
|
|
8710
8820
|
function handleAuthPollFailure(outcome, error, noun, retryCommand, authUrl) {
|
|
8711
|
-
const target = authUrl ? authUrl : "the authentication URL";
|
|
8712
8821
|
const messages = {
|
|
8713
8822
|
[PollOutcome.Timeout]: `${noun} timed out after 5 minutes`,
|
|
8714
8823
|
[PollOutcome.Failed]: `${noun} polling failed: ${error?.message ?? "too many consecutive errors"}`,
|
|
@@ -8718,7 +8827,7 @@ function handleAuthPollFailure(outcome, error, noun, retryCommand, authUrl) {
|
|
|
8718
8827
|
OutputFormatter.error({
|
|
8719
8828
|
Result: RESULTS.Failure,
|
|
8720
8829
|
Message: messages[outcome] ?? `${noun} polling failed`,
|
|
8721
|
-
Instructions: `Open ${
|
|
8830
|
+
Instructions: `Open ${authUrl} while it is valid, then retry. For scripts, run '${retryCommand} --no-wait' to return the pending authorization details without polling.`
|
|
8722
8831
|
});
|
|
8723
8832
|
processContext.exit(POLL_EXIT_CODES[outcome] ?? 1);
|
|
8724
8833
|
}
|
|
@@ -8726,6 +8835,24 @@ function normalizeSessionStatus(session) {
|
|
|
8726
8835
|
return (session.status ?? "pending").toLowerCase();
|
|
8727
8836
|
}
|
|
8728
8837
|
var PENDING_AUTHORIZATION_INSTRUCTIONS = "Open AuthUrl to authorize the connection, then run 'uip is connections list' or 'uip is connections ping <connection-id>' to verify the connection.";
|
|
8838
|
+
function requireAuthUrl(response, noun, verifyCommand, connectionId) {
|
|
8839
|
+
if (response.authUrl) {
|
|
8840
|
+
return true;
|
|
8841
|
+
}
|
|
8842
|
+
OutputFormatter.error({
|
|
8843
|
+
Result: RESULTS.Failure,
|
|
8844
|
+
ErrorCode: "server_error",
|
|
8845
|
+
Retry: "RetryWillNotFix",
|
|
8846
|
+
Message: `Integration Service started the ${noun} session but returned no authorization URL.`,
|
|
8847
|
+
Instructions: `Authorize the connection from the Integration Service page in Automation Cloud, then run '${verifyCommand}' to verify it.`,
|
|
8848
|
+
Data: {
|
|
8849
|
+
SessionId: response.sessionId,
|
|
8850
|
+
...connectionId !== undefined && { ConnectionId: connectionId }
|
|
8851
|
+
}
|
|
8852
|
+
});
|
|
8853
|
+
processContext.exit(1);
|
|
8854
|
+
return false;
|
|
8855
|
+
}
|
|
8729
8856
|
function writePendingAuthorization(connectorKey, connectionId, response) {
|
|
8730
8857
|
const data = {
|
|
8731
8858
|
Status: "AuthorizationPending",
|
|
@@ -8769,23 +8896,6 @@ function extractConnectionConnectorKey(connection) {
|
|
|
8769
8896
|
const key = conn.connector?.key || conn.connectorKey || "";
|
|
8770
8897
|
return typeof key === "string" ? key : "";
|
|
8771
8898
|
}
|
|
8772
|
-
var CONNECTIONS_FETCH_PAGE_SIZE = 200;
|
|
8773
|
-
async function fetchConnections(api, options) {
|
|
8774
|
-
const all = [];
|
|
8775
|
-
for (let pageIndex = 0;; pageIndex++) {
|
|
8776
|
-
const request = {
|
|
8777
|
-
...options.allFolders ? { allFolders: true } : {},
|
|
8778
|
-
pageIndex,
|
|
8779
|
-
pageSize: CONNECTIONS_FETCH_PAGE_SIZE
|
|
8780
|
-
};
|
|
8781
|
-
const override = folderOverride(options.folderKey);
|
|
8782
|
-
const page = override ? await api.apiV1ConnectionsGet(request, override) : await api.apiV1ConnectionsGet(request);
|
|
8783
|
-
all.push(...page);
|
|
8784
|
-
if (page.length < CONNECTIONS_FETCH_PAGE_SIZE) {
|
|
8785
|
-
return all;
|
|
8786
|
-
}
|
|
8787
|
-
}
|
|
8788
|
-
}
|
|
8789
8899
|
function connectionDetailsAreComplete(connections) {
|
|
8790
8900
|
return connections.every((connection) => connection.detailsComplete === true);
|
|
8791
8901
|
}
|
|
@@ -8949,7 +9059,6 @@ var CONNECTIONS_DELETE_EXAMPLES = [
|
|
|
8949
9059
|
Description: "Delete a connection",
|
|
8950
9060
|
Command: "uip is connections delete a1b2c3d4-0000-0000-0000-000000000001",
|
|
8951
9061
|
Output: {
|
|
8952
|
-
Result: "Success",
|
|
8953
9062
|
Code: "ConnectionDeleted",
|
|
8954
9063
|
Data: {
|
|
8955
9064
|
ConnectionId: "a1b2c3d4-0000-0000-0000-000000000001",
|
|
@@ -8991,7 +9100,6 @@ var CONNECTIONS_EXPORT_EXAMPLES = [
|
|
|
8991
9100
|
Description: "Export connections for audit",
|
|
8992
9101
|
Command: "uip is connections export",
|
|
8993
9102
|
Output: {
|
|
8994
|
-
Result: "Success",
|
|
8995
9103
|
Code: "ConnectionExport",
|
|
8996
9104
|
Data: {
|
|
8997
9105
|
"a1b2c3d4-0000-0000-0000-000000000001": {
|
|
@@ -9126,7 +9234,7 @@ var registerConnectionsCommand = (program) => {
|
|
|
9126
9234
|
}
|
|
9127
9235
|
if (connectorDetailsNeedFetch) {
|
|
9128
9236
|
const detailsApi = new ConnectionsApi(config);
|
|
9129
|
-
const [detailsError, detailedConnections] = await catchError(
|
|
9237
|
+
const [detailsError, detailedConnections] = await catchError(listAllConnections(detailsApi, {
|
|
9130
9238
|
allFolders: options.allFolders,
|
|
9131
9239
|
folderKey
|
|
9132
9240
|
}));
|
|
@@ -9143,7 +9251,10 @@ var registerConnectionsCommand = (program) => {
|
|
|
9143
9251
|
}
|
|
9144
9252
|
} else {
|
|
9145
9253
|
const api = new ConnectionsApi(config);
|
|
9146
|
-
const [fetchError, fetched] = await catchError(api
|
|
9254
|
+
const [fetchError, fetched] = await catchError(listAllConnections(api, {
|
|
9255
|
+
allFolders: options.allFolders,
|
|
9256
|
+
folderKey
|
|
9257
|
+
}));
|
|
9147
9258
|
if (fetchError) {
|
|
9148
9259
|
await emitListConnectionsFailure(fetchError);
|
|
9149
9260
|
return;
|
|
@@ -9194,7 +9305,7 @@ var registerConnectionsCommand = (program) => {
|
|
|
9194
9305
|
return;
|
|
9195
9306
|
}
|
|
9196
9307
|
const api = new ConnectionsApi(config);
|
|
9197
|
-
const [fetchError, existingConnections] = await catchError(
|
|
9308
|
+
const [fetchError, existingConnections] = await catchError(listAllConnections(api, { allFolders: true }));
|
|
9198
9309
|
if (fetchError) {
|
|
9199
9310
|
const msg = await extractErrorMessage(fetchError);
|
|
9200
9311
|
OutputFormatter.error({
|
|
@@ -9264,22 +9375,24 @@ var registerConnectionsCommand = (program) => {
|
|
|
9264
9375
|
processContext.exit(1);
|
|
9265
9376
|
return;
|
|
9266
9377
|
}
|
|
9378
|
+
if (!requireAuthUrl(createResponse, "authorization", `uip is connections list ${connectorKey} --refresh`)) {
|
|
9379
|
+
return;
|
|
9380
|
+
}
|
|
9267
9381
|
logger.info(`Session: ${createResponse.sessionId}`);
|
|
9268
9382
|
logger.info(`Auth URL: ${createResponse.authUrl}`);
|
|
9269
|
-
|
|
9383
|
+
const sessionId = createResponse.sessionId;
|
|
9384
|
+
if (options.wait === false || !canFinishBrowserFlow() || !sessionId) {
|
|
9270
9385
|
writePendingAuthorization(connectorKey, undefined, createResponse);
|
|
9271
9386
|
return;
|
|
9272
9387
|
}
|
|
9273
9388
|
const opened = options.browser !== false && await tryOpenAuthUrl(createResponse.authUrl);
|
|
9274
|
-
if (!opened
|
|
9389
|
+
if (!opened) {
|
|
9275
9390
|
OutputFormatter.log({
|
|
9276
9391
|
Message: `Open this URL to authorize: ${createResponse.authUrl}`
|
|
9277
9392
|
});
|
|
9278
9393
|
}
|
|
9279
9394
|
const pollResult = await pollUntil({
|
|
9280
|
-
fn: () => sessionsApi.apiV1SessionsSessionIdGet({
|
|
9281
|
-
sessionId: createResponse.sessionId
|
|
9282
|
-
}),
|
|
9395
|
+
fn: () => sessionsApi.apiV1SessionsSessionIdGet({ sessionId }),
|
|
9283
9396
|
until: (s) => normalizeSessionStatus(s) === "success" || normalizeSessionStatus(s) === "failed",
|
|
9284
9397
|
getStatus: normalizeSessionStatus,
|
|
9285
9398
|
logPrefix: "auth",
|
|
@@ -9329,7 +9442,7 @@ var registerConnectionsCommand = (program) => {
|
|
|
9329
9442
|
if (pollResult.outcome === PollOutcome.Completed && completedStatus === "failed") {
|
|
9330
9443
|
OutputFormatter.error({
|
|
9331
9444
|
Result: RESULTS.Failure,
|
|
9332
|
-
Message: pollResult.data
|
|
9445
|
+
Message: pollResult.data?.errorResponse?.message ?? "Authentication failed",
|
|
9333
9446
|
Instructions: "Check credentials and try again."
|
|
9334
9447
|
});
|
|
9335
9448
|
processContext.exit(1);
|
|
@@ -9409,30 +9522,31 @@ var registerConnectionsCommand = (program) => {
|
|
|
9409
9522
|
return;
|
|
9410
9523
|
}
|
|
9411
9524
|
const api = new ConnectionsApi(config);
|
|
9412
|
-
const [
|
|
9413
|
-
|
|
9414
|
-
|
|
9415
|
-
|
|
9416
|
-
|
|
9417
|
-
|
|
9418
|
-
|
|
9419
|
-
|
|
9420
|
-
|
|
9421
|
-
|
|
9422
|
-
|
|
9423
|
-
|
|
9424
|
-
|
|
9425
|
-
|
|
9426
|
-
folderKey = extractConnectionFolderKey(connection);
|
|
9427
|
-
deletedConnectorKey = extractConnectionConnectorKey(connection);
|
|
9525
|
+
const [lookupError, connection] = await catchError(api.apiV1ConnectionsConnectionIdGet({
|
|
9526
|
+
connectionId,
|
|
9527
|
+
allFolders: true
|
|
9528
|
+
}));
|
|
9529
|
+
const lookupFailure = lookupError ? await extractErrorDetails(lookupError) : undefined;
|
|
9530
|
+
if (lookupFailure?.errorCode === "not_found") {
|
|
9531
|
+
OutputFormatter.error({
|
|
9532
|
+
Result: RESULTS.Failure,
|
|
9533
|
+
ErrorCode: "not_found",
|
|
9534
|
+
Message: `Connection '${connectionId}' not found.`,
|
|
9535
|
+
Instructions: CONNECTION_NOT_FOUND_INSTRUCTIONS
|
|
9536
|
+
});
|
|
9537
|
+
processContext.exit(1);
|
|
9538
|
+
return;
|
|
9428
9539
|
}
|
|
9540
|
+
const folderKey = connection ? extractConnectionFolderKey(connection) : "";
|
|
9541
|
+
const deletedConnectorKey = connection ? extractConnectionConnectorKey(connection) : "";
|
|
9429
9542
|
const [deleteError] = await catchError(api.apiV1ConnectionsConnectionIdDelete({ connectionId }, folderOverride(folderKey)));
|
|
9430
9543
|
if (deleteError) {
|
|
9431
9544
|
const msg = await extractErrorMessage(deleteError);
|
|
9545
|
+
const lookupNote = lookupFailure ? ` The connection's folder could not be read first (${lookupFailure.message}), so the delete was sent without a folder key.` : "";
|
|
9432
9546
|
OutputFormatter.error({
|
|
9433
9547
|
Result: RESULTS.Failure,
|
|
9434
9548
|
Message: msg,
|
|
9435
|
-
Instructions: appendListConnectionsHint(deleteError.message, DELETE_CONNECTIONS_API_INSTRUCTIONS)
|
|
9549
|
+
Instructions: appendListConnectionsHint(deleteError.message, DELETE_CONNECTIONS_API_INSTRUCTIONS) + lookupNote
|
|
9436
9550
|
});
|
|
9437
9551
|
processContext.exit(1);
|
|
9438
9552
|
return;
|
|
@@ -9606,21 +9720,23 @@ var registerConnectionsCommand = (program) => {
|
|
|
9606
9720
|
processContext.exit(1);
|
|
9607
9721
|
return;
|
|
9608
9722
|
}
|
|
9723
|
+
if (!requireAuthUrl(editResponse, "re-authorization", `uip is connections ping ${connectionId}`, connectionId)) {
|
|
9724
|
+
return;
|
|
9725
|
+
}
|
|
9609
9726
|
logger.info(`Auth URL: ${editResponse.authUrl}`);
|
|
9610
|
-
|
|
9727
|
+
const sessionId = editResponse.sessionId;
|
|
9728
|
+
if (options.wait === false || !canFinishBrowserFlow() || !sessionId) {
|
|
9611
9729
|
writePendingAuthorization(undefined, connectionId, editResponse);
|
|
9612
9730
|
return;
|
|
9613
9731
|
}
|
|
9614
9732
|
const opened = options.browser !== false && await tryOpenAuthUrl(editResponse.authUrl);
|
|
9615
|
-
if (!opened
|
|
9733
|
+
if (!opened) {
|
|
9616
9734
|
OutputFormatter.log({
|
|
9617
9735
|
Message: `Open this URL to authorize: ${editResponse.authUrl}`
|
|
9618
9736
|
});
|
|
9619
9737
|
}
|
|
9620
9738
|
const pollResult = await pollUntil({
|
|
9621
|
-
fn: () => sessionsApi.apiV1SessionsSessionIdGet({
|
|
9622
|
-
sessionId: editResponse.sessionId
|
|
9623
|
-
}),
|
|
9739
|
+
fn: () => sessionsApi.apiV1SessionsSessionIdGet({ sessionId }),
|
|
9624
9740
|
until: (s) => normalizeSessionStatus(s) === "success" || normalizeSessionStatus(s) === "failed",
|
|
9625
9741
|
getStatus: normalizeSessionStatus,
|
|
9626
9742
|
logPrefix: "auth",
|
|
@@ -9653,7 +9769,7 @@ var registerConnectionsCommand = (program) => {
|
|
|
9653
9769
|
if (pollResult.outcome === PollOutcome.Completed && completedStatus === "failed") {
|
|
9654
9770
|
OutputFormatter.error({
|
|
9655
9771
|
Result: RESULTS.Failure,
|
|
9656
|
-
Message: pollResult.data
|
|
9772
|
+
Message: pollResult.data?.errorResponse?.message ?? "Re-authentication failed",
|
|
9657
9773
|
Instructions: "Check credentials and try again."
|
|
9658
9774
|
});
|
|
9659
9775
|
processContext.exit(1);
|
|
@@ -9692,9 +9808,6 @@ function canFinishBrowserFlow() {
|
|
|
9692
9808
|
return getOutputSink().capabilities.isInteractive;
|
|
9693
9809
|
}
|
|
9694
9810
|
async function tryOpenAuthUrl(url) {
|
|
9695
|
-
if (!url) {
|
|
9696
|
-
return false;
|
|
9697
|
-
}
|
|
9698
9811
|
const [openError] = await catchError(getFileSystem().utils.open(url));
|
|
9699
9812
|
return !openError;
|
|
9700
9813
|
}
|
|
@@ -10143,7 +10256,7 @@ async function publishToTenant(args) {
|
|
|
10143
10256
|
code: "connectorNotFoundOnTenant",
|
|
10144
10257
|
message: `No design connector with key '${connectorKey}' found on tenant.`,
|
|
10145
10258
|
fixHint: "Run `uip is connectors import` first to push the connector to the tenant, then retry publish.",
|
|
10146
|
-
|
|
10259
|
+
connectorKey
|
|
10147
10260
|
}
|
|
10148
10261
|
};
|
|
10149
10262
|
}
|
|
@@ -10166,9 +10279,9 @@ async function publishToTenant(args) {
|
|
|
10166
10279
|
code: "missingPublishId",
|
|
10167
10280
|
message: "Publish was accepted but the server response did not include a usable job id.",
|
|
10168
10281
|
fixHint: "The connector may still be publishing server-side. Check Studio Web, or re-run publish. If this persists, the publish API response shape may have changed.",
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
|
|
10282
|
+
connectorKey,
|
|
10283
|
+
connectorId,
|
|
10284
|
+
version
|
|
10172
10285
|
}
|
|
10173
10286
|
};
|
|
10174
10287
|
}
|
|
@@ -10187,8 +10300,8 @@ async function publishToTenant(args) {
|
|
|
10187
10300
|
code: "publishTimeout",
|
|
10188
10301
|
message: `Publish job ${publishId} did not finish within ${args.timeoutSeconds ?? 600}s.`,
|
|
10189
10302
|
fixHint: "Server may still complete — check status manually with `uip is connectors publish-status <id>`.",
|
|
10190
|
-
|
|
10191
|
-
|
|
10303
|
+
publishId,
|
|
10304
|
+
lastStatus: status
|
|
10192
10305
|
}
|
|
10193
10306
|
};
|
|
10194
10307
|
}
|
|
@@ -10205,8 +10318,8 @@ async function publishToTenant(args) {
|
|
|
10205
10318
|
code: "publishFailed",
|
|
10206
10319
|
message: `Publish job ${publishId} reported FAILURE.`,
|
|
10207
10320
|
fixHint: "Inspect server logs or re-publish after correcting the connector.",
|
|
10208
|
-
|
|
10209
|
-
|
|
10321
|
+
publishId,
|
|
10322
|
+
serverMessage: statusResp.message
|
|
10210
10323
|
}
|
|
10211
10324
|
};
|
|
10212
10325
|
}
|
|
@@ -10256,6 +10369,918 @@ function sleep(ms) {
|
|
|
10256
10369
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
10257
10370
|
}
|
|
10258
10371
|
|
|
10372
|
+
// ../../node_modules/fflate/esm/index.mjs
|
|
10373
|
+
import { createRequire } from "module";
|
|
10374
|
+
var require2 = createRequire("/");
|
|
10375
|
+
var _a;
|
|
10376
|
+
var Worker;
|
|
10377
|
+
var isMarkedAsUntransferable;
|
|
10378
|
+
try {
|
|
10379
|
+
_a = require2("worker_threads"), Worker = _a.Worker, isMarkedAsUntransferable = _a.isMarkedAsUntransferable;
|
|
10380
|
+
} catch (e) {}
|
|
10381
|
+
var u8 = Uint8Array;
|
|
10382
|
+
var u16 = Uint16Array;
|
|
10383
|
+
var i32 = Int32Array;
|
|
10384
|
+
var fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0, 0]);
|
|
10385
|
+
var fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 0, 0]);
|
|
10386
|
+
var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
|
|
10387
|
+
var freb = function(eb, start) {
|
|
10388
|
+
var b = new u16(31);
|
|
10389
|
+
for (var i = 0;i < 31; ++i) {
|
|
10390
|
+
b[i] = start += 1 << eb[i - 1];
|
|
10391
|
+
}
|
|
10392
|
+
var r = new i32(b[30]);
|
|
10393
|
+
for (var i = 1;i < 30; ++i) {
|
|
10394
|
+
for (var j = b[i];j < b[i + 1]; ++j) {
|
|
10395
|
+
r[j] = j - b[i] << 5 | i;
|
|
10396
|
+
}
|
|
10397
|
+
}
|
|
10398
|
+
return { b, r };
|
|
10399
|
+
};
|
|
10400
|
+
var _a = freb(fleb, 2);
|
|
10401
|
+
var fl = _a.b;
|
|
10402
|
+
var revfl = _a.r;
|
|
10403
|
+
fl[28] = 258, revfl[258] = 28;
|
|
10404
|
+
var _b = freb(fdeb, 0);
|
|
10405
|
+
var fd = _b.b;
|
|
10406
|
+
var revfd = _b.r;
|
|
10407
|
+
var rev = new u16(32768);
|
|
10408
|
+
for (i = 0;i < 32768; ++i) {
|
|
10409
|
+
x = (i & 43690) >> 1 | (i & 21845) << 1;
|
|
10410
|
+
x = (x & 52428) >> 2 | (x & 13107) << 2;
|
|
10411
|
+
x = (x & 61680) >> 4 | (x & 3855) << 4;
|
|
10412
|
+
rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
|
|
10413
|
+
}
|
|
10414
|
+
var x;
|
|
10415
|
+
var i;
|
|
10416
|
+
var hMap = function(cd, mb, r) {
|
|
10417
|
+
var s = cd.length;
|
|
10418
|
+
var i = 0;
|
|
10419
|
+
var l = new u16(mb);
|
|
10420
|
+
for (;i < s; ++i) {
|
|
10421
|
+
if (cd[i])
|
|
10422
|
+
++l[cd[i] - 1];
|
|
10423
|
+
}
|
|
10424
|
+
var le = new u16(mb);
|
|
10425
|
+
for (i = 1;i < mb; ++i) {
|
|
10426
|
+
le[i] = le[i - 1] + l[i - 1] << 1;
|
|
10427
|
+
}
|
|
10428
|
+
var co;
|
|
10429
|
+
if (r) {
|
|
10430
|
+
co = new u16(1 << mb);
|
|
10431
|
+
var rvb = 15 - mb;
|
|
10432
|
+
for (i = 0;i < s; ++i) {
|
|
10433
|
+
if (cd[i]) {
|
|
10434
|
+
var sv = i << 4 | cd[i];
|
|
10435
|
+
var r_1 = mb - cd[i];
|
|
10436
|
+
var v = le[cd[i] - 1]++ << r_1;
|
|
10437
|
+
for (var m = v | (1 << r_1) - 1;v <= m; ++v) {
|
|
10438
|
+
co[rev[v] >> rvb] = sv;
|
|
10439
|
+
}
|
|
10440
|
+
}
|
|
10441
|
+
}
|
|
10442
|
+
} else {
|
|
10443
|
+
co = new u16(s);
|
|
10444
|
+
for (i = 0;i < s; ++i) {
|
|
10445
|
+
if (cd[i]) {
|
|
10446
|
+
co[i] = rev[le[cd[i] - 1]++] >> 15 - cd[i];
|
|
10447
|
+
}
|
|
10448
|
+
}
|
|
10449
|
+
}
|
|
10450
|
+
return co;
|
|
10451
|
+
};
|
|
10452
|
+
var flt = new u8(288);
|
|
10453
|
+
for (i = 0;i < 144; ++i)
|
|
10454
|
+
flt[i] = 8;
|
|
10455
|
+
var i;
|
|
10456
|
+
for (i = 144;i < 256; ++i)
|
|
10457
|
+
flt[i] = 9;
|
|
10458
|
+
var i;
|
|
10459
|
+
for (i = 256;i < 280; ++i)
|
|
10460
|
+
flt[i] = 7;
|
|
10461
|
+
var i;
|
|
10462
|
+
for (i = 280;i < 288; ++i)
|
|
10463
|
+
flt[i] = 8;
|
|
10464
|
+
var i;
|
|
10465
|
+
var fdt = new u8(32);
|
|
10466
|
+
for (i = 0;i < 32; ++i)
|
|
10467
|
+
fdt[i] = 5;
|
|
10468
|
+
var i;
|
|
10469
|
+
var flm = /* @__PURE__ */ hMap(flt, 9, 0);
|
|
10470
|
+
var flrm = /* @__PURE__ */ hMap(flt, 9, 1);
|
|
10471
|
+
var fdm = /* @__PURE__ */ hMap(fdt, 5, 0);
|
|
10472
|
+
var fdrm = /* @__PURE__ */ hMap(fdt, 5, 1);
|
|
10473
|
+
var max = function(a) {
|
|
10474
|
+
var m = a[0];
|
|
10475
|
+
for (var i = 1;i < a.length; ++i) {
|
|
10476
|
+
if (a[i] > m)
|
|
10477
|
+
m = a[i];
|
|
10478
|
+
}
|
|
10479
|
+
return m;
|
|
10480
|
+
};
|
|
10481
|
+
var bits = function(d, p, m) {
|
|
10482
|
+
var o = p / 8 | 0;
|
|
10483
|
+
return (d[o] | d[o + 1] << 8) >> (p & 7) & m;
|
|
10484
|
+
};
|
|
10485
|
+
var bits16 = function(d, p) {
|
|
10486
|
+
var o = p / 8 | 0;
|
|
10487
|
+
return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7);
|
|
10488
|
+
};
|
|
10489
|
+
var shft = function(p) {
|
|
10490
|
+
return (p + 7) / 8 | 0;
|
|
10491
|
+
};
|
|
10492
|
+
var slc = function(v, s, e) {
|
|
10493
|
+
if (s == null || s < 0)
|
|
10494
|
+
s = 0;
|
|
10495
|
+
if (e == null || e > v.length)
|
|
10496
|
+
e = v.length;
|
|
10497
|
+
return new u8(v.subarray(s, e));
|
|
10498
|
+
};
|
|
10499
|
+
var ec = [
|
|
10500
|
+
"unexpected EOF",
|
|
10501
|
+
"invalid block type",
|
|
10502
|
+
"invalid length/literal",
|
|
10503
|
+
"invalid distance",
|
|
10504
|
+
"stream finished",
|
|
10505
|
+
"no stream handler",
|
|
10506
|
+
,
|
|
10507
|
+
"no callback",
|
|
10508
|
+
"invalid UTF-8 data",
|
|
10509
|
+
"extra field too long",
|
|
10510
|
+
"date not in range 1980-2099",
|
|
10511
|
+
"filename too long",
|
|
10512
|
+
"stream finishing",
|
|
10513
|
+
"invalid zip data"
|
|
10514
|
+
];
|
|
10515
|
+
var err = function(ind, msg, nt) {
|
|
10516
|
+
var e = new Error(msg || ec[ind]);
|
|
10517
|
+
e.code = ind;
|
|
10518
|
+
if (Error.captureStackTrace)
|
|
10519
|
+
Error.captureStackTrace(e, err);
|
|
10520
|
+
if (!nt)
|
|
10521
|
+
throw e;
|
|
10522
|
+
return e;
|
|
10523
|
+
};
|
|
10524
|
+
var inflt = function(dat, st, buf, dict) {
|
|
10525
|
+
var sl = dat.length, dl = dict ? dict.length : 0;
|
|
10526
|
+
if (!sl || st.f && !st.l)
|
|
10527
|
+
return buf || new u8(0);
|
|
10528
|
+
var noBuf = !buf;
|
|
10529
|
+
var resize = noBuf || st.i != 2;
|
|
10530
|
+
var noSt = st.i;
|
|
10531
|
+
if (noBuf)
|
|
10532
|
+
buf = new u8(sl * 3);
|
|
10533
|
+
var cbuf = function(l) {
|
|
10534
|
+
var bl = buf.length;
|
|
10535
|
+
if (l > bl) {
|
|
10536
|
+
var nbuf = new u8(Math.max(bl * 2, l));
|
|
10537
|
+
nbuf.set(buf);
|
|
10538
|
+
buf = nbuf;
|
|
10539
|
+
}
|
|
10540
|
+
};
|
|
10541
|
+
var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, { l: lm, d: dm, m: lbt, n: dbt } = st;
|
|
10542
|
+
var tbts = sl * 8;
|
|
10543
|
+
do {
|
|
10544
|
+
if (!lm) {
|
|
10545
|
+
final = bits(dat, pos, 1);
|
|
10546
|
+
var type = bits(dat, pos + 1, 3);
|
|
10547
|
+
pos += 3;
|
|
10548
|
+
if (!type) {
|
|
10549
|
+
var s = shft(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l;
|
|
10550
|
+
if (t > sl) {
|
|
10551
|
+
if (noSt)
|
|
10552
|
+
err(0);
|
|
10553
|
+
break;
|
|
10554
|
+
}
|
|
10555
|
+
if (resize)
|
|
10556
|
+
cbuf(bt + l);
|
|
10557
|
+
buf.set(dat.subarray(s, t), bt);
|
|
10558
|
+
st.b = bt += l, st.p = pos = t * 8, st.f = final;
|
|
10559
|
+
continue;
|
|
10560
|
+
} else if (type == 1)
|
|
10561
|
+
lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
|
|
10562
|
+
else if (type == 2) {
|
|
10563
|
+
var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
|
|
10564
|
+
var tl = hLit + bits(dat, pos + 5, 31) + 1;
|
|
10565
|
+
pos += 14;
|
|
10566
|
+
var ldt = new u8(tl);
|
|
10567
|
+
var clt = new u8(19);
|
|
10568
|
+
for (var i = 0;i < hcLen; ++i) {
|
|
10569
|
+
clt[clim[i]] = bits(dat, pos + i * 3, 7);
|
|
10570
|
+
}
|
|
10571
|
+
pos += hcLen * 3;
|
|
10572
|
+
var clb = max(clt), clbmsk = (1 << clb) - 1;
|
|
10573
|
+
var clm = hMap(clt, clb, 1);
|
|
10574
|
+
for (var i = 0;i < tl; ) {
|
|
10575
|
+
var r = clm[bits(dat, pos, clbmsk)];
|
|
10576
|
+
pos += r & 15;
|
|
10577
|
+
var s = r >> 4;
|
|
10578
|
+
if (s < 16) {
|
|
10579
|
+
ldt[i++] = s;
|
|
10580
|
+
} else {
|
|
10581
|
+
var c = 0, n = 0;
|
|
10582
|
+
if (s == 16)
|
|
10583
|
+
n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];
|
|
10584
|
+
else if (s == 17)
|
|
10585
|
+
n = 3 + bits(dat, pos, 7), pos += 3;
|
|
10586
|
+
else if (s == 18)
|
|
10587
|
+
n = 11 + bits(dat, pos, 127), pos += 7;
|
|
10588
|
+
while (n--)
|
|
10589
|
+
ldt[i++] = c;
|
|
10590
|
+
}
|
|
10591
|
+
}
|
|
10592
|
+
var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
|
|
10593
|
+
lbt = max(lt);
|
|
10594
|
+
dbt = max(dt);
|
|
10595
|
+
lm = hMap(lt, lbt, 1);
|
|
10596
|
+
dm = hMap(dt, dbt, 1);
|
|
10597
|
+
} else
|
|
10598
|
+
err(1);
|
|
10599
|
+
if (pos > tbts) {
|
|
10600
|
+
if (noSt)
|
|
10601
|
+
err(0);
|
|
10602
|
+
break;
|
|
10603
|
+
}
|
|
10604
|
+
}
|
|
10605
|
+
if (resize)
|
|
10606
|
+
cbuf(bt + 131072);
|
|
10607
|
+
var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
|
|
10608
|
+
var lpos = pos;
|
|
10609
|
+
for (;; lpos = pos) {
|
|
10610
|
+
var c = lm[bits16(dat, pos) & lms], sym = c >> 4;
|
|
10611
|
+
pos += c & 15;
|
|
10612
|
+
if (pos > tbts) {
|
|
10613
|
+
if (noSt)
|
|
10614
|
+
err(0);
|
|
10615
|
+
break;
|
|
10616
|
+
}
|
|
10617
|
+
if (!c)
|
|
10618
|
+
err(2);
|
|
10619
|
+
if (sym < 256)
|
|
10620
|
+
buf[bt++] = sym;
|
|
10621
|
+
else if (sym == 256) {
|
|
10622
|
+
lpos = pos, lm = null;
|
|
10623
|
+
break;
|
|
10624
|
+
} else {
|
|
10625
|
+
var add = sym - 254;
|
|
10626
|
+
if (sym > 264) {
|
|
10627
|
+
var i = sym - 257, b = fleb[i];
|
|
10628
|
+
add = bits(dat, pos, (1 << b) - 1) + fl[i];
|
|
10629
|
+
pos += b;
|
|
10630
|
+
}
|
|
10631
|
+
var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
|
|
10632
|
+
if (!d)
|
|
10633
|
+
err(3);
|
|
10634
|
+
pos += d & 15;
|
|
10635
|
+
var dt = fd[dsym];
|
|
10636
|
+
if (dsym > 3) {
|
|
10637
|
+
var b = fdeb[dsym];
|
|
10638
|
+
dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
|
|
10639
|
+
}
|
|
10640
|
+
if (pos > tbts) {
|
|
10641
|
+
if (noSt)
|
|
10642
|
+
err(0);
|
|
10643
|
+
break;
|
|
10644
|
+
}
|
|
10645
|
+
if (resize)
|
|
10646
|
+
cbuf(bt + 131072);
|
|
10647
|
+
var end = bt + add;
|
|
10648
|
+
if (bt < dt) {
|
|
10649
|
+
var shift = dl - dt, dend = Math.min(dt, end);
|
|
10650
|
+
if (shift + bt < 0)
|
|
10651
|
+
err(3);
|
|
10652
|
+
for (;bt < dend; ++bt)
|
|
10653
|
+
buf[bt] = dict[shift + bt];
|
|
10654
|
+
}
|
|
10655
|
+
for (;bt < end; ++bt)
|
|
10656
|
+
buf[bt] = buf[bt - dt];
|
|
10657
|
+
}
|
|
10658
|
+
}
|
|
10659
|
+
st.l = lm, st.p = lpos, st.b = bt, st.f = final;
|
|
10660
|
+
if (lm)
|
|
10661
|
+
final = 1, st.m = lbt, st.d = dm, st.n = dbt;
|
|
10662
|
+
} while (!final);
|
|
10663
|
+
return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);
|
|
10664
|
+
};
|
|
10665
|
+
var wbits = function(d, p, v) {
|
|
10666
|
+
v <<= p & 7;
|
|
10667
|
+
var o = p / 8 | 0;
|
|
10668
|
+
d[o] |= v;
|
|
10669
|
+
d[o + 1] |= v >> 8;
|
|
10670
|
+
};
|
|
10671
|
+
var wbits16 = function(d, p, v) {
|
|
10672
|
+
v <<= p & 7;
|
|
10673
|
+
var o = p / 8 | 0;
|
|
10674
|
+
d[o] |= v;
|
|
10675
|
+
d[o + 1] |= v >> 8;
|
|
10676
|
+
d[o + 2] |= v >> 16;
|
|
10677
|
+
};
|
|
10678
|
+
var hTree = function(d, mb) {
|
|
10679
|
+
var t = [];
|
|
10680
|
+
for (var i = 0;i < d.length; ++i) {
|
|
10681
|
+
if (d[i])
|
|
10682
|
+
t.push({ s: i, f: d[i] });
|
|
10683
|
+
}
|
|
10684
|
+
var s = t.length;
|
|
10685
|
+
var t2 = t.slice();
|
|
10686
|
+
if (!s)
|
|
10687
|
+
return { t: et, l: 0 };
|
|
10688
|
+
if (s == 1) {
|
|
10689
|
+
var v = new u8(t[0].s + 1);
|
|
10690
|
+
v[t[0].s] = 1;
|
|
10691
|
+
return { t: v, l: 1 };
|
|
10692
|
+
}
|
|
10693
|
+
t.sort(function(a, b) {
|
|
10694
|
+
return a.f - b.f;
|
|
10695
|
+
});
|
|
10696
|
+
t.push({ s: -1, f: 25001 });
|
|
10697
|
+
var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;
|
|
10698
|
+
t[0] = { s: -1, f: l.f + r.f, l, r };
|
|
10699
|
+
while (i1 != s - 1) {
|
|
10700
|
+
l = t[t[i0].f < t[i2].f ? i0++ : i2++];
|
|
10701
|
+
r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];
|
|
10702
|
+
t[i1++] = { s: -1, f: l.f + r.f, l, r };
|
|
10703
|
+
}
|
|
10704
|
+
var maxSym = t2[0].s;
|
|
10705
|
+
for (var i = 1;i < s; ++i) {
|
|
10706
|
+
if (t2[i].s > maxSym)
|
|
10707
|
+
maxSym = t2[i].s;
|
|
10708
|
+
}
|
|
10709
|
+
var tr = new u16(maxSym + 1);
|
|
10710
|
+
var mbt = ln(t[i1 - 1], tr, 0);
|
|
10711
|
+
if (mbt > mb) {
|
|
10712
|
+
var i = 0, dt = 0;
|
|
10713
|
+
var lft = mbt - mb, cst = 1 << lft;
|
|
10714
|
+
t2.sort(function(a, b) {
|
|
10715
|
+
return tr[b.s] - tr[a.s] || a.f - b.f;
|
|
10716
|
+
});
|
|
10717
|
+
for (;i < s; ++i) {
|
|
10718
|
+
var i2_1 = t2[i].s;
|
|
10719
|
+
if (tr[i2_1] > mb) {
|
|
10720
|
+
dt += cst - (1 << mbt - tr[i2_1]);
|
|
10721
|
+
tr[i2_1] = mb;
|
|
10722
|
+
} else
|
|
10723
|
+
break;
|
|
10724
|
+
}
|
|
10725
|
+
dt >>= lft;
|
|
10726
|
+
while (dt > 0) {
|
|
10727
|
+
var i2_2 = t2[i].s;
|
|
10728
|
+
if (tr[i2_2] < mb)
|
|
10729
|
+
dt -= 1 << mb - tr[i2_2]++ - 1;
|
|
10730
|
+
else
|
|
10731
|
+
++i;
|
|
10732
|
+
}
|
|
10733
|
+
for (;i >= 0 && dt; --i) {
|
|
10734
|
+
var i2_3 = t2[i].s;
|
|
10735
|
+
if (tr[i2_3] == mb) {
|
|
10736
|
+
--tr[i2_3];
|
|
10737
|
+
++dt;
|
|
10738
|
+
}
|
|
10739
|
+
}
|
|
10740
|
+
mbt = mb;
|
|
10741
|
+
}
|
|
10742
|
+
return { t: new u8(tr), l: mbt };
|
|
10743
|
+
};
|
|
10744
|
+
var ln = function(n, l, d) {
|
|
10745
|
+
return n.s == -1 ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1)) : l[n.s] = d;
|
|
10746
|
+
};
|
|
10747
|
+
var lc = function(c) {
|
|
10748
|
+
var s = c.length;
|
|
10749
|
+
while (s && !c[--s])
|
|
10750
|
+
;
|
|
10751
|
+
var cl = new u16(++s);
|
|
10752
|
+
var cli = 0, cln = c[0], cls = 1;
|
|
10753
|
+
var w = function(v) {
|
|
10754
|
+
cl[cli++] = v;
|
|
10755
|
+
};
|
|
10756
|
+
for (var i = 1;i <= s; ++i) {
|
|
10757
|
+
if (c[i] == cln && i != s)
|
|
10758
|
+
++cls;
|
|
10759
|
+
else {
|
|
10760
|
+
if (!cln && cls > 2) {
|
|
10761
|
+
for (;cls > 138; cls -= 138)
|
|
10762
|
+
w(32754);
|
|
10763
|
+
if (cls > 2) {
|
|
10764
|
+
w(cls > 10 ? cls - 11 << 5 | 28690 : cls - 3 << 5 | 12305);
|
|
10765
|
+
cls = 0;
|
|
10766
|
+
}
|
|
10767
|
+
} else if (cls > 3) {
|
|
10768
|
+
w(cln), --cls;
|
|
10769
|
+
for (;cls > 6; cls -= 6)
|
|
10770
|
+
w(8304);
|
|
10771
|
+
if (cls > 2)
|
|
10772
|
+
w(cls - 3 << 5 | 8208), cls = 0;
|
|
10773
|
+
}
|
|
10774
|
+
while (cls--)
|
|
10775
|
+
w(cln);
|
|
10776
|
+
cls = 1;
|
|
10777
|
+
cln = c[i];
|
|
10778
|
+
}
|
|
10779
|
+
}
|
|
10780
|
+
return { c: cl.subarray(0, cli), n: s };
|
|
10781
|
+
};
|
|
10782
|
+
var clen = function(cf, cl) {
|
|
10783
|
+
var l = 0;
|
|
10784
|
+
for (var i = 0;i < cl.length; ++i)
|
|
10785
|
+
l += cf[i] * cl[i];
|
|
10786
|
+
return l;
|
|
10787
|
+
};
|
|
10788
|
+
var wfblk = function(out, pos, dat) {
|
|
10789
|
+
var s = dat.length;
|
|
10790
|
+
var o = shft(pos + 2);
|
|
10791
|
+
out[o] = s & 255;
|
|
10792
|
+
out[o + 1] = s >> 8;
|
|
10793
|
+
out[o + 2] = out[o] ^ 255;
|
|
10794
|
+
out[o + 3] = out[o + 1] ^ 255;
|
|
10795
|
+
for (var i = 0;i < s; ++i)
|
|
10796
|
+
out[o + i + 4] = dat[i];
|
|
10797
|
+
return (o + 4 + s) * 8;
|
|
10798
|
+
};
|
|
10799
|
+
var wblk = function(dat, out, final, syms, lf, df, eb, li, bs, bl, p) {
|
|
10800
|
+
wbits(out, p++, final);
|
|
10801
|
+
++lf[256];
|
|
10802
|
+
var _a = hTree(lf, 15), { t: dlt, l: mlb } = _a;
|
|
10803
|
+
var _b = hTree(df, 15), { t: ddt, l: mdb } = _b;
|
|
10804
|
+
var _c = lc(dlt), { c: lclt, n: nlc } = _c;
|
|
10805
|
+
var _d = lc(ddt), { c: lcdt, n: ndc } = _d;
|
|
10806
|
+
var lcfreq = new u16(19);
|
|
10807
|
+
for (var i = 0;i < lclt.length; ++i)
|
|
10808
|
+
++lcfreq[lclt[i] & 31];
|
|
10809
|
+
for (var i = 0;i < lcdt.length; ++i)
|
|
10810
|
+
++lcfreq[lcdt[i] & 31];
|
|
10811
|
+
var _e = hTree(lcfreq, 7), { t: lct, l: mlcb } = _e;
|
|
10812
|
+
var nlcc = 19;
|
|
10813
|
+
for (;nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)
|
|
10814
|
+
;
|
|
10815
|
+
var flen = bl + 5 << 3;
|
|
10816
|
+
var ftlen = clen(lf, flt) + clen(df, fdt) + eb;
|
|
10817
|
+
var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + 2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18];
|
|
10818
|
+
if (bs >= 0 && flen <= ftlen && flen <= dtlen)
|
|
10819
|
+
return wfblk(out, p, dat.subarray(bs, bs + bl));
|
|
10820
|
+
var lm, ll, dm, dl;
|
|
10821
|
+
wbits(out, p, 1 + (dtlen < ftlen)), p += 2;
|
|
10822
|
+
if (dtlen < ftlen) {
|
|
10823
|
+
lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;
|
|
10824
|
+
var llm = hMap(lct, mlcb, 0);
|
|
10825
|
+
wbits(out, p, nlc - 257);
|
|
10826
|
+
wbits(out, p + 5, ndc - 1);
|
|
10827
|
+
wbits(out, p + 10, nlcc - 4);
|
|
10828
|
+
p += 14;
|
|
10829
|
+
for (var i = 0;i < nlcc; ++i)
|
|
10830
|
+
wbits(out, p + 3 * i, lct[clim[i]]);
|
|
10831
|
+
p += 3 * nlcc;
|
|
10832
|
+
var lcts = [lclt, lcdt];
|
|
10833
|
+
for (var it = 0;it < 2; ++it) {
|
|
10834
|
+
var clct = lcts[it];
|
|
10835
|
+
for (var i = 0;i < clct.length; ++i) {
|
|
10836
|
+
var len = clct[i] & 31;
|
|
10837
|
+
wbits(out, p, llm[len]), p += lct[len];
|
|
10838
|
+
if (len > 15)
|
|
10839
|
+
wbits(out, p, clct[i] >> 5 & 127), p += clct[i] >> 12;
|
|
10840
|
+
}
|
|
10841
|
+
}
|
|
10842
|
+
} else {
|
|
10843
|
+
lm = flm, ll = flt, dm = fdm, dl = fdt;
|
|
10844
|
+
}
|
|
10845
|
+
for (var i = 0;i < li; ++i) {
|
|
10846
|
+
var sym = syms[i];
|
|
10847
|
+
if (sym > 255) {
|
|
10848
|
+
var len = sym >> 18 & 31;
|
|
10849
|
+
wbits16(out, p, lm[len + 257]), p += ll[len + 257];
|
|
10850
|
+
if (len > 7)
|
|
10851
|
+
wbits(out, p, sym >> 23 & 31), p += fleb[len];
|
|
10852
|
+
var dst = sym & 31;
|
|
10853
|
+
wbits16(out, p, dm[dst]), p += dl[dst];
|
|
10854
|
+
if (dst > 3)
|
|
10855
|
+
wbits16(out, p, sym >> 5 & 8191), p += fdeb[dst];
|
|
10856
|
+
} else {
|
|
10857
|
+
wbits16(out, p, lm[sym]), p += ll[sym];
|
|
10858
|
+
}
|
|
10859
|
+
}
|
|
10860
|
+
wbits16(out, p, lm[256]);
|
|
10861
|
+
return p + ll[256];
|
|
10862
|
+
};
|
|
10863
|
+
var deo = /* @__PURE__ */ new i32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);
|
|
10864
|
+
var et = /* @__PURE__ */ new u8(0);
|
|
10865
|
+
var dflt = function(dat, lvl, plvl, pre, post, st) {
|
|
10866
|
+
var s = st.z || dat.length;
|
|
10867
|
+
var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7000)) + post);
|
|
10868
|
+
var w = o.subarray(pre, o.length - post);
|
|
10869
|
+
var lst = st.l;
|
|
10870
|
+
var pos = (st.r || 0) & 7;
|
|
10871
|
+
if (lvl) {
|
|
10872
|
+
if (pos)
|
|
10873
|
+
w[0] = st.r >> 3;
|
|
10874
|
+
var opt = deo[lvl - 1];
|
|
10875
|
+
var n = opt >> 13, c = opt & 8191;
|
|
10876
|
+
var msk_1 = (1 << plvl) - 1;
|
|
10877
|
+
var prev = st.p || new u16(32768), head = st.h || new u16(msk_1 + 1);
|
|
10878
|
+
var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;
|
|
10879
|
+
var hsh = function(i) {
|
|
10880
|
+
return (dat[i] ^ dat[i + 1] << bs1_1 ^ dat[i + 2] << bs2_1) & msk_1;
|
|
10881
|
+
};
|
|
10882
|
+
var syms = new i32(25000);
|
|
10883
|
+
var lf = new u16(288), df = new u16(32);
|
|
10884
|
+
var lc_1 = 0, eb = 0, i = st.i || 0, li = 0, wi = st.w || 0, bs = 0;
|
|
10885
|
+
for (;i + 2 < s; ++i) {
|
|
10886
|
+
var hv = hsh(i);
|
|
10887
|
+
var imod = i & 32767, pimod = head[hv];
|
|
10888
|
+
prev[imod] = pimod;
|
|
10889
|
+
head[hv] = imod;
|
|
10890
|
+
if (wi <= i) {
|
|
10891
|
+
var rem = s - i;
|
|
10892
|
+
if ((lc_1 > 7000 || li > 24576) && (rem > 423 || !lst)) {
|
|
10893
|
+
pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);
|
|
10894
|
+
li = lc_1 = eb = 0, bs = i;
|
|
10895
|
+
for (var j = 0;j < 286; ++j)
|
|
10896
|
+
lf[j] = 0;
|
|
10897
|
+
for (var j = 0;j < 30; ++j)
|
|
10898
|
+
df[j] = 0;
|
|
10899
|
+
}
|
|
10900
|
+
var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767;
|
|
10901
|
+
if (rem > 2 && hv == hsh(i - dif)) {
|
|
10902
|
+
var maxn = Math.min(n, rem) - 1;
|
|
10903
|
+
var maxd = Math.min(32767, i);
|
|
10904
|
+
var ml = Math.min(258, rem);
|
|
10905
|
+
while (dif <= maxd && --ch_1 && imod != pimod) {
|
|
10906
|
+
if (dat[i + l] == dat[i + l - dif]) {
|
|
10907
|
+
var nl = 0;
|
|
10908
|
+
for (;nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl)
|
|
10909
|
+
;
|
|
10910
|
+
if (nl > l) {
|
|
10911
|
+
l = nl, d = dif;
|
|
10912
|
+
if (nl > maxn)
|
|
10913
|
+
break;
|
|
10914
|
+
var mmd = Math.min(dif, nl - 2);
|
|
10915
|
+
var md = 0;
|
|
10916
|
+
for (var j = 0;j < mmd; ++j) {
|
|
10917
|
+
var ti = i - dif + j & 32767;
|
|
10918
|
+
var pti = prev[ti];
|
|
10919
|
+
var cd = ti - pti & 32767;
|
|
10920
|
+
if (cd > md)
|
|
10921
|
+
md = cd, pimod = ti;
|
|
10922
|
+
}
|
|
10923
|
+
}
|
|
10924
|
+
}
|
|
10925
|
+
imod = pimod, pimod = prev[imod];
|
|
10926
|
+
dif += imod - pimod & 32767;
|
|
10927
|
+
}
|
|
10928
|
+
}
|
|
10929
|
+
if (d) {
|
|
10930
|
+
syms[li++] = 268435456 | revfl[l] << 18 | revfd[d];
|
|
10931
|
+
var lin = revfl[l] & 31, din = revfd[d] & 31;
|
|
10932
|
+
eb += fleb[lin] + fdeb[din];
|
|
10933
|
+
++lf[257 + lin];
|
|
10934
|
+
++df[din];
|
|
10935
|
+
wi = i + l;
|
|
10936
|
+
++lc_1;
|
|
10937
|
+
} else {
|
|
10938
|
+
syms[li++] = dat[i];
|
|
10939
|
+
++lf[dat[i]];
|
|
10940
|
+
}
|
|
10941
|
+
}
|
|
10942
|
+
}
|
|
10943
|
+
for (i = Math.max(i, wi);i < s; ++i) {
|
|
10944
|
+
syms[li++] = dat[i];
|
|
10945
|
+
++lf[dat[i]];
|
|
10946
|
+
}
|
|
10947
|
+
pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);
|
|
10948
|
+
if (!lst) {
|
|
10949
|
+
st.r = pos & 7 | w[pos / 8 | 0] << 3;
|
|
10950
|
+
pos -= 7;
|
|
10951
|
+
st.h = head, st.p = prev, st.i = i, st.w = wi;
|
|
10952
|
+
}
|
|
10953
|
+
} else {
|
|
10954
|
+
for (var i = st.w || 0;i < s + lst; i += 65535) {
|
|
10955
|
+
var e = i + 65535;
|
|
10956
|
+
if (e >= s) {
|
|
10957
|
+
w[pos / 8 | 0] = lst;
|
|
10958
|
+
e = s;
|
|
10959
|
+
}
|
|
10960
|
+
pos = wfblk(w, pos + 1, dat.subarray(i, e));
|
|
10961
|
+
}
|
|
10962
|
+
st.i = s;
|
|
10963
|
+
}
|
|
10964
|
+
return slc(o, 0, pre + shft(pos) + post);
|
|
10965
|
+
};
|
|
10966
|
+
var crct = /* @__PURE__ */ function() {
|
|
10967
|
+
var t = new Int32Array(256);
|
|
10968
|
+
for (var i = 0;i < 256; ++i) {
|
|
10969
|
+
var c = i, k = 9;
|
|
10970
|
+
while (--k)
|
|
10971
|
+
c = (c & 1 && -306674912) ^ c >>> 1;
|
|
10972
|
+
t[i] = c;
|
|
10973
|
+
}
|
|
10974
|
+
return t;
|
|
10975
|
+
}();
|
|
10976
|
+
var crc = function() {
|
|
10977
|
+
var c = -1;
|
|
10978
|
+
return {
|
|
10979
|
+
p: function(d) {
|
|
10980
|
+
var cr = c;
|
|
10981
|
+
for (var i = 0;i < d.length; ++i)
|
|
10982
|
+
cr = crct[cr & 255 ^ d[i]] ^ cr >>> 8;
|
|
10983
|
+
c = cr;
|
|
10984
|
+
},
|
|
10985
|
+
d: function() {
|
|
10986
|
+
return ~c;
|
|
10987
|
+
}
|
|
10988
|
+
};
|
|
10989
|
+
};
|
|
10990
|
+
var dopt = function(dat, opt, pre, post, st) {
|
|
10991
|
+
if (!st) {
|
|
10992
|
+
st = { l: 1 };
|
|
10993
|
+
if (opt.dictionary) {
|
|
10994
|
+
var dict = opt.dictionary.subarray(-32768);
|
|
10995
|
+
var newDat = new u8(dict.length + dat.length);
|
|
10996
|
+
newDat.set(dict);
|
|
10997
|
+
newDat.set(dat, dict.length);
|
|
10998
|
+
dat = newDat;
|
|
10999
|
+
st.w = dict.length;
|
|
11000
|
+
}
|
|
11001
|
+
}
|
|
11002
|
+
return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? st.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 20 : 12 + opt.mem, pre, post, st);
|
|
11003
|
+
};
|
|
11004
|
+
var mrg = function(a, b) {
|
|
11005
|
+
var o = {};
|
|
11006
|
+
for (var k in a)
|
|
11007
|
+
o[k] = a[k];
|
|
11008
|
+
for (var k in b)
|
|
11009
|
+
o[k] = b[k];
|
|
11010
|
+
return o;
|
|
11011
|
+
};
|
|
11012
|
+
var b2 = function(d, b) {
|
|
11013
|
+
return d[b] | d[b + 1] << 8;
|
|
11014
|
+
};
|
|
11015
|
+
var b4 = function(d, b) {
|
|
11016
|
+
return (d[b] | d[b + 1] << 8 | d[b + 2] << 16 | d[b + 3] << 24) >>> 0;
|
|
11017
|
+
};
|
|
11018
|
+
var b8 = function(d, b) {
|
|
11019
|
+
return b4(d, b) + b4(d, b + 4) * 4294967296;
|
|
11020
|
+
};
|
|
11021
|
+
var wbytes = function(d, b, v) {
|
|
11022
|
+
for (;v; ++b)
|
|
11023
|
+
d[b] = v, v >>>= 8;
|
|
11024
|
+
};
|
|
11025
|
+
function deflateSync(data, opts) {
|
|
11026
|
+
return dopt(data, opts || {}, 0, 0);
|
|
11027
|
+
}
|
|
11028
|
+
function inflateSync(data, opts) {
|
|
11029
|
+
return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary);
|
|
11030
|
+
}
|
|
11031
|
+
var fltn = function(d, p, t, o) {
|
|
11032
|
+
for (var k in d) {
|
|
11033
|
+
var val = d[k], n = p + k, op = o;
|
|
11034
|
+
if (Array.isArray(val))
|
|
11035
|
+
op = mrg(o, val[1]), val = val[0];
|
|
11036
|
+
if (ArrayBuffer.isView(val))
|
|
11037
|
+
t[n] = [val, op];
|
|
11038
|
+
else {
|
|
11039
|
+
t[n += "/"] = [new u8(0), op];
|
|
11040
|
+
fltn(val, n, t, o);
|
|
11041
|
+
}
|
|
11042
|
+
}
|
|
11043
|
+
};
|
|
11044
|
+
var te = typeof TextEncoder != "undefined" && /* @__PURE__ */ new TextEncoder;
|
|
11045
|
+
var td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder;
|
|
11046
|
+
var tds = 0;
|
|
11047
|
+
try {
|
|
11048
|
+
td.decode(et, { stream: true });
|
|
11049
|
+
tds = 1;
|
|
11050
|
+
} catch (e) {}
|
|
11051
|
+
var dutf8 = function(d) {
|
|
11052
|
+
for (var r = "", i = 0;; ) {
|
|
11053
|
+
var c = d[i++];
|
|
11054
|
+
var eb = (c > 127) + (c > 223) + (c > 239);
|
|
11055
|
+
if (i + eb > d.length)
|
|
11056
|
+
return { s: r, r: slc(d, i - 1) };
|
|
11057
|
+
if (!eb)
|
|
11058
|
+
r += String.fromCharCode(c);
|
|
11059
|
+
else if (eb == 3) {
|
|
11060
|
+
c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | d[i++] & 63) - 65536, r += String.fromCharCode(55296 | c >> 10, 56320 | c & 1023);
|
|
11061
|
+
} else if (eb & 1)
|
|
11062
|
+
r += String.fromCharCode((c & 31) << 6 | d[i++] & 63);
|
|
11063
|
+
else
|
|
11064
|
+
r += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | d[i++] & 63);
|
|
11065
|
+
}
|
|
11066
|
+
};
|
|
11067
|
+
function strToU8(str, latin1) {
|
|
11068
|
+
if (latin1) {
|
|
11069
|
+
var ar_1 = new u8(str.length);
|
|
11070
|
+
for (var i = 0;i < str.length; ++i)
|
|
11071
|
+
ar_1[i] = str.charCodeAt(i);
|
|
11072
|
+
return ar_1;
|
|
11073
|
+
}
|
|
11074
|
+
if (te)
|
|
11075
|
+
return te.encode(str);
|
|
11076
|
+
var l = str.length;
|
|
11077
|
+
var ar = new u8(str.length + (str.length >> 1));
|
|
11078
|
+
var ai = 0;
|
|
11079
|
+
var w = function(v) {
|
|
11080
|
+
ar[ai++] = v;
|
|
11081
|
+
};
|
|
11082
|
+
for (var i = 0;i < l; ++i) {
|
|
11083
|
+
if (ai + 5 > ar.length) {
|
|
11084
|
+
var n = new u8(ai + 8 + (l - i << 1));
|
|
11085
|
+
n.set(ar);
|
|
11086
|
+
ar = n;
|
|
11087
|
+
}
|
|
11088
|
+
var c = str.charCodeAt(i);
|
|
11089
|
+
if (c < 128 || latin1)
|
|
11090
|
+
w(c);
|
|
11091
|
+
else if (c < 2048)
|
|
11092
|
+
w(192 | c >> 6), w(128 | c & 63);
|
|
11093
|
+
else if (c > 55295 && c < 57344)
|
|
11094
|
+
c = 65536 + (c & 1023 << 10) | str.charCodeAt(++i) & 1023, w(240 | c >> 18), w(128 | c >> 12 & 63), w(128 | c >> 6 & 63), w(128 | c & 63);
|
|
11095
|
+
else
|
|
11096
|
+
w(224 | c >> 12), w(128 | c >> 6 & 63), w(128 | c & 63);
|
|
11097
|
+
}
|
|
11098
|
+
return slc(ar, 0, ai);
|
|
11099
|
+
}
|
|
11100
|
+
function strFromU8(dat, latin1) {
|
|
11101
|
+
if (latin1) {
|
|
11102
|
+
var r = "";
|
|
11103
|
+
for (var i = 0;i < dat.length; i += 16384)
|
|
11104
|
+
r += String.fromCharCode.apply(null, dat.subarray(i, i + 16384));
|
|
11105
|
+
return r;
|
|
11106
|
+
} else if (td) {
|
|
11107
|
+
return td.decode(dat);
|
|
11108
|
+
} else {
|
|
11109
|
+
var _a = dutf8(dat), { s, r } = _a;
|
|
11110
|
+
if (r.length)
|
|
11111
|
+
err(8);
|
|
11112
|
+
return s;
|
|
11113
|
+
}
|
|
11114
|
+
}
|
|
11115
|
+
var slzh = function(d, b) {
|
|
11116
|
+
return b + 30 + b2(d, b + 26) + b2(d, b + 28);
|
|
11117
|
+
};
|
|
11118
|
+
var zh = function(d, b, z) {
|
|
11119
|
+
var fnl = b2(d, b + 28), efl = b2(d, b + 30), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl;
|
|
11120
|
+
var _a = z64hs(d, es, efl, z, b4(d, b + 20), b4(d, b + 24), b4(d, b + 42)), sc = _a[0], su = _a[1], off = _a[2];
|
|
11121
|
+
return [b2(d, b + 10), sc, su, fn, es + efl + b2(d, b + 32), off];
|
|
11122
|
+
};
|
|
11123
|
+
var z64hs = function(d, b, l, z, sc, su, off) {
|
|
11124
|
+
var nsc = sc == 4294967295, nsu = su == 4294967295, noff = off == 4294967295, e = b + l;
|
|
11125
|
+
var nf = nsc + nsu + noff;
|
|
11126
|
+
if (z && nf) {
|
|
11127
|
+
for (;b + 4 < e; b += 4 + b2(d, b + 2)) {
|
|
11128
|
+
if (b2(d, b) == 1) {
|
|
11129
|
+
return [
|
|
11130
|
+
nsc ? b8(d, b + 4 + 8 * nsu) : sc,
|
|
11131
|
+
nsu ? b8(d, b + 4) : su,
|
|
11132
|
+
noff ? b8(d, b + 4 + 8 * (nsu + nsc)) : off,
|
|
11133
|
+
1
|
|
11134
|
+
];
|
|
11135
|
+
}
|
|
11136
|
+
}
|
|
11137
|
+
if (z < 2)
|
|
11138
|
+
err(13);
|
|
11139
|
+
}
|
|
11140
|
+
return [sc, su, off, 0];
|
|
11141
|
+
};
|
|
11142
|
+
var exfl = function(ex) {
|
|
11143
|
+
var le = 0;
|
|
11144
|
+
if (ex) {
|
|
11145
|
+
for (var k in ex) {
|
|
11146
|
+
var l = ex[k].length;
|
|
11147
|
+
if (l > 65535)
|
|
11148
|
+
err(9);
|
|
11149
|
+
le += l + 4;
|
|
11150
|
+
}
|
|
11151
|
+
}
|
|
11152
|
+
return le;
|
|
11153
|
+
};
|
|
11154
|
+
var wzh = function(d, b, f, fn, u, c, ce, co) {
|
|
11155
|
+
var fl = fn.length, ex = f.extra, col = co && co.length;
|
|
11156
|
+
var exl = exfl(ex);
|
|
11157
|
+
wbytes(d, b, ce != null ? 33639248 : 67324752), b += 4;
|
|
11158
|
+
if (ce != null)
|
|
11159
|
+
d[b++] = 20, d[b++] = f.os;
|
|
11160
|
+
d[b] = 20, b += 2;
|
|
11161
|
+
d[b++] = f.flag << 1 | (c < 0 && 8), d[b++] = u && 8;
|
|
11162
|
+
d[b++] = f.compression & 255, d[b++] = f.compression >> 8;
|
|
11163
|
+
var dt = new Date(f.mtime == null ? Date.now() : f.mtime), y = dt.getFullYear() - 1980;
|
|
11164
|
+
if (y < 0 || y > 119)
|
|
11165
|
+
err(10);
|
|
11166
|
+
wbytes(d, b, y << 25 | dt.getMonth() + 1 << 21 | dt.getDate() << 16 | dt.getHours() << 11 | dt.getMinutes() << 5 | dt.getSeconds() >> 1), b += 4;
|
|
11167
|
+
if (c != -1) {
|
|
11168
|
+
wbytes(d, b, f.crc);
|
|
11169
|
+
wbytes(d, b + 4, c < 0 ? -c - 2 : c);
|
|
11170
|
+
wbytes(d, b + 8, f.size);
|
|
11171
|
+
}
|
|
11172
|
+
wbytes(d, b + 12, fl);
|
|
11173
|
+
wbytes(d, b + 14, exl), b += 16;
|
|
11174
|
+
if (ce != null) {
|
|
11175
|
+
wbytes(d, b, col);
|
|
11176
|
+
wbytes(d, b + 6, f.attrs);
|
|
11177
|
+
wbytes(d, b + 10, ce), b += 14;
|
|
11178
|
+
}
|
|
11179
|
+
d.set(fn, b);
|
|
11180
|
+
b += fl;
|
|
11181
|
+
if (exl) {
|
|
11182
|
+
for (var k in ex) {
|
|
11183
|
+
var exf = ex[k], l = exf.length;
|
|
11184
|
+
wbytes(d, b, +k);
|
|
11185
|
+
wbytes(d, b + 2, l);
|
|
11186
|
+
d.set(exf, b + 4), b += 4 + l;
|
|
11187
|
+
}
|
|
11188
|
+
}
|
|
11189
|
+
if (col)
|
|
11190
|
+
d.set(co, b), b += col;
|
|
11191
|
+
return b;
|
|
11192
|
+
};
|
|
11193
|
+
var wzf = function(o, b, c, d, e) {
|
|
11194
|
+
wbytes(o, b, 101010256);
|
|
11195
|
+
wbytes(o, b + 8, c);
|
|
11196
|
+
wbytes(o, b + 10, c);
|
|
11197
|
+
wbytes(o, b + 12, d);
|
|
11198
|
+
wbytes(o, b + 16, e);
|
|
11199
|
+
};
|
|
11200
|
+
function zipSync(data, opts) {
|
|
11201
|
+
if (!opts)
|
|
11202
|
+
opts = {};
|
|
11203
|
+
var r = {};
|
|
11204
|
+
var files = [];
|
|
11205
|
+
fltn(data, "", r, opts);
|
|
11206
|
+
var o = 0;
|
|
11207
|
+
var tot = 0;
|
|
11208
|
+
for (var fn in r) {
|
|
11209
|
+
var _a = r[fn], file = _a[0], p = _a[1];
|
|
11210
|
+
var compression = p.level == 0 ? 0 : 8;
|
|
11211
|
+
var f = strToU8(fn), s = f.length;
|
|
11212
|
+
var com = p.comment, m = com && strToU8(com), ms = m && m.length;
|
|
11213
|
+
var exl = exfl(p.extra);
|
|
11214
|
+
if (s > 65535)
|
|
11215
|
+
err(11);
|
|
11216
|
+
var d = compression ? deflateSync(file, p) : file, l = d.length;
|
|
11217
|
+
var c = crc();
|
|
11218
|
+
c.p(file);
|
|
11219
|
+
files.push(mrg(p, {
|
|
11220
|
+
size: file.length,
|
|
11221
|
+
crc: c.d(),
|
|
11222
|
+
c: d,
|
|
11223
|
+
f,
|
|
11224
|
+
m,
|
|
11225
|
+
u: s != fn.length || m && com.length != ms,
|
|
11226
|
+
o,
|
|
11227
|
+
compression
|
|
11228
|
+
}));
|
|
11229
|
+
o += 30 + s + exl + l;
|
|
11230
|
+
tot += 76 + 2 * (s + exl) + (ms || 0) + l;
|
|
11231
|
+
}
|
|
11232
|
+
var out = new u8(tot + 22), oe = o, cdl = tot - o;
|
|
11233
|
+
for (var i = 0;i < files.length; ++i) {
|
|
11234
|
+
var f = files[i];
|
|
11235
|
+
wzh(out, f.o, f, f.f, f.u, f.c.length);
|
|
11236
|
+
var badd = 30 + f.f.length + exfl(f.extra);
|
|
11237
|
+
out.set(f.c, f.o + badd);
|
|
11238
|
+
wzh(out, o, f, f.f, f.u, f.c.length, f.o, f.m), o += 16 + badd + (f.m ? f.m.length : 0);
|
|
11239
|
+
}
|
|
11240
|
+
wzf(out, o, files.length, cdl, oe);
|
|
11241
|
+
return out;
|
|
11242
|
+
}
|
|
11243
|
+
function unzipSync(data, opts) {
|
|
11244
|
+
var files = {};
|
|
11245
|
+
var e = data.length - 22;
|
|
11246
|
+
for (;b4(data, e) != 101010256; --e) {
|
|
11247
|
+
if (!e || data.length - e > 65558)
|
|
11248
|
+
err(13);
|
|
11249
|
+
}
|
|
11250
|
+
var c = b2(data, e + 8);
|
|
11251
|
+
if (!c)
|
|
11252
|
+
return {};
|
|
11253
|
+
var o = b4(data, e + 16);
|
|
11254
|
+
var z = b4(data, e - 20) == 117853008;
|
|
11255
|
+
if (z) {
|
|
11256
|
+
var ze = b4(data, e - 12);
|
|
11257
|
+
z = b4(data, ze) == 101075792;
|
|
11258
|
+
if (z) {
|
|
11259
|
+
c = b4(data, ze + 32);
|
|
11260
|
+
o = b4(data, ze + 48);
|
|
11261
|
+
}
|
|
11262
|
+
}
|
|
11263
|
+
var fltr = opts && opts.filter;
|
|
11264
|
+
for (var i = 0;i < c; ++i) {
|
|
11265
|
+
var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);
|
|
11266
|
+
o = no;
|
|
11267
|
+
if (!fltr || fltr({
|
|
11268
|
+
name: fn,
|
|
11269
|
+
size: sc,
|
|
11270
|
+
originalSize: su,
|
|
11271
|
+
compression: c_2
|
|
11272
|
+
})) {
|
|
11273
|
+
if (!c_2)
|
|
11274
|
+
files[fn] = slc(data, b, b + sc);
|
|
11275
|
+
else if (c_2 == 8)
|
|
11276
|
+
files[fn] = inflateSync(data.subarray(b, b + sc), { out: new u8(su) });
|
|
11277
|
+
else
|
|
11278
|
+
err(14, "unknown compression type " + c_2);
|
|
11279
|
+
}
|
|
11280
|
+
}
|
|
11281
|
+
return files;
|
|
11282
|
+
}
|
|
11283
|
+
|
|
10259
11284
|
// src/services/connector-builder/util/packaging.ts
|
|
10260
11285
|
var JUNK_NAMES = new Set([
|
|
10261
11286
|
".DS_Store",
|
|
@@ -11231,19 +12256,19 @@ async function resolveSrNameByInternalPath(connectorRoot, internalPath) {
|
|
|
11231
12256
|
return null;
|
|
11232
12257
|
return matches.find((n) => normalizeInternalPath(`/${n}`) === target) ?? matches[0];
|
|
11233
12258
|
}
|
|
11234
|
-
function getSrField(sr,
|
|
11235
|
-
return sr.fields?.[
|
|
12259
|
+
function getSrField(sr, fieldName) {
|
|
12260
|
+
return sr.fields?.[fieldName] ?? null;
|
|
11236
12261
|
}
|
|
11237
|
-
function upsertSrField(sr,
|
|
12262
|
+
function upsertSrField(sr, fieldName, field, overwrite = false) {
|
|
11238
12263
|
if (!sr.fields) {
|
|
11239
12264
|
sr.fields = {};
|
|
11240
12265
|
}
|
|
11241
|
-
const existing = sr.fields[
|
|
12266
|
+
const existing = sr.fields[fieldName];
|
|
11242
12267
|
if (existing === undefined || overwrite) {
|
|
11243
|
-
sr.fields[
|
|
12268
|
+
sr.fields[fieldName] = field;
|
|
11244
12269
|
return sr;
|
|
11245
12270
|
}
|
|
11246
|
-
sr.fields[
|
|
12271
|
+
sr.fields[fieldName] = mergeField(existing, field);
|
|
11247
12272
|
return sr;
|
|
11248
12273
|
}
|
|
11249
12274
|
function mergeField(existing, incoming) {
|
|
@@ -11263,12 +12288,12 @@ function mergeField(existing, incoming) {
|
|
|
11263
12288
|
function isRecord(value) {
|
|
11264
12289
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11265
12290
|
}
|
|
11266
|
-
function removeSrField(sr,
|
|
12291
|
+
function removeSrField(sr, fieldName) {
|
|
11267
12292
|
const fields = sr.fields ?? {};
|
|
11268
|
-
if (!(
|
|
11269
|
-
throw new Error(`Field '${
|
|
12293
|
+
if (!(fieldName in fields)) {
|
|
12294
|
+
throw new Error(`Field '${fieldName}' not found in standard resource.`);
|
|
11270
12295
|
}
|
|
11271
|
-
delete fields[
|
|
12296
|
+
delete fields[fieldName];
|
|
11272
12297
|
return sr;
|
|
11273
12298
|
}
|
|
11274
12299
|
function getSrMetadataKey(sr, key) {
|
|
@@ -11465,8 +12490,8 @@ function buildDefaultParameters(method, resourceName, resourcePath, vendorPath,
|
|
|
11465
12490
|
const params = [];
|
|
11466
12491
|
const pathParams = [];
|
|
11467
12492
|
const seen = new Set;
|
|
11468
|
-
for (const
|
|
11469
|
-
for (const m of
|
|
12493
|
+
for (const src of [vendorPath, resourcePath]) {
|
|
12494
|
+
for (const m of src.matchAll(/\{(\w+)\}/g)) {
|
|
11470
12495
|
if (!seen.has(m[1])) {
|
|
11471
12496
|
seen.add(m[1]);
|
|
11472
12497
|
pathParams.push(m[1]);
|
|
@@ -12242,9 +13267,9 @@ async function removeResource(connectorRoot, name) {
|
|
|
12242
13267
|
let standardResourceRemoved = false;
|
|
12243
13268
|
const fs = getFileSystem();
|
|
12244
13269
|
const srName = await resolveSrNameByInternalPath(root, `/${name}`) ?? name;
|
|
12245
|
-
const
|
|
12246
|
-
if (await fs.exists(
|
|
12247
|
-
await fs.rm(
|
|
13270
|
+
const srPath = fs.path.join(root, "app", "element", "standard-resources", `${srName}.json`);
|
|
13271
|
+
if (await fs.exists(srPath)) {
|
|
13272
|
+
await fs.rm(srPath);
|
|
12248
13273
|
standardResourceRemoved = true;
|
|
12249
13274
|
}
|
|
12250
13275
|
return {
|
|
@@ -12292,13 +13317,13 @@ async function listFields(connectorRoot, resource) {
|
|
|
12292
13317
|
const fields = Object.values(sr.sr.fields ?? {});
|
|
12293
13318
|
return { ok: true, data: { resource, fields } };
|
|
12294
13319
|
}
|
|
12295
|
-
async function getField(connectorRoot, resource,
|
|
13320
|
+
async function getField(connectorRoot, resource, fieldName) {
|
|
12296
13321
|
const sr = await loadSr(connectorRoot, resource);
|
|
12297
13322
|
if (!sr.ok)
|
|
12298
13323
|
return sr;
|
|
12299
|
-
const field = getSrField(sr.sr,
|
|
13324
|
+
const field = getSrField(sr.sr, fieldName);
|
|
12300
13325
|
if (field === null) {
|
|
12301
|
-
return fieldNotFound(resource,
|
|
13326
|
+
return fieldNotFound(resource, fieldName);
|
|
12302
13327
|
}
|
|
12303
13328
|
return { ok: true, data: { resource, field } };
|
|
12304
13329
|
}
|
|
@@ -12341,17 +13366,17 @@ async function upsertField(connectorRoot, resource, field, overwrite = false) {
|
|
|
12341
13366
|
}
|
|
12342
13367
|
};
|
|
12343
13368
|
}
|
|
12344
|
-
async function removeField(connectorRoot, resource,
|
|
13369
|
+
async function removeField(connectorRoot, resource, fieldName) {
|
|
12345
13370
|
const loaded = await loadSr(connectorRoot, resource);
|
|
12346
13371
|
if (!loaded.ok)
|
|
12347
13372
|
return loaded;
|
|
12348
13373
|
const sr = loaded.sr;
|
|
12349
|
-
if (getSrField(sr,
|
|
12350
|
-
return fieldNotFound(resource,
|
|
13374
|
+
if (getSrField(sr, fieldName) === null) {
|
|
13375
|
+
return fieldNotFound(resource, fieldName);
|
|
12351
13376
|
}
|
|
12352
|
-
removeSrField(sr,
|
|
13377
|
+
removeSrField(sr, fieldName);
|
|
12353
13378
|
await writeStandardResource(loaded.root, resource, sr);
|
|
12354
|
-
return { ok: true, data: { resource, fieldName
|
|
13379
|
+
return { ok: true, data: { resource, fieldName } };
|
|
12355
13380
|
}
|
|
12356
13381
|
async function loadSr(connectorRoot, resource) {
|
|
12357
13382
|
const found = await findElementDir(connectorRoot);
|
|
@@ -12372,12 +13397,12 @@ async function loadSr(connectorRoot, resource) {
|
|
|
12372
13397
|
};
|
|
12373
13398
|
}
|
|
12374
13399
|
}
|
|
12375
|
-
function fieldNotFound(resource,
|
|
13400
|
+
function fieldNotFound(resource, fieldName) {
|
|
12376
13401
|
return {
|
|
12377
13402
|
ok: false,
|
|
12378
13403
|
error: {
|
|
12379
13404
|
code: "fieldNotFound",
|
|
12380
|
-
message: `Field '${
|
|
13405
|
+
message: `Field '${fieldName}' was not found in resource '${resource}'.`,
|
|
12381
13406
|
fixHint: "Use listFields to see the available field names."
|
|
12382
13407
|
}
|
|
12383
13408
|
};
|
|
@@ -12683,11 +13708,11 @@ async function restoreParamSnapshot(root, snap) {
|
|
|
12683
13708
|
if (snap.elementJson !== null) {
|
|
12684
13709
|
await fs.writeFile(elementJsonPath(root), snap.elementJson);
|
|
12685
13710
|
}
|
|
12686
|
-
const
|
|
13711
|
+
const srPath = srFilePath(root, snap.srName);
|
|
12687
13712
|
if (snap.srJson !== null) {
|
|
12688
|
-
await fs.writeFile(
|
|
12689
|
-
} else if (await fs.exists(
|
|
12690
|
-
await fs.rm(
|
|
13713
|
+
await fs.writeFile(srPath, snap.srJson);
|
|
13714
|
+
} else if (await fs.exists(srPath)) {
|
|
13715
|
+
await fs.rm(srPath);
|
|
12691
13716
|
}
|
|
12692
13717
|
}
|
|
12693
13718
|
async function locateEntry(connectorRoot, resource, method) {
|
|
@@ -15985,7 +17010,7 @@ async function runConfigureAuth(args, root, initial) {
|
|
|
15985
17010
|
}
|
|
15986
17011
|
}
|
|
15987
17012
|
for (const h of args.authHeaders ?? []) {
|
|
15988
|
-
const
|
|
17013
|
+
const proposed = cfg(h.configName, h.configName, {
|
|
15989
17014
|
configType: h.secret ? "PASSWORD" : "TEXTFIELD_128",
|
|
15990
17015
|
required: true,
|
|
15991
17016
|
encrypt: h.secret,
|
|
@@ -15995,17 +17020,17 @@ async function runConfigureAuth(args, root, initial) {
|
|
|
15995
17020
|
});
|
|
15996
17021
|
const existingHeaderCfg = findConfigByKey(element, h.configName);
|
|
15997
17022
|
if (!existingHeaderCfg) {
|
|
15998
|
-
upsertConfig(element,
|
|
17023
|
+
upsertConfig(element, proposed);
|
|
15999
17024
|
added.push(h.configName);
|
|
16000
17025
|
} else {
|
|
16001
|
-
const diff = diffConfigEntries(existingHeaderCfg,
|
|
17026
|
+
const diff = diffConfigEntries(existingHeaderCfg, proposed);
|
|
16002
17027
|
if (Object.keys(diff).length === 0) {
|
|
16003
17028
|
unchanged.push(h.configName);
|
|
16004
17029
|
} else if (args.forceUpdateExisting) {
|
|
16005
|
-
upsertConfig(element,
|
|
17030
|
+
upsertConfig(element, proposed);
|
|
16006
17031
|
updated.push({
|
|
16007
17032
|
key: h.configName,
|
|
16008
|
-
diff: redactConfigDiff(diff, isSecretConfigEntry(existingHeaderCfg) || isSecretConfigEntry(
|
|
17033
|
+
diff: redactConfigDiff(diff, isSecretConfigEntry(existingHeaderCfg) || isSecretConfigEntry(proposed))
|
|
16009
17034
|
});
|
|
16010
17035
|
} else {
|
|
16011
17036
|
return {
|
|
@@ -16018,7 +17043,7 @@ async function runConfigureAuth(args, root, initial) {
|
|
|
16018
17043
|
redactConfigConflict({
|
|
16019
17044
|
key: h.configName,
|
|
16020
17045
|
existing: existingHeaderCfg,
|
|
16021
|
-
proposed
|
|
17046
|
+
proposed,
|
|
16022
17047
|
diff
|
|
16023
17048
|
})
|
|
16024
17049
|
]
|
|
@@ -16856,9 +17881,9 @@ async function inspectConnector(connectorRoot) {
|
|
|
16856
17881
|
if (srData === null) {
|
|
16857
17882
|
continue;
|
|
16858
17883
|
}
|
|
16859
|
-
const
|
|
16860
|
-
if (
|
|
16861
|
-
srStrippedPathToFile[normalizeInternalPath(
|
|
17884
|
+
const srPath = stringOr(srData.path);
|
|
17885
|
+
if (srPath) {
|
|
17886
|
+
srStrippedPathToFile[normalizeInternalPath(srPath)] = f;
|
|
16862
17887
|
}
|
|
16863
17888
|
}
|
|
16864
17889
|
}
|
|
@@ -17590,7 +18615,7 @@ async function checkParamDrift(elem, root) {
|
|
|
17590
18615
|
return errors;
|
|
17591
18616
|
}
|
|
17592
18617
|
const srCache = new Map;
|
|
17593
|
-
const
|
|
18618
|
+
const loadSr = async (srName) => {
|
|
17594
18619
|
if (srCache.has(srName)) {
|
|
17595
18620
|
return srCache.get(srName) ?? null;
|
|
17596
18621
|
}
|
|
@@ -17612,7 +18637,7 @@ async function checkParamDrift(elem, root) {
|
|
|
17612
18637
|
if (!srName) {
|
|
17613
18638
|
continue;
|
|
17614
18639
|
}
|
|
17615
|
-
const sr = await
|
|
18640
|
+
const sr = await loadSr(srName);
|
|
17616
18641
|
if (!sr) {
|
|
17617
18642
|
continue;
|
|
17618
18643
|
}
|
|
@@ -17648,7 +18673,7 @@ async function checkSrLinkage(elem, root) {
|
|
|
17648
18673
|
return warnings;
|
|
17649
18674
|
}
|
|
17650
18675
|
const srCache = new Map;
|
|
17651
|
-
const
|
|
18676
|
+
const loadSr = async (srName) => {
|
|
17652
18677
|
if (srCache.has(srName)) {
|
|
17653
18678
|
return srCache.get(srName) ?? null;
|
|
17654
18679
|
}
|
|
@@ -17669,7 +18694,7 @@ async function checkSrLinkage(elem, root) {
|
|
|
17669
18694
|
if (!srName) {
|
|
17670
18695
|
continue;
|
|
17671
18696
|
}
|
|
17672
|
-
const sr = await
|
|
18697
|
+
const sr = await loadSr(srName);
|
|
17673
18698
|
if (!sr) {
|
|
17674
18699
|
continue;
|
|
17675
18700
|
}
|
|
@@ -17682,12 +18707,12 @@ async function checkSrLinkage(elem, root) {
|
|
|
17682
18707
|
const srTopPath = stringOr3(sr.path);
|
|
17683
18708
|
let linked = false;
|
|
17684
18709
|
for (const [srMKey, srMCfgRaw] of Object.entries(methodMeta)) {
|
|
17685
|
-
const
|
|
17686
|
-
const cfgMethod = stringOr3("method" in
|
|
18710
|
+
const cfg = asRecord2(srMCfgRaw);
|
|
18711
|
+
const cfgMethod = stringOr3("method" in cfg ? cfg.method : srMKey).toUpperCase();
|
|
17687
18712
|
if (cfgMethod !== resourceMethod) {
|
|
17688
18713
|
continue;
|
|
17689
18714
|
}
|
|
17690
|
-
const ref = stringOr3(
|
|
18715
|
+
const ref = stringOr3(cfg.reference) || stringOr3(cfg.path) || srTopPath;
|
|
17691
18716
|
if (normalizeInternalPath(ref) === normalizeInternalPath(resourcePath)) {
|
|
17692
18717
|
linked = true;
|
|
17693
18718
|
break;
|
|
@@ -17774,11 +18799,11 @@ async function checkFieldlessActivities(elem, root) {
|
|
|
17774
18799
|
continue;
|
|
17775
18800
|
}
|
|
17776
18801
|
checked.add(srName);
|
|
17777
|
-
const
|
|
17778
|
-
if (!await fs.exists(
|
|
18802
|
+
const srPath = fs.path.join(srDir, `${srName}.json`);
|
|
18803
|
+
if (!await fs.exists(srPath)) {
|
|
17779
18804
|
continue;
|
|
17780
18805
|
}
|
|
17781
|
-
const sr = await readJsonFile2(
|
|
18806
|
+
const sr = await readJsonFile2(srPath);
|
|
17782
18807
|
if (sr === null) {
|
|
17783
18808
|
continue;
|
|
17784
18809
|
}
|
|
@@ -18387,7 +19412,7 @@ async function setGlobalConfig(args) {
|
|
|
18387
19412
|
const parameters = getParameters(element);
|
|
18388
19413
|
const parametersAdded = [];
|
|
18389
19414
|
const parametersUpdated = [];
|
|
18390
|
-
const
|
|
19415
|
+
const upsertParam = (param) => {
|
|
18391
19416
|
const idx = parameters.findIndex((p) => p.vendorName === param.vendorName && p.vendorType === param.vendorType);
|
|
18392
19417
|
if (idx < 0) {
|
|
18393
19418
|
parameters.push(param);
|
|
@@ -18398,15 +19423,15 @@ async function setGlobalConfig(args) {
|
|
|
18398
19423
|
}
|
|
18399
19424
|
};
|
|
18400
19425
|
if (acceptType) {
|
|
18401
|
-
|
|
19426
|
+
upsertParam(buildGlobalParameter("Accept", "header", acceptType, "value", "The Accept header"));
|
|
18402
19427
|
}
|
|
18403
19428
|
if (contentType) {
|
|
18404
|
-
|
|
19429
|
+
upsertParam(buildGlobalParameter("Content-Type", "header", contentType, "value", "The Content-Type header"));
|
|
18405
19430
|
}
|
|
18406
19431
|
if (extraHeaders) {
|
|
18407
19432
|
for (const h of extraHeaders) {
|
|
18408
19433
|
if (h.vendorName) {
|
|
18409
|
-
|
|
19434
|
+
upsertParam(buildGlobalParameter(h.vendorName, "header", h.name ?? "", "value"));
|
|
18410
19435
|
}
|
|
18411
19436
|
}
|
|
18412
19437
|
}
|
|
@@ -19577,24 +20602,24 @@ function isObject(v) {
|
|
|
19577
20602
|
function asArray(v) {
|
|
19578
20603
|
return Array.isArray(v) ? v : [];
|
|
19579
20604
|
}
|
|
19580
|
-
function
|
|
20605
|
+
function err2(code, message, fixHint) {
|
|
19581
20606
|
return { ok: false, error: { code, message, fixHint } };
|
|
19582
20607
|
}
|
|
19583
20608
|
async function patchConnector(connectorRoot, pointer, value, op) {
|
|
19584
20609
|
if (op !== "upsert" && op !== "remove") {
|
|
19585
|
-
return
|
|
20610
|
+
return err2("invalidOp", `op must be 'upsert' or 'remove', got '${op}'.`, "Pass op: 'upsert' to write, or op: 'remove' to delete.");
|
|
19586
20611
|
}
|
|
19587
20612
|
let cp;
|
|
19588
20613
|
try {
|
|
19589
20614
|
cp = parsePointer(pointer);
|
|
19590
20615
|
} catch (e) {
|
|
19591
|
-
return
|
|
20616
|
+
return err2("invalidPointer", e instanceof Error ? e.message : String(e), "Use a valid pointer, e.g. 'element.json/configuration/base.url'.");
|
|
19592
20617
|
}
|
|
19593
20618
|
if (op === "upsert" && (value === null || value === undefined)) {
|
|
19594
|
-
return
|
|
20619
|
+
return err2("missingValue", "value is required for upsert operations.", "Pass the object/array/string to write.");
|
|
19595
20620
|
}
|
|
19596
20621
|
if (cp.pathType === PathType.RAW_FILE) {
|
|
19597
|
-
return
|
|
20622
|
+
return err2("readOnly", "Raw file paths are read-only.", "Use queryConnector to read raw files; edit them through a structured pointer.");
|
|
19598
20623
|
}
|
|
19599
20624
|
if (op === "remove") {
|
|
19600
20625
|
const removeErr = validateRemoveTarget(cp);
|
|
@@ -19603,7 +20628,7 @@ async function patchConnector(connectorRoot, pointer, value, op) {
|
|
|
19603
20628
|
}
|
|
19604
20629
|
}
|
|
19605
20630
|
if (isSummary(cp) && op === "upsert") {
|
|
19606
|
-
return
|
|
20631
|
+
return err2("notWritable", `Cannot write to summary path '${pointer}'.`, "Navigate to a specific item (a key, method+path, field, or param).");
|
|
19607
20632
|
}
|
|
19608
20633
|
const snapshot = await captureSnapshot(connectorRoot, cp);
|
|
19609
20634
|
try {
|
|
@@ -19625,9 +20650,9 @@ async function patchConnector(connectorRoot, pointer, value, op) {
|
|
|
19625
20650
|
await restoreSnapshot(connectorRoot, cp, snapshot);
|
|
19626
20651
|
const message = e instanceof Error ? e.message : String(e);
|
|
19627
20652
|
if (/not found/i.test(message)) {
|
|
19628
|
-
return
|
|
20653
|
+
return err2("notFound", message, "Check the connector root and that the addressed file exists.");
|
|
19629
20654
|
}
|
|
19630
|
-
return
|
|
20655
|
+
return err2("unexpected", `Unexpected error writing ${pointer}: ${message}`, "Inspect the connector files; changes were rolled back.");
|
|
19631
20656
|
}
|
|
19632
20657
|
}
|
|
19633
20658
|
function srFilePath2(root, name) {
|
|
@@ -19680,41 +20705,41 @@ async function restoreSnapshot(root, _cp, snap) {
|
|
|
19680
20705
|
await fs.writeFile(elementPath, snap.elementJson);
|
|
19681
20706
|
}
|
|
19682
20707
|
for (const sr of snap.srs) {
|
|
19683
|
-
const
|
|
20708
|
+
const srPath = srFilePath2(root, sr.name);
|
|
19684
20709
|
if (sr.json !== null) {
|
|
19685
|
-
await fs.writeFile(
|
|
19686
|
-
} else if (await fs.exists(
|
|
19687
|
-
await fs.rm(
|
|
20710
|
+
await fs.writeFile(srPath, sr.json);
|
|
20711
|
+
} else if (await fs.exists(srPath)) {
|
|
20712
|
+
await fs.rm(srPath);
|
|
19688
20713
|
}
|
|
19689
20714
|
}
|
|
19690
20715
|
}
|
|
19691
20716
|
function validateRemoveTarget(cp) {
|
|
19692
20717
|
if (isSummary(cp)) {
|
|
19693
|
-
return
|
|
20718
|
+
return err2("notRemovable", "Cannot remove a summary.", "Navigate to a specific item to remove.");
|
|
19694
20719
|
}
|
|
19695
20720
|
if (cp.pathType === PathType.ELEMENT_JSON) {
|
|
19696
20721
|
if (cp.section === Section.WHOLE_FILE) {
|
|
19697
|
-
return
|
|
20722
|
+
return err2("notRemovable", "Cannot remove element.json.", "Replace it via an upsert at 'element.json' instead.");
|
|
19698
20723
|
}
|
|
19699
20724
|
if (cp.section === Section.AUTHENTICATION) {
|
|
19700
|
-
return
|
|
20725
|
+
return err2("notRemovable", "Cannot remove authentication section.", "Replace it via an upsert at 'element.json/authentication'.");
|
|
19701
20726
|
}
|
|
19702
20727
|
if (cp.section === Section.HOOKS && cp.hookType === null && cp.resourceMethod === null) {
|
|
19703
|
-
return
|
|
20728
|
+
return err2("notRemovable", "Cannot remove global hooks array.", "Replace it via an upsert at 'element.json/hooks'.");
|
|
19704
20729
|
}
|
|
19705
20730
|
if (cp.section === Section.PARAMETERS && cp.paramIndex === null && cp.resourceMethod === null) {
|
|
19706
|
-
return
|
|
20731
|
+
return err2("notRemovable", "Cannot remove global parameters array.", "Replace it via an upsert at 'element.json/parameters'.");
|
|
19707
20732
|
}
|
|
19708
20733
|
}
|
|
19709
20734
|
if (cp.pathType === PathType.ELEMENT_METADATA) {
|
|
19710
|
-
return
|
|
20735
|
+
return err2("notRemovable", "Cannot remove element-metadata.json.", "Replace it via an upsert at 'element-metadata.json'.");
|
|
19711
20736
|
}
|
|
19712
20737
|
if (cp.pathType === PathType.STANDARD_RESOURCES) {
|
|
19713
20738
|
if (cp.srName !== null && cp.section === Section.WHOLE_FILE) {
|
|
19714
|
-
return
|
|
20739
|
+
return err2("notRemovable", "Cannot remove a whole SR file via patch.", "Delete the file manually if you intend to drop the resource.");
|
|
19715
20740
|
}
|
|
19716
20741
|
if (cp.section === Section.METADATA && cp.metadataKey === null) {
|
|
19717
|
-
return
|
|
20742
|
+
return err2("notRemovable", "Cannot remove the entire metadata object.", "Replace it via an upsert, or remove individual metadata keys.");
|
|
19718
20743
|
}
|
|
19719
20744
|
}
|
|
19720
20745
|
return null;
|
|
@@ -19735,21 +20760,21 @@ async function routePatch(cp, root, value, op) {
|
|
|
19735
20760
|
if (cp.pathType === PathType.HOOKS) {
|
|
19736
20761
|
return patchHooks(cp, root, value, op);
|
|
19737
20762
|
}
|
|
19738
|
-
return
|
|
20763
|
+
return err2("unexpected", `Unhandled path type ${cp.pathType}`, "This is a bug — report the pointer that triggered it.");
|
|
19739
20764
|
}
|
|
19740
20765
|
async function patchElementJson(cp, root, value, op) {
|
|
19741
20766
|
const element = await readElementJson(root);
|
|
19742
20767
|
const warnings = [];
|
|
19743
20768
|
if (cp.section === Section.WHOLE_FILE) {
|
|
19744
20769
|
if (!isObject(value)) {
|
|
19745
|
-
return
|
|
20770
|
+
return err2("validation", "element.json must be an object.", "Pass the full element.json object as the value.");
|
|
19746
20771
|
}
|
|
19747
20772
|
const incomingKey = value.key;
|
|
19748
20773
|
const incomingName = value.name;
|
|
19749
20774
|
const hasKey = typeof incomingKey === "string" && incomingKey.trim() !== "";
|
|
19750
20775
|
const hasName = typeof incomingName === "string" && incomingName.trim() !== "";
|
|
19751
20776
|
if (!hasKey || !hasName) {
|
|
19752
|
-
return
|
|
20777
|
+
return err2("notWritable", "Refusing to replace element.json: a whole-file value must include a non-empty 'key' and 'name'. An empty or identity-less object would discard the connector definition.", "Edit a specific slice via its pointer (e.g. element.json/configuration/<key>), or pass the full element.json including its 'key' and 'name' as the value.");
|
|
19753
20778
|
}
|
|
19754
20779
|
await writeElementJson(root, value);
|
|
19755
20780
|
return ok("Replaced element.json.");
|
|
@@ -19777,7 +20802,7 @@ async function patchElementJson(cp, root, value, op) {
|
|
|
19777
20802
|
}
|
|
19778
20803
|
if (cp.section === Section.PARAMETERS) {
|
|
19779
20804
|
if (!Array.isArray(value)) {
|
|
19780
|
-
return
|
|
20805
|
+
return err2("validation", "element.json/parameters must be an array.", "Pass the full parameters array as the value.");
|
|
19781
20806
|
}
|
|
19782
20807
|
element.parameters = value;
|
|
19783
20808
|
await writeElementJson(root, element);
|
|
@@ -19785,7 +20810,7 @@ async function patchElementJson(cp, root, value, op) {
|
|
|
19785
20810
|
}
|
|
19786
20811
|
if (cp.section === Section.HOOKS) {
|
|
19787
20812
|
if (!Array.isArray(value)) {
|
|
19788
|
-
return
|
|
20813
|
+
return err2("validation", "element.json/hooks must be an array.", "Pass the full hooks array as the value.");
|
|
19789
20814
|
}
|
|
19790
20815
|
element.hooks = value;
|
|
19791
20816
|
await writeElementJson(root, element);
|
|
@@ -19794,24 +20819,24 @@ async function patchElementJson(cp, root, value, op) {
|
|
|
19794
20819
|
}
|
|
19795
20820
|
if (cp.section === Section.AUTHENTICATION) {
|
|
19796
20821
|
if (!isObject(value)) {
|
|
19797
|
-
return
|
|
20822
|
+
return err2("validation", "element.json/authentication must be an object.", "Pass the authentication object as the value.");
|
|
19798
20823
|
}
|
|
19799
20824
|
element.authentication = value;
|
|
19800
20825
|
await writeElementJson(root, element);
|
|
19801
20826
|
return ok("Replaced element.json/authentication.");
|
|
19802
20827
|
}
|
|
19803
|
-
return
|
|
20828
|
+
return err2("unexpected", `Unhandled section ${cp.section}`, "This is a bug — report the pointer that triggered it.");
|
|
19804
20829
|
}
|
|
19805
20830
|
function patchConfiguration(cp, element, value, op, warnings) {
|
|
19806
20831
|
const key = cp.configKey;
|
|
19807
20832
|
if (key === null) {
|
|
19808
|
-
return
|
|
20833
|
+
return err2("notWritable", "Configuration writes require a specific key.", "Address a single config entry, e.g. 'element.json/configuration/base.url'.");
|
|
19809
20834
|
}
|
|
19810
20835
|
if (op === "remove") {
|
|
19811
20836
|
const config = getConfiguration(element);
|
|
19812
20837
|
const idx = config.findIndex((c) => c.key === key);
|
|
19813
20838
|
if (idx < 0) {
|
|
19814
|
-
return
|
|
20839
|
+
return err2("notFound", `Configuration key '${key}' not found.`, "List 'element.json/configuration' to see available keys.");
|
|
19815
20840
|
}
|
|
19816
20841
|
config.splice(idx, 1);
|
|
19817
20842
|
element.configuration = config;
|
|
@@ -19838,11 +20863,11 @@ function patchResource(cp, element, value, op, warnings) {
|
|
|
19838
20863
|
const resources = asArray(element.resources).filter(isObject);
|
|
19839
20864
|
if (cp.section === Section.RESOURCES && cp.paramIndex === null && cp.hookType === null) {
|
|
19840
20865
|
if (op === "remove") {
|
|
19841
|
-
const
|
|
19842
|
-
if (
|
|
19843
|
-
return
|
|
20866
|
+
const idx = resources.findIndex((r) => r.method === method && r.path === resPath);
|
|
20867
|
+
if (idx < 0) {
|
|
20868
|
+
return err2("notFound", `Resource ${method} ${resPath} not found.`, "List 'element.json/resources' to see available resources.");
|
|
19844
20869
|
}
|
|
19845
|
-
resources.splice(
|
|
20870
|
+
resources.splice(idx, 1);
|
|
19846
20871
|
element.resources = resources;
|
|
19847
20872
|
return ok(`Removed resource ${method} ${resPath}.`);
|
|
19848
20873
|
}
|
|
@@ -19864,14 +20889,14 @@ function patchResource(cp, element, value, op, warnings) {
|
|
|
19864
20889
|
}
|
|
19865
20890
|
const resource = resources.find((r) => r.method === method && r.path === resPath);
|
|
19866
20891
|
if (resource === undefined) {
|
|
19867
|
-
return
|
|
20892
|
+
return err2("notFound", `Resource ${method} ${resPath} not found.`, "Create the resource first, then address its parameters/hooks.");
|
|
19868
20893
|
}
|
|
19869
20894
|
if (cp.section === Section.PARAMETERS) {
|
|
19870
20895
|
const params = asArray(resource.parameters);
|
|
19871
20896
|
if (cp.paramIndex !== null) {
|
|
19872
20897
|
if (op === "remove") {
|
|
19873
20898
|
if (cp.paramIndex < 0 || cp.paramIndex >= params.length) {
|
|
19874
|
-
return
|
|
20899
|
+
return err2("notFound", `Parameter index ${cp.paramIndex} out of range (array has ${params.length} items).`, "Query the parameters array to find valid indexes.");
|
|
19875
20900
|
}
|
|
19876
20901
|
params.splice(cp.paramIndex, 1);
|
|
19877
20902
|
resource.parameters = params;
|
|
@@ -19882,17 +20907,17 @@ function patchResource(cp, element, value, op, warnings) {
|
|
|
19882
20907
|
return validationErr;
|
|
19883
20908
|
}
|
|
19884
20909
|
if (cp.paramIndex < 0 || cp.paramIndex >= params.length) {
|
|
19885
|
-
return
|
|
20910
|
+
return err2("notFound", `Parameter index ${cp.paramIndex} out of range (array has ${params.length} items). To append, write the whole parameters array.`, "Replace the whole parameters array to append a new parameter.");
|
|
19886
20911
|
}
|
|
19887
20912
|
params[cp.paramIndex] = value;
|
|
19888
20913
|
resource.parameters = params;
|
|
19889
20914
|
return ok(`Replaced parameter at index ${cp.paramIndex} on ${method} ${resPath}.`);
|
|
19890
20915
|
}
|
|
19891
20916
|
if (op === "remove") {
|
|
19892
|
-
return
|
|
20917
|
+
return err2("notRemovable", "Cannot remove the entire parameters array.", "Remove individual parameters by index, or replace the array.");
|
|
19893
20918
|
}
|
|
19894
20919
|
if (!Array.isArray(value)) {
|
|
19895
|
-
return
|
|
20920
|
+
return err2("validation", "Resource parameters must be an array.", "Pass the full parameters array as the value.");
|
|
19896
20921
|
}
|
|
19897
20922
|
resource.parameters = value;
|
|
19898
20923
|
return ok(`Replaced parameters array on ${method} ${resPath}.`);
|
|
@@ -19901,16 +20926,16 @@ function patchResource(cp, element, value, op, warnings) {
|
|
|
19901
20926
|
const hooks = asArray(resource.hooks);
|
|
19902
20927
|
if (cp.hookType !== null) {
|
|
19903
20928
|
if (op === "remove") {
|
|
19904
|
-
const
|
|
19905
|
-
if (
|
|
19906
|
-
return
|
|
20929
|
+
const idx = hooks.map((h) => isObject(h) ? h.type : undefined).indexOf(cp.hookType);
|
|
20930
|
+
if (idx < 0) {
|
|
20931
|
+
return err2("notFound", `Hook type '${cp.hookType}' not found on resource.`, "Query the resource hooks to see available types.");
|
|
19907
20932
|
}
|
|
19908
|
-
hooks.splice(
|
|
20933
|
+
hooks.splice(idx, 1);
|
|
19909
20934
|
resource.hooks = hooks;
|
|
19910
20935
|
return ok(`Removed hook '${cp.hookType}' from ${method} ${resPath}.`);
|
|
19911
20936
|
}
|
|
19912
20937
|
if (!isObject(value)) {
|
|
19913
|
-
return
|
|
20938
|
+
return err2("validation", "Resource hook must be an object.", "Pass the hook reference object as the value.");
|
|
19914
20939
|
}
|
|
19915
20940
|
const hookRef = value;
|
|
19916
20941
|
hookRef.type = cp.hookType;
|
|
@@ -19924,22 +20949,22 @@ function patchResource(cp, element, value, op, warnings) {
|
|
|
19924
20949
|
return ok(`Upserted hook '${cp.hookType}' on ${method} ${resPath}.`);
|
|
19925
20950
|
}
|
|
19926
20951
|
if (op === "remove") {
|
|
19927
|
-
return
|
|
20952
|
+
return err2("notRemovable", "Cannot remove the entire hooks array.", "Remove individual hooks by type, or replace the array.");
|
|
19928
20953
|
}
|
|
19929
20954
|
if (!Array.isArray(value)) {
|
|
19930
|
-
return
|
|
20955
|
+
return err2("validation", "Resource hooks must be an array.", "Pass the full hooks array as the value.");
|
|
19931
20956
|
}
|
|
19932
20957
|
resource.hooks = value;
|
|
19933
20958
|
return ok(`Replaced hooks array on ${method} ${resPath}.`);
|
|
19934
20959
|
}
|
|
19935
|
-
return
|
|
20960
|
+
return err2("unexpected", "Unhandled resource sub-path.", "This is a bug — report the pointer that triggered it.");
|
|
19936
20961
|
}
|
|
19937
20962
|
async function patchElementMetadata(root, value) {
|
|
19938
20963
|
if (!isObject(value)) {
|
|
19939
|
-
return
|
|
20964
|
+
return err2("validation", "element-metadata.json must be an object.", "Pass the full element-metadata.json object as the value.");
|
|
19940
20965
|
}
|
|
19941
20966
|
if (Object.keys(value).length === 0) {
|
|
19942
|
-
return
|
|
20967
|
+
return err2("notWritable", "Refusing to replace element-metadata.json with an empty object.", "Pass the full element-metadata.json object as the value (element-metadata.json has no addressable sub-paths). `state query element-metadata.json` returns the on-disk camelCase shape, safe to round-trip.");
|
|
19943
20968
|
}
|
|
19944
20969
|
const fs = getFileSystem();
|
|
19945
20970
|
const path = fs.path.join(root, "app", "element", "element-metadata.json");
|
|
@@ -19951,14 +20976,14 @@ async function patchStandardResources(cp, root, value, op) {
|
|
|
19951
20976
|
const warnings = [];
|
|
19952
20977
|
const srName = cp.srName;
|
|
19953
20978
|
if (srName === null) {
|
|
19954
|
-
return
|
|
20979
|
+
return err2("notWritable", "Cannot write to the standard-resources directory listing.", "Address a specific standard resource by name.");
|
|
19955
20980
|
}
|
|
19956
20981
|
if (cp.section === Section.WHOLE_FILE) {
|
|
19957
20982
|
if (!isObject(value)) {
|
|
19958
|
-
return
|
|
20983
|
+
return err2("validation", `standard-resources/${srName} must be an object.`, "Pass the full standard-resource object as the value.");
|
|
19959
20984
|
}
|
|
19960
20985
|
if (!("fields" in value) && !("metadata" in value)) {
|
|
19961
|
-
return
|
|
20986
|
+
return err2("notWritable", `Refusing to replace standard-resources/${srName}: a whole-file value must include 'fields' or 'metadata'. An empty or shapeless object would wipe the standard resource.`, "Edit a specific slice via its pointer (e.g. .../fields/<name> or .../metadata/method/<VERB>), or pass the full SR object including its 'fields'/'metadata'.");
|
|
19962
20987
|
}
|
|
19963
20988
|
await writeStandardResource(root, srName, value);
|
|
19964
20989
|
const synced = await syncAllMethodsInSr(root, srName);
|
|
@@ -19966,31 +20991,31 @@ async function patchStandardResources(cp, root, value, op) {
|
|
|
19966
20991
|
}
|
|
19967
20992
|
const srData = await readStandardResource(root, srName);
|
|
19968
20993
|
if (cp.section === Section.FIELDS && cp.fieldName !== null) {
|
|
19969
|
-
const
|
|
20994
|
+
const fieldName = cp.fieldName;
|
|
19970
20995
|
if (op === "remove") {
|
|
19971
|
-
removeSrField(srData,
|
|
20996
|
+
removeSrField(srData, fieldName);
|
|
19972
20997
|
await writeStandardResource(root, srName, srData);
|
|
19973
|
-
return ok(`Removed field '${
|
|
20998
|
+
return ok(`Removed field '${fieldName}' from ${srName}.`);
|
|
19974
20999
|
}
|
|
19975
|
-
const validationErr = validateFieldValue(value,
|
|
21000
|
+
const validationErr = validateFieldValue(value, fieldName, warnings);
|
|
19976
21001
|
if (validationErr !== null) {
|
|
19977
21002
|
return validationErr;
|
|
19978
21003
|
}
|
|
19979
21004
|
const obj = value;
|
|
19980
|
-
obj.name =
|
|
19981
|
-
upsertSrField(srData,
|
|
21005
|
+
obj.name = fieldName;
|
|
21006
|
+
upsertSrField(srData, fieldName, obj, true);
|
|
19982
21007
|
await writeStandardResource(root, srName, srData);
|
|
19983
|
-
return ok(`Upserted field '${
|
|
21008
|
+
return ok(`Upserted field '${fieldName}' in ${srName}.`, warnings);
|
|
19984
21009
|
}
|
|
19985
21010
|
if (cp.section === Section.METADATA) {
|
|
19986
21011
|
return patchSrMetadata(cp, root, srName, srData, value, op, warnings);
|
|
19987
21012
|
}
|
|
19988
|
-
return
|
|
21013
|
+
return err2("unexpected", `Unhandled SR section ${cp.section}`, "This is a bug — report the pointer that triggered it.");
|
|
19989
21014
|
}
|
|
19990
21015
|
async function patchSrMetadata(cp, root, srName, srData, value, op, warnings) {
|
|
19991
21016
|
if (cp.metadataKey === null) {
|
|
19992
21017
|
if (!isObject(value)) {
|
|
19993
|
-
return
|
|
21018
|
+
return err2("validation", `metadata in ${srName} must be an object.`, "Pass the full metadata object as the value.");
|
|
19994
21019
|
}
|
|
19995
21020
|
srData.metadata = value;
|
|
19996
21021
|
await writeStandardResource(root, srName, srData);
|
|
@@ -20004,29 +21029,29 @@ async function patchSrMetadata(cp, root, srName, srData, value, op, warnings) {
|
|
|
20004
21029
|
if (op === "remove") {
|
|
20005
21030
|
removeSrParamByName(srData, srMethod, srParamName);
|
|
20006
21031
|
await writeStandardResource(root, srName, srData);
|
|
20007
|
-
const
|
|
20008
|
-
return ok(`Removed parameter '${srParamName}' from ${srName} method ${srMethod}.`, warnings,
|
|
21032
|
+
const changed = await syncSrMethodFromElement(root, srName, srMethod);
|
|
21033
|
+
return ok(`Removed parameter '${srParamName}' from ${srName} method ${srMethod}.`, warnings, changed ? [`${srName}.json[${srMethod}]`] : []);
|
|
20009
21034
|
}
|
|
20010
21035
|
if (!isObject(value)) {
|
|
20011
|
-
return
|
|
21036
|
+
return err2("validation", "SR method parameter must be an object.", "Pass the parameter object as the value.");
|
|
20012
21037
|
}
|
|
20013
21038
|
if (!("type" in value)) {
|
|
20014
|
-
return
|
|
21039
|
+
return err2("validation", "SR method parameter requires 'type' field.", "Add a 'type' field to the parameter object.");
|
|
20015
21040
|
}
|
|
20016
21041
|
if (getSrMethodConfig(srData, srMethod) === null) {
|
|
20017
|
-
return
|
|
21042
|
+
return err2("notFound", `Method '${srMethod}' not found in ${srName} metadata.`, `Create the method config first via standard-resources/${srName}/metadata/method/${srMethod}.`);
|
|
20018
21043
|
}
|
|
20019
21044
|
const obj = value;
|
|
20020
21045
|
obj.name = srParamName;
|
|
20021
21046
|
upsertSrParamByName(srData, srMethod, obj);
|
|
20022
21047
|
await writeStandardResource(root, srName, srData);
|
|
20023
|
-
const
|
|
20024
|
-
return ok(`Upserted parameter '${srParamName}' in ${srName} method ${srMethod}.`, warnings,
|
|
21048
|
+
const changed = await syncSrMethodFromElement(root, srName, srMethod);
|
|
21049
|
+
return ok(`Upserted parameter '${srParamName}' in ${srName} method ${srMethod}.`, warnings, changed ? [`${srName}.json[${srMethod}]`] : []);
|
|
20025
21050
|
}
|
|
20026
21051
|
if (op === "remove") {
|
|
20027
21052
|
const methodMap = srData.metadata?.method ?? {};
|
|
20028
21053
|
if (!(srMethod in methodMap)) {
|
|
20029
|
-
return
|
|
21054
|
+
return err2("notFound", `Method '${srMethod}' not found in ${srName} metadata.`, `Query 'standard-resources/${srName}/metadata' to list methods.`);
|
|
20030
21055
|
}
|
|
20031
21056
|
delete methodMap[srMethod];
|
|
20032
21057
|
await writeStandardResource(root, srName, srData);
|
|
@@ -20041,7 +21066,7 @@ async function patchSrMetadata(cp, root, srName, srData, value, op, warnings) {
|
|
|
20041
21066
|
if (op === "remove") {
|
|
20042
21067
|
const metadata = srData.metadata ?? {};
|
|
20043
21068
|
if (!(metadataKey in metadata)) {
|
|
20044
|
-
return
|
|
21069
|
+
return err2("notFound", `Metadata key '${metadataKey}' not found in ${srName}.`, `Query 'standard-resources/${srName}/metadata' to list keys.`);
|
|
20045
21070
|
}
|
|
20046
21071
|
delete metadata[metadataKey];
|
|
20047
21072
|
await writeStandardResource(root, srName, srData);
|
|
@@ -20053,24 +21078,24 @@ async function patchSrMetadata(cp, root, srName, srData, value, op, warnings) {
|
|
|
20053
21078
|
}
|
|
20054
21079
|
async function patchHooks(cp, root, value, op) {
|
|
20055
21080
|
if (cp.hookFilename === null) {
|
|
20056
|
-
return
|
|
21081
|
+
return err2("notWritable", "Cannot write to the hooks directory listing.", "Address a specific hook file, e.g. 'hooks/my-hook.js'.");
|
|
20057
21082
|
}
|
|
20058
21083
|
const fs = getFileSystem();
|
|
20059
21084
|
const hooksDir = fs.path.join(root, "app", "element", "hooks");
|
|
20060
21085
|
const hookPath = fs.path.join(hooksDir, cp.hookFilename);
|
|
20061
21086
|
const rel = fs.path.relative(fs.path.resolve(hooksDir), fs.path.resolve(hookPath));
|
|
20062
21087
|
if (rel.startsWith("..") || fs.path.isAbsolute(rel)) {
|
|
20063
|
-
return
|
|
21088
|
+
return err2("pathEscape", "Hook path escapes hooks directory.", "Pass a hook filename relative to app/element/hooks.");
|
|
20064
21089
|
}
|
|
20065
21090
|
if (op === "remove") {
|
|
20066
21091
|
if (!await fs.exists(hookPath)) {
|
|
20067
|
-
return
|
|
21092
|
+
return err2("notFound", `Hook file not found: ${cp.hookFilename}`, "Query 'hooks' to list available hook files.");
|
|
20068
21093
|
}
|
|
20069
21094
|
await fs.rm(hookPath);
|
|
20070
21095
|
return ok(`Deleted hook file ${cp.hookFilename}. Warning: check element.json resource hooks for dangling refs to this file and remove them separately.`);
|
|
20071
21096
|
}
|
|
20072
21097
|
if (typeof value !== "string" || value.trim() === "") {
|
|
20073
|
-
return
|
|
21098
|
+
return err2("validation", "Hook file content must be a non-empty string.", "Pass the hook's JavaScript source as a non-empty string.");
|
|
20074
21099
|
}
|
|
20075
21100
|
await fs.mkdir(hooksDir);
|
|
20076
21101
|
await fs.writeFile(hookPath, value);
|
|
@@ -20078,13 +21103,13 @@ async function patchHooks(cp, root, value, op) {
|
|
|
20078
21103
|
}
|
|
20079
21104
|
function validateConfigValue(value, key, warnings) {
|
|
20080
21105
|
if (!isObject(value)) {
|
|
20081
|
-
return
|
|
21106
|
+
return err2("validation", "Configuration value must be an object.", "Pass a config-entry object with at least a 'type' field.");
|
|
20082
21107
|
}
|
|
20083
21108
|
if ("key" in value && value.key !== key) {
|
|
20084
21109
|
warnings.push(`Value key '${String(value.key)}' differs from path key '${key}' — path wins.`);
|
|
20085
21110
|
}
|
|
20086
21111
|
if (!("type" in value)) {
|
|
20087
|
-
return
|
|
21112
|
+
return err2("validation", "Configuration entry requires 'type' field.", "Add a 'type' field (e.g. 'PROPERTY', 'PASSWORD').");
|
|
20088
21113
|
}
|
|
20089
21114
|
if (!("name" in value)) {
|
|
20090
21115
|
warnings.push("Missing 'name' field on config entry.");
|
|
@@ -20093,7 +21118,7 @@ function validateConfigValue(value, key, warnings) {
|
|
|
20093
21118
|
}
|
|
20094
21119
|
function validateResourceValue(value, method, path, warnings) {
|
|
20095
21120
|
if (!isObject(value)) {
|
|
20096
|
-
return
|
|
21121
|
+
return err2("validation", "Resource value must be an object.", "Pass a resource object with method, path, and parameters.");
|
|
20097
21122
|
}
|
|
20098
21123
|
if ("method" in value && value.method !== method) {
|
|
20099
21124
|
warnings.push(`Value method '${String(value.method)}' differs from path method '${method}' — path wins.`);
|
|
@@ -20108,13 +21133,13 @@ function validateResourceValue(value, method, path, warnings) {
|
|
|
20108
21133
|
}
|
|
20109
21134
|
function validateParameterValue(value, warnings) {
|
|
20110
21135
|
if (!isObject(value)) {
|
|
20111
|
-
return
|
|
21136
|
+
return err2("validation", "Parameter value must be an object.", "Pass a parameter object with 'name' and 'type'.");
|
|
20112
21137
|
}
|
|
20113
21138
|
if (!("name" in value)) {
|
|
20114
|
-
return
|
|
21139
|
+
return err2("validation", "Parameter requires 'name' field.", "Add a 'name' field to the parameter object.");
|
|
20115
21140
|
}
|
|
20116
21141
|
if (!("type" in value)) {
|
|
20117
|
-
return
|
|
21142
|
+
return err2("validation", "Parameter requires 'type' field.", "Add a 'type' field to the parameter object.");
|
|
20118
21143
|
}
|
|
20119
21144
|
if (!("vendorType" in value)) {
|
|
20120
21145
|
warnings.push("Missing 'vendorType' on parameter.");
|
|
@@ -20126,10 +21151,10 @@ function validateParameterValue(value, warnings) {
|
|
|
20126
21151
|
}
|
|
20127
21152
|
function validateFieldValue(value, _fieldName, warnings) {
|
|
20128
21153
|
if (!isObject(value)) {
|
|
20129
|
-
return
|
|
21154
|
+
return err2("validation", "Field value must be an object.", "Pass a field object with at least a 'type' field.");
|
|
20130
21155
|
}
|
|
20131
21156
|
if (!("type" in value)) {
|
|
20132
|
-
return
|
|
21157
|
+
return err2("validation", "Field requires 'type' field.", "Add a 'type' field to the field object.");
|
|
20133
21158
|
}
|
|
20134
21159
|
if (!("vendorPath" in value)) {
|
|
20135
21160
|
warnings.push("Missing 'vendorPath' on field.");
|
|
@@ -21244,17 +22269,17 @@ function registerConnectorLifecycleCommands(connectors) {
|
|
|
21244
22269
|
])).argument("<connector-key>", "Exact design connector key (e.g. design-myorg-acmewidgets).").option("--connector-dir <path>", "Target directory for the unpacked source (defaults to the current directory).").addOption(new Option("--path <dir>").hideHelp()).option("--tenant <tenant>", "Override the tenant for the API calls.").examples(DOWNLOAD_EXAMPLES).trackedAction(processContext, async (key, options) => {
|
|
21245
22270
|
const connectorDir = options.connectorDir ?? options.path;
|
|
21246
22271
|
const clientOptions = options.tenant ? { tenant: options.tenant } : undefined;
|
|
21247
|
-
const [
|
|
22272
|
+
const [err, result] = await catchError(getConnector(clientOptions, {
|
|
21248
22273
|
key,
|
|
21249
22274
|
include: "files",
|
|
21250
22275
|
path: connectorDir,
|
|
21251
22276
|
tenant: options.tenant
|
|
21252
22277
|
}));
|
|
21253
|
-
if (
|
|
22278
|
+
if (err) {
|
|
21254
22279
|
OutputFormatter.error({
|
|
21255
22280
|
Result: RESULTS.Failure,
|
|
21256
22281
|
Message: "Connector download failed",
|
|
21257
|
-
Instructions:
|
|
22282
|
+
Instructions: err.message
|
|
21258
22283
|
});
|
|
21259
22284
|
processContext.exit(1);
|
|
21260
22285
|
return;
|
|
@@ -21647,7 +22672,7 @@ var registerConnectorsCommand = (program) => {
|
|
|
21647
22672
|
OutputFormatter.success({
|
|
21648
22673
|
Result: RESULTS.Success,
|
|
21649
22674
|
Code: "Connector",
|
|
21650
|
-
Data: [formatConnectorDetail(connector)]
|
|
22675
|
+
Data: [formatConnectorDetail({ ...connector })]
|
|
21651
22676
|
});
|
|
21652
22677
|
});
|
|
21653
22678
|
connectors.command("metadata").description("Get connector discovery metadata by key").argument("<connector-key>", "Connector key (e.g., uipath-zoho-desk)").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).examples(CONNECTORS_METADATA_EXAMPLES).trackedAction(processContext, async (connectorKey, options) => {
|
|
@@ -21896,13 +22921,13 @@ function parseQueryParams(queryString) {
|
|
|
21896
22921
|
if (trimmed.startsWith("{")) {
|
|
21897
22922
|
const [error, parsed] = catchError(() => JSON.parse(trimmed));
|
|
21898
22923
|
if (!error && parsed && typeof parsed === "object") {
|
|
21899
|
-
const
|
|
22924
|
+
const queryParams = {};
|
|
21900
22925
|
for (const [key, value] of Object.entries(parsed)) {
|
|
21901
22926
|
if (key && value !== undefined && value !== null) {
|
|
21902
|
-
|
|
22927
|
+
queryParams[key] = String(value);
|
|
21903
22928
|
}
|
|
21904
22929
|
}
|
|
21905
|
-
return Object.keys(
|
|
22930
|
+
return Object.keys(queryParams).length > 0 ? queryParams : undefined;
|
|
21906
22931
|
}
|
|
21907
22932
|
}
|
|
21908
22933
|
const queryParams = {};
|
|
@@ -22017,6 +23042,16 @@ function filterByOperation(resources, httpMethod) {
|
|
|
22017
23042
|
return false;
|
|
22018
23043
|
});
|
|
22019
23044
|
}
|
|
23045
|
+
function conflictingDesignActionsFailure(error) {
|
|
23046
|
+
const choices = error.requirements.length > 0 ? error.requirements.map(({ name, refFieldNames }) => `'${name}' needs ${refFieldNames.length > 0 ? refFieldNames.map((field) => `'${field}'`).join(" and ") : "no fields"}`).join("; ") : error.actionNames.map((name) => `'${name}'`).join(", ");
|
|
23047
|
+
return {
|
|
23048
|
+
Result: RESULTS.Failure,
|
|
23049
|
+
ErrorCode: "invalid_argument",
|
|
23050
|
+
Retry: "RetryWillNotFix",
|
|
23051
|
+
Message: error.message,
|
|
23052
|
+
Instructions: `Pass --action <name> to choose one: ${choices}. If actions use different fields, put the deciding -f field last.`
|
|
23053
|
+
};
|
|
23054
|
+
}
|
|
22020
23055
|
function parseFieldOptions(values) {
|
|
22021
23056
|
const result = {};
|
|
22022
23057
|
for (const raw of values) {
|
|
@@ -22025,8 +23060,8 @@ function parseFieldOptions(values) {
|
|
|
22025
23060
|
throw new Error(`Invalid --field value '${raw}'. Expected format 'name=value'.`);
|
|
22026
23061
|
}
|
|
22027
23062
|
const key = raw.substring(0, eqIndex);
|
|
22028
|
-
|
|
22029
|
-
result[key] =
|
|
23063
|
+
delete result[key];
|
|
23064
|
+
result[key] = raw.substring(eqIndex + 1);
|
|
22030
23065
|
}
|
|
22031
23066
|
return result;
|
|
22032
23067
|
}
|
|
@@ -22207,10 +23242,10 @@ async function resolveSolutionResources(solutionFolder, bindings, { tenant } = {
|
|
|
22207
23242
|
};
|
|
22208
23243
|
}
|
|
22209
23244
|
const solutionDir = await resolveSolutionDir(solutionFolder);
|
|
22210
|
-
const { getSolutionAuthContext } = await import("./solution-auth-
|
|
23245
|
+
const { getSolutionAuthContext } = await import("./solution-auth-w6edcwxb.js");
|
|
22211
23246
|
const session = await getSolutionAuthContext({});
|
|
22212
23247
|
assertSessionTenant(tenant, session.tenantName);
|
|
22213
|
-
const engine = await import("./index-
|
|
23248
|
+
const engine = await import("./index-jc6qcbca.js");
|
|
22214
23249
|
const services = await engine.createResourceBuilderServices();
|
|
22215
23250
|
const builder = solutionDir ? await services.getSolutionBuilder(solutionDir, true) : undefined;
|
|
22216
23251
|
const ctx = { engine, services, builder, solutionDir };
|
|
@@ -22585,7 +23620,7 @@ function validateOperationOption(operation) {
|
|
|
22585
23620
|
reportInvalidOperation(operation);
|
|
22586
23621
|
return false;
|
|
22587
23622
|
}
|
|
22588
|
-
function emitResourceMetadata(metadata, operation, warning) {
|
|
23623
|
+
function emitResourceMetadata(metadata, operation, warning, designAction) {
|
|
22589
23624
|
const summary = buildResourceCompactSummary(metadata, operation);
|
|
22590
23625
|
const summaryError = summary.error;
|
|
22591
23626
|
if (typeof summaryError === "string") {
|
|
@@ -22600,7 +23635,7 @@ function emitResourceMetadata(metadata, operation, warning) {
|
|
|
22600
23635
|
OutputFormatter.success({
|
|
22601
23636
|
Result: RESULTS.Success,
|
|
22602
23637
|
Code: "ResourceMetadata",
|
|
22603
|
-
Data: summary,
|
|
23638
|
+
Data: designAction ? { ...summary, designAction } : summary,
|
|
22604
23639
|
...warning ? { Warning: warning } : {}
|
|
22605
23640
|
});
|
|
22606
23641
|
}
|
|
@@ -22642,6 +23677,17 @@ function validateConnectionId2(options) {
|
|
|
22642
23677
|
}
|
|
22643
23678
|
return true;
|
|
22644
23679
|
}
|
|
23680
|
+
var CONNECTION_AUTH_STATUSES = new Set([401, 403]);
|
|
23681
|
+
var NON_IDEMPOTENT_METHODS = new Set(["POST", "PATCH"]);
|
|
23682
|
+
function classifyRunFailure(status, httpMethod) {
|
|
23683
|
+
if (CONNECTION_AUTH_STATUSES.has(status))
|
|
23684
|
+
return;
|
|
23685
|
+
const classified = classifyHttpStatus(status);
|
|
23686
|
+
if (!NON_IDEMPOTENT_METHODS.has(httpMethod) || classified?.errorCode !== "server_error") {
|
|
23687
|
+
return classified;
|
|
23688
|
+
}
|
|
23689
|
+
return { ...classified, retry: "RetryWillNotFix" };
|
|
23690
|
+
}
|
|
22645
23691
|
async function handleExecuteAction(connectorKey, objectName, httpMethod, normalizedOperation, options, requiresBody) {
|
|
22646
23692
|
if (!validateConnectionId2(options))
|
|
22647
23693
|
return;
|
|
@@ -22689,27 +23735,30 @@ async function handleExecuteAction(connectorKey, objectName, httpMethod, normali
|
|
|
22689
23735
|
}
|
|
22690
23736
|
if (!result.ok) {
|
|
22691
23737
|
const message = typeof result.body === "string" ? result.body : JSON.stringify(result.body);
|
|
23738
|
+
const classified = classifyRunFailure(result.status, httpMethod);
|
|
22692
23739
|
OutputFormatter.error({
|
|
22693
23740
|
Result: RESULTS.Failure,
|
|
23741
|
+
ErrorCode: classified?.errorCode,
|
|
22694
23742
|
Message: `${result.status} ${result.statusText}`,
|
|
22695
|
-
Instructions: message
|
|
23743
|
+
Instructions: message,
|
|
23744
|
+
Retry: classified?.retry
|
|
22696
23745
|
});
|
|
22697
23746
|
processContext.exit(1);
|
|
22698
23747
|
return;
|
|
22699
23748
|
}
|
|
22700
|
-
const
|
|
22701
|
-
if (
|
|
23749
|
+
const isListOperation = normalizedOperation === "GET";
|
|
23750
|
+
if (isListOperation) {
|
|
22702
23751
|
const data = {
|
|
22703
23752
|
items: result.body
|
|
22704
23753
|
};
|
|
22705
23754
|
const headers = result.headers ?? {};
|
|
22706
23755
|
const hasMore = Object.entries(headers).find(([key]) => key.toLowerCase() === "elements-has-more");
|
|
22707
23756
|
const nextPageTokenEntry = Object.entries(headers).find(([key]) => key.toLowerCase() === "elements-next-page-token");
|
|
22708
|
-
const
|
|
22709
|
-
if (hasMore ||
|
|
23757
|
+
const nextPageToken = nextPageTokenEntry && hasMoreElementsPages(nextPageTokenEntry[1]) ? nextPageTokenEntry[1] : undefined;
|
|
23758
|
+
if (hasMore || nextPageToken) {
|
|
22710
23759
|
data.Pagination = {
|
|
22711
23760
|
...hasMore && { HasMore: hasMore[1] },
|
|
22712
|
-
...
|
|
23761
|
+
...nextPageToken && { NextPageToken: nextPageToken }
|
|
22713
23762
|
};
|
|
22714
23763
|
}
|
|
22715
23764
|
OutputFormatter.success({
|
|
@@ -22867,7 +23916,7 @@ var registerResourcesCommand = (program) => {
|
|
|
22867
23916
|
})();
|
|
22868
23917
|
OutputFormatter.emitList("ResourceList", formatResourceList(filtered), { emptyInstructions, warning });
|
|
22869
23918
|
});
|
|
22870
|
-
resources.command("describe").description("Describe object fields and operations").argument("<connector-key>", "Connector key").argument("<object-name>", "Object name (the `objectName` from the activity's configuration JSON).").option("--connection-id <id>", "Connection/Instance ID").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("--operation <operation>", `Filter to a single operation (${VALID_OPERATIONS})`).option("--activity-version <version>", "Activity metadata version: 1.0.0 (default, v3 elements endpoints, connection-scoped) or 4.0.0 (v4 elements endpoints, not connection-scoped). Both are addressed by object name.").option("--refresh", "Force re-fetch from API, ignoring cache").option("-f, --field <name=value>", "Parent-field value (repeatable) — runs the api-type ObjectAction (e.g. Jira GenerateSchema, Salesforce GenerateQuerySchema) and merges its custom-field response into requestFields. Requires --connection-id and --operation. If the result comes back holding only the fields you supplied, the response carries a Warning: one of the values does not exist on the connection.", (value, prev = []) => [...prev, value], []).option("--action <name>", "Explicit api-type ObjectAction name (e.g. GenerateSchema). Optional — inferred from --field rules when omitted.").option("--solution-folder <path>", "Solution folder to look up solution-resource pickers in (default: current directory if it is a solution, else the tenant catalog)").examples(RESOURCES_DESCRIBE_EXAMPLES).trackedAction(processContext, async (connectorKey, objectName, options) => {
|
|
23919
|
+
resources.command("describe").description("Describe object fields and operations").argument("<connector-key>", "Connector key").argument("<object-name>", "Object name (the `objectName` from the activity's configuration JSON).").option("--connection-id <id>", "Connection/Instance ID").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("--operation <operation>", `Filter to a single operation (${VALID_OPERATIONS})`).option("--activity-version <version>", "Activity metadata version: 1.0.0 (default, v3 elements endpoints, connection-scoped) or 4.0.0 (v4 elements endpoints, not connection-scoped). Both are addressed by object name.").option("--refresh", "Force re-fetch from API, ignoring cache").option("-f, --field <name=value>", "Parent-field value (repeatable) — runs the api-type ObjectAction (e.g. Jira GenerateSchema, Salesforce GenerateQuerySchema) and merges its custom-field response into requestFields. Requires --connection-id and --operation. If the result comes back holding only the fields you supplied, the response carries a Warning: one of the values does not exist on the connection.", (value, prev = []) => [...prev, value], []).option("--action <name>", "Explicit api-type ObjectAction name (e.g. GenerateSchema). Optional — inferred from --field rules when omitted: of the actions the values satisfy, the one on the last -f field runs, and two on that field need --action.").option("--solution-folder <path>", "Solution folder to look up solution-resource pickers in (default: current directory if it is a solution, else the tenant catalog)").examples(RESOURCES_DESCRIBE_EXAMPLES).trackedAction(processContext, async (connectorKey, objectName, options) => {
|
|
22871
23920
|
if (options.activityVersion && !SUPPORTED_ACTIVITY_VERSIONS.includes(options.activityVersion)) {
|
|
22872
23921
|
OutputFormatter.error({
|
|
22873
23922
|
Result: RESULTS.Failure,
|
|
@@ -22997,14 +24046,22 @@ var registerResourcesCommand = (program) => {
|
|
|
22997
24046
|
}
|
|
22998
24047
|
let metadataRecord = metadata;
|
|
22999
24048
|
let parentOnlyWarning;
|
|
24049
|
+
let designAction;
|
|
23000
24050
|
if (hasFieldArgs && options.connectionId && options.operation) {
|
|
23001
24051
|
const httpMethod = OPERATION_TO_METHOD[options.operation.toUpperCase()] ?? options.operation.toUpperCase();
|
|
23002
|
-
const action = findApiAction(metadataRecord, httpMethod, fieldValues, options.action);
|
|
24052
|
+
const [matchError, action] = catchError(() => findApiAction(metadataRecord, httpMethod, fieldValues, options.action));
|
|
24053
|
+
if (matchError instanceof ConflictingDesignActionsError) {
|
|
24054
|
+
OutputFormatter.error(conflictingDesignActionsFailure(matchError));
|
|
24055
|
+
processContext.exit(1);
|
|
24056
|
+
return;
|
|
24057
|
+
}
|
|
24058
|
+
if (matchError)
|
|
24059
|
+
throw matchError;
|
|
23003
24060
|
if (!action) {
|
|
23004
24061
|
OutputFormatter.error({
|
|
23005
24062
|
Result: RESULTS.Failure,
|
|
23006
24063
|
Message: `No api-type ObjectAction matched [${Object.entries(fieldValues).map(([name, value]) => `${name}=${value}`).join(", ")}] on operation '${options.operation}'`,
|
|
23007
|
-
Instructions: "Check that the connector has a design-time action (objectActions[] or connectorMethodInfo.design.actions[]) whose rules name these fields. A rule can also limit the values it accepts, and an empty value counts as not filled in.
|
|
24064
|
+
Instructions: "Check that the connector has a design-time action (objectActions[] or connectorMethodInfo.design.actions[]) whose rules name these fields. A rule can also limit the values it accepts, and an empty value counts as not filled in."
|
|
23008
24065
|
});
|
|
23009
24066
|
processContext.exit(1);
|
|
23010
24067
|
return;
|
|
@@ -23034,6 +24091,7 @@ var registerResourcesCommand = (program) => {
|
|
|
23034
24091
|
processContext.exit(1);
|
|
23035
24092
|
return;
|
|
23036
24093
|
}
|
|
24094
|
+
designAction = action.name;
|
|
23037
24095
|
metadataRecord = applyDesignActionRemap(metadataRecord, actionResponse, httpMethod, action.onSuccess);
|
|
23038
24096
|
if (isParentOnlyResult(metadataRecord, httpMethod, Object.keys(fieldValues), action.onSuccess.input)) {
|
|
23039
24097
|
parentOnlyWarning = `The schema came back containing only the supplied fields [${Object.keys(fieldValues).join(", ")}], so '${action.name}' resolved nothing further. One of the values probably does not exist on this connection — check them against the lookups for those fields.`;
|
|
@@ -23041,7 +24099,7 @@ var registerResourcesCommand = (program) => {
|
|
|
23041
24099
|
} else {
|
|
23042
24100
|
await writeSchema(connectorKey, cacheConnectionId, resourceName, metadataRecord, options.tenant, cacheVersion);
|
|
23043
24101
|
}
|
|
23044
|
-
emitResourceMetadata(metadataRecord, operation?.name, parentOnlyWarning);
|
|
24102
|
+
emitResourceMetadata(metadataRecord, operation?.name, parentOnlyWarning, designAction);
|
|
23045
24103
|
});
|
|
23046
24104
|
const execute = resources.command("run").description("Run data operations on a connector, or an activity script against a connection");
|
|
23047
24105
|
addExecuteOptions(execute.command("create").description("Create a new record").argument("<connector-key>", "Connector key").argument("<object-name>", "Object name")).option("--body <json>", "Request body as JSON (required)").examples(RESOURCES_EXECUTE_CREATE_EXAMPLES).trackedAction(processContext, (c, o, opts) => handleExecuteAction(c, o, "POST", "POST", opts, true));
|
|
@@ -23072,7 +24130,7 @@ async function runTriggerDesignAction2(api, baseMetadata, input) {
|
|
|
23072
24130
|
const eventObject = await findEventObject(api, input);
|
|
23073
24131
|
const action = await findTriggerDesignAction(eventObject, input.fieldValues, input, input.actionName);
|
|
23074
24132
|
if (!action) {
|
|
23075
|
-
throw Object.assign(new Error(`No api-type design action of trigger object '${input.objectName}' matched fields [${Object.keys(input.fieldValues).join(", ")}]. Its actions and the fields each needs are under design.actions[] in 'uip is triggers objects ${input.connectorKey} ${input.operation} --connection-id ${input.connectionId}'
|
|
24133
|
+
throw Object.assign(new Error(`No api-type design action of trigger object '${input.objectName}' matched fields [${Object.keys(input.fieldValues).join(", ")}]. Its actions and the fields each needs are under design.actions[] in 'uip is triggers objects ${input.connectorKey} ${input.operation} --connection-id ${input.connectionId}'.`), { status: 400 });
|
|
23076
24134
|
}
|
|
23077
24135
|
const bindings = await planBindingsFromParameters(action, input.fieldValues, triggerEventParameters(eventObject));
|
|
23078
24136
|
const resolved = bindings.length > 0 ? await resolveSolutionResources(input.solutionFolder, bindings, {
|
|
@@ -23166,7 +24224,7 @@ var registerTriggersCommand = (program) => {
|
|
|
23166
24224
|
const cached = await readTriggerObjects(connectorKey, options.connectionId, normalizedOp, options.tenant);
|
|
23167
24225
|
if (cached) {
|
|
23168
24226
|
logger.info(`Loaded ${cached.length} trigger objects from cache`);
|
|
23169
|
-
OutputFormatter.emitList("TriggerObjectList", cached, {
|
|
24227
|
+
OutputFormatter.emitList("TriggerObjectList", asTriggerObjects(cached), {
|
|
23170
24228
|
warning: !options.connectionId ? "Results may not include custom objects. Use --connection-id for connection-specific data." : undefined
|
|
23171
24229
|
});
|
|
23172
24230
|
return;
|
|
@@ -23200,12 +24258,12 @@ var registerTriggersCommand = (program) => {
|
|
|
23200
24258
|
if (objectsList.length > 0 && options.connectionId) {
|
|
23201
24259
|
await writeTriggerObjects(connectorKey, options.connectionId, normalizedOp, objectsList, options.tenant);
|
|
23202
24260
|
}
|
|
23203
|
-
OutputFormatter.emitList("TriggerObjectList", objectsList, {
|
|
24261
|
+
OutputFormatter.emitList("TriggerObjectList", asTriggerObjects(objectsList), {
|
|
23204
24262
|
emptyInstructions: `No objects found for operation '${normalizedOp}' on '${connectorKey}'. Check the connector key and operation.`,
|
|
23205
24263
|
warning: !options.connectionId ? "Results may not include custom objects. Use --connection-id for connection-specific data." : undefined
|
|
23206
24264
|
});
|
|
23207
24265
|
});
|
|
23208
|
-
triggers.command("describe").description("Get metadata for a trigger object").argument("<connector-key>", "Connector key").argument("<operation>", "Trigger operation").argument("<object-name>", "Object name").option("--connection-id <id>", "Connection/Instance ID").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("--refresh", "Force re-fetch from API, ignoring cache").option("-f, --field <name=value>", "Field value the trigger's other fields depend on (repeatable), e.g. -f folderEntityName=Invoices. Requires --connection-id.", (value, prev = []) => [...prev, value], []).option("--action <name>", "Action that loads the fields, when more than one matches the --field values. Requires --field.").option("--solution-folder <path>", "Solution folder to look up solution-resource pickers in (default: current directory if it is a solution, else the tenant catalog)").examples(TRIGGERS_DESCRIBE_EXAMPLES).trackedAction(processContext, async (connectorKey, operation, objectName, options) => {
|
|
24266
|
+
triggers.command("describe").description("Get metadata for a trigger object").argument("<connector-key>", "Connector key").argument("<operation>", "Trigger operation").argument("<object-name>", "Object name").option("--connection-id <id>", "Connection/Instance ID").addOption(createHiddenDeprecatedTenantOption("-t, --tenant <tenant-name>")).option("--refresh", "Force re-fetch from API, ignoring cache").option("-f, --field <name=value>", "Field value the trigger's other fields depend on (repeatable), e.g. -f folderEntityName=Invoices. Requires --connection-id.", (value, prev = []) => [...prev, value], []).option("--action <name>", "Action that loads the fields, when more than one on the last -f field matches the --field values. Requires --field.").option("--solution-folder <path>", "Solution folder to look up solution-resource pickers in (default: current directory if it is a solution, else the tenant catalog)").examples(TRIGGERS_DESCRIBE_EXAMPLES).trackedAction(processContext, async (connectorKey, operation, objectName, options) => {
|
|
23209
24267
|
const normalizedOp = operation.toUpperCase();
|
|
23210
24268
|
logger.info(`Describing trigger: ${connectorKey}/${normalizedOp}/${objectName}`);
|
|
23211
24269
|
const fieldValues = parseDescribeFields(options);
|
|
@@ -23236,9 +24294,9 @@ var registerTriggersCommand = (program) => {
|
|
|
23236
24294
|
}
|
|
23237
24295
|
const [error, metadata] = await fetchTriggerMetadata(api, connectorKey, normalizedOp, objectName, options.connectionId);
|
|
23238
24296
|
if (error) {
|
|
23239
|
-
const { result
|
|
24297
|
+
const { result, errorCode, message, retry, context } = await extractErrorDetails(error);
|
|
23240
24298
|
OutputFormatter.error({
|
|
23241
|
-
Result:
|
|
24299
|
+
Result: result,
|
|
23242
24300
|
Message: `Error fetching trigger metadata for '${objectName}'`,
|
|
23243
24301
|
Instructions: message,
|
|
23244
24302
|
ErrorCode: errorCode,
|
|
@@ -23258,6 +24316,7 @@ var registerTriggersCommand = (program) => {
|
|
|
23258
24316
|
return;
|
|
23259
24317
|
}
|
|
23260
24318
|
let described = metadata;
|
|
24319
|
+
let designAction;
|
|
23261
24320
|
if (hasFields && options.connectionId) {
|
|
23262
24321
|
const merged = await describeWithFields(api, described, {
|
|
23263
24322
|
connectorKey,
|
|
@@ -23271,14 +24330,18 @@ var registerTriggersCommand = (program) => {
|
|
|
23271
24330
|
});
|
|
23272
24331
|
if (!merged)
|
|
23273
24332
|
return;
|
|
23274
|
-
described = merged;
|
|
24333
|
+
described = merged.metadata;
|
|
24334
|
+
designAction = merged.action;
|
|
23275
24335
|
} else if (options.connectionId) {
|
|
23276
24336
|
await writeTriggerMetadata(connectorKey, options.connectionId, normalizedOp, objectName, metadata, options.tenant);
|
|
23277
24337
|
}
|
|
23278
24338
|
const result = {
|
|
23279
24339
|
Result: RESULTS.Success,
|
|
23280
24340
|
Code: "TriggerMetadata",
|
|
23281
|
-
Data:
|
|
24341
|
+
Data: {
|
|
24342
|
+
...buildTriggerCompactSummary(described, normalizedOp),
|
|
24343
|
+
...designAction ? { designAction } : {}
|
|
24344
|
+
}
|
|
23282
24345
|
};
|
|
23283
24346
|
if (!options.connectionId) {
|
|
23284
24347
|
result.Warning = "Results may not include custom fields. Use --connection-id for connection-specific metadata.";
|
|
@@ -23289,6 +24352,9 @@ var registerTriggersCommand = (program) => {
|
|
|
23289
24352
|
OutputFormatter.success(result);
|
|
23290
24353
|
});
|
|
23291
24354
|
};
|
|
24355
|
+
function asTriggerObjects(list) {
|
|
24356
|
+
return list.filter((item) => typeof item === "object" && item !== null);
|
|
24357
|
+
}
|
|
23292
24358
|
function parseDescribeFields(options) {
|
|
23293
24359
|
const fieldArgs = options.field ?? [];
|
|
23294
24360
|
if (fieldArgs.length === 0) {
|
|
@@ -23333,26 +24399,26 @@ function parseDescribeFields(options) {
|
|
|
23333
24399
|
async function describeWithFields(api, base, input) {
|
|
23334
24400
|
const [error, described] = await catchError(runTriggerDesignAction2(api, base, input));
|
|
23335
24401
|
if (error) {
|
|
23336
|
-
OutputFormatter.error(await solutionResourceFailure(`Failed to run the design action of trigger object '${input.objectName}'`, error));
|
|
24402
|
+
OutputFormatter.error(error instanceof ConflictingDesignActionsError ? conflictingDesignActionsFailure(error) : await solutionResourceFailure(`Failed to run the design action of trigger object '${input.objectName}'`, error));
|
|
23337
24403
|
processContext.exit(1);
|
|
23338
24404
|
return;
|
|
23339
24405
|
}
|
|
23340
24406
|
logger.info(`Ran design action '${described.action.name}' (${described.action.method} ${described.action.url})`);
|
|
23341
|
-
return described.metadata;
|
|
24407
|
+
return { metadata: described.metadata, action: described.action.name };
|
|
23342
24408
|
}
|
|
23343
24409
|
|
|
23344
24410
|
// src/helpers/typecache.ts
|
|
23345
|
-
async function
|
|
23346
|
-
const
|
|
23347
|
-
|
|
23348
|
-
|
|
23349
|
-
}
|
|
24411
|
+
async function getTypecacheAuth(tenant) {
|
|
24412
|
+
const auth = await getAuthContext({
|
|
24413
|
+
requireOrganizationId: true,
|
|
24414
|
+
requireTenantId: true
|
|
24415
|
+
});
|
|
23350
24416
|
const tenantId = await resolveTenantId(tenant);
|
|
23351
24417
|
return {
|
|
23352
|
-
baseUrl:
|
|
23353
|
-
organizationId:
|
|
24418
|
+
baseUrl: auth.baseUrl,
|
|
24419
|
+
organizationId: auth.organizationId,
|
|
23354
24420
|
tenantId,
|
|
23355
|
-
accessToken:
|
|
24421
|
+
accessToken: auth.accessToken
|
|
23356
24422
|
};
|
|
23357
24423
|
}
|
|
23358
24424
|
function commonParams(projectType) {
|
|
@@ -23374,11 +24440,11 @@ function buildPackagesUrl(ctx, projectType) {
|
|
|
23374
24440
|
["useLatestPackages", "true"],
|
|
23375
24441
|
...commonParams(projectType)
|
|
23376
24442
|
]);
|
|
23377
|
-
return `${ctx.baseUrl}/${ctx.organizationId}/studio_/typecache/api/Packages?${params}`;
|
|
24443
|
+
return `${ctx.baseUrl}/${encodeURIComponent(ctx.organizationId)}/studio_/typecache/api/Packages?${params}`;
|
|
23378
24444
|
}
|
|
23379
24445
|
function buildActivitiesUrl(ctx, packageId, projectType) {
|
|
23380
24446
|
const params = new URLSearchParams(commonParams(projectType));
|
|
23381
|
-
return `${ctx.baseUrl}/${ctx.organizationId}/studio_/typecache/api/Activities/Package/${packageId}?${params}`;
|
|
24447
|
+
return `${ctx.baseUrl}/${encodeURIComponent(ctx.organizationId)}/studio_/typecache/api/Activities/Package/${packageId}?${params}`;
|
|
23382
24448
|
}
|
|
23383
24449
|
function buildHeaders(ctx) {
|
|
23384
24450
|
return {
|
|
@@ -23390,7 +24456,7 @@ function buildHeaders(ctx) {
|
|
|
23390
24456
|
};
|
|
23391
24457
|
}
|
|
23392
24458
|
async function fetchTypecachePackages(projectType, tenant) {
|
|
23393
|
-
const ctx = await
|
|
24459
|
+
const ctx = await getTypecacheAuth(tenant);
|
|
23394
24460
|
const response = await fetch(buildPackagesUrl(ctx, projectType), {
|
|
23395
24461
|
headers: buildHeaders(ctx)
|
|
23396
24462
|
});
|
|
@@ -23405,7 +24471,7 @@ async function fetchTypecachePackages(projectType, tenant) {
|
|
|
23405
24471
|
}));
|
|
23406
24472
|
}
|
|
23407
24473
|
async function fetchTypecacheActivities(packageId, projectType, tenant) {
|
|
23408
|
-
const ctx = await
|
|
24474
|
+
const ctx = await getTypecacheAuth(tenant);
|
|
23409
24475
|
const response = await fetch(buildActivitiesUrl(ctx, packageId, projectType), { headers: buildHeaders(ctx) });
|
|
23410
24476
|
if (!response.ok) {
|
|
23411
24477
|
throw new Error(`Typecache activities fetch failed: ${response.status} ${response.statusText}`);
|
|
@@ -23520,7 +24586,7 @@ var registerTypecacheCommand = (program) => {
|
|
|
23520
24586
|
packages = await readTypecachePackages(options.projectType, options.tenant);
|
|
23521
24587
|
}
|
|
23522
24588
|
if (!packages) {
|
|
23523
|
-
const [connErr,
|
|
24589
|
+
const [connErr, fetched] = await catchError(fetchTypecachePackages(options.projectType, options.tenant));
|
|
23524
24590
|
if (connErr) {
|
|
23525
24591
|
OutputFormatter.error({
|
|
23526
24592
|
Result: RESULTS.Failure,
|
|
@@ -23530,7 +24596,7 @@ var registerTypecacheCommand = (program) => {
|
|
|
23530
24596
|
processContext.exit(1);
|
|
23531
24597
|
return;
|
|
23532
24598
|
}
|
|
23533
|
-
packages =
|
|
24599
|
+
packages = fetched;
|
|
23534
24600
|
if (packages.length > 0)
|
|
23535
24601
|
await writeTypecachePackages(options.projectType, packages, options.tenant);
|
|
23536
24602
|
}
|
|
@@ -23575,30 +24641,65 @@ var WEBHOOKS_CONFIG_EXAMPLES = [
|
|
|
23575
24641
|
}
|
|
23576
24642
|
}
|
|
23577
24643
|
];
|
|
24644
|
+
var CONNECTIONS_LIST_HINT = "uip is connections list <connector-key> --output json";
|
|
24645
|
+
var ELEMENT_INSTANCE_ID_PATTERN = /^[1-9]\d*$/;
|
|
24646
|
+
function failValidation(message, instructions) {
|
|
24647
|
+
OutputFormatter.error({
|
|
24648
|
+
Result: RESULTS.ValidationError,
|
|
24649
|
+
ErrorCode: "invalid_argument",
|
|
24650
|
+
Message: message,
|
|
24651
|
+
Instructions: instructions
|
|
24652
|
+
});
|
|
24653
|
+
processContext.exit(EXIT_CODES.ValidationError);
|
|
24654
|
+
return;
|
|
24655
|
+
}
|
|
23578
24656
|
function parseConnectionOptions(options) {
|
|
23579
|
-
|
|
23580
|
-
|
|
23581
|
-
|
|
23582
|
-
|
|
23583
|
-
|
|
23584
|
-
});
|
|
23585
|
-
|
|
23586
|
-
|
|
24657
|
+
const { connectionId, elementInstanceId: rawInstanceId } = options;
|
|
24658
|
+
if (connectionId === undefined && rawInstanceId === undefined) {
|
|
24659
|
+
return failValidation("Missing connection: pass --connection-id or --element-instance-id", `Get either value from '${CONNECTIONS_LIST_HINT}' (Id or ElementInstanceId field). One is enough; the CLI looks up the other.`);
|
|
24660
|
+
}
|
|
24661
|
+
if (connectionId !== undefined && connectionId.trim() === "") {
|
|
24662
|
+
return failValidation("Invalid connection-id: the value is empty", `Pass the connection's Id from '${CONNECTIONS_LIST_HINT}'.`);
|
|
24663
|
+
}
|
|
24664
|
+
if (rawInstanceId === undefined) {
|
|
24665
|
+
return { connectionId };
|
|
23587
24666
|
}
|
|
23588
|
-
|
|
23589
|
-
|
|
24667
|
+
const elementInstanceId = Number(rawInstanceId);
|
|
24668
|
+
if (!ELEMENT_INSTANCE_ID_PATTERN.test(rawInstanceId) || !Number.isSafeInteger(elementInstanceId)) {
|
|
24669
|
+
return failValidation(`Invalid element-instance-id: '${rawInstanceId}'`, `Element instance ID must be a positive whole number. Get it from '${CONNECTIONS_LIST_HINT}' (ElementInstanceId field).`);
|
|
23590
24670
|
}
|
|
23591
|
-
|
|
23592
|
-
|
|
24671
|
+
return { connectionId, elementInstanceId };
|
|
24672
|
+
}
|
|
24673
|
+
async function reportLookupFailure(connectorKey, error) {
|
|
24674
|
+
const instructions = `Check the id with '${CONNECTIONS_LIST_HINT}', or pass both --connection-id and --element-instance-id.`;
|
|
24675
|
+
if (isConnectionNotFoundError(error)) {
|
|
23593
24676
|
OutputFormatter.error({
|
|
23594
24677
|
Result: RESULTS.Failure,
|
|
23595
|
-
|
|
23596
|
-
|
|
24678
|
+
ErrorCode: "not_found",
|
|
24679
|
+
Retry: "RetryWillNotFix",
|
|
24680
|
+
Message: error.message,
|
|
24681
|
+
Instructions: instructions
|
|
23597
24682
|
});
|
|
23598
|
-
processContext.exit(
|
|
24683
|
+
processContext.exit(EXIT_CODES.Failure);
|
|
23599
24684
|
return;
|
|
23600
24685
|
}
|
|
23601
|
-
|
|
24686
|
+
const failure = await extractErrorDetails(error);
|
|
24687
|
+
OutputFormatter.error({
|
|
24688
|
+
Result: failure.result,
|
|
24689
|
+
ErrorCode: failure.errorCode,
|
|
24690
|
+
Retry: failure.retry,
|
|
24691
|
+
Message: `Error looking up the connection for '${connectorKey}': ${failure.message}`,
|
|
24692
|
+
Instructions: instructions,
|
|
24693
|
+
...failure.context ? { Context: failure.context } : {}
|
|
24694
|
+
});
|
|
24695
|
+
processContext.exit(EXIT_CODES[failure.result] ?? EXIT_CODES.Failure);
|
|
24696
|
+
}
|
|
24697
|
+
function connectorMatches(connectorKey, ids) {
|
|
24698
|
+
if (ids.connectorKey === undefined || ids.connectorKey.toLowerCase() === connectorKey.toLowerCase()) {
|
|
24699
|
+
return true;
|
|
24700
|
+
}
|
|
24701
|
+
failValidation(`Connection '${ids.connectionId}' belongs to connector '${ids.connectorKey}', not '${connectorKey}'`, `Pass '${ids.connectorKey}' as the connector key, or pick a '${connectorKey}' connection from '${CONNECTIONS_LIST_HINT}'.`);
|
|
24702
|
+
return false;
|
|
23602
24703
|
}
|
|
23603
24704
|
var registerWebhooksCommand = (program) => {
|
|
23604
24705
|
const webhooks = program.command("webhooks").description("Manage Integration Service webhook configuration for triggers");
|
|
@@ -23609,15 +24710,10 @@ var registerWebhooksCommand = (program) => {
|
|
|
23609
24710
|
}
|
|
23610
24711
|
const [resolveError, ids] = await catchError(resolveConnectionInstanceIds({ tenant: options.tenant }, requested));
|
|
23611
24712
|
if (resolveError) {
|
|
23612
|
-
|
|
23613
|
-
|
|
23614
|
-
|
|
23615
|
-
|
|
23616
|
-
Retry: failure.retry,
|
|
23617
|
-
Message: `Error looking up the connection for '${connectorKey}': ${failure.message}`,
|
|
23618
|
-
Instructions: "Check the id with 'uip is connections list <connector-key> --output json', or pass both --connection-id and --element-instance-id."
|
|
23619
|
-
});
|
|
23620
|
-
processContext.exit(EXIT_CODES[failure.result] ?? 1);
|
|
24713
|
+
await reportLookupFailure(connectorKey, resolveError);
|
|
24714
|
+
return;
|
|
24715
|
+
}
|
|
24716
|
+
if (!connectorMatches(connectorKey, ids)) {
|
|
23621
24717
|
return;
|
|
23622
24718
|
}
|
|
23623
24719
|
logger.info(`Fetching webhook config for ${connectorKey} (connection: ${ids.connectionId}, instance: ${ids.elementInstanceId})`);
|
|
@@ -23631,7 +24727,7 @@ var registerWebhooksCommand = (program) => {
|
|
|
23631
24727
|
processContext.exit(1);
|
|
23632
24728
|
return;
|
|
23633
24729
|
}
|
|
23634
|
-
|
|
24730
|
+
const output = {
|
|
23635
24731
|
Result: RESULTS.Success,
|
|
23636
24732
|
Code: "WebhookConfig",
|
|
23637
24733
|
Data: {
|
|
@@ -23641,18 +24737,19 @@ var registerWebhooksCommand = (program) => {
|
|
|
23641
24737
|
ElementInstanceId: ids.elementInstanceId
|
|
23642
24738
|
},
|
|
23643
24739
|
Hint: "Register this webhook URL in your external service's app settings. The trigger will not fire until the URL is registered."
|
|
23644
|
-
}
|
|
24740
|
+
};
|
|
24741
|
+
OutputFormatter.success(output);
|
|
23645
24742
|
});
|
|
23646
24743
|
};
|
|
23647
24744
|
|
|
23648
24745
|
// src/tool.ts
|
|
23649
|
-
var
|
|
24746
|
+
var metadata2 = {
|
|
23650
24747
|
name: "integrationservice-tool",
|
|
23651
24748
|
version: package_default.version,
|
|
23652
24749
|
description: "Manage Integration Service connectors, connections, triggers, and webhooks.",
|
|
23653
24750
|
commandPrefix: "is"
|
|
23654
24751
|
};
|
|
23655
|
-
var
|
|
24752
|
+
var registerCommands2 = async (program) => {
|
|
23656
24753
|
registerConnectorsCommand(program);
|
|
23657
24754
|
registerConnectionsCommand(program);
|
|
23658
24755
|
registerActivitiesCommand(program);
|
|
@@ -23662,6 +24759,6 @@ var registerCommands = async (program) => {
|
|
|
23662
24759
|
registerWebhooksCommand(program);
|
|
23663
24760
|
};
|
|
23664
24761
|
|
|
23665
|
-
export {
|
|
24762
|
+
export { metadata2, registerCommands2 };
|
|
23666
24763
|
|
|
23667
|
-
//# debugId=
|
|
24764
|
+
//# debugId=BAFB2396BDBC433664756E2164756E21
|