@workos-inc/node 8.0.0-rc.7 → 8.0.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -0
- package/lib/api-keys/api-keys.cjs +3 -0
- package/lib/api-keys/api-keys.cjs.map +1 -1
- package/lib/api-keys/api-keys.d.cts +2 -1
- package/lib/api-keys/api-keys.d.ts +2 -1
- package/lib/api-keys/api-keys.js +3 -0
- package/lib/api-keys/api-keys.js.map +1 -1
- package/lib/api-keys/interfaces/create-organization-api-key-options.interface.cjs +0 -0
- package/lib/api-keys/interfaces/create-organization-api-key-options.interface.d.cts +16 -0
- package/lib/api-keys/interfaces/create-organization-api-key-options.interface.d.ts +16 -0
- package/lib/api-keys/interfaces/create-organization-api-key-options.interface.js +1 -0
- package/lib/api-keys/interfaces/created-api-key.interface.cjs +0 -0
- package/lib/api-keys/interfaces/created-api-key.interface.d.cts +34 -0
- package/lib/api-keys/interfaces/created-api-key.interface.d.ts +34 -0
- package/lib/api-keys/interfaces/created-api-key.interface.js +1 -0
- package/lib/api-keys/interfaces/index.cjs +0 -0
- package/lib/api-keys/interfaces/index.d.cts +6 -0
- package/lib/api-keys/interfaces/index.d.ts +6 -0
- package/lib/api-keys/interfaces/index.js +1 -0
- package/lib/api-keys/interfaces/list-organization-api-keys-options.interface.cjs +0 -0
- package/lib/api-keys/interfaces/list-organization-api-keys-options.interface.d.cts +9 -0
- package/lib/api-keys/interfaces/list-organization-api-keys-options.interface.d.ts +9 -0
- package/lib/api-keys/interfaces/list-organization-api-keys-options.interface.js +1 -0
- package/lib/api-keys/serializers/create-organization-api-key-options.serializer.cjs +12 -0
- package/lib/api-keys/serializers/create-organization-api-key-options.serializer.cjs.map +1 -0
- package/lib/api-keys/serializers/create-organization-api-key-options.serializer.d.cts +7 -0
- package/lib/api-keys/serializers/create-organization-api-key-options.serializer.d.ts +7 -0
- package/lib/api-keys/serializers/create-organization-api-key-options.serializer.js +11 -0
- package/lib/api-keys/serializers/create-organization-api-key-options.serializer.js.map +1 -0
- package/lib/api-keys/serializers/created-api-key.serializer.cjs +20 -0
- package/lib/api-keys/serializers/created-api-key.serializer.cjs.map +1 -0
- package/lib/api-keys/serializers/created-api-key.serializer.d.cts +7 -0
- package/lib/api-keys/serializers/created-api-key.serializer.d.ts +7 -0
- package/lib/api-keys/serializers/created-api-key.serializer.js +19 -0
- package/lib/api-keys/serializers/created-api-key.serializer.js.map +1 -0
- package/lib/api-keys/serializers/index.cjs +9 -0
- package/lib/api-keys/serializers/index.d.cts +5 -0
- package/lib/api-keys/serializers/index.d.ts +5 -0
- package/lib/api-keys/serializers/index.js +6 -0
- package/lib/common/exceptions/api-key-required.exception.cjs +15 -0
- package/lib/common/exceptions/api-key-required.exception.cjs.map +1 -0
- package/lib/common/exceptions/api-key-required.exception.d.cts +10 -0
- package/lib/common/exceptions/api-key-required.exception.d.ts +10 -0
- package/lib/common/exceptions/api-key-required.exception.js +14 -0
- package/lib/common/exceptions/api-key-required.exception.js.map +1 -0
- package/lib/common/exceptions/index.cjs +2 -0
- package/lib/common/exceptions/index.d.cts +2 -1
- package/lib/common/exceptions/index.d.ts +2 -1
- package/lib/common/exceptions/index.js +2 -1
- package/lib/common/interfaces/event.interface.d.cts +28 -3
- package/lib/common/interfaces/event.interface.d.ts +28 -3
- package/lib/common/interfaces/get-options.interface.d.cts +2 -0
- package/lib/common/interfaces/get-options.interface.d.ts +2 -0
- package/lib/common/interfaces/index.d.cts +2 -2
- package/lib/common/interfaces/index.d.ts +2 -2
- package/lib/common/interfaces/post-options.interface.d.cts +2 -0
- package/lib/common/interfaces/post-options.interface.d.ts +2 -0
- package/lib/common/interfaces/put-options.interface.d.cts +2 -0
- package/lib/common/interfaces/put-options.interface.d.ts +2 -0
- package/lib/common/interfaces/workos-options.interface.d.cts +1 -0
- package/lib/common/interfaces/workos-options.interface.d.ts +1 -0
- package/lib/common/net/http-client.cjs.map +1 -1
- package/lib/common/net/http-client.js.map +1 -1
- package/lib/common/serializers/event.serializer.cjs +13 -5
- package/lib/common/serializers/event.serializer.cjs.map +1 -1
- package/lib/common/serializers/event.serializer.js +13 -5
- package/lib/common/serializers/event.serializer.js.map +1 -1
- package/lib/directory-sync/directory-sync.cjs +1 -1
- package/lib/directory-sync/directory-sync.js +1 -1
- package/lib/factory.cjs +10 -0
- package/lib/factory.cjs.map +1 -0
- package/lib/factory.d.cts +83 -0
- package/lib/factory.d.ts +83 -0
- package/lib/factory.js +10 -0
- package/lib/factory.js.map +1 -0
- package/lib/feature-flags/feature-flags.cjs +37 -0
- package/lib/feature-flags/feature-flags.cjs.map +1 -0
- package/lib/feature-flags/feature-flags.d.cts +21 -0
- package/lib/feature-flags/feature-flags.d.ts +21 -0
- package/lib/feature-flags/feature-flags.js +37 -0
- package/lib/feature-flags/feature-flags.js.map +1 -0
- package/lib/feature-flags/interfaces/add-flag-target-options.interface.cjs +0 -0
- package/lib/feature-flags/interfaces/add-flag-target-options.interface.d.cts +8 -0
- package/lib/feature-flags/interfaces/add-flag-target-options.interface.d.ts +8 -0
- package/lib/feature-flags/interfaces/add-flag-target-options.interface.js +1 -0
- package/lib/feature-flags/interfaces/feature-flag.interface.d.cts +8 -2
- package/lib/feature-flags/interfaces/feature-flag.interface.d.ts +8 -2
- package/lib/feature-flags/interfaces/index.d.cts +4 -1
- package/lib/feature-flags/interfaces/index.d.ts +4 -1
- package/lib/feature-flags/interfaces/list-feature-flags-options.interface.cjs +0 -0
- package/lib/feature-flags/interfaces/list-feature-flags-options.interface.d.cts +7 -0
- package/lib/feature-flags/interfaces/list-feature-flags-options.interface.d.ts +7 -0
- package/lib/feature-flags/interfaces/list-feature-flags-options.interface.js +1 -0
- package/lib/feature-flags/interfaces/remove-flag-target-options.interface.cjs +0 -0
- package/lib/feature-flags/interfaces/remove-flag-target-options.interface.d.cts +8 -0
- package/lib/feature-flags/interfaces/remove-flag-target-options.interface.d.ts +8 -0
- package/lib/feature-flags/interfaces/remove-flag-target-options.interface.js +1 -0
- package/lib/feature-flags/serializers/feature-flag.serializer.cjs +3 -0
- package/lib/feature-flags/serializers/feature-flag.serializer.cjs.map +1 -1
- package/lib/feature-flags/serializers/feature-flag.serializer.js +3 -0
- package/lib/feature-flags/serializers/feature-flag.serializer.js.map +1 -1
- package/lib/feature-flags/serializers/index.cjs +3 -0
- package/lib/feature-flags/serializers/index.d.cts +2 -0
- package/lib/feature-flags/serializers/index.d.ts +2 -0
- package/lib/feature-flags/serializers/index.js +3 -0
- package/lib/fga/serializers/query-result.serializer.cjs.map +1 -1
- package/lib/fga/serializers/query-result.serializer.js.map +1 -1
- package/lib/index.cjs +18 -9
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +18 -5
- package/lib/index.d.ts +18 -5
- package/lib/index.js +16 -10
- package/lib/index.js.map +1 -1
- package/lib/index.worker.cjs +15 -9
- package/lib/index.worker.cjs.map +1 -1
- package/lib/index.worker.d.cts +10 -5
- package/lib/index.worker.d.ts +10 -5
- package/lib/index.worker.js +13 -10
- package/lib/index.worker.js.map +1 -1
- package/lib/organizations/organizations.cjs +14 -2
- package/lib/organizations/organizations.cjs.map +1 -1
- package/lib/organizations/organizations.d.cts +6 -0
- package/lib/organizations/organizations.d.ts +6 -0
- package/lib/organizations/organizations.js +14 -2
- package/lib/organizations/organizations.js.map +1 -1
- package/lib/organizations/serializers/index.cjs +1 -1
- package/lib/organizations/serializers/index.js +1 -1
- package/lib/pkce/pkce.cjs +54 -0
- package/lib/pkce/pkce.cjs.map +1 -0
- package/lib/pkce/pkce.d.cts +38 -0
- package/lib/pkce/pkce.d.ts +38 -0
- package/lib/pkce/pkce.js +53 -0
- package/lib/pkce/pkce.js.map +1 -0
- package/lib/sso/interfaces/authorization-url-options.interface.d.cts +34 -8
- package/lib/sso/interfaces/authorization-url-options.interface.d.ts +34 -8
- package/lib/sso/interfaces/get-profile-and-token-options.interface.d.cts +6 -0
- package/lib/sso/interfaces/get-profile-and-token-options.interface.d.ts +6 -0
- package/lib/sso/interfaces/index.d.cts +2 -2
- package/lib/sso/interfaces/index.d.ts +2 -2
- package/lib/sso/sso.cjs +90 -8
- package/lib/sso/sso.cjs.map +1 -1
- package/lib/sso/sso.d.cts +41 -2
- package/lib/sso/sso.d.ts +41 -2
- package/lib/sso/sso.js +90 -8
- package/lib/sso/sso.js.map +1 -1
- package/lib/user-management/interfaces/authenticate-with-code-and-verifier-options.interface.d.cts +2 -2
- package/lib/user-management/interfaces/authenticate-with-code-and-verifier-options.interface.d.ts +2 -2
- package/lib/user-management/interfaces/authenticate-with-options-base.interface.d.cts +19 -3
- package/lib/user-management/interfaces/authenticate-with-options-base.interface.d.ts +19 -3
- package/lib/user-management/interfaces/authenticate-with-refresh-token-public-client-options.interface.cjs +0 -0
- package/lib/user-management/interfaces/authenticate-with-refresh-token-public-client-options.interface.d.cts +16 -0
- package/lib/user-management/interfaces/authenticate-with-refresh-token-public-client-options.interface.d.ts +16 -0
- package/lib/user-management/interfaces/authenticate-with-refresh-token-public-client-options.interface.js +1 -0
- package/lib/user-management/interfaces/authorization-url-options.interface.d.cts +30 -5
- package/lib/user-management/interfaces/authorization-url-options.interface.d.ts +30 -5
- package/lib/user-management/interfaces/index.d.cts +5 -3
- package/lib/user-management/interfaces/index.d.ts +5 -3
- package/lib/user-management/interfaces/logout-url-options.interface.cjs +0 -0
- package/lib/user-management/interfaces/logout-url-options.interface.d.cts +8 -0
- package/lib/user-management/interfaces/logout-url-options.interface.d.ts +8 -0
- package/lib/user-management/interfaces/logout-url-options.interface.js +1 -0
- package/lib/user-management/serializers/authenticate-with-code-and-verifier-options.serializer.cjs.map +1 -1
- package/lib/user-management/serializers/authenticate-with-code-and-verifier-options.serializer.d.cts +2 -1
- package/lib/user-management/serializers/authenticate-with-code-and-verifier-options.serializer.d.ts +2 -1
- package/lib/user-management/serializers/authenticate-with-code-and-verifier-options.serializer.js.map +1 -1
- package/lib/user-management/serializers/authenticate-with-code-options.serializer.cjs.map +1 -1
- package/lib/user-management/serializers/authenticate-with-code-options.serializer.d.cts +2 -1
- package/lib/user-management/serializers/authenticate-with-code-options.serializer.d.ts +2 -1
- package/lib/user-management/serializers/authenticate-with-code-options.serializer.js.map +1 -1
- package/lib/user-management/serializers/authenticate-with-email-verification.serializer.cjs.map +1 -1
- package/lib/user-management/serializers/authenticate-with-email-verification.serializer.d.cts +2 -1
- package/lib/user-management/serializers/authenticate-with-email-verification.serializer.d.ts +2 -1
- package/lib/user-management/serializers/authenticate-with-email-verification.serializer.js.map +1 -1
- package/lib/user-management/serializers/authenticate-with-magic-auth-options.serializer.cjs.map +1 -1
- package/lib/user-management/serializers/authenticate-with-magic-auth-options.serializer.d.cts +2 -1
- package/lib/user-management/serializers/authenticate-with-magic-auth-options.serializer.d.ts +2 -1
- package/lib/user-management/serializers/authenticate-with-magic-auth-options.serializer.js.map +1 -1
- package/lib/user-management/serializers/authenticate-with-organization-selection-options.serializer.cjs.map +1 -1
- package/lib/user-management/serializers/authenticate-with-organization-selection-options.serializer.d.cts +2 -1
- package/lib/user-management/serializers/authenticate-with-organization-selection-options.serializer.d.ts +2 -1
- package/lib/user-management/serializers/authenticate-with-organization-selection-options.serializer.js.map +1 -1
- package/lib/user-management/serializers/authenticate-with-password-options.serializer.cjs.map +1 -1
- package/lib/user-management/serializers/authenticate-with-password-options.serializer.d.cts +2 -1
- package/lib/user-management/serializers/authenticate-with-password-options.serializer.d.ts +2 -1
- package/lib/user-management/serializers/authenticate-with-password-options.serializer.js.map +1 -1
- package/lib/user-management/serializers/authenticate-with-refresh-token-public-client-options.serializer.cjs +14 -0
- package/lib/user-management/serializers/authenticate-with-refresh-token-public-client-options.serializer.cjs.map +1 -0
- package/lib/user-management/serializers/authenticate-with-refresh-token-public-client-options.serializer.d.cts +8 -0
- package/lib/user-management/serializers/authenticate-with-refresh-token-public-client-options.serializer.d.ts +8 -0
- package/lib/user-management/serializers/authenticate-with-refresh-token-public-client-options.serializer.js +13 -0
- package/lib/user-management/serializers/authenticate-with-refresh-token-public-client-options.serializer.js.map +1 -0
- package/lib/user-management/serializers/authenticate-with-refresh-token.options.serializer.cjs.map +1 -1
- package/lib/user-management/serializers/authenticate-with-refresh-token.options.serializer.d.cts +2 -1
- package/lib/user-management/serializers/authenticate-with-refresh-token.options.serializer.d.ts +2 -1
- package/lib/user-management/serializers/authenticate-with-refresh-token.options.serializer.js.map +1 -1
- package/lib/user-management/serializers/authenticate-with-totp-options.serializer.cjs.map +1 -1
- package/lib/user-management/serializers/authenticate-with-totp-options.serializer.d.cts +2 -1
- package/lib/user-management/serializers/authenticate-with-totp-options.serializer.d.ts +2 -1
- package/lib/user-management/serializers/authenticate-with-totp-options.serializer.js.map +1 -1
- package/lib/user-management/serializers/index.cjs +2 -0
- package/lib/user-management/serializers/index.d.cts +2 -1
- package/lib/user-management/serializers/index.d.ts +2 -1
- package/lib/user-management/serializers/index.js +2 -1
- package/lib/user-management/session.cjs +3 -10
- package/lib/user-management/session.cjs.map +1 -1
- package/lib/user-management/session.js +3 -10
- package/lib/user-management/session.js.map +1 -1
- package/lib/user-management/user-management.cjs +186 -31
- package/lib/user-management/user-management.cjs.map +1 -1
- package/lib/user-management/user-management.d.cts +71 -2
- package/lib/user-management/user-management.d.ts +71 -2
- package/lib/user-management/user-management.js +186 -31
- package/lib/user-management/user-management.js.map +1 -1
- package/lib/vault/vault.cjs +4 -0
- package/lib/vault/vault.cjs.map +1 -1
- package/lib/vault/vault.d.cts +1 -0
- package/lib/vault/vault.d.ts +1 -0
- package/lib/vault/vault.js +4 -0
- package/lib/vault/vault.js.map +1 -1
- package/lib/webhooks/webhooks.cjs +1 -1
- package/lib/webhooks/webhooks.js +1 -1
- package/lib/workos.cjs +68 -26
- package/lib/workos.cjs.map +1 -1
- package/lib/workos.d.cts +37 -8
- package/lib/workos.d.ts +37 -8
- package/lib/workos.js +68 -26
- package/lib/workos.js.map +1 -1
- package/package.json +4 -21
- package/lib/_virtual/rolldown_runtime.cjs +0 -19
- package/lib/_virtual/rolldown_runtime.js +0 -18
- package/lib/client/index.cjs +0 -15
- package/lib/client/index.d.cts +0 -3
- package/lib/client/index.d.ts +0 -3
- package/lib/client/index.js +0 -4
- package/lib/client/sso.cjs +0 -40
- package/lib/client/sso.cjs.map +0 -1
- package/lib/client/sso.d.cts +0 -21
- package/lib/client/sso.d.ts +0 -21
- package/lib/client/sso.js +0 -34
- package/lib/client/sso.js.map +0 -1
- package/lib/client/user-management.cjs +0 -80
- package/lib/client/user-management.cjs.map +0 -1
- package/lib/client/user-management.d.cts +0 -58
- package/lib/client/user-management.d.ts +0 -58
- package/lib/client/user-management.js +0 -72
- package/lib/client/user-management.js.map +0 -1
- package/lib/index.client.cjs +0 -15
- package/lib/index.client.d.cts +0 -3
- package/lib/index.client.d.ts +0 -3
- package/lib/index.client.js +0 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
const require_common_utils_pagination = require('../common/utils/pagination.cjs');
|
|
1
2
|
const require_directory_sync_serializers_directory_group_serializer = require('./serializers/directory-group.serializer.cjs');
|
|
2
3
|
const require_directory_sync_serializers_directory_user_serializer = require('./serializers/directory-user.serializer.cjs');
|
|
3
4
|
const require_directory_sync_serializers_directory_serializer = require('./serializers/directory.serializer.cjs');
|
|
4
5
|
const require_directory_sync_serializers_list_directories_options_serializer = require('./serializers/list-directories-options.serializer.cjs');
|
|
5
|
-
const require_common_utils_pagination = require('../common/utils/pagination.cjs');
|
|
6
6
|
const require_common_utils_fetch_and_deserialize = require('../common/utils/fetch-and-deserialize.cjs');
|
|
7
7
|
|
|
8
8
|
//#region src/directory-sync/directory-sync.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { AutoPaginatable } from "../common/utils/pagination.js";
|
|
1
2
|
import { deserializeDirectoryGroup } from "./serializers/directory-group.serializer.js";
|
|
2
3
|
import { deserializeDirectoryUserWithGroups } from "./serializers/directory-user.serializer.js";
|
|
3
4
|
import { deserializeDirectory } from "./serializers/directory.serializer.js";
|
|
4
5
|
import { serializeListDirectoriesOptions } from "./serializers/list-directories-options.serializer.js";
|
|
5
|
-
import { AutoPaginatable } from "../common/utils/pagination.js";
|
|
6
6
|
import { fetchAndDeserialize } from "../common/utils/fetch-and-deserialize.js";
|
|
7
7
|
|
|
8
8
|
//#region src/directory-sync/directory-sync.ts
|
package/lib/factory.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.cjs","names":["WorkOS"],"sources":["../src/factory.ts"],"sourcesContent":["import { WorkOS } from './workos';\nimport type { UserManagement } from './user-management/user-management';\nimport type { SSO } from './sso/sso';\nimport type { PKCE } from './pkce/pkce';\nimport type { WorkOSOptions } from './common/interfaces';\n\n/**\n * Method names available without API key - single source of truth.\n * Add new public methods here to expose them on PublicUserManagement.\n */\ntype PublicUserManagementMethods =\n | 'getAuthorizationUrl'\n | 'getAuthorizationUrlWithPKCE'\n | 'authenticateWithCodeAndVerifier'\n | 'authenticateWithRefreshToken'\n | 'getLogoutUrl'\n | 'getJwksUrl';\n\n/**\n * SSO method names available without API key.\n */\ntype PublicSSOMethods = 'getAuthorizationUrl' | 'getAuthorizationUrlWithPKCE';\n\n/**\n * Subset of UserManagement methods available without an API key.\n * Used by public clients (browser, mobile, CLI, desktop apps).\n */\nexport type PublicUserManagement = Pick<\n UserManagement,\n PublicUserManagementMethods\n>;\n\n/**\n * Subset of SSO methods available without an API key.\n */\nexport type PublicSSO = Pick<SSO, PublicSSOMethods>;\n\n/**\n * WorkOS client for public/PKCE-only usage.\n * Returned when initialized with only clientId (no API key).\n *\n * For browser, mobile, CLI, and desktop applications that cannot\n * securely store an API key.\n */\nexport interface PublicWorkOS {\n readonly baseURL: string;\n readonly clientId: string;\n readonly pkce: PKCE;\n readonly userManagement: PublicUserManagement;\n readonly sso: PublicSSO;\n}\n\n/**\n * Options for creating a public client (PKCE-only, no API key).\n */\nexport interface PublicClientOptions extends Omit<WorkOSOptions, 'apiKey'> {\n clientId: string;\n /** Discriminant: ensures TypeScript selects PublicWorkOS overload when apiKey is absent */\n apiKey?: never;\n}\n\n/**\n * Options for creating a confidential client (with API key).\n */\nexport interface ConfidentialClientOptions extends WorkOSOptions {\n apiKey: string;\n}\n\n/**\n * Create a type-safe WorkOS client.\n *\n * Returns a narrowed `PublicWorkOS` type when only `clientId` is provided,\n * ensuring compile-time safety for public client usage. Returns the full\n * `WorkOS` type when an API key is provided.\n *\n * Unlike the `WorkOS` constructor, this factory does NOT read from\n * environment variables. Pass credentials explicitly for predictable types.\n *\n * @example\n * // Public client (browser, mobile, CLI) - returns PublicWorkOS\n * const workos = createWorkOS({ clientId: 'client_123' });\n * await workos.userManagement.getAuthorizationUrlWithPKCE({...}); // OK\n * workos.userManagement.listUsers(); // TypeScript error!\n *\n * @example\n * // Confidential client (server) - returns full WorkOS\n * const workos = createWorkOS({\n * apiKey: process.env.WORKOS_API_KEY!,\n * clientId: 'client_123'\n * });\n * await workos.userManagement.listUsers(); // OK\n */\nexport function createWorkOS(options: PublicClientOptions): PublicWorkOS;\nexport function createWorkOS(options: ConfidentialClientOptions): WorkOS;\nexport function createWorkOS(\n options: PublicClientOptions | ConfidentialClientOptions,\n): PublicWorkOS | WorkOS {\n return new WorkOS(options);\n}\n"],"mappings":";;;AA8FA,SAAgB,aACd,SACuB;AACvB,QAAO,IAAIA,sBAAO,QAAQ"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { WorkOSOptions } from "./common/interfaces/workos-options.interface.cjs";
|
|
2
|
+
import { PKCE } from "./pkce/pkce.cjs";
|
|
3
|
+
import { SSO } from "./sso/sso.cjs";
|
|
4
|
+
import { UserManagement } from "./user-management/user-management.cjs";
|
|
5
|
+
import { WorkOS } from "./workos.cjs";
|
|
6
|
+
|
|
7
|
+
//#region src/factory.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Method names available without API key - single source of truth.
|
|
11
|
+
* Add new public methods here to expose them on PublicUserManagement.
|
|
12
|
+
*/
|
|
13
|
+
type PublicUserManagementMethods = 'getAuthorizationUrl' | 'getAuthorizationUrlWithPKCE' | 'authenticateWithCodeAndVerifier' | 'authenticateWithRefreshToken' | 'getLogoutUrl' | 'getJwksUrl';
|
|
14
|
+
/**
|
|
15
|
+
* SSO method names available without API key.
|
|
16
|
+
*/
|
|
17
|
+
type PublicSSOMethods = 'getAuthorizationUrl' | 'getAuthorizationUrlWithPKCE';
|
|
18
|
+
/**
|
|
19
|
+
* Subset of UserManagement methods available without an API key.
|
|
20
|
+
* Used by public clients (browser, mobile, CLI, desktop apps).
|
|
21
|
+
*/
|
|
22
|
+
type PublicUserManagement = Pick<UserManagement, PublicUserManagementMethods>;
|
|
23
|
+
/**
|
|
24
|
+
* Subset of SSO methods available without an API key.
|
|
25
|
+
*/
|
|
26
|
+
type PublicSSO = Pick<SSO, PublicSSOMethods>;
|
|
27
|
+
/**
|
|
28
|
+
* WorkOS client for public/PKCE-only usage.
|
|
29
|
+
* Returned when initialized with only clientId (no API key).
|
|
30
|
+
*
|
|
31
|
+
* For browser, mobile, CLI, and desktop applications that cannot
|
|
32
|
+
* securely store an API key.
|
|
33
|
+
*/
|
|
34
|
+
interface PublicWorkOS {
|
|
35
|
+
readonly baseURL: string;
|
|
36
|
+
readonly clientId: string;
|
|
37
|
+
readonly pkce: PKCE;
|
|
38
|
+
readonly userManagement: PublicUserManagement;
|
|
39
|
+
readonly sso: PublicSSO;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Options for creating a public client (PKCE-only, no API key).
|
|
43
|
+
*/
|
|
44
|
+
interface PublicClientOptions extends Omit<WorkOSOptions, 'apiKey'> {
|
|
45
|
+
clientId: string;
|
|
46
|
+
/** Discriminant: ensures TypeScript selects PublicWorkOS overload when apiKey is absent */
|
|
47
|
+
apiKey?: never;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Options for creating a confidential client (with API key).
|
|
51
|
+
*/
|
|
52
|
+
interface ConfidentialClientOptions extends WorkOSOptions {
|
|
53
|
+
apiKey: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Create a type-safe WorkOS client.
|
|
57
|
+
*
|
|
58
|
+
* Returns a narrowed `PublicWorkOS` type when only `clientId` is provided,
|
|
59
|
+
* ensuring compile-time safety for public client usage. Returns the full
|
|
60
|
+
* `WorkOS` type when an API key is provided.
|
|
61
|
+
*
|
|
62
|
+
* Unlike the `WorkOS` constructor, this factory does NOT read from
|
|
63
|
+
* environment variables. Pass credentials explicitly for predictable types.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* // Public client (browser, mobile, CLI) - returns PublicWorkOS
|
|
67
|
+
* const workos = createWorkOS({ clientId: 'client_123' });
|
|
68
|
+
* await workos.userManagement.getAuthorizationUrlWithPKCE({...}); // OK
|
|
69
|
+
* workos.userManagement.listUsers(); // TypeScript error!
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* // Confidential client (server) - returns full WorkOS
|
|
73
|
+
* const workos = createWorkOS({
|
|
74
|
+
* apiKey: process.env.WORKOS_API_KEY!,
|
|
75
|
+
* clientId: 'client_123'
|
|
76
|
+
* });
|
|
77
|
+
* await workos.userManagement.listUsers(); // OK
|
|
78
|
+
*/
|
|
79
|
+
declare function createWorkOS(options: PublicClientOptions): PublicWorkOS;
|
|
80
|
+
declare function createWorkOS(options: ConfidentialClientOptions): WorkOS;
|
|
81
|
+
//#endregion
|
|
82
|
+
export { ConfidentialClientOptions, PublicClientOptions, PublicSSO, PublicUserManagement, PublicWorkOS, createWorkOS };
|
|
83
|
+
//# sourceMappingURL=factory.d.cts.map
|
package/lib/factory.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { WorkOSOptions } from "./common/interfaces/workos-options.interface.js";
|
|
2
|
+
import { PKCE } from "./pkce/pkce.js";
|
|
3
|
+
import { SSO } from "./sso/sso.js";
|
|
4
|
+
import { UserManagement } from "./user-management/user-management.js";
|
|
5
|
+
import { WorkOS } from "./workos.js";
|
|
6
|
+
|
|
7
|
+
//#region src/factory.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Method names available without API key - single source of truth.
|
|
11
|
+
* Add new public methods here to expose them on PublicUserManagement.
|
|
12
|
+
*/
|
|
13
|
+
type PublicUserManagementMethods = 'getAuthorizationUrl' | 'getAuthorizationUrlWithPKCE' | 'authenticateWithCodeAndVerifier' | 'authenticateWithRefreshToken' | 'getLogoutUrl' | 'getJwksUrl';
|
|
14
|
+
/**
|
|
15
|
+
* SSO method names available without API key.
|
|
16
|
+
*/
|
|
17
|
+
type PublicSSOMethods = 'getAuthorizationUrl' | 'getAuthorizationUrlWithPKCE';
|
|
18
|
+
/**
|
|
19
|
+
* Subset of UserManagement methods available without an API key.
|
|
20
|
+
* Used by public clients (browser, mobile, CLI, desktop apps).
|
|
21
|
+
*/
|
|
22
|
+
type PublicUserManagement = Pick<UserManagement, PublicUserManagementMethods>;
|
|
23
|
+
/**
|
|
24
|
+
* Subset of SSO methods available without an API key.
|
|
25
|
+
*/
|
|
26
|
+
type PublicSSO = Pick<SSO, PublicSSOMethods>;
|
|
27
|
+
/**
|
|
28
|
+
* WorkOS client for public/PKCE-only usage.
|
|
29
|
+
* Returned when initialized with only clientId (no API key).
|
|
30
|
+
*
|
|
31
|
+
* For browser, mobile, CLI, and desktop applications that cannot
|
|
32
|
+
* securely store an API key.
|
|
33
|
+
*/
|
|
34
|
+
interface PublicWorkOS {
|
|
35
|
+
readonly baseURL: string;
|
|
36
|
+
readonly clientId: string;
|
|
37
|
+
readonly pkce: PKCE;
|
|
38
|
+
readonly userManagement: PublicUserManagement;
|
|
39
|
+
readonly sso: PublicSSO;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Options for creating a public client (PKCE-only, no API key).
|
|
43
|
+
*/
|
|
44
|
+
interface PublicClientOptions extends Omit<WorkOSOptions, 'apiKey'> {
|
|
45
|
+
clientId: string;
|
|
46
|
+
/** Discriminant: ensures TypeScript selects PublicWorkOS overload when apiKey is absent */
|
|
47
|
+
apiKey?: never;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Options for creating a confidential client (with API key).
|
|
51
|
+
*/
|
|
52
|
+
interface ConfidentialClientOptions extends WorkOSOptions {
|
|
53
|
+
apiKey: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Create a type-safe WorkOS client.
|
|
57
|
+
*
|
|
58
|
+
* Returns a narrowed `PublicWorkOS` type when only `clientId` is provided,
|
|
59
|
+
* ensuring compile-time safety for public client usage. Returns the full
|
|
60
|
+
* `WorkOS` type when an API key is provided.
|
|
61
|
+
*
|
|
62
|
+
* Unlike the `WorkOS` constructor, this factory does NOT read from
|
|
63
|
+
* environment variables. Pass credentials explicitly for predictable types.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* // Public client (browser, mobile, CLI) - returns PublicWorkOS
|
|
67
|
+
* const workos = createWorkOS({ clientId: 'client_123' });
|
|
68
|
+
* await workos.userManagement.getAuthorizationUrlWithPKCE({...}); // OK
|
|
69
|
+
* workos.userManagement.listUsers(); // TypeScript error!
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* // Confidential client (server) - returns full WorkOS
|
|
73
|
+
* const workos = createWorkOS({
|
|
74
|
+
* apiKey: process.env.WORKOS_API_KEY!,
|
|
75
|
+
* clientId: 'client_123'
|
|
76
|
+
* });
|
|
77
|
+
* await workos.userManagement.listUsers(); // OK
|
|
78
|
+
*/
|
|
79
|
+
declare function createWorkOS(options: PublicClientOptions): PublicWorkOS;
|
|
80
|
+
declare function createWorkOS(options: ConfidentialClientOptions): WorkOS;
|
|
81
|
+
//#endregion
|
|
82
|
+
export { ConfidentialClientOptions, PublicClientOptions, PublicSSO, PublicUserManagement, PublicWorkOS, createWorkOS };
|
|
83
|
+
//# sourceMappingURL=factory.d.ts.map
|
package/lib/factory.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","names":[],"sources":["../src/factory.ts"],"sourcesContent":["import { WorkOS } from './workos';\nimport type { UserManagement } from './user-management/user-management';\nimport type { SSO } from './sso/sso';\nimport type { PKCE } from './pkce/pkce';\nimport type { WorkOSOptions } from './common/interfaces';\n\n/**\n * Method names available without API key - single source of truth.\n * Add new public methods here to expose them on PublicUserManagement.\n */\ntype PublicUserManagementMethods =\n | 'getAuthorizationUrl'\n | 'getAuthorizationUrlWithPKCE'\n | 'authenticateWithCodeAndVerifier'\n | 'authenticateWithRefreshToken'\n | 'getLogoutUrl'\n | 'getJwksUrl';\n\n/**\n * SSO method names available without API key.\n */\ntype PublicSSOMethods = 'getAuthorizationUrl' | 'getAuthorizationUrlWithPKCE';\n\n/**\n * Subset of UserManagement methods available without an API key.\n * Used by public clients (browser, mobile, CLI, desktop apps).\n */\nexport type PublicUserManagement = Pick<\n UserManagement,\n PublicUserManagementMethods\n>;\n\n/**\n * Subset of SSO methods available without an API key.\n */\nexport type PublicSSO = Pick<SSO, PublicSSOMethods>;\n\n/**\n * WorkOS client for public/PKCE-only usage.\n * Returned when initialized with only clientId (no API key).\n *\n * For browser, mobile, CLI, and desktop applications that cannot\n * securely store an API key.\n */\nexport interface PublicWorkOS {\n readonly baseURL: string;\n readonly clientId: string;\n readonly pkce: PKCE;\n readonly userManagement: PublicUserManagement;\n readonly sso: PublicSSO;\n}\n\n/**\n * Options for creating a public client (PKCE-only, no API key).\n */\nexport interface PublicClientOptions extends Omit<WorkOSOptions, 'apiKey'> {\n clientId: string;\n /** Discriminant: ensures TypeScript selects PublicWorkOS overload when apiKey is absent */\n apiKey?: never;\n}\n\n/**\n * Options for creating a confidential client (with API key).\n */\nexport interface ConfidentialClientOptions extends WorkOSOptions {\n apiKey: string;\n}\n\n/**\n * Create a type-safe WorkOS client.\n *\n * Returns a narrowed `PublicWorkOS` type when only `clientId` is provided,\n * ensuring compile-time safety for public client usage. Returns the full\n * `WorkOS` type when an API key is provided.\n *\n * Unlike the `WorkOS` constructor, this factory does NOT read from\n * environment variables. Pass credentials explicitly for predictable types.\n *\n * @example\n * // Public client (browser, mobile, CLI) - returns PublicWorkOS\n * const workos = createWorkOS({ clientId: 'client_123' });\n * await workos.userManagement.getAuthorizationUrlWithPKCE({...}); // OK\n * workos.userManagement.listUsers(); // TypeScript error!\n *\n * @example\n * // Confidential client (server) - returns full WorkOS\n * const workos = createWorkOS({\n * apiKey: process.env.WORKOS_API_KEY!,\n * clientId: 'client_123'\n * });\n * await workos.userManagement.listUsers(); // OK\n */\nexport function createWorkOS(options: PublicClientOptions): PublicWorkOS;\nexport function createWorkOS(options: ConfidentialClientOptions): WorkOS;\nexport function createWorkOS(\n options: PublicClientOptions | ConfidentialClientOptions,\n): PublicWorkOS | WorkOS {\n return new WorkOS(options);\n}\n"],"mappings":";;;AA8FA,SAAgB,aACd,SACuB;AACvB,QAAO,IAAI,OAAO,QAAQ"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const require_common_utils_pagination = require('../common/utils/pagination.cjs');
|
|
2
|
+
const require_common_utils_fetch_and_deserialize = require('../common/utils/fetch-and-deserialize.cjs');
|
|
3
|
+
const require_feature_flags_serializers_feature_flag_serializer = require('./serializers/feature-flag.serializer.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/feature-flags/feature-flags.ts
|
|
6
|
+
var FeatureFlags = class {
|
|
7
|
+
constructor(workos) {
|
|
8
|
+
this.workos = workos;
|
|
9
|
+
}
|
|
10
|
+
async listFeatureFlags(options) {
|
|
11
|
+
return new require_common_utils_pagination.AutoPaginatable(await require_common_utils_fetch_and_deserialize.fetchAndDeserialize(this.workos, "/feature-flags", require_feature_flags_serializers_feature_flag_serializer.deserializeFeatureFlag, options), (params) => require_common_utils_fetch_and_deserialize.fetchAndDeserialize(this.workos, "/feature-flags", require_feature_flags_serializers_feature_flag_serializer.deserializeFeatureFlag, params), options);
|
|
12
|
+
}
|
|
13
|
+
async getFeatureFlag(slug) {
|
|
14
|
+
const { data } = await this.workos.get(`/feature-flags/${slug}`);
|
|
15
|
+
return require_feature_flags_serializers_feature_flag_serializer.deserializeFeatureFlag(data);
|
|
16
|
+
}
|
|
17
|
+
async enableFeatureFlag(slug) {
|
|
18
|
+
const { data } = await this.workos.put(`/feature-flags/${slug}/enable`, {});
|
|
19
|
+
return require_feature_flags_serializers_feature_flag_serializer.deserializeFeatureFlag(data);
|
|
20
|
+
}
|
|
21
|
+
async disableFeatureFlag(slug) {
|
|
22
|
+
const { data } = await this.workos.put(`/feature-flags/${slug}/disable`, {});
|
|
23
|
+
return require_feature_flags_serializers_feature_flag_serializer.deserializeFeatureFlag(data);
|
|
24
|
+
}
|
|
25
|
+
async addFlagTarget(options) {
|
|
26
|
+
const { slug, targetId } = options;
|
|
27
|
+
await this.workos.post(`/feature-flags/${slug}/targets/${targetId}`, {});
|
|
28
|
+
}
|
|
29
|
+
async removeFlagTarget(options) {
|
|
30
|
+
const { slug, targetId } = options;
|
|
31
|
+
await this.workos.delete(`/feature-flags/${slug}/targets/${targetId}`);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
exports.FeatureFlags = FeatureFlags;
|
|
37
|
+
//# sourceMappingURL=feature-flags.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature-flags.cjs","names":["workos: WorkOS","AutoPaginatable","fetchAndDeserialize","deserializeFeatureFlag"],"sources":["../../src/feature-flags/feature-flags.ts"],"sourcesContent":["import { AutoPaginatable } from '../common/utils/pagination';\nimport { WorkOS } from '../workos';\nimport {\n AddFlagTargetOptions,\n FeatureFlag,\n FeatureFlagResponse,\n ListFeatureFlagsOptions,\n RemoveFlagTargetOptions,\n} from './interfaces';\nimport { deserializeFeatureFlag } from './serializers';\nimport { fetchAndDeserialize } from '../common/utils/fetch-and-deserialize';\n\nexport class FeatureFlags {\n constructor(private readonly workos: WorkOS) {}\n\n async listFeatureFlags(\n options?: ListFeatureFlagsOptions,\n ): Promise<AutoPaginatable<FeatureFlag>> {\n return new AutoPaginatable(\n await fetchAndDeserialize<FeatureFlagResponse, FeatureFlag>(\n this.workos,\n '/feature-flags',\n deserializeFeatureFlag,\n options,\n ),\n (params) =>\n fetchAndDeserialize<FeatureFlagResponse, FeatureFlag>(\n this.workos,\n '/feature-flags',\n deserializeFeatureFlag,\n params,\n ),\n options,\n );\n }\n\n async getFeatureFlag(slug: string): Promise<FeatureFlag> {\n const { data } = await this.workos.get<FeatureFlagResponse>(\n `/feature-flags/${slug}`,\n );\n\n return deserializeFeatureFlag(data);\n }\n\n async enableFeatureFlag(slug: string): Promise<FeatureFlag> {\n const { data } = await this.workos.put<FeatureFlagResponse>(\n `/feature-flags/${slug}/enable`,\n {},\n );\n\n return deserializeFeatureFlag(data);\n }\n\n async disableFeatureFlag(slug: string): Promise<FeatureFlag> {\n const { data } = await this.workos.put<FeatureFlagResponse>(\n `/feature-flags/${slug}/disable`,\n {},\n );\n\n return deserializeFeatureFlag(data);\n }\n\n async addFlagTarget(options: AddFlagTargetOptions): Promise<void> {\n const { slug, targetId } = options;\n await this.workos.post(`/feature-flags/${slug}/targets/${targetId}`, {});\n }\n\n async removeFlagTarget(options: RemoveFlagTargetOptions): Promise<void> {\n const { slug, targetId } = options;\n await this.workos.delete(`/feature-flags/${slug}/targets/${targetId}`);\n }\n}\n"],"mappings":";;;;;AAYA,IAAa,eAAb,MAA0B;CACxB,YAAY,AAAiBA,QAAgB;EAAhB;;CAE7B,MAAM,iBACJ,SACuC;AACvC,SAAO,IAAIC,gDACT,MAAMC,+DACJ,KAAK,QACL,kBACAC,kFACA,QACD,GACA,WACCD,+DACE,KAAK,QACL,kBACAC,kFACA,OACD,EACH,QACD;;CAGH,MAAM,eAAe,MAAoC;EACvD,MAAM,EAAE,SAAS,MAAM,KAAK,OAAO,IACjC,kBAAkB,OACnB;AAED,SAAOA,iFAAuB,KAAK;;CAGrC,MAAM,kBAAkB,MAAoC;EAC1D,MAAM,EAAE,SAAS,MAAM,KAAK,OAAO,IACjC,kBAAkB,KAAK,UACvB,EAAE,CACH;AAED,SAAOA,iFAAuB,KAAK;;CAGrC,MAAM,mBAAmB,MAAoC;EAC3D,MAAM,EAAE,SAAS,MAAM,KAAK,OAAO,IACjC,kBAAkB,KAAK,WACvB,EAAE,CACH;AAED,SAAOA,iFAAuB,KAAK;;CAGrC,MAAM,cAAc,SAA8C;EAChE,MAAM,EAAE,MAAM,aAAa;AAC3B,QAAM,KAAK,OAAO,KAAK,kBAAkB,KAAK,WAAW,YAAY,EAAE,CAAC;;CAG1E,MAAM,iBAAiB,SAAiD;EACtE,MAAM,EAAE,MAAM,aAAa;AAC3B,QAAM,KAAK,OAAO,OAAO,kBAAkB,KAAK,WAAW,WAAW"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AutoPaginatable } from "../common/utils/pagination.cjs";
|
|
2
|
+
import { FeatureFlag } from "./interfaces/feature-flag.interface.cjs";
|
|
3
|
+
import { AddFlagTargetOptions } from "./interfaces/add-flag-target-options.interface.cjs";
|
|
4
|
+
import { ListFeatureFlagsOptions } from "./interfaces/list-feature-flags-options.interface.cjs";
|
|
5
|
+
import { RemoveFlagTargetOptions } from "./interfaces/remove-flag-target-options.interface.cjs";
|
|
6
|
+
import { WorkOS } from "../workos.cjs";
|
|
7
|
+
|
|
8
|
+
//#region src/feature-flags/feature-flags.d.ts
|
|
9
|
+
declare class FeatureFlags {
|
|
10
|
+
private readonly workos;
|
|
11
|
+
constructor(workos: WorkOS);
|
|
12
|
+
listFeatureFlags(options?: ListFeatureFlagsOptions): Promise<AutoPaginatable<FeatureFlag>>;
|
|
13
|
+
getFeatureFlag(slug: string): Promise<FeatureFlag>;
|
|
14
|
+
enableFeatureFlag(slug: string): Promise<FeatureFlag>;
|
|
15
|
+
disableFeatureFlag(slug: string): Promise<FeatureFlag>;
|
|
16
|
+
addFlagTarget(options: AddFlagTargetOptions): Promise<void>;
|
|
17
|
+
removeFlagTarget(options: RemoveFlagTargetOptions): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { FeatureFlags };
|
|
21
|
+
//# sourceMappingURL=feature-flags.d.cts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AutoPaginatable } from "../common/utils/pagination.js";
|
|
2
|
+
import { FeatureFlag } from "./interfaces/feature-flag.interface.js";
|
|
3
|
+
import { AddFlagTargetOptions } from "./interfaces/add-flag-target-options.interface.js";
|
|
4
|
+
import { ListFeatureFlagsOptions } from "./interfaces/list-feature-flags-options.interface.js";
|
|
5
|
+
import { RemoveFlagTargetOptions } from "./interfaces/remove-flag-target-options.interface.js";
|
|
6
|
+
import { WorkOS } from "../workos.js";
|
|
7
|
+
|
|
8
|
+
//#region src/feature-flags/feature-flags.d.ts
|
|
9
|
+
declare class FeatureFlags {
|
|
10
|
+
private readonly workos;
|
|
11
|
+
constructor(workos: WorkOS);
|
|
12
|
+
listFeatureFlags(options?: ListFeatureFlagsOptions): Promise<AutoPaginatable<FeatureFlag>>;
|
|
13
|
+
getFeatureFlag(slug: string): Promise<FeatureFlag>;
|
|
14
|
+
enableFeatureFlag(slug: string): Promise<FeatureFlag>;
|
|
15
|
+
disableFeatureFlag(slug: string): Promise<FeatureFlag>;
|
|
16
|
+
addFlagTarget(options: AddFlagTargetOptions): Promise<void>;
|
|
17
|
+
removeFlagTarget(options: RemoveFlagTargetOptions): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { FeatureFlags };
|
|
21
|
+
//# sourceMappingURL=feature-flags.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AutoPaginatable } from "../common/utils/pagination.js";
|
|
2
|
+
import { fetchAndDeserialize } from "../common/utils/fetch-and-deserialize.js";
|
|
3
|
+
import { deserializeFeatureFlag } from "./serializers/feature-flag.serializer.js";
|
|
4
|
+
|
|
5
|
+
//#region src/feature-flags/feature-flags.ts
|
|
6
|
+
var FeatureFlags = class {
|
|
7
|
+
constructor(workos) {
|
|
8
|
+
this.workos = workos;
|
|
9
|
+
}
|
|
10
|
+
async listFeatureFlags(options) {
|
|
11
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/feature-flags", deserializeFeatureFlag, options), (params) => fetchAndDeserialize(this.workos, "/feature-flags", deserializeFeatureFlag, params), options);
|
|
12
|
+
}
|
|
13
|
+
async getFeatureFlag(slug) {
|
|
14
|
+
const { data } = await this.workos.get(`/feature-flags/${slug}`);
|
|
15
|
+
return deserializeFeatureFlag(data);
|
|
16
|
+
}
|
|
17
|
+
async enableFeatureFlag(slug) {
|
|
18
|
+
const { data } = await this.workos.put(`/feature-flags/${slug}/enable`, {});
|
|
19
|
+
return deserializeFeatureFlag(data);
|
|
20
|
+
}
|
|
21
|
+
async disableFeatureFlag(slug) {
|
|
22
|
+
const { data } = await this.workos.put(`/feature-flags/${slug}/disable`, {});
|
|
23
|
+
return deserializeFeatureFlag(data);
|
|
24
|
+
}
|
|
25
|
+
async addFlagTarget(options) {
|
|
26
|
+
const { slug, targetId } = options;
|
|
27
|
+
await this.workos.post(`/feature-flags/${slug}/targets/${targetId}`, {});
|
|
28
|
+
}
|
|
29
|
+
async removeFlagTarget(options) {
|
|
30
|
+
const { slug, targetId } = options;
|
|
31
|
+
await this.workos.delete(`/feature-flags/${slug}/targets/${targetId}`);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { FeatureFlags };
|
|
37
|
+
//# sourceMappingURL=feature-flags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature-flags.js","names":["workos: WorkOS"],"sources":["../../src/feature-flags/feature-flags.ts"],"sourcesContent":["import { AutoPaginatable } from '../common/utils/pagination';\nimport { WorkOS } from '../workos';\nimport {\n AddFlagTargetOptions,\n FeatureFlag,\n FeatureFlagResponse,\n ListFeatureFlagsOptions,\n RemoveFlagTargetOptions,\n} from './interfaces';\nimport { deserializeFeatureFlag } from './serializers';\nimport { fetchAndDeserialize } from '../common/utils/fetch-and-deserialize';\n\nexport class FeatureFlags {\n constructor(private readonly workos: WorkOS) {}\n\n async listFeatureFlags(\n options?: ListFeatureFlagsOptions,\n ): Promise<AutoPaginatable<FeatureFlag>> {\n return new AutoPaginatable(\n await fetchAndDeserialize<FeatureFlagResponse, FeatureFlag>(\n this.workos,\n '/feature-flags',\n deserializeFeatureFlag,\n options,\n ),\n (params) =>\n fetchAndDeserialize<FeatureFlagResponse, FeatureFlag>(\n this.workos,\n '/feature-flags',\n deserializeFeatureFlag,\n params,\n ),\n options,\n );\n }\n\n async getFeatureFlag(slug: string): Promise<FeatureFlag> {\n const { data } = await this.workos.get<FeatureFlagResponse>(\n `/feature-flags/${slug}`,\n );\n\n return deserializeFeatureFlag(data);\n }\n\n async enableFeatureFlag(slug: string): Promise<FeatureFlag> {\n const { data } = await this.workos.put<FeatureFlagResponse>(\n `/feature-flags/${slug}/enable`,\n {},\n );\n\n return deserializeFeatureFlag(data);\n }\n\n async disableFeatureFlag(slug: string): Promise<FeatureFlag> {\n const { data } = await this.workos.put<FeatureFlagResponse>(\n `/feature-flags/${slug}/disable`,\n {},\n );\n\n return deserializeFeatureFlag(data);\n }\n\n async addFlagTarget(options: AddFlagTargetOptions): Promise<void> {\n const { slug, targetId } = options;\n await this.workos.post(`/feature-flags/${slug}/targets/${targetId}`, {});\n }\n\n async removeFlagTarget(options: RemoveFlagTargetOptions): Promise<void> {\n const { slug, targetId } = options;\n await this.workos.delete(`/feature-flags/${slug}/targets/${targetId}`);\n }\n}\n"],"mappings":";;;;;AAYA,IAAa,eAAb,MAA0B;CACxB,YAAY,AAAiBA,QAAgB;EAAhB;;CAE7B,MAAM,iBACJ,SACuC;AACvC,SAAO,IAAI,gBACT,MAAM,oBACJ,KAAK,QACL,kBACA,wBACA,QACD,GACA,WACC,oBACE,KAAK,QACL,kBACA,wBACA,OACD,EACH,QACD;;CAGH,MAAM,eAAe,MAAoC;EACvD,MAAM,EAAE,SAAS,MAAM,KAAK,OAAO,IACjC,kBAAkB,OACnB;AAED,SAAO,uBAAuB,KAAK;;CAGrC,MAAM,kBAAkB,MAAoC;EAC1D,MAAM,EAAE,SAAS,MAAM,KAAK,OAAO,IACjC,kBAAkB,KAAK,UACvB,EAAE,CACH;AAED,SAAO,uBAAuB,KAAK;;CAGrC,MAAM,mBAAmB,MAAoC;EAC3D,MAAM,EAAE,SAAS,MAAM,KAAK,OAAO,IACjC,kBAAkB,KAAK,WACvB,EAAE,CACH;AAED,SAAO,uBAAuB,KAAK;;CAGrC,MAAM,cAAc,SAA8C;EAChE,MAAM,EAAE,MAAM,aAAa;AAC3B,QAAM,KAAK,OAAO,KAAK,kBAAkB,KAAK,WAAW,YAAY,EAAE,CAAC;;CAG1E,MAAM,iBAAiB,SAAiD;EACtE,MAAM,EAAE,MAAM,aAAa;AAC3B,QAAM,KAAK,OAAO,OAAO,kBAAkB,KAAK,WAAW,WAAW"}
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/feature-flags/interfaces/add-flag-target-options.interface.d.ts
|
|
2
|
+
interface AddFlagTargetOptions {
|
|
3
|
+
slug: string;
|
|
4
|
+
targetId: string;
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { AddFlagTargetOptions };
|
|
8
|
+
//# sourceMappingURL=add-flag-target-options.interface.d.cts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/feature-flags/interfaces/add-flag-target-options.interface.d.ts
|
|
2
|
+
interface AddFlagTargetOptions {
|
|
3
|
+
slug: string;
|
|
4
|
+
targetId: string;
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { AddFlagTargetOptions };
|
|
8
|
+
//# sourceMappingURL=add-flag-target-options.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -4,7 +4,10 @@ interface FeatureFlag {
|
|
|
4
4
|
id: string;
|
|
5
5
|
name: string;
|
|
6
6
|
slug: string;
|
|
7
|
-
description
|
|
7
|
+
description: string;
|
|
8
|
+
tags: string[];
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
defaultValue: boolean;
|
|
8
11
|
createdAt: string;
|
|
9
12
|
updatedAt: string;
|
|
10
13
|
}
|
|
@@ -13,7 +16,10 @@ interface FeatureFlagResponse {
|
|
|
13
16
|
id: string;
|
|
14
17
|
name: string;
|
|
15
18
|
slug: string;
|
|
16
|
-
description
|
|
19
|
+
description: string;
|
|
20
|
+
tags: string[];
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
default_value: boolean;
|
|
17
23
|
created_at: string;
|
|
18
24
|
updated_at: string;
|
|
19
25
|
}
|
|
@@ -4,7 +4,10 @@ interface FeatureFlag {
|
|
|
4
4
|
id: string;
|
|
5
5
|
name: string;
|
|
6
6
|
slug: string;
|
|
7
|
-
description
|
|
7
|
+
description: string;
|
|
8
|
+
tags: string[];
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
defaultValue: boolean;
|
|
8
11
|
createdAt: string;
|
|
9
12
|
updatedAt: string;
|
|
10
13
|
}
|
|
@@ -13,7 +16,10 @@ interface FeatureFlagResponse {
|
|
|
13
16
|
id: string;
|
|
14
17
|
name: string;
|
|
15
18
|
slug: string;
|
|
16
|
-
description
|
|
19
|
+
description: string;
|
|
20
|
+
tags: string[];
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
default_value: boolean;
|
|
17
23
|
created_at: string;
|
|
18
24
|
updated_at: string;
|
|
19
25
|
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import { FeatureFlag, FeatureFlagResponse } from "./feature-flag.interface.cjs";
|
|
2
|
-
|
|
2
|
+
import { AddFlagTargetOptions } from "./add-flag-target-options.interface.cjs";
|
|
3
|
+
import { ListFeatureFlagsOptions } from "./list-feature-flags-options.interface.cjs";
|
|
4
|
+
import { RemoveFlagTargetOptions } from "./remove-flag-target-options.interface.cjs";
|
|
5
|
+
export { AddFlagTargetOptions, FeatureFlag, FeatureFlagResponse, ListFeatureFlagsOptions, RemoveFlagTargetOptions };
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import { FeatureFlag, FeatureFlagResponse } from "./feature-flag.interface.js";
|
|
2
|
-
|
|
2
|
+
import { AddFlagTargetOptions } from "./add-flag-target-options.interface.js";
|
|
3
|
+
import { ListFeatureFlagsOptions } from "./list-feature-flags-options.interface.js";
|
|
4
|
+
import { RemoveFlagTargetOptions } from "./remove-flag-target-options.interface.js";
|
|
5
|
+
export { AddFlagTargetOptions, FeatureFlag, FeatureFlagResponse, ListFeatureFlagsOptions, RemoveFlagTargetOptions };
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PaginationOptions } from "../../common/interfaces/pagination-options.interface.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/feature-flags/interfaces/list-feature-flags-options.interface.d.ts
|
|
4
|
+
type ListFeatureFlagsOptions = PaginationOptions;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { ListFeatureFlagsOptions };
|
|
7
|
+
//# sourceMappingURL=list-feature-flags-options.interface.d.cts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PaginationOptions } from "../../common/interfaces/pagination-options.interface.js";
|
|
2
|
+
|
|
3
|
+
//#region src/feature-flags/interfaces/list-feature-flags-options.interface.d.ts
|
|
4
|
+
type ListFeatureFlagsOptions = PaginationOptions;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { ListFeatureFlagsOptions };
|
|
7
|
+
//# sourceMappingURL=list-feature-flags-options.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/feature-flags/interfaces/remove-flag-target-options.interface.d.ts
|
|
2
|
+
interface RemoveFlagTargetOptions {
|
|
3
|
+
slug: string;
|
|
4
|
+
targetId: string;
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { RemoveFlagTargetOptions };
|
|
8
|
+
//# sourceMappingURL=remove-flag-target-options.interface.d.cts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/feature-flags/interfaces/remove-flag-target-options.interface.d.ts
|
|
2
|
+
interface RemoveFlagTargetOptions {
|
|
3
|
+
slug: string;
|
|
4
|
+
targetId: string;
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { RemoveFlagTargetOptions };
|
|
8
|
+
//# sourceMappingURL=remove-flag-target-options.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -6,6 +6,9 @@ const deserializeFeatureFlag = (featureFlag) => ({
|
|
|
6
6
|
name: featureFlag.name,
|
|
7
7
|
slug: featureFlag.slug,
|
|
8
8
|
description: featureFlag.description,
|
|
9
|
+
tags: featureFlag.tags,
|
|
10
|
+
enabled: featureFlag.enabled,
|
|
11
|
+
defaultValue: featureFlag.default_value,
|
|
9
12
|
createdAt: featureFlag.created_at,
|
|
10
13
|
updatedAt: featureFlag.updated_at
|
|
11
14
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-flag.serializer.cjs","names":[],"sources":["../../../src/feature-flags/serializers/feature-flag.serializer.ts"],"sourcesContent":["import {\n FeatureFlag,\n FeatureFlagResponse,\n} from '../interfaces/feature-flag.interface';\n\nexport const deserializeFeatureFlag = (\n featureFlag: FeatureFlagResponse,\n): FeatureFlag => ({\n object: featureFlag.object,\n id: featureFlag.id,\n name: featureFlag.name,\n slug: featureFlag.slug,\n description: featureFlag.description,\n createdAt: featureFlag.created_at,\n updatedAt: featureFlag.updated_at,\n});\n"],"mappings":";;AAKA,MAAa,0BACX,iBACiB;CACjB,QAAQ,YAAY;CACpB,IAAI,YAAY;CAChB,MAAM,YAAY;CAClB,MAAM,YAAY;CAClB,aAAa,YAAY;CACzB,WAAW,YAAY;CACvB,WAAW,YAAY;CACxB"}
|
|
1
|
+
{"version":3,"file":"feature-flag.serializer.cjs","names":[],"sources":["../../../src/feature-flags/serializers/feature-flag.serializer.ts"],"sourcesContent":["import {\n FeatureFlag,\n FeatureFlagResponse,\n} from '../interfaces/feature-flag.interface';\n\nexport const deserializeFeatureFlag = (\n featureFlag: FeatureFlagResponse,\n): FeatureFlag => ({\n object: featureFlag.object,\n id: featureFlag.id,\n name: featureFlag.name,\n slug: featureFlag.slug,\n description: featureFlag.description,\n tags: featureFlag.tags,\n enabled: featureFlag.enabled,\n defaultValue: featureFlag.default_value,\n createdAt: featureFlag.created_at,\n updatedAt: featureFlag.updated_at,\n});\n"],"mappings":";;AAKA,MAAa,0BACX,iBACiB;CACjB,QAAQ,YAAY;CACpB,IAAI,YAAY;CAChB,MAAM,YAAY;CAClB,MAAM,YAAY;CAClB,aAAa,YAAY;CACzB,MAAM,YAAY;CAClB,SAAS,YAAY;CACrB,cAAc,YAAY;CAC1B,WAAW,YAAY;CACvB,WAAW,YAAY;CACxB"}
|
|
@@ -5,6 +5,9 @@ const deserializeFeatureFlag = (featureFlag) => ({
|
|
|
5
5
|
name: featureFlag.name,
|
|
6
6
|
slug: featureFlag.slug,
|
|
7
7
|
description: featureFlag.description,
|
|
8
|
+
tags: featureFlag.tags,
|
|
9
|
+
enabled: featureFlag.enabled,
|
|
10
|
+
defaultValue: featureFlag.default_value,
|
|
8
11
|
createdAt: featureFlag.created_at,
|
|
9
12
|
updatedAt: featureFlag.updated_at
|
|
10
13
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-flag.serializer.js","names":[],"sources":["../../../src/feature-flags/serializers/feature-flag.serializer.ts"],"sourcesContent":["import {\n FeatureFlag,\n FeatureFlagResponse,\n} from '../interfaces/feature-flag.interface';\n\nexport const deserializeFeatureFlag = (\n featureFlag: FeatureFlagResponse,\n): FeatureFlag => ({\n object: featureFlag.object,\n id: featureFlag.id,\n name: featureFlag.name,\n slug: featureFlag.slug,\n description: featureFlag.description,\n createdAt: featureFlag.created_at,\n updatedAt: featureFlag.updated_at,\n});\n"],"mappings":";AAKA,MAAa,0BACX,iBACiB;CACjB,QAAQ,YAAY;CACpB,IAAI,YAAY;CAChB,MAAM,YAAY;CAClB,MAAM,YAAY;CAClB,aAAa,YAAY;CACzB,WAAW,YAAY;CACvB,WAAW,YAAY;CACxB"}
|
|
1
|
+
{"version":3,"file":"feature-flag.serializer.js","names":[],"sources":["../../../src/feature-flags/serializers/feature-flag.serializer.ts"],"sourcesContent":["import {\n FeatureFlag,\n FeatureFlagResponse,\n} from '../interfaces/feature-flag.interface';\n\nexport const deserializeFeatureFlag = (\n featureFlag: FeatureFlagResponse,\n): FeatureFlag => ({\n object: featureFlag.object,\n id: featureFlag.id,\n name: featureFlag.name,\n slug: featureFlag.slug,\n description: featureFlag.description,\n tags: featureFlag.tags,\n enabled: featureFlag.enabled,\n defaultValue: featureFlag.default_value,\n createdAt: featureFlag.created_at,\n updatedAt: featureFlag.updated_at,\n});\n"],"mappings":";AAKA,MAAa,0BACX,iBACiB;CACjB,QAAQ,YAAY;CACpB,IAAI,YAAY;CAChB,MAAM,YAAY;CAClB,MAAM,YAAY;CAClB,aAAa,YAAY;CACzB,MAAM,YAAY;CAClB,SAAS,YAAY;CACrB,cAAc,YAAY;CAC1B,WAAW,YAAY;CACvB,WAAW,YAAY;CACxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-result.serializer.cjs","names":[],"sources":["../../../src/fga/serializers/query-result.serializer.ts"],"sourcesContent":["import { QueryResult, QueryResultResponse } from '../interfaces';\nimport { Warning } from '../interfaces/warning.interface';\nimport { ListResponse } from '../../common/interfaces';\n\nexport interface QueryResultListResponse
|
|
1
|
+
{"version":3,"file":"query-result.serializer.cjs","names":[],"sources":["../../../src/fga/serializers/query-result.serializer.ts"],"sourcesContent":["import { QueryResult, QueryResultResponse } from '../interfaces';\nimport { Warning } from '../interfaces/warning.interface';\nimport { ListResponse } from '../../common/interfaces';\n\nexport interface QueryResultListResponse extends ListResponse<QueryResultResponse> {\n warnings?: Warning[];\n}\n\nexport const deserializeQueryResult = (\n queryResult: QueryResultResponse,\n): QueryResult => ({\n resourceType: queryResult.resource_type,\n resourceId: queryResult.resource_id,\n relation: queryResult.relation,\n warrant: {\n resourceType: queryResult.warrant.resource_type,\n resourceId: queryResult.warrant.resource_id,\n relation: queryResult.warrant.relation,\n subject: {\n resourceType: queryResult.warrant.subject.resource_type,\n resourceId: queryResult.warrant.subject.resource_id,\n relation: queryResult.warrant.subject.relation,\n },\n },\n isImplicit: queryResult.is_implicit,\n meta: queryResult.meta,\n});\n"],"mappings":";;AAQA,MAAa,0BACX,iBACiB;CACjB,cAAc,YAAY;CAC1B,YAAY,YAAY;CACxB,UAAU,YAAY;CACtB,SAAS;EACP,cAAc,YAAY,QAAQ;EAClC,YAAY,YAAY,QAAQ;EAChC,UAAU,YAAY,QAAQ;EAC9B,SAAS;GACP,cAAc,YAAY,QAAQ,QAAQ;GAC1C,YAAY,YAAY,QAAQ,QAAQ;GACxC,UAAU,YAAY,QAAQ,QAAQ;GACvC;EACF;CACD,YAAY,YAAY;CACxB,MAAM,YAAY;CACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-result.serializer.js","names":[],"sources":["../../../src/fga/serializers/query-result.serializer.ts"],"sourcesContent":["import { QueryResult, QueryResultResponse } from '../interfaces';\nimport { Warning } from '../interfaces/warning.interface';\nimport { ListResponse } from '../../common/interfaces';\n\nexport interface QueryResultListResponse
|
|
1
|
+
{"version":3,"file":"query-result.serializer.js","names":[],"sources":["../../../src/fga/serializers/query-result.serializer.ts"],"sourcesContent":["import { QueryResult, QueryResultResponse } from '../interfaces';\nimport { Warning } from '../interfaces/warning.interface';\nimport { ListResponse } from '../../common/interfaces';\n\nexport interface QueryResultListResponse extends ListResponse<QueryResultResponse> {\n warnings?: Warning[];\n}\n\nexport const deserializeQueryResult = (\n queryResult: QueryResultResponse,\n): QueryResult => ({\n resourceType: queryResult.resource_type,\n resourceId: queryResult.resource_id,\n relation: queryResult.relation,\n warrant: {\n resourceType: queryResult.warrant.resource_type,\n resourceId: queryResult.warrant.resource_id,\n relation: queryResult.warrant.relation,\n subject: {\n resourceType: queryResult.warrant.subject.resource_type,\n resourceId: queryResult.warrant.subject.resource_id,\n relation: queryResult.warrant.subject.relation,\n },\n },\n isImplicit: queryResult.is_implicit,\n meta: queryResult.meta,\n});\n"],"mappings":";AAQA,MAAa,0BACX,iBACiB;CACjB,cAAc,YAAY;CAC1B,YAAY,YAAY;CACxB,UAAU,YAAY;CACtB,SAAS;EACP,cAAc,YAAY,QAAQ;EAClC,YAAY,YAAY,QAAQ;EAChC,UAAU,YAAY,QAAQ;EAC9B,SAAS;GACP,cAAc,YAAY,QAAQ,QAAQ;GAC1C,YAAY,YAAY,QAAQ,QAAQ;GACxC,UAAU,YAAY,QAAQ,QAAQ;GACvC;EACF;CACD,YAAY,YAAY;CACxB,MAAM,YAAY;CACnB"}
|