MCPcopy Index your code
hub / github.com/simstudioai/sim / evaluate

Function evaluate

apps/sim/lib/core/config/feature-flags.ts:182–195  ·  view source on GitHub ↗

* The admin clause is resolved last and lazily: a global/userId/orgId match * short-circuits before any DB read, a rule without `admins` never queries, and a * missing `userId` resolves to `false` without a query.

(
  rule: FeatureFlagRule | undefined,
  ctx: FeatureFlagContext
)

Source from the content-addressed store, hash-verified

180 * missing `userId` resolves to `false` without a query.
181 */
182async function evaluate(
183 rule: FeatureFlagRule | undefined,
184 ctx: FeatureFlagContext
185): Promise<boolean> {
186 if (!rule) return false
187 if (rule.enabled) return true
188 if (ctx.userId && rule.userIds?.includes(ctx.userId)) return true
189 if (ctx.orgId && rule.orgIds?.includes(ctx.orgId)) return true
190 if (rule.adminEnabled) {
191 const admin = ctx.isAdmin ?? (ctx.userId ? await resolveAdmin(ctx.userId) : false)
192 if (admin) return true
193 }
194 return false
195}
196
197/**
198 * Resolve the full flag document. Reads from AWS AppConfig on hosted deployments

Callers 1

isFeatureEnabledFunction · 0.85

Calls 1

resolveAdminFunction · 0.85

Tested by

no test coverage detected