MOBILE-2842 core: Interfaces for DB schemas
This commit is contained in:
		
							parent
							
								
									8280694383
								
							
						
					
					
						commit
						fb29050627
					
				| @ -23,6 +23,7 @@ import { CoreConstants } from '@core/constants'; | |||||||
| import { CoreLocalNotificationsProvider } from '@providers/local-notifications'; | import { CoreLocalNotificationsProvider } from '@providers/local-notifications'; | ||||||
| import { CoreConfigProvider } from '@providers/config'; | import { CoreConfigProvider } from '@providers/config'; | ||||||
| import { ILocalNotification } from '@ionic-native/local-notifications'; | import { ILocalNotification } from '@ionic-native/local-notifications'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle calendar events. |  * Service to handle calendar events. | ||||||
| @ -38,7 +39,7 @@ export class AddonCalendarProvider { | |||||||
| 
 | 
 | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     static EVENTS_TABLE = 'addon_calendar_events'; |     static EVENTS_TABLE = 'addon_calendar_events'; | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: AddonCalendarProvider.EVENTS_TABLE, |             name: AddonCalendarProvider.EVENTS_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -17,6 +17,7 @@ import { CoreLoggerProvider } from '@providers/logger'; | |||||||
| import { CoreSitesProvider } from '@providers/sites'; | import { CoreSitesProvider } from '@providers/sites'; | ||||||
| import { CoreAppProvider } from '@providers/app'; | import { CoreAppProvider } from '@providers/app'; | ||||||
| import { CoreTextUtilsProvider } from '@providers/utils/text'; | import { CoreTextUtilsProvider } from '@providers/utils/text'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle Offline messages. |  * Service to handle Offline messages. | ||||||
| @ -29,7 +30,7 @@ export class AddonMessagesOfflineProvider { | |||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     static MESSAGES_TABLE = 'addon_messages_offline_messages'; // When group messaging isn't available or a new conversation starts.
 |     static MESSAGES_TABLE = 'addon_messages_offline_messages'; // When group messaging isn't available or a new conversation starts.
 | ||||||
|     static CONVERSATION_MESSAGES_TABLE = 'addon_messages_offline_conversation_messages'; // Conversation messages.
 |     static CONVERSATION_MESSAGES_TABLE = 'addon_messages_offline_conversation_messages'; // Conversation messages.
 | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: AddonMessagesOfflineProvider.MESSAGES_TABLE, |             name: AddonMessagesOfflineProvider.MESSAGES_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -18,6 +18,7 @@ import { CoreLoggerProvider } from '@providers/logger'; | |||||||
| import { CoreSitesProvider } from '@providers/sites'; | import { CoreSitesProvider } from '@providers/sites'; | ||||||
| import { CoreTextUtilsProvider } from '@providers/utils/text'; | import { CoreTextUtilsProvider } from '@providers/utils/text'; | ||||||
| import { CoreTimeUtilsProvider } from '@providers/utils/time'; | import { CoreTimeUtilsProvider } from '@providers/utils/time'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle offline assign. |  * Service to handle offline assign. | ||||||
| @ -30,7 +31,7 @@ export class AddonModAssignOfflineProvider { | |||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     static SUBMISSIONS_TABLE = 'addon_mod_assign_submissions'; |     static SUBMISSIONS_TABLE = 'addon_mod_assign_submissions'; | ||||||
|     static SUBMISSIONS_GRADES_TABLE = 'addon_mod_assign_submissions_grading'; |     static SUBMISSIONS_GRADES_TABLE = 'addon_mod_assign_submissions_grading'; | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: AddonModAssignOfflineProvider.SUBMISSIONS_TABLE, |             name: AddonModAssignOfflineProvider.SUBMISSIONS_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -14,6 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { CoreSitesProvider } from '@providers/sites'; | import { CoreSitesProvider } from '@providers/sites'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle offline choices. |  * Service to handle offline choices. | ||||||
| @ -23,7 +24,7 @@ export class AddonModChoiceOfflineProvider { | |||||||
| 
 | 
 | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     static CHOICE_TABLE = 'addon_mod_choice_responses'; |     static CHOICE_TABLE = 'addon_mod_choice_responses'; | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: AddonModChoiceOfflineProvider.CHOICE_TABLE, |             name: AddonModChoiceOfflineProvider.CHOICE_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -18,6 +18,7 @@ import { CoreSitesProvider } from '@providers/sites'; | |||||||
| import { CoreTextUtilsProvider } from '@providers/utils/text'; | import { CoreTextUtilsProvider } from '@providers/utils/text'; | ||||||
| import { CoreFileProvider } from '@providers/file'; | import { CoreFileProvider } from '@providers/file'; | ||||||
| import { CoreFileUploaderProvider } from '@core/fileuploader/providers/fileuploader'; | import { CoreFileUploaderProvider } from '@core/fileuploader/providers/fileuploader'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle Offline data. |  * Service to handle Offline data. | ||||||
| @ -29,7 +30,7 @@ export class AddonModDataOfflineProvider { | |||||||
| 
 | 
 | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     static DATA_ENTRY_TABLE = 'addon_mod_data_entry'; |     static DATA_ENTRY_TABLE = 'addon_mod_data_entry'; | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: AddonModDataOfflineProvider.DATA_ENTRY_TABLE, |             name: AddonModDataOfflineProvider.DATA_ENTRY_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -17,6 +17,7 @@ import { CoreLoggerProvider } from '@providers/logger'; | |||||||
| import { CoreSitesProvider } from '@providers/sites'; | import { CoreSitesProvider } from '@providers/sites'; | ||||||
| import { CoreTextUtilsProvider } from '@providers/utils/text'; | import { CoreTextUtilsProvider } from '@providers/utils/text'; | ||||||
| import { CoreTimeUtilsProvider } from '@providers/utils/time'; | import { CoreTimeUtilsProvider } from '@providers/utils/time'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle Offline feedback. |  * Service to handle Offline feedback. | ||||||
| @ -28,7 +29,7 @@ export class AddonModFeedbackOfflineProvider { | |||||||
| 
 | 
 | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     static FEEDBACK_TABLE = 'addon_mod_feedback_answers'; |     static FEEDBACK_TABLE = 'addon_mod_feedback_answers'; | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: AddonModFeedbackOfflineProvider.FEEDBACK_TABLE, |             name: AddonModFeedbackOfflineProvider.FEEDBACK_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -16,6 +16,7 @@ import { Injectable } from '@angular/core'; | |||||||
| import { CoreFileProvider } from '@providers/file'; | import { CoreFileProvider } from '@providers/file'; | ||||||
| import { CoreSitesProvider } from '@providers/sites'; | import { CoreSitesProvider } from '@providers/sites'; | ||||||
| import { CoreTextUtilsProvider } from '@providers/utils/text'; | import { CoreTextUtilsProvider } from '@providers/utils/text'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle offline forum. |  * Service to handle offline forum. | ||||||
| @ -27,7 +28,7 @@ export class AddonModForumOfflineProvider { | |||||||
|     static DISCUSSIONS_TABLE = 'addon_mod_forum_discussions'; |     static DISCUSSIONS_TABLE = 'addon_mod_forum_discussions'; | ||||||
|     static REPLIES_TABLE = 'addon_mod_forum_replies'; |     static REPLIES_TABLE = 'addon_mod_forum_replies'; | ||||||
| 
 | 
 | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: AddonModForumOfflineProvider.DISCUSSIONS_TABLE, |             name: AddonModForumOfflineProvider.DISCUSSIONS_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -17,6 +17,7 @@ import { CoreFileProvider } from '@providers/file'; | |||||||
| import { CoreSitesProvider } from '@providers/sites'; | import { CoreSitesProvider } from '@providers/sites'; | ||||||
| import { CoreUtilsProvider } from '@providers/utils/utils'; | import { CoreUtilsProvider } from '@providers/utils/utils'; | ||||||
| import { CoreTextUtilsProvider } from '@providers/utils/text'; | import { CoreTextUtilsProvider } from '@providers/utils/text'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle offline glossary. |  * Service to handle offline glossary. | ||||||
| @ -27,7 +28,7 @@ export class AddonModGlossaryOfflineProvider { | |||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     static ENTRIES_TABLE = 'addon_mod_glossary_entrues'; |     static ENTRIES_TABLE = 'addon_mod_glossary_entrues'; | ||||||
| 
 | 
 | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: AddonModGlossaryOfflineProvider.ENTRIES_TABLE, |             name: AddonModGlossaryOfflineProvider.ENTRIES_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -18,6 +18,7 @@ import { CoreSitesProvider } from '@providers/sites'; | |||||||
| import { CoreTextUtilsProvider } from '@providers/utils/text'; | import { CoreTextUtilsProvider } from '@providers/utils/text'; | ||||||
| import { CoreTimeUtilsProvider } from '@providers/utils/time'; | import { CoreTimeUtilsProvider } from '@providers/utils/time'; | ||||||
| import { CoreUtilsProvider } from '@providers/utils/utils'; | import { CoreUtilsProvider } from '@providers/utils/utils'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| import { AddonModLessonProvider } from './lesson'; | import { AddonModLessonProvider } from './lesson'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
| @ -31,7 +32,7 @@ export class AddonModLessonOfflineProvider { | |||||||
|     // Variables for database. We use lowercase in the names to match the WS responses.
 |     // Variables for database. We use lowercase in the names to match the WS responses.
 | ||||||
|     static RETAKES_TABLE = 'addon_mod_lesson_retakes'; |     static RETAKES_TABLE = 'addon_mod_lesson_retakes'; | ||||||
|     static PAGE_ATTEMPTS_TABLE = 'addon_mod_lesson_page_attempts'; |     static PAGE_ATTEMPTS_TABLE = 'addon_mod_lesson_page_attempts'; | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: AddonModLessonOfflineProvider.RETAKES_TABLE, |             name: AddonModLessonOfflineProvider.RETAKES_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -25,6 +25,7 @@ import { CoreUrlUtilsProvider } from '@providers/utils/url'; | |||||||
| import { CoreUtilsProvider } from '@providers/utils/utils'; | import { CoreUtilsProvider } from '@providers/utils/utils'; | ||||||
| import { CoreCourseProvider } from '@core/course/providers/course'; | import { CoreCourseProvider } from '@core/course/providers/course'; | ||||||
| import { CoreSyncBaseProvider } from '@classes/base-sync'; | import { CoreSyncBaseProvider } from '@classes/base-sync'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| import { AddonModLessonProvider } from './lesson'; | import { AddonModLessonProvider } from './lesson'; | ||||||
| import { AddonModLessonOfflineProvider } from './lesson-offline'; | import { AddonModLessonOfflineProvider } from './lesson-offline'; | ||||||
| import { AddonModLessonPrefetchHandler } from './prefetch-handler'; | import { AddonModLessonPrefetchHandler } from './prefetch-handler'; | ||||||
| @ -58,7 +59,7 @@ export class AddonModLessonSyncProvider extends CoreSyncBaseProvider { | |||||||
| 
 | 
 | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     static RETAKES_FINISHED_TABLE = 'addon_mod_lesson_retakes_finished_sync'; |     static RETAKES_FINISHED_TABLE = 'addon_mod_lesson_retakes_finished_sync'; | ||||||
|     protected tablesSchema = { |     protected tablesSchema: SQLiteDBTableSchema = { | ||||||
|         name: AddonModLessonSyncProvider.RETAKES_FINISHED_TABLE, |         name: AddonModLessonSyncProvider.RETAKES_FINISHED_TABLE, | ||||||
|         columns: [ |         columns: [ | ||||||
|             { |             { | ||||||
|  | |||||||
| @ -21,6 +21,7 @@ import { CoreDomUtilsProvider } from '@providers/utils/dom'; | |||||||
| import { CoreUtilsProvider } from '@providers/utils/utils'; | import { CoreUtilsProvider } from '@providers/utils/utils'; | ||||||
| import { CoreGradesProvider } from '@core/grades/providers/grades'; | import { CoreGradesProvider } from '@core/grades/providers/grades'; | ||||||
| import { CoreSiteWSPreSets } from '@classes/site'; | import { CoreSiteWSPreSets } from '@classes/site'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| import { AddonModLessonOfflineProvider } from './lesson-offline'; | import { AddonModLessonOfflineProvider } from './lesson-offline'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
| @ -155,7 +156,7 @@ export class AddonModLessonProvider { | |||||||
| 
 | 
 | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     static PASSWORD_TABLE = 'addon_mod_lesson_password'; |     static PASSWORD_TABLE = 'addon_mod_lesson_password'; | ||||||
|     protected tablesSchema = { |     protected tablesSchema: SQLiteDBTableSchema = { | ||||||
|         name: AddonModLessonProvider.PASSWORD_TABLE, |         name: AddonModLessonProvider.PASSWORD_TABLE, | ||||||
|         columns: [ |         columns: [ | ||||||
|             { |             { | ||||||
|  | |||||||
| @ -17,6 +17,7 @@ import { Injectable, Injector } from '@angular/core'; | |||||||
| import { CoreSitesProvider } from '@providers/sites'; | import { CoreSitesProvider } from '@providers/sites'; | ||||||
| import { AddonModQuizAccessRuleHandler } from '../../../providers/access-rules-delegate'; | import { AddonModQuizAccessRuleHandler } from '../../../providers/access-rules-delegate'; | ||||||
| import { AddonModQuizAccessPasswordComponent } from '../component/password'; | import { AddonModQuizAccessPasswordComponent } from '../component/password'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Handler to support password access rule. |  * Handler to support password access rule. | ||||||
| @ -25,7 +26,7 @@ import { AddonModQuizAccessPasswordComponent } from '../component/password'; | |||||||
| export class AddonModQuizAccessPasswordHandler implements AddonModQuizAccessRuleHandler { | export class AddonModQuizAccessPasswordHandler implements AddonModQuizAccessRuleHandler { | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     static PASSWORD_TABLE = 'addon_mod_quiz_access_password'; |     static PASSWORD_TABLE = 'addon_mod_quiz_access_password'; | ||||||
|     protected tableSchema = { |     protected tableSchema: SQLiteDBTableSchema = { | ||||||
|         name: AddonModQuizAccessPasswordHandler.PASSWORD_TABLE, |         name: AddonModQuizAccessPasswordHandler.PASSWORD_TABLE, | ||||||
|         columns: [ |         columns: [ | ||||||
|             { |             { | ||||||
|  | |||||||
| @ -21,7 +21,7 @@ import { CoreUtilsProvider } from '@providers/utils/utils'; | |||||||
| import { CoreQuestionProvider } from '@core/question/providers/question'; | import { CoreQuestionProvider } from '@core/question/providers/question'; | ||||||
| import { CoreQuestionBehaviourDelegate } from '@core/question/providers/behaviour-delegate'; | import { CoreQuestionBehaviourDelegate } from '@core/question/providers/behaviour-delegate'; | ||||||
| import { AddonModQuizProvider } from './quiz'; | import { AddonModQuizProvider } from './quiz'; | ||||||
| import { SQLiteDB } from '@classes/sqlitedb'; | import { SQLiteDB, SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle offline quiz. |  * Service to handle offline quiz. | ||||||
| @ -33,7 +33,7 @@ export class AddonModQuizOfflineProvider { | |||||||
| 
 | 
 | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     static ATTEMPTS_TABLE = 'addon_mod_quiz_attempts'; |     static ATTEMPTS_TABLE = 'addon_mod_quiz_attempts'; | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: AddonModQuizOfflineProvider.ATTEMPTS_TABLE, |             name: AddonModQuizOfflineProvider.ATTEMPTS_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -21,7 +21,7 @@ import { CoreTimeUtilsProvider } from '@providers/utils/time'; | |||||||
| import { CoreUtilsProvider } from '@providers/utils/utils'; | import { CoreUtilsProvider } from '@providers/utils/utils'; | ||||||
| import { CoreUserProvider } from '@core/user/providers/user'; | import { CoreUserProvider } from '@core/user/providers/user'; | ||||||
| import { AddonModScormProvider } from './scorm'; | import { AddonModScormProvider } from './scorm'; | ||||||
| import { SQLiteDB } from '@classes/sqlitedb'; | import { SQLiteDB, SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle offline SCORM. |  * Service to handle offline SCORM. | ||||||
| @ -34,7 +34,7 @@ export class AddonModScormOfflineProvider { | |||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     static ATTEMPTS_TABLE = 'addon_mod_scorm_offline_attempts'; |     static ATTEMPTS_TABLE = 'addon_mod_scorm_offline_attempts'; | ||||||
|     static TRACKS_TABLE = 'addon_mod_scorm_offline_scos_tracks'; |     static TRACKS_TABLE = 'addon_mod_scorm_offline_scos_tracks'; | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: AddonModScormOfflineProvider.ATTEMPTS_TABLE, |             name: AddonModScormOfflineProvider.ATTEMPTS_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -16,6 +16,7 @@ import { Injectable } from '@angular/core'; | |||||||
| import { CoreLoggerProvider } from '@providers/logger'; | import { CoreLoggerProvider } from '@providers/logger'; | ||||||
| import { CoreSitesProvider } from '@providers/sites'; | import { CoreSitesProvider } from '@providers/sites'; | ||||||
| import { CoreTextUtilsProvider } from '@providers/utils/text'; | import { CoreTextUtilsProvider } from '@providers/utils/text'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle Offline survey. |  * Service to handle Offline survey. | ||||||
| @ -27,7 +28,7 @@ export class AddonModSurveyOfflineProvider { | |||||||
| 
 | 
 | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     static SURVEY_TABLE = 'addon_mod_survey_answers'; |     static SURVEY_TABLE = 'addon_mod_survey_answers'; | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: AddonModSurveyOfflineProvider.SURVEY_TABLE, |             name: AddonModSurveyOfflineProvider.SURVEY_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -15,6 +15,7 @@ | |||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { CoreLoggerProvider } from '@providers/logger'; | import { CoreLoggerProvider } from '@providers/logger'; | ||||||
| import { CoreSitesProvider } from '@providers/sites'; | import { CoreSitesProvider } from '@providers/sites'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle offline wiki. |  * Service to handle offline wiki. | ||||||
| @ -26,7 +27,7 @@ export class AddonModWikiOfflineProvider { | |||||||
| 
 | 
 | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     static NEW_PAGES_TABLE = 'addon_mod_wiki_new_pages_store'; |     static NEW_PAGES_TABLE = 'addon_mod_wiki_new_pages_store'; | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: AddonModWikiOfflineProvider.NEW_PAGES_TABLE, |             name: AddonModWikiOfflineProvider.NEW_PAGES_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -17,6 +17,7 @@ import { CoreFileProvider } from '@providers/file'; | |||||||
| import { CoreSitesProvider } from '@providers/sites'; | import { CoreSitesProvider } from '@providers/sites'; | ||||||
| import { CoreTextUtilsProvider } from '@providers/utils/text'; | import { CoreTextUtilsProvider } from '@providers/utils/text'; | ||||||
| import { CoreTimeUtilsProvider } from '@providers/utils/time'; | import { CoreTimeUtilsProvider } from '@providers/utils/time'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle offline workshop. |  * Service to handle offline workshop. | ||||||
| @ -30,7 +31,7 @@ export class AddonModWorkshopOfflineProvider { | |||||||
|     static EVALUATE_SUBMISSIONS_TABLE = 'addon_mod_workshop_evaluate_submissions'; |     static EVALUATE_SUBMISSIONS_TABLE = 'addon_mod_workshop_evaluate_submissions'; | ||||||
|     static EVALUATE_ASSESSMENTS_TABLE = 'addon_mod_workshop_evaluate_assessments'; |     static EVALUATE_ASSESSMENTS_TABLE = 'addon_mod_workshop_evaluate_assessments'; | ||||||
| 
 | 
 | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: AddonModWorkshopOfflineProvider.SUBMISSIONS_TABLE, |             name: AddonModWorkshopOfflineProvider.SUBMISSIONS_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -16,6 +16,7 @@ import { Injectable } from '@angular/core'; | |||||||
| import { CoreLoggerProvider } from '@providers/logger'; | import { CoreLoggerProvider } from '@providers/logger'; | ||||||
| import { CoreSitesProvider } from '@providers/sites'; | import { CoreSitesProvider } from '@providers/sites'; | ||||||
| import { CoreTimeUtilsProvider } from '@providers/utils/time'; | import { CoreTimeUtilsProvider } from '@providers/utils/time'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle offline notes. |  * Service to handle offline notes. | ||||||
| @ -26,7 +27,7 @@ export class AddonNotesOfflineProvider { | |||||||
| 
 | 
 | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     static NOTES_TABLE = 'addon_notes_offline_notes'; |     static NOTES_TABLE = 'addon_notes_offline_notes'; | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: AddonNotesOfflineProvider.NOTES_TABLE, |             name: AddonNotesOfflineProvider.NOTES_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -28,6 +28,7 @@ import { CoreConfigProvider } from '@providers/config'; | |||||||
| import { CoreConstants } from '@core/constants'; | import { CoreConstants } from '@core/constants'; | ||||||
| import { CoreConfigConstants } from '../../../configconstants'; | import { CoreConfigConstants } from '../../../configconstants'; | ||||||
| import { ILocalNotification } from '@ionic-native/local-notifications'; | import { ILocalNotification } from '@ionic-native/local-notifications'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle push notifications. |  * Service to handle push notifications. | ||||||
| @ -41,7 +42,7 @@ export class AddonPushNotificationsProvider { | |||||||
| 
 | 
 | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     static BADGE_TABLE = 'addon_pushnotifications_badge'; |     static BADGE_TABLE = 'addon_pushnotifications_badge'; | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: AddonPushNotificationsProvider.BADGE_TABLE, |             name: AddonPushNotificationsProvider.BADGE_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -15,7 +15,7 @@ | |||||||
| import { Injector } from '@angular/core'; | import { Injector } from '@angular/core'; | ||||||
| import { TranslateService } from '@ngx-translate/core'; | import { TranslateService } from '@ngx-translate/core'; | ||||||
| import { HttpClient } from '@angular/common/http'; | import { HttpClient } from '@angular/common/http'; | ||||||
| import { SQLiteDB } from './sqlitedb'; | import { SQLiteDB, SQLiteDBTableSchema } from './sqlitedb'; | ||||||
| import { CoreAppProvider } from '@providers/app'; | import { CoreAppProvider } from '@providers/app'; | ||||||
| import { CoreDbProvider } from '@providers/db'; | import { CoreDbProvider } from '@providers/db'; | ||||||
| import { CoreEventsProvider } from '@providers/events'; | import { CoreEventsProvider } from '@providers/events'; | ||||||
| @ -168,7 +168,7 @@ export class CoreSite { | |||||||
|     // Variables for the database.
 |     // Variables for the database.
 | ||||||
|     protected WS_CACHE_TABLE = 'wscache'; |     protected WS_CACHE_TABLE = 'wscache'; | ||||||
|     protected CONFIG_TABLE = 'core_site_config'; |     protected CONFIG_TABLE = 'core_site_config'; | ||||||
|     protected tableSchemas = [ |     protected tableSchemas: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: this.WS_CACHE_TABLE, |             name: this.WS_CACHE_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -15,6 +15,129 @@ | |||||||
| import { SQLite, SQLiteObject } from '@ionic-native/sqlite'; | import { SQLite, SQLiteObject } from '@ionic-native/sqlite'; | ||||||
| import { Platform } from 'ionic-angular'; | import { Platform } from 'ionic-angular'; | ||||||
| 
 | 
 | ||||||
|  | /** | ||||||
|  |  * Schema of a table. | ||||||
|  |  */ | ||||||
|  | export interface SQLiteDBTableSchema { | ||||||
|  |     /** | ||||||
|  |      * The table name. | ||||||
|  |      * @type {string} | ||||||
|  |      */ | ||||||
|  |     name: string; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * The columns to create in the table. | ||||||
|  |      * @type {SQLiteDBColumnSchema[]} | ||||||
|  |      */ | ||||||
|  |     columns: SQLiteDBColumnSchema[]; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Names of columns that are primary key. Use it for compound primary keys. | ||||||
|  |      * @type {string[]} | ||||||
|  |      */ | ||||||
|  |     primaryKeys?: string[]; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * List of sets of unique columns. E.g: [['section', 'title'], ['author', 'title']]. | ||||||
|  |      * @type {string[][]} | ||||||
|  |      */ | ||||||
|  |     uniqueKeys?: string[][]; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * List of foreign keys. | ||||||
|  |      * @type {SQLiteDBForeignKeySchema[]} | ||||||
|  |      */ | ||||||
|  |     foreignKeys?: SQLiteDBForeignKeySchema[]; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Check constraint for the table. | ||||||
|  |      * @type {string} | ||||||
|  |      */ | ||||||
|  |     tableCheck?: string; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Schema of a column. | ||||||
|  |  */ | ||||||
|  | export interface SQLiteDBColumnSchema { | ||||||
|  |     /** | ||||||
|  |      * Column's name. | ||||||
|  |      * @type {string} | ||||||
|  |      */ | ||||||
|  |     name: string; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Column's type. | ||||||
|  |      * @type {string} | ||||||
|  |      */ | ||||||
|  |     type?: 'INTEGER' | 'REAL' | 'TEXT' | 'BLOB'; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Whether the column is a primary key. Use it only if primary key is a single column. | ||||||
|  |      * @type {boolean} | ||||||
|  |      */ | ||||||
|  |     primaryKey?: boolean; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Whether it should be autoincremented. Only if primaryKey is true. | ||||||
|  |      * @type {boolean} | ||||||
|  |      */ | ||||||
|  |     autoIncrement?: boolean; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * True if column shouldn't be null. | ||||||
|  |      * @type {boolean} | ||||||
|  |      */ | ||||||
|  |     notNull?: boolean; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * WWhether the column is unique. | ||||||
|  |      * @type {boolean} | ||||||
|  |      */ | ||||||
|  |     unique?: boolean; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Check constraint for the column. | ||||||
|  |      * @type {string} | ||||||
|  |      */ | ||||||
|  |     check?: string; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Default value for the column. | ||||||
|  |      * @type {string} | ||||||
|  |      */ | ||||||
|  |     default?: string; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Schema of a foreign key. | ||||||
|  |  */ | ||||||
|  | export interface SQLiteDBForeignKeySchema { | ||||||
|  |     /** | ||||||
|  |      * Columns to include in this foreign key. | ||||||
|  |      * @type {string[]} | ||||||
|  |      */ | ||||||
|  |     columns: string[]; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * The external table referenced by this key. | ||||||
|  |      * @type {string} | ||||||
|  |      */ | ||||||
|  |     table: string; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * List of referenced columns from the referenced table. | ||||||
|  |      * @type {string[]} | ||||||
|  |      */ | ||||||
|  |     foreignColumns?: string[]; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * Text with the actions to apply to the foreign key. | ||||||
|  |      * @type {string} | ||||||
|  |      */ | ||||||
|  |     actions?: string; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /** | /** | ||||||
|  * Class to interact with the local database. |  * Class to interact with the local database. | ||||||
|  * |  * | ||||||
| @ -43,27 +166,15 @@ export class SQLiteDB { | |||||||
|      * Helper function to create a table if it doesn't exist. |      * Helper function to create a table if it doesn't exist. | ||||||
|      * |      * | ||||||
|      * @param {string} name The table name. |      * @param {string} name The table name. | ||||||
|      * @param {any[]} columns The columns to create in the table. Each column can have: |      * @param {SQLiteDBColumnSchema[]} columns The columns to create in the table. | ||||||
|      *                    * {string} name  Column's name. |  | ||||||
|      *                    * {string} [type] Column's type. |  | ||||||
|      *                    * {boolean} [primaryKey] If column is primary key. Use it only if primary key is a single column. |  | ||||||
|      *                    * {boolean} [autoIncrement] Whether it should be autoincremented. Only if primaryKey is true. |  | ||||||
|      *                    * {boolean} [notNull] True if column shouldn't be null. |  | ||||||
|      *                    * {boolean} [unique] Whether the column is unique. |  | ||||||
|      *                    * {string} [check] Check constraint for the column. |  | ||||||
|      *                    * {string} [default] Default value for the column. |  | ||||||
|      * @param {string[]} [primaryKeys] Names of columns that are primary key. Use it for compound primary keys. |      * @param {string[]} [primaryKeys] Names of columns that are primary key. Use it for compound primary keys. | ||||||
|      * @param {string[][]} [uniqueKeys] List of sets of unique columns. E.g: [['section', 'title'], ['author', 'title']]. |      * @param {string[][]} [uniqueKeys] List of sets of unique columns. E.g: [['section', 'title'], ['author', 'title']]. | ||||||
|      * @param {any[]} [foreignKeys] List of foreign keys. Each key can have: |      * @param {SQLiteDBForeignKeySchema[]} [foreignKeys] List of foreign keys. | ||||||
|      *                    * {string[]} columns Columns to include in this foreign key. |  | ||||||
|      *                    * {string} table The external table referenced by this key. |  | ||||||
|      *                    * {string[]} [foreignColumns] List of referenced columns from the referenced table. |  | ||||||
|      *                    * {string} [actions] Text with the actions to apply to the foreign key. |  | ||||||
|      * @param {string} [tableCheck] Check constraint for the table. |      * @param {string} [tableCheck] Check constraint for the table. | ||||||
|      * @return SQL query. |      * @return SQL query. | ||||||
|      */ |      */ | ||||||
|     buildCreateTableSql(name: string, columns: any[], primaryKeys?: string[], uniqueKeys?: string[][], foreignKeys?: any[], |     buildCreateTableSql(name: string, columns: SQLiteDBColumnSchema[], primaryKeys?: string[], uniqueKeys?: string[][], | ||||||
|             tableCheck?: string): string { |             foreignKeys?: SQLiteDBForeignKeySchema[], tableCheck?: string): string { | ||||||
|         const columnsSql = []; |         const columnsSql = []; | ||||||
|         let sql = `CREATE TABLE IF NOT EXISTS ${name} (`; |         let sql = `CREATE TABLE IF NOT EXISTS ${name} (`; | ||||||
| 
 | 
 | ||||||
| @ -207,27 +318,15 @@ export class SQLiteDB { | |||||||
|      * Create a table if it doesn't exist. |      * Create a table if it doesn't exist. | ||||||
|      * |      * | ||||||
|      * @param {string} name The table name. |      * @param {string} name The table name. | ||||||
|      * @param {any[]} columns The columns to create in the table. Each column can have: |      * @param {SQLiteDBColumnSchema[]} columns The columns to create in the table. | ||||||
|      *                    * {string} name  Column's name. |  | ||||||
|      *                    * {string} [type] Column's type. |  | ||||||
|      *                    * {boolean} [primaryKey] If column is primary key. Use it only if primary key is a single column. |  | ||||||
|      *                    * {boolean} [autoIncrement] Whether it should be autoincremented. Only if primaryKey is true. |  | ||||||
|      *                    * {boolean} [notNull] True if column shouldn't be null. |  | ||||||
|      *                    * {boolean} [unique] Whether the column is unique. |  | ||||||
|      *                    * {string} [check] Check constraint for the column. |  | ||||||
|      *                    * {string} [default] Default value for the column. |  | ||||||
|      * @param {string[]} [primaryKeys] Names of columns that are primary key. Use it for compound primary keys. |      * @param {string[]} [primaryKeys] Names of columns that are primary key. Use it for compound primary keys. | ||||||
|      * @param {string[][]} [uniqueKeys] List of sets of unique columns. E.g: [['section', 'title'], ['author', 'title']]. |      * @param {string[][]} [uniqueKeys] List of sets of unique columns. E.g: [['section', 'title'], ['author', 'title']]. | ||||||
|      * @param {any[]} [foreignKeys] List of foreign keys. Each key can have: |      * @param {SQLiteDBForeignKeySchema[]} [foreignKeys] List of foreign keys. | ||||||
|      *                    * {string[]} columns Columns to include in this foreign key. |  | ||||||
|      *                    * {string} table The external table referenced by this key. |  | ||||||
|      *                    * {string[]} [foreignColumns] List of referenced columns from the referenced table. |  | ||||||
|      *                    * {string} [actions] Text with the actions to apply to the foreign key. |  | ||||||
|      * @param {string} [tableCheck] Check constraint for the table. |      * @param {string} [tableCheck] Check constraint for the table. | ||||||
|      * @return {Promise<any>} Promise resolved when success. |      * @return {Promise<any>} Promise resolved when success. | ||||||
|      */ |      */ | ||||||
|     createTable(name: string, columns: any[], primaryKeys?: string[], uniqueKeys?: string[][], foreignKeys?: any[], |     createTable(name: string, columns: SQLiteDBColumnSchema[], primaryKeys?: string[], uniqueKeys?: string[][], | ||||||
|             tableCheck?: string): Promise<any> { |             foreignKeys?: SQLiteDBForeignKeySchema[], tableCheck?: string): Promise<any> { | ||||||
|         const sql = this.buildCreateTableSql(name, columns, primaryKeys, uniqueKeys, foreignKeys, tableCheck); |         const sql = this.buildCreateTableSql(name, columns, primaryKeys, uniqueKeys, foreignKeys, tableCheck); | ||||||
| 
 | 
 | ||||||
|         return this.execute(sql); |         return this.execute(sql); | ||||||
| @ -236,10 +335,10 @@ export class SQLiteDB { | |||||||
|     /** |     /** | ||||||
|      * Create a table if it doesn't exist from a schema. |      * Create a table if it doesn't exist from a schema. | ||||||
|      * |      * | ||||||
|      * @param {any} table Table schema. |      * @param {SQLiteDBTableSchema} table Table schema. | ||||||
|      * @return {Promise<any>} Promise resolved when success. |      * @return {Promise<any>} Promise resolved when success. | ||||||
|      */ |      */ | ||||||
|     createTableFromSchema(table: any): Promise<any> { |     createTableFromSchema(table: SQLiteDBTableSchema): Promise<any> { | ||||||
|         return this.createTable(table.name, table.columns, table.primaryKeys, table.uniqueKeys, |         return this.createTable(table.name, table.columns, table.primaryKeys, table.uniqueKeys, | ||||||
|             table.foreignKeys, table.tableCheck); |             table.foreignKeys, table.tableCheck); | ||||||
|     } |     } | ||||||
| @ -247,10 +346,10 @@ export class SQLiteDB { | |||||||
|     /** |     /** | ||||||
|      * Create several tables if they don't exist from a list of schemas. |      * Create several tables if they don't exist from a list of schemas. | ||||||
|      * |      * | ||||||
|      * @param {any[]} tables List of table schema. |      * @param {SQLiteDBTableSchema[]} tables List of table schema. | ||||||
|      * @return {Promise<any>} Promise resolved when success. |      * @return {Promise<any>} Promise resolved when success. | ||||||
|      */ |      */ | ||||||
|     createTablesFromSchema(tables: any[]): Promise<any> { |     createTablesFromSchema(tables: SQLiteDBTableSchema[]): Promise<any> { | ||||||
|         const promises = []; |         const promises = []; | ||||||
|         tables.forEach((table) => { |         tables.forEach((table) => { | ||||||
|             promises.push(this.createTableFromSchema(table)); |             promises.push(this.createTableFromSchema(table)); | ||||||
|  | |||||||
| @ -14,6 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { CoreSitesProvider } from '@providers/sites'; | import { CoreSitesProvider } from '@providers/sites'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to handle offline data for courses. |  * Service to handle offline data for courses. | ||||||
| @ -23,7 +24,7 @@ export class CoreCourseOfflineProvider { | |||||||
| 
 | 
 | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     static MANUAL_COMPLETION_TABLE = 'course_manual_completion'; |     static MANUAL_COMPLETION_TABLE = 'course_manual_completion'; | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: CoreCourseOfflineProvider.MANUAL_COMPLETION_TABLE, |             name: CoreCourseOfflineProvider.MANUAL_COMPLETION_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -23,6 +23,7 @@ import { CoreUtilsProvider } from '@providers/utils/utils'; | |||||||
| import { CoreSiteWSPreSets, CoreSite } from '@classes/site'; | import { CoreSiteWSPreSets, CoreSite } from '@classes/site'; | ||||||
| import { CoreConstants } from '../../constants'; | import { CoreConstants } from '../../constants'; | ||||||
| import { CoreCourseOfflineProvider } from './course-offline'; | import { CoreCourseOfflineProvider } from './course-offline'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service that provides some features regarding a course. |  * Service that provides some features regarding a course. | ||||||
| @ -47,7 +48,7 @@ export class CoreCourseProvider { | |||||||
| 
 | 
 | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     protected COURSE_STATUS_TABLE = 'course_status'; |     protected COURSE_STATUS_TABLE = 'course_status'; | ||||||
|     protected courseStatusTableSchema = { |     protected courseStatusTableSchema: SQLiteDBTableSchema = { | ||||||
|         name: this.COURSE_STATUS_TABLE, |         name: this.COURSE_STATUS_TABLE, | ||||||
|         columns: [ |         columns: [ | ||||||
|             { |             { | ||||||
|  | |||||||
| @ -27,6 +27,7 @@ import { CoreConstants } from '../../constants'; | |||||||
| import { Md5 } from 'ts-md5/dist/md5'; | import { Md5 } from 'ts-md5/dist/md5'; | ||||||
| import { Subject, BehaviorSubject, Subscription } from 'rxjs'; | import { Subject, BehaviorSubject, Subscription } from 'rxjs'; | ||||||
| import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate'; | import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Progress of downloading a list of modules. |  * Progress of downloading a list of modules. | ||||||
| @ -202,7 +203,7 @@ export interface CoreCourseModulePrefetchHandler extends CoreDelegateHandler { | |||||||
| export class CoreCourseModulePrefetchDelegate extends CoreDelegate { | export class CoreCourseModulePrefetchDelegate extends CoreDelegate { | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     protected CHECK_UPDATES_TIMES_TABLE = 'check_updates_times'; |     protected CHECK_UPDATES_TIMES_TABLE = 'check_updates_times'; | ||||||
|     protected checkUpdatesTableSchema = { |     protected checkUpdatesTableSchema: SQLiteDBTableSchema = { | ||||||
|         name: this.CHECK_UPDATES_TIMES_TABLE, |         name: this.CHECK_UPDATES_TIMES_TABLE, | ||||||
|         columns: [ |         columns: [ | ||||||
|             { |             { | ||||||
|  | |||||||
| @ -26,6 +26,7 @@ import { CoreTimeUtilsProvider } from '@providers/utils/time'; | |||||||
| import { FileTransferErrorMock } from './file-transfer'; | import { FileTransferErrorMock } from './file-transfer'; | ||||||
| import { CoreEmulatorCaptureHelperProvider } from './capture-helper'; | import { CoreEmulatorCaptureHelperProvider } from './capture-helper'; | ||||||
| import { CoreConstants } from '../../constants'; | import { CoreConstants } from '../../constants'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Helper service for the emulator feature. It also acts as an init handler. |  * Helper service for the emulator feature. It also acts as an init handler. | ||||||
| @ -40,7 +41,7 @@ export class CoreEmulatorHelperProvider implements CoreInitHandler { | |||||||
| 
 | 
 | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     protected LAST_RECEIVED_NOTIFICATION_TABLE = 'core_emulator_last_received_notification'; |     protected LAST_RECEIVED_NOTIFICATION_TABLE = 'core_emulator_last_received_notification'; | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: this.LAST_RECEIVED_NOTIFICATION_TABLE, |             name: this.LAST_RECEIVED_NOTIFICATION_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ import { LocalNotifications, ILocalNotification, ILocalNotificationAction } from | |||||||
| import { CoreAppProvider } from '@providers/app'; | import { CoreAppProvider } from '@providers/app'; | ||||||
| import { CoreTextUtilsProvider } from '@providers/utils/text'; | import { CoreTextUtilsProvider } from '@providers/utils/text'; | ||||||
| import { CoreUtilsProvider } from '@providers/utils/utils'; | import { CoreUtilsProvider } from '@providers/utils/utils'; | ||||||
| import { SQLiteDB } from '@classes/sqlitedb'; | import { SQLiteDB, SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| import { CoreConstants } from '@core/constants'; | import { CoreConstants } from '@core/constants'; | ||||||
| import { CoreConfigConstants } from '../../../configconstants'; | import { CoreConfigConstants } from '../../../configconstants'; | ||||||
| import * as moment from 'moment'; | import * as moment from 'moment'; | ||||||
| @ -43,7 +43,7 @@ export class LocalNotificationsMock extends LocalNotifications { | |||||||
| 
 | 
 | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     protected DESKTOP_NOTIFS_TABLE = 'desktop_local_notifications'; |     protected DESKTOP_NOTIFS_TABLE = 'desktop_local_notifications'; | ||||||
|     protected tableSchema = { |     protected tableSchema: SQLiteDBTableSchema = { | ||||||
|         name: this.DESKTOP_NOTIFS_TABLE, |         name: this.DESKTOP_NOTIFS_TABLE, | ||||||
|         columns: [ |         columns: [ | ||||||
|             { |             { | ||||||
|  | |||||||
| @ -17,6 +17,7 @@ import { CoreLoggerProvider } from '@providers/logger'; | |||||||
| import { CoreSitesProvider } from '@providers/sites'; | import { CoreSitesProvider } from '@providers/sites'; | ||||||
| import { CoreTimeUtilsProvider } from '@providers/utils/time'; | import { CoreTimeUtilsProvider } from '@providers/utils/time'; | ||||||
| import { CoreUtilsProvider } from '@providers/utils/utils'; | import { CoreUtilsProvider } from '@providers/utils/utils'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * An object to represent a question state. |  * An object to represent a question state. | ||||||
| @ -63,7 +64,7 @@ export class CoreQuestionProvider { | |||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     protected QUESTION_TABLE = 'questions'; |     protected QUESTION_TABLE = 'questions'; | ||||||
|     protected QUESTION_ANSWERS_TABLE = 'question_answers'; |     protected QUESTION_ANSWERS_TABLE = 'question_answers'; | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: this.QUESTION_TABLE, |             name: this.QUESTION_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -21,7 +21,7 @@ import { CoreSitesProvider } from '@providers/sites'; | |||||||
| import { CoreMimetypeUtilsProvider } from '@providers/utils/mimetype'; | import { CoreMimetypeUtilsProvider } from '@providers/utils/mimetype'; | ||||||
| import { CoreTextUtilsProvider } from '@providers/utils/text'; | import { CoreTextUtilsProvider } from '@providers/utils/text'; | ||||||
| import { Md5 } from 'ts-md5/dist/md5'; | import { Md5 } from 'ts-md5/dist/md5'; | ||||||
| import { SQLiteDB } from '@classes/sqlitedb'; | import { SQLiteDB, SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to share files with the app. |  * Service to share files with the app. | ||||||
| @ -32,7 +32,7 @@ export class CoreSharedFilesProvider { | |||||||
| 
 | 
 | ||||||
|     // Variables for the database.
 |     // Variables for the database.
 | ||||||
|     protected SHARED_FILES_TABLE = 'shared_files'; |     protected SHARED_FILES_TABLE = 'shared_files'; | ||||||
|     protected tableSchema = { |     protected tableSchema: SQLiteDBTableSchema = { | ||||||
|         name: this.SHARED_FILES_TABLE, |         name: this.SHARED_FILES_TABLE, | ||||||
|         columns: [ |         columns: [ | ||||||
|             { |             { | ||||||
|  | |||||||
| @ -18,6 +18,7 @@ import { CoreLoggerProvider } from '@providers/logger'; | |||||||
| import { CoreSite } from '@classes/site'; | import { CoreSite } from '@classes/site'; | ||||||
| import { CoreSitesProvider } from '@providers/sites'; | import { CoreSitesProvider } from '@providers/sites'; | ||||||
| import { CoreUtilsProvider } from '@providers/utils/utils'; | import { CoreUtilsProvider } from '@providers/utils/utils'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Service to provide user functionalities. |  * Service to provide user functionalities. | ||||||
| @ -31,7 +32,7 @@ export class CoreUserProvider { | |||||||
| 
 | 
 | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     protected USERS_TABLE = 'users'; |     protected USERS_TABLE = 'users'; | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: this.USERS_TABLE, |             name: this.USERS_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { CoreAppProvider } from './app'; | import { CoreAppProvider } from './app'; | ||||||
| import { SQLiteDB } from '@classes/sqlitedb'; | import { SQLiteDB, SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Factory to provide access to dynamic and permanent config and settings. |  * Factory to provide access to dynamic and permanent config and settings. | ||||||
| @ -24,7 +24,7 @@ import { SQLiteDB } from '@classes/sqlitedb'; | |||||||
| export class CoreConfigProvider { | export class CoreConfigProvider { | ||||||
|     protected appDB: SQLiteDB; |     protected appDB: SQLiteDB; | ||||||
|     protected TABLE_NAME = 'core_config'; |     protected TABLE_NAME = 'core_config'; | ||||||
|     protected tableSchema = { |     protected tableSchema: SQLiteDBTableSchema = { | ||||||
|         name: this.TABLE_NAME, |         name: this.TABLE_NAME, | ||||||
|         columns: [ |         columns: [ | ||||||
|             { |             { | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ import { CoreConfigProvider } from './config'; | |||||||
| import { CoreLoggerProvider } from './logger'; | import { CoreLoggerProvider } from './logger'; | ||||||
| import { CoreUtilsProvider } from './utils/utils'; | import { CoreUtilsProvider } from './utils/utils'; | ||||||
| import { CoreConstants } from '@core/constants'; | import { CoreConstants } from '@core/constants'; | ||||||
| import { SQLiteDB } from '@classes/sqlitedb'; | import { SQLiteDB, SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Interface that all cron handlers must implement. |  * Interface that all cron handlers must implement. | ||||||
| @ -94,7 +94,7 @@ export class CoreCronDelegate { | |||||||
| 
 | 
 | ||||||
|     // Variables for database.
 |     // Variables for database.
 | ||||||
|     protected CRON_TABLE = 'cron'; |     protected CRON_TABLE = 'cron'; | ||||||
|     protected tableSchema = { |     protected tableSchema: SQLiteDBTableSchema = { | ||||||
|         name: this.CRON_TABLE, |         name: this.CRON_TABLE, | ||||||
|         columns: [ |         columns: [ | ||||||
|             { |             { | ||||||
|  | |||||||
| @ -28,7 +28,7 @@ import { CoreTextUtilsProvider } from './utils/text'; | |||||||
| import { CoreTimeUtilsProvider } from './utils/time'; | import { CoreTimeUtilsProvider } from './utils/time'; | ||||||
| import { CoreUrlUtilsProvider } from './utils/url'; | import { CoreUrlUtilsProvider } from './utils/url'; | ||||||
| import { CoreUtilsProvider } from './utils/utils'; | import { CoreUtilsProvider } from './utils/utils'; | ||||||
| import { SQLiteDB } from '@classes/sqlitedb'; | import { SQLiteDB, SQLiteDBTableSchema } 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'; | ||||||
| 
 | 
 | ||||||
| @ -254,7 +254,7 @@ export class CoreFilepoolProvider { | |||||||
|     protected FILES_TABLE = 'filepool_files'; // Downloaded files.
 |     protected FILES_TABLE = 'filepool_files'; // Downloaded files.
 | ||||||
|     protected LINKS_TABLE = 'filepool_files_links'; // Links between downloaded files and components.
 |     protected LINKS_TABLE = 'filepool_files_links'; // Links between downloaded files and components.
 | ||||||
|     protected PACKAGES_TABLE = 'filepool_packages'; // Downloaded packages (sets of files).
 |     protected PACKAGES_TABLE = 'filepool_packages'; // Downloaded packages (sets of files).
 | ||||||
|     protected appTablesSchema = [ |     protected appTablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: this.QUEUE_TABLE, |             name: this.QUEUE_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
| @ -306,7 +306,7 @@ export class CoreFilepoolProvider { | |||||||
|             primaryKeys: ['siteId', 'fileId'] |             primaryKeys: ['siteId', 'fileId'] | ||||||
|         } |         } | ||||||
|     ]; |     ]; | ||||||
|     protected sitesTablesSchema = [ |     protected sitesTablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: this.FILES_TABLE, |             name: this.FILES_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -22,7 +22,7 @@ import { CoreEventsProvider } from './events'; | |||||||
| import { CoreLoggerProvider } from './logger'; | import { CoreLoggerProvider } from './logger'; | ||||||
| import { CoreTextUtilsProvider } from './utils/text'; | import { CoreTextUtilsProvider } from './utils/text'; | ||||||
| import { CoreUtilsProvider } from './utils/utils'; | import { CoreUtilsProvider } from './utils/utils'; | ||||||
| import { SQLiteDB } from '@classes/sqlitedb'; | import { SQLiteDB, SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| import { CoreConstants } from '@core/constants'; | import { CoreConstants } from '@core/constants'; | ||||||
| import { Subject, Subscription } from 'rxjs'; | import { Subject, Subscription } from 'rxjs'; | ||||||
| 
 | 
 | ||||||
| @ -38,7 +38,7 @@ export class CoreLocalNotificationsProvider { | |||||||
|     protected SITES_TABLE = 'notification_sites'; // Store to asigne unique codes to each site.
 |     protected SITES_TABLE = 'notification_sites'; // Store to asigne unique codes to each site.
 | ||||||
|     protected COMPONENTS_TABLE = 'notification_components'; // Store to asigne unique codes to each component.
 |     protected COMPONENTS_TABLE = 'notification_components'; // Store to asigne unique codes to each component.
 | ||||||
|     protected TRIGGERED_TABLE = 'notifications_triggered'; // Store to prevent re-triggering notifications.
 |     protected TRIGGERED_TABLE = 'notifications_triggered'; // Store to prevent re-triggering notifications.
 | ||||||
|     protected tablesSchema = [ |     protected tablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: this.SITES_TABLE, |             name: this.SITES_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
|  | |||||||
| @ -25,7 +25,7 @@ import { CoreUtilsProvider } from './utils/utils'; | |||||||
| import { CoreConstants } from '@core/constants'; | import { CoreConstants } from '@core/constants'; | ||||||
| import { CoreConfigConstants } from '../configconstants'; | import { CoreConfigConstants } from '../configconstants'; | ||||||
| import { CoreSite } from '@classes/site'; | import { CoreSite } from '@classes/site'; | ||||||
| import { SQLiteDB } from '@classes/sqlitedb'; | import { SQLiteDB, SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| import { Md5 } from 'ts-md5/dist/md5'; | import { Md5 } from 'ts-md5/dist/md5'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
| @ -143,7 +143,7 @@ export class CoreSitesProvider { | |||||||
|     // Variables for the database.
 |     // Variables for the database.
 | ||||||
|     protected SITES_TABLE = 'sites'; |     protected SITES_TABLE = 'sites'; | ||||||
|     protected CURRENT_SITE_TABLE = 'current_site'; |     protected CURRENT_SITE_TABLE = 'current_site'; | ||||||
|     protected appTablesSchema = [ |     protected appTablesSchema: SQLiteDBTableSchema[] = [ | ||||||
|         { |         { | ||||||
|             name: this.SITES_TABLE, |             name: this.SITES_TABLE, | ||||||
|             columns: [ |             columns: [ | ||||||
| @ -1251,18 +1251,18 @@ export class CoreSitesProvider { | |||||||
|     /** |     /** | ||||||
|      * Create a table in all the sites databases. |      * Create a table in all the sites databases. | ||||||
|      * |      * | ||||||
|      * @param {any} table Table schema. |      * @param {SQLiteDBTamableSchema} table Table schema. | ||||||
|      */ |      */ | ||||||
|     createTableFromSchema(table: any): void { |     createTableFromSchema(table: SQLiteDBTableSchema): void { | ||||||
|         this.createTablesFromSchema([table]); |         this.createTablesFromSchema([table]); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * Create several tables in all the sites databases. |      * Create several tables in all the sites databases. | ||||||
|      * |      * | ||||||
|      * @param {any[]} tables List of tables schema. |      * @param {SQLiteDBTamableSchema[]} tables List of tables schema. | ||||||
|      */ |      */ | ||||||
|     createTablesFromSchema(tables: any[]): void { |     createTablesFromSchema(tables: SQLiteDBTableSchema[]): void { | ||||||
|         // Add the tables to the list of schemas. This list is to create all the tables in new sites.
 |         // Add the tables to the list of schemas. This list is to create all the tables in new sites.
 | ||||||
|         this.siteTablesSchemas = this.siteTablesSchemas.concat(tables); |         this.siteTablesSchemas = this.siteTablesSchemas.concat(tables); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -15,6 +15,7 @@ | |||||||
| import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||||
| import { CoreEventsProvider } from './events'; | import { CoreEventsProvider } from './events'; | ||||||
| import { CoreSitesProvider } from './sites'; | import { CoreSitesProvider } from './sites'; | ||||||
|  | import { SQLiteDBTableSchema } from '@classes/sqlitedb'; | ||||||
| 
 | 
 | ||||||
| /* | /* | ||||||
|  * Service that provides some features regarding synchronization. |  * Service that provides some features regarding synchronization. | ||||||
| @ -24,7 +25,7 @@ export class CoreSyncProvider { | |||||||
| 
 | 
 | ||||||
|     // Variables for the database.
 |     // Variables for the database.
 | ||||||
|     protected SYNC_TABLE = 'sync'; |     protected SYNC_TABLE = 'sync'; | ||||||
|     protected tableSchema = { |     protected tableSchema: SQLiteDBTableSchema = { | ||||||
|         name: this.SYNC_TABLE, |         name: this.SYNC_TABLE, | ||||||
|         columns: [ |         columns: [ | ||||||
|             { |             { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user