@great-detail/support-sdk 0.2.7 → 0.2.9
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/dist/chunk-KG7KNOPC.js +1 -0
- package/dist/{chunk-YM5DPCH2.js → chunk-ZYSG2PTQ.js} +1 -1
- package/dist/cli/index.cjs +1 -1
- package/dist/cli/index.d.cts +1 -2
- package/dist/cli/index.d.ts +1 -2
- package/dist/cli/index.js +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/{index-D5qMSL8Q.d.cts → index-BMsEq65I.d.cts} +179 -24
- package/dist/{index-D5qMSL8Q.d.ts → index-BMsEq65I.d.ts} +179 -24
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -1
- package/package.json +1 -2
- package/src/Action/index.ts +10 -0
- package/src/Boilerplate/CreateBoilerplate.ts +59 -0
- package/src/Boilerplate/GetBoilerplate.ts +47 -0
- package/src/Boilerplate/ListBoilerplates.ts +46 -0
- package/src/Boilerplate/UpdateBoilerplate.ts +59 -0
- package/src/Boilerplate/index.ts +13 -0
- package/src/Channel/index.ts +10 -0
- package/src/Client/index.ts +13 -0
- package/src/Contact/index.ts +14 -0
- package/src/Conversation/index.ts +13 -0
- package/src/Label/index.ts +14 -0
- package/src/Message/index.ts +11 -0
- package/src/Model/index.ts +15 -0
- package/src/Note/index.ts +15 -0
- package/src/Source/index.ts +11 -0
- package/src/Transport/FetchTransport.ts +1 -17
- package/src/index.ts +10 -47
- package/dist/chunk-AVKSGUMM.js +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Great Detail Support System.
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2024 Great Detail Ltd
|
|
5
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
6
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
7
|
+
* @see https://greatdetail.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export { type ListChannelsResponsePayload } from "./ListChannels.js";
|
package/src/Client/index.ts
CHANGED
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
import ListActions from "../Action/ListActions.js";
|
|
11
11
|
import Authentication from "../Authentication/index.js";
|
|
12
|
+
import CreateBoilerplate from "../Boilerplate/CreateBoilerplate.js";
|
|
13
|
+
import GetBoilerplate from "../Boilerplate/GetBoilerplate.js";
|
|
14
|
+
import ListBoilerplates from "../Boilerplate/ListBoilerplates.js";
|
|
15
|
+
import UpdateBoilerplate from "../Boilerplate/UpdateBoilerplate.js";
|
|
12
16
|
import ListChannels from "../Channel/ListChannels.js";
|
|
13
17
|
import { BASE_URL_ENV_VAR } from "../constants/environment.js";
|
|
14
18
|
import { DEFAULT_SUPPORT_BASE_URL } from "../constants/index.js";
|
|
@@ -74,6 +78,15 @@ export default class Client {
|
|
|
74
78
|
};
|
|
75
79
|
}
|
|
76
80
|
|
|
81
|
+
public get boilerplate() {
|
|
82
|
+
return {
|
|
83
|
+
get: new GetBoilerplate(this._transport),
|
|
84
|
+
list: new ListBoilerplates(this._transport),
|
|
85
|
+
create: new CreateBoilerplate(this._transport),
|
|
86
|
+
update: new UpdateBoilerplate(this._transport),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
77
90
|
public get channel() {
|
|
78
91
|
return {
|
|
79
92
|
list: new ListChannels(this._transport),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Great Detail Support System.
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2024 Great Detail Ltd
|
|
5
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
6
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
7
|
+
* @see https://greatdetail.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export { type CreateContactResponsePayload } from "./CreateContact.js";
|
|
11
|
+
export { type GetContactResponsePayload } from "./GetContact.js";
|
|
12
|
+
export { type ListContactsResponsePayload } from "./ListContacts.js";
|
|
13
|
+
export { type ListLabelContactsResponsePayload } from "./ListLabelContacts.js";
|
|
14
|
+
export { type UpdateContactResponsePayload } from "./UpdateContact.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Great Detail Support System.
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2024 Great Detail Ltd
|
|
5
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
6
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
7
|
+
* @see https://greatdetail.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export { type GetConversationResponsePayload } from "./GetConversation.js";
|
|
11
|
+
export { type ListConversationsResponsePayload } from "./ListConversations.js";
|
|
12
|
+
export { type ListLabelConversationsResponsePayload } from "./ListLabelConversations.js";
|
|
13
|
+
export { type UpdateConversationResponsePayload } from "./UpdateConversation.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Great Detail Support System.
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2024 Great Detail Ltd
|
|
5
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
6
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
7
|
+
* @see https://greatdetail.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export { type CreateLabelResponsePayload } from "./CreateLabel.js";
|
|
11
|
+
export { type DeleteLabelResponsePayload } from "./DeleteLabel.js";
|
|
12
|
+
export { type GetLabelResponsePayload } from "./GetLabel.js";
|
|
13
|
+
export { type ListLabelsResponsePayload } from "./ListLabels.js";
|
|
14
|
+
export { type UpdateLabelResponsePayload } from "./UpdateLabel.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Great Detail Support System.
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2024 Great Detail Ltd
|
|
5
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
6
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
7
|
+
* @see https://greatdetail.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export { type ListConversationMessagesResponsePayload } from "./ListConversationMessages.js";
|
|
11
|
+
export { type ListMessagesResponsePayload } from "./ListMessages.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Great Detail Support System.
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2024 Great Detail Ltd
|
|
5
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
6
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
7
|
+
* @see https://greatdetail.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export { type GetModelResponsePayload } from "./GetModel.js";
|
|
11
|
+
export { type ListModelsResponsePayload } from "./ListModels.js";
|
|
12
|
+
|
|
13
|
+
export { type CreateCorrectionResponsePayload } from "./Correction/CreateCorrectionModel.js";
|
|
14
|
+
|
|
15
|
+
export { type CreateResponseResponsePayload } from "./Response/CreateResponseModel.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Great Detail Support System.
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2024 Great Detail Ltd
|
|
5
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
6
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
7
|
+
* @see https://greatdetail.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export { type CreateContactNoteResponsePayload } from "./CreateContactNote.js";
|
|
11
|
+
export { type CreateConversationNoteResponsePayload } from "./CreateConversationNote.js";
|
|
12
|
+
export { type GetNoteResponsePayload } from "./GetNote.js";
|
|
13
|
+
export { type ListContactNotesResponsePayload } from "./ListContactNotes.js";
|
|
14
|
+
export { type ListConversationNotesResponsePayload } from "./ListConversationNotes.js";
|
|
15
|
+
export { type UpdateNoteResponsePayload } from "./UpdateNote.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Great Detail Support System.
|
|
3
|
+
*
|
|
4
|
+
* @copyright 2024 Great Detail Ltd
|
|
5
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
6
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
7
|
+
* @see https://greatdetail.com
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export { type GetSourceResponsePayload } from "./GetSource.js";
|
|
11
|
+
export { type ListSourcesResponsePayload } from "./ListSources.js";
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* @see https://greatdetail.com
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import fetch, { Request } from "cross-fetch";
|
|
11
10
|
import isNetworkError from "is-network-error";
|
|
12
11
|
import ky from "ky";
|
|
13
12
|
import AuthenticationError from "../Error/AuthenticationError.js";
|
|
@@ -19,33 +18,18 @@ import Transport, { Options as TransportOptions } from "./index.js";
|
|
|
19
18
|
|
|
20
19
|
export interface InputOptions extends TransportOptions {
|
|
21
20
|
baseURL: string;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Alternative Fetch Provider.
|
|
25
|
-
* Used to override the default fetch provider and use polyfills or other
|
|
26
|
-
* libraries.
|
|
27
|
-
*
|
|
28
|
-
* @since 1.0.0
|
|
29
|
-
*/
|
|
30
|
-
fetch?: typeof fetch;
|
|
31
21
|
}
|
|
32
22
|
|
|
33
23
|
export interface Options extends TransportOptions {
|
|
34
24
|
baseURL: string;
|
|
35
|
-
fetch: typeof fetch;
|
|
36
25
|
}
|
|
37
26
|
|
|
38
27
|
export default class FetchTransport implements Transport {
|
|
39
28
|
public options: Options;
|
|
40
29
|
|
|
41
|
-
constructor({
|
|
42
|
-
baseURL,
|
|
43
|
-
fetch: fetchAlternative = fetch,
|
|
44
|
-
...options
|
|
45
|
-
}: InputOptions) {
|
|
30
|
+
constructor({ baseURL, ...options }: InputOptions) {
|
|
46
31
|
this.options = {
|
|
47
32
|
...options,
|
|
48
|
-
fetch: fetchAlternative,
|
|
49
33
|
baseURL,
|
|
50
34
|
};
|
|
51
35
|
}
|
package/src/index.ts
CHANGED
|
@@ -24,50 +24,13 @@ export { default as KeyAuthentication } from "./Authentication/KeyAuthentication
|
|
|
24
24
|
export { default as TokenAuthentication } from "./Authentication/TokenAuthentication.js";
|
|
25
25
|
export { default as PublicAuthentication } from "./Authentication/PublicAuthentication.js";
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export { type UpdateContactResponsePayload } from "./Contact/UpdateContact.js";
|
|
38
|
-
export { type CreateContactResponsePayload } from "./Contact/CreateContact.js";
|
|
39
|
-
|
|
40
|
-
// Conversations
|
|
41
|
-
export { type GetConversationResponsePayload } from "./Conversation/GetConversation.js";
|
|
42
|
-
export { type ListConversationsResponsePayload } from "./Conversation/ListConversations.js";
|
|
43
|
-
export { type ListLabelConversationsResponsePayload } from "./Conversation/ListLabelConversations.js";
|
|
44
|
-
export { type UpdateConversationResponsePayload } from "./Conversation/UpdateConversation.js";
|
|
45
|
-
|
|
46
|
-
// Labels
|
|
47
|
-
export { type CreateLabelResponsePayload } from "./Label/CreateLabel.js";
|
|
48
|
-
export { type DeleteLabelResponsePayload } from "./Label/DeleteLabel.js";
|
|
49
|
-
export { type GetLabelResponsePayload } from "./Label/GetLabel.js";
|
|
50
|
-
export { type ListLabelsResponsePayload } from "./Label/ListLabels.js";
|
|
51
|
-
export { type UpdateLabelResponsePayload } from "./Label/UpdateLabel.js";
|
|
52
|
-
|
|
53
|
-
// Messages
|
|
54
|
-
export { type ListConversationMessagesResponsePayload } from "./Message/ListConversationMessages.js";
|
|
55
|
-
export { type ListMessagesResponsePayload } from "./Message/ListMessages.js";
|
|
56
|
-
|
|
57
|
-
// Models
|
|
58
|
-
export { type GetModelResponsePayload } from "./Model/GetModel.js";
|
|
59
|
-
export { type ListModelsResponsePayload } from "./Model/ListModels.js";
|
|
60
|
-
export { type CreateCorrectionResponsePayload } from "./Model/Correction/CreateCorrectionModel.js";
|
|
61
|
-
export { type CreateResponseResponsePayload } from "./Model/Response/CreateResponseModel.js";
|
|
62
|
-
|
|
63
|
-
// Notes
|
|
64
|
-
export { type GetNoteResponsePayload } from "./Note/GetNote.js";
|
|
65
|
-
export { type UpdateNoteResponsePayload } from "./Note/UpdateNote.js";
|
|
66
|
-
export { type ListConversationNotesResponsePayload } from "./Note/ListConversationNotes.js";
|
|
67
|
-
export { type ListContactNotesResponsePayload } from "./Note/ListContactNotes.js";
|
|
68
|
-
export { type CreateConversationNoteResponsePayload } from "./Note/CreateConversationNote.js";
|
|
69
|
-
export { type CreateContactNoteResponsePayload } from "./Note/CreateContactNote.js";
|
|
70
|
-
|
|
71
|
-
// Sources
|
|
72
|
-
export { type GetSourceResponsePayload } from "./Source/GetSource.js";
|
|
73
|
-
export { type ListSourcesResponsePayload } from "./Source/ListSources.js";
|
|
27
|
+
export * from "./Action/index.js";
|
|
28
|
+
export * from "./Boilerplate/index.js";
|
|
29
|
+
export * from "./Channel/index.js";
|
|
30
|
+
export * from "./Contact/index.js";
|
|
31
|
+
export * from "./Conversation/index.js";
|
|
32
|
+
export * from "./Label/index.js";
|
|
33
|
+
export * from "./Message/index.js";
|
|
34
|
+
export * from "./Model/index.js";
|
|
35
|
+
export * from "./Note/index.js";
|
|
36
|
+
export * from "./Source/index.js";
|
package/dist/chunk-AVKSGUMM.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var Nt=Object.defineProperty;var Jt=(e,t)=>{for(var s in t)Nt(e,s,{get:t[s],enumerable:!0})};var Ot="https://api.support.greatdetail.com",wt={"X-Powered-By":"GDSupport/JavaScript"},Vt="api-key";var p=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"}).then(s=>new W(s))}},W=class{constructor(t){this.response=t}async result(){return this.response.json()}};var c=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"}).then(s=>new X(s))}},X=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as d}from"zod";var u=class e{constructor(t){this._transport=t}static SCHEMA=d.object({name:d.string(),account:d.string(),emailAddress:d.string().email().optional(),telephoneNumber:d.string().optional()});async send({body:t,request:s={}}){return this._transport.send("v1/contacts",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(t))}).then(r=>new Q(r))}},Q=class{constructor(t){this.response=t}async result(){return this.response.json()}};var l=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new Z(r))}},Z=class{constructor(t){this.response=t}async result(){return this.response.json()}};var m=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"}).then(s=>new tt(s))}},tt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var g=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...s,method:"GET"}).then(r=>new et(r))}},et=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as k}from"zod";var h=class e{constructor(t){this._transport=t}static SCHEMA=k.object({name:k.string().optional(),emailAddress:k.string().email().optional(),telephoneNumber:k.string().optional()});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new st(n))}},st=class{constructor(t){this.response=t}async result(){return this.response.json()}};var f=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new rt(r))}},rt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var b=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/conversations",{...t,method:"GET"}).then(s=>new nt(s))}},nt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var y=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...s,method:"GET"}).then(r=>new ot(r))}},ot=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as Ft}from"zod";var R=class e{constructor(t){this._transport=t}static SCHEMA=Ft.object({hasEnded:Ft.boolean()});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new it(n))}},it=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as K}from"zod";var x=class e{constructor(t){this._transport=t}static SCHEMA=K.object({title:K.string(),description:K.string().optional(),account:K.string()});async send({body:t,request:s={}}){return this._transport.send("v1/labels",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(t))}).then(r=>new at(r))}},at=class{constructor(t){this.response=t}async result(){return this.response.json()}};var A=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...s,method:"DELETE"}).then(r=>new pt(r))}},pt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var C=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new ct(r))}},ct=class{constructor(t){this.response=t}async result(){return this.response.json()}};var T=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"}).then(s=>new dt(s))}},dt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as ut}from"zod";var _=class e{constructor(t){this._transport=t}static SCHEMA=ut.object({title:ut.string().optional(),description:ut.string().optional()});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new lt(n))}},lt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var P=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET"}).then(r=>new mt(r))}},mt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var S=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"}).then(s=>new gt(s))}},gt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as Y}from"zod";var E=class e{constructor(t){this._transport=t}static SCHEMA=Y.object({input:Y.string().max(65536),original:Y.string().max(65536),correction:Y.string().max(65536)});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new ht(n))}},ht=class{constructor(t){this.response=t}async result(){return this.response.json()}};var v=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new ft(r))}},ft=class{constructor(t){this.response=t}async result(){return this.response.json()}};var O=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"}).then(s=>new bt(s))}},bt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as $}from"zod";var w=class e{constructor(t){this._transport=t}static SCHEMA=$.array($.object({role:$.enum(["user","assistant"]),content:$.string().max(65536).nullable()})).min(1);async send({id:t,body:s,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new yt(n))}},yt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as Ut}from"zod";var F=class e{constructor(t){this._transport=t}static SCHEMA=Ut.object({content:Ut.string()});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new Rt(n))}},Rt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as qt}from"zod";var U=class e{constructor(t){this._transport=t}static SCHEMA=qt.object({content:qt.string()});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new xt(n))}},xt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var q=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new At(r))}},At=class{constructor(t){this.response=t}async result(){return this.response.json()}};var I=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...s,method:"GET"}).then(r=>new Ct(r))}},Ct=class{constructor(t){this.response=t}async result(){return this.response.json()}};var j=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...s,method:"GET"}).then(r=>new Tt(r))}},Tt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as It}from"zod";var L=class e{constructor(t){this._transport=t}static SCHEMA=It.object({content:It.string().optional()});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new _t(n))}},_t=class{constructor(t){this.response=t}async result(){return this.response.json()}};var H=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new Pt(r))}},Pt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var N=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/sources",{...t,method:"GET"}).then(s=>new St(s))}},St=class{constructor(t){this.response=t}async result(){return this.response.json()}};var qe="SUPPORT_ACCESS_TOKEN",Ie="SUPPORT_API_KEY",je="SUPPORT_KEY_NAME",jt="SUPPORT_BASE_URL";var M=class{constructor(t){this._transport=t}getRelativeURL({id:t,vcf:s={}}){let r=s.variant??"vcard",n=s.format??(s.variant==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(r)+"&format="+encodeURIComponent(n)}getURL(t){return this._transport.getURL(this.getRelativeURL(t))}};var G=class e{constructor(t=e.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=wt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};import Mt,{Request as Gt}from"cross-fetch";import Dt from"is-network-error";import zt from"ky";var o=class extends Error{};var i=class extends o{};var D=class extends i{static unauthenticated(){return new this("An unauthenticated request occurred")}};var z=class extends i{static forbidden(){return new this("A forbidden request occurred")}};var a=class extends o{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,s){return new this(`Forbidden method for request: ${t} ${s}`)}};var J=class extends o{};var B=class extends o{static badRequest(){return new this("Bad request")}};var V=class{options;constructor({baseURL:t,fetch:s=Mt,...r}){this.options={...r,fetch:s,baseURL:t}}getURL(t){return new URL(t,this.options.baseURL).toString()}getRequest(t,s){s.headers=new Headers(s.headers);for(let r of this.options.requestFilterables){let n=r.getHeaders();for(let[Lt,Ht]of Object.entries(n))s.headers.set(Lt,Ht)}return new Gt(this.getURL(t),s)}async send(t,s){return await zt(this.getRequest(t,s)).then(r=>{if(!r.ok){let n=r.status;switch(console.error(JSON.stringify(r)),n){case 400:throw B.badRequest();case 401:throw D.unauthenticated();case 403:throw z.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,s.method??"GET")}}return r}).catch(r=>{throw Dt(r)?new J("A network error occurred",{cause:r}):r})}};var Et=class e{static DEFAULT_BASE_URL=Ot;_transport;constructor(t,{baseURL:s,...r}={}){this._transport=new V({requestFilterables:[new G,t],...r,baseURL:s?.toString()??e.getBaseURL()})}static getBaseURL(){return process.env[jt]??this.DEFAULT_BASE_URL}get action(){return{list:new p(this._transport)}}get channel(){return{list:new c(this._transport)}}get contact(){return{get:new l(this._transport),list:new m(this._transport),update:new h(this._transport),create:new u(this._transport),vcf:{get:new M(this._transport)},note:{list:new I(this._transport),create:new F(this._transport)}}}get conversation(){return{get:new f(this._transport),list:new b(this._transport),update:new R(this._transport),message:{list:new P(this._transport)},note:{list:new j(this._transport),create:new U(this._transport)}}}get label(){return{create:new x(this._transport),get:new C(this._transport),list:new T(this._transport),update:new _(this._transport),delete:new A(this._transport),contact:{list:new g(this._transport)},conversation:{list:new y(this._transport)}}}get message(){return{list:new S(this._transport)}}get model(){return{get:new v(this._transport),list:new O(this._transport),response:{create:new w(this._transport)},correction:{create:new E(this._transport)}}}get note(){return{get:new q(this._transport),update:new L(this._transport)}}get source(){return{get:new H(this._transport),list:new N(this._transport)}}};var vt=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};export{Jt as a,Ot as b,Vt as c,qe as d,Ie as e,je as f,o as g,i as h,D as i,z as j,a as k,J as l,B as m,Et as n,vt as o};
|