presidium 0.29.0 → 0.29.2

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/DynamoStream.js CHANGED
@@ -183,14 +183,13 @@ DynamoStream.prototype.getRecords = async function* getRecords(
183
183
  const SymbolUpdateShards = Symbol('UpdateShards')
184
184
 
185
185
  DynamoStream.prototype[Symbol.asyncIterator] = async function* () {
186
- let shards = await pipe([
187
- always(this.getStreams()),
186
+ let shards = await pipe(this.getStreams(), [
188
187
  flatMap(Stream => this.getShards(Stream)),
189
188
  map(assign({
190
189
  ShardIteratorType: always(this.shardIteratorType),
191
190
  })),
192
191
  transform(Transducer.passthrough, []),
193
- ])()
192
+ ])
194
193
  let muxAsyncIterator = Mux.race([
195
194
  ...shards.map(Shard => this.getRecords(Shard)),
196
195
  (async function* UpdateShardsGenerator() {
@@ -206,13 +205,11 @@ DynamoStream.prototype[Symbol.asyncIterator] = async function* () {
206
205
  while (!this.closed) {
207
206
  const { value, done } = await muxAsyncIterator.next()
208
207
  if (value == SymbolUpdateShards) {
209
- const latestShards = await pipe([
210
- always(this.getStreams()),
208
+ const latestShards = await pipe(this.getStreams(), [
211
209
  flatMap(Stream => this.getShards(Stream)),
212
210
  transform(Transducer.passthrough, []),
213
- ])()
214
- const newShards = pipe([
215
- always(shards),
211
+ ])
212
+ const newShards = pipe(shards, [
216
213
  differenceWith(
217
214
  (ShardA, ShardB) => ShardA.ShardId == ShardB.ShardId,
218
215
  latestShards,
@@ -220,7 +217,7 @@ DynamoStream.prototype[Symbol.asyncIterator] = async function* () {
220
217
  map(assign({
221
218
  ShardIteratorType: always('TRIM_HORIZON'),
222
219
  })),
223
- ])()
220
+ ])
224
221
 
225
222
  shards = latestShards
226
223
  if (newShards.length > 0) {
package/SecretsManager.js CHANGED
@@ -47,9 +47,46 @@ SecretsManager.prototype.createSecret = function (name, secretString) {
47
47
  return this.awsSecretsManager.createSecret({
48
48
  Name: name,
49
49
  SecretString: secretString,
50
+ }).promise().catch(async error => {
51
+ if (error.name == 'ResourceExistsException') {
52
+ const secretValue = await this.getSecretValue(name)
53
+ return this.awsSecretsManager.updateSecret({
54
+ SecretId: secretValue.ARN,
55
+ SecretString: secretString,
56
+ }).promise()
57
+ } else {
58
+ throw error
59
+ }
60
+ })
61
+ }
62
+
63
+ /**
64
+ * @name SecretsManager.prototype.updateSecret
65
+ *
66
+ * @synopsis
67
+ * ```coffeescript [specscript]
68
+ * new SecretsManager(...).updateSecret(
69
+ * name string,
70
+ * secretString string,
71
+ * ) -> result Promise<{}>
72
+ * ```
73
+ */
74
+ SecretsManager.prototype.updateSecret = function (name, secretString) {
75
+ return this.awsSecretsManager.updateSecret({
76
+ Name: name,
77
+ SecretString: secretString,
50
78
  }).promise()
51
79
  }
52
80
 
81
+ /**
82
+ * @name SecretsManager.prototype.putSecret
83
+ *
84
+ * @alias SecretsManager.prototype.createSecret
85
+ */
86
+ SecretsManager.prototype.putSecret = function (...args) {
87
+ return this.createSecret(...args)
88
+ }
89
+
53
90
  /**
54
91
  * @name SecretsManager.prototype.getSecretValue
55
92
  *
@@ -27,8 +27,14 @@ const test = new Test('SecretsManager', async function () {
27
27
  let didRerunTooSoon = false
28
28
 
29
29
  try {
30
- const result = await secretsManager.createSecret(mySecret.name, mySecret.value)
31
- assert.equal(result.Name, mySecret.name)
30
+ const result0 = await secretsManager.createSecret(mySecret.name, mySecret.value)
31
+ assert.equal(result0.Name, mySecret.name)
32
+
33
+ mySecret.value = 'helloworld2'
34
+
35
+ // should update
36
+ const result1 = await secretsManager.putSecret(mySecret.name, mySecret.value)
37
+ assert.equal(result1.Name, mySecret.name)
32
38
  } catch (error) {
33
39
  if (error.message.includes('scheduled for deletion')) {
34
40
  didRerunTooSoon = true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "presidium",
3
- "version": "0.29.0",
3
+ "version": "0.29.2",
4
4
  "description": "A library for creating web services",
5
5
  "author": "Richard Tong",
6
6
  "license": "MIT",