@spaceinvoices/react-ui 0.4.0 → 0.4.1

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.
@@ -8,6 +8,17 @@ import { z } from 'zod';
8
8
 
9
9
  // Schemas for invoice endpoints
10
10
 
11
+ // Dependency schema for invoice
12
+ const CreateDocumentPayment = z.object({
13
+ amount: z.number().gt(0).optional(),
14
+ type: z.string().max(20),
15
+ date: z.string().optional(),
16
+ reference: z.union([z.string(), z.null()]).optional(),
17
+ note: z.union([z.string(), z.null()]).optional(),
18
+ metadata: z.union([z.record(z.string(), z.any()), z.null()]).optional(),
19
+ });
20
+
21
+
11
22
  // Dependency schema for invoice
12
23
  const LineDiscount = z.object({
13
24
  value: z.number().gte(0),
@@ -15,6 +26,56 @@ const LineDiscount = z.object({
15
26
  });
16
27
 
17
28
 
29
+ // Dependency schema for invoice
30
+ const DocumentItemTax = z
31
+ .object({
32
+ rate: z.number(),
33
+ tax_id: z.string(),
34
+ classification: z.string(),
35
+ reverse_charge: z.boolean(),
36
+ amount: z.number(),
37
+ })
38
+ .partial();
39
+
40
+
41
+ // Dependency schema for invoice
42
+ const DocumentEntity = z
43
+ .object({
44
+ name: z.union([z.string(), z.null()]),
45
+ email: z.union([z.string(), z.null()]),
46
+ address: z.union([z.string(), z.null()]),
47
+ address_2: z.union([z.string(), z.null()]),
48
+ post_code: z.union([z.string(), z.null()]),
49
+ city: z.union([z.string(), z.null()]),
50
+ state: z.union([z.string(), z.null()]),
51
+ country: z.union([z.string(), z.null()]),
52
+ country_code: z.union([z.string(), z.null()]),
53
+ tax_number: z.union([z.string(), z.null()]),
54
+ tax_number_2: z.union([z.string(), z.null()]),
55
+ company_number: z.union([z.string(), z.null()]),
56
+ bank_account: z.union([
57
+ z
58
+ .object({
59
+ type: z
60
+ .enum(["iban", "us_domestic", "uk_domestic", "other"])
61
+ .default("iban"),
62
+ name: z.string(),
63
+ bank_name: z.string(),
64
+ iban: z.string(),
65
+ account_number: z.string(),
66
+ bic: z.string(),
67
+ routing_number: z.string(),
68
+ sort_code: z.string(),
69
+ })
70
+ .partial()
71
+ .passthrough(),
72
+ z.null(),
73
+ ]),
74
+ })
75
+ .partial()
76
+ .passthrough();
77
+
78
+
18
79
  // Schema for create invoice operation
19
80
  const createInvoiceSchemaDefinition = z.object({
20
81
  is_draft: z.boolean().optional(),
@@ -22,84 +83,17 @@ const createInvoiceSchemaDefinition = z.object({
22
83
  .string()
23
84
  .regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?)?$/)
24
85
  .optional(),
25
- issuer: z
26
- .object({
27
- name: z.union([z.string(), z.null()]),
28
- email: z.union([z.string(), z.null()]),
29
- address: z.union([z.string(), z.null()]),
30
- address_2: z.union([z.string(), z.null()]),
31
- post_code: z.union([z.string(), z.null()]),
32
- city: z.union([z.string(), z.null()]),
33
- state: z.union([z.string(), z.null()]),
34
- country: z.union([z.string(), z.null()]),
35
- country_code: z.union([z.string(), z.null()]),
36
- tax_number: z.union([z.string(), z.null()]),
37
- tax_number_2: z.union([z.string(), z.null()]),
38
- company_number: z.union([z.string(), z.null()]),
39
- bank_account: z.union([
40
- z
41
- .object({
42
- type: z
43
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
44
- .default("iban"),
45
- name: z.string(),
46
- bank_name: z.string(),
47
- iban: z.string(),
48
- account_number: z.string(),
49
- bic: z.string(),
50
- routing_number: z.string(),
51
- sort_code: z.string(),
52
- })
53
- .partial()
54
- .passthrough(),
55
- z.null(),
56
- ]),
57
- })
58
- .partial()
59
- .passthrough()
60
- .optional(),
86
+ issuer: DocumentEntity.optional(),
61
87
  customer_id: z.union([z.string(), z.null()]).optional(),
62
- customer: z
63
- .union([
88
+ customer: DocumentEntity.and(
89
+ z.union([
64
90
  z
65
- .object({
66
- name: z.union([z.string(), z.null()]),
67
- email: z.union([z.string(), z.null()]),
68
- address: z.union([z.string(), z.null()]),
69
- address_2: z.union([z.string(), z.null()]),
70
- post_code: z.union([z.string(), z.null()]),
71
- city: z.union([z.string(), z.null()]),
72
- state: z.union([z.string(), z.null()]),
73
- country: z.union([z.string(), z.null()]),
74
- country_code: z.union([z.string(), z.null()]),
75
- tax_number: z.union([z.string(), z.null()]),
76
- tax_number_2: z.union([z.string(), z.null()]),
77
- company_number: z.union([z.string(), z.null()]),
78
- bank_account: z.union([
79
- z
80
- .object({
81
- type: z
82
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
83
- .default("iban"),
84
- name: z.string(),
85
- bank_name: z.string(),
86
- iban: z.string(),
87
- account_number: z.string(),
88
- bic: z.string(),
89
- routing_number: z.string(),
90
- sort_code: z.string(),
91
- })
92
- .partial()
93
- .passthrough(),
94
- z.null(),
95
- ]),
96
- save_customer: z.boolean().default(true),
97
- })
91
+ .object({ save_customer: z.boolean().default(true) })
98
92
  .partial()
99
93
  .passthrough(),
100
94
  z.null(),
101
95
  ])
102
- .optional(),
96
+ ).optional(),
103
97
  note: z.union([z.string(), z.null()]).optional(),
104
98
  payment_terms: z.union([z.string(), z.null()]).optional(),
105
99
  tax_clause: z.union([z.string(), z.null()]).optional(),
@@ -117,19 +111,7 @@ const createInvoiceSchemaDefinition = z.object({
117
111
  gross_price: z.number().optional(),
118
112
  quantity: z.number().gte(-140737488355328).lte(140737488355327),
119
113
  unit: z.union([z.string(), z.null()]).optional(),
120
- taxes: z
121
- .array(
122
- z
123
- .object({
124
- rate: z.number(),
125
- tax_id: z.string(),
126
- classification: z.string(),
127
- reverse_charge: z.boolean(),
128
- amount: z.number(),
129
- })
130
- .partial()
131
- )
132
- .optional(),
114
+ taxes: z.array(DocumentItemTax).optional(),
133
115
  discounts: z.array(LineDiscount).max(5).optional(),
134
116
  metadata: z
135
117
  .union([
@@ -147,21 +129,7 @@ const createInvoiceSchemaDefinition = z.object({
147
129
  )
148
130
  .min(1),
149
131
  linked_documents: z.array(z.string().min(1)).optional(),
150
- payments: z
151
- .union([
152
- z.array(
153
- z.object({
154
- amount: z.number().gt(0).optional(),
155
- type: z.string().max(20),
156
- date: z.string().optional(),
157
- reference: z.union([z.string(), z.null()]).optional(),
158
- note: z.union([z.string(), z.null()]).optional(),
159
- metadata: z.union([z.record(z.string(), z.any()), z.null()]).optional(),
160
- })
161
- ),
162
- z.null(),
163
- ])
164
- .optional(),
132
+ payments: z.union([z.array(CreateDocumentPayment), z.null()]).optional(),
165
133
  furs: z
166
134
  .union([
167
135
  z
@@ -230,81 +198,17 @@ const updateInvoiceSchemaDefinition = z
230
198
  date: z
231
199
  .string()
232
200
  .regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?)?$/),
233
- issuer: z
234
- .object({
235
- name: z.union([z.string(), z.null()]),
236
- email: z.union([z.string(), z.null()]),
237
- address: z.union([z.string(), z.null()]),
238
- address_2: z.union([z.string(), z.null()]),
239
- post_code: z.union([z.string(), z.null()]),
240
- city: z.union([z.string(), z.null()]),
241
- state: z.union([z.string(), z.null()]),
242
- country: z.union([z.string(), z.null()]),
243
- country_code: z.union([z.string(), z.null()]),
244
- tax_number: z.union([z.string(), z.null()]),
245
- tax_number_2: z.union([z.string(), z.null()]),
246
- company_number: z.union([z.string(), z.null()]),
247
- bank_account: z.union([
248
- z
249
- .object({
250
- type: z
251
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
252
- .default("iban"),
253
- name: z.string(),
254
- bank_name: z.string(),
255
- iban: z.string(),
256
- account_number: z.string(),
257
- bic: z.string(),
258
- routing_number: z.string(),
259
- sort_code: z.string(),
260
- })
261
- .partial()
262
- .passthrough(),
263
- z.null(),
264
- ]),
265
- })
266
- .partial()
267
- .passthrough(),
201
+ issuer: DocumentEntity.and(z.unknown()),
268
202
  customer_id: z.union([z.string(), z.null()]),
269
- customer: z.union([
270
- z
271
- .object({
272
- name: z.union([z.string(), z.null()]),
273
- email: z.union([z.string(), z.null()]),
274
- address: z.union([z.string(), z.null()]),
275
- address_2: z.union([z.string(), z.null()]),
276
- post_code: z.union([z.string(), z.null()]),
277
- city: z.union([z.string(), z.null()]),
278
- state: z.union([z.string(), z.null()]),
279
- country: z.union([z.string(), z.null()]),
280
- country_code: z.union([z.string(), z.null()]),
281
- tax_number: z.union([z.string(), z.null()]),
282
- tax_number_2: z.union([z.string(), z.null()]),
283
- company_number: z.union([z.string(), z.null()]),
284
- bank_account: z.union([
285
- z
286
- .object({
287
- type: z
288
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
289
- .default("iban"),
290
- name: z.string(),
291
- bank_name: z.string(),
292
- iban: z.string(),
293
- account_number: z.string(),
294
- bic: z.string(),
295
- routing_number: z.string(),
296
- sort_code: z.string(),
297
- })
298
- .partial()
299
- .passthrough(),
300
- z.null(),
301
- ]),
302
- save_customer: z.boolean().default(true),
303
- })
304
- .partial()
305
- .passthrough(),
306
- z.null(),
307
- ]),
203
+ customer: DocumentEntity.and(
204
+ z.union([
205
+ z
206
+ .object({ save_customer: z.boolean().default(true) })
207
+ .partial()
208
+ .passthrough(),
209
+ z.null(),
210
+ ])
211
+ ),
308
212
  items: z
309
213
  .array(
310
214
  z.object({
@@ -314,19 +218,7 @@ const updateInvoiceSchemaDefinition = z
314
218
  gross_price: z.number().optional(),
315
219
  quantity: z.number().gte(-140737488355328).lte(140737488355327),
316
220
  unit: z.union([z.string(), z.null()]).optional(),
317
- taxes: z
318
- .array(
319
- z
320
- .object({
321
- rate: z.number(),
322
- tax_id: z.string(),
323
- classification: z.string(),
324
- reverse_charge: z.boolean(),
325
- amount: z.number(),
326
- })
327
- .partial()
328
- )
329
- .optional(),
221
+ taxes: z.array(DocumentItemTax).optional(),
330
222
  discounts: z.array(LineDiscount).max(5).optional(),
331
223
  metadata: z
332
224
  .union([
@@ -14,14 +14,18 @@ const registerFursRealEstatePremiseSchemaDefinition = z.object({
14
14
  real_estate: z
15
15
  .object({
16
16
  cadastral_number: z.string().min(1).regex(/^\d+$/),
17
- building_number: z.union([z.string(), z.null()]).optional(),
18
- building_section: z.union([z.string(), z.null()]).optional(),
19
- community: z.string().min(1),
20
- city: z.union([z.string(), z.null()]).optional(),
21
- street: z.union([z.string(), z.null()]).optional(),
22
- house_number: z.union([z.string(), z.null()]).optional(),
17
+ building_number: z.string().min(1).regex(/^\d+$/),
18
+ building_section: z.string().min(1).regex(/^\d+$/),
19
+ street: z.string().min(1).max(100),
20
+ house_number: z.string().min(1).max(10),
23
21
  house_number_additional: z.union([z.string(), z.null()]).optional(),
24
- postal_code: z.union([z.string(), z.null()]).optional(),
22
+ community: z.string().min(1).max(100),
23
+ city: z.string().min(1).max(100),
24
+ postal_code: z
25
+ .string()
26
+ .min(4)
27
+ .max(4)
28
+ .regex(/^\d{4}$/),
25
29
  })
26
30
  .passthrough(),
27
31
  });
@@ -15,6 +15,56 @@ const LineDiscount = z.object({
15
15
  });
16
16
 
17
17
 
18
+ // Dependency schema for renderadvanceinvoicepreview_body
19
+ const DocumentItemTax = z
20
+ .object({
21
+ rate: z.number(),
22
+ tax_id: z.string(),
23
+ classification: z.string(),
24
+ reverse_charge: z.boolean(),
25
+ amount: z.number(),
26
+ })
27
+ .partial();
28
+
29
+
30
+ // Dependency schema for renderadvanceinvoicepreview_body
31
+ const DocumentEntity = z
32
+ .object({
33
+ name: z.union([z.string(), z.null()]),
34
+ email: z.union([z.string(), z.null()]),
35
+ address: z.union([z.string(), z.null()]),
36
+ address_2: z.union([z.string(), z.null()]),
37
+ post_code: z.union([z.string(), z.null()]),
38
+ city: z.union([z.string(), z.null()]),
39
+ state: z.union([z.string(), z.null()]),
40
+ country: z.union([z.string(), z.null()]),
41
+ country_code: z.union([z.string(), z.null()]),
42
+ tax_number: z.union([z.string(), z.null()]),
43
+ tax_number_2: z.union([z.string(), z.null()]),
44
+ company_number: z.union([z.string(), z.null()]),
45
+ bank_account: z.union([
46
+ z
47
+ .object({
48
+ type: z
49
+ .enum(["iban", "us_domestic", "uk_domestic", "other"])
50
+ .default("iban"),
51
+ name: z.string(),
52
+ bank_name: z.string(),
53
+ iban: z.string(),
54
+ account_number: z.string(),
55
+ bic: z.string(),
56
+ routing_number: z.string(),
57
+ sort_code: z.string(),
58
+ })
59
+ .partial()
60
+ .passthrough(),
61
+ z.null(),
62
+ ]),
63
+ })
64
+ .partial()
65
+ .passthrough();
66
+
67
+
18
68
  // Dependency schema for renderadvanceinvoicepreview_body
19
69
  const CompleteAdvanceInvoicePreview = z.object({
20
70
  is_draft: z.boolean().optional(),
@@ -22,84 +72,17 @@ const CompleteAdvanceInvoicePreview = z.object({
22
72
  .string()
23
73
  .regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?)?$/)
24
74
  .optional(),
25
- issuer: z
26
- .object({
27
- name: z.union([z.string(), z.null()]),
28
- email: z.union([z.string(), z.null()]),
29
- address: z.union([z.string(), z.null()]),
30
- address_2: z.union([z.string(), z.null()]),
31
- post_code: z.union([z.string(), z.null()]),
32
- city: z.union([z.string(), z.null()]),
33
- state: z.union([z.string(), z.null()]),
34
- country: z.union([z.string(), z.null()]),
35
- country_code: z.union([z.string(), z.null()]),
36
- tax_number: z.union([z.string(), z.null()]),
37
- tax_number_2: z.union([z.string(), z.null()]),
38
- company_number: z.union([z.string(), z.null()]),
39
- bank_account: z.union([
40
- z
41
- .object({
42
- type: z
43
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
44
- .default("iban"),
45
- name: z.string(),
46
- bank_name: z.string(),
47
- iban: z.string(),
48
- account_number: z.string(),
49
- bic: z.string(),
50
- routing_number: z.string(),
51
- sort_code: z.string(),
52
- })
53
- .partial()
54
- .passthrough(),
55
- z.null(),
56
- ]),
57
- })
58
- .partial()
59
- .passthrough()
60
- .optional(),
75
+ issuer: DocumentEntity.optional(),
61
76
  customer_id: z.union([z.string(), z.null()]).optional(),
62
- customer: z
63
- .union([
77
+ customer: DocumentEntity.and(
78
+ z.union([
64
79
  z
65
- .object({
66
- name: z.union([z.string(), z.null()]),
67
- email: z.union([z.string(), z.null()]),
68
- address: z.union([z.string(), z.null()]),
69
- address_2: z.union([z.string(), z.null()]),
70
- post_code: z.union([z.string(), z.null()]),
71
- city: z.union([z.string(), z.null()]),
72
- state: z.union([z.string(), z.null()]),
73
- country: z.union([z.string(), z.null()]),
74
- country_code: z.union([z.string(), z.null()]),
75
- tax_number: z.union([z.string(), z.null()]),
76
- tax_number_2: z.union([z.string(), z.null()]),
77
- company_number: z.union([z.string(), z.null()]),
78
- bank_account: z.union([
79
- z
80
- .object({
81
- type: z
82
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
83
- .default("iban"),
84
- name: z.string(),
85
- bank_name: z.string(),
86
- iban: z.string(),
87
- account_number: z.string(),
88
- bic: z.string(),
89
- routing_number: z.string(),
90
- sort_code: z.string(),
91
- })
92
- .partial()
93
- .passthrough(),
94
- z.null(),
95
- ]),
96
- save_customer: z.boolean().default(true),
97
- })
80
+ .object({ save_customer: z.boolean().default(true) })
98
81
  .partial()
99
82
  .passthrough(),
100
83
  z.null(),
101
84
  ])
102
- .optional(),
85
+ ).optional(),
103
86
  note: z.union([z.string(), z.null()]).optional(),
104
87
  tax_clause: z.union([z.string(), z.null()]).optional(),
105
88
  currency_code: z.string().max(3).optional(),
@@ -116,19 +99,7 @@ const CompleteAdvanceInvoicePreview = z.object({
116
99
  gross_price: z.number().optional(),
117
100
  quantity: z.number().gte(-140737488355328).lte(140737488355327),
118
101
  unit: z.union([z.string(), z.null()]).optional(),
119
- taxes: z
120
- .array(
121
- z
122
- .object({
123
- rate: z.number(),
124
- tax_id: z.string(),
125
- classification: z.string(),
126
- reverse_charge: z.boolean(),
127
- amount: z.number(),
128
- })
129
- .partial()
130
- )
131
- .optional(),
102
+ taxes: z.array(DocumentItemTax).optional(),
132
103
  discounts: z.array(LineDiscount).max(5).optional(),
133
104
  metadata: z
134
105
  .union([
@@ -188,84 +159,17 @@ const PartialAdvanceInvoicePreview = z.object({
188
159
  .string()
189
160
  .regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?)?$/)
190
161
  .optional(),
191
- issuer: z
192
- .object({
193
- name: z.union([z.string(), z.null()]),
194
- email: z.union([z.string(), z.null()]),
195
- address: z.union([z.string(), z.null()]),
196
- address_2: z.union([z.string(), z.null()]),
197
- post_code: z.union([z.string(), z.null()]),
198
- city: z.union([z.string(), z.null()]),
199
- state: z.union([z.string(), z.null()]),
200
- country: z.union([z.string(), z.null()]),
201
- country_code: z.union([z.string(), z.null()]),
202
- tax_number: z.union([z.string(), z.null()]),
203
- tax_number_2: z.union([z.string(), z.null()]),
204
- company_number: z.union([z.string(), z.null()]),
205
- bank_account: z.union([
206
- z
207
- .object({
208
- type: z
209
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
210
- .default("iban"),
211
- name: z.string(),
212
- bank_name: z.string(),
213
- iban: z.string(),
214
- account_number: z.string(),
215
- bic: z.string(),
216
- routing_number: z.string(),
217
- sort_code: z.string(),
218
- })
219
- .partial()
220
- .passthrough(),
221
- z.null(),
222
- ]),
223
- })
224
- .partial()
225
- .passthrough()
226
- .optional(),
162
+ issuer: DocumentEntity.optional(),
227
163
  customer_id: z.union([z.string(), z.null()]).optional(),
228
- customer: z
229
- .union([
164
+ customer: DocumentEntity.and(
165
+ z.union([
230
166
  z
231
- .object({
232
- name: z.union([z.string(), z.null()]),
233
- email: z.union([z.string(), z.null()]),
234
- address: z.union([z.string(), z.null()]),
235
- address_2: z.union([z.string(), z.null()]),
236
- post_code: z.union([z.string(), z.null()]),
237
- city: z.union([z.string(), z.null()]),
238
- state: z.union([z.string(), z.null()]),
239
- country: z.union([z.string(), z.null()]),
240
- country_code: z.union([z.string(), z.null()]),
241
- tax_number: z.union([z.string(), z.null()]),
242
- tax_number_2: z.union([z.string(), z.null()]),
243
- company_number: z.union([z.string(), z.null()]),
244
- bank_account: z.union([
245
- z
246
- .object({
247
- type: z
248
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
249
- .default("iban"),
250
- name: z.string(),
251
- bank_name: z.string(),
252
- iban: z.string(),
253
- account_number: z.string(),
254
- bic: z.string(),
255
- routing_number: z.string(),
256
- sort_code: z.string(),
257
- })
258
- .partial()
259
- .passthrough(),
260
- z.null(),
261
- ]),
262
- save_customer: z.boolean().default(true),
263
- })
167
+ .object({ save_customer: z.boolean().default(true) })
264
168
  .partial()
265
169
  .passthrough(),
266
170
  z.null(),
267
171
  ])
268
- .optional(),
172
+ ).optional(),
269
173
  note: z.union([z.string(), z.null()]).optional(),
270
174
  tax_clause: z.union([z.string(), z.null()]).optional(),
271
175
  currency_code: z.string().max(3).optional(),