@naanlang/naan 1.0.10 → 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.
@@ -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, remaining, output, error)
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, remaining, output, error)
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(function(item) {
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
- if dvalue.indexOf(".") >= 0
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
- table.rangeKey = compress(output.range) // range attribute name or false
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
- // exstart: <exclusive start key> // for paging
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.exstart
911
- params.ExclusiveStartKey = options.exstart
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
- // exstart: <exclusive start key> // for paging
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.exstart
961
- params.ExclusiveStartKey = options.exstart
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
- debuglog("SQS.sendMessage:", awsSDK, sqs.aws, sqs.aws.sendMessage)
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
@@ -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));", "173"],
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
 
@@ -108,7 +108,8 @@ RegisterTestCategory("Lingo", [
108
108
  //
109
109
 
110
110
  [ "false <=> false;", "0" ],
111
- [ "false <=> true;", "0" ],
111
+ [ "false <=> true;", "1" ],
112
+ [ "true <=> false;", "-1" ],
112
113
  [ "'a' <=> 'a';", "0" ],
113
114
  [ "'a' <=> 'b';", "-1" ],
114
115
  [ "'b' <=> 'a';", "1" ],