Add meta to ApiPayload interfaces

This commit is contained in:
Alexander Skvortsov 2021-12-01 16:04:15 -05:00
parent b0504597da
commit 0bdb018ad4
No known key found for this signature in database
GPG Key ID: C4E3BBF9C3412B4C
2 changed files with 10 additions and 8 deletions

View File

@ -1,6 +1,6 @@
import app from '../common/app';
import { FlarumRequestOptions } from './Application';
import Store, { ApiPayloadSingle, ApiResponseSingle } from './Store';
import Store, { ApiPayloadSingle, ApiResponseSingle, MetaInformation } from './Store';
export interface ModelIdentifier {
type: string;
@ -162,7 +162,7 @@ export default abstract class Model {
*/
save(
attributes: SaveAttributes,
options: Omit<FlarumRequestOptions<ApiPayloadSingle>, 'url'> & { meta?: any } = {}
options: Omit<FlarumRequestOptions<ApiPayloadSingle>, 'url'> & { meta?: MetaInformation } = {}
): Promise<ApiResponseSingle<this>> {
const data: ModelData & { id?: string } = {
type: this.data.type,

View File

@ -2,13 +2,15 @@ import app from '../common/app';
import { FlarumRequestOptions } from './Application';
import Model, { ModelData, SavedModelData } from './Model';
export interface MetaInformation {
[key: string]: any;
}
export interface ApiQueryParamsSingle {
fields?: string[];
include?: string;
bySlug?: boolean;
meta?: {
[key: string]: any;
};
meta?: MetaInformation;
}
export interface ApiQueryParamsPlural {
@ -25,9 +27,7 @@ export interface ApiQueryParamsPlural {
size?: number;
};
sort?: string;
meta?: {
[key: string]: any;
};
meta?: MetaInformation;
}
export type ApiQueryParams = ApiQueryParamsPlural | ApiQueryParamsSingle;
@ -35,6 +35,7 @@ export type ApiQueryParams = ApiQueryParamsPlural | ApiQueryParamsSingle;
export interface ApiPayloadSingle {
data: SavedModelData;
included?: SavedModelData[];
meta?: MetaInformation;
}
export interface ApiPayloadPlural {
@ -45,6 +46,7 @@ export interface ApiPayloadPlural {
next?: string;
prev?: string;
};
meta?: MetaInformation;
}
export type ApiPayload = ApiPayloadSingle | ApiPayloadPlural;