Skip to content

Commit

Permalink
feat: generate orval types with dependent features (#4902)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew authored Oct 2, 2023
1 parent 40dfb92 commit 751bc46
Show file tree
Hide file tree
Showing 113 changed files with 1,407 additions and 87 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ package-lock.json
# Ignore frontend build
frontend/build

# Ignore orval apis
frontend/src/openapi/apis

# Generated docs
website/docs/reference/api/**/sidebar.js
website/docs/reference/api/**/**.info.mdx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import useAPI from '../useApi/useApi';
import useToast from '../../../useToast';
import { formatUnknownError } from '../../../../utils/formatUnknownError';
import { useCallback } from 'react';
import { DependentFeatureSchema } from '../../../../openapi';

// TODO: generate from orval
interface IParentFeaturePayload {
feature: string;
}
export const useDependentFeaturesApi = (project: string) => {
const { makeRequest, createRequest, errors, loading } = useAPI({
propagateErrors: true,
Expand All @@ -15,7 +12,7 @@ export const useDependentFeaturesApi = (project: string) => {

const addDependency = async (
childFeature: string,
parentFeaturePayload: IParentFeaturePayload
parentFeaturePayload: DependentFeatureSchema
) => {
const req = createRequest(
`/api/admin/projects/${project}/features/${childFeature}/dependencies`,
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/openapi/models/accessOverviewSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
import type { UserAccessSchema } from './userAccessSchema';

/**
* Data containing an overview of all the projects and groups users have access to
*/
export interface AccessOverviewSchema {
/** A list of user access details */
overview?: UserAccessSchema[];
}
14 changes: 14 additions & 0 deletions frontend/src/openapi/models/addFeatureDependency401.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/

export type AddFeatureDependency401 = {
/** The ID of the error instance */
id?: string;
/** The name of the error kind */
name?: string;
/** A description of what went wrong. */
message?: string;
};
14 changes: 14 additions & 0 deletions frontend/src/openapi/models/addFeatureDependency403.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/

export type AddFeatureDependency403 = {
/** The ID of the error instance */
id?: string;
/** The name of the error kind */
name?: string;
/** A description of what went wrong. */
message?: string;
};
14 changes: 14 additions & 0 deletions frontend/src/openapi/models/addFeatureDependency404.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/

export type AddFeatureDependency404 = {
/** The ID of the error instance */
id?: string;
/** The name of the error kind */
name?: string;
/** A description of what went wrong. */
message?: string;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Do not edit manually.
* See `gen:api` script in package.json
*/
import type { SdkContextSchema } from './sdkContextSchema';
import type { SdkFlatContextSchema } from './sdkFlatContextSchema';
import type { AdvancedPlaygroundEnvironmentFeatureSchemaStrategies } from './advancedPlaygroundEnvironmentFeatureSchemaStrategies';
import type { AdvancedPlaygroundEnvironmentFeatureSchemaVariant } from './advancedPlaygroundEnvironmentFeatureSchemaVariant';
import type { VariantSchema } from './variantSchema';
Expand All @@ -17,7 +17,7 @@ export interface AdvancedPlaygroundEnvironmentFeatureSchema {
/** The feature's environment. */
environment: string;
/** The context to use when evaluating toggles */
context: SdkContextSchema;
context: SdkFlatContextSchema;
/** The ID of the project that contains this feature. */
projectId: string;
/** Feature's applicable strategies and cumulative results of the strategies */
Expand Down
35 changes: 7 additions & 28 deletions frontend/src/openapi/models/changeRequestCreateFeatureSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,10 @@ import type { ChangeRequestCreateFeatureSchemaOneOfOnesix } from './changeReques
* Data used to create a [change request](https://docs.getunleash.io/reference/change-requests) for a single feature change.
*/
export type ChangeRequestCreateFeatureSchema =
| (ChangeRequestCreateFeatureSchemaOneOf & {
/** The name of the feature that this change applies to. */
feature: string;
})
| (ChangeRequestCreateFeatureSchemaOneOfFour & {
/** The name of the feature that this change applies to. */
feature: string;
})
| (ChangeRequestCreateFeatureSchemaOneOfSix & {
/** The name of the feature that this change applies to. */
feature: string;
})
| (ChangeRequestCreateFeatureSchemaOneOfEight & {
/** The name of the feature that this change applies to. */
feature: string;
})
| (ChangeRequestCreateFeatureSchemaOneOfOneone & {
/** The name of the feature that this change applies to. */
feature: string;
})
| (ChangeRequestCreateFeatureSchemaOneOfOnethree & {
/** The name of the feature that this change applies to. */
feature: string;
})
| (ChangeRequestCreateFeatureSchemaOneOfOnesix & {
/** The name of the feature that this change applies to. */
feature: string;
});
| ChangeRequestCreateFeatureSchemaOneOf
| ChangeRequestCreateFeatureSchemaOneOfFour
| ChangeRequestCreateFeatureSchemaOneOfSix
| ChangeRequestCreateFeatureSchemaOneOfEight
| ChangeRequestCreateFeatureSchemaOneOfOneone
| ChangeRequestCreateFeatureSchemaOneOfOnethree
| ChangeRequestCreateFeatureSchemaOneOfOnesix;
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import type { ChangeRequestCreateFeatureSchemaOneOfPayload } from './changeReque
* Update the enabled state for a feature.
*/
export type ChangeRequestCreateFeatureSchemaOneOf = {
/** The name of the feature that this change applies to. */
feature: string;
/** The name of this action. */
action: ChangeRequestCreateFeatureSchemaOneOfAction;
payload: ChangeRequestCreateFeatureSchemaOneOfPayload;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import type { ChangeRequestCreateFeatureSchemaOneOfEightPayload } from './change
* Delete a strategy from this feature.
*/
export type ChangeRequestCreateFeatureSchemaOneOfEight = {
/** The name of the feature that this change applies to. */
feature: string;
/** The name of this action. */
action: ChangeRequestCreateFeatureSchemaOneOfEightAction;
payload: ChangeRequestCreateFeatureSchemaOneOfEightPayload;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import type { CreateFeatureStrategySchema } from './createFeatureStrategySchema'
* Add a strategy to the feature
*/
export type ChangeRequestCreateFeatureSchemaOneOfFour = {
/** The name of the feature that this change applies to. */
feature: string;
/** The name of this action. */
action: ChangeRequestCreateFeatureSchemaOneOfFourAction;
payload: CreateFeatureStrategySchema;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import type { ChangeRequestCreateFeatureSchemaOneOfOneoneAction } from './change
* Archive a feature.
*/
export type ChangeRequestCreateFeatureSchemaOneOfOneone = {
/** The name of the feature that this change applies to. */
feature: string;
/** The name of this action. */
action: ChangeRequestCreateFeatureSchemaOneOfOneoneAction;
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import type { SetStrategySortOrderSchema } from './setStrategySortOrderSchema';
* Reorder strategies for this feature
*/
export type ChangeRequestCreateFeatureSchemaOneOfOnesix = {
/** The name of the feature that this change applies to. */
feature: string;
/** The name of this action. */
action: ChangeRequestCreateFeatureSchemaOneOfOnesixAction;
payload: SetStrategySortOrderSchema;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import type { ChangeRequestCreateFeatureSchemaOneOfOnethreePayload } from './cha
* Update variants for this feature.
*/
export type ChangeRequestCreateFeatureSchemaOneOfOnethree = {
/** The name of the feature that this change applies to. */
feature: string;
/** The name of this action. */
action: ChangeRequestCreateFeatureSchemaOneOfOnethreeAction;
payload: ChangeRequestCreateFeatureSchemaOneOfOnethreePayload;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import type { UpdateFeatureStrategySchema } from './updateFeatureStrategySchema'
* Update a strategy belonging to this feature.
*/
export type ChangeRequestCreateFeatureSchemaOneOfSix = {
/** The name of the feature that this change applies to. */
feature: string;
/** The name of this action. */
action: ChangeRequestCreateFeatureSchemaOneOfSixAction;
payload: UpdateFeatureStrategySchema;
Expand Down
22 changes: 18 additions & 4 deletions frontend/src/openapi/models/changeRequestCreateSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,26 @@
* Do not edit manually.
* See `gen:api` script in package.json
*/
import type { ChangeRequestCreateSegmentSchema } from './changeRequestCreateSegmentSchema';
import type { ChangeRequestCreateFeatureSchema } from './changeRequestCreateFeatureSchema';
import type { ChangeRequestCreateSchemaOneOf } from './changeRequestCreateSchemaOneOf';
import type { ChangeRequestCreateSchemaOneOfThree } from './changeRequestCreateSchemaOneOfThree';
import type { ChangeRequestCreateSchemaOneOfSix } from './changeRequestCreateSchemaOneOfSix';
import type { ChangeRequestCreateSchemaOneOfNine } from './changeRequestCreateSchemaOneOfNine';
import type { ChangeRequestCreateSchemaOneOfOneone } from './changeRequestCreateSchemaOneOfOneone';
import type { ChangeRequestCreateSchemaOneOfOnethree } from './changeRequestCreateSchemaOneOfOnethree';
import type { ChangeRequestCreateSchemaOneOfOnesix } from './changeRequestCreateSchemaOneOfOnesix';
import type { ChangeRequestCreateSchemaOneOfOneeight } from './changeRequestCreateSchemaOneOfOneeight';
import type { ChangeRequestCreateSchemaOneOfTwoone } from './changeRequestCreateSchemaOneOfTwoone';

/**
* Data used to create a [change request](https://docs.getunleash.io/reference/change-requests) for a single feature or segment change.
*/
export type ChangeRequestCreateSchema =
| ChangeRequestCreateSegmentSchema
| ChangeRequestCreateFeatureSchema;
| ChangeRequestCreateSchemaOneOf
| ChangeRequestCreateSchemaOneOfThree
| ChangeRequestCreateSchemaOneOfSix
| ChangeRequestCreateSchemaOneOfNine
| ChangeRequestCreateSchemaOneOfOneone
| ChangeRequestCreateSchemaOneOfOnethree
| ChangeRequestCreateSchemaOneOfOnesix
| ChangeRequestCreateSchemaOneOfOneeight
| ChangeRequestCreateSchemaOneOfTwoone;
13 changes: 13 additions & 0 deletions frontend/src/openapi/models/changeRequestCreateSchemaOneOf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
import type { ChangeRequestCreateSchemaOneOfAction } from './changeRequestCreateSchemaOneOfAction';
import type { UpsertSegmentSchema } from './upsertSegmentSchema';

export type ChangeRequestCreateSchemaOneOf = {
/** The name of this action. */
action: ChangeRequestCreateSchemaOneOfAction;
payload: UpsertSegmentSchema;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/

/**
* The name of this action.
*/
export type ChangeRequestCreateSchemaOneOfAction =
typeof ChangeRequestCreateSchemaOneOfAction[keyof typeof ChangeRequestCreateSchemaOneOfAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const ChangeRequestCreateSchemaOneOfAction = {
updateSegment: 'updateSegment',
} as const;
18 changes: 18 additions & 0 deletions frontend/src/openapi/models/changeRequestCreateSchemaOneOfNine.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
import type { ChangeRequestCreateSchemaOneOfNineAction } from './changeRequestCreateSchemaOneOfNineAction';
import type { CreateFeatureStrategySchema } from './createFeatureStrategySchema';

/**
* Add a strategy to the feature
*/
export type ChangeRequestCreateSchemaOneOfNine = {
/** The name of the feature that this change applies to. */
feature: string;
/** The name of this action. */
action: ChangeRequestCreateSchemaOneOfNineAction;
payload: CreateFeatureStrategySchema;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/

/**
* The name of this action.
*/
export type ChangeRequestCreateSchemaOneOfNineAction =
typeof ChangeRequestCreateSchemaOneOfNineAction[keyof typeof ChangeRequestCreateSchemaOneOfNineAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const ChangeRequestCreateSchemaOneOfNineAction = {
addStrategy: 'addStrategy',
} as const;
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
import type { ChangeRequestCreateSchemaOneOfOneeightAction } from './changeRequestCreateSchemaOneOfOneeightAction';
import type { ChangeRequestCreateSchemaOneOfOneeightPayload } from './changeRequestCreateSchemaOneOfOneeightPayload';

/**
* Update variants for this feature.
*/
export type ChangeRequestCreateSchemaOneOfOneeight = {
/** The name of the feature that this change applies to. */
feature: string;
/** The name of this action. */
action: ChangeRequestCreateSchemaOneOfOneeightAction;
payload: ChangeRequestCreateSchemaOneOfOneeightPayload;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/

/**
* The name of this action.
*/
export type ChangeRequestCreateSchemaOneOfOneeightAction =
typeof ChangeRequestCreateSchemaOneOfOneeightAction[keyof typeof ChangeRequestCreateSchemaOneOfOneeightAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const ChangeRequestCreateSchemaOneOfOneeightAction = {
patchVariant: 'patchVariant',
} as const;
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
import type { VariantSchema } from './variantSchema';

export type ChangeRequestCreateSchemaOneOfOneeightPayload = {
variants: VariantSchema[];
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/
import type { ChangeRequestCreateSchemaOneOfOneoneAction } from './changeRequestCreateSchemaOneOfOneoneAction';
import type { UpdateFeatureStrategySchema } from './updateFeatureStrategySchema';

/**
* Update a strategy belonging to this feature.
*/
export type ChangeRequestCreateSchemaOneOfOneone = {
/** The name of the feature that this change applies to. */
feature: string;
/** The name of this action. */
action: ChangeRequestCreateSchemaOneOfOneoneAction;
payload: UpdateFeatureStrategySchema;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Generated by Orval
* Do not edit manually.
* See `gen:api` script in package.json
*/

/**
* The name of this action.
*/
export type ChangeRequestCreateSchemaOneOfOneoneAction =
typeof ChangeRequestCreateSchemaOneOfOneoneAction[keyof typeof ChangeRequestCreateSchemaOneOfOneoneAction];

// eslint-disable-next-line @typescript-eslint/no-redeclare
export const ChangeRequestCreateSchemaOneOfOneoneAction = {
updateStrategy: 'updateStrategy',
} as const;
Loading

0 comments on commit 751bc46

Please sign in to comment.