@cumulus/db 18.3.1 → 18.3.3
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/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { PostgresRule, PostgresRuleRecord, } from './types/rule';
|
|
|
16
16
|
export { PostgresGranule, PostgresGranuleRecord, } from './types/granule';
|
|
17
17
|
export { PostgresPdr, PostgresPdrRecord, } from './types/pdr';
|
|
18
18
|
export { PostgresFile, PostgresFileRecord, } from './types/file';
|
|
19
|
+
export { PostgresGranuleExecution, } from './types/granule-execution';
|
|
19
20
|
export { translateApiAsyncOperationToPostgresAsyncOperation, translatePostgresAsyncOperationToApiAsyncOperation, } from './translate/async_operations';
|
|
20
21
|
export { translateApiFiletoPostgresFile, translatePostgresFileToApiFile, } from './translate/file';
|
|
21
22
|
export { translateApiCollectionToPostgresCollection, translatePostgresCollectionToApiCollection, } from './translate/collections';
|
|
@@ -4,9 +4,20 @@ import { PostgresGranuleExecution } from '../types/granule-execution';
|
|
|
4
4
|
export default class GranulesExecutionsPgModel {
|
|
5
5
|
readonly tableName: TableNames;
|
|
6
6
|
constructor();
|
|
7
|
-
create(knexTransaction: Knex.Transaction, item: PostgresGranuleExecution): Promise<number[]>;
|
|
8
|
-
exists(knexTransaction: Knex.Transaction, item: PostgresGranuleExecution): Promise<boolean>;
|
|
9
|
-
upsert(knexTransaction: Knex.Transaction, item: PostgresGranuleExecution): Promise<any[]>;
|
|
7
|
+
create(knexTransaction: Knex | Knex.Transaction, item: PostgresGranuleExecution): Promise<number[]>;
|
|
8
|
+
exists(knexTransaction: Knex | Knex.Transaction, item: PostgresGranuleExecution): Promise<boolean>;
|
|
9
|
+
upsert(knexTransaction: Knex | Knex.Transaction, item: PostgresGranuleExecution): Promise<any[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Creates multiple granuleExecutions in Postgres
|
|
12
|
+
*
|
|
13
|
+
* @param {Knex | Knex.Transaction} knexOrTransaction - DB client or transaction
|
|
14
|
+
* @param {PostgresGranuleExecution[]} items - Records to insert into the DB
|
|
15
|
+
* @param {string | Array<string>} returningFields - A string or array of strings
|
|
16
|
+
* of columns to return. Defaults to 'cumulus_id'.
|
|
17
|
+
* @returns {Promise<PostgresGranuleExecution[]>} Returns an array of objects
|
|
18
|
+
* from the specified column(s) from returningFields.
|
|
19
|
+
*/
|
|
20
|
+
insert(knexOrTransaction: Knex | Knex.Transaction, items: PostgresGranuleExecution[], returningFields?: string | string[]): Promise<PostgresGranuleExecution[]>;
|
|
10
21
|
/**
|
|
11
22
|
* Get execution_cumulus_id column values from the granule_cumulus_id
|
|
12
23
|
*
|
|
@@ -37,6 +48,9 @@ export default class GranulesExecutionsPgModel {
|
|
|
37
48
|
_intersectProps: {};
|
|
38
49
|
_unionProps: never;
|
|
39
50
|
}[]>;
|
|
51
|
+
count(knexOrTransaction: Knex | Knex.Transaction, params: ([string, string, string] | [Partial<PostgresGranuleExecution>])[]): Promise<{
|
|
52
|
+
[k: string]: string | number;
|
|
53
|
+
}[]>;
|
|
40
54
|
}
|
|
41
55
|
export { GranulesExecutionsPgModel };
|
|
42
56
|
//# sourceMappingURL=granules-executions.d.ts.map
|
|
@@ -22,6 +22,21 @@ class GranulesExecutionsPgModel {
|
|
|
22
22
|
.merge()
|
|
23
23
|
.returning('*');
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates multiple granuleExecutions in Postgres
|
|
27
|
+
*
|
|
28
|
+
* @param {Knex | Knex.Transaction} knexOrTransaction - DB client or transaction
|
|
29
|
+
* @param {PostgresGranuleExecution[]} items - Records to insert into the DB
|
|
30
|
+
* @param {string | Array<string>} returningFields - A string or array of strings
|
|
31
|
+
* of columns to return. Defaults to 'cumulus_id'.
|
|
32
|
+
* @returns {Promise<PostgresGranuleExecution[]>} Returns an array of objects
|
|
33
|
+
* from the specified column(s) from returningFields.
|
|
34
|
+
*/
|
|
35
|
+
async insert(knexOrTransaction, items, returningFields = '*') {
|
|
36
|
+
return await knexOrTransaction(this.tableName)
|
|
37
|
+
.insert(items)
|
|
38
|
+
.returning(returningFields);
|
|
39
|
+
}
|
|
25
40
|
/**
|
|
26
41
|
* Get execution_cumulus_id column values from the granule_cumulus_id
|
|
27
42
|
*
|
|
@@ -65,6 +80,21 @@ class GranulesExecutionsPgModel {
|
|
|
65
80
|
return knexTransaction(this.tableName)
|
|
66
81
|
.where(query);
|
|
67
82
|
}
|
|
83
|
+
async count(knexOrTransaction, params) {
|
|
84
|
+
const query = knexOrTransaction(this.tableName)
|
|
85
|
+
.where((builder) => {
|
|
86
|
+
params.forEach((param) => {
|
|
87
|
+
if (param.length === 3) {
|
|
88
|
+
builder.where(...param);
|
|
89
|
+
}
|
|
90
|
+
if (param.length === 1) {
|
|
91
|
+
builder.where(param[0]);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
})
|
|
95
|
+
.count();
|
|
96
|
+
return await query;
|
|
97
|
+
}
|
|
68
98
|
}
|
|
69
99
|
exports.default = GranulesExecutionsPgModel;
|
|
70
100
|
exports.GranulesExecutionsPgModel = GranulesExecutionsPgModel;
|
package/dist/test-utils.js
CHANGED
|
@@ -51,7 +51,7 @@ const fakeRuleRecordFactory = (params) => ({
|
|
|
51
51
|
exports.fakeRuleRecordFactory = fakeRuleRecordFactory;
|
|
52
52
|
const fakeCollectionRecordFactory = (params) => ({
|
|
53
53
|
name: (0, crypto_random_string_1.default)({ length: 5 }),
|
|
54
|
-
version: '
|
|
54
|
+
version: '001',
|
|
55
55
|
sample_file_name: 'file.txt',
|
|
56
56
|
granule_id_extraction_regex: 'fake-regex',
|
|
57
57
|
granule_id_validation_regex: 'fake-regex',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cumulus/db",
|
|
3
|
-
"version": "18.3.
|
|
3
|
+
"version": "18.3.3",
|
|
4
4
|
"description": "Utilities for working with the Cumulus DB",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@aws-sdk/client-secrets-manager": "^3.447.0",
|
|
36
|
-
"@cumulus/aws-client": "18.3.
|
|
37
|
-
"@cumulus/common": "18.3.
|
|
38
|
-
"@cumulus/errors": "18.3.
|
|
39
|
-
"@cumulus/logger": "18.3.
|
|
40
|
-
"@cumulus/message": "18.3.
|
|
41
|
-
"@cumulus/types": "18.3.
|
|
36
|
+
"@cumulus/aws-client": "18.3.3",
|
|
37
|
+
"@cumulus/common": "18.3.3",
|
|
38
|
+
"@cumulus/errors": "18.3.3",
|
|
39
|
+
"@cumulus/logger": "18.3.3",
|
|
40
|
+
"@cumulus/message": "18.3.3",
|
|
41
|
+
"@cumulus/types": "18.3.3",
|
|
42
42
|
"crypto-random-string": "^3.2.0",
|
|
43
43
|
"is-valid-hostname": "1.0.2",
|
|
44
44
|
"knex": "2.4.1",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/uuid": "^8.0.0"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "2750792b9913f7bbad429d4b942ef4e59c5ef3d2"
|
|
54
54
|
}
|