1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-23 00:22:19 +01:00
unleash.unleash/src/lib/segments/segment-service-interface.ts
Gastón Fournier 1d0bc833b3
chore: refactor segments to stop depending on the implementation (#3315)
## About the changes
- Introducing ISegmentService interface to decouple from the actual
implementation
- Moving UpsertSegmentSchema to OSS to be able to use types
- Added comments where our code is coupled with segments just to
highlight and have a conversation about some use cases if needed, but
they can be removed before merging
- Removed segment service from some project features as it was not used
2023-03-15 14:58:19 +01:00

30 lines
752 B
TypeScript

import { UpsertSegmentSchema } from 'lib/openapi';
import { ISegment, IUser } from 'lib/types';
export interface ISegmentService {
updateStrategySegments: (
strategyId: string,
segmentIds: number[],
) => Promise<void>;
addToStrategy(id: number, strategyId: string): Promise<void>;
getByStrategy(strategyId: string): Promise<ISegment[]>;
getActive(): Promise<ISegment[]>;
getAll(): Promise<ISegment[]>;
create(
data: UpsertSegmentSchema,
user: Partial<Pick<IUser, 'username' | 'email'>>,
): Promise<ISegment>;
delete(id: number, user: IUser): Promise<void>;
cloneStrategySegments(
sourceStrategyId: string,
targetStrategyId: string,
): Promise<void>;
}