docspring 3.3.0 → 4.0.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.
- package/AGENTS.md +79 -19
- package/README.md +65 -63
- package/dist/ApiClient.js +63 -28
- package/dist/RequestSchemas.js +2297 -0
- package/dist/RequestValidator.js +494 -0
- package/dist/api/Client.js +1346 -948
- package/dist/index.js +651 -154
- package/dist/model/AiFieldNamingLanguage.js +64 -0
- package/dist/model/{CreateWebhookData.js → AuthenticationCheck.js} +32 -28
- package/dist/model/BarcodeSymbology.js +89 -0
- package/dist/model/CheckCharacter.js +74 -0
- package/dist/model/CombinedFieldType.js +59 -0
- package/dist/model/CombinedPdf.js +294 -0
- package/dist/model/{MoveFolderData.js → CombinedPdfFiles.js} +27 -27
- package/dist/model/CombinedPdfList.js +132 -0
- package/dist/model/{ForbiddenErrorResponse.js → CombinedPdfSource.js} +59 -73
- package/dist/model/CombinedPdfSourceInput.js +270 -0
- package/dist/model/CombinedPdfSourcePdf.js +130 -0
- package/dist/model/CombinedPdfSourceType.js +74 -0
- package/dist/model/CombinedPdfState.js +74 -0
- package/dist/model/{CopyTemplateOptions.js → CopyTemplateRequest.js} +26 -22
- package/dist/model/{CombinePdfsData.js → CreateCombinedPdfRequest.js} +69 -53
- package/dist/model/{CreateCustomFileData.js → CreateCustomFileFromUploadRequest.js} +25 -23
- package/dist/model/{CreateFolderData.js → CreateFolderRequest.js} +47 -28
- package/dist/model/{TemplateDeleteResponse.js → CreateSignatureRequestEventRequest.js} +49 -74
- package/dist/model/CreateSignatureRequestTokenRequest.js +88 -0
- package/dist/model/{SubmissionBatchData.js → CreateSubmissionBatchRequest.js} +67 -42
- package/dist/model/CreateSubmissionRequest.js +212 -0
- package/dist/model/CreateTemplateRequest.js +545 -0
- package/dist/model/CreateWebhookRequest.js +234 -0
- package/dist/model/CustomFile.js +67 -16
- package/dist/model/CustomFileList.js +132 -0
- package/dist/model/CustomFileSourcePdf.js +130 -0
- package/dist/model/ErrorCode.js +154 -0
- package/dist/model/{CreateSubmissionResponse.js → ErrorDetail.js} +65 -75
- package/dist/model/ErrorInfo.js +211 -0
- package/dist/model/ErrorResponse.js +12 -41
- package/dist/model/ExpirationInterval.js +64 -0
- package/dist/model/FieldComparisonCondition.js +137 -0
- package/dist/model/FieldComparisonOperator.js +69 -0
- package/dist/model/FieldDisplayType.js +79 -0
- package/dist/model/{MultipleErrorsResponse.js → FieldEqualsCondition.js} +48 -52
- package/dist/model/FieldEqualsOperator.js +59 -0
- package/dist/model/{SuccessMultipleErrorsResponse.js → FieldInCondition.js} +54 -53
- package/dist/model/FieldOverride.js +722 -0
- package/dist/model/FieldPresenceCondition.js +126 -0
- package/dist/model/FieldPresenceOperator.js +59 -0
- package/dist/model/FieldRangeCondition.js +148 -0
- package/dist/model/FieldReimportState.js +69 -0
- package/dist/model/FieldSetupLogic.js +59 -0
- package/dist/model/FieldSetupNaming.js +59 -0
- package/dist/model/FieldSetupSource.js +64 -0
- package/dist/model/Folder.js +38 -11
- package/dist/model/FolderList.js +132 -0
- package/dist/model/GeneratedFile.js +214 -0
- package/dist/model/GeneratedFileState.js +64 -0
- package/dist/model/HtmlEngineOptions.js +230 -0
- package/dist/model/HtmlEngineOptionsInput.js +193 -0
- package/dist/model/ImageGravity.js +94 -0
- package/dist/model/ImageScaleType.js +64 -0
- package/dist/model/ModelCodeLanguage.js +94 -0
- package/dist/model/{UpdatePdfTemplate.js → MoveFolderRequest.js} +34 -28
- package/dist/model/{MoveTemplateData.js → MoveTemplateRequest.js} +25 -35
- package/dist/model/NumberConditionType.js +79 -0
- package/dist/model/PageFormat.js +114 -0
- package/dist/model/{PublishVersionData.js → PublishTemplateVersionRequest.js} +33 -33
- package/dist/model/{RenameFolderData.js → RenameFolderRequest.js} +25 -23
- package/dist/model/{RestoreVersionData.js → RestoreTemplateVersionRequest.js} +25 -23
- package/dist/model/ShapeType.js +79 -0
- package/dist/model/{SubmissionDataRequestShow.js → SignatureRequest.js} +165 -240
- package/dist/model/SignatureRequestAuthSecondFactorType.js +79 -0
- package/dist/model/SignatureRequestAuthType.js +84 -0
- package/dist/model/{SubmissionDataRequestEvent.js → SignatureRequestEvent.js} +67 -149
- package/dist/model/SignatureRequestEventType.js +79 -0
- package/dist/model/SignatureRequestInput.js +278 -0
- package/dist/model/SignatureRequestMessageType.js +94 -0
- package/dist/model/SignatureRequestState.js +64 -0
- package/dist/model/SignatureRequestToken.js +195 -0
- package/dist/model/SignatureRequestTokenType.js +59 -0
- package/dist/model/StringConditionType.js +74 -0
- package/dist/model/Submission.js +186 -345
- package/dist/model/SubmissionAction.js +30 -115
- package/dist/model/SubmissionActionState.js +69 -0
- package/dist/model/SubmissionActionType.js +84 -0
- package/dist/model/SubmissionBatch.js +74 -55
- package/dist/model/SubmissionBatchState.js +64 -0
- package/dist/model/SubmissionFiles.js +108 -0
- package/dist/model/SubmissionInput.js +204 -0
- package/dist/model/{ListSubmissionsResponse.js → SubmissionList.js} +35 -42
- package/dist/model/SubmissionSource.js +69 -0
- package/dist/model/SubmissionSourcePdf.js +130 -0
- package/dist/model/SubmissionState.js +114 -0
- package/dist/model/Template.js +310 -573
- package/dist/model/TemplateActor.js +171 -0
- package/dist/model/TemplateActorType.js +64 -0
- package/dist/model/TemplateDefaults.js +307 -0
- package/dist/model/TemplateDefaultsInput.js +305 -0
- package/dist/model/TemplateDocument.js +280 -0
- package/dist/model/TemplateDocumentState.js +74 -0
- package/dist/model/{CreatePdfSubmissionData.js → TemplateFieldDependency.js} +70 -89
- package/dist/model/TemplateFieldDependencyAction.js +64 -0
- package/dist/model/{TemplatePublishVersionResponse.js → TemplateFieldDependencyCondition.js} +51 -61
- package/dist/model/TemplateFieldDependencyConditionInput.js +304 -0
- package/dist/model/TemplateFieldDependencyInput.js +182 -0
- package/dist/model/TemplateFieldDependencyMatch.js +59 -0
- package/dist/model/TemplateFieldDependencyOperator.js +99 -0
- package/dist/model/TemplateFieldLogicStatus.js +74 -0
- package/dist/model/TemplateFormMode.js +64 -0
- package/dist/model/{TemplateModelCodeResponse.js → TemplateModelCode.js} +34 -86
- package/dist/model/TemplatePageAiError.js +69 -0
- package/dist/model/TemplatePageAiNamingStatus.js +59 -0
- package/dist/model/TemplatePageFieldsStatus.js +74 -0
- package/dist/model/TemplatePageImageStatus.js +59 -0
- package/dist/model/TemplatePageProcessingStatus.js +162 -0
- package/dist/model/{SubmissionDataRequestToken.js → TemplateSourcePdf.js} +52 -56
- package/dist/model/TemplateSummary.js +560 -0
- package/dist/model/{SuccessErrorResponse.js → TemplateSummaryList.js} +43 -55
- package/dist/model/TemplateType.js +59 -0
- package/dist/model/{Submission422Response.js → TemplateVersion.js} +60 -63
- package/dist/model/TemplateVersionType.js +64 -0
- package/dist/model/TextAlignment.js +69 -0
- package/dist/model/TextOverflow.js +59 -0
- package/dist/model/TextVerticalAlignment.js +64 -0
- package/dist/model/Typeface.js +134 -0
- package/dist/model/UpdateSignatureRequestRequest.js +183 -0
- package/dist/model/UpdateTemplateDocumentRequest.js +136 -0
- package/dist/model/UpdateTemplateRequest.js +450 -0
- package/dist/model/UpdateWebhookRequest.js +209 -0
- package/dist/model/UploadMethod.js +54 -0
- package/dist/model/{UploadPresignResponse.js → UploadPresign.js} +53 -58
- package/dist/model/{AddFieldsData.js → UrlSourcePdf.js} +49 -31
- package/dist/model/Webhook.js +58 -73
- package/dist/model/WebhookEventType.js +174 -0
- package/dist/model/WebhookList.js +132 -0
- package/dist/model/WebhookMode.js +59 -0
- package/package.json +1 -1
- package/dist/model/BatchGeneratePdfs201Response.js +0 -194
- package/dist/model/CombinedSubmission.js +0 -313
- package/dist/model/CombinedSubmissionAction.js +0 -268
- package/dist/model/CreateCombinedSubmissionResponse.js +0 -180
- package/dist/model/CreateCustomFileResponse.js +0 -167
- package/dist/model/CreateHtmlTemplate.js +0 -108
- package/dist/model/CreatePdfTemplate.js +0 -108
- package/dist/model/CreateSubmissionDataRequestData.js +0 -314
- package/dist/model/CreateSubmissionDataRequestEventRequest.js +0 -239
- package/dist/model/CreateSubmissionDataRequestEventResponse.js +0 -167
- package/dist/model/CreateSubmissionDataRequestResponse.js +0 -167
- package/dist/model/CreateSubmissionDataRequestTokenResponse.js +0 -167
- package/dist/model/ErrorOrMultipleErrorsResponse.js +0 -153
- package/dist/model/JsonSchema.js +0 -205
- package/dist/model/SubmissionBatchWithSubmissions.js +0 -228
- package/dist/model/SubmissionDataRequest.js +0 -496
- package/dist/model/SubmissionPreview.js +0 -509
- package/dist/model/TemplateAddFieldsResponse.js +0 -156
- package/dist/model/TemplatePreview.js +0 -796
- package/dist/model/UpdateHtmlTemplate.js +0 -108
- package/dist/model/UpdateSubmissionDataRequestData.js +0 -311
- 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`)
|
|
4
|
-
|
|
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
|
|
11
|
-
|
|
12
|
-
|
|
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
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
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.0.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
|
|
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: {
|
|
71
|
+
metadata: { user_id: 42 },
|
|
72
|
+
test: true,
|
|
69
73
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
|
87
|
-
`download_url
|
|
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,92 @@ 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 |
|
|
102
92
|
| [`copyTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#copytemplate) | Copy a template |
|
|
103
|
-
| [`
|
|
104
|
-
| [`
|
|
105
|
-
| [`createDataRequestToken`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createdatarequesttoken) | Create a new data request token for form authentication |
|
|
93
|
+
| [`createCombinedPdf`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createcombinedpdf) | Combine PDFs |
|
|
94
|
+
| [`createCustomFileFromUpload`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createcustomfilefromupload) | Create a custom file from an upload |
|
|
106
95
|
| [`createFolder`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createfolder) | Create a folder |
|
|
107
|
-
| [`
|
|
108
|
-
| [`
|
|
109
|
-
| [`
|
|
96
|
+
| [`createSignatureRequestEvent`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createsignaturerequestevent) | Record a signature request event |
|
|
97
|
+
| [`createSignatureRequestToken`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createsignaturerequesttoken) | Create a signature request token |
|
|
98
|
+
| [`createSubmission`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createsubmission) | Generate a PDF |
|
|
99
|
+
| [`createSubmissionBatch`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createsubmissionbatch) | Generate PDFs in a batch |
|
|
100
|
+
| [`createTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createtemplate) | Create a template |
|
|
110
101
|
| [`createWebhook`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#createwebhook) | Create a webhook |
|
|
102
|
+
| [`deleteCustomFile`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#deletecustomfile) | Delete a custom file |
|
|
111
103
|
| [`deleteFolder`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#deletefolder) | Delete a folder |
|
|
112
104
|
| [`deleteTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#deletetemplate) | Delete a template |
|
|
113
105
|
| [`deleteWebhook`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#deletewebhook) | Delete a webhook |
|
|
114
|
-
| [`
|
|
115
|
-
| [`expireSubmission`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#expiresubmission) | Expire a
|
|
116
|
-
| [`
|
|
117
|
-
| [`
|
|
118
|
-
| [`
|
|
119
|
-
| [`
|
|
120
|
-
| [`
|
|
121
|
-
| [`
|
|
122
|
-
| [`getSubmission`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getsubmission) |
|
|
123
|
-
| [`getSubmissionBatch`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getsubmissionbatch) |
|
|
124
|
-
| [`getTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplate) |
|
|
125
|
-
| [`getTemplateModelCode`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplatemodelcode) | Generate typed
|
|
126
|
-
| [`getTemplateSchema`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplateschema) |
|
|
106
|
+
| [`expireCombinedPdf`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#expirecombinedpdf) | Expire a combined PDF |
|
|
107
|
+
| [`expireSubmission`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#expiresubmission) | Expire a submission |
|
|
108
|
+
| [`generateSubmissionPreview`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#generatesubmissionpreview) | Generate a preview PDF |
|
|
109
|
+
| [`getCombinedPdf`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getcombinedpdf) | Get a combined PDF |
|
|
110
|
+
| [`getCustomFile`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getcustomfile) | Get a custom file |
|
|
111
|
+
| [`getFolder`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getfolder) | Get a folder |
|
|
112
|
+
| [`getPresignUrl`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getpresignurl) | Get a presigned URL to upload a file |
|
|
113
|
+
| [`getSignatureRequest`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getsignaturerequest) | Get a signature request |
|
|
114
|
+
| [`getSubmission`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getsubmission) | Get a submission |
|
|
115
|
+
| [`getSubmissionBatch`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getsubmissionbatch) | Get a batch |
|
|
116
|
+
| [`getTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplate) | Get a template |
|
|
117
|
+
| [`getTemplateModelCode`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplatemodelcode) | Generate typed code for a template's submission data |
|
|
118
|
+
| [`getTemplateSchema`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#gettemplateschema) | Get the JSON Schema of a template's submission data |
|
|
127
119
|
| [`getWebhook`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#getwebhook) | Get a webhook |
|
|
128
|
-
| [`
|
|
129
|
-
| [`
|
|
130
|
-
| [`
|
|
131
|
-
| [`
|
|
132
|
-
| [`
|
|
133
|
-
| [`
|
|
134
|
-
| [`
|
|
135
|
-
| [`
|
|
120
|
+
| [`listCombinedPdfs`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listcombinedpdfs) | List combined PDFs |
|
|
121
|
+
| [`listCustomFiles`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listcustomfiles) | List custom files |
|
|
122
|
+
| [`listFolders`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listfolders) | List folders |
|
|
123
|
+
| [`listSubmissions`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listsubmissions) | List submissions |
|
|
124
|
+
| [`listTemplates`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listtemplates) | List templates |
|
|
125
|
+
| [`listTemplateSubmissions`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listtemplatesubmissions) | List a template's submissions |
|
|
126
|
+
| [`listWebhooks`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#listwebhooks) | List webhooks |
|
|
127
|
+
| [`moveFolder`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#movefolder) | Move a folder |
|
|
128
|
+
| [`moveTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#movetemplate) | Move a template to a folder |
|
|
136
129
|
| [`publishTemplateVersion`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#publishtemplateversion) | Publish a template version |
|
|
137
130
|
| [`renameFolder`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#renamefolder) | Rename a folder |
|
|
138
131
|
| [`restoreTemplateVersion`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#restoretemplateversion) | Restore a template version |
|
|
139
132
|
| [`testAuthentication`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#testauthentication) | Test authentication |
|
|
140
|
-
| [`
|
|
141
|
-
| [`updateTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatetemplate) | Update a
|
|
142
|
-
| [`updateTemplateDocument`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatetemplatedocument) |
|
|
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 |
|
|
133
|
+
| [`updateSignatureRequest`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatesignaturerequest) | Update a signature request |
|
|
134
|
+
| [`updateTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatetemplate) | Update a template |
|
|
135
|
+
| [`updateTemplateDocument`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatetemplatedocument) | Replace a template's PDF |
|
|
144
136
|
| [`updateWebhook`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#updatewebhook) | Update a webhook |
|
|
137
|
+
| [`uploadTemplate`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#uploadtemplate) | Create a PDF template from an uploaded PDF |
|
|
138
|
+
| [`uploadTemplateDocument`](https://github.com/DocSpring/docspring-javascript/blob/main/docs/Client.md#uploadtemplatedocument) | Replace a template's PDF with an uploaded PDF |
|
|
145
139
|
|
|
146
140
|
## Errors
|
|
147
141
|
|
|
148
|
-
|
|
142
|
+
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.
|
|
143
|
+
|
|
144
|
+
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`.
|
|
145
|
+
The details are the ones the API's 422 response would have, so you get them without a round trip.
|
|
149
146
|
|
|
150
147
|
## API changes
|
|
151
148
|
|
|
152
|
-
DocSpring adds fields and enum values to API
|
|
149
|
+
DocSpring adds fields and enum values to API v2 without releasing a new API version. Changes that would break
|
|
153
150
|
existing code, such as removing or renaming a field, go in a new API version
|
|
154
151
|
([API changes](https://docspring.com/docs/api-guide/openapi-schema/#api-changes)). So this SDK keeps working with
|
|
155
152
|
responses that are newer than it is:
|
|
156
153
|
|
|
157
|
-
- The model object keeps a response field added to the API after this release as a property.
|
|
158
|
-
-
|
|
154
|
+
- 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.
|
|
155
|
+
- 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
156
|
|
|
160
157
|
Upgrade the SDK to read new fields and enum values. The [changelog](https://github.com/DocSpring/docspring-javascript/blob/main/CHANGELOG.md) lists
|
|
161
158
|
what each release adds.
|
|
162
159
|
|
|
163
160
|
## About this SDK
|
|
164
161
|
|
|
165
|
-
This SDK is generated from DocSpring's [OpenAPI spec](https://docspring.com/api-docs/
|
|
166
|
-
[DocSpring's fork of OpenAPI Generator](https://github.com/DocSpring/openapi-generator/tree/docspring/all_patches) 7.
|
|
167
|
-
The fork
|
|
162
|
+
This SDK is generated from DocSpring's [OpenAPI spec](https://docspring.com/api-docs/v2/openapi.json) with
|
|
163
|
+
[DocSpring's fork of OpenAPI Generator](https://github.com/DocSpring/openapi-generator/tree/docspring/all_patches) 7.26.0.
|
|
164
|
+
The fork changes the JavaScript generator:
|
|
165
|
+
|
|
166
|
+
- Enum types have static constants (`SubmissionState.processed`). Stock OpenAPI Generator makes them instance fields.
|
|
168
167
|
|
|
169
168
|
On top of the generated code, we add:
|
|
170
169
|
|
|
171
170
|
- A client constructor that reads your credentials, region and host from the environment.
|
|
171
|
+
- A nested object that's null in a response is `null` (stock OpenAPI Generator makes it `undefined`).
|
|
172
|
+
- 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
173
|
|
|
173
|
-
|
|
174
|
-
[open an issue](https://github.com/DocSpring/docspring-javascript/issues) or
|
|
175
|
-
we'll fix
|
|
174
|
+
Each release regenerates every file, so a change made only here would be lost in the next one. Issues and pull
|
|
175
|
+
requests are welcome all the same: [open an issue](https://github.com/DocSpring/docspring-javascript/issues) or a pull request, or email
|
|
176
|
+
[support@docspring.com](mailto:support@docspring.com), and we'll make the fix in the generator so that every release
|
|
177
|
+
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
178
|
|
|
177
179
|
## License
|
|
178
180
|
|
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.
|
|
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:
|
|
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
|
|
41
|
+
* @version 4.0.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/
|
|
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/
|
|
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-
|
|
91
|
+
'User-Agent': 'docspring-javascript-4.0.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
|
-
* @
|
|
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
|
|
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
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
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
|
-
|
|
536
|
+
reject(err);
|
|
503
537
|
}
|
|
504
538
|
}
|
|
505
|
-
|
|
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/
|
|
526
|
-
'description': "
|
|
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
|
}, {
|