@ekanos/cli 0.19.0 → 0.21.0

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.
@@ -14,9 +14,11 @@ export interface AudiencesArgs {
14
14
  /**
15
15
  * `audiences` — a Source's audiences, for its Source admin. An audience is a
16
16
  * named set of the Source's products (with optional per-product widget and
17
- * tool rules) that people see in the app: each team member holds one, their
18
- * own else their team's default (`ekanos teams audience`). It replaces a
19
- * product scope; `sources scopes` and `teams scope` keep working until 0.20.
17
+ * tool rules) that people see in the app. Each team is on one, its business
18
+ * type (`ekanos teams audience`), and every member is on their team's; the
19
+ * team's groups narrow it per person (`ekanos teams groups`). It replaces a
20
+ * product scope; `sources scopes` and `teams scope` keep working until the
21
+ * 2027-03-01 sunset.
20
22
  *
21
23
  * list every audience, its products and rules
22
24
  * show <audience> one, in full
@@ -8,9 +8,11 @@ const USAGE = 'Run "ekanos audiences list", "ekanos audiences show <audience>",
8
8
  /**
9
9
  * `audiences` — a Source's audiences, for its Source admin. An audience is a
10
10
  * named set of the Source's products (with optional per-product widget and
11
- * tool rules) that people see in the app: each team member holds one, their
12
- * own else their team's default (`ekanos teams audience`). It replaces a
13
- * product scope; `sources scopes` and `teams scope` keep working until 0.20.
11
+ * tool rules) that people see in the app. Each team is on one, its business
12
+ * type (`ekanos teams audience`), and every member is on their team's; the
13
+ * team's groups narrow it per person (`ekanos teams groups`). It replaces a
14
+ * product scope; `sources scopes` and `teams scope` keep working until the
15
+ * 2027-03-01 sunset.
14
16
  *
15
17
  * list every audience, its products and rules
16
18
  * show <audience> one, in full
@@ -62,7 +64,7 @@ export async function runAudiences(ctx, args) {
62
64
  describeLines(audience),
63
65
  ]),
64
66
  notes: [
65
- 'A person sees the products of their own audience, else their team’s ("ekanos teams audience <team>").',
67
+ 'A person sees their team’s audience ("ekanos teams audience <team>"), narrowed by their groups ("ekanos teams groups list <team>").',
66
68
  ],
67
69
  }));
68
70
  }
@@ -1 +1 @@
1
-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S,cAAc,CACrB,EAAM,EACN,QAAkB,EAClB,KAAa,EACb,OAAO,GAA6B,EAAE;;IAEtC,OAAO,EAAE,CAAC,MAAM,CAAC;QACf,KAAK;QACL,IAAI,QAAE,OAAO,CAAC,IAAI,mCAAI,IAAI;QAC1B,IAAI,EAAE;YACJ,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC;YAC3B,GAAG,CAAC,QAAQ,CAAC,WAAW;gBACtB,CAAC,CAAE,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,CAA6B;gBAChE,CAAC,CAAC,EAAE,CAAC;YACP,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,IAAI,CAAC;YACrE;gBACE,UAAU;gBACV,QAAQ,CAAC,mBAAmB;oBAC1B,CAAC,CAAC,6CAA6C;oBAC/C,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;wBAC5B,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC;wBACrC,CAAC,CAAC,MAAM;aACb;SACF;QACD,KAAK,EAAE;YACL,4FAA4F;SAC7F;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,KAAK,CAAC,IAAY;IACzB,OAAO,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC;AAC7D,CAAC","sourcesContent":["import type {\n Audience,\n AudienceCreateRequest,\n AudienceUpdateRequest,\n} from '@ekanos/integration-schema';\n\nimport { requireSession, resolveAuthEnvironment } from '../auth/session';\nimport type { CliContext } from '../context';\nimport { invalidStateError, usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { resolveSourceTarget } from '../source-target';\nimport {\n createAudience,\n listAudiences,\n showAudience,\n updateAudience,\n} from '../teams-api';\nimport { type Ui, pluralize } from '../ui';\nimport { TeamsClient } from './teams';\n\nexport interface AudiencesArgs {\n host?: string;\n source?: string;\n /** `list`, `show <audience>`, `create <name>`, `set <audience>`. */\n positionals: readonly string[];\n yes: boolean;\n /** `--products`, `--widgets`, `--tools`, `--name`, `--description` … */\n flags?: Record<string, string | boolean | string[]>;\n dir: string;\n env: Record<string, string | undefined>;\n}\n\nconst USAGE =\n 'Run \"ekanos audiences list\", \"ekanos audiences show <audience>\", \"ekanos audiences create <name> [--products a,b | --all-entitled]\" or \"ekanos audiences set <audience> [--products a,b] [--widgets <product>=<id>,…] [--tools <product>=<name>,…]\".';\n\ntype ProductRule = { slug: string; widgetIds?: string[]; toolNames?: string[] };\n\n/**\n * `audiences` — a Source's audiences, for its Source admin. An audience is a\n * named set of the Source's products (with optional per-product widget and\n * tool rules) that people see in the app: each team member holds one, their\n * own else their team's default (`ekanos teams audience`). It replaces a\n * product scope; `sources scopes` and `teams scope` keep working until 0.20.\n *\n * list every audience, its products and rules\n * show <audience> one, in full\n * create <name> … --products a,b | --all-entitled, --description,\n * --default, --widgets <product>=<id>,…,\n * --tools <product>=<name>,…\n * set <audience> … the same flags, plus --name; --products\n * replaces the product set (rules of kept\n * products stay unless re-stated). Dropping a\n * product needs --yes.\n */\nexport async function runAudiences(\n ctx: CliContext,\n args: AudiencesArgs,\n): Promise<ExitCode> {\n const [verb = 'list', rawName, ...extra] = args.positionals;\n if (!['list', 'show', 'create', 'set'].includes(verb)) {\n throw usageError(`Unknown audiences subcommand \"${verb}\".`, USAGE);\n }\n if (extra.length > 0) {\n throw usageError(`Unexpected argument \"${extra[0]}\".`, USAGE);\n }\n if (verb === 'list' && rawName) {\n throw usageError(`Unexpected argument \"${rawName}\".`, USAGE);\n }\n const name = rawName?.trim();\n if (verb !== 'list' && !name) {\n throw usageError(\n verb === 'create'\n ? 'audiences create needs a name.'\n : `audiences ${verb} needs an audience (its name or id).`,\n USAGE,\n );\n }\n const flags = readFlags(args.flags ?? {});\n\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const resolved = await resolveSourceTarget(env, requireSession(env), args);\n const client = new TeamsClient(env, resolved.session);\n const source = resolved.source;\n\n if (verb === 'list') {\n const list = await client.call((token) =>\n listAudiences(env.host, token, source),\n );\n if (list.audiences.length === 0) {\n return ctx.succeed(\n { host: env.host, ...list },\n ctx.ui.result({\n title: `No audiences on ${list.source.slug}`,\n notes: [`\"ekanos audiences create <name> --products a,b\" makes one.`],\n }),\n );\n }\n return ctx.succeed(\n { host: env.host, ...list },\n ctx.ui.result({\n title: `Audiences on ${list.source.slug}`,\n rows: list.audiences.map((audience): [string, string[]] => [\n audience.name,\n describeLines(audience),\n ]),\n notes: [\n 'A person sees the products of their own audience, else their team’s (\"ekanos teams audience <team>\").',\n ],\n }),\n );\n }\n\n if (verb === 'show') {\n const shown = await client.call((token) =>\n showAudience(env.host, token, { source, audience: name! }),\n );\n return ctx.succeed(\n { host: env.host, ...shown },\n renderAudience(ctx.ui, shown.audience, `${shown.audience.name}`),\n );\n }\n\n if (verb === 'create') {\n const body: AudienceCreateRequest = {\n name: name!,\n ...(flags.description !== undefined\n ? { description: flags.description }\n : {}),\n ...(flags.isDefault ? { isDefault: true } : {}),\n ...(flags.allEntitled !== undefined\n ? { includesAllEntitled: flags.allEntitled }\n : {}),\n ...(flags.products || flags.widgets.size > 0 || flags.tools.size > 0\n ? { products: applyRules([], flags) }\n : {}),\n };\n const created = await client.call((token) =>\n createAudience(env.host, token, source, body),\n );\n return ctx.succeed(\n { host: env.host, ...created },\n renderAudience(\n ctx.ui,\n created.audience,\n `Created ${created.audience.name}`,\n ),\n );\n }\n\n const current = await client.call((token) =>\n showAudience(env.host, token, { source, audience: name! }),\n );\n const before = current.audience;\n const body: AudienceUpdateRequest = {\n ...(flags.name !== undefined ? { name: flags.name } : {}),\n ...(flags.description !== undefined\n ? { description: flags.description }\n : {}),\n ...(flags.isDefault ? { isDefault: true } : {}),\n ...(flags.allEntitled !== undefined\n ? { includesAllEntitled: flags.allEntitled }\n : {}),\n };\n if (flags.products || flags.widgets.size > 0 || flags.tools.size > 0) {\n body.products = applyRules(\n before.products.map((product) => ({\n slug: product.slug,\n ...(product.widgetIds ? { widgetIds: product.widgetIds } : {}),\n ...(product.toolNames ? { toolNames: product.toolNames } : {}),\n })),\n flags,\n );\n }\n if (Object.keys(body).length === 0) {\n throw usageError(\n 'Nothing to change.',\n 'Pass --products, --widgets, --tools, --name, --description, --default or --all-entitled.',\n );\n }\n\n const kept = new Set((body.products ?? []).map((product) => product.slug));\n const dropped = body.products\n ? before.products.filter((product) => !kept.has(product.slug))\n : [];\n if (dropped.length > 0 && !args.yes) {\n throw invalidStateError(\n `${before.name} would no longer show ${dropped.map((product) => product.slug).join(', ')}: everyone on it stops seeing ${dropped.length === 1 ? 'it' : 'them'} in the app.`,\n `Re-run with --yes: ekanos audiences set ${quote(before.name)} … --source ${source} --yes`,\n );\n }\n\n const updated = await client.call((token) =>\n updateAudience(env.host, token, { source, audience: name! }, body),\n );\n return ctx.succeed(\n { host: env.host, ...updated },\n renderAudience(\n ctx.ui,\n updated.audience,\n `Updated ${updated.audience.name}`,\n {\n tone: dropped.length > 0 ? 'warn' : 'ok',\n },\n ),\n );\n}\n\ninterface AudienceFlags {\n name?: string;\n description?: string;\n isDefault: boolean;\n allEntitled?: boolean;\n /** Slugs, in the order given; absent when the flag was not passed. */\n products?: string[];\n widgets: Map<string, string[]>;\n tools: Map<string, string[]>;\n}\n\nfunction readFlags(\n flags: Record<string, string | boolean | string[]>,\n): AudienceFlags {\n const text = (key: string) =>\n typeof flags[key] === 'string' ? (flags[key] as string) : undefined;\n const list = (key: string) => {\n const value = flags[key];\n return Array.isArray(value)\n ? value\n : typeof value === 'string'\n ? [value]\n : [];\n };\n\n const products = text('products');\n return {\n name: text('name'),\n description: text('description'),\n isDefault: flags.default === true,\n allEntitled:\n typeof flags['all-entitled'] === 'boolean'\n ? (flags['all-entitled'] as boolean)\n : undefined,\n products:\n products === undefined\n ? undefined\n : products === 'none'\n ? []\n : products\n .split(',')\n .map((slug) => slug.trim().toLowerCase())\n .filter(Boolean),\n widgets: ruleMap('widgets', list('widgets')),\n tools: ruleMap('tools', list('tools')),\n };\n}\n\n/** `linear=w1,w2` per product; `linear=` clears the rule (all of them). */\nfunction ruleMap(flag: string, values: string[]): Map<string, string[]> {\n const rules = new Map<string, string[]>();\n for (const value of values) {\n const at = value.indexOf('=');\n const slug = (at < 0 ? value : value.slice(0, at)).trim().toLowerCase();\n if (!slug || at < 0) {\n throw usageError(\n `--${flag} takes <product>=<name>,<name>… (got \"${value}\").`,\n `e.g. --${flag} linear=${flag === 'widgets' ? 'linear-issues' : 'create_issue'}; \"<product>=\" lifts the rule.`,\n );\n }\n rules.set(\n slug,\n value\n .slice(at + 1)\n .split(',')\n .map((item) => item.trim())\n .filter(Boolean),\n );\n }\n return rules;\n}\n\n/** The product set after `--products` and the widget and tool rules. */\nfunction applyRules(base: ProductRule[], flags: AudienceFlags): ProductRule[] {\n const known = new Map(base.map((product) => [product.slug, product]));\n const slugs = flags.products ?? base.map((product) => product.slug);\n\n const products = slugs.map((slug): ProductRule => {\n const existing = known.get(slug);\n return {\n slug,\n ...(existing?.widgetIds ? { widgetIds: existing.widgetIds } : {}),\n ...(existing?.toolNames ? { toolNames: existing.toolNames } : {}),\n };\n });\n for (const [kind, rules] of [\n ['widgetIds', flags.widgets],\n ['toolNames', flags.tools],\n ] as const) {\n for (const [slug, names] of rules) {\n const product = products.find((entry) => entry.slug === slug);\n if (!product) {\n throw usageError(\n `--${kind === 'widgetIds' ? 'widgets' : 'tools'} names ${slug}, which the audience would not show.`,\n 'Add it with --products, or name a product that is in the audience.',\n );\n }\n if (names.length > 0) product[kind] = names;\n else delete product[kind];\n }\n }\n return products;\n}\n\nfunction describeLines(audience: Audience): string[] {\n const lines = [\n [\n audience.includesAllEntitled\n ? 'every product the Source has'\n : pluralize(audience.products.length, 'product'),\n audience.isDefault ? 'given to every new team' : null,\n ]\n .filter(Boolean)\n .join(' · '),\n ];\n if (!audience.includesAllEntitled) {\n lines.push(\n audience.products.length > 0\n ? audience.products.map(productWords).join(', ')\n : 'no products',\n );\n }\n return lines;\n}\n\nfunction productWords(product: Audience['products'][number]): string {\n const rules = [\n product.widgetIds\n ? `${pluralize(product.widgetIds.length, 'widget')}`\n : null,\n product.toolNames ? `${pluralize(product.toolNames.length, 'tool')}` : null,\n ].filter(Boolean);\n return rules.length > 0\n ? `${product.slug} (only ${rules.join(', ')})`\n : product.slug;\n}\n\nfunction renderAudience(\n ui: Ui,\n audience: Audience,\n title: string,\n options: { tone?: 'ok' | 'warn' } = {},\n): string {\n return ui.result({\n title,\n tone: options.tone ?? 'ok',\n rows: [\n ['Audience', audience.name],\n ...(audience.description\n ? ([['About', audience.description]] as Array<[string, string]>)\n : []),\n ['Default', audience.isDefault ? 'yes, new teams start on it' : 'no'],\n [\n 'Products',\n audience.includesAllEntitled\n ? 'every product the Source has, now and later'\n : audience.products.length > 0\n ? audience.products.map(productWords)\n : 'none',\n ],\n ],\n notes: [\n 'Teams and members are put on an audience with \"ekanos teams audience <team> [<audience>]\".',\n ],\n });\n}\n\nfunction quote(name: string): string {\n return /^[A-Za-z0-9._-]+$/.test(name) ? name : `\"${name}\"`;\n}\n"]}
1
+ {"version":3,"file":"audiences.js","sourceRoot":"","sources":["../../src/commands/audiences.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EACL,cAAc,EACd,aAAa,EACb,YAAY,EACZ,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAW,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AActC,MAAM,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CAAC,4BAA4B,CAAC,CAAC,CAAC,IAAI,CAAC;YACrE;gBACE,UAAU;gBACV,QAAQ,CAAC,mBAAmB;oBAC1B,CAAC,CAAC,6CAA6C;oBAC/C,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;wBAC5B,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC;wBACrC,CAAC,CAAC,MAAM;aACb;SACF;QACD,KAAK,EAAE;YACL,4FAA4F;SAC7F;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,KAAK,CAAC,IAAY;IACzB,OAAO,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC;AAC7D,CAAC","sourcesContent":["import type {\n Audience,\n AudienceCreateRequest,\n AudienceUpdateRequest,\n} from '@ekanos/integration-schema';\n\nimport { requireSession, resolveAuthEnvironment } from '../auth/session';\nimport type { CliContext } from '../context';\nimport { invalidStateError, usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { resolveSourceTarget } from '../source-target';\nimport {\n createAudience,\n listAudiences,\n showAudience,\n updateAudience,\n} from '../teams-api';\nimport { type Ui, pluralize } from '../ui';\nimport { TeamsClient } from './teams';\n\nexport interface AudiencesArgs {\n host?: string;\n source?: string;\n /** `list`, `show <audience>`, `create <name>`, `set <audience>`. */\n positionals: readonly string[];\n yes: boolean;\n /** `--products`, `--widgets`, `--tools`, `--name`, `--description` … */\n flags?: Record<string, string | boolean | string[]>;\n dir: string;\n env: Record<string, string | undefined>;\n}\n\nconst USAGE =\n 'Run \"ekanos audiences list\", \"ekanos audiences show <audience>\", \"ekanos audiences create <name> [--products a,b | --all-entitled]\" or \"ekanos audiences set <audience> [--products a,b] [--widgets <product>=<id>,…] [--tools <product>=<name>,…]\".';\n\ntype ProductRule = { slug: string; widgetIds?: string[]; toolNames?: string[] };\n\n/**\n * `audiences` — a Source's audiences, for its Source admin. An audience is a\n * named set of the Source's products (with optional per-product widget and\n * tool rules) that people see in the app. Each team is on one, its business\n * type (`ekanos teams audience`), and every member is on their team's; the\n * team's groups narrow it per person (`ekanos teams groups`). It replaces a\n * product scope; `sources scopes` and `teams scope` keep working until the\n * 2027-03-01 sunset.\n *\n * list every audience, its products and rules\n * show <audience> one, in full\n * create <name> … --products a,b | --all-entitled, --description,\n * --default, --widgets <product>=<id>,…,\n * --tools <product>=<name>,…\n * set <audience> … the same flags, plus --name; --products\n * replaces the product set (rules of kept\n * products stay unless re-stated). Dropping a\n * product needs --yes.\n */\nexport async function runAudiences(\n ctx: CliContext,\n args: AudiencesArgs,\n): Promise<ExitCode> {\n const [verb = 'list', rawName, ...extra] = args.positionals;\n if (!['list', 'show', 'create', 'set'].includes(verb)) {\n throw usageError(`Unknown audiences subcommand \"${verb}\".`, USAGE);\n }\n if (extra.length > 0) {\n throw usageError(`Unexpected argument \"${extra[0]}\".`, USAGE);\n }\n if (verb === 'list' && rawName) {\n throw usageError(`Unexpected argument \"${rawName}\".`, USAGE);\n }\n const name = rawName?.trim();\n if (verb !== 'list' && !name) {\n throw usageError(\n verb === 'create'\n ? 'audiences create needs a name.'\n : `audiences ${verb} needs an audience (its name or id).`,\n USAGE,\n );\n }\n const flags = readFlags(args.flags ?? {});\n\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const resolved = await resolveSourceTarget(env, requireSession(env), args);\n const client = new TeamsClient(env, resolved.session);\n const source = resolved.source;\n\n if (verb === 'list') {\n const list = await client.call((token) =>\n listAudiences(env.host, token, source),\n );\n if (list.audiences.length === 0) {\n return ctx.succeed(\n { host: env.host, ...list },\n ctx.ui.result({\n title: `No audiences on ${list.source.slug}`,\n notes: [`\"ekanos audiences create <name> --products a,b\" makes one.`],\n }),\n );\n }\n return ctx.succeed(\n { host: env.host, ...list },\n ctx.ui.result({\n title: `Audiences on ${list.source.slug}`,\n rows: list.audiences.map((audience): [string, string[]] => [\n audience.name,\n describeLines(audience),\n ]),\n notes: [\n 'A person sees their team’s audience (\"ekanos teams audience <team>\"), narrowed by their groups (\"ekanos teams groups list <team>\").',\n ],\n }),\n );\n }\n\n if (verb === 'show') {\n const shown = await client.call((token) =>\n showAudience(env.host, token, { source, audience: name! }),\n );\n return ctx.succeed(\n { host: env.host, ...shown },\n renderAudience(ctx.ui, shown.audience, `${shown.audience.name}`),\n );\n }\n\n if (verb === 'create') {\n const body: AudienceCreateRequest = {\n name: name!,\n ...(flags.description !== undefined\n ? { description: flags.description }\n : {}),\n ...(flags.isDefault ? { isDefault: true } : {}),\n ...(flags.allEntitled !== undefined\n ? { includesAllEntitled: flags.allEntitled }\n : {}),\n ...(flags.products || flags.widgets.size > 0 || flags.tools.size > 0\n ? { products: applyRules([], flags) }\n : {}),\n };\n const created = await client.call((token) =>\n createAudience(env.host, token, source, body),\n );\n return ctx.succeed(\n { host: env.host, ...created },\n renderAudience(\n ctx.ui,\n created.audience,\n `Created ${created.audience.name}`,\n ),\n );\n }\n\n const current = await client.call((token) =>\n showAudience(env.host, token, { source, audience: name! }),\n );\n const before = current.audience;\n const body: AudienceUpdateRequest = {\n ...(flags.name !== undefined ? { name: flags.name } : {}),\n ...(flags.description !== undefined\n ? { description: flags.description }\n : {}),\n ...(flags.isDefault ? { isDefault: true } : {}),\n ...(flags.allEntitled !== undefined\n ? { includesAllEntitled: flags.allEntitled }\n : {}),\n };\n if (flags.products || flags.widgets.size > 0 || flags.tools.size > 0) {\n body.products = applyRules(\n before.products.map((product) => ({\n slug: product.slug,\n ...(product.widgetIds ? { widgetIds: product.widgetIds } : {}),\n ...(product.toolNames ? { toolNames: product.toolNames } : {}),\n })),\n flags,\n );\n }\n if (Object.keys(body).length === 0) {\n throw usageError(\n 'Nothing to change.',\n 'Pass --products, --widgets, --tools, --name, --description, --default or --all-entitled.',\n );\n }\n\n const kept = new Set((body.products ?? []).map((product) => product.slug));\n const dropped = body.products\n ? before.products.filter((product) => !kept.has(product.slug))\n : [];\n if (dropped.length > 0 && !args.yes) {\n throw invalidStateError(\n `${before.name} would no longer show ${dropped.map((product) => product.slug).join(', ')}: everyone on it stops seeing ${dropped.length === 1 ? 'it' : 'them'} in the app.`,\n `Re-run with --yes: ekanos audiences set ${quote(before.name)} … --source ${source} --yes`,\n );\n }\n\n const updated = await client.call((token) =>\n updateAudience(env.host, token, { source, audience: name! }, body),\n );\n return ctx.succeed(\n { host: env.host, ...updated },\n renderAudience(\n ctx.ui,\n updated.audience,\n `Updated ${updated.audience.name}`,\n {\n tone: dropped.length > 0 ? 'warn' : 'ok',\n },\n ),\n );\n}\n\ninterface AudienceFlags {\n name?: string;\n description?: string;\n isDefault: boolean;\n allEntitled?: boolean;\n /** Slugs, in the order given; absent when the flag was not passed. */\n products?: string[];\n widgets: Map<string, string[]>;\n tools: Map<string, string[]>;\n}\n\nfunction readFlags(\n flags: Record<string, string | boolean | string[]>,\n): AudienceFlags {\n const text = (key: string) =>\n typeof flags[key] === 'string' ? (flags[key] as string) : undefined;\n const list = (key: string) => {\n const value = flags[key];\n return Array.isArray(value)\n ? value\n : typeof value === 'string'\n ? [value]\n : [];\n };\n\n const products = text('products');\n return {\n name: text('name'),\n description: text('description'),\n isDefault: flags.default === true,\n allEntitled:\n typeof flags['all-entitled'] === 'boolean'\n ? (flags['all-entitled'] as boolean)\n : undefined,\n products:\n products === undefined\n ? undefined\n : products === 'none'\n ? []\n : products\n .split(',')\n .map((slug) => slug.trim().toLowerCase())\n .filter(Boolean),\n widgets: ruleMap('widgets', list('widgets')),\n tools: ruleMap('tools', list('tools')),\n };\n}\n\n/** `linear=w1,w2` per product; `linear=` clears the rule (all of them). */\nfunction ruleMap(flag: string, values: string[]): Map<string, string[]> {\n const rules = new Map<string, string[]>();\n for (const value of values) {\n const at = value.indexOf('=');\n const slug = (at < 0 ? value : value.slice(0, at)).trim().toLowerCase();\n if (!slug || at < 0) {\n throw usageError(\n `--${flag} takes <product>=<name>,<name>… (got \"${value}\").`,\n `e.g. --${flag} linear=${flag === 'widgets' ? 'linear-issues' : 'create_issue'}; \"<product>=\" lifts the rule.`,\n );\n }\n rules.set(\n slug,\n value\n .slice(at + 1)\n .split(',')\n .map((item) => item.trim())\n .filter(Boolean),\n );\n }\n return rules;\n}\n\n/** The product set after `--products` and the widget and tool rules. */\nfunction applyRules(base: ProductRule[], flags: AudienceFlags): ProductRule[] {\n const known = new Map(base.map((product) => [product.slug, product]));\n const slugs = flags.products ?? base.map((product) => product.slug);\n\n const products = slugs.map((slug): ProductRule => {\n const existing = known.get(slug);\n return {\n slug,\n ...(existing?.widgetIds ? { widgetIds: existing.widgetIds } : {}),\n ...(existing?.toolNames ? { toolNames: existing.toolNames } : {}),\n };\n });\n for (const [kind, rules] of [\n ['widgetIds', flags.widgets],\n ['toolNames', flags.tools],\n ] as const) {\n for (const [slug, names] of rules) {\n const product = products.find((entry) => entry.slug === slug);\n if (!product) {\n throw usageError(\n `--${kind === 'widgetIds' ? 'widgets' : 'tools'} names ${slug}, which the audience would not show.`,\n 'Add it with --products, or name a product that is in the audience.',\n );\n }\n if (names.length > 0) product[kind] = names;\n else delete product[kind];\n }\n }\n return products;\n}\n\nfunction describeLines(audience: Audience): string[] {\n const lines = [\n [\n audience.includesAllEntitled\n ? 'every product the Source has'\n : pluralize(audience.products.length, 'product'),\n audience.isDefault ? 'given to every new team' : null,\n ]\n .filter(Boolean)\n .join(' · '),\n ];\n if (!audience.includesAllEntitled) {\n lines.push(\n audience.products.length > 0\n ? audience.products.map(productWords).join(', ')\n : 'no products',\n );\n }\n return lines;\n}\n\nfunction productWords(product: Audience['products'][number]): string {\n const rules = [\n product.widgetIds\n ? `${pluralize(product.widgetIds.length, 'widget')}`\n : null,\n product.toolNames ? `${pluralize(product.toolNames.length, 'tool')}` : null,\n ].filter(Boolean);\n return rules.length > 0\n ? `${product.slug} (only ${rules.join(', ')})`\n : product.slug;\n}\n\nfunction renderAudience(\n ui: Ui,\n audience: Audience,\n title: string,\n options: { tone?: 'ok' | 'warn' } = {},\n): string {\n return ui.result({\n title,\n tone: options.tone ?? 'ok',\n rows: [\n ['Audience', audience.name],\n ...(audience.description\n ? ([['About', audience.description]] as Array<[string, string]>)\n : []),\n ['Default', audience.isDefault ? 'yes, new teams start on it' : 'no'],\n [\n 'Products',\n audience.includesAllEntitled\n ? 'every product the Source has, now and later'\n : audience.products.length > 0\n ? audience.products.map(productWords)\n : 'none',\n ],\n ],\n notes: [\n 'Teams and members are put on an audience with \"ekanos teams audience <team> [<audience>]\".',\n ],\n });\n}\n\nfunction quote(name: string): string {\n return /^[A-Za-z0-9._-]+$/.test(name) ? name : `\"${name}\"`;\n}\n"]}
@@ -2,14 +2,15 @@ import type { TeamScopeState } from '@ekanos/integration-schema';
2
2
  /**
3
3
  * A product the CLI reports as ready for a team can still be hidden from the
4
4
  * team in the app by the team's product scopes — the "Bronze" scope that
5
- * hid Linear and Zendesk on a team whose setup read as done. Wherever the
6
- * CLI says a product is ready, it says this too, with the command that
7
- * changes it.
5
+ * hid Linear and Zendesk on a team whose setup read as done — or, once a
6
+ * Source's scopes are retired, by the team's audience (its business type).
7
+ * Wherever the CLI says a product is ready, it says this too, with the
8
+ * command that changes it.
8
9
  */
9
10
  /**
10
11
  * The one line `sources scopes` and `teams scope` print (to stderr, so JSON
11
12
  * on stdout is unchanged): a scope is an audience now. Both commands keep
12
- * their published behaviour until 0.20.
13
+ * their published behaviour until the scope routes' 2027-03-01 sunset.
13
14
  */
14
15
  export declare function scopeDeprecationNotice(replacement: string): string;
15
16
  export interface ScopeFacts {
@@ -2,30 +2,41 @@ import { cli } from '../invocation.js';
2
2
  /**
3
3
  * A product the CLI reports as ready for a team can still be hidden from the
4
4
  * team in the app by the team's product scopes — the "Bronze" scope that
5
- * hid Linear and Zendesk on a team whose setup read as done. Wherever the
6
- * CLI says a product is ready, it says this too, with the command that
7
- * changes it.
5
+ * hid Linear and Zendesk on a team whose setup read as done — or, once a
6
+ * Source's scopes are retired, by the team's audience (its business type).
7
+ * Wherever the CLI says a product is ready, it says this too, with the
8
+ * command that changes it.
8
9
  */
9
10
  /**
10
11
  * The one line `sources scopes` and `teams scope` print (to stderr, so JSON
11
12
  * on stdout is unchanged): a scope is an audience now. Both commands keep
12
- * their published behaviour until 0.20.
13
+ * their published behaviour until the scope routes' 2027-03-01 sunset.
13
14
  */
14
15
  export function scopeDeprecationNotice(replacement) {
15
- return `Deprecated: product scopes are audiences now. Use "${cli()} ${replacement}"; this command keeps working until 0.20.`;
16
+ return `Deprecated: product scopes are audiences now. Use "${cli()} ${replacement}"; this command keeps working until 2027-03-01.`;
16
17
  }
17
18
  /** "hidden by its product scope Bronze" — the problem, in words. */
18
19
  export function scopeHiddenWords(scope) {
19
- return scope.state === 'locked_out' || scope.scopes.length === 0
20
- ? 'hidden from the team in the app: it holds none of the Source’s product scopes'
21
- : `hidden from the team in the app by its product scope${scope.scopes.length === 1 ? '' : 's'} ${scope.scopes.join(', ')}`;
20
+ // No scope held and still scoped: the team's audience (its business type)
21
+ // decides, which only a host whose scopes are retired reports.
22
+ if (scope.state === 'locked_out') {
23
+ return 'hidden from the team in the app: it holds none of the Source’s product scopes, and no audience';
24
+ }
25
+ if (scope.scopes.length === 0) {
26
+ return 'hidden from the team in the app by its audience';
27
+ }
28
+ return `hidden from the team in the app by its product scope${scope.scopes.length === 1 ? '' : 's'} ${scope.scopes.join(', ')}`;
22
29
  }
23
30
  /** The command that shows the product to the team. */
24
31
  export function scopeFix(scope, target) {
25
- const set = `${cli()} teams scope set ${target.team} <scope> --source ${target.source}`;
26
- if (scope.state === 'locked_out' || scope.scopes.length === 0) {
27
- return `${set} (scopes and their products: ${cli()} sources scopes --source ${target.source})`;
32
+ const audience = `${cli()} teams audience ${target.team} <audience> --source ${target.source}`;
33
+ if (scope.state === 'locked_out') {
34
+ return `${audience} (audiences and their products: ${cli()} audiences list --source ${target.source}; a host still on scopes: ${cli()} teams scope set ${target.team} <scope>)`;
28
35
  }
36
+ if (scope.scopes.length === 0) {
37
+ return `"${cli()} teams audience ${target.team} --source ${target.source}" names its audience; add ${target.product} to it with "${cli()} audiences set <audience> --products …", or move the team: ${audience}`;
38
+ }
39
+ const set = `${cli()} teams scope set ${target.team} <scope> --source ${target.source}`;
29
40
  return `${cli()} sources scopes add ${quote(scope.scopes[0])} ${target.product} --source ${target.source} (every team on ${scope.scopes[0]} then sees it; or move the team to a scope that has it: ${set})`;
30
41
  }
31
42
  /** The two lines `teams show` / `teams connect` print for a hidden product. */
@@ -1 +1 @@
1
- {"version":3,"file":"scope-notice.js","sourceRoot":"","sources":["../../src/commands/scope-notice.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC;;;;;;GAMG;AAEH;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,WAAmB;IACxD,OAAO,sDAAsD,GAAG,EAAE,IAAI,WAAW,2CAA2C,CAAC;AAC/H,CAAC;AAOD,oEAAoE;AACpE,MAAM,UAAU,gBAAgB,CAAC,KAAiB;IAChD,OAAO,KAAK,CAAC,KAAK,KAAK,YAAY,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;QAC9D,CAAC,CAAC,+EAA+E;QACjF,CAAC,CAAC,uDAAuD,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AAC/H,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,QAAQ,CACtB,KAAiB,EACjB,MAAyD;IAEzD,MAAM,GAAG,GAAG,GAAG,GAAG,EAAE,oBAAoB,MAAM,CAAC,IAAI,qBAAqB,MAAM,CAAC,MAAM,EAAE,CAAC;IACxF,IAAI,KAAK,CAAC,KAAK,KAAK,YAAY,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9D,OAAO,GAAG,GAAG,iCAAiC,GAAG,EAAE,4BAA4B,MAAM,CAAC,MAAM,GAAG,CAAC;IAClG,CAAC;IACD,OAAO,GAAG,GAAG,EAAE,uBAAuB,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,IAAI,MAAM,CAAC,OAAO,aAAa,MAAM,CAAC,MAAM,oBAAoB,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,2DAA2D,GAAG,GAAG,CAAC;AAChN,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,gBAAgB,CAC9B,KAAqD,EACrD,MAAyD;IAEzD,IAAI,EAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,CAAA;QAAE,OAAO,EAAE,CAAC;IAC9B,OAAO;QACL,KAAK,MAAM,CAAC,OAAO,OAAO,gBAAgB,CAAC,KAAK,CAAC,GAAG;QACpD,UAAU,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE;KACpC,CAAC;AACJ,CAAC;AAED,SAAS,KAAK,CAAC,IAAY;IACzB,OAAO,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC;AAC7D,CAAC","sourcesContent":["import type { TeamScopeState } from '@ekanos/integration-schema';\n\nimport { cli } from '../invocation';\n\n/**\n * A product the CLI reports as ready for a team can still be hidden from the\n * team in the app by the team's product scopes — the \"Bronze\" scope that\n * hid Linear and Zendesk on a team whose setup read as done. Wherever the\n * CLI says a product is ready, it says this too, with the command that\n * changes it.\n */\n\n/**\n * The one line `sources scopes` and `teams scope` print (to stderr, so JSON\n * on stdout is unchanged): a scope is an audience now. Both commands keep\n * their published behaviour until 0.20.\n */\nexport function scopeDeprecationNotice(replacement: string): string {\n return `Deprecated: product scopes are audiences now. Use \"${cli()} ${replacement}\"; this command keeps working until 0.20.`;\n}\n\nexport interface ScopeFacts {\n state: TeamScopeState;\n scopes: string[];\n}\n\n/** \"hidden by its product scope Bronze\" — the problem, in words. */\nexport function scopeHiddenWords(scope: ScopeFacts): string {\n return scope.state === 'locked_out' || scope.scopes.length === 0\n ? 'hidden from the team in the app: it holds none of the Source’s product scopes'\n : `hidden from the team in the app by its product scope${scope.scopes.length === 1 ? '' : 's'} ${scope.scopes.join(', ')}`;\n}\n\n/** The command that shows the product to the team. */\nexport function scopeFix(\n scope: ScopeFacts,\n target: { team: string; product: string; source: string },\n): string {\n const set = `${cli()} teams scope set ${target.team} <scope> --source ${target.source}`;\n if (scope.state === 'locked_out' || scope.scopes.length === 0) {\n return `${set} (scopes and their products: ${cli()} sources scopes --source ${target.source})`;\n }\n return `${cli()} sources scopes add ${quote(scope.scopes[0]!)} ${target.product} --source ${target.source} (every team on ${scope.scopes[0]} then sees it; or move the team to a scope that has it: ${set})`;\n}\n\n/** The two lines `teams show` / `teams connect` print for a hidden product. */\nexport function scopeHiddenLines(\n scope: (ScopeFacts & { hidden: boolean }) | undefined,\n target: { team: string; product: string; source: string },\n): string[] {\n if (!scope?.hidden) return [];\n return [\n `! ${target.product} is ${scopeHiddenWords(scope)}.`,\n ` Fix: ${scopeFix(scope, target)}`,\n ];\n}\n\nfunction quote(name: string): string {\n return /^[A-Za-z0-9._-]+$/.test(name) ? name : `\"${name}\"`;\n}\n"]}
1
+ {"version":3,"file":"scope-notice.js","sourceRoot":"","sources":["../../src/commands/scope-notice.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC;;;;;;;GAOG;AAEH;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,WAAmB;IACxD,OAAO,sDAAsD,GAAG,EAAE,IAAI,WAAW,iDAAiD,CAAC;AACrI,CAAC;AAOD,oEAAoE;AACpE,MAAM,UAAU,gBAAgB,CAAC,KAAiB;IAChD,0EAA0E;IAC1E,+DAA+D;IAC/D,IAAI,KAAK,CAAC,KAAK,KAAK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CAAC,CAAC,CAAC,2DAA2D,GAAG,GAAG,CAAC;AAChN,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,gBAAgB,CAC9B,KAAqD,EACrD,MAAyD;IAEzD,IAAI,EAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,CAAA;QAAE,OAAO,EAAE,CAAC;IAC9B,OAAO;QACL,KAAK,MAAM,CAAC,OAAO,OAAO,gBAAgB,CAAC,KAAK,CAAC,GAAG;QACpD,UAAU,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE;KACpC,CAAC;AACJ,CAAC;AAED,SAAS,KAAK,CAAC,IAAY;IACzB,OAAO,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC;AAC7D,CAAC","sourcesContent":["import type { TeamScopeState } from '@ekanos/integration-schema';\n\nimport { cli } from '../invocation';\n\n/**\n * A product the CLI reports as ready for a team can still be hidden from the\n * team in the app by the team's product scopes — the \"Bronze\" scope that\n * hid Linear and Zendesk on a team whose setup read as done — or, once a\n * Source's scopes are retired, by the team's audience (its business type).\n * Wherever the CLI says a product is ready, it says this too, with the\n * command that changes it.\n */\n\n/**\n * The one line `sources scopes` and `teams scope` print (to stderr, so JSON\n * on stdout is unchanged): a scope is an audience now. Both commands keep\n * their published behaviour until the scope routes' 2027-03-01 sunset.\n */\nexport function scopeDeprecationNotice(replacement: string): string {\n return `Deprecated: product scopes are audiences now. Use \"${cli()} ${replacement}\"; this command keeps working until 2027-03-01.`;\n}\n\nexport interface ScopeFacts {\n state: TeamScopeState;\n scopes: string[];\n}\n\n/** \"hidden by its product scope Bronze\" — the problem, in words. */\nexport function scopeHiddenWords(scope: ScopeFacts): string {\n // No scope held and still scoped: the team's audience (its business type)\n // decides, which only a host whose scopes are retired reports.\n if (scope.state === 'locked_out') {\n return 'hidden from the team in the app: it holds none of the Source’s product scopes, and no audience';\n }\n if (scope.scopes.length === 0) {\n return 'hidden from the team in the app by its audience';\n }\n return `hidden from the team in the app by its product scope${scope.scopes.length === 1 ? '' : 's'} ${scope.scopes.join(', ')}`;\n}\n\n/** The command that shows the product to the team. */\nexport function scopeFix(\n scope: ScopeFacts,\n target: { team: string; product: string; source: string },\n): string {\n const audience = `${cli()} teams audience ${target.team} <audience> --source ${target.source}`;\n if (scope.state === 'locked_out') {\n return `${audience} (audiences and their products: ${cli()} audiences list --source ${target.source}; a host still on scopes: ${cli()} teams scope set ${target.team} <scope>)`;\n }\n if (scope.scopes.length === 0) {\n return `\"${cli()} teams audience ${target.team} --source ${target.source}\" names its audience; add ${target.product} to it with \"${cli()} audiences set <audience> --products …\", or move the team: ${audience}`;\n }\n const set = `${cli()} teams scope set ${target.team} <scope> --source ${target.source}`;\n return `${cli()} sources scopes add ${quote(scope.scopes[0]!)} ${target.product} --source ${target.source} (every team on ${scope.scopes[0]} then sees it; or move the team to a scope that has it: ${set})`;\n}\n\n/** The two lines `teams show` / `teams connect` print for a hidden product. */\nexport function scopeHiddenLines(\n scope: (ScopeFacts & { hidden: boolean }) | undefined,\n target: { team: string; product: string; source: string },\n): string[] {\n if (!scope?.hidden) return [];\n return [\n `! ${target.product} is ${scopeHiddenWords(scope)}.`,\n ` Fix: ${scopeFix(scope, target)}`,\n ];\n}\n\nfunction quote(name: string): string {\n return /^[A-Za-z0-9._-]+$/.test(name) ? name : `\"${name}\"`;\n}\n"]}
@@ -211,7 +211,7 @@ async function runProducts(ctx, args, rest) {
211
211
  * scope's products and how many teams hold it. Once a Source has a scope,
212
212
  * each team sees in the app only its scopes' products. `add|remove <scope>
213
213
  * <product>` changes one scope (by name or id) through what
214
- * `/admin/sources/[id]/product-scopes` uses; a product can only be added if
214
+ * `/admin/sources/[id]/scopes` uses; a product can only be added if
215
215
  * the Source has it. Taking one out hides it from every team on the scope
216
216
  * that no other of its scopes shows it to, so that needs `--yes`.
217
217
  */
@@ -1 +1 @@
1
- {"version":3,"file":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wCAAwC,EACxE,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CACpB,CAAC;IACJ,CAAC;CACF","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport type { StoredSession } from '../auth/credential-store';\nimport { loginHint } from '../auth/host-trust';\nimport {\n type AuthEnvironment,\n refreshStoredSession,\n requireSession,\n resolveAuthEnvironment,\n} from '../auth/session';\nimport type { CliContext } from '../context';\nimport { authRequiredError, invalidStateError, usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { hostPredatesFeatures, productGroup } from '../product-kinds';\nimport { EKANOS_CONFIG_FILENAME } from '../project';\nimport { fetchSeatsWithOneRefresh } from '../seats';\nimport {\n type SourceProduct,\n type SourceProductsApiResult,\n listSourceProducts,\n setSourceProduct,\n} from '../source-products-api';\nimport { resolveSourceTarget } from '../source-target';\nimport { type SourceSeat, stillUnauthorizedSourceSeats } from '../sources-api';\nimport { listProductScopes, setScopeProduct } from '../teams-api';\nimport { type Ui, pluralize, shortHost } from '../ui';\nimport { scopeDeprecationNotice } from './scope-notice';\nimport { runSourcePeople, runSourceRoles } from './sources-roles';\n\nexport interface SourcesArgs {\n host?: string;\n /** `products [enable|disable <product>]`, `scopes [add|remove <scope> <product>]`; none lists the sources. */\n positionals?: readonly string[];\n source?: string;\n yes?: boolean;\n /** `roles` and `people`: their flags (`--level`, `--permission`, `--search` …). */\n flags?: Record<string, string | boolean | string[]>;\n /** `roles delete` asks at a terminal; the test seams for it. */\n stdinIsTTY?: boolean;\n ask?: (question: string) => Promise<string>;\n /** Where a project's ekanos.json may sit — its `source` field, if any, is the marker. */\n dir: string;\n env: Record<string, string | undefined>;\n}\n\n/**\n * `sources` — list every source the caller holds a developer or admin seat\n * on, the read half of the publish-target-verification story.\n *\n * The list itself is the mechanism that makes `publish` safe: a partner (or\n * an agent acting for one) can always answer \"which sources can I possibly\n * publish to?\" before running `ekanos use` or passing `--source`.\n */\nexport async function runSources(\n ctx: CliContext,\n args: SourcesArgs,\n): Promise<ExitCode> {\n const [subcommand, ...rest] = args.positionals ?? [];\n if (subcommand !== undefined) {\n if (subcommand === 'scopes') return runScopes(ctx, args, rest);\n if (subcommand === 'roles') return runSourceRoles(ctx, args, rest);\n if (subcommand === 'people') return runSourcePeople(ctx, args, rest);\n if (subcommand !== 'products') {\n throw usageError(\n `Unknown sources subcommand \"${subcommand}\".`,\n 'Run \"ekanos sources\" to list your sources, \"ekanos sources products [enable|disable <product>]\", \"ekanos sources scopes [add|remove <scope> <product>]\", \"ekanos sources roles [list|create|update|delete <role>]\" or \"ekanos sources people\".',\n );\n }\n return runProducts(ctx, args, rest);\n }\n\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const session = requireSession(env);\n\n const result = await fetchSeatsWithOneRefresh(env, session);\n\n if (result.status === 'unauthorized') {\n stillUnauthorizedSourceSeats(env);\n }\n\n const activeSource = readActiveSource(args.dir);\n\n return ctx.succeed(\n { host: env.host, sources: result.sources, activeSource },\n humanSummary(ctx.ui, env.host, result.sources, activeSource),\n );\n}\n\n/**\n * Best-effort, lenient read of ekanos.json's `source` field — mirrors\n * `readProjectHost` in `auth/session.ts`. A missing, unparseable, or\n * sourceless ekanos.json (or no project at all) simply means \"no active\n * source to mark\", never an error: `sources` must answer outside a project\n * too.\n */\nexport function readActiveSource(dir: string): string | null {\n const configPath = path.join(dir, EKANOS_CONFIG_FILENAME);\n\n let raw: string;\n try {\n raw = fs.readFileSync(configPath, 'utf8');\n } catch {\n return null;\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n return null;\n }\n\n const source =\n typeof parsed === 'object' && parsed !== null\n ? (parsed as { source?: unknown }).source\n : undefined;\n\n return typeof source === 'string' && source.trim().length > 0\n ? source.trim()\n : null;\n}\n\n/** Why a product is not enabled, by the lever that would enable it — the words `catalog` uses. */\nconst NOT_ENABLED_BECAUSE: Record<SourceProduct['lever'], string> = {\n flag: 'its Flag is off',\n plan: 'no active plan',\n entitlement: 'not granted',\n};\n\nfunction humanSummary(\n ui: Ui,\n host: string,\n sources: SourceSeat[],\n activeSource: string | null,\n): string {\n if (sources.length === 0) {\n return ui.result({\n // Read by any signed-in account, a team member's too: no word here\n // may imply the host serves more than one customer.\n title: 'No partner seats',\n tone: 'warn',\n rows: [['Host', shortHost(host)]],\n notes: ['This account has no partner seats on this host.'],\n });\n }\n\n const orphaned =\n activeSource && !sources.some((s) => s.slug === activeSource);\n\n return ui.result({\n title: `${pluralize(sources.length, 'source')} on ${shortHost(host)}`,\n rows: sources.map((source): [string, string] => [\n source.slug,\n [\n source.name ?? '(unnamed)',\n source.roles.join(', '),\n ...(source.slug === activeSource ? [ui.accent('this project')] : []),\n ].join(' · '),\n ]),\n notes: orphaned\n ? [\n `This project's ekanos.json points at \"${activeSource}\", which is not in the list above.`,\n ]\n : [],\n });\n}\n\n/**\n * `sources products` — the catalog as one Source has it: every product, its\n * kind (Feature or Integration), and whether it is enabled for the Source.\n * `enable|disable <product>` switch one through the levers `/admin` uses\n * (`attachProductToSource` / `detachProductFromSource` for an Integration,\n * the Feature lever for a Feature). A Source admin switches the\n * integrations their Source built (`owned`); anything else is a super-admin\n * grant, which an `ekanos login` session never carries, so from the terminal\n * that write answers with where to do it.\n */\nasync function runProducts(\n ctx: CliContext,\n args: SourcesArgs,\n rest: readonly string[],\n): Promise<ExitCode> {\n const [verb, rawProduct, ...extra] = rest;\n if (extra.length > 0) {\n throw usageError(\n `Unexpected argument \"${extra[0]}\".`,\n 'Run \"ekanos sources products [enable|disable <product>] [--source <slug>]\".',\n );\n }\n if (verb !== undefined && verb !== 'enable' && verb !== 'disable') {\n throw usageError(\n `Unknown sources products subcommand \"${verb}\".`,\n 'Run \"ekanos sources products\", \"ekanos sources products enable <product>\" or \"ekanos sources products disable <product> --yes\".',\n );\n }\n const product = verb ? productSlug(rawProduct, verb) : null;\n if (verb === 'disable' && !args.yes) {\n throw invalidStateError(\n `Disabling ${product} removes it from the Source: its plans, widget settings, Source credentials and workspaces go with it.`,\n `Re-run with --yes: ekanos sources products disable ${product} --yes`,\n );\n }\n\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const resolved = await resolveSourceTarget(env, requireSession(env), {\n source: args.source,\n dir: args.dir,\n });\n const client = new ProductsClient(env, resolved.session);\n\n if (!verb || !product) {\n const list = await client.call((token) =>\n listSourceProducts(env.host, token, resolved.source),\n );\n const legacyHost = hostPredatesFeatures(list.products);\n const byKind = (kind: 'feature' | 'experience' | 'integration') =>\n list.products\n .filter((entry) => productGroup(entry, legacyHost) === kind)\n .map((entry): [string, string] => [\n entry.slug,\n `${entry.enabled ? '✓ enabled' : `✗ not enabled (${NOT_ENABLED_BECAUSE[entry.lever]})`} · ${entry.name}${entry.owned ? ' · built by this Source' : ''}${entry.registered ? '' : ' · no package on this host'}`,\n ]);\n return ctx.succeed(\n { host: env.host, ...list },\n [\n ctx.ui.result({\n title: `Features on ${list.source.slug}`,\n rows: byKind('feature'),\n }),\n ...(byKind('experience').length > 0\n ? [\n ctx.ui.result({\n title: `Experiences on ${list.source.slug}`,\n rows: byKind('experience'),\n }),\n ]\n : []),\n ctx.ui.result({\n title: `Integrations on ${list.source.slug}`,\n rows: byKind('integration'),\n notes: [\n list.canEnable\n ? '\"ekanos sources products enable|disable <product>\" switches one.'\n : list.canEnableOwned\n ? '\"ekanos sources products enable|disable <product>\" switches one built by this Source; any other is a super-admin grant, made in the browser at /admin/sources → the Source → Products.'\n : 'Enabling one is a super-admin grant, made in the browser at /admin/sources → the Source → Products.',\n '\"ekanos teams connect <team> <product>\" connects an enabled integration for a team.',\n ],\n }),\n ].join('\\n'),\n );\n }\n\n const enabled = verb === 'enable';\n const result = await client.call((token) =>\n setSourceProduct(env.host, token, {\n source: resolved.source,\n product,\n enabled,\n }),\n );\n return ctx.succeed(\n { host: env.host, ...result },\n ctx.ui.result({\n title: result.changed\n ? `${enabled ? 'Enabled' : 'Disabled'} ${result.product.name} for ${result.source.slug}`\n : `${result.product.name} was already ${enabled ? 'enabled' : 'off'} for ${result.source.slug}`,\n rows: [\n ['Kind', result.product.kind],\n [\n 'Switched by',\n result.product.lever === 'flag'\n ? 'its Flag'\n : result.product.lever === 'plan'\n ? 'its plan'\n : 'the entitlement',\n ],\n ],\n notes:\n enabled && result.product.kind === 'integration'\n ? [\n `Next: \"ekanos teams connect <team> ${result.product.slug}\" connects it for a team.`,\n ]\n : [],\n }),\n );\n}\n\n/**\n * `sources scopes` — the Source's product scopes, for its Source admin: each\n * scope's products and how many teams hold it. Once a Source has a scope,\n * each team sees in the app only its scopes' products. `add|remove <scope>\n * <product>` changes one scope (by name or id) through what\n * `/admin/sources/[id]/product-scopes` uses; a product can only be added if\n * the Source has it. Taking one out hides it from every team on the scope\n * that no other of its scopes shows it to, so that needs `--yes`.\n */\nasync function runScopes(\n ctx: CliContext,\n args: SourcesArgs,\n rest: readonly string[],\n): Promise<ExitCode> {\n const [verb, rawScope, rawProduct, ...extra] = rest;\n const usage =\n 'Run \"ekanos sources scopes\", \"ekanos sources scopes add <scope> <product>\" or \"ekanos sources scopes remove <scope> <product> --yes\".';\n if (verb !== undefined && verb !== 'add' && verb !== 'remove') {\n throw usageError(`Unknown sources scopes subcommand \"${verb}\".`, usage);\n }\n if (extra.length > 0) {\n throw usageError(`Unexpected argument \"${extra[0]}\".`, usage);\n }\n const scope = rawScope?.trim();\n if (verb && !scope) {\n throw usageError(\n `sources scopes ${verb} needs a scope and a product.`,\n usage,\n );\n }\n const product = verb ? scopeProductSlug(rawProduct, verb) : null;\n if (verb === 'remove' && !args.yes) {\n throw invalidStateError(\n `Taking ${product} out of ${scope} hides it, in the app, from every team on ${scope} that no other of its scopes shows it to.`,\n `Re-run with --yes: ekanos sources scopes remove ${quoteArg(scope!)} ${product} --yes`,\n );\n }\n\n ctx.warn(\n scopeDeprecationNotice(\n verb ? `audiences set ${scope} --products …` : 'audiences list',\n ),\n );\n\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const resolved = await resolveSourceTarget(env, requireSession(env), {\n source: args.source,\n dir: args.dir,\n });\n const client = new ProductsClient(env, resolved.session);\n\n if (!verb || !product || !scope) {\n const list = await client.call((token) =>\n listProductScopes(env.host, token, resolved.source),\n );\n if (list.scopes.length === 0) {\n return ctx.succeed(\n { host: env.host, ...list },\n ctx.ui.result({\n title: `No product scopes on ${list.source.slug}`,\n rows: [['Teams see', 'every product the Source has']],\n notes: [\n 'Scopes are created at /admin/sources → the Source → Product scopes.',\n ],\n }),\n );\n }\n return ctx.succeed(\n { host: env.host, ...list },\n ctx.ui.result({\n title: `Product scopes on ${list.source.slug}`,\n rows: list.scopes.map((entry): [string, string[]] => [\n entry.name,\n [\n `${pluralize(entry.teamCount, 'team')}${entry.isDefault ? ' · given to every new team' : ''}`,\n entry.products.length > 0\n ? entry.products.map((item) => item.slug).join(', ')\n : 'no products',\n ],\n ]),\n notes: [\n 'A team sees in the app only the products of the scopes it holds.',\n '\"ekanos sources scopes add <scope> <product>\" shows a product to every team on a scope; \"ekanos teams scope show|set <team>\" reads or changes which scopes a team holds.',\n ],\n }),\n );\n }\n\n const included = verb === 'add';\n const result = await client.call((token) =>\n setScopeProduct(\n env.host,\n token,\n { source: resolved.source, scope, product },\n included,\n ),\n );\n return ctx.succeed(\n { host: env.host, ...result },\n ctx.ui.result({\n title: result.changed\n ? `${included ? 'Added' : 'Took'} ${result.product.name} ${included ? 'to' : 'out of'} ${result.scope.name}`\n : `${result.product.name} was already ${included ? 'in' : 'not in'} ${result.scope.name}`,\n tone: !included && result.changed ? 'warn' : 'ok',\n rows: [\n ['Teams on it', String(result.scope.teamCount)],\n [\n 'Products',\n result.scope.products.length > 0\n ? result.scope.products.map((item) => item.slug).join(', ')\n : 'none',\n ],\n ],\n notes: [\n included\n ? `Every team on ${result.scope.name} sees ${result.product.slug} in the app now.`\n : `Teams on ${result.scope.name} see ${result.product.slug} only if another of their scopes has it.`,\n ],\n }),\n );\n}\n\nfunction scopeProductSlug(value: string | undefined, verb: string): string {\n const slug = value?.trim().toLowerCase();\n if (slug && /^[a-z0-9][a-z0-9-]*$/.test(slug)) return slug;\n throw usageError(\n value\n ? `\"${value}\" is not a product slug.`\n : `sources scopes ${verb} needs a product.`,\n '\"ekanos sources products\" lists them, e.g. \"ekanos sources scopes add Bronze linear\".',\n );\n}\n\nfunction quoteArg(value: string): string {\n return /^[A-Za-z0-9._-]+$/.test(value) ? value : `\"${value}\"`;\n}\n\nfunction productSlug(value: string | undefined, verb: string): string {\n const slug = value?.trim().toLowerCase();\n if (slug && /^[a-z0-9][a-z0-9-]*$/.test(slug)) return slug;\n throw usageError(\n value\n ? `\"${value}\" is not a product slug.`\n : `sources products ${verb} needs a product.`,\n '\"ekanos sources products\" lists them, e.g. \"ekanos sources products enable agents\".',\n );\n}\n\nclass ProductsClient {\n constructor(\n private readonly env: AuthEnvironment,\n private session: StoredSession,\n ) {}\n\n async call<T>(\n send: (accessToken: string) => Promise<SourceProductsApiResult<T>>,\n ): Promise<T> {\n let result = await send(this.session.accessToken);\n if (result.status === 'unauthorized') {\n this.session = await refreshStoredSession(this.env, this.session);\n result = await send(this.session.accessToken);\n }\n if (result.status === 'ok') return result.data;\n throw authRequiredError(\n `The session for ${this.env.host} could not authorize the sources call.`,\n loginHint(this.env),\n );\n }\n}\n"]}
1
+ {"version":3,"file":"sources.js","sourceRoot":"","sources":["../../src/commands/sources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAEL,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE7E,OAAO,EAAE,oBAAoB,EAAE,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AW,EAAE,CAAC;IACzC,IAAI,IAAI,IAAI,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3D,MAAM,UAAU,CACd,KAAK;QACH,CAAC,CAAC,IAAI,KAAK,0BAA0B;QACrC,CAAC,CAAC,oBAAoB,IAAI,mBAAmB,EAC/C,qFAAqF,CACtF,CAAC;AACJ,CAAC;AAED,MAAM,cAAc;IAClB,YACmB,GAAoB,EAC7B,OAAsB;mBADb,GAAG;uBACZ,OAAO;IACd,CAAC;IAEJ,KAAK,CAAC,IAAI,CACR,IAAkE;QAElE,IAAI,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAClD,IAAI,MAAM,CAAC,MAAM,KAAK,cAAc,EAAE,CAAC;YACrC,IAAI,CAAC,OAAO,GAAG,MAAM,oBAAoB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAClE,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI;YAAE,OAAO,MAAM,CAAC,IAAI,CAAC;QAC/C,MAAM,iBAAiB,CACrB,mBAAmB,IAAI,CAAC,GAAG,CAAC,IAAI,wCAAwC,EACxE,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CACpB,CAAC;IACJ,CAAC;CACF","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport type { StoredSession } from '../auth/credential-store';\nimport { loginHint } from '../auth/host-trust';\nimport {\n type AuthEnvironment,\n refreshStoredSession,\n requireSession,\n resolveAuthEnvironment,\n} from '../auth/session';\nimport type { CliContext } from '../context';\nimport { authRequiredError, invalidStateError, usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { hostPredatesFeatures, productGroup } from '../product-kinds';\nimport { EKANOS_CONFIG_FILENAME } from '../project';\nimport { fetchSeatsWithOneRefresh } from '../seats';\nimport {\n type SourceProduct,\n type SourceProductsApiResult,\n listSourceProducts,\n setSourceProduct,\n} from '../source-products-api';\nimport { resolveSourceTarget } from '../source-target';\nimport { type SourceSeat, stillUnauthorizedSourceSeats } from '../sources-api';\nimport { listProductScopes, setScopeProduct } from '../teams-api';\nimport { type Ui, pluralize, shortHost } from '../ui';\nimport { scopeDeprecationNotice } from './scope-notice';\nimport { runSourcePeople, runSourceRoles } from './sources-roles';\n\nexport interface SourcesArgs {\n host?: string;\n /** `products [enable|disable <product>]`, `scopes [add|remove <scope> <product>]`; none lists the sources. */\n positionals?: readonly string[];\n source?: string;\n yes?: boolean;\n /** `roles` and `people`: their flags (`--level`, `--permission`, `--search` …). */\n flags?: Record<string, string | boolean | string[]>;\n /** `roles delete` asks at a terminal; the test seams for it. */\n stdinIsTTY?: boolean;\n ask?: (question: string) => Promise<string>;\n /** Where a project's ekanos.json may sit — its `source` field, if any, is the marker. */\n dir: string;\n env: Record<string, string | undefined>;\n}\n\n/**\n * `sources` — list every source the caller holds a developer or admin seat\n * on, the read half of the publish-target-verification story.\n *\n * The list itself is the mechanism that makes `publish` safe: a partner (or\n * an agent acting for one) can always answer \"which sources can I possibly\n * publish to?\" before running `ekanos use` or passing `--source`.\n */\nexport async function runSources(\n ctx: CliContext,\n args: SourcesArgs,\n): Promise<ExitCode> {\n const [subcommand, ...rest] = args.positionals ?? [];\n if (subcommand !== undefined) {\n if (subcommand === 'scopes') return runScopes(ctx, args, rest);\n if (subcommand === 'roles') return runSourceRoles(ctx, args, rest);\n if (subcommand === 'people') return runSourcePeople(ctx, args, rest);\n if (subcommand !== 'products') {\n throw usageError(\n `Unknown sources subcommand \"${subcommand}\".`,\n 'Run \"ekanos sources\" to list your sources, \"ekanos sources products [enable|disable <product>]\", \"ekanos sources scopes [add|remove <scope> <product>]\", \"ekanos sources roles [list|create|update|delete <role>]\" or \"ekanos sources people\".',\n );\n }\n return runProducts(ctx, args, rest);\n }\n\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const session = requireSession(env);\n\n const result = await fetchSeatsWithOneRefresh(env, session);\n\n if (result.status === 'unauthorized') {\n stillUnauthorizedSourceSeats(env);\n }\n\n const activeSource = readActiveSource(args.dir);\n\n return ctx.succeed(\n { host: env.host, sources: result.sources, activeSource },\n humanSummary(ctx.ui, env.host, result.sources, activeSource),\n );\n}\n\n/**\n * Best-effort, lenient read of ekanos.json's `source` field — mirrors\n * `readProjectHost` in `auth/session.ts`. A missing, unparseable, or\n * sourceless ekanos.json (or no project at all) simply means \"no active\n * source to mark\", never an error: `sources` must answer outside a project\n * too.\n */\nexport function readActiveSource(dir: string): string | null {\n const configPath = path.join(dir, EKANOS_CONFIG_FILENAME);\n\n let raw: string;\n try {\n raw = fs.readFileSync(configPath, 'utf8');\n } catch {\n return null;\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n return null;\n }\n\n const source =\n typeof parsed === 'object' && parsed !== null\n ? (parsed as { source?: unknown }).source\n : undefined;\n\n return typeof source === 'string' && source.trim().length > 0\n ? source.trim()\n : null;\n}\n\n/** Why a product is not enabled, by the lever that would enable it — the words `catalog` uses. */\nconst NOT_ENABLED_BECAUSE: Record<SourceProduct['lever'], string> = {\n flag: 'its Flag is off',\n plan: 'no active plan',\n entitlement: 'not granted',\n};\n\nfunction humanSummary(\n ui: Ui,\n host: string,\n sources: SourceSeat[],\n activeSource: string | null,\n): string {\n if (sources.length === 0) {\n return ui.result({\n // Read by any signed-in account, a team member's too: no word here\n // may imply the host serves more than one customer.\n title: 'No partner seats',\n tone: 'warn',\n rows: [['Host', shortHost(host)]],\n notes: ['This account has no partner seats on this host.'],\n });\n }\n\n const orphaned =\n activeSource && !sources.some((s) => s.slug === activeSource);\n\n return ui.result({\n title: `${pluralize(sources.length, 'source')} on ${shortHost(host)}`,\n rows: sources.map((source): [string, string] => [\n source.slug,\n [\n source.name ?? '(unnamed)',\n source.roles.join(', '),\n ...(source.slug === activeSource ? [ui.accent('this project')] : []),\n ].join(' · '),\n ]),\n notes: orphaned\n ? [\n `This project's ekanos.json points at \"${activeSource}\", which is not in the list above.`,\n ]\n : [],\n });\n}\n\n/**\n * `sources products` — the catalog as one Source has it: every product, its\n * kind (Feature or Integration), and whether it is enabled for the Source.\n * `enable|disable <product>` switch one through the levers `/admin` uses\n * (`attachProductToSource` / `detachProductFromSource` for an Integration,\n * the Feature lever for a Feature). A Source admin switches the\n * integrations their Source built (`owned`); anything else is a super-admin\n * grant, which an `ekanos login` session never carries, so from the terminal\n * that write answers with where to do it.\n */\nasync function runProducts(\n ctx: CliContext,\n args: SourcesArgs,\n rest: readonly string[],\n): Promise<ExitCode> {\n const [verb, rawProduct, ...extra] = rest;\n if (extra.length > 0) {\n throw usageError(\n `Unexpected argument \"${extra[0]}\".`,\n 'Run \"ekanos sources products [enable|disable <product>] [--source <slug>]\".',\n );\n }\n if (verb !== undefined && verb !== 'enable' && verb !== 'disable') {\n throw usageError(\n `Unknown sources products subcommand \"${verb}\".`,\n 'Run \"ekanos sources products\", \"ekanos sources products enable <product>\" or \"ekanos sources products disable <product> --yes\".',\n );\n }\n const product = verb ? productSlug(rawProduct, verb) : null;\n if (verb === 'disable' && !args.yes) {\n throw invalidStateError(\n `Disabling ${product} removes it from the Source: its plans, widget settings, Source credentials and workspaces go with it.`,\n `Re-run with --yes: ekanos sources products disable ${product} --yes`,\n );\n }\n\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const resolved = await resolveSourceTarget(env, requireSession(env), {\n source: args.source,\n dir: args.dir,\n });\n const client = new ProductsClient(env, resolved.session);\n\n if (!verb || !product) {\n const list = await client.call((token) =>\n listSourceProducts(env.host, token, resolved.source),\n );\n const legacyHost = hostPredatesFeatures(list.products);\n const byKind = (kind: 'feature' | 'experience' | 'integration') =>\n list.products\n .filter((entry) => productGroup(entry, legacyHost) === kind)\n .map((entry): [string, string] => [\n entry.slug,\n `${entry.enabled ? '✓ enabled' : `✗ not enabled (${NOT_ENABLED_BECAUSE[entry.lever]})`} · ${entry.name}${entry.owned ? ' · built by this Source' : ''}${entry.registered ? '' : ' · no package on this host'}`,\n ]);\n return ctx.succeed(\n { host: env.host, ...list },\n [\n ctx.ui.result({\n title: `Features on ${list.source.slug}`,\n rows: byKind('feature'),\n }),\n ...(byKind('experience').length > 0\n ? [\n ctx.ui.result({\n title: `Experiences on ${list.source.slug}`,\n rows: byKind('experience'),\n }),\n ]\n : []),\n ctx.ui.result({\n title: `Integrations on ${list.source.slug}`,\n rows: byKind('integration'),\n notes: [\n list.canEnable\n ? '\"ekanos sources products enable|disable <product>\" switches one.'\n : list.canEnableOwned\n ? '\"ekanos sources products enable|disable <product>\" switches one built by this Source; any other is a super-admin grant, made in the browser at /admin/sources → the Source → Products.'\n : 'Enabling one is a super-admin grant, made in the browser at /admin/sources → the Source → Products.',\n '\"ekanos teams connect <team> <product>\" connects an enabled integration for a team.',\n ],\n }),\n ].join('\\n'),\n );\n }\n\n const enabled = verb === 'enable';\n const result = await client.call((token) =>\n setSourceProduct(env.host, token, {\n source: resolved.source,\n product,\n enabled,\n }),\n );\n return ctx.succeed(\n { host: env.host, ...result },\n ctx.ui.result({\n title: result.changed\n ? `${enabled ? 'Enabled' : 'Disabled'} ${result.product.name} for ${result.source.slug}`\n : `${result.product.name} was already ${enabled ? 'enabled' : 'off'} for ${result.source.slug}`,\n rows: [\n ['Kind', result.product.kind],\n [\n 'Switched by',\n result.product.lever === 'flag'\n ? 'its Flag'\n : result.product.lever === 'plan'\n ? 'its plan'\n : 'the entitlement',\n ],\n ],\n notes:\n enabled && result.product.kind === 'integration'\n ? [\n `Next: \"ekanos teams connect <team> ${result.product.slug}\" connects it for a team.`,\n ]\n : [],\n }),\n );\n}\n\n/**\n * `sources scopes` — the Source's product scopes, for its Source admin: each\n * scope's products and how many teams hold it. Once a Source has a scope,\n * each team sees in the app only its scopes' products. `add|remove <scope>\n * <product>` changes one scope (by name or id) through what\n * `/admin/sources/[id]/scopes` uses; a product can only be added if\n * the Source has it. Taking one out hides it from every team on the scope\n * that no other of its scopes shows it to, so that needs `--yes`.\n */\nasync function runScopes(\n ctx: CliContext,\n args: SourcesArgs,\n rest: readonly string[],\n): Promise<ExitCode> {\n const [verb, rawScope, rawProduct, ...extra] = rest;\n const usage =\n 'Run \"ekanos sources scopes\", \"ekanos sources scopes add <scope> <product>\" or \"ekanos sources scopes remove <scope> <product> --yes\".';\n if (verb !== undefined && verb !== 'add' && verb !== 'remove') {\n throw usageError(`Unknown sources scopes subcommand \"${verb}\".`, usage);\n }\n if (extra.length > 0) {\n throw usageError(`Unexpected argument \"${extra[0]}\".`, usage);\n }\n const scope = rawScope?.trim();\n if (verb && !scope) {\n throw usageError(\n `sources scopes ${verb} needs a scope and a product.`,\n usage,\n );\n }\n const product = verb ? scopeProductSlug(rawProduct, verb) : null;\n if (verb === 'remove' && !args.yes) {\n throw invalidStateError(\n `Taking ${product} out of ${scope} hides it, in the app, from every team on ${scope} that no other of its scopes shows it to.`,\n `Re-run with --yes: ekanos sources scopes remove ${quoteArg(scope!)} ${product} --yes`,\n );\n }\n\n ctx.warn(\n scopeDeprecationNotice(\n verb ? `audiences set ${scope} --products …` : 'audiences list',\n ),\n );\n\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const resolved = await resolveSourceTarget(env, requireSession(env), {\n source: args.source,\n dir: args.dir,\n });\n const client = new ProductsClient(env, resolved.session);\n\n if (!verb || !product || !scope) {\n const list = await client.call((token) =>\n listProductScopes(env.host, token, resolved.source),\n );\n if (list.scopes.length === 0) {\n return ctx.succeed(\n { host: env.host, ...list },\n ctx.ui.result({\n title: `No product scopes on ${list.source.slug}`,\n rows: [['Teams see', 'every product the Source has']],\n notes: [\n 'Scopes are created at /admin/sources → the Source → Product scopes.',\n ],\n }),\n );\n }\n return ctx.succeed(\n { host: env.host, ...list },\n ctx.ui.result({\n title: `Product scopes on ${list.source.slug}`,\n rows: list.scopes.map((entry): [string, string[]] => [\n entry.name,\n [\n `${pluralize(entry.teamCount, 'team')}${entry.isDefault ? ' · given to every new team' : ''}`,\n entry.products.length > 0\n ? entry.products.map((item) => item.slug).join(', ')\n : 'no products',\n ],\n ]),\n notes: [\n 'A team sees in the app only the products of the scopes it holds.',\n '\"ekanos sources scopes add <scope> <product>\" shows a product to every team on a scope; \"ekanos teams scope show|set <team>\" reads or changes which scopes a team holds.',\n ],\n }),\n );\n }\n\n const included = verb === 'add';\n const result = await client.call((token) =>\n setScopeProduct(\n env.host,\n token,\n { source: resolved.source, scope, product },\n included,\n ),\n );\n return ctx.succeed(\n { host: env.host, ...result },\n ctx.ui.result({\n title: result.changed\n ? `${included ? 'Added' : 'Took'} ${result.product.name} ${included ? 'to' : 'out of'} ${result.scope.name}`\n : `${result.product.name} was already ${included ? 'in' : 'not in'} ${result.scope.name}`,\n tone: !included && result.changed ? 'warn' : 'ok',\n rows: [\n ['Teams on it', String(result.scope.teamCount)],\n [\n 'Products',\n result.scope.products.length > 0\n ? result.scope.products.map((item) => item.slug).join(', ')\n : 'none',\n ],\n ],\n notes: [\n included\n ? `Every team on ${result.scope.name} sees ${result.product.slug} in the app now.`\n : `Teams on ${result.scope.name} see ${result.product.slug} only if another of their scopes has it.`,\n ],\n }),\n );\n}\n\nfunction scopeProductSlug(value: string | undefined, verb: string): string {\n const slug = value?.trim().toLowerCase();\n if (slug && /^[a-z0-9][a-z0-9-]*$/.test(slug)) return slug;\n throw usageError(\n value\n ? `\"${value}\" is not a product slug.`\n : `sources scopes ${verb} needs a product.`,\n '\"ekanos sources products\" lists them, e.g. \"ekanos sources scopes add Bronze linear\".',\n );\n}\n\nfunction quoteArg(value: string): string {\n return /^[A-Za-z0-9._-]+$/.test(value) ? value : `\"${value}\"`;\n}\n\nfunction productSlug(value: string | undefined, verb: string): string {\n const slug = value?.trim().toLowerCase();\n if (slug && /^[a-z0-9][a-z0-9-]*$/.test(slug)) return slug;\n throw usageError(\n value\n ? `\"${value}\" is not a product slug.`\n : `sources products ${verb} needs a product.`,\n '\"ekanos sources products\" lists them, e.g. \"ekanos sources products enable agents\".',\n );\n}\n\nclass ProductsClient {\n constructor(\n private readonly env: AuthEnvironment,\n private session: StoredSession,\n ) {}\n\n async call<T>(\n send: (accessToken: string) => Promise<SourceProductsApiResult<T>>,\n ): Promise<T> {\n let result = await send(this.session.accessToken);\n if (result.status === 'unauthorized') {\n this.session = await refreshStoredSession(this.env, this.session);\n result = await send(this.session.accessToken);\n }\n if (result.status === 'ok') return result.data;\n throw authRequiredError(\n `The session for ${this.env.host} could not authorize the sources call.`,\n loginHint(this.env),\n );\n }\n}\n"]}
@@ -3,10 +3,19 @@ import type { ExitCode } from '../exit-codes.js';
3
3
  import { type TeamsArgs } from './teams.js';
4
4
  /**
5
5
  * `teams audience <team> [<audience>] [--member <email> [--inherit]]` — the
6
- * audience a team starts its members on, and a member's own override of it
7
- * (a Source admin's only; audited). Without an audience it reads. Moving
6
+ * team's audience (its business type), which every member is on; their
7
+ * groups narrow it (`teams groups`). Without an audience it reads. Moving
8
8
  * people to an audience that shows fewer products hides the difference from
9
9
  * them in the app, so that needs `--yes`. `teams scope` is the deprecated
10
10
  * form of this.
11
+ *
12
+ * `--member <email>` reads one person's. Setting it (`<audience>` or
13
+ * `--inherit`) is deprecated: a host on plan 258 refuses a per-person
14
+ * audience (`AUDIENCE_SET_ON_TEAM`), and an older host still takes it.
11
15
  */
12
16
  export declare function runTeamAudience(ctx: CliContext, args: TeamsArgs, rest: readonly string[]): Promise<ExitCode>;
17
+ /**
18
+ * The one line a per-person audience write prints (to stderr, so JSON on
19
+ * stdout is unchanged) before it is sent.
20
+ */
21
+ export declare function memberAudienceDeprecationNotice(team: string): string;
@@ -3,14 +3,18 @@ import { invalidStateError, usageError } from '../errors.js';
3
3
  import { resolveSourceTarget } from '../source-target.js';
4
4
  import { listAudiences, setMemberAudience, setTeamAudience, showMemberAudience, showTeamAudience, } from '../teams-api.js';
5
5
  import { TeamsClient } from './teams.js';
6
- const USAGE = 'Run "ekanos teams audience <team>" to read a team’s audience, "ekanos teams audience <team> <audience> [--yes]" to set it, or add --member <email> (with <audience>, or --inherit to clear it) for one person’s own.';
6
+ const USAGE = 'Run "ekanos teams audience <team>" to read a team’s audience (its business type), "ekanos teams audience <team> <audience> [--yes]" to set it, or add --member <email> to read one person’s.';
7
7
  /**
8
8
  * `teams audience <team> [<audience>] [--member <email> [--inherit]]` — the
9
- * audience a team starts its members on, and a member's own override of it
10
- * (a Source admin's only; audited). Without an audience it reads. Moving
9
+ * team's audience (its business type), which every member is on; their
10
+ * groups narrow it (`teams groups`). Without an audience it reads. Moving
11
11
  * people to an audience that shows fewer products hides the difference from
12
12
  * them in the app, so that needs `--yes`. `teams scope` is the deprecated
13
13
  * form of this.
14
+ *
15
+ * `--member <email>` reads one person's. Setting it (`<audience>` or
16
+ * `--inherit`) is deprecated: a host on plan 258 refuses a per-person
17
+ * audience (`AUDIENCE_SET_ON_TEAM`), and an older host still takes it.
14
18
  */
15
19
  export async function runTeamAudience(ctx, args, rest) {
16
20
  var _a, _b;
@@ -50,6 +54,10 @@ export async function runTeamAudience(ctx, args, rest) {
50
54
  if (!audience && !inherit) {
51
55
  return ctx.succeed(Object.assign({ host: env.host }, current), describeMember(ctx, current));
52
56
  }
57
+ if (inherit && !current.isOverride) {
58
+ return ctx.succeed(Object.assign(Object.assign({ host: env.host }, current), { before: current.audience }), describeMember(ctx, current, current.audience));
59
+ }
60
+ ctx.warn(memberAudienceDeprecationNotice(team));
53
61
  const next = inherit
54
62
  ? (await client.call((token) => showTeamAudience(env.host, token, target))).audience.id
55
63
  : audience;
@@ -72,7 +80,7 @@ export async function runTeamAudience(ctx, args, rest) {
72
80
  source,
73
81
  from: current.audience,
74
82
  to: audience,
75
- who: `members of ${team} on the team default`,
83
+ who: `members of ${team}`,
76
84
  yes: args.yes,
77
85
  retry: `ekanos teams audience ${team} ${quote(audience)} --source ${source} --yes`,
78
86
  });
@@ -109,7 +117,7 @@ function findAudience(audiences, ref) {
109
117
  function describeTeam(ctx, result, before) {
110
118
  var _a;
111
119
  return ctx.ui.result({
112
- title: `${result.team.slug} starts its members on ${result.audience.name}`,
120
+ title: `${result.team.slug} is on ${result.audience.name}`,
113
121
  rows: [
114
122
  ['Audience', result.audience.name],
115
123
  ...(before !== undefined
@@ -117,7 +125,7 @@ function describeTeam(ctx, result, before) {
117
125
  : []),
118
126
  ],
119
127
  notes: [
120
- 'A member’s own audience overrides it: "ekanos teams audience <team> <audience> --member <email>".',
128
+ `Every member is on it; their groups narrow it: "ekanos teams groups list ${result.team.slug}".`,
121
129
  '"ekanos audiences show <audience>" lists what it shows.',
122
130
  ],
123
131
  });
@@ -130,7 +138,7 @@ function describeMember(ctx, result, before) {
130
138
  ['Audience', result.audience.name],
131
139
  [
132
140
  'From',
133
- result.isOverride ? 'their own' : `the ${result.team.slug} default`,
141
+ result.isOverride ? 'their own' : `the ${result.team.slug} audience`,
134
142
  ],
135
143
  ...(before !== undefined
136
144
  ? [['Before', (_a = before === null || before === void 0 ? void 0 : before.name) !== null && _a !== void 0 ? _a : 'none']]
@@ -138,6 +146,13 @@ function describeMember(ctx, result, before) {
138
146
  ],
139
147
  });
140
148
  }
149
+ /**
150
+ * The one line a per-person audience write prints (to stderr, so JSON on
151
+ * stdout is unchanged) before it is sent.
152
+ */
153
+ export function memberAudienceDeprecationNotice(team) {
154
+ return `Deprecated: a person’s access is set by the team’s audience and their groups. Hosts on the audiences model refuse this (AUDIENCE_SET_ON_TEAM); set the team’s with "ekanos teams audience ${team} <audience>", or add them to a group with "ekanos teams groups members add ${team} <group> <email>".`;
155
+ }
141
156
  function quote(name) {
142
157
  return /^[A-Za-z0-9._-]+$/.test(name) ? name : `"${name}"`;
143
158
  }