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

    Admin-tier CRUD over product_fee_rule. Accepts any rule type (admin-global, admin-for-customer, or customer).

    Identity / version split: product_fee_rule holds scope columns (routeId, customerId, type) plus a currentVersionId pointer; every mutable field (matcher, status, priority, fee values, label, description) lives on product_fee_rule_version and is append-only. Editing means inserting a new version row, merged onto the version in effect now, and re-pointing currentVersionId in one transaction.

    Duplicate-matcher detection is enforced by the partial unique index product_fee_rule_unique_tuple — see ProductActivationRuleAdminService for the rationale. matcherHash is denormalized onto the identity row; service code maintains identity.matcherHash = currentVersion.matcherHash on every version bump and translates the unique-violation back into DUPLICATE_MATCHER.

    Hierarchy

    Index
    • Parameters

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

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

        • valkeyClient: ValkeyClient | null

      Returns ProductFeeRuleAdminService

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

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

    • Parameters

      • input: {
            customerId?: string;
            description?: string;
            effectiveFrom?: Instant;
            fixedFeeAmount?: BigNumber;
            label?: string;
            matcher?: Matcher;
            priority: number;
            routeId: string;
            type?: "CUSTOMER" | "ADMIN";
            variableFeeBps?: BigNumber;
        }
        • OptionalcustomerId?: string
        • 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).

        • OptionalfixedFeeAmount?: BigNumber
        • Optionallabel?: string
        • Optionalmatcher?: Matcher
        • priority: number
        • routeId: string
        • Optionaltype?: "CUSTOMER" | "ADMIN"
        • OptionalvariableFeeBps?: BigNumber

      Returns Promise<
          | { ok: true; value: AdminProductFeeRule }
          | { error: ServiceError; 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;
            routeIds?: string[];
            statuses?: ("ACTIVE" | "DISABLED")[];
            types?: ("CUSTOMER" | "ADMIN")[];
            updatedAt?: DbTimestampCriteria<Instant>;
        }

      Returns Promise<
          {
              ok: true;
              value: { hasNext: boolean; items: AdminProductFeeRule[]; 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[]

    • Parameters

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

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