diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index ce0ad7dbd..6ef8d4f55 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -38,7 +38,7 @@ export class AppComponent {
private sqliteservice: SqliteService,
private InativityService: InativityService,
public ThemeService: ThemeService,
- private storage: Storage,
+ private storage: Storage
) {
this.initializeApp();
this.storage.set('version', environment.version).then(() => {})
@@ -62,7 +62,7 @@ export class AppComponent {
try {
this.sqliteservice.databaseConn();
} catch (error) {
- console.error("Error creating local database: ", error)
+ console.error("Error creating local database: ", error)
}
}
diff --git a/src/app/pages/agenda/new-event/new-event.page.ts b/src/app/pages/agenda/new-event/new-event.page.ts
index 804edb193..07e03d7e3 100644
--- a/src/app/pages/agenda/new-event/new-event.page.ts
+++ b/src/app/pages/agenda/new-event/new-event.page.ts
@@ -393,16 +393,21 @@ export class NewEventPage implements OnInit {
if(this.loggeduser.Profile == 'MDGPR') {
eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
-
+ this.toastService._successMessage('Evento criado');
+
}
else if(this.loggeduser.Profile == 'PR') {
const CalendarId = this.selectedCalendarId()
eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
+ this.toastService._successMessage('Evento criado');
+
} else {
const CalendarId = this.selectedCalendarId()
eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
+ this.toastService._successMessage('Evento criado');
+
}
const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
@@ -440,7 +445,6 @@ export class NewEventPage implements OnInit {
this.chatMethodService.sendMessage(this.roomId, data1);
}
- this.toastService._successMessage()
let data = Object.assign(this.postEvent,{id:eventId})
this.modalController.dismiss(data);
diff --git a/src/app/pages/chat/chat.page.ts b/src/app/pages/chat/chat.page.ts
index d90ef3bc7..31f8c4831 100644
--- a/src/app/pages/chat/chat.page.ts
+++ b/src/app/pages/chat/chat.page.ts
@@ -222,7 +222,8 @@ export class ChatPage implements OnInit {
this.idSelected = '';
this.hideRefreshBtn = false;
this.closeAllDesktopComponents()
- this.ChatSystemService.getRoomById(this.roomId).roomLeave()
+
+ this.ChatSystemService.getRoomById(this.roomId)?.roomLeave()
}
else {
this.hideRefreshBtn = true;
diff --git a/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts b/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts
index 06920d731..fcde38383 100644
--- a/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts
+++ b/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts
@@ -388,11 +388,11 @@ export class DespachoPage implements OnInit {
this.despachoService.sendExpedienteToPending(this.serialnumber).subscribe(res => {
this.goBack();
loader.remove()
- this.toastService.successMessage()
+ this.toastService._successMessage("Processo enviado para pendestes")
},
error => {
loader.remove()
- this.toastService.badRequest("Processo não enviado para despacho")
+ this.toastService._badRequest("Processo não enviado para pendestes")
});
// loader.remove()
}
diff --git a/src/app/pages/gabinete-digital/gabinete-digital.page.ts b/src/app/pages/gabinete-digital/gabinete-digital.page.ts
index 3cee29768..dc3687d14 100644
--- a/src/app/pages/gabinete-digital/gabinete-digital.page.ts
+++ b/src/app/pages/gabinete-digital/gabinete-digital.page.ts
@@ -182,11 +182,9 @@ export class GabineteDigitalPage implements OnInit {
if(this.NotificationsService.active === false) {
this.checkRoutes();
this.LoadCounts();
- this.updateAllProcess()
} else {
this.checkRoutes();
this.LoadCounts();
- this.updateAllProcess()
}
}
})
@@ -657,11 +655,9 @@ export class GabineteDigitalPage implements OnInit {
expedientes = expedientes.map((element) => this.expedienteTaskPipe.transform(element));
this.expedientegbstore.reset(expedientes);
- this.updateAllProcess()
let despachos = await this.despachoRule.getList({ updateStore: true })
- this.updateAllProcess()
if (despachos) {
this.despachoStore.reset(despachos)
}
@@ -712,7 +708,6 @@ export class GabineteDigitalPage implements OnInit {
pendentes = pendentes.map((element)=> this.customTaskPipe.transform(element))
this.pendentesstore.reset(pendentes);
- this.updateAllProcess()
let depachoAPI = await this.processesbackend.GetTasksList("Despacho do Presidente da República", false).toPromise();
@@ -725,15 +720,49 @@ export class GabineteDigitalPage implements OnInit {
depacho = depacho.map((e)=> this.customTaskPipe.transform(e))
this.despachoprstore.reset(depacho)
- this.updateAllProcess()
+
} else if(SessionStore.user.Profile == 'PR') {
let depacho: any = depachoAPI.filter(data => data.activityInstanceName == "Concluir Despacho").filter(data => data.workflowInstanceDataFields.Status == "Active")
depacho = depacho.map((e)=> this.customTaskPipe.transform(e))
this.despachoprstore.reset(depacho)
- this.updateAllProcess()
+
}
+ let diplomasValidar = depachoAPI.filter(data => data.activityInstanceName == "Revisar Diploma");
+
+ diplomasValidar = diplomasValidar.filter(data => data.activityInstanceName != "Tarefa de Despacho");
+
+
+ this.deplomasStore.resetDiplomasReview(diplomasValidar.map((element)=> {
+
+ let date = new Date(element.taskStartDate);
+ date.setMonth(date.getMonth() + 1);
+ let taskDate = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds();
+
+ return {
+ "SerialNumber": element.serialNumber,
+ "Folio": element.workflowInstanceDataFields.Subject,
+ "Senders": element.workflowInstanceDataFields.Sender,
+ "CreateDate": taskDate,
+ "DocumentURL": element.workflowInstanceDataFields.ViewerRequest,
+ "Remetente": element.workflowInstanceDataFields.Remetente,
+ "DocumentsQty": element.totalDocuments,
+ "DocId": element.workflowInstanceDataFields.DocIdDiferimento,
+ "WorkflowName": element.workflowDisplayName,
+ "activityInstanceName": element.activityInstanceName,
+ "Status": element.workflowInstanceDataFields.Status,
+ }
+ }))
+
+
+ let diplomasAssinar: any = depachoAPI.filter(data => data.activityInstanceName == "Assinar Diploma");
+ diplomasAssinar = diplomasAssinar.map((element) => this.expedienteTaskPipe.transform(element))
+ this.deplomasStore.resetDiplomasParaAssinar(diplomasAssinar)
+
+ let diplomasAssinados: any = depachoAPI.filter(data => data.activityInstanceName == "Diploma Assinado");
+ diplomasAssinados = diplomasAssinados.map((element) => this.expedienteTaskPipe.transform(element))
+ this.deplomasStore.resetDiplomasAssinadoList(diplomasAssinados)
for(let calendar of this.eventService.calendarNamesAry) {
if(calendar == 'Meu calendario') {
@@ -776,45 +805,8 @@ export class GabineteDigitalPage implements OnInit {
// this.eventoaprovacaostore.countPr = eventsPRList.length
// this.eventoaprovacaostore.resetpr(eventsPRList);
- this.updateAllProcess()
-
- let diplomasValidar = depachoAPI.filter(data => data.activityInstanceName == "Revisar Diploma");
-
- diplomasValidar = diplomasValidar.filter(data => data.activityInstanceName != "Tarefa de Despacho");
- this.deplomasStore.resetDiplomasReview(diplomasValidar.map((element)=> {
-
- let date = new Date(element.taskStartDate);
- date.setMonth(date.getMonth() + 1);
- let taskDate = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds();
-
- return {
- "SerialNumber": element.serialNumber,
- "Folio": element.workflowInstanceDataFields.Subject,
- "Senders": element.workflowInstanceDataFields.Sender,
- "CreateDate": taskDate,
- "DocumentURL": element.workflowInstanceDataFields.ViewerRequest,
- "Remetente": element.workflowInstanceDataFields.Remetente,
- "DocumentsQty": element.totalDocuments,
- "DocId": element.workflowInstanceDataFields.DocIdDiferimento,
- "WorkflowName": element.workflowDisplayName,
- "activityInstanceName": element.activityInstanceName,
- "Status": element.workflowInstanceDataFields.Status,
- }
- }))
-
-
- let diplomasAssinar: any = depachoAPI.filter(data => data.activityInstanceName == "Assinar Diploma");
- diplomasAssinar = diplomasAssinar.map((element) => this.expedienteTaskPipe.transform(element))
- this.deplomasStore.resetDiplomasParaAssinar(diplomasAssinar)
-
- let diplomasAssinados: any = depachoAPI.filter(data => data.activityInstanceName == "Diploma Assinado");
- diplomasAssinados = diplomasAssinados.map((element) => this.expedienteTaskPipe.transform(element))
- this.deplomasStore.resetDiplomasAssinadoList(diplomasAssinados)
-
-
- this.updateAllProcess()
this.loadCount = true
}
diff --git a/src/app/pages/publications/publication-detail/publication-detail.page.html b/src/app/pages/publications/publication-detail/publication-detail.page.html
index 5972a1a12..da36dd843 100644
--- a/src/app/pages/publications/publication-detail/publication-detail.page.html
+++ b/src/app/pages/publications/publication-detail/publication-detail.page.html
@@ -27,7 +27,7 @@
-
{{publication.Message}}
+
{{publication.Message}}
diff --git a/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.html b/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.html
index 25ccf90b8..efd173932 100644
--- a/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.html
+++ b/src/app/pages/publications/view-publications/publication-detail/publication-detail.page.html
@@ -30,7 +30,7 @@
-
{{publication.Message}}
+
{{publication.Message}}
diff --git a/src/app/pages/publications/view-publications/view-publications.page.html b/src/app/pages/publications/view-publications/view-publications.page.html
index efcd8a52b..033a353ec 100644
--- a/src/app/pages/publications/view-publications/view-publications.page.html
+++ b/src/app/pages/publications/view-publications/view-publications.page.html
@@ -49,7 +49,7 @@
{{publication.DatePublication | date: 'dd-MM-yy HH:mm'}}
-
{{publication.Message}}
+
{{publication.Message}}
diff --git a/src/app/services/chat/message.service.ts b/src/app/services/chat/message.service.ts
index d4f93829a..a0c279faf 100644
--- a/src/app/services/chat/message.service.ts
+++ b/src/app/services/chat/message.service.ts
@@ -562,7 +562,9 @@ export class MessageService {
}
for( const [name, value] of Object.entries(message)) {
- this.rowInstance[name] = value
+ try {
+ this.rowInstance[name] = value
+ } catch (error) {}
}
await this.rowInstance.save()
diff --git a/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts b/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts
index 0be6a4e27..8bf877621 100644
--- a/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts
+++ b/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts
@@ -42,23 +42,23 @@ export class AllProcessesPage implements OnInit {
) {
this.loggeduser = SessionStore.user;
- window['all-process'] = this.updateAllProcess
+ window['all-process'] = () => {
+ if(window.location.href.includes('?processes=true')) {
+ this.updateAllProcess()
+ }
+ }
}
ngOnInit() {
+ this.updateAllProcess()
- // this.loadAllProcesses();
- this.updateAllProcess()
-
- this.router.events.forEach((event) => {
- if (event instanceof NavigationStart && event.url.startsWith('/home/gabinete-digital')) {
- if (window.location.pathname.startsWith('/home/gabinete-digital')) {
- this.refreshing();
- } else {
- // this.loadAllProcesses();
- }
+ this.router.events.forEach((event) => {
+ if (event instanceof NavigationStart && event.url.startsWith('/home/gabinete-digital')) {
+ if (window.location.pathname.startsWith('/home/gabinete-digital')) {
+ this.refreshing();
}
- });
+ }
+ });
}
doRefresh(event) {
diff --git a/src/app/shared/header/header.page.html b/src/app/shared/header/header.page.html
index 1be4eaaea..cc8bf0f7f 100644
--- a/src/app/shared/header/header.page.html
+++ b/src/app/shared/header/header.page.html
@@ -1,4 +1,4 @@
-
-
{{publication.Message}}
+
{{publication.Message}}
diff --git a/src/app/store/deplomas.service.ts b/src/app/store/deplomas.service.ts
index b14581d85..b9dca137d 100644
--- a/src/app/store/deplomas.service.ts
+++ b/src/app/store/deplomas.service.ts
@@ -105,9 +105,6 @@ export class DeplomasService {
this._diplomasAssinadoListCount = value.length
this._diplomasAssinadoList = value
this.saveDiplomasAssinadoList()
- if(window['all-process']) {
- window['all-process']()
- }
if(window['all-process-gabinete']) {
window['all-process-gabinete']()
}
@@ -119,9 +116,6 @@ export class DeplomasService {
this._diplomasParaAssinar = value
this.saveDiplomasParaAssinar()
- if(window['all-process']) {
- window['all-process']()
- }
if(window['all-process-gabinete']) {
window['all-process-gabinete']()
}
@@ -132,9 +126,6 @@ export class DeplomasService {
this._diplomasReviewCount = value.length
this.saveDiplomasReviewList()
- if(window['all-process']) {
- window['all-process']()
- }
if(window['all-process-gabinete']) {
window['all-process-gabinete']()
}
@@ -146,9 +137,6 @@ export class DeplomasService {
this._diplomasGerarList = value
this.savetDiplomaGerar()
- if(window['all-process']) {
- window['all-process']()
- }
if(window['all-process-gabinete']) {
window['all-process-gabinete']()
}
diff --git a/src/app/store/despacho-store.service.ts b/src/app/store/despacho-store.service.ts
index 36038eb1e..b892808cd 100644
--- a/src/app/store/despacho-store.service.ts
+++ b/src/app/store/despacho-store.service.ts
@@ -110,9 +110,6 @@ export class DespachoStoreService {
this._list = eventsList
this.save({dynamicCount:true})
- if(window['all-process']) {
- window['all-process']()
- }
if(window['all-process-gabinete']) {
window['all-process-gabinete']()
}
diff --git a/src/app/store/despachospr-store.service.ts b/src/app/store/despachospr-store.service.ts
index dd76d51d0..46e5d9265 100644
--- a/src/app/store/despachospr-store.service.ts
+++ b/src/app/store/despachospr-store.service.ts
@@ -39,9 +39,6 @@ reset(eventsList: any) {
this.count = this._list.length
this.save()
- if(window['all-process']) {
- window['all-process']()
- }
if(window['all-process-gabinete']) {
window['all-process-gabinete']()
}
diff --git a/src/app/store/eventoaprovacao-store.service.ts b/src/app/store/eventoaprovacao-store.service.ts
index b9550096e..c31192920 100644
--- a/src/app/store/eventoaprovacao-store.service.ts
+++ b/src/app/store/eventoaprovacao-store.service.ts
@@ -61,10 +61,6 @@ export class EventoaprovacaoStoreService {
})
}, 10)
-
- if(window['all-process']) {
- window['all-process']()
- }
if(window['all-process-gabinete']) {
window['all-process-gabinete']()
}
diff --git a/src/app/store/expedientegd-store.service.ts b/src/app/store/expedientegd-store.service.ts
index 66b580228..a24939d90 100644
--- a/src/app/store/expedientegd-store.service.ts
+++ b/src/app/store/expedientegd-store.service.ts
@@ -37,9 +37,6 @@ export class ExpedientegdStoreService {
this._list = eventsList
this.save()
- if(window['all-process']) {
- window['all-process']()
- }
if(window['all-process-gabinete']) {
window['all-process-gabinete']()
}
diff --git a/src/app/store/pedidos-store.service.ts b/src/app/store/pedidos-store.service.ts
index 13f5abcad..6ee6bd1c4 100644
--- a/src/app/store/pedidos-store.service.ts
+++ b/src/app/store/pedidos-store.service.ts
@@ -62,9 +62,6 @@ export class PedidosStoreService {
this.countparecer = this._listParecer.length
this.saveDeferimento()
- if(window['all-process']) {
- window['all-process']()
- }
if(window['all-process-gabinete']) {
window['all-process-gabinete']()
}
@@ -75,9 +72,6 @@ export class PedidosStoreService {
this.countdeferimento =this._listDeferimento.length
this.saveParecer()
- if(window['all-process']) {
- window['all-process']()
- }
if(window['all-process-gabinete']) {
window['all-process-gabinete']()
}
diff --git a/src/app/store/pendestes-store.service.ts b/src/app/store/pendestes-store.service.ts
index 7863633f6..cc37ec710 100644
--- a/src/app/store/pendestes-store.service.ts
+++ b/src/app/store/pendestes-store.service.ts
@@ -42,9 +42,6 @@ export class PendestesStoreService {
this.count = this._list.length
this.save()
- if(window['all-process']) {
- window['all-process']()
- }
if(window['all-process-gabinete']) {
window['all-process-gabinete']()
}
diff --git a/src/app/store/presidential-actions-store.service.ts b/src/app/store/presidential-actions-store.service.ts
index 6132fe909..611a53149 100644
--- a/src/app/store/presidential-actions-store.service.ts
+++ b/src/app/store/presidential-actions-store.service.ts
@@ -32,9 +32,6 @@ export class PresidentialActionsStoreService {
this._list = list
this.save(this._list)
- if(window['all-process']) {
- window['all-process']()
- }
if(window['all-process-gabinete']) {
window['all-process-gabinete']()
}
diff --git a/src/app/store/to-day-event-storage.service.ts b/src/app/store/to-day-event-storage.service.ts
index 8c21af6d6..8e5d46c86 100644
--- a/src/app/store/to-day-event-storage.service.ts
+++ b/src/app/store/to-day-event-storage.service.ts
@@ -38,9 +38,6 @@ export class ToDayEventStorageService {
reset(eventsList: EventList[]) {
this._eventsList = eventsList
this.save()
- if(window['all-process']) {
- window['all-process']()
- }
if(window['all-process-gabinete']) {
window['all-process-gabinete']()
}
diff --git a/src/plugin/src/connection/dbSwtich.d.ts b/src/plugin/src/connection/dbSwtich.d.ts
deleted file mode 100644
index a459450c4..000000000
--- a/src/plugin/src/connection/dbSwtich.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { DatabaseSchema, TableSchema } from '../models/register-modal.interface.js';
-import { actionParam, dbType } from './intreface.js';
-export declare class DBSwitch {
- static requestHandler(TableSchema: TableSchema, DBconfig: DatabaseSchema, dbType: dbType, action: actionParam, arg: any, queryId: any): Promise;
-}
diff --git a/src/plugin/src/connection/dbSwtich.js b/src/plugin/src/connection/dbSwtich.js
deleted file mode 100644
index f8ec1ce40..000000000
--- a/src/plugin/src/connection/dbSwtich.js
+++ /dev/null
@@ -1,29 +0,0 @@
-import { indexedDB } from './indexedDb/indexedb.js';
-import { IndexedDBWorkerQueue } from './worker.queue.js';
-export class DBSwitch {
- static async requestHandler(TableSchema, DBconfig, dbType, action, arg, queryId) {
- if (typeof (Worker) !== "undefined" && IndexedDBWorkerQueue.webWorkerModuleSupport) {
- //great, your browser supports web workers
- return new Promise(async (resolve, reject) => {
- const request = IndexedDBWorkerQueue.register({
- params: { TableSchema, DBconfig, queryId, action, arg, dbType },
- method: 'execute',
- func: (message) => {
- if (message.queryId == queryId) {
- resolve(message === null || message === void 0 ? void 0 : message.value);
- return true;
- }
- },
- });
- if (request == false) {
- const result = await indexedDB.requestHandler(TableSchema, DBconfig, queryId)[action](arg);
- resolve(result === null || result === void 0 ? void 0 : result.value);
- }
- });
- }
- else {
- const result = await indexedDB.requestHandler(TableSchema, DBconfig, queryId)[action](arg);
- return result === null || result === void 0 ? void 0 : result.value;
- }
- }
-}
diff --git a/src/plugin/src/connection/indexedDb/connector.d.ts b/src/plugin/src/connection/indexedDb/connector.d.ts
deleted file mode 100644
index 1fb933e57..000000000
--- a/src/plugin/src/connection/indexedDb/connector.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { DatabaseSchema } from '../../models/register-modal.interface.js';
-export declare class IndexedDBConnection {
- constructor();
- static connect(config: DatabaseSchema): Promise;
- static migrate(config: DatabaseSchema): Promise;
- private runMigrations;
-}
diff --git a/src/plugin/src/connection/indexedDb/connector.js b/src/plugin/src/connection/indexedDb/connector.js
deleted file mode 100644
index abc57da00..000000000
--- a/src/plugin/src/connection/indexedDb/connector.js
+++ /dev/null
@@ -1,62 +0,0 @@
-// inspire by https://github.com/hc-oss/use-indexeddb
-export class IndexedDBConnection {
- constructor() { }
- connect(config) {
- return new Promise((resolve, reject) => {
- const idbInstance = indexedDB || self.indexedDB || self.mozIndexedDB || self.webkitIndexedDB || self.msIndexedDB;
- if (idbInstance) {
- const request = idbInstance.open(config.databaseName, config.version);
- request.onsuccess = () => {
- resolve(request.result);
- };
- request.onerror = (e) => {
- reject(e.target.error.name);
- };
- request.onupgradeneeded = async (e) => {
- console.log('need to migrate first');
- await this.migrate(config);
- return await this.connect(config);
- };
- // request.onblocked = async (e: any) => {
- // reject(e.target.error.name);
- // }
- }
- else {
- reject("IDBDatabase not supported inside webworker");
- }
- });
- }
- migrate(config) {
- return new Promise((resolve, reject) => {
- const idbInstance = indexedDB || self.indexedDB || self.mozIndexedDB || self.webkitIndexedDB || self.msIndexedDB;
- if (idbInstance) {
- const request = idbInstance.open(config.databaseName, config.version);
- request.onsuccess = () => {
- resolve(false);
- };
- request.onerror = (e) => {
- reject(e.target.error.name);
- };
- request.onupgradeneeded = async (e) => {
- const db = e.target.result;
- await this.runMigrations(db, config);
- db.close();
- resolve(true);
- };
- }
- else {
- reject("Failed to connect");
- }
- });
- }
- async runMigrations(db, config) {
- await config.stores.forEach(async (storeSchema) => {
- if (!db.objectStoreNames.contains(storeSchema.name)) {
- const ObjectStore = db.createObjectStore(storeSchema.name, storeSchema.id);
- storeSchema.fields.forEach(c => {
- ObjectStore.createIndex(c.name, c.keyPath, c.options);
- });
- }
- });
- }
-}
diff --git a/src/plugin/src/connection/indexedDb/dynamicChange.d.ts b/src/plugin/src/connection/indexedDb/dynamicChange.d.ts
deleted file mode 100644
index 323a0034d..000000000
--- a/src/plugin/src/connection/indexedDb/dynamicChange.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export declare class IndexedDBConnectionDynamicChange {
- changeSchema(db: any, schemaChanges: any): void;
-}
diff --git a/src/plugin/src/connection/indexedDb/dynamicChange.js b/src/plugin/src/connection/indexedDb/dynamicChange.js
deleted file mode 100644
index 461d6a3fc..000000000
--- a/src/plugin/src/connection/indexedDb/dynamicChange.js
+++ /dev/null
@@ -1,31 +0,0 @@
-import { IndexedDBConnection } from './connector';
-export class IndexedDBConnectionDynamicChange {
- changeSchema(db, schemaChanges) {
- db.close();
- const newDb = new IndexedDBConnection().connect({
- databaseName: 'databaseName',
- type: 'indexedDB',
- version: 0
- });
- // newDb.on('blocked', () => false); // Silence console warning of blocked event.
- // Workaround: If DB is empty from tables, it needs to be recreated
- // if (db.tables.length === 0) {
- // await db.delete();
- // newDb.version(1).stores(schemaChanges);
- // return await newDb.open();
- //}
- // Extract current schema in dexie format:
- const currentSchema = db.tables.reduce((result, { name, schema }) => {
- result[name] = [schema.primKey.src, ...schema.indexes.map((idx) => idx.src)].join(',');
- return result;
- }, {});
- // console.log('Version: ' + db.verno);
- // console.log('Current Schema: ', currentSchema);
- // Tell Dexie about current schema:
- // newDb.version(db.verno).stores(currentSchema);
- // Tell Dexie about next schema:
- // newDb.version(db.verno + 1).stores(schemaChanges);
- // Upgrade it:
- // return await newDb.open();
- }
-}
diff --git a/src/plugin/src/connection/indexedDb/indexedb.d.ts b/src/plugin/src/connection/indexedDb/indexedb.d.ts
deleted file mode 100644
index f8e32357a..000000000
--- a/src/plugin/src/connection/indexedDb/indexedb.d.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { DatabaseSchema, TableSchema } from "../../models/register-modal.interface.js";
-import { Method } from "../../models/model.interface.js";
-declare class _indexedDB {
- private validateStore;
- private validateBeforeTransaction;
- private createTransaction;
- migrate(config: DatabaseSchema): Promise;
- getConnection(config: DatabaseSchema): Promise;
- getActions: (currentStore: any, config: any) => {
- getByID: (id: string | number) => Promise;
- getOneByIndex: (keyPath: string, value: string | number) => Promise;
- getManyByIndex: (keyPath: string, value: string | number) => Promise;
- getAll: () => Promise;
- add: (value: Object, key?: any) => Promise;
- update: (value: any, key?: any) => Promise;
- deleteByID: (id: any) => Promise;
- deleteAll: () => Promise;
- openCursor: (cursorCallback: any, keyRange?: IDBKeyRange) => Promise;
- };
- requestHandler: (TableSchema: TableSchema, config: DatabaseSchema, queryId: any) => {
- select: (methods: Method[]) => Promise;
- update: (methods: Method[]) => Promise<{
- queryId: any;
- }>;
- delete: (methods: Method[]) => Promise<{
- queryId: any;
- value?: undefined;
- } | {
- queryId: any;
- value: any;
- }>;
- insert: (methods: Method[]) => Promise<{
- queryId: any;
- value: any;
- }>;
- };
-}
-export declare const indexedDB: _indexedDB;
-export {};
diff --git a/src/plugin/src/connection/indexedDb/indexedb.js b/src/plugin/src/connection/indexedDb/indexedb.js
deleted file mode 100644
index 010e45a94..000000000
--- a/src/plugin/src/connection/indexedDb/indexedb.js
+++ /dev/null
@@ -1,362 +0,0 @@
-import { IndexedDBConnection } from "./connector.js";
-import { SqlObject } from "../../sql/sqlObject/sqlObject.js";
-// inspire by https://github.com/hc-oss/use-indexeddb
-class _indexedDB {
- constructor() {
- this.getActions = (currentStore, config) => {
- return {
- getByID: (id) => {
- return new Promise((resolve, reject) => {
- this.getConnection(config)
- .then(db => {
- this.validateBeforeTransaction(db, currentStore, reject);
- let tx = this.createTransaction(db, "readonly", currentStore, resolve, reject);
- let objectStore = tx.objectStore(currentStore);
- let request = objectStore.get(id);
- request.onsuccess = (e) => {
- resolve(e.target.result);
- };
- })
- .catch(reject);
- });
- },
- getOneByIndex: (keyPath, value) => {
- return new Promise((resolve, reject) => {
- this.getConnection(config)
- .then(db => {
- this.validateBeforeTransaction(db, currentStore, reject);
- let tx = this.createTransaction(db, "readonly", currentStore, resolve, reject);
- let objectStore = tx.objectStore(currentStore);
- let index = objectStore.index(keyPath);
- let request = index.get(value);
- request.onsuccess = (e) => {
- resolve(e.target.result);
- };
- })
- .catch(reject);
- });
- },
- getManyByIndex: (keyPath, value) => {
- return new Promise((resolve, reject) => {
- this.getConnection(config)
- .then(db => {
- this.validateBeforeTransaction(db, currentStore, reject);
- let tx = this.createTransaction(db, "readonly", currentStore, resolve, reject);
- let objectStore = tx.objectStore(currentStore);
- let index = objectStore.index(keyPath);
- let request = index.getAll(value);
- request.onsuccess = (e) => {
- resolve(e.target.result);
- };
- })
- .catch(reject);
- });
- },
- getAll: () => {
- return new Promise((resolve, reject) => {
- this.getConnection(config).then(db => {
- this.validateBeforeTransaction(db, currentStore, reject);
- let tx = this.createTransaction(db, "readonly", currentStore, resolve, reject);
- let objectStore = tx.objectStore(currentStore);
- let request = objectStore.getAll();
- request.onsuccess = (e) => {
- resolve(e.target.result);
- };
- })
- .catch(reject);
- });
- },
- add: (value, key) => {
- return new Promise((resolve, reject) => {
- this.getConnection(config).then(db => {
- this.validateBeforeTransaction(db, currentStore, reject);
- let tx = this.createTransaction(db, "readwrite", currentStore, resolve, reject);
- let objectStore = tx.objectStore(currentStore);
- let request = objectStore.add(value, key);
- request.onsuccess = (e) => {
- var _a, _b;
- (_b = (_a = tx) === null || _a === void 0 ? void 0 : _a.commit) === null || _b === void 0 ? void 0 : _b.call(_a);
- resolve(e.target.result);
- db.transaction;
- };
- request.onerror = (e) => {
- let data = {
- error: e.target['error']
- };
- resolve(data);
- };
- })
- .catch(reject);
- });
- },
- update: (value, key) => {
- return new Promise((resolve, reject) => {
- this.getConnection(config).then(db => {
- this.validateBeforeTransaction(db, currentStore, reject);
- let tx = this.createTransaction(db, "readwrite", currentStore, resolve, reject);
- let objectStore = tx.objectStore(currentStore);
- let request = objectStore.put(value, key);
- request.onsuccess = (e) => {
- var _a, _b;
- (_b = (_a = tx) === null || _a === void 0 ? void 0 : _a.commit) === null || _b === void 0 ? void 0 : _b.call(_a);
- resolve(e.target.result);
- };
- })
- .catch(reject);
- });
- },
- deleteByID: (id) => {
- return new Promise((resolve, reject) => {
- this.getConnection(config).then(db => {
- this.validateBeforeTransaction(db, currentStore, reject);
- let tx = this.createTransaction(db, "readwrite", currentStore, resolve, reject);
- let objectStore = tx.objectStore(currentStore);
- let request = objectStore.delete(id);
- request.onsuccess = (e) => {
- var _a, _b;
- (_b = (_a = tx) === null || _a === void 0 ? void 0 : _a.commit) === null || _b === void 0 ? void 0 : _b.call(_a);
- resolve(e);
- };
- })
- .catch(reject);
- });
- },
- deleteAll: () => {
- return new Promise((resolve, reject) => {
- this.getConnection(config)
- .then(db => {
- this.validateBeforeTransaction(db, currentStore, reject);
- let tx = this.createTransaction(db, "readwrite", currentStore, resolve, reject);
- let objectStore = tx.objectStore(currentStore);
- objectStore.clear();
- tx.oncomplete = (e) => {
- var _a, _b;
- try {
- (_b = (_a = tx) === null || _a === void 0 ? void 0 : _a.commit) === null || _b === void 0 ? void 0 : _b.call(_a);
- resolve(e);
- }
- catch (error) {
- resolve(e);
- }
- };
- })
- .catch(reject);
- });
- },
- openCursor: (cursorCallback, keyRange) => {
- return new Promise((resolve, reject) => {
- this.getConnection(config)
- .then(db => {
- this.validateBeforeTransaction(db, currentStore, reject);
- let tx = this.createTransaction(db, "readonly", currentStore, resolve, reject);
- let objectStore = tx.objectStore(currentStore);
- let request = objectStore.openCursor(keyRange);
- request.onsuccess = e => {
- cursorCallback(e);
- resolve();
- // db.close();
- };
- })
- .catch(reject);
- });
- },
- };
- };
- this.requestHandler = (TableSchema, config, queryId) => {
- return {
- select: async (methods) => {
- if (methods[0].methodName == 'all') {
- return {
- queryId: queryId,
- value: await this.getActions(TableSchema.name, config).getAll()
- };
- }
- else if (methods[0].methodName == 'get') {
- const args = methods[0].arguments;
- if (Object.keys(args).length == 1) {
- const key = Object.keys(args)[0];
- const value = args[key];
- if (TableSchema.id.keyPath == key) {
- return {
- queryId: queryId,
- value: await this.getActions(TableSchema.name, config).getByID(value)
- };
- }
- else {
- return {
- queryId: queryId,
- value: await this.getActions(TableSchema.name, config).getOneByIndex(key, value)
- };
- }
- }
- }
- else if (methods[methods.length - 1].methodName == 'execute') {
- return new Promise(async (resolve, reject) => {
- const sqlObject = new SqlObject(TableSchema, methods);
- await this.getActions(TableSchema.name, config).openCursor(async (event) => {
- var cursor = event.target.result;
- if (cursor) {
- const row = cursor.value;
- await sqlObject.runFirstMethod(row);
- cursor.continue();
- }
- else {
- sqlObject.doneRunFirstMethod();
- sqlObject.run();
- resolve({
- queryId: queryId,
- value: sqlObject.firstMethod.rows
- });
- }
- });
- });
- }
- else if (methods[methods.length - 1].methodName == 'first') {
- return new Promise(async (resolve, reject) => {
- const sqlObject = new SqlObject(TableSchema, methods);
- await this.getActions(TableSchema.name, config).openCursor(async (event) => {
- var cursor = event.target.result;
- if (cursor) {
- const row = cursor.value;
- await sqlObject.runFirstMethod(row, resolve, 1);
- cursor.continue();
- }
- else {
- sqlObject.doneRunFirstMethod();
- sqlObject.run();
- resolve({
- queryId: queryId,
- value: sqlObject.firstMethod.rows
- });
- }
- });
- });
- }
- },
- update: async (methods) => {
- if (methods[0].methodName == 'save') {
- const args = methods[0].arguments;
- const idFieldName = TableSchema.id.keyPath;
- const idValue = args[idFieldName];
- if (idValue) {
- await this.getActions(TableSchema.name, config).update(args);
- }
- else {
- await this.getActions(TableSchema.name, config).update(args, idValue);
- }
- return {
- queryId
- };
- }
- else if (methods[0].methodName != 'update' && methods[methods.length - 1].methodName == 'update') {
- const argsToUpdate = methods[methods.length - 1].arguments;
- const customMethods = Object.create(methods);
- customMethods[methods.length - 1].methodName = 'execute';
- const result = await this.requestHandler(TableSchema, config, queryId).select(customMethods);
- const rows = result.value;
- for (let row of rows) {
- const updateRow = Object.assign(row, argsToUpdate);
- await this.getActions(TableSchema.name, config).update(updateRow);
- }
- return {
- queryId
- };
- }
- else if (methods[0].methodName == 'update') {
- const argsToUpdate = methods[0].arguments;
- const idFieldName = TableSchema.id.keyPath;
- //await this.getActions(TableSchema.name, config).update(argsToUpdate)
- const idValue = argsToUpdate[idFieldName];
- if (idValue) {
- await this.getActions(TableSchema.name, config).update(argsToUpdate);
- }
- else {
- await this.getActions(TableSchema.name, config).update(argsToUpdate, idValue);
- }
- return {
- queryId
- };
- }
- },
- delete: async (methods) => {
- if (methods[methods.length - 1].methodName == 'delete' &&
- methods[methods.length - 1].arguments == null) {
- const customMethods = Object.create(methods);
- customMethods[methods.length - 1].methodName = 'execute';
- const result = await this.requestHandler(TableSchema, config, queryId).select(customMethods);
- const rows = result.value;
- for (let row of rows) {
- const id = row[TableSchema.id.keyPath];
- await this.getActions(TableSchema.name, config).deleteByID(id);
- }
- return {
- queryId
- };
- }
- else if (methods[methods.length - 1].methodName == 'delete' &&
- typeof methods[methods.length - 1].arguments == 'object') {
- const IdInObject = methods[methods.length - 1].arguments;
- const idValue = IdInObject[TableSchema.id.keyPath];
- return {
- queryId: queryId,
- value: await this.getActions(TableSchema.name, config).deleteByID(idValue)
- };
- }
- else if (methods[methods.length - 1].methodName == 'delete' &&
- methods[methods.length - 1].arguments == '*') {
- return {
- queryId: queryId,
- value: await this.getActions(TableSchema.name, config).deleteAll()
- };
- }
- },
- insert: async (methods) => {
- const createdObjKeys = [];
- const rows = methods[0].arguments;
- for (let insert of rows) {
- const id = await this.getActions(TableSchema.name, config).add(insert);
- insert[TableSchema.id.keyPath] = id;
- }
- // return first element
- if (rows.length == 1) {
- return {
- queryId: queryId,
- value: rows[0]
- };
- }
- else {
- return {
- queryId: queryId,
- value: rows
- };
- }
- }
- };
- };
- }
- validateStore(db, storeName) {
- return db.objectStoreNames.contains(storeName);
- }
- validateBeforeTransaction(db, storeName, reject) {
- if (!db) {
- reject("Queried before opening connection");
- }
- if (!this.validateStore(db, storeName)) {
- reject(`Store ${storeName} not found`);
- }
- }
- createTransaction(db, dbMode, currentStore, resolve, reject, abort) {
- let tx = db.transaction(currentStore, dbMode);
- tx.onerror = reject;
- tx.oncomplete = resolve;
- tx.onabort = abort;
- return tx;
- }
- migrate(config) {
- return new IndexedDBConnection().migrate(config);
- }
- getConnection(config) {
- return new IndexedDBConnection().connect(config);
- }
-}
-export const indexedDB = new _indexedDB();
diff --git a/src/plugin/src/connection/intreface.d.ts b/src/plugin/src/connection/intreface.d.ts
deleted file mode 100644
index 5d31fbfcc..000000000
--- a/src/plugin/src/connection/intreface.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export declare type actionParam = 'insert' | 'update' | 'delete' | 'select';
-export declare type dbType = 'indexedDB' | 'localStorage';
diff --git a/src/plugin/src/connection/intreface.js b/src/plugin/src/connection/intreface.js
deleted file mode 100644
index cb0ff5c3b..000000000
--- a/src/plugin/src/connection/intreface.js
+++ /dev/null
@@ -1 +0,0 @@
-export {};
diff --git a/src/plugin/src/connection/worker.d.ts b/src/plugin/src/connection/worker.d.ts
deleted file mode 100644
index cb0ff5c3b..000000000
--- a/src/plugin/src/connection/worker.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export {};
diff --git a/src/plugin/src/connection/worker.js b/src/plugin/src/connection/worker.js
deleted file mode 100644
index 174c12cc3..000000000
--- a/src/plugin/src/connection/worker.js
+++ /dev/null
@@ -1,26 +0,0 @@
-import { indexedDB } from './indexedDb/indexedb.js';
-onmessage = async (oEvent) => {
- const { TableSchema, DBconfig, queryId, action, arg } = oEvent.data;
- indexedDB.requestHandler(TableSchema, DBconfig, queryId)[action](arg).then((result) => {
- try {
- postMessage(result);
- }
- catch (error) {
- postMessage({
- queryId: result.queryId,
- value: undefined
- });
- }
- }).catch((result)=> {
- try {
- postMessage(result);
- }
- catch (error) {
- postMessage({
- queryId: result.queryId,
- value: undefined
- });
- }
- })
-
-};
diff --git a/src/plugin/src/connection/worker.queue.d.ts b/src/plugin/src/connection/worker.queue.d.ts
deleted file mode 100644
index 4e4898c29..000000000
--- a/src/plugin/src/connection/worker.queue.d.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-interface WsRegister {
- type?: 'response' | 'Register';
- func: Function;
- queryId?: string;
- params: any;
- method: 'execute' | 'migrate';
-}
-export declare class _IndexedDBWorkerQueue {
- private myWorker;
- webWorkerModuleSupport: boolean;
- constructor();
- supportsWorkerType(): boolean;
- private workerQueues;
- register(data: WsRegister): string | false;
- onmessage(data: any): Promise;
- requestHandler(): void;
-}
-export declare const IndexedDBWorkerQueue: _IndexedDBWorkerQueue;
-export {};
diff --git a/src/plugin/src/connection/worker.queue.js b/src/plugin/src/connection/worker.queue.js
deleted file mode 100644
index e9a3f67c3..000000000
--- a/src/plugin/src/connection/worker.queue.js
+++ /dev/null
@@ -1,51 +0,0 @@
-export class _IndexedDBWorkerQueue {
- constructor() {
- this.webWorkerModuleSupport = false;
- this.workerQueues = {};
- this.webWorkerModuleSupport = this.supportsWorkerType();
- if (this.webWorkerModuleSupport) {
- this.myWorker = new Worker(new URL('./worker.js', import.meta.url), { type: "module" });
- this.myWorker.onmessage = (oEvent) => {
- const data = oEvent.data;
- this.onmessage(data);
- };
- this.myWorker.onerror = (error) => {
- console.log(error, 'erroror');
- };
- }
- }
- // https://stackoverflow.com/a/62963963/14115342
- supportsWorkerType() {
- let supports = false;
- const tester = {
- get type() { return supports = true; } // it's been called, it's supported
- };
- try {
- const worker = new Worker('blob://', tester);
- }
- finally {
- return supports;
- }
- }
- register(data) {
- try {
- this.myWorker.postMessage(data.params);
- this.workerQueues[data.queryId] = data;
- return data.queryId;
- }
- catch (error) {
- return false;
- }
- }
- async onmessage(data) {
- for (const [key, value] of Object.entries(this.workerQueues)) {
- const dontRepeat = await value.func(data);
- if (dontRepeat || !data.queryId) {
- delete this.workerQueues[key];
- }
- }
- }
- requestHandler() {
- }
-}
-export const IndexedDBWorkerQueue = new _IndexedDBWorkerQueue();
diff --git a/src/plugin/src/index.d.ts b/src/plugin/src/index.d.ts
deleted file mode 100644
index da23bc5ac..000000000
--- a/src/plugin/src/index.d.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { Model } from './models/model.js';
-import { LocalStorage } from './models/model.js';
-import { ModelReader } from './models/model.reader.js';
-import { registerModel, migrate } from './models/register-model.js';
-export declare const models: {
- Value(arg: any): {};
- CharField(data?: import("./models/field/interface.js").CharFieldParams): import("./models/field/allFields.js").CharField;
- BooleanField(data?: import("./models/field/interface.js").BooleanFieldParams): import("./models/field/allFields.js").BooleanField;
- TextField(data?: import("./models/field/interface.js").TextFieldParams): import("./models/field/allFields.js").TextField;
- IntegerField(data?: import("./models/field/interface.js").IntegerFieldParams): import("./models/field/allFields.js").IntegerField;
- DateField(data?: import("./models/field/interface.js").DateFieldParams): import("./models/field/allFields.js").DateField;
- DateTimeField(data?: import("./models/field/interface.js").DateTimeFieldParams): import("./models/field/allFields.js").DateTimeField;
- BigIntegerField(data?: import("./models/field/interface.js").BigIntegerFieldParams): import("./models/field/allFields.js").BigIntegerField;
- AutoField(data?: import("./models/field/interface.js").AutoFieldParams): import("./models/field/allFields.js").AutoField;
- OneToOneField(data: import("./models/field/interface.js").OneToOneFieldParams): import("./models/field/allFields.js").OneToOneField;
- ForeignKey(data: import("./models/field/interface.js").ForeignKeyParams): import("./models/field/allFields.js").ForeignKey;
- ManyToManyField(data?: import("./models/field/interface.js").ManyToManyFieldParams): import("./models/field/allFields.js").ManyToManyField;
- indexedDB: {
- fields: {
- JsonField: (data?: import("./models/field/interface.js").IndexedDBJsonFieldParams) => import("./models/field/allFields.js").indexedDBJsonField;
- ArrayField: (data?: import("./models/field/interface.js").IndexedDBArrayFieldParams) => import("./models/field/allFields.js").indexedDBArrayField;
- };
- };
- Model: typeof Model;
- LocalStorage: typeof LocalStorage;
- read: typeof ModelReader.read;
- migrate: typeof migrate;
- register: typeof registerModel.register;
-};
diff --git a/src/plugin/src/index.js b/src/plugin/src/index.js
deleted file mode 100644
index 0db38b57f..000000000
--- a/src/plugin/src/index.js
+++ /dev/null
@@ -1,11 +0,0 @@
-import { Model } from './models/model.js';
-import { LocalStorage } from './models/model.js';
-import * as Fields from './models/field/fields.js';
-import { ModelReader } from './models/model.reader.js';
-import { registerModel, migrate } from './models/register-model.js';
-export const models = Object.assign(Object.assign({ Model,
- LocalStorage, read: ModelReader.read, migrate: migrate, register: registerModel.register }, Fields), { Value(arg) {
- if (arg == 'null') {
- return {};
- }
- } });
diff --git a/src/plugin/src/models/field/allFields.d.ts b/src/plugin/src/models/field/allFields.d.ts
deleted file mode 100644
index 8ea37dd46..000000000
--- a/src/plugin/src/models/field/allFields.d.ts
+++ /dev/null
@@ -1,140 +0,0 @@
-import { FieldType } from '../../sql/query/interface.js';
-import { field } from './field.js';
-import { FieldKeys } from './fields.interface.js';
-import { AutoFieldParams, BooleanFieldParams, DateFieldParams, DateTimeFieldParams, ForeignKeyParams, IndexedDBArrayFieldParams, IndexedDBJsonFieldParams, IntegerFieldParams, ManyToManyFieldParams, OneToOneFieldParams } from './interface.js';
-import { BigIntegerFieldParams } from './interface.js';
-import { CharFieldParams } from './interface.js';
-import { TextFieldParams } from './interface.js';
-export declare class AutoField extends field {
- fieldName: FieldKeys;
- unique: boolean;
- autoIncrement: boolean;
- primaryKey?: boolean;
- type: FieldType;
- blank: boolean;
- default?: any;
- constructor(data?: AutoFieldParams);
- valid(value: any): boolean;
-}
-export declare class BigIntegerField extends field {
- fieldName: FieldKeys;
- unique?: boolean;
- primaryKey?: boolean;
- blank?: boolean;
- default?: any;
- type: FieldType;
- constructor(data?: BigIntegerFieldParams);
- valid(value: any): boolean;
-}
-export declare class BooleanField extends field {
- fieldName: FieldKeys;
- unique?: boolean;
- blank?: boolean;
- default?: any;
- constructor(data?: BooleanFieldParams);
- valid(value: any): boolean;
-}
-export declare class CharField extends field {
- fieldName: FieldKeys;
- maxLength?: number | undefined;
- minLength?: number | undefined;
- choices?: any[] | undefined;
- primaryKey?: boolean;
- blank?: boolean;
- default?: any;
- unique?: boolean;
- type: FieldType;
- constructor(data?: CharFieldParams);
- valid(value: any): boolean;
-}
-export declare class DateField extends field {
- fieldName: FieldKeys;
- type: FieldType;
- blank?: boolean;
- default?: any;
- constructor(data?: DateFieldParams);
- valid(value: any): boolean;
-}
-export declare class DateTimeField extends field {
- fieldName: FieldKeys;
- type: FieldType;
- blank?: boolean;
- default?: any;
- constructor(data?: DateTimeFieldParams);
- valid(value: any): boolean;
-}
-export declare class indexedDBArrayField extends field {
- fieldName: FieldKeys;
- type: FieldType;
- blank?: boolean;
- default?: any;
- maxLength?: number;
- minLength?: number;
- size?: number;
- private _field?;
- get field(): any;
- set field(value: any);
- constructor(data?: IndexedDBArrayFieldParams);
- valid(value: any): boolean;
-}
-export declare class indexedDBJsonField extends field {
- fieldName: FieldKeys;
- type: FieldType;
- blank?: boolean;
- default?: any;
- null?: boolean;
- constructor(data?: IndexedDBJsonFieldParams);
- valid(value: any): boolean;
-}
-export declare class TextField extends field {
- fieldName: FieldKeys;
- maxLength?: number | undefined;
- minLength?: number | undefined;
- primaryKey?: boolean;
- blank?: boolean;
- default?: any;
- type: FieldType.TEXT;
- constructor(data?: TextFieldParams);
- valid(value: any): boolean;
-}
-export declare class IntegerField extends field {
- fieldName: FieldKeys;
- unique?: boolean;
- primaryKey?: boolean;
- type: FieldType;
- blank?: boolean;
- default?: any;
- constructor(data?: IntegerFieldParams);
- valid(value: any): boolean;
-}
-export declare class ForeignKey extends field {
- fieldName: FieldKeys;
- model: any;
- foreignKey: boolean;
- blank?: boolean;
- default?: any;
- constructor(data?: ForeignKeyParams);
- valid(value: any): boolean;
-}
-export declare class OneToOneField extends field {
- fieldName: FieldKeys;
- foreignKey: boolean;
- model: any;
- blank?: boolean;
- default?: any;
- onDelete?: any;
- constructor(data?: OneToOneFieldParams);
- contractor(contractor: any): void;
- valid(value: any): boolean;
-}
-export declare class ManyToManyField extends field {
- fieldName: FieldKeys;
- model: any;
- foreignKey: boolean;
- blank?: boolean;
- default?: any;
- onDelete?: any;
- unique?: boolean;
- constructor(data?: ManyToManyFieldParams);
- valid(value: any): boolean;
-}
diff --git a/src/plugin/src/models/field/allFields.js b/src/plugin/src/models/field/allFields.js
deleted file mode 100644
index 9d5c450cc..000000000
--- a/src/plugin/src/models/field/allFields.js
+++ /dev/null
@@ -1,253 +0,0 @@
-import { FieldType } from '../../sql/query/interface.js';
-import { field } from './field.js';
-export class AutoField extends field {
- constructor(data) {
- super();
- this.fieldName = 'AutoField';
- this.unique = true;
- this.autoIncrement = true;
- this.type = FieldType.BIGINT;
- this.blank = true;
- Object.assign(this, data);
- }
- valid(value) {
- if (!(typeof value == 'bigint' || typeof value == 'number')) {
- return false;
- }
- else if (!((this === null || this === void 0 ? void 0 : this.blank) == undefined && this.isNull(value) == false)) {
- return false;
- }
- return false;
- }
-}
-export class BigIntegerField extends field {
- constructor(data) {
- super();
- this.fieldName = 'BigIntegerField';
- this.type = FieldType.BIGINT;
- Object.assign(this, data);
- }
- valid(value) {
- if (!(typeof value == 'bigint' || typeof value == 'number')) {
- if ((this === null || this === void 0 ? void 0 : this.blank) != true) {
- return false;
- }
- else if (!(value === null || value === undefined)) {
- return false;
- }
- }
- else if (!this.rules(this, value)) {
- return false;
- }
- return true;
- }
-}
-export class BooleanField extends field {
- constructor(data) {
- super();
- this.fieldName = 'BooleanField';
- Object.assign(this, data);
- }
- valid(value) {
- if (typeof value != 'boolean') {
- return false;
- }
- return true;
- }
-}
-export class CharField extends field {
- constructor(data) {
- super();
- this.fieldName = 'CharField';
- this.type = FieldType.DATE;
- Object.assign(this, data);
- }
- valid(value) {
- if (!(typeof value == 'string')) {
- if ((this === null || this === void 0 ? void 0 : this.blank) != true) {
- return false;
- }
- else if (!(value === null || value === undefined)) {
- return false;
- }
- }
- else if (!this.rules(this, value)) {
- return false;
- }
- return true;
- }
-}
-export class DateField extends field {
- constructor(data) {
- super();
- this.fieldName = 'DateField';
- this.type = FieldType.DATE;
- Object.assign(this, data);
- }
- valid(value) {
- if (!(typeof value == 'string')) {
- if ((this === null || this === void 0 ? void 0 : this.blank) != true) {
- return false;
- }
- }
- else if (!((this === null || this === void 0 ? void 0 : this.blank) == undefined && this.isNull(value) == false)) {
- return true;
- }
- return false;
- }
-}
-export class DateTimeField extends field {
- constructor(data) {
- super();
- this.fieldName = 'DateTimeField';
- this.type = FieldType.DATE;
- Object.assign(this, data);
- }
- valid(value) {
- if (!(typeof value == 'string')) {
- if ((this === null || this === void 0 ? void 0 : this.blank) != true) {
- return false;
- }
- }
- else if (!((this === null || this === void 0 ? void 0 : this.blank) == undefined && this.isNull(value) == false)) {
- return false;
- }
- return true;
- }
-}
-export class indexedDBArrayField extends field {
- constructor(data) {
- super();
- this.fieldName = 'indexedDBArrayField';
- this.type = FieldType.ARRAY;
- Object.assign(this, data);
- }
- get field() {
- return this._field;
- }
- set field(value) {
- this._field = value;
- }
- valid(value) {
- if (!(Array.isArray(value))) {
- if ((this === null || this === void 0 ? void 0 : this.blank) != true) {
- return false;
- }
- }
- else if (this.isNull(value) == true) {
- if ((this === null || this === void 0 ? void 0 : this.blank) != true) {
- return false;
- }
- }
- else if (this.size) {
- if (value.length != this.size) {
- return false;
- }
- }
- if (this.field) {
- for (const e of value) {
- if (!this.field.valid(e)) {
- return false;
- }
- }
- }
- return true;
- }
-}
-export class indexedDBJsonField extends field {
- constructor(data) {
- super();
- this.fieldName = 'indexedDBJsonField';
- this.type = FieldType.JSON;
- Object.assign(this, data);
- }
- valid(value) {
- if (!(typeof value == 'object' && Array.isArray(value) == false)) {
- if ((this === null || this === void 0 ? void 0 : this.blank) != true) {
- return false;
- }
- }
- else if (this.isNull(value) == true) {
- }
- return true;
- }
-}
-export class TextField extends field {
- constructor(data) {
- super();
- this.fieldName = 'TextField';
- Object.assign(this, data);
- }
- valid(value) {
- if (!(typeof value == 'string')) {
- if ((this === null || this === void 0 ? void 0 : this.blank) != true) {
- return false;
- }
- else if (!(value === null || value === undefined)) {
- return false;
- }
- }
- else if (!this.rules(this, value)) {
- return false;
- }
- return true;
- }
-}
-export class IntegerField extends field {
- constructor(data) {
- super();
- this.fieldName = 'IntegerField';
- this.type = FieldType.INT;
- Object.assign(this, data);
- }
- valid(value) {
- if (!(typeof value == 'number')) {
- if ((this === null || this === void 0 ? void 0 : this.blank) != true) {
- return false;
- }
- else if (!(value === null || value === undefined)) {
- return false;
- }
- }
- else if (!this.rules(this, value)) {
- return false;
- }
- return true;
- }
-}
-export class ForeignKey extends field {
- constructor(data) {
- super();
- this.fieldName = 'ForeignKey';
- this.foreignKey = true;
- Object.assign(this, data);
- }
- valid(value) {
- return !this.isNull(value);
- }
-}
-export class OneToOneField extends field {
- constructor(data) {
- super();
- this.fieldName = 'ManyToManyField';
- this.foreignKey = true;
- Object.assign(this, data);
- }
- contractor(contractor) {
- throw new Error('Method not implemented.');
- }
- valid(value) {
- return !this.isNull(value);
- }
-}
-export class ManyToManyField extends field {
- constructor(data) {
- super();
- this.fieldName = 'ManyToManyField';
- this.foreignKey = true;
- Object.assign(this, data);
- }
- valid(value) {
- return !this.isNull(value);
- }
-}
diff --git a/src/plugin/src/models/field/field.d.ts b/src/plugin/src/models/field/field.d.ts
deleted file mode 100644
index 900500008..000000000
--- a/src/plugin/src/models/field/field.d.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { FieldKeys } from "./fields.interface";
-export declare class field {
- fieldName: FieldKeys;
- primaryKey?: any;
- maxLength?: number | undefined;
- minLength?: number | undefined;
- choices?: any[] | undefined;
- type: number;
- blank?: boolean;
- default?: any;
- unique?: boolean;
- foreignKey?: boolean;
- model?: field;
- get field(): boolean;
- isNull(value: any): boolean;
- rules(field: field, value: any): boolean;
-}
diff --git a/src/plugin/src/models/field/field.js b/src/plugin/src/models/field/field.js
deleted file mode 100644
index 7d929b90e..000000000
--- a/src/plugin/src/models/field/field.js
+++ /dev/null
@@ -1,32 +0,0 @@
-export class field {
- get field() {
- return true;
- }
- isNull(value) {
- if (value == undefined) {
- return true;
- }
- else if (value == null) {
- return true;
- }
- else if (value == '' && !Array.isArray(value)) {
- return true;
- }
- return false;
- }
- rules(field, value) {
- if (field === null || field === void 0 ? void 0 : field.maxLength) {
- if (value.toString().length > field.maxLength) {
- return false;
- }
- }
- if (field === null || field === void 0 ? void 0 : field.minLength) {
- if (value.toString().length < field.minLength) {
- return false;
- }
- }
- if (field === null || field === void 0 ? void 0 : field.foreignKey) {
- }
- return true;
- }
-}
diff --git a/src/plugin/src/models/field/fields.d.ts b/src/plugin/src/models/field/fields.d.ts
deleted file mode 100644
index 93199a38d..000000000
--- a/src/plugin/src/models/field/fields.d.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { AutoFieldParams, BigIntegerFieldParams, BooleanFieldParams, CharFieldParams, DateFieldParams, DateTimeFieldParams, ForeignKeyParams, IndexedDBArrayFieldParams, IndexedDBJsonFieldParams, IntegerFieldParams, ManyToManyFieldParams, OneToOneFieldParams, TextFieldParams } from './interface.js';
-import * as Fields from './allFields.js';
-export declare function CharField(data?: CharFieldParams): Fields.CharField;
-export declare function BooleanField(data?: BooleanFieldParams): Fields.BooleanField;
-export declare function TextField(data?: TextFieldParams): Fields.TextField;
-export declare function IntegerField(data?: IntegerFieldParams): Fields.IntegerField;
-export declare function DateField(data?: DateFieldParams): Fields.DateField;
-export declare function DateTimeField(data?: DateTimeFieldParams): Fields.DateTimeField;
-export declare function BigIntegerField(data?: BigIntegerFieldParams): Fields.BigIntegerField;
-export declare function AutoField(data?: AutoFieldParams): Fields.AutoField;
-export declare const indexedDB: {
- fields: {
- JsonField: (data?: IndexedDBJsonFieldParams) => Fields.indexedDBJsonField;
- ArrayField: (data?: IndexedDBArrayFieldParams) => Fields.indexedDBArrayField;
- };
-};
-export declare function OneToOneField(data: OneToOneFieldParams): Fields.OneToOneField;
-export declare function ForeignKey(data: ForeignKeyParams): Fields.ForeignKey;
-export declare function ManyToManyField(data?: ManyToManyFieldParams): Fields.ManyToManyField;
diff --git a/src/plugin/src/models/field/fields.interface.d.ts b/src/plugin/src/models/field/fields.interface.d.ts
deleted file mode 100644
index 1a9e77d4b..000000000
--- a/src/plugin/src/models/field/fields.interface.d.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-export declare const FieldKeysArray: readonly ["CharField", "JsonField", "AutoField", "BigIntegerField", "DateField", "IntegerField", "TextField", "BooleanField", "OneToOneField", "ForeignKey", "ManyToManyField", "indexedDBJsonField", "indexedDBArrayField", "DateTimeField", "DateField"];
-export declare const AttributesArray: readonly ["maxLength", "minLength", "choices", "primaryKey", "unique", "autoIncrement", "type", "choices", "model", "blank", "default", "onDelete", "foreignKey"];
-export declare type FieldKeys = typeof FieldKeysArray[number];
-export declare type FieldsMap = {
- [P in K]?: T;
-};
-export declare type FieldAttributesKeys = typeof AttributesArray[number];
-export declare type AttributesMap = {
- [P in K]?: T;
-};
diff --git a/src/plugin/src/models/field/fields.interface.js b/src/plugin/src/models/field/fields.interface.js
deleted file mode 100644
index b9fa76219..000000000
--- a/src/plugin/src/models/field/fields.interface.js
+++ /dev/null
@@ -1,33 +0,0 @@
-export const FieldKeysArray = [
- 'CharField',
- 'JsonField',
- 'AutoField',
- 'BigIntegerField',
- 'DateField',
- 'IntegerField',
- 'TextField',
- 'BooleanField',
- 'OneToOneField',
- 'ForeignKey',
- 'ManyToManyField',
- 'indexedDBJsonField',
- 'indexedDBArrayField',
- 'DateTimeField',
- 'DateField'
-]; // TS3.4 syntax
-export const AttributesArray = [
- 'maxLength',
- 'minLength',
- 'choices',
- 'primaryKey',
- 'unique',
- 'autoIncrement',
- 'type',
- 'choices',
- 'model',
- 'blank',
- 'default',
- 'onDelete',
- 'foreignKey'
-]; // TS3.4 syntax
-// https://stackoverflow.com/a/64694571/14115342
diff --git a/src/plugin/src/models/field/fields.js b/src/plugin/src/models/field/fields.js
deleted file mode 100644
index 76b2c7c33..000000000
--- a/src/plugin/src/models/field/fields.js
+++ /dev/null
@@ -1,40 +0,0 @@
-import * as Fields from './allFields.js';
-export function CharField(data) {
- return new Fields.CharField(data);
-}
-export function BooleanField(data) {
- return new Fields.BooleanField(data);
-}
-export function TextField(data) {
- return new Fields.TextField(data);
-}
-export function IntegerField(data) {
- return new Fields.IntegerField(data);
-}
-export function DateField(data) {
- return new Fields.DateField(data);
-}
-export function DateTimeField(data) {
- return new Fields.DateTimeField(data);
-}
-export function BigIntegerField(data) {
- return new Fields.BigIntegerField(data);
-}
-export function AutoField(data) {
- return new Fields.AutoField(data);
-}
-export const indexedDB = {
- fields: {
- JsonField: (data) => new Fields.indexedDBJsonField(data),
- ArrayField: (data) => new Fields.indexedDBArrayField(data)
- }
-};
-export function OneToOneField(data) {
- return new Fields.OneToOneField(data);
-}
-export function ForeignKey(data) {
- return new Fields.ForeignKey(data);
-}
-export function ManyToManyField(data) {
- return new Fields.ManyToManyField(data);
-}
diff --git a/src/plugin/src/models/field/interface.d.ts b/src/plugin/src/models/field/interface.d.ts
deleted file mode 100644
index e2154a545..000000000
--- a/src/plugin/src/models/field/interface.d.ts
+++ /dev/null
@@ -1,97 +0,0 @@
-import { field } from './field.js';
-export interface CharFieldParams {
- maxLength?: number;
- minLength?: number;
- primaryKey?: boolean;
- choices?: any[] | undefined;
- unique?: boolean;
- blank?: boolean;
- default?: any;
-}
-export interface TextFieldParams {
- maxLength?: number;
- minLength?: number;
- primaryKey?: boolean;
- unique?: boolean;
- default?: any;
- blank?: boolean;
-}
-export interface IntegerFieldParams {
- primaryKey?: boolean;
- unique?: boolean;
- default?: any;
- blank?: boolean;
-}
-export interface BigIntegerFieldParams {
- primaryKey?: boolean;
- unique?: boolean;
- default?: any;
- blank?: boolean;
-}
-export interface AutoFieldParams {
- primaryKey?: boolean;
-}
-export interface IndexedDBJsonFieldParams {
- unique?: boolean;
- blank?: boolean;
- null?: boolean;
- default?: any;
-}
-export interface IndexedDBArrayFieldParams {
- unique?: boolean;
- blank?: boolean;
- type?: any;
- default?: any;
- maxLength?: number;
- minLength?: number;
- field?: field;
- size?: number;
-}
-export interface DateTimeFieldParams {
- unique?: boolean;
- blank?: boolean;
- default?: any;
-}
-export interface DateFieldParams {
- unique?: boolean;
- blank?: boolean;
- default?: any;
-}
-export interface BooleanFieldParams {
- unique?: boolean;
- blank?: boolean;
- default?: any;
-}
-export interface ForeignKeyParams {
- model: any;
- unique?: boolean;
- blank?: boolean;
- default?: any;
- onDelete?: any;
- primaryKey?: boolean;
-}
-export interface OneToOneFieldParams {
- model: any;
- unique?: boolean;
- blank?: boolean;
- default?: any;
- onDelete?: any;
-}
-export interface ManyToManyFieldParams {
- model: any;
- unique?: boolean;
- blank?: boolean;
- default?: any;
- onDelete?: any;
-}
-export interface PossibleFieldAttributes {
- model?: any;
- unique?: boolean;
- blank?: boolean;
- default?: any;
- onDelete?: any;
- primaryKey?: boolean;
- maxLength?: number;
- minLength?: number;
- choices?: any[] | undefined;
-}
diff --git a/src/plugin/src/models/field/interface.js b/src/plugin/src/models/field/interface.js
deleted file mode 100644
index cb0ff5c3b..000000000
--- a/src/plugin/src/models/field/interface.js
+++ /dev/null
@@ -1 +0,0 @@
-export {};
diff --git a/src/plugin/src/models/mode-migrations.d.ts b/src/plugin/src/models/mode-migrations.d.ts
deleted file mode 100644
index 4f7594221..000000000
--- a/src/plugin/src/models/mode-migrations.d.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export declare class _ModelMigrations {
- callback: any[];
- private isMigrationsReady;
- migrationsState(value: boolean): void;
- isReady(modelClassRepresentation: any): void;
- waitMigration(): Promise;
-}
-export declare const ModelMigrations: _ModelMigrations;
diff --git a/src/plugin/src/models/mode-migrations.js b/src/plugin/src/models/mode-migrations.js
deleted file mode 100644
index fd236f610..000000000
--- a/src/plugin/src/models/mode-migrations.js
+++ /dev/null
@@ -1,31 +0,0 @@
-export class _ModelMigrations {
- constructor() {
- this.callback = [];
- this.isMigrationsReady = false;
- }
- migrationsState(value) {
- this.isMigrationsReady = value;
- if (this.isMigrationsReady) {
- this.callback.forEach((item, index, object) => {
- item();
- object.splice(index, 1);
- });
- }
- }
- isReady(modelClassRepresentation) {
- // const classInstance: typeof models.Model = new modelClassRepresentation()
- }
- async waitMigration() {
- return new Promise((resolve, reject) => {
- if (!this.isMigrationsReady) {
- this.callback.push(() => {
- resolve('ready');
- });
- }
- else {
- resolve('ready');
- }
- });
- }
-}
-export const ModelMigrations = new _ModelMigrations();
diff --git a/src/plugin/src/models/model-from.d.ts b/src/plugin/src/models/model-from.d.ts
deleted file mode 100644
index e69de29bb..000000000
diff --git a/src/plugin/src/models/model-from.js b/src/plugin/src/models/model-from.js
deleted file mode 100644
index e69de29bb..000000000
diff --git a/src/plugin/src/models/model-manager.d.ts b/src/plugin/src/models/model-manager.d.ts
deleted file mode 100644
index c778c6040..000000000
--- a/src/plugin/src/models/model-manager.d.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { Methods, Method } from './model.interface.js';
-import { DatabaseSchema, TableSchema } from './register-modal.interface.js';
-export declare class ModelManager {
- constructor();
- static obj: (DatabaseSchema: DatabaseSchema, TableSchema: TableSchema) => {
- create: (arg: Method[], queryId: string) => Promise;
- get: (arg: Method[], queryId: string) => Promise;
- save: (arg: Method[], queryId: string) => Promise;
- execute: (arg: Methods | Method[], queryId: string) => Promise;
- update: (arg: any, queryId: string) => Promise;
- delete: (arg: any, queryId: string) => Promise;
- all: (arg: any, queryId: string) => Promise;
- };
-}
diff --git a/src/plugin/src/models/model-manager.js b/src/plugin/src/models/model-manager.js
deleted file mode 100644
index a1884ee7d..000000000
--- a/src/plugin/src/models/model-manager.js
+++ /dev/null
@@ -1,39 +0,0 @@
-var _a;
-import { DBSwitch } from '../connection/dbSwtich.js';
-import { ModelMigrations } from './mode-migrations.js';
-export class ModelManager {
- constructor() { }
-}
-_a = ModelManager;
-ModelManager.obj = (DatabaseSchema, TableSchema) => {
- return {
- create: async (arg, queryId) => {
- await ModelMigrations.waitMigration();
- return await DBSwitch.requestHandler(TableSchema, DatabaseSchema, DatabaseSchema.type, 'insert', arg, queryId);
- },
- get: async (arg, queryId) => {
- await ModelMigrations.waitMigration();
- return await DBSwitch.requestHandler(TableSchema, DatabaseSchema, DatabaseSchema.type, 'select', arg, queryId);
- },
- save: async (arg, queryId) => {
- await ModelMigrations.waitMigration();
- return await DBSwitch.requestHandler(TableSchema, DatabaseSchema, DatabaseSchema.type, 'update', arg, queryId);
- },
- execute: async (arg, queryId) => {
- await ModelMigrations.waitMigration();
- return await DBSwitch.requestHandler(TableSchema, DatabaseSchema, DatabaseSchema.type, 'select', arg, queryId);
- },
- update: async (arg, queryId) => {
- await ModelMigrations.waitMigration();
- return await DBSwitch.requestHandler(TableSchema, DatabaseSchema, DatabaseSchema.type, 'update', arg, queryId);
- },
- delete: async (arg, queryId) => {
- await ModelMigrations.waitMigration();
- return await DBSwitch.requestHandler(TableSchema, DatabaseSchema, DatabaseSchema.type, 'delete', arg, queryId);
- },
- all: async (arg, queryId) => {
- await ModelMigrations.waitMigration();
- return await DBSwitch.requestHandler(TableSchema, DatabaseSchema, DatabaseSchema.type, 'select', arg, queryId);
- },
- };
-};
diff --git a/src/plugin/src/models/model.d.ts b/src/plugin/src/models/model.d.ts
deleted file mode 100644
index 1574ec608..000000000
--- a/src/plugin/src/models/model.d.ts
+++ /dev/null
@@ -1,64 +0,0 @@
-import { getParams } from './model.interface.js';
-import { DatabaseSchema, DatabaseSchemaLocalStorage, TableSchema } from './register-modal.interface.js';
-import { ModelManager } from './model-manager.js';
-export declare class Model extends ModelManager {
- constructor(obg?: any);
- get(arg: any): Promise;
- getDBSchema(): DatabaseSchema;
- getModelName(): string;
- filter(...arg: any[]): any;
- getTableSchema(): TableSchema;
- getPrimaryKeyValue(): any;
- save(): Promise;
- delete(): Promise;
- static deleteAll(): Promise;
- all(): Promise;
- getFields(arg: any): {};
- formValidation(data: any): boolean;
- Value(args: any): string;
- static Value(args: any): string;
- static formValidation(data: any): boolean;
- static getModelsFields(arg: any): Promise;
- static all(): Promise;
- static get(arg: getParams): Promise;
- private static getId;
- static getModelName(): string;
- static filter(...arg: any[]): any;
- static NewModelInstance(): any;
- static getDBSchema(): DatabaseSchema;
- static getTableSchema(): TableSchema;
- private static getEmptyFields;
- private static getFields;
- static create(arg: any): Promise;
- private static newInstance;
- static createOrFind(getArg: any, defaultCreate: any): Promise;
- static updateOrCreate(argToFind: any, argsToUpdate: any): Promise;
- static update(arg: any): Promise;
- static object: ({ queryId, DBconfig, TableSchema, some }: {
- queryId?: string;
- DBconfig: any;
- TableSchema: any;
- some?: any;
- }) => {
- filter: (...args: any[]) => any;
- execute: () => Promise;
- update: (args: any) => Promise;
- delete: () => Promise;
- all: () => Promise;
- };
-}
-export declare class LocalStorage {
- constructor();
- static save(data?: Object): void;
- static get(): any;
- static getModelName(): string;
- static getDBSchema(): DatabaseSchemaLocalStorage;
- static getTableSchema(): TableSchema;
- private static getIgnoreAttributes;
- static ignoreAttributes(attributesStartWidth?: string[]): void;
- private static getFields;
- private static formValidation;
- static clear(): void;
- static clearComponent(): void;
- static clearStorage(): void;
-}
diff --git a/src/plugin/src/models/model.interface.d.ts b/src/plugin/src/models/model.interface.d.ts
deleted file mode 100644
index 50937339c..000000000
--- a/src/plugin/src/models/model.interface.d.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-export declare const MethodNameArray: readonly ["save", "filter", "get", "create", "execute", "update", "delete", "all", "first"];
-export declare type MethodName = typeof MethodNameArray[number];
-export interface Method {
- methodName: MethodName;
- arguments: any;
-}
-export declare type Methods = {
- [key: string]: Method[];
-};
-export declare type getParams = Object;
diff --git a/src/plugin/src/models/model.interface.js b/src/plugin/src/models/model.interface.js
deleted file mode 100644
index c1ceba925..000000000
--- a/src/plugin/src/models/model.interface.js
+++ /dev/null
@@ -1,11 +0,0 @@
-export const MethodNameArray = [
- 'save',
- 'filter',
- 'get',
- 'create',
- 'execute',
- 'update',
- 'delete',
- 'all',
- 'first',
-]; // TS3.4 syntax
diff --git a/src/plugin/src/models/model.js b/src/plugin/src/models/model.js
deleted file mode 100644
index 9ed0a8a30..000000000
--- a/src/plugin/src/models/model.js
+++ /dev/null
@@ -1,393 +0,0 @@
-var _a, _b;
-import { hashCode, uniqueGenerator } from '../utils.js';
-import { ModelManager } from './model-manager.js';
-import { models, modelsConfig, modelsConfigLocalStorage } from './register-model.js';
-import { FieldType } from '../sql/query/interface.js';
-import * as Fields from './field/allFields.js';
-let methods = {} = {};
-// inspire by https://github.com/brianschardt/browser-orm
-export class Model extends (_b = ModelManager) {
- constructor(obg) {
- super();
- Object.assign(this, obg);
- }
- get(arg) {
- return Model.get(arg);
- }
- getDBSchema() {
- const modelName = this.constructor.name;
- return modelsConfig[modelName].DatabaseSchema;
- }
- getModelName() {
- return this.constructor.name;
- }
- filter(...arg) {
- return Model.filter(arg);
- }
- getTableSchema() {
- const modelName = this.constructor.name;
- return modelsConfig[modelName].TableSchema;
- }
- getPrimaryKeyValue() {
- const TableSchema = this.getTableSchema();
- const idFieldName = TableSchema.id.keyPath;
- return this[idFieldName];
- }
- async save() {
- const DBconfig = this.getDBSchema();
- const tableSchema = this.getTableSchema();
- const fiendsName = tableSchema.fields.map((field) => field.name);
- fiendsName.push(tableSchema.id.keyPath);
- const Fields = {};
- for (let name of fiendsName) {
- Fields[name] = this[name];
- }
- const methods = [{ methodName: 'save', arguments: Fields }];
- const queryId = uniqueGenerator();
- await Model.obj(DBconfig, tableSchema).save(methods, queryId);
- }
- async delete() {
- const DBconfig = this.getDBSchema();
- const TableSchema = this.getTableSchema();
- const idFieldName = TableSchema.id.keyPath;
- const createArg = {};
- createArg[idFieldName] = this[idFieldName];
- const _methods = [{ methodName: 'delete', arguments: createArg }];
- const queryId = uniqueGenerator();
- await Model.obj(DBconfig, TableSchema).delete(_methods, queryId);
- }
- static async deleteAll() {
- const DBconfig = this.getDBSchema();
- const TableSchema = this.getTableSchema();
- const idFieldName = TableSchema.id.keyPath;
- const createArg = {};
- createArg[idFieldName] = this[idFieldName];
- const _methods = [{ methodName: 'delete', arguments: '*' }];
- const queryId = uniqueGenerator();
- await Model.obj(DBconfig, TableSchema).delete(_methods, queryId);
- }
- async all() {
- const DBconfig = this.getDBSchema();
- const TableSchema = this.getTableSchema();
- return await Model.object({ DBconfig, TableSchema }).all();
- }
- getFields(arg) {
- return Model.getFields(arg);
- }
- formValidation(data) {
- return Model.formValidation(data);
- }
- Value(args) {
- return Model.Value(args);
- }
- static Value(args) {
- return '';
- }
- static formValidation(data) {
- const TableSchema = this.getTableSchema();
- for (let field of TableSchema.fields) {
- const Field = new Fields[field.className](field.fieldAttributes);
- const FieldValue = data[field.name];
- if (!Field.valid(FieldValue)) {
- throw ('invalid insert into ' + TableSchema.name + ', invalid value for field ' + field.name + ' = ' + JSON.stringify(FieldValue));
- }
- }
- return true;
- }
- static async getModelsFields(arg) {
- var _c;
- const newArgs = {};
- const TableSchema = this.getTableSchema();
- if ((_c = TableSchema.id) === null || _c === void 0 ? void 0 : _c.autoIncrement) {
- TableSchema.fields.push({
- keyPath: TableSchema.id.keyPath,
- name: TableSchema.id.keyPath,
- options: {
- type: FieldType.INT,
- unique: true
- }
- });
- }
- for (const fieldName in TableSchema.fields) {
- newArgs[fieldName] = arg[fieldName];
- }
- }
- static async all() {
- const DBconfig = this.getDBSchema();
- const TableSchema = this.getTableSchema();
- return await Model.object({ DBconfig, TableSchema }).all();
- }
- static async get(arg) {
- const _methods = [{ methodName: 'get', arguments: arg }];
- const DBconfig = this.getDBSchema();
- const TableSchema = this.getTableSchema();
- const queryId = uniqueGenerator();
- const foundObj = await super.obj(DBconfig, TableSchema).get(_methods, queryId);
- if (!foundObj) {
- return false;
- }
- const ModelName = this.getModelName();
- let newInstance = new models[ModelName]();
- Object.assign(newInstance, Object.assign({}, foundObj));
- if (TableSchema.fieldTypes['ManyToManyField']) {
- for (const fieldName of TableSchema.fieldTypes['ManyToManyField']) {
- delete newInstance[fieldName];
- }
- }
- Object.defineProperty(newInstance, TableSchema.id.keyPath, {
- configurable: false,
- writable: false
- });
- delete newInstance.obj;
- return newInstance;
- }
- static getId() {
- return hashCode(this.toString());
- }
- static getModelName() {
- return this.toString().split('(' || /s+/)[0].split(' ' || /s+/)[1];
- }
- static filter(...arg) {
- const queryId = uniqueGenerator();
- const DBconfig = this.getDBSchema();
- const TableSchema = this.getTableSchema();
- const newInstanceModel = this.NewModelInstance();
- return Object.assign(newInstanceModel, this.object({ queryId, DBconfig, TableSchema, some: ['filter', arg] }));
- }
- static NewModelInstance() {
- class newInstanceModel {
- }
- Object.assign(newInstanceModel, this);
- return newInstanceModel;
- }
- static getDBSchema() {
- const modalName = this.getModelName();
- return modelsConfig[modalName].DatabaseSchema;
- }
- static getTableSchema() {
- const modalName = this.getModelName();
- return modelsConfig[modalName].TableSchema;
- }
- static async getEmptyFields() {
- const TableSchema = this.getTableSchema();
- const emptyFields = {};
- const fieldsName = TableSchema.fields.map((field) => field.name);
- for (let fieldName of fieldsName) {
- emptyFields[fieldName] = null;
- }
- return emptyFields;
- }
- static getFields(arg) {
- const TableSchema = this.getTableSchema();
- const filteredArgs = {};
- const fieldsName = TableSchema.fields.map((field) => field.name);
- for (let fieldName of fieldsName) {
- if (arg.hasOwnProperty(fieldName)) {
- filteredArgs[fieldName] = arg[fieldName];
- }
- }
- return filteredArgs;
- }
- static async create(arg) {
- if (arg.constructor.name != 'Array') {
- arg = [arg];
- }
- const emptyFields = await this.getEmptyFields();
- const TableSchema = this.getTableSchema();
- for (let i in arg) {
- arg[i] = Object.assign(Object.assign({}, emptyFields), this.getFields(arg[i]));
- if (!this.formValidation(arg[i])) {
- throw ('invalid ' + JSON.stringify(arg[i]));
- }
- }
- for (let i in arg) {
- if (TableSchema.attributes.foreignKey) {
- for (let field of TableSchema.attributes.foreignKey) {
- try {
- arg[i][field] = arg[i][field].getPrimaryKeyValue();
- }
- catch (error) { }
- }
- }
- }
- const _methods = [{ methodName: 'create', arguments: arg }];
- const DBconfig = this.getDBSchema();
- const queryId = uniqueGenerator();
- const createObject = await super.obj(DBconfig, TableSchema).create(_methods, queryId);
- if (createObject) {
- if (typeof createObject[TableSchema.id.keyPath] == 'object') {
- throw (createObject[TableSchema.id.keyPath].error);
- }
- else {
- const ModelName = this.getModelName();
- let newInstance = new models[ModelName]();
- Object.assign(newInstance, createObject);
- delete newInstance.obj;
- return newInstance;
- }
- }
- else {
- }
- }
- static newInstance({ TableSchema, DBconfig, ModelName, dataToMerge }) {
- let newInstance = new models[ModelName]();
- Object.assign(newInstance, Object.assign({}, dataToMerge));
- delete newInstance.obj;
- return newInstance;
- }
- static async createOrFind(getArg, defaultCreate) {
- const result = await this.filter(getArg).execute();
- const TableSchema = this.getTableSchema();
- const DBconfig = this.getDBSchema();
- const ModelName = this.getModelName();
- let instance;
- let created;
- if (result.length == 1) {
- created = false;
- instance = await this.newInstance({ TableSchema, DBconfig, ModelName, dataToMerge: result[0] });
- }
- else {
- created = true;
- instance = await this.create(Object.assign(getArg, defaultCreate));
- }
- return [instance, created];
- }
- static async updateOrCreate(argToFind, argsToUpdate) {
- let [instance, created] = await this.createOrFind(argToFind, argsToUpdate);
- if (!created) {
- const params = Object.assign(argToFind, argsToUpdate);
- instance = Object.assign(instance, params);
- await instance.save();
- }
- return instance;
- }
- static async update(arg) {
- arg = this.getFields(arg);
- const DBconfig = this.getDBSchema();
- const TableSchema = this.getTableSchema();
- const _methods = [{ methodName: 'update', arguments: arg }];
- const queryId = uniqueGenerator();
- return await super.obj(DBconfig, TableSchema).update(_methods, queryId);
- }
-}
-_a = Model;
-Model.object = ({ queryId = uniqueGenerator(), DBconfig, TableSchema, some = null }) => {
- if (!methods[queryId]) {
- methods[queryId] = [];
- }
- if (some) {
- const methodName = some[0];
- const methodArgs = some[1];
- _a.object({ queryId, DBconfig, TableSchema })[methodName](...methodArgs);
- }
- return {
- filter: (...args) => {
- methods[queryId].push({ methodName: 'filter', arguments: args });
- const newInstanceModel = _a.NewModelInstance();
- return Object.assign(newInstanceModel, _a.object({ DBconfig, TableSchema, queryId }));
- },
- execute: async () => {
- methods[queryId].push({ methodName: 'execute', arguments: null });
- const _methods = methods[queryId];
- methods[queryId] = [];
- return await Reflect.get(_b, "obj", _a).call(_a, DBconfig, TableSchema).execute(_methods, queryId);
- },
- update: async (args) => {
- methods[queryId].push({ methodName: 'update', arguments: args });
- const _methods = methods[queryId];
- methods[queryId] = [];
- return await Reflect.get(_b, "obj", _a).call(_a, DBconfig, TableSchema).update(_methods, queryId);
- },
- delete: async () => {
- methods[queryId].push({ methodName: 'delete', arguments: null });
- const _methods = methods[queryId];
- methods[queryId] = [];
- return await Reflect.get(_b, "obj", _a).call(_a, DBconfig, TableSchema).delete(_methods, queryId);
- },
- all: async () => {
- methods[queryId].push({ methodName: 'all', arguments: null });
- const _methods = methods[queryId];
- methods[queryId] = [];
- return await Reflect.get(_b, "obj", _a).call(_a, DBconfig, TableSchema).all(_methods, queryId);
- }
- };
-};
-export class LocalStorage {
- constructor() { }
- static save(data = {}) {
- const dataToSave = this.getFields(Object.assign(this, Object.assign({}, data)));
- const key = this.getTableSchema().id;
- localStorage.setItem(key.keyPath, JSON.stringify(dataToSave));
- }
- static get() {
- const key = this.getTableSchema().id;
- const restedData = JSON.parse(localStorage.getItem(key.keyPath));
- Object.assign(this, Object.assign({}, restedData));
- return restedData;
- }
- static getModelName() {
- return this.toString().split('(' || /s+/)[0].split(' ' || /s+/)[1];
- }
- static getDBSchema() {
- const modalName = this.getModelName();
- return modelsConfigLocalStorage[modalName].DatabaseSchema;
- }
- static getTableSchema() {
- const modalName = this.getModelName();
- return modelsConfigLocalStorage[modalName].TableSchema;
- }
- static getIgnoreAttributes() {
- return false;
- }
- static ignoreAttributes(attributesStartWidth = []) {
- if (!this.getIgnoreAttributes()) {
- this.getIgnoreAttributes = () => {
- return attributesStartWidth;
- };
- }
- }
- static getFields(arg) {
- const TableSchema = this.getTableSchema();
- const filteredArgs = {};
- const fieldsName = TableSchema.fields.map((field) => field.name);
- const Attributes = this.getIgnoreAttributes();
- const fieldNameFilter = fieldsName.filter((fieldName) => {
- if (Attributes) {
- for (let Attribute of Attributes) {
- if (fieldName.startsWith(Attribute)) {
- return false;
- }
- }
- }
- return true;
- });
- for (let fieldName of fieldNameFilter) {
- if (arg.hasOwnProperty(fieldName)) {
- filteredArgs[fieldName] = arg[fieldName];
- }
- }
- return filteredArgs;
- }
- static formValidation(data) {
- const TableSchema = this.getTableSchema();
- for (let field of TableSchema.fields) {
- const Field = new Fields[field.className](field.fieldAttributes);
- const FieldValue = data[field.name];
- if (!Field.valid(FieldValue)) {
- throw ('invalid insert into ' + TableSchema.name + ', invalid value for field ' + field.name + ' = ' + JSON.stringify(FieldValue));
- }
- }
- return true;
- }
- static clear() {
- this.clearComponent();
- this.clearStorage();
- }
- static clearComponent() {
- const key = this.getTableSchema().id;
- }
- static clearStorage() {
- const key = this.getTableSchema().id;
- localStorage.removeItem(key.keyPath);
- }
-}
diff --git a/src/plugin/src/models/model.reader.d.ts b/src/plugin/src/models/model.reader.d.ts
deleted file mode 100644
index 8d6d3ce87..000000000
--- a/src/plugin/src/models/model.reader.d.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { FieldsMap, AttributesMap } from './field/fields.interface.js';
-export declare class ModelReader {
- static read(modelClassRepresentation: any): {
- modelName: string;
- fields: {
- [key: string]: any;
- };
- fieldTypes: FieldsMap<"CharField" | "JsonField" | "AutoField" | "BigIntegerField" | "DateField" | "IntegerField" | "TextField" | "BooleanField" | "OneToOneField" | "ForeignKey" | "ManyToManyField" | "indexedDBJsonField" | "indexedDBArrayField" | "DateTimeField", string[]>;
- attributes: AttributesMap<"maxLength" | "minLength" | "choices" | "primaryKey" | "unique" | "autoIncrement" | "type" | "model" | "blank" | "default" | "onDelete" | "foreignKey", string[]>;
- };
-}
-export declare class LocalStorageModelReader {
- static read(modelClassRepresentation: any): {
- modelName: string;
- fields: {
- [key: string]: any;
- };
- attributes: AttributesMap<"maxLength" | "minLength" | "choices" | "primaryKey" | "unique" | "autoIncrement" | "type" | "model" | "blank" | "default" | "onDelete" | "foreignKey", string[]>;
- fieldTypes: FieldsMap<"CharField" | "JsonField" | "AutoField" | "BigIntegerField" | "DateField" | "IntegerField" | "TextField" | "BooleanField" | "OneToOneField" | "ForeignKey" | "ManyToManyField" | "indexedDBJsonField" | "indexedDBArrayField" | "DateTimeField", string[]>;
- };
-}
diff --git a/src/plugin/src/models/model.reader.js b/src/plugin/src/models/model.reader.js
deleted file mode 100644
index 397660b36..000000000
--- a/src/plugin/src/models/model.reader.js
+++ /dev/null
@@ -1,53 +0,0 @@
-import { FieldKeysArray } from './field/fields.interface.js';
-export class ModelReader {
- static read(modelClassRepresentation) {
- const classInstance = new modelClassRepresentation();
- const modelName = classInstance.getModelName();
- const fieldTypes = {};
- const fields = {};
- const attributes = {};
- for (const [fieldName, Field] of Object.entries(classInstance)) {
- const type = Field === null || Field === void 0 ? void 0 : Field.fieldName;
- if (FieldKeysArray.includes(type)) {
- fields[fieldName] = Field;
- if (!fieldTypes[type]) {
- fieldTypes[type] = [];
- }
- fieldTypes[type].push(fieldName);
- for (const [FieldProperty, value] of Object.entries(Field)) {
- if (typeof value != "function") {
- if (!attributes[FieldProperty]) {
- attributes[FieldProperty] = [];
- }
- attributes[FieldProperty].push(fieldName);
- }
- }
- }
- }
- return {
- modelName,
- fields,
- fieldTypes,
- attributes,
- };
- }
-}
-export class LocalStorageModelReader {
- static read(modelClassRepresentation) {
- const classInstance = modelClassRepresentation;
- const fieldTypes = {};
- const attributes = {};
- const modelName = classInstance.getModelName();
- const fields = {};
- for (const [fieldName, Field] of Object.entries(classInstance)) {
- // const type = Field?.fieldName
- fields[fieldName] = Field || null;
- }
- return {
- modelName,
- fields,
- attributes,
- fieldTypes
- };
- }
-}
diff --git a/src/plugin/src/models/register-model.d.ts b/src/plugin/src/models/register-model.d.ts
deleted file mode 100644
index a3d81b004..000000000
--- a/src/plugin/src/models/register-model.d.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { Model, LocalStorage } from './model.js';
-import { DatabaseSchema, DatabaseSchemaLocalStorage, TableSchema, TableSchemaLocalStorage } from './register-modal.interface.js';
-import { OneToOneField, ForeignKey, ManyToManyField } from './field/allFields.js';
-interface register {
- databaseName: string;
- version: number;
- type: 'indexedDB' | 'localStorage';
- models: typeof Model[] | typeof LocalStorage[];
-}
-export declare const models: {};
-export declare const modelsConfig: {
- [key: string]: {
- DatabaseSchema: DatabaseSchema;
- TableSchema: TableSchema;
- OneToOneField?: {
- [key: string]: {};
- };
- };
-};
-export declare const modelsLocalStorage: {};
-export declare const modelsConfigLocalStorage: {
- [key: string]: {
- DatabaseSchema: DatabaseSchemaLocalStorage;
- TableSchema: TableSchemaLocalStorage;
- };
-};
-export declare function migrate(register: register): void;
-export declare class registerModel {
- static register(entries: register): Promise;
- static manyToManyRelationShip(foreignKeyField: ManyToManyField, FieldName: string, modelName: string, databaseSchema: DatabaseSchema): Model;
-}
-export declare class registerLocalStorage {
- static register(entries: register): Promise;
-}
-export declare class ModelEditor {
- static addMethodOneToOneField(foreignKeyField: OneToOneField, FieldName: string, modelName: string, databaseSchema: DatabaseSchema): void;
- static addMethodForeignKey(foreignKeyField: ForeignKey, FieldName: string, modelName: string, databaseSchema: DatabaseSchema): void;
- static addMethodManyToManyField(foreignKeyField: ManyToManyField, FieldName: string, modelName: string, databaseSchema: DatabaseSchema): Promise;
-}
-export {};
diff --git a/src/plugin/src/models/register-model.js b/src/plugin/src/models/register-model.js
deleted file mode 100644
index 4281870bb..000000000
--- a/src/plugin/src/models/register-model.js
+++ /dev/null
@@ -1,346 +0,0 @@
-import { Model } from './model.js';
-import { LocalStorageModelReader, ModelReader } from './model.reader.js';
-import { indexedDB } from './../connection/indexedDb/indexedb.js';
-import { OneToOneField, ForeignKey, ManyToManyField } from './field/allFields.js';
-import { uncapitalize } from '../utils.js';
-import { FieldType } from '../sql/query/interface.js';
-import { ModelMigrations } from './mode-migrations.js';
-export const models = {};
-export const modelsConfig = {};
-export const modelsLocalStorage = {};
-export const modelsConfigLocalStorage = {};
-export function migrate(register) {
- if (register.type == 'indexedDB') {
- registerModel.register(register);
- }
- else if (register.type == 'localStorage') {
- registerLocalStorage.register(register);
- }
-}
-export class registerModel {
- static async register(entries) {
- var _a, _b, _c;
- const databaseSchema = {
- databaseName: entries.databaseName,
- version: entries.version,
- type: entries.type,
- stores: []
- };
- for (const modelClassRepresentations of entries.models) {
- const ModelName = modelClassRepresentations.getModelName();
- models[ModelName] = modelClassRepresentations;
- }
- let index = 0;
- for (const modelClassRepresentations of entries.models) {
- const { fields, modelName, attributes, fieldTypes } = ModelReader.read(modelClassRepresentations);
- const idFieldName = (_a = attributes === null || attributes === void 0 ? void 0 : attributes.primaryKey) === null || _a === void 0 ? void 0 : _a.shift();
- databaseSchema.stores.push({
- name: modelName,
- id: {
- keyPath: idFieldName || 'id',
- autoIncrement: fields[idFieldName] ? ((_b = fields[idFieldName]) === null || _b === void 0 ? void 0 : _b.primaryKey) == true : true,
- type: FieldType.INT
- },
- attributes: attributes,
- fields: [],
- fieldTypes
- });
- for (const [fieldName, Field] of Object.entries(fields)) {
- // dont register fields that is primary key and auto increment
- if (!((Field === null || Field === void 0 ? void 0 : Field.primaryKey) && (Field === null || Field === void 0 ? void 0 : Field.autoIncrement)) && !((_c = fieldTypes['ManyToManyField']) === null || _c === void 0 ? void 0 : _c.includes(fieldName))) {
- databaseSchema.stores[index].fields.push({
- name: fieldName,
- keyPath: fieldName,
- options: {
- unique: (Field === null || Field === void 0 ? void 0 : Field.unique) || false,
- type: Field.type
- },
- className: Field === null || Field === void 0 ? void 0 : Field.fieldName,
- fieldAttributes: Object.assign({}, Field)
- });
- }
- if (Field instanceof OneToOneField) {
- await ModelEditor.addMethodOneToOneField(Field, fieldName, modelName, databaseSchema);
- }
- else if (Field instanceof ForeignKey) {
- await ModelEditor.addMethodForeignKey(Field, fieldName, modelName, databaseSchema);
- }
- else if (Field instanceof ManyToManyField) {
- await ModelEditor.addMethodManyToManyField(Field, fieldName, modelName, databaseSchema);
- }
- }
- index++;
- }
- for (const modelClassRepresentations of entries.models) {
- const ModelName = modelClassRepresentations.getModelName();
- models[ModelName] = modelClassRepresentations;
- const tableSchema = databaseSchema.stores.find((e) => e.name == ModelName);
- modelsConfig[ModelName] = {
- DatabaseSchema: databaseSchema,
- TableSchema: tableSchema
- };
- }
- if (databaseSchema.type == 'indexedDB') {
- await indexedDB.migrate(databaseSchema);
- }
- ModelMigrations.migrationsState(true);
- }
- static manyToManyRelationShip(foreignKeyField, FieldName, modelName, databaseSchema) {
- const foreignKeyFieldModel = foreignKeyField.model;
- const currentModel = models[modelName];
- const foreignKeyFieldModelName = foreignKeyFieldModel.getModelName();
- const currentModelName = models[modelName].getModelName();
- const tableName = currentModelName + foreignKeyFieldModelName;
- const num = databaseSchema.stores.push({
- name: tableName,
- id: { keyPath: 'id', autoIncrement: true, type: FieldType.INT },
- fields: [
- {
- name: 'iD' + foreignKeyFieldModelName,
- keyPath: 'iD' + foreignKeyFieldModelName,
- options: {
- unique: false,
- type: FieldType.INT
- },
- className: 'IntegerField'
- },
- {
- name: 'iD' + currentModelName,
- keyPath: 'iD' + currentModelName,
- options: {
- unique: false,
- type: FieldType.INT
- },
- className: 'IntegerField'
- }
- ],
- attributes: {},
- fieldTypes: {
- IntegerField: ['iD' + foreignKeyFieldModelName, 'iD' + currentModelName]
- }
- });
- const id = num - 1;
- models[tableName] = generateGenericModel({
- DBSchema: databaseSchema,
- ModelName: tableName,
- TableSchema: databaseSchema.stores[id]
- });
- return generateGenericModel({
- DBSchema: databaseSchema,
- ModelName: tableName,
- TableSchema: databaseSchema.stores[id]
- });
- }
-}
-export class registerLocalStorage {
- static async register(entries) {
- const databaseSchema = {
- databaseName: entries.databaseName,
- version: entries.version,
- type: 'localStorage',
- stores: []
- };
- for (const modelClassRepresentations of entries.models) {
- const ModelName = modelClassRepresentations.getModelName();
- modelsLocalStorage[ModelName] = modelClassRepresentations;
- }
- let index = 0;
- for (const modelClassRepresentations of entries.models) {
- const { fields, modelName, attributes, fieldTypes } = LocalStorageModelReader.read(modelClassRepresentations);
- // const idFieldName = attributes?.primaryKey?.shift()
- databaseSchema.stores.push({
- name: modelName,
- id: {
- keyPath: modelName,
- type: FieldType.VARCHAR,
- autoIncrement: false
- },
- attributes: attributes,
- fields: [],
- fieldTypes
- });
- for (const [fieldName, Field] of Object.entries(fields)) {
- databaseSchema.stores[index].fields.push({
- name: fieldName,
- keyPath: fieldName,
- options: {
- unique: false,
- type: null
- },
- className: Field === null || Field === void 0 ? void 0 : Field.fieldName,
- fieldAttributes: Object.assign({}, Field)
- });
- }
- index++;
- }
- for (const modelClassRepresentations of entries.models) {
- const ModelName = modelClassRepresentations.getModelName();
- const tableSchema = databaseSchema.stores.find((e) => e.name == ModelName);
- modelClassRepresentations.getDBSchema = () => {
- return databaseSchema;
- };
- modelClassRepresentations.getTableSchema = () => {
- return tableSchema;
- };
- modelsConfigLocalStorage[ModelName] = {
- DatabaseSchema: databaseSchema,
- TableSchema: tableSchema
- };
- modelsLocalStorage[ModelName] = modelClassRepresentations;
- }
- ModelMigrations.migrationsState(true);
- }
-}
-export class ModelEditor {
- static addMethodOneToOneField(foreignKeyField, FieldName, modelName, databaseSchema) {
- const foreignKeyFieldModel = foreignKeyField.model;
- const currentModel = models[modelName];
- foreignKeyFieldModel['prototype'][modelName] = async function (body) {
- const foreignModel = currentModel;
- const TableSchema = foreignModel.getTableSchema();
- const obj = {};
- obj[TableSchema.id.keyPath] = this.getPrimaryKeyValue();
- return await foreignModel.get(obj);
- };
- currentModel['prototype'][foreignKeyFieldModel['name']] = async function () {
- const foreignModel = foreignKeyFieldModel;
- let params = {};
- const TableSchema = foreignModel.getTableSchema();
- params[TableSchema.id.keyPath] = this.getPrimaryKeyValue();
- return await foreignModel.get(params);
- };
- }
- static addMethodForeignKey(foreignKeyField, FieldName, modelName, databaseSchema) {
- const foreignKeyFieldModel = foreignKeyField.model;
- const currentModel = models[modelName];
- const FunctionName = uncapitalize(modelName);
- foreignKeyFieldModel['prototype'][FunctionName + '_setAll'] = async function () {
- const obj = {};
- obj[FieldName] = this.getPrimaryKeyValue();
- const currentModel = models[modelName];
- return await currentModel.filter(obj).execute();
- };
- foreignKeyFieldModel['prototype'][FunctionName + '_setAdd'] = async function (arg) {
- const reporter = this;
- arg[FieldName] = reporter;
- return currentModel['create'](arg);
- };
- currentModel['prototype'][foreignKeyFieldModel.getModelName()] = async function () {
- const TableSchema = foreignKeyFieldModel.getTableSchema();
- const obj = {};
- obj[TableSchema.id.keyPath] = this[FieldName];
- return foreignKeyFieldModel.filter(obj).execute();
- };
- }
- static async addMethodManyToManyField(foreignKeyField, FieldName, modelName, databaseSchema) {
- const foreignKeyFieldModel = foreignKeyField.model;
- FieldName = FieldName;
- const currentModel = models[modelName];
- const middleTable = await registerModel.manyToManyRelationShip(foreignKeyField, FieldName, modelName, databaseSchema);
- currentModel['prototype'][FieldName + '_add'] = async function (modelInstances) {
- if (modelInstances.constructor.name != 'Array') {
- modelInstances = [modelInstances];
- }
- for (const modelInstance of modelInstances) {
- if (modelInstance instanceof foreignKeyFieldModel) {
- let params = {};
- params[`iD${currentModel.getModelName()}`] = this.getPrimaryKeyValue();
- params[`iD${modelInstance.getModelName()}`] = modelInstance.getPrimaryKeyValue();
- await middleTable['create'](params);
- }
- else {
- throw ('Need to be instance of ' + foreignKeyFieldModel.getModelName());
- }
- }
- };
- currentModel['prototype'][FieldName] = function () {
- let _model = this;
- return {
- async all() {
- let params = {};
- params[`iD${_model.getModelName()}`] = _model.getPrimaryKeyValue();
- const middleTableResult = await middleTable['filter'](params).execute();
- foreignKeyField.model;
- return middleTableResult;
- }
- };
- };
- currentModel['prototype'][FieldName + '_all'] = async function () {
- let _model = this;
- let params = {};
- let result = [];
- params[`iD${_model.getModelName()}`] = _model.getPrimaryKeyValue();
- const middleTableResult = await middleTable['filter'](params).execute();
- let ids;
- if (middleTableResult) {
- const TableSchema = foreignKeyField.model.getTableSchema();
- ids = middleTableResult.map((e) => {
- return e[`iD${foreignKeyField.model.name}`];
- });
- let params = {};
- for (const id of ids) {
- try {
- params[TableSchema.id.keyPath] = id;
- const row = await foreignKeyField.model.get(params);
- result.push(row);
- }
- catch (error) {
- }
- }
- }
- return result;
- };
- foreignKeyField.model['prototype'][uncapitalize(modelName) + '_set_all'] = async function () {
- let _model = this;
- let params = {};
- let result = [];
- params[`iD${_model.getModelName()}`] = _model.getPrimaryKeyValue();
- const middleTableResult = await middleTable['filter'](params).execute();
- let ids;
- if (middleTableResult) {
- const TableSchema = currentModel.getTableSchema();
- ids = middleTableResult.map((e) => {
- return e[`iD${modelName}`];
- });
- let params = {};
- for (const id of ids) {
- try {
- params[TableSchema.id.keyPath] = id;
- const row = await currentModel.get(params);
- result.push(row);
- }
- catch (error) {
- }
- }
- }
- return result;
- };
- }
-}
-function generateGenericModel({ DBSchema, ModelName, TableSchema }) {
- class GenericModel extends Model {
- }
- for (const [Field, value] of Object.entries(Model)) {
- GenericModel[Field] = value;
- }
- // GenericModel.prototype = Model.prototype
- GenericModel.prototype['getDBSchema'] = () => {
- return DBSchema;
- };
- GenericModel.prototype['getModelName'] = () => {
- return ModelName;
- };
- GenericModel.prototype['getTableSchema'] = () => {
- return TableSchema;
- };
- GenericModel['getDBSchema'] = () => {
- return DBSchema;
- };
- GenericModel['getModelName'] = () => {
- return ModelName;
- };
- GenericModel['getTableSchema'] = () => {
- return TableSchema;
- };
- return GenericModel;
-}
diff --git a/src/plugin/src/sql/Operators/Object-condition-operator.d.ts b/src/plugin/src/sql/Operators/Object-condition-operator.d.ts
deleted file mode 100644
index 7f1e4550b..000000000
--- a/src/plugin/src/sql/Operators/Object-condition-operator.d.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { TableSchema } from '../../models/register-modal.interface.js';
-import { argsAttributes } from './args-attributes.js';
-export declare class ObjectConditionOperator {
- private TableSchema;
- private args;
- row: any;
- constructor(TableSchema: TableSchema, args: argsAttributes);
- run(row: any): boolean | any;
- private execute;
-}
diff --git a/src/plugin/src/sql/Operators/Object-condition-operator.js b/src/plugin/src/sql/Operators/Object-condition-operator.js
deleted file mode 100644
index 5193cda2a..000000000
--- a/src/plugin/src/sql/Operators/Object-condition-operator.js
+++ /dev/null
@@ -1,33 +0,0 @@
-export class ObjectConditionOperator {
- constructor(TableSchema, args) {
- this.TableSchema = TableSchema;
- this.args = args;
- }
- run(row) {
- this.row = row;
- for (const arg of this.args.value) {
- const result = this.execute(arg);
- if (result) {
- return true;
- }
- }
- }
- execute(objOperator) {
- for (let objOperatorFieldName in objOperator) {
- const field = objOperator[objOperatorFieldName];
- const fieldName = field.fieldName;
- const fieldPath = field.fieldPath;
- const operation = field.operation;
- const operationArg = field.operationArg;
- const fieldClassName = field.fieldClassName;
- const operator = field.operator;
- const customData = field.customData({ row: this.row, fieldPath });
- const arg = operationArg;
- let operationResult = operator({ fieldName, arg, row: this.row, TableSchema: this.TableSchema, element: fieldName, fieldPath, customData });
- if (!operationResult) {
- return false;
- }
- }
- return true;
- }
-}
diff --git a/src/plugin/src/sql/Operators/args-attributes.d.ts b/src/plugin/src/sql/Operators/args-attributes.d.ts
deleted file mode 100644
index f596044ac..000000000
--- a/src/plugin/src/sql/Operators/args-attributes.d.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { AttributesMap, FieldKeys, FieldsMap } from "../../models/field/fields.interface.js";
-import { OperatorKeys } from "./object-operator.js";
-import { TableSchema, FieldSchema } from '../../models/register-modal.interface.js';
-export interface Field {
- fieldName: string;
- fieldPath: string;
- operation: OperatorKeys;
- operationArg?: string;
- operator: Function;
- fieldClassName: FieldKeys;
- customData?: Function;
-}
-export declare class argsAttributes {
- private TableSchema;
- value: Array>;
- schemeFields: AttributesMap;
- constructor(args: any, TableSchema: TableSchema);
- private analyzeArgs;
- private detectClassName;
- private detectOperator;
- private argsPrettyTransform;
-}
diff --git a/src/plugin/src/sql/Operators/args-attributes.js b/src/plugin/src/sql/Operators/args-attributes.js
deleted file mode 100644
index 850d90558..000000000
--- a/src/plugin/src/sql/Operators/args-attributes.js
+++ /dev/null
@@ -1,118 +0,0 @@
-import { OperatorsKeysArray, operator, ObjOperatorOverwrite, ArrOperatorOverwrite } from "./object-operator.js";
-import { info } from "./operators.js";
-export class argsAttributes {
- constructor(args, TableSchema) {
- this.TableSchema = TableSchema;
- this.value = [];
- this.schemeFields = {} = {};
- for (const field of this.TableSchema.fields) {
- this.schemeFields[field.name] = field;
- }
- this.schemeFields[this.TableSchema.id.keyPath] = {
- keyPath: this.TableSchema.id.keyPath,
- name: this.TableSchema.id.keyPath,
- className: 'IntegerField',
- };
- if (args.constructor.name != 'Array') {
- args = [args];
- }
- const conditions = this.argsPrettyTransform(args);
- this.value = this.analyzeArgs(conditions);
- }
- analyzeArgs(conditions) {
- return conditions.map((condition) => {
- const newObject = {};
- const keys = Object.keys(condition);
- for (let field of keys) {
- let fieldName;
- let fieldPath;
- let arg;
- const element = field.split('__');
- if (element.length == 1) {
- element.push('eq');
- }
- let operation = element[element.length - 1];
- if (OperatorsKeysArray.includes(operation)) {
- operation = element.pop();
- }
- else {
- operation = 'eq';
- }
- fieldName = element[0];
- fieldPath = element.join('.');
- if (OperatorsKeysArray.includes(operation)) {
- arg = condition[field];
- }
- else {
- throw ('operator');
- }
- const fieldClassName = this.detectClassName(fieldName);
- newObject[field] = {
- fieldName: fieldName,
- fieldPath: fieldPath,
- operation: operation,
- operationArg: arg,
- operator: this.detectOperator(fieldClassName, operation, fieldName),
- fieldClassName: fieldClassName,
- };
- if (fieldClassName == 'indexedDBArrayField' || fieldClassName == 'indexedDBJsonField') {
- newObject[field]['customData'] = info.run;
- }
- else {
- newObject[field]['customData'] = () => { };
- }
- }
- return newObject;
- });
- }
- detectClassName(fieldName) {
- return this.schemeFields[fieldName].className;
- }
- detectOperator(fieldClassName, operation, fieldName) {
- try {
- if (fieldClassName == 'indexedDBJsonField') {
- return ObjOperatorOverwrite[operation];
- }
- else if (fieldClassName == 'indexedDBArrayField') {
- return ArrOperatorOverwrite[operation];
- }
- else {
- return operator[operation];
- }
- }
- catch (err) {
- // console.log(this.TableSchema, this.schemeFields[fieldName])
- throw ('Field ' + fieldName + ' does not exit on the table' + err);
- }
- }
- argsPrettyTransform(args) {
- const conditions = [];
- const loop = (o) => {
- // https://stackoverflow.com/a/38597076/14115342
- const condition = {};
- for (const k of Object.keys(o)) {
- if (o[k].constructor.name === 'Array') {
- loop(o[k]);
- }
- else {
- if (o.constructor.name === 'Array') {
- // console.log('dif', o, k , )
- for (const j of Object.keys(o[k])) {
- // console.log('push', o[k], j)
- condition[j] = o[k][j];
- }
- }
- else {
- // console.log('push', o, k)
- condition[k] = o[k];
- }
- }
- }
- if (JSON.stringify(condition) !== '{}') {
- conditions.push(condition);
- }
- };
- loop(args);
- return conditions;
- }
-}
diff --git a/src/plugin/src/sql/Operators/object-operator.d.ts b/src/plugin/src/sql/Operators/object-operator.d.ts
deleted file mode 100644
index c027dfb9f..000000000
--- a/src/plugin/src/sql/Operators/object-operator.d.ts
+++ /dev/null
@@ -1,478 +0,0 @@
-export declare const OperatorsKeysArray: readonly ["gt", "gte", "lt", "lte", "not", "eq", "contains", "len", "hasKey", "ForeignKey", "containedBy", "overlap", "isNull", "contained_by", "has_key", "has_keys", "has_any_keys", "len", "overlap", "iexact"];
-export declare type OperatorKeys = typeof OperatorsKeysArray[number];
-export declare const operator: {
- gt: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- gte: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- lt: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- lte: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- not: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- eq: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- contains: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => any;
- len({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
- hasKey({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
- containedBy({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
- overlap({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): any;
- isNull({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
- iexact({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-};
-export declare const ObjOperatorOverwrite: {
- gt: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- gte: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- lt: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- lte: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- not: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- eq: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- contains: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => any;
- len({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
- hasKey({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
- containedBy({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
- overlap({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): any;
- isNull({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
- iexact({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-} & {
- isNull({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
- eq: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- contains: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- contained_by: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- has_key({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
- has_keys({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
- has_any_keys({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-};
-export declare const ArrOperatorOverwrite: {
- gt: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- gte: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- lt: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- lte: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- not: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- eq: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- contains: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => any;
- len({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
- hasKey({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
- containedBy({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
- overlap({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): any;
- isNull({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
- iexact({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-} & {
- isNull({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }): boolean;
- eq: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- contains: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- contained_by: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- len: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
- overlap: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- TableSchema: any;
- element: any;
- fieldPath: any;
- customData: any;
- }) => boolean;
-};
diff --git a/src/plugin/src/sql/Operators/object-operator.js b/src/plugin/src/sql/Operators/object-operator.js
deleted file mode 100644
index 9322d5db1..000000000
--- a/src/plugin/src/sql/Operators/object-operator.js
+++ /dev/null
@@ -1,107 +0,0 @@
-import * as operatorsObject from './operators.js';
-export const OperatorsKeysArray = [
- 'gt',
- 'gte',
- 'lt',
- 'lte',
- 'not',
- 'eq',
- 'contains',
- 'len',
- 'hasKey',
- 'ForeignKey',
- 'containedBy',
- 'overlap',
- 'isNull',
- 'contained_by',
- 'has_key',
- 'has_keys',
- 'has_any_keys',
- 'len',
- 'overlap',
- 'iexact'
-]; // TS3.4 syntax
-export const operator = {
- gt: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) => {
- return operatorsObject.gt.validate({ fieldName, arg, row, fieldPath, customData });
- },
- gte: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) => {
- return operatorsObject.gte.validate({ fieldName, arg, row, fieldPath, customData });
- },
- lt: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) => {
- return operatorsObject.lt.validate({ fieldName, arg, row, fieldPath, customData });
- },
- lte: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) => {
- return operatorsObject.lte.validate({ fieldName, arg, row, fieldPath });
- },
- not: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) => {
- return operatorsObject.not.validate({ fieldName, arg, row, fieldPath });
- },
- eq: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) => {
- return operatorsObject.eq.validate({ fieldName, arg, row, fieldPath, customData });
- },
- contains: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) => {
- return operatorsObject.contains.validate({ fieldName, arg, row, fieldPath, customData });
- },
- len({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) {
- return operatorsObject.len.validate({ fieldName, arg, row, fieldPath, customData });
- },
- hasKey({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) {
- return operatorsObject.hasKey.validate({ fieldName, arg, row, fieldPath, customData });
- },
- containedBy({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) {
- return operatorsObject.containedBy.validate({ fieldName, arg, row, fieldPath, customData });
- },
- overlap({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) {
- return operatorsObject.overlap.validate({ fieldName, arg, row, fieldPath, customData });
- },
- isNull({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) {
- return operatorsObject.isNull.validate({ fieldName, arg, row, fieldPath, customData });
- },
- iexact({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) {
- return operatorsObject.iexact.validate({ fieldName, arg, row, fieldPath, customData });
- }
-};
-export const ObjOperatorOverwrite = Object.assign(Object.assign({}, operator), {
- isNull({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) {
- return operatorsObject.objectIsnull.validate({ fieldName, arg, row, fieldPath, customData });
- },
- eq: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) => {
- return operatorsObject.objectEq.validate({ fieldName, arg, row, fieldPath, customData });
- },
- contains: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) => {
- return operatorsObject.objectContains.validate({ fieldName, arg, row, fieldPath, customData });
- },
- contained_by: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) => {
- return operatorsObject.objectContains_by.validate({ fieldName, arg, row, fieldPath, customData });
- },
- has_key({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) {
- return operatorsObject.objectHasKey.validate({ fieldName, arg, row, fieldPath, customData });
- },
- has_keys({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) {
- return operatorsObject.objectHasKeys.validate({ fieldName, arg, row, fieldPath, customData });
- },
- has_any_keys({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) {
- return operatorsObject.objectHasnyKeys.validate({ fieldName, arg, row, fieldPath, customData });
- }
-});
-export const ArrOperatorOverwrite = Object.assign(Object.assign({}, operator), {
- isNull({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) {
- return operatorsObject.objectIsnull.validate({ fieldName, arg, row, fieldPath, customData });
- },
- eq: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) => {
- return operatorsObject.ArrayFieldEq.validate({ fieldName, arg, row, fieldPath, customData });
- },
- contains: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) => {
- return operatorsObject.ArrayFieldContains.validate({ fieldName, arg, row, fieldPath, customData });
- },
- contained_by: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) => {
- return operatorsObject.ArrayFieldContains_by.validate({ fieldName, arg, row, fieldPath, customData });
- },
- len: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) => {
- return operatorsObject.ArrayFieldContains_len.validate({ fieldName, arg, row, fieldPath, customData });
- },
- overlap: ({ fieldName, arg, row, TableSchema, element, fieldPath, customData }) => {
- return operatorsObject.ArrayFieldContains_overlap.validate({ fieldName, arg, row, fieldPath, customData });
- }
-});
diff --git a/src/plugin/src/sql/Operators/operators.d.ts b/src/plugin/src/sql/Operators/operators.d.ts
deleted file mode 100644
index fc7c952a5..000000000
--- a/src/plugin/src/sql/Operators/operators.d.ts
+++ /dev/null
@@ -1,258 +0,0 @@
-export declare class gt {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class iexact {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class gte {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class lt {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class lte {
- static validate({ fieldName, arg, row, fieldPath }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- }): boolean;
-}
-export declare class not {
- static validate({ fieldName, arg, row, fieldPath }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- }): boolean;
-}
-export declare class eq {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class contains {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): any;
-}
-export declare class info {
- static run({ row, fieldPath }: {
- row: any;
- fieldPath: any;
- }): {
- value: any;
- present: any;
- };
-}
-export declare class containsOBj {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class containedBy {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class overlap {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): any;
-}
-export declare class len {
- static validate({ fieldName, arg, rowFieldValue, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- rowFieldValue?: any[];
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class hasKey {
- static validate({ fieldName, arg, rowFieldValue, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- rowFieldValue?: any[];
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class hasAnyKeys {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): any;
-}
-/**
- * @returns true when all of the given keys are in the data
- */
-export declare class hasKeys {
- static validate(fieldObj: any, keys: any, row: any): boolean;
-}
-export declare class isNull {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class objectIsnull {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class objectEq {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class objectContains {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class objectContains_by {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class objectHasKey {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class objectHasKeys {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class objectHasnyKeys {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class ArrayFieldEq {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class ArrayFieldContains {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class ArrayFieldContains_by {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class ArrayFieldContains_overlap {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
-export declare class ArrayFieldContains_len {
- static validate({ fieldName, arg, row, fieldPath, customData }: {
- fieldName: any;
- arg: any;
- row: any;
- fieldPath: any;
- customData: any;
- }): boolean;
-}
diff --git a/src/plugin/src/sql/Operators/operators.js b/src/plugin/src/sql/Operators/operators.js
deleted file mode 100644
index ca5376b1a..000000000
--- a/src/plugin/src/sql/Operators/operators.js
+++ /dev/null
@@ -1,576 +0,0 @@
-import { getDeep } from '../../utils.js';
-export class gt {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- return _rowFieldValue > arg;
- }
-}
-export class iexact {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- return _rowFieldValue === arg;
- }
-}
-export class gte {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- return _rowFieldValue >= arg;
- }
-}
-export class lt {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- return _rowFieldValue < arg;
- }
-}
-export class lte {
- static validate({ fieldName, arg, row, fieldPath }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- return _rowFieldValue <= arg;
- }
-}
-export class not {
- static validate({ fieldName, arg, row, fieldPath }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- return _rowFieldValue != arg;
- }
-}
-export class eq {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- return _rowFieldValue == arg;
- }
-}
-export class contains {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- return _rowFieldValue.some(r => arg.includes(r));
- }
-}
-export class info {
- static run({ row, fieldPath }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return {
- present: false,
- value: undefined
- };
- }
- }
- catch (error) {
- return {
- present: false,
- value: undefined
- };
- }
- return {
- present: true,
- value: undefined
- };
- }
-}
-export class containsOBj {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- const keys = Object.keys(arg);
- for (let key of keys) {
- if (!_rowFieldValue[key]) {
- return false;
- }
- }
- return true;
- }
-}
-export class containedBy {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- for (let value of _rowFieldValue) {
- if (!arg.includes(value)) {
- return false;
- }
- }
- return true;
- }
-}
-export class overlap {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- return _rowFieldValue.some(r => arg.includes(r));
- }
-}
-export class len {
- static validate({ fieldName, arg, rowFieldValue = [], row, fieldPath, customData }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- return _rowFieldValue.length == arg;
- }
-}
-export class hasKey {
- static validate({ fieldName, arg, rowFieldValue = [], row, fieldPath, customData }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- const keys = Object.keys(arg);
- for (let key of keys) {
- if (!_rowFieldValue[key]) {
- return false;
- }
- }
- }
-}
-export class hasAnyKeys {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- return _rowFieldValue.some(key => !arg.includes(key));
- }
-}
-/**
- * @returns true when all of the given keys are in the data
- */
-export class hasKeys {
- static validate(fieldObj, keys, row) {
- for (let fieldName of keys) {
- if (!fieldObj[fieldName]) {
- return false;
- }
- }
- return true;
- }
-}
-// Slice transforms
-export class isNull {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- return (_rowFieldValue == null) == arg;
- }
-}
-// object
-export class objectIsnull {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let rowFieldValue;
- try {
- rowFieldValue = getDeep(row, fieldPath);
- if (rowFieldValue === undefined) {
- if (arg == true) {
- return true;
- }
- }
- }
- catch (error) {
- if (arg == true) {
- return true;
- }
- return false;
- }
- if (JSON.stringify(rowFieldValue) == '{}' && arg == false) {
- return true;
- }
- else if (rowFieldValue == null && arg == true) {
- return true;
- }
- else if (rowFieldValue == undefined) {
- return true;
- }
- return false;
- }
-}
-export class objectEq {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- if (JSON.stringify(_rowFieldValue = getDeep(row, fieldPath)) == '{}' && '{}' == JSON.stringify(arg)) {
- return true;
- }
- else if (arg == null && JSON.stringify(_rowFieldValue) == '{}') {
- return true;
- }
- else if (fieldPath) {
- if (arg == _rowFieldValue) {
- return true;
- }
- }
- return false;
- }
-}
-export class objectContains {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- // console.log(fieldName, arg, row)
- let rowValue;
- try {
- rowValue = getDeep(row, fieldPath);
- if (rowValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- for (const keys of Object.keys(arg)) {
- if (!rowValue[keys]) {
- return false;
- }
- else {
- if (rowValue[keys] != arg[keys]) {
- return false;
- }
- }
- }
- return true;
- }
-}
-export class objectContains_by {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- // console.log(fieldName, arg, row);
- let rowValue;
- const keyCount = Object.keys(arg).length;
- let keyFoundNEqual = 0;
- try {
- rowValue = getDeep(row, fieldPath);
- if (rowValue === undefined) {
- return false;
- }
- else {
- for (const keys of Object.keys(arg)) {
- if (rowValue[keys]) {
- if (rowValue[keys] == arg[keys]) {
- keyFoundNEqual++;
- }
- }
- }
- }
- }
- catch (error) {
- return false;
- }
- // console.log('keyFoundNEqual', keyFoundNEqual, 'keyCount', keyCount);
- if (keyFoundNEqual == 0) {
- return true;
- }
- else if (keyFoundNEqual == keyCount) {
- return true;
- }
- return false;
- }
-}
-export class objectHasKey {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let rowValue;
- try {
- rowValue = getDeep(row, fieldPath);
- if (rowValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- if (rowValue[arg]) {
- return true;
- }
- return false;
- }
-}
-export class objectHasKeys {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let rowValue;
- try {
- rowValue = getDeep(row, fieldPath);
- if (rowValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- const keys = Object.keys(rowValue);
- for (const a of arg) {
- if (!keys.includes(a)) {
- return false;
- }
- }
- return true;
- }
-}
-export class objectHasnyKeys {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let rowValue;
- try {
- rowValue = getDeep(row, fieldPath);
- if (rowValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- const keys = Object.keys(rowValue);
- for (const a of arg) {
- if (keys.includes(a)) {
- return true;
- }
- }
- return false;
- }
-}
-// array shit
-export class ArrayFieldEq {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let _rowFieldValue;
- try {
- _rowFieldValue = getDeep(row, fieldPath);
- if (_rowFieldValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- if (JSON.stringify(_rowFieldValue) == '[]' && '[]' == JSON.stringify(arg)) {
- return true;
- }
- else if (arg == null && JSON.stringify(_rowFieldValue) == '[]') {
- return true;
- }
- else if (fieldPath) {
- if (arg == _rowFieldValue) {
- return true;
- }
- }
- return false;
- }
-}
-export class ArrayFieldContains {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let rowValue;
- try {
- rowValue = getDeep(row, fieldPath);
- if (rowValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- try {
- for (const keys of arg) {
- if (!rowValue.includes(keys)) {
- return false;
- }
- }
- }
- catch (error) {
- return false;
- }
- return true;
- }
-}
-export class ArrayFieldContains_by {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let rowValue;
- try {
- rowValue = getDeep(row, fieldPath);
- if (rowValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- try {
- for (const keys of arg) {
- if (rowValue.includes(keys)) {
- return true;
- }
- }
- }
- catch (error) {
- return false;
- }
- return false;
- }
-}
-export class ArrayFieldContains_overlap {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let rowValue;
- try {
- rowValue = getDeep(row, fieldPath);
- if (rowValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- try {
- for (const keys of arg) {
- if (rowValue.includes(keys)) {
- return true;
- }
- }
- }
- catch (error) {
- return false;
- }
- return false;
- }
-}
-export class ArrayFieldContains_len {
- static validate({ fieldName, arg, row, fieldPath, customData }) {
- let rowValue;
- try {
- rowValue = getDeep(row, fieldPath);
- if (rowValue === undefined) {
- return false;
- }
- }
- catch (error) {
- return false;
- }
- if (rowValue.length == arg) {
- return true;
- }
- return false;
- }
-}
diff --git a/src/plugin/src/sql/Operators/query-bulder.d.ts b/src/plugin/src/sql/Operators/query-bulder.d.ts
deleted file mode 100644
index e69de29bb..000000000
diff --git a/src/plugin/src/sql/Operators/query-bulder.js b/src/plugin/src/sql/Operators/query-bulder.js
deleted file mode 100644
index e69de29bb..000000000
diff --git a/src/plugin/src/sql/methods/filter.d.ts b/src/plugin/src/sql/methods/filter.d.ts
deleted file mode 100644
index 1169c4cf1..000000000
--- a/src/plugin/src/sql/methods/filter.d.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { ObjectConditionOperator } from '../Operators/Object-condition-operator.js';
-import { argsAttributes } from '../Operators/args-attributes.js';
-export declare class filter {
- private arg;
- private TableSchema;
- rows: any[];
- operator: ObjectConditionOperator;
- constructor(arg: argsAttributes, TableSchema: any);
- cursor(row: object, resolve?: any, limit?: any): Promise;
- run(rows: any[]): Promise;
-}
diff --git a/src/plugin/src/sql/methods/filter.js b/src/plugin/src/sql/methods/filter.js
deleted file mode 100644
index e8563a9ba..000000000
--- a/src/plugin/src/sql/methods/filter.js
+++ /dev/null
@@ -1,28 +0,0 @@
-import { ObjectConditionOperator } from '../Operators/Object-condition-operator.js';
-export class filter {
- constructor(arg, TableSchema) {
- this.arg = arg;
- this.TableSchema = TableSchema;
- this.rows = [];
- this.operator = new ObjectConditionOperator(this.TableSchema, this.arg);
- }
- async cursor(row, resolve, limit) {
- const operationsResult = await this.operator.run(row);
- if (operationsResult == true) {
- this.rows.push(row);
- if (this.rows.length == limit) {
- resolve(this.rows);
- }
- }
- }
- async run(rows) {
- const newRows = [];
- for (let row of rows) {
- const operationsResult = await this.operator.run(row);
- if (operationsResult == true) {
- newRows.push(row);
- }
- }
- return newRows;
- }
-}
diff --git a/src/plugin/src/sql/methods/methods.d.ts b/src/plugin/src/sql/methods/methods.d.ts
deleted file mode 100644
index 36eb234c1..000000000
--- a/src/plugin/src/sql/methods/methods.d.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-export declare const methodsType: readonly ["filter"];
-export declare type methodsTypeKeys = typeof methodsType[number];
-export declare type methodsMap = {
- [P in K]?: T;
-};
-export declare class methodFunction {
- private arg;
- private TableSchema;
- rows: any[];
- constructor(arg: any, TableSchema: any);
- cursor(row: object, resolve?: any, limit?: any): Promise;
- run(rows: any[]): Promise;
-}
-export declare const methods: methodsMap;
diff --git a/src/plugin/src/sql/methods/methods.js b/src/plugin/src/sql/methods/methods.js
deleted file mode 100644
index 04abc8bd0..000000000
--- a/src/plugin/src/sql/methods/methods.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import { filter } from './filter.js';
-export const methodsType = [
- 'filter',
-]; // TS3.4 syntax
-export const methods = {
- filter: filter
-};
diff --git a/src/plugin/src/sql/query/interface.d.ts b/src/plugin/src/sql/query/interface.d.ts
deleted file mode 100644
index c51a9ae6c..000000000
--- a/src/plugin/src/sql/query/interface.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export declare enum FieldType {
- AUTO = 0,
- INT = 1,
- BIGINT = 2,
- TEXT = 3,
- VARCHAR = 4,
- DATE = 5,
- BOOL = 6,
- CHAR = 7,
- JSON = 8,
- ARRAY = 9
-}
diff --git a/src/plugin/src/sql/query/interface.js b/src/plugin/src/sql/query/interface.js
deleted file mode 100644
index 42481b09a..000000000
--- a/src/plugin/src/sql/query/interface.js
+++ /dev/null
@@ -1,14 +0,0 @@
-export var FieldType;
-(function (FieldType) {
- FieldType[FieldType["AUTO"] = 0] = "AUTO";
- FieldType[FieldType["INT"] = 1] = "INT";
- FieldType[FieldType["BIGINT"] = 2] = "BIGINT";
- FieldType[FieldType["TEXT"] = 3] = "TEXT";
- FieldType[FieldType["VARCHAR"] = 4] = "VARCHAR";
- FieldType[FieldType["DATE"] = 5] = "DATE";
- FieldType[FieldType["BOOL"] = 6] = "BOOL";
- FieldType[FieldType["CHAR"] = 7] = "CHAR";
- FieldType[FieldType["JSON"] = 8] = "JSON";
- FieldType[FieldType["ARRAY"] = 9] = "ARRAY";
-})(FieldType || (FieldType = {}));
-//
diff --git a/src/plugin/src/sql/sqlObject/sql.d.ts b/src/plugin/src/sql/sqlObject/sql.d.ts
deleted file mode 100644
index a4c423060..000000000
--- a/src/plugin/src/sql/sqlObject/sql.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-declare class sql {
- filter(): void;
-}
diff --git a/src/plugin/src/sql/sqlObject/sql.js b/src/plugin/src/sql/sqlObject/sql.js
deleted file mode 100644
index 4c777dc5c..000000000
--- a/src/plugin/src/sql/sqlObject/sql.js
+++ /dev/null
@@ -1,3 +0,0 @@
-class sql {
- filter() { }
-}
diff --git a/src/plugin/src/sql/sqlObject/sqlObject.d.ts b/src/plugin/src/sql/sqlObject/sqlObject.d.ts
deleted file mode 100644
index 69abf4c89..000000000
--- a/src/plugin/src/sql/sqlObject/sqlObject.d.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { Method } from '../../models/model.interface.js';
-import { TableSchema } from '../../models/register-modal.interface.js';
-import { methodFunction } from '../methods/methods.js';
-import { argsAttributes } from '../Operators/args-attributes.js';
-export declare class SqlObject {
- private TableSchema;
- private Methods;
- limit: number;
- rows: any[];
- firstMethod: methodFunction;
- params: any[];
- argsAttributes: argsAttributes;
- constructor(TableSchema: TableSchema, Methods: Method[]);
- runFirstMethod(row: any, resolve?: any, limit?: any): Promise;
- doneRunFirstMethod(): Promise;
- run(): Promise;
-}
diff --git a/src/plugin/src/sql/sqlObject/sqlObject.js b/src/plugin/src/sql/sqlObject/sqlObject.js
deleted file mode 100644
index e59a2c9f6..000000000
--- a/src/plugin/src/sql/sqlObject/sqlObject.js
+++ /dev/null
@@ -1,31 +0,0 @@
-import { methods } from '../methods/methods.js';
-import { argsAttributes } from '../Operators/args-attributes.js';
-export class SqlObject {
- constructor(TableSchema, Methods) {
- this.TableSchema = TableSchema;
- this.Methods = Methods;
- this.limit = 0;
- this.rows = [];
- this.params = [];
- const arg = this.Methods[0].arguments;
- const methodName = this.Methods[0].methodName;
- this.argsAttributes = new argsAttributes(arg, TableSchema);
- this.firstMethod = new methods[methodName](this.argsAttributes, this.TableSchema);
- }
- async runFirstMethod(row, resolve, limit) {
- this.firstMethod.cursor(row, resolve, limit);
- }
- async doneRunFirstMethod() {
- this.rows = this.firstMethod.rows;
- }
- async run() {
- for (let i = 1; i < this.Methods.length; i++) {
- const method = this.Methods[i];
- const methodName = method.methodName;
- if (methods[methodName]) {
- const methodToExecute = new methods[methodName](this.argsAttributes, this.TableSchema);
- this.rows = await methodToExecute.run(this.rows);
- }
- }
- }
-}
diff --git a/src/plugin/src/utils.d.ts b/src/plugin/src/utils.d.ts
deleted file mode 100644
index 1d1f7e7a7..000000000
--- a/src/plugin/src/utils.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-export declare function uniqueGenerator(): string;
-export declare function hashCode(str: string): number;
-export declare function getDeep(obj: any, path: any): any;
-/** First Character uppercase */
-export declare function capitalize(str: any): any;
-/** First Character lowercase */
-export declare function uncapitalize(str: any): any;
diff --git a/src/plugin/src/utils.js b/src/plugin/src/utils.js
deleted file mode 100644
index b5770f4cc..000000000
--- a/src/plugin/src/utils.js
+++ /dev/null
@@ -1,34 +0,0 @@
-// generate unique string
-export function uniqueGenerator() {
- return (Math.random() + 'uuid' + new Date().getTime()).slice(2);
-}
-export function hashCode(str) {
- var hash = 0;
- for (var i = 0; i < str.length; i++) {
- var char = str.charCodeAt(i);
- hash = ((hash << 5) - hash) + char;
- hash = hash & hash;
- }
- return hash;
-}
-export function getDeep(obj, path) {
- try {
- for (var i = 0, path = path.split('.'), len = path.length; i < len; i++) {
- obj = obj[path[i]];
- }
- ;
- return obj;
- }
- catch (error) {
- return undefined;
- }
-}
-;
-/** First Character uppercase */
-export function capitalize(str) {
- return str.charAt(0).toUpperCase() + str.slice(1);
-}
-/** First Character lowercase */
-export function uncapitalize(str) {
- return str.charAt(0).toLowerCase() + str.slice(1);
-}
diff --git a/version/git-version.ts b/version/git-version.ts
index 118928ce6..f1fbb0ea5 100644
--- a/version/git-version.ts
+++ b/version/git-version.ts
@@ -1,12 +1,12 @@
export let versionData = {
- "shortSHA": "53b496ff0",
- "SHA": "53b496ff01cf30f09558aad215858bcd99ce3b13",
+ "shortSHA": "6e2669e52",
+ "SHA": "6e2669e52fe3be7da7e9afae832984db59613a83",
"branch": "no_bug_movemente",
"lastCommitAuthor": "'Peter Maquiran'",
- "lastCommitTime": "'Thu Feb 23 18:06:27 2023 +0100'",
- "lastCommitMessage": "update envarioment",
- "lastCommitNumber": "4826",
- "change": "diff --git a/src/app/models/beast-orm.ts b/src/app/models/beast-orm.ts\nindex 7ed0f9c1c..f6ac4f7b1 100644\n--- a/src/app/models/beast-orm.ts\n+++ b/src/app/models/beast-orm.ts\n@@ -1,4 +1,5 @@\n-import { models } from 'beast-orm'\n+//import { models } from 'beast-orm'\n+import { models } from 'src/plugin/src'\n import { environment } from 'src/environments/environment'\n const { ArrayField, JsonField} = models.indexedDB.fields\n \ndiff --git a/src/plugin/src/connection/dbSwtich.d.ts b/src/plugin/src/connection/dbSwtich.d.ts\nindex a459450c4..08694b748 100644\n--- a/src/plugin/src/connection/dbSwtich.d.ts\n+++ b/src/plugin/src/connection/dbSwtich.d.ts\n@@ -2,4 +2,5 @@ import { DatabaseSchema, TableSchema } from '../models/register-modal.interface.\n import { actionParam, dbType } from './intreface.js';\n export declare class DBSwitch {\n static requestHandler(TableSchema: TableSchema, DBconfig: DatabaseSchema, dbType: dbType, action: actionParam, arg: any, queryId: any): Promise;\n+ static callBackRequestHandler(TableSchema: TableSchema, DBconfig: DatabaseSchema, dbType: dbType, action: actionParam, arg: any, queryId: any): Promise;\n }\ndiff --git a/src/plugin/src/connection/dbSwtich.js b/src/plugin/src/connection/dbSwtich.js\nindex f8ec1ce40..e7f3c6e68 100644\n--- a/src/plugin/src/connection/dbSwtich.js\n+++ b/src/plugin/src/connection/dbSwtich.js\n@@ -7,12 +7,10 @@ export class DBSwitch {\n return new Promise(async (resolve, reject) => {\n const request = IndexedDBWorkerQueue.register({\n params: { TableSchema, DBconfig, queryId, action, arg, dbType },\n+ queryId: queryId,\n method: 'execute',\n func: (message) => {\n- if (message.queryId == queryId) {\n- resolve(message === null || message === void 0 ? void 0 : message.value);\n- return true;\n- }\n+ resolve(message === null || message === void 0 ? void 0 : message.value);\n },\n });\n if (request == false) {\n@@ -26,4 +24,25 @@ export class DBSwitch {\n return result === null || result === void 0 ? void 0 : result.value;\n }\n }\n+ static async callBackRequestHandler(TableSchema, DBconfig, dbType, action, arg, queryId) {\n+ if (typeof (Worker) !== \"undefined\" && IndexedDBWorkerQueue.webWorkerModuleSupport) {\n+ //great, your browser supports web workers\n+ const request = IndexedDBWorkerQueue.register({\n+ params: { TableSchema, DBconfig, queryId, action, arg, dbType },\n+ queryId: queryId,\n+ method: 'execute',\n+ func: (message) => {\n+ arg.callback(message === null || message === void 0 ? void 0 : message.value);\n+ },\n+ });\n+ if (request == false) {\n+ const result = await indexedDB.requestHandler(TableSchema, DBconfig, queryId)[action](arg);\n+ arg.callback(result === null || result === void 0 ? void 0 : result.value);\n+ }\n+ }\n+ else {\n+ const result = await indexedDB.requestHandler(TableSchema, DBconfig, queryId)[action](arg);\n+ arg.callback(result === null || result === void 0 ? void 0 : result.value);\n+ }\n+ }\n }\ndiff --git a/src/plugin/src/connection/indexedDb/connector.d.ts b/src/plugin/src/connection/indexedDb/connector.d.ts\nindex 1fb933e57..2b0715571 100644\n--- a/src/plugin/src/connection/indexedDb/connector.d.ts\n+++ b/src/plugin/src/connection/indexedDb/connector.d.ts\n@@ -1,7 +1,47 @@\n import { DatabaseSchema } from '../../models/register-modal.interface.js';\n-export declare class IndexedDBConnection {\n+import { transaction } from './transaction.js';\n+export declare class IndexedDB {\n+ static transactions: {\n+ [key: string]: {\n+ [key: string]: {\n+ callback: Function;\n+ queryId: string;\n+ mode: string;\n+ config: DatabaseSchema;\n+ }[];\n+ };\n+ };\n+ static dbInstance: {\n+ [dbNmae: string]: IDBDatabase;\n+ };\n+ static dbInstanceUsing: {\n+ [dbNmae: string]: {\n+ [store: string]: boolean;\n+ };\n+ };\n+ static txInstance: {\n+ [dbNmae: string]: {\n+ [store: string]: IDBTransaction;\n+ };\n+ };\n constructor();\n static connect(config: DatabaseSchema): Promise;\n static migrate(config: DatabaseSchema): Promise;\n- private runMigrations;\n+ static run(config: any): boolean;\n+ static request({ queryId }: {\n+ queryId: any;\n+ }, callback: Function): void;\n+ private static runMigrations;\n+ static executingTransaction: {\n+ [key: string]: {\n+ [key: string]: boolean;\n+ };\n+ };\n+ static executeTransaction(currentStore: any, databaseName: any): void;\n+ static getOrCreateTransaction({ currentStore, queryId, config }: {\n+ currentStore: any;\n+ queryId: any;\n+ config: any;\n+ }, mode: any, callback: (transaction: transaction) => void): void;\n+ private static createTransaction;\n }\ndiff --git a/src/plugin/src/connection/indexedDb/connector.js b/src/plugin/src/connection/indexedDb/connector.js\nindex abc57da00..e56385aa3 100644\n--- a/src/plugin/src/connection/indexedDb/connector.js\n+++ b/src/plugin/src/connection/indexedDb/connector.js\n@@ -1,12 +1,17 @@\n+import { transaction } from './transaction.js';\n // inspire by https://github.com/hc-oss/use-indexeddb\n-export class IndexedDBConnection {\n+export class IndexedDB {\n constructor() { }\n- connect(config) {\n+ static connect(config) {\n return new Promise((resolve, reject) => {\n+ if (this.dbInstance[config.databaseName]) {\n+ resolve(this.dbInstance[config.databaseName]);\n+ }\n const idbInstance = indexedDB || self.indexedDB || self.mozIndexedDB || self.webkitIndexedDB || self.msIndexedDB;\n if (idbInstance) {\n const request = idbInstance.open(config.databaseName, config.version);\n request.onsuccess = () => {\n+ this.dbInstance[config.databaseName] = request.result;\n resolve(request.result);\n };\n request.onerror = (e) => {\n@@ -26,12 +31,13 @@ export class IndexedDBConnection {\n }\n });\n }\n- migrate(config) {\n+ static migrate(config) {\n return new Promise((resolve, reject) => {\n const idbInstance = indexedDB || self.indexedDB || self.mozIndexedDB || self.webkitIndexedDB || self.msIndexedDB;\n if (idbInstance) {\n const request = idbInstance.open(config.databaseName, config.version);\n request.onsuccess = () => {\n+ // request.result.close()\n resolve(false);\n };\n request.onerror = (e) => {\n@@ -47,9 +53,35 @@ export class IndexedDBConnection {\n else {\n reject(\"Failed to connect\");\n }\n+ // if(!this.transactions[config.databaseName]) {\n+ // this.transactions[config.databaseName] = {}\n+ // for( const storeName of config.stores) {\n+ // if(!this.transactions[config.databaseName][storeName.name]) { \n+ // this.transactions[config.databaseName][storeName.name] = []\n+ // }\n+ // }\n+ // }\n });\n }\n- async runMigrations(db, config) {\n+ static run(config) {\n+ if (!this.transactions[config.databaseName]) {\n+ this.transactions[config.databaseName] = {};\n+ this.executingTransaction[config.databaseName] = {};\n+ this.txInstance[config.databaseName] = {};\n+ this.dbInstanceUsing[config.databaseName] = {};\n+ for (const storeName of config.stores) {\n+ if (!this.transactions[config.databaseName][storeName.name]) {\n+ this.transactions[config.databaseName][storeName.name] = [];\n+ this.executingTransaction[config.databaseName][storeName.name] = false;\n+ this.txInstance[config.databaseName][storeName.name] = null;\n+ }\n+ }\n+ }\n+ return true;\n+ }\n+ static request({ queryId }, callback) {\n+ }\n+ static async runMigrations(db, config) {\n await config.stores.forEach(async (storeSchema) => {\n if (!db.objectStoreNames.contains(storeSchema.name)) {\n const ObjectStore = db.createObjectStore(storeSchema.name, storeSchema.id);\n@@ -59,4 +91,61 @@ export class IndexedDBConnection {\n }\n });\n }\n+ static executeTransaction(currentStore, databaseName) {\n+ const { mode, callback, config } = this.transactions[databaseName][currentStore].shift();\n+ const done = () => {\n+ var _a, _b;\n+ if (this.transactions[config.databaseName][currentStore].length == 0) {\n+ this.executingTransaction[databaseName][currentStore] = false;\n+ try {\n+ (_b = (_a = this.txInstance[databaseName][currentStore]) === null || _a === void 0 ? void 0 : _a.commit) === null || _b === void 0 ? void 0 : _b.call(_a);\n+ }\n+ catch (error) { }\n+ this.dbInstance[config.databaseName].close();\n+ delete this.dbInstanceUsing[config.databaseName][currentStore];\n+ if (Object.keys(this.dbInstanceUsing[config.databaseName]).length == 0) {\n+ delete this.dbInstance[config.databaseName];\n+ }\n+ }\n+ else {\n+ this.executeTransaction(currentStore, databaseName);\n+ }\n+ };\n+ const transactionInstance = new transaction({\n+ store: currentStore,\n+ done,\n+ db: this.dbInstance[config.databaseName],\n+ tx: this.txInstance[databaseName][currentStore]\n+ });\n+ // console.log('execute')\n+ callback(transactionInstance);\n+ }\n+ static getOrCreateTransaction({ currentStore, queryId, config }, mode, callback) {\n+ this.transactions[config.databaseName][currentStore].push({ config, queryId, mode, callback });\n+ if (this.executingTransaction[config.databaseName][currentStore] == false) {\n+ this.executingTransaction[config.databaseName][currentStore] = true;\n+ // console.log('start')\n+ this.connect(config).then(() => {\n+ const tx = this.createTransaction(this.dbInstance[config.databaseName], \"readwrite\", currentStore, () => { });\n+ this.txInstance[config.databaseName][currentStore] = tx;\n+ this.executeTransaction(currentStore, config.databaseName);\n+ this.dbInstanceUsing[config.databaseName][currentStore] = true;\n+ });\n+ }\n+ else {\n+ // console.log('padding '+this.transactions[config.databaseName][currentStore].length)\n+ }\n+ }\n+ static createTransaction(db, dbMode, currentStore, resolve, reject, abort) {\n+ let tx = db.transaction(currentStore, dbMode);\n+ tx.onerror = reject;\n+ tx.oncomplete = resolve;\n+ tx.onabort = abort;\n+ return tx;\n+ }\n }\n+IndexedDB.transactions = {};\n+IndexedDB.dbInstance = {};\n+IndexedDB.dbInstanceUsing = {};\n+IndexedDB.txInstance = {};\n+IndexedDB.executingTransaction = {};\n\\ No newline at end of file\ndiff --git a/src/plugin/src/connection/indexedDb/dynamicChange.js b/src/plugin/src/connection/indexedDb/dynamicChange.js\nindex 461d6a3fc..a620ee453 100644\n--- a/src/plugin/src/connection/indexedDb/dynamicChange.js\n+++ b/src/plugin/src/connection/indexedDb/dynamicChange.js\n@@ -1,8 +1,8 @@\n-import { IndexedDBConnection } from './connector';\n+import { IndexedDB } from './connector';\n export class IndexedDBConnectionDynamicChange {\n changeSchema(db, schemaChanges) {\n db.close();\n- const newDb = new IndexedDBConnection().connect({\n+ const newDb = IndexedDB.connect({\n databaseName: 'databaseName',\n type: 'indexedDB',\n version: 0\ndiff --git a/src/plugin/src/connection/indexedDb/indexedb.d.ts b/src/plugin/src/connection/indexedDb/indexedb.d.ts\nindex f8e32357a..08a3d355c 100644\n--- a/src/plugin/src/connection/indexedDb/indexedb.d.ts\n+++ b/src/plugin/src/connection/indexedDb/indexedb.d.ts\n@@ -1,18 +1,25 @@\n import { DatabaseSchema, TableSchema } from \"../../models/register-modal.interface.js\";\n import { Method } from \"../../models/model.interface.js\";\n-declare class _indexedDB {\n+declare class indexedDBInterface {\n private validateStore;\n private validateBeforeTransaction;\n private createTransaction;\n migrate(config: DatabaseSchema): Promise;\n getConnection(config: DatabaseSchema): Promise;\n- getActions: (currentStore: any, config: any) => {\n+ getActions: (currentStore: any, config: any, queryId: any) => {\n getByID: (id: string | number) => Promise;\n getOneByIndex: (keyPath: string, value: string | number) => Promise;\n getManyByIndex: (keyPath: string, value: string | number) => Promise;\n getAll: () => Promise;\n- add: (value: Object, key?: any) => Promise;\n- update: (value: any, key?: any) => Promise;\n+ add: ({ value, key, func }: {\n+ value: any;\n+ key: any;\n+ func: any;\n+ }) => void;\n+ update: ({ value, key }: {\n+ value: any;\n+ key?: any;\n+ }) => Promise;\n deleteByID: (id: any) => Promise;\n deleteAll: () => Promise;\n openCursor: (cursorCallback: any, keyRange?: IDBKeyRange) => Promise;\n@@ -29,11 +36,11 @@ declare class _indexedDB {\n queryId: any;\n value: any;\n }>;\n- insert: (methods: Method[]) => Promise<{\n+ insert: (methods: Method[]) => Promise;\n+ migrate: () => Promise<{\n queryId: any;\n- value: any;\n }>;\n };\n }\n-export declare const indexedDB: _indexedDB;\n+export declare const indexedDB: indexedDBInterface;\n export {};\ndiff --git a/src/plugin/src/connection/indexedDb/indexedb.js b/src/plugin/src/connection/indexedDb/indexedb.js\nindex 010e45a94..1e30c97ef 100644\n--- a/src/plugin/src/connection/indexedDb/indexedb.js\n+++ b/src/plugin/src/connection/indexedDb/indexedb.js\n@@ -1,39 +1,30 @@\n-import { IndexedDBConnection } from \"./connector.js\";\n+import { IndexedDB } from \"./connector.js\";\n import { SqlObject } from \"../../sql/sqlObject/sqlObject.js\";\n // inspire by https://github.com/hc-oss/use-indexeddb\n-class _indexedDB {\n+class indexedDBInterface {\n constructor() {\n- this.getActions = (currentStore, config) => {\n+ this.getActions = (currentStore, config, queryId) => {\n return {\n getByID: (id) => {\n return new Promise((resolve, reject) => {\n- this.getConnection(config)\n- .then(db => {\n- this.validateBeforeTransaction(db, currentStore, reject);\n- let tx = this.createTransaction(db, \"readonly\", currentStore, resolve, reject);\n- let objectStore = tx.objectStore(currentStore);\n- let request = objectStore.get(id);\n+ IndexedDB.getOrCreateTransaction({ currentStore, queryId, config }, 'readonly', (transaction) => {\n+ let objectStore = transaction.objectStore(currentStore);\n+ let request = objectStore.get({ id, config });\n request.onsuccess = (e) => {\n resolve(e.target.result);\n };\n- })\n- .catch(reject);\n+ });\n });\n },\n getOneByIndex: (keyPath, value) => {\n return new Promise((resolve, reject) => {\n- this.getConnection(config)\n- .then(db => {\n- this.validateBeforeTransaction(db, currentStore, reject);\n- let tx = this.createTransaction(db, \"readonly\", currentStore, resolve, reject);\n- let objectStore = tx.objectStore(currentStore);\n- let index = objectStore.index(keyPath);\n- let request = index.get(value);\n+ IndexedDB.getOrCreateTransaction({ currentStore, queryId, config }, 'readonly', (transaction) => {\n+ let objectStore = transaction.objectStore(currentStore);\n+ let request = objectStore.index({ keyPath, value, config });\n request.onsuccess = (e) => {\n resolve(e.target.result);\n };\n- })\n- .catch(reject);\n+ });\n });\n },\n getManyByIndex: (keyPath, value) => {\n@@ -54,30 +45,39 @@ class _indexedDB {\n },\n getAll: () => {\n return new Promise((resolve, reject) => {\n- this.getConnection(config).then(db => {\n- this.validateBeforeTransaction(db, currentStore, reject);\n- let tx = this.createTransaction(db, \"readonly\", currentStore, resolve, reject);\n- let objectStore = tx.objectStore(currentStore);\n- let request = objectStore.getAll();\n+ IndexedDB.getOrCreateTransaction({ currentStore, queryId, config }, 'readonly', (transaction) => {\n+ let objectStore = transaction.objectStore(currentStore);\n+ let request = objectStore.getAll(config);\n request.onsuccess = (e) => {\n+ // console.log('all', e.target.results)\n resolve(e.target.result);\n };\n- })\n- .catch(reject);\n+ });\n });\n },\n- add: (value, key) => {\n+ add: ({ value, key, func }) => {\n+ IndexedDB.getOrCreateTransaction({ currentStore, queryId, config }, 'readwrite', (transaction) => {\n+ let objectStore = transaction.objectStore(currentStore);\n+ let request = objectStore.add({ value, key, config });\n+ request.onsuccess = (e) => {\n+ func(e.target.result);\n+ };\n+ request.onerror = (e) => {\n+ // console.log(e)\n+ let data = {\n+ error: e.target['error']\n+ };\n+ func(data);\n+ };\n+ });\n+ },\n+ update: ({ value, key = undefined }) => {\n return new Promise((resolve, reject) => {\n- this.getConnection(config).then(db => {\n- this.validateBeforeTransaction(db, currentStore, reject);\n- let tx = this.createTransaction(db, \"readwrite\", currentStore, resolve, reject);\n- let objectStore = tx.objectStore(currentStore);\n- let request = objectStore.add(value, key);\n+ IndexedDB.getOrCreateTransaction({ currentStore, queryId, config }, 'readwrite', (transaction) => {\n+ let objectStore = transaction.objectStore(currentStore);\n+ let request = objectStore.put({ value, key, config });\n request.onsuccess = (e) => {\n- var _a, _b;\n- (_b = (_a = tx) === null || _a === void 0 ? void 0 : _a.commit) === null || _b === void 0 ? void 0 : _b.call(_a);\n resolve(e.target.result);\n- db.transaction;\n };\n request.onerror = (e) => {\n let data = {\n@@ -85,62 +85,35 @@ class _indexedDB {\n };\n resolve(data);\n };\n- })\n- .catch(reject);\n+ });\n });\n },\n- update: (value, key) => {\n+ deleteByID: (id) => {\n return new Promise((resolve, reject) => {\n- this.getConnection(config).then(db => {\n- this.validateBeforeTransaction(db, currentStore, reject);\n- let tx = this.createTransaction(db, \"readwrite\", currentStore, resolve, reject);\n- let objectStore = tx.objectStore(currentStore);\n- let request = objectStore.put(value, key);\n+ IndexedDB.getOrCreateTransaction({ currentStore, queryId, config }, 'readwrite', (transaction) => {\n+ let objectStore = transaction.objectStore(currentStore);\n+ let request = objectStore.delete({ id, config });\n request.onsuccess = (e) => {\n- var _a, _b;\n- (_b = (_a = tx) === null || _a === void 0 ? void 0 : _a.commit) === null || _b === void 0 ? void 0 : _b.call(_a);\n resolve(e.target.result);\n };\n- })\n- .catch(reject);\n- });\n- },\n- deleteByID: (id) => {\n- return new Promise((resolve, reject) => {\n- this.getConnection(config).then(db => {\n- this.validateBeforeTransaction(db, currentStore, reject);\n- let tx = this.createTransaction(db, \"readwrite\", currentStore, resolve, reject);\n- let objectStore = tx.objectStore(currentStore);\n- let request = objectStore.delete(id);\n- request.onsuccess = (e) => {\n- var _a, _b;\n- (_b = (_a = tx) === null || _a === void 0 ? void 0 : _a.commit) === null || _b === void 0 ? void 0 : _b.call(_a);\n- resolve(e);\n+ request.onerror = (e) => {\n+ let data = {\n+ error: e.target['error']\n+ };\n+ resolve(data);\n };\n- })\n- .catch(reject);\n+ });\n });\n },\n deleteAll: () => {\n return new Promise((resolve, reject) => {\n- this.getConnection(config)\n- .then(db => {\n- this.validateBeforeTransaction(db, currentStore, reject);\n- let tx = this.createTransaction(db, \"readwrite\", currentStore, resolve, reject);\n- let objectStore = tx.objectStore(currentStore);\n- objectStore.clear();\n- tx.oncomplete = (e) => {\n- var _a, _b;\n- try {\n- (_b = (_a = tx) === null || _a === void 0 ? void 0 : _a.commit) === null || _b === void 0 ? void 0 : _b.call(_a);\n- resolve(e);\n- }\n- catch (error) {\n- resolve(e);\n- }\n+ IndexedDB.getOrCreateTransaction({ currentStore, queryId, config }, 'readwrite', (transaction) => {\n+ let objectStore = transaction.objectStore(currentStore);\n+ let request = objectStore.clear({ config });\n+ request.onsuccess = (e) => {\n+ resolve(e.target.result);\n };\n- })\n- .catch(reject);\n+ });\n });\n },\n openCursor: (cursorCallback, keyRange) => {\n@@ -154,7 +127,7 @@ class _indexedDB {\n request.onsuccess = e => {\n cursorCallback(e);\n resolve();\n- // db.close();\n+ db.close();\n };\n })\n .catch(reject);\n@@ -168,7 +141,7 @@ class _indexedDB {\n if (methods[0].methodName == 'all') {\n return {\n queryId: queryId,\n- value: await this.getActions(TableSchema.name, config).getAll()\n+ value: await this.getActions(TableSchema.name, config, queryId).getAll()\n };\n }\n else if (methods[0].methodName == 'get') {\n@@ -179,13 +152,13 @@ class _indexedDB {\n if (TableSchema.id.keyPath == key) {\n return {\n queryId: queryId,\n- value: await this.getActions(TableSchema.name, config).getByID(value)\n+ value: await this.getActions(TableSchema.name, config, queryId).getByID(value)\n };\n }\n else {\n return {\n queryId: queryId,\n- value: await this.getActions(TableSchema.name, config).getOneByIndex(key, value)\n+ value: await this.getActions(TableSchema.name, config, queryId).getOneByIndex(key, value)\n };\n }\n }\n@@ -193,28 +166,30 @@ class _indexedDB {\n else if (methods[methods.length - 1].methodName == 'execute') {\n return new Promise(async (resolve, reject) => {\n const sqlObject = new SqlObject(TableSchema, methods);\n- await this.getActions(TableSchema.name, config).openCursor(async (event) => {\n- var cursor = event.target.result;\n- if (cursor) {\n- const row = cursor.value;\n- await sqlObject.runFirstMethod(row);\n- cursor.continue();\n- }\n- else {\n- sqlObject.doneRunFirstMethod();\n- sqlObject.run();\n- resolve({\n- queryId: queryId,\n- value: sqlObject.firstMethod.rows\n- });\n- }\n+ //await this.getActions(TableSchema.name, config, queryId).openCursor(async(event: any) => {\n+ //var cursor = event.target.result;\n+ //if(cursor) {\n+ const rows = await this.getActions(TableSchema.name, config, queryId).getAll();\n+ for (const row of rows) {\n+ //const row = cursor.value\n+ await sqlObject.runFirstMethod(row);\n+ //cursor.continue();\n+ }\n+ //} else {\n+ sqlObject.doneRunFirstMethod();\n+ sqlObject.run();\n+ resolve({\n+ queryId: queryId,\n+ value: sqlObject.firstMethod.rows\n });\n+ //}\n+ //})\n });\n }\n else if (methods[methods.length - 1].methodName == 'first') {\n return new Promise(async (resolve, reject) => {\n const sqlObject = new SqlObject(TableSchema, methods);\n- await this.getActions(TableSchema.name, config).openCursor(async (event) => {\n+ await this.getActions(TableSchema.name, config, queryId).openCursor(async (event) => {\n var cursor = event.target.result;\n if (cursor) {\n const row = cursor.value;\n@@ -239,10 +214,10 @@ class _indexedDB {\n const idFieldName = TableSchema.id.keyPath;\n const idValue = args[idFieldName];\n if (idValue) {\n- await this.getActions(TableSchema.name, config).update(args);\n+ await this.getActions(TableSchema.name, config, queryId).update({ value: args });\n }\n else {\n- await this.getActions(TableSchema.name, config).update(args, idValue);\n+ await this.getActions(TableSchema.name, config, queryId).update({ value: args, key: idValue });\n }\n return {\n queryId\n@@ -256,7 +231,7 @@ class _indexedDB {\n const rows = result.value;\n for (let row of rows) {\n const updateRow = Object.assign(row, argsToUpdate);\n- await this.getActions(TableSchema.name, config).update(updateRow);\n+ await this.getActions(TableSchema.name, config, queryId).update({ value: updateRow });\n }\n return {\n queryId\n@@ -268,10 +243,10 @@ class _indexedDB {\n //await this.getActions(TableSchema.name, config).update(argsToUpdate)\n const idValue = argsToUpdate[idFieldName];\n if (idValue) {\n- await this.getActions(TableSchema.name, config).update(argsToUpdate);\n+ await this.getActions(TableSchema.name, config, queryId).update({ value: argsToUpdate });\n }\n else {\n- await this.getActions(TableSchema.name, config).update(argsToUpdate, idValue);\n+ await this.getActions(TableSchema.name, config, queryId).update({ value: argsToUpdate, key: idValue });\n }\n return {\n queryId\n@@ -287,7 +262,7 @@ class _indexedDB {\n const rows = result.value;\n for (let row of rows) {\n const id = row[TableSchema.id.keyPath];\n- await this.getActions(TableSchema.name, config).deleteByID(id);\n+ await this.getActions(TableSchema.name, config, queryId).deleteByID(id);\n }\n return {\n queryId\n@@ -299,37 +274,36 @@ class _indexedDB {\n const idValue = IdInObject[TableSchema.id.keyPath];\n return {\n queryId: queryId,\n- value: await this.getActions(TableSchema.name, config).deleteByID(idValue)\n+ value: await this.getActions(TableSchema.name, config, queryId).deleteByID(idValue)\n };\n }\n else if (methods[methods.length - 1].methodName == 'delete' &&\n methods[methods.length - 1].arguments == '*') {\n return {\n queryId: queryId,\n- value: await this.getActions(TableSchema.name, config).deleteAll()\n+ value: await this.getActions(TableSchema.name, config, queryId).deleteAll()\n };\n }\n },\n insert: async (methods) => {\n- const createdObjKeys = [];\n- const rows = methods[0].arguments;\n- for (let insert of rows) {\n- const id = await this.getActions(TableSchema.name, config).add(insert);\n- insert[TableSchema.id.keyPath] = id;\n- }\n- // return first element\n- if (rows.length == 1) {\n- return {\n- queryId: queryId,\n- value: rows[0]\n- };\n- }\n- else {\n- return {\n- queryId: queryId,\n- value: rows\n- };\n- }\n+ return new Promise((resolve, reject) => {\n+ const rows = methods[0].arguments;\n+ for (let insert of rows) {\n+ this.getActions(TableSchema.name, config, queryId).add({ value: insert, key: null, func: (id) => {\n+ insert[TableSchema.id.keyPath] = id;\n+ resolve({\n+ queryId: queryId,\n+ value: insert\n+ });\n+ } });\n+ }\n+ });\n+ },\n+ migrate: async () => {\n+ await IndexedDB.run(config);\n+ return {\n+ queryId: queryId\n+ };\n }\n };\n };\n@@ -353,10 +327,10 @@ class _indexedDB {\n return tx;\n }\n migrate(config) {\n- return new IndexedDBConnection().migrate(config);\n+ return IndexedDB.migrate(config);\n }\n getConnection(config) {\n- return new IndexedDBConnection().connect(config);\n+ return IndexedDB.connect(config);\n }\n }\n-export const indexedDB = new _indexedDB();\n+export const indexedDB = new indexedDBInterface();\ndiff --git a/src/plugin/src/connection/intreface.d.ts b/src/plugin/src/connection/intreface.d.ts\nindex 5d31fbfcc..25f0f8ec3 100644\n--- a/src/plugin/src/connection/intreface.d.ts\n+++ b/src/plugin/src/connection/intreface.d.ts\n@@ -1,2 +1,2 @@\n-export declare type actionParam = 'insert' | 'update' | 'delete' | 'select';\n+export declare type actionParam = 'insert' | 'update' | 'delete' | 'select' | 'migrate' | 'trigger';\n export declare type dbType = 'indexedDB' | 'localStorage';\ndiff --git a/src/plugin/src/connection/worker.js b/src/plugin/src/connection/worker.js\nindex 174c12cc3..0390c8962 100644\n--- a/src/plugin/src/connection/worker.js\n+++ b/src/plugin/src/connection/worker.js\n@@ -11,7 +11,7 @@ onmessage = async (oEvent) => {\n value: undefined\n });\n }\n- }).catch((result)=> {\n+ }).catch((result) => {\n try {\n postMessage(result);\n }\n@@ -21,6 +21,5 @@ onmessage = async (oEvent) => {\n value: undefined\n });\n }\n- })\n-\n+ });\n };\ndiff --git a/src/plugin/src/connection/worker.queue.d.ts b/src/plugin/src/connection/worker.queue.d.ts\nindex 4e4898c29..6ccb3060c 100644\n--- a/src/plugin/src/connection/worker.queue.d.ts\n+++ b/src/plugin/src/connection/worker.queue.d.ts\n@@ -1,7 +1,7 @@\n interface WsRegister {\n type?: 'response' | 'Register';\n func: Function;\n- queryId?: string;\n+ queryId: string;\n params: any;\n method: 'execute' | 'migrate';\n }\n@@ -13,7 +13,7 @@ export declare class _IndexedDBWorkerQueue {\n private workerQueues;\n register(data: WsRegister): string | false;\n onmessage(data: any): Promise;\n- requestHandler(): void;\n+ finish(queryId: any): void;\n }\n export declare const IndexedDBWorkerQueue: _IndexedDBWorkerQueue;\n export {};\ndiff --git a/src/plugin/src/connection/worker.queue.js b/src/plugin/src/connection/worker.queue.js\nindex e9a3f67c3..e1b50159b 100644\n--- a/src/plugin/src/connection/worker.queue.js\n+++ b/src/plugin/src/connection/worker.queue.js\n@@ -10,7 +10,7 @@ export class _IndexedDBWorkerQueue {\n this.onmessage(data);\n };\n this.myWorker.onerror = (error) => {\n- console.log(error, 'erroror');\n+ console.log('myWorker', error);\n };\n }\n }\n@@ -38,14 +38,14 @@ export class _IndexedDBWorkerQueue {\n }\n }\n async onmessage(data) {\n- for (const [key, value] of Object.entries(this.workerQueues)) {\n- const dontRepeat = await value.func(data);\n- if (dontRepeat || !data.queryId) {\n- delete this.workerQueues[key];\n- }\n- }\n+ const value = this.workerQueues[data.queryId];\n+ await value.func(data);\n }\n- requestHandler() {\n+ finish(queryId) {\n+ try {\n+ delete this.workerQueues[queryId];\n+ }\n+ catch (error) { }\n }\n }\n export const IndexedDBWorkerQueue = new _IndexedDBWorkerQueue();\ndiff --git a/src/plugin/src/models/mode-migrations.js b/src/plugin/src/models/mode-migrations.js\nindex fd236f610..8c550e061 100644\n--- a/src/plugin/src/models/mode-migrations.js\n+++ b/src/plugin/src/models/mode-migrations.js\n@@ -8,7 +8,6 @@ export class _ModelMigrations {\n if (this.isMigrationsReady) {\n this.callback.forEach((item, index, object) => {\n item();\n- object.splice(index, 1);\n });\n }\n }\ndiff --git a/src/plugin/src/models/model-manager.d.ts b/src/plugin/src/models/model-manager.d.ts\nindex c778c6040..a10e28e1b 100644\n--- a/src/plugin/src/models/model-manager.d.ts\n+++ b/src/plugin/src/models/model-manager.d.ts\n@@ -10,5 +10,7 @@ export declare class ModelManager {\n update: (arg: any, queryId: string) => Promise;\n delete: (arg: any, queryId: string) => Promise;\n all: (arg: any, queryId: string) => Promise;\n+ migrate: (queryId?: string) => Promise;\n+ trigger: (args: any, Subscription: any) => Promise;\n };\n }\ndiff --git a/src/plugin/src/models/model-manager.js b/src/plugin/src/models/model-manager.js\nindex a1884ee7d..1c0386594 100644\n--- a/src/plugin/src/models/model-manager.js\n+++ b/src/plugin/src/models/model-manager.js\n@@ -1,6 +1,7 @@\n var _a;\n import { DBSwitch } from '../connection/dbSwtich.js';\n import { ModelMigrations } from './mode-migrations.js';\n+import { uniqueGenerator } from '../utils.js';\n export class ModelManager {\n constructor() { }\n }\n@@ -35,5 +36,10 @@ ModelManager.obj = (DatabaseSchema, TableSchema) => {\n await ModelMigrations.waitMigration();\n return await DBSwitch.requestHandler(TableSchema, DatabaseSchema, DatabaseSchema.type, 'select', arg, queryId);\n },\n+ migrate: async (queryId = uniqueGenerator()) => {\n+ return await DBSwitch.requestHandler(TableSchema, DatabaseSchema, DatabaseSchema.type, 'migrate', {}, queryId);\n+ }, trigger: async (args, Subscription) => {\n+ DBSwitch.callBackRequestHandler(TableSchema, DatabaseSchema, DatabaseSchema.type, 'trigger', args, Subscription);\n+ }\n };\n };\ndiff --git a/src/plugin/src/models/model.d.ts b/src/plugin/src/models/model.d.ts\nindex 1574ec608..99b7da85f 100644\n--- a/src/plugin/src/models/model.d.ts\n+++ b/src/plugin/src/models/model.d.ts\n@@ -35,7 +35,7 @@ export declare class Model extends ModelManager {\n static updateOrCreate(argToFind: any, argsToUpdate: any): Promise;\n static update(arg: any): Promise;\n static object: ({ queryId, DBconfig, TableSchema, some }: {\n- queryId?: string;\n+ queryId: any;\n DBconfig: any;\n TableSchema: any;\n some?: any;\ndiff --git a/src/plugin/src/models/model.js b/src/plugin/src/models/model.js\nindex 9ed0a8a30..0290a32d2 100644\n--- a/src/plugin/src/models/model.js\n+++ b/src/plugin/src/models/model.js\n@@ -4,6 +4,7 @@ import { ModelManager } from './model-manager.js';\n import { models, modelsConfig, modelsConfigLocalStorage } from './register-model.js';\n import { FieldType } from '../sql/query/interface.js';\n import * as Fields from './field/allFields.js';\n+import { IndexedDBWorkerQueue } from '../connection/worker.queue.js';\n let methods = {} = {};\n // inspire by https://github.com/brianschardt/browser-orm\n export class Model extends (_b = ModelManager) {\n@@ -45,6 +46,7 @@ export class Model extends (_b = ModelManager) {\n const methods = [{ methodName: 'save', arguments: Fields }];\n const queryId = uniqueGenerator();\n await Model.obj(DBconfig, tableSchema).save(methods, queryId);\n+ IndexedDBWorkerQueue.finish(queryId);\n }\n async delete() {\n const DBconfig = this.getDBSchema();\n@@ -55,6 +57,7 @@ export class Model extends (_b = ModelManager) {\n const _methods = [{ methodName: 'delete', arguments: createArg }];\n const queryId = uniqueGenerator();\n await Model.obj(DBconfig, TableSchema).delete(_methods, queryId);\n+ IndexedDBWorkerQueue.finish(queryId);\n }\n static async deleteAll() {\n const DBconfig = this.getDBSchema();\n@@ -65,11 +68,15 @@ export class Model extends (_b = ModelManager) {\n const _methods = [{ methodName: 'delete', arguments: '*' }];\n const queryId = uniqueGenerator();\n await Model.obj(DBconfig, TableSchema).delete(_methods, queryId);\n+ IndexedDBWorkerQueue.finish(queryId);\n }\n async all() {\n const DBconfig = this.getDBSchema();\n const TableSchema = this.getTableSchema();\n- return await Model.object({ DBconfig, TableSchema }).all();\n+ const queryId = uniqueGenerator();\n+ const result = await Model.object({ queryId, DBconfig, TableSchema }).all();\n+ IndexedDBWorkerQueue.finish(queryId);\n+ return result;\n }\n getFields(arg) {\n return Model.getFields(arg);\n@@ -113,9 +120,13 @@ export class Model extends (_b = ModelManager) {\n }\n }\n static async all() {\n+ // console.log('trigger get')\n const DBconfig = this.getDBSchema();\n const TableSchema = this.getTableSchema();\n- return await Model.object({ DBconfig, TableSchema }).all();\n+ const queryId = uniqueGenerator();\n+ const result = await Model.object({ queryId, DBconfig, TableSchema }).all();\n+ IndexedDBWorkerQueue.finish(queryId);\n+ return result;\n }\n static async get(arg) {\n const _methods = [{ methodName: 'get', arguments: arg }];\n@@ -123,6 +134,7 @@ export class Model extends (_b = ModelManager) {\n const TableSchema = this.getTableSchema();\n const queryId = uniqueGenerator();\n const foundObj = await super.obj(DBconfig, TableSchema).get(_methods, queryId);\n+ IndexedDBWorkerQueue.finish(queryId);\n if (!foundObj) {\n return false;\n }\n@@ -152,7 +164,9 @@ export class Model extends (_b = ModelManager) {\n const DBconfig = this.getDBSchema();\n const TableSchema = this.getTableSchema();\n const newInstanceModel = this.NewModelInstance();\n- return Object.assign(newInstanceModel, this.object({ queryId, DBconfig, TableSchema, some: ['filter', arg] }));\n+ const result = Object.assign(newInstanceModel, this.object({ queryId, DBconfig, TableSchema, some: ['filter', arg] }));\n+ IndexedDBWorkerQueue.finish(queryId);\n+ return result;\n }\n static NewModelInstance() {\n class newInstanceModel {\n@@ -194,6 +208,7 @@ export class Model extends (_b = ModelManager) {\n }\n const emptyFields = await this.getEmptyFields();\n const TableSchema = this.getTableSchema();\n+ const ModelName = TableSchema.name;\n for (let i in arg) {\n arg[i] = Object.assign(Object.assign({}, emptyFields), this.getFields(arg[i]));\n if (!this.formValidation(arg[i])) {\n@@ -213,25 +228,49 @@ export class Model extends (_b = ModelManager) {\n const _methods = [{ methodName: 'create', arguments: arg }];\n const DBconfig = this.getDBSchema();\n const queryId = uniqueGenerator();\n- const createObject = await super.obj(DBconfig, TableSchema).create(_methods, queryId);\n+ const createObjectRequest = super.obj(DBconfig, TableSchema).create(_methods, queryId);\n+ for (let i in arg) {\n+ let newInstance = new models[ModelName]();\n+ Object.assign(newInstance, arg[i]);\n+ delete newInstance.obj;\n+ delete newInstance[TableSchema.id.keyPath];\n+ if (TableSchema.fieldTypes.ManyToManyField) {\n+ for (let field of TableSchema.fieldTypes.ManyToManyField) {\n+ // console.log(ModelName, field)\n+ newInstance[field] = null;\n+ }\n+ }\n+ if (TableSchema.fieldTypes.OneToOneField) {\n+ for (let field of TableSchema.fieldTypes.ManyToManyField) {\n+ // console.log(ModelName, field)\n+ newInstance[field] = null;\n+ }\n+ }\n+ arg[i] = newInstance;\n+ }\n+ const createObject = await createObjectRequest;\n+ IndexedDBWorkerQueue.finish(queryId);\n if (createObject) {\n if (typeof createObject[TableSchema.id.keyPath] == 'object') {\n throw (createObject[TableSchema.id.keyPath].error);\n }\n else {\n- const ModelName = this.getModelName();\n- let newInstance = new models[ModelName]();\n- Object.assign(newInstance, createObject);\n- delete newInstance.obj;\n- return newInstance;\n+ if (Array.isArray(createObject)) {\n+ for (let a in createObject) {\n+ arg[a][TableSchema.id.keyPath] = createObject[a][TableSchema.id.keyPath];\n+ }\n+ return arg;\n+ }\n+ else {\n+ arg[0][TableSchema.id.keyPath] = createObject[TableSchema.id.keyPath];\n+ return arg[0];\n+ }\n }\n }\n- else {\n- }\n }\n static newInstance({ TableSchema, DBconfig, ModelName, dataToMerge }) {\n let newInstance = new models[ModelName]();\n- Object.assign(newInstance, Object.assign({}, dataToMerge));\n+ Object.assign(newInstance, dataToMerge);\n delete newInstance.obj;\n return newInstance;\n }\n@@ -267,11 +306,13 @@ export class Model extends (_b = ModelManager) {\n const TableSchema = this.getTableSchema();\n const _methods = [{ methodName: 'update', arguments: arg }];\n const queryId = uniqueGenerator();\n- return await super.obj(DBconfig, TableSchema).update(_methods, queryId);\n+ const result = await super.obj(DBconfig, TableSchema).update(_methods, queryId);\n+ IndexedDBWorkerQueue.finish(queryId);\n+ return result;\n }\n }\n _a = Model;\n-Model.object = ({ queryId = uniqueGenerator(), DBconfig, TableSchema, some = null }) => {\n+Model.object = ({ queryId, DBconfig, TableSchema, some = null }) => {\n if (!methods[queryId]) {\n methods[queryId] = [];\n }\n@@ -305,6 +346,7 @@ Model.object = ({ queryId = uniqueGenerator(), DBconfig, TableSchema, some = nul\n return await Reflect.get(_b, \"obj\", _a).call(_a, DBconfig, TableSchema).delete(_methods, queryId);\n },\n all: async () => {\n+ // console.log('model all')\n methods[queryId].push({ methodName: 'all', arguments: null });\n const _methods = methods[queryId];\n methods[queryId] = [];\ndiff --git a/src/plugin/src/models/register-model.js b/src/plugin/src/models/register-model.js\nindex 4281870bb..37ec93cf3 100644\n--- a/src/plugin/src/models/register-model.js\n+++ b/src/plugin/src/models/register-model.js\n@@ -5,6 +5,7 @@ import { OneToOneField, ForeignKey, ManyToManyField } from './field/allFields.js\n import { uncapitalize } from '../utils.js';\n import { FieldType } from '../sql/query/interface.js';\n import { ModelMigrations } from './mode-migrations.js';\n+import { ModelManager } from './model-manager.js';\n export const models = {};\n export const modelsConfig = {};\n export const modelsLocalStorage = {};\n@@ -71,19 +72,23 @@ export class registerModel {\n }\n index++;\n }\n+ let tableSchema_;\n for (const modelClassRepresentations of entries.models) {\n const ModelName = modelClassRepresentations.getModelName();\n models[ModelName] = modelClassRepresentations;\n const tableSchema = databaseSchema.stores.find((e) => e.name == ModelName);\n+ tableSchema_ = tableSchema;\n modelsConfig[ModelName] = {\n DatabaseSchema: databaseSchema,\n TableSchema: tableSchema\n };\n }\n if (databaseSchema.type == 'indexedDB') {\n+ // console.log(JSON.stringify(databaseSchema))\n await indexedDB.migrate(databaseSchema);\n+ ModelMigrations.migrationsState(true);\n+ await ModelManager.obj(databaseSchema, tableSchema_).migrate();\n }\n- ModelMigrations.migrationsState(true);\n }\n static manyToManyRelationShip(foreignKeyField, FieldName, modelName, databaseSchema) {\n const foreignKeyFieldModel = foreignKeyField.model;",
- "changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts\n\nChanges not staged for commit:\n (use \"git add ...\" to update what will be committed)\n (use \"git restore ...\" to discard changes in working directory)\n\tmodified: src/app/models/beast-orm.ts\n\tmodified: src/plugin/src/connection/dbSwtich.d.ts\n\tmodified: src/plugin/src/connection/dbSwtich.js\n\tmodified: src/plugin/src/connection/indexedDb/connector.d.ts\n\tmodified: src/plugin/src/connection/indexedDb/connector.js\n\tmodified: src/plugin/src/connection/indexedDb/dynamicChange.js\n\tmodified: src/plugin/src/connection/indexedDb/indexedb.d.ts\n\tmodified: src/plugin/src/connection/indexedDb/indexedb.js\n\tmodified: src/plugin/src/connection/intreface.d.ts\n\tmodified: src/plugin/src/connection/worker.js\n\tmodified: src/plugin/src/connection/worker.queue.d.ts\n\tmodified: src/plugin/src/connection/worker.queue.js\n\tmodified: src/plugin/src/models/mode-migrations.js\n\tmodified: src/plugin/src/models/model-manager.d.ts\n\tmodified: src/plugin/src/models/model-manager.js\n\tmodified: src/plugin/src/models/model.d.ts\n\tmodified: src/plugin/src/models/model.js\n\tmodified: src/plugin/src/models/register-model.js",
+ "lastCommitTime": "'Thu Feb 23 18:06:46 2023 +0100'",
+ "lastCommitMessage": "debugging",
+ "lastCommitNumber": "4827",
+ "change": "",
+ "changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/app.component.ts\n\tmodified: src/app/pages/agenda/new-event/new-event.page.ts\n\tmodified: src/app/pages/chat/chat.page.ts\n\tmodified: src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.ts\n\tmodified: src/app/pages/publications/publication-detail/publication-detail.page.html\n\tmodified: src/app/pages/publications/view-publications/publication-detail/publication-detail.page.html\n\tmodified: src/app/pages/publications/view-publications/view-publications.page.html\n\tmodified: src/app/services/chat/message.service.ts\n\tmodified: src/app/shared/gabinete-digital/all-processes/all-processes.page.ts\n\tmodified: src/app/shared/header/header.page.html\n\tmodified: src/app/shared/popover/despachos-options/despachos-options.page.ts\n\tmodified: src/app/shared/publication/new-publication/new-publication.page.ts\n\tmodified: src/app/shared/publication/view-publications/publication-detail/publication-detail.page.html\n\tmodified: src/app/shared/publication/view-publications/view-publications.page.html\n\tmodified: src/app/store/deplomas.service.ts\n\tmodified: src/app/store/despacho-store.service.ts\n\tmodified: src/app/store/despachospr-store.service.ts\n\tmodified: src/app/store/eventoaprovacao-store.service.ts\n\tmodified: src/app/store/expedientegd-store.service.ts\n\tmodified: src/app/store/pedidos-store.service.ts\n\tmodified: src/app/store/pendestes-store.service.ts\n\tmodified: src/app/store/presidential-actions-store.service.ts\n\tmodified: src/app/store/to-day-event-storage.service.ts\n\tdeleted: src/plugin/src/connection/dbSwtich.d.ts\n\tdeleted: src/plugin/src/connection/dbSwtich.js\n\tdeleted: src/plugin/src/connection/indexedDb/connector.d.ts\n\tdeleted: src/plugin/src/connection/indexedDb/connector.js\n\tdeleted: src/plugin/src/connection/indexedDb/dynamicChange.d.ts\n\tdeleted: src/plugin/src/connection/indexedDb/dynamicChange.js\n\tdeleted: src/plugin/src/connection/indexedDb/indexedb.d.ts\n\tdeleted: src/plugin/src/connection/indexedDb/indexedb.js\n\tdeleted: src/plugin/src/connection/intreface.d.ts\n\tdeleted: src/plugin/src/connection/intreface.js\n\tdeleted: src/plugin/src/connection/worker.d.ts\n\tdeleted: src/plugin/src/connection/worker.js\n\tdeleted: src/plugin/src/connection/worker.queue.d.ts\n\tdeleted: src/plugin/src/connection/worker.queue.js\n\tdeleted: src/plugin/src/index.d.ts\n\tdeleted: src/plugin/src/index.js\n\tdeleted: src/plugin/src/models/field/allFields.d.ts\n\tdeleted: src/plugin/src/models/field/allFields.js\n\tdeleted: src/plugin/src/models/field/field.d.ts\n\tdeleted: src/plugin/src/models/field/field.js\n\tdeleted: src/plugin/src/models/field/fields.d.ts\n\tdeleted: src/plugin/src/models/field/fields.interface.d.ts\n\tdeleted: src/plugin/src/models/field/fields.interface.js\n\tdeleted: src/plugin/src/models/field/fields.js\n\tdeleted: src/plugin/src/models/field/interface.d.ts\n\tdeleted: src/plugin/src/models/field/interface.js\n\tdeleted: src/plugin/src/models/mode-migrations.d.ts\n\tdeleted: src/plugin/src/models/mode-migrations.js\n\tdeleted: src/plugin/src/models/model-from.d.ts\n\tdeleted: src/plugin/src/models/model-from.js\n\tdeleted: src/plugin/src/models/model-manager.d.ts\n\tdeleted: src/plugin/src/models/model-manager.js\n\tdeleted: src/plugin/src/models/model.d.ts\n\tdeleted: src/plugin/src/models/model.interface.d.ts\n\tdeleted: src/plugin/src/models/model.interface.js\n\tdeleted: src/plugin/src/models/model.js\n\tdeleted: src/plugin/src/models/model.reader.d.ts\n\tdeleted: src/plugin/src/models/model.reader.js\n\tdeleted: src/plugin/src/models/register-model.d.ts\n\tdeleted: src/plugin/src/models/register-model.js\n\tdeleted: src/plugin/src/sql/Operators/Object-condition-operator.d.ts\n\tdeleted: src/plugin/src/sql/Operators/Object-condition-operator.js\n\tdeleted: src/plugin/src/sql/Operators/args-attributes.d.ts\n\tdeleted: src/plugin/src/sql/Operators/args-attributes.js\n\tdeleted: src/plugin/src/sql/Operators/object-operator.d.ts\n\tdeleted: src/plugin/src/sql/Operators/object-operator.js\n\tdeleted: src/plugin/src/sql/Operators/operators.d.ts\n\tdeleted: src/plugin/src/sql/Operators/operators.js\n\tdeleted: src/plugin/src/sql/Operators/query-bulder.d.ts\n\tdeleted: src/plugin/src/sql/Operators/query-bulder.js\n\tdeleted: src/plugin/src/sql/methods/filter.d.ts\n\tdeleted: src/plugin/src/sql/methods/filter.js\n\tdeleted: src/plugin/src/sql/methods/methods.d.ts\n\tdeleted: src/plugin/src/sql/methods/methods.js\n\tdeleted: src/plugin/src/sql/query/interface.d.ts\n\tdeleted: src/plugin/src/sql/query/interface.js\n\tdeleted: src/plugin/src/sql/sqlObject/sql.d.ts\n\tdeleted: src/plugin/src/sql/sqlObject/sql.js\n\tdeleted: src/plugin/src/sql/sqlObject/sqlObject.d.ts\n\tdeleted: src/plugin/src/sql/sqlObject/sqlObject.js\n\tdeleted: src/plugin/src/utils.d.ts\n\tdeleted: src/plugin/src/utils.js",
"changeAuthor": "peter.maquiran"
}
\ No newline at end of file