@iebh/tera-fy 2.3.10 → 2.3.12

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 (82) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/api.md +8 -11
  3. package/dist/plugin.vue2.es2019.js +28 -27
  4. package/dist/terafy.bootstrapper.es2019.js +2 -2
  5. package/dist/terafy.bootstrapper.js +2 -2
  6. package/dist/terafy.es2019.js +5 -5
  7. package/dist/terafy.js +5 -5
  8. package/eslint.config.js +4 -66
  9. package/lib/{projectFile.ts → projectFile.js} +52 -76
  10. package/lib/syncro/{entities.ts → entities.js} +14 -83
  11. package/lib/syncro/{keyed.ts → keyed.js} +46 -68
  12. package/lib/syncro/{syncro.ts → syncro.js} +104 -136
  13. package/lib/{terafy.bootstrapper.ts → terafy.bootstrapper.js} +20 -30
  14. package/lib/{terafy.client.ts → terafy.client.js} +85 -84
  15. package/lib/{terafy.proxy.ts → terafy.proxy.js} +12 -26
  16. package/lib/{terafy.server.ts → terafy.server.js} +204 -229
  17. package/package.json +20 -39
  18. package/plugins/{base.ts → base.js} +3 -5
  19. package/plugins/{firebase.ts → firebase.js} +22 -21
  20. package/plugins/{vite.ts → vite.js} +3 -3
  21. package/plugins/{vue2.ts → vue2.js} +8 -10
  22. package/plugins/{vue3.ts → vue3.js} +7 -10
  23. package/utils/mixin.js +15 -0
  24. package/utils/{pathTools.ts → pathTools.js} +8 -9
  25. package/widgets/tera-file-select.vue +1 -1
  26. package/dist/lib/projectFile.d.ts +0 -190
  27. package/dist/lib/projectFile.js +0 -305
  28. package/dist/lib/projectFile.js.map +0 -1
  29. package/dist/lib/syncro/entities.d.ts +0 -34
  30. package/dist/lib/syncro/entities.js +0 -212
  31. package/dist/lib/syncro/entities.js.map +0 -1
  32. package/dist/lib/syncro/keyed (Rhino's conflicted copy 2026-05-10).js +0 -287
  33. package/dist/lib/syncro/keyed.d.ts +0 -95
  34. package/dist/lib/syncro/keyed.js +0 -288
  35. package/dist/lib/syncro/keyed.js (Rhino's conflicted copy 2026-05-10).map +0 -1
  36. package/dist/lib/syncro/keyed.js.map +0 -1
  37. package/dist/lib/syncro/syncro (Rhino's conflicted copy 2026-05-10).js +0 -765
  38. package/dist/lib/syncro/syncro.d (Rhino's conflicted copy 2026-05-10).ts +0 -336
  39. package/dist/lib/syncro/syncro.d.ts +0 -343
  40. package/dist/lib/syncro/syncro.js +0 -771
  41. package/dist/lib/syncro/syncro.js (Rhino's conflicted copy 2026-05-10).map +0 -1
  42. package/dist/lib/syncro/syncro.js.map +0 -1
  43. package/dist/lib/terafy.bootstrapper.d.ts +0 -42
  44. package/dist/lib/terafy.bootstrapper.js +0 -129
  45. package/dist/lib/terafy.bootstrapper.js.map +0 -1
  46. package/dist/lib/terafy.client.d.ts +0 -555
  47. package/dist/lib/terafy.client.js +0 -1153
  48. package/dist/lib/terafy.client.js.map +0 -1
  49. package/dist/lib/terafy.proxy.d.ts +0 -66
  50. package/dist/lib/terafy.proxy.js +0 -130
  51. package/dist/lib/terafy.proxy.js.map +0 -1
  52. package/dist/lib/terafy.server.d.ts +0 -697
  53. package/dist/lib/terafy.server.js +0 -2062
  54. package/dist/lib/terafy.server.js.map +0 -1
  55. package/dist/plugin.vue2.es2019 (Rhino's conflicted copy 2026-05-10).js +0 -1271
  56. package/dist/plugins/base.d.ts +0 -20
  57. package/dist/plugins/base.js +0 -22
  58. package/dist/plugins/base.js.map +0 -1
  59. package/dist/plugins/firebase.d.ts +0 -62
  60. package/dist/plugins/firebase.js +0 -123
  61. package/dist/plugins/firebase.js.map +0 -1
  62. package/dist/plugins/vite.d.ts +0 -12
  63. package/dist/plugins/vite.js +0 -22
  64. package/dist/plugins/vite.js.map +0 -1
  65. package/dist/plugins/vue2.d.ts +0 -67
  66. package/dist/plugins/vue2.js +0 -104
  67. package/dist/plugins/vue2.js.map +0 -1
  68. package/dist/plugins/vue3.d.ts +0 -63
  69. package/dist/plugins/vue3.js +0 -93
  70. package/dist/plugins/vue3.js.map +0 -1
  71. package/dist/utils/mixin.d.ts +0 -11
  72. package/dist/utils/mixin.js +0 -15
  73. package/dist/utils/mixin.js.map +0 -1
  74. package/dist/utils/pDefer.d.ts +0 -16
  75. package/dist/utils/pDefer.js +0 -19
  76. package/dist/utils/pDefer.js.map +0 -1
  77. package/dist/utils/pathTools.d.ts +0 -70
  78. package/dist/utils/pathTools.js +0 -120
  79. package/dist/utils/pathTools.js.map +0 -1
  80. package/tsconfig.json +0 -30
  81. package/utils/mixin.ts +0 -18
  82. package/utils/pDefer.ts +0 -27
@@ -1,697 +0,0 @@
1
- declare global {
2
- interface Window {
3
- panic(text: any): void;
4
- }
5
- }
6
- interface UiWindowPermissions {
7
- popup?: boolean;
8
- location?: boolean;
9
- menubar?: boolean;
10
- status?: boolean;
11
- scrollbars?: boolean;
12
- }
13
- interface UiWindowOptions {
14
- width?: number;
15
- height?: number;
16
- center?: boolean;
17
- permissions?: UiWindowPermissions;
18
- }
19
- /**
20
- * Server-side functions available to the Tera-Fy client library
21
- *
22
- * @class TeraFyServer
23
- */
24
- export default class TeraFyServer {
25
- /**
26
- * Various settings to configure behaviour
27
- *
28
- * @type {Object}
29
- * @property {Boolean} devMode Operate in devMode - i.e. force outer refresh when encountering an existing TeraFy instance
30
- * @property {Number} verbosity Verbosity level, the higher the more chatty TeraFY will be. Set to zero to disable all `debug()` call output
31
- * @property {Number} subscribeTimeout Acceptable timeout period for subscribers to acklowledge a project change event, failing to respond will result in the subscriber being removed from the available subscriber list
32
- * @property {String} restrictOrigin URL to restrict communications to
33
- * @property {String} projectId The project to use as the default reference when calling various APIs
34
- * @property {Number} serverMode The current server mode matching `SERVERMODE_*`
35
- * @property {String} siteUrl The main site absolute URL
36
- * @property {String} sitePathLogin Either an absolute URL or the relative path (taken from `siteUrl`) when trying to log in the user
37
- * @property {Boolean} embedWorkaround Try to use `getUserViaEmbedWorkaround()` to force a login via popup if the user is running in local mode (see function docs for more details). This is toggled to false after the first run
38
- */
39
- settings: any;
40
- static SERVERMODE_NONE: number;
41
- static SERVERMODE_EMBEDDED: number;
42
- static SERVERMODE_FRAME: number;
43
- static SERVERMODE_POPUP: number;
44
- static SERVERMODE_TERA: number;
45
- /**
46
- * Create a context based on a shallow copy of this instance + additional functionality for the incoming MessageEvent
47
- * This is used by acceptMessage to provide a means to reply / send messages to the originator
48
- *
49
- * @param {MessageEvent} e Original message event to base the new context on
50
- *
51
- * @returns {Object} A context, which is this instance extended with additional properties
52
- */
53
- createContext(e: MessageEvent): any;
54
- /**
55
- * Create a new client context from the server to the client even if the client hasn't requested the communication
56
- * This function is used to send unsolicited communications from the server->client in contrast to createContext() which _replies_ from client->server->client
57
- *
58
- * @returns {Object} A context, which is this instance extended with additional properties
59
- */
60
- getClientContext(): any;
61
- /**
62
- * MessageEvent context
63
- * Only available if the context was created via `createContext()`
64
- *
65
- * @type {MessageEvent}
66
- */
67
- messageEvent: MessageEvent | null;
68
- /**
69
- * Request an RPC call from the original sender of a mesasge
70
- * This function only works if the context was sub-classed via `createContext()`
71
- *
72
- * @param {String} method The method name to call
73
- * @param {...*} [args] Optional arguments to pass to the function
74
- *
75
- * @returns {Promise<*>} The resolved output of the server function
76
- */
77
- senderRpc(method: string, ...args: any[]): Promise<any>;
78
- /**
79
- * Return basic server information as a form of validation
80
- *
81
- * @returns {Promise<Object>} Basic promise result
82
- * @property {Date} date Server date
83
- */
84
- handshake(): Promise<any>;
85
- /**
86
- * Send a message + wait for a response object
87
- * This method should likely be part of the context returned by createContext
88
- * Assuming it's intended to work on the base class referencing a stored messageEvent
89
- *
90
- * @param {Object} message Message object to send
91
- * @returns {Promise<*>} A promise which resolves when the operation has completed with the remote reply
92
- */
93
- send(message: any): Promise<any>;
94
- /**
95
- * Send raw message content to the client
96
- * Unlike send() this method does not expect any response
97
- *
98
- * @param {Object} message Message object to send
99
- * @param {Window} sendVia Window context to dispatch the message via if its not the same as the regular window
100
- */
101
- sendRaw(message: any, sendVia?: any): void;
102
- /**
103
- * Setter to translate between string inputs and the server modes in SERVERMODE_*
104
- *
105
- * @param {String} mode The server mode to set to
106
- */
107
- setServerMode(mode: string): void;
108
- /**
109
- * Accept a message from the parent event listener
110
- *
111
- * @param {MessageEvent} rawMessage Raw message event to process
112
- */
113
- acceptMessage(rawMessage: MessageEvent): void;
114
- /**
115
- * Listening postboxes, these correspond to outgoing message IDs that expect a response
116
- */
117
- acceptPostboxes: Record<string, any>;
118
- /**
119
- * Wrapper function which runs a callback after the frontend UI has obtained focus
120
- * This is to fix the issue where the front-end needs to switch between a regular webpage and a focused TERA iFrame wrapper
121
- * Any use of $prompt or other UI calls should be wrapped here
122
- *
123
- * @param {Function} cb Async function to run in focused mode
124
- *
125
- * @returns {Promise<*>} A promise which resolves with the resulting inner callback payload
126
- */
127
- requestFocus(cb: () => Promise<any>): Promise<any>;
128
- /**
129
- * Emit messages down into all connected clients
130
- * Note that emitted messages have no response - they are sent to clients only with no return value
131
- *
132
- * @param {String} event The event name to emit
133
- * @param {...*} [args] Optional event payload to send
134
- * @returns {Promise} A promise which resolves when the transmission has completed
135
- */
136
- emitClients(event: string, ...args: any[]): Promise<void>;
137
- /**
138
- * RPC callback to set the server verbostiy level
139
- *
140
- * @param {Number} verbosity The desired server verbosity level
141
- */
142
- setServerVerbosity(verbosity: number): void;
143
- /**
144
- * User / active session within TERA
145
- * @class User
146
- * @property {String} id Unique identifier of the user
147
- * @property {String} email The email address of the current user
148
- * @property {String} name The provided full name of the user
149
- * @property {Boolean} isMember Whether the active user has a TERA Membership
150
- */
151
- /**
152
- * Fetch the current session user
153
- *
154
- * @param {Object} [options] Additional options to mutate behaviour
155
- * @param {Boolean} [options.forceRetry=false] Forcabily try to refresh the user state
156
- * @param {Boolean} [options.waitPromises=true] Wait for $auth + $membership to resolve before fetching the user (mainly internal use)
157
- *
158
- * @returns {Promise<User>} The current logged in user or null if none
159
- */
160
- getUser(options?: any): Promise<any | null>;
161
- /**
162
- * Require a user login to TERA
163
- * If there is no user OR they are not logged in a prompt is shown to go and do so
164
- * This is an pre-requisite step for requireProject()
165
- *
166
- * @returns {Promise<User>} A promise which will resolve if the there is a user and they are logged in
167
- */
168
- requireUser(): Promise<any>;
169
- /**
170
- * Provide an object of credentials for 3rd party services like Firebase/Supabase
171
- *
172
- * @returns An object containing 3rd party service credentials
173
- */
174
- getCredentials(): {
175
- firebaseApiKey: string;
176
- firebaseAppId: string;
177
- firebaseAuthDomain: string;
178
- firebaseProjectId: string;
179
- kindeClientId: string;
180
- kindeDomain: string;
181
- logrocketProject: string;
182
- supabaseKey: string;
183
- supabaseUrl: string;
184
- };
185
- /**
186
- * Get auth credentials for kinde
187
- * @returns The kinde auth token
188
- */
189
- getKindeToken(): Promise<string>;
190
- /**
191
- * In embed mode only - create a popup window and try to auth via that
192
- *
193
- * When in embed mode we can't store local state (Cookies without SameSite + LocalStorage etc.) so the only way to auth the user in the restricted envionment:
194
- *
195
- * 1. Try to read state from LocalStorage (if so, skip everything else)
196
- * 2. Create a popup - which can escape the security container - and trigger a login
197
- * 3. Listen locally for a message from the popup which it will transmit the authed user to its original window opener
198
- * 3. Stash the state in LocalStorage to avoid this in future
199
- *
200
- * This workaround is only needed when developing with TERA in an embed window - i.e. local dev / stand alone websites
201
- * Its annoying but I've tried everything else as a security method to get Non-Same-Origin sites to talk to each other
202
- * - MC 2024-04-03
203
- *
204
- * @returns {Promise} A promise which resolves when the operation has completed
205
- */
206
- getUserViaEmbedWorkaround(): Promise<void>;
207
- /**
208
- * Project entry within TERA
209
- * @class Project
210
- * @property {String} id The Unique ID of the project
211
- * @property {String} name The name of the project
212
- * @property {String} created The creation date of the project as an ISO string
213
- * @property {Boolean} isOwner Whether the current session user is the owner of the project
214
- */
215
- /**
216
- * Get the currently active project, if any
217
- *
218
- * @returns {Promise<Project|null>} The currently active project, if any
219
- */
220
- getProject(): Promise<any | null>;
221
- /**
222
- * Get a list of projects the current session user has access to
223
- *
224
- * @returns {Promise<Array<Project>>} Collection of projects the user has access to
225
- */
226
- getProjects(): Promise<any[]>;
227
- /**
228
- * Set the currently active project within TERA
229
- *
230
- * @param {Object|String} project The project to set as active - either the full Project object or its ID
231
- * @returns {Promise} A promise which resolves when the operation has completed
232
- */
233
- setActiveProject(project: any): Promise<void>;
234
- /**
235
- * Ask the user to select a project from those available - if one isn't already active
236
- * Note that this function will percist in asking the uesr even if they try to cancel
237
- *
238
- * @param {Object} [options] Additional options to mutate behaviour
239
- * @param {Boolean} [options.autoRequireUser=true] Automatically call `requireUser()` before trying to fetch a list of projects
240
- * @param {Boolean} [options.autoSetActiveProject=true] After selecting a project set that project as active in TERA
241
- * @param {String} [options.title="Select a project to work with"] The title of the dialog to display
242
- * @param {String} [options.noSelectTitle='Select project'] Dialog title when warning the user they need to select something
243
- * @param {String} [options.noSelectBody='A project needs to be selected to continue'] Dialog body when warning the user they need to select something
244
- *
245
- * @returns {Promise<Project>} The active project
246
- */
247
- requireProject(options?: any): Promise<any>;
248
- /**
249
- * Prompt the user to select a project from those available
250
- *
251
- * @param {Object} [options] Additional options to mutate behaviour
252
- * @param {String} [options.title="Select a project to work with"] The title of the dialog to display
253
- * @param {Boolean} [options.allowCancel=true] Allow cancelling the operation, will throw `'CANCEL'` if actioned
254
- * @param {Boolean} [options.setActive=false] Also set the project as active when selected
255
- *
256
- * @returns {Promise<Project>} The active project
257
- */
258
- selectProject(options?: any): Promise<any>;
259
- /**
260
- * Get a one-off snapshot of a namespace without mounting it
261
- * This can be used for simpler apps which don't have their own reactive / observer equivelent
262
- *
263
- * @param {String} name The alias of the namespace, this should be alphanumeric + hyphens + underscores
264
- *
265
- * @returns {Promise<Object>} A promise which resolves to the namespace POJO state
266
- */
267
- getNamespace(name: string): Promise<any>;
268
- /**
269
- * Set (or merge by default) a one-off snapshot over an existing namespace
270
- * This can be used for simpler apps which don't have their own reactive / observer equivelent and just want to quickly set something
271
- *
272
- * @param {String} name The name of the namespace
273
- * @param {Object} state The state to merge
274
- * @param {Object} [options] Additional options to mutate behaviour
275
- * @param {'merge'|'set'} [options.method='merge'] How to handle the state. 'merge' (merge a partial state over the existing namespace state), 'set' (completely overwrite the existing namespace)
276
- *
277
- * @returns {Promise<Object>} A promise which resolves to the namespace POJO state
278
- */
279
- setNamespace(name: string, state: any, options?: any): Promise<any>;
280
- /**
281
- * Return a list of namespaces available to the current project
282
- *
283
- * @returns {Promise<Array<Object>>} Collection of available namespaces for the current project
284
- * @property {String} name The name of the namespace
285
- */
286
- listNamespaces(): Promise<any[]>;
287
- /**
288
- * Return the current, full snapshot state of the active project
289
- *
290
- * @param {Object} [options] Additional options to mutate behaviour
291
- * @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
292
- * @param {Array<String>} [options.paths] Paths to subscribe to e.g. ['/users/'],
293
- *
294
- * @returns {Promise<Object>} The current project state snapshot
295
- */
296
- getProjectState(options?: any): Promise<any>;
297
- /**
298
- * Set a nested value within the project state
299
- *
300
- * Paths can be any valid Lodash.set() value such as:
301
- * - Dotted notation - e.g. `foo.bar.1.baz`
302
- * - Array path segments e.g. `['foo', 'bar', 1, 'baz']`
303
- *
304
- * Conflict strategies (copied from utils/pathTools @ `set()`)
305
- * - 'set' / 'overwrite' - Just overwrite any existing value
306
- * - 'merge' - Merge existing values using Lodash.merge()
307
- * - 'defaults' - Merge existing values using Lodash.defaultsDeep()
308
- *
309
- * @param {String|Array<String>} path The sub-path within the project state to set
310
- * @param {*} value The value to set, this is set using the conflict strategy
311
- *
312
- * @param {Object} [options] Additional options to mutate behaviour
313
- * @param {'set'} [options.strategy='set'] A PathTools.set strategy to handle existing values, if any
314
- *
315
- * @returns {Promise<*>} A promise which resolves to `value` when the operation has been dispatched to the server and saved
316
- */
317
- setProjectState(path: string | string[], value: any, options?: any): Promise<any>;
318
- /**
319
- * Set a nested value within the project state - just like `setProjectState()` but applying the 'defaults' strategy by default
320
- *
321
- * @see setProjectState()
322
- * @param {String|Array<String>} [path] The sub-path within the project state to set, if unspecifed the entire target is used as a target and a save operation is forced
323
- * @param {*} value The value to set as the default structure
324
- * @param {Object} [options] Additional options to mutate behaviour, see setProjectState() for the full list of supported options
325
- *
326
- * @returns {Promise<*>} A promise which resolves to the eventual input value after defaults have been applied
327
- */
328
- setProjectStateDefaults(path: string | string[] | any, value?: any, options?: any): Promise<any>;
329
- /**
330
- * Force refetching the remote project state into local
331
- *
332
- * @returns {Promise} A promise which resolves when the operation has completed
333
- */
334
- setProjectStateRefresh(): Promise<null>;
335
- /**
336
- * Data structure for a project file
337
- * @class ProjectFile
338
- *
339
- * @property {String} id A UUID string representing the unique ID of the file
340
- * @property {String} name Relative name path (can contain prefix directories) for the human readable file name
341
- * @property {Object} parsedName An object representing meta file parts of a file name
342
- * @property {String} parsedName.basename The filename + extention (i.e. everything without directory name)
343
- * @property {String} parsedName.filename The file portion of the name (basename without the extension)
344
- * @property {String} parsedName.ext The extension portion of the name (always lower case)
345
- * @property {String} parsedName.dirName The directory path portion of the name
346
- * @property {Date} created A date representing when the file was created
347
- * @property {Date} modified A date representing when the file was created
348
- * @property {Date} accessed A date representing when the file was last accessed
349
- * @property {Number} size Size, in bytes, of the file
350
- * @property {String} mime The associated mime type for the file
351
- */
352
- /**
353
- * Data structure for a file filter
354
- * @class FileFilters
355
- *
356
- * @property {Boolean} [library=false] Restrict to library files only
357
- * @property {String} [filename] CSV of @momsfriendlydevco/match expressions to filter the filename by (filenames are the basename sans extension)
358
- * @property {String} [basename] CSV of @momsfriendlydevco/match expressions to filter the basename by
359
- * @property {String} [ext] CSV of @momsfriendlydevco/match expressions to filter the file extension by
360
- */
361
- /**
362
- * Prompt the user to select a library to operate on
363
- *
364
- * @param {Object} [options] Additional options to mutate behaviour
365
- * @param {String} [options.title="Select a file"] The title of the dialog to display
366
- * @param {String|Array<String>} [options.hint] Hints to identify the file to select in array order of preference
367
- * @param {Boolean} [options.save=false] Set to truthy if saving a new file, UI will adjust to allowing overwrite OR new file name input
368
- * @param {String} [options.saveFilename] File name to save as, if omitted the hinting system is used otherwise 'My File.unknown' is assumed
369
- * @param {FileFilters} [options.filters] Optional file filters
370
- * @param {Boolean} [options.allowUpload=true] Allow uploading new files
371
- * @param {Boolean} [options.allowRefresh=true] Allow the user to manually refresh the file list
372
- * @param {Boolean} [options.allowDownloadZip=true] Allow the user to download a Zip of all files
373
- * @param {Boolean} [options.allowCancel=true] Allow cancelling the operation. Will throw `'CANCEL'` as the promise rejection if acationed
374
- * @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
375
- * @param {Boolean} [options.showHiddenFiles=false] Whether hidden data.json files should be shown
376
- *
377
- * @returns {Promise<ProjectFile>} The eventually selected file, if in save mode new files are created as stubs
378
- */
379
- selectProjectFile(options?: any): Promise<any>;
380
- /**
381
- * Fetch the files associated with a given project
382
- *
383
- * @param {Object} options Options which mutate behaviour
384
- * @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
385
- * @param {Boolean} [options.lazy=true] If true, use the fastest method to retrieve the file list such as the cache. If false, force a refresh each time
386
- * @param {Boolean} [options.meta=true] Pull meta information for each file entity
387
- *
388
- * @returns {Promise<Array<ProjectFile>>} A collection of project files for the given project
389
- */
390
- getProjectFiles(options?: any): Promise<any[]>;
391
- /**
392
- * Fetch a project file by its name
393
- *
394
- * @param {String} name The name + relative directory path component
395
- *
396
- * @param {Object|String} [options] Additional options to mutate behaviour, if a string is given `options.subkey` is assumed
397
- * @param {String} [options.subkey] If specified only the extracted subkey is returned rather than the full object
398
- * @param {Boolean} [options.cache=true] Use the existing file cache if possible, set to false to force a refresh of files from the server first
399
- *
400
- * @returns {Promise<ProjectFile>} The eventual fetched ProjectFile (or requested subkey)
401
- */
402
- getProjectFile(name: string, options?: any): Promise<any>;
403
- /**
404
- * Fetch the raw contents of a file by its ID
405
- *
406
- * @param {String} [id] File ID to retrieve the contents of
407
- *
408
- * @param {Object} [options] Additional options to mutate behaviour
409
- * @param {'blob'|'json'} [options.format='blob'] The format to retrieve the file in. If `json` the raw output is run via JSON.parse() first
410
- *
411
- * @returns {*} The file contents in the requested format
412
- */
413
- getProjectFileContents(id: string, options?: any): Promise<any>;
414
- /**
415
- * Create a new file
416
- * This creates an empty file which can then be written to
417
- * This function also forces a local file list cache update
418
- *
419
- * @param {String} name The name + relative directory path component
420
- * @returns {Promise<ProjectFile>} The eventual ProjectFile created
421
- */
422
- createProjectFile(name: string): Promise<any>;
423
- /**
424
- * Moves a project file to a new name/path.
425
- * The file's unique ID (UUID) remains the same, but its 'name' (relative path) and associated properties will be updated.
426
- *
427
- * @param {String} sourceId The unique ID (UUID) of the file to move.
428
- * @param {String} newName The new relative name for the file (e.g., "documents/report-final.pdf" or "image.png").
429
- * This path is relative to the project's root file directory.
430
- *
431
- * @param {Object} [options] Additional options to mutate behaviour.
432
- * @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing.
433
- * @param {Boolean} [options.overwrite=true] If true (default), moving a file to a `newName` that already exists will overwrite the existing file.
434
- * This aligns with the default behavior of the underlying Supabase storage `move` operation.
435
- * If set to false, the function would ideally check and prevent overwrite, but current implementation relies on underlying storage behavior.
436
- *
437
- * @returns {Promise<ProjectFile | null>} A promise which resolves to the updated ProjectFile object for the moved file if found after the operation,
438
- * or null if the file could not be located post-move (e.g., if its ID changed unexpectedly or it was deleted).
439
- */
440
- moveProjectFile(sourceId: string, newName: string, options?: any): Promise<any | null>;
441
- /**
442
- * Remove a project file by its ID
443
- *
444
- * @param {String} id The File ID to remove
445
- *
446
- * @returns {Promise} A promise which resolves when the operation has completed
447
- */
448
- deleteProjectFile(id: string): Promise<null>;
449
- /**
450
- * Save (or overwrite) a file within a project
451
- *
452
- * @param {String|ProjectFile} [id] ProjectFile or ID of the same to overwrite, if omitted a file is prompted for
453
- * @param {File|Blob|FormData|Object|Array} contents The new file contents
454
- * @param {Object} [options] Additional options to mutate behaviour
455
- * @param {String|ProjectFile} [options.id] Alternate method to specify the file ID to save as, if omitted one will be prompted for
456
- * @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
457
- * @param {String|Array<String>} [options.hint] Hint(s) to store against the library. Generally corresponds to the current operation being performed - e.g. 'deduped'
458
- * @param {String} [options.filename] Suggested filename if `id` is unspecified
459
- * @param {String} [options.title='Save citation library'] Dialog title if `id` is unspecified and a prompt is necessary
460
- * @param {Object} [options.meta] Optional meta data to merge into the file data
461
- *
462
- * @returns {Promise} A promise which will resolve when the write operation has completed
463
- */
464
- setProjectFileContents(id: string | any | null, contents: any, options?: any): Promise<null>;
465
- /**
466
- * Creates a new "folder" within the project's file storage.
467
- * Folders in Supabase storage are typically represented by creating a placeholder file (e.g., .emptyFolderPlaceholder) within the desired path.
468
- * This operation is idempotent: if the folder (via its placeholder) already exists, it will not error.
469
- *
470
- * @param {String} folderPath The relative path of the folder to create (e.g., "myDocuments/reports").
471
- * @param {Object} [options] Additional options.
472
- * @param {Boolean} [options.autoRequire=true] Automatically run `requireProject()` to ensure an active project context.
473
- * @returns {Promise<void>} A promise that resolves when the folder is created or ensured.
474
- * @throws {Error} If no project is active (and autoRequire is false), or if folderPath is invalid, or if the creation fails.
475
- */
476
- createProjectFolder(folderPath: string, options?: {
477
- autoRequire?: boolean;
478
- }): Promise<void>;
479
- /**
480
- * Deletes a "folder" and all its contents from the project's file storage.
481
- * This involves listing all files under the given folder path (prefix) and removing them.
482
- *
483
- * @param {String} folderPath The relative path of the folder to delete (e.g., "myDocuments/reports").
484
- * @param {Object} [options] Additional options.
485
- * @param {Boolean} [options.autoRequire=true] Automatically run `requireProject()` to ensure an active project context.
486
- * @returns {Promise<null>} A promise that resolves with null when the folder and its contents are deleted.
487
- * @throws {Error} If no project is active (and autoRequire is false), or if folderPath is invalid, or if deletion fails.
488
- */
489
- deleteProjectFolder(folderPath: string, options?: {
490
- autoRequire?: boolean;
491
- }): Promise<null>;
492
- /**
493
- * Prompt the user to select a library to operate on and return a array of references in a given format
494
- *
495
- * @param {Object} [options] Additional options to mutate behaviour - see `getProjectLibrary()` for parent list of options
496
- * @param {String} [options.title="Select a citation library"] The title of the dialog to display
497
- * @param {String|Array<String>} [options.hint] Hints to identify the library to select in array order of preference. Generally corresponds to the previous stage - e.g. 'deduped', 'review1', 'review2', 'dedisputed'
498
- * @param {Boolean} [options.allowUpload=true] Allow uploading new files
499
- * @param {Boolean} [options.allowRefresh=true] Allow the user to manually refresh the file list
500
- * @param {Boolean} [options.allowDownloadZip=true] Allow the user to download a Zip of all files
501
- * @param {Boolean} [options.allowCancel=true] Allow cancelling the operation. Will throw `'CANCEL'` as the promise rejection if acationed
502
- * @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
503
- * @param {FileFilters} [options.filters] Optional file filters, defaults to citation library selection only
504
- *
505
- * @returns {Promise<Array<Ref>>} A collection of references from the selected file
506
- */
507
- selectProjectLibrary(options?: any): Promise<any[]>;
508
- /**
509
- * Fetch + convert a project file into a library of citations
510
- *
511
- * @param {String} id File ID to read
512
- *
513
- * @param {Object} [options] Additional options to mutate behaviour
514
- * @param {String} [options.format='json'] Format for the file. ENUM: 'pojo' (return a parsed JS collection), 'blob' (raw JS Blob object), 'file' (named JS File object)
515
- * @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
516
- * @param {Function} [options.filter] Optional async file filter, called each time as `(File:ProjectFile)`
517
- * @param {Function} [options.find] Optional async final stage file filter to reduce all candidates down to one subject file
518
- *
519
- * @returns {Promise<Array<Ref>>|Promise<*>} A collection of references (default bevahiour) or a whatever format was requested
520
- */
521
- getProjectLibrary(id: string, options?: any): Promise<any>;
522
- /**
523
- * Save back a citation library from some input
524
- *
525
- * @param {String} [id] File ID to save back to, if omitted a file will be prompted for
526
- * @param {Array<RefLibRef>|Blob|File} [refs] Collection of references for the selected library or the raw Blob/File
527
- *
528
- * @param {Object} [options] Additional options to mutate behaviour
529
- * @param {String} [options.id] Alternate method to specify the file ID to save as, if omitted one will be prompted for
530
- * @param {Array<RefLibRef>|Blob|File} [options.refs] Alternate method to specify the refs to save as an array or raw Blob/File
531
- * @param {String} [options.format='auto'] Input format used. ENUM: 'auto' (try to figure it out from context), 'pojo' (JS array of RefLib references), 'blob' (raw JS Blob object), 'file' (named JS File object)
532
- * @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
533
- * @param {String|Array<String>} [options.hint] Hint(s) to store against the library. Generally corresponds to the current operation being performed - e.g. 'deduped'
534
- * @param {String} [options.filename] Suggested filename if `id` is unspecified
535
- * @param {String} [options.title='Save citation library'] Dialog title if `id` is unspecified and a prompt is necessary
536
- * @param {Boolean} [options.overwrite=true] Allow existing file upsert
537
- * @param {Object} [options.meta] Optional meta data to merge into the file data
538
- *
539
- * @returns {Promise} A promise which resolves when the save operation has completed
540
- */
541
- setProjectLibrary(id: string | any | null, refs?: any, options?: any): Promise<null>;
542
- /**
543
- * Create a log entry for the currently active project
544
- *
545
- * The required log object can be of various forms. See https://tera-tools.com/api/logs.json for the full list
546
- *
547
- * @param {Object} log The log entry to create
548
- * @returns {Promise} A promise which resolves when the operation has completed
549
- */
550
- projectLog(log: any): Promise<void>;
551
- /**
552
- * Set an active tools URL or other context information so that it survives a refresh
553
- * This only really makes a difference to tools within the tera-tools.com site where the tool is working as an embed
554
- *
555
- * @param {Object|String} options Context information about the page, if this is a string, its assumed to popupate `url`
556
- * @param {String} [options.path] The URL path segment to restore on next refresh
557
- * @param {String} [options.title] The page title associated with the path
558
- */
559
- setPage(options: any): void;
560
- /**
561
- * Setup the TERA-fy client singleton
562
- *
563
- * @param {Object} [options] Additional options to merge into `settings`
564
- */
565
- constructor(options?: any);
566
- /**
567
- * Initialize the browser listener
568
- */
569
- init(): void;
570
- /**
571
- * Display simple text within TERA
572
- *
573
- * @param {String} [text] Text to display, if specified this populates `options.body`
574
- *
575
- * @param {Object} [options] Additional options to mutate behaviour
576
- * @param {String} [options.body="Alert!"] The body text to display
577
- * @param {Boolean} [options.isHtml=false] If falsy the text is rendered as plain-text otherwise it will be assumed as HTML content
578
- * @param {String} [options.title='TERA'] The title of the alert box
579
- * @param {'ok'|false} [options.buttons='ok'] Button set to use or falsy to disable
580
- *
581
- * @returns {Promise} A promise which resolves when the alert has been dismissed
582
- */
583
- uiAlert(text: string | any, options?: any): Promise<void>;
584
- /**
585
- * Present a simple ok/cancel dialog to the user
586
- *
587
- * @param {String} [text] Text to display, if specified this populates `options.body`
588
- *
589
- * @param {Object} [options] Additional options to mutate behaviour
590
- * @param {String} [options.body="Confirm?"] The body text to display
591
- * @param {Boolean} [options.isHtml=false] If falsy the text is rendered as plain-text otherwise it will be assumed as HTML content
592
- * @param {String} [options.title='TERA'] The title of the confirmation box
593
- *
594
- * @returns {Promise} A promise which resolves with `Promise.resolve('OK')` or rejects with `Promise.reject('CANCEL')`
595
- */
596
- uiConfirm(text: string | any, options?: any): Promise<'OK'>;
597
- /**
598
- * Present some JSON to the user
599
- *
600
- * @function uiJson
601
- * @param {String|Object} data Data to display
602
- *
603
- * @param {Object} [options] Additional options to mutate behaviour
604
- * @param {String} [options.body=""] The body text to display above the JSON
605
- * @param {Boolean} [options.isHtml=false] If falsy the text is rendered as plain-text otherwise it will be assumed as HTML content
606
- * @param {String|Object} [options.json] The JSON data to display
607
- * @param {String} [options.title='TERA'] The title of the confirmation box
608
- *
609
- * @returns {Promise} A promise which resolves with `Promise.resolve('OK')`
610
- */
611
- uiJson(data: any, options?: any): Promise<'OK'>;
612
- /**
613
- * Trigger a fatal error, killing the outer TERA site
614
- *
615
- * @function uiPanic
616
- * @param {String} [text] Text to display
617
- */
618
- uiPanic(text: any): void;
619
- /**
620
- * Display, update or dispose of windows for long running tasks
621
- * All options are cumulative - i.e. they are merged with other options previously provided
622
- *
623
- * @param {Object|Boolean} [options] Additional options to mutate behaviour, if boolean false `close: true` is assumed
624
- * @param {String} [options.body=''] Window body text
625
- * @param {Boolean} [options.bodyHtml=false] If truthy, treat the body as HTML
626
- * @param {String} [options.title='TERA'] Window title, can only be set on the initial call
627
- * @param {Boolean} [options.close=false] Close the existing dialog, if true the dialog is disposed and options reset
628
- * @param {Number} [options.progress] The current progress of the task being conducted, this is assumed to be a value less than `progressMax`
629
- * @param {Number} [options.progressMax] The maximum value that the progress can be
630
- *
631
- * @returns {Promise} A promise which resolves when the dialog has been updated
632
- */
633
- uiProgress(options?: any): Promise<void>;
634
- _uiProgress: {
635
- options: any | null;
636
- promise: Promise<any> | null;
637
- };
638
- /**
639
- * Prompt the user for an input, responding with a Promisable value
640
- *
641
- * @param {String} [text] Text to display, if specified this populates `options.body`
642
- *
643
- * @param {Object} [options] Additional options to mutate behaviour
644
- * @param {String} [options.body] Optional additional body text
645
- * @param {Boolean} [options.isHtml=false] If truthy, treat the body as HTML
646
- * @param {String} [options.value] Current or default value to display pre-filled
647
- * @param {String} [options.title='Input required'] The dialog title to display
648
- * @param {String} [options.placeholder] Optional placeholder text
649
- * @param {Boolean} [options.required=true] Treat nullish or empty inputs as a cancel operation
650
- *
651
- * @returns {Promise<*>} Either the eventual user value or a throw with `Promise.reject('CANCEL')`
652
- */
653
- uiPrompt(text: string | any, options?: any): Promise<any>;
654
- /**
655
- * Catch an error using the TERA error handler
656
- *
657
- * @param {Error|Object|String} error Error to handle, generally an Error object but can be a POJO or a scalar string
658
- *
659
- * @returns {Void} This function is fatal
660
- */
661
- uiThrow(error: any): Promise<void>;
662
- /**
663
- * Open a popup window containing a new site
664
- *
665
- * @param {String} url The URL to open
666
- *
667
- * @param {Object} [options] Additional options to mutate behaviour
668
- * @param {Number} [options.width=500] The desired width of the window
669
- * @param {Number} [options.height=600] The desired height of the window
670
- * @param {Boolean} [options.center=true] Attempt to center the window on the screen
671
- * @param {Object} [options.permissions] Additional permissions to set on opening, defaults to a suitable set of permission for popups (see code)
672
- *
673
- * @returns {WindowProxy} The opened window object (if `noopener` is not set in permissions)
674
- */
675
- uiWindow(url: string | URL, options?: UiWindowOptions): WindowProxy | null;
676
- /**
677
- * Display HTML content full-screen within TERA
678
- * This function is ideally called within a requestFocus() wrapper
679
- *
680
- * @param {DOMElement|String|false} content Either a prepared DOM element or string to compile, set to falsy to remove existing content
681
- *
682
- * @param {Object} [options] Additional options to mutate behaviour
683
- * @param {Boolean|String} [options.logo=false] Add a logo to the output, if boolean true the Tera-tools logo is used otherwise specify a path or URL
684
- */
685
- uiSplat(content: Element | string | false, options?: any): void;
686
- /**
687
- * Debugging output function.
688
- * This function will only act if `settings.devMode` is truthy.
689
- *
690
- * @param {...any} inputArgs The arguments to process for debugging. The function signature is flexible: `debug([method], [verboseLevel], ...msg)`.
691
- * - The first argument can optionally be a logging method string: 'INFO', 'LOG', 'WARN', or 'ERROR'. Defaults to 'LOG'.
692
- * - The next argument can optionally be a numeric verbosity level. The message is ignored if `settings.verbosity` is lower than this level. Defaults to 1.
693
- * - All subsequent arguments are passed to the console as the log message.
694
- */
695
- debug(...inputArgs: any[]): void;
696
- }
697
- export {};