@dugjason/front-node 0.1.0-beta.2 → 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 (303) hide show
  1. package/{LICENSE.md → LICENSE} +2 -2
  2. package/README.md +41 -258
  3. package/dist/index.cjs +2 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +11907 -0
  6. package/dist/index.d.cts.map +1 -0
  7. package/dist/index.d.mts +11907 -0
  8. package/dist/index.d.mts.map +1 -0
  9. package/dist/index.mjs +2 -0
  10. package/dist/index.mjs.map +1 -0
  11. package/package.json +67 -38
  12. package/dist/client.d.ts +0 -53
  13. package/dist/client.d.ts.map +0 -1
  14. package/dist/client.js +0 -230
  15. package/dist/client.js.map +0 -1
  16. package/dist/core/client.d.ts +0 -36
  17. package/dist/core/client.d.ts.map +0 -1
  18. package/dist/core/client.js +0 -89
  19. package/dist/core/client.js.map +0 -1
  20. package/dist/core/errors.d.ts +0 -55
  21. package/dist/core/errors.d.ts.map +0 -1
  22. package/dist/core/errors.js +0 -124
  23. package/dist/core/errors.js.map +0 -1
  24. package/dist/core/paginator.d.ts +0 -88
  25. package/dist/core/paginator.d.ts.map +0 -1
  26. package/dist/core/paginator.js +0 -129
  27. package/dist/core/paginator.js.map +0 -1
  28. package/dist/core/resource.d.ts +0 -143
  29. package/dist/core/resource.d.ts.map +0 -1
  30. package/dist/core/resource.js +0 -132
  31. package/dist/core/resource.js.map +0 -1
  32. package/dist/endpoints/accounts.d.ts +0 -34
  33. package/dist/endpoints/accounts.d.ts.map +0 -1
  34. package/dist/endpoints/accounts.js +0 -85
  35. package/dist/endpoints/accounts.js.map +0 -1
  36. package/dist/endpoints/analytics.d.ts +0 -32
  37. package/dist/endpoints/analytics.d.ts.map +0 -1
  38. package/dist/endpoints/analytics.js +0 -48
  39. package/dist/endpoints/analytics.js.map +0 -1
  40. package/dist/endpoints/applications.d.ts +0 -15
  41. package/dist/endpoints/applications.d.ts.map +0 -1
  42. package/dist/endpoints/applications.js +0 -17
  43. package/dist/endpoints/applications.js.map +0 -1
  44. package/dist/endpoints/attachments.d.ts +0 -8
  45. package/dist/endpoints/attachments.d.ts.map +0 -1
  46. package/dist/endpoints/attachments.js +0 -10
  47. package/dist/endpoints/attachments.js.map +0 -1
  48. package/dist/endpoints/channels.d.ts +0 -41
  49. package/dist/endpoints/channels.d.ts.map +0 -1
  50. package/dist/endpoints/channels.js +0 -64
  51. package/dist/endpoints/channels.js.map +0 -1
  52. package/dist/endpoints/comments.d.ts +0 -30
  53. package/dist/endpoints/comments.d.ts.map +0 -1
  54. package/dist/endpoints/comments.js +0 -45
  55. package/dist/endpoints/comments.js.map +0 -1
  56. package/dist/endpoints/contacts.d.ts +0 -46
  57. package/dist/endpoints/contacts.d.ts.map +0 -1
  58. package/dist/endpoints/contacts.js +0 -99
  59. package/dist/endpoints/contacts.js.map +0 -1
  60. package/dist/endpoints/conversations.d.ts +0 -77
  61. package/dist/endpoints/conversations.d.ts.map +0 -1
  62. package/dist/endpoints/conversations.js +0 -221
  63. package/dist/endpoints/conversations.js.map +0 -1
  64. package/dist/endpoints/drafts.d.ts +0 -12
  65. package/dist/endpoints/drafts.d.ts.map +0 -1
  66. package/dist/endpoints/drafts.js +0 -26
  67. package/dist/endpoints/drafts.js.map +0 -1
  68. package/dist/endpoints/events.d.ts +0 -13
  69. package/dist/endpoints/events.d.ts.map +0 -1
  70. package/dist/endpoints/events.js +0 -21
  71. package/dist/endpoints/events.js.map +0 -1
  72. package/dist/endpoints/inboxes.d.ts +0 -42
  73. package/dist/endpoints/inboxes.d.ts.map +0 -1
  74. package/dist/endpoints/inboxes.js +0 -83
  75. package/dist/endpoints/inboxes.js.map +0 -1
  76. package/dist/endpoints/knowledge-base-articles.d.ts +0 -8
  77. package/dist/endpoints/knowledge-base-articles.d.ts.map +0 -1
  78. package/dist/endpoints/knowledge-base-articles.js +0 -10
  79. package/dist/endpoints/knowledge-base-articles.js.map +0 -1
  80. package/dist/endpoints/knowledge-bases.d.ts +0 -50
  81. package/dist/endpoints/knowledge-bases.d.ts.map +0 -1
  82. package/dist/endpoints/knowledge-bases.js +0 -131
  83. package/dist/endpoints/knowledge-bases.js.map +0 -1
  84. package/dist/endpoints/links.d.ts +0 -30
  85. package/dist/endpoints/links.d.ts.map +0 -1
  86. package/dist/endpoints/links.js +0 -67
  87. package/dist/endpoints/links.js.map +0 -1
  88. package/dist/endpoints/message-template-folders.d.ts +0 -38
  89. package/dist/endpoints/message-template-folders.d.ts.map +0 -1
  90. package/dist/endpoints/message-template-folders.js +0 -114
  91. package/dist/endpoints/message-template-folders.js.map +0 -1
  92. package/dist/endpoints/message-templates.d.ts +0 -30
  93. package/dist/endpoints/message-templates.d.ts.map +0 -1
  94. package/dist/endpoints/message-templates.js +0 -69
  95. package/dist/endpoints/message-templates.js.map +0 -1
  96. package/dist/endpoints/messages.d.ts +0 -21
  97. package/dist/endpoints/messages.d.ts.map +0 -1
  98. package/dist/endpoints/messages.js +0 -31
  99. package/dist/endpoints/messages.js.map +0 -1
  100. package/dist/endpoints/rules.d.ts +0 -16
  101. package/dist/endpoints/rules.d.ts.map +0 -1
  102. package/dist/endpoints/rules.js +0 -21
  103. package/dist/endpoints/rules.js.map +0 -1
  104. package/dist/endpoints/shifts.d.ts +0 -46
  105. package/dist/endpoints/shifts.d.ts.map +0 -1
  106. package/dist/endpoints/shifts.js +0 -70
  107. package/dist/endpoints/shifts.js.map +0 -1
  108. package/dist/endpoints/signatures.d.ts +0 -36
  109. package/dist/endpoints/signatures.d.ts.map +0 -1
  110. package/dist/endpoints/signatures.js +0 -52
  111. package/dist/endpoints/signatures.js.map +0 -1
  112. package/dist/endpoints/statuses.d.ts +0 -15
  113. package/dist/endpoints/statuses.d.ts.map +0 -1
  114. package/dist/endpoints/statuses.js +0 -22
  115. package/dist/endpoints/statuses.js.map +0 -1
  116. package/dist/endpoints/tags.d.ts +0 -30
  117. package/dist/endpoints/tags.d.ts.map +0 -1
  118. package/dist/endpoints/tags.js +0 -49
  119. package/dist/endpoints/tags.js.map +0 -1
  120. package/dist/endpoints/teammate-groups.d.ts +0 -47
  121. package/dist/endpoints/teammate-groups.d.ts.map +0 -1
  122. package/dist/endpoints/teammate-groups.js +0 -101
  123. package/dist/endpoints/teammate-groups.js.map +0 -1
  124. package/dist/endpoints/teammates.d.ts +0 -28
  125. package/dist/endpoints/teammates.d.ts.map +0 -1
  126. package/dist/endpoints/teammates.js +0 -59
  127. package/dist/endpoints/teammates.js.map +0 -1
  128. package/dist/endpoints/teams.d.ts +0 -37
  129. package/dist/endpoints/teams.d.ts.map +0 -1
  130. package/dist/endpoints/teams.js +0 -79
  131. package/dist/endpoints/teams.js.map +0 -1
  132. package/dist/front.d.ts +0 -103
  133. package/dist/front.d.ts.map +0 -1
  134. package/dist/front.js +0 -162
  135. package/dist/front.js.map +0 -1
  136. package/dist/generated/client/client.gen.d.ts +0 -3
  137. package/dist/generated/client/client.gen.d.ts.map +0 -1
  138. package/dist/generated/client/client.gen.js +0 -204
  139. package/dist/generated/client/client.gen.js.map +0 -1
  140. package/dist/generated/client/index.d.ts +0 -8
  141. package/dist/generated/client/index.d.ts.map +0 -1
  142. package/dist/generated/client/index.js +0 -6
  143. package/dist/generated/client/index.js.map +0 -1
  144. package/dist/generated/client/types.gen.d.ts +0 -125
  145. package/dist/generated/client/types.gen.d.ts.map +0 -1
  146. package/dist/generated/client/types.gen.js +0 -3
  147. package/dist/generated/client/types.gen.js.map +0 -1
  148. package/dist/generated/client/utils.gen.d.ts +0 -39
  149. package/dist/generated/client/utils.gen.d.ts.map +0 -1
  150. package/dist/generated/client/utils.gen.js +0 -230
  151. package/dist/generated/client/utils.gen.js.map +0 -1
  152. package/dist/generated/client.gen.d.ts +0 -13
  153. package/dist/generated/client.gen.d.ts.map +0 -1
  154. package/dist/generated/client.gen.js +0 -6
  155. package/dist/generated/client.gen.js.map +0 -1
  156. package/dist/generated/core/auth.gen.d.ts +0 -19
  157. package/dist/generated/core/auth.gen.d.ts.map +0 -1
  158. package/dist/generated/core/auth.gen.js +0 -15
  159. package/dist/generated/core/auth.gen.js.map +0 -1
  160. package/dist/generated/core/bodySerializer.gen.d.ts +0 -18
  161. package/dist/generated/core/bodySerializer.gen.d.ts.map +0 -1
  162. package/dist/generated/core/bodySerializer.gen.js +0 -58
  163. package/dist/generated/core/bodySerializer.gen.js.map +0 -1
  164. package/dist/generated/core/params.gen.d.ts +0 -34
  165. package/dist/generated/core/params.gen.d.ts.map +0 -1
  166. package/dist/generated/core/params.gen.js +0 -89
  167. package/dist/generated/core/params.gen.js.map +0 -1
  168. package/dist/generated/core/pathSerializer.gen.d.ts +0 -34
  169. package/dist/generated/core/pathSerializer.gen.d.ts.map +0 -1
  170. package/dist/generated/core/pathSerializer.gen.js +0 -115
  171. package/dist/generated/core/pathSerializer.gen.js.map +0 -1
  172. package/dist/generated/core/serverSentEvents.gen.d.ts +0 -72
  173. package/dist/generated/core/serverSentEvents.gen.d.ts.map +0 -1
  174. package/dist/generated/core/serverSentEvents.gen.js +0 -136
  175. package/dist/generated/core/serverSentEvents.gen.js.map +0 -1
  176. package/dist/generated/core/types.gen.d.ts +0 -79
  177. package/dist/generated/core/types.gen.d.ts.map +0 -1
  178. package/dist/generated/core/types.gen.js +0 -3
  179. package/dist/generated/core/types.gen.js.map +0 -1
  180. package/dist/generated/core/utils.gen.d.ts +0 -15
  181. package/dist/generated/core/utils.gen.d.ts.map +0 -1
  182. package/dist/generated/core/utils.gen.js +0 -70
  183. package/dist/generated/core/utils.gen.js.map +0 -1
  184. package/dist/generated/sdk.gen.d.ts +0 -1292
  185. package/dist/generated/sdk.gen.d.ts.map +0 -1
  186. package/dist/generated/sdk.gen.js +0 -4202
  187. package/dist/generated/sdk.gen.js.map +0 -1
  188. package/dist/generated/types.gen.d.ts +0 -8492
  189. package/dist/generated/types.gen.d.ts.map +0 -1
  190. package/dist/generated/types.gen.js +0 -149
  191. package/dist/generated/types.gen.js.map +0 -1
  192. package/dist/index.d.ts +0 -28
  193. package/dist/index.d.ts.map +0 -1
  194. package/dist/index.js +0 -6
  195. package/dist/index.js.map +0 -1
  196. package/dist/oauth.d.ts +0 -28
  197. package/dist/oauth.d.ts.map +0 -1
  198. package/dist/oauth.js +0 -82
  199. package/dist/oauth.js.map +0 -1
  200. package/dist/resources/accounts.d.ts +0 -16
  201. package/dist/resources/accounts.d.ts.map +0 -1
  202. package/dist/resources/accounts.js +0 -37
  203. package/dist/resources/accounts.js.map +0 -1
  204. package/dist/resources/analytics.d.ts +0 -36
  205. package/dist/resources/analytics.d.ts.map +0 -1
  206. package/dist/resources/analytics.js +0 -82
  207. package/dist/resources/analytics.js.map +0 -1
  208. package/dist/resources/applications.d.ts +0 -9
  209. package/dist/resources/applications.d.ts.map +0 -1
  210. package/dist/resources/applications.js +0 -13
  211. package/dist/resources/applications.js.map +0 -1
  212. package/dist/resources/channels.d.ts +0 -18
  213. package/dist/resources/channels.d.ts.map +0 -1
  214. package/dist/resources/channels.js +0 -35
  215. package/dist/resources/channels.js.map +0 -1
  216. package/dist/resources/comments.d.ts +0 -18
  217. package/dist/resources/comments.d.ts.map +0 -1
  218. package/dist/resources/comments.js +0 -36
  219. package/dist/resources/comments.js.map +0 -1
  220. package/dist/resources/contacts.d.ts +0 -16
  221. package/dist/resources/contacts.d.ts.map +0 -1
  222. package/dist/resources/contacts.js +0 -37
  223. package/dist/resources/contacts.js.map +0 -1
  224. package/dist/resources/conversations.d.ts +0 -24
  225. package/dist/resources/conversations.d.ts.map +0 -1
  226. package/dist/resources/conversations.js +0 -55
  227. package/dist/resources/conversations.js.map +0 -1
  228. package/dist/resources/drafts.d.ts +0 -15
  229. package/dist/resources/drafts.d.ts.map +0 -1
  230. package/dist/resources/drafts.js +0 -34
  231. package/dist/resources/drafts.js.map +0 -1
  232. package/dist/resources/events.d.ts +0 -23
  233. package/dist/resources/events.d.ts.map +0 -1
  234. package/dist/resources/events.js +0 -28
  235. package/dist/resources/events.js.map +0 -1
  236. package/dist/resources/inboxes.d.ts +0 -12
  237. package/dist/resources/inboxes.d.ts.map +0 -1
  238. package/dist/resources/inboxes.js +0 -25
  239. package/dist/resources/inboxes.js.map +0 -1
  240. package/dist/resources/knowledge-base-articles.d.ts +0 -15
  241. package/dist/resources/knowledge-base-articles.d.ts.map +0 -1
  242. package/dist/resources/knowledge-base-articles.js +0 -34
  243. package/dist/resources/knowledge-base-articles.js.map +0 -1
  244. package/dist/resources/knowledge-base-categories.d.ts +0 -16
  245. package/dist/resources/knowledge-base-categories.d.ts.map +0 -1
  246. package/dist/resources/knowledge-base-categories.js +0 -37
  247. package/dist/resources/knowledge-base-categories.js.map +0 -1
  248. package/dist/resources/knowledge-bases.d.ts +0 -15
  249. package/dist/resources/knowledge-bases.d.ts.map +0 -1
  250. package/dist/resources/knowledge-bases.js +0 -35
  251. package/dist/resources/knowledge-bases.js.map +0 -1
  252. package/dist/resources/links.d.ts +0 -12
  253. package/dist/resources/links.d.ts.map +0 -1
  254. package/dist/resources/links.js +0 -25
  255. package/dist/resources/links.js.map +0 -1
  256. package/dist/resources/message-template-folders.d.ts +0 -13
  257. package/dist/resources/message-template-folders.d.ts.map +0 -1
  258. package/dist/resources/message-template-folders.js +0 -41
  259. package/dist/resources/message-template-folders.js.map +0 -1
  260. package/dist/resources/message-templates.d.ts +0 -16
  261. package/dist/resources/message-templates.d.ts.map +0 -1
  262. package/dist/resources/message-templates.js +0 -50
  263. package/dist/resources/message-templates.js.map +0 -1
  264. package/dist/resources/messages.d.ts +0 -36
  265. package/dist/resources/messages.d.ts.map +0 -1
  266. package/dist/resources/messages.js +0 -55
  267. package/dist/resources/messages.js.map +0 -1
  268. package/dist/resources/rules.d.ts +0 -11
  269. package/dist/resources/rules.d.ts.map +0 -1
  270. package/dist/resources/rules.js +0 -22
  271. package/dist/resources/rules.js.map +0 -1
  272. package/dist/resources/shifts.d.ts +0 -14
  273. package/dist/resources/shifts.d.ts.map +0 -1
  274. package/dist/resources/shifts.js +0 -31
  275. package/dist/resources/shifts.js.map +0 -1
  276. package/dist/resources/signatures.d.ts +0 -17
  277. package/dist/resources/signatures.d.ts.map +0 -1
  278. package/dist/resources/signatures.js +0 -51
  279. package/dist/resources/signatures.js.map +0 -1
  280. package/dist/resources/statuses.d.ts +0 -13
  281. package/dist/resources/statuses.d.ts.map +0 -1
  282. package/dist/resources/statuses.js +0 -28
  283. package/dist/resources/statuses.js.map +0 -1
  284. package/dist/resources/tags.d.ts +0 -17
  285. package/dist/resources/tags.d.ts.map +0 -1
  286. package/dist/resources/tags.js +0 -53
  287. package/dist/resources/tags.js.map +0 -1
  288. package/dist/resources/teammate-groups.d.ts +0 -17
  289. package/dist/resources/teammate-groups.d.ts.map +0 -1
  290. package/dist/resources/teammate-groups.js +0 -25
  291. package/dist/resources/teammate-groups.js.map +0 -1
  292. package/dist/resources/teammates.d.ts +0 -17
  293. package/dist/resources/teammates.d.ts.map +0 -1
  294. package/dist/resources/teammates.js +0 -40
  295. package/dist/resources/teammates.js.map +0 -1
  296. package/dist/resources/teams.d.ts +0 -11
  297. package/dist/resources/teams.d.ts.map +0 -1
  298. package/dist/resources/teams.js +0 -28
  299. package/dist/resources/teams.js.map +0 -1
  300. package/dist/types.d.ts +0 -46
  301. package/dist/types.d.ts.map +0 -1
  302. package/dist/types.js +0 -2
  303. package/dist/types.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 J.Dugdale
3
+ Copyright (c) 2026 Jason Dugdale
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,283 +1,66 @@
1
- # Front Node.js SDK
1
+ # front-node
2
2
 
3
- A modern TypeScript SDK for the [Front.com API](https://dev.frontapp.com/reference/introduction). This SDK provides a clean, intuitive interface for interacting with Front's customer operations platform.
3
+ A modern TypeScript SDK for the [Front](https://front.com) API.
4
4
 
5
- ## Installation
5
+ ## Install
6
6
 
7
7
  ```bash
8
8
  npm install @dugjason/front-node
9
- # or
10
- pnpm add @dugjason/front-node
11
9
  ```
12
10
 
13
- ## Quick Start
11
+ ## Usage
14
12
 
15
- ```typescript
16
- import { Front } from " @dugjason/front-node"
13
+ ```ts
14
+ import { Front } from "@dugjason/front-node";
17
15
 
18
- // Initialize with API key (required)
19
- const front = new Front({ apiKey: "your-api-key" })
16
+ const front = new Front({ apiKey: process.env.FRONT_API_TOKEN });
20
17
 
21
- // Get token details
22
- const tokenInfo = await front.me()
18
+ const teammates = await front.teammates.list();
23
19
 
24
- // Fetch a conversation
25
- const { conversation } = await front.conversations.fetch("cnv_12345")
26
-
27
- // List teammates
28
- const { teammates } = await front.teammates.list()
29
-
30
- // Update a teammate
31
- await front.teammates.update(teammates[0].id, {
32
- is_available: true
33
- })
34
- ```
35
-
36
- ## Authentication
37
-
38
- The SDK supports two authentication methods:
39
-
40
- ### 1. OAuth (Recommended for Production)
41
-
42
- OAuth provides automatic token refresh and is required for public integrations:
43
-
44
- ```typescript
45
- const front = new Front({
46
- oauth: {
47
- clientId: "your-oauth-client-id",
48
- clientSecret: "your-oauth-client-secret",
49
- accessToken: "your-current-access-token",
50
- refreshToken: "your-refresh-token",
51
-
52
- // Optional: Called when tokens are refreshed
53
- onTokenRefresh: async (tokens) => {
54
- // Save new tokens to your database
55
- await saveTokensToDatabase(tokens)
56
- }
57
- }
58
- })
59
- ```
60
-
61
- The SDK automatically refreshes tokens when they expire (Front issues OAuth access tokens with a 1hr TTL) and calls your `onTokenRefresh` callback with the new tokens.
62
-
63
- ### 2. API Key (Simple Setup)
64
-
65
- For testing or single-instance usage:
66
-
67
- ```typescript
68
- // Specify your API key when initializing the client
69
- const front = new Front({ apiKey: "your-api-key" })
70
-
71
- // Or omit the auth, and we'll load it from `process.env.FRONT_API_KEY` automatically
72
- const front = new Front()
73
- ```
74
-
75
- ## Response Signature
76
-
77
- All requests have similar return object structure.
78
- The response will contain;
79
- * a `response` object containing the raw response from the API
80
- * the returned object(s) as either an object, list or an iterable list
81
-
82
- ### Single Object Responses
83
-
84
- In cases where we're creating or fetching a single resource the response will contain an object matching the name of the resource. For example;
85
- ```typescript
86
- const { tag } = front.tags.create({ ... })
87
- ```
88
-
89
- ### List Responses
90
-
91
- For lists of resources, we return a `page` containing `items`.
92
- In some cases the Front API only returns a single page of resources (no pagination), but in others you can use the iterator to page through all results;
93
-
94
- ```typescript
95
- const { page } = await front.accounts.list()
96
- for (const account of page.items) {
97
- await doSomething(account)
98
- }
99
- ```
100
-
101
- ## Resource Classes
102
-
103
- Resources are returned as instances of classes, such as a `Teammate` or `Message`. This allows us to support class instance methods such as `.update()` or .delete() methods on class resources.
104
- For example, we can fetch a tag then update it;
105
-
106
- ```typescript
107
- // Fetch the tag
108
- let { tag } = await front.tags.get(tagId)
109
-
110
- // Then we can update it either using the class instance
111
- tag = await tag.update({ highlight: "red" })
112
- // or using the same `front.tags...` method
113
- tag = await front.tags.update(tagId, { highlight: "red" })
114
- ```
115
-
116
- ## API Reference
117
-
118
- ### Token Identity
119
-
120
- ```typescript
121
- // Get details about the current API token
122
- const tokenInfo = await front.me()
123
- console.log("Company name:", tokenInfo.name) // Company name
124
- console.log("Company ID:", tokenInfo.id) // Company ID (e.g., 'cmp_123')
125
- ```
126
-
127
- ### Conversations
128
-
129
- ```typescript
130
- // List conversations
131
- const { page: conversations } = await front.conversations.list({
132
- q: "status:unassigned"
133
- limit: 50,
134
- })
135
-
136
- // Fetch a specific conversation
137
- const { conversation } = await front.conversations.fetch("cnv_123")
138
-
139
- // Update a conversation
140
- await front.conversations.update("cnv_123", {
141
- status: "archived"
142
- })
143
-
144
- // Get conversation messages
145
- const { page: messages } = await front.conversations.listMessages("cnv_123")
146
-
147
- // Get conversation events
148
- const { page: events } = await front.conversations.listEvents("cnv_123")
149
- ```
150
-
151
- ### Teammates
152
-
153
- ```typescript
154
- // List all teammates
155
- const { page: teammates } = await front.teammates.list()
156
-
157
- // Fetch a specific teammate
158
- const { teammate } = await front.teammates.fetch("tea_123")
159
-
160
- // Update a teammate
161
- await front.teammates.update("tea_123", {
162
- first_name: "John",
163
- last_name: "Doe",
164
- is_available: true
165
- })
166
- ```
167
-
168
- ### Drafts
169
-
170
- The drafts API allows you to create, edit, list, and delete draft messages. Drafts can be created as new conversations or as replies to existing conversations.
171
-
172
- ```typescript
173
- // Create a new draft in a channel (starts a new conversation)
174
- const { draft } = await front.drafts.create("cha_123", {
175
- body: "This is a new draft message",
176
- subject: "Draft Subject",
20
+ // ID-scoped operations do not require fetching the resource first.
21
+ await front.channels.createMessage("cha_123", {
22
+ body: "Hello from Front",
23
+ options: { archive: true },
177
24
  to: ["customer@example.com"],
178
- cc: ["manager@company.com"],
179
- author_id: "tea_123",
180
- mode: "private", // 'private' or 'shared'
181
- should_add_default_signature: true
182
- })
183
-
184
- // Create a draft reply to an existing conversation
185
- const { draft: reply } = await front.drafts.createReply("cnv_123", {
186
- body: "This is a draft reply",
187
- channel_id: "cha_123",
188
- author_id: "tea_123",
189
- mode: "shared"
190
- })
25
+ });
26
+ await front.conversations.addTag("cnv_123", { tag_ids: ["tag_123"] });
27
+ await front.messages.markSeen("msg_123");
191
28
  ```
192
29
 
193
- ## Error Handling
194
-
195
- The SDK throws structured errors with helpful information:
30
+ ## Development
196
31
 
197
- ```typescript
198
- try {
199
- const { conversation } = await front.conversations.fetch("invalid-id")
200
- } catch (error) {
201
- if (error instanceof FrontError) {
202
- console.error("Status:", error.status)
203
- console.error("Message:", error.message)
204
- console.error("Code:", error.code)
205
- }
206
- }
32
+ ```bash
33
+ bun install
34
+ bun test
35
+ bun run check
207
36
  ```
208
37
 
209
- ## TypeScript Support
210
-
211
- The SDK is built with TypeScript and provides full type definitions:
38
+ ## Release
212
39
 
213
- ```typescript
214
- import { Front, type Account, type Contact } from "@dugjason/front-node"
40
+ Releases are managed by Changesets. Add a changeset for user-facing changes:
215
41
 
216
- const front = new Front({ apiKey: "your-api-key" })
217
-
218
- // Full type safety
219
- let account: Account
220
- let contacts: Array<Contact>
221
- const accountRes = await front.accounts.fetch("acc_123")
222
- account = accountRes.account
223
- const contactsRes = front.accounts.listContacts("acc_123")
224
- contacts = contactsRes.page.items
42
+ ```bash
43
+ bun run changeset
225
44
  ```
226
45
 
227
- ## Pagination
228
-
229
- The SDK supports robust pagination using iterators.
230
-
231
- ## Releases
232
-
233
- This package uses automated publishing with manual version management. When changes are merged to the main branch, the current version in `package.json` is automatically published to npm.
234
-
235
- ### Release Process
46
+ Merging to `main` opens or updates a version PR. Merging that version PR publishes
47
+ to npm as `@dugjason/front-node` through npm trusted publishing.
236
48
 
237
- 1. **Version Management**: Version bumps are handled manually using semantic versioning:
238
- - **Patch** (`1.0.0` → `1.0.1`): Bug fixes, documentation updates, refactoring
239
- - **Minor** (`1.0.0` → `1.1.0`): New features, enhancements
240
- - **Major** (`1.0.0` → `2.0.0`): Breaking changes
49
+ ## Custom `fetch`
241
50
 
242
- 2. **How to Release**:
243
- ```bash
244
- # Bump version using pnpm (recommended)
245
- pnpm version patch # for bug fixes
246
- pnpm version minor # for new features
247
- pnpm version major # for breaking changes
248
-
249
- # Or manually edit package.json and create a git tag
250
- git tag v1.2.3
251
-
252
- # Push changes and tags
253
- git push origin main --tags
254
- ```
51
+ You can use the library with a custom fetch library, compatible with `node:fetch`.
52
+ An illustrative example could be a fetch implementation with built-in tracing or custom telemetry;
255
53
 
256
- 3. **What Happens on Push to Main**:
257
- - Tests run on Node.js 20 and 22
258
- - Code is linted with Biome
259
- - TypeScript compilation is verified
260
- - Package is published to npm using the current `package.json` version
261
- - GitHub release is created with the current version tag
54
+ ```ts
55
+ import { Front } from "@dugjason/front-node";
262
56
 
263
- ### Development Workflow
264
-
265
- 1. Create feature branch from `main`
266
- 2. Make changes and commit
267
- 3. Open Pull Request
268
- 4. After review and merge to `main`:
269
- - If you want to publish: bump version first, then merge
270
- - If not ready to publish: merge without version bump
271
-
272
- ## Requirements
273
-
274
- - Node.js 18.0.0 or higher (for native fetch support)
275
- - TypeScript 5.0+ (if using TypeScript)
276
-
277
- ## License
278
-
279
- ISC
280
-
281
- ## Contributing
282
-
283
- Contributions are welcome! Please feel free to submit a Pull Request.
57
+ const loggingFetch: typeof fetch = async (input, init) => {
58
+ const t0 = performance.now();
59
+ const response = await globalThis.fetch(input, init);
60
+ console.log(
61
+ `${init?.method ?? "GET"} ${input} ${response.status} ${Math.round(performance.now() - t0)}ms`,
62
+ );
63
+ return response;
64
+ };
65
+ const front = new Front({ fetch: loggingFetch });
66
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`@dugjason/front-node`,t=`0.2.0`,n=class extends Error{status;headers;response;body;constructor(e,t){super(`Front API error: ${e.status} ${e.statusText}`),this.name=`FrontApiError`,this.status=e.status,this.headers=e.headers,this.response=e,this.body=t}};const r=e=>{if(!e)return null;try{let t=new URL(e).searchParams.get(`page_token`);if(t!==null&&t!==``)return t}catch{return null}return null},i=e=>{if(typeof e!=`object`||!e||Array.isArray(e))return e;let t=e,n={};for(let[e,i]of Object.entries(t)){if(e===`_pagination`){if(typeof i==`object`&&i&&!Array.isArray(i)){let e=i,t=e.next,a=typeof t==`string`?r(t):t;n.pagination={...e,next:a}}continue}n[e]=i}return n},a=`${e}@${t}`,o=/\/$/u,s=(e,t)=>`${e.replace(o,``)}${t.startsWith(`/`)?t:`/${t}`}`,c=(e,t)=>{if(!t)return e;let n=new URLSearchParams;for(let[e,r]of Object.entries(t))r!==void 0&&n.set(e,r);let r=n.toString();return r.length>0?`${e}?${r}`:e};var l=class{apiKey;baseUrl;fetchImpl;userAgent;constructor(e){this.apiKey=e.apiKey,this.baseUrl=e.baseUrl??`https://api2.frontapp.com`,this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.userAgent=e.userAgent??a}buildUrl(e,t){return c(s(this.baseUrl,e),t)}static expandPath(e,t){let n=e;for(let[e,r]of Object.entries(t))n=n.replace(`{${e}}`,encodeURIComponent(r));if(n.includes(`{`))throw Error(`Unresolved path template: ${e} → ${n}`);return n}async requestJson(e,t,r){let a=this.buildUrl(t,r?.query),o=new Headers({Accept:`application/json`,Authorization:`Bearer ${this.apiKey}`,"User-Agent":this.userAgent});r?.body!==void 0&&o.set(`Content-Type`,`application/json`);let s=await this.fetchImpl(a,{body:r?.body===void 0?void 0:JSON.stringify(r.body),headers:o,method:e});if(!s.ok){let e,t=await s.text();try{e=JSON.parse(t)}catch{e=t}throw new n(s,e)}if(s.status===204)return;let c=await s.text();if(c.length===0)return;let l=JSON.parse(c);return i(l)}async requestWithoutParsingBody(e,t,r){let i=this.buildUrl(t,r?.query),a=new Headers({Accept:`*/*`,Authorization:`Bearer ${this.apiKey}`,"User-Agent":this.userAgent});if(r?.headers!==void 0)for(let[e,t]of Object.entries(r.headers))t!==void 0&&a.set(e,t);let o=await this.fetchImpl(i,{headers:a,method:e});if(!o.ok){let e,t=await o.text();try{e=JSON.parse(t)}catch{e=t}throw new n(o,e)}return o}},u=class{state;base;stateLoaded;resourceId;constructor(e,t,n){this.base=e,this.stateLoaded=t!==void 0,t!==void 0&&(this.state=structuredClone(t)),this.resourceId=n}get id(){let e=(this.stateLoaded?this.state.id:void 0)??this.resourceId;if(e===void 0)throw Error(`This resource operation requires an ID.`);return e}get links(){return this.requireState()._links}set links(e){this.assign(`_links`,e)}get data(){return this.requireState()}pick(e){return this.requireState()[e]}assign(e,t){this.state={...this.requireState(),[e]:t}}replaceState(e){this.state=structuredClone(e),this.stateLoaded=!0}hasState(){return this.stateLoaded}requireState(){if(!this.stateLoaded)throw Error(`This resource operation requires fetched resource data.`);return this.state}onAfterRefresh(){}async refresh(){let e=await this.base.requestJson(`GET`,this.selfPath());return this.replaceState(e),this.onAfterRefresh(),this}async delete(){await this.base.requestJson(`DELETE`,this.selfPath())}async patchNoContent(e,t){await this.base.requestJson(`PATCH`,this.selfPath(),{body:e}),this.stateLoaded&&(this.state=t(this.state,e))}async patchReplaceFromResponse(e){let t=await this.base.requestJson(`PATCH`,this.selfPath(),{body:e});this.replaceState(t)}async save(){await this.update(this.toUpdateBody())}};const d=e=>{if(!e)return;let t={};return e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),e.sort_by!==void 0&&(t.sort_by=String(e.sort_by)),e.sort_order!==void 0&&(t.sort_order=String(e.sort_order)),t},ee=e=>{if(!e)return;let t={};return e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),e.sort_by!==void 0&&(t.sort_by=String(e.sort_by)),e.sort_order!==void 0&&(t.sort_order=String(e.sort_order)),t},te=e=>({custom_fields:e.custom_fields,description:e.description??void 0,domains:e.domains,name:e.name});var f=class e extends u{selfPath(){return l.expandPath(`/accounts/{account_id}`,{account_id:this.id})}get name(){return this.pick(`name`)}set name(e){this.assign(`name`,e)}get description(){return this.pick(`description`)}set description(e){this.assign(`description`,e)}get domains(){return this.pick(`domains`)}set domains(e){this.assign(`domains`,e)}get customFields(){return this.pick(`custom_fields`)}set customFields(e){this.assign(`custom_fields`,e)}get logoUrl(){return this.pick(`logo_url`)}get externalId(){return this.pick(`external_id`)}get createdAt(){return this.pick(`created_at`)}get updatedAt(){return this.pick(`updated_at`)}toUpdateBody(){return te(this.state)}async update(e,t){if(typeof e==`string`){await this.target(e).update(t??{});return}await this.patchReplaceFromResponse(e)}async delete(e){if(e===void 0){await super.delete();return}await this.target(e).delete()}async listContacts(e,t){if(typeof e==`string`)return await this.target(e).listContacts(t);let n=l.expandPath(`/accounts/{account_id}/contacts`,{account_id:this.id});return await this.base.requestJson(`GET`,n,{query:ee(e)})}async addContacts(e,t){if(typeof e==`string`){await this.target(e).addContacts(t??{contact_ids:[]});return}let n=l.expandPath(`/accounts/{account_id}/contacts`,{account_id:this.id});await this.base.requestJson(`POST`,n,{body:e})}async removeContacts(e,t){if(typeof e==`string`){await this.target(e).removeContacts(t??{contact_ids:[]});return}let n=l.expandPath(`/accounts/{account_id}/contacts`,{account_id:this.id});await this.base.requestJson(`DELETE`,n,{body:e})}async list(e){return await this.base.requestJson(`GET`,`/accounts`,{query:d(e)})}async create(t){let n=await this.base.requestJson(`POST`,`/accounts`,{body:t});return new e(this.base,n)}async get(e){return await this.target(e).refresh()}target(t){return new e(this.base,void 0,t)}async listCustomFields(){return await this.base.requestJson(`GET`,`/accounts/custom_fields`)}},p=class{state;base;constructor(e,t){this.base=e,this.state=structuredClone(t)}get id(){return this.state.id}get links(){return this.state._links}get data(){return this.state}selfPath(){return l.expandPath(`/analytics/exports/{export_id}`,{export_id:this.id})}async refresh(){let e=await this.base.requestJson(`GET`,this.selfPath());return this.state=structuredClone(e),this}},m=class{state;base;constructor(e,t){this.base=e,this.state=structuredClone(t)}get uid(){return this.state.uid}get links(){return this.state._links}get data(){return this.state}selfPath(){return l.expandPath(`/analytics/reports/{report_uid}`,{report_uid:this.uid})}async refresh(){let e=await this.base.requestJson(`GET`,this.selfPath());return this.state=structuredClone(e),this}},h=class{base;constructor(e){this.base=e}async createExport(e){let t=await this.base.requestJson(`POST`,`/analytics/exports`,{body:e});return new p(this.base,t)}async getExport(e){let t=l.expandPath(`/analytics/exports/{export_id}`,{export_id:e}),n=await this.base.requestJson(`GET`,t);return new p(this.base,n)}async createReport(e){let t=await this.base.requestJson(`POST`,`/analytics/reports`,{body:e});return new m(this.base,t)}async getReport(e){let t=l.expandPath(`/analytics/reports/{report_uid}`,{report_uid:e}),n=await this.base.requestJson(`GET`,t);return new m(this.base,n)}},g=class{base;constructor(e){this.base=e}async triggerEvent(e,t){let n=l.expandPath(`/applications/{application_uid}/events`,{application_uid:e});await this.base.requestJson(`POST`,n,{body:t})}};const ne=(e,t)=>{let n=Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),r={...e};return n.name!==void 0&&(r={...r,name:n.name}),n.settings!==void 0&&(r={...r,settings:{...e.settings,...n.settings}}),r},re=e=>({name:e.name,settings:e.settings});var _=class e extends u{selfPath(){return l.expandPath(`/channels/{channel_id}`,{channel_id:this.id})}get name(){return this.pick(`name`)}set name(e){this.assign(`name`,e)}get settings(){return this.pick(`settings`)}set settings(e){this.assign(`settings`,e)}get type(){return this.pick(`type`)}get address(){return this.pick(`address`)}get sendAs(){return this.pick(`send_as`)}get isPrivate(){return this.pick(`is_private`)}get isValid(){return this.pick(`is_valid`)}delete(){return Promise.reject(Error(`Deleting channel ${this.id} is not supported by the Front REST API for this path.`))}toUpdateBody(){return re(this.state)}async update(e,t){let{body:n,id:r}=this.resolveIdAndBody(e,t),i=l.expandPath(`/channels/{channel_id}`,{channel_id:r});await this.base.requestJson(`PATCH`,i,{body:n}),this.hasState()&&r===this.id&&this.replaceState(ne(this.state,n))}async createDraft(e,t){let{body:n,id:r}=this.resolveIdAndBody(e,t),i=l.expandPath(`/channels/{channel_id}/drafts`,{channel_id:r});return await this.base.requestJson(`POST`,i,{body:n})}async receiveCustomMessage(e,t){let{body:n,id:r}=this.resolveIdAndBody(e,t),i=l.expandPath(`/channels/{channel_id}/incoming_messages`,{channel_id:r});return await this.base.requestJson(`POST`,i,{body:n})}async createMessage(e,t){let{body:n,id:r}=this.resolveIdAndBody(e,t),i=l.expandPath(`/channels/{channel_id}/messages`,{channel_id:r});return await this.base.requestJson(`POST`,i,{body:n})}async validate(e){let t=e??this.id,n=l.expandPath(`/channels/{channel_id}/validate`,{channel_id:t});return await this.base.requestJson(`POST`,n)}async list(){return await this.base.requestJson(`GET`,`/channels`)}async get(t){let n=l.expandPath(`/channels/{channel_id}`,{channel_id:t}),r=await this.base.requestJson(`GET`,n);return new e(this.base,r)}async create(e,t){let n=l.expandPath(`/inboxes/{inbox_id}/channels`,{inbox_id:e});await this.base.requestJson(`POST`,n,{body:t})}resolveIdAndBody(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`A request body is required.`);return{body:t,id:e}}return{body:e,id:this.id}}};const ie=e=>({body:e.body,is_pinned:e.is_pinned});var v=class e extends u{selfPath(){return l.expandPath(`/comments/{comment_id}`,{comment_id:this.id})}patchPath(){return l.expandPath(`/comments/{comment_id}/`,{comment_id:this.id})}get author(){return this.pick(`author`)}get body(){return this.pick(`body`)}set body(e){this.assign(`body`,e)}get isPinned(){return this.pick(`is_pinned`)}set isPinned(e){this.assign(`is_pinned`,e)}get postedAt(){return this.pick(`posted_at`)}get attachments(){return this.pick(`attachments`)}delete(e){return e===void 0?Promise.reject(Error(`Deleting comment ${this.id} is not supported by the Front REST API for this path.`)):this.target(e).delete()}toUpdateBody(){return ie(this.state)}async update(e,t){if(typeof e==`string`){await this.target(e).update(t??{});return}let n=await this.base.requestJson(`PATCH`,this.patchPath(),{body:e});this.replaceState(n)}async listMentions(e){if(e!==void 0)return await this.target(e).listMentions();let t=l.expandPath(`/comments/{comment_id}/mentions`,{comment_id:this.id});return await this.base.requestJson(`GET`,t)}async addReply(t,n){if(typeof t==`string`)return await this.target(t).addReply(n??{body:``});let r=l.expandPath(`/comments/{comment_id}/replies`,{comment_id:this.id}),i=await this.base.requestJson(`POST`,r,{body:t});return new e(this.base,i)}async downloadAttachment(e,t){if(t!==void 0)return await this.target(e).downloadAttachment(t);let n=l.expandPath(`/comments/{comment_id}/download/{attachment_link_id}`,{attachment_link_id:e,comment_id:this.id});return await this.base.requestWithoutParsingBody(`GET`,n)}async get(e){return await this.target(e).refresh()}target(t){return new e(this.base,void 0,t)}};const y=e=>{if(!e)return;let t={};return e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),e.sort_by!==void 0&&(t.sort_by=String(e.sort_by)),e.sort_order!==void 0&&(t.sort_order=String(e.sort_order)),t},b=e=>{if(!e)return;let t={};return e.q!==void 0&&(t.q=String(e.q)),e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),t},x=(e,t)=>{let{parent_tag_id:n,...r}=t,i=Object.fromEntries(Object.entries(r).filter(([,e])=>e!==void 0));return{...e,...i}},S=(e,t)=>{let n={description:e.description??void 0,highlight:e.highlight??void 0,is_visible_in_conversation_lists:e.is_visible_in_conversation_lists,name:e.name};return t!==void 0&&(n.parent_tag_id=t),n};var C=class e extends u{parentTagIdForUpdate;constructor(e,t,n){super(e,t,n),this.parentTagIdForUpdate=void 0}selfPath(){return l.expandPath(`/tags/{tag_id}`,{tag_id:this.id})}onAfterRefresh(){this.parentTagIdForUpdate=void 0}get name(){return this.pick(`name`)}set name(e){this.assign(`name`,e)}get description(){return this.pick(`description`)}set description(e){this.assign(`description`,e)}get highlight(){return this.pick(`highlight`)}set highlight(e){this.assign(`highlight`,e)}get isPrivate(){return this.pick(`is_private`)}get isVisibleInConversationLists(){return this.pick(`is_visible_in_conversation_lists`)}set isVisibleInConversationLists(e){this.assign(`is_visible_in_conversation_lists`,e)}get createdAt(){return this.pick(`created_at`)}get updatedAt(){return this.pick(`updated_at`)}get parentTagId(){return this.parentTagIdForUpdate}set parentTagId(e){this.parentTagIdForUpdate=e}toUpdateBody(){return S(this.state,this.parentTagIdForUpdate)}async update(e,t){if(typeof e==`string`){await this.target(e).update(t??{});return}await this.patchNoContent(e,x),`parent_tag_id`in e&&(this.parentTagIdForUpdate=e.parent_tag_id===null||e.parent_tag_id===void 0?void 0:e.parent_tag_id)}async delete(e){if(e===void 0){await super.delete();return}await this.target(e).delete()}async listChildren(t){if(t!==void 0)return await this.target(t).listChildren();let n=l.expandPath(`/tags/{tag_id}/children`,{tag_id:this.id});return((await this.base.requestJson(`GET`,n))._results??[]).map(t=>new e(this.base,t))}async createChild(t,n){if(typeof t==`string`){if(n===void 0)throw Error(`Creating a child tag requires a request body.`);return await this.target(t).createChild(n)}let r=l.expandPath(`/tags/{tag_id}/children`,{tag_id:this.id}),i=await this.base.requestJson(`POST`,r,{body:t});return new e(this.base,i)}async listTaggedConversations(e,t){if(typeof e==`string`)return await this.target(e).listTaggedConversations(t);let n=l.expandPath(`/tags/{tag_id}/conversations`,{tag_id:this.id});return await this.base.requestJson(`GET`,n,{query:b(e)})}async list(e){return await this.base.requestJson(`GET`,`/tags`,{query:y(e)})}async create(t){let n=await this.base.requestJson(`POST`,`/tags`,{body:t});return new e(this.base,n)}async get(e){return await this.target(e).refresh()}target(t){return new e(this.base,void 0,t)}};const ae=e=>{if(!e)return;let t={};return e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),e.sort_by!==void 0&&(t.sort_by=String(e.sort_by)),e.sort_order!==void 0&&(t.sort_order=String(e.sort_order)),t};var w=class{base;constructor(e){this.base=e}async listRules(){return await this.base.requestJson(`GET`,`/company/rules`)}async listTicketStatuses(){return await this.base.requestJson(`GET`,`/company/statuses`)}async getTicketStatus(e){let t=l.expandPath(`/company/statuses/{status_id}`,{status_id:e});return await this.base.requestJson(`GET`,t)}async listTags(e){return await this.base.requestJson(`GET`,`/company/tags`,{query:ae(e)})}async createTag(e){let t=await this.base.requestJson(`POST`,`/company/tags`,{body:e});return new C(this.base,t)}};const oe=e=>{if(!e)return;let t={};return e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),t};var T=class{base;constructor(e){this.base=e}async list(){return await this.base.requestJson(`GET`,`/contact_lists`)}async create(e){await this.base.requestJson(`POST`,`/contact_lists`,{body:e})}async delete(e){let t=l.expandPath(`/contact_lists/{contact_list_id}`,{contact_list_id:e});await this.base.requestJson(`DELETE`,t)}async listContacts(e,t){let n=l.expandPath(`/contact_lists/{contact_list_id}/contacts`,{contact_list_id:e});return await this.base.requestJson(`GET`,n,{query:oe(t)})}async addContacts(e,t){let n=l.expandPath(`/contact_lists/{contact_list_id}/contacts`,{contact_list_id:e});await this.base.requestJson(`POST`,n,{body:t})}async removeContacts(e,t){let n=l.expandPath(`/contact_lists/{contact_list_id}/contacts`,{contact_list_id:e});await this.base.requestJson(`DELETE`,n,{body:t})}};const E=e=>{if(e.id===void 0||e.id===``)throw Error("Contact response missing `id`.");return{...e,_links:e._links!==void 0&&e._links!==null?{...e._links}:{},id:e.id}},se=e=>{if(!e)return;let t={};return e.q!==void 0&&(t.q=String(e.q)),e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),e.sort_by!==void 0&&(t.sort_by=String(e.sort_by)),e.sort_order!==void 0&&(t.sort_order=String(e.sort_order)),t},ce=e=>{if(!e)return;let t={};return e.q!==void 0&&(t.q=String(e.q)),e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),t},le=(e,t)=>{let n={...e};return t.name!==void 0&&(n={...n,name:t.name}),t.description!==void 0&&(n={...n,description:t.description}),t.links!==void 0&&(n={...n,links:t.links}),t.custom_fields!==void 0&&(n={...n,custom_fields:t.custom_fields}),n},ue=e=>({custom_fields:e.custom_fields,description:e.description,links:e.links,name:e.name});var D=class e extends u{constructor(e,t,n){super(e,t===void 0?void 0:E(t),n)}selfPath(){return l.expandPath(`/contacts/{contact_id}`,{contact_id:this.id})}get name(){return this.pick(`name`)}set name(e){this.assign(`name`,e)}get description(){return this.pick(`description`)}set description(e){this.assign(`description`,e)}get avatarUrl(){return this.pick(`avatar_url`)}get contactLinks(){return this.pick(`links`)}set contactLinks(e){this.assign(`links`,e)}get handles(){return this.pick(`handles`)}get customFields(){return this.pick(`custom_fields`)}set customFields(e){this.assign(`custom_fields`,e)}get lists(){return this.pick(`lists`)}get groups(){return this.pick(`groups`)}get isPrivate(){return this.pick(`is_private`)}toUpdateBody(){return ue(this.state)}async update(e,t){if(typeof e==`string`){await this.target(e).update(t??{});return}await this.patchNoContent(e,le)}async delete(e){if(e===void 0){await super.delete();return}await this.target(e).delete()}async refresh(){let e=await this.base.requestJson(`GET`,this.selfPath());return this.replaceState(E(e)),this.onAfterRefresh(),this}async listConversations(e,t){if(typeof e==`string`)return await this.target(e).listConversations(t);let n=l.expandPath(`/contacts/{contact_id}/conversations`,{contact_id:this.id});return await this.base.requestJson(`GET`,n,{query:ce(e)})}async addHandle(e,t){if(typeof e==`string`){await this.target(e).addHandle(t??{handle:``,source:`custom`});return}let n=l.expandPath(`/contacts/{contact_id}/handles`,{contact_id:this.id});await this.base.requestJson(`POST`,n,{body:e});let r=this.pick(`handles`)??[];this.assign(`handles`,[...r,e])}async deleteHandle(e,t){if(typeof e==`string`){await this.target(e).deleteHandle(t??{force:!1,handle:``,source:`custom`});return}let n=l.expandPath(`/contacts/{contact_id}/handles`,{contact_id:this.id});await this.base.requestJson(`DELETE`,n,{body:e});let r=this.pick(`handles`)??[];this.assign(`handles`,r.filter(t=>t.handle!==e.handle||t.source!==e.source))}async listNotes(e){if(e!==void 0)return await this.target(e).listNotes();let t=l.expandPath(`/contacts/{contact_id}/notes`,{contact_id:this.id});return await this.base.requestJson(`GET`,t)}async addNote(e,t){if(typeof e==`string`)return await this.target(e).addNote(t??{author_id:``,body:``});let n=l.expandPath(`/contacts/{contact_id}/notes`,{contact_id:this.id});return await this.base.requestJson(`POST`,n,{body:e})}async list(e){return await this.base.requestJson(`GET`,`/contacts`,{query:se(e)})}async create(t){let n=await this.base.requestJson(`POST`,`/contacts`,{body:t});return new e(this.base,n)}async listCustomFields(){return await this.base.requestJson(`GET`,`/contacts/custom_fields`)}async merge(t){let n=await this.base.requestJson(`POST`,`/contacts/merge`,{body:t});return new e(this.base,n)}async get(e){return await this.target(e).refresh()}target(t){return new e(this.base,void 0,t)}};const de=e=>{if(!e)return;let t={};return e.q!==void 0&&(t.q=String(e.q)),e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),e.sort_by!==void 0&&(t.sort_by=String(e.sort_by)),e.sort_order!==void 0&&(t.sort_order=String(e.sort_order)),t},fe=e=>{if(!e)return;let t={};return e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),t},pe=e=>{if(!e)return;let t={};return e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),t},me=e=>{if(!e)return;let t={};return e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),e.sort_by!==void 0&&(t.sort_by=String(e.sort_by)),e.sort_order!==void 0&&(t.sort_order=String(e.sort_order)),t},he=(e,t,n)=>{let r=l.expandPath(`/conversations/{conversation_id}/messages`,{conversation_id:t});return e.requestJson(`GET`,r,{query:me(n)})},ge=e=>{if(!e)return;let t={};return e.ignore_errors!==void 0&&(t.ignore_errors=e.ignore_errors?`true`:`false`),t},_e=e=>{switch(e){case`archived`:return`archived`;case`deleted`:return`deleted`;case`open`:return`unassigned`;case`spam`:return`deleted`;default:return e}},ve=e=>{if(e===`archived`)return`archived`;if(e===`deleted`)return`deleted`;if(e===`unassigned`)return`open`},ye=(e,t)=>{let n=Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),r={...e};if(n.status!==void 0&&(r={...r,status:_e(n.status)}),n.status_id!==void 0&&(r={...r,status_id:n.status_id}),n.custom_fields!==void 0&&(r={...r,custom_fields:n.custom_fields}),n.tag_ids!==void 0){let e=new Set(n.tag_ids);r={...r,tags:r.tags.filter(t=>e.has(t.id))}}let i=n.assignee_id;return i!==void 0&&(r={...r,assignee:{...r.assignee,id:i===null?``:i}}),r},O=e=>{let t=ve(e.status);return{assignee_id:e.assignee.id===``?void 0:e.assignee.id,custom_fields:e.custom_fields,tag_ids:e.tags.map(e=>e.id),...t===void 0?{}:{status:t},...e.status_id===void 0?{}:{status_id:e.status_id}}};var k=class e extends u{selfPath(){return l.expandPath(`/conversations/{conversation_id}`,{conversation_id:this.id})}get subject(){return this.pick(`subject`)}get status(){return this.pick(`status`)}get statusId(){return this.pick(`status_id`)}get statusCategory(){return this.pick(`status_category`)}get ticketIds(){return this.pick(`ticket_ids`)}get assignee(){return this.pick(`assignee`)}get recipient(){return this.pick(`recipient`)}get tags(){return this.pick(`tags`)}get conversationLinks(){return this.pick(`links`)}get customFields(){return this.pick(`custom_fields`)}get createdAt(){return this.pick(`created_at`)}get updatedAt(){return this.pick(`updated_at`)}get waitingSince(){return this.pick(`waiting_since`)}get isPrivate(){return this.pick(`is_private`)}get scheduledReminders(){return this.pick(`scheduled_reminders`)}get metadata(){return this.pick(`metadata`)}toUpdateBody(){return O(this.state)}async update(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Updating a conversation by ID requires a request body.`);await this.target(e).update(t);return}await this.patchNoContent(e,ye)}async delete(e){if(e!==void 0){await this.target(e).delete();return}await super.delete()}async updateAssignee(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Updating a conversation assignee by ID requires a request body.`);await this.target(e).updateAssignee(t);return}let n=l.expandPath(`/conversations/{conversation_id}/assignee`,{conversation_id:this.id});await this.base.requestJson(`PUT`,n,{body:e})}async listComments(e){if(e!==void 0)return await this.target(e).listComments();let t=l.expandPath(`/conversations/{conversation_id}/comments`,{conversation_id:this.id});return await this.base.requestJson(`GET`,t)}async addComment(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Adding a conversation comment by ID requires a request body.`);return await this.target(e).addComment(t)}let n=l.expandPath(`/conversations/{conversation_id}/comments`,{conversation_id:this.id}),r=await this.base.requestJson(`POST`,n,{body:e});return new v(this.base,r)}async listDrafts(e){if(e!==void 0)return await this.target(e).listDrafts();let t=l.expandPath(`/conversations/{conversation_id}/drafts`,{conversation_id:this.id});return await this.base.requestJson(`GET`,t)}async createDraftReply(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Creating a conversation draft by ID requires a request body.`);return await this.target(e).createDraftReply(t)}let n=l.expandPath(`/conversations/{conversation_id}/drafts`,{conversation_id:this.id});return await this.base.requestJson(`POST`,n,{body:e})}async listEvents(e,t){if(typeof e==`string`)return await this.target(e).listEvents(t);let n=l.expandPath(`/conversations/{conversation_id}/events`,{conversation_id:this.id});return await this.base.requestJson(`GET`,n,{query:pe(e)})}async listFollowers(e){if(e!==void 0)return await this.target(e).listFollowers();let t=l.expandPath(`/conversations/{conversation_id}/followers`,{conversation_id:this.id});return await this.base.requestJson(`GET`,t)}async addFollowers(e,t,n){if(typeof e==`string`){if(t===void 0)throw Error(`Adding conversation followers by ID requires a request body.`);await this.target(e).addFollowers(t,n);return}let r=l.expandPath(`/conversations/{conversation_id}/followers`,{conversation_id:this.id});await this.base.requestJson(`POST`,r,{body:e,query:ge(t)})}async deleteFollowers(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Removing conversation followers by ID requires a request body.`);await this.target(e).deleteFollowers(t);return}let n=l.expandPath(`/conversations/{conversation_id}/followers`,{conversation_id:this.id});await this.base.requestJson(`DELETE`,n,{body:e})}async listInboxes(e){if(e!==void 0)return await this.target(e).listInboxes();let t=l.expandPath(`/conversations/{conversation_id}/inboxes`,{conversation_id:this.id});return await this.base.requestJson(`GET`,t)}async addLink(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Adding a conversation link by ID requires a request body.`);await this.target(e).addLink(t);return}let n=l.expandPath(`/conversations/{conversation_id}/links`,{conversation_id:this.id});await this.base.requestJson(`POST`,n,{body:e})}async removeLinks(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Removing conversation links by ID requires a request body.`);await this.target(e).removeLinks(t);return}let n=l.expandPath(`/conversations/{conversation_id}/links`,{conversation_id:this.id});await this.base.requestJson(`DELETE`,n,{body:e})}async listMessages(e,t){return typeof e==`string`?await this.target(e).listMessages(t):await he(this.base,this.id,e)}async createMessageReply(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Replying to a conversation by ID requires a request body.`);return await this.target(e).createMessageReply(t)}let n=l.expandPath(`/conversations/{conversation_id}/messages`,{conversation_id:this.id});return await this.base.requestJson(`POST`,n,{body:e})}async updateReminders(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Updating conversation reminders by ID requires a request body.`);await this.target(e).updateReminders(t);return}let n=l.expandPath(`/conversations/{conversation_id}/reminders`,{conversation_id:this.id});await this.base.requestJson(`PATCH`,n,{body:e})}async addTag(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Adding a conversation tag by ID requires a request body.`);await this.target(e).addTag(t);return}let n=l.expandPath(`/conversations/{conversation_id}/tags`,{conversation_id:this.id});await this.base.requestJson(`POST`,n,{body:e})}async removeTag(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Removing a conversation tag by ID requires a request body.`);await this.target(e).removeTag(t);return}let n=l.expandPath(`/conversations/{conversation_id}/tags`,{conversation_id:this.id});await this.base.requestJson(`DELETE`,n,{body:e})}async list(e){return await this.base.requestJson(`GET`,`/conversations`,{query:de(e)})}async create(t){let n=await this.base.requestJson(`POST`,`/conversations`,{body:t});return new e(this.base,n)}async listCustomFields(){return await this.base.requestJson(`GET`,`/conversations/custom_fields`)}async search(e,t){let n=l.expandPath(`/conversations/search/{query}`,{query:e});return await this.base.requestJson(`GET`,n,{query:fe(t)})}async get(e){let t=this.target(e);return await t.refresh(),t}target(t){return new e(this.base,void 0,t)}},A=class{base;constructor(e){this.base=e}async list(){return await this.base.requestJson(`GET`,`/custom_fields`)}},j=class{base;constructor(e){this.base=e}async download(e){let t=l.expandPath(`/download/{attachment_link_id}`,{attachment_link_id:e});return await this.base.requestWithoutParsingBody(`GET`,t)}},M=class{base;constructor(e){this.base=e}async delete(e,t){let n=l.expandPath(`/drafts/{draft_id}`,{draft_id:e});await this.base.requestJson(`DELETE`,n,{body:t})}async edit(e,t){let n=l.expandPath(`/drafts/{message_id}/`,{message_id:e});return await this.base.requestJson(`PATCH`,n,{body:t})}};const N=e=>{if(!e)return;let t={};return e.q!==void 0&&(t.q=String(e.q)),e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),e.sort_by!==void 0&&(t.sort_by=String(e.sort_by)),e.sort_order!==void 0&&(t.sort_order=String(e.sort_order)),t};var P=class{base;constructor(e){this.base=e}async list(e){return await this.base.requestJson(`GET`,`/events`,{query:N(e)})}async get(e){let t=l.expandPath(`/events/{event_id}`,{event_id:e});return await this.base.requestJson(`GET`,t)}};const be=e=>{if(!e)return;let t={};return e.q!==void 0&&(t.q=String(e.q)),e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),t},F=e=>{let{id:t}=e;if(t===void 0||t===``)throw Error(`Inbox response missing id`);return t};var I=class e{state;base;inboxId;constructor(e,t,n){if(this.base=e,t===void 0){this.inboxId=n;return}let r=F(t);this.inboxId=r,this.state=structuredClone({...t,id:r})}get id(){let e=this.state?.id??this.inboxId;if(e===void 0)throw Error(`This inbox operation requires an ID.`);return e}get links(){return this.requireState()._links}get data(){return this.requireState()}requireState(){if(this.state===void 0)throw Error(`This inbox operation requires fetched resource data.`);return this.state}selfPath(){return l.expandPath(`/inboxes/{inbox_id}`,{inbox_id:this.id})}async refresh(){let e=await this.base.requestJson(`GET`,this.selfPath()),t=F(e);return this.state=structuredClone({...e,id:t}),this}async listChannels(e){if(e!==void 0)return await this.target(e).listChannels();let t=l.expandPath(`/inboxes/{inbox_id}/channels`,{inbox_id:this.id});return await this.base.requestJson(`GET`,t)}async listConversations(e,t){if(typeof e==`string`)return await this.target(e).listConversations(t);let n=l.expandPath(`/inboxes/{inbox_id}/conversations`,{inbox_id:this.id});return await this.base.requestJson(`GET`,n,{query:be(e)})}async importMessage(e,t){if(typeof e==`string`)return await this.target(e).importMessage(t??{});let n=l.expandPath(`/inboxes/{inbox_id}/imported_messages`,{inbox_id:this.id});return await this.base.requestJson(`POST`,n,{body:e})}async listTeammateAccess(e){if(e!==void 0)return await this.target(e).listTeammateAccess();let t=l.expandPath(`/inboxes/{inbox_id}/teammates`,{inbox_id:this.id});return await this.base.requestJson(`GET`,t)}async addTeammateAccess(e,t){if(typeof e==`string`){await this.target(e).addTeammateAccess(t??{teammate_ids:[]});return}let n=l.expandPath(`/inboxes/{inbox_id}/teammates`,{inbox_id:this.id});await this.base.requestJson(`POST`,n,{body:e})}async removeTeammateAccess(e,t){if(typeof e==`string`){await this.target(e).removeTeammateAccess(t??{teammate_ids:[]});return}let n=l.expandPath(`/inboxes/{inbox_id}/teammates`,{inbox_id:this.id});await this.base.requestJson(`DELETE`,n,{body:e})}async list(){return await this.base.requestJson(`GET`,`/inboxes`)}async create(t){let n=await this.base.requestJson(`POST`,`/inboxes`,{body:t});return new e(this.base,n)}async listCustomFields(){return await this.base.requestJson(`GET`,`/inboxes/custom_fields`)}async get(e){return await this.target(e).refresh()}target(t){return new e(this.base,void 0,t)}};const L=e=>{if(!e)return;let t={};return e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),Object.keys(t).length>0?t:void 0};var R=class e{base;knowledgeBaseId;snapshot;constructor(e,t,n){this.base=e,this.knowledgeBaseId=t??``,this.snapshot=n}get id(){if(this.knowledgeBaseId.length===0)throw Error(`This knowledge base operation requires an ID.`);return this.knowledgeBaseId}get data(){return this.snapshot}async refresh(){let e=l.expandPath(`/knowledge_bases/{knowledge_base_id}`,{knowledge_base_id:this.knowledgeBaseId});return this.snapshot=await this.base.requestJson(`GET`,e),this}async getContentDefault(){let e=l.expandPath(`/knowledge_bases/{knowledge_base_id}/content`,{knowledge_base_id:this.knowledgeBaseId});return await this.base.requestJson(`GET`,e)}async updateContentDefault(e){let t=l.expandPath(`/knowledge_bases/{knowledge_base_id}/content`,{knowledge_base_id:this.knowledgeBaseId});return await this.base.requestJson(`PATCH`,t,{body:e})}async getContentLocale(e){let t=l.expandPath(`/knowledge_bases/{knowledge_base_id}/locales/{locale}/content`,{knowledge_base_id:this.knowledgeBaseId,locale:e});return await this.base.requestJson(`GET`,t)}async updateContentLocale(e,t){let n=l.expandPath(`/knowledge_bases/{knowledge_base_id}/locales/{locale}/content`,{knowledge_base_id:this.knowledgeBaseId,locale:e});return await this.base.requestJson(`PATCH`,n,{body:t})}async listArticles(e){let t=l.expandPath(`/knowledge_bases/{knowledge_base_id}/articles`,{knowledge_base_id:this.knowledgeBaseId});return await this.base.requestJson(`GET`,t,{query:L(e)})}async createArticleDefault(e){let t=l.expandPath(`/knowledge_bases/{knowledge_base_id}/articles`,{knowledge_base_id:this.knowledgeBaseId}),n=await this.base.requestJson(`POST`,t,{body:e});return new z(this.base,n.id,n)}async createArticleLocale(e,t){let n=l.expandPath(`/knowledge_bases/{knowledge_base_id}/locales/{locale}/articles`,{knowledge_base_id:this.knowledgeBaseId,locale:e}),r=await this.base.requestJson(`POST`,n,{body:t});return new z(this.base,r.id,r)}async listCategories(e){let t=l.expandPath(`/knowledge_bases/{knowledge_base_id}/categories`,{knowledge_base_id:this.knowledgeBaseId});return await this.base.requestJson(`GET`,t,{query:L(e)})}async createCategoryDefault(e){let t=l.expandPath(`/knowledge_bases/{knowledge_base_id}/categories`,{knowledge_base_id:this.knowledgeBaseId}),n=await this.base.requestJson(`POST`,t,{body:e});return new B(this.base,n.id,n)}async createCategoryLocale(e,t){let n=l.expandPath(`/knowledge_bases/{knowledge_base_id}/locales/{locale}/categories`,{knowledge_base_id:this.knowledgeBaseId,locale:e}),r=await this.base.requestJson(`POST`,n,{body:t});return new B(this.base,r.id,r)}async list(){return await this.base.requestJson(`GET`,`/knowledge_bases`)}async create(t){let n=await this.base.requestJson(`POST`,`/knowledge_bases`,{body:t});return new e(this.base,n.id,n)}async get(e){let t=this.target(e);return await t.refresh(),t}target(t){return new e(this.base,t)}article(e){return new z(this.base,e)}category(e){return new B(this.base,e)}},z=class{base;articleId;snapshot;constructor(e,t,n){this.base=e,this.articleId=t,this.snapshot=n}get id(){return this.articleId}get data(){return this.snapshot}async refresh(){let e=l.expandPath(`/knowledge_base_articles/{article_id}`,{article_id:this.articleId});return this.snapshot=await this.base.requestJson(`GET`,e),this}async delete(){let e=l.expandPath(`/knowledge_base_articles/{article_id}`,{article_id:this.articleId});return await this.base.requestJson(`DELETE`,e)}async getContentDefault(){let e=l.expandPath(`/knowledge_base_articles/{article_id}/content`,{article_id:this.articleId});return await this.base.requestJson(`GET`,e)}async updateContentDefault(e){let t=l.expandPath(`/knowledge_base_articles/{article_id}/content`,{article_id:this.articleId});return await this.base.requestJson(`PATCH`,t,{body:e})}async getContentLocale(e){let t=l.expandPath(`/knowledge_base_articles/{article_id}/locales/{locale}/content`,{article_id:this.articleId,locale:e});return await this.base.requestJson(`GET`,t)}async updateContentLocale(e,t){let n=l.expandPath(`/knowledge_base_articles/{article_id}/locales/{locale}/content`,{article_id:this.articleId,locale:e});return await this.base.requestJson(`PATCH`,n,{body:t})}async downloadAttachment(e){let t=l.expandPath(`/knowledge_base_articles/{article_id}/download/{attachment_id}`,{article_id:this.articleId,attachment_id:e});return await this.base.requestWithoutParsingBody(`GET`,t)}},B=class{base;categoryId;snapshot;constructor(e,t,n){this.base=e,this.categoryId=t,this.snapshot=n}get id(){return this.categoryId}get data(){return this.snapshot}async refresh(){let e=l.expandPath(`/knowledge_base_categories/{category_id}`,{category_id:this.categoryId});return this.snapshot=await this.base.requestJson(`GET`,e),this}async delete(){let e=l.expandPath(`/knowledge_base_categories/{category_id}`,{category_id:this.categoryId});await this.base.requestJson(`DELETE`,e)}async listArticles(e){let t=l.expandPath(`/knowledge_base_categories/{category_id}/articles`,{category_id:this.categoryId});return await this.base.requestJson(`GET`,t,{query:L(e)})}async getContentDefault(){let e=l.expandPath(`/knowledge_base_categories/{category_id}/content`,{category_id:this.categoryId});return await this.base.requestJson(`GET`,e)}async updateContentDefault(e){let t=l.expandPath(`/knowledge_base_categories/{category_id}/content`,{category_id:this.categoryId});return await this.base.requestJson(`PATCH`,t,{body:e})}async getContentLocale(e){let t=l.expandPath(`/knowledge_base_categories/{category_id}/locales/{locale}/content`,{category_id:this.categoryId,locale:e});return await this.base.requestJson(`GET`,t)}async updateContentLocale(e,t){let n=l.expandPath(`/knowledge_base_categories/{category_id}/locales/{locale}/content`,{category_id:this.categoryId,locale:e});return await this.base.requestJson(`PATCH`,n,{body:t})}};const xe=e=>{if(!e)return;let t={};return e.q!==void 0&&(t.q=String(e.q)),e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),e.sort_by!==void 0&&(t.sort_by=String(e.sort_by)),e.sort_order!==void 0&&(t.sort_order=String(e.sort_order)),t},Se=e=>{if(!e)return;let t={};return e.q!==void 0&&(t.q=String(e.q)),e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),e.sort_by!==void 0&&(t.sort_by=String(e.sort_by)),e.sort_order!==void 0&&(t.sort_order=String(e.sort_order)),t},Ce=(e,t)=>{let n=Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0));return{...e,...n}},we=e=>({name:e.name});var V=class e extends u{selfPath(){return l.expandPath(`/links/{link_id}`,{link_id:this.id})}get name(){return this.pick(`name`)}set name(e){this.assign(`name`,e)}get type(){return this.pick(`type`)}get externalUrl(){return this.pick(`external_url`)}get customFields(){return this.pick(`custom_fields`)}delete(e){return e===void 0?Promise.reject(Error(`Deleting link ${this.id} is not supported by the Front REST API for this path.`)):this.target(e).delete()}toUpdateBody(){return we(this.state)}async update(e,t){if(typeof e==`string`){await this.target(e).update(t??{});return}await this.patchNoContent(e,Ce)}async listConversations(e,t){if(typeof e==`string`)return await this.target(e).listConversations(t);let n=l.expandPath(`/links/{link_id}/conversations`,{link_id:this.id});return await this.base.requestJson(`GET`,n,{query:Se(e)})}async list(e){return await this.base.requestJson(`GET`,`/links`,{query:xe(e)})}async create(t){let n=await this.base.requestJson(`POST`,`/links`,{body:t});return new e(this.base,n)}async listCustomFields(){return await this.base.requestJson(`GET`,`/links/custom_fields`)}async get(e){return await this.target(e).refresh()}target(t){return new e(this.base,void 0,t)}},H=class{base;constructor(e){this.base=e}async details(){return await this.base.requestJson(`GET`,`/me`)}};const Te=e=>{if(!e)return;let t={};return e.sort_by!==void 0&&(t.sort_by=String(e.sort_by)),e.sort_order!==void 0&&(t.sort_order=String(e.sort_order)),t},Ee=e=>{let t={body:e.body,name:e.name,subject:e.subject===null?void 0:e.subject};return e.inbox_ids!==null&&(t.inbox_ids=e.inbox_ids),t};var U=class e extends u{folderIdForUpdate;constructor(e,t,n){super(e,t,n),this.folderIdForUpdate=void 0}onAfterRefresh(){this.folderIdForUpdate=void 0}selfPath(){return l.expandPath(`/message_templates/{message_template_id}`,{message_template_id:this.id})}get name(){return this.pick(`name`)}set name(e){this.assign(`name`,e)}get subject(){return this.pick(`subject`)}set subject(e){this.assign(`subject`,e)}get body(){return this.pick(`body`)}set body(e){this.assign(`body`,e)}get isAvailableForAllInboxes(){return this.pick(`is_available_for_all_inboxes`)}get inboxIds(){return this.pick(`inbox_ids`)}set inboxIds(e){this.assign(`inbox_ids`,e)}get folderId(){return this.folderIdForUpdate}set folderId(e){this.folderIdForUpdate=e}toUpdateBody(){let e=Ee(this.state);return this.folderIdForUpdate!==void 0&&(e.folder_id=this.folderIdForUpdate??void 0),e}async update(e,t){if(typeof e==`string`){await this.target(e).update(t??{});return}await this.patchReplaceFromResponse(e),`folder_id`in e&&(this.folderIdForUpdate=e.folder_id===null||e.folder_id===void 0?void 0:e.folder_id)}async delete(e){if(e===void 0){await super.delete();return}await this.target(e).delete()}async downloadAttachment(e,t){if(t!==void 0)return await this.target(e).downloadAttachment(t);let n=l.expandPath(`/message_templates/{message_template_id}/download/{attachment_link_id}`,{attachment_link_id:e,message_template_id:this.id});return await this.base.requestWithoutParsingBody(`GET`,n)}async list(e){return await this.base.requestJson(`GET`,`/message_templates`,{query:Te(e)})}async create(t){let n=await this.base.requestJson(`POST`,`/message_templates`,{body:t});return new e(this.base,n)}async get(e){return await this.target(e).refresh()}target(t){return new e(this.base,void 0,t)}};const De=e=>{if(!e)return;let t={};return e.sort_by!==void 0&&(t.sort_by=String(e.sort_by)),e.sort_order!==void 0&&(t.sort_order=String(e.sort_order)),t},Oe=(e,t)=>{let n={name:e.name};return t!==void 0&&(n.parent_folder_id=t??void 0),n};var W=class e extends u{parentFolderIdForUpdate;constructor(e,t,n){super(e,t,n),this.parentFolderIdForUpdate=void 0}onAfterRefresh(){this.parentFolderIdForUpdate=void 0}selfPath(){return l.expandPath(`/message_template_folders/{message_template_folder_id}`,{message_template_folder_id:this.id})}get name(){return this.pick(`name`)}set name(e){this.assign(`name`,e)}get parentFolderId(){return this.parentFolderIdForUpdate}set parentFolderId(e){this.parentFolderIdForUpdate=e}toUpdateBody(){return Oe(this.state,this.parentFolderIdForUpdate)}async update(e,t){if(typeof e==`string`){await this.target(e).update(t??{});return}await this.patchReplaceFromResponse(e),`parent_folder_id`in e&&(this.parentFolderIdForUpdate=e.parent_folder_id===null||e.parent_folder_id===void 0?void 0:e.parent_folder_id)}async delete(e){if(e!==void 0){await this.target(e).delete();return}await this.base.requestJson(`DELETE`,this.selfPath())}async listChildFolders(e){if(e!==void 0)return await this.target(e).listChildFolders();let t=l.expandPath(`/message_template_folders/{message_template_folder_id}/message_template_folders`,{message_template_folder_id:this.id});return await this.base.requestJson(`GET`,t)}async createChildFolder(t,n){if(typeof t==`string`){if(n===void 0)throw Error(`Creating a child folder requires a request body.`);return await this.target(t).createChildFolder(n)}let r=l.expandPath(`/message_template_folders/{message_template_folder_id}/message_template_folders`,{message_template_folder_id:this.id}),i=await this.base.requestJson(`POST`,r,{body:t});return new e(this.base,i)}async listChildTemplates(e){if(e!==void 0)return await this.target(e).listChildTemplates();let t=l.expandPath(`/message_template_folders/{message_template_folder_id}/message_templates`,{message_template_folder_id:this.id});return await this.base.requestJson(`GET`,t)}async createChildTemplate(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Creating a child template requires a request body.`);return await this.target(e).createChildTemplate(t)}let n=l.expandPath(`/message_template_folders/{message_template_folder_id}/message_templates`,{message_template_folder_id:this.id}),r=await this.base.requestJson(`POST`,n,{body:e});return new U(this.base,r)}async list(e){return await this.base.requestJson(`GET`,`/message_template_folders`,{query:De(e)})}async create(t){let n=await this.base.requestJson(`POST`,`/message_template_folders`,{body:t});return new e(this.base,n)}async get(e){return await this.target(e).refresh()}target(t){return new e(this.base,void 0,t)}};const ke={};var G=class e{base;boundMessageId;snapshot;constructor(e,t,n){this.base=e,this.boundMessageId=t,this.snapshot=n}get messageIdParam(){return this.messageId}get data(){return this.snapshot}async refresh(){let e=l.expandPath(`/messages/{message_id}`,{message_id:this.messageId});return this.snapshot=await this.base.requestJson(`GET`,e),this}async fetchRaw(e,t){let n=typeof e==`string`?e:this.messageId,r=typeof e==`string`?t:e,i=l.expandPath(`/messages/{message_id}`,{message_id:n}),a={...r?.headers};return a.Accept===void 0&&(a.Accept=`application/json`),await this.base.requestWithoutParsingBody(`GET`,i,{headers:a})}async downloadAttachment(e,t){let n=t===void 0?this.messageId:e,r=t??e,i=l.expandPath(`/messages/{message_id}/download/{attachment_link_id}`,{attachment_link_id:r,message_id:n});return await this.base.requestWithoutParsingBody(`GET`,i)}async getSeen(e=this.messageId){let t=l.expandPath(`/messages/{message_id}/seen`,{message_id:e});return await this.base.requestJson(`GET`,t)}async markSeen(e=this.messageId){let t=l.expandPath(`/messages/{message_id}/seen`,{message_id:e});await this.base.requestJson(`POST`,t,{body:ke})}get messageId(){if(this.boundMessageId===void 0)throw Error(`This message operation requires an ID.`);return this.boundMessageId}async get(t){let n=l.expandPath(`/messages/{message_id}`,{message_id:t}),r=await this.base.requestJson(`GET`,n);return new e(this.base,t,r)}},K=class{base;constructor(e){this.base=e}async list(){return await this.base.requestJson(`GET`,`/rules`)}async get(e){let t=l.expandPath(`/rules/{rule_id}`,{rule_id:e});return await this.base.requestJson(`GET`,t)}};const Ae=e=>{if(!e)return;let t={};return e.q!==void 0&&(t.q=String(e.q)),e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),t},je=(e,t)=>{let n=Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0));return{...e,...n}},Me=e=>({custom_fields:e.custom_fields,first_name:e.first_name,is_available:e.is_available,last_name:e.last_name,username:e.username});var q=class e extends u{selfPath(){return l.expandPath(`/teammates/{teammate_id}`,{teammate_id:this.id})}get email(){return this.pick(`email`)}get username(){return this.pick(`username`)}set username(e){this.assign(`username`,e)}get firstName(){return this.pick(`first_name`)}set firstName(e){this.assign(`first_name`,e)}get lastName(){return this.pick(`last_name`)}set lastName(e){this.assign(`last_name`,e)}get isAdmin(){return this.pick(`is_admin`)}get isAvailable(){return this.pick(`is_available`)}set isAvailable(e){this.assign(`is_available`,e)}get isBlocked(){return this.pick(`is_blocked`)}get type(){return this.pick(`type`)}get customFields(){return this.pick(`custom_fields`)}set customFields(e){this.assign(`custom_fields`,e)}toUpdateBody(){return Me(this.state)}async update(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Updating a teammate by ID requires a request body.`);await this.target(e).update(t);return}await this.patchNoContent(e,je)}async listAssignedConversations(e,t){if(typeof e==`string`)return await this.target(e).listAssignedConversations(t);let n=l.expandPath(`/teammates/{teammate_id}/conversations`,{teammate_id:this.id});return await this.base.requestJson(`GET`,n,{query:Ae(e)})}async list(){return await this.base.requestJson(`GET`,`/teammates`)}async get(e){let t=this.target(e);return await t.refresh(),t}target(t){return new e(this.base,void 0,t)}};const Ne=(e,t)=>{let{times:n,...r}=t,i=Object.fromEntries(Object.entries(r).filter(([,e])=>e!==void 0)),a={...e,...i};return n!==void 0&&(a={...a,times:{...e.times,...n}}),a},Pe=e=>({color:e.color,name:e.name,times:e.times,timezone:e.timezone});var J=class e extends u{selfPath(){return l.expandPath(`/shifts/{shift_id}`,{shift_id:this.id})}get name(){return this.pick(`name`)}set name(e){this.assign(`name`,e)}get color(){return this.pick(`color`)}set color(e){this.assign(`color`,e)}get timezone(){return this.pick(`timezone`)}set timezone(e){this.assign(`timezone`,e)}get times(){return this.pick(`times`)}set times(e){this.assign(`times`,e)}get createdAt(){return this.pick(`created_at`)}get updatedAt(){return this.pick(`updated_at`)}toUpdateBody(){return Pe(this.state)}async update(e,t){if(typeof e==`string`){await this.target(e).update(t??{});return}await this.patchNoContent(e,Ne)}async delete(e){if(e===void 0){await super.delete();return}await this.target(e).delete()}async listTeammates(e){if(e!==void 0)return await this.target(e).listTeammates();let t=l.expandPath(`/shifts/{shift_id}/teammates`,{shift_id:this.id});return((await this.base.requestJson(`GET`,t))._results??[]).map(e=>new q(this.base,e))}async addTeammates(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Adding teammates requires a request body.`);await this.target(e).addTeammates(t);return}let n=l.expandPath(`/shifts/{shift_id}/teammates`,{shift_id:this.id});await this.base.requestJson(`POST`,n,{body:e})}async removeTeammates(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Removing teammates requires a request body.`);await this.target(e).removeTeammates(t);return}let n=l.expandPath(`/shifts/{shift_id}/teammates`,{shift_id:this.id});await this.base.requestJson(`DELETE`,n,{body:e})}async list(){return await this.base.requestJson(`GET`,`/shifts`)}async create(t){let n=await this.base.requestJson(`POST`,`/shifts`,{body:t});return new e(this.base,n)}async get(e){return await this.target(e).refresh()}target(t){return new e(this.base,void 0,t)}};const Fe=e=>({body:e.body,channel_ids:e.channel_ids===null?void 0:e.channel_ids,is_default:e.is_default,is_visible_for_all_teammate_channels:e.is_visible_for_all_teammate_channels,name:e.name??void 0,sender_info:e.sender_info??void 0});var Y=class e extends u{selfPath(){return l.expandPath(`/signatures/{signature_id}`,{signature_id:this.id})}get name(){return this.pick(`name`)}set name(e){this.assign(`name`,e)}get body(){return this.pick(`body`)}set body(e){this.assign(`body`,e)}get senderInfo(){return this.pick(`sender_info`)}set senderInfo(e){this.assign(`sender_info`,e)}get isVisibleForAllTeammateChannels(){return this.pick(`is_visible_for_all_teammate_channels`)}set isVisibleForAllTeammateChannels(e){this.assign(`is_visible_for_all_teammate_channels`,e)}get isDefault(){return this.pick(`is_default`)}set isDefault(e){this.assign(`is_default`,e)}get isPrivate(){return this.pick(`is_private`)}get channelIds(){return this.pick(`channel_ids`)}set channelIds(e){this.assign(`channel_ids`,e)}toUpdateBody(){return Fe(this.state)}async update(e,t){if(typeof e==`string`){await this.target(e).update(t??{});return}await this.patchReplaceFromResponse(e)}async delete(e){if(e===void 0){await super.delete();return}await this.target(e).delete()}async get(e){return await this.target(e).refresh()}target(t){return new e(this.base,void 0,t)}async listTeammate(e){let t=l.expandPath(`/teammates/{teammate_id}/signatures`,{teammate_id:e});return await this.base.requestJson(`GET`,t)}async createTeammate(t,n){let r=l.expandPath(`/teammates/{teammate_id}/signatures`,{teammate_id:t}),i=await this.base.requestJson(`POST`,r,{body:n});return new e(this.base,i)}async listTeam(e){let t=l.expandPath(`/teams/{team_id}/signatures`,{team_id:e});return await this.base.requestJson(`GET`,t)}async createTeam(t,n){let r=l.expandPath(`/teams/{team_id}/signatures`,{team_id:t}),i=await this.base.requestJson(`POST`,r,{body:n});return new e(this.base,i)}};const Ie=(e,t)=>{let{permissions:n,...r}=t,i=Object.fromEntries(Object.entries(r).filter(([,e])=>e!==void 0)),a={...e,...i};if(n!==void 0){let t=n.contacts,r=e.permissions.contacts;a={...a,permissions:{...e.permissions,...n,contacts:t===void 0?r:{...r,...t}}}}return a},Le=e=>{let t=e.contacts;if(t===void 0)return;let{access:n}=t;if(n===void 0)return;let r={access:n};return t.contact_list_ids!==void 0&&(r.contact_list_ids=t.contact_list_ids),{contacts:r}},X=e=>{let t={name:e.name};e.description!==null&&(t.description=e.description);let n=Le(e.permissions);return n!==void 0&&(t.permissions=n),t};var Z=class e extends u{selfPath(){return l.expandPath(`/teammate_groups/{teammate_group_id}`,{teammate_group_id:this.id})}get name(){return this.pick(`name`)}set name(e){this.assign(`name`,e)}get description(){return this.pick(`description`)}set description(e){this.assign(`description`,e)}get isManagedByScim(){return this.pick(`is_managed_by_scim`)}get permissions(){return this.pick(`permissions`)}set permissions(e){this.assign(`permissions`,e)}toUpdateBody(){return X(this.state)}async update(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Updating a teammate group by ID requires a request body.`);await this.target(e).update(t);return}await this.patchNoContent(e,Ie)}async listInboxes(){let e=l.expandPath(`/teammate_groups/{teammate_group_id}/inboxes`,{teammate_group_id:this.id});return await this.base.requestJson(`GET`,e)}async addInboxes(e){let t=l.expandPath(`/teammate_groups/{teammate_group_id}/inboxes`,{teammate_group_id:this.id});await this.base.requestJson(`POST`,t,{body:e})}async removeInboxes(e){let t=l.expandPath(`/teammate_groups/{teammate_group_id}/inboxes`,{teammate_group_id:this.id});await this.base.requestJson(`DELETE`,t,{body:e})}async listTeammates(){let e=l.expandPath(`/teammate_groups/{teammate_group_id}/teammates`,{teammate_group_id:this.id});return((await this.base.requestJson(`GET`,e))._results??[]).map(e=>new q(this.base,e))}async addTeammates(e){let t=l.expandPath(`/teammate_groups/{teammate_group_id}/teammates`,{teammate_group_id:this.id});await this.base.requestJson(`POST`,t,{body:e})}async removeTeammates(e){let t=l.expandPath(`/teammate_groups/{teammate_group_id}/teammates`,{teammate_group_id:this.id});await this.base.requestJson(`DELETE`,t,{body:e})}async listTeams(){let e=l.expandPath(`/teammate_groups/{teammate_group_id}/teams`,{teammate_group_id:this.id});return await this.base.requestJson(`GET`,e)}async addTeams(e){let t=l.expandPath(`/teammate_groups/{teammate_group_id}/teams`,{teammate_group_id:this.id});await this.base.requestJson(`POST`,t,{body:e})}async removeTeams(e){let t=l.expandPath(`/teammate_groups/{teammate_group_id}/teams`,{teammate_group_id:this.id});await this.base.requestJson(`DELETE`,t,{body:e})}async list(){return await this.base.requestJson(`GET`,`/teammate_groups`)}async create(t){let n=await this.base.requestJson(`POST`,`/teammate_groups`,{body:t});return new e(this.base,n)}async get(e){let t=this.target(e);return await t.refresh(),t}target(t){return new e(this.base,void 0,t)}};const Re=e=>{if(!e)return;let t={};return e.q!==void 0&&(t.q=String(e.q)),e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),e.sort_by!==void 0&&(t.sort_by=String(e.sort_by)),e.sort_order!==void 0&&(t.sort_order=String(e.sort_order)),t},ze=e=>{if(!e)return;let t={};return e.sort_by!==void 0&&(t.sort_by=String(e.sort_by)),e.sort_order!==void 0&&(t.sort_order=String(e.sort_order)),t},Be=e=>{if(!e)return;let t={};return e.sort_by!==void 0&&(t.sort_by=String(e.sort_by)),e.sort_order!==void 0&&(t.sort_order=String(e.sort_order)),t},Ve=e=>{if(!e)return;let t={};return e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),e.sort_by!==void 0&&(t.sort_by=String(e.sort_by)),e.sort_order!==void 0&&(t.sort_order=String(e.sort_order)),t},He=e=>{if(!e)return;let t={};return e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),t};var Q=class e{state;base;teamId;constructor(e,t,n){this.base=e,this.state=t===void 0?void 0:structuredClone(t),this.teamId=n}get id(){let e=this.state?.id??this.teamId;if(e===void 0)throw Error(`This team operation requires an ID.`);return e}get links(){return this.requireState()._links}get data(){return this.state}requireState(){if(this.state===void 0)throw Error(`This team operation requires fetched resource data.`);return this.state}selfPath(){return l.expandPath(`/teams/{team_id}`,{team_id:this.id})}async refresh(){let e=await this.base.requestJson(`GET`,this.selfPath());return this.state=structuredClone(e),this}async listChannels(){let e=l.expandPath(`/teams/{team_id}/channels`,{team_id:this.id});return await this.base.requestJson(`GET`,e)}async listContactGroups(){let e=l.expandPath(`/teams/{team_id}/contact_groups`,{team_id:this.id});return await this.base.requestJson(`GET`,e)}async createContactGroup(e){let t=l.expandPath(`/teams/{team_id}/contact_groups`,{team_id:this.id});await this.base.requestJson(`POST`,t,{body:e})}async listContactLists(){let e=l.expandPath(`/teams/{team_id}/contact_lists`,{team_id:this.id});return await this.base.requestJson(`GET`,e)}async createContactList(e){let t=l.expandPath(`/teams/{team_id}/contact_lists`,{team_id:this.id});await this.base.requestJson(`POST`,t,{body:e})}async listContacts(e){let t=l.expandPath(`/teams/{team_id}/contacts`,{team_id:this.id});return await this.base.requestJson(`GET`,t,{query:Re(e)})}async createContact(e){let t=l.expandPath(`/teams/{team_id}/contacts`,{team_id:this.id});return await this.base.requestJson(`POST`,t,{body:e})}async listInboxes(){let e=l.expandPath(`/teams/{team_id}/inboxes`,{team_id:this.id});return await this.base.requestJson(`GET`,e)}async createInbox(e){let t=l.expandPath(`/teams/{team_id}/inboxes`,{team_id:this.id}),n=await this.base.requestJson(`POST`,t,{body:e});return new I(this.base,n)}async listMessageTemplateFolders(e){let t=l.expandPath(`/teams/{team_id}/message_template_folders`,{team_id:this.id});return await this.base.requestJson(`GET`,t,{query:ze(e)})}async createMessageTemplateFolder(e){let t=l.expandPath(`/teams/{team_id}/message_template_folders`,{team_id:this.id});return await this.base.requestJson(`POST`,t,{body:e})}async listMessageTemplates(e){let t=l.expandPath(`/teams/{team_id}/message_templates`,{team_id:this.id});return await this.base.requestJson(`GET`,t,{query:Be(e)})}async createMessageTemplate(e){let t=l.expandPath(`/teams/{team_id}/message_templates`,{team_id:this.id});return await this.base.requestJson(`POST`,t,{body:e})}async listRules(){let e=l.expandPath(`/teams/{team_id}/rules`,{team_id:this.id});return await this.base.requestJson(`GET`,e)}async listShifts(){let e=l.expandPath(`/teams/{team_id}/shifts`,{team_id:this.id});return await this.base.requestJson(`GET`,e)}async createShift(e){let t=l.expandPath(`/teams/{team_id}/shifts`,{team_id:this.id});return await this.base.requestJson(`POST`,t,{body:e})}async listSignatures(){let e=l.expandPath(`/teams/{team_id}/signatures`,{team_id:this.id});return await this.base.requestJson(`GET`,e)}async createSignature(e){let t=l.expandPath(`/teams/{team_id}/signatures`,{team_id:this.id}),n=await this.base.requestJson(`POST`,t,{body:e});return new Y(this.base,n)}async listTags(e){let t=l.expandPath(`/teams/{team_id}/tags`,{team_id:this.id});return await this.base.requestJson(`GET`,t,{query:Ve(e)})}async createTag(e){let t=l.expandPath(`/teams/{team_id}/tags`,{team_id:this.id}),n=await this.base.requestJson(`POST`,t,{body:e});return new C(this.base,n)}async addTeammates(e){let t=l.expandPath(`/teams/{team_id}/teammates`,{team_id:this.id});await this.base.requestJson(`POST`,t,{body:e})}async removeTeammates(e){let t=l.expandPath(`/teams/{team_id}/teammates`,{team_id:this.id});await this.base.requestJson(`DELETE`,t,{body:e})}async listViews(e){let t=l.expandPath(`/teams/{team_id}/views`,{team_id:this.id});return await this.base.requestJson(`GET`,t,{query:He(e)})}async createView(e){let t=l.expandPath(`/teams/{team_id}/views`,{team_id:this.id});return await this.base.requestJson(`POST`,t,{body:e})}async listTeams(){return await this.base.requestJson(`GET`,`/teams`)}async getTeam(e){let t=this.target(e);return await t.refresh(),t}target(t){return new e(this.base,void 0,t)}};const Ue=e=>{if(!e)return;let t={};return e.limit!==void 0&&(t.limit=String(e.limit)),e.page_token!==void 0&&(t.page_token=String(e.page_token)),t},We=(e,t)=>{let n=Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),r={...e,...n};return Object.hasOwn(t,`highlight`)&&(r={...r,highlight:t.highlight??null}),r},Ge=e=>({assignee_ids:e.assignee_ids,highlight:e.highlight??void 0,inbox_ids:e.inbox_ids,name:e.name,no_tags:e.no_tags,not_assignee_ids:e.not_assignee_ids,not_tag_ids:e.not_tag_ids,tag_ids:e.tag_ids});var $=class e extends u{selfPath(){return l.expandPath(`/views/{view_id}`,{view_id:this.id})}get name(){return this.pick(`name`)}set name(e){this.assign(`name`,e)}get highlight(){return this.pick(`highlight`)}set highlight(e){this.assign(`highlight`,e)}get inboxIds(){return this.pick(`inbox_ids`)}set inboxIds(e){this.assign(`inbox_ids`,e)}get tagIds(){return this.pick(`tag_ids`)}set tagIds(e){this.assign(`tag_ids`,e)}get notTagIds(){return this.pick(`not_tag_ids`)}set notTagIds(e){this.assign(`not_tag_ids`,e)}get noTags(){return this.pick(`no_tags`)}set noTags(e){this.assign(`no_tags`,e)}get assigneeIds(){return this.pick(`assignee_ids`)}set assigneeIds(e){this.assign(`assignee_ids`,e)}get notAssigneeIds(){return this.pick(`not_assignee_ids`)}set notAssigneeIds(e){this.assign(`not_assignee_ids`,e)}toUpdateBody(){return Ge(this.state)}async update(e,t){if(typeof e==`string`){if(t===void 0)throw Error(`Updating a view by ID requires a request body.`);await this.target(e).update(t);return}await this.patchNoContent(e,We)}async addTeammates(e){let t=l.expandPath(`/views/{view_id}/teammates`,{view_id:this.id});await this.base.requestJson(`POST`,t,{body:e})}async list(e){return await this.base.requestJson(`GET`,`/views`,{query:Ue(e)})}async get(e){let t=this.target(e);return await t.refresh(),t}target(t){return new e(this.base,void 0,t)}};const Ke=()=>{let e=process.env.FRONT_API_TOKEN;if(!e)return;let t=e.trim();return t.length>0?t:void 0};var qe=class extends l{accounts;analytics;applications;channels;comments;company;contactLists;contacts;conversations;customFieldsGlobal;downloads;drafts;events;inboxes;knowledgeBases;links;me;messageTemplateFolders;messageTemplates;messages;rules;shifts;tags;signatures;teammateGroups;teammates;teams;views;constructor(e){let{apiKey:t,baseUrl:n,fetch:r,userAgent:i}=e??{},a=t??Ke();if(!a)throw Error(`Front API token is required. Set FRONT_API_TOKEN in the environment or pass { apiKey: "..." } to the Front constructor.`);super({apiKey:a,baseUrl:n??`https://api2.frontapp.com`,...r===void 0?{}:{fetch:r},...i===void 0?{}:{userAgent:i}}),this.accounts=new f(this),this.analytics=new h(this),this.applications=new g(this),this.channels=new _(this),this.comments=new v(this),this.company=new w(this),this.contactLists=new T(this),this.contacts=new D(this),this.conversations=new k(this),this.customFieldsGlobal=new A(this),this.downloads=new j(this),this.drafts=new M(this),this.events=new P(this),this.inboxes=new I(this),this.knowledgeBases=new R(this),this.links=new V(this),this.me=new H(this),this.messageTemplateFolders=new W(this),this.messageTemplates=new U(this),this.messages=new G(this),this.rules=new K(this),this.shifts=new J(this),this.tags=new C(this),this.signatures=new Y(this),this.teammateGroups=new Z(this),this.teammates=new q(this),this.teams=new Q(this),this.views=new $(this)}};exports.Front=qe,exports.FrontAccounts=f,exports.FrontAnalytics=h,exports.FrontAnalyticsExport=p,exports.FrontAnalyticsReport=m,exports.FrontApiError=n,exports.FrontApplications=g,exports.FrontBase=l,exports.FrontChannels=_,exports.FrontComments=v,exports.FrontCompany=w,exports.FrontContactLists=T,exports.FrontContacts=D,exports.FrontConversations=k,exports.FrontCustomFieldsGlobal=A,exports.FrontDownloads=j,exports.FrontDrafts=M,exports.FrontEvents=P,exports.FrontInboxes=I,exports.FrontKnowledgeBaseArticle=z,exports.FrontKnowledgeBaseCategory=B,exports.FrontKnowledgeBases=R,exports.FrontLinks=V,exports.FrontMe=H,exports.FrontMessageTemplateFolders=W,exports.FrontMessageTemplates=U,exports.FrontMessages=G,exports.FrontResource=u,exports.FrontRules=K,exports.FrontShifts=J,exports.FrontSignatures=Y,exports.FrontTags=C,exports.FrontTeammateGroups=Z,exports.FrontTeammates=q,exports.FrontTeams=Q,exports.FrontViews=$,exports.normalizeFrontResponse=i,exports.pageTokenFromPaginationNextUrl=r;
2
+ //# sourceMappingURL=index.cjs.map