@fiduswriter/frontend 0.1.27 → 0.1.29

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.
Files changed (146) hide show
  1. package/dist/admin_console/index.d.ts +9 -2
  2. package/dist/admin_console/index.d.ts.map +1 -1
  3. package/dist/admin_console/index.js.map +1 -1
  4. package/dist/api/index.d.ts +62 -75
  5. package/dist/api/index.d.ts.map +1 -1
  6. package/dist/app/index.d.ts +11 -6
  7. package/dist/app/index.d.ts.map +1 -1
  8. package/dist/app/index.js +66 -23
  9. package/dist/app/index.js.map +1 -1
  10. package/dist/document_templates/actions.js +2 -4
  11. package/dist/document_templates/actions.js.map +1 -1
  12. package/dist/document_templates/editor.d.ts +2 -2
  13. package/dist/document_templates/editor.d.ts.map +1 -1
  14. package/dist/document_templates/editor.js +2 -2
  15. package/dist/document_templates/editor.js.map +1 -1
  16. package/dist/document_templates/overview.d.ts +7 -7
  17. package/dist/document_templates/overview.d.ts.map +1 -1
  18. package/dist/document_templates/overview.js.map +1 -1
  19. package/dist/documents/overview/actions.d.ts +3 -2
  20. package/dist/documents/overview/actions.d.ts.map +1 -1
  21. package/dist/documents/overview/actions.js +20 -17
  22. package/dist/documents/overview/actions.js.map +1 -1
  23. package/dist/documents/overview/index.d.ts +8 -17
  24. package/dist/documents/overview/index.d.ts.map +1 -1
  25. package/dist/documents/overview/index.js +2 -2
  26. package/dist/documents/overview/index.js.map +1 -1
  27. package/dist/documents/overview/menu.d.ts.map +1 -1
  28. package/dist/documents/overview/menu.js +2 -2
  29. package/dist/documents/overview/menu.js.map +1 -1
  30. package/dist/documents/tools.d.ts +2 -2
  31. package/dist/documents/tools.d.ts.map +1 -1
  32. package/dist/documents/tools.js.map +1 -1
  33. package/dist/e2ee/passphrase_urls.d.ts +10 -0
  34. package/dist/e2ee/passphrase_urls.d.ts.map +1 -0
  35. package/dist/e2ee/passphrase_urls.js +23 -0
  36. package/dist/e2ee/passphrase_urls.js.map +1 -0
  37. package/dist/error_hook/index.d.ts +8 -1
  38. package/dist/error_hook/index.d.ts.map +1 -1
  39. package/dist/error_hook/index.js +10 -12
  40. package/dist/error_hook/index.js.map +1 -1
  41. package/dist/feedback/index.d.ts +3 -2
  42. package/dist/feedback/index.d.ts.map +1 -1
  43. package/dist/feedback/index.js.map +1 -1
  44. package/dist/index.d.ts +1 -1
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/maintenance/index.d.ts +3 -2
  47. package/dist/maintenance/index.d.ts.map +1 -1
  48. package/dist/maintenance/index.js.map +1 -1
  49. package/dist/menu/index.d.ts +3 -3
  50. package/dist/menu/index.d.ts.map +1 -1
  51. package/dist/menu/index.js +0 -1
  52. package/dist/menu/index.js.map +1 -1
  53. package/dist/pages/flatpage.js.map +1 -1
  54. package/dist/prelogin/index.d.ts +3 -7
  55. package/dist/prelogin/index.d.ts.map +1 -1
  56. package/dist/prelogin/index.js.map +1 -1
  57. package/dist/types.d.ts +63 -8
  58. package/dist/types.d.ts.map +1 -1
  59. package/dist/user/auth/email_confirm.d.ts +2 -2
  60. package/dist/user/auth/email_confirm.d.ts.map +1 -1
  61. package/dist/user/auth/email_confirm.js +5 -6
  62. package/dist/user/auth/email_confirm.js.map +1 -1
  63. package/dist/user/auth/login.d.ts +3 -3
  64. package/dist/user/auth/login.d.ts.map +1 -1
  65. package/dist/user/auth/login.js +18 -19
  66. package/dist/user/auth/login.js.map +1 -1
  67. package/dist/user/auth/password_reset_change.d.ts +2 -2
  68. package/dist/user/auth/password_reset_change.d.ts.map +1 -1
  69. package/dist/user/auth/password_reset_change.js +0 -1
  70. package/dist/user/auth/password_reset_change.js.map +1 -1
  71. package/dist/user/auth/password_reset_request.d.ts +2 -2
  72. package/dist/user/auth/password_reset_request.d.ts.map +1 -1
  73. package/dist/user/auth/password_reset_request.js +0 -1
  74. package/dist/user/auth/password_reset_request.js.map +1 -1
  75. package/dist/user/auth/signup.d.ts +2 -2
  76. package/dist/user/auth/signup.d.ts.map +1 -1
  77. package/dist/user/auth/signup.js +2 -2
  78. package/dist/user/auth/signup.js.map +1 -1
  79. package/dist/user/auth/two_factor.d.ts +7 -5
  80. package/dist/user/auth/two_factor.d.ts.map +1 -1
  81. package/dist/user/auth/two_factor.js +3 -2
  82. package/dist/user/auth/two_factor.js.map +1 -1
  83. package/dist/user/contacts/add_dialog.d.ts +16 -2
  84. package/dist/user/contacts/add_dialog.d.ts.map +1 -1
  85. package/dist/user/contacts/add_dialog.js +4 -4
  86. package/dist/user/contacts/add_dialog.js.map +1 -1
  87. package/dist/user/contacts/delete_dialog.d.ts +3 -2
  88. package/dist/user/contacts/delete_dialog.d.ts.map +1 -1
  89. package/dist/user/contacts/delete_dialog.js.map +1 -1
  90. package/dist/user/contacts/index.d.ts +10 -2
  91. package/dist/user/contacts/index.d.ts.map +1 -1
  92. package/dist/user/contacts/index.js.map +1 -1
  93. package/dist/user/contacts/invite.d.ts +3 -2
  94. package/dist/user/contacts/invite.d.ts.map +1 -1
  95. package/dist/user/contacts/invite.js +3 -2
  96. package/dist/user/contacts/invite.js.map +1 -1
  97. package/dist/user/contacts/menu.d.ts.map +1 -1
  98. package/dist/user/contacts/menu.js +1 -1
  99. package/dist/user/contacts/menu.js.map +1 -1
  100. package/dist/user/contacts/respond_invite.d.ts +3 -2
  101. package/dist/user/contacts/respond_invite.d.ts.map +1 -1
  102. package/dist/user/contacts/respond_invite.js.map +1 -1
  103. package/dist/user/profile/delete_user.d.ts +3 -2
  104. package/dist/user/profile/delete_user.d.ts.map +1 -1
  105. package/dist/user/profile/delete_user.js.map +1 -1
  106. package/dist/user/profile/dialogs.d.ts +8 -7
  107. package/dist/user/profile/dialogs.d.ts.map +1 -1
  108. package/dist/user/profile/dialogs.js +3 -4
  109. package/dist/user/profile/dialogs.js.map +1 -1
  110. package/dist/user/profile/index.d.ts +9 -4
  111. package/dist/user/profile/index.d.ts.map +1 -1
  112. package/dist/user/profile/index.js.map +1 -1
  113. package/package.json +12 -9
  114. package/src/admin_console/index.ts +9 -2
  115. package/src/api/index.ts +78 -39
  116. package/src/app/index.ts +114 -50
  117. package/src/document_templates/actions.ts +6 -6
  118. package/src/document_templates/editor.ts +10 -8
  119. package/src/document_templates/overview.ts +10 -12
  120. package/src/documents/overview/actions.ts +52 -25
  121. package/src/documents/overview/index.ts +16 -27
  122. package/src/documents/overview/menu.ts +4 -2
  123. package/src/documents/tools.ts +2 -2
  124. package/src/error_hook/index.ts +20 -15
  125. package/src/feedback/index.ts +5 -3
  126. package/src/index.ts +3 -1
  127. package/src/maintenance/index.ts +16 -7
  128. package/src/menu/index.ts +4 -4
  129. package/src/pages/flatpage.ts +4 -4
  130. package/src/prelogin/index.ts +4 -8
  131. package/src/types.ts +53 -9
  132. package/src/user/auth/email_confirm.ts +19 -19
  133. package/src/user/auth/login.ts +23 -22
  134. package/src/user/auth/password_reset_change.ts +4 -4
  135. package/src/user/auth/password_reset_request.ts +3 -3
  136. package/src/user/auth/signup.ts +8 -8
  137. package/src/user/auth/two_factor.ts +31 -22
  138. package/src/user/contacts/add_dialog.ts +7 -4
  139. package/src/user/contacts/delete_dialog.ts +3 -2
  140. package/src/user/contacts/index.ts +14 -4
  141. package/src/user/contacts/invite.ts +9 -5
  142. package/src/user/contacts/menu.ts +4 -1
  143. package/src/user/contacts/respond_invite.ts +3 -2
  144. package/src/user/profile/delete_user.ts +3 -2
  145. package/src/user/profile/dialogs.ts +19 -18
  146. package/src/user/profile/index.ts +13 -10
@@ -17,6 +17,7 @@ import {PassphraseManager} from "fwtoolkit/e2ee/passphrase-manager"
17
17
  import {createPasswordDialog, enterPasswordDialog} from "fwtoolkit/e2ee/password-dialog"
18
18
 
19
19
  import type {DocumentOverview} from "./index.js"
20
+ import type {FrontendApp} from "../../types.js"
20
21
  import {documentDialogTemplate, importDocumentTemplate} from "./templates.js"
21
22
 
22
23
  const exportProgressCallback = (doc: Record<string, unknown>) => {
@@ -96,7 +97,9 @@ export class DocumentOverviewActions {
96
97
  newContactCall: ((memberDetails: Record<string, unknown>) =>
97
98
  this.documentOverview.contacts.push(memberDetails as any)) as any,
98
99
  e2ee: doc.e2ee as boolean,
99
- settings: this.documentOverview.app.settings
100
+ settings: this.documentOverview.app.settings,
101
+ documentApi: this.documentOverview.app.apiConnectors.document,
102
+ contactsApi: this.documentOverview.app.apiConnectors.contacts
100
103
  })
101
104
  this.accessRightsTab
102
105
  .load()
@@ -124,7 +127,7 @@ export class DocumentOverviewActions {
124
127
  return Promise.resolve()
125
128
  }
126
129
  const displayTitle = getDisplayTitle(doc)
127
- return (this.documentOverview.app as any).apiConnectors.documentList.deleteDocument({id}).then((json: any) => {
130
+ return this.documentOverview.app.apiConnectors.document.deleteDocument({id}).then((json: any) => {
128
131
  if ((json as any).done) {
129
132
  addAlert(
130
133
  "success",
@@ -142,7 +145,7 @@ export class DocumentOverviewActions {
142
145
  })
143
146
  }
144
147
 
145
- deleteDocumentDialog(ids: number[], app: any): void {
148
+ deleteDocumentDialog(ids: number[], app: FrontendApp): void {
146
149
  if (app.isOffline()) {
147
150
  addAlert(
148
151
  "info",
@@ -295,12 +298,12 @@ export class DocumentOverviewActions {
295
298
  if (isFidus) {
296
299
  const importer = new FidusFileImporter(
297
300
  file!,
298
- this.documentOverview.user,
301
+ this.documentOverview.user as unknown as Record<string, unknown>,
299
302
  this.documentOverview.path,
300
303
  true,
301
304
  this.documentOverview.contacts,
302
305
  e2eeOptions,
303
- (this.documentOverview.app as any).apiConnectors
306
+ this.documentOverview.app.apiConnectors
304
307
  )
305
308
 
306
309
  try {
@@ -375,7 +378,7 @@ export class DocumentOverviewActions {
375
378
  bibDB: this.documentOverview.app.bibDB,
376
379
  files: {},
377
380
  e2eeOptions,
378
- apiConnectors: (this.documentOverview.app as any).apiConnectors
381
+ apiConnectors: this.documentOverview.app.apiConnectors
379
382
  }
380
383
 
381
384
  const importer = new importerInfo.importer(
@@ -422,7 +425,13 @@ export class DocumentOverviewActions {
422
425
  const doc = await doImport(e2eeOptions)
423
426
  if (doc?.id) {
424
427
  try {
425
- await PassphraseManager.saveDocumentPassword(doc.id, password)
428
+ await PassphraseManager.saveDocumentPassword(
429
+ doc.id,
430
+ password,
431
+ null as any,
432
+ "user",
433
+ true
434
+ )
426
435
  } catch (err) {
427
436
  console.error(
428
437
  "Failed to save document password for imported document:",
@@ -455,7 +464,9 @@ export class DocumentOverviewActions {
455
464
  if (result?.action === "unlock" && result.passphrase) {
456
465
  activateWait()
457
466
  try {
458
- await PassphraseManager.unlockWithPassphrase(result.passphrase)
467
+ await PassphraseManager.unlockWithPassphrase(
468
+ result.passphrase
469
+ )
459
470
  await importWithAutoPassword()
460
471
  done = true
461
472
  } catch (err: any) {
@@ -540,7 +551,7 @@ export class DocumentOverviewActions {
540
551
  ids,
541
552
  this.documentOverview.documentList as any,
542
553
  this.documentOverview.schema,
543
- (this.documentOverview.app as any).apiConnectors.documentList
554
+ this.documentOverview.app.apiConnectors.document
544
555
  ).then(() => {
545
556
  ids.forEach(id => {
546
557
  const doc = this.documentOverview.documentList.find(
@@ -551,7 +562,10 @@ export class DocumentOverviewActions {
551
562
  doc,
552
563
  {db: doc.bibliography as any},
553
564
  {db: doc.images as any},
554
- this.documentOverview.user as any
565
+ this.documentOverview.user as any,
566
+ null,
567
+ null,
568
+ this.documentOverview.app.apiConnectors.documentImport
555
569
  )
556
570
 
557
571
  copier
@@ -572,7 +586,7 @@ export class DocumentOverviewActions {
572
586
  ids,
573
587
  this.documentOverview.documentList as any,
574
588
  this.documentOverview.schema,
575
- (this.documentOverview.app as any).apiConnectors.documentList
589
+ this.documentOverview.app.apiConnectors.document
576
590
  ).then(() => {
577
591
  const docs = ids.map(id =>
578
592
  this.documentOverview.documentList.find(entry => entry.id === id)
@@ -647,7 +661,9 @@ export class DocumentOverviewActions {
647
661
  (selectTemplateDialog.dialogEl.querySelector(
648
662
  "select"
649
663
  ) as HTMLSelectElement).value,
650
- e2eeOptions
664
+ e2eeOptions,
665
+ this.documentOverview.app
666
+ .apiConnectors.documentImport
651
667
  )
652
668
 
653
669
  copier
@@ -727,12 +743,17 @@ export class DocumentOverviewActions {
727
743
  ids,
728
744
  this.documentOverview.documentList as any,
729
745
  this.documentOverview.schema,
730
- (this.documentOverview.app as any).apiConnectors.documentList
746
+ this.documentOverview.app.apiConnectors.document
731
747
  ).then(() =>
732
748
  ids.forEach(id => {
733
749
  const doc = this.documentOverview.documentList.find(entry => entry.id === id)
734
750
  if (!doc) return
735
- new ExportFidusFile(doc as any, {db: doc.bibliography as any}, {db: doc.images as any})
751
+ new ExportFidusFile(
752
+ this.documentOverview.app,
753
+ doc as any,
754
+ {db: doc.bibliography as any},
755
+ {db: doc.images as any}
756
+ )
736
757
  })
737
758
  )
738
759
  })
@@ -744,12 +765,18 @@ export class DocumentOverviewActions {
744
765
  ids,
745
766
  this.documentOverview.documentList as any,
746
767
  this.documentOverview.schema,
747
- (this.documentOverview.app as any).apiConnectors.documentList
768
+ this.documentOverview.app.apiConnectors.document
748
769
  ).then(() =>
749
770
  ids.forEach(id => {
750
771
  const doc = this.documentOverview.documentList.find(entry => entry.id === id)
751
772
  if (!doc) return
752
- new ExportFidusFile(doc as any, {db: doc.bibliography as any}, {db: doc.images as any}, false)
773
+ new ExportFidusFile(
774
+ this.documentOverview.app,
775
+ doc as any,
776
+ {db: doc.bibliography as any},
777
+ {db: doc.images as any},
778
+ false
779
+ )
753
780
  })
754
781
  )
755
782
  })
@@ -761,7 +788,7 @@ export class DocumentOverviewActions {
761
788
  ids,
762
789
  this.documentOverview.documentList as any,
763
790
  this.documentOverview.schema,
764
- (this.documentOverview.app as any).apiConnectors.documentList
791
+ this.documentOverview.app.apiConnectors.document
765
792
  ).then(() =>
766
793
  ids.forEach(id => {
767
794
  const doc = this.documentOverview.documentList.find(entry => entry.id === id)
@@ -796,7 +823,7 @@ export class DocumentOverviewActions {
796
823
  ids,
797
824
  this.documentOverview.documentList as any,
798
825
  this.documentOverview.schema,
799
- (this.documentOverview.app as any).apiConnectors.documentList
826
+ this.documentOverview.app.apiConnectors.document
800
827
  ).then(() => {
801
828
  ids.forEach(id => {
802
829
  const doc = this.documentOverview.documentList.find(entry => entry.id === id)
@@ -842,7 +869,7 @@ export class DocumentOverviewActions {
842
869
  ids,
843
870
  this.documentOverview.documentList as any,
844
871
  this.documentOverview.schema,
845
- (this.documentOverview.app as any).apiConnectors.documentList
872
+ this.documentOverview.app.apiConnectors.document
846
873
  ).then(() =>
847
874
  ids.forEach(id => {
848
875
  const doc = this.documentOverview.documentList.find(entry => entry.id === id)
@@ -871,7 +898,7 @@ export class DocumentOverviewActions {
871
898
  ids,
872
899
  this.documentOverview.documentList as any,
873
900
  this.documentOverview.schema,
874
- (this.documentOverview.app as any).apiConnectors.documentList
901
+ this.documentOverview.app.apiConnectors.document
875
902
  ).then(() =>
876
903
  ids.forEach(id => {
877
904
  const doc = this.documentOverview.documentList.find(entry => entry.id === id)
@@ -902,7 +929,7 @@ export class DocumentOverviewActions {
902
929
  ids,
903
930
  this.documentOverview.documentList as any,
904
931
  this.documentOverview.schema,
905
- (this.documentOverview.app as any).apiConnectors.documentList
932
+ this.documentOverview.app.apiConnectors.document
906
933
  ).then(() =>
907
934
  ids.forEach(id => {
908
935
  const doc = this.documentOverview.documentList.find(entry => entry.id === id)
@@ -933,7 +960,7 @@ export class DocumentOverviewActions {
933
960
  ids,
934
961
  this.documentOverview.documentList as any,
935
962
  this.documentOverview.schema,
936
- (this.documentOverview.app as any).apiConnectors.documentList
963
+ this.documentOverview.app.apiConnectors.document
937
964
  ).then(() =>
938
965
  ids.forEach(id => {
939
966
  const doc = this.documentOverview.documentList.find(entry => entry.id === id)
@@ -995,7 +1022,7 @@ export class DocumentOverviewActions {
995
1022
  dialogTabs.bind(dialog.dialogEl.querySelector("#documentoptions-tab")!)
996
1023
  }
997
1024
 
998
- revisionsDialog(documentId: number, app: any): void {
1025
+ revisionsDialog(documentId: number, app: FrontendApp): void {
999
1026
  if (app.isOffline()) {
1000
1027
  addAlert(
1001
1028
  "info",
@@ -1009,8 +1036,8 @@ export class DocumentOverviewActions {
1009
1036
  const revDialog = new DocumentRevisionsDialog(
1010
1037
  documentId,
1011
1038
  this.documentOverview.documentList,
1012
- this.documentOverview.user,
1013
- (this.documentOverview.app as any).apiConnectors
1039
+ this.documentOverview.user as unknown as Record<string, unknown>,
1040
+ this.documentOverview.app.apiConnectors
1014
1041
  )
1015
1042
  revDialog.init().then((actionObject: any) => {
1016
1043
  switch (actionObject.action) {
@@ -19,7 +19,7 @@ import {
19
19
  import {baseBodyTemplate} from "../../common/index.js"
20
20
  import {FeedbackTab} from "../../feedback/index.js"
21
21
  import {SiteMenu} from "../../menu/index.js"
22
- import type {App} from "../../types.js"
22
+ import type {FrontendApp, User} from "../../types.js"
23
23
 
24
24
  import {DocumentOverviewActions} from "./actions.js"
25
25
  import {bulkMenuModel, menuModel} from "./menu.js"
@@ -52,24 +52,13 @@ interface Contact {
52
52
  }
53
53
 
54
54
  interface DocumentOverviewConstructorOptions {
55
- app: App & {
56
- isOffline: () => boolean
57
- indexedDB: {
58
- readAllData: (store: string) => Promise<Array<Record<string, unknown>>>
59
- clearData: (store: string) => Promise<void>
60
- insertData: (store: string, data: Array<Record<string, unknown>>) => Promise<void>
61
- }
62
- settings: Record<string, unknown>
63
- bibDB?: unknown
64
- csl?: {getStyles: () => Promise<unknown>}
65
- page: unknown
66
- }
67
- user: Record<string, unknown>
55
+ app: FrontendApp
56
+ user: User & {id?: number}
68
57
  }
69
58
 
70
59
  export class DocumentOverview {
71
- app: DocumentOverviewConstructorOptions["app"]
72
- user: Record<string, unknown>
60
+ app: FrontendApp
61
+ user: User & {id?: number}
73
62
  path: string
74
63
  schema: any
75
64
  documentList: DocumentListEntry[]
@@ -112,7 +101,7 @@ export class DocumentOverview {
112
101
  this.active = true
113
102
  return whenReady().then(() => {
114
103
  this.render()
115
- const smenu = new SiteMenu(this.app as any, "documents")
104
+ const smenu = new SiteMenu(this.app, "documents")
116
105
  smenu.init()
117
106
  new DocumentOverviewActions(this)
118
107
  this.menu = new OverviewMenuView(this, menuModel as any)
@@ -131,9 +120,9 @@ export class DocumentOverview {
131
120
  this.dom = document.createElement("body")
132
121
  this.dom.innerHTML = baseBodyTemplate({
133
122
  contents: "",
134
- user: this.user as any,
123
+ user: this.user,
135
124
  hasOverview: true,
136
- app: this.app as any
125
+ app: this.app
137
126
  })
138
127
  ensureCSS([
139
128
  staticUrl("css/document_overview.css"),
@@ -142,7 +131,7 @@ export class DocumentOverview {
142
131
  staticUrl("css/e2ee.css")
143
132
  ])
144
133
  document.body = this.dom
145
- setDocTitle(gettext("Document Overview"), this.app as any)
134
+ setDocTitle(gettext("Document Overview"), this.app as {name: string})
146
135
  const feedbackTab = new FeedbackTab(this.app)
147
136
  feedbackTab.init()
148
137
  }
@@ -260,7 +249,7 @@ export class DocumentOverview {
260
249
  return cachedPromise.then(() => {})
261
250
  }
262
251
  return whenReady()
263
- .then(() => (this.app as any).apiConnectors.documentList.getDocumentList())
252
+ .then(() => this.app.apiConnectors.document.getDocumentList())
264
253
  .then((json) => {
265
254
  const typedJson = json as Record<string, unknown>
266
255
  return cachedPromise.then(oldJson => {
@@ -282,7 +271,7 @@ export class DocumentOverview {
282
271
 
283
272
  async bulkDecryptDocumentEncryptionKeys(): Promise<void> {
284
273
  try {
285
- const response = await (this.app as any).apiConnectors.documentList.getEncryptionKeys()
274
+ const response = await this.app.apiConnectors.document.getEncryptionKeys()
286
275
 
287
276
  if (!(response as any)?.keys?.length) {
288
277
  return
@@ -369,13 +358,13 @@ export class DocumentOverview {
369
358
  }
370
359
 
371
360
  loaddatafromIndexedDB(): Promise<any> {
372
- return this.app.indexedDB
361
+ return this.app.indexedDB!
373
362
  .readAllData("document_data")
374
363
  .then(response => {
375
364
  if (!response.length) {
376
365
  return false
377
366
  }
378
- const data = response[0]
367
+ const data = response[0] as Record<string, unknown>
379
368
  delete data.id
380
369
  return data
381
370
  })
@@ -383,9 +372,9 @@ export class DocumentOverview {
383
372
 
384
373
  updateIndexedDB(json: Record<string, unknown>): Promise<void> {
385
374
  ;(json as any).id = 1
386
- return this.app.indexedDB
375
+ return this.app.indexedDB!
387
376
  .clearData("document_data")
388
- .then(() => this.app.indexedDB.insertData("document_data", [json]))
377
+ .then(() => this.app.indexedDB!.insertData("document_data", [json]))
389
378
  }
390
379
 
391
380
  initializeView(json: any): any {
@@ -495,7 +484,7 @@ export class DocumentOverview {
495
484
  pathParts.pop()
496
485
  const parentPath = pathParts.join("/") + "/"
497
486
  const href =
498
- parentPath === "/" && (this.app as any).routes[""].app === "document"
487
+ parentPath === "/" && this.app.routes[""].app === "document"
499
488
  ? parentPath
500
489
  : `/documents${encodeURI(parentPath)}`
501
490
  tableRender = (_data: any, table: any, type: string) => {
@@ -48,7 +48,7 @@ export const bulkMenuModel = (): MenuModel => ({
48
48
  movingFiles: docs,
49
49
  allFiles: overview.documentList,
50
50
  moveFunction: (id: number, _title: string, path: string) =>
51
- (overview.app as any).apiConnectors.documentList.moveDocument({
51
+ overview.app.apiConnectors.document.moveDocument({
52
52
  id,
53
53
  path
54
54
  }),
@@ -96,7 +96,9 @@ export const bulkMenuModel = (): MenuModel => ({
96
96
  e2ee,
97
97
  "",
98
98
  null as any,
99
- overview.app.settings
99
+ overview.app.settings,
100
+ overview.app.apiConnectors.contacts,
101
+ overview.app.apiConnectors.document
100
102
  )
101
103
  dialog.init()
102
104
  }
@@ -4,7 +4,7 @@ import {getSettings} from "@fiduswriter/document/schema/convert"
4
4
  import {acceptAllNoInsertions} from "@fiduswriter/document/transform"
5
5
  import {addAlert} from "fwtoolkit"
6
6
 
7
- import type {DocumentListApi} from "../api/index.js"
7
+ import type {DocumentApi} from "../api/index.js"
8
8
 
9
9
  export interface DocEntry {
10
10
  id: number
@@ -23,7 +23,7 @@ export const getMissingDocumentListData = (
23
23
  ids: Array<number | string>,
24
24
  documentList: DocEntry[],
25
25
  schema: Schema,
26
- documentListApi: DocumentListApi,
26
+ documentListApi: DocumentApi,
27
27
  rawContent = false
28
28
  ): Promise<void> => {
29
29
  // get extra data for the documents identified by the ids and updates the
@@ -1,4 +1,5 @@
1
1
  import StackTrace from "stacktrace-js"
2
+ import type {ErrorHookApi} from "../api/index.js"
2
3
 
3
4
  interface CsrfSettings {
4
5
  getCsrfToken(): string
@@ -10,8 +11,18 @@ declare global {
10
11
  }
11
12
  }
12
13
 
14
+ interface ErrorHookApp {
15
+ apiConnectors: {
16
+ errorHook: ErrorHookApi
17
+ }
18
+ }
19
+
13
20
  export class ErrorHook {
14
- constructor() {}
21
+ app: ErrorHookApp
22
+
23
+ constructor(app: ErrorHookApp) {
24
+ this.app = app
25
+ }
15
26
 
16
27
  init(): void {
17
28
  window.onerror = (
@@ -29,20 +40,14 @@ export class ErrorHook {
29
40
  }
30
41
 
31
42
  sendLog(details: string): void {
32
- const body = new FormData()
33
- body.append("context", navigator.userAgent)
34
- body.append("details", details)
35
-
36
- fetch("/api/django_js_error_hook/", {
37
- method: "POST",
38
- headers: {
39
- "X-CSRFToken": window.settings.getCsrfToken()
40
- },
41
- credentials: "include",
42
- body
43
- }).catch(error => {
44
- console.warn(error)
45
- })
43
+ this.app.apiConnectors.errorHook
44
+ .send({
45
+ context: navigator.userAgent,
46
+ details
47
+ })
48
+ .catch(error => {
49
+ console.warn(error)
50
+ })
46
51
  }
47
52
 
48
53
  onError(
@@ -1,14 +1,16 @@
1
1
  import {ensureCSS} from "fwtoolkit"
2
2
 
3
+ import type {FrontendApp} from "../types.js"
4
+
3
5
  // Creates the feedback tab. The tab is meant for user feedback to the developers while FW is still in
4
6
  // a somewhat early stage. It is included in a way so it's easy to remove from all the templates.
5
7
  // This is also where browser sniffing happens to prevent still unsupported browsers from logging in.
6
8
 
7
9
  export class FeedbackTab {
8
10
  previousActiveElement: HTMLElement | null
9
- app: any
11
+ app: FrontendApp
10
12
 
11
- constructor(app?: any) {
13
+ constructor(app: FrontendApp) {
12
14
  this.previousActiveElement = null
13
15
  this.app = app
14
16
  }
@@ -116,7 +118,7 @@ export class FeedbackTab {
116
118
  closeFeedbackEl.style.display = "none"
117
119
  feedbackFormEl.style.visibility = "hidden"
118
120
 
119
- ;(this.app as any).apiConnectors.feedback
121
+ this.app.apiConnectors.feedback
120
122
  .send({message: messageEl.value})
121
123
  .then(() => {
122
124
  messageEl.value = ""
package/src/index.ts CHANGED
@@ -80,7 +80,7 @@ export type {
80
80
  export type {PreloginApp} from "./prelogin/index.js"
81
81
  export type {
82
82
  ConfigApi,
83
- DocumentListApi,
83
+ DocumentApi,
84
84
  DocumentImportApi,
85
85
  UserProfileApi,
86
86
  AuthApi,
@@ -91,5 +91,7 @@ export type {
91
91
  ErrorHookApi,
92
92
  MaintenanceApi,
93
93
  RevisionApi,
94
+ BibliographyApi,
95
+ ImageApi,
94
96
  ApiConnectors
95
97
  } from "./api/index.js"
@@ -5,13 +5,22 @@ import {updateDoc} from "@fiduswriter/document/schema/convert"
5
5
  import {FW_DOCUMENT_VERSION} from "@fiduswriter/document/schema/index"
6
6
  import {addAlert, findTarget, whenReady} from "fwtoolkit"
7
7
 
8
+ import type {
9
+ OldDocsResponse,
10
+ RevisionIdsResponse,
11
+ TemplateBaseResponse,
12
+ TemplateIdsResponse,
13
+ UserBibListResponse
14
+ } from "../api/index.js"
15
+ import type {FrontendApp} from "../types.js"
16
+
8
17
  export class DocMaintenance {
9
- app: any
18
+ app: FrontendApp
10
19
  batch: number
11
20
  revSavesLeft: number
12
21
  docTemplatesSavesLeft: number
13
22
 
14
- constructor(app: any) {
23
+ constructor(app: FrontendApp) {
15
24
  this.app = app
16
25
  this.batch = 0
17
26
  this.revSavesLeft = 0
@@ -40,7 +49,7 @@ export class DocMaintenance {
40
49
  getDocBatch(): void {
41
50
  this.batch++
42
51
  this.app.apiConnectors.maintenance.getAllOldDocs()
43
- .then((json: any) => {
52
+ .then((json: OldDocsResponse) => {
44
53
  const docs = window.JSON.parse(json.docs)
45
54
  if (docs.length) {
46
55
  addAlert("info", `${gettext("Downloaded batch")}: ${this.batch}`)
@@ -77,7 +86,7 @@ export class DocMaintenance {
77
86
  if (docVersion < 2) {
78
87
  p = this.app.apiConnectors.maintenance.getUserBibList({
79
88
  user_id: doc.fields.owner
80
- }).then((json: any) => {
89
+ }).then((json: UserBibListResponse) => {
81
90
  return json.bibList.reduce((db: any, item: any) => {
82
91
  const id = item["id"]
83
92
  const bibDBEntry: any = {}
@@ -121,7 +130,7 @@ export class DocMaintenance {
121
130
 
122
131
  updateDocumentTemplates(): void {
123
132
  addAlert("info", gettext("Updating document templates."))
124
- this.app.apiConnectors.maintenance.getAllTemplateIds().then((json: any) => {
133
+ this.app.apiConnectors.maintenance.getAllTemplateIds().then((json: TemplateIdsResponse) => {
125
134
  const count = json.template_ids.length
126
135
  if (count) {
127
136
  json.template_ids.forEach((templateId: number) =>
@@ -136,7 +145,7 @@ export class DocMaintenance {
136
145
 
137
146
  updateDocumentTemplate(id: number): void {
138
147
  this.app.apiConnectors.maintenance.getTemplateBase({id}).then(
139
- (json: any) => {
148
+ (json: TemplateBaseResponse) => {
140
149
  const oldDoc = {
141
150
  content: json.content,
142
151
  diffs: [],
@@ -173,7 +182,7 @@ export class DocMaintenance {
173
182
 
174
183
  updateRevisions(): void {
175
184
  addAlert("info", gettext("Updating saved revisions."))
176
- this.app.apiConnectors.maintenance.getAllRevisionIds().then((json: any) => {
185
+ this.app.apiConnectors.maintenance.getAllRevisionIds().then((json: RevisionIdsResponse) => {
177
186
  this.revSavesLeft = json.revision_ids.length
178
187
  if (this.revSavesLeft) {
179
188
  json.revision_ids.forEach((revId: number) => this.updateRevision(revId))
package/src/menu/index.ts CHANGED
@@ -2,19 +2,19 @@ import {keyName} from "w3c-keyname"
2
2
 
3
3
  import {dropdownSelect, whenReady} from "fwtoolkit"
4
4
  import {headerNavTemplate} from "./templates.js"
5
- import type {App, MenuPlugins, NavItem, SiteMenuLike} from "../types.js"
5
+ import type {FrontendApp, MenuPlugins, NavItem, SiteMenuLike} from "../types.js"
6
6
 
7
7
  // Bindings for the top menu on overview pages
8
8
 
9
9
  export class SiteMenu implements SiteMenuLike {
10
- app: App
10
+ app: FrontendApp
11
11
  activeItem: string | undefined
12
12
  navItems: NavItem[]
13
13
  listeners: {onKeydown?: (event: KeyboardEvent) => void}
14
14
  keyboardShortcuts: Map<string, NavItem>
15
15
  plugins?: Record<string, {init(): void}>
16
16
 
17
- constructor(app: App, activeItem?: string) {
17
+ constructor(app: FrontendApp, activeItem?: string) {
18
18
  this.app = app
19
19
  this.activeItem = activeItem
20
20
  this.navItems = [
@@ -209,7 +209,7 @@ export class SiteMenu implements SiteMenuLike {
209
209
  sessionStorage.removeItem(key)
210
210
  }
211
211
  }
212
- ;(this.app.apiConnectors as any).auth
212
+ this.app.apiConnectors.auth
213
213
  .logout()
214
214
  .then(() => {
215
215
  window.location.href =
@@ -23,12 +23,12 @@ export class FlatPage extends PreloginPage {
23
23
  }
24
24
 
25
25
  getPageData(): Promise<void> {
26
- return (this.app as any).apiConnectors.flatPage.get(this.url)
27
- .then((data: any) => {
28
- this.title = data.title
26
+ return this.app.apiConnectors.flatPage.get(this.url)
27
+ .then((data: Record<string, unknown>) => {
28
+ this.title = data.title as string
29
29
  this.contents = `<div class="fw-flatpage">
30
30
  <h1 class="fw-login-title">${data.title}</h1>
31
- ${data.content}
31
+ ${data.content as string}
32
32
  </div>`
33
33
  })
34
34
  .catch(() => {
@@ -1,6 +1,6 @@
1
1
  import {ensureCSS, setDocTitle, setLanguage, whenReady} from "fwtoolkit"
2
2
  import {FeedbackTab} from "../feedback/index.js"
3
- import type {RouteMap, Settings} from "../types.js"
3
+ import type {FrontendApp} from "../types.js"
4
4
 
5
5
  import {basePreloginTemplate} from "./templates.js"
6
6
 
@@ -16,12 +16,8 @@ interface HeaderLink {
16
16
  link: string
17
17
  }
18
18
 
19
- export interface PreloginApp {
20
- routes: RouteMap
21
- settings: Settings
22
- goTo: (url: string) => void
23
- name: string
24
- config: Record<string, unknown>
19
+ export interface PreloginApp extends FrontendApp {
20
+ config: FrontendApp
25
21
  }
26
22
 
27
23
  interface PluginExport {
@@ -168,7 +164,7 @@ export class PreloginPage {
168
164
  })
169
165
  document.body = this.dom
170
166
  ensureCSS([staticUrl("css/prelogin.css")])
171
- setDocTitle(this.title, this.app)
167
+ setDocTitle(this.title, this.app as {name: string})
172
168
  const feedbackTab = new FeedbackTab(this.app)
173
169
  feedbackTab.init()
174
170
  }