@tiddlywiki/mws 0.1.13 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -20
- package/dist/metafile-esm.json +1 -1
- package/dist/mws.js +40249 -20249
- package/dist/mws.js.map +1 -1
- package/mws.run.mjs +28 -8
- package/package.json +20 -33
- package/plugins/client/plugin.info +1 -1
- package/plugins/client/src/multiwikiclientadaptor.ts +11 -39
- package/plugins/client/src/mws.d.ts +2 -1
- package/plugins/client/src/new-multiwikiclientadaptor.ts +634 -0
- package/plugins/client/src/types.d.ts +2531 -1036
- package/plugins/client/tiddlers/managetiddleraction.js +0 -5
- package/plugins/client/tiddlers/syncer/multiwikiclientadaptor.js +1 -1
- package/plugins/client/tiddlers/syncer/new-multiwikiclientadaptor.js +432 -0
- package/plugins/client/tiddlers/syncer/syncer.js +123 -241
- package/plugins/client/tsconfig.json +5 -1
- package/prisma/browser.ts +2 -0
- package/prisma/client/browser.ts +84 -0
- package/prisma/client/client.ts +108 -0
- package/prisma/client/commonInputTypes.ts +598 -0
- package/prisma/client/enums.ts +42 -0
- package/prisma/client/internal/class.ts +326 -0
- package/prisma/client/internal/prismaNamespace.ts +1870 -0
- package/prisma/client/internal/prismaNamespaceBrowser.ts +259 -0
- package/prisma/client/models/Bag.ts +1701 -0
- package/prisma/client/models/BagPermission.ts +1284 -0
- package/prisma/client/models/Recipe.ts +1722 -0
- package/prisma/client/models/RecipeBag.ts +1518 -0
- package/prisma/client/models/RecipePermission.ts +1284 -0
- package/prisma/client/models/Roles.ts +1316 -0
- package/prisma/client/models/Sessions.ts +1344 -0
- package/prisma/client/models/Settings.ts +1093 -0
- package/prisma/client/models/Template.ts +1477 -0
- package/prisma/client/models/TemplatePermission.ts +1284 -0
- package/prisma/client/models/Tiddler.ts +1434 -0
- package/prisma/client/models/TiddlerEvent.ts +1360 -0
- package/prisma/client/models/Users.ts +1579 -0
- package/prisma/client/models.ts +24 -0
- package/prisma/client/pjtg.ts +183 -0
- package/prisma/index.ts +74 -0
- package/prisma/migrations/20260708160259_init/migration.sql +172 -0
- package/prisma/migrations-v1/migration_lock.toml +3 -0
- package/prisma/package.json +12 -0
- package/prisma/schema.prisma +147 -89
- package/prisma/types.ts +9 -0
- package/public/.default.html +1 -0
- package/public/admin-vanilla/fish.svg +399 -0
- package/public/admin-vanilla/fish2.svg +389 -0
- package/public/admin-vanilla/main-64WYHWYI.js +1791 -0
- package/public/admin-vanilla/main-64WYHWYI.js.map +7 -0
- package/public/admin-vanilla/main-LYDE4NDJ.css +1 -0
- package/public/admin-vanilla/normalize.css +349 -0
- package/public/admin-vanilla/polyfill-ADOI2A4V.js +2 -0
- package/public/admin-vanilla/polyfill-ADOI2A4V.js.map +7 -0
- package/public/{react-admin → admin-vanilla}/site.webmanifest +1 -1
- package/public/admin-vanilla.html +62 -0
- package/public/admin-vanilla.json +1 -0
- package/public/{react-admin → stats}/stats.html +5 -2
- package/public/{react-admin → stats}/stats.js +2 -1
- package/scripts/build-docs.sh +30 -0
- package/scripts/helpers.mjs +107 -0
- package/scripts/json.js +8 -0
- package/scripts/scripts.mjs +114 -0
- package/prisma/client/client.d.ts +0 -1
- package/prisma/client/client.js +0 -3
- package/prisma/client/default.d.ts +0 -1
- package/prisma/client/default.js +0 -3
- package/prisma/client/edge.d.ts +0 -1
- package/prisma/client/edge.js +0 -297
- package/prisma/client/index-browser.js +0 -275
- package/prisma/client/index.d.ts +0 -17770
- package/prisma/client/index.js +0 -324
- package/prisma/client/package.json +0 -173
- package/prisma/client/query_engine_bg.js +0 -811
- package/prisma/client/query_engine_bg.wasm +0 -0
- package/prisma/client/runtime/edge-esm.js +0 -10000
- package/prisma/client/runtime/edge.js +0 -10036
- package/prisma/client/runtime/index-browser.d.ts +0 -370
- package/prisma/client/runtime/index-browser.js +0 -2300
- package/prisma/client/runtime/library.d.ts +0 -3681
- package/prisma/client/runtime/library.js +0 -10604
- package/prisma/client/runtime/react-native.js +0 -10629
- package/prisma/client/runtime/wasm-compiler-edge.js +0 -11238
- package/prisma/client/runtime/wasm-engine-edge.js +0 -7801
- package/prisma/client/schema.prisma +0 -156
- package/prisma/client/wasm-edge-light-loader.mjs +0 -4
- package/prisma/client/wasm-worker-loader.mjs +0 -4
- package/prisma/client/wasm.d.ts +0 -1
- package/prisma/client/wasm.js +0 -304
- package/prisma/global.ts +0 -53
- package/public/react-admin/chunk-YALWN5OT.js +0 -2
- package/public/react-admin/esm-L4WLVWJN.js +0 -3
- package/public/react-admin/esm-L4WLVWJN.js.map +0 -7
- package/public/react-admin/esm-QMNGI3LF.js +0 -3
- package/public/react-admin/esm-QMNGI3LF.js.map +0 -7
- package/public/react-admin/index.html +0 -36
- package/public/react-admin/main.js +0 -268
- package/public/react-admin/main.js.map +0 -7
- package/public/react-admin/stats.json +0 -1
- package/scripts.mjs +0 -142
- /package/prisma/{migrations → migrations-v1}/20250606001949_init/migration.sql +0 -0
- /package/prisma/{migrations → migrations-v1}/20250613000526_remove_group/migration.sql +0 -0
- /package/prisma/{migrations → migrations-v1}/20250620014502_settings/migration.sql +0 -0
- /package/prisma/{migrations → migrations-v1}/20250707205229_recipes/migration.sql +0 -0
- /package/public/{react-admin → admin-vanilla}/android-chrome-192x192.png +0 -0
- /package/public/{react-admin → admin-vanilla}/android-chrome-512x512.png +0 -0
- /package/public/{react-admin → admin-vanilla}/apple-touch-icon.png +0 -0
- /package/public/{react-admin → admin-vanilla}/favicon-16x16.png +0 -0
- /package/public/{react-admin → admin-vanilla}/favicon-32x32.png +0 -0
- /package/public/{react-admin → admin-vanilla}/favicon.ico +0 -0
- /package/public/{react-admin → admin-vanilla}/favicon.png +0 -0
- /package/public/{react-admin/chunk-YALWN5OT.js.map → admin-vanilla/main-LYDE4NDJ.css.map} +0 -0
- /package/public/{react-admin → admin-vanilla}/missing-favicon.png +0 -0
- /package/public/{react-admin → admin-vanilla}/motovun-jack.jpg +0 -0
- /package/public/{react-admin → admin-vanilla}/mws-icon.png +0 -0
- /package/public/{react-admin → admin-vanilla}/vite.svg +0 -0
- /package/public/{react-admin → stats}/stats.css +0 -0
- /package/public/{react-admin → stats}/stats.svg +0 -0
|
@@ -89,7 +89,7 @@ function Syncer(options) {
|
|
|
89
89
|
self.processTaskQueue();
|
|
90
90
|
} else {
|
|
91
91
|
// Look for deletions of tiddlers we're already syncing
|
|
92
|
-
var outstandingDeletion = false
|
|
92
|
+
var outstandingDeletion = false;
|
|
93
93
|
$tw.utils.each(changes,function(change,title,object) {
|
|
94
94
|
if(change.deleted && $tw.utils.hop(self.tiddlerInfo,title)) {
|
|
95
95
|
outstandingDeletion = true;
|
|
@@ -139,9 +139,9 @@ function Syncer(options) {
|
|
|
139
139
|
self.handleLazyLoadEvent(title);
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
if(this.syncadaptor.subscribe) this.syncadaptor.subscribe(function(){
|
|
143
|
+
self.syncFromServer();
|
|
144
|
+
});
|
|
145
145
|
|
|
146
146
|
// Get the login status
|
|
147
147
|
this.getStatus(function(err,isLoggedIn) {
|
|
@@ -309,7 +309,7 @@ Syncer.prototype.syncFromServer = function() {
|
|
|
309
309
|
|
|
310
310
|
Syncer.prototype.canSyncFromServer = function() {
|
|
311
311
|
return !!this.syncadaptor.getUpdatedTiddlers || !!this.syncadaptor.getSkinnyTiddlers;
|
|
312
|
-
}
|
|
312
|
+
};
|
|
313
313
|
|
|
314
314
|
/*
|
|
315
315
|
Force load a tiddler from the server
|
|
@@ -424,25 +424,25 @@ Syncer.prototype.handleRefreshEvent = function() {
|
|
|
424
424
|
Process the next task
|
|
425
425
|
*/
|
|
426
426
|
Syncer.prototype.processTaskQueue = function() {
|
|
427
|
-
var self = this;
|
|
428
427
|
// Only process a task if the sync adaptor is fully initialised and we're not already performing
|
|
429
428
|
// a task. If we are already performing a task then we'll dispatch the next one when it completes
|
|
430
429
|
if((!this.syncadaptor.isReady || this.syncadaptor.isReady()) && this.numTasksInProgress === 0) {
|
|
431
430
|
// Choose the next task to perform
|
|
432
|
-
|
|
431
|
+
const task = this.chooseNextTask();
|
|
433
432
|
// Perform the task if we had one
|
|
434
|
-
if(typeof task === "
|
|
433
|
+
if(typeof task === "function") {
|
|
435
434
|
this.numTasksInProgress += 1;
|
|
436
|
-
task
|
|
437
|
-
|
|
435
|
+
task(err => {
|
|
436
|
+
this.numTasksInProgress -= 1;
|
|
438
437
|
if(err) {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
438
|
+
const [,name] = /(save|load|delete|sync)Task$/.exec(task.name) || [];
|
|
439
|
+
this.displayError("Sync error while processing " + name + " task", err);
|
|
440
|
+
this.updateDirtyStatus();
|
|
441
|
+
this.triggerTimeout(this.errorRetryInterval);
|
|
442
442
|
} else {
|
|
443
|
-
|
|
443
|
+
this.updateDirtyStatus();
|
|
444
444
|
// Process the next task
|
|
445
|
-
|
|
445
|
+
this.processTaskQueue.call(this);
|
|
446
446
|
}
|
|
447
447
|
});
|
|
448
448
|
} else {
|
|
@@ -480,43 +480,28 @@ Returns either:
|
|
|
480
480
|
* the boolean true if there are pending sync tasks that aren't yet due
|
|
481
481
|
* null if there's no pending sync tasks (just the next poll)
|
|
482
482
|
*/
|
|
483
|
-
|
|
483
|
+
/** @returns {((callback: () => void) => void) | boolean} */
|
|
484
484
|
Syncer.prototype.chooseNextTask = function() {
|
|
485
485
|
var pending = this.getPendingTitles();
|
|
486
486
|
|
|
487
487
|
if(pending.savePending.length){
|
|
488
|
-
|
|
489
|
-
return new SaveAllTiddlersTask(this, pending.savePending);
|
|
490
|
-
} else {
|
|
491
|
-
return new SaveTiddlerTask(this, pending.savePending[0]);
|
|
492
|
-
}
|
|
488
|
+
return saveTask.bind(this, pending.savePending);
|
|
493
489
|
}
|
|
494
490
|
if(pending.syncServer){
|
|
495
|
-
return
|
|
491
|
+
return syncTask.bind(this);
|
|
496
492
|
}
|
|
497
493
|
if(pending.deletePending.length){
|
|
498
|
-
|
|
499
|
-
return new DeleteAllTiddlersTask(this, pending.deletePending);
|
|
500
|
-
} else {
|
|
501
|
-
return new DeleteTiddlerTask(this, pending.deletePending[0]);
|
|
502
|
-
}
|
|
494
|
+
return deleteTask.bind(this, pending.deletePending);
|
|
503
495
|
}
|
|
504
496
|
if(pending.loadPending.length){
|
|
505
|
-
|
|
506
|
-
var self = this;
|
|
507
|
-
pending.loadPending.forEach(function(e){ delete self.titlesToBeLoaded[e]; });
|
|
508
|
-
return new LoadAllTiddlersTask(this, pending.loadPending);
|
|
509
|
-
} else {
|
|
510
|
-
delete this.titlesToBeLoaded[pending.loadPending[0]];
|
|
511
|
-
return new LoadTiddlerTask(this, pending.loadPending[0]);
|
|
512
|
-
}
|
|
497
|
+
return loadTask.bind(this, pending.loadPending);
|
|
513
498
|
}
|
|
514
499
|
return pending.havePending;
|
|
515
500
|
};
|
|
516
501
|
|
|
517
502
|
Syncer.prototype.getPendingTitles = function() {
|
|
518
503
|
var now = new Date(),
|
|
519
|
-
thresholdLastSaved = now - this.throttleInterval,
|
|
504
|
+
thresholdLastSaved = now.valueOf() - this.throttleInterval,
|
|
520
505
|
havePending = null,
|
|
521
506
|
savePending = [],
|
|
522
507
|
syncServer = false,
|
|
@@ -534,7 +519,6 @@ Syncer.prototype.getPendingTitles = function() {
|
|
|
534
519
|
isReadyToSave = !tiddlerInfo || !tiddlerInfo.timestampLastSaved || tiddlerInfo.timestampLastSaved < thresholdLastSaved;
|
|
535
520
|
if(hasChanged) {
|
|
536
521
|
if(isReadyToSave) {
|
|
537
|
-
// return new SaveTiddlerTask(this,title);
|
|
538
522
|
savePending.push(title);
|
|
539
523
|
} else {
|
|
540
524
|
havePending = true;
|
|
@@ -544,7 +528,6 @@ Syncer.prototype.getPendingTitles = function() {
|
|
|
544
528
|
}
|
|
545
529
|
// Second we check for an outstanding sync from server
|
|
546
530
|
if(this.forceSyncFromServer || (this.timestampLastSyncFromServer && (now.valueOf() >= (this.timestampLastSyncFromServer.valueOf() + this.pollTimerInterval)))) {
|
|
547
|
-
// return new SyncFromServerTask(this);
|
|
548
531
|
syncServer = true;
|
|
549
532
|
}
|
|
550
533
|
// Third, we check tiddlers that are known from the server but not currently in the store, and so need deleting on the server
|
|
@@ -554,248 +537,147 @@ Syncer.prototype.getPendingTitles = function() {
|
|
|
554
537
|
tiddlerInfo = this.tiddlerInfo[title];
|
|
555
538
|
tiddler = this.wiki.tiddlerExists(title) && this.wiki.getTiddler(title);
|
|
556
539
|
if(!tiddler) {
|
|
557
|
-
// return new DeleteTiddlerTask(this,title);
|
|
558
540
|
deletePending.push(title);
|
|
559
541
|
}
|
|
560
542
|
}
|
|
561
543
|
// Finally, check for tiddlers that need loading
|
|
562
|
-
// title = Object.keys(this.titlesToBeLoaded)[0];
|
|
563
|
-
// if(title) {
|
|
564
|
-
// delete this.titlesToBeLoaded[title];
|
|
565
|
-
// return new LoadTiddlerTask(this,title);
|
|
566
|
-
// }
|
|
567
544
|
loadPending.push(...Object.keys(this.titlesToBeLoaded));
|
|
568
545
|
// No tasks are ready now, but might be in the future
|
|
569
546
|
return {havePending: havePending, loadPending: loadPending, savePending: savePending, deletePending: deletePending, syncServer: syncServer};
|
|
570
547
|
};
|
|
571
548
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
this.
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
SaveTiddlerTask.prototype.run = function(callback) {
|
|
583
|
-
var self = this,
|
|
584
|
-
changeCount = this.syncer.wiki.getChangeCount(this.title),
|
|
585
|
-
tiddler = this.syncer.wiki.tiddlerExists(this.title) && this.syncer.wiki.getTiddler(this.title);
|
|
586
|
-
this.syncer.logger.log("Dispatching 'save' task:",this.title);
|
|
587
|
-
if(tiddler) {
|
|
588
|
-
this.syncer.syncadaptor.saveTiddler(tiddler,function(err,adaptorInfo,revision) {
|
|
589
|
-
// If there's an error, exit without changing any internal state
|
|
590
|
-
if(err) {
|
|
591
|
-
return callback(err);
|
|
592
|
-
}
|
|
593
|
-
// Adjust the info stored about this tiddler
|
|
594
|
-
self.syncer.tiddlerInfo[self.title] = {
|
|
595
|
-
changeCount: changeCount,
|
|
596
|
-
adaptorInfo: adaptorInfo,
|
|
597
|
-
revision: revision,
|
|
598
|
-
timestampLastSaved: new Date()
|
|
599
|
-
};
|
|
600
|
-
// Invoke the callback
|
|
601
|
-
callback(null);
|
|
602
|
-
},{
|
|
603
|
-
tiddlerInfo: self.syncer.tiddlerInfo[self.title]
|
|
604
|
-
});
|
|
605
|
-
} else {
|
|
606
|
-
$tw.utils.nextTick(callback(null));
|
|
607
|
-
}
|
|
608
|
-
};
|
|
609
|
-
|
|
610
|
-
function SaveAllTiddlersTask(syncer,titles) {
|
|
611
|
-
this.syncer = syncer;
|
|
612
|
-
this.titles = titles;
|
|
613
|
-
this.type = "save all";
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
SaveAllTiddlersTask.prototype.toString = function() {
|
|
617
|
-
return "SAVE ALL " + this.titles;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
SaveAllTiddlersTask.prototype.run = function(callback) {
|
|
621
|
-
var self = this;
|
|
622
|
-
this.syncer.logger.log("Dispatching 'save all' task:",this.titles);
|
|
623
|
-
var changeCounts = this.titles.reduce(function (r,title) { r[title] = self.syncer.wiki.getChangeCount(title); return r; }, {});
|
|
624
|
-
var tiddlers = this.titles
|
|
625
|
-
.map(function(title){return self.syncer.wiki.tiddlerExists(title) && self.syncer.wiki.getTiddler(title);})
|
|
626
|
-
.filter(function(title){return title;});
|
|
627
|
-
if(!tiddlers.length) return void $tw.utils.nextTick(callback(null));
|
|
628
|
-
this.syncer.syncadaptor.saveTiddlers({
|
|
629
|
-
syncer: this.syncer,
|
|
549
|
+
/** @this {Syncer} */
|
|
550
|
+
function saveTask(titles, callback) {
|
|
551
|
+
this.logger.log("Dispatching 'save' task");
|
|
552
|
+
var changeCounts = titles.reduce((r, title) => { r[title] = this.wiki.getChangeCount(title); return r; }, {});
|
|
553
|
+
var tiddlers = titles.map(title => this.wiki.tiddlerExists(title) && this.wiki.getTiddler(title)).filter(e => e);
|
|
554
|
+
if(!tiddlers.length) return $tw.utils.nextTick(() => { callback(null); });
|
|
555
|
+
const options = {
|
|
556
|
+
syncer: this,
|
|
630
557
|
tiddlers: tiddlers,
|
|
631
|
-
onNext:
|
|
632
|
-
|
|
558
|
+
onNext: (title, adaptorInfo, revision) => {
|
|
559
|
+
this.tiddlerInfo[title] = {
|
|
633
560
|
changeCount: changeCounts[title],
|
|
634
561
|
adaptorInfo: adaptorInfo,
|
|
635
562
|
revision: revision,
|
|
636
563
|
timestampLastSaved: new Date()
|
|
637
564
|
};
|
|
638
565
|
},
|
|
639
|
-
onDone:
|
|
640
|
-
onError:
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
this.syncer.logger.log("Dispatching 'delete' task:",this.title);
|
|
657
|
-
this.syncer.syncadaptor.deleteTiddler(this.title,function(err) {
|
|
658
|
-
// If there's an error, exit without changing any internal state
|
|
659
|
-
if(err) {
|
|
660
|
-
return callback(err);
|
|
661
|
-
}
|
|
662
|
-
// Remove the info stored about this tiddler
|
|
663
|
-
delete self.syncer.tiddlerInfo[self.title];
|
|
664
|
-
// Invoke the callback
|
|
665
|
-
callback(null);
|
|
666
|
-
},{
|
|
667
|
-
tiddlerInfo: self.syncer.tiddlerInfo[this.title]
|
|
668
|
-
});
|
|
669
|
-
};
|
|
670
|
-
|
|
671
|
-
function DeleteAllTiddlersTask(syncer,titles) {
|
|
672
|
-
this.syncer = syncer;
|
|
673
|
-
this.titles = titles;
|
|
674
|
-
this.type = "delete all";
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
DeleteAllTiddlersTask.prototype.toString = function() {
|
|
678
|
-
return "DELETE ALL " + this.titles;
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
DeleteAllTiddlersTask.prototype.run = function(callback) {
|
|
682
|
-
var self = this;
|
|
683
|
-
this.syncer.logger.log("Dispatching 'delete all' task:",this.titles);
|
|
684
|
-
this.syncer.syncadaptor.deleteTiddlers({
|
|
685
|
-
syncer: this.syncer,
|
|
686
|
-
titles: this.titles,
|
|
687
|
-
onNext: function(title){
|
|
688
|
-
delete self.syncer.tiddlerInfo[title];
|
|
689
|
-
},
|
|
690
|
-
onDone: function(){callback(null);},
|
|
691
|
-
onError: function(err){callback(err);},
|
|
692
|
-
});
|
|
566
|
+
onDone: () => { callback(null); },
|
|
567
|
+
onError: err => { callback(err); },
|
|
568
|
+
};
|
|
569
|
+
if(this.syncadaptor.saveTiddlers) {
|
|
570
|
+
this.syncadaptor.saveTiddlers(options);
|
|
571
|
+
} else {
|
|
572
|
+
const tiddler = options.tiddlers[0],
|
|
573
|
+
title = tiddler.fields.title;
|
|
574
|
+
this.syncadaptor.saveTiddler(tiddler, function (err, adaptorInfo, revision) {
|
|
575
|
+
if(err) {
|
|
576
|
+
options.onError(err);
|
|
577
|
+
} else {
|
|
578
|
+
options.onNext(title, adaptorInfo, revision);
|
|
579
|
+
options.onDone();
|
|
580
|
+
}
|
|
581
|
+
}, { tiddlerInfo: this.tiddlerInfo[title] });
|
|
582
|
+
}
|
|
693
583
|
};
|
|
694
584
|
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
this.
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
callback(null);
|
|
719
|
-
});
|
|
585
|
+
/** @this {Syncer} */
|
|
586
|
+
function deleteTask(titles, callback) {
|
|
587
|
+
this.logger.log("Dispatching 'delete' task");
|
|
588
|
+
const options = {
|
|
589
|
+
syncer: this,
|
|
590
|
+
titles,
|
|
591
|
+
onNext: title => { delete this.tiddlerInfo[title]; },
|
|
592
|
+
onDone: () => { callback(null); },
|
|
593
|
+
onError: err => { callback(err); },
|
|
594
|
+
};
|
|
595
|
+
if(this.syncadaptor.deleteTiddlers) {
|
|
596
|
+
this.syncadaptor.deleteTiddlers(options);
|
|
597
|
+
} else {
|
|
598
|
+
const title = options.titles[0];
|
|
599
|
+
this.syncadaptor.deleteTiddler(title, function (err) {
|
|
600
|
+
if(err) {
|
|
601
|
+
options.onError(err);
|
|
602
|
+
} else {
|
|
603
|
+
options.onNext(title);
|
|
604
|
+
options.onDone();
|
|
605
|
+
}
|
|
606
|
+
}, { tiddlerInfo: this.tiddlerInfo[title] });
|
|
607
|
+
}
|
|
720
608
|
};
|
|
721
609
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
this.
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
610
|
+
/** @this {Syncer} */
|
|
611
|
+
function loadTask(titles, callback) {
|
|
612
|
+
this.logger.log("Dispatching 'load' task");
|
|
613
|
+
const options = {
|
|
614
|
+
syncer: this,
|
|
615
|
+
titles,
|
|
616
|
+
onNext: tiddlerFields => { this.storeTiddler(tiddlerFields); },
|
|
617
|
+
onDone: () => { callback(null); },
|
|
618
|
+
onError: err => { callback(err); },
|
|
619
|
+
};
|
|
620
|
+
if(this.syncadaptor.loadTiddlers) {
|
|
621
|
+
options.titles.forEach(e => { delete this.titlesToBeLoaded[e]; });
|
|
622
|
+
this.syncadaptor.loadTiddlers(options);
|
|
623
|
+
} else {
|
|
624
|
+
delete this.titlesToBeLoaded[options.titles[0]];
|
|
625
|
+
this.syncadaptor.loadTiddler(options.titles[0], function (err, tiddlerFields) {
|
|
626
|
+
if(err) {
|
|
627
|
+
options.onError(err);
|
|
628
|
+
} else {
|
|
629
|
+
options.onNext(tiddlerFields);
|
|
630
|
+
options.onDone();
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
}
|
|
744
634
|
};
|
|
745
635
|
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
this.type = "syncfromserver";
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
SyncFromServerTask.prototype.toString = function() {
|
|
752
|
-
return "SYNCFROMSERVER";
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
SyncFromServerTask.prototype.run = function(callback) {
|
|
636
|
+
/** @this {Syncer} */
|
|
637
|
+
function syncTask(callback) {
|
|
756
638
|
var self = this;
|
|
757
|
-
var syncSystemFromServer = (self.
|
|
639
|
+
var syncSystemFromServer = (self.wiki.getTiddlerText("$:/config/SyncSystemTiddlersFromServer") === "yes" ? true : false);
|
|
758
640
|
var successCallback = function() {
|
|
759
|
-
self.
|
|
760
|
-
self.
|
|
641
|
+
self.forceSyncFromServer = false;
|
|
642
|
+
self.timestampLastSyncFromServer = new Date();
|
|
761
643
|
callback(null);
|
|
762
644
|
};
|
|
763
|
-
if(this.
|
|
764
|
-
this.
|
|
645
|
+
if(this.syncadaptor.getUpdatedTiddlers) {
|
|
646
|
+
this.syncadaptor.getUpdatedTiddlers(self,function(err,updates) {
|
|
765
647
|
if(err) {
|
|
766
|
-
self.
|
|
648
|
+
self.displayError($tw.language.getString("Error/RetrievingSkinny"),err);
|
|
767
649
|
return callback(err);
|
|
768
650
|
}
|
|
769
651
|
if(updates) {
|
|
770
652
|
$tw.utils.each(updates.modifications,function(title) {
|
|
771
|
-
self.
|
|
653
|
+
self.titlesToBeLoaded[title] = true;
|
|
772
654
|
});
|
|
773
655
|
$tw.utils.each(updates.deletions,function(title) {
|
|
774
|
-
if(syncSystemFromServer || !self.
|
|
775
|
-
delete self.
|
|
776
|
-
self.
|
|
777
|
-
self.
|
|
656
|
+
if(syncSystemFromServer || !self.wiki.isSystemTiddler(title)) {
|
|
657
|
+
delete self.tiddlerInfo[title];
|
|
658
|
+
self.logger.log("Deleting tiddler missing from server:",title);
|
|
659
|
+
self.wiki.deleteTiddler(title);
|
|
778
660
|
}
|
|
779
661
|
});
|
|
780
662
|
}
|
|
781
663
|
return successCallback();
|
|
782
664
|
});
|
|
783
|
-
} else if(this.
|
|
784
|
-
this.
|
|
665
|
+
} else if(this.syncadaptor.getSkinnyTiddlers) {
|
|
666
|
+
this.syncadaptor.getSkinnyTiddlers(function(err,tiddlers) {
|
|
785
667
|
// Check for errors
|
|
786
668
|
if(err) {
|
|
787
|
-
self.
|
|
669
|
+
self.displayError($tw.language.getString("Error/RetrievingSkinny"),err);
|
|
788
670
|
return callback(err);
|
|
789
671
|
}
|
|
790
672
|
// Keep track of which tiddlers we already know about have been reported this time
|
|
791
|
-
var previousTitles = Object.keys(self.
|
|
673
|
+
var previousTitles = Object.keys(self.tiddlerInfo);
|
|
792
674
|
// Process each incoming tiddler
|
|
793
675
|
for(var t=0; t<tiddlers.length; t++) {
|
|
794
676
|
// Get the incoming tiddler fields, and the existing tiddler
|
|
795
677
|
var tiddlerFields = tiddlers[t],
|
|
796
678
|
incomingRevision = tiddlerFields.revision + "",
|
|
797
|
-
tiddler = self.
|
|
798
|
-
tiddlerInfo = self.
|
|
679
|
+
tiddler = self.wiki.tiddlerExists(tiddlerFields.title) && self.wiki.getTiddler(tiddlerFields.title),
|
|
680
|
+
tiddlerInfo = self.tiddlerInfo[tiddlerFields.title],
|
|
799
681
|
currRevision = tiddlerInfo ? tiddlerInfo.revision : null,
|
|
800
682
|
indexInPreviousTitles = previousTitles.indexOf(tiddlerFields.title);
|
|
801
683
|
if(indexInPreviousTitles !== -1) {
|
|
@@ -805,22 +687,22 @@ SyncFromServerTask.prototype.run = function(callback) {
|
|
|
805
687
|
if(currRevision !== incomingRevision) {
|
|
806
688
|
// Only load the skinny version if we don't already have a fat version of the tiddler
|
|
807
689
|
if(!tiddler || tiddler.fields.text === undefined) {
|
|
808
|
-
self.
|
|
690
|
+
self.storeTiddler(tiddlerFields);
|
|
809
691
|
}
|
|
810
692
|
// Do a full load of this tiddler
|
|
811
|
-
self.
|
|
693
|
+
self.titlesToBeLoaded[tiddlerFields.title] = true;
|
|
812
694
|
}
|
|
813
695
|
}
|
|
814
696
|
// Delete any tiddlers that were previously reported but missing this time
|
|
815
697
|
$tw.utils.each(previousTitles,function(title) {
|
|
816
|
-
if(syncSystemFromServer || !self.
|
|
817
|
-
delete self.
|
|
818
|
-
self.
|
|
819
|
-
self.
|
|
698
|
+
if(syncSystemFromServer || !self.wiki.isSystemTiddler(title)) {
|
|
699
|
+
delete self.tiddlerInfo[title];
|
|
700
|
+
self.logger.log("Deleting tiddler missing from server:",title);
|
|
701
|
+
self.wiki.deleteTiddler(title);
|
|
820
702
|
}
|
|
821
703
|
});
|
|
822
|
-
self.
|
|
823
|
-
self.
|
|
704
|
+
self.forceSyncFromServer = false;
|
|
705
|
+
self.timestampLastSyncFromServer = new Date();
|
|
824
706
|
return successCallback();
|
|
825
707
|
});
|
|
826
708
|
} else {
|
|
@@ -828,4 +710,4 @@ SyncFromServerTask.prototype.run = function(callback) {
|
|
|
828
710
|
}
|
|
829
711
|
};
|
|
830
712
|
|
|
831
|
-
exports.Syncer = Syncer;
|
|
713
|
+
exports.Syncer = Syncer;
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
"alwaysStrict": true,
|
|
13
13
|
"rootDir": "./src",
|
|
14
14
|
"esModuleInterop": true,
|
|
15
|
+
"allowImportingTsExtensions": false,
|
|
16
|
+
"inlineSourceMap": true,
|
|
17
|
+
"inlineSources": true,
|
|
18
|
+
// "sourceRoot": ""
|
|
15
19
|
// "noUnusedLocals": false,
|
|
16
20
|
// "noUnusedParameters": false,
|
|
17
21
|
// "noFallthroughCasesInSwitch": true,
|
|
@@ -21,6 +25,6 @@
|
|
|
21
25
|
|
|
22
26
|
},
|
|
23
27
|
"files": [
|
|
24
|
-
"src/multiwikiclientadaptor.ts"
|
|
28
|
+
"src/new-multiwikiclientadaptor.ts"
|
|
25
29
|
],
|
|
26
30
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
|
|
2
|
+
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
// biome-ignore-all lint: generated file
|
|
5
|
+
// @ts-nocheck
|
|
6
|
+
/*
|
|
7
|
+
* This file should be your main import to use Prisma-related types and utilities in a browser.
|
|
8
|
+
* Use it to get access to models, enums, and input types.
|
|
9
|
+
*
|
|
10
|
+
* This file does not contain a `PrismaClient` class, nor several other helpers that are intended as server-side only.
|
|
11
|
+
* See `client.ts` for the standard, server-side entry point.
|
|
12
|
+
*
|
|
13
|
+
* 🟢 You can import this file directly.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import * as Prisma from './internal/prismaNamespaceBrowser.ts'
|
|
17
|
+
export { Prisma }
|
|
18
|
+
export * as $Enums from './enums.ts'
|
|
19
|
+
export * from './enums.ts';
|
|
20
|
+
/**
|
|
21
|
+
* Model Bag
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
export type Bag = Prisma.BagModel
|
|
25
|
+
/**
|
|
26
|
+
* Model BagPermission
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
export type BagPermission = Prisma.BagPermissionModel
|
|
30
|
+
/**
|
|
31
|
+
* Model Tiddler
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
export type Tiddler = Prisma.TiddlerModel
|
|
35
|
+
/**
|
|
36
|
+
* Model TiddlerEvent
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
export type TiddlerEvent = Prisma.TiddlerEventModel
|
|
40
|
+
/**
|
|
41
|
+
* Model Template
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
export type Template = Prisma.TemplateModel
|
|
45
|
+
/**
|
|
46
|
+
* Model TemplatePermission
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
export type TemplatePermission = Prisma.TemplatePermissionModel
|
|
50
|
+
/**
|
|
51
|
+
* Model Recipe
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
export type Recipe = Prisma.RecipeModel
|
|
55
|
+
/**
|
|
56
|
+
* Model RecipePermission
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
59
|
+
export type RecipePermission = Prisma.RecipePermissionModel
|
|
60
|
+
/**
|
|
61
|
+
* Model RecipeBag
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
export type RecipeBag = Prisma.RecipeBagModel
|
|
65
|
+
/**
|
|
66
|
+
* Model Settings
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
69
|
+
export type Settings = Prisma.SettingsModel
|
|
70
|
+
/**
|
|
71
|
+
* Model Roles
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
export type Roles = Prisma.RolesModel
|
|
75
|
+
/**
|
|
76
|
+
* Model Users
|
|
77
|
+
*
|
|
78
|
+
*/
|
|
79
|
+
export type Users = Prisma.UsersModel
|
|
80
|
+
/**
|
|
81
|
+
* Model Sessions
|
|
82
|
+
*
|
|
83
|
+
*/
|
|
84
|
+
export type Sessions = Prisma.SessionsModel
|