Compare commits
2 Commits
date-forma
...
feat/singl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e52aa8a12d | ||
|
|
3361acdef3 |
@@ -1,3 +1,5 @@
|
|||||||
|
TEST
|
||||||
|
|
||||||
<p align="center" style="margin-top: 120px">
|
<p align="center" style="margin-top: 120px">
|
||||||
<a href="https://github.com/documenso/documenso">
|
<a href="https://github.com/documenso/documenso">
|
||||||
<img width="250px" src="https://github.com/documenso/documenso/assets/1309312/cd7823ec-4baa-40b9-be78-4acb3b1c73cb" alt="Documenso Logo">
|
<img width="250px" src="https://github.com/documenso/documenso/assets/1309312/cd7823ec-4baa-40b9-be78-4acb3b1c73cb" alt="Documenso Logo">
|
||||||
@@ -227,11 +229,12 @@ docker run -d --restart=unless-stopped -p 3000:3000 -v documenso:/app/data --nam
|
|||||||
```
|
```
|
||||||
|
|
||||||
Command Breakdown:
|
Command Breakdown:
|
||||||
|
|
||||||
- `-d` - Let's you run the container in background
|
- `-d` - Let's you run the container in background
|
||||||
- `-p` - Passes down which ports to use. First half is the host port, Second half is the app port. You can change the first half anything you want and reverse proxy to that port.
|
- `-p` - Passes down which ports to use. First half is the host port, Second half is the app port. You can change the first half anything you want and reverse proxy to that port.
|
||||||
- `-v` - Volume let's you persist the data
|
- `-v` - Volume let's you persist the data
|
||||||
- `--name` - Name of the container
|
- `--name` - Name of the container
|
||||||
- `documenso:latest` - Image you have built
|
- `documenso:latest` - Image you have built
|
||||||
|
|
||||||
# Deployment
|
# Deployment
|
||||||
|
|
||||||
@@ -277,5 +280,5 @@ containers:
|
|||||||
- start
|
- start
|
||||||
- --
|
- --
|
||||||
- -H
|
- -H
|
||||||
- "::"
|
- '::'
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -89,77 +89,84 @@ export const createSinglePlayerDocument = async (
|
|||||||
|
|
||||||
const pdfBytes = await doc.save();
|
const pdfBytes = await doc.save();
|
||||||
|
|
||||||
const documentToken = await prisma.$transaction(async (tx) => {
|
const documentToken = await prisma.$transaction(
|
||||||
const documentToken = nanoid();
|
async (tx) => {
|
||||||
|
const documentToken = nanoid();
|
||||||
|
|
||||||
// Fetch service user who will be the owner of the document.
|
// Fetch service user who will be the owner of the document.
|
||||||
const serviceUser = await tx.user.findFirstOrThrow({
|
const serviceUser = await tx.user.findFirstOrThrow({
|
||||||
where: {
|
where: {
|
||||||
email: SERVICE_USER_EMAIL,
|
email: SERVICE_USER_EMAIL,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const documentDataBytes = Buffer.from(pdfBytes).toString('base64');
|
const documentDataBytes = Buffer.from(pdfBytes).toString('base64');
|
||||||
|
|
||||||
const { id: documentDataId } = await tx.documentData.create({
|
const { id: documentDataId } = await tx.documentData.create({
|
||||||
data: {
|
data: {
|
||||||
type: DocumentDataType.BYTES_64,
|
type: DocumentDataType.BYTES_64,
|
||||||
data: documentDataBytes,
|
data: documentDataBytes,
|
||||||
initialData: documentDataBytes,
|
initialData: documentDataBytes,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create document.
|
// Create document.
|
||||||
const document = await tx.document.create({
|
const document = await tx.document.create({
|
||||||
data: {
|
data: {
|
||||||
title: documentName,
|
title: documentName,
|
||||||
status: DocumentStatus.COMPLETED,
|
status: DocumentStatus.COMPLETED,
|
||||||
documentDataId,
|
documentDataId,
|
||||||
userId: serviceUser.id,
|
userId: serviceUser.id,
|
||||||
createdAt,
|
createdAt,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create recipient.
|
// Create recipient.
|
||||||
const recipient = await tx.recipient.create({
|
const recipient = await tx.recipient.create({
|
||||||
data: {
|
data: {
|
||||||
documentId: document.id,
|
documentId: document.id,
|
||||||
name: signer.name,
|
name: signer.name,
|
||||||
email: signer.email,
|
email: signer.email,
|
||||||
token: documentToken,
|
token: documentToken,
|
||||||
signedAt: createdAt,
|
signedAt: createdAt,
|
||||||
readStatus: ReadStatus.OPENED,
|
readStatus: ReadStatus.OPENED,
|
||||||
signingStatus: SigningStatus.SIGNED,
|
signingStatus: SigningStatus.SIGNED,
|
||||||
sendStatus: SendStatus.SENT,
|
sendStatus: SendStatus.SENT,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create fields and signatures.
|
// Create fields and signatures.
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
fields.map(async (field) => {
|
fields.map(async (field) => {
|
||||||
const insertedField = await tx.field.create({
|
const insertedField = await tx.field.create({
|
||||||
data: {
|
|
||||||
documentId: document.id,
|
|
||||||
recipientId: recipient.id,
|
|
||||||
...mapField(field, signer),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (field.type === FieldType.SIGNATURE || field.type === FieldType.FREE_SIGNATURE) {
|
|
||||||
await tx.signature.create({
|
|
||||||
data: {
|
data: {
|
||||||
fieldId: insertedField.id,
|
documentId: document.id,
|
||||||
signatureImageAsBase64,
|
|
||||||
typedSignature,
|
|
||||||
recipientId: recipient.id,
|
recipientId: recipient.id,
|
||||||
|
...mapField(field, signer),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
return documentToken;
|
if (field.type === FieldType.SIGNATURE || field.type === FieldType.FREE_SIGNATURE) {
|
||||||
});
|
await tx.signature.create({
|
||||||
|
data: {
|
||||||
|
fieldId: insertedField.id,
|
||||||
|
signatureImageAsBase64,
|
||||||
|
typedSignature,
|
||||||
|
recipientId: recipient.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
return documentToken;
|
||||||
|
},
|
||||||
|
// Test values.
|
||||||
|
{
|
||||||
|
maxWait: 30000,
|
||||||
|
timeout: 30000,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
// Todo: Handle `downloadLink`
|
// Todo: Handle `downloadLink`
|
||||||
const template = createElement(DocumentSelfSignedEmailTemplate, {
|
const template = createElement(DocumentSelfSignedEmailTemplate, {
|
||||||
|
|||||||
Reference in New Issue
Block a user