@cumulus/db 13.2.1 → 13.3.1

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
@@ -22,7 +22,7 @@ export { translateApiCollectionToPostgresCollection, translatePostgresCollection
22
22
  export { translateApiProviderToPostgresProvider, translatePostgresProviderToApiProvider, } from './translate/providers';
23
23
  export { translatePostgresRuleToApiRule, translateApiRuleToPostgresRule, translateApiRuleToPostgresRuleRaw, } from './translate/rules';
24
24
  export { translateApiExecutionToPostgresExecution, translatePostgresExecutionToApiExecution, } from './translate/executions';
25
- export { translateApiGranuleToPostgresGranule, translatePostgresGranuleToApiGranule, translatePostgresGranuleResultToApiGranule, } from './translate/granules';
25
+ export { translateApiGranuleToPostgresGranule, translateApiGranuleToPostgresGranuleWithoutNilsRemoved, translatePostgresGranuleToApiGranule, translatePostgresGranuleResultToApiGranule, } from './translate/granules';
26
26
  export { translateApiPdrToPostgresPdr, translatePostgresPdrToApiPdr, } from './translate/pdr';
27
27
  export { getCollectionsByGranuleIds, } from './lib/collection';
28
28
  export { executionArnsFromGranuleIdsAndWorkflowNames, newestExecutionArnFromGranuleIdWorkflowName, getWorkflowNameIntersectFromGranuleIds, getApiExecutionCumulusIds, getApiGranuleExecutionCumulusIdsByExecution, getExecutionInfoByGranuleCumulusId, } from './lib/execution';
package/dist/index.js CHANGED
@@ -23,8 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getApiGranuleExecutionCumulusIds = exports.getApiGranuleCumulusIds = exports.getFilesAndGranuleInfoQuery = exports.getExecutionInfoByGranuleCumulusId = exports.getApiGranuleExecutionCumulusIdsByExecution = exports.getApiExecutionCumulusIds = exports.getWorkflowNameIntersectFromGranuleIds = exports.newestExecutionArnFromGranuleIdWorkflowName = exports.executionArnsFromGranuleIdsAndWorkflowNames = exports.getCollectionsByGranuleIds = exports.translatePostgresPdrToApiPdr = exports.translateApiPdrToPostgresPdr = exports.translatePostgresGranuleResultToApiGranule = exports.translatePostgresGranuleToApiGranule = exports.translateApiGranuleToPostgresGranule = exports.translatePostgresExecutionToApiExecution = 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.getGranulesByApiPropertiesQuery = exports.upsertGranuleWithExecutionJoinRecord = exports.getUniqueGranuleByGranuleId = exports.getGranuleCollectionId = void 0;
26
+ exports.getApiGranuleCumulusIds = exports.getFilesAndGranuleInfoQuery = exports.getExecutionInfoByGranuleCumulusId = exports.getApiGranuleExecutionCumulusIdsByExecution = exports.getApiExecutionCumulusIds = exports.getWorkflowNameIntersectFromGranuleIds = exports.newestExecutionArnFromGranuleIdWorkflowName = exports.executionArnsFromGranuleIdsAndWorkflowNames = exports.getCollectionsByGranuleIds = exports.translatePostgresPdrToApiPdr = exports.translateApiPdrToPostgresPdr = exports.translatePostgresGranuleResultToApiGranule = exports.translatePostgresGranuleToApiGranule = exports.translateApiGranuleToPostgresGranuleWithoutNilsRemoved = exports.translateApiGranuleToPostgresGranule = exports.translatePostgresExecutionToApiExecution = 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.getGranulesByApiPropertiesQuery = exports.upsertGranuleWithExecutionJoinRecord = exports.getUniqueGranuleByGranuleId = exports.getGranuleCollectionId = exports.getApiGranuleExecutionCumulusIds = 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; } });
@@ -77,6 +77,7 @@ Object.defineProperty(exports, "translateApiExecutionToPostgresExecution", { enu
77
77
  Object.defineProperty(exports, "translatePostgresExecutionToApiExecution", { enumerable: true, get: function () { return executions_1.translatePostgresExecutionToApiExecution; } });
78
78
  var granules_1 = require("./translate/granules");
79
79
  Object.defineProperty(exports, "translateApiGranuleToPostgresGranule", { enumerable: true, get: function () { return granules_1.translateApiGranuleToPostgresGranule; } });
80
+ Object.defineProperty(exports, "translateApiGranuleToPostgresGranuleWithoutNilsRemoved", { enumerable: true, get: function () { return granules_1.translateApiGranuleToPostgresGranuleWithoutNilsRemoved; } });
80
81
  Object.defineProperty(exports, "translatePostgresGranuleToApiGranule", { enumerable: true, get: function () { return granules_1.translatePostgresGranuleToApiGranule; } });
81
82
  Object.defineProperty(exports, "translatePostgresGranuleResultToApiGranule", { enumerable: true, get: function () { return granules_1.translatePostgresGranuleResultToApiGranule; } });
82
83
  var pdr_1 = require("./translate/pdr");
@@ -35,16 +35,44 @@ export declare const translatePostgresGranuleToApiGranule: ({ granulePgRecord, c
35
35
  /**
36
36
  * Generate a Postgres granule record from a DynamoDB record.
37
37
  *
38
- * @param {AWS.DynamoDB.DocumentClient.AttributeMap} dynamoRecord
38
+ * @param {Object} params
39
+ * @param {AWS.DynamoDB.DocumentClient.AttributeMap} params.dynamoRecord
39
40
  * Record from DynamoDB
40
- * @param {Knex | Knex.Transaction} knexOrTransaction
41
+ * @param {Knex | Knex.Transaction} params.knexOrTransaction
41
42
  * Knex client for reading from RDS database
42
- * @param {Object} collectionPgModel - Instance of the collection database model
43
- * @param {Object} pdrPgModel - Instance of the pdr database model
44
- * @param {Object} providerPgModel - Instance of the provider database model
43
+ * @param {Object} params.collectionPgModel - Instance of the collection database model
44
+ * @param {Object} params.pdrPgModel - Instance of the pdr database model
45
+ * @param {Object} params.providerPgModel - Instance of the provider database model
45
46
  * @returns {Object} A granule PG record
46
47
  */
47
- export declare const translateApiGranuleToPostgresGranule: (dynamoRecord: AWS.DynamoDB.DocumentClient.AttributeMap, knexOrTransaction: Knex | Knex.Transaction, collectionPgModel?: CollectionPgModel, pdrPgModel?: PdrPgModel, providerPgModel?: ProviderPgModel) => Promise<PostgresGranule>;
48
+ export declare const translateApiGranuleToPostgresGranuleWithoutNilsRemoved: ({ dynamoRecord, knexOrTransaction, collectionPgModel, pdrPgModel, providerPgModel, }: {
49
+ dynamoRecord: AWS.DynamoDB.DocumentClient.AttributeMap;
50
+ knexOrTransaction: Knex | Knex.Transaction;
51
+ collectionPgModel?: CollectionPgModel | undefined;
52
+ pdrPgModel?: PdrPgModel | undefined;
53
+ providerPgModel?: ProviderPgModel | undefined;
54
+ }) => Promise<PostgresGranule>;
55
+ /**
56
+ * Generate a Postgres granule record from a DynamoDB record. Removes
57
+ * any null/undefined properties.
58
+ *
59
+ * @param {Object} params
60
+ * @param {AWS.DynamoDB.DocumentClient.AttributeMap} params.dynamoRecord
61
+ * Record from DynamoDB
62
+ * @param {Knex | Knex.Transaction} params.knexOrTransaction
63
+ * Knex client for reading from RDS database
64
+ * @param {Object} params.collectionPgModel - Instance of the collection database model
65
+ * @param {Object} params.pdrPgModel - Instance of the pdr database model
66
+ * @param {Object} params.providerPgModel - Instance of the provider database model
67
+ * @returns {Object} A granule PG record with null/undefined properties removed
68
+ */
69
+ export declare const translateApiGranuleToPostgresGranule: ({ dynamoRecord, knexOrTransaction, collectionPgModel, pdrPgModel, providerPgModel, }: {
70
+ dynamoRecord: AWS.DynamoDB.DocumentClient.AttributeMap;
71
+ knexOrTransaction: Knex | Knex.Transaction;
72
+ collectionPgModel?: CollectionPgModel | undefined;
73
+ pdrPgModel?: PdrPgModel | undefined;
74
+ providerPgModel?: ProviderPgModel | undefined;
75
+ }) => Promise<PostgresGranule>;
48
76
  /**
49
77
  * Translate a custom database result into an API granule
50
78
  *
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.translatePostgresGranuleResultToApiGranule = exports.translateApiGranuleToPostgresGranule = exports.translatePostgresGranuleToApiGranule = void 0;
3
+ exports.translatePostgresGranuleResultToApiGranule = exports.translateApiGranuleToPostgresGranule = exports.translateApiGranuleToPostgresGranuleWithoutNilsRemoved = exports.translatePostgresGranuleToApiGranule = void 0;
4
4
  const Collections_1 = require("@cumulus/message/Collections");
5
5
  const util_1 = require("@cumulus/common/util");
6
6
  const errors_1 = require("@cumulus/errors");
@@ -80,16 +80,17 @@ exports.translatePostgresGranuleToApiGranule = translatePostgresGranuleToApiGran
80
80
  /**
81
81
  * Generate a Postgres granule record from a DynamoDB record.
82
82
  *
83
- * @param {AWS.DynamoDB.DocumentClient.AttributeMap} dynamoRecord
83
+ * @param {Object} params
84
+ * @param {AWS.DynamoDB.DocumentClient.AttributeMap} params.dynamoRecord
84
85
  * Record from DynamoDB
85
- * @param {Knex | Knex.Transaction} knexOrTransaction
86
+ * @param {Knex | Knex.Transaction} params.knexOrTransaction
86
87
  * Knex client for reading from RDS database
87
- * @param {Object} collectionPgModel - Instance of the collection database model
88
- * @param {Object} pdrPgModel - Instance of the pdr database model
89
- * @param {Object} providerPgModel - Instance of the provider database model
88
+ * @param {Object} params.collectionPgModel - Instance of the collection database model
89
+ * @param {Object} params.pdrPgModel - Instance of the pdr database model
90
+ * @param {Object} params.providerPgModel - Instance of the provider database model
90
91
  * @returns {Object} A granule PG record
91
92
  */
92
- const translateApiGranuleToPostgresGranule = async (dynamoRecord, knexOrTransaction, collectionPgModel = new collection_1.CollectionPgModel(), pdrPgModel = new pdr_1.PdrPgModel(), providerPgModel = new provider_1.ProviderPgModel()) => {
93
+ const translateApiGranuleToPostgresGranuleWithoutNilsRemoved = async ({ dynamoRecord, knexOrTransaction, collectionPgModel = new collection_1.CollectionPgModel(), pdrPgModel = new pdr_1.PdrPgModel(), providerPgModel = new provider_1.ProviderPgModel(), }) => {
93
94
  const { name, version } = (0, Collections_1.deconstructCollectionId)(dynamoRecord.collectionId);
94
95
  const granuleRecord = {
95
96
  granule_id: dynamoRecord.granuleId,
@@ -126,6 +127,28 @@ const translateApiGranuleToPostgresGranule = async (dynamoRecord, knexOrTransact
126
127
  };
127
128
  return granuleRecord;
128
129
  };
130
+ exports.translateApiGranuleToPostgresGranuleWithoutNilsRemoved = translateApiGranuleToPostgresGranuleWithoutNilsRemoved;
131
+ /**
132
+ * Generate a Postgres granule record from a DynamoDB record. Removes
133
+ * any null/undefined properties.
134
+ *
135
+ * @param {Object} params
136
+ * @param {AWS.DynamoDB.DocumentClient.AttributeMap} params.dynamoRecord
137
+ * Record from DynamoDB
138
+ * @param {Knex | Knex.Transaction} params.knexOrTransaction
139
+ * Knex client for reading from RDS database
140
+ * @param {Object} params.collectionPgModel - Instance of the collection database model
141
+ * @param {Object} params.pdrPgModel - Instance of the pdr database model
142
+ * @param {Object} params.providerPgModel - Instance of the provider database model
143
+ * @returns {Object} A granule PG record with null/undefined properties removed
144
+ */
145
+ const translateApiGranuleToPostgresGranule = async ({ dynamoRecord, knexOrTransaction, collectionPgModel = new collection_1.CollectionPgModel(), pdrPgModel = new pdr_1.PdrPgModel(), providerPgModel = new provider_1.ProviderPgModel(), }) => (0, util_1.removeNilProperties)(await (0, exports.translateApiGranuleToPostgresGranuleWithoutNilsRemoved)({
146
+ dynamoRecord,
147
+ knexOrTransaction,
148
+ collectionPgModel,
149
+ pdrPgModel,
150
+ providerPgModel,
151
+ }));
129
152
  exports.translateApiGranuleToPostgresGranule = translateApiGranuleToPostgresGranule;
130
153
  /**
131
154
  * Translate a custom database result into an API granule
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cumulus/db",
3
- "version": "13.2.1",
3
+ "version": "13.3.1",
4
4
  "description": "Utilities for working with the Cumulus DB",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -29,12 +29,12 @@
29
29
  "node": ">=14.19.1"
30
30
  },
31
31
  "dependencies": {
32
- "@cumulus/aws-client": "13.2.1",
33
- "@cumulus/common": "13.2.1",
34
- "@cumulus/errors": "13.2.1",
35
- "@cumulus/logger": "13.2.1",
36
- "@cumulus/message": "13.2.1",
37
- "@cumulus/types": "13.2.1",
32
+ "@cumulus/aws-client": "13.3.1",
33
+ "@cumulus/common": "13.3.1",
34
+ "@cumulus/errors": "13.3.1",
35
+ "@cumulus/logger": "13.3.1",
36
+ "@cumulus/message": "13.3.1",
37
+ "@cumulus/types": "13.3.1",
38
38
  "crypto-random-string": "^3.2.0",
39
39
  "is-valid-hostname": "1.0.2",
40
40
  "knex": "0.95.15",
@@ -46,5 +46,5 @@
46
46
  "devDependencies": {
47
47
  "@types/uuid": "^8.0.0"
48
48
  },
49
- "gitHead": "3239565c8f6c8db897518eeaf27549552dbd839a"
49
+ "gitHead": "9b5fb964cfb651a76b784a009e5e443d3633b7c6"
50
50
  }