Sashais testingSchematic logo
// Step 1: get the company

const apiKey = "";
const client = new SchematicClient({ apiKey });

const company = await client.companies.lookupCompany({
  keys: { workspace_id: "workspace-1" },
});
// Step 2: get locale limit from the plan entitlement

const entitlements = await client.entitlements.listPlanEntitlements({
  planId: company.data.plan?.id,
});
const entitlement = entitlements.data
  .filter((e) => e.feature?.name === "locale")
  .at(0)?.valueNumeric;
const localesLimit = entitlement ?? 0;
// Step 3: get site locale trait

const workspaceTraits = company.data.traits ?? {};

const workspaceLocaleTrait = workspaceTraits.locale as Record<
  string,
  { count: number }
>;

const siteLocaleTrait = workspaceLocaleTrait["site-1"] ?? { count: 0 };
// Step 4: actual check

const canAddLocale = siteLocaleTrait.count < localesLimit;