@peernova/cuneiform-sf 1.0.2 → 1.0.4-beta.10

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 (488) hide show
  1. package/LICENSE +81 -30
  2. package/README.md +168 -134
  3. package/lib/adapters/connection-facade.d.ts +458 -0
  4. package/lib/adapters/connection-facade.js +379 -0
  5. package/lib/adapters/connection-facade.js.map +1 -0
  6. package/lib/adapters/errors.d.ts +547 -0
  7. package/lib/adapters/errors.js +937 -0
  8. package/lib/adapters/errors.js.map +1 -0
  9. package/lib/adapters/lifecycle.d.ts +112 -0
  10. package/lib/adapters/lifecycle.js +94 -0
  11. package/lib/adapters/lifecycle.js.map +1 -0
  12. package/lib/adapters/rest/cache.d.ts +69 -0
  13. package/lib/adapters/rest/cache.js +133 -0
  14. package/lib/adapters/rest/cache.js.map +1 -0
  15. package/lib/adapters/rest/index.d.ts +11 -0
  16. package/lib/adapters/rest/index.js +18 -0
  17. package/lib/adapters/rest/index.js.map +1 -0
  18. package/lib/adapters/rest/profiling-rest-client.d.ts +137 -0
  19. package/lib/adapters/rest/profiling-rest-client.js +115 -0
  20. package/lib/adapters/rest/profiling-rest-client.js.map +1 -0
  21. package/lib/adapters/rest/rest-api-adapter.d.ts +393 -0
  22. package/lib/adapters/rest/rest-api-adapter.js +764 -0
  23. package/lib/adapters/rest/rest-api-adapter.js.map +1 -0
  24. package/lib/adapters/rest/types.d.ts +34 -0
  25. package/lib/adapters/rest/types.js +9 -0
  26. package/lib/adapters/rest/types.js.map +1 -0
  27. package/lib/adapters/retry.d.ts +91 -0
  28. package/lib/adapters/retry.js +215 -0
  29. package/lib/adapters/retry.js.map +1 -0
  30. package/lib/adapters/soql/cuneiform-query-builder.d.ts +418 -0
  31. package/lib/adapters/soql/cuneiform-query-builder.js +606 -0
  32. package/lib/adapters/soql/cuneiform-query-builder.js.map +1 -0
  33. package/lib/adapters/soql/soql-query-adapter.d.ts +141 -0
  34. package/lib/adapters/soql/soql-query-adapter.js +259 -0
  35. package/lib/adapters/soql/soql-query-adapter.js.map +1 -0
  36. package/lib/adapters/soql/types.d.ts +37 -0
  37. package/lib/adapters/soql/types.js +19 -0
  38. package/lib/adapters/soql/types.js.map +1 -0
  39. package/lib/adapters/testing/index.d.ts +37 -0
  40. package/lib/adapters/testing/index.js +20 -0
  41. package/lib/adapters/testing/index.js.map +1 -0
  42. package/lib/adapters/testing/mock-connection.d.ts +77 -0
  43. package/lib/adapters/testing/mock-connection.js +207 -0
  44. package/lib/adapters/testing/mock-connection.js.map +1 -0
  45. package/lib/adapters/testing/mock-logger.d.ts +29 -0
  46. package/lib/adapters/testing/mock-logger.js +57 -0
  47. package/lib/adapters/testing/mock-logger.js.map +1 -0
  48. package/lib/adapters/testing/mock-mcp-adapters.d.ts +32 -0
  49. package/lib/adapters/testing/mock-mcp-adapters.js +52 -0
  50. package/lib/adapters/testing/mock-mcp-adapters.js.map +1 -0
  51. package/lib/adapters/testing/mock-oclif-config.d.ts +22 -0
  52. package/lib/adapters/testing/mock-oclif-config.js +90 -0
  53. package/lib/adapters/testing/mock-oclif-config.js.map +1 -0
  54. package/lib/adapters/testing/mock-rest-adapter.d.ts +26 -0
  55. package/lib/adapters/testing/mock-rest-adapter.js +243 -0
  56. package/lib/adapters/testing/mock-rest-adapter.js.map +1 -0
  57. package/lib/adapters/testing/mock-salesforce-connection.d.ts +40 -0
  58. package/lib/adapters/testing/mock-salesforce-connection.js +61 -0
  59. package/lib/adapters/testing/mock-salesforce-connection.js.map +1 -0
  60. package/lib/adapters/testing/mock-soql-adapter.d.ts +30 -0
  61. package/lib/adapters/testing/mock-soql-adapter.js +120 -0
  62. package/lib/adapters/testing/mock-soql-adapter.js.map +1 -0
  63. package/lib/adapters/testing/mock-tooling-adapter.d.ts +24 -0
  64. package/lib/adapters/testing/mock-tooling-adapter.js +163 -0
  65. package/lib/adapters/testing/mock-tooling-adapter.js.map +1 -0
  66. package/lib/adapters/testing/stub-connection.d.ts +93 -0
  67. package/lib/adapters/testing/stub-connection.js +97 -0
  68. package/lib/adapters/testing/stub-connection.js.map +1 -0
  69. package/lib/adapters/testing/stub-rest-adapter.d.ts +52 -0
  70. package/lib/adapters/testing/stub-rest-adapter.js +58 -0
  71. package/lib/adapters/testing/stub-rest-adapter.js.map +1 -0
  72. package/lib/adapters/testing/stub-soql-adapter.d.ts +56 -0
  73. package/lib/adapters/testing/stub-soql-adapter.js +50 -0
  74. package/lib/adapters/testing/stub-soql-adapter.js.map +1 -0
  75. package/lib/adapters/testing/types.d.ts +71 -0
  76. package/lib/adapters/testing/types.js +9 -0
  77. package/lib/adapters/testing/types.js.map +1 -0
  78. package/lib/adapters/tooling/index.d.ts +10 -0
  79. package/lib/adapters/tooling/index.js +17 -0
  80. package/lib/adapters/tooling/index.js.map +1 -0
  81. package/lib/adapters/tooling/tooling-api-adapter.d.ts +157 -0
  82. package/lib/adapters/tooling/tooling-api-adapter.js +339 -0
  83. package/lib/adapters/tooling/tooling-api-adapter.js.map +1 -0
  84. package/lib/adapters/tooling/types.d.ts +81 -0
  85. package/lib/adapters/tooling/types.js +9 -0
  86. package/lib/adapters/tooling/types.js.map +1 -0
  87. package/lib/adapters/types.d.ts +112 -0
  88. package/lib/adapters/types.js +169 -0
  89. package/lib/adapters/types.js.map +1 -0
  90. package/lib/base/cuneiform-command.d.ts +175 -0
  91. package/lib/base/cuneiform-command.js +326 -0
  92. package/lib/base/cuneiform-command.js.map +1 -0
  93. package/lib/commands/cuneiform/compatibility/check.d.ts +43 -0
  94. package/lib/commands/cuneiform/compatibility/check.js +114 -0
  95. package/lib/commands/cuneiform/compatibility/check.js.map +1 -0
  96. package/lib/commands/cuneiform/definition/create.d.ts +120 -0
  97. package/lib/commands/cuneiform/definition/create.js +737 -0
  98. package/lib/commands/cuneiform/definition/create.js.map +1 -0
  99. package/lib/commands/cuneiform/definition/export.d.ts +57 -0
  100. package/lib/commands/cuneiform/definition/export.js +133 -0
  101. package/lib/commands/cuneiform/definition/export.js.map +1 -0
  102. package/lib/commands/cuneiform/definition/get.d.ts +86 -0
  103. package/lib/commands/cuneiform/definition/get.js +277 -0
  104. package/lib/commands/cuneiform/definition/get.js.map +1 -0
  105. package/lib/commands/cuneiform/definition/import.d.ts +54 -0
  106. package/lib/commands/cuneiform/definition/import.js +118 -0
  107. package/lib/commands/cuneiform/definition/import.js.map +1 -0
  108. package/lib/commands/cuneiform/definition/list.d.ts +110 -0
  109. package/lib/commands/cuneiform/definition/list.js +351 -0
  110. package/lib/commands/cuneiform/definition/list.js.map +1 -0
  111. package/lib/commands/cuneiform/definition/purge.d.ts +109 -0
  112. package/lib/commands/cuneiform/definition/purge.js +578 -0
  113. package/lib/commands/cuneiform/definition/purge.js.map +1 -0
  114. package/lib/commands/cuneiform/definition/update.d.ts +58 -0
  115. package/lib/commands/cuneiform/definition/update.js +209 -0
  116. package/lib/commands/cuneiform/definition/update.js.map +1 -0
  117. package/lib/commands/cuneiform/mcp/serve.d.ts +56 -0
  118. package/lib/commands/cuneiform/mcp/serve.js +109 -0
  119. package/lib/commands/cuneiform/mcp/serve.js.map +1 -0
  120. package/lib/commands/cuneiform/object/describe.d.ts +61 -0
  121. package/lib/commands/cuneiform/object/describe.js +461 -0
  122. package/lib/commands/cuneiform/object/describe.js.map +1 -0
  123. package/lib/commands/cuneiform/object/list.d.ts +123 -0
  124. package/lib/commands/cuneiform/object/list.js +264 -0
  125. package/lib/commands/cuneiform/object/list.js.map +1 -0
  126. package/lib/commands/cuneiform/org/details.d.ts +99 -0
  127. package/lib/commands/cuneiform/org/details.js +521 -0
  128. package/lib/commands/cuneiform/org/details.js.map +1 -0
  129. package/lib/commands/cuneiform/org/reset.d.ts +46 -0
  130. package/lib/commands/cuneiform/org/reset.js +135 -0
  131. package/lib/commands/cuneiform/org/reset.js.map +1 -0
  132. package/lib/commands/cuneiform/profile/request/cancel.d.ts +59 -0
  133. package/lib/commands/cuneiform/profile/request/cancel.js +202 -0
  134. package/lib/commands/cuneiform/profile/request/cancel.js.map +1 -0
  135. package/lib/commands/cuneiform/profile/request/delete.d.ts +59 -0
  136. package/lib/commands/cuneiform/profile/request/delete.js +223 -0
  137. package/lib/commands/cuneiform/profile/request/delete.js.map +1 -0
  138. package/lib/commands/cuneiform/profile/request/list.d.ts +35 -0
  139. package/lib/commands/cuneiform/profile/request/list.js +102 -0
  140. package/lib/commands/cuneiform/profile/request/list.js.map +1 -0
  141. package/lib/commands/cuneiform/profile.d.ts +93 -0
  142. package/lib/commands/cuneiform/profile.js +353 -0
  143. package/lib/commands/cuneiform/profile.js.map +1 -0
  144. package/lib/commands/cuneiform/summary/purge.d.ts +80 -0
  145. package/lib/commands/cuneiform/summary/purge.js +467 -0
  146. package/lib/commands/cuneiform/summary/purge.js.map +1 -0
  147. package/lib/commands/cuneiform/summary/reprofile.d.ts +60 -0
  148. package/lib/commands/cuneiform/summary/reprofile.js +236 -0
  149. package/lib/commands/cuneiform/summary/reprofile.js.map +1 -0
  150. package/lib/commands/cuneiform/summary/stop.d.ts +59 -0
  151. package/lib/commands/cuneiform/summary/stop.js +234 -0
  152. package/lib/commands/cuneiform/summary/stop.js.map +1 -0
  153. package/lib/commands/cuneiform/user/details.d.ts +77 -0
  154. package/lib/commands/cuneiform/user/details.js +414 -0
  155. package/lib/commands/cuneiform/user/details.js.map +1 -0
  156. package/lib/constants/namespace-constants.d.ts +102 -0
  157. package/lib/constants/namespace-constants.js +225 -0
  158. package/lib/constants/namespace-constants.js.map +1 -0
  159. package/lib/debug/command-debug-proxy.d.ts +101 -0
  160. package/lib/debug/command-debug-proxy.js +171 -0
  161. package/lib/debug/command-debug-proxy.js.map +1 -0
  162. package/lib/debug/debug-logger.d.ts +85 -0
  163. package/lib/debug/debug-logger.js +133 -0
  164. package/lib/debug/debug-logger.js.map +1 -0
  165. package/lib/debug/service-debug-proxy.d.ts +30 -0
  166. package/lib/debug/service-debug-proxy.js +102 -0
  167. package/lib/debug/service-debug-proxy.js.map +1 -0
  168. package/lib/hooks/prerun.d.ts +25 -0
  169. package/lib/hooks/prerun.js +47 -0
  170. package/lib/hooks/prerun.js.map +1 -0
  171. package/lib/mcp/config/mcp-config.d.ts +55 -0
  172. package/lib/mcp/config/mcp-config.js +51 -0
  173. package/lib/mcp/config/mcp-config.js.map +1 -0
  174. package/lib/mcp/config/pagination.d.ts +96 -0
  175. package/lib/mcp/config/pagination.js +108 -0
  176. package/lib/mcp/config/pagination.js.map +1 -0
  177. package/lib/mcp/config/system-prompts.d.ts +18 -0
  178. package/lib/mcp/config/system-prompts.js +92 -0
  179. package/lib/mcp/config/system-prompts.js.map +1 -0
  180. package/lib/mcp/errors.d.ts +23 -0
  181. package/lib/mcp/errors.js +27 -0
  182. package/lib/mcp/errors.js.map +1 -0
  183. package/lib/mcp/schemas/input-schemas.d.ts +327 -0
  184. package/lib/mcp/schemas/input-schemas.js +310 -0
  185. package/lib/mcp/schemas/input-schemas.js.map +1 -0
  186. package/lib/mcp/server.d.ts +40 -0
  187. package/lib/mcp/server.js +316 -0
  188. package/lib/mcp/server.js.map +1 -0
  189. package/lib/mcp/tools/contactpoint-tools.d.ts +14 -0
  190. package/lib/mcp/tools/contactpoint-tools.js +34 -0
  191. package/lib/mcp/tools/contactpoint-tools.js.map +1 -0
  192. package/lib/mcp/tools/definition-io-tools.d.ts +19 -0
  193. package/lib/mcp/tools/definition-io-tools.js +152 -0
  194. package/lib/mcp/tools/definition-io-tools.js.map +1 -0
  195. package/lib/mcp/tools/definition-tools.d.ts +51 -0
  196. package/lib/mcp/tools/definition-tools.js +220 -0
  197. package/lib/mcp/tools/definition-tools.js.map +1 -0
  198. package/lib/mcp/tools/index.d.ts +37 -0
  199. package/lib/mcp/tools/index.js +88 -0
  200. package/lib/mcp/tools/index.js.map +1 -0
  201. package/lib/mcp/tools/object-tools.d.ts +22 -0
  202. package/lib/mcp/tools/object-tools.js +327 -0
  203. package/lib/mcp/tools/object-tools.js.map +1 -0
  204. package/lib/mcp/tools/org-tools.d.ts +14 -0
  205. package/lib/mcp/tools/org-tools.js +177 -0
  206. package/lib/mcp/tools/org-tools.js.map +1 -0
  207. package/lib/mcp/tools/profile-tools.d.ts +59 -0
  208. package/lib/mcp/tools/profile-tools.js +213 -0
  209. package/lib/mcp/tools/profile-tools.js.map +1 -0
  210. package/lib/mcp/tools/summary-tools.d.ts +14 -0
  211. package/lib/mcp/tools/summary-tools.js +38 -0
  212. package/lib/mcp/tools/summary-tools.js.map +1 -0
  213. package/lib/mcp/tools/tool-factory.d.ts +63 -0
  214. package/lib/mcp/tools/tool-factory.js +146 -0
  215. package/lib/mcp/tools/tool-factory.js.map +1 -0
  216. package/lib/mcp/tools/user-tools.d.ts +25 -0
  217. package/lib/mcp/tools/user-tools.js +167 -0
  218. package/lib/mcp/tools/user-tools.js.map +1 -0
  219. package/lib/models/cascade-skip-accumulator.d.ts +25 -0
  220. package/lib/models/cascade-skip-accumulator.js +9 -0
  221. package/lib/models/cascade-skip-accumulator.js.map +1 -0
  222. package/lib/models/date-literal.d.ts +280 -0
  223. package/lib/models/date-literal.js +1164 -0
  224. package/lib/models/date-literal.js.map +1 -0
  225. package/lib/models/object-describe-types.d.ts +173 -0
  226. package/lib/models/object-describe-types.js +9 -0
  227. package/lib/models/object-describe-types.js.map +1 -0
  228. package/lib/models/portability-recipe.d.ts +35 -0
  229. package/lib/models/portability-recipe.js +113 -0
  230. package/lib/models/portability-recipe.js.map +1 -0
  231. package/lib/models/profile-request-types.d.ts +118 -0
  232. package/lib/models/profile-request-types.js +23 -0
  233. package/lib/models/profile-request-types.js.map +1 -0
  234. package/lib/models/profiling-execution-types.d.ts +154 -0
  235. package/lib/models/profiling-execution-types.js +14 -0
  236. package/lib/models/profiling-execution-types.js.map +1 -0
  237. package/lib/models/service-result.d.ts +114 -0
  238. package/lib/models/service-result.js +81 -0
  239. package/lib/models/service-result.js.map +1 -0
  240. package/lib/models/sfdmu-types.d.ts +49 -0
  241. package/lib/models/sfdmu-types.js +23 -0
  242. package/lib/models/sfdmu-types.js.map +1 -0
  243. package/lib/models/status-types.d.ts +38 -0
  244. package/lib/models/status-types.js +12 -0
  245. package/lib/models/status-types.js.map +1 -0
  246. package/lib/models/summary-bulk-types.d.ts +61 -0
  247. package/lib/models/summary-bulk-types.js +23 -0
  248. package/lib/models/summary-bulk-types.js.map +1 -0
  249. package/lib/models/user-details-types.d.ts +188 -0
  250. package/lib/models/user-details-types.js +9 -0
  251. package/lib/models/user-details-types.js.map +1 -0
  252. package/lib/models/year-range.d.ts +78 -0
  253. package/lib/models/year-range.js +153 -0
  254. package/lib/models/year-range.js.map +1 -0
  255. package/lib/operations/CompatibilityCheckOperation.d.ts +62 -0
  256. package/lib/operations/CompatibilityCheckOperation.js +102 -0
  257. package/lib/operations/CompatibilityCheckOperation.js.map +1 -0
  258. package/lib/operations/DefinitionCreateOperation.d.ts +427 -0
  259. package/lib/operations/DefinitionCreateOperation.js +1270 -0
  260. package/lib/operations/DefinitionCreateOperation.js.map +1 -0
  261. package/lib/operations/DefinitionExportOperation.d.ts +155 -0
  262. package/lib/operations/DefinitionExportOperation.js +281 -0
  263. package/lib/operations/DefinitionExportOperation.js.map +1 -0
  264. package/lib/operations/DefinitionImportOperation.d.ts +144 -0
  265. package/lib/operations/DefinitionImportOperation.js +357 -0
  266. package/lib/operations/DefinitionImportOperation.js.map +1 -0
  267. package/lib/operations/DefinitionListOperation.d.ts +66 -0
  268. package/lib/operations/DefinitionListOperation.js +108 -0
  269. package/lib/operations/DefinitionListOperation.js.map +1 -0
  270. package/lib/operations/DefinitionPurgeOperation.d.ts +203 -0
  271. package/lib/operations/DefinitionPurgeOperation.js +465 -0
  272. package/lib/operations/DefinitionPurgeOperation.js.map +1 -0
  273. package/lib/operations/DefinitionUpdateOperation.d.ts +78 -0
  274. package/lib/operations/DefinitionUpdateOperation.js +142 -0
  275. package/lib/operations/DefinitionUpdateOperation.js.map +1 -0
  276. package/lib/operations/OrgDetailsOperation.d.ts +253 -0
  277. package/lib/operations/OrgDetailsOperation.js +456 -0
  278. package/lib/operations/OrgDetailsOperation.js.map +1 -0
  279. package/lib/operations/OrgResetOperation.d.ts +114 -0
  280. package/lib/operations/OrgResetOperation.js +209 -0
  281. package/lib/operations/OrgResetOperation.js.map +1 -0
  282. package/lib/operations/ProfileOperation.d.ts +192 -0
  283. package/lib/operations/ProfileOperation.js +371 -0
  284. package/lib/operations/ProfileOperation.js.map +1 -0
  285. package/lib/operations/ProfileRequestCancelOperation.d.ts +59 -0
  286. package/lib/operations/ProfileRequestCancelOperation.js +137 -0
  287. package/lib/operations/ProfileRequestCancelOperation.js.map +1 -0
  288. package/lib/operations/ProfileRequestDeleteOperation.d.ts +64 -0
  289. package/lib/operations/ProfileRequestDeleteOperation.js +134 -0
  290. package/lib/operations/ProfileRequestDeleteOperation.js.map +1 -0
  291. package/lib/operations/ProfileRequestListOperation.d.ts +39 -0
  292. package/lib/operations/ProfileRequestListOperation.js +61 -0
  293. package/lib/operations/ProfileRequestListOperation.js.map +1 -0
  294. package/lib/operations/SummaryPurgeOperation.d.ts +134 -0
  295. package/lib/operations/SummaryPurgeOperation.js +257 -0
  296. package/lib/operations/SummaryPurgeOperation.js.map +1 -0
  297. package/lib/operations/SummaryReprofileOperation.d.ts +88 -0
  298. package/lib/operations/SummaryReprofileOperation.js +174 -0
  299. package/lib/operations/SummaryReprofileOperation.js.map +1 -0
  300. package/lib/operations/SummaryStopOperation.d.ts +87 -0
  301. package/lib/operations/SummaryStopOperation.js +175 -0
  302. package/lib/operations/SummaryStopOperation.js.map +1 -0
  303. package/lib/services/BulkExecutionService.d.ts +120 -0
  304. package/lib/services/BulkExecutionService.js +535 -0
  305. package/lib/services/BulkExecutionService.js.map +1 -0
  306. package/lib/services/CompatibilityService.d.ts +81 -0
  307. package/lib/services/CompatibilityService.js +118 -0
  308. package/lib/services/CompatibilityService.js.map +1 -0
  309. package/lib/services/ConfigureMode.d.ts +98 -0
  310. package/lib/services/ConfigureMode.js +413 -0
  311. package/lib/services/ConfigureMode.js.map +1 -0
  312. package/lib/services/ContactPointService.d.ts +111 -0
  313. package/lib/services/ContactPointService.js +286 -0
  314. package/lib/services/ContactPointService.js.map +1 -0
  315. package/lib/services/DataAvailabilityService.d.ts +81 -0
  316. package/lib/services/DataAvailabilityService.js +128 -0
  317. package/lib/services/DataAvailabilityService.js.map +1 -0
  318. package/lib/services/DefinitionFieldGenerationService.d.ts +357 -0
  319. package/lib/services/DefinitionFieldGenerationService.js +899 -0
  320. package/lib/services/DefinitionFieldGenerationService.js.map +1 -0
  321. package/lib/services/DefinitionQueryBuilder.d.ts +92 -0
  322. package/lib/services/DefinitionQueryBuilder.js +328 -0
  323. package/lib/services/DefinitionQueryBuilder.js.map +1 -0
  324. package/lib/services/ObjectDescribeService.d.ts +436 -0
  325. package/lib/services/ObjectDescribeService.js +881 -0
  326. package/lib/services/ObjectDescribeService.js.map +1 -0
  327. package/lib/services/ObjectFilteringService.d.ts +484 -0
  328. package/lib/services/ObjectFilteringService.js +1080 -0
  329. package/lib/services/ObjectFilteringService.js.map +1 -0
  330. package/lib/services/ObjectListCommandService.d.ts +467 -0
  331. package/lib/services/ObjectListCommandService.js +904 -0
  332. package/lib/services/ObjectListCommandService.js.map +1 -0
  333. package/lib/services/ObjectListService.d.ts +201 -0
  334. package/lib/services/ObjectListService.js +350 -0
  335. package/lib/services/ObjectListService.js.map +1 -0
  336. package/lib/services/OrgInfoService.d.ts +493 -0
  337. package/lib/services/OrgInfoService.js +1142 -0
  338. package/lib/services/OrgInfoService.js.map +1 -0
  339. package/lib/services/PollingService.d.ts +105 -0
  340. package/lib/services/PollingService.js +117 -0
  341. package/lib/services/PollingService.js.map +1 -0
  342. package/lib/services/ProfileRequestService.d.ts +186 -0
  343. package/lib/services/ProfileRequestService.js +555 -0
  344. package/lib/services/ProfileRequestService.js.map +1 -0
  345. package/lib/services/ProfilingDefinitionService.d.ts +575 -0
  346. package/lib/services/ProfilingDefinitionService.js +1029 -0
  347. package/lib/services/ProfilingDefinitionService.js.map +1 -0
  348. package/lib/services/ProfilingExecutionService.d.ts +122 -0
  349. package/lib/services/ProfilingExecutionService.js +320 -0
  350. package/lib/services/ProfilingExecutionService.js.map +1 -0
  351. package/lib/services/ProfilingSummaryService.d.ts +292 -0
  352. package/lib/services/ProfilingSummaryService.js +688 -0
  353. package/lib/services/ProfilingSummaryService.js.map +1 -0
  354. package/lib/services/RecordTypeService.d.ts +129 -0
  355. package/lib/services/RecordTypeService.js +284 -0
  356. package/lib/services/RecordTypeService.js.map +1 -0
  357. package/lib/services/SFDMUService.d.ts +146 -0
  358. package/lib/services/SFDMUService.js +323 -0
  359. package/lib/services/SFDMUService.js.map +1 -0
  360. package/lib/services/TabDetectionService.d.ts +105 -0
  361. package/lib/services/TabDetectionService.js +206 -0
  362. package/lib/services/TabDetectionService.js.map +1 -0
  363. package/lib/services/UnconfigureMode.d.ts +74 -0
  364. package/lib/services/UnconfigureMode.js +378 -0
  365. package/lib/services/UnconfigureMode.js.map +1 -0
  366. package/lib/services/UserConfigurationService.d.ts +158 -0
  367. package/lib/services/UserConfigurationService.js +574 -0
  368. package/lib/services/UserConfigurationService.js.map +1 -0
  369. package/lib/services/UserConfigurationTypes.d.ts +181 -0
  370. package/lib/services/UserConfigurationTypes.js +14 -0
  371. package/lib/services/UserConfigurationTypes.js.map +1 -0
  372. package/lib/services/UserReadinessService.d.ts +347 -0
  373. package/lib/services/UserReadinessService.js +891 -0
  374. package/lib/services/UserReadinessService.js.map +1 -0
  375. package/lib/services/constants.d.ts +54 -0
  376. package/lib/services/constants.js +71 -0
  377. package/lib/services/constants.js.map +1 -0
  378. package/lib/services/namespace-constants.d.ts +1 -0
  379. package/lib/services/namespace-constants.js +11 -0
  380. package/lib/services/namespace-constants.js.map +1 -0
  381. package/lib/services/namespace-filter.d.ts +36 -0
  382. package/lib/services/namespace-filter.js +109 -0
  383. package/lib/services/namespace-filter.js.map +1 -0
  384. package/lib/services/validation.d.ts +47 -0
  385. package/lib/services/validation.js +119 -0
  386. package/lib/services/validation.js.map +1 -0
  387. package/lib/utils/batch-processor.d.ts +13 -0
  388. package/lib/utils/batch-processor.js +39 -0
  389. package/lib/utils/batch-processor.js.map +1 -0
  390. package/lib/utils/formatting/availability-grid.d.ts +81 -0
  391. package/lib/utils/formatting/availability-grid.js +94 -0
  392. package/lib/utils/formatting/availability-grid.js.map +1 -0
  393. package/lib/utils/formatting/business-process-grid.d.ts +51 -0
  394. package/lib/utils/formatting/business-process-grid.js +58 -0
  395. package/lib/utils/formatting/business-process-grid.js.map +1 -0
  396. package/lib/utils/formatting/command-display.d.ts +154 -0
  397. package/lib/utils/formatting/command-display.js +154 -0
  398. package/lib/utils/formatting/command-display.js.map +1 -0
  399. package/lib/utils/formatting/definition-create-display.d.ts +118 -0
  400. package/lib/utils/formatting/definition-create-display.js +230 -0
  401. package/lib/utils/formatting/definition-create-display.js.map +1 -0
  402. package/lib/utils/formatting/empty-states.d.ts +35 -0
  403. package/lib/utils/formatting/empty-states.js +70 -0
  404. package/lib/utils/formatting/empty-states.js.map +1 -0
  405. package/lib/utils/formatting/errors.d.ts +33 -0
  406. package/lib/utils/formatting/errors.js +72 -0
  407. package/lib/utils/formatting/errors.js.map +1 -0
  408. package/lib/utils/formatting/field-types.d.ts +32 -0
  409. package/lib/utils/formatting/field-types.js +88 -0
  410. package/lib/utils/formatting/field-types.js.map +1 -0
  411. package/lib/utils/formatting/index.d.ts +29 -0
  412. package/lib/utils/formatting/index.js +28 -0
  413. package/lib/utils/formatting/index.js.map +1 -0
  414. package/lib/utils/formatting/indicators.d.ts +113 -0
  415. package/lib/utils/formatting/indicators.js +161 -0
  416. package/lib/utils/formatting/indicators.js.map +1 -0
  417. package/lib/utils/formatting/loading-messages.d.ts +37 -0
  418. package/lib/utils/formatting/loading-messages.js +50 -0
  419. package/lib/utils/formatting/loading-messages.js.map +1 -0
  420. package/lib/utils/formatting/namespace-display.d.ts +31 -0
  421. package/lib/utils/formatting/namespace-display.js +64 -0
  422. package/lib/utils/formatting/namespace-display.js.map +1 -0
  423. package/lib/utils/formatting/numbers.d.ts +73 -0
  424. package/lib/utils/formatting/numbers.js +187 -0
  425. package/lib/utils/formatting/numbers.js.map +1 -0
  426. package/lib/utils/formatting/object-describe-display.d.ts +117 -0
  427. package/lib/utils/formatting/object-describe-display.js +447 -0
  428. package/lib/utils/formatting/object-describe-display.js.map +1 -0
  429. package/lib/utils/formatting/object-list-display.d.ts +225 -0
  430. package/lib/utils/formatting/object-list-display.js +718 -0
  431. package/lib/utils/formatting/object-list-display.js.map +1 -0
  432. package/lib/utils/formatting/org-identity.d.ts +15 -0
  433. package/lib/utils/formatting/org-identity.js +28 -0
  434. package/lib/utils/formatting/org-identity.js.map +1 -0
  435. package/lib/utils/formatting/record-age-grid.d.ts +41 -0
  436. package/lib/utils/formatting/record-age-grid.js +56 -0
  437. package/lib/utils/formatting/record-age-grid.js.map +1 -0
  438. package/lib/utils/formatting/sections.d.ts +108 -0
  439. package/lib/utils/formatting/sections.js +150 -0
  440. package/lib/utils/formatting/sections.js.map +1 -0
  441. package/lib/utils/formatting/tables.d.ts +90 -0
  442. package/lib/utils/formatting/tables.js +113 -0
  443. package/lib/utils/formatting/tables.js.map +1 -0
  444. package/lib/utils/formatting/user-details-display.d.ts +101 -0
  445. package/lib/utils/formatting/user-details-display.js +425 -0
  446. package/lib/utils/formatting/user-details-display.js.map +1 -0
  447. package/lib/utils/pagination/keypress-reader.d.ts +20 -0
  448. package/lib/utils/pagination/keypress-reader.js +63 -0
  449. package/lib/utils/pagination/keypress-reader.js.map +1 -0
  450. package/lib/utils/pagination/paginate-output.d.ts +48 -0
  451. package/lib/utils/pagination/paginate-output.js +136 -0
  452. package/lib/utils/pagination/paginate-output.js.map +1 -0
  453. package/messages/compatibility.check.md +71 -0
  454. package/messages/cuneiform.access.md +138 -0
  455. package/messages/definition.create.md +525 -0
  456. package/messages/definition.export.md +84 -0
  457. package/messages/definition.get.md +147 -0
  458. package/messages/definition.import.md +65 -0
  459. package/messages/definition.list.md +264 -0
  460. package/messages/definition.purge.md +330 -0
  461. package/messages/definition.update.md +118 -0
  462. package/messages/mcp.serve.md +66 -0
  463. package/messages/object.describe.md +205 -0
  464. package/messages/object.list.md +463 -0
  465. package/messages/org.details.md +386 -0
  466. package/messages/org.reset.md +71 -0
  467. package/messages/profile.md +243 -0
  468. package/messages/profile.request.cancel.md +143 -0
  469. package/messages/profile.request.delete.md +139 -0
  470. package/messages/profile.request.list.md +89 -0
  471. package/messages/summary.purge.md +218 -0
  472. package/messages/summary.reprofile.md +150 -0
  473. package/messages/summary.stop.md +157 -0
  474. package/messages/user.details.md +501 -0
  475. package/oclif.lock +3267 -2148
  476. package/oclif.manifest.json +2829 -31
  477. package/package.json +104 -18
  478. package/lib/commands/cuneiform/about.d.ts +0 -13
  479. package/lib/commands/cuneiform/about.js +0 -26
  480. package/lib/commands/cuneiform/about.js.map +0 -1
  481. package/lib/commands/hello/world.d.ts +0 -14
  482. package/lib/commands/hello/world.js +0 -27
  483. package/lib/commands/hello/world.js.map +0 -1
  484. package/lib/index.d.ts +0 -2
  485. package/lib/index.js +0 -2
  486. package/lib/index.js.map +0 -1
  487. package/messages/cuneiform.about.md +0 -19
  488. package/messages/hello.world.md +0 -29
@@ -0,0 +1,737 @@
1
+ /*
2
+ * Copyright (c) 2026, PeerNova, Inc. All Rights Reserved.
3
+ * PROPRIETARY AND CONFIDENTIAL. Unauthorized copying, modification,
4
+ * or distribution is strictly prohibited. Use is governed by the
5
+ * Master Subscription Agreement (MSA) between PeerNova, Inc. and the
6
+ * licensee. See LICENSE file in the repo root.
7
+ */
8
+ import { execFile } from 'node:child_process';
9
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
10
+ import { join } from 'node:path';
11
+ import { Flags } from '@salesforce/sf-plugins-core';
12
+ import { Messages } from '@salesforce/core';
13
+ import { CuneiformCommand } from '../../../base/cuneiform-command.js';
14
+ import { ProfilingDefinitionService } from '../../../services/ProfilingDefinitionService.js';
15
+ import { ProfilingExecutionService } from '../../../services/ProfilingExecutionService.js';
16
+ import { ProfilingSummaryService } from '../../../services/ProfilingSummaryService.js';
17
+ import { RecordTypeService } from '../../../services/RecordTypeService.js';
18
+ import { ObjectFilteringService } from '../../../services/ObjectFilteringService.js';
19
+ import { OrgInfoService } from '../../../services/OrgInfoService.js';
20
+ import { DefinitionCreateOperation, } from '../../../operations/DefinitionCreateOperation.js';
21
+ import { DataAvailabilityService } from '../../../services/DataAvailabilityService.js';
22
+ import { ProfilingRestClient } from '../../../adapters/rest/profiling-rest-client.js';
23
+ import { parseNamespaceFilter } from '../../../services/namespace-filter.js';
24
+ import { parsePortabilityRecipe } from '../../../models/portability-recipe.js';
25
+ import { renderSummaryBox } from '../../../utils/formatting/command-display.js';
26
+ import { resolveYearRange } from '../../../models/year-range.js';
27
+ import { validateDateLiteral, resolveDateLiteralRange } from '../../../models/date-literal.js';
28
+ import { displayOrgContext, displayResultsTables, resolveOperationFailure, buildPreConfirmSummary, } from '../../../utils/formatting/definition-create-display.js';
29
+ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
30
+ const messages = Messages.loadMessages('@peernova/cuneiform-sf', 'definition.create');
31
+ /**
32
+ * Creates profiling definitions for Salesforce objects.
33
+ */
34
+ // eslint-disable-next-line sf-plugin/only-extend-SfCommand -- CuneiformCommand extends SfCommand with shared access gate logic
35
+ export default class DefinitionCreate extends CuneiformCommand {
36
+ static summary = messages.getMessage('summary');
37
+ static description = messages.getMessage('description');
38
+ static examples = messages.getMessages('examples');
39
+ // eslint-disable-next-line sf-plugin/spread-base-flags -- CuneiformCommand has no additional flags to spread
40
+ static flags = {
41
+ 'target-org': Flags.requiredOrg({
42
+ summary: messages.getMessage('flags.target-org.summary'),
43
+ char: 'o',
44
+ required: true,
45
+ }),
46
+ 'api-version': Flags.orgApiVersion(),
47
+ objects: Flags.string({
48
+ summary: messages.getMessage('flags.objects.summary'),
49
+ char: 'b',
50
+ multiple: true,
51
+ }),
52
+ 'from-file': Flags.file({
53
+ summary: messages.getMessage('flags.from-file.summary'),
54
+ exists: true,
55
+ }),
56
+ filter: Flags.option({
57
+ summary: messages.getMessage('flags.filter.summary'),
58
+ char: 'f',
59
+ options: ['all', 'standard', 'custom'],
60
+ default: 'all',
61
+ })(),
62
+ pattern: Flags.string({
63
+ summary: messages.getMessage('flags.pattern.summary'),
64
+ char: 'p',
65
+ }),
66
+ namespace: Flags.string({
67
+ summary: messages.getMessage('flags.namespace.summary'),
68
+ char: 'n',
69
+ }),
70
+ classification: Flags.option({
71
+ summary: messages.getMessage('flags.classification.summary'),
72
+ options: ['customer', 'internal', 'all'],
73
+ default: 'customer',
74
+ })(),
75
+ 'with-records': Flags.boolean({
76
+ summary: messages.getMessage('flags.with-records.summary'),
77
+ }),
78
+ 'without-records': Flags.boolean({
79
+ summary: messages.getMessage('flags.without-records.summary'),
80
+ }),
81
+ 'with-record-types': Flags.boolean({
82
+ summary: messages.getMessage('flags.with-record-types.summary'),
83
+ }),
84
+ category: Flags.string({
85
+ summary: messages.getMessage('flags.category.summary'),
86
+ char: 'c',
87
+ }),
88
+ 'min-records': Flags.integer({
89
+ summary: messages.getMessage('flags.min-records.summary'),
90
+ min: 0,
91
+ default: 0,
92
+ }),
93
+ limit: Flags.integer({
94
+ summary: messages.getMessage('flags.limit.summary'),
95
+ char: 'l',
96
+ min: 1,
97
+ default: 100,
98
+ }),
99
+ method: Flags.option({
100
+ summary: messages.getMessage('flags.method.summary'),
101
+ char: 't',
102
+ options: ['metadata', 'historical', 'comparative', 'recordtype', 'outcome', 'full'],
103
+ default: 'full',
104
+ })(),
105
+ recordtype: Flags.string({
106
+ summary: messages.getMessage('flags.recordtype.summary'),
107
+ }),
108
+ 'record-type-status': Flags.option({
109
+ summary: messages.getMessage('flags.record-type-status.summary'),
110
+ options: ['active', 'all', 'inactive'],
111
+ default: 'active',
112
+ })(),
113
+ // eslint-disable-next-line sf-plugin/flag-min-max-default -- year defaults to current year at runtime when method requires it
114
+ year: Flags.integer({
115
+ summary: messages.getMessage('flags.year.summary'),
116
+ min: 2000,
117
+ max: 2050,
118
+ }),
119
+ // eslint-disable-next-line sf-plugin/flag-min-max-default -- depth defaults vary by method at runtime
120
+ depth: Flags.integer({
121
+ summary: messages.getMessage('flags.depth.summary'),
122
+ min: 1,
123
+ max: 10,
124
+ }),
125
+ // eslint-disable-next-line sf-plugin/flag-min-max-default -- from defaults to MIN_YEAR at runtime when to is specified
126
+ from: Flags.integer({
127
+ summary: messages.getMessage('flags.from.summary'),
128
+ min: 2000,
129
+ max: 2050,
130
+ }),
131
+ // eslint-disable-next-line sf-plugin/flag-min-max-default -- to defaults to current year at runtime when from is specified
132
+ to: Flags.integer({
133
+ summary: messages.getMessage('flags.to.summary'),
134
+ min: 2000,
135
+ max: 2050,
136
+ }),
137
+ 'no-value-frequency': Flags.boolean({
138
+ summary: messages.getMessage('flags.no-value-frequency.summary'),
139
+ }),
140
+ 'use-prior': Flags.boolean({
141
+ summary: messages.getMessage('flags.use-prior.summary'),
142
+ }),
143
+ 'lifetime-primary': Flags.boolean({
144
+ summary: messages.getMessage('flags.lifetime-primary.summary'),
145
+ }),
146
+ 'date-literal': Flags.string({
147
+ summary: messages.getMessage('flags.date-literal.summary'),
148
+ }),
149
+ 'date-field': Flags.string({
150
+ summary: messages.getMessage('flags.date-field.summary'),
151
+ default: 'CreatedDate',
152
+ }),
153
+ profiled: Flags.boolean({
154
+ summary: messages.getMessage('flags.profiled.summary'),
155
+ }),
156
+ 'dry-run': Flags.boolean({
157
+ summary: messages.getMessage('flags.dry-run.summary'),
158
+ char: 'd',
159
+ default: false,
160
+ }),
161
+ 'no-prompt': Flags.boolean({
162
+ summary: messages.getMessage('flags.no-prompt.summary'),
163
+ default: false,
164
+ }),
165
+ profile: Flags.boolean({
166
+ summary: messages.getMessage('flags.profile.summary'),
167
+ }),
168
+ open: Flags.boolean({
169
+ summary: messages.getMessage('flags.open.summary'),
170
+ }),
171
+ logs: Flags.boolean({
172
+ summary: messages.getMessage('flags.logs.summary'),
173
+ }),
174
+ 'name-prefix': Flags.string({
175
+ summary: messages.getMessage('flags.name-prefix.summary'),
176
+ }),
177
+ 'name-suffix': Flags.string({
178
+ summary: messages.getMessage('flags.name-suffix.summary'),
179
+ }),
180
+ 'time-category': Flags.string({
181
+ summary: messages.getMessage('flags.time-category.summary'),
182
+ }),
183
+ 'segment-category': Flags.string({
184
+ summary: messages.getMessage('flags.segment-category.summary'),
185
+ }),
186
+ origin: Flags.string({
187
+ summary: messages.getMessage('flags.origin.summary'),
188
+ default: 'Created via the Cuneiform for Salesforce CLI.',
189
+ }),
190
+ };
191
+ /**
192
+ * Determines the effective --with-records value.
193
+ *
194
+ * When --method full is used and no explicit scope/filter flags are supplied by the user,
195
+ * defaults withRecords to true so the default scope is "customer objects with records."
196
+ * This prevents full profiling from targeting empty or system-only objects.
197
+ *
198
+ * Scope flags that suppress the default: --with-records, --without-records, --filter (non-default),
199
+ * --objects, --pattern.
200
+ */
201
+ static resolveWithRecords(method, withRecordsFlag, withoutRecordsFlag, objects, pattern, filter) {
202
+ if (method !== 'full')
203
+ return withRecordsFlag;
204
+ // If user explicitly supplied any scope-narrowing flags, respect their intent.
205
+ if (withRecordsFlag !== undefined || withoutRecordsFlag !== undefined)
206
+ return withRecordsFlag;
207
+ if (objects !== undefined && objects.length > 0)
208
+ return withRecordsFlag;
209
+ if (pattern !== undefined)
210
+ return withRecordsFlag;
211
+ if (filter !== 'all')
212
+ return withRecordsFlag;
213
+ // No explicit scope flags for --method full: default to withRecords=true
214
+ return true;
215
+ }
216
+ /**
217
+ * Executes the create command.
218
+ *
219
+ * @returns DefinitionCreateResult with success status and creation statistics
220
+ */
221
+ // eslint-disable-next-line complexity -- multi-flag validation, service wiring, and result mapping are inherently sequential
222
+ async run() {
223
+ const { flags } = await this.parse(DefinitionCreate);
224
+ const targetOrg = flags['target-org'].getUsername();
225
+ if (!targetOrg) {
226
+ this.error(messages.getMessage('errors.noTargetOrg'));
227
+ }
228
+ const dryRun = flags['dry-run'];
229
+ // CLI-4215 (REQ-002 / GAP.02): --from-file supplies a portability recipe (objects + run-level
230
+ // parameters) as bulk input. It is mutually exclusive with --objects/--pattern; when present it
231
+ // drives object selection, method, category, and the naming suffix, and enables
232
+ // portabilityNaming so names render as `${objectLabel} • ${nameSuffix}`.
233
+ let recipe;
234
+ const fromFile = flags['from-file'];
235
+ if (fromFile !== undefined) {
236
+ const hasObjectsFlag = flags.objects !== undefined && flags.objects.length > 0;
237
+ if (hasObjectsFlag || flags.pattern !== undefined) {
238
+ this.error(messages.getMessage('errors.fromFileMutualExclusion'));
239
+ }
240
+ const parsedRecipe = parsePortabilityRecipe(await readFile(fromFile, 'utf8'));
241
+ if (parsedRecipe.error !== undefined) {
242
+ this.error(parsedRecipe.error, { code: 'INVALID_RECIPE' });
243
+ }
244
+ recipe = parsedRecipe.value;
245
+ }
246
+ // Portability recipes default to metadata (one definition per object) — never the --method
247
+ // flag default ('full'), which would fan out colliding names (CLI-4215 H2).
248
+ const method = recipe ? recipe.method ?? 'metadata' : flags.method;
249
+ const parsedObjects = recipe
250
+ ? recipe.objects
251
+ : DefinitionCreate.parseMultiValueFlag(flags.objects, { caseInsensitive: true });
252
+ // Validate --with-records and --without-records mutual exclusion
253
+ if (flags['with-records'] && flags['without-records']) {
254
+ this.error(messages.getMessage('errors.mutuallyExclusiveRecordFlags'));
255
+ }
256
+ // Validate --min-records and --without-records mutual exclusion (CLI-1265)
257
+ if (flags['min-records'] > 0 && flags['without-records']) {
258
+ this.error(messages.getMessage('errors.minRecordsWithoutRecords'));
259
+ }
260
+ // Validate --recordtype requires a method that supports record type scoping
261
+ if (flags.recordtype && method === 'metadata') {
262
+ this.error(messages.getMessage('errors.recordtypeMethodRequired'));
263
+ }
264
+ // Validate --profiled mutual exclusion with --method metadata
265
+ if (flags.profiled && method === 'metadata') {
266
+ this.error(messages.getMessage('errors.profiledWithMetadata'));
267
+ }
268
+ // Validate --date-literal mutual exclusion with year-based flags
269
+ // Note: --depth is allowed with --date-literal (controls cascade depth)
270
+ const hasDateLiteral = flags['date-literal'] !== undefined;
271
+ const hasYearFlags = flags.year !== undefined || flags.from !== undefined || flags.to !== undefined;
272
+ if (hasDateLiteral && (hasYearFlags || flags['use-prior'])) {
273
+ this.error(messages.getMessage('errors.dateLiteralMutualExclusion'));
274
+ }
275
+ // Validate --lifetime-primary contract (CLI-2944)
276
+ // AC5: only valid with --method comparative.
277
+ // AC4: mutually exclusive with --use-prior.
278
+ // AC5a: mutually exclusive with --depth (no cascade for the lifetime-vs-X variant).
279
+ // AC3: requires a secondary filter (--date-literal, --year, or --from/--to).
280
+ if (flags['lifetime-primary']) {
281
+ if (method !== 'comparative') {
282
+ this.error(messages.getMessage('errors.lifetimePrimaryMethodRequired'));
283
+ }
284
+ if (flags['use-prior']) {
285
+ this.error(messages.getMessage('errors.lifetimePrimaryUsePriorMutualExclusion'));
286
+ }
287
+ if (flags.depth !== undefined) {
288
+ this.error(messages.getMessage('errors.lifetimePrimaryDepthMutualExclusion'));
289
+ }
290
+ if (!hasDateLiteral && !hasYearFlags) {
291
+ this.error(messages.getMessage('errors.lifetimePrimaryRequiresSecondaryFilter'));
292
+ }
293
+ }
294
+ // Resolve date literal range (when --date-literal is used)
295
+ let dateLiteralRange;
296
+ if (hasDateLiteral) {
297
+ const validationError = validateDateLiteral(flags['date-literal']);
298
+ if (validationError) {
299
+ this.error(validationError);
300
+ }
301
+ try {
302
+ dateLiteralRange = resolveDateLiteralRange({
303
+ dateLiteral: flags['date-literal'],
304
+ depth: flags.depth,
305
+ dateField: flags['date-field'],
306
+ });
307
+ }
308
+ catch (err) {
309
+ this.error(err.message);
310
+ }
311
+ }
312
+ // Warn when year-related flags are used with metadata (no time dimension)
313
+ if (hasYearFlags && method === 'metadata') {
314
+ this.warn(messages.getMessage('warnings.yearIgnored'));
315
+ }
316
+ // Resolve year range with method-aware defaults (skipped when using date literals)
317
+ let yearRange;
318
+ if (dateLiteralRange) {
319
+ // Date literal mode: year range is empty (date literals replace year-based scoping)
320
+ yearRange = { entries: [] };
321
+ }
322
+ else {
323
+ try {
324
+ yearRange = resolveYearRange({
325
+ year: flags.year,
326
+ depth: flags.depth,
327
+ from: flags.from,
328
+ to: flags.to,
329
+ usePrior: flags['use-prior'],
330
+ method,
331
+ });
332
+ }
333
+ catch (err) {
334
+ this.error(messages.getMessage('errors.yearRangeInvalid', [err.message]));
335
+ }
336
+ }
337
+ // Extract single year for backward compatibility with operation layer
338
+ const year = yearRange.entries.length > 0 ? yearRange.entries[0].year : undefined;
339
+ // Resolve withRecords default for --method full
340
+ const withRecords = DefinitionCreate.resolveWithRecords(method, flags['with-records'], flags['without-records'], parsedObjects, flags.pattern, flags.filter);
341
+ // Parse --namespace at the command boundary into the typed NamespaceFilter
342
+ // discriminated union consumed by operation/service/adapter layers (CLI-3801).
343
+ const namespaceResult = parseNamespaceFilter(flags.namespace);
344
+ if (namespaceResult.error) {
345
+ this.error(messages.getMessage('errors.invalidNamespace', [namespaceResult.error]), {
346
+ code: 'INVALID_NAMESPACE',
347
+ });
348
+ }
349
+ // Initialize services
350
+ const { facade, soqlAdapter, restAdapter } = await this.initConnection(flags);
351
+ const definitionService = new ProfilingDefinitionService({ soqlAdapter, restAdapter });
352
+ const filteringService = new ObjectFilteringService({ restApiAdapter: restAdapter, soqlAdapter });
353
+ const profilingSummaryService = flags.profiled ? new ProfilingSummaryService({ soqlAdapter }) : undefined;
354
+ const recordTypeService = method === 'recordtype' || method === 'full' ? new RecordTypeService({ soqlAdapter }) : undefined;
355
+ const dataAvailabilityService = yearRange.entries.length > 0 ? new DataAvailabilityService({ soqlAdapter }) : undefined;
356
+ // REST client enables server-side definition creation (naming, categorization, dedup)
357
+ // When available, steps 3-7 of the pipeline delegate to the ISV REST API
358
+ const restClient = new ProfilingRestClient(restAdapter);
359
+ const operation = new DefinitionCreateOperation(definitionService, filteringService, undefined, profilingSummaryService, recordTypeService, dataAvailabilityService, restClient);
360
+ // Fetch org identity
361
+ this.spinner.start(messages.getMessage('spinner.connecting'));
362
+ const orgInfoService = new OrgInfoService({ connectionFacade: facade, soqlAdapter, restAdapter });
363
+ const orgIdentityResult = await orgInfoService.getOrgIdentity();
364
+ this.spinner.stop();
365
+ if (orgIdentityResult.success) {
366
+ displayOrgContext(this.log.bind(this), orgIdentityResult.data, facade.instanceUrl);
367
+ }
368
+ // Collect callback results for post-execution rendering
369
+ const callbackResults = [];
370
+ let hasObjectWarnings = false;
371
+ const previewState = {
372
+ recordCounts: new Map(),
373
+ objectLabels: new Map(),
374
+ };
375
+ // Build operation options
376
+ const operationOptions = {
377
+ targetOrg,
378
+ objects: parsedObjects,
379
+ pattern: flags.pattern,
380
+ filter: flags.filter,
381
+ namespace: namespaceResult.value,
382
+ classification: flags.classification,
383
+ withRecords,
384
+ withoutRecords: flags['without-records'],
385
+ withRecordTypes: flags['with-record-types'],
386
+ method,
387
+ recordType: flags.recordtype,
388
+ recordTypeStatus: flags['record-type-status'],
389
+ category: recipe?.category ?? flags.category,
390
+ minRecords: flags['min-records'],
391
+ limit: flags.limit,
392
+ // CLI-3402: --depth propagates the current-year default into options.year so the
393
+ // ISV's historicalWithYear gate fires for the depth-only cascade (per documented
394
+ // --depth contract: "When no anchor year is specified, defaults to the current year").
395
+ // Kept here instead of folding into hasYearFlags because hasYearFlags also drives the
396
+ // --date-literal mutual-exclusion check at line 306 where --depth IS intentionally allowed.
397
+ year: hasYearFlags || flags.depth !== undefined ? year : undefined,
398
+ yearRange,
399
+ noValueFrequency: flags['no-value-frequency'],
400
+ usePrior: flags['use-prior'],
401
+ lifetimePrimary: flags['lifetime-primary'],
402
+ dateLiteralRange,
403
+ profiled: flags.profiled,
404
+ namePrefix: flags['name-prefix'],
405
+ nameSuffix: recipe?.nameSuffix ?? flags['name-suffix'],
406
+ portabilityNaming: recipe !== undefined,
407
+ timeCategory: flags['time-category'],
408
+ segmentCategory: flags['segment-category'],
409
+ origin: flags.origin,
410
+ dryRun,
411
+ noPrompt: flags['no-prompt'],
412
+ // Precedence: dryRun (operation skips callback) > --json (auto-confirm) > --no-prompt (auto-confirm) > interactive prompt
413
+ onPreviewReady: async (preview) => this.handlePreviewReady(preview, method, flags['no-prompt'], previewState, callbackResults),
414
+ onProgress: (message) => {
415
+ if (message.startsWith('Object not found:')) {
416
+ // Surface "not found" warnings immediately to the user
417
+ const objectName = message.replace('Object not found: ', '');
418
+ this.spinner.stop();
419
+ this.warn(messages.getMessage('warnings.objectNotVerified', [objectName]));
420
+ this.log('');
421
+ hasObjectWarnings = true;
422
+ return;
423
+ }
424
+ else if (message.includes('definitions to create') || message.includes('definition to create')) {
425
+ // Phase 1 complete — stop spinner, preview table will render next
426
+ this.spinner.stop();
427
+ }
428
+ else if (message.startsWith('Complete:')) {
429
+ // Skip the final summary message — the table renders the results
430
+ return;
431
+ }
432
+ else {
433
+ this.spinner.status = message;
434
+ }
435
+ },
436
+ onObjectComplete: (objResult) => {
437
+ callbackResults.push({
438
+ objectName: objResult.objectName,
439
+ objectLabel: previewState.objectLabels.get(objResult.objectName),
440
+ status: objResult.status,
441
+ type: objResult.type,
442
+ definitionKey: objResult.definitionKey,
443
+ category: objResult.category,
444
+ timeCategory: objResult.timeCategory,
445
+ segmentCategory: objResult.segmentCategory,
446
+ fieldCount: objResult.fieldCount,
447
+ });
448
+ // Update spinner with running progress counts
449
+ const counts = { created: 0, skipped: 0, failed: 0 };
450
+ for (const r of callbackResults) {
451
+ if (r.status === 'success')
452
+ counts.created++;
453
+ else if (r.status === 'skip')
454
+ counts.skipped++;
455
+ else if (r.status === 'fail')
456
+ counts.failed++;
457
+ }
458
+ const parts = [`${objResult.current}/${objResult.total}`];
459
+ if (counts.created > 0)
460
+ parts.push(`${counts.created} ${messages.getMessage('spinner.status.created')}`);
461
+ if (counts.skipped > 0)
462
+ parts.push(`${counts.skipped} ${messages.getMessage('spinner.status.skipped')}`);
463
+ if (counts.failed > 0)
464
+ parts.push(`${counts.failed} ${messages.getMessage('spinner.status.failed')}`);
465
+ this.spinner.status = parts.join(', ');
466
+ },
467
+ };
468
+ // Execute operation
469
+ this.log('');
470
+ this.spinner.start(messages.getMessage('spinner.validatingObjects'));
471
+ const result = await operation.execute(operationOptions);
472
+ if (hasObjectWarnings) {
473
+ // Spinner was already stopped by the warning handler; suppress duplicate output
474
+ try {
475
+ this.spinner.stop('');
476
+ }
477
+ catch {
478
+ /* already stopped */
479
+ }
480
+ }
481
+ else {
482
+ this.spinner.stop();
483
+ }
484
+ // Handle failure
485
+ if (!result.success) {
486
+ return this.handleOperationFailure(result, targetOrg, dryRun);
487
+ }
488
+ const data = result.data;
489
+ // Handle cancellation
490
+ if (data.cancelled) {
491
+ this.log('');
492
+ this.log(messages.getMessage('output.cancelled'));
493
+ return {
494
+ success: true,
495
+ created: 0,
496
+ failed: 0,
497
+ skipped: data.skipped,
498
+ total: data.total,
499
+ dryRun,
500
+ failures: [],
501
+ results: [],
502
+ };
503
+ }
504
+ // Display results tables (suppress in JSON mode — printTable writes directly to stdout)
505
+ if (!this.jsonEnabled()) {
506
+ displayResultsTables(this.log.bind(this), this.warn.bind(this), callbackResults, data, dryRun, data.recordCounts ?? previewState.recordCounts);
507
+ }
508
+ // Display warnings if any (skip "Object not found" warnings already shown inline)
509
+ const remainingWarnings = (result.warnings ?? []).filter((w) => !w.startsWith('Object not found:'));
510
+ if (remainingWarnings.length > 0) {
511
+ this.log('');
512
+ for (const warning of remainingWarnings) {
513
+ this.warn(warning);
514
+ }
515
+ }
516
+ // Post-creation actions
517
+ await this.handlePostCreationActions(flags, data, dryRun, facade, soqlAdapter, restAdapter, facade.instanceUrl ?? '');
518
+ if (data.failed > 0) {
519
+ process.exitCode = 1;
520
+ }
521
+ return {
522
+ success: true,
523
+ created: data.created,
524
+ failed: data.failed,
525
+ skipped: data.skipped,
526
+ total: data.total,
527
+ dryRun,
528
+ failures: data.failures,
529
+ results: data.results,
530
+ availabilityGrid: data.availabilityGrid,
531
+ };
532
+ }
533
+ /**
534
+ * Two-stage confirmation: summary then detailed preview table.
535
+ */
536
+ async handlePreviewReady(preview, method, noPrompt, previewState, callbackResults) {
537
+ this.spinner.stop();
538
+ // eslint-disable-next-line no-param-reassign -- intentional state mutation for preview callback
539
+ previewState.recordCounts = preview.recordCounts;
540
+ for (const input of [...preview.toCreate, ...preview.toSkip]) {
541
+ if (input.objectLabel)
542
+ previewState.objectLabels.set(input.objectName, input.objectLabel);
543
+ }
544
+ // Stage 1: Summary
545
+ const uniqueObjects = new Set([
546
+ ...preview.toCreate.map((i) => i.objectName),
547
+ ...preview.toSkip.map((i) => i.objectName),
548
+ ]).size;
549
+ const preConfirmEntries = buildPreConfirmSummary(uniqueObjects, method, preview.toCreate.length, preview.toSkip.length);
550
+ // Suppress all display output in JSON mode — this.log() writes to stdout,
551
+ // which would produce invalid JSON when mixed with the JSON payload.
552
+ if (!this.jsonEnabled()) {
553
+ this.log('');
554
+ this.log(renderSummaryBox({
555
+ title: messages.getMessage('output.creationSummary'),
556
+ entries: preConfirmEntries,
557
+ }));
558
+ }
559
+ if (!this.jsonEnabled() && !noPrompt) {
560
+ this.log('');
561
+ const showDetail = await this.confirm({
562
+ message: messages.getMessage('prompt.showDetail'),
563
+ });
564
+ if (!showDetail)
565
+ return false;
566
+ }
567
+ // Stage 2: Detailed preview table
568
+ const previewCallbackResults = preview.toCreate.map((input) => ({
569
+ objectName: input.objectName,
570
+ objectLabel: input.objectLabel,
571
+ status: 'preview',
572
+ type: input.method,
573
+ category: input.category,
574
+ timeCategory: DefinitionCreateOperation.resolveTimeCategory(input),
575
+ segmentCategory: input.recordTypeName,
576
+ }));
577
+ const skipCallbackResults = preview.toSkip.map((input) => ({
578
+ objectName: input.objectName,
579
+ objectLabel: input.objectLabel,
580
+ status: 'skip',
581
+ type: input.method,
582
+ category: input.category,
583
+ timeCategory: DefinitionCreateOperation.resolveTimeCategory(input),
584
+ segmentCategory: input.recordTypeName,
585
+ }));
586
+ const previewData = {
587
+ created: preview.toCreate.length,
588
+ failed: 0,
589
+ skipped: preview.toSkip.length,
590
+ total: preview.total,
591
+ results: [],
592
+ failures: [],
593
+ };
594
+ // Display preview tables (suppress in JSON mode — printTable writes directly to stdout)
595
+ if (!this.jsonEnabled()) {
596
+ displayResultsTables(this.log.bind(this), this.warn.bind(this), [...previewCallbackResults, ...skipCallbackResults], previewData, true, preview.recordCounts);
597
+ }
598
+ if (this.jsonEnabled())
599
+ return true;
600
+ if (noPrompt)
601
+ return true;
602
+ this.log('');
603
+ const confirmed = await this.confirm({
604
+ message: messages.getMessage('prompt.confirm', [String(preview.toCreate.length)]),
605
+ });
606
+ if (confirmed) {
607
+ // eslint-disable-next-line no-param-reassign -- intentional array reset for callback results
608
+ callbackResults.length = 0;
609
+ this.spinner.start(messages.getMessage('output.creating', [preview.toCreate.length]));
610
+ }
611
+ return confirmed;
612
+ }
613
+ /**
614
+ * Handles operation failure by translating error codes to user-friendly messages.
615
+ */
616
+ handleOperationFailure(result, targetOrg, dryRun) {
617
+ const failure = resolveOperationFailure(result, targetOrg, dryRun, (errorCodeMap, errorCode, fallbackMessage, msgs) => DefinitionCreate.resolveErrorMessage(errorCodeMap, errorCode, fallbackMessage, msgs));
618
+ if (failure.type === 'exit') {
619
+ if (failure.log)
620
+ this.log(failure.log);
621
+ process.exitCode = 2;
622
+ return failure.result;
623
+ }
624
+ this.error(failure.message, { code: failure.code });
625
+ }
626
+ /**
627
+ * Handles post-creation actions: --profile, --open, --logs.
628
+ */
629
+ async handlePostCreationActions(flags, data, dryRun, _facade, soqlAdapter, restAdapter, instanceUrl) {
630
+ if (flags.profile && data.created > 0 && !dryRun) {
631
+ await this.triggerProfiling(data, soqlAdapter, restAdapter);
632
+ }
633
+ else if (flags.profile && dryRun) {
634
+ this.log('');
635
+ this.log(messages.getMessage('output.profileDryRun', [String(data.created)]));
636
+ }
637
+ if (flags.open && data.created > 0 && !dryRun) {
638
+ this.openInBrowser(data, instanceUrl);
639
+ }
640
+ if (flags.logs) {
641
+ await this.writeSessionLogs(data, dryRun);
642
+ }
643
+ }
644
+ /**
645
+ * Triggers fire-and-forget profiling for successfully created definitions.
646
+ */
647
+ async triggerProfiling(data, soqlAdapter, restAdapter) {
648
+ const successResults = data.results.filter((r) => r.status === 'success' && r.definitionId);
649
+ if (successResults.length === 0)
650
+ return;
651
+ const executionService = new ProfilingExecutionService({ restAdapter, soqlAdapter });
652
+ this.log('');
653
+ this.log(messages.getMessage('output.profilingStarting'));
654
+ for (const r of successResults) {
655
+ // eslint-disable-next-line no-await-in-loop -- Sequential triggers to avoid overwhelming the org
656
+ const execResult = await executionService.execute(r.definitionId);
657
+ if (execResult.success) {
658
+ this.log(messages.getMessage('output.profilingSuccess', [r.definitionName ?? '', execResult.data ?? '']));
659
+ }
660
+ else {
661
+ this.warn(messages.getMessage('warnings.profilingFailed', [
662
+ r.definitionName ?? '',
663
+ execResult.message ?? 'unknown error',
664
+ ]));
665
+ }
666
+ }
667
+ }
668
+ /**
669
+ * Opens the first created definition in the default browser.
670
+ */
671
+ openInBrowser(data, instanceUrl) {
672
+ const firstSuccess = data.results.find((r) => r.status === 'success' && r.definitionId);
673
+ if (!firstSuccess)
674
+ return;
675
+ const url = `${instanceUrl}/lightning/r/pnova__Profiling_Definition__c/${firstSuccess.definitionId}/view`;
676
+ const platform = process.platform;
677
+ if (platform === 'darwin') {
678
+ execFile('open', [url], () => { });
679
+ }
680
+ else if (platform === 'win32') {
681
+ execFile('cmd', ['/c', 'start', url], () => { });
682
+ }
683
+ else {
684
+ execFile('xdg-open', [url], () => { });
685
+ }
686
+ this.log('');
687
+ if (data.created > 1) {
688
+ this.log(messages.getMessage('output.openedMultiple', [String(data.created)]));
689
+ }
690
+ else {
691
+ this.log(messages.getMessage('output.openedSingle'));
692
+ }
693
+ }
694
+ /**
695
+ * Writes session logs to a timestamped directory.
696
+ */
697
+ async writeSessionLogs(data, dryRun) {
698
+ const now = new Date();
699
+ const timestamp = now
700
+ .toISOString()
701
+ .replace(/:/g, '-')
702
+ .replace(/\.\d+Z$/, '');
703
+ const sessionDir = join('.cuneiform', 'logs', 'definition-create', timestamp);
704
+ await mkdir(sessionDir, { recursive: true });
705
+ const sessionData = {
706
+ timestamp: now.toISOString(),
707
+ dryRun,
708
+ created: data.created,
709
+ failed: data.failed,
710
+ skipped: data.skipped,
711
+ total: data.total,
712
+ results: data.results,
713
+ failures: data.failures,
714
+ };
715
+ const createdDefs = data.results
716
+ .filter((r) => r.status === 'success')
717
+ .map((r) => ({
718
+ objectName: r.objectName,
719
+ definitionName: r.definitionName,
720
+ definitionId: r.definitionId,
721
+ definitionKey: r.definitionKey,
722
+ }));
723
+ const errors = data.failures.map((f) => ({
724
+ objectName: f.objectName,
725
+ error: f.error,
726
+ errorCode: f.errorCode,
727
+ }));
728
+ await Promise.all([
729
+ writeFile(join(sessionDir, 'session.json'), JSON.stringify(sessionData, null, 2)),
730
+ writeFile(join(sessionDir, 'definitions-created.json'), JSON.stringify(createdDefs, null, 2)),
731
+ writeFile(join(sessionDir, 'errors.json'), JSON.stringify(errors, null, 2)),
732
+ ]);
733
+ this.log('');
734
+ this.log(messages.getMessage('output.sessionLog', [`${sessionDir}/`]));
735
+ }
736
+ }
737
+ //# sourceMappingURL=create.js.map