sf-plugin-data 0.2.0 → 0.3.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/README.md CHANGED
@@ -45,6 +45,16 @@ example `sf dc retrieve`.
45
45
  and the Command Palette in VS Code, and groups your files by data space in a side panel.
46
46
  - It brings its own copy of this plugin, so no `sf plugins install` or link is needed there.
47
47
 
48
+ ## Get started
49
+
50
+ ```sh
51
+ # 1. See which data spaces the org has
52
+ sf data360 list dataspace --target-org <alias>
53
+
54
+ # 2. Retrieve the components of one of them
55
+ sf data360 retrieve --dataspace <name> --target-org <alias>
56
+ ```
57
+
48
58
  ## Quick start
49
59
 
50
60
  ```sh
@@ -75,6 +85,7 @@ The commands:
75
85
  | `sf data360 delete` | Deletes components by name, or the ones whose files a Git range deleted. |
76
86
  | `sf data360 publish` | Publishes one segment or one calculated insight. |
77
87
  | `sf data360 segment members export` | Writes the members of a published segment to a CSV or JSON file. |
88
+ | `sf data360 list dataspace` | Lists the org's data spaces with name, label and prefix. |
78
89
 
79
90
  Every command has `--help` with all flags, and `--json` for machine-readable output.
80
91
 
@@ -150,7 +161,8 @@ are left out, and deploy keeps them. The exact layout of each file is on its typ
150
161
 
151
162
  - `-m <type>:<Name>` selects one component; repeat `-m` to select several, of any types.
152
163
  - 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.
164
+ Retrieve without `-m` selects every component of every type in the run's data space, as if
165
+ each type were named bare; `-m` narrows the run.
154
166
  - Deploy and delete always name their components, or take them from Git with
155
167
  `--changed-since`. Deploy also takes files and folders with `--source-dir` (`-d`).
156
168
 
@@ -224,8 +236,8 @@ accepted the deletion and is still finishing it. Pass `--keep-local-files` to ke
224
236
 
225
237
  - `--preview` removes nothing; it lists the files that would go.
226
238
  - 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.
239
+ - If a file cannot be removed, the org result stays as it is and the run is `partial` (exit
240
+ code 68); remove that file by hand instead of repeating the delete.
229
241
  - A `--changed-since` delete removes no file: its files are already gone in Git.
230
242
  - A field delete (`--field`) removes no file; it refreshes the DMO and mapping files.
231
243
 
@@ -235,7 +247,7 @@ The JSON fields and every case are in [Delete](docs/types/delete.md#local-files-
235
247
 
236
248
  Human output prints one line per component, such as `created dmo Customer__dlm`. The suffix
237
249
  ` (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.
250
+ The exit code is explained in [Exit codes](#exit-codes).
239
251
 
240
252
  Every problem carries a plugin error code, a short hint and a link to the code's page:
241
253
 
@@ -252,6 +264,31 @@ When Salesforce refuses a request, the message shows its HTTP status, error code
252
264
  explanation. HTTP 429 and 503 mean rate limits or availability problems: wait and try again.
253
265
  Reads are retried a few times by themselves; writes are not.
254
266
 
267
+ ### Exit codes
268
+
269
+ Every command exits with one of the Salesforce CLI exit codes:
270
+
271
+ | Code | Status | When |
272
+ | ---- | --------------------- | --------------------------------------------------------------------------------------------------- |
273
+ | 0 | `success`, `accepted` | Everything worked. `accepted`: `--async` started the work and the command did not wait. |
274
+ | 1 | `failed`, `blocked` | Something failed or was refused and nothing was written, or it is unclear whether a write happened. |
275
+ | 2 | | A flag or usage error, reported by Salesforce CLI before the command runs. |
276
+ | 68 | `partial` | Something was confirmed written (or a file retrieved) and something else failed or was blocked. |
277
+ | 69 | `processing` | Salesforce is still processing without `--async`, or a wait ran out. Only when nothing failed. |
278
+
279
+ - A failure wins over 69: when one item failed and another is still processing, the code is 1,
280
+ or 68 when something was confirmed written.
281
+ - An unclear write (`unknown`) is always 1. Check the org before you run the command again.
282
+ - `--allow-processing` is not `--async`. It allows a write that makes Salesforce process; the
283
+ command still waits, and work still processing at the end exits 69.
284
+ - With `--json`, the top-level `status` is the exit code, and `result.status` is one of
285
+ `success`, `accepted`, `processing`, `partial`, `blocked` or `failed`.
286
+ - `deploy --changed-since` with no changes in the range has nothing to do and exits 0. A
287
+ selection whose files are all skipped (verbatim files) exits 1 with `NOTHING_TO_DEPLOY`.
288
+ - Retrieve without `-m` selects every type. With an explicit `--api-version` other than `68.0`
289
+ and no `-m`, it is refused with `INVALID_SCOPE`, because several types use API 68 only;
290
+ pass `-m` with the types you want.
291
+
255
292
  ### API version
256
293
 
257
294
  Every type uses Data Cloud API 68 by default (`--api-version auto`). DLOs, DMOs, mappings and
@@ -263,7 +300,8 @@ upgrading. The other types accept `auto` or `68.0`. `--api-version latest` is no
263
300
  Every command runs in one data space, chosen with the optional `--dataspace NAME`;
264
301
  `--data-space` is a compatibility alias. Neither spelling has a CLI default of its own: leave
265
302
  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.
303
+ and an unknown data space stops it before any read or write. `sf data360 list dataspace` shows
304
+ the names the org has.
267
305
 
268
306
  - **The file names its data space.** Every file carries the top-level key `c__dataSpace`. Deploy
269
307
  and delete refuse a file of another data space than the run's, before any write. Deploy can
@@ -552,12 +590,20 @@ a page under [docs/errors](docs/errors/README.md).
552
590
  - `resolveSegment(connection, { dataSpace, apiName })` or `{ dataSpace, marketSegmentId }`: one
553
591
  segment, matched exactly. A segment of another data space fails with `SEGMENT_OTHER_DATASPACE`,
554
592
  no segment at all with `SEGMENT_NOT_FOUND`.
593
+ - `listDataSpaces(connection)`: every data space of the org with `name`, `label` (the name when
594
+ Salesforce gives none) and `prefix` (every data space but `default` has one). An incomplete
595
+ list fails with `DATASPACE_READ_FAILED`, a refused session with `AUTHENTICATION_FAILED`.
555
596
  - `crossSpaceContext(connection, { from, to, names? })`: what the rename rules of
556
597
  [salesforce-data360-rules](https://www.npmjs.com/package/salesforce-data360-rules) need to turn
557
598
  names of one data space into those of another (`placeDmo` for DMO names, `translateSegmentName`, …): the org's
558
599
  data spaces with their prefixes and, when a name in `names` is an identity resolution output
559
600
  (or `names` is left out), its rulesets. A data space the org lacks fails with
560
601
  `UNKNOWN_DATASPACE`.
602
+ - `runRetrieve(connection, { dataspace?, metadata?, outputDir?, overwrite?, apiVersion? })`: runs
603
+ `sf data360 retrieve` with those flags and returns the same envelope `--json` shows. It does
604
+ not throw for a refusal; the envelope's `status` and diagnostics say what happened, and
605
+ `exitCodeOf(envelope)` gives the exit code the command would use. The connection's API version
606
+ is restored afterwards.
561
607
 
562
608
  ## Local development
563
609
 
@@ -519,8 +519,9 @@ directories, symbolic links, junctions, files reached through a linked folder an
519
519
  hard-linked files are refused (`UNSAFE_PATH`), as is any path outside the project's
520
520
  `data360` folder. Each result item lists
521
521
  `removedLocalFiles` with an outcome per file: `removed`, `not-present`, `kept` or
522
- `failed`. A failed removal keeps the confirmed org result, and the command exits
523
- nonzero with `LOCAL_FILE_REMOVAL_FAILED`. `--keep-local-files` keeps every file
522
+ `failed`. A failed removal keeps the confirmed org result, and the run is `partial`
523
+ (exit code 68) with `LOCAL_FILE_REMOVAL_FAILED` when at least one deletion is confirmed,
524
+ otherwise (deletions still processing only) `processing` (exit code 69). `--keep-local-files` keeps every file
524
525
  (outcome `kept`). `--preview` removes nothing and lists the files as `localFiles` with
525
526
  `exists`. The outcomes unchanged, blocked, failed, unknown, rejected and
526
527
  deletion-unconfirmed remove
@@ -997,8 +997,8 @@ Field-level delete,
997
997
  (default: current directory) are overwritten with fresh reads. A mapping file with
998
998
  another name is found by its binding (source DLO, target DMO, data space) and keeps
999
999
  its name. Absent files are not created (`not-present`); no file is deleted. A failed refresh keeps outcome
1000
- `deleted`, reports the file as `failed` and `LOCAL_REFRESH_FAILED`, and exits
1001
- nonzero.
1000
+ `deleted`, reports the file as `failed` and `LOCAL_REFRESH_FAILED`, and the run is
1001
+ `partial` (exit code 68).
1002
1002
  - `--preview` writes nothing and reports one `unmap` step per pair (the pair
1003
1003
  Salesforce drops with the field), one `delete-field` step per field and
1004
1004
  `localFiles` with `exists`. Human preview line per pair:
@@ -1203,6 +1203,7 @@ After a confirmed deletion (`deleted`/`confirmed-deleted`, or
1203
1203
  `deletion-processing`/`acknowledged-processing`) delete removes the component's local
1204
1204
  file at its canonical path by name, one regular file at a time and only inside the
1205
1205
  project's `data360` folder. Results list `removedLocalFiles` (`removed`, `not-present`,
1206
- `kept`, `failed`); a failed removal keeps the org outcome and exits nonzero with
1207
- `LOCAL_FILE_REMOVAL_FAILED`. `--keep-local-files` keeps the files and `--preview` lists
1206
+ `kept`, `failed`); a failed removal keeps the org outcome and the run is `partial`
1207
+ (exit code 68) with `LOCAL_FILE_REMOVAL_FAILED` when at least one deletion is confirmed,
1208
+ otherwise (deletions still processing only) `processing` (exit code 69). `--keep-local-files` keeps the files and `--preview` lists
1208
1209
  them as `localFiles`. Details are in [artifact formats](artifact-format.md).
package/lib/api.d.ts CHANGED
@@ -3,5 +3,11 @@ export { listSegments, resolveSegment } from './services/segment-lookup.js';
3
3
  export type { LookupConnection, SegmentLookup, SegmentRow } from './services/segment-lookup.js';
4
4
  export { crossSpaceContext } from './services/cross-space-context.js';
5
5
  export { DataSpaceError } from './services/data-space-check.js';
6
+ export { listDataSpaces } from './services/list-data-spaces.js';
7
+ export type { DataSpaceListing } from './services/list-data-spaces.js';
6
8
  export { CrossSpaceError } from './services/cross-dataspace-deploy.js';
7
9
  export type { CrossSpaceContext } from 'salesforce-data360-rules';
10
+ export { exitCodeOf } from './exit-code.js';
11
+ export { runRetrieve } from './services/run-retrieve.js';
12
+ export type { RetrieveOptions } from './services/run-retrieve.js';
13
+ export type { RetrieveEnvelope } from './commands/data360/retrieve.js';
package/lib/api.js CHANGED
@@ -4,4 +4,7 @@ export { SegmentError } from './artifacts/segment-document.js';
4
4
  export { listSegments, resolveSegment } from './services/segment-lookup.js';
5
5
  export { crossSpaceContext } from './services/cross-space-context.js';
6
6
  export { DataSpaceError } from './services/data-space-check.js';
7
+ export { listDataSpaces } from './services/list-data-spaces.js';
7
8
  export { CrossSpaceError } from './services/cross-dataspace-deploy.js';
9
+ export { exitCodeOf } from './exit-code.js';
10
+ export { runRetrieve } from './services/run-retrieve.js';
@@ -53,7 +53,7 @@ type AdmittedSource = {
53
53
  export type DeleteEnvelope = {
54
54
  contract: 'sf-data360-delete';
55
55
  contractVersion: '1.1.0';
56
- status: 'success' | 'blocked' | 'failed';
56
+ status: 'success' | 'processing' | 'partial' | 'blocked' | 'failed';
57
57
  metadata: {
58
58
  operation: 'delete';
59
59
  preview: boolean;
@@ -158,7 +158,7 @@ export type DeleteEnvelope = {
158
158
  export default class Delete extends SfCommand<DeleteEnvelope> {
159
159
  static readonly aliases: string[];
160
160
  static readonly summary = "Delete exact Data360 Transforms, Segments, IR owners, streams, DLOs, DMOs, single custom DMO fields or mappings.";
161
- static readonly description = "One delete can carry any mix of families, each named exactly with -m. It runs them in reverse dependency order, one phase after the other: graphs, then identity resolution, calculated insights and Segments (a dependent before the component it needs, including a graph or CI/Segment on the unified DMO of a selected IR), then data transforms, then relationships, mappings, DMOs and DLOs, then data streams. A phase starts only after every item of the previous one settled; a blocked, failed or unconfirmed item stops the run, and an item Salesforce is still processing stops the later phases with DELETE_PHASE_NOT_SETTLED. A -m delete needs no confirmation flag: check the selection with --preview first. Before the first delete, the current definition of each selected transform, Segment, IR, CI and graph is read from the org by its name (read-only); one the org does not have reports unchanged. A transform name resolves to its target ID through the complete transform list: no match is unchanged, two or more matches (ignoring case) are refused with TRANSFORM_TARGET_NOT_RESOLVED. --changed-since <ref> selects the canonical plugin files deleted since the merge base with that reference (every family; changed files are ignored) and deletes their components in the same phase order. Identity and definition come from each file's base content; a path present again is not a delete, while a rename (also one split across commit, index and worktree), an unstaged deletion or a deleted file of no known family blocks before any org call (BLOCKED_GIT_LIFECYCLE). A --changed-since delete needs --confirm-delete (--preview runs without it; --confirm-delete is accepted only with --changed-since), takes no -m or --delete-dlo, and removes no local file. A deleted data transform is resolved by its name like a -m one; a relationship takes its source DMO from the base content; a stream file deleted together with its landing DLO file deletes the stream with its DLO. --preview runs every phase read-only and reports an item whose selected dependents an earlier phase deletes as planned-dependencies (DEPENDENCIES_PLANNED) without checking it further. A stream selected together with its landing DLO is deleted with --delete-dlo semantics and the DLO item reports removedWith the stream; the last mapping of a custom DMO selected together with that DMO is not sent on its own and reports removedWith the DMO; it reports deleted only once its own read answers 404 after the DMO deletion, otherwise deletion-unconfirmed (MAPPING_DELETION_UNCONFIRMED). data-transform:Name uses auto/API68 in the run data space (TRANSFORM_DATASPACE_MISMATCH for another). Preview is GET-only. A target of any owner or namespace is deleted with one native DELETE (Salesforce decides; a 4xx answer is reported as rejected); one whose status is PROCESSING is refused before it (TRANSFORM_DELETE_PROCESSING, in --preview too); settlement needs complete bounded inventory omission of both ID and name, otherwise the result is deletion-unconfirmed (never replay). No DLO, run or data cleanup; exhaustive external-consumer exclusion is not established. segment:Name uses auto/API68 in the run data space (the stored name, <prefix>_<Name> outside default; SEGMENT_DATASPACE_MISMATCH for another). Fresh source bindings and exact runtime/private identity are checked before one native DELETE. Only independent absence or a preserved DELETING/PROCESSING read acknowledges the result; HTTP204 alone is insufficient. No replay, Segment XML, shared-DMO deletion or physical-output cleanup guarantee. identity-resolution:ObjectApiName uses auto/API68 in the run data space (the stored name, <prefix>_<type>_<rulesetId> outside default; IDENTITY_RESOLUTION_DATASPACE_MISMATCH for another) and deletes a present owner that is not PUBLISHING or DELETING. A fresh target-local ID is resolved before one native68 DELETE; bounded exact ID/name absence confirms owner-definition deletion only. Exhaustive external-consumer exclusion and physical profile/output cleanup remain unverified. IR never cascades, runs processing, replays writes or falls back to another API. data-graph:Name uses auto/API68 in the run data space (graph names are unique in the org; DATA_GRAPH_DATASPACE_MISMATCH for a graph of another). Fresh identity, created date, definition, root and ready checks plus explicit empty native dependency/related-segment arrays are mandatory. A draft graph (never built, retrieved as-is) is deleted by name with the same scope and dependency checks. Exhaustive external-consumer exclusion remains unverified; no generated-resource cleanup, storage or credit guarantee. A Graph delete never cascades. calculated-insight:Name__cio uses --api-version auto (68.0) or 68.0 in the run data space (the GET must name it, CI_IDENTITY_CHANGED otherwise). The insight is read by name with the API 68 GET (absent is unchanged; it must answer with that name and data space), deleted with one DELETE in any status, schedule or SQL (Salesforce decides; a 4xx answer is reported as rejected), then read until it answers 404. CI never cascades; no compute, storage or credits guarantee. Exact data-stream:ApiName selects guarded IngestApi stream deletion at auto/API68 in the run data space (its DLO must belong to it). The linked DLO is preserved by default; --delete-dlo explicitly acknowledges deleting that exclusively linked DLO. Selected stream and linked DLO checks only, not unrelated-org preservation. Native routes default to API68; explicit numeric pins are preserved. Relationship deletion (relationship:SourceDmo__dlm:Name; a bare relationship:Name is refused with INVALID_SELECTION) runs first in its phase, before mappings, DMOs and DLOs. The relationships of the named source DMO are listed and the name is looked up ignoring letter case: no match is unchanged, two matches are refused (AMBIGUOUS_RELATIONSHIP_TARGET), and a match whose source object is another DMO is refused (RELATIONSHIP_TARGET_BINDING_MISMATCH). In a --changed-since delete the source DMO and binding come from the deleted file, and when its name is absent but the binding exists under another name the delete is refused with RELATIONSHIP_NAME_MISMATCH. Otherwise one DELETE is sent and its absence confirmed by listing again; a 4xx answer is reported as rejected. --preview only lists. A mapping:Name with a valid local data360/mapping/Name.mapping-meta.json file (with --changed-since, the deleted file's base content) is found in the org the way deploy finds it: by the file's source DLO and target DMO, whatever Salesforce named it (the org name is reported as targetApiName). No org mapping with that binding is unchanged; two or more are refused with AMBIGUOUS_MAPPING_TARGET before any write. Otherwise the exact name is read, and a mapping that reads absent (404) reports unchanged. Mapping deletion runs at native API 61 and up (default 68) and deletes the whole mapping with one Metadata API destructive deployment (ObjectSourceTargetMap), whatever pairs it holds, also onto a standard DMO (Salesforce refuses the last mapping onto a standard DMO copy in a data space other than default; a Failed destructive deployment is reported as rejected). Afterwards the mapping must read absent and the other mappings and the fields of the DMO must be unchanged. The last mapping of a custom DMO is refused before any write (MAPPING_LAST_MAPPING_DELETE_BLOCKED) because Salesforce does not delete it; delete the DMO instead, which removes its mapping. Qualification uses empty custom fixtures, not populated-data guarantees. --preview performs zero writes and reports the planned step. Any partial failure stops the batch; no retries or rollback. Whole-DMO deletion is sent for every DMO, a standard one (creationType Standard) and one read without a creationType included, and Salesforce decides: a 4xx answer is reported as rejected (for example, Salesforce refuses to delete a platform-generated DMO while the identity resolution or graph that owns it exists). Field-level delete: exactly one dmo:Name__dlm with one or more --field Name__c removes the named fields from that DMO. It is the one delete operation that changes mappings it was not given and writes project files. Reads first: every field must exist on the DMO. Any field but the primary key may be named, also the standard, system and generated fields of any DMO: Salesforce decides, and a refused destructive change is reported as rejected. This is the only command that removes such platform-owned fields; every mapping pair targeting a named field is collected, and a mapped field is refused only when the mapping list fails; one that no mapping lists a pair for has no pair to lose and is removed. Then one Metadata API destructive change for all fields, sent once and never retried; Salesforce drops the mapping pairs of the removed fields itself. Fresh reads right before it must still match the plan, and polled reads afterwards must show the fields absent, exactly the collected pairs gone and every other mapping, pair, DMO property and field unchanged; any other difference fails with DMO_FIELD_REMOVAL_SIDE_EFFECT. Nothing is rolled back. After success the existing data360/dmo and data360/mapping files under --output-dir (default: current directory) are overwritten with the current definitions; absent files are not created and no file is deleted. A failed file refresh keeps the confirmed org result and exits nonzero. --field --preview writes nothing and reports pairs, fields and files. --field cannot be combined with another selector, --changed-since or --delete-dlo. Local files: after a confirmed deletion (deleted, or a DLO, DMO, Segment or IR Salesforce accepted and is still deleting) the component's own local file is removed by default, one regular file at a time at its canonical path and never a folder: data360/dlo, data360/dmo, data360/relationship, data360/data-stream, data360/dataTransforms, data360/identityResolution and data360/dataGraphs files, both files of a CI (data360/calculatedInsights/Name__cio.calculatedInsight-meta.json and .calculatedInsight-meta.sql) and the Segment files (data360/segments/Name.segment.json and every Name.segment.*.sql beside it) under the current directory (with --delete-dlo also the linked DLO's file), and the mapping file of that name or the one whose binding matches. Links, hard-linked files and paths outside those folders are refused. Nothing is removed on --preview, which lists the files instead, nor for unchanged, blocked, failed, rejected or unconfirmed deletions. --keep-local-files keeps them. A failed removal keeps the confirmed org result and exits nonzero with LOCAL_FILE_REMOVAL_FAILED.";
161
+ static readonly description = "One delete can carry any mix of families, each named exactly with -m. It runs them in reverse dependency order, one phase after the other: graphs, then identity resolution, calculated insights and Segments (a dependent before the component it needs, including a graph or CI/Segment on the unified DMO of a selected IR), then data transforms, then relationships, mappings, DMOs and DLOs, then data streams. A phase starts only after every item of the previous one settled; a blocked, failed or unconfirmed item stops the run, and an item Salesforce is still processing stops the later phases with DELETE_PHASE_NOT_SETTLED (status processing, exit 69, when nothing failed). A -m delete needs no confirmation flag: check the selection with --preview first. Before the first delete, the current definition of each selected transform, Segment, IR, CI and graph is read from the org by its name (read-only); one the org does not have reports unchanged. A transform name resolves to its target ID through the complete transform list: no match is unchanged, two or more matches (ignoring case) are refused with TRANSFORM_TARGET_NOT_RESOLVED. --changed-since <ref> selects the canonical plugin files deleted since the merge base with that reference (every family; changed files are ignored) and deletes their components in the same phase order. Identity and definition come from each file's base content; a path present again is not a delete, while a rename (also one split across commit, index and worktree), an unstaged deletion or a deleted file of no known family blocks before any org call (BLOCKED_GIT_LIFECYCLE). A --changed-since delete needs --confirm-delete (--preview runs without it; --confirm-delete is accepted only with --changed-since), takes no -m or --delete-dlo, and removes no local file. A deleted data transform is resolved by its name like a -m one; a relationship takes its source DMO from the base content; a stream file deleted together with its landing DLO file deletes the stream with its DLO. --preview runs every phase read-only and reports an item whose selected dependents an earlier phase deletes as planned-dependencies (DEPENDENCIES_PLANNED) without checking it further. A stream selected together with its landing DLO is deleted with --delete-dlo semantics and the DLO item reports removedWith the stream; the last mapping of a custom DMO selected together with that DMO is not sent on its own and reports removedWith the DMO; it reports deleted only once its own read answers 404 after the DMO deletion, otherwise deletion-unconfirmed (MAPPING_DELETION_UNCONFIRMED). data-transform:Name uses auto/API68 in the run data space (TRANSFORM_DATASPACE_MISMATCH for another). Preview is GET-only. A target of any owner or namespace is deleted with one native DELETE (Salesforce decides; a 4xx answer is reported as rejected); one whose status is PROCESSING is refused before it (TRANSFORM_DELETE_PROCESSING, in --preview too); settlement needs complete bounded inventory omission of both ID and name, otherwise the result is deletion-unconfirmed (never replay). No DLO, run or data cleanup; exhaustive external-consumer exclusion is not established. segment:Name uses auto/API68 in the run data space (the stored name, <prefix>_<Name> outside default; SEGMENT_DATASPACE_MISMATCH for another). Fresh source bindings and exact runtime/private identity are checked before one native DELETE. Only independent absence or a preserved DELETING/PROCESSING read acknowledges the result; HTTP204 alone is insufficient. No replay, Segment XML, shared-DMO deletion or physical-output cleanup guarantee. identity-resolution:ObjectApiName uses auto/API68 in the run data space (the stored name, <prefix>_<type>_<rulesetId> outside default; IDENTITY_RESOLUTION_DATASPACE_MISMATCH for another) and deletes a present owner that is not PUBLISHING or DELETING. A fresh target-local ID is resolved before one native68 DELETE; bounded exact ID/name absence confirms owner-definition deletion only. Exhaustive external-consumer exclusion and physical profile/output cleanup remain unverified. IR never cascades, runs processing, replays writes or falls back to another API. data-graph:Name uses auto/API68 in the run data space (graph names are unique in the org; DATA_GRAPH_DATASPACE_MISMATCH for a graph of another). Fresh identity, created date, definition, root and ready checks plus explicit empty native dependency/related-segment arrays are mandatory. A draft graph (never built, retrieved as-is) is deleted by name with the same scope and dependency checks. Exhaustive external-consumer exclusion remains unverified; no generated-resource cleanup, storage or credit guarantee. A Graph delete never cascades. calculated-insight:Name__cio uses --api-version auto (68.0) or 68.0 in the run data space (the GET must name it, CI_IDENTITY_CHANGED otherwise). The insight is read by name with the API 68 GET (absent is unchanged; it must answer with that name and data space), deleted with one DELETE in any status, schedule or SQL (Salesforce decides; a 4xx answer is reported as rejected), then read until it answers 404. CI never cascades; no compute, storage or credits guarantee. Exact data-stream:ApiName selects guarded IngestApi stream deletion at auto/API68 in the run data space (its DLO must belong to it). The linked DLO is preserved by default; --delete-dlo explicitly acknowledges deleting that exclusively linked DLO. Selected stream and linked DLO checks only, not unrelated-org preservation. Native routes default to API68; explicit numeric pins are preserved. Relationship deletion (relationship:SourceDmo__dlm:Name; a bare relationship:Name is refused with INVALID_SELECTION) runs first in its phase, before mappings, DMOs and DLOs. The relationships of the named source DMO are listed and the name is looked up ignoring letter case: no match is unchanged, two matches are refused (AMBIGUOUS_RELATIONSHIP_TARGET), and a match whose source object is another DMO is refused (RELATIONSHIP_TARGET_BINDING_MISMATCH). In a --changed-since delete the source DMO and binding come from the deleted file, and when its name is absent but the binding exists under another name the delete is refused with RELATIONSHIP_NAME_MISMATCH. Otherwise one DELETE is sent and its absence confirmed by listing again; a 4xx answer is reported as rejected. --preview only lists. A mapping:Name with a valid local data360/mapping/Name.mapping-meta.json file (with --changed-since, the deleted file's base content) is found in the org the way deploy finds it: by the file's source DLO and target DMO, whatever Salesforce named it (the org name is reported as targetApiName). No org mapping with that binding is unchanged; two or more are refused with AMBIGUOUS_MAPPING_TARGET before any write. Otherwise the exact name is read, and a mapping that reads absent (404) reports unchanged. Mapping deletion runs at native API 61 and up (default 68) and deletes the whole mapping with one Metadata API destructive deployment (ObjectSourceTargetMap), whatever pairs it holds, also onto a standard DMO (Salesforce refuses the last mapping onto a standard DMO copy in a data space other than default; a Failed destructive deployment is reported as rejected). Afterwards the mapping must read absent and the other mappings and the fields of the DMO must be unchanged. The last mapping of a custom DMO is refused before any write (MAPPING_LAST_MAPPING_DELETE_BLOCKED) because Salesforce does not delete it; delete the DMO instead, which removes its mapping. Qualification uses empty custom fixtures, not populated-data guarantees. --preview performs zero writes and reports the planned step. Any partial failure stops the batch; no retries or rollback. Whole-DMO deletion is sent for every DMO, a standard one (creationType Standard) and one read without a creationType included, and Salesforce decides: a 4xx answer is reported as rejected (for example, Salesforce refuses to delete a platform-generated DMO while the identity resolution or graph that owns it exists). Field-level delete: exactly one dmo:Name__dlm with one or more --field Name__c removes the named fields from that DMO. It is the one delete operation that changes mappings it was not given and writes project files. Reads first: every field must exist on the DMO. Any field but the primary key may be named, also the standard, system and generated fields of any DMO: Salesforce decides, and a refused destructive change is reported as rejected. This is the only command that removes such platform-owned fields; every mapping pair targeting a named field is collected, and a mapped field is refused only when the mapping list fails; one that no mapping lists a pair for has no pair to lose and is removed. Then one Metadata API destructive change for all fields, sent once and never retried; Salesforce drops the mapping pairs of the removed fields itself. Fresh reads right before it must still match the plan, and polled reads afterwards must show the fields absent, exactly the collected pairs gone and every other mapping, pair, DMO property and field unchanged; any other difference fails with DMO_FIELD_REMOVAL_SIDE_EFFECT. Nothing is rolled back. After success the existing data360/dmo and data360/mapping files under --output-dir (default: current directory) are overwritten with the current definitions; absent files are not created and no file is deleted. A failed file refresh keeps the confirmed org result and the run is partial (exit 68, LOCAL_REFRESH_FAILED). --field --preview writes nothing and reports pairs, fields and files. --field cannot be combined with another selector, --changed-since or --delete-dlo. Local files: after a confirmed deletion (deleted, or a DLO, DMO, Segment or IR Salesforce accepted and is still deleting) the component's own local file is removed by default, one regular file at a time at its canonical path and never a folder: data360/dlo, data360/dmo, data360/relationship, data360/data-stream, data360/dataTransforms, data360/identityResolution and data360/dataGraphs files, both files of a CI (data360/calculatedInsights/Name__cio.calculatedInsight-meta.json and .calculatedInsight-meta.sql) and the Segment files (data360/segments/Name.segment.json and every Name.segment.*.sql beside it) under the current directory (with --delete-dlo also the linked DLO's file), and the mapping file of that name or the one whose binding matches. Links, hard-linked files and paths outside those folders are refused. Nothing is removed on --preview, which lists the files instead, nor for unchanged, blocked, failed, rejected or unconfirmed deletions. --keep-local-files keeps them. A failed removal keeps the confirmed org result and the run is partial (exit 68) with LOCAL_FILE_REMOVAL_FAILED when a deletion is confirmed, otherwise processing (exit 69).";
162
162
  static readonly flags: {
163
163
  'target-org': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
164
164
  metadata: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -24,6 +24,7 @@ import { getConnectDiagnostic, retainConnectDiagnostic, } from '../../transport/
24
24
  import { explainSpaceMismatch, operationDiagnostic, replaceExplanation, } from '../../services/operation-diagnostic.js';
25
25
  import { rejectedNextAction } from '../../services/deploy-result.js';
26
26
  import { annotateDiagnostics, formatDiagnostic } from '../../errors/registry.js';
27
+ import { exitCodeOf } from '../../exit-code.js';
27
28
  import { nativeDmoFieldName, nativeDmoName, NativeDmoError, } from '../../artifacts/native-dmo-document.js';
28
29
  import { writeNativeDmoDocument } from '../../artifacts/write-native-dmo.js';
29
30
  import { writeNativeMappingDocument } from '../../artifacts/write-native-mapping.js';
@@ -392,6 +393,18 @@ function admitSourceInput(input) {
392
393
  }
393
394
  }
394
395
  }
396
+ /** Codes that mean Salesforce is still processing a deletion, not a failure. */
397
+ const notSettledCodes = new Set([
398
+ 'DELETE_PHASE_NOT_SETTLED',
399
+ 'IDENTITY_RESOLUTION_NOT_SETTLED',
400
+ ]);
401
+ /**
402
+ * Salesforce is still processing this item's deletion, or the item waits for one in flight.
403
+ * @param {DeleteItem} item Executed item.
404
+ * @returns {boolean} True when the item is still processing.
405
+ */
406
+ const stillProcessing = (item) => item.outcome === 'deletion-processing' ||
407
+ (item.diagnostics ?? []).some((diagnostic) => notSettledCodes.has(diagnostic.code));
395
408
  /**
396
409
  * Reduce a pair to the names reported in the result; the selector stays internal.
397
410
  * @param {DmoFieldPair} pair Planned or removed pair.
@@ -461,7 +474,7 @@ function fieldDeleteLines(item) {
461
474
  export default class Delete extends SfCommand {
462
475
  static aliases = ['datacloud:delete', 'd360:delete', 'dc:delete'];
463
476
  static summary = 'Delete exact Data360 Transforms, Segments, IR owners, streams, DLOs, DMOs, single custom DMO fields or mappings.';
464
- static description = "One delete can carry any mix of families, each named exactly with -m. It runs them in reverse dependency order, one phase after the other: graphs, then identity resolution, calculated insights and Segments (a dependent before the component it needs, including a graph or CI/Segment on the unified DMO of a selected IR), then data transforms, then relationships, mappings, DMOs and DLOs, then data streams. A phase starts only after every item of the previous one settled; a blocked, failed or unconfirmed item stops the run, and an item Salesforce is still processing stops the later phases with DELETE_PHASE_NOT_SETTLED. A -m delete needs no confirmation flag: check the selection with --preview first. Before the first delete, the current definition of each selected transform, Segment, IR, CI and graph is read from the org by its name (read-only); one the org does not have reports unchanged. A transform name resolves to its target ID through the complete transform list: no match is unchanged, two or more matches (ignoring case) are refused with TRANSFORM_TARGET_NOT_RESOLVED. --changed-since <ref> selects the canonical plugin files deleted since the merge base with that reference (every family; changed files are ignored) and deletes their components in the same phase order. Identity and definition come from each file's base content; a path present again is not a delete, while a rename (also one split across commit, index and worktree), an unstaged deletion or a deleted file of no known family blocks before any org call (BLOCKED_GIT_LIFECYCLE). A --changed-since delete needs --confirm-delete (--preview runs without it; --confirm-delete is accepted only with --changed-since), takes no -m or --delete-dlo, and removes no local file. A deleted data transform is resolved by its name like a -m one; a relationship takes its source DMO from the base content; a stream file deleted together with its landing DLO file deletes the stream with its DLO. --preview runs every phase read-only and reports an item whose selected dependents an earlier phase deletes as planned-dependencies (DEPENDENCIES_PLANNED) without checking it further. A stream selected together with its landing DLO is deleted with --delete-dlo semantics and the DLO item reports removedWith the stream; the last mapping of a custom DMO selected together with that DMO is not sent on its own and reports removedWith the DMO; it reports deleted only once its own read answers 404 after the DMO deletion, otherwise deletion-unconfirmed (MAPPING_DELETION_UNCONFIRMED). data-transform:Name uses auto/API68 in the run data space (TRANSFORM_DATASPACE_MISMATCH for another). Preview is GET-only. A target of any owner or namespace is deleted with one native DELETE (Salesforce decides; a 4xx answer is reported as rejected); one whose status is PROCESSING is refused before it (TRANSFORM_DELETE_PROCESSING, in --preview too); settlement needs complete bounded inventory omission of both ID and name, otherwise the result is deletion-unconfirmed (never replay). No DLO, run or data cleanup; exhaustive external-consumer exclusion is not established. segment:Name uses auto/API68 in the run data space (the stored name, <prefix>_<Name> outside default; SEGMENT_DATASPACE_MISMATCH for another). Fresh source bindings and exact runtime/private identity are checked before one native DELETE. Only independent absence or a preserved DELETING/PROCESSING read acknowledges the result; HTTP204 alone is insufficient. No replay, Segment XML, shared-DMO deletion or physical-output cleanup guarantee. identity-resolution:ObjectApiName uses auto/API68 in the run data space (the stored name, <prefix>_<type>_<rulesetId> outside default; IDENTITY_RESOLUTION_DATASPACE_MISMATCH for another) and deletes a present owner that is not PUBLISHING or DELETING. A fresh target-local ID is resolved before one native68 DELETE; bounded exact ID/name absence confirms owner-definition deletion only. Exhaustive external-consumer exclusion and physical profile/output cleanup remain unverified. IR never cascades, runs processing, replays writes or falls back to another API. data-graph:Name uses auto/API68 in the run data space (graph names are unique in the org; DATA_GRAPH_DATASPACE_MISMATCH for a graph of another). Fresh identity, created date, definition, root and ready checks plus explicit empty native dependency/related-segment arrays are mandatory. A draft graph (never built, retrieved as-is) is deleted by name with the same scope and dependency checks. Exhaustive external-consumer exclusion remains unverified; no generated-resource cleanup, storage or credit guarantee. A Graph delete never cascades. calculated-insight:Name__cio uses --api-version auto (68.0) or 68.0 in the run data space (the GET must name it, CI_IDENTITY_CHANGED otherwise). The insight is read by name with the API 68 GET (absent is unchanged; it must answer with that name and data space), deleted with one DELETE in any status, schedule or SQL (Salesforce decides; a 4xx answer is reported as rejected), then read until it answers 404. CI never cascades; no compute, storage or credits guarantee. Exact data-stream:ApiName selects guarded IngestApi stream deletion at auto/API68 in the run data space (its DLO must belong to it). The linked DLO is preserved by default; --delete-dlo explicitly acknowledges deleting that exclusively linked DLO. Selected stream and linked DLO checks only, not unrelated-org preservation. Native routes default to API68; explicit numeric pins are preserved. Relationship deletion (relationship:SourceDmo__dlm:Name; a bare relationship:Name is refused with INVALID_SELECTION) runs first in its phase, before mappings, DMOs and DLOs. The relationships of the named source DMO are listed and the name is looked up ignoring letter case: no match is unchanged, two matches are refused (AMBIGUOUS_RELATIONSHIP_TARGET), and a match whose source object is another DMO is refused (RELATIONSHIP_TARGET_BINDING_MISMATCH). In a --changed-since delete the source DMO and binding come from the deleted file, and when its name is absent but the binding exists under another name the delete is refused with RELATIONSHIP_NAME_MISMATCH. Otherwise one DELETE is sent and its absence confirmed by listing again; a 4xx answer is reported as rejected. --preview only lists. A mapping:Name with a valid local data360/mapping/Name.mapping-meta.json file (with --changed-since, the deleted file's base content) is found in the org the way deploy finds it: by the file's source DLO and target DMO, whatever Salesforce named it (the org name is reported as targetApiName). No org mapping with that binding is unchanged; two or more are refused with AMBIGUOUS_MAPPING_TARGET before any write. Otherwise the exact name is read, and a mapping that reads absent (404) reports unchanged. Mapping deletion runs at native API 61 and up (default 68) and deletes the whole mapping with one Metadata API destructive deployment (ObjectSourceTargetMap), whatever pairs it holds, also onto a standard DMO (Salesforce refuses the last mapping onto a standard DMO copy in a data space other than default; a Failed destructive deployment is reported as rejected). Afterwards the mapping must read absent and the other mappings and the fields of the DMO must be unchanged. The last mapping of a custom DMO is refused before any write (MAPPING_LAST_MAPPING_DELETE_BLOCKED) because Salesforce does not delete it; delete the DMO instead, which removes its mapping. Qualification uses empty custom fixtures, not populated-data guarantees. --preview performs zero writes and reports the planned step. Any partial failure stops the batch; no retries or rollback. Whole-DMO deletion is sent for every DMO, a standard one (creationType Standard) and one read without a creationType included, and Salesforce decides: a 4xx answer is reported as rejected (for example, Salesforce refuses to delete a platform-generated DMO while the identity resolution or graph that owns it exists). Field-level delete: exactly one dmo:Name__dlm with one or more --field Name__c removes the named fields from that DMO. It is the one delete operation that changes mappings it was not given and writes project files. Reads first: every field must exist on the DMO. Any field but the primary key may be named, also the standard, system and generated fields of any DMO: Salesforce decides, and a refused destructive change is reported as rejected. This is the only command that removes such platform-owned fields; every mapping pair targeting a named field is collected, and a mapped field is refused only when the mapping list fails; one that no mapping lists a pair for has no pair to lose and is removed. Then one Metadata API destructive change for all fields, sent once and never retried; Salesforce drops the mapping pairs of the removed fields itself. Fresh reads right before it must still match the plan, and polled reads afterwards must show the fields absent, exactly the collected pairs gone and every other mapping, pair, DMO property and field unchanged; any other difference fails with DMO_FIELD_REMOVAL_SIDE_EFFECT. Nothing is rolled back. After success the existing data360/dmo and data360/mapping files under --output-dir (default: current directory) are overwritten with the current definitions; absent files are not created and no file is deleted. A failed file refresh keeps the confirmed org result and exits nonzero. --field --preview writes nothing and reports pairs, fields and files. --field cannot be combined with another selector, --changed-since or --delete-dlo. Local files: after a confirmed deletion (deleted, or a DLO, DMO, Segment or IR Salesforce accepted and is still deleting) the component's own local file is removed by default, one regular file at a time at its canonical path and never a folder: data360/dlo, data360/dmo, data360/relationship, data360/data-stream, data360/dataTransforms, data360/identityResolution and data360/dataGraphs files, both files of a CI (data360/calculatedInsights/Name__cio.calculatedInsight-meta.json and .calculatedInsight-meta.sql) and the Segment files (data360/segments/Name.segment.json and every Name.segment.*.sql beside it) under the current directory (with --delete-dlo also the linked DLO's file), and the mapping file of that name or the one whose binding matches. Links, hard-linked files and paths outside those folders are refused. Nothing is removed on --preview, which lists the files instead, nor for unchanged, blocked, failed, rejected or unconfirmed deletions. --keep-local-files keeps them. A failed removal keeps the confirmed org result and exits nonzero with LOCAL_FILE_REMOVAL_FAILED.";
477
+ static description = "One delete can carry any mix of families, each named exactly with -m. It runs them in reverse dependency order, one phase after the other: graphs, then identity resolution, calculated insights and Segments (a dependent before the component it needs, including a graph or CI/Segment on the unified DMO of a selected IR), then data transforms, then relationships, mappings, DMOs and DLOs, then data streams. A phase starts only after every item of the previous one settled; a blocked, failed or unconfirmed item stops the run, and an item Salesforce is still processing stops the later phases with DELETE_PHASE_NOT_SETTLED (status processing, exit 69, when nothing failed). A -m delete needs no confirmation flag: check the selection with --preview first. Before the first delete, the current definition of each selected transform, Segment, IR, CI and graph is read from the org by its name (read-only); one the org does not have reports unchanged. A transform name resolves to its target ID through the complete transform list: no match is unchanged, two or more matches (ignoring case) are refused with TRANSFORM_TARGET_NOT_RESOLVED. --changed-since <ref> selects the canonical plugin files deleted since the merge base with that reference (every family; changed files are ignored) and deletes their components in the same phase order. Identity and definition come from each file's base content; a path present again is not a delete, while a rename (also one split across commit, index and worktree), an unstaged deletion or a deleted file of no known family blocks before any org call (BLOCKED_GIT_LIFECYCLE). A --changed-since delete needs --confirm-delete (--preview runs without it; --confirm-delete is accepted only with --changed-since), takes no -m or --delete-dlo, and removes no local file. A deleted data transform is resolved by its name like a -m one; a relationship takes its source DMO from the base content; a stream file deleted together with its landing DLO file deletes the stream with its DLO. --preview runs every phase read-only and reports an item whose selected dependents an earlier phase deletes as planned-dependencies (DEPENDENCIES_PLANNED) without checking it further. A stream selected together with its landing DLO is deleted with --delete-dlo semantics and the DLO item reports removedWith the stream; the last mapping of a custom DMO selected together with that DMO is not sent on its own and reports removedWith the DMO; it reports deleted only once its own read answers 404 after the DMO deletion, otherwise deletion-unconfirmed (MAPPING_DELETION_UNCONFIRMED). data-transform:Name uses auto/API68 in the run data space (TRANSFORM_DATASPACE_MISMATCH for another). Preview is GET-only. A target of any owner or namespace is deleted with one native DELETE (Salesforce decides; a 4xx answer is reported as rejected); one whose status is PROCESSING is refused before it (TRANSFORM_DELETE_PROCESSING, in --preview too); settlement needs complete bounded inventory omission of both ID and name, otherwise the result is deletion-unconfirmed (never replay). No DLO, run or data cleanup; exhaustive external-consumer exclusion is not established. segment:Name uses auto/API68 in the run data space (the stored name, <prefix>_<Name> outside default; SEGMENT_DATASPACE_MISMATCH for another). Fresh source bindings and exact runtime/private identity are checked before one native DELETE. Only independent absence or a preserved DELETING/PROCESSING read acknowledges the result; HTTP204 alone is insufficient. No replay, Segment XML, shared-DMO deletion or physical-output cleanup guarantee. identity-resolution:ObjectApiName uses auto/API68 in the run data space (the stored name, <prefix>_<type>_<rulesetId> outside default; IDENTITY_RESOLUTION_DATASPACE_MISMATCH for another) and deletes a present owner that is not PUBLISHING or DELETING. A fresh target-local ID is resolved before one native68 DELETE; bounded exact ID/name absence confirms owner-definition deletion only. Exhaustive external-consumer exclusion and physical profile/output cleanup remain unverified. IR never cascades, runs processing, replays writes or falls back to another API. data-graph:Name uses auto/API68 in the run data space (graph names are unique in the org; DATA_GRAPH_DATASPACE_MISMATCH for a graph of another). Fresh identity, created date, definition, root and ready checks plus explicit empty native dependency/related-segment arrays are mandatory. A draft graph (never built, retrieved as-is) is deleted by name with the same scope and dependency checks. Exhaustive external-consumer exclusion remains unverified; no generated-resource cleanup, storage or credit guarantee. A Graph delete never cascades. calculated-insight:Name__cio uses --api-version auto (68.0) or 68.0 in the run data space (the GET must name it, CI_IDENTITY_CHANGED otherwise). The insight is read by name with the API 68 GET (absent is unchanged; it must answer with that name and data space), deleted with one DELETE in any status, schedule or SQL (Salesforce decides; a 4xx answer is reported as rejected), then read until it answers 404. CI never cascades; no compute, storage or credits guarantee. Exact data-stream:ApiName selects guarded IngestApi stream deletion at auto/API68 in the run data space (its DLO must belong to it). The linked DLO is preserved by default; --delete-dlo explicitly acknowledges deleting that exclusively linked DLO. Selected stream and linked DLO checks only, not unrelated-org preservation. Native routes default to API68; explicit numeric pins are preserved. Relationship deletion (relationship:SourceDmo__dlm:Name; a bare relationship:Name is refused with INVALID_SELECTION) runs first in its phase, before mappings, DMOs and DLOs. The relationships of the named source DMO are listed and the name is looked up ignoring letter case: no match is unchanged, two matches are refused (AMBIGUOUS_RELATIONSHIP_TARGET), and a match whose source object is another DMO is refused (RELATIONSHIP_TARGET_BINDING_MISMATCH). In a --changed-since delete the source DMO and binding come from the deleted file, and when its name is absent but the binding exists under another name the delete is refused with RELATIONSHIP_NAME_MISMATCH. Otherwise one DELETE is sent and its absence confirmed by listing again; a 4xx answer is reported as rejected. --preview only lists. A mapping:Name with a valid local data360/mapping/Name.mapping-meta.json file (with --changed-since, the deleted file's base content) is found in the org the way deploy finds it: by the file's source DLO and target DMO, whatever Salesforce named it (the org name is reported as targetApiName). No org mapping with that binding is unchanged; two or more are refused with AMBIGUOUS_MAPPING_TARGET before any write. Otherwise the exact name is read, and a mapping that reads absent (404) reports unchanged. Mapping deletion runs at native API 61 and up (default 68) and deletes the whole mapping with one Metadata API destructive deployment (ObjectSourceTargetMap), whatever pairs it holds, also onto a standard DMO (Salesforce refuses the last mapping onto a standard DMO copy in a data space other than default; a Failed destructive deployment is reported as rejected). Afterwards the mapping must read absent and the other mappings and the fields of the DMO must be unchanged. The last mapping of a custom DMO is refused before any write (MAPPING_LAST_MAPPING_DELETE_BLOCKED) because Salesforce does not delete it; delete the DMO instead, which removes its mapping. Qualification uses empty custom fixtures, not populated-data guarantees. --preview performs zero writes and reports the planned step. Any partial failure stops the batch; no retries or rollback. Whole-DMO deletion is sent for every DMO, a standard one (creationType Standard) and one read without a creationType included, and Salesforce decides: a 4xx answer is reported as rejected (for example, Salesforce refuses to delete a platform-generated DMO while the identity resolution or graph that owns it exists). Field-level delete: exactly one dmo:Name__dlm with one or more --field Name__c removes the named fields from that DMO. It is the one delete operation that changes mappings it was not given and writes project files. Reads first: every field must exist on the DMO. Any field but the primary key may be named, also the standard, system and generated fields of any DMO: Salesforce decides, and a refused destructive change is reported as rejected. This is the only command that removes such platform-owned fields; every mapping pair targeting a named field is collected, and a mapped field is refused only when the mapping list fails; one that no mapping lists a pair for has no pair to lose and is removed. Then one Metadata API destructive change for all fields, sent once and never retried; Salesforce drops the mapping pairs of the removed fields itself. Fresh reads right before it must still match the plan, and polled reads afterwards must show the fields absent, exactly the collected pairs gone and every other mapping, pair, DMO property and field unchanged; any other difference fails with DMO_FIELD_REMOVAL_SIDE_EFFECT. Nothing is rolled back. After success the existing data360/dmo and data360/mapping files under --output-dir (default: current directory) are overwritten with the current definitions; absent files are not created and no file is deleted. A failed file refresh keeps the confirmed org result and the run is partial (exit 68, LOCAL_REFRESH_FAILED). --field --preview writes nothing and reports pairs, fields and files. --field cannot be combined with another selector, --changed-since or --delete-dlo. Local files: after a confirmed deletion (deleted, or a DLO, DMO, Segment or IR Salesforce accepted and is still deleting) the component's own local file is removed by default, one regular file at a time at its canonical path and never a folder: data360/dlo, data360/dmo, data360/relationship, data360/data-stream, data360/dataTransforms, data360/identityResolution and data360/dataGraphs files, both files of a CI (data360/calculatedInsights/Name__cio.calculatedInsight-meta.json and .calculatedInsight-meta.sql) and the Segment files (data360/segments/Name.segment.json and every Name.segment.*.sql beside it) under the current directory (with --delete-dlo also the linked DLO's file), and the mapping file of that name or the one whose binding matches. Links, hard-linked files and paths outside those folders are refused. Nothing is removed on --preview, which lists the files instead, nor for unchanged, blocked, failed, rejected or unconfirmed deletions. --keep-local-files keeps them. A failed removal keeps the confirmed org result and the run is partial (exit 68) with LOCAL_FILE_REMOVAL_FAILED when a deletion is confirmed, otherwise processing (exit 69).";
465
478
  static flags = {
466
479
  'target-org': Flags.string({
467
480
  char: 'o',
@@ -1029,10 +1042,47 @@ export default class Delete extends SfCommand {
1029
1042
  retryable: false,
1030
1043
  });
1031
1044
  };
1045
+ /**
1046
+ * Final status of an executed run: an unknown or unconfirmed mutation keeps the run status, a
1047
+ * success becoming failed;
1048
+ * an item confirmed deleted beside a failed or blocked one is partial, as is a confirmed
1049
+ * deletion whose local file was not removed; otherwise a deletion Salesforce is still
1050
+ * processing (an item, a phase not settled, an identity resolution in flight) is processing.
1051
+ * @returns {string} Envelope status (one of DeleteEnvelope status values).
1052
+ */
1053
+ const settledStatus = () => {
1054
+ const { status } = envelope;
1055
+ if (flags.preview)
1056
+ return status;
1057
+ const executed = envelope.result.items.filter((item) => item.operation !== 'preview');
1058
+ if (executed.some((item) => item.mutation === 'unknown' ||
1059
+ item.mutation === 'acknowledged' ||
1060
+ item.outcome === 'deletion-unconfirmed'))
1061
+ // An unknown mutation never reads as success (exit 1).
1062
+ return status === 'success' ? 'failed' : status;
1063
+ const { errors } = envelope.diagnostics;
1064
+ const written = executed.some((item) => item.mutation === 'confirmed-deleted');
1065
+ const failed = executed.some((item) => (item.outcome === 'failed' || item.outcome === 'blocked') && !stillProcessing(item)) ||
1066
+ // A stop is a failure unless only a deletion still processing or a local file caused it.
1067
+ (status !== 'success' &&
1068
+ (errors.length === 0 ||
1069
+ errors.some((error) => !notSettledCodes.has(error.code) && error.code !== 'LOCAL_FILE_REMOVAL_FAILED')));
1070
+ if (failed)
1071
+ return written ? 'partial' : status;
1072
+ // Partial needs a confirmed deletion; a file of a deletion still processing waits for it.
1073
+ if (written && errors.some((error) => error.code === 'LOCAL_FILE_REMOVAL_FAILED'))
1074
+ return 'partial';
1075
+ return executed.some((item) => stillProcessing(item)) ||
1076
+ errors.some((error) => notSettledCodes.has(error.code))
1077
+ ? 'processing'
1078
+ : status;
1079
+ };
1032
1080
  const finish = async () => {
1033
1081
  await removeConfirmedFiles();
1034
- if (envelope.status !== 'success')
1035
- process.exitCode = 1;
1082
+ envelope.status = settledStatus();
1083
+ const exitCode = exitCodeOf(envelope);
1084
+ if (exitCode !== 0)
1085
+ process.exitCode = exitCode;
1036
1086
  annotateDiagnostics(envelope);
1037
1087
  if (!this.jsonEnabled()) {
1038
1088
  this.log(`Delete${flags.preview ? ' preview' : ''}: ${envelope.status}.`);
@@ -79,7 +79,7 @@ type ExecutionItem = Omit<DeployExecutionResult, 'outcome'> & {
79
79
  export type DeployEnvelope = {
80
80
  contract: 'sf-data360-deploy';
81
81
  contractVersion: '1.1.0';
82
- status: 'success' | 'blocked' | 'failed';
82
+ status: 'success' | 'processing' | 'partial' | 'blocked' | 'failed';
83
83
  metadata: {
84
84
  operation: 'deploy';
85
85
  preview: boolean;
@@ -13,6 +13,7 @@ import { explainInput, explainSpaceMismatch, explanationOf, hintOf, operationDia
13
13
  import { SegmentError } from '../../artifacts/segment-document.js';
14
14
  import { bindSegmentChildren } from '../../services/bind-segment-dependencies.js';
15
15
  import { annotateDiagnostics, formatDiagnostic } from '../../errors/registry.js';
16
+ import { exitCodeOf } from '../../exit-code.js';
16
17
  import { getConnectDiagnostic, retainConnectDiagnostic, } from '../../transport/connect-diagnostic.js';
17
18
  import { preflightDataStream, executeDataStream, } from '../../services/command-native-data-stream.js';
18
19
  import { verifyDataStreamInputDigest } from '../../artifacts/read-deploy-input.js';
@@ -132,6 +133,11 @@ const rank = (input) => input.document.kind === 'dlo'
132
133
  : input.document.kind === 'mapping'
133
134
  ? 2
134
135
  : 3;
136
+ /** Item codes that mean Salesforce is still processing a write of this run, not a failure. */
137
+ const processingCodes = new Set([
138
+ 'IDENTITY_RESOLUTION_NOT_SETTLED',
139
+ 'TRANSFORM_SCHEDULE_NOT_SENT',
140
+ ]);
135
141
  /**
136
142
  * Add the run's data space prefix to the DMO options, if there is one.
137
143
  * @param {[] | [DmoCommandOptions]} options DMO options (field removal).
@@ -183,7 +189,7 @@ export default class Deploy extends SfCommand {
183
189
  }),
184
190
  'allow-processing': Flags.boolean({
185
191
  default: false,
186
- summary: 'Acknowledge stream create/update, Graph create/update and Segment/IR processing; IR CREATE also provisions generated outputs. Data transforms and calculated insights do not need it.',
192
+ summary: 'Acknowledge stream create/update, Graph create/update and Segment/IR processing; IR CREATE also provisions generated outputs. Data transforms and calculated insights do not need it. It is not --async: the deploy still waits, and a write Salesforce is still processing at the end is status processing, exit 69.',
187
193
  }),
188
194
  'allow-field-removal': Flags.boolean({
189
195
  default: false,
@@ -498,6 +504,41 @@ export default class Deploy extends SfCommand {
498
504
  const mappingNames = new Map();
499
505
  const processingDlos = new Set();
500
506
  const mappingChanges = new Map();
507
+ /**
508
+ * Final status of a run that reached its end: an unknown mutation keeps the run status, a
509
+ * success becoming failed; some
510
+ * item confirmed written beside a failed or blocked one (or an unwritten copy file) is partial;
511
+ * otherwise a server still processing (a DLO, segment or transform, an identity resolution
512
+ * not yet settled, a transform schedule not sent while processing) is processing.
513
+ * @param {CrudStageResult['status']} status Status of the stages.
514
+ * @param {boolean} copyNotWritten A cross-data-space copy file was not written.
515
+ * @returns {string} Envelope status (one of DeployEnvelope status values).
516
+ */
517
+ const settledStatus = (status, copyNotWritten) => {
518
+ if (flags.preview)
519
+ return status;
520
+ const executed = envelope.result.items.filter((item) => item.operation === 'execute');
521
+ const mutations = executed.map((item) => ('mutation' in item ? item.mutation : undefined));
522
+ // An unknown mutation never reads as success (exit 1).
523
+ if (mutations.includes('unknown'))
524
+ return status === 'success' ? 'failed' : status;
525
+ // The code is on the item, or on the preflight that stopped it before its write.
526
+ const stillProcessing = (item) => [
527
+ ...item.diagnostics,
528
+ ...('preflight' in item && item.preflight ? item.preflight.diagnostics : []),
529
+ ].some((diagnostic) => processingCodes.has(diagnostic.code));
530
+ const written = mutations.some((mutation) => mutation === 'confirmed-created' || mutation === 'confirmed-updated');
531
+ const failed = executed.some((item) => (item.outcome === 'failed' || item.outcome === 'blocked') && !stillProcessing(item)) ||
532
+ // A stop without a failed item is a failure unless an item still processing caused it.
533
+ (status !== 'success' && !executed.some((item) => stillProcessing(item)));
534
+ if (failed)
535
+ return written ? 'partial' : status;
536
+ if (copyNotWritten)
537
+ return 'partial';
538
+ return processingDlos.size > 0 || executed.some((item) => stillProcessing(item))
539
+ ? 'processing'
540
+ : status;
541
+ };
501
542
  const finish = (status, code, error) => {
502
543
  envelope.status = status;
503
544
  if (code) {
@@ -537,8 +578,9 @@ export default class Deploy extends SfCommand {
537
578
  ...(mappedFields ? { mappedFields } : {}),
538
579
  });
539
580
  }
540
- if (status !== 'success')
541
- process.exitCode = 1;
581
+ const exitCode = exitCodeOf(envelope);
582
+ if (exitCode !== 0)
583
+ process.exitCode = exitCode;
542
584
  annotateDiagnostics(envelope);
543
585
  if (!this.jsonEnabled()) {
544
586
  this.log(flags.preview
@@ -763,7 +805,7 @@ export default class Deploy extends SfCommand {
763
805
  families.set(input.path, input.document.kind === 'native-data-graph' ? 'data-graph' : input.document.kind);
764
806
  // Every selected file was a skipped verbatim file: nothing to deploy.
765
807
  if (resolvedInputs.length === 0 && skipped.length > 0)
766
- return finish('success');
808
+ return finish('blocked', 'NOTHING_TO_DEPLOY');
767
809
  if (resolvedInputs.length === 0 && changedSince === undefined)
768
810
  return finish('blocked', 'INVALID_SELECTION');
769
811
  const graphInputs = resolvedInputs.filter((input) => input.document.kind === 'native-data-graph');
@@ -994,6 +1036,7 @@ export default class Deploy extends SfCommand {
994
1036
  processingDlos.add(input.path);
995
1037
  envelope.result.items.push({
996
1038
  ...execution,
1039
+ ...(kind === 'dlo' && serverProcessing ? { serverProcessing: true } : {}),
997
1040
  family: kind,
998
1041
  identity,
999
1042
  operation: 'execute',
@@ -1039,6 +1082,7 @@ export default class Deploy extends SfCommand {
1039
1082
  })) {
1040
1083
  settled = true;
1041
1084
  processingDlos.delete(input.path);
1085
+ delete envelope.result.items.at(-1).serverProcessing;
1042
1086
  break;
1043
1087
  }
1044
1088
  }
@@ -1649,9 +1693,10 @@ export default class Deploy extends SfCommand {
1649
1693
  })
1650
1694
  : await (this.executeNativeDmo ?? executeDmo)(input.document, dmoClient(), effectiveScope, ...withDataSpacePrefix(fieldRemoval(dmoMappings, dmoClient), await dataSpacePrefixOption()));
1651
1695
  const { serverProcessing, ...execution } = result;
1652
- if (['dlo', 'segment'].includes(input.document.kind) && serverProcessing)
1696
+ const processing = ['dlo', 'segment'].includes(input.document.kind) && serverProcessing === true;
1697
+ if (processing)
1653
1698
  processingDlos.add(input.path);
1654
- Object.assign(item, execution);
1699
+ Object.assign(item, execution, processing ? { serverProcessing: true } : {});
1655
1700
  }
1656
1701
  catch (error) {
1657
1702
  item.diagnostics = [
@@ -2371,7 +2416,7 @@ export default class Deploy extends SfCommand {
2371
2416
  }
2372
2417
  envelope.result.crossDataSpace.copies = copies;
2373
2418
  }
2374
- return finish(outcome.status, outcome.code, outcome.error);
2419
+ return finish(settledStatus(outcome.status, (envelope.result.crossDataSpace?.copies ?? []).some((copy) => copy.outcome === 'not-written')), outcome.code, outcome.error);
2375
2420
  }
2376
2421
  catch (error) {
2377
2422
  if (error instanceof GitSelectionError) {
@@ -0,0 +1,53 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ import { plugin } from '../../../plugin.js';
3
+ import type { DataSpaceListing } from '../../../services/list-data-spaces.js';
4
+ import type { LookupConnection } from '../../../services/segment-lookup.js';
5
+ export type ListDataSpaceEnvelope = {
6
+ contract: 'sf-data360-list-dataspace';
7
+ contractVersion: '1.0.0';
8
+ status: 'success' | 'blocked' | 'failed';
9
+ metadata: {
10
+ operation: 'list-dataspace';
11
+ apiVersion: '68.0';
12
+ plugin: typeof plugin;
13
+ };
14
+ provenance: {
15
+ command: 'sf data360 list dataspace';
16
+ generatedAt: string;
17
+ };
18
+ diagnostics: {
19
+ warnings: string[];
20
+ errors: Array<{
21
+ code: string;
22
+ message: string;
23
+ retryable: false;
24
+ }>;
25
+ };
26
+ result: {
27
+ items: DataSpaceListing[];
28
+ };
29
+ };
30
+ /**
31
+ * List the data spaces of the org: the names `--dataspace` takes in every other command.
32
+ */
33
+ export default class ListDataSpace extends SfCommand<ListDataSpaceEnvelope> {
34
+ static readonly aliases: string[];
35
+ static readonly summary = "List the data spaces of the org.";
36
+ static readonly description = "Reads every Data360 data space of the org (GET /ssot/data-spaces at API 68, page by page until the list is complete) and shows its name, label and prefix. The name is what --dataspace takes in the other sf data360 commands; the prefix (every data space but default has one) is what Salesforce puts in front of some names in that data space, such as ds2_Individual__dlm. A list that cannot be read completely is DATASPACE_READ_FAILED and nothing is shown. Read-only: nothing in the org changes.";
37
+ static readonly examples: string[];
38
+ static readonly flags: {
39
+ 'target-org': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
40
+ };
41
+ protected resolveConnection: (alias?: string) => Promise<LookupConnection>;
42
+ /**
43
+ * Read the org's data spaces.
44
+ * @returns {Promise<ListDataSpaceEnvelope>} List receipt.
45
+ */
46
+ run(): Promise<ListDataSpaceEnvelope>;
47
+ /**
48
+ * Set the exit code and print the human list.
49
+ * @param {ListDataSpaceEnvelope} envelope Filled receipt.
50
+ * @returns {ListDataSpaceEnvelope} The same receipt.
51
+ */
52
+ private finish;
53
+ }