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

    Class ProductActivationRuleAdminService

    Admin-tier CRUD over product_activation_rule: any tier on a route, and ADMIN DENY-only cross-route rules. The scope is fixed at create; see docs/PRODUCT_SERVICES.md § Cross-route activation rules.

    Hierarchy

    Index
    • Parameters

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

          Publishes product.activationRule.*; null publishes nothing (scripts, tests).

        • valkeyClient: ValkeyClient | null

      Returns ProductActivationRuleAdminService

    cache: ServiceCache<CachedSearchPage<AdminProductActivationRule>>
    db: B2bDatabase
    instance: (...args: []) => ProductActivationRuleAdminService = ...

    The process default: built from each dependency's own instance().

    • Parameters

      • input: {
            customerId?: string;
            description?: string;
            effectiveFrom?: Instant;
            label?: string;
            matcher?: Matcher | undefined;
            priority: number;
            type?: "CUSTOMER" | "ADMIN";
            value: "APPROVE" | "DENY";
        } & ActivationRuleScopeInput
        • OptionalcustomerId?: string

          External id; required when type='CUSTOMER'. On a cross-route rule it is a scope column: the rule applies to this customer only.

        • Optionaldescription?: string
        • OptionaleffectiveFrom?: Instant

          When this version becomes effective. Defaults to now() at the DB layer when omitted. Pass a future Temporal.Instant to schedule a change (e.g. Reg E 30-day notice).

        • Optionallabel?: string
        • Optionalmatcher?: Matcher | undefined
        • priority: number
        • Optionaltype?: "CUSTOMER" | "ADMIN"
        • value: "APPROVE" | "DENY"

      Returns Promise<
          | { ok: true; value: AdminProductActivationRule }
          | { error: CreateError; ok: false },
      >

    • Clear each customer's membership tag and each record tag wherever cached, and always this namespace's collection tag. keys are exact deletes in this instance's key space: the only bust a null client honours.

      Parameters

      • __namedParameters: {
            customerIds: readonly string[];
            keys?: readonly CacheKey[];
            records?: readonly string[];
        }

      Returns Promise<void>

    • Parameters

      • input: {
            createdAt?: DbTimestampCriteria<Instant>;
            customerIds?: string[];
            ids?: string[];
            orderBy?: RuleOrderByCriterion[];
            page?: number;
            pageSize?: number;
            productCategories?: ProductCategory[];
            productIds?: string[];
            routeIds?: string[];
            scopes?: ("ROUTE" | "CROSS_ROUTE")[];
            statuses?: ("ACTIVE" | "DISABLED")[];
            types?: ("CUSTOMER" | "ADMIN")[];
            updatedAt?: DbTimestampCriteria<Instant>;
            vendorIds?: Vendor[];
        }
        • OptionalcreatedAt?: DbTimestampCriteria<Instant>
        • OptionalcustomerIds?: string[]
        • Optionalids?: string[]
        • OptionalorderBy?: RuleOrderByCriterion[]
        • Optionalpage?: number
        • OptionalpageSize?: number
        • OptionalproductCategories?: ProductCategory[]

          Matches cross-route rules scoped to these categories.

        • OptionalproductIds?: string[]

          A route rule's route product, or a cross-route rule's scope product.

        • OptionalrouteIds?: string[]

          Matches route rules only.

        • Optionalscopes?: ("ROUTE" | "CROSS_ROUTE")[]

          ROUTE rules have a route; CROSS_ROUTE rules do not.

        • Optionalstatuses?: ("ACTIVE" | "DISABLED")[]
        • Optionaltypes?: ("CUSTOMER" | "ADMIN")[]
        • OptionalupdatedAt?: DbTimestampCriteria<Instant>
        • OptionalvendorIds?: Vendor[]

          A route rule's route vendor, or a cross-route rule's scope vendor.

      Returns Promise<
          {
              ok: true;
              value: {
                  hasNext: boolean;
                  items: AdminProductActivationRule[];
                  total: number;
              };
          },
      >

    • Tags for a page: the scope its query searched (each customer's membership tag, else the collection tag), so an empty page is bustable too, plus the records it projects and the fields that chose or ordered its rows.

      Parameters

      • __namedParameters: {
            customerIds: readonly string[] | undefined;
            fields?: readonly string[];
            records?: readonly string[];
        }

      Returns string[]

    • The rule's scope (route, or category / vendor / product / customer) is fixed at create; a cross-route rule stays DENY.

      Parameters

      • input: {
            data: {
                description?: string | null;
                effectiveFrom?: Instant;
                label?: string | null;
                matcher?: Matcher;
                priority?: number;
                status?: "ACTIVE" | "DISABLED";
                value?: "APPROVE" | "DENY";
            };
            id: string;
        }

      Returns Promise<
          | { ok: true; value: AdminProductActivationRule }
          | { error: ServiceError; ok: false },
      >