@great-detail/support-sdk 0.25.0 → 0.26.0
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/index.cjs +1 -1
- package/dist/index.d.cts +4400 -8
- package/dist/index.d.ts +4400 -8
- package/dist/index.js +1 -1
- package/package.json +4 -23
- package/README.md +0 -80
- package/dist/Client-DE_bNRkN.d.cts +0 -4379
- package/dist/Client-DE_bNRkN.d.ts +0 -4379
- package/dist/chunk-RTRINZVE.js +0 -1
- package/dist/chunk-YQRKO6KD.js +0 -1
- package/dist/cli/index.cjs +0 -1
- package/dist/cli/index.d.cts +0 -20
- package/dist/cli/index.d.ts +0 -20
- package/dist/cli/index.js +0 -1
- package/dist/cli.cjs +0 -2
- package/dist/cli.d.cts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var pt=Object.create;var Y=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var ct=Object.getPrototypeOf,mt=Object.prototype.hasOwnProperty;var Z=(n,t)=>{for(var e in t)Y(n,e,{get:t[e],enumerable:!0})},tt=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of at(t))!mt.call(n,r)&&r!==e&&Y(n,r,{get:()=>t[r],enumerable:!(o=it(t,r))||o.enumerable});return n};var ut=(n,t,e)=>(e=n!=null?pt(ct(n)):{},tt(t||!n||!n.__esModule?Y(e,"default",{value:n,enumerable:!0}):e,n)),lt=n=>tt(Y({},"__esModule",{value:!0}),n);var Ot={};Z(Ot,{Client:()=>u,DEFAULT_SUPPORT_BASE_URL:()=>K,Error:()=>X,SDK_VERSION:()=>gt,SupportError:()=>c,WHATSAPP_BUSINESS_PROFILE_VERTICAL:()=>dt,WHATSAPP_TEMPLATE_CATEGORIES:()=>Ct,WHATSAPP_TEMPLATE_INDUSTRIES:()=>At,WHATSAPP_TEMPLATE_LANGUAGES:()=>ht,WHATSAPP_TEMPLATE_QUALITY_SCORES:()=>_t,WHATSAPP_TEMPLATE_STATUSES:()=>ft,WHATSAPP_TEMPLATE_SUBCATEGORIES:()=>Tt,WHATSAPP_TEMPLATE_TOPICS:()=>Et,WHATSAPP_TEMPLATE_USECASES:()=>Rt,default:()=>u,eventWebhookSchema:()=>J});module.exports=lt(Ot);var K="https://api.support.greatdetail.com",et={"x-powered-by":"GDS/JavaScript"};var l=class{constructor(t){this._transport=t}list({filter:t,pagination:e,request:o={}}={}){return this._transport.send("v1/accounts",{...o,method:"GET",searchParams:this._transport.query.build({pagination:e,filter:t})})}get(t,{request:e={}}={}){return this._transport.send(`v1/accounts/${encodeURIComponent(t)}`,{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send(`v1/accounts/${encodeURIComponent(t)}`,{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/accounts",{...e,method:"POST",json:t})}};var d=class{constructor(t){this._transport=t}get(t,e,{request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...o,method:"GET"})}list(t,{filter:e,pagination:o,request:r={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...r,method:"GET",searchParams:this._transport.query.build({pagination:o,filter:e})})}delete(t,e,{body:o,request:r={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...r,method:"DELETE",json:o})}create(t,{body:e={},request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...o,method:"POST",json:e})}};var f=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...o,method:"PATCH",json:e})}};var h=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notifications/events/account/"+encodeURIComponent(t),{...e,method:"GET"})}listByAccount(t,{filter:e,pagination:o,request:r={}}={}){return this._transport.send(`v1/accounts/${encodeURIComponent(t)}/notifications/events`,{...r,method:"GET",searchParams:this._transport.query.build({pagination:o,filter:e})})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notifications/events/account/"+encodeURIComponent(t),{...o,method:"PATCH",json:{...e,readAt:e.readAt instanceof Date&&typeof e.readAt.getMonth=="function"?e.readAt.toISOString():e.readAt}})}};var C=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send(`v1/actions/${encodeURIComponent(t)}`,{...e,method:"GET"})}list({filter:t,sort:e,pagination:o,request:r={}}={}){return this._transport.send("v1/actions",{...r,method:"GET",searchParams:this._transport.query.build({sort:e,pagination:o,filter:t})})}};var ot="SUPPORT_ACCESS_TOKEN",nt="SUPPORT_KEY_NAME",rt="SUPPORT_KEY_PASSWORD",Q="SUPPORT_SIGNING_KEY",st="SUPPORT_BASE_URL";var T=class{name;#t;constructor({name:t=process.env[nt],password:e=process.env[rt]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){let t=typeof this.name=="function"?this.name():this.name,e=typeof this.#t=="function"?this.#t():this.#t;return{Authorization:`Basic ${btoa(t+":"+e)}`}}};var A=class{#t;constructor({token:t=process.env[ot]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${typeof this.#t=="function"?this.#t():this.#t}`}}};var E=class{getHeaders(){return{}}};var R=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({filter:t,pagination:e,include:o,request:r={}}={}){return this._transport.send("v1/boilerplates/categories",{...r,method:"GET",searchParams:this._transport.query.build({include:o,pagination:e,filter:t})})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var _=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({filter:t,pagination:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:this._transport.query.build({pagination:e,filter:t})})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var g=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({filter:t,pagination:e,request:o={}}={}){return this._transport.send("v1/channels",{...o,method:"GET",searchParams:this._transport.query.build({pagination:e,filter:t})})}update(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"DELETE"})}sendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/sendgrid/sync",{...o,method:"POST",json:e})}};var O=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversation-settings",{...o,method:"PATCH",json:e})}};var b=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({filter:t,pagination:e,request:o={}}={}){return this._transport.send("v1/composition-sections",{...o,method:"GET",searchParams:this._transport.query.build({pagination:e,filter:t})})}create({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var I=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send(`v1/contacts/${encodeURIComponent(t)}`,{...o,method:"GET",searchParams:this._transport.query.build({include:e})})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",r=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(r)}getVCFURL(t,e={}){return this._transport.getURL(this.getRelativeVCFURL(t,e))}getVCF(t,e={}){return this._transport.send(this.getVCFURL(t,e),{method:"GET"})}list({pagination:t,filter:e,sort:o,request:r={}}={}){return this._transport.send("v1/contacts",{...r,method:"GET",searchParams:this._transport.query.build({pagination:t,sort:o,filter:e})})}create({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send(`v1/contacts/${encodeURIComponent(t)}`,{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send(`v1/contacts/${encodeURIComponent(t)}`,{...e,method:"DELETE"})}merge(t,e,{request:o={}}={}){return this._transport.send(`v1/contacts/${encodeURIComponent(t)}/merge`,{...o,method:"POST",json:{contact:e}})}};var x=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send(`v1/conversations/${encodeURIComponent(t)}`,{...o,method:"GET",searchParams:this._transport.query.build({include:e})})}list({filter:t,sort:e,pagination:o,include:r,request:s={}}={}){return this._transport.send("v1/conversations",{...s,method:"GET",searchParams:this._transport.query.build({sort:e,pagination:o,filter:t,include:r})})}create({body:t,request:e={}}){return this._transport.send("v1/conversations",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send(`v1/conversations/${encodeURIComponent(t)}`,{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send(`v1/conversations/${encodeURIComponent(t)}`,{...e,method:"DELETE"})}triggerResponse(t,{request:e={}}={}){return this._transport.send(`v1/conversations/${encodeURIComponent(t)}/response`,{...e,method:"POST"})}};var v=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send(`v1/conversation/${encodeURIComponent(t)}/context`,{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send(`v1/conversation/${encodeURIComponent(t)}/context`,{...o,method:"PATCH",json:e})}};var S=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/feedback/conversation/"+encodeURIComponent(t),{...e,method:"GET"})}list({pagination:t,filter:e,request:o={}}={}){return this._transport.send("v1/feedback/conversation",{...o,method:"GET",searchParams:this._transport.query.build({filter:e,pagination:t})})}create({body:t,request:e={}}){return this._transport.send("v1/feedback/conversation",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/feedback/conversation/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var y=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/escalations/"+encodeURIComponent(t),{...e,method:"GET"})}list({filter:t,pagination:e,request:o={}}={}){return this._transport.send("v1/escalations",{...o,method:"GET",searchParams:this._transport.query.build({pagination:e,filter:t})})}create({body:t,request:e={}}){return this._transport.send("v1/escalations",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send(`v1/escalations/${encodeURIComponent(t)}`,{...e,method:"DELETE"})}};var U=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/imports/"+encodeURIComponent(t),{...e,method:"GET"})}list({pagination:t,filter:e,request:o={}}={}){return this._transport.send("v1/imports",{...o,method:"GET",searchParams:this._transport.query.build({filter:e,pagination:t})})}create({body:t,request:e={}}){return this._transport.send("v1/imports",{...e,method:"POST",json:t})}delete(t,{body:e,request:o={}}){return this._transport.send("v1/imports/"+encodeURIComponent(t),{...o,method:"DELETE",json:e})}};var P=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/integrations/whatsapp/accounts/"+encodeURIComponent(t),{...o,method:"GET",searchParams:this._transport.query.build({include:e})})}list({request:t={}}={}){return this._transport.send("v1/integrations/whatsapp/accounts",{...t,method:"GET"})}};var L=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/integrations/whatsapp/phone-numbers/"+encodeURIComponent(t)+"/business-profile",{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/integrations/whatsapp/phone-numbers/"+encodeURIComponent(t)+"/business-profile",{...o,method:"PATCH",json:e})}};var D=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/integrations/whatsapp/phone-numbers/"+encodeURIComponent(t),{...o,method:"GET",searchParams:this._transport.query.build({include:e})})}list({whatsappAccount:t,channel:e,request:o={}}={}){return this._transport.send("v1/integrations/whatsapp/phone-numbers",{...o,method:"GET",searchParams:this._transport.query.build({filter:{whatsappAccount:t,channel:e}})})}};var G=class{constructor(t){this._transport=t}listByAccount(t,{search:e,status:o,quality:r,category:s,language:p,request:i={}}={}){return this._transport.send(`v1/integrations/whatsapp/accounts/${t}/templates`,{...i,method:"GET",searchParams:this._transport.query.build({filter:{search:e,status:o,quality:r,category:s,language:p}})})}getByAccount(t,e,{request:o={}}={}){return this._transport.send(`v1/integrations/whatsapp/accounts/${t}/templates/${e}`,{...o,method:"GET"})}deleteByAccount(t,e,{request:o={}}={}){return this._transport.send(`v1/integrations/whatsapp/accounts/${t}/templates/${e}`,{...o,method:"DELETE"})}};var N=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({filter:t,pagination:e,include:o,request:r={}}={}){return this._transport.send("v1/labels",{...r,method:"GET",searchParams:this._transport.query.build({pagination:e,filter:t,include:o})})}create({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var W=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send(`v1/messages/${encodeURIComponent(t)}`,{...e,method:"GET"})}list({filter:t,pagination:e,include:o,request:r={}}={}){return this._transport.send("v1/messages",{...r,method:"GET",searchParams:this._transport.query.build({pagination:e,include:o,filter:t})})}create({body:t,request:e={}}){return this._transport.send("v1/messages",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send(`v1/messages/${encodeURIComponent(t)}`,{...e,method:"DELETE"})}};var k=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/configs/"+encodeURIComponent(t),{...e,method:"GET"})}list({pagination:t,filter:e,request:o={}}={}){return this._transport.send("v1/models/configs",{...o,method:"GET",searchParams:this._transport.query.build({filter:e,pagination:t})})}create({body:t,request:e={}}){return this._transport.send("v1/models/configs",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/models/configs/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/models/configs/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var M=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/interfaces/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models/interfaces",{...t,method:"GET"})}};var F=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}list({filter:t,pagination:e,request:o={}}={}){return this._transport.send("v1/notes",{...o,method:"GET",searchParams:this._transport.query.build({filter:t,pagination:e})})}create({body:t,request:e={}}){return this._transport.send("v1/notes",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var w=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}list({featured:t,category:e,request:o={}}={}){let r=[];if(e){let s=Array.isArray(e)?e:[e];for(let p of s)r.push(["category",p])}return t!==void 0&&r.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:r})}};var B=class{constructor(t){this._transport=t}getMessageFrequency({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}getChannelMessageFrequency(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}getModelUsage({request:t={}}={}){return this._transport.send("v1/statistics/model-usage",{...t,method:"GET"})}};var z=ut(require("ky"),1);var c=class extends Error{constructor(e,o,{requestID:r,body:s,cause:p}){super(`GDS(ERR): [${e.status}] ${o.method}:${e.url}${s?" - "+s:""}`,{cause:p});this.response=e;this.request=o;this.requestID=r}requestID};function m(n){return typeof n=="function"&&(n=n()),typeof n.toString=="function"?n.toString():typeof n=="string"?n:String(n)}var H=class n{static _filterExemptColumns=["filter"];static build({sort:t,pagination:e,filter:o,include:r,custom:s}){return[...Object.entries(o??{}).flatMap(([p,i])=>n._filterExemptColumns.includes(p)?[]:this.query(`filter[${p}]`,i)),...this.query("filter",o?.filter),...Object.entries(r??{}).flatMap(([p,i])=>i?this.query("include",p):[]),...Object.entries(t??{}).flatMap(([p,i])=>i===void 0?[]:this.query("sort",(i==="desc"?"-":"")+m(p))),...this.paginationCursor(e),...this.query("page[size]",e?.size),...Object.entries(s??{}).flatMap(([p,i])=>this.query(p,i))]}static query(t,e){let o=[];if(e===void 0)return o;if(e===null)return[...o,[t,"null"]];for(let r of Array.isArray(e)?e:[e])o.push([t,m(r)]);return o}static paginationCursor({before:t,after:e,preferred:o="after"}={}){let r=[];if(t===void 0&&e===void 0)return r;let s=t?{dir:"before",value:m(t)}:void 0,p=e?{dir:"after",value:m(e)}:void 0,i=o==="after"?p||s:s||p;return i&&r.push([`page[${i.dir}]`,i.value]),r}};var q=class{client;options;query=H;constructor({baseURL:t,authentication:e,...o}){this.options={authentication:e,baseURL:t},this.client=z.default.create({prefixUrl:this.options.baseURL,headers:et,timeout:12e3,...o.request})}getURL(t){return new URL(t,this.options.baseURL).toString()}_generateRequestId(){let t="";if(globalThis.crypto&&typeof globalThis.crypto.getRandomValues=="function"){let r=new Uint8Array(21);return globalThis.crypto.getRandomValues(r),t+Array.from(r,s=>s.toString(16).padStart(2,"0")).join("")}if(globalThis.crypto&&typeof globalThis.crypto.randomUUID=="function")return t+globalThis.crypto.randomUUID();let e=Date.now().toString(36),o=Math.random().toString(36).slice(2);return`${t}${e}-${o}`}send(t,e={}){let o=this._generateRequestId(),r=e.authentication??this.options.authentication,p=this.client.extend({headers:{...r.getHeaders(),"x-request-id":o}})(t,e).catch(async i=>{throw i instanceof z.HTTPError?new c(i.response,i.request,{requestID:o,body:await i.response.text(),cause:i}):i});return{requestID:o,response:()=>p,json:async()=>(await p).json()}}};var j=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...o,method:"GET",searchParams:this._transport.query.build({include:e})})}list({filter:t,include:e,pagination:o,request:r={}}={}){return this._transport.send("v1/uploads",{...r,method:"GET",searchParams:this._transport.query.build({filter:t,include:e,pagination:o})})}create({files:t,include:e,request:o={}}){let r=new FormData;for(let s of t)r.append("file",s);return this._transport.send("v1/uploads",{...o,method:"POST",searchParams:this._transport.query.build({include:e}),body:r})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var a=require("zod"),J=a.z.object({data:a.z.object({event:a.z.object({id:a.z.string(),type:a.z.string(),payload:a.z.record(a.z.string(),a.z.string()),createdAt:a.z.iso.datetime()})})});var V=class{constructor(t){this._transport=t}async event({key:t=process.env[Q],maxSignatures:e=3,request:o}){let r=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+Q);if(!r)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(r)?r.slice(0,e):[r]))throw new Error("Untrusted signature")}let{data:s}=J.parse(o.body);return{event:s.event}}async _verifySignature(t,e,o){let r=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let s of o)if(await crypto.subtle.verify("HMAC",r,new TextEncoder().encode(atob(s)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var $=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"GET"})}list({pagination:t,filter:e,request:o={}}={}){return this._transport.send("v1/webhooks/subscriptions",{...o,method:"GET",searchParams:this._transport.query.build({filter:e,pagination:t})})}test(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t)+"/test",{...e,method:"POST"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks/subscriptions",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var u=class n{static DEFAULT_BASE_URL=K;static PublicAuthentication=E;static BasicAuthentication=T;static BearerAuthentication=A;_transport;account;accountAccessToken;accountConversationSettings;accountNotificationEvent;action;boilerplateCategory;boilerplateContent;channel;channelConversationSettings;compositionSection;contact;conversation;conversationContext;conversationFeedback;escalation;label;import;integration;message;modelConfig;modelInterface;note;source;statistics;upload;webhook;webhookSubscription;constructor(t,{baseURL:e,...o}={}){this._transport=new q({authentication:t,...o,baseURL:e?.toString()??n.getBaseURL()}),this.account=new l(this._transport),this.accountAccessToken=new d(this._transport),this.accountConversationSettings=new f(this._transport),this.accountNotificationEvent=new h(this._transport),this.action=new C(this._transport),this.boilerplateCategory=new R(this._transport),this.boilerplateContent=new _(this._transport),this.channel=new g(this._transport),this.channelConversationSettings=new O(this._transport),this.compositionSection=new b(this._transport),this.contact=new I(this._transport),this.conversation=new x(this._transport),this.conversationContext=new v(this._transport),this.conversationFeedback=new S(this._transport),this.escalation=new y(this._transport),this.label=new N(this._transport),this.import=new U(this._transport),this.integration={whatsapp:{account:new P(this._transport),phoneNumber:new D(this._transport),businessProfile:new L(this._transport),template:new G(this._transport)}},this.message=new W(this._transport),this.modelConfig=new k(this._transport),this.modelInterface=new M(this._transport),this.note=new F(this._transport),this.source=new w(this._transport),this.statistics=new B(this._transport),this.upload=new j(this._transport),this.webhook=new V(this._transport),this.webhookSubscription=new $(this._transport)}static getBaseURL(){return process.env[st]??this.DEFAULT_BASE_URL}$request(t,e){return this._transport.send(t,e)}};var X={};Z(X,{SupportError:()=>c});var dt=["ALCOHOL","APPAREL","AUTO","BEAUTY","EDU","ENTERTAIN","EVENT_PLAN","FINANCE","GOVT","GROCERY","HEALTH","HOTEL","NONPROFIT","ONLINE_GAMBLING","OTC_DRUGS","OTHER","PHYSICAL_GAMBLING","PROF_SERVICES","RESTAURANT","RETAIL","TRAVEL"];var ft=["PENDING","APPROVED","REJECTED","IN_APPEAL","PAUSED","PENDING_DELETION","DELETED","DISABLED","LIMIT_EXCEEDED"],ht=["af","sq","ar","ar_EG","ar_AE","ar_LB","ar_MA","ar_QA","az","be_BY","bn","bn_IN","bg","ca","zh_CN","zh_HK","zh_TW","hr","cs","da","prs_AF","nl","nl_BE","en","en_GB","en_US","en_AE","en_AU","en_CA","en_GH","en_IE","en_IN","en_JM","en_MY","en_NZ","en_QA","en_SG","en_UG","en_ZA","et","fil","fi","fr","fr_BE","fr_CA","fr_CH","fr_CI","fr_MA","ka","de","de_AT","de_CH","el","gu","ha","he","hi","hu","id","ga","it","ja","kn","kk","rw_RW","ko","ky_KG","lo","lv","lt","mk","ms","ml","mr","nb","ps_AF","fa","pl","pt_BR","pt_PT","pa","ro","ru","sr","si_LK","sk","sl","es","es_AR","es_CL","es_CO","es_CR","es_DO","es_EC","es_HN","es_MX","es_PA","es_PE","es_ES","es_UY","sw","sv","ta","te","th","th","tr","uk","ur","uz","vi","zu"],Ct=["AUTHENTICATION","MARKETING","UTILITY"],Tt=["ORDER_DETAILS","ORDER_STATUS"],At=["E_COMMERCE","FINANCIAL_SERVICES"],Et=["ACCOUNT_UPDATES","CUSTOMER_FEEDBACK","EVENT_REMINDER","FIXED_TEMPLATE_PRICE_TEST","IDENTITY_VERIFICATION","ORDER_MANAGEMENT","PAYMENTS"],Rt=["ACCOUNT_CREATION_CONFIRMATION","PAYMENT_DUE_REMINDER","FEEDBACK_SURVEY","PAYMENT_ACTION_REQUIRED","SHIPMENT_CONFIRMATION","PAYMENT_OVERDUE","DELIVERY_UPDATE","PAYMENT_CONFIRMATION","ORDER_DELAY","FRAUD_ALERT","DELIVERY_FAILED","AUTO_PAY_REMINDER","DELIVERY_CONFIRMATION","PAYMENT_SCHEDULED","ORDER_PICK_UP","PAYMENT_REJECT_FAIL","ORDER_ACTION_NEEDED","STATEMENT_AVAILABLE","ORDER_CONFIRMATION","LOW_BALANCE_WARNING","ORDER_OR_TRANSACTION_CANCEL","RECEIPT_ATTACHMENT","RETURN_CONFIRMATION","STATEMENT_ATTACHMENT","TRANSACTION_ALERT"],_t=["GREEN","YELLOW","RED","UNKNOWN"];var gt="0.25.0";0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,Error,SDK_VERSION,SupportError,WHATSAPP_BUSINESS_PROFILE_VERTICAL,WHATSAPP_TEMPLATE_CATEGORIES,WHATSAPP_TEMPLATE_INDUSTRIES,WHATSAPP_TEMPLATE_LANGUAGES,WHATSAPP_TEMPLATE_QUALITY_SCORES,WHATSAPP_TEMPLATE_STATUSES,WHATSAPP_TEMPLATE_SUBCATEGORIES,WHATSAPP_TEMPLATE_TOPICS,WHATSAPP_TEMPLATE_USECASES,eventWebhookSchema});
|
|
1
|
+
"use strict";var pt=Object.create;var Y=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var ct=Object.getPrototypeOf,mt=Object.prototype.hasOwnProperty;var Z=(n,t)=>{for(var e in t)Y(n,e,{get:t[e],enumerable:!0})},tt=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of at(t))!mt.call(n,r)&&r!==e&&Y(n,r,{get:()=>t[r],enumerable:!(o=it(t,r))||o.enumerable});return n};var ut=(n,t,e)=>(e=n!=null?pt(ct(n)):{},tt(t||!n||!n.__esModule?Y(e,"default",{value:n,enumerable:!0}):e,n)),lt=n=>tt(Y({},"__esModule",{value:!0}),n);var Ot={};Z(Ot,{Client:()=>u,DEFAULT_SUPPORT_BASE_URL:()=>K,Error:()=>X,SDK_VERSION:()=>gt,SupportError:()=>c,WHATSAPP_BUSINESS_PROFILE_VERTICAL:()=>dt,WHATSAPP_TEMPLATE_CATEGORIES:()=>Ct,WHATSAPP_TEMPLATE_INDUSTRIES:()=>At,WHATSAPP_TEMPLATE_LANGUAGES:()=>ht,WHATSAPP_TEMPLATE_QUALITY_SCORES:()=>_t,WHATSAPP_TEMPLATE_STATUSES:()=>ft,WHATSAPP_TEMPLATE_SUBCATEGORIES:()=>Tt,WHATSAPP_TEMPLATE_TOPICS:()=>Et,WHATSAPP_TEMPLATE_USECASES:()=>Rt,default:()=>u,eventWebhookSchema:()=>J});module.exports=lt(Ot);var K="https://api.support.greatdetail.com",et={"x-powered-by":"GDS/JavaScript"};var l=class{constructor(t){this._transport=t}list({filter:t,pagination:e,request:o={}}={}){return this._transport.send("v1/accounts",{...o,method:"GET",searchParams:this._transport.query.build({pagination:e,filter:t})})}get(t,{request:e={}}={}){return this._transport.send(`v1/accounts/${encodeURIComponent(t)}`,{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send(`v1/accounts/${encodeURIComponent(t)}`,{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/accounts",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send(`v1/accounts/${encodeURIComponent(t)}`,{...e,method:"DELETE"})}};var d=class{constructor(t){this._transport=t}get(t,e,{request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...o,method:"GET"})}list(t,{filter:e,pagination:o,request:r={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...r,method:"GET",searchParams:this._transport.query.build({pagination:o,filter:e})})}delete(t,e,{body:o,request:r={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...r,method:"DELETE",json:o})}create(t,{body:e={},request:o={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...o,method:"POST",json:e})}};var f=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/conversation-settings",{...o,method:"PATCH",json:e})}};var h=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notifications/events/account/"+encodeURIComponent(t),{...e,method:"GET"})}listByAccount(t,{filter:e,pagination:o,request:r={}}={}){return this._transport.send(`v1/accounts/${encodeURIComponent(t)}/notifications/events`,{...r,method:"GET",searchParams:this._transport.query.build({pagination:o,filter:e})})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notifications/events/account/"+encodeURIComponent(t),{...o,method:"PATCH",json:{...e,readAt:e.readAt instanceof Date&&typeof e.readAt.getMonth=="function"?e.readAt.toISOString():e.readAt}})}};var C=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send(`v1/actions/${encodeURIComponent(t)}`,{...e,method:"GET"})}list({filter:t,sort:e,pagination:o,request:r={}}={}){return this._transport.send("v1/actions",{...r,method:"GET",searchParams:this._transport.query.build({sort:e,pagination:o,filter:t})})}};var ot="SUPPORT_ACCESS_TOKEN",nt="SUPPORT_KEY_NAME",rt="SUPPORT_KEY_PASSWORD",Q="SUPPORT_SIGNING_KEY",st="SUPPORT_BASE_URL";var T=class{name;#t;constructor({name:t=process.env[nt],password:e=process.env[rt]}={}){if(!t)throw new Error("Name option must be specified when using Basic Authentication");if(!e)throw new Error("Password option must be specified when using Basic Authentication");this.name=t,this.#t=e}getHeaders(){let t=typeof this.name=="function"?this.name():this.name,e=typeof this.#t=="function"?this.#t():this.#t;return{Authorization:`Basic ${btoa(t+":"+e)}`}}};var A=class{#t;constructor({token:t=process.env[ot]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${typeof this.#t=="function"?this.#t():this.#t}`}}};var E=class{getHeaders(){return{}}};var R=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({filter:t,pagination:e,include:o,request:r={}}={}){return this._transport.send("v1/boilerplates/categories",{...r,method:"GET",searchParams:this._transport.query.build({include:o,pagination:e,filter:t})})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/categories",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var _=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({filter:t,pagination:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:this._transport.query.build({pagination:e,filter:t})})}create({body:t,request:e={}}){return this._transport.send("v1/boilerplates/contents",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var g=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({filter:t,pagination:e,request:o={}}={}){return this._transport.send("v1/channels",{...o,method:"GET",searchParams:this._transport.query.build({pagination:e,filter:t})})}update(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}create({body:t,request:e={}}){return this._transport.send("v1/channels",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"DELETE"})}sendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/sendgrid/sync",{...o,method:"POST",json:e})}};var O=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversation-settings",{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversation-settings",{...o,method:"PATCH",json:e})}};var b=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({filter:t,pagination:e,request:o={}}={}){return this._transport.send("v1/composition-sections",{...o,method:"GET",searchParams:this._transport.query.build({pagination:e,filter:t})})}create({body:t,request:e={}}){return this._transport.send("v1/composition-sections",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var I=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send(`v1/contacts/${encodeURIComponent(t)}`,{...o,method:"GET",searchParams:this._transport.query.build({include:e})})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",r=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(r)}getVCFURL(t,e={}){return this._transport.getURL(this.getRelativeVCFURL(t,e))}getVCF(t,e={}){return this._transport.send(this.getVCFURL(t,e),{method:"GET"})}list({pagination:t,filter:e,sort:o,request:r={}}={}){return this._transport.send("v1/contacts",{...r,method:"GET",searchParams:this._transport.query.build({pagination:t,sort:o,filter:e})})}create({body:t,request:e={}}){return this._transport.send("v1/contacts",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send(`v1/contacts/${encodeURIComponent(t)}`,{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send(`v1/contacts/${encodeURIComponent(t)}`,{...e,method:"DELETE"})}merge(t,e,{request:o={}}={}){return this._transport.send(`v1/contacts/${encodeURIComponent(t)}/merge`,{...o,method:"POST",json:{contact:e}})}};var x=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send(`v1/conversations/${encodeURIComponent(t)}`,{...o,method:"GET",searchParams:this._transport.query.build({include:e})})}list({filter:t,sort:e,pagination:o,include:r,request:s={}}={}){return this._transport.send("v1/conversations",{...s,method:"GET",searchParams:this._transport.query.build({sort:e,pagination:o,filter:t,include:r})})}create({body:t,request:e={}}){return this._transport.send("v1/conversations",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send(`v1/conversations/${encodeURIComponent(t)}`,{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send(`v1/conversations/${encodeURIComponent(t)}`,{...e,method:"DELETE"})}triggerResponse(t,{request:e={}}={}){return this._transport.send(`v1/conversations/${encodeURIComponent(t)}/response`,{...e,method:"POST"})}};var v=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send(`v1/conversation/${encodeURIComponent(t)}/context`,{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send(`v1/conversation/${encodeURIComponent(t)}/context`,{...o,method:"PATCH",json:e})}};var S=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/feedback/conversation/"+encodeURIComponent(t),{...e,method:"GET"})}list({pagination:t,filter:e,request:o={}}={}){return this._transport.send("v1/feedback/conversation",{...o,method:"GET",searchParams:this._transport.query.build({filter:e,pagination:t})})}create({body:t,request:e={}}){return this._transport.send("v1/feedback/conversation",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/feedback/conversation/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var y=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/escalations/"+encodeURIComponent(t),{...e,method:"GET"})}list({filter:t,pagination:e,request:o={}}={}){return this._transport.send("v1/escalations",{...o,method:"GET",searchParams:this._transport.query.build({pagination:e,filter:t})})}create({body:t,request:e={}}){return this._transport.send("v1/escalations",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send(`v1/escalations/${encodeURIComponent(t)}`,{...e,method:"DELETE"})}};var D=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/imports/"+encodeURIComponent(t),{...e,method:"GET"})}list({pagination:t,filter:e,request:o={}}={}){return this._transport.send("v1/imports",{...o,method:"GET",searchParams:this._transport.query.build({filter:e,pagination:t})})}create({body:t,request:e={}}){return this._transport.send("v1/imports",{...e,method:"POST",json:t})}delete(t,{body:e,request:o={}}){return this._transport.send("v1/imports/"+encodeURIComponent(t),{...o,method:"DELETE",json:e})}};var U=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/integrations/whatsapp/accounts/"+encodeURIComponent(t),{...o,method:"GET",searchParams:this._transport.query.build({include:e})})}list({request:t={}}={}){return this._transport.send("v1/integrations/whatsapp/accounts",{...t,method:"GET"})}};var P=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/integrations/whatsapp/phone-numbers/"+encodeURIComponent(t)+"/business-profile",{...e,method:"GET"})}update(t,{body:e,request:o={}}){return this._transport.send("v1/integrations/whatsapp/phone-numbers/"+encodeURIComponent(t)+"/business-profile",{...o,method:"PATCH",json:e})}};var L=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/integrations/whatsapp/phone-numbers/"+encodeURIComponent(t),{...o,method:"GET",searchParams:this._transport.query.build({include:e})})}list({whatsappAccount:t,channel:e,request:o={}}={}){return this._transport.send("v1/integrations/whatsapp/phone-numbers",{...o,method:"GET",searchParams:this._transport.query.build({filter:{whatsappAccount:t,channel:e}})})}};var G=class{constructor(t){this._transport=t}listByAccount(t,{search:e,status:o,quality:r,category:s,language:p,request:i={}}={}){return this._transport.send(`v1/integrations/whatsapp/accounts/${t}/templates`,{...i,method:"GET",searchParams:this._transport.query.build({filter:{search:e,status:o,quality:r,category:s,language:p}})})}getByAccount(t,e,{request:o={}}={}){return this._transport.send(`v1/integrations/whatsapp/accounts/${t}/templates/${e}`,{...o,method:"GET"})}deleteByAccount(t,e,{request:o={}}={}){return this._transport.send(`v1/integrations/whatsapp/accounts/${t}/templates/${e}`,{...o,method:"DELETE"})}};var N=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({filter:t,pagination:e,include:o,request:r={}}={}){return this._transport.send("v1/labels",{...r,method:"GET",searchParams:this._transport.query.build({pagination:e,filter:t,include:o})})}create({body:t,request:e={}}){return this._transport.send("v1/labels",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var W=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send(`v1/messages/${encodeURIComponent(t)}`,{...e,method:"GET"})}list({filter:t,pagination:e,include:o,request:r={}}={}){return this._transport.send("v1/messages",{...r,method:"GET",searchParams:this._transport.query.build({pagination:e,include:o,filter:t})})}create({body:t,request:e={}}){return this._transport.send("v1/messages",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send(`v1/messages/${encodeURIComponent(t)}`,{...e,method:"DELETE"})}};var k=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/configs/"+encodeURIComponent(t),{...e,method:"GET"})}list({pagination:t,filter:e,request:o={}}={}){return this._transport.send("v1/models/configs",{...o,method:"GET",searchParams:this._transport.query.build({filter:e,pagination:t})})}create({body:t,request:e={}}){return this._transport.send("v1/models/configs",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/models/configs/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}delete(t,{request:e={}}={}){return this._transport.send("v1/models/configs/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var M=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/interfaces/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models/interfaces",{...t,method:"GET"})}};var F=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}list({filter:t,pagination:e,request:o={}}={}){return this._transport.send("v1/notes",{...o,method:"GET",searchParams:this._transport.query.build({filter:t,pagination:e})})}create({body:t,request:e={}}){return this._transport.send("v1/notes",{...e,method:"POST",json:t})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var w=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}list({featured:t,category:e,request:o={}}={}){let r=[];if(e){let s=Array.isArray(e)?e:[e];for(let p of s)r.push(["category",p])}return t!==void 0&&r.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:r})}};var B=class{constructor(t){this._transport=t}getMessageFrequency({request:t={}}={}){return this._transport.send("v1/statistics/message-frequency",{...t,method:"GET"})}getChannelMessageFrequency(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/statistics/message-frequency",{...e,method:"GET"})}getModelUsage({request:t={}}={}){return this._transport.send("v1/statistics/model-usage",{...t,method:"GET"})}};var z=ut(require("ky"),1);var c=class extends Error{constructor(e,o,{requestID:r,body:s,...p}){super(`GDS(ERR): [${e.status}] ${o.method}:${e.url}${s?" - "+s:""}`,p);this.response=e;this.request=o;this.requestID=r}requestID};function m(n){return typeof n=="function"&&(n=n()),typeof n.toString=="function"?n.toString():typeof n=="string"?n:String(n)}var H=class n{static _filterExemptColumns=["filter"];static build({sort:t,pagination:e,filter:o,include:r,custom:s}){return[...Object.entries(o??{}).flatMap(([p,i])=>n._filterExemptColumns.includes(p)?[]:this.query(`filter[${p}]`,i)),...this.query("filter",o?.filter),...Object.entries(r??{}).flatMap(([p,i])=>i?this.query("include",p):[]),...Object.entries(t??{}).flatMap(([p,i])=>i===void 0?[]:this.query("sort",(i==="desc"?"-":"")+m(p))),...this.paginationCursor(e),...this.query("page[size]",e?.size),...Object.entries(s??{}).flatMap(([p,i])=>this.query(p,i))]}static query(t,e){let o=[];if(e===void 0)return o;if(e===null)return[...o,[t,"null"]];for(let r of Array.isArray(e)?e:[e])o.push([t,m(r)]);return o}static paginationCursor({before:t,after:e,preferred:o="after"}={}){let r=[];if(t===void 0&&e===void 0)return r;let s=t?{dir:"before",value:m(t)}:void 0,p=e?{dir:"after",value:m(e)}:void 0,i=o==="after"?p||s:s||p;return i&&r.push([`page[${i.dir}]`,i.value]),r}};var q=class{client;options;query=H;constructor({baseURL:t,authentication:e,...o}){this.options={authentication:e,baseURL:t},this.client=z.default.create({prefixUrl:this.options.baseURL,headers:et,timeout:12e3,...o.request})}getURL(t){return new URL(t,this.options.baseURL).toString()}_generateRequestId(){let t="";if(globalThis.crypto&&typeof globalThis.crypto.getRandomValues=="function"){let r=new Uint8Array(21);return globalThis.crypto.getRandomValues(r),t+Array.from(r,s=>s.toString(16).padStart(2,"0")).join("")}if(globalThis.crypto&&typeof globalThis.crypto.randomUUID=="function")return t+globalThis.crypto.randomUUID();let e=Date.now().toString(36),o=Math.random().toString(36).slice(2);return`${t}${e}-${o}`}send(t,e={}){let o=this._generateRequestId(),r=e.authentication??this.options.authentication,p=this.client.extend({headers:{...r.getHeaders(),"x-request-id":o}})(t,e).catch(async i=>{throw i instanceof z.HTTPError?new c(i.response,i.request,{requestID:o,body:await i.response.text(),cause:i}):i});return{requestID:o,response:()=>p,json:async()=>(await p).json()}}};var j=class{constructor(t){this._transport=t}get(t,{include:e,request:o={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...o,method:"GET",searchParams:this._transport.query.build({include:e})})}list({filter:t,include:e,pagination:o,request:r={}}={}){return this._transport.send("v1/uploads",{...r,method:"GET",searchParams:this._transport.query.build({filter:t,include:e,pagination:o})})}create({files:t,include:e,request:o={}}){let r=new FormData;for(let s of t)r.append("file",s);return this._transport.send("v1/uploads",{...o,method:"POST",searchParams:this._transport.query.build({include:e}),body:r})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var a=require("zod"),J=a.z.object({data:a.z.object({event:a.z.object({id:a.z.string(),type:a.z.string(),payload:a.z.record(a.z.string(),a.z.string()),createdAt:a.z.iso.datetime()})})});var V=class{constructor(t){this._transport=t}async event({key:t=process.env[Q],maxSignatures:e=3,request:o}){let r=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+Q);if(!r)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(r)?r.slice(0,e):[r]))throw new Error("Untrusted signature")}let{data:s}=J.parse(o.body);return{event:s.event}}async _verifySignature(t,e,o){let r=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let s of o)if(await crypto.subtle.verify("HMAC",r,new TextEncoder().encode(atob(s)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var $=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"GET"})}list({pagination:t,filter:e,request:o={}}={}){return this._transport.send("v1/webhooks/subscriptions",{...o,method:"GET",searchParams:this._transport.query.build({filter:e,pagination:t})})}test(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t)+"/test",{...e,method:"POST"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks/subscriptions",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/subscriptions/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var u=class n{static DEFAULT_BASE_URL=K;static PublicAuthentication=E;static BasicAuthentication=T;static BearerAuthentication=A;_transport;account;accountAccessToken;accountConversationSettings;accountNotificationEvent;action;boilerplateCategory;boilerplateContent;channel;channelConversationSettings;compositionSection;contact;conversation;conversationContext;conversationFeedback;escalation;label;import;integration;message;modelConfig;modelInterface;note;source;statistics;upload;webhook;webhookSubscription;constructor(t,{baseURL:e,...o}={}){this._transport=new q({authentication:t,...o,baseURL:e?.toString()??n.getBaseURL()}),this.account=new l(this._transport),this.accountAccessToken=new d(this._transport),this.accountConversationSettings=new f(this._transport),this.accountNotificationEvent=new h(this._transport),this.action=new C(this._transport),this.boilerplateCategory=new R(this._transport),this.boilerplateContent=new _(this._transport),this.channel=new g(this._transport),this.channelConversationSettings=new O(this._transport),this.compositionSection=new b(this._transport),this.contact=new I(this._transport),this.conversation=new x(this._transport),this.conversationContext=new v(this._transport),this.conversationFeedback=new S(this._transport),this.escalation=new y(this._transport),this.label=new N(this._transport),this.import=new D(this._transport),this.integration={whatsapp:{account:new U(this._transport),phoneNumber:new L(this._transport),businessProfile:new P(this._transport),template:new G(this._transport)}},this.message=new W(this._transport),this.modelConfig=new k(this._transport),this.modelInterface=new M(this._transport),this.note=new F(this._transport),this.source=new w(this._transport),this.statistics=new B(this._transport),this.upload=new j(this._transport),this.webhook=new V(this._transport),this.webhookSubscription=new $(this._transport)}static getBaseURL(){return process.env[st]??this.DEFAULT_BASE_URL}$request(t,e){return this._transport.send(t,e)}};var X={};Z(X,{SupportError:()=>c});var dt=["ALCOHOL","APPAREL","AUTO","BEAUTY","EDU","ENTERTAIN","EVENT_PLAN","FINANCE","GOVT","GROCERY","HEALTH","HOTEL","NONPROFIT","ONLINE_GAMBLING","OTC_DRUGS","OTHER","PHYSICAL_GAMBLING","PROF_SERVICES","RESTAURANT","RETAIL","TRAVEL"];var ft=["PENDING","APPROVED","REJECTED","IN_APPEAL","PAUSED","PENDING_DELETION","DELETED","DISABLED","LIMIT_EXCEEDED"],ht=["af","sq","ar","ar_EG","ar_AE","ar_LB","ar_MA","ar_QA","az","be_BY","bn","bn_IN","bg","ca","zh_CN","zh_HK","zh_TW","hr","cs","da","prs_AF","nl","nl_BE","en","en_GB","en_US","en_AE","en_AU","en_CA","en_GH","en_IE","en_IN","en_JM","en_MY","en_NZ","en_QA","en_SG","en_UG","en_ZA","et","fil","fi","fr","fr_BE","fr_CA","fr_CH","fr_CI","fr_MA","ka","de","de_AT","de_CH","el","gu","ha","he","hi","hu","id","ga","it","ja","kn","kk","rw_RW","ko","ky_KG","lo","lv","lt","mk","ms","ml","mr","nb","ps_AF","fa","pl","pt_BR","pt_PT","pa","ro","ru","sr","si_LK","sk","sl","es","es_AR","es_CL","es_CO","es_CR","es_DO","es_EC","es_HN","es_MX","es_PA","es_PE","es_ES","es_UY","sw","sv","ta","te","th","th","tr","uk","ur","uz","vi","zu"],Ct=["AUTHENTICATION","MARKETING","UTILITY"],Tt=["ORDER_DETAILS","ORDER_STATUS"],At=["E_COMMERCE","FINANCIAL_SERVICES"],Et=["ACCOUNT_UPDATES","CUSTOMER_FEEDBACK","EVENT_REMINDER","FIXED_TEMPLATE_PRICE_TEST","IDENTITY_VERIFICATION","ORDER_MANAGEMENT","PAYMENTS"],Rt=["ACCOUNT_CREATION_CONFIRMATION","PAYMENT_DUE_REMINDER","FEEDBACK_SURVEY","PAYMENT_ACTION_REQUIRED","SHIPMENT_CONFIRMATION","PAYMENT_OVERDUE","DELIVERY_UPDATE","PAYMENT_CONFIRMATION","ORDER_DELAY","FRAUD_ALERT","DELIVERY_FAILED","AUTO_PAY_REMINDER","DELIVERY_CONFIRMATION","PAYMENT_SCHEDULED","ORDER_PICK_UP","PAYMENT_REJECT_FAIL","ORDER_ACTION_NEEDED","STATEMENT_AVAILABLE","ORDER_CONFIRMATION","LOW_BALANCE_WARNING","ORDER_OR_TRANSACTION_CANCEL","RECEIPT_ATTACHMENT","RETURN_CONFIRMATION","STATEMENT_ATTACHMENT","TRANSACTION_ALERT"],_t=["GREEN","YELLOW","RED","UNKNOWN"];var gt="0.26.0";0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,Error,SDK_VERSION,SupportError,WHATSAPP_BUSINESS_PROFILE_VERTICAL,WHATSAPP_TEMPLATE_CATEGORIES,WHATSAPP_TEMPLATE_INDUSTRIES,WHATSAPP_TEMPLATE_LANGUAGES,WHATSAPP_TEMPLATE_QUALITY_SCORES,WHATSAPP_TEMPLATE_STATUSES,WHATSAPP_TEMPLATE_SUBCATEGORIES,WHATSAPP_TEMPLATE_TOPICS,WHATSAPP_TEMPLATE_USECASES,eventWebhookSchema});
|