mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-10 01:16:39 +02:00
Feat/apply changes api (#2276)
* feat: initial setup * fix: add types for suggest changes payload * feat: add types for change events * fix: change param order * fix: remove enum * fix: remove unused method * fix: remove method from interface
This commit is contained in:
parent
95da63c8c7
commit
b2c099a1c0
@ -381,10 +381,10 @@ export interface ISuggestChangeFeature {
|
||||
changes: ISuggestChange[];
|
||||
}
|
||||
|
||||
export interface ISuggestChange {
|
||||
export interface ISuggestChangeBase {
|
||||
id?: number;
|
||||
action: SuggestChangeAction;
|
||||
payload: any;
|
||||
payload: SuggestChangePayload;
|
||||
createdBy?: Pick<User, 'id' | 'username' | 'imageUrl'>;
|
||||
createdAt?: Date;
|
||||
}
|
||||
@ -397,13 +397,66 @@ export enum SuggestChangesetState {
|
||||
CANCELLED = 'Cancelled',
|
||||
}
|
||||
|
||||
export enum SuggestChangeAction {
|
||||
UPDATE_ENABLED = 'updateEnabled',
|
||||
ADD_STRATEGY = 'strategyAdd',
|
||||
UPDATE_STRATEGY = 'strategyUpdate',
|
||||
DELETE_STRATEGY = 'strategyDelete',
|
||||
type SuggestChangePayload =
|
||||
| SuggestChangeEnabled
|
||||
| SuggestChangeAddStrategy
|
||||
| SuggestChangeEditStrategy
|
||||
| SuggestChangeDeleteStrategy;
|
||||
|
||||
export interface ISuggestChangeAddStrategy extends ISuggestChangeBase {
|
||||
action: 'addStrategy';
|
||||
payload: SuggestChangeAddStrategy;
|
||||
}
|
||||
|
||||
export interface ISuggestChangeDeleteStrategy extends ISuggestChangeBase {
|
||||
action: 'deleteStrategy';
|
||||
payload: SuggestChangeDeleteStrategy;
|
||||
}
|
||||
|
||||
export interface ISuggestChangeUpdateStrategy extends ISuggestChangeBase {
|
||||
action: 'updateStrategy';
|
||||
payload: SuggestChangeEditStrategy;
|
||||
}
|
||||
|
||||
export interface ISuggestChangeEnabled extends ISuggestChangeBase {
|
||||
action: 'updateEnabled';
|
||||
payload: SuggestChangeEnabled;
|
||||
}
|
||||
|
||||
export type ISuggestChange =
|
||||
| ISuggestChangeAddStrategy
|
||||
| ISuggestChangeDeleteStrategy
|
||||
| ISuggestChangeUpdateStrategy
|
||||
| ISuggestChangeEnabled;
|
||||
|
||||
type SuggestChangeEnabled = { enabled: boolean };
|
||||
|
||||
type SuggestChangeAddStrategy = Pick<
|
||||
IFeatureStrategy,
|
||||
'parameters' | 'constraints'
|
||||
> & { name: string };
|
||||
|
||||
type SuggestChangeEditStrategy = SuggestChangeAddStrategy & { id: string };
|
||||
|
||||
type SuggestChangeDeleteStrategy = {
|
||||
deleteId: string;
|
||||
};
|
||||
|
||||
export enum SuggestChangesetEvent {
|
||||
CREATED = 'CREATED',
|
||||
UPDATED = 'UPDATED',
|
||||
SUBMITTED = 'SUBMITTED',
|
||||
APPROVED = 'APPROVED',
|
||||
REJECTED = 'REJECTED',
|
||||
CLOSED = 'CLOSED',
|
||||
}
|
||||
|
||||
export type SuggestChangeAction =
|
||||
| 'updateEnabled'
|
||||
| 'addStrategy'
|
||||
| 'updateStrategy'
|
||||
| 'deleteStrategy';
|
||||
|
||||
export interface ISuggestChangeEventData {
|
||||
feature: string;
|
||||
data: unknown;
|
||||
|
@ -124,6 +124,20 @@ export default class FakeFeatureStrategiesStore
|
||||
return Promise.resolve(rows);
|
||||
}
|
||||
|
||||
async getFeatureToggleForEnvironment(
|
||||
featureName: string,
|
||||
// eslint-disable-next-line
|
||||
environment: string,
|
||||
): Promise<FeatureToggleWithEnvironment> {
|
||||
const toggle = this.featureToggles.find((f) => f.name === featureName);
|
||||
if (toggle) {
|
||||
return { ...toggle, environments: [] };
|
||||
}
|
||||
throw new NotFoundError(
|
||||
`Could not find feature with name ${featureName}`,
|
||||
);
|
||||
}
|
||||
|
||||
async getFeatureToggleWithEnvs(
|
||||
featureName: string,
|
||||
archived: boolean = false,
|
||||
|
@ -29,7 +29,7 @@ export default class FakeSuggestChangeStore implements ISuggestChangeStore {
|
||||
}
|
||||
|
||||
addChangeToSet(
|
||||
change: PartialSome<ISuggestChange, 'id' | 'createdBy' | 'createdAt'>,
|
||||
change: ISuggestChange,
|
||||
feature: string,
|
||||
changeSetID: number,
|
||||
userId: number,
|
||||
@ -44,6 +44,7 @@ export default class FakeSuggestChangeStore implements ISuggestChangeStore {
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user