@typecall/admin-sdk 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (523) hide show
  1. package/dist/fabric/common/call.cjs +4 -0
  2. package/dist/fabric/common/call.cjs.map +1 -0
  3. package/dist/fabric/common/call.d.cts +12 -0
  4. package/dist/fabric/common/call.d.ts +12 -0
  5. package/dist/fabric/common/call.js +3 -0
  6. package/dist/fabric/common/call.js.map +1 -0
  7. package/dist/fabric/common/conversation.cjs +4 -0
  8. package/dist/fabric/common/conversation.cjs.map +1 -0
  9. package/dist/fabric/common/conversation.d.cts +13 -0
  10. package/dist/fabric/common/conversation.d.ts +13 -0
  11. package/dist/fabric/common/conversation.js +3 -0
  12. package/dist/fabric/common/conversation.js.map +1 -0
  13. package/dist/fabric/common/country.cjs +4 -0
  14. package/dist/fabric/common/country.cjs.map +1 -0
  15. package/dist/fabric/common/country.d.cts +3 -0
  16. package/dist/fabric/common/country.d.ts +3 -0
  17. package/dist/fabric/common/country.js +3 -0
  18. package/dist/fabric/common/country.js.map +1 -0
  19. package/dist/fabric/common/date.cjs +4 -0
  20. package/dist/fabric/common/date.cjs.map +1 -0
  21. package/dist/fabric/common/date.d.cts +4 -0
  22. package/dist/fabric/common/date.d.ts +4 -0
  23. package/dist/fabric/common/date.js +3 -0
  24. package/dist/fabric/common/date.js.map +1 -0
  25. package/dist/fabric/common/entity.cjs +4 -0
  26. package/dist/fabric/common/entity.cjs.map +1 -0
  27. package/dist/fabric/common/entity.d.cts +9 -0
  28. package/dist/fabric/common/entity.d.ts +9 -0
  29. package/dist/fabric/common/entity.js +3 -0
  30. package/dist/fabric/common/entity.js.map +1 -0
  31. package/dist/fabric/common/field.cjs +4 -0
  32. package/dist/fabric/common/field.cjs.map +1 -0
  33. package/dist/fabric/common/field.d.cts +8 -0
  34. package/dist/fabric/common/field.d.ts +8 -0
  35. package/dist/fabric/common/field.js +3 -0
  36. package/dist/fabric/common/field.js.map +1 -0
  37. package/dist/fabric/common/handle.cjs +18 -0
  38. package/dist/fabric/common/handle.cjs.map +1 -0
  39. package/dist/fabric/common/handle.d.cts +20 -0
  40. package/dist/fabric/common/handle.d.ts +20 -0
  41. package/dist/fabric/common/handle.js +11 -0
  42. package/dist/fabric/common/handle.js.map +1 -0
  43. package/dist/fabric/common/language.cjs +4 -0
  44. package/dist/fabric/common/language.cjs.map +1 -0
  45. package/dist/fabric/common/language.d.cts +3 -0
  46. package/dist/fabric/common/language.d.ts +3 -0
  47. package/dist/fabric/common/language.js +3 -0
  48. package/dist/fabric/common/language.js.map +1 -0
  49. package/dist/fabric/common/money.cjs +4 -0
  50. package/dist/fabric/common/money.cjs.map +1 -0
  51. package/dist/fabric/common/money.d.cts +7 -0
  52. package/dist/fabric/common/money.d.ts +7 -0
  53. package/dist/fabric/common/money.js +3 -0
  54. package/dist/fabric/common/money.js.map +1 -0
  55. package/dist/fabric/common/note.cjs +4 -0
  56. package/dist/fabric/common/note.cjs.map +1 -0
  57. package/dist/fabric/common/note.d.cts +10 -0
  58. package/dist/fabric/common/note.d.ts +10 -0
  59. package/dist/fabric/common/note.js +3 -0
  60. package/dist/fabric/common/note.js.map +1 -0
  61. package/dist/fabric/common/region.cjs +4 -0
  62. package/dist/fabric/common/region.cjs.map +1 -0
  63. package/dist/fabric/common/region.d.cts +3 -0
  64. package/dist/fabric/common/region.d.ts +3 -0
  65. package/dist/fabric/common/region.js +3 -0
  66. package/dist/fabric/common/region.js.map +1 -0
  67. package/dist/fabric/common/user.cjs +4 -0
  68. package/dist/fabric/common/user.cjs.map +1 -0
  69. package/dist/fabric/common/user.d.cts +4 -0
  70. package/dist/fabric/common/user.d.ts +4 -0
  71. package/dist/fabric/common/user.js +3 -0
  72. package/dist/fabric/common/user.js.map +1 -0
  73. package/dist/fabric/domains/account/account.cjs +4 -0
  74. package/dist/fabric/domains/account/account.cjs.map +1 -0
  75. package/dist/fabric/domains/account/account.d.cts +58 -0
  76. package/dist/fabric/domains/account/account.d.ts +58 -0
  77. package/dist/fabric/domains/account/account.js +3 -0
  78. package/dist/fabric/domains/account/account.js.map +1 -0
  79. package/dist/fabric/domains/account/device.cjs +4 -0
  80. package/dist/fabric/domains/account/device.cjs.map +1 -0
  81. package/dist/fabric/domains/account/device.d.cts +29 -0
  82. package/dist/fabric/domains/account/device.d.ts +29 -0
  83. package/dist/fabric/domains/account/device.js +3 -0
  84. package/dist/fabric/domains/account/device.js.map +1 -0
  85. package/dist/fabric/domains/account/token.cjs +4 -0
  86. package/dist/fabric/domains/account/token.cjs.map +1 -0
  87. package/dist/fabric/domains/account/token.d.cts +7 -0
  88. package/dist/fabric/domains/account/token.d.ts +7 -0
  89. package/dist/fabric/domains/account/token.js +3 -0
  90. package/dist/fabric/domains/account/token.js.map +1 -0
  91. package/dist/fabric/domains/analytics/call.cjs +4 -0
  92. package/dist/fabric/domains/analytics/call.cjs.map +1 -0
  93. package/dist/fabric/domains/analytics/call.d.cts +288 -0
  94. package/dist/fabric/domains/analytics/call.d.ts +288 -0
  95. package/dist/fabric/domains/analytics/call.js +3 -0
  96. package/dist/fabric/domains/analytics/call.js.map +1 -0
  97. package/dist/fabric/domains/analytics/charge.cjs +4 -0
  98. package/dist/fabric/domains/analytics/charge.cjs.map +1 -0
  99. package/dist/fabric/domains/analytics/charge.d.cts +14 -0
  100. package/dist/fabric/domains/analytics/charge.d.ts +14 -0
  101. package/dist/fabric/domains/analytics/charge.js +3 -0
  102. package/dist/fabric/domains/analytics/charge.js.map +1 -0
  103. package/dist/fabric/domains/analytics/utterance.cjs +4 -0
  104. package/dist/fabric/domains/analytics/utterance.cjs.map +1 -0
  105. package/dist/fabric/domains/analytics/utterance.d.cts +39 -0
  106. package/dist/fabric/domains/analytics/utterance.d.ts +39 -0
  107. package/dist/fabric/domains/analytics/utterance.js +3 -0
  108. package/dist/fabric/domains/analytics/utterance.js.map +1 -0
  109. package/dist/fabric/domains/phone/call.cjs +4 -0
  110. package/dist/fabric/domains/phone/call.cjs.map +1 -0
  111. package/dist/fabric/domains/phone/call.d.cts +7 -0
  112. package/dist/fabric/domains/phone/call.d.ts +7 -0
  113. package/dist/fabric/domains/phone/call.js +3 -0
  114. package/dist/fabric/domains/phone/call.js.map +1 -0
  115. package/dist/fabric/domains/phone/command.cjs +4 -0
  116. package/dist/fabric/domains/phone/command.cjs.map +1 -0
  117. package/dist/fabric/domains/phone/command.d.cts +142 -0
  118. package/dist/fabric/domains/phone/command.d.ts +142 -0
  119. package/dist/fabric/domains/phone/command.js +3 -0
  120. package/dist/fabric/domains/phone/command.js.map +1 -0
  121. package/dist/fabric/domains/phone/endpoint.cjs +4 -0
  122. package/dist/fabric/domains/phone/endpoint.cjs.map +1 -0
  123. package/dist/fabric/domains/phone/endpoint.d.cts +37 -0
  124. package/dist/fabric/domains/phone/endpoint.d.ts +37 -0
  125. package/dist/fabric/domains/phone/endpoint.js +3 -0
  126. package/dist/fabric/domains/phone/endpoint.js.map +1 -0
  127. package/dist/fabric/domains/phone/state.cjs +4 -0
  128. package/dist/fabric/domains/phone/state.cjs.map +1 -0
  129. package/dist/fabric/domains/phone/state.d.cts +42 -0
  130. package/dist/fabric/domains/phone/state.d.ts +42 -0
  131. package/dist/fabric/domains/phone/state.js +3 -0
  132. package/dist/fabric/domains/phone/state.js.map +1 -0
  133. package/dist/fabric/domains/workspace/business_hours.cjs +4 -0
  134. package/dist/fabric/domains/workspace/business_hours.cjs.map +1 -0
  135. package/dist/fabric/domains/workspace/business_hours.d.cts +65 -0
  136. package/dist/fabric/domains/workspace/business_hours.d.ts +65 -0
  137. package/dist/fabric/domains/workspace/business_hours.js +3 -0
  138. package/dist/fabric/domains/workspace/business_hours.js.map +1 -0
  139. package/dist/fabric/domains/workspace/channel.cjs +4 -0
  140. package/dist/fabric/domains/workspace/channel.cjs.map +1 -0
  141. package/dist/fabric/domains/workspace/channel.d.cts +103 -0
  142. package/dist/fabric/domains/workspace/channel.d.ts +103 -0
  143. package/dist/fabric/domains/workspace/channel.js +3 -0
  144. package/dist/fabric/domains/workspace/channel.js.map +1 -0
  145. package/dist/fabric/domains/workspace/channel_number.cjs +4 -0
  146. package/dist/fabric/domains/workspace/channel_number.cjs.map +1 -0
  147. package/dist/fabric/domains/workspace/channel_number.d.cts +53 -0
  148. package/dist/fabric/domains/workspace/channel_number.d.ts +53 -0
  149. package/dist/fabric/domains/workspace/channel_number.js +3 -0
  150. package/dist/fabric/domains/workspace/channel_number.js.map +1 -0
  151. package/dist/fabric/domains/workspace/channel_user.cjs +4 -0
  152. package/dist/fabric/domains/workspace/channel_user.cjs.map +1 -0
  153. package/dist/fabric/domains/workspace/channel_user.d.cts +23 -0
  154. package/dist/fabric/domains/workspace/channel_user.d.ts +23 -0
  155. package/dist/fabric/domains/workspace/channel_user.js +3 -0
  156. package/dist/fabric/domains/workspace/channel_user.js.map +1 -0
  157. package/dist/fabric/domains/workspace/chat.cjs +4 -0
  158. package/dist/fabric/domains/workspace/chat.cjs.map +1 -0
  159. package/dist/fabric/domains/workspace/chat.d.cts +43 -0
  160. package/dist/fabric/domains/workspace/chat.d.ts +43 -0
  161. package/dist/fabric/domains/workspace/chat.js +3 -0
  162. package/dist/fabric/domains/workspace/chat.js.map +1 -0
  163. package/dist/fabric/domains/workspace/chat_user.cjs +4 -0
  164. package/dist/fabric/domains/workspace/chat_user.cjs.map +1 -0
  165. package/dist/fabric/domains/workspace/chat_user.d.cts +23 -0
  166. package/dist/fabric/domains/workspace/chat_user.d.ts +23 -0
  167. package/dist/fabric/domains/workspace/chat_user.js +3 -0
  168. package/dist/fabric/domains/workspace/chat_user.js.map +1 -0
  169. package/dist/fabric/domains/workspace/communication.cjs +4 -0
  170. package/dist/fabric/domains/workspace/communication.cjs.map +1 -0
  171. package/dist/fabric/domains/workspace/communication.d.cts +112 -0
  172. package/dist/fabric/domains/workspace/communication.d.ts +112 -0
  173. package/dist/fabric/domains/workspace/communication.js +3 -0
  174. package/dist/fabric/domains/workspace/communication.js.map +1 -0
  175. package/dist/fabric/domains/workspace/company.cjs +4 -0
  176. package/dist/fabric/domains/workspace/company.cjs.map +1 -0
  177. package/dist/fabric/domains/workspace/company.d.cts +22 -0
  178. package/dist/fabric/domains/workspace/company.d.ts +22 -0
  179. package/dist/fabric/domains/workspace/company.js +3 -0
  180. package/dist/fabric/domains/workspace/company.js.map +1 -0
  181. package/dist/fabric/domains/workspace/contact.cjs +4 -0
  182. package/dist/fabric/domains/workspace/contact.cjs.map +1 -0
  183. package/dist/fabric/domains/workspace/contact.d.cts +50 -0
  184. package/dist/fabric/domains/workspace/contact.d.ts +50 -0
  185. package/dist/fabric/domains/workspace/contact.js +3 -0
  186. package/dist/fabric/domains/workspace/contact.js.map +1 -0
  187. package/dist/fabric/domains/workspace/contact_channel.cjs +4 -0
  188. package/dist/fabric/domains/workspace/contact_channel.cjs.map +1 -0
  189. package/dist/fabric/domains/workspace/contact_channel.d.cts +23 -0
  190. package/dist/fabric/domains/workspace/contact_channel.d.ts +23 -0
  191. package/dist/fabric/domains/workspace/contact_channel.js +3 -0
  192. package/dist/fabric/domains/workspace/contact_channel.js.map +1 -0
  193. package/dist/fabric/domains/workspace/contact_company.cjs +4 -0
  194. package/dist/fabric/domains/workspace/contact_company.cjs.map +1 -0
  195. package/dist/fabric/domains/workspace/contact_company.d.cts +22 -0
  196. package/dist/fabric/domains/workspace/contact_company.d.ts +22 -0
  197. package/dist/fabric/domains/workspace/contact_company.js +3 -0
  198. package/dist/fabric/domains/workspace/contact_company.js.map +1 -0
  199. package/dist/fabric/domains/workspace/domain.cjs +4 -0
  200. package/dist/fabric/domains/workspace/domain.cjs.map +1 -0
  201. package/dist/fabric/domains/workspace/domain.d.cts +21 -0
  202. package/dist/fabric/domains/workspace/domain.d.ts +21 -0
  203. package/dist/fabric/domains/workspace/domain.js +3 -0
  204. package/dist/fabric/domains/workspace/domain.js.map +1 -0
  205. package/dist/fabric/domains/workspace/file.cjs +4 -0
  206. package/dist/fabric/domains/workspace/file.cjs.map +1 -0
  207. package/dist/fabric/domains/workspace/file.d.cts +25 -0
  208. package/dist/fabric/domains/workspace/file.d.ts +25 -0
  209. package/dist/fabric/domains/workspace/file.js +3 -0
  210. package/dist/fabric/domains/workspace/file.js.map +1 -0
  211. package/dist/fabric/domains/workspace/integration.cjs +4 -0
  212. package/dist/fabric/domains/workspace/integration.cjs.map +1 -0
  213. package/dist/fabric/domains/workspace/integration.d.cts +36 -0
  214. package/dist/fabric/domains/workspace/integration.d.ts +36 -0
  215. package/dist/fabric/domains/workspace/integration.js +3 -0
  216. package/dist/fabric/domains/workspace/integration.js.map +1 -0
  217. package/dist/fabric/domains/workspace/integration_channel.cjs +4 -0
  218. package/dist/fabric/domains/workspace/integration_channel.cjs.map +1 -0
  219. package/dist/fabric/domains/workspace/integration_channel.d.cts +23 -0
  220. package/dist/fabric/domains/workspace/integration_channel.d.ts +23 -0
  221. package/dist/fabric/domains/workspace/integration_channel.js +3 -0
  222. package/dist/fabric/domains/workspace/integration_channel.js.map +1 -0
  223. package/dist/fabric/domains/workspace/invoice.cjs +4 -0
  224. package/dist/fabric/domains/workspace/invoice.cjs.map +1 -0
  225. package/dist/fabric/domains/workspace/invoice.d.cts +30 -0
  226. package/dist/fabric/domains/workspace/invoice.d.ts +30 -0
  227. package/dist/fabric/domains/workspace/invoice.js +3 -0
  228. package/dist/fabric/domains/workspace/invoice.js.map +1 -0
  229. package/dist/fabric/domains/workspace/payment_method.cjs +4 -0
  230. package/dist/fabric/domains/workspace/payment_method.cjs.map +1 -0
  231. package/dist/fabric/domains/workspace/payment_method.d.cts +26 -0
  232. package/dist/fabric/domains/workspace/payment_method.d.ts +26 -0
  233. package/dist/fabric/domains/workspace/payment_method.js +3 -0
  234. package/dist/fabric/domains/workspace/payment_method.js.map +1 -0
  235. package/dist/fabric/domains/workspace/phone.cjs +4 -0
  236. package/dist/fabric/domains/workspace/phone.cjs.map +1 -0
  237. package/dist/fabric/domains/workspace/phone.d.cts +36 -0
  238. package/dist/fabric/domains/workspace/phone.d.ts +36 -0
  239. package/dist/fabric/domains/workspace/phone.js +3 -0
  240. package/dist/fabric/domains/workspace/phone.js.map +1 -0
  241. package/dist/fabric/domains/workspace/phone_number.cjs +4 -0
  242. package/dist/fabric/domains/workspace/phone_number.cjs.map +1 -0
  243. package/dist/fabric/domains/workspace/phone_number.d.cts +178 -0
  244. package/dist/fabric/domains/workspace/phone_number.d.ts +178 -0
  245. package/dist/fabric/domains/workspace/phone_number.js +3 -0
  246. package/dist/fabric/domains/workspace/phone_number.js.map +1 -0
  247. package/dist/fabric/domains/workspace/prompt.cjs +4 -0
  248. package/dist/fabric/domains/workspace/prompt.cjs.map +1 -0
  249. package/dist/fabric/domains/workspace/prompt.d.cts +38 -0
  250. package/dist/fabric/domains/workspace/prompt.d.ts +38 -0
  251. package/dist/fabric/domains/workspace/prompt.js +3 -0
  252. package/dist/fabric/domains/workspace/prompt.js.map +1 -0
  253. package/dist/fabric/domains/workspace/sip_trunk.cjs +4 -0
  254. package/dist/fabric/domains/workspace/sip_trunk.cjs.map +1 -0
  255. package/dist/fabric/domains/workspace/sip_trunk.d.cts +31 -0
  256. package/dist/fabric/domains/workspace/sip_trunk.d.ts +31 -0
  257. package/dist/fabric/domains/workspace/sip_trunk.js +3 -0
  258. package/dist/fabric/domains/workspace/sip_trunk.js.map +1 -0
  259. package/dist/fabric/domains/workspace/subscription.cjs +4 -0
  260. package/dist/fabric/domains/workspace/subscription.cjs.map +1 -0
  261. package/dist/fabric/domains/workspace/subscription.d.cts +57 -0
  262. package/dist/fabric/domains/workspace/subscription.d.ts +57 -0
  263. package/dist/fabric/domains/workspace/subscription.js +3 -0
  264. package/dist/fabric/domains/workspace/subscription.js.map +1 -0
  265. package/dist/fabric/domains/workspace/tag.cjs +4 -0
  266. package/dist/fabric/domains/workspace/tag.cjs.map +1 -0
  267. package/dist/fabric/domains/workspace/tag.d.cts +23 -0
  268. package/dist/fabric/domains/workspace/tag.d.ts +23 -0
  269. package/dist/fabric/domains/workspace/tag.js +3 -0
  270. package/dist/fabric/domains/workspace/tag.js.map +1 -0
  271. package/dist/fabric/domains/workspace/thread.cjs +4 -0
  272. package/dist/fabric/domains/workspace/thread.cjs.map +1 -0
  273. package/dist/fabric/domains/workspace/thread.d.cts +45 -0
  274. package/dist/fabric/domains/workspace/thread.d.ts +45 -0
  275. package/dist/fabric/domains/workspace/thread.js +3 -0
  276. package/dist/fabric/domains/workspace/thread.js.map +1 -0
  277. package/dist/fabric/domains/workspace/user.cjs +4 -0
  278. package/dist/fabric/domains/workspace/user.cjs.map +1 -0
  279. package/dist/fabric/domains/workspace/user.d.cts +61 -0
  280. package/dist/fabric/domains/workspace/user.d.ts +61 -0
  281. package/dist/fabric/domains/workspace/user.js +3 -0
  282. package/dist/fabric/domains/workspace/user.js.map +1 -0
  283. package/dist/fabric/domains/workspace/voice.cjs +4 -0
  284. package/dist/fabric/domains/workspace/voice.cjs.map +1 -0
  285. package/dist/fabric/domains/workspace/voice.d.cts +43 -0
  286. package/dist/fabric/domains/workspace/voice.d.ts +43 -0
  287. package/dist/fabric/domains/workspace/voice.js +3 -0
  288. package/dist/fabric/domains/workspace/voice.js.map +1 -0
  289. package/dist/fabric/domains/workspace/workspace.cjs +4 -0
  290. package/dist/fabric/domains/workspace/workspace.cjs.map +1 -0
  291. package/dist/fabric/domains/workspace/workspace.d.cts +37 -0
  292. package/dist/fabric/domains/workspace/workspace.d.ts +37 -0
  293. package/dist/fabric/domains/workspace/workspace.js +3 -0
  294. package/dist/fabric/domains/workspace/workspace.js.map +1 -0
  295. package/dist/fabric/services/account/account.cjs +4 -0
  296. package/dist/fabric/services/account/account.cjs.map +1 -0
  297. package/dist/fabric/services/account/account.d.cts +24 -0
  298. package/dist/fabric/services/account/account.d.ts +24 -0
  299. package/dist/fabric/services/account/account.js +3 -0
  300. package/dist/fabric/services/account/account.js.map +1 -0
  301. package/dist/fabric/services/account/client.cjs +106 -0
  302. package/dist/fabric/services/account/client.cjs.map +1 -0
  303. package/dist/fabric/services/account/client.d.cts +28 -0
  304. package/dist/fabric/services/account/client.d.ts +28 -0
  305. package/dist/fabric/services/account/client.js +104 -0
  306. package/dist/fabric/services/account/client.js.map +1 -0
  307. package/dist/fabric/services/rest/client/analytics.cjs +212 -0
  308. package/dist/fabric/services/rest/client/analytics.cjs.map +1 -0
  309. package/dist/fabric/services/rest/client/analytics.d.cts +37 -0
  310. package/dist/fabric/services/rest/client/analytics.d.ts +37 -0
  311. package/dist/fabric/services/rest/client/analytics.js +206 -0
  312. package/dist/fabric/services/rest/client/analytics.js.map +1 -0
  313. package/dist/fabric/services/rest/client/base.cjs +135 -0
  314. package/dist/fabric/services/rest/client/base.cjs.map +1 -0
  315. package/dist/fabric/services/rest/client/base.d.cts +66 -0
  316. package/dist/fabric/services/rest/client/base.d.ts +66 -0
  317. package/dist/fabric/services/rest/client/base.js +129 -0
  318. package/dist/fabric/services/rest/client/base.js.map +1 -0
  319. package/dist/fabric/services/rest/client/business_hours.cjs +196 -0
  320. package/dist/fabric/services/rest/client/business_hours.cjs.map +1 -0
  321. package/dist/fabric/services/rest/client/business_hours.d.cts +20 -0
  322. package/dist/fabric/services/rest/client/business_hours.d.ts +20 -0
  323. package/dist/fabric/services/rest/client/business_hours.js +190 -0
  324. package/dist/fabric/services/rest/client/business_hours.js.map +1 -0
  325. package/dist/fabric/services/rest/client/channel_numbers.cjs +198 -0
  326. package/dist/fabric/services/rest/client/channel_numbers.cjs.map +1 -0
  327. package/dist/fabric/services/rest/client/channel_numbers.d.cts +20 -0
  328. package/dist/fabric/services/rest/client/channel_numbers.d.ts +20 -0
  329. package/dist/fabric/services/rest/client/channel_numbers.js +192 -0
  330. package/dist/fabric/services/rest/client/channel_numbers.js.map +1 -0
  331. package/dist/fabric/services/rest/client/channels.cjs +196 -0
  332. package/dist/fabric/services/rest/client/channels.cjs.map +1 -0
  333. package/dist/fabric/services/rest/client/channels.d.cts +26 -0
  334. package/dist/fabric/services/rest/client/channels.d.ts +26 -0
  335. package/dist/fabric/services/rest/client/channels.js +190 -0
  336. package/dist/fabric/services/rest/client/channels.js.map +1 -0
  337. package/dist/fabric/services/rest/client/domains.cjs +186 -0
  338. package/dist/fabric/services/rest/client/domains.cjs.map +1 -0
  339. package/dist/fabric/services/rest/client/domains.d.cts +19 -0
  340. package/dist/fabric/services/rest/client/domains.d.ts +19 -0
  341. package/dist/fabric/services/rest/client/domains.js +180 -0
  342. package/dist/fabric/services/rest/client/domains.js.map +1 -0
  343. package/dist/fabric/services/rest/client/files.cjs +183 -0
  344. package/dist/fabric/services/rest/client/files.cjs.map +1 -0
  345. package/dist/fabric/services/rest/client/files.d.cts +19 -0
  346. package/dist/fabric/services/rest/client/files.d.ts +19 -0
  347. package/dist/fabric/services/rest/client/files.js +177 -0
  348. package/dist/fabric/services/rest/client/files.js.map +1 -0
  349. package/dist/fabric/services/rest/client/invoices.cjs +171 -0
  350. package/dist/fabric/services/rest/client/invoices.cjs.map +1 -0
  351. package/dist/fabric/services/rest/client/invoices.d.cts +18 -0
  352. package/dist/fabric/services/rest/client/invoices.d.ts +18 -0
  353. package/dist/fabric/services/rest/client/invoices.js +165 -0
  354. package/dist/fabric/services/rest/client/invoices.js.map +1 -0
  355. package/dist/fabric/services/rest/client/payment_methods.cjs +189 -0
  356. package/dist/fabric/services/rest/client/payment_methods.cjs.map +1 -0
  357. package/dist/fabric/services/rest/client/payment_methods.d.cts +18 -0
  358. package/dist/fabric/services/rest/client/payment_methods.d.ts +18 -0
  359. package/dist/fabric/services/rest/client/payment_methods.js +183 -0
  360. package/dist/fabric/services/rest/client/payment_methods.js.map +1 -0
  361. package/dist/fabric/services/rest/client/phone_numbers.cjs +181 -0
  362. package/dist/fabric/services/rest/client/phone_numbers.cjs.map +1 -0
  363. package/dist/fabric/services/rest/client/phone_numbers.d.cts +20 -0
  364. package/dist/fabric/services/rest/client/phone_numbers.d.ts +20 -0
  365. package/dist/fabric/services/rest/client/phone_numbers.js +175 -0
  366. package/dist/fabric/services/rest/client/phone_numbers.js.map +1 -0
  367. package/dist/fabric/services/rest/client/phones.cjs +191 -0
  368. package/dist/fabric/services/rest/client/phones.cjs.map +1 -0
  369. package/dist/fabric/services/rest/client/phones.d.cts +21 -0
  370. package/dist/fabric/services/rest/client/phones.d.ts +21 -0
  371. package/dist/fabric/services/rest/client/phones.js +185 -0
  372. package/dist/fabric/services/rest/client/phones.js.map +1 -0
  373. package/dist/fabric/services/rest/client/prompts.cjs +189 -0
  374. package/dist/fabric/services/rest/client/prompts.cjs.map +1 -0
  375. package/dist/fabric/services/rest/client/prompts.d.cts +21 -0
  376. package/dist/fabric/services/rest/client/prompts.d.ts +21 -0
  377. package/dist/fabric/services/rest/client/prompts.js +183 -0
  378. package/dist/fabric/services/rest/client/prompts.js.map +1 -0
  379. package/dist/fabric/services/rest/client/subscriptions.cjs +159 -0
  380. package/dist/fabric/services/rest/client/subscriptions.cjs.map +1 -0
  381. package/dist/fabric/services/rest/client/subscriptions.d.cts +16 -0
  382. package/dist/fabric/services/rest/client/subscriptions.d.ts +16 -0
  383. package/dist/fabric/services/rest/client/subscriptions.js +153 -0
  384. package/dist/fabric/services/rest/client/subscriptions.js.map +1 -0
  385. package/dist/fabric/services/rest/client/tags.cjs +186 -0
  386. package/dist/fabric/services/rest/client/tags.cjs.map +1 -0
  387. package/dist/fabric/services/rest/client/tags.d.cts +19 -0
  388. package/dist/fabric/services/rest/client/tags.d.ts +19 -0
  389. package/dist/fabric/services/rest/client/tags.js +180 -0
  390. package/dist/fabric/services/rest/client/tags.js.map +1 -0
  391. package/dist/fabric/services/rest/client/users.cjs +186 -0
  392. package/dist/fabric/services/rest/client/users.cjs.map +1 -0
  393. package/dist/fabric/services/rest/client/users.d.cts +21 -0
  394. package/dist/fabric/services/rest/client/users.d.ts +21 -0
  395. package/dist/fabric/services/rest/client/users.js +180 -0
  396. package/dist/fabric/services/rest/client/users.js.map +1 -0
  397. package/dist/fabric/services/rest/client/voices.cjs +174 -0
  398. package/dist/fabric/services/rest/client/voices.cjs.map +1 -0
  399. package/dist/fabric/services/rest/client/voices.d.cts +17 -0
  400. package/dist/fabric/services/rest/client/voices.d.ts +17 -0
  401. package/dist/fabric/services/rest/client/voices.js +168 -0
  402. package/dist/fabric/services/rest/client/voices.js.map +1 -0
  403. package/dist/fabric/services/rest/client/workspace.cjs +171 -0
  404. package/dist/fabric/services/rest/client/workspace.cjs.map +1 -0
  405. package/dist/fabric/services/rest/client/workspace.d.cts +16 -0
  406. package/dist/fabric/services/rest/client/workspace.d.ts +16 -0
  407. package/dist/fabric/services/rest/client/workspace.js +165 -0
  408. package/dist/fabric/services/rest/client/workspace.js.map +1 -0
  409. package/dist/fabric/services/rest/client.cjs +1079 -0
  410. package/dist/fabric/services/rest/client.cjs.map +1 -0
  411. package/dist/fabric/services/rest/client.d.cts +105 -0
  412. package/dist/fabric/services/rest/client.d.ts +105 -0
  413. package/dist/fabric/services/rest/client.js +1070 -0
  414. package/dist/fabric/services/rest/client.js.map +1 -0
  415. package/dist/fabric/services/rest/dto/analytics.cjs +4 -0
  416. package/dist/fabric/services/rest/dto/analytics.cjs.map +1 -0
  417. package/dist/fabric/services/rest/dto/analytics.d.cts +11 -0
  418. package/dist/fabric/services/rest/dto/analytics.d.ts +11 -0
  419. package/dist/fabric/services/rest/dto/analytics.js +3 -0
  420. package/dist/fabric/services/rest/dto/analytics.js.map +1 -0
  421. package/dist/fabric/services/rest/dto/billing.cjs +4 -0
  422. package/dist/fabric/services/rest/dto/billing.cjs.map +1 -0
  423. package/dist/fabric/services/rest/dto/billing.d.cts +2 -0
  424. package/dist/fabric/services/rest/dto/billing.d.ts +2 -0
  425. package/dist/fabric/services/rest/dto/billing.js +3 -0
  426. package/dist/fabric/services/rest/dto/billing.js.map +1 -0
  427. package/dist/fabric/services/rest/dto/business_hours.cjs +91 -0
  428. package/dist/fabric/services/rest/dto/business_hours.cjs.map +1 -0
  429. package/dist/fabric/services/rest/dto/business_hours.d.cts +410 -0
  430. package/dist/fabric/services/rest/dto/business_hours.d.ts +410 -0
  431. package/dist/fabric/services/rest/dto/business_hours.js +81 -0
  432. package/dist/fabric/services/rest/dto/business_hours.js.map +1 -0
  433. package/dist/fabric/services/rest/dto/channel.cjs +76 -0
  434. package/dist/fabric/services/rest/dto/channel.cjs.map +1 -0
  435. package/dist/fabric/services/rest/dto/channel.d.cts +171 -0
  436. package/dist/fabric/services/rest/dto/channel.d.ts +171 -0
  437. package/dist/fabric/services/rest/dto/channel.js +65 -0
  438. package/dist/fabric/services/rest/dto/channel.js.map +1 -0
  439. package/dist/fabric/services/rest/dto/channel_number.cjs +20 -0
  440. package/dist/fabric/services/rest/dto/channel_number.cjs.map +1 -0
  441. package/dist/fabric/services/rest/dto/channel_number.d.cts +24 -0
  442. package/dist/fabric/services/rest/dto/channel_number.d.ts +24 -0
  443. package/dist/fabric/services/rest/dto/channel_number.js +17 -0
  444. package/dist/fabric/services/rest/dto/channel_number.js.map +1 -0
  445. package/dist/fabric/services/rest/dto/domain.cjs +14 -0
  446. package/dist/fabric/services/rest/dto/domain.cjs.map +1 -0
  447. package/dist/fabric/services/rest/dto/domain.d.cts +12 -0
  448. package/dist/fabric/services/rest/dto/domain.d.ts +12 -0
  449. package/dist/fabric/services/rest/dto/domain.js +11 -0
  450. package/dist/fabric/services/rest/dto/domain.js.map +1 -0
  451. package/dist/fabric/services/rest/dto/file.cjs +4 -0
  452. package/dist/fabric/services/rest/dto/file.cjs.map +1 -0
  453. package/dist/fabric/services/rest/dto/file.d.cts +9 -0
  454. package/dist/fabric/services/rest/dto/file.d.ts +9 -0
  455. package/dist/fabric/services/rest/dto/file.js +3 -0
  456. package/dist/fabric/services/rest/dto/file.js.map +1 -0
  457. package/dist/fabric/services/rest/dto/invoice.cjs +4 -0
  458. package/dist/fabric/services/rest/dto/invoice.cjs.map +1 -0
  459. package/dist/fabric/services/rest/dto/invoice.d.cts +5 -0
  460. package/dist/fabric/services/rest/dto/invoice.d.ts +5 -0
  461. package/dist/fabric/services/rest/dto/invoice.js +3 -0
  462. package/dist/fabric/services/rest/dto/invoice.js.map +1 -0
  463. package/dist/fabric/services/rest/dto/payment-method.cjs +4 -0
  464. package/dist/fabric/services/rest/dto/payment-method.cjs.map +1 -0
  465. package/dist/fabric/services/rest/dto/payment-method.d.cts +1 -0
  466. package/dist/fabric/services/rest/dto/payment-method.d.ts +1 -0
  467. package/dist/fabric/services/rest/dto/payment-method.js +3 -0
  468. package/dist/fabric/services/rest/dto/payment-method.js.map +1 -0
  469. package/dist/fabric/services/rest/dto/payment_method.cjs +4 -0
  470. package/dist/fabric/services/rest/dto/payment_method.cjs.map +1 -0
  471. package/dist/fabric/services/rest/dto/payment_method.d.cts +5 -0
  472. package/dist/fabric/services/rest/dto/payment_method.d.ts +5 -0
  473. package/dist/fabric/services/rest/dto/payment_method.js +3 -0
  474. package/dist/fabric/services/rest/dto/payment_method.js.map +1 -0
  475. package/dist/fabric/services/rest/dto/phone.cjs +37 -0
  476. package/dist/fabric/services/rest/dto/phone.cjs.map +1 -0
  477. package/dist/fabric/services/rest/dto/phone.d.cts +69 -0
  478. package/dist/fabric/services/rest/dto/phone.d.ts +69 -0
  479. package/dist/fabric/services/rest/dto/phone.js +32 -0
  480. package/dist/fabric/services/rest/dto/phone.js.map +1 -0
  481. package/dist/fabric/services/rest/dto/phone_number.cjs +15 -0
  482. package/dist/fabric/services/rest/dto/phone_number.cjs.map +1 -0
  483. package/dist/fabric/services/rest/dto/phone_number.d.cts +11 -0
  484. package/dist/fabric/services/rest/dto/phone_number.d.ts +11 -0
  485. package/dist/fabric/services/rest/dto/phone_number.js +12 -0
  486. package/dist/fabric/services/rest/dto/phone_number.js.map +1 -0
  487. package/dist/fabric/services/rest/dto/prompt.cjs +34 -0
  488. package/dist/fabric/services/rest/dto/prompt.cjs.map +1 -0
  489. package/dist/fabric/services/rest/dto/prompt.d.cts +62 -0
  490. package/dist/fabric/services/rest/dto/prompt.d.ts +62 -0
  491. package/dist/fabric/services/rest/dto/prompt.js +30 -0
  492. package/dist/fabric/services/rest/dto/prompt.js.map +1 -0
  493. package/dist/fabric/services/rest/dto/tag.cjs +25 -0
  494. package/dist/fabric/services/rest/dto/tag.cjs.map +1 -0
  495. package/dist/fabric/services/rest/dto/tag.d.cts +38 -0
  496. package/dist/fabric/services/rest/dto/tag.d.ts +38 -0
  497. package/dist/fabric/services/rest/dto/tag.js +21 -0
  498. package/dist/fabric/services/rest/dto/tag.js.map +1 -0
  499. package/dist/fabric/services/rest/dto/user.cjs +36 -0
  500. package/dist/fabric/services/rest/dto/user.cjs.map +1 -0
  501. package/dist/fabric/services/rest/dto/user.d.cts +76 -0
  502. package/dist/fabric/services/rest/dto/user.d.ts +76 -0
  503. package/dist/fabric/services/rest/dto/user.js +31 -0
  504. package/dist/fabric/services/rest/dto/user.js.map +1 -0
  505. package/dist/fabric/services/rest/dto/workspace.cjs +25 -0
  506. package/dist/fabric/services/rest/dto/workspace.cjs.map +1 -0
  507. package/dist/fabric/services/rest/dto/workspace.d.cts +50 -0
  508. package/dist/fabric/services/rest/dto/workspace.d.ts +50 -0
  509. package/dist/fabric/services/rest/dto/workspace.js +22 -0
  510. package/dist/fabric/services/rest/dto/workspace.js.map +1 -0
  511. package/dist/fabric/services/rest/errors.cjs +41 -0
  512. package/dist/fabric/services/rest/errors.cjs.map +1 -0
  513. package/dist/fabric/services/rest/errors.d.cts +12 -0
  514. package/dist/fabric/services/rest/errors.d.ts +12 -0
  515. package/dist/fabric/services/rest/errors.js +37 -0
  516. package/dist/fabric/services/rest/errors.js.map +1 -0
  517. package/dist/index.cjs +1336 -14
  518. package/dist/index.cjs.map +1 -1
  519. package/dist/index.d.cts +137 -6
  520. package/dist/index.d.ts +137 -6
  521. package/dist/index.js +1332 -14
  522. package/dist/index.js.map +1 -1
  523. package/package.json +10 -1
package/dist/index.cjs CHANGED
@@ -1,5 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ var MiniSearch = require('minisearch');
4
+ var nanostores = require('nanostores');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var MiniSearch__default = /*#__PURE__*/_interopDefault(MiniSearch);
9
+
3
10
  // src/errors.ts
4
11
  var AdminSdkError = class extends Error {
5
12
  constructor(message) {
@@ -42,36 +49,1355 @@ var RateLimitError = class extends ApiError {
42
49
  }
43
50
  };
44
51
 
52
+ // src/fabric/services/rest/errors.ts
53
+ var RestError = class extends Error {
54
+ status;
55
+ statusText;
56
+ body;
57
+ constructor(status, statusText, body) {
58
+ super(`HTTP ${status} ${statusText}: ${body ?? ""}`);
59
+ this.name = "RestError";
60
+ this.status = status;
61
+ this.statusText = statusText;
62
+ this.body = body;
63
+ Object.setPrototypeOf(this, new.target.prototype);
64
+ }
65
+ };
66
+ var NotFoundError2 = class extends RestError {
67
+ constructor(statusText = "Not Found", body) {
68
+ super(404, statusText, body);
69
+ this.name = "NotFoundError";
70
+ Object.setPrototypeOf(this, new.target.prototype);
71
+ }
72
+ };
73
+ function isNotFoundError(error) {
74
+ if (error instanceof NotFoundError2) {
75
+ return true;
76
+ }
77
+ if (error instanceof RestError && error.status === 404) {
78
+ return true;
79
+ }
80
+ if (typeof error === "object" && error !== null && error.status === 404) {
81
+ return true;
82
+ }
83
+ return false;
84
+ }
85
+
86
+ // src/fabric/services/account/client.ts
87
+ var AccountClient = class {
88
+ baseUrl;
89
+ accessToken;
90
+ fetchFn;
91
+ refreshPromise = null;
92
+ constructor(config) {
93
+ this.baseUrl = config.baseUrl.replace(/\/$/, "");
94
+ this.accessToken = config.accessToken;
95
+ this.fetchFn = config.fetch ?? globalThis.fetch.bind(globalThis);
96
+ }
97
+ getToken() {
98
+ return this.accessToken;
99
+ }
100
+ async refreshToken() {
101
+ if (this.refreshPromise) {
102
+ return this.refreshPromise;
103
+ }
104
+ this.refreshPromise = (async () => {
105
+ try {
106
+ const res = await this.fetchFn(`${this.baseUrl}/api/tokens`, {
107
+ method: "POST",
108
+ headers: {
109
+ Accept: "application/json"
110
+ },
111
+ credentials: "include"
112
+ });
113
+ if (!res.ok) {
114
+ const errorText = await res.text().catch(() => "");
115
+ throw new Error(
116
+ `Token refresh failed: HTTP ${res.status} ${res.statusText}: ${errorText}`
117
+ );
118
+ }
119
+ const body = await res.json();
120
+ this.accessToken = body.data.access_token;
121
+ return this.accessToken;
122
+ } finally {
123
+ this.refreshPromise = null;
124
+ }
125
+ })();
126
+ return this.refreshPromise;
127
+ }
128
+ async revokeToken() {
129
+ await this.fetchFn(`${this.baseUrl}/api/tokens`, {
130
+ method: "DELETE",
131
+ credentials: "include"
132
+ });
133
+ this.accessToken = "";
134
+ }
135
+ /**
136
+ * GET /api/account
137
+ * Fetches the currently authenticated account and associated workspaces.
138
+ * Automatically refreshes and retries once if a 401 Unauthorized is encountered.
139
+ */
140
+ async getAccount() {
141
+ const doFetch = (token) => this.fetchFn(`${this.baseUrl}/api/account`, {
142
+ method: "GET",
143
+ headers: {
144
+ Accept: "application/json",
145
+ Authorization: `Bearer ${token}`
146
+ }
147
+ });
148
+ let res = await doFetch(this.accessToken);
149
+ if (res.status === 401) {
150
+ const newToken = await this.refreshToken();
151
+ res = await doFetch(newToken);
152
+ }
153
+ if (!res.ok) {
154
+ const errorText = await res.text().catch(() => "");
155
+ if (res.status === 404) {
156
+ throw new NotFoundError2(res.statusText, errorText);
157
+ }
158
+ throw new RestError(res.status, res.statusText, errorText);
159
+ }
160
+ const json = await res.json();
161
+ return json.data;
162
+ }
163
+ };
164
+ var BaseResourceClient = class {
165
+ constructor(transport) {
166
+ this.transport = transport;
167
+ }
168
+ transport;
169
+ items = /* @__PURE__ */ new Map();
170
+ isLoaded = false;
171
+ searchIndex;
172
+ _version = nanostores.atom(1);
173
+ $version = this._version;
174
+ get version() {
175
+ return this._version.get();
176
+ }
177
+ get loaded() {
178
+ return this.isLoaded;
179
+ }
180
+ /**
181
+ * Returns all items currently stored in cache.
182
+ */
183
+ all() {
184
+ return Array.from(this.items.values());
185
+ }
186
+ /**
187
+ * Synchronously finds an item in cache by ID.
188
+ */
189
+ find(id) {
190
+ return this.items.get(id);
191
+ }
192
+ /**
193
+ * Synchronously finds multiple items in cache by ID.
194
+ */
195
+ getMany(...ids) {
196
+ const results = [];
197
+ for (const id of ids) {
198
+ const item = this.items.get(id);
199
+ if (item) results.push(item);
200
+ }
201
+ return results;
202
+ }
203
+ /**
204
+ * Searches cached items by search term using MiniSearch prefix matching.
205
+ * If search term is empty, returns all items.
206
+ */
207
+ search(term) {
208
+ const trimmed = term.trim();
209
+ if (!trimmed || !this.searchIndex) {
210
+ return this.all();
211
+ }
212
+ const results = this.searchIndex.search(trimmed, { prefix: true });
213
+ const matched = [];
214
+ for (const r of results) {
215
+ const item = this.items.get(r.id);
216
+ if (item) matched.push(item);
217
+ }
218
+ return matched;
219
+ }
220
+ /**
221
+ * Hook for subclasses to define what fields get indexed for search.
222
+ */
223
+ extractSearchTerms(item) {
224
+ return Object.values(item).filter((v) => typeof v === "string" || typeof v === "number").join(" ").toLowerCase();
225
+ }
226
+ /**
227
+ * Adds or replaces an item in the search index.
228
+ */
229
+ indexItem(item) {
230
+ if (!this.searchIndex) {
231
+ this.searchIndex = new MiniSearch__default.default({
232
+ fields: ["terms"],
233
+ storeFields: ["id"]
234
+ });
235
+ }
236
+ const doc = { id: item.id, terms: this.extractSearchTerms(item) };
237
+ if (this.searchIndex.has(item.id)) {
238
+ this.searchIndex.replace(doc);
239
+ } else {
240
+ this.searchIndex.add(doc);
241
+ }
242
+ }
243
+ /**
244
+ * Sets or updates a single item in cache and search index.
245
+ */
246
+ setItem(item) {
247
+ this.items.set(item.id, item);
248
+ this.indexItem(item);
249
+ }
250
+ /**
251
+ * Removes a single item from cache and search index.
252
+ */
253
+ removeItem(id) {
254
+ this.items.delete(id);
255
+ if (this.searchIndex?.has(id)) {
256
+ this.searchIndex.discard(id);
257
+ }
258
+ }
259
+ /**
260
+ * Populates cache and search index with all items, marking the client as loaded.
261
+ */
262
+ setAll(items) {
263
+ this.items.clear();
264
+ this.searchIndex?.removeAll();
265
+ for (const item of items) {
266
+ this.items.set(item.id, item);
267
+ this.indexItem(item);
268
+ }
269
+ this.isLoaded = true;
270
+ this.bump();
271
+ }
272
+ /**
273
+ * Clears the in-memory cache and search index.
274
+ */
275
+ clearCache() {
276
+ this.items.clear();
277
+ this.searchIndex?.removeAll();
278
+ this.isLoaded = false;
279
+ this.bump();
280
+ }
281
+ bump() {
282
+ this._version.set(this._version.get() + 1);
283
+ }
284
+ };
285
+
286
+ // src/fabric/services/rest/client/users.ts
287
+ var UsersClient = class extends BaseResourceClient {
288
+ extractSearchTerms(user) {
289
+ return `${user.first_name} ${user.last_name} ${user.display_name ?? ""} ${user.email} ${user.extension ?? ""}`.toLowerCase();
290
+ }
291
+ async listAll(force = false) {
292
+ if (this.isLoaded && !force) {
293
+ return this.all();
294
+ }
295
+ const users = await this.transport.requestData("/users");
296
+ this.setAll(users);
297
+ return users;
298
+ }
299
+ async load(force = false) {
300
+ return this.listAll(force);
301
+ }
302
+ async get(id, force = false) {
303
+ if (!force) {
304
+ const cached = this.find(id);
305
+ if (cached) return cached;
306
+ }
307
+ const user = await this.transport.requestData(`/users/${id}`);
308
+ this.setItem(user);
309
+ this.bump();
310
+ return user;
311
+ }
312
+ async create(data) {
313
+ const user = await this.transport.requestData("/users", {
314
+ method: "POST",
315
+ body: JSON.stringify(data)
316
+ });
317
+ this.setItem(user);
318
+ this.bump();
319
+ return user;
320
+ }
321
+ async update(id, data) {
322
+ const user = await this.transport.requestData(`/users/${id}`, {
323
+ method: "PATCH",
324
+ body: JSON.stringify(data)
325
+ });
326
+ this.setItem(user);
327
+ this.bump();
328
+ return user;
329
+ }
330
+ async delete(id) {
331
+ await this.transport.request(`/users/${id}`, { method: "DELETE" });
332
+ this.removeItem(id);
333
+ this.bump();
334
+ }
335
+ };
336
+
337
+ // src/fabric/services/rest/client/channels.ts
338
+ var ChannelsClient = class extends BaseResourceClient {
339
+ extractSearchTerms(channel) {
340
+ return `${channel.name}`.toLowerCase();
341
+ }
342
+ async listAll(force = false) {
343
+ if (this.isLoaded && !force) {
344
+ return this.all();
345
+ }
346
+ const channels = await this.transport.requestData("/channels");
347
+ this.setAll(channels);
348
+ return channels;
349
+ }
350
+ async load(force = false) {
351
+ return this.listAll(force);
352
+ }
353
+ async get(id, force = false) {
354
+ if (!force) {
355
+ const cached = this.find(id);
356
+ if (cached) return cached;
357
+ }
358
+ const channel = await this.transport.requestData(
359
+ `/channels/${id}`
360
+ );
361
+ this.setItem(channel);
362
+ this.bump();
363
+ return channel;
364
+ }
365
+ async create(data) {
366
+ const channel = await this.transport.requestData("/channels", {
367
+ method: "POST",
368
+ body: JSON.stringify(data)
369
+ });
370
+ this.setItem(channel);
371
+ this.bump();
372
+ return channel;
373
+ }
374
+ async update(id, data) {
375
+ const channel = await this.transport.requestData(
376
+ `/channels/${id}`,
377
+ {
378
+ method: "PATCH",
379
+ body: JSON.stringify(data)
380
+ }
381
+ );
382
+ this.setItem(channel);
383
+ this.bump();
384
+ return channel;
385
+ }
386
+ async delete(id) {
387
+ await this.transport.request(`/channels/${id}`, {
388
+ method: "DELETE"
389
+ });
390
+ this.removeItem(id);
391
+ this.bump();
392
+ }
393
+ publicChannels() {
394
+ return this.all().filter((c) => !c.is_private);
395
+ }
396
+ };
397
+
398
+ // src/fabric/services/rest/client/channel_numbers.ts
399
+ var ChannelNumbersClient = class extends BaseResourceClient {
400
+ extractSearchTerms(item) {
401
+ const rawCid = item.cid || "";
402
+ const cleanCid = rawCid.replace(/^\+/, "");
403
+ return `${item.name || ""} ${rawCid} ${cleanCid} ${item.label || ""} ${item.country || ""}`.toLowerCase();
404
+ }
405
+ async listAll(force = false) {
406
+ if (this.isLoaded && !force) {
407
+ return this.all();
408
+ }
409
+ const items = await this.transport.requestData("/channel-numbers");
410
+ this.setAll(items);
411
+ return items;
412
+ }
413
+ async load(force = false) {
414
+ return this.listAll(force);
415
+ }
416
+ async get(id, force = false) {
417
+ if (!force) {
418
+ const cached = this.find(id);
419
+ if (cached) return cached;
420
+ }
421
+ const item = await this.transport.requestData(
422
+ `/channel-numbers/${id}`
423
+ );
424
+ this.setItem(item);
425
+ this.bump();
426
+ return item;
427
+ }
428
+ async create(data) {
429
+ const channelNumber = await this.transport.requestData(
430
+ "/channel-numbers",
431
+ {
432
+ method: "POST",
433
+ body: JSON.stringify(data)
434
+ }
435
+ );
436
+ this.setItem(channelNumber);
437
+ this.bump();
438
+ return channelNumber;
439
+ }
440
+ async update(id, data) {
441
+ const channelNumber = await this.transport.requestData(
442
+ `/channel-numbers/${id}`,
443
+ {
444
+ method: "PATCH",
445
+ body: JSON.stringify(data)
446
+ }
447
+ );
448
+ this.setItem(channelNumber);
449
+ this.bump();
450
+ return channelNumber;
451
+ }
452
+ async delete(id) {
453
+ await this.transport.request(`/channel-numbers/${id}`, {
454
+ method: "DELETE"
455
+ });
456
+ this.removeItem(id);
457
+ this.bump();
458
+ }
459
+ };
460
+
461
+ // src/fabric/services/rest/client/phones.ts
462
+ var PhonesClient = class extends BaseResourceClient {
463
+ extractSearchTerms(item) {
464
+ const rawMac = item.mac_address || "";
465
+ const cleanMac = rawMac.replace(/[:-]/g, "");
466
+ return `${item.name} ${item.model} ${item.serial_number || ""} ${rawMac} ${cleanMac} ${item.location}`.toLowerCase();
467
+ }
468
+ async listAll(force = false) {
469
+ if (this.isLoaded && !force) {
470
+ return this.all();
471
+ }
472
+ const items = await this.transport.requestData("/phones");
473
+ this.setAll(items);
474
+ return items;
475
+ }
476
+ async load(force = false) {
477
+ return this.listAll(force);
478
+ }
479
+ async get(id, force = false) {
480
+ if (!force) {
481
+ const cached = this.find(id);
482
+ if (cached) return cached;
483
+ }
484
+ const item = await this.transport.requestData(`/phones/${id}`);
485
+ this.setItem(item);
486
+ this.bump();
487
+ return item;
488
+ }
489
+ getConfig(id) {
490
+ return this.transport.request(`/phones/${id}/config`);
491
+ }
492
+ async create(data) {
493
+ const item = await this.transport.requestData("/phones", {
494
+ method: "POST",
495
+ body: JSON.stringify(data)
496
+ });
497
+ this.setItem(item);
498
+ this.bump();
499
+ return item;
500
+ }
501
+ async update(id, data) {
502
+ const item = await this.transport.requestData(`/phones/${id}`, {
503
+ method: "PATCH",
504
+ body: JSON.stringify(data)
505
+ });
506
+ this.setItem(item);
507
+ this.bump();
508
+ return item;
509
+ }
510
+ async delete(id) {
511
+ await this.transport.request(`/phones/${id}`, { method: "DELETE" });
512
+ this.removeItem(id);
513
+ this.bump();
514
+ }
515
+ };
516
+
517
+ // src/fabric/services/rest/client/phone_numbers.ts
518
+ var PhoneNumbersClient = class extends BaseResourceClient {
519
+ extractSearchTerms(item) {
520
+ const rawStart = item.range_start || "";
521
+ const rawEnd = item.range_end || "";
522
+ const cleanStart = rawStart.replace(/^\+/, "");
523
+ const cleanEnd = rawEnd.replace(/^\+/, "");
524
+ return `${item.name} ${rawStart} ${cleanStart} ${rawEnd} ${cleanEnd} ${item.country}`.toLowerCase();
525
+ }
526
+ async listAll(force = false) {
527
+ if (this.isLoaded && !force) {
528
+ return this.all();
529
+ }
530
+ const items = await this.transport.requestData("/phone-numbers");
531
+ this.setAll(items);
532
+ return items;
533
+ }
534
+ async load(force = false) {
535
+ return this.listAll(force);
536
+ }
537
+ async get(id, force = false) {
538
+ if (!force) {
539
+ const cached = this.find(id);
540
+ if (cached) return cached;
541
+ }
542
+ const item = await this.transport.requestData(
543
+ `/phone-numbers/${id}`
544
+ );
545
+ this.setItem(item);
546
+ this.bump();
547
+ return item;
548
+ }
549
+ async update(id, data) {
550
+ const item = await this.transport.requestData(
551
+ `/phone-numbers/${id}`,
552
+ {
553
+ method: "PATCH",
554
+ body: JSON.stringify(data)
555
+ }
556
+ );
557
+ this.setItem(item);
558
+ this.bump();
559
+ return item;
560
+ }
561
+ };
562
+
563
+ // src/fabric/services/rest/client/business_hours.ts
564
+ var BusinessHoursClient = class extends BaseResourceClient {
565
+ extractSearchTerms(item) {
566
+ return `${item.name} ${item.timezone}`.toLowerCase();
567
+ }
568
+ async listAll(force = false) {
569
+ if (this.isLoaded && !force) {
570
+ return this.all();
571
+ }
572
+ const items = await this.transport.requestData("/business-hours");
573
+ this.setAll(items);
574
+ return items;
575
+ }
576
+ async load(force = false) {
577
+ return this.listAll(force);
578
+ }
579
+ async get(id, force = false) {
580
+ if (!force) {
581
+ const cached = this.find(id);
582
+ if (cached) return cached;
583
+ }
584
+ const item = await this.transport.requestData(
585
+ `/business-hours/${id}`
586
+ );
587
+ this.setItem(item);
588
+ this.bump();
589
+ return item;
590
+ }
591
+ async create(data) {
592
+ const item = await this.transport.requestData(
593
+ "/business-hours",
594
+ {
595
+ method: "POST",
596
+ body: JSON.stringify(data)
597
+ }
598
+ );
599
+ this.setItem(item);
600
+ this.bump();
601
+ return item;
602
+ }
603
+ async update(id, data) {
604
+ const item = await this.transport.requestData(
605
+ `/business-hours/${id}`,
606
+ {
607
+ method: "PATCH",
608
+ body: JSON.stringify(data)
609
+ }
610
+ );
611
+ this.setItem(item);
612
+ this.bump();
613
+ return item;
614
+ }
615
+ async delete(id) {
616
+ await this.transport.request(`/business-hours/${id}`, {
617
+ method: "DELETE"
618
+ });
619
+ this.removeItem(id);
620
+ this.bump();
621
+ }
622
+ };
623
+
624
+ // src/fabric/services/rest/client/tags.ts
625
+ var TagsClient = class extends BaseResourceClient {
626
+ extractSearchTerms(item) {
627
+ return `${item.name} ${item.color} ${item.scopes.join(" ")}`.toLowerCase();
628
+ }
629
+ async listAll(force = false) {
630
+ if (this.isLoaded && !force) {
631
+ return this.all();
632
+ }
633
+ const items = await this.transport.requestData("/tags");
634
+ this.setAll(items);
635
+ return items;
636
+ }
637
+ async load(force = false) {
638
+ return this.listAll(force);
639
+ }
640
+ async get(id, force = false) {
641
+ if (!force) {
642
+ const cached = this.find(id);
643
+ if (cached) return cached;
644
+ }
645
+ const item = await this.transport.requestData(`/tags/${id}`);
646
+ this.setItem(item);
647
+ this.bump();
648
+ return item;
649
+ }
650
+ async create(data) {
651
+ const tag = await this.transport.requestData("/tags", {
652
+ method: "POST",
653
+ body: JSON.stringify(data)
654
+ });
655
+ this.setItem(tag);
656
+ this.bump();
657
+ return tag;
658
+ }
659
+ async update(id, data) {
660
+ const tag = await this.transport.requestData(`/tags/${id}`, {
661
+ method: "PATCH",
662
+ body: JSON.stringify(data)
663
+ });
664
+ this.setItem(tag);
665
+ this.bump();
666
+ return tag;
667
+ }
668
+ async delete(id) {
669
+ await this.transport.request(`/tags/${id}`, { method: "DELETE" });
670
+ this.removeItem(id);
671
+ this.bump();
672
+ }
673
+ };
674
+
675
+ // src/fabric/services/rest/client/domains.ts
676
+ var DomainsClient = class extends BaseResourceClient {
677
+ extractSearchTerms(item) {
678
+ return item.domain.toLowerCase();
679
+ }
680
+ async listAll(force = false) {
681
+ if (this.isLoaded && !force) {
682
+ return this.all();
683
+ }
684
+ const items = await this.transport.requestData("/domains");
685
+ this.setAll(items);
686
+ return items;
687
+ }
688
+ async load(force = false) {
689
+ return this.listAll(force);
690
+ }
691
+ async get(id, force = false) {
692
+ if (!force) {
693
+ const cached = this.find(id);
694
+ if (cached) return cached;
695
+ }
696
+ const item = await this.transport.requestData(`/domains/${id}`);
697
+ this.setItem(item);
698
+ this.bump();
699
+ return item;
700
+ }
701
+ async create(data) {
702
+ const domain = await this.transport.requestData("/domains", {
703
+ method: "POST",
704
+ body: JSON.stringify(data)
705
+ });
706
+ this.setItem(domain);
707
+ this.bump();
708
+ return domain;
709
+ }
710
+ async update(id, data) {
711
+ const domain = await this.transport.requestData(`/domains/${id}`, {
712
+ method: "PATCH",
713
+ body: JSON.stringify(data)
714
+ });
715
+ this.setItem(domain);
716
+ this.bump();
717
+ return domain;
718
+ }
719
+ async delete(id) {
720
+ await this.transport.request(`/domains/${id}`, { method: "DELETE" });
721
+ this.removeItem(id);
722
+ this.bump();
723
+ }
724
+ };
725
+
726
+ // src/fabric/services/rest/client/workspace.ts
727
+ var WorkspaceClient = class extends BaseResourceClient {
728
+ cachedProfile = null;
729
+ async get(force = false) {
730
+ if (this.cachedProfile && !force) {
731
+ return this.cachedProfile;
732
+ }
733
+ const profile = await this.transport.requestData("/workspace");
734
+ this.cachedProfile = profile;
735
+ this.bump();
736
+ return profile;
737
+ }
738
+ async load(force = false) {
739
+ return this.get(force);
740
+ }
741
+ current() {
742
+ return this.cachedProfile;
743
+ }
744
+ async update(data) {
745
+ const profile = await this.transport.requestData(
746
+ "/workspace",
747
+ {
748
+ method: "PATCH",
749
+ body: JSON.stringify(data)
750
+ }
751
+ );
752
+ this.cachedProfile = profile;
753
+ this.bump();
754
+ return profile;
755
+ }
756
+ clearCache() {
757
+ super.clearCache();
758
+ this.cachedProfile = null;
759
+ }
760
+ };
761
+
762
+ // src/fabric/services/rest/client/files.ts
763
+ var FilesClient = class extends BaseResourceClient {
764
+ getDownloadLink(path) {
765
+ return this.transport.requestData(
766
+ "/files/link/download",
767
+ {
768
+ headers: { "X-File-Path": path }
769
+ }
770
+ );
771
+ }
772
+ getUploadLink(category, entityId, extension) {
773
+ const params = new URLSearchParams({ category });
774
+ if (entityId) params.append("entity_id", entityId);
775
+ if (extension) params.append("extension", extension);
776
+ return this.transport.requestData(
777
+ `/files/link/upload?${params.toString()}`
778
+ );
779
+ }
780
+ async uploadToS3(data, url) {
781
+ const response = await fetch(url, {
782
+ method: "PUT",
783
+ body: data
784
+ });
785
+ if (!response.ok) {
786
+ throw new Error(`S3 Upload failed: ${response.statusText}`);
787
+ }
788
+ }
789
+ async uploadBlob(blob, entityId, category = "track", extension = "wav") {
790
+ const { url, path } = await this.getUploadLink(
791
+ category,
792
+ entityId,
793
+ extension
794
+ );
795
+ await this.uploadToS3(blob, url);
796
+ return path;
797
+ }
798
+ async uploadTrack(file, entityId) {
799
+ const extension = file.name.split(".").pop()?.toLowerCase() || "wav";
800
+ const { url, path } = await this.getUploadLink(
801
+ "track",
802
+ entityId,
803
+ extension
804
+ );
805
+ await this.uploadToS3(file, url);
806
+ return { path, name: file.name };
807
+ }
808
+ };
809
+
810
+ // src/fabric/services/rest/client/prompts.ts
811
+ var PromptsClient = class extends BaseResourceClient {
812
+ extractSearchTerms(item) {
813
+ return `${item.name} ${item.entity_id}`.toLowerCase();
814
+ }
815
+ async listAll(force = false) {
816
+ if (this.isLoaded && !force) {
817
+ return this.all();
818
+ }
819
+ const items = await this.transport.requestData("/prompts");
820
+ this.setAll(items);
821
+ return items;
822
+ }
823
+ async load(force = false) {
824
+ return this.listAll(force);
825
+ }
826
+ listAllMy() {
827
+ return this.transport.requestData("/prompts/my");
828
+ }
829
+ async get(id, force = false) {
830
+ if (!force) {
831
+ const cached = this.find(id);
832
+ if (cached) return cached;
833
+ }
834
+ const item = await this.transport.requestData(`/prompts/${id}`);
835
+ this.setItem(item);
836
+ this.bump();
837
+ return item;
838
+ }
839
+ async create(data) {
840
+ const prompt = await this.transport.requestData("/prompts", {
841
+ method: "POST",
842
+ body: JSON.stringify(data)
843
+ });
844
+ this.setItem(prompt);
845
+ this.bump();
846
+ return prompt;
847
+ }
848
+ async update(id, data) {
849
+ const prompt = await this.transport.requestData(`/prompts/${id}`, {
850
+ method: "PATCH",
851
+ body: JSON.stringify(data)
852
+ });
853
+ this.setItem(prompt);
854
+ this.bump();
855
+ return prompt;
856
+ }
857
+ async delete(id) {
858
+ await this.transport.request(`/prompts/${id}`, { method: "DELETE" });
859
+ this.removeItem(id);
860
+ this.bump();
861
+ }
862
+ };
863
+
864
+ // src/fabric/services/rest/client/voices.ts
865
+ var VoicesClient = class extends BaseResourceClient {
866
+ extractSearchTerms(item) {
867
+ return `${item.name} ${item.language_code} ${item.gender} ${item.provider}`.toLowerCase();
868
+ }
869
+ async listAll(force = false) {
870
+ if (this.isLoaded && !force) {
871
+ return this.all();
872
+ }
873
+ const items = await this.transport.requestData("/voices");
874
+ this.setAll(items);
875
+ return items;
876
+ }
877
+ async load(force = false) {
878
+ return this.listAll(force);
879
+ }
880
+ async get(id, force = false) {
881
+ if (!force) {
882
+ const cached = this.find(id);
883
+ if (cached) return cached;
884
+ }
885
+ const item = await this.transport.requestData(`/voices/${id}`);
886
+ this.setItem(item);
887
+ this.bump();
888
+ return item;
889
+ }
890
+ voiceAgents() {
891
+ return this.all().filter(
892
+ (v) => v.scope.toLowerCase().replace(/[-_]/g, "") === "voiceagent"
893
+ );
894
+ }
895
+ synthesize(id, ssml) {
896
+ return this.transport.requestBlob(`/voices/${id}/tts/synthesize`, {
897
+ method: "POST",
898
+ body: JSON.stringify({ ssml })
899
+ });
900
+ }
901
+ };
902
+
903
+ // src/fabric/services/rest/client/invoices.ts
904
+ var InvoicesClient = class extends BaseResourceClient {
905
+ extractSearchTerms(item) {
906
+ return `${item.number} ${item.status}`.toLowerCase();
907
+ }
908
+ async listAll(force = false) {
909
+ if (this.isLoaded && !force) {
910
+ return this.all();
911
+ }
912
+ const items = await this.transport.requestData("/invoices");
913
+ this.setAll(items);
914
+ return items;
915
+ }
916
+ async load(force = false) {
917
+ return this.listAll(force);
918
+ }
919
+ async get(id, force = false) {
920
+ if (!force) {
921
+ const cached = this.find(id);
922
+ if (cached) return cached;
923
+ }
924
+ const item = await this.transport.requestData(`/invoices/${id}`);
925
+ this.setItem(item);
926
+ this.bump();
927
+ return item;
928
+ }
929
+ getPaymentUrl(id) {
930
+ return this.transport.request(
931
+ `/invoices/${id}/payment-url`
932
+ );
933
+ }
934
+ download(id) {
935
+ return this.transport.requestBlob(`/invoices/${id}/download`);
936
+ }
937
+ };
938
+
939
+ // src/fabric/services/rest/client/payment_methods.ts
940
+ var PaymentMethodsClient = class extends BaseResourceClient {
941
+ extractSearchTerms(item) {
942
+ return (item.last_four || item.last_four_digits || "").toLowerCase();
943
+ }
944
+ async listAll(force = false) {
945
+ if (this.isLoaded && !force) {
946
+ return this.all();
947
+ }
948
+ const items = await this.transport.requestData("/payment-methods");
949
+ this.setAll(items);
950
+ return items;
951
+ }
952
+ async load(force = false) {
953
+ return this.listAll(force);
954
+ }
955
+ async get(id, force = false) {
956
+ if (!force) {
957
+ const cached = this.find(id);
958
+ if (cached) return cached;
959
+ }
960
+ const item = await this.transport.requestData(
961
+ `/payment-methods/${id}`
962
+ );
963
+ this.setItem(item);
964
+ this.bump();
965
+ return item;
966
+ }
967
+ createUrl() {
968
+ return this.transport.request(
969
+ "/payment-methods/create-url"
970
+ );
971
+ }
972
+ async delete(id) {
973
+ await this.transport.request(`/payment-methods/${id}`, {
974
+ method: "DELETE"
975
+ });
976
+ this.removeItem(id);
977
+ this.bump();
978
+ }
979
+ async setAsPrimary(id) {
980
+ const paymentMethod = await this.transport.requestData(
981
+ `/payment-methods/${id}/set-as-primary`,
982
+ { method: "POST" }
983
+ );
984
+ for (const item of this.items.values()) {
985
+ item.is_primary = item.id === id;
986
+ }
987
+ this.setItem(paymentMethod);
988
+ this.bump();
989
+ return paymentMethod;
990
+ }
991
+ };
992
+
993
+ // src/fabric/services/rest/client/subscriptions.ts
994
+ var SubscriptionsClient = class extends BaseResourceClient {
995
+ cachedSubscription = null;
996
+ async get(force = false) {
997
+ if (this.cachedSubscription && !force) {
998
+ return this.cachedSubscription;
999
+ }
1000
+ const sub = await this.transport.requestData("/subscription");
1001
+ this.cachedSubscription = sub;
1002
+ this.bump();
1003
+ return sub;
1004
+ }
1005
+ async load(force = false) {
1006
+ return this.get(force);
1007
+ }
1008
+ current() {
1009
+ return this.cachedSubscription;
1010
+ }
1011
+ clearCache() {
1012
+ super.clearCache();
1013
+ this.cachedSubscription = null;
1014
+ }
1015
+ };
1016
+
1017
+ // src/fabric/services/rest/client/analytics.ts
1018
+ var AnalyticsClient = class extends BaseResourceClient {
1019
+ listCallLogs(params = {}) {
1020
+ const query = new URLSearchParams();
1021
+ if (params.from) query.append("from", params.from);
1022
+ if (params.to) query.append("to", params.to);
1023
+ if (params.page) query.append("page", String(params.page));
1024
+ if (params.per_page) query.append("per_page", String(params.per_page));
1025
+ if (params.status) {
1026
+ params.status.forEach((s) => query.append("status[]", s));
1027
+ }
1028
+ if (params.category) {
1029
+ params.category.forEach((c) => query.append("category[]", c));
1030
+ }
1031
+ if (params.user_id) {
1032
+ params.user_id.forEach((u) => query.append("user_id[]", u));
1033
+ }
1034
+ const qs = query.toString();
1035
+ const queryString = qs ? `?${qs}` : "";
1036
+ return this.transport.request(`/analytics/call-logs${queryString}`).catch((err) => {
1037
+ if (isNotFoundError(err)) {
1038
+ return this.transport.request(
1039
+ `/reports/call-logs${queryString}`
1040
+ );
1041
+ }
1042
+ throw err;
1043
+ });
1044
+ }
1045
+ async listCallEvents(callLogId) {
1046
+ return this.transport.requestData(`/analytics/call-logs/${callLogId}/events`).catch((err) => {
1047
+ if (isNotFoundError(err)) {
1048
+ return this.transport.requestData(
1049
+ `/reports/call-logs/${callLogId}/events`
1050
+ );
1051
+ }
1052
+ throw err;
1053
+ });
1054
+ }
1055
+ listCallUtterances(callLogId) {
1056
+ return this.transport.requestData(
1057
+ `/analytics/call-logs/${callLogId}/utterances`
1058
+ );
1059
+ }
1060
+ };
1061
+
1062
+ // src/fabric/services/rest/client.ts
1063
+ var WorkspaceRestClient = class {
1064
+ baseUrl;
1065
+ getAccessToken;
1066
+ getWorkspaceId;
1067
+ refreshAccessToken;
1068
+ fetchFn;
1069
+ refreshPromise = null;
1070
+ users;
1071
+ channels;
1072
+ channelNumbers;
1073
+ phones;
1074
+ phoneNumbers;
1075
+ businessHours;
1076
+ tags;
1077
+ domains;
1078
+ workspace;
1079
+ files;
1080
+ prompts;
1081
+ voices;
1082
+ invoices;
1083
+ paymentMethods;
1084
+ subscriptions;
1085
+ analytics;
1086
+ constructor(config) {
1087
+ this.baseUrl = config.baseUrl.replace(/\/+$/, "");
1088
+ this.getAccessToken = config.getAccessToken;
1089
+ this.getWorkspaceId = config.getWorkspaceId;
1090
+ this.refreshAccessToken = config.refreshAccessToken;
1091
+ this.fetchFn = config.fetch ?? globalThis.fetch.bind(globalThis);
1092
+ this.users = new UsersClient(this);
1093
+ this.channels = new ChannelsClient(this);
1094
+ this.channelNumbers = new ChannelNumbersClient(this);
1095
+ this.phones = new PhonesClient(this);
1096
+ this.phoneNumbers = new PhoneNumbersClient(this);
1097
+ this.businessHours = new BusinessHoursClient(this);
1098
+ this.tags = new TagsClient(this);
1099
+ this.domains = new DomainsClient(this);
1100
+ this.workspace = new WorkspaceClient(this);
1101
+ this.files = new FilesClient(this);
1102
+ this.prompts = new PromptsClient(this);
1103
+ this.voices = new VoicesClient(this);
1104
+ this.invoices = new InvoicesClient(this);
1105
+ this.paymentMethods = new PaymentMethodsClient(this);
1106
+ this.subscriptions = new SubscriptionsClient(this);
1107
+ this.analytics = new AnalyticsClient(this);
1108
+ }
1109
+ clearCaches() {
1110
+ this.users.clearCache();
1111
+ this.channels.clearCache();
1112
+ this.channelNumbers.clearCache();
1113
+ this.phones.clearCache();
1114
+ this.phoneNumbers.clearCache();
1115
+ this.businessHours.clearCache();
1116
+ this.tags.clearCache();
1117
+ this.domains.clearCache();
1118
+ this.workspace.clearCache();
1119
+ this.files.clearCache();
1120
+ this.prompts.clearCache();
1121
+ this.voices.clearCache();
1122
+ this.invoices.clearCache();
1123
+ this.paymentMethods.clearCache();
1124
+ this.subscriptions.clearCache();
1125
+ }
1126
+ async refreshToken() {
1127
+ if (!this.refreshAccessToken) {
1128
+ return void 0;
1129
+ }
1130
+ if (!this.refreshPromise) {
1131
+ this.refreshPromise = (async () => {
1132
+ try {
1133
+ return await this.refreshAccessToken();
1134
+ } finally {
1135
+ this.refreshPromise = null;
1136
+ }
1137
+ })();
1138
+ }
1139
+ return this.refreshPromise;
1140
+ }
1141
+ async execute(path, init = {}, overrideToken, isRetry = false) {
1142
+ const token = overrideToken ?? this.getAccessToken();
1143
+ const workspaceId = this.getWorkspaceId();
1144
+ const headers = {
1145
+ ...init.body && typeof init.body === "string" ? { "Content-Type": "application/json" } : {},
1146
+ ...token ? { Authorization: `Bearer ${token}` } : {},
1147
+ ...workspaceId ? { "X-Workspace-ID": workspaceId } : {},
1148
+ ...init.headers || {}
1149
+ };
1150
+ const res = await this.fetchFn(`${this.baseUrl}${path}`, {
1151
+ ...init,
1152
+ headers
1153
+ });
1154
+ if (res.status === 401 && !isRetry && this.refreshAccessToken) {
1155
+ try {
1156
+ const refreshedToken = await this.refreshToken();
1157
+ const nextToken = typeof refreshedToken === "string" && refreshedToken.length > 0 ? refreshedToken : void 0;
1158
+ return await this.execute(path, init, nextToken, true);
1159
+ } catch (refreshErr) {
1160
+ throw refreshErr;
1161
+ }
1162
+ }
1163
+ if (!res.ok) {
1164
+ const errorText = await res.text().catch(() => "");
1165
+ if (res.status === 404) {
1166
+ throw new NotFoundError2(res.statusText, errorText);
1167
+ }
1168
+ throw new RestError(res.status, res.statusText, errorText);
1169
+ }
1170
+ return res;
1171
+ }
1172
+ async request(path, init = {}) {
1173
+ const res = await this.execute(path, {
1174
+ ...init,
1175
+ headers: {
1176
+ Accept: "application/json",
1177
+ ...init.headers || {}
1178
+ }
1179
+ });
1180
+ if (res.status === 204) {
1181
+ return void 0;
1182
+ }
1183
+ return await res.json();
1184
+ }
1185
+ async requestData(path, init = {}) {
1186
+ const res = await this.request(path, init);
1187
+ return res.data;
1188
+ }
1189
+ async requestBlob(path, init = {}) {
1190
+ const res = await this.execute(path, init);
1191
+ return res.blob();
1192
+ }
1193
+ };
1194
+
45
1195
  // src/client.ts
46
- var DEFAULT_BASE_URL = "https://api.typecall.com/v1";
1196
+ var ENVIRONMENTS = {
1197
+ production: {
1198
+ api: "https://rest.typecall.com/",
1199
+ account: "https://account.typecall.com"
1200
+ },
1201
+ development: {
1202
+ api: "https://rest.typecall.dev/",
1203
+ account: "https://account.typecall.dev"
1204
+ }
1205
+ };
47
1206
  var DEFAULT_TIMEOUT_MS = 3e4;
48
1207
  var TypecallAdmin = class {
49
1208
  apiKey;
1209
+ accessToken;
1210
+ activeWorkspaceId;
1211
+ accountData;
50
1212
  baseUrl;
1213
+ accountUrl;
51
1214
  fetchFn;
52
1215
  timeoutMs;
53
1216
  defaultHeaders;
54
- constructor(options) {
55
- if (!options?.apiKey) {
1217
+ accountClient;
1218
+ restClient;
1219
+ constructor(options = {}) {
1220
+ if (options.apiKey !== void 0 && !options.apiKey.trim()) {
56
1221
  throw new AdminSdkError(
57
1222
  "An `apiKey` must be provided to initialize TypecallAdmin."
58
1223
  );
59
1224
  }
1225
+ const env = options.environment ?? "production";
1226
+ const envDefaults = ENVIRONMENTS[env] ?? ENVIRONMENTS.production;
60
1227
  this.apiKey = options.apiKey;
61
- this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
62
- this.fetchFn = options.fetch ?? globalThis.fetch;
63
- this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
64
- this.defaultHeaders = options.headers ?? {};
65
- if (!this.fetchFn) {
1228
+ this.accessToken = options.accessToken || void 0;
1229
+ this.baseUrl = (options.baseUrl ?? envDefaults.api).replace(/\/+$/, "");
1230
+ this.accountUrl = (options.accountUrl ?? envDefaults.account).replace(
1231
+ /\/+$/,
1232
+ ""
1233
+ );
1234
+ const rawFetch = options.fetch ?? globalThis.fetch;
1235
+ if (!rawFetch) {
66
1236
  throw new AdminSdkError(
67
1237
  "No global `fetch` found. Provide a custom `fetch` implementation in `AdminSdkOptions`."
68
1238
  );
69
1239
  }
1240
+ this.fetchFn = rawFetch.bind(globalThis);
1241
+ this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
1242
+ this.defaultHeaders = options.headers ?? {};
1243
+ this.accountClient = new AccountClient({
1244
+ baseUrl: this.accountUrl,
1245
+ accessToken: this.accessToken ?? "",
1246
+ fetch: this.fetchFn
1247
+ });
1248
+ this.restClient = new WorkspaceRestClient({
1249
+ baseUrl: this.baseUrl,
1250
+ getAccessToken: () => this.apiKey || this.accessToken || this.accountClient.getToken(),
1251
+ getWorkspaceId: () => this.activeWorkspaceId,
1252
+ refreshAccessToken: async () => {
1253
+ if (this.apiKey) return;
1254
+ const newToken = await this.accountClient.refreshToken();
1255
+ this.accessToken = newToken;
1256
+ return newToken;
1257
+ },
1258
+ fetch: this.fetchFn
1259
+ });
1260
+ }
1261
+ /**
1262
+ * Sets the active workspace ID for subsequent workspace-scoped requests.
1263
+ */
1264
+ setWorkspaceId(workspaceId) {
1265
+ if (this.activeWorkspaceId !== workspaceId) {
1266
+ this.activeWorkspaceId = workspaceId;
1267
+ this.restClient.clearCaches();
1268
+ }
1269
+ }
1270
+ /**
1271
+ * Returns the active workspace ID, if set.
1272
+ */
1273
+ getWorkspaceId() {
1274
+ return this.activeWorkspaceId;
1275
+ }
1276
+ get users() {
1277
+ return this.restClient.users;
1278
+ }
1279
+ get channels() {
1280
+ return this.restClient.channels;
1281
+ }
1282
+ get channelNumbers() {
1283
+ return this.restClient.channelNumbers;
1284
+ }
1285
+ get phones() {
1286
+ return this.restClient.phones;
1287
+ }
1288
+ get phoneNumbers() {
1289
+ return this.restClient.phoneNumbers;
1290
+ }
1291
+ get businessHours() {
1292
+ return this.restClient.businessHours;
1293
+ }
1294
+ get tags() {
1295
+ return this.restClient.tags;
1296
+ }
1297
+ get domains() {
1298
+ return this.restClient.domains;
1299
+ }
1300
+ get workspace() {
1301
+ return this.restClient.workspace;
1302
+ }
1303
+ get files() {
1304
+ return this.restClient.files;
1305
+ }
1306
+ get prompts() {
1307
+ return this.restClient.prompts;
1308
+ }
1309
+ get voices() {
1310
+ return this.restClient.voices;
1311
+ }
1312
+ get invoices() {
1313
+ return this.restClient.invoices;
1314
+ }
1315
+ get paymentMethods() {
1316
+ return this.restClient.paymentMethods;
1317
+ }
1318
+ get subscriptions() {
1319
+ return this.restClient.subscriptions;
1320
+ }
1321
+ get billing() {
1322
+ return {
1323
+ invoices: this.restClient.invoices,
1324
+ paymentMethods: this.restClient.paymentMethods,
1325
+ subscriptions: this.restClient.subscriptions
1326
+ };
1327
+ }
1328
+ get analytics() {
1329
+ return this.restClient.analytics;
1330
+ }
1331
+ /**
1332
+ * Returns the currently cached Account, if loaded.
1333
+ */
1334
+ get account() {
1335
+ return this.accountData;
1336
+ }
1337
+ /**
1338
+ * Updates the active access token and re-syncs the internal Account client.
1339
+ */
1340
+ setAccessToken(token) {
1341
+ this.accessToken = token;
1342
+ this.accountClient = new AccountClient({
1343
+ baseUrl: this.accountUrl,
1344
+ accessToken: token,
1345
+ fetch: this.fetchFn
1346
+ });
1347
+ }
1348
+ /**
1349
+ * Returns the active access token.
1350
+ */
1351
+ getAccessToken() {
1352
+ return this.accessToken || this.accountClient.getToken() || void 0;
1353
+ }
1354
+ async getAccount() {
1355
+ try {
1356
+ let account;
1357
+ if (this.accessToken) {
1358
+ try {
1359
+ account = await this.accountClient.getAccount();
1360
+ } catch (fetchErr) {
1361
+ const newToken = await this.accountClient.refreshToken();
1362
+ this.accessToken = newToken;
1363
+ account = await this.accountClient.getAccount();
1364
+ }
1365
+ } else {
1366
+ const newToken = await this.accountClient.refreshToken();
1367
+ this.accessToken = newToken;
1368
+ account = await this.accountClient.getAccount();
1369
+ }
1370
+ this.accountData = account;
1371
+ this.accessToken = this.accountClient.getToken();
1372
+ return account;
1373
+ } catch (err) {
1374
+ throw new AuthenticationError(
1375
+ "Authentication failed: unable to fetch account or refresh token",
1376
+ err instanceof Error ? err.message : err
1377
+ );
1378
+ }
1379
+ }
1380
+ /**
1381
+ * Signs out by revoking the current session and clearing internal state.
1382
+ */
1383
+ async logout() {
1384
+ try {
1385
+ await this.accountClient.revokeToken();
1386
+ } finally {
1387
+ this.accessToken = void 0;
1388
+ this.accountData = void 0;
1389
+ }
70
1390
  }
71
1391
  /**
72
1392
  * Helper to perform authenticated HTTP requests against the Typecall Admin API.
73
1393
  */
74
1394
  async request(path, options = {}) {
1395
+ const authHeader = this.apiKey ? `Bearer ${this.apiKey}` : this.accessToken ? `Bearer ${this.accessToken}` : null;
1396
+ if (!authHeader) {
1397
+ throw new AdminSdkError(
1398
+ "No authentication credentials available for this request."
1399
+ );
1400
+ }
75
1401
  const { query, headers = {}, ...init } = options;
76
1402
  const normalizedPath = path.startsWith("/") ? path : `/${path}`;
77
1403
  const url = new URL(`${this.baseUrl}${normalizedPath}`);
@@ -88,7 +1414,7 @@ var TypecallAdmin = class {
88
1414
  const response = await this.fetchFn(url.toString(), {
89
1415
  ...init,
90
1416
  headers: {
91
- Authorization: `Bearer ${this.apiKey}`,
1417
+ Authorization: authHeader,
92
1418
  "Content-Type": "application/json",
93
1419
  Accept: "application/json",
94
1420
  ...this.defaultHeaders,
@@ -118,11 +1444,7 @@ var TypecallAdmin = class {
118
1444
  );
119
1445
  }
120
1446
  default:
121
- throw new ApiError(
122
- response.status,
123
- response.statusText,
124
- errorBody
125
- );
1447
+ throw new ApiError(response.status, response.statusText, errorBody);
126
1448
  }
127
1449
  }
128
1450
  if (response.status === 204) {