@naanlang/naan 1.0.8 → 1.0.10
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/naan.min.js +4 -4
- package/frameworks/browser/browser.nlg +1 -1
- package/frameworks/browser/sworker.js +17 -17
- package/frameworks/browser/terminals.nlg +1 -1
- package/frameworks/browser/workers.nlg +1 -1
- package/frameworks/client/psm_client.nlg +1 -1
- package/frameworks/common/common.nlg +2 -2
- package/frameworks/node/filesystem.nlg +8 -7
- package/frameworks/node/psm_server.nlg +3 -3
- package/frameworks/project/build.nlg +5 -5
- package/frameworks/project/proj_console.nlg +1 -1
- package/frameworks/project/proj_lambda.nlg +1 -1
- package/frameworks/project/projects.nlg +5 -5
- package/frameworks/running/debugnub.nlg +1 -1
- package/frameworks/running/executors.nlg +1 -1
- package/frameworks/running/sourcecode.nlg +2 -2
- package/frameworks/storage/csv.nlg +2 -2
- package/frameworks/storage/dbt_pouch.nlg +1 -1
- package/frameworks/storage/psm.nlg +1 -1
- package/frameworks/storage/psm_dbtables.nlg +4 -4
- package/frameworks/storage/resources.nlg +3 -2
- package/lib/browser/env_web.js +6 -6
- package/lib/core/naanlib.js +4 -4
- package/package.json +1 -1
- package/plugins/serviceAws/aws_dynamo.nlg +12 -12
- package/plugins/serviceAws/dbt_aws.nlg +17 -17
- package/test/harness.nlg +2 -1
- package/test/test_05_strings.nlg +2 -0
- package/test/test_06_lingoparse.nlg +6 -0
- package/test/test_07_lingo.nlg +9 -9
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2021-
|
|
9
|
+
* Copyright (c) 2021-2023 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -88,7 +88,7 @@ closure TimeKeys(prefix, baseMS, local timekeys, prelen) {
|
|
|
88
88
|
// partition key in the specified direction, or false if there are no more keys. Dates in the
|
|
89
89
|
// future are considered invalid and return false.
|
|
90
90
|
//
|
|
91
|
-
timekeys.adjustPartID = function adjustPartID(partID, adjust, local
|
|
91
|
+
timekeys.adjustPartID = function adjustPartID(partID, adjust, local yyyy, doy, dayms, msec) {
|
|
92
92
|
partID = partID.slice(prelen)
|
|
93
93
|
yyyy = toint(partID.substring(0,4))
|
|
94
94
|
doy = toint(partID.substring(4,7))
|
|
@@ -246,7 +246,7 @@ closure DynaConverter(local conv) {
|
|
|
246
246
|
// datumDynToNaan
|
|
247
247
|
// Convert a DynamoDB typed attribute to Naan format.
|
|
248
248
|
//
|
|
249
|
-
conv.datumDynToNaan = function datumDynToNaan(dtype, dvalue
|
|
249
|
+
conv.datumDynToNaan = function datumDynToNaan(dtype, dvalue) {
|
|
250
250
|
if dtype == "BS" || dtype == "SS"
|
|
251
251
|
dvalue
|
|
252
252
|
else if dtype == "NS"
|
|
@@ -305,7 +305,7 @@ closure DynaConverter(local conv) {
|
|
|
305
305
|
// specified parameter block.
|
|
306
306
|
//
|
|
307
307
|
closure genAttributeNameAdder(params, local adex) {
|
|
308
|
-
function attrib(name, local
|
|
308
|
+
function attrib(name, local key, data) {
|
|
309
309
|
if !string(name)
|
|
310
310
|
name = tostring(name) // try to make it a string
|
|
311
311
|
if !params.ExpressionAttributeNames
|
|
@@ -377,7 +377,7 @@ closure DynaConverter(local conv) {
|
|
|
377
377
|
//
|
|
378
378
|
|
|
379
379
|
conv.createKeyExpression = function createKeyExpression(params, conds
|
|
380
|
-
local
|
|
380
|
+
local attval, rangename, range, keyname, op, expr, rangex, arg1, arg2) {
|
|
381
381
|
|
|
382
382
|
// dupeop
|
|
383
383
|
//
|
|
@@ -535,7 +535,7 @@ closure DynaTable(dyna, tablename, local table) {
|
|
|
535
535
|
// rangeType: <name> // string | numeric (if exists)
|
|
536
536
|
// }
|
|
537
537
|
//
|
|
538
|
-
table.info = closure info(local params, pending
|
|
538
|
+
table.info = closure info(local params, pending) {
|
|
539
539
|
if !dyna.aws
|
|
540
540
|
return (list(Error("DynaTable.info: not logged into AWS")))
|
|
541
541
|
params = {
|
|
@@ -691,7 +691,7 @@ closure DynaTable(dyna, tablename, local table) {
|
|
|
691
691
|
}
|
|
692
692
|
params.Key = makeDynKey(list(hashValue, rangeValue))
|
|
693
693
|
pending = new(nonce)
|
|
694
|
-
dyna.aws.getItem(params, function(error, data
|
|
694
|
+
dyna.aws.getItem(params, function(error, data) {
|
|
695
695
|
if error {
|
|
696
696
|
dynaTableError = error
|
|
697
697
|
debuglog("aws.getItem failed", tablename, ErrorString(error))
|
|
@@ -716,7 +716,7 @@ closure DynaTable(dyna, tablename, local table) {
|
|
|
716
716
|
Item: dyna.conv.recordNaanToDyn(record)
|
|
717
717
|
}
|
|
718
718
|
pending = new(nonce)
|
|
719
|
-
dyna.aws.putItem(params, function(error, data
|
|
719
|
+
dyna.aws.putItem(params, function(error, data) {
|
|
720
720
|
if error {
|
|
721
721
|
dynaTableError = error
|
|
722
722
|
debuglog("aws.putItem failed", tablename, ErrorString(error))
|
|
@@ -745,7 +745,7 @@ closure DynaTable(dyna, tablename, local table) {
|
|
|
745
745
|
// The result is a standard result tuple `(error, record).
|
|
746
746
|
|
|
747
747
|
table.updateRecord = closure updateRecord(hashValue, rangeValue, options,
|
|
748
|
-
local error, params,
|
|
748
|
+
local error, params, pending) {
|
|
749
749
|
if preflightError(this)
|
|
750
750
|
return
|
|
751
751
|
params = {
|
|
@@ -817,7 +817,7 @@ closure DynaTable(dyna, tablename, local table) {
|
|
|
817
817
|
params.ReturnValues = "NONE"
|
|
818
818
|
}
|
|
819
819
|
pending = new(nonce)
|
|
820
|
-
dyna.aws.deleteItem(params, function(error, data
|
|
820
|
+
dyna.aws.deleteItem(params, function(error, data) {
|
|
821
821
|
if error {
|
|
822
822
|
dynaTableError = error
|
|
823
823
|
debuglog("aws.deleteItem failed", tablename, ErrorString(error))
|
|
@@ -868,7 +868,7 @@ closure DynaTable(dyna, tablename, local table) {
|
|
|
868
868
|
//
|
|
869
869
|
|
|
870
870
|
table.queryRecords = closure queryRecords(hashValue, options
|
|
871
|
-
local error, params, hashKey,
|
|
871
|
+
local error, params, hashKey, output)
|
|
872
872
|
{
|
|
873
873
|
if preflightError(this)
|
|
874
874
|
return
|
|
@@ -937,7 +937,7 @@ closure DynaTable(dyna, tablename, local table) {
|
|
|
937
937
|
//
|
|
938
938
|
|
|
939
939
|
table.scanRecords = closure scanRecords(options
|
|
940
|
-
local params,
|
|
940
|
+
local params, output, error)
|
|
941
941
|
{
|
|
942
942
|
if preflightError(this)
|
|
943
943
|
return
|
|
@@ -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)
|
|
@@ -365,7 +365,7 @@ closure dawsTable(database, path, tableOptions, local table) {
|
|
|
365
365
|
//
|
|
366
366
|
// Convert an S3 get response to a new table document.
|
|
367
367
|
|
|
368
|
-
function s3resp2doc(resp, local doc
|
|
368
|
+
function s3resp2doc(resp, local doc) {
|
|
369
369
|
if resp.Metadata.naandbt
|
|
370
370
|
try {
|
|
371
371
|
doc = new(JSONparse(resp.Metadata.naandbt))
|
|
@@ -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)
|
|
@@ -787,7 +787,7 @@ closure S3DB(s3b, local database, result) {
|
|
|
787
787
|
//
|
|
788
788
|
// Delete the database and close it.
|
|
789
789
|
|
|
790
|
-
database.destroy = function destroy(
|
|
790
|
+
database.destroy = function destroy() {
|
|
791
791
|
if !database.bucket
|
|
792
792
|
return (list(Error("database closed")))
|
|
793
793
|
list(Error("not sure how to destroy this database")) // ### delete the base object?
|
package/test/harness.nlg
CHANGED
|
@@ -28,7 +28,8 @@ Naan.module.chns("Play");;
|
|
|
28
28
|
*
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
closure Parsenv(name, local penv, gohome,
|
|
31
|
+
closure Parsenv(name, local penv, gohome, lingo, naansym) {
|
|
32
|
+
global()
|
|
32
33
|
penv = new(object, this)
|
|
33
34
|
gohome = makeActivator()
|
|
34
35
|
sleep(1)
|
package/test/test_05_strings.nlg
CHANGED
|
@@ -524,6 +524,12 @@ RegisterTestCategory("Lingo parse", [
|
|
|
524
524
|
{ errors: "undeclared global at (1, 26) found c" } ],
|
|
525
525
|
[ "function(a) { global(b), c * a };",
|
|
526
526
|
{ errors: "undeclared global at (1, 26) found c" } ],
|
|
527
|
+
[ "closure nest() { function t() { function t() { 3 } } };", "nest"],
|
|
528
|
+
[ "function errch1() { global(), while:seeking true { loop { break:seeking } } };", "errch1" ],
|
|
529
|
+
[ "closure errch2() { global(), function a() { b.proc }, function b() { a } };", "errch2" ],
|
|
530
|
+
[ "function errch3(local a) { f.g(function() { a = 3 }) };", "errch3" ],
|
|
531
|
+
[ "function errch4(local a) { try {} catch { if true { a=3 } } };", "errch4" ],
|
|
532
|
+
[ "function errch5() { function&(local a) { } };", "errch5"]
|
|
527
533
|
]);
|
|
528
534
|
|
|
529
535
|
|
package/test/test_07_lingo.nlg
CHANGED
|
@@ -301,14 +301,14 @@ RegisterTestCategory("Lingo", [
|
|
|
301
301
|
"function() {"
|
|
302
302
|
" loop {"
|
|
303
303
|
" if 1 {"
|
|
304
|
-
"
|
|
304
|
+
" f(), if false"
|
|
305
305
|
" break"
|
|
306
|
-
" }, 3, break } });>", "(function lambda false (loop false (((identity 1)
|
|
306
|
+
" }, 3, break } });>", "(function lambda false (loop false (((identity 1) (f) ((identity false) (break)))) 3 (break)))" ],
|
|
307
307
|
|
|
308
|
-
[ "quote(function(){if 1 {
|
|
308
|
+
[ "quote(function(){if 1 { f(), if 3 { if 4 5 } else 6 } else 7 });",
|
|
309
309
|
"function () {\n"
|
|
310
310
|
" if 1 {\n"
|
|
311
|
-
"
|
|
311
|
+
" (f)\n"
|
|
312
312
|
" if 3 {\n"
|
|
313
313
|
" if 4\n"
|
|
314
314
|
" 5 }\n"
|
|
@@ -387,7 +387,7 @@ RegisterTestCategory("Lingo", [
|
|
|
387
387
|
[ "for x in `(a b c) print(x);>", "abc|Dictionary{8}" ],
|
|
388
388
|
[ "function() { loop { if x > 3 break, 4 } };>", "(function lambda false (loop false ((> x 3)) 4))" ],
|
|
389
389
|
[ "function () { for xx in [a,b,c] { if true { if xx eq 3, break }, print(xx) } }();>", "abc|Dictionary{7}" ],
|
|
390
|
-
[ "function (x) { loop try {
|
|
390
|
+
[ "function (x) { loop try { f(), if x continue, 2, break } catch { 3 } }();", "2" ],
|
|
391
391
|
|
|
392
392
|
[ "miter=iterate(`(a,b,c), `x);", "{\n"
|
|
393
393
|
" target : (a, b, c),\n"
|
|
@@ -455,11 +455,11 @@ RegisterTestCategory("Lingo", [
|
|
|
455
455
|
[ "function(){function jim(){ print(\"1\"),function jim(){print(\"2\")}, jim()}, jim()}();", "12|\"2\"" ],
|
|
456
456
|
[ "closure(){function jim(){ print(\"1\"),function jim(){print(\"2\")}, jim()}, jim()}();", "12|\"2\"" ],
|
|
457
457
|
[ "function(){function jim(){print(\"1\")},function jim(){print(\"2\")}, jim()}();",
|
|
458
|
-
{ errors: "
|
|
458
|
+
{ errors: "duplicate procedure name at (1, 48) found jim" } ],
|
|
459
459
|
[ "closure(){function jim(){print(\"1\")},function jim(){print(\"2\")}, jim()}();",
|
|
460
|
-
{ errors: "
|
|
460
|
+
{ errors: "duplicate procedure name at (1, 47) found jim" } ],
|
|
461
461
|
[ "function(){function jim(){print(\"1\")}(),function jim(){print(\"2\")}, jim()}();",
|
|
462
|
-
{ errors: "
|
|
462
|
+
{ errors: "duplicate procedure name at (1, 50) found jim" } ],
|
|
463
463
|
|
|
464
464
|
[ "function(){{spawn:function(){[{ok:true}]}}};", "function () {\n"
|
|
465
465
|
" {\n"
|
|
@@ -482,7 +482,7 @@ RegisterTestCategory("Lingo", [
|
|
|
482
482
|
[ "function eee(f) { print(f), function iii(f) { print(f), ccc() }(7) } (4);", "47|f" ],
|
|
483
483
|
[ "function fff(f) { print(f), function& iii(f) { print(f), ccc() }(9) } (6);", "69|f" ],
|
|
484
484
|
|
|
485
|
-
[ "function (f
|
|
485
|
+
[ "function (f) { print(f), function jjj(f) { print(f), ccc() }, jjj(21) } (22);", "2221|f" ],
|
|
486
486
|
[ "function& (f, local jjj) { print(f), function jjj(f) { print(f), ccc() }, jjj(23) } (24);", "2423|24" ],
|
|
487
487
|
|
|
488
488
|
[ "function (g, local f) { f = 17, function f(g) { print(f, g), ccc() }, f(25) } (26);", "1725|f" ],
|