@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.
Files changed (35) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +3 -3
  3. package/bin/index.js +2 -2
  4. package/dist/env_web.js +149 -20
  5. package/dist/naan.min.js +5 -5
  6. package/frameworks/browser/sworker.js +309 -91
  7. package/frameworks/browser/terminals.nlg +22 -9
  8. package/frameworks/browser/workers.nlg +19 -11
  9. package/frameworks/client/apiclient.nlg +17 -4
  10. package/frameworks/client/psm_client.nlg +116 -53
  11. package/frameworks/common/common.nlg +12 -2
  12. package/frameworks/node/apiserver.nlg +25 -13
  13. package/frameworks/node/filesystem.nlg +173 -30
  14. package/frameworks/node/psm_server.nlg +95 -32
  15. package/frameworks/project/build.nlg +40 -23
  16. package/frameworks/project/projects.nlg +47 -26
  17. package/frameworks/running/debugnub.nlg +2 -5
  18. package/frameworks/storage/csv.nlg +120 -0
  19. package/frameworks/storage/dbt_pouch.nlg +41 -25
  20. package/frameworks/storage/psm.nlg +108 -28
  21. package/frameworks/storage/psm_dbtables.nlg +7 -3
  22. package/frameworks/storage/resources.nlg +30 -2
  23. package/lib/browser/env_web.js +147 -18
  24. package/lib/browser/env_webworker.js +1 -1
  25. package/lib/browser/require.js +1 -1
  26. package/lib/core/naanlib.js +5 -5
  27. package/package.json +1 -1
  28. package/plugins/serviceAws/aws_cloudwatchlogs.nlg +1 -1
  29. package/plugins/serviceAws/aws_dynamo.nlg +625 -141
  30. package/plugins/serviceAws/aws_dynextra.nlg +294 -0
  31. package/plugins/serviceAws/dbt_aws.nlg +31 -11
  32. package/plugins/serviceAws/psm_aws.nlg +42 -26
  33. package/plugins/serviceAws/serviceAws.nlg +1 -0
  34. package/plugins/serviceGitHub/psm_github.nlg +41 -25
  35. 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. The loose criteria
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.userName == creds.userName
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
- // addResource
59
+ // writeResource
71
60
  //
72
- // Add credentials for a named resource. The label is a string. The resource is a dictionary
73
- // comprising these keys:
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, result) tuple. Error, if non-false, is a dictionary of field
80
- // keys and error diagnostic strings. The special key "label" refers to the label string.
81
- connector.addResource = function addResource(resource, local label, errors, creds, error, resID, data) {
82
- function badField(str) { !string(str) || str.trim().length == 0 }
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 = hashResourceID(resource)
106
- `(error, data) = connector.vault.addResource(resID, creds)
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, { added: [resID] })
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