@naanlang/naan 1.0.2 → 1.0.3
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 +3 -3
- package/bin/index.js +2 -2
- package/dist/env_web.js +149 -20
- package/dist/naan.min.js +5 -5
- package/frameworks/browser/sworker.js +309 -91
- package/frameworks/browser/terminals.nlg +22 -9
- package/frameworks/browser/workers.nlg +19 -11
- package/frameworks/client/apiclient.nlg +17 -4
- package/frameworks/client/psm_client.nlg +116 -53
- package/frameworks/common/common.nlg +12 -2
- package/frameworks/node/apiserver.nlg +25 -13
- package/frameworks/node/filesystem.nlg +173 -30
- package/frameworks/node/psm_server.nlg +95 -32
- package/frameworks/project/build.nlg +40 -23
- package/frameworks/project/projects.nlg +47 -26
- package/frameworks/running/debugnub.nlg +2 -5
- 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 +147 -18
- package/lib/browser/env_webworker.js +1 -1
- package/lib/browser/require.js +1 -1
- package/lib/core/naanlib.js +5 -5
- package/package.json +1 -1
- package/plugins/serviceAws/aws_cloudwatchlogs.nlg +1 -1
- package/plugins/serviceAws/aws_dynamo.nlg +625 -141
- package/plugins/serviceAws/aws_dynextra.nlg +294 -0
- package/plugins/serviceAws/dbt_aws.nlg +31 -11
- package/plugins/serviceAws/psm_aws.nlg +42 -26
- package/plugins/serviceAws/serviceAws.nlg +1 -0
- package/plugins/serviceGitHub/psm_github.nlg +41 -25
- package/plugins/serviceGitLab/psm_gitlab.nlg +41 -25
|
@@ -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
|