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
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { Connection } from '@salesforce/core';
|
|
2
|
-
import type { DmoCreateRequest } from '../artifacts/dmo-document.js';
|
|
3
|
-
import type { DmoDocument } from '../artifacts/dmo-document.js';
|
|
4
|
-
type ReadConnection = Pick<Connection, 'instanceUrl' | 'request' | 'metadata' | 'getApiVersion'>;
|
|
5
|
-
export type DmoDeployPreview = {
|
|
6
|
-
outcome: 'create' | 'update' | 'unchanged' | 'blocked-changes' | 'blocked';
|
|
7
|
-
target: 'absent' | 'present' | 'unknown';
|
|
8
|
-
absenceProof: 'complete-inventory' | 'none';
|
|
9
|
-
diagnostics: Array<{
|
|
10
|
-
code: string;
|
|
11
|
-
message: string;
|
|
12
|
-
}>;
|
|
13
|
-
};
|
|
14
|
-
declare const messages: {
|
|
15
|
-
readonly INVALID_SOURCE: "Supply one valid authored-only DMO document bound to default.";
|
|
16
|
-
readonly INVALID_SCOPE: "Use an explicit API 65.0 connection and default target data space.";
|
|
17
|
-
readonly SOURCE_EXECUTION_UNSUPPORTED: "Execution requires Other category and a nondynamic Text primary key for qualified readback.";
|
|
18
|
-
readonly TARGET_AUTHENTICATION_FAILED: "Refresh target authentication, then repeat preview.";
|
|
19
|
-
readonly TARGET_INVENTORY_UNAVAILABLE: "Obtain a complete valid target inventory, then repeat preview.";
|
|
20
|
-
readonly TARGET_UNQUALIFIED: "Resolve target detail, Metadata, generated semantics and relationship qualification before deploying.";
|
|
21
|
-
readonly OBJECT_CHANGED: "Object label, description or date designation differs; update is not supported.";
|
|
22
|
-
readonly CATEGORY_CHANGED: "Object category differs; category migration is not supported.";
|
|
23
|
-
readonly FIELD_SET_CHANGED: "Authored field identities differ; adding, removing or renaming fields is not supported.";
|
|
24
|
-
readonly FIELD_CHANGED: "Authored field configuration differs; field updates are not supported.";
|
|
25
|
-
readonly IMMUTABLE_FIELD_CHANGED: "Field type or primary-key designation differs; immutable changes are not supported.";
|
|
26
|
-
readonly UPDATE_UNSUPPORTED: "Existing changes are blocked until the PATCH contract is proven; no delete/recreate fallback.";
|
|
27
|
-
};
|
|
28
|
-
type Code = keyof typeof messages;
|
|
29
|
-
/**
|
|
30
|
-
* Compare allowlisted authored meaning; exact field identities, not array positions, bind fields.
|
|
31
|
-
* Optional-property absence remains distinct from an explicitly supplied empty value.
|
|
32
|
-
* @param {DmoCreateRequest} source Independently mapped authored input.
|
|
33
|
-
* @param {DmoCreateRequest} target Independently mapped qualified target.
|
|
34
|
-
* @returns {Code[]} Deterministically ordered change reasons, without payload values.
|
|
35
|
-
*/
|
|
36
|
-
export declare function compareDmoMeaning(source: DmoCreateRequest, target: DmoCreateRequest): Code[];
|
|
37
|
-
/**
|
|
38
|
-
* Admit only evidenced object/non-primary existing-field label changes, atomically.
|
|
39
|
-
* The broader offline candidate is not execution authorization.
|
|
40
|
-
* @param {unknown} desired Authored input.
|
|
41
|
-
* @param {DmoDocument} current Fresh qualified target.
|
|
42
|
-
* @returns {ReturnType<typeof buildDmoUpdateDelta>} Safe label delta or blockers.
|
|
43
|
-
*/
|
|
44
|
-
export declare function buildExecutableDmoDelta(desired: unknown, current: DmoDocument): {
|
|
45
|
-
status: "blocked";
|
|
46
|
-
blockers: string[];
|
|
47
|
-
} | {
|
|
48
|
-
status: "unchanged";
|
|
49
|
-
blockers: [];
|
|
50
|
-
expected: DmoDocument;
|
|
51
|
-
} | {
|
|
52
|
-
status: "candidate";
|
|
53
|
-
blockers: [];
|
|
54
|
-
patch: import("../artifacts/dmo-update-delta.js").DmoUpdatePatch;
|
|
55
|
-
expected: DmoDocument;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Read-only preflight for one authored standalone DMO; never discovers files or mutates an org.
|
|
59
|
-
* Only the complete inventory contract proves absence; no HTTP error is treated as missing.
|
|
60
|
-
* Existing targets must pass the same full common retrieval semantics as authored export.
|
|
61
|
-
* @param {unknown} document One explicitly selected authored-only DMO document.
|
|
62
|
-
* @param {ReadConnection} connection Explicit authenticated target connection (core owns tokens).
|
|
63
|
-
* @param {unknown} apiVersion Explicit supported API version.
|
|
64
|
-
* @param {unknown} dataSpace Explicit target data space.
|
|
65
|
-
* @param {boolean} allowLabelUpdates Internal opt-in; public command remains create-only.
|
|
66
|
-
* @returns {Promise<DmoDeployPreview>} Deterministic payload-free classification and remediation.
|
|
67
|
-
*/
|
|
68
|
-
export declare function preflightDmoDeploy(document: unknown, connection: ReadConnection, apiVersion: unknown, dataSpace: unknown, allowLabelUpdates?: boolean): Promise<DmoDeployPreview>;
|
|
69
|
-
export {};
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { buildDmoCreateRequestFromDocument } from '../artifacts/dmo-document.js';
|
|
2
|
-
import { buildDmoUpdateDelta } from '../artifacts/dmo-update-delta.js';
|
|
3
|
-
import { ConnectClient, ConnectError } from '../transport/connect-client.js';
|
|
4
|
-
import { retrieveDmo } from './retrieve-other-dmo.js';
|
|
5
|
-
/**
|
|
6
|
-
* Reconstruct detached authored input from its already validated request.
|
|
7
|
-
* @param {DmoCreateRequest} request Mapped request.
|
|
8
|
-
* @returns {DmoDocument} Authored snapshot.
|
|
9
|
-
*/
|
|
10
|
-
function documentFromRequest(request) {
|
|
11
|
-
const { name, dataSpaceName, ...spec } = request;
|
|
12
|
-
return {
|
|
13
|
-
schemaVersion: 1,
|
|
14
|
-
kind: 'dmo',
|
|
15
|
-
identity: { apiName: `${name}__dlm`, dataSpace: dataSpaceName },
|
|
16
|
-
spec,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
const messages = {
|
|
20
|
-
INVALID_SOURCE: 'Supply one valid authored-only DMO document bound to default.',
|
|
21
|
-
INVALID_SCOPE: 'Use an explicit API 65.0 connection and default target data space.',
|
|
22
|
-
SOURCE_EXECUTION_UNSUPPORTED: 'Execution requires Other category and a nondynamic Text primary key for qualified readback.',
|
|
23
|
-
TARGET_AUTHENTICATION_FAILED: 'Refresh target authentication, then repeat preview.',
|
|
24
|
-
TARGET_INVENTORY_UNAVAILABLE: 'Obtain a complete valid target inventory, then repeat preview.',
|
|
25
|
-
TARGET_UNQUALIFIED: 'Resolve target detail, Metadata, generated semantics and relationship qualification before deploying.',
|
|
26
|
-
OBJECT_CHANGED: 'Object label, description or date designation differs; update is not supported.',
|
|
27
|
-
CATEGORY_CHANGED: 'Object category differs; category migration is not supported.',
|
|
28
|
-
FIELD_SET_CHANGED: 'Authored field identities differ; adding, removing or renaming fields is not supported.',
|
|
29
|
-
FIELD_CHANGED: 'Authored field configuration differs; field updates are not supported.',
|
|
30
|
-
IMMUTABLE_FIELD_CHANGED: 'Field type or primary-key designation differs; immutable changes are not supported.',
|
|
31
|
-
UPDATE_UNSUPPORTED: 'Existing changes are blocked until the PATCH contract is proven; no delete/recreate fallback.',
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Construct deterministic payload-free diagnostics, never remote errors or authored values.
|
|
35
|
-
* @param {string} outcome Preview classification.
|
|
36
|
-
* @param {string} target Established target state.
|
|
37
|
-
* @param {Code[]} codes Ordered diagnostic codes.
|
|
38
|
-
* @returns {DmoDeployPreview} Internal preview, not mutation authorization.
|
|
39
|
-
*/
|
|
40
|
-
function preview(outcome, target, codes = []) {
|
|
41
|
-
return {
|
|
42
|
-
outcome,
|
|
43
|
-
target,
|
|
44
|
-
absenceProof: target === 'absent' ? 'complete-inventory' : 'none',
|
|
45
|
-
diagnostics: codes.map((code) => ({ code, message: messages[code] })),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Compare allowlisted authored meaning; exact field identities, not array positions, bind fields.
|
|
50
|
-
* Optional-property absence remains distinct from an explicitly supplied empty value.
|
|
51
|
-
* @param {DmoCreateRequest} source Independently mapped authored input.
|
|
52
|
-
* @param {DmoCreateRequest} target Independently mapped qualified target.
|
|
53
|
-
* @returns {Code[]} Deterministically ordered change reasons, without payload values.
|
|
54
|
-
*/
|
|
55
|
-
export function compareDmoMeaning(source, target) {
|
|
56
|
-
const codes = [];
|
|
57
|
-
if (['label', 'description', 'eventDateTimeFieldName', 'recordModifiedFieldName'].some((key) => source[key] !== target[key]))
|
|
58
|
-
codes.push('OBJECT_CHANGED');
|
|
59
|
-
if (source.category !== target.category)
|
|
60
|
-
codes.push('CATEGORY_CHANGED');
|
|
61
|
-
const fields = new Map(target.fields.map((field) => [field.name, field]));
|
|
62
|
-
if (source.fields.length !== fields.size ||
|
|
63
|
-
source.fields.some((field) => !fields.has(field.name)))
|
|
64
|
-
codes.push('FIELD_SET_CHANGED');
|
|
65
|
-
let immutable = false;
|
|
66
|
-
let modified = false;
|
|
67
|
-
for (const field of source.fields) {
|
|
68
|
-
const current = fields.get(field.name);
|
|
69
|
-
if (!current)
|
|
70
|
-
continue;
|
|
71
|
-
immutable ||=
|
|
72
|
-
field.dataType !== current.dataType || field.isPrimaryKey !== current.isPrimaryKey;
|
|
73
|
-
modified ||= ['label', 'description', 'category', 'isDynamicLookup'].some((key) => field[key] !== current[key]);
|
|
74
|
-
}
|
|
75
|
-
if (immutable)
|
|
76
|
-
codes.push('IMMUTABLE_FIELD_CHANGED');
|
|
77
|
-
if (modified)
|
|
78
|
-
codes.push('FIELD_CHANGED');
|
|
79
|
-
return codes;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Admit only evidenced object/non-primary existing-field label changes, atomically.
|
|
83
|
-
* The broader offline candidate is not execution authorization.
|
|
84
|
-
* @param {unknown} desired Authored input.
|
|
85
|
-
* @param {DmoDocument} current Fresh qualified target.
|
|
86
|
-
* @returns {ReturnType<typeof buildDmoUpdateDelta>} Safe label delta or blockers.
|
|
87
|
-
*/
|
|
88
|
-
export function buildExecutableDmoDelta(desired, current) {
|
|
89
|
-
const delta = buildDmoUpdateDelta(desired, current, 'default');
|
|
90
|
-
if (delta.status !== 'candidate')
|
|
91
|
-
return delta;
|
|
92
|
-
if ('description' in delta.patch ||
|
|
93
|
-
delta.patch.fields?.some((field) => {
|
|
94
|
-
const prior = current.spec.fields.find((item) => item.name === field.name);
|
|
95
|
-
return !prior || prior.isPrimaryKey;
|
|
96
|
-
}))
|
|
97
|
-
return { status: 'blocked', blockers: ['UPDATE_UNPROVEN'] };
|
|
98
|
-
return delta;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Read-only preflight for one authored standalone DMO; never discovers files or mutates an org.
|
|
102
|
-
* Only the complete inventory contract proves absence; no HTTP error is treated as missing.
|
|
103
|
-
* Existing targets must pass the same full common retrieval semantics as authored export.
|
|
104
|
-
* @param {unknown} document One explicitly selected authored-only DMO document.
|
|
105
|
-
* @param {ReadConnection} connection Explicit authenticated target connection (core owns tokens).
|
|
106
|
-
* @param {unknown} apiVersion Explicit supported API version.
|
|
107
|
-
* @param {unknown} dataSpace Explicit target data space.
|
|
108
|
-
* @param {boolean} allowLabelUpdates Internal opt-in; public command remains create-only.
|
|
109
|
-
* @returns {Promise<DmoDeployPreview>} Deterministic payload-free classification and remediation.
|
|
110
|
-
*/
|
|
111
|
-
export async function preflightDmoDeploy(document, connection, apiVersion, dataSpace, allowLabelUpdates = false) {
|
|
112
|
-
let source;
|
|
113
|
-
try {
|
|
114
|
-
// Map before any read and detach the source from caller edits across asynchronous acquisition.
|
|
115
|
-
source = buildDmoCreateRequestFromDocument(document, 'default');
|
|
116
|
-
}
|
|
117
|
-
catch {
|
|
118
|
-
return preview('blocked', 'unknown', ['INVALID_SOURCE']);
|
|
119
|
-
}
|
|
120
|
-
// Offline mapping is broader than execution: reject authored properties that the
|
|
121
|
-
// common readback projector already knows cannot qualify, before any target read.
|
|
122
|
-
const primary = source.fields.find((field) => field.isPrimaryKey);
|
|
123
|
-
if (source.category !== 'Other' || primary.dataType !== 'Text' || primary.isDynamicLookup)
|
|
124
|
-
return preview('blocked', 'unknown', ['SOURCE_EXECUTION_UNSUPPORTED']);
|
|
125
|
-
try {
|
|
126
|
-
if (apiVersion !== '65.0' ||
|
|
127
|
-
dataSpace !== 'default' ||
|
|
128
|
-
connection.getApiVersion() !== apiVersion)
|
|
129
|
-
return preview('blocked', 'unknown', ['INVALID_SCOPE']);
|
|
130
|
-
const client = new ConnectClient(connection, apiVersion);
|
|
131
|
-
const inventory = await client.listDataModelObjects();
|
|
132
|
-
const apiName = `${source.name}__dlm`;
|
|
133
|
-
if (!inventory.some((item) => item.dataSpaceName === dataSpace && item.name === apiName))
|
|
134
|
-
return preview('create', 'absent');
|
|
135
|
-
try {
|
|
136
|
-
const acquired = await retrieveDmo(connection, apiName, apiVersion, dataSpace);
|
|
137
|
-
if (allowLabelUpdates) {
|
|
138
|
-
const delta = buildExecutableDmoDelta(documentFromRequest(source), acquired.candidate);
|
|
139
|
-
return delta.status === 'blocked'
|
|
140
|
-
? preview('blocked-changes', 'present', ['UPDATE_UNSUPPORTED'])
|
|
141
|
-
: preview(delta.status === 'candidate' ? 'update' : 'unchanged', 'present');
|
|
142
|
-
}
|
|
143
|
-
const target = buildDmoCreateRequestFromDocument(acquired.candidate, dataSpace);
|
|
144
|
-
const codes = compareDmoMeaning(source, target);
|
|
145
|
-
return codes.length === 0
|
|
146
|
-
? preview('unchanged', 'present')
|
|
147
|
-
: preview('blocked-changes', 'present', [...codes, 'UPDATE_UNSUPPORTED']);
|
|
148
|
-
}
|
|
149
|
-
catch {
|
|
150
|
-
// Inventory presence is not enough to infer authored equality or update feasibility.
|
|
151
|
-
return preview('blocked', 'present', ['TARGET_UNQUALIFIED']);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
catch (error) {
|
|
155
|
-
return preview('blocked', 'unknown', [
|
|
156
|
-
error instanceof ConnectError && error.code === 'AUTHENTICATION_FAILED'
|
|
157
|
-
? 'TARGET_AUTHENTICATION_FAILED'
|
|
158
|
-
: 'TARGET_INVENTORY_UNAVAILABLE',
|
|
159
|
-
]);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { Connection } from '@salesforce/core';
|
|
2
|
-
import type { DmoCommonProjection, DmoDocument } from '../artifacts/dmo-document.js';
|
|
3
|
-
/** Payload-free acquisition diagnostics; no remote errors or partial projections escape. */
|
|
4
|
-
export declare class DmoRetrieveError extends Error {
|
|
5
|
-
readonly code: string;
|
|
6
|
-
constructor(code: string);
|
|
7
|
-
}
|
|
8
|
-
type ReadConnection = Pick<Connection, 'instanceUrl' | 'request' | 'metadata' | 'getApiVersion'>;
|
|
9
|
-
/**
|
|
10
|
-
* Validate retrieval syntax and current scope before authentication or resource reads.
|
|
11
|
-
* @param {string[]} selectors Repeated type or exact selectors; empty means all implemented families.
|
|
12
|
-
* @param {string} apiVersion Explicit API version.
|
|
13
|
-
* @param {string} dataSpace Explicit source scope.
|
|
14
|
-
*/
|
|
15
|
-
export declare function validateDmoSelection(selectors: string[], apiVersion: string, dataSpace: string): void;
|
|
16
|
-
/**
|
|
17
|
-
* Expand complete inventory only for type/all selection; exact-only needs no list request.
|
|
18
|
-
* @param {ReadConnection} connection Authenticated core connection.
|
|
19
|
-
* @param {string[]} selectors Previously supplied selectors.
|
|
20
|
-
* @param {string} apiVersion Explicit API version.
|
|
21
|
-
* @param {string} dataSpace Explicit source scope.
|
|
22
|
-
* @returns {Promise<string[]>} Deduplicated, deterministically ordered exact names.
|
|
23
|
-
*/
|
|
24
|
-
export declare function selectDmos(connection: ReadConnection, selectors: string[], apiVersion: string, dataSpace: string): Promise<string[]>;
|
|
25
|
-
/**
|
|
26
|
-
* Read through core's Metadata/SOAP implementation with operation-local redirect refusal.
|
|
27
|
-
* Installed jsforce Metadata binds SOAP to _conn, bypassing Connection.request options.
|
|
28
|
-
* Shadow that receiver and transport only; retain core credentials, envelope and parser.
|
|
29
|
-
* @param {ReadConnection} connection Existing authenticated core connection.
|
|
30
|
-
* @param {string} objectApiName Exact independently validated DMO identity.
|
|
31
|
-
* @returns {Promise<unknown>} Untrusted parsed Metadata records, never a raw SOAP envelope.
|
|
32
|
-
*/
|
|
33
|
-
export declare function readDmoMetadata(connection: ReadConnection, objectApiName: string): Promise<unknown>;
|
|
34
|
-
/**
|
|
35
|
-
* Acquire complete API 65/default inputs and qualify them through the common DMO projector.
|
|
36
|
-
* Core owns authentication; Metadata read returns records, not a raw SOAP envelope.
|
|
37
|
-
* @param {ReadConnection} connection Existing authenticated Salesforce core connection at API 65.0.
|
|
38
|
-
* @param {unknown} objectApiName Exact non-namespaced custom DMO API name.
|
|
39
|
-
* @param {unknown} apiVersion Explicit supported API version, without fallback.
|
|
40
|
-
* @param {unknown} dataSpace Explicit supported source space, without fallback.
|
|
41
|
-
* @returns {Promise<DmoCommonProjection & { candidate: DmoDocument }>} Qualified projection and expectations.
|
|
42
|
-
*/
|
|
43
|
-
export declare function retrieveDmo(connection: ReadConnection, objectApiName: unknown, apiVersion: unknown, dataSpace: unknown): Promise<DmoCommonProjection & {
|
|
44
|
-
candidate: DmoDocument;
|
|
45
|
-
}>;
|
|
46
|
-
export {};
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { buildDmoCreateRequestFromDocument, DmoDocumentError, projectCommonDmoConnectMetadata, } from '../artifacts/dmo-document.js';
|
|
2
|
-
import { ConnectClient, ConnectError } from '../transport/connect-client.js';
|
|
3
|
-
/** Payload-free acquisition diagnostics; no remote errors or partial projections escape. */
|
|
4
|
-
export class DmoRetrieveError extends Error {
|
|
5
|
-
code;
|
|
6
|
-
constructor(code) {
|
|
7
|
-
super('DMO retrieval failed.');
|
|
8
|
-
this.code = code;
|
|
9
|
-
this.name = 'DmoRetrieveError';
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Validate retrieval syntax and current scope before authentication or resource reads.
|
|
14
|
-
* @param {string[]} selectors Repeated type or exact selectors; empty means all implemented families.
|
|
15
|
-
* @param {string} apiVersion Explicit API version.
|
|
16
|
-
* @param {string} dataSpace Explicit source scope.
|
|
17
|
-
*/
|
|
18
|
-
export function validateDmoSelection(selectors, apiVersion, dataSpace) {
|
|
19
|
-
if (selectors.some((selector) => !/^dmo(?::[A-Za-z][A-Za-z0-9_]*__dlm)?$/u.test(selector)))
|
|
20
|
-
throw new DmoRetrieveError('INVALID_SELECTION');
|
|
21
|
-
if (apiVersion !== '65.0' || dataSpace !== 'default')
|
|
22
|
-
throw new DmoRetrieveError('INVALID_SCOPE');
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Expand complete inventory only for type/all selection; exact-only needs no list request.
|
|
26
|
-
* @param {ReadConnection} connection Authenticated core connection.
|
|
27
|
-
* @param {string[]} selectors Previously supplied selectors.
|
|
28
|
-
* @param {string} apiVersion Explicit API version.
|
|
29
|
-
* @param {string} dataSpace Explicit source scope.
|
|
30
|
-
* @returns {Promise<string[]>} Deduplicated, deterministically ordered exact names.
|
|
31
|
-
*/
|
|
32
|
-
export async function selectDmos(connection, selectors, apiVersion, dataSpace) {
|
|
33
|
-
validateDmoSelection(selectors, apiVersion, dataSpace);
|
|
34
|
-
if (connection.getApiVersion() !== apiVersion)
|
|
35
|
-
throw new DmoRetrieveError('INVALID_SCOPE');
|
|
36
|
-
const names = selectors
|
|
37
|
-
.filter((selector) => selector !== 'dmo')
|
|
38
|
-
.map((selector) => selector.slice(4));
|
|
39
|
-
if (selectors.length === 0 || selectors.includes('dmo')) {
|
|
40
|
-
const inventory = await new ConnectClient(connection, apiVersion).listDataModelObjects();
|
|
41
|
-
for (const item of inventory) {
|
|
42
|
-
if (item.dataSpaceName !== dataSpace)
|
|
43
|
-
continue;
|
|
44
|
-
if (typeof item.name !== 'string' || !/^[A-Za-z][A-Za-z0-9_]*__dlm$/u.test(item.name))
|
|
45
|
-
throw new DmoRetrieveError('INVALID_INVENTORY');
|
|
46
|
-
names.push(item.name);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
// eslint-disable-next-line unicorn/no-array-sort -- The package TypeScript library target lacks toSorted; this array is newly allocated.
|
|
50
|
-
return [...new Set(names)].sort();
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Read through core's Metadata/SOAP implementation with operation-local redirect refusal.
|
|
54
|
-
* Installed jsforce Metadata binds SOAP to _conn, bypassing Connection.request options.
|
|
55
|
-
* Shadow that receiver and transport only; retain core credentials, envelope and parser.
|
|
56
|
-
* @param {ReadConnection} connection Existing authenticated core connection.
|
|
57
|
-
* @param {string} objectApiName Exact independently validated DMO identity.
|
|
58
|
-
* @returns {Promise<unknown>} Untrusted parsed Metadata records, never a raw SOAP envelope.
|
|
59
|
-
*/
|
|
60
|
-
export async function readDmoMetadata(connection, objectApiName) {
|
|
61
|
-
try {
|
|
62
|
-
const transport = connection._transport;
|
|
63
|
-
if (typeof transport?.httpRequest !== 'function')
|
|
64
|
-
throw new DmoRetrieveError('ACQUISITION_FAILED');
|
|
65
|
-
const receiver = Object.create(connection);
|
|
66
|
-
const guardedTransport = Object.create(transport);
|
|
67
|
-
guardedTransport.httpRequest = (request, options) => transport.httpRequest(request, {
|
|
68
|
-
...options,
|
|
69
|
-
followRedirect: () => {
|
|
70
|
-
throw new DmoRetrieveError('METADATA_REDIRECT_REFUSED');
|
|
71
|
-
},
|
|
72
|
-
retry: { maxRetries: 0 },
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(receiver, '_transport', { value: guardedTransport });
|
|
75
|
-
const metadata = Object.create(connection.metadata);
|
|
76
|
-
Object.defineProperty(metadata, '_conn', { value: receiver });
|
|
77
|
-
return await metadata.read('CustomObject', [objectApiName]);
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
if (error instanceof DmoRetrieveError)
|
|
81
|
-
throw error;
|
|
82
|
-
throw new DmoRetrieveError('ACQUISITION_FAILED');
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Acquire complete API 65/default inputs and qualify them through the common DMO projector.
|
|
87
|
-
* Core owns authentication; Metadata read returns records, not a raw SOAP envelope.
|
|
88
|
-
* @param {ReadConnection} connection Existing authenticated Salesforce core connection at API 65.0.
|
|
89
|
-
* @param {unknown} objectApiName Exact non-namespaced custom DMO API name.
|
|
90
|
-
* @param {unknown} apiVersion Explicit supported API version, without fallback.
|
|
91
|
-
* @param {unknown} dataSpace Explicit supported source space, without fallback.
|
|
92
|
-
* @returns {Promise<DmoCommonProjection & { candidate: DmoDocument }>} Qualified projection and expectations.
|
|
93
|
-
*/
|
|
94
|
-
export async function retrieveDmo(connection, objectApiName, apiVersion, dataSpace) {
|
|
95
|
-
if (apiVersion !== '65.0' || dataSpace !== 'default')
|
|
96
|
-
throw new DmoRetrieveError('INVALID_SCOPE');
|
|
97
|
-
if (typeof objectApiName !== 'string' ||
|
|
98
|
-
!/^[A-Za-z][A-Za-z0-9]*(?:_[A-Za-z0-9]+)*__dlm$/u.test(objectApiName) ||
|
|
99
|
-
/^ssot/iu.test(objectApiName))
|
|
100
|
-
throw new DmoRetrieveError('UNSUPPORTED_DMO_IDENTITY');
|
|
101
|
-
try {
|
|
102
|
-
// Metadata's SOAP endpoint uses the connection version, not the Connect URL version.
|
|
103
|
-
if (connection.getApiVersion() !== apiVersion)
|
|
104
|
-
throw new DmoRetrieveError('INVALID_SCOPE');
|
|
105
|
-
const client = new ConnectClient(connection, apiVersion);
|
|
106
|
-
const connect = await client.get(`/services/data/v${apiVersion}/ssot/data-model-objects/${objectApiName}`);
|
|
107
|
-
// Array input preserves record cardinality so missing/ambiguous reads cannot be selected away.
|
|
108
|
-
const records = await readDmoMetadata(connection, objectApiName);
|
|
109
|
-
if (!Array.isArray(records) || records.length !== 1)
|
|
110
|
-
throw new DmoRetrieveError('INVALID_METADATA');
|
|
111
|
-
const metadata = records[0];
|
|
112
|
-
if (!metadata ||
|
|
113
|
-
typeof metadata !== 'object' ||
|
|
114
|
-
Array.isArray(metadata) ||
|
|
115
|
-
!Object.hasOwn(metadata, 'fullName') ||
|
|
116
|
-
metadata.fullName !== objectApiName)
|
|
117
|
-
throw new DmoRetrieveError('INVALID_METADATA');
|
|
118
|
-
const relationships = await client.listDataModelObjectRelationships(objectApiName, dataSpace);
|
|
119
|
-
const projection = projectCommonDmoConnectMetadata(connect, metadata, relationships);
|
|
120
|
-
// Incomplete candidates are diagnostic only, including absent Engagement event designations.
|
|
121
|
-
if (projection.status !== 'projected' ||
|
|
122
|
-
projection.blockers.length > 0 ||
|
|
123
|
-
!projection.candidate)
|
|
124
|
-
throw new DmoRetrieveError(projection.blockers.includes('ENGAGEMENT_EVENT_DESIGNATION_UNAVAILABLE')
|
|
125
|
-
? 'ENGAGEMENT_EVENT_DESIGNATION_UNAVAILABLE'
|
|
126
|
-
: (projection.blockers[0] ?? 'INCOMPLETE_DMO_PROJECTION'));
|
|
127
|
-
const candidate = projection.candidate;
|
|
128
|
-
buildDmoCreateRequestFromDocument(candidate, dataSpace);
|
|
129
|
-
if (candidate.identity.apiName !== objectApiName)
|
|
130
|
-
throw new DmoRetrieveError('INVALID_METADATA');
|
|
131
|
-
return { ...projection, candidate };
|
|
132
|
-
}
|
|
133
|
-
catch (error) {
|
|
134
|
-
if (error instanceof DmoRetrieveError ||
|
|
135
|
-
error instanceof ConnectError ||
|
|
136
|
-
error instanceof DmoDocumentError)
|
|
137
|
-
throw error;
|
|
138
|
-
throw new DmoRetrieveError('ACQUISITION_FAILED');
|
|
139
|
-
}
|
|
140
|
-
}
|