@naanlang/naan 1.0.2 → 1.0.5
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 +1 -1
- package/README.md +10 -8
- package/bin/index.js +2 -2
- package/dist/env_web.js +172 -22
- package/dist/naan.min.js +6 -6
- package/frameworks/browser/https_request.nlg +120 -0
- package/frameworks/browser/sworker.js +299 -91
- package/frameworks/browser/terminals.nlg +28 -13
- package/frameworks/browser/workers.nlg +27 -12
- package/frameworks/client/apiclient.nlg +17 -4
- package/frameworks/client/psm_client.nlg +184 -81
- package/frameworks/common/common.nlg +105 -25
- package/frameworks/common/preferences.nlg +1 -0
- package/frameworks/common/watching.nlg +1 -0
- package/frameworks/node/apiserver.nlg +31 -15
- package/frameworks/node/filesystem.nlg +230 -46
- package/frameworks/node/gitter.nlg +27 -6
- package/frameworks/node/https_request.nlg +119 -0
- package/frameworks/node/node.nlg +1 -0
- package/frameworks/node/psm_server.nlg +113 -37
- package/frameworks/project/build.nlg +40 -23
- package/frameworks/project/proj_cliser.nlg +11 -3
- package/frameworks/project/proj_console.nlg +13 -4
- package/frameworks/project/proj_folder.nlg +10 -1
- package/frameworks/project/proj_lambda.nlg +13 -4
- package/frameworks/project/proj_static.nlg +11 -3
- package/frameworks/project/projects.nlg +128 -40
- package/frameworks/running/debugnub.nlg +2 -5
- package/frameworks/running/executors.nlg +1 -0
- package/frameworks/storage/csv.nlg +120 -0
- package/frameworks/storage/dbt_pouch.nlg +41 -25
- package/frameworks/storage/psm.nlg +108 -28
- package/frameworks/storage/psm_dbtables.nlg +7 -3
- package/frameworks/storage/resources.nlg +30 -2
- package/lib/browser/env_web.js +170 -20
- package/lib/browser/env_webworker.js +1 -1
- package/lib/browser/require.js +1 -1
- package/lib/core/naanlib.js +6 -6
- package/package.json +2 -1
- package/plugins/serviceAws/aws/aws-sdk-node.min.js +2 -0
- package/plugins/serviceAws/aws/aws-sdk.min.js +2 -88
- package/plugins/serviceAws/aws_cloudwatchlogs.nlg +8 -7
- package/plugins/serviceAws/aws_dynamo.nlg +715 -148
- package/plugins/serviceAws/aws_dynextra.nlg +294 -0
- package/plugins/serviceAws/aws_lambda.nlg +11 -4
- package/plugins/serviceAws/aws_s3.nlg +44 -14
- package/plugins/serviceAws/dbt_aws.nlg +58 -45
- package/plugins/serviceAws/psm_aws.nlg +61 -40
- package/plugins/serviceAws/serviceAws.nlg +7 -4
- package/plugins/serviceGitHub/psm_github.nlg +41 -25
- package/plugins/serviceGitLab/psm_gitlab.nlg +41 -25
- package/test/harness.nlg +3 -1
- package/test/test_01_core.nlg +5 -5
- package/test/test_02_context.nlg +4 -4
- package/test/test_03_jsinterop.nlg +9 -3
- package/plugins/serviceAws/aws_cognito.nlg +0 -76
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2019-
|
|
9
|
+
* Copyright (c) 2019-2022 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -77,7 +77,7 @@ closure TermHost(track, api, name, workerID, options,
|
|
|
77
77
|
if !target.written
|
|
78
78
|
target.term.WriteLn("(reconnected)")
|
|
79
79
|
}, 1000).run()
|
|
80
|
-
else
|
|
80
|
+
else if message.respOp
|
|
81
81
|
debuglog("unknown host response message:", message.respOp)
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -170,6 +170,7 @@ closure TermHost(track, api, name, workerID, options,
|
|
|
170
170
|
|
|
171
171
|
target.sendControl = function sendControl(workerOp, payload) {
|
|
172
172
|
target.ws.send(js.w.JSON.stringify({
|
|
173
|
+
guid: api.guid
|
|
173
174
|
clientID: clientID
|
|
174
175
|
serverID: serverID
|
|
175
176
|
workerID: target.workerID
|
|
@@ -355,7 +356,7 @@ closure TermHost(track, api, name, workerID, options,
|
|
|
355
356
|
*/
|
|
356
357
|
|
|
357
358
|
closure TermLocal(track, name, workerID, options,
|
|
358
|
-
local target, nlregex)
|
|
359
|
+
local target, nlregex, listener)
|
|
359
360
|
{
|
|
360
361
|
if workerID == "NaanIDE" {
|
|
361
362
|
if !js.t
|
|
@@ -363,8 +364,6 @@ closure TermLocal(track, name, workerID, options,
|
|
|
363
364
|
termInstallVirtualWatcher(track, js.t)
|
|
364
365
|
return (termIDE(track, name, workerID, js.t)) // connect to IDE execution instance itself
|
|
365
366
|
}
|
|
366
|
-
if not js.w.Worker
|
|
367
|
-
return (list(Error("Local environment does not support workers")))
|
|
368
367
|
if dictionary(options)
|
|
369
368
|
options = new(options)
|
|
370
369
|
else
|
|
@@ -372,13 +371,27 @@ closure TermLocal(track, name, workerID, options,
|
|
|
372
371
|
target = runningExecutors.ExecutorBase(track, "Local", name)
|
|
373
372
|
nlregex = RegExp("\\n", "g")
|
|
374
373
|
target.workerID = workerID
|
|
375
|
-
target.worker = xnew(js.w.Worker, "env_webworker.js")
|
|
376
374
|
target.msgQueue = []
|
|
375
|
+
if workerID == "NaanIDE-Debug" {
|
|
376
|
+
target.worker = js.w.open(js.w.location.href, "_blank")
|
|
377
|
+
target.worker.addEventListener("beforeunload", function(e) { // our target is closing
|
|
378
|
+
destroy()
|
|
379
|
+
})
|
|
380
|
+
js.w.addEventListener("beforeunload", function(e) { // we are closing
|
|
381
|
+
// ### tell target we are closing (if needed)
|
|
382
|
+
})
|
|
383
|
+
listener = js.w
|
|
384
|
+
} else {
|
|
385
|
+
if not js.w.Worker
|
|
386
|
+
return (list(Error("Local environment does not support workers")))
|
|
387
|
+
target.worker = xnew(js.w.Worker, "env_webworker.js")
|
|
388
|
+
listener = target.worker
|
|
389
|
+
}
|
|
377
390
|
|
|
378
391
|
// onmessage
|
|
379
392
|
// A message was received from the worker.
|
|
380
393
|
|
|
381
|
-
|
|
394
|
+
listener.addEventListener("message", function(e, msg) {
|
|
382
395
|
msg = new(e.data)
|
|
383
396
|
if msg.id != "targetout" && msg.id != "loaded" {
|
|
384
397
|
if msg.id == "status"
|
|
@@ -388,14 +401,14 @@ closure TermLocal(track, name, workerID, options,
|
|
|
388
401
|
target.msgQueue.push(msg)
|
|
389
402
|
return } }
|
|
390
403
|
target.doMessage(msg)
|
|
391
|
-
}
|
|
404
|
+
})
|
|
392
405
|
|
|
393
406
|
// onerror
|
|
394
407
|
// The worker had an error.
|
|
395
408
|
|
|
396
|
-
target.worker.
|
|
409
|
+
target.worker.addEventListener("error", function(e) {
|
|
397
410
|
target.execClosed(Error("instance error", e.message))
|
|
398
|
-
}
|
|
411
|
+
})
|
|
399
412
|
|
|
400
413
|
//
|
|
401
414
|
// oninterrupt
|
|
@@ -589,14 +602,17 @@ closure findIDEtarget(track, name, workerID, naancont, local target) {
|
|
|
589
602
|
*
|
|
590
603
|
*/
|
|
591
604
|
|
|
592
|
-
closure termIDE(track, name, workerID, naancont, local target, connected) {
|
|
605
|
+
closure termIDE(track, name, workerID, naancont, title, local target, connected) {
|
|
593
606
|
target = findIDEtarget(track, name, workerID, naancont)
|
|
594
607
|
if target { // new naancont on existing target
|
|
595
608
|
target.updateController(naancont)
|
|
609
|
+
target.title = title
|
|
610
|
+
track.update(target)
|
|
596
611
|
return (target)
|
|
597
612
|
}
|
|
598
613
|
target = runningExecutors.ExecutorBase(track, "Local", name)
|
|
599
614
|
target.name = name
|
|
615
|
+
target.title = title
|
|
600
616
|
target.workerID = workerID
|
|
601
617
|
target.naancont = naancont
|
|
602
618
|
connected = []
|
|
@@ -743,7 +759,6 @@ closure termIDE(track, name, workerID, naancont, local target, connected) {
|
|
|
743
759
|
/*
|
|
744
760
|
* termInstallVirtualWatcher
|
|
745
761
|
*
|
|
746
|
-
* column positioning: // // !
|
|
747
762
|
* Install a persistent watcher to note when virtual terminals come and go, and manage their
|
|
748
763
|
* execution target lifetimes.
|
|
749
764
|
*
|
|
@@ -753,7 +768,7 @@ closure termInstallVirtualWatcher(track, naancont) {
|
|
|
753
768
|
|
|
754
769
|
function watchVsites(msg, local error, target) {
|
|
755
770
|
if msg.op == "VsiteOpen" {
|
|
756
|
-
`(error, target) = termIDE(track, msg.name, "NaanVsite", msg.naancont)
|
|
771
|
+
`(error, target) = termIDE(track, msg.name, "NaanVsite", msg.naancont, msg.title)
|
|
757
772
|
target.attention()
|
|
758
773
|
}
|
|
759
774
|
else if msg.op == "VsiteClose" {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
closure ServiceWorker(local serv, callback) {
|
|
21
|
+
closure ServiceWorker(pubID, pubVersion, local serv, callback) {
|
|
22
22
|
serv = new(object, this)
|
|
23
23
|
|
|
24
24
|
//
|
|
@@ -32,7 +32,11 @@ closure ServiceWorker(local serv, callback) {
|
|
|
32
32
|
mchan = xnew(js.w.MessageChannel)
|
|
33
33
|
serv.msgport = mchan.port2
|
|
34
34
|
serv.msgport.onmessage = workerMsg.proc
|
|
35
|
-
serv.sw.postMessage({
|
|
35
|
+
serv.sw.postMessage({
|
|
36
|
+
hereIsYourPort: mchan.port1
|
|
37
|
+
hereIsMyID: pubID
|
|
38
|
+
hereIsMyVersion: pubVersion
|
|
39
|
+
}, [mchan.port1])
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
//
|
|
@@ -50,7 +54,16 @@ closure ServiceWorker(local serv, callback) {
|
|
|
50
54
|
request: msg.request
|
|
51
55
|
version: msg.version
|
|
52
56
|
})
|
|
53
|
-
} else if msg.id == "
|
|
57
|
+
} else if msg.id == "upgrade" {
|
|
58
|
+
if serv.upgrade != msg.version {
|
|
59
|
+
serv.upgrade = msg.version // only report once
|
|
60
|
+
callback(false, {
|
|
61
|
+
message: "upgrade"
|
|
62
|
+
version: msg.version
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else if msg.id == "text"
|
|
54
67
|
debuglog("sw[".concat(serv.scope, "]: "), msg.text) // handy remote debug capability
|
|
55
68
|
}
|
|
56
69
|
|
|
@@ -174,10 +187,10 @@ closure ServiceWorker(local serv, callback) {
|
|
|
174
187
|
*
|
|
175
188
|
*/
|
|
176
189
|
|
|
177
|
-
closure ScopedServiceWorker(local scoper, result) {
|
|
190
|
+
closure ScopedServiceWorker(pubID, pubVersion, callback, local scoper, result) {
|
|
178
191
|
scoper = new(object, ScopedServiceWorker)
|
|
179
192
|
scoper.scopes = {}
|
|
180
|
-
scoper.serv = ServiceWorker()
|
|
193
|
+
scoper.serv = ServiceWorker(pubID, pubVersion)
|
|
181
194
|
result = scoper.serv.register("/", closure(error, data, local response, filepath, scope) {
|
|
182
195
|
if data.message == "fetch" {
|
|
183
196
|
response = {
|
|
@@ -201,7 +214,7 @@ closure ScopedServiceWorker(local scoper, result) {
|
|
|
201
214
|
filepath = xnew(js.w.URL, data.request.url).pathname
|
|
202
215
|
filepath = DecodeURIComponent(filepath) // "/run/<scope>/path..."
|
|
203
216
|
filepath = filepath.slice(4) // "/<scope>/path..."
|
|
204
|
-
error = true
|
|
217
|
+
error = true // stays true iff not in scope
|
|
205
218
|
for scope in scoper.scopes {
|
|
206
219
|
if filepath.startsWith(scope) {
|
|
207
220
|
filepath = filepath.slice(scope.length+1) // remove scope including "/"
|
|
@@ -209,8 +222,6 @@ closure ScopedServiceWorker(local scoper, result) {
|
|
|
209
222
|
break
|
|
210
223
|
}
|
|
211
224
|
}
|
|
212
|
-
if error === true
|
|
213
|
-
debuglog("ScopedServiceWorker: couldn't find scope", scope, "in", totuple(scoper.scopes))
|
|
214
225
|
|
|
215
226
|
// read resource failed
|
|
216
227
|
if error {
|
|
@@ -226,7 +237,8 @@ closure ScopedServiceWorker(local scoper, result) {
|
|
|
226
237
|
response.body = data
|
|
227
238
|
scoper.serv.msgport.postMessage(response)
|
|
228
239
|
return
|
|
229
|
-
}
|
|
240
|
+
} else if data.message == "upgrade"
|
|
241
|
+
callback(data.version)
|
|
230
242
|
})
|
|
231
243
|
if result.0 {
|
|
232
244
|
ErrorDebuglog("ScopedServiceWorker failed", result)
|
|
@@ -302,6 +314,7 @@ closure TrackedScope(track, scope, fs, rootpath, local trope, result) {
|
|
|
302
314
|
mimeType = {
|
|
303
315
|
"css": "text/css",
|
|
304
316
|
"csv": "text/csv",
|
|
317
|
+
"gif": "image/gif",
|
|
305
318
|
"htm": "text/html",
|
|
306
319
|
"html": "text/html",
|
|
307
320
|
"ico": "image/x-icon",
|
|
@@ -353,12 +366,14 @@ closure TrackedScope(track, scope, fs, rootpath, local trope, result) {
|
|
|
353
366
|
/*
|
|
354
367
|
* TrackServiceWorkers
|
|
355
368
|
*
|
|
356
|
-
* Configure service workers to be tracked in the execution tracker.
|
|
369
|
+
* Configure service workers to be tracked in the execution tracker. The pubID identifies us as
|
|
370
|
+
* the publisher for this service worker, and the version allows it to clear its cache when versions
|
|
371
|
+
* change.
|
|
357
372
|
*
|
|
358
373
|
*/
|
|
359
374
|
|
|
360
|
-
closure TrackServiceWorkers(track, local error) {
|
|
361
|
-
`(error, serviceWorker) = ScopedServiceWorker()
|
|
375
|
+
closure TrackServiceWorkers(track, pubID, pubVersion, callback, local error) {
|
|
376
|
+
`(error, serviceWorker) = ScopedServiceWorker(pubID, pubVersion, callback)
|
|
362
377
|
if error
|
|
363
378
|
ErrorDebugLog("TrackServiceWorkers: cannot load service worker", error)
|
|
364
379
|
track.register(TrackedScope, "V-Site")
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2017-
|
|
9
|
+
* Copyright (c) 2017-2022 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -20,9 +20,10 @@
|
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
closure MakeNideAPIclient(url, local client) {
|
|
23
|
+
closure MakeNideAPIclient(url, guid, local client) {
|
|
24
24
|
client = new(object, this)
|
|
25
25
|
client.url = url
|
|
26
|
+
client.guid = guid
|
|
26
27
|
client.notifyAfter = 0
|
|
27
28
|
|
|
28
29
|
// clientRequest() - general request routine
|
|
@@ -51,6 +52,8 @@ closure MakeNideAPIclient(url, local client) {
|
|
|
51
52
|
request.responseType = options.responseType
|
|
52
53
|
if options.contentType
|
|
53
54
|
request.setRequestHeader("Content-Type", options.contentType)
|
|
55
|
+
if guid
|
|
56
|
+
request.setRequestHeader("x-naanlang-api-guid", guid)
|
|
54
57
|
request.send(options.putdata)
|
|
55
58
|
}
|
|
56
59
|
|
|
@@ -117,7 +120,7 @@ closure MakeNideAPIclient(url, local client) {
|
|
|
117
120
|
// Otherwise if communication failed then the result is:
|
|
118
121
|
// callback(<error>).
|
|
119
122
|
|
|
120
|
-
client.psmRemote = closure psmRemote(options, data, callback, local query, method, reqOptions) {
|
|
123
|
+
client.psmRemote = closure psmRemote(options, data, callback, local query, method, reqOptions, error) {
|
|
121
124
|
query = EncodeQuery("/psm/?", options)
|
|
122
125
|
if data
|
|
123
126
|
method = "PUT"
|
|
@@ -131,6 +134,16 @@ closure MakeNideAPIclient(url, local client) {
|
|
|
131
134
|
reqOptions.contentType = "application/octet-stream" // we are sending binary data
|
|
132
135
|
else
|
|
133
136
|
reqOptions.responseType = "arraybuffer" // we are requesting binary data
|
|
137
|
+
} else if options.encoding == "json" {
|
|
138
|
+
if data {
|
|
139
|
+
reqOptions.contentType = "application/json;charset=UTF-8" // we are sending JSON
|
|
140
|
+
`(error, data) = JsonStringify(data)
|
|
141
|
+
if error
|
|
142
|
+
return (callback(Error("psmRemote failed:", error)))
|
|
143
|
+
reqOptions.putdata = data
|
|
144
|
+
}
|
|
145
|
+
else
|
|
146
|
+
reqOptions.responseType = "application/json" // we are requesting JSON
|
|
134
147
|
}
|
|
135
148
|
clientRequest(method, url.concat(query), reqOptions, function (error, req, event, local data) {
|
|
136
149
|
if !error && req.status != 200
|
|
@@ -172,7 +185,7 @@ closure MakeNideAPIclient(url, local client) {
|
|
|
172
185
|
|
|
173
186
|
function apicInit(local manifest) {
|
|
174
187
|
|
|
175
|
-
manifest = `(
|
|
188
|
+
manifest = `(MakeNideAPIclient, apicInit)
|
|
176
189
|
|
|
177
190
|
Naan.module.build(module.id, "apiclient", function(modobj, compobj) {
|
|
178
191
|
Naan.module.require("./client.nlg")
|