sf-plugin-data 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +589 -2
- package/bin/run.js +4 -0
- package/docs/artifact-format.md +527 -0
- package/docs/capabilities.md +1208 -0
- package/docs/git-workflow.md +160 -0
- package/docs/handover.md +10446 -0
- package/lib/api.d.ts +7 -0
- package/lib/api.js +7 -0
- package/lib/artifacts/code-fields.d.ts +49 -0
- package/lib/artifacts/code-fields.js +142 -0
- package/lib/artifacts/data-graph-document.d.ts +29 -0
- package/lib/artifacts/data-graph-document.js +52 -0
- package/lib/artifacts/data-space-field.d.ts +65 -0
- package/lib/artifacts/data-space-field.js +98 -0
- package/lib/artifacts/data-stream-document.d.ts +264 -0
- package/lib/artifacts/data-stream-document.js +680 -0
- package/lib/artifacts/data-transform-document.d.ts +152 -0
- package/lib/artifacts/data-transform-document.js +560 -0
- package/lib/artifacts/dependency-selection.d.ts +51 -0
- package/lib/artifacts/dependency-selection.js +154 -0
- package/lib/artifacts/dlo-document.d.ts +93 -0
- package/lib/artifacts/dlo-document.js +253 -0
- package/lib/artifacts/enum-case.d.ts +39 -0
- package/lib/artifacts/enum-case.js +67 -0
- package/lib/artifacts/git-deploy-selection.d.ts +68 -0
- package/lib/artifacts/git-deploy-selection.js +474 -0
- package/lib/artifacts/identity-resolution-document.d.ts +133 -0
- package/lib/artifacts/identity-resolution-document.js +625 -0
- package/lib/artifacts/mapping-document.d.ts +1 -0
- package/lib/artifacts/mapping-document.js +1 -0
- package/lib/artifacts/native-calculated-insight-document.d.ts +142 -0
- package/lib/artifacts/native-calculated-insight-document.js +321 -0
- package/lib/artifacts/native-data-graph-document.d.ts +124 -0
- package/lib/artifacts/native-data-graph-document.js +780 -0
- package/lib/artifacts/native-dmo-document.d.ts +151 -0
- package/lib/artifacts/native-dmo-document.js +313 -0
- package/lib/artifacts/native-mapping-document.d.ts +67 -0
- package/lib/artifacts/native-mapping-document.js +187 -0
- package/lib/artifacts/native-relationship-document.d.ts +76 -0
- package/lib/artifacts/native-relationship-document.js +232 -0
- package/lib/artifacts/path-selector.d.ts +55 -0
- package/lib/artifacts/path-selector.js +167 -0
- package/lib/artifacts/read-deploy-input.d.ts +239 -0
- package/lib/artifacts/read-deploy-input.js +1359 -0
- package/lib/artifacts/segment-document.d.ts +183 -0
- package/lib/artifacts/segment-document.js +570 -0
- package/lib/artifacts/verbatim-document.d.ts +203 -0
- package/lib/artifacts/verbatim-document.js +339 -0
- package/lib/artifacts/write-data-graph.d.ts +17 -0
- package/lib/artifacts/write-data-graph.js +162 -0
- package/lib/artifacts/write-data-stream.d.ts +11 -0
- package/lib/artifacts/write-data-stream.js +175 -0
- package/lib/artifacts/write-data-transform.d.ts +11 -0
- package/lib/artifacts/write-data-transform.js +180 -0
- package/lib/artifacts/write-dlo.d.ts +11 -0
- package/lib/artifacts/write-dlo.js +158 -0
- package/lib/artifacts/write-identity-resolution.d.ts +18 -0
- package/lib/artifacts/write-identity-resolution.js +165 -0
- package/lib/artifacts/write-mapping-definition.d.ts +17 -0
- package/lib/artifacts/write-mapping-definition.js +127 -0
- package/lib/artifacts/write-member-export.d.ts +88 -0
- package/lib/artifacts/write-member-export.js +199 -0
- package/lib/artifacts/write-native-calculated-insight.d.ts +21 -0
- package/lib/artifacts/write-native-calculated-insight.js +176 -0
- package/lib/artifacts/write-native-dmo.d.ts +11 -0
- package/lib/artifacts/write-native-dmo.js +158 -0
- package/lib/artifacts/write-native-mapping.d.ts +11 -0
- package/lib/artifacts/write-native-mapping.js +157 -0
- package/lib/artifacts/write-native-relationship.d.ts +11 -0
- package/lib/artifacts/write-native-relationship.js +157 -0
- package/lib/artifacts/write-segment.d.ts +26 -0
- package/lib/artifacts/write-segment.js +212 -0
- package/lib/commands/data360/delete.d.ts +280 -0
- package/lib/commands/data360/delete.js +2297 -0
- package/lib/commands/data360/deploy.d.ts +303 -0
- package/lib/commands/data360/deploy.js +2400 -0
- package/lib/commands/data360/publish.d.ts +93 -0
- package/lib/commands/data360/publish.js +292 -0
- package/lib/commands/data360/retrieve.d.ts +322 -0
- package/lib/commands/data360/retrieve.js +1963 -0
- package/lib/commands/data360/segment/members/export.d.ts +101 -0
- package/lib/commands/data360/segment/members/export.js +318 -0
- package/lib/errors/codes/calculated-insight.d.ts +2 -0
- package/lib/errors/codes/calculated-insight.js +25 -0
- package/lib/errors/codes/data-graph.d.ts +2 -0
- package/lib/errors/codes/data-graph.js +22 -0
- package/lib/errors/codes/data-stream.d.ts +2 -0
- package/lib/errors/codes/data-stream.js +70 -0
- package/lib/errors/codes/data-transform.d.ts +2 -0
- package/lib/errors/codes/data-transform.js +35 -0
- package/lib/errors/codes/dependency.d.ts +2 -0
- package/lib/errors/codes/dependency.js +11 -0
- package/lib/errors/codes/dlo.d.ts +2 -0
- package/lib/errors/codes/dlo.js +31 -0
- package/lib/errors/codes/dmo.d.ts +2 -0
- package/lib/errors/codes/dmo.js +28 -0
- package/lib/errors/codes/general.d.ts +2 -0
- package/lib/errors/codes/general.js +57 -0
- package/lib/errors/codes/identity-resolution.d.ts +2 -0
- package/lib/errors/codes/identity-resolution.js +24 -0
- package/lib/errors/codes/mapping.d.ts +2 -0
- package/lib/errors/codes/mapping.js +42 -0
- package/lib/errors/codes/relationship.d.ts +2 -0
- package/lib/errors/codes/relationship.js +21 -0
- package/lib/errors/codes/segment.d.ts +2 -0
- package/lib/errors/codes/segment.js +49 -0
- package/lib/errors/registry.d.ts +60 -0
- package/lib/errors/registry.js +123 -0
- package/lib/plugin.d.ts +5 -0
- package/lib/plugin.js +5 -0
- package/lib/services/acquire-retrieve-selection.d.ts +43 -0
- package/lib/services/acquire-retrieve-selection.js +145 -0
- package/lib/services/bind-identity-resolution-dependencies.d.ts +53 -0
- package/lib/services/bind-identity-resolution-dependencies.js +238 -0
- package/lib/services/bind-segment-dependencies.d.ts +49 -0
- package/lib/services/bind-segment-dependencies.js +115 -0
- package/lib/services/bounded-reads.d.ts +17 -0
- package/lib/services/bounded-reads.js +42 -0
- package/lib/services/calculated-insight-sql-checks.d.ts +33 -0
- package/lib/services/calculated-insight-sql-checks.js +193 -0
- package/lib/services/command-dlo.d.ts +48 -0
- package/lib/services/command-dlo.js +103 -0
- package/lib/services/command-native-data-graph.d.ts +54 -0
- package/lib/services/command-native-data-graph.js +485 -0
- package/lib/services/command-native-data-stream.d.ts +104 -0
- package/lib/services/command-native-data-stream.js +257 -0
- package/lib/services/command-native-dmo.d.ts +124 -0
- package/lib/services/command-native-dmo.js +338 -0
- package/lib/services/command-native-mapping.d.ts +65 -0
- package/lib/services/command-native-mapping.js +129 -0
- package/lib/services/command-native-relationship.d.ts +46 -0
- package/lib/services/command-native-relationship.js +103 -0
- package/lib/services/cross-dataspace-deploy.d.ts +111 -0
- package/lib/services/cross-dataspace-deploy.js +493 -0
- package/lib/services/cross-dataspace-rename.d.ts +74 -0
- package/lib/services/cross-dataspace-rename.js +1314 -0
- package/lib/services/cross-dataspace-sql.d.ts +109 -0
- package/lib/services/cross-dataspace-sql.js +1301 -0
- package/lib/services/cross-space-context.d.ts +23 -0
- package/lib/services/cross-space-context.js +36 -0
- package/lib/services/crud-plan.d.ts +137 -0
- package/lib/services/crud-plan.js +408 -0
- package/lib/services/data-space-check.d.ts +89 -0
- package/lib/services/data-space-check.js +162 -0
- package/lib/services/data-space-prefix.d.ts +77 -0
- package/lib/services/data-space-prefix.js +127 -0
- package/lib/services/data-transform-space.d.ts +31 -0
- package/lib/services/data-transform-space.js +79 -0
- package/lib/services/delete-calculated-insight.d.ts +44 -0
- package/lib/services/delete-calculated-insight.js +101 -0
- package/lib/services/delete-data-transform.d.ts +52 -0
- package/lib/services/delete-data-transform.js +222 -0
- package/lib/services/delete-dmo-field.d.ts +211 -0
- package/lib/services/delete-dmo-field.js +472 -0
- package/lib/services/delete-identity-resolution.d.ts +43 -0
- package/lib/services/delete-identity-resolution.js +295 -0
- package/lib/services/delete-segment.d.ts +42 -0
- package/lib/services/delete-segment.js +248 -0
- package/lib/services/deploy-result.d.ts +54 -0
- package/lib/services/deploy-result.js +60 -0
- package/lib/services/escaped-copy.d.ts +23 -0
- package/lib/services/escaped-copy.js +88 -0
- package/lib/services/execute-calculated-insight-deploy.d.ts +42 -0
- package/lib/services/execute-calculated-insight-deploy.js +96 -0
- package/lib/services/execute-data-transform-deploy.d.ts +56 -0
- package/lib/services/execute-data-transform-deploy.js +168 -0
- package/lib/services/execute-native-identity-resolution-deploy.d.ts +48 -0
- package/lib/services/execute-native-identity-resolution-deploy.js +360 -0
- package/lib/services/execute-segment-deploy.d.ts +45 -0
- package/lib/services/execute-segment-deploy.js +393 -0
- package/lib/services/local-file-removal.d.ts +36 -0
- package/lib/services/local-file-removal.js +103 -0
- package/lib/services/native-calculated-insight.d.ts +87 -0
- package/lib/services/native-calculated-insight.js +164 -0
- package/lib/services/native-crm-data-stream.d.ts +91 -0
- package/lib/services/native-crm-data-stream.js +272 -0
- package/lib/services/native-data-graph-context.d.ts +12 -0
- package/lib/services/native-data-graph-context.js +139 -0
- package/lib/services/native-data-graph-crd.d.ts +261 -0
- package/lib/services/native-data-graph-crd.js +866 -0
- package/lib/services/native-data-stream.d.ts +329 -0
- package/lib/services/native-data-stream.js +1830 -0
- package/lib/services/native-dlo.d.ts +163 -0
- package/lib/services/native-dlo.js +402 -0
- package/lib/services/native-dmo.d.ts +191 -0
- package/lib/services/native-dmo.js +614 -0
- package/lib/services/native-mapping.d.ts +255 -0
- package/lib/services/native-mapping.js +1226 -0
- package/lib/services/native-relationship.d.ts +132 -0
- package/lib/services/native-relationship.js +512 -0
- package/lib/services/operation-diagnostic.d.ts +83 -0
- package/lib/services/operation-diagnostic.js +272 -0
- package/lib/services/preflight-calculated-insight-deploy.d.ts +58 -0
- package/lib/services/preflight-calculated-insight-deploy.js +95 -0
- package/lib/services/preflight-data-transform-deploy.d.ts +33 -0
- package/lib/services/preflight-data-transform-deploy.js +104 -0
- package/lib/services/preflight-identity-resolution-deploy.d.ts +107 -0
- package/lib/services/preflight-identity-resolution-deploy.js +281 -0
- package/lib/services/preflight-segment-deploy.d.ts +31 -0
- package/lib/services/preflight-segment-deploy.js +109 -0
- package/lib/services/publish-calculated-insight.d.ts +40 -0
- package/lib/services/publish-calculated-insight.js +95 -0
- package/lib/services/publish-segment.d.ts +65 -0
- package/lib/services/publish-segment.js +194 -0
- package/lib/services/readback-pace.d.ts +16 -0
- package/lib/services/readback-pace.js +23 -0
- package/lib/services/retrieve-data-transform.d.ts +26 -0
- package/lib/services/retrieve-data-transform.js +65 -0
- package/lib/services/retrieve-identity-resolution.d.ts +40 -0
- package/lib/services/retrieve-identity-resolution.js +87 -0
- package/lib/services/retrieve-inventory.d.ts +32 -0
- package/lib/services/retrieve-inventory.js +151 -0
- package/lib/services/retrieve-segment.d.ts +120 -0
- package/lib/services/retrieve-segment.js +502 -0
- package/lib/services/segment-lookup.d.ts +46 -0
- package/lib/services/segment-lookup.js +108 -0
- package/lib/services/segment-members.d.ts +144 -0
- package/lib/services/segment-members.js +402 -0
- package/lib/services/select-native-retrieve.d.ts +60 -0
- package/lib/services/select-native-retrieve.js +226 -0
- package/lib/services/settle-calculated-insight.d.ts +22 -0
- package/lib/services/settle-calculated-insight.js +53 -0
- package/lib/services/sql-tokens.d.ts +58 -0
- package/lib/services/sql-tokens.js +147 -0
- package/lib/transport/api-version.d.ts +36 -0
- package/lib/transport/api-version.js +89 -0
- package/lib/transport/bound-ssot.d.ts +27 -0
- package/lib/transport/bound-ssot.js +116 -0
- package/lib/transport/calculated-insight-rest.d.ts +28 -0
- package/lib/transport/calculated-insight-rest.js +62 -0
- package/lib/transport/connect-client.d.ts +129 -0
- package/lib/transport/connect-client.js +446 -0
- package/lib/transport/connect-diagnostic.d.ts +89 -0
- package/lib/transport/connect-diagnostic.js +331 -0
- package/lib/transport/data-graph-rest.d.ts +27 -0
- package/lib/transport/data-graph-rest.js +76 -0
- package/lib/transport/data-stream-rest.d.ts +62 -0
- package/lib/transport/data-stream-rest.js +348 -0
- package/lib/transport/data-transform-rest.d.ts +25 -0
- package/lib/transport/data-transform-rest.js +100 -0
- package/lib/transport/dlo-native-rest.d.ts +22 -0
- package/lib/transport/dlo-native-rest.js +89 -0
- package/lib/transport/dlo-rest.d.ts +23 -0
- package/lib/transport/dlo-rest.js +135 -0
- package/lib/transport/dmo-native-rest.d.ts +18 -0
- package/lib/transport/dmo-native-rest.js +55 -0
- package/lib/transport/dmo-rest.d.ts +30 -0
- package/lib/transport/dmo-rest.js +163 -0
- package/lib/transport/mapping-rest.d.ts +63 -0
- package/lib/transport/mapping-rest.js +341 -0
- package/lib/transport/project-metadata.d.ts +36 -0
- package/lib/transport/project-metadata.js +118 -0
- package/lib/transport/relationship-rest.d.ts +43 -0
- package/lib/transport/relationship-rest.js +201 -0
- package/package.json +96 -4
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
import { Org } from '@salesforce/core';
|
|
2
|
+
import { buildNativeIdentityResolutionCreate, buildNativeIdentityResolutionUpdate, nativeIdentityResolutionDocument, } from '../services/preflight-identity-resolution-deploy.js';
|
|
3
|
+
import { apiDiagnostic, connectDiagnostic, diagnosticDataProperty, diagnosticRequestId, getConnectDiagnostic, retainConnectDiagnostic, } from './connect-diagnostic.js';
|
|
4
|
+
import { segmentWriteBody, validateSegmentDocument } from '../artifacts/segment-document.js';
|
|
5
|
+
/** Native 404 codes that name an item as absent or deleted, read from a single REST error. */
|
|
6
|
+
const nativeAbsenceCodes = ['ITEM_NOT_FOUND', 'ENTITY_IS_DELETED'];
|
|
7
|
+
/**
|
|
8
|
+
* The request header that makes Connect REST answer in plain text. By default it HTML-escapes
|
|
9
|
+
* every string of a response (`<>"'\&` read as `< > " ' \ &`) while it
|
|
10
|
+
* stores what a write sends as is, so a retrieved label, description, formula or SQL would not be
|
|
11
|
+
* what Salesforce holds (live API 68: data transforms, DLOs, data streams, calculated insights,
|
|
12
|
+
* segments; DB entry data360:connect-rest-entity-encoding-header-api68).
|
|
13
|
+
*/
|
|
14
|
+
export const plainTextHeaders = Object.freeze({
|
|
15
|
+
'X-Chatter-Entity-Encoding': 'false',
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* The request with {@link plainTextHeaders} when it goes to a Data 360 (`/ssot/`) route; any
|
|
19
|
+
* other request as it is. Only `/ssot/` routes get the header: a Data 360 read on any other
|
|
20
|
+
* route still returns HTML-escaped text.
|
|
21
|
+
* @param {Parameters<Connection['request']>[0]} request Request as built.
|
|
22
|
+
* @returns {Parameters<Connection['request']>[0]} Request to send.
|
|
23
|
+
*/
|
|
24
|
+
export function plainTextRequest(request) {
|
|
25
|
+
const object = typeof request === 'string' ? { method: 'GET', url: request } : request;
|
|
26
|
+
if (!/\/services\/data\/[^/?#]+\/ssot\//u.test(String(object.url)))
|
|
27
|
+
return request;
|
|
28
|
+
return { ...object, headers: { ...object.headers, ...plainTextHeaders } };
|
|
29
|
+
}
|
|
30
|
+
/** An intentionally payload-free diagnostic safe for JSON and console output. */
|
|
31
|
+
export class ConnectError extends Error {
|
|
32
|
+
code;
|
|
33
|
+
statusCode;
|
|
34
|
+
nativeCode;
|
|
35
|
+
constructor(code, statusCode, nativeCode) {
|
|
36
|
+
super(code === 'AUTHENTICATION_FAILED'
|
|
37
|
+
? 'Salesforce authentication failed.'
|
|
38
|
+
: 'Data360 request failed.');
|
|
39
|
+
this.code = code;
|
|
40
|
+
this.statusCode = statusCode;
|
|
41
|
+
this.nativeCode = nativeCode;
|
|
42
|
+
this.name = 'ConnectError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Bounded retry of in-process requests. GETs retry after network errors and HTTP 429/503;
|
|
47
|
+
* writes retry only when the request provably never reached Salesforce. `sleep` and `warn`
|
|
48
|
+
* are replaceable (tests, commands); `warn` defaults to one stderr line so JSON stdout stays clean.
|
|
49
|
+
*/
|
|
50
|
+
export const connectRetry = {
|
|
51
|
+
attempts: 3,
|
|
52
|
+
delaysMs: [1000, 2000],
|
|
53
|
+
maxRetryAfterMs: 60_000,
|
|
54
|
+
sleep: async (milliseconds) => {
|
|
55
|
+
await new Promise((resolve) => {
|
|
56
|
+
setTimeout(resolve, milliseconds);
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
warn: (message) => {
|
|
60
|
+
process.stderr.write(`Warning: ${message}\n`);
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
// Codes raised before a connection exists: the request never reached Salesforce.
|
|
64
|
+
const unsentCodes = new Set(['ECONNREFUSED', 'ENOTFOUND', 'EHOSTUNREACH', 'EAI_AGAIN']);
|
|
65
|
+
const readRetryCodes = new Set([...unsentCodes, 'ETIMEDOUT', 'ECONNRESET', 'ECONNABORTED']);
|
|
66
|
+
const networkCodes = new WeakMap();
|
|
67
|
+
/**
|
|
68
|
+
* Find a Node network error code on the error or its first two causes.
|
|
69
|
+
* @param {unknown} error Raw transport failure.
|
|
70
|
+
* @returns {string | undefined} A known retry candidate code.
|
|
71
|
+
*/
|
|
72
|
+
function networkCode(error) {
|
|
73
|
+
let current = error;
|
|
74
|
+
for (let depth = 0; depth < 3 && current && typeof current === 'object'; depth++) {
|
|
75
|
+
const code = diagnosticDataProperty(current, 'code');
|
|
76
|
+
if (typeof code === 'string' && readRetryCodes.has(code))
|
|
77
|
+
return code;
|
|
78
|
+
current = diagnosticDataProperty(current, 'cause');
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Decide whether and how long to wait before the next attempt.
|
|
84
|
+
* @param {string} method HTTP method.
|
|
85
|
+
* @param {number} attempt One-based number of the failed attempt.
|
|
86
|
+
* @param {unknown} error The failure thrown by that attempt.
|
|
87
|
+
* @returns {{ wait: number; reason: string } | undefined} Wait in ms, or undefined to give up.
|
|
88
|
+
*/
|
|
89
|
+
function retryPlan(method, attempt, error) {
|
|
90
|
+
if (attempt >= connectRetry.attempts || !error || typeof error !== 'object')
|
|
91
|
+
return;
|
|
92
|
+
const backoff = connectRetry.delaysMs[Math.min(attempt, connectRetry.delaysMs.length) - 1] ?? 0;
|
|
93
|
+
const code = networkCodes.get(error);
|
|
94
|
+
if (code) {
|
|
95
|
+
if (method !== 'GET' && !unsentCodes.has(code))
|
|
96
|
+
return;
|
|
97
|
+
return { wait: backoff, reason: code };
|
|
98
|
+
}
|
|
99
|
+
const diagnostic = getConnectDiagnostic(error);
|
|
100
|
+
if (method !== 'GET' || !diagnostic || diagnostic.kind === 'api-error')
|
|
101
|
+
return;
|
|
102
|
+
let wait = backoff;
|
|
103
|
+
if (diagnostic.retryAfter !== undefined) {
|
|
104
|
+
wait = /^\d+$/u.test(diagnostic.retryAfter)
|
|
105
|
+
? Number(diagnostic.retryAfter) * 1000
|
|
106
|
+
: Math.max(0, Date.parse(diagnostic.retryAfter) - Date.now());
|
|
107
|
+
wait = Math.min(wait, connectRetry.maxRetryAfterMs);
|
|
108
|
+
}
|
|
109
|
+
return { wait, reason: `HTTP ${diagnostic.statusCode}` };
|
|
110
|
+
}
|
|
111
|
+
/** Bounded SSOT transport; Salesforce core owns credentials. */
|
|
112
|
+
export class ConnectClient {
|
|
113
|
+
connection;
|
|
114
|
+
origin;
|
|
115
|
+
prefix;
|
|
116
|
+
selection;
|
|
117
|
+
constructor(connection, selection) {
|
|
118
|
+
this.connection = connection;
|
|
119
|
+
// Numeric compatibility is normalized immediately; bare latest needs resolved SOAP evidence.
|
|
120
|
+
const candidate = typeof selection === 'string'
|
|
121
|
+
? { requested: selection, restSelector: `v${selection}`, soapNumeric: selection }
|
|
122
|
+
: selection;
|
|
123
|
+
if (!candidate ||
|
|
124
|
+
typeof candidate.soapNumeric !== 'string' ||
|
|
125
|
+
!/^\d{2,3}\.0$/u.test(candidate.soapNumeric) ||
|
|
126
|
+
!((candidate.requested === 'latest' && candidate.restSelector === 'latest') ||
|
|
127
|
+
(candidate.requested === candidate.soapNumeric &&
|
|
128
|
+
candidate.restSelector === `v${candidate.soapNumeric}`)))
|
|
129
|
+
throw new ConnectError('INVALID_REQUEST');
|
|
130
|
+
this.selection = Object.freeze({
|
|
131
|
+
requested: candidate.requested,
|
|
132
|
+
restSelector: candidate.restSelector,
|
|
133
|
+
soapNumeric: candidate.soapNumeric,
|
|
134
|
+
});
|
|
135
|
+
try {
|
|
136
|
+
const instance = new URL(connection.instanceUrl);
|
|
137
|
+
if (instance.protocol !== 'https:' ||
|
|
138
|
+
instance.username ||
|
|
139
|
+
instance.password ||
|
|
140
|
+
instance.pathname !== '/' ||
|
|
141
|
+
instance.search ||
|
|
142
|
+
instance.hash)
|
|
143
|
+
throw new Error('Invalid origin');
|
|
144
|
+
this.origin = instance.origin;
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
throw new ConnectError('INVALID_REQUEST');
|
|
148
|
+
}
|
|
149
|
+
this.prefix = `/services/data/${this.selection.restSelector}/ssot/`;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Load existing Salesforce CLI authentication without exposing token fields.
|
|
153
|
+
* @param {string} aliasOrUsername Explicit existing org alias or username.
|
|
154
|
+
* @param {string} apiVersion Explicit version; endpoint support is checked by future adapters.
|
|
155
|
+
* @returns {Promise<ConnectClient>} An authenticated client, without making a resource request.
|
|
156
|
+
*/
|
|
157
|
+
static async create(aliasOrUsername, apiVersion) {
|
|
158
|
+
if (!aliasOrUsername.trim() || !/^\d{2,3}\.0$/u.test(apiVersion)) {
|
|
159
|
+
throw new ConnectError('INVALID_REQUEST');
|
|
160
|
+
}
|
|
161
|
+
try {
|
|
162
|
+
const org = await Org.create({ aliasOrUsername });
|
|
163
|
+
return new ConnectClient(org.getConnection(apiVersion), apiVersion);
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
throw new ConnectError('AUTHENTICATION_FAILED');
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Read a single SSOT response. Does not infer pagination; see `connectRetry` for the bounded retry.
|
|
171
|
+
* @template T
|
|
172
|
+
* @param {string} path Root-relative SSOT path or same-origin absolute URL, with optional query.
|
|
173
|
+
* @returns {Promise<T>} The unmodified resource response; callers must validate its schema.
|
|
174
|
+
*/
|
|
175
|
+
async get(path) {
|
|
176
|
+
return this.read(path);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Create one native API68 Segment in the data space of the file (`?dataspace=`), without
|
|
180
|
+
* redirect or replay. The definition goes as written (`segmentWriteBody`); without a schedule in
|
|
181
|
+
* the file it does not refresh.
|
|
182
|
+
* @param {unknown} value Complete admitted portable definition.
|
|
183
|
+
* @param {ReadonlyMap<string, string>} [children] Waterfall child API name to target definition ID.
|
|
184
|
+
* @returns {Promise<unknown>} Untrusted acknowledgement, not settlement.
|
|
185
|
+
*/
|
|
186
|
+
async createSegment(value, children) {
|
|
187
|
+
if (this.selection.requested !== '68.0')
|
|
188
|
+
throw new ConnectError('INVALID_REQUEST');
|
|
189
|
+
const document = validateSegmentDocument(value);
|
|
190
|
+
return this.send({
|
|
191
|
+
method: 'POST',
|
|
192
|
+
// The create names the data space of the file (live API 68: in a non-default data space
|
|
193
|
+
// Salesforce stores the segment as <prefix>_<Name>, and keeps a name that has it already).
|
|
194
|
+
url: this.safeUrl(`${this.prefix}segments?dataspace=${encodeURIComponent(document.c__dataSpace)}`),
|
|
195
|
+
body: JSON.stringify(segmentWriteBody(document, true, false, children)),
|
|
196
|
+
headers: { 'content-type': 'application/json' },
|
|
197
|
+
}, this.noRefreshReceiver());
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* PATCH the full authored definition on the native API68 Segment route; the schedule keys go
|
|
201
|
+
* along only when `schedule` is set (the schedule of the file differs from the org's).
|
|
202
|
+
* @param {unknown} value Complete independently admitted desired Segment document.
|
|
203
|
+
* @param {boolean} [schedule] Whether to send the schedule of the file.
|
|
204
|
+
* @param {ReadonlyMap<string, string>} [children] Waterfall child API name to target definition ID.
|
|
205
|
+
* @returns {Promise<unknown>} Untrusted single-attempt response, never settlement evidence.
|
|
206
|
+
*/
|
|
207
|
+
async patchSegment(value, schedule = false, children) {
|
|
208
|
+
if (this.selection.requested !== '68.0')
|
|
209
|
+
throw new ConnectError('INVALID_REQUEST');
|
|
210
|
+
const document = validateSegmentDocument(value);
|
|
211
|
+
return this.send({
|
|
212
|
+
method: 'PATCH',
|
|
213
|
+
url: this.safeUrl(`${this.prefix}segments/${document.identity.apiName}`),
|
|
214
|
+
body: JSON.stringify(segmentWriteBody(document, false, schedule, children)),
|
|
215
|
+
headers: { 'content-type': 'application/json' },
|
|
216
|
+
}, this.noRefreshReceiver());
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Create exactly one native68 IR owner without refresh, replay or redirect.
|
|
220
|
+
* @param {unknown} value Complete independently admitted portable definition.
|
|
221
|
+
* @param {string} [dataSpacePrefix] Prefix of the ruleset's data space; required outside default.
|
|
222
|
+
* @returns {Promise<unknown>} Untrusted response, never settlement evidence.
|
|
223
|
+
*/
|
|
224
|
+
async createIdentityResolution(value, dataSpacePrefix) {
|
|
225
|
+
if (this.selection.requested !== '68.0')
|
|
226
|
+
throw new ConnectError('INVALID_REQUEST');
|
|
227
|
+
return this.send({
|
|
228
|
+
method: 'POST',
|
|
229
|
+
url: this.safeUrl(`${this.prefix}identity-resolutions`),
|
|
230
|
+
body: JSON.stringify(buildNativeIdentityResolutionCreate(value, dataSpacePrefix)),
|
|
231
|
+
headers: { 'content-type': 'application/json' },
|
|
232
|
+
}, this.noRefreshReceiver());
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* PATCH the complete preserved input shape on one exact native68 owner; never run processing.
|
|
236
|
+
* @param {unknown} value Complete independently admitted desired definition.
|
|
237
|
+
* @param {unknown} [current] Current target definition; lists it has and the file empties are sent empty.
|
|
238
|
+
* @returns {Promise<unknown>} Untrusted response, never settlement evidence.
|
|
239
|
+
*/
|
|
240
|
+
async patchIdentityResolution(value, current) {
|
|
241
|
+
if (this.selection.requested !== '68.0')
|
|
242
|
+
throw new ConnectError('INVALID_REQUEST');
|
|
243
|
+
const document = nativeIdentityResolutionDocument(value);
|
|
244
|
+
return this.send({
|
|
245
|
+
method: 'PATCH',
|
|
246
|
+
url: this.safeUrl(`${this.prefix}identity-resolutions/${document.identity.apiName}`),
|
|
247
|
+
body: JSON.stringify(buildNativeIdentityResolutionUpdate(document, current)),
|
|
248
|
+
headers: { 'content-type': 'application/json' },
|
|
249
|
+
}, this.noRefreshReceiver());
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Delete exactly one native68 owner by its freshly resolved Salesforce record ID.
|
|
253
|
+
* No name routing, refresh, replay, redirect or arbitrary DELETE path is exposed.
|
|
254
|
+
* @param {string} id Independently bound target-local IR record ID.
|
|
255
|
+
* @returns {Promise<void>} Acknowledged HTTP204 only, never owner absence proof.
|
|
256
|
+
*/
|
|
257
|
+
async deleteIdentityResolution(id) {
|
|
258
|
+
if (this.selection.requested !== '68.0' ||
|
|
259
|
+
typeof id !== 'string' ||
|
|
260
|
+
!/^1ir[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/u.test(id))
|
|
261
|
+
throw new ConnectError('INVALID_REQUEST');
|
|
262
|
+
const noContent = Symbol('identity-resolution-deleted');
|
|
263
|
+
const response = await this.send({ method: 'DELETE', url: this.safeUrl(`${this.prefix}identity-resolutions/${id}`) }, this.noRefreshReceiver(), noContent);
|
|
264
|
+
if (response !== noContent)
|
|
265
|
+
throw new ConnectError('REQUEST_FAILED');
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Delete one exact native68 Segment by API name, without replay or redirect.
|
|
269
|
+
* @param {string} apiName Freshly matched target API name.
|
|
270
|
+
* @returns {Promise<void>} HTTP204 acknowledgement, not independent absence proof.
|
|
271
|
+
*/
|
|
272
|
+
async deleteSegment(apiName) {
|
|
273
|
+
if (this.selection.requested !== '68.0' || !/^[A-Za-z][A-Za-z0-9_]{0,199}$/u.test(apiName))
|
|
274
|
+
throw new ConnectError('INVALID_REQUEST');
|
|
275
|
+
const noContent = Symbol('segment-deleted');
|
|
276
|
+
const response = await this.send({ method: 'DELETE', url: this.safeUrl(`${this.prefix}segments/${apiName}`) }, this.noRefreshReceiver(), noContent);
|
|
277
|
+
if (response !== noContent)
|
|
278
|
+
throw new ConnectError('REQUEST_FAILED');
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Publish one native API68 Segment by its record ID: one POST without a body, never resent
|
|
282
|
+
* after a reset, timeout, 429 or 503 (only a request that provably never left is repeated).
|
|
283
|
+
* @param {string} marketSegmentId Freshly read `1sg` record ID of the segment.
|
|
284
|
+
* @returns {Promise<unknown>} Untrusted acknowledgement (publishStatus, jobId), not the result.
|
|
285
|
+
*/
|
|
286
|
+
async publishSegment(marketSegmentId) {
|
|
287
|
+
if (this.selection.requested !== '68.0' ||
|
|
288
|
+
typeof marketSegmentId !== 'string' ||
|
|
289
|
+
!/^1sg[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?$/u.test(marketSegmentId))
|
|
290
|
+
throw new ConnectError('INVALID_REQUEST');
|
|
291
|
+
return this.send({
|
|
292
|
+
method: 'POST',
|
|
293
|
+
url: this.safeUrl(`${this.prefix}segments/${marketSegmentId}/actions/publish`),
|
|
294
|
+
// JSforce never sends a POST whose body is undefined (the request hangs unsent);
|
|
295
|
+
// an empty string goes out as Content-Length 0, the bodiless POST the route expects.
|
|
296
|
+
body: '',
|
|
297
|
+
}, this.noRefreshReceiver());
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Run one read-only SOQL query (the core `/query` route, outside SSOT) over the command's own
|
|
301
|
+
* connection, without refresh or redirect; the first page only. Callers check `done`.
|
|
302
|
+
* @param {string} query SOQL built only from validated identifiers and static text.
|
|
303
|
+
* @returns {Promise<unknown>} Untrusted query response.
|
|
304
|
+
*/
|
|
305
|
+
async soql(query) {
|
|
306
|
+
if (this.selection.restSelector === 'latest' || typeof query !== 'string' || !query.trim())
|
|
307
|
+
throw new ConnectError('INVALID_REQUEST');
|
|
308
|
+
return this.send({
|
|
309
|
+
method: 'GET',
|
|
310
|
+
url: `${this.origin}/services/data/${this.selection.restSelector}/query?q=${encodeURIComponent(query)}`,
|
|
311
|
+
}, this.noRefreshReceiver());
|
|
312
|
+
}
|
|
313
|
+
noRefreshReceiver() {
|
|
314
|
+
const receiver = Object.create(this.connection);
|
|
315
|
+
Object.defineProperty(receiver, '_refreshDelegate', { value: undefined });
|
|
316
|
+
return receiver;
|
|
317
|
+
}
|
|
318
|
+
async read(path, noContentResponse) {
|
|
319
|
+
return this.send({ method: 'GET', url: this.safeUrl(path) }, this.noRefreshReceiver(), noContentResponse);
|
|
320
|
+
}
|
|
321
|
+
async send(request, receiver, noContentResponse) {
|
|
322
|
+
const method = typeof request === 'object' ? String(request.method ?? 'GET').toUpperCase() : 'GET';
|
|
323
|
+
for (let attempt = 1;; attempt++) {
|
|
324
|
+
try {
|
|
325
|
+
return await this.sendOnce(request, receiver, noContentResponse);
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
const plan = retryPlan(method, attempt, error);
|
|
329
|
+
if (!plan)
|
|
330
|
+
throw error;
|
|
331
|
+
const url = typeof request === 'object' ? request.url : request;
|
|
332
|
+
const route = typeof url === 'string' ? url.split('?')[0].replace(this.origin, '') : '';
|
|
333
|
+
connectRetry.warn(`${method} ${route} failed (${plan.reason}); retrying in ${Math.ceil(plan.wait / 1000)} s (attempt ${attempt + 1} of ${connectRetry.attempts}).`);
|
|
334
|
+
await connectRetry.sleep(plan.wait);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
async sendOnce(request, receiver, noContentResponse) {
|
|
339
|
+
let responseStatus;
|
|
340
|
+
let diagnostic;
|
|
341
|
+
const transport = '_transport' in receiver
|
|
342
|
+
? receiver._transport
|
|
343
|
+
: undefined;
|
|
344
|
+
// Observe this request before JSforce discards numeric wire error status and headers.
|
|
345
|
+
const observer = transport && typeof transport.httpRequest === 'function'
|
|
346
|
+
? {
|
|
347
|
+
httpRequest: (input, options) => {
|
|
348
|
+
const pending = transport.httpRequest.call(transport, input, options);
|
|
349
|
+
const observed = pending.then((response) => {
|
|
350
|
+
const status = response?.statusCode;
|
|
351
|
+
const headers = diagnosticDataProperty(response, 'headers');
|
|
352
|
+
diagnostic = apiDiagnostic(status, diagnosticDataProperty(response, 'body'), headers, diagnosticRequestId(headers));
|
|
353
|
+
if (typeof status === 'number' &&
|
|
354
|
+
Number.isInteger(status) &&
|
|
355
|
+
status >= 400 &&
|
|
356
|
+
status <= 599)
|
|
357
|
+
responseStatus = status;
|
|
358
|
+
return response;
|
|
359
|
+
});
|
|
360
|
+
return Object.assign(observed, { stream: () => pending.stream() });
|
|
361
|
+
},
|
|
362
|
+
}
|
|
363
|
+
: undefined;
|
|
364
|
+
try {
|
|
365
|
+
return await receiver.request(plainTextRequest(request),
|
|
366
|
+
// Core narrows options to JSON, but JSforce supports request-local transport/redirect guards.
|
|
367
|
+
{
|
|
368
|
+
...(observer ? { transport: observer } : {}),
|
|
369
|
+
noContentResponse,
|
|
370
|
+
retry: { maxRetries: 0, methods: [] },
|
|
371
|
+
followRedirect: () => {
|
|
372
|
+
throw new ConnectError('INVALID_REQUEST');
|
|
373
|
+
},
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
catch (error) {
|
|
377
|
+
if (error instanceof ConnectError)
|
|
378
|
+
throw error;
|
|
379
|
+
const status = error && typeof error === 'object' && 'statusCode' in error ? error.statusCode : undefined;
|
|
380
|
+
const statusCode = typeof status === 'number' && Number.isInteger(status) && status >= 400 && status <= 599
|
|
381
|
+
? status
|
|
382
|
+
: responseStatus;
|
|
383
|
+
const expired = error &&
|
|
384
|
+
typeof error === 'object' &&
|
|
385
|
+
'name' in error &&
|
|
386
|
+
error.name === 'INVALID_SESSION_ID';
|
|
387
|
+
// Core preserves the parsed single REST error in data. Never infer absence from
|
|
388
|
+
// HTTP status, message text, raw JSON strings or a mixed/malformed error envelope.
|
|
389
|
+
const nativeError = error;
|
|
390
|
+
const data = nativeError?.data;
|
|
391
|
+
// A GET or DELETE may answer 404 ENTITY_IS_DELETED while an item is being deleted (live
|
|
392
|
+
// API 68, calculated insight); callers decide whether that code means absent.
|
|
393
|
+
const absence = nativeAbsenceCodes.find((value) => value === nativeError?.errorCode);
|
|
394
|
+
const nativeCode = typeof request === 'object' &&
|
|
395
|
+
(request.method === 'GET' || request.method === 'DELETE') &&
|
|
396
|
+
statusCode === 404 &&
|
|
397
|
+
!expired &&
|
|
398
|
+
absence !== undefined &&
|
|
399
|
+
nativeError?.name === absence &&
|
|
400
|
+
!!data &&
|
|
401
|
+
typeof data === 'object' &&
|
|
402
|
+
!Array.isArray(data) &&
|
|
403
|
+
Object.keys(data).length === 2 &&
|
|
404
|
+
'errorCode' in data &&
|
|
405
|
+
data.errorCode === absence &&
|
|
406
|
+
'message' in data &&
|
|
407
|
+
typeof data.message === 'string'
|
|
408
|
+
? absence
|
|
409
|
+
: undefined;
|
|
410
|
+
const code = statusCode === undefined && !expired ? networkCode(error) : undefined;
|
|
411
|
+
const failure = retainConnectDiagnostic(new ConnectError(statusCode === 401 || expired ? 'AUTHENTICATION_FAILED' : 'REQUEST_FAILED', statusCode, nativeCode), diagnostic ??
|
|
412
|
+
apiDiagnostic(statusCode, diagnosticDataProperty(error, 'data')) ??
|
|
413
|
+
connectDiagnostic(statusCode));
|
|
414
|
+
if (code)
|
|
415
|
+
networkCodes.set(failure, code);
|
|
416
|
+
throw failure;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
safeUrl(path) {
|
|
420
|
+
// Reject normalization ambiguities before URL parsing, including nested encodings.
|
|
421
|
+
if (/[\\\s#\p{Cc}]/u.test(path) || /%(?:2e|2f|5c|25|0[0-9a-f]|1[0-9a-f]|7f)/iu.test(path)) {
|
|
422
|
+
throw new ConnectError('INVALID_REQUEST');
|
|
423
|
+
}
|
|
424
|
+
try {
|
|
425
|
+
const url = new URL(path, this.origin);
|
|
426
|
+
const rawPath = path.startsWith('https://') ? path.slice(path.indexOf('/', 8)) : path;
|
|
427
|
+
if (!(path.startsWith('/') && !path.startsWith('//')) && !path.startsWith(`${this.origin}/`))
|
|
428
|
+
throw new Error('Invalid URL');
|
|
429
|
+
if (url.origin !== this.origin ||
|
|
430
|
+
url.username ||
|
|
431
|
+
url.password ||
|
|
432
|
+
!url.pathname.startsWith(this.prefix) ||
|
|
433
|
+
url.pathname === this.prefix ||
|
|
434
|
+
rawPath
|
|
435
|
+
.split('?')[0]
|
|
436
|
+
.split('/')
|
|
437
|
+
.some((part) => part === '.' || part === '..') ||
|
|
438
|
+
url.pathname.includes('//'))
|
|
439
|
+
throw new Error('Invalid path');
|
|
440
|
+
return url.href;
|
|
441
|
+
}
|
|
442
|
+
catch {
|
|
443
|
+
throw new ConnectError('INVALID_REQUEST');
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export type ConnectDiagnostic = Readonly<{
|
|
2
|
+
statusCode: number;
|
|
3
|
+
kind: 'rate-limit' | 'service-unavailable' | 'api-error';
|
|
4
|
+
retryAfter?: string;
|
|
5
|
+
errors?: ReadonlyArray<Readonly<{
|
|
6
|
+
code?: string;
|
|
7
|
+
message?: string;
|
|
8
|
+
}>>;
|
|
9
|
+
requestId?: string;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Read data properties only; never invoke remote accessors or proxy traps.
|
|
13
|
+
* @param {unknown} value Candidate record.
|
|
14
|
+
* @param {string} key Proven transport field.
|
|
15
|
+
* @returns {unknown} Own data value, if present.
|
|
16
|
+
*/
|
|
17
|
+
export declare function diagnosticDataProperty(value: unknown, key: string): unknown;
|
|
18
|
+
/**
|
|
19
|
+
* Classify only actual HTTP429/503; 503 never proves throttling, even with Retry-After.
|
|
20
|
+
* @param {unknown} statusCode Actual wire status.
|
|
21
|
+
* @param {unknown} [headers] Actual wire headers, not exception message text.
|
|
22
|
+
* @returns {ConnectDiagnostic | undefined} Immutable payload-free evidence.
|
|
23
|
+
*/
|
|
24
|
+
export declare function connectDiagnostic(statusCode: unknown, headers?: unknown): ConnectDiagnostic | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Normalize display evidence after a transport has independently confirmed HTTP failure.
|
|
27
|
+
* Callers pass parsed REST error data (not an Error), and an optional extracted request ID.
|
|
28
|
+
* Authentication responses never disclose server prose; a 403 save refusal keeps its text.
|
|
29
|
+
* @param {unknown} statusCode Actual wire status, never inferred from prose.
|
|
30
|
+
* @param {unknown} body Parsed error data or bounded JSON body.
|
|
31
|
+
* @param {unknown} [headers] Actual headers for existing Retry-After handling only.
|
|
32
|
+
* @param {unknown} [requestId] Separately extracted server correlation identifier.
|
|
33
|
+
* @returns {ConnectDiagnostic | undefined} Immutable display-only evidence.
|
|
34
|
+
*/
|
|
35
|
+
export declare function apiDiagnostic(statusCode: unknown, body: unknown, headers?: unknown, requestId?: unknown): ConnectDiagnostic | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Extract one correlation ID from demonstrated HTTP header names, never arbitrary headers.
|
|
38
|
+
* @param {unknown} headers Actual response headers.
|
|
39
|
+
* @returns {unknown} Candidate ID, validated by apiDiagnostic before retention.
|
|
40
|
+
*/
|
|
41
|
+
export declare function diagnosticRequestId(headers: unknown): unknown;
|
|
42
|
+
/**
|
|
43
|
+
* Normalize only a bounded failed installed-CLI HTTP receipt, not stdout/stderr envelopes.
|
|
44
|
+
* Successful receipts and unproven HTTP failures never produce display evidence.
|
|
45
|
+
* @param {string} receipt Actual --include stdout.
|
|
46
|
+
* @returns {ConnectDiagnostic | undefined} Safe detached evidence only.
|
|
47
|
+
*/
|
|
48
|
+
export declare function apiReceiptDiagnostic(receipt: string): ConnectDiagnostic | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Retain safe metadata privately without changing an existing error or response shape.
|
|
51
|
+
* @template {object} T
|
|
52
|
+
* @param {T} target Existing error or detached native Graph read result.
|
|
53
|
+
* @param {ConnectDiagnostic | undefined} diagnostic Classified wire evidence.
|
|
54
|
+
* @returns {T} Unchanged target identity.
|
|
55
|
+
*/
|
|
56
|
+
export declare function retainConnectDiagnostic<T extends object>(target: T, diagnostic: ConnectDiagnostic | undefined): T;
|
|
57
|
+
/**
|
|
58
|
+
* A remote problem text that passes the display filter of REST errors, else undefined.
|
|
59
|
+
* @param {unknown} value Candidate text from a Salesforce answer.
|
|
60
|
+
* @returns {string | undefined} The text when it is safe to show.
|
|
61
|
+
*/
|
|
62
|
+
export declare function displayableApiText(value: unknown): string | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Retain at most three Metadata API problem texts that pass the same display filter as REST errors.
|
|
65
|
+
* A text that does not pass is dropped, never truncated or echoed.
|
|
66
|
+
* @template {object} T
|
|
67
|
+
* @param {T} target Existing error.
|
|
68
|
+
* @param {unknown[]} problems Candidate problem texts from a Metadata deployment receipt.
|
|
69
|
+
* @returns {T} Unchanged target identity.
|
|
70
|
+
*/
|
|
71
|
+
export declare function retainMetadataProblems<T extends object>(target: T, problems: unknown[]): T;
|
|
72
|
+
/**
|
|
73
|
+
* Read retained Metadata API problem texts.
|
|
74
|
+
* @param {unknown} target Existing error.
|
|
75
|
+
* @returns {ReadonlyArray<string> | undefined} Safe texts (possibly none), or undefined when no Metadata deployment failed.
|
|
76
|
+
*/
|
|
77
|
+
export declare function getMetadataProblems(target: unknown): readonly string[] | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Read transport evidence without disclosing raw remote bodies, headers or causes.
|
|
80
|
+
* @param {unknown} target Existing error or native Graph read result.
|
|
81
|
+
* @returns {ConnectDiagnostic | undefined} Immutable safe evidence, if present.
|
|
82
|
+
*/
|
|
83
|
+
export declare function getConnectDiagnostic(target: unknown): ConnectDiagnostic | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Extract only unique Retry-After headers from the leading CLI HTTP receipt header block.
|
|
86
|
+
* @param {string} receipt Installed CLI --include stdout.
|
|
87
|
+
* @returns {ConnectDiagnostic | undefined} Safe evidence; never retains stdout or body.
|
|
88
|
+
*/
|
|
89
|
+
export declare function connectReceiptDiagnostic(receipt: string): ConnectDiagnostic | undefined;
|