mirror of
https://github.com/flarum/framework.git
synced 2025-02-27 06:52:10 +08:00
Bundled output for commit 17db36fb3cdc32a398f87aa9ee8dd0a1a831cad5
Includes transpiled JS/TS, and Typescript declaration files (typings). [skip ci]
This commit is contained in:
parent
17db36fb3c
commit
d2a952d264
@ -46,6 +46,17 @@ declare const app: never;
|
|||||||
declare const m: import('mithril').Static;
|
declare const m: import('mithril').Static;
|
||||||
declare const dayjs: typeof import('dayjs');
|
declare const dayjs: typeof import('dayjs');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From https://github.com/lokesh/color-thief/issues/188
|
||||||
|
*/
|
||||||
|
declare module 'color-thief-browser' {
|
||||||
|
type Color = [number, number, number];
|
||||||
|
export default class ColorThief {
|
||||||
|
getColor: (img: HTMLImageElement | null) => Color;
|
||||||
|
getPalette: (img: HTMLImageElement | null) => Color[];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type ESModule = { __esModule: true; [key: string]: unknown };
|
type ESModule = { __esModule: true; [key: string]: unknown };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +35,7 @@ export default class AdminApplication extends Application {
|
|||||||
history: {
|
history: {
|
||||||
canGoBack: () => boolean;
|
canGoBack: () => boolean;
|
||||||
getPrevious: () => void;
|
getPrevious: () => void;
|
||||||
backUrl: () => any;
|
backUrl: () => string;
|
||||||
back: () => void;
|
back: () => void;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
|
@ -3,6 +3,6 @@ export default class ReadmeModal extends Modal<import("../../common/components/M
|
|||||||
name: any;
|
name: any;
|
||||||
extName: any;
|
extName: any;
|
||||||
loadReadme(): Promise<void>;
|
loadReadme(): Promise<void>;
|
||||||
readme: any;
|
readme: import("../../common/Store").ApiResponseSingle<import("../../common/Model").default> | undefined;
|
||||||
}
|
}
|
||||||
import Modal from "../../common/components/Modal";
|
import Modal from "../../common/components/Modal";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/// <reference path="../../../src/common/translator-icu-rich.d.ts" />
|
/// <reference path="../../../src/common/translator-icu-rich.d.ts" />
|
||||||
/// <reference types="mithril" />
|
import type Mithril from 'mithril';
|
||||||
import type User from '../../common/models/User';
|
import type User from '../../common/models/User';
|
||||||
import ItemList from '../../common/utils/ItemList';
|
import ItemList from '../../common/utils/ItemList';
|
||||||
import AdminPage from './AdminPage';
|
import AdminPage from './AdminPage';
|
||||||
@ -11,7 +11,7 @@ declare type ColumnData = {
|
|||||||
/**
|
/**
|
||||||
* Component(s) to show for this column.
|
* Component(s) to show for this column.
|
||||||
*/
|
*/
|
||||||
content: (user: User) => JSX.Element;
|
content: (user: User) => Mithril.Children;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Admin page which displays a paginated list of all users on the forum.
|
* Admin page which displays a paginated list of all users on the forum.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export default class ExtensionReadme extends Model {
|
export default class ExtensionReadme extends Model {
|
||||||
content: any;
|
content: () => any;
|
||||||
}
|
}
|
||||||
import Model from "../../common/Model";
|
import Model from "../../common/Model";
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import ItemList from './utils/ItemList';
|
import ItemList from './utils/ItemList';
|
||||||
import Translator from './Translator';
|
import Translator from './Translator';
|
||||||
import Store from './Store';
|
import Store, { ApiPayload, ApiResponsePlural, ApiResponseSingle } from './Store';
|
||||||
import Session from './Session';
|
import Session from './Session';
|
||||||
import Drawer from './utils/Drawer';
|
import Drawer from './utils/Drawer';
|
||||||
import RequestError, { InternalFlarumRequestOptions } from './utils/RequestError';
|
import RequestError, { InternalFlarumRequestOptions } from './utils/RequestError';
|
||||||
@ -12,6 +12,7 @@ import type DefaultResolver from './resolvers/DefaultResolver';
|
|||||||
import type Mithril from 'mithril';
|
import type Mithril from 'mithril';
|
||||||
import type Component from './Component';
|
import type Component from './Component';
|
||||||
import type { ComponentAttrs } from './Component';
|
import type { ComponentAttrs } from './Component';
|
||||||
|
import Model, { SavedModelData } from './Model';
|
||||||
export declare type FlarumScreens = 'phone' | 'tablet' | 'desktop' | 'desktop-hd';
|
export declare type FlarumScreens = 'phone' | 'tablet' | 'desktop' | 'desktop-hd';
|
||||||
export declare type FlarumGenericRoute = RouteItem<any, any, any>;
|
export declare type FlarumGenericRoute = RouteItem<any, any, any>;
|
||||||
export interface FlarumRequestOptions<ResponseType> extends Omit<Mithril.RequestOptions<ResponseType>, 'extract'> {
|
export interface FlarumRequestOptions<ResponseType> extends Omit<Mithril.RequestOptions<ResponseType>, 'extract'> {
|
||||||
@ -159,10 +160,10 @@ export default class Application {
|
|||||||
*/
|
*/
|
||||||
drawer: Drawer;
|
drawer: Drawer;
|
||||||
data: {
|
data: {
|
||||||
apiDocument: Record<string, unknown> | null;
|
apiDocument: ApiPayload | null;
|
||||||
locale: string;
|
locale: string;
|
||||||
locales: Record<string, string>;
|
locales: Record<string, string>;
|
||||||
resources: Record<string, unknown>[];
|
resources: SavedModelData[];
|
||||||
session: {
|
session: {
|
||||||
userId: number;
|
userId: number;
|
||||||
csrfToken: string;
|
csrfToken: string;
|
||||||
@ -190,7 +191,8 @@ export default class Application {
|
|||||||
/**
|
/**
|
||||||
* Get the API response document that has been preloaded into the application.
|
* Get the API response document that has been preloaded into the application.
|
||||||
*/
|
*/
|
||||||
preloadedApiDocument(): Record<string, unknown> | null;
|
preloadedApiDocument<M extends Model>(): ApiResponseSingle<M> | null;
|
||||||
|
preloadedApiDocument<Ms extends Model[]>(): ApiResponsePlural<Ms[number]> | null;
|
||||||
/**
|
/**
|
||||||
* Determine the current screen mode, based on our media queries.
|
* Determine the current screen mode, based on our media queries.
|
||||||
*/
|
*/
|
||||||
@ -217,7 +219,7 @@ export default class Application {
|
|||||||
* @param options
|
* @param options
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
request<ResponseType>(originalOptions: FlarumRequestOptions<ResponseType>): Promise<ResponseType | string>;
|
request<ResponseType>(originalOptions: FlarumRequestOptions<ResponseType>): Promise<ResponseType>;
|
||||||
/**
|
/**
|
||||||
* By default, show an error alert, and log the error to the console.
|
* By default, show an error alert, and log the error to the console.
|
||||||
*/
|
*/
|
||||||
|
197
framework/core/js/dist-typings/common/Model.d.ts
vendored
197
framework/core/js/dist-typings/common/Model.d.ts
vendored
@ -1,149 +1,148 @@
|
|||||||
|
import { FlarumRequestOptions } from './Application';
|
||||||
|
import Store, { ApiPayloadSingle, ApiResponseSingle, MetaInformation } from './Store';
|
||||||
|
export interface ModelIdentifier {
|
||||||
|
type: string;
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
export interface ModelAttributes {
|
||||||
|
[key: string]: unknown;
|
||||||
|
}
|
||||||
|
export interface ModelRelationships {
|
||||||
|
[relationship: string]: {
|
||||||
|
data: ModelIdentifier | ModelIdentifier[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export interface UnsavedModelData {
|
||||||
|
type?: string;
|
||||||
|
attributes?: ModelAttributes;
|
||||||
|
relationships?: ModelRelationships;
|
||||||
|
}
|
||||||
|
export interface SavedModelData {
|
||||||
|
type: string;
|
||||||
|
id: string;
|
||||||
|
attributes?: ModelAttributes;
|
||||||
|
relationships?: ModelRelationships;
|
||||||
|
}
|
||||||
|
export declare type ModelData = UnsavedModelData | SavedModelData;
|
||||||
|
interface SaveRelationships {
|
||||||
|
[relationship: string]: Model | Model[];
|
||||||
|
}
|
||||||
|
interface SaveAttributes {
|
||||||
|
[key: string]: unknown;
|
||||||
|
relationships?: SaveRelationships;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* The `Model` class represents a local data resource. It provides methods to
|
* The `Model` class represents a local data resource. It provides methods to
|
||||||
* persist changes via the API.
|
* persist changes via the API.
|
||||||
*
|
|
||||||
* @abstract
|
|
||||||
*/
|
*/
|
||||||
export default class Model {
|
export default abstract class Model {
|
||||||
/**
|
|
||||||
* Generate a function which returns the value of the given attribute.
|
|
||||||
*
|
|
||||||
* @param {String} name
|
|
||||||
* @param {function} [transform] A function to transform the attribute value
|
|
||||||
* @return {*}
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
public static attribute(name: string, transform?: Function | undefined): any;
|
|
||||||
/**
|
|
||||||
* Generate a function which returns the value of the given has-one
|
|
||||||
* relationship.
|
|
||||||
*
|
|
||||||
* @param {String} name
|
|
||||||
* @return {Model|Boolean|undefined} false if no information about the
|
|
||||||
* relationship exists; undefined if the relationship exists but the model
|
|
||||||
* has not been loaded; or the model if it has been loaded.
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
public static hasOne(name: string): Model | boolean | undefined;
|
|
||||||
/**
|
|
||||||
* Generate a function which returns the value of the given has-many
|
|
||||||
* relationship.
|
|
||||||
*
|
|
||||||
* @param {String} name
|
|
||||||
* @return {Array|Boolean} false if no information about the relationship
|
|
||||||
* exists; an array if it does, containing models if they have been
|
|
||||||
* loaded, and undefined for those that have not.
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
public static hasMany(name: string): any[] | boolean;
|
|
||||||
/**
|
|
||||||
* Transform the given value into a Date object.
|
|
||||||
*
|
|
||||||
* @param {String} value
|
|
||||||
* @return {Date|null}
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
public static transformDate(value: string): Date | null;
|
|
||||||
/**
|
|
||||||
* Get a resource identifier object for the given model.
|
|
||||||
*
|
|
||||||
* @param {Model} model
|
|
||||||
* @return {Object}
|
|
||||||
* @protected
|
|
||||||
*/
|
|
||||||
protected static getIdentifier(model: Model): Object;
|
|
||||||
/**
|
|
||||||
* @param {Object} data A resource object from the API.
|
|
||||||
* @param {Store} store The data store that this model should be persisted to.
|
|
||||||
* @public
|
|
||||||
*/
|
|
||||||
constructor(data?: Object, store?: any);
|
|
||||||
/**
|
/**
|
||||||
* The resource object from the API.
|
* The resource object from the API.
|
||||||
*
|
|
||||||
* @type {Object}
|
|
||||||
* @public
|
|
||||||
*/
|
*/
|
||||||
public data: Object;
|
data: ModelData;
|
||||||
/**
|
/**
|
||||||
* The time at which the model's data was last updated. Watching the value
|
* The time at which the model's data was last updated. Watching the value
|
||||||
* of this property is a fast way to retain/cache a subtree if data hasn't
|
* of this property is a fast way to retain/cache a subtree if data hasn't
|
||||||
* changed.
|
* changed.
|
||||||
*
|
|
||||||
* @type {Date}
|
|
||||||
* @public
|
|
||||||
*/
|
*/
|
||||||
public freshness: Date;
|
freshness: Date;
|
||||||
/**
|
/**
|
||||||
* Whether or not the resource exists on the server.
|
* Whether or not the resource exists on the server.
|
||||||
*
|
|
||||||
* @type {Boolean}
|
|
||||||
* @public
|
|
||||||
*/
|
*/
|
||||||
public exists: boolean;
|
exists: boolean;
|
||||||
/**
|
/**
|
||||||
* The data store that this resource should be persisted to.
|
* The data store that this resource should be persisted to.
|
||||||
*
|
|
||||||
* @type {Store}
|
|
||||||
* @protected
|
|
||||||
*/
|
*/
|
||||||
protected store: any;
|
protected store: Store;
|
||||||
|
/**
|
||||||
|
* @param data A resource object from the API.
|
||||||
|
* @param store The data store that this model should be persisted to.
|
||||||
|
*/
|
||||||
|
constructor(data?: ModelData, store?: Store);
|
||||||
/**
|
/**
|
||||||
* Get the model's ID.
|
* Get the model's ID.
|
||||||
*
|
*
|
||||||
* @return {Integer}
|
|
||||||
* @public
|
|
||||||
* @final
|
* @final
|
||||||
*/
|
*/
|
||||||
public id(): any;
|
id(): string | undefined;
|
||||||
/**
|
/**
|
||||||
* Get one of the model's attributes.
|
* Get one of the model's attributes.
|
||||||
*
|
*
|
||||||
* @param {String} attribute
|
|
||||||
* @return {*}
|
|
||||||
* @public
|
|
||||||
* @final
|
* @final
|
||||||
*/
|
*/
|
||||||
public attribute(attribute: string): any;
|
attribute<T = unknown>(attribute: string): T;
|
||||||
/**
|
/**
|
||||||
* Merge new data into this model locally.
|
* Merge new data into this model locally.
|
||||||
*
|
*
|
||||||
* @param {Object} data A resource object to merge into this model
|
* @param data A resource object to merge into this model
|
||||||
* @public
|
|
||||||
*/
|
*/
|
||||||
public pushData(data: Object): void;
|
pushData(data: ModelData | {
|
||||||
|
relationships?: SaveRelationships;
|
||||||
|
}): this;
|
||||||
/**
|
/**
|
||||||
* Merge new attributes into this model locally.
|
* Merge new attributes into this model locally.
|
||||||
*
|
*
|
||||||
* @param {Object} attributes The attributes to merge.
|
* @param attributes The attributes to merge.
|
||||||
* @public
|
|
||||||
*/
|
*/
|
||||||
public pushAttributes(attributes: Object): void;
|
pushAttributes(attributes: ModelAttributes): void;
|
||||||
/**
|
/**
|
||||||
* Merge new attributes into this model, both locally and with persistence.
|
* Merge new attributes into this model, both locally and with persistence.
|
||||||
*
|
*
|
||||||
* @param {Object} attributes The attributes to save. If a 'relationships' key
|
* @param attributes The attributes to save. If a 'relationships' key
|
||||||
* exists, it will be extracted and relationships will also be saved.
|
* exists, it will be extracted and relationships will also be saved.
|
||||||
* @param {Object} [options]
|
|
||||||
* @return {Promise}
|
|
||||||
* @public
|
|
||||||
*/
|
*/
|
||||||
public save(attributes: Object, options?: Object | undefined): Promise<any>;
|
save(attributes: SaveAttributes, options?: Omit<FlarumRequestOptions<ApiPayloadSingle>, 'url'> & {
|
||||||
|
meta?: MetaInformation;
|
||||||
|
}): Promise<ApiResponseSingle<this>>;
|
||||||
/**
|
/**
|
||||||
* Send a request to delete the resource.
|
* Send a request to delete the resource.
|
||||||
*
|
*
|
||||||
* @param {Object} body Data to send along with the DELETE request.
|
* @param body Data to send along with the DELETE request.
|
||||||
* @param {Object} [options]
|
|
||||||
* @return {Promise}
|
|
||||||
* @public
|
|
||||||
*/
|
*/
|
||||||
public delete(body: Object, options?: Object | undefined): Promise<any>;
|
delete(body?: FlarumRequestOptions<void>['body'], options?: Omit<FlarumRequestOptions<void>, 'url'>): Promise<void>;
|
||||||
/**
|
/**
|
||||||
* Construct a path to the API endpoint for this resource.
|
* Construct a path to the API endpoint for this resource.
|
||||||
*
|
|
||||||
* @return {String}
|
|
||||||
* @protected
|
|
||||||
*/
|
*/
|
||||||
protected apiEndpoint(): string;
|
protected apiEndpoint(): string;
|
||||||
copyData(): any;
|
protected copyData(): ModelData;
|
||||||
|
protected rawRelationship<M extends Model>(relationship: string): undefined | ModelIdentifier;
|
||||||
|
protected rawRelationship<M extends Model[]>(relationship: string): undefined | ModelIdentifier[];
|
||||||
|
/**
|
||||||
|
* Generate a function which returns the value of the given attribute.
|
||||||
|
*
|
||||||
|
* @param transform A function to transform the attribute value
|
||||||
|
*/
|
||||||
|
static attribute<T>(name: string): () => T;
|
||||||
|
static attribute<T, O = unknown>(name: string, transform: (attr: O) => T): () => T;
|
||||||
|
/**
|
||||||
|
* Generate a function which returns the value of the given has-one
|
||||||
|
* relationship.
|
||||||
|
*
|
||||||
|
* @return false if no information about the
|
||||||
|
* relationship exists; undefined if the relationship exists but the model
|
||||||
|
* has not been loaded; or the model if it has been loaded.
|
||||||
|
*/
|
||||||
|
static hasOne<M extends Model>(name: string): () => M | false;
|
||||||
|
static hasOne<M extends Model | null>(name: string): () => M | null | false;
|
||||||
|
/**
|
||||||
|
* Generate a function which returns the value of the given has-many
|
||||||
|
* relationship.
|
||||||
|
*
|
||||||
|
* @return false if no information about the relationship
|
||||||
|
* exists; an array if it does, containing models if they have been
|
||||||
|
* loaded, and undefined for those that have not.
|
||||||
|
*/
|
||||||
|
static hasMany<M extends Model>(name: string): () => (M | undefined)[] | false;
|
||||||
|
/**
|
||||||
|
* Transform the given value into a Date object.
|
||||||
|
*/
|
||||||
|
static transformDate(value: string): Date;
|
||||||
|
static transformDate(value: string | null): Date | null;
|
||||||
|
static transformDate(value: string | undefined): Date | undefined;
|
||||||
|
static transformDate(value: string | null | undefined): Date | null | undefined;
|
||||||
|
/**
|
||||||
|
* Get a resource identifier object for the given model.
|
||||||
|
*/
|
||||||
|
protected static getIdentifier(model: Model): ModelIdentifier;
|
||||||
}
|
}
|
||||||
|
export {};
|
||||||
|
134
framework/core/js/dist-typings/common/Store.d.ts
vendored
134
framework/core/js/dist-typings/common/Store.d.ts
vendored
@ -1,97 +1,127 @@
|
|||||||
|
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?: MetaInformation;
|
||||||
|
}
|
||||||
|
export interface ApiQueryParamsPlural {
|
||||||
|
fields?: string[];
|
||||||
|
include?: string;
|
||||||
|
filter?: {
|
||||||
|
q: string;
|
||||||
|
[key: string]: string;
|
||||||
|
};
|
||||||
|
page?: {
|
||||||
|
offset?: number;
|
||||||
|
number?: number;
|
||||||
|
limit?: number;
|
||||||
|
size?: number;
|
||||||
|
};
|
||||||
|
sort?: string;
|
||||||
|
meta?: MetaInformation;
|
||||||
|
}
|
||||||
|
export declare type ApiQueryParams = ApiQueryParamsPlural | ApiQueryParamsSingle;
|
||||||
|
export interface ApiPayloadSingle {
|
||||||
|
data: SavedModelData;
|
||||||
|
included?: SavedModelData[];
|
||||||
|
meta?: MetaInformation;
|
||||||
|
}
|
||||||
|
export interface ApiPayloadPlural {
|
||||||
|
data: SavedModelData[];
|
||||||
|
included?: SavedModelData[];
|
||||||
|
links?: {
|
||||||
|
first: string;
|
||||||
|
next?: string;
|
||||||
|
prev?: string;
|
||||||
|
};
|
||||||
|
meta?: MetaInformation;
|
||||||
|
}
|
||||||
|
export declare type ApiPayload = ApiPayloadSingle | ApiPayloadPlural;
|
||||||
|
export declare type ApiResponseSingle<M extends Model> = M & {
|
||||||
|
payload: ApiPayloadSingle;
|
||||||
|
};
|
||||||
|
export declare type ApiResponsePlural<M extends Model> = M[] & {
|
||||||
|
payload: ApiPayloadPlural;
|
||||||
|
};
|
||||||
|
export declare type ApiResponse<M extends Model> = ApiResponseSingle<M> | ApiResponsePlural<M>;
|
||||||
|
interface ApiQueryRequestOptions<ResponseType> extends Omit<FlarumRequestOptions<ResponseType>, 'url'> {
|
||||||
|
}
|
||||||
|
interface StoreData {
|
||||||
|
[type: string]: Partial<Record<string, Model>>;
|
||||||
|
}
|
||||||
|
export declare function payloadIsPlural(payload: ApiPayload): payload is ApiPayloadPlural;
|
||||||
/**
|
/**
|
||||||
* The `Store` class defines a local data store, and provides methods to
|
* The `Store` class defines a local data store, and provides methods to
|
||||||
* retrieve data from the API.
|
* retrieve data from the API.
|
||||||
*/
|
*/
|
||||||
export default class Store {
|
export default class Store {
|
||||||
constructor(models: any);
|
|
||||||
/**
|
/**
|
||||||
* The local data store. A tree of resource types to IDs, such that
|
* The local data store. A tree of resource types to IDs, such that
|
||||||
* accessing data[type][id] will return the model for that type/ID.
|
* accessing data[type][id] will return the model for that type/ID.
|
||||||
*
|
|
||||||
* @type {Object}
|
|
||||||
* @protected
|
|
||||||
*/
|
*/
|
||||||
protected data: Object;
|
protected data: StoreData;
|
||||||
/**
|
/**
|
||||||
* The model registry. A map of resource types to the model class that
|
* The model registry. A map of resource types to the model class that
|
||||||
* should be used to represent resources of that type.
|
* should be used to represent resources of that type.
|
||||||
*
|
|
||||||
* @type {Object}
|
|
||||||
* @public
|
|
||||||
*/
|
*/
|
||||||
public models: Object;
|
models: Record<string, typeof Model>;
|
||||||
|
constructor(models: Record<string, typeof Model>);
|
||||||
/**
|
/**
|
||||||
* Push resources contained within an API payload into the store.
|
* Push resources contained within an API payload into the store.
|
||||||
*
|
*
|
||||||
* @param {Object} payload
|
* @return The model(s) representing the resource(s) contained
|
||||||
* @return {Model|Model[]} The model(s) representing the resource(s) contained
|
|
||||||
* within the 'data' key of the payload.
|
* within the 'data' key of the payload.
|
||||||
* @public
|
|
||||||
*/
|
*/
|
||||||
public pushPayload(payload: Object): any | any[];
|
pushPayload<M extends Model>(payload: ApiPayloadSingle): ApiResponseSingle<M>;
|
||||||
|
pushPayload<Ms extends Model[]>(payload: ApiPayloadPlural): ApiResponseSingle<Ms[number]>;
|
||||||
/**
|
/**
|
||||||
* Create a model to represent a resource object (or update an existing one),
|
* Create a model to represent a resource object (or update an existing one),
|
||||||
* and push it into the store.
|
* and push it into the store.
|
||||||
*
|
*
|
||||||
* @param {Object} data The resource object
|
* @param data The resource object
|
||||||
* @return {Model|null} The model, or null if no model class has been
|
* @return The model, or null if no model class has been
|
||||||
* registered for this resource type.
|
* registered for this resource type.
|
||||||
* @public
|
|
||||||
*/
|
*/
|
||||||
public pushObject(data: Object): any | null;
|
pushObject<M extends Model>(data: SavedModelData): M | null;
|
||||||
|
pushObject<M extends Model>(data: SavedModelData, allowUnregistered: false): M;
|
||||||
/**
|
/**
|
||||||
* Make a request to the API to find record(s) of a specific type.
|
* Make a request to the API to find record(s) of a specific type.
|
||||||
*
|
|
||||||
* @param {String} type The resource type.
|
|
||||||
* @param {Integer|Integer[]|Object} [id] The ID(s) of the model(s) to retrieve.
|
|
||||||
* Alternatively, if an object is passed, it will be handled as the
|
|
||||||
* `query` parameter.
|
|
||||||
* @param {Object} [query]
|
|
||||||
* @param {Object} [options]
|
|
||||||
* @return {Promise}
|
|
||||||
* @public
|
|
||||||
*/
|
*/
|
||||||
public find(type: string, id?: any | any[] | Object, query?: Object | undefined, options?: Object | undefined): Promise<any>;
|
find<M extends Model>(type: string, params: ApiQueryParamsSingle): Promise<ApiResponseSingle<M>>;
|
||||||
|
find<Ms extends Model[]>(type: string, params: ApiQueryParamsPlural): Promise<ApiResponsePlural<Ms[number]>>;
|
||||||
|
find<M extends Model>(type: string, id: string, params?: ApiQueryParamsSingle, options?: ApiQueryRequestOptions<ApiPayloadSingle>): Promise<ApiResponseSingle<M>>;
|
||||||
|
find<Ms extends Model[]>(type: string, ids: string[], params?: ApiQueryParamsPlural, options?: ApiQueryRequestOptions<ApiPayloadPlural>): Promise<ApiResponsePlural<Ms[number]>>;
|
||||||
/**
|
/**
|
||||||
* Get a record from the store by ID.
|
* Get a record from the store by ID.
|
||||||
*
|
|
||||||
* @param {String} type The resource type.
|
|
||||||
* @param {Integer} id The resource ID.
|
|
||||||
* @return {Model}
|
|
||||||
* @public
|
|
||||||
*/
|
*/
|
||||||
public getById(type: string, id: any): any;
|
getById<M extends Model>(type: string, id: string): M | undefined;
|
||||||
/**
|
/**
|
||||||
* Get a record from the store by the value of a model attribute.
|
* Get a record from the store by the value of a model attribute.
|
||||||
*
|
*
|
||||||
* @param {String} type The resource type.
|
* @param type The resource type.
|
||||||
* @param {String} key The name of the method on the model.
|
* @param key The name of the method on the model.
|
||||||
* @param {*} value The value of the model attribute.
|
* @param value The value of the model attribute.
|
||||||
* @return {Model}
|
|
||||||
* @public
|
|
||||||
*/
|
*/
|
||||||
public getBy(type: string, key: string, value: any): any;
|
getBy<M extends Model, T = unknown>(type: string, key: keyof M, value: T): M | undefined;
|
||||||
/**
|
/**
|
||||||
* Get all loaded records of a specific type.
|
* Get all loaded records of a specific type.
|
||||||
*
|
|
||||||
* @param {String} type
|
|
||||||
* @return {Model[]}
|
|
||||||
* @public
|
|
||||||
*/
|
*/
|
||||||
public all(type: string): any[];
|
all<M extends Model>(type: string): M[];
|
||||||
/**
|
/**
|
||||||
* Remove the given model from the store.
|
* Remove the given model from the store.
|
||||||
*
|
|
||||||
* @param {Model} model
|
|
||||||
*/
|
*/
|
||||||
remove(model: any): void;
|
remove(model: Model): void;
|
||||||
/**
|
/**
|
||||||
* Create a new record of the given type.
|
* Create a new record of the given type.
|
||||||
*
|
*
|
||||||
* @param {String} type The resource type
|
* @param type The resource type
|
||||||
* @param {Object} [data] Any data to initialize the model with
|
* @param data Any data to initialize the model with
|
||||||
* @return {Model}
|
|
||||||
* @public
|
|
||||||
*/
|
*/
|
||||||
public createRecord(type: string, data?: Object | undefined): any;
|
createRecord<M extends Model>(type: string, data?: ModelData): M;
|
||||||
}
|
}
|
||||||
|
export {};
|
||||||
|
@ -4,4 +4,4 @@ import User from '../models/User';
|
|||||||
* The `username` helper displays a user's username in a <span class="username">
|
* The `username` helper displays a user's username in a <span class="username">
|
||||||
* tag. If the user doesn't exist, the username will be displayed as [deleted].
|
* tag. If the user doesn't exist, the username will be displayed as [deleted].
|
||||||
*/
|
*/
|
||||||
export default function username(user: User): Mithril.Vnode;
|
export default function username(user: User | null | undefined | false): Mithril.Vnode;
|
||||||
|
@ -1,3 +1,48 @@
|
|||||||
|
import Model from '../Model';
|
||||||
|
import ItemList from '../utils/ItemList';
|
||||||
|
import Mithril from 'mithril';
|
||||||
|
import Post from './Post';
|
||||||
|
import User from './User';
|
||||||
export default class Discussion extends Model {
|
export default class Discussion extends Model {
|
||||||
|
title(): string;
|
||||||
|
slug(): string;
|
||||||
|
createdAt(): Date | undefined;
|
||||||
|
user(): false | User | null;
|
||||||
|
firstPost(): false | Post | null;
|
||||||
|
lastPostedAt(): Date | null | undefined;
|
||||||
|
lastPostedUser(): false | User | null;
|
||||||
|
lastPost(): false | Post | null;
|
||||||
|
lastPostNumber(): number | null | undefined;
|
||||||
|
commentCount(): number | undefined;
|
||||||
|
replyCount(): Number;
|
||||||
|
posts(): false | (Post | undefined)[];
|
||||||
|
mostRelevantPost(): false | Post | null;
|
||||||
|
lastReadAt(): Date | null | undefined;
|
||||||
|
lastReadPostNumber(): number | null | undefined;
|
||||||
|
isUnread(): boolean;
|
||||||
|
isRead(): boolean;
|
||||||
|
hiddenAt(): Date | null | undefined;
|
||||||
|
hiddenUser(): false | User | null;
|
||||||
|
isHidden(): boolean;
|
||||||
|
canReply(): boolean | undefined;
|
||||||
|
canRename(): boolean | undefined;
|
||||||
|
canHide(): boolean | undefined;
|
||||||
|
canDelete(): boolean | undefined;
|
||||||
|
/**
|
||||||
|
* Remove a post from the discussion's posts relationship.
|
||||||
|
*/
|
||||||
|
removePost(id: string): void;
|
||||||
|
/**
|
||||||
|
* Get the estimated number of unread posts in this discussion for the current
|
||||||
|
* user.
|
||||||
|
*/
|
||||||
|
unreadCount(): number;
|
||||||
|
/**
|
||||||
|
* Get the Badge components that apply to this discussion.
|
||||||
|
*/
|
||||||
|
badges(): ItemList<Mithril.Children>;
|
||||||
|
/**
|
||||||
|
* Get a list of all of the post IDs in this discussion.
|
||||||
|
*/
|
||||||
|
postIds(): string[];
|
||||||
}
|
}
|
||||||
import Model from "../Model";
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import Model from '../Model';
|
||||||
export default class Forum extends Model {
|
export default class Forum extends Model {
|
||||||
|
apiEndpoint(): string;
|
||||||
}
|
}
|
||||||
import Model from "../Model";
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
export default Group;
|
import Model from '../Model';
|
||||||
declare class Group extends Model {
|
export default class Group extends Model {
|
||||||
|
static ADMINISTRATOR_ID: string;
|
||||||
|
static GUEST_ID: string;
|
||||||
|
static MEMBER_ID: string;
|
||||||
|
nameSingular(): string;
|
||||||
|
namePlural(): string;
|
||||||
|
color(): string | null;
|
||||||
|
icon(): string | null;
|
||||||
|
isHidden(): boolean;
|
||||||
}
|
}
|
||||||
declare namespace Group {
|
|
||||||
const ADMINISTRATOR_ID: string;
|
|
||||||
const GUEST_ID: string;
|
|
||||||
const MEMBER_ID: string;
|
|
||||||
}
|
|
||||||
import Model from "../Model";
|
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
import Model from '../Model';
|
||||||
|
import User from './User';
|
||||||
export default class Notification extends Model {
|
export default class Notification extends Model {
|
||||||
|
contentType(): string;
|
||||||
|
content(): string;
|
||||||
|
createdAt(): Date;
|
||||||
|
isRead(): boolean;
|
||||||
|
user(): false | User;
|
||||||
|
fromUser(): false | User | null;
|
||||||
|
subject(): false | Model | null;
|
||||||
}
|
}
|
||||||
import Model from "../Model";
|
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
import Model from '../Model';
|
||||||
|
import Discussion from './Discussion';
|
||||||
|
import User from './User';
|
||||||
export default class Post extends Model {
|
export default class Post extends Model {
|
||||||
|
number(): number;
|
||||||
|
discussion(): Discussion;
|
||||||
|
createdAt(): Date;
|
||||||
|
user(): false | User;
|
||||||
|
contentType(): string | null;
|
||||||
|
content(): string | null | undefined;
|
||||||
|
contentHtml(): string | null | undefined;
|
||||||
|
renderFailed(): boolean | undefined;
|
||||||
|
contentPlain(): string | null | undefined;
|
||||||
|
editedAt(): Date | null | undefined;
|
||||||
|
editedUser(): false | User | null;
|
||||||
|
isEdited(): boolean;
|
||||||
|
hiddenAt(): Date | null | undefined;
|
||||||
|
hiddenUser(): false | User | null;
|
||||||
|
isHidden(): boolean;
|
||||||
|
canEdit(): boolean | undefined;
|
||||||
|
canHide(): boolean | undefined;
|
||||||
|
canDelete(): boolean | undefined;
|
||||||
}
|
}
|
||||||
import Model from "../Model";
|
|
||||||
|
@ -1,3 +1,46 @@
|
|||||||
|
import { Color } from 'color-thief-browser';
|
||||||
|
import Model from '../Model';
|
||||||
|
import ItemList from '../utils/ItemList';
|
||||||
|
import Mithril from 'mithril';
|
||||||
|
import Group from './Group';
|
||||||
export default class User extends Model {
|
export default class User extends Model {
|
||||||
|
username(): string;
|
||||||
|
slug(): string;
|
||||||
|
displayName(): string;
|
||||||
|
email(): string | undefined;
|
||||||
|
isEmailConfirmed(): boolean | undefined;
|
||||||
|
password(): string | undefined;
|
||||||
|
avatarUrl(): string | null;
|
||||||
|
preferences(): Record<string, any> | null | undefined;
|
||||||
|
groups(): false | (Group | undefined)[];
|
||||||
|
joinTime(): Date | null | undefined;
|
||||||
|
lastSeenAt(): Date | null | undefined;
|
||||||
|
markedAllAsReadAt(): Date | null | undefined;
|
||||||
|
unreadNotificationCount(): number | undefined;
|
||||||
|
newNotificationCount(): number | undefined;
|
||||||
|
discussionCount(): number | undefined;
|
||||||
|
commentCount(): number | undefined;
|
||||||
|
canEdit(): boolean | undefined;
|
||||||
|
canEditCredentials(): boolean | undefined;
|
||||||
|
canEditGroups(): boolean | undefined;
|
||||||
|
canDelete(): boolean | undefined;
|
||||||
|
color(): string;
|
||||||
|
protected avatarColor: Color | null;
|
||||||
|
/**
|
||||||
|
* Check whether or not the user has been seen in the last 5 minutes.
|
||||||
|
*/
|
||||||
|
isOnline(): boolean;
|
||||||
|
/**
|
||||||
|
* Get the Badge components that apply to this user.
|
||||||
|
*/
|
||||||
|
badges(): ItemList<Mithril.Children>;
|
||||||
|
/**
|
||||||
|
* Calculate the dominant color of the user's avatar. The dominant color will
|
||||||
|
* be set to the `avatarColor` property once it has been calculated.
|
||||||
|
*/
|
||||||
|
protected calculateAvatarColor(): void;
|
||||||
|
/**
|
||||||
|
* Update the user's preferences.
|
||||||
|
*/
|
||||||
|
savePreferences(newPreferences: Record<string, unknown>): Promise<this>;
|
||||||
}
|
}
|
||||||
import Model from "../Model";
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import Model from '../Model';
|
import Model from '../Model';
|
||||||
|
import { ApiQueryParamsPlural, ApiResponsePlural } from '../Store';
|
||||||
export interface Page<TModel> {
|
export interface Page<TModel> {
|
||||||
number: number;
|
number: number;
|
||||||
items: TModel[];
|
items: TModel[];
|
||||||
@ -13,6 +14,9 @@ export interface PaginationLocation {
|
|||||||
export interface PaginatedListParams {
|
export interface PaginatedListParams {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
export interface PaginatedListRequestParams extends Omit<ApiQueryParamsPlural, 'include'> {
|
||||||
|
include?: string | string[];
|
||||||
|
}
|
||||||
export default abstract class PaginatedListState<T extends Model, P extends PaginatedListParams = PaginatedListParams> {
|
export default abstract class PaginatedListState<T extends Model, P extends PaginatedListParams = PaginatedListParams> {
|
||||||
protected location: PaginationLocation;
|
protected location: PaginationLocation;
|
||||||
protected pageSize: number;
|
protected pageSize: number;
|
||||||
@ -26,11 +30,11 @@ export default abstract class PaginatedListState<T extends Model, P extends Pagi
|
|||||||
clear(): void;
|
clear(): void;
|
||||||
loadPrev(): Promise<void>;
|
loadPrev(): Promise<void>;
|
||||||
loadNext(): Promise<void>;
|
loadNext(): Promise<void>;
|
||||||
protected parseResults(pg: number, results: T[]): void;
|
protected parseResults(pg: number, results: ApiResponsePlural<T>): void;
|
||||||
/**
|
/**
|
||||||
* Load a new page of results.
|
* Load a new page of results.
|
||||||
*/
|
*/
|
||||||
protected loadPage(page?: number): Promise<T[]>;
|
protected loadPage(page?: number): Promise<ApiResponsePlural<T>>;
|
||||||
/**
|
/**
|
||||||
* Get the parameters that should be passed in the API request.
|
* Get the parameters that should be passed in the API request.
|
||||||
* Do not include page offset unless subclass overrides loadPage.
|
* Do not include page offset unless subclass overrides loadPage.
|
||||||
@ -38,7 +42,7 @@ export default abstract class PaginatedListState<T extends Model, P extends Pagi
|
|||||||
* @abstract
|
* @abstract
|
||||||
* @see loadPage
|
* @see loadPage
|
||||||
*/
|
*/
|
||||||
protected requestParams(): any;
|
protected requestParams(): PaginatedListRequestParams;
|
||||||
/**
|
/**
|
||||||
* Update the `this.params` object, calling `refresh` if they have changed.
|
* Update the `this.params` object, calling `refresh` if they have changed.
|
||||||
* Use `requestParams` for converting `this.params` into API parameters
|
* Use `requestParams` for converting `this.params` into API parameters
|
||||||
@ -73,7 +77,7 @@ export default abstract class PaginatedListState<T extends Model, P extends Pagi
|
|||||||
/**
|
/**
|
||||||
* Stored state parameters.
|
* Stored state parameters.
|
||||||
*/
|
*/
|
||||||
getParams(): any;
|
getParams(): P;
|
||||||
protected getNextPageNumber(): number;
|
protected getNextPageNumber(): number;
|
||||||
protected getPrevPageNumber(): number;
|
protected getPrevPageNumber(): number;
|
||||||
protected paramsChanged(newParams: P): boolean;
|
protected paramsChanged(newParams: P): boolean;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import Model from '../Model';
|
||||||
/**
|
/**
|
||||||
* The `computed` utility creates a function that will cache its output until
|
* The `computed` utility creates a function that will cache its output until
|
||||||
* any of the dependent values are dirty.
|
* any of the dependent values are dirty.
|
||||||
@ -7,4 +8,4 @@
|
|||||||
* dependent values.
|
* dependent values.
|
||||||
* @return {Function}
|
* @return {Function}
|
||||||
*/
|
*/
|
||||||
export default function computed(...dependentKeys: string[]): Function;
|
export default function computed<T, M = Model>(...args: [...string[], (this: M, ...args: unknown[]) => T]): () => T;
|
||||||
|
@ -3,6 +3,7 @@ import Page, { IPageAttrs } from '../../common/components/Page';
|
|||||||
import ItemList from '../../common/utils/ItemList';
|
import ItemList from '../../common/utils/ItemList';
|
||||||
import PostStreamState from '../states/PostStreamState';
|
import PostStreamState from '../states/PostStreamState';
|
||||||
import Discussion from '../../common/models/Discussion';
|
import Discussion from '../../common/models/Discussion';
|
||||||
|
import { ApiResponseSingle } from '../../common/Store';
|
||||||
export interface IDiscussionPageAttrs extends IPageAttrs {
|
export interface IDiscussionPageAttrs extends IPageAttrs {
|
||||||
id: string;
|
id: string;
|
||||||
near?: number;
|
near?: number;
|
||||||
@ -77,7 +78,7 @@ export default class DiscussionPage<CustomAttrs extends IDiscussionPageAttrs = I
|
|||||||
/**
|
/**
|
||||||
* Initialize the component to display the given discussion.
|
* Initialize the component to display the given discussion.
|
||||||
*/
|
*/
|
||||||
show(discussion: Discussion): void;
|
show(discussion: ApiResponseSingle<Discussion>): void;
|
||||||
/**
|
/**
|
||||||
* Build an item list for the contents of the sidebar.
|
* Build an item list for the contents of the sidebar.
|
||||||
*/
|
*/
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
export default class NotificationsDropdown extends Dropdown {
|
export default class NotificationsDropdown extends Dropdown {
|
||||||
onclick(): void;
|
onclick(): void;
|
||||||
goToRoute(): void;
|
goToRoute(): void;
|
||||||
getUnreadCount(): any;
|
getUnreadCount(): number | undefined;
|
||||||
getNewCount(): any;
|
getNewCount(): number | undefined;
|
||||||
menuClick(e: any): void;
|
menuClick(e: any): void;
|
||||||
}
|
}
|
||||||
import Dropdown from "../../common/components/Dropdown";
|
import Dropdown from "../../common/components/Dropdown";
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
import PaginatedListState, { Page, PaginatedListParams } from '../../common/states/PaginatedListState';
|
import PaginatedListState, { Page, PaginatedListParams, PaginatedListRequestParams } from '../../common/states/PaginatedListState';
|
||||||
import Discussion from '../../common/models/Discussion';
|
import Discussion from '../../common/models/Discussion';
|
||||||
export interface IRequestParams {
|
import { ApiResponsePlural } from '../../common/Store';
|
||||||
include: string[];
|
|
||||||
filter: Record<string, string>;
|
|
||||||
sort?: string;
|
|
||||||
}
|
|
||||||
export interface DiscussionListParams extends PaginatedListParams {
|
export interface DiscussionListParams extends PaginatedListParams {
|
||||||
sort?: string;
|
sort?: string;
|
||||||
}
|
}
|
||||||
@ -12,8 +8,8 @@ export default class DiscussionListState<P extends DiscussionListParams = Discus
|
|||||||
protected extraDiscussions: Discussion[];
|
protected extraDiscussions: Discussion[];
|
||||||
constructor(params: P, page?: number);
|
constructor(params: P, page?: number);
|
||||||
get type(): string;
|
get type(): string;
|
||||||
requestParams(): IRequestParams;
|
requestParams(): PaginatedListRequestParams;
|
||||||
protected loadPage(page?: number): Promise<Discussion[]>;
|
protected loadPage(page?: number): Promise<ApiResponsePlural<Discussion>>;
|
||||||
clear(): void;
|
clear(): void;
|
||||||
/**
|
/**
|
||||||
* Get a map of sort keys (which appear in the URL, and are used for
|
* Get a map of sort keys (which appear in the URL, and are used for
|
||||||
|
2
framework/core/js/dist/admin.js
generated
vendored
2
framework/core/js/dist/admin.js
generated
vendored
File diff suppressed because one or more lines are too long
29
framework/core/js/dist/admin.js.LICENSE.txt
generated
vendored
29
framework/core/js/dist/admin.js.LICENSE.txt
generated
vendored
@ -9,6 +9,30 @@
|
|||||||
* Date: 2021-02-16
|
* Date: 2021-02-16
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Block below copied from Protovis: http://mbostock.github.com/protovis/
|
||||||
|
* Copyright 2010 Stanford Visualization Group
|
||||||
|
* Licensed under the BSD License: http://www.opensource.org/licenses/bsd-license.php
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Color Thief v2.0
|
||||||
|
* by Lokesh Dhakar - http://www.lokeshdhakar.com
|
||||||
|
*
|
||||||
|
* Thanks
|
||||||
|
* ------
|
||||||
|
* Nick Rabinowitz - For creating quantize.js.
|
||||||
|
* John Schulz - For clean up and optimization. @JFSIII
|
||||||
|
* Nathan Spady - For adding drag and drop support to the demo page.
|
||||||
|
*
|
||||||
|
* License
|
||||||
|
* -------
|
||||||
|
* Copyright 2011, 2015 Lokesh Dhakar
|
||||||
|
* Released under the MIT license
|
||||||
|
* https://raw.githubusercontent.com/lokesh/color-thief/master/LICENSE
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* jQuery JavaScript Library v3.6.0
|
* jQuery JavaScript Library v3.6.0
|
||||||
* https://jquery.com/
|
* https://jquery.com/
|
||||||
@ -28,6 +52,11 @@
|
|||||||
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* quantize.js Copyright 2008 Nick Rabinowitz.
|
||||||
|
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* tabbable 5.2.1
|
* tabbable 5.2.1
|
||||||
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
||||||
|
2
framework/core/js/dist/admin.js.map
generated
vendored
2
framework/core/js/dist/admin.js.map
generated
vendored
File diff suppressed because one or more lines are too long
2
framework/core/js/dist/forum.js
generated
vendored
2
framework/core/js/dist/forum.js
generated
vendored
File diff suppressed because one or more lines are too long
2
framework/core/js/dist/forum.js.map
generated
vendored
2
framework/core/js/dist/forum.js.map
generated
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user