sf-plugin-data 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +572 -240
  3. package/docs/artifact-format.md +527 -633
  4. package/docs/capabilities.md +1159 -168
  5. package/docs/git-workflow.md +135 -12
  6. package/docs/handover.md +7826 -12
  7. package/lib/api.d.ts +7 -0
  8. package/lib/api.js +7 -0
  9. package/lib/artifacts/code-fields.d.ts +49 -0
  10. package/lib/artifacts/code-fields.js +142 -0
  11. package/lib/artifacts/data-graph-document.d.ts +29 -0
  12. package/lib/artifacts/data-graph-document.js +52 -0
  13. package/lib/artifacts/data-space-field.d.ts +65 -0
  14. package/lib/artifacts/data-space-field.js +98 -0
  15. package/lib/artifacts/data-stream-document.d.ts +264 -0
  16. package/lib/artifacts/data-stream-document.js +680 -0
  17. package/lib/artifacts/data-transform-document.d.ts +152 -0
  18. package/lib/artifacts/data-transform-document.js +560 -0
  19. package/lib/artifacts/dependency-selection.d.ts +51 -0
  20. package/lib/artifacts/dependency-selection.js +154 -0
  21. package/lib/artifacts/dlo-document.d.ts +93 -0
  22. package/lib/artifacts/dlo-document.js +253 -0
  23. package/lib/artifacts/enum-case.d.ts +39 -0
  24. package/lib/artifacts/enum-case.js +67 -0
  25. package/lib/artifacts/git-deploy-selection.d.ts +68 -0
  26. package/lib/artifacts/git-deploy-selection.js +474 -0
  27. package/lib/artifacts/identity-resolution-document.d.ts +133 -0
  28. package/lib/artifacts/identity-resolution-document.js +625 -0
  29. package/lib/artifacts/mapping-document.d.ts +1 -0
  30. package/lib/artifacts/mapping-document.js +1 -0
  31. package/lib/artifacts/native-calculated-insight-document.d.ts +142 -0
  32. package/lib/artifacts/native-calculated-insight-document.js +321 -0
  33. package/lib/artifacts/native-data-graph-document.d.ts +124 -0
  34. package/lib/artifacts/native-data-graph-document.js +780 -0
  35. package/lib/artifacts/native-dmo-document.d.ts +151 -0
  36. package/lib/artifacts/native-dmo-document.js +313 -0
  37. package/lib/artifacts/native-mapping-document.d.ts +67 -0
  38. package/lib/artifacts/native-mapping-document.js +187 -0
  39. package/lib/artifacts/native-relationship-document.d.ts +76 -0
  40. package/lib/artifacts/native-relationship-document.js +232 -0
  41. package/lib/artifacts/path-selector.d.ts +55 -0
  42. package/lib/artifacts/path-selector.js +167 -0
  43. package/lib/artifacts/read-deploy-input.d.ts +222 -6
  44. package/lib/artifacts/read-deploy-input.js +1213 -53
  45. package/lib/artifacts/segment-document.d.ts +183 -0
  46. package/lib/artifacts/segment-document.js +570 -0
  47. package/lib/artifacts/verbatim-document.d.ts +203 -0
  48. package/lib/artifacts/verbatim-document.js +339 -0
  49. package/lib/artifacts/write-data-graph.d.ts +17 -0
  50. package/lib/artifacts/write-data-graph.js +162 -0
  51. package/lib/artifacts/write-data-stream.d.ts +11 -0
  52. package/lib/artifacts/write-data-stream.js +175 -0
  53. package/lib/artifacts/write-data-transform.d.ts +11 -0
  54. package/lib/artifacts/write-data-transform.js +180 -0
  55. package/lib/artifacts/write-dlo.d.ts +11 -0
  56. package/lib/artifacts/write-dlo.js +158 -0
  57. package/lib/artifacts/write-identity-resolution.d.ts +18 -0
  58. package/lib/artifacts/write-identity-resolution.js +165 -0
  59. package/lib/artifacts/write-mapping-definition.d.ts +17 -0
  60. package/lib/artifacts/write-mapping-definition.js +127 -0
  61. package/lib/artifacts/write-member-export.d.ts +88 -0
  62. package/lib/artifacts/write-member-export.js +199 -0
  63. package/lib/artifacts/write-native-calculated-insight.d.ts +21 -0
  64. package/lib/artifacts/write-native-calculated-insight.js +176 -0
  65. package/lib/artifacts/write-native-dmo.d.ts +11 -0
  66. package/lib/artifacts/write-native-dmo.js +158 -0
  67. package/lib/artifacts/write-native-mapping.d.ts +11 -0
  68. package/lib/artifacts/write-native-mapping.js +157 -0
  69. package/lib/artifacts/write-native-relationship.d.ts +11 -0
  70. package/lib/artifacts/write-native-relationship.js +157 -0
  71. package/lib/artifacts/write-segment.d.ts +26 -0
  72. package/lib/artifacts/write-segment.js +212 -0
  73. package/lib/commands/data360/delete.d.ts +280 -0
  74. package/lib/commands/data360/delete.js +2297 -0
  75. package/lib/commands/data360/deploy.d.ts +234 -15
  76. package/lib/commands/data360/deploy.js +2292 -100
  77. package/lib/commands/data360/publish.d.ts +93 -0
  78. package/lib/commands/data360/publish.js +292 -0
  79. package/lib/commands/data360/retrieve.d.ts +260 -13
  80. package/lib/commands/data360/retrieve.js +1880 -85
  81. package/lib/commands/data360/segment/members/export.d.ts +101 -0
  82. package/lib/commands/data360/segment/members/export.js +318 -0
  83. package/lib/errors/codes/calculated-insight.d.ts +2 -0
  84. package/lib/errors/codes/calculated-insight.js +25 -0
  85. package/lib/errors/codes/data-graph.d.ts +2 -0
  86. package/lib/errors/codes/data-graph.js +22 -0
  87. package/lib/errors/codes/data-stream.d.ts +2 -0
  88. package/lib/errors/codes/data-stream.js +70 -0
  89. package/lib/errors/codes/data-transform.d.ts +2 -0
  90. package/lib/errors/codes/data-transform.js +35 -0
  91. package/lib/errors/codes/dependency.d.ts +2 -0
  92. package/lib/errors/codes/dependency.js +11 -0
  93. package/lib/errors/codes/dlo.d.ts +2 -0
  94. package/lib/errors/codes/dlo.js +31 -0
  95. package/lib/errors/codes/dmo.d.ts +2 -0
  96. package/lib/errors/codes/dmo.js +28 -0
  97. package/lib/errors/codes/general.d.ts +2 -0
  98. package/lib/errors/codes/general.js +57 -0
  99. package/lib/errors/codes/identity-resolution.d.ts +2 -0
  100. package/lib/errors/codes/identity-resolution.js +24 -0
  101. package/lib/errors/codes/mapping.d.ts +2 -0
  102. package/lib/errors/codes/mapping.js +42 -0
  103. package/lib/errors/codes/relationship.d.ts +2 -0
  104. package/lib/errors/codes/relationship.js +21 -0
  105. package/lib/errors/codes/segment.d.ts +2 -0
  106. package/lib/errors/codes/segment.js +49 -0
  107. package/lib/errors/registry.d.ts +60 -0
  108. package/lib/errors/registry.js +123 -0
  109. package/lib/plugin.d.ts +1 -0
  110. package/lib/plugin.js +3 -1
  111. package/lib/services/acquire-retrieve-selection.d.ts +43 -0
  112. package/lib/services/acquire-retrieve-selection.js +145 -0
  113. package/lib/services/bind-identity-resolution-dependencies.d.ts +53 -0
  114. package/lib/services/bind-identity-resolution-dependencies.js +238 -0
  115. package/lib/services/bind-segment-dependencies.d.ts +49 -0
  116. package/lib/services/bind-segment-dependencies.js +115 -0
  117. package/lib/services/bounded-reads.d.ts +17 -0
  118. package/lib/services/bounded-reads.js +42 -0
  119. package/lib/services/calculated-insight-sql-checks.d.ts +33 -0
  120. package/lib/services/calculated-insight-sql-checks.js +193 -0
  121. package/lib/services/command-dlo.d.ts +48 -0
  122. package/lib/services/command-dlo.js +103 -0
  123. package/lib/services/command-native-data-graph.d.ts +54 -0
  124. package/lib/services/command-native-data-graph.js +485 -0
  125. package/lib/services/command-native-data-stream.d.ts +104 -0
  126. package/lib/services/command-native-data-stream.js +257 -0
  127. package/lib/services/command-native-dmo.d.ts +124 -0
  128. package/lib/services/command-native-dmo.js +338 -0
  129. package/lib/services/command-native-mapping.d.ts +65 -0
  130. package/lib/services/command-native-mapping.js +129 -0
  131. package/lib/services/command-native-relationship.d.ts +46 -0
  132. package/lib/services/command-native-relationship.js +103 -0
  133. package/lib/services/cross-dataspace-deploy.d.ts +111 -0
  134. package/lib/services/cross-dataspace-deploy.js +493 -0
  135. package/lib/services/cross-dataspace-rename.d.ts +74 -0
  136. package/lib/services/cross-dataspace-rename.js +1314 -0
  137. package/lib/services/cross-dataspace-sql.d.ts +109 -0
  138. package/lib/services/cross-dataspace-sql.js +1301 -0
  139. package/lib/services/cross-space-context.d.ts +23 -0
  140. package/lib/services/cross-space-context.js +36 -0
  141. package/lib/services/crud-plan.d.ts +137 -0
  142. package/lib/services/crud-plan.js +408 -0
  143. package/lib/services/data-space-check.d.ts +89 -0
  144. package/lib/services/data-space-check.js +162 -0
  145. package/lib/services/data-space-prefix.d.ts +77 -0
  146. package/lib/services/data-space-prefix.js +127 -0
  147. package/lib/services/data-transform-space.d.ts +31 -0
  148. package/lib/services/data-transform-space.js +79 -0
  149. package/lib/services/delete-calculated-insight.d.ts +44 -0
  150. package/lib/services/delete-calculated-insight.js +101 -0
  151. package/lib/services/delete-data-transform.d.ts +52 -0
  152. package/lib/services/delete-data-transform.js +222 -0
  153. package/lib/services/delete-dmo-field.d.ts +211 -0
  154. package/lib/services/delete-dmo-field.js +472 -0
  155. package/lib/services/delete-identity-resolution.d.ts +43 -0
  156. package/lib/services/delete-identity-resolution.js +295 -0
  157. package/lib/services/delete-segment.d.ts +42 -0
  158. package/lib/services/delete-segment.js +248 -0
  159. package/lib/services/deploy-result.d.ts +54 -0
  160. package/lib/services/deploy-result.js +60 -0
  161. package/lib/services/escaped-copy.d.ts +23 -0
  162. package/lib/services/escaped-copy.js +88 -0
  163. package/lib/services/execute-calculated-insight-deploy.d.ts +42 -0
  164. package/lib/services/execute-calculated-insight-deploy.js +96 -0
  165. package/lib/services/execute-data-transform-deploy.d.ts +56 -0
  166. package/lib/services/execute-data-transform-deploy.js +168 -0
  167. package/lib/services/execute-native-identity-resolution-deploy.d.ts +48 -0
  168. package/lib/services/execute-native-identity-resolution-deploy.js +360 -0
  169. package/lib/services/execute-segment-deploy.d.ts +45 -0
  170. package/lib/services/execute-segment-deploy.js +393 -0
  171. package/lib/services/local-file-removal.d.ts +36 -0
  172. package/lib/services/local-file-removal.js +103 -0
  173. package/lib/services/native-calculated-insight.d.ts +87 -0
  174. package/lib/services/native-calculated-insight.js +164 -0
  175. package/lib/services/native-crm-data-stream.d.ts +91 -0
  176. package/lib/services/native-crm-data-stream.js +272 -0
  177. package/lib/services/native-data-graph-context.d.ts +12 -0
  178. package/lib/services/native-data-graph-context.js +139 -0
  179. package/lib/services/native-data-graph-crd.d.ts +261 -0
  180. package/lib/services/native-data-graph-crd.js +866 -0
  181. package/lib/services/native-data-stream.d.ts +329 -0
  182. package/lib/services/native-data-stream.js +1830 -0
  183. package/lib/services/native-dlo.d.ts +163 -0
  184. package/lib/services/native-dlo.js +402 -0
  185. package/lib/services/native-dmo.d.ts +191 -0
  186. package/lib/services/native-dmo.js +614 -0
  187. package/lib/services/native-mapping.d.ts +255 -0
  188. package/lib/services/native-mapping.js +1226 -0
  189. package/lib/services/native-relationship.d.ts +132 -0
  190. package/lib/services/native-relationship.js +512 -0
  191. package/lib/services/operation-diagnostic.d.ts +83 -0
  192. package/lib/services/operation-diagnostic.js +272 -0
  193. package/lib/services/preflight-calculated-insight-deploy.d.ts +58 -0
  194. package/lib/services/preflight-calculated-insight-deploy.js +95 -0
  195. package/lib/services/preflight-data-transform-deploy.d.ts +33 -0
  196. package/lib/services/preflight-data-transform-deploy.js +104 -0
  197. package/lib/services/preflight-identity-resolution-deploy.d.ts +107 -0
  198. package/lib/services/preflight-identity-resolution-deploy.js +281 -0
  199. package/lib/services/preflight-segment-deploy.d.ts +31 -0
  200. package/lib/services/preflight-segment-deploy.js +109 -0
  201. package/lib/services/publish-calculated-insight.d.ts +40 -0
  202. package/lib/services/publish-calculated-insight.js +95 -0
  203. package/lib/services/publish-segment.d.ts +65 -0
  204. package/lib/services/publish-segment.js +194 -0
  205. package/lib/services/readback-pace.d.ts +16 -0
  206. package/lib/services/readback-pace.js +23 -0
  207. package/lib/services/retrieve-data-transform.d.ts +26 -0
  208. package/lib/services/retrieve-data-transform.js +65 -0
  209. package/lib/services/retrieve-identity-resolution.d.ts +40 -0
  210. package/lib/services/retrieve-identity-resolution.js +87 -0
  211. package/lib/services/retrieve-inventory.d.ts +32 -0
  212. package/lib/services/retrieve-inventory.js +151 -0
  213. package/lib/services/retrieve-segment.d.ts +120 -0
  214. package/lib/services/retrieve-segment.js +502 -0
  215. package/lib/services/segment-lookup.d.ts +46 -0
  216. package/lib/services/segment-lookup.js +108 -0
  217. package/lib/services/segment-members.d.ts +144 -0
  218. package/lib/services/segment-members.js +402 -0
  219. package/lib/services/select-native-retrieve.d.ts +60 -0
  220. package/lib/services/select-native-retrieve.js +226 -0
  221. package/lib/services/settle-calculated-insight.d.ts +22 -0
  222. package/lib/services/settle-calculated-insight.js +53 -0
  223. package/lib/services/sql-tokens.d.ts +58 -0
  224. package/lib/services/sql-tokens.js +147 -0
  225. package/lib/transport/api-version.d.ts +36 -0
  226. package/lib/transport/api-version.js +89 -0
  227. package/lib/transport/bound-ssot.d.ts +27 -0
  228. package/lib/transport/bound-ssot.js +116 -0
  229. package/lib/transport/calculated-insight-rest.d.ts +28 -0
  230. package/lib/transport/calculated-insight-rest.js +62 -0
  231. package/lib/transport/connect-client.d.ts +94 -32
  232. package/lib/transport/connect-client.js +318 -178
  233. package/lib/transport/connect-diagnostic.d.ts +89 -0
  234. package/lib/transport/connect-diagnostic.js +331 -0
  235. package/lib/transport/data-graph-rest.d.ts +27 -0
  236. package/lib/transport/data-graph-rest.js +76 -0
  237. package/lib/transport/data-stream-rest.d.ts +62 -0
  238. package/lib/transport/data-stream-rest.js +348 -0
  239. package/lib/transport/data-transform-rest.d.ts +25 -0
  240. package/lib/transport/data-transform-rest.js +100 -0
  241. package/lib/transport/dlo-native-rest.d.ts +22 -0
  242. package/lib/transport/dlo-native-rest.js +89 -0
  243. package/lib/transport/dlo-rest.d.ts +23 -0
  244. package/lib/transport/dlo-rest.js +135 -0
  245. package/lib/transport/dmo-native-rest.d.ts +18 -0
  246. package/lib/transport/dmo-native-rest.js +55 -0
  247. package/lib/transport/dmo-rest.d.ts +30 -0
  248. package/lib/transport/dmo-rest.js +163 -0
  249. package/lib/transport/mapping-rest.d.ts +63 -0
  250. package/lib/transport/mapping-rest.js +341 -0
  251. package/lib/transport/project-metadata.d.ts +36 -0
  252. package/lib/transport/project-metadata.js +118 -0
  253. package/lib/transport/relationship-rest.d.ts +43 -0
  254. package/lib/transport/relationship-rest.js +201 -0
  255. package/package.json +29 -6
  256. package/lib/artifacts/dmo-document.d.ts +0 -181
  257. package/lib/artifacts/dmo-document.js +0 -848
  258. package/lib/artifacts/dmo-update-delta.d.ts +0 -28
  259. package/lib/artifacts/dmo-update-delta.js +0 -86
  260. package/lib/artifacts/write-other-dmo.d.ts +0 -17
  261. package/lib/artifacts/write-other-dmo.js +0 -140
  262. package/lib/services/execute-dmo-create.d.ts +0 -24
  263. package/lib/services/execute-dmo-create.js +0 -118
  264. package/lib/services/execute-dmo-deploy.d.ts +0 -33
  265. package/lib/services/execute-dmo-deploy.js +0 -197
  266. package/lib/services/preflight-dmo-deploy.d.ts +0 -69
  267. package/lib/services/preflight-dmo-deploy.js +0 -161
  268. package/lib/services/retrieve-other-dmo.d.ts +0 -46
  269. package/lib/services/retrieve-other-dmo.js +0 -140
@@ -0,0 +1,151 @@
1
+ import { dataTransformName } from '../artifacts/data-transform-document.js';
2
+ import { dataTransformSpaceById, readDataTransformSpaces } from './data-transform-space.js';
3
+ import { NativeMappingError } from '../artifacts/native-mapping-document.js';
4
+ import { ConnectClient } from '../transport/connect-client.js';
5
+ /** Stream and graph API names, as their exact selectors accept them. */
6
+ const componentName = /^[A-Za-z][A-Za-z0-9_]{0,199}$/u;
7
+ /**
8
+ * Every API name a list route returns, following its `limit`/`offset` paging until `totalSize`
9
+ * (or, without it, a short or empty page). Extra envelope keys are ignored; a malformed answer
10
+ * stops the listing (NATIVE_INVENTORY_UNCONFIRMED). An entry without a usable API name is skipped
11
+ * with a warning, an entry that names only other data spaces is left out and a repeated name is
12
+ * listed once. A page that adds no new name ends the listing (a server ignoring the offset).
13
+ * @param {Pick<Connection, 'instanceUrl' | 'request'>} connection Authenticated connection.
14
+ * @param {string} version Numeric API version of the reads.
15
+ * @param {InventoryRoute} route The family's list route.
16
+ * @param {string[]} [warnings] Receives one warning per skipped entry.
17
+ * @returns {Promise<string[]>} Sorted API names.
18
+ */
19
+ async function listNames(connection, version, route, warnings) {
20
+ const client = new ConnectClient(connection, version);
21
+ const seen = new Set();
22
+ const names = [];
23
+ for (let offset = 0;;) {
24
+ const page = await client.get(route.url(offset));
25
+ const entries = page?.[route.key];
26
+ if (!page || typeof page !== 'object' || !Array.isArray(entries))
27
+ throw new NativeMappingError('NATIVE_INVENTORY_UNCONFIRMED');
28
+ let named = 0;
29
+ let added = 0;
30
+ for (const [index, entry] of entries.entries()) {
31
+ const item = (entry && typeof entry === 'object' ? entry : {});
32
+ const value = item[route.nameKey];
33
+ const apiName = typeof value === 'string' ? value : undefined;
34
+ if (apiName === undefined || !route.pattern.test(apiName)) {
35
+ warnings?.push(`${route.family} inventory: skipped ${apiName === undefined ? `the entry at position ${offset + index}` : `"${apiName}"`} because it has no usable API name.`);
36
+ continue;
37
+ }
38
+ named++;
39
+ if (seen.has(apiName))
40
+ continue;
41
+ seen.add(apiName);
42
+ added++;
43
+ const spaces = route.spaces(item);
44
+ if (spaces === undefined)
45
+ route.unresolved?.push({ apiName, entry: item });
46
+ else if (spaces.length === 0 || spaces.includes(route.dataSpace))
47
+ names.push(apiName);
48
+ }
49
+ if (route.pageSize === undefined)
50
+ break;
51
+ offset += entries.length;
52
+ const total = page.totalSize;
53
+ const more = typeof total === 'number' && Number.isSafeInteger(total)
54
+ ? offset < total
55
+ : entries.length >= route.pageSize;
56
+ if (entries.length === 0 || !more || (named > 0 && added === 0))
57
+ break;
58
+ }
59
+ names.sort();
60
+ return names;
61
+ }
62
+ /**
63
+ * A string, or nothing.
64
+ * @param {unknown} value Any value.
65
+ * @returns {string[]} The non-empty string alone, else empty.
66
+ */
67
+ const named = (value) => (typeof value === 'string' && value ? [value] : []);
68
+ /**
69
+ * Every data stream `GET /ssot/data-streams` lists (`limit` 1 to 200, `offset`), kept unless its
70
+ * DLO names only other data spaces than the run's.
71
+ * @param {Pick<Connection, 'instanceUrl' | 'request'>} connection Authenticated connection.
72
+ * @param {string} version Numeric API version.
73
+ * @param {string[]} [warnings] Receives one warning per skipped entry.
74
+ * @param {string} [dataSpace] The run's data space.
75
+ * @returns {Promise<string[]>} Sorted stream API names.
76
+ */
77
+ export async function listDataStreamNames(connection, version, warnings, dataSpace = 'default') {
78
+ return listNames(connection, version, {
79
+ family: 'data-stream',
80
+ url: (offset) => `/services/data/v${version}/ssot/data-streams?limit=200&offset=${offset}`,
81
+ pageSize: 200,
82
+ key: 'dataStreams',
83
+ nameKey: 'name',
84
+ pattern: componentName,
85
+ dataSpace,
86
+ spaces: (entry) => {
87
+ const info = entry.dataLakeObjectInfo
88
+ ?.dataSpaceInfo;
89
+ return Array.isArray(info)
90
+ ? info.flatMap((space) => named(space?.name))
91
+ : [];
92
+ },
93
+ }, warnings);
94
+ }
95
+ /**
96
+ * Every data transform of the run's data space that `GET /ssot/data-transforms` lists (pages of
97
+ * at most 20, `offset`; the list ignores `?dataspace=`, live API 68). An entry is in the data
98
+ * space its `dataSpaceName` names; for one without it, one SOQL read of the org's
99
+ * MktDataTransform records names it by the entry's record `id`, and a transform without any data
100
+ * space there (a system transform) is listed in default only.
101
+ * @param {Pick<Connection, 'instanceUrl' | 'request'>} connection Authenticated connection.
102
+ * @param {string[]} [warnings] Receives one warning per skipped entry.
103
+ * @param {string} [dataSpace] The run's data space.
104
+ * @returns {Promise<string[]>} Sorted transform names.
105
+ */
106
+ export async function listDataTransformNames(connection, warnings, dataSpace = 'default') {
107
+ const unresolved = [];
108
+ const names = await listNames(connection, '68.0', {
109
+ family: 'data-transform',
110
+ unresolved,
111
+ url: (offset) => `/services/data/v68.0/ssot/data-transforms?limit=20&offset=${offset}`,
112
+ pageSize: 20,
113
+ key: 'dataTransforms',
114
+ nameKey: 'name',
115
+ pattern: dataTransformName,
116
+ dataSpace,
117
+ spaces: (entry) => {
118
+ const space = named(entry.dataSpaceName);
119
+ return space.length > 0 ? space : undefined;
120
+ },
121
+ }, warnings);
122
+ if (unresolved.length === 0)
123
+ return names;
124
+ const client = new ConnectClient(connection, '68.0');
125
+ const spaces = await readDataTransformSpaces(async (query) => client.soql(query));
126
+ // By the record ID of the list entry only: the record's Name is a label.
127
+ for (const { apiName, entry } of unresolved)
128
+ if (dataTransformSpaceById(entry.id, spaces) === dataSpace)
129
+ names.push(apiName);
130
+ names.sort();
131
+ return names;
132
+ }
133
+ /**
134
+ * Every data graph of one data space `GET /ssot/data-graphs/metadata?dataspace=` lists (the route
135
+ * filters by it and has no paging); each entry's own `dataspaceName` must name it too.
136
+ * @param {Pick<Connection, 'instanceUrl' | 'request'>} connection Authenticated connection.
137
+ * @param {string[]} [warnings] Receives one warning per skipped entry.
138
+ * @param {string} [dataSpace] The run's data space.
139
+ * @returns {Promise<string[]>} Sorted graph developer names.
140
+ */
141
+ export async function listDataGraphNames(connection, warnings, dataSpace = 'default') {
142
+ return listNames(connection, '68.0', {
143
+ family: 'data-graph',
144
+ url: () => `/services/data/v68.0/ssot/data-graphs/metadata?dataspace=${encodeURIComponent(dataSpace)}`,
145
+ key: 'dataGraphMetadata',
146
+ nameKey: 'developerName',
147
+ pattern: componentName,
148
+ dataSpace,
149
+ spaces: (entry) => named(entry.dataspaceName),
150
+ }, warnings);
151
+ }
@@ -0,0 +1,120 @@
1
+ import type { Connection } from '@salesforce/core';
2
+ import { SegmentError } from '../artifacts/segment-document.js';
3
+ import type { SegmentDocument, SegmentSchedule } from '../artifacts/segment-document.js';
4
+ import type { ApiVersionSelection } from '../transport/api-version.js';
5
+ import type { DocumentMode } from '../artifacts/verbatim-document.js';
6
+ export type SegmentAcquisition = {
7
+ /** The reported identity: the requested name in the run's data space. */
8
+ identity: {
9
+ dataSpace: string;
10
+ apiName: string;
11
+ };
12
+ candidate?: SegmentDocument;
13
+ blockers: string[];
14
+ expectations?: {
15
+ runtime: Record<string, unknown>;
16
+ };
17
+ /** The plugin-built explanation of the first blocker, when it has one. */
18
+ explanation?: string;
19
+ };
20
+ /**
21
+ * Project the schedule of a segment GET onto the write shape of the file (live API 68,
22
+ * 2026-11-18): `publishScheduleInfo` gives `frequency`, `interval`, `daysOfWeek` (read as a plain
23
+ * list; an empty one is left out) and `time` (from `timeInfo`, which Salesforce reads back as
24
+ * null); `publishScheduleStartDateTime`, `publishScheduleEndDate` and
25
+ * `publishScheduleEndDateTime` give `startDateTime`, `endDate` and `endDateTime`;
26
+ * `nextScheduledDate` is left out, and so is `publishInterval` beside `publishScheduleInfo`.
27
+ * Without `publishScheduleInfo`, a refresh other than NO_REFRESH (an hourly interval) keeps its
28
+ * `publishInterval`. A segment with NO_REFRESH and no dates has no schedule, so retrieve leaves
29
+ * the key out. Schedule details the plugin does not know (another `publishScheduleInfo` key, a
30
+ * `frequency` that is not text, `daysOfWeek` that is not a list) are UNSUPPORTED_SEGMENT_VARIANT
31
+ * on retrieve; a deploy-mode read gives `opaqueSegmentSchedule`, so a file without `schedule`
32
+ * still deploys and keeps the org schedule.
33
+ * @param {Record<string, unknown>} raw The segment inside the GET response.
34
+ * @param {DocumentMode} [mode] `deploy` (target reads) or `retrieve`.
35
+ * @returns {SegmentSchedule | undefined} Projected schedule, or undefined for none.
36
+ */
37
+ export declare function projectSegmentSchedule(raw: Record<string, unknown>, mode?: DocumentMode): SegmentSchedule | undefined;
38
+ /**
39
+ * Admit an exact response without discarding unknown potentially meaningful fields. Retrieve mode
40
+ * reads `segments[0]` of any wrapper, keeps keys the plugin does not know in `spec` (and extra
41
+ * `includeDbt` keys in `spec.includeDbt`), does not check the observed fields, and refuses only
42
+ * what the file cannot represent (no DBT configuration, parameters, a schedule the file cannot
43
+ * hold, another source kind, a model name unfit for a file), so the segment is written verbatim;
44
+ * the model SQL is kept as read (plain text, plainTextHeaders).
45
+ * Segments of other types than DBT are projected by `projectTypedSegment`.
46
+ * @param {unknown} response Untrusted API68 exact GET response.
47
+ * @param {string} apiName Requested exact identity.
48
+ * @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (keeps unknown keys).
49
+ * @param {ReadonlyMap<string, string>} [children] Waterfall child definition ID to API name.
50
+ * @returns {{candidate: SegmentDocument; runtime: Record<string, unknown>}} Detached portable and private projections.
51
+ */
52
+ export declare function projectSegment(response: unknown, apiName: string, mode?: DocumentMode, children?: ReadonlyMap<string, string>): {
53
+ candidate: SegmentDocument;
54
+ runtime: Record<string, unknown>;
55
+ };
56
+ /**
57
+ * The refusal of a segment that the org holds in another data space than the run's. Its name is
58
+ * unique in the org (Salesforce stores a non-default segment as `<prefix>_<Name>`), so a read by
59
+ * name finds it wherever it is.
60
+ * @param {string} apiName Segment name.
61
+ * @param {unknown} found The data space the org names for it.
62
+ * @param {string} dataSpace The run's data space.
63
+ * @returns {SegmentError} SEGMENT_DATASPACE_MISMATCH with an explanation.
64
+ */
65
+ export declare function segmentSpaceMismatch(apiName: string, found: unknown, dataSpace: string): SegmentError;
66
+ /**
67
+ * Acquire one API68 Segment of the run's data space by its exact (stored) name; the GET needs no
68
+ * data space (live API 68: the stored name is unique in the org), and a segment of another data
69
+ * space is SEGMENT_DATASPACE_MISMATCH.
70
+ * A failed GET is never absence evidence; no runtime writes are available. A retrieve of a
71
+ * Waterfall with child segments, without `children`, names them with one segment list read
72
+ * (their definition IDs are org-specific); when that read fails the criteria stay as read.
73
+ * @param {Connection} connection Authenticated command-owned API68 connection.
74
+ * @param {string} apiName Exact selected identity.
75
+ * @param {string | ApiVersionSelection} apiVersion Requested fixed API version.
76
+ * @param {string} dataSpace The run's data space.
77
+ * @param {DocumentMode} [mode] `deploy` (strict) or `retrieve` (keeps what the plugin does not model).
78
+ * @param {ReadonlyMap<string, string>} [children] Waterfall child definition ID to API name.
79
+ * @returns {Promise<SegmentAcquisition>} Detached portable candidate and private runtime baseline.
80
+ */
81
+ export declare function retrieveSegment(connection: Pick<Connection, 'instanceUrl' | 'request' | 'getApiVersion' | 'getUsername'>, apiName: string, apiVersion: string | ApiVersionSelection, dataSpace: string, mode?: DocumentMode, children?: ReadonlyMap<string, string>): Promise<SegmentAcquisition>;
82
+ /**
83
+ * Name the child segments of a Waterfall read in retrieve mode (retrieve and delete): one
84
+ * segment list read per connection maps each definition ID to its API name. Nothing is read for
85
+ * another segment type or a Waterfall without children; a failed list read names nothing.
86
+ * @param {Pick<Connection, 'instanceUrl' | 'request'>} connection Authenticated API 68 connection.
87
+ * @param {unknown} response Segment GET response.
88
+ * @returns {Promise<ReadonlyMap<string, string> | undefined>} Definition ID to API name.
89
+ */
90
+ export declare function segmentChildNames(connection: Pick<Connection, 'instanceUrl' | 'request'>, response: unknown): Promise<ReadonlyMap<string, string> | undefined>;
91
+ /**
92
+ * Every segment of the run's data space the API 68 list returns, following its
93
+ * `batchSize`/`offset` paging until `totalSize` (or, without it, until a short or empty page).
94
+ * The list is filtered by each entry's own `dataSpace`, never by a query parameter. Extra envelope
95
+ * keys are ignored; a malformed page stops the listing (SEGMENT_ACQUISITION_FAILED). An entry
96
+ * without a usable API name or data space is skipped with a warning, a segment of another data
97
+ * space is left out and a repeated name is listed once. A page that adds no new name ends the
98
+ * listing (a server ignoring the offset).
99
+ * @param {Pick<Connection, 'instanceUrl' | 'request'>} connection Authenticated API 68 connection.
100
+ * @param {string[]} [warnings] Receives one warning per skipped entry.
101
+ * @param {string} [dataSpace] The run's data space.
102
+ * @returns {Promise<string[]>} Sorted API names.
103
+ */
104
+ export declare function listSegmentNames(connection: Pick<Connection, 'instanceUrl' | 'request'>, warnings?: string[], dataSpace?: string): Promise<string[]>;
105
+ /**
106
+ * The entries of the segment list in one data space (or, without one, in every data space), as
107
+ * `listSegmentNames` pages and filters them, in list order.
108
+ * @param {Pick<Connection, 'instanceUrl' | 'request'>} connection Authenticated API 68 connection.
109
+ * @param {string[]} [warnings] Receives one warning per skipped entry.
110
+ * @param {string} [dataSpace] Data space to keep; undefined keeps every one.
111
+ * @param {object} [options] Options.
112
+ * @param {boolean} [options.queryDataSpace] Also send the data space as `dataspace` query parameter
113
+ * (the list filters by it); only the segment lookup asks for it.
114
+ * @returns {Promise<Array<Record<string, unknown> & {apiName: string}>>} Listed segments.
115
+ */
116
+ export declare function listSegmentEntries(connection: Pick<Connection, 'instanceUrl' | 'request'>, warnings?: string[], dataSpace?: string, options?: {
117
+ queryDataSpace?: boolean;
118
+ }): Promise<Array<Record<string, unknown> & {
119
+ apiName: string;
120
+ }>>;