OSS-first docs
These docs teach the open system first: contracts, generated surfaces, runtimes, governance, and incremental adoption. Studio shows up as the operating layer on top, not as the source of truth.
Create a targeting rule for a flag.
Goal
Add conditional targeting to a flag.
Context
Called when setting up targeting.
Source Definition
import { defineCommand, defineQuery } from '@lssm-tech/lib.contracts-spec';
import { defineSchemaModel, ScalarTypeEnum } from '@lssm-tech/lib.schema';
export const CreateRuleContract = defineCommand({
meta: {
key: 'flag.rule.create',
version: '1.0.0',
stability: 'stable',
owners: ['platform.feature-flags'],
tags: ['feature-flags', 'rule', 'create'],
description: 'Create a targeting rule for a flag.',
goal: 'Add conditional targeting to a flag.',
context: 'Called when setting up targeting.',
},
io: {
input: CreateRuleInput,
output: TargetingRuleModel,
errors: {
FLAG_NOT_FOUND: {
description: 'Flag does not exist',
http: 404,
gqlCode: 'FLAG_NOT_FOUND',
when: 'Flag ID is invalid',
},
INVALID_OPERATOR: {
description: 'Invalid operator',
http: 400,
gqlCode: 'INVALID_OPERATOR',
when: 'Operator is not supported',
},
},
},
policy: {
auth: 'admin',
},
});