feat(clerk-js): Add organization basic resources#57
Conversation
26c5337 to
09f9012
Compare
There was a problem hiding this comment.
@igneel64 As discussed we should align all models to use this._baseX(X=Post,Put, etc...) method for XHR requests.
| }) | ||
| .then(res => { | ||
| const organizationsJSON = res.payload | ||
| ?.response as unknown as OrganizationJSON[]; |
There was a problem hiding this comment.
❓ Just asking, why is the type assertion needed here?
I'd expect that we wouldn't need it because of the generic param in line 48:
.request<OrganizationJSON[]>({
Is this type broken?
| this.fromJSON(data); | ||
| } | ||
|
|
||
| static async create(name: string): Promise<OrganizationResource> { |
There was a problem hiding this comment.
❓ IIRC, all resources use the this.basePost | this.baseGet | ... methods that retrieve a json and return the instantiated resource. Why did we decide to use the static BaseResource._fetch here?
To be honest, I'm not a huge fan of the this.basePost approach, but if we don't have any specific reasons to do otherwise, I think it'd be better to remain consistent and tackle them all at once in a different PR
2e21552 to
1635132
Compare
| this.#fapiClient.onAfterResponse(callback); | ||
| } | ||
|
|
||
| __unstable_inviteMember = async ( |
There was a problem hiding this comment.
❓ @igneel64 Can you please elaborate why do we consider this an unstable method at this point?
There was a problem hiding this comment.
❓ A follow up question, does this method invite a member or creates an org? Something seems to be missing.
There was a problem hiding this comment.
@SokratisVidros , thanks for the comment.
The use of the __unstable prefix is intended here. Currently we cannot expose methods on clerk-react from internal clerk-js resources. The only way this can be done is through the Clerk interface.
The same interface though is exposed globally. That means that adding a method there, it is also exposed in window.Clerk.methodName.
Since adding methods indiscriminately on the global Clerk object is not the optimal outcome, for now we are adding to those methods the __unstable prefix to prevent misuse.
(Also this method just invites a member on an organization. The organizations can be retrieved from the useOrganizations hook.)
| const clerk = useClerk(); | ||
|
|
||
| return { | ||
| createOrganization: clerk.createOrganization, |
There was a problem hiding this comment.
🔧 Ditto about listing orgs.
087735f to
080c50b
Compare
…mechanism alignment Fix state clearing of organizationInvitationToken
080c50b to
fc11087
Compare
Type of change
Packages affected
@clerk/clerk-js@clerk/clerk-react@clerk/nextjs@clerk/types@clerk/clerk-expo@clerk/backend-core@clerk/clerk-sdk-node@clerk/edgebuild/tooling/choreDescription
npm testruns as expected.npm run buildruns as expected.First iteration of the organizations base resources:
OrganizationOrganizationMembershipOrganizationInvitation