@great-detail/support-sdk 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-IXJNWCJL.js → chunk-3OAKTXT5.js} +1 -1
- package/dist/{chunk-SRYAEALQ.js → chunk-QJODVR4A.js} +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +76 -1
- package/dist/index.d.ts +76 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/Error/index.ts +9 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
var _t=Object.defineProperty;var Pt=(e,t)=>{for(var s in t)_t(e,s,{get:t[s],enumerable:!0})};var yt="https://api.support.greatdetail.com",Rt={"X-Powered-By":"GDSupport/JavaScript"},Et="api-key";var p=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"}).then(s=>new V(s))}},V=class{constructor(t){this.response=t}async result(){return this.response.json()}};var c=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"}).then(s=>new J(s))}},J=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as u}from"zod";var d=class e{constructor(t){this._transport=t}static SCHEMA=u.object({name:u.string(),account:u.string(),emailAddress:u.string().email().optional(),telephoneNumber:u.string().optional()});async send({body:t,request:s={}}){return this._transport.send("v1/contacts",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(t))}).then(r=>new K(r))}},K=class{constructor(t){this.response=t}async result(){return this.response.json()}};var l=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new k(r))}},k=class{constructor(t){this.response=t}async result(){return this.response.json()}};var m=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"}).then(s=>new Y(s))}},Y=class{constructor(t){this.response=t}async result(){return this.response.json()}};var g=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...s,method:"GET"}).then(r=>new $(r))}},$=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as D}from"zod";var h=class e{constructor(t){this._transport=t}static SCHEMA=D.object({name:D.string().optional(),emailAddress:D.string().email().optional(),telephoneNumber:D.string().optional()});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new W(n))}},W=class{constructor(t){this.response=t}async result(){return this.response.json()}};var f=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new X(r))}},X=class{constructor(t){this.response=t}async result(){return this.response.json()}};var b=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/conversations",{...t,method:"GET"}).then(s=>new Q(s))}},Q=class{constructor(t){this.response=t}async result(){return this.response.json()}};var y=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...s,method:"GET"}).then(r=>new Z(r))}},Z=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as xt}from"zod";var R=class e{constructor(t){this._transport=t}static SCHEMA=xt.object({hasEnded:xt.boolean()});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new tt(n))}},tt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as G}from"zod";var x=class e{constructor(t){this._transport=t}static SCHEMA=G.object({title:G.string(),description:G.string().optional(),account:G.string()});async send({body:t,request:s={}}){return this._transport.send("v1/labels",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(t))}).then(r=>new et(r))}},et=class{constructor(t){this.response=t}async result(){return this.response.json()}};var A=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...s,method:"DELETE"}).then(r=>new st(r))}},st=class{constructor(t){this.response=t}async result(){return this.response.json()}};var T=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new rt(r))}},rt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var _=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"}).then(s=>new nt(s))}},nt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as ot}from"zod";var C=class e{constructor(t){this._transport=t}static SCHEMA=ot.object({title:ot.string().optional(),description:ot.string().optional()});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new it(n))}},it=class{constructor(t){this.response=t}async result(){return this.response.json()}};var P=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET"}).then(r=>new at(r))}},at=class{constructor(t){this.response=t}async result(){return this.response.json()}};var S=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"}).then(s=>new pt(s))}},pt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z}from"zod";var E=class e{constructor(t){this._transport=t}static SCHEMA=z.object({input:z.string().max(65536),original:z.string().max(65536),correction:z.string().max(65536)});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new ct(n))}},ct=class{constructor(t){this.response=t}async result(){return this.response.json()}};var v=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new ut(r))}},ut=class{constructor(t){this.response=t}async result(){return this.response.json()}};var w=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"}).then(s=>new dt(s))}},dt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as B}from"zod";var O=class e{constructor(t){this._transport=t}static SCHEMA=B.array(B.object({role:B.enum(["user","assistant"]),content:B.string().max(65536).nullable()})).min(1);async send({id:t,body:s,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new lt(n))}},lt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var F=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new mt(r))}},mt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var U=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/sources",{...t,method:"GET"}).then(s=>new gt(s))}},gt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var ie="SUPPORT_ACCESS_TOKEN",ae="SUPPORT_API_KEY",pe="SUPPORT_KEY_NAME",At="SUPPORT_BASE_URL";var q=class{constructor(t){this._transport=t}getURL({id:t,vcf:s={}}){let r=s.variant??"vcard",n=s.format??(s.variant==="vcard"?"vcf":"json");return this._transport.getURL("v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(r)+"&format="+encodeURIComponent(n))}};var I=class e{constructor(t=e.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Rt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};import Ct from"is-network-error";var o=class extends Error{};var i=class extends o{};var L=class extends i{static unauthenticated(){return new this("An unauthenticated request occurred")}};var j=class extends i{static forbidden(){return new this("A forbidden request occurred")}};var a=class extends o{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,s){return new this(`Forbidden method for request: ${t} ${s}`)}};var H=class extends o{};var N=class extends o{static badRequest(){return new this("Bad request")}};var M=class{options;constructor({baseURL:t,fetch:s=fetch,...r}){this.options={...r,fetch:s,baseURL:t}}getURL(t){return new URL(t,this.options.baseURL).toString()}getRequest(t,s){s.headers=new Headers(s.headers);for(let r of this.options.requestFilterables){let n=r.getHeaders();for(let[bt,Tt]of Object.entries(n))s.headers.set(bt,Tt)}return new Request(this.getURL(t),s)}async send(t,s){return await this.options.fetch(this.getRequest(t,s)).then(r=>{if(!r.ok){let n=r.status;switch(console.error(JSON.stringify(r)),n){case 400:throw N.badRequest();case 401:throw L.unauthenticated();case 403:throw j.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,s.method??"GET")}}return r}).catch(r=>{throw Ct(r)?new H("A network error occurred",{cause:r}):r})}};var ht=class e{static DEFAULT_BASE_URL=yt;_transport;constructor(t,{baseURL:s,...r}={}){this._transport=new M({requestFilterables:[new I,t],...r,baseURL:s?.toString()??e.getBaseURL()})}static getBaseURL(){return process.env[At]??this.DEFAULT_BASE_URL}get action(){return{list:new p(this._transport)}}get channel(){return{list:new c(this._transport)}}get contact(){return{get:new l(this._transport),list:new m(this._transport),update:new h(this._transport),create:new d(this._transport),vcf:{get:new q(this._transport)}}}get conversation(){return{get:new f(this._transport),list:new b(this._transport),update:new R(this._transport),message:{list:new P(this._transport)}}}get label(){return{create:new x(this._transport),get:new T(this._transport),list:new _(this._transport),update:new C(this._transport),delete:new A(this._transport),contact:{list:new g(this._transport)},conversation:{list:new y(this._transport)}}}get message(){return{list:new S(this._transport)}}get model(){return{get:new v(this._transport),list:new w(this._transport),response:{create:new O(this._transport)},correction:{create:new E(this._transport)}}}get source(){return{get:new F(this._transport),list:new U(this._transport)}}};var ft=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};export{Pt as a,yt as b,Et as c,ie as d,ae as e,pe as f,o as g,H as h,ht as i,ft as j};
|
|
1
|
+
var _t=Object.defineProperty;var Pt=(e,t)=>{for(var s in t)_t(e,s,{get:t[s],enumerable:!0})};var yt="https://api.support.greatdetail.com",Rt={"X-Powered-By":"GDSupport/JavaScript"},Et="api-key";var p=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"}).then(s=>new V(s))}},V=class{constructor(t){this.response=t}async result(){return this.response.json()}};var c=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"}).then(s=>new J(s))}},J=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as u}from"zod";var d=class e{constructor(t){this._transport=t}static SCHEMA=u.object({name:u.string(),account:u.string(),emailAddress:u.string().email().optional(),telephoneNumber:u.string().optional()});async send({body:t,request:s={}}){return this._transport.send("v1/contacts",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(t))}).then(r=>new K(r))}},K=class{constructor(t){this.response=t}async result(){return this.response.json()}};var l=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new k(r))}},k=class{constructor(t){this.response=t}async result(){return this.response.json()}};var m=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"}).then(s=>new Y(s))}},Y=class{constructor(t){this.response=t}async result(){return this.response.json()}};var g=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...s,method:"GET"}).then(r=>new $(r))}},$=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as D}from"zod";var h=class e{constructor(t){this._transport=t}static SCHEMA=D.object({name:D.string().optional(),emailAddress:D.string().email().optional(),telephoneNumber:D.string().optional()});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new W(n))}},W=class{constructor(t){this.response=t}async result(){return this.response.json()}};var f=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new X(r))}},X=class{constructor(t){this.response=t}async result(){return this.response.json()}};var b=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/conversations",{...t,method:"GET"}).then(s=>new Q(s))}},Q=class{constructor(t){this.response=t}async result(){return this.response.json()}};var y=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...s,method:"GET"}).then(r=>new Z(r))}},Z=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as xt}from"zod";var R=class e{constructor(t){this._transport=t}static SCHEMA=xt.object({hasEnded:xt.boolean()});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new tt(n))}},tt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as G}from"zod";var x=class e{constructor(t){this._transport=t}static SCHEMA=G.object({title:G.string(),description:G.string().optional(),account:G.string()});async send({body:t,request:s={}}){return this._transport.send("v1/labels",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(t))}).then(r=>new et(r))}},et=class{constructor(t){this.response=t}async result(){return this.response.json()}};var A=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...s,method:"DELETE"}).then(r=>new st(r))}},st=class{constructor(t){this.response=t}async result(){return this.response.json()}};var T=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new rt(r))}},rt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var _=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"}).then(s=>new nt(s))}},nt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as ot}from"zod";var C=class e{constructor(t){this._transport=t}static SCHEMA=ot.object({title:ot.string().optional(),description:ot.string().optional()});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new it(n))}},it=class{constructor(t){this.response=t}async result(){return this.response.json()}};var P=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET"}).then(r=>new at(r))}},at=class{constructor(t){this.response=t}async result(){return this.response.json()}};var S=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"}).then(s=>new pt(s))}},pt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z}from"zod";var E=class e{constructor(t){this._transport=t}static SCHEMA=z.object({input:z.string().max(65536),original:z.string().max(65536),correction:z.string().max(65536)});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new ct(n))}},ct=class{constructor(t){this.response=t}async result(){return this.response.json()}};var v=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new ut(r))}},ut=class{constructor(t){this.response=t}async result(){return this.response.json()}};var w=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"}).then(s=>new dt(s))}},dt=class{constructor(t){this.response=t}async result(){return this.response.json()}};import{z as B}from"zod";var O=class e{constructor(t){this._transport=t}static SCHEMA=B.array(B.object({role:B.enum(["user","assistant"]),content:B.string().max(65536).nullable()})).min(1);async send({id:t,body:s,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(n=>new lt(n))}},lt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var F=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new mt(r))}},mt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var U=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/sources",{...t,method:"GET"}).then(s=>new gt(s))}},gt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var ie="SUPPORT_ACCESS_TOKEN",ae="SUPPORT_API_KEY",pe="SUPPORT_KEY_NAME",At="SUPPORT_BASE_URL";var q=class{constructor(t){this._transport=t}getURL({id:t,vcf:s={}}){let r=s.variant??"vcard",n=s.format??(s.variant==="vcard"?"vcf":"json");return this._transport.getURL("v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(r)+"&format="+encodeURIComponent(n))}};var I=class e{constructor(t=e.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Rt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};import Ct from"is-network-error";var o=class extends Error{};var i=class extends o{};var L=class extends i{static unauthenticated(){return new this("An unauthenticated request occurred")}};var j=class extends i{static forbidden(){return new this("A forbidden request occurred")}};var a=class extends o{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,s){return new this(`Forbidden method for request: ${t} ${s}`)}};var H=class extends o{};var N=class extends o{static badRequest(){return new this("Bad request")}};var M=class{options;constructor({baseURL:t,fetch:s=fetch,...r}){this.options={...r,fetch:s,baseURL:t}}getURL(t){return new URL(t,this.options.baseURL).toString()}getRequest(t,s){s.headers=new Headers(s.headers);for(let r of this.options.requestFilterables){let n=r.getHeaders();for(let[bt,Tt]of Object.entries(n))s.headers.set(bt,Tt)}return new Request(this.getURL(t),s)}async send(t,s){return await this.options.fetch(this.getRequest(t,s)).then(r=>{if(!r.ok){let n=r.status;switch(console.error(JSON.stringify(r)),n){case 400:throw N.badRequest();case 401:throw L.unauthenticated();case 403:throw j.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,s.method??"GET")}}return r}).catch(r=>{throw Ct(r)?new H("A network error occurred",{cause:r}):r})}};var ht=class e{static DEFAULT_BASE_URL=yt;_transport;constructor(t,{baseURL:s,...r}={}){this._transport=new M({requestFilterables:[new I,t],...r,baseURL:s?.toString()??e.getBaseURL()})}static getBaseURL(){return process.env[At]??this.DEFAULT_BASE_URL}get action(){return{list:new p(this._transport)}}get channel(){return{list:new c(this._transport)}}get contact(){return{get:new l(this._transport),list:new m(this._transport),update:new h(this._transport),create:new d(this._transport),vcf:{get:new q(this._transport)}}}get conversation(){return{get:new f(this._transport),list:new b(this._transport),update:new R(this._transport),message:{list:new P(this._transport)}}}get label(){return{create:new x(this._transport),get:new T(this._transport),list:new _(this._transport),update:new C(this._transport),delete:new A(this._transport),contact:{list:new g(this._transport)},conversation:{list:new y(this._transport)}}}get message(){return{list:new S(this._transport)}}get model(){return{get:new v(this._transport),list:new w(this._transport),response:{create:new O(this._transport)},correction:{create:new E(this._transport)}}}get source(){return{get:new F(this._transport),list:new U(this._transport)}}};var ft=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};export{Pt as a,yt as b,Et as c,ie as d,ae as e,pe as f,o as g,i as h,L as i,j,a as k,H as l,N as m,ht as n,ft as o};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as y,o as F}from"./chunk-3OAKTXT5.js";import{Command as A}from"commander";import{Command as b}from"commander";import{oraPromise as I}from"ora";function m({client:n,ora:s}){let o=new b("actions").description("Actions");return o.addCommand(new b("list").description("List actions").action(async()=>{let t=await I(()=>n.action.list.send(),{...s,text:"Finding actions"});console.log(await t.result())})),o}import{Command as v}from"commander";import{oraPromise as S}from"ora";function r({client:n,ora:s}){let o=new v("channels").description("Channels");return o.addCommand(new v("list").description("List channels").action(async()=>{let t=await S(()=>n.channel.list.send(),{...s,text:"Finding channels"});console.log(await t.result())})),o}import{Command as d}from"commander";import{oraPromise as L}from"ora";function c({client:n,ora:s}){let o=new d("contacts").description("Contacts");return o.addCommand(new d("get").description("Find contact").argument("<contact>","Contact ID").action(async t=>{let e=await L(()=>n.contact.get.send({id:t}),{...s,text:"Finding contact"});console.log(await e.result())})),o.addCommand(new d("list").description("List contacts").action(async()=>{let t=await L(()=>n.contact.list.send(),{...s,text:"Finding contacts"});console.log(await t.result())})),o}import{Command as p}from"commander";import{oraPromise as P}from"ora";function l({client:n,ora:s}){let o=new p("conversations").description("Conversations");return o.addCommand(new p("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async t=>{let e=await P(()=>n.conversation.get.send({id:t}),{...s,text:"Finding conversation"});console.log(await e.result())})),o.addCommand(new p("list").description("List conversations").action(async()=>{let t=await P(()=>n.conversation.list.send(),{...s,text:"Finding conversations"});console.log(await t.result())})),o}import{Command as a}from"commander";import{oraPromise as u}from"ora";function f({client:n,ora:s}){let o=new a("labels").description("Labels");return o.addCommand(new a("get").description("Find label").argument("<label>","Label ID").action(async t=>{let e=await u(()=>n.label.get.send({id:t}),{...s,text:"Finding label"});console.log(await e.result())})),o.addCommand(new a("list").description("List labels").action(async()=>{let t=await u(()=>n.label.list.send(),{...s,text:"Finding labels"});console.log(await t.result())})),o.addCommand(new a("conversations").description("Find label conversations").argument("<label>","Label ID").action(async t=>{let e=await u(()=>n.label.conversation.list.send({id:t}),{...s,text:"Finding conversations"});console.log(await e.result())})),o}import{Command as h}from"commander";import{oraPromise as M}from"ora";function C({client:n,ora:s}){let o=new h("messages").description("Messages");return o.addCommand(new h("list").description("List messages").action(async()=>{let t=await M(()=>n.message.list.send(),{...s,text:"Finding messages"});console.log(await t.result())})),o}import{Command as g}from"commander";import{oraPromise as j}from"ora";function w({client:n,ora:s}){let o=new g("models").description("Models");return o.addCommand(new g("get").description("Find model").argument("<model>","Model ID").action(async t=>{let e=await j(()=>n.model.get.send({id:t}),{...s,text:"Finding model"});console.log(await e.result())})),o.addCommand(new g("list").description("List models").action(async()=>{let t=await j(()=>n.model.list.send(),{...s,text:"Finding models"});console.log(await t.result())})),o}import{Command as O}from"commander";import{oraPromise as D}from"ora";function x({client:n,ora:s}){let o=new O("sources").description("Sources");return o.addCommand(new O("get").description("Find source").argument("<source>","Source ID").action(async t=>{let e=await D(()=>n.source.get.send({id:t}),{...s,text:"Finding source"});console.log(await e.result())})),o.addCommand(new O("list").description("List sources").action(async()=>{let t=await D(()=>n.source.list.send(),{...s,text:"Finding sources"});console.log(await t.result())})),o}var i={ora:{spinner:"simpleDotsScrolling"},client:new y(new F)},G=new A("gds").description("Great Detail Support System").addCommand(m(i)).addCommand(r(i)).addCommand(c(i)).addCommand(l(i)).addCommand(f(i)).addCommand(C(i)).addCommand(w(i)).addCommand(x(i)),go=G;export{go as a};
|
package/dist/cli/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-QJODVR4A.js";import"../chunk-3OAKTXT5.js";export{a as default};
|
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as r}from"./chunk-
|
|
2
|
+
import{a as r}from"./chunk-QJODVR4A.js";import"./chunk-3OAKTXT5.js";r.parseAsync(process.argv);
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var qt=Object.create;var Y=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Nt=Object.getPrototypeOf,Ht=Object.prototype.hasOwnProperty;var Pt=(e,t)=>{for(var s in t)Y(e,s,{get:t[s],enumerable:!0})},Ct=(e,t,s,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of jt(t))!Ht.call(e,o)&&o!==s&&Y(e,o,{get:()=>t[o],enumerable:!(r=It(t,o))||r.enumerable});return e};var Mt=(e,t,s)=>(s=e!=null?qt(Nt(e)):{},Ct(t||!e||!e.__esModule?Y(s,"default",{value:e,enumerable:!0}):s,e)),Dt=e=>Ct(Y({},"__esModule",{value:!0}),e);var Gt={};Pt(Gt,{Client:()=>d,DEFAULT_SUPPORT_BASE_URL:()=>$,Error:()=>_t,KeyAuthentication:()=>K,PublicAuthentication:()=>J,TokenAuthentication:()=>k,default:()=>d});module.exports=Dt(Gt);var $="https://api.support.greatdetail.com",Et={"X-Powered-By":"GDSupport/JavaScript"},St="api-key";var u=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"}).then(s=>new X(s))}},X=class{constructor(t){this.response=t}async result(){return this.response.json()}};var l=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"}).then(s=>new Q(s))}},Q=class{constructor(t){this.response=t}async result(){return this.response.json()}};var vt="SUPPORT_ACCESS_TOKEN",wt="SUPPORT_API_KEY",Ot="SUPPORT_KEY_NAME",Lt="SUPPORT_BASE_URL";var m=class{constructor(t){this._transport=t}getURL({id:t,vcf:s={}}){let r=s.variant??"vcard",o=s.format??(s.variant==="vcard"?"vcf":"json");return this._transport.getURL("v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(r)+"&format="+encodeURIComponent(o))}};var p=require("zod"),g=class e{constructor(t){this._transport=t}static SCHEMA=p.z.object({name:p.z.string(),account:p.z.string(),emailAddress:p.z.string().email().optional(),telephoneNumber:p.z.string().optional()});async send({body:t,request:s={}}){return this._transport.send("v1/contacts",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(t))}).then(r=>new Z(r))}},Z=class{constructor(t){this.response=t}async result(){return this.response.json()}};var h=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new tt(r))}},tt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var f=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"}).then(s=>new et(s))}},et=class{constructor(t){this.response=t}async result(){return this.response.json()}};var y=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...s,method:"GET"}).then(r=>new st(r))}},st=class{constructor(t){this.response=t}async result(){return this.response.json()}};var b=require("zod"),R=class e{constructor(t){this._transport=t}static SCHEMA=b.z.object({name:b.z.string().optional(),emailAddress:b.z.string().email().optional(),telephoneNumber:b.z.string().optional()});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(o=>new rt(o))}},rt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var x=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new ot(r))}},ot=class{constructor(t){this.response=t}async result(){return this.response.json()}};var A=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/conversations",{...t,method:"GET"}).then(s=>new nt(s))}},nt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var _=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...s,method:"GET"}).then(r=>new it(r))}},it=class{constructor(t){this.response=t}async result(){return this.response.json()}};var at=require("zod"),T=class e{constructor(t){this._transport=t}static SCHEMA=at.z.object({hasEnded:at.z.boolean()});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(o=>new pt(o))}},pt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var P=require("zod"),C=class e{constructor(t){this._transport=t}static SCHEMA=P.z.object({title:P.z.string(),description:P.z.string().optional(),account:P.z.string()});async send({body:t,request:s={}}){return this._transport.send("v1/labels",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(t))}).then(r=>new ct(r))}},ct=class{constructor(t){this.response=t}async result(){return this.response.json()}};var E=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...s,method:"DELETE"}).then(r=>new dt(r))}},dt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var S=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new ut(r))}},ut=class{constructor(t){this.response=t}async result(){return this.response.json()}};var v=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"}).then(s=>new lt(s))}},lt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var W=require("zod"),w=class e{constructor(t){this._transport=t}static SCHEMA=W.z.object({title:W.z.string().optional(),description:W.z.string().optional()});async send({id:t,body:s,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...r,method:"PATCH",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(o=>new mt(o))}},mt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var O=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET"}).then(r=>new gt(r))}},gt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var L=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"}).then(s=>new ht(s))}},ht=class{constructor(t){this.response=t}async result(){return this.response.json()}};var F=require("zod"),U=class e{constructor(t){this._transport=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:s,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(o=>new ft(o))}},ft=class{constructor(t){this.response=t}async result(){return this.response.json()}};var q=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new yt(r))}},yt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var I=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"}).then(s=>new bt(s))}},bt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var j=require("zod"),N=class e{constructor(t){this._transport=t}static SCHEMA=j.z.array(j.z.object({role:j.z.enum(["user","assistant"]),content:j.z.string().max(65536).nullable()})).min(1);async send({id:t,body:s,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(s))}).then(o=>new Rt(o))}},Rt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var H=class e{constructor(t=e.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Et;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var M=class{constructor(t){this._transport=t}async send({id:t,request:s={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...s,method:"GET"}).then(r=>new xt(r))}},xt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var D=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/sources",{...t,method:"GET"}).then(s=>new At(s))}},At=class{constructor(t){this.response=t}async result(){return this.response.json()}};var Ft=Mt(require("is-network-error"),1);var n=class extends Error{};var i=class extends n{};var G=class extends i{static unauthenticated(){return new this("An unauthenticated request occurred")}};var V=class extends i{static forbidden(){return new this("A forbidden request occurred")}};var c=class extends n{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,s){return new this(`Forbidden method for request: ${t} ${s}`)}};var a=class extends n{};var z=class extends n{static badRequest(){return new this("Bad request")}};var B=class{options;constructor({baseURL:t,fetch:s=fetch,...r}){this.options={...r,fetch:s,baseURL:t}}getURL(t){return new URL(t,this.options.baseURL).toString()}getRequest(t,s){s.headers=new Headers(s.headers);for(let r of this.options.requestFilterables){let o=r.getHeaders();for(let[Tt,Ut]of Object.entries(o))s.headers.set(Tt,Ut)}return new Request(this.getURL(t),s)}async send(t,s){return await this.options.fetch(this.getRequest(t,s)).then(r=>{if(!r.ok){let o=r.status;switch(console.error(JSON.stringify(r)),o){case 400:throw z.badRequest();case 401:throw G.unauthenticated();case 403:throw V.forbidden();case 404:throw c.notFound(t);case 405:throw c.forbiddenMethod(t,s.method??"GET")}}return r}).catch(r=>{throw(0,Ft.default)(r)?new a("A network error occurred",{cause:r}):r})}};var d=class e{static DEFAULT_BASE_URL=$;_transport;constructor(t,{baseURL:s,...r}={}){this._transport=new B({requestFilterables:[new H,t],...r,baseURL:s?.toString()??e.getBaseURL()})}static getBaseURL(){return process.env[Lt]??this.DEFAULT_BASE_URL}get action(){return{list:new u(this._transport)}}get channel(){return{list:new l(this._transport)}}get contact(){return{get:new h(this._transport),list:new f(this._transport),update:new R(this._transport),create:new g(this._transport),vcf:{get:new m(this._transport)}}}get conversation(){return{get:new x(this._transport),list:new A(this._transport),update:new T(this._transport),message:{list:new O(this._transport)}}}get label(){return{create:new C(this._transport),get:new S(this._transport),list:new v(this._transport),update:new w(this._transport),delete:new E(this._transport),contact:{list:new y(this._transport)},conversation:{list:new _(this._transport)}}}get message(){return{list:new L(this._transport)}}get model(){return{get:new q(this._transport),list:new I(this._transport),response:{create:new N(this._transport)},correction:{create:new U(this._transport)}}}get source(){return{get:new M(this._transport),list:new D(this._transport)}}};var _t={};Pt(_t,{NetworkError:()=>a,SupportError:()=>n});var K=class e{static DEFAULT_NAME=St;name;#t;constructor({name:t=process.env[Ot]??e.DEFAULT_NAME,key:s=process.env[wt]}={}){if(!s)throw new Error("API Key option must be specified when using Key Authentication");this.name=t,this.#t=s}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var k=class{#t;constructor({token:t=process.env[vt]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var J=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,Error,KeyAuthentication,PublicAuthentication,TokenAuthentication});
|
|
1
|
+
"use strict";var qt=Object.create;var Y=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Nt=Object.getPrototypeOf,Ht=Object.prototype.hasOwnProperty;var Pt=(e,t)=>{for(var r in t)Y(e,r,{get:t[r],enumerable:!0})},Ct=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of jt(t))!Ht.call(e,o)&&o!==r&&Y(e,o,{get:()=>t[o],enumerable:!(s=It(t,o))||s.enumerable});return e};var Mt=(e,t,r)=>(r=e!=null?qt(Nt(e)):{},Ct(t||!e||!e.__esModule?Y(r,"default",{value:e,enumerable:!0}):r,e)),Dt=e=>Ct(Y({},"__esModule",{value:!0}),e);var Gt={};Pt(Gt,{Client:()=>m,DEFAULT_SUPPORT_BASE_URL:()=>$,Error:()=>_t,KeyAuthentication:()=>K,PublicAuthentication:()=>J,TokenAuthentication:()=>k,default:()=>m});module.exports=Dt(Gt);var $="https://api.support.greatdetail.com",Et={"X-Powered-By":"GDSupport/JavaScript"},St="api-key";var h=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/actions",{...t,method:"GET"}).then(r=>new X(r))}},X=class{constructor(t){this.response=t}async result(){return this.response.json()}};var g=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/channels",{...t,method:"GET"}).then(r=>new Q(r))}},Q=class{constructor(t){this.response=t}async result(){return this.response.json()}};var vt="SUPPORT_ACCESS_TOKEN",wt="SUPPORT_API_KEY",Ot="SUPPORT_KEY_NAME",Lt="SUPPORT_BASE_URL";var f=class{constructor(t){this._transport=t}getURL({id:t,vcf:r={}}){let s=r.variant??"vcard",o=r.format??(r.variant==="vcard"?"vcf":"json");return this._transport.getURL("v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(s)+"&format="+encodeURIComponent(o))}};var l=require("zod"),y=class e{constructor(t){this._transport=t}static SCHEMA=l.z.object({name:l.z.string(),account:l.z.string(),emailAddress:l.z.string().email().optional(),telephoneNumber:l.z.string().optional()});async send({body:t,request:r={}}){return this._transport.send("v1/contacts",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(t))}).then(s=>new Z(s))}},Z=class{constructor(t){this.response=t}async result(){return this.response.json()}};var b=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new tt(s))}},tt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var R=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/contacts",{...t,method:"GET"}).then(r=>new et(r))}},et=class{constructor(t){this.response=t}async result(){return this.response.json()}};var x=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...r,method:"GET"}).then(s=>new rt(s))}},rt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var A=require("zod"),_=class e{constructor(t){this._transport=t}static SCHEMA=A.z.object({name:A.z.string().optional(),emailAddress:A.z.string().email().optional(),telephoneNumber:A.z.string().optional()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(o=>new st(o))}},st=class{constructor(t){this.response=t}async result(){return this.response.json()}};var T=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new ot(s))}},ot=class{constructor(t){this.response=t}async result(){return this.response.json()}};var P=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/conversations",{...t,method:"GET"}).then(r=>new nt(r))}},nt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var C=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...r,method:"GET"}).then(s=>new it(s))}},it=class{constructor(t){this.response=t}async result(){return this.response.json()}};var at=require("zod"),E=class e{constructor(t){this._transport=t}static SCHEMA=at.z.object({hasEnded:at.z.boolean()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t),{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(o=>new pt(o))}},pt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var S=require("zod"),v=class e{constructor(t){this._transport=t}static SCHEMA=S.z.object({title:S.z.string(),description:S.z.string().optional(),account:S.z.string()});async send({body:t,request:r={}}){return this._transport.send("v1/labels",{...r,method:"POST",headers:{...r.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(t))}).then(s=>new ct(s))}},ct=class{constructor(t){this.response=t}async result(){return this.response.json()}};var w=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...r,method:"DELETE"}).then(s=>new dt(s))}},dt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var O=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new ut(s))}},ut=class{constructor(t){this.response=t}async result(){return this.response.json()}};var L=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/labels",{...t,method:"GET"}).then(r=>new lt(r))}},lt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var W=require("zod"),F=class e{constructor(t){this._transport=t}static SCHEMA=W.z.object({title:W.z.string().optional(),description:W.z.string().optional()});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...s,method:"PATCH",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(o=>new mt(o))}},mt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var U=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...r,method:"GET"}).then(s=>new ht(s))}},ht=class{constructor(t){this.response=t}async result(){return this.response.json()}};var q=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/messages",{...t,method:"GET"}).then(r=>new gt(r))}},gt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var I=require("zod"),j=class e{constructor(t){this._transport=t}static SCHEMA=I.z.object({input:I.z.string().max(65536),original:I.z.string().max(65536),correction:I.z.string().max(65536)});async send({id:t,body:r,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(o=>new ft(o))}},ft=class{constructor(t){this.response=t}async result(){return this.response.json()}};var N=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new yt(s))}},yt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var H=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"}).then(r=>new bt(r))}},bt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var M=require("zod"),D=class e{constructor(t){this._transport=t}static SCHEMA=M.z.array(M.z.object({role:M.z.enum(["user","assistant"]),content:M.z.string().max(65536).nullable()})).min(1);async send({id:t,body:r,request:s={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...s,method:"POST",headers:{...s.headers,"Content-Type":"application/json"},body:JSON.stringify(e.SCHEMA.parse(r))}).then(o=>new Rt(o))}},Rt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var G=class e{constructor(t=e.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Et;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var V=class{constructor(t){this._transport=t}async send({id:t,request:r={}}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...r,method:"GET"}).then(s=>new xt(s))}},xt=class{constructor(t){this.response=t}async result(){return this.response.json()}};var z=class{constructor(t){this._transport=t}async send({request:t={}}={}){return this._transport.send("v1/sources",{...t,method:"GET"}).then(r=>new At(r))}},At=class{constructor(t){this.response=t}async result(){return this.response.json()}};var Ft=Mt(require("is-network-error"),1);var n=class extends Error{};var i=class extends n{};var p=class extends i{static unauthenticated(){return new this("An unauthenticated request occurred")}};var c=class extends i{static forbidden(){return new this("A forbidden request occurred")}};var a=class extends n{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,r){return new this(`Forbidden method for request: ${t} ${r}`)}};var d=class extends n{};var u=class extends n{static badRequest(){return new this("Bad request")}};var B=class{options;constructor({baseURL:t,fetch:r=fetch,...s}){this.options={...s,fetch:r,baseURL:t}}getURL(t){return new URL(t,this.options.baseURL).toString()}getRequest(t,r){r.headers=new Headers(r.headers);for(let s of this.options.requestFilterables){let o=s.getHeaders();for(let[Tt,Ut]of Object.entries(o))r.headers.set(Tt,Ut)}return new Request(this.getURL(t),r)}async send(t,r){return await this.options.fetch(this.getRequest(t,r)).then(s=>{if(!s.ok){let o=s.status;switch(console.error(JSON.stringify(s)),o){case 400:throw u.badRequest();case 401:throw p.unauthenticated();case 403:throw c.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,r.method??"GET")}}return s}).catch(s=>{throw(0,Ft.default)(s)?new d("A network error occurred",{cause:s}):s})}};var m=class e{static DEFAULT_BASE_URL=$;_transport;constructor(t,{baseURL:r,...s}={}){this._transport=new B({requestFilterables:[new G,t],...s,baseURL:r?.toString()??e.getBaseURL()})}static getBaseURL(){return process.env[Lt]??this.DEFAULT_BASE_URL}get action(){return{list:new h(this._transport)}}get channel(){return{list:new g(this._transport)}}get contact(){return{get:new b(this._transport),list:new R(this._transport),update:new _(this._transport),create:new y(this._transport),vcf:{get:new f(this._transport)}}}get conversation(){return{get:new T(this._transport),list:new P(this._transport),update:new E(this._transport),message:{list:new U(this._transport)}}}get label(){return{create:new v(this._transport),get:new O(this._transport),list:new L(this._transport),update:new F(this._transport),delete:new w(this._transport),contact:{list:new x(this._transport)},conversation:{list:new C(this._transport)}}}get message(){return{list:new q(this._transport)}}get model(){return{get:new N(this._transport),list:new H(this._transport),response:{create:new D(this._transport)},correction:{create:new j(this._transport)}}}get source(){return{get:new V(this._transport),list:new z(this._transport)}}};var _t={};Pt(_t,{AuthError:()=>i,AuthenticationError:()=>p,AuthorizationError:()=>c,LogicError:()=>a,NetworkError:()=>d,SupportError:()=>n,ValidationError:()=>u});var K=class e{static DEFAULT_NAME=St;name;#t;constructor({name:t=process.env[Ot]??e.DEFAULT_NAME,key:r=process.env[wt]}={}){if(!r)throw new Error("API Key option must be specified when using Key Authentication");this.name=t,this.#t=r}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var k=class{#t;constructor({token:t=process.env[vt]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var J=class{async filter(){return{headers:this.getHeaders()}}getHeaders(){return{}}};0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,Error,KeyAuthentication,PublicAuthentication,TokenAuthentication});
|
package/dist/index.d.cts
CHANGED
|
@@ -49,12 +49,87 @@ declare class NetworkError extends SupportError {
|
|
|
49
49
|
* @see https://greatdetail.com
|
|
50
50
|
*/
|
|
51
51
|
|
|
52
|
+
declare class AuthError extends SupportError {
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Great Detail Support System.
|
|
57
|
+
*
|
|
58
|
+
* @copyright 2024 Great Detail Ltd
|
|
59
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
60
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
61
|
+
* @see https://greatdetail.com
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
declare class AuthenticationError extends AuthError {
|
|
65
|
+
static unauthenticated(): AuthenticationError;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Great Detail Support System.
|
|
70
|
+
*
|
|
71
|
+
* @copyright 2024 Great Detail Ltd
|
|
72
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
73
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
74
|
+
* @see https://greatdetail.com
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
declare class AuthorizationError extends AuthError {
|
|
78
|
+
static forbidden(): AuthorizationError;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Great Detail Support System.
|
|
83
|
+
*
|
|
84
|
+
* @copyright 2024 Great Detail Ltd
|
|
85
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
86
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
87
|
+
* @see https://greatdetail.com
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
declare class ValidationError extends SupportError {
|
|
91
|
+
static badRequest(): ValidationError;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Great Detail Support System.
|
|
96
|
+
*
|
|
97
|
+
* @copyright 2024 Great Detail Ltd
|
|
98
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
99
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
100
|
+
* @see https://greatdetail.com
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
declare class LogicError extends SupportError {
|
|
104
|
+
static notFound(url: string): LogicError;
|
|
105
|
+
static forbiddenMethod(method: string, url: string): LogicError;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Great Detail Support System.
|
|
110
|
+
*
|
|
111
|
+
* @copyright 2024 Great Detail Ltd
|
|
112
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
113
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
114
|
+
* @see https://greatdetail.com
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
type index_AuthError = AuthError;
|
|
118
|
+
declare const index_AuthError: typeof AuthError;
|
|
119
|
+
type index_AuthenticationError = AuthenticationError;
|
|
120
|
+
declare const index_AuthenticationError: typeof AuthenticationError;
|
|
121
|
+
type index_AuthorizationError = AuthorizationError;
|
|
122
|
+
declare const index_AuthorizationError: typeof AuthorizationError;
|
|
123
|
+
type index_LogicError = LogicError;
|
|
124
|
+
declare const index_LogicError: typeof LogicError;
|
|
52
125
|
type index_NetworkError = NetworkError;
|
|
53
126
|
declare const index_NetworkError: typeof NetworkError;
|
|
54
127
|
type index_SupportError = SupportError;
|
|
55
128
|
declare const index_SupportError: typeof SupportError;
|
|
129
|
+
type index_ValidationError = ValidationError;
|
|
130
|
+
declare const index_ValidationError: typeof ValidationError;
|
|
56
131
|
declare namespace index {
|
|
57
|
-
export { index_NetworkError as NetworkError, index_SupportError as SupportError };
|
|
132
|
+
export { index_AuthError as AuthError, index_AuthenticationError as AuthenticationError, index_AuthorizationError as AuthorizationError, index_LogicError as LogicError, index_NetworkError as NetworkError, index_SupportError as SupportError, index_ValidationError as ValidationError };
|
|
58
133
|
}
|
|
59
134
|
|
|
60
135
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -49,12 +49,87 @@ declare class NetworkError extends SupportError {
|
|
|
49
49
|
* @see https://greatdetail.com
|
|
50
50
|
*/
|
|
51
51
|
|
|
52
|
+
declare class AuthError extends SupportError {
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Great Detail Support System.
|
|
57
|
+
*
|
|
58
|
+
* @copyright 2024 Great Detail Ltd
|
|
59
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
60
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
61
|
+
* @see https://greatdetail.com
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
declare class AuthenticationError extends AuthError {
|
|
65
|
+
static unauthenticated(): AuthenticationError;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Great Detail Support System.
|
|
70
|
+
*
|
|
71
|
+
* @copyright 2024 Great Detail Ltd
|
|
72
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
73
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
74
|
+
* @see https://greatdetail.com
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
declare class AuthorizationError extends AuthError {
|
|
78
|
+
static forbidden(): AuthorizationError;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Great Detail Support System.
|
|
83
|
+
*
|
|
84
|
+
* @copyright 2024 Great Detail Ltd
|
|
85
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
86
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
87
|
+
* @see https://greatdetail.com
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
declare class ValidationError extends SupportError {
|
|
91
|
+
static badRequest(): ValidationError;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Great Detail Support System.
|
|
96
|
+
*
|
|
97
|
+
* @copyright 2024 Great Detail Ltd
|
|
98
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
99
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
100
|
+
* @see https://greatdetail.com
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
declare class LogicError extends SupportError {
|
|
104
|
+
static notFound(url: string): LogicError;
|
|
105
|
+
static forbiddenMethod(method: string, url: string): LogicError;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Great Detail Support System.
|
|
110
|
+
*
|
|
111
|
+
* @copyright 2024 Great Detail Ltd
|
|
112
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
113
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
114
|
+
* @see https://greatdetail.com
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
type index_AuthError = AuthError;
|
|
118
|
+
declare const index_AuthError: typeof AuthError;
|
|
119
|
+
type index_AuthenticationError = AuthenticationError;
|
|
120
|
+
declare const index_AuthenticationError: typeof AuthenticationError;
|
|
121
|
+
type index_AuthorizationError = AuthorizationError;
|
|
122
|
+
declare const index_AuthorizationError: typeof AuthorizationError;
|
|
123
|
+
type index_LogicError = LogicError;
|
|
124
|
+
declare const index_LogicError: typeof LogicError;
|
|
52
125
|
type index_NetworkError = NetworkError;
|
|
53
126
|
declare const index_NetworkError: typeof NetworkError;
|
|
54
127
|
type index_SupportError = SupportError;
|
|
55
128
|
declare const index_SupportError: typeof SupportError;
|
|
129
|
+
type index_ValidationError = ValidationError;
|
|
130
|
+
declare const index_ValidationError: typeof ValidationError;
|
|
56
131
|
declare namespace index {
|
|
57
|
-
export { index_NetworkError as NetworkError, index_SupportError as SupportError };
|
|
132
|
+
export { index_AuthError as AuthError, index_AuthenticationError as AuthenticationError, index_AuthorizationError as AuthorizationError, index_LogicError as LogicError, index_NetworkError as NetworkError, index_SupportError as SupportError, index_ValidationError as ValidationError };
|
|
58
133
|
}
|
|
59
134
|
|
|
60
135
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as A,b as P,c as a,d as p,e as n,f as i,g as f,h as l,i as m,j as y,k as d,l as u,m as c,n as x,o as h}from"./chunk-3OAKTXT5.js";var R={};A(R,{AuthError:()=>l,AuthenticationError:()=>m,AuthorizationError:()=>y,LogicError:()=>d,NetworkError:()=>u,SupportError:()=>f,ValidationError:()=>c});var t=class r{static DEFAULT_NAME=a;name;#e;constructor({name:e=process.env[i]??r.DEFAULT_NAME,key:s=process.env[n]}={}){if(!s)throw new Error("API Key option must be specified when using Key Authentication");this.name=e,this.#e=s}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Basic ${btoa(this.name+":"+this.#e)}`}}};var o=class{#e;constructor({token:e=process.env[p]}={}){if(!e)throw new Error("Access Token option must be specified when using Token Authentication");this.#e=e}async filter(){return{headers:this.getHeaders()}}getHeaders(){return{Authorization:`Bearer ${this.#e}`}}};export{x as Client,P as DEFAULT_SUPPORT_BASE_URL,R as Error,t as KeyAuthentication,h as PublicAuthentication,o as TokenAuthentication,x as default};
|
package/package.json
CHANGED
package/src/Error/index.ts
CHANGED
|
@@ -8,4 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export { default as SupportError } from "./SupportError.js";
|
|
11
|
+
|
|
11
12
|
export { default as NetworkError } from "./NetworkError.js";
|
|
13
|
+
|
|
14
|
+
export { default as AuthError } from "./AuthError.js";
|
|
15
|
+
export { default as AuthenticationError } from "./AuthenticationError.js";
|
|
16
|
+
export { default as AuthorizationError } from "./AuthorizationError.js";
|
|
17
|
+
|
|
18
|
+
export { default as ValidationError } from "./ValidationError.js";
|
|
19
|
+
|
|
20
|
+
export { default as LogicError } from "./LogicError.js";
|