-
Notifications
You must be signed in to change notification settings - Fork 15
Description
A clear and concise description of what the feature is
I may be misusing and/or not understanding typescript (so tell me when I'm way off the mark), but I would like to decorate SingleTypeManger and CollectionTypeManger. Currently, that's not really possible, so adding interfaces would be great I think. We'd also have to have an option to pass it to a new StrapiClient constructor via a factory method (like is already done for the HttpClient but that's hidden to us users).
Does this make sense?
Why should this feature be included?
Interfaces for the main client components would enhance type flexibility, clarity, and extensibility, as well as decoratability
Please provide an example for how this would work
Currently, I have a RetryingCollectionTypeManagerAdapter. Adding an exported interface ICollectionTypeManager without the private fields would make it possible to implement and decorate the CollectionTypeManager. Example:
interface ICollectionTypeManager {
find(queryParams?: API.BaseQueryParams): Promise<API.DocumentResponseCollection>;
findOne(documentID: string, queryParams?: API.BaseQueryParams): Promise<API.DocumentResponse>;
create(data: Record<string, any>, queryParams?: API.BaseQueryParams): Promise<API.DocumentResponse>;
update(documentID: string, data: Record<string, unknown>, queryParams?: API.BaseQueryParams): Promise<API.DocumentResponse>;
delete(documentID: string, queryParams?: API.BaseQueryParams): Promise<void>;
}would allow
class RetryingCollectionTypeManagerDecorator implements ICollectionTypeManager {
...
}That could then be injected in a new StrapiClient constructur that allows passing a factory for both, giving full control over the inner workings. I could then also implement a new IStrapiClient interface allowing for easier decoration and passing of that.