@cumulus/db 18.5.1 → 18.5.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
|
@@ -28,7 +28,7 @@ export { translateApiPdrToPostgresPdr, translatePostgresPdrToApiPdr, } from './t
|
|
|
28
28
|
export { getCollectionsByGranuleIds, } from './lib/collection';
|
|
29
29
|
export { batchDeleteExecutionFromDatabaseByCumulusCollectionId, executionArnsFromGranuleIdsAndWorkflowNames, getApiExecutionCumulusIds, getApiGranuleExecutionCumulusIdsByExecution, getExecutionInfoByGranuleCumulusId, getWorkflowNameIntersectFromGranuleIds, newestExecutionArnFromGranuleIdWorkflowName, } from './lib/execution';
|
|
30
30
|
export { getFilesAndGranuleInfoQuery, } from './lib/file';
|
|
31
|
-
export { getApiGranuleCumulusIds, getApiGranuleExecutionCumulusIds, getGranuleCollectionId, getUniqueGranuleByGranuleId, getGranuleByUniqueColumns, upsertGranuleWithExecutionJoinRecord, getGranulesByApiPropertiesQuery, getGranulesByGranuleId, getGranuleAndCollection, } from './lib/granule';
|
|
31
|
+
export { getApiGranuleCumulusIds, getApiGranuleExecutionCumulusIds, getGranuleCollectionId, getUniqueGranuleByGranuleId, getGranuleByUniqueColumns, upsertGranuleWithExecutionJoinRecord, getGranulesByApiPropertiesQuery, getGranulesByGranuleId, getGranuleAndCollection, updateBatchGranulesCollection, } from './lib/granule';
|
|
32
32
|
export { QuerySearchClient, } from './lib/QuerySearchClient';
|
|
33
33
|
export { AsyncOperationPgModel } from './models/async_operation';
|
|
34
34
|
export { BasePgModel } from './models/base';
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.newestExecutionArnFromGranuleIdWorkflowName = exports.getWorkflowNameIntersectFromGranuleIds = exports.getExecutionInfoByGranuleCumulusId = exports.getApiGranuleExecutionCumulusIdsByExecution = exports.getApiExecutionCumulusIds = exports.executionArnsFromGranuleIdsAndWorkflowNames = exports.batchDeleteExecutionFromDatabaseByCumulusCollectionId = exports.getCollectionsByGranuleIds = exports.translatePostgresPdrToApiPdr = exports.translateApiPdrToPostgresPdr = exports.translatePostgresGranuleResultToApiGranule = exports.translatePostgresGranuleToApiGranule = exports.translateApiGranuleToPostgresGranuleWithoutNilsRemoved = exports.translateApiGranuleToPostgresGranule = exports.translatePostgresExecutionToApiExecution = exports.translateApiExecutionToPostgresExecutionWithoutNilsRemoved = exports.translateApiExecutionToPostgresExecution = exports.translateApiRuleToPostgresRuleRaw = exports.translateApiRuleToPostgresRule = exports.translatePostgresRuleToApiRule = exports.translatePostgresProviderToApiProvider = exports.translateApiProviderToPostgresProvider = exports.translatePostgresCollectionToApiCollection = exports.translateApiCollectionToPostgresCollection = exports.translatePostgresFileToApiFile = exports.translateApiFiletoPostgresFile = exports.translatePostgresAsyncOperationToApiAsyncOperation = exports.translateApiAsyncOperationToPostgresAsyncOperation = exports.nullifyUndefinedProviderValues = exports.validateProviderHost = exports.migrationDir = exports.TableNames = exports.createRejectableTransaction = exports.localStackConnectionEnv = exports.getKnexConfig = exports.getKnexClient = exports.isCollisionError = exports.generateLocalTestDb = exports.fakeRuleRecordFactory = exports.fakeProviderRecordFactory = exports.fakePdrRecordFactory = exports.fakeGranuleRecordFactory = exports.fakeFileRecordFactory = exports.fakeExecutionRecordFactory = exports.fakeCollectionRecordFactory = exports.fakeAsyncOperationRecordFactory = exports.destroyLocalTestDb = exports.deleteTestDatabase = exports.createTestDatabase = exports.Knex = void 0;
|
|
27
|
-
exports.RulePgModel = exports.ProviderPgModel = exports.PdrPgModel = exports.GranulesExecutionsPgModel = exports.GranulePgModel = exports.FilePgModel = exports.ExecutionPgModel = exports.CollectionPgModel = exports.BasePgModel = exports.AsyncOperationPgModel = exports.QuerySearchClient = exports.getGranuleAndCollection = exports.getGranulesByGranuleId = exports.getGranulesByApiPropertiesQuery = exports.upsertGranuleWithExecutionJoinRecord = exports.getGranuleByUniqueColumns = exports.getUniqueGranuleByGranuleId = exports.getGranuleCollectionId = exports.getApiGranuleExecutionCumulusIds = exports.getApiGranuleCumulusIds = exports.getFilesAndGranuleInfoQuery = void 0;
|
|
27
|
+
exports.RulePgModel = exports.ProviderPgModel = exports.PdrPgModel = exports.GranulesExecutionsPgModel = exports.GranulePgModel = exports.FilePgModel = exports.ExecutionPgModel = exports.CollectionPgModel = exports.BasePgModel = exports.AsyncOperationPgModel = exports.QuerySearchClient = exports.updateBatchGranulesCollection = exports.getGranuleAndCollection = exports.getGranulesByGranuleId = exports.getGranulesByApiPropertiesQuery = exports.upsertGranuleWithExecutionJoinRecord = exports.getGranuleByUniqueColumns = exports.getUniqueGranuleByGranuleId = exports.getGranuleCollectionId = exports.getApiGranuleExecutionCumulusIds = exports.getApiGranuleCumulusIds = exports.getFilesAndGranuleInfoQuery = void 0;
|
|
28
28
|
const path = __importStar(require("path"));
|
|
29
29
|
var knex_1 = require("knex");
|
|
30
30
|
Object.defineProperty(exports, "Knex", { enumerable: true, get: function () { return knex_1.Knex; } });
|
|
@@ -106,6 +106,7 @@ Object.defineProperty(exports, "upsertGranuleWithExecutionJoinRecord", { enumera
|
|
|
106
106
|
Object.defineProperty(exports, "getGranulesByApiPropertiesQuery", { enumerable: true, get: function () { return granule_1.getGranulesByApiPropertiesQuery; } });
|
|
107
107
|
Object.defineProperty(exports, "getGranulesByGranuleId", { enumerable: true, get: function () { return granule_1.getGranulesByGranuleId; } });
|
|
108
108
|
Object.defineProperty(exports, "getGranuleAndCollection", { enumerable: true, get: function () { return granule_1.getGranuleAndCollection; } });
|
|
109
|
+
Object.defineProperty(exports, "updateBatchGranulesCollection", { enumerable: true, get: function () { return granule_1.updateBatchGranulesCollection; } });
|
|
109
110
|
var QuerySearchClient_1 = require("./lib/QuerySearchClient");
|
|
110
111
|
Object.defineProperty(exports, "QuerySearchClient", { enumerable: true, get: function () { return QuerySearchClient_1.QuerySearchClient; } });
|
|
111
112
|
var async_operation_1 = require("./models/async_operation");
|
package/dist/lib/granule.d.ts
CHANGED
|
@@ -118,4 +118,13 @@ export declare const getGranuleAndCollection: (knexOrTransaction: Knex | Knex.Tr
|
|
|
118
118
|
* @returns {Promise<PostgresGranuleRecord[]>} The returned list of records
|
|
119
119
|
*/
|
|
120
120
|
export declare const getGranulesByGranuleId: (knexOrTransaction: Knex | Knex.Transaction, granuleId: string) => Promise<PostgresGranuleRecord[]>;
|
|
121
|
+
/**
|
|
122
|
+
* Update a list of granuleIds to a new collection_cumulus_id in postgres
|
|
123
|
+
*
|
|
124
|
+
* @param {Knex} knex - DB client or transaction
|
|
125
|
+
* @param {Array<String>} granuleIds - list of Granule IDs
|
|
126
|
+
* @param {number} collectionCumulusId - collection_cumulus_id to be update to
|
|
127
|
+
* @returns {Promise<void>}
|
|
128
|
+
*/
|
|
129
|
+
export declare const updateBatchGranulesCollection: (knex: Knex, granuleIds: Array<String>, collectionCumulusId: number) => Promise<void>;
|
|
121
130
|
//# sourceMappingURL=granule.d.ts.map
|
package/dist/lib/granule.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getGranulesByGranuleId = exports.getGranuleAndCollection = exports.getGranulesByApiPropertiesQuery = exports.getApiGranuleExecutionCumulusIds = exports.getGranuleByUniqueColumns = exports.getUniqueGranuleByGranuleId = exports.getApiGranuleCumulusIds = exports.upsertGranuleWithExecutionJoinRecord = exports.getGranuleCollectionId = void 0;
|
|
6
|
+
exports.updateBatchGranulesCollection = exports.getGranulesByGranuleId = exports.getGranuleAndCollection = exports.getGranulesByApiPropertiesQuery = exports.getApiGranuleExecutionCumulusIds = exports.getGranuleByUniqueColumns = exports.getUniqueGranuleByGranuleId = exports.getApiGranuleCumulusIds = exports.upsertGranuleWithExecutionJoinRecord = exports.getGranuleCollectionId = void 0;
|
|
7
7
|
const Collections_1 = require("@cumulus/message/Collections");
|
|
8
8
|
const errors_1 = require("@cumulus/errors");
|
|
9
9
|
const logger_1 = __importDefault(require("@cumulus/logger"));
|
|
@@ -12,6 +12,7 @@ const granule_1 = require("../models/granule");
|
|
|
12
12
|
const granules_executions_1 = require("../models/granules-executions");
|
|
13
13
|
const { deprecate } = require('@cumulus/common/util');
|
|
14
14
|
const { TableNames } = require('../tables');
|
|
15
|
+
const log = new logger_1.default({ sender: '@cumulus/db/lib/granules' });
|
|
15
16
|
const getGranuleCollectionId = async (knexOrTransaction, granule) => {
|
|
16
17
|
const collectionPgModel = new collection_1.CollectionPgModel();
|
|
17
18
|
const collection = await collectionPgModel.get(knexOrTransaction, { cumulus_id: granule.collection_cumulus_id });
|
|
@@ -250,4 +251,23 @@ const getGranulesByGranuleId = async (knexOrTransaction, granuleId) => {
|
|
|
250
251
|
return records;
|
|
251
252
|
};
|
|
252
253
|
exports.getGranulesByGranuleId = getGranulesByGranuleId;
|
|
254
|
+
/**
|
|
255
|
+
* Update a list of granuleIds to a new collection_cumulus_id in postgres
|
|
256
|
+
*
|
|
257
|
+
* @param {Knex} knex - DB client or transaction
|
|
258
|
+
* @param {Array<String>} granuleIds - list of Granule IDs
|
|
259
|
+
* @param {number} collectionCumulusId - collection_cumulus_id to be update to
|
|
260
|
+
* @returns {Promise<void>}
|
|
261
|
+
*/
|
|
262
|
+
const updateBatchGranulesCollection = async (knex, granuleIds, collectionCumulusId) => {
|
|
263
|
+
const { granules: granulesTable, } = TableNames;
|
|
264
|
+
try {
|
|
265
|
+
await knex(granulesTable).whereIn('granule_id', granuleIds).update({ collection_cumulus_id: collectionCumulusId });
|
|
266
|
+
}
|
|
267
|
+
catch (thrownError) {
|
|
268
|
+
log.error(`Write Granules failed: ${JSON.stringify(thrownError)}`);
|
|
269
|
+
throw thrownError;
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
exports.updateBatchGranulesCollection = updateBatchGranulesCollection;
|
|
253
273
|
//# sourceMappingURL=granule.js.map
|
|
@@ -6,10 +6,6 @@ const up = async (knex) => {
|
|
|
6
6
|
await knex.raw('ALTER TABLE executions ALTER COLUMN cumulus_id TYPE BIGINT, ALTER COLUMN parent_cumulus_id TYPE BIGINT');
|
|
7
7
|
await knex.raw('ALTER TABLE granules_executions ALTER COLUMN granule_cumulus_id TYPE BIGINT, ALTER COLUMN execution_cumulus_id TYPE BIGINT');
|
|
8
8
|
await knex.raw('ALTER TABLE pdrs ALTER COLUMN execution_cumulus_id TYPE BIGINT');
|
|
9
|
-
await knex.raw('VACUUM (ANALYZE, VERBOSE) executions');
|
|
10
|
-
await knex.raw('VACUUM (ANALYZE, VERBOSE) files');
|
|
11
|
-
await knex.raw('VACUUM (ANALYZE, VERBOSE) granules_executions');
|
|
12
|
-
await knex.raw('VACUUM (ANALYZE, VERBOSE) pdrs');
|
|
13
9
|
};
|
|
14
10
|
exports.up = up;
|
|
15
11
|
const down = async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cumulus/db",
|
|
3
|
-
"version": "18.5.
|
|
3
|
+
"version": "18.5.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.621.0",
|
|
36
|
-
"@cumulus/aws-client": "18.5.
|
|
37
|
-
"@cumulus/common": "18.5.
|
|
38
|
-
"@cumulus/errors": "18.5.
|
|
39
|
-
"@cumulus/logger": "18.5.
|
|
40
|
-
"@cumulus/message": "18.5.
|
|
41
|
-
"@cumulus/types": "18.5.
|
|
36
|
+
"@cumulus/aws-client": "18.5.3",
|
|
37
|
+
"@cumulus/common": "18.5.3",
|
|
38
|
+
"@cumulus/errors": "18.5.3",
|
|
39
|
+
"@cumulus/logger": "18.5.3",
|
|
40
|
+
"@cumulus/message": "18.5.3",
|
|
41
|
+
"@cumulus/types": "18.5.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": "710a2742b86966888094319920f57471b72a0cf8"
|
|
54
54
|
}
|