@great-detail/support-sdk 0.16.0 → 0.16.2
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-DGn8aBic.d.cts → Client-DKNuv_mB.d.cts} +73 -1
- package/dist/{Client-DGn8aBic.d.ts → Client-DKNuv_mB.d.ts} +73 -1
- package/dist/chunk-CBX4D3XB.js +1 -0
- package/dist/{chunk-PS4YVHTA.js → chunk-MTQCQH5K.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 +2 -61
- package/dist/index.d.ts +2 -61
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-R3BOF7IE.js +0 -1
|
@@ -302,6 +302,77 @@ declare class AccountAccessTokenAPI {
|
|
|
302
302
|
};
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
+
/**
|
|
306
|
+
* Great Detail Support System.
|
|
307
|
+
*
|
|
308
|
+
* @copyright 2024 Great Detail Ltd
|
|
309
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
310
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
311
|
+
* @see https://greatdetail.com
|
|
312
|
+
*/
|
|
313
|
+
|
|
314
|
+
type AccountConversationSettings = {
|
|
315
|
+
account: AccountID;
|
|
316
|
+
defaultName?: Nullable<string>;
|
|
317
|
+
responseDuration?: Nullable<string>;
|
|
318
|
+
resolveDuration?: Nullable<string>;
|
|
319
|
+
} & ResponseTimestamp;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Great Detail Support System.
|
|
323
|
+
*
|
|
324
|
+
* @copyright 2024 Great Detail Ltd
|
|
325
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
326
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
327
|
+
* @see https://greatdetail.com
|
|
328
|
+
*/
|
|
329
|
+
|
|
330
|
+
interface GetAccountConversationSettingsOptions {
|
|
331
|
+
request?: SendOptions;
|
|
332
|
+
}
|
|
333
|
+
type GetAccountConversationSettingsResponse = {
|
|
334
|
+
data: {
|
|
335
|
+
accountConversationSettings: AccountConversationSettings;
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Great Detail Support System.
|
|
341
|
+
*
|
|
342
|
+
* @copyright 2024 Great Detail Ltd
|
|
343
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
344
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
345
|
+
* @see https://greatdetail.com
|
|
346
|
+
*/
|
|
347
|
+
|
|
348
|
+
type UpdateAccountConversationSettingsPayload = {
|
|
349
|
+
defaultName?: Nullable<string>;
|
|
350
|
+
responseDuration?: Nullable<string>;
|
|
351
|
+
resolveDuration?: Nullable<string>;
|
|
352
|
+
};
|
|
353
|
+
interface UpdateAccountConversationSettingsOptions {
|
|
354
|
+
body: UpdateAccountConversationSettingsPayload;
|
|
355
|
+
request?: SendOptions;
|
|
356
|
+
}
|
|
357
|
+
type UpdateAccountConversationSettingsResponse = {
|
|
358
|
+
data: {
|
|
359
|
+
accountConversationSettings: AccountConversationSettings;
|
|
360
|
+
};
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
declare class AccountConversationSettingsAPI {
|
|
364
|
+
protected _transport: FetchTransport;
|
|
365
|
+
constructor(_transport: FetchTransport);
|
|
366
|
+
get(account: AccountID, { request }?: GetAccountConversationSettingsOptions): {
|
|
367
|
+
response: () => Promise<ky.KyResponse<GetAccountConversationSettingsResponse>>;
|
|
368
|
+
json: () => Promise<GetAccountConversationSettingsResponse>;
|
|
369
|
+
};
|
|
370
|
+
update(account: AccountID, { body, request }: UpdateAccountConversationSettingsOptions): {
|
|
371
|
+
response: () => Promise<ky.KyResponse<UpdateAccountConversationSettingsResponse>>;
|
|
372
|
+
json: () => Promise<UpdateAccountConversationSettingsResponse>;
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
|
|
305
376
|
/**
|
|
306
377
|
* Great Detail Support System.
|
|
307
378
|
*
|
|
@@ -2897,6 +2968,7 @@ declare class Client {
|
|
|
2897
2968
|
_transport: FetchTransport;
|
|
2898
2969
|
account: AccountAPI;
|
|
2899
2970
|
accountAccessToken: AccountAccessTokenAPI;
|
|
2971
|
+
accountConversationSettings: AccountConversationSettingsAPI;
|
|
2900
2972
|
action: ActionAPI;
|
|
2901
2973
|
boilerplateCategory: BoilerplateCategoryAPI;
|
|
2902
2974
|
boilerplateContent: BoilerplateContentAPI;
|
|
@@ -2918,4 +2990,4 @@ declare class Client {
|
|
|
2918
2990
|
static getBaseURL(): string;
|
|
2919
2991
|
}
|
|
2920
2992
|
|
|
2921
|
-
export { type
|
|
2993
|
+
export { type CreateBoilerplateCategoryPayload as $, type Account as A, type ListActionsOptions as B, Client as C, type DeleteAccountAccessTokenPayload as D, type ListActionsResponse as E, type BoilerplateContent as F, type GetAccountOptions as G, type BoilerplateContentID as H, type CreateBoilerplateContentPayload as I, type CreateBoilerplateContentOptions as J, type CreateBoilerplateContentResponse as K, type ListAccountAccessTokensOptions as L, type GetBoilerplateContentOptions as M, type GetBoilerplateContentResponse as N, type Options as O, type ListBoilerplateCategoryBoilerplateContentsOptions as P, type ListBoilerplateCategoryBoilerplateContentsResponse as Q, type RequestFilterable as R, type SortOptions as S, type ListBoilerplateContentsOptions as T, type UpdateAccountPayload as U, type ListBoilerplateContentsResponse as V, type UpdateBoilerplateContentPayload as W, type UpdateBoilerplateContentOptions as X, type UpdateBoilerplateContentResponse as Y, type BoilerplateCategory as Z, type BoilerplateCategoryID as _, type Options$5 as a, type DeleteConversationResponse as a$, type CreateBoilerplateCategoryOptions as a0, type CreateBoilerplateCategoryResponse as a1, type GetBoilerplateCategoryOptions as a2, type GetBoilerplateCategoryResponse as a3, type ListBoilerplateCategoriesIncludeOptions as a4, type ListBoilerplateCategoriesOptions as a5, type ListBoilerplateCategoriesResponse as a6, type UpdateBoilerplateCategoryPayload as a7, type UpdateBoilerplateCategoryOptions as a8, type UpdateBoilerplateCategoryResponse as a9, type ListCompositionSectionsOptions as aA, type ListCompositionSectionsResponse as aB, type UpdateCompositionSectionPayload as aC, type UpdateCompositionSectionOptions as aD, type UpdateCompositionSectionResponse as aE, type Contact as aF, type ContactID as aG, type CreateContactPayload as aH, type CreateContactOptions as aI, type CreateContactResponse as aJ, type GetContactIncludeOptions as aK, type GetContactOptions as aL, type GetContactResponse as aM, type GetContactVCFOptions as aN, type ListContactsOptions as aO, type ListContactsResponse as aP, type ListLabelContactsOptions as aQ, type ListLabelContactsResponse as aR, type UpdateContactPayload as aS, type UpdateContactOptions as aT, type UpdateContactResponse as aU, type Conversation as aV, type ConversationID as aW, type CreateConversationPayload as aX, type CreateConversationOptions as aY, type CreateConversationResponse as aZ, type DeleteConversationOptions as a_, type Channel as aa, type ChannelID as ab, type CreateChannelPayload as ac, type CreateChannelOptions as ad, type CreateChannelResponse as ae, type GetChannelOptions as af, type GetChannelResponse as ag, type ListChannelsOptions as ah, type ListChannelsResponse as ai, type MetaWhatsappChannelGetBusinessProfileOptions as aj, type MetaWhatsappChannelGetBusinessProfileResponse as ak, type TwilioSendChannelSyncPayload as al, type TwilioSendgridChannelSyncOptions as am, type TwilioSendgridChannelSyncResponse as an, type UpdateChannelPayload as ao, type UpdateChannelOptions as ap, type UpdateChannelResponse as aq, type CompositionSection as ar, type CompositionSectionID as as, type CreateCompositionSectionPayload as at, type CreateCompositionSectionOptions as au, type CreateCompositionSectionResponse as av, type GetCompositionSectionOptions as aw, type GetCompositionSectionResponse as ax, type ListChannelCompositionSectionsOptions as ay, type ListChannelCompositionSectionsResponse as az, type AccountID as b, type Note as b$, type GetConversationIncludeOptions as b0, type GetConversationOptions as b1, type GetConversationResponse as b2, type ListContactConversationsOptions as b3, type ListContactConversationsResponse as b4, type ListConversationsIncludeOptions as b5, type FilterOptions as b6, type ListConversationOptions as b7, type ListConversationsResponse as b8, type ListLabelConversationsOptions as b9, type CreateMessageResponse as bA, type DeleteMessageOptions as bB, type DeleteMessageResponse as bC, type ListChannelMessagesIncludeOptions as bD, type ListChannelMessagesOptions as bE, type ListChannelMessagesResponse as bF, type ListConversationMessagesIncludeOptions as bG, type ListConversationMessagesOptions as bH, type ListConversationMessagesResponse as bI, type ListMessagesIncludeOptions as bJ, type ListMessagesOptions as bK, type ListMessagesResponse as bL, type MessageID as bM, type MessageRole as bN, type MessageStatus as bO, type Model as bP, type CreateCorrectionModelPayload as bQ, type CreateCorrectionModelOptions as bR, type CreateCorrectionResponse as bS, type CreateResponseModelPayload as bT, type CreateResponseModelOptions as bU, type CreateResponseResponse as bV, type GetModelOptions as bW, type GetModelResponse as bX, type ListModelsOptions as bY, type ListModelsResponse as bZ, type ModelID as b_, type ListLabelConversationsResponse as ba, type UpdateConversationPayload as bb, type UpdateConversationOptions as bc, type UpdateConversationResponse as bd, type Label as be, type CreateLabelPayload as bf, type CreateLabelOptions as bg, type CreateLabelResponse as bh, type DeleteLabelOptions as bi, type DeleteLabelResponse as bj, type GetLabelOptions as bk, type GetLabelResponse as bl, type LabelID as bm, type ListContactLabelsOptions as bn, type ListContactLabelsResponse as bo, type ListConversationLabelsOptions as bp, type ListConversationLabelsResponse as bq, type ListLabelsIncludeOptions as br, type ListLabelsOptions as bs, type ListLabelsResponse as bt, type UpdateLabelPayload as bu, type UpdateLabelOptions as bv, type UpdateLabelResponse as bw, type Message as bx, type CreateMessagePayload as by, type CreateMessageOptions as bz, type CreateAccountPayload as c, type CreateContactNotePayload as c0, type CreateContactNoteOptions as c1, type CreateContactNoteResponse as c2, type CreateConversationNotePayload as c3, type CreateConversationNoteOptions as c4, type CreateConversationNoteResponse as c5, type GetNoteOptions as c6, type GetNoteResponse as c7, type ListContactNotesOptions as c8, type ListContactNotesResponse as c9, type GetNotificationWellKnownResponse as cA, type ListConversationNotesOptions as ca, type ListConversationNotesResponse as cb, type NoteID as cc, type UpdateNotePayload as cd, type UpdateNoteOptions as ce, type UpdateNoteResponse as cf, type Source as cg, type GetSourceOptions as ch, type GetSourceResponse as ci, type ListSourcesOptions as cj, type ListSourcesResponse as ck, type SourceID as cl, type NotificationSubscription as cm, type CreateContactNotificationSubscriptionPayload as cn, type CreateContactNotificationSubscriptionOptions as co, type CreateContactNotificationSubscriptionResponse as cp, type NotificationSubscriptionID as cq, type Upload as cr, type CreateUploadOptions as cs, type CreateUploadResponse as ct, type DeleteUploadOptions as cu, type DeleteUploadResponse as cv, type GetUploadOptions as cw, type GetUploadResponse as cx, type UploadID as cy, type WebhookResponse as cz, type CreateAccountOptions as d, type CreateAccountResponse as e, type GetAccountResponse as f, type UpdateAccountOptions as g, type UpdateAccountResponse as h, type AccountAccessToken as i, type AccountAccessTokenID as j, type CreateAccountAccessTokenPayload as k, type CreateAccountAccessTokenOptions as l, type CreateAccountAccessTokenResponse as m, type DeleteAccountAccessTokenOptions as n, type DeleteAccountAccessTokenResponse as o, type GetAccountAccessTokenOptions as p, type GetAccountAccessTokenResponse as q, type ListAccountAccessTokensResponse as r, type AccountConversationSettings as s, type GetAccountConversationSettingsOptions as t, type GetAccountConversationSettingsResponse as u, type UpdateAccountConversationSettingsPayload as v, type UpdateAccountConversationSettingsOptions as w, type UpdateAccountConversationSettingsResponse as x, type Action as y, type ActionID as z };
|
|
@@ -302,6 +302,77 @@ declare class AccountAccessTokenAPI {
|
|
|
302
302
|
};
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
+
/**
|
|
306
|
+
* Great Detail Support System.
|
|
307
|
+
*
|
|
308
|
+
* @copyright 2024 Great Detail Ltd
|
|
309
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
310
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
311
|
+
* @see https://greatdetail.com
|
|
312
|
+
*/
|
|
313
|
+
|
|
314
|
+
type AccountConversationSettings = {
|
|
315
|
+
account: AccountID;
|
|
316
|
+
defaultName?: Nullable<string>;
|
|
317
|
+
responseDuration?: Nullable<string>;
|
|
318
|
+
resolveDuration?: Nullable<string>;
|
|
319
|
+
} & ResponseTimestamp;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Great Detail Support System.
|
|
323
|
+
*
|
|
324
|
+
* @copyright 2024 Great Detail Ltd
|
|
325
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
326
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
327
|
+
* @see https://greatdetail.com
|
|
328
|
+
*/
|
|
329
|
+
|
|
330
|
+
interface GetAccountConversationSettingsOptions {
|
|
331
|
+
request?: SendOptions;
|
|
332
|
+
}
|
|
333
|
+
type GetAccountConversationSettingsResponse = {
|
|
334
|
+
data: {
|
|
335
|
+
accountConversationSettings: AccountConversationSettings;
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Great Detail Support System.
|
|
341
|
+
*
|
|
342
|
+
* @copyright 2024 Great Detail Ltd
|
|
343
|
+
* @author Great Detail Ltd <info@greatdetail.com>
|
|
344
|
+
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
345
|
+
* @see https://greatdetail.com
|
|
346
|
+
*/
|
|
347
|
+
|
|
348
|
+
type UpdateAccountConversationSettingsPayload = {
|
|
349
|
+
defaultName?: Nullable<string>;
|
|
350
|
+
responseDuration?: Nullable<string>;
|
|
351
|
+
resolveDuration?: Nullable<string>;
|
|
352
|
+
};
|
|
353
|
+
interface UpdateAccountConversationSettingsOptions {
|
|
354
|
+
body: UpdateAccountConversationSettingsPayload;
|
|
355
|
+
request?: SendOptions;
|
|
356
|
+
}
|
|
357
|
+
type UpdateAccountConversationSettingsResponse = {
|
|
358
|
+
data: {
|
|
359
|
+
accountConversationSettings: AccountConversationSettings;
|
|
360
|
+
};
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
declare class AccountConversationSettingsAPI {
|
|
364
|
+
protected _transport: FetchTransport;
|
|
365
|
+
constructor(_transport: FetchTransport);
|
|
366
|
+
get(account: AccountID, { request }?: GetAccountConversationSettingsOptions): {
|
|
367
|
+
response: () => Promise<ky.KyResponse<GetAccountConversationSettingsResponse>>;
|
|
368
|
+
json: () => Promise<GetAccountConversationSettingsResponse>;
|
|
369
|
+
};
|
|
370
|
+
update(account: AccountID, { body, request }: UpdateAccountConversationSettingsOptions): {
|
|
371
|
+
response: () => Promise<ky.KyResponse<UpdateAccountConversationSettingsResponse>>;
|
|
372
|
+
json: () => Promise<UpdateAccountConversationSettingsResponse>;
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
|
|
305
376
|
/**
|
|
306
377
|
* Great Detail Support System.
|
|
307
378
|
*
|
|
@@ -2897,6 +2968,7 @@ declare class Client {
|
|
|
2897
2968
|
_transport: FetchTransport;
|
|
2898
2969
|
account: AccountAPI;
|
|
2899
2970
|
accountAccessToken: AccountAccessTokenAPI;
|
|
2971
|
+
accountConversationSettings: AccountConversationSettingsAPI;
|
|
2900
2972
|
action: ActionAPI;
|
|
2901
2973
|
boilerplateCategory: BoilerplateCategoryAPI;
|
|
2902
2974
|
boilerplateContent: BoilerplateContentAPI;
|
|
@@ -2918,4 +2990,4 @@ declare class Client {
|
|
|
2918
2990
|
static getBaseURL(): string;
|
|
2919
2991
|
}
|
|
2920
2992
|
|
|
2921
|
-
export { type
|
|
2993
|
+
export { type CreateBoilerplateCategoryPayload as $, type Account as A, type ListActionsOptions as B, Client as C, type DeleteAccountAccessTokenPayload as D, type ListActionsResponse as E, type BoilerplateContent as F, type GetAccountOptions as G, type BoilerplateContentID as H, type CreateBoilerplateContentPayload as I, type CreateBoilerplateContentOptions as J, type CreateBoilerplateContentResponse as K, type ListAccountAccessTokensOptions as L, type GetBoilerplateContentOptions as M, type GetBoilerplateContentResponse as N, type Options as O, type ListBoilerplateCategoryBoilerplateContentsOptions as P, type ListBoilerplateCategoryBoilerplateContentsResponse as Q, type RequestFilterable as R, type SortOptions as S, type ListBoilerplateContentsOptions as T, type UpdateAccountPayload as U, type ListBoilerplateContentsResponse as V, type UpdateBoilerplateContentPayload as W, type UpdateBoilerplateContentOptions as X, type UpdateBoilerplateContentResponse as Y, type BoilerplateCategory as Z, type BoilerplateCategoryID as _, type Options$5 as a, type DeleteConversationResponse as a$, type CreateBoilerplateCategoryOptions as a0, type CreateBoilerplateCategoryResponse as a1, type GetBoilerplateCategoryOptions as a2, type GetBoilerplateCategoryResponse as a3, type ListBoilerplateCategoriesIncludeOptions as a4, type ListBoilerplateCategoriesOptions as a5, type ListBoilerplateCategoriesResponse as a6, type UpdateBoilerplateCategoryPayload as a7, type UpdateBoilerplateCategoryOptions as a8, type UpdateBoilerplateCategoryResponse as a9, type ListCompositionSectionsOptions as aA, type ListCompositionSectionsResponse as aB, type UpdateCompositionSectionPayload as aC, type UpdateCompositionSectionOptions as aD, type UpdateCompositionSectionResponse as aE, type Contact as aF, type ContactID as aG, type CreateContactPayload as aH, type CreateContactOptions as aI, type CreateContactResponse as aJ, type GetContactIncludeOptions as aK, type GetContactOptions as aL, type GetContactResponse as aM, type GetContactVCFOptions as aN, type ListContactsOptions as aO, type ListContactsResponse as aP, type ListLabelContactsOptions as aQ, type ListLabelContactsResponse as aR, type UpdateContactPayload as aS, type UpdateContactOptions as aT, type UpdateContactResponse as aU, type Conversation as aV, type ConversationID as aW, type CreateConversationPayload as aX, type CreateConversationOptions as aY, type CreateConversationResponse as aZ, type DeleteConversationOptions as a_, type Channel as aa, type ChannelID as ab, type CreateChannelPayload as ac, type CreateChannelOptions as ad, type CreateChannelResponse as ae, type GetChannelOptions as af, type GetChannelResponse as ag, type ListChannelsOptions as ah, type ListChannelsResponse as ai, type MetaWhatsappChannelGetBusinessProfileOptions as aj, type MetaWhatsappChannelGetBusinessProfileResponse as ak, type TwilioSendChannelSyncPayload as al, type TwilioSendgridChannelSyncOptions as am, type TwilioSendgridChannelSyncResponse as an, type UpdateChannelPayload as ao, type UpdateChannelOptions as ap, type UpdateChannelResponse as aq, type CompositionSection as ar, type CompositionSectionID as as, type CreateCompositionSectionPayload as at, type CreateCompositionSectionOptions as au, type CreateCompositionSectionResponse as av, type GetCompositionSectionOptions as aw, type GetCompositionSectionResponse as ax, type ListChannelCompositionSectionsOptions as ay, type ListChannelCompositionSectionsResponse as az, type AccountID as b, type Note as b$, type GetConversationIncludeOptions as b0, type GetConversationOptions as b1, type GetConversationResponse as b2, type ListContactConversationsOptions as b3, type ListContactConversationsResponse as b4, type ListConversationsIncludeOptions as b5, type FilterOptions as b6, type ListConversationOptions as b7, type ListConversationsResponse as b8, type ListLabelConversationsOptions as b9, type CreateMessageResponse as bA, type DeleteMessageOptions as bB, type DeleteMessageResponse as bC, type ListChannelMessagesIncludeOptions as bD, type ListChannelMessagesOptions as bE, type ListChannelMessagesResponse as bF, type ListConversationMessagesIncludeOptions as bG, type ListConversationMessagesOptions as bH, type ListConversationMessagesResponse as bI, type ListMessagesIncludeOptions as bJ, type ListMessagesOptions as bK, type ListMessagesResponse as bL, type MessageID as bM, type MessageRole as bN, type MessageStatus as bO, type Model as bP, type CreateCorrectionModelPayload as bQ, type CreateCorrectionModelOptions as bR, type CreateCorrectionResponse as bS, type CreateResponseModelPayload as bT, type CreateResponseModelOptions as bU, type CreateResponseResponse as bV, type GetModelOptions as bW, type GetModelResponse as bX, type ListModelsOptions as bY, type ListModelsResponse as bZ, type ModelID as b_, type ListLabelConversationsResponse as ba, type UpdateConversationPayload as bb, type UpdateConversationOptions as bc, type UpdateConversationResponse as bd, type Label as be, type CreateLabelPayload as bf, type CreateLabelOptions as bg, type CreateLabelResponse as bh, type DeleteLabelOptions as bi, type DeleteLabelResponse as bj, type GetLabelOptions as bk, type GetLabelResponse as bl, type LabelID as bm, type ListContactLabelsOptions as bn, type ListContactLabelsResponse as bo, type ListConversationLabelsOptions as bp, type ListConversationLabelsResponse as bq, type ListLabelsIncludeOptions as br, type ListLabelsOptions as bs, type ListLabelsResponse as bt, type UpdateLabelPayload as bu, type UpdateLabelOptions as bv, type UpdateLabelResponse as bw, type Message as bx, type CreateMessagePayload as by, type CreateMessageOptions as bz, type CreateAccountPayload as c, type CreateContactNotePayload as c0, type CreateContactNoteOptions as c1, type CreateContactNoteResponse as c2, type CreateConversationNotePayload as c3, type CreateConversationNoteOptions as c4, type CreateConversationNoteResponse as c5, type GetNoteOptions as c6, type GetNoteResponse as c7, type ListContactNotesOptions as c8, type ListContactNotesResponse as c9, type GetNotificationWellKnownResponse as cA, type ListConversationNotesOptions as ca, type ListConversationNotesResponse as cb, type NoteID as cc, type UpdateNotePayload as cd, type UpdateNoteOptions as ce, type UpdateNoteResponse as cf, type Source as cg, type GetSourceOptions as ch, type GetSourceResponse as ci, type ListSourcesOptions as cj, type ListSourcesResponse as ck, type SourceID as cl, type NotificationSubscription as cm, type CreateContactNotificationSubscriptionPayload as cn, type CreateContactNotificationSubscriptionOptions as co, type CreateContactNotificationSubscriptionResponse as cp, type NotificationSubscriptionID as cq, type Upload as cr, type CreateUploadOptions as cs, type CreateUploadResponse as ct, type DeleteUploadOptions as cu, type DeleteUploadResponse as cv, type GetUploadOptions as cw, type GetUploadResponse as cx, type UploadID as cy, type WebhookResponse as cz, type CreateAccountOptions as d, type CreateAccountResponse as e, type GetAccountResponse as f, type UpdateAccountOptions as g, type UpdateAccountResponse as h, type AccountAccessToken as i, type AccountAccessTokenID as j, type CreateAccountAccessTokenPayload as k, type CreateAccountAccessTokenOptions as l, type CreateAccountAccessTokenResponse as m, type DeleteAccountAccessTokenOptions as n, type DeleteAccountAccessTokenResponse as o, type GetAccountAccessTokenOptions as p, type GetAccountAccessTokenResponse as q, type ListAccountAccessTokensResponse as r, type AccountConversationSettings as s, type GetAccountConversationSettingsOptions as t, type GetAccountConversationSettingsResponse as u, type UpdateAccountConversationSettingsPayload as v, type UpdateAccountConversationSettingsOptions as w, type UpdateAccountConversationSettingsResponse as x, type Action as y, type ActionID as z };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var $=Object.defineProperty;var Z=(r,t)=>{for(var e in t)$(r,e,{get:t[e],enumerable:!0})};var d=class{getHeaders(){return{}}};var Q="SUPPORT_ACCESS_TOKEN",H="SUPPORT_KEY_NAME",q="SUPPORT_KEY_PASSWORD",j="SUPPORT_SIGNING_KEY",V="SUPPORT_BASE_URL";var u=class{name;#t;constructor({name:t=process.env[H],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 K="https://api.support.greatdetail.com",W={"X-Powered-By":"GDSupport/JavaScript"};import{z as s}from"zod";var C=class r{static SCHEMA=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")]),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()})})]))})});constructor(){}async event({key:t=process.env[j],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."+j);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}=r.SCHEMA.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??{})]})}getVCFURL(t,{vcf:e={}}){let o=e.variant??"vcard",n=e.format??(o==="vcard"?"vcf":"json"),i="v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(n);return this._transport.getURL(i)}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})}};var A=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)]})}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 y=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 S=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 U=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}create(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var D=class r{constructor(t=r.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=W;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"})}};import z from"is-network-error";import J,{HTTPError as X}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 x=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=J.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let n of this.options.requestFilterables){let i=n.getHeaders();for(let[l,Y]of Object.entries(i))o.headers.has(l)||o.headers.set(l,Y)}}]}})}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(z(n))throw new x("A network error occurred",{cause:n});if(n instanceof X){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 F=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 N=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var k=class r{static DEFAULT_BASE_URL=K;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 D,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 A(this._transport),this.label=new T(this._transport),this.message=new y(this._transport),this.model=new S(this._transport),this.note=new U(this._transport),this.notificationSubscription=new G(this._transport),this.source=new E(this._transport),this.statistics=new w(this._transport),this.upload=new F(this._transport),this.webhook=new C,this.wellKnown=new N(this._transport)}static getBaseURL(){return process.env[V]??this.DEFAULT_BASE_URL}};export{Z as a,d as b,K as c,a as d,c as e,P as f,B as g,p as h,x as i,m as j,k};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as v,k as b}from"./chunk-
|
|
1
|
+
import{b as v,k as b}from"./chunk-CBX4D3XB.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 Ut=Object.create;var q=Object.defineProperty;var Dt=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,xt=Object.prototype.hasOwnProperty;var Pt=(n,t)=>{for(var e in t)q(n,e,{get:t[e],enumerable:!0})},Ct=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Gt(t))!xt.call(n,s)&&s!==e&&q(n,s,{get:()=>t[s],enumerable:!(o=Dt(t,s))||o.enumerable});return n};var ht=(n,t,e)=>(e=n!=null?Ut(Et(n)):{},Ct(t||!n||!n.__esModule?q(e,"default",{value:n,enumerable:!0}):e,n)),Bt=n=>Ct(q({},"__esModule",{value:!0}),n);var Nt={};Pt(Nt,{default:()=>Mt});module.exports=Bt(Nt);var wt=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}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",z="SUPPORT_SIGNING_KEY",Rt="SUPPORT_BASE_URL";var O=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 g=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 R=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 v=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 bt="https://api.support.greatdetail.com",vt={"X-Powered-By":"GDSupport/JavaScript"};var y=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??{})]})}getVCFURL(t,{vcf:e={}}){let o=e.variant??"vcard",s=e.format??(o==="vcard"?"vcf":"json"),i="v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(s);return this._transport.getURL(i)}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})}};var _=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)]})}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 I=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 T=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 A=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 w=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}create(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var U=class n{constructor(t=n.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=vt;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 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 G=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"})}};var Lt=ht(require("is-network-error"),1),H=ht(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var l=class extends a{};var E=class extends l{static unauthenticated(){return new this("An unauthenticated request occurred")}};var x=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 P=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=H.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,St]of Object.entries(i))o.headers.has(d)||o.headers.set(d,St)}}]}})}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 P("A network error occurred",{cause:s});if(s instanceof H.HTTPError){let i=s.response.status;switch(console.error(JSON.stringify(s.response)),i){case 400:throw u.badRequest();case 401:throw E.unauthenticated();case 403:throw x.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 F=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");var M=class n{static SCHEMA=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")]),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()})})]))})});constructor(){}async event({key:t=process.env[z],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."+z);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}=n.SCHEMA.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 j=class n{static DEFAULT_BASE_URL=bt;static PublicAuthentication=m;static BasicAuthentication=O;static BearerAuthentication=g;_transport;account;accountAccessToken;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 U,t],...o,baseURL:e?.toString()??n.getBaseURL()}),this.account=new C(this._transport),this.accountAccessToken=new h(this._transport),this.action=new f(this._transport),this.boilerplateCategory=new R(this._transport),this.boilerplateContent=new b(this._transport),this.channel=new v(this._transport),this.compositionSection=new L(this._transport),this.contact=new y(this._transport),this.conversation=new _(this._transport),this.label=new I(this._transport),this.message=new T(this._transport),this.model=new A(this._transport),this.note=new w(this._transport),this.notificationSubscription=new S(this._transport),this.source=new D(this._transport),this.statistics=new G(this._transport),this.upload=new F(this._transport),this.webhook=new M,this.wellKnown=new N(this._transport)}static getBaseURL(){return process.env[Rt]??this.DEFAULT_BASE_URL}};var J=require("commander"),yt=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,yt.oraPromise)(()=>n.action.list().json(),{...t,text:"Finding actions"});console.log(o)})),e}var Z=require("commander"),_t=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,_t.oraPromise)(()=>n.channel.list().json(),{...t,text:"Finding channels"});console.log(o)})),e}var k=require("commander"),K=require("ora");function et({client:n,ora:t}){let e=new k.Command("contacts").description("Contacts");return e.addCommand(new k.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 k.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 k.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 Q=require("commander"),W=require("ora");function st({client:n,ora:t}){let e=new Q.Command("labels").description("Labels");return e.addCommand(new Q.Command("get").description("Find label").argument("<label>","Label ID").action(async o=>{let s=await(0,W.oraPromise)(()=>n.label.get(o).json(),{...t,text:"Finding label"});console.log(s)})),e.addCommand(new Q.Command("list").description("List labels").action(async()=>{let o=await(0,W.oraPromise)(()=>n.label.list().json(),{...t,text:"Finding labels"});console.log(o)})),e.addCommand(new Q.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async o=>{let s=await(0,W.oraPromise)(()=>n.conversation.listByLabel(o).json(),{...t,text:"Finding conversations"});console.log(s)})),e}var rt=require("commander"),It=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,It.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 $=require("commander"),ct=require("ora");function mt({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,ct.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,ct.oraPromise)(()=>n.source.list().json(),{...t,text:"Finding sources"});console.log(o)})),e}var At=require("commander");var lt=require("commander"),Tt=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,Tt.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 At.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(dt({client:n,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new j(new m)},Ft=new wt.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)),Mt=Ft;
|
|
1
|
+
"use strict";var Dt=Object.create;var q=Object.defineProperty;var Gt=Object.getOwnPropertyDescriptor;var Et=Object.getOwnPropertyNames;var xt=Object.getPrototypeOf,Pt=Object.prototype.hasOwnProperty;var Ft=(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 Et(t))!Pt.call(n,s)&&s!==e&&q(n,s,{get:()=>t[s],enumerable:!(o=Gt(t,s))||o.enumerable});return n};var ft=(n,t,e)=>(e=n!=null?Dt(xt(n)):{},ht(t||!n||!n.__esModule?q(e,"default",{value:n,enumerable:!0}):e,n)),Bt=n=>ht(q({},"__esModule",{value:!0}),n);var Nt={};Ft(Nt,{default:()=>jt});module.exports=Bt(Nt);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 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 gt="SUPPORT_ACCESS_TOKEN",Ot="SUPPORT_KEY_NAME",Rt="SUPPORT_KEY_PASSWORD",J="SUPPORT_SIGNING_KEY",vt="SUPPORT_BASE_URL";var O=class{name;#t;constructor({name:t=process.env[Ot],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[gt]}={}){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 y=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??{})]})}getVCFURL(t,{vcf:e={}}){let o=e.variant??"vcard",s=e.format??(o==="vcard"?"vcf":"json"),i="v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(s);return this._transport.getURL(i)}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})}};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: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)]})}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: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 T=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}create(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"})}};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,Ut]of Object.entries(i))o.headers.has(d)||o.headers.set(d,Ut)}}]}})}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");var j=class n{static SCHEMA=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")]),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()})})]))})});constructor(){}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}=n.SCHEMA.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=O;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 g(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 y(this._transport),this.conversation=new I(this._transport),this.label=new A(this._transport),this.message=new T(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.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"),It=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,It.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 W=require("commander"),nt=require("ora");function st({client:n,ora:t}){let e=new W.Command("conversations").description("Conversations");return e.addCommand(new W.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async o=>{let s=await(0,nt.oraPromise)(()=>n.conversation.get(o).json(),{...t,text:"Finding conversation"});console.log(s)})),e.addCommand(new W.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 H=require("commander"),Y=require("ora");function rt({client:n,ora:t}){let e=new H.Command("labels").description("Labels");return e.addCommand(new H.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 H.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 H.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 $=require("commander"),pt=require("ora");function ct({client:n,ora:t}){let e=new $.Command("models").description("Models");return e.addCommand(new $.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 $.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 z=require("commander"),mt=require("ora");function lt({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,mt.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,mt.oraPromise)(()=>n.source.list().json(),{...t,text:"Finding sources"});console.log(o)})),e}var wt=require("commander");var dt=require("commander"),Tt=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,Tt.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 wt.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)},Mt=new St.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)),jt=Mt;
|
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-MTQCQH5K.js";import"../chunk-CBX4D3XB.js";export{a as default};
|
package/dist/cli.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var Ut=Object.create;var ut=Object.defineProperty;var Dt=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,xt=Object.prototype.hasOwnProperty;var Pt=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Gt(t))!xt.call(n,s)&&s!==e&&ut(n,s,{get:()=>t[s],enumerable:!(o=Dt(t,s))||o.enumerable});return n};var Ct=(n,t,e)=>(e=n!=null?Ut(Et(n)):{},Pt(t||!n||!n.__esModule?ut(e,"default",{value:n,enumerable:!0}):e,n));var At=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}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 ht="SUPPORT_ACCESS_TOKEN",ft="SUPPORT_KEY_NAME",Ot="SUPPORT_KEY_PASSWORD",$="SUPPORT_SIGNING_KEY",gt="SUPPORT_BASE_URL";var O=class{name;#t;constructor({name:t=process.env[ft],password:e=process.env[Ot]}={}){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 g=class{#t;constructor({token:t=process.env[ht]}={}){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 R=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 v=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 Rt="https://api.support.greatdetail.com",bt={"X-Powered-By":"GDSupport/JavaScript"};var y=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??{})]})}getVCFURL(t,{vcf:e={}}){let o=e.variant??"vcard",s=e.format??(o==="vcard"?"vcf":"json"),i="v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(s);return this._transport.getURL(i)}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})}};var _=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)]})}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 I=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 T=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 A=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 w=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}create(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var U=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 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 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 G=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"})}};var vt=Ct(require("is-network-error"),1),q=Ct(require("ky"),1);var a=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var l=class extends a{};var E=class extends l{static unauthenticated(){return new this("An unauthenticated request occurred")}};var x=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 P=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,St]of Object.entries(i))o.headers.has(d)||o.headers.set(d,St)}}]}})}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,vt.default)(s))throw new P("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 E.unauthenticated();case 403:throw x.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 F=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");var M=class n{static SCHEMA=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")]),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()})})]))})});constructor(){}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}=n.SCHEMA.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 j=class n{static DEFAULT_BASE_URL=Rt;static PublicAuthentication=m;static BasicAuthentication=O;static BearerAuthentication=g;_transport;account;accountAccessToken;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 U,t],...o,baseURL:e?.toString()??n.getBaseURL()}),this.account=new C(this._transport),this.accountAccessToken=new h(this._transport),this.action=new f(this._transport),this.boilerplateCategory=new R(this._transport),this.boilerplateContent=new b(this._transport),this.channel=new v(this._transport),this.compositionSection=new L(this._transport),this.contact=new y(this._transport),this.conversation=new _(this._transport),this.label=new I(this._transport),this.message=new T(this._transport),this.model=new A(this._transport),this.note=new w(this._transport),this.notificationSubscription=new S(this._transport),this.source=new D(this._transport),this.statistics=new G(this._transport),this.upload=new F(this._transport),this.webhook=new M,this.wellKnown=new N(this._transport)}static getBaseURL(){return process.env[gt]??this.DEFAULT_BASE_URL}};var z=require("commander"),Lt=require("ora");function J({client:n,ora:t}){let e=new z.Command("actions").description("Actions");return e.addCommand(new z.Command("list").description("List actions").action(async()=>{let o=await(0,Lt.oraPromise)(()=>n.action.list().json(),{...t,text:"Finding actions"});console.log(o)})),e}var X=require("commander"),yt=require("ora");function Z({client:n,ora:t}){let e=new X.Command("channels").description("Channels");return e.addCommand(new X.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 k=require("commander"),H=require("ora");function tt({client:n,ora:t}){let e=new k.Command("contacts").description("Contacts");return e.addCommand(new k.Command("get").description("Find contact").argument("<contact>","Contact ID").action(async o=>{let s=await(0,H.oraPromise)(()=>n.contact.get(o).json(),{...t,text:"Finding contact"});console.log(s)})),e.addCommand(new k.Command("list").description("List contacts").action(async()=>{let o=await(0,H.oraPromise)(()=>n.contact.list().json(),{...t,text:"Finding contacts"});console.log(o)})),e.addCommand(new k.Command("get-vcf").description("Export Contact as VCF").argument("<contact>","Contact ID").action(async o=>{let s=await(0,H.oraPromise)(()=>n.contact.getVCF(o).response(),{...t,text:"Exporting contact"});console.log(s)})),e}var K=require("commander"),et=require("ora");function ot({client:n,ora:t}){let e=new K.Command("conversations").description("Conversations");return e.addCommand(new K.Command("get").description("Find conversation").argument("<conversation>","Conversation ID").action(async o=>{let s=await(0,et.oraPromise)(()=>n.conversation.get(o).json(),{...t,text:"Finding conversation"});console.log(s)})),e.addCommand(new K.Command("list").description("List conversations").action(async()=>{let o=await(0,et.oraPromise)(()=>n.conversation.list().json(),{...t,text:"Finding conversations"});console.log(o)})),e}var Q=require("commander"),V=require("ora");function nt({client:n,ora:t}){let e=new Q.Command("labels").description("Labels");return e.addCommand(new Q.Command("get").description("Find label").argument("<label>","Label ID").action(async o=>{let s=await(0,V.oraPromise)(()=>n.label.get(o).json(),{...t,text:"Finding label"});console.log(s)})),e.addCommand(new Q.Command("list").description("List labels").action(async()=>{let o=await(0,V.oraPromise)(()=>n.label.list().json(),{...t,text:"Finding labels"});console.log(o)})),e.addCommand(new Q.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async o=>{let s=await(0,V.oraPromise)(()=>n.conversation.listByLabel(o).json(),{...t,text:"Finding conversations"});console.log(s)})),e}var st=require("commander"),_t=require("ora");function rt({client:n,ora:t}){let e=new st.Command("messages").description("Messages");return e.addCommand(new st.Command("list").description("List messages").action(async()=>{let o=await(0,_t.oraPromise)(()=>n.message.list().json(),{...t,text:"Finding messages"});console.log(o)})),e}var W=require("commander"),it=require("ora");function at({client:n,ora:t}){let e=new W.Command("models").description("Models");return e.addCommand(new W.Command("get").description("Find model").argument("<model>","Model ID").action(async o=>{let s=await(0,it.oraPromise)(()=>n.model.get(o).json(),{...t,text:"Finding model"});console.log(s)})),e.addCommand(new W.Command("list").description("List models").action(async()=>{let o=await(0,it.oraPromise)(()=>n.model.list().json(),{...t,text:"Finding models"});console.log(o)})),e}var Y=require("commander"),pt=require("ora");function ct({client:n,ora:t}){let e=new Y.Command("sources").description("Sources");return e.addCommand(new Y.Command("get").description("Find source").argument("<source>","Source ID").action(async o=>{let s=await(0,pt.oraPromise)(()=>n.source.get(o).json(),{...t,text:"Finding source"});console.log(s)})),e.addCommand(new Y.Command("list").description("List sources").action(async()=>{let o=await(0,pt.oraPromise)(()=>n.source.list().json(),{...t,text:"Finding sources"});console.log(o)})),e}var Tt=require("commander");var mt=require("commander"),It=require("ora");function lt({client:n,ora:t}){let e=new mt.Command("notifications").description("Well-Known Notifications Details");return e.addCommand(new mt.Command("get").description("Get Notifications Server Well-Known Info").action(async()=>{let o=await(0,It.oraPromise)(()=>n.wellKnown.getNotifications().json(),{...t,text:"Finding Notifications Well-Known Info"});console.log(o)})),e}function dt({client:n,ora:t}){let e=new Tt.Command("well-known").description("Well-Known Metadata & Info");return e.addCommand(lt({client:n,ora:t})),e}var p={ora:{spinner:"simpleDotsScrolling"},client:new j(new m)},Bt=new At.Command("gds").description("Great Detail Support System").addCommand(J(p)).addCommand(Z(p)).addCommand(tt(p)).addCommand(ot(p)).addCommand(nt(p)).addCommand(rt(p)).addCommand(at(p)).addCommand(ct(p)).addCommand(dt(p)),wt=Bt;wt.parseAsync(process.argv);
|
|
2
|
+
"use strict";var Dt=Object.create;var Ct=Object.defineProperty;var Gt=Object.getOwnPropertyDescriptor;var Et=Object.getOwnPropertyNames;var xt=Object.getPrototypeOf,Pt=Object.prototype.hasOwnProperty;var Ft=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Et(t))!Pt.call(n,s)&&s!==e&&Ct(n,s,{get:()=>t[s],enumerable:!(o=Gt(t,s))||o.enumerable});return n};var ht=(n,t,e)=>(e=n!=null?Dt(xt(n)):{},Ft(t||!n||!n.__esModule?Ct(e,"default",{value:n,enumerable:!0}):e,n));var wt=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 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 ft="SUPPORT_ACCESS_TOKEN",gt="SUPPORT_KEY_NAME",Ot="SUPPORT_KEY_PASSWORD",z="SUPPORT_SIGNING_KEY",Rt="SUPPORT_BASE_URL";var O=class{name;#t;constructor({name:t=process.env[gt],password:e=process.env[Ot]}={}){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 y=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 _=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??{})]})}getVCFURL(t,{vcf:e={}}){let o=e.variant??"vcard",s=e.format??(o==="vcard"?"vcf":"json"),i="v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(s);return this._transport.getURL(i)}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})}};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: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)]})}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: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 T=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}create(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"})}};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,Ut]of Object.entries(i))o.headers.has(d)||o.headers.set(d,Ut)}}]}})}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");var j=class n{static SCHEMA=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")]),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()})})]))})});constructor(){}async event({key:t=process.env[z],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."+z);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}=n.SCHEMA.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=O;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 g(this._transport),this.boilerplateCategory=new v(this._transport),this.boilerplateContent=new b(this._transport),this.channel=new L(this._transport),this.compositionSection=new y(this._transport),this.contact=new _(this._transport),this.conversation=new I(this._transport),this.label=new A(this._transport),this.message=new T(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.wellKnown=new N(this._transport)}static getBaseURL(){return process.env[Rt]??this.DEFAULT_BASE_URL}};var J=require("commander"),yt=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,yt.oraPromise)(()=>n.action.list().json(),{...t,text:"Finding actions"});console.log(o)})),e}var Z=require("commander"),_t=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,_t.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 H=require("commander"),W=require("ora");function st({client:n,ora:t}){let e=new H.Command("labels").description("Labels");return e.addCommand(new H.Command("get").description("Find label").argument("<label>","Label ID").action(async o=>{let s=await(0,W.oraPromise)(()=>n.label.get(o).json(),{...t,text:"Finding label"});console.log(s)})),e.addCommand(new H.Command("list").description("List labels").action(async()=>{let o=await(0,W.oraPromise)(()=>n.label.list().json(),{...t,text:"Finding labels"});console.log(o)})),e.addCommand(new H.Command("conversations").description("Find label conversations").argument("<label>","Label ID").action(async o=>{let s=await(0,W.oraPromise)(()=>n.conversation.listByLabel(o).json(),{...t,text:"Finding conversations"});console.log(s)})),e}var rt=require("commander"),It=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,It.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 $=require("commander"),ct=require("ora");function mt({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,ct.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,ct.oraPromise)(()=>n.source.list().json(),{...t,text:"Finding sources"});console.log(o)})),e}var Tt=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 Tt.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)},Bt=new wt.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)),St=Bt;St.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-MTQCQH5K.js";import"./chunk-CBX4D3XB.js";r.parseAsync(process.argv);
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var et=Object.create;var k=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var st=Object.getPrototypeOf,nt=Object.prototype.hasOwnProperty;var V=(r,t)=>{for(var e in t)k(r,e,{get:t[e],enumerable:!0})},K=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of rt(t))!nt.call(r,n)&&n!==e&&k(r,n,{get:()=>t[n],enumerable:!(o=ot(t,n))||o.enumerable});return r};var W=(r,t,e)=>(e=r!=null?et(st(r)):{},K(t||!r||!r.__esModule?k(e,"default",{value:r,enumerable:!0}):e,r)),it=r=>K(k({},"__esModule",{value:!0}),r);var pt={};V(pt,{Client:()=>h,DEFAULT_SUPPORT_BASE_URL:()=>j,Error:()=>H,default:()=>h});module.exports=it(pt);var j="https://api.support.greatdetail.com",Y={"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}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 z="SUPPORT_ACCESS_TOKEN",$="SUPPORT_KEY_NAME",J="SUPPORT_KEY_PASSWORD",q="SUPPORT_SIGNING_KEY",X="SUPPORT_BASE_URL";var g=class{name;#t;constructor({name:t=process.env[$],password:e=process.env[J]}={}){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 x=class{#t;constructor({token:t=process.env[z]}={}){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{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 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 I=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 T=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??{})]})}getVCFURL(t,{vcf:e={}}){let o=e.variant??"vcard",n=e.format??(o==="vcard"?"vcf":"json"),i="v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(n);return this._transport.getURL(i)}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})}};var A=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)]})}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 y=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 S=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 E=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}create(t,{body:e,request:o={}}){return this._transport.send("v1/contacts/"+encodeURIComponent(t)+"/notification-subscriptions",{...o,method:"POST",json:e})}};var D=class r{constructor(t=r.STANDARD_HEADERS){this._standardHeaders=t}static STANDARD_HEADERS=Y;async filter(){return{headers:this.getHeaders()}}getHeaders(){return this._standardHeaders}};var w=class{constructor(t){this._transport=t}get(t,{request:e={}}={}){return this._transport.send("v1/sources/"+encodeURIComponent(t),{...e,method:"GET"})}list({featured:t,category:e,request:o={}}={}){let n=[];if(e){let i=Array.isArray(e)?e:[e];for(let f of i)n.push(["category",f])}return t!==void 0&&n.push(["featured",String(t)]),this._transport.send("v1/sources",{...o,method:"GET",searchParams:n})}};var P=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"})}};var Z=W(require("is-network-error"),1),Q=W(require("ky"),1);var p=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends p{};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 p{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 p{};var m=class extends p{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 n of this.options.requestFilterables){let i=n.getHeaders();for(let[f,tt]of Object.entries(i))o.headers.has(f)||o.headers.set(f,tt)}}]}})}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,Z.default)(n))throw new u("A network error occurred",{cause:n});if(n instanceof Q.HTTPError){let i=n.response.status;switch(console.error(JSON.stringify(n.response)),i){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(i>=500&&i<600)throw p.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 s=require("zod");var F=class r{static SCHEMA=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")]),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()})})]))})});constructor(){}async event({key:t=process.env[q],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."+q);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}=r.SCHEMA.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 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=j;static PublicAuthentication=v;static BasicAuthentication=g;static BearerAuthentication=x;_transport;account;accountAccessToken;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()??r.getBaseURL()}),this.account=new C(this._transport),this.accountAccessToken=new R(this._transport),this.action=new O(this._transport),this.boilerplateCategory=new _(this._transport),this.boilerplateContent=new b(this._transport),this.channel=new L(this._transport),this.compositionSection=new I(this._transport),this.contact=new T(this._transport),this.conversation=new A(this._transport),this.label=new y(this._transport),this.message=new U(this._transport),this.model=new S(this._transport),this.note=new E(this._transport),this.notificationSubscription=new G(this._transport),this.source=new w(this._transport),this.statistics=new P(this._transport),this.upload=new M(this._transport),this.webhook=new F,this.wellKnown=new N(this._transport)}static getBaseURL(){return process.env[X]??this.DEFAULT_BASE_URL}};var H={};V(H,{AuthError:()=>c,AuthenticationError:()=>l,AuthorizationError:()=>d,LogicError:()=>a,NetworkError:()=>u,SupportError:()=>p,ValidationError:()=>m});0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,Error});
|
|
1
|
+
"use strict";var ot=Object.create;var j=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var nt=Object.getPrototypeOf,it=Object.prototype.hasOwnProperty;var K=(r,t)=>{for(var e in t)j(r,e,{get:t[e],enumerable:!0})},W=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of st(t))!it.call(r,n)&&n!==e&&j(r,n,{get:()=>t[n],enumerable:!(o=rt(t,n))||o.enumerable});return r};var Y=(r,t,e)=>(e=r!=null?ot(nt(r)):{},W(t||!r||!r.__esModule?j(e,"default",{value:r,enumerable:!0}):e,r)),pt=r=>W(j({},"__esModule",{value:!0}),r);var at={};K(at,{Client:()=>C,DEFAULT_SUPPORT_BASE_URL:()=>Q,Error:()=>V,default:()=>C});module.exports=pt(at);var Q="https://api.support.greatdetail.com",z={"X-Powered-By":"GDSupport/JavaScript"};var h=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 x=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 $="SUPPORT_ACCESS_TOKEN",J="SUPPORT_KEY_NAME",X="SUPPORT_KEY_PASSWORD",H="SUPPORT_SIGNING_KEY",Z="SUPPORT_BASE_URL";var g=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 A=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 I=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 T=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??{})]})}getVCFURL(t,{vcf:e={}}){let o=e.variant??"vcard",n=e.format??(o==="vcard"?"vcf":"json"),i="v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(n);return this._transport.getURL(i)}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})}};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)]})}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 S=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 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}create(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=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 i=Array.isArray(e)?e:[e];for(let f of i)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"})}};var tt=Y(require("is-network-error"),1),q=Y(require("ky"),1);var p=class extends Error{static serverError(t){return new this("Server Error: "+t)}};var c=class extends p{};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 p{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 p{};var m=class extends p{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=q.default.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let n of this.options.requestFilterables){let i=n.getHeaders();for(let[f,et]of Object.entries(i))o.headers.has(f)||o.headers.set(f,et)}}]}})}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 i=n.response.status;switch(console.error(JSON.stringify(n.response)),i){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(i>=500&&i<600)throw p.serverError(i)}throw n});return{response:()=>o,json:async()=>(await o).json()}}};var F=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 s=require("zod");var N=class r{static SCHEMA=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")]),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()})})]))})});constructor(){}async event({key:t=process.env[H],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."+H);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}=r.SCHEMA.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 C=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 M({requestFilterables:[new w,t],...o,baseURL:e?.toString()??r.getBaseURL()}),this.account=new h(this._transport),this.accountAccessToken=new R(this._transport),this.accountConversationSettings=new x(this._transport),this.action=new O(this._transport),this.boilerplateCategory=new _(this._transport),this.boilerplateContent=new L(this._transport),this.channel=new A(this._transport),this.compositionSection=new I(this._transport),this.contact=new T(this._transport),this.conversation=new y(this._transport),this.label=new S(this._transport),this.message=new U(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 F(this._transport),this.webhook=new N,this.wellKnown=new k(this._transport)}static getBaseURL(){return process.env[Z]??this.DEFAULT_BASE_URL}};var V={};K(V,{AuthError:()=>c,AuthenticationError:()=>l,AuthorizationError:()=>d,LogicError:()=>a,NetworkError:()=>u,SupportError:()=>p,ValidationError:()=>m});0&&(module.exports={Client,DEFAULT_SUPPORT_BASE_URL,Error});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export { i as AccountAccessTokenID, r as ActionID, P as BoilerplateCategoryID, B as BoilerplateContentID, a2 as ChannelID, C as Client, ai as CompositionSectionID, av as ContactID, aK as ConversationID, k as CreateAccountAccessTokenOptions, j as CreateAccountAccessTokenPayload, l as CreateAccountAccessTokenResponse, d as CreateAccountOptions, c as CreateAccountPayload, e as CreateAccountResponse, T as CreateBoilerplateCategoryOptions, Q as CreateBoilerplateCategoryPayload, V as CreateBoilerplateCategoryResponse, w as CreateBoilerplateContentOptions, v as CreateBoilerplateContentPayload, x as CreateBoilerplateContentResponse, a4 as CreateChannelOptions, a3 as CreateChannelPayload, a5 as CreateChannelResponse, ak as CreateCompositionSectionOptions, aj as CreateCompositionSectionPayload, al as CreateCompositionSectionResponse, bN as CreateContactNoteOptions, bM as CreateContactNotePayload, bO as CreateContactNoteResponse, c6 as CreateContactNotificationSubscriptionOptions, c5 as CreateContactNotificationSubscriptionPayload, c7 as CreateContactNotificationSubscriptionResponse, ax as CreateContactOptions, aw as CreateContactPayload, ay as CreateContactResponse, bQ as CreateConversationNoteOptions, bP as CreateConversationNotePayload, bR as CreateConversationNoteResponse, aM as CreateConversationOptions, aL as CreateConversationPayload, aN as CreateConversationResponse, bC as CreateCorrectionModelOptions, bB as CreateCorrectionModelPayload, bD as CreateCorrectionResponse, b3 as CreateLabelOptions, b2 as CreateLabelPayload, b4 as CreateLabelResponse, bl as CreateMessageOptions, bk as CreateMessagePayload, bm as CreateMessageResponse, bF as CreateResponseModelOptions, bE as CreateResponseModelPayload, bG as CreateResponseResponse, c9 as CreateUploadOptions, ca as CreateUploadResponse, m as DeleteAccountAccessTokenOptions, D as DeleteAccountAccessTokenPayload, n as DeleteAccountAccessTokenResponse, aO as DeleteConversationOptions, aP as DeleteConversationResponse, b5 as DeleteLabelOptions, b6 as DeleteLabelResponse, bn as DeleteMessageOptions, bo as DeleteMessageResponse, cb as DeleteUploadOptions, cc as DeleteUploadResponse, aW as FilterOptions, o as GetAccountAccessTokenOptions, p as GetAccountAccessTokenResponse, G as GetAccountOptions, f as GetAccountResponse, W as GetBoilerplateCategoryOptions, X as GetBoilerplateCategoryResponse, y as GetBoilerplateContentOptions, z as GetBoilerplateContentResponse, a6 as GetChannelOptions, a7 as GetChannelResponse, am as GetCompositionSectionOptions, an as GetCompositionSectionResponse, az as GetContactIncludeOptions, aA as GetContactOptions, aB as GetContactResponse, aC as GetContactVCFOptions, aQ as GetConversationIncludeOptions, aR as GetConversationOptions, aS as GetConversationResponse, b7 as GetLabelOptions, b8 as GetLabelResponse, bH as GetModelOptions, bI as GetModelResponse, bS as GetNoteOptions, bT as GetNoteResponse, ch as GetNotificationWellKnownResponse, c0 as GetSourceOptions, c1 as GetSourceResponse, cd as GetUploadOptions, ce as GetUploadResponse, b9 as LabelID, L as ListAccountAccessTokensOptions, q as ListAccountAccessTokensResponse, t as ListActionsOptions, u as ListActionsResponse, Y as ListBoilerplateCategoriesIncludeOptions, Z as ListBoilerplateCategoriesOptions, _ as ListBoilerplateCategoriesResponse, E as ListBoilerplateCategoryBoilerplateContentsOptions, F as ListBoilerplateCategoryBoilerplateContentsResponse, H as ListBoilerplateContentsOptions, I as ListBoilerplateContentsResponse, ao as ListChannelCompositionSectionsOptions, ap as ListChannelCompositionSectionsResponse, bp as ListChannelMessagesIncludeOptions, bq as ListChannelMessagesOptions, br as ListChannelMessagesResponse, a8 as ListChannelsOptions, a9 as ListChannelsResponse, aq as ListCompositionSectionsOptions, ar as ListCompositionSectionsResponse, aT as ListContactConversationsOptions, aU as ListContactConversationsResponse, ba as ListContactLabelsOptions, bb as ListContactLabelsResponse, bU as ListContactNotesOptions, bV as ListContactNotesResponse, aD as ListContactsOptions, aE as ListContactsResponse, bc as ListConversationLabelsOptions, bd as ListConversationLabelsResponse, bs as ListConversationMessagesIncludeOptions, bt as ListConversationMessagesOptions, bu as ListConversationMessagesResponse, bW as ListConversationNotesOptions, bX as ListConversationNotesResponse, aX as ListConversationOptions, aV as ListConversationsIncludeOptions, aY as ListConversationsResponse, aF as ListLabelContactsOptions, aG as ListLabelContactsResponse, aZ as ListLabelConversationsOptions, a_ as ListLabelConversationsResponse, be as ListLabelsIncludeOptions, bf as ListLabelsOptions, bg as ListLabelsResponse, bv as ListMessagesIncludeOptions, bw as ListMessagesOptions, bx as ListMessagesResponse, bJ as ListModelsOptions, bK as ListModelsResponse, c2 as ListSourcesOptions, c3 as ListSourcesResponse, by as MessageID, bz as MessageRole, bA as MessageStatus, aa as MetaWhatsappChannelGetBusinessProfileOptions, ab as MetaWhatsappChannelGetBusinessProfileResponse, bL as ModelID, bY as NoteID, c8 as NotificationSubscriptionID, O as Options, a as RequestFilterable, s as SortOptions, c4 as SourceID, b as TransportOptions, ac as TwilioSendChannelSyncPayload, ad as TwilioSendgridChannelSyncOptions, ae as TwilioSendgridChannelSyncResponse, g as UpdateAccountOptions, U as UpdateAccountPayload, h as UpdateAccountResponse, a0 as UpdateBoilerplateCategoryOptions, $ as UpdateBoilerplateCategoryPayload, a1 as UpdateBoilerplateCategoryResponse, K as UpdateBoilerplateContentOptions, J as UpdateBoilerplateContentPayload, M as UpdateBoilerplateContentResponse, ag as UpdateChannelOptions, af as UpdateChannelPayload, ah as UpdateChannelResponse, at as UpdateCompositionSectionOptions, as as UpdateCompositionSectionPayload, au as UpdateCompositionSectionResponse, aI as UpdateContactOptions, aH as UpdateContactPayload, aJ as UpdateContactResponse, b0 as UpdateConversationOptions, a$ as UpdateConversationPayload, b1 as UpdateConversationResponse, bi as UpdateLabelOptions, bh as UpdateLabelPayload, bj as UpdateLabelResponse, b_ as UpdateNoteOptions, bZ as UpdateNotePayload, b$ as UpdateNoteResponse, cf as UploadID, cg as WebhookResponse, C as default } from './Client-DGn8aBic.cjs';
|
|
1
|
+
export { A as Account, i as AccountAccessToken, j as AccountAccessTokenID, s as AccountConversationSettings, b as AccountID, y as Action, z as ActionID, Z as BoilerplateCategory, _ as BoilerplateCategoryID, F as BoilerplateContent, H as BoilerplateContentID, aa as Channel, ab as ChannelID, C as Client, ar as CompositionSection, as as CompositionSectionID, aF as Contact, aG as ContactID, aV as Conversation, aW as ConversationID, l as CreateAccountAccessTokenOptions, k as CreateAccountAccessTokenPayload, m as CreateAccountAccessTokenResponse, d as CreateAccountOptions, c as CreateAccountPayload, e as CreateAccountResponse, a0 as CreateBoilerplateCategoryOptions, $ as CreateBoilerplateCategoryPayload, a1 as CreateBoilerplateCategoryResponse, J as CreateBoilerplateContentOptions, I as CreateBoilerplateContentPayload, K as CreateBoilerplateContentResponse, ad as CreateChannelOptions, ac as CreateChannelPayload, ae as CreateChannelResponse, au as CreateCompositionSectionOptions, at as CreateCompositionSectionPayload, av as CreateCompositionSectionResponse, c1 as CreateContactNoteOptions, c0 as CreateContactNotePayload, c2 as CreateContactNoteResponse, co as CreateContactNotificationSubscriptionOptions, cn as CreateContactNotificationSubscriptionPayload, cp as CreateContactNotificationSubscriptionResponse, aI as CreateContactOptions, aH as CreateContactPayload, aJ as CreateContactResponse, c4 as CreateConversationNoteOptions, c3 as CreateConversationNotePayload, c5 as CreateConversationNoteResponse, aY as CreateConversationOptions, aX as CreateConversationPayload, aZ as CreateConversationResponse, bR as CreateCorrectionModelOptions, bQ as CreateCorrectionModelPayload, bS as CreateCorrectionResponse, bg as CreateLabelOptions, bf as CreateLabelPayload, bh as CreateLabelResponse, bz as CreateMessageOptions, by as CreateMessagePayload, bA as CreateMessageResponse, bU as CreateResponseModelOptions, bT as CreateResponseModelPayload, bV as CreateResponseResponse, cs as CreateUploadOptions, ct as CreateUploadResponse, n as DeleteAccountAccessTokenOptions, D as DeleteAccountAccessTokenPayload, o as DeleteAccountAccessTokenResponse, a_ as DeleteConversationOptions, a$ as DeleteConversationResponse, bi as DeleteLabelOptions, bj as DeleteLabelResponse, bB as DeleteMessageOptions, bC as DeleteMessageResponse, cu as DeleteUploadOptions, cv as DeleteUploadResponse, b6 as FilterOptions, p as GetAccountAccessTokenOptions, q as GetAccountAccessTokenResponse, t as GetAccountConversationSettingsOptions, u as GetAccountConversationSettingsResponse, G as GetAccountOptions, f as GetAccountResponse, a2 as GetBoilerplateCategoryOptions, a3 as GetBoilerplateCategoryResponse, M as GetBoilerplateContentOptions, N as GetBoilerplateContentResponse, af as GetChannelOptions, ag as GetChannelResponse, aw as GetCompositionSectionOptions, ax as GetCompositionSectionResponse, aK as GetContactIncludeOptions, aL as GetContactOptions, aM as GetContactResponse, aN as GetContactVCFOptions, b0 as GetConversationIncludeOptions, b1 as GetConversationOptions, b2 as GetConversationResponse, bk as GetLabelOptions, bl as GetLabelResponse, bW as GetModelOptions, bX as GetModelResponse, c6 as GetNoteOptions, c7 as GetNoteResponse, cA as GetNotificationWellKnownResponse, ch as GetSourceOptions, ci as GetSourceResponse, cw as GetUploadOptions, cx as GetUploadResponse, be as Label, bm as LabelID, L as ListAccountAccessTokensOptions, r as ListAccountAccessTokensResponse, B as ListActionsOptions, E as ListActionsResponse, a4 as ListBoilerplateCategoriesIncludeOptions, a5 as ListBoilerplateCategoriesOptions, a6 as ListBoilerplateCategoriesResponse, P as ListBoilerplateCategoryBoilerplateContentsOptions, Q as ListBoilerplateCategoryBoilerplateContentsResponse, T as ListBoilerplateContentsOptions, V as ListBoilerplateContentsResponse, ay as ListChannelCompositionSectionsOptions, az as ListChannelCompositionSectionsResponse, bD as ListChannelMessagesIncludeOptions, bE as ListChannelMessagesOptions, bF as ListChannelMessagesResponse, ah as ListChannelsOptions, ai as ListChannelsResponse, aA as ListCompositionSectionsOptions, aB as ListCompositionSectionsResponse, b3 as ListContactConversationsOptions, b4 as ListContactConversationsResponse, bn as ListContactLabelsOptions, bo as ListContactLabelsResponse, c8 as ListContactNotesOptions, c9 as ListContactNotesResponse, aO as ListContactsOptions, aP as ListContactsResponse, bp as ListConversationLabelsOptions, bq as ListConversationLabelsResponse, bG as ListConversationMessagesIncludeOptions, bH as ListConversationMessagesOptions, bI as ListConversationMessagesResponse, ca as ListConversationNotesOptions, cb as ListConversationNotesResponse, b7 as ListConversationOptions, b5 as ListConversationsIncludeOptions, b8 as ListConversationsResponse, aQ as ListLabelContactsOptions, aR as ListLabelContactsResponse, b9 as ListLabelConversationsOptions, ba as ListLabelConversationsResponse, br as ListLabelsIncludeOptions, bs as ListLabelsOptions, bt as ListLabelsResponse, bJ as ListMessagesIncludeOptions, bK as ListMessagesOptions, bL as ListMessagesResponse, bY as ListModelsOptions, bZ as ListModelsResponse, cj as ListSourcesOptions, ck as ListSourcesResponse, bx as Message, bM as MessageID, bN as MessageRole, bO as MessageStatus, aj as MetaWhatsappChannelGetBusinessProfileOptions, ak as MetaWhatsappChannelGetBusinessProfileResponse, bP as Model, b_ as ModelID, b$ as Note, cc as NoteID, cm as NotificationSubscription, cq as NotificationSubscriptionID, O as Options, R as RequestFilterable, S as SortOptions, cg as Source, cl as SourceID, a as TransportOptions, al as TwilioSendChannelSyncPayload, am as TwilioSendgridChannelSyncOptions, an as TwilioSendgridChannelSyncResponse, w as UpdateAccountConversationSettingsOptions, v as UpdateAccountConversationSettingsPayload, x as UpdateAccountConversationSettingsResponse, g as UpdateAccountOptions, U as UpdateAccountPayload, h as UpdateAccountResponse, a8 as UpdateBoilerplateCategoryOptions, a7 as UpdateBoilerplateCategoryPayload, a9 as UpdateBoilerplateCategoryResponse, X as UpdateBoilerplateContentOptions, W as UpdateBoilerplateContentPayload, Y as UpdateBoilerplateContentResponse, ap as UpdateChannelOptions, ao as UpdateChannelPayload, aq as UpdateChannelResponse, aD as UpdateCompositionSectionOptions, aC as UpdateCompositionSectionPayload, aE as UpdateCompositionSectionResponse, aT as UpdateContactOptions, aS as UpdateContactPayload, aU as UpdateContactResponse, bc as UpdateConversationOptions, bb as UpdateConversationPayload, bd as UpdateConversationResponse, bv as UpdateLabelOptions, bu as UpdateLabelPayload, bw as UpdateLabelResponse, ce as UpdateNoteOptions, cd as UpdateNotePayload, cf as UpdateNoteResponse, cr as Upload, cy as UploadID, cz as WebhookResponse, C as default } from './Client-DKNuv_mB.cjs';
|
|
3
2
|
import 'ky';
|
|
4
3
|
import 'zod';
|
|
5
4
|
|
|
@@ -137,62 +136,4 @@ declare namespace index {
|
|
|
137
136
|
export { index_AuthError as AuthError, index_AuthenticationError as AuthenticationError, index_AuthorizationError as AuthorizationError, index_LogicError as LogicError, index_NetworkError as NetworkError, index_SupportError as SupportError, index_ValidationError as ValidationError };
|
|
138
137
|
}
|
|
139
138
|
|
|
140
|
-
|
|
141
|
-
* Great Detail Support System.
|
|
142
|
-
*
|
|
143
|
-
* @copyright 2024 Great Detail Ltd
|
|
144
|
-
* @author Great Detail Ltd <info@greatdetail.com>
|
|
145
|
-
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
146
|
-
* @see https://greatdetail.com
|
|
147
|
-
*/
|
|
148
|
-
|
|
149
|
-
type AccountConversationSettings = {
|
|
150
|
-
account: AccountID;
|
|
151
|
-
defaultName?: Nullable<string>;
|
|
152
|
-
responseDuration?: Nullable<string>;
|
|
153
|
-
resolveDuration?: Nullable<string>;
|
|
154
|
-
} & ResponseTimestamp;
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Great Detail Support System.
|
|
158
|
-
*
|
|
159
|
-
* @copyright 2024 Great Detail Ltd
|
|
160
|
-
* @author Great Detail Ltd <info@greatdetail.com>
|
|
161
|
-
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
162
|
-
* @see https://greatdetail.com
|
|
163
|
-
*/
|
|
164
|
-
|
|
165
|
-
interface GetAccountConversationSettingsOptions {
|
|
166
|
-
request?: SendOptions;
|
|
167
|
-
}
|
|
168
|
-
type GetAccountConversationSettingsResponse = {
|
|
169
|
-
data: {
|
|
170
|
-
accountConversationSettings: AccountConversationSettings;
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Great Detail Support System.
|
|
176
|
-
*
|
|
177
|
-
* @copyright 2024 Great Detail Ltd
|
|
178
|
-
* @author Great Detail Ltd <info@greatdetail.com>
|
|
179
|
-
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
180
|
-
* @see https://greatdetail.com
|
|
181
|
-
*/
|
|
182
|
-
|
|
183
|
-
type UpdateAccountConversationSettingsPayload = {
|
|
184
|
-
defaultName?: Nullable<string>;
|
|
185
|
-
responseDuration?: Nullable<string>;
|
|
186
|
-
resolveDuration?: Nullable<string>;
|
|
187
|
-
};
|
|
188
|
-
interface UpdateAccountConversationSettingsOptions {
|
|
189
|
-
body: UpdateAccountConversationSettingsPayload;
|
|
190
|
-
request?: SendOptions;
|
|
191
|
-
}
|
|
192
|
-
type UpdateAccountConversationSettingsResponse = {
|
|
193
|
-
data: {
|
|
194
|
-
accountConversationSettings: AccountConversationSettings;
|
|
195
|
-
};
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
export { AccountID, DEFAULT_SUPPORT_BASE_URL, index as Error, type GetAccountConversationSettingsOptions, type GetAccountConversationSettingsResponse, type UpdateAccountConversationSettingsOptions, type UpdateAccountConversationSettingsPayload, type UpdateAccountConversationSettingsResponse };
|
|
139
|
+
export { DEFAULT_SUPPORT_BASE_URL, index as Error };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export { i as AccountAccessTokenID, r as ActionID, P as BoilerplateCategoryID, B as BoilerplateContentID, a2 as ChannelID, C as Client, ai as CompositionSectionID, av as ContactID, aK as ConversationID, k as CreateAccountAccessTokenOptions, j as CreateAccountAccessTokenPayload, l as CreateAccountAccessTokenResponse, d as CreateAccountOptions, c as CreateAccountPayload, e as CreateAccountResponse, T as CreateBoilerplateCategoryOptions, Q as CreateBoilerplateCategoryPayload, V as CreateBoilerplateCategoryResponse, w as CreateBoilerplateContentOptions, v as CreateBoilerplateContentPayload, x as CreateBoilerplateContentResponse, a4 as CreateChannelOptions, a3 as CreateChannelPayload, a5 as CreateChannelResponse, ak as CreateCompositionSectionOptions, aj as CreateCompositionSectionPayload, al as CreateCompositionSectionResponse, bN as CreateContactNoteOptions, bM as CreateContactNotePayload, bO as CreateContactNoteResponse, c6 as CreateContactNotificationSubscriptionOptions, c5 as CreateContactNotificationSubscriptionPayload, c7 as CreateContactNotificationSubscriptionResponse, ax as CreateContactOptions, aw as CreateContactPayload, ay as CreateContactResponse, bQ as CreateConversationNoteOptions, bP as CreateConversationNotePayload, bR as CreateConversationNoteResponse, aM as CreateConversationOptions, aL as CreateConversationPayload, aN as CreateConversationResponse, bC as CreateCorrectionModelOptions, bB as CreateCorrectionModelPayload, bD as CreateCorrectionResponse, b3 as CreateLabelOptions, b2 as CreateLabelPayload, b4 as CreateLabelResponse, bl as CreateMessageOptions, bk as CreateMessagePayload, bm as CreateMessageResponse, bF as CreateResponseModelOptions, bE as CreateResponseModelPayload, bG as CreateResponseResponse, c9 as CreateUploadOptions, ca as CreateUploadResponse, m as DeleteAccountAccessTokenOptions, D as DeleteAccountAccessTokenPayload, n as DeleteAccountAccessTokenResponse, aO as DeleteConversationOptions, aP as DeleteConversationResponse, b5 as DeleteLabelOptions, b6 as DeleteLabelResponse, bn as DeleteMessageOptions, bo as DeleteMessageResponse, cb as DeleteUploadOptions, cc as DeleteUploadResponse, aW as FilterOptions, o as GetAccountAccessTokenOptions, p as GetAccountAccessTokenResponse, G as GetAccountOptions, f as GetAccountResponse, W as GetBoilerplateCategoryOptions, X as GetBoilerplateCategoryResponse, y as GetBoilerplateContentOptions, z as GetBoilerplateContentResponse, a6 as GetChannelOptions, a7 as GetChannelResponse, am as GetCompositionSectionOptions, an as GetCompositionSectionResponse, az as GetContactIncludeOptions, aA as GetContactOptions, aB as GetContactResponse, aC as GetContactVCFOptions, aQ as GetConversationIncludeOptions, aR as GetConversationOptions, aS as GetConversationResponse, b7 as GetLabelOptions, b8 as GetLabelResponse, bH as GetModelOptions, bI as GetModelResponse, bS as GetNoteOptions, bT as GetNoteResponse, ch as GetNotificationWellKnownResponse, c0 as GetSourceOptions, c1 as GetSourceResponse, cd as GetUploadOptions, ce as GetUploadResponse, b9 as LabelID, L as ListAccountAccessTokensOptions, q as ListAccountAccessTokensResponse, t as ListActionsOptions, u as ListActionsResponse, Y as ListBoilerplateCategoriesIncludeOptions, Z as ListBoilerplateCategoriesOptions, _ as ListBoilerplateCategoriesResponse, E as ListBoilerplateCategoryBoilerplateContentsOptions, F as ListBoilerplateCategoryBoilerplateContentsResponse, H as ListBoilerplateContentsOptions, I as ListBoilerplateContentsResponse, ao as ListChannelCompositionSectionsOptions, ap as ListChannelCompositionSectionsResponse, bp as ListChannelMessagesIncludeOptions, bq as ListChannelMessagesOptions, br as ListChannelMessagesResponse, a8 as ListChannelsOptions, a9 as ListChannelsResponse, aq as ListCompositionSectionsOptions, ar as ListCompositionSectionsResponse, aT as ListContactConversationsOptions, aU as ListContactConversationsResponse, ba as ListContactLabelsOptions, bb as ListContactLabelsResponse, bU as ListContactNotesOptions, bV as ListContactNotesResponse, aD as ListContactsOptions, aE as ListContactsResponse, bc as ListConversationLabelsOptions, bd as ListConversationLabelsResponse, bs as ListConversationMessagesIncludeOptions, bt as ListConversationMessagesOptions, bu as ListConversationMessagesResponse, bW as ListConversationNotesOptions, bX as ListConversationNotesResponse, aX as ListConversationOptions, aV as ListConversationsIncludeOptions, aY as ListConversationsResponse, aF as ListLabelContactsOptions, aG as ListLabelContactsResponse, aZ as ListLabelConversationsOptions, a_ as ListLabelConversationsResponse, be as ListLabelsIncludeOptions, bf as ListLabelsOptions, bg as ListLabelsResponse, bv as ListMessagesIncludeOptions, bw as ListMessagesOptions, bx as ListMessagesResponse, bJ as ListModelsOptions, bK as ListModelsResponse, c2 as ListSourcesOptions, c3 as ListSourcesResponse, by as MessageID, bz as MessageRole, bA as MessageStatus, aa as MetaWhatsappChannelGetBusinessProfileOptions, ab as MetaWhatsappChannelGetBusinessProfileResponse, bL as ModelID, bY as NoteID, c8 as NotificationSubscriptionID, O as Options, a as RequestFilterable, s as SortOptions, c4 as SourceID, b as TransportOptions, ac as TwilioSendChannelSyncPayload, ad as TwilioSendgridChannelSyncOptions, ae as TwilioSendgridChannelSyncResponse, g as UpdateAccountOptions, U as UpdateAccountPayload, h as UpdateAccountResponse, a0 as UpdateBoilerplateCategoryOptions, $ as UpdateBoilerplateCategoryPayload, a1 as UpdateBoilerplateCategoryResponse, K as UpdateBoilerplateContentOptions, J as UpdateBoilerplateContentPayload, M as UpdateBoilerplateContentResponse, ag as UpdateChannelOptions, af as UpdateChannelPayload, ah as UpdateChannelResponse, at as UpdateCompositionSectionOptions, as as UpdateCompositionSectionPayload, au as UpdateCompositionSectionResponse, aI as UpdateContactOptions, aH as UpdateContactPayload, aJ as UpdateContactResponse, b0 as UpdateConversationOptions, a$ as UpdateConversationPayload, b1 as UpdateConversationResponse, bi as UpdateLabelOptions, bh as UpdateLabelPayload, bj as UpdateLabelResponse, b_ as UpdateNoteOptions, bZ as UpdateNotePayload, b$ as UpdateNoteResponse, cf as UploadID, cg as WebhookResponse, C as default } from './Client-DGn8aBic.js';
|
|
1
|
+
export { A as Account, i as AccountAccessToken, j as AccountAccessTokenID, s as AccountConversationSettings, b as AccountID, y as Action, z as ActionID, Z as BoilerplateCategory, _ as BoilerplateCategoryID, F as BoilerplateContent, H as BoilerplateContentID, aa as Channel, ab as ChannelID, C as Client, ar as CompositionSection, as as CompositionSectionID, aF as Contact, aG as ContactID, aV as Conversation, aW as ConversationID, l as CreateAccountAccessTokenOptions, k as CreateAccountAccessTokenPayload, m as CreateAccountAccessTokenResponse, d as CreateAccountOptions, c as CreateAccountPayload, e as CreateAccountResponse, a0 as CreateBoilerplateCategoryOptions, $ as CreateBoilerplateCategoryPayload, a1 as CreateBoilerplateCategoryResponse, J as CreateBoilerplateContentOptions, I as CreateBoilerplateContentPayload, K as CreateBoilerplateContentResponse, ad as CreateChannelOptions, ac as CreateChannelPayload, ae as CreateChannelResponse, au as CreateCompositionSectionOptions, at as CreateCompositionSectionPayload, av as CreateCompositionSectionResponse, c1 as CreateContactNoteOptions, c0 as CreateContactNotePayload, c2 as CreateContactNoteResponse, co as CreateContactNotificationSubscriptionOptions, cn as CreateContactNotificationSubscriptionPayload, cp as CreateContactNotificationSubscriptionResponse, aI as CreateContactOptions, aH as CreateContactPayload, aJ as CreateContactResponse, c4 as CreateConversationNoteOptions, c3 as CreateConversationNotePayload, c5 as CreateConversationNoteResponse, aY as CreateConversationOptions, aX as CreateConversationPayload, aZ as CreateConversationResponse, bR as CreateCorrectionModelOptions, bQ as CreateCorrectionModelPayload, bS as CreateCorrectionResponse, bg as CreateLabelOptions, bf as CreateLabelPayload, bh as CreateLabelResponse, bz as CreateMessageOptions, by as CreateMessagePayload, bA as CreateMessageResponse, bU as CreateResponseModelOptions, bT as CreateResponseModelPayload, bV as CreateResponseResponse, cs as CreateUploadOptions, ct as CreateUploadResponse, n as DeleteAccountAccessTokenOptions, D as DeleteAccountAccessTokenPayload, o as DeleteAccountAccessTokenResponse, a_ as DeleteConversationOptions, a$ as DeleteConversationResponse, bi as DeleteLabelOptions, bj as DeleteLabelResponse, bB as DeleteMessageOptions, bC as DeleteMessageResponse, cu as DeleteUploadOptions, cv as DeleteUploadResponse, b6 as FilterOptions, p as GetAccountAccessTokenOptions, q as GetAccountAccessTokenResponse, t as GetAccountConversationSettingsOptions, u as GetAccountConversationSettingsResponse, G as GetAccountOptions, f as GetAccountResponse, a2 as GetBoilerplateCategoryOptions, a3 as GetBoilerplateCategoryResponse, M as GetBoilerplateContentOptions, N as GetBoilerplateContentResponse, af as GetChannelOptions, ag as GetChannelResponse, aw as GetCompositionSectionOptions, ax as GetCompositionSectionResponse, aK as GetContactIncludeOptions, aL as GetContactOptions, aM as GetContactResponse, aN as GetContactVCFOptions, b0 as GetConversationIncludeOptions, b1 as GetConversationOptions, b2 as GetConversationResponse, bk as GetLabelOptions, bl as GetLabelResponse, bW as GetModelOptions, bX as GetModelResponse, c6 as GetNoteOptions, c7 as GetNoteResponse, cA as GetNotificationWellKnownResponse, ch as GetSourceOptions, ci as GetSourceResponse, cw as GetUploadOptions, cx as GetUploadResponse, be as Label, bm as LabelID, L as ListAccountAccessTokensOptions, r as ListAccountAccessTokensResponse, B as ListActionsOptions, E as ListActionsResponse, a4 as ListBoilerplateCategoriesIncludeOptions, a5 as ListBoilerplateCategoriesOptions, a6 as ListBoilerplateCategoriesResponse, P as ListBoilerplateCategoryBoilerplateContentsOptions, Q as ListBoilerplateCategoryBoilerplateContentsResponse, T as ListBoilerplateContentsOptions, V as ListBoilerplateContentsResponse, ay as ListChannelCompositionSectionsOptions, az as ListChannelCompositionSectionsResponse, bD as ListChannelMessagesIncludeOptions, bE as ListChannelMessagesOptions, bF as ListChannelMessagesResponse, ah as ListChannelsOptions, ai as ListChannelsResponse, aA as ListCompositionSectionsOptions, aB as ListCompositionSectionsResponse, b3 as ListContactConversationsOptions, b4 as ListContactConversationsResponse, bn as ListContactLabelsOptions, bo as ListContactLabelsResponse, c8 as ListContactNotesOptions, c9 as ListContactNotesResponse, aO as ListContactsOptions, aP as ListContactsResponse, bp as ListConversationLabelsOptions, bq as ListConversationLabelsResponse, bG as ListConversationMessagesIncludeOptions, bH as ListConversationMessagesOptions, bI as ListConversationMessagesResponse, ca as ListConversationNotesOptions, cb as ListConversationNotesResponse, b7 as ListConversationOptions, b5 as ListConversationsIncludeOptions, b8 as ListConversationsResponse, aQ as ListLabelContactsOptions, aR as ListLabelContactsResponse, b9 as ListLabelConversationsOptions, ba as ListLabelConversationsResponse, br as ListLabelsIncludeOptions, bs as ListLabelsOptions, bt as ListLabelsResponse, bJ as ListMessagesIncludeOptions, bK as ListMessagesOptions, bL as ListMessagesResponse, bY as ListModelsOptions, bZ as ListModelsResponse, cj as ListSourcesOptions, ck as ListSourcesResponse, bx as Message, bM as MessageID, bN as MessageRole, bO as MessageStatus, aj as MetaWhatsappChannelGetBusinessProfileOptions, ak as MetaWhatsappChannelGetBusinessProfileResponse, bP as Model, b_ as ModelID, b$ as Note, cc as NoteID, cm as NotificationSubscription, cq as NotificationSubscriptionID, O as Options, R as RequestFilterable, S as SortOptions, cg as Source, cl as SourceID, a as TransportOptions, al as TwilioSendChannelSyncPayload, am as TwilioSendgridChannelSyncOptions, an as TwilioSendgridChannelSyncResponse, w as UpdateAccountConversationSettingsOptions, v as UpdateAccountConversationSettingsPayload, x as UpdateAccountConversationSettingsResponse, g as UpdateAccountOptions, U as UpdateAccountPayload, h as UpdateAccountResponse, a8 as UpdateBoilerplateCategoryOptions, a7 as UpdateBoilerplateCategoryPayload, a9 as UpdateBoilerplateCategoryResponse, X as UpdateBoilerplateContentOptions, W as UpdateBoilerplateContentPayload, Y as UpdateBoilerplateContentResponse, ap as UpdateChannelOptions, ao as UpdateChannelPayload, aq as UpdateChannelResponse, aD as UpdateCompositionSectionOptions, aC as UpdateCompositionSectionPayload, aE as UpdateCompositionSectionResponse, aT as UpdateContactOptions, aS as UpdateContactPayload, aU as UpdateContactResponse, bc as UpdateConversationOptions, bb as UpdateConversationPayload, bd as UpdateConversationResponse, bv as UpdateLabelOptions, bu as UpdateLabelPayload, bw as UpdateLabelResponse, ce as UpdateNoteOptions, cd as UpdateNotePayload, cf as UpdateNoteResponse, cr as Upload, cy as UploadID, cz as WebhookResponse, C as default } from './Client-DKNuv_mB.js';
|
|
3
2
|
import 'ky';
|
|
4
3
|
import 'zod';
|
|
5
4
|
|
|
@@ -137,62 +136,4 @@ declare namespace index {
|
|
|
137
136
|
export { index_AuthError as AuthError, index_AuthenticationError as AuthenticationError, index_AuthorizationError as AuthorizationError, index_LogicError as LogicError, index_NetworkError as NetworkError, index_SupportError as SupportError, index_ValidationError as ValidationError };
|
|
138
137
|
}
|
|
139
138
|
|
|
140
|
-
|
|
141
|
-
* Great Detail Support System.
|
|
142
|
-
*
|
|
143
|
-
* @copyright 2024 Great Detail Ltd
|
|
144
|
-
* @author Great Detail Ltd <info@greatdetail.com>
|
|
145
|
-
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
146
|
-
* @see https://greatdetail.com
|
|
147
|
-
*/
|
|
148
|
-
|
|
149
|
-
type AccountConversationSettings = {
|
|
150
|
-
account: AccountID;
|
|
151
|
-
defaultName?: Nullable<string>;
|
|
152
|
-
responseDuration?: Nullable<string>;
|
|
153
|
-
resolveDuration?: Nullable<string>;
|
|
154
|
-
} & ResponseTimestamp;
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Great Detail Support System.
|
|
158
|
-
*
|
|
159
|
-
* @copyright 2024 Great Detail Ltd
|
|
160
|
-
* @author Great Detail Ltd <info@greatdetail.com>
|
|
161
|
-
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
162
|
-
* @see https://greatdetail.com
|
|
163
|
-
*/
|
|
164
|
-
|
|
165
|
-
interface GetAccountConversationSettingsOptions {
|
|
166
|
-
request?: SendOptions;
|
|
167
|
-
}
|
|
168
|
-
type GetAccountConversationSettingsResponse = {
|
|
169
|
-
data: {
|
|
170
|
-
accountConversationSettings: AccountConversationSettings;
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Great Detail Support System.
|
|
176
|
-
*
|
|
177
|
-
* @copyright 2024 Great Detail Ltd
|
|
178
|
-
* @author Great Detail Ltd <info@greatdetail.com>
|
|
179
|
-
* @author Dom Webber <dom.webber@greatdetail.com>
|
|
180
|
-
* @see https://greatdetail.com
|
|
181
|
-
*/
|
|
182
|
-
|
|
183
|
-
type UpdateAccountConversationSettingsPayload = {
|
|
184
|
-
defaultName?: Nullable<string>;
|
|
185
|
-
responseDuration?: Nullable<string>;
|
|
186
|
-
resolveDuration?: Nullable<string>;
|
|
187
|
-
};
|
|
188
|
-
interface UpdateAccountConversationSettingsOptions {
|
|
189
|
-
body: UpdateAccountConversationSettingsPayload;
|
|
190
|
-
request?: SendOptions;
|
|
191
|
-
}
|
|
192
|
-
type UpdateAccountConversationSettingsResponse = {
|
|
193
|
-
data: {
|
|
194
|
-
accountConversationSettings: AccountConversationSettings;
|
|
195
|
-
};
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
export { AccountID, DEFAULT_SUPPORT_BASE_URL, index as Error, type GetAccountConversationSettingsOptions, type GetAccountConversationSettingsResponse, type UpdateAccountConversationSettingsOptions, type UpdateAccountConversationSettingsPayload, type UpdateAccountConversationSettingsResponse };
|
|
139
|
+
export { DEFAULT_SUPPORT_BASE_URL, index as Error };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s,c as
|
|
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-CBX4D3XB.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};
|
package/package.json
CHANGED
package/dist/chunk-R3BOF7IE.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var Y=Object.defineProperty;var X=(r,t)=>{for(var e in t)Y(r,e,{get:t[e],enumerable:!0})};var d=class{getHeaders(){return{}}};var j="SUPPORT_ACCESS_TOKEN",Q="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[Q],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[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 V="https://api.support.greatdetail.com",K={"X-Powered-By":"GDSupport/JavaScript"};import{z as s}from"zod";var C=class r{static SCHEMA=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")]),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()})})]))})});constructor(){}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}=r.SCHEMA.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}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 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 v=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??{})]})}getVCFURL(t,{vcf:e={}}){let o=e.variant??"vcard",n=e.format??(o==="vcard"?"vcf":"json"),i="v1/contacts/"+encodeURIComponent(t)+"/vcf?variant="+encodeURIComponent(o)+"&format="+encodeURIComponent(n);return this._transport.getURL(i)}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})}};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)]})}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 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 U=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}create(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 D=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"})}};import $ from"is-network-error";import z,{HTTPError as J}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 M=class{client;options;constructor({baseURL:t,...e}){this.options={...e,baseURL:t},this.client=z.create({prefixUrl:this.options.baseURL,timeout:12e3,hooks:{beforeRequest:[o=>{for(let n of this.options.requestFilterables){let i=n.getHeaders();for(let[l,W]of Object.entries(i))o.headers.has(l)||o.headers.set(l,W)}}]}})}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($(n))throw new B("A network error occurred",{cause:n});if(n instanceof J){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 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 F=class{constructor(t){this._transport=t}getNotifications({request:t={}}={}){return this._transport.send(".well-known/notifications",{...t,method:"GET"})}};var k=class r{static DEFAULT_BASE_URL=V;static PublicAuthentication=d;static BasicAuthentication=u;static BearerAuthentication=h;_transport;account;accountAccessToken;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.action=new O(this._transport),this.boilerplateCategory=new g(this._transport),this.boilerplateContent=new b(this._transport),this.channel=new _(this._transport),this.compositionSection=new v(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 y(this._transport),this.note=new U(this._transport),this.notificationSubscription=new S(this._transport),this.source=new E(this._transport),this.statistics=new D(this._transport),this.upload=new x(this._transport),this.webhook=new C,this.wellKnown=new F(this._transport)}static getBaseURL(){return process.env[H]??this.DEFAULT_BASE_URL}};export{X 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,k};
|