@naanlang/naan 1.0.0

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 (98) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +46 -0
  3. package/dist/env_web.js +431 -0
  4. package/dist/naan.min.js +73 -0
  5. package/frameworks/browser/browser.nlg +30 -0
  6. package/frameworks/browser/pouchdb/pouchdb.min.js +7 -0
  7. package/frameworks/browser/spark-md5/spark-md5.min.js +1 -0
  8. package/frameworks/browser/sworker.js +192 -0
  9. package/frameworks/browser/terminals.nlg +787 -0
  10. package/frameworks/browser/workers.nlg +386 -0
  11. package/frameworks/client/apiclient.nlg +183 -0
  12. package/frameworks/client/client.nlg +29 -0
  13. package/frameworks/client/psm_client.nlg +572 -0
  14. package/frameworks/common/common.nlg +464 -0
  15. package/frameworks/common/preferences.nlg +131 -0
  16. package/frameworks/common/repltools.nlg +100 -0
  17. package/frameworks/common/watching.nlg +97 -0
  18. package/frameworks/node/apiserver.nlg +399 -0
  19. package/frameworks/node/filesystem.nlg +1012 -0
  20. package/frameworks/node/gitter.nlg +234 -0
  21. package/frameworks/node/node.nlg +81 -0
  22. package/frameworks/node/psm_server.nlg +465 -0
  23. package/frameworks/node/worker.nlg +560 -0
  24. package/frameworks/project/build.nlg +1229 -0
  25. package/frameworks/project/jszip.js +30 -0
  26. package/frameworks/project/jszip.nlg +87 -0
  27. package/frameworks/project/proj_cliser.nlg +139 -0
  28. package/frameworks/project/proj_console.nlg +137 -0
  29. package/frameworks/project/proj_folder.nlg +143 -0
  30. package/frameworks/project/proj_lambda.nlg +137 -0
  31. package/frameworks/project/proj_static.nlg +138 -0
  32. package/frameworks/project/project.nlg +29 -0
  33. package/frameworks/project/projects.nlg +587 -0
  34. package/frameworks/project/uglifyjs.js +1 -0
  35. package/frameworks/project/uglifyjs.nlg +79 -0
  36. package/frameworks/running/debugcom.nlg +163 -0
  37. package/frameworks/running/debugnub.nlg +565 -0
  38. package/frameworks/running/debugutil.nlg +510 -0
  39. package/frameworks/running/executors.nlg +767 -0
  40. package/frameworks/running/running.nlg +151 -0
  41. package/frameworks/running/sourcecode.nlg +346 -0
  42. package/frameworks/running/taskexec.nlg +196 -0
  43. package/frameworks/storage/dbt_pouch.nlg +773 -0
  44. package/frameworks/storage/file_manager.nlg +772 -0
  45. package/frameworks/storage/psm.nlg +326 -0
  46. package/frameworks/storage/psm_dbtables.nlg +814 -0
  47. package/frameworks/storage/resources.nlg +445 -0
  48. package/frameworks/storage/storage.nlg +52 -0
  49. package/lib/browser/env_web.js +431 -0
  50. package/lib/browser/env_webworker.js +146 -0
  51. package/lib/browser/require.js +1653 -0
  52. package/lib/core/naanlib.js +73 -0
  53. package/lib/env_node.js +282 -0
  54. package/lib/env_nodeworker.js +165 -0
  55. package/lib/node_repl.js +25 -0
  56. package/lib/node_repl_init.nlg +52 -0
  57. package/package.json +13 -0
  58. package/plugins/gitClient/clientops.nlg +317 -0
  59. package/plugins/gitClient/gitClient.nlg +63 -0
  60. package/plugins/gitClient/gitutils.nlg +1331 -0
  61. package/plugins/gitClient/minimatch.js +945 -0
  62. package/plugins/gitClient/minimatch_license.txt +15 -0
  63. package/plugins/gitClient/minimatch_readme.md +208 -0
  64. package/plugins/nodeLib/nodeLib.nlg +26 -0
  65. package/plugins/nodeLib/node_cp.nlg +65 -0
  66. package/plugins/nodeLib/node_fs.nlg +137 -0
  67. package/plugins/nodeLib/node_https.nlg +172 -0
  68. package/plugins/nodeLib/node_util.nlg +180 -0
  69. package/plugins/serviceAws/aws/aws-sdk.min.js +88 -0
  70. package/plugins/serviceAws/aws/lambda_rest_index.js +122 -0
  71. package/plugins/serviceAws/aws/lambda_rest_init.nlg +58 -0
  72. package/plugins/serviceAws/aws/lambda_ws_index.js +498 -0
  73. package/plugins/serviceAws/aws/lambda_ws_init.nlg +49 -0
  74. package/plugins/serviceAws/aws_cloudwatchlogs.nlg +122 -0
  75. package/plugins/serviceAws/aws_cognito.nlg +76 -0
  76. package/plugins/serviceAws/aws_dynamo.nlg +509 -0
  77. package/plugins/serviceAws/aws_lambda.nlg +95 -0
  78. package/plugins/serviceAws/aws_s3.nlg +134 -0
  79. package/plugins/serviceAws/aws_utils.nlg +86 -0
  80. package/plugins/serviceAws/dbt_aws.nlg +769 -0
  81. package/plugins/serviceAws/lambda_naan_control.nlg +175 -0
  82. package/plugins/serviceAws/psm_aws.nlg +258 -0
  83. package/plugins/serviceAws/serviceAws.nlg +38 -0
  84. package/plugins/serviceGitHub/gitops.nlg +522 -0
  85. package/plugins/serviceGitHub/psm_github.nlg +205 -0
  86. package/plugins/serviceGitHub/serviceGitHub.nlg +65 -0
  87. package/plugins/serviceGitLab/gitops.nlg +528 -0
  88. package/plugins/serviceGitLab/psm_gitlab.nlg +205 -0
  89. package/plugins/serviceGitLab/serviceGitLab.nlg +65 -0
  90. package/test/harness.nlg +312 -0
  91. package/test/node_test.js +33 -0
  92. package/test/test_01_core.nlg +768 -0
  93. package/test/test_02_context.nlg +269 -0
  94. package/test/test_03_jsinterop.nlg +137 -0
  95. package/test/test_04_numerics.nlg +450 -0
  96. package/test/test_05_strings.nlg +63 -0
  97. package/test/test_06_lingoparse.nlg +500 -0
  98. package/test/test_07_lingo.nlg +623 -0
@@ -0,0 +1,180 @@
1
+ /*
2
+ * node_util.nlg
3
+ *
4
+ * Generic node utility functions for the NodeJS environment.
5
+ *
6
+ * column positioning: // // !
7
+ *
8
+ * Copyright (c) 2021-2022 by Richard C. Zulch
9
+ *
10
+ */
11
+
12
+
13
+ /*
14
+ * MultipartBody
15
+ *
16
+ * column positioning: // // !
17
+ * Create a multipart Form body from the specified dictionary, returning a buffer. Any xobject in
18
+ * the dictionary is coded as an octet. If you want a different filename, include an options object
19
+ * that defines that filename.
20
+ *
21
+ *The result is a dictionary as follows:
22
+ * {
23
+ * body: <Buffer>
24
+ * header: {
25
+ * Content-Type: "multipart/form-data; boundary=<boundary>"
26
+ * }
27
+ * }
28
+ *
29
+ *
30
+ */
31
+
32
+ function MultipartBody(dict, options, local boundary, parts, key, data, filename) {
33
+ boundary = "xx-xx-xx-xx-xx"
34
+ parts = []
35
+ for `(key, data) in dict {
36
+ if xobject(data) {
37
+ if options[key]
38
+ filename = options[key]
39
+ else
40
+ filename = key
41
+ parts.push(xnew(js.g.Buffer.from, "--".concat(boundary, "\r\n",
42
+ "Content-Disposition: form-data; name=\"", key, "\"; filename=\"", filename, "\"\r\n",
43
+ "Content-Type:application/octet-stream\r\n\r\n"), "utf8"))
44
+ parts.push(xnew(js.g.Buffer.from, data, "binary"))
45
+ parts.push(xnew(js.g.Buffer.from, "\r\n", "utf8"))
46
+ }
47
+ else {
48
+ parts.push(xnew(js.g.Buffer.from, "--".concat(boundary, "\r\n",
49
+ "Content-Disposition: form-data; name=\"", key,
50
+ "\"; \r\n\r\n", data, "\r\n"), "utf8"))
51
+ }
52
+ }
53
+ parts.push(xnew(js.g.Buffer.from, "--".concat(boundary, "--\r\n"), "utf8"))
54
+ data = js.g.Buffer.concat(parts)
55
+ {
56
+ body: data
57
+ headers: {
58
+ "Content-Type": "multipart/form-data; boundary=".concat(boundary)
59
+ "Content-Length": data.length
60
+ }
61
+ }
62
+ };
63
+
64
+
65
+ /*
66
+ * EncodeQuery
67
+ *
68
+ * Encode a dictionary of query terms into a query string for a URI.
69
+ *
70
+ */
71
+
72
+ function EncodeQuery(prefix, items, local result, item) {
73
+ result = []
74
+ for item in items
75
+ result.push(js.g.encodeURIComponent(item).concat("=", js.g.encodeURIComponent(items[item])))
76
+ result = result.join("&")
77
+ if prefix && result.length > 0
78
+ prefix.concat(result)
79
+ else
80
+ result
81
+ };
82
+
83
+
84
+ /*
85
+ * JsonParse
86
+ *
87
+ * Parse a string as JSON, returning a result tuple instead of an exception.
88
+ *
89
+ */
90
+
91
+ function JsonParse(data) {
92
+ try {
93
+ data = js.g.JSON.parse(data)
94
+ list(false, data)
95
+ } catch {
96
+ if true
97
+ list(exception)
98
+ }
99
+ };
100
+
101
+
102
+ /*
103
+ * JsonStringify
104
+ *
105
+ * Convert an object to a JSON string, returning a result tuple instead of an exception.
106
+ *
107
+ */
108
+
109
+ function JsonStringify(data) {
110
+ try {
111
+ data = js.g.JSON.stringify(data)
112
+ list(false, data)
113
+ } catch {
114
+ if true
115
+ list(exception)
116
+ }
117
+ };
118
+
119
+
120
+ /*
121
+ * RandomBytes
122
+ *
123
+ * Return the specified number of random bytes.
124
+ *
125
+ */
126
+
127
+ function RandomBytes(bytes) {
128
+ if !xobject(crypto)
129
+ crypto = js.r("crypto")
130
+ crypto.randomBytes(bytes)
131
+ };
132
+
133
+
134
+ /*
135
+ * UUID
136
+ *
137
+ * Return a new v4 variant 1 UUID, which is the random variety. It will be a 36-character string.
138
+ *
139
+ */
140
+
141
+ function UUID(local rando, cc) {
142
+ rando = RandomBytes(36) // length of UUID
143
+ "00000000-0000-4000-8000-000000000000".replace(RegExp("[018]", "g"), function(cc, offset) {
144
+ if cc == "4"
145
+ cc = 4
146
+ else if cc == "8"
147
+ cc = bitor(8, bitand(rando[offset], 3))
148
+ else
149
+ cc = bitand(rando[offset], 15)
150
+ "0123456789abcdef".charAt(cc)
151
+ })
152
+ };
153
+
154
+
155
+ /*
156
+ * nodeUtilInit
157
+ *
158
+ * Initialize NodeJS utilities.
159
+ *
160
+ */
161
+
162
+ function nodeUtilInit(local manifest) {
163
+ manifest = `(MultipartBody, EncodeQuery, JsonParse, JsonStringify, RandomBytes, UUID, nodeUtilInit)
164
+
165
+ Naan.module.build(module.id, "node_util", function(modobj, compobj) {
166
+ require("nodeLib.nlg")
167
+ compobj.manifest = manifest
168
+ modobj.exports.JsonParse = JsonParse
169
+ modobj.exports.JsonStringify = JsonStringify
170
+ modobj.exports.UUID = UUID
171
+ function postload() {
172
+ nodeFs = js.r("fs")
173
+ nodePath = js.r("path")
174
+ nodeHttps = js.r("https")
175
+ nodeStream = js.r("stream")
176
+ nodeCp = js.r("child_process")
177
+ }()
178
+ module.postload = postload
179
+ })
180
+ }();