@iebh/tera-fy 1.0.1
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/.storybook/main.js +22 -0
- package/.storybook/preview.js +17 -0
- package/LICENSE +20 -0
- package/README.md +7 -0
- package/dist/terafy.js +12 -0
- package/dist/terafy.js.map +7 -0
- package/docs/terafy.client.md +154 -0
- package/docs/terafy.server.md +221 -0
- package/index.html +258 -0
- package/lib/terafy.client.js +345 -0
- package/lib/terafy.server.js +362 -0
- package/package.json +78 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
<a name="TeraFy"></a>
|
|
2
|
+
|
|
3
|
+
## TeraFy
|
|
4
|
+
**Kind**: global class
|
|
5
|
+
|
|
6
|
+
* [TeraFy](#TeraFy)
|
|
7
|
+
* [new TeraFy()](#new_TeraFy_new)
|
|
8
|
+
* [.settings](#TeraFy+settings) : <code>Object</code>
|
|
9
|
+
* [.dom](#TeraFy+dom) : <code>Object</code>
|
|
10
|
+
* [.methods](#TeraFy+methods) : <code>Array.<String></code>
|
|
11
|
+
* [.acceptPostboxes](#TeraFy+acceptPostboxes)
|
|
12
|
+
* [.send(message)](#TeraFy+send) ⇒ <code>Promise.<\*></code>
|
|
13
|
+
* [.sendRaw(message)](#TeraFy+sendRaw)
|
|
14
|
+
* [.rpc(method)](#TeraFy+rpc) ⇒ <code>Promise.<\*></code>
|
|
15
|
+
* [.acceptMessage(Raw)](#TeraFy+acceptMessage)
|
|
16
|
+
* [.init()](#TeraFy+init)
|
|
17
|
+
* [.injectMain()](#TeraFy+injectMain)
|
|
18
|
+
* [.injectStylesheet()](#TeraFy+injectStylesheet)
|
|
19
|
+
* [.injectMethods()](#TeraFy+injectMethods)
|
|
20
|
+
* [.bindProjectState([options], Paths)](#TeraFy+bindProjectState) ⇒ <code>Promies.<Reactive.<Object>></code>
|
|
21
|
+
|
|
22
|
+
<a name="new_TeraFy_new"></a>
|
|
23
|
+
|
|
24
|
+
### new TeraFy()
|
|
25
|
+
Main Tera-Fy Client (class singleton) to be used in a frontend browser
|
|
26
|
+
|
|
27
|
+
<a name="TeraFy+settings"></a>
|
|
28
|
+
|
|
29
|
+
### teraFy.settings : <code>Object</code>
|
|
30
|
+
Various settings to configure behaviour
|
|
31
|
+
|
|
32
|
+
**Kind**: instance property of [<code>TeraFy</code>](#TeraFy)
|
|
33
|
+
**Properties**
|
|
34
|
+
|
|
35
|
+
| Name | Type | Description |
|
|
36
|
+
| --- | --- | --- |
|
|
37
|
+
| devMode | <code>Boolean</code> | Operate in devMode - i.e. force outer refresh when encountering an existing TeraFy instance |
|
|
38
|
+
| siteUrl | <code>String</code> | The TERA URL to connect to |
|
|
39
|
+
| restrictOrigin | <code>String</code> | URL to restrict communications to |
|
|
40
|
+
|
|
41
|
+
<a name="TeraFy+dom"></a>
|
|
42
|
+
|
|
43
|
+
### teraFy.dom : <code>Object</code>
|
|
44
|
+
DOMElements for this TeraFy instance
|
|
45
|
+
|
|
46
|
+
**Kind**: instance property of [<code>TeraFy</code>](#TeraFy)
|
|
47
|
+
**Properties**
|
|
48
|
+
|
|
49
|
+
| Name | Type | Description |
|
|
50
|
+
| --- | --- | --- |
|
|
51
|
+
| el | <code>DOMElement</code> | The main tera-fy div wrapper |
|
|
52
|
+
| iframe | <code>DOMElement</code> | The internal iFrame element |
|
|
53
|
+
| stylesheet | <code>DOMElement</code> | The corresponding stylesheet |
|
|
54
|
+
|
|
55
|
+
<a name="TeraFy+methods"></a>
|
|
56
|
+
|
|
57
|
+
### teraFy.methods : <code>Array.<String></code>
|
|
58
|
+
List of function stubs mapped here from the server
|
|
59
|
+
This array is forms the reference of `TeraFy.METHOD()` objects to provide locally which will be mapped via `TeraFy.rpc(METHOD, ...args)`
|
|
60
|
+
|
|
61
|
+
**Kind**: instance property of [<code>TeraFy</code>](#TeraFy)
|
|
62
|
+
<a name="TeraFy+acceptPostboxes"></a>
|
|
63
|
+
|
|
64
|
+
### teraFy.acceptPostboxes
|
|
65
|
+
Listening postboxes, these correspond to outgoing message IDs that expect a response
|
|
66
|
+
|
|
67
|
+
**Kind**: instance property of [<code>TeraFy</code>](#TeraFy)
|
|
68
|
+
<a name="TeraFy+send"></a>
|
|
69
|
+
|
|
70
|
+
### teraFy.send(message) ⇒ <code>Promise.<\*></code>
|
|
71
|
+
Send a message + wait for a response object
|
|
72
|
+
|
|
73
|
+
**Kind**: instance method of [<code>TeraFy</code>](#TeraFy)
|
|
74
|
+
**Returns**: <code>Promise.<\*></code> - A promise which resolves when the operation has completed with the remote reply
|
|
75
|
+
|
|
76
|
+
| Param | Type | Description |
|
|
77
|
+
| --- | --- | --- |
|
|
78
|
+
| message | <code>Object</code> | Message object to send |
|
|
79
|
+
|
|
80
|
+
<a name="TeraFy+sendRaw"></a>
|
|
81
|
+
|
|
82
|
+
### teraFy.sendRaw(message)
|
|
83
|
+
Send raw message content to the server
|
|
84
|
+
This function does not return or wait for a reply - use `send()` for that
|
|
85
|
+
|
|
86
|
+
**Kind**: instance method of [<code>TeraFy</code>](#TeraFy)
|
|
87
|
+
|
|
88
|
+
| Param | Type | Description |
|
|
89
|
+
| --- | --- | --- |
|
|
90
|
+
| message | <code>Object</code> | Message object to send |
|
|
91
|
+
|
|
92
|
+
<a name="TeraFy+rpc"></a>
|
|
93
|
+
|
|
94
|
+
### teraFy.rpc(method) ⇒ <code>Promise.<\*></code>
|
|
95
|
+
Call an RPC function in the server instance
|
|
96
|
+
|
|
97
|
+
**Kind**: instance method of [<code>TeraFy</code>](#TeraFy)
|
|
98
|
+
**Returns**: <code>Promise.<\*></code> - The resolved output of the server function
|
|
99
|
+
|
|
100
|
+
| Param | Type | Description |
|
|
101
|
+
| --- | --- | --- |
|
|
102
|
+
| method | <code>String</code> | The method name to call |
|
|
103
|
+
| [...] | <code>\*</code> | Optional arguments to pass to the function |
|
|
104
|
+
|
|
105
|
+
<a name="TeraFy+acceptMessage"></a>
|
|
106
|
+
|
|
107
|
+
### teraFy.acceptMessage(Raw)
|
|
108
|
+
Accept an incoming message
|
|
109
|
+
|
|
110
|
+
**Kind**: instance method of [<code>TeraFy</code>](#TeraFy)
|
|
111
|
+
|
|
112
|
+
| Param | Type | Description |
|
|
113
|
+
| --- | --- | --- |
|
|
114
|
+
| Raw | <code>MessageEvent</code> | message event to process |
|
|
115
|
+
|
|
116
|
+
<a name="TeraFy+init"></a>
|
|
117
|
+
|
|
118
|
+
### teraFy.init()
|
|
119
|
+
Initalize the TERA client singleton
|
|
120
|
+
|
|
121
|
+
**Kind**: instance method of [<code>TeraFy</code>](#TeraFy)
|
|
122
|
+
<a name="TeraFy+injectMain"></a>
|
|
123
|
+
|
|
124
|
+
### teraFy.injectMain()
|
|
125
|
+
Find an existing active TERA server OR initalize one
|
|
126
|
+
|
|
127
|
+
**Kind**: instance method of [<code>TeraFy</code>](#TeraFy)
|
|
128
|
+
<a name="TeraFy+injectStylesheet"></a>
|
|
129
|
+
|
|
130
|
+
### teraFy.injectStylesheet()
|
|
131
|
+
Inject a local stylesheet to handle TERA server functionality
|
|
132
|
+
|
|
133
|
+
**Kind**: instance method of [<code>TeraFy</code>](#TeraFy)
|
|
134
|
+
<a name="TeraFy+injectMethods"></a>
|
|
135
|
+
|
|
136
|
+
### teraFy.injectMethods()
|
|
137
|
+
Inject all server methods defined in `methods` as local functions wrapped in the `rpc` function
|
|
138
|
+
|
|
139
|
+
**Kind**: instance method of [<code>TeraFy</code>](#TeraFy)
|
|
140
|
+
<a name="TeraFy+bindProjectState"></a>
|
|
141
|
+
|
|
142
|
+
### teraFy.bindProjectState([options], Paths) ⇒ <code>Promies.<Reactive.<Object>></code>
|
|
143
|
+
Return a Vue reactive object that can be read/written which whose changes will transparently be written back to the TERA server instance
|
|
144
|
+
|
|
145
|
+
**Kind**: instance method of [<code>TeraFy</code>](#TeraFy)
|
|
146
|
+
**Returns**: <code>Promies.<Reactive.<Object>></code> - A reactive object representing the project state
|
|
147
|
+
|
|
148
|
+
| Param | Type | Default | Description |
|
|
149
|
+
| --- | --- | --- | --- |
|
|
150
|
+
| [options] | <code>Object</code> | | Additional options to mutate behaviour |
|
|
151
|
+
| [options.autoRequire] | <code>Boolean</code> | <code>true</code> | Run `requireProject()` automatically before continuing |
|
|
152
|
+
| [options.write] | <code>Boolean</code> | <code>true</code> | Allow local reactivity to writes - send these to the server |
|
|
153
|
+
| Paths | <code>Array.<String></code> | | to subscribe to e.g. ['/users/'], |
|
|
154
|
+
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
## Classes
|
|
2
|
+
|
|
3
|
+
<dl>
|
|
4
|
+
<dt><a href="#TeraFyServer">TeraFyServer</a></dt>
|
|
5
|
+
<dd></dd>
|
|
6
|
+
<dt><a href="#User">User</a></dt>
|
|
7
|
+
<dd></dd>
|
|
8
|
+
<dt><a href="#Project">Project</a></dt>
|
|
9
|
+
<dd></dd>
|
|
10
|
+
</dl>
|
|
11
|
+
|
|
12
|
+
<a name="TeraFyServer"></a>
|
|
13
|
+
|
|
14
|
+
## TeraFyServer
|
|
15
|
+
**Kind**: global class
|
|
16
|
+
|
|
17
|
+
* [TeraFyServer](#TeraFyServer)
|
|
18
|
+
* [new TeraFyServer()](#new_TeraFyServer_new)
|
|
19
|
+
* [.settings](#TeraFyServer+settings) : <code>Object</code>
|
|
20
|
+
* [.sendRaw(message)](#TeraFyServer+sendRaw)
|
|
21
|
+
* [.acceptMessage(Raw)](#TeraFyServer+acceptMessage)
|
|
22
|
+
* [.handshake()](#TeraFyServer+handshake) ⇒ <code>Promise.<Object></code>
|
|
23
|
+
* [.getUser()](#TeraFyServer+getUser) ⇒ [<code>Promise.<User></code>](#User)
|
|
24
|
+
* [.getProject()](#TeraFyServer+getProject) ⇒ <code>Promise.<(Project\|null)></code>
|
|
25
|
+
* [.getProjects()](#TeraFyServer+getProjects) ⇒ <code>Promise.<Array.<Project>></code>
|
|
26
|
+
* [.requireProject()](#TeraFyServer+requireProject) ⇒ [<code>Promise.<Project></code>](#Project)
|
|
27
|
+
* [.selectProject([options])](#TeraFyServer+selectProject) ⇒ [<code>Promise.<Project></code>](#Project)
|
|
28
|
+
* [.getProjectStateSnapshot([options], Paths)](#TeraFyServer+getProjectStateSnapshot) ⇒ <code>Promise.<Object></code>
|
|
29
|
+
* [.applyProjectStatePatch()](#TeraFyServer+applyProjectStatePatch)
|
|
30
|
+
* [.getProjectLibrary([options])](#TeraFyServer+getProjectLibrary) ⇒ <code>Promise.<Array.<RefLibRef>></code>
|
|
31
|
+
* [.setProjectLibrary(Collection, [options])](#TeraFyServer+setProjectLibrary) ⇒ <code>Promise</code>
|
|
32
|
+
* [.init()](#TeraFyServer+init)
|
|
33
|
+
|
|
34
|
+
<a name="new_TeraFyServer_new"></a>
|
|
35
|
+
|
|
36
|
+
### new TeraFyServer()
|
|
37
|
+
Server-side functions available to the Tera-Fy client library
|
|
38
|
+
|
|
39
|
+
<a name="TeraFyServer+settings"></a>
|
|
40
|
+
|
|
41
|
+
### teraFyServer.settings : <code>Object</code>
|
|
42
|
+
Various settings to configure behaviour
|
|
43
|
+
|
|
44
|
+
**Kind**: instance property of [<code>TeraFyServer</code>](#TeraFyServer)
|
|
45
|
+
**Properties**
|
|
46
|
+
|
|
47
|
+
| Name | Type | Description |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| devMode | <code>Boolean</code> | Operate in devMode - i.e. force outer refresh when encountering an existing TeraFy instance |
|
|
50
|
+
| restrictOrigin | <code>String</code> | URL to restrict communications to |
|
|
51
|
+
|
|
52
|
+
<a name="TeraFyServer+sendRaw"></a>
|
|
53
|
+
|
|
54
|
+
### teraFyServer.sendRaw(message)
|
|
55
|
+
Send raw message content to the client
|
|
56
|
+
|
|
57
|
+
**Kind**: instance method of [<code>TeraFyServer</code>](#TeraFyServer)
|
|
58
|
+
|
|
59
|
+
| Param | Type | Description |
|
|
60
|
+
| --- | --- | --- |
|
|
61
|
+
| message | <code>Object</code> | Message object to send |
|
|
62
|
+
|
|
63
|
+
<a name="TeraFyServer+acceptMessage"></a>
|
|
64
|
+
|
|
65
|
+
### teraFyServer.acceptMessage(Raw)
|
|
66
|
+
Accept a message from the parent event listener
|
|
67
|
+
|
|
68
|
+
**Kind**: instance method of [<code>TeraFyServer</code>](#TeraFyServer)
|
|
69
|
+
|
|
70
|
+
| Param | Type | Description |
|
|
71
|
+
| --- | --- | --- |
|
|
72
|
+
| Raw | <code>MessageEvent</code> | message event to process |
|
|
73
|
+
|
|
74
|
+
<a name="TeraFyServer+handshake"></a>
|
|
75
|
+
|
|
76
|
+
### teraFyServer.handshake() ⇒ <code>Promise.<Object></code>
|
|
77
|
+
Return basic server information as a form of validation
|
|
78
|
+
|
|
79
|
+
**Kind**: instance method of [<code>TeraFyServer</code>](#TeraFyServer)
|
|
80
|
+
**Returns**: <code>Promise.<Object></code> - Basic promise result
|
|
81
|
+
**Properties**
|
|
82
|
+
|
|
83
|
+
| Name | Type | Description |
|
|
84
|
+
| --- | --- | --- |
|
|
85
|
+
| date | <code>Date</code> | Server date |
|
|
86
|
+
|
|
87
|
+
<a name="TeraFyServer+getUser"></a>
|
|
88
|
+
|
|
89
|
+
### teraFyServer.getUser() ⇒ [<code>Promise.<User></code>](#User)
|
|
90
|
+
Fetch the current session user
|
|
91
|
+
|
|
92
|
+
**Kind**: instance method of [<code>TeraFyServer</code>](#TeraFyServer)
|
|
93
|
+
**Returns**: [<code>Promise.<User></code>](#User) - The current logged in user or null if none
|
|
94
|
+
<a name="TeraFyServer+getProject"></a>
|
|
95
|
+
|
|
96
|
+
### teraFyServer.getProject() ⇒ <code>Promise.<(Project\|null)></code>
|
|
97
|
+
Get the currently active project, if any
|
|
98
|
+
|
|
99
|
+
**Kind**: instance method of [<code>TeraFyServer</code>](#TeraFyServer)
|
|
100
|
+
**Returns**: <code>Promise.<(Project\|null)></code> - The currently active project, if any
|
|
101
|
+
<a name="TeraFyServer+getProjects"></a>
|
|
102
|
+
|
|
103
|
+
### teraFyServer.getProjects() ⇒ <code>Promise.<Array.<Project>></code>
|
|
104
|
+
Get a list of projects the current session user has access to
|
|
105
|
+
|
|
106
|
+
**Kind**: instance method of [<code>TeraFyServer</code>](#TeraFyServer)
|
|
107
|
+
**Returns**: <code>Promise.<Array.<Project>></code> - Collection of projects the user has access to
|
|
108
|
+
<a name="TeraFyServer+requireProject"></a>
|
|
109
|
+
|
|
110
|
+
### teraFyServer.requireProject() ⇒ [<code>Promise.<Project></code>](#Project)
|
|
111
|
+
Ask the user to select a project from those available - if one isn't already active
|
|
112
|
+
Note that this function will percist in asking the uesr even if they try to cancel
|
|
113
|
+
|
|
114
|
+
**Kind**: instance method of [<code>TeraFyServer</code>](#TeraFyServer)
|
|
115
|
+
**Returns**: [<code>Promise.<Project></code>](#Project) - The active project
|
|
116
|
+
<a name="TeraFyServer+selectProject"></a>
|
|
117
|
+
|
|
118
|
+
### teraFyServer.selectProject([options]) ⇒ [<code>Promise.<Project></code>](#Project)
|
|
119
|
+
Prompt the user to select a project from those available
|
|
120
|
+
|
|
121
|
+
**Kind**: instance method of [<code>TeraFyServer</code>](#TeraFyServer)
|
|
122
|
+
**Returns**: [<code>Promise.<Project></code>](#Project) - The active project
|
|
123
|
+
|
|
124
|
+
| Param | Type | Default | Description |
|
|
125
|
+
| --- | --- | --- | --- |
|
|
126
|
+
| [options] | <code>Object</code> | | Additional options to mutate behaviour |
|
|
127
|
+
| [options.title] | <code>String</code> | <code>"Select a project to work with"</code> | The title of the dialog to display |
|
|
128
|
+
| [options.allowCancel] | <code>Boolean</code> | <code>true</code> | Advertise cancelling the operation, the dialog can still be cancelled by closing it |
|
|
129
|
+
|
|
130
|
+
<a name="TeraFyServer+getProjectStateSnapshot"></a>
|
|
131
|
+
|
|
132
|
+
### teraFyServer.getProjectStateSnapshot([options], Paths) ⇒ <code>Promise.<Object></code>
|
|
133
|
+
Return the current, full snapshot state of the active project
|
|
134
|
+
|
|
135
|
+
**Kind**: instance method of [<code>TeraFyServer</code>](#TeraFyServer)
|
|
136
|
+
**Returns**: <code>Promise.<Object></code> - The current project state snapshot
|
|
137
|
+
|
|
138
|
+
| Param | Type | Default | Description |
|
|
139
|
+
| --- | --- | --- | --- |
|
|
140
|
+
| [options] | <code>Object</code> | | Additional options to mutate behaviour |
|
|
141
|
+
| [options.autoRequire] | <code>Boolean</code> | <code>true</code> | Run `requireProject()` automatically before continuing |
|
|
142
|
+
| Paths | <code>Array.<String></code> | | to subscribe to e.g. ['/users/'], |
|
|
143
|
+
|
|
144
|
+
<a name="TeraFyServer+applyProjectStatePatch"></a>
|
|
145
|
+
|
|
146
|
+
### teraFyServer.applyProjectStatePatch()
|
|
147
|
+
Apply a computed `just-diff` patch to the current project state
|
|
148
|
+
|
|
149
|
+
**Kind**: instance method of [<code>TeraFyServer</code>](#TeraFyServer)
|
|
150
|
+
<a name="TeraFyServer+getProjectLibrary"></a>
|
|
151
|
+
|
|
152
|
+
### teraFyServer.getProjectLibrary([options]) ⇒ <code>Promise.<Array.<RefLibRef>></code>
|
|
153
|
+
Fetch the active projects citation library
|
|
154
|
+
|
|
155
|
+
**Kind**: instance method of [<code>TeraFyServer</code>](#TeraFyServer)
|
|
156
|
+
**Returns**: <code>Promise.<Array.<RefLibRef>></code> - Collection of references for the selected library
|
|
157
|
+
|
|
158
|
+
| Param | Type | Default | Description |
|
|
159
|
+
| --- | --- | --- | --- |
|
|
160
|
+
| [options] | <code>Object</code> | | Additional options to mutate behaviour |
|
|
161
|
+
| [options.autoRequire] | <code>Boolean</code> | <code>true</code> | Run `requireProject()` automatically before continuing |
|
|
162
|
+
| [options.multiple] | <code>Boolean</code> | <code>false</code> | Allow selection of multiple libraries |
|
|
163
|
+
| [options.hint] | <code>String</code> \| <code>Array.<String></code> | | Hints to identify the library to select in array order of preference. Generally corresponds to the previous stage - e.g. 'deduped', 'review1', 'review2', 'dedisputed' |
|
|
164
|
+
|
|
165
|
+
<a name="TeraFyServer+setProjectLibrary"></a>
|
|
166
|
+
|
|
167
|
+
### teraFyServer.setProjectLibrary(Collection, [options]) ⇒ <code>Promise</code>
|
|
168
|
+
Save back a projects citation library
|
|
169
|
+
|
|
170
|
+
**Kind**: instance method of [<code>TeraFyServer</code>](#TeraFyServer)
|
|
171
|
+
**Returns**: <code>Promise</code> - A promise which resolves when the save operation has completed
|
|
172
|
+
|
|
173
|
+
| Param | Type | Default | Description |
|
|
174
|
+
| --- | --- | --- | --- |
|
|
175
|
+
| Collection | <code>Array.<RefLibRef></code> | | of references for the selected library |
|
|
176
|
+
| [options] | <code>Object</code> | | Additional options to mutate behaviour |
|
|
177
|
+
| [options.autoRequire] | <code>Boolean</code> | <code>true</code> | Run `requireProject()` automatically before continuing |
|
|
178
|
+
| [options.hint] | <code>String</code> | | Hint to store against the library. Generally corresponds to the current operation being performed - e.g. 'deduped' |
|
|
179
|
+
|
|
180
|
+
<a name="TeraFyServer+init"></a>
|
|
181
|
+
|
|
182
|
+
### teraFyServer.init()
|
|
183
|
+
Initialize the browser listener
|
|
184
|
+
|
|
185
|
+
**Kind**: instance method of [<code>TeraFyServer</code>](#TeraFyServer)
|
|
186
|
+
<a name="User"></a>
|
|
187
|
+
|
|
188
|
+
## User
|
|
189
|
+
**Kind**: global class
|
|
190
|
+
**Properties**
|
|
191
|
+
|
|
192
|
+
| Name | Type | Description |
|
|
193
|
+
| --- | --- | --- |
|
|
194
|
+
| id | <code>String</code> | Unique identifier of the user |
|
|
195
|
+
| email | <code>String</code> | The email address of the current user |
|
|
196
|
+
| name | <code>String</code> | The provided full name of the user |
|
|
197
|
+
| isSubscribed | <code>Boolean</code> | Whether the active user has a TERA subscription |
|
|
198
|
+
|
|
199
|
+
<a name="new_User_new"></a>
|
|
200
|
+
|
|
201
|
+
### new User()
|
|
202
|
+
User / active session within TERA
|
|
203
|
+
|
|
204
|
+
<a name="Project"></a>
|
|
205
|
+
|
|
206
|
+
## Project
|
|
207
|
+
**Kind**: global class
|
|
208
|
+
**Properties**
|
|
209
|
+
|
|
210
|
+
| Name | Type | Description |
|
|
211
|
+
| --- | --- | --- |
|
|
212
|
+
| id | <code>String</code> | The Unique ID of the project |
|
|
213
|
+
| name | <code>String</code> | The name of the project |
|
|
214
|
+
| created | <code>String</code> | The creation date of the project as an ISO string |
|
|
215
|
+
| isOwner | <code>Boolean</code> | Whether the current session user is the owner of the project |
|
|
216
|
+
|
|
217
|
+
<a name="new_Project_new"></a>
|
|
218
|
+
|
|
219
|
+
### new Project()
|
|
220
|
+
Project entry within TERA
|
|
221
|
+
|
package/index.html
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<title>Tera-Fy documentation</title>
|
|
4
|
+
|
|
5
|
+
<!-- 3rd party libraries -->
|
|
6
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/3.3.6/vue.global.min.js" integrity="sha512-y5PnNJyq3UHlylzZhPzDDyrYC2pmfjBjlcaJL5fhzjj5EcUAYKeELoeCUT0Jc+r5IWzRgNGDE1XVxDAtkpdRlw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
|
7
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/css/bootstrap.min.css" integrity="sha512-b2QcS5SsA8tZodcDtGRELiGv5SaKSk1vDHDaQRda0htPYWZ6046lr3kJ5bAAQdpV2mmA/4v0wQF9MyU6/pDIAg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
|
8
|
+
|
|
9
|
+
<style>
|
|
10
|
+
.list-group-item-action {
|
|
11
|
+
user-select: none;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.list-group-item-action select.form-control {
|
|
17
|
+
display: inline-flex;
|
|
18
|
+
max-width: 150px;
|
|
19
|
+
}
|
|
20
|
+
</style>
|
|
21
|
+
|
|
22
|
+
<script type="module">
|
|
23
|
+
import TeraFy from './dist/terafy.js';
|
|
24
|
+
|
|
25
|
+
Vue.createApp({
|
|
26
|
+
data() { return {
|
|
27
|
+
/**
|
|
28
|
+
* Actual TeraFy instance to use in testing
|
|
29
|
+
* @type {TeraFy}
|
|
30
|
+
*/
|
|
31
|
+
terafy: new TeraFy({
|
|
32
|
+
devMode: true,
|
|
33
|
+
}),
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Last response from a method
|
|
37
|
+
* @type {String}
|
|
38
|
+
*/
|
|
39
|
+
response: '(Nothing)',
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Whether the last response was classed as an error
|
|
43
|
+
* @type {Boolean}
|
|
44
|
+
*/
|
|
45
|
+
isError: null,
|
|
46
|
+
}},
|
|
47
|
+
methods: {
|
|
48
|
+
/**
|
|
49
|
+
* Run a named TERA-fy method within a safe context and display the result
|
|
50
|
+
* @param {String} method The method to run
|
|
51
|
+
* @param {*} [args...] Additional method arguments
|
|
52
|
+
*/
|
|
53
|
+
run(method, ...args) {
|
|
54
|
+
Promise.resolve()
|
|
55
|
+
.then(()=> this.terafy[method](...args))
|
|
56
|
+
.then(res => {
|
|
57
|
+
this.response = res;
|
|
58
|
+
this.isError = false;
|
|
59
|
+
})
|
|
60
|
+
.catch(e => {
|
|
61
|
+
this.response = 'Error: ' + e.toString();
|
|
62
|
+
console.warn('TERA threw error', e);
|
|
63
|
+
this.isError = true;
|
|
64
|
+
})
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
mounted() {
|
|
68
|
+
return this.terafy.init();
|
|
69
|
+
},
|
|
70
|
+
}).mount('#app');
|
|
71
|
+
</script>
|
|
72
|
+
</head>
|
|
73
|
+
<body>
|
|
74
|
+
<div id="app">
|
|
75
|
+
<div class="container pt-4">
|
|
76
|
+
<div class="row">
|
|
77
|
+
<div class="col-sm-12 col-md-6">
|
|
78
|
+
|
|
79
|
+
<!-- Client specifics {{{ -->
|
|
80
|
+
<div class="card mb-2">
|
|
81
|
+
<div class="card-header">Client Specifics</div>
|
|
82
|
+
<div class="card-body">
|
|
83
|
+
<div class="list-group">
|
|
84
|
+
<a
|
|
85
|
+
@click="run('toggleFullscreen')"
|
|
86
|
+
class="list-group-item list-group-item-action"
|
|
87
|
+
>
|
|
88
|
+
terafy.toggleFullscreen()
|
|
89
|
+
</a>
|
|
90
|
+
|
|
91
|
+
<a
|
|
92
|
+
@click="run('toggleDevMode')"
|
|
93
|
+
class="list-group-item list-group-item-action"
|
|
94
|
+
>
|
|
95
|
+
terafy.toggleDevMode()
|
|
96
|
+
</a>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
<!-- }}} -->
|
|
101
|
+
|
|
102
|
+
<!-- Basics {{{ -->
|
|
103
|
+
<div class="card mb-2">
|
|
104
|
+
<div class="card-header">Basic</div>
|
|
105
|
+
<div class="card-body">
|
|
106
|
+
<div class="list-group">
|
|
107
|
+
<a
|
|
108
|
+
@click="run('handshake')"
|
|
109
|
+
class="list-group-item list-group-item-action"
|
|
110
|
+
>
|
|
111
|
+
terafy.handshake()
|
|
112
|
+
</a>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
<!-- }}} -->
|
|
117
|
+
|
|
118
|
+
<!-- Session {{{ -->
|
|
119
|
+
<div class="card mb-2">
|
|
120
|
+
<div class="card-header">Session / User</div>
|
|
121
|
+
<div class="card-body">
|
|
122
|
+
<div class="list-group">
|
|
123
|
+
<a
|
|
124
|
+
@click="run('getUser')"
|
|
125
|
+
class="list-group-item list-group-item-action"
|
|
126
|
+
>
|
|
127
|
+
terafy.getUser()
|
|
128
|
+
</a>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
<!-- }}} -->
|
|
133
|
+
|
|
134
|
+
<!-- Projects {{{ -->
|
|
135
|
+
<div class="card mb-2">
|
|
136
|
+
<div class="card-header">Projects</div>
|
|
137
|
+
<div class="card-body">
|
|
138
|
+
<div class="list-group">
|
|
139
|
+
<a
|
|
140
|
+
@click="run('bindProject')"
|
|
141
|
+
class="list-group-item list-group-item-action disabled"
|
|
142
|
+
>
|
|
143
|
+
terafy.bindProject()
|
|
144
|
+
</a>
|
|
145
|
+
<a
|
|
146
|
+
@click="run('getProject')"
|
|
147
|
+
class="list-group-item list-group-item-action"
|
|
148
|
+
>
|
|
149
|
+
terafy.getProject()
|
|
150
|
+
</a>
|
|
151
|
+
<a
|
|
152
|
+
@click="run('getProjects')"
|
|
153
|
+
class="list-group-item list-group-item-action"
|
|
154
|
+
>
|
|
155
|
+
terafy.getProjects()
|
|
156
|
+
</a>
|
|
157
|
+
<a
|
|
158
|
+
@click="run('requireProject')"
|
|
159
|
+
class="list-group-item list-group-item-action"
|
|
160
|
+
>
|
|
161
|
+
terafy.requireProject()
|
|
162
|
+
</a>
|
|
163
|
+
<a
|
|
164
|
+
@click="run('selectProject')"
|
|
165
|
+
class="list-group-item list-group-item-action"
|
|
166
|
+
>
|
|
167
|
+
terafy.selectProject()
|
|
168
|
+
</a>
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
<!-- }}} -->
|
|
173
|
+
|
|
174
|
+
<!-- Project State {{{ -->
|
|
175
|
+
<div class="card mb-2">
|
|
176
|
+
<div class="card-header">Project State</div>
|
|
177
|
+
<div class="card-body">
|
|
178
|
+
<div class="list-group">
|
|
179
|
+
<a
|
|
180
|
+
@click="run('getProjectStateSnapshot')"
|
|
181
|
+
class="list-group-item list-group-item-action"
|
|
182
|
+
>
|
|
183
|
+
terafy.getProjectStateSnapshot()
|
|
184
|
+
</a>
|
|
185
|
+
<a
|
|
186
|
+
@click="run('bindProjectState')"
|
|
187
|
+
class="list-group-item list-group-item-action disabled"
|
|
188
|
+
>
|
|
189
|
+
terafy.bindProjectState()
|
|
190
|
+
</a>
|
|
191
|
+
<a
|
|
192
|
+
@click="run('applyProjectStatePatch')"
|
|
193
|
+
class="list-group-item list-group-item-action disabled"
|
|
194
|
+
>
|
|
195
|
+
terafy.applyProjectStatePatch()
|
|
196
|
+
</a>
|
|
197
|
+
</div>
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
<!-- }}} -->
|
|
201
|
+
|
|
202
|
+
<!-- Project Libraries {{{ -->
|
|
203
|
+
<div class="card mb-2">
|
|
204
|
+
<div class="card-header">Project Libraries</div>
|
|
205
|
+
<div class="card-body">
|
|
206
|
+
<div class="list-group">
|
|
207
|
+
<a
|
|
208
|
+
@click="run('getProjectLibrary')"
|
|
209
|
+
class="list-group-item list-group-item-action"
|
|
210
|
+
>
|
|
211
|
+
terafy.getProjectLibrary({multiple: false})
|
|
212
|
+
</a>
|
|
213
|
+
<a
|
|
214
|
+
@click="run('getProjectLibrary', {multiple: true})"
|
|
215
|
+
class="list-group-item list-group-item-action"
|
|
216
|
+
>
|
|
217
|
+
terafy.getProjectLibrary({multiple: true})
|
|
218
|
+
</a>
|
|
219
|
+
<a
|
|
220
|
+
@click="run('setProjectLibrary')"
|
|
221
|
+
class="list-group-item list-group-item-action disabled"
|
|
222
|
+
>
|
|
223
|
+
terafy.setProjectLibrary()
|
|
224
|
+
</a>
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
<!-- }}} -->
|
|
229
|
+
|
|
230
|
+
</div>
|
|
231
|
+
<!-- Result area {{{ -->
|
|
232
|
+
<div class="col-sm-12 col-md-6">
|
|
233
|
+
<div class="card">
|
|
234
|
+
<div class="card-header d-flex justify-content-between align-items-center">
|
|
235
|
+
<div>Response</div>
|
|
236
|
+
<div>
|
|
237
|
+
<div v-if="isError" class="badge bg-danger">Error!</div>
|
|
238
|
+
<div v-else-if="isError !== null" class="badge bg-success">Success</div>
|
|
239
|
+
</div>
|
|
240
|
+
</div>
|
|
241
|
+
<div class="card-body" :class="isError && 'bg-danger'">
|
|
242
|
+
<pre
|
|
243
|
+
class="bg-light border p-2 rounded m-0"
|
|
244
|
+
:class="
|
|
245
|
+
isError === true ? 'bg-danger'
|
|
246
|
+
: isError === false ? 'bg-success'
|
|
247
|
+
: 'bg-light'
|
|
248
|
+
"
|
|
249
|
+
>{{response}}</pre>
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
<!-- }}} -->
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
</div>
|
|
257
|
+
</body>
|
|
258
|
+
</html>
|