@timeax/digital-service-engine 0.2.8 → 0.3.0

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.
@@ -790,6 +790,14 @@ type FilterServicesForVisibleGroupInput = {
790
790
  fallback?: FallbackSettings;
791
791
  strictSafety?: boolean;
792
792
  enforcePolicies?: boolean;
793
+ rateContext?: {
794
+ mode: "context";
795
+ } | {
796
+ mode: "custom_primary_rate";
797
+ source: "manual" | "service";
798
+ primaryRate?: number;
799
+ primaryServiceId?: ServiceIdRef;
800
+ };
793
801
  };
794
802
  };
795
803
  type FilterServicesForVisibleGroupResult = {
@@ -790,6 +790,14 @@ type FilterServicesForVisibleGroupInput = {
790
790
  fallback?: FallbackSettings;
791
791
  strictSafety?: boolean;
792
792
  enforcePolicies?: boolean;
793
+ rateContext?: {
794
+ mode: "context";
795
+ } | {
796
+ mode: "custom_primary_rate";
797
+ source: "manual" | "service";
798
+ primaryRate?: number;
799
+ primaryServiceId?: ServiceIdRef;
800
+ };
793
801
  };
794
802
  };
795
803
  type FilterServicesForVisibleGroupResult = {
@@ -4271,6 +4271,10 @@ function filterServicesForVisibleGroup(input, deps) {
4271
4271
  (_h = (_g = context.ratePolicy) != null ? _g : explicitFallbackSettings == null ? void 0 : explicitFallbackSettings.ratePolicy) != null ? _h : builderOptions == null ? void 0 : builderOptions.ratePolicy
4272
4272
  );
4273
4273
  const policySource = (_j = (_i = context.policies) != null ? _i : builderOptions == null ? void 0 : builderOptions.policies) != null ? _j : [];
4274
+ const resolvedCustomPrimaryRate = resolveCustomPrimaryRate(
4275
+ context.rateContext,
4276
+ svcMap
4277
+ );
4274
4278
  const visibleServiceIds = context.selectedButtons === void 0 ? void 0 : collectVisibleServiceIds(
4275
4279
  deps.builder,
4276
4280
  context.tagId,
@@ -4297,7 +4301,11 @@ function filterServicesForVisibleGroup(input, deps) {
4297
4301
  cap.id,
4298
4302
  (_k = context.effectiveConstraints) != null ? _k : {}
4299
4303
  );
4300
- const passesRate2 = candidatePassesRateCoherence(
4304
+ const passesRate2 = resolvedCustomPrimaryRate != null ? passesRatePolicy(
4305
+ resolvedRatePolicy,
4306
+ resolvedCustomPrimaryRate,
4307
+ toFiniteNumber(cap.rate)
4308
+ ) : candidatePassesRateCoherence(
4301
4309
  deps.builder,
4302
4310
  svcMap,
4303
4311
  context.tagId,
@@ -4337,6 +4345,17 @@ function filterServicesForVisibleGroup(input, deps) {
4337
4345
  diagnostics: lastDiagnostics && lastDiagnostics.length ? lastDiagnostics : void 0
4338
4346
  };
4339
4347
  }
4348
+ function resolveCustomPrimaryRate(rateContext, serviceMap) {
4349
+ if (!rateContext || rateContext.mode !== "custom_primary_rate") {
4350
+ return void 0;
4351
+ }
4352
+ if (rateContext.source === "manual") {
4353
+ return toFiniteNumber(rateContext.primaryRate);
4354
+ }
4355
+ if (rateContext.primaryServiceId == null) return void 0;
4356
+ const cap = getServiceCapability(serviceMap, rateContext.primaryServiceId);
4357
+ return toFiniteNumber(cap == null ? void 0 : cap.rate);
4358
+ }
4340
4359
  function evaluatePoliciesRaw(raw, serviceIds, svcMap, tagId, visibleServiceIds) {
4341
4360
  const compiled = compilePolicies(raw);
4342
4361
  const evaluated = evaluateServicePolicies(