@verdocs/js-sdk 4.0.10 → 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 +68 -1
- package/dist/index.d.ts +68 -1
- package/dist/index.js +115 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +99 -1
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1894,6 +1894,104 @@ const deleteField = (endpoint, templateId, fieldName) => endpoint.api //
|
|
|
1894
1894
|
.delete(`/templates/${templateId}/fields/${fieldName}`)
|
|
1895
1895
|
.then((r) => r.data);
|
|
1896
1896
|
|
|
1897
|
+
/**
|
|
1898
|
+
* Various helpers to identify available operations for a template by a user.
|
|
1899
|
+
*
|
|
1900
|
+
* @module
|
|
1901
|
+
*/
|
|
1902
|
+
/**
|
|
1903
|
+
* Check to see if the user created the template.
|
|
1904
|
+
*/
|
|
1905
|
+
const userIsTemplateCreator = (session, template) => session && template && session.profile_id === template.profile_id;
|
|
1906
|
+
/**
|
|
1907
|
+
* Check to see if a template is "shared" with the user.
|
|
1908
|
+
*/
|
|
1909
|
+
const userHasSharedTemplate = (session, template) => session && template && !template.is_personal && session.organization_id === template.organization_id;
|
|
1910
|
+
/**
|
|
1911
|
+
* Check to see if the user can create a personal/private template.
|
|
1912
|
+
*/
|
|
1913
|
+
const userCanCreatePersonalTemplate = (session) => userHasPermissions(session, ['template:creator:create:personal']);
|
|
1914
|
+
/**
|
|
1915
|
+
* Check to see if the user can create an org-shared template.
|
|
1916
|
+
*/
|
|
1917
|
+
const userCanCreateOrgTemplate = (session) => userHasPermissions(session, ['template:creator:create:org']);
|
|
1918
|
+
/**
|
|
1919
|
+
* Check to see if the user can create a public template.
|
|
1920
|
+
*/
|
|
1921
|
+
const userCanCreatePublicTemplate = (session) => userHasPermissions(session, ['template:creator:create:public']);
|
|
1922
|
+
/**
|
|
1923
|
+
* Check to see if the user can read/view a template.
|
|
1924
|
+
*/
|
|
1925
|
+
const userCanReadTemplate = (session, template) => template.is_public ||
|
|
1926
|
+
userIsTemplateCreator(session, template) ||
|
|
1927
|
+
(userHasSharedTemplate(session, template) && userHasPermissions(session, ['template:member:read']));
|
|
1928
|
+
/**
|
|
1929
|
+
* Check to see if the user can update a tempate.
|
|
1930
|
+
*/
|
|
1931
|
+
const userCanUpdateTemplate = (session, template) => userIsTemplateCreator(session, template) ||
|
|
1932
|
+
(userHasSharedTemplate(session, template) && userHasPermissions(session, ['template:member:read', 'template:member:write']));
|
|
1933
|
+
/**
|
|
1934
|
+
* Check to see if the user can change whether a template is personal vs org-shared.
|
|
1935
|
+
*/
|
|
1936
|
+
const userCanMakeTemplatePrivate = (session, template) => userIsTemplateCreator(session, template)
|
|
1937
|
+
? userHasPermissions(session, ['template:creator:create:personal'])
|
|
1938
|
+
: userHasPermissions(session, ['template:member:visibility']);
|
|
1939
|
+
/**
|
|
1940
|
+
* Check to see if the user can change whether a template is personal vs org-shared.
|
|
1941
|
+
*/
|
|
1942
|
+
const userCanMakeTemplateShared = (session, template) => userIsTemplateCreator(session, template)
|
|
1943
|
+
? userHasPermissions(session, ['template:creator:create:org'])
|
|
1944
|
+
: userHasPermissions(session, ['template:member:visibility']);
|
|
1945
|
+
/**
|
|
1946
|
+
* Check to see if the user can change whether a template is personal vs org-shared.
|
|
1947
|
+
*/
|
|
1948
|
+
const userCanMakeTemplatePublic = (session, template) => userIsTemplateCreator(session, template)
|
|
1949
|
+
? userHasPermissions(session, ['template:creator:create:public'])
|
|
1950
|
+
: userHasPermissions(session, ['template:member:visibility']);
|
|
1951
|
+
/**
|
|
1952
|
+
* Check to see if the user can change whether a template is personal vs org-shared.
|
|
1953
|
+
*/
|
|
1954
|
+
const userCanChangeOrgVisibility = (session, template) => userIsTemplateCreator(session, template) && userHasPermissions(session, ['template:creator:create:personal']);
|
|
1955
|
+
/**
|
|
1956
|
+
* Check to see if the user can change whether a template is personal vs org-shared.
|
|
1957
|
+
*/
|
|
1958
|
+
const userCanDeleteTemplate = (session, template) => userIsTemplateCreator(session, template)
|
|
1959
|
+
? userHasPermissions(session, ['template:creator:delete'])
|
|
1960
|
+
: userHasPermissions(session, ['template:member:delete']);
|
|
1961
|
+
/**
|
|
1962
|
+
* Confirm whether the user can create an envelope using the specified template.
|
|
1963
|
+
*/
|
|
1964
|
+
const userCanSendTemplate = (session, template) => {
|
|
1965
|
+
switch (template.sender) {
|
|
1966
|
+
case 'creator':
|
|
1967
|
+
return userIsTemplateCreator(session, template);
|
|
1968
|
+
case 'organization_member':
|
|
1969
|
+
case 'organization_member_as_creator':
|
|
1970
|
+
return userIsTemplateCreator(session, template) || template.organization_id === session?.organization_id;
|
|
1971
|
+
default:
|
|
1972
|
+
return true;
|
|
1973
|
+
}
|
|
1974
|
+
};
|
|
1975
|
+
/**
|
|
1976
|
+
* Confirm whether the user can create a new template.
|
|
1977
|
+
*/
|
|
1978
|
+
const userCanCreateTemplate = (session) => userCanCreatePersonalTemplate(session) || userCanCreateOrgTemplate(session) || userCanCreatePublicTemplate(session);
|
|
1979
|
+
/**
|
|
1980
|
+
* Check to see if the user can "build" the template (use the field builder). The user must have write access to the
|
|
1981
|
+
* template, and the template must have at least one signer role.
|
|
1982
|
+
*/
|
|
1983
|
+
const userCanBuildTemplate = (session, template) => userCanUpdateTemplate(session, template) && (template.roles || []).filter((role) => role.type === 'signer').length > 0;
|
|
1984
|
+
const getFieldsForRole = (template, role_name) => (template.fields || []).filter((field) => field.role_name === role_name);
|
|
1985
|
+
/**
|
|
1986
|
+
* Check to see if the user can preview the template. The user must have read access to the template, the template must
|
|
1987
|
+
* have at least one signer, and every signer must have at least one field.
|
|
1988
|
+
*/
|
|
1989
|
+
const userCanPreviewTemplate = (session, template) => {
|
|
1990
|
+
const hasPermission = userCanReadTemplate(session, template);
|
|
1991
|
+
const signers = (template.roles || []).filter((role) => role.type === 'signer');
|
|
1992
|
+
return hasPermission && signers.length > 0 && signers.every((signer) => getFieldsForRole(template, signer.name).length > 0);
|
|
1993
|
+
};
|
|
1994
|
+
|
|
1897
1995
|
/**
|
|
1898
1996
|
* Enable automatic reminders. setup_time is the number of days after the envelope is sent that the first reminder
|
|
1899
1997
|
* should be sent. interval_time is the number of days between reminders.
|
|
@@ -2617,5 +2715,5 @@ const recordSignupSurvey = (endpoint, params) => endpoint.api //
|
|
|
2617
2715
|
.post('/user/signup', params)
|
|
2618
2716
|
.then((r) => r.data);
|
|
2619
2717
|
|
|
2620
|
-
export { AtoB, Countries, VerdocsEndpoint, acceptOrganizationInvitation, addGroupMembers, addGroupPermission, addOrganizationMemberRole, addTemplateTag, authenticateApp, authenticateUser, billingPlaceholder, blobToBase64, canPerformTemplateAction, cancelEnvelope, capitalize, claimNewUser, convertToE164, createApiKey, createBusinessAccount, createEnvelope, createEnvelopeReminder, createField, createInitials, createOrganization, createOrganizationInvitation, createProfile, createSignature, createTag, createTemplate, createTemplateDocument, createTemplateFromSharepoint, createTemplateReminder, createTemplateRole, createTemplatev2, createUser, declineOrganizationInvitation, decodeAccessTokenBody, decodeJWTBody, deleteApiKey, deleteEnvelopeFieldAttachment, deleteEnvelopeReminder, deleteField, deleteGroupMembers, deleteGroupPermission, deleteOrganization, deleteOrganizationInvitation, deleteOrganizationMember, deleteOrganizationMemberRole, deleteProfile, deleteSignature, deleteTemplate, deleteTemplateDocument, deleteTemplateReminder, deleteTemplateRole, deleteTemplateTag, downloadBlob, envelopeIsActive, envelopeIsComplete, envelopeRecipientAgree, envelopeRecipientChangeOwner, envelopeRecipientDecline, envelopeRecipientPrepare, envelopeRecipientSubmit, envelopeRecipientUpdateName, fileToDataUrl, formatFullName, formatInitials, formatShortTimeAgo, fullNameToInitials, getAllTags, getApiKeys, getCountryByCode, getCurrentProfile, getDocumentDownloadLink, getDocumentPreviewLink, getEnvelope, getEnvelopeDocument, getEnvelopeDocumentPageDisplayUri, getEnvelopeFile, getEnvelopeRecipients, getEnvelopeReminder, getEnvelopesByTemplateId, getEnvelopesSummary, getFieldAttachment, getGroup, getGroupByName, getGroupMembers, getGroups, getInPersonLink, getMatchingCountry, getNextRecipient, getNotifications, getOrganization, getOrganizationInvitation, getOrganizationInvitations, getOrganizationMemberPlans, getOrganizationMembers, getOrganizations, getPlusOneCountry, getProfile, getProfileGroups, getProfiles, getRGB, getRGBA, getRLeft, getRTop, getRValue, getRecipientsWithActions, getRoleColor, getRoles, getSignature, getSignatures, getSignerToken, getSigningSession, getStars, getTag, getTemplate, getTemplateDocument, getTemplateDocumentFile, getTemplateDocumentPageDisplayUri, getTemplateDocumentThumbnail, getTemplateDocuments, getTemplateOwnerInfo, getTemplateReminder, getTemplateRole, getTemplateRoleFields, getTemplateRoles, getTemplateTags, getTemplates, getTemplatesSummary, getValidator, getValidators, getWebhooks, hasRequiredPermissions, integerSequence, isAmericanSamoa, isCanada, isDominicanRepublic, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, isPuertoRico, isValidEmail, isValidPhone, isValidRoleName, isValidTag, listEnvelopes, listTemplates, nameToRGBA, recipientCanAct, recipientHasAction, recordSignupSurvey, refreshTokens, rescale, resendInvitation, resendOrganizationInvitation, resendVerification, resetPassword, rotateApiKey, searchEnvelopes, searchTemplates, sendDelegate, setWebhooks, switchProfile, throttledGetEnvelope, throttledGetTemplate, timePeriod, toggleStar, updateApiKey, updateEmail, updateEnvelopeField, updateEnvelopeFieldInitials, updateEnvelopeFieldSignature, updateEnvelopeReminder, updateField, updateOrganization, updateOrganizationInvitation, updatePassword, updateProfile, updateRecipient, updateTemplate, updateTemplateReminder, updateTemplateRole, uploadEnvelopeFieldAttachment, userCanAct, userCanCancelEnvelope, userCanFinishEnvelope, userCanSignNow, userHasPermissions, userIsEnvelopeOwner, userIsEnvelopeRecipient, validateToken };
|
|
2718
|
+
export { AtoB, Countries, VerdocsEndpoint, acceptOrganizationInvitation, addGroupMembers, addGroupPermission, addOrganizationMemberRole, addTemplateTag, authenticateApp, authenticateUser, billingPlaceholder, blobToBase64, canPerformTemplateAction, cancelEnvelope, capitalize, claimNewUser, convertToE164, createApiKey, createBusinessAccount, createEnvelope, createEnvelopeReminder, createField, createInitials, createOrganization, createOrganizationInvitation, createProfile, createSignature, createTag, createTemplate, createTemplateDocument, createTemplateFromSharepoint, createTemplateReminder, createTemplateRole, createTemplatev2, createUser, declineOrganizationInvitation, decodeAccessTokenBody, decodeJWTBody, deleteApiKey, deleteEnvelopeFieldAttachment, deleteEnvelopeReminder, deleteField, deleteGroupMembers, deleteGroupPermission, deleteOrganization, deleteOrganizationInvitation, deleteOrganizationMember, deleteOrganizationMemberRole, deleteProfile, deleteSignature, deleteTemplate, deleteTemplateDocument, deleteTemplateReminder, deleteTemplateRole, deleteTemplateTag, downloadBlob, envelopeIsActive, envelopeIsComplete, envelopeRecipientAgree, envelopeRecipientChangeOwner, envelopeRecipientDecline, envelopeRecipientPrepare, envelopeRecipientSubmit, envelopeRecipientUpdateName, fileToDataUrl, formatFullName, formatInitials, formatShortTimeAgo, fullNameToInitials, getAllTags, getApiKeys, getCountryByCode, getCurrentProfile, getDocumentDownloadLink, getDocumentPreviewLink, getEnvelope, getEnvelopeDocument, getEnvelopeDocumentPageDisplayUri, getEnvelopeFile, getEnvelopeRecipients, getEnvelopeReminder, getEnvelopesByTemplateId, getEnvelopesSummary, getFieldAttachment, getFieldsForRole, getGroup, getGroupByName, getGroupMembers, getGroups, getInPersonLink, getMatchingCountry, getNextRecipient, getNotifications, getOrganization, getOrganizationInvitation, getOrganizationInvitations, getOrganizationMemberPlans, getOrganizationMembers, getOrganizations, getPlusOneCountry, getProfile, getProfileGroups, getProfiles, getRGB, getRGBA, getRLeft, getRTop, getRValue, getRecipientsWithActions, getRoleColor, getRoles, getSignature, getSignatures, getSignerToken, getSigningSession, getStars, getTag, getTemplate, getTemplateDocument, getTemplateDocumentFile, getTemplateDocumentPageDisplayUri, getTemplateDocumentThumbnail, getTemplateDocuments, getTemplateOwnerInfo, getTemplateReminder, getTemplateRole, getTemplateRoleFields, getTemplateRoles, getTemplateTags, getTemplates, getTemplatesSummary, getValidator, getValidators, getWebhooks, hasRequiredPermissions, integerSequence, isAmericanSamoa, isCanada, isDominicanRepublic, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, isPuertoRico, isValidEmail, isValidPhone, isValidRoleName, isValidTag, listEnvelopes, listTemplates, nameToRGBA, recipientCanAct, recipientHasAction, recordSignupSurvey, refreshTokens, rescale, resendInvitation, resendOrganizationInvitation, resendVerification, resetPassword, rotateApiKey, searchEnvelopes, searchTemplates, sendDelegate, setWebhooks, switchProfile, throttledGetEnvelope, throttledGetTemplate, timePeriod, toggleStar, updateApiKey, updateEmail, updateEnvelopeField, updateEnvelopeFieldInitials, updateEnvelopeFieldSignature, updateEnvelopeReminder, updateField, updateOrganization, updateOrganizationInvitation, updatePassword, updateProfile, updateRecipient, updateTemplate, updateTemplateReminder, updateTemplateRole, uploadEnvelopeFieldAttachment, userCanAct, userCanBuildTemplate, userCanCancelEnvelope, userCanChangeOrgVisibility, userCanCreateOrgTemplate, userCanCreatePersonalTemplate, userCanCreatePublicTemplate, userCanCreateTemplate, userCanDeleteTemplate, userCanFinishEnvelope, userCanMakeTemplatePrivate, userCanMakeTemplatePublic, userCanMakeTemplateShared, userCanPreviewTemplate, userCanReadTemplate, userCanSendTemplate, userCanSignNow, userCanUpdateTemplate, userHasPermissions, userHasSharedTemplate, userIsEnvelopeOwner, userIsEnvelopeRecipient, userIsTemplateCreator, validateToken };
|
|
2621
2719
|
//# sourceMappingURL=index.mjs.map
|