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[];
|
changes: ISuggestChange[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISuggestChange {
|
export interface ISuggestChangeBase {
|
||||||
id?: number;
|
id?: number;
|
||||||
action: SuggestChangeAction;
|
action: SuggestChangeAction;
|
||||||
payload: any;
|
payload: SuggestChangePayload;
|
||||||
createdBy?: Pick<User, 'id' | 'username' | 'imageUrl'>;
|
createdBy?: Pick<User, 'id' | 'username' | 'imageUrl'>;
|
||||||
createdAt?: Date;
|
createdAt?: Date;
|
||||||
}
|
}
|
||||||
@ -397,13 +397,66 @@ export enum SuggestChangesetState {
|
|||||||
CANCELLED = 'Cancelled',
|
CANCELLED = 'Cancelled',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SuggestChangeAction {
|
type SuggestChangePayload =
|
||||||
UPDATE_ENABLED = 'updateEnabled',
|
| SuggestChangeEnabled
|
||||||
ADD_STRATEGY = 'strategyAdd',
|
| SuggestChangeAddStrategy
|
||||||
UPDATE_STRATEGY = 'strategyUpdate',
|
| SuggestChangeEditStrategy
|
||||||
DELETE_STRATEGY = 'strategyDelete',
|
| 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 {
|
export interface ISuggestChangeEventData {
|
||||||
feature: string;
|
feature: string;
|
||||||
data: unknown;
|
data: unknown;
|
||||||
|
@ -124,6 +124,20 @@ export default class FakeFeatureStrategiesStore
|
|||||||
return Promise.resolve(rows);
|
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(
|
async getFeatureToggleWithEnvs(
|
||||||
featureName: string,
|
featureName: string,
|
||||||
archived: boolean = false,
|
archived: boolean = false,
|
||||||
|
@ -29,7 +29,7 @@ export default class FakeSuggestChangeStore implements ISuggestChangeStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addChangeToSet(
|
addChangeToSet(
|
||||||
change: PartialSome<ISuggestChange, 'id' | 'createdBy' | 'createdAt'>,
|
change: ISuggestChange,
|
||||||
feature: string,
|
feature: string,
|
||||||
changeSetID: number,
|
changeSetID: number,
|
||||||
userId: number,
|
userId: number,
|
||||||
@ -44,6 +44,7 @@ export default class FakeSuggestChangeStore implements ISuggestChangeStore {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user