@great-detail/support-sdk
Advanced tools
Comparing version 0.3.4 to 0.4.0
#!/usr/bin/env node | ||
import{a as r}from"./chunk-KH5SOWM5.js";import"./chunk-JOZI4K7D.js";r.parseAsync(process.argv); | ||
import{a as r}from"./chunk-2WFTGNNI.js";import"./chunk-ILW336CI.js";r.parseAsync(process.argv); |
import { Command } from 'commander'; | ||
import { C as Client } from '../index-D1aGs0vV.js'; | ||
import { C as Client } from '../index-Dp-x4kXq.js'; | ||
import { Options as Options$1 } from 'ora'; | ||
@@ -4,0 +4,0 @@ import 'ky'; |
@@ -1,1 +0,1 @@ | ||
import{a}from"../chunk-KH5SOWM5.js";import"../chunk-JOZI4K7D.js";export{a as default}; | ||
import{a}from"../chunk-2WFTGNNI.js";import"../chunk-ILW336CI.js";export{a as default}; |
@@ -1,3 +0,3 @@ | ||
import { A as Authentication } from './index-D1aGs0vV.js'; | ||
export { C as Client, b as CreateBoilerplateCategoryBoilerplateResponsePayload, e as CreateBoilerplateCategoryResponsePayload, H as CreateContactNoteResponsePayload, j as CreateContactResponsePayload, I as CreateConversationNoteResponsePayload, E as CreateCorrectionResponsePayload, t as CreateLabelResponsePayload, F as CreateResponseResponsePayload, D as DeleteLabelResponsePayload, f as GetBoilerplateCategoryResponsePayload, G as GetBoilerplateResponsePayload, k as GetContactResponsePayload, o as GetConversationResponsePayload, u as GetLabelResponsePayload, z as GetModelResponsePayload, J as GetNoteResponsePayload, P as GetSourceResponsePayload, L as ListActionsResponsePayload, g as ListBoilerplateCategoriesResponsePayload, c as ListBoilerplateCategoryBoilerplatesResponsePayload, d as ListBoilerplatesResponsePayload, i as ListChannelsResponsePayload, s as ListContactConversationsResponsePayload, K as ListContactNotesResponsePayload, l as ListContactsResponsePayload, x as ListConversationMessagesResponsePayload, M as ListConversationNotesResponsePayload, p as ListConversationsResponsePayload, m as ListLabelContactsResponsePayload, q as ListLabelConversationsResponsePayload, v as ListLabelsResponsePayload, y as ListMessagesResponsePayload, B as ListModelsResponsePayload, Q as ListSourcesResponsePayload, O as Options, R as RequestFilterable, a as TransportOptions, h as UpdateBoilerplateCategoryResponsePayload, U as UpdateBoilerplateResponsePayload, n as UpdateContactResponsePayload, r as UpdateConversationResponsePayload, w as UpdateLabelResponsePayload, N as UpdateNoteResponsePayload, C as default } from './index-D1aGs0vV.js'; | ||
import { A as Authentication } from './index-Dp-x4kXq.js'; | ||
export { C as Client, b as CreateBoilerplateCategoryBoilerplateResponse, e as CreateBoilerplateCategoryResponse, H as CreateContactNoteResponse, j as CreateContactResponse, I as CreateConversationNoteResponse, E as CreateCorrectionResponse, t as CreateLabelResponse, F as CreateResponseResponse, D as DeleteLabelResponse, f as GetBoilerplateCategoryResponse, G as GetBoilerplateResponse, k as GetContactResponse, o as GetConversationResponse, u as GetLabelResponse, z as GetModelResponse, J as GetNoteResponse, P as GetSourceResponse, L as ListActionsResponse, g as ListBoilerplateCategoriesResponse, c as ListBoilerplateCategoryBoilerplatesResponse, d as ListBoilerplatesResponse, i as ListChannelsResponse, s as ListContactConversationsResponse, K as ListContactNotesResponse, l as ListContactsResponse, x as ListConversationMessagesResponse, M as ListConversationNotesResponse, p as ListConversationsResponse, m as ListLabelContactsResponse, q as ListLabelConversationsResponse, v as ListLabelsResponse, y as ListMessagesResponse, B as ListModelsResponse, Q as ListSourcesResponse, O as Options, R as RequestFilterable, a as TransportOptions, h as UpdateBoilerplateCategoryResponse, U as UpdateBoilerplateResponse, n as UpdateContactResponse, r as UpdateConversationResponse, w as UpdateLabelResponse, N as UpdateNoteResponse, C as default } from './index-Dp-x4kXq.js'; | ||
import 'ky'; | ||
@@ -215,12 +215,15 @@ import 'zod'; | ||
/** | ||
* Great Detail Support System. | ||
* | ||
* @copyright 2024 Great Detail Ltd | ||
* @author Great Detail Ltd <info@greatdetail.com> | ||
* @author Dom Webber <dom.webber@greatdetail.com> | ||
* @see https://greatdetail.com | ||
*/ | ||
type CreateConversationResponse = { | ||
conversation: { | ||
id: string; | ||
name?: string; | ||
hasEnded: boolean; | ||
conversationStatus: "AwaitingContactConversationStatus" | "AwaitingAgentConversationStatus" | "ResolvedConversationStatus" | "ClosedConversationStatus"; | ||
accountChannel: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
type CreateContactSubscriptionResponsePayload = { | ||
type CreateContactSubscriptionResponse = { | ||
subscription: { | ||
@@ -233,2 +236,2 @@ id: string; | ||
export { type CreateContactSubscriptionResponsePayload, DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication, TokenAuthentication }; | ||
export { type CreateContactSubscriptionResponse, type CreateConversationResponse, DEFAULT_SUPPORT_BASE_URL, index as Error, KeyAuthentication, PublicAuthentication, TokenAuthentication }; |
@@ -1,1 +0,1 @@ | ||
import{a as d,b as g,c as s,d as n,e as a,f as p,g as f,h as m,i as u,j as c,k as l,l as x,m as A,n as h,o as _}from"./chunk-JOZI4K7D.js";var E={};d(E,{AuthError:()=>m,AuthenticationError:()=>u,AuthorizationError:()=>c,LogicError:()=>l,NetworkError:()=>x,SupportError:()=>f,ValidationError:()=>A});var t=class o{static DEFAULT_NAME=s;name;#r;constructor({name:r=process.env[p]??o.DEFAULT_NAME,key:i=process.env[a]}={}){if(!i)throw new Error("API Key option must be specified when using Key Authentication");this.name=r,this.#r=i}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#r)}`}}};var e=class{#r;constructor({token:r=process.env[n]}={}){if(!r)throw new Error("Access Token option must be specified when using Token Authentication");this.#r=r}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#r}`}}};export{h as Client,g as DEFAULT_SUPPORT_BASE_URL,E as Error,t as KeyAuthentication,_ as PublicAuthentication,e as TokenAuthentication,h as default}; | ||
import{a as d,b as g,c as s,d as n,e as a,f as p,g as f,h as m,i as u,j as c,k as l,l as x,m as A,n as h,o as _}from"./chunk-ILW336CI.js";var E={};d(E,{AuthError:()=>m,AuthenticationError:()=>u,AuthorizationError:()=>c,LogicError:()=>l,NetworkError:()=>x,SupportError:()=>f,ValidationError:()=>A});var t=class o{static DEFAULT_NAME=s;name;#r;constructor({name:r=process.env[p]??o.DEFAULT_NAME,key:i=process.env[a]}={}){if(!i)throw new Error("API Key option must be specified when using Key Authentication");this.name=r,this.#r=i}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#r)}`}}};var e=class{#r;constructor({token:r=process.env[n]}={}){if(!r)throw new Error("Access Token option must be specified when using Token Authentication");this.#r=r}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#r}`}}};export{h as Client,g as DEFAULT_SUPPORT_BASE_URL,E as Error,t as KeyAuthentication,_ as PublicAuthentication,e as TokenAuthentication,h as default}; |
{ | ||
"name": "@great-detail/support-sdk", | ||
"version": "0.3.4", | ||
"version": "0.4.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "JavaScript SDK for the Great Detail Support System", |
@@ -10,2 +10,2 @@ /** | ||
export { type ListActionsResponsePayload } from "./ListActions.js"; | ||
export { type ListActionsResponse } from "./ListActions.js"; |
@@ -16,16 +16,3 @@ /** | ||
export default class ListActions { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport | ||
.send("v1/actions", { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new ListActionsResponse(response)); | ||
} | ||
} | ||
export type ListActionsResponsePayload = { | ||
export type ListActionsResponse = { | ||
actions: { | ||
@@ -45,8 +32,11 @@ id: string; | ||
export class ListActionsResponse { | ||
constructor(public response: Response) {} | ||
export default class ListActions { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<ListActionsResponsePayload> { | ||
return this.response.json(); | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport.send<ListActionsResponse>("v1/actions", { | ||
...request, | ||
method: "GET", | ||
}); | ||
} | ||
} |
@@ -19,2 +19,13 @@ /** | ||
export type CreateBoilerplateCategoryBoilerplateResponse = { | ||
boilerplate: { | ||
id: string; | ||
title: string; | ||
content: string; | ||
account: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export default class CreateBoilerplateCategoryBoilerplate { | ||
@@ -30,41 +41,17 @@ public static SCHEMA = z.object({ | ||
public async send({ id, body, request = {} }: Options) { | ||
return this._transport | ||
.send( | ||
"v1/boilerplate-categories/" + encodeURIComponent(id) + "/boilerplates", | ||
{ | ||
...request, | ||
method: "POST", | ||
headers: { | ||
...request.headers, | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify( | ||
CreateBoilerplateCategoryBoilerplate.SCHEMA.parse(body), | ||
), | ||
return this._transport.send<CreateBoilerplateCategoryBoilerplateResponse>( | ||
"v1/boilerplate-categories/" + encodeURIComponent(id) + "/boilerplates", | ||
{ | ||
...request, | ||
method: "POST", | ||
headers: { | ||
...request.headers, | ||
"Content-Type": "application/json", | ||
}, | ||
) | ||
.then( | ||
(response) => | ||
new CreateBoilerplateCategoryBoilerplateResponse(response), | ||
); | ||
body: JSON.stringify( | ||
CreateBoilerplateCategoryBoilerplate.SCHEMA.parse(body), | ||
), | ||
}, | ||
); | ||
} | ||
} | ||
export type CreateBoilerplateCategoryBoilerplateResponsePayload = { | ||
boilerplate: { | ||
id: string; | ||
title: string; | ||
content: string; | ||
account: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export class CreateBoilerplateCategoryBoilerplateResponse { | ||
constructor(public response: Response) {} | ||
public async result(): Promise<CreateBoilerplateCategoryBoilerplateResponsePayload> { | ||
return this.response.json(); | ||
} | ||
} |
@@ -17,16 +17,3 @@ /** | ||
export default class GetBoilerplate { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/boilerplates/" + encodeURIComponent(id), { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new GetBoilerplateResponse(response)); | ||
} | ||
} | ||
export type GetBoilerplateResponsePayload = { | ||
export type GetBoilerplateResponse = { | ||
boilerplate: { | ||
@@ -43,8 +30,14 @@ id: string; | ||
export class GetBoilerplateResponse { | ||
constructor(public response: Response) {} | ||
export default class GetBoilerplate { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<GetBoilerplateResponsePayload> { | ||
return this.response.json(); | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport.send<GetBoilerplateResponse>( | ||
"v1/boilerplates/" + encodeURIComponent(id), | ||
{ | ||
...request, | ||
method: "GET", | ||
}, | ||
); | ||
} | ||
} |
@@ -10,6 +10,6 @@ /** | ||
export { type CreateBoilerplateCategoryBoilerplateResponsePayload } from "./CreateBoilerplateCategoryBoilerplate.js"; | ||
export { type ListBoilerplateCategoryBoilerplatesResponsePayload } from "./ListBoilerplateCategoryBoilerplates.js"; | ||
export { type GetBoilerplateResponsePayload } from "./GetBoilerplate.js"; | ||
export { type ListBoilerplatesResponsePayload } from "./ListBoilerplates.js"; | ||
export { type UpdateBoilerplateResponsePayload } from "./UpdateBoilerplate.js"; | ||
export { type CreateBoilerplateCategoryBoilerplateResponse } from "./CreateBoilerplateCategoryBoilerplate.js"; | ||
export { type ListBoilerplateCategoryBoilerplatesResponse } from "./ListBoilerplateCategoryBoilerplates.js"; | ||
export { type GetBoilerplateResponse } from "./GetBoilerplate.js"; | ||
export { type ListBoilerplatesResponse } from "./ListBoilerplates.js"; | ||
export { type UpdateBoilerplateResponse } from "./UpdateBoilerplate.js"; |
@@ -21,17 +21,13 @@ /** | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport | ||
.send( | ||
"v1/boilerplate-categories/" + encodeURIComponent(id) + "/boilerplates", | ||
{ | ||
...request, | ||
method: "GET", | ||
}, | ||
) | ||
.then( | ||
(response) => new ListBoilerplateCategoryBoilerplatesResponse(response), | ||
); | ||
return this._transport.send<ListBoilerplateCategoryBoilerplatesResponse>( | ||
"v1/boilerplate-categories/" + encodeURIComponent(id) + "/boilerplates", | ||
{ | ||
...request, | ||
method: "GET", | ||
}, | ||
); | ||
} | ||
} | ||
export type ListBoilerplateCategoryBoilerplatesResponsePayload = { | ||
export type ListBoilerplateCategoryBoilerplatesResponse = { | ||
boilerplates: { | ||
@@ -47,9 +43,1 @@ id: string; | ||
}; | ||
export class ListBoilerplateCategoryBoilerplatesResponse { | ||
constructor(public response: Response) {} | ||
public async result(): Promise<ListBoilerplateCategoryBoilerplatesResponsePayload> { | ||
return this.response.json(); | ||
} | ||
} |
@@ -16,16 +16,3 @@ /** | ||
export default class ListBoilerplates { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport | ||
.send("v1/boilerplates", { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new ListBoilerplatesResponse(response)); | ||
} | ||
} | ||
export type ListBoilerplatesResponsePayload = { | ||
export type ListBoilerplatesResponse = { | ||
boilerplates: { | ||
@@ -42,8 +29,11 @@ id: string; | ||
export class ListBoilerplatesResponse { | ||
constructor(public response: Response) {} | ||
export default class ListBoilerplates { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<ListBoilerplatesResponsePayload> { | ||
return this.response.json(); | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport.send<ListBoilerplatesResponse>("v1/boilerplates", { | ||
...request, | ||
method: "GET", | ||
}); | ||
} | ||
} |
@@ -19,2 +19,14 @@ /** | ||
export type UpdateBoilerplateResponse = { | ||
boilerplate: { | ||
id: string; | ||
title: string; | ||
content: string; | ||
account: string; | ||
boilerplateCategory: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export default class UpdateBoilerplate { | ||
@@ -29,4 +41,5 @@ public static SCHEMA = z.object({ | ||
public async send({ id, body, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/boilerplates/" + encodeURIComponent(id), { | ||
return this._transport.send<UpdateBoilerplateResponse>( | ||
"v1/boilerplates/" + encodeURIComponent(id), | ||
{ | ||
...request, | ||
@@ -39,25 +52,5 @@ method: "PATCH", | ||
body: JSON.stringify(UpdateBoilerplate.SCHEMA.parse(body)), | ||
}) | ||
.then((response) => new UpdateBoilerplateResponse(response)); | ||
}, | ||
); | ||
} | ||
} | ||
export type UpdateBoilerplateResponsePayload = { | ||
boilerplate: { | ||
id: string; | ||
title: string; | ||
content: string; | ||
account: string; | ||
boilerplateCategory: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export class UpdateBoilerplateResponse { | ||
constructor(public response: Response) {} | ||
public async result(): Promise<UpdateBoilerplateResponsePayload> { | ||
return this.response.json(); | ||
} | ||
} |
@@ -18,2 +18,13 @@ /** | ||
export type CreateBoilerplateCategoryResponse = { | ||
boilerplateCategory: { | ||
id: string; | ||
title: string; | ||
description?: string; | ||
account: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export default class CreateBoilerplateCategory { | ||
@@ -29,4 +40,5 @@ public static SCHEMA = z.object({ | ||
public async send({ body, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/boilerplate-categories", { | ||
return this._transport.send<CreateBoilerplateCategoryResponse>( | ||
"v1/boilerplate-categories", | ||
{ | ||
...request, | ||
@@ -39,24 +51,5 @@ method: "POST", | ||
body: JSON.stringify(CreateBoilerplateCategory.SCHEMA.parse(body)), | ||
}) | ||
.then((response) => new CreateBoilerplateCategoryResponse(response)); | ||
}, | ||
); | ||
} | ||
} | ||
export type CreateBoilerplateCategoryResponsePayload = { | ||
boilerplateCategory: { | ||
id: string; | ||
title: string; | ||
description?: string; | ||
account: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export class CreateBoilerplateCategoryResponse { | ||
constructor(public response: Response) {} | ||
public async result(): Promise<CreateBoilerplateCategoryResponsePayload> { | ||
return this.response.json(); | ||
} | ||
} |
@@ -17,16 +17,3 @@ /** | ||
export default class GetBoilerplateCategory { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/boilerplate-categories/" + encodeURIComponent(id), { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new GetBoilerplateCategoryResponse(response)); | ||
} | ||
} | ||
export type GetBoilerplateCategoryResponsePayload = { | ||
export type GetBoilerplateCategoryResponse = { | ||
boilerplateCategory: { | ||
@@ -42,8 +29,14 @@ id: string; | ||
export class GetBoilerplateCategoryResponse { | ||
constructor(public response: Response) {} | ||
export default class GetBoilerplateCategory { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<GetBoilerplateCategoryResponsePayload> { | ||
return this.response.json(); | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport.send<GetBoilerplateCategoryResponse>( | ||
"v1/boilerplate-categories/" + encodeURIComponent(id), | ||
{ | ||
...request, | ||
method: "GET", | ||
}, | ||
); | ||
} | ||
} |
@@ -10,5 +10,5 @@ /** | ||
export { type CreateBoilerplateCategoryResponsePayload } from "./CreateBoilerplateCategory.js"; | ||
export { type GetBoilerplateCategoryResponsePayload } from "./GetBoilerplateCategory.js"; | ||
export { type ListBoilerplateCategoriesResponsePayload } from "./ListBoilerplateCategories.js"; | ||
export { type UpdateBoilerplateCategoryResponsePayload } from "./UpdateBoilerplateCategory.js"; | ||
export { type CreateBoilerplateCategoryResponse } from "./CreateBoilerplateCategory.js"; | ||
export { type GetBoilerplateCategoryResponse } from "./GetBoilerplateCategory.js"; | ||
export { type ListBoilerplateCategoriesResponse } from "./ListBoilerplateCategories.js"; | ||
export { type UpdateBoilerplateCategoryResponse } from "./UpdateBoilerplateCategory.js"; |
@@ -16,16 +16,3 @@ /** | ||
export default class ListBoilerplateCategories { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport | ||
.send("v1/boilerplate-categories", { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new ListBoilerplateCategoriesResponse(response)); | ||
} | ||
} | ||
export type ListBoilerplateCategoriesResponsePayload = { | ||
export type ListBoilerplateCategoriesResponse = { | ||
boilerplateCategories: { | ||
@@ -41,8 +28,14 @@ id: string; | ||
export class ListBoilerplateCategoriesResponse { | ||
constructor(public response: Response) {} | ||
export default class ListBoilerplateCategories { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<ListBoilerplateCategoriesResponsePayload> { | ||
return this.response.json(); | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport.send<ListBoilerplateCategoriesResponse>( | ||
"v1/boilerplate-categories", | ||
{ | ||
...request, | ||
method: "GET", | ||
}, | ||
); | ||
} | ||
} |
@@ -19,2 +19,13 @@ /** | ||
export type UpdateBoilerplateCategoryResponse = { | ||
boilerplateCategory: { | ||
id: string; | ||
title: string; | ||
description?: string; | ||
account: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export default class UpdateBoilerplateCategory { | ||
@@ -29,4 +40,5 @@ public static SCHEMA = z.object({ | ||
public async send({ id, body, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/boilerplate-categories/" + encodeURIComponent(id), { | ||
return this._transport.send<UpdateBoilerplateCategoryResponse>( | ||
"v1/boilerplate-categories/" + encodeURIComponent(id), | ||
{ | ||
...request, | ||
@@ -39,24 +51,5 @@ method: "PATCH", | ||
body: JSON.stringify(UpdateBoilerplateCategory.SCHEMA.parse(body)), | ||
}) | ||
.then((response) => new UpdateBoilerplateCategoryResponse(response)); | ||
}, | ||
); | ||
} | ||
} | ||
export type UpdateBoilerplateCategoryResponsePayload = { | ||
boilerplateCategory: { | ||
id: string; | ||
title: string; | ||
description?: string; | ||
account: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export class UpdateBoilerplateCategoryResponse { | ||
constructor(public response: Response) {} | ||
public async result(): Promise<UpdateBoilerplateCategoryResponsePayload> { | ||
return this.response.json(); | ||
} | ||
} |
@@ -10,2 +10,2 @@ /** | ||
export { type ListChannelsResponsePayload } from "./ListChannels.js"; | ||
export { type ListChannelsResponse } from "./ListChannels.js"; |
@@ -16,16 +16,3 @@ /** | ||
export default class ListChannels { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport | ||
.send("v1/channels", { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new ListChannelsResponse(response)); | ||
} | ||
} | ||
export type ListChannelsResponsePayload = { | ||
export type ListChannelsResponse = { | ||
channels: ({ | ||
@@ -58,8 +45,11 @@ id: string; | ||
export class ListChannelsResponse { | ||
constructor(public response: Response) {} | ||
export default class ListChannels { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<ListChannelsResponsePayload> { | ||
return this.response.json(); | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport.send<ListChannelsResponse>("v1/channels", { | ||
...request, | ||
method: "GET", | ||
}); | ||
} | ||
} |
@@ -26,3 +26,3 @@ /** | ||
console.log(await result.result()); | ||
console.log(await result.json()); | ||
}), | ||
@@ -29,0 +29,0 @@ ); |
@@ -26,3 +26,3 @@ /** | ||
console.log(await result.result()); | ||
console.log(await result.json()); | ||
}), | ||
@@ -29,0 +29,0 @@ ); |
@@ -29,3 +29,3 @@ /** | ||
console.log(await result.result()); | ||
console.log(await result.json()); | ||
}), | ||
@@ -41,3 +41,3 @@ ); | ||
console.log(await result.result()); | ||
console.log(await result.json()); | ||
}), | ||
@@ -44,0 +44,0 @@ ); |
@@ -32,3 +32,3 @@ /** | ||
console.log(await result.result()); | ||
console.log(await result.json()); | ||
}), | ||
@@ -44,3 +44,3 @@ ); | ||
console.log(await result.result()); | ||
console.log(await result.json()); | ||
}), | ||
@@ -47,0 +47,0 @@ ); |
@@ -29,3 +29,3 @@ /** | ||
console.log(await result.result()); | ||
console.log(await result.json()); | ||
}), | ||
@@ -41,3 +41,3 @@ ); | ||
console.log(await result.result()); | ||
console.log(await result.json()); | ||
}), | ||
@@ -59,3 +59,3 @@ ); | ||
console.log(await result.result()); | ||
console.log(await result.json()); | ||
}), | ||
@@ -62,0 +62,0 @@ ); |
@@ -26,3 +26,3 @@ /** | ||
console.log(await result.result()); | ||
console.log(await result.json()); | ||
}), | ||
@@ -29,0 +29,0 @@ ); |
@@ -29,3 +29,3 @@ /** | ||
console.log(await result.result()); | ||
console.log(await result.json()); | ||
}), | ||
@@ -41,3 +41,3 @@ ); | ||
console.log(await result.result()); | ||
console.log(await result.json()); | ||
}), | ||
@@ -44,0 +44,0 @@ ); |
@@ -29,3 +29,3 @@ /** | ||
console.log(await result.result()); | ||
console.log(await result.json()); | ||
}), | ||
@@ -41,3 +41,3 @@ ); | ||
console.log(await result.result()); | ||
console.log(await result.json()); | ||
}), | ||
@@ -44,0 +44,0 @@ ); |
@@ -138,2 +138,3 @@ /** | ||
update: new UpdateConversation(this._transport), | ||
create: new CreateConversationNote(this._transport), | ||
message: { | ||
@@ -140,0 +141,0 @@ list: new ListConversationMessages(this._transport), |
@@ -18,28 +18,3 @@ /** | ||
export default class CreateContact { | ||
public static SCHEMA = z.object({ | ||
name: z.string(), | ||
account: z.string(), | ||
emailAddress: z.string().email().optional(), | ||
telephoneNumber: z.string().optional(), | ||
}); | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ body, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/contacts", { | ||
...request, | ||
method: "POST", | ||
headers: { | ||
...request.headers, | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(CreateContact.SCHEMA.parse(body)), | ||
}) | ||
.then((response) => new CreateContactResponse(response)); | ||
} | ||
} | ||
export type CreateContactResponsePayload = { | ||
export type CreateContactResponse = { | ||
contact: { | ||
@@ -56,8 +31,23 @@ id: string; | ||
export class CreateContactResponse { | ||
constructor(public response: Response) {} | ||
export default class CreateContact { | ||
public static SCHEMA = z.object({ | ||
name: z.string(), | ||
account: z.string(), | ||
emailAddress: z.string().email().optional(), | ||
telephoneNumber: z.string().optional(), | ||
}); | ||
public async result(): Promise<CreateContactResponsePayload> { | ||
return this.response.json(); | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ body, request = {} }: Options) { | ||
return this._transport.send<CreateContactResponse>("v1/contacts", { | ||
...request, | ||
method: "POST", | ||
headers: { | ||
...request.headers, | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(CreateContact.SCHEMA.parse(body)), | ||
}); | ||
} | ||
} |
@@ -17,16 +17,3 @@ /** | ||
export default class GetContact { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/contacts/" + encodeURIComponent(id), { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new GetContactResponse(response)); | ||
} | ||
} | ||
export type GetContactResponsePayload = { | ||
export type GetContactResponse = { | ||
contact: { | ||
@@ -43,8 +30,14 @@ id: string; | ||
export class GetContactResponse { | ||
constructor(public response: Response) {} | ||
export default class GetContact { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<GetContactResponsePayload> { | ||
return this.response.json(); | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport.send<GetContactResponse>( | ||
"v1/contacts/" + encodeURIComponent(id), | ||
{ | ||
...request, | ||
method: "GET", | ||
}, | ||
); | ||
} | ||
} |
@@ -10,6 +10,6 @@ /** | ||
export { type CreateContactResponsePayload } from "./CreateContact.js"; | ||
export { type GetContactResponsePayload } from "./GetContact.js"; | ||
export { type ListContactsResponsePayload } from "./ListContacts.js"; | ||
export { type ListLabelContactsResponsePayload } from "./ListLabelContacts.js"; | ||
export { type UpdateContactResponsePayload } from "./UpdateContact.js"; | ||
export { type CreateContactResponse } from "./CreateContact.js"; | ||
export { type GetContactResponse } from "./GetContact.js"; | ||
export { type ListContactsResponse } from "./ListContacts.js"; | ||
export { type ListLabelContactsResponse } from "./ListLabelContacts.js"; | ||
export { type UpdateContactResponse } from "./UpdateContact.js"; |
@@ -16,16 +16,3 @@ /** | ||
export default class ListContacts { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport | ||
.send("v1/contacts", { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new ListContactsResponse(response)); | ||
} | ||
} | ||
export type ListContactsResponsePayload = { | ||
export type ListContactsResponse = { | ||
contacts: { | ||
@@ -42,8 +29,11 @@ id: string; | ||
export class ListContactsResponse { | ||
constructor(public response: Response) {} | ||
export default class ListContacts { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<ListContactsResponsePayload> { | ||
return this.response.json(); | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport.send<ListContactsResponse>("v1/contacts", { | ||
...request, | ||
method: "GET", | ||
}); | ||
} | ||
} |
@@ -17,16 +17,3 @@ /** | ||
export default class ListLabelContacts { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/labels/" + encodeURIComponent(id) + "/contacts", { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new ListLabelContactsResponse(response)); | ||
} | ||
} | ||
export type ListLabelContactsResponsePayload = { | ||
export type ListLabelContactsResponse = { | ||
contacts: { | ||
@@ -43,8 +30,14 @@ id: string; | ||
export class ListLabelContactsResponse { | ||
constructor(public response: Response) {} | ||
export default class ListLabelContacts { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<ListLabelContactsResponsePayload> { | ||
return this.response.json(); | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport.send<ListLabelContactsResponse>( | ||
"v1/labels/" + encodeURIComponent(id) + "/contacts", | ||
{ | ||
...request, | ||
method: "GET", | ||
}, | ||
); | ||
} | ||
} |
@@ -19,2 +19,14 @@ /** | ||
export type UpdateContactResponse = { | ||
contact: { | ||
id: string; | ||
name?: string; | ||
emailAddress?: string; | ||
telephoneNumber?: string; | ||
account: string; | ||
createdAt: string; | ||
updatedAt?: string; | ||
}; | ||
}; | ||
export default class UpdateContact { | ||
@@ -30,4 +42,5 @@ public static SCHEMA = z.object({ | ||
public async send({ id, body, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/contacts/" + encodeURIComponent(id), { | ||
return this._transport.send<UpdateContactResponse>( | ||
"v1/contacts/" + encodeURIComponent(id), | ||
{ | ||
...request, | ||
@@ -40,25 +53,5 @@ method: "PATCH", | ||
body: JSON.stringify(UpdateContact.SCHEMA.parse(body)), | ||
}) | ||
.then((response) => new UpdateContactResponse(response)); | ||
}, | ||
); | ||
} | ||
} | ||
export type UpdateContactResponsePayload = { | ||
contact: { | ||
id: string; | ||
name?: string; | ||
emailAddress?: string; | ||
telephoneNumber?: string; | ||
account: string; | ||
createdAt: string; | ||
updatedAt?: string; | ||
}; | ||
}; | ||
export class UpdateContactResponse { | ||
constructor(public response: Response) {} | ||
public async result(): Promise<UpdateContactResponsePayload> { | ||
return this.response.json(); | ||
} | ||
} |
@@ -17,16 +17,3 @@ /** | ||
export default class GetConversation { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/conversations/" + encodeURIComponent(id), { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new GetConversationResponse(response)); | ||
} | ||
} | ||
export type GetConversationResponsePayload = { | ||
export type GetConversationResponse = { | ||
conversation: { | ||
@@ -47,8 +34,14 @@ id: string; | ||
export class GetConversationResponse { | ||
constructor(public response: Response) {} | ||
export default class GetConversation { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<GetConversationResponsePayload> { | ||
return this.response.json(); | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport.send<GetConversationResponse>( | ||
"v1/conversations/" + encodeURIComponent(id), | ||
{ | ||
...request, | ||
method: "GET", | ||
}, | ||
); | ||
} | ||
} |
@@ -10,6 +10,7 @@ /** | ||
export { type GetConversationResponsePayload } from "./GetConversation.js"; | ||
export { type ListConversationsResponsePayload } from "./ListConversations.js"; | ||
export { type ListLabelConversationsResponsePayload } from "./ListLabelConversations.js"; | ||
export { type UpdateConversationResponsePayload } from "./UpdateConversation.js"; | ||
export { type ListContactConversationsResponsePayload } from "./ListContactConversations.js"; | ||
export { type GetConversationResponse } from "./GetConversation.js"; | ||
export { type ListConversationsResponse } from "./ListConversations.js"; | ||
export { type ListLabelConversationsResponse } from "./ListLabelConversations.js"; | ||
export { type UpdateConversationResponse } from "./UpdateConversation.js"; | ||
export { type ListContactConversationsResponse } from "./ListContactConversations.js"; | ||
export { type CreateConversationResponse } from "./CreateConversation.js"; |
@@ -17,16 +17,3 @@ /** | ||
export default class ListContactConversations { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/contacts/" + encodeURIComponent(id) + "/conversations", { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new ListContactConversationsResponse(response)); | ||
} | ||
} | ||
export type ListContactConversationsResponsePayload = { | ||
export type ListContactConversationsResponse = { | ||
conversations: { | ||
@@ -47,8 +34,14 @@ id: string; | ||
export class ListContactConversationsResponse { | ||
constructor(public response: Response) {} | ||
export default class ListContactConversations { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<ListContactConversationsResponsePayload> { | ||
return this.response.json(); | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport.send<ListContactConversationsResponse>( | ||
"v1/contacts/" + encodeURIComponent(id) + "/conversations", | ||
{ | ||
...request, | ||
method: "GET", | ||
}, | ||
); | ||
} | ||
} |
@@ -16,16 +16,3 @@ /** | ||
export default class ListConversations { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport | ||
.send("v1/conversations", { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new ListConversationsResponse(response)); | ||
} | ||
} | ||
export type ListConversationsResponsePayload = { | ||
export type ListConversationsResponse = { | ||
conversations: { | ||
@@ -46,8 +33,11 @@ id: string; | ||
export class ListConversationsResponse { | ||
constructor(public response: Response) {} | ||
export default class ListConversations { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<ListConversationsResponsePayload> { | ||
return this.response.json(); | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport.send<ListConversationsResponse>("v1/conversations", { | ||
...request, | ||
method: "GET", | ||
}); | ||
} | ||
} |
@@ -17,16 +17,3 @@ /** | ||
export default class ListLabelConversations { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/labels/" + encodeURIComponent(id) + "/conversations", { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new ListLabelConversationsResponse(response)); | ||
} | ||
} | ||
export type ListLabelConversationsResponsePayload = { | ||
export type ListLabelConversationsResponse = { | ||
conversations: { | ||
@@ -47,8 +34,14 @@ id: string; | ||
export class ListLabelConversationsResponse { | ||
constructor(public response: Response) {} | ||
export default class ListLabelConversations { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<ListLabelConversationsResponsePayload> { | ||
return this.response.json(); | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport.send<ListLabelConversationsResponse>( | ||
"v1/labels/" + encodeURIComponent(id) + "/conversations", | ||
{ | ||
...request, | ||
method: "GET", | ||
}, | ||
); | ||
} | ||
} |
@@ -19,2 +19,18 @@ /** | ||
export type UpdateConversationResponse = { | ||
conversation: { | ||
id: string; | ||
name?: string; | ||
hasEnded: boolean; | ||
conversationStatus: | ||
| "AwaitingContactConversationStatus" | ||
| "AwaitingAgentConversationStatus" | ||
| "ResolvedConversationStatus" | ||
| "ClosedConversationStatus"; | ||
accountChannel: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export default class UpdateConversation { | ||
@@ -36,4 +52,5 @@ public static SCHEMA = z.object({ | ||
public async send({ id, body, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/conversations/" + encodeURIComponent(id), { | ||
return this._transport.send<UpdateConversationResponse>( | ||
"v1/conversations/" + encodeURIComponent(id), | ||
{ | ||
...request, | ||
@@ -46,29 +63,5 @@ method: "PATCH", | ||
body: JSON.stringify(UpdateConversation.SCHEMA.parse(body)), | ||
}) | ||
.then((response) => new UpdateConversationResponse(response)); | ||
}, | ||
); | ||
} | ||
} | ||
export type UpdateConversationResponsePayload = { | ||
conversation: { | ||
id: string; | ||
name?: string; | ||
hasEnded: boolean; | ||
conversationStatus: | ||
| "AwaitingContactConversationStatus" | ||
| "AwaitingAgentConversationStatus" | ||
| "ResolvedConversationStatus" | ||
| "ClosedConversationStatus"; | ||
accountChannel: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export class UpdateConversationResponse { | ||
constructor(public response: Response) {} | ||
public async result(): Promise<UpdateConversationResponsePayload> { | ||
return this.response.json(); | ||
} | ||
} |
@@ -18,27 +18,3 @@ /** | ||
export default class CreateLabel { | ||
public static SCHEMA = z.object({ | ||
title: z.string(), | ||
description: z.string().optional(), | ||
account: z.string(), | ||
}); | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ body, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/labels", { | ||
...request, | ||
method: "POST", | ||
headers: { | ||
...request.headers, | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(CreateLabel.SCHEMA.parse(body)), | ||
}) | ||
.then((response) => new CreateLabelResponse(response)); | ||
} | ||
} | ||
export type CreateLabelResponsePayload = { | ||
export type CreateLabelResponse = { | ||
label: { | ||
@@ -54,8 +30,22 @@ id: string; | ||
export class CreateLabelResponse { | ||
constructor(public response: Response) {} | ||
export default class CreateLabel { | ||
public static SCHEMA = z.object({ | ||
title: z.string(), | ||
description: z.string().optional(), | ||
account: z.string(), | ||
}); | ||
public async result(): Promise<CreateLabelResponsePayload> { | ||
return this.response.json(); | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ body, request = {} }: Options) { | ||
return this._transport.send<CreateLabelResponse>("v1/labels", { | ||
...request, | ||
method: "POST", | ||
headers: { | ||
...request.headers, | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(CreateLabel.SCHEMA.parse(body)), | ||
}); | ||
} | ||
} |
@@ -17,2 +17,4 @@ /** | ||
export type DeleteLabelResponse = Record<string, never>; | ||
export default class DeleteLabel { | ||
@@ -22,19 +24,10 @@ constructor(protected _transport: FetchTransport) {} | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/labels/" + encodeURIComponent(id), { | ||
return this._transport.send<DeleteLabelResponse>( | ||
"v1/labels/" + encodeURIComponent(id), | ||
{ | ||
...request, | ||
method: "DELETE", | ||
}) | ||
.then((response) => new DeleteLabelResponse(response)); | ||
}, | ||
); | ||
} | ||
} | ||
export type DeleteLabelResponsePayload = Record<string, never>; | ||
export class DeleteLabelResponse { | ||
constructor(public response: Response) {} | ||
public async result(): Promise<DeleteLabelResponsePayload> { | ||
return this.response.json(); | ||
} | ||
} |
@@ -17,16 +17,3 @@ /** | ||
export default class GetLabel { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/labels/" + encodeURIComponent(id), { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new GetLabelResponse(response)); | ||
} | ||
} | ||
export type GetLabelResponsePayload = { | ||
export type GetLabelResponse = { | ||
label: { | ||
@@ -42,8 +29,14 @@ id: string; | ||
export class GetLabelResponse { | ||
constructor(public response: Response) {} | ||
export default class GetLabel { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<GetLabelResponsePayload> { | ||
return this.response.json(); | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport.send<GetLabelResponse>( | ||
"v1/labels/" + encodeURIComponent(id), | ||
{ | ||
...request, | ||
method: "GET", | ||
}, | ||
); | ||
} | ||
} |
@@ -10,6 +10,6 @@ /** | ||
export { type CreateLabelResponsePayload } from "./CreateLabel.js"; | ||
export { type DeleteLabelResponsePayload } from "./DeleteLabel.js"; | ||
export { type GetLabelResponsePayload } from "./GetLabel.js"; | ||
export { type ListLabelsResponsePayload } from "./ListLabels.js"; | ||
export { type UpdateLabelResponsePayload } from "./UpdateLabel.js"; | ||
export { type CreateLabelResponse } from "./CreateLabel.js"; | ||
export { type DeleteLabelResponse } from "./DeleteLabel.js"; | ||
export { type GetLabelResponse } from "./GetLabel.js"; | ||
export { type ListLabelsResponse } from "./ListLabels.js"; | ||
export { type UpdateLabelResponse } from "./UpdateLabel.js"; |
@@ -16,16 +16,3 @@ /** | ||
export default class ListLabels { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport | ||
.send("v1/labels", { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new ListLabelsResponse(response)); | ||
} | ||
} | ||
export type ListLabelsResponsePayload = { | ||
export type ListLabelsResponse = { | ||
labels: { | ||
@@ -41,8 +28,11 @@ id: string; | ||
export class ListLabelsResponse { | ||
constructor(public response: Response) {} | ||
export default class ListLabels { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<ListLabelsResponsePayload> { | ||
return this.response.json(); | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport.send<ListLabelsResponse>("v1/labels", { | ||
...request, | ||
method: "GET", | ||
}); | ||
} | ||
} |
@@ -19,2 +19,13 @@ /** | ||
export type UpdateLabelResponse = { | ||
label: { | ||
id: string; | ||
title: string; | ||
description?: string; | ||
account: string; | ||
createdAt: string; | ||
updatedAt?: string; | ||
}; | ||
}; | ||
export default class UpdateLabel { | ||
@@ -29,4 +40,5 @@ public static SCHEMA = z.object({ | ||
public async send({ id, body, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/labels/" + encodeURIComponent(id), { | ||
return this._transport.send<UpdateLabelResponse>( | ||
"v1/labels/" + encodeURIComponent(id), | ||
{ | ||
...request, | ||
@@ -39,24 +51,5 @@ method: "PATCH", | ||
body: JSON.stringify(UpdateLabel.SCHEMA.parse(body)), | ||
}) | ||
.then((response) => new UpdateLabelResponse(response)); | ||
}, | ||
); | ||
} | ||
} | ||
export type UpdateLabelResponsePayload = { | ||
label: { | ||
id: string; | ||
title: string; | ||
description?: string; | ||
account: string; | ||
createdAt: string; | ||
updatedAt?: string; | ||
}; | ||
}; | ||
export class UpdateLabelResponse { | ||
constructor(public response: Response) {} | ||
public async result(): Promise<UpdateLabelResponsePayload> { | ||
return this.response.json(); | ||
} | ||
} |
@@ -10,3 +10,3 @@ /** | ||
export { type ListConversationMessagesResponsePayload } from "./ListConversationMessages.js"; | ||
export { type ListMessagesResponsePayload } from "./ListMessages.js"; | ||
export { type ListConversationMessagesResponse } from "./ListConversationMessages.js"; | ||
export { type ListMessagesResponse } from "./ListMessages.js"; |
@@ -17,16 +17,3 @@ /** | ||
export default class ListConversationMessages { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/conversations/" + encodeURIComponent(id) + "/messages", { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new ListConversationMessagesResponse(response)); | ||
} | ||
} | ||
export type ListConversationMessagesResponsePayload = { | ||
export type ListConversationMessagesResponse = { | ||
messages: { | ||
@@ -51,8 +38,14 @@ id: string; | ||
export class ListConversationMessagesResponse { | ||
constructor(public response: Response) {} | ||
export default class ListConversationMessages { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<ListConversationMessagesResponsePayload> { | ||
return this.response.json(); | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport.send( | ||
"v1/conversations/" + encodeURIComponent(id) + "/messages", | ||
{ | ||
...request, | ||
method: "GET", | ||
}, | ||
); | ||
} | ||
} |
@@ -16,16 +16,3 @@ /** | ||
export default class ListMessages { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport | ||
.send("v1/messages", { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new ListMessagesResponse(response)); | ||
} | ||
} | ||
export type ListMessagesResponsePayload = { | ||
export type ListMessagesResponse = { | ||
messages: { | ||
@@ -50,8 +37,11 @@ id: string; | ||
export class ListMessagesResponse { | ||
constructor(public response: Response) {} | ||
export default class ListMessages { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<ListMessagesResponsePayload> { | ||
return this.response.json(); | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport.send<ListMessagesResponse>("v1/messages", { | ||
...request, | ||
method: "GET", | ||
}); | ||
} | ||
} |
@@ -19,2 +19,4 @@ /** | ||
export type CreateCorrectionResponse = unknown; | ||
export default class CreateCorrectionModel { | ||
@@ -30,4 +32,5 @@ public static SCHEMA = z.object({ | ||
public async send({ id, body, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/models/" + encodeURIComponent(id) + "/correction", { | ||
return this._transport.send<CreateCorrectionResponse>( | ||
"v1/models/" + encodeURIComponent(id) + "/correction", | ||
{ | ||
...request, | ||
@@ -40,15 +43,5 @@ method: "POST", | ||
body: JSON.stringify(CreateCorrectionModel.SCHEMA.parse(body)), | ||
}) | ||
.then((response) => new CreateCorrectionModelResponse(response)); | ||
}, | ||
); | ||
} | ||
} | ||
export type CreateCorrectionResponsePayload = unknown; | ||
export class CreateCorrectionModelResponse { | ||
constructor(public response: Response) {} | ||
public async result(): Promise<CreateCorrectionResponsePayload> { | ||
return this.response.json(); | ||
} | ||
} |
@@ -17,16 +17,3 @@ /** | ||
export default class GetModel { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/models/" + encodeURIComponent(id), { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new GetModelResponse(response)); | ||
} | ||
} | ||
export type GetModelResponsePayload = { | ||
export type GetModelResponse = { | ||
model: { | ||
@@ -41,8 +28,14 @@ id: string; | ||
export class GetModelResponse { | ||
constructor(public response: Response) {} | ||
export default class GetModel { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<GetModelResponsePayload> { | ||
return this.response.json(); | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport.send<GetModelResponse>( | ||
"v1/models/" + encodeURIComponent(id), | ||
{ | ||
...request, | ||
method: "GET", | ||
}, | ||
); | ||
} | ||
} |
@@ -10,7 +10,7 @@ /** | ||
export { type GetModelResponsePayload } from "./GetModel.js"; | ||
export { type ListModelsResponsePayload } from "./ListModels.js"; | ||
export { type GetModelResponse } from "./GetModel.js"; | ||
export { type ListModelsResponse } from "./ListModels.js"; | ||
export { type CreateCorrectionResponsePayload } from "./Correction/CreateCorrectionModel.js"; | ||
export { type CreateCorrectionResponse } from "./Correction/CreateCorrectionModel.js"; | ||
export { type CreateResponseResponsePayload } from "./Response/CreateResponseModel.js"; | ||
export { type CreateResponseResponse } from "./Response/CreateResponseModel.js"; |
@@ -16,16 +16,3 @@ /** | ||
export default class ListModels { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport | ||
.send("v1/models", { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new ListModelsResponse(response)); | ||
} | ||
} | ||
export type ListModelsResponsePayload = { | ||
export type ListModelsResponse = { | ||
models: { | ||
@@ -40,8 +27,11 @@ id: string; | ||
export class ListModelsResponse { | ||
constructor(public response: Response) {} | ||
export default class ListModels { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<ListModelsResponsePayload> { | ||
return this.response.json(); | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport.send<ListModelsResponse>("v1/models", { | ||
...request, | ||
method: "GET", | ||
}); | ||
} | ||
} |
@@ -19,2 +19,10 @@ /** | ||
export type CreateResponseResponse = { | ||
message: string | null; | ||
debug: { | ||
duration: string; | ||
sources: (string | undefined)[]; | ||
}; | ||
}; | ||
export default class CreateResponseModel { | ||
@@ -33,4 +41,5 @@ public static SCHEMA = z | ||
public async send({ id, body, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/models/" + encodeURIComponent(id) + "/response", { | ||
return this._transport.send<CreateResponseResponse>( | ||
"v1/models/" + encodeURIComponent(id) + "/response", | ||
{ | ||
...request, | ||
@@ -43,21 +52,5 @@ method: "POST", | ||
body: JSON.stringify(CreateResponseModel.SCHEMA.parse(body)), | ||
}) | ||
.then((response) => new CreateResponseModelResponse(response)); | ||
}, | ||
); | ||
} | ||
} | ||
export type CreateResponseResponsePayload = { | ||
message: string | null; | ||
debug: { | ||
duration: string; | ||
sources: (string | undefined)[]; | ||
}; | ||
}; | ||
export class CreateResponseModelResponse { | ||
constructor(public response: Response) {} | ||
public async result(): Promise<CreateResponseResponsePayload> { | ||
return this.response.json(); | ||
} | ||
} |
@@ -19,2 +19,11 @@ /** | ||
export type CreateContactNoteResponse = { | ||
note: { | ||
id: string; | ||
content: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export default class CreateContactNote { | ||
@@ -28,4 +37,5 @@ public static SCHEMA = z.object({ | ||
public async send({ id, body, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/contacts/" + encodeURIComponent(id) + "/notes", { | ||
return this._transport.send<CreateContactNoteResponse>( | ||
"v1/contacts/" + encodeURIComponent(id) + "/notes", | ||
{ | ||
...request, | ||
@@ -38,22 +48,5 @@ method: "POST", | ||
body: JSON.stringify(CreateContactNote.SCHEMA.parse(body)), | ||
}) | ||
.then((response) => new CreateContactNoteResponse(response)); | ||
}, | ||
); | ||
} | ||
} | ||
export type CreateContactNoteResponsePayload = { | ||
note: { | ||
id: string; | ||
content: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export class CreateContactNoteResponse { | ||
constructor(public response: Response) {} | ||
public async result(): Promise<CreateContactNoteResponsePayload> { | ||
return this.response.json(); | ||
} | ||
} |
@@ -19,2 +19,11 @@ /** | ||
export type CreateConversationNoteResponse = { | ||
note: { | ||
id: string; | ||
content: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export default class CreateConversationNote { | ||
@@ -28,4 +37,5 @@ public static SCHEMA = z.object({ | ||
public async send({ id, body, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/conversations/" + encodeURIComponent(id) + "/notes", { | ||
return this._transport.send<CreateConversationNoteResponse>( | ||
"v1/conversations/" + encodeURIComponent(id) + "/notes", | ||
{ | ||
...request, | ||
@@ -38,22 +48,5 @@ method: "POST", | ||
body: JSON.stringify(CreateConversationNote.SCHEMA.parse(body)), | ||
}) | ||
.then((response) => new CreateConversationNoteResponse(response)); | ||
}, | ||
); | ||
} | ||
} | ||
export type CreateConversationNoteResponsePayload = { | ||
note: { | ||
id: string; | ||
content: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export class CreateConversationNoteResponse { | ||
constructor(public response: Response) {} | ||
public async result(): Promise<CreateConversationNoteResponsePayload> { | ||
return this.response.json(); | ||
} | ||
} |
@@ -17,16 +17,3 @@ /** | ||
export default class GetNote { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/notes/" + encodeURIComponent(id), { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new GetNoteResponse(response)); | ||
} | ||
} | ||
export type GetNoteResponsePayload = { | ||
export type GetNoteResponse = { | ||
note: { | ||
@@ -40,8 +27,14 @@ id: string; | ||
export class GetNoteResponse { | ||
constructor(public response: Response) {} | ||
export default class GetNote { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<GetNoteResponsePayload> { | ||
return this.response.json(); | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport.send<GetNoteResponse>( | ||
"v1/notes/" + encodeURIComponent(id), | ||
{ | ||
...request, | ||
method: "GET", | ||
}, | ||
); | ||
} | ||
} |
@@ -10,7 +10,7 @@ /** | ||
export { type CreateContactNoteResponsePayload } from "./CreateContactNote.js"; | ||
export { type CreateConversationNoteResponsePayload } from "./CreateConversationNote.js"; | ||
export { type GetNoteResponsePayload } from "./GetNote.js"; | ||
export { type ListContactNotesResponsePayload } from "./ListContactNotes.js"; | ||
export { type ListConversationNotesResponsePayload } from "./ListConversationNotes.js"; | ||
export { type UpdateNoteResponsePayload } from "./UpdateNote.js"; | ||
export { type CreateContactNoteResponse } from "./CreateContactNote.js"; | ||
export { type CreateConversationNoteResponse } from "./CreateConversationNote.js"; | ||
export { type GetNoteResponse } from "./GetNote.js"; | ||
export { type ListContactNotesResponse } from "./ListContactNotes.js"; | ||
export { type ListConversationNotesResponse } from "./ListConversationNotes.js"; | ||
export { type UpdateNoteResponse } from "./UpdateNote.js"; |
@@ -17,16 +17,3 @@ /** | ||
export default class ListContactNotes { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/contacts/" + encodeURIComponent(id) + "/notes", { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new ListContactNotesResponse(response)); | ||
} | ||
} | ||
export type ListContactNotesResponsePayload = { | ||
export type ListContactNotesResponse = { | ||
notes: { | ||
@@ -40,8 +27,14 @@ id: string; | ||
export class ListContactNotesResponse { | ||
constructor(public response: Response) {} | ||
export default class ListContactNotes { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<ListContactNotesResponsePayload> { | ||
return this.response.json(); | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport.send<ListContactNotesResponse>( | ||
"v1/contacts/" + encodeURIComponent(id) + "/notes", | ||
{ | ||
...request, | ||
method: "GET", | ||
}, | ||
); | ||
} | ||
} |
@@ -17,16 +17,3 @@ /** | ||
export default class ListConversationNotes { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/conversations/" + encodeURIComponent(id) + "/notes", { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new ListConversationNotesResponse(response)); | ||
} | ||
} | ||
export type ListConversationNotesResponsePayload = { | ||
export type ListConversationNotesResponse = { | ||
notes: { | ||
@@ -40,8 +27,14 @@ id: string; | ||
export class ListConversationNotesResponse { | ||
constructor(public response: Response) {} | ||
export default class ListConversationNotes { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<ListConversationNotesResponsePayload> { | ||
return this.response.json(); | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport.send<ListConversationNotesResponse>( | ||
"v1/conversations/" + encodeURIComponent(id) + "/notes", | ||
{ | ||
...request, | ||
method: "GET", | ||
}, | ||
); | ||
} | ||
} |
@@ -19,2 +19,11 @@ /** | ||
export type UpdateNoteResponse = { | ||
note: { | ||
id: string; | ||
content: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export default class UpdateNote { | ||
@@ -28,4 +37,5 @@ public static SCHEMA = z.object({ | ||
public async send({ id, body, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/notes/" + encodeURIComponent(id), { | ||
return this._transport.send<UpdateNoteResponse>( | ||
"v1/notes/" + encodeURIComponent(id), | ||
{ | ||
...request, | ||
@@ -38,22 +48,5 @@ method: "PATCH", | ||
body: JSON.stringify(UpdateNote.SCHEMA.parse(body)), | ||
}) | ||
.then((response) => new UpdateNoteResponse(response)); | ||
}, | ||
); | ||
} | ||
} | ||
export type UpdateNoteResponsePayload = { | ||
note: { | ||
id: string; | ||
content: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export class UpdateNoteResponse { | ||
constructor(public response: Response) {} | ||
public async result(): Promise<UpdateNoteResponsePayload> { | ||
return this.response.json(); | ||
} | ||
} |
@@ -17,16 +17,3 @@ /** | ||
export default class GetSource { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/sources/" + encodeURIComponent(id), { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new GetSourceResponse(response)); | ||
} | ||
} | ||
export type GetSourceResponsePayload = { | ||
export type GetSourceResponse = { | ||
source: { | ||
@@ -42,8 +29,14 @@ id: string; | ||
export class GetSourceResponse { | ||
constructor(public response: Response) {} | ||
export default class GetSource { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<GetSourceResponsePayload> { | ||
return this.response.json(); | ||
public async send({ id, request = {} }: Options) { | ||
return this._transport.send<GetSourceResponse>( | ||
"v1/sources/" + encodeURIComponent(id), | ||
{ | ||
...request, | ||
method: "GET", | ||
}, | ||
); | ||
} | ||
} |
@@ -10,3 +10,3 @@ /** | ||
export { type GetSourceResponsePayload } from "./GetSource.js"; | ||
export { type ListSourcesResponsePayload } from "./ListSources.js"; | ||
export { type GetSourceResponse } from "./GetSource.js"; | ||
export { type ListSourcesResponse } from "./ListSources.js"; |
@@ -16,16 +16,3 @@ /** | ||
export default class ListSources { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport | ||
.send("v1/sources", { | ||
...request, | ||
method: "GET", | ||
}) | ||
.then((response) => new ListSourcesResponse(response)); | ||
} | ||
} | ||
export type ListSourcesResponsePayload = { | ||
export type ListSourcesResponse = { | ||
sources: { | ||
@@ -41,8 +28,11 @@ id: string; | ||
export class ListSourcesResponse { | ||
constructor(public response: Response) {} | ||
export default class ListSources { | ||
constructor(protected _transport: FetchTransport) {} | ||
public async result(): Promise<ListSourcesResponsePayload> { | ||
return this.response.json(); | ||
public async send({ request = {} }: Options = {}) { | ||
return this._transport.send<ListSourcesResponse>("v1/sources", { | ||
...request, | ||
method: "GET", | ||
}); | ||
} | ||
} |
@@ -19,2 +19,10 @@ /** | ||
export type CreateContactSubscriptionResponse = { | ||
subscription: { | ||
id: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export default class CreateContactSubscription { | ||
@@ -35,4 +43,5 @@ public static SCHEMA = z.discriminatedUnion("type", [ | ||
public async send({ id, body, request = {} }: Options) { | ||
return this._transport | ||
.send("v1/contacts/" + encodeURIComponent(id) + "/subscriptions", { | ||
return this._transport.send<CreateContactSubscriptionResponse>( | ||
"v1/contacts/" + encodeURIComponent(id) + "/subscriptions", | ||
{ | ||
...request, | ||
@@ -45,21 +54,5 @@ method: "POST", | ||
body: JSON.stringify(CreateContactSubscription.SCHEMA.parse(body)), | ||
}) | ||
.then((response) => new CreateContactSubscriptionResponse(response)); | ||
}, | ||
); | ||
} | ||
} | ||
export type CreateContactSubscriptionResponsePayload = { | ||
subscription: { | ||
id: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
}; | ||
export class CreateContactSubscriptionResponse { | ||
constructor(public response: Response) {} | ||
public async result(): Promise<CreateContactSubscriptionResponsePayload> { | ||
return this.response.json(); | ||
} | ||
} |
@@ -10,2 +10,2 @@ /** | ||
export { type CreateContactSubscriptionResponsePayload } from "./CreateContactSubscription.js"; | ||
export { type CreateContactSubscriptionResponse } from "./CreateContactSubscription.js"; |
@@ -11,3 +11,3 @@ /** | ||
import isNetworkError from "is-network-error"; | ||
import ky, { HTTPError } from "ky"; | ||
import ky, { HTTPError, KyInstance } from "ky"; | ||
import AuthenticationError from "../Error/AuthenticationError.js"; | ||
@@ -29,2 +29,3 @@ import AuthorizationError from "../Error/AuthorizationError.js"; | ||
export default class FetchTransport implements Transport { | ||
public client: KyInstance; | ||
public options: Options; | ||
@@ -37,2 +38,24 @@ | ||
}; | ||
this.client = ky.create({ | ||
prefixUrl: this.options.baseURL, | ||
hooks: { | ||
beforeRequest: [ | ||
(request) => { | ||
for (const filterable of this.options.requestFilterables) { | ||
const filterableHeaders = filterable.getHeaders(); | ||
for (const [headerName, headerValue] of Object.entries( | ||
filterableHeaders, | ||
)) { | ||
// Skip explicitly-overwritten headers | ||
if (request.headers.has(headerName)) { | ||
continue; | ||
} | ||
request.headers.set(headerName, headerValue); | ||
} | ||
} | ||
}, | ||
], | ||
}, | ||
}); | ||
} | ||
@@ -44,20 +67,5 @@ | ||
public getRequest(url: string, request: RequestInit): Request { | ||
// Merge headers | ||
request.headers = new Headers(request.headers); | ||
for (const filterable of this.options.requestFilterables) { | ||
const filterableHeaders = filterable.getHeaders(); | ||
for (const [headerName, headerValue] of Object.entries( | ||
filterableHeaders, | ||
)) { | ||
request.headers.set(headerName, headerValue); | ||
} | ||
} | ||
return new Request(this.getURL(url), request); | ||
} | ||
public async send<T = unknown>(url: string, request: RequestInit) { | ||
// See: https://github.com/node-fetch/node-fetch/issues/481#issuecomment-592491825 | ||
return await ky<T>(this.getRequest(url, request)).catch((error) => { | ||
return await this.client<T>(url, request).catch((error) => { | ||
if (isNetworkError(error)) { | ||
@@ -64,0 +72,0 @@ throw new NetworkError("A network error occurred", { cause: error }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 7 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 7 instances in 1 package
104
243413
4469