@great-detail/support-sdk 0.2.2 → 0.2.4
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-DQ4HNN5U.js +1 -0
- package/dist/{chunk-YQ6LXSV4.js → chunk-Z2LEUYUK.js} +1 -1
- package/dist/cli/index.cjs +1 -1
- package/dist/cli/index.d.cts +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/{index-BwsedLC7.d.cts → index-Cjm56Jad.d.cts} +206 -54
- package/dist/{index-BwsedLC7.d.ts → index-Cjm56Jad.d.ts} +206 -54
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/Client/index.ts +12 -0
- package/src/Note/CreateContactNote.ts +56 -0
- package/src/Note/CreateConversationNote.ts +56 -0
- package/src/Note/ListContactNotes.ts +45 -0
- package/src/Note/ListConversationNotes.ts +45 -0
- package/src/index.ts +4 -0
- package/dist/chunk-WAY6IGDK.js +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as Authentication } from './index-
|
|
2
|
-
export { C as Client, e as CreateContactResponsePayload, r as CreateCorrectionResponsePayload, j as CreateLabelResponsePayload, s as CreateResponseResponsePayload, D as DeleteLabelResponsePayload, G as GetContactResponsePayload, f as GetConversationResponsePayload, k as GetLabelResponsePayload, p as GetModelResponsePayload, t as GetNoteResponsePayload,
|
|
1
|
+
import { A as Authentication } from './index-Cjm56Jad.cjs';
|
|
2
|
+
export { C as Client, y as CreateContactNoteResponsePayload, e as CreateContactResponsePayload, x as CreateConversationNoteResponsePayload, r as CreateCorrectionResponsePayload, j as CreateLabelResponsePayload, s as CreateResponseResponsePayload, D as DeleteLabelResponsePayload, G as GetContactResponsePayload, f as GetConversationResponsePayload, k as GetLabelResponsePayload, p as GetModelResponsePayload, t as GetNoteResponsePayload, z as GetSourceResponsePayload, L as ListActionsResponsePayload, b as ListChannelsResponsePayload, w as ListContactNotesResponsePayload, c as ListContactsResponsePayload, n as ListConversationMessagesResponsePayload, v as ListConversationNotesResponsePayload, g as ListConversationsResponsePayload, d as ListLabelContactsResponsePayload, h as ListLabelConversationsResponsePayload, l as ListLabelsResponsePayload, o as ListMessagesResponsePayload, q as ListModelsResponsePayload, B as ListSourcesResponsePayload, O as Options, R as RequestFilterable, a as TransportOptions, U as UpdateContactResponsePayload, i as UpdateConversationResponsePayload, m as UpdateLabelResponsePayload, u as UpdateNoteResponsePayload, C as default } from './index-Cjm56Jad.cjs';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as Authentication } from './index-
|
|
2
|
-
export { C as Client, e as CreateContactResponsePayload, r as CreateCorrectionResponsePayload, j as CreateLabelResponsePayload, s as CreateResponseResponsePayload, D as DeleteLabelResponsePayload, G as GetContactResponsePayload, f as GetConversationResponsePayload, k as GetLabelResponsePayload, p as GetModelResponsePayload, t as GetNoteResponsePayload,
|
|
1
|
+
import { A as Authentication } from './index-Cjm56Jad.js';
|
|
2
|
+
export { C as Client, y as CreateContactNoteResponsePayload, e as CreateContactResponsePayload, x as CreateConversationNoteResponsePayload, r as CreateCorrectionResponsePayload, j as CreateLabelResponsePayload, s as CreateResponseResponsePayload, D as DeleteLabelResponsePayload, G as GetContactResponsePayload, f as GetConversationResponsePayload, k as GetLabelResponsePayload, p as GetModelResponsePayload, t as GetNoteResponsePayload, z as GetSourceResponsePayload, L as ListActionsResponsePayload, b as ListChannelsResponsePayload, w as ListContactNotesResponsePayload, c as ListContactsResponsePayload, n as ListConversationMessagesResponsePayload, v as ListConversationNotesResponsePayload, g as ListConversationsResponsePayload, d as ListLabelContactsResponsePayload, h as ListLabelConversationsResponsePayload, l as ListLabelsResponsePayload, o as ListMessagesResponsePayload, q as ListModelsResponsePayload, B as ListSourcesResponsePayload, O as Options, R as RequestFilterable, a as TransportOptions, U as UpdateContactResponsePayload, i as UpdateConversationResponsePayload, m as UpdateLabelResponsePayload, u as UpdateNoteResponsePayload, C as default } from './index-Cjm56Jad.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as P,b as A,c as a,d as p,e as n,f as i,g as f,h as l,i as
|
|
1
|
+
import{a as P,b as A,c as a,d as p,e as n,f as i,g as f,h as l,i as y,j as m,k as d,l as x,m as u,n as c,o as h}from"./chunk-DQ4HNN5U.js";var R={};P(R,{AuthError:()=>l,AuthenticationError:()=>y,AuthorizationError:()=>m,LogicError:()=>d,NetworkError:()=>x,SupportError:()=>f,ValidationError:()=>u});var o=class r{static DEFAULT_NAME=a;name;#e;constructor({name:e=process.env[i]??r.DEFAULT_NAME,key:s=process.env[n]}={}){if(!s)throw new Error("API Key option must be specified when using Key Authentication");this.name=e,this.#e=s}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#e)}`}}};var t=class{#e;constructor({token:e=process.env[p]}={}){if(!e)throw new Error("Access Token option must be specified when using Token Authentication");this.#e=e}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#e}`}}};export{c as Client,A as DEFAULT_SUPPORT_BASE_URL,R as Error,o as KeyAuthentication,h as PublicAuthentication,t as TokenAuthentication,c as default};
|
package/package.json
CHANGED
package/src/Client/index.ts
CHANGED
|
@@ -33,7 +33,11 @@ import CreateCorrectionModel from "../Model/Correction/CreateCorrectionModel.js"
|
|
|
33
33
|
import GetModel from "../Model/GetModel.js";
|
|
34
34
|
import ListModels from "../Model/ListModels.js";
|
|
35
35
|
import CreateResponseModel from "../Model/Response/CreateResponseModel.js";
|
|
36
|
+
import CreateContactNote from "../Note/CreateContactNote.js";
|
|
37
|
+
import CreateConversationNote from "../Note/CreateConversationNote.js";
|
|
36
38
|
import GetNote from "../Note/GetNote.js";
|
|
39
|
+
import ListContactNotes from "../Note/ListContactNotes.js";
|
|
40
|
+
import ListConversationNotes from "../Note/ListConversationNotes.js";
|
|
37
41
|
import UpdateNote from "../Note/UpdateNote.js";
|
|
38
42
|
import RequestStandardHeaders from "../Request/RequestStandardHeaders.js";
|
|
39
43
|
import GetSource from "../Source/GetSource.js";
|
|
@@ -85,6 +89,10 @@ export default class Client {
|
|
|
85
89
|
vcf: {
|
|
86
90
|
get: new GetContactVCFURL(this._transport),
|
|
87
91
|
},
|
|
92
|
+
note: {
|
|
93
|
+
list: new ListContactNotes(this._transport),
|
|
94
|
+
create: new CreateContactNote(this._transport),
|
|
95
|
+
},
|
|
88
96
|
};
|
|
89
97
|
}
|
|
90
98
|
|
|
@@ -96,6 +104,10 @@ export default class Client {
|
|
|
96
104
|
message: {
|
|
97
105
|
list: new ListConversationMessages(this._transport),
|
|
98
106
|
},
|
|
107
|
+
note: {
|
|
108
|
+
list: new ListConversationNotes(this._transport),
|
|
109
|
+
create: new CreateConversationNote(this._transport),
|
|
110
|
+
},
|
|
99
111
|
};
|
|
100
112
|
}
|
|
101
113
|
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
import { z } from "zod";
|
|
11
|
+
import FetchTransport from "../Transport/FetchTransport.js";
|
|
12
|
+
|
|
13
|
+
export interface Options {
|
|
14
|
+
id: string;
|
|
15
|
+
body: z.infer<typeof CreateContactNote.SCHEMA>;
|
|
16
|
+
request?: RequestInit;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default class CreateContactNote {
|
|
20
|
+
public static SCHEMA = z.object({
|
|
21
|
+
content: z.string(),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
constructor(protected _transport: FetchTransport) {}
|
|
25
|
+
|
|
26
|
+
public async send({ id, body, request = {} }: Options) {
|
|
27
|
+
return this._transport
|
|
28
|
+
.send("v1/contacts/" + encodeURIComponent(id) + "/notes", {
|
|
29
|
+
...request,
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers: {
|
|
32
|
+
...request.headers,
|
|
33
|
+
"Content-Type": "application/json",
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify(CreateContactNote.SCHEMA.parse(body)),
|
|
36
|
+
})
|
|
37
|
+
.then((response) => new CreateContactNoteResponse(response));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type CreateContactNoteResponsePayload = {
|
|
42
|
+
note: {
|
|
43
|
+
id: string;
|
|
44
|
+
content: string;
|
|
45
|
+
createdAt: string;
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export class CreateContactNoteResponse {
|
|
51
|
+
constructor(public response: Response) {}
|
|
52
|
+
|
|
53
|
+
public async result(): Promise<CreateContactNoteResponsePayload> {
|
|
54
|
+
return this.response.json();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
import { z } from "zod";
|
|
11
|
+
import FetchTransport from "../Transport/FetchTransport.js";
|
|
12
|
+
|
|
13
|
+
export interface Options {
|
|
14
|
+
id: string;
|
|
15
|
+
body: z.infer<typeof CreateConversationNote.SCHEMA>;
|
|
16
|
+
request?: RequestInit;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default class CreateConversationNote {
|
|
20
|
+
public static SCHEMA = z.object({
|
|
21
|
+
content: z.string(),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
constructor(protected _transport: FetchTransport) {}
|
|
25
|
+
|
|
26
|
+
public async send({ id, body, request = {} }: Options) {
|
|
27
|
+
return this._transport
|
|
28
|
+
.send("v1/conversations/" + encodeURIComponent(id) + "/notes", {
|
|
29
|
+
...request,
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers: {
|
|
32
|
+
...request.headers,
|
|
33
|
+
"Content-Type": "application/json",
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify(CreateConversationNote.SCHEMA.parse(body)),
|
|
36
|
+
})
|
|
37
|
+
.then((response) => new CreateConversationNoteResponse(response));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type CreateConversationNoteResponsePayload = {
|
|
42
|
+
note: {
|
|
43
|
+
id: string;
|
|
44
|
+
content: string;
|
|
45
|
+
createdAt: string;
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export class CreateConversationNoteResponse {
|
|
51
|
+
constructor(public response: Response) {}
|
|
52
|
+
|
|
53
|
+
public async result(): Promise<CreateConversationNoteResponsePayload> {
|
|
54
|
+
return this.response.json();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
import FetchTransport from "../Transport/FetchTransport.js";
|
|
11
|
+
|
|
12
|
+
export interface Options {
|
|
13
|
+
id: string;
|
|
14
|
+
request?: RequestInit;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default class ListContactNotes {
|
|
18
|
+
constructor(protected _transport: FetchTransport) {}
|
|
19
|
+
|
|
20
|
+
public async send({ id, request = {} }: Options) {
|
|
21
|
+
return this._transport
|
|
22
|
+
.send("v1/contacts/" + encodeURIComponent(id) + "/notes", {
|
|
23
|
+
...request,
|
|
24
|
+
method: "GET",
|
|
25
|
+
})
|
|
26
|
+
.then((response) => new ListContactNotesResponse(response));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type ListContactNotesResponsePayload = {
|
|
31
|
+
notes: {
|
|
32
|
+
id: string;
|
|
33
|
+
content: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
updatedAt: string;
|
|
36
|
+
}[];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export class ListContactNotesResponse {
|
|
40
|
+
constructor(public response: Response) {}
|
|
41
|
+
|
|
42
|
+
public async result(): Promise<ListContactNotesResponsePayload> {
|
|
43
|
+
return this.response.json();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
import FetchTransport from "../Transport/FetchTransport.js";
|
|
11
|
+
|
|
12
|
+
export interface Options {
|
|
13
|
+
id: string;
|
|
14
|
+
request?: RequestInit;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default class ListConversationNotes {
|
|
18
|
+
constructor(protected _transport: FetchTransport) {}
|
|
19
|
+
|
|
20
|
+
public async send({ id, request = {} }: Options) {
|
|
21
|
+
return this._transport
|
|
22
|
+
.send("v1/conversations/" + encodeURIComponent(id) + "/notes", {
|
|
23
|
+
...request,
|
|
24
|
+
method: "GET",
|
|
25
|
+
})
|
|
26
|
+
.then((response) => new ListConversationNotesResponse(response));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type ListConversationNotesResponsePayload = {
|
|
31
|
+
notes: {
|
|
32
|
+
id: string;
|
|
33
|
+
content: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
updatedAt: string;
|
|
36
|
+
}[];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export class ListConversationNotesResponse {
|
|
40
|
+
constructor(public response: Response) {}
|
|
41
|
+
|
|
42
|
+
public async result(): Promise<ListConversationNotesResponsePayload> {
|
|
43
|
+
return this.response.json();
|
|
44
|
+
}
|
|
45
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -63,6 +63,10 @@ export { type CreateResponseResponsePayload } from "./Model/Response/CreateRespo
|
|
|
63
63
|
// Notes
|
|
64
64
|
export { type GetNoteResponsePayload } from "./Note/GetNote.js";
|
|
65
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";
|
|
66
70
|
|
|
67
71
|
// Sources
|
|
68
72
|
export { type GetSourceResponsePayload } from "./Source/GetSource.js";
|
package/dist/chunk-WAY6IGDK.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var vt=Object.defineProperty;var Ot=(e,t)=>{for(var s in t)vt(e,s,{get:t[s],enumerable:!0})};var At="https://api.support.greatdetail.com",Tt={"X-Powered-By":"GDSupport/JavaScript"},Ut="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 K(s))}},K=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 k(s))}},k=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 Y(r))}},Y=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 $(r))}},$=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 W(s))}},W=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 X(r))}},X=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z}from"zod";var h=class e{constructor(t){this._transport=t}static SCHEMA=z.object({name:z.string().optional(),emailAddress:z.string().email().optional(),telephoneNumber:z.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 Q(n))}},Q=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 Z(r))}},Z=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 tt(s))}},tt=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 et(r))}},et=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as _t}from"zod";var R=class e{constructor(t){this._transport=t}static SCHEMA=_t.object({hasEnded:_t.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 st(n))}},st=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as B}from"zod";var x=class e{constructor(t){this._transport=t}static SCHEMA=B.object({title:B.string(),description:B.string().optional(),account:B.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 rt(r))}},rt=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 nt(r))}},nt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var T=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 ot(r))}},ot=class{constructor(t){this.response=t}async result(){return this.response.json()}};var _=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"}).then(s=>new it(s))}},it=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as at}from"zod";var C=class e{constructor(t){this._transport=t}static SCHEMA=at.object({title:at.string().optional(),description:at.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 pt(n))}},pt=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 ct(r))}},ct=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 dt(s))}},dt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as V}from"zod";var E=class e{constructor(t){this._transport=t}static SCHEMA=V.object({input:V.string().max(65536),original:V.string().max(65536),correction:V.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 ut(n))}},ut=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 lt(r))}},lt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var w=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"}).then(s=>new mt(s))}},mt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as J}from"zod";var O=class e{constructor(t){this._transport=t}static SCHEMA=J.array(J.object({role:J.enum(["user","assistant"]),content:J.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 gt(n))}},gt=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/notes/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new ht(r))}},ht=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as Ct}from"zod";var U=class e{constructor(t){this._transport=t}static SCHEMA=Ct.object({content:Ct.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 ft(n))}},ft=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/sources/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new bt(r))}},bt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var I=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/sources",{...t,method:"GET"}).then(s=>new yt(s))}},yt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var ge="SUPPORT_ACCESS_TOKEN",he="SUPPORT_API_KEY",fe="SUPPORT_KEY_NAME",Pt="SUPPORT_BASE_URL";var L=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 j=class e{constructor(t=e.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Tt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};import wt from"is-network-error";var o=class extends Error{};var i=class extends o{};var H=class extends i{static unauthenticated(){return new this("An unauthenticated request occurred")}};var N=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 M=class extends o{};var D=class extends o{static badRequest(){return new this("Bad request")}};var G=class{options;constructor({baseURL:t,fetch:s=fetch,...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[St,Et]of Object.entries(n))s.headers.set(St,Et)}return new Request(this.getURL(t),s)}async send(t,s){return await this.options.fetch(this.getRequest(t,s)).then(r=>{if(!r.ok){let n=r.status;switch(console.error(JSON.stringify(r)),n){case 400:throw D.badRequest();case 401:throw H.unauthenticated();case 403:throw N.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,s.method??"GET")}}return r}).catch(r=>{throw wt(r)?new M("A network error occurred",{cause:r}):r})}};var Rt=class e{static DEFAULT_BASE_URL=At;_transport;constructor(t,{baseURL:s,...r}={}){this._transport=new G({requestFilterables:[new j,t],...r,baseURL:s?.toString()??e.getBaseURL()})}static getBaseURL(){return process.env[Pt]??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 L(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)}}}get label(){return{create:new x(this._transport),get:new T(this._transport),list:new _(this._transport),update:new C(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 w(this._transport),response:{create:new O(this._transport)},correction:{create:new E(this._transport)}}}get note(){return{get:new F(this._transport),update:new U(this._transport)}}get source(){return{get:new q(this._transport),list:new I(this._transport)}}};var xt=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};export{Ot as a,At as b,Ut as c,ge as d,he as e,fe as f,o as g,i as h,H as i,N as j,a as k,M as l,D as m,Rt as n,xt as o};
|