@naanlang/naan 1.4.0 → 1.4.2

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.
Files changed (42) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +10 -10
  3. package/bin/index.js +25 -15
  4. package/dist/env_web.js +68 -73
  5. package/dist/naan.min.js +5 -5
  6. package/frameworks/browser/sworker.js +23 -23
  7. package/frameworks/browser/terminals.nlg +52 -3
  8. package/frameworks/client/psm_client.nlg +2 -0
  9. package/frameworks/client/relaycon.nlg +1 -1
  10. package/frameworks/common/common.nlg +10 -54
  11. package/frameworks/node/filesystem.nlg +5 -4
  12. package/frameworks/node/psm_server.nlg +1 -1
  13. package/frameworks/node/shell.nlg +134 -0
  14. package/frameworks/node/worker.nlg +1 -1
  15. package/frameworks/project/build.nlg +19 -5
  16. package/frameworks/project/projects.nlg +12 -1
  17. package/frameworks/running/debugnub.nlg +102 -12
  18. package/frameworks/running/debugutil.nlg +30 -13
  19. package/frameworks/running/executors.nlg +7 -3
  20. package/frameworks/running/running.nlg +26 -6
  21. package/frameworks/running/sourcecode.nlg +3 -1
  22. package/frameworks/running/taskexec.nlg +1 -1
  23. package/frameworks/storage/dbt_pouch.nlg +37 -19
  24. package/frameworks/storage/file_manager.nlg +1 -1
  25. package/frameworks/storage/psm_dbtables.nlg +23 -24
  26. package/frameworks/storage/resources.nlg +12 -4
  27. package/frameworks/storage/storage.nlg +2 -2
  28. package/lib/browser/env_web.js +73 -78
  29. package/lib/core/naanlib.js +5 -5
  30. package/package.json +1 -1
  31. package/plugins/gitClient/gitClient.nlg +3 -3
  32. package/plugins/openSearch/openSearch.nlg +2 -2
  33. package/plugins/serviceAws/aws_s3.nlg +17 -1
  34. package/plugins/serviceAws/psm_aws.nlg +4 -2
  35. package/plugins/serviceAws/serviceAws.nlg +1 -1
  36. package/plugins/serviceGC/gc_api.nlg +4 -4
  37. package/plugins/serviceGitHub/serviceGitHub.nlg +1 -1
  38. package/plugins/serviceGitLab/psm_gitlab.nlg +1 -1
  39. package/plugins/serviceGitLab/serviceGitLab.nlg +1 -1
  40. package/test/harness.nlg +9 -9
  41. package/test/test_01_core.nlg +24 -2
  42. package/test/test_02_context.nlg +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naanlang/naan",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "author": "Richard C. Zulch",
5
5
  "description": "Naan™ software platform",
6
6
  "main": "./lib/core/naanlib.js",
@@ -54,9 +54,9 @@ function gitcInit(local manifest) {
54
54
  })
55
55
  nideCommon = require("nideCommon/nideCommon.nlg")
56
56
  letimport(nideCommon)
57
- require("plugins/gitClient/clientops.nlg")
58
- require("plugins/gitClient/gitutils.nlg")
59
- gitcRequireJS("plugins/gitClient/minimatch.js", function(error, result) {
57
+ require("./clientops.nlg")
58
+ require("./gitutils.nlg")
59
+ gitcRequireJS("./minimatch.js", function(error, result) {
60
60
  if error
61
61
  ErrorDebugLog(error)
62
62
  })
@@ -567,8 +567,8 @@ function opseInit(local manifest) {
567
567
 
568
568
  Naan.module.build(module.id, "openSearch", function(modobj, compobj) {
569
569
  compobj.manifest = manifest
570
- require("frameworks/common").LiveImport()
571
- letimport(require("frameworks/node/https_request.nlg"))
570
+ require("naanlib:frameworks/common").LiveImport()
571
+ letimport(require("naanlib:frameworks/node/https_request.nlg"))
572
572
  modobj.exports.OpenSearchClient = OpenSearchClient
573
573
  })
574
574
  } ();
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * column positioning: // // !
8
8
  *
9
- * Copyright (c) 2020-2023 by Richard C. Zulch
9
+ * Copyright (c) 2020-2024 by Richard C. Zulch
10
10
  *
11
11
  */
12
12
 
@@ -41,6 +41,22 @@ closure S3bucket(s3, name, bucketOptions, local bucket) {
41
41
  pending.wait()
42
42
  }
43
43
 
44
+ //
45
+ // get
46
+ //
47
+ bucket.get = closure get(key, local pending) {
48
+ pending = new(nonce)
49
+ s3.aws.getObject({
50
+ Bucket: bucket.name
51
+ Key: key
52
+ }, function (error, data) {
53
+ if error
54
+ error = Error("S3bucket.get failed:", error.name, "key:", key, "in", bucket.name)
55
+ pending.signal(list(error, data))
56
+ })
57
+ pending.wait()
58
+ }
59
+
44
60
  //
45
61
  // listObjects
46
62
  //
@@ -252,6 +252,8 @@ closure psmaConnector(psm, local connClassID, connector, watch) {
252
252
 
253
253
  connector.connect = function connect(resID, service, args,
254
254
  local error, s3b, db, rootpath, table) {
255
+ if !resID || args && !tuple(args)
256
+ return (list(Error("invalid arguments")))
255
257
  `(error, s3b) = connector.access(resID)
256
258
  if !error
257
259
  `(error, db) = S3DB(s3b, args.1) // get S3 bucket as a database
@@ -262,12 +264,12 @@ closure psmaConnector(psm, local connClassID, connector, watch) {
262
264
  else if service == "NideFS" {
263
265
  rootpath = args.0 // connect to a NideFS filesystem
264
266
  if !rootpath
265
- return (Error("mandatory rootpath missing"))
267
+ return (list(Error("mandatory rootpath missing")))
266
268
  `(error, table) = db.table(rootpath, args.1) // args.1 is table options; see dawsTable
267
269
  if error
268
270
  list(error)
269
271
  else
270
- require("frameworks/storage/psm_dbtables.nlg").FSview(table, rootpath)
272
+ require("naanlib:frameworks/storage/psm_dbtables.nlg").FSview(table, rootpath)
271
273
  } else
272
274
  list(Error("unsupported service", service))
273
275
  }
@@ -23,7 +23,7 @@ function sawsInit(local manifest) {
23
23
 
24
24
  Naan.module.build(module.id, "serviceAws", function(modobj, compobj) {
25
25
  compobj.manifest = manifest
26
- require("frameworks/common").LiveImport()
26
+ require("naanlib:frameworks/common").LiveImport()
27
27
  require("./aws_utils.nlg")
28
28
  function sawsPostload() {
29
29
  if js.g
@@ -74,7 +74,7 @@ closure GcApi(options, local gcapi, cacert, renew, access_token, expires_at) {
74
74
  //
75
75
  // Make an HTTPS request on the API, renewing the access token first if needed.
76
76
  //
77
- closure request(url, put, local error, data, status) {
77
+ closure request(url, put, sseHook, local error, data, status) {
78
78
  if !(milliseconds() < expires_at - 60000) {
79
79
  `(error, data) = auth(renew)
80
80
  if error
@@ -87,7 +87,7 @@ closure GcApi(options, local gcapi, cacert, renew, access_token, expires_at) {
87
87
  `(Accept, "application/json"),
88
88
  list(`Authorization, "Bearer ".concat(access_token))
89
89
  ]
90
- sseHook: options.sseHook || undefined
90
+ sseHook: sseHook || options.sseHook || undefined
91
91
  })
92
92
  if error
93
93
  list(error)
@@ -172,13 +172,13 @@ closure GcApi(options, local gcapi, cacert, renew, access_token, expires_at) {
172
172
  // object: <string>
173
173
  // }
174
174
  //
175
- gcapi.chatCompletion = closure chatCompletion(query) {
175
+ gcapi.chatCompletion = closure chatCompletion(query, sseHook) {
176
176
  if options.preview {
177
177
  query = new(query)
178
178
  if !query.model.endsWith("-preview")
179
179
  query.model = query.model.concat("-preview")
180
180
  }
181
- request(gcapi.urlbase.concat("chat/completions"), query)
181
+ request(gcapi.urlbase.concat("chat/completions"), query, sseHook)
182
182
  }
183
183
 
184
184
  // uploadFile
@@ -60,6 +60,6 @@ function ghubInit(local manifest) {
60
60
  Naan.module.build(module.id, "serviceGitHub", function(modobj, compobj) {
61
61
  compobj.manifest = manifest
62
62
  })
63
- require("frameworks/common", { in: naanlib }).LiveImport()
63
+ require("naanlib:frameworks/common").LiveImport()
64
64
  require("./psm_github.nlg").GitHubConnector(App.psm)
65
65
  } ();
@@ -20,7 +20,7 @@
20
20
 
21
21
  closure plabConnector(psm, local connClassID, connector, watch) {
22
22
  connClassID = "GLAB"
23
- require("plugins/serviceGitLab/gitops.nlg")
23
+ require("./gitops.nlg")
24
24
  connector = new(object, this)
25
25
  connector.psm = psm
26
26
  connector.vault = psm.vault(connClassID)
@@ -60,6 +60,6 @@ function glabInit(local manifest) {
60
60
  Naan.module.build(module.id, "serviceGitLab", function(modobj, compobj) {
61
61
  compobj.manifest = manifest
62
62
  })
63
- require("frameworks/common", { in: naanlib }).LiveImport()
63
+ require("naanlib:frameworks/common").LiveImport()
64
64
  require("./psm_gitlab.nlg").GitLabConnector(App.psm)
65
65
  } ();
package/test/harness.nlg CHANGED
@@ -83,15 +83,15 @@ closure Parsenv(name, local penv, gohome, lingo, naansym) {
83
83
  `(errors, expr) = lingo.parse(source)
84
84
  for error in errors
85
85
  output.errors.push(penv.lib.ParseErrorString(error))
86
- if expr {
87
- output.exprs.push(expr)
88
- expr = function() { evalactive(expr) }() // return here if return executed outside procedure
89
- output.results.push(expr)
90
- if source.tokenlast().atom == `;>
91
- output.pretty.push(tostring(expr, { quote: true }))
92
- else if source.tokenlast().atom != `;;
93
- output.pretty.push(lingo.print(expr))
94
- }
86
+ output.exprs.push(expr)
87
+ expr = function() { evalactive(expr) }() // return here if return executed outside procedure
88
+ output.results.push(expr)
89
+ if expr === Naan.local.mu
90
+ { }
91
+ else if source.tokenlast().atom == `;>
92
+ output.pretty.push(tostring(expr, { quote: true }))
93
+ else if source.tokenlast().atom != `;;
94
+ output.pretty.push(lingo.print(expr))
95
95
  } finally {
96
96
  sudo(putproc(`exception, savex)) }
97
97
  }
@@ -23,7 +23,7 @@ RegisterTestCategory("core", [
23
23
  // booleans and/or undefined
24
24
  //
25
25
 
26
- [ "false;", "" ],
26
+ [ "false;", "false" ],
27
27
  [ "true;", "true" ],
28
28
  [ "not true;", "false" ],
29
29
  [ "not false;", "true" ],
@@ -61,9 +61,16 @@ RegisterTestCategory("core", [
61
61
  [ "lambda(unintern(\"lambda\"));", "true" ],
62
62
 
63
63
  [ "car(`;);", ";" ],
64
+
65
+ [ "null;", "null" ],
66
+ [ "null();", "(null)" ],
67
+ [ "mu;", "mu" ],
68
+ [ "mu();", "" ],
69
+ [ "mu.tostring;", '"mu"' ],
70
+ [ "mu().tostring;", '"mu"' ],
64
71
 
65
72
  //
66
- // basic lists and dotted pairs
73
+ // basic tuples and dotted pairs
67
74
  //
68
75
 
69
76
  [ "`();>", "false" ],
@@ -82,6 +89,21 @@ RegisterTestCategory("core", [
82
89
  [ "`((a . b) . (c d));>", "((a . b) c d)" ],
83
90
  [ "`((a b) . (c . d));>", "((a b) c . d)" ],
84
91
 
92
+ //
93
+ // tuple manipulation
94
+ //
95
+
96
+ [ "append(`(a,b,c), d, `(e,f));>", "(a b c d e f)" ],
97
+ [ "append(`(3), `((4)));>", "(3 (4))" ],
98
+ [ "append(`(3), 5);>", "(3 5)" ],
99
+ [ "append(3, 4, 5);>", "(3 4 5)" ],
100
+
101
+ [ "subatq(list(a,3), list(a, 4));", "list(4, 3)" ],
102
+ [ "subatq(list(a,3), [list(a, 4)]);", "list(4, 3)" ],
103
+ [ "subatq(function joe(x) { 4*x }, [list(joe, bob), list(x,y)]);>",
104
+ "(Lib::defproc function bob (y) (* 4 y))" ],
105
+ [ "subat(list(a, { b: c }, [d, e]), [list(a,1), list(b,2), list(c,3), list(e,d), list(d,e)]);",
106
+ "(1, { 2: 3 }, [e, d])" ],
85
107
 
86
108
  //
87
109
  // assignment
@@ -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));", "171"],
41
+ [ "length(symlist(nsactive(true).0));", "173"],
42
42
  [ "testvar;", "testvar" ],
43
43
  [ "function setTestvar(v) { testvar=v };", "setTestvar" ],
44
44
  [ "naanvar;", "naanvar" ],