@great-detail/support-sdk 0.0.5 → 0.0.7
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 +59 -0
- package/dist/chunk-PWDTRAX2.js +1 -0
- package/dist/chunk-QYWS5WK5.js +1 -0
- package/dist/cli/index.cjs +1 -0
- package/dist/cli/index.d.cts +21 -0
- package/dist/cli/index.d.ts +21 -0
- package/dist/cli/index.js +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/index-ByUz_hOL.d.cts +728 -0
- package/dist/index-ByUz_hOL.d.ts +728 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +8 -655
- package/dist/index.d.ts +8 -655
- package/dist/index.js +1 -1
- package/package.json +15 -8
- package/src/Action/ListActions.ts +6 -2
- package/src/Authentication/KeyAuthentication.ts +7 -3
- package/src/Authentication/TokenAuthentication.ts +2 -1
- package/src/Authentication/index.ts +2 -1
- package/src/Channel/ListChannels.ts +20 -3
- package/src/Client/index.ts +2 -0
- package/src/Contact/GetContact.ts +1 -0
- package/src/Contact/ListContacts.ts +1 -0
- package/src/Conversation/GetConversation.ts +1 -0
- package/src/Conversation/ListConversations.ts +1 -0
- package/src/Conversation/UpdateConversation.ts +62 -0
- package/src/Label/CreateLabel.ts +1 -0
- package/src/Label/GetLabel.ts +1 -0
- package/src/Label/ListLabels.ts +1 -0
- package/src/Message/ListMessages.ts +7 -0
- package/src/Model/GetModel.ts +2 -2
- package/src/Model/ListModels.ts +2 -2
- package/src/Source/GetSource.ts +2 -1
- package/src/Source/ListSources.ts +2 -1
- package/src/__tests__/Authentication/KeyAuthentication.test.ts +79 -0
- package/src/__tests__/Authentication/TokenAuthentication.test.ts +79 -0
- package/src/cli/actions.ts +1 -1
- package/src/cli/channels.ts +1 -1
- package/src/cli/contacts.ts +1 -1
- package/src/cli/conversations.ts +1 -1
- package/src/cli/labels.ts +1 -1
- package/src/cli/messages.ts +1 -1
- package/src/cli/models.ts +1 -1
- package/src/cli/sources.ts +1 -1
- package/src/constants/index.ts +21 -0
- package/dist/chunk-BFO7RVLV.js +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var L=Object.defineProperty;var
|
|
1
|
+
"use strict";var L=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.prototype.hasOwnProperty;var re=(t,e)=>{for(var s in e)L(t,s,{get:e[s],enumerable:!0})},ie=(t,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ne(e))!oe.call(t,o)&&o!==s&&L(t,o,{get:()=>e[o],enumerable:!(n=se(e,o))||n.enumerable});return t};var pe=t=>ie(L({},"__esModule",{value:!0}),t);var ae={};re(ae,{Client:()=>i,DEFAULT_SUPPORT_BASE_URL:()=>I,KeyAuthentication:()=>a,PublicAuthentication:()=>l,TokenAuthentication:()=>c,default:()=>i});module.exports=pe(ae);var I="https://api.support.greatdetail.com",X={"X-Powered-By":"GDSupport/JavaScript"},Q="api-key",Z="SUPPORT_ACCESS_TOKEN",ee="SUPPORT_API_KEY",te="SUPPORT_KEY_NAME";var a=class t{static DEFAULT_NAME=Q;name;#e;constructor({name:e=process.env[te]??t.DEFAULT_NAME,key:s=process.env[ee]}={}){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 c=class{#e;constructor({token:e=process.env[Z]}={}){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 l=class{async filter(e){return e}};var d=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/actions",{...e,method:"GET"},s).then(n=>new U(n))}},U=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 v(n))}},v=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/contacts/"+encodeURIComponent(e),{...s,method:"GET"},n).then(o=>new N(o))}},N=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/contacts",{...e,method:"GET"},s).then(n=>new D(n))}},D=class{constructor(e){this.response=e}async result(){return this.response.json()}};var h=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 j(o))}},j=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 M(n))}},M=class{constructor(e){this.response=e}async result(){return this.response.json()}};var G=require("zod"),y=class t{constructor(e){this._client=e}static SCHEMA=G.z.object({hasEnded:G.z.boolean()});async send({id:e,body:s,request:n={},...o}){return this._client.send("/v1/conversations/"+encodeURIComponent(e),{...n,method:"POST",headers:{...n.headers,"Content-Type":"application/json"},body:JSON.stringify(t.SCHEMA.parse(s))},o).then(p=>new H(p))}},H=class{constructor(e){this.response=e}async result(){return this.response.json()}};var r=require("zod"),R=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 F(o))}},F=class{constructor(e){this.response=e}async result(){return this.response.json()}};var b=class{constructor(e){this._client=e}async send({id:e,request:s={},...n}){return this._client.send("/v1/labels/"+encodeURIComponent(e),{...s,method:"GET"},n).then(o=>new K(o))}},K=class{constructor(e){this.response=e}async result(){return this.response.json()}};var x=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 A=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/messages",{...e,method:"GET"},s).then(n=>new z(n))}},z=class{constructor(e){this.response=e}async result(){return this.response.json()}};var O=require("zod"),C=class t{constructor(e){this._client=e}static SCHEMA=O.z.object({input:O.z.string().max(65536),original:O.z.string().max(65536),correction:O.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(p=>new B(p))}},B=class{constructor(e){this.response=e}async result(){return this.response.json()}};var S=class{constructor(e){this._client=e}async send({id:e,request:s={},...n}){return this._client.send("/v1/models/"+encodeURIComponent(e),{...s,method:"GET"},n).then(o=>new k(o))}},k=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/models",{...e,method:"GET"},s).then(n=>new Y(n))}},Y=class{constructor(e){this.response=e}async result(){return this.response.json()}};var E=require("zod"),_=class t{constructor(e){this._client=e}static SCHEMA=E.z.array(E.z.object({role:E.z.enum(["user","assistant"]),content:E.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(p=>new J(p))}},J=class{constructor(e){this.response=e}async result(){return this.response.json()}};var T=class t{constructor(e=t.STANDARD_HEADERS){this._standardHeaders=e}static STANDARD_HEADERS=X;async filter(e){return{...e,headers:{...e.headers,...this._standardHeaders}}}};var w=class{constructor(e){this._client=e}async send({id:e,request:s={},...n}){return this._client.send("/v1/sources/"+encodeURIComponent(e),{...s,method:"GET"},n).then(o=>new $(o))}},$=class{constructor(e){this.response=e}async result(){return this.response.json()}};var q=class{constructor(e){this._client=e}async send({request:e={},...s}={}){return this._client.send("/v1/sources",{...e,method:"GET"},s).then(n=>new W(n))}},W=class{constructor(e){this.response=e}async result(){return this.response.json()}};var i=class t{static DEFAULT_BASE_URL=I;options;constructor(e,s={}){this.options={requestFilterables:[new T,e],baseURL:process.env.SUPPORT_BASE_URL??t.DEFAULT_BASE_URL,...s}}action={list:new d(this)};channel={list:new u(this)};contact={get:new m(this),list:new g(this)};conversation={get:new h(this),list:new f(this),update:new y(this)};label={create:new R(this),get:new b(this),list:new x(this)};message={list:new A(this)};model={get:new S(this),list:new P(this),response:{create:new _(this)},correction:{create:new C(this)}};source={get:new w(this),list:new q(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});
|