mirror of
https://github.com/flarum/framework.git
synced 2025-01-22 07:43:33 +08:00
Add meta to ApiPayload interfaces
This commit is contained in:
parent
b0504597da
commit
0bdb018ad4
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user