sf-plugin-data 0.1.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.
Files changed (277) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +618 -240
  3. package/docs/artifact-format.md +528 -633
  4. package/docs/capabilities.md +1160 -168
  5. package/docs/git-workflow.md +135 -12
  6. package/docs/handover.md +7826 -12
  7. package/lib/api.d.ts +13 -0
  8. package/lib/api.js +10 -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 +2347 -0
  75. package/lib/commands/data360/deploy.d.ts +235 -16
  76. package/lib/commands/data360/deploy.js +2339 -102
  77. package/lib/commands/data360/list/dataspace.d.ts +53 -0
  78. package/lib/commands/data360/list/dataspace.js +109 -0
  79. package/lib/commands/data360/publish.d.ts +93 -0
  80. package/lib/commands/data360/publish.js +298 -0
  81. package/lib/commands/data360/retrieve.d.ts +283 -14
  82. package/lib/commands/data360/retrieve.js +1945 -95
  83. package/lib/commands/data360/segment/members/export.d.ts +101 -0
  84. package/lib/commands/data360/segment/members/export.js +320 -0
  85. package/lib/errors/codes/calculated-insight.d.ts +2 -0
  86. package/lib/errors/codes/calculated-insight.js +25 -0
  87. package/lib/errors/codes/data-graph.d.ts +2 -0
  88. package/lib/errors/codes/data-graph.js +22 -0
  89. package/lib/errors/codes/data-stream.d.ts +2 -0
  90. package/lib/errors/codes/data-stream.js +70 -0
  91. package/lib/errors/codes/data-transform.d.ts +2 -0
  92. package/lib/errors/codes/data-transform.js +35 -0
  93. package/lib/errors/codes/dependency.d.ts +2 -0
  94. package/lib/errors/codes/dependency.js +11 -0
  95. package/lib/errors/codes/dlo.d.ts +2 -0
  96. package/lib/errors/codes/dlo.js +31 -0
  97. package/lib/errors/codes/dmo.d.ts +2 -0
  98. package/lib/errors/codes/dmo.js +28 -0
  99. package/lib/errors/codes/general.d.ts +2 -0
  100. package/lib/errors/codes/general.js +58 -0
  101. package/lib/errors/codes/identity-resolution.d.ts +2 -0
  102. package/lib/errors/codes/identity-resolution.js +24 -0
  103. package/lib/errors/codes/mapping.d.ts +2 -0
  104. package/lib/errors/codes/mapping.js +42 -0
  105. package/lib/errors/codes/relationship.d.ts +2 -0
  106. package/lib/errors/codes/relationship.js +21 -0
  107. package/lib/errors/codes/segment.d.ts +2 -0
  108. package/lib/errors/codes/segment.js +49 -0
  109. package/lib/errors/registry.d.ts +60 -0
  110. package/lib/errors/registry.js +123 -0
  111. package/lib/exit-code.d.ts +10 -0
  112. package/lib/exit-code.js +24 -0
  113. package/lib/plugin.d.ts +1 -0
  114. package/lib/plugin.js +3 -1
  115. package/lib/services/acquire-retrieve-selection.d.ts +43 -0
  116. package/lib/services/acquire-retrieve-selection.js +145 -0
  117. package/lib/services/bind-identity-resolution-dependencies.d.ts +53 -0
  118. package/lib/services/bind-identity-resolution-dependencies.js +238 -0
  119. package/lib/services/bind-segment-dependencies.d.ts +49 -0
  120. package/lib/services/bind-segment-dependencies.js +115 -0
  121. package/lib/services/bounded-reads.d.ts +17 -0
  122. package/lib/services/bounded-reads.js +42 -0
  123. package/lib/services/calculated-insight-sql-checks.d.ts +33 -0
  124. package/lib/services/calculated-insight-sql-checks.js +193 -0
  125. package/lib/services/command-dlo.d.ts +48 -0
  126. package/lib/services/command-dlo.js +103 -0
  127. package/lib/services/command-native-data-graph.d.ts +54 -0
  128. package/lib/services/command-native-data-graph.js +485 -0
  129. package/lib/services/command-native-data-stream.d.ts +104 -0
  130. package/lib/services/command-native-data-stream.js +257 -0
  131. package/lib/services/command-native-dmo.d.ts +124 -0
  132. package/lib/services/command-native-dmo.js +338 -0
  133. package/lib/services/command-native-mapping.d.ts +65 -0
  134. package/lib/services/command-native-mapping.js +129 -0
  135. package/lib/services/command-native-relationship.d.ts +46 -0
  136. package/lib/services/command-native-relationship.js +103 -0
  137. package/lib/services/cross-dataspace-deploy.d.ts +111 -0
  138. package/lib/services/cross-dataspace-deploy.js +493 -0
  139. package/lib/services/cross-dataspace-rename.d.ts +74 -0
  140. package/lib/services/cross-dataspace-rename.js +1314 -0
  141. package/lib/services/cross-dataspace-sql.d.ts +109 -0
  142. package/lib/services/cross-dataspace-sql.js +1301 -0
  143. package/lib/services/cross-space-context.d.ts +23 -0
  144. package/lib/services/cross-space-context.js +38 -0
  145. package/lib/services/crud-plan.d.ts +137 -0
  146. package/lib/services/crud-plan.js +408 -0
  147. package/lib/services/data-space-check.d.ts +92 -0
  148. package/lib/services/data-space-check.js +169 -0
  149. package/lib/services/data-space-prefix.d.ts +77 -0
  150. package/lib/services/data-space-prefix.js +127 -0
  151. package/lib/services/data-transform-space.d.ts +31 -0
  152. package/lib/services/data-transform-space.js +79 -0
  153. package/lib/services/delete-calculated-insight.d.ts +44 -0
  154. package/lib/services/delete-calculated-insight.js +101 -0
  155. package/lib/services/delete-data-transform.d.ts +52 -0
  156. package/lib/services/delete-data-transform.js +222 -0
  157. package/lib/services/delete-dmo-field.d.ts +211 -0
  158. package/lib/services/delete-dmo-field.js +472 -0
  159. package/lib/services/delete-identity-resolution.d.ts +43 -0
  160. package/lib/services/delete-identity-resolution.js +295 -0
  161. package/lib/services/delete-segment.d.ts +42 -0
  162. package/lib/services/delete-segment.js +248 -0
  163. package/lib/services/deploy-result.d.ts +54 -0
  164. package/lib/services/deploy-result.js +60 -0
  165. package/lib/services/escaped-copy.d.ts +23 -0
  166. package/lib/services/escaped-copy.js +88 -0
  167. package/lib/services/execute-calculated-insight-deploy.d.ts +42 -0
  168. package/lib/services/execute-calculated-insight-deploy.js +96 -0
  169. package/lib/services/execute-data-transform-deploy.d.ts +56 -0
  170. package/lib/services/execute-data-transform-deploy.js +168 -0
  171. package/lib/services/execute-native-identity-resolution-deploy.d.ts +48 -0
  172. package/lib/services/execute-native-identity-resolution-deploy.js +360 -0
  173. package/lib/services/execute-segment-deploy.d.ts +45 -0
  174. package/lib/services/execute-segment-deploy.js +393 -0
  175. package/lib/services/list-data-spaces.d.ts +17 -0
  176. package/lib/services/list-data-spaces.js +24 -0
  177. package/lib/services/local-file-removal.d.ts +36 -0
  178. package/lib/services/local-file-removal.js +103 -0
  179. package/lib/services/native-calculated-insight.d.ts +87 -0
  180. package/lib/services/native-calculated-insight.js +164 -0
  181. package/lib/services/native-crm-data-stream.d.ts +91 -0
  182. package/lib/services/native-crm-data-stream.js +272 -0
  183. package/lib/services/native-data-graph-context.d.ts +12 -0
  184. package/lib/services/native-data-graph-context.js +139 -0
  185. package/lib/services/native-data-graph-crd.d.ts +261 -0
  186. package/lib/services/native-data-graph-crd.js +866 -0
  187. package/lib/services/native-data-stream.d.ts +329 -0
  188. package/lib/services/native-data-stream.js +1830 -0
  189. package/lib/services/native-dlo.d.ts +163 -0
  190. package/lib/services/native-dlo.js +402 -0
  191. package/lib/services/native-dmo.d.ts +191 -0
  192. package/lib/services/native-dmo.js +614 -0
  193. package/lib/services/native-mapping.d.ts +255 -0
  194. package/lib/services/native-mapping.js +1226 -0
  195. package/lib/services/native-relationship.d.ts +132 -0
  196. package/lib/services/native-relationship.js +512 -0
  197. package/lib/services/operation-diagnostic.d.ts +83 -0
  198. package/lib/services/operation-diagnostic.js +272 -0
  199. package/lib/services/preflight-calculated-insight-deploy.d.ts +58 -0
  200. package/lib/services/preflight-calculated-insight-deploy.js +95 -0
  201. package/lib/services/preflight-data-transform-deploy.d.ts +33 -0
  202. package/lib/services/preflight-data-transform-deploy.js +104 -0
  203. package/lib/services/preflight-identity-resolution-deploy.d.ts +107 -0
  204. package/lib/services/preflight-identity-resolution-deploy.js +281 -0
  205. package/lib/services/preflight-segment-deploy.d.ts +31 -0
  206. package/lib/services/preflight-segment-deploy.js +109 -0
  207. package/lib/services/publish-calculated-insight.d.ts +40 -0
  208. package/lib/services/publish-calculated-insight.js +95 -0
  209. package/lib/services/publish-segment.d.ts +65 -0
  210. package/lib/services/publish-segment.js +194 -0
  211. package/lib/services/readback-pace.d.ts +16 -0
  212. package/lib/services/readback-pace.js +23 -0
  213. package/lib/services/retrieve-data-transform.d.ts +26 -0
  214. package/lib/services/retrieve-data-transform.js +65 -0
  215. package/lib/services/retrieve-identity-resolution.d.ts +40 -0
  216. package/lib/services/retrieve-identity-resolution.js +87 -0
  217. package/lib/services/retrieve-inventory.d.ts +32 -0
  218. package/lib/services/retrieve-inventory.js +151 -0
  219. package/lib/services/retrieve-segment.d.ts +120 -0
  220. package/lib/services/retrieve-segment.js +502 -0
  221. package/lib/services/run-retrieve.d.ts +24 -0
  222. package/lib/services/run-retrieve.js +51 -0
  223. package/lib/services/segment-lookup.d.ts +46 -0
  224. package/lib/services/segment-lookup.js +108 -0
  225. package/lib/services/segment-members.d.ts +144 -0
  226. package/lib/services/segment-members.js +402 -0
  227. package/lib/services/select-native-retrieve.d.ts +60 -0
  228. package/lib/services/select-native-retrieve.js +226 -0
  229. package/lib/services/settle-calculated-insight.d.ts +22 -0
  230. package/lib/services/settle-calculated-insight.js +53 -0
  231. package/lib/services/sql-tokens.d.ts +58 -0
  232. package/lib/services/sql-tokens.js +147 -0
  233. package/lib/transport/api-version.d.ts +36 -0
  234. package/lib/transport/api-version.js +89 -0
  235. package/lib/transport/bound-ssot.d.ts +27 -0
  236. package/lib/transport/bound-ssot.js +116 -0
  237. package/lib/transport/calculated-insight-rest.d.ts +28 -0
  238. package/lib/transport/calculated-insight-rest.js +62 -0
  239. package/lib/transport/connect-client.d.ts +94 -32
  240. package/lib/transport/connect-client.js +318 -178
  241. package/lib/transport/connect-diagnostic.d.ts +89 -0
  242. package/lib/transport/connect-diagnostic.js +331 -0
  243. package/lib/transport/data-graph-rest.d.ts +27 -0
  244. package/lib/transport/data-graph-rest.js +76 -0
  245. package/lib/transport/data-stream-rest.d.ts +62 -0
  246. package/lib/transport/data-stream-rest.js +348 -0
  247. package/lib/transport/data-transform-rest.d.ts +25 -0
  248. package/lib/transport/data-transform-rest.js +100 -0
  249. package/lib/transport/dlo-native-rest.d.ts +22 -0
  250. package/lib/transport/dlo-native-rest.js +89 -0
  251. package/lib/transport/dlo-rest.d.ts +23 -0
  252. package/lib/transport/dlo-rest.js +135 -0
  253. package/lib/transport/dmo-native-rest.d.ts +18 -0
  254. package/lib/transport/dmo-native-rest.js +55 -0
  255. package/lib/transport/dmo-rest.d.ts +30 -0
  256. package/lib/transport/dmo-rest.js +163 -0
  257. package/lib/transport/mapping-rest.d.ts +63 -0
  258. package/lib/transport/mapping-rest.js +341 -0
  259. package/lib/transport/project-metadata.d.ts +36 -0
  260. package/lib/transport/project-metadata.js +118 -0
  261. package/lib/transport/relationship-rest.d.ts +43 -0
  262. package/lib/transport/relationship-rest.js +201 -0
  263. package/package.json +29 -6
  264. package/lib/artifacts/dmo-document.d.ts +0 -181
  265. package/lib/artifacts/dmo-document.js +0 -848
  266. package/lib/artifacts/dmo-update-delta.d.ts +0 -28
  267. package/lib/artifacts/dmo-update-delta.js +0 -86
  268. package/lib/artifacts/write-other-dmo.d.ts +0 -17
  269. package/lib/artifacts/write-other-dmo.js +0 -140
  270. package/lib/services/execute-dmo-create.d.ts +0 -24
  271. package/lib/services/execute-dmo-create.js +0 -118
  272. package/lib/services/execute-dmo-deploy.d.ts +0 -33
  273. package/lib/services/execute-dmo-deploy.js +0 -197
  274. package/lib/services/preflight-dmo-deploy.d.ts +0 -69
  275. package/lib/services/preflight-dmo-deploy.js +0 -161
  276. package/lib/services/retrieve-other-dmo.d.ts +0 -46
  277. package/lib/services/retrieve-other-dmo.js +0 -140
@@ -0,0 +1,101 @@
1
+ import { getConnectDiagnostic, retainConnectDiagnostic } from '../transport/connect-diagnostic.js';
2
+ import { ConnectError } from '../transport/connect-client.js';
3
+ import { operationDiagnostic } from './operation-diagnostic.js';
4
+ import { rejectedNextAction } from './deploy-result.js';
5
+ import { CalculatedInsightError, calculatedInsightName, calculatedInsightSpaceMismatch, } from '../artifacts/native-calculated-insight-document.js';
6
+ import { createCalculatedInsightClient } from '../transport/calculated-insight-rest.js';
7
+ import { calculatedInsightPresence, calculatedInsightReadContext, } from './native-calculated-insight.js';
8
+ import { rejectedWrite } from './execute-calculated-insight-deploy.js';
9
+ import { settleCalculatedInsight } from './settle-calculated-insight.js';
10
+ /**
11
+ * Delete one insight by name: absent is unchanged; otherwise one DELETE, then reads until it
12
+ * answers 404. The read before the DELETE must answer with the selected name and data space
13
+ * (the name and data space check of `calculatedInsightPresence`). Any status and content is deletable;
14
+ * Salesforce decides. No cascade, replay or rollback.
15
+ * @param {object} value Identity of the insight (a document from the org or the base file).
16
+ * @param {string} value.apiName Exact name ending in __cio.
17
+ * @param {string} value.dataSpace Its data space.
18
+ * @param {CalculatedInsightConnection} connection API 68 connection.
19
+ * @param {ApiVersionSelection} selection Route selection (68.0).
20
+ * @param {string} dataSpace Selected data space.
21
+ * @param {CalculatedInsightDeleteOptions} options Confirmation, verifier, preview and test seams.
22
+ * @returns {Promise<CalculatedInsightDeleteResult>} Payload-free outcome.
23
+ */
24
+ export async function deleteCalculatedInsight(value, connection, selection, dataSpace, options) {
25
+ let attempted = false;
26
+ const result = (outcome, mutation, code, error) => retainConnectDiagnostic({
27
+ family: 'calculated-insight',
28
+ route: {
29
+ apiVersion: '68.0',
30
+ method: 'DELETE',
31
+ resource: 'calculated-insights',
32
+ },
33
+ outcome,
34
+ mutation,
35
+ requiredEffects: outcome === 'delete' ? ['destructive'] : [],
36
+ diagnostics: code
37
+ ? [
38
+ {
39
+ code,
40
+ message: (() => {
41
+ const next = mutation === 'rejected'
42
+ ? rejectedNextAction
43
+ : mutation === 'unknown'
44
+ ? 'CI deletion may have occurred; no replay or rollback was performed.'
45
+ : 'CI deletion was not attempted.';
46
+ return getConnectDiagnostic(error) ? operationDiagnostic(error, next) : next;
47
+ })(),
48
+ },
49
+ ]
50
+ : [],
51
+ }, getConnectDiagnostic(error));
52
+ try {
53
+ if (!value ||
54
+ typeof value.apiName !== 'string' ||
55
+ !calculatedInsightName.test(value.apiName) ||
56
+ selection.requested !== '68.0')
57
+ throw new CalculatedInsightError('INVALID_CI_SCOPE');
58
+ if (value.dataSpace !== dataSpace)
59
+ throw calculatedInsightSpaceMismatch(value, dataSpace);
60
+ if (typeof options.verifyInput !== 'function')
61
+ throw new Error('Required guards');
62
+ if ('preview' in options && typeof options.preview !== 'boolean')
63
+ throw new Error('Preview');
64
+ const context = options.context ?? calculatedInsightReadContext(connection, dataSpace);
65
+ context.check();
66
+ await options.verifyInput();
67
+ // Name and data space only: an insight the plugin cannot represent is deleted by name.
68
+ const acquired = await calculatedInsightPresence(context, value.apiName);
69
+ context.check();
70
+ await options.verifyInput();
71
+ if (acquired.state === 'absent')
72
+ return result('unchanged', 'not-attempted');
73
+ if (options.preview === true)
74
+ return result('delete', 'not-attempted');
75
+ if (options.confirmDelete !== true)
76
+ return result('blocked', 'not-attempted', 'DESTRUCTIVE_CONFIRMATION_REQUIRED');
77
+ const client = options.nativeClient ?? createCalculatedInsightClient(connection, '68.0', dataSpace);
78
+ context.check();
79
+ attempted = true;
80
+ try {
81
+ await client.delete(value.apiName);
82
+ }
83
+ catch (error) {
84
+ // A 404 naming the insight absent or deleted (live API 68: ENTITY_IS_DELETED) is not a
85
+ // refusal: the read below decides. Nothing is resent.
86
+ const gone = error instanceof ConnectError && error.statusCode === 404 && error.nativeCode !== undefined;
87
+ if (!gone && rejectedWrite(error))
88
+ return result('failed', 'rejected', 'REQUEST_FAILED', error);
89
+ if (!gone)
90
+ throw error;
91
+ }
92
+ await settleCalculatedInsight(context, { apiName: value.apiName }, 'absent', options);
93
+ return result('deleted', 'confirmed-deleted');
94
+ }
95
+ catch (error) {
96
+ const code = error instanceof CalculatedInsightError ? error.code : undefined;
97
+ return attempted
98
+ ? result('failed', 'unknown', 'CI_DELETION_UNCONFIRMED', error)
99
+ : result('blocked', 'not-attempted', code ?? 'CI_ADMISSION_FAILED', error);
100
+ }
101
+ }
@@ -0,0 +1,52 @@
1
+ import type { DataTransformClient } from '../transport/data-transform-rest.js';
2
+ export type DataTransformDeleteOptions = {
3
+ targetId: string;
4
+ preview?: boolean;
5
+ confirmDelete: boolean;
6
+ verifyInput: () => Promise<void>;
7
+ /** Clock and sleep for the settlement poll; tests inject fakes. */
8
+ now?: () => number;
9
+ delay?: (milliseconds: number) => Promise<void>;
10
+ };
11
+ export type DataTransformDeleteResult = {
12
+ operation: 'delete';
13
+ targetId: string;
14
+ outcome: 'preview' | 'blocked' | 'deleted' | 'deletion-unconfirmed' | 'failed';
15
+ mutation: 'not-attempted' | 'acknowledged' | 'confirmed-deleted' | 'unknown' | 'rejected';
16
+ /** Salesforce's refusal of the DELETE (HTTP 4xx), when the mutation is `rejected`. */
17
+ error?: unknown;
18
+ };
19
+ /**
20
+ * Read the complete native collection using fixed 20-row pages, at most 101 pages (2020 rows).
21
+ * Require stable totalSize, full nonfinal pages and unique identities; never follow server URLs.
22
+ * This is collection visibility evidence, not an exhaustive external-consumer exclusion check.
23
+ * @param {DataTransformClient} client Fixed API68/default adapter.
24
+ * @param {() => void} check Scope/input drift guard between every page.
25
+ * @returns {Promise<Array<{id: string, name: string}>>} Complete observed identity inventory.
26
+ */
27
+ export declare function listDataTransformInventory(client: DataTransformClient, check?: () => void): Promise<Array<{
28
+ id: string;
29
+ name: string;
30
+ }>>;
31
+ /**
32
+ * Resolve the target ID of a data transform from its API name: read the complete inventory and
33
+ * take the one entry whose name matches, ignoring case. Read-only; used by delete and deploy.
34
+ * @param {DataTransformClient} client Fixed API68/default adapter.
35
+ * @param {string} name API name of the selected transform.
36
+ * @returns {Promise<string | undefined>} The one matching target ID; undefined when none matches.
37
+ */
38
+ export declare function resolveDataTransformTargetId(client: DataTransformClient, name: string): Promise<string | undefined>;
39
+ /**
40
+ * Delete one positively matched target of any owner; preview never writes and execution sends
41
+ * once, and Salesforce decides (a 4xx answer other than 404 is reported as rejected).
42
+ * A verbatim file (a transform the plugin cannot model) is deleted by its name: the GET must
43
+ * carry the same ID and name and not change between the reads.
44
+ * A resolved DELETE is only acknowledgement; settlement is the transform's absence from one
45
+ * bounded complete inventory, polled within a bound. Any read failure or partial list leaves
46
+ * the deletion unconfirmed. Never deletes DLOs, retries mutations or treats GET404 as absence.
47
+ * @param {unknown} value Exact portable definition expectation, not ownership authority.
48
+ * @param {DataTransformClient} client Bound native API68/default transform adapter.
49
+ * @param {DataTransformDeleteOptions} options Exact target ID, confirmation and fresh local input guard.
50
+ * @returns {Promise<DataTransformDeleteResult>} Honest acknowledgement/settlement classification.
51
+ */
52
+ export declare function deleteDataTransform(value: unknown, client: DataTransformClient, options: DataTransformDeleteOptions): Promise<DataTransformDeleteResult>;
@@ -0,0 +1,222 @@
1
+ import { setTimeout as wait } from 'node:timers/promises';
2
+ import { isDeepStrictEqual } from 'node:util';
3
+ import { DataTransformError, dataTransformId, dataTransformName, dataTransformSpaceMismatch, plainTransformExpressions, sameDataTransformDocument, serializeDataTransformDocument, validateDataTransformDocument, } from '../artifacts/data-transform-document.js';
4
+ import { retrieveDataTransform } from './retrieve-data-transform.js';
5
+ import { isVerbatimDocument, verbatimDataSpace } from '../artifacts/verbatim-document.js';
6
+ import { resolveDataTransformSpace } from './data-transform-space.js';
7
+ import { ConnectError } from '../transport/connect-client.js';
8
+ import { rejectedWrite } from './execute-calculated-insight-deploy.js';
9
+ import { replaceExplanation } from './operation-diagnostic.js';
10
+ /** Salesforce keeps listing a deleted transform for about 10-25 seconds (live, 2026-11-14). */
11
+ const SETTLE_BUDGET_MS = 60_000;
12
+ const SETTLE_INTERVAL_MS = 5000;
13
+ /**
14
+ * Read the complete native collection using fixed 20-row pages, at most 101 pages (2020 rows).
15
+ * Require stable totalSize, full nonfinal pages and unique identities; never follow server URLs.
16
+ * This is collection visibility evidence, not an exhaustive external-consumer exclusion check.
17
+ * @param {DataTransformClient} client Fixed API68/default adapter.
18
+ * @param {() => void} check Scope/input drift guard between every page.
19
+ * @returns {Promise<Array<{id: string, name: string}>>} Complete observed identity inventory.
20
+ */
21
+ export async function listDataTransformInventory(client, check = () => { }) {
22
+ const inventory = [];
23
+ let total;
24
+ for (let offset = 0; offset <= 2000; offset += 20) {
25
+ check();
26
+ const raw = await client.list(offset);
27
+ check();
28
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw))
29
+ throw new DataTransformError('INCOMPLETE_TRANSFORM_INVENTORY');
30
+ const page = raw;
31
+ if (!Number.isSafeInteger(page.totalSize) ||
32
+ page.totalSize < 0 ||
33
+ page.totalSize > 2020 ||
34
+ (total !== undefined && page.totalSize !== total) ||
35
+ !Array.isArray(page.dataTransforms))
36
+ throw new DataTransformError('INCOMPLETE_TRANSFORM_INVENTORY');
37
+ total = page.totalSize;
38
+ if (page.dataTransforms.length !== Math.min(20, total - offset))
39
+ throw new DataTransformError('INCOMPLETE_TRANSFORM_INVENTORY');
40
+ for (const item of page.dataTransforms) {
41
+ if (!item || typeof item !== 'object' || Array.isArray(item))
42
+ throw new DataTransformError('INCOMPLETE_TRANSFORM_INVENTORY');
43
+ const row = item;
44
+ if (typeof row.id !== 'string' ||
45
+ !dataTransformId.test(row.id) ||
46
+ typeof row.name !== 'string' ||
47
+ !dataTransformName.test(row.name) ||
48
+ inventory.some((entry) => entry.id === row.id || entry.name === row.name))
49
+ throw new DataTransformError('INCOMPLETE_TRANSFORM_INVENTORY');
50
+ inventory.push({ id: row.id, name: row.name });
51
+ }
52
+ if (inventory.length === total)
53
+ return inventory;
54
+ }
55
+ throw new DataTransformError('INCOMPLETE_TRANSFORM_INVENTORY');
56
+ }
57
+ /**
58
+ * Resolve the target ID of a data transform from its API name: read the complete inventory and
59
+ * take the one entry whose name matches, ignoring case. Read-only; used by delete and deploy.
60
+ * @param {DataTransformClient} client Fixed API68/default adapter.
61
+ * @param {string} name API name of the selected transform.
62
+ * @returns {Promise<string | undefined>} The one matching target ID; undefined when none matches.
63
+ */
64
+ export async function resolveDataTransformTargetId(client, name) {
65
+ const inventory = await listDataTransformInventory(client);
66
+ const matches = inventory.filter((row) => row.name.toLowerCase() === name.toLowerCase());
67
+ if (matches.length > 1) {
68
+ const error = new DataTransformError('TRANSFORM_TARGET_NOT_RESOLVED');
69
+ replaceExplanation(error, `The org has ${matches.length} data transforms named ${name} (ignoring case), so the name does not resolve to one target ID. Nothing was changed.`);
70
+ throw error;
71
+ }
72
+ return matches[0]?.id;
73
+ }
74
+ /**
75
+ * A transform Salesforce is still processing is not deleted: live (API 68, 2026-11-16) its DELETE
76
+ * was answered but the transform stayed. Refused before the DELETE, so nothing is sent.
77
+ * @param {unknown} status The `status` of the transform's GET.
78
+ */
79
+ function refuseProcessing(status) {
80
+ if (typeof status !== 'string' || status.toUpperCase() !== 'PROCESSING')
81
+ return;
82
+ const error = new DataTransformError('TRANSFORM_DELETE_PROCESSING');
83
+ replaceExplanation(error, 'Data Cloud is still processing the data transform (status PROCESSING), so the DELETE was not sent and nothing was changed.');
84
+ throw error;
85
+ }
86
+ /**
87
+ * The raw GET of a transform named by a verbatim file, checked only for what a delete needs: the
88
+ * same record ID and name, in the file's data space (its `dataSpaceName`, otherwise the org's
89
+ * MktDataTransform record; TRANSFORM_DATASPACE_MISMATCH otherwise). Any owner is accepted
90
+ * (Salesforce decides; it refuses a system transform). Its definition is not projected.
91
+ * @param {string} targetId Resolved record ID.
92
+ * @param {string} name Name of the verbatim file.
93
+ * @param {string} dataSpace The verbatim file's data space.
94
+ * @param {Pick<DataTransformClient, 'get' | 'dataSpaces'>} client Transform reader.
95
+ * @returns {Promise<string>} The GET without run observations, as comparable JSON text.
96
+ */
97
+ async function readVerbatimTransform(targetId, name, dataSpace, client) {
98
+ const runtime = await client.get(targetId);
99
+ if (!runtime || typeof runtime !== 'object' || Array.isArray(runtime))
100
+ throw new DataTransformError('INVALID_TRANSFORM_RESPONSE');
101
+ const raw = runtime;
102
+ if (raw.id !== targetId || raw.name !== name)
103
+ throw new DataTransformError('TRANSFORM_DELETE_IDENTITY_MISMATCH');
104
+ const space = await resolveDataTransformSpace(raw, async () => client.dataSpaces());
105
+ if (space !== dataSpace)
106
+ throw dataTransformSpaceMismatch(name, space, dataSpace);
107
+ refuseProcessing(raw.status);
108
+ return JSON.stringify(Object.fromEntries(Object.entries(raw).filter(([key]) => !key.startsWith('lastRun'))));
109
+ }
110
+ /**
111
+ * Delete one positively matched target of any owner; preview never writes and execution sends
112
+ * once, and Salesforce decides (a 4xx answer other than 404 is reported as rejected).
113
+ * A verbatim file (a transform the plugin cannot model) is deleted by its name: the GET must
114
+ * carry the same ID and name and not change between the reads.
115
+ * A resolved DELETE is only acknowledgement; settlement is the transform's absence from one
116
+ * bounded complete inventory, polled within a bound. Any read failure or partial list leaves
117
+ * the deletion unconfirmed. Never deletes DLOs, retries mutations or treats GET404 as absence.
118
+ * @param {unknown} value Exact portable definition expectation, not ownership authority.
119
+ * @param {DataTransformClient} client Bound native API68/default transform adapter.
120
+ * @param {DataTransformDeleteOptions} options Exact target ID, confirmation and fresh local input guard.
121
+ * @returns {Promise<DataTransformDeleteResult>} Honest acknowledgement/settlement classification.
122
+ */
123
+ export async function deleteDataTransform(value, client, options) {
124
+ // Read as retrieve writes it: the file and the GET may keep keys the plugin does not model.
125
+ const verbatim = isVerbatimDocument(value, 'data-transform');
126
+ const canonicalOf = (input) => verbatim
127
+ ? JSON.stringify(input)
128
+ : serializeDataTransformDocument(validateDataTransformDocument(input, 'retrieve'), 'retrieve');
129
+ const canonical = canonicalOf(value);
130
+ const name = verbatim
131
+ ? value.identity.apiName
132
+ : String(validateDataTransformDocument(value, 'retrieve').definition.name);
133
+ // The org transform must be in the file's data space, before any DELETE.
134
+ const space = verbatim
135
+ ? verbatimDataSpace(value)
136
+ : validateDataTransformDocument(value, 'retrieve').c__dataSpace;
137
+ const { targetId, confirmDelete, verifyInput } = options;
138
+ const preview = options.preview === true;
139
+ const methods = { ...client };
140
+ const check = () => {
141
+ if (typeof targetId !== 'string' ||
142
+ !dataTransformId.test(targetId) ||
143
+ typeof verifyInput !== 'function' ||
144
+ options.targetId !== targetId ||
145
+ options.confirmDelete !== confirmDelete ||
146
+ options.verifyInput !== verifyInput ||
147
+ (options.preview === true) !== preview ||
148
+ !isDeepStrictEqual({ ...client }, methods) ||
149
+ canonicalOf(value) !== canonical)
150
+ throw new DataTransformError('TRANSFORM_DELETE_INPUT_DRIFT');
151
+ };
152
+ const verify = async () => {
153
+ check();
154
+ await verifyInput();
155
+ check();
156
+ };
157
+ let first;
158
+ const read = async () => {
159
+ check();
160
+ if (verbatim) {
161
+ const observed = await readVerbatimTransform(targetId, name, space, client);
162
+ check();
163
+ first ??= observed;
164
+ if (observed !== first)
165
+ throw new DataTransformError('TRANSFORM_TARGET_DRIFT');
166
+ return;
167
+ }
168
+ const observed = await retrieveDataTransform(targetId, client, 'retrieve', undefined, space);
169
+ check();
170
+ refuseProcessing(observed.runtime.status);
171
+ // Enum values the org stores in its own letter case are no drift. The file matches as written
172
+ // (also when Salesforce stores an entity itself) or with its HTML-escaped expressions decoded.
173
+ const local = validateDataTransformDocument(value, 'retrieve');
174
+ if (!sameDataTransformDocument(observed.document, local, 'retrieve') &&
175
+ !sameDataTransformDocument(observed.document, { ...local, definition: plainTransformExpressions(local.definition) }, 'retrieve'))
176
+ throw new DataTransformError('TRANSFORM_TARGET_DRIFT');
177
+ };
178
+ await verify();
179
+ await read();
180
+ check();
181
+ const inventory = await listDataTransformInventory(client, check);
182
+ if (!inventory.some((row) => row.id === targetId && row.name === name))
183
+ throw new DataTransformError('TRANSFORM_DELETE_IDENTITY_MISMATCH');
184
+ await verify();
185
+ await read();
186
+ const result = (outcome, mutation) => ({ operation: 'delete', targetId, outcome, mutation });
187
+ if (preview)
188
+ return result('preview', 'not-attempted');
189
+ if (confirmDelete !== true)
190
+ return result('blocked', 'not-attempted');
191
+ try {
192
+ await client.delete(targetId);
193
+ }
194
+ catch (error) {
195
+ // Salesforce's 4xx refusal changed nothing (live API 68: 403 on a system transform). A 404
196
+ // and any other error have an uncertain outcome. Never replay or claim acknowledgement.
197
+ if (rejectedWrite(error) && !(error instanceof ConnectError && error.statusCode === 404))
198
+ return { ...result('failed', 'rejected'), error };
199
+ return result('deletion-unconfirmed', 'unknown');
200
+ }
201
+ try {
202
+ // The list keeps the transform for a while after the DELETE: poll it, bounded.
203
+ const now = options.now ?? Date.now;
204
+ const delay = options.delay ?? (async (milliseconds) => wait(milliseconds));
205
+ const deadline = now() + SETTLE_BUDGET_MS;
206
+ let listed = true;
207
+ for (;;) {
208
+ check();
209
+ const after = await listDataTransformInventory(client, check);
210
+ listed = after.some((row) => row.id === targetId || row.name === name);
211
+ if (!listed || now() >= deadline)
212
+ break;
213
+ await delay(Math.min(SETTLE_INTERVAL_MS, Math.max(0, deadline - now())));
214
+ }
215
+ if (listed)
216
+ return result('deletion-unconfirmed', 'acknowledged');
217
+ return result('deleted', 'confirmed-deleted');
218
+ }
219
+ catch {
220
+ return result('deletion-unconfirmed', 'acknowledged');
221
+ }
222
+ }
@@ -0,0 +1,211 @@
1
+ import type { NativeDmoDocument } from '../artifacts/native-dmo-document.js';
2
+ import type { NativeMappingDocument } from '../artifacts/native-mapping-document.js';
3
+ import type { NativeDmoSettle } from './native-dmo.js';
4
+ import type { DmoClient } from '../transport/dmo-rest.js';
5
+ import type { MappingClient } from '../transport/mapping-rest.js';
6
+ import type { DloClient } from '../transport/dlo-rest.js';
7
+ /** One mapping pair whose target is a field selected for deletion. */
8
+ export type DmoFieldPair = {
9
+ mapping: string;
10
+ sourceFieldDeveloperName: string;
11
+ targetFieldDeveloperName: string;
12
+ /** Observed pair selector; the only identity the pair DELETE accepts. */
13
+ developerName: string;
14
+ };
15
+ export type DmoFieldDeleteClients = {
16
+ /** Single-attempt DMO reads. */
17
+ dmo: Pick<DmoClient, 'get'>;
18
+ /** Client with the Metadata API route for the destructive change. */
19
+ remover: Pick<DmoClient, 'removeFields'>;
20
+ mappings: Pick<MappingClient, 'list' | 'get'>;
21
+ /** Source DLO reads; a refreshed mapping file leaves out the pairs Salesforce generated. */
22
+ source?: Pick<DloClient, 'get'>;
23
+ };
24
+ export type DmoFieldDeletePlan = {
25
+ apiName: string;
26
+ dataSpace: string;
27
+ fields: string[];
28
+ /** Mappings that hold a pair for a selected field, in inventory order. */
29
+ mappings: Array<{
30
+ document: NativeMappingDocument;
31
+ pairs: DmoFieldPair[];
32
+ }>;
33
+ };
34
+ /** Updated while the writes run, so a stop can report exactly what was already written. */
35
+ export type DmoFieldDeleteProgress = {
36
+ step: 'recheck' | 'remove' | 'readback';
37
+ /** Pairs Salesforce dropped with the fields, confirmed by an independent read. */
38
+ unmappedPairs: DmoFieldPair[];
39
+ /** Whether the destructive change was sent. */
40
+ removalSent: boolean;
41
+ };
42
+ /** Reads that bracket a field removal. */
43
+ export type FieldRemovalReaders = {
44
+ dmo: Pick<DmoClient, 'get'>;
45
+ mappings: Pick<MappingClient, 'list' | 'get'>;
46
+ };
47
+ /** What a field removal must leave untouched, read right before the write. */
48
+ export type FieldRemovalSnapshot = {
49
+ apiName: string;
50
+ fields: string[];
51
+ /** Raw DMO read. */
52
+ dmo: Record<string, unknown>;
53
+ /** Every mapping of the DMO, normalized, ordered by name. */
54
+ mappings: NativeMappingDocument[];
55
+ /** Pairs whose target is a removed field; Salesforce drops them with the field. */
56
+ pairs: DmoFieldPair[];
57
+ };
58
+ export type DmoFieldLocalFile = {
59
+ kind: 'dmo' | 'mapping';
60
+ /** Org name of the DMO or mapping. */
61
+ apiName: string;
62
+ path: string;
63
+ /** Name the local file uses for the mapping; differs from the org name for a hand-written file. */
64
+ fileApiName?: string;
65
+ };
66
+ export type DmoFieldRefresh = {
67
+ path: string;
68
+ outcome: 'refreshed' | 'unchanged' | 'not-present' | 'failed';
69
+ /** Refusal code of a failed refresh. */
70
+ code?: string;
71
+ };
72
+ type Receipt = {
73
+ path: string;
74
+ outcome: 'retrieved' | 'unchanged';
75
+ };
76
+ export type DmoFieldWriters = {
77
+ dmo: (value: unknown, projectRoot: string, overwrite: boolean) => Promise<Receipt>;
78
+ mapping: (value: unknown, projectRoot: string, overwrite: boolean) => Promise<Receipt>;
79
+ };
80
+ /**
81
+ * Admit a field-level delete with reads only: every named field present on the DMO, and every
82
+ * mapping pair that targets a named field identified by its observed selector on an ACTIVE
83
+ * mapping. Any field but the primary key may be named, standard, system and generated fields
84
+ * included: Salesforce decides, and its refusal is reported.
85
+ * @param {string} apiName Exact DMO full name.
86
+ * @param {string[]} fields Exact, distinct field names ending in __c.
87
+ * @param {DmoFieldDeleteClients} clients Target clients; only read here.
88
+ * @param {string} requestScope The run's data space.
89
+ * @returns {Promise<DmoFieldDeletePlan>} Pairs Salesforce drops with the fields, per mapping, and the fields.
90
+ */
91
+ export declare function planDmoFieldDelete(apiName: string, fields: string[], clients: DmoFieldDeleteClients, requestScope: string): Promise<DmoFieldDeletePlan>;
92
+ /**
93
+ * Snapshot, read-only and right before the write, what a field removal may change: the fields
94
+ * must exist, and every mapping of the DMO must be ACTIVE and match its detail read. The pairs
95
+ * that target the fields are collected, because Salesforce drops them with the field; a mapped
96
+ * field that no mapping lists a pair for has none to drop.
97
+ * @param {string} apiName Exact DMO full name.
98
+ * @param {string[]} fields Fields to remove.
99
+ * @param {FieldRemovalReaders} readers Target readers.
100
+ * @param {string} requestScope The run's data space.
101
+ * @returns {Promise<FieldRemovalSnapshot>} Expected state around the write.
102
+ */
103
+ export declare function snapshotFieldRemoval(apiName: string, fields: string[], readers: FieldRemovalReaders, requestScope: string): Promise<FieldRemovalSnapshot>;
104
+ /**
105
+ * Send the one field removal, then confirm with bounded reads that the fields are gone, that
106
+ * every mapping lost exactly its pairs for them (Salesforce drops those itself) and that the other
107
+ * mappings, pairs, selectors, DMO properties and fields are unchanged. A pair or field still
108
+ * present is waited for; any other difference stops with DMO_FIELD_REMOVAL_SIDE_EFFECT. Nothing is
109
+ * retried.
110
+ * @param {FieldRemovalSnapshot} snapshot State read right before the write.
111
+ * @param {FieldRemovalReaders} readers Target readers.
112
+ * @param {Function} remove The single write: one Metadata API destructive change.
113
+ * @param {Function} [onSent] Called once the write is about to be sent, and once it returned.
114
+ * @param {string} requestScope The run's data space.
115
+ * @param {NativeDmoSettle} [settle] Readback attempts and spacing.
116
+ * @returns {Promise<{pairs: DmoFieldPair[], dmo: Record<string, unknown>}>} The pairs Salesforce dropped and the DMO read that confirmed it.
117
+ */
118
+ export declare function removeFieldsWithPairs(snapshot: FieldRemovalSnapshot, readers: FieldRemovalReaders, remove: () => Promise<void>, onSent: ((step: "remove" | "readback") => void) | undefined, requestScope: string, settle?: NativeDmoSettle): Promise<{
119
+ pairs: DmoFieldPair[];
120
+ dmo: Record<string, unknown>;
121
+ }>;
122
+ /** Pairs a deployment may let Salesforce drop: covered fields, held by selected mappings only. */
123
+ export type FieldRemovalCoverage = {
124
+ /** Mapped fields the admission covered. */
125
+ fields: string[];
126
+ /** Source DLOs of the selected mapping files that target the DMO. */
127
+ sources: string[];
128
+ };
129
+ /**
130
+ * Snapshot, remove and confirm in one call; used by deploy for fields the file omits. The
131
+ * snapshot must agree with the admission: a pair on an uncovered field, or held by a mapping the
132
+ * deployment does not reconcile, refuses before the removal is sent.
133
+ * @param {string} apiName Exact DMO full name.
134
+ * @param {string[]} fields Fields to remove.
135
+ * @param {FieldRemovalReaders} readers Target readers.
136
+ * @param {Function} remove The single Metadata API destructive change.
137
+ * @param {FieldRemovalCoverage} coverage What the admission allowed to be dropped.
138
+ * @param {string} requestScope The run's data space.
139
+ * @param {NativeDmoSettle} [settle] Readback attempts and spacing.
140
+ * @returns {Promise<DmoFieldPair[]>} The pairs Salesforce dropped.
141
+ */
142
+ /**
143
+ * Read-only check before any write of a deployment that removes fields: the snapshot conditions
144
+ * hold and every pair on a removed field is covered by the admission.
145
+ * @param {string} apiName Exact DMO full name.
146
+ * @param {string[]} fields Fields to remove.
147
+ * @param {FieldRemovalReaders} readers Target readers.
148
+ * @param {FieldRemovalCoverage} coverage What the admission allowed to be dropped.
149
+ * @param {string} requestScope The run's data space.
150
+ * @returns {Promise<FieldRemovalSnapshot>} The snapshot.
151
+ */
152
+ export declare function checkFieldRemoval(apiName: string, fields: string[], readers: FieldRemovalReaders, coverage: FieldRemovalCoverage, requestScope: string): Promise<FieldRemovalSnapshot>;
153
+ /**
154
+ * Snapshot, remove and confirm in one call; used by deploy for fields the file omits.
155
+ * @param {string} apiName Exact DMO full name.
156
+ * @param {string[]} fields Fields to remove.
157
+ * @param {FieldRemovalReaders} readers Target readers.
158
+ * @param {Function} remove The single Metadata API destructive change.
159
+ * @param {FieldRemovalCoverage} coverage What the admission allowed to be dropped.
160
+ * @param {string} requestScope The run's data space.
161
+ * @param {NativeDmoSettle} [settle] Readback attempts and spacing.
162
+ * @returns {Promise<DmoFieldPair[]>} The pairs Salesforce dropped.
163
+ */
164
+ export declare function removeFieldsChecked(apiName: string, fields: string[], readers: FieldRemovalReaders, remove: () => Promise<void>, coverage: FieldRemovalCoverage, requestScope: string, settle?: NativeDmoSettle): Promise<DmoFieldPair[]>;
165
+ /**
166
+ * Run the admitted removal once, never retried: a fresh snapshot that must still match the plan,
167
+ * one Metadata API destructive change for all fields (Salesforce drops their mapping pairs
168
+ * itself), then bounded reads that confirm the fields and exactly those pairs are gone and nothing
169
+ * else changed. The first failure throws; `progress` then says what was already written.
170
+ * @param {DmoFieldDeletePlan} plan Admitted plan.
171
+ * @param {DmoFieldDeleteClients} clients Target clients.
172
+ * @param {DmoFieldDeleteProgress} progress Mutated before and after the write.
173
+ * @param {string} requestScope The run's data space.
174
+ * @param {NativeDmoSettle} [settle] Readback attempts and spacing.
175
+ * @returns {Promise<NativeDmoDocument>} Definition read back without the fields.
176
+ */
177
+ export declare function executeDmoFieldDelete(plan: DmoFieldDeletePlan, clients: DmoFieldDeleteClients, progress: DmoFieldDeleteProgress, requestScope: string, settle?: NativeDmoSettle): Promise<NativeDmoDocument>;
178
+ /**
179
+ * Find the local file of a mapping: the file named after the org mapping, otherwise the one file
180
+ * whose binding (source DLO, target DMO, data space) matches, as a hand-written file is named
181
+ * freely. Unreadable files are skipped; two matching files leave the canonical name.
182
+ * @param {NativeMappingDocument} document Org mapping.
183
+ * @param {string} root Absolute project root.
184
+ * @returns {Promise<DmoFieldLocalFile>} The file to refresh, existing or not.
185
+ */
186
+ export declare function mappingLocalFile(document: NativeMappingDocument, root: string): Promise<DmoFieldLocalFile>;
187
+ /**
188
+ * Name the project files of the DMO and of every mapping that loses a pair.
189
+ * @param {DmoFieldDeletePlan} plan Admitted plan.
190
+ * @param {string} projectRoot Absolute project root.
191
+ * @returns {Promise<DmoFieldLocalFile[]>} DMO file first, then one file per mapping.
192
+ */
193
+ export declare function dmoFieldLocalFiles(plan: DmoFieldDeletePlan, projectRoot: string): Promise<DmoFieldLocalFile[]>;
194
+ /**
195
+ * Report whether a project file exists, without reading or following it.
196
+ * @param {string} file Exact path.
197
+ * @returns {Promise<boolean>} False only for a confirmed absence.
198
+ */
199
+ export declare function localFileExists(file: string): Promise<boolean>;
200
+ /**
201
+ * Refresh the project files that already exist from fresh reads of the target; a file that is not
202
+ * present is never created. Every file is attempted; a failure is reported, never thrown.
203
+ * @param {DmoFieldDeletePlan} plan Executed plan.
204
+ * @param {string} projectRoot Absolute project root.
205
+ * @param {DmoFieldDeleteClients} clients Target clients; only read here.
206
+ * @param {DmoFieldWriters} writers Existing artifact writers.
207
+ * @param {string} requestScope The run's data space.
208
+ * @returns {Promise<DmoFieldRefresh[]>} One outcome per canonical file.
209
+ */
210
+ export declare function refreshDmoFieldFiles(plan: DmoFieldDeletePlan, projectRoot: string, clients: DmoFieldDeleteClients, writers: DmoFieldWriters, requestScope: string): Promise<DmoFieldRefresh[]>;
211
+ export {};