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,485 @@
|
|
|
1
|
+
import { getConnectDiagnostic, retainConnectDiagnostic } from '../transport/connect-diagnostic.js';
|
|
2
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
3
|
+
import { DataGraphError, graphRequire } from '../artifacts/data-graph-document.js';
|
|
4
|
+
import { observeNativeDataGraph, nativeDataGraphDocumentFromResponse, nativeDataGraphSpace, nativeDataGraphSpaceMismatch, nativeDataGraphUnreferenced, } from '../artifacts/native-data-graph-document.js';
|
|
5
|
+
import { graphRecord, graphText } from '../artifacts/data-graph-document.js';
|
|
6
|
+
import { validateNativeDataGraphDocument } from '../artifacts/native-data-graph-document.js';
|
|
7
|
+
import { acquireNativeDataGraph, bindNativeGraphRoot, nativeDataGraphLifecycle, nativeGraphStillGenerating, NativeGraphProcessingRequired, NativeGraphWriteRefused, NativeGraphWriteRejected, sendNativeGraphWrite, updateNativeDataGraph, } from './native-data-graph-crd.js';
|
|
8
|
+
import { isVerbatimDocument, verbatimDataSpace } from '../artifacts/verbatim-document.js';
|
|
9
|
+
import { explanationOf, operationDiagnostic } from './operation-diagnostic.js';
|
|
10
|
+
import { rejectedNextAction } from './deploy-result.js';
|
|
11
|
+
import { proveNativeDataGraphAbsent } from './native-data-graph-crd.js';
|
|
12
|
+
/**
|
|
13
|
+
* Project independently read native runtime configuration into a distinct authored artifact.
|
|
14
|
+
* Retrieve takes the graph in any status and keeps settings the plugin does not model (deploy
|
|
15
|
+
* of such a file refuses and names the key); the root DMO is not read. The graph is read twice
|
|
16
|
+
* and both reads must agree. A shape the file cannot hold (an unknown schedule form, a jsonPath
|
|
17
|
+
* other than `$` or `parent.name`) throws, so the retrieve catch-all keeps the GET verbatim.
|
|
18
|
+
* @param {string} name Exact selected graph.
|
|
19
|
+
* @param {NativeGraphContext} context Scoped independent readers.
|
|
20
|
+
* @returns {Promise<import('../artifacts/native-data-graph-document.js').NativeDataGraphDocument>} Portable intent without generated identities.
|
|
21
|
+
*/
|
|
22
|
+
export async function retrieveNativeDataGraph(name, context) {
|
|
23
|
+
context.check();
|
|
24
|
+
const read = await context.get(name);
|
|
25
|
+
if (read.status !== 200)
|
|
26
|
+
throw retainConnectDiagnostic(new Error('Native Graph read unavailable'), getConnectDiagnostic(read));
|
|
27
|
+
const raw = graphRecord(read.body);
|
|
28
|
+
// A GET answering with another graph is an item failure, never a verbatim file.
|
|
29
|
+
if (raw.name !== name)
|
|
30
|
+
throw new DataGraphError('DATA_GRAPH_IDENTITY_MISMATCH');
|
|
31
|
+
// Graph names are unique in the org: a graph of another data space is an item failure, read
|
|
32
|
+
// before anything is projected or kept as read.
|
|
33
|
+
const found = nativeDataGraphSpace(raw);
|
|
34
|
+
if (found !== context.space)
|
|
35
|
+
throw nativeDataGraphSpaceMismatch(name, found, context.space, 'org');
|
|
36
|
+
// A draft (created with creationMode DRAFT, never built) reads without its draft status in
|
|
37
|
+
// the file, and a draft cannot be edited by PUT (live, API68, 2026-11-16): keep it as read.
|
|
38
|
+
if (raw.status === 'draft')
|
|
39
|
+
throw new DataGraphError('DATA_GRAPH_DRAFT');
|
|
40
|
+
const document = nativeDataGraphDocumentFromResponse(raw, 'retrieve');
|
|
41
|
+
const observed = observeNativeDataGraph(raw, document, 'retrieve');
|
|
42
|
+
const fresh = await acquireNativeDataGraph(context, document, false, 'retrieve');
|
|
43
|
+
try {
|
|
44
|
+
graphRequire(isDeepStrictEqual({ state: 'present', observation: observed }, fresh));
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if (error instanceof Error)
|
|
48
|
+
retainConnectDiagnostic(error, getConnectDiagnostic(fresh));
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
return document;
|
|
52
|
+
}
|
|
53
|
+
export const nativeGraphLimitations = 'Native dependency and related-segment arrays block delete only: delete is refused while any node or field reports one, while deploy and retrieve proceed regardless. Exhaustive external-consumer exclusion is unverified. Definition absence does not establish generated DMO, mapping or transform cleanup, computation success, storage reclamation or credit savings.';
|
|
54
|
+
/**
|
|
55
|
+
* Find the identity resolution that produces a unified graph root (deploy preview only; the
|
|
56
|
+
* real deploy leaves this decision to the API).
|
|
57
|
+
* @param {NativeGraphContext} context Scope-checked readers.
|
|
58
|
+
* @param {string} rootName The graph's unified primary object.
|
|
59
|
+
* @returns {Promise<{name: string; status: unknown} | undefined>} The owning ruleset, if any.
|
|
60
|
+
*/
|
|
61
|
+
async function readNativeGraphRootOwner(context, rootName) {
|
|
62
|
+
context.check();
|
|
63
|
+
graphRequire(typeof context.identityResolutions === 'function');
|
|
64
|
+
const read = await context.identityResolutions();
|
|
65
|
+
context.check();
|
|
66
|
+
if (read.status !== 200)
|
|
67
|
+
throw retainConnectDiagnostic(new Error('Identity resolution list unavailable'), getConnectDiagnostic(read));
|
|
68
|
+
const list = graphRecord(read.body).identityResolutions;
|
|
69
|
+
graphRequire(Array.isArray(list));
|
|
70
|
+
const wanted = rootName.toLowerCase();
|
|
71
|
+
const owners = new Map();
|
|
72
|
+
for (const value of list) {
|
|
73
|
+
const ruleset = graphRecord(value);
|
|
74
|
+
// The list answers every data space whatever ?dataspace= says: keep the run's only.
|
|
75
|
+
if (typeof ruleset.dataSpaceName === 'string' && ruleset.dataSpaceName !== context.space)
|
|
76
|
+
continue;
|
|
77
|
+
const rules = ruleset.reconciliationRules ?? [];
|
|
78
|
+
graphRequire(Array.isArray(rules));
|
|
79
|
+
if (rules.some((rule) => typeof graphRecord(rule).unifiedDmoName === 'string' &&
|
|
80
|
+
graphRecord(rule).unifiedDmoName.toLowerCase() === wanted)) {
|
|
81
|
+
graphText(ruleset.objectApiName);
|
|
82
|
+
owners.set(ruleset.objectApiName, ruleset.rulesetStatus);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// One unified object has one producing ruleset; anything else is not a safe answer.
|
|
86
|
+
graphRequire(owners.size <= 1);
|
|
87
|
+
const [owner] = owners;
|
|
88
|
+
return owner ? { name: owner[0], status: owner[1] } : undefined;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Read a graph named by a verbatim file for its delete, from the raw GET only: it must carry the
|
|
92
|
+
* selected name in the run's data space (another one is DATA_GRAPH_DATASPACE_MISMATCH), be ready with an ID, created date and all generated
|
|
93
|
+
* names, and no node or field may report dependencies or segments. Its definition is not
|
|
94
|
+
* projected.
|
|
95
|
+
* @param {NativeGraphContext} context Scope-checked readers.
|
|
96
|
+
* @param {string} name Name of the verbatim file.
|
|
97
|
+
* @returns {Promise<{state: 'absent'} | {state: 'present'; raw: unknown}>} Absent, or the GET body.
|
|
98
|
+
*/
|
|
99
|
+
async function readVerbatimGraphForDelete(context, name) {
|
|
100
|
+
context.check();
|
|
101
|
+
const read = await context.get(name);
|
|
102
|
+
context.check();
|
|
103
|
+
if (read.status !== 200) {
|
|
104
|
+
const proof = await proveNativeDataGraphAbsent(context, name, read);
|
|
105
|
+
if (proof.state === 'absent')
|
|
106
|
+
return { state: 'absent' };
|
|
107
|
+
throw retainConnectDiagnostic(new Error('Native Graph read unavailable'), getConnectDiagnostic(proof) ?? getConnectDiagnostic(read));
|
|
108
|
+
}
|
|
109
|
+
const raw = graphRecord(read.body);
|
|
110
|
+
if (raw.name !== name)
|
|
111
|
+
throw new DataGraphError('DATA_GRAPH_IDENTITY_MISMATCH');
|
|
112
|
+
const found = nativeDataGraphSpace(raw);
|
|
113
|
+
if (found !== context.space)
|
|
114
|
+
throw nativeDataGraphSpaceMismatch(name, found, context.space, 'org');
|
|
115
|
+
graphRequire(
|
|
116
|
+
// A draft (creationMode DRAFT, never built) reads without ID and created date; the
|
|
117
|
+
// DELETE removes it (live, API68, 2026-11-16).
|
|
118
|
+
(raw.status === 'draft' ||
|
|
119
|
+
(raw.status === 'ready' &&
|
|
120
|
+
typeof raw.id === 'string' &&
|
|
121
|
+
raw.id.trim() !== '' &&
|
|
122
|
+
typeof raw.createdDate === 'string' &&
|
|
123
|
+
Number.isFinite(Date.parse(raw.createdDate)) &&
|
|
124
|
+
!nativeGraphStillGenerating(raw))) &&
|
|
125
|
+
// Delete stays refused while any node or field reports dependencies or segments.
|
|
126
|
+
nativeDataGraphUnreferenced(raw.sourceObject));
|
|
127
|
+
return { state: 'present', raw: structuredClone(read.body) };
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Bind one invocation to fresh target identity and root; never import creation ownership.
|
|
131
|
+
* @param {unknown} value Exact local native intent.
|
|
132
|
+
* @param {NativeGraphContext} context Independently org-bound readers.
|
|
133
|
+
* @param {DataGraphClient} client Single-attempt writer.
|
|
134
|
+
* @param {object} options Explicit operation intent and immutable source verifier.
|
|
135
|
+
* @param {'deploy' | 'delete'} options.operation Requested product operation.
|
|
136
|
+
* @param {boolean} options.preview Zero-write comparison.
|
|
137
|
+
* @param {boolean} options.confirmed Explicit processing/deletion acknowledgement.
|
|
138
|
+
* @param {Function} options.verifyInput Re-admit exact local bytes and flags.
|
|
139
|
+
* @param {Function} [options.pause] Read-only polling seam.
|
|
140
|
+
* @param {Function} [options.now] Injectable monotonic clock.
|
|
141
|
+
* @param {number} [options.waitTimeoutSeconds] Deploy invocation budget in seconds.
|
|
142
|
+
* @param {Function} [options.progress] Stderr-only progress sink.
|
|
143
|
+
* @returns {Promise<NativeGraphOperationResult>} Truthful mutation evidence.
|
|
144
|
+
*/
|
|
145
|
+
export async function operateNativeDataGraph(value, context, client, options) {
|
|
146
|
+
let attempted = false;
|
|
147
|
+
let creating = false;
|
|
148
|
+
let diagnostic;
|
|
149
|
+
const original = context;
|
|
150
|
+
// Delete reads the file and the GET as retrieve writes them: settings the plugin does not
|
|
151
|
+
// model are kept, not refused. Deploy stays strict.
|
|
152
|
+
const mode = options.operation === 'delete' ? 'retrieve' : 'deploy';
|
|
153
|
+
const now = options.now ?? Date.now;
|
|
154
|
+
const started = now();
|
|
155
|
+
const budget = options.operation === 'deploy' ? (options.waitTimeoutSeconds ?? 1800) * 1000 : 120_000;
|
|
156
|
+
const end = started + budget;
|
|
157
|
+
let previous = started;
|
|
158
|
+
let expired = false;
|
|
159
|
+
let timer;
|
|
160
|
+
context = {
|
|
161
|
+
...original,
|
|
162
|
+
check: () => {
|
|
163
|
+
original.check();
|
|
164
|
+
const current = now();
|
|
165
|
+
graphRequire(!expired &&
|
|
166
|
+
Number.isFinite(budget) &&
|
|
167
|
+
budget > 0 &&
|
|
168
|
+
Number.isFinite(current) &&
|
|
169
|
+
current >= previous &&
|
|
170
|
+
current < end &&
|
|
171
|
+
context.orgId === original.orgId);
|
|
172
|
+
previous = current;
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
// Guard the actual dispatch, including CREATE delegated to the fixture lifecycle.
|
|
176
|
+
const writer = {
|
|
177
|
+
get: (name) => client.get(name),
|
|
178
|
+
create: (definition) => {
|
|
179
|
+
context.check();
|
|
180
|
+
attempted = true;
|
|
181
|
+
return client.create(definition);
|
|
182
|
+
},
|
|
183
|
+
update: (name, definition) => {
|
|
184
|
+
context.check();
|
|
185
|
+
const update = client.update;
|
|
186
|
+
graphRequire(typeof update === 'function');
|
|
187
|
+
attempted = true;
|
|
188
|
+
return update(name, definition);
|
|
189
|
+
},
|
|
190
|
+
delete: (name) => {
|
|
191
|
+
context.check();
|
|
192
|
+
attempted = true;
|
|
193
|
+
return client.delete(name);
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
const waitPause = options.pause ??
|
|
197
|
+
(async (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)));
|
|
198
|
+
const progress = options.progress ??
|
|
199
|
+
((message) => {
|
|
200
|
+
process.stderr.write(`${message}\n`);
|
|
201
|
+
});
|
|
202
|
+
const acquire = async (document) => {
|
|
203
|
+
const result = await acquireNativeDataGraph(context, document, options.operation === 'deploy', mode);
|
|
204
|
+
diagnostic = getConnectDiagnostic(result) ?? diagnostic;
|
|
205
|
+
return result;
|
|
206
|
+
};
|
|
207
|
+
// A verbatim file (a graph the plugin cannot model) is deleted by its name.
|
|
208
|
+
const verbatimDelete = async (name) => {
|
|
209
|
+
context.check();
|
|
210
|
+
const orgId = context.orgId;
|
|
211
|
+
await options.verifyInput();
|
|
212
|
+
const before = await readVerbatimGraphForDelete(context, name);
|
|
213
|
+
if (before.state === 'absent')
|
|
214
|
+
return { outcome: 'unchanged', mutation: 'not-attempted' };
|
|
215
|
+
await options.verifyInput();
|
|
216
|
+
graphRequire(isDeepStrictEqual(before, await readVerbatimGraphForDelete(context, name)) &&
|
|
217
|
+
context.orgId === orgId);
|
|
218
|
+
if (options.preview)
|
|
219
|
+
return { outcome: 'delete', mutation: 'not-attempted' };
|
|
220
|
+
graphRequire(options.confirmed === true);
|
|
221
|
+
await options.verifyInput();
|
|
222
|
+
graphRequire(isDeepStrictEqual(before, await readVerbatimGraphForDelete(context, name)));
|
|
223
|
+
context.check();
|
|
224
|
+
graphRequire(context.orgId === orgId);
|
|
225
|
+
try {
|
|
226
|
+
await sendNativeGraphWrite(async () => writer.delete(name), 'delete', {
|
|
227
|
+
now,
|
|
228
|
+
end,
|
|
229
|
+
pause: waitPause,
|
|
230
|
+
progress,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
const evidence = getConnectDiagnostic(error);
|
|
235
|
+
if (error instanceof NativeGraphWriteRefused)
|
|
236
|
+
return retainConnectDiagnostic({ outcome: 'failed', mutation: 'not-attempted' }, evidence);
|
|
237
|
+
if (evidence?.kind === 'api-error' && evidence.statusCode >= 400 && evidence.statusCode < 500)
|
|
238
|
+
return retainConnectDiagnostic({ outcome: 'failed', mutation: 'rejected' }, evidence);
|
|
239
|
+
throw error;
|
|
240
|
+
}
|
|
241
|
+
return { outcome: 'deleted', mutation: 'confirmed-deleted' };
|
|
242
|
+
};
|
|
243
|
+
const work = async () => {
|
|
244
|
+
if (options.operation === 'delete' && isVerbatimDocument(value, 'native-data-graph')) {
|
|
245
|
+
const fileSpace = verbatimDataSpace(value);
|
|
246
|
+
if (fileSpace !== context.space)
|
|
247
|
+
throw nativeDataGraphSpaceMismatch(value.identity.apiName, fileSpace, context.space, 'file');
|
|
248
|
+
return verbatimDelete(value.identity.apiName);
|
|
249
|
+
}
|
|
250
|
+
context.check();
|
|
251
|
+
const document = validateNativeDataGraphDocument(value, mode);
|
|
252
|
+
// The file's data space is the run's; the org graph's is checked on its first read.
|
|
253
|
+
if (document.c__dataSpace !== context.space)
|
|
254
|
+
throw nativeDataGraphSpaceMismatch(document.definition.name, document.c__dataSpace, context.space, 'file');
|
|
255
|
+
const orgId = context.orgId;
|
|
256
|
+
await options.verifyInput();
|
|
257
|
+
const rootName = document.definition.primaryObjectName;
|
|
258
|
+
// Deploy preview checks root and owner itself: no API answer exists without a write.
|
|
259
|
+
// The real deploy sends the graph as authored and the API decides.
|
|
260
|
+
const checkOwner = options.preview && options.operation === 'deploy';
|
|
261
|
+
const blocked = (code, message) => ({
|
|
262
|
+
outcome: 'blocked',
|
|
263
|
+
mutation: 'not-attempted',
|
|
264
|
+
diagnostics: [{ code, message }],
|
|
265
|
+
});
|
|
266
|
+
let root;
|
|
267
|
+
try {
|
|
268
|
+
root = await bindNativeGraphRoot(context, rootName);
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
if (checkOwner && getConnectDiagnostic(error)?.statusCode === 404)
|
|
272
|
+
return blocked('DATA_GRAPH_ROOT_NOT_FOUND', `The graph root ${rootName} does not exist in the target (data space ${context.space}).`);
|
|
273
|
+
throw error;
|
|
274
|
+
}
|
|
275
|
+
let ownerDiagnostics = [];
|
|
276
|
+
// A Derived root is an identity resolution output (unified DMO); other roots have no owner.
|
|
277
|
+
if (checkOwner && root.creationType === 'Derived') {
|
|
278
|
+
const owner = await readNativeGraphRootOwner(context, rootName);
|
|
279
|
+
if (!owner)
|
|
280
|
+
return blocked('DATA_GRAPH_OWNER_NOT_FOUND', `No identity resolution ruleset in the target produces the graph root ${rootName}.`);
|
|
281
|
+
if (owner.status !== 'PUBLISHED')
|
|
282
|
+
return blocked('DATA_GRAPH_OWNER_NOT_PUBLISHED', `Identity resolution ruleset ${owner.name} produces the graph root ${rootName} but is ${typeof owner.status === 'string' ? owner.status : 'not published'}; publish it before deploying the graph.`);
|
|
283
|
+
ownerDiagnostics = [
|
|
284
|
+
{
|
|
285
|
+
code: 'DATA_GRAPH_OWNER',
|
|
286
|
+
message: `The graph root ${rootName} is produced by identity resolution ruleset ${owner.name} (PUBLISHED).`,
|
|
287
|
+
},
|
|
288
|
+
];
|
|
289
|
+
}
|
|
290
|
+
const withOwner = (result) => ownerDiagnostics.length > 0 ? { ...result, diagnostics: ownerDiagnostics } : result;
|
|
291
|
+
const before = await acquire(document);
|
|
292
|
+
context.check();
|
|
293
|
+
graphRequire(context.orgId === orgId);
|
|
294
|
+
if (before.state === 'absent' && options.operation === 'delete')
|
|
295
|
+
return { outcome: 'unchanged', mutation: 'not-attempted' };
|
|
296
|
+
const graphName = document.definition.name;
|
|
297
|
+
if (before.state === 'pending' && options.operation === 'deploy')
|
|
298
|
+
return blocked('DATA_GRAPH_PENDING', before.deleting
|
|
299
|
+
? `A data graph named ${graphName} was deleted but Salesforce still lists it, so a graph of that name cannot be created yet. Wait a few minutes and rerun the deploy. Nothing was written.`
|
|
300
|
+
: `The data graph ${graphName} is still being built: Salesforce has not generated all its objects yet. Wait until it is ready and rerun the deploy. Nothing was written.`);
|
|
301
|
+
const processingRequired = (operation) => blocked('PROCESSING_ACKNOWLEDGEMENT_REQUIRED', `${operation === 'create' ? 'Creating' : 'Changing'} the data graph ${graphName} starts a graph build in Data Cloud and needs --allow-processing. Nothing was written.`);
|
|
302
|
+
if (before.state === 'present' && options.operation === 'deploy') {
|
|
303
|
+
let outcome;
|
|
304
|
+
try {
|
|
305
|
+
outcome = await updateNativeDataGraph(context, writer, document, before.observation, {
|
|
306
|
+
preview: options.preview,
|
|
307
|
+
confirmed: options.confirmed,
|
|
308
|
+
verify: async () => {
|
|
309
|
+
await options.verifyInput();
|
|
310
|
+
graphRequire(isDeepStrictEqual(root, await bindNativeGraphRoot(context, rootName)));
|
|
311
|
+
},
|
|
312
|
+
now,
|
|
313
|
+
pause: waitPause,
|
|
314
|
+
progress,
|
|
315
|
+
started,
|
|
316
|
+
end,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
if (error instanceof NativeGraphProcessingRequired)
|
|
321
|
+
return processingRequired('update');
|
|
322
|
+
// Salesforce keeps the old join of a PUT that changes it: refused before any write.
|
|
323
|
+
if (error instanceof DataGraphError && error.code === 'HTML_ESCAPED_FILE')
|
|
324
|
+
return {
|
|
325
|
+
...blocked(error.code, explanationOf(error) ?? error.message),
|
|
326
|
+
target: 'present',
|
|
327
|
+
};
|
|
328
|
+
if (error instanceof DataGraphError && error.code === 'DATA_GRAPH_JOIN_CHANGE')
|
|
329
|
+
return {
|
|
330
|
+
...blocked('DATA_GRAPH_JOIN_CHANGE', `${explanationOf(error) ?? 'The join of a related object differs from the graph in the org.'} Nothing was written.`),
|
|
331
|
+
target: 'present',
|
|
332
|
+
};
|
|
333
|
+
// The PUT was sent and Salesforce refused it with an API 4xx: nothing was written. The
|
|
334
|
+
// item carries Salesforce's answer.
|
|
335
|
+
if (error instanceof NativeGraphWriteRejected)
|
|
336
|
+
return retainConnectDiagnostic({
|
|
337
|
+
outcome: 'failed',
|
|
338
|
+
mutation: 'rejected',
|
|
339
|
+
diagnostics: [
|
|
340
|
+
{ code: 'REQUEST_FAILED', message: operationDiagnostic(error, rejectedNextAction) },
|
|
341
|
+
],
|
|
342
|
+
}, getConnectDiagnostic(error));
|
|
343
|
+
// The PUT was accepted, but the settled graph kept the old join.
|
|
344
|
+
if (error instanceof DataGraphError && error.code === 'DATA_GRAPH_CHANGE_NOT_APPLIED')
|
|
345
|
+
return {
|
|
346
|
+
outcome: 'failed',
|
|
347
|
+
mutation: 'unknown',
|
|
348
|
+
diagnostics: [
|
|
349
|
+
{
|
|
350
|
+
code: 'DATA_GRAPH_CHANGE_NOT_APPLIED',
|
|
351
|
+
message: `Salesforce accepted the update of the data graph ${graphName} but the graph read back has another join than the file (for example on a newly added related object, or after a concurrent edit), so the change is not reported as updated. Other changes of the same PUT may have been applied: retrieve the graph to see its current state.`,
|
|
352
|
+
},
|
|
353
|
+
],
|
|
354
|
+
};
|
|
355
|
+
// Every PUT was refused with HTTP429/503 until the budget ran out: nothing was processed.
|
|
356
|
+
if (error instanceof NativeGraphWriteRefused)
|
|
357
|
+
return retainConnectDiagnostic({ outcome: 'failed', mutation: 'not-attempted' }, getConnectDiagnostic(error));
|
|
358
|
+
throw error;
|
|
359
|
+
}
|
|
360
|
+
return withOwner({
|
|
361
|
+
outcome,
|
|
362
|
+
mutation: outcome === 'updated' ? 'confirmed-updated' : 'not-attempted',
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
graphRequire(options.operation === 'deploy'
|
|
366
|
+
? before.state === 'absent'
|
|
367
|
+
: before.state === 'present' &&
|
|
368
|
+
before.observation.status === 'ready' &&
|
|
369
|
+
// Retrieve mode does not check these; the delete still needs its identity and a
|
|
370
|
+
// graph whose generated names are all there (not still being built).
|
|
371
|
+
before.observation.id.trim() !== '' &&
|
|
372
|
+
Number.isFinite(Date.parse(before.observation.createdDate)) &&
|
|
373
|
+
!nativeGraphStillGenerating({ ...before.observation.target, status: 'ready' }) &&
|
|
374
|
+
// Delete stays refused while any node or field reports dependencies or segments.
|
|
375
|
+
nativeDataGraphUnreferenced(before.observation.target.sourceObject));
|
|
376
|
+
await options.verifyInput();
|
|
377
|
+
graphRequire(isDeepStrictEqual(before, await acquire(document)) &&
|
|
378
|
+
isDeepStrictEqual(root, await bindNativeGraphRoot(context, rootName)) &&
|
|
379
|
+
context.orgId === orgId);
|
|
380
|
+
if (options.preview)
|
|
381
|
+
return withOwner({
|
|
382
|
+
outcome: options.operation === 'deploy' ? 'create' : 'delete',
|
|
383
|
+
mutation: 'not-attempted',
|
|
384
|
+
});
|
|
385
|
+
if (options.operation === 'deploy' && options.confirmed !== true)
|
|
386
|
+
return processingRequired('create');
|
|
387
|
+
graphRequire(options.confirmed === true);
|
|
388
|
+
if (options.operation === 'deploy') {
|
|
389
|
+
// Reuse the qualified create settlement; fixture ownership is not public delete authority.
|
|
390
|
+
const lifecycle = nativeDataGraphLifecycle(document, context, writer, {
|
|
391
|
+
record: async (phase) => {
|
|
392
|
+
await options.verifyInput();
|
|
393
|
+
if (phase === 'create-attempt')
|
|
394
|
+
graphRequire(isDeepStrictEqual(root, await bindNativeGraphRoot(context, rootName)) &&
|
|
395
|
+
isDeepStrictEqual(before, await acquire(document)));
|
|
396
|
+
},
|
|
397
|
+
safeToDelete: async () => false,
|
|
398
|
+
pause: options.pause,
|
|
399
|
+
now,
|
|
400
|
+
// Keep waiting while the created graph is still building, up to --wait-timeout.
|
|
401
|
+
creation: { started, end, pause: waitPause, progress },
|
|
402
|
+
});
|
|
403
|
+
creating = true;
|
|
404
|
+
const result = await lifecycle.create(true);
|
|
405
|
+
return retainConnectDiagnostic({
|
|
406
|
+
outcome: result.outcome === 'created'
|
|
407
|
+
? 'created'
|
|
408
|
+
: result.outcome === 'unknown'
|
|
409
|
+
? 'failed'
|
|
410
|
+
: 'blocked',
|
|
411
|
+
mutation: result.outcome === 'created'
|
|
412
|
+
? 'confirmed-created'
|
|
413
|
+
: result.mutation === 'attempted'
|
|
414
|
+
? 'unknown'
|
|
415
|
+
: 'not-attempted',
|
|
416
|
+
...(result.failedCheck ? { failedCheck: result.failedCheck } : {}),
|
|
417
|
+
}, getConnectDiagnostic(result) ?? diagnostic);
|
|
418
|
+
}
|
|
419
|
+
// The pre-check above required empty native node/field dependencies and segments.
|
|
420
|
+
// Compare all captured identity/date/definition fields again after local admission, immediately before dispatch.
|
|
421
|
+
await options.verifyInput();
|
|
422
|
+
graphRequire(isDeepStrictEqual(before, await acquire(document)) &&
|
|
423
|
+
isDeepStrictEqual(root, await bindNativeGraphRoot(context, rootName)));
|
|
424
|
+
context.check();
|
|
425
|
+
graphRequire(context.orgId === orgId);
|
|
426
|
+
// The DELETE answer decides: 2xx is deleted, an API 4xx is a refusal. No read-back:
|
|
427
|
+
// the by-name metadata read serves a stale copy for minutes after a delete (live, API68).
|
|
428
|
+
// HTTP429/503 was not processed: the identical DELETE is sent again within the budget.
|
|
429
|
+
try {
|
|
430
|
+
await sendNativeGraphWrite(async () => writer.delete(document.definition.name), 'delete', { now, end, pause: waitPause, progress });
|
|
431
|
+
}
|
|
432
|
+
catch (error) {
|
|
433
|
+
const evidence = getConnectDiagnostic(error);
|
|
434
|
+
if (error instanceof NativeGraphWriteRefused)
|
|
435
|
+
return retainConnectDiagnostic({ outcome: 'failed', mutation: 'not-attempted' }, evidence);
|
|
436
|
+
if (evidence?.kind === 'api-error' && evidence.statusCode >= 400 && evidence.statusCode < 500)
|
|
437
|
+
return retainConnectDiagnostic({ outcome: 'failed', mutation: 'rejected' }, evidence);
|
|
438
|
+
// Other 5xx or transport: the DELETE may have happened; never replay it.
|
|
439
|
+
throw error;
|
|
440
|
+
}
|
|
441
|
+
return { outcome: 'deleted', mutation: 'confirmed-deleted' };
|
|
442
|
+
};
|
|
443
|
+
try {
|
|
444
|
+
return await Promise.race([
|
|
445
|
+
work(),
|
|
446
|
+
new Promise((_resolve, reject) => {
|
|
447
|
+
const schedule = () => {
|
|
448
|
+
if (expired)
|
|
449
|
+
return;
|
|
450
|
+
const remaining = end - now();
|
|
451
|
+
if (remaining <= 0) {
|
|
452
|
+
expired = true;
|
|
453
|
+
reject(new Error('Native Graph deadline'));
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
// Node overflows longer delays to 1ms; retain the original invocation deadline.
|
|
457
|
+
timer = setTimeout(schedule, Math.min(remaining, 2_147_483_647));
|
|
458
|
+
};
|
|
459
|
+
schedule();
|
|
460
|
+
}),
|
|
461
|
+
]);
|
|
462
|
+
}
|
|
463
|
+
catch (error) {
|
|
464
|
+
// A file or graph of another data space, or a root of another one: refused before any write.
|
|
465
|
+
if (!attempted &&
|
|
466
|
+
error instanceof DataGraphError &&
|
|
467
|
+
(error.code === 'DATA_GRAPH_DATASPACE_MISMATCH' ||
|
|
468
|
+
error.code === 'DATA_GRAPH_DEPENDENCY_OTHER_DATASPACE'))
|
|
469
|
+
return {
|
|
470
|
+
outcome: 'blocked',
|
|
471
|
+
mutation: 'not-attempted',
|
|
472
|
+
diagnostics: [{ code: error.code, message: explanationOf(error) ?? error.message }],
|
|
473
|
+
};
|
|
474
|
+
return retainConnectDiagnostic({
|
|
475
|
+
outcome: attempted ? 'failed' : 'blocked',
|
|
476
|
+
mutation: attempted ? 'unknown' : 'not-attempted',
|
|
477
|
+
// The invocation deadline can fire before the create lifecycle reports its step.
|
|
478
|
+
...(attempted && creating ? { failedCheck: 'deadline' } : {}),
|
|
479
|
+
}, getConnectDiagnostic(error) ?? diagnostic);
|
|
480
|
+
}
|
|
481
|
+
finally {
|
|
482
|
+
expired = true;
|
|
483
|
+
clearTimeout(timer);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { DataStreamDeployClients, DataStreamDeployOptions, DataStreamDeleteClients, DataStreamDeleteOptions } from './native-data-stream.js';
|
|
2
|
+
type PublicDeleteOptions = Omit<DataStreamDeleteOptions, 'survivorDloNames'>;
|
|
3
|
+
/**
|
|
4
|
+
* Watch the first stream read of a delete: an exact HTTP 404 for the selected name means the
|
|
5
|
+
* stream is already gone (a rerun after it was deleted), not a failure.
|
|
6
|
+
* @template T
|
|
7
|
+
* @param {string} apiName Exact selected stream name.
|
|
8
|
+
* @param {T} clients Native clients.
|
|
9
|
+
* @returns {object} Clients with the watched read, and whether that first read answered 404.
|
|
10
|
+
*/
|
|
11
|
+
export declare function watchStreamAbsence<T extends {
|
|
12
|
+
streams: Pick<DataStreamDeleteClients['streams'], 'get'>;
|
|
13
|
+
}>(apiName: string, clients: T): {
|
|
14
|
+
clients: T;
|
|
15
|
+
absent: () => boolean;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Preview selected-stream/linked-parent deletion only; unrelated org objects are outside this scope.
|
|
19
|
+
* @param {string} apiName Exact selected stream name.
|
|
20
|
+
* @param {DataStreamDeleteClients} clients Independent native and dependency readers.
|
|
21
|
+
* @param {PublicDeleteOptions} options Explicit cascade acknowledgement and selection guard.
|
|
22
|
+
* @returns {Promise<object>} Payload-free preview, never private target identifiers.
|
|
23
|
+
*/
|
|
24
|
+
export declare function preflightDeleteDataStream(apiName: string, clients: DataStreamDeleteClients, options: PublicDeleteOptions): Promise<{
|
|
25
|
+
outcome: "unchanged";
|
|
26
|
+
mutation: "not-attempted";
|
|
27
|
+
deleteDlo: boolean;
|
|
28
|
+
} | {
|
|
29
|
+
plannedDependencies?: import("./native-data-stream.js").StreamDependent[] | undefined;
|
|
30
|
+
targetDloName?: string | undefined;
|
|
31
|
+
outcome: "delete" | "planned-dependencies";
|
|
32
|
+
mutation: "not-attempted";
|
|
33
|
+
deleteDlo: boolean;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Delete exactly the selected stream with linked-parent checks and actual-dispatch classification.
|
|
37
|
+
* @param {string} apiName Exact selected stream name.
|
|
38
|
+
* @param {DataStreamDeleteClients} clients Single-attempt native mutation and independent readers.
|
|
39
|
+
* @param {PublicDeleteOptions} options Cascade acknowledgement and immutable selection guard.
|
|
40
|
+
* @returns {Promise<object>} Confirmed deletion or payload-free blocked/unknown result.
|
|
41
|
+
*/
|
|
42
|
+
export declare function executeDeleteDataStream(apiName: string, clients: DataStreamDeleteClients, options: PublicDeleteOptions): Promise<{
|
|
43
|
+
outcome: "deleted";
|
|
44
|
+
mutation: "confirmed-deleted";
|
|
45
|
+
targetApiName: string;
|
|
46
|
+
targetDloName: string;
|
|
47
|
+
diagnostics: never[];
|
|
48
|
+
} | {
|
|
49
|
+
outcome: "unchanged";
|
|
50
|
+
mutation: "not-attempted";
|
|
51
|
+
diagnostics: never[];
|
|
52
|
+
targetApiName?: undefined;
|
|
53
|
+
targetDloName?: undefined;
|
|
54
|
+
} | {
|
|
55
|
+
outcome: "blocked" | "failed";
|
|
56
|
+
mutation: "unknown" | "not-attempted";
|
|
57
|
+
diagnostics: {
|
|
58
|
+
code: string;
|
|
59
|
+
message: string;
|
|
60
|
+
retryable: false;
|
|
61
|
+
}[];
|
|
62
|
+
targetApiName?: undefined;
|
|
63
|
+
targetDloName?: undefined;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Compare qualified stream configuration without exposing private source/schema/record identifiers.
|
|
67
|
+
* @param {unknown} value Portable stream intent.
|
|
68
|
+
* @param {DataStreamDeployClients} clients Independent target readers.
|
|
69
|
+
* @param {string} [dataSpace] The run's data space.
|
|
70
|
+
* @returns {Promise<object>} Public payload-free read-only preview.
|
|
71
|
+
*/
|
|
72
|
+
export declare function preflightDataStream(value: unknown, clients: DataStreamDeployClients, dataSpace?: string): Promise<{
|
|
73
|
+
diagnostics: never[];
|
|
74
|
+
changes?: string[] | undefined;
|
|
75
|
+
family: "data-stream";
|
|
76
|
+
outcome: "create" | "update" | "unchanged";
|
|
77
|
+
target: string;
|
|
78
|
+
absenceProof: string;
|
|
79
|
+
requiredEffects: string[];
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Dispatch through completed internal lifecycle helpers and classify failure at the actual write boundary.
|
|
83
|
+
* @param {unknown} value Portable stream intent.
|
|
84
|
+
* @param {DataStreamDeployClients} clients Native target clients.
|
|
85
|
+
* @param {DataStreamDeployOptions} options Exact local input guards and processing acknowledgement.
|
|
86
|
+
* @returns {Promise<object>} Public confirmed/unknown mutation result, without response payloads.
|
|
87
|
+
*/
|
|
88
|
+
export declare function executeDataStream(value: unknown, clients: DataStreamDeployClients, options: DataStreamDeployOptions): Promise<{
|
|
89
|
+
family: "data-stream";
|
|
90
|
+
outcome: "blocked" | "failed";
|
|
91
|
+
mutation: "unknown" | "not-attempted" | "rejected";
|
|
92
|
+
diagnostics: {
|
|
93
|
+
code: string;
|
|
94
|
+
message: string;
|
|
95
|
+
}[];
|
|
96
|
+
} | {
|
|
97
|
+
family: "data-stream";
|
|
98
|
+
outcome: "updated" | "unchanged" | "created";
|
|
99
|
+
mutation: "not-attempted" | "confirmed-created" | "confirmed-updated";
|
|
100
|
+
targetApiName: string;
|
|
101
|
+
targetDloName: string;
|
|
102
|
+
diagnostics: import("./native-data-stream.js").DataStreamNotice[];
|
|
103
|
+
}>;
|
|
104
|
+
export {};
|