@deepintel-ltd/farmpro-contracts 1.5.19 → 1.5.20

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoices.routes.d.ts","sourceRoot":"","sources":["../../src/routes/invoices.routes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAexB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgGzB,CAAC"}
@@ -0,0 +1,98 @@
1
+ import { initContract } from '@ts-rest/core';
2
+ import { z } from 'zod';
3
+ import { createInvoiceSchema, updateInvoiceSchema, invoiceResponseSchema, invoiceListResponseSchema, } from '../schemas/invoices.schemas';
4
+ import { jsonApiErrorResponseSchema, jsonApiPaginationQuerySchema, jsonApiSortQuerySchema, } from '../schemas/common.schemas';
5
+ const c = initContract();
6
+ export const invoicesRouter = c.router({
7
+ // List all invoices for an organization
8
+ listInvoices: {
9
+ method: 'GET',
10
+ path: '/organizations/:organizationId/invoices',
11
+ pathParams: z.object({
12
+ organizationId: z.string().uuid(),
13
+ }),
14
+ query: jsonApiPaginationQuerySchema
15
+ .merge(jsonApiSortQuerySchema)
16
+ .extend({
17
+ 'filter[paymentStatus]': z.enum(['pending', 'paid', 'overdue', 'cancelled']).optional(),
18
+ }),
19
+ responses: {
20
+ 200: invoiceListResponseSchema,
21
+ 401: jsonApiErrorResponseSchema,
22
+ 404: jsonApiErrorResponseSchema,
23
+ },
24
+ summary: 'List all invoices for an organization',
25
+ description: 'Get a paginated list of invoices for the specified organization',
26
+ },
27
+ // Create a new invoice
28
+ createInvoice: {
29
+ method: 'POST',
30
+ path: '/organizations/:organizationId/invoices',
31
+ pathParams: z.object({
32
+ organizationId: z.string().uuid(),
33
+ }),
34
+ body: z.object({ data: createInvoiceSchema }),
35
+ responses: {
36
+ 201: invoiceResponseSchema,
37
+ 400: jsonApiErrorResponseSchema,
38
+ 401: jsonApiErrorResponseSchema,
39
+ 404: jsonApiErrorResponseSchema,
40
+ 422: jsonApiErrorResponseSchema,
41
+ },
42
+ summary: 'Create a new invoice',
43
+ description: 'Create a new invoice for an organization. The invoice will be generated with the organization logo.',
44
+ },
45
+ // Get invoice by ID
46
+ getInvoice: {
47
+ method: 'GET',
48
+ path: '/organizations/:organizationId/invoices/:id',
49
+ pathParams: z.object({
50
+ organizationId: z.string().uuid(),
51
+ id: z.string().uuid(),
52
+ }),
53
+ responses: {
54
+ 200: invoiceResponseSchema,
55
+ 404: jsonApiErrorResponseSchema,
56
+ 401: jsonApiErrorResponseSchema,
57
+ },
58
+ summary: 'Get invoice by ID',
59
+ description: 'Get detailed information about a specific invoice',
60
+ },
61
+ // Update invoice
62
+ updateInvoice: {
63
+ method: 'PATCH',
64
+ path: '/organizations/:organizationId/invoices/:id',
65
+ pathParams: z.object({
66
+ organizationId: z.string().uuid(),
67
+ id: z.string().uuid(),
68
+ }),
69
+ body: z.object({ data: updateInvoiceSchema }),
70
+ responses: {
71
+ 200: invoiceResponseSchema,
72
+ 400: jsonApiErrorResponseSchema,
73
+ 404: jsonApiErrorResponseSchema,
74
+ 401: jsonApiErrorResponseSchema,
75
+ 422: jsonApiErrorResponseSchema,
76
+ },
77
+ summary: 'Update invoice',
78
+ description: 'Update invoice information',
79
+ },
80
+ // Generate invoice PDF
81
+ generateInvoicePdf: {
82
+ method: 'POST',
83
+ path: '/organizations/:organizationId/invoices/:id/generate-pdf',
84
+ pathParams: z.object({
85
+ organizationId: z.string().uuid(),
86
+ id: z.string().uuid(),
87
+ }),
88
+ body: z.void(),
89
+ responses: {
90
+ 200: invoiceResponseSchema,
91
+ 404: jsonApiErrorResponseSchema,
92
+ 401: jsonApiErrorResponseSchema,
93
+ 500: jsonApiErrorResponseSchema,
94
+ },
95
+ summary: 'Generate invoice PDF',
96
+ description: 'Generate and save PDF for an invoice with organization logo',
97
+ },
98
+ });