@timeax/digital-service-engine 0.2.1 → 0.2.3

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.
@@ -273,6 +273,7 @@ type FallbackEditorServiceRecord = {
273
273
  };
274
274
  type FallbackEditorServiceMap = DgpServiceMap;
275
275
  type FallbackRegistrationScope = "global" | "node";
276
+ type FallbackEligibleSource = "all_services" | "registered";
276
277
  type FallbackScopeRef = {
277
278
  scope: "global";
278
279
  primary: ServiceIdRef;
@@ -394,6 +395,16 @@ interface FallbackEditor {
394
395
  replace(context: FallbackScopeRef, candidates: ServiceIdRef[], options?: FallbackMutationOptions): FallbackEditorState;
395
396
  /** Clears one exact scope value */
396
397
  clear(context: FallbackScopeRef): FallbackEditorState;
398
+ /**
399
+ * Returns candidates eligible for the given scope.
400
+ * Defaults to discovery from the loaded services pool.
401
+ */
402
+ eligible(context: FallbackScopeRef, options?: {
403
+ exclude?: ServiceIdRef[];
404
+ unique?: boolean;
405
+ limit?: number;
406
+ source?: FallbackEligibleSource;
407
+ }): ServiceIdRef[];
397
408
  }
398
409
  declare function createFallbackEditor(options?: FallbackEditorOptions): FallbackEditor;
399
410
 
@@ -970,4 +981,4 @@ type EditorSnapshot = {
970
981
  /** Exported alias so the schema generator can target an array */
971
982
  type AdminPolicies = DynamicRule[];
972
983
 
973
- export { type AdminPolicies, type BaseFieldUI, type ButtonValue, type CanvasEvents, type CanvasOptions, type CanvasState, type CatalogGroupNode, type CatalogId, type CatalogNode, type CatalogNodeBase, type CatalogNodeKind, type CatalogServiceId, type CatalogSmartGroupNode, type CatalogSmartRule, type CatalogViewMode, type Command, type CommentAnchor, type CommentId, type CommentMessage, type CommentNode, type CommentThread, type ConnectKind, type ConstraintKey, type DgpServiceCapability, type DgpServiceMap, type DraftWire, type DynamicRule, type EdgeKind, type EdgeRoute, type EdgeView, type EditorEvents, type EditorOptions, type EditorSnapshot, type FallbackCandidateCheck, type FallbackCheckReason, type FallbackCheckResult, type FallbackDiagnostics, type FallbackEditor, type FallbackEditorOptions, type FallbackEditorServiceMap, type FallbackEditorServiceRecord, type FallbackEditorState, type FallbackMutationOptions, type FallbackRegistration, type FallbackRegistrationScope, type FallbackScopeRef, type FallbackSettings, type Field, type FieldOption, type FieldType, type FieldValidationOp, type FieldValidationRule, type FieldValidationValueBy, type FieldWithTypedDefaults, type FlagKey, type FlowNode, type GraphEdge, type GraphNode, type GraphSnapshot, type IdType, type LayoutState, type NodeIdRef, type NodeKind, type NodePos, type NodePositions, type NodeView, type NoticeKind, type NoticeSeverity, type NoticeTarget, type NoticeType, type OrderSnapshot, type PricingRole, type QuantityMark, type QuantityRule, type RatePolicy, type Scalar, type ServiceCatalogState, type ServiceEstimates, type ServiceFallback, type ServiceFallbacks, type ServiceFlag, type ServiceFlags, type ServiceIdRef, type ServiceProps, type ServicePropsNotice, type ServiceWhereClause, type ServiceWhereOp, type SnapshotContext, type SpeedEstimate, type Tag, type ThreadId, type TimeRangeEstimate, type Ui, type UiAnyOf, type UiArray, type UiBoolean, type UiNumber, type UiObject, type UiString, type UiValue, type UtilityLineItem, type UtilityMark, type UtilityMode, type ValidationCode, type ValidationError, type ValidatorOptions, type Viewport, type WithQuantityDefault, createFallbackEditor };
984
+ export { type AdminPolicies, type BaseFieldUI, type ButtonValue, type CanvasEvents, type CanvasOptions, type CanvasState, type CatalogGroupNode, type CatalogId, type CatalogNode, type CatalogNodeBase, type CatalogNodeKind, type CatalogServiceId, type CatalogSmartGroupNode, type CatalogSmartRule, type CatalogViewMode, type Command, type CommentAnchor, type CommentId, type CommentMessage, type CommentNode, type CommentThread, type ConnectKind, type ConstraintKey, type DgpServiceCapability, type DgpServiceMap, type DraftWire, type DynamicRule, type EdgeKind, type EdgeRoute, type EdgeView, type EditorEvents, type EditorOptions, type EditorSnapshot, type FallbackCandidateCheck, type FallbackCheckReason, type FallbackCheckResult, type FallbackDiagnostics, type FallbackEditor, type FallbackEditorOptions, type FallbackEditorServiceMap, type FallbackEditorServiceRecord, type FallbackEditorState, type FallbackEligibleSource, type FallbackMutationOptions, type FallbackRegistration, type FallbackRegistrationScope, type FallbackScopeRef, type FallbackSettings, type Field, type FieldOption, type FieldType, type FieldValidationOp, type FieldValidationRule, type FieldValidationValueBy, type FieldWithTypedDefaults, type FlagKey, type FlowNode, type GraphEdge, type GraphNode, type GraphSnapshot, type IdType, type LayoutState, type NodeIdRef, type NodeKind, type NodePos, type NodePositions, type NodeView, type NoticeKind, type NoticeSeverity, type NoticeTarget, type NoticeType, type OrderSnapshot, type PricingRole, type QuantityMark, type QuantityRule, type RatePolicy, type Scalar, type ServiceCatalogState, type ServiceEstimates, type ServiceFallback, type ServiceFallbacks, type ServiceFlag, type ServiceFlags, type ServiceIdRef, type ServiceProps, type ServicePropsNotice, type ServiceWhereClause, type ServiceWhereOp, type SnapshotContext, type SpeedEstimate, type Tag, type ThreadId, type TimeRangeEstimate, type Ui, type UiAnyOf, type UiArray, type UiBoolean, type UiNumber, type UiObject, type UiString, type UiValue, type UtilityLineItem, type UtilityMark, type UtilityMode, type ValidationCode, type ValidationError, type ValidatorOptions, type Viewport, type WithQuantityDefault, createFallbackEditor };
@@ -273,6 +273,7 @@ type FallbackEditorServiceRecord = {
273
273
  };
274
274
  type FallbackEditorServiceMap = DgpServiceMap;
275
275
  type FallbackRegistrationScope = "global" | "node";
276
+ type FallbackEligibleSource = "all_services" | "registered";
276
277
  type FallbackScopeRef = {
277
278
  scope: "global";
278
279
  primary: ServiceIdRef;
@@ -394,6 +395,16 @@ interface FallbackEditor {
394
395
  replace(context: FallbackScopeRef, candidates: ServiceIdRef[], options?: FallbackMutationOptions): FallbackEditorState;
395
396
  /** Clears one exact scope value */
396
397
  clear(context: FallbackScopeRef): FallbackEditorState;
398
+ /**
399
+ * Returns candidates eligible for the given scope.
400
+ * Defaults to discovery from the loaded services pool.
401
+ */
402
+ eligible(context: FallbackScopeRef, options?: {
403
+ exclude?: ServiceIdRef[];
404
+ unique?: boolean;
405
+ limit?: number;
406
+ source?: FallbackEligibleSource;
407
+ }): ServiceIdRef[];
397
408
  }
398
409
  declare function createFallbackEditor(options?: FallbackEditorOptions): FallbackEditor;
399
410
 
@@ -970,4 +981,4 @@ type EditorSnapshot = {
970
981
  /** Exported alias so the schema generator can target an array */
971
982
  type AdminPolicies = DynamicRule[];
972
983
 
973
- export { type AdminPolicies, type BaseFieldUI, type ButtonValue, type CanvasEvents, type CanvasOptions, type CanvasState, type CatalogGroupNode, type CatalogId, type CatalogNode, type CatalogNodeBase, type CatalogNodeKind, type CatalogServiceId, type CatalogSmartGroupNode, type CatalogSmartRule, type CatalogViewMode, type Command, type CommentAnchor, type CommentId, type CommentMessage, type CommentNode, type CommentThread, type ConnectKind, type ConstraintKey, type DgpServiceCapability, type DgpServiceMap, type DraftWire, type DynamicRule, type EdgeKind, type EdgeRoute, type EdgeView, type EditorEvents, type EditorOptions, type EditorSnapshot, type FallbackCandidateCheck, type FallbackCheckReason, type FallbackCheckResult, type FallbackDiagnostics, type FallbackEditor, type FallbackEditorOptions, type FallbackEditorServiceMap, type FallbackEditorServiceRecord, type FallbackEditorState, type FallbackMutationOptions, type FallbackRegistration, type FallbackRegistrationScope, type FallbackScopeRef, type FallbackSettings, type Field, type FieldOption, type FieldType, type FieldValidationOp, type FieldValidationRule, type FieldValidationValueBy, type FieldWithTypedDefaults, type FlagKey, type FlowNode, type GraphEdge, type GraphNode, type GraphSnapshot, type IdType, type LayoutState, type NodeIdRef, type NodeKind, type NodePos, type NodePositions, type NodeView, type NoticeKind, type NoticeSeverity, type NoticeTarget, type NoticeType, type OrderSnapshot, type PricingRole, type QuantityMark, type QuantityRule, type RatePolicy, type Scalar, type ServiceCatalogState, type ServiceEstimates, type ServiceFallback, type ServiceFallbacks, type ServiceFlag, type ServiceFlags, type ServiceIdRef, type ServiceProps, type ServicePropsNotice, type ServiceWhereClause, type ServiceWhereOp, type SnapshotContext, type SpeedEstimate, type Tag, type ThreadId, type TimeRangeEstimate, type Ui, type UiAnyOf, type UiArray, type UiBoolean, type UiNumber, type UiObject, type UiString, type UiValue, type UtilityLineItem, type UtilityMark, type UtilityMode, type ValidationCode, type ValidationError, type ValidatorOptions, type Viewport, type WithQuantityDefault, createFallbackEditor };
984
+ export { type AdminPolicies, type BaseFieldUI, type ButtonValue, type CanvasEvents, type CanvasOptions, type CanvasState, type CatalogGroupNode, type CatalogId, type CatalogNode, type CatalogNodeBase, type CatalogNodeKind, type CatalogServiceId, type CatalogSmartGroupNode, type CatalogSmartRule, type CatalogViewMode, type Command, type CommentAnchor, type CommentId, type CommentMessage, type CommentNode, type CommentThread, type ConnectKind, type ConstraintKey, type DgpServiceCapability, type DgpServiceMap, type DraftWire, type DynamicRule, type EdgeKind, type EdgeRoute, type EdgeView, type EditorEvents, type EditorOptions, type EditorSnapshot, type FallbackCandidateCheck, type FallbackCheckReason, type FallbackCheckResult, type FallbackDiagnostics, type FallbackEditor, type FallbackEditorOptions, type FallbackEditorServiceMap, type FallbackEditorServiceRecord, type FallbackEditorState, type FallbackEligibleSource, type FallbackMutationOptions, type FallbackRegistration, type FallbackRegistrationScope, type FallbackScopeRef, type FallbackSettings, type Field, type FieldOption, type FieldType, type FieldValidationOp, type FieldValidationRule, type FieldValidationValueBy, type FieldWithTypedDefaults, type FlagKey, type FlowNode, type GraphEdge, type GraphNode, type GraphSnapshot, type IdType, type LayoutState, type NodeIdRef, type NodeKind, type NodePos, type NodePositions, type NodeView, type NoticeKind, type NoticeSeverity, type NoticeTarget, type NoticeType, type OrderSnapshot, type PricingRole, type QuantityMark, type QuantityRule, type RatePolicy, type Scalar, type ServiceCatalogState, type ServiceEstimates, type ServiceFallback, type ServiceFallbacks, type ServiceFlag, type ServiceFlags, type ServiceIdRef, type ServiceProps, type ServicePropsNotice, type ServiceWhereClause, type ServiceWhereOp, type SnapshotContext, type SpeedEstimate, type Tag, type ThreadId, type TimeRangeEstimate, type Ui, type UiAnyOf, type UiArray, type UiBoolean, type UiNumber, type UiObject, type UiString, type UiValue, type UtilityLineItem, type UtilityMark, type UtilityMode, type ValidationCode, type ValidationError, type ValidatorOptions, type Viewport, type WithQuantityDefault, createFallbackEditor };
@@ -4706,6 +4706,9 @@ function toFiniteNumber(v) {
4706
4706
  const n = Number(v);
4707
4707
  return Number.isFinite(n) ? n : NaN;
4708
4708
  }
4709
+ function isValidServiceIdRef(value) {
4710
+ return typeof value === "number" && Number.isFinite(value) || typeof value === "string" && value.trim().length > 0;
4711
+ }
4709
4712
  function constraintFitOk(svcMap, candidate, constraints) {
4710
4713
  const cap = getServiceCapability(svcMap, candidate);
4711
4714
  if (!cap) return false;
@@ -4714,18 +4717,27 @@ function constraintFitOk(svcMap, candidate, constraints) {
4714
4717
  return !(constraints.cancel === true && !cap.cancel);
4715
4718
  }
4716
4719
  function getServiceCapability(svcMap, candidate) {
4717
- if (candidate === void 0 || candidate === null) return void 0;
4718
- const direct = svcMap[candidate];
4719
- if (direct) return direct;
4720
- const byString = svcMap[String(candidate)];
4721
- if (byString) return byString;
4722
- if (typeof candidate === "string") {
4723
- const maybeNumber = Number(candidate);
4724
- if (Number.isFinite(maybeNumber)) {
4725
- return svcMap[maybeNumber];
4726
- }
4720
+ var _a;
4721
+ return (_a = getServiceCapabilityEntry(svcMap, candidate)) == null ? void 0 : _a.capability;
4722
+ }
4723
+ function getServiceCapabilityAliases(svcMap, candidate) {
4724
+ const entry = getServiceCapabilityEntry(svcMap, candidate);
4725
+ if (!entry) return [];
4726
+ return collectServiceRefAliases(entry.key, entry.capability);
4727
+ }
4728
+ function isSameServiceCapabilityRef(svcMap, left, right) {
4729
+ if (!isValidServiceIdRef(left) || !isValidServiceIdRef(right)) return false;
4730
+ const leftAliases = new Set(
4731
+ getServiceCapabilityAliases(svcMap, left).map((value) => String(value))
4732
+ );
4733
+ if (!leftAliases.size) {
4734
+ leftAliases.add(String(left));
4727
4735
  }
4728
- return void 0;
4736
+ const rightAliases = getServiceCapabilityAliases(svcMap, right);
4737
+ if (!rightAliases.length) {
4738
+ return leftAliases.has(String(right));
4739
+ }
4740
+ return rightAliases.some((value) => leftAliases.has(String(value)));
4729
4741
  }
4730
4742
  function normalizeRatePolicy(policy) {
4731
4743
  var _a;
@@ -4761,6 +4773,74 @@ function rateOk(svcMap, candidate, primary, policy) {
4761
4773
  if (!Number.isFinite(cRate) || !Number.isFinite(pRate)) return false;
4762
4774
  return passesRatePolicy(policy.ratePolicy, pRate, cRate);
4763
4775
  }
4776
+ function getServiceCapabilityEntry(svcMap, candidate) {
4777
+ if (candidate === void 0 || candidate === null) return void 0;
4778
+ const direct = svcMap[candidate];
4779
+ if (direct) {
4780
+ return { key: String(candidate), capability: direct };
4781
+ }
4782
+ const byString = svcMap[String(candidate)];
4783
+ if (byString) {
4784
+ return { key: String(candidate), capability: byString };
4785
+ }
4786
+ if (typeof candidate === "string") {
4787
+ const maybeNumber = Number(candidate);
4788
+ if (Number.isFinite(maybeNumber)) {
4789
+ const byNumber = svcMap[maybeNumber];
4790
+ if (byNumber) {
4791
+ return { key: String(maybeNumber), capability: byNumber };
4792
+ }
4793
+ }
4794
+ }
4795
+ const target = String(candidate);
4796
+ for (const [key, capability] of Object.entries(svcMap != null ? svcMap : {})) {
4797
+ if (collectServiceRefAliases(key, capability).some(
4798
+ (alias) => String(alias) === target
4799
+ )) {
4800
+ return { key, capability };
4801
+ }
4802
+ }
4803
+ return void 0;
4804
+ }
4805
+ function collectServiceRefAliases(key, capability) {
4806
+ const out = [];
4807
+ const seen = /* @__PURE__ */ new Set();
4808
+ const push = (value) => {
4809
+ if (!isValidServiceIdRef(value)) return;
4810
+ const normalized = normalizeServiceRef(value);
4811
+ if (!normalized) return;
4812
+ const aliasKey = String(normalized);
4813
+ if (seen.has(aliasKey)) return;
4814
+ seen.add(aliasKey);
4815
+ out.push(normalized);
4816
+ };
4817
+ push(getCanonicalServiceRef(key, capability));
4818
+ push(capability.service);
4819
+ push(capability.key);
4820
+ push(capability.id);
4821
+ return out;
4822
+ }
4823
+ function getCanonicalServiceRef(key, capability) {
4824
+ const explicitRefs = [capability.service, capability.key, capability.id];
4825
+ for (const ref of explicitRefs) {
4826
+ if (!isValidServiceIdRef(ref)) continue;
4827
+ if (String(ref) === key) {
4828
+ return ref;
4829
+ }
4830
+ }
4831
+ return normalizeServiceRef(key);
4832
+ }
4833
+ function normalizeServiceRef(value) {
4834
+ if (!isValidServiceIdRef(value)) return void 0;
4835
+ if (typeof value === "number") return value;
4836
+ const trimmed = value.trim();
4837
+ if (!trimmed) return void 0;
4838
+ const asNumber = Number(trimmed);
4839
+ if (Number.isFinite(asNumber) && String(asNumber) === trimmed) {
4840
+ return asNumber;
4841
+ }
4842
+ return trimmed;
4843
+ }
4764
4844
 
4765
4845
  // src/core/validate/steps/rates.ts
4766
4846
  function validateRates(v) {
@@ -6206,7 +6286,7 @@ function collectFailedFallbacks(props, services, settings) {
6206
6286
  const s = { ...DEFAULT_SETTINGS, ...settings != null ? settings : {} };
6207
6287
  const out = [];
6208
6288
  const fb = (_a = props.fallbacks) != null ? _a : {};
6209
- const primaryRate = (p) => rateOf(services, p);
6289
+ const primaryRate = (primary) => rateOf(services, primary);
6210
6290
  for (const [nodeId, list] of Object.entries((_b = fb.nodes) != null ? _b : {})) {
6211
6291
  const { primary, tagContexts } = primaryForNode(props, nodeId);
6212
6292
  if (!primary) {
@@ -6219,34 +6299,34 @@ function collectFailedFallbacks(props, services, settings) {
6219
6299
  });
6220
6300
  continue;
6221
6301
  }
6222
- for (const cand of list) {
6223
- const cap = getCap(services, cand);
6224
- if (!cap) {
6302
+ for (const candidate of list) {
6303
+ const capability = getCap(services, candidate);
6304
+ if (!capability) {
6225
6305
  out.push({
6226
6306
  scope: "node",
6227
6307
  nodeId,
6228
6308
  primary,
6229
- candidate: cand,
6309
+ candidate,
6230
6310
  reason: "unknown_service"
6231
6311
  });
6232
6312
  continue;
6233
6313
  }
6234
- if (String(cand) === String(primary)) {
6314
+ if (isSameServiceCapabilityRef(services, candidate, primary)) {
6235
6315
  out.push({
6236
6316
  scope: "node",
6237
6317
  nodeId,
6238
6318
  primary,
6239
- candidate: cand,
6319
+ candidate,
6240
6320
  reason: "cycle"
6241
6321
  });
6242
6322
  continue;
6243
6323
  }
6244
- if (!passesRate(s.ratePolicy, primaryRate(primary), cap.rate)) {
6324
+ if (!passesRate(s.ratePolicy, primaryRate(primary), capability.rate)) {
6245
6325
  out.push({
6246
6326
  scope: "node",
6247
6327
  nodeId,
6248
6328
  primary,
6249
- candidate: cand,
6329
+ candidate,
6250
6330
  reason: "rate_violation"
6251
6331
  });
6252
6332
  continue;
@@ -6256,58 +6336,55 @@ function collectFailedFallbacks(props, services, settings) {
6256
6336
  scope: "node",
6257
6337
  nodeId,
6258
6338
  primary,
6259
- candidate: cand,
6339
+ candidate,
6260
6340
  reason: "no_tag_context"
6261
6341
  });
6262
6342
  continue;
6263
6343
  }
6264
- let anyPass = false;
6265
- let anyFail = false;
6266
6344
  for (const tagId of tagContexts) {
6267
- const ok2 = s.requireConstraintFit ? satisfiesTagConstraints(tagId, { services, props }, cap) : true;
6268
- if (ok2) anyPass = true;
6269
- else {
6270
- anyFail = true;
6271
- out.push({
6272
- scope: "node",
6273
- nodeId,
6274
- primary,
6275
- candidate: cand,
6276
- tagContext: tagId,
6277
- reason: "constraint_mismatch"
6278
- });
6279
- }
6345
+ const fitsConstraints = s.requireConstraintFit ? satisfiesTagConstraints(
6346
+ tagId,
6347
+ { services, props },
6348
+ capability
6349
+ ) : true;
6350
+ if (fitsConstraints) continue;
6351
+ out.push({
6352
+ scope: "node",
6353
+ nodeId,
6354
+ primary,
6355
+ candidate,
6356
+ tagContext: tagId,
6357
+ reason: "constraint_mismatch"
6358
+ });
6280
6359
  }
6281
- void anyPass;
6282
- void anyFail;
6283
6360
  }
6284
6361
  }
6285
6362
  for (const [primary, list] of Object.entries((_c = fb.global) != null ? _c : {})) {
6286
- for (const cand of list) {
6287
- const cap = getCap(services, cand);
6288
- if (!cap) {
6363
+ for (const candidate of list) {
6364
+ const capability = getCap(services, candidate);
6365
+ if (!capability) {
6289
6366
  out.push({
6290
6367
  scope: "global",
6291
6368
  primary,
6292
- candidate: cand,
6369
+ candidate,
6293
6370
  reason: "unknown_service"
6294
6371
  });
6295
6372
  continue;
6296
6373
  }
6297
- if (String(cand) === String(primary)) {
6374
+ if (isSameServiceCapabilityRef(services, candidate, primary)) {
6298
6375
  out.push({
6299
6376
  scope: "global",
6300
6377
  primary,
6301
- candidate: cand,
6378
+ candidate,
6302
6379
  reason: "cycle"
6303
6380
  });
6304
6381
  continue;
6305
6382
  }
6306
- if (!passesRate(s.ratePolicy, primaryRate(primary), cap.rate)) {
6383
+ if (!passesRate(s.ratePolicy, primaryRate(primary), capability.rate)) {
6307
6384
  out.push({
6308
6385
  scope: "global",
6309
6386
  primary,
6310
- candidate: cand,
6387
+ candidate,
6311
6388
  reason: "rate_violation"
6312
6389
  });
6313
6390
  }
@@ -6316,52 +6393,61 @@ function collectFailedFallbacks(props, services, settings) {
6316
6393
  return out;
6317
6394
  }
6318
6395
  function rateOf(map, id) {
6319
- var _a;
6396
+ var _a, _b;
6320
6397
  if (id === void 0 || id === null) return void 0;
6321
- const c = getCap(map, id);
6322
- return (_a = c == null ? void 0 : c.rate) != null ? _a : void 0;
6398
+ return (_b = (_a = getCap(map, id)) == null ? void 0 : _a.rate) != null ? _b : void 0;
6323
6399
  }
6324
- function passesRate(policy, primaryRate, candRate) {
6325
- if (typeof candRate !== "number" || !Number.isFinite(candRate))
6400
+ function passesRate(policy, primaryRate, candidateRate) {
6401
+ if (typeof candidateRate !== "number" || !Number.isFinite(candidateRate)) {
6326
6402
  return false;
6327
- if (typeof primaryRate !== "number" || !Number.isFinite(primaryRate))
6403
+ }
6404
+ if (typeof primaryRate !== "number" || !Number.isFinite(primaryRate)) {
6328
6405
  return false;
6329
- return passesRatePolicy(normalizeRatePolicy(policy), primaryRate, candRate);
6406
+ }
6407
+ return passesRatePolicy(
6408
+ normalizeRatePolicy(policy),
6409
+ primaryRate,
6410
+ candidateRate
6411
+ );
6330
6412
  }
6331
6413
  function getCap(map, id) {
6332
6414
  return getServiceCapability(map, id);
6333
6415
  }
6334
- function isCapFlagEnabled(cap, flagId) {
6416
+ function isCapFlagEnabled(capability, flagId) {
6335
6417
  var _a, _b;
6336
- const fromFlags = (_b = (_a = cap.flags) == null ? void 0 : _a[flagId]) == null ? void 0 : _b.enabled;
6418
+ const fromFlags = (_b = (_a = capability.flags) == null ? void 0 : _a[flagId]) == null ? void 0 : _b.enabled;
6337
6419
  if (fromFlags === true) return true;
6338
6420
  if (fromFlags === false) return false;
6339
- const legacy = cap[flagId];
6421
+ const legacy = capability[flagId];
6340
6422
  return legacy === true;
6341
6423
  }
6342
- function satisfiesTagConstraints(tagId, ctx, cap) {
6343
- const tag = ctx.props.filters.find((t) => t.id === tagId);
6344
- const eff = tag == null ? void 0 : tag.constraints;
6345
- if (!eff) return true;
6346
- for (const [key, value] of Object.entries(eff)) {
6347
- if (value === true && !isCapFlagEnabled(cap, key)) {
6424
+ function satisfiesTagConstraints(tagId, ctx, capability) {
6425
+ const tag = ctx.props.filters.find((item) => item.id === tagId);
6426
+ const effectiveConstraints2 = tag == null ? void 0 : tag.constraints;
6427
+ if (!effectiveConstraints2) return true;
6428
+ for (const [key, value] of Object.entries(effectiveConstraints2)) {
6429
+ if (value === true && !isCapFlagEnabled(capability, key)) {
6348
6430
  return false;
6349
6431
  }
6350
6432
  }
6351
6433
  return true;
6352
6434
  }
6353
6435
  function primaryForNode(props, nodeId) {
6354
- const tag = props.filters.find((t) => t.id === nodeId);
6436
+ const tag = props.filters.find((item) => item.id === nodeId);
6355
6437
  if (tag) {
6356
6438
  return { primary: tag.service_id, tagContexts: [tag.id] };
6357
6439
  }
6358
6440
  const field = props.fields.find(
6359
- (f) => Array.isArray(f.options) && f.options.some((o) => o.id === nodeId)
6441
+ (item) => Array.isArray(item.options) && item.options.some((option2) => option2.id === nodeId)
6360
6442
  );
6361
- if (!field) return { tagContexts: [], reasonNoPrimary: "no_parent_field" };
6362
- const opt = field.options.find((o) => o.id === nodeId);
6363
- const contexts = bindIdsToArray(field.bind_id);
6364
- return { primary: opt.service_id, tagContexts: contexts };
6443
+ if (!field) {
6444
+ return { tagContexts: [], reasonNoPrimary: "no_parent_field" };
6445
+ }
6446
+ const option = field.options.find((item) => item.id === nodeId);
6447
+ return {
6448
+ primary: option.service_id,
6449
+ tagContexts: bindIdsToArray(field.bind_id)
6450
+ };
6365
6451
  }
6366
6452
  function bindIdsToArray(bind) {
6367
6453
  if (!bind) return [];