@iebh/tera-fy 2.0.21 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/api.md +68 -66
  3. package/dist/lib/projectFile.d.ts +182 -0
  4. package/dist/lib/projectFile.js +157 -0
  5. package/dist/lib/projectFile.js.map +1 -0
  6. package/dist/lib/syncro/entities.d.ts +28 -0
  7. package/dist/lib/syncro/entities.js +203 -0
  8. package/dist/lib/syncro/entities.js.map +1 -0
  9. package/dist/lib/syncro/keyed.d.ts +95 -0
  10. package/dist/lib/syncro/keyed.js +286 -0
  11. package/dist/lib/syncro/keyed.js.map +1 -0
  12. package/dist/lib/syncro/syncro.d.ts +328 -0
  13. package/dist/lib/syncro/syncro.js +633 -0
  14. package/dist/lib/syncro/syncro.js.map +1 -0
  15. package/dist/lib/terafy.bootstrapper.d.ts +42 -0
  16. package/dist/lib/terafy.bootstrapper.js +130 -0
  17. package/dist/lib/terafy.bootstrapper.js.map +1 -0
  18. package/dist/lib/terafy.client.d.ts +532 -0
  19. package/dist/lib/terafy.client.js +1110 -0
  20. package/dist/lib/terafy.client.js.map +1 -0
  21. package/dist/lib/terafy.proxy.d.ts +66 -0
  22. package/dist/lib/terafy.proxy.js +123 -0
  23. package/dist/lib/terafy.proxy.js.map +1 -0
  24. package/dist/lib/terafy.server.d.ts +607 -0
  25. package/dist/lib/terafy.server.js +1774 -0
  26. package/dist/lib/terafy.server.js.map +1 -0
  27. package/dist/plugin.vue2.es2019.js +30 -13
  28. package/dist/plugins/base.d.ts +20 -0
  29. package/dist/plugins/base.js +21 -0
  30. package/dist/plugins/base.js.map +1 -0
  31. package/dist/plugins/firebase.d.ts +62 -0
  32. package/dist/plugins/firebase.js +111 -0
  33. package/dist/plugins/firebase.js.map +1 -0
  34. package/dist/plugins/vite.d.ts +12 -0
  35. package/dist/plugins/vite.js +22 -0
  36. package/dist/plugins/vite.js.map +1 -0
  37. package/dist/plugins/vue2.d.ts +68 -0
  38. package/dist/plugins/vue2.js +96 -0
  39. package/dist/plugins/vue2.js.map +1 -0
  40. package/dist/plugins/vue3.d.ts +64 -0
  41. package/dist/plugins/vue3.js +96 -0
  42. package/dist/plugins/vue3.js.map +1 -0
  43. package/dist/terafy.bootstrapper.es2019.js +2 -2
  44. package/dist/terafy.bootstrapper.js +2 -2
  45. package/dist/terafy.es2019.js +2 -2
  46. package/dist/terafy.js +1 -1
  47. package/dist/utils/mixin.d.ts +11 -0
  48. package/dist/utils/mixin.js +15 -0
  49. package/dist/utils/mixin.js.map +1 -0
  50. package/dist/utils/pDefer.d.ts +12 -0
  51. package/dist/utils/pDefer.js +14 -0
  52. package/dist/utils/pDefer.js.map +1 -0
  53. package/dist/utils/pathTools.d.ts +70 -0
  54. package/dist/utils/pathTools.js +120 -0
  55. package/dist/utils/pathTools.js.map +1 -0
  56. package/eslint.config.js +44 -8
  57. package/lib/{projectFile.js → projectFile.ts} +83 -40
  58. package/lib/syncro/entities.ts +288 -0
  59. package/lib/syncro/{keyed.js → keyed.ts} +114 -57
  60. package/lib/syncro/{syncro.js → syncro.ts} +204 -169
  61. package/lib/{terafy.bootstrapper.js → terafy.bootstrapper.ts} +49 -31
  62. package/lib/{terafy.client.js → terafy.client.ts} +94 -86
  63. package/lib/{terafy.proxy.js → terafy.proxy.ts} +43 -16
  64. package/lib/{terafy.server.js → terafy.server.ts} +364 -223
  65. package/package.json +65 -26
  66. package/plugins/{base.js → base.ts} +3 -1
  67. package/plugins/{firebase.js → firebase.ts} +34 -16
  68. package/plugins/{vite.js → vite.ts} +3 -3
  69. package/plugins/{vue2.js → vue2.ts} +17 -10
  70. package/plugins/{vue3.js → vue3.ts} +11 -9
  71. package/tsconfig.json +30 -0
  72. package/utils/{mixin.js → mixin.ts} +1 -1
  73. package/utils/{pDefer.js → pDefer.ts} +10 -3
  74. package/utils/{pathTools.js → pathTools.ts} +11 -9
  75. package/lib/syncro/entities.js +0 -232
@@ -0,0 +1,532 @@
1
+ /**
2
+ * Main Tera-Fy Client (class singleton) to be used in a frontend browser
3
+ *
4
+ * @class TeraFy
5
+ */
6
+ export default class TeraFy {
7
+ /**
8
+ * Various settings to configure behaviour
9
+ *
10
+ * @type {Object}
11
+ * @property {String} session Unique session signature for this instance of TeraFy, used to sign server messages, if falsy `getEntropicString(16)` is used to populate
12
+ * @property {Boolean} devMode Operate in Dev-Mode - i.e. force outer refresh when encountering an existing TeraFy instance + be more tolerent of weird iframe origins
13
+ * @property {Number} verbosity Verbosity level, the higher the more chatty TeraFY will be. Set to zero to disable all `debug()` call output
14
+ * @property {'detect'|'parent'|'child'|'popup'} mode How to communicate with TERA. 'parent' assumes that the parent of the current document is TERA, 'child' spawns an iFrame and uses TERA there, 'detect' tries parent and switches to `modeFallback` if communication fails
15
+ * @property {String} modeFallback Method to use when all method detection fails
16
+ * @property {Object<Object<Function>>} modeOverrides Functions to run when switching to specific modes, these are typically used to augment config. Called as `(config:Object)`
17
+ * @property {Number} modeTimeout How long entities have in 'detect' mode to identify themselves
18
+ * @property {String} siteUrl The TERA URL to connect to
19
+ * @property {String} restrictOrigin URL to restrict communications to
20
+ * @property {Array<String>} List of sandbox allowables for the embedded if in embed mode
21
+ * @property {Number} handshakeInterval Interval in milliseconds when sanning for a handshake
22
+ * @property {Number} handshakeTimeout Interval in milliseconds for when to give up trying to handshake
23
+ * @property {Array<String|Array<String>>} [debugPaths] List of paths (in either dotted or array notation) to enter debugging mode if a change is detected in dev mode e.g. `{debugPaths: ['foo.bar.baz']}`. This really slows down state writes so should only be used for debugging
24
+ */
25
+ settings: {
26
+ session: string | null;
27
+ devMode: boolean;
28
+ verbosity: number;
29
+ mode: "detect" | "parent" | "child" | "popup";
30
+ modeTimeout: number;
31
+ modeFallback: string;
32
+ modeOverrides: {
33
+ [key: string]: (config: any) => void;
34
+ };
35
+ siteUrl: string;
36
+ restrictOrigin: string;
37
+ frameSandbox: string[];
38
+ handshakeInterval: number;
39
+ handshakeTimeout: number;
40
+ debugPaths: Array<string | Array<string>> | null;
41
+ };
42
+ /**
43
+ * Event emitter subscription endpoint
44
+ * @type {Mitt}
45
+ */
46
+ events: any;
47
+ /**
48
+ * DOMElements for this TeraFy instance
49
+ *
50
+ * @type {Object}
51
+ * @property {DOMElement} el The main tera-fy div wrapper
52
+ * @property {DOMElement} iframe The internal iFrame element (if `settings.mode == 'child'`)
53
+ * @property {Window} popup The popup window context (if `settings.mode == 'popup'`)
54
+ * @property {DOMElement} stylesheet The corresponding stylesheet
55
+ */
56
+ dom: {
57
+ el: HTMLDivElement | null;
58
+ iframe: HTMLIFrameElement | null;
59
+ popup: Window | null;
60
+ stylesheet: HTMLStyleElement | null;
61
+ };
62
+ /**
63
+ * List of function stubs mapped from the server to here
64
+ * This array is forms the reference of `TeraFy.METHOD()` objects to provide locally which will be mapped via `TeraFy.rpc(METHOD, ...args)`
65
+ *
66
+ * @type {Array<String>}
67
+ */
68
+ methods: readonly ["handshake", "setServerVerbosity", "getUser", "requireUser", "getCredentials", "bindProject", "getProject", "getProjects", "setActiveProject", "requireProject", "selectProject", "getNamespace", "setNamespace", "listNamespaces", "getProjectState", "setProjectState", "setProjectStateDefaults", "setProjectStateRefresh", "getProjectFileContents", "deleteProjectFile", "setProjectFileContents", "selectProjectLibrary", "getProjectLibrary", "setProjectLibrary", "projectLog", "setPage", "uiAlert", "uiConfirm", "uiPanic", "uiProgress", "uiPrompt", "uiThrow", "uiSplat", "uiWindow"];
69
+ /**
70
+ * Loaded plugins via Use()
71
+ * @type {Array<TeraFyPlugin>}
72
+ */
73
+ plugins: any[];
74
+ /**
75
+ * Active namespaces we are subscribed to
76
+ * Each key is the namespace name with the value as the local reactive \ observer \ object equivelent
77
+ * The key string is always of the form `${ENTITY}::${ID}` e.g. `projects:1234`
78
+ *
79
+ * @type {Object<Object>}
80
+ */
81
+ namespaces: {
82
+ [key: string]: any;
83
+ };
84
+ /**
85
+ * Send a message + wait for a response object
86
+ *
87
+ * @param {Object} message Message object to send
88
+ * @returns {Promise<*>} A promise which resolves when the operation has completed with the remote reply
89
+ */
90
+ send(message: any): any;
91
+ /**
92
+ * Send raw message content to the server
93
+ * This function does not return or wait for a reply - use `send()` for that
94
+ *
95
+ * @param {Object} message Message object to send
96
+ */
97
+ sendRaw(message: any): void;
98
+ /**
99
+ * Call an RPC function in the server instance
100
+ *
101
+ * @param {String} method The method name to call
102
+ * @param {...*} [args] Optional arguments to pass to the function
103
+ *
104
+ * @returns {Promise<*>} The resolved output of the server function
105
+ */
106
+ rpc(method: any, ...args: any[]): any;
107
+ /**
108
+ * Accept an incoming message
109
+ *
110
+ * @param {MessageEvent} rawMessage Raw message event to process
111
+ *
112
+ * @returns {Promise} A promise which will resolve when the message has been processed
113
+ */
114
+ acceptMessage(rawMessage: any): Promise<any>;
115
+ /**
116
+ * Listening postboxes, these correspond to outgoing message IDs that expect a response
117
+ */
118
+ acceptPostboxes: {
119
+ [key: string]: any;
120
+ };
121
+ /**
122
+ * Make a namespace available locally
123
+ * This generally creates whatever framework flavoured reactive/observer/object is supported locally - generally with writes automatically synced with the master state
124
+ *
125
+ * @function mountNamespace
126
+ * @param {String} name The alias of the namespace, this should be alphanumeric + hyphens + underscores
127
+ *
128
+ * @returns {Promise<Reactive>} A promise which resolves to the reactive object
129
+ */
130
+ mountNamespace(name: any): Promise<any>;
131
+ /**
132
+ * @interface
133
+ * Actual namespace mounting function designed to be overriden by plugins
134
+ *
135
+ * @param {String} name The alias of the namespace, this should be alphanumeric + hyphens + underscores
136
+ *
137
+ * @returns {Promise} A promise which resolves when the mount operation has completed
138
+ */
139
+ _mountNamespace(name: any): void;
140
+ /**
141
+ * Release a locally mounted namespace
142
+ * This function will remove the namespace from `namespaces`, cleaning up any memory / subscription hooks
143
+ *
144
+ * @function unmountNamespace
145
+ *
146
+ * @param {String} name The name of the namespace to unmount
147
+ *
148
+ * @returns {Promise} A promise which resolves when the operation has completed
149
+ */
150
+ unmountNamespace(name: any): void | Promise<void>;
151
+ /**
152
+ * @interface
153
+ * Actual namespace unmounting function designed to be overriden by plugins
154
+ *
155
+ * @param {String} name The name of the namespace to unmount
156
+ *
157
+ * @returns {Promise} A promise which resolves when the operation has completed
158
+ */
159
+ _unmountNamespace(name: any): void;
160
+ /**
161
+ * Setup the TERA-fy client singleton
162
+ *
163
+ * @param {Object} [options] Additional options to merge into `settings` via `set`
164
+ */
165
+ constructor(options?: any);
166
+ private initPromise;
167
+ /**
168
+ * Initalize the TERA client singleton
169
+ * This function can only be called once and will return the existing init() worker Promise if its called againt
170
+ *
171
+ * @param {Object} [options] Additional options to merge into `settings` via `set`
172
+ * @returns {Promise<TeraFy>} An eventual promise which will resovle with this terafy instance
173
+ */
174
+ init(options?: any): Promise<TeraFy>;
175
+ /**
176
+ * Populate `settings.mode`
177
+ * Try to communicate with a parent frame, if none assume we need to fallback to child mode
178
+ *
179
+ * @returns {Promise<String>} A promise which will resolve with the detected mode to use
180
+ */
181
+ detectMode(): Promise<'parent' | 'child' | 'popup'>;
182
+ /**
183
+ * Find an existing active TERA server OR initalize one
184
+ *
185
+ * @returns {Promise} A promise which will resolve when the loading has completed and we have found a parent TERA instance or initiallized a child
186
+ */
187
+ injectComms(): Promise<void>;
188
+ /**
189
+ * Keep trying to handshake until the target responds
190
+ *
191
+ * @param {Object} [options] Additional options to mutate behaviour
192
+ * @property {Number} [handshakeInterval] Interval in milliseconds when sanning for a handshake, defaults to global setting
193
+ * @property {Number} [handshakeTimeout] Interval in milliseconds for when to give up trying to handshake, defaults to global setting
194
+ *
195
+ * @returns {Promise} A promise which will either resolve when the handshake is successful OR fail with 'TIMEOUT'
196
+ */
197
+ handshakeLoop(options?: any): Promise<void>;
198
+ /**
199
+ * Inject a local stylesheet to handle TERA server functionality
200
+ *
201
+ * @returns {Promise} A promise which will resolve when the loading has completed and we have found a parent TERA instance or initiallized a child
202
+ */
203
+ injectStylesheet(): Promise<void>;
204
+ /**
205
+ * Inject all server methods defined in `methods` as local functions wrapped in the `rpc` function
206
+ */
207
+ injectMethods(): void;
208
+ /**
209
+ * Debugging output function
210
+ * This function will only act if `settings.devMode` is truthy
211
+ *
212
+ * @param {'INFO'|'LOG'|'WARN'|'ERROR'} [method='LOG'] Logging method to use
213
+ * @param {Number} [verboseLevel=1] The verbosity level to trigger at. If `settings.verbosity` is lower than this, the message is ignored
214
+ * @param {...*} [msg] Output to show
215
+ */
216
+ debug(...msg: any[]): void;
217
+ /**
218
+ * Set or merge settings
219
+ * This function also routes 'special' keys like `devMode` to their internal handlers
220
+ *
221
+ * @param {String|Object} key Either a single setting key to set or an object to merge
222
+ * @param {*} value The value to set if `key` is a string
223
+ *
224
+ * @param {Object} [options] Additional options to mutate behaviour
225
+ * @param {Boolean} [options.ignoreNullish=true] If falsy, this forces the setting of undefined or null values rather than ignoring them when specifying values by string
226
+ *
227
+ * @returns {TeraFy} This chainable terafy instance
228
+ */
229
+ set(key: string | object, value?: any, options?: {
230
+ ignoreNullish?: boolean;
231
+ }): this;
232
+ /**
233
+ * Set or merge settings - but only in dev mode and only if the value is not undefined
234
+ *
235
+ * @see set()
236
+ * @param {String|Object} key Either a single setting key to set or an object to merge
237
+ * @param {*} value The value to set if `key` is a string
238
+ * @param {Object} [options] Additional options to mutate behaviour
239
+ *
240
+ * @returns {TeraFy} This chainable terafy instance
241
+ */
242
+ setIfDev(key: any, value: any, options?: any): this;
243
+ /**
244
+ * Include a TeraFy client plugin
245
+ *
246
+ * @param {Function|Object|String} source Either the JS module class, singleton object or URL to fetch it from. Eventually constructed as invoked as `(teraClient:TeraFy, options:Object)`
247
+ * @param {Object} [options] Additional options to mutate behaviour during construction (pass options to init() to intialize later options)
248
+ *
249
+ * @returns {TeraFy} This chainable terafy instance
250
+ */
251
+ use(source: any, options?: any): this;
252
+ /**
253
+ * Internal function used by use() to merge an external declared singleton against this object
254
+ *
255
+ * @param {Object} target Initalied class instance to extend
256
+ * @param {Object} source Initalized source object to extend from
257
+ */
258
+ mixin(target: any, source: any): void;
259
+ /**
260
+ * Set or toggle devMode
261
+ * This function also accepts meta values:
262
+ *
263
+ * 'toggle' - Set dev mode to whatever the opposing value of the current mode
264
+ * 'proxy' - Optimize for using a loopback proxy
265
+ *
266
+ * @param {'toggle'|'proxy'|Boolean} [devModeEnabled='toggle'] Optional boolean to force dev mode or specify other behaviour
267
+ *
268
+ * @returns {TeraFy} This chainable terafy instance
269
+ */
270
+ toggleDevMode(devModeEnabled?: 'toggle' | 'proxy' | boolean): this;
271
+ /**
272
+ * Fit the nested TERA server to a full-screen
273
+ * This is usually because the server component wants to perform some user activity like calling $prompt
274
+ *
275
+ * @param {String|Boolean} [isFocused='toggle'] Whether to fullscreen the embedded component
276
+ */
277
+ toggleFocus(isFocused?: boolean | 'toggle'): void;
278
+ /**
279
+ * Generate random entropic character string in Base64
280
+ *
281
+ * @param {Number} [maxLength=32] Maximum lengh of the genrated string
282
+ * @returns {String}
283
+ */
284
+ getEntropicString(maxLength?: number): string;
285
+ /**
286
+ * Return basic server information as a form of validation
287
+ *
288
+ * @function handshake
289
+ * @returns {Promise<Object>} Basic promise result
290
+ * @property {Date} date Server date
291
+ */
292
+ /**
293
+ * RPC callback to set the server verbostiy level
294
+ *
295
+ * @function setServerVerbosity
296
+ * @param {Number} verbosity The desired server verbosity level
297
+ */
298
+ /**
299
+ * User / active session within TERA
300
+ *
301
+ * @name User
302
+ * @property {String} id Unique identifier of the user
303
+ * @property {String} email The email address of the current user
304
+ * @property {String} name The provided full name of the user
305
+ * @property {Boolean} isSubscribed Whether the active user has a TERA subscription
306
+ */
307
+ /**
308
+ * Fetch the current session user
309
+ *
310
+ * @function getUser
311
+ * @param {Boolean} [options.forceRetry=false] Forcabily try to refresh the user state
312
+ * @param {Boolean} [options.waitPromises=true] Wait for $auth + $subscriptions to resolve before fetching the user (mainly internal use)
313
+ * @returns {Promise<User>} The current logged in user or null if none
314
+ */
315
+ /**
316
+ * Provide an object of credentials for 3rd party services like Firebase/Supabase
317
+ *
318
+ * @function getCredentials
319
+ * @returns {Object} An object containing 3rd party service credentials
320
+ */
321
+ /**
322
+ * Require a user login to TERA
323
+ * If there is no user OR they are not logged in a prompt is shown to go and do so
324
+ * This is an pre-requisite step for requireProject()
325
+ *
326
+ * @function requireUser
327
+ *
328
+ * @param {Object} [options] Additional options to mutate behaviour
329
+ * @param {Boolean} [options.forceRetry=false] Forcabily try to refresh the user state
330
+ *
331
+ * @returns {Promise<User>} The current logged in user or null if none
332
+ */
333
+ /**
334
+ * Require a user login to TERA
335
+ * If there is no user OR they are not logged in a prompt is shown to go and do so
336
+ * This is an pre-requisite step for requireProject()
337
+ *
338
+ * @returns {Promise} A promise which will resolve if the there is a user and they are logged in
339
+ */
340
+ /**
341
+ * Project entry within TERA
342
+ *
343
+ * @name Project
344
+ * @url https://tera-tools.com/help/api/schema
345
+ */
346
+ /**
347
+ * Get the currently active project, if any
348
+ *
349
+ * @function getProject
350
+ * @returns {Promise<Project|null>} The currently active project, if any
351
+ */
352
+ /**
353
+ * Get a list of projects the current session user has access to
354
+ *
355
+ * @function getProjects
356
+ * @returns {Promise<Array<Project>>} Collection of projects the user has access to
357
+ */
358
+ /**
359
+ * Set the currently active project within TERA
360
+ *
361
+ * @function setActiveProject
362
+ * @param {Object|String} project The project to set as active - either the full Project object or its ID
363
+ */
364
+ /**
365
+ * Ask the user to select a project from those available - if one isn't already active
366
+ * Note that this function will percist in asking the uesr even if they try to cancel
367
+ *
368
+ * @function requireProject
369
+ * @param {Object} [options] Additional options to mutate behaviour
370
+ * @param {Boolean} [options.autoSetActiveProject=true] After selecting a project set that project as active in TERA
371
+ * @param {String} [options.title="Select a project to work with"] The title of the dialog to display
372
+ * @param {String} [options.noSelectTitle='Select project'] Dialog title when warning the user they need to select something
373
+ * @param {String} [options.noSelectBody='A project needs to be selected to continue'] Dialog body when warning the user they need to select something
374
+ *
375
+ * @returns {Promise<Project>} The active project
376
+ */
377
+ /**
378
+ * Prompt the user to select a project from those available
379
+ *
380
+ * @function selectProject
381
+ * @param {Object} [options] Additional options to mutate behaviour
382
+ * @param {String} [options.title="Select a project to work with"] The title of the dialog to display
383
+ * @param {Boolean} [options.allowCancel=true] Advertise cancelling the operation, the dialog can still be cancelled by closing it
384
+ * @param {Boolean} [options.setActive=false] Also set the project as active when selected
385
+ *
386
+ * @returns {Promise<Project>} The active project
387
+ */
388
+ /**
389
+ * Get a one-off snapshot of a namespace without mounting it
390
+ * This can be used for simpler apps which don't have their own reactive / observer equivelent
391
+ *
392
+ * @function getNamespace
393
+ * @param {String} name The alias of the namespace, this should be alphanumeric + hyphens + underscores
394
+ *
395
+ * @returns {Promise<Object>} A promise which resolves to the namespace POJO state
396
+ */
397
+ /**
398
+ * Set (or merge by default) a one-off snapshot over an existing namespace
399
+ * This can be used for simpler apps which don't have their own reactive / observer equivelent and just want to quickly set something
400
+ *
401
+ * @function setNamespace
402
+ * @param {String} name The name of the namespace
403
+ * @param {Object} state The state to merge
404
+ * @param {Object} [options] Additional options to mutate behaviour
405
+ * @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)
406
+ *
407
+ * @returns {Promise<Object>} A promise which resolves to the namespace POJO state
408
+ */
409
+ /**
410
+ * Return a list of namespaces available to the current project
411
+ *
412
+ * @function listNamespaces
413
+ * @returns {Promise<Array<Object>>} Collection of available namespaces for the current project
414
+ * @property {String} name The name of the namespace
415
+ */
416
+ /**
417
+ * Return the current, full snapshot state of the active project
418
+ *
419
+ * @function getProjectState
420
+ * @param {Object} [options] Additional options to mutate behaviour
421
+ * @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
422
+ * @param {Array<String>} Paths to subscribe to e.g. ['/users/'],
423
+ *
424
+ * @returns {Promise<Object>} The current project state snapshot
425
+ */
426
+ /**
427
+ * Set a nested value within the project state
428
+ * Paths can be any valid Lodash.set() value such as:
429
+ *
430
+ * - Dotted notation - e.g. `foo.bar.1.baz`
431
+ * - Array path segments e.g. `['foo', 'bar', 1, 'baz']`
432
+ *
433
+ * @function setProjectState
434
+ * @param {String|Array<String>} path The sub-path within the project state to set
435
+ * @param {*} value The value to set
436
+ *
437
+ * @param {Object} [options] Additional options to mutate behaviour
438
+ * @param {Boolean} [options.save=true] Save the changes to the server immediately, disable to queue up multiple writes
439
+ *
440
+ * @returns {Promise} A promise which resolves when the operation has been dispatched to the server
441
+ */
442
+ /**
443
+ * Set a nested value within the project state - just like `setProjectState()` - but only if no value for that path exists
444
+ *
445
+ * @function setProjectStateDefaults
446
+ * @see setProjectState()
447
+ * @param {String|Array<String>} path The sub-path within the project state to set
448
+ * @param {*} value The value to set
449
+ * @param {Object} [options] Additional options to mutate behaviour, see setProjectState() for the full list of supported options
450
+ *
451
+ * @returns {Promise<Boolean>} A promise which resolves to whether any changes were made - True if defaults were applied, false otherwise
452
+ */
453
+ /**
454
+ * Force refetching the remote project state into local
455
+ * This is only ever needed when saving large quantities of data that need to be immediately available
456
+ *
457
+ * @function setProjectStateRefresh
458
+ * @returns {Promise} A promise which resolves when the operation has completed
459
+ */
460
+ /**
461
+ * Data structure for a file filter
462
+ * @name FileFilters
463
+ *
464
+ * @property {Boolean} [library=false] Restrict to library files only
465
+ * @property {String} [filename] CSV of @momsfriendlydevco/match expressions to filter the filename by (filenames are the basename sans extension)
466
+ * @property {String} [basename] CSV of @momsfriendlydevco/match expressions to filter the basename by
467
+ * @property {String} [ext] CSV of @momsfriendlydevco/match expressions to filter the file extension by
468
+ */
469
+ /**
470
+ * Prompt the user to select a library to operate on
471
+ *
472
+ * @function selectProjectFile
473
+ * @param {Object} [options] Additional options to mutate behaviour
474
+ * @param {String} [options.title="Select a file"] The title of the dialog to display
475
+ * @param {String|Array<String>} [options.hint] Hints to identify the file to select in array order of preference
476
+ * @param {Boolean} [options.save=false] Set to truthy if saving a new file, UI will adjust to allowing overwrite OR new file name input
477
+ * @param {FileFilters} [options.filters] Optional file filters
478
+ * @param {Boolean} [options.allowUpload=true] Allow uploading new files
479
+ * @param {Boolean} [options.allowRefresh=true] Allow the user to manually refresh the file list
480
+ * @param {Boolean} [options.allowDownloadZip=true] Allow the user to download a Zip of all files
481
+ * @param {Boolean} [options.allowCancel=true] Allow cancelling the operation. Will throw `'CANCEL'` as the promise rejection if acationed
482
+ * @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
483
+ * @param {FileFilters} [options.filter] Optional file filters
484
+ *
485
+ * @returns {Promise<ProjectFile>} The eventually selected file, if in save mode new files are created as stubs
486
+ */
487
+ selectProjectFile(options?: any): any;
488
+ /**
489
+ * Fetch the files associated with a given project
490
+ *
491
+ * @function getProjectFiles
492
+ * @param {Object} options Options which mutate behaviour
493
+ * @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
494
+ * @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
495
+ * @param {Boolean} [options.meta=true] Pull meta information for each file entity
496
+ *
497
+ * @returns {Promise<Array<ProjectFile>>} A collection of project files for the given project
498
+ */
499
+ getProjectFiles(options?: any): any;
500
+ /**
501
+ * Fetch the raw contents of a file by its ID
502
+ *
503
+ * @function getProjectFileContents
504
+ * @param {String} [id] File ID to retrieve the contents of
505
+ * @param {Object} [options] Additioanl options to mutate behaviour
506
+ * @param {'blob'|'json'} [options.format='blob'] The format to retrieve the file in
507
+ *
508
+ * @returns {*} The file contents in the requested format
509
+ */
510
+ /**
511
+ * Fetch a project file by its name
512
+ *
513
+ * @function getProjectFile
514
+ * @param {String} id The name + relative directory path component
515
+ *
516
+ * @param {Object|String} [options] Additional options to mutate behaviour, if a string is given `options.subkey` is assumed
517
+ * @param {String} [options.subkey] If specified only the extracted subkey is returned rather than the full object
518
+ * @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
519
+ *
520
+ * @returns {Promise<ProjectFile>} The eventual fetched ProjectFile (or requested subkey)
521
+ */
522
+ getProjectFile(id: any, options?: any): any;
523
+ /**
524
+ * Create a new file
525
+ * This creates an empty file which can then be written to
526
+ *
527
+ * @function createProjectFile
528
+ * @param {String} name The name + relative directory path component
529
+ * @returns {Promise<ProjectFile>} The eventual ProjectFile created
530
+ */
531
+ createProjectFile(name: any): any;
532
+ }