@great-detail/support-sdk 0.16.13 → 0.16.14
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/{Client-CJSL873u.d.cts → Client-BQeXSLP6.d.cts} +23 -1
- package/dist/{Client-CJSL873u.d.ts → Client-BQeXSLP6.d.ts} +23 -1
- package/dist/chunk-5NLQ55US.js +1 -0
- package/dist/{chunk-E5JWUN6F.js → chunk-SNJCTFV7.js} +1 -1
- package/dist/cli/index.cjs +1 -1
- package/dist/cli/index.d.cts +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-V7LNWFJE.js +0 -1
|
@@ -145,6 +145,24 @@ type GetAccountResponse = {
|
|
|
145
145
|
};
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
+
/**
|
|
149
|
+
* Great Detail Support System.
|
|
150
|
+
*
|
|
151
|
+
* @copyright 2024 Great Detail Ltd
|
|
152
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
153
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
154
|
+
* @see https://greatdetail.com
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
interface GetCurrentAccountOptions {
|
|
158
|
+
request?: SendOptions;
|
|
159
|
+
}
|
|
160
|
+
type GetCurrentAccountResponse = {
|
|
161
|
+
data: {
|
|
162
|
+
account: Account;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
|
|
148
166
|
/**
|
|
149
167
|
* Great Detail Support System.
|
|
150
168
|
*
|
|
@@ -176,6 +194,10 @@ declare class AccountAPI {
|
|
|
176
194
|
response: () => Promise<ky.KyResponse<GetAccountResponse>>;
|
|
177
195
|
json: () => Promise<GetAccountResponse>;
|
|
178
196
|
};
|
|
197
|
+
getCurrent({ request }: GetCurrentAccountOptions): {
|
|
198
|
+
response: () => Promise<ky.KyResponse<GetCurrentAccountResponse>>;
|
|
199
|
+
json: () => Promise<GetCurrentAccountResponse>;
|
|
200
|
+
};
|
|
179
201
|
update(id: AccountID, { body, request }: UpdateAccountOptions): {
|
|
180
202
|
response: () => Promise<ky.KyResponse<UpdateAccountResponse>>;
|
|
181
203
|
json: () => Promise<UpdateAccountResponse>;
|
|
@@ -3147,4 +3169,4 @@ declare class Client {
|
|
|
3147
3169
|
static getBaseURL(): string;
|
|
3148
3170
|
}
|
|
3149
3171
|
|
|
3150
|
-
export { type
|
|
3172
|
+
export { type BoilerplateCategory as $, type Account as A, type Action as B, Client as C, type DeleteAccountAccessTokenPayload as D, type ActionID as E, type ListActionsOptions as F, type GetAccountOptions as G, type ListActionsResponse as H, type BoilerplateContent as I, type BoilerplateContentID as J, type CreateBoilerplateContentPayload as K, type ListAccountAccessTokensOptions as L, type CreateBoilerplateContentOptions as M, type CreateBoilerplateContentResponse as N, type Options as O, type GetBoilerplateContentOptions as P, type GetBoilerplateContentResponse as Q, type RequestFilterable as R, type SortOptions as S, type ListBoilerplateCategoryBoilerplateContentsOptions as T, type UpdateAccountPayload as U, type ListBoilerplateCategoryBoilerplateContentsResponse as V, type ListBoilerplateContentsOptions as W, type ListBoilerplateContentsResponse as X, type UpdateBoilerplateContentPayload as Y, type UpdateBoilerplateContentOptions as Z, type UpdateBoilerplateContentResponse as _, type Options$4 as a, type ConversationID as a$, type BoilerplateCategoryID as a0, type CreateBoilerplateCategoryPayload as a1, type CreateBoilerplateCategoryOptions as a2, type CreateBoilerplateCategoryResponse as a3, type GetBoilerplateCategoryOptions as a4, type GetBoilerplateCategoryResponse as a5, type ListBoilerplateCategoriesIncludeOptions as a6, type ListBoilerplateCategoriesOptions as a7, type ListBoilerplateCategoriesResponse as a8, type UpdateBoilerplateCategoryPayload as a9, type ListChannelCompositionSectionsOptions as aA, type ListChannelCompositionSectionsResponse as aB, type ListCompositionSectionsOptions as aC, type ListCompositionSectionsResponse as aD, type UpdateCompositionSectionPayload as aE, type UpdateCompositionSectionOptions as aF, type UpdateCompositionSectionResponse as aG, type Contact as aH, type ContactID as aI, type CustomMetadata as aJ, type CreateContactPayload as aK, type CreateContactOptions as aL, type CreateContactResponse as aM, type DeleteContactOptions as aN, type DeleteContactResponse as aO, type GetContactIncludeOptions as aP, type GetContactOptions as aQ, type GetContactResponse as aR, type GetContactVCFOptions as aS, type ListContactsOptions as aT, type ListContactsResponse as aU, type ListLabelContactsOptions as aV, type ListLabelContactsResponse as aW, type UpdateContactPayload as aX, type UpdateContactOptions as aY, type UpdateContactResponse as aZ, type Conversation as a_, type UpdateBoilerplateCategoryOptions as aa, type UpdateBoilerplateCategoryResponse as ab, type Channel as ac, type ChannelID as ad, type CreateChannelPayload as ae, type CreateChannelOptions as af, type CreateChannelResponse as ag, type GetChannelOptions as ah, type GetChannelResponse as ai, type ListChannelsOptions as aj, type ListChannelsResponse as ak, type MetaWhatsappChannelGetBusinessProfileOptions as al, type MetaWhatsappChannelGetBusinessProfileResponse as am, type TwilioSendChannelSyncPayload as an, type TwilioSendgridChannelSyncOptions as ao, type TwilioSendgridChannelSyncResponse as ap, type UpdateChannelPayload as aq, type UpdateChannelOptions as ar, type UpdateChannelResponse as as, type CompositionSection as at, type CompositionSectionID as au, type CreateCompositionSectionPayload as av, type CreateCompositionSectionOptions as aw, type CreateCompositionSectionResponse as ax, type GetCompositionSectionOptions as ay, type GetCompositionSectionResponse as az, type AccountID as b, type CreateCorrectionModelOptions as b$, type ActiveConversationStatus as b0, type ConcludedConversationStatus as b1, type ConversationStatus as b2, type CreateConversationPayload as b3, type CreateConversationOptions as b4, type CreateConversationResponse as b5, type DeleteConversationOptions as b6, type DeleteConversationResponse as b7, type GetConversationIncludeOptions as b8, type GetConversationOptions as b9, type ListConversationLabelsResponse as bA, type ListLabelsIncludeOptions as bB, type ListLabelsOptions as bC, type ListLabelsResponse as bD, type UpdateLabelPayload as bE, type UpdateLabelOptions as bF, type UpdateLabelResponse as bG, type Message as bH, type CreateMessagePayload as bI, type CreateMessageOptions as bJ, type CreateMessageResponse as bK, type DeleteMessageOptions as bL, type DeleteMessageResponse as bM, type ListChannelMessagesIncludeOptions as bN, type ListChannelMessagesOptions as bO, type ListChannelMessagesResponse as bP, type ListConversationMessagesIncludeOptions as bQ, type ListConversationMessagesOptions as bR, type ListConversationMessagesResponse as bS, type ListMessagesIncludeOptions as bT, type ListMessagesOptions as bU, type ListMessagesResponse as bV, type MessageID as bW, type MessageRole as bX, type MessageStatus as bY, type Model as bZ, type CreateCorrectionModelPayload as b_, type GetConversationResponse as ba, type ListChannelConversationsOptions as bb, type ListChannelConversationsResponse as bc, type ListContactConversationsOptions as bd, type ListContactConversationsResponse as be, type ListConversationsIncludeOptions as bf, type FilterOptions as bg, type ListConversationOptions as bh, type ListConversationsResponse as bi, type ListLabelConversationsOptions as bj, type ListLabelConversationsResponse as bk, type UpdateConversationPayload as bl, type UpdateConversationOptions as bm, type UpdateConversationResponse as bn, type Label as bo, type CreateLabelPayload as bp, type CreateLabelOptions as bq, type CreateLabelResponse as br, type DeleteLabelOptions as bs, type DeleteLabelResponse as bt, type GetLabelOptions as bu, type GetLabelResponse as bv, type LabelID as bw, type ListContactLabelsOptions as bx, type ListContactLabelsResponse as by, type ListConversationLabelsOptions as bz, type CreateAccountPayload as c, type CreateCorrectionResponse as c0, type CreateResponseModelPayload as c1, type CreateResponseModelOptions as c2, type CreateResponseResponse as c3, type GetModelOptions as c4, type GetModelResponse as c5, type ListModelsOptions as c6, type ListModelsResponse as c7, type ModelID as c8, type Note as c9, type NotificationSubscriptionID as cA, type Upload as cB, type CreateUploadOptions as cC, type CreateUploadResponse as cD, type DeleteUploadOptions as cE, type DeleteUploadResponse as cF, type GetUploadOptions as cG, type GetUploadResponse as cH, type UploadID as cI, type CreateWebhookPayload as cJ, type CreateWebhookOptions as cK, type CreateWebhookResponse as cL, type DeleteWebhookOptions as cM, type DeleteWebhookResponse as cN, type EventWebhookOptions as cO, eventWebhookSchema as cP, type ListWebhooksOptions as cQ, type ListWebhooksResponse as cR, type WebhookID as cS, type WebhookResponse as cT, type GetNotificationWellKnownResponse as cU, type CreateContactNotePayload as ca, type CreateContactNoteOptions as cb, type CreateContactNoteResponse as cc, type CreateConversationNotePayload as cd, type CreateConversationNoteOptions as ce, type CreateConversationNoteResponse as cf, type GetNoteOptions as cg, type GetNoteResponse as ch, type ListContactNotesOptions as ci, type ListContactNotesResponse as cj, type ListConversationNotesOptions as ck, type ListConversationNotesResponse as cl, type NoteID as cm, type UpdateNotePayload as cn, type UpdateNoteOptions as co, type UpdateNoteResponse as cp, type Source as cq, type GetSourceOptions as cr, type GetSourceResponse as cs, type ListSourcesOptions as ct, type ListSourcesResponse as cu, type SourceID as cv, type NotificationSubscription as cw, type CreateContactNotificationSubscriptionPayload as cx, type CreateContactNotificationSubscriptionOptions as cy, type CreateContactNotificationSubscriptionResponse as cz, type CreateAccountOptions as d, type CreateAccountResponse as e, type GetAccountResponse as f, type GetCurrentAccountOptions as g, type GetCurrentAccountResponse as h, type UpdateAccountOptions as i, type UpdateAccountResponse as j, type AccountAccessToken as k, type AccountAccessTokenID as l, type CreateAccountAccessTokenPayload as m, type CreateAccountAccessTokenOptions as n, type CreateAccountAccessTokenResponse as o, type DeleteAccountAccessTokenOptions as p, type DeleteAccountAccessTokenResponse as q, type GetAccountAccessTokenOptions as r, type GetAccountAccessTokenResponse as s, type ListAccountAccessTokensResponse as t, type AccountConversationSettings as u, type GetAccountConversationSettingsOptions as v, type GetAccountConversationSettingsResponse as w, type UpdateAccountConversationSettingsPayload as x, type UpdateAccountConversationSettingsOptions as y, type UpdateAccountConversationSettingsResponse as z };
|
|
@@ -145,6 +145,24 @@ type GetAccountResponse = {
|
|
|
145
145
|
};
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
+
/**
|
|
149
|
+
* Great Detail Support System.
|
|
150
|
+
*
|
|
151
|
+
* @copyright 2024 Great Detail Ltd
|
|
152
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
153
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
154
|
+
* @see https://greatdetail.com
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
interface GetCurrentAccountOptions {
|
|
158
|
+
request?: SendOptions;
|
|
159
|
+
}
|
|
160
|
+
type GetCurrentAccountResponse = {
|
|
161
|
+
data: {
|
|
162
|
+
account: Account;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
|
|
148
166
|
/**
|
|
149
167
|
* Great Detail Support System.
|
|
150
168
|
*
|
|
@@ -176,6 +194,10 @@ declare class AccountAPI {
|
|
|
176
194
|
response: () => Promise<ky.KyResponse<GetAccountResponse>>;
|
|
177
195
|
json: () => Promise<GetAccountResponse>;
|
|
178
196
|
};
|
|
197
|
+
getCurrent({ request }: GetCurrentAccountOptions): {
|
|
198
|
+
response: () => Promise<ky.KyResponse<GetCurrentAccountResponse>>;
|
|
199
|
+
json: () => Promise<GetCurrentAccountResponse>;
|
|
200
|
+
};
|
|
179
201
|
update(id: AccountID, { body, request }: UpdateAccountOptions): {
|
|
180
202
|
response: () => Promise<ky.KyResponse<UpdateAccountResponse>>;
|
|
181
203
|
json: () => Promise<UpdateAccountResponse>;
|
|
@@ -3147,4 +3169,4 @@ declare class Client {
|
|
|
3147
3169
|
static getBaseURL(): string;
|
|
3148
3170
|
}
|
|
3149
3171
|
|
|
3150
|
-
export { type
|
|
3172
|
+
export { type BoilerplateCategory as $, type Account as A, type Action as B, Client as C, type DeleteAccountAccessTokenPayload as D, type ActionID as E, type ListActionsOptions as F, type GetAccountOptions as G, type ListActionsResponse as H, type BoilerplateContent as I, type BoilerplateContentID as J, type CreateBoilerplateContentPayload as K, type ListAccountAccessTokensOptions as L, type CreateBoilerplateContentOptions as M, type CreateBoilerplateContentResponse as N, type Options as O, type GetBoilerplateContentOptions as P, type GetBoilerplateContentResponse as Q, type RequestFilterable as R, type SortOptions as S, type ListBoilerplateCategoryBoilerplateContentsOptions as T, type UpdateAccountPayload as U, type ListBoilerplateCategoryBoilerplateContentsResponse as V, type ListBoilerplateContentsOptions as W, type ListBoilerplateContentsResponse as X, type UpdateBoilerplateContentPayload as Y, type UpdateBoilerplateContentOptions as Z, type UpdateBoilerplateContentResponse as _, type Options$4 as a, type ConversationID as a$, type BoilerplateCategoryID as a0, type CreateBoilerplateCategoryPayload as a1, type CreateBoilerplateCategoryOptions as a2, type CreateBoilerplateCategoryResponse as a3, type GetBoilerplateCategoryOptions as a4, type GetBoilerplateCategoryResponse as a5, type ListBoilerplateCategoriesIncludeOptions as a6, type ListBoilerplateCategoriesOptions as a7, type ListBoilerplateCategoriesResponse as a8, type UpdateBoilerplateCategoryPayload as a9, type ListChannelCompositionSectionsOptions as aA, type ListChannelCompositionSectionsResponse as aB, type ListCompositionSectionsOptions as aC, type ListCompositionSectionsResponse as aD, type UpdateCompositionSectionPayload as aE, type UpdateCompositionSectionOptions as aF, type UpdateCompositionSectionResponse as aG, type Contact as aH, type ContactID as aI, type CustomMetadata as aJ, type CreateContactPayload as aK, type CreateContactOptions as aL, type CreateContactResponse as aM, type DeleteContactOptions as aN, type DeleteContactResponse as aO, type GetContactIncludeOptions as aP, type GetContactOptions as aQ, type GetContactResponse as aR, type GetContactVCFOptions as aS, type ListContactsOptions as aT, type ListContactsResponse as aU, type ListLabelContactsOptions as aV, type ListLabelContactsResponse as aW, type UpdateContactPayload as aX, type UpdateContactOptions as aY, type UpdateContactResponse as aZ, type Conversation as a_, type UpdateBoilerplateCategoryOptions as aa, type UpdateBoilerplateCategoryResponse as ab, type Channel as ac, type ChannelID as ad, type CreateChannelPayload as ae, type CreateChannelOptions as af, type CreateChannelResponse as ag, type GetChannelOptions as ah, type GetChannelResponse as ai, type ListChannelsOptions as aj, type ListChannelsResponse as ak, type MetaWhatsappChannelGetBusinessProfileOptions as al, type MetaWhatsappChannelGetBusinessProfileResponse as am, type TwilioSendChannelSyncPayload as an, type TwilioSendgridChannelSyncOptions as ao, type TwilioSendgridChannelSyncResponse as ap, type UpdateChannelPayload as aq, type UpdateChannelOptions as ar, type UpdateChannelResponse as as, type CompositionSection as at, type CompositionSectionID as au, type CreateCompositionSectionPayload as av, type CreateCompositionSectionOptions as aw, type CreateCompositionSectionResponse as ax, type GetCompositionSectionOptions as ay, type GetCompositionSectionResponse as az, type AccountID as b, type CreateCorrectionModelOptions as b$, type ActiveConversationStatus as b0, type ConcludedConversationStatus as b1, type ConversationStatus as b2, type CreateConversationPayload as b3, type CreateConversationOptions as b4, type CreateConversationResponse as b5, type DeleteConversationOptions as b6, type DeleteConversationResponse as b7, type GetConversationIncludeOptions as b8, type GetConversationOptions as b9, type ListConversationLabelsResponse as bA, type ListLabelsIncludeOptions as bB, type ListLabelsOptions as bC, type ListLabelsResponse as bD, type UpdateLabelPayload as bE, type UpdateLabelOptions as bF, type UpdateLabelResponse as bG, type Message as bH, type CreateMessagePayload as bI, type CreateMessageOptions as bJ, type CreateMessageResponse as bK, type DeleteMessageOptions as bL, type DeleteMessageResponse as bM, type ListChannelMessagesIncludeOptions as bN, type ListChannelMessagesOptions as bO, type ListChannelMessagesResponse as bP, type ListConversationMessagesIncludeOptions as bQ, type ListConversationMessagesOptions as bR, type ListConversationMessagesResponse as bS, type ListMessagesIncludeOptions as bT, type ListMessagesOptions as bU, type ListMessagesResponse as bV, type MessageID as bW, type MessageRole as bX, type MessageStatus as bY, type Model as bZ, type CreateCorrectionModelPayload as b_, type GetConversationResponse as ba, type ListChannelConversationsOptions as bb, type ListChannelConversationsResponse as bc, type ListContactConversationsOptions as bd, type ListContactConversationsResponse as be, type ListConversationsIncludeOptions as bf, type FilterOptions as bg, type ListConversationOptions as bh, type ListConversationsResponse as bi, type ListLabelConversationsOptions as bj, type ListLabelConversationsResponse as bk, type UpdateConversationPayload as bl, type UpdateConversationOptions as bm, type UpdateConversationResponse as bn, type Label as bo, type CreateLabelPayload as bp, type CreateLabelOptions as bq, type CreateLabelResponse as br, type DeleteLabelOptions as bs, type DeleteLabelResponse as bt, type GetLabelOptions as bu, type GetLabelResponse as bv, type LabelID as bw, type ListContactLabelsOptions as bx, type ListContactLabelsResponse as by, type ListConversationLabelsOptions as bz, type CreateAccountPayload as c, type CreateCorrectionResponse as c0, type CreateResponseModelPayload as c1, type CreateResponseModelOptions as c2, type CreateResponseResponse as c3, type GetModelOptions as c4, type GetModelResponse as c5, type ListModelsOptions as c6, type ListModelsResponse as c7, type ModelID as c8, type Note as c9, type NotificationSubscriptionID as cA, type Upload as cB, type CreateUploadOptions as cC, type CreateUploadResponse as cD, type DeleteUploadOptions as cE, type DeleteUploadResponse as cF, type GetUploadOptions as cG, type GetUploadResponse as cH, type UploadID as cI, type CreateWebhookPayload as cJ, type CreateWebhookOptions as cK, type CreateWebhookResponse as cL, type DeleteWebhookOptions as cM, type DeleteWebhookResponse as cN, type EventWebhookOptions as cO, eventWebhookSchema as cP, type ListWebhooksOptions as cQ, type ListWebhooksResponse as cR, type WebhookID as cS, type WebhookResponse as cT, type GetNotificationWellKnownResponse as cU, type CreateContactNotePayload as ca, type CreateContactNoteOptions as cb, type CreateContactNoteResponse as cc, type CreateConversationNotePayload as cd, type CreateConversationNoteOptions as ce, type CreateConversationNoteResponse as cf, type GetNoteOptions as cg, type GetNoteResponse as ch, type ListContactNotesOptions as ci, type ListContactNotesResponse as cj, type ListConversationNotesOptions as ck, type ListConversationNotesResponse as cl, type NoteID as cm, type UpdateNotePayload as cn, type UpdateNoteOptions as co, type UpdateNoteResponse as cp, type Source as cq, type GetSourceOptions as cr, type GetSourceResponse as cs, type ListSourcesOptions as ct, type ListSourcesResponse as cu, type SourceID as cv, type NotificationSubscription as cw, type CreateContactNotificationSubscriptionPayload as cx, type CreateContactNotificationSubscriptionOptions as cy, type CreateContactNotificationSubscriptionResponse as cz, type CreateAccountOptions as d, type CreateAccountResponse as e, type GetAccountResponse as f, type GetCurrentAccountOptions as g, type GetCurrentAccountResponse as h, type UpdateAccountOptions as i, type UpdateAccountResponse as j, type AccountAccessToken as k, type AccountAccessTokenID as l, type CreateAccountAccessTokenPayload as m, type CreateAccountAccessTokenOptions as n, type CreateAccountAccessTokenResponse as o, type DeleteAccountAccessTokenOptions as p, type DeleteAccountAccessTokenResponse as q, type GetAccountAccessTokenOptions as r, type GetAccountAccessTokenResponse as s, type ListAccountAccessTokensResponse as t, type AccountConversationSettings as u, type GetAccountConversationSettingsOptions as v, type GetAccountConversationSettingsResponse as w, type UpdateAccountConversationSettingsPayload as x, type UpdateAccountConversationSettingsOptions as y, type UpdateAccountConversationSettingsResponse as z };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var $=Object.defineProperty;var tt=(r,t)=>{for(var e in t)$(r,e,{get:t[e],enumerable:!0})};var d=class{getHeaders(){return{}}};var Q="SUPPORT_ACCESS_TOKEN",W="SUPPORT_KEY_NAME",q="SUPPORT_KEY_PASSWORD",N="SUPPORT_SIGNING_KEY",H="SUPPORT_BASE_URL";var u=class{name;#t;constructor({name:t=process.env[W],password:e=process.env[q]}={}){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(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var h=class{#t;constructor({token:t=process.env[Q]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var V="https://api.support.greatdetail.com",K={"X-Powered-By":"GDSupport/JavaScript"};import{z as s}from"zod";var Y=s.object({data:s.object({event:s.intersection(s.object({id:s.string(),createdAt:s.string().datetime()}),s.union([s.object({type:s.union([s.literal("account.created"),s.literal("account.updated")]),payload:s.object({account:s.string()})}),s.object({type:s.union([s.literal("accountAccessToken.created"),s.literal("accountAccessToken.deleted")]),payload:s.object({accountAccessToken:s.string()})}),s.object({type:s.union([s.literal("contact.created"),s.literal("contact.updated"),s.literal("contact.deleted")]),payload:s.object({contact:s.string()})}),s.object({type:s.union([s.literal("conversation.created"),s.literal("conversation.updated"),s.literal("conversation.closed"),s.literal("conversation.received"),s.literal("conversation.resolved"),s.literal("conversation.sent")]),payload:s.object({conversation:s.string()})}),s.object({type:s.union([s.literal("message.created"),s.literal("message.updated"),s.literal("message.delivered"),s.literal("message.failed"),s.literal("message.read"),s.literal("message.received"),s.literal("message.sent")]),payload:s.object({message:s.string()})})]))})});var C=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}getCurrent({request:t={}}){return this._transport.send("v1/accounts/current",{...t,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 f=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,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}delete(t,e,{body:o,request:n={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...n,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 R=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 O=class{constructor(t){this._transport=t}list({limit:t,sort:e,request:o={}}={}){return this._transport.send("v1/actions",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var g=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}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 v=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByCategory=this.listByBoilerplateCategory;listByBoilerplateCategory(t,{limit:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 b=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/channels",{...e,method:"GET",searchParams:[...this._transport.limitQuery(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})}metaWhatsappGetBusinessProfile(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}twilioSendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...o,method:"POST",json:e})}};var _=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 L=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.includeQuery(e??{})]})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",n=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(n)}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({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(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"})}};var I=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.includeQuery(e??{})]})}list({limit:t,filter:e,include:o,request:n={}}={}){return this._transport.send("v1/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(o??{})]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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"})}};var T=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,include:o,request:n={}}={}){return this._transport.send("v1/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(o??{})]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByConversation(t,{limit:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 A=class{constructor(t){this._transport=t}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/messages",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}listByConversation(t,{limit:e,include:o,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o??{})]})}listByChannel(t,{limit:e,include:o,request:n={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o)]})}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 U=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}createResponse(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...o,method:"POST",timeout:12e4,json:e})}createCorrection(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...o,method:"POST",json:e})}};var y=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}listByContact(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}listByConversation(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}createForConversation(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var S=class{constructor(t){this._transport=t}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var G=class r{constructor(t=r.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=K;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var D=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 n=[];if(e){let i=Array.isArray(e)?e:[e];for(let l of i)n.push(["category",l])}return t!==void 0&&n.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:n})}};var E=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"})}};import J from"is-network-error";import X,{HTTPError as Z}from"ky";var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends a{};var w=class extends c{static unauthenticated(){return new this("An unauthenticated request occurred")}};var P=class extends c{static forbidden(){return new this("A forbidden request occurred")}};var p=class extends a{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var B=class extends a{};var m=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var F=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=X.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let n of this.options.requestFilterables){let i=n.getHeaders();for(let[l,z]of Object.entries(i))o.headers.has(l)||o.headers.set(l,z)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[o,n]of Object.entries(t))n!==void 0&&e.push(["sort",n+o]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let o of Object.keys(t))e.push(["include",o]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let o=this.client(t,e).catch(n=>{if(J(n))throw new B("A network error occurred",{cause:n});if(n instanceof Z){let i=n.response.status;switch(console.error(JSON.stringify(n.response)),i){case 400:throw m.badRequest();case 401:throw w.unauthenticated();case 403:throw P.forbidden();case 404:throw p.notFound(t);case 405:throw p.forbiddenMethod(t,e.method??"GET");case 415:throw m.unsupportedMediaType();case 418:throw p.teapot();case 429:throw p.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw n});return{response:()=>o,json:async()=>(await o).json()}}};var M=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}create({account:t,files:e,request:o={}}){let n=new FormData;for(let i of e)n.append("file",i);return this._transport.send("v1/uploads",{...o,method:"POST",body:n,searchParams:{account:t}})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var x=class{constructor(t){this._transport=t}list({request:t={}}={}){return this._transport.send("v1/webhooks",{...t,method:"GET"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/"+encodeURIComponent(t),{...e,method:"DELETE"})}async event({key:t=process.env[N],maxSignatures:e=3,request:o}){let n=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+N);if(!n)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(n)?n.slice(0,e):[n]))throw new Error("Untrusted signature")}let{data:i}=Y.parse(o.body);return{event:i.event}}async _verifySignature(t,e,o){let n=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let i of o)if(await crypto.subtle.verify("HMAC",n,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var k=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var j=class r{static DEFAULT_BASE_URL=V;static PublicAuthentication=d;static BasicAuthentication=u;static BearerAuthentication=h;_transport;account;accountAccessToken;accountConversationSettings;action;boilerplateCategory;boilerplateContent;channel;compositionSection;contact;conversation;label;message;model;note;notificationSubscription;source;statistics;upload;webhook;wellKnown;constructor(t,{baseURL:e,...o}={}){this._transport=new F({requestFilterables:[new G,t],...o,baseURL:e?.toString()??r.getBaseURL()}),this.account=new C(this._transport),this.accountAccessToken=new f(this._transport),this.accountConversationSettings=new R(this._transport),this.action=new O(this._transport),this.boilerplateCategory=new g(this._transport),this.boilerplateContent=new v(this._transport),this.channel=new b(this._transport),this.compositionSection=new _(this._transport),this.contact=new L(this._transport),this.conversation=new I(this._transport),this.label=new T(this._transport),this.message=new A(this._transport),this.model=new U(this._transport),this.note=new y(this._transport),this.notificationSubscription=new S(this._transport),this.source=new D(this._transport),this.statistics=new E(this._transport),this.upload=new M(this._transport),this.webhook=new x(this._transport),this.wellKnown=new k(this._transport)}static getBaseURL(){return process.env[H]??this.DEFAULT_BASE_URL}};export{tt as a,d as b,V as c,a as d,c as e,w as f,P as g,p as h,B as i,m as j,Y as k,j as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as v,
|
|
1
|
+
import{b as v,l as b}from"./chunk-5NLQ55US.js";import{Command as G}from"commander";import{Command as L}from"commander";import{oraPromise as S}from"ora";function r({client:t,ora:s}){let o=new L("actions").description("Actions");return o.addCommand(new L("list").description("List actions").action(async()=>{let n=await S(()=>t.action.list().json(),{...s,text:"Finding actions"});console.log(n)})),o}import{Command as D}from"commander";import{oraPromise as M}from"ora";function d({client:t,ora:s}){let o=new D("channels").description("Channels");return o.addCommand(new D("list").description("List channels").action(async()=>{let n=await M(()=>t.channel.list().json(),{...s,text:"Finding channels"});console.log(n)})),o}import{Command as a}from"commander";import{oraPromise as c}from"ora";function p({client:t,ora:s}){let o=new a("contacts").description("Contacts");return o.addCommand(new a("get").description("Find contact").argument("<contact>","Contact ID").action(async n=>{let i=await c(()=>t.contact.get(n).json(),{...s,text:"Finding contact"});console.log(i)})),o.addCommand(new a("list").description("List contacts").action(async()=>{let n=await c(()=>t.contact.list().json(),{...s,text:"Finding contacts"});console.log(n)})),o.addCommand(new a("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async n=>{let i=await c(()=>t.contact.getVCF(n).response(),{...s,text:"Exporting contact"});console.log(i)})),o}import{Command as l}from"commander";import{oraPromise as I}from"ora";function f({client:t,ora:s}){let o=new l("conversations").description("Conversations");return o.addCommand(new l("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async n=>{let i=await I(()=>t.conversation.get(n).json(),{...s,text:"Finding conversation"});console.log(i)})),o.addCommand(new l("list").description("List conversations").action(async()=>{let n=await I(()=>t.conversation.list().json(),{...s,text:"Finding conversations"});console.log(n)})),o}import{Command as m}from"commander";import{oraPromise as u}from"ora";function C({client:t,ora:s}){let o=new m("labels").description("Labels");return o.addCommand(new m("get").description("Find label").argument("<label>","Label ID").action(async n=>{let i=await u(()=>t.label.get(n).json(),{...s,text:"Finding label"});console.log(i)})),o.addCommand(new m("list").description("List labels").action(async()=>{let n=await u(()=>t.label.list().json(),{...s,text:"Finding labels"});console.log(n)})),o.addCommand(new m("conversations").description("Find label conversations").argument("<label>","Label ID").action(async n=>{let i=await u(()=>t.conversation.listByLabel(n).json(),{...s,text:"Finding conversations"});console.log(i)})),o}import{Command as P}from"commander";import{oraPromise as W}from"ora";function g({client:t,ora:s}){let o=new P("messages").description("Messages");return o.addCommand(new P("list").description("List messages").action(async()=>{let n=await W(()=>t.message.list().json(),{...s,text:"Finding messages"});console.log(n)})),o}import{Command as w}from"commander";import{oraPromise as K}from"ora";function O({client:t,ora:s}){let o=new w("models").description("Models");return o.addCommand(new w("get").description("Find model").argument("<model>","Model ID").action(async n=>{let i=await K(()=>t.model.get(n).json(),{...s,text:"Finding model"});console.log(i)})),o.addCommand(new w("list").description("List models").action(async()=>{let n=await K(()=>t.model.list().json(),{...s,text:"Finding models"});console.log(n)})),o}import{Command as x}from"commander";import{oraPromise as h}from"ora";function y({client:t,ora:s}){let o=new x("sources").description("Sources");return o.addCommand(new x("get").description("Find source").argument("<source>","Source ID").action(async n=>{let i=await h(()=>t.source.get(n).json(),{...s,text:"Finding source"});console.log(i)})),o.addCommand(new x("list").description("List sources").action(async()=>{let n=await h(()=>t.source.list().json(),{...s,text:"Finding sources"});console.log(n)})),o}import{Command as E}from"commander";import{Command as N}from"commander";import{oraPromise as A}from"ora";function j({client:t,ora:s}){let o=new N("notifications").description("Well-Known Notifications Details");return o.addCommand(new N("get").description("Get Notifications Server Well-Known Info").action(async()=>{let n=await A(()=>t.wellKnown.getNotifications().json(),{...s,text:"Finding Notifications Well-Known Info"});console.log(n)})),o}function F({client:t,ora:s}){let o=new E("well-known").description("Well-Known Metadata & Info");return o.addCommand(j({client:t,ora:s})),o}var e={ora:{spinner:"simpleDotsScrolling"},client:new b(new v)},V=new G("gds").description("Great Detail Support System").addCommand(r(e)).addCommand(d(e)).addCommand(p(e)).addCommand(f(e)).addCommand(C(e)).addCommand(g(e)).addCommand(O(e)).addCommand(y(e)).addCommand(F(e)),Po=V;export{Po as a};
|
package/dist/cli/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Gt=Object.create;var q=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var xt=Object.getOwnPropertyNames;var Pt=Object.getPrototypeOf,Ft=Object.prototype.hasOwnProperty;var Bt=(n,t)=>{for(var e in t)q(n,e,{get:t[e],enumerable:!0})},ht=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of xt(t))!Ft.call(n,s)&&s!==e&&q(n,s,{get:()=>t[s],enumerable:!(o=Et(t,s))||o.enumerable});return n};var ft=(n,t,e)=>(e=n!=null?Gt(Pt(n)):{},ht(t||!n||!n.__esModule?q(e,"default",{value:n,enumerable:!0}):e,n)),Mt=n=>ht(q({},"__esModule",{value:!0}),n);var kt={};Bt(kt,{default:()=>Nt});module.exports=Mt(kt);var Ut=require("commander");var m=class{getHeaders(){return{}}};var C=class{constructor(t){this._transport=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 h=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,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}delete(t,e,{body:o,request:s={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...s,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 O=class{constructor(t){this._transport=t}list({limit:t,sort:e,request:o={}}={}){return this._transport.send("v1/actions",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var Ot="SUPPORT_ACCESS_TOKEN",gt="SUPPORT_KEY_NAME",Rt="SUPPORT_KEY_PASSWORD",J="SUPPORT_SIGNING_KEY",vt="SUPPORT_BASE_URL";var g=class{name;#t;constructor({name:t=process.env[gt],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(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var R=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 ${this.#t}`}}};var v=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}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 b=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByCategory=this.listByBoilerplateCategory;listByBoilerplateCategory(t,{limit:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 L=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/channels",{...e,method:"GET",searchParams:[...this._transport.limitQuery(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})}metaWhatsappGetBusinessProfile(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}twilioSendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...o,method:"POST",json:e})}};var _=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 bt="https://api.support.greatdetail.com",Lt={"X-Powered-By":"GDSupport/JavaScript"};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.includeQuery(e??{})]})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",s=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(s)}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({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(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"})}};var y=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.includeQuery(e??{})]})}list({limit:t,filter:e,include:o,request:s={}}={}){return this._transport.send("v1/conversations",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(o??{})]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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"})}};var T=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,include:o,request:s={}}={}){return this._transport.send("v1/labels",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(o??{})]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByConversation(t,{limit:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 A=class{constructor(t){this._transport=t}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/messages",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}listByConversation(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o??{})]})}listByChannel(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o)]})}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 w=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}createResponse(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...o,method:"POST",timeout:12e4,json:e})}createCorrection(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...o,method:"POST",json:e})}};var S=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}listByContact(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}listByConversation(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}createForConversation(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var U=class{constructor(t){this._transport=t}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var D=class n{constructor(t=n.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Lt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var G=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 s=[];if(e){let i=Array.isArray(e)?e:[e];for(let d of i)s.push(["category",d])}return t!==void 0&&s.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:s})}};var E=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 _t=ft(require("is-network-error"),1),K=ft(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var l=class extends a{};var x=class extends l{static unauthenticated(){return new this("An unauthenticated request occurred")}};var P=class extends l{static forbidden(){return new this("A forbidden request occurred")}};var c=class extends a{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var F=class extends a{};var u=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var B=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=K.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let s of this.options.requestFilterables){let i=s.getHeaders();for(let[d,Dt]of Object.entries(i))o.headers.has(d)||o.headers.set(d,Dt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[o,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+o]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let o of Object.keys(t))e.push(["include",o]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let o=this.client(t,e).catch(s=>{if((0,_t.default)(s))throw new F("A network error occurred",{cause:s});if(s instanceof K.HTTPError){let i=s.response.status;switch(console.error(JSON.stringify(s.response)),i){case 400:throw u.badRequest();case 401:throw x.unauthenticated();case 403:throw P.forbidden();case 404:throw c.notFound(t);case 405:throw c.forbiddenMethod(t,e.method??"GET");case 415:throw u.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw s});return{response:()=>o,json:async()=>(await o).json()}}};var M=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}create({account:t,files:e,request:o={}}){let s=new FormData;for(let i of e)s.append("file",i);return this._transport.send("v1/uploads",{...o,method:"POST",body:s,searchParams:{account:t}})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var r=require("zod"),It=r.z.object({data:r.z.object({event:r.z.intersection(r.z.object({id:r.z.string(),createdAt:r.z.string().datetime()}),r.z.union([r.z.object({type:r.z.union([r.z.literal("account.created"),r.z.literal("account.updated")]),payload:r.z.object({account:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("accountAccessToken.created"),r.z.literal("accountAccessToken.deleted")]),payload:r.z.object({accountAccessToken:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("contact.created"),r.z.literal("contact.updated"),r.z.literal("contact.deleted")]),payload:r.z.object({contact:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("conversation.created"),r.z.literal("conversation.updated"),r.z.literal("conversation.closed"),r.z.literal("conversation.received"),r.z.literal("conversation.resolved"),r.z.literal("conversation.sent")]),payload:r.z.object({conversation:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("message.created"),r.z.literal("message.updated"),r.z.literal("message.delivered"),r.z.literal("message.failed"),r.z.literal("message.read"),r.z.literal("message.received"),r.z.literal("message.sent")]),payload:r.z.object({message:r.z.string()})})]))})});var j=class{constructor(t){this._transport=t}list({request:t={}}={}){return this._transport.send("v1/webhooks",{...t,method:"GET"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/"+encodeURIComponent(t),{...e,method:"DELETE"})}async event({key:t=process.env[J],maxSignatures:e=3,request:o}){let s=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+J);if(!s)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(s)?s.slice(0,e):[s]))throw new Error("Untrusted signature")}let{data:i}=It.parse(o.body);return{event:i.event}}async _verifySignature(t,e,o){let s=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let i of o)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var N=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var k=class n{static DEFAULT_BASE_URL=bt;static PublicAuthentication=m;static BasicAuthentication=g;static BearerAuthentication=R;_transport;account;accountAccessToken;accountConversationSettings;action;boilerplateCategory;boilerplateContent;channel;compositionSection;contact;conversation;label;message;model;note;notificationSubscription;source;statistics;upload;webhook;wellKnown;constructor(t,{baseURL:e,...o}={}){this._transport=new B({requestFilterables:[new D,t],...o,baseURL:e?.toString()??n.getBaseURL()}),this.account=new C(this._transport),this.accountAccessToken=new h(this._transport),this.accountConversationSettings=new f(this._transport),this.action=new O(this._transport),this.boilerplateCategory=new v(this._transport),this.boilerplateContent=new b(this._transport),this.channel=new L(this._transport),this.compositionSection=new _(this._transport),this.contact=new I(this._transport),this.conversation=new y(this._transport),this.label=new T(this._transport),this.message=new A(this._transport),this.model=new w(this._transport),this.note=new S(this._transport),this.notificationSubscription=new U(this._transport),this.source=new G(this._transport),this.statistics=new E(this._transport),this.upload=new M(this._transport),this.webhook=new j(this._transport),this.wellKnown=new N(this._transport)}static getBaseURL(){return process.env[vt]??this.DEFAULT_BASE_URL}};var X=require("commander"),yt=require("ora");function Z({client:n,ora:t}){let e=new X.Command("actions").description("Actions");return e.addCommand(new X.Command("list").description("List actions").action(async()=>{let o=await(0,yt.oraPromise)(()=>n.action.list().json(),{...t,text:"Finding actions"});console.log(o)})),e}var tt=require("commander"),Tt=require("ora");function et({client:n,ora:t}){let e=new tt.Command("channels").description("Channels");return e.addCommand(new tt.Command("list").description("List channels").action(async()=>{let o=await(0,Tt.oraPromise)(()=>n.channel.list().json(),{...t,text:"Finding channels"});console.log(o)})),e}var Q=require("commander"),V=require("ora");function ot({client:n,ora:t}){let e=new Q.Command("contacts").description("Contacts");return e.addCommand(new Q.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async o=>{let s=await(0,V.oraPromise)(()=>n.contact.get(o).json(),{...t,text:"Finding contact"});console.log(s)})),e.addCommand(new Q.Command("list").description("List contacts").action(async()=>{let o=await(0,V.oraPromise)(()=>n.contact.list().json(),{...t,text:"Finding contacts"});console.log(o)})),e.addCommand(new Q.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async o=>{let s=await(0,V.oraPromise)(()=>n.contact.getVCF(o).response(),{...t,text:"Exporting contact"});console.log(s)})),e}var H=require("commander"),nt=require("ora");function st({client:n,ora:t}){let e=new H.Command("conversations").description("Conversations");return e.addCommand(new H.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async o=>{let s=await(0,nt.oraPromise)(()=>n.conversation.get(o).json(),{...t,text:"Finding conversation"});console.log(s)})),e.addCommand(new H.Command("list").description("List conversations").action(async()=>{let o=await(0,nt.oraPromise)(()=>n.conversation.list().json(),{...t,text:"Finding conversations"});console.log(o)})),e}var W=require("commander"),Y=require("ora");function rt({client:n,ora:t}){let e=new W.Command("labels").description("Labels");return e.addCommand(new W.Command("get").description("Find label").argument("<label>","Label ID").action(async o=>{let s=await(0,Y.oraPromise)(()=>n.label.get(o).json(),{...t,text:"Finding label"});console.log(s)})),e.addCommand(new W.Command("list").description("List labels").action(async()=>{let o=await(0,Y.oraPromise)(()=>n.label.list().json(),{...t,text:"Finding labels"});console.log(o)})),e.addCommand(new W.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async o=>{let s=await(0,Y.oraPromise)(()=>n.conversation.listByLabel(o).json(),{...t,text:"Finding conversations"});console.log(s)})),e}var it=require("commander"),At=require("ora");function at({client:n,ora:t}){let e=new it.Command("messages").description("Messages");return e.addCommand(new it.Command("list").description("List messages").action(async()=>{let o=await(0,At.oraPromise)(()=>n.message.list().json(),{...t,text:"Finding messages"});console.log(o)})),e}var z=require("commander"),pt=require("ora");function ct({client:n,ora:t}){let e=new z.Command("models").description("Models");return e.addCommand(new z.Command("get").description("Find model").argument("<model>","Model ID").action(async o=>{let s=await(0,pt.oraPromise)(()=>n.model.get(o).json(),{...t,text:"Finding model"});console.log(s)})),e.addCommand(new z.Command("list").description("List models").action(async()=>{let o=await(0,pt.oraPromise)(()=>n.model.list().json(),{...t,text:"Finding models"});console.log(o)})),e}var $=require("commander"),mt=require("ora");function lt({client:n,ora:t}){let e=new $.Command("sources").description("Sources");return e.addCommand(new $.Command("get").description("Find source").argument("<source>","Source ID").action(async o=>{let s=await(0,mt.oraPromise)(()=>n.source.get(o).json(),{...t,text:"Finding source"});console.log(s)})),e.addCommand(new $.Command("list").description("List sources").action(async()=>{let o=await(0,mt.oraPromise)(()=>n.source.list().json(),{...t,text:"Finding sources"});console.log(o)})),e}var St=require("commander");var dt=require("commander"),wt=require("ora");function ut({client:n,ora:t}){let e=new dt.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new dt.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let o=await(0,wt.oraPromise)(()=>n.wellKnown.getNotifications().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(o)})),e}function Ct({client:n,ora:t}){let e=new St.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(ut({client:n,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new k(new m)},jt=new Ut.Command("gds").description("Great Detail Support System").addCommand(Z(p)).addCommand(et(p)).addCommand(ot(p)).addCommand(st(p)).addCommand(rt(p)).addCommand(at(p)).addCommand(ct(p)).addCommand(lt(p)).addCommand(Ct(p)),Nt=jt;
|
|
1
|
+
"use strict";var Gt=Object.create;var q=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var xt=Object.getOwnPropertyNames;var Pt=Object.getPrototypeOf,Ft=Object.prototype.hasOwnProperty;var Bt=(n,t)=>{for(var e in t)q(n,e,{get:t[e],enumerable:!0})},ht=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of xt(t))!Ft.call(n,s)&&s!==e&&q(n,s,{get:()=>t[s],enumerable:!(o=Et(t,s))||o.enumerable});return n};var ft=(n,t,e)=>(e=n!=null?Gt(Pt(n)):{},ht(t||!n||!n.__esModule?q(e,"default",{value:n,enumerable:!0}):e,n)),Mt=n=>ht(q({},"__esModule",{value:!0}),n);var kt={};Bt(kt,{default:()=>Nt});module.exports=Mt(kt);var Ut=require("commander");var m=class{getHeaders(){return{}}};var C=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}getCurrent({request:t={}}){return this._transport.send("v1/accounts/current",{...t,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 h=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,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}delete(t,e,{body:o,request:s={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...s,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 O=class{constructor(t){this._transport=t}list({limit:t,sort:e,request:o={}}={}){return this._transport.send("v1/actions",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var Ot="SUPPORT_ACCESS_TOKEN",gt="SUPPORT_KEY_NAME",Rt="SUPPORT_KEY_PASSWORD",J="SUPPORT_SIGNING_KEY",vt="SUPPORT_BASE_URL";var g=class{name;#t;constructor({name:t=process.env[gt],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(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var R=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 ${this.#t}`}}};var v=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}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 b=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByCategory=this.listByBoilerplateCategory;listByBoilerplateCategory(t,{limit:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 L=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/channels",{...e,method:"GET",searchParams:[...this._transport.limitQuery(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})}metaWhatsappGetBusinessProfile(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}twilioSendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...o,method:"POST",json:e})}};var _=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 bt="https://api.support.greatdetail.com",Lt={"X-Powered-By":"GDSupport/JavaScript"};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.includeQuery(e??{})]})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",s=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(s)}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({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(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"})}};var y=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.includeQuery(e??{})]})}list({limit:t,filter:e,include:o,request:s={}}={}){return this._transport.send("v1/conversations",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(o??{})]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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"})}};var T=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,include:o,request:s={}}={}){return this._transport.send("v1/labels",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(o??{})]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByConversation(t,{limit:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 A=class{constructor(t){this._transport=t}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/messages",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}listByConversation(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o??{})]})}listByChannel(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o)]})}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 w=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}createResponse(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...o,method:"POST",timeout:12e4,json:e})}createCorrection(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...o,method:"POST",json:e})}};var S=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}listByContact(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}listByConversation(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}createForConversation(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var U=class{constructor(t){this._transport=t}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var D=class n{constructor(t=n.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Lt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var G=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 s=[];if(e){let i=Array.isArray(e)?e:[e];for(let d of i)s.push(["category",d])}return t!==void 0&&s.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:s})}};var E=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 _t=ft(require("is-network-error"),1),K=ft(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var l=class extends a{};var x=class extends l{static unauthenticated(){return new this("An unauthenticated request occurred")}};var P=class extends l{static forbidden(){return new this("A forbidden request occurred")}};var c=class extends a{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var F=class extends a{};var u=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var B=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=K.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let s of this.options.requestFilterables){let i=s.getHeaders();for(let[d,Dt]of Object.entries(i))o.headers.has(d)||o.headers.set(d,Dt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[o,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+o]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let o of Object.keys(t))e.push(["include",o]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let o=this.client(t,e).catch(s=>{if((0,_t.default)(s))throw new F("A network error occurred",{cause:s});if(s instanceof K.HTTPError){let i=s.response.status;switch(console.error(JSON.stringify(s.response)),i){case 400:throw u.badRequest();case 401:throw x.unauthenticated();case 403:throw P.forbidden();case 404:throw c.notFound(t);case 405:throw c.forbiddenMethod(t,e.method??"GET");case 415:throw u.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw s});return{response:()=>o,json:async()=>(await o).json()}}};var M=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}create({account:t,files:e,request:o={}}){let s=new FormData;for(let i of e)s.append("file",i);return this._transport.send("v1/uploads",{...o,method:"POST",body:s,searchParams:{account:t}})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var r=require("zod"),It=r.z.object({data:r.z.object({event:r.z.intersection(r.z.object({id:r.z.string(),createdAt:r.z.string().datetime()}),r.z.union([r.z.object({type:r.z.union([r.z.literal("account.created"),r.z.literal("account.updated")]),payload:r.z.object({account:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("accountAccessToken.created"),r.z.literal("accountAccessToken.deleted")]),payload:r.z.object({accountAccessToken:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("contact.created"),r.z.literal("contact.updated"),r.z.literal("contact.deleted")]),payload:r.z.object({contact:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("conversation.created"),r.z.literal("conversation.updated"),r.z.literal("conversation.closed"),r.z.literal("conversation.received"),r.z.literal("conversation.resolved"),r.z.literal("conversation.sent")]),payload:r.z.object({conversation:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("message.created"),r.z.literal("message.updated"),r.z.literal("message.delivered"),r.z.literal("message.failed"),r.z.literal("message.read"),r.z.literal("message.received"),r.z.literal("message.sent")]),payload:r.z.object({message:r.z.string()})})]))})});var j=class{constructor(t){this._transport=t}list({request:t={}}={}){return this._transport.send("v1/webhooks",{...t,method:"GET"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/"+encodeURIComponent(t),{...e,method:"DELETE"})}async event({key:t=process.env[J],maxSignatures:e=3,request:o}){let s=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+J);if(!s)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(s)?s.slice(0,e):[s]))throw new Error("Untrusted signature")}let{data:i}=It.parse(o.body);return{event:i.event}}async _verifySignature(t,e,o){let s=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let i of o)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var N=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var k=class n{static DEFAULT_BASE_URL=bt;static PublicAuthentication=m;static BasicAuthentication=g;static BearerAuthentication=R;_transport;account;accountAccessToken;accountConversationSettings;action;boilerplateCategory;boilerplateContent;channel;compositionSection;contact;conversation;label;message;model;note;notificationSubscription;source;statistics;upload;webhook;wellKnown;constructor(t,{baseURL:e,...o}={}){this._transport=new B({requestFilterables:[new D,t],...o,baseURL:e?.toString()??n.getBaseURL()}),this.account=new C(this._transport),this.accountAccessToken=new h(this._transport),this.accountConversationSettings=new f(this._transport),this.action=new O(this._transport),this.boilerplateCategory=new v(this._transport),this.boilerplateContent=new b(this._transport),this.channel=new L(this._transport),this.compositionSection=new _(this._transport),this.contact=new I(this._transport),this.conversation=new y(this._transport),this.label=new T(this._transport),this.message=new A(this._transport),this.model=new w(this._transport),this.note=new S(this._transport),this.notificationSubscription=new U(this._transport),this.source=new G(this._transport),this.statistics=new E(this._transport),this.upload=new M(this._transport),this.webhook=new j(this._transport),this.wellKnown=new N(this._transport)}static getBaseURL(){return process.env[vt]??this.DEFAULT_BASE_URL}};var X=require("commander"),yt=require("ora");function Z({client:n,ora:t}){let e=new X.Command("actions").description("Actions");return e.addCommand(new X.Command("list").description("List actions").action(async()=>{let o=await(0,yt.oraPromise)(()=>n.action.list().json(),{...t,text:"Finding actions"});console.log(o)})),e}var tt=require("commander"),Tt=require("ora");function et({client:n,ora:t}){let e=new tt.Command("channels").description("Channels");return e.addCommand(new tt.Command("list").description("List channels").action(async()=>{let o=await(0,Tt.oraPromise)(()=>n.channel.list().json(),{...t,text:"Finding channels"});console.log(o)})),e}var Q=require("commander"),V=require("ora");function ot({client:n,ora:t}){let e=new Q.Command("contacts").description("Contacts");return e.addCommand(new Q.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async o=>{let s=await(0,V.oraPromise)(()=>n.contact.get(o).json(),{...t,text:"Finding contact"});console.log(s)})),e.addCommand(new Q.Command("list").description("List contacts").action(async()=>{let o=await(0,V.oraPromise)(()=>n.contact.list().json(),{...t,text:"Finding contacts"});console.log(o)})),e.addCommand(new Q.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async o=>{let s=await(0,V.oraPromise)(()=>n.contact.getVCF(o).response(),{...t,text:"Exporting contact"});console.log(s)})),e}var H=require("commander"),nt=require("ora");function st({client:n,ora:t}){let e=new H.Command("conversations").description("Conversations");return e.addCommand(new H.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async o=>{let s=await(0,nt.oraPromise)(()=>n.conversation.get(o).json(),{...t,text:"Finding conversation"});console.log(s)})),e.addCommand(new H.Command("list").description("List conversations").action(async()=>{let o=await(0,nt.oraPromise)(()=>n.conversation.list().json(),{...t,text:"Finding conversations"});console.log(o)})),e}var W=require("commander"),Y=require("ora");function rt({client:n,ora:t}){let e=new W.Command("labels").description("Labels");return e.addCommand(new W.Command("get").description("Find label").argument("<label>","Label ID").action(async o=>{let s=await(0,Y.oraPromise)(()=>n.label.get(o).json(),{...t,text:"Finding label"});console.log(s)})),e.addCommand(new W.Command("list").description("List labels").action(async()=>{let o=await(0,Y.oraPromise)(()=>n.label.list().json(),{...t,text:"Finding labels"});console.log(o)})),e.addCommand(new W.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async o=>{let s=await(0,Y.oraPromise)(()=>n.conversation.listByLabel(o).json(),{...t,text:"Finding conversations"});console.log(s)})),e}var it=require("commander"),At=require("ora");function at({client:n,ora:t}){let e=new it.Command("messages").description("Messages");return e.addCommand(new it.Command("list").description("List messages").action(async()=>{let o=await(0,At.oraPromise)(()=>n.message.list().json(),{...t,text:"Finding messages"});console.log(o)})),e}var z=require("commander"),pt=require("ora");function ct({client:n,ora:t}){let e=new z.Command("models").description("Models");return e.addCommand(new z.Command("get").description("Find model").argument("<model>","Model ID").action(async o=>{let s=await(0,pt.oraPromise)(()=>n.model.get(o).json(),{...t,text:"Finding model"});console.log(s)})),e.addCommand(new z.Command("list").description("List models").action(async()=>{let o=await(0,pt.oraPromise)(()=>n.model.list().json(),{...t,text:"Finding models"});console.log(o)})),e}var $=require("commander"),mt=require("ora");function lt({client:n,ora:t}){let e=new $.Command("sources").description("Sources");return e.addCommand(new $.Command("get").description("Find source").argument("<source>","Source ID").action(async o=>{let s=await(0,mt.oraPromise)(()=>n.source.get(o).json(),{...t,text:"Finding source"});console.log(s)})),e.addCommand(new $.Command("list").description("List sources").action(async()=>{let o=await(0,mt.oraPromise)(()=>n.source.list().json(),{...t,text:"Finding sources"});console.log(o)})),e}var St=require("commander");var dt=require("commander"),wt=require("ora");function ut({client:n,ora:t}){let e=new dt.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new dt.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let o=await(0,wt.oraPromise)(()=>n.wellKnown.getNotifications().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(o)})),e}function Ct({client:n,ora:t}){let e=new St.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(ut({client:n,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new k(new m)},jt=new Ut.Command("gds").description("Great Detail Support System").addCommand(Z(p)).addCommand(et(p)).addCommand(ot(p)).addCommand(st(p)).addCommand(rt(p)).addCommand(at(p)).addCommand(ct(p)).addCommand(lt(p)).addCommand(Ct(p)),Nt=jt;
|
package/dist/cli/index.d.cts
CHANGED
package/dist/cli/index.d.ts
CHANGED
package/dist/cli/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-SNJCTFV7.js";import"../chunk-5NLQ55US.js";export{a as default};
|
package/dist/cli.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var Gt=Object.create;var Ct=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var xt=Object.getOwnPropertyNames;var Pt=Object.getPrototypeOf,Ft=Object.prototype.hasOwnProperty;var Bt=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of xt(t))!Ft.call(n,s)&&s!==e&&Ct(n,s,{get:()=>t[s],enumerable:!(o=Et(t,s))||o.enumerable});return n};var ht=(n,t,e)=>(e=n!=null?Gt(Pt(n)):{},Bt(t||!n||!n.__esModule?Ct(e,"default",{value:n,enumerable:!0}):e,n));var St=require("commander");var m=class{getHeaders(){return{}}};var C=class{constructor(t){this._transport=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 h=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,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}delete(t,e,{body:o,request:s={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...s,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 O=class{constructor(t){this._transport=t}list({limit:t,sort:e,request:o={}}={}){return this._transport.send("v1/actions",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var ft="SUPPORT_ACCESS_TOKEN",Ot="SUPPORT_KEY_NAME",gt="SUPPORT_KEY_PASSWORD",$="SUPPORT_SIGNING_KEY",Rt="SUPPORT_BASE_URL";var g=class{name;#t;constructor({name:t=process.env[Ot],password:e=process.env[gt]}={}){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(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var R=class{#t;constructor({token:t=process.env[ft]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var v=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}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 b=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByCategory=this.listByBoilerplateCategory;listByBoilerplateCategory(t,{limit:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 L=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/channels",{...e,method:"GET",searchParams:[...this._transport.limitQuery(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})}metaWhatsappGetBusinessProfile(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}twilioSendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...o,method:"POST",json:e})}};var _=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 vt="https://api.support.greatdetail.com",bt={"X-Powered-By":"GDSupport/JavaScript"};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.includeQuery(e??{})]})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",s=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(s)}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({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(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"})}};var y=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.includeQuery(e??{})]})}list({limit:t,filter:e,include:o,request:s={}}={}){return this._transport.send("v1/conversations",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(o??{})]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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"})}};var T=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,include:o,request:s={}}={}){return this._transport.send("v1/labels",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(o??{})]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByConversation(t,{limit:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 A=class{constructor(t){this._transport=t}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/messages",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}listByConversation(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o??{})]})}listByChannel(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o)]})}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 w=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}createResponse(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...o,method:"POST",timeout:12e4,json:e})}createCorrection(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...o,method:"POST",json:e})}};var S=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}listByContact(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}listByConversation(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}createForConversation(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var U=class{constructor(t){this._transport=t}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var D=class n{constructor(t=n.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=bt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var G=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 s=[];if(e){let i=Array.isArray(e)?e:[e];for(let d of i)s.push(["category",d])}return t!==void 0&&s.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:s})}};var E=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 Lt=ht(require("is-network-error"),1),q=ht(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var l=class extends a{};var x=class extends l{static unauthenticated(){return new this("An unauthenticated request occurred")}};var P=class extends l{static forbidden(){return new this("A forbidden request occurred")}};var c=class extends a{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var F=class extends a{};var u=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var B=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=q.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let s of this.options.requestFilterables){let i=s.getHeaders();for(let[d,Dt]of Object.entries(i))o.headers.has(d)||o.headers.set(d,Dt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[o,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+o]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let o of Object.keys(t))e.push(["include",o]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let o=this.client(t,e).catch(s=>{if((0,Lt.default)(s))throw new F("A network error occurred",{cause:s});if(s instanceof q.HTTPError){let i=s.response.status;switch(console.error(JSON.stringify(s.response)),i){case 400:throw u.badRequest();case 401:throw x.unauthenticated();case 403:throw P.forbidden();case 404:throw c.notFound(t);case 405:throw c.forbiddenMethod(t,e.method??"GET");case 415:throw u.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw s});return{response:()=>o,json:async()=>(await o).json()}}};var M=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}create({account:t,files:e,request:o={}}){let s=new FormData;for(let i of e)s.append("file",i);return this._transport.send("v1/uploads",{...o,method:"POST",body:s,searchParams:{account:t}})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var r=require("zod"),_t=r.z.object({data:r.z.object({event:r.z.intersection(r.z.object({id:r.z.string(),createdAt:r.z.string().datetime()}),r.z.union([r.z.object({type:r.z.union([r.z.literal("account.created"),r.z.literal("account.updated")]),payload:r.z.object({account:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("accountAccessToken.created"),r.z.literal("accountAccessToken.deleted")]),payload:r.z.object({accountAccessToken:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("contact.created"),r.z.literal("contact.updated"),r.z.literal("contact.deleted")]),payload:r.z.object({contact:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("conversation.created"),r.z.literal("conversation.updated"),r.z.literal("conversation.closed"),r.z.literal("conversation.received"),r.z.literal("conversation.resolved"),r.z.literal("conversation.sent")]),payload:r.z.object({conversation:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("message.created"),r.z.literal("message.updated"),r.z.literal("message.delivered"),r.z.literal("message.failed"),r.z.literal("message.read"),r.z.literal("message.received"),r.z.literal("message.sent")]),payload:r.z.object({message:r.z.string()})})]))})});var j=class{constructor(t){this._transport=t}list({request:t={}}={}){return this._transport.send("v1/webhooks",{...t,method:"GET"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/"+encodeURIComponent(t),{...e,method:"DELETE"})}async event({key:t=process.env[$],maxSignatures:e=3,request:o}){let s=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+$);if(!s)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(s)?s.slice(0,e):[s]))throw new Error("Untrusted signature")}let{data:i}=_t.parse(o.body);return{event:i.event}}async _verifySignature(t,e,o){let s=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let i of o)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var N=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var k=class n{static DEFAULT_BASE_URL=vt;static PublicAuthentication=m;static BasicAuthentication=g;static BearerAuthentication=R;_transport;account;accountAccessToken;accountConversationSettings;action;boilerplateCategory;boilerplateContent;channel;compositionSection;contact;conversation;label;message;model;note;notificationSubscription;source;statistics;upload;webhook;wellKnown;constructor(t,{baseURL:e,...o}={}){this._transport=new B({requestFilterables:[new D,t],...o,baseURL:e?.toString()??n.getBaseURL()}),this.account=new C(this._transport),this.accountAccessToken=new h(this._transport),this.accountConversationSettings=new f(this._transport),this.action=new O(this._transport),this.boilerplateCategory=new v(this._transport),this.boilerplateContent=new b(this._transport),this.channel=new L(this._transport),this.compositionSection=new _(this._transport),this.contact=new I(this._transport),this.conversation=new y(this._transport),this.label=new T(this._transport),this.message=new A(this._transport),this.model=new w(this._transport),this.note=new S(this._transport),this.notificationSubscription=new U(this._transport),this.source=new G(this._transport),this.statistics=new E(this._transport),this.upload=new M(this._transport),this.webhook=new j(this._transport),this.wellKnown=new N(this._transport)}static getBaseURL(){return process.env[Rt]??this.DEFAULT_BASE_URL}};var J=require("commander"),It=require("ora");function X({client:n,ora:t}){let e=new J.Command("actions").description("Actions");return e.addCommand(new J.Command("list").description("List actions").action(async()=>{let o=await(0,It.oraPromise)(()=>n.action.list().json(),{...t,text:"Finding actions"});console.log(o)})),e}var Z=require("commander"),yt=require("ora");function tt({client:n,ora:t}){let e=new Z.Command("channels").description("Channels");return e.addCommand(new Z.Command("list").description("List channels").action(async()=>{let o=await(0,yt.oraPromise)(()=>n.channel.list().json(),{...t,text:"Finding channels"});console.log(o)})),e}var Q=require("commander"),K=require("ora");function et({client:n,ora:t}){let e=new Q.Command("contacts").description("Contacts");return e.addCommand(new Q.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async o=>{let s=await(0,K.oraPromise)(()=>n.contact.get(o).json(),{...t,text:"Finding contact"});console.log(s)})),e.addCommand(new Q.Command("list").description("List contacts").action(async()=>{let o=await(0,K.oraPromise)(()=>n.contact.list().json(),{...t,text:"Finding contacts"});console.log(o)})),e.addCommand(new Q.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async o=>{let s=await(0,K.oraPromise)(()=>n.contact.getVCF(o).response(),{...t,text:"Exporting contact"});console.log(s)})),e}var V=require("commander"),ot=require("ora");function nt({client:n,ora:t}){let e=new V.Command("conversations").description("Conversations");return e.addCommand(new V.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async o=>{let s=await(0,ot.oraPromise)(()=>n.conversation.get(o).json(),{...t,text:"Finding conversation"});console.log(s)})),e.addCommand(new V.Command("list").description("List conversations").action(async()=>{let o=await(0,ot.oraPromise)(()=>n.conversation.list().json(),{...t,text:"Finding conversations"});console.log(o)})),e}var W=require("commander"),H=require("ora");function st({client:n,ora:t}){let e=new W.Command("labels").description("Labels");return e.addCommand(new W.Command("get").description("Find label").argument("<label>","Label ID").action(async o=>{let s=await(0,H.oraPromise)(()=>n.label.get(o).json(),{...t,text:"Finding label"});console.log(s)})),e.addCommand(new W.Command("list").description("List labels").action(async()=>{let o=await(0,H.oraPromise)(()=>n.label.list().json(),{...t,text:"Finding labels"});console.log(o)})),e.addCommand(new W.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async o=>{let s=await(0,H.oraPromise)(()=>n.conversation.listByLabel(o).json(),{...t,text:"Finding conversations"});console.log(s)})),e}var rt=require("commander"),Tt=require("ora");function it({client:n,ora:t}){let e=new rt.Command("messages").description("Messages");return e.addCommand(new rt.Command("list").description("List messages").action(async()=>{let o=await(0,Tt.oraPromise)(()=>n.message.list().json(),{...t,text:"Finding messages"});console.log(o)})),e}var Y=require("commander"),at=require("ora");function pt({client:n,ora:t}){let e=new Y.Command("models").description("Models");return e.addCommand(new Y.Command("get").description("Find model").argument("<model>","Model ID").action(async o=>{let s=await(0,at.oraPromise)(()=>n.model.get(o).json(),{...t,text:"Finding model"});console.log(s)})),e.addCommand(new Y.Command("list").description("List models").action(async()=>{let o=await(0,at.oraPromise)(()=>n.model.list().json(),{...t,text:"Finding models"});console.log(o)})),e}var z=require("commander"),ct=require("ora");function mt({client:n,ora:t}){let e=new z.Command("sources").description("Sources");return e.addCommand(new z.Command("get").description("Find source").argument("<source>","Source ID").action(async o=>{let s=await(0,ct.oraPromise)(()=>n.source.get(o).json(),{...t,text:"Finding source"});console.log(s)})),e.addCommand(new z.Command("list").description("List sources").action(async()=>{let o=await(0,ct.oraPromise)(()=>n.source.list().json(),{...t,text:"Finding sources"});console.log(o)})),e}var wt=require("commander");var lt=require("commander"),At=require("ora");function dt({client:n,ora:t}){let e=new lt.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new lt.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let o=await(0,At.oraPromise)(()=>n.wellKnown.getNotifications().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(o)})),e}function ut({client:n,ora:t}){let e=new wt.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(dt({client:n,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new k(new m)},Mt=new St.Command("gds").description("Great Detail Support System").addCommand(X(p)).addCommand(tt(p)).addCommand(et(p)).addCommand(nt(p)).addCommand(st(p)).addCommand(it(p)).addCommand(pt(p)).addCommand(mt(p)).addCommand(ut(p)),Ut=Mt;Ut.parseAsync(process.argv);
|
|
2
|
+
"use strict";var Gt=Object.create;var Ct=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var xt=Object.getOwnPropertyNames;var Pt=Object.getPrototypeOf,Ft=Object.prototype.hasOwnProperty;var Bt=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of xt(t))!Ft.call(n,s)&&s!==e&&Ct(n,s,{get:()=>t[s],enumerable:!(o=Et(t,s))||o.enumerable});return n};var ht=(n,t,e)=>(e=n!=null?Gt(Pt(n)):{},Bt(t||!n||!n.__esModule?Ct(e,"default",{value:n,enumerable:!0}):e,n));var St=require("commander");var m=class{getHeaders(){return{}}};var C=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}getCurrent({request:t={}}){return this._transport.send("v1/accounts/current",{...t,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 h=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,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}delete(t,e,{body:o,request:s={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...s,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 O=class{constructor(t){this._transport=t}list({limit:t,sort:e,request:o={}}={}){return this._transport.send("v1/actions",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var ft="SUPPORT_ACCESS_TOKEN",Ot="SUPPORT_KEY_NAME",gt="SUPPORT_KEY_PASSWORD",$="SUPPORT_SIGNING_KEY",Rt="SUPPORT_BASE_URL";var g=class{name;#t;constructor({name:t=process.env[Ot],password:e=process.env[gt]}={}){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(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var R=class{#t;constructor({token:t=process.env[ft]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var v=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}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 b=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByCategory=this.listByBoilerplateCategory;listByBoilerplateCategory(t,{limit:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 L=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/channels",{...e,method:"GET",searchParams:[...this._transport.limitQuery(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})}metaWhatsappGetBusinessProfile(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}twilioSendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...o,method:"POST",json:e})}};var _=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 vt="https://api.support.greatdetail.com",bt={"X-Powered-By":"GDSupport/JavaScript"};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.includeQuery(e??{})]})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",s=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(s)}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({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(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"})}};var y=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.includeQuery(e??{})]})}list({limit:t,filter:e,include:o,request:s={}}={}){return this._transport.send("v1/conversations",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(o??{})]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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"})}};var T=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,include:o,request:s={}}={}){return this._transport.send("v1/labels",{...s,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(o??{})]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByConversation(t,{limit:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 A=class{constructor(t){this._transport=t}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/messages",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}listByConversation(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o??{})]})}listByChannel(t,{limit:e,include:o,request:s={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...s,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o)]})}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 w=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}createResponse(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...o,method:"POST",timeout:12e4,json:e})}createCorrection(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...o,method:"POST",json:e})}};var S=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}listByContact(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}listByConversation(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}createForConversation(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var U=class{constructor(t){this._transport=t}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var D=class n{constructor(t=n.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=bt;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var G=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 s=[];if(e){let i=Array.isArray(e)?e:[e];for(let d of i)s.push(["category",d])}return t!==void 0&&s.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:s})}};var E=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 Lt=ht(require("is-network-error"),1),q=ht(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var l=class extends a{};var x=class extends l{static unauthenticated(){return new this("An unauthenticated request occurred")}};var P=class extends l{static forbidden(){return new this("A forbidden request occurred")}};var c=class extends a{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var F=class extends a{};var u=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var B=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=q.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let s of this.options.requestFilterables){let i=s.getHeaders();for(let[d,Dt]of Object.entries(i))o.headers.has(d)||o.headers.set(d,Dt)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[o,s]of Object.entries(t))s!==void 0&&e.push(["sort",s+o]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let o of Object.keys(t))e.push(["include",o]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let o=this.client(t,e).catch(s=>{if((0,Lt.default)(s))throw new F("A network error occurred",{cause:s});if(s instanceof q.HTTPError){let i=s.response.status;switch(console.error(JSON.stringify(s.response)),i){case 400:throw u.badRequest();case 401:throw x.unauthenticated();case 403:throw P.forbidden();case 404:throw c.notFound(t);case 405:throw c.forbiddenMethod(t,e.method??"GET");case 415:throw u.unsupportedMediaType();case 418:throw c.teapot();case 429:throw c.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw s});return{response:()=>o,json:async()=>(await o).json()}}};var M=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}create({account:t,files:e,request:o={}}){let s=new FormData;for(let i of e)s.append("file",i);return this._transport.send("v1/uploads",{...o,method:"POST",body:s,searchParams:{account:t}})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var r=require("zod"),_t=r.z.object({data:r.z.object({event:r.z.intersection(r.z.object({id:r.z.string(),createdAt:r.z.string().datetime()}),r.z.union([r.z.object({type:r.z.union([r.z.literal("account.created"),r.z.literal("account.updated")]),payload:r.z.object({account:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("accountAccessToken.created"),r.z.literal("accountAccessToken.deleted")]),payload:r.z.object({accountAccessToken:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("contact.created"),r.z.literal("contact.updated"),r.z.literal("contact.deleted")]),payload:r.z.object({contact:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("conversation.created"),r.z.literal("conversation.updated"),r.z.literal("conversation.closed"),r.z.literal("conversation.received"),r.z.literal("conversation.resolved"),r.z.literal("conversation.sent")]),payload:r.z.object({conversation:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("message.created"),r.z.literal("message.updated"),r.z.literal("message.delivered"),r.z.literal("message.failed"),r.z.literal("message.read"),r.z.literal("message.received"),r.z.literal("message.sent")]),payload:r.z.object({message:r.z.string()})})]))})});var j=class{constructor(t){this._transport=t}list({request:t={}}={}){return this._transport.send("v1/webhooks",{...t,method:"GET"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/"+encodeURIComponent(t),{...e,method:"DELETE"})}async event({key:t=process.env[$],maxSignatures:e=3,request:o}){let s=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+$);if(!s)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(s)?s.slice(0,e):[s]))throw new Error("Untrusted signature")}let{data:i}=_t.parse(o.body);return{event:i.event}}async _verifySignature(t,e,o){let s=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let i of o)if(await crypto.subtle.verify("HMAC",s,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var N=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var k=class n{static DEFAULT_BASE_URL=vt;static PublicAuthentication=m;static BasicAuthentication=g;static BearerAuthentication=R;_transport;account;accountAccessToken;accountConversationSettings;action;boilerplateCategory;boilerplateContent;channel;compositionSection;contact;conversation;label;message;model;note;notificationSubscription;source;statistics;upload;webhook;wellKnown;constructor(t,{baseURL:e,...o}={}){this._transport=new B({requestFilterables:[new D,t],...o,baseURL:e?.toString()??n.getBaseURL()}),this.account=new C(this._transport),this.accountAccessToken=new h(this._transport),this.accountConversationSettings=new f(this._transport),this.action=new O(this._transport),this.boilerplateCategory=new v(this._transport),this.boilerplateContent=new b(this._transport),this.channel=new L(this._transport),this.compositionSection=new _(this._transport),this.contact=new I(this._transport),this.conversation=new y(this._transport),this.label=new T(this._transport),this.message=new A(this._transport),this.model=new w(this._transport),this.note=new S(this._transport),this.notificationSubscription=new U(this._transport),this.source=new G(this._transport),this.statistics=new E(this._transport),this.upload=new M(this._transport),this.webhook=new j(this._transport),this.wellKnown=new N(this._transport)}static getBaseURL(){return process.env[Rt]??this.DEFAULT_BASE_URL}};var J=require("commander"),It=require("ora");function X({client:n,ora:t}){let e=new J.Command("actions").description("Actions");return e.addCommand(new J.Command("list").description("List actions").action(async()=>{let o=await(0,It.oraPromise)(()=>n.action.list().json(),{...t,text:"Finding actions"});console.log(o)})),e}var Z=require("commander"),yt=require("ora");function tt({client:n,ora:t}){let e=new Z.Command("channels").description("Channels");return e.addCommand(new Z.Command("list").description("List channels").action(async()=>{let o=await(0,yt.oraPromise)(()=>n.channel.list().json(),{...t,text:"Finding channels"});console.log(o)})),e}var Q=require("commander"),K=require("ora");function et({client:n,ora:t}){let e=new Q.Command("contacts").description("Contacts");return e.addCommand(new Q.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async o=>{let s=await(0,K.oraPromise)(()=>n.contact.get(o).json(),{...t,text:"Finding contact"});console.log(s)})),e.addCommand(new Q.Command("list").description("List contacts").action(async()=>{let o=await(0,K.oraPromise)(()=>n.contact.list().json(),{...t,text:"Finding contacts"});console.log(o)})),e.addCommand(new Q.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async o=>{let s=await(0,K.oraPromise)(()=>n.contact.getVCF(o).response(),{...t,text:"Exporting contact"});console.log(s)})),e}var V=require("commander"),ot=require("ora");function nt({client:n,ora:t}){let e=new V.Command("conversations").description("Conversations");return e.addCommand(new V.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async o=>{let s=await(0,ot.oraPromise)(()=>n.conversation.get(o).json(),{...t,text:"Finding conversation"});console.log(s)})),e.addCommand(new V.Command("list").description("List conversations").action(async()=>{let o=await(0,ot.oraPromise)(()=>n.conversation.list().json(),{...t,text:"Finding conversations"});console.log(o)})),e}var W=require("commander"),H=require("ora");function st({client:n,ora:t}){let e=new W.Command("labels").description("Labels");return e.addCommand(new W.Command("get").description("Find label").argument("<label>","Label ID").action(async o=>{let s=await(0,H.oraPromise)(()=>n.label.get(o).json(),{...t,text:"Finding label"});console.log(s)})),e.addCommand(new W.Command("list").description("List labels").action(async()=>{let o=await(0,H.oraPromise)(()=>n.label.list().json(),{...t,text:"Finding labels"});console.log(o)})),e.addCommand(new W.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async o=>{let s=await(0,H.oraPromise)(()=>n.conversation.listByLabel(o).json(),{...t,text:"Finding conversations"});console.log(s)})),e}var rt=require("commander"),Tt=require("ora");function it({client:n,ora:t}){let e=new rt.Command("messages").description("Messages");return e.addCommand(new rt.Command("list").description("List messages").action(async()=>{let o=await(0,Tt.oraPromise)(()=>n.message.list().json(),{...t,text:"Finding messages"});console.log(o)})),e}var Y=require("commander"),at=require("ora");function pt({client:n,ora:t}){let e=new Y.Command("models").description("Models");return e.addCommand(new Y.Command("get").description("Find model").argument("<model>","Model ID").action(async o=>{let s=await(0,at.oraPromise)(()=>n.model.get(o).json(),{...t,text:"Finding model"});console.log(s)})),e.addCommand(new Y.Command("list").description("List models").action(async()=>{let o=await(0,at.oraPromise)(()=>n.model.list().json(),{...t,text:"Finding models"});console.log(o)})),e}var z=require("commander"),ct=require("ora");function mt({client:n,ora:t}){let e=new z.Command("sources").description("Sources");return e.addCommand(new z.Command("get").description("Find source").argument("<source>","Source ID").action(async o=>{let s=await(0,ct.oraPromise)(()=>n.source.get(o).json(),{...t,text:"Finding source"});console.log(s)})),e.addCommand(new z.Command("list").description("List sources").action(async()=>{let o=await(0,ct.oraPromise)(()=>n.source.list().json(),{...t,text:"Finding sources"});console.log(o)})),e}var wt=require("commander");var lt=require("commander"),At=require("ora");function dt({client:n,ora:t}){let e=new lt.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new lt.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let o=await(0,At.oraPromise)(()=>n.wellKnown.getNotifications().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(o)})),e}function ut({client:n,ora:t}){let e=new wt.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(dt({client:n,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new k(new m)},Mt=new St.Command("gds").description("Great Detail Support System").addCommand(X(p)).addCommand(tt(p)).addCommand(et(p)).addCommand(nt(p)).addCommand(st(p)).addCommand(it(p)).addCommand(pt(p)).addCommand(mt(p)).addCommand(ut(p)),Ut=Mt;Ut.parseAsync(process.argv);
|
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-SNJCTFV7.js";import"./chunk-5NLQ55US.js";r.parseAsync(process.argv);
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var st=Object.create;var j=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,pt=Object.prototype.hasOwnProperty;var H=(s,t)=>{for(var e in t)j(s,e,{get:t[e],enumerable:!0})},K=(s,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of nt(t))!pt.call(s,n)&&n!==e&&j(s,n,{get:()=>t[n],enumerable:!(o=rt(t,n))||o.enumerable});return s};var Y=(s,t,e)=>(e=s!=null?st(it(s)):{},K(t||!s||!s.__esModule?j(e,"default",{value:s,enumerable:!0}):e,s)),at=s=>K(j({},"__esModule",{value:!0}),s);var ct={};H(ct,{Client:()=>h,DEFAULT_SUPPORT_BASE_URL:()=>Q,Error:()=>V,default:()=>h});module.exports=at(ct);var Q="https://api.support.greatdetail.com",z={"X-Powered-By":"GDSupport/JavaScript"};var C=class{constructor(t){this._transport=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 R=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,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}delete(t,e,{body:o,request:n={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...n,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 O=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 g=class{constructor(t){this._transport=t}list({limit:t,sort:e,request:o={}}={}){return this._transport.send("v1/actions",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var $="SUPPORT_ACCESS_TOKEN",J="SUPPORT_KEY_NAME",X="SUPPORT_KEY_PASSWORD",W="SUPPORT_SIGNING_KEY",Z="SUPPORT_BASE_URL";var x=class{name;#t;constructor({name:t=process.env[J],password:e=process.env[X]}={}){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(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var v=class{#t;constructor({token:t=process.env[$]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var b=class{getHeaders(){return{}}};var _=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}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 L=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByCategory=this.listByBoilerplateCategory;listByBoilerplateCategory(t,{limit:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 I=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/channels",{...e,method:"GET",searchParams:[...this._transport.limitQuery(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})}metaWhatsappGetBusinessProfile(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}twilioSendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...o,method:"POST",json:e})}};var T=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 A=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.includeQuery(e??{})]})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",n=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(n)}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({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(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"})}};var y=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.includeQuery(e??{})]})}list({limit:t,filter:e,include:o,request:n={}}={}){return this._transport.send("v1/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(o??{})]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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"})}};var U=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,include:o,request:n={}}={}){return this._transport.send("v1/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(o??{})]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByConversation(t,{limit:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 S=class{constructor(t){this._transport=t}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/messages",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}listByConversation(t,{limit:e,include:o,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o??{})]})}listByChannel(t,{limit:e,include:o,request:n={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o)]})}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 E=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}createResponse(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...o,method:"POST",timeout:12e4,json:e})}createCorrection(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...o,method:"POST",json:e})}};var D=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}listByContact(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}listByConversation(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}createForConversation(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var G=class{constructor(t){this._transport=t}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var w=class s{constructor(t=s.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=z;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var P=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 n=[];if(e){let p=Array.isArray(e)?e:[e];for(let f of p)n.push(["category",f])}return t!==void 0&&n.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:n})}};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 tt=Y(require("is-network-error"),1),q=Y(require("ky"),1);var i=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends i{};var l=class extends c{static unauthenticated(){return new this("An unauthenticated request occurred")}};var d=class extends c{static forbidden(){return new this("A forbidden request occurred")}};var a=class extends i{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var u=class extends i{};var m=class extends i{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var F=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=q.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let n of this.options.requestFilterables){let p=n.getHeaders();for(let[f,ot]of Object.entries(p))o.headers.has(f)||o.headers.set(f,ot)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[o,n]of Object.entries(t))n!==void 0&&e.push(["sort",n+o]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let o of Object.keys(t))e.push(["include",o]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let o=this.client(t,e).catch(n=>{if((0,tt.default)(n))throw new u("A network error occurred",{cause:n});if(n instanceof q.HTTPError){let p=n.response.status;switch(console.error(JSON.stringify(n.response)),p){case 400:throw m.badRequest();case 401:throw l.unauthenticated();case 403:throw d.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,e.method??"GET");case 415:throw m.unsupportedMediaType();case 418:throw a.teapot();case 429:throw a.rateLimited()}if(p>=500&&p<600)throw i.serverError(p)}throw n});return{response:()=>o,json:async()=>(await o).json()}}};var M=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}create({account:t,files:e,request:o={}}){let n=new FormData;for(let p of e)n.append("file",p);return this._transport.send("v1/uploads",{...o,method:"POST",body:n,searchParams:{account:t}})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var r=require("zod"),et=r.z.object({data:r.z.object({event:r.z.intersection(r.z.object({id:r.z.string(),createdAt:r.z.string().datetime()}),r.z.union([r.z.object({type:r.z.union([r.z.literal("account.created"),r.z.literal("account.updated")]),payload:r.z.object({account:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("accountAccessToken.created"),r.z.literal("accountAccessToken.deleted")]),payload:r.z.object({accountAccessToken:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("contact.created"),r.z.literal("contact.updated"),r.z.literal("contact.deleted")]),payload:r.z.object({contact:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("conversation.created"),r.z.literal("conversation.updated"),r.z.literal("conversation.closed"),r.z.literal("conversation.received"),r.z.literal("conversation.resolved"),r.z.literal("conversation.sent")]),payload:r.z.object({conversation:r.z.string()})}),r.z.object({type:r.z.union([r.z.literal("message.created"),r.z.literal("message.updated"),r.z.literal("message.delivered"),r.z.literal("message.failed"),r.z.literal("message.read"),r.z.literal("message.received"),r.z.literal("message.sent")]),payload:r.z.object({message:r.z.string()})})]))})});var k=class{constructor(t){this._transport=t}list({request:t={}}={}){return this._transport.send("v1/webhooks",{...t,method:"GET"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/"+encodeURIComponent(t),{...e,method:"DELETE"})}async event({key:t=process.env[W],maxSignatures:e=3,request:o}){let n=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+W);if(!n)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(n)?n.slice(0,e):[n]))throw new Error("Untrusted signature")}let{data:p}=et.parse(o.body);return{event:p.event}}async _verifySignature(t,e,o){let n=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let p of o)if(await crypto.subtle.verify("HMAC",n,new TextEncoder().encode(atob(p)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var N=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var h=class s{static DEFAULT_BASE_URL=Q;static PublicAuthentication=b;static BasicAuthentication=x;static BearerAuthentication=v;_transport;account;accountAccessToken;accountConversationSettings;action;boilerplateCategory;boilerplateContent;channel;compositionSection;contact;conversation;label;message;model;note;notificationSubscription;source;statistics;upload;webhook;wellKnown;constructor(t,{baseURL:e,...o}={}){this._transport=new F({requestFilterables:[new w,t],...o,baseURL:e?.toString()??s.getBaseURL()}),this.account=new C(this._transport),this.accountAccessToken=new R(this._transport),this.accountConversationSettings=new O(this._transport),this.action=new g(this._transport),this.boilerplateCategory=new _(this._transport),this.boilerplateContent=new L(this._transport),this.channel=new I(this._transport),this.compositionSection=new T(this._transport),this.contact=new A(this._transport),this.conversation=new y(this._transport),this.label=new U(this._transport),this.message=new S(this._transport),this.model=new E(this._transport),this.note=new D(this._transport),this.notificationSubscription=new G(this._transport),this.source=new P(this._transport),this.statistics=new B(this._transport),this.upload=new M(this._transport),this.webhook=new k(this._transport),this.wellKnown=new N(this._transport)}static getBaseURL(){return process.env[Z]??this.DEFAULT_BASE_URL}};var V={};H(V,{AuthError:()=>c,AuthenticationError:()=>l,AuthorizationError:()=>d,LogicError:()=>a,NetworkError:()=>u,SupportError:()=>i,ValidationError:()=>m});0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,Error});
|
|
1
|
+
"use strict";var rt=Object.create;var j=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,pt=Object.prototype.hasOwnProperty;var K=(r,t)=>{for(var e in t)j(r,e,{get:t[e],enumerable:!0})},Y=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of nt(t))!pt.call(r,n)&&n!==e&&j(r,n,{get:()=>t[n],enumerable:!(o=st(t,n))||o.enumerable});return r};var z=(r,t,e)=>(e=r!=null?rt(it(r)):{},Y(t||!r||!r.__esModule?j(e,"default",{value:r,enumerable:!0}):e,r)),at=r=>Y(j({},"__esModule",{value:!0}),r);var ct={};K(ct,{Client:()=>h,DEFAULT_SUPPORT_BASE_URL:()=>Q,Error:()=>H,default:()=>h,eventWebhookSchema:()=>V});module.exports=at(ct);var Q="https://api.support.greatdetail.com",$={"X-Powered-By":"GDSupport/JavaScript"};var C=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t),{...e,method:"GET"})}getCurrent({request:t={}}){return this._transport.send("v1/accounts/current",{...t,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 R=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,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}delete(t,e,{body:o,request:n={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...n,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 O=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 x=class{constructor(t){this._transport=t}list({limit:t,sort:e,request:o={}}={}){return this._transport.send("v1/actions",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var J="SUPPORT_ACCESS_TOKEN",X="SUPPORT_KEY_NAME",Z="SUPPORT_KEY_PASSWORD",W="SUPPORT_SIGNING_KEY",tt="SUPPORT_BASE_URL";var g=class{name;#t;constructor({name:t=process.env[X],password:e=process.env[Z]}={}){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(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var v=class{#t;constructor({token:t=process.env[J]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var b=class{getHeaders(){return{}}};var _=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}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 L=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByCategory=this.listByBoilerplateCategory;listByBoilerplateCategory(t,{limit:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 I=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/channels",{...e,method:"GET",searchParams:[...this._transport.limitQuery(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})}metaWhatsappGetBusinessProfile(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}twilioSendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...o,method:"POST",json:e})}};var T=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 A=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.includeQuery(e??{})]})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",n=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(n)}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({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(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"})}};var y=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.includeQuery(e??{})]})}list({limit:t,filter:e,include:o,request:n={}}={}){return this._transport.send("v1/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(o??{})]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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"})}};var U=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,include:o,request:n={}}={}){return this._transport.send("v1/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(o??{})]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByConversation(t,{limit:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 S=class{constructor(t){this._transport=t}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/messages",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}listByConversation(t,{limit:e,include:o,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o??{})]})}listByChannel(t,{limit:e,include:o,request:n={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o)]})}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 E=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}createResponse(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...o,method:"POST",timeout:12e4,json:e})}createCorrection(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...o,method:"POST",json:e})}};var G=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}listByContact(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}listByConversation(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}createForConversation(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var D=class{constructor(t){this._transport=t}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var w=class r{constructor(t=r.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=$;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var P=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 n=[];if(e){let p=Array.isArray(e)?e:[e];for(let f of p)n.push(["category",f])}return t!==void 0&&n.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:n})}};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 et=z(require("is-network-error"),1),q=z(require("ky"),1);var i=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends i{};var l=class extends c{static unauthenticated(){return new this("An unauthenticated request occurred")}};var d=class extends c{static forbidden(){return new this("A forbidden request occurred")}};var a=class extends i{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var u=class extends i{};var m=class extends i{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var F=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=q.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let n of this.options.requestFilterables){let p=n.getHeaders();for(let[f,ot]of Object.entries(p))o.headers.has(f)||o.headers.set(f,ot)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[o,n]of Object.entries(t))n!==void 0&&e.push(["sort",n+o]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let o of Object.keys(t))e.push(["include",o]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let o=this.client(t,e).catch(n=>{if((0,et.default)(n))throw new u("A network error occurred",{cause:n});if(n instanceof q.HTTPError){let p=n.response.status;switch(console.error(JSON.stringify(n.response)),p){case 400:throw m.badRequest();case 401:throw l.unauthenticated();case 403:throw d.forbidden();case 404:throw a.notFound(t);case 405:throw a.forbiddenMethod(t,e.method??"GET");case 415:throw m.unsupportedMediaType();case 418:throw a.teapot();case 429:throw a.rateLimited()}if(p>=500&&p<600)throw i.serverError(p)}throw n});return{response:()=>o,json:async()=>(await o).json()}}};var M=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}create({account:t,files:e,request:o={}}){let n=new FormData;for(let p of e)n.append("file",p);return this._transport.send("v1/uploads",{...o,method:"POST",body:n,searchParams:{account:t}})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var s=require("zod"),V=s.z.object({data:s.z.object({event:s.z.intersection(s.z.object({id:s.z.string(),createdAt:s.z.string().datetime()}),s.z.union([s.z.object({type:s.z.union([s.z.literal("account.created"),s.z.literal("account.updated")]),payload:s.z.object({account:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("accountAccessToken.created"),s.z.literal("accountAccessToken.deleted")]),payload:s.z.object({accountAccessToken:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("contact.created"),s.z.literal("contact.updated"),s.z.literal("contact.deleted")]),payload:s.z.object({contact:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("conversation.created"),s.z.literal("conversation.updated"),s.z.literal("conversation.closed"),s.z.literal("conversation.received"),s.z.literal("conversation.resolved"),s.z.literal("conversation.sent")]),payload:s.z.object({conversation:s.z.string()})}),s.z.object({type:s.z.union([s.z.literal("message.created"),s.z.literal("message.updated"),s.z.literal("message.delivered"),s.z.literal("message.failed"),s.z.literal("message.read"),s.z.literal("message.received"),s.z.literal("message.sent")]),payload:s.z.object({message:s.z.string()})})]))})});var k=class{constructor(t){this._transport=t}list({request:t={}}={}){return this._transport.send("v1/webhooks",{...t,method:"GET"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/"+encodeURIComponent(t),{...e,method:"DELETE"})}async event({key:t=process.env[W],maxSignatures:e=3,request:o}){let n=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+W);if(!n)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(n)?n.slice(0,e):[n]))throw new Error("Untrusted signature")}let{data:p}=V.parse(o.body);return{event:p.event}}async _verifySignature(t,e,o){let n=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let p of o)if(await crypto.subtle.verify("HMAC",n,new TextEncoder().encode(atob(p)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var N=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var h=class r{static DEFAULT_BASE_URL=Q;static PublicAuthentication=b;static BasicAuthentication=g;static BearerAuthentication=v;_transport;account;accountAccessToken;accountConversationSettings;action;boilerplateCategory;boilerplateContent;channel;compositionSection;contact;conversation;label;message;model;note;notificationSubscription;source;statistics;upload;webhook;wellKnown;constructor(t,{baseURL:e,...o}={}){this._transport=new F({requestFilterables:[new w,t],...o,baseURL:e?.toString()??r.getBaseURL()}),this.account=new C(this._transport),this.accountAccessToken=new R(this._transport),this.accountConversationSettings=new O(this._transport),this.action=new x(this._transport),this.boilerplateCategory=new _(this._transport),this.boilerplateContent=new L(this._transport),this.channel=new I(this._transport),this.compositionSection=new T(this._transport),this.contact=new A(this._transport),this.conversation=new y(this._transport),this.label=new U(this._transport),this.message=new S(this._transport),this.model=new E(this._transport),this.note=new G(this._transport),this.notificationSubscription=new D(this._transport),this.source=new P(this._transport),this.statistics=new B(this._transport),this.upload=new M(this._transport),this.webhook=new k(this._transport),this.wellKnown=new N(this._transport)}static getBaseURL(){return process.env[tt]??this.DEFAULT_BASE_URL}};var H={};K(H,{AuthError:()=>c,AuthenticationError:()=>l,AuthorizationError:()=>d,LogicError:()=>a,NetworkError:()=>u,SupportError:()=>i,ValidationError:()=>m});0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,Error,eventWebhookSchema});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as Account,
|
|
1
|
+
export { A as Account, k as AccountAccessToken, l as AccountAccessTokenID, u as AccountConversationSettings, b as AccountID, B as Action, E as ActionID, b0 as ActiveConversationStatus, $ as BoilerplateCategory, a0 as BoilerplateCategoryID, I as BoilerplateContent, J as BoilerplateContentID, ac as Channel, ad as ChannelID, C as Client, at as CompositionSection, au as CompositionSectionID, b1 as ConcludedConversationStatus, aH as Contact, aI as ContactID, a_ as Conversation, a$ as ConversationID, b2 as ConversationStatus, n as CreateAccountAccessTokenOptions, m as CreateAccountAccessTokenPayload, o as CreateAccountAccessTokenResponse, d as CreateAccountOptions, c as CreateAccountPayload, e as CreateAccountResponse, a2 as CreateBoilerplateCategoryOptions, a1 as CreateBoilerplateCategoryPayload, a3 as CreateBoilerplateCategoryResponse, M as CreateBoilerplateContentOptions, K as CreateBoilerplateContentPayload, N as CreateBoilerplateContentResponse, af as CreateChannelOptions, ae as CreateChannelPayload, ag as CreateChannelResponse, aw as CreateCompositionSectionOptions, av as CreateCompositionSectionPayload, ax as CreateCompositionSectionResponse, cb as CreateContactNoteOptions, ca as CreateContactNotePayload, cc as CreateContactNoteResponse, cy as CreateContactNotificationSubscriptionOptions, cx as CreateContactNotificationSubscriptionPayload, cz as CreateContactNotificationSubscriptionResponse, aL as CreateContactOptions, aK as CreateContactPayload, aM as CreateContactResponse, ce as CreateConversationNoteOptions, cd as CreateConversationNotePayload, cf as CreateConversationNoteResponse, b4 as CreateConversationOptions, b3 as CreateConversationPayload, b5 as CreateConversationResponse, b$ as CreateCorrectionModelOptions, b_ as CreateCorrectionModelPayload, c0 as CreateCorrectionResponse, bq as CreateLabelOptions, bp as CreateLabelPayload, br as CreateLabelResponse, bJ as CreateMessageOptions, bI as CreateMessagePayload, bK as CreateMessageResponse, c2 as CreateResponseModelOptions, c1 as CreateResponseModelPayload, c3 as CreateResponseResponse, cC as CreateUploadOptions, cD as CreateUploadResponse, cK as CreateWebhookOptions, cJ as CreateWebhookPayload, cL as CreateWebhookResponse, aJ as CustomMetadata, p as DeleteAccountAccessTokenOptions, D as DeleteAccountAccessTokenPayload, q as DeleteAccountAccessTokenResponse, aN as DeleteContactOptions, aO as DeleteContactResponse, b6 as DeleteConversationOptions, b7 as DeleteConversationResponse, bs as DeleteLabelOptions, bt as DeleteLabelResponse, bL as DeleteMessageOptions, bM as DeleteMessageResponse, cE as DeleteUploadOptions, cF as DeleteUploadResponse, cM as DeleteWebhookOptions, cN as DeleteWebhookResponse, cO as EventWebhookOptions, bg as FilterOptions, r as GetAccountAccessTokenOptions, s as GetAccountAccessTokenResponse, v as GetAccountConversationSettingsOptions, w as GetAccountConversationSettingsResponse, G as GetAccountOptions, f as GetAccountResponse, a4 as GetBoilerplateCategoryOptions, a5 as GetBoilerplateCategoryResponse, P as GetBoilerplateContentOptions, Q as GetBoilerplateContentResponse, ah as GetChannelOptions, ai as GetChannelResponse, ay as GetCompositionSectionOptions, az as GetCompositionSectionResponse, aP as GetContactIncludeOptions, aQ as GetContactOptions, aR as GetContactResponse, aS as GetContactVCFOptions, b8 as GetConversationIncludeOptions, b9 as GetConversationOptions, ba as GetConversationResponse, g as GetCurrentAccountOptions, h as GetCurrentAccountResponse, bu as GetLabelOptions, bv as GetLabelResponse, c4 as GetModelOptions, c5 as GetModelResponse, cg as GetNoteOptions, ch as GetNoteResponse, cU as GetNotificationWellKnownResponse, cr as GetSourceOptions, cs as GetSourceResponse, cG as GetUploadOptions, cH as GetUploadResponse, bo as Label, bw as LabelID, L as ListAccountAccessTokensOptions, t as ListAccountAccessTokensResponse, F as ListActionsOptions, H as ListActionsResponse, a6 as ListBoilerplateCategoriesIncludeOptions, a7 as ListBoilerplateCategoriesOptions, a8 as ListBoilerplateCategoriesResponse, T as ListBoilerplateCategoryBoilerplateContentsOptions, V as ListBoilerplateCategoryBoilerplateContentsResponse, W as ListBoilerplateContentsOptions, X as ListBoilerplateContentsResponse, aA as ListChannelCompositionSectionsOptions, aB as ListChannelCompositionSectionsResponse, bb as ListChannelConversationsOptions, bc as ListChannelConversationsResponse, bN as ListChannelMessagesIncludeOptions, bO as ListChannelMessagesOptions, bP as ListChannelMessagesResponse, aj as ListChannelsOptions, ak as ListChannelsResponse, aC as ListCompositionSectionsOptions, aD as ListCompositionSectionsResponse, bd as ListContactConversationsOptions, be as ListContactConversationsResponse, bx as ListContactLabelsOptions, by as ListContactLabelsResponse, ci as ListContactNotesOptions, cj as ListContactNotesResponse, aT as ListContactsOptions, aU as ListContactsResponse, bz as ListConversationLabelsOptions, bA as ListConversationLabelsResponse, bQ as ListConversationMessagesIncludeOptions, bR as ListConversationMessagesOptions, bS as ListConversationMessagesResponse, ck as ListConversationNotesOptions, cl as ListConversationNotesResponse, bh as ListConversationOptions, bf as ListConversationsIncludeOptions, bi as ListConversationsResponse, aV as ListLabelContactsOptions, aW as ListLabelContactsResponse, bj as ListLabelConversationsOptions, bk as ListLabelConversationsResponse, bB as ListLabelsIncludeOptions, bC as ListLabelsOptions, bD as ListLabelsResponse, bT as ListMessagesIncludeOptions, bU as ListMessagesOptions, bV as ListMessagesResponse, c6 as ListModelsOptions, c7 as ListModelsResponse, ct as ListSourcesOptions, cu as ListSourcesResponse, cQ as ListWebhooksOptions, cR as ListWebhooksResponse, bH as Message, bW as MessageID, bX as MessageRole, bY as MessageStatus, al as MetaWhatsappChannelGetBusinessProfileOptions, am as MetaWhatsappChannelGetBusinessProfileResponse, bZ as Model, c8 as ModelID, c9 as Note, cm as NoteID, cw as NotificationSubscription, cA as NotificationSubscriptionID, O as Options, R as RequestFilterable, S as SortOptions, cq as Source, cv as SourceID, a as TransportOptions, an as TwilioSendChannelSyncPayload, ao as TwilioSendgridChannelSyncOptions, ap as TwilioSendgridChannelSyncResponse, y as UpdateAccountConversationSettingsOptions, x as UpdateAccountConversationSettingsPayload, z as UpdateAccountConversationSettingsResponse, i as UpdateAccountOptions, U as UpdateAccountPayload, j as UpdateAccountResponse, aa as UpdateBoilerplateCategoryOptions, a9 as UpdateBoilerplateCategoryPayload, ab as UpdateBoilerplateCategoryResponse, Z as UpdateBoilerplateContentOptions, Y as UpdateBoilerplateContentPayload, _ as UpdateBoilerplateContentResponse, ar as UpdateChannelOptions, aq as UpdateChannelPayload, as as UpdateChannelResponse, aF as UpdateCompositionSectionOptions, aE as UpdateCompositionSectionPayload, aG as UpdateCompositionSectionResponse, aY as UpdateContactOptions, aX as UpdateContactPayload, aZ as UpdateContactResponse, bm as UpdateConversationOptions, bl as UpdateConversationPayload, bn as UpdateConversationResponse, bF as UpdateLabelOptions, bE as UpdateLabelPayload, bG as UpdateLabelResponse, co as UpdateNoteOptions, cn as UpdateNotePayload, cp as UpdateNoteResponse, cB as Upload, cI as UploadID, cS as WebhookID, cT as WebhookResponse, C as default, cP as eventWebhookSchema } from './Client-BQeXSLP6.cjs';
|
|
2
2
|
import 'ky';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as Account,
|
|
1
|
+
export { A as Account, k as AccountAccessToken, l as AccountAccessTokenID, u as AccountConversationSettings, b as AccountID, B as Action, E as ActionID, b0 as ActiveConversationStatus, $ as BoilerplateCategory, a0 as BoilerplateCategoryID, I as BoilerplateContent, J as BoilerplateContentID, ac as Channel, ad as ChannelID, C as Client, at as CompositionSection, au as CompositionSectionID, b1 as ConcludedConversationStatus, aH as Contact, aI as ContactID, a_ as Conversation, a$ as ConversationID, b2 as ConversationStatus, n as CreateAccountAccessTokenOptions, m as CreateAccountAccessTokenPayload, o as CreateAccountAccessTokenResponse, d as CreateAccountOptions, c as CreateAccountPayload, e as CreateAccountResponse, a2 as CreateBoilerplateCategoryOptions, a1 as CreateBoilerplateCategoryPayload, a3 as CreateBoilerplateCategoryResponse, M as CreateBoilerplateContentOptions, K as CreateBoilerplateContentPayload, N as CreateBoilerplateContentResponse, af as CreateChannelOptions, ae as CreateChannelPayload, ag as CreateChannelResponse, aw as CreateCompositionSectionOptions, av as CreateCompositionSectionPayload, ax as CreateCompositionSectionResponse, cb as CreateContactNoteOptions, ca as CreateContactNotePayload, cc as CreateContactNoteResponse, cy as CreateContactNotificationSubscriptionOptions, cx as CreateContactNotificationSubscriptionPayload, cz as CreateContactNotificationSubscriptionResponse, aL as CreateContactOptions, aK as CreateContactPayload, aM as CreateContactResponse, ce as CreateConversationNoteOptions, cd as CreateConversationNotePayload, cf as CreateConversationNoteResponse, b4 as CreateConversationOptions, b3 as CreateConversationPayload, b5 as CreateConversationResponse, b$ as CreateCorrectionModelOptions, b_ as CreateCorrectionModelPayload, c0 as CreateCorrectionResponse, bq as CreateLabelOptions, bp as CreateLabelPayload, br as CreateLabelResponse, bJ as CreateMessageOptions, bI as CreateMessagePayload, bK as CreateMessageResponse, c2 as CreateResponseModelOptions, c1 as CreateResponseModelPayload, c3 as CreateResponseResponse, cC as CreateUploadOptions, cD as CreateUploadResponse, cK as CreateWebhookOptions, cJ as CreateWebhookPayload, cL as CreateWebhookResponse, aJ as CustomMetadata, p as DeleteAccountAccessTokenOptions, D as DeleteAccountAccessTokenPayload, q as DeleteAccountAccessTokenResponse, aN as DeleteContactOptions, aO as DeleteContactResponse, b6 as DeleteConversationOptions, b7 as DeleteConversationResponse, bs as DeleteLabelOptions, bt as DeleteLabelResponse, bL as DeleteMessageOptions, bM as DeleteMessageResponse, cE as DeleteUploadOptions, cF as DeleteUploadResponse, cM as DeleteWebhookOptions, cN as DeleteWebhookResponse, cO as EventWebhookOptions, bg as FilterOptions, r as GetAccountAccessTokenOptions, s as GetAccountAccessTokenResponse, v as GetAccountConversationSettingsOptions, w as GetAccountConversationSettingsResponse, G as GetAccountOptions, f as GetAccountResponse, a4 as GetBoilerplateCategoryOptions, a5 as GetBoilerplateCategoryResponse, P as GetBoilerplateContentOptions, Q as GetBoilerplateContentResponse, ah as GetChannelOptions, ai as GetChannelResponse, ay as GetCompositionSectionOptions, az as GetCompositionSectionResponse, aP as GetContactIncludeOptions, aQ as GetContactOptions, aR as GetContactResponse, aS as GetContactVCFOptions, b8 as GetConversationIncludeOptions, b9 as GetConversationOptions, ba as GetConversationResponse, g as GetCurrentAccountOptions, h as GetCurrentAccountResponse, bu as GetLabelOptions, bv as GetLabelResponse, c4 as GetModelOptions, c5 as GetModelResponse, cg as GetNoteOptions, ch as GetNoteResponse, cU as GetNotificationWellKnownResponse, cr as GetSourceOptions, cs as GetSourceResponse, cG as GetUploadOptions, cH as GetUploadResponse, bo as Label, bw as LabelID, L as ListAccountAccessTokensOptions, t as ListAccountAccessTokensResponse, F as ListActionsOptions, H as ListActionsResponse, a6 as ListBoilerplateCategoriesIncludeOptions, a7 as ListBoilerplateCategoriesOptions, a8 as ListBoilerplateCategoriesResponse, T as ListBoilerplateCategoryBoilerplateContentsOptions, V as ListBoilerplateCategoryBoilerplateContentsResponse, W as ListBoilerplateContentsOptions, X as ListBoilerplateContentsResponse, aA as ListChannelCompositionSectionsOptions, aB as ListChannelCompositionSectionsResponse, bb as ListChannelConversationsOptions, bc as ListChannelConversationsResponse, bN as ListChannelMessagesIncludeOptions, bO as ListChannelMessagesOptions, bP as ListChannelMessagesResponse, aj as ListChannelsOptions, ak as ListChannelsResponse, aC as ListCompositionSectionsOptions, aD as ListCompositionSectionsResponse, bd as ListContactConversationsOptions, be as ListContactConversationsResponse, bx as ListContactLabelsOptions, by as ListContactLabelsResponse, ci as ListContactNotesOptions, cj as ListContactNotesResponse, aT as ListContactsOptions, aU as ListContactsResponse, bz as ListConversationLabelsOptions, bA as ListConversationLabelsResponse, bQ as ListConversationMessagesIncludeOptions, bR as ListConversationMessagesOptions, bS as ListConversationMessagesResponse, ck as ListConversationNotesOptions, cl as ListConversationNotesResponse, bh as ListConversationOptions, bf as ListConversationsIncludeOptions, bi as ListConversationsResponse, aV as ListLabelContactsOptions, aW as ListLabelContactsResponse, bj as ListLabelConversationsOptions, bk as ListLabelConversationsResponse, bB as ListLabelsIncludeOptions, bC as ListLabelsOptions, bD as ListLabelsResponse, bT as ListMessagesIncludeOptions, bU as ListMessagesOptions, bV as ListMessagesResponse, c6 as ListModelsOptions, c7 as ListModelsResponse, ct as ListSourcesOptions, cu as ListSourcesResponse, cQ as ListWebhooksOptions, cR as ListWebhooksResponse, bH as Message, bW as MessageID, bX as MessageRole, bY as MessageStatus, al as MetaWhatsappChannelGetBusinessProfileOptions, am as MetaWhatsappChannelGetBusinessProfileResponse, bZ as Model, c8 as ModelID, c9 as Note, cm as NoteID, cw as NotificationSubscription, cA as NotificationSubscriptionID, O as Options, R as RequestFilterable, S as SortOptions, cq as Source, cv as SourceID, a as TransportOptions, an as TwilioSendChannelSyncPayload, ao as TwilioSendgridChannelSyncOptions, ap as TwilioSendgridChannelSyncResponse, y as UpdateAccountConversationSettingsOptions, x as UpdateAccountConversationSettingsPayload, z as UpdateAccountConversationSettingsResponse, i as UpdateAccountOptions, U as UpdateAccountPayload, j as UpdateAccountResponse, aa as UpdateBoilerplateCategoryOptions, a9 as UpdateBoilerplateCategoryPayload, ab as UpdateBoilerplateCategoryResponse, Z as UpdateBoilerplateContentOptions, Y as UpdateBoilerplateContentPayload, _ as UpdateBoilerplateContentResponse, ar as UpdateChannelOptions, aq as UpdateChannelPayload, as as UpdateChannelResponse, aF as UpdateCompositionSectionOptions, aE as UpdateCompositionSectionPayload, aG as UpdateCompositionSectionResponse, aY as UpdateContactOptions, aX as UpdateContactPayload, aZ as UpdateContactResponse, bm as UpdateConversationOptions, bl as UpdateConversationPayload, bn as UpdateConversationResponse, bF as UpdateLabelOptions, bE as UpdateLabelPayload, bG as UpdateLabelResponse, co as UpdateNoteOptions, cn as UpdateNotePayload, cp as UpdateNoteResponse, cB as Upload, cI as UploadID, cS as WebhookID, cT as WebhookResponse, C as default, cP as eventWebhookSchema } from './Client-BQeXSLP6.js';
|
|
2
2
|
import 'ky';
|
|
3
3
|
import 'zod';
|
|
4
4
|
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s,c as l,d as o,e as r,f as t,g as e,h as p,i as f,j as m,k as x}from"./chunk-
|
|
1
|
+
import{a as s,c as l,d as o,e as r,f as t,g as e,h as p,i as f,j as m,k as u,l as x}from"./chunk-5NLQ55US.js";var a={};s(a,{AuthError:()=>r,AuthenticationError:()=>t,AuthorizationError:()=>e,LogicError:()=>p,NetworkError:()=>f,SupportError:()=>o,ValidationError:()=>m});export{x as Client,l as DEFAULT_SUPPORT_BASE_URL,a as Error,x as default,u as eventWebhookSchema};
|
package/package.json
CHANGED
package/dist/chunk-V7LNWFJE.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var $=Object.defineProperty;var tt=(r,t)=>{for(var e in t)$(r,e,{get:t[e],enumerable:!0})};var d=class{getHeaders(){return{}}};var Q="SUPPORT_ACCESS_TOKEN",W="SUPPORT_KEY_NAME",q="SUPPORT_KEY_PASSWORD",N="SUPPORT_SIGNING_KEY",H="SUPPORT_BASE_URL";var u=class{name;#t;constructor({name:t=process.env[W],password:e=process.env[q]}={}){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(){return{Authorization:`Basic ${btoa(this.name+":"+this.#t)}`}}};var h=class{#t;constructor({token:t=process.env[Q]}={}){if(!t)throw new Error("Access Token option must be specified when using Token Authentication");this.#t=t}getHeaders(){return{Authorization:`Bearer ${this.#t}`}}};var V="https://api.support.greatdetail.com",K={"X-Powered-By":"GDSupport/JavaScript"};import{z as s}from"zod";var Y=s.object({data:s.object({event:s.intersection(s.object({id:s.string(),createdAt:s.string().datetime()}),s.union([s.object({type:s.union([s.literal("account.created"),s.literal("account.updated")]),payload:s.object({account:s.string()})}),s.object({type:s.union([s.literal("accountAccessToken.created"),s.literal("accountAccessToken.deleted")]),payload:s.object({accountAccessToken:s.string()})}),s.object({type:s.union([s.literal("contact.created"),s.literal("contact.updated"),s.literal("contact.deleted")]),payload:s.object({contact:s.string()})}),s.object({type:s.union([s.literal("conversation.created"),s.literal("conversation.updated"),s.literal("conversation.closed"),s.literal("conversation.received"),s.literal("conversation.resolved"),s.literal("conversation.sent")]),payload:s.object({conversation:s.string()})}),s.object({type:s.union([s.literal("message.created"),s.literal("message.updated"),s.literal("message.delivered"),s.literal("message.failed"),s.literal("message.read"),s.literal("message.received"),s.literal("message.sent")]),payload:s.object({message:s.string()})})]))})});var C=class{constructor(t){this._transport=t}list({request:t={}}={}){return this._transport.send("v1/webhooks",{...t,method:"GET"})}create({body:t,request:e={}}){return this._transport.send("v1/webhooks",{...e,method:"POST",json:t})}delete(t,{request:e={}}={}){return this._transport.send("v1/webhooks/"+encodeURIComponent(t),{...e,method:"DELETE"})}async event({key:t=process.env[N],maxSignatures:e=3,request:o}){let n=o.headers["gds-signature"];if(t!==!1){if(t===void 0)throw new Error("Missing webhook signing key in process.env."+N);if(!n)throw new Error("Missing signature header");if(!this._verifySignature(t,o.body,Array.isArray(n)?n.slice(0,e):[n]))throw new Error("Untrusted signature")}let{data:i}=Y.parse(o.body);return{event:i.event}}async _verifySignature(t,e,o){let n=await crypto.subtle.importKey("raw",new TextEncoder().encode(t),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]);for(let i of o)if(await crypto.subtle.verify("HMAC",n,new TextEncoder().encode(atob(i)),new TextEncoder().encode(JSON.stringify(e))))return!0;return!1}};var f=class{constructor(t){this._transport=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 R=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,{request:e={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens",{...e,method:"GET"})}delete(t,e,{body:o,request:n={}}={}){return this._transport.send("v1/accounts/"+encodeURIComponent(t)+"/access-tokens/"+encodeURIComponent(e),{...n,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 O=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 g=class{constructor(t){this._transport=t}list({limit:t,sort:e,request:o={}}={}){return this._transport.send("v1/actions",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.sortQuery(e)]})}};var v=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e)]})}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 b=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/boilerplates/contents/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/boilerplates/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByCategory=this.listByBoilerplateCategory;listByBoilerplateCategory(t,{limit:e,request:o={}}={}){return this._transport.send("v1/boilerplates/categories/"+encodeURIComponent(t)+"/contents",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 _=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/channels",{...e,method:"GET",searchParams:[...this._transport.limitQuery(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})}metaWhatsappGetBusinessProfile(t,{request:e={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/meta-whatsapp/business-profile",{...e,method:"GET"})}twilioSendgridChannelSync(t,{body:e,request:o={}}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/twilio-sendgrid/sync",{...o,method:"POST",json:e})}};var L=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/composition-sections/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,request:e={}}={}){return this._transport.send("v1/composition-sections",{...e,method:"GET",searchParams:[...this._transport.limitQuery(t)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/composition-sections",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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.includeQuery(e??{})]})}getRelativeVCFURL(t,{vcf:e={}}={}){let o=e.variant??"vcard",n=e.format??(o==="vcard"?"vcf":"json");return"v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(n)}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({limit:t,query:e,request:o={}}={}){return this._transport.send("v1/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e)]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/contacts",{...o,method:"GET",searchParams:[...this._transport.limitQuery(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"})}};var T=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.includeQuery(e??{})]})}list({limit:t,filter:e,include:o,request:n={}}={}){return this._transport.send("v1/conversations",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...e?[["filter",e]]:[],...this._transport.includeQuery(o??{})]})}listByLabel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByChannel(t,{limit:e,request:o={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/conversations",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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"})}};var A=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/labels/"+encodeURIComponent(t),{...e,method:"GET"})}list({limit:t,query:e,include:o,request:n={}}={}){return this._transport.send("v1/labels",{...n,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.queryQuery(e),...this._transport.includeQuery(o??{})]})}listByContact(t,{limit:e,request:o={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}listByConversation(t,{limit:e,request:o={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/labels",{...o,method:"GET",searchParams:[...this._transport.limitQuery(e)]})}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 U=class{constructor(t){this._transport=t}list({limit:t,include:e,request:o={}}={}){return this._transport.send("v1/messages",{...o,method:"GET",searchParams:[...this._transport.limitQuery(t),...this._transport.includeQuery(e??{})]})}listByConversation(t,{limit:e,include:o,request:n={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o??{})]})}listByChannel(t,{limit:e,include:o,request:n={}}={}){return this._transport.send("v1/channels/"+encodeURIComponent(t)+"/messages",{...n,method:"GET",searchParams:[...this._transport.limitQuery(e),...this._transport.includeQuery(o)]})}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 y=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/models/"+encodeURIComponent(t),{...e,method:"GET"})}list({request:t={}}={}){return this._transport.send("v1/models",{...t,method:"GET"})}createResponse(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/response",{...o,method:"POST",timeout:12e4,json:e})}createCorrection(t,{body:e,request:o={}}){return this._transport.send("v1/models/"+encodeURIComponent(t)+"/correction",{...o,method:"POST",json:e})}};var S=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...e,method:"GET"})}listByContact(t,{request:e={}}={}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}listByConversation(t,{request:e={}}={}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...e,method:"GET"})}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}createForConversation(t,{body:e,request:o={}}){return this._transport.send("v1/conversations/"+encodeURIComponent(t)+"/notes",{...o,method:"POST",json:e})}update(t,{body:e,request:o={}}){return this._transport.send("v1/notes/"+encodeURIComponent(t),{...o,method:"PATCH",json:e})}};var D=class{constructor(t){this._transport=t}createForContact(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var G=class r{constructor(t=r.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=K;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var E=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 n=[];if(e){let i=Array.isArray(e)?e:[e];for(let l of i)n.push(["category",l])}return t!==void 0&&n.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:n})}};var w=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"})}};import J from"is-network-error";import X,{HTTPError as Z}from"ky";var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends a{};var P=class extends c{static unauthenticated(){return new this("An unauthenticated request occurred")}};var B=class extends c{static forbidden(){return new this("A forbidden request occurred")}};var p=class extends a{static notFound(t){return new this(`Record not found for request: ${t}`)}static forbiddenMethod(t,e){return new this(`Forbidden method for request: ${t} ${e}`)}static teapot(){return new this("I'm a teapot")}static rateLimited(){return new this("Request has been rate-limited")}};var F=class extends a{};var m=class extends a{static badRequest(){return new this("Bad request")}static unsupportedMediaType(){return new this("Unsupported Media Type")}};var M=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=X.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let n of this.options.requestFilterables){let i=n.getHeaders();for(let[l,z]of Object.entries(i))o.headers.has(l)||o.headers.set(l,z)}}]}})}getURL(t){return new URL(t,this.options.baseURL).toString()}sortQuery(t){let e=[];if(t===void 0)return e;for(let[o,n]of Object.entries(t))n!==void 0&&e.push(["sort",n+o]);return e}limitQuery(t){let e=[];return t===void 0||e.push(["limit",t.toString()]),e}includeQuery(t){let e=[];if(t===void 0)return e;for(let o of Object.keys(t))e.push(["include",o]);return e}queryQuery(t){let e=[];return t===void 0||e.push(["query",t]),e}send(t,e={}){let o=this.client(t,e).catch(n=>{if(J(n))throw new F("A network error occurred",{cause:n});if(n instanceof Z){let i=n.response.status;switch(console.error(JSON.stringify(n.response)),i){case 400:throw m.badRequest();case 401:throw P.unauthenticated();case 403:throw B.forbidden();case 404:throw p.notFound(t);case 405:throw p.forbiddenMethod(t,e.method??"GET");case 415:throw m.unsupportedMediaType();case 418:throw p.teapot();case 429:throw p.rateLimited()}if(i>=500&&i<600)throw a.serverError(i)}throw n});return{response:()=>o,json:async()=>(await o).json()}}};var x=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"GET"})}create({account:t,files:e,request:o={}}){let n=new FormData;for(let i of e)n.append("file",i);return this._transport.send("v1/uploads",{...o,method:"POST",body:n,searchParams:{account:t}})}delete(t,{request:e={}}={}){return this._transport.send("v1/uploads/"+encodeURIComponent(t),{...e,method:"DELETE"})}};var k=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var j=class r{static DEFAULT_BASE_URL=V;static PublicAuthentication=d;static BasicAuthentication=u;static BearerAuthentication=h;_transport;account;accountAccessToken;accountConversationSettings;action;boilerplateCategory;boilerplateContent;channel;compositionSection;contact;conversation;label;message;model;note;notificationSubscription;source;statistics;upload;webhook;wellKnown;constructor(t,{baseURL:e,...o}={}){this._transport=new M({requestFilterables:[new G,t],...o,baseURL:e?.toString()??r.getBaseURL()}),this.account=new f(this._transport),this.accountAccessToken=new R(this._transport),this.accountConversationSettings=new O(this._transport),this.action=new g(this._transport),this.boilerplateCategory=new v(this._transport),this.boilerplateContent=new b(this._transport),this.channel=new _(this._transport),this.compositionSection=new L(this._transport),this.contact=new I(this._transport),this.conversation=new T(this._transport),this.label=new A(this._transport),this.message=new U(this._transport),this.model=new y(this._transport),this.note=new S(this._transport),this.notificationSubscription=new D(this._transport),this.source=new E(this._transport),this.statistics=new w(this._transport),this.upload=new x(this._transport),this.webhook=new C(this._transport),this.wellKnown=new k(this._transport)}static getBaseURL(){return process.env[H]??this.DEFAULT_BASE_URL}};export{tt as a,d as b,V as c,a as d,c as e,P as f,B as g,p as h,F as i,m as j,j as k};
|