Skip to content
Merged
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
7 changes: 6 additions & 1 deletion server/src/schemas/tool-inputs/create-sales-order.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { z } from 'zod';
import { Order, OrderSchema } from '../entities/order.js';
import { Customer, CustomerSchema } from '../entities/customer.js';
import { makeZodFieldMap } from '../utils/schema-util.js';

const immutableOrderFields = ['id', 'createdAt', 'updatedAt', 'tenantId'] as const satisfies (keyof Order)[];
const serverOnlyCustomerFields = ['createdAt', 'updatedAt', 'tenantId'] as const satisfies (keyof Customer)[];

export const CreateSalesOrderInputSchema = z.object({
order: OrderSchema.omit(makeZodFieldMap(immutableOrderFields)),
order: OrderSchema.omit(makeZodFieldMap(immutableOrderFields)).extend({
customer: CustomerSchema.omit(makeZodFieldMap(serverOnlyCustomerFields)).optional(),
}),
});
export type CreateSalesOrderInput = z.infer<typeof CreateSalesOrderInputSchema>;
16 changes: 5 additions & 11 deletions server/tests/integration/adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@ const baseAddress = (overrides: Partial<Record<string, string>> = {}) => ({
...overrides,
});

const buildCustomer = (extId: string) => {
const timestamp = new Date().toISOString();
return {
id: `CUST-${extId}-${Date.now()}`,
tenantId: 'mock-tenant',
createdAt: timestamp,
updatedAt: timestamp,
email: `${extId.toLowerCase()}@example.com`,
firstName: 'Adapter',
};
};
const buildCustomer = (extId: string) => ({
id: `CUST-${extId}-${Date.now()}`,
email: `${extId.toLowerCase()}@example.com`,
firstName: 'Adapter',
});

const buildOrder = (extId: string) => ({
externalId: extId,
Expand Down
16 changes: 5 additions & 11 deletions server/tests/integration/e2e-workflows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@ const address = (overrides: Partial<Record<string, string>> = {}) => ({
...overrides,
});

const buildCustomer = (prefix: string) => {
const timestamp = new Date().toISOString();
return {
id: `WF-CUST-${prefix}-${Date.now()}`,
tenantId: 'mock-tenant',
createdAt: timestamp,
updatedAt: timestamp,
email: `${prefix.toLowerCase()}@example.com`,
firstName: prefix,
};
};
const buildCustomer = (prefix: string) => ({
id: `WF-CUST-${prefix}-${Date.now()}`,
email: `${prefix.toLowerCase()}@example.com`,
firstName: prefix,
});

const buildOrderPayload = (prefix: string) => ({
externalId: `${prefix}-${Date.now()}`,
Expand Down
16 changes: 5 additions & 11 deletions server/tests/integration/tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@ const requiredAddress = (overrides: Partial<Record<string, string>> = {}) => ({
...overrides,
});

const buildCustomer = (prefix: string) => {
const timestamp = new Date().toISOString();
return {
id: `CUST-${prefix}-${Date.now()}`,
tenantId: 'mock-tenant',
createdAt: timestamp,
updatedAt: timestamp,
email: `${prefix.toLowerCase()}@example.com`,
firstName: prefix,
};
};
const buildCustomer = (prefix: string) => ({
id: `CUST-${prefix}-${Date.now()}`,
email: `${prefix.toLowerCase()}@example.com`,
firstName: prefix,
});

const makeLineItem = (idSuffix: string) => ({
id: `LI-${idSuffix}`,
Expand Down
Loading