@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.
@@ -15,6 +15,56 @@ const LineDiscount = z.object({
15
15
  });
16
16
 
17
17
 
18
+ // Dependency schema for renderinvoicepreview_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 renderinvoicepreview_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 renderinvoicepreview_body
19
69
  const CompleteInvoicePreview = z.object({
20
70
  is_draft: z.boolean().optional(),
@@ -22,84 +72,17 @@ const CompleteInvoicePreview = 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
  payment_terms: z.union([z.string(), z.null()]).optional(),
105
88
  tax_clause: z.union([z.string(), z.null()]).optional(),
@@ -117,19 +100,7 @@ const CompleteInvoicePreview = z.object({
117
100
  gross_price: z.number().optional(),
118
101
  quantity: z.number().gte(-140737488355328).lte(140737488355327),
119
102
  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(),
103
+ taxes: z.array(DocumentItemTax).optional(),
133
104
  discounts: z.array(LineDiscount).max(5).optional(),
134
105
  metadata: z
135
106
  .union([
@@ -189,84 +160,17 @@ const PartialInvoicePreview = z.object({
189
160
  .string()
190
161
  .regex(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?)?$/)
191
162
  .optional(),
192
- issuer: z
193
- .object({
194
- name: z.union([z.string(), z.null()]),
195
- email: z.union([z.string(), z.null()]),
196
- address: z.union([z.string(), z.null()]),
197
- address_2: z.union([z.string(), z.null()]),
198
- post_code: z.union([z.string(), z.null()]),
199
- city: z.union([z.string(), z.null()]),
200
- state: z.union([z.string(), z.null()]),
201
- country: z.union([z.string(), z.null()]),
202
- country_code: z.union([z.string(), z.null()]),
203
- tax_number: z.union([z.string(), z.null()]),
204
- tax_number_2: z.union([z.string(), z.null()]),
205
- company_number: z.union([z.string(), z.null()]),
206
- bank_account: z.union([
207
- z
208
- .object({
209
- type: z
210
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
211
- .default("iban"),
212
- name: z.string(),
213
- bank_name: z.string(),
214
- iban: z.string(),
215
- account_number: z.string(),
216
- bic: z.string(),
217
- routing_number: z.string(),
218
- sort_code: z.string(),
219
- })
220
- .partial()
221
- .passthrough(),
222
- z.null(),
223
- ]),
224
- })
225
- .partial()
226
- .passthrough()
227
- .optional(),
163
+ issuer: DocumentEntity.optional(),
228
164
  customer_id: z.union([z.string(), z.null()]).optional(),
229
- customer: z
230
- .union([
165
+ customer: DocumentEntity.and(
166
+ z.union([
231
167
  z
232
- .object({
233
- name: z.union([z.string(), z.null()]),
234
- email: z.union([z.string(), z.null()]),
235
- address: z.union([z.string(), z.null()]),
236
- address_2: z.union([z.string(), z.null()]),
237
- post_code: z.union([z.string(), z.null()]),
238
- city: z.union([z.string(), z.null()]),
239
- state: z.union([z.string(), z.null()]),
240
- country: z.union([z.string(), z.null()]),
241
- country_code: z.union([z.string(), z.null()]),
242
- tax_number: z.union([z.string(), z.null()]),
243
- tax_number_2: z.union([z.string(), z.null()]),
244
- company_number: z.union([z.string(), z.null()]),
245
- bank_account: z.union([
246
- z
247
- .object({
248
- type: z
249
- .enum(["iban", "us_domestic", "uk_domestic", "other"])
250
- .default("iban"),
251
- name: z.string(),
252
- bank_name: z.string(),
253
- iban: z.string(),
254
- account_number: z.string(),
255
- bic: z.string(),
256
- routing_number: z.string(),
257
- sort_code: z.string(),
258
- })
259
- .partial()
260
- .passthrough(),
261
- z.null(),
262
- ]),
263
- save_customer: z.boolean().default(true),
264
- })
168
+ .object({ save_customer: z.boolean().default(true) })
265
169
  .partial()
266
170
  .passthrough(),
267
171
  z.null(),
268
172
  ])
269
- .optional(),
173
+ ).optional(),
270
174
  note: z.union([z.string(), z.null()]).optional(),
271
175
  payment_terms: z.union([z.string(), z.null()]).optional(),
272
176
  tax_clause: z.union([z.string(), z.null()]).optional(),