@verdocs/js-sdk 4.2.136 → 4.2.156

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.js CHANGED
@@ -887,6 +887,11 @@ var globalThis$1 = /*@__PURE__*/getDefaultExportFromCjs(globalThis_1);
887
887
  * const {access_token} = await Auth.authenticate({ client_id: '...', client_secret: '...', grant_type:'client_credentials' });
888
888
  * VerdocsEndpoint.getDefault().setAuthToken(access_token);
889
889
  * ```
890
+ *
891
+ * @group Authentication
892
+ * @api POST /v2/oauth2/token Authenticate
893
+ * @apiBody string(format: 'uuid') id The ID of the envelope to retrieve.
894
+ * @apiSuccess IAuthenticateResponse . The detailed metadata for the envelope requested
890
895
  */
891
896
  const authenticate = (endpoint, params) => endpoint.api //
892
897
  .post('/v2/oauth2/token', params)
@@ -1504,18 +1509,42 @@ class VerdocsEndpoint {
1504
1509
  * const request: ICreateEnvelopeRequest = {template_id: 'd2338742-f3a1-465b-8592-806587413cc1', name: 'Bill of Sale', roles: [role1, role2]};
1505
1510
  * const {id, recipients} = await Envelopes.createEnvelope(VerdocsEndpoint.getDefault(), request);
1506
1511
  * ```
1512
+ *
1513
+ * @group Envelopes
1514
+ * @api POST /v2/envelopes Create Envelope
1515
+ * @apiBody string(format:uuid) template_id The template to base the new Envelope from
1516
+ * @apiBody array(items:ICreateEnvelopeRecipient) recipients A list of recipients to include in the workflow. Must specify one recipient to match each template Role.
1517
+ * @apiBody string name? Override the name of the envelope (defaults to the template name).
1518
+ * @apiBody string description? Override the description of the envelope (defaults to the template description).
1519
+ * @apiBody array(items:IEnvelopeField) fields? Provide default values for fields in the envelope. Note that only "name", "role_name", and "default" should be set in this array.
1520
+ * @apiBody boolean no_contact? If set to true, no email or SMS messages will be sent to any recipients.
1521
+ * @apiBody integer(min: 0) initial_reminder? Override the template initial-reminder setting.
1522
+ * @apiBody integer(min: 0) followup_reminders? Override the template initial-reminder setting.
1523
+ * @apiSuccess IEnvelope . The newly-created envelope.
1507
1524
  */
1508
1525
  const createEnvelope = async (endpoint, request) => endpoint.api //
1509
1526
  .post('/v2/envelopes', request)
1510
1527
  .then((r) => r.data);
1511
1528
  /**
1512
- * Get all metadata for an Envelope.
1529
+ * Get all metadata for an envelope. Note that when called by non-creators (e.g. Recipients)
1530
+ * this will return only the **metadata** the caller is allowed to view.
1531
+ *
1532
+ * @group Envelopes
1533
+ * @api GET /v2/envelopes/:id Get Envelope Details
1534
+ * @apiParam string(format: 'uuid') id The ID of the envelope to retrieve.
1535
+ * @apiSuccess IEnvelope . The detailed metadata for the envelope requested
1513
1536
  */
1514
1537
  const getEnvelope = async (endpoint, envelopeId) => endpoint.api //
1515
1538
  .get(`/v2/envelopes/${envelopeId}`)
1516
1539
  .then((r) => r.data);
1517
1540
  /**
1518
- * Get an Envelope Document
1541
+ * Get all metadata for an envelope document. Note that when called by non-creators (e.g. Recipients)
1542
+ * this will return only the **metadata** the caller is allowed to view.
1543
+ *
1544
+ * @group Envelopes
1545
+ * @api GET /envelopes/:id Get Envelope Details
1546
+ * @apiParam string(format: 'uuid') id The ID of the document to retrieve.
1547
+ * @apiSuccess IEnvelopeDocument . The detailed metadata for the document requested
1519
1548
  */
1520
1549
  const getEnvelopeDocument = async (endpoint, envelopeId, documentId) => endpoint.api //
1521
1550
  .get(`/envelopes/${envelopeId}/envelope_documents/${documentId}`)
@@ -1523,6 +1552,15 @@ const getEnvelopeDocument = async (endpoint, envelopeId, documentId) => endpoint
1523
1552
  /**
1524
1553
  * Get a pre-signed download link for an Envelope Document. This link expires quickly, so it should
1525
1554
  * be accessed immediately and never shared. Content-Disposition will be set to "download".
1555
+ *
1556
+ * @group Envelopes
1557
+ * @api GET /envelopes/:envelope_id/envelope_documents/:document_id Preview, Download, or Link to a Document
1558
+ * @apiParam string(format: 'uuid') envelope_id The ID of the envelope to retrieve.
1559
+ * @apiParam string(format: 'uuid') document_id The ID of the document to retrieve.
1560
+ * @apiQuery boolean download? Set to true to generate a download link (content-disposition: download).
1561
+ * @apiQuery boolean preview? Set to true to generate a preview link (content-disposition: inline).
1562
+ * @apiQuery boolean file? Set to true to return the raw binary BLOB data of the file rather than a link.
1563
+ * @apiSuccess string . The generated link.
1526
1564
  */
1527
1565
  const getDocumentDownloadLink = async (endpoint, envelopeId, documentId) => endpoint.api //
1528
1566
  .get(`/envelopes/${envelopeId}/envelope_documents/${documentId}?download=true`)
@@ -1536,6 +1574,12 @@ const getDocumentPreviewLink = async (endpoint, envelopeId, documentId) => endpo
1536
1574
  .then((r) => r.data);
1537
1575
  /**
1538
1576
  * Cancel an Envelope.
1577
+ *
1578
+ * @group Envelopes
1579
+ * @api PUT /v2/envelopes/:id Cancel envelope
1580
+ * @apiParam string(format: 'uuid') id The ID of the envelope to cancel.
1581
+ * @apiBody string(enum: 'cancel') action The action to perform (currently only "cancel" is supported).
1582
+ * @apiSuccess IEnvelope . The updated envelope.
1539
1583
  */
1540
1584
  const cancelEnvelope = async (endpoint, envelopeId) => endpoint.api //
1541
1585
  .put(`/v2/envelopes/${envelopeId}`, { action: 'cancel' })
@@ -1550,32 +1594,68 @@ const getEnvelopeFile = async (endpoint, envelopeId, documentId) => endpoint.api
1550
1594
  .then((r) => r.data);
1551
1595
  /**
1552
1596
  * Update an envelope. Currently, only reminder settings may be changed.
1597
+ *
1598
+ * @group Envelopes
1599
+ * @api PATCH /v2/envelopes/:id Update Envelope
1600
+ * @apiParam string(format: 'uuid') id The ID of the envelope to update.
1601
+ * @apiBody IEnvelope . Set of fields to update. Omit (leave undefined) any fields that should not be changed.
1602
+ * @apiSuccess IEnvelope . A copy of the newly-updated envelope.
1553
1603
  */
1554
1604
  const updateEnvelope = async (endpoint, envelopeId, params) => endpoint.api //
1555
1605
  .patch(`/v2/envelopes/${envelopeId}`, params)
1556
1606
  .then((r) => r.data);
1557
1607
  /**
1558
1608
  * Update a Document field. Typically called during the signing process as a Recipient fills in fields.
1609
+ *
1610
+ * @group Envelopes
1611
+ * @api PUT /envelopes/:envelope_id/fields/:field_name Update Envelope Field
1612
+ * @apiParam string(format: 'uuid') envelope_id The ID of the envelope to retrieve.
1613
+ * @apiParam string field_name The name of the field to update. Be sure to URL-encode the value.
1614
+ * @apiBody IEnvelopeFieldSettings . Set of properties to update. Leave undefined any properties that should not be changed.
1615
+ * @apiSuccess IEnvelope . A copy of the newly-updated field.
1559
1616
  */
1560
1617
  const updateEnvelopeField = async (endpoint, envelopeId, fieldName, value) => endpoint.api //
1561
1618
  .put(`/envelopes/${envelopeId}/fields/${fieldName}`, value)
1562
1619
  .then((r) => r.data);
1563
1620
  /**
1564
- * Update a Document signature field. Signature fields are ID-driven. Call `Document.createSignature()` first to create a
1565
- * signature for a Recipient, then call `Documents.updateDocumentFieldSignature()` to attach it to a field.
1621
+ * Apply a signature to a signature field. Signature fields are ID-driven. Call `createSignature()`
1622
+ * first to create a signature for a Recipient, then call `updateEnvelopeFieldSignature()` to
1623
+ * attach it to a field.
1624
+ *
1625
+ * @group Envelopes
1626
+ * @api PUT /envelopes/:envelope_id/fields/:field_name/signature/:signature_id Update Envelope
1627
+ * @apiParam string(format: 'uuid') envelope_id The ID of the envelope to update.
1628
+ * @apiParam string field_name The name of the field to update. Be sure to URL-encode the value.
1629
+ * @apiParam string(format: 'uuid') signature_id The ID of the signature to attach.
1630
+ * @apiSuccess IEnvelopeFieldSettings . A copy of the newly-updated field.
1566
1631
  */
1567
1632
  const updateEnvelopeFieldSignature = async (endpoint, envelopeId, fieldName, signatureId) => endpoint.api //
1568
1633
  .put(`/envelopes/${envelopeId}/fields/${fieldName}/signature/${signatureId}`)
1569
1634
  .then((r) => r.data);
1570
1635
  /**
1571
- * Update a Document signature field. Signature fields are ID-driven. Call `Document.createSignature()` first to create a
1572
- * signature for a Recipient, then call `Documents.updateDocumentFieldSignature()` to attach it to a field.
1636
+ * Apply an initial to an initials field. Initial fields are ID-driven. Call `createInitial()`
1637
+ * first to create an initial block for a Recipient, then call `supdateEnvelopeFieldInitials()` to
1638
+ * attach it to a field.
1639
+ *
1640
+ * @group Envelopes
1641
+ * @api PUT /envelopes/:envelope_id/fields/:field_name/initial/:initial_id Update Envelope
1642
+ * @apiParam string(format: 'uuid') envelope_id The ID of the envelope to update.
1643
+ * @apiParam string field_name The name of the field to update. Be sure to URL-encode the value.
1644
+ * @apiParam string(format: 'uuid') initial_id The ID of the initial block to attach.
1645
+ * @apiSuccess IEnvelopeFieldSettings . A copy of the newly-updated field.
1573
1646
  */
1574
1647
  const updateEnvelopeFieldInitials = async (endpoint, envelopeId, fieldName, initialId) => endpoint.api //
1575
1648
  .put(`/envelopes/${envelopeId}/fields/${fieldName}/initial/${initialId}`)
1576
1649
  .then((r) => r.data);
1577
1650
  /**
1578
- * Upload an attachment.
1651
+ * Upload an attachment to an attachment field
1652
+ *
1653
+ * @group Envelopes
1654
+ * @api PUT /envelopes/:envelope_id/fields/:field_name Upload or Delete Attachment
1655
+ * @apiParam string(format: 'uuid') envelope_id The ID of the envelope to update.
1656
+ * @apiParam string field_name The name of the field to update. Be sure to URL-encode the value.
1657
+ * @apiBody string document The file to attach. Must contain standard File object fields. If omitted, the attachment will be deleted instead.
1658
+ * @apiSuccess IEnvelopeFieldSettings . A copy of the newly-updated field.
1579
1659
  */
1580
1660
  const uploadEnvelopeFieldAttachment = async (endpoint, envelopeId, fieldName, file, onUploadProgress) => {
1581
1661
  const formData = new FormData();
@@ -1592,7 +1672,9 @@ const uploadEnvelopeFieldAttachment = async (endpoint, envelopeId, fieldName, fi
1592
1672
  .then((r) => r.data);
1593
1673
  };
1594
1674
  /**
1595
- * Delete an attachment.
1675
+ * Delete an attachment. Note that this is not a DELETE endpoint because the field itself is not
1676
+ * being deleted. Instead, it is a similar operation to uploading a new attachment, but the
1677
+ * omission of the attachment signals the server to delete the current entry.
1596
1678
  */
1597
1679
  const deleteEnvelopeFieldAttachment = async (endpoint, envelopeId, fieldName) => {
1598
1680
  const formData = new FormData();
@@ -1602,7 +1684,13 @@ const deleteEnvelopeFieldAttachment = async (endpoint, envelopeId, fieldName) =>
1602
1684
  .then((r) => r.data);
1603
1685
  };
1604
1686
  /**
1605
- * Get the attached file for an attachment field (if any)
1687
+ * Get the attached file for an attachment field (if any).
1688
+ *
1689
+ * @group Envelopes
1690
+ * @api GET /envelopes/:envelope_id/fields/:field_name/document Download attachment in binary format
1691
+ * @apiParam string(format: 'uuid') envelope_id The ID of the envelope to retrieve.
1692
+ * @apiParam string field_name The name of the field from which to download the attachment.
1693
+ * @apiSuccess string . The file binary data.
1606
1694
  */
1607
1695
  const getFieldAttachment = async (endpoint, envelopeId, fieldName) => endpoint.api //
1608
1696
  .get(`/envelopes/${envelopeId}/fields/${fieldName}/document`, { responseType: 'blob' })
@@ -1611,6 +1699,13 @@ const getFieldAttachment = async (endpoint, envelopeId, fieldName) => endpoint.a
1611
1699
  * Get a display URI for a given page in a file attached to an envelope document. These pages are rendered server-side
1612
1700
  * into PNG resources suitable for display in IMG tags although they may be used elsewhere. Note that these are intended
1613
1701
  * for DISPLAY ONLY, are not legally binding documents, and do not contain any encoded metadata from participants.
1702
+ *
1703
+ * @group Envelopes
1704
+ * @api GET /v2/envelope-documnets/page-image/:document_id/:variant/:page Get Document Page Display URI
1705
+ * @apiParam string(format: 'uuid') document_id The ID of the document to retrieve.
1706
+ * @apiParam string(enum: 'original'|'filled') variant The variant of the document to retrieve.
1707
+ * @apiParam integer page The page number to retrieve
1708
+ * @apiSuccess string . The page display URI. Note that this is a signed URL with a short expiration. It should be used immediately and never databased or cached.
1614
1709
  */
1615
1710
  const getEnvelopeDocumentPageDisplayUri = async (endpoint, documentId, page, variant = 'original') => endpoint.api.get(`/v2/envelope-documents/page-image/${documentId}/${variant}/${page}`, { timeout: 20000 }).then((r) => r.data);
1616
1711
  /**
@@ -1621,6 +1716,24 @@ const getEnvelopeDocumentPageDisplayUri = async (endpoint, documentId, page, var
1621
1716
  *
1622
1717
  * const {count, envelopes} = await getEnvelopes((VerdocsEndpoint.getDefault(), { q: 'test' });
1623
1718
  * ```
1719
+ *
1720
+ * @group Envelopes
1721
+ * @api GET /v2/envelopes List Envelopes
1722
+ * @apiQuery string q? Match envelopes whose name contains this string
1723
+ * @apiQuery string(enum: 'inbox' | 'sent' | 'action' | 'waiting' | 'completed') view? Request pre-defined view. `inbox` returns envelopes where action is required by the caller. `sent` returns envelopes created by the caller. `action` returns envelopes where action is required by the caller. `waiting` returns envelopes where action is required by anyone. `completed` returns envelopes where all actions are complete.
1724
+ * @apiQuery array(items: 'complete' | 'pending' | 'in progress' | 'declined' | 'canceled') status? Match envelopes in one of the specified states.
1725
+ * @apiQuery boolean(default: false) include_org? If true, include organizations-shared envelopes
1726
+ * @apiQuery string(format: uuid) template_id? Match envelopes created from the specified template ID
1727
+ * @apiQuery string(format: date-time) created_before? Match envelopes created before this date
1728
+ * @apiQuery string(format: date-time) created_after? Match envelopes created after this date
1729
+ * @apiQuery string(enum: 'name' | 'created_at' | 'updated_at' | 'canceled_at' | 'status') sort_by? Return results sorted by this criteria
1730
+ * @apiQuery boolean ascending? Set true/false to override the sort direction. Note that the default depends on `sort_by`. Date-based sorts default to descending, while name and status default to ascending.
1731
+ * @apiQuery integer(default: 20) rows? Limit the number of rows returned
1732
+ * @apiQuery integer(default: 0) page? Specify which page of results to return
1733
+ * @apiSuccess integer(format: int32) count The total number of records matching the query, helpful for pagination
1734
+ * @apiSuccess integer(format: int32) rows The number of rows returned in this response page
1735
+ * @apiSuccess integer(format: int32) page The page number of this response
1736
+ * @apiSuccess array(items: IEnvelope) envelopes List of envelopes found
1624
1737
  */
1625
1738
  const getEnvelopes = (endpoint, params) => endpoint.api //
1626
1739
  .get('/v2/envelopes', { params })
@@ -1631,6 +1744,11 @@ const getEnvelopes = (endpoint, params) => endpoint.api //
1631
1744
  * an initials block to be used for all initials fields in the document. Thus, this is typically called one time to
1632
1745
  * create and store an initials block. Thereafter, the ID of the initials block may be re-used for each initials field
1633
1746
  * to be "stamped" by the user.
1747
+ *
1748
+ * @group Signatures and Initials
1749
+ * @api POST /initials Create Initial Block
1750
+ * @apiBody string initial Blob containing initials image to store.
1751
+ * @apiSuccess IInitial . The newly-created initial block.
1634
1752
  */
1635
1753
  const createInitials = (endpoint, name, initials) => {
1636
1754
  const data = new FormData();
@@ -1666,12 +1784,24 @@ const submitKbaIdentity = (endpoint, envelope_id, role_name, identity) => endpoi
1666
1784
  * Submit an identity response to a KBA challenge. Answers should be submitted in the same order as
1667
1785
  * the challenges were listed in `IRecipientKbaStepChallenge.questions`.
1668
1786
  */
1669
- const submitKbaChallengeResponse = (endpoint, envelope_id, role_name, response) => endpoint.api //
1670
- .post(`/v2/kba/response`, { envelope_id, role_name, response })
1787
+ const submitKbaChallengeResponse = (endpoint, envelope_id, role_name, responses) => endpoint.api //
1788
+ .post(`/v2/kba/response`, { envelope_id, role_name, responses })
1671
1789
  .then((r) => r.data);
1672
1790
 
1673
1791
  /**
1674
- * Update a recipient's status block
1792
+ * Update a recipient's status.
1793
+ *
1794
+ * @group Recipients
1795
+ * @api PUT /envelopes/:envelope_id/recipients/:role_name Update Recipient Status
1796
+ * @apiParam string(format:uuid) envelope_id The envelope to operate on.
1797
+ * @apiParam string role_name The role to adjust.
1798
+ * @apiBody string(enum:'submit'|'decline'|'owner_update'|'update'|'prepare') action The action to take. Adjusts the status, and may also perform other operations.
1799
+ * @apiBody string first_name? Ignored unless action is 'owner_update' or 'update'. The new owner's or recipient's first name.
1800
+ * @apiBody string last_name? Ignored unless action is 'owner_update' or 'update'. The new owner's or recipient's last name.
1801
+ * @apiBody string email? Ignored unless action is 'owner_update'. The new owner's email address.
1802
+ * @apiBody boolean agreed? Ignored unless action is 'update'. Set to true to accept the e-signing disclosures.
1803
+ * @apiBody array(items:IRecipient) recipients? Ignored unless action is 'prepare'. A list of recipients and their fields to set defaults for.
1804
+ * @apiSuccess IRecipient . The updated Recipient.
1675
1805
  */
1676
1806
  const updateRecipient = async (endpoint, envelope_id, role_name, params) => endpoint.api //
1677
1807
  .put(`/envelopes/${envelope_id}/recipients/${role_name}`, params)
@@ -1702,10 +1832,17 @@ const envelopeRecipientUpdateName = (endpoint, envelopeId, roleName, first_name,
1702
1832
  const envelopeRecipientPrepare = (endpoint, envelopeId, roleName, recipients) => updateRecipient(endpoint, envelopeId, roleName, { action: 'prepare', recipients });
1703
1833
  /**
1704
1834
  * Begin a signing session for an Envelope. This path requires an invite code, and should generally
1705
- * be called with a NON-default endpoint to avoid conflicting with any active user session the user
1835
+ * be called with a NON-default Endpoint to avoid conflicting with any active user session the user
1706
1836
  * may have. To initiate in-person signing by an authenticated user (e.g. self-signing), call
1707
1837
  * getInPersonLink() instead. The response from that call includes both a link for direct signing
1708
1838
  * via a Web browser as well as an in-person access_key. That access_key.key may be used here as well.
1839
+ *
1840
+ * @group Recipients
1841
+ * @api POST /v2/sign/unauth/:envelope_id/:role_name/:key Start Signing Session
1842
+ * @apiParam string(format:uuid) envelope_id The envelope to operate on.
1843
+ * @apiParam string role_name The role to request.
1844
+ * @apiParam string key Access key generated by the envelope creator or email/SMS invite.
1845
+ * @apiSuccess ISignerTokenResponse . Signing session token and envelope/recipient metadata.
1709
1846
  */
1710
1847
  const startSigningSession = async (endpoint, envelope_id, role_name, key) => {
1711
1848
  return endpoint.api //
@@ -1716,7 +1853,18 @@ const startSigningSession = async (endpoint, envelope_id, role_name, key) => {
1716
1853
  });
1717
1854
  };
1718
1855
  /**
1719
- * Get an in-person signing link.
1856
+ * Get an in-person signing link. Must be called by the owner/creator of the envelope. The response
1857
+ * also includes the raw access key that may be used to directly initiate a signing session (see
1858
+ * `startSigningSession`) as well as an access token representing a valid signing session for
1859
+ * immediate use in embeds or other applications. Note that in-person signing is considered a
1860
+ * lower-security operation than authenticated signing, and the final envelope certificate will
1861
+ * reflect this.
1862
+ *
1863
+ * @group Recipients
1864
+ * @api POST /v2/sign/in-person/:envelope_id/:role_name Get In-Person Signing Link
1865
+ * @apiParam string(format:uuid) envelope_id The envelope to operate on.
1866
+ * @apiParam string role_name The role to request.
1867
+ * @apiSuccess IInPersonLinkResponse . Signing session token and envelope/recipient metadata.
1720
1868
  */
1721
1869
  const getInPersonLink = (endpoint, envelope_id, role_name) => endpoint.api //
1722
1870
  .post(`/v2/sign/in-person/${envelope_id}/${encodeURIComponent(role_name)}`)
@@ -1728,7 +1876,17 @@ const sendDelegate = (endpoint, envelopeId, roleName) => endpoint.api //
1728
1876
  .post(`/envelopes/${envelopeId}/recipients/${encodeURIComponent(roleName)}`)
1729
1877
  .then((r) => r.data);
1730
1878
  /**
1731
- * Resend a recipient's invitation.
1879
+ * Resend a recipient's invitation. NOTE: User interfaces should rate-limit this operation to
1880
+ * avoid spamming recipients. Excessive use of this endpoint may result in Verdocs rate-limiting
1881
+ * the calling application to prevent abuse. This endpoint will return a 200 OK even if the
1882
+ * no_contact flag is set on the envelope (in which case the call will be ignored).
1883
+ *
1884
+ * @group Recipients
1885
+ * @api PUT /v2/envelopes/:envelope_id/recipients/:role_name Resend Invitation
1886
+ * @apiParam string(format:uuid) envelope_id The envelope to operate on.
1887
+ * @apiParam string role_name The role to operate on.
1888
+ * @apiBody string(enum:'resend') action The operation to perform.
1889
+ * @apiSuccess string . Success message.
1732
1890
  */
1733
1891
  const resendInvitation = (endpoint, envelopeId, roleName) => endpoint.api //
1734
1892
  .put(`/v2/envelopes/${envelopeId}/recipients/${encodeURIComponent(roleName)}`, { action: 'resend' })
@@ -1812,6 +1970,12 @@ const getNextRecipient = (envelope) => {
1812
1970
  * a signature block to be used for all signature fields in the document. Thus, this is typically called one time to
1813
1971
  * create and store a signature block. Thereafter, the ID of the signature block may be re-used for each signature field
1814
1972
  * to be "stamped" by the user.
1973
+ *
1974
+ * @group Signatures and Initials
1975
+ * @api POST /signatures Create Signature Block
1976
+ *
1977
+ * @apiBody string signature Blob containing signature image to store.
1978
+ * @apiSuccess ISignature . The newly-created signature block.
1815
1979
  */
1816
1980
  const createSignature = (endpoint, name, signature) => {
1817
1981
  const data = new FormData();
@@ -1821,19 +1985,34 @@ const createSignature = (endpoint, name, signature) => {
1821
1985
  .then((r) => r.data);
1822
1986
  };
1823
1987
  /**
1824
- * Get the availbable signatures for a user.
1988
+ * Get the available signatures for a user.
1989
+ *
1990
+ * @group Signatures and Initials
1991
+ * @api GET /signatures Create Signature Block
1992
+ *
1993
+ * @apiSuccess array(items:ISignature) . A list of signatures previously stored for the user.
1825
1994
  */
1826
1995
  const getSignatures = (endpoint) => endpoint.api //
1827
1996
  .get('/signatures')
1828
1997
  .then((r) => r.data);
1829
1998
  /**
1830
1999
  * Get a user's signature by ID.
2000
+ *
2001
+ * @group Signatures and Initials
2002
+ * @api GET /signatures/:id Delete Signature Block
2003
+ * @apiParam string(format: 'uuid') id The ID of the signature to delete.
2004
+ * @apiSuccess ISignature . The signature metadata requested.
1831
2005
  */
1832
2006
  const getSignature = (endpoint, signatureId) => endpoint.api //
1833
2007
  .get(`/signatures/${signatureId}`)
1834
2008
  .then((r) => r.data);
1835
2009
  /**
1836
2010
  * Delete a user's signature.
2011
+ *
2012
+ * @group Signatures and Initials
2013
+ * @api DELETE /signatures/:id Delete Signature Block
2014
+ * @apiParam string(format: 'uuid') id The ID of the signature to delete.
2015
+ * @apiSuccess string . OK
1837
2016
  */
1838
2017
  const deleteSignature = (endpoint, signatureId) => endpoint.api //
1839
2018
  .delete(`/signatures/${signatureId}`)
@@ -2746,6 +2925,21 @@ const getAllTags = (endpoint) => endpoint.api //
2746
2925
  * await getTemplates((VerdocsEndpoint.getDefault(), { is_creator: true });
2747
2926
  * await getTemplates((VerdocsEndpoint.getDefault(), { is_organization: true });
2748
2927
  * ```
2928
+ *
2929
+ * @group Templates
2930
+ * @api GET /v2/templates Get Templates
2931
+ * @apiQuery string q? Find templates whose names/descriptions contain the specified query string
2932
+ * @apiQuery boolean is_starred? If true, returns only templates with at least one "star".
2933
+ * @apiQuery boolean is_creator? If true, returns only templates that the caller created.
2934
+ * @apiQuery string(enum: 'private_shared' | 'private' | 'shared' | 'public') visibility? Return only templates with the specified visibility.
2935
+ * @apiQuery string(enum: 'created_at' | 'updated_at' | 'name' | 'last_used_at' | 'counter' | 'star_counter') sort_by? Return results sorted by this criteria
2936
+ * @apiQuery boolean ascending? Set true/false to override the sort direction. Note that the default depends on `sort_by`. Date-based sorts default to descending, while name defaults to ascending.
2937
+ * @apiQuery integer(default: 20) rows? Limit the number of rows returned
2938
+ * @apiQuery integer(default: 0) page? Specify which page of results to return
2939
+ * @apiSuccess integer(format: int32) count The total number of records matching the query, helpful for pagination
2940
+ * @apiSuccess integer(format: int32) rows The number of rows returned in this response page
2941
+ * @apiSuccess integer(format: int32) page The page number of this response
2942
+ * @apiSuccess array(items: ITemplate) templates List of templates found
2749
2943
  */
2750
2944
  const getTemplates = (endpoint, params) => endpoint.api //
2751
2945
  .get('/v2/templates', { params })
@@ -2759,31 +2953,34 @@ const getTemplates = (endpoint, params) => endpoint.api //
2759
2953
  * const template = await getTemplate((VerdocsEndpoint.getDefault(), '83da3d70-7857-4392-b876-c4592a304bc9');
2760
2954
  * ```
2761
2955
  */
2762
- const getTemplate = (endpoint, templateId) => endpoint.api //
2763
- .get(`/v2/templates/${templateId}`)
2764
- .then((r) => {
2765
- const template = r.data;
2766
- window?.console?.log('[JS_SDK] Post-processing template', template);
2767
- // Post-process the template to upgrade to new data fields
2768
- if (!template.documents && template.template_documents) {
2769
- template.documents = template.template_documents;
2770
- }
2771
- template.documents?.forEach((document) => {
2772
- if (!document.order) {
2773
- document.order = 0;
2774
- }
2775
- if (document.page_numbers) {
2776
- document.pages = document.page_numbers;
2777
- }
2778
- });
2779
- // Temporary upgrade from legacy app
2780
- template.fields?.forEach((field) => {
2781
- if (field.setting) {
2782
- field.settings = field.setting;
2956
+ const getTemplate = (endpoint, templateId) => {
2957
+ window?.console?.log('[JS_SDK] Loading template', templateId);
2958
+ return endpoint.api //
2959
+ .get(`/v2/templates/${templateId}`)
2960
+ .then((r) => {
2961
+ const template = r.data;
2962
+ window?.console?.log('[JS_SDK] Post-processing template', template);
2963
+ // Post-process the template to upgrade to new data fields
2964
+ if (!template.documents && template.template_documents) {
2965
+ template.documents = template.template_documents;
2783
2966
  }
2967
+ template.documents?.forEach((document) => {
2968
+ if (!document.order) {
2969
+ document.order = 0;
2970
+ }
2971
+ if (document.page_numbers) {
2972
+ document.pages = document.page_numbers;
2973
+ }
2974
+ });
2975
+ // Temporary upgrade from legacy app
2976
+ template.fields?.forEach((field) => {
2977
+ if (field.setting) {
2978
+ field.settings = field.setting;
2979
+ }
2980
+ });
2981
+ return template;
2784
2982
  });
2785
- return template;
2786
- });
2983
+ };
2787
2984
  const ALLOWED_CREATE_FIELDS = [
2788
2985
  'name',
2789
2986
  'is_personal',