@naanlang/naan 1.0.9 → 1.0.11
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 +1 -1
- package/bin/index.js +2 -2
- package/dist/env_web.js +8 -2
- package/dist/naan.min.js +5 -5
- package/frameworks/browser/sworker.js +17 -17
- package/frameworks/common/common.nlg +1 -1
- package/frameworks/common/utils.nlg +77 -0
- package/frameworks/node/filesystem.nlg +1 -1
- package/frameworks/node/https_request.nlg +19 -2
- package/frameworks/node/node.nlg +1 -0
- package/frameworks/project/projects.nlg +4 -2
- package/frameworks/running/debugnub.nlg +4 -4
- package/frameworks/storage/file_manager.nlg +1 -1
- package/frameworks/storage/psm.nlg +3 -3
- package/lib/browser/env_web.js +14 -8
- package/lib/core/naanlib.js +5 -5
- package/lib/env_nodeworker.js +5 -0
- package/package.json +1 -1
- package/plugins/openSearch/openSearch.nlg +490 -0
- package/plugins/openSearch/os_dynamo.nlg +195 -0
- package/plugins/serviceAws/aws/aws-sdk-node.min.js +1 -1
- package/plugins/serviceAws/aws/aws-sdk.min.js +1 -1
- package/plugins/serviceAws/aws_cloudwatchlogs.nlg +3 -3
- package/plugins/serviceAws/aws_dynamo.nlg +14 -19
- package/plugins/serviceAws/aws_sqs.nlg +5 -1
- package/plugins/serviceAws/dbt_aws.nlg +15 -15
- package/test/test_02_context.nlg +1 -1
- package/test/test_03_jsinterop.nlg +4 -1
- package/test/test_07_lingo.nlg +2 -1
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2021 by Richard C. Zulch
|
|
9
|
+
* Copyright (c) 2021-2023 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -61,7 +61,7 @@ closure CloudWatchLogs(local cwlogs) {
|
|
|
61
61
|
// describeLogStreams
|
|
62
62
|
//
|
|
63
63
|
cwlogs.describeLogStreams = closure describeLogStreams(name, options,
|
|
64
|
-
local params,
|
|
64
|
+
local params, output, error)
|
|
65
65
|
{
|
|
66
66
|
params = {
|
|
67
67
|
logGroupName: name
|
|
@@ -83,7 +83,7 @@ closure CloudWatchLogs(local cwlogs) {
|
|
|
83
83
|
// getLogEvents
|
|
84
84
|
//
|
|
85
85
|
cwlogs.getLogEvents = closure getLogEvents(groupName, streamName, options
|
|
86
|
-
local params,
|
|
86
|
+
local params, output, error)
|
|
87
87
|
{
|
|
88
88
|
params = {
|
|
89
89
|
logGroupName: groupName
|
|
@@ -250,12 +250,7 @@ closure DynaConverter(local conv) {
|
|
|
250
250
|
if dtype == "BS" || dtype == "SS"
|
|
251
251
|
dvalue
|
|
252
252
|
else if dtype == "NS"
|
|
253
|
-
new(dvalue).map(
|
|
254
|
-
if item.indexOf(".") >= 0
|
|
255
|
-
Number.parseFloat(item)
|
|
256
|
-
else
|
|
257
|
-
Number.parseInt(item)
|
|
258
|
-
})
|
|
253
|
+
new(dvalue).map(Number.parseFloat(item))
|
|
259
254
|
else if dtype == "M"
|
|
260
255
|
recordDynToNaan(dvalue)
|
|
261
256
|
else if dtype == "L"
|
|
@@ -265,11 +260,8 @@ closure DynaConverter(local conv) {
|
|
|
265
260
|
})
|
|
266
261
|
else if dtype == "BOOL"
|
|
267
262
|
dvalue && true
|
|
268
|
-
else if dtype == "N"
|
|
269
|
-
|
|
270
|
-
Number.parseFloat(dvalue)
|
|
271
|
-
else
|
|
272
|
-
Number.parseInt(dvalue) }
|
|
263
|
+
else if dtype == "N"
|
|
264
|
+
Number.parseFloat(dvalue)
|
|
273
265
|
else if dtype == "NULL"
|
|
274
266
|
null
|
|
275
267
|
else if dtype == "B" || dtype == "S"
|
|
@@ -567,7 +559,8 @@ closure DynaTable(dyna, tablename, local table) {
|
|
|
567
559
|
else if key.AttributeName == output.range
|
|
568
560
|
output.rangeType = dyna.conv.fieldTypeDynToNaan(key.AttributeType)
|
|
569
561
|
table.hashKey = compress(output.hash) // hash attribute name
|
|
570
|
-
|
|
562
|
+
if output.range
|
|
563
|
+
table.rangeKey = compress(output.range) // range attribute name or false
|
|
571
564
|
}
|
|
572
565
|
pending.signal(list(error, output))
|
|
573
566
|
})
|
|
@@ -842,9 +835,9 @@ closure DynaTable(dyna, tablename, local table) {
|
|
|
842
835
|
processed = doneCB(data)
|
|
843
836
|
if processed
|
|
844
837
|
remaining -= processed
|
|
838
|
+
params.ExclusiveStartKey = data.LastEvaluatedKey
|
|
845
839
|
if processed && remaining > 0 && data.LastEvaluatedKey {
|
|
846
840
|
params.limit = remaining // set up for next iteration
|
|
847
|
-
params.ExclusiveStartKey = data.LastEvaluatedKey
|
|
848
841
|
true // continue looping
|
|
849
842
|
}
|
|
850
843
|
})
|
|
@@ -862,7 +855,7 @@ closure DynaTable(dyna, tablename, local table) {
|
|
|
862
855
|
// attmap: <dictionary> // map attribute names to #shortcuts
|
|
863
856
|
// reverse: <boolean> // reverse order
|
|
864
857
|
// project: <array> // project only specified attributes
|
|
865
|
-
//
|
|
858
|
+
// paging: <exclusive start key> // for paging; updated each call
|
|
866
859
|
// limit: <number> // maximum count of results
|
|
867
860
|
// }
|
|
868
861
|
//
|
|
@@ -907,8 +900,8 @@ closure DynaTable(dyna, tablename, local table) {
|
|
|
907
900
|
params.ScanIndexForward = false
|
|
908
901
|
if options.project
|
|
909
902
|
params.ProjectionExpression = options.project.join(", ")
|
|
910
|
-
if options.
|
|
911
|
-
params.ExclusiveStartKey = options.
|
|
903
|
+
if options.paging
|
|
904
|
+
params.ExclusiveStartKey = options.paging
|
|
912
905
|
output = []
|
|
913
906
|
`(error) = dynQueryPager(`query, params, options.limit, function(data) {
|
|
914
907
|
if data.Count > 0
|
|
@@ -919,6 +912,7 @@ closure DynaTable(dyna, tablename, local table) {
|
|
|
919
912
|
error = Error("table.queryRecords(".concat(tablename, ") failed"), error)
|
|
920
913
|
output = false
|
|
921
914
|
}
|
|
915
|
+
options.paging = params.ExclusiveStartKey
|
|
922
916
|
list(error, output)
|
|
923
917
|
}
|
|
924
918
|
|
|
@@ -931,7 +925,7 @@ closure DynaTable(dyna, tablename, local table) {
|
|
|
931
925
|
// filter: <key-expression> // conditions for items to return
|
|
932
926
|
// attmap: <dictionary> // map attribute names to #shortcuts
|
|
933
927
|
// project: <array> // project only specified attributes
|
|
934
|
-
//
|
|
928
|
+
// paging: <exclusive start key> // for paging; updated each call
|
|
935
929
|
// limit: <number> // maximum count of results
|
|
936
930
|
// }
|
|
937
931
|
//
|
|
@@ -957,8 +951,8 @@ closure DynaTable(dyna, tablename, local table) {
|
|
|
957
951
|
params.ExpressionAttributeNames = attmap
|
|
958
952
|
if options.project
|
|
959
953
|
params.ProjectionExpression = options.project.join(", ")
|
|
960
|
-
if options.
|
|
961
|
-
params.ExclusiveStartKey = options.
|
|
954
|
+
if options.paging
|
|
955
|
+
params.ExclusiveStartKey = options.paging
|
|
962
956
|
output = []
|
|
963
957
|
`(error) = dynQueryPager(`scan, params, options.limit, function(data) {
|
|
964
958
|
if data.Count >= 0
|
|
@@ -969,6 +963,7 @@ closure DynaTable(dyna, tablename, local table) {
|
|
|
969
963
|
error = Error("table.scanRecords(".concat(tablename, ") failed"), error)
|
|
970
964
|
output = false
|
|
971
965
|
}
|
|
966
|
+
options.paging = params.ExclusiveStartKey
|
|
972
967
|
list(error, output)
|
|
973
968
|
}
|
|
974
969
|
|
|
@@ -68,7 +68,11 @@ closure SQS(local sqs) {
|
|
|
68
68
|
// sendMessage
|
|
69
69
|
//
|
|
70
70
|
sqs.sendMessage = closure sendMessage(queueUrl, msgBody, local params, pending) {
|
|
71
|
-
|
|
71
|
+
if !sqs.aws || !queueUrl {
|
|
72
|
+
error = Error("SQS.sendMessage: invalid arguments", sqs.aws)
|
|
73
|
+
ErrorDebuglog(error)
|
|
74
|
+
return (list(error))
|
|
75
|
+
}
|
|
72
76
|
params = {
|
|
73
77
|
MessageBody: msgBody
|
|
74
78
|
QueueUrl: queueUrl
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2020-
|
|
9
|
+
* Copyright (c) 2020-2023 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -77,7 +77,7 @@ closure dawsBucket(s3b, local bucket, s3) {
|
|
|
77
77
|
|
|
78
78
|
function s3GetCB(error, resp) {
|
|
79
79
|
if error
|
|
80
|
-
error = Error("can't get object", error, key)
|
|
80
|
+
error = Error("can't get object", { status: error.$metadata.httpStatusCode }, error, key)
|
|
81
81
|
else
|
|
82
82
|
resp.md5 = hashFromETag(resp.ETag)
|
|
83
83
|
callback(error, resp)
|
|
@@ -162,7 +162,7 @@ closure dawsBucket(s3b, local bucket, s3) {
|
|
|
162
162
|
md5 = HashMD5(data) // hex character string
|
|
163
163
|
s3.putObject(params, function(error, resp) {
|
|
164
164
|
if error
|
|
165
|
-
error = Error("can't put object", error, key)
|
|
165
|
+
error = Error("can't put object", { status: error.$metadata.httpStatusCode }, error, key)
|
|
166
166
|
else {
|
|
167
167
|
resp.length = length(data)
|
|
168
168
|
resp.md5 = hashFromETag(resp.ETag)
|
|
@@ -188,7 +188,7 @@ closure dawsBucket(s3b, local bucket, s3) {
|
|
|
188
188
|
}
|
|
189
189
|
s3.deleteObject(params, function(error, resp) {
|
|
190
190
|
if error
|
|
191
|
-
error = Error("can't delete object", error, key)
|
|
191
|
+
error = Error("can't delete object", { status: error.$metadata.httpStatusCode }, error, key)
|
|
192
192
|
callback(error, resp)
|
|
193
193
|
})
|
|
194
194
|
}
|
|
@@ -209,7 +209,7 @@ closure dawsBucket(s3b, local bucket, s3) {
|
|
|
209
209
|
}
|
|
210
210
|
s3.copyObject(params, function(error, resp) {
|
|
211
211
|
if error
|
|
212
|
-
error = Error("can't copy object", error)
|
|
212
|
+
error = Error("can't copy object", { status: error.$metadata.httpStatusCode }, error)
|
|
213
213
|
callback(error, resp)
|
|
214
214
|
})
|
|
215
215
|
}
|
|
@@ -245,7 +245,7 @@ closure dawsBucket(s3b, local bucket, s3) {
|
|
|
245
245
|
function listOne() { // list one chunk of objects
|
|
246
246
|
s3.listObjectsV2(params, function(error, resp) {
|
|
247
247
|
if error
|
|
248
|
-
callback(Error("list objects failed", error))
|
|
248
|
+
callback(Error("list objects failed", { status: error.$metadata.httpStatusCode }, error))
|
|
249
249
|
else {
|
|
250
250
|
if output {
|
|
251
251
|
output.Contents = output.Contents.concat(resp.Contents)
|
|
@@ -440,7 +440,7 @@ closure dawsTable(database, path, tableOptions, local table) {
|
|
|
440
440
|
cacheControl: tableOptions.cacheControl
|
|
441
441
|
}, function(error, resp) {
|
|
442
442
|
if error
|
|
443
|
-
error = Error("add failed", error, id, { status: error
|
|
443
|
+
error = Error("add failed", error, id, { status: error.status })
|
|
444
444
|
else {
|
|
445
445
|
doc._md5 = resp.md5 // update the original doc
|
|
446
446
|
doc.length = resp.length }
|
|
@@ -463,7 +463,7 @@ closure dawsTable(database, path, tableOptions, local table) {
|
|
|
463
463
|
cacheControl: tableOptions.cacheControl
|
|
464
464
|
}, function(error, resp) {
|
|
465
465
|
if error
|
|
466
|
-
error = Error("update failed", error, doc._id, { status: error
|
|
466
|
+
error = Error("update failed", error, doc._id, { status: error.status })
|
|
467
467
|
else {
|
|
468
468
|
doc._md5 = resp.md5 // update the original doc
|
|
469
469
|
doc.modified = undefined // we don't know exact modify date
|
|
@@ -484,7 +484,7 @@ closure dawsTable(database, path, tableOptions, local table) {
|
|
|
484
484
|
return (asyncResult(callback, Error("invalid argument")))
|
|
485
485
|
database.bucket.delete(doc._id, function(error, resp) {
|
|
486
486
|
if error
|
|
487
|
-
error = Error("delete failed", error, doc._id, { status: error
|
|
487
|
+
error = Error("delete failed", error, doc._id, { status: error.status })
|
|
488
488
|
callback(error, resp)
|
|
489
489
|
})
|
|
490
490
|
}
|
|
@@ -501,7 +501,7 @@ closure dawsTable(database, path, tableOptions, local table) {
|
|
|
501
501
|
return (asyncResult(callback, id)) // error from makeID
|
|
502
502
|
database.bucket.get(id, false, function(error, resp) {
|
|
503
503
|
if error
|
|
504
|
-
error = Error("get failed", error, id, { status: error
|
|
504
|
+
error = Error("get failed", error, id, { status: error.status })
|
|
505
505
|
else {
|
|
506
506
|
resp.key = key
|
|
507
507
|
resp = s3resp2doc(resp)
|
|
@@ -536,7 +536,7 @@ closure dawsTable(database, path, tableOptions, local table) {
|
|
|
536
536
|
return (asyncResult(callback, id)) // error from makeID
|
|
537
537
|
database.bucket.get(id, true, function(error, resp) {
|
|
538
538
|
if error
|
|
539
|
-
error = Error("md5 failed", error, id, { status: error
|
|
539
|
+
error = Error("md5 failed", error, id, { status: error.status })
|
|
540
540
|
else if resp._md5
|
|
541
541
|
resp = resp._md5
|
|
542
542
|
else
|
|
@@ -561,7 +561,7 @@ closure dawsTable(database, path, tableOptions, local table) {
|
|
|
561
561
|
if id.slice(-1) == "/"
|
|
562
562
|
database.bucket.list(id.slice(0,-1), true, function blcb(error, resp) {
|
|
563
563
|
if error
|
|
564
|
-
error = Error("head failed", error, id, { status: error
|
|
564
|
+
error = Error("head failed", error, id, { status: error.status })
|
|
565
565
|
else if id != resp.CommonPrefixes.0.Prefix {
|
|
566
566
|
error = Error("head not found", id, resp.CommonPrefixes.0.Prefix, { status: 404 })
|
|
567
567
|
resp = false
|
|
@@ -575,7 +575,7 @@ closure dawsTable(database, path, tableOptions, local table) {
|
|
|
575
575
|
else
|
|
576
576
|
database.bucket.get(id, true, function bgcb(error, resp) {
|
|
577
577
|
if error
|
|
578
|
-
error = Error("head failed", error, id, { status: error
|
|
578
|
+
error = Error("head failed", error, id, { status: error.status })
|
|
579
579
|
else {
|
|
580
580
|
resp.key = key
|
|
581
581
|
resp = s3resp2doc(resp)
|
|
@@ -602,7 +602,7 @@ closure dawsTable(database, path, tableOptions, local table) {
|
|
|
602
602
|
error = Error("copy failed", {
|
|
603
603
|
source: srckey
|
|
604
604
|
destination: destkey
|
|
605
|
-
status: error
|
|
605
|
+
status: error.status
|
|
606
606
|
}, error)
|
|
607
607
|
callback(error, resp)
|
|
608
608
|
})
|
|
@@ -694,7 +694,7 @@ closure dawsTable(database, path, tableOptions, local table) {
|
|
|
694
694
|
s3prefix = table.s3prefix
|
|
695
695
|
database.bucket.list(s3prefix, !options.deep, function(error, objects, local obj, key) {
|
|
696
696
|
if error
|
|
697
|
-
error = Error("records list failed", error, options.prefix, { status: error
|
|
697
|
+
error = Error("records list failed", error, options.prefix, { status: error.status })
|
|
698
698
|
else {
|
|
699
699
|
for obj in objects.Contents {
|
|
700
700
|
if obj.Key.startsWith(table.s3prefix)
|
package/test/test_02_context.nlg
CHANGED
|
@@ -38,7 +38,7 @@ RegisterTestCategory("context", [
|
|
|
38
38
|
[ "function setNS(ns) { ns=reverse(ns),sudo(nsactive(reverse(ns, defNS))) };", "setNS" ],
|
|
39
39
|
[ "x;", "x" ],
|
|
40
40
|
[ "y;", "y" ],
|
|
41
|
-
[ "length(symlist(nsactive(true).0));", "
|
|
41
|
+
[ "length(symlist(nsactive(true).0));", "171"],
|
|
42
42
|
[ "testvar;", "testvar" ],
|
|
43
43
|
[ "function setTestvar(v) { testvar=v };", "setTestvar" ],
|
|
44
44
|
[ "naanvar;", "naanvar" ],
|
|
@@ -55,7 +55,10 @@ RegisterTestCategory("JSinterop", [
|
|
|
55
55
|
|
|
56
56
|
[ "sqrt = false;", "false" ],
|
|
57
57
|
[ "Math.sqrt(9);", "3" ], // ensure method selector is not evalulated
|
|
58
|
-
|
|
58
|
+
|
|
59
|
+
[ "merge({ a:3, b:4 }, { a:6, c:7, d:8, e:`(x, y, z) }, xnew({ d:77, f:88 }));",
|
|
60
|
+
"{ a: 6, b: 4, c: 7, d: 77, e: (x, y, z), f: 88 }"],
|
|
61
|
+
|
|
59
62
|
[ "xnew(js.g.Promise, function() {});", "[object Promise]" ],
|
|
60
63
|
|
|
61
64
|
|
package/test/test_07_lingo.nlg
CHANGED
|
@@ -108,7 +108,8 @@ RegisterTestCategory("Lingo", [
|
|
|
108
108
|
//
|
|
109
109
|
|
|
110
110
|
[ "false <=> false;", "0" ],
|
|
111
|
-
[ "false <=> true;", "
|
|
111
|
+
[ "false <=> true;", "1" ],
|
|
112
|
+
[ "true <=> false;", "-1" ],
|
|
112
113
|
[ "'a' <=> 'a';", "0" ],
|
|
113
114
|
[ "'a' <=> 'b';", "-1" ],
|
|
114
115
|
[ "'b' <=> 'a';", "1" ],
|