@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.d.ts CHANGED
@@ -847,8 +847,6 @@ interface ITemplateField {
847
847
  placeholder: string | null;
848
848
  /** For fields that support grouping (radio buttons and check boxes) the value selected will be stored under this name. */
849
849
  group: string | null;
850
- // @deprecated. Use settings instead.
851
- setting?: ITemplateFieldSetting | null;
852
850
  }
853
851
  interface ITextFieldSetting {
854
852
  x: number;
@@ -892,7 +890,11 @@ type THistoryEvent = "recipient:signed" | "recipient:opened" | "recipient:submit
892
890
  type TEventDetail = "in_app" | "mail" | "signer" | "sms" | "reminder" | "preparer" | "manual" | "in_person_link" | "guest" | "email" | "" | string; // Modification events have a string description
893
891
  // Modification events have a string description
894
892
  type TEnvelopeUpdateResult = Omit<IEnvelope, "histories" | "recipients" | "certificate" | "document" | "fields" | "profile">;
895
- type TFieldType = "signature" | "initial" | "checkbox_group" | "radio_button_group" | "textbox" | "timestamp" | "date" | "dropdown" | "textarea" | "attachment" | "payment";
893
+ type TFieldType = "signature" | "initial" | "checkbox_group" | "checkbox" | "radio_button_group" | "radio" | "textbox" | "timestamp" | "date" | "dropdown" | "textarea" | "attachment" | "payment";
894
+ declare const FIELD_TYPES: TFieldType[];
895
+ declare const DEFAULT_FIELD_WIDTHS: Record<TFieldType, number>;
896
+ declare const DEFAULT_FIELD_HEIGHTS: Record<TFieldType, number>;
897
+ declare const DEFAULT_FIELD_SETTINGS: Record<TFieldType, ITemplateFieldSetting>;
896
898
  type TEnvironment = "verdocs" | "verdocs-stage";
897
899
  type TSessionChangedListener = (endpoint: VerdocsEndpoint, session: TSession, profile: IProfile | null) => void;
898
900
  interface VerdocsEndpointOptions {
@@ -2107,16 +2109,34 @@ declare const canPerformTemplateAction: (profile: IProfile | null | undefined, a
2107
2109
  declare const hasRequiredPermissions: (profile: IProfile | null | undefined, permissions: TPermission[]) => boolean;
2108
2110
  /**
2109
2111
  * Add a field to a template.
2112
+ *
2113
+ * ```typescript
2114
+ * import {createField} from '@verdocs/js-sdk/Templates';
2115
+ *
2116
+ * await createField((VerdocsEndpoint.getDefault(), template_id, { ... });
2117
+ * ```
2110
2118
  */
2111
2119
  declare const createField: (endpoint: VerdocsEndpoint, templateId: string, params: ITemplateField) => Promise<ITemplateField>;
2112
2120
  /**
2113
2121
  * Update a template field.
2122
+ *
2123
+ * ```typescript
2124
+ * import {updateField} from '@verdocs/js-sdk/Templates';
2125
+ *
2126
+ * await updateField((VerdocsEndpoint.getDefault(), template_id, field_name, { ... });
2127
+ * ```
2114
2128
  */
2115
- declare const updateField: (endpoint: VerdocsEndpoint, templateId: string, fieldName: string, params: Partial<ITemplateField>) => Promise<ITemplateField>;
2129
+ declare const updateField: (endpoint: VerdocsEndpoint, templateId: string, name: string, params: Partial<ITemplateField>) => Promise<ITemplateField>;
2116
2130
  /**
2117
- * REmove a field from a template.
2131
+ * Remove a field from a template.
2132
+ *
2133
+ * ```typescript
2134
+ * import {deleteField} from '@verdocs/js-sdk/Templates';
2135
+ *
2136
+ * await deleteField((VerdocsEndpoint.getDefault(), template_id, field_name);
2137
+ * ```
2118
2138
  */
2119
- declare const deleteField: (endpoint: VerdocsEndpoint, templateId: string, fieldName: string) => Promise<any>;
2139
+ declare const deleteField: (endpoint: VerdocsEndpoint, templateId: string, name: string) => Promise<any>;
2120
2140
  /**
2121
2141
  * Check to see if the user created the template.
2122
2142
  */
@@ -2235,6 +2255,58 @@ declare const updateTemplateRole: (endpoint: VerdocsEndpoint, template_id: strin
2235
2255
  * ```
2236
2256
  */
2237
2257
  declare const deleteTemplateRole: (endpoint: VerdocsEndpoint, template_id: string, name: string) => Promise<any>;
2258
+ interface ITemplateTag {
2259
+ tag_name: string;
2260
+ template_id: string;
2261
+ }
2262
+ interface ITag {
2263
+ name: string;
2264
+ featured?: boolean;
2265
+ organization_id?: string;
2266
+ created_at?: string;
2267
+ }
2268
+ interface IStar {
2269
+ template_id: string;
2270
+ profile_id: string;
2271
+ }
2272
+ interface ITemplateSearchResult {
2273
+ page: number;
2274
+ row: number;
2275
+ total: number;
2276
+ result: ITemplate[];
2277
+ }
2278
+ /**
2279
+ * Get the template stars for a template.
2280
+ */
2281
+ declare const getStars: (endpoint: VerdocsEndpoint, templateId: string) => Promise<IStar[]>;
2282
+ /**
2283
+ * Toggle the template star for a template.
2284
+ */
2285
+ declare const toggleStar: (endpoint: VerdocsEndpoint, templateId: string) => Promise<ITemplate>;
2286
+ /**
2287
+ * Apply a tag to a template.
2288
+ */
2289
+ declare const addTemplateTag: (endpoint: VerdocsEndpoint, templateId: string, params: ITag) => Promise<ITemplateTag>;
2290
+ /**
2291
+ * Get all tags for a template.
2292
+ */
2293
+ declare const getTemplateTags: (endpoint: VerdocsEndpoint, templateId: string) => Promise<ITemplateTag[]>;
2294
+ /**
2295
+ * Remove a tag from a template.
2296
+ */
2297
+ declare const deleteTemplateTag: (endpoint: VerdocsEndpoint, templateId: string, tagName: string) => Promise<any>;
2298
+ /**
2299
+ * Create an Organization-wide tag.
2300
+ */
2301
+ declare const createTag: (endpoint: VerdocsEndpoint, name: string) => Promise<ITag>;
2302
+ /**
2303
+ * Get an Organization-wide tag.
2304
+ */
2305
+ declare const getTag: (endpoint: VerdocsEndpoint, name: string) => Promise<ITag>;
2306
+ /**
2307
+ * Get all tags available for use by an Organization.
2308
+ */
2309
+ declare const getAllTags: (endpoint: VerdocsEndpoint) => Promise<ITag[]>;
2238
2310
  /**
2239
2311
  * Given a `rgba(r,g,b,a)` string value, returns the hex equivalent, dropping the alpha channel.
2240
2312
  */
@@ -2341,77 +2413,6 @@ declare const decodeJWTBody: (token: string) => any;
2341
2413
  * the presence of the `document_id` field, which will only be present for signing sessions.
2342
2414
  */
2343
2415
  declare const decodeAccessTokenBody: (token: string) => TSession;
2344
- interface ITemplateSearchParams {
2345
- id?: string;
2346
- name?: string;
2347
- sender?: string;
2348
- description?: string;
2349
- profile_id?: string;
2350
- organization_id?: string;
2351
- updated_at?: ITimePeriod;
2352
- created_at?: ITimePeriod;
2353
- last_used_at?: ITimePeriod;
2354
- is_personal?: boolean;
2355
- is_public?: boolean;
2356
- tags?: string[];
2357
- document_name?: string;
2358
- sort_by?: TSortTemplateBy;
2359
- ascending?: boolean;
2360
- row?: number;
2361
- page?: number;
2362
- }
2363
- interface ITemplateTag {
2364
- tag_name: string;
2365
- template_id: string;
2366
- }
2367
- interface ITag {
2368
- name: string;
2369
- featured?: boolean;
2370
- organization_id?: string;
2371
- created_at?: string;
2372
- }
2373
- interface IStar {
2374
- template_id: string;
2375
- profile_id: string;
2376
- }
2377
- interface ITemplateSearchResult {
2378
- page: number;
2379
- row: number;
2380
- total: number;
2381
- result: ITemplate[];
2382
- }
2383
- /**
2384
- * Get the template stars for a template.
2385
- */
2386
- declare const getStars: (endpoint: VerdocsEndpoint, templateId: string) => Promise<IStar[]>;
2387
- /**
2388
- * Toggle the template star for a template.
2389
- */
2390
- declare const toggleStar: (endpoint: VerdocsEndpoint, templateId: string) => Promise<ITemplate>;
2391
- /**
2392
- * Apply a tag to a template.
2393
- */
2394
- declare const addTemplateTag: (endpoint: VerdocsEndpoint, templateId: string, params: ITag) => Promise<ITemplateTag>;
2395
- /**
2396
- * Get all tags for a template.
2397
- */
2398
- declare const getTemplateTags: (endpoint: VerdocsEndpoint, templateId: string) => Promise<ITemplateTag[]>;
2399
- /**
2400
- * Remove a tag from a template.
2401
- */
2402
- declare const deleteTemplateTag: (endpoint: VerdocsEndpoint, templateId: string, tagName: string) => Promise<any>;
2403
- /**
2404
- * Create an Organization-wide tag.
2405
- */
2406
- declare const createTag: (endpoint: VerdocsEndpoint, name: string) => Promise<ITag>;
2407
- /**
2408
- * Get an Organization-wide tag.
2409
- */
2410
- declare const getTag: (endpoint: VerdocsEndpoint, name: string) => Promise<ITag>;
2411
- /**
2412
- * Get all tags available for use by an Organization.
2413
- */
2414
- declare const getAllTags: (endpoint: VerdocsEndpoint) => Promise<ITag[]>;
2415
2416
  interface IGetTemplatesParams {
2416
2417
  is_starred?: boolean;
2417
2418
  is_creator?: boolean;
@@ -2421,12 +2422,12 @@ interface IGetTemplatesParams {
2421
2422
  * Get all templates accessible by the caller, with optional filters.
2422
2423
  *
2423
2424
  * ```typescript
2424
- * import {Templates} from '@verdocs/js-sdk/Templates';
2425
+ * import {getTemplates} from '@verdocs/js-sdk/Templates';
2425
2426
  *
2426
- * await Templates.getTemplates((VerdocsEndpoint.getDefault());
2427
- * await Templates.getTemplates((VerdocsEndpoint.getDefault(), { is_starred: true });
2428
- * await Templates.getTemplates((VerdocsEndpoint.getDefault(), { is_creator: true });
2429
- * await Templates.getTemplates((VerdocsEndpoint.getDefault(), { is_organization: true });
2427
+ * await getTemplates((VerdocsEndpoint.getDefault());
2428
+ * await getTemplates((VerdocsEndpoint.getDefault(), { is_starred: true });
2429
+ * await getTemplates((VerdocsEndpoint.getDefault(), { is_creator: true });
2430
+ * await getTemplates((VerdocsEndpoint.getDefault(), { is_organization: true });
2430
2431
  * ```
2431
2432
  */
2432
2433
  declare const getTemplates: (endpoint: VerdocsEndpoint, params?: IGetTemplatesParams) => Promise<ITemplate[]>;
@@ -2443,9 +2444,9 @@ declare const getTemplates: (endpoint: VerdocsEndpoint, params?: IGetTemplatesPa
2443
2444
  * Lists all templates accessible by the caller, with optional filters.
2444
2445
  *
2445
2446
  * ```typescript
2446
- * import {Templates} from '@verdocs/js-sdk/Templates';
2447
+ * import {listTemplates} from '@verdocs/js-sdk/Templates';
2447
2448
  *
2448
- * await Templates.listTemplates((VerdocsEndpoint.getDefault(), { sharing: 'personal', sort: 'last_used_at' });
2449
+ * await listTemplates((VerdocsEndpoint.getDefault(), { sharing: 'personal', sort: 'last_used_at' });
2449
2450
  * ```
2450
2451
  */
2451
2452
  // export const listTemplates = (endpoint: VerdocsEndpoint, params?: IListTemplatesParams) =>
@@ -2456,9 +2457,9 @@ declare const getTemplates: (endpoint: VerdocsEndpoint, params?: IGetTemplatesPa
2456
2457
  * Get one template by its ID.
2457
2458
  *
2458
2459
  * ```typescript
2459
- * import {Templates} from '@verdocs/js-sdk/Templates';
2460
+ * import {getTemplate} from '@verdocs/js-sdk/Templates';
2460
2461
  *
2461
- * const template = await Templates.getTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2462
+ * const template = await getTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2462
2463
  * ```
2463
2464
  */
2464
2465
  declare const getTemplate: (endpoint: VerdocsEndpoint, templateId: string) => Promise<ITemplate>;
@@ -2520,9 +2521,9 @@ interface ITemplateCreateParams {
2520
2521
  * Create a template.
2521
2522
  *
2522
2523
  * ```typescript
2523
- * import {Templates} from '@verdocs/js-sdk/Templates';
2524
+ * import {createTemplate} from '@verdocs/js-sdk/Templates';
2524
2525
  *
2525
- * const newTemplate = await Templates.createTemplatev2((VerdocsEndpoint.getDefault(), {...});
2526
+ * const newTemplate = await createTemplate((VerdocsEndpoint.getDefault(), {...});
2526
2527
  * ```
2527
2528
  */
2528
2529
  declare const createTemplate: (endpoint: VerdocsEndpoint, params: ITemplateCreateParams, onUploadProgress?: (percent: number, loadedBytes: number, totalBytes: number) => void) => Promise<ITemplate>;
@@ -2544,9 +2545,9 @@ interface ITemplateCreateFromSharepointParams {
2544
2545
  * Create a template from a Sharepoint asset.
2545
2546
  *
2546
2547
  * ```typescript
2547
- * import {Templates} from '@verdocs/js-sdk/Templates';
2548
+ * import {createTemplateFromSharepoint} from '@verdocs/js-sdk/Templates';
2548
2549
  *
2549
- * const newTemplate = await Templates.createTemplateFromSharepoint((VerdocsEndpoint.getDefault(), {...});
2550
+ * const newTemplate = await createTemplateFromSharepoint((VerdocsEndpoint.getDefault(), {...});
2550
2551
  * ```
2551
2552
  */
2552
2553
  declare const createTemplateFromSharepoint: (endpoint: VerdocsEndpoint, params: ITemplateCreateFromSharepointParams) => Promise<ITemplate>;
@@ -2554,9 +2555,9 @@ declare const createTemplateFromSharepoint: (endpoint: VerdocsEndpoint, params:
2554
2555
  * Update a template.
2555
2556
  *
2556
2557
  * ```typescript
2557
- * import {Templates} from '@verdocs/js-sdk/Templates';
2558
+ * import {updateTemplate} from '@verdocs/js-sdk/Templates';
2558
2559
  *
2559
- * const updatedTemplate = await Templates.updateTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9', { name: 'New Name' });
2560
+ * const updatedTemplate = await updateTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9', { name: 'New Name' });
2560
2561
  * ```
2561
2562
  */
2562
2563
  declare const updateTemplate: (endpoint: VerdocsEndpoint, templateId: string, params: Partial<ITemplateCreateParams>) => Promise<ITemplate>;
@@ -2564,22 +2565,12 @@ declare const updateTemplate: (endpoint: VerdocsEndpoint, templateId: string, pa
2564
2565
  * Delete a template.
2565
2566
  *
2566
2567
  * ```typescript
2567
- * import {Templates} from '@verdocs/js-sdk/Templates';
2568
+ * import {deleteTemplate} from '@verdocs/js-sdk/Templates';
2568
2569
  *
2569
- * await Templates.deleteTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2570
+ * await deleteTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2570
2571
  * ```
2571
2572
  */
2572
2573
  declare const deleteTemplate: (endpoint: VerdocsEndpoint, templateId: string) => Promise<any>;
2573
- /**
2574
- * Search for templates matching various criteria.
2575
- *
2576
- * ```typescript
2577
- * import {Templates} from '@verdocs/js-sdk/Templates';
2578
- *
2579
- * const {result, page, total} = await Templates.search((VerdocsEndpoint.getDefault(), { ... });
2580
- * ```
2581
- */
2582
- declare const searchTemplates: (endpoint: VerdocsEndpoint, params: ITemplateSearchParams) => Promise<ITemplateSearchResult>;
2583
2574
  interface ISearchTimeRange {
2584
2575
  start_time: string;
2585
2576
  end_time: string;
@@ -2615,12 +2606,12 @@ interface ITemplateListParams {
2615
2606
  page?: number;
2616
2607
  }
2617
2608
  /**
2618
- * List templates.
2609
+ * List
2619
2610
  *
2620
2611
  * ```typescript
2621
2612
  * import {Templates} from '@verdocs/js-sdk/Templates';
2622
2613
  *
2623
- * const {totals, templates} = await Templates.listTemplates((VerdocsEndpoint.getDefault(), { q: 'test', sort: 'created_at' }); * ```
2614
+ * const {totals, templates} = await listTemplates((VerdocsEndpoint.getDefault(), { q: 'test', sort: 'created_at' }); * ```
2624
2615
  */
2625
2616
  declare const listTemplates: (endpoint: VerdocsEndpoint, params?: ITemplateListParams) => Promise<{
2626
2617
  total: number;
@@ -2706,4 +2697,4 @@ declare const isValidEmail: (email: string | undefined) => boolean;
2706
2697
  declare const isValidPhone: (phone: string | undefined) => boolean;
2707
2698
  declare const isValidRoleName: (value: string, roles: IRole[]) => boolean;
2708
2699
  declare const isValidTag: (value: string, tags: string[]) => boolean;
2709
- export { TRequestStatus, TTemplateSenderType, TTemplateAction, TRecipientAction, TEnvelopeStatus, TRecipientStatus, TRecipientType, TSortTemplateBy, TAccessKeyType, TApiKeyPermission, THistoryEvent, TEventDetail, TEnvelopeUpdateResult, TFieldType, IChannel, IDisabledChannel, INotification, IApiKey, IGroup, IGroupProfile, IOAuth2App, IOrganization, IOrganizationInvitation, IPendingWebhook, IProfile, IUser, IWebhookEvents, IWebhook, IInPersonAccessKey, IInAppAccessKey, IEmailAccessKey, ISMSAccessKey, TAccessKey, IEnvelope, IEnvelopeDocument, IEnvelopeField, IEnvelopeFieldOptions, IEnvelopeFieldSettings, IEnvelopeHistory, IInitial, IKbaPINRequired, IRecipient, IReminder, IRole, ISignature, ITemplate, ITemplateDocument, ITemplateField, ITextFieldSetting, ITemplateFieldSetting, TEnvironment, TSessionChangedListener, VerdocsEndpointOptions, VerdocsEndpoint, createEnvelope, getEnvelopesSummary, getEnvelopeRecipients, getEnvelope, getEnvelopeDocument, getDocumentDownloadLink, getDocumentPreviewLink, cancelEnvelope, getEnvelopeFile, updateEnvelopeField, updateEnvelopeFieldSignature, updateEnvelopeFieldInitials, uploadEnvelopeFieldAttachment, deleteEnvelopeFieldAttachment, getFieldAttachment, getEnvelopeDocumentPageDisplayUri, ITimeRange, IListEnvelopesParams, getEnvelopes, createInitials, IRecipientKbaStepNone, IRecipientKbaStepComplete, IRecipientKbaStepPin, IRecipientKbaStepIdentity, IRecipientKbaStepChallenge, IRecipientKbaStepFailed, TRecipientKbaStep, getKbaStep, submitKbaPin, IKbaIdentity, submitKbaIdentity, IKbaChallengeResponse, submitKbaChallengeResponse, updateRecipient, envelopeRecipientSubmit, envelopeRecipientDecline, envelopeRecipientChangeOwner, envelopeRecipientAgree, envelopeRecipientUpdateName, envelopeRecipientPrepare, ISignerTokenResponse, getSigningSession, getSignerToken, getInPersonLink, sendDelegate, resendInvitation, createEnvelopeReminder, getEnvelopeReminder, updateEnvelopeReminder, deleteEnvelopeReminder, userIsEnvelopeOwner, userIsEnvelopeRecipient, envelopeIsActive, envelopeIsComplete, userCanCancelEnvelope, userCanFinishEnvelope, recipientHasAction, getRecipientsWithActions, recipientCanAct, userCanAct, userCanSignNow, getNextRecipient, createSignature, getSignatures, getSignature, deleteSignature, IEnvelopesSearchResult, IEnvelopesSummary, IDocumentSearchOptions, ICreateEnvelopeRole, IEnvelopeSummaries, IInPersonLinkResponse, IUpdateRecipientSubmitParams, IUpdateRecipientDeclineParams, IUpdateRecipientClaimEnvelope, IUpdateRecipientStatus, IUpdateRecipientAgreedParams, IUpdateRecipientNameParams, IUpdateRecipientPrepareParams, ICreateEnvelopeReminderRequest, ICreateEnvelopeRequest, getApiKeys, createApiKey, rotateApiKey, updateApiKey, deleteApiKey, getGroups, getGroup, createGroup, addGroupMember, deleteGroupMember, updateGroup, getOrganizationInvitations, createOrganizationInvitation, deleteOrganizationInvitation, updateOrganizationInvitation, resendOrganizationInvitation, getOrganizationInvitation, acceptOrganizationInvitation, declineOrganizationInvitation, getOrganizationMembers, deleteOrganizationMember, updateOrganizationMember, getOrganization, updateOrganization, updateOrganizationLogo, updateOrganizationThumbnail, ICreateApiKeyRequest, IUpdateApiKeyRequest, ICreateInvitationRequest, IAcceptOrganizationInvitationRequest, ISetWebhookRequest, getWebhooks, setWebhooks, TTemplatePermissionCreatePublic, TTemplatePermissionCreateOrg, TTemplatePermissionCreatePersonal, TTemplatePermissionDelete, TTemplatePermissionVisibility, TTemplateMemberRead, TTemplateMemberWrite, TTemplateMemberDelete, TTemplateMemberVisibility, TTemplatePermission, TAccountPermissionOwnerAdd, TAccountPermissionOwnerRemove, TAccountPermissionAdminAdd, TAccountPermissionAdminRemove, TAccountPermissionMemberView, TAccountPermissionMemberAdd, TAccountPermissionMemberRemove, TAccountPermission, TOrgPermissionCreate, TOrgPermissionView, TOrgPermissionUpdate, TOrgPermissionDelete, TOrgPermissionTransfer, TOrgPermissionList, TOrgPermission, TEnvelopePermissionCreate, TEnvelopePermissionCancel, TEnvelopePermissionView, TEnvelopePermissionOrg, TEnvelopePermission, TPermission, TRole, RolePermissions, userHasPermissions, ISigningSession, IUserSession, IIdToken, TSessionType, TSession, TActiveSession, canPerformTemplateAction, hasRequiredPermissions, createField, updateField, deleteField, userIsTemplateCreator, userHasSharedTemplate, userCanCreatePersonalTemplate, userCanCreateOrgTemplate, userCanCreatePublicTemplate, userCanReadTemplate, userCanUpdateTemplate, userCanMakeTemplatePrivate, userCanMakeTemplateShared, userCanMakeTemplatePublic, userCanChangeOrgVisibility, userCanDeleteTemplate, userCanSendTemplate, userCanCreateTemplate, userCanBuildTemplate, getFieldsForRole, userCanPreviewTemplate, ICreateTemplateReminderRequest, createTemplateReminder, getTemplateReminder, updateTemplateReminder, deleteTemplateReminder, createTemplateRole, updateTemplateRole, deleteTemplateRole, getStars, toggleStar, addTemplateTag, getTemplateTags, deleteTemplateTag, createTag, getTag, getAllTags, IGetTemplatesParams, getTemplates, getTemplate, IDocumentFromUri, IDocumentFromData, ITemplateCreateParams, createTemplate, ITemplateCreateFromSharepointParams, createTemplateFromSharepoint, updateTemplate, deleteTemplate, searchTemplates, ISearchTimeRange, IGetTemplateSummarySortBy, IGetTemplateSummaryParams, ITemplateListParams, listTemplates, getTemplateDocuments, getTemplateDocument, createTemplateDocument, deleteTemplateDocument, getTemplateDocumentFile, getTemplateDocumentThumbnail, getTemplateDocumentPageDisplayUri, ITemplateSearchParams, ITemplateTag, ITag, IStar, ITemplateSearchResult, IValidator, getValidators, getValidator, isValidEmail, isValidPhone, isValidRoleName, isValidTag, IROPCRequest, IClientCredentialsRequest, IRefreshTokenRequest, TAuthenticationRequest, authenticate, refreshToken, changePassword, resetPassword, resendVerification, verifyEmail, getMyUser, getNotifications, getProfiles, getCurrentProfile, switchProfile, updateProfile, deleteProfile, createProfile, updateProfilePhoto, ICreateProfileRequest, IUpdateProfileRequest, IAuthenticateResponse, IChangePasswordRequest, IChangePasswordResponse, IResetPasswordRequest, IResetPasswordResponse, IVerifyEmailRequest, getRGB, getRGBA, nameToRGBA, getRoleColor, formatShortTimeAgo, 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 };
2700
+ export { TRequestStatus, TTemplateSenderType, TTemplateAction, TRecipientAction, TEnvelopeStatus, TRecipientStatus, TRecipientType, TSortTemplateBy, TAccessKeyType, TApiKeyPermission, THistoryEvent, TEventDetail, TEnvelopeUpdateResult, TFieldType, FIELD_TYPES, DEFAULT_FIELD_WIDTHS, DEFAULT_FIELD_HEIGHTS, DEFAULT_FIELD_SETTINGS, IChannel, IDisabledChannel, INotification, IApiKey, IGroup, IGroupProfile, IOAuth2App, IOrganization, IOrganizationInvitation, IPendingWebhook, IProfile, IUser, IWebhookEvents, IWebhook, IInPersonAccessKey, IInAppAccessKey, IEmailAccessKey, ISMSAccessKey, TAccessKey, IEnvelope, IEnvelopeDocument, IEnvelopeField, IEnvelopeFieldOptions, IEnvelopeFieldSettings, IEnvelopeHistory, IInitial, IKbaPINRequired, IRecipient, IReminder, IRole, ISignature, ITemplate, ITemplateDocument, ITemplateField, ITextFieldSetting, ITemplateFieldSetting, TEnvironment, TSessionChangedListener, VerdocsEndpointOptions, VerdocsEndpoint, createEnvelope, getEnvelopesSummary, getEnvelopeRecipients, getEnvelope, getEnvelopeDocument, getDocumentDownloadLink, getDocumentPreviewLink, cancelEnvelope, getEnvelopeFile, updateEnvelopeField, updateEnvelopeFieldSignature, updateEnvelopeFieldInitials, uploadEnvelopeFieldAttachment, deleteEnvelopeFieldAttachment, getFieldAttachment, getEnvelopeDocumentPageDisplayUri, ITimeRange, IListEnvelopesParams, getEnvelopes, createInitials, IRecipientKbaStepNone, IRecipientKbaStepComplete, IRecipientKbaStepPin, IRecipientKbaStepIdentity, IRecipientKbaStepChallenge, IRecipientKbaStepFailed, TRecipientKbaStep, getKbaStep, submitKbaPin, IKbaIdentity, submitKbaIdentity, IKbaChallengeResponse, submitKbaChallengeResponse, updateRecipient, envelopeRecipientSubmit, envelopeRecipientDecline, envelopeRecipientChangeOwner, envelopeRecipientAgree, envelopeRecipientUpdateName, envelopeRecipientPrepare, ISignerTokenResponse, getSigningSession, getSignerToken, getInPersonLink, sendDelegate, resendInvitation, createEnvelopeReminder, getEnvelopeReminder, updateEnvelopeReminder, deleteEnvelopeReminder, userIsEnvelopeOwner, userIsEnvelopeRecipient, envelopeIsActive, envelopeIsComplete, userCanCancelEnvelope, userCanFinishEnvelope, recipientHasAction, getRecipientsWithActions, recipientCanAct, userCanAct, userCanSignNow, getNextRecipient, createSignature, getSignatures, getSignature, deleteSignature, IEnvelopesSearchResult, IEnvelopesSummary, IDocumentSearchOptions, ICreateEnvelopeRole, IEnvelopeSummaries, IInPersonLinkResponse, IUpdateRecipientSubmitParams, IUpdateRecipientDeclineParams, IUpdateRecipientClaimEnvelope, IUpdateRecipientStatus, IUpdateRecipientAgreedParams, IUpdateRecipientNameParams, IUpdateRecipientPrepareParams, ICreateEnvelopeReminderRequest, ICreateEnvelopeRequest, getApiKeys, createApiKey, rotateApiKey, updateApiKey, deleteApiKey, getGroups, getGroup, createGroup, addGroupMember, deleteGroupMember, updateGroup, getOrganizationInvitations, createOrganizationInvitation, deleteOrganizationInvitation, updateOrganizationInvitation, resendOrganizationInvitation, getOrganizationInvitation, acceptOrganizationInvitation, declineOrganizationInvitation, getOrganizationMembers, deleteOrganizationMember, updateOrganizationMember, getOrganization, updateOrganization, updateOrganizationLogo, updateOrganizationThumbnail, ICreateApiKeyRequest, IUpdateApiKeyRequest, ICreateInvitationRequest, IAcceptOrganizationInvitationRequest, ISetWebhookRequest, getWebhooks, setWebhooks, TTemplatePermissionCreatePublic, TTemplatePermissionCreateOrg, TTemplatePermissionCreatePersonal, TTemplatePermissionDelete, TTemplatePermissionVisibility, TTemplateMemberRead, TTemplateMemberWrite, TTemplateMemberDelete, TTemplateMemberVisibility, TTemplatePermission, TAccountPermissionOwnerAdd, TAccountPermissionOwnerRemove, TAccountPermissionAdminAdd, TAccountPermissionAdminRemove, TAccountPermissionMemberView, TAccountPermissionMemberAdd, TAccountPermissionMemberRemove, TAccountPermission, TOrgPermissionCreate, TOrgPermissionView, TOrgPermissionUpdate, TOrgPermissionDelete, TOrgPermissionTransfer, TOrgPermissionList, TOrgPermission, TEnvelopePermissionCreate, TEnvelopePermissionCancel, TEnvelopePermissionView, TEnvelopePermissionOrg, TEnvelopePermission, TPermission, TRole, RolePermissions, userHasPermissions, ISigningSession, IUserSession, IIdToken, TSessionType, TSession, TActiveSession, canPerformTemplateAction, hasRequiredPermissions, createField, updateField, deleteField, userIsTemplateCreator, userHasSharedTemplate, userCanCreatePersonalTemplate, userCanCreateOrgTemplate, userCanCreatePublicTemplate, userCanReadTemplate, userCanUpdateTemplate, userCanMakeTemplatePrivate, userCanMakeTemplateShared, userCanMakeTemplatePublic, userCanChangeOrgVisibility, userCanDeleteTemplate, userCanSendTemplate, userCanCreateTemplate, userCanBuildTemplate, getFieldsForRole, userCanPreviewTemplate, ICreateTemplateReminderRequest, createTemplateReminder, getTemplateReminder, updateTemplateReminder, deleteTemplateReminder, createTemplateRole, updateTemplateRole, deleteTemplateRole, getStars, toggleStar, addTemplateTag, getTemplateTags, deleteTemplateTag, createTag, getTag, getAllTags, IGetTemplatesParams, getTemplates, getTemplate, IDocumentFromUri, IDocumentFromData, ITemplateCreateParams, createTemplate, ITemplateCreateFromSharepointParams, createTemplateFromSharepoint, updateTemplate, deleteTemplate, ISearchTimeRange, IGetTemplateSummarySortBy, IGetTemplateSummaryParams, ITemplateListParams, listTemplates, getTemplateDocuments, getTemplateDocument, createTemplateDocument, deleteTemplateDocument, getTemplateDocumentFile, getTemplateDocumentThumbnail, getTemplateDocumentPageDisplayUri, ITemplateTag, ITag, IStar, ITemplateSearchResult, IValidator, getValidators, getValidator, isValidEmail, isValidPhone, isValidRoleName, isValidTag, IROPCRequest, IClientCredentialsRequest, IRefreshTokenRequest, TAuthenticationRequest, authenticate, refreshToken, changePassword, resetPassword, resendVerification, verifyEmail, getMyUser, getNotifications, getProfiles, getCurrentProfile, switchProfile, updateProfile, deleteProfile, createProfile, updateProfilePhoto, ICreateProfileRequest, IUpdateProfileRequest, IAuthenticateResponse, IChangePasswordRequest, IChangePasswordResponse, IResetPasswordRequest, IResetPasswordResponse, IVerifyEmailRequest, getRGB, getRGBA, nameToRGBA, getRoleColor, formatShortTimeAgo, 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
@@ -2,6 +2,81 @@
2
2
 
3
3
  var axios = require('axios');
4
4
 
5
+ const FIELD_TYPES = [
6
+ 'textbox',
7
+ 'signature',
8
+ 'initial',
9
+ 'date',
10
+ 'dropdown',
11
+ 'timestamp',
12
+ 'textarea',
13
+ 'checkbox',
14
+ 'radio',
15
+ 'attachment',
16
+ 'payment',
17
+ ];
18
+ const DEFAULT_FIELD_WIDTHS = {
19
+ signature: 71,
20
+ initial: 71,
21
+ date: 75,
22
+ timestamp: 130,
23
+ textbox: 150,
24
+ textarea: 150,
25
+ checkbox: 14,
26
+ checkbox_group: 14,
27
+ radio_button_group: 14,
28
+ radio: 14,
29
+ dropdown: 85,
30
+ attachment: 24,
31
+ payment: 24,
32
+ };
33
+ const DEFAULT_FIELD_HEIGHTS = {
34
+ signature: 36,
35
+ initial: 36,
36
+ date: 15,
37
+ timestamp: 15,
38
+ textbox: 15,
39
+ textarea: 41,
40
+ checkbox: 14,
41
+ checkbox_group: 14,
42
+ radio_button_group: 14,
43
+ radio: 14,
44
+ dropdown: 20,
45
+ attachment: 24,
46
+ payment: 24,
47
+ };
48
+ const DEFAULT_FIELD_SETTINGS = {
49
+ signature: { result: '' },
50
+ initial: { result: '' },
51
+ date: { width: 75, height: 15, result: '' },
52
+ timestamp: { width: 130, height: 15 },
53
+ textbox: { width: 150, height: 15, result: '', leading: 0, alignment: 0, upperCase: false },
54
+ textarea: { width: 150, height: 15, result: '', leading: 16, alignment: 0, upperCase: false },
55
+ checkbox: {},
56
+ checkbox_group: {
57
+ minimum_checked: 0,
58
+ maximum_checked: 1000,
59
+ options: [
60
+ // { id: `${field.name}-1`, value: 'Option 1', checked: false, x, y },
61
+ ],
62
+ },
63
+ radio_button_group: {
64
+ options: [
65
+ // { id: `${field.name}-1`, value: 'Option 1', selected: false, x, y }
66
+ ],
67
+ },
68
+ radio: {},
69
+ dropdown: {
70
+ width: 85,
71
+ height: 20,
72
+ value: null,
73
+ placeholder: 'Choose',
74
+ options: [{ id: 'option-1', value: 'Option 1' }],
75
+ },
76
+ attachment: {},
77
+ payment: {},
78
+ };
79
+
5
80
  /**
6
81
  * Given a `rgba(r,g,b,a)` string value, returns the hex equivalent, dropping the alpha channel.
7
82
  */
@@ -2299,21 +2374,39 @@ const hasRequiredPermissions = (profile, permissions) => permissions.every((perm
2299
2374
 
2300
2375
  /**
2301
2376
  * Add a field to a template.
2377
+ *
2378
+ * ```typescript
2379
+ * import {createField} from '@verdocs/js-sdk/Templates';
2380
+ *
2381
+ * await createField((VerdocsEndpoint.getDefault(), template_id, { ... });
2382
+ * ```
2302
2383
  */
2303
2384
  const createField = (endpoint, templateId, params) => endpoint.api //
2304
- .post(`/templates/${templateId}/fields`, params)
2385
+ .post(`/v2/fields/${templateId}`, params)
2305
2386
  .then((r) => r.data);
2306
2387
  /**
2307
2388
  * Update a template field.
2389
+ *
2390
+ * ```typescript
2391
+ * import {updateField} from '@verdocs/js-sdk/Templates';
2392
+ *
2393
+ * await updateField((VerdocsEndpoint.getDefault(), template_id, field_name, { ... });
2394
+ * ```
2308
2395
  */
2309
- const updateField = (endpoint, templateId, fieldName, params) => endpoint.api //
2310
- .put(`/templates/${templateId}/fields/${fieldName}`, params)
2396
+ const updateField = (endpoint, templateId, name, params) => endpoint.api //
2397
+ .patch(`/fields/${templateId}/${name}`, params)
2311
2398
  .then((r) => r.data);
2312
2399
  /**
2313
- * REmove a field from a template.
2400
+ * Remove a field from a template.
2401
+ *
2402
+ * ```typescript
2403
+ * import {deleteField} from '@verdocs/js-sdk/Templates';
2404
+ *
2405
+ * await deleteField((VerdocsEndpoint.getDefault(), template_id, field_name);
2406
+ * ```
2314
2407
  */
2315
- const deleteField = (endpoint, templateId, fieldName) => endpoint.api //
2316
- .delete(`/templates/${templateId}/fields/${fieldName}`)
2408
+ const deleteField = (endpoint, templateId, name) => endpoint.api //
2409
+ .delete(`/fields/${templateId}/${name}`)
2317
2410
  .then((r) => r.data);
2318
2411
 
2319
2412
  /**
@@ -2560,12 +2653,12 @@ const getAllTags = (endpoint) => endpoint.api //
2560
2653
  * Get all templates accessible by the caller, with optional filters.
2561
2654
  *
2562
2655
  * ```typescript
2563
- * import {Templates} from '@verdocs/js-sdk/Templates';
2656
+ * import {getTemplates} from '@verdocs/js-sdk/Templates';
2564
2657
  *
2565
- * await Templates.getTemplates((VerdocsEndpoint.getDefault());
2566
- * await Templates.getTemplates((VerdocsEndpoint.getDefault(), { is_starred: true });
2567
- * await Templates.getTemplates((VerdocsEndpoint.getDefault(), { is_creator: true });
2568
- * await Templates.getTemplates((VerdocsEndpoint.getDefault(), { is_organization: true });
2658
+ * await getTemplates((VerdocsEndpoint.getDefault());
2659
+ * await getTemplates((VerdocsEndpoint.getDefault(), { is_starred: true });
2660
+ * await getTemplates((VerdocsEndpoint.getDefault(), { is_creator: true });
2661
+ * await getTemplates((VerdocsEndpoint.getDefault(), { is_organization: true });
2569
2662
  * ```
2570
2663
  */
2571
2664
  const getTemplates = (endpoint, params) => endpoint.api //
@@ -2584,9 +2677,9 @@ const getTemplates = (endpoint, params) => endpoint.api //
2584
2677
  * Lists all templates accessible by the caller, with optional filters.
2585
2678
  *
2586
2679
  * ```typescript
2587
- * import {Templates} from '@verdocs/js-sdk/Templates';
2680
+ * import {listTemplates} from '@verdocs/js-sdk/Templates';
2588
2681
  *
2589
- * await Templates.listTemplates((VerdocsEndpoint.getDefault(), { sharing: 'personal', sort: 'last_used_at' });
2682
+ * await listTemplates((VerdocsEndpoint.getDefault(), { sharing: 'personal', sort: 'last_used_at' });
2590
2683
  * ```
2591
2684
  */
2592
2685
  // export const listTemplates = (endpoint: VerdocsEndpoint, params?: IListTemplatesParams) =>
@@ -2597,9 +2690,9 @@ const getTemplates = (endpoint, params) => endpoint.api //
2597
2690
  * Get one template by its ID.
2598
2691
  *
2599
2692
  * ```typescript
2600
- * import {Templates} from '@verdocs/js-sdk/Templates';
2693
+ * import {getTemplate} from '@verdocs/js-sdk/Templates';
2601
2694
  *
2602
- * const template = await Templates.getTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2695
+ * const template = await getTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2603
2696
  * ```
2604
2697
  */
2605
2698
  const getTemplate = (endpoint, templateId) => endpoint.api //
@@ -2619,6 +2712,7 @@ const getTemplate = (endpoint, templateId) => endpoint.api //
2619
2712
  document.pages = document.page_numbers;
2620
2713
  }
2621
2714
  });
2715
+ // Temporary upgrade from legacy app
2622
2716
  template.fields?.forEach((field) => {
2623
2717
  if (field.setting) {
2624
2718
  field.settings = field.setting;
@@ -2639,9 +2733,9 @@ const ALLOWED_CREATE_FIELDS = [
2639
2733
  * Create a template.
2640
2734
  *
2641
2735
  * ```typescript
2642
- * import {Templates} from '@verdocs/js-sdk/Templates';
2736
+ * import {createTemplate} from '@verdocs/js-sdk/Templates';
2643
2737
  *
2644
- * const newTemplate = await Templates.createTemplatev2((VerdocsEndpoint.getDefault(), {...});
2738
+ * const newTemplate = await createTemplate((VerdocsEndpoint.getDefault(), {...});
2645
2739
  * ```
2646
2740
  */
2647
2741
  const createTemplate = (endpoint, params, onUploadProgress) => {
@@ -2673,9 +2767,9 @@ const createTemplate = (endpoint, params, onUploadProgress) => {
2673
2767
  * Create a template from a Sharepoint asset.
2674
2768
  *
2675
2769
  * ```typescript
2676
- * import {Templates} from '@verdocs/js-sdk/Templates';
2770
+ * import {createTemplateFromSharepoint} from '@verdocs/js-sdk/Templates';
2677
2771
  *
2678
- * const newTemplate = await Templates.createTemplateFromSharepoint((VerdocsEndpoint.getDefault(), {...});
2772
+ * const newTemplate = await createTemplateFromSharepoint((VerdocsEndpoint.getDefault(), {...});
2679
2773
  * ```
2680
2774
  */
2681
2775
  const createTemplateFromSharepoint = (endpoint, params) => {
@@ -2688,9 +2782,9 @@ const createTemplateFromSharepoint = (endpoint, params) => {
2688
2782
  * Update a template.
2689
2783
  *
2690
2784
  * ```typescript
2691
- * import {Templates} from '@verdocs/js-sdk/Templates';
2785
+ * import {updateTemplate} from '@verdocs/js-sdk/Templates';
2692
2786
  *
2693
- * const updatedTemplate = await Templates.updateTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9', { name: 'New Name' });
2787
+ * const updatedTemplate = await updateTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9', { name: 'New Name' });
2694
2788
  * ```
2695
2789
  */
2696
2790
  const updateTemplate = (endpoint, templateId, params) => endpoint.api //
@@ -2700,33 +2794,21 @@ const updateTemplate = (endpoint, templateId, params) => endpoint.api //
2700
2794
  * Delete a template.
2701
2795
  *
2702
2796
  * ```typescript
2703
- * import {Templates} from '@verdocs/js-sdk/Templates';
2797
+ * import {deleteTemplate} from '@verdocs/js-sdk/Templates';
2704
2798
  *
2705
- * await Templates.deleteTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2799
+ * await deleteTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2706
2800
  * ```
2707
2801
  */
2708
2802
  const deleteTemplate = (endpoint, templateId) => endpoint.api //
2709
2803
  .delete(`/templates/${templateId}`)
2710
2804
  .then((r) => r.data);
2711
2805
  /**
2712
- * Search for templates matching various criteria.
2713
- *
2714
- * ```typescript
2715
- * import {Templates} from '@verdocs/js-sdk/Templates';
2716
- *
2717
- * const {result, page, total} = await Templates.search((VerdocsEndpoint.getDefault(), { ... });
2718
- * ```
2719
- */
2720
- const searchTemplates = async (endpoint, params) => endpoint.api //
2721
- .post('/templates/search', params)
2722
- .then((r) => r.data);
2723
- /**
2724
- * List templates.
2806
+ * List
2725
2807
  *
2726
2808
  * ```typescript
2727
2809
  * import {Templates} from '@verdocs/js-sdk/Templates';
2728
2810
  *
2729
- * const {totals, templates} = await Templates.listTemplates((VerdocsEndpoint.getDefault(), { q: 'test', sort: 'created_at' }); * ```
2811
+ * const {totals, templates} = await listTemplates((VerdocsEndpoint.getDefault(), { q: 'test', sort: 'created_at' }); * ```
2730
2812
  */
2731
2813
  const listTemplates = async (endpoint, params = {}) => endpoint.api //
2732
2814
  .post('/templates/list', params)
@@ -2846,6 +2928,10 @@ const isValidTag = (value, tags) => TagRegEx.test(value) || tags.findIndex((tag)
2846
2928
 
2847
2929
  exports.AtoB = AtoB;
2848
2930
  exports.Countries = Countries;
2931
+ exports.DEFAULT_FIELD_HEIGHTS = DEFAULT_FIELD_HEIGHTS;
2932
+ exports.DEFAULT_FIELD_SETTINGS = DEFAULT_FIELD_SETTINGS;
2933
+ exports.DEFAULT_FIELD_WIDTHS = DEFAULT_FIELD_WIDTHS;
2934
+ exports.FIELD_TYPES = FIELD_TYPES;
2849
2935
  exports.RolePermissions = RolePermissions;
2850
2936
  exports.VerdocsEndpoint = VerdocsEndpoint;
2851
2937
  exports.acceptOrganizationInvitation = acceptOrganizationInvitation;
@@ -2984,7 +3070,6 @@ exports.resendOrganizationInvitation = resendOrganizationInvitation;
2984
3070
  exports.resendVerification = resendVerification;
2985
3071
  exports.resetPassword = resetPassword;
2986
3072
  exports.rotateApiKey = rotateApiKey;
2987
- exports.searchTemplates = searchTemplates;
2988
3073
  exports.sendDelegate = sendDelegate;
2989
3074
  exports.setWebhooks = setWebhooks;
2990
3075
  exports.submitKbaChallengeResponse = submitKbaChallengeResponse;