Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat(erp): let listed users install Coming soon integrations (#1986)

BettrCallRaul89fa2cb123cd
diff --git a/.claude/rules/environment-configuration.md b/.claude/rules/environment-configuration.md
index 914f687136..f090aa837a 100644
--- a/.claude/rules/environment-configuration.md
+++ b/.claude/rules/environment-configuration.md
@@ -155,7 +155,7 @@ vars through `ci/src/deploy.ts` → `sst.config.ts` → the ERP service only.
**Analytics / config** — `POSTHOG_API_HOST`, `POSTHOG_PROJECT_PUBLIC_KEY`
(optional, public), `CARBON_EDITION` (`community|cloud|enterprise|test` →
-`CarbonEdition`), `CONTROLLED_ENVIRONMENT` (ITAR flag), `DEFAULT_LANGUAGE`
+`CarbonEdition`), `CONTROLLED_ENVIRONMENT` (ITAR flag), `INTEGRATION_EARLY_ACCESS_USER_IDS` (server-only, comma-separated user ids that can install an `internalOnly` integration on Cloud), `DEFAULT_LANGUAGE`
(default `en`), `GTM_URL`, `GTM_EVENTS_API_SECRET_KEY`.
**Maintenance and status (both optional, server-only)** — `MAINTENANCE_MODE=true`
diff --git a/.claude/rules/onshape-panel.md b/.claude/rules/onshape-panel.md
index 5d20a59bf1..13dc309716 100644
--- a/.claude/rules/onshape-panel.md
+++ b/.claude/rules/onshape-panel.md
@@ -20,7 +20,7 @@ A Carbon panel in Onshape's element right panel. Users push parts, assemblies an
- `ONSHAPE_INTEGRATION_IDS`, `OnshapeIntegrationId`, `isOnshapeIntegrationId` and `getConflictingOnshapeIntegration` (`lib/connection.ts`) cover the two sync connections only. `OnshapeOAuthIntegrationId` covers all three.
- Status, releases and the three plan routes read the connection with the service role. The `companyIntegration` SELECT policy needs settings view; through a parts-view user's client the row reads as absent and the panel says Onshape is not connected. The Fields route uses the user's client: it requires settings update anyway.
- Only an `onshape-v2` item link means "the panel pushes to this item". A sync connection's item row is BOM-import bookkeeping for the BoM Explorer; the item card and Detach never read or delete it.
-- OAuth: the sync integration and the panel are two Onshape apps and share no variable. `onshape` reads `ONSHAPE_CLIENT_ID`, `ONSHAPE_CLIENT_SECRET`, `ONSHAPE_OAUTH_REDIRECT_URL` (→ `/api/integrations/onshape/oauth`); `onshape-v2` reads `ONSHAPE_V2_CLIENT_ID`, `ONSHAPE_V2_CLIENT_SECRET`, `ONSHAPE_V2_OAUTH_REDIRECT_URL` (→ `/api/integrations/onshape-v2/oauth`). Both ask for `OAuth2Read OAuth2Write`. Each card is `active` only when its own client id is set (`config.tsx`, `config-v2.tsx`); otherwise it reads Not Configured, Install is disabled and an installed connection's Details link goes nowhere; the env schema groups them as `onshape` and `onshapeV2`. `onshape-v2` is also `internalOnly`: on Carbon Cloud only Carbon staff can install it, in any company, and everyone else sees Coming soon (`isIntegrationComingSoon`, `@carbon/ee/plan`). The install route refuses them with `coming-soon` (`isIntegrationInstallWithheld`, `modules/settings/settings.service.ts`); a company that has it installed keeps it. Install routes call `beginOnshapeAuthorization`; callbacks call `completeOnshapeAuthorization` (`modules/settings/settings.service.ts`); `getOnshapeOAuthConfig` picks the client and redirect per id and answers `not-configured` when one of that integration's three variables is missing. A connection's tokens belong to the app that issued them: changing an integration's client id means reconnecting. State is the cookie-bound one from `@carbon/auth/oauth-state.server`.
+- OAuth: the sync integration and the panel are two Onshape apps and share no variable. `onshape` reads `ONSHAPE_CLIENT_ID`, `ONSHAPE_CLIENT_SECRET`, `ONSHAPE_OAUTH_REDIRECT_URL` (→ `/api/integrations/onshape/oauth`); `onshape-v2` reads `ONSHAPE_V2_CLIENT_ID`, `ONSHAPE_V2_CLIENT_SECRET`, `ONSHAPE_V2_OAUTH_REDIRECT_URL` (→ `/api/integrations/onshape-v2/oauth`). Both ask for `OAuth2Read OAuth2Write`. Each card is `active` only when its own client id is set (`config.tsx`, `config-v2.tsx`); otherwise it reads Not Configured, Install is disabled and an installed connection's Details link goes nowhere; the env schema groups them as `onshape` and `onshapeV2`. `onshape-v2` is also `internalOnly`: on Carbon Cloud only Carbon staff and the users listed in `INTEGRATION_EARLY_ACCESS_USER_IDS` can install it, in any company they belong to, and everyone else sees Coming soon (`isIntegrationComingSoon`, `@carbon/ee/plan`; `hasIntegrationEarlyAccess`, `@carbon/ee/plan.server`). The install route refuses them with `coming-soon` (`isIntegrationInstallWithheld`, `modules/settings/settings.service.ts`); a company that has it installed keeps it. Install routes call `beginOnshapeAuthorization`; callbacks call `completeOnshapeAuthorization` (`modules/settings/settings.service.ts`); `getOnshapeOAuthConfig` picks the client and redirect per id and answers `not-configured` when one of that integration's three variables is missing. A connection's tokens belong to the app that issued them: changing an integration's client id means reconnecting. State is the cookie-bound one from `@carbon/auth/oauth-state.server`.
- Connect opens a popup (`beginOAuthPopup`, `packages/ee/src/oauth-popup.ts`, opened inside the click). The callback renders `oauthPopupResponse`: it posts the outcome to the opener and closes, or lands on the integrations page with no opener. The drawer's Reconnect action POSTs to the install route and follows `{ redirectUrl }`.
- Uninstall only sets `active = false` and keeps the tokens, so `getOnshapeClient` reads the `onshape-v2` row only while it is active: after an uninstall every panel read answers "not connected". A plan already stored can still be applied until it expires (15 min); APPLY makes no Onshape call.
- `onshapeHealthcheck` (`hooks.server.ts`) builds the client (refreshing an expired token) and reads `/companies`; a revoked grant reads unhealthy.
diff --git a/apps/erp/app/modules/settings/settings.service.ts b/apps/erp/app/modules/settings/settings.service.ts
index fc6338bff8..6f0ad7e8c4 100644
--- a/apps/erp/app/modules/settings/settings.service.ts
+++ b/apps/erp/app/modules/settings/settings.service.ts
@@ -188,7 +188,10 @@ import {
patchOnshapeSettings
} from "@carbon/ee/onshape.server";
import { isIntegrationComingSoon } from "@carbon/ee/plan";
-import { companyHasFeature } from "@carbon/ee/plan.server";
+import {
+ companyHasFeature,
+ hasIntegrationEarlyAccess
+} from "@carbon/ee/plan.server";
import { patchRampSettings } from "@carbon/ee/ramp.server";
import { resolveCapabilities } from "@carbon/ee/sync";
import { trigger } from "@carbon/jobs";
@@ -591,13 +594,18 @@ export async function isIntegrationInstallWithheld(
{
companyId,
integrationId,
- email
- }: { companyId: string; integrationId: string; email: string }
+ email,
+ userId
+ }: { companyId: string; integrationId: string; email: string; userId: string }
): Promise<boolean> {
const integration = availableIntegrations.find((i) => i.id === integrationId);
if (
!integration ||
- !isIntegrationComingSoon(integration, { edition: CarbonEdition, email })
+ !isIntegrationComingSoon(integration, {
+ edition: CarbonEdition,
+ email,
+ hasEarlyAccess: hasIntegrationEarlyAccess(userId)
+ })
) {
return false;
}
diff --git a/apps/erp/app/modules/settings/ui/Integrations/IntegrationCard.tsx b/apps/erp/app/modules/settings/ui/Integrations/IntegrationCard.tsx
index 2cd6adcaad..767888ec07 100644
--- a/apps/erp/app/modules/settings/ui/Integrations/IntegrationCard.tsx
+++ b/apps/erp/app/modules/settings/ui/Integrations/IntegrationCard.tsx
@@ -62,10 +62,12 @@ export type IntegrationHealth = {
export function IntegrationCard({
integration,
- installed
+ installed,
+ hasEarlyAccess
}: {
integration: Integration;
installed: IntegrationHealth | null;
+ hasEarlyAccess: boolean;
}) {
const fetcher = useFetcher<{}>();
const navigate = useNavigate();
@@ -94,11 +96,15 @@ export function IntegrationCard({
const isStarterPlan = isGated && !isWhitelisted;
const edition = useEdition();
const user = useUser();
- // Only an install is withheld: a company where Carbon staff installed it
- // keeps a working card.
+ // Only an install is withheld: a company where it was installed keeps a
+ // working card.
const comingSoon =
!installed &&
- isIntegrationComingSoon(integration, { edition, email: user.email });
+ isIntegrationComingSoon(integration, {
+ edition,
+ email: user.email,
+ hasEarlyAccess
+ });
// At most one ACTIVE integration per provider role, enforced by a database
// trigger. Surfacing it here is what keeps a customer from meeting that
diff --git a/apps/erp/app/modules/settings/ui/Integrations/IntegrationsList.tsx b/apps/erp/app/modules/settings/ui/Integrations/IntegrationsList.tsx
index 28ec1994da..23065228e3 100644
--- a/apps/erp/app/modules/settings/ui/Integrations/IntegrationsList.tsx
+++ b/apps/erp/app/modules/settings/ui/Integrations/IntegrationsList.tsx
@@ -37,12 +37,15 @@ type IntegrationsListProps = {
availableIntegrations: Integration[];
integrations: Array<IntegrationHealth>;
quickInstallConnectors?: QuickInstallConnector[];
+ /** The user may install Coming soon integrations (`hasIntegrationEarlyAccess`). */
+ hasEarlyAccess: boolean;
};
const IntegrationsList = ({
integrations,
availableIntegrations,
- quickInstallConnectors = []
+ quickInstallConnectors = [],
+ hasEarlyAccess
}: IntegrationsListProps) => {
const { t } = useLingui();
const [params] = useUrlParams();
@@ -77,12 +80,24 @@ const IntegrationsList = ({
(integration) =>
!installedIds.includes(integration.id) &&
integration.active &&
- !isIntegrationComingSoon(integration, { edition, email })
+ !isIntegrationComingSoon(integration, {
+ edition,
+ email,
+ hasEarlyAccess
+ })
);
}
return filtered;
- }, [availableIntegrations, installedIds, search, filter, edition, email]);
+ }, [
+ availableIntegrations,
+ installedIds,
+ search,
+ filter,
+ edition,
+ email,
+ hasEarlyAccess
+ ]);
const anyWhitelistedVisible = useAnyVisible({
containerRef: gridRef,
@@ -129,6 +144,7 @@ const IntegrationsList = ({
key={integration.id}
integration={integration}
installed={installed.find((i) => i.id === integration.id) || null}
+ hasEarlyAccess={hasEarlyAccess}
/>
);
})}
diff --git a/apps/erp/app/routes/api+/integrations.$id.connect.ts b/apps/erp/app/routes/api+/integrations.$id.connect.ts
index d2c2d8c438..a8b38bbf92 100644
--- a/apps/erp/app/routes/api+/integrations.$id.connect.ts
+++ b/apps/erp/app/routes/api+/integrations.$id.connect.ts
@@ -57,7 +57,8 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
await isIntegrationInstallWithheld(client, {
companyId,
integrationId,
- email
+ email,
+ userId
})
) {
return redirectExternal(
diff --git a/apps/erp/app/routes/api+/integrations.onshape-v2.install.ts b/apps/erp/app/routes/api+/integrations.onshape-v2.install.ts
index a3fa095e64..ddb861dd97 100644
--- a/apps/erp/app/routes/api+/integrations.onshape-v2.install.ts
+++ b/apps/erp/app/routes/api+/integrations.onshape-v2.install.ts
@@ -21,7 +21,8 @@ async function authorize(request: Request) {
await isIntegrationInstallWithheld(client, {
companyId,
integrationId: ONSHAPE_V2_INTEGRATION_ID,
- email
+ email,
+ userId
})
) {
return { ok: false as const, reason: "coming-soon" as const };
diff --git a/apps/erp/app/routes/x+/settings+/integrations.$id.tsx b/apps/erp/app/routes/x+/settings+/integrations.$id.tsx
index 5a874c415e..1257ab353d 100644
--- a/apps/erp/app/routes/x+/settings+/integrations.$id.tsx
+++ b/apps/erp/app/routes/x+/settings+/integrations.$id.tsx
@@ -1160,7 +1160,8 @@ async function installIntegration({ request, params }: ActionFunctionArgs) {
await isIntegrationInstallWithheld(client, {
companyId,
integrationId,
- email
+ email,
+ userId
})
) {
// The connect route's refusal: the integrations page resolves the code to
diff --git a/apps/erp/app/routes/x+/settings+/integrations.tsx b/apps/erp/app/routes/x+/settings+/integrations.tsx
index 7ad91ad0c4..0dd03c1d92 100644
--- a/apps/erp/app/routes/x+/settings+/integrations.tsx
+++ b/apps/erp/app/routes/x+/settings+/integrations.tsx
@@ -10,6 +10,7 @@ import {
getIntegrationIdsByRole,
quickInstallConnectors
} from "@carbon/ee";
+import { hasIntegrationEarlyAccess } from "@carbon/ee/plan.server";
import { RecordOutlet, toast } from "@carbon/react";
import { redirect } from "@carbon/utils";
import { useLingui } from "@lingui/react/macro";
@@ -26,7 +27,7 @@ export const config = {
};
export async function loader({ request }: LoaderFunctionArgs) {
- const { client, companyId } = await requirePermissions(request, {
+ const { client, companyId, userId } = await requirePermissions(request, {
view: "settings"
});
@@ -75,7 +76,9 @@ export async function loader({ request }: LoaderFunctionArgs) {
return data({
integrations: items,
- activeRoles
+ activeRoles,
+ // Decided here so the early access list never reaches the browser.
+ hasEarlyAccess: hasIntegrationEarlyAccess(userId)
// No OAuth state here. Every OAuth install now starts at
// `api+/integrations.$id.connect`, which issues a SIGNED, browser-bound,
// single-use state — strictly better than the unsigned correlation value this
@@ -84,7 +87,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
export default function IntegrationsRoute() {
- const { integrations } = useLoaderData<typeof loader>();
+ const { integrations, hasEarlyAccess } = useLoaderData<typeof loader>();
const { i18n } = useLingui();
const [searchParams, setSearchParams] = useSearchParams();
@@ -125,6 +128,7 @@ export default function IntegrationsRoute() {
// @ts-expect-error TS2322 - TODO: fix type
availableIntegrations={availableIntegrations}
quickInstallConnectors={quickInstallConnectors}
+ hasEarlyAccess={hasEarlyAccess}
/>
<RecordOutlet />
</>
diff --git a/packages/ee/AGENTS.md b/packages/ee/AGENTS.md
index a7c4c720be..2232a3697b 100644
--- a/packages/ee/AGENTS.md
+++ b/packages/ee/AGENTS.md
@@ -76,7 +76,7 @@ pnpm --filter @carbon/ee typecheck
- **Provider roles**: every integration that participates in sync declares `providerRole: "accounting" | "spend" | "oee"` on its descriptor. That ONE declaration replaces the id lists that used to answer "which are accounting providers" five different ways, and the database enforces at most one ACTIVE integration per role per company (`companyIntegration_single_active_role`, migration `20260924133915`) — except `oee`, which may have several active integrations at once (`check_single_active_provider_role()` skips it, migration `20261013030022`); its one-device-per-work-center rule is `UNIQUE(workCenterId, companyId)` on `workCenterDevice` instead (`.claude/rules/oee-provider.md`). `getIntegrationsByRole`/`getIntegrationIdsByRole` (barrel) are the lookups; `no-integration-id-branching` (`@carbon/checks`) stops new id branching. NOTE the barrel cannot be imported from a `*.service.ts` (browser-bundled) or from most tests — it reaches `@carbon/auth`, which validates the full server env at import time; that is why `./sync` takes the registry slice as an argument instead of importing it
- **Ledger delegation**: when a spend provider's mode declares `ownsLedgerFamilies`, `applyLedgerDelegation` sets that family to `"none"` AND disables its backing entities — derived from `POSTING_POLICY`, never a hard-coded `"bill"`. Each half alone is wrong (families-only leaves the document pushing; entity-only parks a `DOC_SYNC_DISABLED` Warning forever). `getJournalPostingPolicyDecision` accepts only `EffectivePostingSyncSettings`, so the compiler refuses a posting decision made from raw settings
- **Integration pattern**: `defineIntegration()` → config with id, name, settings, OAuth, actions
-- **Internal-only integrations**: `internalOnly: true` on a descriptor makes it installable on Carbon Cloud by Carbon staff only (`isInternalEmail`), in any company; everyone else sees a Coming soon card. Self-hosted editions are not gated. `isIntegrationComingSoon` (`./plan`) is the one rule; the ERP's `isIntegrationInstallWithheld` (`modules/settings/settings.service.ts`) applies it in the connect route, the install action and the `onshape-v2` install route, and only to a company that does not have the integration installed. An integration with its own install route must call it there too
+- **Internal-only integrations**: `internalOnly: true` on a descriptor makes it installable on Carbon Cloud only by Carbon staff (`isInternalEmail`), in any company, and by users whose id is in `INTEGRATION_EARLY_ACCESS_USER_IDS` (`hasIntegrationEarlyAccess`, `./plan.server`; comma-separated, read on the server only, so the list never reaches the browser or the code); everyone else sees a Coming soon card. Self-hosted editions are not gated. `isIntegrationComingSoon` (`./plan`) is the one rule; the ERP's `isIntegrationInstallWithheld` (`modules/settings/settings.service.ts`) applies it in the connect route, the install action and the `onshape-v2` install route, and only to a company that does not have the integration installed. An integration with its own install route must call it there too
- **SAML SSO** (`./sso.server`, `src/sso/`): `isSsoEnabled()` (`gate.ts` — Enterprise edition AND `sso` in `AUTH_PROVIDERS`) is the ONE flag; the connection lookups and admin mutations self-gate on it. `provider.server.ts` = GoTrue admin API wrappers + `getSamlSpUrls`; `connections.server.ts` = `ssoConnection` lookups (each attaches a computed `domains: string[]` of VERIFIED `ssoDomain` claims), `isSsoRequiredForEmail`, `getSsoAwareInviteLink`, upsert/requireSso/deactivate mutations, and the domain-claim flows `addSsoDomain`/`verifySsoDomain`/`removeSsoDomain`; `verification.server.ts` = the DNS TXT ownership challenge (`_carbon-challenge.<domain>` → `carbon-domain-verification=<token>`, `checkDomainVerification` with pinned public resolvers, one-shot manual verify — no polling or re-verification); `session.server.ts` = amr-based session classification (`getSsoProviderIdFromSession` for enforcement, never `getSsoProviderIdFromUser`); `provisioning.server.ts` = identity linking + invite-first migration + `deleteJitSsoUser` (full removal of a rejected throwaway JIT user — auth user AND its trigger-created `user`/`userPermission` rows, guarded on zero memberships; takes a `Kysely<KyselyDatabase>` param — callers pass their own db client) + the **pre-seed** helpers `seedSsoIdentityForUser` / `backfillSsoIdentitiesForDomain` / `removeSsoIdentitiesForDomain` (+ pure `emailDomain` / `ssoProviderColumn`). Pre-seeding is the account-linking fix under `GOTRUE_DISABLE_SIGNUP=true`: a row in `auth.identities` with `identity_data.email = lower(email)` makes GoTrue link a SAML sign-in to the existing user via its **email-column** fallback — provider-agnostic (works for any IdP: Okta/Entra/OneLogin/Ping/…, whose NameID shapes differ), keyed on the generated `email` column NOT `provider_id`. `verifySsoDomain` backfills every existing on-domain user when a domain is verified; the three account-creation flows (`apps/erp/.../users.service.ts`) seed newly-invited users; `removeSsoDomain` tears the domain's identities down. A DB guard trigger on `auth.sso_domains` (migration `…_sso-domain-guard.sql`, `ssoReservedDomain` table) blocks registering an unclaimed/reserved domain. Only verified domains ever reach GoTrue. Full architecture + the provider-agnostic linking rationale: `.claude/rules/authentication-system.md` (Enterprise SAML SSO section); design: `.ai/specs/2026-08-29-saml-sso-account-linking.md`
- **Onshape panel auth** (`./onshape/panel-session.server`, `src/onshape/panel/session.server.ts`): the `cps_` bearer credential for the Onshape iframe, which the `SameSite=Lax` `carbon` cookie cannot reach. Mints, stores (Redis `panel-session:<token>`, 12 h) and revokes sessions, and exports `requireOnshapePanelPermissions`, the panel routes' gate: the same claims check as `requirePermissions`, answering 401/403 with no redirect. Imports `getUserClaims`, `userHasVerifiedTotpFactor`, `getUserScopedClient` and `hasPermission` from `@carbon/auth`; auth never imports it back. See `.claude/rules/onshape-panel.md`
- **Exports**: `./accounting`, `./plan`, `./plan.server`, `./entitlements.server`, `./permissions.server`, `./console.server`, `./approvals`, `./audit.server`, `./backups.server`, `./email-notifications.server`, `./api-keys.server`, `./webhooks.server`, `./two-factor.server`, `./forecast.server`, `./customer-portals.server`, `./mcp`, `./mcp.server`, `./rules` (client-safe storage + sales rule query services/UI), `./rules.server` (both evaluators AND the entitlement-gated authoring writes — `upsertEnforcementRule`/`deleteEnforcementRule`/`assign*`/`unassign*` in `rules/service.server.ts`, each embedding `requireEntitlement("SALES_RULES"|"STORAGE_RULES")`), `./workflows`, `./workflows/help`, `./workflows/labels`, `./workflows.server`, `./slack.server`, `./hooks.server`, `./sso.server`, `./onshape/integration-id`, `./onshape/panel-session.server`, `./jira`, `./linear`, `./rillet/hooks.server`, `./xero/hooks.server`, `./ramp.server`, `./ramp/hooks.server`, `./oee`, `./oee.server`, `./sense/hooks.server`, etc.
diff --git a/packages/ee/src/plan.server.ts b/packages/ee/src/plan.server.ts
index 79e11357ab..a5b32ed263 100644
--- a/packages/ee/src/plan.server.ts
+++ b/packages/ee/src/plan.server.ts
@@ -2,7 +2,12 @@
// Carbon Enterprise file, licensed only under the Carbon Commercial License
// (packages/ee/LICENSE). Not AGPL. Running, modifying, or copying it beyond those terms requires a commercial license.
-import { CarbonEdition, error, STRIPE_BYPASS_COMPANY_IDS } from "@carbon/auth";
+import {
+ CarbonEdition,
+ error,
+ INTEGRATION_EARLY_ACCESS_USER_IDS,
+ STRIPE_BYPASS_COMPANY_IDS
+} from "@carbon/auth";
import {
getCompanyPlanId,
isCarbonOwnedCompany
@@ -14,6 +19,7 @@ import type { SupabaseClient } from "@supabase/supabase-js";
import {
defaultUpgradeMessage,
type GateSpec,
+ isListedUserId,
planMeetsRequirement,
resolveRequirement
} from "./plan";
@@ -25,6 +31,16 @@ function isBypassCompany(companyId: string): boolean {
.includes(companyId);
}
+/**
+ * Whether this user may install an `internalOnly` integration on Carbon Cloud
+ * without a Carbon email (`isIntegrationComingSoon`): their id is listed in
+ * `INTEGRATION_EARLY_ACCESS_USER_IDS`. The list is deployment configuration,
+ * so no customer's id is in the code.
+ */
+export function hasIntegrationEarlyAccess(userId: string): boolean {
+ return isListedUserId(INTEGRATION_EARLY_ACCESS_USER_IDS, userId);
+}
+
// The plan read is `getCompanyPlanId` (`@carbon/auth`): service role, cached, and
// shared with the API-key plan gate in `requirePermissions`. A failed read
// normalizes to the lowest plan, which turns plan-gated ENFORCEMENT (storage/sales
diff --git a/packages/ee/src/plan.test.ts b/packages/ee/src/plan.test.ts
index cf2ce845b3..d5cb43c0e7 100644
--- a/packages/ee/src/plan.test.ts
+++ b/packages/ee/src/plan.test.ts
@@ -4,7 +4,7 @@
import { Edition } from "@carbon/utils";
import { describe, expect, it } from "vitest";
-import { isIntegrationComingSoon } from "./plan";
+import { isIntegrationComingSoon, isListedUserId } from "./plan";
const internalOnly = { id: "cad", internalOnly: true };
const customer = "[email protected]";
@@ -14,7 +14,8 @@ describe("isIntegrationComingSoon", () => {
expect(
isIntegrationComingSoon(internalOnly, {
edition: Edition.Cloud,
- email: customer
+ email: customer,
+ hasEarlyAccess: false
})
).toBe(true);
});
@@ -26,7 +27,11 @@ describe("isIntegrationComingSoon", () => {
]) {
expect(
- isIntegrationComingSoon(internalOnly, { edition: Edition.Cloud, email })
+ isIntegrationComingSoon(internalOnly, {
+ edition: Edition.Cloud,
+ email,
+ hasEarlyAccess: false
+ })
).toBe(false);
}
});
@@ -35,7 +40,8 @@ describe("isIntegrationComingSoon", () => {
expect(
isIntegrationComingSoon(internalOnly, {
edition: Edition.Cloud,
- email: null
+ email: null,
+ hasEarlyAccess: false
})
).toBe(true);
});
@@ -47,7 +53,11 @@ describe("isIntegrationComingSoon", () => {
Edition.Test
]) {
expect(
- isIntegrationComingSoon(internalOnly, { edition, email: customer })
+ isIntegrationComingSoon(internalOnly, {
+ edition,
+ email: customer,
+ hasEarlyAccess: false
+ })
).toBe(false);
}
});
@@ -58,9 +68,50 @@ describe("isIntegrationComingSoon", () => {
{ id: "cad" },
{
edition: Edition.Cloud,
- email: customer
+ email: customer,
+ hasEarlyAccess: false
}
)
).toBe(false);
});
+
+ it("offers it to a customer with early access on Cloud", () => {
+ expect(
+ isIntegrationComingSoon(internalOnly, {
+ edition: Edition.Cloud,
+ email: customer,
+ hasEarlyAccess: true
+ })
+ ).toBe(false);
+ });
+});
+
+describe("isListedUserId", () => {
+ const list = "user-a, user-b ,user-c";
+
+ it("finds an id anywhere in the list, ignoring spaces", () => {
+ for (const id of ["user-a", "user-b", "user-c"]) {
+ expect(isListedUserId(list, id)).toBe(true);
+ }
+ });
+
+ it("ignores quotes left around the value", () => {
+ expect(isListedUserId('"user-a,user-b"', "user-a")).toBe(true);
+ expect(isListedUserId('"user-a,user-b"', "user-b")).toBe(true);
+ expect(isListedUserId("'user-a'", "user-a")).toBe(true);
+ expect(isListedUserId('" user-a "', "user-a")).toBe(true);
+ expect(isListedUserId('"user-a" , " user-b"', "user-b")).toBe(true);
+ });
+
+ it("matches whole ids only", () => {
+ expect(isListedUserId(list, "user")).toBe(false);
+ expect(isListedUserId(list, "user-a, user-b")).toBe(false);
+ });
+
+ it("matches nothing for an empty list or an empty id", () => {
+ expect(isListedUserId(undefined, "user-a")).toBe(false);
+ expect(isListedUserId("", "user-a")).toBe(false);
+ expect(isListedUserId("user-a,,", "")).toBe(false);
+ expect(isListedUserId("user-a", null)).toBe(false);
+ });
});
diff --git a/packages/ee/src/plan.ts b/packages/ee/src/plan.ts
index 72cfbad33f..f18efcda2d 100644
--- a/packages/ee/src/plan.ts
+++ b/packages/ee/src/plan.ts
@@ -51,24 +51,48 @@ export function isIntegrationWhitelisted(id: string) {
/**
* Whether this user sees an `internalOnly` integration as "Coming soon" and
- * cannot install it. Carbon staff (`isInternalEmail`) can, in any company.
+ * cannot install it. Carbon staff (`isInternalEmail`) can, in any company, and
+ * so can a user with early access (`hasIntegrationEarlyAccess`, `plan.server`).
* Only Carbon Cloud gates it: a self-hosted instance configures its own OAuth
* app and has no Carbon staff to install it.
*
- * It gates the install only. A company where staff installed it keeps it, so
+ * It gates the install only. A company where it was installed keeps it, so
* its own admins can open, reconnect and uninstall it.
*/
export function isIntegrationComingSoon(
integration: { id: string; internalOnly?: boolean },
- { edition, email }: { edition: Edition; email: string | null | undefined }
+ {
+ edition,
+ email,
+ hasEarlyAccess
+ }: {
+ edition: Edition;
+ email: string | null | undefined;
+ hasEarlyAccess: boolean;
+ }
): boolean {
return (
integration.internalOnly === true &&
edition === Edition.Cloud &&
- !isInternalEmail(email)
+ !isInternalEmail(email) &&
+ !hasEarlyAccess
);
}
+/**
+ * Whether `userId` is an entry of a comma-separated id list. Spaces and quotes
+ * around an entry are ignored, so a list pasted with them still matches.
+ */
+export function isListedUserId(
+ list: string | null | undefined,
+ userId: string | null | undefined
+): boolean {
+ if (!list || !userId) return false;
+ return list
+ .split(",")
+ .some((entry) => entry.replace(/^[\s"']+|[\s"']+$/g, "") === userId);
+}
+
export type PlanRequirement = Plan | Plan[];
export type GateSpec =
diff --git a/packages/ee/src/types.ts b/packages/ee/src/types.ts
index 017e2b96e8..abc9522f70 100644
--- a/packages/ee/src/types.ts
+++ b/packages/ee/src/types.ts
@@ -202,10 +202,11 @@ export type IntegrationConfig = {
*/
active?: boolean;
/**
- * Installable on Carbon Cloud by Carbon staff only, while the integration is
- * rolled out. Everyone else sees a "Coming soon" card. Staff may install it in
- * any company, and the install then works for that company like any other.
- * See `isIntegrationComingSoon` (`plan.ts`).
+ * Installable on Carbon Cloud by Carbon staff and early access users only,
+ * while the integration is rolled out. Everyone else sees a "Coming soon"
+ * card. They may install it in any company they belong to, and the install
+ * then works for that company like any other. See `isIntegrationComingSoon`
+ * (`plan.ts`) and `hasIntegrationEarlyAccess` (`plan.server.ts`).
*/
internalOnly?: boolean;
/** Category for grouping in the UI (e.g., "Accounting", "CAD", "Email") */
diff --git a/packages/env/src/index.ts b/packages/env/src/index.ts
index f74f7eec72..ba424fef28 100644
--- a/packages/env/src/index.ts
+++ b/packages/env/src/index.ts
@@ -121,6 +121,10 @@ export const MAINTENANCE_MODE = parseBoolean(getEnv("MAINTENANCE_MODE"), false);
export const SYSTEM_STATUS_URL = getEnv("SYSTEM_STATUS_URL");
+export const INTEGRATION_EARLY_ACCESS_USER_IDS = getEnv(
+ "INTEGRATION_EARLY_ACCESS_USER_IDS"
+);
+
// Carbon GovCloud Rider metadata. These are the authoritative `docVersion` /
// `docHash` stamped onto every ITAR certification, and the target of the
// "View the full Rider" link. `ITAR_RIDER_SHA256` is the sha256 of the Rider PDF
diff --git a/packages/env/src/schema.ts b/packages/env/src/schema.ts
index c73b2af038..a78f009aab 100644
--- a/packages/env/src/schema.ts
+++ b/packages/env/src/schema.ts
@@ -128,6 +128,11 @@ export const schema = define({
"URL of a JSON document with the latest version and an announcement",
type: url
},
+ INTEGRATION_EARLY_ACCESS_USER_IDS: {
+ group: "core",
+ description:
+ "Comma-separated user ids that can install Coming soon integrations on Cloud"
+ },
DEFAULT_LANGUAGE: {
group: "core",
description: "Default UI language (en)",