diff --git a/.changeset/34730-s3b-slack-setup-entry.md b/.changeset/34730-s3b-slack-setup-entry.md new file mode 100644 index 00000000000..1a0ef6e260d --- /dev/null +++ b/.changeset/34730-s3b-slack-setup-entry.md @@ -0,0 +1,12 @@ +--- +'@objectstack/service-messaging': patch +'@objectstack/platform-objects': patch +--- + +Clause-②: no +Metadata-protocol: none + +feat(messaging): Setup lists the Slack page where connector-slack is composed + +- **Setup › Integrations › Slack.** Where connector-slack is composed, Setup now lists a Slack entry under Integrations. It opens the console's Slack page (`messaging:slack`), where an organization administrator installs or replaces the organization's Slack token, removes the install, and reviews or removes each member's Slack link. The entry asks `setup.write`, the capability every Slack administrator door asks. `MessagingServicePlugin` registers it in the same `kernel:ready` hook, and on the same condition, as the `slack` channel. Without connector-slack, Setup lists no Slack entry. The label is translated in every locale the platform ships. The bundle is exported as `SLACK_SETUP_UI_BUNDLE`, with `SLACK_SETUP_COMPONENT_REF`. +- **The Slack link removal topic, on every deployment.** `GET /api/v1/messaging/preference-options` and `GET /api/v1/messaging/me/preferences` list the topic `messaging.slack_link_removed` on every deployment, including one without connector-slack. It is emitted only where connector-slack is composed, when an administrator removes a person's Slack link or removes the organization's Slack install. diff --git a/packages/cli/scripts/check-app-nav-i18n.mjs b/packages/cli/scripts/check-app-nav-i18n.mjs index 626c6dfc769..954ddb43acc 100644 --- a/packages/cli/scripts/check-app-nav-i18n.mjs +++ b/packages/cli/scripts/check-app-nav-i18n.mjs @@ -465,6 +465,17 @@ const CONTRIBUTORS = [ return { manifests: [CONNECTOR_CREDENTIALS_UI_BUNDLE] }; }, }, + { + // `nav_slack` (Setup → Integrations). Registered by `MessagingServicePlugin` + // at `kernel:ready`, and only where connector-slack's `slack` service + // resolves, so the bundle is read directly — the row above's shape. + source: '@objectstack/service-messaging (SLACK_SETUP_UI_BUNDLE)', + apps: ['setup'], + async load() { + const { SLACK_SETUP_UI_BUNDLE } = await import('@objectstack/service-messaging'); + return { manifests: [SLACK_SETUP_UI_BUNDLE] }; + }, + }, { source: '@objectstack/cloud-connection (cloud + marketplace UI bundles)', apps: ['setup'], diff --git a/packages/cli/test/setup-integrations-order.pin.test.ts b/packages/cli/test/setup-integrations-order.pin.test.ts index 74f147a35bc..2238e1126c5 100644 --- a/packages/cli/test/setup-integrations-order.pin.test.ts +++ b/packages/cli/test/setup-integrations-order.pin.test.ts @@ -14,6 +14,7 @@ // Datasources `@objectstack/service-datasource` // Connector Credentials `@objectstack/service-automation` // Connector Connections `@objectstack/service-automation` (same contribution) +// Slack `@objectstack/service-messaging` (with connector-slack composed) // Cloud Connection `@objectstack/cloud-connection` // // Each contributor states the group's other priorities in its own header so @@ -35,16 +36,18 @@ // Why it lives in `packages/cli/test/` // --------------------------------------------------------------------------- // The same reason as `connect-agent-both-halves-wire.pin.test.ts` beside it: -// this is a COMPOSED fact across five packages and the registry fold, and +// this is a COMPOSED fact across six packages and the registry fold, and // `packages/cli` is the only workspace package that depends on all of them. // -// Two of the five register their contribution from inside `init()` through +// Two of the six register their contribution from inside `init()` through // the `manifest` service rather than exporting it, so they are booted here on // a context that serves exactly that service — the shape // `packages/cli/scripts/check-app-nav-i18n.mjs` boots the same two with. // `@objectstack/service-automation` registers its bundle at `kernel:ready`, // which this context never fires, so its exported bundle is read directly, as -// that gate does too. +// that gate does too. `@objectstack/service-messaging` registers its Slack +// bundle at `kernel:ready` too, and only with connector-slack composed; it is +// read the same way. import { describe, expect, it } from 'vitest'; import { CLOUD_CONNECTION_UI_BUNDLE } from '@objectstack/cloud-connection'; @@ -54,6 +57,7 @@ import { SETUP_APP, SETUP_NAV_CONTRIBUTIONS } from '@objectstack/platform-object import { WebhookOutboxPlugin } from '@objectstack/plugin-webhooks'; import { CONNECTOR_CREDENTIALS_UI_BUNDLE } from '@objectstack/service-automation'; import { DatasourceAdminServicePlugin } from '@objectstack/service-datasource'; +import { SLACK_SETUP_UI_BUNDLE } from '@objectstack/service-messaging'; type AnyRec = Record; @@ -67,6 +71,7 @@ const EXPECTED_TIERS: readonly (readonly string[])[] = [ ['nav_webhooks', 'nav_http_deliveries', 'nav_datasources'], // One contribution carries both, in this order (ADR-0143 D5 added the second). ['nav_connector_credentials', 'nav_connector_connections'], + ['nav_slack'], ['nav_cloud_connection'], ]; @@ -105,6 +110,7 @@ async function setupContributions(): Promise = SETUP_NAV_CONTRIBUTIONS.map((contribution) => ({ diff --git a/packages/cli/vitest.config.ts b/packages/cli/vitest.config.ts index 19e1c1b0f5e..471ca1d9903 100644 --- a/packages/cli/vitest.config.ts +++ b/packages/cli/vitest.config.ts @@ -1008,6 +1008,14 @@ export default defineConfig({ find: /^@objectstack\/service-push$/, replacement: path.resolve(__dirname, '../services/service-push/src/index.ts'), }, + // `setup-integrations-order.pin.test.ts` reads `SLACK_SETUP_UI_BUNDLE`, + // the Setup › Integrations › Slack contribution. Resolved to source for + // the reason its neighbours give. `check:test-source-alias` names this + // import and fails without it. + { + find: /^@objectstack\/service-messaging$/, + replacement: path.resolve(__dirname, '../services/service-messaging/src/index.ts'), + }, ], }, test: { diff --git a/packages/platform-objects/src/apps/translations/ar.source-hashes.ts b/packages/platform-objects/src/apps/translations/ar.source-hashes.ts index 6a4178a065f..e78465f76d6 100644 --- a/packages/platform-objects/src/apps/translations/ar.source-hashes.ts +++ b/packages/platform-objects/src/apps/translations/ar.source-hashes.ts @@ -128,6 +128,7 @@ export const arSourceHashes: Readonly> = { 'apps.setup.navigation.nav_datasources.label': '2f0648ce23158e6f', 'apps.setup.navigation.nav_connector_credentials.label': '0504775224e05a81', 'apps.setup.navigation.nav_connector_connections.label': '949e9a8fd25c3d57', + 'apps.setup.navigation.nav_slack.label': 'c3c9e181e8c74b22', 'apps.setup.navigation.nav_oauth_apps.label': '1b26cce61a4c10eb', 'apps.studio.label': '5aaaaea2294ee893', 'apps.studio.description': 'c026a5795933995d', diff --git a/packages/platform-objects/src/apps/translations/ar.ts b/packages/platform-objects/src/apps/translations/ar.ts index 2ae20a8951a..0c2b2cbd2d3 100644 --- a/packages/platform-objects/src/apps/translations/ar.ts +++ b/packages/platform-objects/src/apps/translations/ar.ts @@ -125,6 +125,7 @@ export const ar: TranslationData = { nav_datasources: { label: 'مصادر البيانات' }, nav_connector_credentials: { label: 'بيانات اعتماد الموصلات' }, nav_connector_connections: { label: 'اتصالات الموصلات' }, + nav_slack: { label: 'Slack' }, nav_oauth_apps: { label: 'تطبيقات OAuth' }, }, diff --git a/packages/platform-objects/src/apps/translations/de.source-hashes.ts b/packages/platform-objects/src/apps/translations/de.source-hashes.ts index 01ab03f0b83..91a326ba4c7 100644 --- a/packages/platform-objects/src/apps/translations/de.source-hashes.ts +++ b/packages/platform-objects/src/apps/translations/de.source-hashes.ts @@ -129,6 +129,7 @@ export const deSourceHashes: Readonly> = { 'apps.setup.navigation.nav_datasources.label': '2f0648ce23158e6f', 'apps.setup.navigation.nav_connector_credentials.label': '0504775224e05a81', 'apps.setup.navigation.nav_connector_connections.label': '949e9a8fd25c3d57', + 'apps.setup.navigation.nav_slack.label': 'c3c9e181e8c74b22', 'apps.setup.navigation.nav_oauth_apps.label': '1b26cce61a4c10eb', 'apps.studio.label': '5aaaaea2294ee893', 'apps.studio.description': 'c026a5795933995d', diff --git a/packages/platform-objects/src/apps/translations/de.ts b/packages/platform-objects/src/apps/translations/de.ts index be27d6ad545..68868cfa17e 100644 --- a/packages/platform-objects/src/apps/translations/de.ts +++ b/packages/platform-objects/src/apps/translations/de.ts @@ -127,6 +127,7 @@ export const de: TranslationData = { nav_datasources: { label: 'Datenquellen' }, nav_connector_credentials: { label: 'Konnektor-Anmeldedaten' }, nav_connector_connections: { label: 'Konnektor-Verbindungen' }, + nav_slack: { label: 'Slack' }, nav_oauth_apps: { label: 'OAuth-Anwendungen' }, }, diff --git a/packages/platform-objects/src/apps/translations/en.ts b/packages/platform-objects/src/apps/translations/en.ts index b5661f1bd4c..c9967e11236 100644 --- a/packages/platform-objects/src/apps/translations/en.ts +++ b/packages/platform-objects/src/apps/translations/en.ts @@ -166,6 +166,7 @@ export const en: TranslationData = { nav_datasources: { label: 'Datasources' }, nav_connector_credentials: { label: 'Connector Credentials' }, nav_connector_connections: { label: 'Connector Connections' }, + nav_slack: { label: 'Slack' }, // Advanced // diff --git a/packages/platform-objects/src/apps/translations/es-ES.ts b/packages/platform-objects/src/apps/translations/es-ES.ts index 8cd297bebcc..94f2fe549ff 100644 --- a/packages/platform-objects/src/apps/translations/es-ES.ts +++ b/packages/platform-objects/src/apps/translations/es-ES.ts @@ -113,6 +113,7 @@ export const esES: TranslationData = { nav_datasources: { label: 'Fuentes de datos' }, nav_connector_credentials: { label: 'Credenciales de conectores' }, nav_connector_connections: { label: 'Conexiones de conectores' }, + nav_slack: { label: 'Slack' }, nav_oauth_apps: { label: 'Aplicaciones OAuth' }, }, diff --git a/packages/platform-objects/src/apps/translations/fr.source-hashes.ts b/packages/platform-objects/src/apps/translations/fr.source-hashes.ts index 297eed91030..95bbcde6467 100644 --- a/packages/platform-objects/src/apps/translations/fr.source-hashes.ts +++ b/packages/platform-objects/src/apps/translations/fr.source-hashes.ts @@ -129,6 +129,7 @@ export const frSourceHashes: Readonly> = { 'apps.setup.navigation.nav_datasources.label': '2f0648ce23158e6f', 'apps.setup.navigation.nav_connector_credentials.label': '0504775224e05a81', 'apps.setup.navigation.nav_connector_connections.label': '949e9a8fd25c3d57', + 'apps.setup.navigation.nav_slack.label': 'c3c9e181e8c74b22', 'apps.setup.navigation.nav_oauth_apps.label': '1b26cce61a4c10eb', 'apps.studio.label': '5aaaaea2294ee893', 'apps.studio.description': 'c026a5795933995d', diff --git a/packages/platform-objects/src/apps/translations/fr.ts b/packages/platform-objects/src/apps/translations/fr.ts index 4c5aa108121..bf54af71032 100644 --- a/packages/platform-objects/src/apps/translations/fr.ts +++ b/packages/platform-objects/src/apps/translations/fr.ts @@ -127,6 +127,7 @@ export const fr: TranslationData = { nav_datasources: { label: 'Sources de données' }, nav_connector_credentials: { label: 'Identifiants des connecteurs' }, nav_connector_connections: { label: 'Connexions des connecteurs' }, + nav_slack: { label: 'Slack' }, nav_oauth_apps: { label: 'Applications OAuth' }, }, diff --git a/packages/platform-objects/src/apps/translations/ja-JP.ts b/packages/platform-objects/src/apps/translations/ja-JP.ts index 11b5700cff3..a47aab85a20 100644 --- a/packages/platform-objects/src/apps/translations/ja-JP.ts +++ b/packages/platform-objects/src/apps/translations/ja-JP.ts @@ -113,6 +113,7 @@ export const jaJP: TranslationData = { nav_datasources: { label: 'データソース' }, nav_connector_credentials: { label: 'コネクタ認証情報' }, nav_connector_connections: { label: 'コネクタ接続' }, + nav_slack: { label: 'Slack' }, nav_oauth_apps: { label: 'OAuth アプリケーション' }, }, diff --git a/packages/platform-objects/src/apps/translations/ko.source-hashes.ts b/packages/platform-objects/src/apps/translations/ko.source-hashes.ts index 6f04e1bcf83..7733c67416e 100644 --- a/packages/platform-objects/src/apps/translations/ko.source-hashes.ts +++ b/packages/platform-objects/src/apps/translations/ko.source-hashes.ts @@ -129,6 +129,7 @@ export const koSourceHashes: Readonly> = { 'apps.setup.navigation.nav_datasources.label': '2f0648ce23158e6f', 'apps.setup.navigation.nav_connector_credentials.label': '0504775224e05a81', 'apps.setup.navigation.nav_connector_connections.label': '949e9a8fd25c3d57', + 'apps.setup.navigation.nav_slack.label': 'c3c9e181e8c74b22', 'apps.setup.navigation.nav_oauth_apps.label': '1b26cce61a4c10eb', 'apps.studio.label': '5aaaaea2294ee893', 'apps.studio.description': 'c026a5795933995d', diff --git a/packages/platform-objects/src/apps/translations/ko.ts b/packages/platform-objects/src/apps/translations/ko.ts index 3d2ac860ff8..66f39ddb906 100644 --- a/packages/platform-objects/src/apps/translations/ko.ts +++ b/packages/platform-objects/src/apps/translations/ko.ts @@ -126,6 +126,7 @@ export const ko: TranslationData = { nav_datasources: { label: '데이터 소스' }, nav_connector_credentials: { label: '커넥터 자격 증명' }, nav_connector_connections: { label: '커넥터 연결' }, + nav_slack: { label: 'Slack' }, nav_oauth_apps: { label: 'OAuth 애플리케이션' }, }, diff --git a/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.ts b/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.ts index fbcebc6653a..28d50b41e88 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.ts @@ -129,6 +129,7 @@ export const ptBRSourceHashes: Readonly> = { 'apps.setup.navigation.nav_datasources.label': '2f0648ce23158e6f', 'apps.setup.navigation.nav_connector_credentials.label': '0504775224e05a81', 'apps.setup.navigation.nav_connector_connections.label': '949e9a8fd25c3d57', + 'apps.setup.navigation.nav_slack.label': 'c3c9e181e8c74b22', 'apps.setup.navigation.nav_oauth_apps.label': '1b26cce61a4c10eb', 'apps.studio.label': '5aaaaea2294ee893', 'apps.studio.description': 'c026a5795933995d', diff --git a/packages/platform-objects/src/apps/translations/pt-BR.ts b/packages/platform-objects/src/apps/translations/pt-BR.ts index 654a0abe4fc..6599e9845c5 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.ts @@ -127,6 +127,7 @@ export const ptBR: TranslationData = { nav_datasources: { label: 'Fontes de dados' }, nav_connector_credentials: { label: 'Credenciais dos conectores' }, nav_connector_connections: { label: 'Conexões dos conectores' }, + nav_slack: { label: 'Slack' }, nav_oauth_apps: { label: 'Aplicativos OAuth' }, }, diff --git a/packages/platform-objects/src/apps/translations/ru.source-hashes.ts b/packages/platform-objects/src/apps/translations/ru.source-hashes.ts index 6427e27ade3..d0c1b7036ec 100644 --- a/packages/platform-objects/src/apps/translations/ru.source-hashes.ts +++ b/packages/platform-objects/src/apps/translations/ru.source-hashes.ts @@ -129,6 +129,7 @@ export const ruSourceHashes: Readonly> = { 'apps.setup.navigation.nav_datasources.label': '2f0648ce23158e6f', 'apps.setup.navigation.nav_connector_credentials.label': '0504775224e05a81', 'apps.setup.navigation.nav_connector_connections.label': '949e9a8fd25c3d57', + 'apps.setup.navigation.nav_slack.label': 'c3c9e181e8c74b22', 'apps.setup.navigation.nav_oauth_apps.label': '1b26cce61a4c10eb', 'apps.studio.label': '5aaaaea2294ee893', 'apps.studio.description': 'c026a5795933995d', diff --git a/packages/platform-objects/src/apps/translations/ru.ts b/packages/platform-objects/src/apps/translations/ru.ts index 5efdec002b1..410c388a5a7 100644 --- a/packages/platform-objects/src/apps/translations/ru.ts +++ b/packages/platform-objects/src/apps/translations/ru.ts @@ -127,6 +127,7 @@ export const ru: TranslationData = { nav_datasources: { label: 'Источники данных' }, nav_connector_credentials: { label: 'Учётные данные коннекторов' }, nav_connector_connections: { label: 'Подключения коннекторов' }, + nav_slack: { label: 'Slack' }, nav_oauth_apps: { label: 'Приложения OAuth' }, }, diff --git a/packages/platform-objects/src/apps/translations/zh-CN.ts b/packages/platform-objects/src/apps/translations/zh-CN.ts index 3bbf4596e63..b95b2ac04ca 100644 --- a/packages/platform-objects/src/apps/translations/zh-CN.ts +++ b/packages/platform-objects/src/apps/translations/zh-CN.ts @@ -120,6 +120,7 @@ export const zhCN: TranslationData = { nav_datasources: { label: '数据源' }, nav_connector_credentials: { label: '连接器凭据' }, nav_connector_connections: { label: '连接器连接' }, + nav_slack: { label: 'Slack' }, nav_oauth_apps: { label: 'OAuth 应用' }, }, diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.ts b/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.ts index 06b42354c86..519f7384c29 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.ts @@ -128,6 +128,7 @@ export const zhHantSourceHashes: Readonly> = { 'apps.setup.navigation.nav_datasources.label': '2f0648ce23158e6f', 'apps.setup.navigation.nav_connector_credentials.label': '0504775224e05a81', 'apps.setup.navigation.nav_connector_connections.label': '949e9a8fd25c3d57', + 'apps.setup.navigation.nav_slack.label': 'c3c9e181e8c74b22', 'apps.setup.navigation.nav_oauth_apps.label': '1b26cce61a4c10eb', 'apps.studio.label': '5aaaaea2294ee893', 'apps.studio.description': 'c026a5795933995d', diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.ts b/packages/platform-objects/src/apps/translations/zh-Hant.ts index 1fbe2060100..b55762e124b 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.ts @@ -125,6 +125,7 @@ export const zhHant: TranslationData = { nav_datasources: { label: '資料來源' }, nav_connector_credentials: { label: '連接器憑證' }, nav_connector_connections: { label: '連接器連線' }, + nav_slack: { label: 'Slack' }, nav_oauth_apps: { label: 'OAuth 應用程式' }, }, diff --git a/packages/services/service-messaging/src/index.ts b/packages/services/service-messaging/src/index.ts index 8f58de36fc6..d9c58985719 100644 --- a/packages/services/service-messaging/src/index.ts +++ b/packages/services/service-messaging/src/index.ts @@ -103,6 +103,7 @@ export { SLACK_ADMIN_CAPABILITY, } from './slack-link-routes.js'; export type { SlackLinkRoutesDeps } from './slack-link-routes.js'; +export { SLACK_SETUP_UI_BUNDLE, SLACK_SETUP_COMPONENT_REF } from './slack-setup-ui.js'; // [#24978] Keyed notification text — `EmitInput.keyedText`, rendered per // recipient at delivery from the `i18n` service's catalog. diff --git a/packages/services/service-messaging/src/messaging-service-plugin.ts b/packages/services/service-messaging/src/messaging-service-plugin.ts index 672f6e3bf12..794db597159 100644 --- a/packages/services/service-messaging/src/messaging-service-plugin.ts +++ b/packages/services/service-messaging/src/messaging-service-plugin.ts @@ -29,6 +29,7 @@ import { type SlackTriggerEngine, } from './slack-links.js'; import { SLACK_ACCOUNT_ROUTE, SLACK_LINK_ROUTE, registerSlackLinkRoutes } from './slack-link-routes.js'; +import { SLACK_SETUP_UI_BUNDLE } from './slack-setup-ui.js'; import { NotificationTemplateStore, TEMPLATE_BUILTINS, @@ -641,7 +642,9 @@ export class MessagingServicePlugin implements Plugin { // preference doors (`getKnownChannels`) answer as they do with no // Slack in the composition. It sends a DM to a recipient's // confirmed link with their organization's own install token - // (sys_channel_account). + // (sys_channel_account). [#34730 step 3] Setup's Slack entry + // (`slack-setup-ui.ts`) is registered on the same condition, so a + // composition without connector-slack lists no Slack page. ctx.hook('kernel:ready', async () => { if (!getSlack()) return; service.registerChannelProvider('slack', lazyChannelMount({ @@ -650,6 +653,11 @@ export class MessagingServicePlugin implements Plugin { announce: '[messaging] slack channel registered (a DM to the recipient\'s confirmed sys_channel_user_link, with their organization\'s sys_channel_account token)', logger: ctx.logger, })); + try { + ctx.getService<{ register(m: unknown): void }>('manifest').register(SLACK_SETUP_UI_BUNDLE); + } catch { + /* no manifest service: no console to carry the entry */ + } }); } diff --git a/packages/services/service-messaging/src/slack-channel-composition.test.ts b/packages/services/service-messaging/src/slack-channel-composition.test.ts index 6872770e186..375fbccc2da 100644 --- a/packages/services/service-messaging/src/slack-channel-composition.test.ts +++ b/packages/services/service-messaging/src/slack-channel-composition.test.ts @@ -13,6 +13,11 @@ * * The `/automation` save doors read the same list; their side is pinned in * `@objectstack/runtime` (`automation-notify-slack-composition.test.ts`). + * + * [#34730 step 3] Setup's Slack entry (`SLACK_SETUP_UI_BUNDLE`) is registered + * on the same condition, and read back through the Setup app fold the + * `/api/v1/meta/app` door serves (`SchemaRegistry.getApp`): listed under + * Integrations with connector-slack composed, absent without it. */ import { describe, it, expect } from 'vitest'; @@ -22,7 +27,13 @@ import { assertEngineUpdateDispatch, type EngineFindOneQueryInput, } from '@objectstack/metadata-core'; +import { SchemaRegistry } from '@objectstack/objectql'; +import { SETUP_APP } from '@objectstack/platform-objects/apps'; +import { ManifestSchema } from '@objectstack/spec/kernel'; +import { PLATFORM_CAPABILITIES } from '@objectstack/spec/security'; import { MessagingServicePlugin } from './messaging-service-plugin.js'; +import { SLACK_ADMIN_CAPABILITY } from './slack-link-routes.js'; +import { SLACK_SETUP_COMPONENT_REF, SLACK_SETUP_UI_BUNDLE } from './slack-setup-ui.js'; import type { MessagingService } from './messaging-service.js'; import { MY_PREFERENCES_ROUTE } from './my-preferences-routes.js'; import { PREFERENCE_OPTIONS_ROUTE } from './preference-options-routes.js'; @@ -51,12 +62,13 @@ async function compose(opts: { slack: boolean }) { async update(_object: string, data: any, options?: any) { assertEngineUpdateDispatch(data, options); return {}; }, async delete(_object: string, options?: any) { assertEngineDeleteDispatch(options); return {}; }, }; + const manifests: Array<{ id?: string; navigationContributions?: unknown[] }> = []; const handlers = new Map Promise>(); const mount = (verb: string) => (path: string, handler: (req: unknown, res: unknown) => Promise) => { handlers.set(`${verb} ${path}`, handler); }; const services = new Map([ ['data', engine], ['objectql', engine], - ['manifest', { register() {} }], + ['manifest', { register: (m: { id?: string }) => { manifests.push(m); } }], ['http-server', { get: mount('GET'), post: mount('POST'), put: mount('PUT'), delete: mount('DELETE'), patch: mount('PATCH'), use() {} }], ['auth', { api: { @@ -93,6 +105,7 @@ async function compose(opts: { slack: boolean }) { } return { messaging: services.get('messaging') as MessagingService, + manifests, optionChannels: async () => (await get(PREFERENCE_OPTIONS_ROUTE)).channels.map((c: any) => c.value), myChannels: async () => (await get(MY_PREFERENCES_ROUTE)).channels.map((c: any) => c.channel), }; @@ -118,3 +131,40 @@ describe('the slack channel is known only where connector-slack is composed', () expect(await c.myChannels()).toContain('slack'); }); }); + +/** Setup's Integrations group as the meta door serves it: the shell plus every contribution the boot registered. */ +function setupIntegrations(manifests: Array<{ id?: string; navigationContributions?: unknown[] }>) { + const registry = new SchemaRegistry({ multiTenant: false, collisionPolicy: 'error' }); + (registry as any).logLevel = 'silent'; + registry.registerApp(structuredClone(SETUP_APP), '@objectstack/platform-objects'); + for (const m of manifests) { + if (m.id && Array.isArray(m.navigationContributions)) registry.setPackageNavContributions(m.id, m.navigationContributions as any); + } + const group = (registry.getApp('setup') as any)?.navigation?.find((item: any) => item?.id === 'group_integrations'); + return (group?.children ?? []) as Array<{ id: string; componentRef?: string; requiredPermissions?: string[] }>; +} + +describe('Setup lists the Slack page only where connector-slack is composed', () => { + it('the bundle is a valid manifest naming the console page and the capability the Slack admin doors ask', () => { + expect(() => ManifestSchema.parse(SLACK_SETUP_UI_BUNDLE)).not.toThrow(); + expect(SLACK_SETUP_COMPONENT_REF).toBe('messaging:slack'); + expect(SLACK_ADMIN_CAPABILITY).toBe('setup.write'); + expect(PLATFORM_CAPABILITIES.find((c) => c.name === SLACK_ADMIN_CAPABILITY)?.scope).toBe('org'); + }); + + it('with a slack service: the entry is registered once and served under Integrations', async () => { + const c = await compose({ slack: true }); + expect(c.manifests.filter((m) => m.id === SLACK_SETUP_UI_BUNDLE.id)).toHaveLength(1); + const entry = setupIntegrations(c.manifests).find((item) => item.id === 'nav_slack'); + expect(entry?.componentRef).toBe('messaging:slack'); + expect(entry?.requiredPermissions).toEqual(['setup.write']); + }); + + it('without a slack service: no entry is registered and Integrations serves none', async () => { + const c = await compose({ slack: false }); + expect(c.manifests.map((m) => m.id)).not.toContain(SLACK_SETUP_UI_BUNDLE.id); + expect(setupIntegrations(c.manifests).map((item) => item.id)).not.toContain('nav_slack'); + // The control: the same boot registered the messaging manifest, whose Setup entries it serves. + expect(c.manifests.map((m) => m.id)).toContain('com.objectstack.service.messaging'); + }); +}); diff --git a/packages/services/service-messaging/src/slack-setup-ui.ts b/packages/services/service-messaging/src/slack-setup-ui.ts new file mode 100644 index 00000000000..47e25a53791 --- /dev/null +++ b/packages/services/service-messaging/src/slack-setup-ui.ts @@ -0,0 +1,65 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * Setup → Integrations → "Slack" — the navigation entry of the Slack + * administrator doors (`PUT` / `DELETE /api/v1/messaging/slack/account`, + * `GET /api/v1/messaging/slack/links`, `DELETE …/slack/links/:id`), carried by + * the messaging service that owns those doors: the entry lives and dies with + * the capability, the `CONNECTOR_CREDENTIALS_UI_BUNDLE` shape in + * `@objectstack/service-automation`. + * + * The page body is the console's `messaging:slack` component + * (`@object-ui/app-shell`), named by registry key like every other + * framework-contributed Setup page. + * + * Registered by `MessagingServicePlugin` at `kernel:ready` in the same hook, + * and on the same condition, as the `slack` channel: only where + * connector-slack's `slack` client service resolves. A composition without + * connector-slack has no Slack channel, its Slack doors answer 503, and Setup + * lists no Slack entry. + * + * The entry asks {@link SLACK_ADMIN_CAPABILITY} (`setup.write`), the capability + * every administrator door asks: the rule the page's doors enforce is stated + * by the plugin that enforces it, not borrowed from the group. + */ + +import { SLACK_ADMIN_CAPABILITY } from './slack-link-routes.js'; + +/** The console component the entry opens. */ +export const SLACK_SETUP_COMPONENT_REF = 'messaging:slack'; + +/** + * `priority` orders contributions within a group, lowest first. The group's + * other contributors, read where they are declared: Webhooks / HTTP Deliveries + * (`@objectstack/plugin-webhooks`) and Datasources + * (`@objectstack/service-datasource`) at 100, Connector Credentials and + * Connector Connections (`@objectstack/service-automation`) at 120, Cloud + * Connection (`@objectstack/cloud-connection`) at 200 — so 140 sorts this + * entry after the connector pages and before the cloud connection. + */ +export const SLACK_SETUP_UI_BUNDLE = { + id: 'com.objectstack.service-messaging.slack-ui', + namespace: 'sys', + version: '0.1.0', + type: 'plugin', + scope: 'system', + name: 'Slack Setup UI', + description: 'Setup navigation for the Slack page: install or replace the organization\'s Slack token, remove the install, and review or remove each member\'s Slack link.', + navigationContributions: [ + { + app: 'setup', + group: 'group_integrations', + priority: 140, + items: [ + { + id: 'nav_slack', + type: 'component', + label: 'Slack', + componentRef: SLACK_SETUP_COMPONENT_REF, + icon: 'message-square', + requiredPermissions: [SLACK_ADMIN_CAPABILITY], + }, + ], + }, + ], +}; diff --git a/packages/services/service-messaging/vitest.config.ts b/packages/services/service-messaging/vitest.config.ts index 935e585b993..9123dbfbab9 100644 --- a/packages/services/service-messaging/vitest.config.ts +++ b/packages/services/service-messaging/vitest.config.ts @@ -26,6 +26,10 @@ export default defineConfig({ // Mechanism + measured costs: examples/app-showcase/vitest.config.ts. // Enforced repo-wide by scripts/check-console-intercept-disarm.mjs. disableConsoleIntercept: true, + // #13517: quiet the registry's per-item registration chatter — the + // engine's own `OS_REGISTRY_LOG` seam, not a change to its shipped + // default. Enforced by scripts/check-registry-log-declared.mjs. + env: { OS_REGISTRY_LOG: 'warn' }, }, resolve: { alias: [