@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.
- package/LICENSE.md +21 -0
- package/README.md +46 -0
- package/dist/env_web.js +431 -0
- package/dist/naan.min.js +73 -0
- package/frameworks/browser/browser.nlg +30 -0
- package/frameworks/browser/pouchdb/pouchdb.min.js +7 -0
- package/frameworks/browser/spark-md5/spark-md5.min.js +1 -0
- package/frameworks/browser/sworker.js +192 -0
- package/frameworks/browser/terminals.nlg +787 -0
- package/frameworks/browser/workers.nlg +386 -0
- package/frameworks/client/apiclient.nlg +183 -0
- package/frameworks/client/client.nlg +29 -0
- package/frameworks/client/psm_client.nlg +572 -0
- package/frameworks/common/common.nlg +464 -0
- package/frameworks/common/preferences.nlg +131 -0
- package/frameworks/common/repltools.nlg +100 -0
- package/frameworks/common/watching.nlg +97 -0
- package/frameworks/node/apiserver.nlg +399 -0
- package/frameworks/node/filesystem.nlg +1012 -0
- package/frameworks/node/gitter.nlg +234 -0
- package/frameworks/node/node.nlg +81 -0
- package/frameworks/node/psm_server.nlg +465 -0
- package/frameworks/node/worker.nlg +560 -0
- package/frameworks/project/build.nlg +1229 -0
- package/frameworks/project/jszip.js +30 -0
- package/frameworks/project/jszip.nlg +87 -0
- package/frameworks/project/proj_cliser.nlg +139 -0
- package/frameworks/project/proj_console.nlg +137 -0
- package/frameworks/project/proj_folder.nlg +143 -0
- package/frameworks/project/proj_lambda.nlg +137 -0
- package/frameworks/project/proj_static.nlg +138 -0
- package/frameworks/project/project.nlg +29 -0
- package/frameworks/project/projects.nlg +587 -0
- package/frameworks/project/uglifyjs.js +1 -0
- package/frameworks/project/uglifyjs.nlg +79 -0
- package/frameworks/running/debugcom.nlg +163 -0
- package/frameworks/running/debugnub.nlg +565 -0
- package/frameworks/running/debugutil.nlg +510 -0
- package/frameworks/running/executors.nlg +767 -0
- package/frameworks/running/running.nlg +151 -0
- package/frameworks/running/sourcecode.nlg +346 -0
- package/frameworks/running/taskexec.nlg +196 -0
- package/frameworks/storage/dbt_pouch.nlg +773 -0
- package/frameworks/storage/file_manager.nlg +772 -0
- package/frameworks/storage/psm.nlg +326 -0
- package/frameworks/storage/psm_dbtables.nlg +814 -0
- package/frameworks/storage/resources.nlg +445 -0
- package/frameworks/storage/storage.nlg +52 -0
- package/lib/browser/env_web.js +431 -0
- package/lib/browser/env_webworker.js +146 -0
- package/lib/browser/require.js +1653 -0
- package/lib/core/naanlib.js +73 -0
- package/lib/env_node.js +282 -0
- package/lib/env_nodeworker.js +165 -0
- package/lib/node_repl.js +25 -0
- package/lib/node_repl_init.nlg +52 -0
- package/package.json +13 -0
- package/plugins/gitClient/clientops.nlg +317 -0
- package/plugins/gitClient/gitClient.nlg +63 -0
- package/plugins/gitClient/gitutils.nlg +1331 -0
- package/plugins/gitClient/minimatch.js +945 -0
- package/plugins/gitClient/minimatch_license.txt +15 -0
- package/plugins/gitClient/minimatch_readme.md +208 -0
- package/plugins/nodeLib/nodeLib.nlg +26 -0
- package/plugins/nodeLib/node_cp.nlg +65 -0
- package/plugins/nodeLib/node_fs.nlg +137 -0
- package/plugins/nodeLib/node_https.nlg +172 -0
- package/plugins/nodeLib/node_util.nlg +180 -0
- package/plugins/serviceAws/aws/aws-sdk.min.js +88 -0
- package/plugins/serviceAws/aws/lambda_rest_index.js +122 -0
- package/plugins/serviceAws/aws/lambda_rest_init.nlg +58 -0
- package/plugins/serviceAws/aws/lambda_ws_index.js +498 -0
- package/plugins/serviceAws/aws/lambda_ws_init.nlg +49 -0
- package/plugins/serviceAws/aws_cloudwatchlogs.nlg +122 -0
- package/plugins/serviceAws/aws_cognito.nlg +76 -0
- package/plugins/serviceAws/aws_dynamo.nlg +509 -0
- package/plugins/serviceAws/aws_lambda.nlg +95 -0
- package/plugins/serviceAws/aws_s3.nlg +134 -0
- package/plugins/serviceAws/aws_utils.nlg +86 -0
- package/plugins/serviceAws/dbt_aws.nlg +769 -0
- package/plugins/serviceAws/lambda_naan_control.nlg +175 -0
- package/plugins/serviceAws/psm_aws.nlg +258 -0
- package/plugins/serviceAws/serviceAws.nlg +38 -0
- package/plugins/serviceGitHub/gitops.nlg +522 -0
- package/plugins/serviceGitHub/psm_github.nlg +205 -0
- package/plugins/serviceGitHub/serviceGitHub.nlg +65 -0
- package/plugins/serviceGitLab/gitops.nlg +528 -0
- package/plugins/serviceGitLab/psm_gitlab.nlg +205 -0
- package/plugins/serviceGitLab/serviceGitLab.nlg +65 -0
- package/test/harness.nlg +312 -0
- package/test/node_test.js +33 -0
- package/test/test_01_core.nlg +768 -0
- package/test/test_02_context.nlg +269 -0
- package/test/test_03_jsinterop.nlg +137 -0
- package/test/test_04_numerics.nlg +450 -0
- package/test/test_05_strings.nlg +63 -0
- package/test/test_06_lingoparse.nlg +500 -0
- 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
|
+
}();
|