@ekanos/cli 0.25.0 → 0.26.1

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.
Files changed (56) hide show
  1. package/README.md +4 -0
  2. package/dist/catalog-api.d.ts +8 -1
  3. package/dist/catalog-api.js +26 -1
  4. package/dist/catalog-api.js.map +1 -1
  5. package/dist/commands/add.js +2 -1
  6. package/dist/commands/add.js.map +1 -1
  7. package/dist/commands/apps.js +6 -4
  8. package/dist/commands/apps.js.map +1 -1
  9. package/dist/commands/dev.d.ts +5 -0
  10. package/dist/commands/dev.js +25 -9
  11. package/dist/commands/dev.js.map +1 -1
  12. package/dist/commands/routes.js +7 -1
  13. package/dist/commands/routes.js.map +1 -1
  14. package/dist/commands/sources.js +11 -8
  15. package/dist/commands/sources.js.map +1 -1
  16. package/dist/commands/sync.js +3 -2
  17. package/dist/commands/sync.js.map +1 -1
  18. package/dist/commands/teams-events.js +9 -1
  19. package/dist/commands/teams-events.js.map +1 -1
  20. package/dist/commands/teams-lifecycle.js +9 -1
  21. package/dist/commands/teams-lifecycle.js.map +1 -1
  22. package/dist/commands/teams-onboard.js +9 -1
  23. package/dist/commands/teams-onboard.js.map +1 -1
  24. package/dist/commands/teams-overview.d.ts +1 -1
  25. package/dist/commands/teams-overview.js +41 -14
  26. package/dist/commands/teams-overview.js.map +1 -1
  27. package/dist/commands/teams.js +9 -1
  28. package/dist/commands/teams.js.map +1 -1
  29. package/dist/compatibility.d.ts +7 -1
  30. package/dist/compatibility.js +7 -1
  31. package/dist/compatibility.js.map +1 -1
  32. package/dist/contracts-api.d.ts +32 -0
  33. package/dist/contracts-api.js +66 -0
  34. package/dist/contracts-api.js.map +1 -0
  35. package/dist/experience/host-contract-source.d.ts +35 -0
  36. package/dist/experience/host-contract-source.js +121 -0
  37. package/dist/experience/host-contract-source.js.map +1 -0
  38. package/dist/experience/publish.js +7 -11
  39. package/dist/experience/publish.js.map +1 -1
  40. package/dist/harness-scaffold.js +5 -0
  41. package/dist/harness-scaffold.js.map +1 -1
  42. package/dist/host-snapshots.d.ts +66 -0
  43. package/dist/host-snapshots.js +273 -0
  44. package/dist/host-snapshots.js.map +1 -0
  45. package/dist/product-slug.d.ts +8 -0
  46. package/dist/product-slug.js +13 -0
  47. package/dist/product-slug.js.map +1 -0
  48. package/package.json +2 -2
  49. package/templates/experience/package.json.tmpl +4 -4
  50. package/templates/harness/app/catalog/[slug]/page.tsx.tmpl +1 -0
  51. package/templates/harness/app/catalog/layout.tsx.tmpl +1 -0
  52. package/templates/harness/app/catalog/page.tsx.tmpl +1 -0
  53. package/templates/harness/app/experience/publishes/page.tsx.tmpl +1 -0
  54. package/templates/harness/app/integrations/[slug]/publishes/page.tsx.tmpl +1 -0
  55. package/templates/package.json.tmpl +4 -4
  56. package/templates/skills/build-integration/references/widget-design.md +24 -0
@@ -1 +1 @@
1
- {"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAEL,cAAc,EACd,eAAe,GAChB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EACL,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,MAAM,CAAC,MAAM,WAAW,GAAsB;IAC5C,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE;QACL,sFAAsF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AC,MAAM,GAAG,CAAC;YACd,CAAC,CAAC,UAAU,OAAO,CAAC,YAAY,CAAC,MAAM,eAAe,OAAO,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,eAAe,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YACpI,CAAC,CAAC,OAAO;gBACP,CAAC,CAAC,yCAAyC;gBAC3C,CAAC,CAAC,YAAY;oBACZ,CAAC,CAAC,0FAA0F;oBAC5F,CAAC,CAAC,iEAAiE,CAC1E,CAAC;IACJ,CAAC;CACF,CAAC;AAEF;;;;GAIG;AACH,SAAS,cAAc,CAAC,GAAqB;IAC3C,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,IAAI,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import { shortOperation } from '@ekanos/integration-schema';\n\nimport { harnessContractSources } from '../dev-experience';\nimport { validationError } from '../errors';\nimport {\n type ResolvedContract,\n defaultSources,\n resolveContract,\n} from '../experience/contract-sources';\nimport { pinIntegration } from '../experience/pin-integration';\nimport { DEPRECATED_USES, renamesNotice } from '../experience/pins';\nimport {\n readExperienceProject,\n readLockfile,\n writeIntegrations,\n} from '../experience/project';\nimport { loadPins, regenerateIntegrations } from '../experience/regenerate';\nimport { failOnErrors } from '../experience/report';\nimport type { ExperienceCommand } from './index-experience';\n\nexport const syncCommand: ExperienceCommand = {\n name: 'sync',\n usage: [\n \" sync Re-resolve every integration's contract, accept a new digest within the\",\n ' pinned line, and regenerate the lock + types (--check: report only)',\n ],\n specs: {\n dir: {\n type: 'string',\n description: 'Project directory (default: the current one)',\n },\n check: {\n type: 'boolean',\n description:\n 'Report drift without writing anything; exit 3 when there is some',\n },\n 'from-dir': {\n type: 'string',\n description: 'Directory of contract files to resolve from',\n },\n 'contracts-dir': {\n type: 'string',\n description:\n 'Contracts directory the harness resolves from (same as \"ekanos dev --contracts-dir\"; default: EKANOS_CONTRACTS_DIR)',\n },\n 'from-path': {\n type: 'string',\n description: 'An integration project directory to resolve from',\n },\n },\n async run(ctx, args) {\n const project = readExperienceProject(args.dir);\n const checkOnly = args.flags.check === true;\n const fromDir = args.flags['from-dir'] as string | undefined;\n const fromPath = args.flags['from-path'] as string | undefined;\n const contractsDir = args.flags['contracts-dir'] as string | undefined;\n const explicit = Boolean(\n fromDir ?? fromPath ?? contractsDir ?? args.env.EKANOS_CONTRACTS_DIR,\n );\n // The harness's own registry chain (session catalog, published-package\n // cache, contracts directory, then the committed snapshot) is what\n // `ekanos dev` resolves with, so it is what decides drift here too.\n const sources = defaultSources(\n project,\n { fromDir, fromPath, env: args.env },\n await harnessContractSources(project.dir, args.env, {\n ...((contractsDir ?? fromDir)\n ? { contractsDir: (contractsDir ?? fromDir) as string }\n : {}),\n onUnavailable: (reason) =>\n ctx.warn(\n `Could not ask the project's @ekanos/harness for contracts (${reason}); resolving from the committed snapshots only.`,\n ),\n }),\n );\n\n if (project.deprecatedUses) {\n ctx.warn(DEPRECATED_USES);\n const notice = renamesNotice(project.renames);\n if (notice) ctx.warn(notice);\n }\n\n const lock = readLockfile(project);\n const resolved = new Map<string, ResolvedContract>();\n const drift: string[] = [];\n const consulted = new Set<ResolvedContract['kind'] | 'harness'>();\n for (const use of project.integrations) {\n const hit = await resolveContract(sources, use.name, use.version);\n resolved.set(use.name, hit);\n consulted.add(isSnapshotOnly(hit) ? 'snapshot' : 'harness');\n const locked = lock.integrations[use.name];\n if (!locked || locked.digest !== hit.contract.digest) {\n drift.push(\n `${use.name}: ${locked ? `${locked.contractVersion} -> ${hit.contract.contractVersion}` : `new pin ${hit.contract.contractVersion}`}`,\n );\n }\n }\n\n const snapshotOnly = !explicit && !consulted.has('harness');\n const snapshotNotice =\n 'Only the committed snapshots were consulted (no contracts directory and nothing newer from the harness registry), so a running \"ekanos dev\" that resolves elsewhere can still see a drifted digest. Pass --contracts-dir <dir> or set EKANOS_CONTRACTS_DIR, as you do for \"ekanos dev\".';\n\n if (checkOnly) {\n if (drift.length > 0) {\n throw validationError(\n `${drift.length} integration${drift.length === 1 ? '' : 's'} drifted: ${drift.join('; ')}.`,\n 'Run \"ekanos sync\" to accept the new contracts.',\n );\n }\n\n if (snapshotOnly) ctx.warn(snapshotNotice);\n\n return ctx.succeed(\n { drift: [], changed: false, snapshotOnly },\n snapshotOnly\n ? 'All integrations match their committed snapshots (no other contract source was consulted).'\n : 'All integrations match their pinned contracts.',\n );\n }\n\n // Judge the incoming contracts before writing any of it: a new contract\n // that drops a declared operation must not silently replace the old pin.\n const candidate = new Map(\n [...resolved].map(([name, hit]) => [name, hit.contract]),\n );\n const incoming = project.integrations.flatMap((use) => {\n const contract = candidate.get(use.name);\n if (!contract) return [];\n const have = new Set(\n contract.operations.map((op) => shortOperation(op.id)),\n );\n\n return use.operations\n .filter((id) => !have.has(shortOperation(id)))\n .map((id) => ({\n check: 'checks/integration-pins',\n severity: 'error' as const,\n message: `integration \"${use.name}\": ${use.name}@${use.version} (contract ${contract.contractVersion}) no longer provides ${shortOperation(id)}.`,\n hint: 'Remove the operation from \"integrations\", or keep the older pinned contract.',\n file: 'ekanos.json',\n }));\n });\n const failed = failOnErrors(ctx, 'sync', incoming, { drift }, project.dir);\n if (failed !== null) return failed;\n\n let changed = false;\n if (project.deprecatedUses) {\n changed = writeIntegrations(project, project.integrations) || changed;\n }\n for (const use of project.integrations) {\n const hit = resolved.get(use.name);\n if (!hit) continue;\n const result = pinIntegration(project, use, hit.contract);\n changed = changed || result.snapshotChanged || result.lockChanged;\n }\n const { pinned } = loadPins(project);\n const typesChanged = regenerateIntegrations(project, pinned);\n changed = changed || typesChanged;\n\n if (snapshotOnly && drift.length === 0) ctx.warn(snapshotNotice);\n\n return ctx.succeed(\n {\n drift,\n changed,\n snapshotOnly,\n explicitSource: explicit,\n migratedUses: project.deprecatedUses,\n renames: project.renames,\n integrations: project.integrations.map((u) => ({\n integration: u.name,\n contractVersion: resolved.get(u.name)?.contract.contractVersion,\n digest: resolved.get(u.name)?.contract.digest,\n origin: resolved.get(u.name)?.origin,\n })),\n },\n drift.length > 0\n ? `Synced ${project.integrations.length} integration${project.integrations.length === 1 ? '' : 's'}; accepted: ${drift.join('; ')}.`\n : changed\n ? 'Synced; lock or types were regenerated.'\n : snapshotOnly\n ? 'Nothing to sync against the committed snapshots; no other contract source was consulted.'\n : 'Nothing to sync: every integration matches its pinned contract.',\n );\n },\n};\n\n/**\n * The harness's registry source falls back to the committed snapshot when it\n * finds nothing newer, and says so in its origin (\"snapshot <dir>\"). A hit that\n * is only that fallback proves nothing about the registry.\n */\nfunction isSnapshotOnly(hit: ResolvedContract): boolean {\n return hit.kind === 'snapshot' || hit.origin.startsWith('snapshot ');\n}\n"]}
1
+ {"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAEL,cAAc,EACd,eAAe,GAChB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EACL,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,MAAM,CAAC,MAAM,WAAW,GAAsB;IAC5C,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE;QACL,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CAAC,MAAM;gBAC7C,MAAM,EAAE,MAAA,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,0CAAE,MAAM;aACrC,CAAC,GAAA,CAAC;SACJ,EACD,KAAK,CAAC,MAAM,GAAG,CAAC;YACd,CAAC,CAAC,UAAU,OAAO,CAAC,YAAY,CAAC,MAAM,eAAe,OAAO,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,eAAe,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YACpI,CAAC,CAAC,OAAO;gBACP,CAAC,CAAC,yCAAyC;gBAC3C,CAAC,CAAC,YAAY;oBACZ,CAAC,CAAC,0FAA0F;oBAC5F,CAAC,CAAC,iEAAiE,CAC1E,CAAC;IACJ,CAAC;CACF,CAAC;AAEF;;;;GAIG;AACH,SAAS,cAAc,CAAC,GAAqB;IAC3C,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,IAAI,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import { shortOperation } from '@ekanos/integration-schema';\n\nimport { harnessContractSources } from '../dev-experience';\nimport { validationError } from '../errors';\nimport {\n type ResolvedContract,\n defaultSources,\n resolveContract,\n} from '../experience/contract-sources';\nimport {\n hostContractSource,\n withHostBeforeSnapshots,\n} from '../experience/host-contract-source';\nimport { pinIntegration } from '../experience/pin-integration';\nimport { DEPRECATED_USES, renamesNotice } from '../experience/pins';\nimport {\n readExperienceProject,\n readLockfile,\n writeIntegrations,\n} from '../experience/project';\nimport { loadPins, regenerateIntegrations } from '../experience/regenerate';\nimport { failOnErrors } from '../experience/report';\nimport type { ExperienceCommand } from './index-experience';\n\nexport const syncCommand: ExperienceCommand = {\n name: 'sync',\n usage: [\n \" sync Re-resolve every integration's contract, accept a new digest within the\",\n ' pinned line, and regenerate the lock + types (--check: report only)',\n ],\n specs: {\n dir: {\n type: 'string',\n description: 'Project directory (default: the current one)',\n },\n check: {\n type: 'boolean',\n description:\n 'Report drift without writing anything; exit 3 when there is some',\n },\n 'from-dir': {\n type: 'string',\n description: 'Directory of contract files to resolve from',\n },\n 'contracts-dir': {\n type: 'string',\n description:\n 'Contracts directory the harness resolves from (same as \"ekanos dev --contracts-dir\"; default: EKANOS_CONTRACTS_DIR)',\n },\n 'from-path': {\n type: 'string',\n description: 'An integration project directory to resolve from',\n },\n },\n async run(ctx, args) {\n const project = readExperienceProject(args.dir);\n const checkOnly = args.flags.check === true;\n const fromDir = args.flags['from-dir'] as string | undefined;\n const fromPath = args.flags['from-path'] as string | undefined;\n const contractsDir = args.flags['contracts-dir'] as string | undefined;\n const explicit = Boolean(\n fromDir ?? fromPath ?? contractsDir ?? args.env.EKANOS_CONTRACTS_DIR,\n );\n // The harness's own registry chain (session catalog, published-package\n // cache, contracts directory, then the committed snapshot) is what\n // `ekanos dev` resolves with, so it is what decides drift here too.\n const sources = defaultSources(\n project,\n { fromDir, fromPath, env: args.env },\n withHostBeforeSnapshots(\n await harnessContractSources(project.dir, args.env, {\n ...((contractsDir ?? fromDir)\n ? { contractsDir: (contractsDir ?? fromDir) as string }\n : {}),\n onUnavailable: (reason) =>\n ctx.warn(\n `Could not ask the project's @ekanos/harness for contracts (${reason}); resolving from the host and the committed snapshots.`,\n ),\n }),\n hostContractSource({ ctx, env: args.env, projectDir: project.dir }),\n ),\n );\n\n if (project.deprecatedUses) {\n ctx.warn(DEPRECATED_USES);\n const notice = renamesNotice(project.renames);\n if (notice) ctx.warn(notice);\n }\n\n const lock = readLockfile(project);\n const resolved = new Map<string, ResolvedContract>();\n const drift: string[] = [];\n const consulted = new Set<ResolvedContract['kind'] | 'harness'>();\n for (const use of project.integrations) {\n const hit = await resolveContract(sources, use.name, use.version);\n resolved.set(use.name, hit);\n consulted.add(isSnapshotOnly(hit) ? 'snapshot' : 'harness');\n const locked = lock.integrations[use.name];\n if (!locked || locked.digest !== hit.contract.digest) {\n drift.push(\n `${use.name}: ${locked ? `${locked.contractVersion} -> ${hit.contract.contractVersion}` : `new pin ${hit.contract.contractVersion}`}`,\n );\n }\n }\n\n const snapshotOnly = !explicit && !consulted.has('harness');\n const snapshotNotice =\n 'Only the committed snapshots were consulted (no contracts directory and nothing newer from the harness registry), so a running \"ekanos dev\" that resolves elsewhere can still see a drifted digest. Pass --contracts-dir <dir> or set EKANOS_CONTRACTS_DIR, as you do for \"ekanos dev\".';\n\n if (checkOnly) {\n if (drift.length > 0) {\n throw validationError(\n `${drift.length} integration${drift.length === 1 ? '' : 's'} drifted: ${drift.join('; ')}.`,\n 'Run \"ekanos sync\" to accept the new contracts.',\n );\n }\n\n if (snapshotOnly) ctx.warn(snapshotNotice);\n\n return ctx.succeed(\n { drift: [], changed: false, snapshotOnly },\n snapshotOnly\n ? 'All integrations match their committed snapshots (no other contract source was consulted).'\n : 'All integrations match their pinned contracts.',\n );\n }\n\n // Judge the incoming contracts before writing any of it: a new contract\n // that drops a declared operation must not silently replace the old pin.\n const candidate = new Map(\n [...resolved].map(([name, hit]) => [name, hit.contract]),\n );\n const incoming = project.integrations.flatMap((use) => {\n const contract = candidate.get(use.name);\n if (!contract) return [];\n const have = new Set(\n contract.operations.map((op) => shortOperation(op.id)),\n );\n\n return use.operations\n .filter((id) => !have.has(shortOperation(id)))\n .map((id) => ({\n check: 'checks/integration-pins',\n severity: 'error' as const,\n message: `integration \"${use.name}\": ${use.name}@${use.version} (contract ${contract.contractVersion}) no longer provides ${shortOperation(id)}.`,\n hint: 'Remove the operation from \"integrations\", or keep the older pinned contract.',\n file: 'ekanos.json',\n }));\n });\n const failed = failOnErrors(ctx, 'sync', incoming, { drift }, project.dir);\n if (failed !== null) return failed;\n\n let changed = false;\n if (project.deprecatedUses) {\n changed = writeIntegrations(project, project.integrations) || changed;\n }\n for (const use of project.integrations) {\n const hit = resolved.get(use.name);\n if (!hit) continue;\n const result = pinIntegration(project, use, hit.contract);\n changed = changed || result.snapshotChanged || result.lockChanged;\n }\n const { pinned } = loadPins(project);\n const typesChanged = regenerateIntegrations(project, pinned);\n changed = changed || typesChanged;\n\n if (snapshotOnly && drift.length === 0) ctx.warn(snapshotNotice);\n\n return ctx.succeed(\n {\n drift,\n changed,\n snapshotOnly,\n explicitSource: explicit,\n migratedUses: project.deprecatedUses,\n renames: project.renames,\n integrations: project.integrations.map((u) => ({\n integration: u.name,\n contractVersion: resolved.get(u.name)?.contract.contractVersion,\n digest: resolved.get(u.name)?.contract.digest,\n origin: resolved.get(u.name)?.origin,\n })),\n },\n drift.length > 0\n ? `Synced ${project.integrations.length} integration${project.integrations.length === 1 ? '' : 's'}; accepted: ${drift.join('; ')}.`\n : changed\n ? 'Synced; lock or types were regenerated.'\n : snapshotOnly\n ? 'Nothing to sync against the committed snapshots; no other contract source was consulted.'\n : 'Nothing to sync: every integration matches its pinned contract.',\n );\n },\n};\n\n/**\n * The harness's registry source falls back to the committed snapshot when it\n * finds nothing newer, and says so in its origin (\"snapshot <dir>\"). A hit that\n * is only that fallback proves nothing about the registry.\n */\nfunction isSnapshotOnly(hit: ResolvedContract): boolean {\n return hit.kind === 'snapshot' || hit.origin.startsWith('snapshot ');\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import { requireSession, resolveAuthEnvironment } from '../auth/session.js';
2
2
  import { usageError } from '../errors.js';
3
+ import { PRODUCT_SLUG_SHAPE, isProductSlug } from '../product-slug.js';
3
4
  import { resolveSourceTarget } from '../source-target.js';
4
5
  import { listTeamEvents } from '../teams-api.js';
5
6
  import { TeamsClient } from './teams.js';
@@ -107,8 +108,15 @@ function runLine(run) {
107
108
  }
108
109
  function slugOperand(value, what) {
109
110
  const slug = value === null || value === void 0 ? void 0 : value.trim().toLowerCase();
110
- if (slug && /^[a-z0-9][a-z0-9-]*$/.test(slug))
111
+ if (slug &&
112
+ (what === 'product'
113
+ ? isProductSlug(slug)
114
+ : /^[a-z0-9][a-z0-9-]*$/.test(slug))) {
111
115
  return slug;
116
+ }
117
+ if (what === 'product' && value) {
118
+ throw usageError(`"${value}" is not a product slug.`, `${PRODUCT_SLUG_SHAPE} "ekanos catalog" lists them.`);
119
+ }
112
120
  throw usageError(value ? `"${value}" is not a ${what} slug.` : `Name the ${what}.`, USAGE);
113
121
  }
114
122
  /** `--since 30m|24h|7d` (before now) or a date the host can read, as ISO. */
@@ -1 +1 @@
1
- {"version":3,"file":"teams-events.js","sourceRoot":"","sources":["../../src/commands/teams-events.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAkB,MAAM,SAAS,CAAC;AAEtD,MAAM,KAAK,GACT,4GAA4G,CAAC;AAC/G,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,GAAe,EACf,IAAe,EACf,QAA2B,EAC3B,GAAG,GAAiB,IAAI,CAAC,GAAG;;IAE5B,MAAM,IAAI,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC9C,MAAM,iBAAiB,GACrB,QAAQ,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAC9E,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,UAAU,CAAC,wBAAwB,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACnE,CAAC;IACD,MAAM,WAAW,GACf,QAAO,MAAA,IAAI,CAAC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;IACxC,MAAM,KAAK,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IACjE,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,SAAS,EAAE,CAAC;QAChE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,UAAU,CACd,4CAA4C,SAAS,GAAG,EACxD,KAAK,CACN,CAAC;AACJ,CAAC","sourcesContent":["import type {\n AgentRunSummary,\n TeamIntegrationEvent,\n} from '@ekanos/integration-schema';\n\nimport { requireSession, resolveAuthEnvironment } from '../auth/session';\nimport type { CliContext } from '../context';\nimport { usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { resolveSourceTarget } from '../source-target';\nimport { listTeamEvents } from '../teams-api';\nimport type { ResultRow } from '../ui';\nimport { TeamsClient, type TeamsArgs } from './teams';\n\nconst USAGE =\n 'Run \"ekanos teams events <team> [<product>] [--product <slug>] [--since 24h|7d|<date>] [--limit <1-100>]\".';\nconst MAX_LIMIT = 100;\n\n/**\n * `teams events <team> [<product>]` — the integration events recorded for a\n * team, newest first, each with what it started: \"an event arrived, and\n * here's why it did or didn't start a run\". The team-level counterpart of\n * `routes unrouted`. Read-only; never the event's payload.\n */\nexport async function runTeamEvents(\n ctx: CliContext,\n args: TeamsArgs,\n operands: readonly string[],\n now: () => number = Date.now,\n): Promise<ExitCode> {\n const team = slugOperand(operands[0], 'team');\n const positionalProduct =\n operands[1] === undefined ? undefined : slugOperand(operands[1], 'product');\n if (operands[2] !== undefined) {\n throw usageError(`Unexpected argument \"${operands[2]}\".`, USAGE);\n }\n const flagProduct =\n typeof args.flags?.product === 'string'\n ? slugOperand(args.flags.product, 'product')\n : undefined;\n if (positionalProduct && flagProduct && positionalProduct !== flagProduct) {\n throw usageError(\n `Two products named: \"${positionalProduct}\" and --product \"${flagProduct}\".`,\n USAGE,\n );\n }\n const product = positionalProduct ?? flagProduct;\n const since = parseSince(args.flags?.since, now());\n const limit = parseLimit(args.flags?.limit);\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 list = await client.call((token) =>\n listTeamEvents(\n env.host,\n token,\n { source: resolved.source, team },\n { product, since, limit },\n ),\n );\n\n const scope = [\n product ? `for ${product}` : '',\n since ? `since ${since.slice(0, 16).replace('T', ' ')}` : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n if (list.events.length === 0) {\n return ctx.succeed(\n { host: env.host, ...list },\n ctx.ui.result({\n title: `No events recorded for ${list.team.slug}${scope ? ` ${scope}` : ''}`,\n tone: 'warn',\n notes: [\n 'An event lands here once an integration emits one for this team.',\n `Nothing yet? Check the team's setup (\"ekanos teams show ${list.team.slug} <product>\") and, for a Source connection, \"ekanos routes unrouted\".`,\n ],\n }),\n );\n }\n\n const quiet = list.events.filter(\n (event) => event.status === 'done' && event.runs.length === 0,\n ).length;\n return ctx.succeed(\n { host: env.host, ...list },\n ctx.ui.result({\n title: `${list.events.length} event${list.events.length === 1 ? '' : 's'} on ${list.team.slug}${scope ? ` ${scope}` : ''}`,\n tone: list.events.some(\n (event) => event.status === 'failed' || event.status === 'dropped',\n )\n ? 'warn'\n : 'ok',\n rows: list.events.map((event) => eventRow(event, list.team.slug)),\n notes: [\n ...(quiet > 0\n ? [\n `List an agent's triggers with \"ekanos teams triggers list ${list.team.slug} <key>\"; add one with \"ekanos teams triggers add ${list.team.slug} <key> event <event-id>\".`,\n ]\n : []),\n `\"ekanos runs show <run-id> --team ${list.team.slug}\" opens a run.`,\n ],\n }),\n );\n}\n\nfunction eventRow(event: TeamIntegrationEvent, team: string): ResultRow {\n return [\n event.receivedAt.slice(0, 19).replace('T', ' '),\n [`${event.eventId} · ${event.status}`, ...outcome(event, team)],\n ];\n}\n\n/** Why the event did or didn't start a run, in a line or two. */\nfunction outcome(event: TeamIntegrationEvent, team: string): string[] {\n switch (event.status) {\n case 'pending':\n return [' waiting to be dispatched'];\n case 'processing':\n return [' being dispatched now'];\n case 'dropped':\n return [\n ' dropped: no integration declares this event any more, its payload did not validate, or it was an agent’s own activity',\n ];\n case 'failed':\n return [\n ` failed after ${event.attempts} attempt${event.attempts === 1 ? '' : 's'}: ${event.lastError ?? 'no error recorded'} (retried while attempts remain)`,\n ...event.runs.map(runLine),\n ];\n case 'done':\n if (event.runs.length > 0) return event.runs.map(runLine);\n return event.subscribedTriggers === 0\n ? [\n ` no run: no enabled trigger on ${team} subscribes to ${event.eventId}`,\n ]\n : [\n ` no run: ${event.subscribedTriggers} enabled trigger${event.subscribedTriggers === 1 ? '' : 's'} subscribe${event.subscribedTriggers === 1 ? 's' : ''} to it, but none matched its filter or its agent could not start (paused, or Agents off)`,\n ];\n }\n}\n\nfunction runLine(run: AgentRunSummary): string {\n return ` → run ${run.id} · ${run.agent.templateKey ?? run.agent.slug} · ${run.status}`;\n}\n\nfunction slugOperand(\n value: string | undefined,\n what: 'team' | 'product',\n): 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 ? `\"${value}\" is not a ${what} slug.` : `Name the ${what}.`,\n USAGE,\n );\n}\n\n/** `--since 30m|24h|7d` (before now) or a date the host can read, as ISO. */\nexport function parseSince(\n raw: string | boolean | string[] | undefined,\n nowMs: number,\n): string | undefined {\n if (raw === undefined) return undefined;\n const value = typeof raw === 'string' ? raw.trim() : '';\n const relative = /^(\\d+)([mhd])$/.exec(value);\n if (relative) {\n const unitMs = { m: 60_000, h: 3_600_000, d: 86_400_000 }[\n relative[2] as 'm' | 'h' | 'd'\n ];\n return new Date(nowMs - Number(relative[1]) * unitMs).toISOString();\n }\n const parsed = Date.parse(value);\n if (value && !Number.isNaN(parsed)) return new Date(parsed).toISOString();\n throw usageError(\n `--since \"${value}\" is not a duration or a date.`,\n 'Use a duration before now (30m, 24h, 7d) or a date (2026-10-19, 2026-10-19T09:00Z).',\n );\n}\n\nfunction parseLimit(\n raw: string | boolean | string[] | undefined,\n): number | undefined {\n if (raw === undefined) return undefined;\n const limit = typeof raw === 'string' ? Number(raw) : Number.NaN;\n if (Number.isInteger(limit) && limit >= 1 && limit <= MAX_LIMIT) {\n return limit;\n }\n throw usageError(\n `--limit must be a whole number from 1 to ${MAX_LIMIT}.`,\n USAGE,\n );\n}\n"]}
1
+ {"version":3,"file":"teams-events.js","sourceRoot":"","sources":["../../src/commands/teams-events.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAkB,MAAM,SAAS,CAAC;AAEtD,MAAM,KAAK,GACT,4GAA4G,CAAC;AAC/G,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,GAAe,EACf,IAAe,EACf,QAA2B,EAC3B,GAAG,GAAiB,IAAI,CAAC,GAAG;;IAE5B,MAAM,IAAI,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC9C,MAAM,iBAAiB,GACrB,QAAQ,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAC9E,IAAI,QAAQ,CAAC,CAAC,CAAC,K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,CAAC,GAAG,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;IACtE,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1E,MAAM,UAAU,CACd,YAAY,KAAK,gCAAgC,EACjD,qFAAqF,CACtF,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CACjB,GAA4C;IAE5C,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxC,MAAM,KAAK,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IACjE,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,SAAS,EAAE,CAAC;QAChE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,UAAU,CACd,4CAA4C,SAAS,GAAG,EACxD,KAAK,CACN,CAAC;AACJ,CAAC","sourcesContent":["import type {\n AgentRunSummary,\n TeamIntegrationEvent,\n} from '@ekanos/integration-schema';\n\nimport { requireSession, resolveAuthEnvironment } from '../auth/session';\nimport type { CliContext } from '../context';\nimport { usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { PRODUCT_SLUG_SHAPE, isProductSlug } from '../product-slug';\nimport { resolveSourceTarget } from '../source-target';\nimport { listTeamEvents } from '../teams-api';\nimport type { ResultRow } from '../ui';\nimport { TeamsClient, type TeamsArgs } from './teams';\n\nconst USAGE =\n 'Run \"ekanos teams events <team> [<product>] [--product <slug>] [--since 24h|7d|<date>] [--limit <1-100>]\".';\nconst MAX_LIMIT = 100;\n\n/**\n * `teams events <team> [<product>]` — the integration events recorded for a\n * team, newest first, each with what it started: \"an event arrived, and\n * here's why it did or didn't start a run\". The team-level counterpart of\n * `routes unrouted`. Read-only; never the event's payload.\n */\nexport async function runTeamEvents(\n ctx: CliContext,\n args: TeamsArgs,\n operands: readonly string[],\n now: () => number = Date.now,\n): Promise<ExitCode> {\n const team = slugOperand(operands[0], 'team');\n const positionalProduct =\n operands[1] === undefined ? undefined : slugOperand(operands[1], 'product');\n if (operands[2] !== undefined) {\n throw usageError(`Unexpected argument \"${operands[2]}\".`, USAGE);\n }\n const flagProduct =\n typeof args.flags?.product === 'string'\n ? slugOperand(args.flags.product, 'product')\n : undefined;\n if (positionalProduct && flagProduct && positionalProduct !== flagProduct) {\n throw usageError(\n `Two products named: \"${positionalProduct}\" and --product \"${flagProduct}\".`,\n USAGE,\n );\n }\n const product = positionalProduct ?? flagProduct;\n const since = parseSince(args.flags?.since, now());\n const limit = parseLimit(args.flags?.limit);\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 list = await client.call((token) =>\n listTeamEvents(\n env.host,\n token,\n { source: resolved.source, team },\n { product, since, limit },\n ),\n );\n\n const scope = [\n product ? `for ${product}` : '',\n since ? `since ${since.slice(0, 16).replace('T', ' ')}` : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n if (list.events.length === 0) {\n return ctx.succeed(\n { host: env.host, ...list },\n ctx.ui.result({\n title: `No events recorded for ${list.team.slug}${scope ? ` ${scope}` : ''}`,\n tone: 'warn',\n notes: [\n 'An event lands here once an integration emits one for this team.',\n `Nothing yet? Check the team's setup (\"ekanos teams show ${list.team.slug} <product>\") and, for a Source connection, \"ekanos routes unrouted\".`,\n ],\n }),\n );\n }\n\n const quiet = list.events.filter(\n (event) => event.status === 'done' && event.runs.length === 0,\n ).length;\n return ctx.succeed(\n { host: env.host, ...list },\n ctx.ui.result({\n title: `${list.events.length} event${list.events.length === 1 ? '' : 's'} on ${list.team.slug}${scope ? ` ${scope}` : ''}`,\n tone: list.events.some(\n (event) => event.status === 'failed' || event.status === 'dropped',\n )\n ? 'warn'\n : 'ok',\n rows: list.events.map((event) => eventRow(event, list.team.slug)),\n notes: [\n ...(quiet > 0\n ? [\n `List an agent's triggers with \"ekanos teams triggers list ${list.team.slug} <key>\"; add one with \"ekanos teams triggers add ${list.team.slug} <key> event <event-id>\".`,\n ]\n : []),\n `\"ekanos runs show <run-id> --team ${list.team.slug}\" opens a run.`,\n ],\n }),\n );\n}\n\nfunction eventRow(event: TeamIntegrationEvent, team: string): ResultRow {\n return [\n event.receivedAt.slice(0, 19).replace('T', ' '),\n [`${event.eventId} · ${event.status}`, ...outcome(event, team)],\n ];\n}\n\n/** Why the event did or didn't start a run, in a line or two. */\nfunction outcome(event: TeamIntegrationEvent, team: string): string[] {\n switch (event.status) {\n case 'pending':\n return [' waiting to be dispatched'];\n case 'processing':\n return [' being dispatched now'];\n case 'dropped':\n return [\n ' dropped: no integration declares this event any more, its payload did not validate, or it was an agent’s own activity',\n ];\n case 'failed':\n return [\n ` failed after ${event.attempts} attempt${event.attempts === 1 ? '' : 's'}: ${event.lastError ?? 'no error recorded'} (retried while attempts remain)`,\n ...event.runs.map(runLine),\n ];\n case 'done':\n if (event.runs.length > 0) return event.runs.map(runLine);\n return event.subscribedTriggers === 0\n ? [\n ` no run: no enabled trigger on ${team} subscribes to ${event.eventId}`,\n ]\n : [\n ` no run: ${event.subscribedTriggers} enabled trigger${event.subscribedTriggers === 1 ? '' : 's'} subscribe${event.subscribedTriggers === 1 ? 's' : ''} to it, but none matched its filter or its agent could not start (paused, or Agents off)`,\n ];\n }\n}\n\nfunction runLine(run: AgentRunSummary): string {\n return ` → run ${run.id} · ${run.agent.templateKey ?? run.agent.slug} · ${run.status}`;\n}\n\nfunction slugOperand(\n value: string | undefined,\n what: 'team' | 'product',\n): string {\n const slug = value?.trim().toLowerCase();\n if (\n slug &&\n (what === 'product'\n ? isProductSlug(slug)\n : /^[a-z0-9][a-z0-9-]*$/.test(slug))\n ) {\n return slug;\n }\n if (what === 'product' && value) {\n throw usageError(\n `\"${value}\" is not a product slug.`,\n `${PRODUCT_SLUG_SHAPE} \"ekanos catalog\" lists them.`,\n );\n }\n throw usageError(\n value ? `\"${value}\" is not a ${what} slug.` : `Name the ${what}.`,\n USAGE,\n );\n}\n\n/** `--since 30m|24h|7d` (before now) or a date the host can read, as ISO. */\nexport function parseSince(\n raw: string | boolean | string[] | undefined,\n nowMs: number,\n): string | undefined {\n if (raw === undefined) return undefined;\n const value = typeof raw === 'string' ? raw.trim() : '';\n const relative = /^(\\d+)([mhd])$/.exec(value);\n if (relative) {\n const unitMs = { m: 60_000, h: 3_600_000, d: 86_400_000 }[\n relative[2] as 'm' | 'h' | 'd'\n ];\n return new Date(nowMs - Number(relative[1]) * unitMs).toISOString();\n }\n const parsed = Date.parse(value);\n if (value && !Number.isNaN(parsed)) return new Date(parsed).toISOString();\n throw usageError(\n `--since \"${value}\" is not a duration or a date.`,\n 'Use a duration before now (30m, 24h, 7d) or a date (2026-10-19, 2026-10-19T09:00Z).',\n );\n}\n\nfunction parseLimit(\n raw: string | boolean | string[] | undefined,\n): number | undefined {\n if (raw === undefined) return undefined;\n const limit = typeof raw === 'string' ? Number(raw) : Number.NaN;\n if (Number.isInteger(limit) && limit >= 1 && limit <= MAX_LIMIT) {\n return limit;\n }\n throw usageError(\n `--limit must be a whole number from 1 to ${MAX_LIMIT}.`,\n USAGE,\n );\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { requireSession, resolveAuthEnvironment } from '../auth/session.js';
2
2
  import { invalidStateError, usageError } from '../errors.js';
3
3
  import { cli } from '../invocation.js';
4
+ import { PRODUCT_SLUG_SHAPE, isProductSlug } from '../product-slug.js';
4
5
  import { resolveSourceTarget } from '../source-target.js';
5
6
  import { createTeamGroup, deleteTeamGroup, leaveTeam, listTeamGroups, listTeamHealth, listTeamWorkspaces, ownTeamHealth, resendTeamInvitation, runTeamHealthCheck, setTeamDefaultWorkspace, setTeamGroupMember, updateTeamGroup, } from '../team-lifecycle-api.js';
6
7
  import { promptYesNo } from './publish.js';
@@ -448,8 +449,15 @@ function noExtra(extra) {
448
449
  }
449
450
  function slugOf(value, what) {
450
451
  const slug = value === null || value === void 0 ? void 0 : value.trim().toLowerCase();
451
- if (slug && /^[a-z0-9][a-z0-9-]*$/.test(slug))
452
+ if (slug &&
453
+ (what === 'product'
454
+ ? isProductSlug(slug)
455
+ : /^[a-z0-9][a-z0-9-]*$/.test(slug))) {
452
456
  return slug;
457
+ }
458
+ if (what === 'product' && value) {
459
+ throw usageError(`"${value}" is not a product slug.`, `${PRODUCT_SLUG_SHAPE} "ekanos catalog" lists them.`);
460
+ }
453
461
  throw usageError(value ? `"${value}" is not a ${what} slug.` : `Name the ${what}.`, what === 'team'
454
462
  ? '"ekanos teams list" lists the teams, e.g. "ekanos teams health bank-a".'
455
463
  : '"ekanos catalog" lists the products, e.g. "ekanos teams health bank-a zendesk".');
@@ -1 +1 @@
1
- {"version":3,"file":"teams-lifecycle.js","sourceRoot":"","sources":["../../src/commands/teams-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAGL,eAAe,EACf,eAAe,EACf,SAAS,EACT,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAkB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AED,SAAS,KAAK,CAAC,KAAa;IAC1B,OAAO,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC;AAChE,CAAC;AAED,SAAS,OAAO,CAAC,KAAwB;IACvC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,UAAU,CACd,wBAAwB,KAAK,CAAC,CAAC,CAAC,IAAI,EACpC,4BAA4B,CAC7B,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,KAAyB,EAAE,IAAwB;IACjE,MAAM,IAAI,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,GAAG,WAAW,EAAE,CAAC;IACzC,IAAI,IAAI,IAAI,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3D,MAAM,UAAU,CACd,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,IAAI,QAAQ,CAAC,CAAC,CAAC,YAAY,IAAI,GAAG,EACjE,IAAI,KAAK,MAAM;QACb,CAAC,CAAC,yEAAyE;QAC3E,CAAC,CAAC,iFAAiF,CACtF,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,KAAyB;IACxC,MAAM,KAAK,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,GAAG,WAAW,EAAE,CAAC;IAC1C,IAAI,KAAK,IAAI,4BAA4B,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACpE,MAAM,UAAU,CACd,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,4BAA4B,CAAC,CAAC,CAAC,2BAA2B,EAC3E,2DAA2D,CAC5D,CAAC;AACJ,CAAC","sourcesContent":["import { requireSession, resolveAuthEnvironment } from '../auth/session';\nimport type { CliContext } from '../context';\nimport { invalidStateError, usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { cli } from '../invocation';\nimport { resolveSourceTarget } from '../source-target';\nimport {\n type TeamGroup,\n type TeamHealthRow,\n createTeamGroup,\n deleteTeamGroup,\n leaveTeam,\n listTeamGroups,\n listTeamHealth,\n listTeamWorkspaces,\n ownTeamHealth,\n resendTeamInvitation,\n runTeamHealthCheck,\n setTeamDefaultWorkspace,\n setTeamGroupMember,\n updateTeamGroup,\n} from '../team-lifecycle-api';\nimport type { ResultRow } from '../ui';\nimport { promptYesNo } from './publish';\nimport { TeamsClient, type TeamsArgs, canPrompt } from './teams';\n\n/**\n * A team's lifecycle from the terminal, for the Source admin:\n * `teams members resend`, `teams leave`, `teams groups …`, `teams health`\n * and `teams workspace …`. Each is parsed before a session is touched\n * (`parseLifecycle`), and a change that takes something away is confirmed\n * first — asked at a terminal, `--yes` in a script or agent run — so a usage\n * error or an unconfirmed change never costs a request. The host does the\n * rest through the services the app's own screens use, with an Admin Audit\n * row per write.\n *\n * Ownership transfer and team deletion are not here: in the app they are\n * the primary owner's alone, confirmed by a code emailed to them.\n */\n\nexport const LIFECYCLE_SUBCOMMANDS = [\n 'leave',\n 'groups',\n 'health',\n 'workspace',\n] as const;\ntype LifecycleSubcommand = (typeof LIFECYCLE_SUBCOMMANDS)[number];\n\n/** `teams members <verb>` verbs handled here rather than in onboarding. */\nexport const LIFECYCLE_MEMBER_VERBS = ['resend'] as const;\n\n/** What an unconfirmed change says, and the question a terminal is asked. */\nexport interface Confirmation {\n what: string;\n command: string;\n question: string;\n}\n\nexport type LifecyclePlan = (\n | { kind: 'resend'; team: string; email: string }\n | { kind: 'leave'; team: string }\n | { kind: 'groups-list'; team: string }\n | {\n kind: 'groups-create';\n team: string;\n name: string;\n description?: string;\n products?: string[];\n }\n | {\n kind: 'groups-update';\n team: string;\n group: string;\n name?: string;\n description?: string | null;\n products?: string[];\n }\n | { kind: 'groups-delete'; team: string; group: string }\n | {\n kind: 'groups-member';\n team: string;\n group: string;\n email: string;\n member: boolean;\n }\n | {\n kind: 'health';\n team: string;\n product?: string;\n run: boolean;\n /** `--mine`: the caller's own personal connection to <product>. */\n mine?: boolean;\n }\n | { kind: 'workspace-list'; team: string }\n | { kind: 'workspace-default'; team: string; workspace: string }\n) & { confirm?: Confirmation };\n\nexport function isLifecycleSubcommand(\n value: string | undefined,\n): value is LifecycleSubcommand {\n return (LIFECYCLE_SUBCOMMANDS as readonly string[]).includes(value ?? '');\n}\n\nexport function isLifecycleMemberVerb(value: string | undefined): boolean {\n return (LIFECYCLE_MEMBER_VERBS as readonly string[]).includes(value ?? '');\n}\n\nconst GROUPS_USAGE =\n 'Run one of: ekanos teams groups list <team>, ekanos teams groups create <team> <name> [--description <text>] [--products <slug,slug>], ekanos teams groups update <team> <group> [--name <name>] [--description <text>] [--products <slug,slug>|none], ekanos teams groups delete <team> <group> --yes, ekanos teams groups members add|remove <team> <group> <email>.';\nconst WORKSPACE_USAGE =\n 'Run \"ekanos teams workspace list <team>\" or \"ekanos teams workspace default <team> <workspace>\".';\n\n/**\n * `subcommand` is `members` (with `resend` first in `rest`) or one\n * of {@link LIFECYCLE_SUBCOMMANDS}.\n */\nexport function parseLifecycle(\n subcommand: string,\n rest: readonly string[],\n args: Pick<TeamsArgs, 'yes' | 'flags'>,\n): LifecyclePlan {\n const flags = args.flags ?? {};\n\n if (subcommand === 'members') {\n const [, team, email, ...extra] = rest;\n noExtra(extra);\n return {\n kind: 'resend',\n team: slugOf(team, 'team'),\n email: emailOf(email),\n };\n }\n\n if (subcommand === 'leave') {\n const [team, ...extra] = rest;\n noExtra(extra);\n const teamSlug = slugOf(team, 'team');\n return {\n kind: 'leave',\n team: teamSlug,\n ...confirmUnless(args.yes, {\n what: `Leaving ${teamSlug} ends your own membership of it; only an invitation brings you back.`,\n command: `${cli()} teams leave ${teamSlug} --yes`,\n question: `Leave ${teamSlug}? [y/N]`,\n }),\n };\n }\n\n if (subcommand === 'health') {\n const [team, product, ...extra] = rest;\n noExtra(extra);\n const run = flags.run === true;\n const productSlug =\n product === undefined ? undefined : slugOf(product, 'product');\n if (run && !productSlug) {\n throw usageError(\n 'teams health --run checks one integration; name it.',\n 'Run \"ekanos teams health <team> <product> --run\"; \"ekanos teams health <team>\" lists them.',\n );\n }\n const mine = flags.mine === true;\n if (mine && !productSlug) {\n throw usageError(\n 'teams health --mine shows your own connection to one integration; name it.',\n 'Run \"ekanos teams health <team> <product> --mine [--run]\".',\n );\n }\n return {\n kind: 'health',\n team: slugOf(team, 'team'),\n ...(productSlug ? { product: productSlug } : {}),\n run,\n ...(mine ? { mine } : {}),\n };\n }\n\n if (subcommand === 'workspace') {\n const [verb, team, workspace, ...extra] = rest;\n noExtra(extra);\n if (verb === 'list') {\n if (workspace !== undefined) noExtra([workspace]);\n return { kind: 'workspace-list', team: slugOf(team, 'team') };\n }\n if (verb === 'default') {\n const teamSlug = slugOf(team, 'team');\n if (!workspace?.trim()) {\n throw usageError(\n 'Name the workspace.',\n `Run \"${cli()} teams workspace default ${teamSlug} <workspace>\"; \"${cli()} teams workspace list ${teamSlug}\" lists them.`,\n );\n }\n return {\n kind: 'workspace-default',\n team: teamSlug,\n workspace: workspace.trim().toLowerCase(),\n };\n }\n throw usageError(\n verb\n ? `Unknown teams workspace subcommand \"${verb}\".`\n : 'teams workspace needs a subcommand.',\n WORKSPACE_USAGE,\n );\n }\n\n const [verb, ...operands] = rest;\n if (verb === 'list') {\n const [team, ...extra] = operands;\n noExtra(extra);\n return { kind: 'groups-list', team: slugOf(team, 'team') };\n }\n if (verb === 'create') {\n const [team, name, ...extra] = operands;\n noExtra(extra);\n const teamSlug = slugOf(team, 'team');\n if (!name?.trim()) {\n throw usageError(\n 'Name the group.',\n `Run \"${cli()} teams groups create ${teamSlug} \\\\\"Loan officers\\\\\"\".`,\n );\n }\n const description = stringFlag(flags.description);\n const products = productsFlag(flags.products);\n return {\n kind: 'groups-create',\n team: teamSlug,\n name: name.trim(),\n ...(description === undefined ? {} : { description }),\n ...(products === undefined ? {} : { products }),\n };\n }\n if (verb === 'update') {\n const [team, group, ...extra] = operands;\n noExtra(extra);\n const teamSlug = slugOf(team, 'team');\n const groupRef = groupOf(group, teamSlug);\n const name = stringFlag(flags.name);\n const description = stringFlag(flags.description);\n const products = productsFlag(flags.products);\n if (\n name === undefined &&\n description === undefined &&\n products === undefined\n ) {\n throw usageError(\n 'Nothing to change.',\n `Pass --name, --description or --products, e.g. \"${cli()} teams groups update ${teamSlug} ${quote(groupRef)} --products linear,zendesk\".`,\n );\n }\n return {\n kind: 'groups-update',\n team: teamSlug,\n group: groupRef,\n ...(name === undefined ? {} : { name }),\n ...(description === undefined\n ? {}\n : { description: description === '' ? null : description }),\n ...(products === undefined ? {} : { products }),\n };\n }\n if (verb === 'delete') {\n const [team, group, ...extra] = operands;\n noExtra(extra);\n const teamSlug = slugOf(team, 'team');\n const groupRef = groupOf(group, teamSlug);\n return {\n kind: 'groups-delete',\n team: teamSlug,\n group: groupRef,\n ...confirmUnless(args.yes, {\n what: `Deleting the group ${groupRef} of ${teamSlug} takes away what it narrows: its members see what the team's other groups (or the whole team) give them.`,\n command: `${cli()} teams groups delete ${teamSlug} ${quote(groupRef)} --yes`,\n question: `Delete the group ${groupRef} of ${teamSlug}? [y/N]`,\n }),\n };\n }\n if (verb === 'members') {\n const [action, team, group, email, ...extra] = operands;\n noExtra(extra);\n if (action !== 'add' && action !== 'remove') {\n throw usageError(\n action\n ? `Unknown teams groups members subcommand \"${action}\".`\n : 'teams groups members needs add or remove.',\n GROUPS_USAGE,\n );\n }\n const teamSlug = slugOf(team, 'team');\n const groupRef = groupOf(group, teamSlug);\n const address = emailOf(email);\n return {\n kind: 'groups-member',\n team: teamSlug,\n group: groupRef,\n email: address,\n member: action === 'add',\n ...(action === 'remove'\n ? confirmUnless(args.yes, {\n what: `Taking ${address} out of ${groupRef} changes what they see on ${teamSlug}.`,\n command: `${cli()} teams groups members remove ${teamSlug} ${quote(groupRef)} ${address} --yes`,\n question: `Take ${address} out of ${groupRef} on ${teamSlug}? [y/N]`,\n })\n : {}),\n };\n }\n throw usageError(\n verb\n ? `Unknown teams groups subcommand \"${verb}\".`\n : 'teams groups needs a subcommand.',\n GROUPS_USAGE,\n );\n}\n\nexport async function runLifecycle(\n ctx: CliContext,\n args: TeamsArgs,\n plan: LifecyclePlan,\n): Promise<ExitCode> {\n if (plan.confirm) await confirmChange(ctx, args, plan.confirm);\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 host = env.host;\n const source = resolved.source;\n const team = { source, team: plan.team };\n\n switch (plan.kind) {\n case 'resend': {\n const done = await client.call((token) =>\n resendTeamInvitation(host, token, { ...team, email: plan.email }),\n );\n return ctx.succeed(\n { host, ...done },\n ctx.ui.result({\n title:\n done.action === 'resent'\n ? `Resent ${done.email}'s invitation to ${done.team.slug}`\n : `Renewed ${done.email}'s expired invitation to ${done.team.slug}`,\n rows: [\n ['Role', done.role],\n ['Expires', done.expiresAt.slice(0, 10)],\n ],\n notes: [\n done.action === 'resent'\n ? 'A fresh invitation email is on its way; the earlier link stops working.'\n : 'The link they already have works again; no new email is sent for a renewal.',\n ],\n }),\n );\n }\n\n case 'leave': {\n const done = await client.call((token) => leaveTeam(host, token, team));\n return ctx.succeed(\n { host, ...done },\n ctx.ui.result({\n title: `You left ${done.team.slug}`,\n rows: [['Your role was', done.role]],\n notes: [\n `As the Source admin you still manage it from here (\"${cli()} teams show ${done.team.slug}\").`,\n ],\n }),\n );\n }\n\n case 'groups-list': {\n const list = await client.call((token) =>\n listTeamGroups(host, token, team),\n );\n return ctx.succeed(\n { host, ...list },\n ctx.ui.result({\n title:\n list.groups.length === 0\n ? `${list.team.slug} has no groups`\n : `Groups of ${list.team.slug}`,\n tone: list.groups.length === 0 ? 'warn' : 'ok',\n rows: list.groups.map(groupRow),\n notes: [\n `A group narrows what its members see to its products. \"${cli()} teams groups create ${list.team.slug} <name> --products <slug,slug>\" adds one.`,\n ],\n }),\n );\n }\n\n case 'groups-create': {\n const done = await client.call((token) =>\n createTeamGroup(host, token, team, {\n name: plan.name,\n ...(plan.description === undefined\n ? {}\n : { description: plan.description }),\n ...(plan.products === undefined ? {} : { products: plan.products }),\n }),\n );\n return ctx.succeed(\n { host, ...done },\n ctx.ui.result({\n title: `Created group ${done.group.name} on ${done.team.slug}`,\n rows: [groupRow(done.group)],\n notes: [\n `Add members with \"${cli()} teams groups members add ${done.team.slug} ${quote(done.group.name)} <email>\".`,\n ],\n }),\n );\n }\n\n case 'groups-update': {\n const done = await client.call((token) =>\n updateTeamGroup(\n host,\n token,\n { ...team, group: plan.group },\n {\n ...(plan.name === undefined ? {} : { name: plan.name }),\n ...(plan.description === undefined\n ? {}\n : { description: plan.description }),\n ...(plan.products === undefined ? {} : { products: plan.products }),\n },\n ),\n );\n return ctx.succeed(\n { host, ...done },\n ctx.ui.result({\n title: `Updated group ${done.group.name} on ${done.team.slug}`,\n rows: [groupRow(done.group)],\n }),\n );\n }\n\n case 'groups-delete': {\n const done = await client.call((token) =>\n deleteTeamGroup(host, token, { ...team, group: plan.group }),\n );\n return ctx.succeed(\n { host, ...done },\n ctx.ui.result({\n title: `Deleted group ${done.group.name} from ${done.team.slug}`,\n tone: 'warn',\n }),\n );\n }\n\n case 'groups-member': {\n const done = await client.call((token) =>\n setTeamGroupMember(\n host,\n token,\n { ...team, group: plan.group, email: plan.email },\n plan.member,\n ),\n );\n return ctx.succeed(\n { host, ...done },\n ctx.ui.result({\n title: !done.changed\n ? `${done.email} was already ${plan.member ? 'in' : 'not in'} ${done.group.name}`\n : plan.member\n ? `Added ${done.email} to ${done.group.name}`\n : `Took ${done.email} out of ${done.group.name}`,\n rows: [groupRow(done.group)],\n }),\n );\n }\n\n case 'health': {\n if (plan.mine && plan.product) {\n const product = plan.product;\n const done = await client.call((token) =>\n ownTeamHealth(host, token, { ...team, product }, plan.run),\n );\n return ctx.succeed(\n { host, ...done, mine: true },\n ctx.ui.result({\n title: `Your ${done.integration.productName} connection: ${done.integration.status}`,\n tone: toneOf(done.integration),\n rows: healthRows(done.integration),\n notes: plan.run\n ? []\n : [\n `\"${cli()} teams health ${done.team.slug} ${product} --mine --run\" checks it now.`,\n ],\n }),\n );\n }\n if (plan.run && plan.product) {\n const product = plan.product;\n const done = await client.call((token) =>\n runTeamHealthCheck(host, token, { ...team, product }),\n );\n return ctx.succeed(\n { host, ...done },\n ctx.ui.result({\n title: `${done.integration.productName} on ${done.team.slug}: ${done.integration.status}`,\n tone: toneOf(done.integration),\n rows: healthRows(done.integration),\n }),\n );\n }\n const list = await client.call((token) =>\n listTeamHealth(host, token, team),\n );\n const rows = plan.product\n ? list.integrations.filter((row) => row.slug === plan.product)\n : list.integrations;\n if (plan.product && rows.length === 0) {\n throw invalidStateError(\n `${list.team.slug} has not connected ${plan.product}, so it has no health to show.`,\n `\"${cli()} teams health ${list.team.slug}\" lists what it has connected.`,\n );\n }\n const data = { host, ...list, integrations: rows };\n if (plan.product) {\n const row = rows[0]!;\n return ctx.succeed(\n data,\n ctx.ui.result({\n title: `${row.productName} on ${list.team.slug}: ${row.status}`,\n tone: toneOf(row),\n rows: healthRows(row),\n notes: [\n `\"${cli()} teams health ${list.team.slug} ${row.slug} --run\" checks it now.`,\n ],\n }),\n );\n }\n return ctx.succeed(\n data,\n ctx.ui.result({\n title:\n rows.length === 0\n ? `${list.team.slug} has no connected integrations`\n : `Integration health on ${list.team.slug}`,\n tone:\n rows.length === 0\n ? 'warn'\n : rows.some((row) => row.status === 'unhealthy')\n ? 'err'\n : rows.some((row) => row.status !== 'healthy')\n ? 'warn'\n : 'ok',\n rows: rows.map((row): ResultRow => [\n row.slug,\n `${row.status}${row.statusReason ? ` · ${row.statusReason}` : ''}${row.lastCheckedAt ? ` · checked ${row.lastCheckedAt.slice(0, 10)}` : ' · never checked'}`,\n ]),\n notes:\n rows.length === 0\n ? []\n : [\n `\"${cli()} teams health ${list.team.slug} <product> --run\" checks one now.`,\n ],\n }),\n );\n }\n\n case 'workspace-list': {\n const list = await client.call((token) =>\n listTeamWorkspaces(host, token, team),\n );\n return ctx.succeed(\n { host, ...list },\n ctx.ui.result({\n title:\n list.workspaces.length === 0\n ? `${list.team.slug} has no workspaces`\n : `Workspaces of ${list.team.slug}`,\n tone: list.workspaces.length === 0 ? 'warn' : 'ok',\n rows: list.workspaces.map((workspace): ResultRow => [\n workspace.slug,\n [\n workspace.label ?? workspace.name,\n ...(workspace.isDefault ? ['default'] : []),\n ...(workspace.visible ? [] : ['hidden by the team']),\n ].join(' · '),\n ]),\n notes: [\n `\"${cli()} teams workspace default ${list.team.slug} <workspace>\" sets the one the team lands on.`,\n ],\n }),\n );\n }\n\n case 'workspace-default': {\n const done = await client.call((token) =>\n setTeamDefaultWorkspace(host, token, team, plan.workspace),\n );\n return ctx.succeed(\n { host, ...done },\n ctx.ui.result({\n title: done.changed\n ? `${done.team.slug} now lands on ${done.workspace.label ?? done.workspace.name}`\n : `${done.workspace.label ?? done.workspace.name} is already ${done.team.slug}'s default`,\n rows: [['Was', done.previous?.slug ?? '—']],\n notes: ['A member who picked their own default keeps theirs.'],\n }),\n );\n }\n }\n}\n\nfunction confirmUnless(\n yes: boolean,\n confirm: Confirmation,\n): { confirm?: Confirmation } {\n return yes ? {} : { confirm };\n}\n\n/**\n * A change that takes something away: asked at a terminal; a script, an\n * agent run or `--json` passes `--yes` instead. Asked before any request.\n */\nexport async function confirmChange(\n ctx: CliContext,\n args: TeamsArgs,\n confirm: Confirmation,\n): Promise<void> {\n if (!canPrompt(ctx, args)) {\n throw invalidStateError(\n confirm.what,\n `Re-run with --yes: ${confirm.command}`,\n );\n }\n const { ask } = args;\n const confirmed = ask\n ? /^y(es)?$/i.test((await ask(confirm.question)).trim())\n : await promptYesNo(confirm.question);\n if (!confirmed) {\n throw invalidStateError(\n `Not confirmed: ${confirm.what}`,\n 'Nothing was changed.',\n );\n }\n}\n\nfunction groupRow(group: TeamGroup): ResultRow {\n return [\n group.kind === 'predefined'\n ? `${group.name} (predefined)`\n : group.kind === 'everyone'\n ? `${group.name} (everyone in no other group)`\n : group.name,\n [\n group.description ?? 'no description',\n group.kind === 'everyone'\n ? 'members: everyone on the team in no other group'\n : `members: ${group.members.length === 0 ? 'none' : group.members.map((member) => member.email ?? member.userId).join(', ')}`,\n `products: ${group.products.length === 0 ? 'none (no narrowing)' : group.products.map((product) => product.slug).join(', ')}`,\n ],\n ];\n}\n\nfunction healthRows(row: TeamHealthRow): ResultRow[] {\n return [\n ['Status', row.status],\n ...(row.statusReason ? [['Why', row.statusReason] as const] : []),\n ['Last checked', row.lastCheckedAt ?? 'never'],\n ['Last success', row.lastSuccessAt ?? '—'],\n ['Last failure', row.lastFailureAt ?? '—'],\n ...(row.lastErrorMessage\n ? [['Last error', row.lastErrorMessage] as const]\n : []),\n ...(row.tokenExpiresAt\n ? [['Token expires', row.tokenExpiresAt] as const]\n : []),\n ];\n}\n\nfunction toneOf(row: TeamHealthRow) {\n return row.status === 'healthy'\n ? ('ok' as const)\n : row.status === 'unhealthy'\n ? ('err' as const)\n : ('warn' as const);\n}\n\nfunction stringFlag(value: unknown): string | undefined {\n return typeof value === 'string' ? value.trim() : undefined;\n}\n\n/** `--products a,b`: the list; `--products none` (or empty): no products. */\nfunction productsFlag(value: unknown): string[] | undefined {\n if (typeof value !== 'string') return undefined;\n const trimmed = value.trim().toLowerCase();\n if (trimmed === '' || trimmed === 'none') return [];\n return [\n ...new Set(\n trimmed\n .split(',')\n .map((slug) => slug.trim())\n .filter(Boolean)\n .map((slug) => slugOf(slug, 'product')),\n ),\n ];\n}\n\nfunction groupOf(value: string | undefined, team: string): string {\n const group = value?.trim();\n if (group) return group;\n throw usageError(\n 'Name the group, by name or id.',\n `\"${cli()} teams groups list ${team}\" lists them.`,\n );\n}\n\nfunction quote(value: string): string {\n return /^[A-Za-z0-9._-]+$/.test(value) ? value : `\"${value}\"`;\n}\n\nfunction noExtra(extra: readonly string[]) {\n if (extra.length > 0) {\n throw usageError(\n `Unexpected argument \"${extra[0]}\".`,\n 'See \"ekanos teams --help\".',\n );\n }\n}\n\nfunction slugOf(value: string | undefined, what: 'team' | 'product'): 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 ? `\"${value}\" is not a ${what} slug.` : `Name the ${what}.`,\n what === 'team'\n ? '\"ekanos teams list\" lists the teams, e.g. \"ekanos teams health bank-a\".'\n : '\"ekanos catalog\" lists the products, e.g. \"ekanos teams health bank-a zendesk\".',\n );\n}\n\nfunction emailOf(value: string | undefined): string {\n const email = value?.trim().toLowerCase();\n if (email && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email)) return email;\n throw usageError(\n value ? `\"${value}\" is not an email address.` : 'Name the person by email.',\n 'e.g. \"ekanos teams members resend bank-a ana@bank-a.com\".',\n );\n}\n"]}
1
+ {"version":3,"file":"teams-lifecycle.js","sourceRoot":"","sources":["../../src/commands/teams-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAGL,eAAe,EACf,eAAe,EACf,SAAS,EACT,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAkB,SAAS,EAAE,MAAM,SAAS,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;IACpE,MAAM,UAAU,CACd,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,4BAA4B,CAAC,CAAC,CAAC,2BAA2B,EAC3E,2DAA2D,CAC5D,CAAC;AACJ,CAAC","sourcesContent":["import { requireSession, resolveAuthEnvironment } from '../auth/session';\nimport type { CliContext } from '../context';\nimport { invalidStateError, usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { cli } from '../invocation';\nimport { PRODUCT_SLUG_SHAPE, isProductSlug } from '../product-slug';\nimport { resolveSourceTarget } from '../source-target';\nimport {\n type TeamGroup,\n type TeamHealthRow,\n createTeamGroup,\n deleteTeamGroup,\n leaveTeam,\n listTeamGroups,\n listTeamHealth,\n listTeamWorkspaces,\n ownTeamHealth,\n resendTeamInvitation,\n runTeamHealthCheck,\n setTeamDefaultWorkspace,\n setTeamGroupMember,\n updateTeamGroup,\n} from '../team-lifecycle-api';\nimport type { ResultRow } from '../ui';\nimport { promptYesNo } from './publish';\nimport { TeamsClient, type TeamsArgs, canPrompt } from './teams';\n\n/**\n * A team's lifecycle from the terminal, for the Source admin:\n * `teams members resend`, `teams leave`, `teams groups …`, `teams health`\n * and `teams workspace …`. Each is parsed before a session is touched\n * (`parseLifecycle`), and a change that takes something away is confirmed\n * first — asked at a terminal, `--yes` in a script or agent run — so a usage\n * error or an unconfirmed change never costs a request. The host does the\n * rest through the services the app's own screens use, with an Admin Audit\n * row per write.\n *\n * Ownership transfer and team deletion are not here: in the app they are\n * the primary owner's alone, confirmed by a code emailed to them.\n */\n\nexport const LIFECYCLE_SUBCOMMANDS = [\n 'leave',\n 'groups',\n 'health',\n 'workspace',\n] as const;\ntype LifecycleSubcommand = (typeof LIFECYCLE_SUBCOMMANDS)[number];\n\n/** `teams members <verb>` verbs handled here rather than in onboarding. */\nexport const LIFECYCLE_MEMBER_VERBS = ['resend'] as const;\n\n/** What an unconfirmed change says, and the question a terminal is asked. */\nexport interface Confirmation {\n what: string;\n command: string;\n question: string;\n}\n\nexport type LifecyclePlan = (\n | { kind: 'resend'; team: string; email: string }\n | { kind: 'leave'; team: string }\n | { kind: 'groups-list'; team: string }\n | {\n kind: 'groups-create';\n team: string;\n name: string;\n description?: string;\n products?: string[];\n }\n | {\n kind: 'groups-update';\n team: string;\n group: string;\n name?: string;\n description?: string | null;\n products?: string[];\n }\n | { kind: 'groups-delete'; team: string; group: string }\n | {\n kind: 'groups-member';\n team: string;\n group: string;\n email: string;\n member: boolean;\n }\n | {\n kind: 'health';\n team: string;\n product?: string;\n run: boolean;\n /** `--mine`: the caller's own personal connection to <product>. */\n mine?: boolean;\n }\n | { kind: 'workspace-list'; team: string }\n | { kind: 'workspace-default'; team: string; workspace: string }\n) & { confirm?: Confirmation };\n\nexport function isLifecycleSubcommand(\n value: string | undefined,\n): value is LifecycleSubcommand {\n return (LIFECYCLE_SUBCOMMANDS as readonly string[]).includes(value ?? '');\n}\n\nexport function isLifecycleMemberVerb(value: string | undefined): boolean {\n return (LIFECYCLE_MEMBER_VERBS as readonly string[]).includes(value ?? '');\n}\n\nconst GROUPS_USAGE =\n 'Run one of: ekanos teams groups list <team>, ekanos teams groups create <team> <name> [--description <text>] [--products <slug,slug>], ekanos teams groups update <team> <group> [--name <name>] [--description <text>] [--products <slug,slug>|none], ekanos teams groups delete <team> <group> --yes, ekanos teams groups members add|remove <team> <group> <email>.';\nconst WORKSPACE_USAGE =\n 'Run \"ekanos teams workspace list <team>\" or \"ekanos teams workspace default <team> <workspace>\".';\n\n/**\n * `subcommand` is `members` (with `resend` first in `rest`) or one\n * of {@link LIFECYCLE_SUBCOMMANDS}.\n */\nexport function parseLifecycle(\n subcommand: string,\n rest: readonly string[],\n args: Pick<TeamsArgs, 'yes' | 'flags'>,\n): LifecyclePlan {\n const flags = args.flags ?? {};\n\n if (subcommand === 'members') {\n const [, team, email, ...extra] = rest;\n noExtra(extra);\n return {\n kind: 'resend',\n team: slugOf(team, 'team'),\n email: emailOf(email),\n };\n }\n\n if (subcommand === 'leave') {\n const [team, ...extra] = rest;\n noExtra(extra);\n const teamSlug = slugOf(team, 'team');\n return {\n kind: 'leave',\n team: teamSlug,\n ...confirmUnless(args.yes, {\n what: `Leaving ${teamSlug} ends your own membership of it; only an invitation brings you back.`,\n command: `${cli()} teams leave ${teamSlug} --yes`,\n question: `Leave ${teamSlug}? [y/N]`,\n }),\n };\n }\n\n if (subcommand === 'health') {\n const [team, product, ...extra] = rest;\n noExtra(extra);\n const run = flags.run === true;\n const productSlug =\n product === undefined ? undefined : slugOf(product, 'product');\n if (run && !productSlug) {\n throw usageError(\n 'teams health --run checks one integration; name it.',\n 'Run \"ekanos teams health <team> <product> --run\"; \"ekanos teams health <team>\" lists them.',\n );\n }\n const mine = flags.mine === true;\n if (mine && !productSlug) {\n throw usageError(\n 'teams health --mine shows your own connection to one integration; name it.',\n 'Run \"ekanos teams health <team> <product> --mine [--run]\".',\n );\n }\n return {\n kind: 'health',\n team: slugOf(team, 'team'),\n ...(productSlug ? { product: productSlug } : {}),\n run,\n ...(mine ? { mine } : {}),\n };\n }\n\n if (subcommand === 'workspace') {\n const [verb, team, workspace, ...extra] = rest;\n noExtra(extra);\n if (verb === 'list') {\n if (workspace !== undefined) noExtra([workspace]);\n return { kind: 'workspace-list', team: slugOf(team, 'team') };\n }\n if (verb === 'default') {\n const teamSlug = slugOf(team, 'team');\n if (!workspace?.trim()) {\n throw usageError(\n 'Name the workspace.',\n `Run \"${cli()} teams workspace default ${teamSlug} <workspace>\"; \"${cli()} teams workspace list ${teamSlug}\" lists them.`,\n );\n }\n return {\n kind: 'workspace-default',\n team: teamSlug,\n workspace: workspace.trim().toLowerCase(),\n };\n }\n throw usageError(\n verb\n ? `Unknown teams workspace subcommand \"${verb}\".`\n : 'teams workspace needs a subcommand.',\n WORKSPACE_USAGE,\n );\n }\n\n const [verb, ...operands] = rest;\n if (verb === 'list') {\n const [team, ...extra] = operands;\n noExtra(extra);\n return { kind: 'groups-list', team: slugOf(team, 'team') };\n }\n if (verb === 'create') {\n const [team, name, ...extra] = operands;\n noExtra(extra);\n const teamSlug = slugOf(team, 'team');\n if (!name?.trim()) {\n throw usageError(\n 'Name the group.',\n `Run \"${cli()} teams groups create ${teamSlug} \\\\\"Loan officers\\\\\"\".`,\n );\n }\n const description = stringFlag(flags.description);\n const products = productsFlag(flags.products);\n return {\n kind: 'groups-create',\n team: teamSlug,\n name: name.trim(),\n ...(description === undefined ? {} : { description }),\n ...(products === undefined ? {} : { products }),\n };\n }\n if (verb === 'update') {\n const [team, group, ...extra] = operands;\n noExtra(extra);\n const teamSlug = slugOf(team, 'team');\n const groupRef = groupOf(group, teamSlug);\n const name = stringFlag(flags.name);\n const description = stringFlag(flags.description);\n const products = productsFlag(flags.products);\n if (\n name === undefined &&\n description === undefined &&\n products === undefined\n ) {\n throw usageError(\n 'Nothing to change.',\n `Pass --name, --description or --products, e.g. \"${cli()} teams groups update ${teamSlug} ${quote(groupRef)} --products linear,zendesk\".`,\n );\n }\n return {\n kind: 'groups-update',\n team: teamSlug,\n group: groupRef,\n ...(name === undefined ? {} : { name }),\n ...(description === undefined\n ? {}\n : { description: description === '' ? null : description }),\n ...(products === undefined ? {} : { products }),\n };\n }\n if (verb === 'delete') {\n const [team, group, ...extra] = operands;\n noExtra(extra);\n const teamSlug = slugOf(team, 'team');\n const groupRef = groupOf(group, teamSlug);\n return {\n kind: 'groups-delete',\n team: teamSlug,\n group: groupRef,\n ...confirmUnless(args.yes, {\n what: `Deleting the group ${groupRef} of ${teamSlug} takes away what it narrows: its members see what the team's other groups (or the whole team) give them.`,\n command: `${cli()} teams groups delete ${teamSlug} ${quote(groupRef)} --yes`,\n question: `Delete the group ${groupRef} of ${teamSlug}? [y/N]`,\n }),\n };\n }\n if (verb === 'members') {\n const [action, team, group, email, ...extra] = operands;\n noExtra(extra);\n if (action !== 'add' && action !== 'remove') {\n throw usageError(\n action\n ? `Unknown teams groups members subcommand \"${action}\".`\n : 'teams groups members needs add or remove.',\n GROUPS_USAGE,\n );\n }\n const teamSlug = slugOf(team, 'team');\n const groupRef = groupOf(group, teamSlug);\n const address = emailOf(email);\n return {\n kind: 'groups-member',\n team: teamSlug,\n group: groupRef,\n email: address,\n member: action === 'add',\n ...(action === 'remove'\n ? confirmUnless(args.yes, {\n what: `Taking ${address} out of ${groupRef} changes what they see on ${teamSlug}.`,\n command: `${cli()} teams groups members remove ${teamSlug} ${quote(groupRef)} ${address} --yes`,\n question: `Take ${address} out of ${groupRef} on ${teamSlug}? [y/N]`,\n })\n : {}),\n };\n }\n throw usageError(\n verb\n ? `Unknown teams groups subcommand \"${verb}\".`\n : 'teams groups needs a subcommand.',\n GROUPS_USAGE,\n );\n}\n\nexport async function runLifecycle(\n ctx: CliContext,\n args: TeamsArgs,\n plan: LifecyclePlan,\n): Promise<ExitCode> {\n if (plan.confirm) await confirmChange(ctx, args, plan.confirm);\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 host = env.host;\n const source = resolved.source;\n const team = { source, team: plan.team };\n\n switch (plan.kind) {\n case 'resend': {\n const done = await client.call((token) =>\n resendTeamInvitation(host, token, { ...team, email: plan.email }),\n );\n return ctx.succeed(\n { host, ...done },\n ctx.ui.result({\n title:\n done.action === 'resent'\n ? `Resent ${done.email}'s invitation to ${done.team.slug}`\n : `Renewed ${done.email}'s expired invitation to ${done.team.slug}`,\n rows: [\n ['Role', done.role],\n ['Expires', done.expiresAt.slice(0, 10)],\n ],\n notes: [\n done.action === 'resent'\n ? 'A fresh invitation email is on its way; the earlier link stops working.'\n : 'The link they already have works again; no new email is sent for a renewal.',\n ],\n }),\n );\n }\n\n case 'leave': {\n const done = await client.call((token) => leaveTeam(host, token, team));\n return ctx.succeed(\n { host, ...done },\n ctx.ui.result({\n title: `You left ${done.team.slug}`,\n rows: [['Your role was', done.role]],\n notes: [\n `As the Source admin you still manage it from here (\"${cli()} teams show ${done.team.slug}\").`,\n ],\n }),\n );\n }\n\n case 'groups-list': {\n const list = await client.call((token) =>\n listTeamGroups(host, token, team),\n );\n return ctx.succeed(\n { host, ...list },\n ctx.ui.result({\n title:\n list.groups.length === 0\n ? `${list.team.slug} has no groups`\n : `Groups of ${list.team.slug}`,\n tone: list.groups.length === 0 ? 'warn' : 'ok',\n rows: list.groups.map(groupRow),\n notes: [\n `A group narrows what its members see to its products. \"${cli()} teams groups create ${list.team.slug} <name> --products <slug,slug>\" adds one.`,\n ],\n }),\n );\n }\n\n case 'groups-create': {\n const done = await client.call((token) =>\n createTeamGroup(host, token, team, {\n name: plan.name,\n ...(plan.description === undefined\n ? {}\n : { description: plan.description }),\n ...(plan.products === undefined ? {} : { products: plan.products }),\n }),\n );\n return ctx.succeed(\n { host, ...done },\n ctx.ui.result({\n title: `Created group ${done.group.name} on ${done.team.slug}`,\n rows: [groupRow(done.group)],\n notes: [\n `Add members with \"${cli()} teams groups members add ${done.team.slug} ${quote(done.group.name)} <email>\".`,\n ],\n }),\n );\n }\n\n case 'groups-update': {\n const done = await client.call((token) =>\n updateTeamGroup(\n host,\n token,\n { ...team, group: plan.group },\n {\n ...(plan.name === undefined ? {} : { name: plan.name }),\n ...(plan.description === undefined\n ? {}\n : { description: plan.description }),\n ...(plan.products === undefined ? {} : { products: plan.products }),\n },\n ),\n );\n return ctx.succeed(\n { host, ...done },\n ctx.ui.result({\n title: `Updated group ${done.group.name} on ${done.team.slug}`,\n rows: [groupRow(done.group)],\n }),\n );\n }\n\n case 'groups-delete': {\n const done = await client.call((token) =>\n deleteTeamGroup(host, token, { ...team, group: plan.group }),\n );\n return ctx.succeed(\n { host, ...done },\n ctx.ui.result({\n title: `Deleted group ${done.group.name} from ${done.team.slug}`,\n tone: 'warn',\n }),\n );\n }\n\n case 'groups-member': {\n const done = await client.call((token) =>\n setTeamGroupMember(\n host,\n token,\n { ...team, group: plan.group, email: plan.email },\n plan.member,\n ),\n );\n return ctx.succeed(\n { host, ...done },\n ctx.ui.result({\n title: !done.changed\n ? `${done.email} was already ${plan.member ? 'in' : 'not in'} ${done.group.name}`\n : plan.member\n ? `Added ${done.email} to ${done.group.name}`\n : `Took ${done.email} out of ${done.group.name}`,\n rows: [groupRow(done.group)],\n }),\n );\n }\n\n case 'health': {\n if (plan.mine && plan.product) {\n const product = plan.product;\n const done = await client.call((token) =>\n ownTeamHealth(host, token, { ...team, product }, plan.run),\n );\n return ctx.succeed(\n { host, ...done, mine: true },\n ctx.ui.result({\n title: `Your ${done.integration.productName} connection: ${done.integration.status}`,\n tone: toneOf(done.integration),\n rows: healthRows(done.integration),\n notes: plan.run\n ? []\n : [\n `\"${cli()} teams health ${done.team.slug} ${product} --mine --run\" checks it now.`,\n ],\n }),\n );\n }\n if (plan.run && plan.product) {\n const product = plan.product;\n const done = await client.call((token) =>\n runTeamHealthCheck(host, token, { ...team, product }),\n );\n return ctx.succeed(\n { host, ...done },\n ctx.ui.result({\n title: `${done.integration.productName} on ${done.team.slug}: ${done.integration.status}`,\n tone: toneOf(done.integration),\n rows: healthRows(done.integration),\n }),\n );\n }\n const list = await client.call((token) =>\n listTeamHealth(host, token, team),\n );\n const rows = plan.product\n ? list.integrations.filter((row) => row.slug === plan.product)\n : list.integrations;\n if (plan.product && rows.length === 0) {\n throw invalidStateError(\n `${list.team.slug} has not connected ${plan.product}, so it has no health to show.`,\n `\"${cli()} teams health ${list.team.slug}\" lists what it has connected.`,\n );\n }\n const data = { host, ...list, integrations: rows };\n if (plan.product) {\n const row = rows[0]!;\n return ctx.succeed(\n data,\n ctx.ui.result({\n title: `${row.productName} on ${list.team.slug}: ${row.status}`,\n tone: toneOf(row),\n rows: healthRows(row),\n notes: [\n `\"${cli()} teams health ${list.team.slug} ${row.slug} --run\" checks it now.`,\n ],\n }),\n );\n }\n return ctx.succeed(\n data,\n ctx.ui.result({\n title:\n rows.length === 0\n ? `${list.team.slug} has no connected integrations`\n : `Integration health on ${list.team.slug}`,\n tone:\n rows.length === 0\n ? 'warn'\n : rows.some((row) => row.status === 'unhealthy')\n ? 'err'\n : rows.some((row) => row.status !== 'healthy')\n ? 'warn'\n : 'ok',\n rows: rows.map((row): ResultRow => [\n row.slug,\n `${row.status}${row.statusReason ? ` · ${row.statusReason}` : ''}${row.lastCheckedAt ? ` · checked ${row.lastCheckedAt.slice(0, 10)}` : ' · never checked'}`,\n ]),\n notes:\n rows.length === 0\n ? []\n : [\n `\"${cli()} teams health ${list.team.slug} <product> --run\" checks one now.`,\n ],\n }),\n );\n }\n\n case 'workspace-list': {\n const list = await client.call((token) =>\n listTeamWorkspaces(host, token, team),\n );\n return ctx.succeed(\n { host, ...list },\n ctx.ui.result({\n title:\n list.workspaces.length === 0\n ? `${list.team.slug} has no workspaces`\n : `Workspaces of ${list.team.slug}`,\n tone: list.workspaces.length === 0 ? 'warn' : 'ok',\n rows: list.workspaces.map((workspace): ResultRow => [\n workspace.slug,\n [\n workspace.label ?? workspace.name,\n ...(workspace.isDefault ? ['default'] : []),\n ...(workspace.visible ? [] : ['hidden by the team']),\n ].join(' · '),\n ]),\n notes: [\n `\"${cli()} teams workspace default ${list.team.slug} <workspace>\" sets the one the team lands on.`,\n ],\n }),\n );\n }\n\n case 'workspace-default': {\n const done = await client.call((token) =>\n setTeamDefaultWorkspace(host, token, team, plan.workspace),\n );\n return ctx.succeed(\n { host, ...done },\n ctx.ui.result({\n title: done.changed\n ? `${done.team.slug} now lands on ${done.workspace.label ?? done.workspace.name}`\n : `${done.workspace.label ?? done.workspace.name} is already ${done.team.slug}'s default`,\n rows: [['Was', done.previous?.slug ?? '—']],\n notes: ['A member who picked their own default keeps theirs.'],\n }),\n );\n }\n }\n}\n\nfunction confirmUnless(\n yes: boolean,\n confirm: Confirmation,\n): { confirm?: Confirmation } {\n return yes ? {} : { confirm };\n}\n\n/**\n * A change that takes something away: asked at a terminal; a script, an\n * agent run or `--json` passes `--yes` instead. Asked before any request.\n */\nexport async function confirmChange(\n ctx: CliContext,\n args: TeamsArgs,\n confirm: Confirmation,\n): Promise<void> {\n if (!canPrompt(ctx, args)) {\n throw invalidStateError(\n confirm.what,\n `Re-run with --yes: ${confirm.command}`,\n );\n }\n const { ask } = args;\n const confirmed = ask\n ? /^y(es)?$/i.test((await ask(confirm.question)).trim())\n : await promptYesNo(confirm.question);\n if (!confirmed) {\n throw invalidStateError(\n `Not confirmed: ${confirm.what}`,\n 'Nothing was changed.',\n );\n }\n}\n\nfunction groupRow(group: TeamGroup): ResultRow {\n return [\n group.kind === 'predefined'\n ? `${group.name} (predefined)`\n : group.kind === 'everyone'\n ? `${group.name} (everyone in no other group)`\n : group.name,\n [\n group.description ?? 'no description',\n group.kind === 'everyone'\n ? 'members: everyone on the team in no other group'\n : `members: ${group.members.length === 0 ? 'none' : group.members.map((member) => member.email ?? member.userId).join(', ')}`,\n `products: ${group.products.length === 0 ? 'none (no narrowing)' : group.products.map((product) => product.slug).join(', ')}`,\n ],\n ];\n}\n\nfunction healthRows(row: TeamHealthRow): ResultRow[] {\n return [\n ['Status', row.status],\n ...(row.statusReason ? [['Why', row.statusReason] as const] : []),\n ['Last checked', row.lastCheckedAt ?? 'never'],\n ['Last success', row.lastSuccessAt ?? '—'],\n ['Last failure', row.lastFailureAt ?? '—'],\n ...(row.lastErrorMessage\n ? [['Last error', row.lastErrorMessage] as const]\n : []),\n ...(row.tokenExpiresAt\n ? [['Token expires', row.tokenExpiresAt] as const]\n : []),\n ];\n}\n\nfunction toneOf(row: TeamHealthRow) {\n return row.status === 'healthy'\n ? ('ok' as const)\n : row.status === 'unhealthy'\n ? ('err' as const)\n : ('warn' as const);\n}\n\nfunction stringFlag(value: unknown): string | undefined {\n return typeof value === 'string' ? value.trim() : undefined;\n}\n\n/** `--products a,b`: the list; `--products none` (or empty): no products. */\nfunction productsFlag(value: unknown): string[] | undefined {\n if (typeof value !== 'string') return undefined;\n const trimmed = value.trim().toLowerCase();\n if (trimmed === '' || trimmed === 'none') return [];\n return [\n ...new Set(\n trimmed\n .split(',')\n .map((slug) => slug.trim())\n .filter(Boolean)\n .map((slug) => slugOf(slug, 'product')),\n ),\n ];\n}\n\nfunction groupOf(value: string | undefined, team: string): string {\n const group = value?.trim();\n if (group) return group;\n throw usageError(\n 'Name the group, by name or id.',\n `\"${cli()} teams groups list ${team}\" lists them.`,\n );\n}\n\nfunction quote(value: string): string {\n return /^[A-Za-z0-9._-]+$/.test(value) ? value : `\"${value}\"`;\n}\n\nfunction noExtra(extra: readonly string[]) {\n if (extra.length > 0) {\n throw usageError(\n `Unexpected argument \"${extra[0]}\".`,\n 'See \"ekanos teams --help\".',\n );\n }\n}\n\nfunction slugOf(value: string | undefined, what: 'team' | 'product'): string {\n const slug = value?.trim().toLowerCase();\n if (\n slug &&\n (what === 'product'\n ? isProductSlug(slug)\n : /^[a-z0-9][a-z0-9-]*$/.test(slug))\n ) {\n return slug;\n }\n if (what === 'product' && value) {\n throw usageError(\n `\"${value}\" is not a product slug.`,\n `${PRODUCT_SLUG_SHAPE} \"ekanos catalog\" lists them.`,\n );\n }\n throw usageError(\n value ? `\"${value}\" is not a ${what} slug.` : `Name the ${what}.`,\n what === 'team'\n ? '\"ekanos teams list\" lists the teams, e.g. \"ekanos teams health bank-a\".'\n : '\"ekanos catalog\" lists the products, e.g. \"ekanos teams health bank-a zendesk\".',\n );\n}\n\nfunction emailOf(value: string | undefined): string {\n const email = value?.trim().toLowerCase();\n if (email && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email)) return email;\n throw usageError(\n value ? `\"${value}\" is not an email address.` : 'Name the person by email.',\n 'e.g. \"ekanos teams members resend bank-a ana@bank-a.com\".',\n );\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import { invalidStateError, usageError } from '../errors.js';
2
+ import { PRODUCT_SLUG_SHAPE, isProductSlug } from '../product-slug.js';
2
3
  import { addTeamMember, createTeam, disconnectTeamIntegration, inviteTeamMember, listTeamMembers, listTeamRoles, removeTeamMember, renameTeam, setTeamMemberRole, } from '../teams-api.js';
3
4
  import { runTeamConnect } from './teams-connect.js';
4
5
  /**
@@ -314,8 +315,15 @@ function noExtra(extra) {
314
315
  }
315
316
  function slugOf(value, what) {
316
317
  const slug = value === null || value === void 0 ? void 0 : value.trim().toLowerCase();
317
- if (slug && /^[a-z0-9][a-z0-9-]*$/.test(slug))
318
+ if (slug &&
319
+ (what === 'product'
320
+ ? isProductSlug(slug)
321
+ : /^[a-z0-9][a-z0-9-]*$/.test(slug))) {
318
322
  return slug;
323
+ }
324
+ if (what === 'product' && value) {
325
+ throw usageError(`"${value}" is not a product slug.`, `${PRODUCT_SLUG_SHAPE} "ekanos catalog" lists them.`);
326
+ }
319
327
  throw usageError(value ? `"${value}" is not a ${what} slug.` : `Name the ${what}.`, what === 'team'
320
328
  ? '"ekanos teams list" lists the teams, e.g. "ekanos teams members list bank-a".'
321
329
  : '"ekanos catalog" lists the products, e.g. "ekanos teams connect bank-a zendesk".');