Compare commits

...

2 Commits

4 changed files with 79 additions and 57 deletions

View File

@ -456,10 +456,22 @@ const ZCreateFieldSchema = z.object({
recipientId: z.number(),
type: z.nativeEnum(FieldType),
pageNumber: z.number(),
pageX: z.number(),
pageY: z.number(),
pageWidth: z.number(),
pageHeight: z.number(),
pageX: z
.number()
.min(0, 'Must be between 0-100 (percentage of page width)')
.max(100, 'Must be between 0-100 (percentage of page width)'),
pageY: z
.number()
.min(0, 'Must be between 0-100 (percentage of page height)')
.max(100, 'Must be between 0-100 (percentage of page height)'),
pageWidth: z
.number()
.min(0, 'Must be between 0-100 (percentage of page width)')
.max(100, 'Must be between 0-100 (percentage of page width)'),
pageHeight: z
.number()
.min(0, 'Must be between 0-100 (percentage of page height)')
.max(100, 'Must be between 0-100 (percentage of page height)'),
fieldMeta: ZFieldMetaSchema.openapi({}),
});

View File

@ -427,18 +427,18 @@ test.describe('Document API V2', () => {
field: {
recipientId: recipient!.id,
type: 'TEXT',
pageNumber: 791.77,
pageX: 7845.22,
pageY: 6843.16,
width: 3932.15,
height: 8879.89,
pageNumber: 1,
pageX: 25.5,
pageY: 30.2,
width: 40.0,
height: 15.5,
fieldMeta: { type: 'text', label: 'Test Field' },
},
},
});
expect(res.ok()).toBeFalsy();
expect([404, 401, 500]).toContain(res.status());
expect([400, 404, 401, 500]).toContain(res.status());
});
test('should allow authorized access to document field create endpoint', async ({
@ -459,11 +459,11 @@ test.describe('Document API V2', () => {
field: {
recipientId: recipient!.id,
type: 'TEXT',
pageNumber: 791.77,
pageX: 7845.22,
pageY: 6843.16,
width: 3932.15,
height: 8879.89,
pageNumber: 1,
pageX: 25.5,
pageY: 30.2,
width: 40.0,
height: 15.5,
fieldMeta: { type: 'text', label: 'Test Field' },
},
},
@ -494,21 +494,21 @@ test.describe('Document API V2', () => {
{
recipientId: recipient!.id,
type: 'TEXT',
pageNumber: 791.77,
pageX: 7845.22,
pageY: 6843.16,
width: 3932.15,
height: 8879.89,
pageNumber: 1,
pageX: 25.5,
pageY: 30.2,
width: 40.0,
height: 15.5,
fieldMeta: { type: 'text', label: 'First test field' },
},
{
recipientId: recipient!.id,
type: 'TEXT',
pageNumber: 791.77,
pageX: 845.22,
pageY: 843.16,
width: 932.15,
height: 879.89,
pageNumber: 1,
pageX: 50.0,
pageY: 60.0,
width: 35.0,
height: 12.0,
fieldMeta: { type: 'text', label: 'Second test field' },
},
],
@ -538,21 +538,21 @@ test.describe('Document API V2', () => {
{
recipientId: recipient!.id,
type: 'TEXT',
pageNumber: 791.77,
pageX: 7845.22,
pageY: 6843.16,
width: 3932.15,
height: 8879.89,
pageNumber: 1,
pageX: 25.5,
pageY: 30.2,
width: 40.0,
height: 15.5,
fieldMeta: { type: 'text', label: 'First test field' },
},
{
recipientId: recipient!.id,
type: 'TEXT',
pageNumber: 791.77,
pageX: 845.22,
pageY: 843.16,
width: 932.15,
height: 879.89,
pageNumber: 1,
pageX: 50.0,
pageY: 60.0,
width: 35.0,
height: 12.0,
fieldMeta: { type: 'text', label: 'Second test field' },
},
],
@ -892,11 +892,11 @@ test.describe('Document API V2', () => {
field: {
recipientId: recipient.id,
type: FieldType.TEXT,
pageNumber: 5735.12,
pageX: 936.28,
pageY: 594.41,
width: 589.39,
height: 122.23,
pageNumber: 1,
pageX: 35.0,
pageY: 45.0,
width: 30.0,
height: 10.0,
fieldMeta: { type: 'text', label: 'Test' },
},
},
@ -931,11 +931,11 @@ test.describe('Document API V2', () => {
field: {
recipientId: recipient.id,
type: FieldType.TEXT,
pageNumber: 5735.12,
pageX: 936.28,
pageY: 594.41,
width: 589.39,
height: 122.23,
pageNumber: 1,
pageX: 35.0,
pageY: 45.0,
width: 30.0,
height: 10.0,
fieldMeta: { type: 'text', label: 'Test' },
},
},

View File

@ -57,17 +57,27 @@ export const ZFieldPageNumberSchema = z
export const ZFieldPageXSchema = z
.number()
.min(0)
.min(0, 'Must be between 0-100 (percentage of page width)')
.max(100, 'Must be between 0-100 (percentage of page width)')
.describe('The X coordinate of where the field will be placed.');
export const ZFieldPageYSchema = z
.number()
.min(0)
.min(0, 'Must be between 0-100 (percentage of page height)')
.max(100, 'Must be between 0-100 (percentage of page height)')
.describe('The Y coordinate of where the field will be placed.');
export const ZFieldWidthSchema = z.number().min(1).describe('The width of the field.');
export const ZFieldWidthSchema = z
.number()
.min(0, 'Must be between 0-100 (percentage of page width)')
.max(100, 'Must be between 0-100 (percentage of page width)')
.describe('The width of the field.');
export const ZFieldHeightSchema = z.number().min(1).describe('The height of the field.');
export const ZFieldHeightSchema = z
.number()
.min(0, 'Must be between 0-100 (percentage of page height)')
.max(100, 'Must be between 0-100 (percentage of page height)')
.describe('The height of the field.');
// ---------------------------------------------

View File

@ -115,10 +115,10 @@ export const ZSetDocumentFieldsRequestSchema = z.object({
recipientId: z.number().min(1),
envelopeItemId: z.string(),
pageNumber: z.number().min(1),
pageX: z.number().min(0),
pageY: z.number().min(0),
pageWidth: z.number().min(0),
pageHeight: z.number().min(0),
pageX: z.number().min(0).max(100),
pageY: z.number().min(0).max(100),
pageWidth: z.number().min(0).max(100),
pageHeight: z.number().min(0).max(100),
fieldMeta: ZFieldMetaSchema,
}),
),
@ -137,10 +137,10 @@ export const ZSetFieldsForTemplateRequestSchema = z.object({
recipientId: z.number().min(1),
envelopeItemId: z.string(),
pageNumber: z.number().min(1),
pageX: z.number().min(0),
pageY: z.number().min(0),
pageWidth: z.number().min(0),
pageHeight: z.number().min(0),
pageX: z.number().min(0).max(100),
pageY: z.number().min(0).max(100),
pageWidth: z.number().min(0).max(100),
pageHeight: z.number().min(0).max(100),
fieldMeta: ZFieldMetaSchema,
}),
),