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,560 @@
1
+ import { dataTransformName } from './path-selector.js';
2
+ import { crossSpaceSentence, explainInput, printableKey, } from '../services/operation-diagnostic.js';
3
+ import { foldEnums } from './enum-case.js';
4
+ import { dataSpaceKey, isDataSpaceName, readSingleDataSpace } from './data-space-field.js';
5
+ import { unescapeSalesforceHtml } from './native-calculated-insight-document.js';
6
+ import { htmlEntityOutsideTexts } from '../services/cross-dataspace-sql.js';
7
+ /** Payload-free refusal of a native data transform operation. */
8
+ export class DataTransformError extends Error {
9
+ code;
10
+ constructor(code) {
11
+ super(`Native Data Transform operation refused: ${code}.`);
12
+ this.code = code;
13
+ this.name = 'DataTransformError';
14
+ }
15
+ }
16
+ export const dataTransformId = /^1dt[A-Za-z0-9]{15}$/u;
17
+ /** Top-level keys of the native create/update input, in the order a GET is projected. */
18
+ const inputKeys = [
19
+ 'name',
20
+ 'label',
21
+ 'description',
22
+ 'type',
23
+ 'dataSpaceName',
24
+ 'fullRunFrequency',
25
+ 'definition',
26
+ 'definitions',
27
+ 'parameters',
28
+ 'tags',
29
+ 'capabilities',
30
+ 'currencyIsoCode',
31
+ 'primarySource',
32
+ ];
33
+ /**
34
+ * Server-owned top-level keys of a GET (live API 68 GET, isolated-source 2026-11-15), plus every
35
+ * `lastRun*` key; no create/update input takes them. Other keys outside `inputKeys` are kept on
36
+ * retrieve, and deploy refuses them.
37
+ */
38
+ const serverKeys = new Set([
39
+ 'actionUrls',
40
+ 'createdBy',
41
+ 'createdDate',
42
+ 'creationSource',
43
+ 'creationType',
44
+ 'id',
45
+ 'lastModifiedBy',
46
+ 'lastModifiedDate',
47
+ 'namespace',
48
+ 'status',
49
+ 'url',
50
+ ]);
51
+ /** Server-owned keys of an `outputDataObjects` entry; the rest is sent as read. */
52
+ const outputServerKeys = ['id', 'createdDate', 'lastModifiedDate', 'status'];
53
+ /**
54
+ * Reject a condition without retaining resource payloads in diagnostics.
55
+ * @param {unknown} condition Admission condition.
56
+ * @param {string} code Stable refusal code.
57
+ */
58
+ function requireTransform(condition, code = 'UNSUPPORTED_TRANSFORM_INPUT') {
59
+ if (!condition)
60
+ throw new DataTransformError(code);
61
+ }
62
+ /**
63
+ * Require inert JSON before reading properties or cloning untrusted values.
64
+ * @param {unknown} value JSON candidate.
65
+ * @param {Set<object>} ancestors Active recursion stack.
66
+ */
67
+ function inert(value, ancestors = new Set()) {
68
+ if (value === null || typeof value === 'string' || typeof value === 'boolean')
69
+ return;
70
+ if (typeof value === 'number') {
71
+ requireTransform(Number.isFinite(value));
72
+ return;
73
+ }
74
+ requireTransform(value && typeof value === 'object' && !ancestors.has(value));
75
+ requireTransform(Object.getPrototypeOf(value) === (Array.isArray(value) ? Array.prototype : Object.prototype));
76
+ ancestors.add(value);
77
+ const keys = Reflect.ownKeys(value);
78
+ if (Array.isArray(value))
79
+ requireTransform(keys.length === value.length + 1);
80
+ for (const key of keys) {
81
+ if (Array.isArray(value) && key === 'length')
82
+ continue;
83
+ requireTransform(typeof key === 'string');
84
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
85
+ requireTransform(descriptor?.enumerable && 'value' in descriptor);
86
+ inert(descriptor.value, ancestors);
87
+ }
88
+ ancestors.delete(value);
89
+ }
90
+ /**
91
+ * Check an exact object key inventory after inert JSON admission.
92
+ * @param {unknown} value Candidate record.
93
+ * @param {string[]} [keys] Exact accepted properties.
94
+ * @returns {Record<string, unknown>} Checked record.
95
+ */
96
+ function record(value, keys) {
97
+ requireTransform(value && typeof value === 'object' && !Array.isArray(value));
98
+ if (keys)
99
+ requireTransform(Object.keys(value).length === keys.length && keys.every((key) => Object.hasOwn(value, key)));
100
+ return value;
101
+ }
102
+ /**
103
+ * Refuse a transform file, naming the key path that cannot be deployed.
104
+ * @param {string} keyPath Printable key path.
105
+ * @param {string} problem What is wrong with it.
106
+ * @returns {DataTransformError} UNSUPPORTED_TRANSFORM_INPUT with an explanation.
107
+ */
108
+ function refuseKey(keyPath, problem) {
109
+ return explainInput(new DataTransformError('UNSUPPORTED_TRANSFORM_INPUT'), `The data transform file cannot be deployed: ${keyPath} ${problem}. Correct the file, or retrieve the transform again once the plugin supports it.`);
110
+ }
111
+ /**
112
+ * The data space a transform input names itself (`dataSpaceName`), or undefined when it names
113
+ * none (its data space then comes from the org's MktDataTransform record).
114
+ * @param {Record<string, unknown>} input Admitted transform input.
115
+ * @returns {string | undefined} Data space.
116
+ */
117
+ export function dataTransformSpace(input) {
118
+ return typeof input.dataSpaceName === 'string' ? input.dataSpaceName : undefined;
119
+ }
120
+ /**
121
+ * The refusal of a transform file whose `c__dataSpace` is not the run's data space.
122
+ * @param {string} name Transform name.
123
+ * @param {string} fileSpace The file's c__dataSpace.
124
+ * @param {string} dataSpace The run's data space.
125
+ * @param {boolean} [crossSpace] A deploy of a file --allow-cross-dataspace can translate: say so.
126
+ * @returns {DataTransformError} TRANSFORM_DATASPACE_MISMATCH with an explanation.
127
+ */
128
+ export function dataTransformSpaceMismatch(name, fileSpace, dataSpace, crossSpace = false) {
129
+ return explainInput(new DataTransformError('TRANSFORM_DATASPACE_MISMATCH'), `Data transform ${name} is in the data space ${printableKey(fileSpace)} (${dataSpaceKey}, or the org's transform; one without any data space is handled in default), but the run's data space is ${printableKey(dataSpace)}. Run the command with --dataspace ${printableKey(fileSpace)}.${crossSpace ? crossSpaceSentence(dataSpace) : ''}`);
130
+ }
131
+ /**
132
+ * Admit the native transform input as authored: inert JSON, an exact name, exactly one of
133
+ * `definition` / `definitions`, only create/update input keys and, when `dataSpaceName` is
134
+ * present, a data space name. Salesforce validates the rest. Retrieve mode keeps keys the
135
+ * input does not take; deploy then refuses them, naming the key.
136
+ * @param {unknown} value Complete native input.
137
+ * @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (keeps unknown keys).
138
+ * @returns {Record<string, unknown>} Detached input, sent as written.
139
+ */
140
+ export function buildDataTransformInput(value, mode = 'deploy') {
141
+ inert(value);
142
+ const input = record(value);
143
+ requireTransform(typeof input.name === 'string' && dataTransformName.test(input.name));
144
+ if (Object.hasOwn(input, 'definition') && Object.hasOwn(input, 'definitions'))
145
+ throw refuseKey('definition.definitions', 'is present beside definition.definition');
146
+ requireTransform(Object.hasOwn(input, 'definition') || Object.hasOwn(input, 'definitions'));
147
+ if (mode === 'deploy')
148
+ for (const key of Object.keys(input))
149
+ if (!inputKeys.includes(key))
150
+ throw refuseKey(`definition.${printableKey(key)}`, 'is not a key the data transform create/update input takes');
151
+ // A transform on DLOs has no dataSpaceName; one on DMOs names its data space.
152
+ requireTransform(!Object.hasOwn(input, 'dataSpaceName') || isDataSpaceName(input.dataSpaceName));
153
+ return structuredClone(input);
154
+ }
155
+ /**
156
+ * Refuse a transform file problem, naming the key.
157
+ * @param {string} code Refusal code.
158
+ * @param {string} keyPath Key path.
159
+ * @param {string} problem What is wrong with it.
160
+ * @returns {DataTransformError} Refusal with an explanation.
161
+ */
162
+ function refuseFile(code, keyPath, problem) {
163
+ return explainInput(new DataTransformError(code), `The data transform file cannot be deployed: ${keyPath} ${problem}. Correct the file, or retrieve the transform again.`);
164
+ }
165
+ /**
166
+ * Validate the portable input-only native API68 artifact. Its `c__dataSpace` must equal
167
+ * `definition.dataSpaceName` when the definition names one.
168
+ * @param {unknown} value Portable candidate.
169
+ * @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (keeps unknown input keys).
170
+ * @returns {DataTransformDocument} Detached checked document.
171
+ */
172
+ export function validateDataTransformDocument(value, mode = 'deploy') {
173
+ inert(value);
174
+ const scheduled = Boolean(value && typeof value === 'object' && Object.hasOwn(value, 'schedule'));
175
+ const dataSpace = readSingleDataSpace(record(value), refuseFile);
176
+ const document = record(value, scheduled
177
+ ? ['schemaVersion', 'kind', 'apiVersion', dataSpaceKey, 'definition', 'schedule']
178
+ : ['schemaVersion', 'kind', 'apiVersion', dataSpaceKey, 'definition']);
179
+ requireTransform(document.schemaVersion === 1 &&
180
+ document.kind === 'data-transform' &&
181
+ document.apiVersion === '68.0');
182
+ if (scheduled &&
183
+ (!document.schedule ||
184
+ typeof document.schedule !== 'object' ||
185
+ Array.isArray(document.schedule)))
186
+ throw refuseKey('schedule', 'is not an object');
187
+ const definition = buildDataTransformInput(document.definition, mode);
188
+ const named = dataTransformSpace(definition);
189
+ if (named !== undefined && named !== dataSpace)
190
+ throw refuseFile('INVALID_DATASPACE_FIELD', dataSpaceKey, 'must name the data space of definition.dataSpaceName');
191
+ return {
192
+ schemaVersion: 1,
193
+ kind: 'data-transform',
194
+ apiVersion: '68.0',
195
+ c__dataSpace: dataSpace,
196
+ definition,
197
+ ...(scheduled
198
+ ? { schedule: structuredClone(document.schedule) }
199
+ : {}),
200
+ };
201
+ }
202
+ /**
203
+ * Sort object keys recursively, so equal JSON compares equal whatever the property order.
204
+ * @param {unknown} entry JSON value.
205
+ * @returns {unknown} Detached value with sorted keys.
206
+ */
207
+ function canonical(entry) {
208
+ if (Array.isArray(entry))
209
+ return entry.map((child) => canonical(child));
210
+ if (entry && typeof entry === 'object') {
211
+ const entries = Object.entries(entry);
212
+ entries.sort(([left], [right]) => left.localeCompare(right, 'en'));
213
+ return Object.fromEntries(entries.map(([key, child]) => [key, canonical(child)]));
214
+ }
215
+ return entry;
216
+ }
217
+ /**
218
+ * Produce stable portable bytes independent of response property ordering.
219
+ * @param {unknown} value Checked artifact candidate.
220
+ * @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (keeps unknown input keys).
221
+ * @returns {string} Deterministic JSON with final LF.
222
+ */
223
+ export function serializeDataTransformDocument(value, mode = 'deploy') {
224
+ const document = validateDataTransformDocument(value, mode);
225
+ // eslint-disable-next-line unicorn/no-null -- JSON indentation requires a null replacer, not a field policy.
226
+ return `${JSON.stringify(canonical(document), null, 2)}\n`;
227
+ }
228
+ /**
229
+ * STL node parameter keys whose values are SQL expressions. Salesforce stores them as sent and
230
+ * never decodes HTML entities on write; without the plain-text request header (plainTextHeaders)
231
+ * its GET returns them HTML-escaped (`&gt;`, `&lt;`, `&quot;`, `&#39;`), as older plugin versions
232
+ * wrote them into files (live, DB entries data360:plugin-cross-dataspace-deploy-3b-api68 and
233
+ * data360:connect-rest-entity-encoding-header-api68).
234
+ */
235
+ const stlExpressionKeys = new Set([
236
+ 'formulaExpression',
237
+ 'sqlFilterExpression',
238
+ ]);
239
+ /** DCSQL manifest node keys that hold SQL text, treated the same way. */
240
+ const dcsqlSqlKeys = ['compiled_code', 'raw_code'];
241
+ const isObject = (value) => Boolean(value) && typeof value === 'object' && !Array.isArray(value);
242
+ /**
243
+ * A node key as it may appear in a message: a printable key, dots allowed (`model.out1`).
244
+ * @param {string} key Node key.
245
+ * @returns {string} Printable key.
246
+ */
247
+ const nodeKey = (key) => /^[A-Za-z_$][\w.$-]{0,79}$/u.test(key) ? key : printableKey(key);
248
+ /**
249
+ * Replace every SQL expression string below one STL node's parameters.
250
+ * @param {unknown} value Parameters or part of them (changed in place).
251
+ * @param {string} at JSON path of `value`.
252
+ * @param {(text: string, at: string) => string} visit Replacement of one expression.
253
+ */
254
+ function visitParameters(value, at, visit) {
255
+ if (Array.isArray(value)) {
256
+ for (const [index, entry] of value.entries())
257
+ visitParameters(entry, `${at}[${index}]`, visit);
258
+ return;
259
+ }
260
+ if (!isObject(value))
261
+ return;
262
+ for (const [key, entry] of Object.entries(value)) {
263
+ const path = `${at}.${printableKey(key)}`;
264
+ if (typeof entry === 'string' && stlExpressionKeys.has(key))
265
+ value[key] = visit(entry, path);
266
+ else
267
+ visitParameters(entry, path, visit);
268
+ }
269
+ }
270
+ /**
271
+ * A copy of a transform input with every SQL expression replaced: STL formula and SQL filter
272
+ * expressions and the SQL of DCSQL manifest nodes, in `definition` or each `definitions` entry.
273
+ * @param {Record<string, unknown>} input Transform input (not changed).
274
+ * @param {(text: string, at: string) => string} visit Replacement of one expression.
275
+ * @returns {Record<string, unknown>} Detached input.
276
+ */
277
+ function mapTransformExpressions(input, visit) {
278
+ const copy = structuredClone(input);
279
+ const entries = Array.isArray(copy.definitions)
280
+ ? copy.definitions.map((entry, index) => [entry, `definition.definitions[${index}]`])
281
+ : [[copy.definition, 'definition.definition']];
282
+ for (const [entry, at] of entries) {
283
+ if (!isObject(entry))
284
+ continue;
285
+ if (isObject(entry.nodes))
286
+ for (const [key, node] of Object.entries(entry.nodes))
287
+ if (isObject(node))
288
+ visitParameters(node.parameters, `${at}.nodes.${nodeKey(key)}.parameters`, visit);
289
+ const manifest = entry.manifest;
290
+ if (isObject(manifest) && isObject(manifest.nodes))
291
+ for (const [key, node] of Object.entries(manifest.nodes))
292
+ if (isObject(node))
293
+ for (const sqlKey of dcsqlSqlKeys)
294
+ if (typeof node[sqlKey] === 'string')
295
+ node[sqlKey] = visit(node[sqlKey], `${at}.manifest.nodes.${nodeKey(key)}.${sqlKey}`);
296
+ }
297
+ return copy;
298
+ }
299
+ /**
300
+ * A transform file's input with each SQL expression that is an HTML-escaped copy (an entity
301
+ * outside texts, as an older plugin version retrieved it) decoded, the others kept, so a delete
302
+ * compares such a file with the org as observed.
303
+ * @param {Record<string, unknown>} input Transform input from a file.
304
+ * @returns {Record<string, unknown>} Detached input.
305
+ */
306
+ export function plainTransformExpressions(input) {
307
+ return mapTransformExpressions(input, (text) => htmlEntityOutsideTexts(text) === undefined ? text : unescapeSalesforceHtml(text));
308
+ }
309
+ /**
310
+ * Refuse a transform file whose SQL expression holds an HTML entity outside texts, comments and
311
+ * quoted names: Salesforce does not decode entities on write, so it would read them as a syntax
312
+ * error.
313
+ * @param {DataTransformDocument} document Checked transform file.
314
+ */
315
+ export function refuseEscapedTransformExpressions(document) {
316
+ let found;
317
+ mapTransformExpressions(document.definition, (text, at) => {
318
+ const entity = found ? undefined : htmlEntityOutsideTexts(text);
319
+ if (entity)
320
+ found = { at, ...entity };
321
+ return text;
322
+ });
323
+ if (found)
324
+ throw explainInput(new DataTransformError('UNSUPPORTED_TRANSFORM_INPUT'), `The data transform file cannot be deployed: ${found.at} holds the HTML entity ${found.text} at line ${found.line}:${found.column} outside texts, which Salesforce reads as a syntax error (it stores what it is sent and does not decode entities). Write the character itself in the file. If a fresh retrieve of the data transform still shows the entity, Salesforce stores the expression that way; write the character itself in the file, or fix the expression in Data Cloud.`);
325
+ }
326
+ /**
327
+ * A transform input without the `nodeType` `STANDARD` of its STL aggregate nodes, which Salesforce
328
+ * adds to an aggregate node that does not name it (live API 68), so a file without it compares
329
+ * equal to the org.
330
+ * @param {Record<string, unknown>} input Transform input (not changed).
331
+ * @returns {Record<string, unknown>} Detached input.
332
+ */
333
+ function withoutDefaultNodeType(input) {
334
+ const copy = structuredClone(input);
335
+ const entries = Array.isArray(copy.definitions) ? copy.definitions : [copy.definition];
336
+ for (const entry of entries) {
337
+ if (!isObject(entry) || !isObject(entry.nodes))
338
+ continue;
339
+ for (const node of Object.values(entry.nodes))
340
+ if (isObject(node) &&
341
+ node.action === 'aggregate' &&
342
+ isObject(node.parameters) &&
343
+ typeof node.parameters.nodeType === 'string' &&
344
+ node.parameters.nodeType.toUpperCase() === 'STANDARD')
345
+ delete node.parameters.nodeType;
346
+ }
347
+ return copy;
348
+ }
349
+ /**
350
+ * Transform keys whose values are enums Salesforce stores in its own letter case
351
+ * (`fullRunFrequency` `Weekly` reads `WEEKLY`, live API 68): the transform, definition, output
352
+ * object and field `type`, the output `category` and an output node's `writeMode`.
353
+ */
354
+ const transformEnumKeys = new Set([
355
+ 'category',
356
+ 'fullRunFrequency',
357
+ 'type',
358
+ 'writeMode',
359
+ ]);
360
+ /**
361
+ * The schedule of a transform that does not run on a schedule. Retrieve leaves the key out for
362
+ * it; a file states it explicitly to turn a schedule off.
363
+ */
364
+ export const unscheduled = Object.freeze({ frequency: 'None' });
365
+ /** Schedule keys whose values Salesforce may store in its own letter case. */
366
+ const scheduleEnumKeys = new Set(['frequency']);
367
+ /**
368
+ * Whether the org transform already holds the definition of the file: the same canonical input,
369
+ * with enum values compared ignoring letter case and an aggregate node's `nodeType` `STANDARD`
370
+ * (added by Salesforce) the same as none. Names, labels, SQL and other text compare exactly (the
371
+ * org's expressions as stored, read as plain text). The schedule is not compared.
372
+ * @param {DataTransformDocument} current Org document as projected.
373
+ * @param {DataTransformDocument} desired Document from the file.
374
+ * @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (keeps unknown input keys).
375
+ * @returns {boolean} True when the definition would not change.
376
+ */
377
+ export function sameDataTransformDefinition(current, desired, mode = 'deploy') {
378
+ const comparable = (document) => serializeDataTransformDocument({
379
+ schemaVersion: 1,
380
+ kind: 'data-transform',
381
+ apiVersion: '68.0',
382
+ c__dataSpace: document.c__dataSpace,
383
+ definition: foldEnums(withoutDefaultNodeType(document.definition), transformEnumKeys),
384
+ }, mode);
385
+ return comparable(current) === comparable(desired);
386
+ }
387
+ /**
388
+ * A schedule without the write-only `shouldForceSpecifiedMinutes` (a schedule PUT takes it; the
389
+ * GET never returns it, live API 68), at the top level and in each per-definition entry.
390
+ * @param {unknown} schedule Schedule or part of one.
391
+ * @returns {unknown} Detached copy without the key.
392
+ */
393
+ function withoutWriteOnly(schedule) {
394
+ if (Array.isArray(schedule))
395
+ return schedule.map((entry) => withoutWriteOnly(entry));
396
+ if (!schedule || typeof schedule !== 'object')
397
+ return schedule;
398
+ return Object.fromEntries(Object.entries(schedule)
399
+ .filter(([key]) => key !== 'shouldForceSpecifiedMinutes')
400
+ .map(([key, entry]) => [key, withoutWriteOnly(entry)]));
401
+ }
402
+ /**
403
+ * Whether the org schedule (as retrieve projects it) equals the schedule of the file; the
404
+ * frequency is compared ignoring letter case, the write-only `shouldForceSpecifiedMinutes` is not
405
+ * compared, everything else exactly.
406
+ * @param {Record<string, unknown> | undefined} current Projected org schedule; none is unscheduled.
407
+ * @param {Record<string, unknown>} desired Schedule from the file.
408
+ * @returns {boolean} True when the schedule would not change.
409
+ */
410
+ export function sameDataTransformSchedule(current, desired) {
411
+ const comparable = (schedule) => JSON.stringify(canonical(foldEnums(withoutWriteOnly(schedule), scheduleEnumKeys)));
412
+ return comparable(current ?? unscheduled) === comparable(desired);
413
+ }
414
+ /**
415
+ * Whether the org transform already holds the file: the same definition and, when the file has
416
+ * a schedule, the same schedule. A file without a schedule leaves the schedule alone.
417
+ * @param {DataTransformDocument} current Org document as projected.
418
+ * @param {DataTransformDocument} desired Document from the file.
419
+ * @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (keeps unknown input keys).
420
+ * @returns {boolean} True when nothing would change.
421
+ */
422
+ export function sameDataTransformDocument(current, desired, mode = 'deploy') {
423
+ return (sameDataTransformDefinition(current, desired, mode) &&
424
+ (desired.schedule === undefined ||
425
+ sameDataTransformSchedule(current.schedule, desired.schedule)));
426
+ }
427
+ /**
428
+ * Project a schedule GET onto the keys the schedule PUT takes (live API 68, 2026-11-18):
429
+ * `frequency`, `interval`, `daysOfWeek`, `shouldForceSpecifiedMinutes` and `time` with
430
+ * `hour`, `minute` and `timeZone` (the GET's `time.timezone.zoneId`); the server-set
431
+ * `nextScheduledDate` and `type` are left out. A transform without a schedule (`frequency`
432
+ * `None`, or an empty `schedule` object) gives no schedule, so retrieve leaves the key out and
433
+ * a deploy of that file leaves the schedule alone. The per-definition
434
+ * `schedule` map of a system transform keeps its map, each entry projected the same way and the
435
+ * outer `type` left out; Salesforce refuses a schedule PUT on a system transform (403). Any other
436
+ * shape is kept as read. An empty answer (a schedule read that failed on retrieve) gives no
437
+ * schedule.
438
+ * @param {Record<string, unknown>} raw Schedule GET.
439
+ * @returns {Record<string, unknown> | undefined} Projected schedule, or undefined for none read.
440
+ */
441
+ export function projectDataTransformSchedule(raw) {
442
+ const object = (value) => Boolean(value) && typeof value === 'object' && !Array.isArray(value);
443
+ if (typeof raw.frequency === 'string') {
444
+ if (raw.frequency.toLowerCase() === 'none')
445
+ return undefined;
446
+ const projected = { frequency: raw.frequency };
447
+ for (const key of ['interval', 'daysOfWeek', 'shouldForceSpecifiedMinutes'])
448
+ if (raw[key] !== undefined && raw[key] !== null)
449
+ projected[key] = structuredClone(raw[key]);
450
+ if (object(raw.time)) {
451
+ const time = {};
452
+ for (const key of ['hour', 'minute'])
453
+ if (raw.time[key] !== undefined && raw.time[key] !== null)
454
+ time[key] = raw.time[key];
455
+ const zone = object(raw.time.timezone) ? raw.time.timezone.zoneId : raw.time.timeZone;
456
+ if (zone !== undefined && zone !== null)
457
+ time.timeZone = zone;
458
+ projected.time = time;
459
+ }
460
+ return projected;
461
+ }
462
+ if (Object.keys(raw).length === 0)
463
+ return undefined;
464
+ if (object(raw.schedule) &&
465
+ Object.keys(raw).every((key) => key === 'schedule' || key === 'type')) {
466
+ const entries = Object.entries(raw.schedule);
467
+ if (entries.length === 0)
468
+ return undefined;
469
+ // A system transform: one schedule per definition, each projected the same way.
470
+ if (entries.every(([, entry]) => object(entry) && typeof entry.frequency === 'string'))
471
+ return {
472
+ schedule: Object.fromEntries(entries.map(([key, entry]) => [
473
+ key,
474
+ projectDataTransformSchedule(entry),
475
+ ])),
476
+ };
477
+ }
478
+ return structuredClone(raw);
479
+ }
480
+ /**
481
+ * Project one `definition` or `definitions[]` entry as read: without its schedule (a PUT ignores
482
+ * it; the schedule has its own route) and without the server-owned keys of each output object.
483
+ * Everything else is kept.
484
+ * @param {unknown} definition Entry from a GET.
485
+ * @returns {unknown} Detached projected entry.
486
+ */
487
+ function projectDefinition(definition) {
488
+ const projected = structuredClone(definition);
489
+ if (!projected || typeof projected !== 'object' || Array.isArray(projected))
490
+ return projected;
491
+ const entry = projected;
492
+ delete entry.schedule;
493
+ if (Array.isArray(entry.outputDataObjects))
494
+ for (const output of entry.outputDataObjects)
495
+ if (output && typeof output === 'object' && !Array.isArray(output))
496
+ for (const key of outputServerKeys)
497
+ delete output[key];
498
+ return entry;
499
+ }
500
+ /**
501
+ * Admit a transform GET of any owner (custom, system or packaged; Salesforce decides about
502
+ * writes) and project its native input: the input keys present, definitions without schedule and
503
+ * output objects without server-owned keys, plus the schedule as projected from its own GET.
504
+ * Retrieve mode also keeps keys that are neither input nor server-owned, and leaves out a `null`
505
+ * `definition` or `definitions` beside the other one.
506
+ * @param {unknown} value Native item response.
507
+ * @param {unknown} scheduleValue Independently read native schedule; also kept as read.
508
+ * @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (keeps unknown keys).
509
+ * @param {string} [dataSpace] The transform's resolved data space (from `dataSpaceName`, or the
510
+ * org's MktDataTransform record); required when the GET names none.
511
+ * @returns {DataTransformObservation} Portable input plus detached read-only observations.
512
+ */
513
+ export function observeDataTransform(value, scheduleValue, mode = 'deploy', dataSpace) {
514
+ inert(value);
515
+ inert(scheduleValue);
516
+ const runtime = record(value);
517
+ const schedule = record(scheduleValue);
518
+ requireTransform(typeof runtime.id === 'string' && dataTransformId.test(runtime.id), 'INVALID_TRANSFORM_RESPONSE');
519
+ const projected = {};
520
+ // On retrieve, a null definition or definitions beside the other one is the unused one.
521
+ const unused = (key) => mode === 'retrieve' &&
522
+ (key === 'definition' || key === 'definitions') &&
523
+ runtime[key] === null &&
524
+ Object.hasOwn(runtime, key === 'definition' ? 'definitions' : 'definition');
525
+ for (const key of inputKeys) {
526
+ if (!Object.hasOwn(runtime, key) || unused(key))
527
+ continue;
528
+ const entry = runtime[key];
529
+ projected[key] =
530
+ key === 'definition'
531
+ ? projectDefinition(entry)
532
+ : key === 'definitions' && Array.isArray(entry)
533
+ ? entry.map((item) => projectDefinition(item))
534
+ : structuredClone(entry);
535
+ }
536
+ if (mode === 'retrieve')
537
+ for (const key of Object.keys(runtime))
538
+ if (!inputKeys.includes(key) && !serverKeys.has(key) && !key.startsWith('lastRun'))
539
+ projected[key] = structuredClone(runtime[key]);
540
+ const projectedSchedule = projectDataTransformSchedule(schedule);
541
+ const definition = buildDataTransformInput(projected, mode);
542
+ const space = dataTransformSpace(definition) ?? dataSpace;
543
+ requireTransform(space !== undefined, 'INVALID_TRANSFORM_RESPONSE');
544
+ // A resolved data space that differs from the one the GET names is not this transform.
545
+ requireTransform(dataSpace === undefined || dataSpace === space, 'INVALID_TRANSFORM_RESPONSE');
546
+ return {
547
+ document: {
548
+ schemaVersion: 1,
549
+ kind: 'data-transform',
550
+ apiVersion: '68.0',
551
+ c__dataSpace: space,
552
+ definition,
553
+ ...(projectedSchedule === undefined ? {} : { schedule: projectedSchedule }),
554
+ },
555
+ targetId: runtime.id,
556
+ runtime: structuredClone(runtime),
557
+ schedule: structuredClone(schedule),
558
+ };
559
+ }
560
+ export { dataTransformName } from './path-selector.js';
@@ -0,0 +1,51 @@
1
+ import type { DloDocument } from './dlo-document.js';
2
+ import type { CalculatedInsightReference as CalculatedInsightReference } from './native-calculated-insight-document.js';
3
+ import type { IdentityResolutionDocument } from './identity-resolution-document.js';
4
+ import type { NativeDmoDocument } from './native-dmo-document.js';
5
+ import type { DocumentMode } from './verbatim-document.js';
6
+ import type { SegmentDocument } from './segment-document.js';
7
+ export type DependencyIdentity = {
8
+ kind: 'dmo' | 'segment' | 'identity-resolution' | 'calculated-insight' | 'dlo';
9
+ dataSpace: string;
10
+ apiName: string;
11
+ };
12
+ export type DependencyNode = {
13
+ identity: DependencyIdentity;
14
+ dependencies: DependencyIdentity[];
15
+ };
16
+ export declare const dependencyLimits: Readonly<{
17
+ nodes: 256;
18
+ edges: 512;
19
+ }>;
20
+ /** Payload-free selection refusal. */
21
+ export declare class DependencySelectionError extends Error {
22
+ readonly code: string;
23
+ constructor(code: string);
24
+ }
25
+ /**
26
+ * Key exact typed identities in any data space; API names are mandatory, never label fallbacks.
27
+ * @param {DependencyIdentity} identity Logical identity.
28
+ * @returns {string} Unambiguous typed key.
29
+ */
30
+ export declare function dependencyKey(identity: DependencyIdentity): string;
31
+ /**
32
+ * Extract only admitted family structures; unknown closure must not become an empty leaf.
33
+ * @param {NativeDmoDocument | SegmentDocument | IdentityResolutionDocument} value Authored component.
34
+ * @param {DocumentMode} [mode] `retrieve` checks a DLO or DMO only for its identity.
35
+ * @param {string} [dataSpace] The run's data space: a DLO (which lists every data space it
36
+ * belongs to) is keyed in it when it lists it.
37
+ * @returns {DependencyNode} Exact component and dependencies.
38
+ */
39
+ export declare function documentDependencyNode(value: NativeDmoDocument | SegmentDocument | IdentityResolutionDocument | CalculatedInsightReference | DloDocument, mode?: DocumentMode, dataSpace?: string): DependencyNode;
40
+ /**
41
+ * Order selected nodes dependency-first, retaining isolated roots and external prerequisites.
42
+ * Family/space/name is a tie-break only among ready nodes. External nodes need target binding.
43
+ * @param {DependencyNode[]} nodes Complete selected graph.
44
+ * @param {{nodes: number, edges: number}} [limits] Node and edge caps; deploy keeps the default,
45
+ * retrieve passes unbounded caps (it writes files and provisions nothing).
46
+ * @returns {string[]} Ordered typed keys.
47
+ */
48
+ export declare function orderDependencyNodes(nodes: DependencyNode[], limits?: Readonly<{
49
+ nodes: number;
50
+ edges: number;
51
+ }>): string[];