@frogbotai/piece-xero 0.22.0 → 0.24.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/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # `@frogbotai/piece-xero`
2
+
3
+ Native Xero accounting actions and event triggers for FrogBot.
4
+
5
+ ## Usage
6
+
7
+ ```ts
8
+ import { createXero } from '@frogbotai/piece-xero';
9
+
10
+ export const xero = createXero({
11
+ oauth: {
12
+ clientId: process.env.XERO_CLIENT_ID!,
13
+ clientSecret: process.env.XERO_CLIENT_SECRET!,
14
+ },
15
+ });
16
+ ```
17
+
18
+ Xero rotates refresh tokens. FrogBot stores the replacement `refresh_token` returned by each OAuth refresh and maps it back to `refreshToken`. Account identity comes from Xero OpenID Connect user info. Every accounting request requires an explicit organization (`tenantId`) and sends it as `Xero-Tenant-Id`.
19
+
20
+ ## Actions
21
+
22
+ | Upstream action slug | Previous wrapper export | Native action | Notes |
23
+ | -------------------------------------- | --------------------------------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
24
+ | `xero_create_contact` | `xeroCreateContact` | `createOrUpdateContact` | |
25
+ | `xero_create_invoice` | `xeroCreateInvoice` | `createOrUpdateInvoice` | |
26
+ | `xero_allocate_credit_note_to_invoice` | `xeroAllocateCreditNoteToInvoice` | `allocateCreditNote` | |
27
+ | `xero_create_bank_transfer` | `xeroCreateBankTransfer` | `createBankTransfer` | |
28
+ | `xero_create_quote_draft` | `xeroCreateQuoteDraft` | `createQuote` | Draft only. |
29
+ | `xero_send_invoice_email` | `xeroSendInvoiceEmail` | `sendInvoiceEmail` | |
30
+ | `xero_create_bill` | `xeroCreateBill` | `createBill` | |
31
+ | `xero_create_payment` | `xeroCreatePayment` | `createPayment` | |
32
+ | `xero_create_purchase_order` | `xeroCreatePurchaseOrder` | `createPurchaseOrder` | |
33
+ | `xero_update_purchase_order` | `xeroUpdatePurchaseOrder` | `updatePurchaseOrder` | |
34
+ | `xero_upload_attachment` | `xeroUploadAttachment` | `uploadAttachment` | Reads an access-controlled FrogBot file; rejects redirects, cross-origin URLs, credentials, non-HTTPS URLs, and files over 10 MB. |
35
+ | `xero_add_items_to_sales_invoice` | `xeroAddItemsToSalesInvoice` | `addInvoiceItems` | |
36
+ | `xero_create_credit_note` | `xeroCreateCreditNote` | `createCreditNote` | |
37
+ | `xero_create_inventory_item` | `xeroCreateInventoryItem` | `createItem` | |
38
+ | `xero_create_project` | `xeroCreateProject` | `createProject` | |
39
+ | `xero_update_sales_invoice` | `xeroUpdateSalesInvoice` | `updateInvoice` | |
40
+ | `xero_create_repeating_sales_invoice` | `xeroCreateRepeatingSalesInvoice` | `createRepeatingInvoice` | |
41
+ | `xero_find_contact` | `xeroFindContact` | `findContact` | |
42
+ | `xero_find_invoice` | `xeroFindInvoice` | `findInvoice` | |
43
+ | `xero_find_item` | `xeroFindItem` | `findItem` | |
44
+ | `xero_find_purchase_order` | `xeroFindPurchaseOrder` | `findPurchaseOrder` | |
45
+ | `xero_get_invoice_history` | `xeroGetInvoiceHistory` | `getInvoiceHistory` | |
46
+ | `xero_create_bank_transaction` | `xeroCreateBankTransaction` | `createBankTransaction` | |
47
+ | `xero_find_or_create_contact` | `xeroFindOrCreateContact` | `findOrCreateContact` | |
48
+ | `custom_api_call` | `customApiCall` | `customApiCall` | Relative accounting API paths only; OAuth authorization and tenant headers cannot be overridden. |
49
+
50
+ ## Triggers
51
+
52
+ | Upstream trigger slug | Native trigger | Type | Notes |
53
+ | ----------------------------- | ------------------------- | --------- | ------------------------------------------------------ |
54
+ | `xero_new_contact` | `contactCreated` | `app` | Shares the app-level Xero webhook. |
55
+ | `xero_new_or_updated_contact` | `contactCreatedOrUpdated` | `app` | Shares the app-level Xero webhook. |
56
+ | `xero_new_sales_invoice` | `salesInvoiceCreated` | `app` | Shares the app-level Xero webhook; bills are excluded. |
57
+ | `xero_updated_sales_invoice` | `salesInvoiceUpdated` | `app` | Shares the app-level Xero webhook; bills are excluded. |
58
+ | `xero_new_bank_transaction` | `bankTransactionCreated` | `polling` | Up to five pages per poll. |
59
+ | `xero_new_payment` | `paymentCreated` | `polling` | Up to five pages per poll. |
60
+ | `xero_new_purchase_order` | `purchaseOrderCreated` | `polling` | Up to five pages per poll. |
61
+ | `xero_new_reconciled_payment` | `paymentReconciled` | `polling` | Cursor tracks reconciliation transitions. |
62
+ | `xero_updated_quote` | `quoteUpdated` | `polling` | Cursor tracks update timestamps. |
63
+ | `xero_new_bill` | `billCreated` | `polling` | Up to five pages per poll. |
64
+ | `xero_new_credit_note` | `creditNoteCreated` | `polling` | Up to five pages per poll. |
65
+ | `xero_new_project` | `projectCreated` | `polling` | Up to five pages per poll. |
66
+ | `xero_new_quote` | `quoteCreated` | `polling` | Up to five pages per poll. |
67
+
68
+ ## Webhook Setup
69
+
70
+ Xero manages one webhook URL per app rather than exposing webhook registration APIs. Configure `webhookKey` once on the Xero piece instance. In Xero Developer, open the app, choose **Webhooks**, select the Contact and Invoice categories, enter the instance-level webhook URL shown by FrogBot, save it, and validate the **Intent to receive** request.
71
+
72
+ Every app trigger requires its Xero Organization ID (`tenantId`). Find it in Xero under **Settings > General settings > Organization details** and copy the **Xero organisation ID**. FrogBot rejects every event whose payload `tenantId` does not exactly match this value, including when multiple trigger subscribers share the app-level webhook.
73
+
74
+ FrogBot validates `x-xero-signature` against the untouched request body with HMAC-SHA256 and a timing-safe comparison before parsing or routing events. Xero's intent-to-receive (ITR) probe is a signed empty-event delivery: a valid probe receives HTTP 200 and an invalid signature receives HTTP 401. Keep at least one app trigger configured so the instance webhook remains mounted.
75
+
76
+ ## Limitations
77
+
78
+ - Webhook creation and deletion remain manual because Xero does not provide a vendor registration API.
79
+ - Polling requests at most five pages per run, then persists the next page and original modification window until all pages have been drained. It retains the latest 5,000 identifiers for overlap deduplication.
80
+ - The custom action is intentionally restricted to the Xero accounting API origin and cannot send arbitrary authorization headers.
@@ -0,0 +1,58 @@
1
+ import type { PieceRunArgs } from 'frogbot/pieces';
2
+ import { z } from 'zod';
3
+ import type { XeroClient, XeroJSON } from './client.js';
4
+ declare const sendInvoiceEmailInput: z.ZodObject<{
5
+ invoiceId: z.ZodString;
6
+ tenantId: z.ZodString;
7
+ }, z.core.$strip>;
8
+ export declare const xeroActions: ({
9
+ slug: string;
10
+ label: string;
11
+ description: string;
12
+ input: z.ZodObject<{
13
+ invoiceId: z.ZodString;
14
+ tenantId: z.ZodString;
15
+ }, z.core.$strip>;
16
+ output: z.ZodObject<{
17
+ success: z.ZodLiteral<true>;
18
+ }, z.core.$strip>;
19
+ run({ input, client, req, }: PieceRunArgs<z.output<typeof sendInvoiceEmailInput>, object, XeroClient>): Promise<{
20
+ success: boolean;
21
+ }>;
22
+ } | {
23
+ slug: string;
24
+ label: string;
25
+ description: string;
26
+ input: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
27
+ output: z.ZodObject<{}, z.core.$catchall<z.ZodUnion<readonly [z.ZodJSONSchema, z.ZodArray<z.ZodJSONSchema>]>>>;
28
+ idempotent: boolean;
29
+ options: {
30
+ tenantId({ client, req, }: {
31
+ client: XeroClient;
32
+ req: {
33
+ signal?: AbortSignal | null;
34
+ };
35
+ }): Promise<{
36
+ label: string;
37
+ value: string;
38
+ }[]>;
39
+ };
40
+ run: (args: PieceRunArgs<unknown, object, {
41
+ listTenants: (signal?: AbortSignal) => Promise<{
42
+ tenantId: string;
43
+ tenantName: string;
44
+ }[]>;
45
+ request: <TSchema extends z.ZodType>(input: {
46
+ path: string;
47
+ tenantId?: string;
48
+ method?: "DELETE" | "GET" | "POST" | "PUT";
49
+ body?: BodyInit | XeroJSON;
50
+ headers?: Record<string, string>;
51
+ query?: Record<string, boolean | number | string | undefined>;
52
+ signal?: AbortSignal;
53
+ base?: "accounting" | "connections" | "identity" | "projects";
54
+ }, schema: TSchema) => Promise<z.core.output<TSchema>>;
55
+ }>) => Promise<unknown>;
56
+ })[];
57
+ export {};
58
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAwPxD,QAAA,MAAM,qBAAqB;;;iBAAwD,CAAC;AA+xBpF,eAAO,MAAM,WAAW;;;;;;;;;;;iCApxBnB,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC;;;;;;;;;;;;oBAxN7D,UAAU;;yBACF,WAAW,GAAG,IAAI;;;;;;;;;;;;kCAoCpC,EAAA,OAAI;;;;;;;;;;WAnDuD,OAAO,CAAC,OAAO,CAAC;IAohChF,CAAC"}