@cumulus/db 14.0.0 → 14.1.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.
@@ -4,7 +4,9 @@ import { GranulePgModel } from '../models/granule';
4
4
  import { GranulesExecutionsPgModel } from '../models/granules-executions';
5
5
  import { PostgresGranule, PostgresGranuleRecord } from '../types/granule';
6
6
  import { UpdatedAtRange } from '../types/record';
7
- export declare const getGranuleCollectionId: (knexOrTransaction: Knex | Knex.Transaction, granule: PostgresGranule) => Promise<string>;
7
+ export declare const getGranuleCollectionId: (knexOrTransaction: Knex, granule: {
8
+ collection_cumulus_id: number;
9
+ }) => Promise<string>;
8
10
  /**
9
11
  * Upsert a granule and a record in the granules/executions join table.
10
12
  *
@@ -89,7 +91,7 @@ export declare const getGranulesByApiPropertiesQuery: (knex: Knex, { collectionI
89
91
  *
90
92
  * @param {Knex | Knex.Transaction} knexOrTransaction - DB client or transaction
91
93
  * @param {string} granuleId - Granule ID
92
- * @returns {Promise<Array<PostgresGranuleRecord>} The returned list of records
94
+ * @returns {Promise<PostgresGranuleRecord[]>} The returned list of records
93
95
  */
94
- export declare const getGranulesByGranuleId: (knexOrTransaction: Knex | Knex.Transaction, granuleId: string) => Promise<Array<PostgresGranuleRecord>>;
96
+ export declare const getGranulesByGranuleId: (knexOrTransaction: Knex | Knex.Transaction, granuleId: string) => Promise<PostgresGranuleRecord[]>;
95
97
  //# sourceMappingURL=granule.d.ts.map
@@ -187,7 +187,7 @@ exports.getGranulesByApiPropertiesQuery = getGranulesByApiPropertiesQuery;
187
187
  *
188
188
  * @param {Knex | Knex.Transaction} knexOrTransaction - DB client or transaction
189
189
  * @param {string} granuleId - Granule ID
190
- * @returns {Promise<Array<PostgresGranuleRecord>} The returned list of records
190
+ * @returns {Promise<PostgresGranuleRecord[]>} The returned list of records
191
191
  */
192
192
  const getGranulesByGranuleId = async (knexOrTransaction, granuleId) => {
193
193
  const { granules: granulesTable, } = TableNames;
@@ -88,8 +88,8 @@ declare class BasePgModel<ItemType, RecordType extends BaseRecord> {
88
88
  * @param {ItemType} item - A record to insert into the DB
89
89
  * @param {string | Array<string>} returningFields - A string or array of strings
90
90
  * of columns to return. Defaults to 'cumulus_id'.
91
- * @returns {Promise<unknown[] | Object[]>} Returns an array of objects or an
92
- * array of values from the specified column(s) from returningFields.
91
+ * @returns {Promise<unknown[] | Object[]>} Returns an array of objects
92
+ * from the specified column(s) from returningFields.
93
93
  */
94
94
  create(knexOrTransaction: Knex | Knex.Transaction, item: ItemType, returningFields?: string | string[]): Promise<unknown[] | Object[]>;
95
95
  /**
@@ -99,8 +99,8 @@ declare class BasePgModel<ItemType, RecordType extends BaseRecord> {
99
99
  * @param {ItemType[]} items - Records to insert into the DB
100
100
  * @param {string | Array<string>} returningFields - A string or array of strings
101
101
  * of columns to return. Defaults to 'cumulus_id'.
102
- * @returns {Promise<unknown[] | Object[]>} Returns an array of objects or an
103
- * array of values from the specified column(s) from returningFields.
102
+ * @returns {Promise<unknown[] | Object[]>} Returns an array of objects
103
+ * from the specified column(s) from returningFields.
104
104
  */
105
105
  insert(knexOrTransaction: Knex | Knex.Transaction, items: ItemType[], returningFields?: string | string[]): Promise<unknown[] | Object[]>;
106
106
  /**
@@ -155,8 +155,8 @@ class BasePgModel {
155
155
  * @param {ItemType} item - A record to insert into the DB
156
156
  * @param {string | Array<string>} returningFields - A string or array of strings
157
157
  * of columns to return. Defaults to 'cumulus_id'.
158
- * @returns {Promise<unknown[] | Object[]>} Returns an array of objects or an
159
- * array of values from the specified column(s) from returningFields.
158
+ * @returns {Promise<unknown[] | Object[]>} Returns an array of objects
159
+ * from the specified column(s) from returningFields.
160
160
  */
161
161
  async create(knexOrTransaction, item, returningFields = 'cumulus_id') {
162
162
  return await knexOrTransaction(this.tableName)
@@ -170,8 +170,8 @@ class BasePgModel {
170
170
  * @param {ItemType[]} items - Records to insert into the DB
171
171
  * @param {string | Array<string>} returningFields - A string or array of strings
172
172
  * of columns to return. Defaults to 'cumulus_id'.
173
- * @returns {Promise<unknown[] | Object[]>} Returns an array of objects or an
174
- * array of values from the specified column(s) from returningFields.
173
+ * @returns {Promise<unknown[] | Object[]>} Returns an array of objects
174
+ * from the specified column(s) from returningFields.
175
175
  */
176
176
  async insert(knexOrTransaction, items, returningFields = 'cumulus_id') {
177
177
  return await knexOrTransaction(this.tableName)
@@ -52,7 +52,7 @@ export default class GranulePgModel extends BasePgModel<PostgresGranule, Postgre
52
52
  executionCumulusId?: number;
53
53
  executionPgModel?: ExecutionPgModel;
54
54
  writeConstraints: boolean;
55
- }): Promise<any[]>;
55
+ }): Promise<PostgresGranuleRecord[]>;
56
56
  /**
57
57
  * Get granules from the granule cumulus_id
58
58
  *
@@ -107,8 +107,7 @@ class GranulePgModel extends base_1.BasePgModel {
107
107
  // exist at all
108
108
  upsertQuery.whereNotExists(exclusionClause);
109
109
  }
110
- upsertQuery.returning('*');
111
- return await upsertQuery;
110
+ return await upsertQuery.returning('*');
112
111
  }
113
112
  const upsertQuery = knexOrTrx(this.tableName)
114
113
  .insert(granule)
@@ -120,8 +119,7 @@ class GranulePgModel extends base_1.BasePgModel {
120
119
  }
121
120
  upsertQuery.where(knexOrTrx.raw(`${this.tableName}.created_at <= to_timestamp(${(0, timestamp_1.translateDateToUTC)(granule.created_at)})`));
122
121
  }
123
- upsertQuery.returning('*');
124
- return await upsertQuery;
122
+ return await upsertQuery.returning('*');
125
123
  }
126
124
  /**
127
125
  * Get granules from the granule cumulus_id
@@ -19,7 +19,8 @@ class GranulesExecutionsPgModel {
19
19
  return await knexTransaction(this.tableName)
20
20
  .insert(item)
21
21
  .onConflict(['granule_cumulus_id', 'execution_cumulus_id'])
22
- .merge();
22
+ .merge()
23
+ .returning('*');
23
24
  }
24
25
  /**
25
26
  * Get execution_cumulus_id column values from the granule_cumulus_id
@@ -6,9 +6,9 @@ declare class ProviderPgModel extends BasePgModel<PostgresProvider, PostgresProv
6
6
  upsert(knexOrTransaction: Knex | Knex.Transaction, provider: PostgresProvider): Knex.QueryBuilder<any, {
7
7
  _base: any;
8
8
  _hasSelection: true;
9
- _keys: "name" | "cumulus_id";
9
+ _keys: "cumulus_id";
10
10
  _aliases: {};
11
- _single: true;
11
+ _single: false;
12
12
  _intersectProps: {};
13
13
  _unionProps: never;
14
14
  }[]>;
@@ -6,9 +6,9 @@ declare class RulePgModel extends BasePgModel<PostgresRule, PostgresRuleRecord>
6
6
  upsert(knexOrTransaction: Knex | Knex.Transaction, rule: PostgresRule): Knex.QueryBuilder<any, {
7
7
  _base: any;
8
8
  _hasSelection: true;
9
- _keys: "name" | "cumulus_id";
9
+ _keys: "cumulus_id";
10
10
  _aliases: {};
11
- _single: true;
11
+ _single: false;
12
12
  _intersectProps: {};
13
13
  _unionProps: never;
14
14
  }[]>;
@@ -10,8 +10,8 @@ import { PostgresRule } from './types/rule';
10
10
  export declare const createTestDatabase: (knex: Knex, dbName: string, dbUser: string) => Promise<void>;
11
11
  export declare const deleteTestDatabase: (knex: Knex, dbName: string) => Promise<any>;
12
12
  export declare const generateLocalTestDb: (testDbName: string, migrationDir: string, envParams: object) => Promise<{
13
- knex: Knex<any, unknown[]>;
14
- knexAdmin: Knex<any, unknown[]>;
13
+ knex: Knex<any, any[]>;
14
+ knexAdmin: Knex<any, any[]>;
15
15
  }>;
16
16
  export declare const destroyLocalTestDb: ({ knex, knexAdmin, testDbName, }: {
17
17
  knex: Knex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cumulus/db",
3
- "version": "14.0.0",
3
+ "version": "14.1.0",
4
4
  "description": "Utilities for working with the Cumulus DB",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -29,15 +29,15 @@
29
29
  "node": ">=14.19.1"
30
30
  },
31
31
  "dependencies": {
32
- "@cumulus/aws-client": "14.0.0",
33
- "@cumulus/common": "14.0.0",
34
- "@cumulus/errors": "14.0.0",
35
- "@cumulus/logger": "14.0.0",
36
- "@cumulus/message": "14.0.0",
37
- "@cumulus/types": "14.0.0",
32
+ "@cumulus/aws-client": "14.1.0",
33
+ "@cumulus/common": "14.1.0",
34
+ "@cumulus/errors": "14.1.0",
35
+ "@cumulus/logger": "14.1.0",
36
+ "@cumulus/message": "14.1.0",
37
+ "@cumulus/types": "14.1.0",
38
38
  "crypto-random-string": "^3.2.0",
39
39
  "is-valid-hostname": "1.0.2",
40
- "knex": "0.95.15",
40
+ "knex": "2.4.1",
41
41
  "lodash": "^4.17.21",
42
42
  "pg": "^8.3.0",
43
43
  "snake-camel": "^1.0.6",
@@ -46,5 +46,5 @@
46
46
  "devDependencies": {
47
47
  "@types/uuid": "^8.0.0"
48
48
  },
49
- "gitHead": "bc0cd0857e007b64e4e8809f7de16a4aeb1e6840"
49
+ "gitHead": "d97b5b37913944c0f0ecf958f2a567ec3714816c"
50
50
  }