@verdocs/js-sdk 4.2.26 → 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
@@ -1,5 +1,80 @@
1
1
  import axios from 'axios';
2
2
 
3
+ const FIELD_TYPES = [
4
+ 'textbox',
5
+ 'signature',
6
+ 'initial',
7
+ 'date',
8
+ 'dropdown',
9
+ 'timestamp',
10
+ 'textarea',
11
+ 'checkbox',
12
+ 'radio',
13
+ 'attachment',
14
+ 'payment',
15
+ ];
16
+ const DEFAULT_FIELD_WIDTHS = {
17
+ signature: 71,
18
+ initial: 71,
19
+ date: 75,
20
+ timestamp: 130,
21
+ textbox: 150,
22
+ textarea: 150,
23
+ checkbox: 14,
24
+ checkbox_group: 14,
25
+ radio_button_group: 14,
26
+ radio: 14,
27
+ dropdown: 85,
28
+ attachment: 24,
29
+ payment: 24,
30
+ };
31
+ const DEFAULT_FIELD_HEIGHTS = {
32
+ signature: 36,
33
+ initial: 36,
34
+ date: 15,
35
+ timestamp: 15,
36
+ textbox: 15,
37
+ textarea: 41,
38
+ checkbox: 14,
39
+ checkbox_group: 14,
40
+ radio_button_group: 14,
41
+ radio: 14,
42
+ dropdown: 20,
43
+ attachment: 24,
44
+ payment: 24,
45
+ };
46
+ const DEFAULT_FIELD_SETTINGS = {
47
+ signature: { result: '' },
48
+ initial: { result: '' },
49
+ date: { width: 75, height: 15, result: '' },
50
+ timestamp: { width: 130, height: 15 },
51
+ textbox: { width: 150, height: 15, result: '', leading: 0, alignment: 0, upperCase: false },
52
+ textarea: { width: 150, height: 15, result: '', leading: 16, alignment: 0, upperCase: false },
53
+ checkbox: {},
54
+ checkbox_group: {
55
+ minimum_checked: 0,
56
+ maximum_checked: 1000,
57
+ options: [
58
+ // { id: `${field.name}-1`, value: 'Option 1', checked: false, x, y },
59
+ ],
60
+ },
61
+ radio_button_group: {
62
+ options: [
63
+ // { id: `${field.name}-1`, value: 'Option 1', selected: false, x, y }
64
+ ],
65
+ },
66
+ radio: {},
67
+ dropdown: {
68
+ width: 85,
69
+ height: 20,
70
+ value: null,
71
+ placeholder: 'Choose',
72
+ options: [{ id: 'option-1', value: 'Option 1' }],
73
+ },
74
+ attachment: {},
75
+ payment: {},
76
+ };
77
+
3
78
  /**
4
79
  * Given a `rgba(r,g,b,a)` string value, returns the hex equivalent, dropping the alpha channel.
5
80
  */
@@ -2297,21 +2372,39 @@ const hasRequiredPermissions = (profile, permissions) => permissions.every((perm
2297
2372
 
2298
2373
  /**
2299
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
+ * ```
2300
2381
  */
2301
2382
  const createField = (endpoint, templateId, params) => endpoint.api //
2302
- .post(`/templates/${templateId}/fields`, params)
2383
+ .post(`/v2/fields/${templateId}`, params)
2303
2384
  .then((r) => r.data);
2304
2385
  /**
2305
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
+ * ```
2306
2393
  */
2307
- const updateField = (endpoint, templateId, fieldName, params) => endpoint.api //
2308
- .put(`/templates/${templateId}/fields/${fieldName}`, params)
2394
+ const updateField = (endpoint, templateId, name, params) => endpoint.api //
2395
+ .patch(`/fields/${templateId}/${name}`, params)
2309
2396
  .then((r) => r.data);
2310
2397
  /**
2311
- * 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
+ * ```
2312
2405
  */
2313
- const deleteField = (endpoint, templateId, fieldName) => endpoint.api //
2314
- .delete(`/templates/${templateId}/fields/${fieldName}`)
2406
+ const deleteField = (endpoint, templateId, name) => endpoint.api //
2407
+ .delete(`/fields/${templateId}/${name}`)
2315
2408
  .then((r) => r.data);
2316
2409
 
2317
2410
  /**
@@ -2558,12 +2651,12 @@ const getAllTags = (endpoint) => endpoint.api //
2558
2651
  * Get all templates accessible by the caller, with optional filters.
2559
2652
  *
2560
2653
  * ```typescript
2561
- * import {Templates} from '@verdocs/js-sdk/Templates';
2654
+ * import {getTemplates} from '@verdocs/js-sdk/Templates';
2562
2655
  *
2563
- * await Templates.getTemplates((VerdocsEndpoint.getDefault());
2564
- * await Templates.getTemplates((VerdocsEndpoint.getDefault(), { is_starred: true });
2565
- * await Templates.getTemplates((VerdocsEndpoint.getDefault(), { is_creator: true });
2566
- * 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 });
2567
2660
  * ```
2568
2661
  */
2569
2662
  const getTemplates = (endpoint, params) => endpoint.api //
@@ -2582,9 +2675,9 @@ const getTemplates = (endpoint, params) => endpoint.api //
2582
2675
  * Lists all templates accessible by the caller, with optional filters.
2583
2676
  *
2584
2677
  * ```typescript
2585
- * import {Templates} from '@verdocs/js-sdk/Templates';
2678
+ * import {listTemplates} from '@verdocs/js-sdk/Templates';
2586
2679
  *
2587
- * await Templates.listTemplates((VerdocsEndpoint.getDefault(), { sharing: 'personal', sort: 'last_used_at' });
2680
+ * await listTemplates((VerdocsEndpoint.getDefault(), { sharing: 'personal', sort: 'last_used_at' });
2588
2681
  * ```
2589
2682
  */
2590
2683
  // export const listTemplates = (endpoint: VerdocsEndpoint, params?: IListTemplatesParams) =>
@@ -2595,9 +2688,9 @@ const getTemplates = (endpoint, params) => endpoint.api //
2595
2688
  * Get one template by its ID.
2596
2689
  *
2597
2690
  * ```typescript
2598
- * import {Templates} from '@verdocs/js-sdk/Templates';
2691
+ * import {getTemplate} from '@verdocs/js-sdk/Templates';
2599
2692
  *
2600
- * const template = await Templates.getTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2693
+ * const template = await getTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2601
2694
  * ```
2602
2695
  */
2603
2696
  const getTemplate = (endpoint, templateId) => endpoint.api //
@@ -2617,6 +2710,7 @@ const getTemplate = (endpoint, templateId) => endpoint.api //
2617
2710
  document.pages = document.page_numbers;
2618
2711
  }
2619
2712
  });
2713
+ // Temporary upgrade from legacy app
2620
2714
  template.fields?.forEach((field) => {
2621
2715
  if (field.setting) {
2622
2716
  field.settings = field.setting;
@@ -2637,9 +2731,9 @@ const ALLOWED_CREATE_FIELDS = [
2637
2731
  * Create a template.
2638
2732
  *
2639
2733
  * ```typescript
2640
- * import {Templates} from '@verdocs/js-sdk/Templates';
2734
+ * import {createTemplate} from '@verdocs/js-sdk/Templates';
2641
2735
  *
2642
- * const newTemplate = await Templates.createTemplatev2((VerdocsEndpoint.getDefault(), {...});
2736
+ * const newTemplate = await createTemplate((VerdocsEndpoint.getDefault(), {...});
2643
2737
  * ```
2644
2738
  */
2645
2739
  const createTemplate = (endpoint, params, onUploadProgress) => {
@@ -2671,9 +2765,9 @@ const createTemplate = (endpoint, params, onUploadProgress) => {
2671
2765
  * Create a template from a Sharepoint asset.
2672
2766
  *
2673
2767
  * ```typescript
2674
- * import {Templates} from '@verdocs/js-sdk/Templates';
2768
+ * import {createTemplateFromSharepoint} from '@verdocs/js-sdk/Templates';
2675
2769
  *
2676
- * const newTemplate = await Templates.createTemplateFromSharepoint((VerdocsEndpoint.getDefault(), {...});
2770
+ * const newTemplate = await createTemplateFromSharepoint((VerdocsEndpoint.getDefault(), {...});
2677
2771
  * ```
2678
2772
  */
2679
2773
  const createTemplateFromSharepoint = (endpoint, params) => {
@@ -2686,9 +2780,9 @@ const createTemplateFromSharepoint = (endpoint, params) => {
2686
2780
  * Update a template.
2687
2781
  *
2688
2782
  * ```typescript
2689
- * import {Templates} from '@verdocs/js-sdk/Templates';
2783
+ * import {updateTemplate} from '@verdocs/js-sdk/Templates';
2690
2784
  *
2691
- * 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' });
2692
2786
  * ```
2693
2787
  */
2694
2788
  const updateTemplate = (endpoint, templateId, params) => endpoint.api //
@@ -2698,33 +2792,21 @@ const updateTemplate = (endpoint, templateId, params) => endpoint.api //
2698
2792
  * Delete a template.
2699
2793
  *
2700
2794
  * ```typescript
2701
- * import {Templates} from '@verdocs/js-sdk/Templates';
2795
+ * import {deleteTemplate} from '@verdocs/js-sdk/Templates';
2702
2796
  *
2703
- * await Templates.deleteTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2797
+ * await deleteTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2704
2798
  * ```
2705
2799
  */
2706
2800
  const deleteTemplate = (endpoint, templateId) => endpoint.api //
2707
2801
  .delete(`/templates/${templateId}`)
2708
2802
  .then((r) => r.data);
2709
2803
  /**
2710
- * Search for templates matching various criteria.
2711
- *
2712
- * ```typescript
2713
- * import {Templates} from '@verdocs/js-sdk/Templates';
2714
- *
2715
- * const {result, page, total} = await Templates.search((VerdocsEndpoint.getDefault(), { ... });
2716
- * ```
2717
- */
2718
- const searchTemplates = async (endpoint, params) => endpoint.api //
2719
- .post('/templates/search', params)
2720
- .then((r) => r.data);
2721
- /**
2722
- * List templates.
2804
+ * List
2723
2805
  *
2724
2806
  * ```typescript
2725
2807
  * import {Templates} from '@verdocs/js-sdk/Templates';
2726
2808
  *
2727
- * 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' }); * ```
2728
2810
  */
2729
2811
  const listTemplates = async (endpoint, params = {}) => endpoint.api //
2730
2812
  .post('/templates/list', params)
@@ -2842,5 +2924,5 @@ const isValidRoleName = (value, roles) => roles.findIndex((role) => role.name ==
2842
2924
  const TagRegEx = /^[a-zA-Z0-9-]{0,32}$/;
2843
2925
  const isValidTag = (value, tags) => TagRegEx.test(value) || tags.findIndex((tag) => tag === value) !== -1;
2844
2926
 
2845
- export { AtoB, Countries, 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 };
2846
2928
  //# sourceMappingURL=index.mjs.map