@frogbotai/piece-xero 0.29.0 → 0.31.0

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.
package/dist/actions.js CHANGED
@@ -1,9 +1,18 @@
1
+ import { findPieceFile } from 'frogbot/pieces';
1
2
  import { z } from 'zod';
2
3
  import { xeroResponse } from './client.js';
3
4
  import { defineAction } from './define.js';
4
- const tenant = { tenantId: z.string().min(1).meta({ label: 'Organization' }) };
5
+ const tenant = {
6
+ tenantId: z.string().min(1).meta({
7
+ label: 'Organization'
8
+ })
9
+ };
5
10
  const date = z.string().regex(/^\d{4}-\d{2}-\d{2}$/);
6
- const lineAmountType = z.enum(['Exclusive', 'Inclusive', 'NoTax']);
11
+ const lineAmountType = z.enum([
12
+ 'Exclusive',
13
+ 'Inclusive',
14
+ 'NoTax'
15
+ ]);
7
16
  const lineItem = z.object({
8
17
  Description: z.string().min(1),
9
18
  Quantity: z.number().optional(),
@@ -12,25 +21,36 @@ const lineItem = z.object({
12
21
  ItemCode: z.string().optional(),
13
22
  TaxType: z.string().optional(),
14
23
  DiscountRate: z.number().optional(),
15
- LineItemID: z.string().optional(),
24
+ LineItemID: z.string().optional()
16
25
  });
17
- async function tenantOptions({ client, req, }) {
26
+ async function tenantOptions({ client, req }) {
18
27
  const tenants = await client.listTenants(req.signal ?? undefined);
19
- return tenants.map(({ tenantId, tenantName }) => ({ label: tenantName, value: tenantId }));
28
+ return tenants.map(({ tenantId, tenantName })=>({
29
+ label: tenantName,
30
+ value: tenantId
31
+ }));
20
32
  }
21
33
  const apiDefaults = {
22
34
  output: xeroResponse,
23
35
  idempotent: false,
24
- options: { tenantId: tenantOptions },
36
+ options: {
37
+ tenantId: tenantOptions
38
+ }
25
39
  };
26
40
  function accountingRequest(client, input, path, method, body, signal) {
27
- return client.request({ path, method, tenantId: input.tenantId, body, signal }, xeroResponse);
41
+ return client.request({
42
+ path,
43
+ method,
44
+ tenantId: input.tenantId,
45
+ body,
46
+ signal
47
+ }, xeroResponse);
28
48
  }
29
49
  const createOrUpdateContactInput = z.object({
30
50
  ...tenant,
31
51
  contactId: z.string().optional(),
32
52
  name: z.string().min(1),
33
- email: z.string().email().optional(),
53
+ email: z.string().email().optional()
34
54
  });
35
55
  const createOrUpdateContact = defineAction({
36
56
  ...apiDefaults,
@@ -38,9 +58,16 @@ const createOrUpdateContact = defineAction({
38
58
  label: 'Create or update contact',
39
59
  description: 'Create a Xero contact or update one by ID.',
40
60
  input: createOrUpdateContactInput,
41
- async run({ input, client, req }) {
42
- return accountingRequest(client, input, `/Contacts${input.contactId ? `/${input.contactId}` : ''}`, 'POST', { Contacts: [{ Name: input.name, EmailAddress: input.email }] }, req.signal ?? undefined);
43
- },
61
+ async run ({ input, client, req }) {
62
+ return accountingRequest(client, input, `/Contacts${input.contactId ? `/${input.contactId}` : ''}`, 'POST', {
63
+ Contacts: [
64
+ {
65
+ Name: input.name,
66
+ EmailAddress: input.email
67
+ }
68
+ ]
69
+ }, req.signal ?? undefined);
70
+ }
44
71
  });
45
72
  const createOrUpdateInvoiceInput = z.object({
46
73
  ...tenant,
@@ -52,7 +79,13 @@ const createOrUpdateInvoiceInput = z.object({
52
79
  date: date.optional(),
53
80
  dueDate: date,
54
81
  reference: z.string().optional(),
55
- status: z.enum(['DRAFT', 'SUBMITTED', 'AUTHORISED', 'DELETED', 'VOIDED']),
82
+ status: z.enum([
83
+ 'DRAFT',
84
+ 'SUBMITTED',
85
+ 'AUTHORISED',
86
+ 'DELETED',
87
+ 'VOIDED'
88
+ ])
56
89
  });
57
90
  const createOrUpdateInvoice = defineAction({
58
91
  ...apiDefaults,
@@ -60,28 +93,34 @@ const createOrUpdateInvoice = defineAction({
60
93
  label: 'Create or update invoice',
61
94
  description: 'Create or update an accounts-receivable invoice.',
62
95
  input: createOrUpdateInvoiceInput,
63
- async run({ input, client, req }) {
96
+ async run ({ input, client, req }) {
64
97
  return accountingRequest(client, input, `/Invoices${input.invoiceId ? `/${input.invoiceId}` : ''}`, 'POST', {
65
98
  Invoices: [
66
99
  {
67
100
  Type: 'ACCREC',
68
- Contact: { ContactID: input.contactId, Name: input.name, EmailAddress: input.email },
69
- LineItems: [input.lineItem],
101
+ Contact: {
102
+ ContactID: input.contactId,
103
+ Name: input.name,
104
+ EmailAddress: input.email
105
+ },
106
+ LineItems: [
107
+ input.lineItem
108
+ ],
70
109
  Date: input.date,
71
110
  DueDate: input.dueDate,
72
111
  Reference: input.reference,
73
- Status: input.status,
74
- },
75
- ],
112
+ Status: input.status
113
+ }
114
+ ]
76
115
  }, req.signal ?? undefined);
77
- },
116
+ }
78
117
  });
79
118
  const allocateCreditNoteInput = z.object({
80
119
  ...tenant,
81
120
  creditNoteId: z.string().min(1),
82
121
  invoiceId: z.string().min(1),
83
122
  amount: z.number(),
84
- date: date.optional(),
123
+ date: date.optional()
85
124
  });
86
125
  const allocateCreditNote = defineAction({
87
126
  ...apiDefaults,
@@ -89,13 +128,19 @@ const allocateCreditNote = defineAction({
89
128
  label: 'Allocate credit note',
90
129
  description: 'Allocate a credit note to an invoice.',
91
130
  input: allocateCreditNoteInput,
92
- async run({ input, client, req }) {
131
+ async run ({ input, client, req }) {
93
132
  return accountingRequest(client, input, `/CreditNotes/${input.creditNoteId}/Allocations`, 'POST', {
94
133
  Allocations: [
95
- { Invoice: { InvoiceID: input.invoiceId }, Amount: input.amount, Date: input.date },
96
- ],
134
+ {
135
+ Invoice: {
136
+ InvoiceID: input.invoiceId
137
+ },
138
+ Amount: input.amount,
139
+ Date: input.date
140
+ }
141
+ ]
97
142
  }, req.signal ?? undefined);
98
- },
143
+ }
99
144
  });
100
145
  const createBankTransferInput = z.object({
101
146
  ...tenant,
@@ -105,7 +150,7 @@ const createBankTransferInput = z.object({
105
150
  date: date.optional(),
106
151
  reference: z.string().optional(),
107
152
  fromIsReconciled: z.boolean().default(false),
108
- toIsReconciled: z.boolean().default(false),
153
+ toIsReconciled: z.boolean().default(false)
109
154
  });
110
155
  const createBankTransfer = defineAction({
111
156
  ...apiDefaults,
@@ -113,21 +158,25 @@ const createBankTransfer = defineAction({
113
158
  label: 'Create bank transfer',
114
159
  description: 'Transfer between bank accounts.',
115
160
  input: createBankTransferInput,
116
- async run({ input, client, req }) {
161
+ async run ({ input, client, req }) {
117
162
  return accountingRequest(client, input, '/BankTransfers', 'PUT', {
118
163
  BankTransfers: [
119
164
  {
120
- FromBankAccount: { AccountID: input.fromBankAccountId },
121
- ToBankAccount: { AccountID: input.toBankAccountId },
165
+ FromBankAccount: {
166
+ AccountID: input.fromBankAccountId
167
+ },
168
+ ToBankAccount: {
169
+ AccountID: input.toBankAccountId
170
+ },
122
171
  Amount: input.amount,
123
172
  Date: input.date,
124
173
  Reference: input.reference,
125
174
  FromIsReconciled: input.fromIsReconciled || undefined,
126
- ToIsReconciled: input.toIsReconciled || undefined,
127
- },
128
- ],
175
+ ToIsReconciled: input.toIsReconciled || undefined
176
+ }
177
+ ]
129
178
  }, req.signal ?? undefined);
130
- },
179
+ }
131
180
  });
132
181
  const createQuoteInput = z.object({
133
182
  ...tenant,
@@ -141,7 +190,7 @@ const createQuoteInput = z.object({
141
190
  title: z.string().optional(),
142
191
  summary: z.string().optional(),
143
192
  terms: z.string().optional(),
144
- status: z.literal('DRAFT').default('DRAFT'),
193
+ status: z.literal('DRAFT').default('DRAFT')
145
194
  });
146
195
  const createQuote = defineAction({
147
196
  ...apiDefaults,
@@ -149,42 +198,53 @@ const createQuote = defineAction({
149
198
  label: 'Create quote',
150
199
  description: 'Create a draft quote.',
151
200
  input: createQuoteInput,
152
- async run({ input, client, req }) {
201
+ async run ({ input, client, req }) {
153
202
  return accountingRequest(client, input, '/Quotes', 'POST', {
154
203
  Quotes: [
155
204
  {
156
- Contact: { ContactID: input.contactId },
205
+ Contact: {
206
+ ContactID: input.contactId
207
+ },
157
208
  Date: input.date,
158
209
  ExpiryDate: input.expiryDate,
159
- LineItems: [input.lineItem],
210
+ LineItems: [
211
+ input.lineItem
212
+ ],
160
213
  LineAmountTypes: input.lineAmountTypes,
161
214
  Reference: input.reference,
162
215
  QuoteNumber: input.quoteNumber,
163
216
  Title: input.title,
164
217
  Summary: input.summary,
165
218
  Terms: input.terms,
166
- Status: input.status,
167
- },
168
- ],
219
+ Status: input.status
220
+ }
221
+ ]
169
222
  }, req.signal ?? undefined);
170
- },
223
+ }
224
+ });
225
+ const sendInvoiceEmailInput = z.object({
226
+ ...tenant,
227
+ invoiceId: z.string().min(1)
171
228
  });
172
- const sendInvoiceEmailInput = z.object({ ...tenant, invoiceId: z.string().min(1) });
173
229
  const sendInvoiceEmail = defineAction({
174
230
  slug: 'sendInvoiceEmail',
175
231
  label: 'Send invoice email',
176
232
  description: 'Send a sales invoice by email.',
177
233
  input: sendInvoiceEmailInput,
178
- output: z.object({ success: z.literal(true) }),
179
- async run({ input, client, req }) {
234
+ output: z.object({
235
+ success: z.literal(true)
236
+ }),
237
+ async run ({ input, client, req }) {
180
238
  await client.request({
181
239
  path: `/Invoices/${input.invoiceId}/Email`,
182
240
  method: 'POST',
183
241
  tenantId: input.tenantId,
184
- signal: req.signal ?? undefined,
242
+ signal: req.signal ?? undefined
185
243
  }, z.null());
186
- return { success: true };
187
- },
244
+ return {
245
+ success: true
246
+ };
247
+ }
188
248
  });
189
249
  const invoiceBase = {
190
250
  ...tenant,
@@ -194,7 +254,11 @@ const invoiceBase = {
194
254
  dueDate: date.optional(),
195
255
  lineAmountTypes: lineAmountType.optional(),
196
256
  invoiceNumber: z.string().optional(),
197
- status: z.enum(['DRAFT', 'SUBMITTED', 'AUTHORISED']).default('DRAFT'),
257
+ status: z.enum([
258
+ 'DRAFT',
259
+ 'SUBMITTED',
260
+ 'AUTHORISED'
261
+ ]).default('DRAFT')
198
262
  };
199
263
  const createBillInput = z.object(invoiceBase);
200
264
  const createBill = defineAction({
@@ -203,22 +267,26 @@ const createBill = defineAction({
203
267
  label: 'Create bill',
204
268
  description: 'Create an accounts-payable bill.',
205
269
  input: createBillInput,
206
- async run({ input, client, req }) {
270
+ async run ({ input, client, req }) {
207
271
  return accountingRequest(client, input, '/Invoices', 'POST', {
208
272
  Invoices: [
209
273
  {
210
274
  Type: 'ACCPAY',
211
- Contact: { ContactID: input.contactId },
212
- LineItems: [input.lineItem],
275
+ Contact: {
276
+ ContactID: input.contactId
277
+ },
278
+ LineItems: [
279
+ input.lineItem
280
+ ],
213
281
  Date: input.date,
214
282
  DueDate: input.dueDate,
215
283
  LineAmountTypes: input.lineAmountTypes,
216
284
  InvoiceNumber: input.invoiceNumber,
217
- Status: input.status,
218
- },
219
- ],
285
+ Status: input.status
286
+ }
287
+ ]
220
288
  }, req.signal ?? undefined);
221
- },
289
+ }
222
290
  });
223
291
  const createPaymentInput = z.object({
224
292
  ...tenant,
@@ -227,7 +295,7 @@ const createPaymentInput = z.object({
227
295
  amount: z.number(),
228
296
  date,
229
297
  reference: z.string().optional(),
230
- isReconciled: z.boolean().default(false),
298
+ isReconciled: z.boolean().default(false)
231
299
  });
232
300
  const createPayment = defineAction({
233
301
  ...apiDefaults,
@@ -235,20 +303,24 @@ const createPayment = defineAction({
235
303
  label: 'Create payment',
236
304
  description: 'Apply a payment to an invoice.',
237
305
  input: createPaymentInput,
238
- async run({ input, client, req }) {
306
+ async run ({ input, client, req }) {
239
307
  return accountingRequest(client, input, '/Payments', 'PUT', {
240
308
  Payments: [
241
309
  {
242
- Invoice: { InvoiceID: input.invoiceId },
243
- Account: { AccountID: input.accountId },
310
+ Invoice: {
311
+ InvoiceID: input.invoiceId
312
+ },
313
+ Account: {
314
+ AccountID: input.accountId
315
+ },
244
316
  Amount: input.amount,
245
317
  Date: input.date,
246
318
  Reference: input.reference,
247
- IsReconciled: input.isReconciled || undefined,
248
- },
249
- ],
319
+ IsReconciled: input.isReconciled || undefined
320
+ }
321
+ ]
250
322
  }, req.signal ?? undefined);
251
- },
323
+ }
252
324
  });
253
325
  const purchaseOrderInput = z.object({
254
326
  ...tenant,
@@ -260,12 +332,18 @@ const purchaseOrderInput = z.object({
260
332
  purchaseOrderNumber: z.string().optional(),
261
333
  reference: z.string().optional(),
262
334
  brandingThemeId: z.string().optional(),
263
- status: z.enum(['DRAFT', 'SUBMITTED', 'AUTHORISED', 'BILLED', 'DELETED']).default('DRAFT'),
335
+ status: z.enum([
336
+ 'DRAFT',
337
+ 'SUBMITTED',
338
+ 'AUTHORISED',
339
+ 'BILLED',
340
+ 'DELETED'
341
+ ]).default('DRAFT'),
264
342
  deliveryAddress: z.string().optional(),
265
343
  attentionTo: z.string().optional(),
266
344
  telephone: z.string().optional(),
267
345
  deliveryInstructions: z.string().optional(),
268
- expectedArrivalDate: date.optional(),
346
+ expectedArrivalDate: date.optional()
269
347
  });
270
348
  const createPurchaseOrder = defineAction({
271
349
  ...apiDefaults,
@@ -273,12 +351,16 @@ const createPurchaseOrder = defineAction({
273
351
  label: 'Create purchase order',
274
352
  description: 'Create a purchase order.',
275
353
  input: purchaseOrderInput,
276
- async run({ input, client, req }) {
354
+ async run ({ input, client, req }) {
277
355
  return accountingRequest(client, input, '/PurchaseOrders', 'POST', {
278
356
  PurchaseOrders: [
279
357
  {
280
- Contact: { ContactID: input.contactId },
281
- LineItems: [input.lineItem],
358
+ Contact: {
359
+ ContactID: input.contactId
360
+ },
361
+ LineItems: [
362
+ input.lineItem
363
+ ],
282
364
  Date: input.date,
283
365
  DeliveryDate: input.deliveryDate,
284
366
  LineAmountTypes: input.lineAmountTypes,
@@ -290,22 +372,28 @@ const createPurchaseOrder = defineAction({
290
372
  AttentionTo: input.attentionTo,
291
373
  Telephone: input.telephone,
292
374
  DeliveryInstructions: input.deliveryInstructions,
293
- ExpectedArrivalDate: input.expectedArrivalDate,
294
- },
295
- ],
375
+ ExpectedArrivalDate: input.expectedArrivalDate
376
+ }
377
+ ]
296
378
  }, req.signal ?? undefined);
297
- },
379
+ }
298
380
  });
299
381
  const updatePurchaseOrderInput = z.object({
300
382
  ...tenant,
301
383
  purchaseOrderId: z.string().min(1),
302
- status: z.enum(['DRAFT', 'SUBMITTED', 'AUTHORISED', 'BILLED', 'DELETED']).optional(),
384
+ status: z.enum([
385
+ 'DRAFT',
386
+ 'SUBMITTED',
387
+ 'AUTHORISED',
388
+ 'BILLED',
389
+ 'DELETED'
390
+ ]).optional(),
303
391
  sentToContact: z.boolean().default(false),
304
392
  deliveryAddress: z.string().optional(),
305
393
  attentionTo: z.string().optional(),
306
394
  telephone: z.string().optional(),
307
395
  deliveryInstructions: z.string().optional(),
308
- expectedArrivalDate: date.optional(),
396
+ expectedArrivalDate: date.optional()
309
397
  });
310
398
  const updatePurchaseOrder = defineAction({
311
399
  ...apiDefaults,
@@ -314,7 +402,7 @@ const updatePurchaseOrder = defineAction({
314
402
  description: 'Update a purchase order.',
315
403
  input: updatePurchaseOrderInput,
316
404
  idempotent: true,
317
- async run({ input, client, req }) {
405
+ async run ({ input, client, req }) {
318
406
  return accountingRequest(client, input, `/PurchaseOrders/${input.purchaseOrderId}`, 'POST', {
319
407
  PurchaseOrders: [
320
408
  {
@@ -325,11 +413,11 @@ const updatePurchaseOrder = defineAction({
325
413
  AttentionTo: input.attentionTo,
326
414
  Telephone: input.telephone,
327
415
  DeliveryInstructions: input.deliveryInstructions,
328
- ExpectedArrivalDate: input.expectedArrivalDate,
329
- },
330
- ],
416
+ ExpectedArrivalDate: input.expectedArrivalDate
417
+ }
418
+ ]
331
419
  }, req.signal ?? undefined);
332
- },
420
+ }
333
421
  });
334
422
  const uploadAttachmentInput = z.object({
335
423
  ...tenant,
@@ -344,13 +432,16 @@ const uploadAttachmentInput = z.object({
344
432
  'Accounts',
345
433
  'ManualJournals',
346
434
  'Receipts',
347
- 'RepeatingInvoices',
435
+ 'RepeatingInvoices'
348
436
  ]),
349
437
  resourceId: z.string().min(1),
350
- file: z.union([z.string(), z.number()]),
438
+ file: z.union([
439
+ z.string(),
440
+ z.number()
441
+ ]),
351
442
  fileName: z.string().min(1),
352
443
  contentType: z.string().min(1).default('application/octet-stream'),
353
- includeOnline: z.boolean().default(false),
444
+ includeOnline: z.boolean().default(false)
354
445
  });
355
446
  const uploadAttachment = defineAction({
356
447
  ...apiDefaults,
@@ -358,65 +449,60 @@ const uploadAttachment = defineAction({
358
449
  label: 'Upload attachment',
359
450
  description: 'Upload an attachment to a Xero resource.',
360
451
  input: uploadAttachmentInput,
361
- async run({ input, client, req }) {
362
- const collection = req.frogbot.config.files?.slug;
363
- if (!collection)
364
- throw new Error('FrogBot files are not configured.');
365
- const file = await req.frogbot.findByID({
366
- collection,
452
+ async run ({ input, client, req }) {
453
+ const file = await findPieceFile(req, 'Xero', {
367
454
  id: input.file,
368
455
  depth: 0,
369
456
  req,
370
- overrideAccess: false,
457
+ overrideAccess: false
371
458
  });
372
459
  const urlValue = typeof file.url === 'string' ? file.url : undefined;
373
- if (!urlValue)
374
- throw new Error('The selected file has no URL.');
460
+ if (!urlValue) throw new Error('The selected file has no URL.');
375
461
  const payloadConfig = await req.frogbot.config._internal.payloadConfig;
376
462
  const originValue = payloadConfig.serverURL || req.url;
377
- if (!originValue)
378
- throw new Error('FrogBot file requests require a server URL.');
463
+ if (!originValue) throw new Error('FrogBot file requests require a server URL.');
379
464
  const origin = new URL(originValue);
380
465
  const url = new URL(urlValue, origin);
381
- if (!['http:', 'https:'].includes(origin.protocol) ||
382
- origin.username ||
383
- origin.password ||
384
- !['http:', 'https:'].includes(url.protocol) ||
385
- url.username ||
386
- url.password ||
387
- url.origin !== origin.origin) {
466
+ if (![
467
+ 'http:',
468
+ 'https:'
469
+ ].includes(origin.protocol) || origin.username || origin.password || ![
470
+ 'http:',
471
+ 'https:'
472
+ ].includes(url.protocol) || url.username || url.password || url.origin !== origin.origin) {
388
473
  throw new Error('The selected file URL is unsafe.');
389
474
  }
390
475
  const response = await fetch(url, {
391
476
  headers: {
392
477
  cookie: req.headers.get('cookie') ?? '',
393
- authorization: req.headers.get('authorization') ?? '',
478
+ authorization: req.headers.get('authorization') ?? ''
394
479
  },
395
480
  redirect: 'error',
396
- signal: req.signal ?? undefined,
481
+ signal: req.signal ?? undefined
397
482
  });
398
- if (!response.ok)
399
- throw new Error(`Unable to load attachment (${response.status}).`);
483
+ if (!response.ok) throw new Error(`Unable to load attachment (${response.status}).`);
400
484
  const bytes = new Uint8Array(await response.arrayBuffer());
401
- if (bytes.byteLength > 10_000_000)
402
- throw new Error('Xero attachments cannot exceed 10 MB.');
403
- const suffix = input.includeOnline && ['Invoices', 'CreditNotes'].includes(input.resourceType)
404
- ? '?IncludeOnline=true'
405
- : '';
485
+ if (bytes.byteLength > 10_000_000) throw new Error('Xero attachments cannot exceed 10 MB.');
486
+ const suffix = input.includeOnline && [
487
+ 'Invoices',
488
+ 'CreditNotes'
489
+ ].includes(input.resourceType) ? '?IncludeOnline=true' : '';
406
490
  return client.request({
407
491
  path: `/${input.resourceType}/${input.resourceId}/Attachments/${encodeURIComponent(input.fileName)}${suffix}`,
408
492
  method: 'POST',
409
493
  tenantId: input.tenantId,
410
494
  body: bytes,
411
- headers: { 'Content-Type': input.contentType },
412
- signal: req.signal ?? undefined,
495
+ headers: {
496
+ 'Content-Type': input.contentType
497
+ },
498
+ signal: req.signal ?? undefined
413
499
  }, xeroResponse);
414
- },
500
+ }
415
501
  });
416
502
  const addInvoiceItemsInput = z.object({
417
503
  ...tenant,
418
504
  invoiceId: z.string().min(1),
419
- newLineItems: z.array(lineItem).min(1),
505
+ newLineItems: z.array(lineItem).min(1)
420
506
  });
421
507
  const addInvoiceItems = defineAction({
422
508
  ...apiDefaults,
@@ -424,35 +510,47 @@ const addInvoiceItems = defineAction({
424
510
  label: 'Add invoice items',
425
511
  description: 'Append items to a sales invoice.',
426
512
  input: addInvoiceItemsInput,
427
- async run({ input, client, req }) {
513
+ async run ({ input, client, req }) {
428
514
  const current = await client.request({
429
515
  path: `/Invoices/${input.invoiceId}`,
430
516
  tenantId: input.tenantId,
431
- signal: req.signal ?? undefined,
517
+ signal: req.signal ?? undefined
432
518
  }, z.object({
433
- Invoices: z
434
- .array(z.object({ LineItems: z.array(lineItem.passthrough()).default([]) }))
435
- .min(1),
519
+ Invoices: z.array(z.object({
520
+ LineItems: z.array(lineItem.passthrough()).default([])
521
+ })).min(1)
436
522
  }));
437
523
  return accountingRequest(client, input, `/Invoices/${input.invoiceId}`, 'POST', {
438
524
  Invoices: [
439
- { Type: 'ACCREC', LineItems: [...current.Invoices[0].LineItems, ...input.newLineItems] },
440
- ],
525
+ {
526
+ Type: 'ACCREC',
527
+ LineItems: [
528
+ ...current.Invoices[0].LineItems,
529
+ ...input.newLineItems
530
+ ]
531
+ }
532
+ ]
441
533
  }, req.signal ?? undefined);
442
- },
534
+ }
443
535
  });
444
536
  const createCreditNoteInput = z.object({
445
537
  ...tenant,
446
- type: z.enum(['ACCRECCREDIT', 'ACCPAYCREDIT']).default('ACCRECCREDIT'),
538
+ type: z.enum([
539
+ 'ACCRECCREDIT',
540
+ 'ACCPAYCREDIT'
541
+ ]).default('ACCRECCREDIT'),
447
542
  contactId: z.string().min(1),
448
543
  date: date.optional(),
449
- status: z.enum(['DRAFT', 'AUTHORISED']).default('DRAFT'),
544
+ status: z.enum([
545
+ 'DRAFT',
546
+ 'AUTHORISED'
547
+ ]).default('DRAFT'),
450
548
  lineAmountTypes: lineAmountType.optional(),
451
549
  creditNoteNumber: z.string().optional(),
452
550
  reference: z.string().optional(),
453
551
  currencyCode: z.string().optional(),
454
552
  brandingThemeId: z.string().optional(),
455
- lineItems: z.array(lineItem).optional(),
553
+ lineItems: z.array(lineItem).optional()
456
554
  });
457
555
  const createCreditNote = defineAction({
458
556
  ...apiDefaults,
@@ -460,12 +558,14 @@ const createCreditNote = defineAction({
460
558
  label: 'Create credit note',
461
559
  description: 'Create a credit note.',
462
560
  input: createCreditNoteInput,
463
- async run({ input, client, req }) {
561
+ async run ({ input, client, req }) {
464
562
  return accountingRequest(client, input, '/CreditNotes', 'POST', {
465
563
  CreditNotes: [
466
564
  {
467
565
  Type: input.type,
468
- Contact: { ContactID: input.contactId },
566
+ Contact: {
567
+ ContactID: input.contactId
568
+ },
469
569
  Date: input.date,
470
570
  Status: input.status,
471
571
  LineAmountTypes: input.lineAmountTypes,
@@ -473,11 +573,11 @@ const createCreditNote = defineAction({
473
573
  Reference: input.type === 'ACCRECCREDIT' ? input.reference : undefined,
474
574
  CurrencyCode: input.currencyCode,
475
575
  BrandingThemeID: input.brandingThemeId,
476
- LineItems: input.lineItems,
477
- },
478
- ],
576
+ LineItems: input.lineItems
577
+ }
578
+ ]
479
579
  }, req.signal ?? undefined);
480
- },
580
+ }
481
581
  });
482
582
  const createItemInput = z.object({
483
583
  ...tenant,
@@ -487,12 +587,16 @@ const createItemInput = z.object({
487
587
  purchaseDescription: z.string().optional(),
488
588
  isSold: z.boolean().default(true),
489
589
  isPurchased: z.boolean().default(true),
490
- salesDetails: z.object({ UnitPrice: z.number() }).optional(),
491
- purchaseDetails: z.object({ UnitPrice: z.number() }).optional(),
590
+ salesDetails: z.object({
591
+ UnitPrice: z.number()
592
+ }).optional(),
593
+ purchaseDetails: z.object({
594
+ UnitPrice: z.number()
595
+ }).optional(),
492
596
  salesAccountId: z.string().optional(),
493
597
  purchaseAccountId: z.string().optional(),
494
598
  cogsAccountId: z.string().optional(),
495
- inventoryAssetAccountId: z.string().optional(),
599
+ inventoryAssetAccountId: z.string().optional()
496
600
  });
497
601
  const createItem = defineAction({
498
602
  ...apiDefaults,
@@ -500,7 +604,7 @@ const createItem = defineAction({
500
604
  label: 'Create inventory item',
501
605
  description: 'Create an inventory item.',
502
606
  input: createItemInput,
503
- async run({ input, client, req }) {
607
+ async run ({ input, client, req }) {
504
608
  return accountingRequest(client, input, '/Items', 'POST', {
505
609
  Code: input.code,
506
610
  Name: input.name,
@@ -508,26 +612,25 @@ const createItem = defineAction({
508
612
  PurchaseDescription: input.purchaseDescription,
509
613
  IsSold: input.isSold,
510
614
  IsPurchased: input.isPurchased,
511
- SalesDetails: input.salesDetails || input.salesAccountId
512
- ? { ...input.salesDetails, AccountID: input.salesAccountId }
513
- : undefined,
514
- PurchaseDetails: input.purchaseDetails || input.purchaseAccountId || input.cogsAccountId
515
- ? {
516
- ...input.purchaseDetails,
517
- AccountID: input.purchaseAccountId,
518
- COGSAccountID: input.cogsAccountId,
519
- }
520
- : undefined,
521
- InventoryAssetAccountID: input.inventoryAssetAccountId,
615
+ SalesDetails: input.salesDetails || input.salesAccountId ? {
616
+ ...input.salesDetails,
617
+ AccountID: input.salesAccountId
618
+ } : undefined,
619
+ PurchaseDetails: input.purchaseDetails || input.purchaseAccountId || input.cogsAccountId ? {
620
+ ...input.purchaseDetails,
621
+ AccountID: input.purchaseAccountId,
622
+ COGSAccountID: input.cogsAccountId
623
+ } : undefined,
624
+ InventoryAssetAccountID: input.inventoryAssetAccountId
522
625
  }, req.signal ?? undefined);
523
- },
626
+ }
524
627
  });
525
628
  const createProjectInput = z.object({
526
629
  ...tenant,
527
630
  contactId: z.string().min(1),
528
631
  name: z.string().min(1),
529
632
  deadlineUtc: z.string().datetime().optional(),
530
- estimateAmount: z.number().optional(),
633
+ estimateAmount: z.number().optional()
531
634
  });
532
635
  const createProject = defineAction({
533
636
  ...apiDefaults,
@@ -535,7 +638,7 @@ const createProject = defineAction({
535
638
  label: 'Create project',
536
639
  description: 'Create a Xero project.',
537
640
  input: createProjectInput,
538
- async run({ input, client, req }) {
641
+ async run ({ input, client, req }) {
539
642
  return client.request({
540
643
  base: 'projects',
541
644
  path: '/Projects',
@@ -545,11 +648,11 @@ const createProject = defineAction({
545
648
  contactId: input.contactId,
546
649
  name: input.name,
547
650
  deadlineUtc: input.deadlineUtc,
548
- estimateAmount: input.estimateAmount,
651
+ estimateAmount: input.estimateAmount
549
652
  },
550
- signal: req.signal ?? undefined,
653
+ signal: req.signal ?? undefined
551
654
  }, xeroResponse);
552
- },
655
+ }
553
656
  });
554
657
  const updateInvoiceInput = z.object({
555
658
  ...tenant,
@@ -560,10 +663,16 @@ const updateInvoiceInput = z.object({
560
663
  brandingThemeId: z.string().optional(),
561
664
  url: z.string().url().optional(),
562
665
  contactId: z.string().optional(),
563
- status: z.enum(['DRAFT', 'SUBMITTED', 'AUTHORISED', 'VOIDED', 'DELETED']).optional(),
666
+ status: z.enum([
667
+ 'DRAFT',
668
+ 'SUBMITTED',
669
+ 'AUTHORISED',
670
+ 'VOIDED',
671
+ 'DELETED'
672
+ ]).optional(),
564
673
  sentToContact: z.boolean().default(false),
565
674
  replaceAllLineItems: z.boolean().default(false),
566
- lineItems: z.array(lineItem).optional(),
675
+ lineItems: z.array(lineItem).optional()
567
676
  });
568
677
  const updateInvoice = defineAction({
569
678
  ...apiDefaults,
@@ -572,27 +681,35 @@ const updateInvoice = defineAction({
572
681
  description: 'Update a sales invoice.',
573
682
  input: updateInvoiceInput,
574
683
  idempotent: true,
575
- async run({ input, client, req }) {
684
+ async run ({ input, client, req }) {
576
685
  let lineItems = input.lineItems;
577
686
  if (lineItems?.length && !input.replaceAllLineItems) {
578
687
  const current = await client.request({
579
688
  path: `/Invoices/${input.invoiceId}`,
580
689
  tenantId: input.tenantId,
581
- signal: req.signal ?? undefined,
690
+ signal: req.signal ?? undefined
582
691
  }, z.object({
583
- Invoices: z
584
- .array(z.object({ LineItems: z.array(lineItem.passthrough()).default([]) }))
585
- .min(1),
692
+ Invoices: z.array(z.object({
693
+ LineItems: z.array(lineItem.passthrough()).default([])
694
+ })).min(1)
586
695
  }));
587
- const updates = new Map(lineItems.filter((item) => item.LineItemID).map((item) => [item.LineItemID, item]));
588
- const existing = current.Invoices[0].LineItems.map((item) => {
696
+ const updates = new Map(lineItems.filter((item)=>item.LineItemID).map((item)=>[
697
+ item.LineItemID,
698
+ item
699
+ ]));
700
+ const existing = current.Invoices[0].LineItems.map((item)=>{
589
701
  const update = item.LineItemID ? updates.get(item.LineItemID) : undefined;
590
- if (item.LineItemID)
591
- updates.delete(item.LineItemID);
592
- return update ? { ...item, ...update } : item;
702
+ if (item.LineItemID) updates.delete(item.LineItemID);
703
+ return update ? {
704
+ ...item,
705
+ ...update
706
+ } : item;
593
707
  });
594
- const additions = lineItems.filter((item) => !item.LineItemID || updates.has(item.LineItemID));
595
- lineItems = [...existing, ...additions];
708
+ const additions = lineItems.filter((item)=>!item.LineItemID || updates.has(item.LineItemID));
709
+ lineItems = [
710
+ ...existing,
711
+ ...additions
712
+ ];
596
713
  }
597
714
  return accountingRequest(client, input, `/Invoices/${input.invoiceId}`, 'POST', {
598
715
  Invoices: [
@@ -604,39 +721,47 @@ const updateInvoice = defineAction({
604
721
  InvoiceNumber: input.invoiceNumber,
605
722
  BrandingThemeID: input.brandingThemeId,
606
723
  Url: input.url,
607
- Contact: input.contactId ? { ContactID: input.contactId } : undefined,
724
+ Contact: input.contactId ? {
725
+ ContactID: input.contactId
726
+ } : undefined,
608
727
  Status: input.status,
609
728
  SentToContact: input.sentToContact,
610
- LineItems: lineItems,
611
- },
612
- ],
729
+ LineItems: lineItems
730
+ }
731
+ ]
613
732
  }, req.signal ?? undefined);
614
- },
733
+ }
615
734
  });
616
735
  const repeatingInput = z.object({
617
736
  ...tenant,
618
737
  contactId: z.string().min(1),
619
738
  schedulePeriod: z.number().int(),
620
- scheduleUnit: z.enum(['WEEKLY', 'MONTHLY']),
739
+ scheduleUnit: z.enum([
740
+ 'WEEKLY',
741
+ 'MONTHLY'
742
+ ]),
621
743
  dueDate: z.number().int(),
622
744
  dueDateType: z.enum([
623
745
  'OFCURRENTMONTH',
624
746
  'OFFOLLOWINGMONTH',
625
747
  'DAYSAFTERBILLDATE',
626
- 'DAYSAFTERBILLMONTH',
748
+ 'DAYSAFTERBILLMONTH'
627
749
  ]),
628
750
  startDate: date,
629
751
  endDate: date.optional(),
630
752
  lineAmountTypes: lineAmountType.default('Exclusive'),
631
753
  currencyCode: z.string().min(1),
632
- status: z.enum(['DRAFT', 'AUTHORISED']).default('DRAFT'),
754
+ status: z.enum([
755
+ 'DRAFT',
756
+ 'AUTHORISED'
757
+ ]).default('DRAFT'),
633
758
  reference: z.string().optional(),
634
759
  brandingThemeId: z.string().optional(),
635
760
  approvedForSending: z.boolean().default(false),
636
761
  sendCopy: z.boolean().default(false),
637
762
  markAsSent: z.boolean().default(false),
638
763
  includePdf: z.boolean().default(false),
639
- lineItems: z.array(lineItem).min(1),
764
+ lineItems: z.array(lineItem).min(1)
640
765
  });
641
766
  const createRepeatingInvoice = defineAction({
642
767
  ...apiDefaults,
@@ -644,27 +769,33 @@ const createRepeatingInvoice = defineAction({
644
769
  label: 'Create repeating invoice',
645
770
  description: 'Create a repeating sales invoice.',
646
771
  input: repeatingInput,
647
- async run({ input, client, req }) {
648
- if (input.scheduleUnit === 'WEEKLY' &&
649
- !['DAYSAFTERBILLDATE', 'OFFOLLOWINGMONTH'].includes(input.dueDateType)) {
772
+ async run ({ input, client, req }) {
773
+ if (input.scheduleUnit === 'WEEKLY' && ![
774
+ 'DAYSAFTERBILLDATE',
775
+ 'OFFOLLOWINGMONTH'
776
+ ].includes(input.dueDateType)) {
650
777
  throw new Error('Weekly schedules require DAYSAFTERBILLDATE or OFFOLLOWINGMONTH.');
651
778
  }
652
- if (input.scheduleUnit === 'MONTHLY' &&
653
- !['OFCURRENTMONTH', 'OFFOLLOWINGMONTH'].includes(input.dueDateType)) {
779
+ if (input.scheduleUnit === 'MONTHLY' && ![
780
+ 'OFCURRENTMONTH',
781
+ 'OFFOLLOWINGMONTH'
782
+ ].includes(input.dueDateType)) {
654
783
  throw new Error('Monthly schedules require OFCURRENTMONTH or OFFOLLOWINGMONTH.');
655
784
  }
656
785
  return accountingRequest(client, input, '/RepeatingInvoices', 'POST', {
657
786
  RepeatingInvoices: [
658
787
  {
659
788
  Type: 'ACCREC',
660
- Contact: { ContactID: input.contactId },
789
+ Contact: {
790
+ ContactID: input.contactId
791
+ },
661
792
  Schedule: {
662
793
  Period: input.schedulePeriod,
663
794
  Unit: input.scheduleUnit,
664
795
  DueDate: input.dueDate,
665
796
  DueDateType: input.dueDateType,
666
797
  StartDate: input.startDate,
667
- EndDate: input.endDate,
798
+ EndDate: input.endDate
668
799
  },
669
800
  LineItems: input.lineItems,
670
801
  LineAmountTypes: input.lineAmountTypes,
@@ -675,11 +806,11 @@ const createRepeatingInvoice = defineAction({
675
806
  ApprovedForSending: input.approvedForSending || undefined,
676
807
  SendCopy: input.sendCopy || undefined,
677
808
  MarkAsSent: input.markAsSent || undefined,
678
- IncludePDF: input.includePdf || undefined,
679
- },
680
- ],
809
+ IncludePDF: input.includePdf || undefined
810
+ }
811
+ ]
681
812
  }, req.signal ?? undefined);
682
- },
813
+ }
683
814
  });
684
815
  function lookupAction(slug, label, path, query) {
685
816
  return defineAction({
@@ -689,37 +820,47 @@ function lookupAction(slug, label, path, query) {
689
820
  description: label,
690
821
  input: lookupInput,
691
822
  idempotent: true,
692
- async run({ input, client, req }) {
693
- return client.request({ path, tenantId: input.tenantId, query: query(input), signal: req.signal ?? undefined }, xeroResponse);
694
- },
823
+ async run ({ input, client, req }) {
824
+ return client.request({
825
+ path,
826
+ tenantId: input.tenantId,
827
+ query: query(input),
828
+ signal: req.signal ?? undefined
829
+ }, xeroResponse);
830
+ }
695
831
  });
696
832
  }
697
833
  const lookupInput = z.object({
698
834
  ...tenant,
699
835
  searchBy: z.string().min(1),
700
836
  value: z.string().min(1),
701
- page: z.number().int().positive().optional(),
837
+ page: z.number().int().positive().optional()
702
838
  });
703
- const findContact = lookupAction('findContact', 'Find contact', '/Contacts', (input) => input.searchBy === 'SEARCH_TERM'
704
- ? { SearchTerm: input.value, page: input.page ?? 1 }
705
- : {
839
+ const findContact = lookupAction('findContact', 'Find contact', '/Contacts', (input)=>input.searchBy === 'SEARCH_TERM' ? {
840
+ SearchTerm: input.value,
841
+ page: input.page ?? 1
842
+ } : {
706
843
  where: `${input.searchBy === 'ACCOUNT_NUMBER' ? 'AccountNumber' : 'Name'}=="${input.value.replaceAll('"', '\\"')}"`,
707
- page: input.page ?? 1,
844
+ page: input.page ?? 1
708
845
  });
709
- const findInvoice = lookupAction('findInvoice', 'Find invoice', '/Invoices', (input) => input.searchBy === 'SEARCH_TERM'
710
- ? { SearchTerm: input.value, page: input.page ?? 1 }
711
- : {
846
+ const findInvoice = lookupAction('findInvoice', 'Find invoice', '/Invoices', (input)=>input.searchBy === 'SEARCH_TERM' ? {
847
+ SearchTerm: input.value,
848
+ page: input.page ?? 1
849
+ } : {
712
850
  where: `${input.searchBy === 'REFERENCE' ? 'Reference' : 'InvoiceNumber'}=="${input.value.replaceAll('"', '\\"')}"`,
713
- page: input.page ?? 1,
851
+ page: input.page ?? 1
714
852
  });
715
- const findItem = lookupAction('findItem', 'Find item', '/Items', (input) => ({
716
- where: `${input.searchBy === 'NAME' ? 'Name' : 'Code'}=="${input.value.replaceAll('"', '\\"')}"`,
717
- }));
718
- const findPurchaseOrder = lookupAction('findPurchaseOrder', 'Find purchase order', '/PurchaseOrders', (input) => ({
719
- where: `${input.searchBy === 'REFERENCE' ? 'Reference' : 'PurchaseOrderNumber'}=="${input.value.replaceAll('"', '\\"')}"`,
720
- page: String(input.page ?? 1),
721
- }));
722
- const getInvoiceHistoryInput = z.object({ ...tenant, invoiceId: z.string().min(1) });
853
+ const findItem = lookupAction('findItem', 'Find item', '/Items', (input)=>({
854
+ where: `${input.searchBy === 'NAME' ? 'Name' : 'Code'}=="${input.value.replaceAll('"', '\\"')}"`
855
+ }));
856
+ const findPurchaseOrder = lookupAction('findPurchaseOrder', 'Find purchase order', '/PurchaseOrders', (input)=>({
857
+ where: `${input.searchBy === 'REFERENCE' ? 'Reference' : 'PurchaseOrderNumber'}=="${input.value.replaceAll('"', '\\"')}"`,
858
+ page: String(input.page ?? 1)
859
+ }));
860
+ const getInvoiceHistoryInput = z.object({
861
+ ...tenant,
862
+ invoiceId: z.string().min(1)
863
+ });
723
864
  const getInvoiceHistory = defineAction({
724
865
  ...apiDefaults,
725
866
  slug: 'getInvoiceHistory',
@@ -727,24 +868,27 @@ const getInvoiceHistory = defineAction({
727
868
  description: 'Get invoice history.',
728
869
  input: getInvoiceHistoryInput,
729
870
  idempotent: true,
730
- async run({ input, client, req }) {
871
+ async run ({ input, client, req }) {
731
872
  return client.request({
732
873
  path: `/Invoices/${input.invoiceId}/History`,
733
874
  tenantId: input.tenantId,
734
- signal: req.signal ?? undefined,
875
+ signal: req.signal ?? undefined
735
876
  }, xeroResponse);
736
- },
877
+ }
737
878
  });
738
879
  const createBankTransactionInput = z.object({
739
880
  ...tenant,
740
- type: z.enum(['SPEND', 'RECEIVE']).default('SPEND'),
881
+ type: z.enum([
882
+ 'SPEND',
883
+ 'RECEIVE'
884
+ ]).default('SPEND'),
741
885
  contactId: z.string().min(1),
742
886
  bankAccountId: z.string().min(1),
743
887
  lineItem,
744
888
  date: date.optional(),
745
889
  reference: z.string().optional(),
746
890
  lineAmountTypes: lineAmountType.optional(),
747
- isReconciled: z.boolean().default(false),
891
+ isReconciled: z.boolean().default(false)
748
892
  });
749
893
  const createBankTransaction = defineAction({
750
894
  ...apiDefaults,
@@ -752,52 +896,74 @@ const createBankTransaction = defineAction({
752
896
  label: 'Create bank transaction',
753
897
  description: 'Create a spend or receive transaction.',
754
898
  input: createBankTransactionInput,
755
- async run({ input, client, req }) {
899
+ async run ({ input, client, req }) {
756
900
  return accountingRequest(client, input, '/BankTransactions', 'POST', {
757
901
  BankTransactions: [
758
902
  {
759
903
  Type: input.type,
760
- Contact: { ContactID: input.contactId },
761
- BankAccount: { AccountID: input.bankAccountId },
762
- LineItems: [input.lineItem],
904
+ Contact: {
905
+ ContactID: input.contactId
906
+ },
907
+ BankAccount: {
908
+ AccountID: input.bankAccountId
909
+ },
910
+ LineItems: [
911
+ input.lineItem
912
+ ],
763
913
  Date: input.date,
764
914
  Reference: input.reference,
765
915
  LineAmountTypes: input.lineAmountTypes,
766
- IsReconciled: input.isReconciled || undefined,
767
- },
768
- ],
916
+ IsReconciled: input.isReconciled || undefined
917
+ }
918
+ ]
769
919
  }, req.signal ?? undefined);
770
- },
920
+ }
771
921
  });
772
922
  const findOrCreateContact = defineAction({
773
923
  ...apiDefaults,
774
924
  slug: 'findOrCreateContact',
775
925
  label: 'Find or create contact',
776
926
  description: 'Find a contact by name or create it.',
777
- input: createOrUpdateContactInput.omit({ contactId: true }),
927
+ input: createOrUpdateContactInput.omit({
928
+ contactId: true
929
+ }),
778
930
  idempotent: true,
779
- async run({ input, client, req }) {
931
+ async run ({ input, client, req }) {
780
932
  const existing = await client.request({
781
933
  path: '/Contacts',
782
934
  tenantId: input.tenantId,
783
- query: { where: `Name=="${input.name.replaceAll('"', '\\"')}"` },
784
- signal: req.signal ?? undefined,
935
+ query: {
936
+ where: `Name=="${input.name.replaceAll('"', '\\"')}"`
937
+ },
938
+ signal: req.signal ?? undefined
785
939
  }, xeroResponse);
786
- if (Array.isArray(existing.Contacts) && existing.Contacts.length)
787
- return existing;
788
- return accountingRequest(client, input, '/Contacts', 'POST', { Contacts: [{ Name: input.name, EmailAddress: input.email }] }, req.signal ?? undefined);
789
- },
790
- });
791
- const customPath = z
792
- .string()
793
- .regex(/^\/(?!\/)(?!.*[%?#\\])[A-Za-z0-9._~!$&'()*+,;=:@/-]+$/)
794
- .refine((value) => value.split('/').every((segment) => segment !== '.' && segment !== '..'));
940
+ if (Array.isArray(existing.Contacts) && existing.Contacts.length) return existing;
941
+ return accountingRequest(client, input, '/Contacts', 'POST', {
942
+ Contacts: [
943
+ {
944
+ Name: input.name,
945
+ EmailAddress: input.email
946
+ }
947
+ ]
948
+ }, req.signal ?? undefined);
949
+ }
950
+ });
951
+ const customPath = z.string().regex(/^\/(?!\/)(?!.*[%?#\\])[A-Za-z0-9._~!$&'()*+,;=:@/-]+$/).refine((value)=>value.split('/').every((segment)=>segment !== '.' && segment !== '..'));
795
952
  const customApiInput = z.object({
796
953
  ...tenant,
797
- method: z.enum(['DELETE', 'GET', 'POST', 'PUT']),
954
+ method: z.enum([
955
+ 'DELETE',
956
+ 'GET',
957
+ 'POST',
958
+ 'PUT'
959
+ ]),
798
960
  path: customPath,
799
- query: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).default({}),
800
- body: z.json().optional(),
961
+ query: z.record(z.string(), z.union([
962
+ z.string(),
963
+ z.number(),
964
+ z.boolean()
965
+ ])).default({}),
966
+ body: z.json().optional()
801
967
  });
802
968
  const customApiCall = defineAction({
803
969
  ...apiDefaults,
@@ -805,16 +971,16 @@ const customApiCall = defineAction({
805
971
  label: 'Custom API call',
806
972
  description: 'Call a relative Xero accounting API path.',
807
973
  input: customApiInput,
808
- async run({ input, client, req }) {
974
+ async run ({ input, client, req }) {
809
975
  return client.request({
810
976
  path: input.path,
811
977
  method: input.method,
812
978
  tenantId: input.tenantId,
813
979
  query: input.query,
814
980
  body: input.body,
815
- signal: req.signal ?? undefined,
981
+ signal: req.signal ?? undefined
816
982
  }, xeroResponse);
817
- },
983
+ }
818
984
  });
819
985
  export const xeroActions = [
820
986
  createOrUpdateContact,
@@ -841,6 +1007,7 @@ export const xeroActions = [
841
1007
  getInvoiceHistory,
842
1008
  createBankTransaction,
843
1009
  findOrCreateContact,
844
- customApiCall,
1010
+ customApiCall
845
1011
  ];
1012
+
846
1013
  //# sourceMappingURL=actions.js.map