sf-plugin-data 0.1.0 → 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 -21
- package/README.md +572 -240
- package/docs/artifact-format.md +527 -633
- package/docs/capabilities.md +1159 -168
- package/docs/git-workflow.md +135 -12
- package/docs/handover.md +7826 -12
- 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 +222 -6
- package/lib/artifacts/read-deploy-input.js +1213 -53
- 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 +234 -15
- package/lib/commands/data360/deploy.js +2292 -100
- package/lib/commands/data360/publish.d.ts +93 -0
- package/lib/commands/data360/publish.js +292 -0
- package/lib/commands/data360/retrieve.d.ts +260 -13
- package/lib/commands/data360/retrieve.js +1880 -85
- 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 +1 -0
- package/lib/plugin.js +3 -1
- 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 +94 -32
- package/lib/transport/connect-client.js +318 -178
- 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 +29 -6
- package/lib/artifacts/dmo-document.d.ts +0 -181
- package/lib/artifacts/dmo-document.js +0 -848
- package/lib/artifacts/dmo-update-delta.d.ts +0 -28
- package/lib/artifacts/dmo-update-delta.js +0 -86
- package/lib/artifacts/write-other-dmo.d.ts +0 -17
- package/lib/artifacts/write-other-dmo.js +0 -140
- package/lib/services/execute-dmo-create.d.ts +0 -24
- package/lib/services/execute-dmo-create.js +0 -118
- package/lib/services/execute-dmo-deploy.d.ts +0 -33
- package/lib/services/execute-dmo-deploy.js +0 -197
- package/lib/services/preflight-dmo-deploy.d.ts +0 -69
- package/lib/services/preflight-dmo-deploy.js +0 -161
- package/lib/services/retrieve-other-dmo.d.ts +0 -46
- package/lib/services/retrieve-other-dmo.js +0 -140
|
@@ -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;
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { types } from 'node:util';
|
|
2
|
+
const evidence = new WeakMap();
|
|
3
|
+
/**
|
|
4
|
+
* Read data properties only; never invoke remote accessors or proxy traps.
|
|
5
|
+
* @param {unknown} value Candidate record.
|
|
6
|
+
* @param {string} key Proven transport field.
|
|
7
|
+
* @returns {unknown} Own data value, if present.
|
|
8
|
+
*/
|
|
9
|
+
export function diagnosticDataProperty(value, key) {
|
|
10
|
+
if (!value || typeof value !== 'object' || types.isProxy(value))
|
|
11
|
+
return undefined;
|
|
12
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
13
|
+
return descriptor && 'value' in descriptor ? descriptor.value : undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Admit bounded prose, not arbitrary response serialization or sensitive echoes.
|
|
17
|
+
* This is conservative display filtering, not a guarantee that free text contains no PII.
|
|
18
|
+
* @param {unknown} value Structured API message leaf.
|
|
19
|
+
* @returns {string | undefined} Useful explanation without recognized sensitive material.
|
|
20
|
+
*/
|
|
21
|
+
function safeMessage(value) {
|
|
22
|
+
if (typeof value !== 'string' || value.length > 400)
|
|
23
|
+
return;
|
|
24
|
+
// Reject controls before whitespace normalization, including terminal and bidi controls.
|
|
25
|
+
if (/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/u.test(value))
|
|
26
|
+
return;
|
|
27
|
+
// Salesforce's fixed text for an internal error carries only a digits-only ErrorId; the
|
|
28
|
+
// general filters would drop it ("contact", phone-like digits), hiding the ErrorId support needs.
|
|
29
|
+
if (/^An unexpected error occurred\. Please include this ErrorId if you contact support: \d+-\d+ \(-?\d+\)\.?$/u.test(value))
|
|
30
|
+
return value;
|
|
31
|
+
if (/[<>{}[\]\\]|https?:|www\.|\b(?:bearer|authorization|cookie|password|secret|token|accessToken|refreshToken|session|credential|payload|private|email|phone|address|ssn)\b|\bselect\b.+\bfrom\b|\bat\s+\S+\s*\(/iu.test(value) ||
|
|
32
|
+
/[\w.+-]+@[\w.-]+|\b\d[\d ()+-]{7,}\d\b|\b[A-Za-z0-9+/=_-]{48,}\b|\b\w+\s*=\s*\S+/u.test(value))
|
|
33
|
+
return;
|
|
34
|
+
// A quoted token can be a credential or record value, not just a schema identifier.
|
|
35
|
+
// Only a quoted Salesforce API name (Name__c, ns__Name__dlm, Table__dlm.Field__c) is kept;
|
|
36
|
+
// any other quoted text uses the caller's contextual fallback instead.
|
|
37
|
+
if (/["'`]/u.test(value.replaceAll(/(["'`])[A-Za-z]\w*__[A-Za-z]+(?:\.[A-Za-z]\w*__[A-Za-z]+)?\1/gu, '')))
|
|
38
|
+
return;
|
|
39
|
+
// Personal-record and credential/value contexts can echo data even without quotes.
|
|
40
|
+
// These filters deliberately do not claim to establish confidentiality for all free text.
|
|
41
|
+
if (/\b(?:api[ -]?key|customer|contact|subscriber|person)\b|\b(?:invalid|rejected)\s+value\b/iu.test(value))
|
|
42
|
+
return;
|
|
43
|
+
const message = value.replaceAll(/\s+/gu, ' ').trim();
|
|
44
|
+
if (!message ||
|
|
45
|
+
/^(?:internal server error|bad request|unknown error|error|service unavailable|too many requests|unauthorized|forbidden)[.! ]*$/iu.test(message))
|
|
46
|
+
return;
|
|
47
|
+
if (/^[\d\W_]+$/u.test(message))
|
|
48
|
+
return;
|
|
49
|
+
return message;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Normalize only REST error records/arrays and their known data/errors containers.
|
|
53
|
+
* No arbitrary keys, native Error.message, causes or raw objects are retained.
|
|
54
|
+
* @param {unknown} candidate Parsed error data, or a bounded JSON error body.
|
|
55
|
+
* @returns {ReadonlyArray<object> | undefined} At most three immutable safe entries.
|
|
56
|
+
*/
|
|
57
|
+
function apiErrors(candidate) {
|
|
58
|
+
let budget = 16_384;
|
|
59
|
+
const result = [];
|
|
60
|
+
const seen = new Set();
|
|
61
|
+
const visit = (value, depth, parsed) => {
|
|
62
|
+
if (depth > 3 || result.length >= 3)
|
|
63
|
+
return;
|
|
64
|
+
if (typeof value === 'string') {
|
|
65
|
+
budget -= value.length;
|
|
66
|
+
if (budget < 0 || parsed || !/^[\s]*[[{]/u.test(value))
|
|
67
|
+
return;
|
|
68
|
+
try {
|
|
69
|
+
visit(JSON.parse(value), depth + 1, true);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
/* Not display evidence. */
|
|
73
|
+
}
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (!value ||
|
|
77
|
+
typeof value !== 'object' ||
|
|
78
|
+
types.isProxy(value) ||
|
|
79
|
+
types.isNativeError(value) ||
|
|
80
|
+
seen.has(value))
|
|
81
|
+
return;
|
|
82
|
+
seen.add(value);
|
|
83
|
+
if (Array.isArray(value)) {
|
|
84
|
+
if (value.length > 3)
|
|
85
|
+
return;
|
|
86
|
+
for (let index = 0; index < value.length; index++)
|
|
87
|
+
visit(diagnosticDataProperty(value, String(index)), depth + 1, parsed);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const rawCode = diagnosticDataProperty(value, 'errorCode');
|
|
91
|
+
const rawMessage = diagnosticDataProperty(value, 'message');
|
|
92
|
+
for (const leaf of [rawCode, rawMessage])
|
|
93
|
+
if (typeof leaf === 'string')
|
|
94
|
+
budget -= leaf.length;
|
|
95
|
+
if (budget < 0)
|
|
96
|
+
return;
|
|
97
|
+
const code = typeof rawCode === 'string' && /^[A-Z][A-Z0-9_]{0,79}$/u.test(rawCode) ? rawCode : undefined;
|
|
98
|
+
const message = safeMessage(rawMessage);
|
|
99
|
+
const size = result.reduce((total, entry) => total + (entry.code?.length ?? 0) + (entry.message?.length ?? 0) + 4, 0);
|
|
100
|
+
if ((code || message) && size + (code?.length ?? 0) + (message?.length ?? 0) + 4 <= 1300)
|
|
101
|
+
result.push(Object.freeze({ ...(code ? { code } : {}), ...(message ? { message } : {}) }));
|
|
102
|
+
if (typeof rawMessage === 'string' && /^[\s]*[[{]/u.test(rawMessage))
|
|
103
|
+
visit(rawMessage, depth + 1, parsed);
|
|
104
|
+
if (rawCode === undefined && rawMessage === undefined) {
|
|
105
|
+
for (const key of ['data', 'errors'])
|
|
106
|
+
visit(diagnosticDataProperty(value, key), depth + 1, parsed);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
visit(candidate, 0, false);
|
|
110
|
+
return result.length > 0 ? Object.freeze(result) : undefined;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Admit only a bounded server delay or canonical HTTP-date, never arbitrary header text.
|
|
114
|
+
* @param {unknown} headers Actual response headers.
|
|
115
|
+
* @returns {string | undefined} Safe Retry-After value, if uniquely supplied.
|
|
116
|
+
*/
|
|
117
|
+
function retryAfter(headers) {
|
|
118
|
+
if (!headers || typeof headers !== 'object' || Array.isArray(headers))
|
|
119
|
+
return;
|
|
120
|
+
if (types.isProxy(headers))
|
|
121
|
+
return;
|
|
122
|
+
const keys = Object.getOwnPropertyNames(headers);
|
|
123
|
+
if (keys.length > 100)
|
|
124
|
+
return;
|
|
125
|
+
const entries = keys.filter((key) => key.toLowerCase() === 'retry-after');
|
|
126
|
+
if (entries.length !== 1)
|
|
127
|
+
return;
|
|
128
|
+
const value = diagnosticDataProperty(headers, entries[0]);
|
|
129
|
+
if (typeof value !== 'string' || value.length > 64)
|
|
130
|
+
return;
|
|
131
|
+
if (/^(?:0|[1-9]\d{0,9})$/u.test(value))
|
|
132
|
+
return value;
|
|
133
|
+
if (/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT$/u.test(value)) {
|
|
134
|
+
const date = new Date(value);
|
|
135
|
+
if (Number.isFinite(date.getTime()) && date.toUTCString() === value)
|
|
136
|
+
return value;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Classify only actual HTTP429/503; 503 never proves throttling, even with Retry-After.
|
|
141
|
+
* @param {unknown} statusCode Actual wire status.
|
|
142
|
+
* @param {unknown} [headers] Actual wire headers, not exception message text.
|
|
143
|
+
* @returns {ConnectDiagnostic | undefined} Immutable payload-free evidence.
|
|
144
|
+
*/
|
|
145
|
+
export function connectDiagnostic(statusCode, headers) {
|
|
146
|
+
if (statusCode !== 429 && statusCode !== 503)
|
|
147
|
+
return;
|
|
148
|
+
const wait = retryAfter(headers);
|
|
149
|
+
return Object.freeze({
|
|
150
|
+
statusCode,
|
|
151
|
+
kind: statusCode === 429 ? 'rate-limit' : 'service-unavailable',
|
|
152
|
+
...(wait === undefined ? {} : { retryAfter: wait }),
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/** Error codes of a 403 that concern access, sessions or licences; their text is never shown. */
|
|
156
|
+
const accessCode = /SESSION|AUTH|LOGIN|ACCESS|PERMISSION|FORBIDDEN|DISABLED|PASSWORD|TOKEN|CREDENTIAL|LICENSE/u;
|
|
157
|
+
/**
|
|
158
|
+
* Normalize display evidence after a transport has independently confirmed HTTP failure.
|
|
159
|
+
* Callers pass parsed REST error data (not an Error), and an optional extracted request ID.
|
|
160
|
+
* Authentication responses never disclose server prose; a 403 save refusal keeps its text.
|
|
161
|
+
* @param {unknown} statusCode Actual wire status, never inferred from prose.
|
|
162
|
+
* @param {unknown} body Parsed error data or bounded JSON body.
|
|
163
|
+
* @param {unknown} [headers] Actual headers for existing Retry-After handling only.
|
|
164
|
+
* @param {unknown} [requestId] Separately extracted server correlation identifier.
|
|
165
|
+
* @returns {ConnectDiagnostic | undefined} Immutable display-only evidence.
|
|
166
|
+
*/
|
|
167
|
+
export function apiDiagnostic(statusCode, body, headers, requestId) {
|
|
168
|
+
if (typeof statusCode !== 'number' ||
|
|
169
|
+
!Number.isInteger(statusCode) ||
|
|
170
|
+
statusCode < 400 ||
|
|
171
|
+
statusCode > 599)
|
|
172
|
+
return;
|
|
173
|
+
const admitted = apiErrors(body);
|
|
174
|
+
// An authentication answer (401, or a 403 about access) shows its codes only. A 403 that is a
|
|
175
|
+
// save refusal (for example ENTITY_SAVE_ERROR while a segment is PROCESSING) keeps its text.
|
|
176
|
+
const errors = statusCode === 401 || statusCode === 403
|
|
177
|
+
? admitted &&
|
|
178
|
+
Object.freeze(admitted
|
|
179
|
+
.filter(({ code }) => code)
|
|
180
|
+
.map(({ code, message }) => Object.freeze(statusCode === 403 && message && !accessCode.test(code)
|
|
181
|
+
? { code, message }
|
|
182
|
+
: { code })))
|
|
183
|
+
: admitted;
|
|
184
|
+
const id = typeof requestId === 'string' && /^[A-Za-z0-9][A-Za-z0-9-]{7,79}$/u.test(requestId)
|
|
185
|
+
? requestId
|
|
186
|
+
: undefined;
|
|
187
|
+
return Object.freeze({
|
|
188
|
+
...(connectDiagnostic(statusCode, headers) ?? { statusCode, kind: 'api-error' }),
|
|
189
|
+
...(errors ? { errors } : {}),
|
|
190
|
+
...(id ? { requestId: id } : {}),
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Extract one correlation ID from demonstrated HTTP header names, never arbitrary headers.
|
|
195
|
+
* @param {unknown} headers Actual response headers.
|
|
196
|
+
* @returns {unknown} Candidate ID, validated by apiDiagnostic before retention.
|
|
197
|
+
*/
|
|
198
|
+
export function diagnosticRequestId(headers) {
|
|
199
|
+
if (!headers || typeof headers !== 'object' || types.isProxy(headers))
|
|
200
|
+
return undefined;
|
|
201
|
+
const keys = Object.getOwnPropertyNames(headers);
|
|
202
|
+
if (keys.length > 100)
|
|
203
|
+
return undefined;
|
|
204
|
+
const matches = keys.filter((key) => ['x-sfdc-request-id', 'x-request-id'].includes(key.toLowerCase()));
|
|
205
|
+
return matches.length === 1 ? diagnosticDataProperty(headers, matches[0]) : undefined;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Normalize only a bounded failed installed-CLI HTTP receipt, not stdout/stderr envelopes.
|
|
209
|
+
* Successful receipts and unproven HTTP failures never produce display evidence.
|
|
210
|
+
* @param {string} receipt Actual --include stdout.
|
|
211
|
+
* @returns {ConnectDiagnostic | undefined} Safe detached evidence only.
|
|
212
|
+
*/
|
|
213
|
+
export function apiReceiptDiagnostic(receipt) {
|
|
214
|
+
const match = /^HTTP\/\d(?:\.\d)? (\d{3})[^\r\n]*\r?\n/u.exec(receipt.slice(0, 256));
|
|
215
|
+
if (!match)
|
|
216
|
+
return;
|
|
217
|
+
const status = Number(match[1]);
|
|
218
|
+
if (status < 400 || status > 599)
|
|
219
|
+
return;
|
|
220
|
+
const headerBlock = receipt.slice(0, 16_384);
|
|
221
|
+
const headers = {};
|
|
222
|
+
let offset = match[0].length;
|
|
223
|
+
const duplicates = new Set();
|
|
224
|
+
while (offset < headerBlock.length) {
|
|
225
|
+
const line = /^([^\r\n]*)\r?\n/u.exec(headerBlock.slice(offset));
|
|
226
|
+
if (!line)
|
|
227
|
+
break;
|
|
228
|
+
const header = /^([^:\s]+):[ \t]*(.*)$/u.exec(line[1]);
|
|
229
|
+
if (!line[1]) {
|
|
230
|
+
offset += line[0].length;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
if (!header)
|
|
234
|
+
break;
|
|
235
|
+
const key = header[1].toLowerCase();
|
|
236
|
+
if (['retry-after', 'x-sfdc-request-id', 'x-request-id'].includes(key)) {
|
|
237
|
+
if (Object.hasOwn(headers, key))
|
|
238
|
+
duplicates.add(key);
|
|
239
|
+
headers[key] = header[2];
|
|
240
|
+
}
|
|
241
|
+
offset += line[0].length;
|
|
242
|
+
}
|
|
243
|
+
const requestId = duplicates.has('x-request-id') || duplicates.has('x-sfdc-request-id')
|
|
244
|
+
? undefined
|
|
245
|
+
: diagnosticRequestId(headers);
|
|
246
|
+
if (duplicates.has('retry-after'))
|
|
247
|
+
delete headers['retry-after'];
|
|
248
|
+
return apiDiagnostic(status, receipt.length - offset <= 16_384 ? receipt.slice(offset) : undefined, headers, requestId);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Retain safe metadata privately without changing an existing error or response shape.
|
|
252
|
+
* @template {object} T
|
|
253
|
+
* @param {T} target Existing error or detached native Graph read result.
|
|
254
|
+
* @param {ConnectDiagnostic | undefined} diagnostic Classified wire evidence.
|
|
255
|
+
* @returns {T} Unchanged target identity.
|
|
256
|
+
*/
|
|
257
|
+
export function retainConnectDiagnostic(target, diagnostic) {
|
|
258
|
+
if (diagnostic)
|
|
259
|
+
evidence.set(target, diagnostic);
|
|
260
|
+
return target;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* A remote problem text that passes the display filter of REST errors, else undefined.
|
|
264
|
+
* @param {unknown} value Candidate text from a Salesforce answer.
|
|
265
|
+
* @returns {string | undefined} The text when it is safe to show.
|
|
266
|
+
*/
|
|
267
|
+
export function displayableApiText(value) {
|
|
268
|
+
return safeMessage(value);
|
|
269
|
+
}
|
|
270
|
+
const metadataProblems = new WeakMap();
|
|
271
|
+
/**
|
|
272
|
+
* Retain at most three Metadata API problem texts that pass the same display filter as REST errors.
|
|
273
|
+
* A text that does not pass is dropped, never truncated or echoed.
|
|
274
|
+
* @template {object} T
|
|
275
|
+
* @param {T} target Existing error.
|
|
276
|
+
* @param {unknown[]} problems Candidate problem texts from a Metadata deployment receipt.
|
|
277
|
+
* @returns {T} Unchanged target identity.
|
|
278
|
+
*/
|
|
279
|
+
export function retainMetadataProblems(target, problems) {
|
|
280
|
+
const safe = [];
|
|
281
|
+
for (const problem of problems.slice(0, 20)) {
|
|
282
|
+
const message = safeMessage(problem);
|
|
283
|
+
if (message && !safe.includes(message) && safe.length < 3)
|
|
284
|
+
safe.push(message);
|
|
285
|
+
}
|
|
286
|
+
metadataProblems.set(target, Object.freeze(safe));
|
|
287
|
+
return target;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Read retained Metadata API problem texts.
|
|
291
|
+
* @param {unknown} target Existing error.
|
|
292
|
+
* @returns {ReadonlyArray<string> | undefined} Safe texts (possibly none), or undefined when no Metadata deployment failed.
|
|
293
|
+
*/
|
|
294
|
+
export function getMetadataProblems(target) {
|
|
295
|
+
if (target && typeof target === 'object')
|
|
296
|
+
return metadataProblems.get(target);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Read transport evidence without disclosing raw remote bodies, headers or causes.
|
|
300
|
+
* @param {unknown} target Existing error or native Graph read result.
|
|
301
|
+
* @returns {ConnectDiagnostic | undefined} Immutable safe evidence, if present.
|
|
302
|
+
*/
|
|
303
|
+
export function getConnectDiagnostic(target) {
|
|
304
|
+
if (target && typeof target === 'object')
|
|
305
|
+
return evidence.get(target);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Extract only unique Retry-After headers from the leading CLI HTTP receipt header block.
|
|
309
|
+
* @param {string} receipt Installed CLI --include stdout.
|
|
310
|
+
* @returns {ConnectDiagnostic | undefined} Safe evidence; never retains stdout or body.
|
|
311
|
+
*/
|
|
312
|
+
export function connectReceiptDiagnostic(receipt) {
|
|
313
|
+
const match = /^HTTP\/\d(?:\.\d)? (\d{3})[^\r\n]*\r?\n/u.exec(receipt);
|
|
314
|
+
if (!match)
|
|
315
|
+
return;
|
|
316
|
+
const headers = {};
|
|
317
|
+
let duplicates = false;
|
|
318
|
+
for (const line of receipt.slice(match[0].length).split(/\r?\n/u)) {
|
|
319
|
+
if (!line)
|
|
320
|
+
break;
|
|
321
|
+
const header = /^([^:\s]+):[ \t]*(.*)$/u.exec(line);
|
|
322
|
+
if (!header)
|
|
323
|
+
break;
|
|
324
|
+
if (header[1].toLowerCase() === 'retry-after') {
|
|
325
|
+
if ('retry-after' in headers)
|
|
326
|
+
duplicates = true;
|
|
327
|
+
headers['retry-after'] = header[2];
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return connectDiagnostic(Number(match[1]), duplicates ? undefined : headers);
|
|
331
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ConnectClient } from './connect-client.js';
|
|
2
|
+
export type DataGraphClient = {
|
|
3
|
+
get: (apiName: string) => Promise<unknown>;
|
|
4
|
+
create: (definition: unknown) => Promise<unknown>;
|
|
5
|
+
update?: (apiName: string, definition: unknown) => Promise<unknown>;
|
|
6
|
+
delete: (apiName: string) => Promise<unknown>;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Build the native API68 create body from an authored definition of any shape the native
|
|
10
|
+
* document admits; the API decides what it accepts. Generated names are dropped (see
|
|
11
|
+
* nativeDataGraphCreateDefinition); enum spellings are sent in request form.
|
|
12
|
+
* @param {unknown} value Raw authored definition.
|
|
13
|
+
* @returns {Record<string, unknown>} Detached native request.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildDataGraphCreateRequest(value: unknown): Record<string, unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* Bind native API68 Graph CRD transport in one data space, not lifecycle authorization. Graph
|
|
18
|
+
* routes are by name (names are unique in the org); the create and update bodies name the data
|
|
19
|
+
* space (`dataspaceName`) and must name the client's.
|
|
20
|
+
* The caller must independently qualify dependencies, absence, ownership and settlement.
|
|
21
|
+
* A DELETE acknowledgement does not prove absence or generated-resource cleanup.
|
|
22
|
+
* @param {ConstructorParameters<typeof ConnectClient>[0]} connection Authenticated core receiver.
|
|
23
|
+
* @param {string} apiVersion Explicit qualified numeric version.
|
|
24
|
+
* @param {string} dataSpace The run's data space.
|
|
25
|
+
* @returns {DataGraphClient} Exact operations without automatic retries.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createDataGraphClient(connection: ConstructorParameters<typeof ConnectClient>[0], apiVersion: string, dataSpace: string): DataGraphClient & Required<Pick<DataGraphClient, 'update'>>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { dataGraphName, DataGraphError, graphRecord, graphRequire, } from '../artifacts/data-graph-document.js';
|
|
2
|
+
import { isDataSpaceName } from '../artifacts/data-space-field.js';
|
|
3
|
+
import { ConnectClient } from './connect-client.js';
|
|
4
|
+
import { nativeDataGraphCreateDefinition, nativeDataGraphDocumentOf, validateNativeDataGraphDocument, } from '../artifacts/native-data-graph-document.js';
|
|
5
|
+
/**
|
|
6
|
+
* Build the native API68 create body from an authored definition of any shape the native
|
|
7
|
+
* document admits; the API decides what it accepts. Generated names are dropped (see
|
|
8
|
+
* nativeDataGraphCreateDefinition); enum spellings are sent in request form.
|
|
9
|
+
* @param {unknown} value Raw authored definition.
|
|
10
|
+
* @returns {Record<string, unknown>} Detached native request.
|
|
11
|
+
*/
|
|
12
|
+
export function buildDataGraphCreateRequest(value) {
|
|
13
|
+
return nativeDataGraphCreateDefinition(nativeDataGraphDocumentOf(graphRecord(value)));
|
|
14
|
+
}
|
|
15
|
+
/** Shared core authentication and single-attempt transport, without a generic public writer. */
|
|
16
|
+
class DataGraphTransport extends ConnectClient {
|
|
17
|
+
/**
|
|
18
|
+
* Send an exact operation with refresh/replay/redirect disabled.
|
|
19
|
+
* @param {string} route Fixed qualified route.
|
|
20
|
+
* @param {'GET' | 'POST' | 'PUT' | 'DELETE'} method Native single-attempt verb.
|
|
21
|
+
* @param {Record<string, unknown>} [body] Validated create definition only.
|
|
22
|
+
* @returns {Promise<unknown>} Untrusted response, including undefined for HTTP204.
|
|
23
|
+
*/
|
|
24
|
+
async request(route, method, body) {
|
|
25
|
+
return this.send({
|
|
26
|
+
method,
|
|
27
|
+
url: this.safeUrl(route),
|
|
28
|
+
...(body === undefined
|
|
29
|
+
? {}
|
|
30
|
+
: { body: JSON.stringify(body), headers: { 'content-type': 'application/json' } }),
|
|
31
|
+
}, this.noRefreshReceiver());
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Bind native API68 Graph CRD transport in one data space, not lifecycle authorization. Graph
|
|
36
|
+
* routes are by name (names are unique in the org); the create and update bodies name the data
|
|
37
|
+
* space (`dataspaceName`) and must name the client's.
|
|
38
|
+
* The caller must independently qualify dependencies, absence, ownership and settlement.
|
|
39
|
+
* A DELETE acknowledgement does not prove absence or generated-resource cleanup.
|
|
40
|
+
* @param {ConstructorParameters<typeof ConnectClient>[0]} connection Authenticated core receiver.
|
|
41
|
+
* @param {string} apiVersion Explicit qualified numeric version.
|
|
42
|
+
* @param {string} dataSpace The run's data space.
|
|
43
|
+
* @returns {DataGraphClient} Exact operations without automatic retries.
|
|
44
|
+
*/
|
|
45
|
+
export function createDataGraphClient(connection, apiVersion, dataSpace) {
|
|
46
|
+
if (apiVersion !== '68.0')
|
|
47
|
+
throw new DataGraphError('INVALID_NATIVE_DATA_GRAPH_SCOPE');
|
|
48
|
+
graphRequire(isDataSpaceName(dataSpace));
|
|
49
|
+
const transport = new DataGraphTransport(connection, apiVersion);
|
|
50
|
+
const endpoint = '/services/data/v68.0/ssot/data-graphs';
|
|
51
|
+
/**
|
|
52
|
+
* Bind an exact developer name, never a URL, ID or query.
|
|
53
|
+
* @param {string} apiName Exact Graph name.
|
|
54
|
+
* @returns {string} Fixed item route.
|
|
55
|
+
*/
|
|
56
|
+
function item(apiName) {
|
|
57
|
+
if (typeof apiName !== 'string' || !dataGraphName.test(apiName))
|
|
58
|
+
throw new DataGraphError('INVALID_NATIVE_DATA_GRAPH_NAME');
|
|
59
|
+
return `${endpoint}/${apiName}`;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
get: async (apiName) => transport.request(item(apiName), 'GET'),
|
|
63
|
+
create: async (value) => {
|
|
64
|
+
const body = buildDataGraphCreateRequest(value);
|
|
65
|
+
graphRequire(body.dataspaceName === dataSpace);
|
|
66
|
+
return transport.request(endpoint, 'POST', body);
|
|
67
|
+
},
|
|
68
|
+
update: async (apiName, value) => {
|
|
69
|
+
const route = item(apiName);
|
|
70
|
+
const { definition } = validateNativeDataGraphDocument(nativeDataGraphDocumentOf(graphRecord(value)));
|
|
71
|
+
graphRequire(definition.name === apiName && definition.dataspaceName === dataSpace);
|
|
72
|
+
return transport.request(route, 'PUT', definition);
|
|
73
|
+
},
|
|
74
|
+
delete: async (apiName) => transport.request(item(apiName), 'DELETE'),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { DataStreamError } from '../artifacts/data-stream-document.js';
|
|
2
|
+
import { ConnectClient } from './connect-client.js';
|
|
3
|
+
import type { BoundSsot } from './bound-ssot.js';
|
|
4
|
+
export type DataStreamClient = {
|
|
5
|
+
get: (nameOrId: string) => Promise<unknown>;
|
|
6
|
+
list: (connectionName: string) => Promise<Array<Record<string, unknown>>>;
|
|
7
|
+
/** Ingestion API streams with formulas also send the event's typed source fields. */
|
|
8
|
+
create: (document: unknown, sourceFields?: ReadonlyArray<{
|
|
9
|
+
name: string;
|
|
10
|
+
dataType: string;
|
|
11
|
+
}>) => Promise<unknown>;
|
|
12
|
+
update: (recordId: string, document: unknown) => Promise<unknown>;
|
|
13
|
+
/** One PATCH with a prepared body: `datastreamType` plus the changed parts. */
|
|
14
|
+
patch: (recordId: string, body: Record<string, unknown>) => Promise<unknown>;
|
|
15
|
+
delete: (recordId: string, deleteDlo: boolean) => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Set the stream label with one Metadata API `updateMetadata` of its DataStreamDefinition (the
|
|
18
|
+
* record read first, `masterLabel` replaced) on the bound Connection; never resent. Salesforce
|
|
19
|
+
* ignores a label in a stream PATCH. Absent without a bound Metadata API. `send` wraps only the
|
|
20
|
+
* update (a caller's write ledger); the read before it is not a write.
|
|
21
|
+
*/
|
|
22
|
+
relabel?: (apiName: string, label: string, send?: (write: () => Promise<void>) => Promise<void>) => Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
/** Metadata API type of a data stream; its record name is the stream name. */
|
|
25
|
+
export declare const streamMetadataType = "DataStreamDefinition";
|
|
26
|
+
type JsonObject = Record<string, unknown>;
|
|
27
|
+
/** Native connection and dependency reads a stream binding/delete decision depends on. */
|
|
28
|
+
export type DataStreamReferenceReader = {
|
|
29
|
+
connections: {
|
|
30
|
+
/** One page of IngestApi connections (200 per page) from the offset, 0 by default. */
|
|
31
|
+
list: (offset?: number) => Promise<JsonObject>;
|
|
32
|
+
get: (connectionId: string) => Promise<JsonObject>;
|
|
33
|
+
schema: (connectionId: string) => Promise<JsonObject>;
|
|
34
|
+
};
|
|
35
|
+
dependencies: {
|
|
36
|
+
stream: (recordIdOrName: string) => Promise<JsonObject>;
|
|
37
|
+
dlo: (recordIdOrName: string) => Promise<JsonObject>;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Construct native connection/dependency readers. Family admission validates bodies and decides.
|
|
42
|
+
* @param {ConnectClient} reader Authenticated native GET transport.
|
|
43
|
+
* @param {string} apiVersion Qualified stream pin (API68 only).
|
|
44
|
+
* @returns {DataStreamReferenceReader} Read-only native routes.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createDataStreamReferenceReader(reader: Pick<ConnectClient, 'get'>, apiVersion?: string): DataStreamReferenceReader;
|
|
47
|
+
/** Genuine native HTTP failure, without response text or credentials. */
|
|
48
|
+
export declare class DataStreamHttpError extends DataStreamError {
|
|
49
|
+
readonly status?: number | undefined;
|
|
50
|
+
constructor(code: string, status?: number | undefined);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Construct bounded stream transport. Writes go over the bound in-process connection and are
|
|
54
|
+
* never resent once they may have reached Salesforce; they are not lifecycle authorization.
|
|
55
|
+
* @param {string} targetOrg Existing CLI org alias.
|
|
56
|
+
* @param {ConnectClient} reader Authenticated native GET transport.
|
|
57
|
+
* @param {string} apiVersion Initial qualified pin only.
|
|
58
|
+
* @param {BoundSsot} [sender] The command's shared sender; defaults to one opened for targetOrg.
|
|
59
|
+
* @returns {DataStreamClient} Internal operations; no command wiring.
|
|
60
|
+
*/
|
|
61
|
+
export declare function createDataStreamClient(targetOrg: string, reader: Pick<ConnectClient, 'get'>, apiVersion?: string, sender?: BoundSsot): DataStreamClient;
|
|
62
|
+
export {};
|