@great-detail/support-sdk 0.0.3 → 0.0.5
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/README.md +17 -0
- package/dist/chunk-BFO7RVLV.js +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +209 -25
- package/dist/index.d.ts +209 -25
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/Client/index.ts +10 -0
- package/src/Contact/GetContact.ts +51 -0
- package/src/Label/CreateLabel.ts +62 -0
- package/src/Label/GetLabel.ts +50 -0
- package/src/Model/GetModel.ts +50 -0
- package/src/Source/GetSource.ts +50 -0
- package/src/cli/contacts.ts +14 -0
- package/src/cli/labels.ts +14 -0
- package/src/cli/models.ts +14 -0
- package/src/cli/sources.ts +14 -0
- package/src/index.ts +1 -0
- package/dist/chunk-LS7DRWDS.js +0 -1
|
@@ -0,0 +1,50 @@
|
|
|
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 Client, { SendOptions } from "../Client/index.js";
|
|
11
|
+
|
|
12
|
+
export interface Options extends SendOptions {
|
|
13
|
+
id: string;
|
|
14
|
+
request?: RequestInit;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default class GetSourceRequest {
|
|
18
|
+
constructor(protected _client: Client) {}
|
|
19
|
+
|
|
20
|
+
public async send({ id, request = {}, ...options }: Options) {
|
|
21
|
+
return this._client
|
|
22
|
+
.send(
|
|
23
|
+
"/v1/sources/" + encodeURIComponent(id),
|
|
24
|
+
{
|
|
25
|
+
...request,
|
|
26
|
+
method: "GET",
|
|
27
|
+
},
|
|
28
|
+
options,
|
|
29
|
+
)
|
|
30
|
+
.then((response) => new GetSourceResponse(response));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type GetSourceResponsePayload = {
|
|
35
|
+
source: {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
category: string;
|
|
39
|
+
url: string;
|
|
40
|
+
disambiguatingDescription: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export class GetSourceResponse {
|
|
45
|
+
constructor(public response: Response) {}
|
|
46
|
+
|
|
47
|
+
public async result(): Promise<GetSourceResponsePayload> {
|
|
48
|
+
return this.response.json();
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/cli/contacts.ts
CHANGED
|
@@ -16,6 +16,20 @@ export interface Options extends CommandOptions {}
|
|
|
16
16
|
export default function contacts({ client, ora }: Options) {
|
|
17
17
|
const command = new Command("contacts").description("Contacts");
|
|
18
18
|
|
|
19
|
+
command.addCommand(
|
|
20
|
+
new Command("get")
|
|
21
|
+
.description("Find contact")
|
|
22
|
+
.argument("<contact>", "Contact ID")
|
|
23
|
+
.action(async (id) => {
|
|
24
|
+
const result = await oraPromise(() => client.contact.get.send({ id }), {
|
|
25
|
+
...ora,
|
|
26
|
+
text: "Finding contact",
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
console.log(await result.result());
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
32
|
+
|
|
19
33
|
command.addCommand(
|
|
20
34
|
new Command("list").description("List contacts").action(async () => {
|
|
21
35
|
const result = await oraPromise(() => client.contact.list.send(), {
|
package/src/cli/labels.ts
CHANGED
|
@@ -16,6 +16,20 @@ export interface Options extends CommandOptions {}
|
|
|
16
16
|
export default function labels({ client, ora }: Options) {
|
|
17
17
|
const command = new Command("labels").description("Labels");
|
|
18
18
|
|
|
19
|
+
command.addCommand(
|
|
20
|
+
new Command("get")
|
|
21
|
+
.description("Find label")
|
|
22
|
+
.argument("<label>", "Label ID")
|
|
23
|
+
.action(async (id) => {
|
|
24
|
+
const result = await oraPromise(() => client.label.get.send({ id }), {
|
|
25
|
+
...ora,
|
|
26
|
+
text: "Finding label",
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
console.log(await result.result());
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
32
|
+
|
|
19
33
|
command.addCommand(
|
|
20
34
|
new Command("list").description("List labels").action(async () => {
|
|
21
35
|
const result = await oraPromise(() => client.label.list.send(), {
|
package/src/cli/models.ts
CHANGED
|
@@ -16,6 +16,20 @@ export interface Options extends CommandOptions {}
|
|
|
16
16
|
export default function models({ client, ora }: Options) {
|
|
17
17
|
const command = new Command("models").description("Models");
|
|
18
18
|
|
|
19
|
+
command.addCommand(
|
|
20
|
+
new Command("get")
|
|
21
|
+
.description("Find model")
|
|
22
|
+
.argument("<model>", "Model ID")
|
|
23
|
+
.action(async (id) => {
|
|
24
|
+
const result = await oraPromise(() => client.model.get.send({ id }), {
|
|
25
|
+
...ora,
|
|
26
|
+
text: "Finding model",
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
console.log(await result.result());
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
32
|
+
|
|
19
33
|
command.addCommand(
|
|
20
34
|
new Command("list").description("List models").action(async () => {
|
|
21
35
|
const result = await oraPromise(() => client.model.list.send(), {
|
package/src/cli/sources.ts
CHANGED
|
@@ -16,6 +16,20 @@ export interface Options extends CommandOptions {}
|
|
|
16
16
|
export default function sources({ client, ora }: Options) {
|
|
17
17
|
const command = new Command("sources").description("Sources");
|
|
18
18
|
|
|
19
|
+
command.addCommand(
|
|
20
|
+
new Command("get")
|
|
21
|
+
.description("Find source")
|
|
22
|
+
.argument("<source>", "Source ID")
|
|
23
|
+
.action(async (id) => {
|
|
24
|
+
const result = await oraPromise(() => client.source.get.send({ id }), {
|
|
25
|
+
...ora,
|
|
26
|
+
text: "Finding source",
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
console.log(await result.result());
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
32
|
+
|
|
19
33
|
command.addCommand(
|
|
20
34
|
new Command("list").description("List sources").action(async () => {
|
|
21
35
|
const result = await oraPromise(() => client.source.list.send(), {
|
package/src/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ export { type ListChannelsResponsePayload } from "./Channel/ListChannels.js";
|
|
|
18
18
|
export { type ListContactsResponsePayload } from "./Contact/ListContacts.js";
|
|
19
19
|
export { type ListConversationsResponsePayload } from "./Conversation/ListConversations.js";
|
|
20
20
|
export { type GetConversationResponsePayload } from "./Conversation/GetConversation.js";
|
|
21
|
+
export { type CreateLabelResponsePayload } from "./Label/CreateLabel.js";
|
|
21
22
|
export { type ListLabelsResponsePayload } from "./Label/ListLabels.js";
|
|
22
23
|
export { type ListMessagesResponsePayload } from "./Message/ListMessages.js";
|
|
23
24
|
export { type ListModelsResponsePayload } from "./Model/ListModels.js";
|
package/dist/chunk-LS7DRWDS.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var U="https://api.support.greatdetail.com",v={"X-Powered-By":"GDSupport/JavaScript"},D="api-key";var x=class{async filter(e){return e}};var o=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/actions",{...e,method:"GET"},s).then(n=>new O(n))}},O=class{constructor(e){this.response=e}async result(){return this.response.json()}};var i=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/channels",{...e,method:"GET"},s).then(n=>new S(n))}},S=class{constructor(e){this.response=e}async result(){return this.response.json()}};var p=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/contacts",{...e,method:"GET"},s).then(n=>new A(n))}},A=class{constructor(e){this.response=e}async result(){return this.response.json()}};var c=class{constructor(e){this._client=e}async send({id:e,request:s={},...n}){return this._client.send("/v1/conversations/"+encodeURIComponent(e),{...s,method:"GET"},n).then(r=>new C(r))}},C=class{constructor(e){this.response=e}async result(){return this.response.json()}};var a=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/conversations",{...e,method:"GET"},s).then(n=>new _(n))}},_=class{constructor(e){this.response=e}async result(){return this.response.json()}};var l=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/labels",{...e,method:"GET"},s).then(n=>new P(n))}},P=class{constructor(e){this.response=e}async result(){return this.response.json()}};var u=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/messages",{...e,method:"GET"},s).then(n=>new E(n))}},E=class{constructor(e){this.response=e}async result(){return this.response.json()}};import{z as g}from"zod";var d=class t{constructor(e){this._client=e}static SCHEMA=g.object({input:g.string().max(65536),original:g.string().max(65536),correction:g.string().max(65536)});async send({id:e,body:s,request:n={},...r}){return this._client.send("/v1/models/"+encodeURIComponent(e)+"/correction",{...n,method:"POST",headers:{...n.headers,"Content-Type":"application/json"},body:JSON.stringify(t.SCHEMA.parse(s))},r).then(y=>new q(y))}},q=class{constructor(e){this.response=e}async result(){return this.response.json()}};var m=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/models",{...e,method:"GET"},s).then(n=>new w(n))}},w=class{constructor(e){this.response=e}async result(){return this.response.json()}};import{z as R}from"zod";var h=class t{constructor(e){this._client=e}static SCHEMA=R.array(R.object({role:R.enum(["user","assistant"]),content:R.string().max(65536).nullable()})).min(1);async send({id:e,body:s,request:n={},...r}){return this._client.send("/v1/models/"+encodeURIComponent(e)+"/response",{...n,method:"POST",headers:{...n.headers,"Content-Type":"application/json"},body:JSON.stringify(t.SCHEMA.parse(s))},r).then(y=>new T(y))}},T=class{constructor(e){this.response=e}async result(){return this.response.json()}};var f=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/sources",{...e,method:"GET"},s).then(n=>new L(n))}},L=class{constructor(e){this.response=e}async result(){return this.response.json()}};var b=class t{constructor(e=t.STANDARD_HEADERS){this._standardHeaders=e}static STANDARD_HEADERS=v;async filter(e){return{...e,headers:{...e.headers,...this._standardHeaders}}}};var I=class t{static DEFAULT_BASE_URL=U;options;constructor(e,s={}){this.options={requestFilterables:[new b,e],baseURL:process.env.SUPPORT_BASE_URL??t.DEFAULT_BASE_URL,...s}}action={list:new o(this)};channel={list:new i(this)};contact={list:new p(this)};conversation={get:new c(this),list:new a(this)};label={list:new l(this)};message={list:new u(this)};model={list:new m(this),response:{create:new h(this)},correction:{create:new d(this)}};source={list:new f(this)};async _filterRequest(e){for(let s of this.options.requestFilterables)e=await s.filter(e);return e}async send(e,s,{fetch:n=fetch}={}){return await n(new Request(new URL(e,this.options.baseURL),await this._filterRequest(s)))}};export{U as a,D as b,x as c,I as d};
|