@great-detail/support-sdk 0.0.2 → 0.0.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/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # Great Detail Support System SDK - JS
2
+
3
+ ## Getting Started
4
+
5
+ ```bash
6
+ npm install @great-detail/support-sdk
7
+ ```
8
+
9
+ ## License
10
+
11
+ Proprietary © 2024 Great Detail Ltd
12
+
13
+ ### Contact
14
+
15
+ **Great Detail Ltd**: <<info@greatdetail.com>>
16
+
17
+ **Dom Webber**: <https://domwebber.dev> <<dom.webber@greatdetail.com>>
@@ -0,0 +1 @@
1
+ var j="https://api.support.greatdetail.com",H={"X-Powered-By":"GDSupport/JavaScript"},F="api-key";var O=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 C(n))}},C=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 A(n))}},A=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 P(n))}},P=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 _(r))}},_=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 E(n))}},E=class{constructor(e){this.response=e}async result(){return this.response.json()}};import{z as l}from"zod";var d=class t{constructor(e){this._client=e}static SCHEMA=l.object({title:l.string(),description:l.optional(l.string()),account:l.string()});async send({body:e,request:s={},...n}){return this._client.send("/v1/labels",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(t.SCHEMA.parse(e))},n).then(r=>new q(r))}},q=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/labels",{...e,method:"GET"},s).then(n=>new w(n))}},w=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/messages",{...e,method:"GET"},s).then(n=>new T(n))}},T=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.object({input:R.string().max(65536),original:R.string().max(65536),correction:R.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(S=>new L(S))}},L=class{constructor(e){this.response=e}async result(){return this.response.json()}};var b=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/models",{...e,method:"GET"},s).then(n=>new I(n))}},I=class{constructor(e){this.response=e}async result(){return this.response.json()}};import{z as x}from"zod";var f=class t{constructor(e){this._client=e}static SCHEMA=x.array(x.object({role:x.enum(["user","assistant"]),content:x.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(S=>new v(S))}},v=class{constructor(e){this.response=e}async result(){return this.response.json()}};var g=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/sources",{...e,method:"GET"},s).then(n=>new U(n))}},U=class{constructor(e){this.response=e}async result(){return this.response.json()}};var y=class t{constructor(e=t.STANDARD_HEADERS){this._standardHeaders=e}static STANDARD_HEADERS=H;async filter(e){return{...e,headers:{...e.headers,...this._standardHeaders}}}};var D=class t{static DEFAULT_BASE_URL=j;options;constructor(e,s={}){this.options={requestFilterables:[new y,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={create:new d(this),list:new u(this)};message={list:new m(this)};model={list:new b(this),response:{create:new f(this)},correction:{create:new h(this)}};source={list:new g(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{j as a,F as b,O as c,D as d};
package/dist/cli.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var rt=require("commander");var r=class{async filter(t){return t}};var p=class{constructor(t){this._client=t}async send({request:t={},...e}={}){return this._client.send("/v1/actions",{...t,method:"GET"},e).then(s=>new S(s))}},S=class{constructor(t){this.response=t}async result(){return this.response.json()}};var a=class{constructor(t){this._client=t}async send({request:t={},...e}={}){return this._client.send("/v1/channels",{...t,method:"GET"},e).then(s=>new A(s))}},A=class{constructor(t){this.response=t}async result(){return this.response.json()}};var W="https://api.support.greatdetail.com",Z={"X-Powered-By":"GDSupport/JavaScript"};var c=class{constructor(t){this._client=t}async send({request:t={},...e}={}){return this._client.send("/v1/contacts",{...t,method:"GET"},e).then(s=>new _(s))}},_=class{constructor(t){this.response=t}async result(){return this.response.json()}};var d=class{constructor(t){this._client=t}async send({id:t,request:e={},...s}){return this._client.send("/v1/conversations/"+encodeURIComponent(t),{...e,method:"GET"},s).then(i=>new E(i))}},E=class{constructor(t){this.response=t}async result(){return this.response.json()}};var m=class{constructor(t){this._client=t}async send({request:t={},...e}={}){return this._client.send("/v1/conversations",{...t,method:"GET"},e).then(s=>new L(s))}},L=class{constructor(t){this.response=t}async result(){return this.response.json()}};var l=class{constructor(t){this._client=t}async send({request:t={},...e}={}){return this._client.send("/v1/labels",{...t,method:"GET"},e).then(s=>new q(s))}},q=class{constructor(t){this.response=t}async result(){return this.response.json()}};var u=class{constructor(t){this._client=t}async send({request:t={},...e}={}){return this._client.send("/v1/messages",{...t,method:"GET"},e).then(s=>new v(s))}},v=class{constructor(t){this.response=t}async result(){return this.response.json()}};var f=require("zod"),x=class n{constructor(t){this._client=t}static SCHEMA=f.z.object({input:f.z.string().max(65536),original:f.z.string().max(65536),correction:f.z.string().max(65536)});async send({id:t,body:e,request:s={},...i}){return this._client.send("/v1/models/"+encodeURIComponent(t)+"/correction",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(n.SCHEMA.parse(e))},i).then(y=>new P(y))}},P=class{constructor(t){this.response=t}async result(){return this.response.json()}};var g=class{constructor(t){this._client=t}async send({request:t={},...e}={}){return this._client.send("/v1/models",{...t,method:"GET"},e).then(s=>new T(s))}},T=class{constructor(t){this.response=t}async result(){return this.response.json()}};var O=require("zod"),h=class n{constructor(t){this._client=t}static SCHEMA=O.z.array(O.z.object({role:O.z.enum(["user","assistant"]),content:O.z.string().max(65536).nullable()})).min(1);async send({id:t,body:e,request:s={},...i}){return this._client.send("/v1/models/"+encodeURIComponent(t)+"/response",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(n.SCHEMA.parse(e))},i).then(y=>new I(y))}},I=class{constructor(t){this.response=t}async result(){return this.response.json()}};var b=class n{constructor(t=n.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Z;async filter(t){return{...t,headers:{...t.headers,...this._standardHeaders}}}};var C=class{constructor(t){this._client=t}async send({request:t={},...e}={}){return this._client.send("/v1/sources",{...t,method:"GET"},e).then(s=>new j(s))}},j=class{constructor(t){this.response=t}async result(){return this.response.json()}};var R=class n{static DEFAULT_BASE_URL=W;options;constructor(t,e={}){this.options={requestFilterables:[new b,t],baseURL:process.env.SUPPORT_BASE_URL??n.DEFAULT_BASE_URL,...e}}action={list:new p(this)};channel={list:new a(this)};contact={list:new c(this)};conversation={get:new d(this),list:new m(this)};label={list:new l(this)};message={list:new u(this)};model={list:new g(this),response:{create:new h(this)},correction:{create:new x(this)}};source={list:new C(this)};async _filterRequest(t){for(let e of this.options.requestFilterables)t=await e.filter(t);return t}async send(t,e,{fetch:s=fetch}={}){return await s(new Request(new URL(t,this.options.baseURL),await this._filterRequest(e)))}};var D=require("commander"),$=require("ora");function U({client:n,ora:t}){let e=new D.Command("actions").description("Actions");return e.addCommand(new D.Command("list").description("List actions").action(async()=>{let s=await(0,$.oraPromise)(()=>n.action.list.send(),{...t,text:"Finding actions"});console.log(await s.result())})),e}var F=require("commander"),tt=require("ora");function H({client:n,ora:t}){let e=new F.Command("channels").description("Channels");return e.addCommand(new F.Command("list").description("List channels").action(async()=>{let s=await(0,tt.oraPromise)(()=>n.channel.list.send(),{...t,text:"Finding channels"});console.log(await s.result())})),e}var G=require("commander"),et=require("ora");function N({client:n,ora:t}){let e=new G.Command("contacts").description("Contacts");return e.addCommand(new G.Command("list").description("List contacts").action(async()=>{let s=await(0,et.oraPromise)(()=>n.contact.list.send(),{...t,text:"Finding contacts"});console.log(await s.result())})),e}var w=require("commander"),M=require("ora");function B({client:n,ora:t}){let e=new w.Command("conversations").description("Conversations");return e.addCommand(new w.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async s=>{let i=await(0,M.oraPromise)(()=>n.conversation.get.send({id:s}),{...t,text:"Finding conversation"});console.log(await i.result())})),e.addCommand(new w.Command("list").description("List conversations").action(async()=>{let s=await(0,M.oraPromise)(()=>n.conversation.list.send(),{...t,text:"Finding conversations"});console.log(await s.result())})),e}var k=require("commander"),nt=require("ora");function z({client:n,ora:t}){let e=new k.Command("labels").description("Labels");return e.addCommand(new k.Command("list").description("List labels").action(async()=>{let s=await(0,nt.oraPromise)(()=>n.label.list.send(),{...t,text:"Finding labels"});console.log(await s.result())})),e}var J=require("commander"),st=require("ora");function K({client:n,ora:t}){let e=new J.Command("messages").description("Messages");return e.addCommand(new J.Command("list").description("List messages").action(async()=>{let s=await(0,st.oraPromise)(()=>n.message.list.send(),{...t,text:"Finding messages"});console.log(await s.result())})),e}var X=require("commander"),ot=require("ora");function Y({client:n,ora:t}){let e=new X.Command("models").description("Models");return e.addCommand(new X.Command("list").description("List models").action(async()=>{let s=await(0,ot.oraPromise)(()=>n.model.list.send(),{...t,text:"Finding models"});console.log(await s.result())})),e}var Q=require("commander"),it=require("ora");function V({client:n,ora:t}){let e=new Q.Command("sources").description("Sources");return e.addCommand(new Q.Command("list").description("List sources").action(async()=>{let s=await(0,it.oraPromise)(()=>n.source.list.send(),{...t,text:"Finding sources"});console.log(await s.result())})),e}var o={ora:{spinner:"simpleDotsScrolling"},client:new R(new r)},at=new rt.Command("gds").description("Great Detail Support System").addCommand(U(o)).addCommand(H(o)).addCommand(N(o)).addCommand(B(o)).addCommand(z(o)).addCommand(K(o)).addCommand(Y(o)).addCommand(V(o)),pt=at;pt.parseAsync(process.argv);
2
+ "use strict";var ct=require("commander");var a=class{async filter(t){return t}};var p=class{constructor(t){this._client=t}async send({request:t={},...e}={}){return this._client.send("/v1/actions",{...t,method:"GET"},e).then(s=>new P(s))}},P=class{constructor(t){this.response=t}async result(){return this.response.json()}};var c=class{constructor(t){this._client=t}async send({request:t={},...e}={}){return this._client.send("/v1/channels",{...t,method:"GET"},e).then(s=>new _(s))}},_=class{constructor(t){this.response=t}async result(){return this.response.json()}};var tt="https://api.support.greatdetail.com",et={"X-Powered-By":"GDSupport/JavaScript"};var d=class{constructor(t){this._client=t}async send({request:t={},...e}={}){return this._client.send("/v1/contacts",{...t,method:"GET"},e).then(s=>new E(s))}},E=class{constructor(t){this.response=t}async result(){return this.response.json()}};var l=class{constructor(t){this._client=t}async send({id:t,request:e={},...s}){return this._client.send("/v1/conversations/"+encodeURIComponent(t),{...e,method:"GET"},s).then(o=>new v(o))}},v=class{constructor(t){this.response=t}async result(){return this.response.json()}};var m=class{constructor(t){this._client=t}async send({request:t={},...e}={}){return this._client.send("/v1/conversations",{...t,method:"GET"},e).then(s=>new q(s))}},q=class{constructor(t){this.response=t}async result(){return this.response.json()}};var r=require("zod"),u=class n{constructor(t){this._client=t}static SCHEMA=r.z.object({title:r.z.string(),description:r.z.optional(r.z.string()),account:r.z.string()});async send({body:t,request:e={},...s}){return this._client.send("/v1/labels",{...e,method:"POST",headers:{...e.headers,"Content-Type":"application/json"},body:JSON.stringify(n.SCHEMA.parse(t))},s).then(o=>new L(o))}},L=class{constructor(t){this.response=t}async result(){return this.response.json()}};var f=class{constructor(t){this._client=t}async send({request:t={},...e}={}){return this._client.send("/v1/labels",{...t,method:"GET"},e).then(s=>new T(s))}},T=class{constructor(t){this.response=t}async result(){return this.response.json()}};var g=class{constructor(t){this._client=t}async send({request:t={},...e}={}){return this._client.send("/v1/messages",{...t,method:"GET"},e).then(s=>new j(s))}},j=class{constructor(t){this.response=t}async result(){return this.response.json()}};var x=require("zod"),O=class n{constructor(t){this._client=t}static SCHEMA=x.z.object({input:x.z.string().max(65536),original:x.z.string().max(65536),correction:x.z.string().max(65536)});async send({id:t,body:e,request:s={},...o}){return this._client.send("/v1/models/"+encodeURIComponent(t)+"/correction",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(n.SCHEMA.parse(e))},o).then(A=>new I(A))}},I=class{constructor(t){this.response=t}async result(){return this.response.json()}};var C=class{constructor(t){this._client=t}async send({request:t={},...e}={}){return this._client.send("/v1/models",{...t,method:"GET"},e).then(s=>new D(s))}},D=class{constructor(t){this.response=t}async result(){return this.response.json()}};var y=require("zod"),h=class n{constructor(t){this._client=t}static SCHEMA=y.z.array(y.z.object({role:y.z.enum(["user","assistant"]),content:y.z.string().max(65536).nullable()})).min(1);async send({id:t,body:e,request:s={},...o}){return this._client.send("/v1/models/"+encodeURIComponent(t)+"/response",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(n.SCHEMA.parse(e))},o).then(A=>new U(A))}},U=class{constructor(t){this.response=t}async result(){return this.response.json()}};var b=class n{constructor(t=n.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=et;async filter(t){return{...t,headers:{...t.headers,...this._standardHeaders}}}};var R=class{constructor(t){this._client=t}async send({request:t={},...e}={}){return this._client.send("/v1/sources",{...t,method:"GET"},e).then(s=>new F(s))}},F=class{constructor(t){this.response=t}async result(){return this.response.json()}};var w=class n{static DEFAULT_BASE_URL=tt;options;constructor(t,e={}){this.options={requestFilterables:[new b,t],baseURL:process.env.SUPPORT_BASE_URL??n.DEFAULT_BASE_URL,...e}}action={list:new p(this)};channel={list:new c(this)};contact={list:new d(this)};conversation={get:new l(this),list:new m(this)};label={create:new u(this),list:new f(this)};message={list:new g(this)};model={list:new C(this),response:{create:new h(this)},correction:{create:new O(this)}};source={list:new R(this)};async _filterRequest(t){for(let e of this.options.requestFilterables)t=await e.filter(t);return t}async send(t,e,{fetch:s=fetch}={}){return await s(new Request(new URL(t,this.options.baseURL),await this._filterRequest(e)))}};var H=require("commander"),nt=require("ora");function M({client:n,ora:t}){let e=new H.Command("actions").description("Actions");return e.addCommand(new H.Command("list").description("List actions").action(async()=>{let s=await(0,nt.oraPromise)(()=>n.action.list.send(),{...t,text:"Finding actions"});console.log(await s.result())})),e}var G=require("commander"),st=require("ora");function N({client:n,ora:t}){let e=new G.Command("channels").description("Channels");return e.addCommand(new G.Command("list").description("List channels").action(async()=>{let s=await(0,st.oraPromise)(()=>n.channel.list.send(),{...t,text:"Finding channels"});console.log(await s.result())})),e}var z=require("commander"),ot=require("ora");function B({client:n,ora:t}){let e=new z.Command("contacts").description("Contacts");return e.addCommand(new z.Command("list").description("List contacts").action(async()=>{let s=await(0,ot.oraPromise)(()=>n.contact.list.send(),{...t,text:"Finding contacts"});console.log(await s.result())})),e}var S=require("commander"),k=require("ora");function J({client:n,ora:t}){let e=new S.Command("conversations").description("Conversations");return e.addCommand(new S.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async s=>{let o=await(0,k.oraPromise)(()=>n.conversation.get.send({id:s}),{...t,text:"Finding conversation"});console.log(await o.result())})),e.addCommand(new S.Command("list").description("List conversations").action(async()=>{let s=await(0,k.oraPromise)(()=>n.conversation.list.send(),{...t,text:"Finding conversations"});console.log(await s.result())})),e}var K=require("commander"),it=require("ora");function X({client:n,ora:t}){let e=new K.Command("labels").description("Labels");return e.addCommand(new K.Command("list").description("List labels").action(async()=>{let s=await(0,it.oraPromise)(()=>n.label.list.send(),{...t,text:"Finding labels"});console.log(await s.result())})),e}var Y=require("commander"),rt=require("ora");function Q({client:n,ora:t}){let e=new Y.Command("messages").description("Messages");return e.addCommand(new Y.Command("list").description("List messages").action(async()=>{let s=await(0,rt.oraPromise)(()=>n.message.list.send(),{...t,text:"Finding messages"});console.log(await s.result())})),e}var V=require("commander"),at=require("ora");function W({client:n,ora:t}){let e=new V.Command("models").description("Models");return e.addCommand(new V.Command("list").description("List models").action(async()=>{let s=await(0,at.oraPromise)(()=>n.model.list.send(),{...t,text:"Finding models"});console.log(await s.result())})),e}var Z=require("commander"),pt=require("ora");function $({client:n,ora:t}){let e=new Z.Command("sources").description("Sources");return e.addCommand(new Z.Command("list").description("List sources").action(async()=>{let s=await(0,pt.oraPromise)(()=>n.source.list.send(),{...t,text:"Finding sources"});console.log(await s.result())})),e}var i={ora:{spinner:"simpleDotsScrolling"},client:new w(new a)},lt=new ct.Command("gds").description("Great Detail Support System").addCommand(M(i)).addCommand(N(i)).addCommand(B(i)).addCommand(J(i)).addCommand(X(i)).addCommand(Q(i)).addCommand(W(i)).addCommand($(i)),dt=lt;dt.parseAsync(process.argv);
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{c as u,d as C}from"./chunk-ZLBEVMCE.js";import{Command as I}from"commander";import{Command as O}from"commander";import{oraPromise as h}from"ora";function e({client:n,ora:s}){let o=new O("actions").description("Actions");return o.addCommand(new O("list").description("List actions").action(async()=>{let t=await h(()=>n.action.list.send(),{...s,text:"Finding actions"});console.log(await t.result())})),o}import{Command as x}from"commander";import{oraPromise as j}from"ora";function a({client:n,ora:s}){let o=new x("channels").description("Channels");return o.addCommand(new x("list").description("List channels").action(async()=>{let t=await j(()=>n.channel.list.send(),{...s,text:"Finding channels"});console.log(await t.result())})),o}import{Command as w}from"commander";import{oraPromise as S}from"ora";function r({client:n,ora:s}){let o=new w("contacts").description("Contacts");return o.addCommand(new w("list").description("List contacts").action(async()=>{let t=await S(()=>n.contact.list.send(),{...s,text:"Finding contacts"});console.log(await t.result())})),o}import{Command as m}from"commander";import{oraPromise as g}from"ora";function d({client:n,ora:s}){let o=new m("conversations").description("Conversations");return o.addCommand(new m("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async t=>{let P=await g(()=>n.conversation.get.send({id:t}),{...s,text:"Finding conversation"});console.log(await P.result())})),o.addCommand(new m("list").description("List conversations").action(async()=>{let t=await g(()=>n.conversation.list.send(),{...s,text:"Finding conversations"});console.log(await t.result())})),o}import{Command as y}from"commander";import{oraPromise as A}from"ora";function c({client:n,ora:s}){let o=new y("labels").description("Labels");return o.addCommand(new y("list").description("List labels").action(async()=>{let t=await A(()=>n.label.list.send(),{...s,text:"Finding labels"});console.log(await t.result())})),o}import{Command as v}from"commander";import{oraPromise as D}from"ora";function p({client:n,ora:s}){let o=new v("messages").description("Messages");return o.addCommand(new v("list").description("List messages").action(async()=>{let t=await D(()=>n.message.list.send(),{...s,text:"Finding messages"});console.log(await t.result())})),o}import{Command as F}from"commander";import{oraPromise as M}from"ora";function l({client:n,ora:s}){let o=new F("models").description("Models");return o.addCommand(new F("list").description("List models").action(async()=>{let t=await M(()=>n.model.list.send(),{...s,text:"Finding models"});console.log(await t.result())})),o}import{Command as b}from"commander";import{oraPromise as G}from"ora";function f({client:n,ora:s}){let o=new b("sources").description("Sources");return o.addCommand(new b("list").description("List sources").action(async()=>{let t=await G(()=>n.source.list.send(),{...s,text:"Finding sources"});console.log(await t.result())})),o}var i={ora:{spinner:"simpleDotsScrolling"},client:new C(new u)},k=new I("gds").description("Great Detail Support System").addCommand(e(i)).addCommand(a(i)).addCommand(r(i)).addCommand(d(i)).addCommand(c(i)).addCommand(p(i)).addCommand(l(i)).addCommand(f(i)),L=k;L.parseAsync(process.argv);
2
+ import{c as u,d as C}from"./chunk-WCSPJBPY.js";import{Command as I}from"commander";import{Command as O}from"commander";import{oraPromise as h}from"ora";function e({client:n,ora:s}){let o=new O("actions").description("Actions");return o.addCommand(new O("list").description("List actions").action(async()=>{let t=await h(()=>n.action.list.send(),{...s,text:"Finding actions"});console.log(await t.result())})),o}import{Command as x}from"commander";import{oraPromise as j}from"ora";function a({client:n,ora:s}){let o=new x("channels").description("Channels");return o.addCommand(new x("list").description("List channels").action(async()=>{let t=await j(()=>n.channel.list.send(),{...s,text:"Finding channels"});console.log(await t.result())})),o}import{Command as w}from"commander";import{oraPromise as S}from"ora";function r({client:n,ora:s}){let o=new w("contacts").description("Contacts");return o.addCommand(new w("list").description("List contacts").action(async()=>{let t=await S(()=>n.contact.list.send(),{...s,text:"Finding contacts"});console.log(await t.result())})),o}import{Command as m}from"commander";import{oraPromise as g}from"ora";function d({client:n,ora:s}){let o=new m("conversations").description("Conversations");return o.addCommand(new m("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async t=>{let P=await g(()=>n.conversation.get.send({id:t}),{...s,text:"Finding conversation"});console.log(await P.result())})),o.addCommand(new m("list").description("List conversations").action(async()=>{let t=await g(()=>n.conversation.list.send(),{...s,text:"Finding conversations"});console.log(await t.result())})),o}import{Command as y}from"commander";import{oraPromise as A}from"ora";function c({client:n,ora:s}){let o=new y("labels").description("Labels");return o.addCommand(new y("list").description("List labels").action(async()=>{let t=await A(()=>n.label.list.send(),{...s,text:"Finding labels"});console.log(await t.result())})),o}import{Command as v}from"commander";import{oraPromise as D}from"ora";function p({client:n,ora:s}){let o=new v("messages").description("Messages");return o.addCommand(new v("list").description("List messages").action(async()=>{let t=await D(()=>n.message.list.send(),{...s,text:"Finding messages"});console.log(await t.result())})),o}import{Command as F}from"commander";import{oraPromise as M}from"ora";function l({client:n,ora:s}){let o=new F("models").description("Models");return o.addCommand(new F("list").description("List models").action(async()=>{let t=await M(()=>n.model.list.send(),{...s,text:"Finding models"});console.log(await t.result())})),o}import{Command as b}from"commander";import{oraPromise as G}from"ora";function f({client:n,ora:s}){let o=new b("sources").description("Sources");return o.addCommand(new b("list").description("List sources").action(async()=>{let t=await G(()=>n.source.list.send(),{...s,text:"Finding sources"});console.log(await t.result())})),o}var i={ora:{spinner:"simpleDotsScrolling"},client:new C(new u)},k=new I("gds").description("Great Detail Support System").addCommand(e(i)).addCommand(a(i)).addCommand(r(i)).addCommand(d(i)).addCommand(c(i)).addCommand(p(i)).addCommand(l(i)).addCommand(f(i)),L=k;L.parseAsync(process.argv);
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var E=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var M=(e,t)=>{for(var s in t)E(e,s,{get:t[s],enumerable:!0})},k=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of G(t))!B.call(e,i)&&i!==s&&E(e,i,{get:()=>t[i],enumerable:!(n=H(t,i))||n.enumerable});return e};var K=e=>k(E({},"__esModule",{value:!0}),e);var z={};M(z,{Client:()=>r,DEFAULT_SUPPORT_BASE_URL:()=>y,KeyAuthentication:()=>o,PublicAuthentication:()=>c,TokenAuthentication:()=>p,default:()=>r});module.exports=K(z);var y="https://api.support.greatdetail.com",N={"X-Powered-By":"GDSupport/JavaScript"},j="api-key";var o=class e{static DEFAULT_NAME=j;name;#t;constructor({name:t=process.env.SUPPORT_KEY_NAME??e.DEFAULT_NAME,key:s=process.env.SUPPORT_API_KEY}={}){if(!s)throw new Error("API Key option must be specified when using Key Authentication");this.name=t,this.#t=s}async filter(t){return{...t,headers:{...t.headers,Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}}};var p=class{#t;constructor({token:t=process.env.SUPPORT_ACCESS_TOKEN}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}async filter(t){return{...t,headers:{...t.headers,Authorization:`Bearer ${this.#t}`}}}};var c=class{async filter(t){return t}};var a=class{constructor(t){this._client=t}async send({request:t={},...s}={}){return this._client.send("/v1/actions",{...t,method:"GET"},s).then(n=>new T(n))}},T=class{constructor(t){this.response=t}async result(){return this.response.json()}};var l=class{constructor(t){this._client=t}async send({request:t={},...s}={}){return this._client.send("/v1/channels",{...t,method:"GET"},s).then(n=>new C(n))}},C=class{constructor(t){this.response=t}async result(){return this.response.json()}};var u=class{constructor(t){this._client=t}async send({request:t={},...s}={}){return this._client.send("/v1/contacts",{...t,method:"GET"},s).then(n=>new w(n))}},w=class{constructor(t){this.response=t}async result(){return this.response.json()}};var d=class{constructor(t){this._client=t}async send({id:t,request:s={},...n}){return this._client.send("/v1/conversations/"+encodeURIComponent(t),{...s,method:"GET"},n).then(i=>new q(i))}},q=class{constructor(t){this.response=t}async result(){return this.response.json()}};var m=class{constructor(t){this._client=t}async send({request:t={},...s}={}){return this._client.send("/v1/conversations",{...t,method:"GET"},s).then(n=>new P(n))}},P=class{constructor(t){this.response=t}async result(){return this.response.json()}};var h=class{constructor(t){this._client=t}async send({request:t={},...s}={}){return this._client.send("/v1/labels",{...t,method:"GET"},s).then(n=>new U(n))}},U=class{constructor(t){this.response=t}async result(){return this.response.json()}};var f=class{constructor(t){this._client=t}async send({request:t={},...s}={}){return this._client.send("/v1/messages",{...t,method:"GET"},s).then(n=>new I(n))}},I=class{constructor(t){this.response=t}async result(){return this.response.json()}};var b=require("zod"),g=class e{constructor(t){this._client=t}static SCHEMA=b.z.object({input:b.z.string().max(65536),original:b.z.string().max(65536),correction:b.z.string().max(65536)});async send({id:t,body:s,request:n={},...i}){return this._client.send("/v1/models/"+encodeURIComponent(t)+"/correction",{...n,method:"POST",headers:{...n.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))},i).then(_=>new L(_))}},L=class{constructor(t){this.response=t}async result(){return this.response.json()}};var R=class{constructor(t){this._client=t}async send({request:t={},...s}={}){return this._client.send("/v1/models",{...t,method:"GET"},s).then(n=>new D(n))}},D=class{constructor(t){this.response=t}async result(){return this.response.json()}};var x=require("zod"),A=class e{constructor(t){this._client=t}static SCHEMA=x.z.array(x.z.object({role:x.z.enum(["user","assistant"]),content:x.z.string().max(65536).nullable()})).min(1);async send({id:t,body:s,request:n={},...i}){return this._client.send("/v1/models/"+encodeURIComponent(t)+"/response",{...n,method:"POST",headers:{...n.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))},i).then(_=>new v(_))}},v=class{constructor(t){this.response=t}async result(){return this.response.json()}};var O=class e{constructor(t=e.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=N;async filter(t){return{...t,headers:{...t.headers,...this._standardHeaders}}}};var S=class{constructor(t){this._client=t}async send({request:t={},...s}={}){return this._client.send("/v1/sources",{...t,method:"GET"},s).then(n=>new F(n))}},F=class{constructor(t){this.response=t}async result(){return this.response.json()}};var r=class e{static DEFAULT_BASE_URL=y;options;constructor(t,s={}){this.options={requestFilterables:[new O,t],baseURL:process.env.SUPPORT_BASE_URL??e.DEFAULT_BASE_URL,...s}}action={list:new a(this)};channel={list:new l(this)};contact={list:new u(this)};conversation={get:new d(this),list:new m(this)};label={list:new h(this)};message={list:new f(this)};model={list:new R(this),response:{create:new A(this)},correction:{create:new g(this)}};source={list:new S(this)};async _filterRequest(t){for(let s of this.options.requestFilterables)t=await s.filter(t);return t}async send(t,s,{fetch:n=fetch}={}){return await n(new Request(new URL(t,this.options.baseURL),await this._filterRequest(s)))}};0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,KeyAuthentication,PublicAuthentication,TokenAuthentication});
1
+ "use strict";var E=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var K=(t,e)=>{for(var s in e)E(t,s,{get:e[s],enumerable:!0})},J=(t,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of k(e))!z.call(t,o)&&o!==s&&E(t,o,{get:()=>e[o],enumerable:!(n=B(e,o))||n.enumerable});return t};var Y=t=>J(E({},"__esModule",{value:!0}),t);var $={};K($,{Client:()=>i,DEFAULT_SUPPORT_BASE_URL:()=>C,KeyAuthentication:()=>p,PublicAuthentication:()=>c,TokenAuthentication:()=>a,default:()=>i});module.exports=Y($);var C="https://api.support.greatdetail.com",H={"X-Powered-By":"GDSupport/JavaScript"},G="api-key";var p=class t{static DEFAULT_NAME=G;name;#e;constructor({name:e=process.env.SUPPORT_KEY_NAME??t.DEFAULT_NAME,key:s=process.env.SUPPORT_API_KEY}={}){if(!s)throw new Error("API Key option must be specified when using Key Authentication");this.name=e,this.#e=s}async filter(e){return{...e,headers:{...e.headers,Authorization:`Basic ${btoa(this.name+":"+this.#e)}`}}}};var a=class{#e;constructor({token:e=process.env.SUPPORT_ACCESS_TOKEN}={}){if(!e)throw new Error("Access Token option must be specified when using Token Authentication");this.#e=e}async filter(e){return{...e,headers:{...e.headers,Authorization:`Bearer ${this.#e}`}}}};var c=class{async filter(e){return e}};var l=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/actions",{...e,method:"GET"},s).then(n=>new T(n))}},T=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/channels",{...e,method:"GET"},s).then(n=>new w(n))}},w=class{constructor(e){this.response=e}async result(){return this.response.json()}};var d=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/contacts",{...e,method:"GET"},s).then(n=>new L(n))}},L=class{constructor(e){this.response=e}async result(){return this.response.json()}};var m=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(o=>new q(o))}},q=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/conversations",{...e,method:"GET"},s).then(n=>new I(n))}},I=class{constructor(e){this.response=e}async result(){return this.response.json()}};var r=require("zod"),h=class t{constructor(e){this._client=e}static SCHEMA=r.z.object({title:r.z.string(),description:r.z.optional(r.z.string()),account:r.z.string()});async send({body:e,request:s={},...n}){return this._client.send("/v1/labels",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(t.SCHEMA.parse(e))},n).then(o=>new U(o))}},U=class{constructor(e){this.response=e}async result(){return this.response.json()}};var y=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/labels",{...e,method:"GET"},s).then(n=>new v(n))}},v=class{constructor(e){this.response=e}async result(){return this.response.json()}};var R=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/messages",{...e,method:"GET"},s).then(n=>new D(n))}},D=class{constructor(e){this.response=e}async result(){return this.response.json()}};var b=require("zod"),x=class t{constructor(e){this._client=e}static SCHEMA=b.z.object({input:b.z.string().max(65536),original:b.z.string().max(65536),correction:b.z.string().max(65536)});async send({id:e,body:s,request:n={},...o}){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))},o).then(_=>new j(_))}},j=class{constructor(e){this.response=e}async result(){return this.response.json()}};var g=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/models",{...e,method:"GET"},s).then(n=>new M(n))}},M=class{constructor(e){this.response=e}async result(){return this.response.json()}};var A=require("zod"),O=class t{constructor(e){this._client=e}static SCHEMA=A.z.array(A.z.object({role:A.z.enum(["user","assistant"]),content:A.z.string().max(65536).nullable()})).min(1);async send({id:e,body:s,request:n={},...o}){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))},o).then(_=>new N(_))}},N=class{constructor(e){this.response=e}async result(){return this.response.json()}};var S=class t{constructor(e=t.STANDARD_HEADERS){this._standardHeaders=e}static STANDARD_HEADERS=H;async filter(e){return{...e,headers:{...e.headers,...this._standardHeaders}}}};var P=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/sources",{...e,method:"GET"},s).then(n=>new F(n))}},F=class{constructor(e){this.response=e}async result(){return this.response.json()}};var i=class t{static DEFAULT_BASE_URL=C;options;constructor(e,s={}){this.options={requestFilterables:[new S,e],baseURL:process.env.SUPPORT_BASE_URL??t.DEFAULT_BASE_URL,...s}}action={list:new l(this)};channel={list:new u(this)};contact={list:new d(this)};conversation={get:new m(this),list:new f(this)};label={create:new h(this),list:new y(this)};message={list:new R(this)};model={list:new g(this),response:{create:new O(this)},correction:{create:new x(this)}};source={list:new P(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)))}};0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,KeyAuthentication,PublicAuthentication,TokenAuthentication});
package/dist/index.d.cts CHANGED
@@ -48,7 +48,7 @@ interface Authentication extends RequestFilterable {
48
48
  * @see https://greatdetail.com
49
49
  */
50
50
 
51
- interface Options$c {
51
+ interface Options$d {
52
52
  name?: string;
53
53
  key?: string;
54
54
  }
@@ -56,7 +56,7 @@ declare class KeyAuthentication implements Authentication {
56
56
  #private;
57
57
  static DEFAULT_NAME: string;
58
58
  name: string;
59
- constructor({ name, key, }?: Options$c);
59
+ constructor({ name, key, }?: Options$d);
60
60
  filter(request: RequestInit): Promise<RequestInit>;
61
61
  }
62
62
 
@@ -69,12 +69,12 @@ declare class KeyAuthentication implements Authentication {
69
69
  * @see https://greatdetail.com
70
70
  */
71
71
 
72
- interface Options$b {
72
+ interface Options$c {
73
73
  token?: string;
74
74
  }
75
75
  declare class TokenAuthentication implements Authentication {
76
76
  #private;
77
- constructor({ token }?: Options$b);
77
+ constructor({ token }?: Options$c);
78
78
  filter(request: RequestInit): Promise<RequestInit>;
79
79
  }
80
80
 
@@ -106,15 +106,15 @@ declare class PublicAuthentication implements Authentication {
106
106
  * @see https://greatdetail.com
107
107
  */
108
108
 
109
- interface Options$a extends SendOptions {
109
+ interface Options$b extends SendOptions {
110
110
  request?: RequestInit;
111
111
  }
112
112
  declare class ListActionsRequest {
113
113
  protected _client: Client;
114
114
  constructor(_client: Client);
115
- send({ request, ...options }?: Options$a): Promise<ListActionsResponse>;
115
+ send({ request, ...options }?: Options$b): Promise<ListActionsResponse>;
116
116
  }
117
- type ListResponse$9 = {
117
+ type ListActionsResponsePayload = {
118
118
  actions: {
119
119
  id: string;
120
120
  actionStatus: string;
@@ -127,7 +127,7 @@ type ListResponse$9 = {
127
127
  declare class ListActionsResponse {
128
128
  response: Response;
129
129
  constructor(response: Response);
130
- result(): Promise<ListResponse$9>;
130
+ result(): Promise<ListActionsResponsePayload>;
131
131
  }
132
132
 
133
133
  /**
@@ -139,15 +139,15 @@ declare class ListActionsResponse {
139
139
  * @see https://greatdetail.com
140
140
  */
141
141
 
142
- interface Options$9 extends SendOptions {
142
+ interface Options$a extends SendOptions {
143
143
  request?: RequestInit;
144
144
  }
145
145
  declare class ListChannelsRequest {
146
146
  protected _client: Client;
147
147
  constructor(_client: Client);
148
- send({ request, ...options }?: Options$9): Promise<ListChannelsResponse>;
148
+ send({ request, ...options }?: Options$a): Promise<ListChannelsResponse>;
149
149
  }
150
- type ListResponse$8 = {
150
+ type ListChannelsResponsePayload = {
151
151
  channels: {
152
152
  id: string;
153
153
  name?: string;
@@ -160,7 +160,7 @@ type ListResponse$8 = {
160
160
  declare class ListChannelsResponse {
161
161
  response: Response;
162
162
  constructor(response: Response);
163
- result(): Promise<ListResponse$8>;
163
+ result(): Promise<ListChannelsResponsePayload>;
164
164
  }
165
165
 
166
166
  /**
@@ -172,15 +172,15 @@ declare class ListChannelsResponse {
172
172
  * @see https://greatdetail.com
173
173
  */
174
174
 
175
- interface Options$8 extends SendOptions {
175
+ interface Options$9 extends SendOptions {
176
176
  request?: RequestInit;
177
177
  }
178
178
  declare class ListContactsRequest {
179
179
  protected _client: Client;
180
180
  constructor(_client: Client);
181
- send({ request, ...options }?: Options$8): Promise<ListContactsResponse>;
181
+ send({ request, ...options }?: Options$9): Promise<ListContactsResponse>;
182
182
  }
183
- type ListResponse$7 = {
183
+ type ListContactsResponsePayload = {
184
184
  contacts: {
185
185
  id: string;
186
186
  name?: string;
@@ -193,7 +193,7 @@ type ListResponse$7 = {
193
193
  declare class ListContactsResponse {
194
194
  response: Response;
195
195
  constructor(response: Response);
196
- result(): Promise<ListResponse$7>;
196
+ result(): Promise<ListContactsResponsePayload>;
197
197
  }
198
198
 
199
199
  /**
@@ -205,16 +205,16 @@ declare class ListContactsResponse {
205
205
  * @see https://greatdetail.com
206
206
  */
207
207
 
208
- interface Options$7 extends SendOptions {
208
+ interface Options$8 extends SendOptions {
209
209
  id: string;
210
210
  request?: RequestInit;
211
211
  }
212
212
  declare class GetConversationRequest {
213
213
  protected _client: Client;
214
214
  constructor(_client: Client);
215
- send({ id, request, ...options }: Options$7): Promise<GetConversationResponse>;
215
+ send({ id, request, ...options }: Options$8): Promise<GetConversationResponse>;
216
216
  }
217
- type GetResponse = {
217
+ type GetConversationResponsePayload = {
218
218
  conversation: {
219
219
  id: string;
220
220
  hasEnded: boolean;
@@ -226,7 +226,7 @@ type GetResponse = {
226
226
  declare class GetConversationResponse {
227
227
  response: Response;
228
228
  constructor(response: Response);
229
- result(): Promise<GetResponse>;
229
+ result(): Promise<GetConversationResponsePayload>;
230
230
  }
231
231
 
232
232
  /**
@@ -238,15 +238,15 @@ declare class GetConversationResponse {
238
238
  * @see https://greatdetail.com
239
239
  */
240
240
 
241
- interface Options$6 extends SendOptions {
241
+ interface Options$7 extends SendOptions {
242
242
  request?: RequestInit;
243
243
  }
244
244
  declare class ListConversationsRequest {
245
245
  protected _client: Client;
246
246
  constructor(_client: Client);
247
- send({ request, ...options }?: Options$6): Promise<ListConversationsResponse>;
247
+ send({ request, ...options }?: Options$7): Promise<ListConversationsResponse>;
248
248
  }
249
- type ListResponse$6 = {
249
+ type ListConversationsResponsePayload = {
250
250
  conversations: {
251
251
  id: string;
252
252
  hasEnded: boolean;
@@ -258,7 +258,53 @@ type ListResponse$6 = {
258
258
  declare class ListConversationsResponse {
259
259
  response: Response;
260
260
  constructor(response: Response);
261
- result(): Promise<ListResponse$6>;
261
+ result(): Promise<ListConversationsResponsePayload>;
262
+ }
263
+
264
+ /**
265
+ * Great Detail Support System.
266
+ *
267
+ * @copyright 2024 Great Detail Ltd
268
+ * @author Great Detail Ltd <info@greatdetail.com>
269
+ * @author Dom Webber <dom.webber@greatdetail.com>
270
+ * @see https://greatdetail.com
271
+ */
272
+
273
+ interface Options$6 extends SendOptions {
274
+ body: z.infer<typeof CreateLabelRequest.SCHEMA>;
275
+ request?: RequestInit;
276
+ }
277
+ declare class CreateLabelRequest {
278
+ protected _client: Client;
279
+ static SCHEMA: z.ZodObject<{
280
+ title: z.ZodString;
281
+ description: z.ZodOptional<z.ZodString>;
282
+ account: z.ZodString;
283
+ }, "strip", z.ZodTypeAny, {
284
+ title: string;
285
+ account: string;
286
+ description?: string | undefined;
287
+ }, {
288
+ title: string;
289
+ account: string;
290
+ description?: string | undefined;
291
+ }>;
292
+ constructor(_client: Client);
293
+ send({ body, request, ...options }: Options$6): Promise<CreateLabelResponse>;
294
+ }
295
+ type CreateLabelResponsePayload = {
296
+ label: {
297
+ id: string;
298
+ title: string;
299
+ description?: string;
300
+ createdAt: string;
301
+ updatedAt?: string;
302
+ };
303
+ };
304
+ declare class CreateLabelResponse {
305
+ response: Response;
306
+ constructor(response: Response);
307
+ result(): Promise<CreateLabelResponsePayload>;
262
308
  }
263
309
 
264
310
  /**
@@ -278,7 +324,7 @@ declare class ListLabelsRequest {
278
324
  constructor(_client: Client);
279
325
  send({ request, ...options }?: Options$5): Promise<ListLabelsResponse>;
280
326
  }
281
- type ListResponse$5 = {
327
+ type ListLabelsResponsePayload = {
282
328
  labels: {
283
329
  id: string;
284
330
  title: string;
@@ -290,7 +336,7 @@ type ListResponse$5 = {
290
336
  declare class ListLabelsResponse {
291
337
  response: Response;
292
338
  constructor(response: Response);
293
- result(): Promise<ListResponse$5>;
339
+ result(): Promise<ListLabelsResponsePayload>;
294
340
  }
295
341
 
296
342
  /**
@@ -310,7 +356,7 @@ declare class ListMessagesRequest {
310
356
  constructor(_client: Client);
311
357
  send({ request, ...options }?: Options$4): Promise<ListMessagesResponse>;
312
358
  }
313
- type ListResponse$4 = {
359
+ type ListMessagesResponsePayload = {
314
360
  messages: {
315
361
  id: string;
316
362
  role: "user" | "assistant";
@@ -325,7 +371,7 @@ type ListResponse$4 = {
325
371
  declare class ListMessagesResponse {
326
372
  response: Response;
327
373
  constructor(response: Response);
328
- result(): Promise<ListResponse$4>;
374
+ result(): Promise<ListMessagesResponsePayload>;
329
375
  }
330
376
 
331
377
  /**
@@ -360,11 +406,11 @@ declare class CreateCorrectionModelRequest {
360
406
  constructor(_client: Client);
361
407
  send({ id, body, request, ...options }: Options$3): Promise<CreateCorrectionModelResponse>;
362
408
  }
363
- type ListResponse$3 = unknown;
409
+ type CreateCorrectionResponsePayload = unknown;
364
410
  declare class CreateCorrectionModelResponse {
365
411
  response: Response;
366
412
  constructor(response: Response);
367
- result(): Promise<ListResponse$3>;
413
+ result(): Promise<CreateCorrectionResponsePayload>;
368
414
  }
369
415
 
370
416
  /**
@@ -384,7 +430,7 @@ declare class ListModelsRequest {
384
430
  constructor(_client: Client);
385
431
  send({ request, ...options }?: Options$2): Promise<ListModelsResponse>;
386
432
  }
387
- type ListResponse$2 = {
433
+ type ListModelsResponsePayload = {
388
434
  models: {
389
435
  id: string;
390
436
  name: string;
@@ -396,7 +442,7 @@ type ListResponse$2 = {
396
442
  declare class ListModelsResponse {
397
443
  response: Response;
398
444
  constructor(response: Response);
399
- result(): Promise<ListResponse$2>;
445
+ result(): Promise<ListModelsResponsePayload>;
400
446
  }
401
447
 
402
448
  /**
@@ -428,7 +474,7 @@ declare class CreateResponseModelRequest {
428
474
  constructor(_client: Client);
429
475
  send({ id, body, request, ...options }: Options$1): Promise<CreateResponseModelResponse>;
430
476
  }
431
- type ListResponse$1 = {
477
+ type CreateResponseResponsePayload = {
432
478
  message: string | null;
433
479
  debug: {
434
480
  duration: string;
@@ -438,7 +484,7 @@ type ListResponse$1 = {
438
484
  declare class CreateResponseModelResponse {
439
485
  response: Response;
440
486
  constructor(response: Response);
441
- result(): Promise<ListResponse$1>;
487
+ result(): Promise<CreateResponseResponsePayload>;
442
488
  }
443
489
 
444
490
  /**
@@ -458,7 +504,7 @@ declare class ListSourcesRequest {
458
504
  constructor(_client: Client);
459
505
  send({ request, ...options }?: Options): Promise<ListSourcesResponse>;
460
506
  }
461
- type ListResponse = {
507
+ type ListSourcesResponsePayload = {
462
508
  sources: {
463
509
  id: string;
464
510
  name: string;
@@ -470,7 +516,7 @@ type ListResponse = {
470
516
  declare class ListSourcesResponse {
471
517
  response: Response;
472
518
  constructor(response: Response);
473
- result(): Promise<ListResponse>;
519
+ result(): Promise<ListSourcesResponsePayload>;
474
520
  }
475
521
 
476
522
  /**
@@ -517,6 +563,7 @@ declare class Client {
517
563
  list: ListConversationsRequest;
518
564
  };
519
565
  label: {
566
+ create: CreateLabelRequest;
520
567
  list: ListLabelsRequest;
521
568
  };
522
569
  message: {
@@ -538,4 +585,4 @@ declare class Client {
538
585
  send(url: string | URL, request: RequestInit, { fetch: fetchAlternative }?: SendOptions): Promise<Response>;
539
586
  }
540
587
 
541
- export { Client, DEFAULT_SUPPORT_BASE_URL, KeyAuthentication, PublicAuthentication, type RequestFilterable, TokenAuthentication, Client as default };
588
+ export { Client, type CreateCorrectionResponsePayload, type CreateLabelResponsePayload, type CreateResponseResponsePayload, DEFAULT_SUPPORT_BASE_URL, type GetConversationResponsePayload, KeyAuthentication, type ListActionsResponsePayload, type ListChannelsResponsePayload, type ListContactsResponsePayload, type ListConversationsResponsePayload, type ListLabelsResponsePayload, type ListMessagesResponsePayload, type ListModelsResponsePayload, type ListSourcesResponsePayload, PublicAuthentication, type RequestFilterable, TokenAuthentication, Client as default };
package/dist/index.d.ts CHANGED
@@ -48,7 +48,7 @@ interface Authentication extends RequestFilterable {
48
48
  * @see https://greatdetail.com
49
49
  */
50
50
 
51
- interface Options$c {
51
+ interface Options$d {
52
52
  name?: string;
53
53
  key?: string;
54
54
  }
@@ -56,7 +56,7 @@ declare class KeyAuthentication implements Authentication {
56
56
  #private;
57
57
  static DEFAULT_NAME: string;
58
58
  name: string;
59
- constructor({ name, key, }?: Options$c);
59
+ constructor({ name, key, }?: Options$d);
60
60
  filter(request: RequestInit): Promise<RequestInit>;
61
61
  }
62
62
 
@@ -69,12 +69,12 @@ declare class KeyAuthentication implements Authentication {
69
69
  * @see https://greatdetail.com
70
70
  */
71
71
 
72
- interface Options$b {
72
+ interface Options$c {
73
73
  token?: string;
74
74
  }
75
75
  declare class TokenAuthentication implements Authentication {
76
76
  #private;
77
- constructor({ token }?: Options$b);
77
+ constructor({ token }?: Options$c);
78
78
  filter(request: RequestInit): Promise<RequestInit>;
79
79
  }
80
80
 
@@ -106,15 +106,15 @@ declare class PublicAuthentication implements Authentication {
106
106
  * @see https://greatdetail.com
107
107
  */
108
108
 
109
- interface Options$a extends SendOptions {
109
+ interface Options$b extends SendOptions {
110
110
  request?: RequestInit;
111
111
  }
112
112
  declare class ListActionsRequest {
113
113
  protected _client: Client;
114
114
  constructor(_client: Client);
115
- send({ request, ...options }?: Options$a): Promise<ListActionsResponse>;
115
+ send({ request, ...options }?: Options$b): Promise<ListActionsResponse>;
116
116
  }
117
- type ListResponse$9 = {
117
+ type ListActionsResponsePayload = {
118
118
  actions: {
119
119
  id: string;
120
120
  actionStatus: string;
@@ -127,7 +127,7 @@ type ListResponse$9 = {
127
127
  declare class ListActionsResponse {
128
128
  response: Response;
129
129
  constructor(response: Response);
130
- result(): Promise<ListResponse$9>;
130
+ result(): Promise<ListActionsResponsePayload>;
131
131
  }
132
132
 
133
133
  /**
@@ -139,15 +139,15 @@ declare class ListActionsResponse {
139
139
  * @see https://greatdetail.com
140
140
  */
141
141
 
142
- interface Options$9 extends SendOptions {
142
+ interface Options$a extends SendOptions {
143
143
  request?: RequestInit;
144
144
  }
145
145
  declare class ListChannelsRequest {
146
146
  protected _client: Client;
147
147
  constructor(_client: Client);
148
- send({ request, ...options }?: Options$9): Promise<ListChannelsResponse>;
148
+ send({ request, ...options }?: Options$a): Promise<ListChannelsResponse>;
149
149
  }
150
- type ListResponse$8 = {
150
+ type ListChannelsResponsePayload = {
151
151
  channels: {
152
152
  id: string;
153
153
  name?: string;
@@ -160,7 +160,7 @@ type ListResponse$8 = {
160
160
  declare class ListChannelsResponse {
161
161
  response: Response;
162
162
  constructor(response: Response);
163
- result(): Promise<ListResponse$8>;
163
+ result(): Promise<ListChannelsResponsePayload>;
164
164
  }
165
165
 
166
166
  /**
@@ -172,15 +172,15 @@ declare class ListChannelsResponse {
172
172
  * @see https://greatdetail.com
173
173
  */
174
174
 
175
- interface Options$8 extends SendOptions {
175
+ interface Options$9 extends SendOptions {
176
176
  request?: RequestInit;
177
177
  }
178
178
  declare class ListContactsRequest {
179
179
  protected _client: Client;
180
180
  constructor(_client: Client);
181
- send({ request, ...options }?: Options$8): Promise<ListContactsResponse>;
181
+ send({ request, ...options }?: Options$9): Promise<ListContactsResponse>;
182
182
  }
183
- type ListResponse$7 = {
183
+ type ListContactsResponsePayload = {
184
184
  contacts: {
185
185
  id: string;
186
186
  name?: string;
@@ -193,7 +193,7 @@ type ListResponse$7 = {
193
193
  declare class ListContactsResponse {
194
194
  response: Response;
195
195
  constructor(response: Response);
196
- result(): Promise<ListResponse$7>;
196
+ result(): Promise<ListContactsResponsePayload>;
197
197
  }
198
198
 
199
199
  /**
@@ -205,16 +205,16 @@ declare class ListContactsResponse {
205
205
  * @see https://greatdetail.com
206
206
  */
207
207
 
208
- interface Options$7 extends SendOptions {
208
+ interface Options$8 extends SendOptions {
209
209
  id: string;
210
210
  request?: RequestInit;
211
211
  }
212
212
  declare class GetConversationRequest {
213
213
  protected _client: Client;
214
214
  constructor(_client: Client);
215
- send({ id, request, ...options }: Options$7): Promise<GetConversationResponse>;
215
+ send({ id, request, ...options }: Options$8): Promise<GetConversationResponse>;
216
216
  }
217
- type GetResponse = {
217
+ type GetConversationResponsePayload = {
218
218
  conversation: {
219
219
  id: string;
220
220
  hasEnded: boolean;
@@ -226,7 +226,7 @@ type GetResponse = {
226
226
  declare class GetConversationResponse {
227
227
  response: Response;
228
228
  constructor(response: Response);
229
- result(): Promise<GetResponse>;
229
+ result(): Promise<GetConversationResponsePayload>;
230
230
  }
231
231
 
232
232
  /**
@@ -238,15 +238,15 @@ declare class GetConversationResponse {
238
238
  * @see https://greatdetail.com
239
239
  */
240
240
 
241
- interface Options$6 extends SendOptions {
241
+ interface Options$7 extends SendOptions {
242
242
  request?: RequestInit;
243
243
  }
244
244
  declare class ListConversationsRequest {
245
245
  protected _client: Client;
246
246
  constructor(_client: Client);
247
- send({ request, ...options }?: Options$6): Promise<ListConversationsResponse>;
247
+ send({ request, ...options }?: Options$7): Promise<ListConversationsResponse>;
248
248
  }
249
- type ListResponse$6 = {
249
+ type ListConversationsResponsePayload = {
250
250
  conversations: {
251
251
  id: string;
252
252
  hasEnded: boolean;
@@ -258,7 +258,53 @@ type ListResponse$6 = {
258
258
  declare class ListConversationsResponse {
259
259
  response: Response;
260
260
  constructor(response: Response);
261
- result(): Promise<ListResponse$6>;
261
+ result(): Promise<ListConversationsResponsePayload>;
262
+ }
263
+
264
+ /**
265
+ * Great Detail Support System.
266
+ *
267
+ * @copyright 2024 Great Detail Ltd
268
+ * @author Great Detail Ltd <info@greatdetail.com>
269
+ * @author Dom Webber <dom.webber@greatdetail.com>
270
+ * @see https://greatdetail.com
271
+ */
272
+
273
+ interface Options$6 extends SendOptions {
274
+ body: z.infer<typeof CreateLabelRequest.SCHEMA>;
275
+ request?: RequestInit;
276
+ }
277
+ declare class CreateLabelRequest {
278
+ protected _client: Client;
279
+ static SCHEMA: z.ZodObject<{
280
+ title: z.ZodString;
281
+ description: z.ZodOptional<z.ZodString>;
282
+ account: z.ZodString;
283
+ }, "strip", z.ZodTypeAny, {
284
+ title: string;
285
+ account: string;
286
+ description?: string | undefined;
287
+ }, {
288
+ title: string;
289
+ account: string;
290
+ description?: string | undefined;
291
+ }>;
292
+ constructor(_client: Client);
293
+ send({ body, request, ...options }: Options$6): Promise<CreateLabelResponse>;
294
+ }
295
+ type CreateLabelResponsePayload = {
296
+ label: {
297
+ id: string;
298
+ title: string;
299
+ description?: string;
300
+ createdAt: string;
301
+ updatedAt?: string;
302
+ };
303
+ };
304
+ declare class CreateLabelResponse {
305
+ response: Response;
306
+ constructor(response: Response);
307
+ result(): Promise<CreateLabelResponsePayload>;
262
308
  }
263
309
 
264
310
  /**
@@ -278,7 +324,7 @@ declare class ListLabelsRequest {
278
324
  constructor(_client: Client);
279
325
  send({ request, ...options }?: Options$5): Promise<ListLabelsResponse>;
280
326
  }
281
- type ListResponse$5 = {
327
+ type ListLabelsResponsePayload = {
282
328
  labels: {
283
329
  id: string;
284
330
  title: string;
@@ -290,7 +336,7 @@ type ListResponse$5 = {
290
336
  declare class ListLabelsResponse {
291
337
  response: Response;
292
338
  constructor(response: Response);
293
- result(): Promise<ListResponse$5>;
339
+ result(): Promise<ListLabelsResponsePayload>;
294
340
  }
295
341
 
296
342
  /**
@@ -310,7 +356,7 @@ declare class ListMessagesRequest {
310
356
  constructor(_client: Client);
311
357
  send({ request, ...options }?: Options$4): Promise<ListMessagesResponse>;
312
358
  }
313
- type ListResponse$4 = {
359
+ type ListMessagesResponsePayload = {
314
360
  messages: {
315
361
  id: string;
316
362
  role: "user" | "assistant";
@@ -325,7 +371,7 @@ type ListResponse$4 = {
325
371
  declare class ListMessagesResponse {
326
372
  response: Response;
327
373
  constructor(response: Response);
328
- result(): Promise<ListResponse$4>;
374
+ result(): Promise<ListMessagesResponsePayload>;
329
375
  }
330
376
 
331
377
  /**
@@ -360,11 +406,11 @@ declare class CreateCorrectionModelRequest {
360
406
  constructor(_client: Client);
361
407
  send({ id, body, request, ...options }: Options$3): Promise<CreateCorrectionModelResponse>;
362
408
  }
363
- type ListResponse$3 = unknown;
409
+ type CreateCorrectionResponsePayload = unknown;
364
410
  declare class CreateCorrectionModelResponse {
365
411
  response: Response;
366
412
  constructor(response: Response);
367
- result(): Promise<ListResponse$3>;
413
+ result(): Promise<CreateCorrectionResponsePayload>;
368
414
  }
369
415
 
370
416
  /**
@@ -384,7 +430,7 @@ declare class ListModelsRequest {
384
430
  constructor(_client: Client);
385
431
  send({ request, ...options }?: Options$2): Promise<ListModelsResponse>;
386
432
  }
387
- type ListResponse$2 = {
433
+ type ListModelsResponsePayload = {
388
434
  models: {
389
435
  id: string;
390
436
  name: string;
@@ -396,7 +442,7 @@ type ListResponse$2 = {
396
442
  declare class ListModelsResponse {
397
443
  response: Response;
398
444
  constructor(response: Response);
399
- result(): Promise<ListResponse$2>;
445
+ result(): Promise<ListModelsResponsePayload>;
400
446
  }
401
447
 
402
448
  /**
@@ -428,7 +474,7 @@ declare class CreateResponseModelRequest {
428
474
  constructor(_client: Client);
429
475
  send({ id, body, request, ...options }: Options$1): Promise<CreateResponseModelResponse>;
430
476
  }
431
- type ListResponse$1 = {
477
+ type CreateResponseResponsePayload = {
432
478
  message: string | null;
433
479
  debug: {
434
480
  duration: string;
@@ -438,7 +484,7 @@ type ListResponse$1 = {
438
484
  declare class CreateResponseModelResponse {
439
485
  response: Response;
440
486
  constructor(response: Response);
441
- result(): Promise<ListResponse$1>;
487
+ result(): Promise<CreateResponseResponsePayload>;
442
488
  }
443
489
 
444
490
  /**
@@ -458,7 +504,7 @@ declare class ListSourcesRequest {
458
504
  constructor(_client: Client);
459
505
  send({ request, ...options }?: Options): Promise<ListSourcesResponse>;
460
506
  }
461
- type ListResponse = {
507
+ type ListSourcesResponsePayload = {
462
508
  sources: {
463
509
  id: string;
464
510
  name: string;
@@ -470,7 +516,7 @@ type ListResponse = {
470
516
  declare class ListSourcesResponse {
471
517
  response: Response;
472
518
  constructor(response: Response);
473
- result(): Promise<ListResponse>;
519
+ result(): Promise<ListSourcesResponsePayload>;
474
520
  }
475
521
 
476
522
  /**
@@ -517,6 +563,7 @@ declare class Client {
517
563
  list: ListConversationsRequest;
518
564
  };
519
565
  label: {
566
+ create: CreateLabelRequest;
520
567
  list: ListLabelsRequest;
521
568
  };
522
569
  message: {
@@ -538,4 +585,4 @@ declare class Client {
538
585
  send(url: string | URL, request: RequestInit, { fetch: fetchAlternative }?: SendOptions): Promise<Response>;
539
586
  }
540
587
 
541
- export { Client, DEFAULT_SUPPORT_BASE_URL, KeyAuthentication, PublicAuthentication, type RequestFilterable, TokenAuthentication, Client as default };
588
+ export { Client, type CreateCorrectionResponsePayload, type CreateLabelResponsePayload, type CreateResponseResponsePayload, DEFAULT_SUPPORT_BASE_URL, type GetConversationResponsePayload, KeyAuthentication, type ListActionsResponsePayload, type ListChannelsResponsePayload, type ListContactsResponsePayload, type ListConversationsResponsePayload, type ListLabelsResponsePayload, type ListMessagesResponsePayload, type ListModelsResponsePayload, type ListSourcesResponsePayload, PublicAuthentication, type RequestFilterable, TokenAuthentication, Client as default };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a,b as o,c as u,d as s}from"./chunk-ZLBEVMCE.js";var e=class r{static DEFAULT_NAME=o;name;#t;constructor({name:t=process.env.SUPPORT_KEY_NAME??r.DEFAULT_NAME,key:n=process.env.SUPPORT_API_KEY}={}){if(!n)throw new Error("API Key option must be specified when using Key Authentication");this.name=t,this.#t=n}async filter(t){return{...t,headers:{...t.headers,Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}}};var i=class{#t;constructor({token:t=process.env.SUPPORT_ACCESS_TOKEN}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}async filter(t){return{...t,headers:{...t.headers,Authorization:`Bearer ${this.#t}`}}}};export{s as Client,a as DEFAULT_SUPPORT_BASE_URL,e as KeyAuthentication,u as PublicAuthentication,i as TokenAuthentication,s as default};
1
+ import{a,b as n,c as p,d as i}from"./chunk-WCSPJBPY.js";var t=class s{static DEFAULT_NAME=n;name;#e;constructor({name:e=process.env.SUPPORT_KEY_NAME??s.DEFAULT_NAME,key:r=process.env.SUPPORT_API_KEY}={}){if(!r)throw new Error("API Key option must be specified when using Key Authentication");this.name=e,this.#e=r}async filter(e){return{...e,headers:{...e.headers,Authorization:`Basic ${btoa(this.name+":"+this.#e)}`}}}};var o=class{#e;constructor({token:e=process.env.SUPPORT_ACCESS_TOKEN}={}){if(!e)throw new Error("Access Token option must be specified when using Token Authentication");this.#e=e}async filter(e){return{...e,headers:{...e.headers,Authorization:`Bearer ${this.#e}`}}}};export{i as Client,a as DEFAULT_SUPPORT_BASE_URL,t as KeyAuthentication,p as PublicAuthentication,o as TokenAuthentication,i as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@great-detail/support-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "description": "JavaScript SDK for the Great Detail Support System",
6
6
  "author": "Great Detail Ltd <info@greatdetail.com>",
@@ -30,7 +30,7 @@ export default class ListActionsRequest {
30
30
  }
31
31
  }
32
32
 
33
- export type ListResponse = {
33
+ export type ListActionsResponsePayload = {
34
34
  actions: {
35
35
  id: string;
36
36
  actionStatus: string;
@@ -44,7 +44,7 @@ export type ListResponse = {
44
44
  export class ListActionsResponse {
45
45
  constructor(public response: Response) {}
46
46
 
47
- public async result(): Promise<ListResponse> {
47
+ public async result(): Promise<ListActionsResponsePayload> {
48
48
  return this.response.json();
49
49
  }
50
50
  }
@@ -30,7 +30,7 @@ export default class ListChannelsRequest {
30
30
  }
31
31
  }
32
32
 
33
- export type ListResponse = {
33
+ export type ListChannelsResponsePayload = {
34
34
  channels: {
35
35
  id: string;
36
36
  name?: string;
@@ -44,7 +44,7 @@ export type ListResponse = {
44
44
  export class ListChannelsResponse {
45
45
  constructor(public response: Response) {}
46
46
 
47
- public async result(): Promise<ListResponse> {
47
+ public async result(): Promise<ListChannelsResponsePayload> {
48
48
  return this.response.json();
49
49
  }
50
50
  }
@@ -14,6 +14,7 @@ import { DEFAULT_SUPPORT_BASE_URL } from "../constants/index.js";
14
14
  import ListContactsRequest from "../Contact/ListContacts.js";
15
15
  import GetConversationRequest from "../Conversation/GetConversation.js";
16
16
  import ListConversationsRequest from "../Conversation/ListConversations.js";
17
+ import CreateLabelRequest from "../Label/CreateLabel.js";
17
18
  import ListLabelsRequest from "../Label/ListLabels.js";
18
19
  import ListMessagesRequest from "../Message/ListMessages.js";
19
20
  import CreateCorrectionModelRequest from "../Model/Correction/CreateCorrectionModel.js";
@@ -77,6 +78,7 @@ export default class Client {
77
78
  };
78
79
 
79
80
  public label = {
81
+ create: new CreateLabelRequest(this),
80
82
  list: new ListLabelsRequest(this),
81
83
  };
82
84
 
@@ -30,7 +30,7 @@ export default class ListContactsRequest {
30
30
  }
31
31
  }
32
32
 
33
- export type ListResponse = {
33
+ export type ListContactsResponsePayload = {
34
34
  contacts: {
35
35
  id: string;
36
36
  name?: string;
@@ -44,7 +44,7 @@ export type ListResponse = {
44
44
  export class ListContactsResponse {
45
45
  constructor(public response: Response) {}
46
46
 
47
- public async result(): Promise<ListResponse> {
47
+ public async result(): Promise<ListContactsResponsePayload> {
48
48
  return this.response.json();
49
49
  }
50
50
  }
@@ -31,7 +31,7 @@ export default class GetConversationRequest {
31
31
  }
32
32
  }
33
33
 
34
- export type GetResponse = {
34
+ export type GetConversationResponsePayload = {
35
35
  conversation: {
36
36
  id: string;
37
37
  hasEnded: boolean;
@@ -44,7 +44,7 @@ export type GetResponse = {
44
44
  export class GetConversationResponse {
45
45
  constructor(public response: Response) {}
46
46
 
47
- public async result(): Promise<GetResponse> {
47
+ public async result(): Promise<GetConversationResponsePayload> {
48
48
  return this.response.json();
49
49
  }
50
50
  }
@@ -30,7 +30,7 @@ export default class ListConversationsRequest {
30
30
  }
31
31
  }
32
32
 
33
- export type ListResponse = {
33
+ export type ListConversationsResponsePayload = {
34
34
  conversations: {
35
35
  id: string;
36
36
  hasEnded: boolean;
@@ -43,7 +43,7 @@ export type ListResponse = {
43
43
  export class ListConversationsResponse {
44
44
  constructor(public response: Response) {}
45
45
 
46
- public async result(): Promise<ListResponse> {
46
+ public async result(): Promise<ListConversationsResponsePayload> {
47
47
  return this.response.json();
48
48
  }
49
49
  }
@@ -0,0 +1,62 @@
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 Client, { SendOptions } from "../Client/index.js";
12
+
13
+ export interface Options extends SendOptions {
14
+ body: z.infer<typeof CreateLabelRequest.SCHEMA>;
15
+ request?: RequestInit;
16
+ }
17
+
18
+ export default class CreateLabelRequest {
19
+ public static SCHEMA = z.object({
20
+ title: z.string(),
21
+ description: z.optional(z.string()),
22
+ account: z.string(),
23
+ });
24
+
25
+ constructor(protected _client: Client) {}
26
+
27
+ public async send({ body, request = {}, ...options }: Options) {
28
+ return this._client
29
+ .send(
30
+ "/v1/labels",
31
+ {
32
+ ...request,
33
+ method: "POST",
34
+ headers: {
35
+ ...request.headers,
36
+ "Content-Type": "application/json",
37
+ },
38
+ body: JSON.stringify(CreateLabelRequest.SCHEMA.parse(body)),
39
+ },
40
+ options,
41
+ )
42
+ .then((response) => new CreateLabelResponse(response));
43
+ }
44
+ }
45
+
46
+ export type CreateLabelResponsePayload = {
47
+ label: {
48
+ id: string;
49
+ title: string;
50
+ description?: string;
51
+ createdAt: string;
52
+ updatedAt?: string;
53
+ };
54
+ };
55
+
56
+ export class CreateLabelResponse {
57
+ constructor(public response: Response) {}
58
+
59
+ public async result(): Promise<CreateLabelResponsePayload> {
60
+ return this.response.json();
61
+ }
62
+ }
@@ -30,7 +30,7 @@ export default class ListLabelsRequest {
30
30
  }
31
31
  }
32
32
 
33
- export type ListResponse = {
33
+ export type ListLabelsResponsePayload = {
34
34
  labels: {
35
35
  id: string;
36
36
  title: string;
@@ -43,7 +43,7 @@ export type ListResponse = {
43
43
  export class ListLabelsResponse {
44
44
  constructor(public response: Response) {}
45
45
 
46
- public async result(): Promise<ListResponse> {
46
+ public async result(): Promise<ListLabelsResponsePayload> {
47
47
  return this.response.json();
48
48
  }
49
49
  }
@@ -30,7 +30,7 @@ export default class ListMessagesRequest {
30
30
  }
31
31
  }
32
32
 
33
- export type ListResponse = {
33
+ export type ListMessagesResponsePayload = {
34
34
  messages: {
35
35
  id: string;
36
36
  role: "user" | "assistant";
@@ -46,7 +46,7 @@ export type ListResponse = {
46
46
  export class ListMessagesResponse {
47
47
  constructor(public response: Response) {}
48
48
 
49
- public async result(): Promise<ListResponse> {
49
+ public async result(): Promise<ListMessagesResponsePayload> {
50
50
  return this.response.json();
51
51
  }
52
52
  }
@@ -44,12 +44,12 @@ export default class CreateCorrectionModelRequest {
44
44
  }
45
45
  }
46
46
 
47
- export type ListResponse = unknown;
47
+ export type CreateCorrectionResponsePayload = unknown;
48
48
 
49
49
  export class CreateCorrectionModelResponse {
50
50
  constructor(public response: Response) {}
51
51
 
52
- public async result(): Promise<ListResponse> {
52
+ public async result(): Promise<CreateCorrectionResponsePayload> {
53
53
  return this.response.json();
54
54
  }
55
55
  }
@@ -30,7 +30,7 @@ export default class ListModelsRequest {
30
30
  }
31
31
  }
32
32
 
33
- export type ListResponse = {
33
+ export type ListModelsResponsePayload = {
34
34
  models: {
35
35
  id: string;
36
36
  name: string;
@@ -43,7 +43,7 @@ export type ListResponse = {
43
43
  export class ListModelsResponse {
44
44
  constructor(public response: Response) {}
45
45
 
46
- public async result(): Promise<ListResponse> {
46
+ public async result(): Promise<ListModelsResponsePayload> {
47
47
  return this.response.json();
48
48
  }
49
49
  }
@@ -47,7 +47,7 @@ export default class CreateResponseModelRequest {
47
47
  }
48
48
  }
49
49
 
50
- export type ListResponse = {
50
+ export type CreateResponseResponsePayload = {
51
51
  message: string | null;
52
52
  debug: {
53
53
  duration: string;
@@ -58,7 +58,7 @@ export type ListResponse = {
58
58
  export class CreateResponseModelResponse {
59
59
  constructor(public response: Response) {}
60
60
 
61
- public async result(): Promise<ListResponse> {
61
+ public async result(): Promise<CreateResponseResponsePayload> {
62
62
  return this.response.json();
63
63
  }
64
64
  }
@@ -30,7 +30,7 @@ export default class ListSourcesRequest {
30
30
  }
31
31
  }
32
32
 
33
- export type ListResponse = {
33
+ export type ListSourcesResponsePayload = {
34
34
  sources: {
35
35
  id: string;
36
36
  name: string;
@@ -43,7 +43,7 @@ export type ListResponse = {
43
43
  export class ListSourcesResponse {
44
44
  constructor(public response: Response) {}
45
45
 
46
- public async result(): Promise<ListResponse> {
46
+ public async result(): Promise<ListSourcesResponsePayload> {
47
47
  return this.response.json();
48
48
  }
49
49
  }
package/src/index.ts CHANGED
@@ -13,3 +13,15 @@ export { default as TokenAuthentication } from "./Authentication/TokenAuthentica
13
13
  export { default as PublicAuthentication } from "./Authentication/PublicAuthentication.js";
14
14
  export { type default as RequestFilterable } from "./Request/RequestFilterable.js";
15
15
  export { default, default as Client } from "./Client/index.js";
16
+ export { type ListActionsResponsePayload } from "./Action/ListActions.js";
17
+ export { type ListChannelsResponsePayload } from "./Channel/ListChannels.js";
18
+ export { type ListContactsResponsePayload } from "./Contact/ListContacts.js";
19
+ export { type ListConversationsResponsePayload } from "./Conversation/ListConversations.js";
20
+ export { type GetConversationResponsePayload } from "./Conversation/GetConversation.js";
21
+ export { type CreateLabelResponsePayload } from "./Label/CreateLabel.js";
22
+ export { type ListLabelsResponsePayload } from "./Label/ListLabels.js";
23
+ export { type ListMessagesResponsePayload } from "./Message/ListMessages.js";
24
+ export { type ListModelsResponsePayload } from "./Model/ListModels.js";
25
+ export { type CreateCorrectionResponsePayload } from "./Model/Correction/CreateCorrectionModel.js";
26
+ export { type CreateResponseResponsePayload } from "./Model/Response/CreateResponseModel.js";
27
+ export { type ListSourcesResponsePayload } from "./Source/ListSources.js";
@@ -1 +0,0 @@
1
- var P="https://api.support.greatdetail.com",D={"X-Powered-By":"GDSupport/JavaScript"},v="api-key";var O=class{async filter(t){return t}};var i=class{constructor(t){this._client=t}async send({request:t={},...s}={}){return this._client.send("/v1/actions",{...t,method:"GET"},s).then(n=>new S(n))}},S=class{constructor(t){this.response=t}async result(){return this.response.json()}};var o=class{constructor(t){this._client=t}async send({request:t={},...s}={}){return this._client.send("/v1/channels",{...t,method:"GET"},s).then(n=>new y(n))}},y=class{constructor(t){this.response=t}async result(){return this.response.json()}};var p=class{constructor(t){this._client=t}async send({request:t={},...s}={}){return this._client.send("/v1/contacts",{...t,method:"GET"},s).then(n=>new A(n))}},A=class{constructor(t){this.response=t}async result(){return this.response.json()}};var c=class{constructor(t){this._client=t}async send({id:t,request:s={},...n}){return this._client.send("/v1/conversations/"+encodeURIComponent(t),{...s,method:"GET"},n).then(r=>new _(r))}},_=class{constructor(t){this.response=t}async result(){return this.response.json()}};var l=class{constructor(t){this._client=t}async send({request:t={},...s}={}){return this._client.send("/v1/conversations",{...t,method:"GET"},s).then(n=>new E(n))}},E=class{constructor(t){this.response=t}async result(){return this.response.json()}};var a=class{constructor(t){this._client=t}async send({request:t={},...s}={}){return this._client.send("/v1/labels",{...t,method:"GET"},s).then(n=>new C(n))}},C=class{constructor(t){this.response=t}async result(){return this.response.json()}};var u=class{constructor(t){this._client=t}async send({request:t={},...s}={}){return this._client.send("/v1/messages",{...t,method:"GET"},s).then(n=>new q(n))}},q=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as g}from"zod";var d=class e{constructor(t){this._client=t}static SCHEMA=g.object({input:g.string().max(65536),original:g.string().max(65536),correction:g.string().max(65536)});async send({id:t,body:s,request:n={},...r}){return this._client.send("/v1/models/"+encodeURIComponent(t)+"/correction",{...n,method:"POST",headers:{...n.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))},r).then(x=>new w(x))}},w=class{constructor(t){this.response=t}async result(){return this.response.json()}};var m=class{constructor(t){this._client=t}async send({request:t={},...s}={}){return this._client.send("/v1/models",{...t,method:"GET"},s).then(n=>new T(n))}},T=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as R}from"zod";var h=class e{constructor(t){this._client=t}static SCHEMA=R.array(R.object({role:R.enum(["user","assistant"]),content:R.string().max(65536).nullable()})).min(1);async send({id:t,body:s,request:n={},...r}){return this._client.send("/v1/models/"+encodeURIComponent(t)+"/response",{...n,method:"POST",headers:{...n.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))},r).then(x=>new L(x))}},L=class{constructor(t){this.response=t}async result(){return this.response.json()}};var f=class e{constructor(t=e.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=D;async filter(t){return{...t,headers:{...t.headers,...this._standardHeaders}}}};var b=class{constructor(t){this._client=t}async send({request:t={},...s}={}){return this._client.send("/v1/sources",{...t,method:"GET"},s).then(n=>new I(n))}},I=class{constructor(t){this.response=t}async result(){return this.response.json()}};var U=class e{static DEFAULT_BASE_URL=P;options;constructor(t,s={}){this.options={requestFilterables:[new f,t],baseURL:process.env.SUPPORT_BASE_URL??e.DEFAULT_BASE_URL,...s}}action={list:new i(this)};channel={list:new o(this)};contact={list:new p(this)};conversation={get:new c(this),list:new l(this)};label={list:new a(this)};message={list:new u(this)};model={list:new m(this),response:{create:new h(this)},correction:{create:new d(this)}};source={list:new b(this)};async _filterRequest(t){for(let s of this.options.requestFilterables)t=await s.filter(t);return t}async send(t,s,{fetch:n=fetch}={}){return await n(new Request(new URL(t,this.options.baseURL),await this._filterRequest(s)))}};export{P as a,v as b,O as c,U as d};