MOBILE-2310 core: Improve documentation of interfaces

main
Dani Palou 2018-01-15 08:22:00 +01:00
parent 2194c8e294
commit 0960ce92d4
19 changed files with 850 additions and 110 deletions

View File

@ -32,26 +32,110 @@ import { CoreConfigConstants } from '../configconstants';
import { Md5 } from 'ts-md5/dist/md5';
import { InAppBrowserObject } from '@ionic-native/in-app-browser';
/**
* PreSets accepted by the WS call.
*/
export interface CoreSiteWSPreSets {
getFromCache?: boolean; // Get the value from the cache if it's still valid.
saveToCache?: boolean; // Save the result to the cache.
omitExpires?: boolean; // Ignore cache expiration.
emergencyCache?: boolean; // Use the cache when a request fails. Defaults to true.
cacheKey?: string; // Extra key to add to the cache when storing this call, to identify the entry.
getCacheUsingCacheKey?: boolean; // Whether it should use cache key to retrieve the cached data instead of the request params.
getEmergencyCacheUsingCacheKey?: boolean; // Same as getCacheUsingCacheKey, but for emergency cache.
uniqueCacheKey?: boolean; // Whether it should only be 1 entry for this cache key (all entries with same key will be deleted).
filter?: boolean; // Whether to filter WS response (moodlewssettingfilter). Defaults to true.
rewriteurls?: boolean; // Whether to rewrite URLs (moodlewssettingfileurl). Defaults to true.
responseExpected?: boolean; // Defaults to true. Set to false when the expected response is null.
typeExpected?: string; // Defaults to 'object'. Use it when you expect a type that's not an object|array.
/**
* Get the value from the cache if it's still valid.
* @type {boolean}
*/
getFromCache?: boolean;
/**
* Save the result to the cache.
* @type {boolean}
*/
saveToCache?: boolean;
/**
* Ignore cache expiration.
* @type {boolean}
*/
omitExpires?: boolean;
/**
* Use the cache when a request fails. Defaults to true.
* @type {boolean}
*/
emergencyCache?: boolean;
/**
* Extra key to add to the cache when storing this call, to identify the entry.
* @type {string}
*/
cacheKey?: string;
/**
* Whether it should use cache key to retrieve the cached data instead of the request params.
* @type {boolean}
*/
getCacheUsingCacheKey?: boolean;
/**
* Same as getCacheUsingCacheKey, but for emergency cache.
* @type {boolean}
*/
getEmergencyCacheUsingCacheKey?: boolean;
/**
* Whether it should only be 1 entry for this cache key (all entries with same key will be deleted).
* @type {boolean}
*/
uniqueCacheKey?: boolean;
/**
* Whether to filter WS response (moodlewssettingfilter). Defaults to true.
* @type {boolean}
*/
filter?: boolean;
/**
* Whether to rewrite URLs (moodlewssettingfileurl). Defaults to true.
* @type {boolean}
*/
rewriteurls?: boolean;
/**
* Defaults to true. Set to false when the expected response is null.
* @type {boolean}
*/
responseExpected?: boolean;
/**
* Defaults to 'object'. Use it when you expect a type that's not an object|array.
* @type {string}
*/
typeExpected?: string;
};
/**
* Response of checking local_mobile status.
*/
export interface LocalMobileResponse {
code: number; // Code to identify the authentication method to use.
service?: string; // Name of the service to use.
warning?: string; // Code of the warning message.
coreSupported?: boolean; // Whether core SSO is supported.
/**
* Code to identify the authentication method to use.
* @type {number}
*/
code: number;
/**
* Name of the service to use.
* @type {string}
*/
service?: string;
/**
* Code of the warning message.
* @type {string}
*/
warning?: string;
/**
* Whether core SSO is supported.
* @type {boolean}
*/
coreSupported?: boolean;
}
/**

View File

@ -21,7 +21,7 @@ import { CoreCourseProvider } from './course';
import { CoreCourseFormatDefaultHandler } from './default-format';
/**
* Interface that all course format handlers should implement.
* Interface that all course format handlers must implement.
*/
export interface CoreCourseFormatHandler {
/**

View File

@ -21,7 +21,7 @@ import { CoreCourseProvider } from './course';
import { CoreSite } from '../../../classes/site';
/**
* Interface that all course module handlers should implement.
* Interface that all course module handlers must implement.
*/
export interface CoreCourseModuleHandler {
/**

View File

@ -19,33 +19,132 @@ import { CoreSitesProvider } from '../../../providers/sites';
import { CoreUtilsProvider, PromiseDefer } from '../../../providers/utils/utils';
import { CoreCoursesProvider } from './courses';
/**
* Interface that all courses handlers must implement.
*/
export interface CoreCoursesHandler {
name: string; // Name of the handler.
priority: number; // The highest priority is displayed first.
isEnabled(): boolean|Promise<boolean>; // Whether or not the handler is enabled on a site level.
isEnabledForCourse(courseId: number, accessData: any, navOptions?: any, admOptions?: any) :
boolean|Promise<boolean>; // Whether the handler is enabled on a course level. For perfomance reasons, do NOT call
// WebServices in here, call them in shouldDisplayForCourse.
shouldDisplayForCourse(courseId: number, accessData: any, navOptions?: any, admOptions?: any) :
boolean|Promise<boolean>; // Whether the handler should be displayed in a course. If not implemented, assume it's true.
getDisplayData?(courseId: number): CoreCoursesHandlerData; // Returns the data needed to render the handler.
invalidateEnabledForCourse?(courseId: number, navOptions?: any, admOptions?: any) : Promise<any>; // Should invalidate data
// to determine if handler is enabled for a certain course.
prefetch?(course: any) : Promise<any>; // Will be called when a course is downloaded, and it should prefetch all the data
// to be able to see the addon in offline.
/**
* Name of the handler.
* @type {string}
*/
name: string;
/**
* The highest priority is displayed first.
* @type {number}
*/
priority: number;
/**
* Whether or not the handler is enabled on a site level.
*
* @return {boolean|Promise<boolean>} True or promise resolved with true if enabled.
*/
isEnabled(): boolean|Promise<boolean>;
/**
* Whether or not the handler is enabled for a certain course.
* For perfomance reasons, do NOT call WebServices in here, call them in shouldDisplayForCourse.
*
* @param {number} courseId The course ID.
* @param {any} accessData Access type and data. Default, guest, ...
* @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
* @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
* @return {boolean|Promise<boolean>} True or promise resolved with true if enabled.
*/
isEnabledForCourse(courseId: number, accessData: any, navOptions?: any, admOptions?: any) : boolean|Promise<boolean>;
/**
* Whether or not the handler should be displayed for a course. If not implemented, assume it's true.
*
* @param {number} courseId The course ID.
* @param {any} accessData Access type and data. Default, guest, ...
* @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
* @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
* @return {boolean|Promise<boolean>} True or promise resolved with true if enabled.
*/
shouldDisplayForCourse(courseId: number, accessData: any, navOptions?: any, admOptions?: any) : boolean|Promise<boolean>;
/**
* Returns the data needed to render the handler.
*
* @param {number} courseId The course ID.
* @return {CoreCoursesHandlerData} Data.
*/
getDisplayData?(courseId: number): CoreCoursesHandlerData;
/**
* Should invalidate the data to determine if the handler is enabled for a certain course.
*
* @param {number} courseId The course ID.
* @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions.
* @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions.
* @return {Promise<any>} Promise resolved when done.
*/
invalidateEnabledForCourse?(courseId: number, navOptions?: any, admOptions?: any) : Promise<any>;
/**
* Called when a course is downloaded. It should prefetch all the data to be able to see the addon in offline.
*
* @param {any} course The course.
* @return {Promise<any>} Promise resolved when done.
*/
prefetch?(course: any) : Promise<any>;
};
/**
* Data needed to render a course handler. It's returned by the handler.
*/
export interface CoreCoursesHandlerData {
title: string; // Title to display for the handler.
icon: string; // Name of the icon to display for the handler.
class?: string; // Class to add to the displayed handler.
action(course: any): void; // Action to perform when the handler is clicked.
/**
* Title to display for the handler.
* @type {string}
*/
title: string;
/**
* Name of the icon to display for the handler.
* @type {string}
*/
icon: string;
/**
* Class to add to the displayed handler.
* @type {string}
*/
class?: string;
/**
* Action to perform when the handler is clicked.
*
* @param {any} course The course.
*/
action(course: any): void;
};
/**
* Data returned by the delegate for each handler.
*/
export interface CoreCoursesHandlerToDisplay {
data: CoreCoursesHandlerData; // Data to display.
priority?: number; // Handler's priority.
prefetch?(course: any) : Promise<any>; // Function to prefetch the handler.
/**
* Data to display.
* @type {CoreCoursesHandlerData}
*/
data: CoreCoursesHandlerData;
/**
* The highest priority is displayed first.
* @type {number}
*/
priority?: number;
/**
* Called when a course is downloaded. It should prefetch all the data to be able to see the addon in offline.
*
* @param {any} course The course.
* @return {Promise<any>} Promise resolved when done.
*/
prefetch?(course: any) : Promise<any>;
};
/**

View File

@ -27,10 +27,14 @@ import { CoreUtilsProvider } from '../../../providers/utils/utils';
import { CoreWSFileUploadOptions } from '../../../providers/ws';
/**
* Interface for file upload options.
* File upload options.
*/
export interface CoreFileUploaderOptions extends CoreWSFileUploadOptions {
deleteAfterUpload?: boolean; // Whether the file should be deleted after the upload (if success).
/**
* Whether the file should be deleted after the upload (if success).
* @type {boolean}
*/
deleteAfterUpload?: boolean;
};
/**

View File

@ -30,11 +30,38 @@ import { CoreConfigConstants } from '../../../configconstants';
import { CoreConstants } from '../../constants';
import { Md5 } from 'ts-md5/dist/md5';
/**
* Data related to a SSO authentication.
*/
export interface CoreLoginSSOData {
/**
* The site's URL.
* @type {string}
*/
siteUrl?: string;
/**
* User's token.
* @type {string}
*/
token?: string;
/**
* User's private token.
* @type {string}
*/
privateToken?: string;
/**
* Name of the page to go after authenticated.
* @type {string}
*/
pageName?: string;
/**
* Params to page to the page.
* @type {string}
*/
pageParams?: any
};

View File

@ -18,18 +18,65 @@ import { CoreLoggerProvider } from '../../../providers/logger';
import { CoreSitesProvider } from '../../../providers/sites';
import { Subject, BehaviorSubject } from 'rxjs';
/**
* Interface that all main menu handlers must implement.
*/
export interface CoreMainMenuHandler {
name: string; // Name of the handler.
priority: number; // The highest priority is displayed first.
isEnabled(): boolean|Promise<boolean>; // Whether or not the handler is enabled on a site level.
getDisplayData(): CoreMainMenuHandlerData; // Returns the data needed to render the handler.
/**
* Name of the handler.
* @type {string}
*/
name: string;
/**
* The highest priority is displayed first.
* @type {number}
*/
priority: number;
/**
* Whether or not the handler is enabled on a site level.
*
* @return {boolean|Promise<boolean>} True or promise resolved with true if enabled.
*/
isEnabled(): boolean|Promise<boolean>;
/**
* Returns the data needed to render the handler.
*
* @param {number} courseId The course ID.
* @return {CoreMainMenuHandlerData} Data.
*/
getDisplayData(): CoreMainMenuHandlerData;
};
/**
* Data needed to render a main menu handler. It's returned by the handler.
*/
export interface CoreMainMenuHandlerData {
page: string; // Name of the page.
title: string; // Title to display in the tab.
/**
* Name of the page to load for the handler.
* @type {string}
*/
page: string;
/**
* Title to display for the handler.
* @type {string}
*/
title: string;
/**
* Name of the icon to display for the handler.
* @type {string}
*/
icon: string; // Name of the icon to display in the tab.
class?: string; // Class to add to the displayed handler.
/**
* Class to add to the displayed handler.
* @type {string}
*/
class?: string;
};
/**

View File

@ -17,10 +17,32 @@ import { CoreLangProvider } from '../../../providers/lang';
import { CoreSitesProvider } from '../../../providers/sites';
import { CoreConfigConstants } from '../../../configconstants';
/**
* Custom main menu item.
*/
export interface CoreMainMenuCustomItem {
/**
* Type of the item: app, inappbrowser, browser or embedded.
* @type {string}
*/
type: string;
/**
* Url of the item.
* @type {string}
*/
url: string;
/**
* Label to display for the item.
* @type {string}
*/
label: string;
/**
* Name of the icon to display for the item.
* @type {string}
*/
icon: string;
};

View File

@ -21,10 +21,32 @@ import { CoreDbProvider } from './db';
import { CoreLoggerProvider } from './logger';
import { SQLiteDB } from '../classes/sqlitedb';
/**
* Data stored for a redirect to another page/site.
*/
export interface CoreRedirectData {
/**
* ID of the site to load.
* @type {string}
*/
siteId?: string;
page?: string; // Name of the page to redirect.
params?: any; // Params to pass to the page.
/**
* Name of the page to redirect to.
* @type {string}
*/
page?: string;
/**
* Params to pass to the page.
* @type {any}
*/
params?: any;
/**
* Timestamp when this redirect was last modified.
* @type {number}
*/
timemodified?: number;
};

View File

@ -21,17 +21,64 @@ import { CoreUtilsProvider } from './utils/utils';
import { CoreConstants } from '../core/constants';
import { SQLiteDB } from '../classes/sqlitedb';
/**
* Interface that all cron handlers must implement.
*/
export interface CoreCronHandler {
name: string; // Handler's name.
getInterval?(): number; // Returns handler's interval in milliseconds. Defaults to CoreCronDelegate.DEFAULT_INTERVAL.
usesNetwork?(): boolean; // Whether the process uses network or not. True if not defined.
isSync?(): boolean; // Whether it's a synchronization process or not. True if not defined.
canManualSync?(): boolean; // Whether the sync can be executed manually. Call isSync if not defined.
execute?(siteId?: string): Promise<any>; // Execute the process. Receives ID of site affected, undefined for all sites.
// Important: If the promise is rejected then this function will be called again
// often, it shouldn't be abused.
running: boolean; // Whether the handler is running. Used internally by the provider, there's no need to set it.
timeout: number; // Timeout ID for the handler scheduling. Used internally by the provider, there's no need to set it.
/**
* A name to identify the handler.
* @type {string}
*/
name: string;
/**
* Returns handler's interval in milliseconds. Defaults to CoreCronDelegate.DEFAULT_INTERVAL.
*
* @return {number} Interval time (in milliseconds).
*/
getInterval?(): number;
/**
* Check whether the process uses network or not. True if not defined.
*
* @return {boolean} Whether the process uses network or not
*/
usesNetwork?(): boolean;
/**
* Check whether it's a synchronization process or not. True if not defined.
*
* @return {boolean} Whether it's a synchronization process or not.
*/
isSync?(): boolean;
/**
* Check whether the sync can be executed manually. Call isSync if not defined.
*
* @return {boolean} Whether the sync can be executed manually.
*/
canManualSync?(): boolean;
/**
* Execute the process.
*
* @param {string} [siteId] ID of the site affected. If not defined, all sites.
* @return {Promise<any>} Promise resolved when done. If the promise is rejected, this function will be called again often,
* it shouldn't be abused.
*/
execute?(siteId?: string): Promise<any>;
/**
* Whether the handler is running. Used internally by the provider, there's no need to set it.
* @type {boolean}
*/
running: boolean;
/**
* Timeout ID for the handler scheduling. Used internally by the provider, there's no need to set it.
* @type {number}
*/
timeout: number;
};
/*

View File

@ -16,8 +16,14 @@ import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
import { CoreLoggerProvider } from '../providers/logger';
/**
* Observer instance to stop listening to an event.
*/
export interface CoreEventObserver {
off: () => void; // Unsubscribe.
/**
* Stop the observer.
*/
off: () => void;
};
/*

View File

@ -31,46 +31,204 @@ import { SQLiteDB } from '../classes/sqlitedb';
import { CoreConstants } from '../core/constants';
import { Md5 } from 'ts-md5/dist/md5';
// Entry from filepool.
/**
* Entry from filepool.
*/
export interface CoreFilepoolFileEntry {
/**
* The fileId to identify the file.
* @type {string}
*/
fileId?: string;
/**
* File's URL.
* @type {string}
*/
url?: string;
/**
* File's revision.
* @type {number}
*/
revision?: number;
/**
* File's timemodified.
* @type {number}
*/
timemodified?: number;
stale?: number; // 1 if stale, 0 otherwise.
/**
* 1 if file is stale (needs to be updated), 0 otherwise.
* @type {number}
*/
stale?: number;
/**
* Timestamp when this file was downloaded.
* @type {number}
*/
downloadTime?: number;
isexternalfile?: number; // 1 if external, 0 otherwise.
/**
* 1 if it's a external file (from an external repository), 0 otherwise.
* @type {number}
*/
isexternalfile?: number;
/**
* Type of the repository this file belongs to.
* @type {string}
*/
repositorytype?: string;
/**
* File's path.
* @type {string}
*/
path?: string;
/**
* File's extension.
* @type {string}
*/
extension?: string;
};
// Entry from files queue.
/**
* Entry from the file's queue.
*/
export interface CoreFilepoolQueueEntry {
/**
* The site the file belongs to.
* @type {string}
*/
siteId?: string;
/**
* The fileId to identify the file.
* @type {string}
*/
fileId?: string;
/**
* Timestamp when the file was added to the queue.
* @type {number}
*/
added?: number;
/**
* The priority of the file.
* @type {number}
*/
priority?: number;
/**
* File's URL.
* @type {string}
*/
url?: string;
/**
* File's revision.
* @type {number}
*/
revision?: number;
/**
* File's timemodified.
* @type {number}
*/
timemodified?: number;
isexternalfile?: number; // 1 if external, 0 otherwise.
/**
* 1 if it's a external file (from an external repository), 0 otherwise.
* @type {number}
*/
isexternalfile?: number;
/**
* Type of the repository this file belongs to.
* @type {string}
*/
repositorytype?: string;
/**
* File's path.
* @type {string}
*/
path?: string;
/**
* File links (to link the file to components and componentIds).
* @type {any[]}
*/
links?: any[];
};
// Entry from packages table.
/**
* Entry from packages table.
*/
export interface CoreFilepoolPackageEntry {
/**
* Package id.
* @type {string}
*/
id?: string;
/**
* The component to link the files to.
* @type {string}
*/
component?: string;
/**
* An ID to use in conjunction with the component.
* @type {string|number}
*/
componentId?: string|number;
/**
* Package status.
* @type {string}
*/
status?: string;
/**
* Package previous status.
* @type {string}
*/
previous?: string;
/**
* Package revision.
* @type {string}
*/
revision?: string;
/**
* Package timemodified.
* @type {number}
*/
timemodified?: number;
/**
* Timestamp when this package was updated.
* @type {number}
*/
updated?: number;
/**
* Timestamp when this package was downloaded.
* @type {number}
*/
downloadTime?: number;
/**
* Previous download time.
* @type {number}
*/
previousDownloadTime?: number;
};

View File

@ -16,10 +16,27 @@ import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreSitesProvider } from './sites';
/**
* Group info for an activity.
*/
export interface CoreGroupInfo {
groups?: any[]; // List of groups.
separateGroups?: boolean; // Whether it's separate groups.
visibleGroups?: boolean; // Whether it's visible groups.
/**
* List of groups.
* @type {any[]}
*/
groups?: any[];
/**
* Whether it's separate groups.
* @type {boolean}
*/
separateGroups?: boolean;
/**
* Whether it's visible groups.
* @type {boolean}
*/
visibleGroups?: boolean;
};
/*

View File

@ -17,11 +17,34 @@ import { Platform } from 'ionic-angular';
import { CoreLoggerProvider } from './logger';
import { CoreUtilsProvider } from './utils/utils';
/**
* Interface that all init handlers must implement.
*/
export interface CoreInitHandler {
name: string; // Name of the handler.
load(): Promise<any>; // Function to execute during the init process.
priority?: number; // The highest priority is executed first. You should use values lower than MAX_RECOMMENDED_PRIORITY.
blocking?: boolean; // Set this to true when this process should be resolved before any following one.
/**
* A name to identify the handler.
* @type {string}
*/
name: string;
/**
* Function to execute during the init process.
*
* @return {Promise<any>} Promise resolved when done.
*/
load(): Promise<any>;
/**
* The highest priority is executed first. You should use values lower than MAX_RECOMMENDED_PRIORITY.
* @type {number}
*/
priority?: number;
/**
* Set this to true when this process should be resolved before any following one.
* @type {boolean}
*/
blocking?: boolean;
};
/*

View File

@ -24,10 +24,22 @@ import { SQLiteDB } from '../classes/sqlitedb';
import { CoreConstants } from '../core/constants';
import { Subject } from 'rxjs';
/**
* Local notification.
*/
export interface CoreILocalNotification extends ILocalNotification {
/**
* Number of milliseconds to turn the led on (Android only).
* @type {number}
*/
ledOnTime?: number;
/**
* Number of milliseconds to turn the led off (Android only).
* @type {number}
*/
ledOffTime?: number;
}
};
/*
Generated class for the LocalNotificationsProvider provider.

View File

@ -15,10 +15,31 @@
import { Injectable } from '@angular/core';
import { CoreLoggerProvider } from './logger';
/**
* Interface that all plugin file handlers must implement.
*/
export interface CorePluginFileHandler {
name: string; // Name of the handler.
getComponentRevisionRegExp?(args: string[]): RegExp; // Should return the RegExp to match revision on pluginfile url.
getComponentRevisionReplace?(args: string[]): string; // Should return the String to remove the revision on pluginfile url.
/**
* A name to identify the handler. It should match the "component" of pluginfile URLs.
* @type {string}
*/
name: string;
/**
* Return the RegExp to match the revision on pluginfile URLs.
*
* @param {string[]} args Arguments of the pluginfile URL defining component and filearea at least.
* @return {RegExp} RegExp to match the revision on pluginfile URLs.
*/
getComponentRevisionRegExp?(args: string[]): RegExp;
/**
* Should return the string to remove the revision on pluginfile url.
*
* @param {string[]} args Arguments of the pluginfile URL defining component and filearea at least.
* @return {string} String to remove the revision on pluginfile url.
*/
getComponentRevisionReplace?(args: string[]): string;
};
/**

View File

@ -27,26 +27,102 @@ import { CoreSite } from '../classes/site';
import { SQLiteDB } from '../classes/sqlitedb';
import { Md5 } from 'ts-md5/dist/md5';
/**
* Response of checking if a site exists and its configuration.
*/
export interface CoreSiteCheckResponse {
code: number; // Code to identify the authentication method to use.
siteUrl: string; // Site url to use (might have changed during the process).
service: string; // Service used.
warning?: string; // Code of the warning message to show to the user.
config?: any; // Site public config (if available).
};
/**
* Code to identify the authentication method to use.
* @type {number}
*/
code: number;
export interface CoreSiteUserTokenResponse {
token: string; // User token.
siteUrl: string; // Site URL to use.
privateToken?: string; // User private token.
};
export interface CoreSiteBasicInfo {
id: string;
/**
* Site url to use (might have changed during the process).
* @type {string}
*/
siteUrl: string;
/**
* Service used.
* @type {string}
*/
service: string;
/**
* Code of the warning message to show to the user.
* @type {string}
*/
warning?: string;
/**
* Site public config (if available).
* @type {any}
*/
config?: any;
};
/**
* Response of getting user token.
*/
export interface CoreSiteUserTokenResponse {
/**
* User token.
* @type {string}
*/
token: string;
/**
* Site URL to use.
* @type {string}
*/
siteUrl: string;
/**
* User private token.
* @type {string}
*/
privateToken?: string;
};
/**
* Site's basic info.
*/
export interface CoreSiteBasicInfo {
/**
* Site ID.
* @type {string}
*/
id: string;
/**
* Site URL.
* @type {string}
*/
siteUrl: string;
/**
* User's full name.
* @type {string}
*/
fullName: string;
/**
* Site's name.
* @type {string}
*/
siteName: string;
/**
* User's avatar.
* @type {string}
*/
avatar: string;
/**
* Badge to display in the site.
* @type {number}
*/
badge?: number;
};

View File

@ -24,10 +24,29 @@ import { CoreLoggerProvider } from '../logger';
import { TranslateService } from '@ngx-translate/core';
import { CoreLangProvider } from '../lang';
/**
* Deferred promise. It's similar to the result of $q.defer() in AngularJS.
*/
export interface PromiseDefer {
promise?: Promise<any>; // Promise created.
resolve?: (value?: any) => any; // Function to resolve the promise.
reject?: (reason?: any) => any; // Function to reject the promise.
/**
* The promise.
* @type {Promise<any>}
*/
promise?: Promise<any>;
/**
* Function to resolve the promise.
*
* @param {any} [value] The resolve value.
*/
resolve?: (value?: any) => void; // Function to resolve the promise.
/**
* Function to reject the promise.
*
* @param {any} [reason] The reject param.
*/
reject?: (reason?: any) => void;
}
/*

View File

@ -28,39 +28,95 @@ import { Md5 } from 'ts-md5/dist/md5';
import { CoreInterceptor } from '../classes/interceptor';
/**
* Interface of the presets accepted by the WS call.
* PreSets accepted by the WS call.
*/
export interface CoreWSPreSets {
siteUrl: string; // The site URL.
wsToken: string; // The Webservice token.
responseExpected?: boolean; // Defaults to true. Set to false when the expected response is null.
typeExpected?: string; // Defaults to 'object'. Use it when you expect a type that's not an object|array.
cleanUnicode?: boolean; // Defaults to false. Clean multibyte Unicode chars from data.
/**
* The site URL.
* @type {string}
*/
siteUrl: string;
/**
* The Webservice token.
* @type {string}
*/
wsToken: string;
/**
* Defaults to true. Set to false when the expected response is null.
* @type {boolean}
*/
responseExpected?: boolean;
/**
* Defaults to 'object'. Use it when you expect a type that's not an object|array.
* @type {string}
*/
typeExpected?: string;
/**
* Defaults to false. Clean multibyte Unicode chars from data.
* @type {string}
*/
cleanUnicode?: boolean;
};
/**
* Interface of the presets accepted by AJAX WS calls.
* PreSets accepted by AJAX WS calls.
*/
export interface CoreWSAjaxPreSets {
siteUrl: string; // The site URL.
responseExpected?: boolean; // Defaults to true. Set to false when the expected response is null.
/**
* The site URL.
* @type {string}
*/
siteUrl: string;
/**
* Defaults to true. Set to false when the expected response is null.
* @type {boolean}
*/
responseExpected?: boolean;
};
/**
* Interface for WS Errors.
* Error returned by a WS call.
*/
export interface CoreWSError {
message: string; // The error message.
exception?: string; // Name of the exception. Undefined for local errors (fake WS errors).
errorcode?: string; // The error code. Undefined for local errors (fake WS errors).
/**
* The error message.
* @type {string}
*/
message: string;
/**
* Name of the exception. Undefined for local errors (fake WS errors).
* @type {string}
*/
exception?: string;
/**
* The error code. Undefined for local errors (fake WS errors).
* @type {string}
*/
errorcode?: string;
};
/**
* Interface for file upload options.
* File upload options.
*/
export interface CoreWSFileUploadOptions extends FileUploadOptions {
fileArea?: string; // The file area where to put the file. By default, 'draft'.
itemId?: number; // Item ID of the area where to put the file. By default, 0.
/**
* The file area where to put the file. By default, 'draft'.
* @type {string}
*/
fileArea?: string;
/**
* Item ID of the area where to put the file. By default, 0.
* @type {number}
*/
itemId?: number;
};
/**