@verdocs/js-sdk 6.6.3 → 6.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -236,6 +236,17 @@ interface INotification {
236
236
  time: string;
237
237
  profile?: IProfile;
238
238
  }
239
+ interface INotificationTemplate {
240
+ id: string;
241
+ organization_id: string;
242
+ type: TNotificationType;
243
+ event_name: TEventName;
244
+ template_id?: string;
245
+ html_template?: string;
246
+ text_template?: string;
247
+ template?: ITemplate;
248
+ organization: IOrganization;
249
+ }
239
250
  //////////////////////////////////////// IAM //////////////////////////////
240
251
  interface IApiKey {
241
252
  client_id: string;
@@ -412,23 +423,7 @@ interface IUser {
412
423
  created_at: string;
413
424
  updated_at: string;
414
425
  }
415
- // TODO: Combine this with TWebhookEvent in
416
- interface IWebhookEvents {
417
- envelope_created: boolean;
418
- envelope_completed: boolean;
419
- envelope_updated: boolean;
420
- envelope_canceled: boolean;
421
- envelope_expired: boolean;
422
- template_created: boolean;
423
- template_updated: boolean;
424
- template_deleted: boolean;
425
- template_used: boolean;
426
- recipient_submitted: boolean;
427
- recipient_updated: boolean;
428
- recipient_delegated: boolean;
429
- kba_event: boolean;
430
- entitlement_used: boolean;
431
- }
426
+ type IWebhookEvents = Record<TWebhookEvent, boolean>;
432
427
  interface IWebhook {
433
428
  id: string;
434
429
  organization_id: string;
@@ -1031,7 +1026,7 @@ type TEventDetail = "in_app" | "mail" | "signer" | "sms" | "reminder" | "prepare
1031
1026
  // Modification events have a string description
1032
1027
  type TEnvelopeUpdateResult = Omit<IEnvelope, "histories" | "recipients" | "certificate" | "document" | "fields" | "profile">;
1033
1028
  type TFieldType = "signature" | "initial" | "checkbox" | "radio" | "textbox" | "timestamp" | "date" | "dropdown" | "textarea" | "attachment" | "payment";
1034
- type TWebhookEvent = "envelope_created" | "envelope_completed" | "envelope_canceled" | "envelope_updated" | "envelope_expired" | "template_created" | "template_updated" | "template_deleted" | "template_used" | "recipient_submitted" | "recipient_updated" | "recipient_delegated" | "kba_event" | "entitlement_used";
1029
+ type TWebhookEvent = "envelope_created" | "envelope_completed" | "envelope_canceled" | "envelope_updated" | "envelope_expired" | "template_created" | "template_updated" | "template_deleted" | "template_used" | "recipient_submitted" | "recipient_updated" | "recipient_delegated" | "kba_event" | "entitlement_used" | "recipient_invited" | "recipient_reminded" | "recipient_auth_fail" | "recipient_disclosure_accepted" | "recipient_docs_downloaded" | "recipient_invite_failed";
1035
1030
  declare const WEBHOOK_EVENTS: readonly [
1036
1031
  "envelope_created",
1037
1032
  "envelope_completed",
@@ -1046,7 +1041,13 @@ declare const WEBHOOK_EVENTS: readonly [
1046
1041
  "recipient_updated",
1047
1042
  "recipient_delegated",
1048
1043
  "kba_event",
1049
- "entitlement_used"
1044
+ "entitlement_used",
1045
+ "recipient_invited",
1046
+ "recipient_reminded",
1047
+ "recipient_auth_fail",
1048
+ "recipient_disclosure_accepted",
1049
+ "recipient_docs_downloaded",
1050
+ "recipient_invite_failed"
1050
1051
  ];
1051
1052
  type TTemplateVisibility = "private" | "shared" | "public";
1052
1053
  type TEntitlement = "envelope" | "kba_auth" | "passcode_auth" | "sms_auth" | "kba_id_auth" | "id_auth" | "custom_disclaimer";
@@ -1064,6 +1065,8 @@ type TUsageType = "envelope" | "envelope_canceled" | "envelope_completed" | "env
1064
1065
  * Methods for authenticating webhook requests.
1065
1066
  */
1066
1067
  type TWebhookAuthMethod = "none" | "hmac" | "client_credentials";
1068
+ type TNotificationType = "sms" | "email" | "app";
1069
+ type TEventName = "invitation:canceled" | "transaction:completed" | "envelope:failed" | "envelope:expired" | "envelope:declined" | "envelope:cc" | "recipient:reminder" | "transaction:requested" | "envelope:delegated" | "envelope:completed" | "transaction:canceled" | "user:invited" | "recipient:invited" | "envelope:canceled" | "transaction:sent" | "envelope:signed" | "email:verify" | "email:otp" | "password:reset" | "recipient:question";
1067
1070
  declare const FIELD_TYPES: TFieldType[];
1068
1071
  declare const DEFAULT_FIELD_WIDTHS: Record<TFieldType, number>;
1069
1072
  declare const DEFAULT_FIELD_HEIGHTS: Record<TFieldType, number>;
@@ -2327,6 +2330,17 @@ interface ISetWebhookRequest {
2327
2330
  auth_method: TWebhookAuthMethod;
2328
2331
  events: Record<TWebhookEvent, boolean>;
2329
2332
  }
2333
+ interface ICreateNotificationTemplateRequest {
2334
+ type: TNotificationType;
2335
+ event_name: TEventName;
2336
+ template_id?: string;
2337
+ html_template?: string;
2338
+ text_template?: string;
2339
+ }
2340
+ interface IUpdateNotificationTemplateRequest {
2341
+ html_template?: string;
2342
+ text_template?: string;
2343
+ }
2330
2344
  /**
2331
2345
  * Get a list of keys for a given organization. The caller must have admin access to the organization.
2332
2346
  *
@@ -3003,6 +3017,93 @@ declare const deleteOrganizationMember: (endpoint: VerdocsEndpoint, profileId: s
3003
3017
  * @apiSuccess IProfile . The updated profile for the member.
3004
3018
  */
3005
3019
  declare const updateOrganizationMember: (endpoint: VerdocsEndpoint, profileId: string, params: Partial<Pick<IProfile, "roles" | "first_name" | "last_name">>) => Promise<IProfile>;
3020
+ /**
3021
+ * Get all notification templates for the caller's organization.
3022
+ *
3023
+ * ```typescript
3024
+ * import {getNotificationTemplates} from '@verdocs/js-sdk';
3025
+ *
3026
+ * const templates = await getNotificationTemplates();
3027
+ * ```
3028
+ *
3029
+ * @group Notifications
3030
+ * @api GET /v2/notifications/templates Get notification templates
3031
+ * @apiSuccess array(items: INotificationTemplate) . A list of notification templates for the caller's organization.
3032
+ */
3033
+ declare const getNotificationTemplates: (endpoint: VerdocsEndpoint) => Promise<INotificationTemplate[]>;
3034
+ /**
3035
+ * Get a single notification template by ID.
3036
+ *
3037
+ * ```typescript
3038
+ * import {getNotificationTemplate} from '@verdocs/js-sdk';
3039
+ *
3040
+ * const template = await getNotificationTemplate(TEMPLATEID);
3041
+ * ```
3042
+ *
3043
+ * @group Notifications
3044
+ * @api GET /v2/notifications/templates/:id Get notification template
3045
+ * @apiParam string(format:uuid) id The notification template ID
3046
+ * @apiSuccess INotificationTemplate . The requested notification template.
3047
+ */
3048
+ declare const getNotificationTemplate: (endpoint: VerdocsEndpoint, id: string) => Promise<INotificationTemplate>;
3049
+ /**
3050
+ * Create a notification template. Only one template may exist per combination of type and
3051
+ * event_name. At least one of `html_template` or `text_template` must be provided.
3052
+ *
3053
+ * ```typescript
3054
+ * import {createNotificationTemplate} from '@verdocs/js-sdk';
3055
+ *
3056
+ * const template = await createNotificationTemplate({
3057
+ * type: 'email',
3058
+ * event_name: 'recipient:invited',
3059
+ * html_template: '<p>You have been invited to sign a document.</p>',
3060
+ * });
3061
+ * ```
3062
+ *
3063
+ * @group Notifications
3064
+ * @api POST /v2/notifications/templates Create notification template
3065
+ * @apiBody string(enum:'sms'|'email'|'app') type The notification channel type.
3066
+ * @apiBody string event_name The event that triggers this notification.
3067
+ * @apiBody string template_id? Optional reference to an associated template.
3068
+ * @apiBody string html_template? The HTML content for the notification. At least one of html_template or text_template is required.
3069
+ * @apiBody string text_template? The plain-text content for the notification. At least one of html_template or text_template is required.
3070
+ * @apiSuccess INotificationTemplate . The newly-created notification template.
3071
+ */
3072
+ declare const createNotificationTemplate: (endpoint: VerdocsEndpoint, params: ICreateNotificationTemplateRequest) => Promise<INotificationTemplate>;
3073
+ /**
3074
+ * Update a notification template. At least one of `html_template` or `text_template` must be provided.
3075
+ *
3076
+ * ```typescript
3077
+ * import {updateNotificationTemplate} from '@verdocs/js-sdk';
3078
+ *
3079
+ * const updated = await updateNotificationTemplate(TEMPLATEID, {
3080
+ * html_template: '<p>Updated content.</p>',
3081
+ * });
3082
+ * ```
3083
+ *
3084
+ * @group Notifications
3085
+ * @api PATCH /v2/notifications/templates/:id Update notification template
3086
+ * @apiParam string(format:uuid) id The notification template ID
3087
+ * @apiBody string html_template? The HTML content for the notification. At least one of html_template or text_template is required.
3088
+ * @apiBody string text_template? The plain-text content for the notification. At least one of html_template or text_template is required.
3089
+ * @apiSuccess INotificationTemplate . The updated notification template.
3090
+ */
3091
+ declare const updateNotificationTemplate: (endpoint: VerdocsEndpoint, id: string, params: IUpdateNotificationTemplateRequest) => Promise<INotificationTemplate>;
3092
+ /**
3093
+ * Delete a notification template.
3094
+ *
3095
+ * ```typescript
3096
+ * import {deleteNotificationTemplate} from '@verdocs/js-sdk';
3097
+ *
3098
+ * await deleteNotificationTemplate(TEMPLATEID);
3099
+ * ```
3100
+ *
3101
+ * @group Notification Templates
3102
+ * @api DELETE /v2/notifications/templates/:id Delete notification template
3103
+ * @apiParam string(format:uuid) id The notification template ID
3104
+ * @apiSuccess string . Success.
3105
+ */
3106
+ declare const deleteNotificationTemplate: (endpoint: VerdocsEndpoint, id: string) => Promise<any>;
3006
3107
  /**
3007
3108
  * Get an organization by ID. Note that this endpoint will return only a subset of fields
3008
3109
  * if the caller is not a member of the organization (the public fields).
@@ -3740,9 +3841,9 @@ declare const deleteTemplateDocument: (endpoint: VerdocsEndpoint, documentId: st
3740
3841
  * this will return only the **metadata** the caller is allowed to view.
3741
3842
  *
3742
3843
  * @group Template Documents
3743
- * @api GET /v2/envelope-documents/:id Get envelope document
3844
+ * @api GET /v2/template-documents/:id Get envelope document
3744
3845
  * @apiParam string(format: 'uuid') document_id The ID of the document to retrieve.
3745
- * @apiSuccess IEnvelopeDocument . The detailed metadata for the document requested
3846
+ * @apiSuccess ITemplateDocument . The detailed metadata for the document requested
3746
3847
  */
3747
3848
  declare const getTemplateDocument: (endpoint: VerdocsEndpoint, documentId: string) => Promise<ITemplateDocument>;
3748
3849
  /**
@@ -3932,4 +4033,4 @@ declare const decodeJWTBody: (token: string) => any;
3932
4033
  * the presence of the `document_id` field, which will only be present for signing sessions.
3933
4034
  */
3934
4035
  declare const decodeAccessTokenBody: (token: string) => TSession;
3935
- export { TRequestStatus, TTemplateSender, TTemplateAction, TRecipientAction, TEnvelopeStatus, TRecipientStatus, TRecipientType, TSortTemplateBy, TAccessKeyType, TApiKeyPermission, TDeprecatedHistoryEvent, THistoryEvent, TEventDetail, TEnvelopeUpdateResult, TFieldType, TWebhookEvent, WEBHOOK_EVENTS, TTemplateVisibility, TEntitlement, TRecipientAuthMethod, TRecipientAuthStep, TUsageType, TWebhookAuthMethod, FIELD_TYPES, DEFAULT_FIELD_WIDTHS, DEFAULT_FIELD_HEIGHTS, ALL_PERMISSIONS, IChannel, IDisabledChannel, INotification, IApiKey, IGroup, IGroupProfile, IOAuth2App, IEntitlement, IOrganization, IOrganizationInvitation, IPendingWebhook, IProfile, IUser, IWebhookEvents, IWebhook, IInPersonAccessKey, IInAppAccessKey, IEmailAccessKey, ISMSAccessKey, TAccessKey, IEnvelope, IEnvelopeDocument, IDropdownOption, IEnvelopeField, IEnvelopeFieldOptions, IEnvelopeFieldSettings, IEnvelopeHistory, IInitial, IKbaPINRequired, IKBAQuestion, IRecipient, IRole, ISignature, ITemplate, ITemplateDocument, ITemplateField, ITextFieldSetting, ITemplateFieldSetting, TOrganizationUsage, TEnvironment, TSessionChangedListener, VerdocsEndpointOptions, VerdocsEndpoint, createEnvelope, getEnvelope, getEnvelopeDocument, downloadEnvelopeDocument, getEnvelopeDocumentDownloadLink, getEnvelopeDocumentPreviewLink, cancelEnvelope, getEnvelopeFile, updateEnvelope, updateEnvelopeField, uploadEnvelopeFieldAttachment, deleteEnvelopeFieldAttachment, getEnvelopeDocumentPageDisplayUri, ITimeRange, IListEnvelopesParams, getEnvelopes, getEnvelopesZip, sortFields, sortDocuments, sortRecipients, isFieldFilled, isFieldValid, createInitials, IRecipientKbaStepNone, IRecipientKbaStepComplete, IRecipientKbaStepPin, IRecipientKbaStepIdentity, IRecipientKbaStepChallenge, IRecipientKbaStepFailed, TRecipientKbaStep, getKbaStep, submitKbaPin, IKbaIdentity, submitKbaIdentity, IKbaChallengeResponse, submitKbaChallengeResponse, envelopeRecipientAgree, envelopeRecipientDecline, envelopeRecipientSubmit, startSigningSession, getInPersonLink, verifySigner, delegateRecipient, updateRecipient, remindRecipient, resetRecipient, askQuestion, isEnvelopeOwner, isEnvelopeRecipient, canAccessEnvelope, userIsEnvelopeOwner, userIsEnvelopeRecipient, useCanAccessEnvelope, envelopeIsActive, envelopeIsComplete, userCanCancelEnvelope, userCanFinishEnvelope, recipientHasAction, getRecipientsWithActions, recipientCanAct, userCanAct, userCanSignNow, getNextRecipient, createSignature, IEnvelopesSearchResult, IDocumentSearchOptions, ICreateEnvelopeRecipientFromTemplate, ICreateEnvelopeRecipientDirectly, ISignerTokenResponse, IInPersonLinkResponse, IUpdateRecipientStatus, ICreateEnvelopeReminderRequest, IUpdateRecipientParams, ICreateEnvelopeDocumentFromData, ICreateEnvelopeDocumentFromUri, ICreateEnvelopeDocumentFromFile, ICreateEnvelopeFieldFromTemplate, ICreateEnvelopeFieldDirectly, ICreateEnvelopeFromTemplateRequest, ICreateEnvelopeDirectlyRequest, TCreateEnvelopeRequest, IAuthenticateRecipientViaPasscodeRequest, IAuthenticateRecipientViaEmailRequest, IAuthenticateRecipientViaSMSRequest, IKBAResponse, IAuthenticateRecipientViaKBARequest, TAuthenticateRecipientRequest, DEFAULT_DISCLOSURES, getApiKeys, createApiKey, rotateApiKey, updateApiKey, deleteApiKey, getOrganizationContacts, deleteOrganizationContact, createOrganizationContact, updateOrganizationContact, getGroups, getGroup, createGroup, updateGroup, deleteGroup, addGroupMember, deleteGroupMember, getOrganizationInvitations, createOrganizationInvitation, deleteOrganizationInvitation, updateOrganizationInvitation, resendOrganizationInvitation, getOrganizationInvitation, acceptOrganizationInvitation, declineOrganizationInvitation, getOrganizationMembers, deleteOrganizationMember, updateOrganizationMember, getOrganization, getOrganizationChildren, getOrganizationUsage, createOrganization, updateOrganization, deleteOrganization, updateOrganizationLogo, updateOrganizationThumbnail, getEntitlements, getActiveEntitlements, ICreateApiKeyRequest, IUpdateApiKeyRequest, ICreateInvitationRequest, IAcceptOrganizationInvitationRequest, ISetWebhookRequest, getWebhooks, setWebhooks, rotateWebhookSecret, TTemplatePermissionCreatePublic, TTemplatePermissionCreateOrg, TTemplatePermissionCreatePersonal, TTemplatePermissionDelete, TTemplatePermissionVisibility, TTemplateMemberRead, TTemplateMemberWrite, TTemplateMemberDelete, TTemplateMemberVisibility, TTemplatePermission, TAccountPermissionOwnerAdd, TAccountPermissionOwnerRemove, TAccountPermissionAdminAdd, TAccountPermissionAdminRemove, TAccountPermissionMemberView, TAccountPermissionMemberAdd, TAccountPermissionMemberRemove, TAccountPermission, TOrgPermissionCreate, TOrgPermissionView, TOrgPermissionUpdate, TOrgPermissionDelete, TOrgPermissionTransfer, TOrgPermissionList, TOrgPermission, TEnvelopePermissionCreate, TEnvelopePermissionCancel, TEnvelopePermissionView, TEnvelopePermissionOrg, TEnvelopePermission, TPermission, TRole, RolePermissions, userHasPermissions, ISigningSession, IUserSession, IIdToken, TSessionType, TSession, TActiveSession, canPerformTemplateAction, hasRequiredPermissions, createField, updateField, deleteField, userIsTemplateCreator, userHasSharedTemplate, userCanCreatePersonalTemplate, userCanCreateOrgTemplate, userCanCreatePublicTemplate, userCanReadTemplate, userCanUpdateTemplate, userCanMakeTemplatePrivate, userCanMakeTemplateShared, userCanMakeTemplatePublic, userCanChangeOrgVisibility, userCanDeleteTemplate, userCanSendTemplate, userCanCreateTemplate, userCanBuildTemplate, getFieldsForRole, userCanPreviewTemplate, createTemplateRole, updateTemplateRole, deleteTemplateRole, ITemplateSortBy, TTemplateVisibilityFilter, IGetTemplatesParams, getTemplates, getTemplate, IDocumentFromUri, IDocumentFromData, ITemplateCreateParams, createTemplate, duplicateTemplate, ITemplateCreateFromSharepointParams, createTemplateFromSharepoint, updateTemplate, deleteTemplate, toggleTemplateStar, createTemplateDocument, deleteTemplateDocument, getTemplateDocument, downloadTemplateDocument, getTemplateDocumentDownloadLink, getTemplateDocumentPreviewLink, getTemplateDocumentFile, getTemplateDocumentThumbnail, getTemplateDocumentPageDisplayUri, ITemplateTag, ITag, IStar, ITemplateSearchResult, IValidator, isValidInput, getValidators, isValidEmail, isValidPhone, isValidRoleName, isValidTag, IROPCRequest, IClientCredentialsRequest, IRefreshTokenRequest, TAuthenticationRequest, authenticate, refreshToken, changePassword, resetPassword, resendVerification, verifyEmail, getMyUser, getNotifications, getProfiles, getCurrentProfile, switchProfile, updateProfile, deleteProfile, createProfile, updateProfilePhoto, ICreateProfileRequest, IUpdateProfileRequest, IAuthenticateResponse, IChangePasswordRequest, IChangePasswordResponse, IResetPasswordRequest, IResetPasswordResponse, IVerifyEmailRequest, getRGB, getRGBA, nameToRGBA, getRoleColor, formatShortTimeAgo, collapseEntitlements, getRTop, getRLeft, getRValue, blobToBase64, rescale, fileToDataUrl, downloadBlob, Countries, getCountryByCode, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, getPlusOneCountry, isCanada, isAmericanSamoa, isDominicanRepublic, isPuertoRico, getMatchingCountry, integerSequence, formatFullName, formatInitials, fullNameToInitials, capitalize, convertToE164, randomString, AtoB, decodeJWTBody, decodeAccessTokenBody, IFileWithData, ICountry };
4036
+ export { TRequestStatus, TTemplateSender, TTemplateAction, TRecipientAction, TEnvelopeStatus, TRecipientStatus, TRecipientType, TSortTemplateBy, TAccessKeyType, TApiKeyPermission, TDeprecatedHistoryEvent, THistoryEvent, TEventDetail, TEnvelopeUpdateResult, TFieldType, TWebhookEvent, WEBHOOK_EVENTS, TTemplateVisibility, TEntitlement, TRecipientAuthMethod, TRecipientAuthStep, TUsageType, TWebhookAuthMethod, TNotificationType, TEventName, FIELD_TYPES, DEFAULT_FIELD_WIDTHS, DEFAULT_FIELD_HEIGHTS, ALL_PERMISSIONS, IChannel, IDisabledChannel, INotification, INotificationTemplate, IApiKey, IGroup, IGroupProfile, IOAuth2App, IEntitlement, IOrganization, IOrganizationInvitation, IPendingWebhook, IProfile, IUser, IWebhookEvents, IWebhook, IInPersonAccessKey, IInAppAccessKey, IEmailAccessKey, ISMSAccessKey, TAccessKey, IEnvelope, IEnvelopeDocument, IDropdownOption, IEnvelopeField, IEnvelopeFieldOptions, IEnvelopeFieldSettings, IEnvelopeHistory, IInitial, IKbaPINRequired, IKBAQuestion, IRecipient, IRole, ISignature, ITemplate, ITemplateDocument, ITemplateField, ITextFieldSetting, ITemplateFieldSetting, TOrganizationUsage, TEnvironment, TSessionChangedListener, VerdocsEndpointOptions, VerdocsEndpoint, createEnvelope, getEnvelope, getEnvelopeDocument, downloadEnvelopeDocument, getEnvelopeDocumentDownloadLink, getEnvelopeDocumentPreviewLink, cancelEnvelope, getEnvelopeFile, updateEnvelope, updateEnvelopeField, uploadEnvelopeFieldAttachment, deleteEnvelopeFieldAttachment, getEnvelopeDocumentPageDisplayUri, ITimeRange, IListEnvelopesParams, getEnvelopes, getEnvelopesZip, sortFields, sortDocuments, sortRecipients, isFieldFilled, isFieldValid, createInitials, IRecipientKbaStepNone, IRecipientKbaStepComplete, IRecipientKbaStepPin, IRecipientKbaStepIdentity, IRecipientKbaStepChallenge, IRecipientKbaStepFailed, TRecipientKbaStep, getKbaStep, submitKbaPin, IKbaIdentity, submitKbaIdentity, IKbaChallengeResponse, submitKbaChallengeResponse, envelopeRecipientAgree, envelopeRecipientDecline, envelopeRecipientSubmit, startSigningSession, getInPersonLink, verifySigner, delegateRecipient, updateRecipient, remindRecipient, resetRecipient, askQuestion, isEnvelopeOwner, isEnvelopeRecipient, canAccessEnvelope, userIsEnvelopeOwner, userIsEnvelopeRecipient, useCanAccessEnvelope, envelopeIsActive, envelopeIsComplete, userCanCancelEnvelope, userCanFinishEnvelope, recipientHasAction, getRecipientsWithActions, recipientCanAct, userCanAct, userCanSignNow, getNextRecipient, createSignature, IEnvelopesSearchResult, IDocumentSearchOptions, ICreateEnvelopeRecipientFromTemplate, ICreateEnvelopeRecipientDirectly, ISignerTokenResponse, IInPersonLinkResponse, IUpdateRecipientStatus, ICreateEnvelopeReminderRequest, IUpdateRecipientParams, ICreateEnvelopeDocumentFromData, ICreateEnvelopeDocumentFromUri, ICreateEnvelopeDocumentFromFile, ICreateEnvelopeFieldFromTemplate, ICreateEnvelopeFieldDirectly, ICreateEnvelopeFromTemplateRequest, ICreateEnvelopeDirectlyRequest, TCreateEnvelopeRequest, IAuthenticateRecipientViaPasscodeRequest, IAuthenticateRecipientViaEmailRequest, IAuthenticateRecipientViaSMSRequest, IKBAResponse, IAuthenticateRecipientViaKBARequest, TAuthenticateRecipientRequest, DEFAULT_DISCLOSURES, getApiKeys, createApiKey, rotateApiKey, updateApiKey, deleteApiKey, getOrganizationContacts, deleteOrganizationContact, createOrganizationContact, updateOrganizationContact, getGroups, getGroup, createGroup, updateGroup, deleteGroup, addGroupMember, deleteGroupMember, getOrganizationInvitations, createOrganizationInvitation, deleteOrganizationInvitation, updateOrganizationInvitation, resendOrganizationInvitation, getOrganizationInvitation, acceptOrganizationInvitation, declineOrganizationInvitation, getOrganizationMembers, deleteOrganizationMember, updateOrganizationMember, getNotificationTemplates, getNotificationTemplate, createNotificationTemplate, updateNotificationTemplate, deleteNotificationTemplate, getOrganization, getOrganizationChildren, getOrganizationUsage, createOrganization, updateOrganization, deleteOrganization, updateOrganizationLogo, updateOrganizationThumbnail, getEntitlements, getActiveEntitlements, ICreateApiKeyRequest, IUpdateApiKeyRequest, ICreateInvitationRequest, IAcceptOrganizationInvitationRequest, ISetWebhookRequest, ICreateNotificationTemplateRequest, IUpdateNotificationTemplateRequest, getWebhooks, setWebhooks, rotateWebhookSecret, TTemplatePermissionCreatePublic, TTemplatePermissionCreateOrg, TTemplatePermissionCreatePersonal, TTemplatePermissionDelete, TTemplatePermissionVisibility, TTemplateMemberRead, TTemplateMemberWrite, TTemplateMemberDelete, TTemplateMemberVisibility, TTemplatePermission, TAccountPermissionOwnerAdd, TAccountPermissionOwnerRemove, TAccountPermissionAdminAdd, TAccountPermissionAdminRemove, TAccountPermissionMemberView, TAccountPermissionMemberAdd, TAccountPermissionMemberRemove, TAccountPermission, TOrgPermissionCreate, TOrgPermissionView, TOrgPermissionUpdate, TOrgPermissionDelete, TOrgPermissionTransfer, TOrgPermissionList, TOrgPermission, TEnvelopePermissionCreate, TEnvelopePermissionCancel, TEnvelopePermissionView, TEnvelopePermissionOrg, TEnvelopePermission, TPermission, TRole, RolePermissions, userHasPermissions, ISigningSession, IUserSession, IIdToken, TSessionType, TSession, TActiveSession, canPerformTemplateAction, hasRequiredPermissions, createField, updateField, deleteField, userIsTemplateCreator, userHasSharedTemplate, userCanCreatePersonalTemplate, userCanCreateOrgTemplate, userCanCreatePublicTemplate, userCanReadTemplate, userCanUpdateTemplate, userCanMakeTemplatePrivate, userCanMakeTemplateShared, userCanMakeTemplatePublic, userCanChangeOrgVisibility, userCanDeleteTemplate, userCanSendTemplate, userCanCreateTemplate, userCanBuildTemplate, getFieldsForRole, userCanPreviewTemplate, createTemplateRole, updateTemplateRole, deleteTemplateRole, ITemplateSortBy, TTemplateVisibilityFilter, IGetTemplatesParams, getTemplates, getTemplate, IDocumentFromUri, IDocumentFromData, ITemplateCreateParams, createTemplate, duplicateTemplate, ITemplateCreateFromSharepointParams, createTemplateFromSharepoint, updateTemplate, deleteTemplate, toggleTemplateStar, createTemplateDocument, deleteTemplateDocument, getTemplateDocument, downloadTemplateDocument, getTemplateDocumentDownloadLink, getTemplateDocumentPreviewLink, getTemplateDocumentFile, getTemplateDocumentThumbnail, getTemplateDocumentPageDisplayUri, ITemplateTag, ITag, IStar, ITemplateSearchResult, IValidator, isValidInput, getValidators, isValidEmail, isValidPhone, isValidRoleName, isValidTag, IROPCRequest, IClientCredentialsRequest, IRefreshTokenRequest, TAuthenticationRequest, authenticate, refreshToken, changePassword, resetPassword, resendVerification, verifyEmail, getMyUser, getNotifications, getProfiles, getCurrentProfile, switchProfile, updateProfile, deleteProfile, createProfile, updateProfilePhoto, ICreateProfileRequest, IUpdateProfileRequest, IAuthenticateResponse, IChangePasswordRequest, IChangePasswordResponse, IResetPasswordRequest, IResetPasswordResponse, IVerifyEmailRequest, getRGB, getRGBA, nameToRGBA, getRoleColor, formatShortTimeAgo, collapseEntitlements, getRTop, getRLeft, getRValue, blobToBase64, rescale, fileToDataUrl, downloadBlob, Countries, getCountryByCode, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, getPlusOneCountry, isCanada, isAmericanSamoa, isDominicanRepublic, isPuertoRico, getMatchingCountry, integerSequence, formatFullName, formatInitials, fullNameToInitials, capitalize, convertToE164, randomString, AtoB, decodeJWTBody, decodeAccessTokenBody, IFileWithData, ICountry };
package/dist/index.d.ts CHANGED
@@ -236,6 +236,17 @@ interface INotification {
236
236
  time: string;
237
237
  profile?: IProfile;
238
238
  }
239
+ interface INotificationTemplate {
240
+ id: string;
241
+ organization_id: string;
242
+ type: TNotificationType;
243
+ event_name: TEventName;
244
+ template_id?: string;
245
+ html_template?: string;
246
+ text_template?: string;
247
+ template?: ITemplate;
248
+ organization: IOrganization;
249
+ }
239
250
  //////////////////////////////////////// IAM //////////////////////////////
240
251
  interface IApiKey {
241
252
  client_id: string;
@@ -412,23 +423,7 @@ interface IUser {
412
423
  created_at: string;
413
424
  updated_at: string;
414
425
  }
415
- // TODO: Combine this with TWebhookEvent in
416
- interface IWebhookEvents {
417
- envelope_created: boolean;
418
- envelope_completed: boolean;
419
- envelope_updated: boolean;
420
- envelope_canceled: boolean;
421
- envelope_expired: boolean;
422
- template_created: boolean;
423
- template_updated: boolean;
424
- template_deleted: boolean;
425
- template_used: boolean;
426
- recipient_submitted: boolean;
427
- recipient_updated: boolean;
428
- recipient_delegated: boolean;
429
- kba_event: boolean;
430
- entitlement_used: boolean;
431
- }
426
+ type IWebhookEvents = Record<TWebhookEvent, boolean>;
432
427
  interface IWebhook {
433
428
  id: string;
434
429
  organization_id: string;
@@ -1031,7 +1026,7 @@ type TEventDetail = "in_app" | "mail" | "signer" | "sms" | "reminder" | "prepare
1031
1026
  // Modification events have a string description
1032
1027
  type TEnvelopeUpdateResult = Omit<IEnvelope, "histories" | "recipients" | "certificate" | "document" | "fields" | "profile">;
1033
1028
  type TFieldType = "signature" | "initial" | "checkbox" | "radio" | "textbox" | "timestamp" | "date" | "dropdown" | "textarea" | "attachment" | "payment";
1034
- type TWebhookEvent = "envelope_created" | "envelope_completed" | "envelope_canceled" | "envelope_updated" | "envelope_expired" | "template_created" | "template_updated" | "template_deleted" | "template_used" | "recipient_submitted" | "recipient_updated" | "recipient_delegated" | "kba_event" | "entitlement_used";
1029
+ type TWebhookEvent = "envelope_created" | "envelope_completed" | "envelope_canceled" | "envelope_updated" | "envelope_expired" | "template_created" | "template_updated" | "template_deleted" | "template_used" | "recipient_submitted" | "recipient_updated" | "recipient_delegated" | "kba_event" | "entitlement_used" | "recipient_invited" | "recipient_reminded" | "recipient_auth_fail" | "recipient_disclosure_accepted" | "recipient_docs_downloaded" | "recipient_invite_failed";
1035
1030
  declare const WEBHOOK_EVENTS: readonly [
1036
1031
  "envelope_created",
1037
1032
  "envelope_completed",
@@ -1046,7 +1041,13 @@ declare const WEBHOOK_EVENTS: readonly [
1046
1041
  "recipient_updated",
1047
1042
  "recipient_delegated",
1048
1043
  "kba_event",
1049
- "entitlement_used"
1044
+ "entitlement_used",
1045
+ "recipient_invited",
1046
+ "recipient_reminded",
1047
+ "recipient_auth_fail",
1048
+ "recipient_disclosure_accepted",
1049
+ "recipient_docs_downloaded",
1050
+ "recipient_invite_failed"
1050
1051
  ];
1051
1052
  type TTemplateVisibility = "private" | "shared" | "public";
1052
1053
  type TEntitlement = "envelope" | "kba_auth" | "passcode_auth" | "sms_auth" | "kba_id_auth" | "id_auth" | "custom_disclaimer";
@@ -1064,6 +1065,8 @@ type TUsageType = "envelope" | "envelope_canceled" | "envelope_completed" | "env
1064
1065
  * Methods for authenticating webhook requests.
1065
1066
  */
1066
1067
  type TWebhookAuthMethod = "none" | "hmac" | "client_credentials";
1068
+ type TNotificationType = "sms" | "email" | "app";
1069
+ type TEventName = "invitation:canceled" | "transaction:completed" | "envelope:failed" | "envelope:expired" | "envelope:declined" | "envelope:cc" | "recipient:reminder" | "transaction:requested" | "envelope:delegated" | "envelope:completed" | "transaction:canceled" | "user:invited" | "recipient:invited" | "envelope:canceled" | "transaction:sent" | "envelope:signed" | "email:verify" | "email:otp" | "password:reset" | "recipient:question";
1067
1070
  declare const FIELD_TYPES: TFieldType[];
1068
1071
  declare const DEFAULT_FIELD_WIDTHS: Record<TFieldType, number>;
1069
1072
  declare const DEFAULT_FIELD_HEIGHTS: Record<TFieldType, number>;
@@ -2327,6 +2330,17 @@ interface ISetWebhookRequest {
2327
2330
  auth_method: TWebhookAuthMethod;
2328
2331
  events: Record<TWebhookEvent, boolean>;
2329
2332
  }
2333
+ interface ICreateNotificationTemplateRequest {
2334
+ type: TNotificationType;
2335
+ event_name: TEventName;
2336
+ template_id?: string;
2337
+ html_template?: string;
2338
+ text_template?: string;
2339
+ }
2340
+ interface IUpdateNotificationTemplateRequest {
2341
+ html_template?: string;
2342
+ text_template?: string;
2343
+ }
2330
2344
  /**
2331
2345
  * Get a list of keys for a given organization. The caller must have admin access to the organization.
2332
2346
  *
@@ -3003,6 +3017,93 @@ declare const deleteOrganizationMember: (endpoint: VerdocsEndpoint, profileId: s
3003
3017
  * @apiSuccess IProfile . The updated profile for the member.
3004
3018
  */
3005
3019
  declare const updateOrganizationMember: (endpoint: VerdocsEndpoint, profileId: string, params: Partial<Pick<IProfile, "roles" | "first_name" | "last_name">>) => Promise<IProfile>;
3020
+ /**
3021
+ * Get all notification templates for the caller's organization.
3022
+ *
3023
+ * ```typescript
3024
+ * import {getNotificationTemplates} from '@verdocs/js-sdk';
3025
+ *
3026
+ * const templates = await getNotificationTemplates();
3027
+ * ```
3028
+ *
3029
+ * @group Notifications
3030
+ * @api GET /v2/notifications/templates Get notification templates
3031
+ * @apiSuccess array(items: INotificationTemplate) . A list of notification templates for the caller's organization.
3032
+ */
3033
+ declare const getNotificationTemplates: (endpoint: VerdocsEndpoint) => Promise<INotificationTemplate[]>;
3034
+ /**
3035
+ * Get a single notification template by ID.
3036
+ *
3037
+ * ```typescript
3038
+ * import {getNotificationTemplate} from '@verdocs/js-sdk';
3039
+ *
3040
+ * const template = await getNotificationTemplate(TEMPLATEID);
3041
+ * ```
3042
+ *
3043
+ * @group Notifications
3044
+ * @api GET /v2/notifications/templates/:id Get notification template
3045
+ * @apiParam string(format:uuid) id The notification template ID
3046
+ * @apiSuccess INotificationTemplate . The requested notification template.
3047
+ */
3048
+ declare const getNotificationTemplate: (endpoint: VerdocsEndpoint, id: string) => Promise<INotificationTemplate>;
3049
+ /**
3050
+ * Create a notification template. Only one template may exist per combination of type and
3051
+ * event_name. At least one of `html_template` or `text_template` must be provided.
3052
+ *
3053
+ * ```typescript
3054
+ * import {createNotificationTemplate} from '@verdocs/js-sdk';
3055
+ *
3056
+ * const template = await createNotificationTemplate({
3057
+ * type: 'email',
3058
+ * event_name: 'recipient:invited',
3059
+ * html_template: '<p>You have been invited to sign a document.</p>',
3060
+ * });
3061
+ * ```
3062
+ *
3063
+ * @group Notifications
3064
+ * @api POST /v2/notifications/templates Create notification template
3065
+ * @apiBody string(enum:'sms'|'email'|'app') type The notification channel type.
3066
+ * @apiBody string event_name The event that triggers this notification.
3067
+ * @apiBody string template_id? Optional reference to an associated template.
3068
+ * @apiBody string html_template? The HTML content for the notification. At least one of html_template or text_template is required.
3069
+ * @apiBody string text_template? The plain-text content for the notification. At least one of html_template or text_template is required.
3070
+ * @apiSuccess INotificationTemplate . The newly-created notification template.
3071
+ */
3072
+ declare const createNotificationTemplate: (endpoint: VerdocsEndpoint, params: ICreateNotificationTemplateRequest) => Promise<INotificationTemplate>;
3073
+ /**
3074
+ * Update a notification template. At least one of `html_template` or `text_template` must be provided.
3075
+ *
3076
+ * ```typescript
3077
+ * import {updateNotificationTemplate} from '@verdocs/js-sdk';
3078
+ *
3079
+ * const updated = await updateNotificationTemplate(TEMPLATEID, {
3080
+ * html_template: '<p>Updated content.</p>',
3081
+ * });
3082
+ * ```
3083
+ *
3084
+ * @group Notifications
3085
+ * @api PATCH /v2/notifications/templates/:id Update notification template
3086
+ * @apiParam string(format:uuid) id The notification template ID
3087
+ * @apiBody string html_template? The HTML content for the notification. At least one of html_template or text_template is required.
3088
+ * @apiBody string text_template? The plain-text content for the notification. At least one of html_template or text_template is required.
3089
+ * @apiSuccess INotificationTemplate . The updated notification template.
3090
+ */
3091
+ declare const updateNotificationTemplate: (endpoint: VerdocsEndpoint, id: string, params: IUpdateNotificationTemplateRequest) => Promise<INotificationTemplate>;
3092
+ /**
3093
+ * Delete a notification template.
3094
+ *
3095
+ * ```typescript
3096
+ * import {deleteNotificationTemplate} from '@verdocs/js-sdk';
3097
+ *
3098
+ * await deleteNotificationTemplate(TEMPLATEID);
3099
+ * ```
3100
+ *
3101
+ * @group Notification Templates
3102
+ * @api DELETE /v2/notifications/templates/:id Delete notification template
3103
+ * @apiParam string(format:uuid) id The notification template ID
3104
+ * @apiSuccess string . Success.
3105
+ */
3106
+ declare const deleteNotificationTemplate: (endpoint: VerdocsEndpoint, id: string) => Promise<any>;
3006
3107
  /**
3007
3108
  * Get an organization by ID. Note that this endpoint will return only a subset of fields
3008
3109
  * if the caller is not a member of the organization (the public fields).
@@ -3740,9 +3841,9 @@ declare const deleteTemplateDocument: (endpoint: VerdocsEndpoint, documentId: st
3740
3841
  * this will return only the **metadata** the caller is allowed to view.
3741
3842
  *
3742
3843
  * @group Template Documents
3743
- * @api GET /v2/envelope-documents/:id Get envelope document
3844
+ * @api GET /v2/template-documents/:id Get envelope document
3744
3845
  * @apiParam string(format: 'uuid') document_id The ID of the document to retrieve.
3745
- * @apiSuccess IEnvelopeDocument . The detailed metadata for the document requested
3846
+ * @apiSuccess ITemplateDocument . The detailed metadata for the document requested
3746
3847
  */
3747
3848
  declare const getTemplateDocument: (endpoint: VerdocsEndpoint, documentId: string) => Promise<ITemplateDocument>;
3748
3849
  /**
@@ -3932,4 +4033,4 @@ declare const decodeJWTBody: (token: string) => any;
3932
4033
  * the presence of the `document_id` field, which will only be present for signing sessions.
3933
4034
  */
3934
4035
  declare const decodeAccessTokenBody: (token: string) => TSession;
3935
- export { TRequestStatus, TTemplateSender, TTemplateAction, TRecipientAction, TEnvelopeStatus, TRecipientStatus, TRecipientType, TSortTemplateBy, TAccessKeyType, TApiKeyPermission, TDeprecatedHistoryEvent, THistoryEvent, TEventDetail, TEnvelopeUpdateResult, TFieldType, TWebhookEvent, WEBHOOK_EVENTS, TTemplateVisibility, TEntitlement, TRecipientAuthMethod, TRecipientAuthStep, TUsageType, TWebhookAuthMethod, FIELD_TYPES, DEFAULT_FIELD_WIDTHS, DEFAULT_FIELD_HEIGHTS, ALL_PERMISSIONS, IChannel, IDisabledChannel, INotification, IApiKey, IGroup, IGroupProfile, IOAuth2App, IEntitlement, IOrganization, IOrganizationInvitation, IPendingWebhook, IProfile, IUser, IWebhookEvents, IWebhook, IInPersonAccessKey, IInAppAccessKey, IEmailAccessKey, ISMSAccessKey, TAccessKey, IEnvelope, IEnvelopeDocument, IDropdownOption, IEnvelopeField, IEnvelopeFieldOptions, IEnvelopeFieldSettings, IEnvelopeHistory, IInitial, IKbaPINRequired, IKBAQuestion, IRecipient, IRole, ISignature, ITemplate, ITemplateDocument, ITemplateField, ITextFieldSetting, ITemplateFieldSetting, TOrganizationUsage, TEnvironment, TSessionChangedListener, VerdocsEndpointOptions, VerdocsEndpoint, createEnvelope, getEnvelope, getEnvelopeDocument, downloadEnvelopeDocument, getEnvelopeDocumentDownloadLink, getEnvelopeDocumentPreviewLink, cancelEnvelope, getEnvelopeFile, updateEnvelope, updateEnvelopeField, uploadEnvelopeFieldAttachment, deleteEnvelopeFieldAttachment, getEnvelopeDocumentPageDisplayUri, ITimeRange, IListEnvelopesParams, getEnvelopes, getEnvelopesZip, sortFields, sortDocuments, sortRecipients, isFieldFilled, isFieldValid, createInitials, IRecipientKbaStepNone, IRecipientKbaStepComplete, IRecipientKbaStepPin, IRecipientKbaStepIdentity, IRecipientKbaStepChallenge, IRecipientKbaStepFailed, TRecipientKbaStep, getKbaStep, submitKbaPin, IKbaIdentity, submitKbaIdentity, IKbaChallengeResponse, submitKbaChallengeResponse, envelopeRecipientAgree, envelopeRecipientDecline, envelopeRecipientSubmit, startSigningSession, getInPersonLink, verifySigner, delegateRecipient, updateRecipient, remindRecipient, resetRecipient, askQuestion, isEnvelopeOwner, isEnvelopeRecipient, canAccessEnvelope, userIsEnvelopeOwner, userIsEnvelopeRecipient, useCanAccessEnvelope, envelopeIsActive, envelopeIsComplete, userCanCancelEnvelope, userCanFinishEnvelope, recipientHasAction, getRecipientsWithActions, recipientCanAct, userCanAct, userCanSignNow, getNextRecipient, createSignature, IEnvelopesSearchResult, IDocumentSearchOptions, ICreateEnvelopeRecipientFromTemplate, ICreateEnvelopeRecipientDirectly, ISignerTokenResponse, IInPersonLinkResponse, IUpdateRecipientStatus, ICreateEnvelopeReminderRequest, IUpdateRecipientParams, ICreateEnvelopeDocumentFromData, ICreateEnvelopeDocumentFromUri, ICreateEnvelopeDocumentFromFile, ICreateEnvelopeFieldFromTemplate, ICreateEnvelopeFieldDirectly, ICreateEnvelopeFromTemplateRequest, ICreateEnvelopeDirectlyRequest, TCreateEnvelopeRequest, IAuthenticateRecipientViaPasscodeRequest, IAuthenticateRecipientViaEmailRequest, IAuthenticateRecipientViaSMSRequest, IKBAResponse, IAuthenticateRecipientViaKBARequest, TAuthenticateRecipientRequest, DEFAULT_DISCLOSURES, getApiKeys, createApiKey, rotateApiKey, updateApiKey, deleteApiKey, getOrganizationContacts, deleteOrganizationContact, createOrganizationContact, updateOrganizationContact, getGroups, getGroup, createGroup, updateGroup, deleteGroup, addGroupMember, deleteGroupMember, getOrganizationInvitations, createOrganizationInvitation, deleteOrganizationInvitation, updateOrganizationInvitation, resendOrganizationInvitation, getOrganizationInvitation, acceptOrganizationInvitation, declineOrganizationInvitation, getOrganizationMembers, deleteOrganizationMember, updateOrganizationMember, getOrganization, getOrganizationChildren, getOrganizationUsage, createOrganization, updateOrganization, deleteOrganization, updateOrganizationLogo, updateOrganizationThumbnail, getEntitlements, getActiveEntitlements, ICreateApiKeyRequest, IUpdateApiKeyRequest, ICreateInvitationRequest, IAcceptOrganizationInvitationRequest, ISetWebhookRequest, getWebhooks, setWebhooks, rotateWebhookSecret, TTemplatePermissionCreatePublic, TTemplatePermissionCreateOrg, TTemplatePermissionCreatePersonal, TTemplatePermissionDelete, TTemplatePermissionVisibility, TTemplateMemberRead, TTemplateMemberWrite, TTemplateMemberDelete, TTemplateMemberVisibility, TTemplatePermission, TAccountPermissionOwnerAdd, TAccountPermissionOwnerRemove, TAccountPermissionAdminAdd, TAccountPermissionAdminRemove, TAccountPermissionMemberView, TAccountPermissionMemberAdd, TAccountPermissionMemberRemove, TAccountPermission, TOrgPermissionCreate, TOrgPermissionView, TOrgPermissionUpdate, TOrgPermissionDelete, TOrgPermissionTransfer, TOrgPermissionList, TOrgPermission, TEnvelopePermissionCreate, TEnvelopePermissionCancel, TEnvelopePermissionView, TEnvelopePermissionOrg, TEnvelopePermission, TPermission, TRole, RolePermissions, userHasPermissions, ISigningSession, IUserSession, IIdToken, TSessionType, TSession, TActiveSession, canPerformTemplateAction, hasRequiredPermissions, createField, updateField, deleteField, userIsTemplateCreator, userHasSharedTemplate, userCanCreatePersonalTemplate, userCanCreateOrgTemplate, userCanCreatePublicTemplate, userCanReadTemplate, userCanUpdateTemplate, userCanMakeTemplatePrivate, userCanMakeTemplateShared, userCanMakeTemplatePublic, userCanChangeOrgVisibility, userCanDeleteTemplate, userCanSendTemplate, userCanCreateTemplate, userCanBuildTemplate, getFieldsForRole, userCanPreviewTemplate, createTemplateRole, updateTemplateRole, deleteTemplateRole, ITemplateSortBy, TTemplateVisibilityFilter, IGetTemplatesParams, getTemplates, getTemplate, IDocumentFromUri, IDocumentFromData, ITemplateCreateParams, createTemplate, duplicateTemplate, ITemplateCreateFromSharepointParams, createTemplateFromSharepoint, updateTemplate, deleteTemplate, toggleTemplateStar, createTemplateDocument, deleteTemplateDocument, getTemplateDocument, downloadTemplateDocument, getTemplateDocumentDownloadLink, getTemplateDocumentPreviewLink, getTemplateDocumentFile, getTemplateDocumentThumbnail, getTemplateDocumentPageDisplayUri, ITemplateTag, ITag, IStar, ITemplateSearchResult, IValidator, isValidInput, getValidators, isValidEmail, isValidPhone, isValidRoleName, isValidTag, IROPCRequest, IClientCredentialsRequest, IRefreshTokenRequest, TAuthenticationRequest, authenticate, refreshToken, changePassword, resetPassword, resendVerification, verifyEmail, getMyUser, getNotifications, getProfiles, getCurrentProfile, switchProfile, updateProfile, deleteProfile, createProfile, updateProfilePhoto, ICreateProfileRequest, IUpdateProfileRequest, IAuthenticateResponse, IChangePasswordRequest, IChangePasswordResponse, IResetPasswordRequest, IResetPasswordResponse, IVerifyEmailRequest, getRGB, getRGBA, nameToRGBA, getRoleColor, formatShortTimeAgo, collapseEntitlements, getRTop, getRLeft, getRValue, blobToBase64, rescale, fileToDataUrl, downloadBlob, Countries, getCountryByCode, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, getPlusOneCountry, isCanada, isAmericanSamoa, isDominicanRepublic, isPuertoRico, getMatchingCountry, integerSequence, formatFullName, formatInitials, fullNameToInitials, capitalize, convertToE164, randomString, AtoB, decodeJWTBody, decodeAccessTokenBody, IFileWithData, ICountry };
4036
+ export { TRequestStatus, TTemplateSender, TTemplateAction, TRecipientAction, TEnvelopeStatus, TRecipientStatus, TRecipientType, TSortTemplateBy, TAccessKeyType, TApiKeyPermission, TDeprecatedHistoryEvent, THistoryEvent, TEventDetail, TEnvelopeUpdateResult, TFieldType, TWebhookEvent, WEBHOOK_EVENTS, TTemplateVisibility, TEntitlement, TRecipientAuthMethod, TRecipientAuthStep, TUsageType, TWebhookAuthMethod, TNotificationType, TEventName, FIELD_TYPES, DEFAULT_FIELD_WIDTHS, DEFAULT_FIELD_HEIGHTS, ALL_PERMISSIONS, IChannel, IDisabledChannel, INotification, INotificationTemplate, IApiKey, IGroup, IGroupProfile, IOAuth2App, IEntitlement, IOrganization, IOrganizationInvitation, IPendingWebhook, IProfile, IUser, IWebhookEvents, IWebhook, IInPersonAccessKey, IInAppAccessKey, IEmailAccessKey, ISMSAccessKey, TAccessKey, IEnvelope, IEnvelopeDocument, IDropdownOption, IEnvelopeField, IEnvelopeFieldOptions, IEnvelopeFieldSettings, IEnvelopeHistory, IInitial, IKbaPINRequired, IKBAQuestion, IRecipient, IRole, ISignature, ITemplate, ITemplateDocument, ITemplateField, ITextFieldSetting, ITemplateFieldSetting, TOrganizationUsage, TEnvironment, TSessionChangedListener, VerdocsEndpointOptions, VerdocsEndpoint, createEnvelope, getEnvelope, getEnvelopeDocument, downloadEnvelopeDocument, getEnvelopeDocumentDownloadLink, getEnvelopeDocumentPreviewLink, cancelEnvelope, getEnvelopeFile, updateEnvelope, updateEnvelopeField, uploadEnvelopeFieldAttachment, deleteEnvelopeFieldAttachment, getEnvelopeDocumentPageDisplayUri, ITimeRange, IListEnvelopesParams, getEnvelopes, getEnvelopesZip, sortFields, sortDocuments, sortRecipients, isFieldFilled, isFieldValid, createInitials, IRecipientKbaStepNone, IRecipientKbaStepComplete, IRecipientKbaStepPin, IRecipientKbaStepIdentity, IRecipientKbaStepChallenge, IRecipientKbaStepFailed, TRecipientKbaStep, getKbaStep, submitKbaPin, IKbaIdentity, submitKbaIdentity, IKbaChallengeResponse, submitKbaChallengeResponse, envelopeRecipientAgree, envelopeRecipientDecline, envelopeRecipientSubmit, startSigningSession, getInPersonLink, verifySigner, delegateRecipient, updateRecipient, remindRecipient, resetRecipient, askQuestion, isEnvelopeOwner, isEnvelopeRecipient, canAccessEnvelope, userIsEnvelopeOwner, userIsEnvelopeRecipient, useCanAccessEnvelope, envelopeIsActive, envelopeIsComplete, userCanCancelEnvelope, userCanFinishEnvelope, recipientHasAction, getRecipientsWithActions, recipientCanAct, userCanAct, userCanSignNow, getNextRecipient, createSignature, IEnvelopesSearchResult, IDocumentSearchOptions, ICreateEnvelopeRecipientFromTemplate, ICreateEnvelopeRecipientDirectly, ISignerTokenResponse, IInPersonLinkResponse, IUpdateRecipientStatus, ICreateEnvelopeReminderRequest, IUpdateRecipientParams, ICreateEnvelopeDocumentFromData, ICreateEnvelopeDocumentFromUri, ICreateEnvelopeDocumentFromFile, ICreateEnvelopeFieldFromTemplate, ICreateEnvelopeFieldDirectly, ICreateEnvelopeFromTemplateRequest, ICreateEnvelopeDirectlyRequest, TCreateEnvelopeRequest, IAuthenticateRecipientViaPasscodeRequest, IAuthenticateRecipientViaEmailRequest, IAuthenticateRecipientViaSMSRequest, IKBAResponse, IAuthenticateRecipientViaKBARequest, TAuthenticateRecipientRequest, DEFAULT_DISCLOSURES, getApiKeys, createApiKey, rotateApiKey, updateApiKey, deleteApiKey, getOrganizationContacts, deleteOrganizationContact, createOrganizationContact, updateOrganizationContact, getGroups, getGroup, createGroup, updateGroup, deleteGroup, addGroupMember, deleteGroupMember, getOrganizationInvitations, createOrganizationInvitation, deleteOrganizationInvitation, updateOrganizationInvitation, resendOrganizationInvitation, getOrganizationInvitation, acceptOrganizationInvitation, declineOrganizationInvitation, getOrganizationMembers, deleteOrganizationMember, updateOrganizationMember, getNotificationTemplates, getNotificationTemplate, createNotificationTemplate, updateNotificationTemplate, deleteNotificationTemplate, getOrganization, getOrganizationChildren, getOrganizationUsage, createOrganization, updateOrganization, deleteOrganization, updateOrganizationLogo, updateOrganizationThumbnail, getEntitlements, getActiveEntitlements, ICreateApiKeyRequest, IUpdateApiKeyRequest, ICreateInvitationRequest, IAcceptOrganizationInvitationRequest, ISetWebhookRequest, ICreateNotificationTemplateRequest, IUpdateNotificationTemplateRequest, getWebhooks, setWebhooks, rotateWebhookSecret, TTemplatePermissionCreatePublic, TTemplatePermissionCreateOrg, TTemplatePermissionCreatePersonal, TTemplatePermissionDelete, TTemplatePermissionVisibility, TTemplateMemberRead, TTemplateMemberWrite, TTemplateMemberDelete, TTemplateMemberVisibility, TTemplatePermission, TAccountPermissionOwnerAdd, TAccountPermissionOwnerRemove, TAccountPermissionAdminAdd, TAccountPermissionAdminRemove, TAccountPermissionMemberView, TAccountPermissionMemberAdd, TAccountPermissionMemberRemove, TAccountPermission, TOrgPermissionCreate, TOrgPermissionView, TOrgPermissionUpdate, TOrgPermissionDelete, TOrgPermissionTransfer, TOrgPermissionList, TOrgPermission, TEnvelopePermissionCreate, TEnvelopePermissionCancel, TEnvelopePermissionView, TEnvelopePermissionOrg, TEnvelopePermission, TPermission, TRole, RolePermissions, userHasPermissions, ISigningSession, IUserSession, IIdToken, TSessionType, TSession, TActiveSession, canPerformTemplateAction, hasRequiredPermissions, createField, updateField, deleteField, userIsTemplateCreator, userHasSharedTemplate, userCanCreatePersonalTemplate, userCanCreateOrgTemplate, userCanCreatePublicTemplate, userCanReadTemplate, userCanUpdateTemplate, userCanMakeTemplatePrivate, userCanMakeTemplateShared, userCanMakeTemplatePublic, userCanChangeOrgVisibility, userCanDeleteTemplate, userCanSendTemplate, userCanCreateTemplate, userCanBuildTemplate, getFieldsForRole, userCanPreviewTemplate, createTemplateRole, updateTemplateRole, deleteTemplateRole, ITemplateSortBy, TTemplateVisibilityFilter, IGetTemplatesParams, getTemplates, getTemplate, IDocumentFromUri, IDocumentFromData, ITemplateCreateParams, createTemplate, duplicateTemplate, ITemplateCreateFromSharepointParams, createTemplateFromSharepoint, updateTemplate, deleteTemplate, toggleTemplateStar, createTemplateDocument, deleteTemplateDocument, getTemplateDocument, downloadTemplateDocument, getTemplateDocumentDownloadLink, getTemplateDocumentPreviewLink, getTemplateDocumentFile, getTemplateDocumentThumbnail, getTemplateDocumentPageDisplayUri, ITemplateTag, ITag, IStar, ITemplateSearchResult, IValidator, isValidInput, getValidators, isValidEmail, isValidPhone, isValidRoleName, isValidTag, IROPCRequest, IClientCredentialsRequest, IRefreshTokenRequest, TAuthenticationRequest, authenticate, refreshToken, changePassword, resetPassword, resendVerification, verifyEmail, getMyUser, getNotifications, getProfiles, getCurrentProfile, switchProfile, updateProfile, deleteProfile, createProfile, updateProfilePhoto, ICreateProfileRequest, IUpdateProfileRequest, IAuthenticateResponse, IChangePasswordRequest, IChangePasswordResponse, IResetPasswordRequest, IResetPasswordResponse, IVerifyEmailRequest, getRGB, getRGBA, nameToRGBA, getRoleColor, formatShortTimeAgo, collapseEntitlements, getRTop, getRLeft, getRValue, blobToBase64, rescale, fileToDataUrl, downloadBlob, Countries, getCountryByCode, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, getPlusOneCountry, isCanada, isAmericanSamoa, isDominicanRepublic, isPuertoRico, getMatchingCountry, integerSequence, formatFullName, formatInitials, fullNameToInitials, capitalize, convertToE164, randomString, AtoB, decodeJWTBody, decodeAccessTokenBody, IFileWithData, ICountry };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var axios = require('axios');
4
3
  var axiosRetry = require('axios-retry');
4
+ var axios = require('axios');
5
5
 
6
6
  const WEBHOOK_EVENTS = [
7
7
  'envelope_created',
@@ -18,6 +18,12 @@ const WEBHOOK_EVENTS = [
18
18
  'recipient_delegated',
19
19
  'kba_event',
20
20
  'entitlement_used',
21
+ 'recipient_invited',
22
+ 'recipient_reminded',
23
+ 'recipient_auth_fail',
24
+ 'recipient_disclosure_accepted',
25
+ 'recipient_docs_downloaded',
26
+ 'recipient_invite_failed',
21
27
  ];
22
28
 
23
29
  const FIELD_TYPES = [
@@ -2537,9 +2543,9 @@ const deleteTemplateDocument = (endpoint, documentId) => endpoint.api //
2537
2543
  * this will return only the **metadata** the caller is allowed to view.
2538
2544
  *
2539
2545
  * @group Template Documents
2540
- * @api GET /v2/envelope-documents/:id Get envelope document
2546
+ * @api GET /v2/template-documents/:id Get envelope document
2541
2547
  * @apiParam string(format: 'uuid') document_id The ID of the document to retrieve.
2542
- * @apiSuccess IEnvelopeDocument . The detailed metadata for the document requested
2548
+ * @apiSuccess ITemplateDocument . The detailed metadata for the document requested
2543
2549
  */
2544
2550
  const getTemplateDocument = async (endpoint, documentId) => endpoint.api //
2545
2551
  .get(`/v2/template-documents/${documentId}`)
@@ -3477,6 +3483,112 @@ const updateOrganizationMember = (endpoint, profileId, params) => endpoint.api /
3477
3483
  .patch(`/v2/organization-members/${profileId}`, params)
3478
3484
  .then((r) => r.data);
3479
3485
 
3486
+ /**
3487
+ * Notification Templates allow organizations to customize the email and SMS notifications
3488
+ * sent during signing workflows. Each template is tied to a specific event (e.g. recipient invited,
3489
+ * envelope completed) and notification type (email, sms, etc). The caller must have admin access
3490
+ * to the organization.
3491
+ *
3492
+ * @module
3493
+ */
3494
+ /**
3495
+ * Get all notification templates for the caller's organization.
3496
+ *
3497
+ * ```typescript
3498
+ * import {getNotificationTemplates} from '@verdocs/js-sdk';
3499
+ *
3500
+ * const templates = await getNotificationTemplates();
3501
+ * ```
3502
+ *
3503
+ * @group Notifications
3504
+ * @api GET /v2/notifications/templates Get notification templates
3505
+ * @apiSuccess array(items: INotificationTemplate) . A list of notification templates for the caller's organization.
3506
+ */
3507
+ const getNotificationTemplates = (endpoint) => endpoint.api //
3508
+ .get(`/v2/notifications/templates`)
3509
+ .then((r) => r.data);
3510
+ /**
3511
+ * Get a single notification template by ID.
3512
+ *
3513
+ * ```typescript
3514
+ * import {getNotificationTemplate} from '@verdocs/js-sdk';
3515
+ *
3516
+ * const template = await getNotificationTemplate(TEMPLATEID);
3517
+ * ```
3518
+ *
3519
+ * @group Notifications
3520
+ * @api GET /v2/notifications/templates/:id Get notification template
3521
+ * @apiParam string(format:uuid) id The notification template ID
3522
+ * @apiSuccess INotificationTemplate . The requested notification template.
3523
+ */
3524
+ const getNotificationTemplate = (endpoint, id) => endpoint.api //
3525
+ .get(`/v2/notifications/templates/${id}`)
3526
+ .then((r) => r.data);
3527
+ /**
3528
+ * Create a notification template. Only one template may exist per combination of type and
3529
+ * event_name. At least one of `html_template` or `text_template` must be provided.
3530
+ *
3531
+ * ```typescript
3532
+ * import {createNotificationTemplate} from '@verdocs/js-sdk';
3533
+ *
3534
+ * const template = await createNotificationTemplate({
3535
+ * type: 'email',
3536
+ * event_name: 'recipient:invited',
3537
+ * html_template: '<p>You have been invited to sign a document.</p>',
3538
+ * });
3539
+ * ```
3540
+ *
3541
+ * @group Notifications
3542
+ * @api POST /v2/notifications/templates Create notification template
3543
+ * @apiBody string(enum:'sms'|'email'|'app') type The notification channel type.
3544
+ * @apiBody string event_name The event that triggers this notification.
3545
+ * @apiBody string template_id? Optional reference to an associated template.
3546
+ * @apiBody string html_template? The HTML content for the notification. At least one of html_template or text_template is required.
3547
+ * @apiBody string text_template? The plain-text content for the notification. At least one of html_template or text_template is required.
3548
+ * @apiSuccess INotificationTemplate . The newly-created notification template.
3549
+ */
3550
+ const createNotificationTemplate = (endpoint, params) => endpoint.api //
3551
+ .post(`/v2/notifications/templates`, params)
3552
+ .then((r) => r.data);
3553
+ /**
3554
+ * Update a notification template. At least one of `html_template` or `text_template` must be provided.
3555
+ *
3556
+ * ```typescript
3557
+ * import {updateNotificationTemplate} from '@verdocs/js-sdk';
3558
+ *
3559
+ * const updated = await updateNotificationTemplate(TEMPLATEID, {
3560
+ * html_template: '<p>Updated content.</p>',
3561
+ * });
3562
+ * ```
3563
+ *
3564
+ * @group Notifications
3565
+ * @api PATCH /v2/notifications/templates/:id Update notification template
3566
+ * @apiParam string(format:uuid) id The notification template ID
3567
+ * @apiBody string html_template? The HTML content for the notification. At least one of html_template or text_template is required.
3568
+ * @apiBody string text_template? The plain-text content for the notification. At least one of html_template or text_template is required.
3569
+ * @apiSuccess INotificationTemplate . The updated notification template.
3570
+ */
3571
+ const updateNotificationTemplate = (endpoint, id, params) => endpoint.api //
3572
+ .patch(`/v2/notifications/templates/${id}`, params)
3573
+ .then((r) => r.data);
3574
+ /**
3575
+ * Delete a notification template.
3576
+ *
3577
+ * ```typescript
3578
+ * import {deleteNotificationTemplate} from '@verdocs/js-sdk';
3579
+ *
3580
+ * await deleteNotificationTemplate(TEMPLATEID);
3581
+ * ```
3582
+ *
3583
+ * @group Notification Templates
3584
+ * @api DELETE /v2/notifications/templates/:id Delete notification template
3585
+ * @apiParam string(format:uuid) id The notification template ID
3586
+ * @apiSuccess string . Success.
3587
+ */
3588
+ const deleteNotificationTemplate = (endpoint, id) => endpoint.api //
3589
+ .delete(`/v2/notifications/templates/${id}`)
3590
+ .then((r) => r.data);
3591
+
3480
3592
  /**
3481
3593
  * An Organization is the top level object for ownership for Members, Documents, and Templates.
3482
3594
  *
@@ -3808,6 +3920,7 @@ exports.createEnvelope = createEnvelope;
3808
3920
  exports.createField = createField;
3809
3921
  exports.createGroup = createGroup;
3810
3922
  exports.createInitials = createInitials;
3923
+ exports.createNotificationTemplate = createNotificationTemplate;
3811
3924
  exports.createOrganization = createOrganization;
3812
3925
  exports.createOrganizationContact = createOrganizationContact;
3813
3926
  exports.createOrganizationInvitation = createOrganizationInvitation;
@@ -3826,6 +3939,7 @@ exports.deleteEnvelopeFieldAttachment = deleteEnvelopeFieldAttachment;
3826
3939
  exports.deleteField = deleteField;
3827
3940
  exports.deleteGroup = deleteGroup;
3828
3941
  exports.deleteGroupMember = deleteGroupMember;
3942
+ exports.deleteNotificationTemplate = deleteNotificationTemplate;
3829
3943
  exports.deleteOrganization = deleteOrganization;
3830
3944
  exports.deleteOrganizationContact = deleteOrganizationContact;
3831
3945
  exports.deleteOrganizationInvitation = deleteOrganizationInvitation;
@@ -3869,6 +3983,8 @@ exports.getKbaStep = getKbaStep;
3869
3983
  exports.getMatchingCountry = getMatchingCountry;
3870
3984
  exports.getMyUser = getMyUser;
3871
3985
  exports.getNextRecipient = getNextRecipient;
3986
+ exports.getNotificationTemplate = getNotificationTemplate;
3987
+ exports.getNotificationTemplates = getNotificationTemplates;
3872
3988
  exports.getNotifications = getNotifications;
3873
3989
  exports.getOrganization = getOrganization;
3874
3990
  exports.getOrganizationChildren = getOrganizationChildren;
@@ -3943,6 +4059,7 @@ exports.updateEnvelope = updateEnvelope;
3943
4059
  exports.updateEnvelopeField = updateEnvelopeField;
3944
4060
  exports.updateField = updateField;
3945
4061
  exports.updateGroup = updateGroup;
4062
+ exports.updateNotificationTemplate = updateNotificationTemplate;
3946
4063
  exports.updateOrganization = updateOrganization;
3947
4064
  exports.updateOrganizationContact = updateOrganizationContact;
3948
4065
  exports.updateOrganizationInvitation = updateOrganizationInvitation;