docspring 3.3.0 → 4.1.0

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.
Files changed (184) hide show
  1. package/AGENTS.md +79 -19
  2. package/README.md +74 -63
  3. package/dist/ApiClient.js +63 -28
  4. package/dist/RequestSchemas.js +3452 -0
  5. package/dist/RequestValidator.js +494 -0
  6. package/dist/api/Client.js +1769 -921
  7. package/dist/index.js +847 -154
  8. package/dist/model/AddTemplateFieldsRequest.js +132 -0
  9. package/dist/model/AiFieldNamingLanguage.js +64 -0
  10. package/dist/model/{CreateWebhookData.js → AuthenticationCheck.js} +32 -28
  11. package/dist/model/BarcodeSymbology.js +89 -0
  12. package/dist/model/CheckCharacter.js +74 -0
  13. package/dist/model/CombinedFieldType.js +59 -0
  14. package/dist/model/CombinedPdf.js +294 -0
  15. package/dist/model/{MoveFolderData.js → CombinedPdfFiles.js} +27 -27
  16. package/dist/model/CombinedPdfList.js +132 -0
  17. package/dist/model/{ForbiddenErrorResponse.js → CombinedPdfSource.js} +59 -73
  18. package/dist/model/CombinedPdfSourceInput.js +270 -0
  19. package/dist/model/CombinedPdfSourcePdf.js +130 -0
  20. package/dist/model/CombinedPdfSourceType.js +74 -0
  21. package/dist/model/CombinedPdfState.js +74 -0
  22. package/dist/model/{CopyTemplateOptions.js → CopyTemplateRequest.js} +26 -22
  23. package/dist/model/{CombinePdfsData.js → CreateCombinedPdfRequest.js} +69 -53
  24. package/dist/model/{CreateCustomFileData.js → CreateCustomFileFromUploadRequest.js} +25 -23
  25. package/dist/model/{CreateFolderData.js → CreateFolderRequest.js} +47 -28
  26. package/dist/model/{CreateCustomFileResponse.js → CreateSignatureRequestEventRequest.js} +49 -73
  27. package/dist/model/CreateSignatureRequestTokenRequest.js +88 -0
  28. package/dist/model/CreateSubmissionBatchRequest.js +192 -0
  29. package/dist/model/CreateSubmissionRequest.js +226 -0
  30. package/dist/model/CreateTemplateRequest.js +613 -0
  31. package/dist/model/CreateWebhookRequest.js +234 -0
  32. package/dist/model/CustomFile.js +67 -16
  33. package/dist/model/CustomFileList.js +132 -0
  34. package/dist/model/CustomFileSourcePdf.js +130 -0
  35. package/dist/model/ErrorCode.js +154 -0
  36. package/dist/model/{CreateSubmissionResponse.js → ErrorDetail.js} +65 -75
  37. package/dist/model/ErrorInfo.js +211 -0
  38. package/dist/model/ErrorResponse.js +12 -41
  39. package/dist/model/ExpirationInterval.js +64 -0
  40. package/dist/model/Field.js +1230 -0
  41. package/dist/model/FieldComparisonCondition.js +137 -0
  42. package/dist/model/FieldComparisonOperator.js +69 -0
  43. package/dist/model/FieldDependency.js +154 -0
  44. package/dist/model/FieldDependencyInput.js +154 -0
  45. package/dist/model/FieldDisplayType.js +79 -0
  46. package/dist/model/{MultipleErrorsResponse.js → FieldEqualsCondition.js} +48 -52
  47. package/dist/model/FieldEqualsOperator.js +59 -0
  48. package/dist/model/FieldGroup.js +206 -0
  49. package/dist/model/FieldGroupInput.js +180 -0
  50. package/dist/model/FieldGroupType.js +59 -0
  51. package/dist/model/{SuccessMultipleErrorsResponse.js → FieldInCondition.js} +54 -53
  52. package/dist/model/FieldInput.js +1012 -0
  53. package/dist/model/FieldOverride.js +722 -0
  54. package/dist/model/FieldPresenceCondition.js +126 -0
  55. package/dist/model/FieldPresenceOperator.js +59 -0
  56. package/dist/model/FieldRangeCondition.js +148 -0
  57. package/dist/model/FieldReimportState.js +69 -0
  58. package/dist/model/FieldSetupLogic.js +59 -0
  59. package/dist/model/FieldSetupNaming.js +59 -0
  60. package/dist/model/FieldSetupSource.js +64 -0
  61. package/dist/model/FieldType.js +124 -0
  62. package/dist/model/Folder.js +38 -11
  63. package/dist/model/FolderList.js +132 -0
  64. package/dist/model/GenerateFilesFormat.js +54 -0
  65. package/dist/model/GenerateSubmissionFilesRequest.js +115 -0
  66. package/dist/model/GeneratedFile.js +214 -0
  67. package/dist/model/GeneratedFileState.js +64 -0
  68. package/dist/model/HtmlEngineOptions.js +230 -0
  69. package/dist/model/HtmlEngineOptionsInput.js +193 -0
  70. package/dist/model/ImageGravity.js +94 -0
  71. package/dist/model/ImageScaleType.js +64 -0
  72. package/dist/model/ModelCodeLanguage.js +94 -0
  73. package/dist/model/{UpdatePdfTemplate.js → MoveFolderRequest.js} +34 -28
  74. package/dist/model/{MoveTemplateData.js → MoveTemplateRequest.js} +25 -35
  75. package/dist/model/NumberConditionType.js +79 -0
  76. package/dist/model/OutputFormat.js +59 -0
  77. package/dist/model/PageFormat.js +114 -0
  78. package/dist/model/PageImage.js +220 -0
  79. package/dist/model/{TemplateDeleteResponse.js → PageImages.js} +57 -70
  80. package/dist/model/PredefinedField.js +183 -0
  81. package/dist/model/PredefinedFieldInput.js +183 -0
  82. package/dist/model/{PublishVersionData.js → PublishTemplateVersionRequest.js} +33 -33
  83. package/dist/model/{AddFieldsData.js → RemoveTemplateFieldsRequest.js} +32 -30
  84. package/dist/model/{RenameFolderData.js → RenameFolderRequest.js} +25 -23
  85. package/dist/model/ReorderTemplateFieldsRequest.js +114 -0
  86. package/dist/model/{RestoreVersionData.js → RestoreTemplateVersionRequest.js} +25 -23
  87. package/dist/model/ShapeType.js +79 -0
  88. package/dist/model/{SubmissionDataRequestShow.js → SignatureRequest.js} +165 -240
  89. package/dist/model/SignatureRequestAuthSecondFactorType.js +79 -0
  90. package/dist/model/SignatureRequestAuthType.js +84 -0
  91. package/dist/model/{SubmissionDataRequestEvent.js → SignatureRequestEvent.js} +67 -149
  92. package/dist/model/SignatureRequestEventType.js +79 -0
  93. package/dist/model/SignatureRequestInput.js +278 -0
  94. package/dist/model/SignatureRequestMessageType.js +94 -0
  95. package/dist/model/SignatureRequestState.js +64 -0
  96. package/dist/model/SignatureRequestToken.js +195 -0
  97. package/dist/model/SignatureRequestTokenType.js +59 -0
  98. package/dist/model/StringConditionType.js +74 -0
  99. package/dist/model/Submission.js +198 -341
  100. package/dist/model/SubmissionAction.js +30 -115
  101. package/dist/model/SubmissionActionState.js +69 -0
  102. package/dist/model/SubmissionActionType.js +84 -0
  103. package/dist/model/SubmissionBatch.js +74 -55
  104. package/dist/model/SubmissionBatchState.js +64 -0
  105. package/dist/model/SubmissionFiles.js +117 -0
  106. package/dist/model/SubmissionInput.js +218 -0
  107. package/dist/model/{ListSubmissionsResponse.js → SubmissionList.js} +35 -42
  108. package/dist/model/SubmissionSource.js +69 -0
  109. package/dist/model/SubmissionSourcePdf.js +130 -0
  110. package/dist/model/SubmissionState.js +114 -0
  111. package/dist/model/{SubmissionBatchData.js → SubmissionValidation.js} +46 -48
  112. package/dist/model/Template.js +359 -560
  113. package/dist/model/TemplateActor.js +171 -0
  114. package/dist/model/TemplateActorType.js +64 -0
  115. package/dist/model/TemplateDefaults.js +307 -0
  116. package/dist/model/TemplateDefaultsInput.js +305 -0
  117. package/dist/model/TemplateDiff.js +206 -0
  118. package/dist/model/TemplateDiffSummary.js +165 -0
  119. package/dist/model/TemplateDocument.js +280 -0
  120. package/dist/model/TemplateDocumentState.js +84 -0
  121. package/dist/model/TemplateFieldChange.js +146 -0
  122. package/dist/model/TemplateFieldChanges.js +196 -0
  123. package/dist/model/{CreatePdfSubmissionData.js → TemplateFieldDependency.js} +70 -89
  124. package/dist/model/TemplateFieldDependencyAction.js +64 -0
  125. package/dist/model/{TemplatePublishVersionResponse.js → TemplateFieldDependencyCondition.js} +51 -61
  126. package/dist/model/TemplateFieldDependencyConditionInput.js +304 -0
  127. package/dist/model/TemplateFieldDependencyInput.js +182 -0
  128. package/dist/model/TemplateFieldDependencyMatch.js +59 -0
  129. package/dist/model/TemplateFieldDependencyOperator.js +99 -0
  130. package/dist/model/TemplateFieldLogicStatus.js +74 -0
  131. package/dist/model/{CreatePdfTemplate.js → TemplateFieldMove.js} +52 -28
  132. package/dist/model/TemplateFields.js +147 -0
  133. package/dist/model/TemplateFormMode.js +64 -0
  134. package/dist/model/{TemplateModelCodeResponse.js → TemplateModelCode.js} +34 -86
  135. package/dist/model/TemplatePageAiError.js +69 -0
  136. package/dist/model/TemplatePageAiNamingStatus.js +59 -0
  137. package/dist/model/TemplatePageFieldsStatus.js +74 -0
  138. package/dist/model/TemplatePageImageStatus.js +59 -0
  139. package/dist/model/TemplatePageImages.js +158 -0
  140. package/dist/model/TemplatePageProcessingStatus.js +162 -0
  141. package/dist/model/{SubmissionDataRequestToken.js → TemplateSourcePdf.js} +52 -56
  142. package/dist/model/TemplateSummary.js +560 -0
  143. package/dist/model/{SuccessErrorResponse.js → TemplateSummaryList.js} +43 -55
  144. package/dist/model/TemplateType.js +59 -0
  145. package/dist/model/{Submission422Response.js → TemplateVersion.js} +60 -63
  146. package/dist/model/TemplateVersionType.js +64 -0
  147. package/dist/model/TextAlignment.js +69 -0
  148. package/dist/model/TextOverflow.js +59 -0
  149. package/dist/model/TextVerticalAlignment.js +64 -0
  150. package/dist/model/Typeface.js +134 -0
  151. package/dist/model/UpdateSignatureRequestRequest.js +183 -0
  152. package/dist/model/UpdateTemplateDocumentRequest.js +139 -0
  153. package/dist/model/UpdateTemplateFieldsRequest.js +132 -0
  154. package/dist/model/UpdateTemplateRequest.js +523 -0
  155. package/dist/model/UpdateWebhookRequest.js +209 -0
  156. package/dist/model/UploadMethod.js +54 -0
  157. package/dist/model/{UploadPresignResponse.js → UploadPresign.js} +53 -58
  158. package/dist/model/UrlSourcePdf.js +130 -0
  159. package/dist/model/ValidateSubmissionRequest.js +226 -0
  160. package/dist/model/Webhook.js +58 -73
  161. package/dist/model/WebhookEventType.js +174 -0
  162. package/dist/model/WebhookList.js +132 -0
  163. package/dist/model/WebhookMode.js +59 -0
  164. package/package.json +1 -1
  165. package/dist/model/BatchGeneratePdfs201Response.js +0 -194
  166. package/dist/model/CombinedSubmission.js +0 -313
  167. package/dist/model/CombinedSubmissionAction.js +0 -268
  168. package/dist/model/CreateCombinedSubmissionResponse.js +0 -180
  169. package/dist/model/CreateHtmlTemplate.js +0 -108
  170. package/dist/model/CreateSubmissionDataRequestData.js +0 -314
  171. package/dist/model/CreateSubmissionDataRequestEventRequest.js +0 -239
  172. package/dist/model/CreateSubmissionDataRequestEventResponse.js +0 -167
  173. package/dist/model/CreateSubmissionDataRequestResponse.js +0 -167
  174. package/dist/model/CreateSubmissionDataRequestTokenResponse.js +0 -167
  175. package/dist/model/ErrorOrMultipleErrorsResponse.js +0 -153
  176. package/dist/model/JsonSchema.js +0 -205
  177. package/dist/model/SubmissionBatchWithSubmissions.js +0 -228
  178. package/dist/model/SubmissionDataRequest.js +0 -496
  179. package/dist/model/SubmissionPreview.js +0 -509
  180. package/dist/model/TemplateAddFieldsResponse.js +0 -156
  181. package/dist/model/TemplatePreview.js +0 -796
  182. package/dist/model/UpdateHtmlTemplate.js +0 -108
  183. package/dist/model/UpdateSubmissionDataRequestData.js +0 -311
  184. package/dist/model/UpdateWebhookData.js +0 -108
package/AGENTS.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # AGENTS.md
2
2
 
3
- Notes for AI coding agents working with the DocSpring JavaScript SDK (`docspring`), in this repository or
4
- as a dependency of an app.
3
+ Notes for AI coding agents working with the DocSpring JavaScript SDK (`docspring`): integrating it into an
4
+ app, or working in this repository.
5
5
 
6
6
  ## This code is generated
7
7
 
8
8
  Every file here is generated from DocSpring's OpenAPI spec by
9
9
  [DocSpring's fork of OpenAPI Generator](https://github.com/DocSpring/openapi-generator/tree/docspring/all_patches), and each release replaces
10
- all of it. Don't edit it or open pull requests that change it, and don't patch an installed copy: the next release
11
- overwrites the change. Report bugs at https://github.com/DocSpring/docspring-javascript/issues or to support@docspring.com, and DocSpring fixes them in
12
- the generator.
10
+ all of it. Don't patch an installed copy: the next release overwrites the change. Issues and pull requests are welcome
11
+ at https://github.com/DocSpring/docspring-javascript (or email support@docspring.com), and DocSpring makes the fix in the generator so that every release
12
+ keeps it.
13
13
 
14
14
  ## Where to look
15
15
 
@@ -17,17 +17,77 @@ the generator.
17
17
  - [docs/Client.md](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md): every method, with its parameters and return type.
18
18
  - [docs/](https://github.com/DocSpring/docspring-javascript/tree/main/docs): every model and its fields.
19
19
  - https://docspring.com/docs/llms.txt: DocSpring's documentation for LLMs (`llms-small.txt`, `llms-full.txt`).
20
- - https://docspring.com/docs/api/: the API reference, with JavaScript code for every method.
21
- - https://docspring.com/api-docs/v1/openapi.json: the OpenAPI spec this SDK is generated from.
22
-
23
- ## Using it in an app
24
-
25
- - Credentials come from `DOCSPRING_TOKEN_ID` and `DOCSPRING_TOKEN_SECRET`. Keep them in the environment or a secret
26
- store, never in code. Accounts in the EU region also need `DOCSPRING_REGION=EU`.
27
- - Template IDs look like `tpl_...` and submission IDs like `sub_...`.
28
- - Pass `test: true` when you generate PDFs during development: test PDFs are free and watermarked.
29
- - Generating a PDF waits for it, for up to 95 seconds. For many PDFs or slow templates, set `wait` to false and use
30
- webhooks or check the submission later (https://docspring.com/docs/api-guide/synchronous-requests/).
31
- - Errors: The callback gets `(error, data, response)`. For an error response, `error.status` is the HTTP status and `response.body` the parsed body.
32
- - Responses can be newer than this SDK, because DocSpring adds fields and enum values to API v1 without a new
33
- version. The model object keeps a response field added to the API after this release as a property. An enum value added to the API after this release comes back as a string, so handle values you don't recognize.
20
+ - https://docspring.com/docs/: the guides. https://docspring.com/docs/api/: the API reference, with JavaScript code
21
+ for every method.
22
+ - https://docspring.com/api-docs/v2/openapi.json: the OpenAPI spec this SDK is generated from.
23
+
24
+ ## Set up
25
+
26
+ - Credentials come from `DOCSPRING_TOKEN_ID` and `DOCSPRING_TOKEN_SECRET` (an API token from
27
+ https://app.docspring.com/api_tokens). Keep them in the environment or a secret store, never in code. An account in
28
+ the EU region also needs `DOCSPRING_REGION=EU`.
29
+ - Call DocSpring from your server. The token secret gives full access to the account, so it must never reach a browser
30
+ or a mobile app. Signers use signing links or the embedded signing form instead (see Signature requests).
31
+ - `testAuthentication` checks the credentials.
32
+
33
+ ## Generate PDFs
34
+
35
+ - Read a template's data shape before writing the request: `getTemplateSchema` returns the
36
+ JSON Schema of its submission data (its field names and types), and `getTemplateModelCode`
37
+ generates typed code for it. The keys of `data` are the template's field names. Date fields take `YYYY-MM-DD`.
38
+ - Template IDs look like `tpl_...` and submission IDs like `sub_...`. Store the submission ID with your own record.
39
+ - Pass `test: true` while you build: test PDFs are free and watermarked. Live PDFs use credits.
40
+ - A submission uses the template's latest published version (its draft when nothing has been published yet). Pass
41
+ `version` (`draft`, `1.2.0`, or `1` for the latest 1.x.x) to use another one.
42
+ - `createSubmission` waits for the PDF, for up to 95 seconds, and returns the submission in
43
+ its final state: check its `state` (`processed`, or a failure state with an `error_message`). If the PDF takes longer,
44
+ the call fails with a 504 `polling_timeout` error that has the submission's ID. The submission exists and is still
45
+ being made, so don't send the request again (that makes a second one): get it with
46
+ `getSubmission` until its state isn't `pending`. For slow templates or many PDFs, set
47
+ `wait` to false and use webhooks (https://docspring.com/docs/api-guide/synchronous-requests/).
48
+ `createSubmissionBatch` sends up to 50 submissions in one request.
49
+ - `files.pdf.download_url` is a temporary link. Keep the submission ID (or `files.pdf.permanent_url`, which needs your
50
+ API token) and get a fresh link when someone downloads the PDF.
51
+ - Submission data is often personal data: don't log request or response bodies. `expires_in` deletes a submission's PDF
52
+ and data that many seconds after it's created, and `expireSubmission` deletes them now.
53
+
54
+ ## Errors
55
+
56
+ - Each method returns a promise. For an error response it rejects with an object whose `status` is the HTTP status and `body` the parsed body.
57
+ - Every error response has one body: `{"error": {"code", "message", "details", "request_id"}}`. Branch on `code`, not
58
+ on the message. Each detail has a `pointer` to the request body value it's about, or the query `parameter`.
59
+ - 422 `invalid_data`: the data doesn't match the template. The submission is saved anyway, as `invalid_data`, and the
60
+ error has its `submission_id`.
61
+ - 402 `insufficient_credits`: the submission is saved and is made automatically once the account has credits. Don't
62
+ send it again (https://docspring.com/docs/api-guide/credits-and-rate-limits/).
63
+ - 429 `rate_limited`: wait for the seconds in the `Retry-After` header, then retry.
64
+ - Requests are checked against the API's request schemas before they're sent. A request the API would reject fails with a `ValidationError` (exported by the package), whose `details` are objects with `code`, `message` and a `pointer` into the body (or a `parameter`). Turn the check off with `client.apiClient.validateRequests = false`.
65
+
66
+ ## Webhooks
67
+
68
+ - Webhooks tell your server when a submission is processed or fails, instead of polling
69
+ (https://docspring.com/docs/webhooks/overview/). A webhook created with API v2 sends events in API v2's format
70
+ (version 4).
71
+ - Verify each request's `X-DocSpring-Signature` header before acting on it: an HMAC-SHA256 of `{t}.{raw body}` with the
72
+ webhook's signing secret, computed over the raw body exactly as received
73
+ (https://docspring.com/docs/webhooks/verifying-signatures/).
74
+ - No webhook is sent when a submission starts waiting for credits.
75
+
76
+ ## Signature requests
77
+
78
+ - To have people fill in fields and sign before the PDF is made, create the submission with `signature_requests`. Each
79
+ one has the `fields` its signer fills in (a field belongs to one signature request), and their `name` and `email`.
80
+ The PDF is made when every signer has finished
81
+ (https://docspring.com/docs/api-guide/create-signature-requests/).
82
+ - Send a signer to the `signature_request_url` of a token from
83
+ `createSignatureRequestToken`. An `api` token's link opens the form for 24 hours and an
84
+ `email` token's for 7 days (`expires_at`), so create a new token when a signer comes back later.
85
+ - To show the signing form on your own site, use Signature Requests JS, and add the site's domain to the template's
86
+ Embed Domains (https://docspring.com/docs/guides/embedded-forms/embedded-signature-requests/).
87
+
88
+ ## Responses
89
+
90
+ - List methods return `data` and `next_cursor`: pass `next_cursor` as `cursor` to get the next page.
91
+ - Responses can be newer than this SDK, because DocSpring adds fields and enum values to API v2 without a new
92
+ version. The model object keeps a response field added to the API after this release as a property. The objects defined inside a model, such as a template's `document`, leave it out. Enum values in responses are strings, so a
93
+ value added after this release comes back as it is: handle values you don't recognize.
package/README.md CHANGED
@@ -6,7 +6,10 @@ templates with your data, generates PDFs from HTML templates, combines PDFs and
6
6
  [Documentation](https://docspring.com/docs/) · [API reference](https://docspring.com/docs/api/) ·
7
7
  [npm](https://www.npmjs.com/package/docspring) · [Changelog](https://github.com/DocSpring/docspring-javascript/blob/main/CHANGELOG.md)
8
8
 
9
- Version 3.3.0.
9
+ The code in this repository is generated from DocSpring's OpenAPI spec ([About this SDK](#about-this-sdk)). Issues and
10
+ pull requests are welcome.
11
+
12
+ Version 4.1.0.
10
13
 
11
14
  ## Install and configure
12
15
 
@@ -59,32 +62,22 @@ Fill a template with data (use your template's ID in place of `tpl_1234567890abc
59
62
 
60
63
  ```javascript
61
64
  const templateId = 'tpl_1234567890abcdef01'
62
- const submission = {
65
+ const body = {
63
66
  data: {
64
67
  first_name: 'John',
65
68
  last_name: 'Smith',
66
69
  phone_number: '+11234567890',
67
70
  },
68
- metadata: { foo: 123, bar: 'baz' },
71
+ metadata: { user_id: 42 },
72
+ test: true,
69
73
  }
70
- const wait = undefined
71
-
72
- apiInstance.generatePdf(
73
- templateId,
74
- submission,
75
- { wait: wait },
76
- (error, data, response) => {
77
- if (error) {
78
- console.error('Error calling generatePdf:', error)
79
- } else {
80
- console.log('API call completed successfully:', data)
81
- }
82
- }
83
- )
74
+
75
+ const result = await apiInstance.createSubmission(templateId, body)
76
+ console.log(result)
84
77
  ```
85
78
 
86
- By default the call waits for the PDF, for up to 95 seconds, and the submission in the response has its
87
- `download_url`. Set `wait` to false to get a pending submission straight away.
79
+ By default the call waits for the PDF, for up to 95 seconds, and the submission in the response has a link to
80
+ download it (`files.pdf.download_url`). Set `wait` to false to get a pending submission straight away.
88
81
  [Sync vs. async processing](https://docspring.com/docs/api-guide/synchronous-requests/) covers the time limit, status
89
82
  checks and webhooks.
90
83
 
@@ -96,83 +89,101 @@ JavaScript code for every method.
96
89
 
97
90
  | Method | Description |
98
91
  | ------ | ----------- |
99
- | [`addFieldsToTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#addfieldstotemplate) | Add new fields to a Template |
100
- | [`batchGeneratePdfs`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#batchgeneratepdfs) | Generate multiple PDFs |
101
- | [`combinePdfs`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#combinepdfs) | Merge submission PDFs, template PDFs, or custom files |
92
+ | [`addTemplateFields`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#addtemplatefields) | Add fields to a template |
102
93
  | [`copyTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#copytemplate) | Copy a template |
103
- | [`createCustomFileFromUpload`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createcustomfilefromupload) | Create a new custom file from a cached S3 upload |
104
- | [`createDataRequestEvent`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createdatarequestevent) | Create a new event for emailing a signee a request for signature |
105
- | [`createDataRequestToken`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createdatarequesttoken) | Create a new data request token for form authentication |
94
+ | [`createCombinedPdf`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createcombinedpdf) | Combine PDFs |
95
+ | [`createCustomFileFromUpload`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createcustomfilefromupload) | Create a custom file from an upload |
106
96
  | [`createFolder`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createfolder) | Create a folder |
107
- | [`createHtmlTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createhtmltemplate) | Create a new HTML template |
108
- | [`createPdfTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createpdftemplate) | Create a new PDF template with a form POST file upload |
109
- | [`createPdfTemplateFromUpload`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createpdftemplatefromupload) | Create a new PDF template from a cached S3 file upload |
97
+ | [`createSignatureRequestEvent`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createsignaturerequestevent) | Record a signature request event |
98
+ | [`createSignatureRequestToken`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createsignaturerequesttoken) | Create a signature request token |
99
+ | [`createSubmission`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createsubmission) | Generate a PDF |
100
+ | [`createSubmissionBatch`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createsubmissionbatch) | Generate PDFs in a batch |
101
+ | [`createTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createtemplate) | Create a template |
110
102
  | [`createWebhook`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createwebhook) | Create a webhook |
103
+ | [`deleteCustomFile`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#deletecustomfile) | Delete a custom file |
111
104
  | [`deleteFolder`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#deletefolder) | Delete a folder |
112
105
  | [`deleteTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#deletetemplate) | Delete a template |
113
106
  | [`deleteWebhook`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#deletewebhook) | Delete a webhook |
114
- | [`expireCombinedSubmission`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#expirecombinedsubmission) | Expire a combined submission |
115
- | [`expireSubmission`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#expiresubmission) | Expire a PDF submission |
116
- | [`generatePdf`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#generatepdf) | Generate a PDF |
117
- | [`generatePreview`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#generatepreview) | Generate a preview PDF for partially completed data requests |
118
- | [`getCombinedSubmission`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getcombinedsubmission) | Check the status of a combined submission (merged PDFs) |
119
- | [`getDataRequest`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getdatarequest) | Look up a submission data request |
120
- | [`getFullTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getfulltemplate) | Fetch the full attributes for a PDF template |
121
- | [`getPresignUrl`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getpresignurl) | Get a presigned S3 URL for direct file upload |
122
- | [`getSubmission`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getsubmission) | Check the status of a PDF |
123
- | [`getSubmissionBatch`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getsubmissionbatch) | Check the status of a submission batch job |
124
- | [`getTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplate) | Check the status of an uploaded template |
125
- | [`getTemplateModelCode`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplatemodelcode) | Generate typed model code for a template |
126
- | [`getTemplateSchema`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplateschema) | Fetch the JSON schema for a template |
107
+ | [`expireCombinedPdf`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#expirecombinedpdf) | Expire a combined PDF |
108
+ | [`expireSubmission`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#expiresubmission) | Expire a submission |
109
+ | [`generateSubmissionFiles`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#generatesubmissionfiles) | Generate more files |
110
+ | [`generateSubmissionPreview`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#generatesubmissionpreview) | Generate a preview PDF |
111
+ | [`getCombinedPdf`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getcombinedpdf) | Get a combined PDF |
112
+ | [`getCustomFile`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getcustomfile) | Get a custom file |
113
+ | [`getFolder`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getfolder) | Get a folder |
114
+ | [`getPresignUrl`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getpresignurl) | Get a presigned URL to upload a file |
115
+ | [`getSignatureRequest`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getsignaturerequest) | Get a signature request |
116
+ | [`getSubmission`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getsubmission) | Get a submission |
117
+ | [`getSubmissionBatch`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getsubmissionbatch) | Get a batch |
118
+ | [`getTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplate) | Get a template |
119
+ | [`getTemplateDiff`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplatediff) | Compare a version of a template with the one before it |
120
+ | [`getTemplateModelCode`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplatemodelcode) | Generate typed code for a template's submission data |
121
+ | [`getTemplatePageImages`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplatepageimages) | Get images of a template's pages |
122
+ | [`getTemplateSchema`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplateschema) | Get the JSON Schema of a template's submission data |
127
123
  | [`getWebhook`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getwebhook) | Get a webhook |
128
- | [`listCombinedSubmissions`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listcombinedsubmissions) | Get a list of all combined submissions |
129
- | [`listFolders`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listfolders) | Get a list of all folders |
130
- | [`listSubmissions`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listsubmissions) | List all submissions |
131
- | [`listTemplates`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listtemplates) | Get a list of all templates |
132
- | [`listTemplateSubmissions`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listtemplatesubmissions) | List all submissions for a given template |
133
- | [`listWebhooks`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listwebhooks) | Get a list of all webhooks |
134
- | [`moveFolderToFolder`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#movefoldertofolder) | Move a folder |
135
- | [`moveTemplateToFolder`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#movetemplatetofolder) | Move Template to folder |
124
+ | [`listCombinedPdfs`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listcombinedpdfs) | List combined PDFs |
125
+ | [`listCustomFiles`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listcustomfiles) | List custom files |
126
+ | [`listFolders`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listfolders) | List folders |
127
+ | [`listSubmissions`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listsubmissions) | List submissions |
128
+ | [`listTemplateFields`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listtemplatefields) | List a template's fields |
129
+ | [`listTemplates`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listtemplates) | List templates |
130
+ | [`listTemplateSubmissions`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listtemplatesubmissions) | List a template's submissions |
131
+ | [`listWebhooks`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listwebhooks) | List webhooks |
132
+ | [`moveFolder`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#movefolder) | Move a folder |
133
+ | [`moveTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#movetemplate) | Move a template to a folder |
136
134
  | [`publishTemplateVersion`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#publishtemplateversion) | Publish a template version |
135
+ | [`removeTemplateFields`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#removetemplatefields) | Remove fields from a template |
137
136
  | [`renameFolder`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#renamefolder) | Rename a folder |
137
+ | [`reorderTemplateFields`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#reordertemplatefields) | Reorder a template's fields |
138
138
  | [`restoreTemplateVersion`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#restoretemplateversion) | Restore a template version |
139
139
  | [`testAuthentication`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#testauthentication) | Test authentication |
140
- | [`updateDataRequest`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatedatarequest) | Update a submission data request |
141
- | [`updateTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatetemplate) | Update a Template |
142
- | [`updateTemplateDocument`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatetemplatedocument) | Update a template's document with a form POST file upload |
143
- | [`updateTemplateDocumentFromUpload`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatetemplatedocumentfromupload) | Update a template's document with a cached S3 file upload |
140
+ | [`updateSignatureRequest`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatesignaturerequest) | Update a signature request |
141
+ | [`updateTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatetemplate) | Update a template |
142
+ | [`updateTemplateDocument`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatetemplatedocument) | Replace a template's PDF |
143
+ | [`updateTemplateFields`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatetemplatefields) | Update a template's fields |
144
144
  | [`updateWebhook`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatewebhook) | Update a webhook |
145
+ | [`uploadTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#uploadtemplate) | Create a PDF template from an uploaded PDF |
146
+ | [`uploadTemplateDocument`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#uploadtemplatedocument) | Replace a template's PDF with an uploaded PDF |
147
+ | [`validateSubmission`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#validatesubmission) | Check a submission without creating it |
145
148
 
146
149
  ## Errors
147
150
 
148
- The callback gets `(error, data, response)`. For an error response, `error.status` is the HTTP status and `response.body` the parsed body.
151
+ Each method returns a promise. For an error response it rejects with an object whose `status` is the HTTP status and `body` the parsed body.
152
+
153
+ The client checks each request against the API's request schemas before sending it. A request the API would reject fails with a `ValidationError` (exported by the package), whose `details` are objects with `code`, `message` and a `pointer` into the body (or a `parameter`). Turn the check off with `client.apiClient.validateRequests = false`.
154
+ The details are the ones the API's 422 response would have, so you get them without a round trip.
149
155
 
150
156
  ## API changes
151
157
 
152
- DocSpring adds fields and enum values to API v1 without releasing a new API version. Changes that would break
158
+ DocSpring adds fields and enum values to API v2 without releasing a new API version. Changes that would break
153
159
  existing code, such as removing or renaming a field, go in a new API version
154
160
  ([API changes](https://docspring.com/docs/api-guide/openapi-schema/#api-changes)). So this SDK keeps working with
155
161
  responses that are newer than it is:
156
162
 
157
- - The model object keeps a response field added to the API after this release as a property.
158
- - An enum value added to the API after this release comes back as a string, so handle values you don't recognize.
163
+ - The model object keeps a response field added to the API after this release as a property. The objects defined inside a model, such as a template's `document`, leave it out.
164
+ - Enum values in responses are strings, so a value added to the API after this release comes back as it is: handle values you don't recognize.
159
165
 
160
166
  Upgrade the SDK to read new fields and enum values. The [changelog](https://github.com/DocSpring/docspring-javascript/blob/main/CHANGELOG.md) lists
161
167
  what each release adds.
162
168
 
163
169
  ## About this SDK
164
170
 
165
- This SDK is generated from DocSpring's [OpenAPI spec](https://docspring.com/api-docs/v1/openapi.json) with
166
- [DocSpring's fork of OpenAPI Generator](https://github.com/DocSpring/openapi-generator/tree/docspring/all_patches) 7.16.0.
167
- The fork doesn't change the JavaScript generator.
171
+ This SDK is generated from DocSpring's [OpenAPI spec](https://docspring.com/api-docs/v2/openapi.json) with
172
+ [DocSpring's fork of OpenAPI Generator](https://github.com/DocSpring/openapi-generator/tree/docspring/all_patches) 7.26.0.
173
+ The fork changes the JavaScript generator:
174
+
175
+ - Enum types have static constants (`SubmissionState.processed`). Stock OpenAPI Generator makes them instance fields.
168
176
 
169
177
  On top of the generated code, we add:
170
178
 
171
179
  - A client constructor that reads your credentials, region and host from the environment.
180
+ - A nested object that's null in a response is `null` (stock OpenAPI Generator makes it `undefined`).
181
+ - A rejected call's `response` is an object with the response's status, headers and body. Stock OpenAPI Generator attaches superagent's response, which holds the request's `Authorization` header, so logging the error printed the API token.
172
182
 
173
- Because the code is generated, we can't merge pull requests that change it. Please
174
- [open an issue](https://github.com/DocSpring/docspring-javascript/issues) or email [support@docspring.com](mailto:support@docspring.com) instead, and
175
- we'll fix it in the generator. [AGENTS.md](https://github.com/DocSpring/docspring-javascript/blob/main/AGENTS.md) is a short guide for AI coding agents.
183
+ Each release regenerates every file, so a change made only here would be lost in the next one. Issues and pull
184
+ requests are welcome all the same: [open an issue](https://github.com/DocSpring/docspring-javascript/issues) or a pull request, or email
185
+ [support@docspring.com](mailto:support@docspring.com), and we'll make the fix in the generator so that every release
186
+ keeps it. [AGENTS.md](https://github.com/DocSpring/docspring-javascript/blob/main/AGENTS.md) is a guide for AI coding agents that integrate this SDK.
176
187
 
177
188
  ## License
178
189
 
package/dist/ApiClient.js CHANGED
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _superagent = _interopRequireDefault(require("superagent"));
8
+ var _RequestValidator = require("./RequestValidator");
8
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
10
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
11
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
@@ -13,9 +14,9 @@ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r),
13
14
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
15
  function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r; if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) { var i = r.call(t, e || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === e ? String : Number)(t); } /**
15
16
  * DocSpring API
16
- * Use DocSpring's API to programmatically fill out PDF forms, convert HTML to PDFs, merge PDFs, or request legally binding e-signatures. Requests are rate limited per account, and live PDFs use credits: a request over the limit returns 429 with a Retry-After header, and one your credits can't cover returns 402. See [Credits & Rate Limits](https://docspring.com/docs/api-guide/credits-and-rate-limits/).
17
+ * Use DocSpring's API to programmatically fill out PDF forms, convert HTML to PDFs, merge PDFs, or request legally binding e-signatures.
17
18
  *
18
- * The version of the OpenAPI document: v1
19
+ * The version of the OpenAPI document: v2
19
20
  *
20
21
  *
21
22
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -23,10 +24,23 @@ function _toPrimitive(t, e) { if ("object" != _typeof(t) || !t) return t; var r;
23
24
  * Do not edit the class manually.
24
25
  *
25
26
  */
27
+ // The parts of a superagent response a caller needs. Its own response holds the request and the Authorization
28
+ // header, which logging the response would print.
29
+ function responseInfo(response) {
30
+ return {
31
+ status: response.status,
32
+ statusText: response.statusText,
33
+ headers: response.headers,
34
+ body: response.body,
35
+ text: response.text
36
+ };
37
+ }
38
+
26
39
  /**
27
40
  * @module ApiClient
28
- * @version 3.3.0
41
+ * @version 4.1.0
29
42
  */
43
+
30
44
  /**
31
45
  * Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an
32
46
  * application to use this class directly - the *Api and model classes provide the public API for the service. The
@@ -41,15 +55,23 @@ var ApiClient = /*#__PURE__*/function () {
41
55
  * @param {String} basePath
42
56
  */
43
57
  function ApiClient() {
44
- var basePath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'https://sync.api.docspring.com/api/v1';
58
+ var basePath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'https://sync.api.docspring.com/api/v2';
45
59
  _classCallCheck(this, ApiClient);
46
60
  /**
47
61
  * The base URL against which to resolve every API call's (relative) path.
48
62
  * @type {String}
49
- * @default https://sync.api.docspring.com/api/v1
63
+ * @default https://sync.api.docspring.com/api/v2
50
64
  */
51
65
  this.basePath = basePath.replace(/\/+$/, '');
52
66
 
67
+ /**
68
+ * Check each request against the API's request schemas before sending it, and reject one the API would reject
69
+ * with a ValidationError that has the API's error details.
70
+ * @type {Boolean}
71
+ * @default true
72
+ */
73
+ this.validateRequests = true;
74
+
53
75
  /**
54
76
  * The authentication methods to be included for all API calls.
55
77
  * @type {Array.<String>}
@@ -66,7 +88,7 @@ var ApiClient = /*#__PURE__*/function () {
66
88
  * @default {}
67
89
  */
68
90
  this.defaultHeaders = {
69
- 'User-Agent': 'docspring-javascript-3.3.0'
91
+ 'User-Agent': 'docspring-javascript-4.1.0'
70
92
  };
71
93
 
72
94
  /**
@@ -376,14 +398,6 @@ var ApiClient = /*#__PURE__*/function () {
376
398
  return ApiClient.convertToType(data, returnType);
377
399
  }
378
400
 
379
- /**
380
- * Callback function to receive the result of the operation.
381
- * @callback module:ApiClient~callApiCallback
382
- * @param {String} error Error message, if any.
383
- * @param data The data returned by the service call.
384
- * @param {String} response The complete HTTP response.
385
- */
386
-
387
401
  /**
388
402
  * Invokes the REST service using the supplied settings and parameters.
389
403
  * @param {String} path The base URL to invoke.
@@ -399,13 +413,19 @@ var ApiClient = /*#__PURE__*/function () {
399
413
  * @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
400
414
  * constructor for a complex type.
401
415
  * @param {String} apiBasePath base path defined in the operation/path level to override the default one
402
- * @param {module:ApiClient~callApiCallback} callback The callback function.
403
- * @returns {Object} The SuperAgent request object.
416
+ * @returns {Promise} A {@link https://www.promisejs.org/|Promise} object.
404
417
  */
405
418
  }, {
406
419
  key: "callApi",
407
- value: function callApi(path, httpMethod, pathParams, queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts, returnType, apiBasePath, callback) {
420
+ value: function callApi(path, httpMethod, pathParams, queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts, returnType, apiBasePath) {
408
421
  var _this3 = this;
422
+ if (this.validateRequests) {
423
+ var hasForm = formParams && Object.keys(formParams).length > 0;
424
+ var validationError = (0, _RequestValidator.requestError)(httpMethod, path, queryParams, hasForm ? formParams : bodyParam, function (value) {
425
+ return _this3.isFileParam(value);
426
+ });
427
+ if (validationError) return Promise.reject(validationError);
428
+ }
409
429
  var url = this.buildUrl(path, pathParams, apiBasePath);
410
430
  var request = (0, _superagent["default"])(httpMethod, url);
411
431
  if (this.plugins !== null) {
@@ -489,23 +509,35 @@ var ApiClient = /*#__PURE__*/function () {
489
509
  request.withCredentials();
490
510
  }
491
511
  }
492
- request.end(function (error, response) {
493
- if (callback) {
494
- var data = null;
495
- if (!error) {
512
+ return new Promise(function (resolve, reject) {
513
+ request.end(function (error, response) {
514
+ if (error) {
515
+ var err = {};
516
+ if (response) {
517
+ err.status = response.status;
518
+ err.statusText = response.statusText;
519
+ err.body = response.body;
520
+ err.response = responseInfo(response);
521
+ }
522
+ delete error.response;
523
+ err.error = error;
524
+ reject(err);
525
+ } else {
496
526
  try {
497
- data = _this3.deserialize(response, returnType);
527
+ var data = _this3.deserialize(response, returnType);
498
528
  if (_this3.enableCookies && typeof window === 'undefined') {
499
529
  _this3.agent._saveCookies(response);
500
530
  }
531
+ resolve({
532
+ data: data,
533
+ response: responseInfo(response)
534
+ });
501
535
  } catch (err) {
502
- error = err;
536
+ reject(err);
503
537
  }
504
538
  }
505
- callback(error, data, response);
506
- }
539
+ });
507
540
  });
508
- return request;
509
541
  }
510
542
 
511
543
  /**
@@ -522,8 +554,11 @@ var ApiClient = /*#__PURE__*/function () {
522
554
  */
523
555
  function hostSettings() {
524
556
  return [{
525
- 'url': "https://sync.api.docspring.com/api/v1",
526
- 'description': "No description provided"
557
+ 'url': "https://sync.api.docspring.com/api/v2",
558
+ 'description': "US region"
559
+ }, {
560
+ 'url': "https://sync.api-eu.docspring.com/api/v2",
561
+ 'description': "EU region"
527
562
  }];
528
563
  }
529
564
  }, {