Skip to content

feat(repo): Apply generated API client to downstream SDKs #5537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: tm/backend-api-client
Choose a base branch
from
Draft
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
60 changes: 32 additions & 28 deletions packages/agent-toolkit/src/lib/tools/invitations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@ import { z } from 'zod';
import { ClerkTool } from '../clerk-tool';
import { prunePrivateData } from '../utils';

const createInvitationParameters = z.object({
emailAddress: z.string().describe('(string): Email address to send the invitation to. Required.'),
redirectUrl: z
.string()
.optional()
.describe('(string, optional): URL to redirect users to after they accept the invitation.'),
publicMetadata: z
.record(z.string(), z.any())
.optional()
.describe('(Record<string,any>, optional): Public metadata for the invitation.'),
notify: z
.boolean()
.optional()
.describe('(boolean, optional): Whether to send an email notification. Defaults to true.'),
ignoreExisting: z
.boolean()
.optional()
.describe('(boolean, optional): Whether to ignore if an invitation already exists. Defaults to false.'),
});

const createInvitation = ClerkTool({
name: 'createInvitation',
description: `
Expand All @@ -17,31 +37,17 @@ const createInvitation = ClerkTool({
2. Creating a closed registration system where only invited users can join
3. Pre-configuring user attributes via publicMetadata before they sign up
`,
parameters: z.object({
emailAddress: z.string().describe('(string): Email address to send the invitation to. Required.'),
redirectUrl: z
.string()
.optional()
.describe('(string, optional): URL to redirect users to after they accept the invitation.'),
publicMetadata: z
.record(z.string(), z.any())
.optional()
.describe('(Record<string,any>, optional): Public metadata for the invitation.'),
notify: z
.boolean()
.optional()
.describe('(boolean, optional): Whether to send an email notification. Defaults to true.'),
ignoreExisting: z
.boolean()
.optional()
.describe('(boolean, optional): Whether to ignore if an invitation already exists. Defaults to false.'),
}),
execute: (clerkClient, context) => async params => {
const res = await clerkClient.invitations.createInvitation(params);
return prunePrivateData(context, res.raw);
parameters: createInvitationParameters,
execute: (clerkClient, context) => async (params: z.infer<typeof createInvitationParameters>) => {
const res = await clerkClient.api.invitations.create(params);
return prunePrivateData(context, res); // TODO: Use raw JSON response
},
});

const revokeInvitationParameters = z.object({
invitationId: z.string().describe('(string): The ID of the invitation to revoke. Required.'),
});

const revokeInvitation = ClerkTool({
name: 'revokeInvitation',
description: `
Expand All @@ -56,12 +62,10 @@ const revokeInvitation = ClerkTool({
2. Revoking access when a prospective user should no longer be invited
3. Implementing invitation management controls for administrators
`,
parameters: z.object({
invitationId: z.string().describe('(string): The ID of the invitation to revoke. Required.'),
}),
execute: (clerkClient, context) => async params => {
const res = await clerkClient.invitations.revokeInvitation(params.invitationId);
return prunePrivateData(context, res.raw);
parameters: revokeInvitationParameters,
execute: (clerkClient, context) => async (params: z.infer<typeof revokeInvitationParameters>) => {
const res = await clerkClient.api.invitations.revoke(params.invitationId);
return prunePrivateData(context, res); // TODO: Use raw JSON response
},
});

Expand Down
Loading