@great-detail/support-sdk 0.2.0 → 0.2.2
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-WAY6IGDK.js +1 -0
- package/dist/{chunk-SRYAEALQ.js → chunk-YQ6LXSV4.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-Dj17QRj0.d.cts → index-BwsedLC7.d.cts} +128 -51
- package/dist/{index-Dj17QRj0.d.ts → index-BwsedLC7.d.ts} +128 -51
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +78 -3
- package/dist/index.d.ts +78 -3
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/Client/index.ts +9 -0
- package/src/Contact/ContactVCF/GetContactVCF.ts +10 -8
- package/src/Error/index.ts +9 -0
- package/src/Note/GetNote.ts +45 -0
- package/src/Note/UpdateNote.ts +56 -0
- package/src/index.ts +4 -0
- package/dist/chunk-IXJNWCJL.js +0 -1
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 GetSourceResponsePayload, L as ListActionsResponsePayload, b as ListChannelsResponsePayload, c as ListContactsResponsePayload, n as ListConversationMessagesResponsePayload, g as ListConversationsResponsePayload, d as ListLabelContactsResponsePayload, h as ListLabelConversationsResponsePayload, l as ListLabelsResponsePayload, o as ListMessagesResponsePayload, q as ListModelsResponsePayload,
|
|
1
|
+
import { A as Authentication } from './index-BwsedLC7.js';
|
|
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, v as GetSourceResponsePayload, L as ListActionsResponsePayload, b as ListChannelsResponsePayload, c as ListContactsResponsePayload, n as ListConversationMessagesResponsePayload, g as ListConversationsResponsePayload, d as ListLabelContactsResponsePayload, h as ListLabelConversationsResponsePayload, l as ListLabelsResponsePayload, o as ListMessagesResponsePayload, q as ListModelsResponsePayload, w 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-BwsedLC7.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -49,12 +49,87 @@ declare class NetworkError extends SupportError {
|
|
|
49
49
|
* @see https://greatdetail.com
|
|
50
50
|
*/
|
|
51
51
|
|
|
52
|
+
declare class AuthError extends SupportError {
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Great Detail Support System.
|
|
57
|
+
*
|
|
58
|
+
* @copyright 2024 Great Detail Ltd
|
|
59
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
60
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
61
|
+
* @see https://greatdetail.com
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
declare class AuthenticationError extends AuthError {
|
|
65
|
+
static unauthenticated(): AuthenticationError;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Great Detail Support System.
|
|
70
|
+
*
|
|
71
|
+
* @copyright 2024 Great Detail Ltd
|
|
72
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
73
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
74
|
+
* @see https://greatdetail.com
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
declare class AuthorizationError extends AuthError {
|
|
78
|
+
static forbidden(): AuthorizationError;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Great Detail Support System.
|
|
83
|
+
*
|
|
84
|
+
* @copyright 2024 Great Detail Ltd
|
|
85
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
86
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
87
|
+
* @see https://greatdetail.com
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
declare class ValidationError extends SupportError {
|
|
91
|
+
static badRequest(): ValidationError;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Great Detail Support System.
|
|
96
|
+
*
|
|
97
|
+
* @copyright 2024 Great Detail Ltd
|
|
98
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
99
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
100
|
+
* @see https://greatdetail.com
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
declare class LogicError extends SupportError {
|
|
104
|
+
static notFound(url: string): LogicError;
|
|
105
|
+
static forbiddenMethod(method: string, url: string): LogicError;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Great Detail Support System.
|
|
110
|
+
*
|
|
111
|
+
* @copyright 2024 Great Detail Ltd
|
|
112
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
113
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
114
|
+
* @see https://greatdetail.com
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
type index_AuthError = AuthError;
|
|
118
|
+
declare const index_AuthError: typeof AuthError;
|
|
119
|
+
type index_AuthenticationError = AuthenticationError;
|
|
120
|
+
declare const index_AuthenticationError: typeof AuthenticationError;
|
|
121
|
+
type index_AuthorizationError = AuthorizationError;
|
|
122
|
+
declare const index_AuthorizationError: typeof AuthorizationError;
|
|
123
|
+
type index_LogicError = LogicError;
|
|
124
|
+
declare const index_LogicError: typeof LogicError;
|
|
52
125
|
type index_NetworkError = NetworkError;
|
|
53
126
|
declare const index_NetworkError: typeof NetworkError;
|
|
54
127
|
type index_SupportError = SupportError;
|
|
55
128
|
declare const index_SupportError: typeof SupportError;
|
|
129
|
+
type index_ValidationError = ValidationError;
|
|
130
|
+
declare const index_ValidationError: typeof ValidationError;
|
|
56
131
|
declare namespace index {
|
|
57
|
-
export { index_NetworkError as NetworkError, index_SupportError as SupportError };
|
|
132
|
+
export { index_AuthError as AuthError, index_AuthenticationError as AuthenticationError, index_AuthorizationError as AuthorizationError, index_LogicError as LogicError, index_NetworkError as NetworkError, index_SupportError as SupportError, index_ValidationError as ValidationError };
|
|
58
133
|
}
|
|
59
134
|
|
|
60
135
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a 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 m,j as y,k as d,l as u,m as x,n as c,o as h}from"./chunk-WAY6IGDK.js";var R={};P(R,{AuthError:()=>l,AuthenticationError:()=>m,AuthorizationError:()=>y,LogicError:()=>d,NetworkError:()=>u,SupportError:()=>f,ValidationError:()=>x});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,6 +33,8 @@ 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 GetNote from "../Note/GetNote.js";
|
|
37
|
+
import UpdateNote from "../Note/UpdateNote.js";
|
|
36
38
|
import RequestStandardHeaders from "../Request/RequestStandardHeaders.js";
|
|
37
39
|
import GetSource from "../Source/GetSource.js";
|
|
38
40
|
import ListSources from "../Source/ListSources.js";
|
|
@@ -132,6 +134,13 @@ export default class Client {
|
|
|
132
134
|
};
|
|
133
135
|
}
|
|
134
136
|
|
|
137
|
+
public get note() {
|
|
138
|
+
return {
|
|
139
|
+
get: new GetNote(this._transport),
|
|
140
|
+
update: new UpdateNote(this._transport),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
135
144
|
public get source() {
|
|
136
145
|
return {
|
|
137
146
|
get: new GetSource(this._transport),
|
|
@@ -25,19 +25,21 @@ export interface Options {
|
|
|
25
25
|
export default class GetContactVCFURL {
|
|
26
26
|
constructor(protected _transport: FetchTransport) {}
|
|
27
27
|
|
|
28
|
-
public
|
|
28
|
+
public getRelativeURL({ id, vcf = {} }: Options) {
|
|
29
29
|
const variant = vcf.variant ?? "vcard";
|
|
30
30
|
const format = vcf.format ?? (vcf.variant === "vcard" ? "vcf" : "json");
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
return (
|
|
33
33
|
"v1/contacts/" +
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
encodeURIComponent(id) +
|
|
35
|
+
"/vcf?variant=" +
|
|
36
|
+
encodeURIComponent(variant) +
|
|
37
|
+
"&format=" +
|
|
38
|
+
encodeURIComponent(format)
|
|
39
39
|
);
|
|
40
|
+
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
public getURL(options: Options) {
|
|
43
|
+
return this._transport.getURL(this.getRelativeURL(options));
|
|
42
44
|
}
|
|
43
45
|
}
|
package/src/Error/index.ts
CHANGED
|
@@ -8,4 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export { default as SupportError } from "./SupportError.js";
|
|
11
|
+
|
|
11
12
|
export { default as NetworkError } from "./NetworkError.js";
|
|
13
|
+
|
|
14
|
+
export { default as AuthError } from "./AuthError.js";
|
|
15
|
+
export { default as AuthenticationError } from "./AuthenticationError.js";
|
|
16
|
+
export { default as AuthorizationError } from "./AuthorizationError.js";
|
|
17
|
+
|
|
18
|
+
export { default as ValidationError } from "./ValidationError.js";
|
|
19
|
+
|
|
20
|
+
export { default as LogicError } from "./LogicError.js";
|
|
@@ -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 GetNote {
|
|
18
|
+
constructor(protected _transport: FetchTransport) {}
|
|
19
|
+
|
|
20
|
+
public async send({ id, request = {} }: Options) {
|
|
21
|
+
return this._transport
|
|
22
|
+
.send("v1/notes/" + encodeURIComponent(id), {
|
|
23
|
+
...request,
|
|
24
|
+
method: "GET",
|
|
25
|
+
})
|
|
26
|
+
.then((response) => new GetNoteResponse(response));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type GetNoteResponsePayload = {
|
|
31
|
+
note: {
|
|
32
|
+
id: string;
|
|
33
|
+
content: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
updatedAt: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export class GetNoteResponse {
|
|
40
|
+
constructor(public response: Response) {}
|
|
41
|
+
|
|
42
|
+
public async result(): Promise<GetNoteResponsePayload> {
|
|
43
|
+
return this.response.json();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -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 UpdateNote.SCHEMA>;
|
|
16
|
+
request?: RequestInit;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default class UpdateNote {
|
|
20
|
+
public static SCHEMA = z.object({
|
|
21
|
+
content: z.string().optional(),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
constructor(protected _transport: FetchTransport) {}
|
|
25
|
+
|
|
26
|
+
public async send({ id, body, request = {} }: Options) {
|
|
27
|
+
return this._transport
|
|
28
|
+
.send("v1/notes/" + encodeURIComponent(id), {
|
|
29
|
+
...request,
|
|
30
|
+
method: "PATCH",
|
|
31
|
+
headers: {
|
|
32
|
+
...request.headers,
|
|
33
|
+
"Content-Type": "application/json",
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify(UpdateNote.SCHEMA.parse(body)),
|
|
36
|
+
})
|
|
37
|
+
.then((response) => new UpdateNoteResponse(response));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type UpdateNoteResponsePayload = {
|
|
42
|
+
note: {
|
|
43
|
+
id: string;
|
|
44
|
+
content: string;
|
|
45
|
+
createdAt: string;
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export class UpdateNoteResponse {
|
|
51
|
+
constructor(public response: Response) {}
|
|
52
|
+
|
|
53
|
+
public async result(): Promise<UpdateNoteResponsePayload> {
|
|
54
|
+
return this.response.json();
|
|
55
|
+
}
|
|
56
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -60,6 +60,10 @@ export { type ListModelsResponsePayload } from "./Model/ListModels.js";
|
|
|
60
60
|
export { type CreateCorrectionResponsePayload } from "./Model/Correction/CreateCorrectionModel.js";
|
|
61
61
|
export { type CreateResponseResponsePayload } from "./Model/Response/CreateResponseModel.js";
|
|
62
62
|
|
|
63
|
+
// Notes
|
|
64
|
+
export { type GetNoteResponsePayload } from "./Note/GetNote.js";
|
|
65
|
+
export { type UpdateNoteResponsePayload } from "./Note/UpdateNote.js";
|
|
66
|
+
|
|
63
67
|
// Sources
|
|
64
68
|
export { type GetSourceResponsePayload } from "./Source/GetSource.js";
|
|
65
69
|
export { type ListSourcesResponsePayload } from "./Source/ListSources.js";
|
package/dist/chunk-IXJNWCJL.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var _t=Object.defineProperty;var Pt=(e,t)=>{for(var s in t)_t(e,s,{get:t[s],enumerable:!0})};var yt="https://api.support.greatdetail.com",Rt={"X-Powered-By":"GDSupport/JavaScript"},Et="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 V(s))}},V=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 J(s))}},J=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as u}from"zod";var d=class e{constructor(t){this._transport=t}static SCHEMA=u.object({name:u.string(),account:u.string(),emailAddress:u.string().email().optional(),telephoneNumber:u.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 K(r))}},K=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 k(r))}},k=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 Y(s))}},Y=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 $(r))}},$=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as D}from"zod";var h=class e{constructor(t){this._transport=t}static SCHEMA=D.object({name:D.string().optional(),emailAddress:D.string().email().optional(),telephoneNumber:D.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 W(n))}},W=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 X(r))}},X=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 Q(s))}},Q=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 Z(r))}},Z=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as xt}from"zod";var R=class e{constructor(t){this._transport=t}static SCHEMA=xt.object({hasEnded:xt.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 tt(n))}},tt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as G}from"zod";var x=class e{constructor(t){this._transport=t}static SCHEMA=G.object({title:G.string(),description:G.string().optional(),account:G.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 et(r))}},et=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 st(r))}},st=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 rt(r))}},rt=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 nt(s))}},nt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as ot}from"zod";var C=class e{constructor(t){this._transport=t}static SCHEMA=ot.object({title:ot.string().optional(),description:ot.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 it(n))}},it=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 at(r))}},at=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 pt(s))}},pt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z}from"zod";var E=class e{constructor(t){this._transport=t}static SCHEMA=z.object({input:z.string().max(65536),original:z.string().max(65536),correction:z.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 ct(n))}},ct=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 ut(r))}},ut=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 dt(s))}},dt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as B}from"zod";var O=class e{constructor(t){this._transport=t}static SCHEMA=B.array(B.object({role:B.enum(["user","assistant"]),content:B.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 lt(n))}},lt=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/sources/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new mt(r))}},mt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var U=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/sources",{...t,method:"GET"}).then(s=>new gt(s))}},gt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var ie="SUPPORT_ACCESS_TOKEN",ae="SUPPORT_API_KEY",pe="SUPPORT_KEY_NAME",At="SUPPORT_BASE_URL";var q=class{constructor(t){this._transport=t}getURL({id:t,vcf:s={}}){let r=s.variant??"vcard",n=s.format??(s.variant==="vcard"?"vcf":"json");return this._transport.getURL("v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(r)+"&format="+encodeURIComponent(n))}};var I=class e{constructor(t=e.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Rt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};import Ct from"is-network-error";var o=class extends Error{};var i=class extends o{};var L=class extends i{static unauthenticated(){return new this("An unauthenticated request occurred")}};var j=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 H=class extends o{};var N=class extends o{static badRequest(){return new this("Bad request")}};var M=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[bt,Tt]of Object.entries(n))s.headers.set(bt,Tt)}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 N.badRequest();case 401:throw L.unauthenticated();case 403:throw j.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,s.method??"GET")}}return r}).catch(r=>{throw Ct(r)?new H("A network error occurred",{cause:r}):r})}};var ht=class e{static DEFAULT_BASE_URL=yt;_transport;constructor(t,{baseURL:s,...r}={}){this._transport=new M({requestFilterables:[new I,t],...r,baseURL:s?.toString()??e.getBaseURL()})}static getBaseURL(){return process.env[At]??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 d(this._transport),vcf:{get:new q(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 source(){return{get:new F(this._transport),list:new U(this._transport)}}};var ft=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};export{Pt as a,yt as b,Et as c,ie as d,ae as e,pe as f,o as g,H as h,ht as i,ft as j};
|