FlagsCore
Defined in: core.ts:214
The admin core surface.
Properties
Section titled “Properties”| Property | Modifier | Type | Defined in |
|---|---|---|---|
options |
readonly |
Required<Omit<FlagsCoreOptions, | "runtimeStorage" | "comparators" | "matchers" | "hooks" | "onHookError" | "retention">> & object |
core.ts:215 |
Methods
Section titled “Methods”archiveFlag()
Section titled “archiveFlag()”archiveFlag( flagKey, projectKey?, environmentKey?): Promise<Flag>;Defined in: core.ts:252
Archive a flag: stamp Flag.archivedAt so it is excluded from the next compiled snapshot (leaves SDK payloads) while remaining in the draft for restore. Throws NotFoundError if the flag does not exist.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
flagKey |
string |
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<Flag>
createEnvironment()
Section titled “createEnvironment()”createEnvironment(projectKey, input): Promise<EnvironmentMeta>;Defined in: core.ts:236
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
projectKey |
string |
input |
{ key: string; name?: string; } |
input.key |
string |
input.name? |
string |
Returns
Section titled “Returns”Promise<EnvironmentMeta>
createProject()
Section titled “createProject()”createProject(input): Promise<ProjectMeta>;Defined in: core.ts:231
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
{ key: string; name?: string; } |
input.key |
string |
input.name? |
string |
Returns
Section titled “Returns”Promise<ProjectMeta>
deleteFlag()
Section titled “deleteFlag()”deleteFlag( flagKey, projectKey?, environmentKey?): Promise<void>;Defined in: core.ts:246
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
flagKey |
string |
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<void>
deleteSegment()
Section titled “deleteSegment()”deleteSegment( segmentKey, projectKey?, environmentKey?): Promise<void>;Defined in: core.ts:264
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
segmentKey |
string |
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<void>
deleteSnapshot()
Section titled “deleteSnapshot()”deleteSnapshot(input): Promise<void>;Defined in: core.ts:310
Delete a snapshot’s payload from both source and runtime storage.
Guarded: the active and the latest versions throw
SnapshotProtectedError (protecting the runtime, and preventing
nextVersion from reusing a deleted version number). Appends an
action: "delete" audit entry — the payload is removed, the fact remains.
Vetoable via a before hook (snapshot.delete); the after event
(snapshot.deleted) carries the full snapshot for offloading.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
{ by?: Actor | null; environmentKey?: string; projectKey?: string; version: string; } |
input.by? |
Actor | null |
input.environmentKey? |
string |
input.projectKey? |
string |
input.version |
string |
Returns
Section titled “Returns”Promise<void>
diffDraft()
Section titled “diffDraft()”diffDraft(projectKey?, environmentKey?): Promise<DraftDiff>;Defined in: core.ts:272
Field-level diff of the current draft (flags + segments) against the draft as
it was at the last publish — i.e. the unpublished changes. changed is false
when there is nothing to publish.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<DraftDiff>
discardDraft()
Section titled “discardDraft()”discardDraft(projectKey?, environmentKey?): Promise<Draft>;Defined in: core.ts:274
Discard all unpublished changes: reset the draft to the last-published state.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<Draft>
evaluate()
Section titled “evaluate()”evaluate(input): Promise<FlagEvaluationResult[]>;Defined in: core.ts:341
Evaluate flags against a context (test targeting) using the draft or active snapshot.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
EvaluateInput |
Returns
Section titled “Returns”Promise<FlagEvaluationResult[]>
Example
Section titled “Example”const results = await core.evaluate({ context: { targetingKey: "user-123", plan: "pro" }, source: "draft",});for (const r of results) { console.log(r.key, r.value, r.reason);}getActiveSnapshot()
Section titled “getActiveSnapshot()”getActiveSnapshot(projectKey?, environmentKey?): Promise<Snapshot | null>;Defined in: core.ts:323
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<Snapshot | null>
getActiveVersion()
Section titled “getActiveVersion()”getActiveVersion(projectKey?, environmentKey?): Promise<string | null>;Defined in: core.ts:324
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<string | null>
getDraft()
Section titled “getDraft()”getDraft(projectKey?, environmentKey?): Promise<Draft>;Defined in: core.ts:242
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<Draft>
getFlag()
Section titled “getFlag()”getFlag( flagKey, projectKey?, environmentKey?): Promise<Flag | null>;Defined in: core.ts:244
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
flagKey |
string |
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<Flag | null>
getProject()
Section titled “getProject()”getProject(projectKey): Promise< | ProjectMeta| null>;Defined in: core.ts:232
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
projectKey |
string |
Returns
Section titled “Returns”Promise<
| ProjectMeta
| null>
getSegment()
Section titled “getSegment()”getSegment( segmentKey, projectKey?, environmentKey?): Promise<Segment | null>;Defined in: core.ts:258
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
segmentKey |
string |
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<Segment | null>
getSnapshot()
Section titled “getSnapshot()”getSnapshot( version, projectKey?, environmentKey?): Promise<Snapshot | null>;Defined in: core.ts:318
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
version |
string |
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<Snapshot | null>
importDraft()
Section titled “importDraft()”importDraft( input, projectKey?, environmentKey?): Promise<Draft>;Defined in: core.ts:281
Replace the draft from an imported document ({ flags, segments? }, e.g. a
downloaded snapshot). Validates flags + segments (and references) before
writing; throws DraftValidationError on invalid input. Does not
publish — the caller reviews the resulting draft diff and publishes.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
{ flags: Record<string, Flag>; segments?: Record<string, Segment>; } |
input.flags |
Record<string, Flag> |
input.segments? |
Record<string, Segment> |
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<Draft>
listAudit()
Section titled “listAudit()”listAudit(projectKey?, environmentKey?): Promise<AuditEntry[]>;Defined in: core.ts:325
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<AuditEntry[]>
listEnvironments()
Section titled “listEnvironments()”listEnvironments(projectKey): Promise<EnvironmentMeta[]>;Defined in: core.ts:235
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
projectKey |
string |
Returns
Section titled “Returns”Promise<EnvironmentMeta[]>
listFlags()
Section titled “listFlags()”listFlags(projectKey?, environmentKey?): Promise<Flag[]>;Defined in: core.ts:243
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<Flag[]>
listProjects()
Section titled “listProjects()”listProjects(): Promise<ProjectMeta[]>;Defined in: core.ts:230
Returns
Section titled “Returns”Promise<ProjectMeta[]>
listSegments()
Section titled “listSegments()”listSegments(projectKey?, environmentKey?): Promise<Segment[]>;Defined in: core.ts:257
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<Segment[]>
listSnapshots()
Section titled “listSnapshots()”listSnapshots(projectKey?, environmentKey?): Promise<string[]>;Defined in: core.ts:316
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<string[]>
listSnapshotSummaries()
Section titled “listSnapshotSummaries()”listSnapshotSummaries(projectKey?, environmentKey?): Promise<SnapshotSummary[]>;Defined in: core.ts:317
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<SnapshotSummary[]>
publish()
Section titled “publish()”publish(input?): Promise<Snapshot>;Defined in: core.ts:288
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input? |
{ by?: Actor | null; environmentKey?: string; message?: string; projectKey?: string; } |
input.by? |
Actor | null |
input.environmentKey? |
string |
input.message? |
string |
input.projectKey? |
string |
Returns
Section titled “Returns”Promise<Snapshot>
replaceDraft()
Section titled “replaceDraft()”replaceDraft(draft): Promise<Draft>;Defined in: core.ts:265
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
draft |
Draft |
Returns
Section titled “Returns”Promise<Draft>
restoreFlag()
Section titled “restoreFlag()”restoreFlag( flagKey, projectKey?, environmentKey?): Promise<Flag>;Defined in: core.ts:254
Restore an archived flag by clearing Flag.archivedAt.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
flagKey |
string |
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<Flag>
rollback()
Section titled “rollback()”rollback(input): Promise<Snapshot>;Defined in: core.ts:294
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
{ by?: Actor | null; environmentKey?: string; message?: string; projectKey?: string; version: string; } |
input.by? |
Actor | null |
input.environmentKey? |
string |
input.message? |
string |
input.projectKey? |
string |
input.version |
string |
Returns
Section titled “Returns”Promise<Snapshot>
upsertFlag()
Section titled “upsertFlag()”upsertFlag( flag, projectKey?, environmentKey?): Promise<Flag>;Defined in: core.ts:245
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
flag |
Flag |
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<Flag>
upsertSegment()
Section titled “upsertSegment()”upsertSegment( segment, projectKey?, environmentKey?): Promise<Segment>;Defined in: core.ts:263
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
segment |
Segment |
projectKey? |
string |
environmentKey? |
string |
Returns
Section titled “Returns”Promise<Segment>