-
Notifications
You must be signed in to change notification settings - Fork 10
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
types: webhook event types #58
Conversation
WalkthroughThe recent update enriches the system with a diverse range of webhook event interfaces to manage various user actions, access requests, organization and permission updates, role changes, and subscriber additions. Additionally, a new type called Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
Review Status
Configuration used: CodeRabbit UI
Files selected for processing (1)
- lib/sdk/utilities/types.ts (1 hunks)
Additional Context Used
GitHub Check Runs (1)
main (18.x) failure (11)
lib/sdk/utilities/types.ts: [failure] 44-44:
Strings must use singlequote
lib/sdk/utilities/types.ts: [failure] 44-44:
Strings must use singlequote
lib/sdk/utilities/types.ts: [failure] 44-44:
Strings must use singlequote
lib/sdk/utilities/types.ts: [failure] 59-59:
Strings must use singlequote
lib/sdk/utilities/types.ts: [failure] 71-71:
Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead
lib/sdk/utilities/types.ts: [failure] 73-73:
Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead
lib/sdk/utilities/types.ts: [failure] 85-85:
Strings must use singlequote
lib/sdk/utilities/types.ts: [failure] 97-97:
Strings must use singlequote
lib/sdk/utilities/types.ts: [failure] 109-109:
Strings must use singlequote
lib/sdk/utilities/types.ts: [failure] 121-121:
Strings must use singlequote
Change quotes Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Review Status
Configuration used: CodeRabbit UI
Files selected for processing (1)
- lib/sdk/utilities/types.ts (1 hunks)
Additional Context Used
GitHub Check Runs (1)
main (18.x) failure (11)
lib/sdk/utilities/types.ts: [failure] 71-71:
Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead
lib/sdk/utilities/types.ts: [failure] 73-73:
Array type using 'T[]' is forbidden for non-simple types. Use 'Array' instead
lib/sdk/utilities/types.ts: [failure] 136-136:
Strings must use singlequote
lib/sdk/utilities/types.ts: [failure] 151-151:
Strings must use singlequote
lib/sdk/utilities/types.ts: [failure] 167-167:
Strings must use singlequote
lib/sdk/utilities/types.ts: [failure] 179-179:
Strings must use singlequote
lib/sdk/utilities/types.ts: [failure] 194-194:
Strings must use singlequote
lib/sdk/utilities/types.ts: [failure] 209-209:
Strings must use singlequote
lib/sdk/utilities/types.ts: [failure] 221-221:
Strings must use singlequote
lib/sdk/utilities/types.ts: [failure] 237-237:
Strings must use singlequote
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 12
Review Status
Configuration used: CodeRabbit UI
Files selected for processing (1)
- lib/sdk/utilities/types.ts (1 hunks)
Additional Context Used
GitHub Check Runs (1)
main (18.x) failure (3)
lib/sdk/utilities/types.ts: [failure] 90-90:
Declaration or statement expected.
chore: update array structure Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2e4d23e
to
12be199
Compare
@coderabbitai review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Status
Configuration used: CodeRabbit UI
Files selected for processing (1)
- lib/sdk/utilities/types.ts (1 hunks)
Additional comments not posted (4)
lib/sdk/utilities/types.ts (4)
44-44
: Consider documenting theWebhookSource
type to provide clarity on the context in which each source value is used.
46-60
: Ensure consistency in the use of nullable types across all interfaces. For example,phone
fields inUserCreatedWebhookEvent
are nullable, which is appropriate. Apply this consideration consistently across all user-related fields in other interfaces.
62-86
: For theUserUpdatedWebhookEvent
interface, consider adding documentation comments to explain the purpose of fields likeis_password_reset_requested
andis_suspended
, as their implications on the user's state are significant.
124-137
: In theAccessRequestCreatedWebhookEvent
interface, ensure that theuser_id
field is consistently named across all event interfaces to maintain uniformity and avoid confusion.
I would suggest doing something more along these lines. This way will have a "base" type that the rest can pull from. That way if the base type changes or more webhook events are added we can add it in just 1 place and the rest will fall into place. I also prefer to use type WebhookEventDataMap = {
'user.created': {
user: {
email: string | null;
first_name: string;
id: string;
last_name: string;
phone: string | null;
};
};
'user.updated': {
user: {
email: string;
first_name: string;
id: string;
is_password_reset_requested: boolean;
is_suspended: boolean;
last_name: string;
organizations: Array<{
roles: string[] | null;
code: string;
permissions: Array<{
id: string;
key: string;
}> | null;
}>;
phone: string | null;
};
};
'user.deleted': {
user: {
id: string;
};
};
'user.authenticated': {
user: {
id: string;
};
};
'user.authentication_failed': {
user: {
id: string;
};
};
'access_request.created': {
access_request: {
email: string;
first_name: string;
last_name: string;
user_id: string;
};
};
'organization.created': {
organization: {
code: string;
external_id: string | null;
handle: string;
name: string;
};
};
'organization.updated': {
organization: {
code: string;
external_id: string | null;
handle: string;
is_allow_registrations: boolean;
name: string;
};
};
'organization.deleted': {
organization: {
code: string;
};
};
'permission.created': {
permission: {
description: string;
id: string;
key: string;
name: string;
};
};
'permission.updated': {
permission: {
description: string;
id: string;
key: string;
name: string;
};
};
'permission.deleted': {
permission: {
id: string;
};
};
'role.created': {
role: {
description: string;
id: string;
is_default_role: boolean;
key: string;
name: string;
};
};
'role.updated': {
role: {
description: string;
id: string;
is_default_role: boolean;
key: string;
name: string;
};
};
'role.deleted': {
role: {
id: string;
};
};
'subscriber.created': {
subscriber: {
email: string;
first_name: string;
id: string;
last_name: string;
user_id: string;
};
};
}
type WebhookEvent<TType extends keyof WebhookEventDataMap> = {
data: WebhookEventDataMap[TType];
event_id: string;
source: WebhookSource;
timestamp: string;
type: TType;
}
export type UserCreatedWebhookEvent = WebhookEvent<'user.created'>;
export type UserUpdatedWebhookEvent = WebhookEvent<'user.updated'>;
...
export type RoleDeletedWebhookEvent = WebhookEvent<'role.deleted'>;
export type SubscriberCreatedWebhookEvent = WebhookEvent<'subscriber.created'>; |
Hi, @BrennenRocks Agree, the main reason this has not been merged as we have another solution in the works to handle webhooks. I hope to be able to share soon! |
Hi @BrennenRocks , We have released the @kinde-oss/webhooks package which has types and handing. |
Explain your changes
Suppose there is a related issue with enough detail for a reviewer to understand your changes fully. In that case, you can omit an explanation and instead include either “Fixes #XX” or “Updates #XX” where “XX” is the issue number.
Checklist
🛟 If you need help, consider asking for advice over in the Kinde community.
Summary by CodeRabbit