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,187 @@
|
|
|
1
|
+
import { nativeMappingName } from './path-selector.js';
|
|
2
|
+
import { explainInput, printableKey } from '../services/operation-diagnostic.js';
|
|
3
|
+
import { dataSpaceKey, readSingleDataSpace, refuseLegacyDataSpace } from './data-space-field.js';
|
|
4
|
+
/** Payload-free refusal for the isolated mapping boundary. */
|
|
5
|
+
export class NativeMappingError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
status;
|
|
8
|
+
rejected;
|
|
9
|
+
constructor(code, status,
|
|
10
|
+
/** Salesforce answered with a refusal, so nothing was changed. */
|
|
11
|
+
rejected) {
|
|
12
|
+
super(`Native mapping operation refused: ${code}.`);
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.status = status;
|
|
15
|
+
this.rejected = rejected;
|
|
16
|
+
this.name = 'NativeMappingError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export const mappingDloName = /^[A-Za-z][A-Za-z0-9_]{0,199}__dll$/u;
|
|
20
|
+
export const mappingDmoName = /^[A-Za-z][A-Za-z0-9_]{0,199}__dlm$/u;
|
|
21
|
+
const fieldName = /^[A-Za-z][A-Za-z0-9_]{0,239}__c$/u;
|
|
22
|
+
const fieldSelector = /^[A-Za-z][A-Za-z0-9_]{0,499}$/u;
|
|
23
|
+
/**
|
|
24
|
+
* Require an object at the mapping boundary.
|
|
25
|
+
* @param {unknown} value Untrusted input.
|
|
26
|
+
* @returns {Record<string, unknown>} Object content.
|
|
27
|
+
*/
|
|
28
|
+
function record(value) {
|
|
29
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
30
|
+
throw new NativeMappingError('INVALID_MAPPING_DOCUMENT');
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Refuse an authored mapping file, naming the key path that cannot be deployed.
|
|
35
|
+
* @param {string} code Refusal code.
|
|
36
|
+
* @param {string} keyPath Printable key path.
|
|
37
|
+
* @param {string} problem What is wrong with it.
|
|
38
|
+
* @returns {NativeMappingError} Refusal with an explanation.
|
|
39
|
+
*/
|
|
40
|
+
function refuse(code, keyPath, problem) {
|
|
41
|
+
return explainInput(new NativeMappingError(code), `The mapping file cannot be deployed: ${keyPath} ${problem}. Correct the file, or retrieve the mapping again once the plugin supports it.`);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Require a JSON object at a key path of the file.
|
|
45
|
+
* @param {unknown} value Untrusted input.
|
|
46
|
+
* @param {string} keyPath Printable key path.
|
|
47
|
+
* @returns {Record<string, unknown>} Object content.
|
|
48
|
+
*/
|
|
49
|
+
function objectAt(value, keyPath) {
|
|
50
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
51
|
+
throw refuse('INVALID_MAPPING_DOCUMENT', keyPath, 'must be an object');
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Refuse a key outside the given set and a missing required key.
|
|
56
|
+
* @param {Record<string, unknown>} value Object of the file.
|
|
57
|
+
* @param {string} prefix Key path of the object, with a trailing dot (empty at the top).
|
|
58
|
+
* @param {string[]} required Keys it must hold.
|
|
59
|
+
* @param {string[]} [optional] Keys it may hold.
|
|
60
|
+
* @param {string} [code] Refusal code.
|
|
61
|
+
*/
|
|
62
|
+
function closedKeys(value, prefix, required, optional = [], code = 'INVALID_MAPPING_DOCUMENT') {
|
|
63
|
+
for (const key of Object.keys(value))
|
|
64
|
+
if (!required.includes(key) && !optional.includes(key))
|
|
65
|
+
throw refuse(code, `${prefix}${printableKey(key)}`, 'is not a key a mapping file can hold');
|
|
66
|
+
for (const key of required)
|
|
67
|
+
if (!Object.hasOwn(value, key))
|
|
68
|
+
throw refuse(code, `${prefix}${key}`, 'is missing');
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Validate portable bindings and retain every pair and observed field selector.
|
|
72
|
+
* Saved mapping names identify source artifacts, not a recreated target mapping. Deploy mode (the
|
|
73
|
+
* default) admits only what a deploy can send and names the first offending key path; retrieve
|
|
74
|
+
* mode keeps what the org returned (unknown keys, any field names, no pairs at all) and checks
|
|
75
|
+
* only what names and places the file and the DLO-to-DMO binding the document represents.
|
|
76
|
+
* @param {unknown} value Portable input.
|
|
77
|
+
* @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (lenient).
|
|
78
|
+
* @returns {NativeMappingDocument} Checked independent copy.
|
|
79
|
+
*/
|
|
80
|
+
export function validateNativeMappingDocument(value, mode = 'deploy') {
|
|
81
|
+
const document = objectAt(value, 'the document');
|
|
82
|
+
const identity = objectAt(document.identity, 'identity');
|
|
83
|
+
const spec = objectAt(document.spec, 'spec');
|
|
84
|
+
if (document.schemaVersion !== 1)
|
|
85
|
+
throw refuse('INVALID_MAPPING_DOCUMENT', 'schemaVersion', 'must be 1');
|
|
86
|
+
if (document.kind !== 'mapping')
|
|
87
|
+
throw refuse('INVALID_MAPPING_DOCUMENT', 'kind', 'must be "mapping"');
|
|
88
|
+
if (typeof identity.apiName !== 'string' || !nativeMappingName.test(identity.apiName))
|
|
89
|
+
throw refuse('INVALID_MAPPING_DOCUMENT', 'identity.apiName', 'must be a mapping API name');
|
|
90
|
+
refuseLegacyDataSpace(identity, refuse);
|
|
91
|
+
readSingleDataSpace(document, refuse);
|
|
92
|
+
// The document represents a DLO-to-DMO mapping only; retrieve writes any other as returned.
|
|
93
|
+
if (typeof spec.sourceEntityDeveloperName !== 'string' ||
|
|
94
|
+
!mappingDloName.test(spec.sourceEntityDeveloperName))
|
|
95
|
+
throw refuse('INVALID_MAPPING_DOCUMENT', 'spec.sourceEntityDeveloperName', 'must be a data lake object API name ending in __dll');
|
|
96
|
+
if (typeof spec.targetEntityDeveloperName !== 'string' ||
|
|
97
|
+
!mappingDmoName.test(spec.targetEntityDeveloperName))
|
|
98
|
+
throw refuse('INVALID_MAPPING_DOCUMENT', 'spec.targetEntityDeveloperName', 'must be a data model object API name ending in __dlm');
|
|
99
|
+
if (!Array.isArray(spec.fieldMappings))
|
|
100
|
+
throw refuse('INVALID_MAPPING_DOCUMENT', 'spec.fieldMappings', 'must be a list of pairs');
|
|
101
|
+
const fields = spec.fieldMappings.map((field, index) => objectAt(field, `spec.fieldMappings[${index}]`));
|
|
102
|
+
if (mode === 'retrieve')
|
|
103
|
+
return structuredClone(value);
|
|
104
|
+
closedKeys(document, '', [dataSpaceKey, 'identity', 'kind', 'schemaVersion', 'spec']);
|
|
105
|
+
closedKeys(identity, 'identity.', ['apiName']);
|
|
106
|
+
closedKeys(spec, 'spec.', ['fieldMappings', 'sourceEntityDeveloperName', 'targetEntityDeveloperName'], ['label']);
|
|
107
|
+
if (Object.hasOwn(spec, 'label') &&
|
|
108
|
+
(typeof spec.label !== 'string' ||
|
|
109
|
+
spec.label.trim() === '' ||
|
|
110
|
+
spec.label !== spec.label.trim() ||
|
|
111
|
+
[...spec.label].some((character) => character.codePointAt(0) < 32 || character.codePointAt(0) === 127)))
|
|
112
|
+
throw refuse('INVALID_MAPPING_DOCUMENT', 'spec.label', 'must be a non-empty text');
|
|
113
|
+
if (fields.length === 0)
|
|
114
|
+
throw refuse('INVALID_MAPPING_DOCUMENT', 'spec.fieldMappings', 'must list at least one pair');
|
|
115
|
+
const pairs = new Set();
|
|
116
|
+
const selectors = new Set();
|
|
117
|
+
for (const [index, field] of fields.entries()) {
|
|
118
|
+
const at = `spec.fieldMappings[${index}]`;
|
|
119
|
+
closedKeys(field, `${at}.`, ['sourceFieldDeveloperName', 'targetFieldDeveloperName'], ['developerName'], 'INVALID_MAPPING_FIELD');
|
|
120
|
+
for (const side of ['sourceFieldDeveloperName', 'targetFieldDeveloperName'])
|
|
121
|
+
if (typeof field[side] !== 'string' || !fieldName.test(field[side]))
|
|
122
|
+
throw refuse('INVALID_MAPPING_FIELD', `${at}.${side}`, 'must be a field API name ending in __c');
|
|
123
|
+
const pair = `${String(field.sourceFieldDeveloperName)}:${String(field.targetFieldDeveloperName)}`.toLowerCase();
|
|
124
|
+
if (pairs.has(pair))
|
|
125
|
+
throw refuse('INVALID_MAPPING_FIELD', at, 'repeats another pair');
|
|
126
|
+
pairs.add(pair);
|
|
127
|
+
if (field.developerName === undefined)
|
|
128
|
+
continue;
|
|
129
|
+
if (typeof field.developerName !== 'string' || !fieldSelector.test(field.developerName))
|
|
130
|
+
throw refuse('INVALID_MAPPING_FIELD', `${at}.developerName`, 'must be a field selector');
|
|
131
|
+
if (selectors.has(field.developerName.toLowerCase()))
|
|
132
|
+
throw refuse('INVALID_MAPPING_FIELD', `${at}.developerName`, 'repeats the selector of another pair');
|
|
133
|
+
selectors.add(field.developerName.toLowerCase());
|
|
134
|
+
}
|
|
135
|
+
return structuredClone(value);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Unwrap a detail response without accepting collection or CLI envelopes.
|
|
139
|
+
* @param {unknown} value Native detail response.
|
|
140
|
+
* @returns {Record<string, unknown>} Direct representation.
|
|
141
|
+
*/
|
|
142
|
+
export function unwrapNativeMapping(value) {
|
|
143
|
+
const object = record(value);
|
|
144
|
+
if (typeof object.developerName !== 'string' || !Array.isArray(object.fieldMappings))
|
|
145
|
+
throw new NativeMappingError('INVALID_MAPPING_RESPONSE');
|
|
146
|
+
return object;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Save logical bindings and every returned pair, without runtime mapping status or IDs.
|
|
150
|
+
* @param {unknown} value Direct native response.
|
|
151
|
+
* @param {string} dataSpace The run's data space; a read naming another is refused.
|
|
152
|
+
* @param {DocumentMode} [mode] `retrieve` keeps pairs the plugin cannot deploy as returned.
|
|
153
|
+
* @returns {NativeMappingDocument} Portable definition, not a write payload.
|
|
154
|
+
*/
|
|
155
|
+
export function normalizeNativeMapping(value, dataSpace, mode = 'deploy') {
|
|
156
|
+
const object = unwrapNativeMapping(value);
|
|
157
|
+
if (object.dataSpaceName !== undefined && object.dataSpaceName !== dataSpace)
|
|
158
|
+
throw new NativeMappingError('UNSUPPORTED_MAPPING_DATASPACE');
|
|
159
|
+
return validateNativeMappingDocument({
|
|
160
|
+
schemaVersion: 1,
|
|
161
|
+
kind: 'mapping',
|
|
162
|
+
[dataSpaceKey]: dataSpace,
|
|
163
|
+
identity: { apiName: object.developerName },
|
|
164
|
+
spec: {
|
|
165
|
+
sourceEntityDeveloperName: object.sourceEntityDeveloperName,
|
|
166
|
+
targetEntityDeveloperName: object.targetEntityDeveloperName,
|
|
167
|
+
fieldMappings: object.fieldMappings,
|
|
168
|
+
},
|
|
169
|
+
}, mode);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Unwrap only the documented collection wrapper; do not infer pagination completeness.
|
|
173
|
+
* @param {unknown} value Native collection response.
|
|
174
|
+
* @param {string} dataSpace The run's data space, checked for every entry.
|
|
175
|
+
* @returns {Record<string, unknown>[]} Checked detail representations.
|
|
176
|
+
*/
|
|
177
|
+
export function unwrapNativeMappingCollection(value, dataSpace) {
|
|
178
|
+
const object = record(value);
|
|
179
|
+
if (!Array.isArray(object.objectSourceTargetMaps))
|
|
180
|
+
throw new NativeMappingError('INVALID_MAPPING_RESPONSE');
|
|
181
|
+
return object.objectSourceTargetMaps.map((entry) => {
|
|
182
|
+
const detail = unwrapNativeMapping(entry);
|
|
183
|
+
normalizeNativeMapping(detail, dataSpace);
|
|
184
|
+
return detail;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
export { nativeMappingName } from './path-selector.js';
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { DocumentMode } from './verbatim-document.js';
|
|
2
|
+
export type NativeRelationshipSpec = {
|
|
3
|
+
sourceObjectName: string;
|
|
4
|
+
sourceFieldName: string;
|
|
5
|
+
targetObjectName: string;
|
|
6
|
+
targetFieldName: string;
|
|
7
|
+
cardinality: string;
|
|
8
|
+
relationshipOwner: string;
|
|
9
|
+
/** Optional label (Metadata API masterLabel); absent leaves the org's label as it is. */
|
|
10
|
+
label?: string;
|
|
11
|
+
};
|
|
12
|
+
export type NativeRelationshipDocument = {
|
|
13
|
+
schemaVersion: 1;
|
|
14
|
+
kind: 'relationship';
|
|
15
|
+
/** The data space the relationship belongs to (file key `c__dataSpace`). */
|
|
16
|
+
c__dataSpace: string;
|
|
17
|
+
identity: {
|
|
18
|
+
apiName: string;
|
|
19
|
+
};
|
|
20
|
+
spec: NativeRelationshipSpec;
|
|
21
|
+
};
|
|
22
|
+
/** One relationship as the native list reports it; fields are type-checked, not admitted. */
|
|
23
|
+
export type ObservedRelationship = NativeRelationshipSpec & {
|
|
24
|
+
name: string;
|
|
25
|
+
status: string;
|
|
26
|
+
};
|
|
27
|
+
/** Payload-free refusal for the isolated relationship boundary. */
|
|
28
|
+
export declare class NativeRelationshipError extends Error {
|
|
29
|
+
readonly code: string;
|
|
30
|
+
readonly status?: number | undefined;
|
|
31
|
+
constructor(code: string, status?: number | undefined);
|
|
32
|
+
}
|
|
33
|
+
export declare const relationshipDmoName: RegExp;
|
|
34
|
+
/**
|
|
35
|
+
* Validate the portable relationship structurally. Cardinality, owner and the optional label are
|
|
36
|
+
* sent as authored;
|
|
37
|
+
* Salesforce decides which values it accepts. Deploy mode (the default) names the first offending
|
|
38
|
+
* key path; retrieve mode keeps what the org returned (unknown keys, null or missing values, any
|
|
39
|
+
* field names) and checks only what names and places the file.
|
|
40
|
+
* @param {unknown} value Portable input.
|
|
41
|
+
* @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (lenient).
|
|
42
|
+
* @returns {NativeRelationshipDocument} Checked independent copy.
|
|
43
|
+
*/
|
|
44
|
+
export declare function validateNativeRelationshipDocument(value: unknown, mode?: DocumentMode): NativeRelationshipDocument;
|
|
45
|
+
/**
|
|
46
|
+
* Read one entry of a native relationship list: names and values must be strings, except in
|
|
47
|
+
* retrieve mode, which takes them as listed (an entry the retrieve keeps is checked when its
|
|
48
|
+
* document is built; one it does not keep is never checked).
|
|
49
|
+
* @param {unknown} value Native list entry.
|
|
50
|
+
* @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (as listed).
|
|
51
|
+
* @returns {ObservedRelationship} Flat observation, not yet a portable document.
|
|
52
|
+
*/
|
|
53
|
+
export declare function observeNativeRelationship(value: unknown, mode?: DocumentMode): ObservedRelationship;
|
|
54
|
+
/**
|
|
55
|
+
* Save the authored binding without the generated id, labels, status or creation type.
|
|
56
|
+
* @param {unknown} value Native list entry.
|
|
57
|
+
* @param {string} dataSpace The data space the relationship was listed in (the run's).
|
|
58
|
+
* @param {DocumentMode} [mode] `retrieve` keeps null or missing values as listed.
|
|
59
|
+
* @returns {NativeRelationshipDocument} Portable definition.
|
|
60
|
+
*/
|
|
61
|
+
export declare function normalizeNativeRelationship(value: unknown, dataSpace: string, mode?: DocumentMode): NativeRelationshipDocument;
|
|
62
|
+
/**
|
|
63
|
+
* The authored binding, cardinality and owner of a relationship, in the order of the create body
|
|
64
|
+
* (the label is not part of it).
|
|
65
|
+
* @param {NativeRelationshipSpec} value Observation or document spec.
|
|
66
|
+
* @returns {NativeRelationshipSpec} Exactly the six values of the create body.
|
|
67
|
+
*/
|
|
68
|
+
export declare function relationshipSpec(value: NativeRelationshipSpec): NativeRelationshipSpec;
|
|
69
|
+
/**
|
|
70
|
+
* Whether an observation carries the binding of a document: both objects and both fields.
|
|
71
|
+
* @param {NativeRelationshipSpec} observed Native observation.
|
|
72
|
+
* @param {NativeRelationshipSpec} desired Portable spec.
|
|
73
|
+
* @returns {boolean} Exact binding match.
|
|
74
|
+
*/
|
|
75
|
+
export declare function sameRelationshipBinding(observed: NativeRelationshipSpec, desired: NativeRelationshipSpec): boolean;
|
|
76
|
+
export { nativeRelationshipName } from './path-selector.js';
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { nativeRelationshipName } from './path-selector.js';
|
|
2
|
+
import { explainInput, printableKey } from '../services/operation-diagnostic.js';
|
|
3
|
+
import { dataSpaceKey, readSingleDataSpace, refuseLegacyDataSpace } from './data-space-field.js';
|
|
4
|
+
/** Payload-free refusal for the isolated relationship boundary. */
|
|
5
|
+
export class NativeRelationshipError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
status;
|
|
8
|
+
constructor(code, status) {
|
|
9
|
+
super(`Native relationship operation refused: ${code}.`);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.status = status;
|
|
12
|
+
this.name = 'NativeRelationshipError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export const relationshipDmoName = /^[A-Za-z][A-Za-z0-9_]{0,199}__dlm$/u;
|
|
16
|
+
const fieldName = /^[A-Za-z][A-Za-z0-9_]{0,239}__c$/u;
|
|
17
|
+
// The target may be a DMO or a CRM object (owner SObject, e.g. Account.Id): any API name.
|
|
18
|
+
const targetObjectName = /^[A-Za-z][A-Za-z0-9_]{0,199}$/u;
|
|
19
|
+
const targetFieldName = /^[A-Za-z][A-Za-z0-9_]{0,239}$/u;
|
|
20
|
+
const specKeys = [
|
|
21
|
+
'cardinality',
|
|
22
|
+
'relationshipOwner',
|
|
23
|
+
'sourceFieldName',
|
|
24
|
+
'sourceObjectName',
|
|
25
|
+
'targetFieldName',
|
|
26
|
+
'targetObjectName',
|
|
27
|
+
];
|
|
28
|
+
/**
|
|
29
|
+
* Require an object at the relationship boundary.
|
|
30
|
+
* @param {unknown} value Untrusted input.
|
|
31
|
+
* @param {string} code Refusal code.
|
|
32
|
+
* @returns {Record<string, unknown>} Object content.
|
|
33
|
+
*/
|
|
34
|
+
function record(value, code = 'INVALID_RELATIONSHIP_DOCUMENT') {
|
|
35
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
36
|
+
throw new NativeRelationshipError(code);
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A trimmed, non-empty string without control characters.
|
|
41
|
+
* @param {unknown} value Untrusted value.
|
|
42
|
+
* @returns {boolean} Whether it is a plain token.
|
|
43
|
+
*/
|
|
44
|
+
function plain(value) {
|
|
45
|
+
return (typeof value === 'string' &&
|
|
46
|
+
value.trim() !== '' &&
|
|
47
|
+
value === value.trim() &&
|
|
48
|
+
![...value].some((character) => character.codePointAt(0) < 32 || character.codePointAt(0) === 127));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Refuse an authored relationship file, naming the key path that cannot be deployed.
|
|
52
|
+
* @param {string} keyPath Printable key path.
|
|
53
|
+
* @param {string} problem What is wrong with it.
|
|
54
|
+
* @returns {NativeRelationshipError} Refusal with an explanation.
|
|
55
|
+
*/
|
|
56
|
+
function refuse(keyPath, problem) {
|
|
57
|
+
return refuseWith('INVALID_RELATIONSHIP_DOCUMENT', keyPath, problem);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Refuse an authored relationship file with a given code, naming the key path.
|
|
61
|
+
* @param {string} code Refusal code.
|
|
62
|
+
* @param {string} keyPath Printable key path.
|
|
63
|
+
* @param {string} problem What is wrong with it.
|
|
64
|
+
* @returns {NativeRelationshipError} Refusal with an explanation.
|
|
65
|
+
*/
|
|
66
|
+
function refuseWith(code, keyPath, problem) {
|
|
67
|
+
return explainInput(new NativeRelationshipError(code), `The relationship file cannot be deployed: ${keyPath} ${problem}. Correct the file, or retrieve the relationship again once the plugin supports it.`);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Require a JSON object at a key path of the file.
|
|
71
|
+
* @param {unknown} value Untrusted input.
|
|
72
|
+
* @param {string} keyPath Printable key path.
|
|
73
|
+
* @returns {Record<string, unknown>} Object content.
|
|
74
|
+
*/
|
|
75
|
+
function objectAt(value, keyPath) {
|
|
76
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
77
|
+
throw refuse(keyPath, 'must be an object');
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Refuse a key outside the given set and a missing one.
|
|
82
|
+
* @param {Record<string, unknown>} value Object of the file.
|
|
83
|
+
* @param {string} prefix Key path of the object, with a trailing dot (empty at the top).
|
|
84
|
+
* @param {string[]} keys Keys it must hold.
|
|
85
|
+
* @param {string[]} [optional] Keys it may hold besides.
|
|
86
|
+
*/
|
|
87
|
+
function closedKeys(value, prefix, keys, optional = []) {
|
|
88
|
+
for (const key of Object.keys(value))
|
|
89
|
+
if (!keys.includes(key) && !optional.includes(key))
|
|
90
|
+
throw refuse(`${prefix}${printableKey(key)}`, 'is not a key a relationship file can hold');
|
|
91
|
+
for (const key of keys)
|
|
92
|
+
if (!Object.hasOwn(value, key))
|
|
93
|
+
throw refuse(`${prefix}${key}`, 'is missing');
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Validate the portable relationship structurally. Cardinality, owner and the optional label are
|
|
97
|
+
* sent as authored;
|
|
98
|
+
* Salesforce decides which values it accepts. Deploy mode (the default) names the first offending
|
|
99
|
+
* key path; retrieve mode keeps what the org returned (unknown keys, null or missing values, any
|
|
100
|
+
* field names) and checks only what names and places the file.
|
|
101
|
+
* @param {unknown} value Portable input.
|
|
102
|
+
* @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (lenient).
|
|
103
|
+
* @returns {NativeRelationshipDocument} Checked independent copy.
|
|
104
|
+
*/
|
|
105
|
+
export function validateNativeRelationshipDocument(value, mode = 'deploy') {
|
|
106
|
+
const document = objectAt(value, 'the document');
|
|
107
|
+
const identity = objectAt(document.identity, 'identity');
|
|
108
|
+
const spec = objectAt(document.spec, 'spec');
|
|
109
|
+
if (document.schemaVersion !== 1)
|
|
110
|
+
throw refuse('schemaVersion', 'must be 1');
|
|
111
|
+
if (document.kind !== 'relationship')
|
|
112
|
+
throw refuse('kind', 'must be "relationship"');
|
|
113
|
+
if (typeof identity.apiName !== 'string' || !nativeRelationshipName.test(identity.apiName))
|
|
114
|
+
throw refuse('identity.apiName', 'must be a relationship API name');
|
|
115
|
+
refuseLegacyDataSpace(identity, refuseWith);
|
|
116
|
+
readSingleDataSpace(document, refuseWith);
|
|
117
|
+
if (mode === 'retrieve')
|
|
118
|
+
return structuredClone(value);
|
|
119
|
+
closedKeys(document, '', [dataSpaceKey, 'identity', 'kind', 'schemaVersion', 'spec']);
|
|
120
|
+
closedKeys(identity, 'identity.', ['apiName']);
|
|
121
|
+
closedKeys(spec, 'spec.', specKeys, ['label']);
|
|
122
|
+
const checks = [
|
|
123
|
+
[
|
|
124
|
+
'sourceObjectName',
|
|
125
|
+
(part) => typeof part === 'string' && relationshipDmoName.test(part),
|
|
126
|
+
'must be a data model object API name ending in __dlm',
|
|
127
|
+
],
|
|
128
|
+
[
|
|
129
|
+
'sourceFieldName',
|
|
130
|
+
(part) => typeof part === 'string' && fieldName.test(part),
|
|
131
|
+
'must be a field API name ending in __c',
|
|
132
|
+
],
|
|
133
|
+
[
|
|
134
|
+
'targetObjectName',
|
|
135
|
+
(part) => typeof part === 'string' && targetObjectName.test(part),
|
|
136
|
+
'must be an object API name',
|
|
137
|
+
],
|
|
138
|
+
[
|
|
139
|
+
'targetFieldName',
|
|
140
|
+
(part) => typeof part === 'string' && targetFieldName.test(part),
|
|
141
|
+
'must be a field API name',
|
|
142
|
+
],
|
|
143
|
+
['cardinality', plain, 'must be a non-empty text'],
|
|
144
|
+
['relationshipOwner', plain, 'must be a non-empty text'],
|
|
145
|
+
];
|
|
146
|
+
for (const [key, check, problem] of checks)
|
|
147
|
+
if (!check(spec[key]))
|
|
148
|
+
throw refuse(`spec.${key}`, problem);
|
|
149
|
+
if (Object.hasOwn(spec, 'label') && !plain(spec.label))
|
|
150
|
+
throw refuse('spec.label', 'must be a non-empty text');
|
|
151
|
+
return structuredClone(value);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The name of a nested object or field reference of a list entry.
|
|
155
|
+
* @param {unknown} part Nested reference.
|
|
156
|
+
* @returns {unknown} Its name, unchecked.
|
|
157
|
+
*/
|
|
158
|
+
function name(part) {
|
|
159
|
+
return part && typeof part === 'object' && !Array.isArray(part)
|
|
160
|
+
? part.name
|
|
161
|
+
: undefined;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Read one entry of a native relationship list: names and values must be strings, except in
|
|
165
|
+
* retrieve mode, which takes them as listed (an entry the retrieve keeps is checked when its
|
|
166
|
+
* document is built; one it does not keep is never checked).
|
|
167
|
+
* @param {unknown} value Native list entry.
|
|
168
|
+
* @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (as listed).
|
|
169
|
+
* @returns {ObservedRelationship} Flat observation, not yet a portable document.
|
|
170
|
+
*/
|
|
171
|
+
export function observeNativeRelationship(value, mode = 'deploy') {
|
|
172
|
+
const entry = record(value, 'INVALID_RELATIONSHIP_RESPONSE');
|
|
173
|
+
const observed = {
|
|
174
|
+
name: entry.name,
|
|
175
|
+
status: entry.status,
|
|
176
|
+
sourceObjectName: name(entry.sourceObject),
|
|
177
|
+
sourceFieldName: name(entry.sourceField),
|
|
178
|
+
targetObjectName: name(entry.targetObject),
|
|
179
|
+
targetFieldName: name(entry.targetField),
|
|
180
|
+
cardinality: entry.cardinality,
|
|
181
|
+
relationshipOwner: entry.owner,
|
|
182
|
+
};
|
|
183
|
+
if (mode === 'deploy' && Object.values(observed).some((part) => typeof part !== 'string'))
|
|
184
|
+
throw new NativeRelationshipError('INVALID_RELATIONSHIP_RESPONSE');
|
|
185
|
+
return observed;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Save the authored binding without the generated id, labels, status or creation type.
|
|
189
|
+
* @param {unknown} value Native list entry.
|
|
190
|
+
* @param {string} dataSpace The data space the relationship was listed in (the run's).
|
|
191
|
+
* @param {DocumentMode} [mode] `retrieve` keeps null or missing values as listed.
|
|
192
|
+
* @returns {NativeRelationshipDocument} Portable definition.
|
|
193
|
+
*/
|
|
194
|
+
export function normalizeNativeRelationship(value, dataSpace, mode = 'deploy') {
|
|
195
|
+
const observed = observeNativeRelationship(value, mode);
|
|
196
|
+
return validateNativeRelationshipDocument({
|
|
197
|
+
schemaVersion: 1,
|
|
198
|
+
kind: 'relationship',
|
|
199
|
+
[dataSpaceKey]: dataSpace,
|
|
200
|
+
identity: { apiName: observed.name },
|
|
201
|
+
spec: relationshipSpec(observed),
|
|
202
|
+
}, mode);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* The authored binding, cardinality and owner of a relationship, in the order of the create body
|
|
206
|
+
* (the label is not part of it).
|
|
207
|
+
* @param {NativeRelationshipSpec} value Observation or document spec.
|
|
208
|
+
* @returns {NativeRelationshipSpec} Exactly the six values of the create body.
|
|
209
|
+
*/
|
|
210
|
+
export function relationshipSpec(value) {
|
|
211
|
+
return {
|
|
212
|
+
sourceObjectName: value.sourceObjectName,
|
|
213
|
+
sourceFieldName: value.sourceFieldName,
|
|
214
|
+
targetObjectName: value.targetObjectName,
|
|
215
|
+
targetFieldName: value.targetFieldName,
|
|
216
|
+
cardinality: value.cardinality,
|
|
217
|
+
relationshipOwner: value.relationshipOwner,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Whether an observation carries the binding of a document: both objects and both fields.
|
|
222
|
+
* @param {NativeRelationshipSpec} observed Native observation.
|
|
223
|
+
* @param {NativeRelationshipSpec} desired Portable spec.
|
|
224
|
+
* @returns {boolean} Exact binding match.
|
|
225
|
+
*/
|
|
226
|
+
export function sameRelationshipBinding(observed, desired) {
|
|
227
|
+
return (observed.sourceObjectName === desired.sourceObjectName &&
|
|
228
|
+
observed.sourceFieldName === desired.sourceFieldName &&
|
|
229
|
+
observed.targetObjectName === desired.targetObjectName &&
|
|
230
|
+
observed.targetFieldName === desired.targetFieldName);
|
|
231
|
+
}
|
|
232
|
+
export { nativeRelationshipName } from './path-selector.js';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** Component family of a canonical `data360/` file; also the `-m` selector prefix. */
|
|
2
|
+
export type DeletedArtifactKind = 'dmo' | 'dlo' | 'mapping' | 'relationship' | 'data-stream' | 'data-transform' | 'data-graph' | 'identity-resolution' | 'calculated-insight' | 'segment';
|
|
3
|
+
export declare const dloName: RegExp;
|
|
4
|
+
export declare const nativeDmoName: RegExp;
|
|
5
|
+
export declare const nativeMappingName: RegExp;
|
|
6
|
+
export declare const nativeRelationshipName: RegExp;
|
|
7
|
+
export declare const dataTransformName: RegExp;
|
|
8
|
+
export declare const dataGraphName: RegExp;
|
|
9
|
+
export declare const identityResolutionName: RegExp;
|
|
10
|
+
export declare const calculatedInsightName: RegExp;
|
|
11
|
+
export declare const segmentName: RegExp;
|
|
12
|
+
export declare const ciJsonSuffix = ".calculatedInsight-meta.json";
|
|
13
|
+
export declare const ciSqlSuffix = ".calculatedInsight-meta.sql";
|
|
14
|
+
/** Family by file suffix; every family lives under `data360/` at the project root. */
|
|
15
|
+
export declare const families: ReadonlyArray<{
|
|
16
|
+
kind: DeletedArtifactKind;
|
|
17
|
+
suffix: string;
|
|
18
|
+
directory: readonly string[];
|
|
19
|
+
name: (value: string) => boolean;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const ciSql: (file: string) => boolean;
|
|
22
|
+
export declare const segmentSql: (file: string) => boolean;
|
|
23
|
+
export declare const segmentSqlPattern: RegExp;
|
|
24
|
+
/**
|
|
25
|
+
* Map one project-relative POSIX path to its family and canonical name.
|
|
26
|
+
* @param {string} file Project-relative POSIX path.
|
|
27
|
+
* @returns {object | undefined} Family and canonical name (`__cio` included for calculated
|
|
28
|
+
* insights), or undefined when the path is not a canonical component file.
|
|
29
|
+
*/
|
|
30
|
+
export declare function classifyComponentPath(file: string): {
|
|
31
|
+
kind: DeletedArtifactKind;
|
|
32
|
+
name: string;
|
|
33
|
+
} | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* The `sf data360 deploy/retrieve -m` selector of a component file. A calculated insight's SQL
|
|
36
|
+
* file and a segment's `<Name>.segment.<model>.sql` file map to their owner. Only POSIX paths
|
|
37
|
+
* (`/` separators) relative to the project root are recognised; anything else is undefined.
|
|
38
|
+
* @param {string} relativePath Project-relative POSIX path.
|
|
39
|
+
* @returns {object | undefined} Family, name and `kind:name` selector, or undefined; never throws.
|
|
40
|
+
*/
|
|
41
|
+
export declare function selectorForPath(relativePath: string): {
|
|
42
|
+
kind: DeletedArtifactKind;
|
|
43
|
+
name: string;
|
|
44
|
+
selector: string;
|
|
45
|
+
} | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* The exact `sf data360 delete -m` selector of a component file. Every family deletes by its
|
|
48
|
+
* deploy selector except a relationship, which also names its source DMO
|
|
49
|
+
* (`relationship:<SourceDmo__dlm>:<Name>`), read from the file's content.
|
|
50
|
+
* @param {string} relativePath Project-relative POSIX path.
|
|
51
|
+
* @param {string} documentText The file's text (only read for a relationship).
|
|
52
|
+
* @returns {string | undefined} The selector, or undefined (unknown path, or a relationship whose
|
|
53
|
+
* text is not JSON or names no valid source DMO); never throws.
|
|
54
|
+
*/
|
|
55
|
+
export declare function deleteSelectorFor(relativePath: string, documentText: string): string | undefined;
|