@naanlang/naan 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +46 -0
- package/dist/env_web.js +431 -0
- package/dist/naan.min.js +73 -0
- package/frameworks/browser/browser.nlg +30 -0
- package/frameworks/browser/pouchdb/pouchdb.min.js +7 -0
- package/frameworks/browser/spark-md5/spark-md5.min.js +1 -0
- package/frameworks/browser/sworker.js +192 -0
- package/frameworks/browser/terminals.nlg +787 -0
- package/frameworks/browser/workers.nlg +386 -0
- package/frameworks/client/apiclient.nlg +183 -0
- package/frameworks/client/client.nlg +29 -0
- package/frameworks/client/psm_client.nlg +572 -0
- package/frameworks/common/common.nlg +464 -0
- package/frameworks/common/preferences.nlg +131 -0
- package/frameworks/common/repltools.nlg +100 -0
- package/frameworks/common/watching.nlg +97 -0
- package/frameworks/node/apiserver.nlg +399 -0
- package/frameworks/node/filesystem.nlg +1012 -0
- package/frameworks/node/gitter.nlg +234 -0
- package/frameworks/node/node.nlg +81 -0
- package/frameworks/node/psm_server.nlg +465 -0
- package/frameworks/node/worker.nlg +560 -0
- package/frameworks/project/build.nlg +1229 -0
- package/frameworks/project/jszip.js +30 -0
- package/frameworks/project/jszip.nlg +87 -0
- package/frameworks/project/proj_cliser.nlg +139 -0
- package/frameworks/project/proj_console.nlg +137 -0
- package/frameworks/project/proj_folder.nlg +143 -0
- package/frameworks/project/proj_lambda.nlg +137 -0
- package/frameworks/project/proj_static.nlg +138 -0
- package/frameworks/project/project.nlg +29 -0
- package/frameworks/project/projects.nlg +587 -0
- package/frameworks/project/uglifyjs.js +1 -0
- package/frameworks/project/uglifyjs.nlg +79 -0
- package/frameworks/running/debugcom.nlg +163 -0
- package/frameworks/running/debugnub.nlg +565 -0
- package/frameworks/running/debugutil.nlg +510 -0
- package/frameworks/running/executors.nlg +767 -0
- package/frameworks/running/running.nlg +151 -0
- package/frameworks/running/sourcecode.nlg +346 -0
- package/frameworks/running/taskexec.nlg +196 -0
- package/frameworks/storage/dbt_pouch.nlg +773 -0
- package/frameworks/storage/file_manager.nlg +772 -0
- package/frameworks/storage/psm.nlg +326 -0
- package/frameworks/storage/psm_dbtables.nlg +814 -0
- package/frameworks/storage/resources.nlg +445 -0
- package/frameworks/storage/storage.nlg +52 -0
- package/lib/browser/env_web.js +431 -0
- package/lib/browser/env_webworker.js +146 -0
- package/lib/browser/require.js +1653 -0
- package/lib/core/naanlib.js +73 -0
- package/lib/env_node.js +282 -0
- package/lib/env_nodeworker.js +165 -0
- package/lib/node_repl.js +25 -0
- package/lib/node_repl_init.nlg +52 -0
- package/package.json +13 -0
- package/plugins/gitClient/clientops.nlg +317 -0
- package/plugins/gitClient/gitClient.nlg +63 -0
- package/plugins/gitClient/gitutils.nlg +1331 -0
- package/plugins/gitClient/minimatch.js +945 -0
- package/plugins/gitClient/minimatch_license.txt +15 -0
- package/plugins/gitClient/minimatch_readme.md +208 -0
- package/plugins/nodeLib/nodeLib.nlg +26 -0
- package/plugins/nodeLib/node_cp.nlg +65 -0
- package/plugins/nodeLib/node_fs.nlg +137 -0
- package/plugins/nodeLib/node_https.nlg +172 -0
- package/plugins/nodeLib/node_util.nlg +180 -0
- package/plugins/serviceAws/aws/aws-sdk.min.js +88 -0
- package/plugins/serviceAws/aws/lambda_rest_index.js +122 -0
- package/plugins/serviceAws/aws/lambda_rest_init.nlg +58 -0
- package/plugins/serviceAws/aws/lambda_ws_index.js +498 -0
- package/plugins/serviceAws/aws/lambda_ws_init.nlg +49 -0
- package/plugins/serviceAws/aws_cloudwatchlogs.nlg +122 -0
- package/plugins/serviceAws/aws_cognito.nlg +76 -0
- package/plugins/serviceAws/aws_dynamo.nlg +509 -0
- package/plugins/serviceAws/aws_lambda.nlg +95 -0
- package/plugins/serviceAws/aws_s3.nlg +134 -0
- package/plugins/serviceAws/aws_utils.nlg +86 -0
- package/plugins/serviceAws/dbt_aws.nlg +769 -0
- package/plugins/serviceAws/lambda_naan_control.nlg +175 -0
- package/plugins/serviceAws/psm_aws.nlg +258 -0
- package/plugins/serviceAws/serviceAws.nlg +38 -0
- package/plugins/serviceGitHub/gitops.nlg +522 -0
- package/plugins/serviceGitHub/psm_github.nlg +205 -0
- package/plugins/serviceGitHub/serviceGitHub.nlg +65 -0
- package/plugins/serviceGitLab/gitops.nlg +528 -0
- package/plugins/serviceGitLab/psm_gitlab.nlg +205 -0
- package/plugins/serviceGitLab/serviceGitLab.nlg +65 -0
- package/test/harness.nlg +312 -0
- package/test/node_test.js +33 -0
- package/test/test_01_core.nlg +768 -0
- package/test/test_02_context.nlg +269 -0
- package/test/test_03_jsinterop.nlg +137 -0
- package/test/test_04_numerics.nlg +450 -0
- package/test/test_05_strings.nlg +63 -0
- package/test/test_06_lingoparse.nlg +500 -0
- package/test/test_07_lingo.nlg +623 -0
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* psm_server.nlg
|
|
3
|
+
* Naanlib/frameworks/node
|
|
4
|
+
*
|
|
5
|
+
* PSM Connector for the Node data stores.
|
|
6
|
+
*
|
|
7
|
+
* column positioning: // // !
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2019-2021 by Richard C. Zulch
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* psmsFsView
|
|
16
|
+
*
|
|
17
|
+
* Make a filesystem view for the specified root path. These functions are accessed locally
|
|
18
|
+
* within NodeJS. If a callback is specified then the call is async, but otherwise the call is
|
|
19
|
+
* blocking. There is also a method to dispatch operations requested by the Web API.
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
closure psmsFsView(rootpath, local view, gitter) {
|
|
24
|
+
view = Filesystem(rootpath)
|
|
25
|
+
if view.0
|
|
26
|
+
return (view) // failed to create filesystem access at rootpath
|
|
27
|
+
view = view.1
|
|
28
|
+
|
|
29
|
+
// inherited
|
|
30
|
+
// -- view.winDrives(callback)
|
|
31
|
+
// -- view.testHidden(path, callback)
|
|
32
|
+
// -- view.readLines(path, options, callback)
|
|
33
|
+
// -- view.readFile(path, options, callback)
|
|
34
|
+
// -- view.writeFile(path, data, options, callback)
|
|
35
|
+
// -- view.info(path, callback)
|
|
36
|
+
// -- view.setTimes(path, atime, mtime, callback)
|
|
37
|
+
// -- view.dirList(path, options, callback)
|
|
38
|
+
// -- view.mkdir(path, callback)
|
|
39
|
+
// -- view.tree(path, depthlimit, callback)
|
|
40
|
+
// -- view.dirSearch(path, options, callback)
|
|
41
|
+
// -- view.copy(srcpath, destpath, options, callback)
|
|
42
|
+
// -- view.reveal(path(s), callback)
|
|
43
|
+
// -- view.minimizeApi(content, callback)
|
|
44
|
+
// -- view.unzipApi(path, callback)
|
|
45
|
+
// -- view.touch(path, callback)
|
|
46
|
+
// -- view.shellOpenApi(path, options, callback)
|
|
47
|
+
// -- view.grepLines(path, options, callback)
|
|
48
|
+
// -- view.gitStatus(path, callback)
|
|
49
|
+
// -- view.gitLog(path, callback)
|
|
50
|
+
// -- view.gitShowFile(path, callback)
|
|
51
|
+
|
|
52
|
+
// api
|
|
53
|
+
//
|
|
54
|
+
// Entry point for API requests.
|
|
55
|
+
|
|
56
|
+
view.api = closure api(req, res, local path, proc, result) {
|
|
57
|
+
if not string(req.query.path) {
|
|
58
|
+
res.status(400).send("invalid path")
|
|
59
|
+
return }
|
|
60
|
+
path = req.query.path
|
|
61
|
+
|
|
62
|
+
// gitterLoaded
|
|
63
|
+
// Load gitter if needed for git access, returning false on failure.
|
|
64
|
+
function gitterLoaded(local result) {
|
|
65
|
+
if !gitter {
|
|
66
|
+
result = require("./gitter.nlg").Gitter(view)
|
|
67
|
+
if result.0 {
|
|
68
|
+
res.send(new(array, result))
|
|
69
|
+
return (false) }
|
|
70
|
+
gitter = result.1 }
|
|
71
|
+
true
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// op: pathOp
|
|
75
|
+
function pathOpApi(local selector, local result) {
|
|
76
|
+
try {
|
|
77
|
+
result = list(false, xapply(JSpath, req.query.selector, totuple(js.g.JSON.parse(req.query.arglist))))
|
|
78
|
+
} catch {
|
|
79
|
+
if true
|
|
80
|
+
result = list(Error(exception))
|
|
81
|
+
}
|
|
82
|
+
res.send(new(array, result))
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// op: readLines
|
|
86
|
+
function readLinesApi() {
|
|
87
|
+
res.send(new(array, view.readLines(path, req.query)))
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// op: readFile
|
|
91
|
+
function readFileApi(local options) {
|
|
92
|
+
options = {
|
|
93
|
+
dotfiles: "allow" }
|
|
94
|
+
if req.query.encoding == "binary"
|
|
95
|
+
options.headers = {
|
|
96
|
+
"Content-Type": "application/octet-stream"
|
|
97
|
+
}
|
|
98
|
+
else
|
|
99
|
+
options.headers = { // ### is this always the right default?
|
|
100
|
+
"Content-Type": "text/html; charset=UTF-8"
|
|
101
|
+
}
|
|
102
|
+
res.sendFile(path, options, function (err, local status) {
|
|
103
|
+
if err {
|
|
104
|
+
if err.code == "ENOENT"
|
|
105
|
+
status = 404
|
|
106
|
+
else
|
|
107
|
+
status = 500
|
|
108
|
+
res.status(status).end()
|
|
109
|
+
} })
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// op: writeFile
|
|
113
|
+
function writeFileApi(local options) {
|
|
114
|
+
options = { }
|
|
115
|
+
if req.query.md5
|
|
116
|
+
options.md5 = req.query.md5
|
|
117
|
+
if req.query.encoding
|
|
118
|
+
options.encoding = req.query.encoding
|
|
119
|
+
res.send(new(array, view.writeFile(path, req.body, options)))
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// op: delete
|
|
123
|
+
function deleteApi(local options) {
|
|
124
|
+
options = { }
|
|
125
|
+
if req.query.recursive
|
|
126
|
+
options.recursive = true
|
|
127
|
+
if req.query.directory
|
|
128
|
+
options.directory = true
|
|
129
|
+
res.send(new(array, view.delete(path, options)))
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// op: info
|
|
133
|
+
function infoApi() {
|
|
134
|
+
res.send(new(array, view.info(path)))
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// op: setTimes
|
|
138
|
+
function setTimesApi() {
|
|
139
|
+
res.send(new(array, view.setTimes(path, req.query.atime, req.query.mtime)))
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// op: dirList
|
|
143
|
+
function dirListApi(local options) {
|
|
144
|
+
if req.query.head
|
|
145
|
+
options = { head: true }
|
|
146
|
+
res.send(new(array, view.dirList(path, options)))
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// op: mkdir
|
|
150
|
+
function mkdirApi() {
|
|
151
|
+
res.send(new(array, view.mkdir(path)))
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// op: tree
|
|
155
|
+
function treeApi() {
|
|
156
|
+
res.send(new(array, view.tree(path, req.query.depthlimit)))
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// op: dirSearch
|
|
160
|
+
function dirSearchApi() {
|
|
161
|
+
res.send(new(array, view.dirSearch(path, req.query)))
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// op: copy
|
|
165
|
+
function copyApi() {
|
|
166
|
+
res.send(new(array, view.copy(path, req.query.destination, req.query)))
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// op: reveal
|
|
170
|
+
function revealApi() {
|
|
171
|
+
res.send(new(array, view.reveal(path)))
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// op: minimize
|
|
175
|
+
function minimizeApi() {
|
|
176
|
+
res.send(new(array, view.minimize(req.body)))
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// op: unzip
|
|
180
|
+
function unzipApi() {
|
|
181
|
+
res.send(new(array, view.unzip(path, req.query.destination)))
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// op: touch
|
|
185
|
+
function touchApi() {
|
|
186
|
+
res.send(new(array, view.touch(path)))
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// op: shellOpen
|
|
190
|
+
function shellOpenApi() {
|
|
191
|
+
res.send(new(array, view.shellOpen(path, req.query.args)))
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// op: grepLines
|
|
195
|
+
function grepLinesApi() {
|
|
196
|
+
res.send(new(array, view.grepLines(path, req.query)))
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// op: gitStatus
|
|
200
|
+
function gitStatusApi() {
|
|
201
|
+
if gitterLoaded()
|
|
202
|
+
res.send(new(array, gitter.status(path, req.query)))
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// op: gitLog
|
|
206
|
+
function gitLogApi() {
|
|
207
|
+
if gitterLoaded()
|
|
208
|
+
res.send(new(array, gitter.log(path, req.query)))
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// op: gitShowFile
|
|
212
|
+
function gitShowFileApi() {
|
|
213
|
+
if gitterLoaded()
|
|
214
|
+
res.send(new(array, gitter.showfile(path, req.query)))
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
proc = {
|
|
218
|
+
pathOp: pathOpApi
|
|
219
|
+
readFile: readFileApi
|
|
220
|
+
readLines: readLinesApi
|
|
221
|
+
writeFile: writeFileApi
|
|
222
|
+
delete: deleteApi
|
|
223
|
+
info: infoApi
|
|
224
|
+
setTimes: setTimesApi
|
|
225
|
+
dirList: dirListApi
|
|
226
|
+
mkdir: mkdirApi
|
|
227
|
+
tree: treeApi
|
|
228
|
+
dirSearch: dirSearchApi
|
|
229
|
+
copy: copyApi
|
|
230
|
+
reveal: revealApi
|
|
231
|
+
minimize: minimizeApi
|
|
232
|
+
unzip: unzipApi
|
|
233
|
+
touch: touchApi
|
|
234
|
+
shellOpen: shellOpenApi
|
|
235
|
+
grepLines: grepLinesApi
|
|
236
|
+
gitStatus: gitStatusApi
|
|
237
|
+
gitLog: gitLogApi
|
|
238
|
+
gitShowFile: gitShowFileApi
|
|
239
|
+
}[req.query.op]
|
|
240
|
+
if proc
|
|
241
|
+
proc()
|
|
242
|
+
else
|
|
243
|
+
res.status(400).send("invalid psm op: ".concat(req.query.op))
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// finis
|
|
247
|
+
list(false, view)
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
/*
|
|
252
|
+
* psmsFsConnector
|
|
253
|
+
*
|
|
254
|
+
* Make a PSM file system connector with a single filesystem store. This supports resources
|
|
255
|
+
* but doesn't use them yet. Maybe someday they'll be helpful.
|
|
256
|
+
*
|
|
257
|
+
*/
|
|
258
|
+
|
|
259
|
+
closure psmsFsConnector(psm, api, local connClassID, connector, watch) {
|
|
260
|
+
connClassID = "NodeFS"
|
|
261
|
+
connector = new(object, this)
|
|
262
|
+
connector.psm = psm
|
|
263
|
+
connector.vault = psm.vault(connClassID)
|
|
264
|
+
connector.label = "Naan IDE Server"
|
|
265
|
+
watch = psm.watchable(connector)
|
|
266
|
+
|
|
267
|
+
// hashResourceID
|
|
268
|
+
//
|
|
269
|
+
// Make a stable hash based on the resource credentials that we can persist or share between
|
|
270
|
+
// different domains accessing the same resource.
|
|
271
|
+
connector.hashResourceID = function hashResourceID(resource, local ident) {
|
|
272
|
+
ident = resource.urlName
|
|
273
|
+
if resource.label
|
|
274
|
+
ident = ident.concat(resource.label)
|
|
275
|
+
HashSHA256(ident)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// findResource
|
|
279
|
+
//
|
|
280
|
+
// Find a resource with the specified contents, returning the resID or false. The loose criteria
|
|
281
|
+
// is: if added, would the specified contents be redundant to an existing resource?
|
|
282
|
+
connector.findResource = function findResource(resource, local resID, creds) {
|
|
283
|
+
for resID in listResources().1 {
|
|
284
|
+
creds = access(resID).1
|
|
285
|
+
if resource.urlName == creds.urlName
|
|
286
|
+
&& (!resource.label || resource.label == creds.label)
|
|
287
|
+
return (resID)
|
|
288
|
+
}
|
|
289
|
+
false
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// addResource
|
|
293
|
+
//
|
|
294
|
+
// Add credentials for a named resource. This is just a stub at the moment
|
|
295
|
+
|
|
296
|
+
connector.addResource = function addResource(resource, local creds, errors, error, resID, data) {
|
|
297
|
+
function badField(str) { !string(str) || str.trim().length == 0 }
|
|
298
|
+
creds = { urlName: resource.urlName }
|
|
299
|
+
errors = { }
|
|
300
|
+
if resource.label
|
|
301
|
+
creds.label = resource.label
|
|
302
|
+
else
|
|
303
|
+
creds.label = resource.urlName
|
|
304
|
+
if badField(creds.label)
|
|
305
|
+
errors.label = "invalid label"
|
|
306
|
+
if badField(resource.urlName)
|
|
307
|
+
errors.urlName = "required field"
|
|
308
|
+
if length(errors) > 0
|
|
309
|
+
error = errors
|
|
310
|
+
else {
|
|
311
|
+
if resource.hidden
|
|
312
|
+
creds.hidden = resource.hidden
|
|
313
|
+
if resource.locked
|
|
314
|
+
creds.locked = resource.locked
|
|
315
|
+
resID = hashResourceID(resource)
|
|
316
|
+
`(error, data) = connector.vault.addResource(resID, creds)
|
|
317
|
+
if data {
|
|
318
|
+
watch.notify(connClassID, { added: [resID] })
|
|
319
|
+
data = resID } }
|
|
320
|
+
list(error, data)
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// getResource
|
|
324
|
+
//
|
|
325
|
+
// Get credentials for a named resource, matching the dictionary semantics of addResource. The
|
|
326
|
+
// result is a standard result tuple.
|
|
327
|
+
connector.getResource = function getResource(resID, local error, creds, resource) {
|
|
328
|
+
`(error, creds) = connector.vault.accessResource(resID)
|
|
329
|
+
if error
|
|
330
|
+
return (list(error))
|
|
331
|
+
resource = {
|
|
332
|
+
classID: connClassID
|
|
333
|
+
label: creds.label
|
|
334
|
+
}
|
|
335
|
+
if string(creds.urlName)
|
|
336
|
+
resource.urlName = creds.urlName
|
|
337
|
+
list(false, resource)
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// deleteResource
|
|
341
|
+
//
|
|
342
|
+
// Delete credentials for a resource
|
|
343
|
+
connector.deleteResource = function deleteResource(resID) {
|
|
344
|
+
connector.vault.deleteResource(resID)
|
|
345
|
+
watch.notify(connClassID, { deleted: [resID] })
|
|
346
|
+
list(false, { ok: true})
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// listResources
|
|
350
|
+
//
|
|
351
|
+
// List saved resources in our database
|
|
352
|
+
connector.listResources = function listResources(local error, original) {
|
|
353
|
+
`(error, output) = connector.vault.listResources()
|
|
354
|
+
if error
|
|
355
|
+
return (list(error)) // can't access our saved resources
|
|
356
|
+
original = ["Host"]
|
|
357
|
+
if original
|
|
358
|
+
output = original.concat(output)
|
|
359
|
+
list(false, output)
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// info
|
|
363
|
+
//
|
|
364
|
+
// Return info for a resource.
|
|
365
|
+
connector.info = function info(resID, local info, error, creds) {
|
|
366
|
+
info = {
|
|
367
|
+
classID: connClassID
|
|
368
|
+
type: "remote filesystem"
|
|
369
|
+
services: ["NideFS", "NideHostAPI"]
|
|
370
|
+
}
|
|
371
|
+
if resID == "Host" {
|
|
372
|
+
info.name = "Host"
|
|
373
|
+
info.type = "host filesystem"
|
|
374
|
+
info.locked = true
|
|
375
|
+
info.where = "localhost:".concat(api.port)
|
|
376
|
+
info.access = "HostFS"
|
|
377
|
+
} else {
|
|
378
|
+
`(error, creds) = connector.vault.accessResource(resID)
|
|
379
|
+
if creds {
|
|
380
|
+
if creds.label
|
|
381
|
+
info.name = creds.label
|
|
382
|
+
if creds.locked
|
|
383
|
+
info.locked = true
|
|
384
|
+
if creds.hidden
|
|
385
|
+
info.hidden = true
|
|
386
|
+
info.where = data.urlName
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
list(false, info)
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// access
|
|
393
|
+
//
|
|
394
|
+
// Return credentials for connecting to a service.
|
|
395
|
+
//
|
|
396
|
+
connector.access = function access(resID) {
|
|
397
|
+
if resID == "Host"
|
|
398
|
+
list(false, "HostFS")
|
|
399
|
+
else
|
|
400
|
+
connector.vault.accessResource(resID)
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// connect
|
|
404
|
+
//
|
|
405
|
+
// Connect to the specified service. The first argument is the rootpath, which is required.
|
|
406
|
+
//
|
|
407
|
+
connector.connect = function connect(resID, service, args, local error, creds, api) {
|
|
408
|
+
`(error, creds) = connector.access(resID)
|
|
409
|
+
if !error {
|
|
410
|
+
if creds == "HostFS"
|
|
411
|
+
return (psmsFsView(args.0)) // use HostFS API
|
|
412
|
+
}
|
|
413
|
+
if error
|
|
414
|
+
list(error)
|
|
415
|
+
else if service == "NideFS" {
|
|
416
|
+
return (psmsFsView(args.0)) // use HostFS API
|
|
417
|
+
} else
|
|
418
|
+
list(Error("unsupported service", service))
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// finis
|
|
422
|
+
|
|
423
|
+
psm.register(connClassID, connector)
|
|
424
|
+
connector
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
/*
|
|
429
|
+
* MakeServerPSM
|
|
430
|
+
*
|
|
431
|
+
* Return a new server PSM with our known connectors.
|
|
432
|
+
*
|
|
433
|
+
*/
|
|
434
|
+
|
|
435
|
+
function MakeServerPSM(api, local importPSM) {
|
|
436
|
+
importPSM = require("../storage/psm.nlg")
|
|
437
|
+
App.psm = importPSM.MakePSM(JSpath.resolve(js.d, "NideDB")).1
|
|
438
|
+
if App.psm {
|
|
439
|
+
psmsFsConnector(App.psm, api)
|
|
440
|
+
require("frameworks/storage/dbt_pouch.nlg").DbConnector(App.psm) // Pouch databases as filesystems
|
|
441
|
+
}
|
|
442
|
+
App.psm
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
/*
|
|
447
|
+
* psmsInit
|
|
448
|
+
*
|
|
449
|
+
* Initialize the module.
|
|
450
|
+
*
|
|
451
|
+
*/
|
|
452
|
+
|
|
453
|
+
function psmsInit(local manifest) {
|
|
454
|
+
|
|
455
|
+
manifest = `(psmsFsView, psmsFsConnector, MakeServerPSM, psmsInit)
|
|
456
|
+
|
|
457
|
+
Naan.module.build(module.id, "psm_server", function(modobj, compobj) {
|
|
458
|
+
require("./node.nlg")
|
|
459
|
+
require("./filesystem.nlg")
|
|
460
|
+
require("./gitter.nlg")
|
|
461
|
+
compobj.manifest = manifest
|
|
462
|
+
modobj.exports.MakeServerPSM = MakeServerPSM
|
|
463
|
+
})
|
|
464
|
+
|
|
465
|
+
} ();
|