triangle-utils 1.0.34 → 1.0.36
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/package.json +3 -2
- package/test.js +6 -3
- package/utils/Utils_DynamoDB.js +11 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "triangle-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.36",
|
|
4
4
|
"main": "Utils.js",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "ISC",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"@aws-sdk/client-s3vectors": "^3.953.0",
|
|
14
14
|
"@aws-sdk/s3-request-presigner": "^3.953.0",
|
|
15
15
|
"nodemailer": "^7.0.11",
|
|
16
|
-
"scrapingbee": "^1.7.6"
|
|
16
|
+
"scrapingbee": "^1.7.6",
|
|
17
|
+
"triangle-utils": "^1.0.34"
|
|
17
18
|
}
|
|
18
19
|
}
|
package/test.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import Utils from "./Utils.js";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
const utils = new Utils({ region : "us-east-
|
|
4
|
+
const utils = new Utils({ region : "us-east-2"})
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const jurisdiction_documents = await utils.dynamodb.scan("jurisdiction_documents", {
|
|
7
|
+
defined_attribute_names : ["s3_filename"],
|
|
8
|
+
undefined_attribute_names : ["vector_keys"]
|
|
9
|
+
})
|
|
7
10
|
|
|
8
|
-
console.log(
|
|
11
|
+
console.log(jurisdiction_documents.length)
|
package/utils/Utils_DynamoDB.js
CHANGED
|
@@ -64,15 +64,24 @@ export default class Utils_DynamoDB {
|
|
|
64
64
|
|
|
65
65
|
async scan(table, options = {}) {
|
|
66
66
|
const filters = options.filters !== undefined ? options.filters : {}
|
|
67
|
+
const undefined_attribute_names = options.undefined_attribute_names !== undefined ? options.undefined_attribute_names : []
|
|
68
|
+
const defined_attribute_names = options.defined_attribute_names !== undefined ? options.defined_attribute_names : []
|
|
67
69
|
const concurrency = options.concurrency !== undefined ? options.concurrency : 1
|
|
68
70
|
const attribute_names = options.attribute_names !== undefined ? options.attribute_names : []
|
|
69
71
|
const iterators = []
|
|
70
72
|
for (let i = 0; i < concurrency; i++) {
|
|
71
73
|
const request = Object.fromEntries(Object.entries({
|
|
72
74
|
TableName : table,
|
|
73
|
-
ExpressionAttributeNames : Object.fromEntries(
|
|
75
|
+
ExpressionAttributeNames : Object.fromEntries(
|
|
76
|
+
[...Object.keys(filters), ...attribute_names, ...undefined_attribute_names, ...defined_attribute_names]
|
|
77
|
+
.map(attribute_name => ["#" + attribute_name, attribute_name])
|
|
78
|
+
),
|
|
74
79
|
ExpressionAttributeValues : Object.fromEntries(Object.entries(filters).map(([attribute_name, attribute_value]) => [":" + attribute_name, convert_input(attribute_value)])),
|
|
75
|
-
FilterExpression :
|
|
80
|
+
FilterExpression : [
|
|
81
|
+
...Object.keys(filters).map(attribute_name => "#" + attribute_name + " = :" + attribute_name),
|
|
82
|
+
...undefined_attribute_names.map(attribute_name => "attribute_not_exists(#" + attribute_name + ")"),
|
|
83
|
+
...defined_attribute_names.map(attribute_name => "attribute_exists(#" + attribute_name + ")")
|
|
84
|
+
].join(" AND "),
|
|
76
85
|
ProjectionExpression : attribute_names.map(attribute_name => "#" + attribute_name).join(", "),
|
|
77
86
|
Segment : i,
|
|
78
87
|
TotalSegments : concurrency
|