Skip to content
Closed
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
2 changes: 2 additions & 0 deletions .changeset/thick-singers-pick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
### `createDomain()`

Creates a new domain.

Returns an [`OrganizationDomainResource`](/docs/reference/types/organization-domain-resource) object.

> [!WARNING]
> You must have [**Verified domains**](/docs/guides/organizations/add-members/verified-domains) enabled in your app's settings in the Clerk Dashboard.

```typescript
function createDomain(domainName: string, params?: Pick<CreateOrganizationDomainParams, "enrollmentMode">): Promise<OrganizationDomainResource>
```

#### Parameters


| Parameter | Type | Description |
| ------ | ------ | ------ |
| `domainName` | `string` | The name of the domain to create. |
| `params?` | `Pick`\<[`CreateOrganizationDomainParams`](#create-organization-domain-params), `"enrollmentMode"`\> | Optional parameters, including the `enrollmentMode` to assign to the new domain. |
| `params?.enrollmentMode?` | <code>"manual_invitation" \| "automatic_invitation" \| "automatic_suggestion" \| "enterprise_sso"</code> | The enrollment mode that determines how matching users are added to the Organization. Defaults to `manual_invitation`. |
6 changes: 6 additions & 0 deletions .typedoc/__tests__/extract-methods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { describe, expect, it } from 'vitest';
* - `methods/sign-out.mdx` – simple zero-arg callable
* - `methods/handle-redirect-callback.mdx` – multi-param `parametersTable` with nested rows
* - `methods/handle-email-link-verification.mdx` – required parent (`params`) flattened to `.`
* - `methods/create-domain.mdx` – `Pick<T, K>` parameter flattened to only the selected property
* - `methods/join-waitlist.mdx` – single nominal-param section (`JoinWaitlistParams`)
* - `methods/create.mdx` (api-key) – another single-nominal-param case + warning callout
* - `methods/check-authorization.mdx` – generic instantiation (`CheckAuthorization`)
Expand Down Expand Up @@ -45,6 +46,11 @@ describe('extract-methods snapshots', () => {
await expect(content).toMatchFileSnapshot('./__snapshots__/clerk-methods-handle-email-link-verification.mdx');
});

it('Pick parameter includes only selected properties: organization.createDomain()', async () => {
const content = await readGenerated('shared/organization-resource/methods/create-domain.mdx');
await expect(content).toMatchFileSnapshot('./__snapshots__/organization-resource-methods-create-domain.mdx');
});

it('single nominal-param section: clerk.joinWaitlist()', async () => {
const content = await readGenerated('shared/clerk/methods/join-waitlist.mdx');
await expect(content).toMatchFileSnapshot('./__snapshots__/clerk-methods-join-waitlist.mdx');
Expand Down
62 changes: 61 additions & 1 deletion .typedoc/custom-theme.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,40 @@ function hasDefaultValuesForParameters(parameters) {
}

/**
* Object shape for a parameter: inline `{ … }`, optional-wrapped, or reference to a type alias / interface.
* Collects string literal members from a type used as `Pick`'s key argument.
*
* @param {import('typedoc').Type | undefined} t
* @returns {string[] | undefined}
*/
function getPickPropertyNames(t) {
const unwrapped = unwrapOptional(t);
if (!unwrapped || typeof unwrapped !== 'object') {
return undefined;
}
if (unwrapped.type === 'literal') {
const literal = /** @type {import('typedoc').LiteralType} */ (unwrapped);
if (typeof literal.value === 'string') {
return [literal.value];
}
return undefined;
}
if (!isUnionTypeDoc(unwrapped)) {
return undefined;
}
const names = [];
const union = /** @type {import('typedoc').UnionType} */ (unwrapped);
for (const type of union.types) {
const nestedNames = getPickPropertyNames(type);
if (!nestedNames) {
return undefined;
}
names.push(...nestedNames);
}
return names;
}

/**
* Object shape for a parameter: inline `{ … }`, optional-wrapped, reference to a type alias / interface, or `Pick<T, K>` with literal keys.
*
* @param {import('typedoc').Type | undefined} t
* @returns {import('typedoc').DeclarationReflection | undefined}
Expand All @@ -470,6 +503,33 @@ function getParameterObjectShapeDeclaration(t) {
}
if (o.type === 'reference') {
const ref = /** @type {import('typedoc').ReferenceType} */ (t);
if (ref.name === 'Pick' && ref.package === 'typescript' && ref.typeArguments?.length === 2) {
const [sourceType, keysType] = ref.typeArguments;
const propertyNames = getPickPropertyNames(keysType);
if (!propertyNames?.length) {
return undefined;
}
const sourceDecl = getParameterObjectShapeDeclaration(sourceType);
const sourceRef = sourceType.type === 'reference' ? sourceType.reflection : undefined;
const sourceWithChildren =
sourceDecl ??
(sourceRef && 'children' in sourceRef
? /** @type {import('typedoc').DeclarationReflection} */ (sourceRef)
: undefined);
if (!sourceWithChildren?.children?.length) {
return undefined;
}
const selected = new Set(propertyNames);
const children = sourceWithChildren.children.filter(child => selected.has(child.name));
if (children.length !== selected.size) {
return undefined;
}
return /** @type {import('typedoc').DeclarationReflection} */ ({
...sourceWithChildren,
kind: ReflectionKind.TypeLiteral,
children,
});
}
const sym = ref.reflection;
if (!sym) {
return undefined;
Expand Down
Loading