@cumulus/db 20.1.2 → 20.1.3-alpha.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.
@@ -0,0 +1,4 @@
1
+ import { Knex } from 'knex';
2
+ export declare const up: (knex: Knex) => Promise<void>;
3
+ export declare const down: (knex: Knex) => Promise<void>;
4
+ //# sourceMappingURL=20250425134823_granules_add_producer_granule_id.d.ts.map
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.down = exports.up = void 0;
4
+ const up = async (knex) => {
5
+ if (!await knex.schema.hasColumn('granules', 'producer_granule_id')) {
6
+ await knex.schema.table('granules', (table) => {
7
+ table
8
+ .text('producer_granule_id')
9
+ .comment('Producer Granule Id');
10
+ });
11
+ await knex('granules').update('producer_granule_id', knex.raw('granule_id'));
12
+ await knex.schema.table('granules', (table) => {
13
+ table.text('producer_granule_id').notNullable().alter();
14
+ });
15
+ }
16
+ await knex.raw('CREATE INDEX CONCURRENTLY IF NOT EXISTS granules_producer_granule_id_index ON granules(producer_granule_id)');
17
+ };
18
+ exports.up = up;
19
+ const down = async (knex) => {
20
+ if (await knex.schema.hasColumn('granules', 'producer_granule_id')) {
21
+ await knex.schema.table('granules', (table) => {
22
+ table.dropColumn('producer_granule_id');
23
+ });
24
+ }
25
+ };
26
+ exports.down = down;
27
+ exports.config = {
28
+ transaction: false,
29
+ };
30
+ //# sourceMappingURL=20250425134823_granules_add_producer_granule_id.js.map
@@ -39,6 +39,9 @@ const granuleMapping = {
39
39
  processingStartDateTime: (value) => ({
40
40
  processing_start_date_time: value,
41
41
  }),
42
+ producerGranuleId: (value) => ({
43
+ producer_granule_id: value,
44
+ }),
42
45
  productionDateTime: (value) => ({
43
46
  production_date_time: value,
44
47
  }),
@@ -90,6 +90,7 @@ const fakeProviderRecordFactory = (params) => ({
90
90
  exports.fakeProviderRecordFactory = fakeProviderRecordFactory;
91
91
  const fakeGranuleRecordFactory = (params) => ({
92
92
  granule_id: (0, crypto_random_string_1.default)({ length: 5 }),
93
+ producer_granule_id: (0, crypto_random_string_1.default)({ length: 5 }),
93
94
  status: 'completed',
94
95
  created_at: new Date(),
95
96
  ...params,
@@ -43,6 +43,7 @@ const translatePostgresGranuleToApiGranuleWithoutDbQuery = ({ granulePgRecord, c
43
43
  pdrName: pdr ? pdr.name : undefined,
44
44
  processingEndDateTime: granulePgRecord.processing_end_date_time?.toISOString(),
45
45
  processingStartDateTime: granulePgRecord.processing_start_date_time?.toISOString(),
46
+ producerGranuleId: granulePgRecord.producer_granule_id,
46
47
  productionDateTime: granulePgRecord.production_date_time?.toISOString(),
47
48
  productVolume: granulePgRecord.product_volume,
48
49
  provider: providerPgRecord ? providerPgRecord.name : undefined,
@@ -118,8 +119,11 @@ const validateApiToPostgresGranuleObject = (apiGranule) => {
118
119
  if ((0, isNil_1.default)(apiGranule.granuleId)) {
119
120
  throw new errors_1.ValidationError('granuleId cannot be undefined on a granule, granules must have a collection and a granule ID');
120
121
  }
122
+ if ((0, isNil_1.default)(apiGranule.producerGranuleId)) {
123
+ throw new errors_1.ValidationError('producerGranuleId cannot be undefined on a granule, granules must have a producerGranuleId');
124
+ }
121
125
  if ((0, isNull_1.default)(apiGranule.status)) {
122
- throw new errors_1.ValidationError('status cannot be null on a granule, granules must have a collection and a granule ID');
126
+ throw new errors_1.ValidationError('status cannot be null on a granule, granules must have a status');
123
127
  }
124
128
  };
125
129
  /**
@@ -162,6 +166,7 @@ const translateApiGranuleToPostgresGranuleWithoutNilsRemoved = async ({ dynamoRe
162
166
  granule_id: dynamoRecord.granuleId,
163
167
  status: dynamoRecord.status,
164
168
  collection_cumulus_id: await collectionPgModel.getRecordCumulusId(knexOrTransaction, { name, version }),
169
+ producer_granule_id: dynamoRecord.producerGranuleId,
165
170
  published: dynamoRecord.published,
166
171
  duration: dynamoRecord.duration,
167
172
  time_to_archive: dynamoRecord.timeToArchive,
@@ -4,6 +4,7 @@ export interface PostgresGranuleUniqueColumns {
4
4
  collection_cumulus_id: number;
5
5
  }
6
6
  export interface PostgresGranule extends PostgresGranuleUniqueColumns {
7
+ producer_granule_id: string;
7
8
  status?: GranuleStatus;
8
9
  cmr_link?: string | null;
9
10
  error?: object | null;
@@ -27,6 +28,7 @@ export interface PostgresGranule extends PostgresGranuleUniqueColumns {
27
28
  }
28
29
  export interface PostgresGranuleRecord extends Omit<PostgresGranule, 'product_volume'> {
29
30
  cumulus_id: number;
31
+ producer_granule_id: string;
30
32
  product_volume?: string;
31
33
  created_at: Date;
32
34
  updated_at: Date;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cumulus/db",
3
- "version": "20.1.2",
3
+ "version": "20.1.3-alpha.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": "20.1.2",
37
- "@cumulus/common": "20.1.2",
38
- "@cumulus/errors": "20.1.2",
39
- "@cumulus/logger": "20.1.2",
40
- "@cumulus/message": "20.1.2",
41
- "@cumulus/types": "20.1.2",
36
+ "@cumulus/aws-client": "20.1.3-alpha.0",
37
+ "@cumulus/common": "20.1.3-alpha.0",
38
+ "@cumulus/errors": "20.1.3-alpha.0",
39
+ "@cumulus/logger": "20.1.3-alpha.0",
40
+ "@cumulus/message": "20.1.3-alpha.0",
41
+ "@cumulus/types": "20.1.3-alpha.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": "051ef1428ac21105fd55370d15e26009f4b49f57"
53
+ "gitHead": "7c70abafba784906805f7fac5c4e8b5e53f51c3b"
54
54
  }