@dugjason/front-node 0.0.1

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jason
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # front-node
2
+
3
+ A modern TypeScript SDK for the [Front](https://front.com) API.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @dugjason/front-node
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { Front } from "@dugjason/front-node";
15
+
16
+ const front = new Front({ apiKey: process.env.FRONT_API_TOKEN });
17
+ ```
18
+
19
+ ## Development
20
+
21
+ ```bash
22
+ bun install
23
+ bun test
24
+ bun run check
25
+ ```
26
+
27
+ ## Release
28
+
29
+ Releases are managed by Changesets. Add a changeset for user-facing changes:
30
+
31
+ ```bash
32
+ bun run changeset
33
+ ```
34
+
35
+ Merging to `main` opens or updates a version PR. Merging that version PR publishes
36
+ to npm as `@dugjason/front-node` through npm trusted publishing.
37
+
38
+ ## Custom `fetch`
39
+
40
+ You can use the library with a custom fetch library, compatible with `node:fetch`.
41
+ An illustrative example could be a fetch implementation with built-in tracing or custom telemetry;
42
+
43
+ ```ts
44
+ import { Front } from "@dugjason/front-node";
45
+
46
+ const loggingFetch: typeof fetch = async (input, init) => {
47
+ const t0 = performance.now();
48
+ const response = await globalThis.fetch(input, init);
49
+ console.log(
50
+ `${init?.method ?? "GET"} ${input} ${response.status} ${Math.round(performance.now() - t0)}ms`,
51
+ );
52
+ return response;
53
+ };
54
+ const front = new Front({ fetch: loggingFetch });
55
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=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 t=(e,t)=>{if(e==null||e===``)return null;try{let n=new URL(e,t).searchParams.get(`page_token`);if(n!==null&&n!==``)return n}catch{}return e},n=(e,r)=>{if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>n(e,r));let i=e,a={};for(let[e,o]of Object.entries(i)){if(e===`_pagination`){if(typeof o==`object`&&o&&!Array.isArray(o)){let e=o,n=e.next,i=typeof n==`string`?t(n,r):n;a.pagination={...e,next:i}}continue}a[e]=typeof o==`object`&&o?n(o,r):o}return a},r=/\/$/u,i=(e,t)=>`${e.replace(r,``)}${t.startsWith(`/`)?t:`/${t}`}`,a=(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 o=class{apiKey;baseUrl;fetchImpl;constructor(e){this.apiKey=e.apiKey,this.baseUrl=e.baseUrl??`https://api2.frontapp.com`,this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis)}buildUrl(e,t){return a(i(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(t,r,i){let a=this.buildUrl(r,i?.query),o=new Headers({Accept:`application/json`,Authorization:`Bearer ${this.apiKey}`});i?.body!==void 0&&o.set(`Content-Type`,`application/json`);let s=await this.fetchImpl(a,{body:i?.body===void 0?void 0:JSON.stringify(i.body),headers:o,method:t});if(!s.ok){let t,n=await s.text();try{t=JSON.parse(n)}catch{t=n}throw new e(s,t)}if(s.status===204)return;let c=await s.text();if(c.length!==0)return n(JSON.parse(c),this.baseUrl)}async requestWithoutParsingBody(t,n,r){let i=this.buildUrl(n,r?.query),a=new Headers({Accept:`*/*`,Authorization:`Bearer ${this.apiKey}`});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:t});if(!o.ok){let t,n=await o.text();try{t=JSON.parse(n)}catch{t=n}throw new e(o,t)}return o}},s=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}set links(e){this.assign(`_links`,e)}get data(){return this.state}pick(e){return this.state[e]}assign(e,t){this.state={...this.state,[e]:t}}replaceState(e){this.state=structuredClone(e)}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.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 c=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 l=class extends s{selfPath(){return o.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){await this.patchReplaceFromResponse(e)}async listContacts(e){let t=o.expandPath(`/accounts/{account_id}/contacts`,{account_id:this.id});return await this.base.requestJson(`GET`,t,{query:ee(e)})}async addContacts(e){let t=o.expandPath(`/accounts/{account_id}/contacts`,{account_id:this.id});await this.base.requestJson(`POST`,t,{body:e})}async removeContacts(e){let t=o.expandPath(`/accounts/{account_id}/contacts`,{account_id:this.id});await this.base.requestJson(`DELETE`,t,{body:e})}},u=class{base;constructor(e){this.base=e}async list(e){return await this.base.requestJson(`GET`,`/accounts`,{query:c(e)})}async create(e){let t=await this.base.requestJson(`POST`,`/accounts`,{body:e});return new l(this.base,t)}async get(e){let t=o.expandPath(`/accounts/{account_id}`,{account_id:e}),n=await this.base.requestJson(`GET`,t);return new l(this.base,n)}async listCustomFields(){return await this.base.requestJson(`GET`,`/accounts/custom_fields`)}},d=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 o.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}},f=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 o.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}},p=class{base;constructor(e){this.base=e}async createExport(e){let t=await this.base.requestJson(`POST`,`/analytics/exports`,{body:e});return new d(this.base,t)}async getExport(e){let t=o.expandPath(`/analytics/exports/{export_id}`,{export_id:e}),n=await this.base.requestJson(`GET`,t);return new d(this.base,n)}async createReport(e){let t=await this.base.requestJson(`POST`,`/analytics/reports`,{body:e});return new f(this.base,t)}async getReport(e){let t=o.expandPath(`/analytics/reports/{report_uid}`,{report_uid:e}),n=await this.base.requestJson(`GET`,t);return new f(this.base,n)}},m=class{base;constructor(e){this.base=e}async triggerEvent(e,t){let n=o.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 h=class extends s{selfPath(){return o.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){await this.patchNoContent(e,ne)}async createDraft(e){let t=o.expandPath(`/channels/{channel_id}/drafts`,{channel_id:this.id});return await this.base.requestJson(`POST`,t,{body:e})}async receiveCustomMessage(e){let t=o.expandPath(`/channels/{channel_id}/incoming_messages`,{channel_id:this.id});return await this.base.requestJson(`POST`,t,{body:e})}async createMessage(e){let t=o.expandPath(`/channels/{channel_id}/messages`,{channel_id:this.id});return await this.base.requestJson(`POST`,t,{body:e})}async validate(){let e=o.expandPath(`/channels/{channel_id}/validate`,{channel_id:this.id});return await this.base.requestJson(`POST`,e)}},g=class{base;constructor(e){this.base=e}async list(){return await this.base.requestJson(`GET`,`/channels`)}async get(e){let t=o.expandPath(`/channels/{channel_id}`,{channel_id:e}),n=await this.base.requestJson(`GET`,t);return new h(this.base,n)}};const ie=e=>({body:e.body,is_pinned:e.is_pinned});var _=class e extends s{selfPath(){return o.expandPath(`/comments/{comment_id}`,{comment_id:this.id})}patchPath(){return o.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(){return Promise.reject(Error(`Deleting comment ${this.id} is not supported by the Front REST API for this path.`))}toUpdateBody(){return ie(this.state)}async update(e){let t=await this.base.requestJson(`PATCH`,this.patchPath(),{body:e});this.replaceState(t)}async listMentions(){let e=o.expandPath(`/comments/{comment_id}/mentions`,{comment_id:this.id});return await this.base.requestJson(`GET`,e)}async addReply(t){let n=o.expandPath(`/comments/{comment_id}/replies`,{comment_id:this.id}),r=await this.base.requestJson(`POST`,n,{body:t});return new e(this.base,r)}async downloadAttachment(e){let t=o.expandPath(`/comments/{comment_id}/download/{attachment_link_id}`,{attachment_link_id:e,comment_id:this.id});return await this.base.requestWithoutParsingBody(`GET`,t)}},v=class{base;constructor(e){this.base=e}async get(e){let t=o.expandPath(`/comments/{comment_id}`,{comment_id:e}),n=await this.base.requestJson(`GET`,t);return new _(this.base,n)}};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},oe=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},se=(e,t)=>{let{parent_tag_id:n,...r}=t,i=Object.fromEntries(Object.entries(r).filter(([,e])=>e!==void 0));return{...e,...i}},ce=(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 y=class e extends s{parentTagIdForUpdate;constructor(e,t){super(e,t),this.parentTagIdForUpdate=void 0}selfPath(){return o.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 ce(this.state,this.parentTagIdForUpdate)}async update(e){await this.patchNoContent(e,se),`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 listChildren(){let t=o.expandPath(`/tags/{tag_id}/children`,{tag_id:this.id});return((await this.base.requestJson(`GET`,t))._results??[]).map(t=>new e(this.base,t))}async createChild(t){let n=o.expandPath(`/tags/{tag_id}/children`,{tag_id:this.id}),r=await this.base.requestJson(`POST`,n,{body:t});return new e(this.base,r)}async listTaggedConversations(e){let t=o.expandPath(`/tags/{tag_id}/conversations`,{tag_id:this.id});return await this.base.requestJson(`GET`,t,{query:oe(e)})}},le=class{base;constructor(e){this.base=e}async list(e){return await this.base.requestJson(`GET`,`/tags`,{query:ae(e)})}async create(e){let t=await this.base.requestJson(`POST`,`/tags`,{body:e});return new y(this.base,t)}async get(e){let t=o.expandPath(`/tags/{tag_id}`,{tag_id:e}),n=await this.base.requestJson(`GET`,t);return new y(this.base,n)}};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)),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 b=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=o.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:ue(e)})}async createTag(e){let t=await this.base.requestJson(`POST`,`/company/tags`,{body:e});return new y(this.base,t)}};const de=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 x=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=o.expandPath(`/contact_lists/{contact_list_id}`,{contact_list_id:e});await this.base.requestJson(`DELETE`,t)}async listContacts(e,t){let n=o.expandPath(`/contact_lists/{contact_list_id}/contacts`,{contact_list_id:e});return await this.base.requestJson(`GET`,n,{query:de(t)})}async addContacts(e,t){let n=o.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=o.expandPath(`/contact_lists/{contact_list_id}/contacts`,{contact_list_id:e});await this.base.requestJson(`DELETE`,n,{body:t})}};const S=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}},fe=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},pe=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},me=(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},he=e=>({custom_fields:e.custom_fields,description:e.description,links:e.links,name:e.name});var C=class extends s{selfPath(){return o.expandPath(`/contacts/{contact_id}`,{contact_id:this.id})}constructor(e,t){super(e,S(t))}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 he(this.state)}async update(e){await this.patchNoContent(e,me)}async refresh(){let e=await this.base.requestJson(`GET`,this.selfPath());return this.replaceState(S(e)),this.onAfterRefresh(),this}async listConversations(e){let t=o.expandPath(`/contacts/{contact_id}/conversations`,{contact_id:this.id});return await this.base.requestJson(`GET`,t,{query:pe(e)})}async addHandle(e){let t=o.expandPath(`/contacts/{contact_id}/handles`,{contact_id:this.id});await this.base.requestJson(`POST`,t,{body:e});let n=this.pick(`handles`)??[];this.assign(`handles`,[...n,e])}async deleteHandle(e){let t=o.expandPath(`/contacts/{contact_id}/handles`,{contact_id:this.id});await this.base.requestJson(`DELETE`,t,{body:e});let n=this.pick(`handles`)??[];this.assign(`handles`,n.filter(t=>!(t.handle===e.handle&&t.source===e.source)))}async listNotes(){let e=o.expandPath(`/contacts/{contact_id}/notes`,{contact_id:this.id});return await this.base.requestJson(`GET`,e)}async addNote(e){let t=o.expandPath(`/contacts/{contact_id}/notes`,{contact_id:this.id});return await this.base.requestJson(`POST`,t,{body:e})}},w=class{base;constructor(e){this.base=e}async list(e){return await this.base.requestJson(`GET`,`/contacts`,{query:fe(e)})}async create(e){let t=await this.base.requestJson(`POST`,`/contacts`,{body:e});return new C(this.base,t)}async listCustomFields(){return await this.base.requestJson(`GET`,`/contacts/custom_fields`)}async merge(e){let t=await this.base.requestJson(`POST`,`/contacts/merge`,{body:e});return new C(this.base,t)}async get(e){let t=o.expandPath(`/contacts/{contact_id}`,{contact_id:e}),n=await this.base.requestJson(`GET`,t);return new C(this.base,n)}};const ge=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},_e=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},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)),t},ye=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},be=e=>{if(!e)return;let t={};return e.ignore_errors!==void 0&&(t.ignore_errors=e.ignore_errors?`true`:`false`),t},xe=e=>{switch(e){case`archived`:return`archived`;case`deleted`:return`deleted`;case`open`:return`unassigned`;case`spam`:return`deleted`;default:return e}},Se=e=>{if(e===`archived`)return`archived`;if(e===`deleted`)return`deleted`;if(e===`unassigned`)return`open`},Ce=(e,t)=>{let n=Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),r={...e};if(n.status!==void 0&&(r={...r,status:xe(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},we=e=>{let t=Se(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 T=class extends s{selfPath(){return o.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 we(this.state)}async update(e){await this.patchNoContent(e,Ce)}async delete(){await super.delete()}async updateAssignee(e){let t=o.expandPath(`/conversations/{conversation_id}/assignee`,{conversation_id:this.id});await this.base.requestJson(`PUT`,t,{body:e})}async listComments(){let e=o.expandPath(`/conversations/{conversation_id}/comments`,{conversation_id:this.id});return await this.base.requestJson(`GET`,e)}async addComment(e){let t=o.expandPath(`/conversations/{conversation_id}/comments`,{conversation_id:this.id}),n=await this.base.requestJson(`POST`,t,{body:e});return new _(this.base,n)}async listDrafts(){let e=o.expandPath(`/conversations/{conversation_id}/drafts`,{conversation_id:this.id});return await this.base.requestJson(`GET`,e)}async createDraftReply(e){let t=o.expandPath(`/conversations/{conversation_id}/drafts`,{conversation_id:this.id});return await this.base.requestJson(`POST`,t,{body:e})}async listEvents(e){let t=o.expandPath(`/conversations/{conversation_id}/events`,{conversation_id:this.id});return await this.base.requestJson(`GET`,t,{query:ve(e)})}async listFollowers(){let e=o.expandPath(`/conversations/{conversation_id}/followers`,{conversation_id:this.id});return await this.base.requestJson(`GET`,e)}async addFollowers(e,t){let n=o.expandPath(`/conversations/{conversation_id}/followers`,{conversation_id:this.id});await this.base.requestJson(`POST`,n,{body:e,query:be(t)})}async deleteFollowers(e){let t=o.expandPath(`/conversations/{conversation_id}/followers`,{conversation_id:this.id});await this.base.requestJson(`DELETE`,t,{body:e})}async listInboxes(){let e=o.expandPath(`/conversations/{conversation_id}/inboxes`,{conversation_id:this.id});return await this.base.requestJson(`GET`,e)}async addLink(e){let t=o.expandPath(`/conversations/{conversation_id}/links`,{conversation_id:this.id});await this.base.requestJson(`POST`,t,{body:e})}async removeLinks(e){let t=o.expandPath(`/conversations/{conversation_id}/links`,{conversation_id:this.id});await this.base.requestJson(`DELETE`,t,{body:e})}async listMessages(e){let t=o.expandPath(`/conversations/{conversation_id}/messages`,{conversation_id:this.id});return await this.base.requestJson(`GET`,t,{query:ye(e)})}async createMessageReply(e){let t=o.expandPath(`/conversations/{conversation_id}/messages`,{conversation_id:this.id});return await this.base.requestJson(`POST`,t,{body:e})}async updateReminders(e){let t=o.expandPath(`/conversations/{conversation_id}/reminders`,{conversation_id:this.id});await this.base.requestJson(`PATCH`,t,{body:e})}async addTag(e){let t=o.expandPath(`/conversations/{conversation_id}/tags`,{conversation_id:this.id});await this.base.requestJson(`POST`,t,{body:e})}async removeTag(e){let t=o.expandPath(`/conversations/{conversation_id}/tags`,{conversation_id:this.id});await this.base.requestJson(`DELETE`,t,{body:e})}},E=class{base;constructor(e){this.base=e}async list(e){return await this.base.requestJson(`GET`,`/conversations`,{query:ge(e)})}async create(e){let t=await this.base.requestJson(`POST`,`/conversations`,{body:e});return new T(this.base,t)}async listCustomFields(){return await this.base.requestJson(`GET`,`/conversations/custom_fields`)}async search(e,t){let n=o.expandPath(`/conversations/search/{query}`,{query:e});return await this.base.requestJson(`GET`,n,{query:_e(t)})}async get(e){let t=o.expandPath(`/conversations/{conversation_id}`,{conversation_id:e}),n=await this.base.requestJson(`GET`,t);return new T(this.base,n)}},D=class{base;constructor(e){this.base=e}async list(){return await this.base.requestJson(`GET`,`/custom_fields`)}},O=class{base;constructor(e){this.base=e}async download(e){let t=o.expandPath(`/download/{attachment_link_id}`,{attachment_link_id:e});return await this.base.requestWithoutParsingBody(`GET`,t)}},k=class{base;constructor(e){this.base=e}async delete(e,t){let n=o.expandPath(`/drafts/{draft_id}`,{draft_id:e});await this.base.requestJson(`DELETE`,n,{body:t})}async edit(e,t){let n=o.expandPath(`/drafts/{message_id}/`,{message_id:e});return await this.base.requestJson(`PATCH`,n,{body:t})}};const Te=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 A=class{base;constructor(e){this.base=e}async list(e){return await this.base.requestJson(`GET`,`/events`,{query:Te(e)})}async get(e){let t=o.expandPath(`/events/{event_id}`,{event_id:e});return await this.base.requestJson(`GET`,t)}};const Ee=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},j=e=>{let{id:t}=e;if(t===void 0||t===``)throw Error(`Inbox response missing id`);return t};var M=class{state;base;constructor(e,t){this.base=e;let n=j(t);this.state=structuredClone({...t,id:n})}get id(){return this.state.id}get links(){return this.state._links}get data(){return this.state}selfPath(){return o.expandPath(`/inboxes/{inbox_id}`,{inbox_id:this.id})}async refresh(){let e=await this.base.requestJson(`GET`,this.selfPath()),t=j(e);return this.state=structuredClone({...e,id:t}),this}async listChannels(){let e=o.expandPath(`/inboxes/{inbox_id}/channels`,{inbox_id:this.id});return await this.base.requestJson(`GET`,e)}async createChannel(e){let t=o.expandPath(`/inboxes/{inbox_id}/channels`,{inbox_id:this.id});await this.base.requestJson(`POST`,t,{body:e})}async listConversations(e){let t=o.expandPath(`/inboxes/{inbox_id}/conversations`,{inbox_id:this.id});return await this.base.requestJson(`GET`,t,{query:Ee(e)})}async importMessage(e){let t=o.expandPath(`/inboxes/{inbox_id}/imported_messages`,{inbox_id:this.id});return await this.base.requestJson(`POST`,t,{body:e})}async listTeammateAccess(){let e=o.expandPath(`/inboxes/{inbox_id}/teammates`,{inbox_id:this.id});return await this.base.requestJson(`GET`,e)}async addTeammateAccess(e){let t=o.expandPath(`/inboxes/{inbox_id}/teammates`,{inbox_id:this.id});await this.base.requestJson(`POST`,t,{body:e})}async removeTeammateAccess(e){let t=o.expandPath(`/inboxes/{inbox_id}/teammates`,{inbox_id:this.id});await this.base.requestJson(`DELETE`,t,{body:e})}},N=class{base;constructor(e){this.base=e}async list(){return await this.base.requestJson(`GET`,`/inboxes`)}async create(e){let t=await this.base.requestJson(`POST`,`/inboxes`,{body:e});return new M(this.base,t)}async listCustomFields(){return await this.base.requestJson(`GET`,`/inboxes/custom_fields`)}async get(e){let t=o.expandPath(`/inboxes/{inbox_id}`,{inbox_id:e}),n=await this.base.requestJson(`GET`,t);return new M(this.base,n)}};const P=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 F=class{base;constructor(e){this.base=e}async list(){return await this.base.requestJson(`GET`,`/knowledge_bases`)}async create(e){let t=await this.base.requestJson(`POST`,`/knowledge_bases`,{body:e});return new I(this.base,t.id,t)}async get(e){let t=o.expandPath(`/knowledge_bases/{knowledge_base_id}`,{knowledge_base_id:e}),n=await this.base.requestJson(`GET`,t);return new I(this.base,n.id,n)}withId(e){return new I(this.base,e)}article(e){return new L(this.base,e)}category(e){return new R(this.base,e)}},I=class{base;knowledgeBaseId;snapshot;constructor(e,t,n){this.base=e,this.knowledgeBaseId=t,this.snapshot=n}get id(){return this.knowledgeBaseId}get data(){return this.snapshot}async refresh(){let e=o.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=o.expandPath(`/knowledge_bases/{knowledge_base_id}/content`,{knowledge_base_id:this.knowledgeBaseId});return await this.base.requestJson(`GET`,e)}async updateContentDefault(e){let t=o.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=o.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=o.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=o.expandPath(`/knowledge_bases/{knowledge_base_id}/articles`,{knowledge_base_id:this.knowledgeBaseId});return await this.base.requestJson(`GET`,t,{query:P(e)})}async createArticleDefault(e){let t=o.expandPath(`/knowledge_bases/{knowledge_base_id}/articles`,{knowledge_base_id:this.knowledgeBaseId}),n=await this.base.requestJson(`POST`,t,{body:e});return new L(this.base,n.id,n)}async createArticleLocale(e,t){let n=o.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 L(this.base,r.id,r)}async listCategories(e){let t=o.expandPath(`/knowledge_bases/{knowledge_base_id}/categories`,{knowledge_base_id:this.knowledgeBaseId});return await this.base.requestJson(`GET`,t,{query:P(e)})}async createCategoryDefault(e){let t=o.expandPath(`/knowledge_bases/{knowledge_base_id}/categories`,{knowledge_base_id:this.knowledgeBaseId}),n=await this.base.requestJson(`POST`,t,{body:e});return new R(this.base,n.id,n)}async createCategoryLocale(e,t){let n=o.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 R(this.base,r.id,r)}},L=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=o.expandPath(`/knowledge_base_articles/{article_id}`,{article_id:this.articleId});return this.snapshot=await this.base.requestJson(`GET`,e),this}async delete(){let e=o.expandPath(`/knowledge_base_articles/{article_id}`,{article_id:this.articleId});return await this.base.requestJson(`DELETE`,e)}async getContentDefault(){let e=o.expandPath(`/knowledge_base_articles/{article_id}/content`,{article_id:this.articleId});return await this.base.requestJson(`GET`,e)}async updateContentDefault(e){let t=o.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=o.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=o.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=o.expandPath(`/knowledge_base_articles/{article_id}/download/{attachment_id}`,{article_id:this.articleId,attachment_id:e});return await this.base.requestWithoutParsingBody(`GET`,t)}},R=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=o.expandPath(`/knowledge_base_categories/{category_id}`,{category_id:this.categoryId});return this.snapshot=await this.base.requestJson(`GET`,e),this}async delete(){let e=o.expandPath(`/knowledge_base_categories/{category_id}`,{category_id:this.categoryId});await this.base.requestJson(`DELETE`,e)}async listArticles(e){let t=o.expandPath(`/knowledge_base_categories/{category_id}/articles`,{category_id:this.categoryId});return await this.base.requestJson(`GET`,t,{query:P(e)})}async getContentDefault(){let e=o.expandPath(`/knowledge_base_categories/{category_id}/content`,{category_id:this.categoryId});return await this.base.requestJson(`GET`,e)}async updateContentDefault(e){let t=o.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=o.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=o.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 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},Oe=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},ke=(e,t)=>{let n=Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0));return{...e,...n}},Ae=e=>({name:e.name});var z=class extends s{selfPath(){return o.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(){return Promise.reject(Error(`Deleting link ${this.id} is not supported by the Front REST API for this path.`))}toUpdateBody(){return Ae(this.state)}async update(e){await this.patchNoContent(e,ke)}async listConversations(e){let t=o.expandPath(`/links/{link_id}/conversations`,{link_id:this.id});return await this.base.requestJson(`GET`,t,{query:Oe(e)})}},B=class{base;constructor(e){this.base=e}async list(e){return await this.base.requestJson(`GET`,`/links`,{query:De(e)})}async create(e){let t=await this.base.requestJson(`POST`,`/links`,{body:e});return new z(this.base,t)}async listCustomFields(){return await this.base.requestJson(`GET`,`/links/custom_fields`)}async get(e){let t=o.expandPath(`/links/{link_id}`,{link_id:e}),n=await this.base.requestJson(`GET`,t);return new z(this.base,n)}},V=class{base;constructor(e){this.base=e}async details(){return await this.base.requestJson(`GET`,`/me`)}};const je=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},Me=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 H=class extends s{folderIdForUpdate;constructor(e,t){super(e,t),this.folderIdForUpdate=void 0}onAfterRefresh(){this.folderIdForUpdate=void 0}selfPath(){return o.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=Me(this.state);return this.folderIdForUpdate!==void 0&&(e.folder_id=this.folderIdForUpdate??void 0),e}async update(e){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 downloadAttachment(e){let t=o.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`,t)}},U=class{base;constructor(e){this.base=e}async list(e){return await this.base.requestJson(`GET`,`/message_templates`,{query:je(e)})}async create(e){let t=await this.base.requestJson(`POST`,`/message_templates`,{body:e});return new H(this.base,t)}async get(e){let t=o.expandPath(`/message_templates/{message_template_id}`,{message_template_id:e}),n=await this.base.requestJson(`GET`,t);return new H(this.base,n)}};const Ne=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},Pe=(e,t)=>{let n={name:e.name};return t!==void 0&&(n.parent_folder_id=t??void 0),n};var W=class e extends s{parentFolderIdForUpdate;constructor(e,t){super(e,t),this.parentFolderIdForUpdate=void 0}onAfterRefresh(){this.parentFolderIdForUpdate=void 0}selfPath(){return o.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 Pe(this.state,this.parentFolderIdForUpdate)}async update(e){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(){await this.base.requestJson(`DELETE`,this.selfPath())}async listChildFolders(){let e=o.expandPath(`/message_template_folders/{message_template_folder_id}/message_template_folders`,{message_template_folder_id:this.id});return await this.base.requestJson(`GET`,e)}async createChildFolder(t){let n=o.expandPath(`/message_template_folders/{message_template_folder_id}/message_template_folders`,{message_template_folder_id:this.id}),r=await this.base.requestJson(`POST`,n,{body:t});return new e(this.base,r)}async listChildTemplates(){let e=o.expandPath(`/message_template_folders/{message_template_folder_id}/message_templates`,{message_template_folder_id:this.id});return await this.base.requestJson(`GET`,e)}async createChildTemplate(e){let t=o.expandPath(`/message_template_folders/{message_template_folder_id}/message_templates`,{message_template_folder_id:this.id}),n=await this.base.requestJson(`POST`,t,{body:e});return new H(this.base,n)}},G=class{base;constructor(e){this.base=e}async list(e){return await this.base.requestJson(`GET`,`/message_template_folders`,{query:Ne(e)})}async create(e){let t=await this.base.requestJson(`POST`,`/message_template_folders`,{body:e});return new W(this.base,t)}async get(e){let t=o.expandPath(`/message_template_folders/{message_template_folder_id}`,{message_template_folder_id:e}),n=await this.base.requestJson(`GET`,t);return new W(this.base,n)}};const Fe={};var K=class{base;messageId;snapshot;constructor(e,t,n){this.base=e,this.messageId=t,this.snapshot=n}get messageIdParam(){return this.messageId}get data(){return this.snapshot}async refresh(){let e=o.expandPath(`/messages/{message_id}`,{message_id:this.messageId});return this.snapshot=await this.base.requestJson(`GET`,e),this}async fetchRaw(e){let t=o.expandPath(`/messages/{message_id}`,{message_id:this.messageId}),n={...e?.headers};return n.Accept===void 0&&(n.Accept=`application/json`),await this.base.requestWithoutParsingBody(`GET`,t,{headers:n})}async downloadAttachment(e){let t=o.expandPath(`/messages/{message_id}/download/{attachment_link_id}`,{attachment_link_id:e,message_id:this.messageId});return await this.base.requestWithoutParsingBody(`GET`,t)}async getSeen(){let e=o.expandPath(`/messages/{message_id}/seen`,{message_id:this.messageId});return await this.base.requestJson(`GET`,e)}async markSeen(){let e=o.expandPath(`/messages/{message_id}/seen`,{message_id:this.messageId});await this.base.requestJson(`POST`,e,{body:Fe})}},q=class{base;constructor(e){this.base=e}async get(e){let t=o.expandPath(`/messages/{message_id}`,{message_id:e}),n=await this.base.requestJson(`GET`,t);return new K(this.base,e,n)}withId(e){return new K(this.base,e)}},J=class{base;constructor(e){this.base=e}async list(){return await this.base.requestJson(`GET`,`/rules`)}async get(e){let t=o.expandPath(`/rules/{rule_id}`,{rule_id:e});return await this.base.requestJson(`GET`,t)}};const Ie=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=Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0));return{...e,...n}},Re=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 Y=class extends s{selfPath(){return o.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 Re(this.state)}async update(e){await this.patchNoContent(e,Le)}async listAssignedConversations(e){let t=o.expandPath(`/teammates/{teammate_id}/conversations`,{teammate_id:this.id});return await this.base.requestJson(`GET`,t,{query:Ie(e)})}},X=class{base;constructor(e){this.base=e}async list(){return await this.base.requestJson(`GET`,`/teammates`)}async get(e){let t=o.expandPath(`/teammates/{teammate_id}`,{teammate_id:e}),n=await this.base.requestJson(`GET`,t);return new Y(this.base,n)}};const ze=(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},Be=e=>({color:e.color,name:e.name,times:e.times,timezone:e.timezone});var Z=class extends s{selfPath(){return o.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 Be(this.state)}async update(e){await this.patchNoContent(e,ze)}async listTeammates(){let e=o.expandPath(`/shifts/{shift_id}/teammates`,{shift_id:this.id});return((await this.base.requestJson(`GET`,e))._results??[]).map(e=>new Y(this.base,e))}async addTeammates(e){let t=o.expandPath(`/shifts/{shift_id}/teammates`,{shift_id:this.id});await this.base.requestJson(`POST`,t,{body:e})}async removeTeammates(e){let t=o.expandPath(`/shifts/{shift_id}/teammates`,{shift_id:this.id});await this.base.requestJson(`DELETE`,t,{body:e})}},Ve=class{base;constructor(e){this.base=e}async list(){return await this.base.requestJson(`GET`,`/shifts`)}async create(e){let t=await this.base.requestJson(`POST`,`/shifts`,{body:e});return new Z(this.base,t)}async get(e){let t=o.expandPath(`/shifts/{shift_id}`,{shift_id:e}),n=await this.base.requestJson(`GET`,t);return new Z(this.base,n)}};const He=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 Q=class extends s{selfPath(){return o.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 He(this.state)}async update(e){await this.patchReplaceFromResponse(e)}},Ue=class{base;constructor(e){this.base=e}async get(e){let t=o.expandPath(`/signatures/{signature_id}`,{signature_id:e}),n=await this.base.requestJson(`GET`,t);return new Q(this.base,n)}async listTeammate(e){let t=o.expandPath(`/teammates/{teammate_id}/signatures`,{teammate_id:e});return await this.base.requestJson(`GET`,t)}async createTeammate(e,t){let n=o.expandPath(`/teammates/{teammate_id}/signatures`,{teammate_id:e}),r=await this.base.requestJson(`POST`,n,{body:t});return new Q(this.base,r)}async listTeam(e){let t=o.expandPath(`/teams/{team_id}/signatures`,{team_id:e});return await this.base.requestJson(`GET`,t)}async createTeam(e,t){let n=o.expandPath(`/teams/{team_id}/signatures`,{team_id:e}),r=await this.base.requestJson(`POST`,n,{body:t});return new Q(this.base,r)}};const We=(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},Ge=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}},Ke=e=>{let t={name:e.name};e.description!==null&&(t.description=e.description);let n=Ge(e.permissions);return n!==void 0&&(t.permissions=n),t};var $=class extends s{selfPath(){return o.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 Ke(this.state)}async update(e){await this.patchNoContent(e,We)}async listInboxes(){let e=o.expandPath(`/teammate_groups/{teammate_group_id}/inboxes`,{teammate_group_id:this.id});return await this.base.requestJson(`GET`,e)}async addInboxes(e){let t=o.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=o.expandPath(`/teammate_groups/{teammate_group_id}/inboxes`,{teammate_group_id:this.id});await this.base.requestJson(`DELETE`,t,{body:e})}async listTeammates(){let e=o.expandPath(`/teammate_groups/{teammate_group_id}/teammates`,{teammate_group_id:this.id});return((await this.base.requestJson(`GET`,e))._results??[]).map(e=>new Y(this.base,e))}async addTeammates(e){let t=o.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=o.expandPath(`/teammate_groups/{teammate_group_id}/teammates`,{teammate_group_id:this.id});await this.base.requestJson(`DELETE`,t,{body:e})}async listTeams(){let e=o.expandPath(`/teammate_groups/{teammate_group_id}/teams`,{teammate_group_id:this.id});return await this.base.requestJson(`GET`,e)}async addTeams(e){let t=o.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=o.expandPath(`/teammate_groups/{teammate_group_id}/teams`,{teammate_group_id:this.id});await this.base.requestJson(`DELETE`,t,{body:e})}},qe=class{base;constructor(e){this.base=e}async list(){return await this.base.requestJson(`GET`,`/teammate_groups`)}async create(e){let t=await this.base.requestJson(`POST`,`/teammate_groups`,{body:e});return new $(this.base,t)}async get(e){let t=o.expandPath(`/teammate_groups/{teammate_group_id}`,{teammate_group_id:e}),n=await this.base.requestJson(`GET`,t);return new $(this.base,n)}};const Je=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},Ye=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},Xe=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},Ze=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},Qe=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 $e=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 o.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=o.expandPath(`/teams/{team_id}/channels`,{team_id:this.id});return await this.base.requestJson(`GET`,e)}async listContactGroups(){let e=o.expandPath(`/teams/{team_id}/contact_groups`,{team_id:this.id});return await this.base.requestJson(`GET`,e)}async createContactGroup(e){let t=o.expandPath(`/teams/{team_id}/contact_groups`,{team_id:this.id});await this.base.requestJson(`POST`,t,{body:e})}async listContactLists(){let e=o.expandPath(`/teams/{team_id}/contact_lists`,{team_id:this.id});return await this.base.requestJson(`GET`,e)}async createContactList(e){let t=o.expandPath(`/teams/{team_id}/contact_lists`,{team_id:this.id});await this.base.requestJson(`POST`,t,{body:e})}async listContacts(e){let t=o.expandPath(`/teams/{team_id}/contacts`,{team_id:this.id});return await this.base.requestJson(`GET`,t,{query:Je(e)})}async createContact(e){let t=o.expandPath(`/teams/{team_id}/contacts`,{team_id:this.id});return await this.base.requestJson(`POST`,t,{body:e})}async listInboxes(){let e=o.expandPath(`/teams/{team_id}/inboxes`,{team_id:this.id});return await this.base.requestJson(`GET`,e)}async createInbox(e){let t=o.expandPath(`/teams/{team_id}/inboxes`,{team_id:this.id}),n=await this.base.requestJson(`POST`,t,{body:e});return new M(this.base,n)}async listMessageTemplateFolders(e){let t=o.expandPath(`/teams/{team_id}/message_template_folders`,{team_id:this.id});return await this.base.requestJson(`GET`,t,{query:Ye(e)})}async createMessageTemplateFolder(e){let t=o.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=o.expandPath(`/teams/{team_id}/message_templates`,{team_id:this.id});return await this.base.requestJson(`GET`,t,{query:Xe(e)})}async createMessageTemplate(e){let t=o.expandPath(`/teams/{team_id}/message_templates`,{team_id:this.id});return await this.base.requestJson(`POST`,t,{body:e})}async listRules(){let e=o.expandPath(`/teams/{team_id}/rules`,{team_id:this.id});return await this.base.requestJson(`GET`,e)}async listShifts(){let e=o.expandPath(`/teams/{team_id}/shifts`,{team_id:this.id});return await this.base.requestJson(`GET`,e)}async createShift(e){let t=o.expandPath(`/teams/{team_id}/shifts`,{team_id:this.id});return await this.base.requestJson(`POST`,t,{body:e})}async listSignatures(){let e=o.expandPath(`/teams/{team_id}/signatures`,{team_id:this.id});return await this.base.requestJson(`GET`,e)}async createSignature(e){let t=o.expandPath(`/teams/{team_id}/signatures`,{team_id:this.id}),n=await this.base.requestJson(`POST`,t,{body:e});return new Q(this.base,n)}async listTags(e){let t=o.expandPath(`/teams/{team_id}/tags`,{team_id:this.id});return await this.base.requestJson(`GET`,t,{query:Ze(e)})}async createTag(e){let t=o.expandPath(`/teams/{team_id}/tags`,{team_id:this.id}),n=await this.base.requestJson(`POST`,t,{body:e});return new y(this.base,n)}async addTeammates(e){let t=o.expandPath(`/teams/{team_id}/teammates`,{team_id:this.id});await this.base.requestJson(`POST`,t,{body:e})}async removeTeammates(e){let t=o.expandPath(`/teams/{team_id}/teammates`,{team_id:this.id});await this.base.requestJson(`DELETE`,t,{body:e})}async listViews(e){let t=o.expandPath(`/teams/{team_id}/views`,{team_id:this.id});return await this.base.requestJson(`GET`,t,{query:Qe(e)})}async createView(e){let t=o.expandPath(`/teams/{team_id}/views`,{team_id:this.id});return await this.base.requestJson(`POST`,t,{body:e})}},et=class{base;constructor(e){this.base=e}async listTeams(){return await this.base.requestJson(`GET`,`/teams`)}async getTeam(e){let t=o.expandPath(`/teams/{team_id}`,{team_id:e}),n=await this.base.requestJson(`GET`,t);return new $e(this.base,n)}};const tt=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},nt=(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},rt=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 it=class extends s{selfPath(){return o.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 rt(this.state)}async update(e){await this.patchNoContent(e,nt)}async addTeammates(e){let t=o.expandPath(`/views/{view_id}/teammates`,{view_id:this.id});await this.base.requestJson(`POST`,t,{body:e})}},at=class{base;constructor(e){this.base=e}async list(e){return await this.base.requestJson(`GET`,`/views`,{query:tt(e)})}async get(e){let t=o.expandPath(`/views/{view_id}`,{view_id:e}),n=await this.base.requestJson(`GET`,t);return new it(this.base,n)}};const ot=()=>{let e=process.env.FRONT_API_TOKEN;if(!e)return;let t=e.trim();return t.length>0?t:void 0};var st=class extends o{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}=e??{},i=t??ot();if(!i)throw Error(`Front API token is required. Set FRONT_API_TOKEN in the environment or pass { apiKey: "..." } to the Front constructor.`);super({apiKey:i,baseUrl:n??`https://api2.frontapp.com`,...r===void 0?{}:{fetch:r}}),this.accounts=new u(this),this.analytics=new p(this),this.applications=new m(this),this.channels=new g(this),this.comments=new v(this),this.company=new b(this),this.contactLists=new x(this),this.contacts=new w(this),this.conversations=new E(this),this.customFieldsGlobal=new D(this),this.downloads=new O(this),this.drafts=new k(this),this.events=new A(this),this.inboxes=new N(this),this.knowledgeBases=new F(this),this.links=new B(this),this.me=new V(this),this.messageTemplateFolders=new G(this),this.messageTemplates=new U(this),this.messages=new q(this),this.rules=new J(this),this.shifts=new Ve(this),this.tags=new le(this),this.signatures=new Ue(this),this.teammateGroups=new qe(this),this.teammates=new X(this),this.teams=new et(this),this.views=new at(this)}};exports.Front=st,exports.FrontAccount=l,exports.FrontAccounts=u,exports.FrontAnalytics=p,exports.FrontAnalyticsExport=d,exports.FrontAnalyticsReport=f,exports.FrontApiError=e,exports.FrontApplications=m,exports.FrontBase=o,exports.FrontChannel=h,exports.FrontChannels=g,exports.FrontComment=_,exports.FrontComments=v,exports.FrontCompany=b,exports.FrontContact=C,exports.FrontContactLists=x,exports.FrontContacts=w,exports.FrontConversation=T,exports.FrontConversations=E,exports.FrontCustomFieldsGlobal=D,exports.FrontDownloads=O,exports.FrontDrafts=k,exports.FrontEvents=A,exports.FrontInbox=M,exports.FrontInboxes=N,exports.FrontKnowledgeBase=I,exports.FrontKnowledgeBaseArticle=L,exports.FrontKnowledgeBaseCategory=R,exports.FrontKnowledgeBases=F,exports.FrontLink=z,exports.FrontLinks=B,exports.FrontMe=V,exports.FrontMessage=K,exports.FrontMessageTemplate=H,exports.FrontMessageTemplateFolder=W,exports.FrontMessageTemplateFolders=G,exports.FrontMessageTemplates=U,exports.FrontMessages=q,exports.FrontResource=s,exports.FrontRules=J,exports.FrontShift=Z,exports.FrontShifts=Ve,exports.FrontSignature=Q,exports.FrontSignatures=Ue,exports.FrontTag=y,exports.FrontTags=le,exports.FrontTeam=$e,exports.FrontTeammate=Y,exports.FrontTeammateGroup=$,exports.FrontTeammateGroups=qe,exports.FrontTeammates=X,exports.FrontTeams=et,exports.FrontView=it,exports.FrontViews=at,exports.normalizeFrontResponse=n,exports.pageTokenFromPaginationNextUrl=t;
2
+ //# sourceMappingURL=index.cjs.map