From 5e2d95e0bef5aa4b718df5ab4fa961318e6ef775 Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Tue, 7 Oct 2025 12:28:28 +0200 Subject: [PATCH] refactor: move release plan schemas to OSS (#10748) --- src/lib/openapi/spec/index.ts | 5 ++ .../spec/release-plan-milestone-schema.ts | 60 +++++++++++++ .../release-plan-milestone-strategy-schema.ts | 48 ++++++++++ src/lib/openapi/spec/release-plan-schema.ts | 78 +++++++++++++++++ .../spec/release-plan-template-id-schema.ts | 24 +++++ .../spec/release-plan-template-schema.ts | 87 +++++++++++++++++++ 6 files changed, 302 insertions(+) create mode 100644 src/lib/openapi/spec/release-plan-milestone-schema.ts create mode 100644 src/lib/openapi/spec/release-plan-milestone-strategy-schema.ts create mode 100644 src/lib/openapi/spec/release-plan-schema.ts create mode 100644 src/lib/openapi/spec/release-plan-template-id-schema.ts create mode 100644 src/lib/openapi/spec/release-plan-template-schema.ts diff --git a/src/lib/openapi/spec/index.ts b/src/lib/openapi/spec/index.ts index 6e44c2ba4b..7e41d833a3 100644 --- a/src/lib/openapi/spec/index.ts +++ b/src/lib/openapi/spec/index.ts @@ -170,6 +170,11 @@ export * from './public-signup-token-update-schema.js'; export * from './public-signup-tokens-schema.js'; export * from './push-variants-schema.js'; export * from './record-ui-error-schema.js'; +export * from './release-plan-milestone-schema.js'; +export * from './release-plan-milestone-strategy-schema.js'; +export * from './release-plan-schema.js'; +export * from './release-plan-template-id-schema.js'; +export * from './release-plan-template-schema.js'; export * from './requests-per-second-schema.js'; export * from './requests-per-second-segmented-schema.js'; export * from './reset-password-schema.js'; diff --git a/src/lib/openapi/spec/release-plan-milestone-schema.ts b/src/lib/openapi/spec/release-plan-milestone-schema.ts new file mode 100644 index 0000000000..185366deba --- /dev/null +++ b/src/lib/openapi/spec/release-plan-milestone-schema.ts @@ -0,0 +1,60 @@ +import type { FromSchema } from 'json-schema-to-ts'; +import { releasePlanMilestoneStrategySchema } from './release-plan-milestone-strategy-schema.js'; +import { createFeatureStrategySchema } from './create-feature-strategy-schema.js'; +import { parametersSchema } from './parameters-schema.js'; +import { constraintSchema } from './constraint-schema.js'; +import { createStrategyVariantSchema } from './create-strategy-variant-schema.js'; + +export const releasePlanMilestoneSchema = { + $id: '#/components/schemas/releasePlanMilestoneSchema', + additionalProperties: false, + description: + 'Schema representing the creation of a release plan milestone.', + type: 'object', + required: ['id', 'name', 'sortOrder', 'releasePlanDefinitionId'], + properties: { + id: { + type: 'string', + description: "The milestone's ID. Milestone IDs are ulids.", + example: '01JB9GGTGQYEQ9D40R17T3YVW1', + nullable: false, + }, + name: { + type: 'string', + description: 'The name of the milestone.', + example: 'My milestone', + }, + sortOrder: { + type: 'integer', + description: 'The order of the milestone in the release plan.', + example: 1, + }, + releasePlanDefinitionId: { + type: 'string', + description: + 'The ID of the release plan/template that this milestone belongs to.', + example: '01JB9GGTGQYEQ9D40R17T3YVW2', + }, + strategies: { + type: 'array', + description: + 'A list of strategies that are attached to this milestone.', + items: { + $ref: '#/components/schemas/releasePlanMilestoneStrategySchema', + }, + }, + }, + components: { + schemas: { + releasePlanMilestoneStrategySchema, + createFeatureStrategySchema, + parametersSchema, + constraintSchema, + createStrategyVariantSchema, + }, + }, +} as const; + +export type ReleasePlanMilestoneSchema = FromSchema< + typeof releasePlanMilestoneSchema +>; diff --git a/src/lib/openapi/spec/release-plan-milestone-strategy-schema.ts b/src/lib/openapi/spec/release-plan-milestone-strategy-schema.ts new file mode 100644 index 0000000000..0cd08fb8f6 --- /dev/null +++ b/src/lib/openapi/spec/release-plan-milestone-strategy-schema.ts @@ -0,0 +1,48 @@ +import type { FromSchema } from 'json-schema-to-ts'; +import { createFeatureStrategySchema } from './create-feature-strategy-schema.js'; +import { parametersSchema } from './parameters-schema.js'; +import { constraintSchema } from './constraint-schema.js'; +import { createStrategyVariantSchema } from './create-strategy-variant-schema.js'; + +export const releasePlanMilestoneStrategySchema = { + $id: '#/components/schemas/releasePlanMilestoneStrategySchema', + additionalProperties: false, + description: + 'Schema representing the creation of a release plan milestone strategy.', + type: 'object', + required: ['id', 'milestoneId', 'sortOrder', 'strategyName'], + properties: { + id: { + type: 'string', + description: + "The milestone strategy's ID. Milestone strategy IDs are ulids.", + example: '01JB9GGTGQYEQ9D40R17T3YVW3', + nullable: false, + }, + milestoneId: { + type: 'string', + description: + 'The ID of the milestone that this strategy belongs to.', + example: '01JB9GGTGQYEQ9D40R17T3YVW1', + }, + sortOrder: createFeatureStrategySchema.properties.sortOrder, + title: createFeatureStrategySchema.properties.title, + strategyName: createFeatureStrategySchema.properties.name, + parameters: createFeatureStrategySchema.properties.parameters, + constraints: createFeatureStrategySchema.properties.constraints, + variants: createFeatureStrategySchema.properties.variants, + segments: createFeatureStrategySchema.properties.segments, + }, + components: { + schemas: { + createFeatureStrategySchema, + parametersSchema, + constraintSchema, + createStrategyVariantSchema, + }, + }, +} as const; + +export type ReleasePlanMilestoneStrategySchema = FromSchema< + typeof releasePlanMilestoneStrategySchema +>; diff --git a/src/lib/openapi/spec/release-plan-schema.ts b/src/lib/openapi/spec/release-plan-schema.ts new file mode 100644 index 0000000000..c8fd75980f --- /dev/null +++ b/src/lib/openapi/spec/release-plan-schema.ts @@ -0,0 +1,78 @@ +import type { FromSchema } from 'json-schema-to-ts'; +import { releasePlanMilestoneSchema } from './release-plan-milestone-schema.js'; +import { releasePlanTemplateSchema } from './release-plan-template-schema.js'; +import { releasePlanMilestoneStrategySchema } from './release-plan-milestone-strategy-schema.js'; +import { constraintSchema } from './constraint-schema.js'; +import { createFeatureStrategySchema } from './create-feature-strategy-schema.js'; +import { createStrategyVariantSchema } from './create-strategy-variant-schema.js'; +import { parametersSchema } from './parameters-schema.js'; + +export const releasePlanSchema = { + $id: '#/components/schemas/releasePlanSchema', + additionalProperties: false, + description: 'Schema representing the creation of a release plan.', + type: 'object', + required: [ + 'id', + 'discriminator', + 'name', + 'featureName', + 'environment', + 'createdByUserId', + 'createdAt', + 'milestones', + 'releasePlanTemplateId', + ], + properties: { + id: releasePlanTemplateSchema.properties.id, + discriminator: { + type: 'string', + description: + 'A field to distinguish between release plans and release templates.', + example: 'plan', + nullable: false, + enum: ['plan'], + }, + name: releasePlanTemplateSchema.properties.name, + description: releasePlanTemplateSchema.properties.description, + featureName: { + type: 'string', + description: 'The name of the feature that uses this release plan.', + example: 'my-feature', + }, + environment: { + type: 'string', + description: 'The environment that this release plan is for.', + example: 'production', + }, + createdByUserId: releasePlanTemplateSchema.properties.createdByUserId, + createdAt: releasePlanTemplateSchema.properties.createdAt, + activeMilestoneId: { + type: 'string', + description: + 'The ID of the currently active milestone in this release plan.', + example: '01JB9GGTGQYEQ9D40R17T3YVW1', + nullable: true, + }, + milestones: releasePlanTemplateSchema.properties.milestones, + releasePlanTemplateId: { + type: 'string', + description: + 'The ID of the release plan template that this release plan is based on.', + example: '01JB9GGTGQYEQ9D40R17T3YVW2', + nullable: false, + }, + }, + components: { + schemas: { + releasePlanMilestoneSchema, + releasePlanMilestoneStrategySchema, + createFeatureStrategySchema, + parametersSchema, + constraintSchema, + createStrategyVariantSchema, + }, + }, +} as const; + +export type ReleasePlanSchema = FromSchema; diff --git a/src/lib/openapi/spec/release-plan-template-id-schema.ts b/src/lib/openapi/spec/release-plan-template-id-schema.ts new file mode 100644 index 0000000000..613dfa4b86 --- /dev/null +++ b/src/lib/openapi/spec/release-plan-template-id-schema.ts @@ -0,0 +1,24 @@ +import type { FromSchema } from 'json-schema-to-ts'; + +export const releasePlanTemplateIdSchema = { + $id: '#/components/schemas/releasePlanTemplateIdSchema', + additionalProperties: false, + description: + 'Schema for creating a release plan for a feature flag environment by copying and applying the configuration from a release plan template.', + type: 'object', + required: ['templateId'], + properties: { + templateId: { + type: 'string', + description: + "The release plan template's ID. Release template IDs are ulids.", + example: '01JB9GGTGQYEQ9D40R17T3YVW2', + nullable: false, + }, + }, + components: {}, +} as const; + +export type ReleasePlanTemplateIdSchema = FromSchema< + typeof releasePlanTemplateIdSchema +>; diff --git a/src/lib/openapi/spec/release-plan-template-schema.ts b/src/lib/openapi/spec/release-plan-template-schema.ts new file mode 100644 index 0000000000..c1a9a1b2a6 --- /dev/null +++ b/src/lib/openapi/spec/release-plan-template-schema.ts @@ -0,0 +1,87 @@ +import type { FromSchema } from 'json-schema-to-ts'; +import { releasePlanMilestoneSchema } from './release-plan-milestone-schema.js'; +import { releasePlanMilestoneStrategySchema } from './release-plan-milestone-strategy-schema.js'; +import { createFeatureStrategySchema } from './create-feature-strategy-schema.js'; +import { parametersSchema } from './parameters-schema.js'; +import { constraintSchema } from './constraint-schema.js'; +import { createStrategyVariantSchema } from './create-strategy-variant-schema.js'; + +export const releasePlanTemplateSchema = { + $id: '#/components/schemas/releasePlanTemplateSchema', + additionalProperties: false, + description: 'Schema representing the creation of a release template.', + type: 'object', + required: ['id', 'discriminator', 'name', 'createdByUserId', 'createdAt'], + properties: { + id: { + type: 'string', + description: + "The release plan/template's ID. Release template IDs are ulids.", + example: '01JB9GGTGQYEQ9D40R17T3YVW2', + nullable: false, + }, + discriminator: { + type: 'string', + description: + 'A field to distinguish between release plans and release templates.', + example: 'template', + nullable: false, + enum: ['template'], + }, + name: { + type: 'string', + description: 'The name of the release template.', + example: 'My release plan', + }, + description: { + type: 'string', + description: 'A description of the release template.', + example: 'This is my release plan', + nullable: true, + }, + createdByUserId: { + type: 'number', + description: + 'Release template: The ID of the user who created this template.', + example: 53, + nullable: false, + }, + createdAt: { + type: 'string', + format: 'date-time', + description: + 'The date and time that the release template was created.', + example: '2022-01-01T00:00:00Z', + nullable: false, + }, + milestones: { + type: 'array', + description: 'A list of the milestones in this release template.', + items: { + $ref: '#/components/schemas/releasePlanMilestoneSchema', + }, + }, + archivedAt: { + type: 'string', + format: 'date-time', + description: + 'The date and time that the release template was archived.', + example: '2022-01-01T00:00:00Z', + nullable: true, + }, + }, + components: { + schemas: { + releasePlanMilestoneSchema, + releasePlanMilestoneStrategySchema, + createFeatureStrategySchema, + parametersSchema, + constraintSchema, + createStrategyVariantSchema, + }, + }, +} as const; + +export type ReleasePlanTemplateSchema = FromSchema< + typeof releasePlanTemplateSchema +>;