sf-plugin-data 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +589 -2
- package/bin/run.js +4 -0
- package/docs/artifact-format.md +527 -0
- package/docs/capabilities.md +1208 -0
- package/docs/git-workflow.md +160 -0
- package/docs/handover.md +10446 -0
- package/lib/api.d.ts +7 -0
- package/lib/api.js +7 -0
- package/lib/artifacts/code-fields.d.ts +49 -0
- package/lib/artifacts/code-fields.js +142 -0
- package/lib/artifacts/data-graph-document.d.ts +29 -0
- package/lib/artifacts/data-graph-document.js +52 -0
- package/lib/artifacts/data-space-field.d.ts +65 -0
- package/lib/artifacts/data-space-field.js +98 -0
- package/lib/artifacts/data-stream-document.d.ts +264 -0
- package/lib/artifacts/data-stream-document.js +680 -0
- package/lib/artifacts/data-transform-document.d.ts +152 -0
- package/lib/artifacts/data-transform-document.js +560 -0
- package/lib/artifacts/dependency-selection.d.ts +51 -0
- package/lib/artifacts/dependency-selection.js +154 -0
- package/lib/artifacts/dlo-document.d.ts +93 -0
- package/lib/artifacts/dlo-document.js +253 -0
- package/lib/artifacts/enum-case.d.ts +39 -0
- package/lib/artifacts/enum-case.js +67 -0
- package/lib/artifacts/git-deploy-selection.d.ts +68 -0
- package/lib/artifacts/git-deploy-selection.js +474 -0
- package/lib/artifacts/identity-resolution-document.d.ts +133 -0
- package/lib/artifacts/identity-resolution-document.js +625 -0
- package/lib/artifacts/mapping-document.d.ts +1 -0
- package/lib/artifacts/mapping-document.js +1 -0
- package/lib/artifacts/native-calculated-insight-document.d.ts +142 -0
- package/lib/artifacts/native-calculated-insight-document.js +321 -0
- package/lib/artifacts/native-data-graph-document.d.ts +124 -0
- package/lib/artifacts/native-data-graph-document.js +780 -0
- package/lib/artifacts/native-dmo-document.d.ts +151 -0
- package/lib/artifacts/native-dmo-document.js +313 -0
- package/lib/artifacts/native-mapping-document.d.ts +67 -0
- package/lib/artifacts/native-mapping-document.js +187 -0
- package/lib/artifacts/native-relationship-document.d.ts +76 -0
- package/lib/artifacts/native-relationship-document.js +232 -0
- package/lib/artifacts/path-selector.d.ts +55 -0
- package/lib/artifacts/path-selector.js +167 -0
- package/lib/artifacts/read-deploy-input.d.ts +239 -0
- package/lib/artifacts/read-deploy-input.js +1359 -0
- package/lib/artifacts/segment-document.d.ts +183 -0
- package/lib/artifacts/segment-document.js +570 -0
- package/lib/artifacts/verbatim-document.d.ts +203 -0
- package/lib/artifacts/verbatim-document.js +339 -0
- package/lib/artifacts/write-data-graph.d.ts +17 -0
- package/lib/artifacts/write-data-graph.js +162 -0
- package/lib/artifacts/write-data-stream.d.ts +11 -0
- package/lib/artifacts/write-data-stream.js +175 -0
- package/lib/artifacts/write-data-transform.d.ts +11 -0
- package/lib/artifacts/write-data-transform.js +180 -0
- package/lib/artifacts/write-dlo.d.ts +11 -0
- package/lib/artifacts/write-dlo.js +158 -0
- package/lib/artifacts/write-identity-resolution.d.ts +18 -0
- package/lib/artifacts/write-identity-resolution.js +165 -0
- package/lib/artifacts/write-mapping-definition.d.ts +17 -0
- package/lib/artifacts/write-mapping-definition.js +127 -0
- package/lib/artifacts/write-member-export.d.ts +88 -0
- package/lib/artifacts/write-member-export.js +199 -0
- package/lib/artifacts/write-native-calculated-insight.d.ts +21 -0
- package/lib/artifacts/write-native-calculated-insight.js +176 -0
- package/lib/artifacts/write-native-dmo.d.ts +11 -0
- package/lib/artifacts/write-native-dmo.js +158 -0
- package/lib/artifacts/write-native-mapping.d.ts +11 -0
- package/lib/artifacts/write-native-mapping.js +157 -0
- package/lib/artifacts/write-native-relationship.d.ts +11 -0
- package/lib/artifacts/write-native-relationship.js +157 -0
- package/lib/artifacts/write-segment.d.ts +26 -0
- package/lib/artifacts/write-segment.js +212 -0
- package/lib/commands/data360/delete.d.ts +280 -0
- package/lib/commands/data360/delete.js +2297 -0
- package/lib/commands/data360/deploy.d.ts +303 -0
- package/lib/commands/data360/deploy.js +2400 -0
- package/lib/commands/data360/publish.d.ts +93 -0
- package/lib/commands/data360/publish.js +292 -0
- package/lib/commands/data360/retrieve.d.ts +322 -0
- package/lib/commands/data360/retrieve.js +1963 -0
- package/lib/commands/data360/segment/members/export.d.ts +101 -0
- package/lib/commands/data360/segment/members/export.js +318 -0
- package/lib/errors/codes/calculated-insight.d.ts +2 -0
- package/lib/errors/codes/calculated-insight.js +25 -0
- package/lib/errors/codes/data-graph.d.ts +2 -0
- package/lib/errors/codes/data-graph.js +22 -0
- package/lib/errors/codes/data-stream.d.ts +2 -0
- package/lib/errors/codes/data-stream.js +70 -0
- package/lib/errors/codes/data-transform.d.ts +2 -0
- package/lib/errors/codes/data-transform.js +35 -0
- package/lib/errors/codes/dependency.d.ts +2 -0
- package/lib/errors/codes/dependency.js +11 -0
- package/lib/errors/codes/dlo.d.ts +2 -0
- package/lib/errors/codes/dlo.js +31 -0
- package/lib/errors/codes/dmo.d.ts +2 -0
- package/lib/errors/codes/dmo.js +28 -0
- package/lib/errors/codes/general.d.ts +2 -0
- package/lib/errors/codes/general.js +57 -0
- package/lib/errors/codes/identity-resolution.d.ts +2 -0
- package/lib/errors/codes/identity-resolution.js +24 -0
- package/lib/errors/codes/mapping.d.ts +2 -0
- package/lib/errors/codes/mapping.js +42 -0
- package/lib/errors/codes/relationship.d.ts +2 -0
- package/lib/errors/codes/relationship.js +21 -0
- package/lib/errors/codes/segment.d.ts +2 -0
- package/lib/errors/codes/segment.js +49 -0
- package/lib/errors/registry.d.ts +60 -0
- package/lib/errors/registry.js +123 -0
- package/lib/plugin.d.ts +5 -0
- package/lib/plugin.js +5 -0
- package/lib/services/acquire-retrieve-selection.d.ts +43 -0
- package/lib/services/acquire-retrieve-selection.js +145 -0
- package/lib/services/bind-identity-resolution-dependencies.d.ts +53 -0
- package/lib/services/bind-identity-resolution-dependencies.js +238 -0
- package/lib/services/bind-segment-dependencies.d.ts +49 -0
- package/lib/services/bind-segment-dependencies.js +115 -0
- package/lib/services/bounded-reads.d.ts +17 -0
- package/lib/services/bounded-reads.js +42 -0
- package/lib/services/calculated-insight-sql-checks.d.ts +33 -0
- package/lib/services/calculated-insight-sql-checks.js +193 -0
- package/lib/services/command-dlo.d.ts +48 -0
- package/lib/services/command-dlo.js +103 -0
- package/lib/services/command-native-data-graph.d.ts +54 -0
- package/lib/services/command-native-data-graph.js +485 -0
- package/lib/services/command-native-data-stream.d.ts +104 -0
- package/lib/services/command-native-data-stream.js +257 -0
- package/lib/services/command-native-dmo.d.ts +124 -0
- package/lib/services/command-native-dmo.js +338 -0
- package/lib/services/command-native-mapping.d.ts +65 -0
- package/lib/services/command-native-mapping.js +129 -0
- package/lib/services/command-native-relationship.d.ts +46 -0
- package/lib/services/command-native-relationship.js +103 -0
- package/lib/services/cross-dataspace-deploy.d.ts +111 -0
- package/lib/services/cross-dataspace-deploy.js +493 -0
- package/lib/services/cross-dataspace-rename.d.ts +74 -0
- package/lib/services/cross-dataspace-rename.js +1314 -0
- package/lib/services/cross-dataspace-sql.d.ts +109 -0
- package/lib/services/cross-dataspace-sql.js +1301 -0
- package/lib/services/cross-space-context.d.ts +23 -0
- package/lib/services/cross-space-context.js +36 -0
- package/lib/services/crud-plan.d.ts +137 -0
- package/lib/services/crud-plan.js +408 -0
- package/lib/services/data-space-check.d.ts +89 -0
- package/lib/services/data-space-check.js +162 -0
- package/lib/services/data-space-prefix.d.ts +77 -0
- package/lib/services/data-space-prefix.js +127 -0
- package/lib/services/data-transform-space.d.ts +31 -0
- package/lib/services/data-transform-space.js +79 -0
- package/lib/services/delete-calculated-insight.d.ts +44 -0
- package/lib/services/delete-calculated-insight.js +101 -0
- package/lib/services/delete-data-transform.d.ts +52 -0
- package/lib/services/delete-data-transform.js +222 -0
- package/lib/services/delete-dmo-field.d.ts +211 -0
- package/lib/services/delete-dmo-field.js +472 -0
- package/lib/services/delete-identity-resolution.d.ts +43 -0
- package/lib/services/delete-identity-resolution.js +295 -0
- package/lib/services/delete-segment.d.ts +42 -0
- package/lib/services/delete-segment.js +248 -0
- package/lib/services/deploy-result.d.ts +54 -0
- package/lib/services/deploy-result.js +60 -0
- package/lib/services/escaped-copy.d.ts +23 -0
- package/lib/services/escaped-copy.js +88 -0
- package/lib/services/execute-calculated-insight-deploy.d.ts +42 -0
- package/lib/services/execute-calculated-insight-deploy.js +96 -0
- package/lib/services/execute-data-transform-deploy.d.ts +56 -0
- package/lib/services/execute-data-transform-deploy.js +168 -0
- package/lib/services/execute-native-identity-resolution-deploy.d.ts +48 -0
- package/lib/services/execute-native-identity-resolution-deploy.js +360 -0
- package/lib/services/execute-segment-deploy.d.ts +45 -0
- package/lib/services/execute-segment-deploy.js +393 -0
- package/lib/services/local-file-removal.d.ts +36 -0
- package/lib/services/local-file-removal.js +103 -0
- package/lib/services/native-calculated-insight.d.ts +87 -0
- package/lib/services/native-calculated-insight.js +164 -0
- package/lib/services/native-crm-data-stream.d.ts +91 -0
- package/lib/services/native-crm-data-stream.js +272 -0
- package/lib/services/native-data-graph-context.d.ts +12 -0
- package/lib/services/native-data-graph-context.js +139 -0
- package/lib/services/native-data-graph-crd.d.ts +261 -0
- package/lib/services/native-data-graph-crd.js +866 -0
- package/lib/services/native-data-stream.d.ts +329 -0
- package/lib/services/native-data-stream.js +1830 -0
- package/lib/services/native-dlo.d.ts +163 -0
- package/lib/services/native-dlo.js +402 -0
- package/lib/services/native-dmo.d.ts +191 -0
- package/lib/services/native-dmo.js +614 -0
- package/lib/services/native-mapping.d.ts +255 -0
- package/lib/services/native-mapping.js +1226 -0
- package/lib/services/native-relationship.d.ts +132 -0
- package/lib/services/native-relationship.js +512 -0
- package/lib/services/operation-diagnostic.d.ts +83 -0
- package/lib/services/operation-diagnostic.js +272 -0
- package/lib/services/preflight-calculated-insight-deploy.d.ts +58 -0
- package/lib/services/preflight-calculated-insight-deploy.js +95 -0
- package/lib/services/preflight-data-transform-deploy.d.ts +33 -0
- package/lib/services/preflight-data-transform-deploy.js +104 -0
- package/lib/services/preflight-identity-resolution-deploy.d.ts +107 -0
- package/lib/services/preflight-identity-resolution-deploy.js +281 -0
- package/lib/services/preflight-segment-deploy.d.ts +31 -0
- package/lib/services/preflight-segment-deploy.js +109 -0
- package/lib/services/publish-calculated-insight.d.ts +40 -0
- package/lib/services/publish-calculated-insight.js +95 -0
- package/lib/services/publish-segment.d.ts +65 -0
- package/lib/services/publish-segment.js +194 -0
- package/lib/services/readback-pace.d.ts +16 -0
- package/lib/services/readback-pace.js +23 -0
- package/lib/services/retrieve-data-transform.d.ts +26 -0
- package/lib/services/retrieve-data-transform.js +65 -0
- package/lib/services/retrieve-identity-resolution.d.ts +40 -0
- package/lib/services/retrieve-identity-resolution.js +87 -0
- package/lib/services/retrieve-inventory.d.ts +32 -0
- package/lib/services/retrieve-inventory.js +151 -0
- package/lib/services/retrieve-segment.d.ts +120 -0
- package/lib/services/retrieve-segment.js +502 -0
- package/lib/services/segment-lookup.d.ts +46 -0
- package/lib/services/segment-lookup.js +108 -0
- package/lib/services/segment-members.d.ts +144 -0
- package/lib/services/segment-members.js +402 -0
- package/lib/services/select-native-retrieve.d.ts +60 -0
- package/lib/services/select-native-retrieve.js +226 -0
- package/lib/services/settle-calculated-insight.d.ts +22 -0
- package/lib/services/settle-calculated-insight.js +53 -0
- package/lib/services/sql-tokens.d.ts +58 -0
- package/lib/services/sql-tokens.js +147 -0
- package/lib/transport/api-version.d.ts +36 -0
- package/lib/transport/api-version.js +89 -0
- package/lib/transport/bound-ssot.d.ts +27 -0
- package/lib/transport/bound-ssot.js +116 -0
- package/lib/transport/calculated-insight-rest.d.ts +28 -0
- package/lib/transport/calculated-insight-rest.js +62 -0
- package/lib/transport/connect-client.d.ts +129 -0
- package/lib/transport/connect-client.js +446 -0
- package/lib/transport/connect-diagnostic.d.ts +89 -0
- package/lib/transport/connect-diagnostic.js +331 -0
- package/lib/transport/data-graph-rest.d.ts +27 -0
- package/lib/transport/data-graph-rest.js +76 -0
- package/lib/transport/data-stream-rest.d.ts +62 -0
- package/lib/transport/data-stream-rest.js +348 -0
- package/lib/transport/data-transform-rest.d.ts +25 -0
- package/lib/transport/data-transform-rest.js +100 -0
- package/lib/transport/dlo-native-rest.d.ts +22 -0
- package/lib/transport/dlo-native-rest.js +89 -0
- package/lib/transport/dlo-rest.d.ts +23 -0
- package/lib/transport/dlo-rest.js +135 -0
- package/lib/transport/dmo-native-rest.d.ts +18 -0
- package/lib/transport/dmo-native-rest.js +55 -0
- package/lib/transport/dmo-rest.d.ts +30 -0
- package/lib/transport/dmo-rest.js +163 -0
- package/lib/transport/mapping-rest.d.ts +63 -0
- package/lib/transport/mapping-rest.js +341 -0
- package/lib/transport/project-metadata.d.ts +36 -0
- package/lib/transport/project-metadata.js +118 -0
- package/lib/transport/relationship-rest.d.ts +43 -0
- package/lib/transport/relationship-rest.js +201 -0
- package/package.json +96 -4
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type { DocumentMode } from './verbatim-document.js';
|
|
2
|
+
export type NativeDmoField = {
|
|
3
|
+
name: string;
|
|
4
|
+
label: string;
|
|
5
|
+
dataType: string;
|
|
6
|
+
isPrimaryKey: boolean;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
export type NativeDmoDocument = {
|
|
10
|
+
schemaVersion: 1;
|
|
11
|
+
kind: 'dmo';
|
|
12
|
+
/** The data space the DMO belongs to (file key `c__dataSpace`). */
|
|
13
|
+
c__dataSpace: string;
|
|
14
|
+
identity: {
|
|
15
|
+
apiName: string;
|
|
16
|
+
};
|
|
17
|
+
spec: {
|
|
18
|
+
label: string;
|
|
19
|
+
category: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
fields: NativeDmoField[];
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Compare categories the way the API does: input is case-insensitive, reads are upper case.
|
|
27
|
+
* @param {string} left One category spelling.
|
|
28
|
+
* @param {string} right Another category spelling.
|
|
29
|
+
* @returns {boolean} Whether both name the same category.
|
|
30
|
+
*/
|
|
31
|
+
export declare function sameDmoCategory(left: string, right: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* What may be written on an existing DMO, decided from its raw read alone.
|
|
34
|
+
* 'custom': every field and property this plugin writes.
|
|
35
|
+
* 'standard': custom fields, the object label and the object description only; fields of any
|
|
36
|
+
* other creationType are never sent or removed.
|
|
37
|
+
* 'refused': nothing (a read without a name).
|
|
38
|
+
*/
|
|
39
|
+
export type NativeDmoWriteScope = 'custom' | 'standard' | 'refused';
|
|
40
|
+
/**
|
|
41
|
+
* Classify an existing DMO for writes. A customer-created DMO with an unprefixed name is
|
|
42
|
+
* 'custom'. Every other read with a name is 'standard': Salesforce standard DMOs, the DMOs
|
|
43
|
+
* Salesforce generates (for example `Derived` and `Bridge` from identity resolution, `Adg` from
|
|
44
|
+
* data graphs, `Segment_Membership`), a custom creationType under a namespaced name and a read
|
|
45
|
+
* without a creationType. Salesforce does not protect the generated fields of those DMOs, so the
|
|
46
|
+
* standard scope keeps them out of every write; what Salesforce refuses on them it answers itself.
|
|
47
|
+
* @param {Record<string, unknown>} raw Direct native read.
|
|
48
|
+
* @returns {NativeDmoWriteScope} Write scope of the target.
|
|
49
|
+
*/
|
|
50
|
+
export declare function nativeDmoWriteScope(raw: Record<string, unknown>): NativeDmoWriteScope;
|
|
51
|
+
/**
|
|
52
|
+
* Whether a whole-DMO delete is sent. It is sent for every read that names the DMO, whatever its
|
|
53
|
+
* creationType (standard, generated, custom or none); Salesforce decides and its answer is
|
|
54
|
+
* reported as it comes.
|
|
55
|
+
* @param {Record<string, unknown>} raw Direct native read.
|
|
56
|
+
* @returns {boolean} Whether the delete is sent.
|
|
57
|
+
*/
|
|
58
|
+
export declare function isDeletableNativeDmo(raw: Record<string, unknown>): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Identify generated fields without borrowing DLO SourceVersion assumptions.
|
|
61
|
+
* @param {NativeDmoField} field Portable field.
|
|
62
|
+
* @returns {boolean} Whether writes must omit the field.
|
|
63
|
+
*/
|
|
64
|
+
export declare function isGeneratedDmoField(field: NativeDmoField): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Keep the authored content of a DMO definition: generated fields (system fields, key qualifiers
|
|
67
|
+
* and every field read as System) are left out; a deploy keeps them from the org when the file
|
|
68
|
+
* omits them. Primary keys and the standard fields of a standard DMO stay: a deploy compares a
|
|
69
|
+
* listed standard field, and a definition needs at least one field. Fields are sorted by name:
|
|
70
|
+
* Salesforce returns them in an order that varies between reads, and a deploy matches them by
|
|
71
|
+
* name, so the order carries no meaning.
|
|
72
|
+
* @param {NativeDmoDocument} document Complete definition as read.
|
|
73
|
+
* @returns {NativeDmoDocument} Independent copy without generated fields, fields sorted by name.
|
|
74
|
+
*/
|
|
75
|
+
export declare function leanNativeDmoDocument(document: NativeDmoDocument): NativeDmoDocument;
|
|
76
|
+
/** Payload-free refusal for the isolated native DMO boundary. */
|
|
77
|
+
export declare class NativeDmoError extends Error {
|
|
78
|
+
readonly code: string;
|
|
79
|
+
readonly status?: number | undefined;
|
|
80
|
+
readonly rejected?: true | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* @param {string} code Stable plugin code.
|
|
83
|
+
* @param {number} [status] HTTP status of Salesforce's answer.
|
|
84
|
+
* @param {true} [rejected] Salesforce answered with a refusal, so nothing was changed.
|
|
85
|
+
*/
|
|
86
|
+
constructor(code: string, status?: number | undefined, rejected?: true | undefined);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The default spelling of a standard DMO copy in a non-default data space. Salesforce names the
|
|
90
|
+
* copy of `ssot__<Name>__dlm` `<prefix>_<Name>__dlm` there, with fields without `ssot__`
|
|
91
|
+
* (live API 68, DB entry data360:dataspace-name-spelling-api68). Only this rule is derived: a
|
|
92
|
+
* name without the data space prefix, the default data space or no prefix give undefined, and
|
|
93
|
+
* a standard DMO without `ssot__` (such as `StaticCurrencyRates_Home__dlm`) is never derived.
|
|
94
|
+
* Whether the result is a standard DMO is for the caller's read to prove.
|
|
95
|
+
* @param {string} name DMO name as the file names it.
|
|
96
|
+
* @param {string} dataSpace The run's data space.
|
|
97
|
+
* @param {string} [prefix] The prefix the org's data space list names for it.
|
|
98
|
+
* @returns {string | undefined} `ssot__<Name>__dlm`, or undefined.
|
|
99
|
+
*/
|
|
100
|
+
export declare function standardCopyOrigin(name: string, dataSpace: string, prefix: string | undefined): string | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* Every default-data-space name a `<prefix>_<Name>__dlm` DMO can be the standard copy of:
|
|
103
|
+
* `ssot__<Name>__dlm` (as standardCopyOrigin) and `<Name>__dlm`, for a standard DMO without
|
|
104
|
+
* `ssot__` such as `StaticCurrencyRates_Home__dlm` (live API 68: its dataspace2 copy is
|
|
105
|
+
* `ds2_StaticCurrencyRates_Home__dlm`, DB entry data360:dataspace-prefixed-unique-names-api68).
|
|
106
|
+
* The same conditions as standardCopyOrigin give an empty list. Which candidate, if any, is a
|
|
107
|
+
* Standard DMO of the default data space is for the caller's read to prove; a custom DMO of
|
|
108
|
+
* either name is no origin.
|
|
109
|
+
* @param {string} name DMO name as the file names it.
|
|
110
|
+
* @param {string} dataSpace The run's data space.
|
|
111
|
+
* @param {string} [prefix] The prefix the org's data space list names for it.
|
|
112
|
+
* @returns {string[]} The candidates, `ssot__` spelling first.
|
|
113
|
+
*/
|
|
114
|
+
export declare function standardCopyOrigins(name: string, dataSpace: string, prefix: string | undefined): string[];
|
|
115
|
+
/**
|
|
116
|
+
* The name a field of the default-spelling standard DMO has on its copy: `ssot__X__c` is
|
|
117
|
+
* `X__c`, any other field (`KQ_`, unprefixed) keeps its name.
|
|
118
|
+
* @param {string} name Field name on the default object.
|
|
119
|
+
* @returns {string} Field name on the copy.
|
|
120
|
+
*/
|
|
121
|
+
export declare function standardCopyFieldName(name: string): string;
|
|
122
|
+
export declare const nativeDmoFieldName: RegExp;
|
|
123
|
+
/**
|
|
124
|
+
* Validate the document shape, retaining field definitions and any extra spec keys. Category,
|
|
125
|
+
* data types, label length and key rules are left to the API. Deploy mode (the default) admits
|
|
126
|
+
* only what a deploy can send and names the first offending key path; retrieve mode keeps what
|
|
127
|
+
* the org returned and checks only what names and places the file.
|
|
128
|
+
* @param {unknown} value Portable input.
|
|
129
|
+
* @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (lenient).
|
|
130
|
+
* @returns {NativeDmoDocument} Checked independent copy.
|
|
131
|
+
*/
|
|
132
|
+
export declare function validateNativeDmoDocument(value: unknown, mode?: DocumentMode): NativeDmoDocument;
|
|
133
|
+
/**
|
|
134
|
+
* Unwrap only the direct single-object native DMO representation.
|
|
135
|
+
* @param {unknown} value Native response.
|
|
136
|
+
* @returns {Record<string, unknown>} Direct object.
|
|
137
|
+
*/
|
|
138
|
+
export declare function unwrapNativeDmo(value: unknown): Record<string, unknown>;
|
|
139
|
+
/**
|
|
140
|
+
* Map the read field `type` to the authored `dataType` and keep definition fields, not runtime IDs.
|
|
141
|
+
* Retrieve mode keeps what the plugin cannot map as returned: a field without `type`, or with a
|
|
142
|
+
* `dataType` that differs from it, keeps both keys; a non-boolean `isPrimaryKey` stays; a read
|
|
143
|
+
* without `dataSpaceName` takes the data space it was requested in. A DMO of another data space
|
|
144
|
+
* is UNSUPPORTED_DMO_DATASPACE.
|
|
145
|
+
* @param {unknown} value Direct native response.
|
|
146
|
+
* @param {string} dataSpace The run's data space.
|
|
147
|
+
* @param {DocumentMode} [mode] `retrieve` (lenient) or `deploy` (strict, the default).
|
|
148
|
+
* @returns {NativeDmoDocument} Portable definition with authoritative observed scope.
|
|
149
|
+
*/
|
|
150
|
+
export declare function normalizeNativeDmo(value: unknown, dataSpace: string, mode?: DocumentMode): NativeDmoDocument;
|
|
151
|
+
export { nativeDmoName } from './path-selector.js';
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { nativeDmoName } from './path-selector.js';
|
|
2
|
+
import { explainInput, printableKey } from '../services/operation-diagnostic.js';
|
|
3
|
+
import { sameEnum } from './enum-case.js';
|
|
4
|
+
import { dataSpaceKey, readSingleDataSpace, refuseLegacyDataSpace } from './data-space-field.js';
|
|
5
|
+
/**
|
|
6
|
+
* Compare categories the way the API does: input is case-insensitive, reads are upper case.
|
|
7
|
+
* @param {string} left One category spelling.
|
|
8
|
+
* @param {string} right Another category spelling.
|
|
9
|
+
* @returns {boolean} Whether both name the same category.
|
|
10
|
+
*/
|
|
11
|
+
export function sameDmoCategory(left, right) {
|
|
12
|
+
return sameEnum(left, right);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Classify an existing DMO for writes. A customer-created DMO with an unprefixed name is
|
|
16
|
+
* 'custom'. Every other read with a name is 'standard': Salesforce standard DMOs, the DMOs
|
|
17
|
+
* Salesforce generates (for example `Derived` and `Bridge` from identity resolution, `Adg` from
|
|
18
|
+
* data graphs, `Segment_Membership`), a custom creationType under a namespaced name and a read
|
|
19
|
+
* without a creationType. Salesforce does not protect the generated fields of those DMOs, so the
|
|
20
|
+
* standard scope keeps them out of every write; what Salesforce refuses on them it answers itself.
|
|
21
|
+
* @param {Record<string, unknown>} raw Direct native read.
|
|
22
|
+
* @returns {NativeDmoWriteScope} Write scope of the target.
|
|
23
|
+
*/
|
|
24
|
+
export function nativeDmoWriteScope(raw) {
|
|
25
|
+
if (typeof raw.name !== 'string')
|
|
26
|
+
return 'refused';
|
|
27
|
+
return raw.creationType === 'Custom' && !raw.name.slice(0, -'__dlm'.length).includes('__')
|
|
28
|
+
? 'custom'
|
|
29
|
+
: 'standard';
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Whether a whole-DMO delete is sent. It is sent for every read that names the DMO, whatever its
|
|
33
|
+
* creationType (standard, generated, custom or none); Salesforce decides and its answer is
|
|
34
|
+
* reported as it comes.
|
|
35
|
+
* @param {Record<string, unknown>} raw Direct native read.
|
|
36
|
+
* @returns {boolean} Whether the delete is sent.
|
|
37
|
+
*/
|
|
38
|
+
export function isDeletableNativeDmo(raw) {
|
|
39
|
+
return typeof raw.name === 'string';
|
|
40
|
+
}
|
|
41
|
+
const dmoSystemFields = new Set([
|
|
42
|
+
'DataSource__c',
|
|
43
|
+
'DataSourceObject__c',
|
|
44
|
+
'InternalOrganization__c',
|
|
45
|
+
]);
|
|
46
|
+
/**
|
|
47
|
+
* Identify generated fields without borrowing DLO SourceVersion assumptions.
|
|
48
|
+
* @param {NativeDmoField} field Portable field.
|
|
49
|
+
* @returns {boolean} Whether writes must omit the field.
|
|
50
|
+
*/
|
|
51
|
+
export function isGeneratedDmoField(field) {
|
|
52
|
+
return (dmoSystemFields.has(field.name) ||
|
|
53
|
+
(typeof field.name === 'string' && field.name.startsWith('KQ_')) ||
|
|
54
|
+
field.creationType === 'System');
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Keep the authored content of a DMO definition: generated fields (system fields, key qualifiers
|
|
58
|
+
* and every field read as System) are left out; a deploy keeps them from the org when the file
|
|
59
|
+
* omits them. Primary keys and the standard fields of a standard DMO stay: a deploy compares a
|
|
60
|
+
* listed standard field, and a definition needs at least one field. Fields are sorted by name:
|
|
61
|
+
* Salesforce returns them in an order that varies between reads, and a deploy matches them by
|
|
62
|
+
* name, so the order carries no meaning.
|
|
63
|
+
* @param {NativeDmoDocument} document Complete definition as read.
|
|
64
|
+
* @returns {NativeDmoDocument} Independent copy without generated fields, fields sorted by name.
|
|
65
|
+
*/
|
|
66
|
+
export function leanNativeDmoDocument(document) {
|
|
67
|
+
const lean = structuredClone(document);
|
|
68
|
+
lean.spec.fields = lean.spec.fields
|
|
69
|
+
.filter((field) => field.isPrimaryKey || !isGeneratedDmoField(field))
|
|
70
|
+
// eslint-disable-next-line unicorn/no-array-sort -- Sort a fresh filtered array within the ES2022 library target.
|
|
71
|
+
.sort((left, right) => (left.name < right.name ? -1 : left.name > right.name ? 1 : 0));
|
|
72
|
+
return lean;
|
|
73
|
+
}
|
|
74
|
+
/** Payload-free refusal for the isolated native DMO boundary. */
|
|
75
|
+
export class NativeDmoError extends Error {
|
|
76
|
+
code;
|
|
77
|
+
status;
|
|
78
|
+
rejected;
|
|
79
|
+
/**
|
|
80
|
+
* @param {string} code Stable plugin code.
|
|
81
|
+
* @param {number} [status] HTTP status of Salesforce's answer.
|
|
82
|
+
* @param {true} [rejected] Salesforce answered with a refusal, so nothing was changed.
|
|
83
|
+
*/
|
|
84
|
+
constructor(code, status, rejected) {
|
|
85
|
+
super(`Native DMO operation refused: ${code}.`);
|
|
86
|
+
this.code = code;
|
|
87
|
+
this.status = status;
|
|
88
|
+
this.rejected = rejected;
|
|
89
|
+
this.name = 'NativeDmoError';
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The default spelling of a standard DMO copy in a non-default data space. Salesforce names the
|
|
94
|
+
* copy of `ssot__<Name>__dlm` `<prefix>_<Name>__dlm` there, with fields without `ssot__`
|
|
95
|
+
* (live API 68, DB entry data360:dataspace-name-spelling-api68). Only this rule is derived: a
|
|
96
|
+
* name without the data space prefix, the default data space or no prefix give undefined, and
|
|
97
|
+
* a standard DMO without `ssot__` (such as `StaticCurrencyRates_Home__dlm`) is never derived.
|
|
98
|
+
* Whether the result is a standard DMO is for the caller's read to prove.
|
|
99
|
+
* @param {string} name DMO name as the file names it.
|
|
100
|
+
* @param {string} dataSpace The run's data space.
|
|
101
|
+
* @param {string} [prefix] The prefix the org's data space list names for it.
|
|
102
|
+
* @returns {string | undefined} `ssot__<Name>__dlm`, or undefined.
|
|
103
|
+
*/
|
|
104
|
+
export function standardCopyOrigin(name, dataSpace, prefix) {
|
|
105
|
+
if (dataSpace === 'default' || prefix === undefined || !name.startsWith(`${prefix}_`))
|
|
106
|
+
return undefined;
|
|
107
|
+
const spelling = `ssot__${name.slice(prefix.length + 1)}`;
|
|
108
|
+
return nativeDmoName.test(spelling) ? spelling : undefined;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Every default-data-space name a `<prefix>_<Name>__dlm` DMO can be the standard copy of:
|
|
112
|
+
* `ssot__<Name>__dlm` (as standardCopyOrigin) and `<Name>__dlm`, for a standard DMO without
|
|
113
|
+
* `ssot__` such as `StaticCurrencyRates_Home__dlm` (live API 68: its dataspace2 copy is
|
|
114
|
+
* `ds2_StaticCurrencyRates_Home__dlm`, DB entry data360:dataspace-prefixed-unique-names-api68).
|
|
115
|
+
* The same conditions as standardCopyOrigin give an empty list. Which candidate, if any, is a
|
|
116
|
+
* Standard DMO of the default data space is for the caller's read to prove; a custom DMO of
|
|
117
|
+
* either name is no origin.
|
|
118
|
+
* @param {string} name DMO name as the file names it.
|
|
119
|
+
* @param {string} dataSpace The run's data space.
|
|
120
|
+
* @param {string} [prefix] The prefix the org's data space list names for it.
|
|
121
|
+
* @returns {string[]} The candidates, `ssot__` spelling first.
|
|
122
|
+
*/
|
|
123
|
+
export function standardCopyOrigins(name, dataSpace, prefix) {
|
|
124
|
+
const first = standardCopyOrigin(name, dataSpace, prefix);
|
|
125
|
+
if (first === undefined)
|
|
126
|
+
return [];
|
|
127
|
+
const plain = name.slice(prefix.length + 1);
|
|
128
|
+
return nativeDmoName.test(plain) && !plain.slice(0, -'__dlm'.length).includes('__')
|
|
129
|
+
? [first, plain]
|
|
130
|
+
: [first];
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The name a field of the default-spelling standard DMO has on its copy: `ssot__X__c` is
|
|
134
|
+
* `X__c`, any other field (`KQ_`, unprefixed) keeps its name.
|
|
135
|
+
* @param {string} name Field name on the default object.
|
|
136
|
+
* @returns {string} Field name on the copy.
|
|
137
|
+
*/
|
|
138
|
+
export function standardCopyFieldName(name) {
|
|
139
|
+
return name.startsWith('ssot__') ? name.slice('ssot__'.length) : name;
|
|
140
|
+
}
|
|
141
|
+
export const nativeDmoFieldName = /^[A-Za-z][A-Za-z0-9_]{0,239}__c$/u;
|
|
142
|
+
const runtimeKeys = new Set([
|
|
143
|
+
'id',
|
|
144
|
+
'recordId',
|
|
145
|
+
'recordID',
|
|
146
|
+
'createdDate',
|
|
147
|
+
'lastModifiedDate',
|
|
148
|
+
'isEnabled',
|
|
149
|
+
'isEditable',
|
|
150
|
+
'isSegmentable',
|
|
151
|
+
'status',
|
|
152
|
+
]);
|
|
153
|
+
/**
|
|
154
|
+
* Require a JSON object.
|
|
155
|
+
* @param {unknown} value Untrusted input.
|
|
156
|
+
* @returns {Record<string, unknown>} Object content.
|
|
157
|
+
*/
|
|
158
|
+
function record(value) {
|
|
159
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
160
|
+
throw new NativeDmoError('INVALID_DMO_DOCUMENT');
|
|
161
|
+
return value;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Refuse an authored DMO file, naming the key path that cannot be deployed.
|
|
165
|
+
* @param {string} code Refusal code.
|
|
166
|
+
* @param {string} keyPath Printable key path.
|
|
167
|
+
* @param {string} problem What is wrong with it.
|
|
168
|
+
* @returns {NativeDmoError} Refusal with an explanation.
|
|
169
|
+
*/
|
|
170
|
+
function refuse(code, keyPath, problem) {
|
|
171
|
+
return explainInput(new NativeDmoError(code), `The DMO file cannot be deployed: ${keyPath} ${problem}. Correct the file, or retrieve the DMO again once the plugin supports it.`);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Require a JSON object at a key path of the file.
|
|
175
|
+
* @param {unknown} value Untrusted input.
|
|
176
|
+
* @param {string} keyPath Printable key path.
|
|
177
|
+
* @returns {Record<string, unknown>} Object content.
|
|
178
|
+
*/
|
|
179
|
+
function objectAt(value, keyPath) {
|
|
180
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
181
|
+
throw refuse('INVALID_DMO_DOCUMENT', keyPath, 'must be an object');
|
|
182
|
+
return value;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Validate the document shape, retaining field definitions and any extra spec keys. Category,
|
|
186
|
+
* data types, label length and key rules are left to the API. Deploy mode (the default) admits
|
|
187
|
+
* only what a deploy can send and names the first offending key path; retrieve mode keeps what
|
|
188
|
+
* the org returned and checks only what names and places the file.
|
|
189
|
+
* @param {unknown} value Portable input.
|
|
190
|
+
* @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (lenient).
|
|
191
|
+
* @returns {NativeDmoDocument} Checked independent copy.
|
|
192
|
+
*/
|
|
193
|
+
export function validateNativeDmoDocument(value, mode = 'deploy') {
|
|
194
|
+
const document = objectAt(value, 'the document');
|
|
195
|
+
const identity = objectAt(document.identity, 'identity');
|
|
196
|
+
const spec = objectAt(document.spec, 'spec');
|
|
197
|
+
if (document.schemaVersion !== 1)
|
|
198
|
+
throw refuse('INVALID_DMO_DOCUMENT', 'schemaVersion', 'must be 1');
|
|
199
|
+
if (document.kind !== 'dmo')
|
|
200
|
+
throw refuse('INVALID_DMO_DOCUMENT', 'kind', 'must be "dmo"');
|
|
201
|
+
if (typeof identity.apiName !== 'string' || !nativeDmoName.test(identity.apiName))
|
|
202
|
+
throw refuse('INVALID_DMO_DOCUMENT', 'identity.apiName', 'must be a DMO API name ending in __dlm');
|
|
203
|
+
refuseLegacyDataSpace(identity, refuse);
|
|
204
|
+
readSingleDataSpace(document, refuse);
|
|
205
|
+
if (!Array.isArray(spec.fields))
|
|
206
|
+
throw refuse('INVALID_DMO_DOCUMENT', 'spec.fields', 'must be a list of fields');
|
|
207
|
+
const fields = spec.fields.map((field, index) => objectAt(field, `spec.fields[${index}]`));
|
|
208
|
+
if (mode === 'retrieve')
|
|
209
|
+
return structuredClone(value);
|
|
210
|
+
for (const key of Object.keys(document))
|
|
211
|
+
if (![dataSpaceKey, 'identity', 'kind', 'schemaVersion', 'spec'].includes(key))
|
|
212
|
+
throw refuse('INVALID_DMO_DOCUMENT', printableKey(key), 'is not a key a DMO file can hold');
|
|
213
|
+
for (const key of Object.keys(identity))
|
|
214
|
+
if (key !== 'apiName')
|
|
215
|
+
throw refuse('INVALID_DMO_DOCUMENT', `identity.${printableKey(key)}`, 'is not a key a DMO file can hold');
|
|
216
|
+
// Identity lives in `identity`; runtime observations are never authored input.
|
|
217
|
+
const observed = Object.keys(spec).find((key) => key === 'name' || key === 'dataSpaceName' || runtimeKeys.has(key));
|
|
218
|
+
if (observed !== undefined)
|
|
219
|
+
throw refuse('INVALID_DMO_DOCUMENT', `spec.${observed}`, 'is not a key a DMO file can hold');
|
|
220
|
+
if (typeof spec.label !== 'string' || !spec.label.trim())
|
|
221
|
+
throw refuse('INVALID_DMO_DOCUMENT', 'spec.label', 'must be a non-empty text');
|
|
222
|
+
if (typeof spec.category !== 'string' || !spec.category.trim())
|
|
223
|
+
throw refuse('INVALID_DMO_DOCUMENT', 'spec.category', 'must be a category name');
|
|
224
|
+
if (spec.description !== undefined && typeof spec.description !== 'string')
|
|
225
|
+
throw refuse('INVALID_DMO_DOCUMENT', 'spec.description', 'must be a text');
|
|
226
|
+
if (fields.length === 0)
|
|
227
|
+
throw refuse('INVALID_DMO_DOCUMENT', 'spec.fields', 'must list at least one field');
|
|
228
|
+
const names = new Set();
|
|
229
|
+
for (const [index, field] of fields.entries()) {
|
|
230
|
+
const at = `spec.fields[${index}]`;
|
|
231
|
+
const unknown = Object.keys(field).find((key) => runtimeKeys.has(key) || key === 'type');
|
|
232
|
+
if (unknown !== undefined)
|
|
233
|
+
throw refuse('INVALID_DMO_FIELD', `${at}.${unknown}`, 'is not a key a DMO file can hold');
|
|
234
|
+
if (typeof field.name !== 'string' || !nativeDmoFieldName.test(field.name))
|
|
235
|
+
throw refuse('INVALID_DMO_FIELD', `${at}.name`, 'must be a field API name ending in __c');
|
|
236
|
+
if (names.has(field.name.toLowerCase()))
|
|
237
|
+
throw refuse('INVALID_DMO_FIELD', `${at}.name`, 'repeats the name of another field');
|
|
238
|
+
if (typeof field.label !== 'string' || !field.label.trim())
|
|
239
|
+
throw refuse('INVALID_DMO_FIELD', `${at}.label`, 'must be a non-empty text');
|
|
240
|
+
if (typeof field.dataType !== 'string' || !field.dataType)
|
|
241
|
+
throw refuse('INVALID_DMO_FIELD', `${at}.dataType`, 'must be a data type name');
|
|
242
|
+
if (typeof field.isPrimaryKey !== 'boolean')
|
|
243
|
+
throw refuse('INVALID_DMO_FIELD', `${at}.isPrimaryKey`, 'must be true or false');
|
|
244
|
+
names.add(field.name.toLowerCase());
|
|
245
|
+
}
|
|
246
|
+
return structuredClone(value);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Unwrap only the direct single-object native DMO representation.
|
|
250
|
+
* @param {unknown} value Native response.
|
|
251
|
+
* @returns {Record<string, unknown>} Direct object.
|
|
252
|
+
*/
|
|
253
|
+
export function unwrapNativeDmo(value) {
|
|
254
|
+
const object = record(value);
|
|
255
|
+
if (typeof object.name !== 'string' || !Array.isArray(object.fields))
|
|
256
|
+
throw new NativeDmoError('INVALID_DMO_RESPONSE');
|
|
257
|
+
return object;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Map the read field `type` to the authored `dataType` and keep definition fields, not runtime IDs.
|
|
261
|
+
* Retrieve mode keeps what the plugin cannot map as returned: a field without `type`, or with a
|
|
262
|
+
* `dataType` that differs from it, keeps both keys; a non-boolean `isPrimaryKey` stays; a read
|
|
263
|
+
* without `dataSpaceName` takes the data space it was requested in. A DMO of another data space
|
|
264
|
+
* is UNSUPPORTED_DMO_DATASPACE.
|
|
265
|
+
* @param {unknown} value Direct native response.
|
|
266
|
+
* @param {string} dataSpace The run's data space.
|
|
267
|
+
* @param {DocumentMode} [mode] `retrieve` (lenient) or `deploy` (strict, the default).
|
|
268
|
+
* @returns {NativeDmoDocument} Portable definition with authoritative observed scope.
|
|
269
|
+
*/
|
|
270
|
+
export function normalizeNativeDmo(value, dataSpace, mode = 'deploy') {
|
|
271
|
+
const object = unwrapNativeDmo(value);
|
|
272
|
+
const lenient = mode === 'retrieve';
|
|
273
|
+
const observed = lenient && (object.dataSpaceName === undefined || object.dataSpaceName === null)
|
|
274
|
+
? dataSpace
|
|
275
|
+
: object.dataSpaceName;
|
|
276
|
+
if (observed !== dataSpace)
|
|
277
|
+
throw new NativeDmoError('UNSUPPORTED_DMO_DATASPACE');
|
|
278
|
+
return validateNativeDmoDocument({
|
|
279
|
+
schemaVersion: 1,
|
|
280
|
+
kind: 'dmo',
|
|
281
|
+
[dataSpaceKey]: dataSpace,
|
|
282
|
+
identity: { apiName: object.name },
|
|
283
|
+
spec: {
|
|
284
|
+
label: object.label,
|
|
285
|
+
// Reads are upper case (OTHER, SEGMENT_MEMBERSHIP); save the documented input spelling.
|
|
286
|
+
category: typeof object.category === 'string'
|
|
287
|
+
? object.category
|
|
288
|
+
.split('_')
|
|
289
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase())
|
|
290
|
+
.join('_')
|
|
291
|
+
: object.category,
|
|
292
|
+
...(typeof object.description === 'string' && object.description
|
|
293
|
+
? { description: object.description }
|
|
294
|
+
: {}),
|
|
295
|
+
fields: object.fields.map((value) => {
|
|
296
|
+
const field = record(value);
|
|
297
|
+
// `type` becomes `dataType` only when the read leaves no doubt.
|
|
298
|
+
const mapped = typeof field.type === 'string' &&
|
|
299
|
+
(field.dataType === undefined || field.dataType === field.type);
|
|
300
|
+
if (!lenient &&
|
|
301
|
+
(!mapped ||
|
|
302
|
+
(field.isPrimaryKey !== undefined && typeof field.isPrimaryKey !== 'boolean')))
|
|
303
|
+
throw new NativeDmoError('INVALID_DMO_FIELD');
|
|
304
|
+
return {
|
|
305
|
+
...Object.fromEntries(Object.entries(field).filter(([key]) => !runtimeKeys.has(key) && !(mapped && key === 'type'))),
|
|
306
|
+
...(mapped ? { dataType: field.type } : {}),
|
|
307
|
+
isPrimaryKey: field.isPrimaryKey === undefined ? false : field.isPrimaryKey,
|
|
308
|
+
};
|
|
309
|
+
}),
|
|
310
|
+
},
|
|
311
|
+
}, mode);
|
|
312
|
+
}
|
|
313
|
+
export { nativeDmoName } from './path-selector.js';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { DocumentMode } from './verbatim-document.js';
|
|
2
|
+
export type NativeMappingField = {
|
|
3
|
+
sourceFieldDeveloperName: string;
|
|
4
|
+
targetFieldDeveloperName: string;
|
|
5
|
+
developerName?: string;
|
|
6
|
+
};
|
|
7
|
+
export type NativeMappingDocument = {
|
|
8
|
+
schemaVersion: 1;
|
|
9
|
+
kind: 'mapping';
|
|
10
|
+
/** The data space the mapping belongs to (file key `c__dataSpace`). */
|
|
11
|
+
c__dataSpace: string;
|
|
12
|
+
identity: {
|
|
13
|
+
apiName: string;
|
|
14
|
+
};
|
|
15
|
+
spec: {
|
|
16
|
+
sourceEntityDeveloperName: string;
|
|
17
|
+
targetEntityDeveloperName: string;
|
|
18
|
+
fieldMappings: NativeMappingField[];
|
|
19
|
+
/** Optional label (Metadata API masterLabel); absent leaves the org's label as it is. */
|
|
20
|
+
label?: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/** Payload-free refusal for the isolated mapping boundary. */
|
|
24
|
+
export declare class NativeMappingError extends Error {
|
|
25
|
+
readonly code: string;
|
|
26
|
+
readonly status?: number | undefined;
|
|
27
|
+
/** Salesforce answered with a refusal, so nothing was changed. */
|
|
28
|
+
readonly rejected?: true | undefined;
|
|
29
|
+
constructor(code: string, status?: number | undefined,
|
|
30
|
+
/** Salesforce answered with a refusal, so nothing was changed. */
|
|
31
|
+
rejected?: true | undefined);
|
|
32
|
+
}
|
|
33
|
+
export declare const mappingDloName: RegExp;
|
|
34
|
+
export declare const mappingDmoName: RegExp;
|
|
35
|
+
/**
|
|
36
|
+
* Validate portable bindings and retain every pair and observed field selector.
|
|
37
|
+
* Saved mapping names identify source artifacts, not a recreated target mapping. Deploy mode (the
|
|
38
|
+
* default) admits only what a deploy can send and names the first offending key path; retrieve
|
|
39
|
+
* mode keeps what the org returned (unknown keys, any field names, no pairs at all) and checks
|
|
40
|
+
* only what names and places the file and the DLO-to-DMO binding the document represents.
|
|
41
|
+
* @param {unknown} value Portable input.
|
|
42
|
+
* @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (lenient).
|
|
43
|
+
* @returns {NativeMappingDocument} Checked independent copy.
|
|
44
|
+
*/
|
|
45
|
+
export declare function validateNativeMappingDocument(value: unknown, mode?: DocumentMode): NativeMappingDocument;
|
|
46
|
+
/**
|
|
47
|
+
* Unwrap a detail response without accepting collection or CLI envelopes.
|
|
48
|
+
* @param {unknown} value Native detail response.
|
|
49
|
+
* @returns {Record<string, unknown>} Direct representation.
|
|
50
|
+
*/
|
|
51
|
+
export declare function unwrapNativeMapping(value: unknown): Record<string, unknown>;
|
|
52
|
+
/**
|
|
53
|
+
* Save logical bindings and every returned pair, without runtime mapping status or IDs.
|
|
54
|
+
* @param {unknown} value Direct native response.
|
|
55
|
+
* @param {string} dataSpace The run's data space; a read naming another is refused.
|
|
56
|
+
* @param {DocumentMode} [mode] `retrieve` keeps pairs the plugin cannot deploy as returned.
|
|
57
|
+
* @returns {NativeMappingDocument} Portable definition, not a write payload.
|
|
58
|
+
*/
|
|
59
|
+
export declare function normalizeNativeMapping(value: unknown, dataSpace: string, mode?: DocumentMode): NativeMappingDocument;
|
|
60
|
+
/**
|
|
61
|
+
* Unwrap only the documented collection wrapper; do not infer pagination completeness.
|
|
62
|
+
* @param {unknown} value Native collection response.
|
|
63
|
+
* @param {string} dataSpace The run's data space, checked for every entry.
|
|
64
|
+
* @returns {Record<string, unknown>[]} Checked detail representations.
|
|
65
|
+
*/
|
|
66
|
+
export declare function unwrapNativeMappingCollection(value: unknown, dataSpace: string): Record<string, unknown>[];
|
|
67
|
+
export { nativeMappingName } from './path-selector.js';
|