Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/handlers/list-xero-contacts.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { XeroClientResponse } from "../types/tool-response.js";
import { formatError } from "../helpers/format-error.js";
import { getClientHeaders } from "../helpers/get-client-headers.js";

async function getContacts(page?: number, searchTerm?: string): Promise<Contact[]> {
async function getContacts(page?: number, searchTerm?: string, pageSize?: number): Promise<Contact[]> {
await xeroClient.authenticate();

const contacts = await xeroClient.accountingApi.getContacts(
Expand All @@ -17,7 +17,7 @@ async function getContacts(page?: number, searchTerm?: string): Promise<Contact[
undefined, // includeArchived
true, // summaryOnly
searchTerm, // searchTerm
undefined, // pageSize
pageSize, // pageSize
getClientHeaders(),
);
return contacts.body.contacts ?? [];
Expand All @@ -26,11 +26,11 @@ async function getContacts(page?: number, searchTerm?: string): Promise<Contact[
/**
* List all contacts from Xero
*/
export async function listXeroContacts(page?: number, searchTerm?: string): Promise<
export async function listXeroContacts(page?: number, searchTerm?: string, pageSize?: number): Promise<
XeroClientResponse<Contact[]>
> {
try {
const contacts = await getContacts(page, searchTerm);
const contacts = await getContacts(page, searchTerm, pageSize);

return {
result: contacts,
Expand Down
6 changes: 4 additions & 2 deletions src/handlers/list-xero-credit-notes.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getClientHeaders } from "../helpers/get-client-headers.js";
async function getCreditNotes(
contactId: string | undefined,
page: number,
pageSize: number = 10,
): Promise<CreditNote[]> {
await xeroClient.authenticate();

Expand All @@ -17,7 +18,7 @@ async function getCreditNotes(
"UpdatedDateUTC DESC", // order
page, // page
undefined, // unitdp
10, // pageSize
pageSize, // pageSize
getClientHeaders(),
);

Expand All @@ -30,9 +31,10 @@ async function getCreditNotes(
export async function listXeroCreditNotes(
page: number = 1,
contactId?: string,
pageSize: number = 10,
): Promise<XeroClientResponse<CreditNote[]>> {
try {
const creditNotes = await getCreditNotes(contactId, page);
const creditNotes = await getCreditNotes(contactId, page, pageSize);

return {
result: creditNotes,
Expand Down
6 changes: 4 additions & 2 deletions src/handlers/list-xero-invoices.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ async function getInvoices(
invoiceNumbers: string[] | undefined,
contactIds: string[] | undefined,
page: number,
pageSize: number = 10,
): Promise<Invoice[]> {
await xeroClient.authenticate();

Expand All @@ -25,7 +26,7 @@ async function getInvoices(
false, // createdByMyApp
undefined, // unitdp
false, // summaryOnly
10, // pageSize
pageSize, // pageSize
undefined, // searchTerm
getClientHeaders(),
);
Expand All @@ -39,9 +40,10 @@ export async function listXeroInvoices(
page: number = 1,
contactIds?: string[],
invoiceNumbers?: string[],
pageSize: number = 10,
): Promise<XeroClientResponse<Invoice[]>> {
try {
const invoices = await getInvoices(invoiceNumbers, contactIds, page);
const invoices = await getInvoices(invoiceNumbers, contactIds, page, pageSize);

return {
result: invoices,
Expand Down
5 changes: 4 additions & 1 deletion src/handlers/list-xero-manual-journals.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ async function getManualJournals(
page: number,
manualJournalId?: string,
modifiedAfter?: string,
pageSize: number = 10,
): Promise<ManualJournal[]> {
await xeroClient.authenticate();

Expand All @@ -27,7 +28,7 @@ async function getManualJournals(
undefined,
"UpdatedDateUTC DESC",
page,
10, // pageSize
pageSize, // pageSize
getClientHeaders(),
);

Expand All @@ -41,12 +42,14 @@ export async function listXeroManualJournals(
page: number = 1,
manualJournalId?: string,
modifiedAfter?: string,
pageSize: number = 10,
): Promise<XeroClientResponse<ManualJournal[]>> {
try {
const manualJournals = await getManualJournals(
page,
manualJournalId,
modifiedAfter,
pageSize,
);

return {
Expand Down
6 changes: 4 additions & 2 deletions src/handlers/list-xero-payments.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getClientHeaders } from "../helpers/get-client-headers.js";

async function getPayments(
page: number = 1,
pageSize: number = 10,
{
invoiceNumber,
invoiceId,
Expand Down Expand Up @@ -46,7 +47,7 @@ async function getPayments(
where,
"UpdatedDateUTC DESC", // order
page, // page
10, // pageSize
pageSize, // pageSize
getClientHeaders(), // options
);

Expand All @@ -69,9 +70,10 @@ export async function listXeroPayments(
paymentId?: string;
reference?: string;
},
pageSize: number = 10,
): Promise<XeroClientResponse<Payment[]>> {
try {
const payments = await getPayments(page, {
const payments = await getPayments(page, pageSize, {
invoiceNumber,
invoiceId,
paymentId,
Expand Down
5 changes: 3 additions & 2 deletions src/tools/list/list-contacts.tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ const ListContactsTool = CreateXeroTool(
If not provided, the first page will be returned. If 100 contacts are returned, \
call this tool again with the next page number."),
searchTerm: z.string().optional().describe("Search parameter that performs a case-insensitive text search across the Name, FirstName, LastName, ContactNumber and EmailAddress fields"),
pageSize: z.number().min(1).max(100).default(10).optional().describe("Number of results per page (1-100, default 10)"),
},
async (params) => {
const { page, searchTerm } = params;
const response = await listXeroContacts(page, searchTerm);
const { page, searchTerm, pageSize } = params;
const response = await listXeroContacts(page, searchTerm, pageSize);

if (response.isError) {
return {
Expand Down
5 changes: 3 additions & 2 deletions src/tools/list/list-credit-notes.tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ const ListCreditNotesTool = CreateXeroTool(
{
page: z.number(),
contactId: z.string().optional(),
pageSize: z.number().min(1).max(100).default(10).optional().describe("Number of results per page (1-100, default 10)"),
},
async ({ page, contactId }) => {
const response = await listXeroCreditNotes(page, contactId);
async ({ page, contactId, pageSize }) => {
const response = await listXeroCreditNotes(page, contactId, pageSize);
if (response.error !== null) {
return {
content: [
Expand Down
5 changes: 3 additions & 2 deletions src/tools/list/list-invoices.tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ const ListInvoicesTool = CreateXeroTool(
and the contact or invoice number if one was provided in the previous call.",
{
page: z.number(),
pageSize: z.number().min(1).max(100).default(10).optional().describe("Number of results per page (1-100, default 10)"),
contactIds: z.array(z.string()).optional(),
invoiceNumbers: z
.array(z.string())
.optional()
.describe("If provided, invoice line items will also be returned"),
},
async ({ page, contactIds, invoiceNumbers }) => {
const response = await listXeroInvoices(page, contactIds, invoiceNumbers);
async ({ page, pageSize, contactIds, invoiceNumbers }) => {
const response = await listXeroInvoices(page, contactIds, invoiceNumbers, pageSize);
if (response.error !== null) {
return {
content: [
Expand Down
2 changes: 2 additions & 0 deletions src/tools/list/list-manual-journals.tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ If they want the next page, call this tool again with the next page number, modi
"Optional date YYYY-MM-DD to filter journals modified after this date",
),
page: z.number().optional().describe("Optional page number for pagination"),
pageSize: z.number().min(1).max(100).default(10).optional().describe("Number of results per page (1-100, default 10)"),
// TODO: where, order
},
async (args) => {
const response = await listXeroManualJournals(
args?.page,
args?.manualJournalId,
args?.modifiedAfter,
args?.pageSize,
);

if (response.isError) {
Expand Down
5 changes: 3 additions & 2 deletions src/tools/list/list-payments.tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,19 @@ const ListPaymentsTool = CreateXeroTool(
If many payments are returned, ask the user if they want to see the next page.`,
{
page: z.number().default(1),
pageSize: z.number().min(1).max(100).default(10).optional().describe("Number of results per page (1-100, default 10)"),
invoiceNumber: z.string().optional(),
invoiceId: z.string().optional(),
paymentId: z.string().optional(),
reference: z.string().optional(),
},
async ({ page, invoiceNumber, invoiceId, paymentId, reference }) => {
async ({ page, pageSize, invoiceNumber, invoiceId, paymentId, reference }) => {
const response = await listXeroPayments(page, {
invoiceNumber,
invoiceId,
paymentId,
reference,
});
}, pageSize);

if (response.error !== null) {
return {
Expand Down