Skip to content
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

Add missing properties in Organization & OrganizationInvitation resources #1468

Merged
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
5 changes: 5 additions & 0 deletions .changeset/breezy-fans-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/backend': patch
---

Add missing property 'adminDeleteEnabled' in Organization resource
6 changes: 6 additions & 0 deletions .changeset/cyan-foxes-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@clerk/clerk-js': patch
'@clerk/types': patch
---

Add missing property 'maxAllowedMemberships' in Organization resource
6 changes: 6 additions & 0 deletions .changeset/gentle-kings-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@clerk/backend': patch
'@clerk/types': patch
---

Add missing property 'privateMetadata' in OrganizationInvitation resource
2 changes: 2 additions & 0 deletions packages/backend/src/api/resources/JSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,14 @@ export interface OrganizationJSON extends ClerkResourceJSON {
created_at: number;
updated_at: number;
max_allowed_memberships: number;
admin_delete_enabled: boolean;
}

export interface OrganizationInvitationJSON extends ClerkResourceJSON {
email_address: string;
organization_id: string;
public_metadata: OrganizationInvitationPublicMetadata;
private_metadata: OrganizationInvitationPrivateMetadata;
role: OrganizationMembershipRole;
status: OrganizationInvitationStatus;
created_at: number;
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/api/resources/Organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class Organization {
readonly publicMetadata: OrganizationPublicMetadata | null = {},
readonly privateMetadata: OrganizationPrivateMetadata = {},
readonly maxAllowedMemberships: number,
readonly adminDeleteEnabled: boolean,
) {}

static fromJSON(data: OrganizationJSON): Organization {
Expand All @@ -28,6 +29,7 @@ export class Organization {
data.public_metadata,
data.private_metadata,
data.max_allowed_memberships,
data.admin_delete_enabled,
);
}
}
2 changes: 2 additions & 0 deletions packages/backend/src/api/resources/OrganizationInvitation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class OrganizationInvitation {
readonly updatedAt: number,
readonly status?: OrganizationInvitationStatus,
readonly publicMetadata: OrganizationInvitationPublicMetadata = {},
readonly privateMetadata: OrganizationInvitationPrivateMetadata = {},
) {}

static fromJSON(data: OrganizationInvitationJSON) {
Expand All @@ -23,6 +24,7 @@ export class OrganizationInvitation {
data.updated_at,
data.status,
data.public_metadata,
data.private_metadata,
);
}
}
2 changes: 2 additions & 0 deletions packages/clerk-js/src/core/resources/Organization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ describe('Organization', () => {
updated_at: 5678,
members_count: 1,
pending_invitations_count: 10,
admin_delete_enabled: true,
max_allowed_memberships: 3,
});

expect(organization).toMatchSnapshot();
Expand Down
2 changes: 2 additions & 0 deletions packages/clerk-js/src/core/resources/Organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class Organization extends BaseResource implements OrganizationResource {
updatedAt!: Date;
membersCount = 0;
pendingInvitationsCount = 0;
maxAllowedMemberships!: number;

constructor(data: OrganizationJSON) {
super();
Expand Down Expand Up @@ -180,6 +181,7 @@ export class Organization extends BaseResource implements OrganizationResource {
this.publicMetadata = data.public_metadata;
this.membersCount = data.members_count;
this.pendingInvitationsCount = data.pending_invitations_count;
this.maxAllowedMemberships = data.max_allowed_memberships;
this.adminDeleteEnabled = data.admin_delete_enabled;
this.createdAt = unixEpochToDate(data.created_at);
this.updatedAt = unixEpochToDate(data.updated_at);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ describe('OrganizationMembership', () => {
updated_at: 67890,
members_count: 1,
pending_invitations_count: 10,
admin_delete_enabled: true,
max_allowed_memberships: 3,
},
public_metadata: {
foo: 'bar',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`Organization has the same initial properties 1`] = `
Organization {
"addMember": [Function],
"adminDeleteEnabled": undefined,
"adminDeleteEnabled": true,
"createdAt": 1970-01-01T00:00:12.345Z,
"destroy": [Function],
"getMemberships": [Function],
Expand All @@ -13,6 +13,7 @@ Organization {
"inviteMember": [Function],
"inviteMembers": [Function],
"logoUrl": "https://url-for-logo.png",
"maxAllowedMemberships": 3,
"membersCount": 1,
"name": "test_name",
"pathRoot": "/organizations",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ OrganizationMembership {
"id": "test_id",
"organization": Organization {
"addMember": [Function],
"adminDeleteEnabled": undefined,
"adminDeleteEnabled": true,
"createdAt": 1970-01-01T00:00:12.345Z,
"destroy": [Function],
"getMemberships": [Function],
Expand All @@ -17,6 +17,7 @@ OrganizationMembership {
"inviteMember": [Function],
"inviteMembers": [Function],
"logoUrl": "https://path-to-logo.png",
"maxAllowedMemberships": 3,
"membersCount": 1,
"name": "test_name",
"pathRoot": "/organizations",
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ export interface OrganizationJSON extends ClerkResourceJSON {
members_count: number;
pending_invitations_count: number;
admin_delete_enabled: boolean;
max_allowed_memberships: number;
}

export interface OrganizationMembershipJSON extends ClerkResourceJSON {
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface OrganizationResource extends ClerkResource {
pendingInvitationsCount: number;
publicMetadata: OrganizationPublicMetadata;
adminDeleteEnabled: boolean;
maxAllowedMemberships: number;
createdAt: Date;
updatedAt: Date;
update: (params: UpdateOrganizationParams) => Promise<OrganizationResource>;
Expand Down
4 changes: 4 additions & 0 deletions packages/types/src/organizationInvitation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ declare global {
interface OrganizationInvitationPublicMetadata {
[k: string]: unknown;
}

interface OrganizationInvitationPrivateMetadata {
[k: string]: unknown;
}
}

export interface OrganizationInvitationResource extends ClerkResource {
Expand Down