@iebh/tera-fy 2.3.11 → 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.
- package/CHANGELOG.md +25 -0
- package/api.md +8 -11
- package/dist/plugin.vue2.es2019.js +7 -7
- package/dist/terafy.bootstrapper.es2019.js +2 -2
- package/dist/terafy.bootstrapper.js +2 -2
- package/dist/terafy.es2019.js +5 -5
- package/dist/terafy.js +5 -5
- package/eslint.config.js +4 -66
- package/lib/{projectFile.ts → projectFile.js} +52 -76
- package/lib/syncro/{entities.ts → entities.js} +14 -83
- package/lib/syncro/{keyed.ts → keyed.js} +46 -68
- package/lib/syncro/{syncro.ts → syncro.js} +104 -136
- package/lib/{terafy.bootstrapper.ts → terafy.bootstrapper.js} +20 -30
- package/lib/{terafy.client.ts → terafy.client.js} +85 -84
- package/lib/{terafy.proxy.ts → terafy.proxy.js} +12 -26
- package/lib/{terafy.server.ts → terafy.server.js} +204 -229
- package/package.json +20 -39
- package/plugins/{base.ts → base.js} +3 -5
- package/plugins/{firebase.ts → firebase.js} +22 -21
- package/plugins/{vite.ts → vite.js} +3 -3
- package/plugins/{vue2.ts → vue2.js} +8 -10
- package/plugins/{vue3.ts → vue3.js} +7 -10
- package/utils/mixin.js +15 -0
- package/utils/{pathTools.ts → pathTools.js} +8 -9
- package/widgets/tera-file-select.vue +1 -1
- package/dist/lib/projectFile.d.ts +0 -190
- package/dist/lib/projectFile.js +0 -305
- package/dist/lib/projectFile.js.map +0 -1
- package/dist/lib/syncro/entities.d.ts +0 -34
- package/dist/lib/syncro/entities.js +0 -212
- package/dist/lib/syncro/entities.js.map +0 -1
- package/dist/lib/syncro/keyed (Rhino's conflicted copy 2026-05-10).js +0 -287
- package/dist/lib/syncro/keyed.d.ts +0 -95
- package/dist/lib/syncro/keyed.js +0 -288
- package/dist/lib/syncro/keyed.js (Rhino's conflicted copy 2026-05-10).map +0 -1
- package/dist/lib/syncro/keyed.js.map +0 -1
- package/dist/lib/syncro/syncro (Rhino's conflicted copy 2026-05-10).js +0 -765
- package/dist/lib/syncro/syncro.d (Rhino's conflicted copy 2026-05-10).ts +0 -336
- package/dist/lib/syncro/syncro.d.ts +0 -343
- package/dist/lib/syncro/syncro.js +0 -771
- package/dist/lib/syncro/syncro.js (Rhino's conflicted copy 2026-05-10).map +0 -1
- package/dist/lib/syncro/syncro.js.map +0 -1
- package/dist/lib/terafy.bootstrapper.d.ts +0 -42
- package/dist/lib/terafy.bootstrapper.js +0 -129
- package/dist/lib/terafy.bootstrapper.js.map +0 -1
- package/dist/lib/terafy.client.d.ts +0 -555
- package/dist/lib/terafy.client.js +0 -1153
- package/dist/lib/terafy.client.js.map +0 -1
- package/dist/lib/terafy.proxy.d.ts +0 -66
- package/dist/lib/terafy.proxy.js +0 -130
- package/dist/lib/terafy.proxy.js.map +0 -1
- package/dist/lib/terafy.server.d.ts +0 -697
- package/dist/lib/terafy.server.js +0 -2062
- package/dist/lib/terafy.server.js.map +0 -1
- package/dist/plugin.vue2.es2019 (Rhino's conflicted copy 2026-05-10).js +0 -1271
- package/dist/plugins/base.d.ts +0 -20
- package/dist/plugins/base.js +0 -22
- package/dist/plugins/base.js.map +0 -1
- package/dist/plugins/firebase.d.ts +0 -62
- package/dist/plugins/firebase.js +0 -123
- package/dist/plugins/firebase.js.map +0 -1
- package/dist/plugins/vite.d.ts +0 -12
- package/dist/plugins/vite.js +0 -22
- package/dist/plugins/vite.js.map +0 -1
- package/dist/plugins/vue2.d.ts +0 -67
- package/dist/plugins/vue2.js +0 -104
- package/dist/plugins/vue2.js.map +0 -1
- package/dist/plugins/vue3.d.ts +0 -63
- package/dist/plugins/vue3.js +0 -93
- package/dist/plugins/vue3.js.map +0 -1
- package/dist/utils/mixin.d.ts +0 -11
- package/dist/utils/mixin.js +0 -15
- package/dist/utils/mixin.js.map +0 -1
- package/dist/utils/pDefer.d.ts +0 -16
- package/dist/utils/pDefer.js +0 -19
- package/dist/utils/pDefer.js.map +0 -1
- package/dist/utils/pathTools.d.ts +0 -70
- package/dist/utils/pathTools.js +0 -120
- package/dist/utils/pathTools.js.map +0 -1
- package/tsconfig.json +0 -30
- package/utils/mixin.ts +0 -18
- package/utils/pDefer.ts +0 -27
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import type TeraFy from './terafy.client.js';
|
|
2
|
-
interface TeraClient extends TeraFy {
|
|
3
|
-
getProjectFileContents: (id: any, options?: any) => any;
|
|
4
|
-
setProjectFileContents: (id: any, contents: any, options?: any) => any;
|
|
5
|
-
getProjectLibrary: (id: any, options?: any) => any;
|
|
6
|
-
setProjectLibrary: (id: any, refs: any, options?: any) => any;
|
|
7
|
-
}
|
|
8
|
-
type SupabaseFile = any;
|
|
9
|
-
type RefLibRef = any;
|
|
10
|
-
/**
|
|
11
|
-
* A project file fetched from TERA
|
|
12
|
-
* @class ProjectFile
|
|
13
|
-
*/
|
|
14
|
-
export default class ProjectFile {
|
|
15
|
-
/**
|
|
16
|
-
* Parent TeraClient instance used by all helper functions
|
|
17
|
-
* @type {TeraClient}
|
|
18
|
-
* @private
|
|
19
|
-
*/
|
|
20
|
-
_tera: TeraClient;
|
|
21
|
-
/**
|
|
22
|
-
* The TERA compatible unique ID of the file
|
|
23
|
-
* NOTE: This is computed each time from the Base64 of the file path
|
|
24
|
-
* @type {String}
|
|
25
|
-
*/
|
|
26
|
-
id: string;
|
|
27
|
-
/**
|
|
28
|
-
* The raw Supabase UUID of the file
|
|
29
|
-
* @type {String}
|
|
30
|
-
*/
|
|
31
|
-
sbId: string;
|
|
32
|
-
/**
|
|
33
|
-
* Relative name path (can contain prefix directories) for the human readable file name
|
|
34
|
-
* @type {String}
|
|
35
|
-
*/
|
|
36
|
-
name: string;
|
|
37
|
-
/**
|
|
38
|
-
* CSS class to use as the file icon
|
|
39
|
-
* @type {String}
|
|
40
|
-
*/
|
|
41
|
-
icon: string;
|
|
42
|
-
/**
|
|
43
|
-
* Full path to the file
|
|
44
|
-
* This is also used as the unique identifier within the project
|
|
45
|
-
* @type {String}
|
|
46
|
-
*/
|
|
47
|
-
path: string;
|
|
48
|
-
/**
|
|
49
|
-
* Fully qualified URL to view / access / download the file from TERA
|
|
50
|
-
* This will usually open an edit UI within the TERA site
|
|
51
|
-
* @type {String}
|
|
52
|
-
*/
|
|
53
|
-
url: string;
|
|
54
|
-
/**
|
|
55
|
-
* Rewrite of the URL where the absolute URL has been removed in place of a relative path, assuming the owner project is active
|
|
56
|
-
* This is used to direct to the edit/view/download UI when the files project is active and is usually used in place of URL for TERA related operations
|
|
57
|
-
* @type {String}
|
|
58
|
-
*/
|
|
59
|
-
teraUrl: string;
|
|
60
|
-
/**
|
|
61
|
-
* An object representing meta file parts of a file name
|
|
62
|
-
* @type {Object}
|
|
63
|
-
* @property {String} basename The filename + extension (i.e. everything without directory name)
|
|
64
|
-
* @property {String} filename The file portion of the name (basename without the extension)
|
|
65
|
-
* @property {String} ext The extension portion of the name (always lower case)
|
|
66
|
-
* @property {String} dirName The directory path portion of the name
|
|
67
|
-
*/
|
|
68
|
-
parsedName: any;
|
|
69
|
-
/**
|
|
70
|
-
* A date representing when the file was created
|
|
71
|
-
* @type {Date}
|
|
72
|
-
*/
|
|
73
|
-
created: Date | undefined;
|
|
74
|
-
/**
|
|
75
|
-
* A human readable, formatted version of "created"
|
|
76
|
-
* @type {String}
|
|
77
|
-
*/
|
|
78
|
-
createdFormatted: string;
|
|
79
|
-
/**
|
|
80
|
-
* A date representing when the file was created
|
|
81
|
-
* @type {Date}
|
|
82
|
-
*/
|
|
83
|
-
modified: Date | undefined;
|
|
84
|
-
/**
|
|
85
|
-
* A human readable, formatted version of "modified"
|
|
86
|
-
* @type {String}
|
|
87
|
-
*/
|
|
88
|
-
modifiedFormatted: string;
|
|
89
|
-
/**
|
|
90
|
-
* A date representing when the file was last accessed
|
|
91
|
-
* @type {Date}
|
|
92
|
-
*/
|
|
93
|
-
accessed: Date | undefined;
|
|
94
|
-
/**
|
|
95
|
-
* A human readable, formatted version of "accessed"
|
|
96
|
-
* @type {String}
|
|
97
|
-
*/
|
|
98
|
-
accessedFormatted: string;
|
|
99
|
-
/**
|
|
100
|
-
* Size, in bytes, of the file
|
|
101
|
-
* @type {Number}
|
|
102
|
-
*/
|
|
103
|
-
size: number | undefined;
|
|
104
|
-
/**
|
|
105
|
-
* A human readable, formatted version of the file size
|
|
106
|
-
* @type {String}
|
|
107
|
-
*/
|
|
108
|
-
sizeFormatted: string;
|
|
109
|
-
/**
|
|
110
|
-
* The associated mime type for the file
|
|
111
|
-
* @type {String}
|
|
112
|
-
*/
|
|
113
|
-
mime: string;
|
|
114
|
-
/**
|
|
115
|
-
* Additional meta information for the file
|
|
116
|
-
* @type {Object}
|
|
117
|
-
*/
|
|
118
|
-
meta: Record<string, any>;
|
|
119
|
-
/**
|
|
120
|
-
* Whether this is a folder or not
|
|
121
|
-
*/
|
|
122
|
-
isFolder: boolean;
|
|
123
|
-
/**
|
|
124
|
-
* If it is a folder, it will have an array of files in the folder
|
|
125
|
-
*/
|
|
126
|
-
files?: ProjectFile[];
|
|
127
|
-
/**
|
|
128
|
-
* ProjectFile constructor
|
|
129
|
-
* Takes the input basic file type from Supabase and adds additional formatted fields
|
|
130
|
-
* @param {SupabaseFile} baseFile The basic Supabase file to extend
|
|
131
|
-
* @param {TeraFyClient} baseFile.tera The associated TeraFyClient instance to use for some file methods
|
|
132
|
-
*/
|
|
133
|
-
constructor(baseFile: SupabaseFile);
|
|
134
|
-
/**
|
|
135
|
-
* Fetch the raw file contents as a Blob
|
|
136
|
-
*
|
|
137
|
-
* @param {Object} [options] Additional options to mutate behaviour
|
|
138
|
-
*
|
|
139
|
-
* @returns {Promise<Blob>} The eventual raw file contents as a Blob
|
|
140
|
-
*
|
|
141
|
-
* @see getProjectFile()
|
|
142
|
-
*/
|
|
143
|
-
getContents(options?: any): Promise<Blob>;
|
|
144
|
-
/**
|
|
145
|
-
* Overwrite the contents of a file with new content
|
|
146
|
-
*
|
|
147
|
-
* @param {File|Blob|FormData|Object|Array} contents The new file contents
|
|
148
|
-
*
|
|
149
|
-
* @returns {Promise<void>} A promise which resolves when the operation has completed
|
|
150
|
-
*
|
|
151
|
-
* @see setProjectFileContents()
|
|
152
|
-
*/
|
|
153
|
-
setContents(contents: File | Blob | FormData | object | any[]): Promise<void>;
|
|
154
|
-
/**
|
|
155
|
-
* Fetch the file contents as an array of Reflib refs
|
|
156
|
-
*
|
|
157
|
-
* @returns {Promise<Array<RefLibRef>>} An eventual array of RefLib references
|
|
158
|
-
*
|
|
159
|
-
* @see getProjectLibrary()
|
|
160
|
-
*/
|
|
161
|
-
getRefs(): Promise<Array<RefLibRef>>;
|
|
162
|
-
/**
|
|
163
|
-
* Overwrite the contents of a file with a new collection of Reflib refs
|
|
164
|
-
*
|
|
165
|
-
* @param {Array<RefLibRef>} refs Collection of references for the selected library
|
|
166
|
-
*
|
|
167
|
-
* @returns {Promise<void>} A promise which resolves when the operation has completed
|
|
168
|
-
*
|
|
169
|
-
* @see setProjectLibrary()
|
|
170
|
-
*/
|
|
171
|
-
setRefs(refs: Array<RefLibRef>): Promise<void>;
|
|
172
|
-
/**
|
|
173
|
-
* Compress a file state down into a serializable entity
|
|
174
|
-
* By default this computes a Structured Clone which can be stringified
|
|
175
|
-
*
|
|
176
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
|
|
177
|
-
* @returns {Object} A Structured Clone compatible representation of this ProjectFile instance
|
|
178
|
-
*/
|
|
179
|
-
serialize(): Partial<ProjectFile>;
|
|
180
|
-
/**
|
|
181
|
-
* Restore an entity created with serialize
|
|
182
|
-
* NOTE: This requires the 'tera' instance to be manually added to the 'data' object before calling deserialize,
|
|
183
|
-
* as it's not included in the serialized output.
|
|
184
|
-
*
|
|
185
|
-
* @param {Object} data An input object created via `ProjectFiles.serialize()` (MUST include a 'tera' property added manually)
|
|
186
|
-
* @returns {ProjectFile} A ProjectFile instance setup against the deserialized data
|
|
187
|
-
*/
|
|
188
|
-
static deserialize(data: any): ProjectFile;
|
|
189
|
-
}
|
|
190
|
-
export {};
|
package/dist/lib/projectFile.js
DELETED
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
|
-
import { filesize } from 'filesize';
|
|
3
|
-
import { pick, omit } from 'lodash-es';
|
|
4
|
-
;
|
|
5
|
-
/**
|
|
6
|
-
* A project file fetched from TERA
|
|
7
|
-
* @class ProjectFile
|
|
8
|
-
*/
|
|
9
|
-
export default class ProjectFile {
|
|
10
|
-
/**
|
|
11
|
-
* Parent TeraClient instance used by all helper functions
|
|
12
|
-
* @type {TeraClient}
|
|
13
|
-
* @private
|
|
14
|
-
*/
|
|
15
|
-
_tera;
|
|
16
|
-
/**
|
|
17
|
-
* The TERA compatible unique ID of the file
|
|
18
|
-
* NOTE: This is computed each time from the Base64 of the file path
|
|
19
|
-
* @type {String}
|
|
20
|
-
*/
|
|
21
|
-
id;
|
|
22
|
-
/**
|
|
23
|
-
* The raw Supabase UUID of the file
|
|
24
|
-
* @type {String}
|
|
25
|
-
*/
|
|
26
|
-
sbId;
|
|
27
|
-
/**
|
|
28
|
-
* Relative name path (can contain prefix directories) for the human readable file name
|
|
29
|
-
* @type {String}
|
|
30
|
-
*/
|
|
31
|
-
name;
|
|
32
|
-
/**
|
|
33
|
-
* CSS class to use as the file icon
|
|
34
|
-
* @type {String}
|
|
35
|
-
*/
|
|
36
|
-
icon;
|
|
37
|
-
/**
|
|
38
|
-
* Full path to the file
|
|
39
|
-
* This is also used as the unique identifier within the project
|
|
40
|
-
* @type {String}
|
|
41
|
-
*/
|
|
42
|
-
path;
|
|
43
|
-
/**
|
|
44
|
-
* Fully qualified URL to view / access / download the file from TERA
|
|
45
|
-
* This will usually open an edit UI within the TERA site
|
|
46
|
-
* @type {String}
|
|
47
|
-
*/
|
|
48
|
-
url;
|
|
49
|
-
/**
|
|
50
|
-
* Rewrite of the URL where the absolute URL has been removed in place of a relative path, assuming the owner project is active
|
|
51
|
-
* This is used to direct to the edit/view/download UI when the files project is active and is usually used in place of URL for TERA related operations
|
|
52
|
-
* @type {String}
|
|
53
|
-
*/
|
|
54
|
-
teraUrl;
|
|
55
|
-
/**
|
|
56
|
-
* An object representing meta file parts of a file name
|
|
57
|
-
* @type {Object}
|
|
58
|
-
* @property {String} basename The filename + extension (i.e. everything without directory name)
|
|
59
|
-
* @property {String} filename The file portion of the name (basename without the extension)
|
|
60
|
-
* @property {String} ext The extension portion of the name (always lower case)
|
|
61
|
-
* @property {String} dirName The directory path portion of the name
|
|
62
|
-
*/
|
|
63
|
-
// Using 'any' for simplicity, define an interface for better type safety if desired
|
|
64
|
-
parsedName;
|
|
65
|
-
/**
|
|
66
|
-
* A date representing when the file was created
|
|
67
|
-
* @type {Date}
|
|
68
|
-
*/
|
|
69
|
-
// Using Date | undefined because constructor checks if it exists
|
|
70
|
-
created;
|
|
71
|
-
/**
|
|
72
|
-
* A human readable, formatted version of "created"
|
|
73
|
-
* @type {String}
|
|
74
|
-
*/
|
|
75
|
-
createdFormatted;
|
|
76
|
-
/**
|
|
77
|
-
* A date representing when the file was created
|
|
78
|
-
* @type {Date}
|
|
79
|
-
*/
|
|
80
|
-
// Using Date | undefined because constructor checks if it exists
|
|
81
|
-
modified;
|
|
82
|
-
/**
|
|
83
|
-
* A human readable, formatted version of "modified"
|
|
84
|
-
* @type {String}
|
|
85
|
-
*/
|
|
86
|
-
modifiedFormatted;
|
|
87
|
-
/**
|
|
88
|
-
* A date representing when the file was last accessed
|
|
89
|
-
* @type {Date}
|
|
90
|
-
*/
|
|
91
|
-
// Using Date | undefined because constructor checks if it exists
|
|
92
|
-
accessed;
|
|
93
|
-
/**
|
|
94
|
-
* A human readable, formatted version of "accessed"
|
|
95
|
-
* @type {String}
|
|
96
|
-
*/
|
|
97
|
-
accessedFormatted;
|
|
98
|
-
/**
|
|
99
|
-
* Size, in bytes, of the file
|
|
100
|
-
* @type {Number}
|
|
101
|
-
*/
|
|
102
|
-
// Using number | undefined because constructor uses `|| 0`
|
|
103
|
-
size;
|
|
104
|
-
/**
|
|
105
|
-
* A human readable, formatted version of the file size
|
|
106
|
-
* @type {String}
|
|
107
|
-
*/
|
|
108
|
-
sizeFormatted;
|
|
109
|
-
/**
|
|
110
|
-
* The associated mime type for the file
|
|
111
|
-
* @type {String}
|
|
112
|
-
*/
|
|
113
|
-
mime;
|
|
114
|
-
/**
|
|
115
|
-
* Additional meta information for the file
|
|
116
|
-
* @type {Object}
|
|
117
|
-
*/
|
|
118
|
-
// Using Record<string, any> for a generic object, adjust if meta has a known structure
|
|
119
|
-
meta = {};
|
|
120
|
-
/**
|
|
121
|
-
* Whether this is a folder or not
|
|
122
|
-
*/
|
|
123
|
-
isFolder;
|
|
124
|
-
/**
|
|
125
|
-
* If it is a folder, it will have an array of files in the folder
|
|
126
|
-
*/
|
|
127
|
-
files;
|
|
128
|
-
/**
|
|
129
|
-
* ProjectFile constructor
|
|
130
|
-
* Takes the input basic file type from Supabase and adds additional formatted fields
|
|
131
|
-
* @param {SupabaseFile} baseFile The basic Supabase file to extend
|
|
132
|
-
* @param {TeraFyClient} baseFile.tera The associated TeraFyClient instance to use for some file methods
|
|
133
|
-
*/
|
|
134
|
-
constructor(baseFile) {
|
|
135
|
-
// Note: baseFile.tera is assumed to exist based on the check below and the SupabaseFile type definition above
|
|
136
|
-
if (!baseFile.tera)
|
|
137
|
-
throw new Error('Basic file requires a `tera` key to access the Tera instance');
|
|
138
|
-
Object.assign(this, omit(baseFile, 'encodeIdFunction')); // don't copy encodeIdFunction
|
|
139
|
-
// Check whether encodeIdFunction exists and if it does then parse the id
|
|
140
|
-
if (baseFile.encodeIdFunction && typeof baseFile.encodeIdFunction === 'function') {
|
|
141
|
-
this.id = baseFile.encodeIdFunction(this.id);
|
|
142
|
-
}
|
|
143
|
-
// Translate baseFile.tera -> this._tera (non-enumerable, non-configurable)
|
|
144
|
-
const tera = this.tera;
|
|
145
|
-
Object.defineProperty(this, '_tera', {
|
|
146
|
-
enumerable: false,
|
|
147
|
-
configurable: false,
|
|
148
|
-
get() {
|
|
149
|
-
// NOTE: We can't just set {value:tera} as it upsets how Vue uses proxies
|
|
150
|
-
return tera;
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
delete this.tera; // Remove original ref we merged above
|
|
154
|
-
// Ensure date properties are actual Date objects, not strings.
|
|
155
|
-
// This makes the class resilient to the format of the input data.
|
|
156
|
-
if (this.created && typeof this.created === 'string') {
|
|
157
|
-
this.created = new Date(this.created);
|
|
158
|
-
}
|
|
159
|
-
if (this.modified && typeof this.modified === 'string') {
|
|
160
|
-
this.modified = new Date(this.modified);
|
|
161
|
-
}
|
|
162
|
-
if (this.accessed && typeof this.accessed === 'string') {
|
|
163
|
-
this.accessed = new Date(this.accessed);
|
|
164
|
-
}
|
|
165
|
-
if (this.isFolder) {
|
|
166
|
-
// Process all files in the folder
|
|
167
|
-
this.files = this.files?.map(file => {
|
|
168
|
-
const path = file.path.split(/\//).slice(3).join('/');
|
|
169
|
-
let url = this.url + '/' + file.name; // Add file name to url
|
|
170
|
-
// Parse url to show library instead of download if reflib file
|
|
171
|
-
if (file.meta.reflib) {
|
|
172
|
-
url = url.replace(/\/project\/download\//, '/project/library/');
|
|
173
|
-
}
|
|
174
|
-
return new ProjectFile({
|
|
175
|
-
tera: this._tera,
|
|
176
|
-
...file,
|
|
177
|
-
sbId: file.id, // Sash the original Supabase ID under sbId
|
|
178
|
-
id: file.path,
|
|
179
|
-
encodeIdFunction: baseFile.encodeIdFunction,
|
|
180
|
-
path,
|
|
181
|
-
url,
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
// Calculate `teraUrl` from URL
|
|
186
|
-
// Assuming this.url is always defined after Object.assign
|
|
187
|
-
this.teraUrl = this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/, '/project/$1');
|
|
188
|
-
// Set all `*Formatted` fields
|
|
189
|
-
this.sizeFormatted = filesize(this.size || 0, { spacer: '' });
|
|
190
|
-
this.createdFormatted = this.created ? this.created.toLocaleDateString() : 'Unknown created date';
|
|
191
|
-
this.modifiedFormatted = this.modified ? this.modified.toLocaleDateString() : 'Unknown modified date';
|
|
192
|
-
this.accessedFormatted = this.accessed ? this.accessed.toLocaleDateString() : 'Unknown access date';
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Fetch the raw file contents as a Blob
|
|
196
|
-
*
|
|
197
|
-
* @param {Object} [options] Additional options to mutate behaviour
|
|
198
|
-
*
|
|
199
|
-
* @returns {Promise<Blob>} The eventual raw file contents as a Blob
|
|
200
|
-
*
|
|
201
|
-
* @see getProjectFile()
|
|
202
|
-
*/
|
|
203
|
-
getContents(options) {
|
|
204
|
-
// Assuming _tera has this method and it returns Promise<Blob>
|
|
205
|
-
return this._tera.getProjectFileContents(this.id, options);
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Overwrite the contents of a file with new content
|
|
209
|
-
*
|
|
210
|
-
* @param {File|Blob|FormData|Object|Array} contents The new file contents
|
|
211
|
-
*
|
|
212
|
-
* @returns {Promise<void>} A promise which resolves when the operation has completed
|
|
213
|
-
*
|
|
214
|
-
* @see setProjectFileContents()
|
|
215
|
-
*/
|
|
216
|
-
setContents(contents) {
|
|
217
|
-
// Assuming _tera has this method and it returns Promise<void> or similar
|
|
218
|
-
return this._tera.setProjectFileContents(this.id, contents, {});
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Fetch the file contents as an array of Reflib refs
|
|
222
|
-
*
|
|
223
|
-
* @returns {Promise<Array<RefLibRef>>} An eventual array of RefLib references
|
|
224
|
-
*
|
|
225
|
-
* @see getProjectLibrary()
|
|
226
|
-
*/
|
|
227
|
-
getRefs() {
|
|
228
|
-
// Assuming _tera has this method and it returns Promise<Array<RefLibRef>>
|
|
229
|
-
return this._tera.getProjectLibrary(this.id);
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Overwrite the contents of a file with a new collection of Reflib refs
|
|
233
|
-
*
|
|
234
|
-
* @param {Array<RefLibRef>} refs Collection of references for the selected library
|
|
235
|
-
*
|
|
236
|
-
* @returns {Promise<void>} A promise which resolves when the operation has completed
|
|
237
|
-
*
|
|
238
|
-
* @see setProjectLibrary()
|
|
239
|
-
*/
|
|
240
|
-
setRefs(refs) {
|
|
241
|
-
// Assuming _tera has this method and it returns Promise<void> or similar
|
|
242
|
-
return this._tera.setProjectLibrary(this.id, refs);
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Compress a file state down into a serializable entity
|
|
246
|
-
* By default this computes a Structured Clone which can be stringified
|
|
247
|
-
*
|
|
248
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
|
|
249
|
-
* @returns {Object} A Structured Clone compatible representation of this ProjectFile instance
|
|
250
|
-
*/
|
|
251
|
-
serialize() {
|
|
252
|
-
return pick(this, [
|
|
253
|
-
'id',
|
|
254
|
-
'sbId',
|
|
255
|
-
'name',
|
|
256
|
-
'icon',
|
|
257
|
-
'path',
|
|
258
|
-
'url',
|
|
259
|
-
'parsedName',
|
|
260
|
-
'created',
|
|
261
|
-
'modified',
|
|
262
|
-
'accessed',
|
|
263
|
-
'size',
|
|
264
|
-
'mime',
|
|
265
|
-
'meta',
|
|
266
|
-
// Note that computed values such as `*Formatted` are omitted as they can be computed during the constructor stage
|
|
267
|
-
]);
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Restore an entity created with serialize
|
|
271
|
-
* NOTE: This requires the 'tera' instance to be manually added to the 'data' object before calling deserialize,
|
|
272
|
-
* as it's not included in the serialized output.
|
|
273
|
-
*
|
|
274
|
-
* @param {Object} data An input object created via `ProjectFiles.serialize()` (MUST include a 'tera' property added manually)
|
|
275
|
-
* @returns {ProjectFile} A ProjectFile instance setup against the deserialized data
|
|
276
|
-
*/
|
|
277
|
-
static deserialize(data) {
|
|
278
|
-
// TODO: Check the below
|
|
279
|
-
// WARNING: The original 'serialize' method does NOT include 'tera'.
|
|
280
|
-
// The caller of 'deserialize' MUST add the correct 'tera' instance to the 'data' object
|
|
281
|
-
// before passing it here, otherwise the constructor will fail.
|
|
282
|
-
// e.g., const serializedData = file.serialize();
|
|
283
|
-
// serializedData.tera = myTeraClientInstance;
|
|
284
|
-
// const restoredFile = ProjectFile.deserialize(serializedData);
|
|
285
|
-
// This pick includes 'tera', assuming it was added to 'data' externally.
|
|
286
|
-
const constructorArg = pick(data, [
|
|
287
|
-
'tera', // Assumes 'tera' exists on the input 'data' object
|
|
288
|
-
'id',
|
|
289
|
-
'sbId',
|
|
290
|
-
'name',
|
|
291
|
-
'icon',
|
|
292
|
-
'path',
|
|
293
|
-
'url',
|
|
294
|
-
'parsedName',
|
|
295
|
-
'created',
|
|
296
|
-
'modified',
|
|
297
|
-
'accessed',
|
|
298
|
-
'size',
|
|
299
|
-
'mime',
|
|
300
|
-
'meta',
|
|
301
|
-
]);
|
|
302
|
-
return new ProjectFile(constructorArg);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
//# sourceMappingURL=projectFile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"projectFile.js","sourceRoot":"","sources":["../../lib/projectFile.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAStC,CAAC;AAIF;;;EAGE;AACF,MAAM,CAAC,OAAO,OAAO,WAAW;IAE/B;;;;MAIE;IACF,KAAK,CAAc;IAGnB;;;;MAIE;IACF,EAAE,CAAU;IAGZ;;;MAGE;IACF,IAAI,CAAU;IAGd;;;MAGE;IACF,IAAI,CAAU;IAGd;;;MAGE;IACF,IAAI,CAAU;IAGd;;;;MAIE;IACF,IAAI,CAAU;IAGd;;;;MAIE;IACF,GAAG,CAAU;IAGb;;;;MAIE;IACF,OAA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I,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;IACjE,CAAC;IAGD;;;;;;MAME;IAEF,OAAO;QACN,0EAA0E;QAC1E,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9C,CAAC;IAGD;;;;;;;;MAQE;IAEF,OAAO,CAAC,IAAsB;QAC7B,yEAAyE;QACzE,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;IAGD;;;;;;MAME;IAEF,SAAS;QACR,OAAO,IAAI,CAAC,IAAI,EAAE;YACjB,IAAI;YACJ,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,KAAK;YACL,YAAY;YACZ,SAAS;YACT,UAAU;YACV,UAAU;YACV,MAAM;YACN,MAAM;YACN,MAAM;YACN,kHAAkH;SAClH,CAAC,CAAC;IACJ,CAAC;IAGD;;;;;;;MAOE;IAEF,MAAM,CAAC,WAAW,CAAC,IAAS;QAC3B,wBAAwB;QACxB,oEAAoE;QACpE,wFAAwF;QACxF,+DAA+D;QAC/D,iDAAiD;QACjD,oDAAoD;QACpD,sEAAsE;QAEtE,yEAAyE;QACzE,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,EAAE;YACjC,MAAM,EAAE,mDAAmD;YAC3D,IAAI;YACJ,MAAM;YACN,MAAM;YACN,MAAM;YACN,MAAM;YACN,KAAK;YACL,YAAY;YACZ,SAAS;YACT,UAAU;YACV,UAAU;YACV,MAAM;YACN,MAAM;YACN,MAAM;SACN,CAAC,CAAC;QACH,OAAO,IAAI,WAAW,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC;CACD"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { BoundSupabaseyFunction } from '@iebh/supabasey';
|
|
2
|
-
export interface PostgresSql {
|
|
3
|
-
(strings: TemplateStringsArray, ...values: any[]): Promise<any[]>;
|
|
4
|
-
json(value: any): any;
|
|
5
|
-
}
|
|
6
|
-
interface SyncroEntityConfig {
|
|
7
|
-
singular: string;
|
|
8
|
-
initState: (args: {
|
|
9
|
-
HYPERDRIVE: PostgresSql;
|
|
10
|
-
supabasey: BoundSupabaseyFunction;
|
|
11
|
-
id: string;
|
|
12
|
-
relation?: string;
|
|
13
|
-
}) => Promise<any>;
|
|
14
|
-
flushState: (args: {
|
|
15
|
-
HYPERDRIVE: PostgresSql;
|
|
16
|
-
supabasey?: BoundSupabaseyFunction;
|
|
17
|
-
state: any;
|
|
18
|
-
id?: string;
|
|
19
|
-
fsId?: string;
|
|
20
|
-
relation?: string;
|
|
21
|
-
}) => Promise<any>;
|
|
22
|
-
}
|
|
23
|
-
type SyncroConfig = Record<string, SyncroEntityConfig>;
|
|
24
|
-
/**
|
|
25
|
-
* Entities we support Syncro paths for, each should correspond directly with a Firebase/Firestore collection name
|
|
26
|
-
*
|
|
27
|
-
* @type {Object} An object lookup of entities
|
|
28
|
-
*
|
|
29
|
-
* @property {String} singular The singular noun for the item
|
|
30
|
-
* @property {Function} initState Function called to initialize state when Firestore has no existing document. Called as `({HYPERDRIVE:PostgresSql, supabasey:BoundSupabaseyFunction, id:String, relation?:string})` and expected to return the initial data object state
|
|
31
|
-
* @property {Function} flushState Function called to flush state from Firebase to Postgres. Called the same as `initState` + `{state:Object}`
|
|
32
|
-
*/
|
|
33
|
-
declare const syncroConfig: SyncroConfig;
|
|
34
|
-
export default syncroConfig;
|