presidium 0.16.22 → 0.16.23

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/DynamoIndex.js CHANGED
@@ -150,6 +150,9 @@ DynamoIndex.prototype.query = async function dynamoIndexQuery(
150
150
  }
151
151
 
152
152
  const ExpressionAttributeNames = pipe([
153
+ ...keyConditionStatements, ...filterExpressionStatements
154
+ ], [
155
+ filter(statement => statement.includes(':')),
153
156
  fork([
154
157
  map(
155
158
  statement => statement.trim().startsWith('begins_with')
@@ -169,22 +172,27 @@ DynamoIndex.prototype.query = async function dynamoIndexQuery(
169
172
  map(field => ({ [`#${hashJSON(field)}`]: field })),
170
173
  {},
171
174
  ),
172
- ])([...keyConditionStatements, ...filterExpressionStatements])
175
+ ])
173
176
 
174
177
  const ExpressionAttributeValues = map.entries(
175
178
  ([placeholder, value]) => [`:${placeholder}`, Dynamo.AttributeValue(value)],
176
179
  )(values)
177
180
 
178
- const KeyConditionExpression = keyConditionStatements.map(function (statement) {
179
- if (statement.startsWith('begins_with')) {
180
- const [field, prefix] = statement // 'begins_with(name, :prefix)'
181
- .split(/[()]/)[1] // 'name, :prefix'
182
- .split(',').map(trim) // ['name', ':prefix']
183
- return `begins_with(#${hashJSON(field)}, ${prefix})`
184
- }
185
- const [field, rest] = statement.split(/ (.+)/)
186
- return `#${hashJSON(field)} ${rest}`
187
- }).join(' AND ')
181
+ const KeyConditionExpression = keyConditionStatements
182
+ .filter(statement => statement.includes(':'))
183
+ .map(statement => {
184
+ if (statement.startsWith('begins_with')) {
185
+ const [field, prefix] = statement // 'begins_with(name, :prefix)'
186
+ .split(/[()]/)[1] // 'name, :prefix'
187
+ .split(',').map(trim) // ['name', ':prefix']
188
+ return `begins_with(#${hashJSON(field)}, ${prefix})`
189
+ }
190
+ const [field, rest] = statement.split(/ (.+)/)
191
+ return `#${hashJSON(field)} ${rest}`
192
+ })
193
+ .join(' AND ')
194
+
195
+ console.log(KeyConditionExpression)
188
196
 
189
197
  const FilterExpression = filterExpressionStatements.map(function (statement) {
190
198
  if (statement.startsWith('begins_with')) {
@@ -107,6 +107,29 @@ const test = new Test('DynamoIndex', DynamoIndex)
107
107
  ScannedCount: 2
108
108
  })
109
109
 
110
+ assert.deepEqual(
111
+ await index.query('status = :status AND createTime > 1000', {
112
+ status: 'waitlist',
113
+ }),
114
+ {
115
+ Items: [
116
+ {
117
+ createTime: { N: '1001' },
118
+ id: { S: '2' },
119
+ status: { S: 'waitlist' },
120
+ name: { S: 'geo' },
121
+ },
122
+ {
123
+ createTime: { N: '1002' },
124
+ id: { S: '3' },
125
+ status: { S: 'waitlist' },
126
+ name: { S: 'john' },
127
+ }
128
+ ],
129
+ Count: 2,
130
+ ScannedCount: 2
131
+ })
132
+
110
133
  assert.deepEqual(
111
134
  await index.query('status = :status AND createTime BETWEEN :lower AND :upper', {
112
135
  status: 'waitlist',
package/Gzip.js CHANGED
@@ -7,6 +7,8 @@ const StringStream = require('./internal/StringStream')
7
7
  * @synopsis
8
8
  * ```coffeescript [specscript]
9
9
  * Gzip(raw string) -> gzip stream
10
+ *
11
+ * Gzip() -> gzip stream
10
12
  * ```
11
13
  *
12
14
  * @description
@@ -18,6 +20,9 @@ const StringStream = require('./internal/StringStream')
18
20
  */
19
21
 
20
22
  const Gzip = function (raw) {
23
+ if (raw == null) {
24
+ return zlib.createGzip()
25
+ }
21
26
  return StringStream(raw).pipe(zlib.createGzip())
22
27
  }
23
28
 
package/Gzip.test.js CHANGED
@@ -3,13 +3,24 @@ const assert = require('assert')
3
3
  const zlib = require('zlib')
4
4
  const Gzip = require('./Gzip')
5
5
  const StreamString = require('./internal/StreamString')
6
+ const StringStream = require('./internal/StringStream')
6
7
 
7
8
  const test = new Test('Gzip', async function () {
8
9
  const raw = 'aaaaabbbbbbbcccc'
9
- const transformed = await StreamString(
10
- Gzip(raw).pipe(zlib.createGunzip())
11
- )
12
- assert.equal(raw, transformed)
10
+
11
+ {
12
+ const transformed = await StreamString(
13
+ Gzip(raw).pipe(zlib.createGunzip())
14
+ )
15
+ assert.equal(raw, transformed)
16
+ }
17
+
18
+ {
19
+ const transformed = await StreamString(
20
+ StringStream(raw).pipe(Gzip()).pipe(zlib.createGunzip())
21
+ )
22
+ assert.equal(raw, transformed)
23
+ }
13
24
  }).case()
14
25
 
15
26
  if (process.argv[1] == __filename) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "presidium",
3
- "version": "0.16.22",
3
+ "version": "0.16.23",
4
4
  "description": "A library for creating web services",
5
5
  "author": "Richard Tong",
6
6
  "license": "MIT",