Skip to content

Commit

Permalink
fix(xero): Fix xero endpoints & tweak precommit script to generate te…
Browse files Browse the repository at this point in the history
…sts (#82)

## Describe your changes
- Fix endpoints
- Update precommit script to only operate on changed files

## Issue ticket number and link

## Checklist before requesting a review (skip if just adding/editing
APIs & templates)
- [ ] I added tests, otherwise the reason is:
- [ ] External API requests have `retries`
- [ ] Pagination is used where appropriate
- [ ] The built in `nango.paginate` call is used instead of a `while
(true)` loop
- [ ] Third party requests are NOT parallelized (this can cause issues
with rate limits)
- [ ] If a sync requires metadata the `nango.yaml` has `auto_start:
false`
- [ ] If the sync is a `full` sync then `track_deletes: true` is set
  • Loading branch information
khaliqgant authored Oct 30, 2024
1 parent 0848311 commit 676a094
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
. "$(dirname -- "$0")/_/husky.sh"

node ./scripts/flows.js
npm run generate:tests
npm run generate:tests --pre_commit=true
git add ./integrations/*/tests/*.test.ts
git add ./flows.yaml
npx lint-staged --allow-empty
56 changes: 28 additions & 28 deletions flows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7849,8 +7849,8 @@ integrations:
runs: every hour
output: Contact
sync_type: incremental
endpoint: GET /xero/contacts
version: 1.0.0
endpoint: GET /contacts
version: 1.0.1
accounts:
description: >
Fetches all accounts in Xero (chart of accounts). Incremental sync,
Expand All @@ -7859,8 +7859,8 @@ integrations:
scopes: accounting.settings
output: Account
sync_type: incremental
endpoint: GET /xero/accounts
version: 1.0.0
endpoint: GET /accounts
version: 1.0.1
items:
description: >
Fetches all items in Xero. Incremental sync, does not detect deletes,
Expand All @@ -7871,26 +7871,26 @@ integrations:
scopes: accounting.settings
output: Item
sync_type: incremental
endpoint: GET /xero/items
version: 1.0.0
endpoint: GET /items
version: 1.0.1
invoices:
description: |
Fetches all invoices in Xero. Incremental sync.
runs: every hour
scopes: accounting.transactions
output: Invoice
sync_type: incremental
endpoint: GET /xero/invoices
version: 1.0.0
endpoint: GET /invoices
version: 1.0.1
payments:
description: |
Fetches all payments in Xero. Incremental sync.
runs: every hour
scopes: accounting.transactions
output: Payment
sync_type: incremental
endpoint: GET /xero/payments
version: 1.0.0
endpoint: GET /payments
version: 1.0.1
actions:
create-contact:
description: |
Expand All @@ -7899,8 +7899,8 @@ integrations:
input: CreateContact[]
scopes: accounting.contacts
output: ContactActionResponse
endpoint: POST /xero/contacts
version: 1.0.0
endpoint: POST /contacts
version: 1.0.1
update-contact:
description: >
Updates one or multiple contacts in Xero. Only fields that are passed
Expand All @@ -7909,17 +7909,17 @@ integrations:
input: Contact[]
scopes: accounting.contacts
output: ContactActionResponse
endpoint: PUT /xero/contacts
version: 1.0.0
endpoint: PUT /contacts
version: 1.0.1
create-invoice:
description: |
Creates one or more invoices in Xero.
Note: Does NOT check if the invoice already exists.
input: CreateInvoice[]
scopes: accounting.transactions
output: InvoiceActionResponse
endpoint: POST /xero/invoices
version: 1.0.1
endpoint: POST /invoices
version: 1.0.2
update-invoice:
description: |
Updates one or more invoices in Xero. To delete an invoice
Expand All @@ -7929,51 +7929,51 @@ integrations:
input: UpdateInvoice[]
scopes: accounting.transactions
output: InvoiceActionResponse
endpoint: PUT /xero/invoices
version: 1.0.1
endpoint: PUT /invoices
version: 1.0.2
create-credit-note:
description: |
Creates one or more credit notes in Xero.
Note: Does NOT check if the credit note already exists.
input: CreditNote[]
scopes: accounting.transactions
output: CreditNoteActionResponse
endpoint: POST /xero/creditnotes
version: 1.0.0
endpoint: POST /creditnotes
version: 1.0.1
update-credit-note:
description: |
Updates one or more credit notes in Xero.
input: CreditNote[]
scopes: accounting.transactions
output: CreditNoteActionResponse
endpoint: PUT /xero/creditnotes
version: 1.0.0
endpoint: PUT /creditnotes
version: 1.0.1
create-payment:
description: |
Creates one or more payments in Xero.
Note: Does NOT check if the payment already exists.
scopes: accounting.transactions
input: CreatePayment[]
output: PaymentActionResponse
endpoint: POST /xero/payments
version: 1.0.0
endpoint: POST /payments
version: 1.0.1
create-item:
description: |
Creates one or more items in Xero.
Note: Does NOT check if the item already exists.
scopes: accounting.settings
input: Item[]
output: ItemActionResponse
endpoint: POST /xero/items
version: 1.0.0
endpoint: POST /items
version: 1.0.1
update-item:
description: |
Updates one or more items in Xero.
scopes: accounting.settings
input: Item[]
output: ItemActionResponse
endpoint: PUT /xero/items
version: 1.0.0
endpoint: PUT /items
version: 1.0.1
models:
ActionErrorResponse:
message: string
Expand Down
56 changes: 28 additions & 28 deletions integrations/xero/nango.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ integrations:
runs: every hour
output: Contact
sync_type: incremental
endpoint: GET /xero/contacts
version: 1.0.0
endpoint: GET /contacts
version: 1.0.1
accounts:
description: |
Fetches all accounts in Xero (chart of accounts). Incremental sync, detects deletes, metadata is not required.
runs: every hour
scopes: accounting.settings
output: Account
sync_type: incremental
endpoint: GET /xero/accounts
version: 1.0.0
endpoint: GET /accounts
version: 1.0.1
items:
description: |
Fetches all items in Xero. Incremental sync, does not detect deletes, metadata is not
Expand All @@ -27,26 +27,26 @@ integrations:
scopes: accounting.settings
output: Item
sync_type: incremental
endpoint: GET /xero/items
version: 1.0.0
endpoint: GET /items
version: 1.0.1
invoices:
description: |
Fetches all invoices in Xero. Incremental sync.
runs: every hour
scopes: accounting.transactions
output: Invoice
sync_type: incremental
endpoint: GET /xero/invoices
version: 1.0.0
endpoint: GET /invoices
version: 1.0.1
payments:
description: |
Fetches all payments in Xero. Incremental sync.
runs: every hour
scopes: accounting.transactions
output: Payment
sync_type: incremental
endpoint: GET /xero/payments
version: 1.0.0
endpoint: GET /payments
version: 1.0.1
actions:
create-contact:
description: |
Expand All @@ -55,8 +55,8 @@ integrations:
input: CreateContact[]
scopes: accounting.contacts
output: ContactActionResponse
endpoint: POST /xero/contacts
version: 1.0.0
endpoint: POST /contacts
version: 1.0.1
update-contact:
description: >
Updates one or multiple contacts in Xero.
Expand All @@ -66,17 +66,17 @@ integrations:
input: Contact[]
scopes: accounting.contacts
output: ContactActionResponse
endpoint: PUT /xero/contacts
version: 1.0.0
endpoint: PUT /contacts
version: 1.0.1
create-invoice:
description: |
Creates one or more invoices in Xero.
Note: Does NOT check if the invoice already exists.
input: CreateInvoice[]
scopes: accounting.transactions
output: InvoiceActionResponse
endpoint: POST /xero/invoices
version: 1.0.1
endpoint: POST /invoices
version: 1.0.2
update-invoice:
description: |
Updates one or more invoices in Xero. To delete an invoice
Expand All @@ -86,51 +86,51 @@ integrations:
input: UpdateInvoice[]
scopes: accounting.transactions
output: InvoiceActionResponse
endpoint: PUT /xero/invoices
version: 1.0.1
endpoint: PUT /invoices
version: 1.0.2
create-credit-note:
description: |
Creates one or more credit notes in Xero.
Note: Does NOT check if the credit note already exists.
input: CreditNote[]
scopes: accounting.transactions
output: CreditNoteActionResponse
endpoint: POST /xero/creditnotes
version: 1.0.0
endpoint: POST /creditnotes
version: 1.0.1
update-credit-note:
description: |
Updates one or more credit notes in Xero.
input: CreditNote[]
scopes: accounting.transactions
output: CreditNoteActionResponse
endpoint: PUT /xero/creditnotes
version: 1.0.0
endpoint: PUT /creditnotes
version: 1.0.1
create-payment:
description: |
Creates one or more payments in Xero.
Note: Does NOT check if the payment already exists.
scopes: accounting.transactions
input: CreatePayment[]
output: PaymentActionResponse
endpoint: POST /xero/payments
version: 1.0.0
endpoint: POST /payments
version: 1.0.1
create-item:
description: |
Creates one or more items in Xero.
Note: Does NOT check if the item already exists.
scopes: accounting.settings
input: Item[]
output: ItemActionResponse
endpoint: POST /xero/items
version: 1.0.0
endpoint: POST /items
version: 1.0.1
update-item:
description: |
Updates one or more items in Xero.
scopes: accounting.settings
input: Item[]
output: ItemActionResponse
endpoint: PUT /xero/items
version: 1.0.0
endpoint: PUT /items
version: 1.0.1

models:
ActionErrorResponse:
Expand Down
15 changes: 10 additions & 5 deletions scripts/generate-integration-template-tests.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ popd () {
command popd "$@" > /dev/null
}

if [ -n "$npm_config_integration" ]; then
integrations=("$npm_config_integration")
# Check if pre-commit flag is set
if [ -n "$npm_config_pre_commit" ]; then
integrations=($(git status --porcelain | grep '^ M integrations/' | sed -E 's|^ M integrations/([^/]+)/.*|\1|' | uniq))
else
cd integrations
integrations=($(ls -d */ | sed 's/\///g'))
cd ..
if [ -n "$npm_config_integration" ]; then
integrations=("$npm_config_integration")
else
cd integrations
integrations=($(ls -d */ | sed 's/\///g'))
cd ..
fi
fi

export NANGO_CLI_UPGRADE_MODE=ignore
Expand Down

0 comments on commit 676a094

Please # to comment.