@verdocs/js-sdk 4.0.9 → 4.0.11

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
@@ -302,8 +302,8 @@ interface IEnvelopeField {
302
302
  /** The type of the field */
303
303
  type: TFieldType;
304
304
  /** If true, the field will be required */
305
- required: boolean;
306
- settings?: IEnvelopeFieldSettings;
305
+ required: boolean | null;
306
+ settings: IEnvelopeFieldSettings | null;
307
307
  validator: string | null;
308
308
  /** If set, the placeholder/label for the field. */
309
309
  label: string | null;
@@ -596,7 +596,7 @@ interface ITemplateField {
596
596
  document_id: string;
597
597
  type: TFieldType;
598
598
  required: boolean;
599
- settings: ITemplateFieldSetting;
599
+ settings: ITemplateFieldSetting | null;
600
600
  page: number;
601
601
  validator: string | null;
602
602
  label: string | null;
@@ -1863,6 +1863,73 @@ declare const updateField: (endpoint: VerdocsEndpoint, templateId: string, field
1863
1863
  * REmove a field from a template.
1864
1864
  */
1865
1865
  declare const deleteField: (endpoint: VerdocsEndpoint, templateId: string, fieldName: string) => Promise<any>;
1866
+ /**
1867
+ * Check to see if the user created the template.
1868
+ */
1869
+ declare const userIsTemplateCreator: (session: TSession, template: ITemplate | ITemplateSummary) => boolean | null;
1870
+ /**
1871
+ * Check to see if a template is "shared" with the user.
1872
+ */
1873
+ declare const userHasSharedTemplate: (session: TSession, template: ITemplate | ITemplateSummary) => boolean | null;
1874
+ /**
1875
+ * Check to see if the user can create a personal/private template.
1876
+ */
1877
+ declare const userCanCreatePersonalTemplate: (session: TSession) => boolean;
1878
+ /**
1879
+ * Check to see if the user can create an org-shared template.
1880
+ */
1881
+ declare const userCanCreateOrgTemplate: (session: TSession) => boolean;
1882
+ /**
1883
+ * Check to see if the user can create a public template.
1884
+ */
1885
+ declare const userCanCreatePublicTemplate: (session: TSession) => boolean;
1886
+ /**
1887
+ * Check to see if the user can read/view a template.
1888
+ */
1889
+ declare const userCanReadTemplate: (session: TSession, template: ITemplate | ITemplateSummary) => boolean | null;
1890
+ /**
1891
+ * Check to see if the user can update a tempate.
1892
+ */
1893
+ declare const userCanUpdateTemplate: (session: TSession, template: ITemplate | ITemplateSummary) => boolean | null;
1894
+ /**
1895
+ * Check to see if the user can change whether a template is personal vs org-shared.
1896
+ */
1897
+ declare const userCanMakeTemplatePrivate: (session: TSession, template: ITemplate | ITemplateSummary) => boolean;
1898
+ /**
1899
+ * Check to see if the user can change whether a template is personal vs org-shared.
1900
+ */
1901
+ declare const userCanMakeTemplateShared: (session: TSession, template: ITemplate | ITemplateSummary) => boolean;
1902
+ /**
1903
+ * Check to see if the user can change whether a template is personal vs org-shared.
1904
+ */
1905
+ declare const userCanMakeTemplatePublic: (session: TSession, template: ITemplate | ITemplateSummary) => boolean;
1906
+ /**
1907
+ * Check to see if the user can change whether a template is personal vs org-shared.
1908
+ */
1909
+ declare const userCanChangeOrgVisibility: (session: TSession, template: ITemplate | ITemplateSummary) => boolean | null;
1910
+ /**
1911
+ * Check to see if the user can change whether a template is personal vs org-shared.
1912
+ */
1913
+ declare const userCanDeleteTemplate: (session: TSession, template: ITemplate | ITemplateSummary) => boolean;
1914
+ /**
1915
+ * Confirm whether the user can create an envelope using the specified template.
1916
+ */
1917
+ declare const userCanSendTemplate: (session: TSession, template: ITemplate | ITemplateSummary) => boolean | null;
1918
+ /**
1919
+ * Confirm whether the user can create a new template.
1920
+ */
1921
+ declare const userCanCreateTemplate: (session: TSession) => boolean;
1922
+ /**
1923
+ * Check to see if the user can "build" the template (use the field builder). The user must have write access to the
1924
+ * template, and the template must have at least one signer role.
1925
+ */
1926
+ declare const userCanBuildTemplate: (session: TSession, template: ITemplate) => boolean | null;
1927
+ declare const getFieldsForRole: (template: ITemplate, role_name: string) => ITemplateField[];
1928
+ /**
1929
+ * Check to see if the user can preview the template. The user must have read access to the template, the template must
1930
+ * have at least one signer, and every signer must have at least one field.
1931
+ */
1932
+ declare const userCanPreviewTemplate: (session: TSession, template: ITemplate) => boolean | null;
1866
1933
  interface ICreateTemplateReminderRequest {
1867
1934
  setup_time: number;
1868
1935
  interval_time: number;
@@ -2563,4 +2630,4 @@ interface ISignupSurvey {
2563
2630
  declare const recordSignupSurvey: (endpoint: VerdocsEndpoint, params: ISignupSurvey) => Promise<{
2564
2631
  status: "OK";
2565
2632
  }>;
2566
- export { TRequestStatus, TTemplateSenderType, TTemplatePermission, TTemplateAction, TAccountPermission, TOrgPermission, TApiKeyPermission, TPermission, TRecipientAction, TEnvelopeStatus, TRecipientStatus, TRecipientType, TPlan, TRole, TSortTemplateBy, TAccessKeyType, THistoryEvent, TEventDetail, TEnvelopeUpdateResult, TFieldType, IChannel, IDisabledChannel, INotification, IApiKey, IGroup, IGroupProfile, IOAuth2App, IOrganization, IOrganizationInvitation, IPendingWebhook, IProfile, IWebhookEvents, IWebhook, IInPersonAccessKey, IInAppAccessKey, IEmailAccessKey, ISMSAccessKey, TAccessKey, IEnvelope, IEnvelopeDocument, IEnvelopeField, IEnvelopeFieldOptions, IEnvelopeFieldSettings, IEnvelopeHistory, IInitial, IRecipient, IReminder, IRole, ISignature, ITemplate, ITemplateDocument, ITemplateField, ITextFieldSetting, ITemplateFieldSetting, IActivityEntry, TEnvironment, TSessionChangedListener, VerdocsEndpointOptions, VerdocsEndpoint, createEnvelope, getEnvelopesSummary, IEnvelopeSearchParams, searchEnvelopes, ISigningSessionResult, getSigningSession, getEnvelopeRecipients, getEnvelope, getEnvelopeDocument, getDocumentDownloadLink, getDocumentPreviewLink, cancelEnvelope, getEnvelopeFile, updateEnvelopeField, updateEnvelopeFieldSignature, updateEnvelopeFieldInitials, uploadEnvelopeFieldAttachment, deleteEnvelopeFieldAttachment, getFieldAttachment, getEnvelopeDocumentPageDisplayUri, throttledGetEnvelope, ITimeRange, IListEnvelopesParams, listEnvelopes, getEnvelopesByTemplateId, createInitials, updateRecipient, envelopeRecipientSubmit, envelopeRecipientDecline, envelopeRecipientChangeOwner, envelopeRecipientAgree, envelopeRecipientUpdateName, envelopeRecipientPrepare, ISignerTokenResponse, getSignerToken, getInPersonLink, sendDelegate, resendInvitation, createEnvelopeReminder, getEnvelopeReminder, updateEnvelopeReminder, deleteEnvelopeReminder, userIsEnvelopeOwner, userIsEnvelopeRecipient, envelopeIsActive, envelopeIsComplete, userCanCancelEnvelope, userCanFinishEnvelope, recipientHasAction, getRecipientsWithActions, recipientCanAct, userCanAct, userCanSignNow, getNextRecipient, createSignature, getSignatures, getSignature, deleteSignature, IEnvelopesSearchResultEntry, IEnvelopesSearchResult, IEnvelopesSummary, IDocumentSearchOptions, ICreateEnvelopeRole, IEnvelopeSummary, IEnvelopeSummaries, IInPersonLinkResponse, IUpdateRecipientSubmitParams, IUpdateRecipientDeclineParams, IUpdateRecipientClaimEnvelope, IUpdateRecipientStatus, IUpdateRecipientAgreedParams, IUpdateRecipientNameParams, IUpdateRecipientPrepareParams, ICreateEnvelopeReminderRequest, ICreateEnvelopeRequest, TEnvelopePermission, getApiKeys, createApiKey, rotateApiKey, updateApiKey, deleteApiKey, getGroups, getGroupByName, getGroup, getGroupMembers, addGroupMembers, deleteGroupMembers, addGroupPermission, deleteGroupPermission, getOrganizationInvitations, createOrganizationInvitation, deleteOrganizationInvitation, updateOrganizationInvitation, resendOrganizationInvitation, getOrganizationInvitation, acceptOrganizationInvitation, declineOrganizationInvitation, claimNewUser, getOrganizationMembers, deleteOrganizationMember, addOrganizationMemberRole, deleteOrganizationMemberRole, getOrganizationMemberPlans, getOrganizations, createOrganization, deleteOrganization, getOrganization, updateOrganization, ICreateApiKeyRequest, IUpdateApiKeyRequest, ICreateInvitationRequest, ISetWebhookRequest, getWebhooks, setWebhooks, userHasPermissions, ISigningSessionRequest, ISigningSession, IUserSession, TSessionType, TSession, TActiveSession, canPerformTemplateAction, hasRequiredPermissions, createField, updateField, deleteField, ICreateTemplateReminderRequest, createTemplateReminder, getTemplateReminder, updateTemplateReminder, deleteTemplateReminder, createTemplateRole, getTemplateRoles, getTemplateRole, updateTemplateRole, deleteTemplateRole, getTemplateRoleFields, getStars, toggleStar, addTemplateTag, getTemplateTags, deleteTemplateTag, createTag, getTag, getAllTags, IGetTemplatesParams, getTemplates, getTemplate, getTemplateOwnerInfo, IDocumentFromUri, IDocumentFromData, ITemplateCreateParams, createTemplate, createTemplatev2, ITemplateCreateFromSharepointParams, createTemplateFromSharepoint, updateTemplate, deleteTemplate, searchTemplates, ISearchTimeRange, IGetTemplateSummarySortBy, IGetTemplateSummaryParams, getTemplatesSummary, throttledGetTemplate, ITemplateListParams, listTemplates, getTemplateDocuments, getTemplateDocument, createTemplateDocument, deleteTemplateDocument, getTemplateDocumentFile, getTemplateDocumentThumbnail, getTemplateDocumentPageDisplayUri, ITemplateSummary, ITemplateSearchParams, ITemplateSummaries, ITemplateTag, ITag, IStar, ITemplateOwnerInfo, ITemplateSearchResult, IValidator, getValidators, getValidator, isValidEmail, isValidPhone, isValidRoleName, isValidTag, authenticateUser, authenticateApp, validateToken, refreshTokens, updatePassword, resetPassword, updateEmail, resendVerification, createUser, billingPlaceholder, getNotifications, getProfiles, getCurrentProfile, getRoles, createProfile, getProfile, getProfileGroups, switchProfile, updateProfile, deleteProfile, createBusinessAccount, ISignupSurvey, recordSignupSurvey, ICreateProfileRequest, ISwitchProfileResponse, IUpdateProfileRequest, IAuthenticateUserRequest, IAuthenticateAppRequest, IAuthenticateResponse, TokenValidationRequest, TokenValidationResponse, IUpdatePasswordRequest, UpdatePasswordResponse, UpdateEmailRequest, UpdateEmailResponse, ICreateBusinessAccountRequest, ICreateUserRequest, getRGB, getRGBA, nameToRGBA, getRoleColor, formatShortTimeAgo, timePeriod, 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, AtoB, decodeJWTBody, decodeAccessTokenBody, IFileWithData, ICountry, ITimePeriod };
2633
+ export { TRequestStatus, TTemplateSenderType, TTemplatePermission, TTemplateAction, TAccountPermission, TOrgPermission, TApiKeyPermission, TPermission, TRecipientAction, TEnvelopeStatus, TRecipientStatus, TRecipientType, TPlan, TRole, TSortTemplateBy, TAccessKeyType, THistoryEvent, TEventDetail, TEnvelopeUpdateResult, TFieldType, IChannel, IDisabledChannel, INotification, IApiKey, IGroup, IGroupProfile, IOAuth2App, IOrganization, IOrganizationInvitation, IPendingWebhook, IProfile, IWebhookEvents, IWebhook, IInPersonAccessKey, IInAppAccessKey, IEmailAccessKey, ISMSAccessKey, TAccessKey, IEnvelope, IEnvelopeDocument, IEnvelopeField, IEnvelopeFieldOptions, IEnvelopeFieldSettings, IEnvelopeHistory, IInitial, IRecipient, IReminder, IRole, ISignature, ITemplate, ITemplateDocument, ITemplateField, ITextFieldSetting, ITemplateFieldSetting, IActivityEntry, TEnvironment, TSessionChangedListener, VerdocsEndpointOptions, VerdocsEndpoint, createEnvelope, getEnvelopesSummary, IEnvelopeSearchParams, searchEnvelopes, ISigningSessionResult, getSigningSession, getEnvelopeRecipients, getEnvelope, getEnvelopeDocument, getDocumentDownloadLink, getDocumentPreviewLink, cancelEnvelope, getEnvelopeFile, updateEnvelopeField, updateEnvelopeFieldSignature, updateEnvelopeFieldInitials, uploadEnvelopeFieldAttachment, deleteEnvelopeFieldAttachment, getFieldAttachment, getEnvelopeDocumentPageDisplayUri, throttledGetEnvelope, ITimeRange, IListEnvelopesParams, listEnvelopes, getEnvelopesByTemplateId, createInitials, updateRecipient, envelopeRecipientSubmit, envelopeRecipientDecline, envelopeRecipientChangeOwner, envelopeRecipientAgree, envelopeRecipientUpdateName, envelopeRecipientPrepare, ISignerTokenResponse, getSignerToken, getInPersonLink, sendDelegate, resendInvitation, createEnvelopeReminder, getEnvelopeReminder, updateEnvelopeReminder, deleteEnvelopeReminder, userIsEnvelopeOwner, userIsEnvelopeRecipient, envelopeIsActive, envelopeIsComplete, userCanCancelEnvelope, userCanFinishEnvelope, recipientHasAction, getRecipientsWithActions, recipientCanAct, userCanAct, userCanSignNow, getNextRecipient, createSignature, getSignatures, getSignature, deleteSignature, IEnvelopesSearchResultEntry, IEnvelopesSearchResult, IEnvelopesSummary, IDocumentSearchOptions, ICreateEnvelopeRole, IEnvelopeSummary, IEnvelopeSummaries, IInPersonLinkResponse, IUpdateRecipientSubmitParams, IUpdateRecipientDeclineParams, IUpdateRecipientClaimEnvelope, IUpdateRecipientStatus, IUpdateRecipientAgreedParams, IUpdateRecipientNameParams, IUpdateRecipientPrepareParams, ICreateEnvelopeReminderRequest, ICreateEnvelopeRequest, TEnvelopePermission, getApiKeys, createApiKey, rotateApiKey, updateApiKey, deleteApiKey, getGroups, getGroupByName, getGroup, getGroupMembers, addGroupMembers, deleteGroupMembers, addGroupPermission, deleteGroupPermission, getOrganizationInvitations, createOrganizationInvitation, deleteOrganizationInvitation, updateOrganizationInvitation, resendOrganizationInvitation, getOrganizationInvitation, acceptOrganizationInvitation, declineOrganizationInvitation, claimNewUser, getOrganizationMembers, deleteOrganizationMember, addOrganizationMemberRole, deleteOrganizationMemberRole, getOrganizationMemberPlans, getOrganizations, createOrganization, deleteOrganization, getOrganization, updateOrganization, ICreateApiKeyRequest, IUpdateApiKeyRequest, ICreateInvitationRequest, ISetWebhookRequest, getWebhooks, setWebhooks, userHasPermissions, ISigningSessionRequest, ISigningSession, IUserSession, 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, ICreateTemplateReminderRequest, createTemplateReminder, getTemplateReminder, updateTemplateReminder, deleteTemplateReminder, createTemplateRole, getTemplateRoles, getTemplateRole, updateTemplateRole, deleteTemplateRole, getTemplateRoleFields, getStars, toggleStar, addTemplateTag, getTemplateTags, deleteTemplateTag, createTag, getTag, getAllTags, IGetTemplatesParams, getTemplates, getTemplate, getTemplateOwnerInfo, IDocumentFromUri, IDocumentFromData, ITemplateCreateParams, createTemplate, createTemplatev2, ITemplateCreateFromSharepointParams, createTemplateFromSharepoint, updateTemplate, deleteTemplate, searchTemplates, ISearchTimeRange, IGetTemplateSummarySortBy, IGetTemplateSummaryParams, getTemplatesSummary, throttledGetTemplate, ITemplateListParams, listTemplates, getTemplateDocuments, getTemplateDocument, createTemplateDocument, deleteTemplateDocument, getTemplateDocumentFile, getTemplateDocumentThumbnail, getTemplateDocumentPageDisplayUri, ITemplateSummary, ITemplateSearchParams, ITemplateSummaries, ITemplateTag, ITag, IStar, ITemplateOwnerInfo, ITemplateSearchResult, IValidator, getValidators, getValidator, isValidEmail, isValidPhone, isValidRoleName, isValidTag, authenticateUser, authenticateApp, validateToken, refreshTokens, updatePassword, resetPassword, updateEmail, resendVerification, createUser, billingPlaceholder, getNotifications, getProfiles, getCurrentProfile, getRoles, createProfile, getProfile, getProfileGroups, switchProfile, updateProfile, deleteProfile, createBusinessAccount, ISignupSurvey, recordSignupSurvey, ICreateProfileRequest, ISwitchProfileResponse, IUpdateProfileRequest, IAuthenticateUserRequest, IAuthenticateAppRequest, IAuthenticateResponse, TokenValidationRequest, TokenValidationResponse, IUpdatePasswordRequest, UpdatePasswordResponse, UpdateEmailRequest, UpdateEmailResponse, ICreateBusinessAccountRequest, ICreateUserRequest, getRGB, getRGBA, nameToRGBA, getRoleColor, formatShortTimeAgo, timePeriod, 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, AtoB, decodeJWTBody, decodeAccessTokenBody, IFileWithData, ICountry, ITimePeriod };
package/dist/index.d.ts CHANGED
@@ -302,8 +302,8 @@ interface IEnvelopeField {
302
302
  /** The type of the field */
303
303
  type: TFieldType;
304
304
  /** If true, the field will be required */
305
- required: boolean;
306
- settings?: IEnvelopeFieldSettings;
305
+ required: boolean | null;
306
+ settings: IEnvelopeFieldSettings | null;
307
307
  validator: string | null;
308
308
  /** If set, the placeholder/label for the field. */
309
309
  label: string | null;
@@ -596,7 +596,7 @@ interface ITemplateField {
596
596
  document_id: string;
597
597
  type: TFieldType;
598
598
  required: boolean;
599
- settings: ITemplateFieldSetting;
599
+ settings: ITemplateFieldSetting | null;
600
600
  page: number;
601
601
  validator: string | null;
602
602
  label: string | null;
@@ -1863,6 +1863,73 @@ declare const updateField: (endpoint: VerdocsEndpoint, templateId: string, field
1863
1863
  * REmove a field from a template.
1864
1864
  */
1865
1865
  declare const deleteField: (endpoint: VerdocsEndpoint, templateId: string, fieldName: string) => Promise<any>;
1866
+ /**
1867
+ * Check to see if the user created the template.
1868
+ */
1869
+ declare const userIsTemplateCreator: (session: TSession, template: ITemplate | ITemplateSummary) => boolean | null;
1870
+ /**
1871
+ * Check to see if a template is "shared" with the user.
1872
+ */
1873
+ declare const userHasSharedTemplate: (session: TSession, template: ITemplate | ITemplateSummary) => boolean | null;
1874
+ /**
1875
+ * Check to see if the user can create a personal/private template.
1876
+ */
1877
+ declare const userCanCreatePersonalTemplate: (session: TSession) => boolean;
1878
+ /**
1879
+ * Check to see if the user can create an org-shared template.
1880
+ */
1881
+ declare const userCanCreateOrgTemplate: (session: TSession) => boolean;
1882
+ /**
1883
+ * Check to see if the user can create a public template.
1884
+ */
1885
+ declare const userCanCreatePublicTemplate: (session: TSession) => boolean;
1886
+ /**
1887
+ * Check to see if the user can read/view a template.
1888
+ */
1889
+ declare const userCanReadTemplate: (session: TSession, template: ITemplate | ITemplateSummary) => boolean | null;
1890
+ /**
1891
+ * Check to see if the user can update a tempate.
1892
+ */
1893
+ declare const userCanUpdateTemplate: (session: TSession, template: ITemplate | ITemplateSummary) => boolean | null;
1894
+ /**
1895
+ * Check to see if the user can change whether a template is personal vs org-shared.
1896
+ */
1897
+ declare const userCanMakeTemplatePrivate: (session: TSession, template: ITemplate | ITemplateSummary) => boolean;
1898
+ /**
1899
+ * Check to see if the user can change whether a template is personal vs org-shared.
1900
+ */
1901
+ declare const userCanMakeTemplateShared: (session: TSession, template: ITemplate | ITemplateSummary) => boolean;
1902
+ /**
1903
+ * Check to see if the user can change whether a template is personal vs org-shared.
1904
+ */
1905
+ declare const userCanMakeTemplatePublic: (session: TSession, template: ITemplate | ITemplateSummary) => boolean;
1906
+ /**
1907
+ * Check to see if the user can change whether a template is personal vs org-shared.
1908
+ */
1909
+ declare const userCanChangeOrgVisibility: (session: TSession, template: ITemplate | ITemplateSummary) => boolean | null;
1910
+ /**
1911
+ * Check to see if the user can change whether a template is personal vs org-shared.
1912
+ */
1913
+ declare const userCanDeleteTemplate: (session: TSession, template: ITemplate | ITemplateSummary) => boolean;
1914
+ /**
1915
+ * Confirm whether the user can create an envelope using the specified template.
1916
+ */
1917
+ declare const userCanSendTemplate: (session: TSession, template: ITemplate | ITemplateSummary) => boolean | null;
1918
+ /**
1919
+ * Confirm whether the user can create a new template.
1920
+ */
1921
+ declare const userCanCreateTemplate: (session: TSession) => boolean;
1922
+ /**
1923
+ * Check to see if the user can "build" the template (use the field builder). The user must have write access to the
1924
+ * template, and the template must have at least one signer role.
1925
+ */
1926
+ declare const userCanBuildTemplate: (session: TSession, template: ITemplate) => boolean | null;
1927
+ declare const getFieldsForRole: (template: ITemplate, role_name: string) => ITemplateField[];
1928
+ /**
1929
+ * Check to see if the user can preview the template. The user must have read access to the template, the template must
1930
+ * have at least one signer, and every signer must have at least one field.
1931
+ */
1932
+ declare const userCanPreviewTemplate: (session: TSession, template: ITemplate) => boolean | null;
1866
1933
  interface ICreateTemplateReminderRequest {
1867
1934
  setup_time: number;
1868
1935
  interval_time: number;
@@ -2563,4 +2630,4 @@ interface ISignupSurvey {
2563
2630
  declare const recordSignupSurvey: (endpoint: VerdocsEndpoint, params: ISignupSurvey) => Promise<{
2564
2631
  status: "OK";
2565
2632
  }>;
2566
- export { TRequestStatus, TTemplateSenderType, TTemplatePermission, TTemplateAction, TAccountPermission, TOrgPermission, TApiKeyPermission, TPermission, TRecipientAction, TEnvelopeStatus, TRecipientStatus, TRecipientType, TPlan, TRole, TSortTemplateBy, TAccessKeyType, THistoryEvent, TEventDetail, TEnvelopeUpdateResult, TFieldType, IChannel, IDisabledChannel, INotification, IApiKey, IGroup, IGroupProfile, IOAuth2App, IOrganization, IOrganizationInvitation, IPendingWebhook, IProfile, IWebhookEvents, IWebhook, IInPersonAccessKey, IInAppAccessKey, IEmailAccessKey, ISMSAccessKey, TAccessKey, IEnvelope, IEnvelopeDocument, IEnvelopeField, IEnvelopeFieldOptions, IEnvelopeFieldSettings, IEnvelopeHistory, IInitial, IRecipient, IReminder, IRole, ISignature, ITemplate, ITemplateDocument, ITemplateField, ITextFieldSetting, ITemplateFieldSetting, IActivityEntry, TEnvironment, TSessionChangedListener, VerdocsEndpointOptions, VerdocsEndpoint, createEnvelope, getEnvelopesSummary, IEnvelopeSearchParams, searchEnvelopes, ISigningSessionResult, getSigningSession, getEnvelopeRecipients, getEnvelope, getEnvelopeDocument, getDocumentDownloadLink, getDocumentPreviewLink, cancelEnvelope, getEnvelopeFile, updateEnvelopeField, updateEnvelopeFieldSignature, updateEnvelopeFieldInitials, uploadEnvelopeFieldAttachment, deleteEnvelopeFieldAttachment, getFieldAttachment, getEnvelopeDocumentPageDisplayUri, throttledGetEnvelope, ITimeRange, IListEnvelopesParams, listEnvelopes, getEnvelopesByTemplateId, createInitials, updateRecipient, envelopeRecipientSubmit, envelopeRecipientDecline, envelopeRecipientChangeOwner, envelopeRecipientAgree, envelopeRecipientUpdateName, envelopeRecipientPrepare, ISignerTokenResponse, getSignerToken, getInPersonLink, sendDelegate, resendInvitation, createEnvelopeReminder, getEnvelopeReminder, updateEnvelopeReminder, deleteEnvelopeReminder, userIsEnvelopeOwner, userIsEnvelopeRecipient, envelopeIsActive, envelopeIsComplete, userCanCancelEnvelope, userCanFinishEnvelope, recipientHasAction, getRecipientsWithActions, recipientCanAct, userCanAct, userCanSignNow, getNextRecipient, createSignature, getSignatures, getSignature, deleteSignature, IEnvelopesSearchResultEntry, IEnvelopesSearchResult, IEnvelopesSummary, IDocumentSearchOptions, ICreateEnvelopeRole, IEnvelopeSummary, IEnvelopeSummaries, IInPersonLinkResponse, IUpdateRecipientSubmitParams, IUpdateRecipientDeclineParams, IUpdateRecipientClaimEnvelope, IUpdateRecipientStatus, IUpdateRecipientAgreedParams, IUpdateRecipientNameParams, IUpdateRecipientPrepareParams, ICreateEnvelopeReminderRequest, ICreateEnvelopeRequest, TEnvelopePermission, getApiKeys, createApiKey, rotateApiKey, updateApiKey, deleteApiKey, getGroups, getGroupByName, getGroup, getGroupMembers, addGroupMembers, deleteGroupMembers, addGroupPermission, deleteGroupPermission, getOrganizationInvitations, createOrganizationInvitation, deleteOrganizationInvitation, updateOrganizationInvitation, resendOrganizationInvitation, getOrganizationInvitation, acceptOrganizationInvitation, declineOrganizationInvitation, claimNewUser, getOrganizationMembers, deleteOrganizationMember, addOrganizationMemberRole, deleteOrganizationMemberRole, getOrganizationMemberPlans, getOrganizations, createOrganization, deleteOrganization, getOrganization, updateOrganization, ICreateApiKeyRequest, IUpdateApiKeyRequest, ICreateInvitationRequest, ISetWebhookRequest, getWebhooks, setWebhooks, userHasPermissions, ISigningSessionRequest, ISigningSession, IUserSession, TSessionType, TSession, TActiveSession, canPerformTemplateAction, hasRequiredPermissions, createField, updateField, deleteField, ICreateTemplateReminderRequest, createTemplateReminder, getTemplateReminder, updateTemplateReminder, deleteTemplateReminder, createTemplateRole, getTemplateRoles, getTemplateRole, updateTemplateRole, deleteTemplateRole, getTemplateRoleFields, getStars, toggleStar, addTemplateTag, getTemplateTags, deleteTemplateTag, createTag, getTag, getAllTags, IGetTemplatesParams, getTemplates, getTemplate, getTemplateOwnerInfo, IDocumentFromUri, IDocumentFromData, ITemplateCreateParams, createTemplate, createTemplatev2, ITemplateCreateFromSharepointParams, createTemplateFromSharepoint, updateTemplate, deleteTemplate, searchTemplates, ISearchTimeRange, IGetTemplateSummarySortBy, IGetTemplateSummaryParams, getTemplatesSummary, throttledGetTemplate, ITemplateListParams, listTemplates, getTemplateDocuments, getTemplateDocument, createTemplateDocument, deleteTemplateDocument, getTemplateDocumentFile, getTemplateDocumentThumbnail, getTemplateDocumentPageDisplayUri, ITemplateSummary, ITemplateSearchParams, ITemplateSummaries, ITemplateTag, ITag, IStar, ITemplateOwnerInfo, ITemplateSearchResult, IValidator, getValidators, getValidator, isValidEmail, isValidPhone, isValidRoleName, isValidTag, authenticateUser, authenticateApp, validateToken, refreshTokens, updatePassword, resetPassword, updateEmail, resendVerification, createUser, billingPlaceholder, getNotifications, getProfiles, getCurrentProfile, getRoles, createProfile, getProfile, getProfileGroups, switchProfile, updateProfile, deleteProfile, createBusinessAccount, ISignupSurvey, recordSignupSurvey, ICreateProfileRequest, ISwitchProfileResponse, IUpdateProfileRequest, IAuthenticateUserRequest, IAuthenticateAppRequest, IAuthenticateResponse, TokenValidationRequest, TokenValidationResponse, IUpdatePasswordRequest, UpdatePasswordResponse, UpdateEmailRequest, UpdateEmailResponse, ICreateBusinessAccountRequest, ICreateUserRequest, getRGB, getRGBA, nameToRGBA, getRoleColor, formatShortTimeAgo, timePeriod, 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, AtoB, decodeJWTBody, decodeAccessTokenBody, IFileWithData, ICountry, ITimePeriod };
2633
+ export { TRequestStatus, TTemplateSenderType, TTemplatePermission, TTemplateAction, TAccountPermission, TOrgPermission, TApiKeyPermission, TPermission, TRecipientAction, TEnvelopeStatus, TRecipientStatus, TRecipientType, TPlan, TRole, TSortTemplateBy, TAccessKeyType, THistoryEvent, TEventDetail, TEnvelopeUpdateResult, TFieldType, IChannel, IDisabledChannel, INotification, IApiKey, IGroup, IGroupProfile, IOAuth2App, IOrganization, IOrganizationInvitation, IPendingWebhook, IProfile, IWebhookEvents, IWebhook, IInPersonAccessKey, IInAppAccessKey, IEmailAccessKey, ISMSAccessKey, TAccessKey, IEnvelope, IEnvelopeDocument, IEnvelopeField, IEnvelopeFieldOptions, IEnvelopeFieldSettings, IEnvelopeHistory, IInitial, IRecipient, IReminder, IRole, ISignature, ITemplate, ITemplateDocument, ITemplateField, ITextFieldSetting, ITemplateFieldSetting, IActivityEntry, TEnvironment, TSessionChangedListener, VerdocsEndpointOptions, VerdocsEndpoint, createEnvelope, getEnvelopesSummary, IEnvelopeSearchParams, searchEnvelopes, ISigningSessionResult, getSigningSession, getEnvelopeRecipients, getEnvelope, getEnvelopeDocument, getDocumentDownloadLink, getDocumentPreviewLink, cancelEnvelope, getEnvelopeFile, updateEnvelopeField, updateEnvelopeFieldSignature, updateEnvelopeFieldInitials, uploadEnvelopeFieldAttachment, deleteEnvelopeFieldAttachment, getFieldAttachment, getEnvelopeDocumentPageDisplayUri, throttledGetEnvelope, ITimeRange, IListEnvelopesParams, listEnvelopes, getEnvelopesByTemplateId, createInitials, updateRecipient, envelopeRecipientSubmit, envelopeRecipientDecline, envelopeRecipientChangeOwner, envelopeRecipientAgree, envelopeRecipientUpdateName, envelopeRecipientPrepare, ISignerTokenResponse, getSignerToken, getInPersonLink, sendDelegate, resendInvitation, createEnvelopeReminder, getEnvelopeReminder, updateEnvelopeReminder, deleteEnvelopeReminder, userIsEnvelopeOwner, userIsEnvelopeRecipient, envelopeIsActive, envelopeIsComplete, userCanCancelEnvelope, userCanFinishEnvelope, recipientHasAction, getRecipientsWithActions, recipientCanAct, userCanAct, userCanSignNow, getNextRecipient, createSignature, getSignatures, getSignature, deleteSignature, IEnvelopesSearchResultEntry, IEnvelopesSearchResult, IEnvelopesSummary, IDocumentSearchOptions, ICreateEnvelopeRole, IEnvelopeSummary, IEnvelopeSummaries, IInPersonLinkResponse, IUpdateRecipientSubmitParams, IUpdateRecipientDeclineParams, IUpdateRecipientClaimEnvelope, IUpdateRecipientStatus, IUpdateRecipientAgreedParams, IUpdateRecipientNameParams, IUpdateRecipientPrepareParams, ICreateEnvelopeReminderRequest, ICreateEnvelopeRequest, TEnvelopePermission, getApiKeys, createApiKey, rotateApiKey, updateApiKey, deleteApiKey, getGroups, getGroupByName, getGroup, getGroupMembers, addGroupMembers, deleteGroupMembers, addGroupPermission, deleteGroupPermission, getOrganizationInvitations, createOrganizationInvitation, deleteOrganizationInvitation, updateOrganizationInvitation, resendOrganizationInvitation, getOrganizationInvitation, acceptOrganizationInvitation, declineOrganizationInvitation, claimNewUser, getOrganizationMembers, deleteOrganizationMember, addOrganizationMemberRole, deleteOrganizationMemberRole, getOrganizationMemberPlans, getOrganizations, createOrganization, deleteOrganization, getOrganization, updateOrganization, ICreateApiKeyRequest, IUpdateApiKeyRequest, ICreateInvitationRequest, ISetWebhookRequest, getWebhooks, setWebhooks, userHasPermissions, ISigningSessionRequest, ISigningSession, IUserSession, 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, ICreateTemplateReminderRequest, createTemplateReminder, getTemplateReminder, updateTemplateReminder, deleteTemplateReminder, createTemplateRole, getTemplateRoles, getTemplateRole, updateTemplateRole, deleteTemplateRole, getTemplateRoleFields, getStars, toggleStar, addTemplateTag, getTemplateTags, deleteTemplateTag, createTag, getTag, getAllTags, IGetTemplatesParams, getTemplates, getTemplate, getTemplateOwnerInfo, IDocumentFromUri, IDocumentFromData, ITemplateCreateParams, createTemplate, createTemplatev2, ITemplateCreateFromSharepointParams, createTemplateFromSharepoint, updateTemplate, deleteTemplate, searchTemplates, ISearchTimeRange, IGetTemplateSummarySortBy, IGetTemplateSummaryParams, getTemplatesSummary, throttledGetTemplate, ITemplateListParams, listTemplates, getTemplateDocuments, getTemplateDocument, createTemplateDocument, deleteTemplateDocument, getTemplateDocumentFile, getTemplateDocumentThumbnail, getTemplateDocumentPageDisplayUri, ITemplateSummary, ITemplateSearchParams, ITemplateSummaries, ITemplateTag, ITag, IStar, ITemplateOwnerInfo, ITemplateSearchResult, IValidator, getValidators, getValidator, isValidEmail, isValidPhone, isValidRoleName, isValidTag, authenticateUser, authenticateApp, validateToken, refreshTokens, updatePassword, resetPassword, updateEmail, resendVerification, createUser, billingPlaceholder, getNotifications, getProfiles, getCurrentProfile, getRoles, createProfile, getProfile, getProfileGroups, switchProfile, updateProfile, deleteProfile, createBusinessAccount, ISignupSurvey, recordSignupSurvey, ICreateProfileRequest, ISwitchProfileResponse, IUpdateProfileRequest, IAuthenticateUserRequest, IAuthenticateAppRequest, IAuthenticateResponse, TokenValidationRequest, TokenValidationResponse, IUpdatePasswordRequest, UpdatePasswordResponse, UpdateEmailRequest, UpdateEmailResponse, ICreateBusinessAccountRequest, ICreateUserRequest, getRGB, getRGBA, nameToRGBA, getRoleColor, formatShortTimeAgo, timePeriod, 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, AtoB, decodeJWTBody, decodeAccessTokenBody, IFileWithData, ICountry, ITimePeriod };
package/dist/index.js CHANGED
@@ -1896,6 +1896,104 @@ const deleteField = (endpoint, templateId, fieldName) => endpoint.api //
1896
1896
  .delete(`/templates/${templateId}/fields/${fieldName}`)
1897
1897
  .then((r) => r.data);
1898
1898
 
1899
+ /**
1900
+ * Various helpers to identify available operations for a template by a user.
1901
+ *
1902
+ * @module
1903
+ */
1904
+ /**
1905
+ * Check to see if the user created the template.
1906
+ */
1907
+ const userIsTemplateCreator = (session, template) => session && template && session.profile_id === template.profile_id;
1908
+ /**
1909
+ * Check to see if a template is "shared" with the user.
1910
+ */
1911
+ const userHasSharedTemplate = (session, template) => session && template && !template.is_personal && session.organization_id === template.organization_id;
1912
+ /**
1913
+ * Check to see if the user can create a personal/private template.
1914
+ */
1915
+ const userCanCreatePersonalTemplate = (session) => userHasPermissions(session, ['template:creator:create:personal']);
1916
+ /**
1917
+ * Check to see if the user can create an org-shared template.
1918
+ */
1919
+ const userCanCreateOrgTemplate = (session) => userHasPermissions(session, ['template:creator:create:org']);
1920
+ /**
1921
+ * Check to see if the user can create a public template.
1922
+ */
1923
+ const userCanCreatePublicTemplate = (session) => userHasPermissions(session, ['template:creator:create:public']);
1924
+ /**
1925
+ * Check to see if the user can read/view a template.
1926
+ */
1927
+ const userCanReadTemplate = (session, template) => template.is_public ||
1928
+ userIsTemplateCreator(session, template) ||
1929
+ (userHasSharedTemplate(session, template) && userHasPermissions(session, ['template:member:read']));
1930
+ /**
1931
+ * Check to see if the user can update a tempate.
1932
+ */
1933
+ const userCanUpdateTemplate = (session, template) => userIsTemplateCreator(session, template) ||
1934
+ (userHasSharedTemplate(session, template) && userHasPermissions(session, ['template:member:read', 'template:member:write']));
1935
+ /**
1936
+ * Check to see if the user can change whether a template is personal vs org-shared.
1937
+ */
1938
+ const userCanMakeTemplatePrivate = (session, template) => userIsTemplateCreator(session, template)
1939
+ ? userHasPermissions(session, ['template:creator:create:personal'])
1940
+ : userHasPermissions(session, ['template:member:visibility']);
1941
+ /**
1942
+ * Check to see if the user can change whether a template is personal vs org-shared.
1943
+ */
1944
+ const userCanMakeTemplateShared = (session, template) => userIsTemplateCreator(session, template)
1945
+ ? userHasPermissions(session, ['template:creator:create:org'])
1946
+ : userHasPermissions(session, ['template:member:visibility']);
1947
+ /**
1948
+ * Check to see if the user can change whether a template is personal vs org-shared.
1949
+ */
1950
+ const userCanMakeTemplatePublic = (session, template) => userIsTemplateCreator(session, template)
1951
+ ? userHasPermissions(session, ['template:creator:create:public'])
1952
+ : userHasPermissions(session, ['template:member:visibility']);
1953
+ /**
1954
+ * Check to see if the user can change whether a template is personal vs org-shared.
1955
+ */
1956
+ const userCanChangeOrgVisibility = (session, template) => userIsTemplateCreator(session, template) && userHasPermissions(session, ['template:creator:create:personal']);
1957
+ /**
1958
+ * Check to see if the user can change whether a template is personal vs org-shared.
1959
+ */
1960
+ const userCanDeleteTemplate = (session, template) => userIsTemplateCreator(session, template)
1961
+ ? userHasPermissions(session, ['template:creator:delete'])
1962
+ : userHasPermissions(session, ['template:member:delete']);
1963
+ /**
1964
+ * Confirm whether the user can create an envelope using the specified template.
1965
+ */
1966
+ const userCanSendTemplate = (session, template) => {
1967
+ switch (template.sender) {
1968
+ case 'creator':
1969
+ return userIsTemplateCreator(session, template);
1970
+ case 'organization_member':
1971
+ case 'organization_member_as_creator':
1972
+ return userIsTemplateCreator(session, template) || template.organization_id === session?.organization_id;
1973
+ default:
1974
+ return true;
1975
+ }
1976
+ };
1977
+ /**
1978
+ * Confirm whether the user can create a new template.
1979
+ */
1980
+ const userCanCreateTemplate = (session) => userCanCreatePersonalTemplate(session) || userCanCreateOrgTemplate(session) || userCanCreatePublicTemplate(session);
1981
+ /**
1982
+ * Check to see if the user can "build" the template (use the field builder). The user must have write access to the
1983
+ * template, and the template must have at least one signer role.
1984
+ */
1985
+ const userCanBuildTemplate = (session, template) => userCanUpdateTemplate(session, template) && (template.roles || []).filter((role) => role.type === 'signer').length > 0;
1986
+ const getFieldsForRole = (template, role_name) => (template.fields || []).filter((field) => field.role_name === role_name);
1987
+ /**
1988
+ * Check to see if the user can preview the template. The user must have read access to the template, the template must
1989
+ * have at least one signer, and every signer must have at least one field.
1990
+ */
1991
+ const userCanPreviewTemplate = (session, template) => {
1992
+ const hasPermission = userCanReadTemplate(session, template);
1993
+ const signers = (template.roles || []).filter((role) => role.type === 'signer');
1994
+ return hasPermission && signers.length > 0 && signers.every((signer) => getFieldsForRole(template, signer.name).length > 0);
1995
+ };
1996
+
1899
1997
  /**
1900
1998
  * Enable automatic reminders. setup_time is the number of days after the envelope is sent that the first reminder
1901
1999
  * should be sent. interval_time is the number of days between reminders.
@@ -2703,6 +2801,7 @@ exports.getEnvelopeReminder = getEnvelopeReminder;
2703
2801
  exports.getEnvelopesByTemplateId = getEnvelopesByTemplateId;
2704
2802
  exports.getEnvelopesSummary = getEnvelopesSummary;
2705
2803
  exports.getFieldAttachment = getFieldAttachment;
2804
+ exports.getFieldsForRole = getFieldsForRole;
2706
2805
  exports.getGroup = getGroup;
2707
2806
  exports.getGroupByName = getGroupByName;
2708
2807
  exports.getGroupMembers = getGroupMembers;
@@ -2805,11 +2904,27 @@ exports.updateTemplateReminder = updateTemplateReminder;
2805
2904
  exports.updateTemplateRole = updateTemplateRole;
2806
2905
  exports.uploadEnvelopeFieldAttachment = uploadEnvelopeFieldAttachment;
2807
2906
  exports.userCanAct = userCanAct;
2907
+ exports.userCanBuildTemplate = userCanBuildTemplate;
2808
2908
  exports.userCanCancelEnvelope = userCanCancelEnvelope;
2909
+ exports.userCanChangeOrgVisibility = userCanChangeOrgVisibility;
2910
+ exports.userCanCreateOrgTemplate = userCanCreateOrgTemplate;
2911
+ exports.userCanCreatePersonalTemplate = userCanCreatePersonalTemplate;
2912
+ exports.userCanCreatePublicTemplate = userCanCreatePublicTemplate;
2913
+ exports.userCanCreateTemplate = userCanCreateTemplate;
2914
+ exports.userCanDeleteTemplate = userCanDeleteTemplate;
2809
2915
  exports.userCanFinishEnvelope = userCanFinishEnvelope;
2916
+ exports.userCanMakeTemplatePrivate = userCanMakeTemplatePrivate;
2917
+ exports.userCanMakeTemplatePublic = userCanMakeTemplatePublic;
2918
+ exports.userCanMakeTemplateShared = userCanMakeTemplateShared;
2919
+ exports.userCanPreviewTemplate = userCanPreviewTemplate;
2920
+ exports.userCanReadTemplate = userCanReadTemplate;
2921
+ exports.userCanSendTemplate = userCanSendTemplate;
2810
2922
  exports.userCanSignNow = userCanSignNow;
2923
+ exports.userCanUpdateTemplate = userCanUpdateTemplate;
2811
2924
  exports.userHasPermissions = userHasPermissions;
2925
+ exports.userHasSharedTemplate = userHasSharedTemplate;
2812
2926
  exports.userIsEnvelopeOwner = userIsEnvelopeOwner;
2813
2927
  exports.userIsEnvelopeRecipient = userIsEnvelopeRecipient;
2928
+ exports.userIsTemplateCreator = userIsTemplateCreator;
2814
2929
  exports.validateToken = validateToken;
2815
2930
  //# sourceMappingURL=index.js.map