@revfleet/hscli 0.5.3

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 (329) hide show
  1. package/CHANGELOG.md +466 -0
  2. package/LICENSE +21 -0
  3. package/README.md +287 -0
  4. package/SECURITY.md +68 -0
  5. package/dist/cli.d.ts +8 -0
  6. package/dist/cli.js +192 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/commands/account/index.d.ts +3 -0
  9. package/dist/commands/account/index.js +65 -0
  10. package/dist/commands/account/index.js.map +1 -0
  11. package/dist/commands/api/index.d.ts +3 -0
  12. package/dist/commands/api/index.js +35 -0
  13. package/dist/commands/api/index.js.map +1 -0
  14. package/dist/commands/auth/index.d.ts +3 -0
  15. package/dist/commands/auth/index.js +229 -0
  16. package/dist/commands/auth/index.js.map +1 -0
  17. package/dist/commands/automation/index.d.ts +3 -0
  18. package/dist/commands/automation/index.js +119 -0
  19. package/dist/commands/automation/index.js.map +1 -0
  20. package/dist/commands/cms/blog-settings.d.ts +3 -0
  21. package/dist/commands/cms/blog-settings.js +70 -0
  22. package/dist/commands/cms/blog-settings.js.map +1 -0
  23. package/dist/commands/cms/content-ops.d.ts +13 -0
  24. package/dist/commands/cms/content-ops.js +262 -0
  25. package/dist/commands/cms/content-ops.js.map +1 -0
  26. package/dist/commands/cms/hubdb.d.ts +3 -0
  27. package/dist/commands/cms/hubdb.js +55 -0
  28. package/dist/commands/cms/hubdb.js.map +1 -0
  29. package/dist/commands/cms/index.d.ts +3 -0
  30. package/dist/commands/cms/index.js +119 -0
  31. package/dist/commands/cms/index.js.map +1 -0
  32. package/dist/commands/cms/source-code.d.ts +3 -0
  33. package/dist/commands/cms/source-code.js +101 -0
  34. package/dist/commands/cms/source-code.js.map +1 -0
  35. package/dist/commands/communication-preferences/index.d.ts +3 -0
  36. package/dist/commands/communication-preferences/index.js +107 -0
  37. package/dist/commands/communication-preferences/index.js.map +1 -0
  38. package/dist/commands/conversations/index.d.ts +3 -0
  39. package/dist/commands/conversations/index.js +233 -0
  40. package/dist/commands/conversations/index.js.map +1 -0
  41. package/dist/commands/crm/associations.d.ts +3 -0
  42. package/dist/commands/crm/associations.js +180 -0
  43. package/dist/commands/crm/associations.js.map +1 -0
  44. package/dist/commands/crm/cards.d.ts +3 -0
  45. package/dist/commands/crm/cards.js +72 -0
  46. package/dist/commands/crm/cards.js.map +1 -0
  47. package/dist/commands/crm/carts.d.ts +3 -0
  48. package/dist/commands/crm/carts.js +5 -0
  49. package/dist/commands/crm/carts.js.map +1 -0
  50. package/dist/commands/crm/communications.d.ts +3 -0
  51. package/dist/commands/crm/communications.js +5 -0
  52. package/dist/commands/crm/communications.js.map +1 -0
  53. package/dist/commands/crm/companies.d.ts +3 -0
  54. package/dist/commands/crm/companies.js +5 -0
  55. package/dist/commands/crm/companies.js.map +1 -0
  56. package/dist/commands/crm/contacts.d.ts +3 -0
  57. package/dist/commands/crm/contacts.js +5 -0
  58. package/dist/commands/crm/contacts.js.map +1 -0
  59. package/dist/commands/crm/custom-objects.d.ts +3 -0
  60. package/dist/commands/crm/custom-objects.js +83 -0
  61. package/dist/commands/crm/custom-objects.js.map +1 -0
  62. package/dist/commands/crm/dated.d.ts +9 -0
  63. package/dist/commands/crm/dated.js +247 -0
  64. package/dist/commands/crm/dated.js.map +1 -0
  65. package/dist/commands/crm/deals.d.ts +3 -0
  66. package/dist/commands/crm/deals.js +5 -0
  67. package/dist/commands/crm/deals.js.map +1 -0
  68. package/dist/commands/crm/describe.d.ts +3 -0
  69. package/dist/commands/crm/describe.js +89 -0
  70. package/dist/commands/crm/describe.js.map +1 -0
  71. package/dist/commands/crm/discounts.d.ts +3 -0
  72. package/dist/commands/crm/discounts.js +5 -0
  73. package/dist/commands/crm/discounts.js.map +1 -0
  74. package/dist/commands/crm/engagements.d.ts +3 -0
  75. package/dist/commands/crm/engagements.js +8 -0
  76. package/dist/commands/crm/engagements.js.map +1 -0
  77. package/dist/commands/crm/fees.d.ts +3 -0
  78. package/dist/commands/crm/fees.js +5 -0
  79. package/dist/commands/crm/fees.js.map +1 -0
  80. package/dist/commands/crm/goals.d.ts +3 -0
  81. package/dist/commands/crm/goals.js +30 -0
  82. package/dist/commands/crm/goals.js.map +1 -0
  83. package/dist/commands/crm/imports.d.ts +3 -0
  84. package/dist/commands/crm/imports.js +45 -0
  85. package/dist/commands/crm/imports.js.map +1 -0
  86. package/dist/commands/crm/index.d.ts +3 -0
  87. package/dist/commands/crm/index.js +64 -0
  88. package/dist/commands/crm/index.js.map +1 -0
  89. package/dist/commands/crm/invoices.d.ts +3 -0
  90. package/dist/commands/crm/invoices.js +5 -0
  91. package/dist/commands/crm/invoices.js.map +1 -0
  92. package/dist/commands/crm/leads.d.ts +3 -0
  93. package/dist/commands/crm/leads.js +5 -0
  94. package/dist/commands/crm/leads.js.map +1 -0
  95. package/dist/commands/crm/line-items.d.ts +3 -0
  96. package/dist/commands/crm/line-items.js +5 -0
  97. package/dist/commands/crm/line-items.js.map +1 -0
  98. package/dist/commands/crm/orders.d.ts +3 -0
  99. package/dist/commands/crm/orders.js +5 -0
  100. package/dist/commands/crm/orders.js.map +1 -0
  101. package/dist/commands/crm/owners.d.ts +3 -0
  102. package/dist/commands/crm/owners.js +22 -0
  103. package/dist/commands/crm/owners.js.map +1 -0
  104. package/dist/commands/crm/payments.d.ts +3 -0
  105. package/dist/commands/crm/payments.js +5 -0
  106. package/dist/commands/crm/payments.js.map +1 -0
  107. package/dist/commands/crm/pipelines.d.ts +3 -0
  108. package/dist/commands/crm/pipelines.js +70 -0
  109. package/dist/commands/crm/pipelines.js.map +1 -0
  110. package/dist/commands/crm/products.d.ts +3 -0
  111. package/dist/commands/crm/products.js +5 -0
  112. package/dist/commands/crm/products.js.map +1 -0
  113. package/dist/commands/crm/properties.d.ts +3 -0
  114. package/dist/commands/crm/properties.js +103 -0
  115. package/dist/commands/crm/properties.js.map +1 -0
  116. package/dist/commands/crm/quotes.d.ts +3 -0
  117. package/dist/commands/crm/quotes.js +5 -0
  118. package/dist/commands/crm/quotes.js.map +1 -0
  119. package/dist/commands/crm/shared.d.ts +17 -0
  120. package/dist/commands/crm/shared.js +256 -0
  121. package/dist/commands/crm/shared.js.map +1 -0
  122. package/dist/commands/crm/subscriptions.d.ts +3 -0
  123. package/dist/commands/crm/subscriptions.js +5 -0
  124. package/dist/commands/crm/subscriptions.js.map +1 -0
  125. package/dist/commands/crm/sync.d.ts +3 -0
  126. package/dist/commands/crm/sync.js +116 -0
  127. package/dist/commands/crm/sync.js.map +1 -0
  128. package/dist/commands/crm/taxes.d.ts +3 -0
  129. package/dist/commands/crm/taxes.js +5 -0
  130. package/dist/commands/crm/taxes.js.map +1 -0
  131. package/dist/commands/crm/tickets.d.ts +3 -0
  132. package/dist/commands/crm/tickets.js +5 -0
  133. package/dist/commands/crm/tickets.js.map +1 -0
  134. package/dist/commands/crm/users.d.ts +3 -0
  135. package/dist/commands/crm/users.js +5 -0
  136. package/dist/commands/crm/users.js.map +1 -0
  137. package/dist/commands/doctor/index.d.ts +3 -0
  138. package/dist/commands/doctor/index.js +232 -0
  139. package/dist/commands/doctor/index.js.map +1 -0
  140. package/dist/commands/domains/shared.d.ts +13 -0
  141. package/dist/commands/domains/shared.js +56 -0
  142. package/dist/commands/domains/shared.js.map +1 -0
  143. package/dist/commands/email-events/index.d.ts +3 -0
  144. package/dist/commands/email-events/index.js +77 -0
  145. package/dist/commands/email-events/index.js.map +1 -0
  146. package/dist/commands/events/index.d.ts +3 -0
  147. package/dist/commands/events/index.js +80 -0
  148. package/dist/commands/events/index.js.map +1 -0
  149. package/dist/commands/exports/index.d.ts +3 -0
  150. package/dist/commands/exports/index.js +45 -0
  151. package/dist/commands/exports/index.js.map +1 -0
  152. package/dist/commands/extensions/index.d.ts +3 -0
  153. package/dist/commands/extensions/index.js +118 -0
  154. package/dist/commands/extensions/index.js.map +1 -0
  155. package/dist/commands/feature-flags/index.d.ts +3 -0
  156. package/dist/commands/feature-flags/index.js +65 -0
  157. package/dist/commands/feature-flags/index.js.map +1 -0
  158. package/dist/commands/files/folders.d.ts +3 -0
  159. package/dist/commands/files/folders.js +74 -0
  160. package/dist/commands/files/folders.js.map +1 -0
  161. package/dist/commands/files/index.d.ts +3 -0
  162. package/dist/commands/files/index.js +30 -0
  163. package/dist/commands/files/index.js.map +1 -0
  164. package/dist/commands/forms/index.d.ts +3 -0
  165. package/dist/commands/forms/index.js +37 -0
  166. package/dist/commands/forms/index.js.map +1 -0
  167. package/dist/commands/integrations/index.d.ts +3 -0
  168. package/dist/commands/integrations/index.js +64 -0
  169. package/dist/commands/integrations/index.js.map +1 -0
  170. package/dist/commands/integrators/index.d.ts +3 -0
  171. package/dist/commands/integrators/index.js +79 -0
  172. package/dist/commands/integrators/index.js.map +1 -0
  173. package/dist/commands/legacy/index.d.ts +13 -0
  174. package/dist/commands/legacy/index.js +254 -0
  175. package/dist/commands/legacy/index.js.map +1 -0
  176. package/dist/commands/legacy-v1/index.d.ts +29 -0
  177. package/dist/commands/legacy-v1/index.js +568 -0
  178. package/dist/commands/legacy-v1/index.js.map +1 -0
  179. package/dist/commands/lists/index.d.ts +3 -0
  180. package/dist/commands/lists/index.js +148 -0
  181. package/dist/commands/lists/index.js.map +1 -0
  182. package/dist/commands/marketing/ads.d.ts +3 -0
  183. package/dist/commands/marketing/ads.js +45 -0
  184. package/dist/commands/marketing/ads.js.map +1 -0
  185. package/dist/commands/marketing/behavioral-events.d.ts +3 -0
  186. package/dist/commands/marketing/behavioral-events.js +38 -0
  187. package/dist/commands/marketing/behavioral-events.js.map +1 -0
  188. package/dist/commands/marketing/events.d.ts +3 -0
  189. package/dist/commands/marketing/events.js +69 -0
  190. package/dist/commands/marketing/events.js.map +1 -0
  191. package/dist/commands/marketing/index.d.ts +3 -0
  192. package/dist/commands/marketing/index.js +55 -0
  193. package/dist/commands/marketing/index.js.map +1 -0
  194. package/dist/commands/marketing/landing-pages.d.ts +3 -0
  195. package/dist/commands/marketing/landing-pages.js +48 -0
  196. package/dist/commands/marketing/landing-pages.js.map +1 -0
  197. package/dist/commands/marketing/seo.d.ts +3 -0
  198. package/dist/commands/marketing/seo.js +35 -0
  199. package/dist/commands/marketing/seo.js.map +1 -0
  200. package/dist/commands/marketing/social.d.ts +3 -0
  201. package/dist/commands/marketing/social.js +45 -0
  202. package/dist/commands/marketing/social.js.map +1 -0
  203. package/dist/commands/marketing/subscriptions.d.ts +3 -0
  204. package/dist/commands/marketing/subscriptions.js +27 -0
  205. package/dist/commands/marketing/subscriptions.js.map +1 -0
  206. package/dist/commands/marketing/transactional.d.ts +3 -0
  207. package/dist/commands/marketing/transactional.js +30 -0
  208. package/dist/commands/marketing/transactional.js.map +1 -0
  209. package/dist/commands/marketing-emails-v1/index.d.ts +3 -0
  210. package/dist/commands/marketing-emails-v1/index.js +72 -0
  211. package/dist/commands/marketing-emails-v1/index.js.map +1 -0
  212. package/dist/commands/mcp.d.ts +2 -0
  213. package/dist/commands/mcp.js +10 -0
  214. package/dist/commands/mcp.js.map +1 -0
  215. package/dist/commands/media-bridge/index.d.ts +3 -0
  216. package/dist/commands/media-bridge/index.js +209 -0
  217. package/dist/commands/media-bridge/index.js.map +1 -0
  218. package/dist/commands/reporting/index.d.ts +3 -0
  219. package/dist/commands/reporting/index.js +73 -0
  220. package/dist/commands/reporting/index.js.map +1 -0
  221. package/dist/commands/sales/calling.d.ts +3 -0
  222. package/dist/commands/sales/calling.js +32 -0
  223. package/dist/commands/sales/calling.js.map +1 -0
  224. package/dist/commands/sales/index.d.ts +3 -0
  225. package/dist/commands/sales/index.js +10 -0
  226. package/dist/commands/sales/index.js.map +1 -0
  227. package/dist/commands/sales/meetings.d.ts +3 -0
  228. package/dist/commands/sales/meetings.js +37 -0
  229. package/dist/commands/sales/meetings.js.map +1 -0
  230. package/dist/commands/sales/sequences.d.ts +3 -0
  231. package/dist/commands/sales/sequences.js +78 -0
  232. package/dist/commands/sales/sequences.js.map +1 -0
  233. package/dist/commands/seed/cms.d.ts +6 -0
  234. package/dist/commands/seed/cms.js +204 -0
  235. package/dist/commands/seed/cms.js.map +1 -0
  236. package/dist/commands/seed/commerce.d.ts +3 -0
  237. package/dist/commands/seed/commerce.js +117 -0
  238. package/dist/commands/seed/commerce.js.map +1 -0
  239. package/dist/commands/seed/context.d.ts +8 -0
  240. package/dist/commands/seed/context.js +76 -0
  241. package/dist/commands/seed/context.js.map +1 -0
  242. package/dist/commands/seed/crm-core.d.ts +3 -0
  243. package/dist/commands/seed/crm-core.js +137 -0
  244. package/dist/commands/seed/crm-core.js.map +1 -0
  245. package/dist/commands/seed/data.d.ts +73 -0
  246. package/dist/commands/seed/data.js +49 -0
  247. package/dist/commands/seed/data.js.map +1 -0
  248. package/dist/commands/seed/engagements.d.ts +3 -0
  249. package/dist/commands/seed/engagements.js +89 -0
  250. package/dist/commands/seed/engagements.js.map +1 -0
  251. package/dist/commands/seed/index.d.ts +3 -0
  252. package/dist/commands/seed/index.js +95 -0
  253. package/dist/commands/seed/index.js.map +1 -0
  254. package/dist/commands/seed/infra.d.ts +6 -0
  255. package/dist/commands/seed/infra.js +163 -0
  256. package/dist/commands/seed/infra.js.map +1 -0
  257. package/dist/commands/seed/marketing.d.ts +3 -0
  258. package/dist/commands/seed/marketing.js +172 -0
  259. package/dist/commands/seed/marketing.js.map +1 -0
  260. package/dist/commands/seed/shared.d.ts +8 -0
  261. package/dist/commands/seed/shared.js +37 -0
  262. package/dist/commands/seed/shared.js.map +1 -0
  263. package/dist/commands/seed/types.d.ts +44 -0
  264. package/dist/commands/seed/types.js +2 -0
  265. package/dist/commands/seed/types.js.map +1 -0
  266. package/dist/commands/service/chatflows.d.ts +3 -0
  267. package/dist/commands/service/chatflows.js +30 -0
  268. package/dist/commands/service/chatflows.js.map +1 -0
  269. package/dist/commands/service/index.d.ts +3 -0
  270. package/dist/commands/service/index.js +25 -0
  271. package/dist/commands/service/index.js.map +1 -0
  272. package/dist/commands/service/knowledge-base.d.ts +3 -0
  273. package/dist/commands/service/knowledge-base.js +19 -0
  274. package/dist/commands/service/knowledge-base.js.map +1 -0
  275. package/dist/commands/service/pipelines.d.ts +3 -0
  276. package/dist/commands/service/pipelines.js +36 -0
  277. package/dist/commands/service/pipelines.js.map +1 -0
  278. package/dist/commands/settings/index.d.ts +3 -0
  279. package/dist/commands/settings/index.js +149 -0
  280. package/dist/commands/settings/index.js.map +1 -0
  281. package/dist/commands/site-search/index.d.ts +3 -0
  282. package/dist/commands/site-search/index.js +36 -0
  283. package/dist/commands/site-search/index.js.map +1 -0
  284. package/dist/commands/timeline/index.d.ts +3 -0
  285. package/dist/commands/timeline/index.js +32 -0
  286. package/dist/commands/timeline/index.js.map +1 -0
  287. package/dist/commands/webhooks/index.d.ts +3 -0
  288. package/dist/commands/webhooks/index.js +41 -0
  289. package/dist/commands/webhooks/index.js.map +1 -0
  290. package/dist/commands/workflows/index.d.ts +3 -0
  291. package/dist/commands/workflows/index.js +13 -0
  292. package/dist/commands/workflows/index.js.map +1 -0
  293. package/dist/core/auth.d.ts +33 -0
  294. package/dist/core/auth.js +137 -0
  295. package/dist/core/auth.js.map +1 -0
  296. package/dist/core/capabilities.d.ts +60 -0
  297. package/dist/core/capabilities.js +559 -0
  298. package/dist/core/capabilities.js.map +1 -0
  299. package/dist/core/http.d.ts +47 -0
  300. package/dist/core/http.js +433 -0
  301. package/dist/core/http.js.map +1 -0
  302. package/dist/core/output.d.ts +23 -0
  303. package/dist/core/output.js +197 -0
  304. package/dist/core/output.js.map +1 -0
  305. package/dist/core/permissions.d.ts +9 -0
  306. package/dist/core/permissions.js +27 -0
  307. package/dist/core/permissions.js.map +1 -0
  308. package/dist/core/plugins.d.ts +42 -0
  309. package/dist/core/plugins.js +94 -0
  310. package/dist/core/plugins.js.map +1 -0
  311. package/dist/core/policy.d.ts +2 -0
  312. package/dist/core/policy.js +38 -0
  313. package/dist/core/policy.js.map +1 -0
  314. package/dist/core/schema-cache.d.ts +56 -0
  315. package/dist/core/schema-cache.js +338 -0
  316. package/dist/core/schema-cache.js.map +1 -0
  317. package/dist/core/schemas.d.ts +96 -0
  318. package/dist/core/schemas.js +104 -0
  319. package/dist/core/schemas.js.map +1 -0
  320. package/dist/core/urls.d.ts +50 -0
  321. package/dist/core/urls.js +122 -0
  322. package/dist/core/urls.js.map +1 -0
  323. package/dist/core/vault.d.ts +37 -0
  324. package/dist/core/vault.js +143 -0
  325. package/dist/core/vault.js.map +1 -0
  326. package/dist/mcp/server.d.ts +5 -0
  327. package/dist/mcp/server.js +680 -0
  328. package/dist/mcp/server.js.map +1 -0
  329. package/package.json +84 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/core/output.ts"],"names":[],"mappings":"AAgBA,MAAM,OAAO,QAAS,SAAQ,KAAK;IAExB;IAEA;IACA;IAJT,YACS,IAAY,EACnB,OAAe,EACR,MAAe,EACf,OAAiB;QAExB,KAAK,CAAC,OAAO,CAAC,CAAC;QALR,SAAI,GAAJ,IAAI,CAAQ;QAEZ,WAAM,GAAN,MAAM,CAAS;QACf,YAAO,GAAP,OAAO,CAAU;IAG1B,CAAC;CACF;AAED,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;AAC/G,MAAM,cAAc,GAAG,8BAA8B,CAAC;AACtD,MAAM,iCAAiC,GAAG,0BAA0B,CAAC;AACrE,MAAM,0BAA0B,GAAG;IACjC,wHAAwH;IACxH,yGAAyG;CAC1G,CAAC;AAEF,SAAS,cAAc,CAAC,GAAW;IACjC,MAAM,UAAU,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IACrC,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,QAAQ,GAAG,KAAK,CAAC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CAAC;QACzE,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACpB,OAAO,GAAG,OAAO,GAAG,OAAO,KAAK,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;QAC9D,CAAC;QACD,OAAO,GAAG,OAAO,GAAG,OAAO,MAAM,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;IAC/D,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,CAAC;AACvI,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa;IACrC,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,MAAM,CAAC;IAChC,IAAI,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACnD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Check if the given profile is configured as read-only.
3
+ */
4
+ export declare function isReadOnlyProfile(profile: string): boolean;
5
+ /**
6
+ * Enforce permission profile before executing an HTTP request.
7
+ * Throws if the profile is read-only and the method is a write operation.
8
+ */
9
+ export declare function enforcePermissionProfile(profile: string, method: string): void;
@@ -0,0 +1,27 @@
1
+ import { getProfile } from "./auth.js";
2
+ import { CliError } from "./output.js";
3
+ const WRITE_METHODS = new Set(["POST", "PATCH", "PUT", "DELETE"]);
4
+ /**
5
+ * Check if the given profile is configured as read-only.
6
+ */
7
+ export function isReadOnlyProfile(profile) {
8
+ try {
9
+ const data = getProfile(profile);
10
+ return data.mode === "read-only";
11
+ }
12
+ catch {
13
+ return false;
14
+ }
15
+ }
16
+ /**
17
+ * Enforce permission profile before executing an HTTP request.
18
+ * Throws if the profile is read-only and the method is a write operation.
19
+ */
20
+ export function enforcePermissionProfile(profile, method) {
21
+ if (!WRITE_METHODS.has(method))
22
+ return;
23
+ if (!isReadOnlyProfile(profile))
24
+ return;
25
+ throw new CliError("PERMISSION_DENIED", `Profile '${profile}' is configured as read-only. Write operations (${method}) are not allowed. Use 'hubcli auth set-mode ${profile} read-write' to enable writes.`);
26
+ }
27
+ //# sourceMappingURL=permissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/core/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AAElE;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC,IAAI,KAAK,WAAW,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAe,EAAE,MAAc;IACtE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC;QAAE,OAAO;IACvC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC;QAAE,OAAO;IAExC,MAAM,IAAI,QAAQ,CAChB,mBAAmB,EACnB,YAAY,OAAO,mDAAmD,MAAM,gDAAgD,OAAO,gCAAgC,CACpK,CAAC;AACJ,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Plugin system for hubcli.
3
+ *
4
+ * Plugins are discovered from:
5
+ * 1. HSCLI_PLUGINS env var (comma-separated paths or package names)
6
+ * 2. node_modules packages with "hubcli-plugin" in keywords
7
+ *
8
+ * Each plugin must export: register(program: Command, context: PluginContext)
9
+ */
10
+ import { Command } from "commander";
11
+ import { CliError, printResult, printError, type CliContext } from "./output.js";
12
+ import { maybeWrite } from "../commands/crm/shared.js";
13
+ import type { HubSpotClient } from "./http.js";
14
+ /**
15
+ * Context provided to plugins — gives access to core utilities
16
+ * without requiring knowledge of internal import paths.
17
+ */
18
+ export interface PluginContext {
19
+ /** Get the current CLI context (profile, flags, etc). Call inside .action(), not at registration time. */
20
+ getCtx: () => CliContext;
21
+ /** Create an authenticated HubSpot API client for a profile. */
22
+ createClient: (profile: string) => HubSpotClient;
23
+ /** Print a successful result to stdout. */
24
+ printResult: typeof printResult;
25
+ /** Print an error to stderr. */
26
+ printError: typeof printError;
27
+ /** Structured CLI error constructor. */
28
+ CliError: typeof CliError;
29
+ /** Write-safe helper: enforces --dry-run, --force, and --policy-file gates. */
30
+ maybeWrite: typeof maybeWrite;
31
+ }
32
+ /**
33
+ * The contract a plugin package must satisfy.
34
+ */
35
+ export interface HubcliPlugin {
36
+ register(program: Command, context: PluginContext): void | Promise<void>;
37
+ }
38
+ /**
39
+ * Load and register all discovered plugins.
40
+ * Plugin failures are logged to stderr but never crash the CLI.
41
+ */
42
+ export declare function loadPlugins(program: Command, getCtx: () => CliContext): Promise<void>;
@@ -0,0 +1,94 @@
1
+ import { readdirSync, readFileSync } from "node:fs";
2
+ import { resolve, join, dirname } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { createClient } from "./http.js";
5
+ import { CliError, printResult, printError } from "./output.js";
6
+ import { maybeWrite } from "../commands/crm/shared.js";
7
+ /**
8
+ * Discover plugin package names from node_modules with "hubcli-plugin" keyword.
9
+ */
10
+ function discoverFromNodeModules() {
11
+ const pkgRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
12
+ const nmDir = join(pkgRoot, "node_modules");
13
+ try {
14
+ return readdirSync(nmDir, { withFileTypes: true })
15
+ .filter((d) => d.isDirectory() && !d.name.startsWith("."))
16
+ .flatMap((d) => {
17
+ // Handle scoped packages (@scope/pkg)
18
+ if (d.name.startsWith("@")) {
19
+ try {
20
+ return readdirSync(join(nmDir, d.name), { withFileTypes: true })
21
+ .filter((sd) => sd.isDirectory())
22
+ .map((sd) => `${d.name}/${sd.name}`);
23
+ }
24
+ catch {
25
+ return [];
26
+ }
27
+ }
28
+ return [d.name];
29
+ })
30
+ .filter((name) => {
31
+ try {
32
+ const pj = JSON.parse(readFileSync(join(nmDir, name, "package.json"), "utf8"));
33
+ return Array.isArray(pj.keywords) && pj.keywords.includes("hubcli-plugin");
34
+ }
35
+ catch {
36
+ return false;
37
+ }
38
+ });
39
+ }
40
+ catch {
41
+ return [];
42
+ }
43
+ }
44
+ /**
45
+ * Discover plugin specifiers from HSCLI_PLUGINS env var.
46
+ */
47
+ function discoverFromEnv() {
48
+ const raw = process.env.HSCLI_PLUGINS?.trim();
49
+ if (!raw)
50
+ return [];
51
+ return raw.split(",").map((s) => s.trim()).filter(Boolean);
52
+ }
53
+ /**
54
+ * Resolve a specifier to an importable path.
55
+ */
56
+ function resolveSpecifier(specifier) {
57
+ if (specifier.startsWith(".") || specifier.startsWith("/")) {
58
+ return resolve(process.cwd(), specifier);
59
+ }
60
+ return specifier;
61
+ }
62
+ /**
63
+ * Load and register all discovered plugins.
64
+ * Plugin failures are logged to stderr but never crash the CLI.
65
+ */
66
+ export async function loadPlugins(program, getCtx) {
67
+ const context = {
68
+ getCtx,
69
+ createClient,
70
+ printResult,
71
+ printError,
72
+ CliError,
73
+ maybeWrite,
74
+ };
75
+ const specifiers = [...new Set([...discoverFromEnv(), ...discoverFromNodeModules()])];
76
+ if (specifiers.length === 0)
77
+ return;
78
+ for (const raw of specifiers) {
79
+ const specifier = resolveSpecifier(raw);
80
+ try {
81
+ const mod = await import(specifier);
82
+ const plugin = mod.default ?? mod;
83
+ if (typeof plugin.register !== "function") {
84
+ console.error(`[plugin] ${raw}: missing register() function, skipping`);
85
+ continue;
86
+ }
87
+ await plugin.register(program, context);
88
+ }
89
+ catch (err) {
90
+ console.error(`[plugin] Failed to load '${raw}': ${err instanceof Error ? err.message : String(err)}`);
91
+ }
92
+ }
93
+ }
94
+ //# sourceMappingURL=plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/core/plugins.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAmB,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AA6BvD;;GAEG;AACH,SAAS,uBAAuB;IAC9B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAC1E,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAC5C,IAAI,CAAC;QACH,OAAO,WAAW,CAAC,KAAK,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;aAC/C,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;aACzD,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACb,sCAAsC;YACtC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAA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OAAO,CAAC,KAAK,CAAC,4BAA4B,GAAG,MAAM,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACzG,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { CliContext } from "./output.js";
2
+ export declare function enforceWritePolicy(ctx: CliContext, method: "POST" | "PATCH" | "PUT" | "DELETE", path: string): void;
@@ -0,0 +1,38 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { CliError } from "./output.js";
3
+ function readPolicyFile(path) {
4
+ if (!existsSync(path)) {
5
+ throw new CliError("POLICY_FILE_NOT_FOUND", `Policy file not found: ${path}`);
6
+ }
7
+ try {
8
+ return JSON.parse(readFileSync(path, "utf8"));
9
+ }
10
+ catch {
11
+ throw new CliError("POLICY_INVALID_JSON", `Invalid policy JSON: ${path}`);
12
+ }
13
+ }
14
+ export function enforceWritePolicy(ctx, method, path) {
15
+ const policyPath = ctx.policyFile?.trim() || process.env.HSCLI_POLICY_FILE?.trim();
16
+ if (!policyPath)
17
+ return;
18
+ const config = readPolicyFile(policyPath);
19
+ const profileRule = config.profiles?.[ctx.profile] ?? {};
20
+ const defaults = config.defaults ?? {};
21
+ const allowWrite = profileRule.allowWrite ?? defaults.allowWrite ?? true;
22
+ const allowDelete = profileRule.allowDelete ?? defaults.allowDelete ?? false;
23
+ const requireChangeTicket = profileRule.requireChangeTicket ?? defaults.requireChangeTicket ?? false;
24
+ if (!allowWrite) {
25
+ throw new CliError("POLICY_WRITE_BLOCKED", `Policy blocks write operations for profile '${ctx.profile}'.`);
26
+ }
27
+ if (method === "DELETE" && !allowDelete) {
28
+ throw new CliError("POLICY_DELETE_BLOCKED", `Policy blocks delete operations for profile '${ctx.profile}'.`);
29
+ }
30
+ if (requireChangeTicket && !ctx.changeTicket?.trim()) {
31
+ throw new CliError("POLICY_CHANGE_TICKET_REQUIRED", `Profile '${ctx.profile}' requires --change-ticket for write operations.`);
32
+ }
33
+ const blockedPrefixes = config.blockedMethodPathPrefixes?.[method] ?? [];
34
+ if (blockedPrefixes.some((prefix) => path.startsWith(prefix))) {
35
+ throw new CliError("POLICY_PATH_BLOCKED", `Policy blocks ${method} on path '${path}'.`);
36
+ }
37
+ }
38
+ //# sourceMappingURL=policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/core/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAcvC,SAAS,cAAc,CAAC,IAAY;IAClC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,QAAQ,CAAC,uBAAuB,EAAE,0BAA0B,IAAI,EAAE,CAAC,CAAC;IAChF,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAiB,CAAC;IAChE,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,QAAQ,CAAC,qBAAqB,EAAE,wBAAwB,IAAI,EAAE,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,GAAe,EAAE,MAA2C,EAAE,IAAY;IAC3G,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC;IACnF,IAAI,CAAC,UAAU;QAAE,OAAO;IAExB,MAAM,MAAM,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;IAC1C,MAAM,WAAW,GAAe,MAAM,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACrE,MAAM,QAAQ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
+ type: string;
9
+ fieldType?: string;
10
+ required: boolean;
11
+ options: CrmPropertyOption[];
12
+ }
13
+ export interface CrmPipelineSchema {
14
+ id: string;
15
+ label: string;
16
+ stages: Array<{
17
+ id: string;
18
+ label: string;
19
+ }>;
20
+ }
21
+ export interface CrmAssociationLabelSchema {
22
+ category?: string;
23
+ typeId?: number;
24
+ label: string;
25
+ }
26
+ export interface CrmObjectSchema {
27
+ objectType: string;
28
+ fetchedAt: string;
29
+ properties: CrmPropertySchema[];
30
+ pipelines: CrmPipelineSchema[];
31
+ associationLabels: Record<string, CrmAssociationLabelSchema[]>;
32
+ }
33
+ export interface LoadCrmObjectSchemaOptions {
34
+ profile: string;
35
+ token: string;
36
+ objectType: string;
37
+ offline?: boolean;
38
+ refresh?: boolean;
39
+ ttlMs?: number;
40
+ }
41
+ export interface LoadedCrmObjectSchema {
42
+ source: "cache" | "api";
43
+ stale?: boolean;
44
+ schema: CrmObjectSchema;
45
+ }
46
+ export interface PayloadValidationIssue {
47
+ field: string;
48
+ message: string;
49
+ }
50
+ export interface PayloadValidationResult {
51
+ valid: boolean;
52
+ errors: PayloadValidationIssue[];
53
+ warnings: PayloadValidationIssue[];
54
+ }
55
+ export declare function loadCrmObjectSchema(options: LoadCrmObjectSchemaOptions): Promise<LoadedCrmObjectSchema>;
56
+ export declare function validateCrmPayload(schema: CrmObjectSchema, payload: Record<string, unknown>): PayloadValidationResult;
@@ -0,0 +1,338 @@
1
+ import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { getHubcliHomeDir, getProfile, getApiBaseUrl } from "./auth.js";
4
+ import { HubSpotClient } from "./http.js";
5
+ import { CliError } from "./output.js";
6
+ const SCHEMA_CACHE_VERSION = 1;
7
+ const SCHEMA_CACHE_FILENAME = "schema-cache.json";
8
+ const DEFAULT_SCHEMA_CACHE_TTL_MS = 24 * 60 * 60 * 1000;
9
+ const ASSOCIATION_OBJECT_TYPES = ["contacts", "companies", "deals", "tickets", "notes", "calls", "tasks", "emails", "meetings"];
10
+ export async function loadCrmObjectSchema(options) {
11
+ const objectType = options.objectType.trim().toLowerCase();
12
+ if (!objectType) {
13
+ throw new CliError("SCHEMA_OBJECT_TYPE_REQUIRED", "objectType cannot be empty");
14
+ }
15
+ const ttlMs = options.ttlMs && options.ttlMs > 0 ? options.ttlMs : DEFAULT_SCHEMA_CACHE_TTL_MS;
16
+ const portalId = resolvePortalId(options.profile);
17
+ const key = buildSchemaCacheKey(options.profile, objectType, portalId);
18
+ const cache = readSchemaCache();
19
+ const existing = cache.entries.find((entry) => entry.key === key);
20
+ if (options.offline) {
21
+ if (!existing) {
22
+ throw new CliError("SCHEMA_CACHE_MISS", `No cached schema found for '${objectType}'. Run 'hubcli crm describe ${objectType}' online first.`);
23
+ }
24
+ return {
25
+ source: "cache",
26
+ stale: isExpired(existing.expiresAt),
27
+ schema: existing.schema,
28
+ };
29
+ }
30
+ if (existing && !options.refresh && !isExpired(existing.expiresAt)) {
31
+ return {
32
+ source: "cache",
33
+ schema: existing.schema,
34
+ };
35
+ }
36
+ try {
37
+ const schema = await fetchCrmObjectSchema({
38
+ profile: options.profile,
39
+ token: options.token,
40
+ objectType,
41
+ });
42
+ const nowIso = new Date().toISOString();
43
+ const updated = {
44
+ key,
45
+ profile: options.profile,
46
+ portalId,
47
+ objectType,
48
+ fetchedAt: nowIso,
49
+ expiresAt: new Date(Date.now() + ttlMs).toISOString(),
50
+ schema,
51
+ };
52
+ if (existing) {
53
+ const index = cache.entries.findIndex((entry) => entry.key === key);
54
+ cache.entries[index] = updated;
55
+ }
56
+ else {
57
+ cache.entries.push(updated);
58
+ }
59
+ writeSchemaCache(cache);
60
+ return {
61
+ source: "api",
62
+ schema,
63
+ };
64
+ }
65
+ catch (error) {
66
+ if (existing) {
67
+ return {
68
+ source: "cache",
69
+ stale: true,
70
+ schema: existing.schema,
71
+ };
72
+ }
73
+ throw error;
74
+ }
75
+ }
76
+ export function validateCrmPayload(schema, payload) {
77
+ const errors = [];
78
+ const warnings = [];
79
+ const propertiesValue = payload.properties ?? payload;
80
+ if (!propertiesValue || typeof propertiesValue !== "object" || Array.isArray(propertiesValue)) {
81
+ errors.push({ field: "properties", message: "Payload must be an object or include a 'properties' object." });
82
+ return { valid: false, errors, warnings };
83
+ }
84
+ const provided = propertiesValue;
85
+ const index = new Map(schema.properties.map((property) => [property.name, property]));
86
+ for (const property of schema.properties) {
87
+ if (!property.required)
88
+ continue;
89
+ if (!(property.name in provided)) {
90
+ errors.push({ field: property.name, message: "Required property is missing." });
91
+ }
92
+ }
93
+ for (const [field, value] of Object.entries(provided)) {
94
+ const property = index.get(field);
95
+ if (!property) {
96
+ warnings.push({ field, message: "Property not found in local schema cache (cache may be stale)." });
97
+ continue;
98
+ }
99
+ if (property.options.length > 0 && value !== undefined && value !== null) {
100
+ const allowed = new Set(property.options.map((option) => option.value));
101
+ const submittedValues = normalizeCandidateValues(value);
102
+ for (const candidate of submittedValues) {
103
+ if (!allowed.has(candidate)) {
104
+ errors.push({
105
+ field,
106
+ message: `Value '${candidate}' is not allowed. Allowed: ${Array.from(allowed).join(", ")}`,
107
+ });
108
+ }
109
+ }
110
+ }
111
+ }
112
+ return { valid: errors.length === 0, errors, warnings };
113
+ }
114
+ async function fetchCrmObjectSchema(options) {
115
+ const client = new HubSpotClient(options.token, { profile: options.profile, apiBaseUrl: getApiBaseUrl(options.profile) });
116
+ const objectTypeSegment = encodePathSegment(options.objectType, "objectType");
117
+ const propertiesResponse = await client.request(`/crm/v3/properties/${objectTypeSegment}`);
118
+ const properties = parseProperties(propertiesResponse);
119
+ const pipelines = await maybeLoadPipelines(client, objectTypeSegment, options.objectType);
120
+ const associationLabels = await loadAssociationLabels(client, objectTypeSegment, options.objectType);
121
+ return {
122
+ objectType: options.objectType,
123
+ fetchedAt: new Date().toISOString(),
124
+ properties,
125
+ pipelines,
126
+ associationLabels,
127
+ };
128
+ }
129
+ async function maybeLoadPipelines(client, objectTypeSegment, objectType) {
130
+ if (objectType !== "deals" && objectType !== "tickets") {
131
+ return [];
132
+ }
133
+ try {
134
+ const response = await client.request(`/crm/v3/pipelines/${objectTypeSegment}`);
135
+ return parsePipelines(response);
136
+ }
137
+ catch (error) {
138
+ if (error instanceof CliError && (error.status === 403 || error.status === 404)) {
139
+ return [];
140
+ }
141
+ throw error;
142
+ }
143
+ }
144
+ async function loadAssociationLabels(client, fromObjectTypeSegment, fromObjectType) {
145
+ const output = {};
146
+ for (const toObjectType of ASSOCIATION_OBJECT_TYPES) {
147
+ const toObjectTypeSegment = encodePathSegment(toObjectType, "toObjectType");
148
+ try {
149
+ const response = await client.request(`/crm/v4/associations/${fromObjectTypeSegment}/${toObjectTypeSegment}/labels`);
150
+ output[toObjectType] = parseAssociationLabels(response);
151
+ }
152
+ catch (error) {
153
+ if (error instanceof CliError && (error.status === 403 || error.status === 404)) {
154
+ output[toObjectType] = [];
155
+ continue;
156
+ }
157
+ if (error instanceof CliError && error.code === "UNSUPPORTED_OBJECT_TYPE" && fromObjectType !== toObjectType) {
158
+ output[toObjectType] = [];
159
+ continue;
160
+ }
161
+ throw error;
162
+ }
163
+ }
164
+ return output;
165
+ }
166
+ function parseProperties(payload) {
167
+ return asResultArray(payload).map((item) => {
168
+ const name = asString(item.name) || "";
169
+ const label = asString(item.label) || name;
170
+ const type = asString(item.type) || "string";
171
+ const fieldType = asString(item.fieldType) || undefined;
172
+ const required = typeof item.required === "boolean" ? item.required : false;
173
+ const options = Array.isArray(item.options)
174
+ ? item.options
175
+ .map((value) => {
176
+ const record = asRecord(value);
177
+ const optionValue = asString(record.value);
178
+ if (!optionValue)
179
+ return undefined;
180
+ return {
181
+ label: asString(record.label) || optionValue,
182
+ value: optionValue,
183
+ };
184
+ })
185
+ .filter((value) => Boolean(value))
186
+ : [];
187
+ return {
188
+ name,
189
+ label,
190
+ type,
191
+ fieldType,
192
+ required,
193
+ options,
194
+ };
195
+ }).filter((property) => property.name.length > 0);
196
+ }
197
+ function parsePipelines(payload) {
198
+ return asResultArray(payload).map((item) => {
199
+ const id = asString(item.id) || "";
200
+ const label = asString(item.label) || id;
201
+ const stages = Array.isArray(item.stages)
202
+ ? item.stages
203
+ .map((stage) => {
204
+ const record = asRecord(stage);
205
+ const stageId = asString(record.id);
206
+ if (!stageId)
207
+ return undefined;
208
+ return {
209
+ id: stageId,
210
+ label: asString(record.label) || stageId,
211
+ };
212
+ })
213
+ .filter((stage) => Boolean(stage))
214
+ : [];
215
+ return { id, label, stages };
216
+ }).filter((pipeline) => pipeline.id.length > 0);
217
+ }
218
+ function parseAssociationLabels(payload) {
219
+ return asResultArray(payload).map((item) => {
220
+ const typeIdValue = item.typeId;
221
+ const typeId = typeof typeIdValue === "number"
222
+ ? typeIdValue
223
+ : (typeof typeIdValue === "string" && Number.isFinite(Number(typeIdValue)) ? Number(typeIdValue) : undefined);
224
+ return {
225
+ category: asString(item.category) || undefined,
226
+ typeId,
227
+ label: asString(item.label) || "",
228
+ };
229
+ }).filter((label) => label.label.length > 0);
230
+ }
231
+ function normalizeCandidateValues(value) {
232
+ if (Array.isArray(value)) {
233
+ return value
234
+ .map((item) => (typeof item === "string" ? item.trim() : String(item)))
235
+ .filter(Boolean);
236
+ }
237
+ if (typeof value === "string") {
238
+ if (value.includes(";")) {
239
+ return value.split(";").map((item) => item.trim()).filter(Boolean);
240
+ }
241
+ return [value.trim()].filter(Boolean);
242
+ }
243
+ return [String(value)];
244
+ }
245
+ function asResultArray(payload) {
246
+ if (Array.isArray(payload)) {
247
+ return payload.map((item) => asRecord(item));
248
+ }
249
+ const record = asRecord(payload);
250
+ if (Array.isArray(record.results)) {
251
+ return record.results.map((item) => asRecord(item));
252
+ }
253
+ return [];
254
+ }
255
+ function asRecord(value) {
256
+ if (value && typeof value === "object" && !Array.isArray(value)) {
257
+ return value;
258
+ }
259
+ return {};
260
+ }
261
+ function asString(value) {
262
+ if (typeof value === "string")
263
+ return value;
264
+ if (typeof value === "number" || typeof value === "boolean")
265
+ return String(value);
266
+ return undefined;
267
+ }
268
+ function buildSchemaCacheKey(profile, objectType, portalId) {
269
+ return `${profile.trim()}|${portalId?.trim() || "unknown"}|${objectType.trim().toLowerCase()}`;
270
+ }
271
+ function resolvePortalId(profile) {
272
+ try {
273
+ const value = getProfile(profile).portalId?.trim();
274
+ return value || undefined;
275
+ }
276
+ catch {
277
+ return undefined;
278
+ }
279
+ }
280
+ function isExpired(expiresAt) {
281
+ const parsed = Date.parse(expiresAt);
282
+ if (!Number.isFinite(parsed))
283
+ return true;
284
+ return parsed <= Date.now();
285
+ }
286
+ function schemaCachePaths() {
287
+ const dir = getHubcliHomeDir();
288
+ return { dir, file: join(dir, SCHEMA_CACHE_FILENAME) };
289
+ }
290
+ function readSchemaCache() {
291
+ const { file } = schemaCachePaths();
292
+ if (!existsSync(file)) {
293
+ return { version: SCHEMA_CACHE_VERSION, entries: [] };
294
+ }
295
+ try {
296
+ const parsed = JSON.parse(readFileSync(file, "utf8"));
297
+ if (parsed.version !== SCHEMA_CACHE_VERSION || !Array.isArray(parsed.entries)) {
298
+ return { version: SCHEMA_CACHE_VERSION, entries: [] };
299
+ }
300
+ return {
301
+ version: SCHEMA_CACHE_VERSION,
302
+ entries: parsed.entries,
303
+ };
304
+ }
305
+ catch {
306
+ return { version: SCHEMA_CACHE_VERSION, entries: [] };
307
+ }
308
+ }
309
+ function writeSchemaCache(cache) {
310
+ const { dir, file } = schemaCachePaths();
311
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
312
+ if (process.platform !== "win32") {
313
+ chmodSync(dir, 0o700);
314
+ }
315
+ writeFileSync(file, JSON.stringify(cache, null, 2), { mode: 0o600 });
316
+ if (process.platform !== "win32") {
317
+ chmodSync(file, 0o600);
318
+ }
319
+ }
320
+ // eslint-disable-next-line no-control-regex
321
+ const CONTROL_CHAR_PATTERN = /[\x00-\x1f\x7f]/;
322
+ function encodePathSegment(raw, segmentName) {
323
+ const value = raw?.trim();
324
+ if (!value) {
325
+ throw new CliError("INVALID_PATH_SEGMENT", `${segmentName} cannot be empty`);
326
+ }
327
+ if (CONTROL_CHAR_PATTERN.test(value)) {
328
+ throw new CliError("INVALID_PATH_SEGMENT", `${segmentName} must not contain control characters`);
329
+ }
330
+ if (value.includes("/") || value.includes("\\")) {
331
+ throw new CliError("INVALID_PATH_SEGMENT", `${segmentName} must not contain path separators`);
332
+ }
333
+ if (value === "." || value === "..") {
334
+ throw new CliError("INVALID_PATH_SEGMENT", `${segmentName} cannot be '.' or '..'`);
335
+ }
336
+ return encodeURIComponent(value);
337
+ }
338
+ //# sourceMappingURL=schema-cache.js.map