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(), recipientId: z.number(),
type: z.nativeEnum(FieldType), type: z.nativeEnum(FieldType),
pageNumber: z.number(), pageNumber: z.number(),
pageX: z.number(), pageX: z
pageY: z.number(), .number()
pageWidth: z.number(), .min(0, 'Must be between 0-100 (percentage of page width)')
pageHeight: z.number(), .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({}), fieldMeta: ZFieldMetaSchema.openapi({}),
}); });

View File

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

View File

@ -57,17 +57,27 @@ export const ZFieldPageNumberSchema = z
export const ZFieldPageXSchema = z export const ZFieldPageXSchema = z
.number() .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.'); .describe('The X coordinate of where the field will be placed.');
export const ZFieldPageYSchema = z export const ZFieldPageYSchema = z
.number() .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.'); .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), recipientId: z.number().min(1),
envelopeItemId: z.string(), envelopeItemId: z.string(),
pageNumber: z.number().min(1), pageNumber: z.number().min(1),
pageX: z.number().min(0), pageX: z.number().min(0).max(100),
pageY: z.number().min(0), pageY: z.number().min(0).max(100),
pageWidth: z.number().min(0), pageWidth: z.number().min(0).max(100),
pageHeight: z.number().min(0), pageHeight: z.number().min(0).max(100),
fieldMeta: ZFieldMetaSchema, fieldMeta: ZFieldMetaSchema,
}), }),
), ),
@ -137,10 +137,10 @@ export const ZSetFieldsForTemplateRequestSchema = z.object({
recipientId: z.number().min(1), recipientId: z.number().min(1),
envelopeItemId: z.string(), envelopeItemId: z.string(),
pageNumber: z.number().min(1), pageNumber: z.number().min(1),
pageX: z.number().min(0), pageX: z.number().min(0).max(100),
pageY: z.number().min(0), pageY: z.number().min(0).max(100),
pageWidth: z.number().min(0), pageWidth: z.number().min(0).max(100),
pageHeight: z.number().min(0), pageHeight: z.number().min(0).max(100),
fieldMeta: ZFieldMetaSchema, fieldMeta: ZFieldMetaSchema,
}), }),
), ),