mirror of
https://github.com/documenso/documenso.git
synced 2025-11-15 09:12:02 +10:00
Compare commits
1 Commits
3bcd023b00
...
fix/envelo
| Author | SHA1 | Date | |
|---|---|---|---|
| bbf44acda3 |
@ -22,15 +22,6 @@ Documenso supports Webhooks and allows you to subscribe to the following events:
|
|||||||
- `document.completed`
|
- `document.completed`
|
||||||
- `document.rejected`
|
- `document.rejected`
|
||||||
- `document.cancelled`
|
- `document.cancelled`
|
||||||
- `document.viewed`
|
|
||||||
- `document.recipient.completed`
|
|
||||||
- `document.downloaded`
|
|
||||||
- `document.reminder.sent`
|
|
||||||
- `template.created`
|
|
||||||
- `template.updated`
|
|
||||||
- `template.deleted`
|
|
||||||
- `template.used`
|
|
||||||
- `recipient.authentication.failed`
|
|
||||||
|
|
||||||
## Create a webhook subscription
|
## Create a webhook subscription
|
||||||
|
|
||||||
@ -47,7 +38,7 @@ Clicking on the "**Create Webhook**" button opens a modal to create a new webhoo
|
|||||||
To create a new webhook subscription, you need to provide the following information:
|
To create a new webhook subscription, you need to provide the following information:
|
||||||
|
|
||||||
- Enter the webhook URL that will receive the event payload.
|
- Enter the webhook URL that will receive the event payload.
|
||||||
- Select the event(s) you want to subscribe to: `document.created`, `document.sent`, `document.opened`, `document.signed`, `document.completed`, `document.rejected`, `document.cancelled`, `document.viewed`, `document.recipient.completed`, `document.downloaded`, `document.reminder.sent`, `template.created`, `template.updated`, `template.deleted`, `template.used`, `recipient.authentication.failed`.
|
- Select the event(s) you want to subscribe to: `document.created`, `document.sent`, `document.opened`, `document.signed`, `document.completed`, `document.rejected`, `document.cancelled`.
|
||||||
- Optionally, you can provide a secret key that will be used to sign the payload. This key will be included in the `X-Documenso-Secret` header of the request.
|
- Optionally, you can provide a secret key that will be used to sign the payload. This key will be included in the `X-Documenso-Secret` header of the request.
|
||||||
|
|
||||||

|

|
||||||
@ -628,591 +619,6 @@ Example payload for the `document.rejected` event:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Example payload for the `document.viewed` event:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"event": "DOCUMENT_VIEWED",
|
|
||||||
"payload": {
|
|
||||||
"id": 10,
|
|
||||||
"externalId": null,
|
|
||||||
"userId": 1,
|
|
||||||
"authOptions": null,
|
|
||||||
"formValues": null,
|
|
||||||
"visibility": "EVERYONE",
|
|
||||||
"title": "documenso.pdf",
|
|
||||||
"status": "PENDING",
|
|
||||||
"documentDataId": "hs8qz1ktr9204jn7mg6c5dxy0",
|
|
||||||
"createdAt": "2024-04-22T11:44:43.341Z",
|
|
||||||
"updatedAt": "2024-04-22T11:48:07.569Z",
|
|
||||||
"completedAt": null,
|
|
||||||
"deletedAt": null,
|
|
||||||
"teamId": null,
|
|
||||||
"templateId": null,
|
|
||||||
"source": "DOCUMENT",
|
|
||||||
"documentMeta": {
|
|
||||||
"id": "doc_meta_123",
|
|
||||||
"subject": "Please sign this document",
|
|
||||||
"message": "Hello, please review and sign this document.",
|
|
||||||
"timezone": "UTC",
|
|
||||||
"password": null,
|
|
||||||
"dateFormat": "MM/DD/YYYY",
|
|
||||||
"redirectUrl": null,
|
|
||||||
"signingOrder": "PARALLEL",
|
|
||||||
"typedSignatureEnabled": true,
|
|
||||||
"language": "en",
|
|
||||||
"distributionMethod": "EMAIL",
|
|
||||||
"emailSettings": null
|
|
||||||
},
|
|
||||||
"Recipient": [
|
|
||||||
{
|
|
||||||
"id": 52,
|
|
||||||
"documentId": 10,
|
|
||||||
"templateId": null,
|
|
||||||
"email": "signer@documenso.com",
|
|
||||||
"name": "John Doe",
|
|
||||||
"token": "vbT8hi3jKQmrFP_LN1WcS",
|
|
||||||
"documentDeletedAt": null,
|
|
||||||
"expired": null,
|
|
||||||
"signedAt": null,
|
|
||||||
"authOptions": null,
|
|
||||||
"signingOrder": 1,
|
|
||||||
"rejectionReason": null,
|
|
||||||
"role": "SIGNER",
|
|
||||||
"readStatus": "OPENED",
|
|
||||||
"signingStatus": "NOT_SIGNED",
|
|
||||||
"sendStatus": "SENT"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"createdAt": "2024-04-22T11:50:26.174Z",
|
|
||||||
"webhookEndpoint": "https://mywebhooksite.com/mywebhook"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Example payload for the `document.recipient.completed` event:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"event": "DOCUMENT_RECIPIENT_COMPLETED",
|
|
||||||
"payload": {
|
|
||||||
"id": 10,
|
|
||||||
"externalId": null,
|
|
||||||
"userId": 1,
|
|
||||||
"authOptions": null,
|
|
||||||
"formValues": null,
|
|
||||||
"visibility": "EVERYONE",
|
|
||||||
"title": "documenso.pdf",
|
|
||||||
"status": "PENDING",
|
|
||||||
"documentDataId": "hs8qz1ktr9204jn7mg6c5dxy0",
|
|
||||||
"createdAt": "2024-04-22T11:44:43.341Z",
|
|
||||||
"updatedAt": "2024-04-22T11:51:10.055Z",
|
|
||||||
"completedAt": null,
|
|
||||||
"deletedAt": null,
|
|
||||||
"teamId": null,
|
|
||||||
"templateId": null,
|
|
||||||
"source": "DOCUMENT",
|
|
||||||
"documentMeta": {
|
|
||||||
"id": "doc_meta_123",
|
|
||||||
"subject": "Please sign this document",
|
|
||||||
"message": "Hello, please review and sign this document.",
|
|
||||||
"timezone": "UTC",
|
|
||||||
"password": null,
|
|
||||||
"dateFormat": "MM/DD/YYYY",
|
|
||||||
"redirectUrl": null,
|
|
||||||
"signingOrder": "PARALLEL",
|
|
||||||
"typedSignatureEnabled": true,
|
|
||||||
"language": "en",
|
|
||||||
"distributionMethod": "EMAIL",
|
|
||||||
"emailSettings": null
|
|
||||||
},
|
|
||||||
"Recipient": [
|
|
||||||
{
|
|
||||||
"id": 50,
|
|
||||||
"documentId": 10,
|
|
||||||
"templateId": null,
|
|
||||||
"email": "signer1@documenso.com",
|
|
||||||
"name": "Signer 1",
|
|
||||||
"token": "vbT8hi3jKQmrFP_LN1WcS",
|
|
||||||
"documentDeletedAt": null,
|
|
||||||
"expired": null,
|
|
||||||
"signedAt": "2024-04-22T11:51:10.055Z",
|
|
||||||
"authOptions": {
|
|
||||||
"accessAuth": null,
|
|
||||||
"actionAuth": null
|
|
||||||
},
|
|
||||||
"signingOrder": 1,
|
|
||||||
"rejectionReason": null,
|
|
||||||
"role": "SIGNER",
|
|
||||||
"readStatus": "OPENED",
|
|
||||||
"signingStatus": "SIGNED",
|
|
||||||
"sendStatus": "SENT"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 51,
|
|
||||||
"documentId": 10,
|
|
||||||
"templateId": null,
|
|
||||||
"email": "signer2@documenso.com",
|
|
||||||
"name": "Signer 2",
|
|
||||||
"token": "HkrptwS42ZBXdRKj1TyUo",
|
|
||||||
"documentDeletedAt": null,
|
|
||||||
"expired": null,
|
|
||||||
"signedAt": null,
|
|
||||||
"authOptions": null,
|
|
||||||
"signingOrder": 2,
|
|
||||||
"rejectionReason": null,
|
|
||||||
"role": "SIGNER",
|
|
||||||
"readStatus": "NOT_OPENED",
|
|
||||||
"signingStatus": "NOT_SIGNED",
|
|
||||||
"sendStatus": "SENT"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"createdAt": "2024-04-22T11:51:10.577Z",
|
|
||||||
"webhookEndpoint": "https://mywebhooksite.com/mywebhook"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Example payload for the `document.downloaded` event:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"event": "DOCUMENT_DOWNLOADED",
|
|
||||||
"payload": {
|
|
||||||
"id": 10,
|
|
||||||
"externalId": null,
|
|
||||||
"userId": 1,
|
|
||||||
"authOptions": null,
|
|
||||||
"formValues": null,
|
|
||||||
"visibility": "EVERYONE",
|
|
||||||
"title": "documenso.pdf",
|
|
||||||
"status": "COMPLETED",
|
|
||||||
"documentDataId": "hs8qz1ktr9204jn7mg6c5dxy0",
|
|
||||||
"createdAt": "2024-04-22T11:44:43.341Z",
|
|
||||||
"updatedAt": "2024-04-22T11:52:05.708Z",
|
|
||||||
"completedAt": "2024-04-22T11:52:05.707Z",
|
|
||||||
"deletedAt": null,
|
|
||||||
"teamId": null,
|
|
||||||
"templateId": null,
|
|
||||||
"source": "DOCUMENT",
|
|
||||||
"documentMeta": {
|
|
||||||
"id": "doc_meta_123",
|
|
||||||
"subject": "Please sign this document",
|
|
||||||
"message": "Hello, please review and sign this document.",
|
|
||||||
"timezone": "UTC",
|
|
||||||
"password": null,
|
|
||||||
"dateFormat": "MM/DD/YYYY",
|
|
||||||
"redirectUrl": null,
|
|
||||||
"signingOrder": "PARALLEL",
|
|
||||||
"typedSignatureEnabled": true,
|
|
||||||
"language": "en",
|
|
||||||
"distributionMethod": "EMAIL",
|
|
||||||
"emailSettings": null
|
|
||||||
},
|
|
||||||
"Recipient": [
|
|
||||||
{
|
|
||||||
"id": 51,
|
|
||||||
"documentId": 10,
|
|
||||||
"templateId": null,
|
|
||||||
"email": "signer@documenso.com",
|
|
||||||
"name": "Signer",
|
|
||||||
"token": "HkrptwS42ZBXdRKj1TyUo",
|
|
||||||
"documentDeletedAt": null,
|
|
||||||
"expired": null,
|
|
||||||
"signedAt": "2024-04-22T11:52:05.688Z",
|
|
||||||
"authOptions": {
|
|
||||||
"accessAuth": null,
|
|
||||||
"actionAuth": null
|
|
||||||
},
|
|
||||||
"signingOrder": 1,
|
|
||||||
"rejectionReason": null,
|
|
||||||
"role": "SIGNER",
|
|
||||||
"readStatus": "OPENED",
|
|
||||||
"signingStatus": "SIGNED",
|
|
||||||
"sendStatus": "SENT"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"createdAt": "2024-04-22T11:53:18.577Z",
|
|
||||||
"webhookEndpoint": "https://mywebhooksite.com/mywebhook"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Example payload for the `document.reminder.sent` event:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"event": "DOCUMENT_REMINDER_SENT",
|
|
||||||
"payload": {
|
|
||||||
"id": 10,
|
|
||||||
"externalId": null,
|
|
||||||
"userId": 1,
|
|
||||||
"authOptions": null,
|
|
||||||
"formValues": null,
|
|
||||||
"visibility": "EVERYONE",
|
|
||||||
"title": "documenso.pdf",
|
|
||||||
"status": "PENDING",
|
|
||||||
"documentDataId": "hs8qz1ktr9204jn7mg6c5dxy0",
|
|
||||||
"createdAt": "2024-04-22T11:44:43.341Z",
|
|
||||||
"updatedAt": "2024-04-22T11:48:07.569Z",
|
|
||||||
"completedAt": null,
|
|
||||||
"deletedAt": null,
|
|
||||||
"teamId": null,
|
|
||||||
"templateId": null,
|
|
||||||
"source": "DOCUMENT",
|
|
||||||
"documentMeta": {
|
|
||||||
"id": "doc_meta_123",
|
|
||||||
"subject": "Please sign this document",
|
|
||||||
"message": "Hello, please review and sign this document.",
|
|
||||||
"timezone": "UTC",
|
|
||||||
"password": null,
|
|
||||||
"dateFormat": "MM/DD/YYYY",
|
|
||||||
"redirectUrl": null,
|
|
||||||
"signingOrder": "PARALLEL",
|
|
||||||
"typedSignatureEnabled": true,
|
|
||||||
"language": "en",
|
|
||||||
"distributionMethod": "EMAIL",
|
|
||||||
"emailSettings": null
|
|
||||||
},
|
|
||||||
"Recipient": [
|
|
||||||
{
|
|
||||||
"id": 52,
|
|
||||||
"documentId": 10,
|
|
||||||
"templateId": null,
|
|
||||||
"email": "signer@documenso.com",
|
|
||||||
"name": "Signer",
|
|
||||||
"token": "vbT8hi3jKQmrFP_LN1WcS",
|
|
||||||
"documentDeletedAt": null,
|
|
||||||
"expired": null,
|
|
||||||
"signedAt": null,
|
|
||||||
"authOptions": null,
|
|
||||||
"signingOrder": 1,
|
|
||||||
"rejectionReason": null,
|
|
||||||
"role": "SIGNER",
|
|
||||||
"readStatus": "OPENED",
|
|
||||||
"signingStatus": "NOT_SIGNED",
|
|
||||||
"sendStatus": "SENT"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"createdAt": "2024-04-22T12:00:00.000Z",
|
|
||||||
"webhookEndpoint": "https://mywebhooksite.com/mywebhook"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Example payload for the `template.created` event:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"event": "TEMPLATE_CREATED",
|
|
||||||
"payload": {
|
|
||||||
"id": 5,
|
|
||||||
"externalId": null,
|
|
||||||
"userId": 1,
|
|
||||||
"authOptions": null,
|
|
||||||
"formValues": null,
|
|
||||||
"visibility": "EVERYONE",
|
|
||||||
"title": "employment_contract.pdf",
|
|
||||||
"status": "DRAFT",
|
|
||||||
"documentDataId": "hs8qz1ktr9204jn7mg6c5dxy0",
|
|
||||||
"createdAt": "2024-04-22T11:44:43.341Z",
|
|
||||||
"updatedAt": "2024-04-22T11:44:43.341Z",
|
|
||||||
"completedAt": null,
|
|
||||||
"deletedAt": null,
|
|
||||||
"teamId": 2,
|
|
||||||
"templateId": 5,
|
|
||||||
"source": "TEMPLATE",
|
|
||||||
"documentMeta": {
|
|
||||||
"id": "doc_meta_456",
|
|
||||||
"subject": "Employment Contract",
|
|
||||||
"message": "Please review and sign your employment contract.",
|
|
||||||
"timezone": "UTC",
|
|
||||||
"password": null,
|
|
||||||
"dateFormat": "MM/DD/YYYY",
|
|
||||||
"redirectUrl": null,
|
|
||||||
"signingOrder": "PARALLEL",
|
|
||||||
"typedSignatureEnabled": true,
|
|
||||||
"language": "en",
|
|
||||||
"distributionMethod": "EMAIL",
|
|
||||||
"emailSettings": null
|
|
||||||
},
|
|
||||||
"Recipient": [
|
|
||||||
{
|
|
||||||
"id": 25,
|
|
||||||
"documentId": null,
|
|
||||||
"templateId": 5,
|
|
||||||
"email": "employee@company.com",
|
|
||||||
"name": "Employee",
|
|
||||||
"token": "TemplateToken123",
|
|
||||||
"documentDeletedAt": null,
|
|
||||||
"expired": null,
|
|
||||||
"signedAt": null,
|
|
||||||
"authOptions": null,
|
|
||||||
"signingOrder": 1,
|
|
||||||
"rejectionReason": null,
|
|
||||||
"role": "SIGNER",
|
|
||||||
"readStatus": "NOT_OPENED",
|
|
||||||
"signingStatus": "NOT_SIGNED",
|
|
||||||
"sendStatus": "NOT_SENT"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"createdAt": "2024-04-22T11:44:44.779Z",
|
|
||||||
"webhookEndpoint": "https://mywebhooksite.com/mywebhook"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Example payload for the `template.updated` event:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"event": "TEMPLATE_UPDATED",
|
|
||||||
"payload": {
|
|
||||||
"id": 5,
|
|
||||||
"externalId": null,
|
|
||||||
"userId": 1,
|
|
||||||
"authOptions": null,
|
|
||||||
"formValues": null,
|
|
||||||
"visibility": "EVERYONE",
|
|
||||||
"title": "employment_contract_v2.pdf",
|
|
||||||
"status": "DRAFT",
|
|
||||||
"documentDataId": "hs8qz1ktr9204jn7mg6c5dxy0",
|
|
||||||
"createdAt": "2024-04-22T11:44:43.341Z",
|
|
||||||
"updatedAt": "2024-04-22T12:30:00.000Z",
|
|
||||||
"completedAt": null,
|
|
||||||
"deletedAt": null,
|
|
||||||
"teamId": 2,
|
|
||||||
"templateId": 5,
|
|
||||||
"source": "TEMPLATE",
|
|
||||||
"documentMeta": {
|
|
||||||
"id": "doc_meta_456",
|
|
||||||
"subject": "Employment Contract - Updated",
|
|
||||||
"message": "Please review and sign your employment contract.",
|
|
||||||
"timezone": "UTC",
|
|
||||||
"password": null,
|
|
||||||
"dateFormat": "MM/DD/YYYY",
|
|
||||||
"redirectUrl": null,
|
|
||||||
"signingOrder": "PARALLEL",
|
|
||||||
"typedSignatureEnabled": true,
|
|
||||||
"language": "en",
|
|
||||||
"distributionMethod": "EMAIL",
|
|
||||||
"emailSettings": null
|
|
||||||
},
|
|
||||||
"Recipient": [
|
|
||||||
{
|
|
||||||
"id": 25,
|
|
||||||
"documentId": null,
|
|
||||||
"templateId": 5,
|
|
||||||
"email": "employee@company.com",
|
|
||||||
"name": "Employee",
|
|
||||||
"token": "TemplateToken123",
|
|
||||||
"documentDeletedAt": null,
|
|
||||||
"expired": null,
|
|
||||||
"signedAt": null,
|
|
||||||
"authOptions": null,
|
|
||||||
"signingOrder": 1,
|
|
||||||
"rejectionReason": null,
|
|
||||||
"role": "SIGNER",
|
|
||||||
"readStatus": "NOT_OPENED",
|
|
||||||
"signingStatus": "NOT_SIGNED",
|
|
||||||
"sendStatus": "NOT_SENT"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"createdAt": "2024-04-22T12:30:01.000Z",
|
|
||||||
"webhookEndpoint": "https://mywebhooksite.com/mywebhook"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Example payload for the `template.deleted` event:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"event": "TEMPLATE_DELETED",
|
|
||||||
"payload": {
|
|
||||||
"id": 5,
|
|
||||||
"externalId": null,
|
|
||||||
"userId": 1,
|
|
||||||
"authOptions": null,
|
|
||||||
"formValues": null,
|
|
||||||
"visibility": "EVERYONE",
|
|
||||||
"title": "employment_contract.pdf",
|
|
||||||
"status": "DRAFT",
|
|
||||||
"documentDataId": "hs8qz1ktr9204jn7mg6c5dxy0",
|
|
||||||
"createdAt": "2024-04-22T11:44:43.341Z",
|
|
||||||
"updatedAt": "2024-04-22T11:44:43.341Z",
|
|
||||||
"completedAt": null,
|
|
||||||
"deletedAt": null,
|
|
||||||
"teamId": 2,
|
|
||||||
"templateId": 5,
|
|
||||||
"source": "TEMPLATE",
|
|
||||||
"documentMeta": {
|
|
||||||
"id": "doc_meta_456",
|
|
||||||
"subject": "Employment Contract",
|
|
||||||
"message": "Please review and sign your employment contract.",
|
|
||||||
"timezone": "UTC",
|
|
||||||
"password": null,
|
|
||||||
"dateFormat": "MM/DD/YYYY",
|
|
||||||
"redirectUrl": null,
|
|
||||||
"signingOrder": "PARALLEL",
|
|
||||||
"typedSignatureEnabled": true,
|
|
||||||
"language": "en",
|
|
||||||
"distributionMethod": "EMAIL",
|
|
||||||
"emailSettings": null
|
|
||||||
},
|
|
||||||
"Recipient": [
|
|
||||||
{
|
|
||||||
"id": 25,
|
|
||||||
"documentId": null,
|
|
||||||
"templateId": 5,
|
|
||||||
"email": "employee@company.com",
|
|
||||||
"name": "Employee",
|
|
||||||
"token": "TemplateToken123",
|
|
||||||
"documentDeletedAt": null,
|
|
||||||
"expired": null,
|
|
||||||
"signedAt": null,
|
|
||||||
"authOptions": null,
|
|
||||||
"signingOrder": 1,
|
|
||||||
"rejectionReason": null,
|
|
||||||
"role": "SIGNER",
|
|
||||||
"readStatus": "NOT_OPENED",
|
|
||||||
"signingStatus": "NOT_SIGNED",
|
|
||||||
"sendStatus": "NOT_SENT"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"createdAt": "2024-04-22T13:00:00.000Z",
|
|
||||||
"webhookEndpoint": "https://mywebhooksite.com/mywebhook"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Example payload for the `template.used` event:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"event": "TEMPLATE_USED",
|
|
||||||
"payload": {
|
|
||||||
"id": 15,
|
|
||||||
"externalId": null,
|
|
||||||
"userId": 1,
|
|
||||||
"authOptions": null,
|
|
||||||
"formValues": null,
|
|
||||||
"visibility": "EVERYONE",
|
|
||||||
"title": "employment_contract.pdf",
|
|
||||||
"status": "DRAFT",
|
|
||||||
"documentDataId": "new_doc_data_123",
|
|
||||||
"createdAt": "2024-04-22T14:00:00.000Z",
|
|
||||||
"updatedAt": "2024-04-22T14:00:00.000Z",
|
|
||||||
"completedAt": null,
|
|
||||||
"deletedAt": null,
|
|
||||||
"teamId": 2,
|
|
||||||
"templateId": 5,
|
|
||||||
"source": "TEMPLATE",
|
|
||||||
"documentMeta": {
|
|
||||||
"id": "doc_meta_789",
|
|
||||||
"subject": "Employment Contract",
|
|
||||||
"message": "Please review and sign your employment contract.",
|
|
||||||
"timezone": "UTC",
|
|
||||||
"password": null,
|
|
||||||
"dateFormat": "MM/DD/YYYY",
|
|
||||||
"redirectUrl": null,
|
|
||||||
"signingOrder": "PARALLEL",
|
|
||||||
"typedSignatureEnabled": true,
|
|
||||||
"language": "en",
|
|
||||||
"distributionMethod": "EMAIL",
|
|
||||||
"emailSettings": null
|
|
||||||
},
|
|
||||||
"Recipient": [
|
|
||||||
{
|
|
||||||
"id": 60,
|
|
||||||
"documentId": 15,
|
|
||||||
"templateId": 5,
|
|
||||||
"email": "newemployee@company.com",
|
|
||||||
"name": "New Employee",
|
|
||||||
"token": "DocToken456",
|
|
||||||
"documentDeletedAt": null,
|
|
||||||
"expired": null,
|
|
||||||
"signedAt": null,
|
|
||||||
"authOptions": null,
|
|
||||||
"signingOrder": 1,
|
|
||||||
"rejectionReason": null,
|
|
||||||
"role": "SIGNER",
|
|
||||||
"readStatus": "NOT_OPENED",
|
|
||||||
"signingStatus": "NOT_SIGNED",
|
|
||||||
"sendStatus": "NOT_SENT"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"createdAt": "2024-04-22T14:00:01.000Z",
|
|
||||||
"webhookEndpoint": "https://mywebhooksite.com/mywebhook"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Example payload for the `recipient.authentication.failed` event:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"event": "RECIPIENT_AUTHENTICATION_FAILED",
|
|
||||||
"payload": {
|
|
||||||
"id": 10,
|
|
||||||
"externalId": null,
|
|
||||||
"userId": 1,
|
|
||||||
"authOptions": null,
|
|
||||||
"formValues": null,
|
|
||||||
"visibility": "EVERYONE",
|
|
||||||
"title": "documenso.pdf",
|
|
||||||
"status": "PENDING",
|
|
||||||
"documentDataId": "hs8qz1ktr9204jn7mg6c5dxy0",
|
|
||||||
"createdAt": "2024-04-22T11:44:43.341Z",
|
|
||||||
"updatedAt": "2024-04-22T11:48:07.569Z",
|
|
||||||
"completedAt": null,
|
|
||||||
"deletedAt": null,
|
|
||||||
"teamId": null,
|
|
||||||
"templateId": null,
|
|
||||||
"source": "DOCUMENT",
|
|
||||||
"documentMeta": {
|
|
||||||
"id": "doc_meta_123",
|
|
||||||
"subject": "Please sign this document",
|
|
||||||
"message": "Hello, please review and sign this document.",
|
|
||||||
"timezone": "UTC",
|
|
||||||
"password": null,
|
|
||||||
"dateFormat": "MM/DD/YYYY",
|
|
||||||
"redirectUrl": null,
|
|
||||||
"signingOrder": "PARALLEL",
|
|
||||||
"typedSignatureEnabled": true,
|
|
||||||
"language": "en",
|
|
||||||
"distributionMethod": "EMAIL",
|
|
||||||
"emailSettings": null
|
|
||||||
},
|
|
||||||
"Recipient": [
|
|
||||||
{
|
|
||||||
"id": 52,
|
|
||||||
"documentId": 10,
|
|
||||||
"templateId": null,
|
|
||||||
"email": "signer@documenso.com",
|
|
||||||
"name": "Signer",
|
|
||||||
"token": "vbT8hi3jKQmrFP_LN1WcS",
|
|
||||||
"documentDeletedAt": null,
|
|
||||||
"expired": null,
|
|
||||||
"signedAt": null,
|
|
||||||
"authOptions": {
|
|
||||||
"accessAuth": "TWO_FACTOR_AUTH",
|
|
||||||
"actionAuth": null
|
|
||||||
},
|
|
||||||
"signingOrder": 1,
|
|
||||||
"rejectionReason": null,
|
|
||||||
"role": "SIGNER",
|
|
||||||
"readStatus": "NOT_OPENED",
|
|
||||||
"signingStatus": "NOT_SIGNED",
|
|
||||||
"sendStatus": "SENT"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"createdAt": "2024-04-22T11:49:00.000Z",
|
|
||||||
"webhookEndpoint": "https://mywebhooksite.com/mywebhook"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Webhook Events Testing
|
## Webhook Events Testing
|
||||||
|
|
||||||
You can trigger test webhook events to test the webhook functionality. To trigger a test webhook, navigate to the [Webhooks page](/developers/webhooks) and click on the "Test Webhook" button.
|
You can trigger test webhook events to test the webhook functionality. To trigger a test webhook, navigate to the [Webhooks page](/developers/webhooks) and click on the "Test Webhook" button.
|
||||||
|
|||||||
@ -152,6 +152,18 @@ export const EditorFieldTextForm = ({
|
|||||||
className="h-auto"
|
className="h-auto"
|
||||||
placeholder={t`Add text to the field`}
|
placeholder={t`Add text to the field`}
|
||||||
{...field}
|
{...field}
|
||||||
|
onChange={(e) => {
|
||||||
|
const values = form.getValues();
|
||||||
|
const characterLimit = values.characterLimit || 0;
|
||||||
|
let textValue = e.target.value;
|
||||||
|
|
||||||
|
if (characterLimit > 0 && textValue.length > characterLimit) {
|
||||||
|
textValue = textValue.slice(0, characterLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
e.target.value = textValue;
|
||||||
|
field.onChange(e);
|
||||||
|
}}
|
||||||
rows={1}
|
rows={1}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
@ -175,6 +187,18 @@ export const EditorFieldTextForm = ({
|
|||||||
className="bg-background"
|
className="bg-background"
|
||||||
placeholder={t`Field character limit`}
|
placeholder={t`Field character limit`}
|
||||||
{...field}
|
{...field}
|
||||||
|
onChange={(e) => {
|
||||||
|
field.onChange(e);
|
||||||
|
|
||||||
|
const values = form.getValues();
|
||||||
|
const characterLimit = parseInt(e.target.value, 10) || 0;
|
||||||
|
|
||||||
|
const textValue = values.text || '';
|
||||||
|
|
||||||
|
if (characterLimit > 0 && textValue.length > characterLimit) {
|
||||||
|
form.setValue('text', textValue.slice(0, characterLimit));
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import { prop, sortBy } from 'remeda';
|
|||||||
import { isBase64Image } from '@documenso/lib/constants/signatures';
|
import { isBase64Image } from '@documenso/lib/constants/signatures';
|
||||||
import { DO_NOT_INVALIDATE_QUERY_ON_MUTATION } from '@documenso/lib/constants/trpc';
|
import { DO_NOT_INVALIDATE_QUERY_ON_MUTATION } from '@documenso/lib/constants/trpc';
|
||||||
import type { EnvelopeForSigningResponse } from '@documenso/lib/server-only/envelope/get-envelope-for-recipient-signing';
|
import type { EnvelopeForSigningResponse } from '@documenso/lib/server-only/envelope/get-envelope-for-recipient-signing';
|
||||||
|
import type { TRecipientActionAuth } from '@documenso/lib/types/document-auth';
|
||||||
import {
|
import {
|
||||||
isFieldUnsignedAndRequired,
|
isFieldUnsignedAndRequired,
|
||||||
isRequiredField,
|
isRequiredField,
|
||||||
@ -51,7 +52,11 @@ export type EnvelopeSigningContextValue = {
|
|||||||
setSelectedAssistantRecipientId: (_value: number | null) => void;
|
setSelectedAssistantRecipientId: (_value: number | null) => void;
|
||||||
selectedAssistantRecipient: EnvelopeForSigningResponse['envelope']['recipients'][number] | null;
|
selectedAssistantRecipient: EnvelopeForSigningResponse['envelope']['recipients'][number] | null;
|
||||||
|
|
||||||
signField: (_fieldId: number, _value: TSignEnvelopeFieldValue) => Promise<void>;
|
signField: (
|
||||||
|
_fieldId: number,
|
||||||
|
_value: TSignEnvelopeFieldValue,
|
||||||
|
authOptions?: TRecipientActionAuth,
|
||||||
|
) => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const EnvelopeSigningContext = createContext<EnvelopeSigningContextValue | null>(null);
|
const EnvelopeSigningContext = createContext<EnvelopeSigningContextValue | null>(null);
|
||||||
@ -284,7 +289,11 @@ export const EnvelopeSigningProvider = ({
|
|||||||
: null;
|
: null;
|
||||||
}, [envelope.documentMeta?.signingOrder, envelope.recipients, recipient.id]);
|
}, [envelope.documentMeta?.signingOrder, envelope.recipients, recipient.id]);
|
||||||
|
|
||||||
const signField = async (fieldId: number, fieldValue: TSignEnvelopeFieldValue) => {
|
const signField = async (
|
||||||
|
fieldId: number,
|
||||||
|
fieldValue: TSignEnvelopeFieldValue,
|
||||||
|
authOptions?: TRecipientActionAuth,
|
||||||
|
) => {
|
||||||
// Set the field locally for direct templates.
|
// Set the field locally for direct templates.
|
||||||
if (isDirectTemplate) {
|
if (isDirectTemplate) {
|
||||||
handleDirectTemplateFieldInsertion(fieldId, fieldValue);
|
handleDirectTemplateFieldInsertion(fieldId, fieldValue);
|
||||||
@ -295,7 +304,7 @@ export const EnvelopeSigningProvider = ({
|
|||||||
token: envelopeData.recipient.token,
|
token: envelopeData.recipient.token,
|
||||||
fieldId,
|
fieldId,
|
||||||
fieldValue,
|
fieldValue,
|
||||||
authOptions: undefined,
|
authOptions,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -103,7 +103,6 @@ export default function EnvelopeEditorFieldsPageRenderer() {
|
|||||||
fieldUpdates.height = fieldPageHeight;
|
fieldUpdates.height = fieldPageHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Todo: envelopes Use id
|
|
||||||
editorFields.updateFieldByFormId(fieldFormId, fieldUpdates);
|
editorFields.updateFieldByFormId(fieldFormId, fieldUpdates);
|
||||||
|
|
||||||
// Select the field if it is not already selected.
|
// Select the field if it is not already selected.
|
||||||
|
|||||||
@ -27,7 +27,8 @@ import type {
|
|||||||
import { canRecipientFieldsBeModified } from '@documenso/lib/utils/recipients';
|
import { canRecipientFieldsBeModified } from '@documenso/lib/utils/recipients';
|
||||||
import { AnimateGenericFadeInOut } from '@documenso/ui/components/animate/animate-generic-fade-in-out';
|
import { AnimateGenericFadeInOut } from '@documenso/ui/components/animate/animate-generic-fade-in-out';
|
||||||
import PDFViewerKonvaLazy from '@documenso/ui/components/pdf-viewer/pdf-viewer-konva-lazy';
|
import PDFViewerKonvaLazy from '@documenso/ui/components/pdf-viewer/pdf-viewer-konva-lazy';
|
||||||
import { Alert, AlertDescription } from '@documenso/ui/primitives/alert';
|
import { Alert, AlertDescription, AlertTitle } from '@documenso/ui/primitives/alert';
|
||||||
|
import { Button } from '@documenso/ui/primitives/button';
|
||||||
import { RecipientSelector } from '@documenso/ui/primitives/recipient-selector';
|
import { RecipientSelector } from '@documenso/ui/primitives/recipient-selector';
|
||||||
import { Separator } from '@documenso/ui/primitives/separator';
|
import { Separator } from '@documenso/ui/primitives/separator';
|
||||||
|
|
||||||
@ -112,7 +113,29 @@ export const EnvelopeEditorFieldsPage = () => {
|
|||||||
<EnvelopeRendererFileSelector fields={editorFields.localFields} />
|
<EnvelopeRendererFileSelector fields={editorFields.localFields} />
|
||||||
|
|
||||||
{/* Document View */}
|
{/* Document View */}
|
||||||
<div className="mt-4 flex h-full justify-center p-4">
|
<div className="mt-4 flex flex-col items-center justify-center">
|
||||||
|
{envelope.recipients.length === 0 && (
|
||||||
|
<Alert
|
||||||
|
variant="neutral"
|
||||||
|
className="border-border bg-background mb-4 flex max-w-[800px] flex-row items-center justify-between space-y-0 rounded-sm border"
|
||||||
|
>
|
||||||
|
<div className="flex flex-col gap-1">
|
||||||
|
<AlertTitle>
|
||||||
|
<Trans>Missing Recipients</Trans>
|
||||||
|
</AlertTitle>
|
||||||
|
<AlertDescription>
|
||||||
|
<Trans>You need at least one recipient to add fields</Trans>
|
||||||
|
</AlertDescription>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Button asChild variant="outline">
|
||||||
|
<Link to={`${relativePath.editorPath}`}>
|
||||||
|
<Trans>Add Recipients</Trans>
|
||||||
|
</Link>
|
||||||
|
</Button>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
{currentEnvelopeItem !== null ? (
|
{currentEnvelopeItem !== null ? (
|
||||||
<PDFViewerKonvaLazy customPageRenderer={EnvelopeEditorFieldsPageRenderer} />
|
<PDFViewerKonvaLazy customPageRenderer={EnvelopeEditorFieldsPageRenderer} />
|
||||||
) : (
|
) : (
|
||||||
@ -130,7 +153,7 @@ export const EnvelopeEditorFieldsPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Right Section - Form Fields Panel */}
|
{/* Right Section - Form Fields Panel */}
|
||||||
{currentEnvelopeItem && (
|
{currentEnvelopeItem && envelope.recipients.length > 0 && (
|
||||||
<div className="bg-background border-border sticky top-0 h-full w-80 flex-shrink-0 overflow-y-auto border-l py-4">
|
<div className="bg-background border-border sticky top-0 h-full w-80 flex-shrink-0 overflow-y-auto border-l py-4">
|
||||||
{/* Recipient selector section. */}
|
{/* Recipient selector section. */}
|
||||||
<section className="px-4">
|
<section className="px-4">
|
||||||
@ -138,19 +161,6 @@ export const EnvelopeEditorFieldsPage = () => {
|
|||||||
<Trans>Selected Recipient</Trans>
|
<Trans>Selected Recipient</Trans>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
{envelope.recipients.length === 0 ? (
|
|
||||||
<Alert variant="warning">
|
|
||||||
<AlertDescription className="flex flex-col gap-2">
|
|
||||||
<Trans>You need at least one recipient to add fields</Trans>
|
|
||||||
|
|
||||||
<Link to={`${relativePath.editorPath}`} className="text-sm">
|
|
||||||
<p>
|
|
||||||
<Trans>Click here to add a recipient</Trans>
|
|
||||||
</p>
|
|
||||||
</Link>
|
|
||||||
</AlertDescription>
|
|
||||||
</Alert>
|
|
||||||
) : (
|
|
||||||
<RecipientSelector
|
<RecipientSelector
|
||||||
selectedRecipient={editorFields.selectedRecipient}
|
selectedRecipient={editorFields.selectedRecipient}
|
||||||
onSelectedRecipientChange={(recipient) =>
|
onSelectedRecipientChange={(recipient) =>
|
||||||
@ -160,7 +170,6 @@ export const EnvelopeEditorFieldsPage = () => {
|
|||||||
className="w-full"
|
className="w-full"
|
||||||
align="end"
|
align="end"
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
|
|
||||||
{editorFields.selectedRecipient &&
|
{editorFields.selectedRecipient &&
|
||||||
!canRecipientFieldsBeModified(editorFields.selectedRecipient, envelope.fields) && (
|
!canRecipientFieldsBeModified(editorFields.selectedRecipient, envelope.fields) && (
|
||||||
|
|||||||
@ -323,7 +323,7 @@ export const EnvelopeEditorSettingsDialog = ({
|
|||||||
|
|
||||||
<DialogContent className="flex w-full !max-w-5xl flex-row gap-0 p-0">
|
<DialogContent className="flex w-full !max-w-5xl flex-row gap-0 p-0">
|
||||||
{/* Sidebar. */}
|
{/* Sidebar. */}
|
||||||
<div className="flex w-80 flex-col border-r bg-gray-50">
|
<div className="bg-accent/20 flex w-80 flex-col border-r">
|
||||||
<DialogHeader className="p-6 pb-4">
|
<DialogHeader className="p-6 pb-4">
|
||||||
<DialogTitle>Document Settings</DialogTitle>
|
<DialogTitle>Document Settings</DialogTitle>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|||||||
@ -203,7 +203,6 @@ export const EnvelopeEditorUploadPage = () => {
|
|||||||
debouncedUpdateEnvelopeItems(items);
|
debouncedUpdateEnvelopeItems(items);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Todo: Envelopes - Sync into envelopes data
|
|
||||||
const debouncedUpdateEnvelopeItems = useDebounceFunction((files: LocalFile[]) => {
|
const debouncedUpdateEnvelopeItems = useDebounceFunction((files: LocalFile[]) => {
|
||||||
void updateEnvelopeItems({
|
void updateEnvelopeItems({
|
||||||
envelopeId: envelope.id,
|
envelopeId: envelope.id,
|
||||||
|
|||||||
@ -10,14 +10,17 @@ import { usePageRenderer } from '@documenso/lib/client-only/hooks/use-page-rende
|
|||||||
import { useCurrentEnvelopeRender } from '@documenso/lib/client-only/providers/envelope-render-provider';
|
import { useCurrentEnvelopeRender } from '@documenso/lib/client-only/providers/envelope-render-provider';
|
||||||
import { useOptionalSession } from '@documenso/lib/client-only/providers/session';
|
import { useOptionalSession } from '@documenso/lib/client-only/providers/session';
|
||||||
import { DIRECT_TEMPLATE_RECIPIENT_EMAIL } from '@documenso/lib/constants/direct-templates';
|
import { DIRECT_TEMPLATE_RECIPIENT_EMAIL } from '@documenso/lib/constants/direct-templates';
|
||||||
|
import type { TRecipientActionAuth } from '@documenso/lib/types/document-auth';
|
||||||
import { ZFullFieldSchema } from '@documenso/lib/types/field';
|
import { ZFullFieldSchema } from '@documenso/lib/types/field';
|
||||||
import { createSpinner } from '@documenso/lib/universal/field-renderer/field-generic-items';
|
import { createSpinner } from '@documenso/lib/universal/field-renderer/field-generic-items';
|
||||||
import { renderField } from '@documenso/lib/universal/field-renderer/render-field';
|
import { renderField } from '@documenso/lib/universal/field-renderer/render-field';
|
||||||
import { isFieldUnsignedAndRequired } from '@documenso/lib/utils/advanced-fields-helpers';
|
import { isFieldUnsignedAndRequired } from '@documenso/lib/utils/advanced-fields-helpers';
|
||||||
import { getClientSideFieldTranslations } from '@documenso/lib/utils/fields';
|
import { getClientSideFieldTranslations } from '@documenso/lib/utils/fields';
|
||||||
import { extractInitials } from '@documenso/lib/utils/recipient-formatter';
|
import { extractInitials } from '@documenso/lib/utils/recipient-formatter';
|
||||||
|
import type { TSignEnvelopeFieldValue } from '@documenso/trpc/server/envelope-router/sign-envelope-field.types';
|
||||||
import { EnvelopeFieldToolTip } from '@documenso/ui/components/field/envelope-field-tooltip';
|
import { EnvelopeFieldToolTip } from '@documenso/ui/components/field/envelope-field-tooltip';
|
||||||
import type { TRecipientColor } from '@documenso/ui/lib/recipient-colors';
|
import type { TRecipientColor } from '@documenso/ui/lib/recipient-colors';
|
||||||
|
import { useToast } from '@documenso/ui/primitives/use-toast';
|
||||||
|
|
||||||
import { handleCheckboxFieldClick } from '~/utils/field-signing/checkbox-field';
|
import { handleCheckboxFieldClick } from '~/utils/field-signing/checkbox-field';
|
||||||
import { handleDropdownFieldClick } from '~/utils/field-signing/dropdown-field';
|
import { handleDropdownFieldClick } from '~/utils/field-signing/dropdown-field';
|
||||||
@ -28,20 +31,24 @@ import { handleNumberFieldClick } from '~/utils/field-signing/number-field';
|
|||||||
import { handleSignatureFieldClick } from '~/utils/field-signing/signature-field';
|
import { handleSignatureFieldClick } from '~/utils/field-signing/signature-field';
|
||||||
import { handleTextFieldClick } from '~/utils/field-signing/text-field';
|
import { handleTextFieldClick } from '~/utils/field-signing/text-field';
|
||||||
|
|
||||||
|
import { useRequiredDocumentSigningAuthContext } from '../document-signing/document-signing-auth-provider';
|
||||||
import { useRequiredEnvelopeSigningContext } from '../document-signing/envelope-signing-provider';
|
import { useRequiredEnvelopeSigningContext } from '../document-signing/envelope-signing-provider';
|
||||||
|
|
||||||
export default function EnvelopeSignerPageRenderer() {
|
export default function EnvelopeSignerPageRenderer() {
|
||||||
const { i18n } = useLingui();
|
const { t, i18n } = useLingui();
|
||||||
const { currentEnvelopeItem } = useCurrentEnvelopeRender();
|
const { currentEnvelopeItem } = useCurrentEnvelopeRender();
|
||||||
const { sessionData } = useOptionalSession();
|
const { sessionData } = useOptionalSession();
|
||||||
|
|
||||||
|
const { executeActionAuthProcedure } = useRequiredDocumentSigningAuthContext();
|
||||||
|
const { toast } = useToast();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
envelopeData,
|
envelopeData,
|
||||||
recipient,
|
recipient,
|
||||||
recipientFields,
|
recipientFields,
|
||||||
recipientFieldsRemaining,
|
recipientFieldsRemaining,
|
||||||
showPendingFieldTooltip,
|
showPendingFieldTooltip,
|
||||||
signField,
|
signField: signFieldInternal,
|
||||||
email,
|
email,
|
||||||
setEmail,
|
setEmail,
|
||||||
fullName,
|
fullName,
|
||||||
@ -318,7 +325,6 @@ export default function EnvelopeSignerPageRenderer() {
|
|||||||
* SIGNATURE FIELD.
|
* SIGNATURE FIELD.
|
||||||
*/
|
*/
|
||||||
.with({ type: FieldType.SIGNATURE }, (field) => {
|
.with({ type: FieldType.SIGNATURE }, (field) => {
|
||||||
// Todo: Envelopes - Reauth
|
|
||||||
handleSignatureFieldClick({
|
handleSignatureFieldClick({
|
||||||
field,
|
field,
|
||||||
signature,
|
signature,
|
||||||
@ -329,11 +335,21 @@ export default function EnvelopeSignerPageRenderer() {
|
|||||||
.then(async (payload) => {
|
.then(async (payload) => {
|
||||||
if (payload) {
|
if (payload) {
|
||||||
fieldGroup.add(loadingSpinnerGroup);
|
fieldGroup.add(loadingSpinnerGroup);
|
||||||
|
|
||||||
|
if (payload.value) {
|
||||||
|
void executeActionAuthProcedure({
|
||||||
|
onReauthFormSubmit: async (authOptions) => {
|
||||||
|
await signField(field.id, payload, authOptions);
|
||||||
|
|
||||||
|
loadingSpinnerGroup.destroy();
|
||||||
|
},
|
||||||
|
actionTarget: field.type,
|
||||||
|
});
|
||||||
|
|
||||||
|
setSignature(payload.value);
|
||||||
|
} else {
|
||||||
await signField(field.id, payload);
|
await signField(field.id, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payload?.value) {
|
|
||||||
setSignature(payload.value);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
@ -347,6 +363,26 @@ export default function EnvelopeSignerPageRenderer() {
|
|||||||
fieldGroup.on('pointerdown', handleFieldGroupClick);
|
fieldGroup.on('pointerdown', handleFieldGroupClick);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const signField = async (
|
||||||
|
fieldId: number,
|
||||||
|
payload: TSignEnvelopeFieldValue,
|
||||||
|
authOptions?: TRecipientActionAuth,
|
||||||
|
) => {
|
||||||
|
try {
|
||||||
|
await signFieldInternal(fieldId, payload, authOptions);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
|
||||||
|
toast({
|
||||||
|
title: t`Error`,
|
||||||
|
description: t`An error occurred while signing the field.`,
|
||||||
|
variant: 'destructive',
|
||||||
|
});
|
||||||
|
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the Konva page canvas and all fields and interactions.
|
* Initialize the Konva page canvas and all fields and interactions.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -78,7 +78,6 @@ test.describe('Signing Certificate Tests', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Todo: Envelopes
|
|
||||||
const firstDocumentData = completedDocument.envelopeItems[0].documentData;
|
const firstDocumentData = completedDocument.envelopeItems[0].documentData;
|
||||||
|
|
||||||
const completedDocumentData = await getFile(firstDocumentData);
|
const completedDocumentData = await getFile(firstDocumentData);
|
||||||
@ -169,7 +168,6 @@ test.describe('Signing Certificate Tests', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Todo: Envelopes
|
|
||||||
const firstDocumentData = completedDocument.envelopeItems[0].documentData;
|
const firstDocumentData = completedDocument.envelopeItems[0].documentData;
|
||||||
|
|
||||||
const completedDocumentData = await getFile(firstDocumentData);
|
const completedDocumentData = await getFile(firstDocumentData);
|
||||||
|
|||||||
@ -97,9 +97,7 @@ export const completeDocumentWithToken = async ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (envelope.documentMeta?.signingOrder === DocumentSigningOrder.SEQUENTIAL) {
|
if (envelope.documentMeta?.signingOrder === DocumentSigningOrder.SEQUENTIAL) {
|
||||||
const isRecipientsTurn = await getIsRecipientsTurnToSign({
|
const isRecipientsTurn = await getIsRecipientsTurnToSign({ token: recipient.token });
|
||||||
token: recipient.token,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!isRecipientsTurn) {
|
if (!isRecipientsTurn) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -153,18 +151,6 @@ export const completeDocumentWithToken = async ({
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const envelopeForFailure = await prisma.envelope.findUniqueOrThrow({
|
|
||||||
where: { id: envelope.id },
|
|
||||||
include: { documentMeta: true, recipients: true },
|
|
||||||
});
|
|
||||||
|
|
||||||
await triggerWebhook({
|
|
||||||
event: WebhookTriggerEvents.RECIPIENT_AUTHENTICATION_FAILED,
|
|
||||||
data: ZWebhookDocumentSchema.parse(mapEnvelopeToWebhookDocumentPayload(envelopeForFailure)),
|
|
||||||
userId: envelope.userId,
|
|
||||||
teamId: envelope.teamId,
|
|
||||||
});
|
|
||||||
|
|
||||||
throw new AppError(AppErrorCode.TWO_FACTOR_AUTH_FAILED, {
|
throw new AppError(AppErrorCode.TWO_FACTOR_AUTH_FAILED, {
|
||||||
message: 'Invalid 2FA authentication',
|
message: 'Invalid 2FA authentication',
|
||||||
});
|
});
|
||||||
@ -219,18 +205,6 @@ export const completeDocumentWithToken = async ({
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const envelopeWithRelations = await prisma.envelope.findUniqueOrThrow({
|
|
||||||
where: { id: envelope.id },
|
|
||||||
include: { documentMeta: true, recipients: true },
|
|
||||||
});
|
|
||||||
|
|
||||||
await triggerWebhook({
|
|
||||||
event: WebhookTriggerEvents.DOCUMENT_RECIPIENT_COMPLETED,
|
|
||||||
data: ZWebhookDocumentSchema.parse(mapEnvelopeToWebhookDocumentPayload(envelopeWithRelations)),
|
|
||||||
userId: envelope.userId,
|
|
||||||
teamId: envelope.teamId,
|
|
||||||
});
|
|
||||||
|
|
||||||
await jobs.triggerJob({
|
await jobs.triggerJob({
|
||||||
name: 'send.recipient.signed.email',
|
name: 'send.recipient.signed.email',
|
||||||
payload: {
|
payload: {
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import {
|
|||||||
OrganisationType,
|
OrganisationType,
|
||||||
RecipientRole,
|
RecipientRole,
|
||||||
SigningStatus,
|
SigningStatus,
|
||||||
WebhookTriggerEvents,
|
|
||||||
} from '@prisma/client';
|
} from '@prisma/client';
|
||||||
|
|
||||||
import { mailer } from '@documenso/email/mailer';
|
import { mailer } from '@documenso/email/mailer';
|
||||||
@ -25,16 +24,11 @@ import { prisma } from '@documenso/prisma';
|
|||||||
import { getI18nInstance } from '../../client-only/providers/i18n-server';
|
import { getI18nInstance } from '../../client-only/providers/i18n-server';
|
||||||
import { NEXT_PUBLIC_WEBAPP_URL } from '../../constants/app';
|
import { NEXT_PUBLIC_WEBAPP_URL } from '../../constants/app';
|
||||||
import { extractDerivedDocumentEmailSettings } from '../../types/document-email';
|
import { extractDerivedDocumentEmailSettings } from '../../types/document-email';
|
||||||
import {
|
|
||||||
ZWebhookDocumentSchema,
|
|
||||||
mapEnvelopeToWebhookDocumentPayload,
|
|
||||||
} from '../../types/webhook-payload';
|
|
||||||
import { isDocumentCompleted } from '../../utils/document';
|
import { isDocumentCompleted } from '../../utils/document';
|
||||||
import type { EnvelopeIdOptions } from '../../utils/envelope';
|
import type { EnvelopeIdOptions } from '../../utils/envelope';
|
||||||
import { renderEmailWithI18N } from '../../utils/render-email-with-i18n';
|
import { renderEmailWithI18N } from '../../utils/render-email-with-i18n';
|
||||||
import { getEmailContext } from '../email/get-email-context';
|
import { getEmailContext } from '../email/get-email-context';
|
||||||
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
||||||
import { triggerWebhook } from '../webhooks/trigger/trigger-webhook';
|
|
||||||
|
|
||||||
export type ResendDocumentOptions = {
|
export type ResendDocumentOptions = {
|
||||||
id: EnvelopeIdOptions;
|
id: EnvelopeIdOptions;
|
||||||
@ -236,11 +230,4 @@ export const resendDocument = async ({
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
await triggerWebhook({
|
|
||||||
event: WebhookTriggerEvents.DOCUMENT_REMINDER_SENT,
|
|
||||||
data: ZWebhookDocumentSchema.parse(mapEnvelopeToWebhookDocumentPayload(envelope)),
|
|
||||||
userId: envelope.userId,
|
|
||||||
teamId: envelope.teamId,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { EnvelopeType, ReadStatus, SendStatus, WebhookTriggerEvents } from '@prisma/client';
|
import { EnvelopeType, ReadStatus, SendStatus } from '@prisma/client';
|
||||||
|
import { WebhookTriggerEvents } from '@prisma/client';
|
||||||
|
|
||||||
import { DOCUMENT_AUDIT_LOG_TYPE } from '@documenso/lib/types/document-audit-logs';
|
import { DOCUMENT_AUDIT_LOG_TYPE } from '@documenso/lib/types/document-audit-logs';
|
||||||
import type { RequestMetadata } from '@documenso/lib/universal/extract-request-metadata';
|
import type { RequestMetadata } from '@documenso/lib/universal/extract-request-metadata';
|
||||||
@ -65,13 +66,6 @@ export const viewedDocument = async ({
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
await triggerWebhook({
|
|
||||||
event: WebhookTriggerEvents.DOCUMENT_VIEWED,
|
|
||||||
data: ZWebhookDocumentSchema.parse(mapEnvelopeToWebhookDocumentPayload(envelope)),
|
|
||||||
userId: envelope.userId,
|
|
||||||
teamId: envelope.teamId,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Early return if already opened.
|
// Early return if already opened.
|
||||||
if (recipient.readStatus === ReadStatus.OPENED) {
|
if (recipient.readStatus === ReadStatus.OPENED) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -386,13 +386,6 @@ export const createEnvelope = async ({
|
|||||||
userId,
|
userId,
|
||||||
teamId,
|
teamId,
|
||||||
});
|
});
|
||||||
} else if (type === EnvelopeType.TEMPLATE) {
|
|
||||||
await triggerWebhook({
|
|
||||||
event: WebhookTriggerEvents.TEMPLATE_CREATED,
|
|
||||||
data: ZWebhookDocumentSchema.parse(mapEnvelopeToWebhookDocumentPayload(createdEnvelope)),
|
|
||||||
userId,
|
|
||||||
teamId,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return createdEnvelope;
|
return createdEnvelope;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import type { DocumentMeta, DocumentVisibility, Prisma, TemplateType } from '@prisma/client';
|
import type { DocumentMeta, DocumentVisibility, Prisma, TemplateType } from '@prisma/client';
|
||||||
import { DocumentStatus, EnvelopeType, FolderType, WebhookTriggerEvents } from '@prisma/client';
|
import { EnvelopeType, FolderType } from '@prisma/client';
|
||||||
|
import { DocumentStatus } from '@prisma/client';
|
||||||
import { isDeepEqual } from 'remeda';
|
import { isDeepEqual } from 'remeda';
|
||||||
|
|
||||||
import { DOCUMENT_AUDIT_LOG_TYPE } from '@documenso/lib/types/document-audit-logs';
|
import { DOCUMENT_AUDIT_LOG_TYPE } from '@documenso/lib/types/document-audit-logs';
|
||||||
@ -11,14 +12,9 @@ import { prisma } from '@documenso/prisma';
|
|||||||
import { TEAM_DOCUMENT_VISIBILITY_MAP } from '../../constants/teams';
|
import { TEAM_DOCUMENT_VISIBILITY_MAP } from '../../constants/teams';
|
||||||
import { AppError, AppErrorCode } from '../../errors/app-error';
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
||||||
import type { TDocumentAccessAuthTypes, TDocumentActionAuthTypes } from '../../types/document-auth';
|
import type { TDocumentAccessAuthTypes, TDocumentActionAuthTypes } from '../../types/document-auth';
|
||||||
import {
|
|
||||||
ZWebhookDocumentSchema,
|
|
||||||
mapEnvelopeToWebhookDocumentPayload,
|
|
||||||
} from '../../types/webhook-payload';
|
|
||||||
import { createDocumentAuthOptions, extractDocumentAuthMethods } from '../../utils/document-auth';
|
import { createDocumentAuthOptions, extractDocumentAuthMethods } from '../../utils/document-auth';
|
||||||
import type { EnvelopeIdOptions } from '../../utils/envelope';
|
import type { EnvelopeIdOptions } from '../../utils/envelope';
|
||||||
import { buildTeamWhereQuery, canAccessTeamDocument } from '../../utils/teams';
|
import { buildTeamWhereQuery, canAccessTeamDocument } from '../../utils/teams';
|
||||||
import { triggerWebhook } from '../webhooks/trigger/trigger-webhook';
|
|
||||||
import { getEnvelopeWhereInput } from './get-envelope-by-id';
|
import { getEnvelopeWhereInput } from './get-envelope-by-id';
|
||||||
|
|
||||||
export type UpdateEnvelopeOptions = {
|
export type UpdateEnvelopeOptions = {
|
||||||
@ -343,22 +339,6 @@ export const updateEnvelope = async ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (envelope.type === EnvelopeType.TEMPLATE) {
|
|
||||||
const envelopeWithRelations = await tx.envelope.findUniqueOrThrow({
|
|
||||||
where: { id: updatedEnvelope.id },
|
|
||||||
include: { documentMeta: true, recipients: true },
|
|
||||||
});
|
|
||||||
|
|
||||||
void triggerWebhook({
|
|
||||||
event: WebhookTriggerEvents.TEMPLATE_UPDATED,
|
|
||||||
data: ZWebhookDocumentSchema.parse(
|
|
||||||
mapEnvelopeToWebhookDocumentPayload(envelopeWithRelations),
|
|
||||||
),
|
|
||||||
userId,
|
|
||||||
teamId,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return updatedEnvelope;
|
return updatedEnvelope;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -725,13 +725,6 @@ export const createDocumentFromTemplate = async ({
|
|||||||
teamId,
|
teamId,
|
||||||
});
|
});
|
||||||
|
|
||||||
await triggerWebhook({
|
|
||||||
event: WebhookTriggerEvents.TEMPLATE_USED,
|
|
||||||
data: ZWebhookDocumentSchema.parse(mapEnvelopeToWebhookDocumentPayload(createdEnvelope)),
|
|
||||||
userId,
|
|
||||||
teamId,
|
|
||||||
});
|
|
||||||
|
|
||||||
return envelope;
|
return envelope;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,14 +1,9 @@
|
|||||||
import { EnvelopeType, WebhookTriggerEvents } from '@prisma/client';
|
import { EnvelopeType } from '@prisma/client';
|
||||||
|
|
||||||
import { prisma } from '@documenso/prisma';
|
import { prisma } from '@documenso/prisma';
|
||||||
|
|
||||||
import {
|
|
||||||
ZWebhookDocumentSchema,
|
|
||||||
mapEnvelopeToWebhookDocumentPayload,
|
|
||||||
} from '../../types/webhook-payload';
|
|
||||||
import { type EnvelopeIdOptions } from '../../utils/envelope';
|
import { type EnvelopeIdOptions } from '../../utils/envelope';
|
||||||
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
||||||
import { triggerWebhook } from '../webhooks/trigger/trigger-webhook';
|
|
||||||
|
|
||||||
export type DeleteTemplateOptions = {
|
export type DeleteTemplateOptions = {
|
||||||
id: EnvelopeIdOptions;
|
id: EnvelopeIdOptions;
|
||||||
@ -24,18 +19,6 @@ export const deleteTemplate = async ({ id, userId, teamId }: DeleteTemplateOptio
|
|||||||
teamId,
|
teamId,
|
||||||
});
|
});
|
||||||
|
|
||||||
const templateToDelete = await prisma.envelope.findUniqueOrThrow({
|
|
||||||
where: envelopeWhereInput,
|
|
||||||
include: { documentMeta: true, recipients: true },
|
|
||||||
});
|
|
||||||
|
|
||||||
await triggerWebhook({
|
|
||||||
event: WebhookTriggerEvents.TEMPLATE_DELETED,
|
|
||||||
data: ZWebhookDocumentSchema.parse(mapEnvelopeToWebhookDocumentPayload(templateToDelete)),
|
|
||||||
userId,
|
|
||||||
teamId,
|
|
||||||
});
|
|
||||||
|
|
||||||
return await prisma.envelope.delete({
|
return await prisma.envelope.delete({
|
||||||
where: envelopeWhereInput,
|
where: envelopeWhereInput,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -480,198 +480,5 @@ export const generateSampleWebhookPayload = (
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event === WebhookTriggerEvents.DOCUMENT_VIEWED) {
|
|
||||||
return {
|
|
||||||
event,
|
|
||||||
payload: {
|
|
||||||
...basePayload,
|
|
||||||
status: DocumentStatus.PENDING,
|
|
||||||
recipients: [
|
|
||||||
{
|
|
||||||
...basePayload.recipients[0],
|
|
||||||
readStatus: ReadStatus.OPENED,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
Recipient: [
|
|
||||||
{
|
|
||||||
...basePayload.recipients[0],
|
|
||||||
readStatus: ReadStatus.OPENED,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
createdAt: now.toISOString(),
|
|
||||||
webhookEndpoint: webhookUrl,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event === WebhookTriggerEvents.DOCUMENT_RECIPIENT_COMPLETED) {
|
|
||||||
return {
|
|
||||||
event,
|
|
||||||
payload: {
|
|
||||||
...basePayload,
|
|
||||||
status: DocumentStatus.PENDING,
|
|
||||||
recipients: [
|
|
||||||
{
|
|
||||||
...basePayload.recipients[0],
|
|
||||||
readStatus: ReadStatus.OPENED,
|
|
||||||
signingStatus: SigningStatus.SIGNED,
|
|
||||||
signedAt: now,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
Recipient: [
|
|
||||||
{
|
|
||||||
...basePayload.recipients[0],
|
|
||||||
readStatus: ReadStatus.OPENED,
|
|
||||||
signingStatus: SigningStatus.SIGNED,
|
|
||||||
signedAt: now,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
createdAt: now.toISOString(),
|
|
||||||
webhookEndpoint: webhookUrl,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event === WebhookTriggerEvents.DOCUMENT_DOWNLOADED) {
|
|
||||||
return {
|
|
||||||
event,
|
|
||||||
payload: {
|
|
||||||
...basePayload,
|
|
||||||
status: DocumentStatus.COMPLETED,
|
|
||||||
completedAt: now,
|
|
||||||
recipients: [
|
|
||||||
{
|
|
||||||
...basePayload.recipients[0],
|
|
||||||
readStatus: ReadStatus.OPENED,
|
|
||||||
signingStatus: SigningStatus.SIGNED,
|
|
||||||
signedAt: now,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
Recipient: [
|
|
||||||
{
|
|
||||||
...basePayload.recipients[0],
|
|
||||||
readStatus: ReadStatus.OPENED,
|
|
||||||
signingStatus: SigningStatus.SIGNED,
|
|
||||||
signedAt: now,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
createdAt: now.toISOString(),
|
|
||||||
webhookEndpoint: webhookUrl,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event === WebhookTriggerEvents.DOCUMENT_REMINDER_SENT) {
|
|
||||||
return {
|
|
||||||
event,
|
|
||||||
payload: {
|
|
||||||
...basePayload,
|
|
||||||
status: DocumentStatus.PENDING,
|
|
||||||
recipients: [
|
|
||||||
{
|
|
||||||
...basePayload.recipients[0],
|
|
||||||
sendStatus: SendStatus.SENT,
|
|
||||||
signingStatus: SigningStatus.NOT_SIGNED,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
Recipient: [
|
|
||||||
{
|
|
||||||
...basePayload.recipients[0],
|
|
||||||
sendStatus: SendStatus.SENT,
|
|
||||||
signingStatus: SigningStatus.NOT_SIGNED,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
createdAt: now.toISOString(),
|
|
||||||
webhookEndpoint: webhookUrl,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event === WebhookTriggerEvents.RECIPIENT_AUTHENTICATION_FAILED) {
|
|
||||||
return {
|
|
||||||
event,
|
|
||||||
payload: {
|
|
||||||
...basePayload,
|
|
||||||
status: DocumentStatus.PENDING,
|
|
||||||
recipients: [
|
|
||||||
{
|
|
||||||
...basePayload.recipients[0],
|
|
||||||
readStatus: ReadStatus.NOT_OPENED,
|
|
||||||
signingStatus: SigningStatus.NOT_SIGNED,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
Recipient: [
|
|
||||||
{
|
|
||||||
...basePayload.recipients[0],
|
|
||||||
readStatus: ReadStatus.NOT_OPENED,
|
|
||||||
signingStatus: SigningStatus.NOT_SIGNED,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
createdAt: now.toISOString(),
|
|
||||||
webhookEndpoint: webhookUrl,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event === WebhookTriggerEvents.TEMPLATE_CREATED) {
|
|
||||||
return {
|
|
||||||
event,
|
|
||||||
payload: {
|
|
||||||
...basePayload,
|
|
||||||
title: 'My Template',
|
|
||||||
status: DocumentStatus.DRAFT,
|
|
||||||
templateId: 10,
|
|
||||||
source: DocumentSource.TEMPLATE,
|
|
||||||
},
|
|
||||||
createdAt: now.toISOString(),
|
|
||||||
webhookEndpoint: webhookUrl,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event === WebhookTriggerEvents.TEMPLATE_UPDATED) {
|
|
||||||
return {
|
|
||||||
event,
|
|
||||||
payload: {
|
|
||||||
...basePayload,
|
|
||||||
title: 'My Updated Template',
|
|
||||||
status: DocumentStatus.DRAFT,
|
|
||||||
templateId: 10,
|
|
||||||
source: DocumentSource.TEMPLATE,
|
|
||||||
},
|
|
||||||
createdAt: now.toISOString(),
|
|
||||||
webhookEndpoint: webhookUrl,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event === WebhookTriggerEvents.TEMPLATE_DELETED) {
|
|
||||||
return {
|
|
||||||
event,
|
|
||||||
payload: {
|
|
||||||
...basePayload,
|
|
||||||
title: 'Deleted Template',
|
|
||||||
status: DocumentStatus.DRAFT,
|
|
||||||
templateId: 10,
|
|
||||||
source: DocumentSource.TEMPLATE,
|
|
||||||
},
|
|
||||||
createdAt: now.toISOString(),
|
|
||||||
webhookEndpoint: webhookUrl,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event === WebhookTriggerEvents.TEMPLATE_USED) {
|
|
||||||
return {
|
|
||||||
event,
|
|
||||||
payload: {
|
|
||||||
...basePayload,
|
|
||||||
title: 'Document from Template',
|
|
||||||
status: DocumentStatus.DRAFT,
|
|
||||||
templateId: 10,
|
|
||||||
source: DocumentSource.TEMPLATE,
|
|
||||||
},
|
|
||||||
createdAt: now.toISOString(),
|
|
||||||
webhookEndpoint: webhookUrl,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error(`Unsupported event type: ${event}`);
|
throw new Error(`Unsupported event type: ${event}`);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -62,16 +62,15 @@ export const renderCheckboxFieldElement = (
|
|||||||
const rectWidth = fieldRect.width() * groupScaleX;
|
const rectWidth = fieldRect.width() * groupScaleX;
|
||||||
const rectHeight = fieldRect.height() * groupScaleY;
|
const rectHeight = fieldRect.height() * groupScaleY;
|
||||||
|
|
||||||
// Todo: Envelopes - check sorting more than 10
|
|
||||||
// arr.sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));
|
|
||||||
|
|
||||||
const squares = fieldGroup
|
const squares = fieldGroup
|
||||||
.find('.checkbox-square')
|
.find('.checkbox-square')
|
||||||
.sort((a, b) => a.id().localeCompare(b.id()));
|
.sort((a, b) => a.id().localeCompare(b.id(), undefined, { numeric: true }));
|
||||||
const checkmarks = fieldGroup
|
const checkmarks = fieldGroup
|
||||||
.find('.checkbox-checkmark')
|
.find('.checkbox-checkmark')
|
||||||
.sort((a, b) => a.id().localeCompare(b.id()));
|
.sort((a, b) => a.id().localeCompare(b.id(), undefined, { numeric: true }));
|
||||||
const text = fieldGroup.find('.checkbox-text').sort((a, b) => a.id().localeCompare(b.id()));
|
const text = fieldGroup
|
||||||
|
.find('.checkbox-text')
|
||||||
|
.sort((a, b) => a.id().localeCompare(b.id(), undefined, { numeric: true }));
|
||||||
|
|
||||||
const groupedItems = squares.map((square, i) => ({
|
const groupedItems = squares.map((square, i) => ({
|
||||||
squareElement: square,
|
squareElement: square,
|
||||||
|
|||||||
@ -8,9 +8,9 @@ import type { TRecipientColor } from '@documenso/ui/lib/recipient-colors';
|
|||||||
import type { TFieldMetaSchema } from '../../types/field-meta';
|
import type { TFieldMetaSchema } from '../../types/field-meta';
|
||||||
import { renderCheckboxFieldElement } from './render-checkbox-field';
|
import { renderCheckboxFieldElement } from './render-checkbox-field';
|
||||||
import { renderDropdownFieldElement } from './render-dropdown-field';
|
import { renderDropdownFieldElement } from './render-dropdown-field';
|
||||||
|
import { renderGenericTextFieldElement } from './render-generic-text-field';
|
||||||
import { renderRadioFieldElement } from './render-radio-field';
|
import { renderRadioFieldElement } from './render-radio-field';
|
||||||
import { renderSignatureFieldElement } from './render-signature-field';
|
import { renderSignatureFieldElement } from './render-signature-field';
|
||||||
import { renderTextFieldElement } from './render-text-field';
|
|
||||||
|
|
||||||
export const MIN_FIELD_HEIGHT_PX = 12;
|
export const MIN_FIELD_HEIGHT_PX = 12;
|
||||||
export const MIN_FIELD_WIDTH_PX = 36;
|
export const MIN_FIELD_WIDTH_PX = 36;
|
||||||
@ -43,9 +43,9 @@ type RenderFieldOptions = {
|
|||||||
*
|
*
|
||||||
* @default 'edit'
|
* @default 'edit'
|
||||||
*
|
*
|
||||||
* - `edit` - The field is rendered in edit mode.
|
* - `edit` - The field is rendered in editor page.
|
||||||
* - `sign` - The field is rendered in sign mode. No interactive elements.
|
* - `sign` - The field is rendered for the signing page.
|
||||||
* - `export` - The field is rendered in export mode. No backgrounds, interactive elements, etc.
|
* - `export` - The field is rendered for exporting and sealing into the PDF. No backgrounds, interactive elements, etc.
|
||||||
*/
|
*/
|
||||||
mode: 'edit' | 'sign' | 'export';
|
mode: 'edit' | 'sign' | 'export';
|
||||||
|
|
||||||
@ -76,10 +76,21 @@ export const renderField = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return match(field.type)
|
return match(field.type)
|
||||||
.with(FieldType.TEXT, () => renderTextFieldElement(field, options))
|
.with(
|
||||||
|
FieldType.INITIALS,
|
||||||
|
FieldType.NAME,
|
||||||
|
FieldType.EMAIL,
|
||||||
|
FieldType.DATE,
|
||||||
|
FieldType.TEXT,
|
||||||
|
FieldType.NUMBER,
|
||||||
|
() => renderGenericTextFieldElement(field, options),
|
||||||
|
)
|
||||||
.with(FieldType.CHECKBOX, () => renderCheckboxFieldElement(field, options))
|
.with(FieldType.CHECKBOX, () => renderCheckboxFieldElement(field, options))
|
||||||
.with(FieldType.RADIO, () => renderRadioFieldElement(field, options))
|
.with(FieldType.RADIO, () => renderRadioFieldElement(field, options))
|
||||||
.with(FieldType.DROPDOWN, () => renderDropdownFieldElement(field, options))
|
.with(FieldType.DROPDOWN, () => renderDropdownFieldElement(field, options))
|
||||||
.with(FieldType.SIGNATURE, () => renderSignatureFieldElement(field, options))
|
.with(FieldType.SIGNATURE, () => renderSignatureFieldElement(field, options))
|
||||||
.otherwise(() => renderTextFieldElement(field, options)); // Todo: Envelopes
|
.with(FieldType.FREE_SIGNATURE, () => {
|
||||||
|
throw new Error('Free signature fields are not supported');
|
||||||
|
})
|
||||||
|
.exhaustive();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -12,6 +12,8 @@ import {
|
|||||||
import type { FieldToRender, RenderFieldElementOptions } from './field-renderer';
|
import type { FieldToRender, RenderFieldElementOptions } from './field-renderer';
|
||||||
import { calculateFieldPosition } from './field-renderer';
|
import { calculateFieldPosition } from './field-renderer';
|
||||||
|
|
||||||
|
const DEFAULT_TEXT_ALIGN = 'left';
|
||||||
|
|
||||||
const upsertFieldText = (field: FieldToRender, options: RenderFieldElementOptions): Konva.Text => {
|
const upsertFieldText = (field: FieldToRender, options: RenderFieldElementOptions): Konva.Text => {
|
||||||
const { pageWidth, pageHeight, mode = 'edit', pageLayer, translations } = options;
|
const { pageWidth, pageHeight, mode = 'edit', pageLayer, translations } = options;
|
||||||
|
|
||||||
@ -31,8 +33,8 @@ const upsertFieldText = (field: FieldToRender, options: RenderFieldElementOption
|
|||||||
// Calculate text positioning based on alignment
|
// Calculate text positioning based on alignment
|
||||||
const textX = 0;
|
const textX = 0;
|
||||||
const textY = 0;
|
const textY = 0;
|
||||||
let textAlign: 'left' | 'center' | 'right' = textMeta?.textAlign || 'left';
|
let textAlign: 'left' | 'center' | 'right' = textMeta?.textAlign || DEFAULT_TEXT_ALIGN;
|
||||||
let textVerticalAlign: 'top' | 'middle' | 'bottom' = 'top';
|
const textVerticalAlign: 'top' | 'middle' | 'bottom' = 'middle';
|
||||||
const textFontSize = textMeta?.fontSize || DEFAULT_STANDARD_FONT_SIZE;
|
const textFontSize = textMeta?.fontSize || DEFAULT_STANDARD_FONT_SIZE;
|
||||||
const textPadding = 10;
|
const textPadding = 10;
|
||||||
|
|
||||||
@ -40,51 +42,33 @@ const upsertFieldText = (field: FieldToRender, options: RenderFieldElementOption
|
|||||||
|
|
||||||
// Handle edit mode.
|
// Handle edit mode.
|
||||||
if (mode === 'edit') {
|
if (mode === 'edit') {
|
||||||
|
if (textMeta?.text) {
|
||||||
|
textToRender = textMeta.text;
|
||||||
|
} else if (textMeta?.label) {
|
||||||
|
textToRender = textMeta.label;
|
||||||
|
} else {
|
||||||
|
// Show field name which is centered for the edit mode if no label/text is avaliable.
|
||||||
textToRender = fieldTypeName;
|
textToRender = fieldTypeName;
|
||||||
textAlign = 'center';
|
textAlign = 'center';
|
||||||
textVerticalAlign = 'middle';
|
|
||||||
|
|
||||||
if (textMeta?.label) {
|
|
||||||
textToRender = textMeta.label;
|
|
||||||
} else if (textMeta?.text) {
|
|
||||||
textToRender = textMeta.text;
|
|
||||||
textAlign = textMeta.textAlign || 'center'; // Todo: Envelopes - What is the default
|
|
||||||
|
|
||||||
// Todo: Envelopes - Handle this on signatures
|
|
||||||
if (textMeta.characterLimit) {
|
|
||||||
textToRender = textToRender.slice(0, textMeta.characterLimit);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle sign mode.
|
// Handle sign mode.
|
||||||
if (mode === 'sign' || mode === 'export') {
|
if (mode === 'sign' || mode === 'export') {
|
||||||
textToRender = fieldTypeName;
|
if (!field.inserted) {
|
||||||
textAlign = 'center';
|
|
||||||
textVerticalAlign = 'middle';
|
|
||||||
|
|
||||||
if (textMeta?.label) {
|
|
||||||
textToRender = textMeta.label;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (textMeta?.text) {
|
if (textMeta?.text) {
|
||||||
textToRender = textMeta.text;
|
textToRender = textMeta.text;
|
||||||
textAlign = textMeta.textAlign || 'center'; // Todo: Envelopes - What is the default
|
} else if (textMeta?.label) {
|
||||||
|
textToRender = textMeta.label;
|
||||||
// Todo: Envelopes - Handle this on signatures
|
} else if (mode === 'sign') {
|
||||||
if (textMeta.characterLimit) {
|
// Only show the field name in sign mode if no text/label is avaliable.
|
||||||
textToRender = textToRender.slice(0, textMeta.characterLimit);
|
textToRender = fieldTypeName;
|
||||||
|
textAlign = 'center';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field.inserted) {
|
if (field.inserted) {
|
||||||
textToRender = field.customText;
|
textToRender = field.customText;
|
||||||
textAlign = textMeta?.textAlign || 'center'; // Todo: Envelopes - What is the default
|
|
||||||
|
|
||||||
// Todo: Envelopes - Handle this on signatures
|
|
||||||
if (textMeta?.characterLimit) {
|
|
||||||
textToRender = textToRender.slice(0, textMeta.characterLimit);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +90,7 @@ const upsertFieldText = (field: FieldToRender, options: RenderFieldElementOption
|
|||||||
return fieldText;
|
return fieldText;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const renderTextFieldElement = (
|
export const renderGenericTextFieldElement = (
|
||||||
field: FieldToRender,
|
field: FieldToRender,
|
||||||
options: RenderFieldElementOptions,
|
options: RenderFieldElementOptions,
|
||||||
) => {
|
) => {
|
||||||
@ -1,17 +0,0 @@
|
|||||||
-- AlterEnum
|
|
||||||
-- This migration adds more than one value to an enum.
|
|
||||||
-- With PostgreSQL versions 11 and earlier, this is not possible
|
|
||||||
-- in a single migration. This can be worked around by creating
|
|
||||||
-- multiple migrations, each migration adding only one value to
|
|
||||||
-- the enum.
|
|
||||||
|
|
||||||
|
|
||||||
ALTER TYPE "WebhookTriggerEvents" ADD VALUE 'DOCUMENT_VIEWED';
|
|
||||||
ALTER TYPE "WebhookTriggerEvents" ADD VALUE 'DOCUMENT_RECIPIENT_COMPLETED';
|
|
||||||
ALTER TYPE "WebhookTriggerEvents" ADD VALUE 'DOCUMENT_DOWNLOADED';
|
|
||||||
ALTER TYPE "WebhookTriggerEvents" ADD VALUE 'DOCUMENT_REMINDER_SENT';
|
|
||||||
ALTER TYPE "WebhookTriggerEvents" ADD VALUE 'TEMPLATE_CREATED';
|
|
||||||
ALTER TYPE "WebhookTriggerEvents" ADD VALUE 'TEMPLATE_UPDATED';
|
|
||||||
ALTER TYPE "WebhookTriggerEvents" ADD VALUE 'TEMPLATE_DELETED';
|
|
||||||
ALTER TYPE "WebhookTriggerEvents" ADD VALUE 'TEMPLATE_USED';
|
|
||||||
ALTER TYPE "WebhookTriggerEvents" ADD VALUE 'RECIPIENT_AUTHENTICATION_FAILED';
|
|
||||||
@ -172,15 +172,6 @@ enum WebhookTriggerEvents {
|
|||||||
DOCUMENT_COMPLETED
|
DOCUMENT_COMPLETED
|
||||||
DOCUMENT_REJECTED
|
DOCUMENT_REJECTED
|
||||||
DOCUMENT_CANCELLED
|
DOCUMENT_CANCELLED
|
||||||
DOCUMENT_VIEWED
|
|
||||||
DOCUMENT_RECIPIENT_COMPLETED
|
|
||||||
DOCUMENT_DOWNLOADED
|
|
||||||
DOCUMENT_REMINDER_SENT
|
|
||||||
TEMPLATE_CREATED
|
|
||||||
TEMPLATE_UPDATED
|
|
||||||
TEMPLATE_DELETED
|
|
||||||
TEMPLATE_USED
|
|
||||||
RECIPIENT_AUTHENTICATION_FAILED
|
|
||||||
}
|
}
|
||||||
|
|
||||||
model Webhook {
|
model Webhook {
|
||||||
|
|||||||
@ -1,13 +1,8 @@
|
|||||||
import type { DocumentData } from '@prisma/client';
|
import type { DocumentData } from '@prisma/client';
|
||||||
import { DocumentDataType, EnvelopeType, WebhookTriggerEvents } from '@prisma/client';
|
import { DocumentDataType, EnvelopeType } from '@prisma/client';
|
||||||
|
|
||||||
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
||||||
import { getEnvelopeById } from '@documenso/lib/server-only/envelope/get-envelope-by-id';
|
import { getEnvelopeById } from '@documenso/lib/server-only/envelope/get-envelope-by-id';
|
||||||
import { triggerWebhook } from '@documenso/lib/server-only/webhooks/trigger/trigger-webhook';
|
|
||||||
import {
|
|
||||||
ZWebhookDocumentSchema,
|
|
||||||
mapEnvelopeToWebhookDocumentPayload,
|
|
||||||
} from '@documenso/lib/types/webhook-payload';
|
|
||||||
import { getPresignGetUrl } from '@documenso/lib/universal/upload/server-actions';
|
import { getPresignGetUrl } from '@documenso/lib/universal/upload/server-actions';
|
||||||
import { isDocumentCompleted } from '@documenso/lib/utils/document';
|
import { isDocumentCompleted } from '@documenso/lib/utils/document';
|
||||||
|
|
||||||
@ -81,13 +76,6 @@ export const downloadDocumentRoute = authenticatedProcedure
|
|||||||
const suffix = version === 'signed' ? '_signed.pdf' : '.pdf';
|
const suffix = version === 'signed' ? '_signed.pdf' : '.pdf';
|
||||||
const filename = `${baseTitle}${suffix}`;
|
const filename = `${baseTitle}${suffix}`;
|
||||||
|
|
||||||
void triggerWebhook({
|
|
||||||
event: WebhookTriggerEvents.DOCUMENT_DOWNLOADED,
|
|
||||||
data: ZWebhookDocumentSchema.parse(mapEnvelopeToWebhookDocumentPayload(envelope)),
|
|
||||||
userId: envelope.userId,
|
|
||||||
teamId: envelope.teamId,
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
downloadUrl: url,
|
downloadUrl: url,
|
||||||
filename,
|
filename,
|
||||||
|
|||||||
@ -133,6 +133,49 @@ export const signEnvelopeFieldRoute = procedure
|
|||||||
|
|
||||||
const insertionValues = extractFieldInsertionValues({ fieldValue, field, documentMeta });
|
const insertionValues = extractFieldInsertionValues({ fieldValue, field, documentMeta });
|
||||||
|
|
||||||
|
// Early return for uninserting fields.
|
||||||
|
if (!insertionValues.inserted) {
|
||||||
|
return await prisma.$transaction(async (tx) => {
|
||||||
|
const updatedField = await tx.field.update({
|
||||||
|
where: {
|
||||||
|
id: field.id,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
customText: '',
|
||||||
|
inserted: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await tx.signature.deleteMany({
|
||||||
|
where: {
|
||||||
|
fieldId: field.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (recipient.role !== RecipientRole.ASSISTANT) {
|
||||||
|
await tx.documentAuditLog.create({
|
||||||
|
data: createDocumentAuditLogData({
|
||||||
|
type: DOCUMENT_AUDIT_LOG_TYPE.DOCUMENT_FIELD_UNINSERTED,
|
||||||
|
envelopeId: envelope.id,
|
||||||
|
user: {
|
||||||
|
name: recipient.name,
|
||||||
|
email: recipient.email,
|
||||||
|
},
|
||||||
|
requestMetadata: metadata.requestMetadata,
|
||||||
|
data: {
|
||||||
|
field: field.type,
|
||||||
|
fieldId: field.secondaryId,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
signedField: updatedField,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const derivedRecipientActionAuth = await validateFieldAuth({
|
const derivedRecipientActionAuth = await validateFieldAuth({
|
||||||
documentAuthOptions: envelope.authOptions,
|
documentAuthOptions: envelope.authOptions,
|
||||||
recipient,
|
recipient,
|
||||||
|
|||||||
Reference in New Issue
Block a user