@verdocs/js-sdk 4.2.27 → 4.2.28

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.mjs CHANGED
@@ -2372,21 +2372,39 @@ const hasRequiredPermissions = (profile, permissions) => permissions.every((perm
2372
2372
 
2373
2373
  /**
2374
2374
  * Add a field to a template.
2375
+ *
2376
+ * ```typescript
2377
+ * import {createField} from '@verdocs/js-sdk/Templates';
2378
+ *
2379
+ * await createField((VerdocsEndpoint.getDefault(), template_id, { ... });
2380
+ * ```
2375
2381
  */
2376
2382
  const createField = (endpoint, templateId, params) => endpoint.api //
2377
- .post(`/templates/${templateId}/fields`, params)
2383
+ .post(`/v2/fields/${templateId}`, params)
2378
2384
  .then((r) => r.data);
2379
2385
  /**
2380
2386
  * Update a template field.
2387
+ *
2388
+ * ```typescript
2389
+ * import {updateField} from '@verdocs/js-sdk/Templates';
2390
+ *
2391
+ * await updateField((VerdocsEndpoint.getDefault(), template_id, field_name, { ... });
2392
+ * ```
2381
2393
  */
2382
- const updateField = (endpoint, templateId, fieldName, params) => endpoint.api //
2383
- .put(`/templates/${templateId}/fields/${fieldName}`, params)
2394
+ const updateField = (endpoint, templateId, name, params) => endpoint.api //
2395
+ .patch(`/fields/${templateId}/${name}`, params)
2384
2396
  .then((r) => r.data);
2385
2397
  /**
2386
- * REmove a field from a template.
2398
+ * Remove a field from a template.
2399
+ *
2400
+ * ```typescript
2401
+ * import {deleteField} from '@verdocs/js-sdk/Templates';
2402
+ *
2403
+ * await deleteField((VerdocsEndpoint.getDefault(), template_id, field_name);
2404
+ * ```
2387
2405
  */
2388
- const deleteField = (endpoint, templateId, fieldName) => endpoint.api //
2389
- .delete(`/templates/${templateId}/fields/${fieldName}`)
2406
+ const deleteField = (endpoint, templateId, name) => endpoint.api //
2407
+ .delete(`/fields/${templateId}/${name}`)
2390
2408
  .then((r) => r.data);
2391
2409
 
2392
2410
  /**
@@ -2633,12 +2651,12 @@ const getAllTags = (endpoint) => endpoint.api //
2633
2651
  * Get all templates accessible by the caller, with optional filters.
2634
2652
  *
2635
2653
  * ```typescript
2636
- * import {Templates} from '@verdocs/js-sdk/Templates';
2654
+ * import {getTemplates} from '@verdocs/js-sdk/Templates';
2637
2655
  *
2638
- * await Templates.getTemplates((VerdocsEndpoint.getDefault());
2639
- * await Templates.getTemplates((VerdocsEndpoint.getDefault(), { is_starred: true });
2640
- * await Templates.getTemplates((VerdocsEndpoint.getDefault(), { is_creator: true });
2641
- * await Templates.getTemplates((VerdocsEndpoint.getDefault(), { is_organization: true });
2656
+ * await getTemplates((VerdocsEndpoint.getDefault());
2657
+ * await getTemplates((VerdocsEndpoint.getDefault(), { is_starred: true });
2658
+ * await getTemplates((VerdocsEndpoint.getDefault(), { is_creator: true });
2659
+ * await getTemplates((VerdocsEndpoint.getDefault(), { is_organization: true });
2642
2660
  * ```
2643
2661
  */
2644
2662
  const getTemplates = (endpoint, params) => endpoint.api //
@@ -2657,9 +2675,9 @@ const getTemplates = (endpoint, params) => endpoint.api //
2657
2675
  * Lists all templates accessible by the caller, with optional filters.
2658
2676
  *
2659
2677
  * ```typescript
2660
- * import {Templates} from '@verdocs/js-sdk/Templates';
2678
+ * import {listTemplates} from '@verdocs/js-sdk/Templates';
2661
2679
  *
2662
- * await Templates.listTemplates((VerdocsEndpoint.getDefault(), { sharing: 'personal', sort: 'last_used_at' });
2680
+ * await listTemplates((VerdocsEndpoint.getDefault(), { sharing: 'personal', sort: 'last_used_at' });
2663
2681
  * ```
2664
2682
  */
2665
2683
  // export const listTemplates = (endpoint: VerdocsEndpoint, params?: IListTemplatesParams) =>
@@ -2670,9 +2688,9 @@ const getTemplates = (endpoint, params) => endpoint.api //
2670
2688
  * Get one template by its ID.
2671
2689
  *
2672
2690
  * ```typescript
2673
- * import {Templates} from '@verdocs/js-sdk/Templates';
2691
+ * import {getTemplate} from '@verdocs/js-sdk/Templates';
2674
2692
  *
2675
- * const template = await Templates.getTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2693
+ * const template = await getTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2676
2694
  * ```
2677
2695
  */
2678
2696
  const getTemplate = (endpoint, templateId) => endpoint.api //
@@ -2692,6 +2710,7 @@ const getTemplate = (endpoint, templateId) => endpoint.api //
2692
2710
  document.pages = document.page_numbers;
2693
2711
  }
2694
2712
  });
2713
+ // Temporary upgrade from legacy app
2695
2714
  template.fields?.forEach((field) => {
2696
2715
  if (field.setting) {
2697
2716
  field.settings = field.setting;
@@ -2712,9 +2731,9 @@ const ALLOWED_CREATE_FIELDS = [
2712
2731
  * Create a template.
2713
2732
  *
2714
2733
  * ```typescript
2715
- * import {Templates} from '@verdocs/js-sdk/Templates';
2734
+ * import {createTemplate} from '@verdocs/js-sdk/Templates';
2716
2735
  *
2717
- * const newTemplate = await Templates.createTemplatev2((VerdocsEndpoint.getDefault(), {...});
2736
+ * const newTemplate = await createTemplate((VerdocsEndpoint.getDefault(), {...});
2718
2737
  * ```
2719
2738
  */
2720
2739
  const createTemplate = (endpoint, params, onUploadProgress) => {
@@ -2746,9 +2765,9 @@ const createTemplate = (endpoint, params, onUploadProgress) => {
2746
2765
  * Create a template from a Sharepoint asset.
2747
2766
  *
2748
2767
  * ```typescript
2749
- * import {Templates} from '@verdocs/js-sdk/Templates';
2768
+ * import {createTemplateFromSharepoint} from '@verdocs/js-sdk/Templates';
2750
2769
  *
2751
- * const newTemplate = await Templates.createTemplateFromSharepoint((VerdocsEndpoint.getDefault(), {...});
2770
+ * const newTemplate = await createTemplateFromSharepoint((VerdocsEndpoint.getDefault(), {...});
2752
2771
  * ```
2753
2772
  */
2754
2773
  const createTemplateFromSharepoint = (endpoint, params) => {
@@ -2761,9 +2780,9 @@ const createTemplateFromSharepoint = (endpoint, params) => {
2761
2780
  * Update a template.
2762
2781
  *
2763
2782
  * ```typescript
2764
- * import {Templates} from '@verdocs/js-sdk/Templates';
2783
+ * import {updateTemplate} from '@verdocs/js-sdk/Templates';
2765
2784
  *
2766
- * const updatedTemplate = await Templates.updateTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9', { name: 'New Name' });
2785
+ * const updatedTemplate = await updateTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9', { name: 'New Name' });
2767
2786
  * ```
2768
2787
  */
2769
2788
  const updateTemplate = (endpoint, templateId, params) => endpoint.api //
@@ -2773,33 +2792,21 @@ const updateTemplate = (endpoint, templateId, params) => endpoint.api //
2773
2792
  * Delete a template.
2774
2793
  *
2775
2794
  * ```typescript
2776
- * import {Templates} from '@verdocs/js-sdk/Templates';
2795
+ * import {deleteTemplate} from '@verdocs/js-sdk/Templates';
2777
2796
  *
2778
- * await Templates.deleteTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2797
+ * await deleteTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2779
2798
  * ```
2780
2799
  */
2781
2800
  const deleteTemplate = (endpoint, templateId) => endpoint.api //
2782
2801
  .delete(`/templates/${templateId}`)
2783
2802
  .then((r) => r.data);
2784
2803
  /**
2785
- * Search for templates matching various criteria.
2786
- *
2787
- * ```typescript
2788
- * import {Templates} from '@verdocs/js-sdk/Templates';
2789
- *
2790
- * const {result, page, total} = await Templates.search((VerdocsEndpoint.getDefault(), { ... });
2791
- * ```
2792
- */
2793
- const searchTemplates = async (endpoint, params) => endpoint.api //
2794
- .post('/templates/search', params)
2795
- .then((r) => r.data);
2796
- /**
2797
- * List templates.
2804
+ * List
2798
2805
  *
2799
2806
  * ```typescript
2800
2807
  * import {Templates} from '@verdocs/js-sdk/Templates';
2801
2808
  *
2802
- * const {totals, templates} = await Templates.listTemplates((VerdocsEndpoint.getDefault(), { q: 'test', sort: 'created_at' }); * ```
2809
+ * const {totals, templates} = await listTemplates((VerdocsEndpoint.getDefault(), { q: 'test', sort: 'created_at' }); * ```
2803
2810
  */
2804
2811
  const listTemplates = async (endpoint, params = {}) => endpoint.api //
2805
2812
  .post('/templates/list', params)
@@ -2917,5 +2924,5 @@ const isValidRoleName = (value, roles) => roles.findIndex((role) => role.name ==
2917
2924
  const TagRegEx = /^[a-zA-Z0-9-]{0,32}$/;
2918
2925
  const isValidTag = (value, tags) => TagRegEx.test(value) || tags.findIndex((tag) => tag === value) !== -1;
2919
2926
 
2920
- export { AtoB, Countries, DEFAULT_FIELD_HEIGHTS, DEFAULT_FIELD_SETTINGS, DEFAULT_FIELD_WIDTHS, FIELD_TYPES, RolePermissions, VerdocsEndpoint, acceptOrganizationInvitation, addGroupMember, addTemplateTag, authenticate, blobToBase64, canPerformTemplateAction, cancelEnvelope, capitalize, changePassword, convertToE164, createApiKey, createEnvelope, createEnvelopeReminder, createField, createGroup, createInitials, createOrganizationInvitation, createProfile, createSignature, createTag, createTemplate, createTemplateDocument, createTemplateFromSharepoint, createTemplateReminder, createTemplateRole, declineOrganizationInvitation, decodeAccessTokenBody, decodeJWTBody, deleteApiKey, deleteEnvelopeFieldAttachment, deleteEnvelopeReminder, deleteField, deleteGroupMember, deleteOrganizationInvitation, deleteOrganizationMember, 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, getEnvelopes, getEnvelopesSummary, getFieldAttachment, getFieldsForRole, getGroup, getGroups, getInPersonLink, getKbaStep, getMatchingCountry, getMyUser, getNextRecipient, getNotifications, getOrganization, getOrganizationInvitation, getOrganizationInvitations, getOrganizationMembers, getPlusOneCountry, getProfiles, getRGB, getRGBA, getRLeft, getRTop, getRValue, getRecipientsWithActions, getRoleColor, getSignature, getSignatures, getSignerToken, getSigningSession, getStars, getTag, getTemplate, getTemplateDocument, getTemplateDocumentFile, getTemplateDocumentPageDisplayUri, getTemplateDocumentThumbnail, getTemplateDocuments, getTemplateReminder, getTemplateTags, getTemplates, getValidator, getValidators, getWebhooks, hasRequiredPermissions, integerSequence, isAmericanSamoa, isCanada, isDominicanRepublic, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, isPuertoRico, isValidEmail, isValidPhone, isValidRoleName, isValidTag, listTemplates, nameToRGBA, recipientCanAct, recipientHasAction, refreshToken, rescale, resendInvitation, resendOrganizationInvitation, resendVerification, resetPassword, rotateApiKey, searchTemplates, sendDelegate, setWebhooks, submitKbaChallengeResponse, submitKbaIdentity, submitKbaPin, switchProfile, timePeriod, toggleStar, updateApiKey, updateEnvelopeField, updateEnvelopeFieldInitials, updateEnvelopeFieldSignature, updateEnvelopeReminder, updateField, updateGroup, updateOrganization, updateOrganizationInvitation, updateOrganizationLogo, updateOrganizationMember, updateOrganizationThumbnail, updateProfile, updateProfilePhoto, 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, verifyEmail };
2927
+ export { AtoB, Countries, DEFAULT_FIELD_HEIGHTS, DEFAULT_FIELD_SETTINGS, DEFAULT_FIELD_WIDTHS, FIELD_TYPES, RolePermissions, VerdocsEndpoint, acceptOrganizationInvitation, addGroupMember, addTemplateTag, authenticate, blobToBase64, canPerformTemplateAction, cancelEnvelope, capitalize, changePassword, convertToE164, createApiKey, createEnvelope, createEnvelopeReminder, createField, createGroup, createInitials, createOrganizationInvitation, createProfile, createSignature, createTag, createTemplate, createTemplateDocument, createTemplateFromSharepoint, createTemplateReminder, createTemplateRole, declineOrganizationInvitation, decodeAccessTokenBody, decodeJWTBody, deleteApiKey, deleteEnvelopeFieldAttachment, deleteEnvelopeReminder, deleteField, deleteGroupMember, deleteOrganizationInvitation, deleteOrganizationMember, 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, getEnvelopes, getEnvelopesSummary, getFieldAttachment, getFieldsForRole, getGroup, getGroups, getInPersonLink, getKbaStep, getMatchingCountry, getMyUser, getNextRecipient, getNotifications, getOrganization, getOrganizationInvitation, getOrganizationInvitations, getOrganizationMembers, getPlusOneCountry, getProfiles, getRGB, getRGBA, getRLeft, getRTop, getRValue, getRecipientsWithActions, getRoleColor, getSignature, getSignatures, getSignerToken, getSigningSession, getStars, getTag, getTemplate, getTemplateDocument, getTemplateDocumentFile, getTemplateDocumentPageDisplayUri, getTemplateDocumentThumbnail, getTemplateDocuments, getTemplateReminder, getTemplateTags, getTemplates, getValidator, getValidators, getWebhooks, hasRequiredPermissions, integerSequence, isAmericanSamoa, isCanada, isDominicanRepublic, isFrenchGuiana, isGuadeloupe, isMartinique, isMayotte, isPuertoRico, isValidEmail, isValidPhone, isValidRoleName, isValidTag, listTemplates, nameToRGBA, recipientCanAct, recipientHasAction, refreshToken, rescale, resendInvitation, resendOrganizationInvitation, resendVerification, resetPassword, rotateApiKey, sendDelegate, setWebhooks, submitKbaChallengeResponse, submitKbaIdentity, submitKbaPin, switchProfile, timePeriod, toggleStar, updateApiKey, updateEnvelopeField, updateEnvelopeFieldInitials, updateEnvelopeFieldSignature, updateEnvelopeReminder, updateField, updateGroup, updateOrganization, updateOrganizationInvitation, updateOrganizationLogo, updateOrganizationMember, updateOrganizationThumbnail, updateProfile, updateProfilePhoto, 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, verifyEmail };
2921
2928
  //# sourceMappingURL=index.mjs.map