Skip to content

Commit f3072bd

Browse files
committed
Document Instance API
1 parent 90a053d commit f3072bd

6 files changed

Lines changed: 80 additions & 40 deletions

File tree

.typedoc/__tests__/file-structure.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ describe('Typedoc output', () => {
6464
"backend/email-address-api/methods",
6565
"backend/enterprise-connection-api",
6666
"backend/enterprise-connection-api/methods",
67+
"backend/instance-api",
68+
"backend/instance-api/methods",
6769
"backend/invitation-api",
6870
"backend/invitation-api/methods",
6971
"backend/m2-m-token-api",

.typedoc/reference-objects.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ export const BACKEND_API_CONFIG = {
140140
symbol: 'APIKeysAPI',
141141
declarationHint: 'api/endpoints/APIKeysApi',
142142
},
143+
'backend/instance-api/instance-api.mdx': {
144+
symbol: 'InstanceAPI',
145+
declarationHint: 'api/endpoints/InstanceApi',
146+
},
143147
};
144148

145149
/** Stable iteration order matches key order in {@link REFERENCE_OBJECT_CONFIG} then {@link BACKEND_API_CONFIG}. */

packages/backend/src/api/endpoints/InstanceApi.ts

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,81 +6,75 @@ import { AbstractAPI } from './AbstractApi';
66

77
const basePath = '/instance';
88

9-
type UpdateParams = {
10-
/**
11-
* Toggles test mode for this instance, allowing the use of test email addresses and phone numbers.
12-
*
13-
* @remarks Defaults to true for development instances.
14-
*/
9+
/** @generateWithEmptyComment */
10+
export type UpdateParams = {
11+
/** Toggles [test mode](https://clerk.com/docs/guides/development/testing/test-emails-and-phones#set-up-test-mode) for this instance, allowing the use of test email addresses and phone numbers. Defaults to `true` for development instances. */
1512
testMode?: boolean | null | undefined;
16-
/**
17-
* Whether the instance should be using the HIBP service to check passwords for breaches
18-
*/
13+
/** Whether the instance should be using the Have I Been Pwned (HIBP) service to check passwords for breaches. */
1914
hibp?: boolean | null | undefined;
20-
/**
21-
* The "enhanced_email_deliverability" feature will send emails from "verifications@clerk.dev" instead of your domain.
22-
*
23-
* @remarks This can be helpful if you do not have a high domain reputation.
24-
*/
15+
/** Whether the instance should send emails from "verifications@clerk.dev" instead of your domain. This can be helpful if you do not have a high domain reputation. */
2516
enhancedEmailDeliverability?: boolean | null | undefined;
17+
/** The support email for the instance. */
2618
supportEmail?: string | null | undefined;
19+
/** The npm version for `@clerk/clerk-js`. */
2720
clerkJsVersion?: string | null | undefined;
21+
/** The development origin for the instance. */
2822
developmentOrigin?: string | null | undefined;
29-
/**
30-
* For browser-like stacks such as browser extensions, Electron, or Capacitor.js the instance allowed origins need to be updated with the request origin value.
31-
*
32-
* @remarks For Chrome extensions popup, background, or service worker pages the origin is chrome-extension://extension_uiid. For Electron apps the default origin is http://localhost:3000. For Capacitor, the origin is capacitor://localhost.
33-
*/
23+
/** For browser-like stacks such as browser extensions, Electron, or Capacitor.js, the instance allowed origins need to be updated with the request origin value. For Chrome extensions popup, background, or service worker pages the origin is `chrome-extension://extension_uiid`. For Electron apps the default origin is `http://localhost:3000`. For Capacitor.js, the origin is `capacitor://localhost`. */
3424
allowedOrigins?: Array<string> | undefined;
35-
/**
36-
* Whether the instance should use URL-based session syncing in development mode (i.e. without third-party cookies).
37-
*/
25+
/** Whether the instance should use URL-based session syncing in development mode (i.e. without third-party cookies). */
3826
urlBasedSessionSyncing?: boolean | null | undefined;
39-
/**
40-
* Overrides the sign-in strategy that is preferred when a password is required.
41-
*
42-
* @remarks Accepts `'password'` or `'otp'`. Pass an empty string to clear the override. Passing `null` or `undefined` leaves the current value unchanged. The value is only consulted when a password is required, and is dormant otherwise.
43-
*/
27+
/** Overrides the sign-in strategy that is preferred when a password is required. The value is only consulted when a password is required, and is dormant otherwise. Pass an empty string to clear the override. Passing `null` or `undefined` leaves the current value unchanged. */
4428
preferredSignInStrategyWhenPasswordRequired?: 'password' | 'otp' | '' | null | undefined;
4529
};
4630

47-
type UpdateRestrictionsParams = {
31+
/** @generateWithEmptyComment */
32+
export type UpdateRestrictionsParams = {
33+
/** Whether the instance should have [**Allowlist**](https://clerk.com/docs/guides/secure/restricting-access#allowlist) enabled. */
4834
allowlist?: boolean | null | undefined;
35+
/** Whether the instance should have [**Blocklist**](https://clerk.com/docs/guides/secure/restricting-access#blocklist) enabled. */
4936
blocklist?: boolean | null | undefined;
37+
/** Whether the instance should have [**Block email subaddresses**](https://clerk.com/docs/guides/secure/restricting-access#block-email-subaddresses) enabled. */
5038
blockEmailSubaddresses?: boolean | null | undefined;
39+
/** Whether the instance should have [**Block sign-ups that use disposable email domains**](https://clerk.com/docs/guides/secure/restricting-access#block-sign-ups-that-use-disposable-email-addresses) enabled. */
5140
blockDisposableEmailDomains?: boolean | null | undefined;
41+
/** Whether the instance should [ignore dots for Gmail addresses](https://clerk.com/docs/guides/secure/restricting-access#block-email-subaddresses). */
5242
ignoreDotsForGmailAddresses?: boolean | null | undefined;
5343
};
5444

55-
type UpdateOrganizationSettingsParams = {
45+
/** @generateWithEmptyComment */
46+
export type UpdateOrganizationSettingsParams = {
47+
/** Whether the instance should enable [Organizations](https://clerk.com/docs/guides/organizations/overview). */
5648
enabled?: boolean | null | undefined;
49+
/** The maximum number of [memberships allowed](https://clerk.com/docs/guides/organizations/configure#membership-limits) per Organization. */
5750
maxAllowedMemberships?: number | null | undefined;
51+
/** Whether [Organization admins](https://clerk.com/docs/guides/organizations/control-access/roles-and-permissions#default-roles) are allowed to delete Organizations. */
5852
adminDeleteEnabled?: boolean | null | undefined;
53+
/** Whether [Verified Domains](https://clerk.com/docs/guides/organizations/add-members/verified-domains) are enabled for Organizations. */
5954
domainsEnabled?: boolean | null | undefined;
60-
/**
61-
* Specifies which [enrollment modes](https://clerk.com/docs/guides/organizations/add-members/verified-domains#enable-verified-domains) to enable for your Organization Domains.
62-
*
63-
* @remarks Supported modes are 'automatic_invitation' & 'automatic_suggestion'.
64-
*/
55+
/** Specifies which [enrollment modes](https://clerk.com/docs/guides/organizations/add-members/verified-domains#enable-verified-domains) to enable for your Organization's [Verified Domains](https://clerk.com/docs/guides/organizations/add-members/verified-domains). Supported modes are `'automatic_invitation'` & `'automatic_suggestion'`. */
6556
domainsEnrollmentModes?: Array<string> | undefined;
66-
/**
67-
* Specifies what the default Organization Role is for an Organization creator.
68-
*/
57+
/** Specifies what the default Organization [Role](https://clerk.com/docs/guides/organizations/control-access/roles-and-permissions) is for an Organization creator. */
6958
creatorRoleId?: string | null | undefined;
70-
/**
71-
* Specifies what the default Organization Role is for the Organization Domains.
72-
*/
59+
/** Specifies what the default Organization [Role](https://clerk.com/docs/guides/organizations/control-access/roles-and-permissions) is for the Organization's [Verified Domains](https://clerk.com/docs/guides/organizations/add-members/verified-domains). */
7360
domainsDefaultRoleId?: string | null | undefined;
7461
};
7562

63+
/** @generateWithEmptyComment */
7664
export class InstanceAPI extends AbstractAPI {
65+
/**
66+
* Gets the current [`Instance`](https://clerk.com/docs/reference/backend/types/backend-instance).
67+
*/
7768
public async get() {
7869
return this.request<Instance>({
7970
method: 'GET',
8071
path: basePath,
8172
});
8273
}
8374

75+
/**
76+
* Updates the current instance.
77+
*/
8478
public async update(params: UpdateParams) {
8579
return this.request<void>({
8680
method: 'PATCH',
@@ -89,6 +83,10 @@ export class InstanceAPI extends AbstractAPI {
8983
});
9084
}
9185

86+
/**
87+
* Updates the [restriction](https://clerk.com/docs/guides/secure/restricting-access) settings for the current instance.
88+
* @returns The updated [`InstanceRestrictions`](https://clerk.com/docs/reference/backend/types/backend-instance-restrictions).
89+
*/
9290
public async updateRestrictions(params: UpdateRestrictionsParams) {
9391
return this.request<InstanceRestrictions>({
9492
method: 'PATCH',
@@ -97,13 +95,20 @@ export class InstanceAPI extends AbstractAPI {
9795
});
9896
}
9997

98+
/**
99+
* Gets the [`OrganizationSettings`](https://clerk.com/docs/reference/backend/types/backend-organization-settings) for the current instance.
100+
*/
100101
public async getOrganizationSettings() {
101102
return this.request<OrganizationSettings>({
102103
method: 'GET',
103104
path: joinPaths(basePath, 'organization_settings'),
104105
});
105106
}
106107

108+
/**
109+
* Updates the [Organization-related settings](https://clerk.com/docs/guides/organizations/configure) for the current instance.
110+
* @returns The updated [`OrganizationSettings`](https://clerk.com/docs/reference/backend/types/backend-organization-settings).
111+
*/
107112
public async updateOrganizationSettings(params: UpdateOrganizationSettingsParams) {
108113
return this.request<OrganizationSettings>({
109114
method: 'PATCH',

packages/backend/src/api/resources/Instance.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import type { InstanceJSON } from './JSON';
22

3+
/** @generateWithEmptyComment */
34
export class Instance {
45
constructor(
6+
/** The unique identifier for the instance. */
57
readonly id: string,
8+
/** The type of instance environment, either `'production'` or `'development'`. */
69
readonly environmentType: string,
10+
/** For browser-like stacks such as browser extensions, Electron, or Capacitor.js, the instance allowed origins need to be updated with the request origin value. For Chrome extensions popup, background, or service worker pages the origin is `chrome-extension://extension_uiid`. For Electron apps the default origin is `http://localhost:3000`. For Capacitor.js, the origin is `capacitor://localhost`. */
711
readonly allowedOrigins: Array<string> | null,
812
) {}
913

packages/backend/src/api/resources/InstanceRestrictions.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import type { InstanceRestrictionsJSON } from './JSON';
22

3+
/** The `InstanceRestrictions` object represents the [restrictions](https://clerk.com/docs/guides/secure/restricting-access) settings for the current instance. */
34
export class InstanceRestrictions {
45
constructor(
6+
/** Whether the instance has [**Allowlist**](https://clerk.com/docs/guides/secure/restricting-access#allowlist) enabled. */
57
readonly allowlist: boolean,
8+
/** Whether the instance has [**Blocklist**](https://clerk.com/docs/guides/secure/restricting-access#blocklist) enabled. */
69
readonly blocklist: boolean,
10+
/** Whether the instance has [**Block email subaddresses**](https://clerk.com/docs/guides/secure/restricting-access#block-email-subaddresses) enabled. */
711
readonly blockEmailSubaddresses: boolean,
12+
/** Whether the instance has [**Block sign-ups that use disposable email domains**](https://clerk.com/docs/guides/secure/restricting-access#block-sign-ups-that-use-disposable-email-addresses) enabled. */
813
readonly blockDisposableEmailDomains: boolean,
14+
/** Whether the instance has [**Ignore dots for Gmail addresses**](https://clerk.com/docs/guides/secure/restricting-access#block-email-subaddresses) enabled. */
915
readonly ignoreDotsForGmailAddresses: boolean,
1016
) {}
1117

packages/backend/src/api/resources/OrganizationSettings.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
11
import type { DomainsEnrollmentModes } from './Enums';
22
import type { OrganizationSettingsJSON } from './JSON';
33

4+
/** The `OrganizationSettings` object represents the [Organization-related settings](https://clerk.com/docs/guides/organizations/configure) for the current instance. */
45
export class OrganizationSettings {
56
constructor(
7+
/** Whether the instance has [Organizations](https://clerk.com/docs/guides/organizations/overview) enabled. */
68
readonly enabled: boolean,
9+
/** The maximum number of [memberships allowed](https://clerk.com/docs/guides/organizations/configure#membership-limits) per Organization. */
710
readonly maxAllowedMemberships: number,
11+
/** The maximum number of [Roles allowed](https://clerk.com/docs/guides/organizations/configure#role-limits) per Organization. */
812
readonly maxAllowedRoles: number,
13+
/** The maximum number of [Permissions allowed](https://clerk.com/docs/guides/organizations/configure#permission-limits) per Organization. */
914
readonly maxAllowedPermissions: number,
15+
/** The default [Role](https://clerk.com/docs/guides/organizations/control-access/roles-and-permissions) for an Organization creator. */
1016
readonly creatorRole: string,
17+
/** Whether [admins](https://clerk.com/docs/guides/organizations/control-access/roles-and-permissions#default-roles) are allowed to delete Organizations. */
1118
readonly adminDeleteEnabled: boolean,
19+
/** Whether the instance has [Verified Domains](https://clerk.com/docs/guides/organizations/add-members/verified-domains) enabled. */
1220
readonly domainsEnabled: boolean,
21+
/** Whether the instance has [Organization slugs](https://clerk.com/docs/guides/organizations/add-members/verified-domains#organization-slugs) disabled. */
1322
readonly slugDisabled: boolean,
23+
/**
24+
* The [enrollment modes](https://clerk.com/docs/guides/organizations/add-members/verified-domains#enable-verified-domains) available for Verified Domains.
25+
*
26+
* <ul>
27+
* <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](https://clerk.com/docs/guides/organizations/control-access/roles-and-permissions#default-roles) must invite them manually.</li>
28+
* <li>`automatic_invitation`: Users with a matching email domain automatically receive a pending [invitation](https://clerk.com/docs/reference/types/organization-invitation) (assigned the Organization's default Role) which they can accept to join.</li>
29+
* <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>
30+
* </ul>
31+
*/
1432
readonly domainsEnrollmentModes: Array<DomainsEnrollmentModes>,
33+
/** The default [Role](https://clerk.com/docs/guides/organizations/control-access/roles-and-permissions) for the Organization's [Verified Domains](https://clerk.com/docs/guides/organizations/add-members/verified-domains). */
1534
readonly domainsDefaultRole: string,
1635
) {}
1736

0 commit comments

Comments
 (0)