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 { Md5 } from 'ts-md5/dist/md5';
import { InAppBrowserObject } from '@ionic-native/in-app-browser'; import { InAppBrowserObject } from '@ionic-native/in-app-browser';
/**
* PreSets accepted by the WS call.
*/
export interface CoreSiteWSPreSets { export interface CoreSiteWSPreSets {
getFromCache?: boolean; // Get the value from the cache if it's still valid. /**
saveToCache?: boolean; // Save the result to the cache. * Get the value from the cache if it's still valid.
omitExpires?: boolean; // Ignore cache expiration. * @type {boolean}
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. getFromCache?: boolean;
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). * Save the result to the cache.
filter?: boolean; // Whether to filter WS response (moodlewssettingfilter). Defaults to true. * @type {boolean}
rewriteurls?: boolean; // Whether to rewrite URLs (moodlewssettingfileurl). Defaults to true. */
responseExpected?: boolean; // Defaults to true. Set to false when the expected response is null. saveToCache?: boolean;
typeExpected?: string; // Defaults to 'object'. Use it when you expect a type that's not an object|array.
/**
* 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 { export interface LocalMobileResponse {
code: number; // Code to identify the authentication method to use. /**
service?: string; // Name of the service to use. * Code to identify the authentication method to use.
warning?: string; // Code of the warning message. * @type {number}
coreSupported?: boolean; // Whether core SSO is supported. */
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'; import { CoreCourseFormatDefaultHandler } from './default-format';
/** /**
* Interface that all course format handlers should implement. * Interface that all course format handlers must implement.
*/ */
export interface CoreCourseFormatHandler { export interface CoreCourseFormatHandler {
/** /**

View File

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

View File

@ -19,33 +19,132 @@ import { CoreSitesProvider } from '../../../providers/sites';
import { CoreUtilsProvider, PromiseDefer } from '../../../providers/utils/utils'; import { CoreUtilsProvider, PromiseDefer } from '../../../providers/utils/utils';
import { CoreCoursesProvider } from './courses'; import { CoreCoursesProvider } from './courses';
/**
* Interface that all courses handlers must implement.
*/
export interface CoreCoursesHandler { export interface CoreCoursesHandler {
name: string; // Name of the handler. /**
priority: number; // The highest priority is displayed first. * Name of the handler.
isEnabled(): boolean|Promise<boolean>; // Whether or not the handler is enabled on a site level. * @type {string}
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 name: string;
// 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. * The highest priority is displayed first.
getDisplayData?(courseId: number): CoreCoursesHandlerData; // Returns the data needed to render the handler. * @type {number}
invalidateEnabledForCourse?(courseId: number, navOptions?: any, admOptions?: any) : Promise<any>; // Should invalidate data */
// to determine if handler is enabled for a certain course. priority: number;
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. /**
* 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 { export interface CoreCoursesHandlerData {
title: string; // Title to display for the handler. /**
icon: string; // Name of the icon to display for the handler. * Title to display for the handler.
class?: string; // Class to add to the displayed handler. * @type {string}
action(course: any): void; // Action to perform when the handler is clicked. */
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 { export interface CoreCoursesHandlerToDisplay {
data: CoreCoursesHandlerData; // Data to display. /**
priority?: number; // Handler's priority. * Data to display.
prefetch?(course: any) : Promise<any>; // Function to prefetch the handler. * @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'; import { CoreWSFileUploadOptions } from '../../../providers/ws';
/** /**
* Interface for file upload options. * File upload options.
*/ */
export interface CoreFileUploaderOptions extends CoreWSFileUploadOptions { 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 { CoreConstants } from '../../constants';
import { Md5 } from 'ts-md5/dist/md5'; import { Md5 } from 'ts-md5/dist/md5';
/**
* Data related to a SSO authentication.
*/
export interface CoreLoginSSOData { export interface CoreLoginSSOData {
/**
* The site's URL.
* @type {string}
*/
siteUrl?: string; siteUrl?: string;
/**
* User's token.
* @type {string}
*/
token?: string; token?: string;
/**
* User's private token.
* @type {string}
*/
privateToken?: string; privateToken?: string;
/**
* Name of the page to go after authenticated.
* @type {string}
*/
pageName?: string; pageName?: string;
/**
* Params to page to the page.
* @type {string}
*/
pageParams?: any pageParams?: any
}; };

View File

@ -18,18 +18,65 @@ import { CoreLoggerProvider } from '../../../providers/logger';
import { CoreSitesProvider } from '../../../providers/sites'; import { CoreSitesProvider } from '../../../providers/sites';
import { Subject, BehaviorSubject } from 'rxjs'; import { Subject, BehaviorSubject } from 'rxjs';
/**
* Interface that all main menu handlers must implement.
*/
export interface CoreMainMenuHandler { export interface CoreMainMenuHandler {
name: string; // Name of the handler. /**
priority: number; // The highest priority is displayed first. * Name of the handler.
isEnabled(): boolean|Promise<boolean>; // Whether or not the handler is enabled on a site level. * @type {string}
getDisplayData(): CoreMainMenuHandlerData; // Returns the data needed to render the handler. */
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 { 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. 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 { CoreSitesProvider } from '../../../providers/sites';
import { CoreConfigConstants } from '../../../configconstants'; import { CoreConfigConstants } from '../../../configconstants';
/**
* Custom main menu item.
*/
export interface CoreMainMenuCustomItem { export interface CoreMainMenuCustomItem {
/**
* Type of the item: app, inappbrowser, browser or embedded.
* @type {string}
*/
type: string; type: string;
/**
* Url of the item.
* @type {string}
*/
url: string; url: string;
/**
* Label to display for the item.
* @type {string}
*/
label: string; label: string;
/**
* Name of the icon to display for the item.
* @type {string}
*/
icon: string; icon: string;
}; };

View File

@ -21,10 +21,32 @@ import { CoreDbProvider } from './db';
import { CoreLoggerProvider } from './logger'; import { CoreLoggerProvider } from './logger';
import { SQLiteDB } from '../classes/sqlitedb'; import { SQLiteDB } from '../classes/sqlitedb';
/**
* Data stored for a redirect to another page/site.
*/
export interface CoreRedirectData { export interface CoreRedirectData {
/**
* ID of the site to load.
* @type {string}
*/
siteId?: 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; timemodified?: number;
}; };

View File

@ -21,17 +21,64 @@ import { CoreUtilsProvider } from './utils/utils';
import { CoreConstants } from '../core/constants'; import { CoreConstants } from '../core/constants';
import { SQLiteDB } from '../classes/sqlitedb'; import { SQLiteDB } from '../classes/sqlitedb';
/**
* Interface that all cron handlers must implement.
*/
export interface CoreCronHandler { export interface CoreCronHandler {
name: string; // Handler's name. /**
getInterval?(): number; // Returns handler's interval in milliseconds. Defaults to CoreCronDelegate.DEFAULT_INTERVAL. * A name to identify the handler.
usesNetwork?(): boolean; // Whether the process uses network or not. True if not defined. * @type {string}
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. name: string;
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. * Returns handler's interval in milliseconds. Defaults to CoreCronDelegate.DEFAULT_INTERVAL.
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. * @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 { Subject } from 'rxjs';
import { CoreLoggerProvider } from '../providers/logger'; import { CoreLoggerProvider } from '../providers/logger';
/**
* Observer instance to stop listening to an event.
*/
export interface CoreEventObserver { 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 { CoreConstants } from '../core/constants';
import { Md5 } from 'ts-md5/dist/md5'; import { Md5 } from 'ts-md5/dist/md5';
// Entry from filepool. /**
* Entry from filepool.
*/
export interface CoreFilepoolFileEntry { export interface CoreFilepoolFileEntry {
/**
* The fileId to identify the file.
* @type {string}
*/
fileId?: string; fileId?: string;
/**
* File's URL.
* @type {string}
*/
url?: string; url?: string;
/**
* File's revision.
* @type {number}
*/
revision?: number; revision?: number;
/**
* File's timemodified.
* @type {number}
*/
timemodified?: 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; 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; repositorytype?: string;
/**
* File's path.
* @type {string}
*/
path?: string; path?: string;
/**
* File's extension.
* @type {string}
*/
extension?: string; extension?: string;
}; };
// Entry from files queue. /**
* Entry from the file's queue.
*/
export interface CoreFilepoolQueueEntry { export interface CoreFilepoolQueueEntry {
/**
* The site the file belongs to.
* @type {string}
*/
siteId?: string; siteId?: string;
/**
* The fileId to identify the file.
* @type {string}
*/
fileId?: string; fileId?: string;
/**
* Timestamp when the file was added to the queue.
* @type {number}
*/
added?: number; added?: number;
/**
* The priority of the file.
* @type {number}
*/
priority?: number; priority?: number;
/**
* File's URL.
* @type {string}
*/
url?: string; url?: string;
/**
* File's revision.
* @type {number}
*/
revision?: number; revision?: number;
/**
* File's timemodified.
* @type {number}
*/
timemodified?: 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; repositorytype?: string;
/**
* File's path.
* @type {string}
*/
path?: string; path?: string;
/**
* File links (to link the file to components and componentIds).
* @type {any[]}
*/
links?: any[]; links?: any[];
}; };
// Entry from packages table. /**
* Entry from packages table.
*/
export interface CoreFilepoolPackageEntry { export interface CoreFilepoolPackageEntry {
/**
* Package id.
* @type {string}
*/
id?: string; id?: string;
/**
* The component to link the files to.
* @type {string}
*/
component?: string; component?: string;
/**
* An ID to use in conjunction with the component.
* @type {string|number}
*/
componentId?: string|number; componentId?: string|number;
/**
* Package status.
* @type {string}
*/
status?: string; status?: string;
/**
* Package previous status.
* @type {string}
*/
previous?: string; previous?: string;
/**
* Package revision.
* @type {string}
*/
revision?: string; revision?: string;
/**
* Package timemodified.
* @type {number}
*/
timemodified?: number; timemodified?: number;
/**
* Timestamp when this package was updated.
* @type {number}
*/
updated?: number; updated?: number;
/**
* Timestamp when this package was downloaded.
* @type {number}
*/
downloadTime?: number; downloadTime?: number;
/**
* Previous download time.
* @type {number}
*/
previousDownloadTime?: number; previousDownloadTime?: number;
}; };

View File

@ -16,10 +16,27 @@ import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { CoreSitesProvider } from './sites'; import { CoreSitesProvider } from './sites';
/**
* Group info for an activity.
*/
export interface CoreGroupInfo { export interface CoreGroupInfo {
groups?: any[]; // List of groups. /**
separateGroups?: boolean; // Whether it's separate groups. * List of groups.
visibleGroups?: boolean; // Whether it's visible 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 { CoreLoggerProvider } from './logger';
import { CoreUtilsProvider } from './utils/utils'; import { CoreUtilsProvider } from './utils/utils';
/**
* Interface that all init handlers must implement.
*/
export interface CoreInitHandler { export interface CoreInitHandler {
name: string; // Name of the handler. /**
load(): Promise<any>; // Function to execute during the init process. * A name to identify the handler.
priority?: number; // The highest priority is executed first. You should use values lower than MAX_RECOMMENDED_PRIORITY. * @type {string}
blocking?: boolean; // Set this to true when this process should be resolved before any following one. */
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 { CoreConstants } from '../core/constants';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
/**
* Local notification.
*/
export interface CoreILocalNotification extends ILocalNotification { export interface CoreILocalNotification extends ILocalNotification {
/**
* Number of milliseconds to turn the led on (Android only).
* @type {number}
*/
ledOnTime?: number; ledOnTime?: number;
/**
* Number of milliseconds to turn the led off (Android only).
* @type {number}
*/
ledOffTime?: number; ledOffTime?: number;
} };
/* /*
Generated class for the LocalNotificationsProvider provider. Generated class for the LocalNotificationsProvider provider.

View File

@ -15,10 +15,31 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreLoggerProvider } from './logger'; import { CoreLoggerProvider } from './logger';
/**
* Interface that all plugin file handlers must implement.
*/
export interface CorePluginFileHandler { export interface CorePluginFileHandler {
name: string; // Name of the handler. /**
getComponentRevisionRegExp?(args: string[]): RegExp; // Should return the RegExp to match revision on pluginfile url. * A name to identify the handler. It should match the "component" of pluginfile URLs.
getComponentRevisionReplace?(args: string[]): string; // Should return the String to remove the revision on pluginfile url. * @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 { SQLiteDB } from '../classes/sqlitedb';
import { Md5 } from 'ts-md5/dist/md5'; import { Md5 } from 'ts-md5/dist/md5';
/**
* Response of checking if a site exists and its configuration.
*/
export interface CoreSiteCheckResponse { 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). * Code to identify the authentication method to use.
service: string; // Service used. * @type {number}
warning?: string; // Code of the warning message to show to the user. */
config?: any; // Site public config (if available). code: number;
};
export interface CoreSiteUserTokenResponse { /**
token: string; // User token. * Site url to use (might have changed during the process).
siteUrl: string; // Site URL to use. * @type {string}
privateToken?: string; // User private token. */
};
export interface CoreSiteBasicInfo {
id: string;
siteUrl: 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; fullName: string;
/**
* Site's name.
* @type {string}
*/
siteName: string; siteName: string;
/**
* User's avatar.
* @type {string}
*/
avatar: string; avatar: string;
/**
* Badge to display in the site.
* @type {number}
*/
badge?: number; badge?: number;
}; };

View File

@ -24,10 +24,29 @@ import { CoreLoggerProvider } from '../logger';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { CoreLangProvider } from '../lang'; import { CoreLangProvider } from '../lang';
/**
* Deferred promise. It's similar to the result of $q.defer() in AngularJS.
*/
export interface PromiseDefer { export interface PromiseDefer {
promise?: Promise<any>; // Promise created. /**
resolve?: (value?: any) => any; // Function to resolve the promise. * The promise.
reject?: (reason?: any) => any; // Function to reject 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'; import { CoreInterceptor } from '../classes/interceptor';
/** /**
* Interface of the presets accepted by the WS call. * PreSets accepted by the WS call.
*/ */
export interface CoreWSPreSets { export interface CoreWSPreSets {
siteUrl: string; // The site URL. /**
wsToken: string; // The Webservice token. * The site URL.
responseExpected?: boolean; // Defaults to true. Set to false when the expected response is null. * @type {string}
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. 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 { 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 { export interface CoreWSError {
message: string; // The error message. /**
exception?: string; // Name of the exception. Undefined for local errors (fake WS errors). * The error message.
errorcode?: string; // The error code. Undefined for local errors (fake WS errors). * @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 { 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;
}; };
/** /**