presidium 0.29.13 → 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.
Files changed (158) hide show
  1. package/Archive.js +11 -7
  2. package/AwsCredentials.js +39 -41
  3. package/Docker.js +1377 -1073
  4. package/DynamoDBGlobalSecondaryIndex.js +782 -0
  5. package/DynamoDBStream.js +500 -0
  6. package/DynamoDBTable.js +1483 -0
  7. package/ECR.js +188 -35
  8. package/HTTP.js +390 -0
  9. package/NpmToken.js +26 -9
  10. package/README.md +194 -126
  11. package/Readable.js +88 -0
  12. package/S3Bucket.js +2368 -337
  13. package/SecretsManager.js +193 -123
  14. package/TranscribeStream.js +33 -25
  15. package/WebSocket.js +1 -24
  16. package/XML.js +286 -0
  17. package/package.json +42 -22
  18. package/userAgent.js +5 -0
  19. package/.eslintrc.js +0 -330
  20. package/.github/workflows/nodejs.yml +0 -82
  21. package/Archive.test.js +0 -61
  22. package/AutoScaling.js +0 -106
  23. package/AutoScaling.test.js +0 -57
  24. package/AwsCredentials.test.js +0 -63
  25. package/CHANGELOG.md +0 -11
  26. package/Dependency.js +0 -49
  27. package/Dependency.test.js +0 -74
  28. package/Docker.test.js +0 -483
  29. package/DockerContainer.js +0 -162
  30. package/DockerContainer.test.js +0 -116
  31. package/DockerImage.js +0 -191
  32. package/DockerImage.test.js +0 -89
  33. package/DockerService.js +0 -319
  34. package/DockerService.test.js +0 -191
  35. package/DockerSwarm.js +0 -117
  36. package/DockerSwarm.test.js +0 -32
  37. package/Dynamo.js +0 -460
  38. package/Dynamo.test.js +0 -80
  39. package/DynamoIndex.js +0 -186
  40. package/DynamoIndex.test.js +0 -417
  41. package/DynamoIndexQueryIterator.js +0 -49
  42. package/DynamoIndexQueryIterator.test.js +0 -102
  43. package/DynamoStream.js +0 -251
  44. package/DynamoStream.memory-usage.js +0 -32
  45. package/DynamoStream.test.js +0 -336
  46. package/DynamoTable.js +0 -430
  47. package/DynamoTable.test.js +0 -246
  48. package/DynamoTableScanIterator.js +0 -26
  49. package/DynamoTableScanIterator.test.js +0 -39
  50. package/DynamoTableV2.js +0 -487
  51. package/DynamoTableV2.test.js +0 -121
  52. package/EC2.js +0 -186
  53. package/EC2.test.js +0 -57
  54. package/ECR.test.js +0 -32
  55. package/EcrLoginPassword.js +0 -39
  56. package/Elasticsearch.js +0 -29
  57. package/Elasticsearch.test.js +0 -13
  58. package/ElasticsearchIndex.js +0 -440
  59. package/ElasticsearchIndex.test.js +0 -155
  60. package/Gzip.js +0 -29
  61. package/Gzip.test.js +0 -30
  62. package/Http.js +0 -104
  63. package/Http.test.js +0 -86
  64. package/HttpAgent.js +0 -20
  65. package/HttpAgent.test.js +0 -9
  66. package/HttpServer.js +0 -72
  67. package/HttpServer.test.js +0 -30
  68. package/HttpsAgent.js +0 -20
  69. package/HttpsAgent.test.js +0 -15
  70. package/HttpsServer.js +0 -37
  71. package/Kinesis.js +0 -33
  72. package/Kinesis.test.js +0 -11
  73. package/KinesisStream.js +0 -270
  74. package/KinesisStream.test.js +0 -165
  75. package/Mongo.js +0 -38
  76. package/Mongo.test.js +0 -13
  77. package/MongoCollection.js +0 -26
  78. package/MongoCollection.test.js +0 -23
  79. package/OptionalValidator.test.js +0 -30
  80. package/Password.test.js +0 -19
  81. package/Redis.js +0 -32
  82. package/Redis.test.js +0 -215
  83. package/RequestBuffer.js +0 -21
  84. package/RequestBuffer.test.js +0 -34
  85. package/S3.js +0 -424
  86. package/S3.test.js +0 -13
  87. package/S3Bucket.test.js +0 -86
  88. package/SecretsManager.test.js +0 -76
  89. package/StrictValidator.test.js +0 -36
  90. package/StringStream.js +0 -15
  91. package/TranscribeStream.test.js +0 -119
  92. package/WebSocketServer.js +0 -109
  93. package/WebSocketServer.test.js +0 -156
  94. package/index.js +0 -73
  95. package/internal/AWSAutoScalingDescribeAutoScalingGroupsFilters.js +0 -35
  96. package/internal/AWSEC2DescribeInstancesFilters.js +0 -140
  97. package/internal/AmzCanonicalHeaders.js +0 -18
  98. package/internal/AmzDate.js +0 -14
  99. package/internal/AmzSignature.js +0 -35
  100. package/internal/AmzSignedHeaders.js +0 -13
  101. package/internal/AutoScalingListGroupsDescribeFilterOptions.ss +0 -7
  102. package/internal/AwsCredentials.js +0 -32
  103. package/internal/AwsPresignedUrlV4.js +0 -100
  104. package/internal/Crc32.js +0 -93
  105. package/internal/EC2ListInstancesDescribeFilterOptions.ss +0 -91
  106. package/internal/RetryAwsErrors.js +0 -21
  107. package/internal/StreamString.js +0 -14
  108. package/internal/StringStream.js +0 -15
  109. package/internal/arrayPush.js +0 -14
  110. package/internal/asyncIterableTake.js +0 -18
  111. package/internal/callPropBinary.js +0 -19
  112. package/internal/callPropUnary.js +0 -18
  113. package/internal/createExpressionAttributeNames.js +0 -53
  114. package/internal/createExpressionAttributeValues.js +0 -23
  115. package/internal/createFilterExpression.js +0 -32
  116. package/internal/createKeyConditionExpression.js +0 -32
  117. package/internal/createUpdateServiceSpec.js +0 -260
  118. package/internal/createUpdateServiceSpec.test.js +0 -396
  119. package/internal/filterExists.js +0 -7
  120. package/internal/filterExistsAndNotEmpty.js +0 -12
  121. package/internal/fixtures/csr.pem +0 -17
  122. package/internal/fixtures/my-private-root-ca.cert.pem +0 -22
  123. package/internal/fixtures/my-private-root-ca.privkey.pem +0 -28
  124. package/internal/fixtures/privkey.pem +0 -28
  125. package/internal/getFirstKey.js +0 -11
  126. package/internal/getFirstValue.js +0 -11
  127. package/internal/has.js +0 -6
  128. package/internal/hashJSON.js +0 -13
  129. package/internal/inspect.js +0 -6
  130. package/internal/isArray.js +0 -11
  131. package/internal/isPromise.js +0 -4
  132. package/internal/join.js +0 -13
  133. package/internal/make-certs.sh +0 -34
  134. package/internal/mapKeys.js +0 -29
  135. package/internal/match.js +0 -3
  136. package/internal/objectFilterKeys.js +0 -21
  137. package/internal/parseJSON.js +0 -4
  138. package/internal/parsePath.js +0 -19
  139. package/internal/parseRedisConnectionString.js +0 -36
  140. package/internal/parseRedisConnectionString.test.js +0 -22
  141. package/internal/pathJoin.js +0 -13
  142. package/internal/pathResolve.js +0 -13
  143. package/internal/pathWalk.js +0 -56
  144. package/internal/pathWalk.test.js +0 -25
  145. package/internal/replace.js +0 -3
  146. package/internal/sha256.js +0 -6
  147. package/internal/sleep.js +0 -14
  148. package/internal/slice.js +0 -4
  149. package/internal/split.js +0 -5
  150. package/internal/startsWith.js +0 -5
  151. package/internal/streamToString.js +0 -14
  152. package/internal/stringifyJSON.js +0 -3
  153. package/internal/toArray.js +0 -13
  154. package/internal/trim.js +0 -3
  155. package/media-stream-fixture-aws-keynote.txt +0 -366
  156. package/teardown.js +0 -42
  157. package/teardown.test.js +0 -63
  158. package/test.js +0 -48
package/Archive.js CHANGED
@@ -17,7 +17,7 @@ const pick = require('rubico/pick')
17
17
  *
18
18
  * @synopsis
19
19
  * ```coffeescript [specscript]
20
- * new Archive(base Object<path=>(content string)>) -> Archive
20
+ * new Archive(base Object<string>) -> archive Archive
21
21
  * ```
22
22
  */
23
23
  const Archive = function (base) {
@@ -33,9 +33,11 @@ const Archive = function (base) {
33
33
  *
34
34
  * @synopsis
35
35
  * ```coffeescript [specscript]
36
- * new Archive(base?).tar(path string, options {
36
+ * module tar 'https://github.com/mafintosh/tar-stream'
37
+ *
38
+ * archive.tar(path string, options {
37
39
  * ignore: Array<string>, // paths or names to ignore
38
- * }) -> HotReadableStream
40
+ * }) -> pack tar.Pack
39
41
  * ```
40
42
  *
41
43
  * @description
@@ -75,15 +77,17 @@ Archive.prototype.tar = function archiveTar(path, options) {
75
77
  *
76
78
  * @synopsis
77
79
  * ```coffeescript [specscript]
78
- * new Archive(base?).untar(
79
- * archive Archive,
80
+ * module tar 'https://github.com/mafintosh/tar-stream'
81
+ *
82
+ * archive.untar(
83
+ * pack tar.Pack,
80
84
  * options {
81
85
  * ignore: Array<string>, // paths or names to ignore
82
86
  * },
83
87
  * ) -> Map<(header EntryHeader)=>(stream EntryStream)>
84
88
  * ```
85
89
  */
86
- Archive.prototype.untar = function archiveUntar(archive) {
90
+ Archive.prototype.untar = function archiveUntar(pack) {
87
91
  const extractStream = tar.extract(),
88
92
  extracted = new Map()
89
93
  return new Promise((resolve, reject) => {
@@ -94,7 +98,7 @@ Archive.prototype.untar = function archiveUntar(archive) {
94
98
  })
95
99
  extractStream.on('finish', thunkify(resolve, extracted))
96
100
  extractStream.on('error', reject)
97
- archive.pipe(extractStream)
101
+ pack.pipe(extractStream)
98
102
  })
99
103
  }
100
104
 
package/AwsCredentials.js CHANGED
@@ -1,70 +1,68 @@
1
1
  require('rubico/global')
2
2
  const fs = require('fs')
3
- const nodePath = require('path')
4
- const pathResolve = require('./internal/pathResolve')
3
+ const resolvePath = require('./internal/resolvePath')
5
4
 
6
5
  /**
7
6
  * @name AwsCredentials
8
7
  *
9
8
  * @synopsis
10
9
  * ```coffeescript [specscript]
11
- * AwsCredentials(options {
12
- * profile?: string,
13
- * credentialsFileDir?: string,
14
- * }) -> awsCreds {
10
+ * AwsCredentials(profile string, options? {
11
+ * credentialsFileDirname: string
12
+ * credentialsFilename: string,
13
+ * recurse: boolean,
14
+ * }) -> awsCreds Promise<{
15
15
  * accessKeyId: string,
16
16
  * secretAccessKey: string,
17
- * }
18
- *
19
- * AwsCredentials(profile string) -> awsCreds {
20
- * accessKeyId: string,
21
- * secretAccessKey: string,
22
- * }
17
+ * region: string,
18
+ * }>
23
19
  * ```
24
20
  */
25
21
 
26
- const AwsCredentials = async function (options = {}) {
27
- if (process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY) {
28
- const awsCreds = {
29
- accessKeyId: process.env.AWS_ACCESS_KEY_ID,
30
- secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
31
- }
32
- if (process.env.AWS_REGION) {
33
- awsCreds.region = process.env.AWS_REGION
34
- }
35
- return awsCreds
22
+ const AwsCredentials = async function (profile, options = {}) {
23
+ if (profile == null) {
24
+ profile = 'default'
36
25
  }
37
26
 
38
- const profile = (
39
- typeof options == 'string' ? options : options.profile
40
- ) ?? 'default'
41
-
42
- let credentialsFileDir =
43
- options.credentialsFileDir ?? pathResolve(process.cwd())
27
+ const recurse = options.recurse ?? true
28
+ const credentialsFileDirname = options.credentialsFileDirname ?? '.aws'
29
+ const credentialsFilename = options.credentialsFilename ?? 'credentials'
30
+ let credentialsFileDir = resolvePath(process.cwd())
44
31
  let lines = ''
45
- while (credentialsFileDir != '/') {
32
+ while (recurse && credentialsFileDir != '/') {
46
33
  const credentialsFilePath =
47
- pathResolve(credentialsFileDir, '.aws/credentials')
34
+ resolvePath(credentialsFileDir, `${credentialsFileDirname}/${credentialsFilename}`)
48
35
  if (fs.existsSync(credentialsFilePath)) {
49
- lines = await (
50
- fs.promises.readFile(credentialsFilePath)
51
- .then(buffer => `${buffer}`.split('\n'))
52
- )
36
+ lines = await fs.promises.readFile(credentialsFilePath)
37
+ .then(buffer => buffer.toString('utf8').split('\n'))
53
38
  break
54
39
  }
55
- credentialsFileDir = pathResolve(credentialsFileDir, '..')
40
+ credentialsFileDir = resolvePath(credentialsFileDir, '..')
41
+ }
42
+
43
+ if (lines == '') {
44
+ throw new Error('Missing .aws/credentials file')
56
45
  }
57
46
 
58
47
  const startingLineNumber = lines.findIndex(line => line == `[${profile}]`)
59
48
 
60
- const accessKeyId = lines.find(
49
+ const accessKeyId = startingLineNumber == -1 ? undefined : lines.find(
61
50
  (line, index) => index > startingLineNumber
62
- && line.startsWith('aws_access_key_id')
63
- ).split(' = ')[1]
64
- const secretAccessKey = lines.find(
51
+ && line.startsWith('aws_access_key_id')
52
+ && index - startingLineNumber < 3
53
+ )?.split(' = ')[1]
54
+ const secretAccessKey = startingLineNumber == -1 ? undefined : lines.find(
65
55
  (line, index) => index > startingLineNumber
66
- && line.startsWith('aws_secret_access_key')
67
- ).split(' = ')[1]
56
+ && line.startsWith('aws_secret_access_key')
57
+ && index - startingLineNumber < 3
58
+ )?.split(' = ')[1]
59
+
60
+ if (accessKeyId == null) {
61
+ throw new Error(`unable to find aws_access_key_id for profile ${profile}`)
62
+ }
63
+ if (secretAccessKey == null) {
64
+ throw new Error(`unable to find aws_secret_access_key for profile ${profile}`)
65
+ }
68
66
 
69
67
  return { accessKeyId, secretAccessKey }
70
68
  }