@cumulus/db 18.4.0 → 19.0.0

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.
@@ -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.translatePostgresGranuleResultToApiGranule = exports.translateApiGranuleToPostgresGranule = exports.translateApiGranuleToPostgresGranuleWithoutNilsRemoved = exports.translatePostgresGranuleToApiGranule = void 0;
6
+ exports.translatePostgresGranuleResultToApiGranule = exports.translateApiGranuleToPostgresGranule = exports.translateApiGranuleToPostgresGranuleWithoutNilsRemoved = exports.translatePostgresGranuleToApiGranule = exports.translatePostgresGranuleToApiGranuleWithoutDbQuery = void 0;
7
7
  const Collections_1 = require("@cumulus/message/Collections");
8
8
  const util_1 = require("@cumulus/common/util");
9
9
  const errors_1 = require("@cumulus/errors");
@@ -15,6 +15,46 @@ const provider_1 = require("../models/provider");
15
15
  const file_1 = require("../models/file");
16
16
  const execution_1 = require("../lib/execution");
17
17
  const file_2 = require("./file");
18
+ /**
19
+ * Generate an API Granule object from the granule and associated Postgres objects without
20
+ * querying the database
21
+ *
22
+ * @param params - params
23
+ * @param params.granulePgRecord - Granule from Postgres
24
+ * @param params.collectionPgRecord - Collection from Postgres
25
+ * @param [params.executionUrls] - executionUrls from Postgres
26
+ * @param [params.files] - granule files from Postgres
27
+ * @param [params.pdr] - pdr from Postgres
28
+ * @param [params.providerPgRecord] - provider from Postgres
29
+ * @returns An API Granule with associated Files
30
+ */
31
+ const translatePostgresGranuleToApiGranuleWithoutDbQuery = ({ granulePgRecord, collectionPgRecord, executionUrls = [], files = [], pdr, providerPgRecord, }) => (0, util_1.removeNilProperties)({
32
+ beginningDateTime: granulePgRecord.beginning_date_time?.toISOString(),
33
+ cmrLink: granulePgRecord.cmr_link,
34
+ collectionId: (0, Collections_1.constructCollectionId)(collectionPgRecord.name, collectionPgRecord.version),
35
+ createdAt: granulePgRecord.created_at?.getTime(),
36
+ duration: granulePgRecord.duration,
37
+ endingDateTime: granulePgRecord.ending_date_time?.toISOString(),
38
+ error: granulePgRecord.error,
39
+ execution: executionUrls[0] ? executionUrls[0].url : undefined,
40
+ files: files.length > 0 ? files.map((file) => (0, file_2.translatePostgresFileToApiFile)(file)) : [],
41
+ granuleId: granulePgRecord.granule_id,
42
+ lastUpdateDateTime: granulePgRecord.last_update_date_time?.toISOString(),
43
+ pdrName: pdr ? pdr.name : undefined,
44
+ processingEndDateTime: granulePgRecord.processing_end_date_time?.toISOString(),
45
+ processingStartDateTime: granulePgRecord.processing_start_date_time?.toISOString(),
46
+ productionDateTime: granulePgRecord.production_date_time?.toISOString(),
47
+ productVolume: granulePgRecord.product_volume,
48
+ provider: providerPgRecord ? providerPgRecord.name : undefined,
49
+ published: granulePgRecord.published,
50
+ queryFields: granulePgRecord.query_fields,
51
+ status: granulePgRecord.status,
52
+ timestamp: granulePgRecord.timestamp?.getTime(),
53
+ timeToArchive: granulePgRecord.time_to_archive,
54
+ timeToPreprocess: granulePgRecord.time_to_process,
55
+ updatedAt: granulePgRecord.updated_at?.getTime(),
56
+ });
57
+ exports.translatePostgresGranuleToApiGranuleWithoutDbQuery = translatePostgresGranuleToApiGranuleWithoutDbQuery;
18
58
  /**
19
59
  * Generate an API Granule object from a Postgres Granule with associated Files.
20
60
  *
@@ -52,33 +92,14 @@ const translatePostgresGranuleToApiGranule = async ({ granulePgRecord, collectio
52
92
  else if (granulePgRecord.provider_cumulus_id) {
53
93
  provider = await providerPgModel.get(knexOrTransaction, { cumulus_id: granulePgRecord.provider_cumulus_id });
54
94
  }
55
- const apiGranule = (0, util_1.removeNilProperties)({
56
- beginningDateTime: granulePgRecord.beginning_date_time?.toISOString(),
57
- cmrLink: granulePgRecord.cmr_link,
58
- collectionId: (0, Collections_1.constructCollectionId)(collection.name, collection.version),
59
- createdAt: granulePgRecord.created_at?.getTime(),
60
- duration: granulePgRecord.duration,
61
- endingDateTime: granulePgRecord.ending_date_time?.toISOString(),
62
- error: granulePgRecord.error,
63
- execution: executionUrls[0] ? executionUrls[0].url : undefined,
64
- files: files.length > 0 ? files.map((file) => (0, file_2.translatePostgresFileToApiFile)(file)) : [],
65
- granuleId: granulePgRecord.granule_id,
66
- lastUpdateDateTime: granulePgRecord.last_update_date_time?.toISOString(),
67
- pdrName: pdr ? pdr.name : undefined,
68
- processingEndDateTime: granulePgRecord.processing_end_date_time?.toISOString(),
69
- processingStartDateTime: granulePgRecord.processing_start_date_time?.toISOString(),
70
- productionDateTime: granulePgRecord.production_date_time?.toISOString(),
71
- productVolume: granulePgRecord.product_volume,
72
- provider: provider ? provider.name : undefined,
73
- published: granulePgRecord.published,
74
- queryFields: granulePgRecord.query_fields,
75
- status: granulePgRecord.status,
76
- timestamp: granulePgRecord.timestamp?.getTime(),
77
- timeToArchive: granulePgRecord.time_to_archive,
78
- timeToPreprocess: granulePgRecord.time_to_process,
79
- updatedAt: granulePgRecord.updated_at?.getTime(),
95
+ return (0, exports.translatePostgresGranuleToApiGranuleWithoutDbQuery)({
96
+ granulePgRecord,
97
+ collectionPgRecord: collection,
98
+ executionUrls,
99
+ files,
100
+ pdr,
101
+ providerPgRecord: provider,
80
102
  });
81
- return apiGranule;
82
103
  };
83
104
  exports.translatePostgresGranuleToApiGranule = translatePostgresGranuleToApiGranule;
84
105
  /**
@@ -0,0 +1,52 @@
1
+ export declare type QueryStringParameters = {
2
+ field?: string;
3
+ fields?: string;
4
+ infix?: string;
5
+ limit?: string;
6
+ page?: string;
7
+ order?: string;
8
+ prefix?: string;
9
+ includeFullRecord?: string;
10
+ sort_by?: string;
11
+ sort_key?: string[];
12
+ [key: string]: string | string[] | undefined;
13
+ };
14
+ export declare type QueryEvent = {
15
+ queryStringParameters?: QueryStringParameters;
16
+ };
17
+ export declare type QueriableType = boolean | Date | number | string;
18
+ export declare type RangeType = {
19
+ gte?: Omit<QueriableType, 'boolean'>;
20
+ lte?: Omit<QueriableType, 'boolean'>;
21
+ };
22
+ export declare type SortType = {
23
+ column: string;
24
+ order?: string;
25
+ };
26
+ export declare type DbQueryParameters = {
27
+ fields?: string[];
28
+ infix?: string;
29
+ limit?: number;
30
+ includeFullRecord?: boolean;
31
+ estimateTableRowCount?: boolean;
32
+ exists?: {
33
+ [key: string]: boolean;
34
+ };
35
+ not?: {
36
+ [key: string]: QueriableType | undefined;
37
+ };
38
+ offset?: number;
39
+ page?: number;
40
+ prefix?: string;
41
+ range?: {
42
+ [key: string]: RangeType;
43
+ };
44
+ sort?: SortType[];
45
+ term?: {
46
+ [key: string]: QueriableType | undefined;
47
+ };
48
+ terms?: {
49
+ [key: string]: QueriableType[];
50
+ };
51
+ };
52
+ //# sourceMappingURL=search.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=search.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cumulus/db",
3
- "version": "18.4.0",
3
+ "version": "19.0.0",
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.4.0",
37
- "@cumulus/common": "18.4.0",
38
- "@cumulus/errors": "18.4.0",
39
- "@cumulus/logger": "18.4.0",
40
- "@cumulus/message": "18.4.0",
41
- "@cumulus/types": "18.4.0",
36
+ "@cumulus/aws-client": "19.0.0",
37
+ "@cumulus/common": "19.0.0",
38
+ "@cumulus/errors": "19.0.0",
39
+ "@cumulus/logger": "19.0.0",
40
+ "@cumulus/message": "19.0.0",
41
+ "@cumulus/types": "19.0.0",
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": "05912dd9f996ec1149ecd11ed69ec42f86f0fc8a"
53
+ "gitHead": "3a619db6e6fa20846eb75802e89d5a065fd62fcc"
54
54
  }