diff --git a/.changeset/management-sdk-pinned-spec.md b/.changeset/management-sdk-pinned-spec.md new file mode 100644 index 000000000..bd47b9aad --- /dev/null +++ b/.changeset/management-sdk-pinned-spec.md @@ -0,0 +1,5 @@ +--- +"@reflag/management-sdk": minor +--- + +Update the client to the current Management API. Flags now include `flagType` (`boolean` or `multivariate`), and `createFlag` accepts it; flags are Boolean by default. Flag targeting now includes `targetingMode` and `effectiveRules`, the compiled rules that decide whether the flag is on. diff --git a/.gitignore b/.gitignore index c1ebb6abd..87cf6408b 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,6 @@ junit.xml .next reflag.config.json + +# Generator input prepared from openapi.json by scripts/prepare-spec.mjs +packages/management-sdk/.openapi.generated.json diff --git a/.oxfmtrc.json b/.oxfmtrc.json index 5ad80bb63..afb590a92 100644 --- a/.oxfmtrc.json +++ b/.oxfmtrc.json @@ -9,6 +9,7 @@ "coverage/**", "playwright-report/**", "test-results/**", + "packages/management-sdk/openapi.json", "packages/management-sdk/src/generated/**", "packages/node-sdk/examples/cloudflare-worker/worker-configuration.d.ts" ], diff --git a/packages/management-sdk/README.md b/packages/management-sdk/README.md index 3fde4c1f1..59e238102 100644 --- a/packages/management-sdk/README.md +++ b/packages/management-sdk/README.md @@ -131,7 +131,7 @@ console.log(flags.data); `createFlag` and `updateFlag` return the latest flag details together with `flagStateVersions`, keyed by environment ID. -Use `null` to clear nullable fields like `description` or `ownerUserId` on update. +Flags are Boolean unless you pass `flagType: "multivariate"`. Use `null` to clear nullable fields like `description` or `ownerUserId` on update. ```typescript const created = await api.createFlag({ diff --git a/packages/management-sdk/openapi-generator.config.yaml b/packages/management-sdk/openapi-generator.config.yaml index d0adc698b..ccae1721a 100644 --- a/packages/management-sdk/openapi-generator.config.yaml +++ b/packages/management-sdk/openapi-generator.config.yaml @@ -1,5 +1,5 @@ generatorName: typescript-fetch -inputSpec: https://app.reflag.com/openapi.json +inputSpec: ./.openapi.generated.json outputDir: src/generated templateDir: ./openapi-templates additionalProperties: diff --git a/packages/management-sdk/openapi.json b/packages/management-sdk/openapi.json index e69de29bb..9b908f8a2 100644 --- a/packages/management-sdk/openapi.json +++ b/packages/management-sdk/openapi.json @@ -0,0 +1,2972 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Reflag Management API", + "version": "3.1.0", + "description": "Feature flag Management API", + "contact": { + "name": "Reflag Support", + "url": "https://reflag.com/support" + }, + "license": { + "name": "Proprietary", + "url": "https://reflag.com/" + } + }, + "servers": [ + { + "url": "https://app.reflag.com/api", + "description": "Production server" + } + ], + "security": [ + { + "APIKey": [] + } + ], + "paths": { + "/apps/{appId}": { + "get": { + "summary": "Get details of an application", + "description": "Retrieve a specific application by its identifier", + "operationId": "getApp", + "parameters": [ + { + "in": "path", + "name": "appId", + "schema": { + "$ref": "#/components/schemas/appId" + }, + "required": true, + "description": "App identifier" + } + ], + "responses": { + "200": { + "description": "Requested resource retrieved successfully", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/app" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "404": { + "description": "Requested resource, or its parent, not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/apps": { + "get": { + "summary": "List of applications", + "description": "Retrieve all accessible applications", + "operationId": "listApps", + "parameters": [ + { + "in": "query", + "name": "orgId", + "schema": { + "$ref": "#/components/schemas/orgId" + } + } + ], + "responses": { + "200": { + "description": "Requested resource retrieved successfully", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/appHeaderCollection" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "404": { + "description": "Requested resource, or its parent, not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/apps/{appId}/environments": { + "get": { + "summary": "List environments for application", + "description": "Retrieve all environments for a specific application", + "operationId": "listEnvironments", + "parameters": [ + { + "in": "path", + "name": "appId", + "schema": { + "$ref": "#/components/schemas/appId" + }, + "required": true, + "description": "App identifier" + }, + { + "in": "query", + "name": "sortOrder", + "schema": { + "$ref": "#/components/schemas/sortOrder" + }, + "description": "Sort order applied to the sorting column" + }, + { + "in": "query", + "name": "sortBy", + "schema": { + "$ref": "#/components/schemas/environmentHeaderSortByColumn" + }, + "description": "The column to sort by" + } + ], + "responses": { + "200": { + "description": "Requested resource retrieved successfully", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/environmentHeaderCollection" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "404": { + "description": "Requested resource, or its parent, not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/apps/{appId}/environments/{envId}": { + "get": { + "summary": "Get environment details", + "description": "Retrieve details for a specific environment", + "operationId": "getEnvironment", + "parameters": [ + { + "in": "path", + "name": "appId", + "schema": { + "$ref": "#/components/schemas/appId" + }, + "required": true, + "description": "App identifier" + }, + { + "in": "path", + "name": "envId", + "schema": { + "$ref": "#/components/schemas/envId" + }, + "required": true, + "description": "Environment identifier" + } + ], + "responses": { + "200": { + "description": "Requested resource retrieved successfully", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/environment" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "404": { + "description": "Requested resource, or its parent, not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/apps/{appId}/flags": { + "get": { + "summary": "List flags for application", + "description": "Retrieve all flags for a specific application", + "operationId": "listFlags", + "parameters": [ + { + "in": "path", + "name": "appId", + "schema": { + "$ref": "#/components/schemas/appId" + }, + "required": true, + "description": "App identifier" + } + ], + "responses": { + "200": { + "description": "Requested resource retrieved successfully", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/flagHeaderCollection" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "404": { + "description": "Requested resource, or its parent, not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + }, + "post": { + "summary": "Create a flag", + "description": "Create a new flag in the application. Returns the created flag and the resulting flag-state version for every environment.", + "operationId": "createFlag", + "parameters": [ + { + "in": "path", + "name": "appId", + "schema": { + "$ref": "#/components/schemas/appId" + }, + "required": true, + "description": "App identifier" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "key": { + "type": "string", + "minLength": 1, + "description": "Key of the flag" + }, + "flagType": { + "default": "boolean", + "description": "Type of the flag", + "$ref": "#/components/schemas/flagType" + }, + "name": { + "type": "string", + "minLength": 1, + "description": "Name of the flag" + }, + "description": { + "description": "Description of the flag", + "anyOf": [ + { + "type": "string", + "maxLength": 8192 + }, + { + "type": "null" + } + ] + }, + "stageId": { + "description": "Stage ID of the flag", + "type": "string", + "minLength": 14, + "maxLength": 14 + }, + "ownerUserId": { + "type": [ + "string", + "null" + ] + }, + "permanent": { + "default": false, + "type": "boolean" + }, + "secret": { + "description": "Whether the flag is secret", + "type": "boolean" + } + }, + "required": [ + "key", + "name" + ], + "additionalProperties": false + } + } + } + }, + "responses": { + "200": { + "description": "Requested resource retrieved successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "flag": { + "type": "object", + "properties": { + "id": { + "$ref": "#/components/schemas/flagId" + }, + "key": { + "$ref": "#/components/schemas/flagKey" + }, + "name": { + "type": "string", + "minLength": 1, + "maxLength": 255, + "description": "Flag name" + }, + "flagType": { + "$ref": "#/components/schemas/flagType" + }, + "description": { + "description": "Flag description", + "type": "string" + }, + "stage": { + "$ref": "#/components/schemas/stageHeader" + }, + "owner": { + "$ref": "#/components/schemas/reflagUserHeader" + }, + "archived": { + "type": "boolean", + "description": "Whether the flag is archived" + }, + "stale": { + "type": "boolean", + "description": "Whether the flag is stale" + }, + "permanent": { + "type": "boolean", + "description": "Whether the flag is permanent" + }, + "createdAt": { + "description": "Timestamp when the flag was created", + "type": "string" + }, + "rolledOutToEveryoneAt": { + "description": "Timestamp when the flag was rolled out to everyone", + "type": "string" + }, + "codeRefsCleanedUp": { + "type": "boolean", + "description": "Whether code references for this flag have been cleaned up" + }, + "codeRefsMarkedCleanUserName": { + "description": "Name of the user who marked code references as cleaned up", + "type": "string" + }, + "codeRefsMarkedCleanAt": { + "description": "Timestamp when code references were marked as cleaned up", + "type": "string" + }, + "lastCheckAt": { + "description": "Timestamp when the flag was last checked", + "type": "string" + }, + "noRecentChecks": { + "type": "boolean", + "description": "Whether the flag has no recent access checks" + }, + "lastTrackAt": { + "description": "Timestamp when the flag was last tracked", + "type": "string" + }, + "parentFlagId": { + "description": "Parent flag ID", + "type": "string" + } + }, + "required": [ + "id", + "key", + "name", + "flagType", + "archived", + "stale", + "permanent", + "codeRefsCleanedUp", + "noRecentChecks" + ], + "additionalProperties": false + }, + "flagStateVersions": { + "$ref": "#/components/schemas/appFlagStateVersions" + } + }, + "required": [ + "flag", + "flagStateVersions" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "404": { + "description": "Requested resource, or its parent, not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/apps/{appId}/flags/{flagId}": { + "patch": { + "summary": "Update a flag", + "description": "Update an existing flag. Returns the current flag-state version for every environment, including any versions advanced by this update.", + "operationId": "updateFlag", + "parameters": [ + { + "in": "path", + "name": "appId", + "schema": { + "$ref": "#/components/schemas/appId" + }, + "required": true, + "description": "App identifier" + }, + { + "in": "path", + "name": "flagId", + "schema": { + "$ref": "#/components/schemas/flagId" + }, + "required": true, + "description": "Flag ID" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "minLength": 1, + "description": "Name of the flag" + }, + "description": { + "description": "Description of the flag", + "anyOf": [ + { + "type": "string", + "maxLength": 8192 + }, + { + "type": "null" + } + ] + }, + "ownerUserId": { + "type": [ + "string", + "null" + ] + }, + "permanent": { + "type": "boolean" + }, + "secret": { + "description": "Whether the flag is secret", + "type": "boolean" + }, + "isArchived": { + "type": "boolean" + }, + "stageId": { + "description": "Stage ID of the flag", + "type": "string", + "minLength": 14, + "maxLength": 14 + } + }, + "additionalProperties": false + } + } + } + }, + "responses": { + "200": { + "description": "Requested resource retrieved successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "flag": { + "type": "object", + "properties": { + "id": { + "$ref": "#/components/schemas/flagId" + }, + "key": { + "$ref": "#/components/schemas/flagKey" + }, + "name": { + "type": "string", + "minLength": 1, + "maxLength": 255, + "description": "Flag name" + }, + "flagType": { + "$ref": "#/components/schemas/flagType" + }, + "description": { + "description": "Flag description", + "type": "string" + }, + "stage": { + "$ref": "#/components/schemas/stageHeader" + }, + "owner": { + "$ref": "#/components/schemas/reflagUserHeader" + }, + "archived": { + "type": "boolean", + "description": "Whether the flag is archived" + }, + "stale": { + "type": "boolean", + "description": "Whether the flag is stale" + }, + "permanent": { + "type": "boolean", + "description": "Whether the flag is permanent" + }, + "createdAt": { + "description": "Timestamp when the flag was created", + "type": "string" + }, + "rolledOutToEveryoneAt": { + "description": "Timestamp when the flag was rolled out to everyone", + "type": "string" + }, + "codeRefsCleanedUp": { + "type": "boolean", + "description": "Whether code references for this flag have been cleaned up" + }, + "codeRefsMarkedCleanUserName": { + "description": "Name of the user who marked code references as cleaned up", + "type": "string" + }, + "codeRefsMarkedCleanAt": { + "description": "Timestamp when code references were marked as cleaned up", + "type": "string" + }, + "lastCheckAt": { + "description": "Timestamp when the flag was last checked", + "type": "string" + }, + "noRecentChecks": { + "type": "boolean", + "description": "Whether the flag has no recent access checks" + }, + "lastTrackAt": { + "description": "Timestamp when the flag was last tracked", + "type": "string" + }, + "parentFlagId": { + "description": "Parent flag ID", + "type": "string" + } + }, + "required": [ + "id", + "key", + "name", + "flagType", + "archived", + "stale", + "permanent", + "codeRefsCleanedUp", + "noRecentChecks" + ], + "additionalProperties": false + }, + "flagStateVersions": { + "$ref": "#/components/schemas/appFlagStateVersions" + } + }, + "required": [ + "flag", + "flagStateVersions" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "404": { + "description": "Requested resource, or its parent, not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/apps/{appId}/flags/{flagKey}/targeting/{envId}": { + "get": { + "summary": "Get flag targeting for an environment", + "description": "Read a flag's authored targeting mode, saved explicit assignments, and compiled runtime enable rules with read scope. Saved targets may remain configured while No one disables all effective rules. Version, mode, assignments, and effective rules come from one configuration snapshot. This does not guarantee SDK propagation or replay a live evaluation context.", + "operationId": "getFlagTargeting", + "parameters": [ + { + "in": "path", + "name": "appId", + "schema": { + "$ref": "#/components/schemas/appId" + }, + "required": true, + "description": "App identifier" + }, + { + "in": "path", + "name": "flagKey", + "schema": { + "$ref": "#/components/schemas/flagKey" + }, + "required": true, + "description": "Unique flag key" + }, + { + "in": "path", + "name": "envId", + "schema": { + "$ref": "#/components/schemas/envId" + }, + "required": true, + "description": "Environment identifier" + } + ], + "responses": { + "200": { + "description": "Requested resource retrieved successfully", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/flagTargeting" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "404": { + "description": "Requested resource, or its parent, not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/apps/{appId}/envs/{envId}/companies/{companyId}": { + "put": { + "summary": "Create or update a company", + "description": "Synchronously create or update a company in an environment. Requires the `write:entities` API key scope or admin member access. This scope also grants deletion through the corresponding entity DELETE endpoints, but does not grant membership changes or flag targeting; grant `write:flag:targeting` separately to assign flags and `read` for GET requests. Attributes accept JSON values and are normalized and merged using the same rules as ingestion. Recognized name and avatar attributes also update the corresponding company fields; top-level `name` takes precedence over name attributes. Omitting a field preserves its existing value. New companies may omit all fields. When this request succeeds, a subsequent company targeting request can read the company. Flag configuration propagation to SDKs is independent. Delayed ingestion writes may later replace overlapping values because the last database writer wins.", + "operationId": "upsertCompany", + "parameters": [ + { + "in": "path", + "name": "appId", + "schema": { + "$ref": "#/components/schemas/appId" + }, + "required": true, + "description": "App identifier" + }, + { + "in": "path", + "name": "envId", + "schema": { + "$ref": "#/components/schemas/envId" + }, + "required": true, + "description": "Environment identifier" + }, + { + "in": "path", + "name": "companyId", + "schema": { + "$ref": "#/components/schemas/companyId" + }, + "required": true, + "description": "Company ID within your application" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "description": "Company name. Omit it to preserve an existing name; new companies may be unnamed.", + "type": "string", + "minLength": 1, + "maxLength": 128 + }, + "attributes": { + "$ref": "#/components/schemas/entityAttributesInput" + } + }, + "additionalProperties": false + } + } + } + }, + "responses": { + "200": { + "description": "Company created or updated successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "description": "Company name. Omit it to preserve an existing name; new companies may be unnamed.", + "type": "string", + "minLength": 1, + "maxLength": 128 + }, + "attributes": { + "$ref": "#/components/schemas/entityAttributesInputOutput" + }, + "id": { + "$ref": "#/components/schemas/companyId" + } + }, + "required": [ + "id" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "404": { + "description": "Requested resource, or its parent, not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + }, + "delete": { + "summary": "Delete a company", + "description": "Synchronously delete a company and its related data from an environment. Requires the `write:entities` API key scope or admin member access. By default, users that belong only to this company are also deleted; set `deleteUsers` to false to preserve them. Users that belong to other companies are always preserved.", + "operationId": "deleteCompany", + "parameters": [ + { + "in": "path", + "name": "appId", + "schema": { + "$ref": "#/components/schemas/appId" + }, + "required": true, + "description": "App identifier" + }, + { + "in": "path", + "name": "envId", + "schema": { + "$ref": "#/components/schemas/envId" + }, + "required": true, + "description": "Environment identifier" + }, + { + "in": "path", + "name": "companyId", + "schema": { + "$ref": "#/components/schemas/companyId" + }, + "required": true, + "description": "Company ID within your application" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "deleteUsers": { + "type": "boolean" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Company deleted successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": {}, + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "404": { + "description": "Requested resource, or its parent, not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/apps/{appId}/envs/{envId}/companies/{companyId}/flags": { + "get": { + "summary": "Get flags for a company", + "description": "Retrieve flags evaluated with current runtime rules and the company's stored attributes. value is the evaluated enabled state, not a default or the last SDK result. specificTargetValue is saved assignment metadata and can remain true while No one makes value false. No user or other/request context is supplied; stored attributes may differ from a live SDK request.", + "operationId": "getCompanyFlags", + "parameters": [ + { + "in": "path", + "name": "appId", + "schema": { + "$ref": "#/components/schemas/appId" + }, + "required": true, + "description": "App identifier" + }, + { + "in": "path", + "name": "envId", + "schema": { + "$ref": "#/components/schemas/envId" + }, + "required": true, + "description": "Environment identifier" + }, + { + "in": "path", + "name": "companyId", + "schema": { + "$ref": "#/components/schemas/companyId" + }, + "required": true, + "description": "Company ID within your application" + } + ], + "responses": { + "200": { + "description": "Requested resource retrieved successfully", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/entityFlagsResponse" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "404": { + "description": "Requested resource, or its parent, not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + }, + "patch": { + "summary": "Update flag targeting for a company", + "description": "Update specific targeting for flags for a company in an environment. Returns the environment flag-state version containing the completed update.", + "operationId": "updateCompanyFlags", + "parameters": [ + { + "in": "path", + "name": "appId", + "schema": { + "$ref": "#/components/schemas/appId" + }, + "required": true, + "description": "App identifier" + }, + { + "in": "path", + "name": "envId", + "schema": { + "$ref": "#/components/schemas/envId" + }, + "required": true, + "description": "Environment identifier" + }, + { + "in": "path", + "name": "companyId", + "schema": { + "$ref": "#/components/schemas/companyId" + }, + "required": true, + "description": "Company ID within your application" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/updateEntityFlagsBody" + } + } + } + }, + "responses": { + "200": { + "description": "Requested resource retrieved successfully", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/updateEntityFlagsResponse" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "404": { + "description": "Requested resource, or its parent, not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/apps/{appId}/envs/{envId}/users/{userId}": { + "put": { + "summary": "Create or update a user", + "description": "Synchronously create or update a user in an environment. Requires the `write:entities` API key scope or admin member access. This scope also grants deletion through the corresponding entity DELETE endpoints, but does not grant membership changes or flag targeting; grant `write:flag:targeting` separately to assign flags and `read` for GET requests. Attributes accept JSON values and are normalized and merged using the same rules as ingestion. Recognized name, email, and avatar attributes also update the corresponding user fields; top-level `name` takes precedence over name attributes. Omitting a field preserves its existing value. New users may omit all fields. When this request succeeds, a subsequent user targeting request can read the user. Flag configuration propagation to SDKs is independent. Delayed ingestion writes may later replace overlapping values because the last database writer wins.", + "operationId": "upsertUser", + "parameters": [ + { + "in": "path", + "name": "appId", + "schema": { + "$ref": "#/components/schemas/appId" + }, + "required": true, + "description": "App identifier" + }, + { + "in": "path", + "name": "envId", + "schema": { + "$ref": "#/components/schemas/envId" + }, + "required": true, + "description": "Environment identifier" + }, + { + "in": "path", + "name": "userId", + "schema": { + "$ref": "#/components/schemas/userId" + }, + "required": true, + "description": "User ID within your application" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "description": "User name. Omit it to preserve an existing name; new users may be unnamed.", + "type": "string", + "minLength": 1, + "maxLength": 128 + }, + "attributes": { + "$ref": "#/components/schemas/entityAttributesInput" + } + }, + "additionalProperties": false + } + } + } + }, + "responses": { + "200": { + "description": "User created or updated successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "description": "User name. Omit it to preserve an existing name; new users may be unnamed.", + "type": "string", + "minLength": 1, + "maxLength": 128 + }, + "attributes": { + "$ref": "#/components/schemas/entityAttributesInputOutput" + }, + "id": { + "$ref": "#/components/schemas/userId" + } + }, + "required": [ + "id" + ], + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "404": { + "description": "Requested resource, or its parent, not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + }, + "delete": { + "summary": "Delete a user", + "description": "Synchronously delete a user and its related data, including company memberships, from an environment. Requires the `write:entities` API key scope or admin member access.", + "operationId": "deleteUser", + "parameters": [ + { + "in": "path", + "name": "appId", + "schema": { + "$ref": "#/components/schemas/appId" + }, + "required": true, + "description": "App identifier" + }, + { + "in": "path", + "name": "envId", + "schema": { + "$ref": "#/components/schemas/envId" + }, + "required": true, + "description": "Environment identifier" + }, + { + "in": "path", + "name": "userId", + "schema": { + "$ref": "#/components/schemas/userId" + }, + "required": true, + "description": "User ID within your application" + } + ], + "responses": { + "200": { + "description": "User deleted successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": {}, + "additionalProperties": false + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "404": { + "description": "Requested resource, or its parent, not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/apps/{appId}/envs/{envId}/users/{userId}/flags": { + "get": { + "summary": "Get flags for a user", + "description": "Retrieve flags evaluated with current runtime rules and stored user attributes, also checking each stored company membership separately. value is the evaluated enabled state, not a default or the last SDK result. specificTargetValue is saved assignment metadata and can remain true while No one makes value false. No other/request context is supplied; this is not a replay of a single live SDK request.", + "operationId": "getUserFlags", + "parameters": [ + { + "in": "path", + "name": "appId", + "schema": { + "$ref": "#/components/schemas/appId" + }, + "required": true, + "description": "App identifier" + }, + { + "in": "path", + "name": "envId", + "schema": { + "$ref": "#/components/schemas/envId" + }, + "required": true, + "description": "Environment identifier" + }, + { + "in": "path", + "name": "userId", + "schema": { + "$ref": "#/components/schemas/userId" + }, + "required": true, + "description": "User ID within your application" + } + ], + "responses": { + "200": { + "description": "Requested resource retrieved successfully", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/entityFlagsResponse" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "404": { + "description": "Requested resource, or its parent, not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + }, + "patch": { + "summary": "Update flag targeting for a user", + "description": "Update specific targeting for flags for a user in an environment. Returns the environment flag-state version containing the completed update.", + "operationId": "updateUserFlags", + "parameters": [ + { + "in": "path", + "name": "appId", + "schema": { + "$ref": "#/components/schemas/appId" + }, + "required": true, + "description": "App identifier" + }, + { + "in": "path", + "name": "envId", + "schema": { + "$ref": "#/components/schemas/envId" + }, + "required": true, + "description": "Environment identifier" + }, + { + "in": "path", + "name": "userId", + "schema": { + "$ref": "#/components/schemas/userId" + }, + "required": true, + "description": "User ID within your application" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/updateEntityFlagsBody" + } + } + } + }, + "responses": { + "200": { + "description": "Requested resource retrieved successfully", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/updateEntityFlagsResponse" + } + } + } + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "404": { + "description": "Requested resource, or its parent, not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "appId": { + "type": "string", + "minLength": 1, + "description": "App identifier" + }, + "orgId": { + "type": "string", + "minLength": 1, + "description": "Organization identifier" + }, + "sortOrder": { + "default": "asc", + "description": "Sort order applied to the sorting column", + "type": "string", + "enum": [ + "asc", + "desc" + ] + }, + "environmentHeaderSortByColumn": { + "default": "order", + "description": "The column to sort by", + "type": "string", + "enum": [ + "name", + "order" + ] + }, + "envId": { + "type": "string", + "minLength": 1, + "description": "Environment identifier" + }, + "flagType": { + "type": "string", + "enum": [ + "boolean", + "multivariate" + ], + "description": "The flag type: boolean (release) or multivariate" + }, + "flagId": { + "type": "string", + "minLength": 1, + "description": "Flag ID" + }, + "flagKey": { + "type": "string", + "minLength": 1, + "description": "Unique flag key" + }, + "companyId": { + "type": "string", + "minLength": 1, + "maxLength": 128, + "description": "Company ID within your application" + }, + "entityAttributesInput": { + "anyOf": [ + { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "$ref": "#/components/schemas/__schema0" + } + }, + { + "type": "null" + } + ], + "description": "Entity attributes. Values are normalized exactly like ingestion before being merged with existing attributes." + }, + "updateEntityFlagsBody": { + "type": "object", + "properties": { + "updates": { + "minItems": 1, + "type": "array", + "items": { + "$ref": "#/components/schemas/entityFlagUpdate" + }, + "description": "List of flag updates to apply" + }, + "changeDescription": { + "description": "Description of the change for audit history", + "type": "string" + }, + "notifications": { + "description": "Destination list for notifications about the change. Use [] to disable notifications. Omit to use configured defaults.", + "type": "array", + "items": { + "type": "string", + "enum": [ + "linearComment", + "slack" + ] + } + } + }, + "required": [ + "updates" + ], + "description": "Request body for updating flags for an entity" + }, + "entityFlagUpdate": { + "type": "object", + "properties": { + "flagKey": { + "$ref": "#/components/schemas/flagKey" + }, + "specificTargetValue": { + "anyOf": [ + { + "type": "boolean", + "const": true + }, + { + "type": "null" + } + ], + "description": "Set to true to add a specific-targeting override, or null to remove it" + } + }, + "required": [ + "flagKey", + "specificTargetValue" + ], + "description": "Update for a single flag's explicit targeting override" + }, + "userId": { + "type": "string", + "minLength": 1, + "maxLength": 128, + "description": "User ID within your application" + }, + "__schema0": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "number" + }, + { + "type": "boolean" + }, + { + "type": "null" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/__schema0" + } + }, + { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "$ref": "#/components/schemas/__schema0" + } + } + ] + }, + "app": { + "type": "object", + "properties": { + "org": { + "$ref": "#/components/schemas/orgHeader" + }, + "id": { + "$ref": "#/components/schemas/appId" + }, + "name": { + "type": "string", + "description": "App name" + }, + "demo": { + "type": "boolean", + "description": "Whether the app is a demo app" + }, + "flagKeyFormat": { + "$ref": "#/components/schemas/flagKeyFormat" + }, + "environments": { + "type": "array", + "items": { + "$ref": "#/components/schemas/environment" + }, + "description": "Environments within the app" + }, + "stages": { + "type": "array", + "items": { + "$ref": "#/components/schemas/stageHeader" + }, + "description": "Stages within the app" + }, + "segments": { + "type": "array", + "items": { + "$ref": "#/components/schemas/segmentHeader" + }, + "description": "Segments within the app" + } + }, + "required": [ + "org", + "id", + "name", + "demo", + "flagKeyFormat", + "environments", + "stages", + "segments" + ], + "additionalProperties": false, + "description": "App information with related collections" + }, + "orgHeader": { + "type": "object", + "properties": { + "id": { + "$ref": "#/components/schemas/orgId" + }, + "name": { + "type": "string", + "minLength": 1, + "description": "Organization name" + } + }, + "required": [ + "id", + "name" + ], + "additionalProperties": false, + "description": "Organization's basic information" + }, + "flagKeyFormat": { + "type": "string", + "enum": [ + "custom", + "pascalCase", + "camelCase", + "snakeCaseUpper", + "snakeCaseLower", + "kebabCaseUpper", + "kebabCaseLower" + ], + "description": "The enforced key format when creating flags" + }, + "environment": { + "type": "object", + "properties": { + "id": { + "$ref": "#/components/schemas/envId" + }, + "name": { + "type": "string", + "description": "Environment name" + }, + "isProduction": { + "type": "boolean", + "description": "Whether the environment is a production environment" + }, + "order": { + "type": "integer", + "minimum": 0, + "description": "Environment order in the app (zero-indexed)" + }, + "flagStateVersion": { + "type": "integer", + "minimum": 0, + "description": "Environment version incremented when flag state changes" + }, + "sdkAccess": { + "type": "object", + "properties": { + "publishableKey": { + "type": "string", + "minLength": 1, + "maxLength": 36, + "description": "Publishable key" + }, + "secretKey": { + "type": "string", + "minLength": 1, + "maxLength": 36, + "description": "Secret key" + } + }, + "required": [ + "publishableKey", + "secretKey" + ], + "additionalProperties": false, + "description": "SDK access details" + } + }, + "required": [ + "id", + "name", + "isProduction", + "order", + "flagStateVersion", + "sdkAccess" + ], + "additionalProperties": false, + "description": "Environment details" + }, + "stageHeader": { + "type": "object", + "properties": { + "id": { + "$ref": "#/components/schemas/stageId" + }, + "name": { + "type": "string", + "minLength": 1, + "description": "Stage name" + }, + "color": { + "type": "string", + "minLength": 1, + "maxLength": 64, + "description": "Stage color (HTML color name or hex code)" + }, + "order": { + "type": "integer", + "minimum": 0, + "description": "Stage order" + } + }, + "required": [ + "id", + "name", + "color", + "order" + ], + "additionalProperties": false, + "description": "Stage's basic information" + }, + "stageId": { + "type": "string", + "minLength": 1, + "description": "Stage identifier" + }, + "segmentHeader": { + "type": "object", + "properties": { + "id": { + "$ref": "#/components/schemas/segmentId" + }, + "name": { + "type": "string", + "minLength": 1, + "description": "Segment name" + }, + "type": { + "$ref": "#/components/schemas/segmentType" + } + }, + "required": [ + "id", + "name", + "type" + ], + "additionalProperties": false, + "description": "Segment's basic information" + }, + "segmentId": { + "type": "string", + "minLength": 1, + "description": "Segment identifier" + }, + "segmentType": { + "type": "string", + "enum": [ + "all", + "custom" + ], + "description": "Segment type" + }, + "ErrorResponse": { + "type": "object", + "properties": { + "error": { + "type": "object", + "properties": { + "code": { + "type": "string", + "enum": [ + "invalid_request", + "not_found", + "not_possible", + "not_allowed", + "not_available", + "unknown_error", + "unauthorized", + "unauthenticated" + ], + "description": "Error code" + }, + "message": { + "type": "string", + "description": "Human readable error message" + } + }, + "required": [ + "code", + "message" + ], + "additionalProperties": false, + "description": "The error" + }, + "issues": { + "description": "Individual validation issues, if applicable", + "type": "object", + "propertyNames": { + "type": "string", + "description": "The field that has the issue (uses dot notation). Empty string if the issue is at the root." + }, + "additionalProperties": { + "type": "array", + "items": { + "type": "string", + "description": "The error message" + }, + "description": "Error messages for this field" + } + } + }, + "required": [ + "error" + ], + "additionalProperties": false, + "description": "The error response, including individual issues, if applicable" + }, + "appHeaderCollection": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/appHeader" + }, + "description": "The individual items in the collection" + } + }, + "required": [ + "data" + ], + "additionalProperties": false, + "description": "Collection of Basic app information" + }, + "appHeader": { + "type": "object", + "properties": { + "org": { + "$ref": "#/components/schemas/orgHeader" + }, + "id": { + "$ref": "#/components/schemas/appId" + }, + "name": { + "type": "string", + "description": "App name" + }, + "demo": { + "type": "boolean", + "description": "Whether the app is a demo app" + }, + "flagKeyFormat": { + "$ref": "#/components/schemas/flagKeyFormat" + }, + "environments": { + "type": "array", + "items": { + "$ref": "#/components/schemas/environmentHeader" + }, + "description": "Environments within the app" + } + }, + "required": [ + "org", + "id", + "name", + "demo", + "flagKeyFormat", + "environments" + ], + "additionalProperties": false, + "description": "Basic app information" + }, + "environmentHeader": { + "type": "object", + "properties": { + "id": { + "$ref": "#/components/schemas/envId" + }, + "name": { + "type": "string", + "description": "Environment name" + }, + "isProduction": { + "type": "boolean", + "description": "Whether the environment is a production environment" + }, + "order": { + "type": "integer", + "minimum": 0, + "description": "Environment order in the app (zero-indexed)" + }, + "flagStateVersion": { + "type": "integer", + "minimum": 0, + "description": "Environment version incremented when flag state changes" + } + }, + "required": [ + "id", + "name", + "isProduction", + "order", + "flagStateVersion" + ], + "additionalProperties": false, + "description": "Basic environment information" + }, + "environmentHeaderCollection": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/environmentHeader" + }, + "description": "The individual items in the collection" + }, + "sortOrder": { + "$ref": "#/components/schemas/sortOrder" + }, + "sortBy": { + "$ref": "#/components/schemas/environmentHeaderSortByColumn" + } + }, + "required": [ + "data", + "sortOrder", + "sortBy" + ], + "additionalProperties": false, + "description": "Collection of Basic environment information" + }, + "flagHeaderCollection": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/flagHeader" + }, + "description": "Page of the collection of flags" + }, + "totalCount": { + "type": "integer", + "description": "Total number of flags in collection" + }, + "pageSize": { + "type": "integer", + "description": "Page size" + }, + "pageIndex": { + "type": "integer", + "description": "Page index" + }, + "sortBy": { + "type": "string", + "enum": [ + "name", + "key", + "stage", + "autoFeedbackSurveysEnabled", + "createdAt", + "rolledOutToEveryoneAt", + "environmentStatus", + "owner", + "lastCheck", + "lastTrack", + "stale", + "archivingChecks" + ], + "description": "Sort by" + }, + "sortOrder": { + "description": "Sort order", + "$ref": "#/components/schemas/sortOrder" + } + }, + "required": [ + "data", + "totalCount", + "pageSize", + "pageIndex", + "sortBy", + "sortOrder" + ], + "additionalProperties": false, + "description": "Collection response containing flags" + }, + "flagHeader": { + "type": "object", + "properties": { + "id": { + "$ref": "#/components/schemas/flagId" + }, + "key": { + "$ref": "#/components/schemas/flagKey" + }, + "name": { + "type": "string", + "minLength": 1, + "maxLength": 255, + "description": "Flag name" + }, + "flagType": { + "$ref": "#/components/schemas/flagType" + }, + "description": { + "description": "Flag description", + "type": "string" + }, + "stage": { + "$ref": "#/components/schemas/stageHeader" + }, + "owner": { + "$ref": "#/components/schemas/reflagUserHeader" + }, + "archived": { + "type": "boolean", + "description": "Whether the flag is archived" + }, + "stale": { + "type": "boolean", + "description": "Whether the flag is stale" + }, + "permanent": { + "type": "boolean", + "description": "Whether the flag is permanent" + }, + "createdAt": { + "description": "Timestamp when the flag was created", + "type": "string" + }, + "rolledOutToEveryoneAt": { + "description": "Timestamp when the flag was rolled out to everyone", + "type": "string" + }, + "codeRefsCleanedUp": { + "type": "boolean", + "description": "Whether code references for this flag have been cleaned up" + }, + "codeRefsMarkedCleanUserName": { + "description": "Name of the user who marked code references as cleaned up", + "type": "string" + }, + "codeRefsMarkedCleanAt": { + "description": "Timestamp when code references were marked as cleaned up", + "type": "string" + }, + "lastCheckAt": { + "description": "Timestamp when the flag was last checked", + "type": "string" + }, + "noRecentChecks": { + "type": "boolean", + "description": "Whether the flag has no recent access checks" + }, + "lastTrackAt": { + "description": "Timestamp when the flag was last tracked", + "type": "string" + } + }, + "required": [ + "id", + "key", + "name", + "flagType", + "archived", + "stale", + "permanent", + "codeRefsCleanedUp", + "noRecentChecks" + ], + "additionalProperties": false, + "description": "Basic flag information" + }, + "reflagUserHeader": { + "type": "object", + "properties": { + "id": { + "$ref": "#/components/schemas/reflagUserId" + }, + "name": { + "type": "string", + "minLength": 1, + "description": "User's name" + }, + "email": { + "type": "string", + "format": "email", + "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$", + "description": "User's email" + }, + "avatarUrl": { + "description": "User's avatar URL", + "type": "string", + "format": "uri" + } + }, + "required": [ + "id", + "name", + "email" + ], + "additionalProperties": false, + "description": "Reflag user's basic information" + }, + "reflagUserId": { + "type": "string", + "minLength": 1, + "description": "Reflag user identifier" + }, + "appFlagStateVersions": { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "$ref": "#/components/schemas/flagStateVersion" + }, + "description": "Current flag-state version keyed by environment ID" + }, + "flagStateVersion": { + "type": "integer", + "minimum": 0, + "description": "Environment flag-state version containing the completed mutation" + }, + "flagTargeting": { + "type": "object", + "properties": { + "flagKey": { + "$ref": "#/components/schemas/flagKey" + }, + "version": { + "$ref": "#/components/schemas/flagVersion" + }, + "targetingMode": { + "type": "string", + "enum": [ + "none", + "some", + "everyone" + ], + "description": "Authored targeting mode. Saved specific targets are inactive when this is none and are not required when it is everyone." + }, + "effectiveRules": { + "type": "array", + "items": { + "$ref": "#/components/schemas/effectiveFlagRule" + }, + "description": "Compiled runtime enable rules, including active opt-ins, with segment and flag references resolved. Rules are evaluated independently (OR), not as one combined rule. Empty for No one, archived flags, or a configuration with no enable rules. Uses the same authored snapshot as version; does not guarantee SDK propagation or reproduce a live SDK context." + }, + "updatedAt": { + "type": "string", + "format": "date-time", + "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$", + "description": "Last time the targeting was updated" + }, + "specificTargets": { + "type": "object", + "propertyNames": { + "$ref": "#/components/schemas/flagValue" + }, + "additionalProperties": { + "$ref": "#/components/schemas/flagValueTargeting" + }, + "required": [ + "true" + ], + "description": "Saved explicit assignments, preserved even when inactive. Use targetingMode and effectiveRules to interpret effective targeting, not list membership alone." + } + }, + "required": [ + "flagKey", + "version", + "targetingMode", + "effectiveRules", + "updatedAt", + "specificTargets" + ], + "additionalProperties": false, + "description": "Flag targeting information and its audience" + }, + "flagVersion": { + "type": "integer", + "description": "Flag targeting version" + }, + "effectiveFlagRule": { + "type": "object", + "properties": { + "filter": { + "$ref": "#/components/schemas/effectiveFlagFilter" + } + }, + "required": [ + "filter" + ], + "additionalProperties": false, + "description": "One independent enable rule; a flag is enabled if any rule matches" + }, + "effectiveFlagFilter": { + "description": "A compiled runtime filter with segment and flag references resolved", + "anyOf": [ + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "context" + }, + "field": { + "type": "string" + }, + "operator": { + "type": "string", + "enum": [ + "IS", + "IS_NOT", + "ANY_OF", + "NOT_ANY_OF", + "CONTAINS", + "NOT_CONTAINS", + "GT", + "LT", + "AFTER", + "BEFORE", + "DATE_AFTER", + "DATE_BEFORE", + "SET", + "NOT_SET", + "IS_TRUE", + "IS_FALSE" + ] + }, + "values": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "type", + "field", + "operator" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "rolloutPercentage" + }, + "key": { + "type": "string" + }, + "partialRolloutAttribute": { + "type": "string" + }, + "partialRolloutThreshold": { + "type": "integer" + } + }, + "required": [ + "type", + "key", + "partialRolloutAttribute", + "partialRolloutThreshold" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "constant" + }, + "value": { + "type": "boolean" + } + }, + "required": [ + "type", + "value" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "group" + }, + "operator": { + "type": "string", + "enum": [ + "and", + "or" + ] + }, + "filters": { + "type": "array", + "items": { + "$ref": "#/components/schemas/effectiveFlagFilter" + } + } + }, + "required": [ + "type", + "operator", + "filters" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "negation" + }, + "filter": { + "$ref": "#/components/schemas/effectiveFlagFilter" + } + }, + "required": [ + "type", + "filter" + ], + "additionalProperties": false + } + ] + }, + "flagValue": { + "type": "string", + "const": "true", + "description": "The saved explicit value for the audience; does not imply that targeting is active." + }, + "flagValueTargeting": { + "type": "object", + "properties": { + "companyIds": { + "type": "array", + "items": { + "$ref": "#/components/schemas/companyId" + }, + "description": "Companies that were explicitly given the value" + }, + "userIds": { + "type": "array", + "items": { + "$ref": "#/components/schemas/userId" + }, + "description": "Users that were explicitly given the value" + } + }, + "required": [ + "companyIds", + "userIds" + ], + "additionalProperties": false, + "description": "Flag targeting value and its audience" + }, + "entityFlagsResponse": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/entityFlag" + }, + "description": "List of flags with their enabled status" + }, + "totalCount": { + "type": "integer", + "description": "Total number of flags" + }, + "pageSize": { + "type": "integer", + "description": "Page size" + }, + "pageIndex": { + "type": "integer", + "description": "Page index" + } + }, + "required": [ + "data", + "totalCount", + "pageSize", + "pageIndex" + ], + "additionalProperties": false, + "description": "Response containing flags for an entity" + }, + "entityFlag": { + "type": "object", + "properties": { + "id": { + "$ref": "#/components/schemas/flagId" + }, + "key": { + "$ref": "#/components/schemas/flagKey" + }, + "name": { + "type": "string", + "minLength": 1, + "maxLength": 255, + "description": "Flag name" + }, + "createdAt": { + "type": "string", + "description": "Timestamp when the flag was created" + }, + "value": { + "type": "boolean", + "description": "Evaluated enabled state using current runtime rules and stored entity attributes, not the last SDK result or a default value. Company checks supply only company context. User checks supply user context and also check each stored company membership; no other/request context is supplied. Stored attributes and context may differ from a live SDK request." + }, + "specificTargetValue": { + "description": "Saved explicit assignment, or null if absent. May be true while value is false when targeting is No one. This is configuration metadata, not an effective-access override.", + "type": [ + "boolean", + "null" + ] + }, + "firstExposureAt": { + "description": "First time the entity was exposed to this flag", + "type": [ + "string", + "null" + ] + }, + "lastExposureAt": { + "description": "Last time the entity was exposed to this flag", + "type": [ + "string", + "null" + ] + }, + "lastCheckAt": { + "description": "Last time the flag was checked for this entity", + "type": [ + "string", + "null" + ] + }, + "exposureCount": { + "type": "integer", + "description": "Number of times the entity was exposed to this flag" + }, + "firstTrackAt": { + "description": "First time a track event was recorded for this flag", + "type": [ + "string", + "null" + ] + }, + "lastTrackAt": { + "description": "Last time a track event was recorded for this flag", + "type": [ + "string", + "null" + ] + }, + "trackCount": { + "type": "integer", + "description": "Number of track events for this flag" + } + }, + "required": [ + "id", + "key", + "name", + "createdAt", + "value", + "specificTargetValue", + "firstExposureAt", + "lastExposureAt", + "lastCheckAt", + "exposureCount", + "firstTrackAt", + "lastTrackAt", + "trackCount" + ], + "additionalProperties": false, + "description": "Flag information with enabled status for an entity" + }, + "updateEntityFlagsResponse": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/entityFlag" + }, + "description": "List of flags with their enabled status" + }, + "totalCount": { + "type": "integer", + "description": "Total number of flags" + }, + "pageSize": { + "type": "integer", + "description": "Page size" + }, + "pageIndex": { + "type": "integer", + "description": "Page index" + }, + "flagStateVersion": { + "$ref": "#/components/schemas/flagStateVersion" + } + }, + "required": [ + "data", + "totalCount", + "pageSize", + "pageIndex", + "flagStateVersion" + ], + "additionalProperties": false, + "description": "Updated entity flags and the environment flag-state version containing the change" + }, + "__schema1": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "number" + }, + { + "type": "boolean" + }, + { + "type": "null" + }, + { + "type": "array", + "items": { + "$ref": "#/components/schemas/__schema1" + } + }, + { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "$ref": "#/components/schemas/__schema1" + } + } + ] + }, + "entityAttributesInputOutput": { + "anyOf": [ + { + "type": "object", + "propertyNames": { + "type": "string" + }, + "additionalProperties": { + "$ref": "#/components/schemas/__schema1" + } + }, + { + "type": "null" + } + ], + "description": "Entity attributes. Values are normalized exactly like ingestion before being merged with existing attributes." + } + }, + "securitySchemes": { + "APIKey": { + "type": "http", + "scheme": "bearer", + "description": "API key authentication, for service access" + } + } + } +} diff --git a/packages/management-sdk/package.json b/packages/management-sdk/package.json index d7d9e2d23..f68f83e05 100644 --- a/packages/management-sdk/package.json +++ b/packages/management-sdk/package.json @@ -16,7 +16,8 @@ "access": "public" }, "scripts": { - "generate": "rm -rf src/generated && npx @openapitools/openapi-generator-cli generate -c openapi-generator.config.yaml && node ./scripts/strip-openapi-doc-tags.mjs", + "update-spec": "node ./scripts/update-spec.mjs", + "generate": "rm -rf src/generated && node ./scripts/prepare-spec.mjs && npx @openapitools/openapi-generator-cli generate -c openapi-generator.config.yaml && node ./scripts/strip-openapi-doc-tags.mjs", "build": "yarn generate && tsc --project tsconfig.build.json", "test": "vitest run --passWithNoTests", "test:watch": "vitest", diff --git a/packages/management-sdk/scripts/prepare-spec.mjs b/packages/management-sdk/scripts/prepare-spec.mjs new file mode 100644 index 000000000..17b4393ba --- /dev/null +++ b/packages/management-sdk/scripts/prepare-spec.mjs @@ -0,0 +1,44 @@ +// Prepares openapi.json for the TypeScript generator without changing the +// committed spec. The generator flattens `anyOf` unions into one object with +// every field required, so tagged unions are rewritten as `oneOf` with a +// `type` discriminator and named variants. +import { readFile, writeFile } from "node:fs/promises"; + +const [input = "openapi.json", output = ".openapi.generated.json"] = + process.argv.slice(2); +const spec = JSON.parse(await readFile(input, "utf8")); +const schemas = spec.components?.schemas ?? {}; + +const capitalize = (s) => s[0].toUpperCase() + s.slice(1); + +for (const [name, schema] of Object.entries({ ...schemas })) { + const variants = schema.anyOf ?? schema.oneOf; + if (!Array.isArray(variants) || variants.length < 2) continue; + const tags = variants.map((v) => v.properties?.type?.const); + if (tags.some((tag) => typeof tag !== "string")) continue; + if (new Set(tags).size !== tags.length) continue; + + const mapping = {}; + const oneOf = variants.map((variant, i) => { + const variantName = `${name}${capitalize(tags[i])}`; + const { const: tag, ...typeSchema } = variant.properties.type; + schemas[variantName] = { + ...variant, + properties: { + ...variant.properties, + type: { ...typeSchema, enum: [tag] }, + }, + }; + const ref = `#/components/schemas/${variantName}`; + mapping[tags[i]] = ref; + return { $ref: ref }; + }); + const { anyOf: _anyOf, oneOf: _oneOf, ...rest } = schema; + schemas[name] = { + ...rest, + oneOf, + discriminator: { propertyName: "type", mapping }, + }; +} + +await writeFile(output, `${JSON.stringify(spec, null, 2)}\n`); diff --git a/packages/management-sdk/scripts/update-spec.mjs b/packages/management-sdk/scripts/update-spec.mjs new file mode 100644 index 000000000..7b3fabc16 --- /dev/null +++ b/packages/management-sdk/scripts/update-spec.mjs @@ -0,0 +1,13 @@ +// Downloads the latest Management API spec into openapi.json. +// Builds generate the client from this committed file, so a spec update is a +// reviewable change. Run `yarn update-spec && yarn generate`, then commit both. +import { writeFile } from "node:fs/promises"; + +const url = "https://app.reflag.com/openapi.json"; +const res = await fetch(url); +if (!res.ok) throw new Error(`Failed to download ${url}: ${res.status}`); +const spec = await res.json(); +await writeFile("openapi.json", `${JSON.stringify(spec, null, 2)}\n`); +console.log( + `Updated openapi.json (OpenAPI ${spec.openapi}, ${spec.info?.version})`, +); diff --git a/packages/management-sdk/src/generated/.openapi-generator/FILES b/packages/management-sdk/src/generated/.openapi-generator/FILES index 1c123e8d3..e0632028b 100644 --- a/packages/management-sdk/src/generated/.openapi-generator/FILES +++ b/packages/management-sdk/src/generated/.openapi-generator/FILES @@ -9,6 +9,13 @@ models/CreateFlag200Response.ts models/CreateFlag200ResponseFlag.ts models/CreateFlagRequest.ts models/DeleteCompanyRequest.ts +models/EffectiveFlagFilter.ts +models/EffectiveFlagFilterConstant.ts +models/EffectiveFlagFilterContext.ts +models/EffectiveFlagFilterGroup.ts +models/EffectiveFlagFilterNegation.ts +models/EffectiveFlagFilterRolloutPercentage.ts +models/EffectiveFlagRule.ts models/EntityFlag.ts models/EntityFlagUpdate.ts models/EntityFlagsResponse.ts @@ -23,6 +30,7 @@ models/FlagHeader.ts models/FlagHeaderCollection.ts models/FlagKeyFormat.ts models/FlagTargeting.ts +models/FlagType.ts models/FlagValue.ts models/FlagValueTargeting.ts models/OrgHeader.ts diff --git a/packages/management-sdk/src/generated/apis/DefaultApi.ts b/packages/management-sdk/src/generated/apis/DefaultApi.ts index 5315ca631..3bfd375eb 100644 --- a/packages/management-sdk/src/generated/apis/DefaultApi.ts +++ b/packages/management-sdk/src/generated/apis/DefaultApi.ts @@ -228,7 +228,7 @@ export interface DefaultApiInterface { getApp(requestParameters: GetAppRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; /** - * Retrieve all flags with their targeting status for a specific company + * Retrieve flags evaluated with current runtime rules and the company\'s stored attributes. value is the evaluated enabled state, not a default or the last SDK result. specificTargetValue is saved assignment metadata and can remain true while No one makes value false. No user or other/request context is supplied; stored attributes may differ from a live SDK request. * @summary Get flags for a company * @param requestParameters Request parameters for this operation. * @throws {RequiredError} @@ -236,7 +236,7 @@ export interface DefaultApiInterface { getCompanyFlagsRaw(requestParameters: GetCompanyFlagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** - * Retrieve all flags with their targeting status for a specific company + * Retrieve flags evaluated with current runtime rules and the company\'s stored attributes. value is the evaluated enabled state, not a default or the last SDK result. specificTargetValue is saved assignment metadata and can remain true while No one makes value false. No user or other/request context is supplied; stored attributes may differ from a live SDK request. * Get flags for a company */ getCompanyFlags(requestParameters: GetCompanyFlagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; @@ -256,7 +256,7 @@ export interface DefaultApiInterface { getEnvironment(requestParameters: GetEnvironmentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; /** - * Retrieve targeting for a flag in an environment + * Read a flag\'s authored targeting mode, saved explicit assignments, and compiled runtime enable rules with read scope. Saved targets may remain configured while No one disables all effective rules. Version, mode, assignments, and effective rules come from one configuration snapshot. This does not guarantee SDK propagation or replay a live evaluation context. * @summary Get flag targeting for an environment * @param requestParameters Request parameters for this operation. * @throws {RequiredError} @@ -264,13 +264,13 @@ export interface DefaultApiInterface { getFlagTargetingRaw(requestParameters: GetFlagTargetingRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** - * Retrieve targeting for a flag in an environment + * Read a flag\'s authored targeting mode, saved explicit assignments, and compiled runtime enable rules with read scope. Saved targets may remain configured while No one disables all effective rules. Version, mode, assignments, and effective rules come from one configuration snapshot. This does not guarantee SDK propagation or replay a live evaluation context. * Get flag targeting for an environment */ getFlagTargeting(requestParameters: GetFlagTargetingRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; /** - * Retrieve all flags with their targeting status for a specific user + * Retrieve flags evaluated with current runtime rules and stored user attributes, also checking each stored company membership separately. value is the evaluated enabled state, not a default or the last SDK result. specificTargetValue is saved assignment metadata and can remain true while No one makes value false. No other/request context is supplied; this is not a replay of a single live SDK request. * @summary Get flags for a user * @param requestParameters Request parameters for this operation. * @throws {RequiredError} @@ -278,7 +278,7 @@ export interface DefaultApiInterface { getUserFlagsRaw(requestParameters: GetUserFlagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; /** - * Retrieve all flags with their targeting status for a specific user + * Retrieve flags evaluated with current runtime rules and stored user attributes, also checking each stored company membership separately. value is the evaluated enabled state, not a default or the last SDK result. specificTargetValue is saved assignment metadata and can remain true while No one makes value false. No other/request context is supplied; this is not a replay of a single live SDK request. * Get flags for a user */ getUserFlags(requestParameters: GetUserFlagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; @@ -439,6 +439,7 @@ export class DefaultApi extends runtime.BaseAPI implements DefaultApiInterface { query: queryParameters, body: CreateFlagRequestToJSON({ key: requestParameters['key'], + flagType: requestParameters['flagType'], name: requestParameters['name'], description: requestParameters['description'], stageId: requestParameters['stageId'], @@ -639,7 +640,7 @@ export class DefaultApi extends runtime.BaseAPI implements DefaultApiInterface { } /** - * Retrieve all flags with their targeting status for a specific company + * Retrieve flags evaluated with current runtime rules and the company\'s stored attributes. value is the evaluated enabled state, not a default or the last SDK result. specificTargetValue is saved assignment metadata and can remain true while No one makes value false. No user or other/request context is supplied; stored attributes may differ from a live SDK request. * Get flags for a company */ async getCompanyFlagsRaw(requestParameters: GetCompanyFlagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { @@ -693,7 +694,7 @@ export class DefaultApi extends runtime.BaseAPI implements DefaultApiInterface { } /** - * Retrieve all flags with their targeting status for a specific company + * Retrieve flags evaluated with current runtime rules and the company\'s stored attributes. value is the evaluated enabled state, not a default or the last SDK result. specificTargetValue is saved assignment metadata and can remain true while No one makes value false. No user or other/request context is supplied; stored attributes may differ from a live SDK request. * Get flags for a company */ async getCompanyFlags(requestParameters: GetCompanyFlagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { @@ -757,7 +758,7 @@ export class DefaultApi extends runtime.BaseAPI implements DefaultApiInterface { } /** - * Retrieve targeting for a flag in an environment + * Read a flag\'s authored targeting mode, saved explicit assignments, and compiled runtime enable rules with read scope. Saved targets may remain configured while No one disables all effective rules. Version, mode, assignments, and effective rules come from one configuration snapshot. This does not guarantee SDK propagation or replay a live evaluation context. * Get flag targeting for an environment */ async getFlagTargetingRaw(requestParameters: GetFlagTargetingRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { @@ -811,7 +812,7 @@ export class DefaultApi extends runtime.BaseAPI implements DefaultApiInterface { } /** - * Retrieve targeting for a flag in an environment + * Read a flag\'s authored targeting mode, saved explicit assignments, and compiled runtime enable rules with read scope. Saved targets may remain configured while No one disables all effective rules. Version, mode, assignments, and effective rules come from one configuration snapshot. This does not guarantee SDK propagation or replay a live evaluation context. * Get flag targeting for an environment */ async getFlagTargeting(requestParameters: GetFlagTargetingRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { @@ -820,7 +821,7 @@ export class DefaultApi extends runtime.BaseAPI implements DefaultApiInterface { } /** - * Retrieve all flags with their targeting status for a specific user + * Retrieve flags evaluated with current runtime rules and stored user attributes, also checking each stored company membership separately. value is the evaluated enabled state, not a default or the last SDK result. specificTargetValue is saved assignment metadata and can remain true while No one makes value false. No other/request context is supplied; this is not a replay of a single live SDK request. * Get flags for a user */ async getUserFlagsRaw(requestParameters: GetUserFlagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { @@ -874,7 +875,7 @@ export class DefaultApi extends runtime.BaseAPI implements DefaultApiInterface { } /** - * Retrieve all flags with their targeting status for a specific user + * Retrieve flags evaluated with current runtime rules and stored user attributes, also checking each stored company membership separately. value is the evaluated enabled state, not a default or the last SDK result. specificTargetValue is saved assignment metadata and can remain true while No one makes value false. No other/request context is supplied; this is not a replay of a single live SDK request. * Get flags for a user */ async getUserFlags(requestParameters: GetUserFlagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { diff --git a/packages/management-sdk/src/generated/models/CreateFlag200ResponseFlag.ts b/packages/management-sdk/src/generated/models/CreateFlag200ResponseFlag.ts index 191c55f31..e10e64bce 100644 --- a/packages/management-sdk/src/generated/models/CreateFlag200ResponseFlag.ts +++ b/packages/management-sdk/src/generated/models/CreateFlag200ResponseFlag.ts @@ -20,6 +20,13 @@ import { StageHeaderToJSON, StageHeaderToJSONTyped, } from './StageHeader'; +import type { FlagType } from './FlagType'; +import { + FlagTypeFromJSON, + FlagTypeFromJSONTyped, + FlagTypeToJSON, + FlagTypeToJSONTyped, +} from './FlagType'; import type { ReflagUserHeader } from './ReflagUserHeader'; import { ReflagUserHeaderFromJSON, @@ -48,6 +55,11 @@ export interface CreateFlag200ResponseFlag { * @type {string} */ name: string; + /** + * + * @type {FlagType} + */ + flagType: FlagType; /** * Flag description * @type {string} @@ -125,6 +137,8 @@ export interface CreateFlag200ResponseFlag { parentFlagId?: string; } + + /** * Check if a given object implements the CreateFlag200ResponseFlag interface. */ @@ -132,6 +146,7 @@ export function instanceOfCreateFlag200ResponseFlag(value: object): value is Cre if (!('id' in value) || value['id'] === undefined) return false; if (!('key' in value) || value['key'] === undefined) return false; if (!('name' in value) || value['name'] === undefined) return false; + if (!('flagType' in value) || value['flagType'] === undefined) return false; if (!('archived' in value) || value['archived'] === undefined) return false; if (!('stale' in value) || value['stale'] === undefined) return false; if (!('permanent' in value) || value['permanent'] === undefined) return false; @@ -153,6 +168,7 @@ export function CreateFlag200ResponseFlagFromJSONTyped(json: any, ignoreDiscrimi 'id': json['id'], 'key': json['key'], 'name': json['name'], + 'flagType': FlagTypeFromJSON(json['flagType']), 'description': json['description'] == null ? undefined : json['description'], 'stage': json['stage'] == null ? undefined : StageHeaderFromJSON(json['stage']), 'owner': json['owner'] == null ? undefined : ReflagUserHeaderFromJSON(json['owner']), @@ -185,6 +201,7 @@ export function CreateFlag200ResponseFlagToJSONTyped(value?: CreateFlag200Respon 'id': value['id'], 'key': value['key'], 'name': value['name'], + 'flagType': FlagTypeToJSON(value['flagType']), 'description': value['description'], 'stage': StageHeaderToJSON(value['stage']), 'owner': ReflagUserHeaderToJSON(value['owner']), diff --git a/packages/management-sdk/src/generated/models/CreateFlagRequest.ts b/packages/management-sdk/src/generated/models/CreateFlagRequest.ts index a32356150..601ce8fa9 100644 --- a/packages/management-sdk/src/generated/models/CreateFlagRequest.ts +++ b/packages/management-sdk/src/generated/models/CreateFlagRequest.ts @@ -13,6 +13,14 @@ */ import { mapValues } from '../runtime'; +import type { FlagType } from './FlagType'; +import { + FlagTypeFromJSON, + FlagTypeFromJSONTyped, + FlagTypeToJSON, + FlagTypeToJSONTyped, +} from './FlagType'; + /** * * @interface CreateFlagRequest @@ -23,6 +31,11 @@ export interface CreateFlagRequest { * @type {string} */ key: string; + /** + * Type of the flag + * @type {FlagType} + */ + flagType?: FlagType; /** * Name of the flag * @type {string} @@ -55,6 +68,8 @@ export interface CreateFlagRequest { secret?: boolean; } + + /** * Check if a given object implements the CreateFlagRequest interface. */ @@ -75,6 +90,7 @@ export function CreateFlagRequestFromJSONTyped(json: any, ignoreDiscriminator: b return { 'key': json['key'], + 'flagType': json['flagType'] == null ? undefined : FlagTypeFromJSON(json['flagType']), 'name': json['name'], 'description': json['description'] == null ? undefined : json['description'], 'stageId': json['stageId'] == null ? undefined : json['stageId'], @@ -96,6 +112,7 @@ export function CreateFlagRequestToJSONTyped(value?: CreateFlagRequest | null, i return { 'key': value['key'], + 'flagType': FlagTypeToJSON(value['flagType']), 'name': value['name'], 'description': value['description'], 'stageId': value['stageId'], diff --git a/packages/management-sdk/src/generated/models/EffectiveFlagFilter.ts b/packages/management-sdk/src/generated/models/EffectiveFlagFilter.ts new file mode 100644 index 000000000..e256192f6 --- /dev/null +++ b/packages/management-sdk/src/generated/models/EffectiveFlagFilter.ts @@ -0,0 +1,104 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Reflag Management API + * Feature flag Management API + * + * The version of the OpenAPI document: 3.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import type { EffectiveFlagFilterConstant } from './EffectiveFlagFilterConstant'; +import { + instanceOfEffectiveFlagFilterConstant, + EffectiveFlagFilterConstantFromJSON, + EffectiveFlagFilterConstantFromJSONTyped, + EffectiveFlagFilterConstantToJSON, +} from './EffectiveFlagFilterConstant'; +import type { EffectiveFlagFilterContext } from './EffectiveFlagFilterContext'; +import { + instanceOfEffectiveFlagFilterContext, + EffectiveFlagFilterContextFromJSON, + EffectiveFlagFilterContextFromJSONTyped, + EffectiveFlagFilterContextToJSON, +} from './EffectiveFlagFilterContext'; +import type { EffectiveFlagFilterGroup } from './EffectiveFlagFilterGroup'; +import { + instanceOfEffectiveFlagFilterGroup, + EffectiveFlagFilterGroupFromJSON, + EffectiveFlagFilterGroupFromJSONTyped, + EffectiveFlagFilterGroupToJSON, +} from './EffectiveFlagFilterGroup'; +import type { EffectiveFlagFilterNegation } from './EffectiveFlagFilterNegation'; +import { + instanceOfEffectiveFlagFilterNegation, + EffectiveFlagFilterNegationFromJSON, + EffectiveFlagFilterNegationFromJSONTyped, + EffectiveFlagFilterNegationToJSON, +} from './EffectiveFlagFilterNegation'; +import type { EffectiveFlagFilterRolloutPercentage } from './EffectiveFlagFilterRolloutPercentage'; +import { + instanceOfEffectiveFlagFilterRolloutPercentage, + EffectiveFlagFilterRolloutPercentageFromJSON, + EffectiveFlagFilterRolloutPercentageFromJSONTyped, + EffectiveFlagFilterRolloutPercentageToJSON, +} from './EffectiveFlagFilterRolloutPercentage'; + +/** + * @type EffectiveFlagFilter + * A compiled runtime filter with segment and flag references resolved + */ +export type EffectiveFlagFilter = { type: 'constant' } & EffectiveFlagFilterConstant | { type: 'context' } & EffectiveFlagFilterContext | { type: 'group' } & EffectiveFlagFilterGroup | { type: 'negation' } & EffectiveFlagFilterNegation | { type: 'rolloutPercentage' } & EffectiveFlagFilterRolloutPercentage; + +export function EffectiveFlagFilterFromJSON(json: any): EffectiveFlagFilter { + return EffectiveFlagFilterFromJSONTyped(json, false); +} + +export function EffectiveFlagFilterFromJSONTyped(json: any, ignoreDiscriminator: boolean): EffectiveFlagFilter { + if (json == null) { + return json; + } + switch (json['type']) { + case 'constant': + return Object.assign({}, EffectiveFlagFilterConstantFromJSONTyped(json, true), { type: 'constant' } as const); + case 'context': + return Object.assign({}, EffectiveFlagFilterContextFromJSONTyped(json, true), { type: 'context' } as const); + case 'group': + return Object.assign({}, EffectiveFlagFilterGroupFromJSONTyped(json, true), { type: 'group' } as const); + case 'negation': + return Object.assign({}, EffectiveFlagFilterNegationFromJSONTyped(json, true), { type: 'negation' } as const); + case 'rolloutPercentage': + return Object.assign({}, EffectiveFlagFilterRolloutPercentageFromJSONTyped(json, true), { type: 'rolloutPercentage' } as const); + default: + return json; + } +} + +export function EffectiveFlagFilterToJSON(json: any): any { + return EffectiveFlagFilterToJSONTyped(json, false); +} + +export function EffectiveFlagFilterToJSONTyped(value?: EffectiveFlagFilter | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + switch (value['type']) { + case 'constant': + return Object.assign({}, EffectiveFlagFilterConstantToJSON(value), { type: 'constant' } as const); + case 'context': + return Object.assign({}, EffectiveFlagFilterContextToJSON(value), { type: 'context' } as const); + case 'group': + return Object.assign({}, EffectiveFlagFilterGroupToJSON(value), { type: 'group' } as const); + case 'negation': + return Object.assign({}, EffectiveFlagFilterNegationToJSON(value), { type: 'negation' } as const); + case 'rolloutPercentage': + return Object.assign({}, EffectiveFlagFilterRolloutPercentageToJSON(value), { type: 'rolloutPercentage' } as const); + default: + return value; + } +} + diff --git a/packages/management-sdk/src/generated/models/EffectiveFlagFilterConstant.ts b/packages/management-sdk/src/generated/models/EffectiveFlagFilterConstant.ts new file mode 100644 index 000000000..ae01528a6 --- /dev/null +++ b/packages/management-sdk/src/generated/models/EffectiveFlagFilterConstant.ts @@ -0,0 +1,81 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Reflag Management API + * Feature flag Management API + * + * The version of the OpenAPI document: 3.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @interface EffectiveFlagFilterConstant + */ +export interface EffectiveFlagFilterConstant { + /** + * + * @type {string} + */ + type: EffectiveFlagFilterConstantTypeEnum; + /** + * + * @type {boolean} + */ + value: boolean; +} + + +/** + */ +export const EffectiveFlagFilterConstantTypeEnum = { + Constant: 'constant' +} as const; +export type EffectiveFlagFilterConstantTypeEnum = typeof EffectiveFlagFilterConstantTypeEnum[keyof typeof EffectiveFlagFilterConstantTypeEnum]; + + +/** + * Check if a given object implements the EffectiveFlagFilterConstant interface. + */ +export function instanceOfEffectiveFlagFilterConstant(value: object): value is EffectiveFlagFilterConstant { + if (!('type' in value) || value['type'] === undefined) return false; + if (!('value' in value) || value['value'] === undefined) return false; + return true; +} + +export function EffectiveFlagFilterConstantFromJSON(json: any): EffectiveFlagFilterConstant { + return EffectiveFlagFilterConstantFromJSONTyped(json, false); +} + +export function EffectiveFlagFilterConstantFromJSONTyped(json: any, ignoreDiscriminator: boolean): EffectiveFlagFilterConstant { + if (json == null) { + return json; + } + return { + + 'type': json['type'], + 'value': json['value'], + }; +} + +export function EffectiveFlagFilterConstantToJSON(json: any): EffectiveFlagFilterConstant { + return EffectiveFlagFilterConstantToJSONTyped(json, false); +} + +export function EffectiveFlagFilterConstantToJSONTyped(value?: EffectiveFlagFilterConstant | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'type': value['type'], + 'value': value['value'], + }; +} + diff --git a/packages/management-sdk/src/generated/models/EffectiveFlagFilterContext.ts b/packages/management-sdk/src/generated/models/EffectiveFlagFilterContext.ts new file mode 100644 index 000000000..6b9ee0353 --- /dev/null +++ b/packages/management-sdk/src/generated/models/EffectiveFlagFilterContext.ts @@ -0,0 +1,118 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Reflag Management API + * Feature flag Management API + * + * The version of the OpenAPI document: 3.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @interface EffectiveFlagFilterContext + */ +export interface EffectiveFlagFilterContext { + /** + * + * @type {string} + */ + type: EffectiveFlagFilterContextTypeEnum; + /** + * + * @type {string} + */ + field: string; + /** + * + * @type {string} + */ + operator: EffectiveFlagFilterContextOperatorEnum; + /** + * + * @type {Array} + */ + values?: Array; +} + + +/** + */ +export const EffectiveFlagFilterContextTypeEnum = { + Context: 'context' +} as const; +export type EffectiveFlagFilterContextTypeEnum = typeof EffectiveFlagFilterContextTypeEnum[keyof typeof EffectiveFlagFilterContextTypeEnum]; + +/** + */ +export const EffectiveFlagFilterContextOperatorEnum = { + Is: 'IS', + IsNot: 'IS_NOT', + AnyOf: 'ANY_OF', + NotAnyOf: 'NOT_ANY_OF', + Contains: 'CONTAINS', + NotContains: 'NOT_CONTAINS', + Gt: 'GT', + Lt: 'LT', + After: 'AFTER', + Before: 'BEFORE', + DateAfter: 'DATE_AFTER', + DateBefore: 'DATE_BEFORE', + Set: 'SET', + NotSet: 'NOT_SET', + IsTrue: 'IS_TRUE', + IsFalse: 'IS_FALSE' +} as const; +export type EffectiveFlagFilterContextOperatorEnum = typeof EffectiveFlagFilterContextOperatorEnum[keyof typeof EffectiveFlagFilterContextOperatorEnum]; + + +/** + * Check if a given object implements the EffectiveFlagFilterContext interface. + */ +export function instanceOfEffectiveFlagFilterContext(value: object): value is EffectiveFlagFilterContext { + if (!('type' in value) || value['type'] === undefined) return false; + if (!('field' in value) || value['field'] === undefined) return false; + if (!('operator' in value) || value['operator'] === undefined) return false; + return true; +} + +export function EffectiveFlagFilterContextFromJSON(json: any): EffectiveFlagFilterContext { + return EffectiveFlagFilterContextFromJSONTyped(json, false); +} + +export function EffectiveFlagFilterContextFromJSONTyped(json: any, ignoreDiscriminator: boolean): EffectiveFlagFilterContext { + if (json == null) { + return json; + } + return { + + 'type': json['type'], + 'field': json['field'], + 'operator': json['operator'], + 'values': json['values'] == null ? undefined : json['values'], + }; +} + +export function EffectiveFlagFilterContextToJSON(json: any): EffectiveFlagFilterContext { + return EffectiveFlagFilterContextToJSONTyped(json, false); +} + +export function EffectiveFlagFilterContextToJSONTyped(value?: EffectiveFlagFilterContext | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'type': value['type'], + 'field': value['field'], + 'operator': value['operator'], + 'values': value['values'], + }; +} + diff --git a/packages/management-sdk/src/generated/models/EffectiveFlagFilterGroup.ts b/packages/management-sdk/src/generated/models/EffectiveFlagFilterGroup.ts new file mode 100644 index 000000000..0bc4527cc --- /dev/null +++ b/packages/management-sdk/src/generated/models/EffectiveFlagFilterGroup.ts @@ -0,0 +1,105 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Reflag Management API + * Feature flag Management API + * + * The version of the OpenAPI document: 3.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { EffectiveFlagFilter } from './EffectiveFlagFilter'; +import { + EffectiveFlagFilterFromJSON, + EffectiveFlagFilterFromJSONTyped, + EffectiveFlagFilterToJSON, + EffectiveFlagFilterToJSONTyped, +} from './EffectiveFlagFilter'; + +/** + * + * @interface EffectiveFlagFilterGroup + */ +export interface EffectiveFlagFilterGroup { + /** + * + * @type {string} + */ + type: EffectiveFlagFilterGroupTypeEnum; + /** + * + * @type {string} + */ + operator: EffectiveFlagFilterGroupOperatorEnum; + /** + * + * @type {Array} + */ + filters: Array; +} + + +/** + */ +export const EffectiveFlagFilterGroupTypeEnum = { + Group: 'group' +} as const; +export type EffectiveFlagFilterGroupTypeEnum = typeof EffectiveFlagFilterGroupTypeEnum[keyof typeof EffectiveFlagFilterGroupTypeEnum]; + +/** + */ +export const EffectiveFlagFilterGroupOperatorEnum = { + And: 'and', + Or: 'or' +} as const; +export type EffectiveFlagFilterGroupOperatorEnum = typeof EffectiveFlagFilterGroupOperatorEnum[keyof typeof EffectiveFlagFilterGroupOperatorEnum]; + + +/** + * Check if a given object implements the EffectiveFlagFilterGroup interface. + */ +export function instanceOfEffectiveFlagFilterGroup(value: object): value is EffectiveFlagFilterGroup { + if (!('type' in value) || value['type'] === undefined) return false; + if (!('operator' in value) || value['operator'] === undefined) return false; + if (!('filters' in value) || value['filters'] === undefined) return false; + return true; +} + +export function EffectiveFlagFilterGroupFromJSON(json: any): EffectiveFlagFilterGroup { + return EffectiveFlagFilterGroupFromJSONTyped(json, false); +} + +export function EffectiveFlagFilterGroupFromJSONTyped(json: any, ignoreDiscriminator: boolean): EffectiveFlagFilterGroup { + if (json == null) { + return json; + } + return { + + 'type': json['type'], + 'operator': json['operator'], + 'filters': ((json['filters'] as Array).map(EffectiveFlagFilterFromJSON)), + }; +} + +export function EffectiveFlagFilterGroupToJSON(json: any): EffectiveFlagFilterGroup { + return EffectiveFlagFilterGroupToJSONTyped(json, false); +} + +export function EffectiveFlagFilterGroupToJSONTyped(value?: EffectiveFlagFilterGroup | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'type': value['type'], + 'operator': value['operator'], + 'filters': ((value['filters'] as Array).map(EffectiveFlagFilterToJSON)), + }; +} + diff --git a/packages/management-sdk/src/generated/models/EffectiveFlagFilterNegation.ts b/packages/management-sdk/src/generated/models/EffectiveFlagFilterNegation.ts new file mode 100644 index 000000000..aa1d5c600 --- /dev/null +++ b/packages/management-sdk/src/generated/models/EffectiveFlagFilterNegation.ts @@ -0,0 +1,89 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Reflag Management API + * Feature flag Management API + * + * The version of the OpenAPI document: 3.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { EffectiveFlagFilter } from './EffectiveFlagFilter'; +import { + EffectiveFlagFilterFromJSON, + EffectiveFlagFilterFromJSONTyped, + EffectiveFlagFilterToJSON, + EffectiveFlagFilterToJSONTyped, +} from './EffectiveFlagFilter'; + +/** + * + * @interface EffectiveFlagFilterNegation + */ +export interface EffectiveFlagFilterNegation { + /** + * + * @type {string} + */ + type: EffectiveFlagFilterNegationTypeEnum; + /** + * + * @type {EffectiveFlagFilter} + */ + filter: EffectiveFlagFilter; +} + + +/** + */ +export const EffectiveFlagFilterNegationTypeEnum = { + Negation: 'negation' +} as const; +export type EffectiveFlagFilterNegationTypeEnum = typeof EffectiveFlagFilterNegationTypeEnum[keyof typeof EffectiveFlagFilterNegationTypeEnum]; + + +/** + * Check if a given object implements the EffectiveFlagFilterNegation interface. + */ +export function instanceOfEffectiveFlagFilterNegation(value: object): value is EffectiveFlagFilterNegation { + if (!('type' in value) || value['type'] === undefined) return false; + if (!('filter' in value) || value['filter'] === undefined) return false; + return true; +} + +export function EffectiveFlagFilterNegationFromJSON(json: any): EffectiveFlagFilterNegation { + return EffectiveFlagFilterNegationFromJSONTyped(json, false); +} + +export function EffectiveFlagFilterNegationFromJSONTyped(json: any, ignoreDiscriminator: boolean): EffectiveFlagFilterNegation { + if (json == null) { + return json; + } + return { + + 'type': json['type'], + 'filter': EffectiveFlagFilterFromJSON(json['filter']), + }; +} + +export function EffectiveFlagFilterNegationToJSON(json: any): EffectiveFlagFilterNegation { + return EffectiveFlagFilterNegationToJSONTyped(json, false); +} + +export function EffectiveFlagFilterNegationToJSONTyped(value?: EffectiveFlagFilterNegation | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'type': value['type'], + 'filter': EffectiveFlagFilterToJSON(value['filter']), + }; +} + diff --git a/packages/management-sdk/src/generated/models/EffectiveFlagFilterRolloutPercentage.ts b/packages/management-sdk/src/generated/models/EffectiveFlagFilterRolloutPercentage.ts new file mode 100644 index 000000000..4f3825421 --- /dev/null +++ b/packages/management-sdk/src/generated/models/EffectiveFlagFilterRolloutPercentage.ts @@ -0,0 +1,97 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Reflag Management API + * Feature flag Management API + * + * The version of the OpenAPI document: 3.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @interface EffectiveFlagFilterRolloutPercentage + */ +export interface EffectiveFlagFilterRolloutPercentage { + /** + * + * @type {string} + */ + type: EffectiveFlagFilterRolloutPercentageTypeEnum; + /** + * + * @type {string} + */ + key: string; + /** + * + * @type {string} + */ + partialRolloutAttribute: string; + /** + * + * @type {number} + */ + partialRolloutThreshold: number; +} + + +/** + */ +export const EffectiveFlagFilterRolloutPercentageTypeEnum = { + RolloutPercentage: 'rolloutPercentage' +} as const; +export type EffectiveFlagFilterRolloutPercentageTypeEnum = typeof EffectiveFlagFilterRolloutPercentageTypeEnum[keyof typeof EffectiveFlagFilterRolloutPercentageTypeEnum]; + + +/** + * Check if a given object implements the EffectiveFlagFilterRolloutPercentage interface. + */ +export function instanceOfEffectiveFlagFilterRolloutPercentage(value: object): value is EffectiveFlagFilterRolloutPercentage { + if (!('type' in value) || value['type'] === undefined) return false; + if (!('key' in value) || value['key'] === undefined) return false; + if (!('partialRolloutAttribute' in value) || value['partialRolloutAttribute'] === undefined) return false; + if (!('partialRolloutThreshold' in value) || value['partialRolloutThreshold'] === undefined) return false; + return true; +} + +export function EffectiveFlagFilterRolloutPercentageFromJSON(json: any): EffectiveFlagFilterRolloutPercentage { + return EffectiveFlagFilterRolloutPercentageFromJSONTyped(json, false); +} + +export function EffectiveFlagFilterRolloutPercentageFromJSONTyped(json: any, ignoreDiscriminator: boolean): EffectiveFlagFilterRolloutPercentage { + if (json == null) { + return json; + } + return { + + 'type': json['type'], + 'key': json['key'], + 'partialRolloutAttribute': json['partialRolloutAttribute'], + 'partialRolloutThreshold': json['partialRolloutThreshold'], + }; +} + +export function EffectiveFlagFilterRolloutPercentageToJSON(json: any): EffectiveFlagFilterRolloutPercentage { + return EffectiveFlagFilterRolloutPercentageToJSONTyped(json, false); +} + +export function EffectiveFlagFilterRolloutPercentageToJSONTyped(value?: EffectiveFlagFilterRolloutPercentage | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'type': value['type'], + 'key': value['key'], + 'partialRolloutAttribute': value['partialRolloutAttribute'], + 'partialRolloutThreshold': value['partialRolloutThreshold'], + }; +} + diff --git a/packages/management-sdk/src/generated/models/EffectiveFlagRule.ts b/packages/management-sdk/src/generated/models/EffectiveFlagRule.ts new file mode 100644 index 000000000..b55340c87 --- /dev/null +++ b/packages/management-sdk/src/generated/models/EffectiveFlagRule.ts @@ -0,0 +1,72 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Reflag Management API + * Feature flag Management API + * + * The version of the OpenAPI document: 3.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +import type { EffectiveFlagFilter } from './EffectiveFlagFilter'; +import { + EffectiveFlagFilterFromJSON, + EffectiveFlagFilterFromJSONTyped, + EffectiveFlagFilterToJSON, + EffectiveFlagFilterToJSONTyped, +} from './EffectiveFlagFilter'; + +/** + * One independent enable rule; a flag is enabled if any rule matches + * @interface EffectiveFlagRule + */ +export interface EffectiveFlagRule { + /** + * + * @type {EffectiveFlagFilter} + */ + filter: EffectiveFlagFilter; +} + +/** + * Check if a given object implements the EffectiveFlagRule interface. + */ +export function instanceOfEffectiveFlagRule(value: object): value is EffectiveFlagRule { + if (!('filter' in value) || value['filter'] === undefined) return false; + return true; +} + +export function EffectiveFlagRuleFromJSON(json: any): EffectiveFlagRule { + return EffectiveFlagRuleFromJSONTyped(json, false); +} + +export function EffectiveFlagRuleFromJSONTyped(json: any, ignoreDiscriminator: boolean): EffectiveFlagRule { + if (json == null) { + return json; + } + return { + + 'filter': EffectiveFlagFilterFromJSON(json['filter']), + }; +} + +export function EffectiveFlagRuleToJSON(json: any): EffectiveFlagRule { + return EffectiveFlagRuleToJSONTyped(json, false); +} + +export function EffectiveFlagRuleToJSONTyped(value?: EffectiveFlagRule | null, ignoreDiscriminator: boolean = false): any { + if (value == null) { + return value; + } + + return { + + 'filter': EffectiveFlagFilterToJSON(value['filter']), + }; +} + diff --git a/packages/management-sdk/src/generated/models/EntityFlag.ts b/packages/management-sdk/src/generated/models/EntityFlag.ts index f8fdc4f93..c9214559f 100644 --- a/packages/management-sdk/src/generated/models/EntityFlag.ts +++ b/packages/management-sdk/src/generated/models/EntityFlag.ts @@ -39,27 +39,27 @@ export interface EntityFlag { */ createdAt: string; /** - * Whether the flag is enabled for this entity + * Evaluated enabled state using current runtime rules and stored entity attributes, not the last SDK result or a default value. Company checks supply only company context. User checks supply user context and also check each stored company membership; no other/request context is supplied. Stored attributes and context may differ from a live SDK request. * @type {boolean} */ value: boolean; /** - * + * Saved explicit assignment, or null if absent. May be true while value is false when targeting is No one. This is configuration metadata, not an effective-access override. * @type {boolean} */ specificTargetValue: boolean | null; /** - * + * First time the entity was exposed to this flag * @type {string} */ firstExposureAt: string | null; /** - * + * Last time the entity was exposed to this flag * @type {string} */ lastExposureAt: string | null; /** - * + * Last time the flag was checked for this entity * @type {string} */ lastCheckAt: string | null; @@ -69,12 +69,12 @@ export interface EntityFlag { */ exposureCount: number; /** - * + * First time a track event was recorded for this flag * @type {string} */ firstTrackAt: string | null; /** - * + * Last time a track event was recorded for this flag * @type {string} */ lastTrackAt: string | null; diff --git a/packages/management-sdk/src/generated/models/FlagHeader.ts b/packages/management-sdk/src/generated/models/FlagHeader.ts index 775b32e00..9b26c2a3b 100644 --- a/packages/management-sdk/src/generated/models/FlagHeader.ts +++ b/packages/management-sdk/src/generated/models/FlagHeader.ts @@ -20,6 +20,13 @@ import { StageHeaderToJSON, StageHeaderToJSONTyped, } from './StageHeader'; +import type { FlagType } from './FlagType'; +import { + FlagTypeFromJSON, + FlagTypeFromJSONTyped, + FlagTypeToJSON, + FlagTypeToJSONTyped, +} from './FlagType'; import type { ReflagUserHeader } from './ReflagUserHeader'; import { ReflagUserHeaderFromJSON, @@ -48,6 +55,11 @@ export interface FlagHeader { * @type {string} */ name: string; + /** + * + * @type {FlagType} + */ + flagType: FlagType; /** * Flag description * @type {string} @@ -120,6 +132,8 @@ export interface FlagHeader { lastTrackAt?: string; } + + /** * Check if a given object implements the FlagHeader interface. */ @@ -127,6 +141,7 @@ export function instanceOfFlagHeader(value: object): value is FlagHeader { if (!('id' in value) || value['id'] === undefined) return false; if (!('key' in value) || value['key'] === undefined) return false; if (!('name' in value) || value['name'] === undefined) return false; + if (!('flagType' in value) || value['flagType'] === undefined) return false; if (!('archived' in value) || value['archived'] === undefined) return false; if (!('stale' in value) || value['stale'] === undefined) return false; if (!('permanent' in value) || value['permanent'] === undefined) return false; @@ -148,6 +163,7 @@ export function FlagHeaderFromJSONTyped(json: any, ignoreDiscriminator: boolean) 'id': json['id'], 'key': json['key'], 'name': json['name'], + 'flagType': FlagTypeFromJSON(json['flagType']), 'description': json['description'] == null ? undefined : json['description'], 'stage': json['stage'] == null ? undefined : StageHeaderFromJSON(json['stage']), 'owner': json['owner'] == null ? undefined : ReflagUserHeaderFromJSON(json['owner']), @@ -179,6 +195,7 @@ export function FlagHeaderToJSONTyped(value?: FlagHeader | null, ignoreDiscrimin 'id': value['id'], 'key': value['key'], 'name': value['name'], + 'flagType': FlagTypeToJSON(value['flagType']), 'description': value['description'], 'stage': StageHeaderToJSON(value['stage']), 'owner': ReflagUserHeaderToJSON(value['owner']), diff --git a/packages/management-sdk/src/generated/models/FlagTargeting.ts b/packages/management-sdk/src/generated/models/FlagTargeting.ts index e40f86678..307fd5456 100644 --- a/packages/management-sdk/src/generated/models/FlagTargeting.ts +++ b/packages/management-sdk/src/generated/models/FlagTargeting.ts @@ -20,6 +20,13 @@ import { FlagValueTargetingToJSON, FlagValueTargetingToJSONTyped, } from './FlagValueTargeting'; +import type { EffectiveFlagRule } from './EffectiveFlagRule'; +import { + EffectiveFlagRuleFromJSON, + EffectiveFlagRuleFromJSONTyped, + EffectiveFlagRuleToJSON, + EffectiveFlagRuleToJSONTyped, +} from './EffectiveFlagRule'; /** * Flag targeting information and its audience @@ -36,24 +43,47 @@ export interface FlagTargeting { * @type {number} */ version: number; + /** + * Authored targeting mode. Saved specific targets are inactive when this is none and are not required when it is everyone. + * @type {string} + */ + targetingMode: FlagTargetingTargetingModeEnum; + /** + * Compiled runtime enable rules, including active opt-ins, with segment and flag references resolved. Rules are evaluated independently (OR), not as one combined rule. Empty for No one, archived flags, or a configuration with no enable rules. Uses the same authored snapshot as version; does not guarantee SDK propagation or reproduce a live SDK context. + * @type {Array} + */ + effectiveRules: Array; /** * Last time the targeting was updated * @type {Date} */ updatedAt: Date; /** - * The flag targeting for each value + * Saved explicit assignments, preserved even when inactive. Use targetingMode and effectiveRules to interpret effective targeting, not list membership alone. * @type {{ [key: string]: FlagValueTargeting; }} */ specificTargets: { [key: string]: FlagValueTargeting; }; } + +/** + */ +export const FlagTargetingTargetingModeEnum = { + None: 'none', + Some: 'some', + Everyone: 'everyone' +} as const; +export type FlagTargetingTargetingModeEnum = typeof FlagTargetingTargetingModeEnum[keyof typeof FlagTargetingTargetingModeEnum]; + + /** * Check if a given object implements the FlagTargeting interface. */ export function instanceOfFlagTargeting(value: object): value is FlagTargeting { if (!('flagKey' in value) || value['flagKey'] === undefined) return false; if (!('version' in value) || value['version'] === undefined) return false; + if (!('targetingMode' in value) || value['targetingMode'] === undefined) return false; + if (!('effectiveRules' in value) || value['effectiveRules'] === undefined) return false; if (!('updatedAt' in value) || value['updatedAt'] === undefined) return false; if (!('specificTargets' in value) || value['specificTargets'] === undefined) return false; return true; @@ -71,6 +101,8 @@ export function FlagTargetingFromJSONTyped(json: any, ignoreDiscriminator: boole 'flagKey': json['flagKey'], 'version': json['version'], + 'targetingMode': json['targetingMode'], + 'effectiveRules': ((json['effectiveRules'] as Array).map(EffectiveFlagRuleFromJSON)), 'updatedAt': (new Date(json['updatedAt'])), 'specificTargets': (mapValues(json['specificTargets'], FlagValueTargetingFromJSON)), }; @@ -89,6 +121,8 @@ export function FlagTargetingToJSONTyped(value?: FlagTargeting | null, ignoreDis 'flagKey': value['flagKey'], 'version': value['version'], + 'targetingMode': value['targetingMode'], + 'effectiveRules': ((value['effectiveRules'] as Array).map(EffectiveFlagRuleToJSON)), 'updatedAt': value['updatedAt'].toISOString(), 'specificTargets': (mapValues(value['specificTargets'], FlagValueTargetingToJSON)), }; diff --git a/packages/management-sdk/src/generated/models/FlagType.ts b/packages/management-sdk/src/generated/models/FlagType.ts new file mode 100644 index 000000000..42018717b --- /dev/null +++ b/packages/management-sdk/src/generated/models/FlagType.ts @@ -0,0 +1,52 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Reflag Management API + * Feature flag Management API + * + * The version of the OpenAPI document: 3.1.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * The flag type: boolean (release) or multivariate + */ +export const FlagType = { + Boolean: 'boolean', + Multivariate: 'multivariate' +} as const; +export type FlagType = typeof FlagType[keyof typeof FlagType]; + + +export function instanceOfFlagType(value: any): boolean { + for (const key in FlagType) { + if (Object.prototype.hasOwnProperty.call(FlagType, key)) { + if (FlagType[key as keyof typeof FlagType] === value) { + return true; + } + } + } + return false; +} + +export function FlagTypeFromJSON(json: any): FlagType { + return FlagTypeFromJSONTyped(json, false); +} + +export function FlagTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): FlagType { + return json as FlagType; +} + +export function FlagTypeToJSON(value?: FlagType | null): any { + return value as any; +} + +export function FlagTypeToJSONTyped(value: any, ignoreDiscriminator: boolean): FlagType { + return value as FlagType; +} + diff --git a/packages/management-sdk/src/generated/models/FlagValue.ts b/packages/management-sdk/src/generated/models/FlagValue.ts index 308f3a01d..463c91685 100644 --- a/packages/management-sdk/src/generated/models/FlagValue.ts +++ b/packages/management-sdk/src/generated/models/FlagValue.ts @@ -14,7 +14,7 @@ /** - * The value of the flag served to the audience. + * The saved explicit value for the audience; does not imply that targeting is active. */ export const FlagValue = { True: 'true' diff --git a/packages/management-sdk/src/generated/models/index.ts b/packages/management-sdk/src/generated/models/index.ts index dbac38ed5..3d02eba57 100644 --- a/packages/management-sdk/src/generated/models/index.ts +++ b/packages/management-sdk/src/generated/models/index.ts @@ -7,6 +7,13 @@ export * from './CreateFlag200Response'; export * from './CreateFlag200ResponseFlag'; export * from './CreateFlagRequest'; export * from './DeleteCompanyRequest'; +export * from './EffectiveFlagFilter'; +export * from './EffectiveFlagFilterConstant'; +export * from './EffectiveFlagFilterContext'; +export * from './EffectiveFlagFilterGroup'; +export * from './EffectiveFlagFilterNegation'; +export * from './EffectiveFlagFilterRolloutPercentage'; +export * from './EffectiveFlagRule'; export * from './EntityFlag'; export * from './EntityFlagUpdate'; export * from './EntityFlagsResponse'; @@ -21,6 +28,7 @@ export * from './FlagHeader'; export * from './FlagHeaderCollection'; export * from './FlagKeyFormat'; export * from './FlagTargeting'; +export * from './FlagType'; export * from './FlagValue'; export * from './FlagValueTargeting'; export * from './OrgHeader'; diff --git a/packages/management-sdk/test/effectiveRules.test.ts b/packages/management-sdk/test/effectiveRules.test.ts new file mode 100644 index 000000000..f9eb4912f --- /dev/null +++ b/packages/management-sdk/test/effectiveRules.test.ts @@ -0,0 +1,62 @@ +import { describe, expect, it } from "vitest"; + +import { FlagTargetingFromJSON, FlagTargetingToJSON } from "../src"; + +const effectiveRules = [ + { filter: { type: "constant", value: true } }, + { + filter: { + type: "context", + field: "company.plan", + operator: "ANY_OF", + values: ["enterprise"], + }, + }, + { + filter: { + type: "rolloutPercentage", + key: "new-checkout", + partialRolloutAttribute: "company.id", + partialRolloutThreshold: 50000, + }, + }, + { + filter: { + type: "group", + operator: "and", + filters: [ + { type: "constant", value: true }, + { + type: "negation", + filter: { + type: "context", + field: "user.id", + operator: "IS", + values: ["blocked"], + }, + }, + ], + }, + }, +]; + +const json = { + flagKey: "new-checkout", + version: 3, + targetingMode: "some", + effectiveRules, + updatedAt: "2026-12-01T00:00:00.000Z", + specificTargets: {}, +}; + +describe("effective rules", () => { + it("parses every filter variant, including nested groups and negations", () => { + const targeting = FlagTargetingFromJSON(json); + expect(targeting.effectiveRules).toEqual(effectiveRules); + expect(targeting.updatedAt).toEqual(new Date(json.updatedAt)); + }); + + it("serializes filters back to the same JSON", () => { + expect(FlagTargetingToJSON(FlagTargetingFromJSON(json))).toEqual(json); + }); +});