@cfxlabsinc/b2b-services
    Preparing search index...

    Class SlackTemplateAdminService

    Authoring for b2b.slack_template (docs/proposals/SLACK_TEMPLATES.md §4). Single actor: whoever saves a draft may activate it. Rows are seeded by migration, so every write targets an existing row by its slacktpl_… id, and every write clears the posters' cached read.

    Hierarchy (View Summary)

    Index
    • Parameters

      • __namedParameters: {
            db: B2bDatabase;
            internalEventPublisher: InternalEventPublisher | null;
            valkeyClient: ValkeyClient | null;
        }
        • db: B2bDatabase
        • internalEventPublisher: InternalEventPublisher | null

          Publishes slack.slackTemplate.*; null where nothing writes.

        • valkeyClient: ValkeyClient | null

      Returns SlackTemplateAdminService

    cache: ServiceCache<StoredRow[]>
    db: B2bDatabase
    instance: (...args: []) => SlackTemplateAdminService = ...

    The process service: the shared database, Valkey and the internal bus.

    • Renders a saved version (the draft by default, else the live one; version picks any) or the registry default for a [TEST] post. Variables are the registry samples for sampleCase, never live data. Where it posts is the caller's: always the TEMPLATE_TEST feed, never a customer channel.

      Parameters

      Returns Promise<
          | { ok: true; value: SlackTemplateTest }
          | {
              error:
                  | NotFound
                  | Invalid
                  | ServiceError<
                      | "SLACK_TEMPLATE_VERSION_NOT_FOUND"
                      | "SLACK_TEMPLATE_INVALID_SAMPLE_CASE",
                  >;
              ok: false;
          },
      >

    • A template's saved versions, newest first. Uncached: rows are immutable.

      Parameters

      • input: { id: string; page?: number; pageSize?: number }

      Returns Promise<
          | {
              ok: true;
              value: { hasNext: boolean; items: SlackTemplateVersion[]; total: number };
          }
          | { error: NotFound; ok: false },
      >

    • One change to one template: blocks validates and saves a new draft version, status switches it on or off, liveVersion activates the draft, rolls back to an older version, or (null) resets to the registry default.

      Parameters

      • input: { actorId: string; data: SlackTemplateUpdateData; id: string }
        • actorId: string

          The acting admin, adusr_…; a saved version records it as its author.

        • data: SlackTemplateUpdateData
        • id: string

      Returns Promise<{ ok: true; value: SlackTemplate } | { error: UpdateError; ok: false }>