Skip to content

Commit

Permalink
fix: fixing schema for associated ids on pipedrive (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
manas-vessel authored Aug 17, 2023
1 parent 5ef575c commit ed90916
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vesselapi/integrations",
"version": "1.0.69",
"version": "1.0.70",
"description": "Vessel integrations",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
1 change: 1 addition & 0 deletions src/platforms/pipedrive/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const request = makeRequestFactory(async (auth, options) => {
type requestFunctionType<I, O> = (
auth: Auth,
input: I,
options?: Parameters<ReturnType<typeof request>>[2],
) => Promise<ClientResult<O>>;

const makeClient = () => {
Expand Down
16 changes: 9 additions & 7 deletions src/platforms/pipedrive/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type FindOutput<T> = {
data: T;
};
export type ListOutput<T> = {
data?: T[];
data?: T[] | null;
additional_data?: {
pagination?: { more_items_in_collection?: boolean; start?: number };
};
Expand All @@ -39,7 +39,7 @@ export const listResponseSchema = <TOutput>(
itemSchema: z.ZodType<TOutput, any, any>,
) =>
z.object({
data: z.array(itemSchema).optional(),
data: z.array(itemSchema).optional().nullable(),
additional_data: z
.object({
pagination: z
Expand Down Expand Up @@ -119,6 +119,8 @@ export const pipedriveAssociationId = z.object({
name: z.string(),
});

export const pipedriveStringOrNumber = () => z.union([z.string(), z.number()]);

// -
// Users
// -
Expand Down Expand Up @@ -262,12 +264,12 @@ export const pipedriveNoteSchema = custom.addNativeToZodSchema(
add_time: custom.date(),
update_time: custom.date(),
content: z.string().nullable(),
user_id: z.number().nullable(),
user_id: pipedriveStringOrNumber().nullable(),
active_flag: z.boolean().nullable(),
deal_id: z.number().optional().nullable(),
person_id: z.number().optional().nullable(),
org_id: z.number().optional().nullable(),
lead_id: z.number().optional().nullable(),
deal_id: pipedriveStringOrNumber().optional().nullable(),
person_id: pipedriveStringOrNumber().optional().nullable(),
org_id: pipedriveStringOrNumber().optional().nullable(),
lead_id: pipedriveStringOrNumber().optional().nullable(),
}),
);
export type PipedriveNote = z.infer<typeof pipedriveNoteSchema>;
Expand Down

0 comments on commit ed90916

Please sign in to comment.