Skip to content

Commit af706e3

Browse files
chore(shared): Add JSDocs to all organization resources (#8748)
Co-authored-by: Alexis Aguilar <98043211+alexisintech@users.noreply.github.com>
1 parent 955e998 commit af706e3

8 files changed

Lines changed: 343 additions & 20 deletions

.changeset/good-bottles-deny.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/shared': patch
3+
---
4+
5+
Add JSDoc comments to the Organization-related resource types (`OrganizationDomain`, `OrganizationCreationDefaults`, `OrganizationInvitation`, `OrganizationMembership`, `OrganizationMembershipRequest`, `OrganizationSettings`, and `OrganizationSuggestion`) to improve the generated Typedoc API docs

packages/shared/src/types/organizationCreationDefaults.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
import type { ClerkResourceJSON } from './json';
22
import type { ClerkResource } from './resource';
33

4+
/**
5+
* The type of advisory returned when computing the defaults for creating an Organization.
6+
*
7+
* @inline
8+
*/
49
export type OrganizationCreationAdvisoryType = 'organization_already_exists';
510

11+
/**
12+
* The severity of an advisory returned when computing the defaults for creating an Organization.
13+
*
14+
* @inline
15+
*/
616
export type OrganizationCreationAdvisorySeverity = 'warning';
717

818
export interface OrganizationCreationDefaultsJSON extends ClerkResourceJSON {
@@ -20,18 +30,47 @@ export interface OrganizationCreationDefaultsJSON extends ClerkResourceJSON {
2030
}
2131

2232
/**
33+
* The `OrganizationCreationDefaults` object holds the suggested default values to use when creating an Organization, along with an advisory surfacing a potential issue with the suggested defaults.
34+
*
2335
* @interface
2436
*/
2537
export interface OrganizationCreationDefaultsResource extends ClerkResource {
38+
/**
39+
* An advisory surfacing a potential issue with the suggested defaults, or `null` if there is none.
40+
*/
2641
advisory: {
42+
/**
43+
* The code identifying the advisory.
44+
*/
2745
code: OrganizationCreationAdvisoryType;
46+
/**
47+
* The severity of the advisory.
48+
*/
2849
severity: OrganizationCreationAdvisorySeverity;
50+
/**
51+
* Additional metadata providing context about the advisory.
52+
*/
2953
meta: Record<string, string>;
3054
} | null;
55+
/**
56+
* The suggested default values to pre-fill the Organization creation form with.
57+
*/
3158
form: {
59+
/**
60+
* The suggested Organization name.
61+
*/
3262
name: string;
63+
/**
64+
* The suggested URL-friendly identifier for the Organization.
65+
*/
3366
slug: string;
67+
/**
68+
* The suggested logo URL, or `null` if there is none.
69+
*/
3470
logo: string | null;
71+
/**
72+
* The blur hash of the suggested logo, used to render a placeholder while the image loads, or `null` if there is none.
73+
*/
3574
blurHash: string | null;
3675
};
3776
}
Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,138 @@
11
import type { ClerkResource } from './resource';
22

3+
/**
4+
* Holds the verification details of an Organization's [Verified Domain](https://clerk.com/docs/guides/organizations/add-members/verified-domains).
5+
*/
36
export interface OrganizationDomainVerification {
7+
/**
8+
* The current status of the domain verification.
9+
*/
410
status: OrganizationDomainVerificationStatus;
5-
strategy: 'email_code'; // only available value for now
11+
/**
12+
* The strategy used to verify the domain.
13+
*/
14+
strategy: OrganizationDomainVerificationStrategy;
15+
/**
16+
* The number of verification attempts that have been made.
17+
*/
618
attempts: number;
19+
/**
20+
* The date and time when the current verification attempt expires.
21+
*/
722
expiresAt: Date;
823
}
924

25+
/** @inline */
26+
type OrganizationDomainVerificationStrategy = 'email_code';
27+
1028
/** @inline */
1129
export type OrganizationDomainVerificationStatus = 'unverified' | 'verified';
1230

1331
/** @inline */
1432
export type OrganizationEnrollmentMode = 'manual_invitation' | 'automatic_invitation' | 'automatic_suggestion';
1533

1634
/**
17-
* The `OrganizationDomain` object is the model around an organization domain.
35+
* The `OrganizationDomain` object is the model around an Organization's [Verified Domain](https://clerk.com/docs/guides/organizations/add-members/verified-domains).
1836
*
1937
* @interface
2038
*/
2139
export interface OrganizationDomainResource extends ClerkResource {
40+
/**
41+
* The unique identifier for the Verified Domain.
42+
*/
2243
id: string;
44+
/**
45+
* The domain name, for example `clerk.com`.
46+
*/
2347
name: string;
48+
/**
49+
* The ID of the Organization that the Verified Domain belongs to.
50+
*/
2451
organizationId: string;
52+
/**
53+
* The enrollment mode that determines how matching users are added to the Organization.
54+
*
55+
* <ul>
56+
* <li>`manual_invitation`: No automatic enrollment. Users with a matching email domain are not given any [invitation](https://clerk.com/docs/guides/organizations/add-members/verified-domains#automatic-invitations) or [suggestion](https://clerk.com/docs/guides/organizations/add-members/verified-domains#automatic-suggestions); an admin must invite them manually.</li>
57+
* <li>`automatic_invitation`: Users with a matching email domain automatically receive a pending [invitation](https://clerk.com/docs/reference/types/organizationinvitation) (assigned the Organization's default role) which they can accept to join.</li>
58+
* <li>`automatic_suggestion`: Users with a matching email domain automatically receive a [suggestion](https://clerk.com/docs/guides/organizations/add-members/verified-domains#automatic-suggestions) to join, which they can request.</li>
59+
* </ul>
60+
*/
2561
enrollmentMode: OrganizationEnrollmentMode;
62+
/**
63+
* The verification details for the domain, or `null` if the domain has not been verified.
64+
*/
2665
verification: OrganizationDomainVerification | null;
66+
/**
67+
* The date and time when the domain was created.
68+
*/
2769
createdAt: Date;
70+
/**
71+
* The date and time when the domain was last updated.
72+
*/
2873
updatedAt: Date;
74+
/**
75+
* The email address used to verify the affiliation with the domain, or `null` if none has been provided.
76+
*/
2977
affiliationEmailAddress: string | null;
78+
/**
79+
* The total number of pending [invitations](https://clerk.com/docs/reference/types/organizationinvitation) associated with this domain.
80+
*/
3081
totalPendingInvitations: number;
82+
/**
83+
* The total number of pending [suggestions](https://clerk.com/docs/reference/types/organizationsuggestion) associated with this domain.
84+
*/
3185
totalPendingSuggestions: number;
86+
/**
87+
* Begins the affiliation verification flow by sending a verification code to the provided email address.
88+
*
89+
* @param params - The parameters containing the affiliation email address to verify.
90+
* @returns A promise that resolves to the updated `OrganizationDomain` object.
91+
*/
3292
prepareAffiliationVerification: (params: PrepareAffiliationVerificationParams) => Promise<OrganizationDomainResource>;
3393

94+
/**
95+
* Completes the affiliation verification flow by validating the code sent to the affiliation email address.
96+
*
97+
* @param params - The parameters containing the verification code.
98+
* @returns A promise that resolves to the updated `OrganizationDomain` object.
99+
*/
34100
attemptAffiliationVerification: (params: AttemptAffiliationVerificationParams) => Promise<OrganizationDomainResource>;
101+
/**
102+
* Deletes the Verified Domain.
103+
*
104+
* @returns A promise that resolves once the Verified Domain has been deleted.
105+
*/
35106
delete: () => Promise<void>;
107+
/**
108+
* Updates the enrollment mode of the Verified Domain.
109+
*
110+
* @param params - The parameters containing the new enrollment mode and whether to delete pending invitations or suggestions.
111+
* @returns A promise that resolves to the updated `OrganizationDomain` object.
112+
*/
36113
updateEnrollmentMode: (params: UpdateEnrollmentModeParams) => Promise<OrganizationDomainResource>;
37114
}
38115

116+
/** @generateWithEmptyComment */
39117
export type PrepareAffiliationVerificationParams = {
118+
/**
119+
* The email address, belonging to the domain, that the verification code is sent to.
120+
*/
40121
affiliationEmailAddress: string;
41122
};
42123

124+
/** @generateWithEmptyComment */
43125
export type AttemptAffiliationVerificationParams = {
126+
/**
127+
* The verification code that was sent to the affiliation email address.
128+
*/
44129
code: string;
45130
};
46131

132+
/** @generateWithEmptyComment */
47133
export type UpdateEnrollmentModeParams = Pick<OrganizationDomainResource, 'enrollmentMode'> & {
134+
/**
135+
* Whether to delete any pending [invitations](https://clerk.com/docs/reference/types/organizationinvitation) or [suggestions](https://clerk.com/docs/reference/types/organizationsuggestion) that were created by the previous enrollment mode.
136+
*/
48137
deletePending?: boolean;
49138
};

packages/shared/src/types/organizationInvitation.ts

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,67 @@ import type { ClerkResource } from './resource';
33

44
declare global {
55
/**
6-
* If you want to provide custom types for the organizationInvitation.publicMetadata
7-
* object, simply redeclare this rule in the global namespace.
8-
* Every OrganizationInvitation object will use the provided type.
6+
* If you want to provide custom types for the `organizationInvitation.publicMetadata` object, simply redeclare this rule in the global namespace. Every `OrganizationInvitation` will use the provided type.
97
*/
108
interface OrganizationInvitationPublicMetadata {
119
[k: string]: unknown;
1210
}
1311

12+
/**
13+
* If you want to provide custom types for the `organizationInvitation.privateMetadata` object, simply redeclare this rule in the global namespace. Every `OrganizationInvitation` will use the provided type.
14+
*/
1415
interface OrganizationInvitationPrivateMetadata {
1516
[k: string]: unknown;
1617
}
1718
}
1819

1920
/**
20-
* The `OrganizationInvitation` object is the model around an Organization invitation.
21+
* The `OrganizationInvitation` object is the model around [an invitation to join an Organization](https://clerk.com/docs/guides/organizations/add-members/invitations).
2122
*
2223
* @interface
2324
*/
2425
export interface OrganizationInvitationResource extends ClerkResource {
26+
/**
27+
* The unique identifier for the invitation.
28+
*/
2529
id: string;
30+
/**
31+
* The email address the invitation was sent to.
32+
*/
2633
emailAddress: string;
34+
/**
35+
* The ID of the Organization that the invitation is for.
36+
*/
2737
organizationId: string;
38+
/**
39+
* Metadata that can be read from both the [Frontend API](https://clerk.com/docs/reference/frontend-api){{ target: '_blank' }} and [Backend API](https://clerk.com/docs/reference/backend-api){{ target: '_blank' }}, but can be set only from the Backend API. Once the user accepts the invitation and signs up, these metadata will end up in the user's public metadata.
40+
*/
2841
publicMetadata: OrganizationInvitationPublicMetadata;
42+
/**
43+
* The [Role](https://clerk.com/docs/guides/organizations/control-access/roles-and-permissions) that the invited user will be assigned once they accept the invitation.
44+
*/
2945
role: OrganizationCustomRoleKey;
46+
/**
47+
* The name of the [Role](https://clerk.com/docs/guides/organizations/control-access/roles-and-permissions) that the invited user will be assigned.
48+
*/
3049
roleName: string;
50+
/**
51+
* The current status of the invitation.
52+
*/
3153
status: OrganizationInvitationStatus;
54+
/**
55+
* The date when the invitation was created.
56+
*/
3257
createdAt: Date;
58+
/**
59+
* The date when the invitation was last updated.
60+
*/
3361
updatedAt: Date;
62+
/**
63+
* Revokes the invitation so it can no longer be accepted.
64+
*
65+
* @returns A promise that resolves to the revoked [`OrganizationInvitation`](https://clerk.com/docs/reference/types/organization-invitation) object.
66+
*/
3467
revoke: () => Promise<OrganizationInvitationResource>;
3568
}
3669

0 commit comments

Comments
 (0)