mirror of
https://github.com/flarum/framework.git
synced 2025-01-22 12:33:17 +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 app from '../common/app';
|
||||||
import { FlarumRequestOptions } from './Application';
|
import { FlarumRequestOptions } from './Application';
|
||||||
import Store, { ApiPayloadSingle, ApiResponseSingle } from './Store';
|
import Store, { ApiPayloadSingle, ApiResponseSingle, MetaInformation } from './Store';
|
||||||
|
|
||||||
export interface ModelIdentifier {
|
export interface ModelIdentifier {
|
||||||
type: string;
|
type: string;
|
||||||
|
@ -162,7 +162,7 @@ export default abstract class Model {
|
||||||
*/
|
*/
|
||||||
save(
|
save(
|
||||||
attributes: SaveAttributes,
|
attributes: SaveAttributes,
|
||||||
options: Omit<FlarumRequestOptions<ApiPayloadSingle>, 'url'> & { meta?: any } = {}
|
options: Omit<FlarumRequestOptions<ApiPayloadSingle>, 'url'> & { meta?: MetaInformation } = {}
|
||||||
): Promise<ApiResponseSingle<this>> {
|
): Promise<ApiResponseSingle<this>> {
|
||||||
const data: ModelData & { id?: string } = {
|
const data: ModelData & { id?: string } = {
|
||||||
type: this.data.type,
|
type: this.data.type,
|
||||||
|
|
|
@ -2,13 +2,15 @@ import app from '../common/app';
|
||||||
import { FlarumRequestOptions } from './Application';
|
import { FlarumRequestOptions } from './Application';
|
||||||
import Model, { ModelData, SavedModelData } from './Model';
|
import Model, { ModelData, SavedModelData } from './Model';
|
||||||
|
|
||||||
|
export interface MetaInformation {
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ApiQueryParamsSingle {
|
export interface ApiQueryParamsSingle {
|
||||||
fields?: string[];
|
fields?: string[];
|
||||||
include?: string;
|
include?: string;
|
||||||
bySlug?: boolean;
|
bySlug?: boolean;
|
||||||
meta?: {
|
meta?: MetaInformation;
|
||||||
[key: string]: any;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiQueryParamsPlural {
|
export interface ApiQueryParamsPlural {
|
||||||
|
@ -25,9 +27,7 @@ export interface ApiQueryParamsPlural {
|
||||||
size?: number;
|
size?: number;
|
||||||
};
|
};
|
||||||
sort?: string;
|
sort?: string;
|
||||||
meta?: {
|
meta?: MetaInformation;
|
||||||
[key: string]: any;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ApiQueryParams = ApiQueryParamsPlural | ApiQueryParamsSingle;
|
export type ApiQueryParams = ApiQueryParamsPlural | ApiQueryParamsSingle;
|
||||||
|
@ -35,6 +35,7 @@ export type ApiQueryParams = ApiQueryParamsPlural | ApiQueryParamsSingle;
|
||||||
export interface ApiPayloadSingle {
|
export interface ApiPayloadSingle {
|
||||||
data: SavedModelData;
|
data: SavedModelData;
|
||||||
included?: SavedModelData[];
|
included?: SavedModelData[];
|
||||||
|
meta?: MetaInformation;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiPayloadPlural {
|
export interface ApiPayloadPlural {
|
||||||
|
@ -45,6 +46,7 @@ export interface ApiPayloadPlural {
|
||||||
next?: string;
|
next?: string;
|
||||||
prev?: string;
|
prev?: string;
|
||||||
};
|
};
|
||||||
|
meta?: MetaInformation;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ApiPayload = ApiPayloadSingle | ApiPayloadPlural;
|
export type ApiPayload = ApiPayloadSingle | ApiPayloadPlural;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user