@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,445 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* resources.nlg
|
|
3
|
+
* NaanIDE
|
|
4
|
+
*
|
|
5
|
+
* These objects track resources with dynamically loaded components and change notifications.
|
|
6
|
+
* A resource is an object identified by a UUID that typically refers to an external resource we
|
|
7
|
+
* wish to access from within Nide. Examples are storage locations, thread hosts, and projects.
|
|
8
|
+
* A resource is represented here by a dictionary containing the information necessary to access it.
|
|
9
|
+
* Providers register using a classID string when they wish to handle a resource of that class.
|
|
10
|
+
* Watchers register and unregister for change notifications to a resource list.
|
|
11
|
+
*
|
|
12
|
+
* column positioning: // // !
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) 2019-2021 by Richard C. Zulch
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
* rsrcVault
|
|
21
|
+
*
|
|
22
|
+
* Make a resource vault object, which is used for storing credentials and other persistent
|
|
23
|
+
* information on behalf of resources. The database is the PouchDB that we use for storing access
|
|
24
|
+
* credentials. The tablename distinguishes different resource classes and resource types within
|
|
25
|
+
* the database. Resources are identified by a UUID string. This returns a standard (error, vault)
|
|
26
|
+
* tuple.
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
closure rsrcVault(db, tablename, local vault) {
|
|
31
|
+
vault = new(object, this)
|
|
32
|
+
|
|
33
|
+
// addResource
|
|
34
|
+
//
|
|
35
|
+
// Add credentials for accessing a resource, returning the added credential record.
|
|
36
|
+
|
|
37
|
+
vault.addResource = function addResource(resID, data) {
|
|
38
|
+
vault.table.add(resID, data)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// deleteResource
|
|
42
|
+
//
|
|
43
|
+
// Delete resource credentials.
|
|
44
|
+
|
|
45
|
+
vault.deleteResource = function deleteResource(resID, local error, data) {
|
|
46
|
+
`(error, data) = vault.table.get(resID)
|
|
47
|
+
if !error
|
|
48
|
+
`(error, data) = vault.table.delete(data)
|
|
49
|
+
else if error.status == 404
|
|
50
|
+
error = false // already missing
|
|
51
|
+
if error
|
|
52
|
+
list(error)
|
|
53
|
+
else
|
|
54
|
+
list(false, { ok: true }) }
|
|
55
|
+
|
|
56
|
+
// accessResource
|
|
57
|
+
//
|
|
58
|
+
// Return credentials for access to the resource.
|
|
59
|
+
|
|
60
|
+
vault.accessResource = function accessResource(resID) {
|
|
61
|
+
`(error, data) = vault.table.get(resID)
|
|
62
|
+
if error
|
|
63
|
+
list(error)
|
|
64
|
+
else
|
|
65
|
+
list(false, new(data.content))
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// listResources
|
|
69
|
+
//
|
|
70
|
+
// List saved resources in our database as an array of resIDs.
|
|
71
|
+
|
|
72
|
+
vault.listResources = function listResources(local error, data, output, record) {
|
|
73
|
+
`(error, data) = vault.table.records()
|
|
74
|
+
if error
|
|
75
|
+
return (list(error)) // can't access our record
|
|
76
|
+
output = []
|
|
77
|
+
for record in data.rows
|
|
78
|
+
output.push(record.key)
|
|
79
|
+
list(false, output)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// dbopen
|
|
83
|
+
//
|
|
84
|
+
// Open our database for accessing credentials, and then return the result tuple.
|
|
85
|
+
|
|
86
|
+
let dbopen(local error, data) {
|
|
87
|
+
`(error, data) = db.table(tablename)
|
|
88
|
+
if !error
|
|
89
|
+
vault.table = data
|
|
90
|
+
list(error, vault)
|
|
91
|
+
}()
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
/*
|
|
96
|
+
* ResourceManager
|
|
97
|
+
*
|
|
98
|
+
* Make a resource manager object. A resource manager tracks the dynamic list of resource types
|
|
99
|
+
* available, and also offers providers a storage vault for credentials and other persistent and
|
|
100
|
+
* possibly sensitive information. This does not track the resources themselves, which is done by
|
|
101
|
+
* a resource tracker.
|
|
102
|
+
* A connector is a registered object in a component that is responsible for connecting with
|
|
103
|
+
* its resources. Each connector has a stable classID string. A label is a user-visible string,
|
|
104
|
+
* which is the name of the connector here.
|
|
105
|
+
* The database name is the PouchDB that we use for the vault. The prefix distinguishes this
|
|
106
|
+
* class of resource types from other classes of resource types, e.g. storage vs. projects. This
|
|
107
|
+
* returns a standard (error, vault) tuple.
|
|
108
|
+
*
|
|
109
|
+
* A connector must implement at least the following members:
|
|
110
|
+
* conn.label - return the className of the connector
|
|
111
|
+
* conn.uifields() - entry fields for add this kind of resource in UI
|
|
112
|
+
* conn.findResource(resource) - find a resource by content, returning resID or false
|
|
113
|
+
* conn.addResource(resource) - add the resource dict and return `(error, resID)
|
|
114
|
+
* conn.info(resID) - return `(error, infoDictionary) tuple
|
|
115
|
+
* conn.deleteResource(resID) - delete the specified resource, returning a tuple
|
|
116
|
+
* conn.connect(resID, serviceID, args) - connect to resource and return object
|
|
117
|
+
*
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
closure ResourceManager(dbname, prefix, local reman, watch, result) {
|
|
121
|
+
reman = new(object, this)
|
|
122
|
+
watch = commonWatching.Watchable()
|
|
123
|
+
reman.watch = watch.watch
|
|
124
|
+
reman.unWatch = watch.unWatch
|
|
125
|
+
reman.dbname = dbname
|
|
126
|
+
reman.conns = {}
|
|
127
|
+
result = PouchDB(dbname)
|
|
128
|
+
if result.0
|
|
129
|
+
return (result) // can't access our vault database
|
|
130
|
+
reman.db = result.1
|
|
131
|
+
|
|
132
|
+
// vault
|
|
133
|
+
//
|
|
134
|
+
// Return a vault object for a class, returning the vault or false. If this is successful then
|
|
135
|
+
// you should call register() below after initializing the connector.
|
|
136
|
+
reman.vault = function vault(classID, local name, error, data) {
|
|
137
|
+
name = prefix.concat(classID)
|
|
138
|
+
if reman.conns[classID] {
|
|
139
|
+
debuglog("Resource Manager: already registered", name)
|
|
140
|
+
return (false)
|
|
141
|
+
}
|
|
142
|
+
`(error, data) = rsrcVault(reman.db, name)
|
|
143
|
+
if error
|
|
144
|
+
ErrorDebugLog("Resource Manager: cannot register", name, error)
|
|
145
|
+
data
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// register
|
|
149
|
+
//
|
|
150
|
+
// Register a connector, which may recursively call it back for inquiries on its resources. You
|
|
151
|
+
// must call vault() above first, then initialize and call this if successful.
|
|
152
|
+
reman.register = function register(classID, obj) {
|
|
153
|
+
reman.conns[classID] = obj
|
|
154
|
+
watch.notify(prefix, { added: [classID] })
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// connectors
|
|
158
|
+
//
|
|
159
|
+
// Return an array of the registered connector classIDs.
|
|
160
|
+
reman.connectors = function connectors() {
|
|
161
|
+
reman.conns.*.toarray
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// labels
|
|
165
|
+
//
|
|
166
|
+
// Return an array of labels for the registered connectors.
|
|
167
|
+
reman.labels = function labels(local classID, labels) {
|
|
168
|
+
labels = []
|
|
169
|
+
for remanID in reman.conns.*
|
|
170
|
+
labels.push(reman.conns[classID].label)
|
|
171
|
+
labels
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// watchable
|
|
175
|
+
//
|
|
176
|
+
// Return a new Watchable object.
|
|
177
|
+
reman.watchable = function watchable(connector, local watch) {
|
|
178
|
+
watch = commonWatching.Watchable()
|
|
179
|
+
if connector {
|
|
180
|
+
connector.watch = watch.watch
|
|
181
|
+
connector.unWatch = watch.unWatch
|
|
182
|
+
}
|
|
183
|
+
watch
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// tracker
|
|
187
|
+
//
|
|
188
|
+
// Return a new ResourceTracker tracking object.
|
|
189
|
+
reman.tracker = function tracker() {
|
|
190
|
+
ResourceTracker(reman)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// close
|
|
194
|
+
//
|
|
195
|
+
// Close the resource manager and its database instance.
|
|
196
|
+
reman.close = function close() {
|
|
197
|
+
if reman.db {
|
|
198
|
+
reman.db.close()
|
|
199
|
+
reman.db = false }
|
|
200
|
+
list(false, { ok: true })
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// finis
|
|
204
|
+
|
|
205
|
+
list(false, reman)
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
/*
|
|
210
|
+
* ResourceTracker
|
|
211
|
+
*
|
|
212
|
+
* A resource tracker maintains a list of resources. Each resource is associated with a
|
|
213
|
+
* registered connector using a classID. Resources are enumerated from the list provided by each
|
|
214
|
+
* connector class. A tracker does not store any persistent state information about specific
|
|
215
|
+
* connectors or resources, and can be updated at any time.
|
|
216
|
+
* The tracker object can provide a list of its resources by resID, which are UUID strings.
|
|
217
|
+
* There is no specific collation order. If you want the resources sorted by name or date or
|
|
218
|
+
* whatever, please do that yourself. Once you have a resID, you can use the connect method to get
|
|
219
|
+
* an instance object with methods appropriate to a specifed service on that resource. For example,
|
|
220
|
+
* you can connect to a filesystem instance and then manipulate files. A tracker must be opened
|
|
221
|
+
* before use and should be closed when no longer needed.
|
|
222
|
+
* A classID identifies a type of connector, a className is the user-friendly string for that
|
|
223
|
+
* connector type, and a resID is the string that uniquely names a specific resource.
|
|
224
|
+
*
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
closure ResourceTracker(reman, local retor, watch) {
|
|
228
|
+
retor = new(object, this)
|
|
229
|
+
watch = commonWatching.Watchable()
|
|
230
|
+
retor.watch = watch.watch
|
|
231
|
+
retor.unWatch = watch.unWatch
|
|
232
|
+
|
|
233
|
+
// connUpdateOnChange
|
|
234
|
+
// Update the list when watched connectors change resources.
|
|
235
|
+
function connUpdateOnChange(classID, changelist, local resID) {
|
|
236
|
+
for resID in changelist.deleted
|
|
237
|
+
retor.resids[resID] = undefined
|
|
238
|
+
for resID in changelist.added
|
|
239
|
+
retor.resids[resID] = classID
|
|
240
|
+
watch.notify(classID, changelist) // tell our watchers
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// addConnResources
|
|
244
|
+
// Add the resources for the specified connector.
|
|
245
|
+
function addConnResources(classID, local connector, reslist) {
|
|
246
|
+
if retor.classIdList.indexOf(classID) >= 0
|
|
247
|
+
return // someone screwed up, but let's not join them
|
|
248
|
+
retor.classIdList.push(classID)
|
|
249
|
+
connector = reman.conns[classID]
|
|
250
|
+
connector.watch(connUpdateOnChange)
|
|
251
|
+
reslist = connector.listResources()
|
|
252
|
+
if reslist.1
|
|
253
|
+
connUpdateOnChange(classID, { // notify our new resources
|
|
254
|
+
added: reslist.1
|
|
255
|
+
})
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// remanUpdateOnChange
|
|
259
|
+
// Update after a new connector is added to the resource manager.
|
|
260
|
+
function remanUpdateOnChange(prefix, changelist, local classID) {
|
|
261
|
+
for classID in changelist.added
|
|
262
|
+
addConnResources(classID)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// classIDs
|
|
266
|
+
//
|
|
267
|
+
// Return an array of possible connection classIDs.
|
|
268
|
+
retor.classIDs = function classIDs() {
|
|
269
|
+
retor.classIdList
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// className
|
|
273
|
+
//
|
|
274
|
+
// Return user-friendly name for a classID
|
|
275
|
+
retor.className = function className(classID) {
|
|
276
|
+
reman.conns[classID].label
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// labels
|
|
280
|
+
//
|
|
281
|
+
// Return an array of user-visible labels for our connection types
|
|
282
|
+
retor.labels = function labels(local labels, classID) {
|
|
283
|
+
labels = []
|
|
284
|
+
for classID in retor.classIdList
|
|
285
|
+
labels.push(className(classID))
|
|
286
|
+
labels
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// resources
|
|
290
|
+
//
|
|
291
|
+
// Return an array of our known resources as resIDs.
|
|
292
|
+
retor.resources = function resources(all, local resID, output) {
|
|
293
|
+
output = [ ]
|
|
294
|
+
for resID in retor.resids.* {
|
|
295
|
+
`(error, info) = reman.conns[retor.resids[resID]].info(resID)
|
|
296
|
+
if !error && (all || !info.hidden)
|
|
297
|
+
output.push(resID)
|
|
298
|
+
}
|
|
299
|
+
output
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// addResource
|
|
303
|
+
//
|
|
304
|
+
// Add a resource for a classID, returning the resID as a standard result tuple.
|
|
305
|
+
retor.addResource = function addResource(classID, resource) {
|
|
306
|
+
if !reman.conns[classID]
|
|
307
|
+
list(Error("resource type not available", classID))
|
|
308
|
+
else
|
|
309
|
+
reman.conns[classID].addResource(resource)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// getResource
|
|
313
|
+
//
|
|
314
|
+
// Get a resource for the resID as a standard result tuple.
|
|
315
|
+
retor.getResource = function getResource(resID, local error, classID) {
|
|
316
|
+
`(error, classID) = resourceClassID(resID)
|
|
317
|
+
if error
|
|
318
|
+
list(error)
|
|
319
|
+
else
|
|
320
|
+
reman.conns[classID].getResource(resID)
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// deleteResource
|
|
324
|
+
//
|
|
325
|
+
// Delete a resource.
|
|
326
|
+
retor.deleteResource = function deleteResource(resID, local error, classID) {
|
|
327
|
+
`(error, classID) = resourceClassID(resID)
|
|
328
|
+
if error
|
|
329
|
+
list(error)
|
|
330
|
+
else
|
|
331
|
+
reman.conns[classID].deleteResource(resID)
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// ensureExists
|
|
335
|
+
//
|
|
336
|
+
// Test for resource and add it if needed, returning the resID as a standard result tuple.
|
|
337
|
+
retor.ensureExists = function ensureExists(classID, resource, local resID) {
|
|
338
|
+
resID = reman.conns[classID].findResource(resource)
|
|
339
|
+
if retor.resids[resID]
|
|
340
|
+
list(false, resID)
|
|
341
|
+
else
|
|
342
|
+
addResource(classID, resource)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// uifields
|
|
346
|
+
//
|
|
347
|
+
// Return a dictionary of field descriptions for UI
|
|
348
|
+
retor.uifields = function uifields(classID) {
|
|
349
|
+
reman.conns[classID].uifields()
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// resourceClassID
|
|
353
|
+
//
|
|
354
|
+
// Get a resource for use and return an `(error, classID) tuple.
|
|
355
|
+
retor.resourceClassID = function resourceClassID(resID, local classID) {
|
|
356
|
+
classID = retor.resids[resID]
|
|
357
|
+
if !classID
|
|
358
|
+
return (list(Error("resource not found", resID)))
|
|
359
|
+
if !reman.conns[classID]
|
|
360
|
+
return (list(Error("resource type not available", classID)))
|
|
361
|
+
list(false, classID)
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// info
|
|
365
|
+
//
|
|
366
|
+
// Get a dictionary describing the named resource, or false if not found.
|
|
367
|
+
retor.info = function info(resID, local error, classID, connector, info) {
|
|
368
|
+
`(error, classID) = resourceClassID(resID)
|
|
369
|
+
if classID {
|
|
370
|
+
connector = reman.conns[classID]
|
|
371
|
+
`(error, info) = connector.info(resID)
|
|
372
|
+
}
|
|
373
|
+
new(info)
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// connect
|
|
377
|
+
//
|
|
378
|
+
// Connect to the resource for a service, returning an `(error, instance) tuple.
|
|
379
|
+
// Example:
|
|
380
|
+
// locate.connect(resid, "NideFS", rootpath)
|
|
381
|
+
retor.connect = function connect args {
|
|
382
|
+
function (resID, service, local error, classID) {
|
|
383
|
+
`(error, classID) = resourceClassID(resID)
|
|
384
|
+
if error
|
|
385
|
+
return (list(error))
|
|
386
|
+
reman.conns[classID].connect(resID, service, args.-2)
|
|
387
|
+
} (args.0, args.1)
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// open
|
|
391
|
+
//
|
|
392
|
+
// Start tracking resources.
|
|
393
|
+
retor.open = function open() {
|
|
394
|
+
if retor.classIdList
|
|
395
|
+
return // already open
|
|
396
|
+
watch.reset()
|
|
397
|
+
retor.resids = { } // start empty
|
|
398
|
+
retor.classIdList = []
|
|
399
|
+
for classID in reman.connectors()
|
|
400
|
+
addConnResources(classID)
|
|
401
|
+
reman.watch(remanUpdateOnChange)
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// close
|
|
405
|
+
//
|
|
406
|
+
// stop tracking resources.
|
|
407
|
+
retor.close = function close(local classID, connector) {
|
|
408
|
+
watch.reset()
|
|
409
|
+
if retor.classIdList {
|
|
410
|
+
for classID in retor.classIdList {
|
|
411
|
+
connector = reman.conns[classID]
|
|
412
|
+
connector.unWatch(connUpdateOnChange)
|
|
413
|
+
}
|
|
414
|
+
retor.classIdList = false
|
|
415
|
+
}
|
|
416
|
+
reman.unWatch(remanUpdateOnChange)
|
|
417
|
+
retor.resids = false
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// finis
|
|
421
|
+
retor
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
/*
|
|
426
|
+
* rsrcInit
|
|
427
|
+
*
|
|
428
|
+
* Initialize the component.
|
|
429
|
+
*
|
|
430
|
+
*/
|
|
431
|
+
|
|
432
|
+
function rsrcInit(local manifest) {
|
|
433
|
+
|
|
434
|
+
manifest = `(rsrcVault, ResourceManager, ResourceTracker, rsrcInit)
|
|
435
|
+
|
|
436
|
+
Naan.module.build(module.id, "resources", function(modobj, compobj) {
|
|
437
|
+
require("./storage.nlg")
|
|
438
|
+
require("./dbt_pouch.nlg")
|
|
439
|
+
commonWatching = require("../common/watching.nlg")
|
|
440
|
+
compobj.manifest = manifest
|
|
441
|
+
module.exports.ResourceManager = ResourceManager
|
|
442
|
+
module.exports.ResourceTracker = ResourceTracker
|
|
443
|
+
})
|
|
444
|
+
|
|
445
|
+
} ();
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* storage.nlg
|
|
3
|
+
* Naanlib/frameworks/storage
|
|
4
|
+
*
|
|
5
|
+
* Root component for database and filesystem functionality.
|
|
6
|
+
*
|
|
7
|
+
* column positioning: // // !
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2020-2022 by Richard C. Zulch
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* storInit
|
|
16
|
+
*
|
|
17
|
+
* Initialize the storage module.
|
|
18
|
+
*
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function storInit(local manifest) {
|
|
23
|
+
manifest = `(storInit)
|
|
24
|
+
|
|
25
|
+
Naan.module.build(module.id, "storage", function(modobj, compobj) {
|
|
26
|
+
require("../common/common.nlg").LiveImport()
|
|
27
|
+
require("../common/watching.nlg")
|
|
28
|
+
compobj.manifest = manifest
|
|
29
|
+
LoadComponentOnDemand(list(DbConnector, ListBrowserDBs, PouchDB), "./dbt_pouch.nlg")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// storReload
|
|
33
|
+
//
|
|
34
|
+
// Initialize environment functionality when we reload.
|
|
35
|
+
//
|
|
36
|
+
function storReload(local wsg) {
|
|
37
|
+
wsg = js.w || js.s || js.g // any global: browser or web worker or nodejs
|
|
38
|
+
jspath = js.r("path")
|
|
39
|
+
if js.w || js.s {
|
|
40
|
+
JsLoadScript("frameworks/browser/pouchdb/pouchdb.min.js", "PouchDB")
|
|
41
|
+
pouchdb = wsg.PouchDB
|
|
42
|
+
indexedDB = wsg.indexedDB
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
pouchdb = js.r("pouchdb")
|
|
46
|
+
indexedDB = false
|
|
47
|
+
}
|
|
48
|
+
}()
|
|
49
|
+
module.reload = storReload
|
|
50
|
+
|
|
51
|
+
})
|
|
52
|
+
} ();
|