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.
Files changed (269) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +572 -240
  3. package/docs/artifact-format.md +527 -633
  4. package/docs/capabilities.md +1159 -168
  5. package/docs/git-workflow.md +135 -12
  6. package/docs/handover.md +7826 -12
  7. package/lib/api.d.ts +7 -0
  8. package/lib/api.js +7 -0
  9. package/lib/artifacts/code-fields.d.ts +49 -0
  10. package/lib/artifacts/code-fields.js +142 -0
  11. package/lib/artifacts/data-graph-document.d.ts +29 -0
  12. package/lib/artifacts/data-graph-document.js +52 -0
  13. package/lib/artifacts/data-space-field.d.ts +65 -0
  14. package/lib/artifacts/data-space-field.js +98 -0
  15. package/lib/artifacts/data-stream-document.d.ts +264 -0
  16. package/lib/artifacts/data-stream-document.js +680 -0
  17. package/lib/artifacts/data-transform-document.d.ts +152 -0
  18. package/lib/artifacts/data-transform-document.js +560 -0
  19. package/lib/artifacts/dependency-selection.d.ts +51 -0
  20. package/lib/artifacts/dependency-selection.js +154 -0
  21. package/lib/artifacts/dlo-document.d.ts +93 -0
  22. package/lib/artifacts/dlo-document.js +253 -0
  23. package/lib/artifacts/enum-case.d.ts +39 -0
  24. package/lib/artifacts/enum-case.js +67 -0
  25. package/lib/artifacts/git-deploy-selection.d.ts +68 -0
  26. package/lib/artifacts/git-deploy-selection.js +474 -0
  27. package/lib/artifacts/identity-resolution-document.d.ts +133 -0
  28. package/lib/artifacts/identity-resolution-document.js +625 -0
  29. package/lib/artifacts/mapping-document.d.ts +1 -0
  30. package/lib/artifacts/mapping-document.js +1 -0
  31. package/lib/artifacts/native-calculated-insight-document.d.ts +142 -0
  32. package/lib/artifacts/native-calculated-insight-document.js +321 -0
  33. package/lib/artifacts/native-data-graph-document.d.ts +124 -0
  34. package/lib/artifacts/native-data-graph-document.js +780 -0
  35. package/lib/artifacts/native-dmo-document.d.ts +151 -0
  36. package/lib/artifacts/native-dmo-document.js +313 -0
  37. package/lib/artifacts/native-mapping-document.d.ts +67 -0
  38. package/lib/artifacts/native-mapping-document.js +187 -0
  39. package/lib/artifacts/native-relationship-document.d.ts +76 -0
  40. package/lib/artifacts/native-relationship-document.js +232 -0
  41. package/lib/artifacts/path-selector.d.ts +55 -0
  42. package/lib/artifacts/path-selector.js +167 -0
  43. package/lib/artifacts/read-deploy-input.d.ts +222 -6
  44. package/lib/artifacts/read-deploy-input.js +1213 -53
  45. package/lib/artifacts/segment-document.d.ts +183 -0
  46. package/lib/artifacts/segment-document.js +570 -0
  47. package/lib/artifacts/verbatim-document.d.ts +203 -0
  48. package/lib/artifacts/verbatim-document.js +339 -0
  49. package/lib/artifacts/write-data-graph.d.ts +17 -0
  50. package/lib/artifacts/write-data-graph.js +162 -0
  51. package/lib/artifacts/write-data-stream.d.ts +11 -0
  52. package/lib/artifacts/write-data-stream.js +175 -0
  53. package/lib/artifacts/write-data-transform.d.ts +11 -0
  54. package/lib/artifacts/write-data-transform.js +180 -0
  55. package/lib/artifacts/write-dlo.d.ts +11 -0
  56. package/lib/artifacts/write-dlo.js +158 -0
  57. package/lib/artifacts/write-identity-resolution.d.ts +18 -0
  58. package/lib/artifacts/write-identity-resolution.js +165 -0
  59. package/lib/artifacts/write-mapping-definition.d.ts +17 -0
  60. package/lib/artifacts/write-mapping-definition.js +127 -0
  61. package/lib/artifacts/write-member-export.d.ts +88 -0
  62. package/lib/artifacts/write-member-export.js +199 -0
  63. package/lib/artifacts/write-native-calculated-insight.d.ts +21 -0
  64. package/lib/artifacts/write-native-calculated-insight.js +176 -0
  65. package/lib/artifacts/write-native-dmo.d.ts +11 -0
  66. package/lib/artifacts/write-native-dmo.js +158 -0
  67. package/lib/artifacts/write-native-mapping.d.ts +11 -0
  68. package/lib/artifacts/write-native-mapping.js +157 -0
  69. package/lib/artifacts/write-native-relationship.d.ts +11 -0
  70. package/lib/artifacts/write-native-relationship.js +157 -0
  71. package/lib/artifacts/write-segment.d.ts +26 -0
  72. package/lib/artifacts/write-segment.js +212 -0
  73. package/lib/commands/data360/delete.d.ts +280 -0
  74. package/lib/commands/data360/delete.js +2297 -0
  75. package/lib/commands/data360/deploy.d.ts +234 -15
  76. package/lib/commands/data360/deploy.js +2292 -100
  77. package/lib/commands/data360/publish.d.ts +93 -0
  78. package/lib/commands/data360/publish.js +292 -0
  79. package/lib/commands/data360/retrieve.d.ts +260 -13
  80. package/lib/commands/data360/retrieve.js +1880 -85
  81. package/lib/commands/data360/segment/members/export.d.ts +101 -0
  82. package/lib/commands/data360/segment/members/export.js +318 -0
  83. package/lib/errors/codes/calculated-insight.d.ts +2 -0
  84. package/lib/errors/codes/calculated-insight.js +25 -0
  85. package/lib/errors/codes/data-graph.d.ts +2 -0
  86. package/lib/errors/codes/data-graph.js +22 -0
  87. package/lib/errors/codes/data-stream.d.ts +2 -0
  88. package/lib/errors/codes/data-stream.js +70 -0
  89. package/lib/errors/codes/data-transform.d.ts +2 -0
  90. package/lib/errors/codes/data-transform.js +35 -0
  91. package/lib/errors/codes/dependency.d.ts +2 -0
  92. package/lib/errors/codes/dependency.js +11 -0
  93. package/lib/errors/codes/dlo.d.ts +2 -0
  94. package/lib/errors/codes/dlo.js +31 -0
  95. package/lib/errors/codes/dmo.d.ts +2 -0
  96. package/lib/errors/codes/dmo.js +28 -0
  97. package/lib/errors/codes/general.d.ts +2 -0
  98. package/lib/errors/codes/general.js +57 -0
  99. package/lib/errors/codes/identity-resolution.d.ts +2 -0
  100. package/lib/errors/codes/identity-resolution.js +24 -0
  101. package/lib/errors/codes/mapping.d.ts +2 -0
  102. package/lib/errors/codes/mapping.js +42 -0
  103. package/lib/errors/codes/relationship.d.ts +2 -0
  104. package/lib/errors/codes/relationship.js +21 -0
  105. package/lib/errors/codes/segment.d.ts +2 -0
  106. package/lib/errors/codes/segment.js +49 -0
  107. package/lib/errors/registry.d.ts +60 -0
  108. package/lib/errors/registry.js +123 -0
  109. package/lib/plugin.d.ts +1 -0
  110. package/lib/plugin.js +3 -1
  111. package/lib/services/acquire-retrieve-selection.d.ts +43 -0
  112. package/lib/services/acquire-retrieve-selection.js +145 -0
  113. package/lib/services/bind-identity-resolution-dependencies.d.ts +53 -0
  114. package/lib/services/bind-identity-resolution-dependencies.js +238 -0
  115. package/lib/services/bind-segment-dependencies.d.ts +49 -0
  116. package/lib/services/bind-segment-dependencies.js +115 -0
  117. package/lib/services/bounded-reads.d.ts +17 -0
  118. package/lib/services/bounded-reads.js +42 -0
  119. package/lib/services/calculated-insight-sql-checks.d.ts +33 -0
  120. package/lib/services/calculated-insight-sql-checks.js +193 -0
  121. package/lib/services/command-dlo.d.ts +48 -0
  122. package/lib/services/command-dlo.js +103 -0
  123. package/lib/services/command-native-data-graph.d.ts +54 -0
  124. package/lib/services/command-native-data-graph.js +485 -0
  125. package/lib/services/command-native-data-stream.d.ts +104 -0
  126. package/lib/services/command-native-data-stream.js +257 -0
  127. package/lib/services/command-native-dmo.d.ts +124 -0
  128. package/lib/services/command-native-dmo.js +338 -0
  129. package/lib/services/command-native-mapping.d.ts +65 -0
  130. package/lib/services/command-native-mapping.js +129 -0
  131. package/lib/services/command-native-relationship.d.ts +46 -0
  132. package/lib/services/command-native-relationship.js +103 -0
  133. package/lib/services/cross-dataspace-deploy.d.ts +111 -0
  134. package/lib/services/cross-dataspace-deploy.js +493 -0
  135. package/lib/services/cross-dataspace-rename.d.ts +74 -0
  136. package/lib/services/cross-dataspace-rename.js +1314 -0
  137. package/lib/services/cross-dataspace-sql.d.ts +109 -0
  138. package/lib/services/cross-dataspace-sql.js +1301 -0
  139. package/lib/services/cross-space-context.d.ts +23 -0
  140. package/lib/services/cross-space-context.js +36 -0
  141. package/lib/services/crud-plan.d.ts +137 -0
  142. package/lib/services/crud-plan.js +408 -0
  143. package/lib/services/data-space-check.d.ts +89 -0
  144. package/lib/services/data-space-check.js +162 -0
  145. package/lib/services/data-space-prefix.d.ts +77 -0
  146. package/lib/services/data-space-prefix.js +127 -0
  147. package/lib/services/data-transform-space.d.ts +31 -0
  148. package/lib/services/data-transform-space.js +79 -0
  149. package/lib/services/delete-calculated-insight.d.ts +44 -0
  150. package/lib/services/delete-calculated-insight.js +101 -0
  151. package/lib/services/delete-data-transform.d.ts +52 -0
  152. package/lib/services/delete-data-transform.js +222 -0
  153. package/lib/services/delete-dmo-field.d.ts +211 -0
  154. package/lib/services/delete-dmo-field.js +472 -0
  155. package/lib/services/delete-identity-resolution.d.ts +43 -0
  156. package/lib/services/delete-identity-resolution.js +295 -0
  157. package/lib/services/delete-segment.d.ts +42 -0
  158. package/lib/services/delete-segment.js +248 -0
  159. package/lib/services/deploy-result.d.ts +54 -0
  160. package/lib/services/deploy-result.js +60 -0
  161. package/lib/services/escaped-copy.d.ts +23 -0
  162. package/lib/services/escaped-copy.js +88 -0
  163. package/lib/services/execute-calculated-insight-deploy.d.ts +42 -0
  164. package/lib/services/execute-calculated-insight-deploy.js +96 -0
  165. package/lib/services/execute-data-transform-deploy.d.ts +56 -0
  166. package/lib/services/execute-data-transform-deploy.js +168 -0
  167. package/lib/services/execute-native-identity-resolution-deploy.d.ts +48 -0
  168. package/lib/services/execute-native-identity-resolution-deploy.js +360 -0
  169. package/lib/services/execute-segment-deploy.d.ts +45 -0
  170. package/lib/services/execute-segment-deploy.js +393 -0
  171. package/lib/services/local-file-removal.d.ts +36 -0
  172. package/lib/services/local-file-removal.js +103 -0
  173. package/lib/services/native-calculated-insight.d.ts +87 -0
  174. package/lib/services/native-calculated-insight.js +164 -0
  175. package/lib/services/native-crm-data-stream.d.ts +91 -0
  176. package/lib/services/native-crm-data-stream.js +272 -0
  177. package/lib/services/native-data-graph-context.d.ts +12 -0
  178. package/lib/services/native-data-graph-context.js +139 -0
  179. package/lib/services/native-data-graph-crd.d.ts +261 -0
  180. package/lib/services/native-data-graph-crd.js +866 -0
  181. package/lib/services/native-data-stream.d.ts +329 -0
  182. package/lib/services/native-data-stream.js +1830 -0
  183. package/lib/services/native-dlo.d.ts +163 -0
  184. package/lib/services/native-dlo.js +402 -0
  185. package/lib/services/native-dmo.d.ts +191 -0
  186. package/lib/services/native-dmo.js +614 -0
  187. package/lib/services/native-mapping.d.ts +255 -0
  188. package/lib/services/native-mapping.js +1226 -0
  189. package/lib/services/native-relationship.d.ts +132 -0
  190. package/lib/services/native-relationship.js +512 -0
  191. package/lib/services/operation-diagnostic.d.ts +83 -0
  192. package/lib/services/operation-diagnostic.js +272 -0
  193. package/lib/services/preflight-calculated-insight-deploy.d.ts +58 -0
  194. package/lib/services/preflight-calculated-insight-deploy.js +95 -0
  195. package/lib/services/preflight-data-transform-deploy.d.ts +33 -0
  196. package/lib/services/preflight-data-transform-deploy.js +104 -0
  197. package/lib/services/preflight-identity-resolution-deploy.d.ts +107 -0
  198. package/lib/services/preflight-identity-resolution-deploy.js +281 -0
  199. package/lib/services/preflight-segment-deploy.d.ts +31 -0
  200. package/lib/services/preflight-segment-deploy.js +109 -0
  201. package/lib/services/publish-calculated-insight.d.ts +40 -0
  202. package/lib/services/publish-calculated-insight.js +95 -0
  203. package/lib/services/publish-segment.d.ts +65 -0
  204. package/lib/services/publish-segment.js +194 -0
  205. package/lib/services/readback-pace.d.ts +16 -0
  206. package/lib/services/readback-pace.js +23 -0
  207. package/lib/services/retrieve-data-transform.d.ts +26 -0
  208. package/lib/services/retrieve-data-transform.js +65 -0
  209. package/lib/services/retrieve-identity-resolution.d.ts +40 -0
  210. package/lib/services/retrieve-identity-resolution.js +87 -0
  211. package/lib/services/retrieve-inventory.d.ts +32 -0
  212. package/lib/services/retrieve-inventory.js +151 -0
  213. package/lib/services/retrieve-segment.d.ts +120 -0
  214. package/lib/services/retrieve-segment.js +502 -0
  215. package/lib/services/segment-lookup.d.ts +46 -0
  216. package/lib/services/segment-lookup.js +108 -0
  217. package/lib/services/segment-members.d.ts +144 -0
  218. package/lib/services/segment-members.js +402 -0
  219. package/lib/services/select-native-retrieve.d.ts +60 -0
  220. package/lib/services/select-native-retrieve.js +226 -0
  221. package/lib/services/settle-calculated-insight.d.ts +22 -0
  222. package/lib/services/settle-calculated-insight.js +53 -0
  223. package/lib/services/sql-tokens.d.ts +58 -0
  224. package/lib/services/sql-tokens.js +147 -0
  225. package/lib/transport/api-version.d.ts +36 -0
  226. package/lib/transport/api-version.js +89 -0
  227. package/lib/transport/bound-ssot.d.ts +27 -0
  228. package/lib/transport/bound-ssot.js +116 -0
  229. package/lib/transport/calculated-insight-rest.d.ts +28 -0
  230. package/lib/transport/calculated-insight-rest.js +62 -0
  231. package/lib/transport/connect-client.d.ts +94 -32
  232. package/lib/transport/connect-client.js +318 -178
  233. package/lib/transport/connect-diagnostic.d.ts +89 -0
  234. package/lib/transport/connect-diagnostic.js +331 -0
  235. package/lib/transport/data-graph-rest.d.ts +27 -0
  236. package/lib/transport/data-graph-rest.js +76 -0
  237. package/lib/transport/data-stream-rest.d.ts +62 -0
  238. package/lib/transport/data-stream-rest.js +348 -0
  239. package/lib/transport/data-transform-rest.d.ts +25 -0
  240. package/lib/transport/data-transform-rest.js +100 -0
  241. package/lib/transport/dlo-native-rest.d.ts +22 -0
  242. package/lib/transport/dlo-native-rest.js +89 -0
  243. package/lib/transport/dlo-rest.d.ts +23 -0
  244. package/lib/transport/dlo-rest.js +135 -0
  245. package/lib/transport/dmo-native-rest.d.ts +18 -0
  246. package/lib/transport/dmo-native-rest.js +55 -0
  247. package/lib/transport/dmo-rest.d.ts +30 -0
  248. package/lib/transport/dmo-rest.js +163 -0
  249. package/lib/transport/mapping-rest.d.ts +63 -0
  250. package/lib/transport/mapping-rest.js +341 -0
  251. package/lib/transport/project-metadata.d.ts +36 -0
  252. package/lib/transport/project-metadata.js +118 -0
  253. package/lib/transport/relationship-rest.d.ts +43 -0
  254. package/lib/transport/relationship-rest.js +201 -0
  255. package/package.json +29 -6
  256. package/lib/artifacts/dmo-document.d.ts +0 -181
  257. package/lib/artifacts/dmo-document.js +0 -848
  258. package/lib/artifacts/dmo-update-delta.d.ts +0 -28
  259. package/lib/artifacts/dmo-update-delta.js +0 -86
  260. package/lib/artifacts/write-other-dmo.d.ts +0 -17
  261. package/lib/artifacts/write-other-dmo.js +0 -140
  262. package/lib/services/execute-dmo-create.d.ts +0 -24
  263. package/lib/services/execute-dmo-create.js +0 -118
  264. package/lib/services/execute-dmo-deploy.d.ts +0 -33
  265. package/lib/services/execute-dmo-deploy.js +0 -197
  266. package/lib/services/preflight-dmo-deploy.d.ts +0 -69
  267. package/lib/services/preflight-dmo-deploy.js +0 -161
  268. package/lib/services/retrieve-other-dmo.d.ts +0 -46
  269. package/lib/services/retrieve-other-dmo.js +0 -140
package/README.md CHANGED
@@ -1,258 +1,590 @@
1
1
  # Data360 Salesforce CLI plugin
2
2
 
3
- `sf-plugin-data` is an independently authored TypeScript/ESM
4
- plugin for portable Data360 configuration. **Bounded explicit DMO retrieval is
5
- implemented; strictly read-only deployment preview, bounded guarded creation and label updates are available.** Current retrieval capability is
6
- owned by the common service (API 65.0/default, qualified generated recipe and semantics),
7
- not a permanent DMO architecture. This is not yet a general migration tool or a
8
- published release.
3
+ `sf-plugin-data` adds the `sf data360` commands to Salesforce CLI. They copy Data Cloud (Data 360) configuration between an org and files on your disk: you retrieve components into JSON
4
+ files, keep them in Git, edit them, preview what a deploy would change and deploy them to the
5
+ same or another org. The plugin can also delete components, publish segments and calculated
6
+ insights, and export the members of a segment.
7
+
8
+ What it is not:
9
+
10
+ - **Not a backup, restore or migration tool.** It handles the component types listed in the
11
+ [type overview](#type-overview), not everything Data Cloud holds, and never copies data rows.
12
+ - **Not side-effect free.** Deploying a stream, a segment, a graph or an identity resolution
13
+ ruleset can start processing in the org. Run `--preview` first.
14
+
15
+ Background, evidence and the Salesforce behaviour behind each type are on sfmc.guide:
16
+ [Data Cloud DevOps](https://sfmc.guide/next/data-cloud-devops/) and
17
+ [Data spaces](https://sfmc.guide/next/data-spaces/).
18
+
19
+ ## Install and sign in
20
+
21
+ You need Salesforce CLI, Node.js `^22.22.2 || ^24.15.0` and npm. Until the package is
22
+ published, install it from a checkout of this repository:
9
23
 
10
24
  ```sh
11
- sf data360 retrieve -o source --api-version 65.0 --data-space default -m dmo:Example__dlm -d ./project --json
12
- sf data360 retrieve -o source -m dmo:Example__dlm -d ./project -x
25
+ npm ci
26
+ npm run build
27
+ sf plugins link .
28
+ sf data360 --help
13
29
  ```
14
30
 
15
- `-m/--metadata` is repeatable/non-greedy: exact `dmo:ApiName` selectors coalesce
16
- and sort without an inventory request. `-m dmo` retrieves all DMOs in the selected
17
- space using complete inventory; omitting selectors retrieves all implemented
18
- families (currently DMO only). There is no `--all` flag. Mixed type/exact selections
19
- coalesce. Empty inventory succeeds with no files. Unsupported objects are not
20
- silently skipped: diagnostics identify each object and precise capability/error
21
- code, successful file receipts are retained, and the aggregate exits nonzero. `-o/--target-org` overrides the configured default org. `-d/--output-dir`
22
- is a project root, default cwd; output is `data360/default/dmo/<api-name>.json`.
23
- `-x/--overwrite` permits differing file replacement; identical bytes are unchanged.
24
- Selectors and API 65.0/default scope are validated before core org resolution or
25
- resource reads; the common service remains the per-object capability boundary.
26
- `--json` uses Salesforce CLI's normal outer result wrapper containing a versioned
27
- `sf-data360-retrieve` envelope with status, metadata, diagnostics, provenance and
28
- result. Both retrieve and deploy resolve `metadata.plugin.version` and
29
- `provenance.pluginVersion` from this plugin's own package metadata, not the host
30
- Salesforce CLI version. Blocked/failed work exits 1, success exits 0. Parser/auth flag failures use
31
- core CLI diagnostics; runtime errors never include remote payloads. No org mutation.
32
-
33
- A common offline `joinDmoConnectMetadataFields` helper now joins arbitrary
34
- nonempty field counts and all 12 authored types with exact identity, primary,
35
- dynamic and explicit qualifier semantics. Generated fields stay outside authored
36
- fields; unqualified replay semantics remain blockers. The common object projector
37
- now qualifies complete acquired inputs before the service/command publishes an
38
- authored candidate; no fixed authored count or fixture-specific command rule applies.
39
-
40
- Internal `preflightDmoDeploy` now performs read-only target-aware comparison for
41
- one explicitly supplied authored DMO and API 65.0/default connection. Complete
42
- inventory alone proves absence; existing targets must pass common full retrieval.
43
- Field reordering alone is unchanged. Public preview opts into qualified object and
44
- existing non-primary field label updates; unsupported differences and unknown target semantics fail closed. Its preview
45
- contains static diagnostics, never requests, raw org IDs or remote payloads.
46
- `sf data360 deploy --preview` now uses this service for every explicitly selected
47
- local authored input. API 65.0/default scope remains service-owned. Execution
48
- admission requires Other category with a nondynamic Text primary key; other
49
- portable offline schemas are blocked before target reads because current readback
50
- cannot qualify them. Authored counts and other field types remain unrestricted.
51
- Internal `executeDmoCreate` now performs fresh preflight, a single guarded create only
52
- on proven absence, and independent qualified readback. Existing equality is a no-op;
53
- existing differences remain blocked. HTTP success alone is not verified creation;
54
- ambiguous failures retain `mutation: unknown` and require target inspection, never
55
- automatic retry or rollback. Public CLI creation delegates to this service through `executeDmoDeploy`;
56
- qualification remains synthetic only, not broader deployment or live acceptance.
57
- Metadata SOAP reads refuse same-origin and cross-origin redirects through an
58
- operation-local transport guard; core still owns credentials and SOAP parsing,
59
- and the caller connection/global transport defaults are unchanged.
60
-
61
- Internal offline `buildDmoUpdateDelta` constructs a minimal candidate PATCH and a
62
- nondestructive expected overlay, or returns blockers only. It preserves target-only
63
- fields and omitted descriptions; no removal/tombstone syntax exists. This is not
64
- itself mutation authorization. Public preview and `executeDmoDeploy` now admit only object and existing
65
- non-primary field label changes within the qualified Other/default/API 65 scope.
66
- The selection is fully admitted before writes, then freshly qualified per item;
67
- independent readback must match the overlay and preserve full runtime state. New
68
- fields, descriptions, primary-key labels and other unproven changes block atomically.
69
- Results distinguish `confirmed-updated`, `not-attempted` and `unknown`; ambiguity
70
- stops the public selection without retry or rollback.
71
- API 65 PATCH
72
- routing is documented. Retained synthetic PATCH evidence now qualifies the observed
73
- existing-field display override and complete authored overlay offline; the common
74
- projector reconciles Connect labels with Metadata field overrides while preserving
75
- base/master observations. This is one recorded checkpoint, not general update or
76
- new-field preservation acceptance. HTTP 200 can contain old state, so
77
- execution independently GETs and qualifies readback.
78
-
79
- An internal read-only `readDeployInputs` resolver now admits explicit authored JSON
80
- files/directories or repeated exact `dmo:ApiName` project selectors. Identical paths
81
- coalesce; different files claiming the same identity fail. No selection, bare types,
82
- mixed modes, malformed JSON, duplicate JSON keys, runtime projections and linked
83
- paths fail closed. Directory mode is bounded and strict: every descendant file must
84
- be authored DMO JSON; unrelated files are not silently ignored. This input-only
85
- resolver is wired to preview and execution; input admission alone never authorizes writes.
86
-
87
- ## Package identity and command aliases
88
-
89
- The user-selected current npm identity is **`sf-plugin-data`**, unscoped, at
90
- version `0.1.0`. The repository and directory remain `sf-plugin-data360` under
91
- GitHub owner `JoernBerkefeld`. This is a local product-naming change, not a claim
92
- that npm will accept the name or an attempt to bypass npm restrictions. No lookup
93
- or publication of the new name has been performed; restriction resolution and
94
- release approval remain separate work.
95
-
96
- Canonical commands remain `sf data360 retrieve` and `sf data360 deploy`.
97
- `datacloud`, `d360` and `dc` are equivalent topic aliases for both operations,
98
- including their flags and help. There are only two command implementations and
99
- no `sf data` registrations. Aliases retain canonical `sf-data360-*` envelopes,
100
- provenance command strings, `data360/...` layout and DMO schema/kind; only plugin
101
- identity metadata changes. API 65.0/default limitations remain unchanged.
102
-
103
- Historical evidence: the old unscoped `sf-plugin-data360` lookup returned `E404`
104
- on 2026-10-26, but its later manual publication was rejected with npm `E403`
105
- spam detection. Earlier scoped artifacts and the rejected unscoped artifacts
106
- remain historical evidence only and must not be reused for the current name.
107
- The existing `v0.1.0` tag at `a328066` still identifies `sf-plugin-data360`, not
108
- this local rename. Earlier commit/push/tag approval does not authorize new
109
- history changes or reuse of that tag. Any future release requires fresh explicit
110
- approval, a tree-bound inspected artifact and separate npm restriction resolution.
31
+ Sign in to a Data Cloud org with the usual Salesforce CLI login and pass its alias with
32
+ `--target-org` (or `-o`):
111
33
 
112
- ## Local development
34
+ ```sh
35
+ sf org login web --alias source
36
+ ```
37
+
38
+ Your user needs the Data Cloud permissions for the components you work with. Linking the plugin
39
+ does not grant any org access. `datacloud`, `d360` and `dc` work as aliases of `data360`, for
40
+ example `sf dc retrieve`.
41
+
42
+ ## Use it in VS Code
113
43
 
114
- Requires Node `^22.22.2 || ^24.15.0` and npm. Run from this independent repository:
44
+ - **Data 360 DevTools** (pre-release, not yet published) runs these commands from right-click menus
45
+ and the Command Palette in VS Code, and groups your files by data space in a side panel.
46
+ - It brings its own copy of this plugin, so no `sf plugins install` or link is needed there.
47
+
48
+ ## Quick start
115
49
 
116
50
  ```sh
117
- npm ci --no-workspaces
51
+ # 1. Retrieve components into ./data360/
52
+ sf data360 retrieve -o source -m dlo -m dmo -m mapping
53
+
54
+ # 2. Edit the files, then see what a deploy would do (read-only)
55
+ sf data360 deploy -o target -m dmo:Customer__dlm -m mapping:Customer_Map --preview
56
+
57
+ # 3. Deploy
58
+ sf data360 deploy -o target -m dmo:Customer__dlm -m mapping:Customer_Map
59
+
60
+ # Delete a component by name (preview first)
61
+ sf data360 delete -o target -m segment:Old_Segment --preview
62
+ sf data360 delete -o target -m segment:Old_Segment
63
+
64
+ # Deploy what changed in Git since main, and delete what was deleted
65
+ sf data360 deploy -o target --changed-since main --preview
66
+ sf data360 delete -o target --changed-since main --confirm-delete
67
+ ```
68
+
69
+ The commands:
70
+
71
+ | Command | What it does |
72
+ | ----------------------------------- | ------------------------------------------------------------------------ |
73
+ | `sf data360 retrieve` | Saves components from the org as files under `data360/`. |
74
+ | `sf data360 deploy` | Creates or updates components from files; `--preview` only compares. |
75
+ | `sf data360 delete` | Deletes components by name, or the ones whose files a Git range deleted. |
76
+ | `sf data360 publish` | Publishes one segment or one calculated insight. |
77
+ | `sf data360 segment members export` | Writes the members of a published segment to a CSV or JSON file. |
78
+
79
+ Every command has `--help` with all flags, and `--json` for machine-readable output.
80
+
81
+ ## Type overview
82
+
83
+ Each row is one component type. The first cell links to the type's reference page and names the
84
+ selector you use with `-m`. **Available** means the plugin has that operation; **Unavailable**
85
+ means the plugin has none (it does not mean Salesforce lacks it). Every type works in any data
86
+ space of the org; see [Data spaces](#data-spaces).
87
+
88
+ | Type | Retrieve | Create | Update | Delete | More |
89
+ | ------------------------------------------------------------------------------- | ----------- | ----------- | ----------- | ----------- | ---------------------------------------------------------------------------- |
90
+ | [Data streams](docs/types/data-stream.md), `data-stream` | Available | Available | Available | Available | `--delete-dlo` deletes the landing DLO with the stream; `--allow-processing` |
91
+ | [Data Lake Objects (DLOs)](docs/types/dlo.md), `dlo` | Available | Available | Available | Available | Data space membership; `--allow-dataspace-removal` |
92
+ | [Data Model Objects (DMOs)](docs/types/dmo.md), `dmo` | Available | Available | Available | Available | Field delete (`delete --field`); `--allow-field-removal` |
93
+ | [DLO-to-DMO mappings](docs/types/mapping.md), `mapping` | Available | Available | Available | Available | Mapping label |
94
+ | [DMO field relationships](docs/types/relationship.md), `relationship` | Available | Available | Available | Available | Retrieve by source DMO (`relationship:<Dmo__dlm>`) |
95
+ | [Data transforms](docs/types/data-transform.md), `data-transform` | Available | Available | Available | Available | Schedule |
96
+ | [Calculated insights](docs/types/calculated-insight.md), `calculated-insight` | Available | Available | Available | Available | `sf data360 publish`; `--draft` |
97
+ | [Segments](docs/types/segment.md), `segment` | Available | Available | Available | Available | `sf data360 publish`; schedule; `--allow-processing` |
98
+ | [Segment members](docs/types/segment.md#export-segment-members) | Available | Unavailable | Available | Unavailable | Read: `sf data360 segment members export`; update: `sf data360 publish` |
99
+ | [Data graphs](docs/types/data-graph.md), `data-graph` | Available | Available | Available | Available | Schedule; `--allow-processing`; `--wait-timeout` |
100
+ | [Identity resolution](docs/types/identity-resolution.md), `identity-resolution` | Available | Available | Available | Available | `--async`; `--allow-processing` |
101
+ | Source object definitions | Unavailable | Unavailable | Unavailable | Unavailable | Connectors and credentials are not handled |
102
+ | Kit templates | Unavailable | Unavailable | Unavailable | Unavailable | Data kits are not handled |
103
+ | Kit definitions | Unavailable | Unavailable | Unavailable | Unavailable | Data kits are not handled |
104
+ | Kit membership | Unavailable | Unavailable | Unavailable | Unavailable | Data kits are not handled |
105
+
106
+ Segment members are the rows Salesforce computes when a segment is published, so they cannot be
107
+ created or deleted. Cross-type deletes, the delete order and local file removal are described in
108
+ [Delete](docs/types/delete.md).
109
+
110
+ ## What it does that the Data Cloud UI does not
111
+
112
+ - **Change an existing relationship's label and cardinality in place.** The UI only lets you
113
+ activate or delete an existing relationship.
114
+ - **Create, update and delete SQL (DBT) segments**, with the SQL in its own `.sql` file. The UI
115
+ builds segments only visually.
116
+ - **Retrieve many components in one command** into files you keep in Git.
117
+ - **Deploy only what changed in a Git range** with `--changed-since`, and delete what the range
118
+ deleted.
119
+ - **Deploy or delete related components of several types in one command**, in dependency order:
120
+ for example DLOs, DMOs, mappings and a relationship in one deploy, or data graphs before the
121
+ identity resolution ruleset they use in one delete.
122
+
123
+ ## How it works
124
+
125
+ ### Files on disk
126
+
127
+ Retrieve writes one folder per type under `data360/` in the current directory (or
128
+ `--output-dir`). Each component is one JSON file named after it; segments and calculated
129
+ insights keep their SQL in separate `.sql` files next to the JSON.
130
+
131
+ | Type | File |
132
+ | ------------------- | ------------------------------------------------------------------------------------------------- |
133
+ | Data stream | `data360/data-stream/<Name>.data-stream-meta.json` |
134
+ | DLO | `data360/dlo/<Name>__dll.dlo-meta.json` |
135
+ | DMO | `data360/dmo/<Name>__dlm.dmo-meta.json` |
136
+ | Mapping | `data360/mapping/<Name>.mapping-meta.json` |
137
+ | Relationship | `data360/relationship/<Name>.relationship-meta.json` |
138
+ | Data transform | `data360/dataTransforms/<Name>.dataTransform.json` |
139
+ | Calculated insight | `data360/calculatedInsights/<Name>.calculatedInsight-meta.json` and `.calculatedInsight-meta.sql` |
140
+ | Segment | `data360/segments/<Name>.segment.json` and `<Name>.segment.<model>.sql` |
141
+ | Data graph | `data360/dataGraphs/<Name>.native-dataGraph.json` |
142
+ | Identity resolution | `data360/identityResolution/<Name>.identityResolution.json` |
143
+
144
+ The files hold what you need to recreate a component in another org: no record IDs, no
145
+ values Salesforce generates, no status. Fields and mapping pairs that Salesforce adds by itself
146
+ are left out, and deploy keeps them. The exact layout of each file is on its type page and in
147
+ [artifact format](docs/artifact-format.md).
148
+
149
+ ### Selecting components
150
+
151
+ - `-m <type>:<Name>` selects one component; repeat `-m` to select several, of any types.
152
+ - For retrieve, a bare type (`-m dmo`) selects every component of that type the org lists.
153
+ Retrieve without `-m` selects every DLO, DMO and mapping.
154
+ - Deploy and delete always name their components, or take them from Git with
155
+ `--changed-since`. Deploy also takes files and folders with `--source-dir` (`-d`).
156
+
157
+ ### Preview first
158
+
159
+ `sf data360 deploy --preview` and `sf data360 delete --preview` read the org and report, per
160
+ component, what would happen: `create`, `update`, `unchanged`, `delete`, or `blocked` with the
161
+ reason. They never write to the org and never change local files. When a component needs another
162
+ component that the same command creates first, the preview cannot compare it yet and reports
163
+ `planned-dependencies` for it.
164
+
165
+ ### Deploy
166
+
167
+ - **Order.** One deploy can hold components of several types; the plugin sorts them by
168
+ dependency. Data streams go first, then the native objects in the order DLO, DMO, mapping,
169
+ relationship, then transforms, calculated insights, segments and identity resolution, and data
170
+ graphs last. Each component settles before the next one that depends on it is written.
171
+ - **Sent as written, Salesforce decides.** The plugin sends the file as you wrote it and reports
172
+ Salesforce's answer as the component's error. It keeps no list of allowed values of its own.
173
+ It refuses a change before any write only where Salesforce would accept the request but not
174
+ apply it, or where the change cannot be undone (for example removing fields); the type pages
175
+ list these refusals.
176
+ - **Size.** One deploy takes at most 256 components and 512 links between them. A larger
177
+ selection stops before any write with `DEPENDENCY_LIMIT_EXCEEDED`; split it into smaller
178
+ deploys and run them one after another.
179
+ - **Unchanged components are not written.** Deploying the same file again reports `unchanged`.
180
+ Values that differ only in letter case (`Text` and `text`) count as equal.
181
+ - **Processing.** Creating or updating a data stream, segment, data graph or identity resolution
182
+ ruleset makes Salesforce start processing, so these need `--allow-processing`. Transforms and
183
+ calculated insights do not, but a deployed schedule makes them run in the target org; preview
184
+ warns about that.
185
+ - **Stops on the first problem.** A blocked, failed or unknown result stops the deploy; later
186
+ components report `not-attempted`. Components already written stay written: there is no
187
+ rollback.
188
+ - **Unknown outcome.** When the plugin cannot tell whether a write happened (for example the
189
+ connection dropped), the result says `unknown`. Check the org before you run the deploy
190
+ again; the plugin never repeats such a write by itself.
191
+
192
+ ### Retrieve is lenient, deploy is strict
193
+
194
+ - Retrieve never refuses a component because the org returns something the plugin does not
195
+ recognise. One failing component never stops the others.
196
+ - A setting the plugin does not recognise stays in the retrieved file. Deploy refuses such a
197
+ file and names the setting.
198
+ - A component the file format cannot hold is saved exactly as Salesforce returned it, with a
199
+ warning. Deploy skips such a file in a folder or Git deploy and refuses it when you name it
200
+ (error `VERBATIM_NOT_DEPLOYABLE`). You can still delete the component by name.
201
+
202
+ ### Delete
203
+
204
+ `sf data360 delete` takes any mix of types and deletes them in reverse dependency order: graphs
205
+ first, then identity resolution, calculated insights and segments, transforms, relationships,
206
+ mappings, DMOs, DLOs, and data streams last. Each phase finishes before the next starts.
207
+
208
+ - Components are selected by name with `-m`. A delete reads no local file, except for a mapping,
209
+ which it finds through its local file like deploy does. A `-m` delete needs
210
+ no confirmation flag, so check it with `--preview` first.
211
+ - `--changed-since <ref>` deletes the components whose files were deleted in that Git range. It
212
+ always needs `--confirm-delete` (not with `--preview`).
213
+ - A component the org does not have reports `unchanged`.
214
+ - A data stream keeps its landing DLO unless you add `--delete-dlo`.
215
+ - `sf data360 delete -m dmo:<Name>__dlm --field <Field__c>` removes single fields of a DMO.
216
+
217
+ Details, including what is read before anything is deleted: [Delete](docs/types/delete.md).
218
+
219
+ ### Local files after delete
220
+
221
+ After a confirmed deletion, `sf data360 delete` also removes the deleted component's local file
222
+ (and its `.sql` files) at its usual path under `data360/`. It does the same when Salesforce has
223
+ accepted the deletion and is still finishing it. Pass `--keep-local-files` to keep the files.
224
+
225
+ - `--preview` removes nothing; it lists the files that would go.
226
+ - Only regular files inside the project's `data360` folder are removed, one at a time.
227
+ - If a file cannot be removed, the org result stays as it is and the command exits with an
228
+ error; remove that file by hand instead of repeating the delete.
229
+ - A `--changed-since` delete removes no file: its files are already gone in Git.
230
+ - A field delete (`--field`) removes no file; it refreshes the DMO and mapping files.
231
+
232
+ The JSON fields and every case are in [Delete](docs/types/delete.md#local-files-after-delete).
233
+
234
+ ### Output, JSON and error codes
235
+
236
+ Human output prints one line per component, such as `created dmo Customer__dlm`. The suffix
237
+ ` (server is still processing)` means Salesforce accepted the change and is still working on it.
238
+ The exit code is 0 only when every component was created, updated, deleted or unchanged.
239
+
240
+ Every problem carries a plugin error code, a short hint and a link to the code's page:
241
+
242
+ ```text
243
+ IDENTITY_RESOLUTION_NOT_SETTLED: <message, including Salesforce's own detail when there is one>
244
+ Hint: <what went wrong and what to do>
245
+ Docs: https://github.com/JoernBerkefeld/sf-plugin-data/blob/v<version>/docs/errors/identity-resolution/IDENTITY_RESOLUTION_NOT_SETTLED.md
246
+ ```
247
+
248
+ With `--json`, each diagnostic has the same `hint` and `docs` fields next to `code` and
249
+ `message`. The full list, grouped by type, is in [docs/errors/README.md](docs/errors/README.md).
250
+
251
+ When Salesforce refuses a request, the message shows its HTTP status, error code and
252
+ explanation. HTTP 429 and 503 mean rate limits or availability problems: wait and try again.
253
+ Reads are retried a few times by themselves; writes are not.
254
+
255
+ ### API version
256
+
257
+ Every type uses Data Cloud API 68 by default (`--api-version auto`). DLOs, DMOs, mappings and
258
+ relationships also accept an explicit version from `61.0` up, which the plugin keeps instead of
259
+ upgrading. The other types accept `auto` or `68.0`. `--api-version latest` is not accepted.
260
+
261
+ ## Data spaces
262
+
263
+ Every command runs in one data space, chosen with the optional `--dataspace NAME`;
264
+ `--data-space` is a compatibility alias. Neither spelling has a CLI default of its own: leave
265
+ both out and the command works in `default`. A command never works on all data spaces at once,
266
+ and an unknown data space stops it before any read or write.
267
+
268
+ - **The file names its data space.** Every file carries the top-level key `c__dataSpace`. Deploy
269
+ and delete refuse a file of another data space than the run's, before any write. Deploy can
270
+ translate some of them with `--allow-cross-dataspace` (below).
271
+ - **DLOs follow the run's data space** and can belong to several data spaces. Their file lists
272
+ all of them in `c__dataSpace`. Deploy adds the DLO to the listed data spaces it is not in yet.
273
+ It removes the DLO from a data space the file no longer lists only with
274
+ `--allow-dataspace-removal`. Delete refuses a DLO that also belongs to another data space.
275
+ - **Data streams** belong to the data spaces of their landing DLO; change them through the DLO
276
+ file.
277
+ - **Names are what Salesforce stores.** Every data space has a prefix, chosen when it was
278
+ created. Outside `default`, Salesforce puts that prefix in front of some names: in a data
279
+ space with the prefix `ds2`, a standard DMO is a copy such as `ds2_Individual__dlm` (fields
280
+ without `ssot__`), a segment is stored as `ds2_<Name>`, and an identity resolution ruleset as
281
+ `ds2_<type>_<rulesetId>`. Files carry these names, and the plugin adds or removes no prefix.
282
+ - **First mapping onto a standard DMO copy.** The copy exists only once something is mapped
283
+ onto it in that data space. Deploy the mapping, not a DMO file, to create it; the plugin
284
+ sends the mapping the way Salesforce takes it. This works for the copy of an `ssot__` DMO;
285
+ the copy of a standard DMO without `ssot__` (`ds2_StaticCurrencyRates_Home__dlm`) the plugin
286
+ cannot create yet: map a DLO onto it in the data space in Salesforce.
287
+
288
+ ### Name prefixes (only if you have more than one data space)
289
+
290
+ Custom DMOs, calculated insights, data transforms and data graphs have names that are unique in
291
+ the whole org, whatever their data space. So their names carry the prefix of their data space,
292
+ as Salesforce does itself for segments and identity resolution rulesets. This keeps names from
293
+ clashing between data spaces and shows at a glance where a component belongs. Examples for
294
+ `dataspace2` with the prefix `ds2`:
295
+
296
+ - Custom DMO: `ds2_Order__dlm`
297
+ - Calculated insight: `ds2_Spend__cio`
298
+ - Data transform: `ds2_CopyOrders`
299
+ - Data graph: `ds2_OrderGraph`
300
+
301
+ What the plugin does:
302
+
303
+ - In a data space other than `default`, the name must start with that space's prefix and an
304
+ underscore. In `default`, it must not start with the prefix of another data space.
305
+ - **Deploy of a new component** with a name that breaks the rule is refused before the first
306
+ write of the whole deploy (`DMO_PREFIX_MISMATCH`, `CI_PREFIX_MISMATCH`,
307
+ `TRANSFORM_PREFIX_MISMATCH`, `DATA_GRAPH_PREFIX_MISMATCH`).
308
+ - **Deploy of an existing component** and **retrieve** only warn; the plugin never renames
309
+ anything in the org.
310
+ - Only what you make yourself is checked. Standard DMOs and their copies, objects Salesforce
311
+ generates and packaged components are not.
312
+ - With only the `default` data space nothing is checked and nothing extra is read.
313
+
314
+ ### Deploy from another data space (only if you have more than one data space)
315
+
316
+ `sf data360 deploy --dataspace <target> --allow-cross-dataspace` (short `-c`) deploys files of
317
+ another data space into `<target>`. Each file's `c__dataSpace` says where it comes from. Without
318
+ the flag such a file is refused, and the message names the flag.
319
+
320
+ ```bash
321
+ # See every rename first; nothing is written
322
+ sf data360 deploy -o myOrg --dataspace dataspace2 -c -d data360/dmo/Order__dlm.dmo-meta.json -d data360/segments/Audience.segment.json --preview
323
+ # Then deploy
324
+ sf data360 deploy -o myOrg --dataspace dataspace2 -c -d data360/dmo/Order__dlm.dmo-meta.json -d data360/segments/Audience.segment.json --allow-processing
325
+ ```
326
+
327
+ - **What is translated:** DMOs, mappings, relationships, UI, Waterfall and SQL (DBT)
328
+ segments, calculated insights (classic and SQL Insights Builder), data graphs, identity
329
+ resolution rulesets, STL data transforms (load, join, formula, filter, SQL filter, aggregate,
330
+ append and output nodes) and DCSQL data transforms. A DLO is added to the target data space;
331
+ nothing in it is renamed.
332
+ - **How names change:** by fixed rules, with the prefixes from the org's list of data spaces.
333
+ - Custom DMOs and segments get, lose or swap the prefix: `Order__dlm` becomes
334
+ `ds2_Order__dlm`, `Audience` becomes `ds2_Audience`.
335
+ - A standard DMO becomes its copy and its fields lose `ssot__`: `ssot__Individual__dlm`
336
+ becomes `ds2_Individual__dlm`, `ssot__FirstName__c` becomes `FirstName__c`.
337
+ - Data graphs, data transforms and rulesets get, lose or swap the prefix: `PhoneGraph`
338
+ becomes `ds2_PhoneGraph`, ruleset `Individual_t1` becomes `ds2_Individual_t1` (the ruleset
339
+ ID stays).
340
+ - Identity resolution outputs: when their ruleset is in the same deploy,
341
+ `UnifiedssotIndividual<Id>__dlm` becomes `ds2_UnifiedIndividual<Id>__dlm`. Otherwise deploy
342
+ reads the org's ruleset list once and takes the output of the one ruleset of the same type
343
+ in the target data space; none or several are refused. The outputs of the oldest `default`
344
+ ruleset have no suffix (`UnifiedIndividual__dlm`) and are always placed from that list.
345
+ - The names Salesforce generates for one graph (its helper DMOs and transform, join and field
346
+ developer names) are left out; Salesforce generates new ones. A node developer name is
347
+ rebuilt as Salesforce builds it: `ds2_PhoneGraph_ds2_ContactPointPhone`.
348
+ - In a transform, a field after a join written with the side's qualifier (`R.FirstName__c`)
349
+ is placed by that side. Output DLO names stay, and a DLO has only one writing transform
350
+ across data spaces: give the copy another output object, or delete the source transform.
351
+ - A mapping keeps its DLO side; it is found by its DLO and DMO, as always.
352
+ - Calculated insights get, lose or swap the prefix: `Spend__cio` becomes `ds2_Spend__cio`.
353
+ - **SQL is renamed name by name** (calculated insights, DBT segment models and DCSQL transforms):
354
+ - Tables follow the rules above. A DLO (`__dll`) keeps its name. Another insight (`__cio`)
355
+ gets the prefix.
356
+ - A column follows the rules of its table, through the table name, its alias, a `WITH` block
357
+ or a subquery: `i.ssot__FirstName__c` on `ssot__Individual__dlm i` becomes
358
+ `i.FirstName__c`.
359
+ - A column without a table in front is renamed only when every table of the query spells it
360
+ the same way. Otherwise write the table or alias in front of it.
361
+ - Texts in single quotes and comments never change. `WITH` block names, aliases and column
362
+ aliases are your names and stay. Double quotes and backticks are names.
363
+ - A column alias works without `AS` after a closing bracket, a field, a number or a text
364
+ (`SUM(x) total__c`, `i.FirstName__c fn__c`), as Salesforce accepts it. Right after an
365
+ operator word such as `NOT`, `OR`, `IS`, `BETWEEN … AND` or `EXISTS`, the next name is a
366
+ column to rename, not an alias: write `AS` there if you mean an alias. An alias still
367
+ spelled like the old data space (`COUNT(x) ssot__Total__c`) is refused.
368
+ - SQL ignores case, the rules do not: a name with its rule part in another case
369
+ (`SSOT__ID__C`, `Individual__DLM`) is refused. Write `ssot__`, `__c` and `__dlm` in lower case.
370
+ - Salesforce accepts an insight left in the `default` spelling in another data space, then
371
+ fails it about three minutes after activation without a message. So after the rewrite
372
+ every name of the SQL outside texts and comments must be placed, and none may keep the old
373
+ spelling.
374
+ - A name equal to a column alias reads that alias in `ORDER BY` and `HAVING` (also `SORT BY`,
375
+ `DISTRIBUTE BY`, `CLUSTER BY`, `QUALIFY`), as Spark reads it. In `WHERE` and `GROUP BY` it
376
+ reads the table's column. After `UNION`, `ORDER BY` reads the names of the first branch
377
+ (its aliases and its columns): a name the first branch does not put out is refused there.
378
+ - In a DCSQL transform the columns land by name in the fields of the node's output object
379
+ (`relation_name`). An alias spelled like an output field follows that field, and so do its
380
+ uses in `ORDER BY` and `HAVING`
381
+ (`AS ssot__Name__c` becomes `AS Name__c` when the field becomes `Name__c`). A `GROUP BY`
382
+ name equal to such a renamed alias is refused, because Spark reads it as a
383
+ table column when one exists and as the alias otherwise: group by the expression itself. An
384
+ alias of the column of the same name (`s.Id__c AS Id__c`) is not refused, since that column
385
+ exists. A column without
386
+ an alias is refused when its name and its field's name no longer match in the target (an
387
+ output DLO keeps its fields, so `SELECT ssot__Id__c …` into it is refused): write it with
388
+ `AS` and the field name as the source data space spells it. `*` over a table that is not a
389
+ DLO is refused too, and so is `*` over a DLO when the output fields change: list the columns.
390
+ - A DCSQL node whose `relation_name` names no output object of the transform is an
391
+ intermediate model: its `relation_name` follows the object rules, and its columns are
392
+ checked the same way against that object's fields as the other nodes read them (a DLO keeps
393
+ its fields; a DMO's fields follow its rule, and a custom DMO's never change, so `*` over a DLO
394
+ into one is kept). A node without a `relation_name` is refused. A node's `config`
395
+ (`materialized: table`) is kept, but a value in it that holds an object or field name
396
+ (`unique_key: Id__c`) is refused.
397
+ - Positions are reported per SQL file, line and column.
398
+ - **Nothing is guessed.** A name no rule places exactly is listed, and the whole deploy is
399
+ refused before any write (`CROSS_DATASPACE_UNRESOLVED`). For example, `ds2_Order__dlm`
400
+ towards `default` can be a standard copy or a custom DMO: select its retrieved DMO file too.
401
+ - **Graphs, rulesets and transforms are checked completely.** Salesforce accepts a graph left in
402
+ the `default` spelling in another data space and builds it on the `default` objects. So after
403
+ the translation every object and field name must be covered, and none may keep the old
404
+ spelling; otherwise the file is refused (`CROSS_DATASPACE_UNRESOLVED`).
405
+ - **Not translated yet:** STL transforms with any other node, transforms of other types (such
406
+ as streaming SQL), and data streams. Under the flag they are refused before any write
407
+ (`CROSS_DATASPACE_UNSUPPORTED`).
408
+ - **`--preview`** lists every rename (file, place in the file, old and new name, rule) and the
409
+ copy files it would write. It writes nothing.
410
+ - **Copy files:** after an item has deployed, deploy writes its translated file under the new
411
+ name, for example `data360/dmo/ds2_Order__dlm.dmo-meta.json`, and for an insight or DBT
412
+ segment its SQL files beside it. Your original files never change.
413
+ - A copy goes only to a new path. An existing file with the same content is reused; one with
414
+ other content stops the deploy before any write (`CROSS_DATASPACE_COPY_CONFLICT`).
415
+ - A mapping or relationship copy takes the name Salesforce gave it. A mapping copy holds the
416
+ mapping as Salesforce stores it, the same file a retrieve of the target data space writes.
417
+ That name is known only after the deploy, so another file already at that path does not stop
418
+ the deploy: the copy is reported as not written, in the output and in the `--json` warnings.
419
+ - A copy file selected beside its original (for example `-d data360` after an earlier `-c`
420
+ run) would deploy the same item twice; the deploy is refused before any write
421
+ (`DUPLICATE_IDENTITY`) and names both files.
422
+ - A DLO gets no copy file; the output shows its new data space.
423
+
424
+ Each type page has a "Data spaces" section with its own rules. The
425
+ [Data spaces guide on sfmc.guide](https://sfmc.guide/next/data-spaces/) explains the concept and
426
+ the Salesforce behaviour.
427
+
428
+ ## Per-type notes
429
+
430
+ The few things to know per type. Each type page has the full rules and error codes.
431
+
432
+ ### Data streams
433
+
434
+ - Create the stream first: it creates its landing DLO. Then create the DMO, then the mapping.
435
+ - Salesforce gives a new Ingestion API stream a name of its own. Deploy shows that name in its
436
+ result (`targetApiName` in JSON output); retrieve the stream under that name and keep that
437
+ file.
438
+ - Ingestion API streams and Salesforce CRM streams are tested; other connectors are sent as
439
+ written.
440
+ - Delete keeps the landing DLO unless you add `--delete-dlo`, and is refused while something
441
+ else still uses the stream or its DLO.
442
+ - Reference: [Data streams](docs/types/data-stream.md).
443
+
444
+ ### DLOs
445
+
446
+ - Category and, for Engagement DLOs, the event time field cannot change after create.
447
+ - An existing DLO takes label changes and new fields; other field changes are refused.
448
+ - For a stream's landing DLO, add fields through the stream.
449
+ - Reference: [DLOs](docs/types/dlo.md).
450
+
451
+ ### DMOs
452
+
453
+ - Custom DMOs are fully managed. Standard and generated DMOs take custom fields, labels and the
454
+ description; the plugin never creates a standard DMO.
455
+ - Fields missing from the file are removed only with `--allow-field-removal`. A mapped field is
456
+ removed only when the same deploy also updates every mapping that uses it.
457
+ - `delete --field` removes single fields, also standard and generated ones.
458
+ - Reference: [DMOs](docs/types/dmo.md).
459
+
460
+ ### Mappings
461
+
462
+ - The file is the list of field pairs the mapping should have; deploy adds and removes pairs to
463
+ match it. Pairs Salesforce generates stay.
464
+ - The first mapping onto a standard DMO that is not enabled yet enables it permanently; preview
465
+ warns about it.
466
+ - The last mapping of a custom DMO cannot be deleted on its own: delete the DMO instead.
467
+ - Reference: [Mappings](docs/types/mapping.md).
468
+
469
+ ### Relationships
470
+
471
+ - Retrieve takes the source DMO: `relationship:<Dmo__dlm>` saves all of its relationships.
472
+ - Label, cardinality and source field can change in place. Deploy never deletes relationships.
473
+ - Both objects must be mapped before Salesforce accepts a relationship.
474
+ - Reference: [Relationships](docs/types/relationship.md).
475
+
476
+ ### Data transforms
477
+
478
+ - The file holds the transform as Salesforce returns it, plus its schedule. A file without a
479
+ schedule leaves the org's schedule alone.
480
+ - A deployed schedule makes the transform run in the target org. Deploy never starts a run.
481
+ - Formula, SQL filter and DCSQL SQL are written plain: the plugin asks Salesforce for plain
482
+ text. Salesforce never decodes HTML entities it is sent, so deploy refuses an expression
483
+ holding one outside texts (`&gt;`, `&#39;`): write the character itself.
484
+ - Deploy refuses a file whose text is an HTML-escaped copy of the org's text
485
+ (`HTML_ESCAPED_FILE`, all types): Salesforce would store the entities literally.
486
+ - A DLO is written by one transform only, whatever the data space. A transform copied into
487
+ another data space keeps its output DLO names, so it needs another output object, or the
488
+ source transform deleted first. Salesforce's validation issues are shown with
489
+ `TRANSFORM_VALIDATION_FAILED`.
490
+ - A SQL filter refuses `<>`; write `!=`.
491
+ - Reference: [Data transforms](docs/types/data-transform.md).
492
+
493
+ ### Calculated insights
494
+
495
+ - The SQL is kept in its own `.sql` file. `--draft` deploys a draft; `sf data360 publish`
496
+ activates it.
497
+ - Some SQL is accepted by Salesforce but fails a few minutes after publish without a message,
498
+ for example a table alias or a `--` comment in a classic insight. Deploy warns about each such
499
+ spot with file, line and column, and still deploys
500
+ ([`CI_SQL_FAILS_SILENTLY`](docs/errors/calculated-insight/CI_SQL_FAILS_SILENTLY.md)).
501
+ - Reference: [Calculated insights](docs/types/calculated-insight.md).
502
+
503
+ ### Segments
504
+
505
+ - SQL (DBT) segments keep each model in its own `.sql` file; segments built in the canvas keep
506
+ their criteria in the JSON file.
507
+ - Create and update need `--allow-processing`. A deployed schedule makes the segment publish in
508
+ the target org.
509
+ - The DMO the segment is built on must exist in the target org.
510
+ - `sf data360 publish -m segment:<Name>` publishes and waits for the result (`--async` starts
511
+ it and returns at once); `sf data360 segment members export -m segment:<Name>` writes the members as CSV or JSON.
512
+ - Reference: [Segments](docs/types/segment.md).
513
+
514
+ ### Data graphs
515
+
516
+ - Salesforce refuses removing fields or related objects and changing the root. The plugin
517
+ refuses join changes, which Salesforce would accept but not apply.
518
+ - A file with another name creates another graph; graphs are not renamed.
519
+ - Graphs deploy last and are deleted first.
520
+ - Reference: [Data graphs](docs/types/data-graph.md).
521
+
522
+ ### Identity resolution
523
+
524
+ - Create and update wait until the ruleset is published, which can take minutes. `--async`
525
+ returns as soon as Salesforce accepts the change; run the same deploy again later to check.
526
+ - The configuration type and the secondary DMO cannot change.
527
+ - Reference: [Identity resolution](docs/types/identity-resolution.md).
528
+
529
+ ## Safety and limits
530
+
531
+ - Run `--preview` before every deploy and delete.
532
+ - Use a sandbox or test org first. Deploys of streams, segments, graphs and identity resolution
533
+ start processing; deletes cannot be undone.
534
+ - Retrieve, delete and field delete write files only below `data360/` and refuse symbolic links
535
+ and paths outside it; `segment members export` writes its CSV or JSON to `--output-file`
536
+ (by default under `data/<data space>/`). A differing existing file is replaced only with
537
+ `--overwrite` (`-x`) on retrieve.
538
+ - No retry and no rollback of writes: after an `unknown` result, check the org first.
539
+ - Not every Salesforce behaviour is tested for every type, data space or org; the type pages
540
+ name what is untested.
541
+
542
+ ## Use it from another plugin
543
+
544
+ Other plugins can import `sf-plugin-data/api` and call it with a `Connection` from
545
+ `@salesforce/core` (`(await Org.create({ aliasOrUsername })).getConnection()`). The functions read
546
+ with API 68, print nothing and never exit; a refusal is thrown as an error with a `code` that has
547
+ a page under [docs/errors](docs/errors/README.md).
548
+
549
+ - `listSegments(connection, { dataSpace })`: every segment of one data space with `apiName`,
550
+ `marketSegmentId` (the record ID, `1sg…`), `dataSpace`, `segmentOnApiName`, `segmentStatus` and
551
+ `publishStatus`. An incomplete list fails with `SEGMENT_ACQUISITION_FAILED`.
552
+ - `resolveSegment(connection, { dataSpace, apiName })` or `{ dataSpace, marketSegmentId }`: one
553
+ segment, matched exactly. A segment of another data space fails with `SEGMENT_OTHER_DATASPACE`,
554
+ no segment at all with `SEGMENT_NOT_FOUND`.
555
+ - `crossSpaceContext(connection, { from, to, names? })`: what the rename rules of
556
+ [salesforce-data360-rules](https://www.npmjs.com/package/salesforce-data360-rules) need to turn
557
+ names of one data space into those of another (`placeDmo` for DMO names, `translateSegmentName`, …): the org's
558
+ data spaces with their prefixes and, when a name in `names` is an identity resolution output
559
+ (or `names` is left out), its rulesets. A data space the org lacks fails with
560
+ `UNKNOWN_DATASPACE`.
561
+
562
+ ## Local development
563
+
564
+ ```sh
565
+ npm ci
566
+ npm run build
118
567
  npm run lint
119
568
  npm test
120
- npm run smoke
121
- npm run smoke:package
122
569
  node bin/run.js data360 --help
123
- node bin/run.js data360 retrieve --help
124
- node bin/run.js data360 deploy --help
125
- npm pack --dry-run --json
126
570
  ```
127
571
 
128
- The `bin/run.js` executable is a development/help runner, not a replacement `sf`
129
- binary. The package's oclif metadata exposes `data360` and the `datacloud`, `d360`,
130
- `dc` alias topics to Salesforce CLI. Each supports bare topic help and command help.
131
- Do not install into a shared CLI profile for acceptance: other installed plugins
132
- may own the same topic. Packaged CLI installation acceptance will use a dedicated
133
- profile and exact unsigned-package allowlist in a later slice.
572
+ `bin/run.js` runs the commands from the checkout without installing them into Salesforce CLI.
573
+ The tests run offline and never contact an org. `npm run smoke` runs the quick command and
574
+ documentation checks; `npm run smoke:package` packs the plugin and checks the package in an
575
+ isolated installation.
134
576
 
135
- ### Read-only deploy preview
577
+ To try an installed copy, use a separate Salesforce CLI profile rather than your everyday one:
578
+ other plugins installed there may claim the same `data360` command names.
136
579
 
137
- ```sh
138
- sf data360 deploy --preview -o target -d ./project/data360/default/dmo --json
139
- sf data360 deploy --preview -o target -d ./authored.json -d ./more-authored.json
140
- sf data360 deploy --preview -o target -m dmo:Example__dlm -m dmo:Another__dlm --json
141
- ```
580
+ ## More documentation
581
+
582
+ - [Type reference pages](docs/types/): one page per type, plus [Delete](docs/types/delete.md).
583
+ - [Error codes](docs/errors/README.md).
584
+ - [Artifact format](docs/artifact-format.md): the file layout.
585
+ - [Git workflow](docs/git-workflow.md): `--changed-since` and review flow.
586
+ - [Capabilities](docs/capabilities.md): the status of each type.
587
+ - [Data Cloud DevOps on sfmc.guide](https://sfmc.guide/next/data-cloud-devops/) and
588
+ [Data spaces on sfmc.guide](https://sfmc.guide/next/data-spaces/).
142
589
 
143
- Exactly one repeatable/non-greedy mode is required: `-d/--source-dir` selects explicit
144
- files or directories; `-m/--metadata` selects exact project members from cwd.
145
- No bare type, omitted selection or implicit deploy-all is allowed. All sources
146
- resolve and validate before target inspection. Core `-o/--target-org` supports the
147
- configured default org and explicit override; `--api-version` defaults to 65.0 and
148
- `--data-space` to default, with capability checks delegated to preflight.
149
-
150
- The normal core JSON wrapper contains `sf-data360-deploy` contract version 1.0.0,
151
- status/metadata/diagnostics/provenance/result and one advisory `preview` item per
152
- input. `create` means complete-inventory absence, not an executed create;
153
- `update` means an admitted object/existing non-primary field label delta, not an executed update;
154
- `unchanged` means qualified no-op. `blocked-changes` and `blocked` make aggregate
155
- status blocked/exit 1; unexpected failures make status failed/exit 1. Mixed results
156
- remain visible. Preview writes no local artifact/report and performs no mutations.
157
- Without `--preview`, the same explicit selection performs guarded creation or bounded label updates. The whole
158
- selection is preflighted before any executor call; a known blocker or preflight failure
159
- prevents all writes. Each executor independently repeats fresh preflight; unchanged
160
- items do not write. Execution is sequential and stops on the first blocked, failed or
161
- unknown-mutation item. This is not atomic and provides no concurrency guarantee.
162
- Execution items use `operation: execute`, `outcome: created|updated|unchanged|blocked|failed|not-attempted`,
163
- `mutation: confirmed-created|confirmed-updated|not-attempted|unknown`, optional preflight and diagnostics.
164
- Prior completed receipts remain visible; remaining items are explicitly not-attempted.
165
- Only all-created/updated/unchanged results yield aggregate success/exit 0; blocked/failed
166
- execution exits 1 even after prior mutations. Unknown mutation means creation or update may have
167
- occurred: inspect target before another attempt. No retry or rollback. Additions, descriptions,
168
- primary-key labels and other unproven changes (including mixed edits) block before writes.
169
- Parser/auth flag errors retain core formatting. No public plan or saved-plan infrastructure.
170
-
171
- ## Scope and safety
172
-
173
- `projectCommonDmoConnectMetadata` now composes the shared offline field join and
174
- object semantics in one common implementation used by actual retrieval. Recognized Other generated defaults retain a successful projection across
175
- varied authored counts/types; unproven generated recipes, taxonomy, storage or
176
- execution semantics remain explicit blockers. Explicit date references resolve
177
- exactly to authored DateTime fields; missing Engagement event designation is a
178
- specific blocker, never inferred. Complete nonempty relationships are retained
179
- but unsupported. Incomplete status, blockers or absent candidates prevent publication;
180
- no new live replay acceptance is claimed.
181
-
182
- Seven planned families are tracked in [capabilities](docs/capabilities.md).
183
- An internal read-only Salesforce-core transport now accepts an explicit API
184
- version and only same-origin `/services/data/v<version>/ssot/` requests. It rejects
185
- redirects and emits payload-free structured errors. Explicit DMO retrieval is now wired to the CLI;
186
- no resource-family support is implied. Internal DMO list pagination now uses the
187
- official offset contract, rejects malformed/overlapping pages and unexpected next
188
- links, and fails closed at the documented offset ceiling rather than returning a
189
- partial inventory. It does not provide a consistent snapshot during concurrent
190
- org changes. An internal portable DMO validator/serializer now covers a narrow,
191
- offline custom schema with all 12 nested input field types, dynamic lookup and
192
- field category, strict unknown-field rejection and ordered-field preservation.
193
- Raw projection produces an explicitly incomplete diagnostic candidate, retaining
194
- qualifiers, semantic metadata and generated fields in separate configuration.
195
- A separate internal relationship helper now acquires incoming/outgoing raw metadata
196
- in an explicit data space, requiring total-size consistency and bounded offset
197
- completion. API 65.0 live inspection confirmed HTTP 204 for an empty initial list,
198
- optional count metadata, and sourceObject/targetObject endpoint records. Unknown envelopes block; raw entry fields are preserved. It is not yet
199
- bound to field projection: candidates still carry RELATIONSHIPS_NOT_ACQUIRED and
200
- must never be exported alone from that incomplete helper. Qualified
201
- relationship replay and broader generated-field replay remain unimplemented;
202
- qualified authored filesystem publication is available below. A second offline helper joins exact Connect/Metadata identities for
203
- one proven relationship-free Other shape, binds qualifiers by explicit metadata
204
- reference, and uses authoritative primary/dynamic flags. It retains full readback
205
- expectations and now verifies the autonomous create identity for that exact local
206
- profile: remove one terminal case-sensitive `__dlm` from a validated non-namespaced
207
- custom name, preserving case and internal single underscores. It returns an offline
208
- `projected` result with no identity blocker, not a deployable artifact or request.
209
- A pure internal Other create-request mapper now rechecks the complete joined
210
- projection and explicitly binds only evidenced source/target `default` space.
211
- It preserves authored `__c` field names and excludes generated fields, org IDs
212
- and read-only metadata. It performs no transport. An internal read-only
213
- `retrieveDmo` service now acquires detail, Metadata CustomObject and complete
214
- relationships using an existing Salesforce core connection, explicitly at API
215
- 65.0/default only. It validates both projection and mapper, returning the full
216
- projection/expectations rather than a detached candidate. Missing/ambiguous
217
- Metadata or incomplete relationships fail without partial results. The retrieve
218
- command delegates to this service and passes only its candidate to the writer. The approved Git artifact contains only
219
- `schemaVersion`, `kind`, `identity` and `spec`; runtime source expectations remain
220
- internal. A separate `buildOtherDmoCreateRequestFromDocument` mapper accepts this
221
- standalone authored JSON with explicit default target binding, validates it and
222
- maps only Other with one Text primary and one DateTime nonprimary field, both
223
- without dynamic lookup. It preserves exact names, labels, field order and optional
224
- object description; unsupported semantics and runtime keys reject. This offline
225
- mapping is not deploy acceptance: deployment must separately validate the authored
226
- file and later verify target readback. Profile and Engagement remain
227
- pending; no writable Metadata projection is provided. Public creation uses the guarded common executor, not this narrow mapper alone. See the exact subset and evidence in the artifact document.
228
- The separate common `buildDmoCreateRequestFromDocument` offline mapper accepts
229
- all 12 documented field types, Profile/Other/Engagement, any nonempty authored
230
- field count, boolean dynamic lookup, optional field category/description and
231
- explicit exact DateTime event/record-modified references. It constructs a fresh
232
- allowlisted request from authored JSON; source and explicit target remain default.
233
- Actual retrieval now uses the common projector and mapper; unknown or incomplete
234
- semantic variants return specific blockers and no file. Profile/Engagement generated
235
- replay remains unqualified, not a separate category implementation. No general
236
- export/deployment or new live API acceptance is claimed.
237
-
238
- An internal `writeDmoDocument(candidate, projectRoot, overwrite)` validates
239
- standalone DMO/default authored JSON independently through the common mapper, serializes canonically and
240
- writes `data360/default/dmo/<api-name>.json` beneath the project root. Identical
241
- bytes are unchanged; differing regular files require overwrite. Linked ancestors,
242
- linked destinations and directory/file collisions reject. Complete flushed staging
243
- uses OS temp and atomic rename/exclusive hard-link publication; cross-volume
244
- publication fails closed, with no copy fallback. There is a residual concurrent
245
- filesystem replacement race between path validation and publication; this is not
246
- a hostile-process filesystem sandbox. The command now delegates output here unchanged.
247
- No org was contacted or changed by synthetic tests. Smoke tests retain isolated
248
- state in newly allocated OS-temp roots; they never delete recursively. Windows
249
- contributors on this workspace machine must use `F:/Temp` for TEMP, TMP (when set),
250
- TMPDIR (when set), and actual Node `os.tmpdir()`. Verification rejects mismatches.
251
- Linux CI uses its normal OS temp directory.
252
-
253
- See [artifact format status](docs/artifact-format.md),
254
- [Git workflow](docs/git-workflow.md), and [handover](docs/handover.md).
255
- Release notes belong in GitHub Releases; this npm package has no changelog file.
256
- The release workflow is prepared but requires a future approved remote, npm
257
- ownership/trusted-publisher configuration and release verification. No publication
258
- or remote creation is authorized by this bootstrap.
590
+ Release notes are in GitHub Releases.