triangle-utils 1.4.74 → 1.4.76
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/dist/src/UtilsDynamoDB.d.ts +4 -0
- package/dist/src/UtilsDynamoDB.js +9 -5
- package/dist/src/types/ApplicationConfig.d.ts +1 -0
- package/dist/src/types/ApplicationConfig.js +4 -1
- package/dist/src/types/GlobalConfig.d.ts +0 -1
- package/dist/src/types/GlobalConfig.js +0 -3
- package/package.json +1 -1
- package/src/UtilsDynamoDB.ts +17 -9
- package/src/types/ApplicationConfig.ts +4 -1
- package/src/types/GlobalConfig.ts +0 -3
|
@@ -9,6 +9,7 @@ export declare class UtilsDynamoDB {
|
|
|
9
9
|
attribute_names?: string[];
|
|
10
10
|
segment_id?: number;
|
|
11
11
|
num_segments?: number;
|
|
12
|
+
last_key?: Record<string, any>;
|
|
12
13
|
}): Promise<Record<string, any>[]>;
|
|
13
14
|
get(table: string, key: Record<string, any>, consistent?: boolean): Promise<Record<string, any> | undefined>;
|
|
14
15
|
get_max(table_index_name: string, primary_key: Record<string, string | number>): Promise<Record<string, any> | undefined>;
|
|
@@ -20,6 +21,7 @@ export declare class UtilsDynamoDB {
|
|
|
20
21
|
defined_attribute_names?: string[];
|
|
21
22
|
attribute_names?: string[];
|
|
22
23
|
max_num_items?: number;
|
|
24
|
+
last_key?: Record<string, any>;
|
|
23
25
|
}): Promise<Record<string, any>[]>;
|
|
24
26
|
query_prefix(table_index_name: string, primary_key: Record<string, any>, secondary_key_prefix: Record<string, string>, options?: {
|
|
25
27
|
reverse?: boolean;
|
|
@@ -29,6 +31,7 @@ export declare class UtilsDynamoDB {
|
|
|
29
31
|
defined_attribute_names?: string[];
|
|
30
32
|
attribute_names?: string[];
|
|
31
33
|
max_num_items?: number;
|
|
34
|
+
last_key?: Record<string, any>;
|
|
32
35
|
}): Promise<Record<string, any>[]>;
|
|
33
36
|
query_range(table_index_name: string, primary_key: Record<string, any>, secondary_key_range: Record<string, (string | number)[]>, options?: {
|
|
34
37
|
reverse?: boolean;
|
|
@@ -38,6 +41,7 @@ export declare class UtilsDynamoDB {
|
|
|
38
41
|
defined_attribute_names?: string[];
|
|
39
42
|
attribute_names?: string[];
|
|
40
43
|
max_num_items?: number;
|
|
44
|
+
last_key?: Record<string, any>;
|
|
41
45
|
}): Promise<Record<string, any>[]>;
|
|
42
46
|
set(table_name: string, key: Record<string, any>, attributes: Record<string, any>): Promise<void>;
|
|
43
47
|
append(table_name: string, key: Record<string, any>, attributes: Record<string, any[]>): Promise<void>;
|
|
@@ -64,7 +64,7 @@ function convert_input(input) {
|
|
|
64
64
|
}
|
|
65
65
|
async function compile_pages(request, f, compile = true) {
|
|
66
66
|
const items = [];
|
|
67
|
-
let last_eval_key =
|
|
67
|
+
let last_eval_key = request.ExclusiveStartKey;
|
|
68
68
|
while (true) {
|
|
69
69
|
const request_page = {
|
|
70
70
|
...request,
|
|
@@ -130,7 +130,8 @@ export class UtilsDynamoDB {
|
|
|
130
130
|
FilterExpression: filter_expression.length > 0 ? filter_expression : undefined,
|
|
131
131
|
ProjectionExpression: projection_expression.length > 0 ? projection_expression : undefined,
|
|
132
132
|
Segment: i,
|
|
133
|
-
TotalSegments: num_segments
|
|
133
|
+
TotalSegments: num_segments,
|
|
134
|
+
ExclusiveStartKey: options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
|
|
134
135
|
};
|
|
135
136
|
iterators.push(compile_pages(request, (request) => this.dynamodb.scan(request)));
|
|
136
137
|
}
|
|
@@ -228,7 +229,8 @@ export class UtilsDynamoDB {
|
|
|
228
229
|
ProjectionExpression: projection_expression.length > 0 ? projection_expression : undefined,
|
|
229
230
|
KeyConditionExpression: Object.keys(primary_key).map(key => "#" + key + " = :" + key).join(" AND "),
|
|
230
231
|
ScanIndexForward: !reverse,
|
|
231
|
-
Limit: options.max_num_items
|
|
232
|
+
Limit: options.max_num_items,
|
|
233
|
+
ExclusiveStartKey: options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
|
|
232
234
|
};
|
|
233
235
|
const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile);
|
|
234
236
|
// .then(async items => index_name === undefined || !project ? items :
|
|
@@ -289,7 +291,8 @@ export class UtilsDynamoDB {
|
|
|
289
291
|
...Object.keys(secondary_key_prefix).map(key => "begins_with(#" + key + ", :" + key + ")")
|
|
290
292
|
].join(" AND "),
|
|
291
293
|
ScanIndexForward: !reverse,
|
|
292
|
-
Limit: options.max_num_items
|
|
294
|
+
Limit: options.max_num_items,
|
|
295
|
+
ExclusiveStartKey: options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
|
|
293
296
|
};
|
|
294
297
|
const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile);
|
|
295
298
|
// .then(async items => index_name === undefined || !project ? items :
|
|
@@ -353,7 +356,8 @@ export class UtilsDynamoDB {
|
|
|
353
356
|
...Object.keys(secondary_key_range).map(key => "(#" + key + " BETWEEN :" + key + "_min AND :" + key + "_max)")
|
|
354
357
|
].join(" AND "),
|
|
355
358
|
ScanIndexForward: !reverse,
|
|
356
|
-
Limit: options.max_num_items
|
|
359
|
+
Limit: options.max_num_items,
|
|
360
|
+
ExclusiveStartKey: options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
|
|
357
361
|
};
|
|
358
362
|
const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile);
|
|
359
363
|
// .then(async items => index_name === undefined || !project ? items :
|
|
@@ -5,6 +5,7 @@ export declare class ApplicationConfig {
|
|
|
5
5
|
readonly client_dev_url: string;
|
|
6
6
|
readonly api_url: string;
|
|
7
7
|
readonly api_dev_url: string;
|
|
8
|
+
readonly anthropic_api_key?: string;
|
|
8
9
|
readonly [x: string]: any;
|
|
9
10
|
constructor(application_config: ApplicationConfig);
|
|
10
11
|
static is(application_config: any): application_config is ApplicationConfig;
|
|
@@ -5,6 +5,7 @@ export class ApplicationConfig {
|
|
|
5
5
|
client_dev_url;
|
|
6
6
|
api_url;
|
|
7
7
|
api_dev_url;
|
|
8
|
+
anthropic_api_key;
|
|
8
9
|
constructor(application_config) {
|
|
9
10
|
if (!ApplicationConfig.is(application_config)) {
|
|
10
11
|
throw Error("Invalid input.");
|
|
@@ -15,6 +16,7 @@ export class ApplicationConfig {
|
|
|
15
16
|
this.client_dev_url = application_config.client_dev_url;
|
|
16
17
|
this.api_url = application_config.api_url;
|
|
17
18
|
this.api_dev_url = application_config.api_dev_url;
|
|
19
|
+
this.anthropic_api_key = application_config.anthropic_api_key;
|
|
18
20
|
}
|
|
19
21
|
static is(application_config) {
|
|
20
22
|
return (application_config !== undefined &&
|
|
@@ -23,6 +25,7 @@ export class ApplicationConfig {
|
|
|
23
25
|
typeof application_config.client_url === "string" &&
|
|
24
26
|
typeof application_config.client_dev_url === "string" &&
|
|
25
27
|
typeof application_config.api_url === "string" &&
|
|
26
|
-
typeof application_config.api_dev_url === "string"
|
|
28
|
+
typeof application_config.api_dev_url === "string" &&
|
|
29
|
+
(application_config.anthropic_api_key === undefined || typeof application_config.anthropic_api_key === "string"));
|
|
27
30
|
}
|
|
28
31
|
}
|
|
@@ -12,7 +12,6 @@ export declare class GlobalConfig {
|
|
|
12
12
|
readonly scraping_bee_api_key: string;
|
|
13
13
|
readonly twitter_api_key: string;
|
|
14
14
|
readonly youtube_api_key: string;
|
|
15
|
-
readonly anthropic_api_key: string;
|
|
16
15
|
readonly xai_api_key: string;
|
|
17
16
|
readonly [x: string]: any;
|
|
18
17
|
constructor(global_config: GlobalConfig);
|
|
@@ -12,7 +12,6 @@ export class GlobalConfig {
|
|
|
12
12
|
scraping_bee_api_key;
|
|
13
13
|
twitter_api_key;
|
|
14
14
|
youtube_api_key;
|
|
15
|
-
anthropic_api_key;
|
|
16
15
|
xai_api_key;
|
|
17
16
|
constructor(global_config) {
|
|
18
17
|
if (!GlobalConfig.is(global_config)) {
|
|
@@ -31,7 +30,6 @@ export class GlobalConfig {
|
|
|
31
30
|
this.scraping_bee_api_key = global_config.scraping_bee_api_key;
|
|
32
31
|
this.twitter_api_key = global_config.twitter_api_key;
|
|
33
32
|
this.youtube_api_key = global_config.youtube_api_key;
|
|
34
|
-
this.anthropic_api_key = global_config.anthropic_api_key;
|
|
35
33
|
this.xai_api_key = global_config.xai_api_key;
|
|
36
34
|
}
|
|
37
35
|
static is(global_config) {
|
|
@@ -49,7 +47,6 @@ export class GlobalConfig {
|
|
|
49
47
|
typeof global_config.scraping_bee_api_key === "string" &&
|
|
50
48
|
typeof global_config.twitter_api_key === "string" &&
|
|
51
49
|
typeof global_config.youtube_api_key === "string" &&
|
|
52
|
-
typeof global_config.anthropic_api_key === "string" &&
|
|
53
50
|
typeof global_config.xai_api_key === "string");
|
|
54
51
|
}
|
|
55
52
|
}
|
package/package.json
CHANGED
package/src/UtilsDynamoDB.ts
CHANGED
|
@@ -64,7 +64,7 @@ async function compile_pages(
|
|
|
64
64
|
compile : boolean = true
|
|
65
65
|
) : Promise<any[]> {
|
|
66
66
|
const items = []
|
|
67
|
-
let last_eval_key : Record<string, AttributeValue> | undefined =
|
|
67
|
+
let last_eval_key : Record<string, AttributeValue> | undefined = request.ExclusiveStartKey
|
|
68
68
|
while (true) {
|
|
69
69
|
const request_page : ScanCommandInput|QueryCommandInput = {
|
|
70
70
|
...request,
|
|
@@ -113,7 +113,8 @@ export class UtilsDynamoDB {
|
|
|
113
113
|
defined_attribute_names? : string[],
|
|
114
114
|
attribute_names? : string[],
|
|
115
115
|
segment_id? : number
|
|
116
|
-
num_segments? : number
|
|
116
|
+
num_segments? : number,
|
|
117
|
+
last_key? : Record<string, any>
|
|
117
118
|
} = {}
|
|
118
119
|
) : Promise<Record<string, any>[]> {
|
|
119
120
|
const table_name : string = table_index_name.split(":")[0]
|
|
@@ -151,7 +152,8 @@ export class UtilsDynamoDB {
|
|
|
151
152
|
FilterExpression : filter_expression.length > 0 ? filter_expression : undefined,
|
|
152
153
|
ProjectionExpression : projection_expression.length > 0 ? projection_expression : undefined,
|
|
153
154
|
Segment : i,
|
|
154
|
-
TotalSegments : num_segments
|
|
155
|
+
TotalSegments : num_segments,
|
|
156
|
+
ExclusiveStartKey : options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
|
|
155
157
|
}
|
|
156
158
|
iterators.push(compile_pages(request, (request : ScanCommandInput) => this.dynamodb.scan(request)))
|
|
157
159
|
}
|
|
@@ -232,7 +234,8 @@ export class UtilsDynamoDB {
|
|
|
232
234
|
undefined_attribute_names? : string[],
|
|
233
235
|
defined_attribute_names? : string[],
|
|
234
236
|
attribute_names? : string[],
|
|
235
|
-
max_num_items? : number
|
|
237
|
+
max_num_items? : number,
|
|
238
|
+
last_key? : Record<string, any>
|
|
236
239
|
} = {}
|
|
237
240
|
) : Promise<Record<string, any>[]>{
|
|
238
241
|
const table_name : string = table_index_name.split(":")[0]
|
|
@@ -277,7 +280,8 @@ export class UtilsDynamoDB {
|
|
|
277
280
|
ProjectionExpression : projection_expression.length > 0 ? projection_expression : undefined,
|
|
278
281
|
KeyConditionExpression: Object.keys(primary_key).map(key => "#" + key + " = :" + key).join(" AND "),
|
|
279
282
|
ScanIndexForward : !reverse,
|
|
280
|
-
Limit : options.max_num_items
|
|
283
|
+
Limit : options.max_num_items,
|
|
284
|
+
ExclusiveStartKey : options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
|
|
281
285
|
}
|
|
282
286
|
const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile)
|
|
283
287
|
// .then(async items => index_name === undefined || !project ? items :
|
|
@@ -303,7 +307,8 @@ export class UtilsDynamoDB {
|
|
|
303
307
|
undefined_attribute_names? : string[],
|
|
304
308
|
defined_attribute_names? : string[],
|
|
305
309
|
attribute_names? : string[],
|
|
306
|
-
max_num_items? : number
|
|
310
|
+
max_num_items? : number,
|
|
311
|
+
last_key? : Record<string, any>
|
|
307
312
|
} = {}
|
|
308
313
|
) : Promise<Record<string, any>[]>{
|
|
309
314
|
const table_name : string = table_index_name.split(":")[0]
|
|
@@ -355,7 +360,8 @@ export class UtilsDynamoDB {
|
|
|
355
360
|
...Object.keys(secondary_key_prefix).map(key => "begins_with(#" + key + ", :" + key + ")")
|
|
356
361
|
].join(" AND "),
|
|
357
362
|
ScanIndexForward : !reverse,
|
|
358
|
-
Limit : options.max_num_items
|
|
363
|
+
Limit : options.max_num_items,
|
|
364
|
+
ExclusiveStartKey : options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
|
|
359
365
|
}
|
|
360
366
|
const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile)
|
|
361
367
|
// .then(async items => index_name === undefined || !project ? items :
|
|
@@ -381,7 +387,8 @@ export class UtilsDynamoDB {
|
|
|
381
387
|
undefined_attribute_names? : string[],
|
|
382
388
|
defined_attribute_names? : string[],
|
|
383
389
|
attribute_names? : string[],
|
|
384
|
-
max_num_items? : number
|
|
390
|
+
max_num_items? : number,
|
|
391
|
+
last_key? : Record<string, any>
|
|
385
392
|
} = {}
|
|
386
393
|
) : Promise<Record<string, any>[]>{
|
|
387
394
|
const table_name : string = table_index_name.split(":")[0]
|
|
@@ -436,7 +443,8 @@ export class UtilsDynamoDB {
|
|
|
436
443
|
...Object.keys(secondary_key_range).map(key => "(#" + key + " BETWEEN :" + key + "_min AND :" + key + "_max)")
|
|
437
444
|
].join(" AND "),
|
|
438
445
|
ScanIndexForward : !reverse,
|
|
439
|
-
Limit : options.max_num_items
|
|
446
|
+
Limit : options.max_num_items,
|
|
447
|
+
ExclusiveStartKey : options.last_key !== undefined ? convert_input(options.last_key)?.M : undefined
|
|
440
448
|
}
|
|
441
449
|
const items = await compile_pages(request, (request) => this.dynamodb.query(request), compile)
|
|
442
450
|
// .then(async items => index_name === undefined || !project ? items :
|
|
@@ -6,6 +6,7 @@ export class ApplicationConfig {
|
|
|
6
6
|
readonly client_dev_url : string
|
|
7
7
|
readonly api_url : string
|
|
8
8
|
readonly api_dev_url : string
|
|
9
|
+
readonly anthropic_api_key? : string
|
|
9
10
|
readonly [x : string] : any
|
|
10
11
|
|
|
11
12
|
constructor(application_config : ApplicationConfig) {
|
|
@@ -18,6 +19,7 @@ export class ApplicationConfig {
|
|
|
18
19
|
this.client_dev_url = application_config.client_dev_url
|
|
19
20
|
this.api_url = application_config.api_url
|
|
20
21
|
this.api_dev_url = application_config.api_dev_url
|
|
22
|
+
this.anthropic_api_key = application_config.anthropic_api_key
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
static is(application_config : any) : application_config is ApplicationConfig {
|
|
@@ -28,7 +30,8 @@ export class ApplicationConfig {
|
|
|
28
30
|
typeof application_config.client_url === "string" &&
|
|
29
31
|
typeof application_config.client_dev_url === "string" &&
|
|
30
32
|
typeof application_config.api_url === "string" &&
|
|
31
|
-
typeof application_config.api_dev_url === "string"
|
|
33
|
+
typeof application_config.api_dev_url === "string" &&
|
|
34
|
+
(application_config.anthropic_api_key === undefined || typeof application_config.anthropic_api_key === "string")
|
|
32
35
|
)
|
|
33
36
|
}
|
|
34
37
|
}
|
|
@@ -12,7 +12,6 @@ export class GlobalConfig {
|
|
|
12
12
|
readonly scraping_bee_api_key : string
|
|
13
13
|
readonly twitter_api_key : string
|
|
14
14
|
readonly youtube_api_key : string
|
|
15
|
-
readonly anthropic_api_key : string
|
|
16
15
|
readonly xai_api_key : string
|
|
17
16
|
readonly [x : string] : any
|
|
18
17
|
|
|
@@ -33,7 +32,6 @@ export class GlobalConfig {
|
|
|
33
32
|
this.scraping_bee_api_key = global_config.scraping_bee_api_key
|
|
34
33
|
this.twitter_api_key = global_config.twitter_api_key
|
|
35
34
|
this.youtube_api_key = global_config.youtube_api_key
|
|
36
|
-
this.anthropic_api_key = global_config.anthropic_api_key
|
|
37
35
|
this.xai_api_key = global_config.xai_api_key
|
|
38
36
|
}
|
|
39
37
|
|
|
@@ -53,7 +51,6 @@ export class GlobalConfig {
|
|
|
53
51
|
typeof global_config.scraping_bee_api_key === "string" &&
|
|
54
52
|
typeof global_config.twitter_api_key === "string" &&
|
|
55
53
|
typeof global_config.youtube_api_key === "string" &&
|
|
56
|
-
typeof global_config.anthropic_api_key === "string" &&
|
|
57
54
|
typeof global_config.xai_api_key === "string"
|
|
58
55
|
)
|
|
59
56
|
}
|