@naanlang/naan 1.0.2 → 1.0.5
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 +10 -8
- package/bin/index.js +2 -2
- package/dist/env_web.js +172 -22
- package/dist/naan.min.js +6 -6
- package/frameworks/browser/https_request.nlg +120 -0
- package/frameworks/browser/sworker.js +299 -91
- package/frameworks/browser/terminals.nlg +28 -13
- package/frameworks/browser/workers.nlg +27 -12
- package/frameworks/client/apiclient.nlg +17 -4
- package/frameworks/client/psm_client.nlg +184 -81
- package/frameworks/common/common.nlg +105 -25
- package/frameworks/common/preferences.nlg +1 -0
- package/frameworks/common/watching.nlg +1 -0
- package/frameworks/node/apiserver.nlg +31 -15
- package/frameworks/node/filesystem.nlg +230 -46
- package/frameworks/node/gitter.nlg +27 -6
- package/frameworks/node/https_request.nlg +119 -0
- package/frameworks/node/node.nlg +1 -0
- package/frameworks/node/psm_server.nlg +113 -37
- package/frameworks/project/build.nlg +40 -23
- package/frameworks/project/proj_cliser.nlg +11 -3
- package/frameworks/project/proj_console.nlg +13 -4
- package/frameworks/project/proj_folder.nlg +10 -1
- package/frameworks/project/proj_lambda.nlg +13 -4
- package/frameworks/project/proj_static.nlg +11 -3
- package/frameworks/project/projects.nlg +128 -40
- package/frameworks/running/debugnub.nlg +2 -5
- package/frameworks/running/executors.nlg +1 -0
- package/frameworks/storage/csv.nlg +120 -0
- package/frameworks/storage/dbt_pouch.nlg +41 -25
- package/frameworks/storage/psm.nlg +108 -28
- package/frameworks/storage/psm_dbtables.nlg +7 -3
- package/frameworks/storage/resources.nlg +30 -2
- package/lib/browser/env_web.js +170 -20
- package/lib/browser/env_webworker.js +1 -1
- package/lib/browser/require.js +1 -1
- package/lib/core/naanlib.js +6 -6
- package/package.json +2 -1
- package/plugins/serviceAws/aws/aws-sdk-node.min.js +2 -0
- package/plugins/serviceAws/aws/aws-sdk.min.js +2 -88
- package/plugins/serviceAws/aws_cloudwatchlogs.nlg +8 -7
- package/plugins/serviceAws/aws_dynamo.nlg +715 -148
- package/plugins/serviceAws/aws_dynextra.nlg +294 -0
- package/plugins/serviceAws/aws_lambda.nlg +11 -4
- package/plugins/serviceAws/aws_s3.nlg +44 -14
- package/plugins/serviceAws/dbt_aws.nlg +58 -45
- package/plugins/serviceAws/psm_aws.nlg +61 -40
- package/plugins/serviceAws/serviceAws.nlg +7 -4
- package/plugins/serviceGitHub/psm_github.nlg +41 -25
- package/plugins/serviceGitLab/psm_gitlab.nlg +41 -25
- package/test/harness.nlg +3 -1
- package/test/test_01_core.nlg +5 -5
- package/test/test_02_context.nlg +4 -4
- package/test/test_03_jsinterop.nlg +9 -3
- package/plugins/serviceAws/aws_cognito.nlg +0 -76
|
@@ -50,36 +50,26 @@ closure psmaConnector(psm, local connClassID, connector, watch) {
|
|
|
50
50
|
key: "bucketName" }
|
|
51
51
|
]
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
// hashResourceID
|
|
55
|
-
//
|
|
56
|
-
// Make a stable hash based on the resource credentials that we can persist or share between
|
|
57
|
-
// different domains accessing the same resource.
|
|
58
|
-
connector.hashResourceID = function hashResourceID(resource, local ident) {
|
|
59
|
-
ident = resource.region.concat(resource.region, resource.bucketName)
|
|
60
|
-
if resource.label
|
|
61
|
-
ident = ident.concat(resource.label)
|
|
62
|
-
HashSHA256(ident)
|
|
63
|
-
}
|
|
64
53
|
|
|
65
54
|
// findResource
|
|
66
55
|
//
|
|
67
|
-
// Find a resource with the specified contents, returning the resID or false.
|
|
68
|
-
|
|
69
|
-
connector.findResource = function findResource(resource, local resID, creds) {
|
|
56
|
+
// Find a resource with the specified contents, returning the resID or false.
|
|
57
|
+
connector.findResource = function findResource(resource, local resID, error, creds) {
|
|
70
58
|
for resID in listResources().1 {
|
|
71
|
-
creds =
|
|
72
|
-
if
|
|
73
|
-
&& (!resource.
|
|
59
|
+
`(error, creds) = connector.vault.accessResource(resID)
|
|
60
|
+
if creds && (!resource.region || resource.region == creds.region)
|
|
61
|
+
&& (!resource.bucketName || resource.bucketName == creds.bucketName)
|
|
62
|
+
&& (!resource.label || resource.label == creds.label)
|
|
74
63
|
return (resID)
|
|
75
64
|
}
|
|
76
65
|
false
|
|
77
66
|
}
|
|
78
67
|
|
|
79
|
-
//
|
|
68
|
+
// writeResource
|
|
80
69
|
//
|
|
81
|
-
// Add credentials for a named resource.
|
|
82
|
-
// comprising these
|
|
70
|
+
// Add or update credentials for a named resource. If no resID is specified this adds a new
|
|
71
|
+
// resource; otherwise it updates an existing one. The resource is a dictionary comprising these
|
|
72
|
+
// keys:
|
|
83
73
|
// label - [optional] label we use for this resource
|
|
84
74
|
// keyID - AWS IAM keyID
|
|
85
75
|
// keySecret - AWS IAM keySecret
|
|
@@ -87,10 +77,13 @@ closure psmaConnector(psm, local connClassID, connector, watch) {
|
|
|
87
77
|
// bucketName - AWS bucketName
|
|
88
78
|
// hidden - [optional] don't enumerate to user
|
|
89
79
|
// locked - [optional] don't allow user delete
|
|
90
|
-
// The return value is (error,
|
|
91
|
-
// keys and error diagnostic strings.
|
|
92
|
-
connector.
|
|
93
|
-
|
|
80
|
+
// The return value is an (error, resID) tuple. Error, if non-false, is a dictionary of field
|
|
81
|
+
// keys and error diagnostic strings.
|
|
82
|
+
connector.writeResource = function writeResource(resource, resID,
|
|
83
|
+
local creds, errors, error, data, change) {
|
|
84
|
+
// badField - test for a bad string
|
|
85
|
+
function badField(str) { !string(str) || str.trim().length == 0 }
|
|
86
|
+
|
|
94
87
|
creds = {
|
|
95
88
|
keyID: resource.keyID,
|
|
96
89
|
keySecret: resource.keySecret,
|
|
@@ -104,6 +97,8 @@ closure psmaConnector(psm, local connClassID, connector, watch) {
|
|
|
104
97
|
creds.label = resource.region.concat("-", resource.bucketName)
|
|
105
98
|
if badField(creds.label)
|
|
106
99
|
errors.label = "invalid label"
|
|
100
|
+
else if !resID && findResource({ label: creds.label })
|
|
101
|
+
errors.label = "duplicate name"
|
|
107
102
|
if badField(resource.keyID)
|
|
108
103
|
errors.keyID = "required field"
|
|
109
104
|
if badField(resource.keySecret)
|
|
@@ -119,14 +114,35 @@ closure psmaConnector(psm, local connClassID, connector, watch) {
|
|
|
119
114
|
creds.hidden = resource.hidden
|
|
120
115
|
if resource.locked
|
|
121
116
|
creds.locked = resource.locked
|
|
122
|
-
resID
|
|
123
|
-
|
|
117
|
+
if resID {
|
|
118
|
+
`(error, data) = connector.vault.updateResource(resID, creds)
|
|
119
|
+
change = { changed: [resID] }
|
|
120
|
+
} else {
|
|
121
|
+
resID = UUID()
|
|
122
|
+
`(error, data) = connector.vault.addResource(resID, creds)
|
|
123
|
+
change = { added: [resID] }
|
|
124
|
+
}
|
|
124
125
|
if data {
|
|
125
|
-
watch.notify(connClassID,
|
|
126
|
-
data = resID
|
|
126
|
+
watch.notify(connClassID, change)
|
|
127
|
+
data = resID
|
|
128
|
+
}
|
|
127
129
|
}
|
|
128
130
|
list(error, data)
|
|
129
131
|
}
|
|
132
|
+
|
|
133
|
+
// addResource
|
|
134
|
+
//
|
|
135
|
+
// Add a new resource, returning a standard error tuple per writeResource.
|
|
136
|
+
connector.addResource = function addResource(resource) {
|
|
137
|
+
writeResource(resource)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// updateResource
|
|
141
|
+
//
|
|
142
|
+
// Update an existing resource, returning a standard error tuple per writeResource.
|
|
143
|
+
connector.updateResource = function updateResource(resID, resource) {
|
|
144
|
+
writeResource(resource, resID)
|
|
145
|
+
}
|
|
130
146
|
|
|
131
147
|
// getResource
|
|
132
148
|
//
|
|
@@ -193,28 +209,33 @@ closure psmaConnector(psm, local connClassID, connector, watch) {
|
|
|
193
209
|
//
|
|
194
210
|
// Return an S3 access object, which is the credentials to access an AWS S3 bucket.
|
|
195
211
|
|
|
196
|
-
connector.access = function access(resID, local error, creds,
|
|
212
|
+
connector.access = function access(resID, local error, creds, s3b) {
|
|
197
213
|
`(error, creds) = connector.vault.accessResource(resID)
|
|
198
214
|
if error
|
|
199
215
|
return (list(error)) // can't access that resource
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
216
|
+
if !awsSDK.S3
|
|
217
|
+
return (list(Error("S3 connector: no AWS SDK available")))
|
|
218
|
+
s3b = {
|
|
219
|
+
s3: xnew(awsSDK.S3, {
|
|
220
|
+
region: creds.region
|
|
221
|
+
credentials: {
|
|
222
|
+
accessKeyId: creds.keyID
|
|
223
|
+
secretAccessKey: creds.keySecret
|
|
224
|
+
}})
|
|
225
|
+
bucketName: creds.bucketName
|
|
226
|
+
region: creds.region
|
|
227
|
+
}
|
|
228
|
+
list(false, s3b)
|
|
208
229
|
}
|
|
209
230
|
|
|
210
231
|
// connect
|
|
211
232
|
//
|
|
212
233
|
// Connect to an AWS bucket filesystem, returning a view.
|
|
213
234
|
|
|
214
|
-
connector.connect = function connect(resID, service, args, local error,
|
|
215
|
-
`(error,
|
|
235
|
+
connector.connect = function connect(resID, service, args, local error, s3b, db, table) {
|
|
236
|
+
`(error, s3b) = connector.access(resID)
|
|
216
237
|
if !error
|
|
217
|
-
`(error, db) = S3DB(
|
|
238
|
+
`(error, db) = S3DB(s3b) // get S3 bucket as a database
|
|
218
239
|
if error
|
|
219
240
|
list(error)
|
|
220
241
|
else if service == "NideDB"
|
|
@@ -19,16 +19,19 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
function sawsInit(local manifest) {
|
|
22
|
-
manifest = `(sawsInit)
|
|
22
|
+
manifest = `(awsSDK, sawsLoadList, sawsSetPostLoadCall, sawsCallPostload, sawsInit)
|
|
23
23
|
|
|
24
24
|
Naan.module.build(module.id, "serviceAws", function(modobj, compobj) {
|
|
25
25
|
compobj.manifest = manifest
|
|
26
26
|
require("frameworks/common").LiveImport()
|
|
27
|
+
require("./aws_utils.nlg")
|
|
27
28
|
function sawsPostload() {
|
|
28
|
-
if js.
|
|
29
|
-
awsSDK = js.r("aws-sdk")
|
|
29
|
+
if js.lambda
|
|
30
|
+
awsSDK = js.r("/opt/aws-sdk-node.min.js") // SDK is a layer
|
|
31
|
+
else if js.g
|
|
32
|
+
awsSDK = js.r("aws-sdk-node.min") // SDK must be in search path
|
|
30
33
|
else
|
|
31
|
-
awsSDK = JsLoadScript(JSpath.join(module.locpath, "./aws/aws-sdk.min.js"), "
|
|
34
|
+
awsSDK = JsLoadScript(JSpath.join(module.locpath, "./aws/aws-sdk.min.js"), "awsSdk")
|
|
32
35
|
module.exports.awsSDK = awsSDK
|
|
33
36
|
if App.psm
|
|
34
37
|
require("./psm_aws.nlg").AwsConnector(App.psm)
|
|
@@ -45,41 +45,34 @@ closure phubConnector(psm, local connClassID, connector, watch) {
|
|
|
45
45
|
|
|
46
46
|
// findResource
|
|
47
47
|
//
|
|
48
|
-
// Find a resource with the specified contents, returning the resID or false.
|
|
49
|
-
// is: if added, would the specified contents be redundant to an existing resource?
|
|
48
|
+
// Find a resource with the specified contents, returning the resID or false.
|
|
50
49
|
connector.findResource = function findResource(resource, local resID, creds) {
|
|
51
50
|
for resID in listResources().1 {
|
|
52
51
|
creds = access(resID).1
|
|
53
|
-
if resource.
|
|
52
|
+
if ((!resource.label || resource.label == creds.label)
|
|
53
|
+
&& (!resource.userName || resource.userName == creds.userName))
|
|
54
54
|
return (resID)
|
|
55
55
|
}
|
|
56
56
|
false
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
// hashResourceID
|
|
60
|
-
//
|
|
61
|
-
// Make a stable hash based on the resource credentials that we can persist or share between
|
|
62
|
-
// different domains accessing the same resource.
|
|
63
|
-
connector.hashResourceID = function hashResourceID(resource, local ident) {
|
|
64
|
-
ident = resource.userName
|
|
65
|
-
if resource.label
|
|
66
|
-
ident = ident.concat(resource.label)
|
|
67
|
-
HashSHA256(ident)
|
|
68
|
-
}
|
|
69
58
|
|
|
70
|
-
//
|
|
59
|
+
// writeResource
|
|
71
60
|
//
|
|
72
|
-
// Add credentials for a named resource.
|
|
73
|
-
// comprising these
|
|
61
|
+
// Add or update credentials for a named resource. If no resID is specified this adds a new
|
|
62
|
+
// resource; otherwise it updates an existing one. The resource is a dictionary comprising these
|
|
63
|
+
// keys:
|
|
74
64
|
// label - [optional] label we use for this resource
|
|
75
65
|
// userName - GitHub user name
|
|
76
66
|
// userPat - GitHUB Personal Access Token
|
|
77
67
|
// hidden - [optional] don't enumerate to user
|
|
78
68
|
// locked - [optional] don't allow user delete
|
|
79
|
-
// The return value is (error,
|
|
80
|
-
// keys and error diagnostic strings.
|
|
81
|
-
connector.
|
|
82
|
-
|
|
69
|
+
// The return value is an (error, resID) tuple. Error, if non-false, is a dictionary of field
|
|
70
|
+
// keys and error diagnostic strings.
|
|
71
|
+
connector.writeResource = function writeResource(resource, resID,
|
|
72
|
+
local label, errors, creds, error, data) {
|
|
73
|
+
// badField - test for a bad string
|
|
74
|
+
function badField(str) { !string(str) || str.trim().length == 0 }
|
|
75
|
+
|
|
83
76
|
creds = {
|
|
84
77
|
userName: resource.userName,
|
|
85
78
|
userPat: resource.userPat
|
|
@@ -91,6 +84,8 @@ closure phubConnector(psm, local connClassID, connector, watch) {
|
|
|
91
84
|
creds.label = resource.region.concat("-", resource.bucketName)
|
|
92
85
|
if badField(creds.label)
|
|
93
86
|
errors.label = "invalid label"
|
|
87
|
+
else if !resID && findResource({ label: creds.label })
|
|
88
|
+
errors.label = "duplicate name"
|
|
94
89
|
if badField(resource.userName)
|
|
95
90
|
errors.userName = "required field"
|
|
96
91
|
if badField(resource.userPat)
|
|
@@ -102,15 +97,36 @@ closure phubConnector(psm, local connClassID, connector, watch) {
|
|
|
102
97
|
creds.hidden = resource.hidden
|
|
103
98
|
if resource.locked
|
|
104
99
|
creds.locked = resource.locked
|
|
105
|
-
resID
|
|
106
|
-
|
|
100
|
+
if resID {
|
|
101
|
+
`(error, data) = connector.vault.updateResource(resID, creds)
|
|
102
|
+
change = { changed: [resID] }
|
|
103
|
+
} else {
|
|
104
|
+
resID = UUID()
|
|
105
|
+
`(error, data) = connector.vault.addResource(resID, creds)
|
|
106
|
+
change = { added: [resID] }
|
|
107
|
+
}
|
|
107
108
|
if data {
|
|
108
|
-
watch.notify(connClassID,
|
|
109
|
-
data = resID
|
|
109
|
+
watch.notify(connClassID, change)
|
|
110
|
+
data = resID
|
|
111
|
+
}
|
|
110
112
|
}
|
|
111
113
|
list(error, data)
|
|
112
114
|
}
|
|
113
115
|
|
|
116
|
+
// addResource
|
|
117
|
+
//
|
|
118
|
+
// Add a new resource, returning a standard error tuple per writeResource.
|
|
119
|
+
connector.addResource = function addResource(resource) {
|
|
120
|
+
writeResource(resource)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// updateResource
|
|
124
|
+
//
|
|
125
|
+
// Update an existing resource, returning a standard error tuple per writeResource.
|
|
126
|
+
connector.updateResource = function updateResource(resID, resource) {
|
|
127
|
+
writeResource(resource, resID)
|
|
128
|
+
}
|
|
129
|
+
|
|
114
130
|
// deleteResource
|
|
115
131
|
//
|
|
116
132
|
// Delete credentials for a resource
|
|
@@ -42,44 +42,37 @@ closure plabConnector(psm, local connClassID, connector, watch) {
|
|
|
42
42
|
type: "password" }
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
// hashResourceID
|
|
47
|
-
//
|
|
48
|
-
// Make a stable hash based on the resource credentials that we can persist or share between
|
|
49
|
-
// different domains accessing the same resource.
|
|
50
|
-
connector.hashResourceID = function hashResourceID(resource, local ident) {
|
|
51
|
-
ident = resource.userName
|
|
52
|
-
if resource.label
|
|
53
|
-
ident = ident.concat(resource.label)
|
|
54
|
-
HashSHA256(ident)
|
|
55
|
-
}
|
|
56
45
|
|
|
57
46
|
// findResource
|
|
58
47
|
//
|
|
59
|
-
// Find a resource with the specified contents, returning the resID or false.
|
|
60
|
-
// is: if added, would the specified contents be redundant to an existing resource?
|
|
48
|
+
// Find a resource with the specified contents, returning the resID or false.
|
|
61
49
|
connector.findResource = function findResource(resource, local resID, creds) {
|
|
62
50
|
for resID in listResources().1 {
|
|
63
51
|
creds = access(resID).1
|
|
64
|
-
if resource.
|
|
52
|
+
if ((!resource.label || resource.label == creds.label)
|
|
53
|
+
&& (!resource.userName || resource.userName == creds.userName))
|
|
65
54
|
return (resID)
|
|
66
55
|
}
|
|
67
56
|
false
|
|
68
57
|
}
|
|
69
58
|
|
|
70
|
-
//
|
|
59
|
+
// writeResource
|
|
71
60
|
//
|
|
72
|
-
// Add credentials for a named resource.
|
|
73
|
-
// comprising these
|
|
61
|
+
// Add or update credentials for a named resource. If no resID is specified this adds a new
|
|
62
|
+
// resource; otherwise it updates an existing one. The resource is a dictionary comprising these
|
|
63
|
+
// keys:
|
|
74
64
|
// label - [optional] label we use for this resource
|
|
75
65
|
// userName - GitLab user name
|
|
76
66
|
// userPat - GitLab Personal Access Token
|
|
77
67
|
// hidden - [optional] don't enumerate to user
|
|
78
68
|
// locked - [optional] don't allow user delete
|
|
79
|
-
// The return value is (error,
|
|
80
|
-
// keys and error diagnostic strings.
|
|
81
|
-
connector.
|
|
82
|
-
|
|
69
|
+
// The return value is an (error, resID) tuple. Error, if non-false, is a dictionary of field
|
|
70
|
+
// keys and error diagnostic strings.
|
|
71
|
+
connector.writeResource = function writeResource(resource, resID,
|
|
72
|
+
local label, errors, creds, error, data) {
|
|
73
|
+
// badField - test for a bad string
|
|
74
|
+
function badField(str) { !string(str) || str.trim().length == 0 }
|
|
75
|
+
|
|
83
76
|
creds = {
|
|
84
77
|
userName: resource.userName,
|
|
85
78
|
userPat: resource.userPat
|
|
@@ -91,6 +84,8 @@ closure plabConnector(psm, local connClassID, connector, watch) {
|
|
|
91
84
|
creds.label = resource.region.concat("-", resource.bucketName)
|
|
92
85
|
if badField(creds.label)
|
|
93
86
|
errors.label = "invalid label"
|
|
87
|
+
else if !resID && findResource({ label: creds.label })
|
|
88
|
+
errors.label = "duplicate name"
|
|
94
89
|
if badField(resource.userName)
|
|
95
90
|
errors.userName = "required field"
|
|
96
91
|
if badField(resource.userPat)
|
|
@@ -102,15 +97,36 @@ closure plabConnector(psm, local connClassID, connector, watch) {
|
|
|
102
97
|
creds.hidden = resource.hidden
|
|
103
98
|
if resource.locked
|
|
104
99
|
creds.locked = resource.locked
|
|
105
|
-
resID
|
|
106
|
-
|
|
100
|
+
if resID {
|
|
101
|
+
`(error, data) = connector.vault.updateResource(resID, creds)
|
|
102
|
+
change = { changed: [resID] }
|
|
103
|
+
} else {
|
|
104
|
+
resID = UUID()
|
|
105
|
+
`(error, data) = connector.vault.addResource(resID, creds)
|
|
106
|
+
change = { added: [resID] }
|
|
107
|
+
}
|
|
107
108
|
if data {
|
|
108
|
-
watch.notify(connClassID,
|
|
109
|
-
data = resID
|
|
109
|
+
watch.notify(connClassID, change)
|
|
110
|
+
data = resID
|
|
111
|
+
}
|
|
110
112
|
}
|
|
111
113
|
list(error, data)
|
|
112
114
|
}
|
|
113
115
|
|
|
116
|
+
// addResource
|
|
117
|
+
//
|
|
118
|
+
// Add a new resource, returning a standard error tuple per writeResource.
|
|
119
|
+
connector.addResource = function addResource(resource) {
|
|
120
|
+
writeResource(resource)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// updateResource
|
|
124
|
+
//
|
|
125
|
+
// Update an existing resource, returning a standard error tuple per writeResource.
|
|
126
|
+
connector.updateResource = function updateResource(resID, resource) {
|
|
127
|
+
writeResource(resource, resID)
|
|
128
|
+
}
|
|
129
|
+
|
|
114
130
|
// deleteResource
|
|
115
131
|
//
|
|
116
132
|
// Delete credentials for a resource
|
package/test/harness.nlg
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2020-
|
|
9
|
+
* Copyright (c) 2020-2022 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -224,6 +224,8 @@ function RunTests(local totalTestCount, totalPassCount, totalTimeMS) {
|
|
|
224
224
|
result = parsenv.parse(cmd.concat("\n"))
|
|
225
225
|
else
|
|
226
226
|
return ("invalid cmd at test ".concat(testCounter, ": ", typeof(cmd), "\n"))
|
|
227
|
+
if symbol(expect)
|
|
228
|
+
expect = tostring(expect)
|
|
227
229
|
if string(expect) {
|
|
228
230
|
if result.errors.length > 0
|
|
229
231
|
return (strcat("test(\"", cmd, "\") failed:\n ", result.errors.join("|"), "\n"))
|
package/test/test_01_core.nlg
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2017-
|
|
9
|
+
* Copyright (c) 2017-2022 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -223,8 +223,8 @@ RegisterTestCategory("core", [
|
|
|
223
223
|
[ "unicode(\"Z\");", "0x5a" ],
|
|
224
224
|
[ "unicode(0x2609);", "\"☉\"" ],
|
|
225
225
|
[ "unicode(\"☉\");", "0x2609" ],
|
|
226
|
-
[ "unicode(
|
|
227
|
-
[ "unicode(\"
|
|
226
|
+
[ "unicode(0x1fad3);", "\"🫓\"" ], // "flatbread", i.e. naan
|
|
227
|
+
[ "unicode(\"🫓\");", "0x1fad3" ],
|
|
228
228
|
[ "unicode(0x1f35e);", "\"🍞\"" ],
|
|
229
229
|
[ "unicode(\"🍞\");", "0x1f35e" ],
|
|
230
230
|
[ "unicode(0x1f95c);", "\"🥜\"" ], // peanut, UNICODE 9.0 2016
|
|
@@ -707,7 +707,7 @@ RegisterTestCategory("core", [
|
|
|
707
707
|
[ "cons(`a);>", "(a)" ],
|
|
708
708
|
[ "cons(`a,`b);>", "(a . b)" ],
|
|
709
709
|
[ "cons(`a,`b,`c);>", "(a b . c)" ],
|
|
710
|
-
[ "length(stacktrace());", "
|
|
710
|
+
[ "length(stacktrace());", "55" ],
|
|
711
711
|
|
|
712
712
|
//
|
|
713
713
|
// lower builtin
|
|
@@ -764,5 +764,5 @@ RegisterTestCategory("core", [
|
|
|
764
764
|
// mangled
|
|
765
765
|
//
|
|
766
766
|
|
|
767
|
-
[ "mangled();", "
|
|
767
|
+
[ "mangled();", equal( "prod", "prod") ],
|
|
768
768
|
]);
|
package/test/test_02_context.nlg
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2017-
|
|
9
|
+
* Copyright (c) 2017-2022 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -206,10 +206,10 @@ RegisterTestCategory("context", [
|
|
|
206
206
|
[ "test2(6);", { errors: "exception: recursed 102" } ],
|
|
207
207
|
|
|
208
208
|
[ "function test1(x) { if x > 10000 printline(x) else 0+test2(x+1) };", "==> redefined: test1|test1" ],
|
|
209
|
-
[ "test2(7);", { errors: "exception: recursed
|
|
209
|
+
[ "test2(7);", { errors: "exception: recursed 149" } ],
|
|
210
210
|
|
|
211
211
|
[ "function test2(x) { testRecurCheck(x), if true test1(x+1) else print(x) };", "==> redefined: test2|test2" ],
|
|
212
|
-
[ "test2(8);", { errors: "exception: recursed
|
|
212
|
+
[ "test2(8);", { errors: "exception: recursed 150" } ],
|
|
213
213
|
|
|
214
214
|
[ "function test1(x) { if x > 10000 printline(x) else loop test2(x+1, 4, 5) };", "==> redefined: test1|test1" ],
|
|
215
215
|
[ "function test2(x,y,z) { testRecurCheck(x), loop if true { test1(x+1),break } else print(x) };", "==> redefined: test2|test2" ],
|
|
@@ -222,7 +222,7 @@ RegisterTestCategory("context", [
|
|
|
222
222
|
[ "oo=new(object);", "Object{0}"],
|
|
223
223
|
[ "oo.test1 = function test1(x) { if x > 10000 printline(x) else test2(x+1) };", "==> redefined: test1|test1"],
|
|
224
224
|
[ "oo.test2 = function test2 xt { testRecurCheck(car(xt)), oo.test1(car(xt)+1) };", "==> redefined: test2|test2"],
|
|
225
|
-
[ "oo.test1(11);", { errors: "exception: recursed
|
|
225
|
+
[ "oo.test1(11);", { errors: "exception: recursed 154" } ],
|
|
226
226
|
|
|
227
227
|
[ "function test1 xt { testRecurCheck(car(xt)), if car(xt) > 10000 printline(xt) else test1(car(xt)+1) };",
|
|
228
228
|
"==> redefined: test1|test1" ],
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2020-
|
|
9
|
+
* Copyright (c) 2020-2022 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -33,8 +33,14 @@ RegisterTestCategory("JSinterop", [
|
|
|
33
33
|
[ "o.a;", "undefined" ],
|
|
34
34
|
[ "o.nodef;", "undefined" ],
|
|
35
35
|
|
|
36
|
-
[ "o(3);", {
|
|
37
|
-
|
|
36
|
+
[ "o(3);", {
|
|
37
|
+
"dev": { errors: "xcall \"[object Object]\": TypeError: object.apply is not a function" }
|
|
38
|
+
"prod": { errors: "xcall \"[object Object]\": TypeError: e[3].apply is not a function" }
|
|
39
|
+
}[ "prod"]],
|
|
40
|
+
[ "o(Number);", {
|
|
41
|
+
"dev": { errors: "xcall \"[object Object]\": TypeError: object.apply is not a function" }
|
|
42
|
+
"prod": { errors: "xcall \"[object Object]\": TypeError: e[3].apply is not a function" }
|
|
43
|
+
}[ "prod"]],
|
|
38
44
|
[ "Number(3);", "[Number 3]" ],
|
|
39
45
|
[ "Number(3).toString();", "\"3\"" ],
|
|
40
46
|
[ "tostring(Number(3));", "\"[Number 3]\"" ],
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* aws_cognito.nlg
|
|
3
|
-
* serviceAws
|
|
4
|
-
*
|
|
5
|
-
* Access to Cognito services for AWS.
|
|
6
|
-
*
|
|
7
|
-
* column positioning: // // !
|
|
8
|
-
*
|
|
9
|
-
* Copyright (c) 2022 by Richard C. Zulch
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/*
|
|
15
|
-
* Cognito
|
|
16
|
-
*
|
|
17
|
-
* Cognito service functions.
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
closure Cognito(userPoolID, local cogo) {
|
|
22
|
-
cogo = new(object, this)
|
|
23
|
-
cogo.userPoolID = userPoolID
|
|
24
|
-
|
|
25
|
-
//
|
|
26
|
-
// login
|
|
27
|
-
//
|
|
28
|
-
cogo.login = closure login(creds) {
|
|
29
|
-
cogo.aws = xnew(awsSDK.CognitoIdentityServiceProvider, {
|
|
30
|
-
apiVersion: '2016-04-18'
|
|
31
|
-
accessKeyId: creds.keyID,
|
|
32
|
-
secretAccessKey: creds.keySecret,
|
|
33
|
-
region: creds.region })
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
// getUser
|
|
38
|
-
//
|
|
39
|
-
cogo.adminGetUser = closure adminGetUser(username, local params, pending) {
|
|
40
|
-
params = {
|
|
41
|
-
UserPoolId: cogo.userPoolID
|
|
42
|
-
Username: username
|
|
43
|
-
}
|
|
44
|
-
pending = new(nonce)
|
|
45
|
-
cogo.aws.getFunction(params, function(error, data) {
|
|
46
|
-
if error {
|
|
47
|
-
cogoError = error
|
|
48
|
-
debuglog("aws.cognito.adminGetUser failed", error)
|
|
49
|
-
}
|
|
50
|
-
pending.signal(list(error, data))
|
|
51
|
-
})
|
|
52
|
-
pending.wait()
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// finis
|
|
56
|
-
cogo
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
/*
|
|
61
|
-
* cogoInit
|
|
62
|
-
*
|
|
63
|
-
* Initialize the Lambda module.
|
|
64
|
-
*
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
|
-
function lambdaInit(local manifest) {
|
|
68
|
-
manifest = `(cogoInit, Cognito)
|
|
69
|
-
|
|
70
|
-
Naan.module.build(module.id, "aws_cognito", function(modobj, compobj) {
|
|
71
|
-
require("./serviceAws.nlg")
|
|
72
|
-
compobj.manifest = manifest
|
|
73
|
-
modobj.exports.Cognito = Cognito
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
} ();
|