@iebh/tera-fy 1.13.3 → 1.14.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 CHANGED
@@ -4,7 +4,6 @@ TERA website worker, intended to be embedded with TERA tools.
4
4
 
5
5
  * [TERA-fy API (API explorer)](https://iebh.github.io/TERA-fy/)
6
6
  * [TERA-fy API (Markdown, single page)](./api.md)
7
- * [API playground](https://iebh.github.io/TERA-fy/playground.html)
8
7
  * [TERA-Explorer](https://github.com/IEBH/TERA-explorer) - A simple example project using TERA-fy
9
8
  - [Live standalone version](https://explorer.tera-tools.com/)
10
9
  - [Live Embedded version](https://tera-tools.com/explorer)
package/api.md CHANGED
@@ -77,53 +77,53 @@
77
77
  * [Parameters][73]
78
78
  * [selectProjectFile][74]
79
79
  * [Parameters][75]
80
- * [getProjectFiles][76]
81
- * [Parameters][77]
82
- * [getProjectFile][78]
83
- * [Parameters][79]
84
- * [createProjectFile][80]
85
- * [Parameters][81]
86
- * [handshake][82]
87
- * [Properties][83]
88
- * [setServerVerbosity][84]
89
- * [Parameters][85]
90
- * [User][86]
91
- * [Properties][87]
92
- * [getUser][88]
93
- * [requireUser][89]
94
- * [Parameters][90]
95
- * [Project][91]
96
- * [getProject][92]
97
- * [getProjects][93]
98
- * [setActiveProject][94]
80
+ * [handshake][76]
81
+ * [Properties][77]
82
+ * [setServerVerbosity][78]
83
+ * [Parameters][79]
84
+ * [User][80]
85
+ * [Properties][81]
86
+ * [getUser][82]
87
+ * [requireUser][83]
88
+ * [Parameters][84]
89
+ * [Project][85]
90
+ * [getProject][86]
91
+ * [getProjects][87]
92
+ * [setActiveProject][88]
93
+ * [Parameters][89]
94
+ * [requireProject][90]
95
+ * [Parameters][91]
96
+ * [selectProject][92]
97
+ * [Parameters][93]
98
+ * [getProjectState][94]
99
99
  * [Parameters][95]
100
- * [requireProject][96]
100
+ * [setProjectState][96]
101
101
  * [Parameters][97]
102
- * [selectProject][98]
102
+ * [setProjectStateDefaults][98]
103
103
  * [Parameters][99]
104
- * [getProjectState][100]
105
- * [Parameters][101]
106
- * [setProjectState][102]
107
- * [Parameters][103]
108
- * [setProjectStateDefaults][104]
109
- * [Parameters][105]
110
- * [setProjectStateFlush][106]
111
- * [setProjectStateRefresh][107]
112
- * [saveProjectState][108]
113
- * [replaceProjectState][109]
114
- * [Parameters][110]
115
- * [applyProjectStatePatch][111]
116
- * [Parameters][112]
117
- * [subscribeProjectState][113]
118
- * [FileFilters][114]
119
- * [Properties][115]
120
- * [selectProjectFile][116]
104
+ * [setProjectStateFlush][100]
105
+ * [setProjectStateRefresh][101]
106
+ * [saveProjectState][102]
107
+ * [replaceProjectState][103]
108
+ * [Parameters][104]
109
+ * [applyProjectStatePatch][105]
110
+ * [Parameters][106]
111
+ * [subscribeProjectState][107]
112
+ * [FileFilters][108]
113
+ * [Properties][109]
114
+ * [selectProjectFile][110]
115
+ * [Parameters][111]
116
+ * [getProjectFiles][112]
117
+ * [Parameters][113]
118
+ * [getProjectFileContents][114]
119
+ * [Parameters][115]
120
+ * [getProjectFile][116]
121
121
  * [Parameters][117]
122
- * [getProjectFileContents][118]
122
+ * [createProjectFile][118]
123
123
  * [Parameters][119]
124
124
  * [deleteProjectFile][120]
125
125
  * [Parameters][121]
126
- * [setProjectFile][122]
126
+ * [setProjectFileContents][122]
127
127
  * [Parameters][123]
128
128
  * [selectProjectLibrary][124]
129
129
  * [Parameters][125]
@@ -274,11 +274,13 @@ Fetch the raw file contents as a Blob
274
274
 
275
275
  #### Parameters
276
276
 
277
- * `options` **[Object][149]?** Additioanl options to mutate behaviourreturns {Blob} The eventual raw file contents as a Blob
277
+ * `options` **[Object][149]?** Additioanl options to mutate behaviour
278
+
279
+ Returns **[Blob][152]** The eventual raw file contents as a Blob
278
280
 
279
281
  ### setContents
280
282
 
281
- * **See**: setProjectFile()
283
+ * **See**: setProjectFileContents()
282
284
 
283
285
  Overwrite the contents of a file with new content
284
286
 
@@ -304,8 +306,7 @@ Overwrite the contents of a file with a new collection of Reflib refs
304
306
 
305
307
  #### Parameters
306
308
 
307
- * `refs`  
308
- * `Collection` **[Array][154]\<RefLibRef>** of references for the selected library
309
+ * `refs` **[Array][154]\<RefLibRef>** Collection of references for the selected library
309
310
 
310
311
  Returns **[Promise][155]** A promise which resolves when the operation has completed
311
312
 
@@ -411,7 +412,7 @@ Call an RPC function in the server instance
411
412
  #### Parameters
412
413
 
413
414
  * `method` **[String][148]** The method name to call
414
- * `args` **...any**&#x20;
415
+ * `args` **...any?** Optional arguments to pass to the function
415
416
 
416
417
  Returns **[Promise][155]\<any>** The resolved output of the server function
417
418
 
@@ -421,8 +422,9 @@ Accept an incoming message
421
422
 
422
423
  #### Parameters
423
424
 
424
- * `rawMessage` &#x20;
425
- * `Raw` **[MessageEvent][159]** message event to process
425
+ * `rawMessage` **[MessageEvent][159]** Raw message event to process
426
+
427
+ Returns **[Promise][155]** A promise which will resolve when the message has been processed
426
428
 
427
429
  ### acceptPostboxes
428
430
 
@@ -509,7 +511,7 @@ This function will only act if `settings.devMode` is truthy
509
511
 
510
512
  #### Parameters
511
513
 
512
- * `msg` **...any**&#x20;
514
+ * `msg` **...any?** Output to show
513
515
  * `method` **(`"INFO"` | `"LOG"` | `"WARN"` | `"ERROR"`)** Logging method to use (optional, default `'LOG'`)
514
516
  * `verboseLevel` **[Number][151]** The verbosity level to trigger at. If `settings.verbosity` is lower than this, the message is ignored (optional, default `1`)
515
517
 
@@ -548,9 +550,8 @@ Include a TeraFy client plugin
548
550
 
549
551
  #### Parameters
550
552
 
551
- * `mod` &#x20;
553
+ * `mod` **[Object][149]** The module function to include. Invoked as `(teraClient:TeraFy, options:Object)`
552
554
  * `options` **[Object][149]?** Additional options to mutate behaviour during construction (pass options to init() to intialize later options)
553
- * `The` **[Object][149]** module function to include. Invoked as `(teraClient:TeraFy, options:Object)`
554
555
 
555
556
  Returns **[TeraFy][30]** This chainable terafy instance
556
557
 
@@ -598,46 +599,6 @@ This is an pre-requisite step for requireProject()
598
599
 
599
600
  Returns **[Promise][155]** A promise which will resolve if the there is a user and they are logged in
600
601
 
601
- ### getProjectFiles
602
-
603
- Fetch the files associated with a given project
604
-
605
- #### Parameters
606
-
607
- * `options` **[Object][149]** Options which mutate behaviour
608
-
609
- * `options.autoRequire` **[Boolean][157]** Run `requireProject()` automatically before continuing (optional, default `true`)
610
- * `options.lazy` **[Boolean][157]** If true, use the fastest method to retrieve the file list such as the cache. If false, force a refresh each time (optional, default `true`)
611
- * `options.meta` **[Boolean][157]** Pull meta information for each file entity (optional, default `true`)
612
-
613
- Returns **[Promise][155]<[Array][154]<[ProjectFile][1]>>** A collection of project files for the given project
614
-
615
- ### getProjectFile
616
-
617
- Fetch a project file by its name
618
-
619
- #### Parameters
620
-
621
- * `id` &#x20;
622
- * `name` **[String][148]** The name + relative directory path component
623
- * `options` **([Object][149] | [String][148])?** Additional options to mutate behaviour, if a string is given `options.subkey` is assumed
624
-
625
- * `options.subkey` **[String][148]?** If specified only the extracted subkey is returned rather than the full object
626
- * `options.cache` **[Boolean][157]** Use the existing file cache if possible, set to false to force a refresh of files from the server first (optional, default `true`)
627
-
628
- Returns **[Promise][155]<[ProjectFile][1]>** The eventual fetched ProjectFile (or requested subkey)
629
-
630
- ### createProjectFile
631
-
632
- Create a new file
633
- This creates an empty file which can then be written to
634
-
635
- #### Parameters
636
-
637
- * `name` **[String][148]** The name + relative directory path component
638
-
639
- Returns **[Promise][155]<[ProjectFile][1]>** The eventual ProjectFile created
640
-
641
602
  ## handshake
642
603
 
643
604
  Return basic server information as a form of validation
@@ -671,7 +632,7 @@ User / active session within TERA
671
632
 
672
633
  Fetch the current session user
673
634
 
674
- Returns **[Promise][155]<[User][86]>** The current logged in user or null if none
635
+ Returns **[Promise][155]<[User][80]>** The current logged in user or null if none
675
636
 
676
637
  ## requireUser
677
638
 
@@ -685,7 +646,7 @@ This is an pre-requisite step for requireProject()
685
646
 
686
647
  * `options.forceRetry` **[Boolean][157]** Forcabily try to refresh the user state (optional, default `false`)
687
648
 
688
- Returns **[Promise][155]<[User][86]>** The current logged in user or null if none
649
+ Returns **[Promise][155]<[User][80]>** The current logged in user or null if none
689
650
 
690
651
  ## Project
691
652
 
@@ -695,13 +656,13 @@ Project entry within TERA
695
656
 
696
657
  Get the currently active project, if any
697
658
 
698
- Returns **[Promise][155]<([Project][91] | null)>** The currently active project, if any
659
+ Returns **[Promise][155]<([Project][85] | null)>** The currently active project, if any
699
660
 
700
661
  ## getProjects
701
662
 
702
663
  Get a list of projects the current session user has access to
703
664
 
704
- Returns **[Promise][155]<[Array][154]<[Project][91]>>** Collection of projects the user has access to
665
+ Returns **[Promise][155]<[Array][154]<[Project][85]>>** Collection of projects the user has access to
705
666
 
706
667
  ## setActiveProject
707
668
 
@@ -725,7 +686,7 @@ Note that this function will percist in asking the uesr even if they try to canc
725
686
  * `options.noSelectTitle` **[String][148]** Dialog title when warning the user they need to select something (optional, default `'Select project'`)
726
687
  * `options.noSelectBody` **[String][148]** Dialog body when warning the user they need to select something (optional, default `'A project needs to be selected to continue'`)
727
688
 
728
- Returns **[Promise][155]<[Project][91]>** The active project
689
+ Returns **[Promise][155]<[Project][85]>** The active project
729
690
 
730
691
  ## selectProject
731
692
 
@@ -739,7 +700,7 @@ Prompt the user to select a project from those available
739
700
  * `options.allowCancel` **[Boolean][157]** Advertise cancelling the operation, the dialog can still be cancelled by closing it (optional, default `true`)
740
701
  * `options.setActive` **[Boolean][157]** Also set the project as active when selected (optional, default `false`)
741
702
 
742
- Returns **[Promise][155]<[Project][91]>** The active project
703
+ Returns **[Promise][155]<[Project][85]>** The active project
743
704
 
744
705
  ## getProjectState
745
706
 
@@ -859,16 +820,30 @@ Prompt the user to select a library to operate on
859
820
  * `options.title` **[String][148]** The title of the dialog to display (optional, default `"Select a file"`)
860
821
  * `options.hint` **([String][148] | [Array][154]<[String][148]>)?** Hints to identify the file to select in array order of preference
861
822
  * `options.save` **[Boolean][157]** Set to truthy if saving a new file, UI will adjust to allowing overwrite OR new file name input (optional, default `false`)
862
- * `options.filters` **[FileFilters][114]?** Optional file filters
823
+ * `options.filters` **[FileFilters][108]?** Optional file filters
863
824
  * `options.allowUpload` **[Boolean][157]** Allow uploading new files (optional, default `true`)
864
825
  * `options.allowRefresh` **[Boolean][157]** Allow the user to manually refresh the file list (optional, default `true`)
865
826
  * `options.allowDownloadZip` **[Boolean][157]** Allow the user to download a Zip of all files (optional, default `true`)
866
827
  * `options.allowCancel` **[Boolean][157]** Allow cancelling the operation. Will throw `'CANCEL'` as the promise rejection if acationed (optional, default `true`)
867
828
  * `options.autoRequire` **[Boolean][157]** Run `requireProject()` automatically before continuing (optional, default `true`)
868
- * `options.filter` **[FileFilters][114]?** Optional file filters
829
+ * `options.filter` **[FileFilters][108]?** Optional file filters
869
830
 
870
831
  Returns **[Promise][155]<[ProjectFile][1]>** The eventually selected file, if in save mode new files are created as stubs
871
832
 
833
+ ## getProjectFiles
834
+
835
+ Fetch the files associated with a given project
836
+
837
+ ### Parameters
838
+
839
+ * `options` **[Object][149]** Options which mutate behaviour
840
+
841
+ * `options.autoRequire` **[Boolean][157]** Run `requireProject()` automatically before continuing (optional, default `true`)
842
+ * `options.lazy` **[Boolean][157]** If true, use the fastest method to retrieve the file list such as the cache. If false, force a refresh each time (optional, default `true`)
843
+ * `options.meta` **[Boolean][157]** Pull meta information for each file entity (optional, default `true`)
844
+
845
+ Returns **[Promise][155]<[Array][154]<[ProjectFile][1]>>** A collection of project files for the given project
846
+
872
847
  ## getProjectFileContents
873
848
 
874
849
  Fetch the raw contents of a file by its ID
@@ -882,6 +857,31 @@ Fetch the raw contents of a file by its ID
882
857
 
883
858
  Returns **any** The file contents in the requested format
884
859
 
860
+ ## getProjectFile
861
+
862
+ Fetch a project file by its name
863
+
864
+ ### Parameters
865
+
866
+ * `id` **[String][148]** The name + relative directory path component
867
+ * `options` **([Object][149] | [String][148])?** Additional options to mutate behaviour, if a string is given `options.subkey` is assumed
868
+
869
+ * `options.subkey` **[String][148]?** If specified only the extracted subkey is returned rather than the full object
870
+ * `options.cache` **[Boolean][157]** Use the existing file cache if possible, set to false to force a refresh of files from the server first (optional, default `true`)
871
+
872
+ Returns **[Promise][155]<[ProjectFile][1]>** The eventual fetched ProjectFile (or requested subkey)
873
+
874
+ ## createProjectFile
875
+
876
+ Create a new file
877
+ This creates an empty file which can then be written to
878
+
879
+ ### Parameters
880
+
881
+ * `name` **[String][148]** The name + relative directory path component
882
+
883
+ Returns **[Promise][155]<[ProjectFile][1]>** The eventual ProjectFile created
884
+
885
885
  ## deleteProjectFile
886
886
 
887
887
  Remove a project file by its ID
@@ -892,7 +892,7 @@ Remove a project file by its ID
892
892
 
893
893
  Returns **[Promise][155]** A promise which resolves when the operation has completed
894
894
 
895
- ## setProjectFile
895
+ ## setProjectFileContents
896
896
 
897
897
  Replace a project files contents
898
898
 
@@ -918,7 +918,8 @@ Prompt the user to select a library to operate on and return a array of referenc
918
918
  * `options.allowDownloadZip` **[Boolean][157]** Allow the user to download a Zip of all files (optional, default `true`)
919
919
  * `options.allowCancel` **[Boolean][157]** Allow cancelling the operation. Will throw `'CANCEL'` as the promise rejection if acationed (optional, default `true`)
920
920
  * `options.autoRequire` **[Boolean][157]** Run `requireProject()` automatically before continuing (optional, default `true`)
921
- * `options.filters` **[FileFilters][114]?** Optional file filters, defaults to citation library selection only
921
+ * `options.filters` **[FileFilters][108]?** Optional file filters, defaults to citation library selection only
922
+ * `options` **...any?** Additional options - see `getProjectLibrary()`
922
923
 
923
924
  Returns **[Promise][155]<[Array][154]\<Ref>>** A collection of references from the selected file
924
925
 
@@ -981,7 +982,7 @@ This is usually called by a tool nested within the tera-tools.com embed
981
982
 
982
983
  * `options` **([Object][149] | [String][148])** Context information about the page, if this is a string, its assumed to popupate `url`
983
984
 
984
- * `options.url` **[String][148]?** The URL to restore on next refresh
985
+ * `options.path` **[String][148]?** The URL path segment to restore on next refresh
985
986
  * `options.title` **[String][148]?** The page title associated with the path
986
987
 
987
988
  ## uiAlert
@@ -1240,91 +1241,91 @@ This function is ideally called within a requestFocus() wrapper
1240
1241
 
1241
1242
  [75]: #parameters-19
1242
1243
 
1243
- [76]: #getprojectfiles
1244
+ [76]: #handshake
1244
1245
 
1245
- [77]: #parameters-20
1246
+ [77]: #properties-4
1246
1247
 
1247
- [78]: #getprojectfile
1248
+ [78]: #setserververbosity
1248
1249
 
1249
- [79]: #parameters-21
1250
+ [79]: #parameters-20
1250
1251
 
1251
- [80]: #createprojectfile
1252
+ [80]: #user
1252
1253
 
1253
- [81]: #parameters-22
1254
+ [81]: #properties-5
1254
1255
 
1255
- [82]: #handshake
1256
+ [82]: #getuser
1256
1257
 
1257
- [83]: #properties-4
1258
+ [83]: #requireuser
1258
1259
 
1259
- [84]: #setserververbosity
1260
+ [84]: #parameters-21
1260
1261
 
1261
- [85]: #parameters-23
1262
+ [85]: #project
1262
1263
 
1263
- [86]: #user
1264
+ [86]: #getproject
1264
1265
 
1265
- [87]: #properties-5
1266
+ [87]: #getprojects
1266
1267
 
1267
- [88]: #getuser
1268
+ [88]: #setactiveproject
1268
1269
 
1269
- [89]: #requireuser
1270
+ [89]: #parameters-22
1270
1271
 
1271
- [90]: #parameters-24
1272
+ [90]: #requireproject
1272
1273
 
1273
- [91]: #project
1274
+ [91]: #parameters-23
1274
1275
 
1275
- [92]: #getproject
1276
+ [92]: #selectproject
1276
1277
 
1277
- [93]: #getprojects
1278
+ [93]: #parameters-24
1278
1279
 
1279
- [94]: #setactiveproject
1280
+ [94]: #getprojectstate
1280
1281
 
1281
1282
  [95]: #parameters-25
1282
1283
 
1283
- [96]: #requireproject
1284
+ [96]: #setprojectstate
1284
1285
 
1285
1286
  [97]: #parameters-26
1286
1287
 
1287
- [98]: #selectproject
1288
+ [98]: #setprojectstatedefaults
1288
1289
 
1289
1290
  [99]: #parameters-27
1290
1291
 
1291
- [100]: #getprojectstate
1292
+ [100]: #setprojectstateflush
1292
1293
 
1293
- [101]: #parameters-28
1294
+ [101]: #setprojectstaterefresh
1294
1295
 
1295
- [102]: #setprojectstate
1296
+ [102]: #saveprojectstate
1296
1297
 
1297
- [103]: #parameters-29
1298
+ [103]: #replaceprojectstate
1298
1299
 
1299
- [104]: #setprojectstatedefaults
1300
+ [104]: #parameters-28
1300
1301
 
1301
- [105]: #parameters-30
1302
+ [105]: #applyprojectstatepatch
1302
1303
 
1303
- [106]: #setprojectstateflush
1304
+ [106]: #parameters-29
1304
1305
 
1305
- [107]: #setprojectstaterefresh
1306
+ [107]: #subscribeprojectstate
1306
1307
 
1307
- [108]: #saveprojectstate
1308
+ [108]: #filefilters
1308
1309
 
1309
- [109]: #replaceprojectstate
1310
+ [109]: #properties-6
1310
1311
 
1311
- [110]: #parameters-31
1312
+ [110]: #selectprojectfile-1
1312
1313
 
1313
- [111]: #applyprojectstatepatch
1314
+ [111]: #parameters-30
1314
1315
 
1315
- [112]: #parameters-32
1316
+ [112]: #getprojectfiles
1316
1317
 
1317
- [113]: #subscribeprojectstate
1318
+ [113]: #parameters-31
1318
1319
 
1319
- [114]: #filefilters
1320
+ [114]: #getprojectfilecontents
1320
1321
 
1321
- [115]: #properties-6
1322
+ [115]: #parameters-32
1322
1323
 
1323
- [116]: #selectprojectfile-1
1324
+ [116]: #getprojectfile
1324
1325
 
1325
1326
  [117]: #parameters-33
1326
1327
 
1327
- [118]: #getprojectfilecontents
1328
+ [118]: #createprojectfile
1328
1329
 
1329
1330
  [119]: #parameters-34
1330
1331
 
@@ -1332,7 +1333,7 @@ This function is ideally called within a requestFocus() wrapper
1332
1333
 
1333
1334
  [121]: #parameters-35
1334
1335
 
1335
- [122]: #setprojectfile
1336
+ [122]: #setprojectfilecontents
1336
1337
 
1337
1338
  [123]: #parameters-36
1338
1339