@fiado/type-kit 3.525.0 → 3.527.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/_test_/unit/pdfRender/pdfRenderDtos.test.ts +10 -0
- package/bin/pdfRender/dtos/DocumentUrlResponse.d.ts +1 -3
- package/bin/pdfRender/dtos/GeneratePdfRequest.d.ts +10 -0
- package/bin/pdfRender/dtos/GeneratePdfRequest.js +18 -0
- package/bin/pdfRender/dtos/MergePdfsRequest.d.ts +10 -0
- package/bin/pdfRender/dtos/MergePdfsRequest.js +18 -0
- package/bin/pdfRender/dtos/PdfDocumentResponse.d.ts +4 -2
- package/bin/pdfRender/dtos/PdfDocumentResponse.js +3 -1
- package/bin/pdfRender/dtos/RenderDocumentRequest.d.ts +6 -0
- package/bin/pdfRender/dtos/RenderDocumentRequest.js +6 -0
- package/package.json +1 -1
- package/src/pdfRender/dtos/DocumentUrlResponse.ts +1 -3
- package/src/pdfRender/dtos/GeneratePdfRequest.ts +17 -1
- package/src/pdfRender/dtos/MergePdfsRequest.ts +17 -1
- package/src/pdfRender/dtos/PdfDocumentResponse.ts +4 -2
- package/src/pdfRender/dtos/RenderDocumentRequest.ts +9 -1
|
@@ -74,3 +74,13 @@ describe('pdfRender includeContent', () => {
|
|
|
74
74
|
expect(await errorsOf(MergePdfsRequest, { pdfs: ['JVBERi0='], includeContent: 1 })).toEqual(['includeContent']);
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
|
+
|
|
78
|
+
describe('pdfRender referenceId', () => {
|
|
79
|
+
it('accepts the owner id and folder fields, and rejects unsafe segments', async () => {
|
|
80
|
+
const template = { enterprise: 'SUREKEEP', documentType: 'CREDIT_CONTRACT' };
|
|
81
|
+
expect(await errorsOf(RenderDocumentRequest, { template, data: {}, referenceId: '01JX9KAB12' })).toEqual([]);
|
|
82
|
+
expect(await errorsOf(RenderDocumentRequest, { template, data: {}, referenceId: '../x' })).toEqual(['referenceId']);
|
|
83
|
+
expect(await errorsOf(GeneratePdfRequest, { html: '<p/>', enterprise: 'SUREKEEP', documentType: 'CREDIT_SUMMARY', referenceId: 'abc' })).toEqual([]);
|
|
84
|
+
expect(await errorsOf(MergePdfsRequest, { pdfs: ['JVBERi0='], enterprise: 'A/B' })).toEqual(['enterprise']);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/** Nueva URL firmada para un documento ya guardado. */
|
|
2
2
|
export declare class DocumentUrlResponse {
|
|
3
|
-
|
|
3
|
+
key: string;
|
|
4
4
|
url: string;
|
|
5
5
|
/** ISO-8601. */
|
|
6
6
|
expiresAt: string;
|
|
7
7
|
sha256: string;
|
|
8
8
|
pages: number;
|
|
9
9
|
bytes: number;
|
|
10
|
-
/** ISO-8601 de la generación. */
|
|
11
|
-
createdAt: string;
|
|
12
10
|
}
|
|
@@ -3,4 +3,14 @@ export declare class GeneratePdfRequest {
|
|
|
3
3
|
html: string;
|
|
4
4
|
/** Además de la URL, devuelve el PDF en base64 en la respuesta (tope de 4 MiB). */
|
|
5
5
|
includeContent?: boolean;
|
|
6
|
+
/** Empresa (tenant) dueña del documento; sin ella se guarda en una carpeta común. */
|
|
7
|
+
enterprise?: string;
|
|
8
|
+
/** Tipo de documento (carpeta en S3), p. ej. CREDIT_CONTRACT. */
|
|
9
|
+
documentType?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Id de la entidad dueña del documento (crédito, cliente...). Forma parte de la llave en S3, igual
|
|
12
|
+
* que en el resto del bucket de contratos: {EMPRESA}/{TIPO}/{referenceId}/{uuid}.pdf, o con partner
|
|
13
|
+
* {EMPRESA}/{PARTNER}/{CATEGORIA}/{referenceId}/{TIPO}/{uuid}.pdf.
|
|
14
|
+
*/
|
|
15
|
+
referenceId?: string;
|
|
6
16
|
}
|
|
@@ -25,3 +25,21 @@ __decorate([
|
|
|
25
25
|
(0, class_validator_1.IsBoolean)(),
|
|
26
26
|
__metadata("design:type", Boolean)
|
|
27
27
|
], GeneratePdfRequest.prototype, "includeContent", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, class_validator_1.IsOptional)(),
|
|
30
|
+
(0, class_validator_1.IsString)(),
|
|
31
|
+
(0, class_validator_1.Matches)(/^[A-Za-z0-9_-]{1,64}$/),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], GeneratePdfRequest.prototype, "enterprise", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, class_validator_1.IsOptional)(),
|
|
36
|
+
(0, class_validator_1.IsString)(),
|
|
37
|
+
(0, class_validator_1.Matches)(/^[A-Za-z0-9_-]{1,64}$/),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], GeneratePdfRequest.prototype, "documentType", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, class_validator_1.IsOptional)(),
|
|
42
|
+
(0, class_validator_1.IsString)(),
|
|
43
|
+
(0, class_validator_1.Matches)(/^[A-Za-z0-9_-]{1,64}$/),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], GeneratePdfRequest.prototype, "referenceId", void 0);
|
|
@@ -3,4 +3,14 @@ export declare class MergePdfsRequest {
|
|
|
3
3
|
pdfs: string[];
|
|
4
4
|
/** Además de la URL, devuelve el PDF en base64 en la respuesta (tope de 4 MiB). */
|
|
5
5
|
includeContent?: boolean;
|
|
6
|
+
/** Empresa (tenant) dueña del documento; sin ella se guarda en una carpeta común. */
|
|
7
|
+
enterprise?: string;
|
|
8
|
+
/** Tipo de documento (carpeta en S3), p. ej. CREDIT_CONTRACT. */
|
|
9
|
+
documentType?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Id de la entidad dueña del documento (crédito, cliente...). Forma parte de la llave en S3, igual
|
|
12
|
+
* que en el resto del bucket de contratos: {EMPRESA}/{TIPO}/{referenceId}/{uuid}.pdf, o con partner
|
|
13
|
+
* {EMPRESA}/{PARTNER}/{CATEGORIA}/{referenceId}/{TIPO}/{uuid}.pdf.
|
|
14
|
+
*/
|
|
15
|
+
referenceId?: string;
|
|
6
16
|
}
|
|
@@ -27,3 +27,21 @@ __decorate([
|
|
|
27
27
|
(0, class_validator_1.IsBoolean)(),
|
|
28
28
|
__metadata("design:type", Boolean)
|
|
29
29
|
], MergePdfsRequest.prototype, "includeContent", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, class_validator_1.IsOptional)(),
|
|
32
|
+
(0, class_validator_1.IsString)(),
|
|
33
|
+
(0, class_validator_1.Matches)(/^[A-Za-z0-9_-]{1,64}$/),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], MergePdfsRequest.prototype, "enterprise", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, class_validator_1.IsOptional)(),
|
|
38
|
+
(0, class_validator_1.IsString)(),
|
|
39
|
+
(0, class_validator_1.Matches)(/^[A-Za-z0-9_-]{1,64}$/),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], MergePdfsRequest.prototype, "documentType", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, class_validator_1.IsOptional)(),
|
|
44
|
+
(0, class_validator_1.IsString)(),
|
|
45
|
+
(0, class_validator_1.Matches)(/^[A-Za-z0-9_-]{1,64}$/),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], MergePdfsRequest.prototype, "referenceId", void 0);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Documento PDF generado y guardado por pdf-render-business.
|
|
3
|
-
*
|
|
3
|
+
* `key` es la ubicación del documento en el bucket de contratos, por convención
|
|
4
|
+
* {EMPRESA}/{TIPO}/{referenceId}/{uuid}.pdf (o {EMPRESA}/{PARTNER}/{CATEGORIA}/{referenceId}/{TIPO}/{uuid}.pdf),
|
|
5
|
+
* y es lo que se guarda para pedir una URL nueva con GET /documents/url?key=... cuando venza la actual.
|
|
4
6
|
*/
|
|
5
7
|
export declare class PdfDocumentResponse {
|
|
6
|
-
|
|
8
|
+
key: string;
|
|
7
9
|
url: string;
|
|
8
10
|
/** ISO-8601. */
|
|
9
11
|
expiresAt: string;
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PdfDocumentResponse = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Documento PDF generado y guardado por pdf-render-business.
|
|
6
|
-
*
|
|
6
|
+
* `key` es la ubicación del documento en el bucket de contratos, por convención
|
|
7
|
+
* {EMPRESA}/{TIPO}/{referenceId}/{uuid}.pdf (o {EMPRESA}/{PARTNER}/{CATEGORIA}/{referenceId}/{TIPO}/{uuid}.pdf),
|
|
8
|
+
* y es lo que se guarda para pedir una URL nueva con GET /documents/url?key=... cuando venza la actual.
|
|
7
9
|
*/
|
|
8
10
|
class PdfDocumentResponse {
|
|
9
11
|
}
|
|
@@ -5,4 +5,10 @@ export declare class RenderDocumentRequest {
|
|
|
5
5
|
data: Record<string, unknown>;
|
|
6
6
|
/** Además de la URL, devuelve el PDF en base64 en la respuesta (tope de 4 MiB). */
|
|
7
7
|
includeContent?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Id de la entidad dueña del documento (crédito, cliente...). Forma parte de la llave en S3, igual
|
|
10
|
+
* que en el resto del bucket de contratos: {EMPRESA}/{TIPO}/{referenceId}/{uuid}.pdf, o con partner
|
|
11
|
+
* {EMPRESA}/{PARTNER}/{CATEGORIA}/{referenceId}/{TIPO}/{uuid}.pdf.
|
|
12
|
+
*/
|
|
13
|
+
referenceId?: string;
|
|
8
14
|
}
|
|
@@ -32,3 +32,9 @@ __decorate([
|
|
|
32
32
|
(0, class_validator_1.IsBoolean)(),
|
|
33
33
|
__metadata("design:type", Boolean)
|
|
34
34
|
], RenderDocumentRequest.prototype, "includeContent", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, class_validator_1.IsOptional)(),
|
|
37
|
+
(0, class_validator_1.IsString)(),
|
|
38
|
+
(0, class_validator_1.Matches)(/^[A-Za-z0-9_-]{1,64}$/),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], RenderDocumentRequest.prototype, "referenceId", void 0);
|
package/package.json
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/** Nueva URL firmada para un documento ya guardado. */
|
|
2
2
|
export class DocumentUrlResponse {
|
|
3
|
-
|
|
3
|
+
key!: string;
|
|
4
4
|
url!: string;
|
|
5
5
|
/** ISO-8601. */
|
|
6
6
|
expiresAt!: string;
|
|
7
7
|
sha256!: string;
|
|
8
8
|
pages!: number;
|
|
9
9
|
bytes!: number;
|
|
10
|
-
/** ISO-8601 de la generación. */
|
|
11
|
-
createdAt!: string;
|
|
12
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IsBoolean, IsNotEmpty, IsOptional, IsString } from "class-validator";
|
|
1
|
+
import { IsBoolean, IsNotEmpty, IsOptional, IsString, Matches } from "class-validator";
|
|
2
2
|
|
|
3
3
|
/** HTML ya resuelto por el consumidor; se imprime en A4 con márgenes de 2 mm. */
|
|
4
4
|
export class GeneratePdfRequest {
|
|
@@ -8,4 +8,20 @@ export class GeneratePdfRequest {
|
|
|
8
8
|
/** Además de la URL, devuelve el PDF en base64 en la respuesta (tope de 4 MiB). */
|
|
9
9
|
@IsOptional() @IsBoolean()
|
|
10
10
|
includeContent?: boolean;
|
|
11
|
+
|
|
12
|
+
/** Empresa (tenant) dueña del documento; sin ella se guarda en una carpeta común. */
|
|
13
|
+
@IsOptional() @IsString() @Matches(/^[A-Za-z0-9_-]{1,64}$/)
|
|
14
|
+
enterprise?: string;
|
|
15
|
+
|
|
16
|
+
/** Tipo de documento (carpeta en S3), p. ej. CREDIT_CONTRACT. */
|
|
17
|
+
@IsOptional() @IsString() @Matches(/^[A-Za-z0-9_-]{1,64}$/)
|
|
18
|
+
documentType?: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Id de la entidad dueña del documento (crédito, cliente...). Forma parte de la llave en S3, igual
|
|
22
|
+
* que en el resto del bucket de contratos: {EMPRESA}/{TIPO}/{referenceId}/{uuid}.pdf, o con partner
|
|
23
|
+
* {EMPRESA}/{PARTNER}/{CATEGORIA}/{referenceId}/{TIPO}/{uuid}.pdf.
|
|
24
|
+
*/
|
|
25
|
+
@IsOptional() @IsString() @Matches(/^[A-Za-z0-9_-]{1,64}$/)
|
|
26
|
+
referenceId?: string;
|
|
11
27
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArrayMaxSize, ArrayMinSize, IsArray, IsBoolean, IsOptional, IsString } from "class-validator";
|
|
1
|
+
import { ArrayMaxSize, ArrayMinSize, IsArray, IsBoolean, IsOptional, IsString, Matches } from "class-validator";
|
|
2
2
|
|
|
3
3
|
/** PDFs en base64, en el orden en que deben quedar en el documento final. */
|
|
4
4
|
export class MergePdfsRequest {
|
|
@@ -8,4 +8,20 @@ export class MergePdfsRequest {
|
|
|
8
8
|
/** Además de la URL, devuelve el PDF en base64 en la respuesta (tope de 4 MiB). */
|
|
9
9
|
@IsOptional() @IsBoolean()
|
|
10
10
|
includeContent?: boolean;
|
|
11
|
+
|
|
12
|
+
/** Empresa (tenant) dueña del documento; sin ella se guarda en una carpeta común. */
|
|
13
|
+
@IsOptional() @IsString() @Matches(/^[A-Za-z0-9_-]{1,64}$/)
|
|
14
|
+
enterprise?: string;
|
|
15
|
+
|
|
16
|
+
/** Tipo de documento (carpeta en S3), p. ej. CREDIT_CONTRACT. */
|
|
17
|
+
@IsOptional() @IsString() @Matches(/^[A-Za-z0-9_-]{1,64}$/)
|
|
18
|
+
documentType?: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Id de la entidad dueña del documento (crédito, cliente...). Forma parte de la llave en S3, igual
|
|
22
|
+
* que en el resto del bucket de contratos: {EMPRESA}/{TIPO}/{referenceId}/{uuid}.pdf, o con partner
|
|
23
|
+
* {EMPRESA}/{PARTNER}/{CATEGORIA}/{referenceId}/{TIPO}/{uuid}.pdf.
|
|
24
|
+
*/
|
|
25
|
+
@IsOptional() @IsString() @Matches(/^[A-Za-z0-9_-]{1,64}$/)
|
|
26
|
+
referenceId?: string;
|
|
11
27
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Documento PDF generado y guardado por pdf-render-business.
|
|
3
|
-
*
|
|
3
|
+
* `key` es la ubicación del documento en el bucket de contratos, por convención
|
|
4
|
+
* {EMPRESA}/{TIPO}/{referenceId}/{uuid}.pdf (o {EMPRESA}/{PARTNER}/{CATEGORIA}/{referenceId}/{TIPO}/{uuid}.pdf),
|
|
5
|
+
* y es lo que se guarda para pedir una URL nueva con GET /documents/url?key=... cuando venza la actual.
|
|
4
6
|
*/
|
|
5
7
|
export class PdfDocumentResponse {
|
|
6
|
-
|
|
8
|
+
key!: string;
|
|
7
9
|
url!: string;
|
|
8
10
|
/** ISO-8601. */
|
|
9
11
|
expiresAt!: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IsBoolean, IsDefined, IsObject, IsOptional, ValidateNested } from "class-validator";
|
|
1
|
+
import { IsBoolean, IsDefined, IsObject, IsOptional, IsString, Matches, ValidateNested } from "class-validator";
|
|
2
2
|
import { Type } from "class-transformer";
|
|
3
3
|
import { TemplateRefRequest } from "./TemplateRefRequest";
|
|
4
4
|
|
|
@@ -13,4 +13,12 @@ export class RenderDocumentRequest {
|
|
|
13
13
|
/** Además de la URL, devuelve el PDF en base64 en la respuesta (tope de 4 MiB). */
|
|
14
14
|
@IsOptional() @IsBoolean()
|
|
15
15
|
includeContent?: boolean;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Id de la entidad dueña del documento (crédito, cliente...). Forma parte de la llave en S3, igual
|
|
19
|
+
* que en el resto del bucket de contratos: {EMPRESA}/{TIPO}/{referenceId}/{uuid}.pdf, o con partner
|
|
20
|
+
* {EMPRESA}/{PARTNER}/{CATEGORIA}/{referenceId}/{TIPO}/{uuid}.pdf.
|
|
21
|
+
*/
|
|
22
|
+
@IsOptional() @IsString() @Matches(/^[A-Za-z0-9_-]{1,64}$/)
|
|
23
|
+
referenceId?: string;
|
|
16
24
|
}
|