-
Notifications
You must be signed in to change notification settings - Fork 50
Description
I have run into a couple of spots now where I wanted to use some WorkOS lib methods in an server-side component or Next.js API route. The getWorkOS() method is great for this, however, some complications arise when trying to work with the workos-node pkg interface. A couple of examples:
Invoking a workos-node method which requires an enum as a parameter, such as createOrganization():
import { getWorkOS } from '@workos-inc/authkit-nextjs';
const workOS = getWorkOS();
await workOS.organizations.createOrganization({
name: 'test',
domainData: [
{
domain: 'www.example.com',
state: 'verified' as any, // <-- breaks without "as any"
},
],
});The domainData[0].state argument is supposed to be the DomainDataState enum, but that enum is only exported in the workos-node package.
Another case (albeit more trivial) would be declaring methods or variables and attempting to strongly type them with a workos-node type:
import { getWorkOS } from '@workos-inc/authkit-nextjs';
const workOS = getWorkOS();
const organization: Organization = // "Organization" cannot be found without installing workos-node
await workOS.organizations.createOrganization({ name: 'test' });Would it be possible to export the types/interfaces/enums located within the bundled workos-node package? Ideally this shouldn't increase the export size by much (especially in a non-TS environment). If there is some discussion to be had about import syntax, I am happy to contribute.