@cumulus/db 10.1.2 → 11.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.
- package/dist/index.d.ts +13 -8
- package/dist/index.js +28 -11
- package/dist/lib/QuerySearchClient.d.ts +36 -0
- package/dist/lib/QuerySearchClient.js +51 -0
- package/dist/lib/collection.d.ts +10 -0
- package/dist/lib/collection.js +21 -0
- package/dist/lib/errors.d.ts +6 -0
- package/dist/lib/errors.js +8 -0
- package/dist/lib/execution.d.ts +21 -0
- package/dist/lib/execution.js +28 -1
- package/dist/lib/file.d.ts +33 -0
- package/dist/lib/file.js +61 -0
- package/dist/lib/granule.d.ts +35 -3
- package/dist/lib/granule.js +104 -8
- package/dist/migrations/20210914051414_add_type_to_files.d.ts +4 -0
- package/dist/migrations/20210914051414_add_type_to_files.js +18 -0
- package/dist/models/base.d.ts +63 -9
- package/dist/models/base.js +89 -12
- package/dist/models/collection.d.ts +4 -3
- package/dist/models/collection.js +4 -1
- package/dist/models/execution.d.ts +2 -0
- package/dist/models/execution.js +6 -2
- package/dist/models/file.d.ts +2 -2
- package/dist/models/file.js +2 -1
- package/dist/models/granule.d.ts +13 -2
- package/dist/models/granule.js +27 -13
- package/dist/models/pdr.js +2 -2
- package/dist/test-utils.js +3 -0
- package/dist/translate/async_operations.d.ts +13 -0
- package/dist/translate/async_operations.js +56 -2
- package/dist/translate/collections.d.ts +13 -2
- package/dist/translate/collections.js +31 -2
- package/dist/translate/file.js +3 -1
- package/dist/translate/granules.d.ts +15 -4
- package/dist/translate/granules.js +38 -14
- package/dist/translate/pdr.d.ts +29 -0
- package/dist/translate/pdr.js +82 -0
- package/dist/translate/providers.d.ts +2 -1
- package/dist/translate/providers.js +24 -1
- package/dist/translate/rules.d.ts +2 -1
- package/dist/translate/rules.js +34 -1
- package/dist/types/base.d.ts +5 -0
- package/dist/types/base.js +3 -0
- package/dist/types/collection.d.ts +6 -4
- package/dist/types/file.d.ts +3 -1
- package/dist/types/granule.d.ts +2 -1
- package/dist/types/pdr.d.ts +2 -1
- package/dist/types/provider.d.ts +1 -1
- package/dist/types/provider.js +6 -0
- package/dist/types/query.d.ts +10 -0
- package/dist/types/query.js +3 -0
- package/dist/types/record.d.ts +5 -0
- package/dist/types/record.js +3 -0
- package/dist/types/rule.d.ts +3 -2
- package/package.json +8 -8
- package/dist/translate/pdrs.d.ts +0 -19
- package/dist/translate/pdrs.js +0 -44
package/dist/translate/rules.js
CHANGED
|
@@ -1,9 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.translateApiRuleToPostgresRule = exports.translateApiRuleToPostgresRuleRaw = void 0;
|
|
3
|
+
exports.translateApiRuleToPostgresRule = exports.translateApiRuleToPostgresRuleRaw = exports.translatePostgresRuleToApiRule = void 0;
|
|
4
4
|
const util_1 = require("@cumulus/common/util");
|
|
5
5
|
const collection_1 = require("../models/collection");
|
|
6
6
|
const provider_1 = require("../models/provider");
|
|
7
|
+
const translatePostgresRuleToApiRule = async (pgRule, knex, collectionPgModel = new collection_1.CollectionPgModel(), providerPgModel = new provider_1.ProviderPgModel()) => {
|
|
8
|
+
const provider = pgRule.provider_cumulus_id
|
|
9
|
+
? await providerPgModel.get(knex, { cumulus_id: pgRule.provider_cumulus_id })
|
|
10
|
+
: undefined;
|
|
11
|
+
const collection = pgRule.collection_cumulus_id
|
|
12
|
+
? await collectionPgModel.get(knex, { cumulus_id: pgRule.collection_cumulus_id })
|
|
13
|
+
: undefined;
|
|
14
|
+
const apiRule = {
|
|
15
|
+
name: pgRule.name,
|
|
16
|
+
workflow: pgRule.workflow,
|
|
17
|
+
provider: provider ? provider.name : undefined,
|
|
18
|
+
collection: collection ? {
|
|
19
|
+
name: collection.name,
|
|
20
|
+
version: collection.version,
|
|
21
|
+
} : undefined,
|
|
22
|
+
rule: (0, util_1.removeNilProperties)({
|
|
23
|
+
type: pgRule.type,
|
|
24
|
+
arn: pgRule.arn,
|
|
25
|
+
logEventArn: pgRule.log_event_arn,
|
|
26
|
+
value: pgRule.value,
|
|
27
|
+
}),
|
|
28
|
+
state: pgRule.enabled ? 'ENABLED' : 'DISABLED',
|
|
29
|
+
meta: pgRule.meta,
|
|
30
|
+
payload: pgRule.payload,
|
|
31
|
+
executionNamePrefix: pgRule.execution_name_prefix,
|
|
32
|
+
queueUrl: pgRule.queue_url,
|
|
33
|
+
tags: pgRule.tags ? JSON.parse(pgRule.tags) : undefined,
|
|
34
|
+
createdAt: pgRule.created_at.getTime(),
|
|
35
|
+
updatedAt: pgRule.updated_at.getTime(),
|
|
36
|
+
};
|
|
37
|
+
return (0, util_1.removeNilProperties)(apiRule);
|
|
38
|
+
};
|
|
39
|
+
exports.translatePostgresRuleToApiRule = translatePostgresRuleToApiRule;
|
|
7
40
|
/**
|
|
8
41
|
* Generate a Postgres rule record from a DynamoDB record.
|
|
9
42
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DuplicateHandling } from '@cumulus/types';
|
|
1
2
|
export interface PostgresCollection {
|
|
2
3
|
name: string;
|
|
3
4
|
version: string;
|
|
@@ -5,19 +6,20 @@ export interface PostgresCollection {
|
|
|
5
6
|
granule_id_extraction_regex: string;
|
|
6
7
|
files: string;
|
|
7
8
|
process?: string;
|
|
8
|
-
duplicate_handling?:
|
|
9
|
+
duplicate_handling?: DuplicateHandling;
|
|
9
10
|
report_to_ems?: boolean;
|
|
10
|
-
sample_file_name
|
|
11
|
+
sample_file_name: string;
|
|
11
12
|
url_path?: string;
|
|
12
13
|
ignore_files_config_for_discovery?: boolean;
|
|
13
|
-
meta?:
|
|
14
|
+
meta?: object;
|
|
14
15
|
tags?: string;
|
|
15
16
|
created_at?: Date;
|
|
16
17
|
updated_at?: Date;
|
|
17
18
|
}
|
|
18
|
-
export interface PostgresCollectionRecord extends PostgresCollection {
|
|
19
|
+
export interface PostgresCollectionRecord extends Omit<PostgresCollection, 'tags'> {
|
|
19
20
|
cumulus_id: number;
|
|
20
21
|
created_at: Date;
|
|
21
22
|
updated_at: Date;
|
|
23
|
+
tags: string[];
|
|
22
24
|
}
|
|
23
25
|
//# sourceMappingURL=collection.d.ts.map
|
package/dist/types/file.d.ts
CHANGED
|
@@ -8,11 +8,13 @@ export interface PostgresFile {
|
|
|
8
8
|
file_size?: number;
|
|
9
9
|
path?: string;
|
|
10
10
|
source?: string;
|
|
11
|
+
type?: string;
|
|
11
12
|
}
|
|
12
|
-
export interface PostgresFileRecord extends PostgresFile {
|
|
13
|
+
export interface PostgresFileRecord extends Omit<PostgresFile, 'file_size'> {
|
|
13
14
|
bucket: string;
|
|
14
15
|
key: string;
|
|
15
16
|
cumulus_id: number;
|
|
17
|
+
file_size?: string;
|
|
16
18
|
created_at: Date;
|
|
17
19
|
updated_at: Date;
|
|
18
20
|
}
|
package/dist/types/granule.d.ts
CHANGED
|
@@ -24,8 +24,9 @@ export interface PostgresGranule extends PostgresGranuleUniqueColumns {
|
|
|
24
24
|
processing_end_date_time?: Date;
|
|
25
25
|
query_fields?: unknown;
|
|
26
26
|
}
|
|
27
|
-
export interface PostgresGranuleRecord extends PostgresGranule {
|
|
27
|
+
export interface PostgresGranuleRecord extends Omit<PostgresGranule, 'product_volume'> {
|
|
28
28
|
cumulus_id: number;
|
|
29
|
+
product_volume?: string;
|
|
29
30
|
created_at: Date;
|
|
30
31
|
updated_at: Date;
|
|
31
32
|
}
|
package/dist/types/pdr.d.ts
CHANGED
package/dist/types/provider.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface PostgresProvider {
|
|
|
27
27
|
* postgres for reading. It differs from the PostgresProvider interface in that it types
|
|
28
28
|
* the autogenerated/required fields in the Postgres database as required
|
|
29
29
|
*/
|
|
30
|
-
export interface PostgresProviderRecord extends
|
|
30
|
+
export interface PostgresProviderRecord extends PostgresProvider {
|
|
31
31
|
cumulus_id: number;
|
|
32
32
|
created_at: Date;
|
|
33
33
|
updated_at: Date;
|
package/dist/types/provider.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PostgresProvider
|
|
4
|
+
*
|
|
5
|
+
* This interface describes a Provider object in postgres compatible format that
|
|
6
|
+
* is ready for write to Cumulus's postgres database instance
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PostgresGranuleRecord } from './granule';
|
|
2
|
+
export declare type ProviderNameColumn = {
|
|
3
|
+
providerName: string;
|
|
4
|
+
};
|
|
5
|
+
export declare type CollectionNameAndVersionColumns = {
|
|
6
|
+
collectionName: string;
|
|
7
|
+
collectionVersion: string;
|
|
8
|
+
};
|
|
9
|
+
export declare type GranuleWithProviderAndCollectionInfo = PostgresGranuleRecord & ProviderNameColumn & CollectionNameAndVersionColumns;
|
|
10
|
+
//# sourceMappingURL=query.d.ts.map
|
package/dist/types/rule.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { RuleType, RuleMeta } from '@cumulus/types/api/rules';
|
|
1
2
|
export interface PostgresRule {
|
|
2
3
|
name: string;
|
|
3
4
|
workflow: string;
|
|
4
|
-
type:
|
|
5
|
+
type: RuleType;
|
|
5
6
|
enabled: boolean;
|
|
6
7
|
collection_cumulus_id?: number;
|
|
7
8
|
provider_cumulus_id?: number;
|
|
@@ -10,7 +11,7 @@ export interface PostgresRule {
|
|
|
10
11
|
arn?: string;
|
|
11
12
|
log_event_arn?: string;
|
|
12
13
|
payload?: object;
|
|
13
|
-
meta?:
|
|
14
|
+
meta?: RuleMeta;
|
|
14
15
|
tags?: string;
|
|
15
16
|
queue_url?: string;
|
|
16
17
|
created_at: Date | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cumulus/db",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
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": ">=12.18.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@cumulus/aws-client": "
|
|
33
|
-
"@cumulus/common": "
|
|
34
|
-
"@cumulus/errors": "
|
|
35
|
-
"@cumulus/logger": "
|
|
36
|
-
"@cumulus/message": "
|
|
37
|
-
"@cumulus/types": "
|
|
32
|
+
"@cumulus/aws-client": "11.0.0",
|
|
33
|
+
"@cumulus/common": "11.0.0",
|
|
34
|
+
"@cumulus/errors": "11.0.0",
|
|
35
|
+
"@cumulus/logger": "11.0.0",
|
|
36
|
+
"@cumulus/message": "11.0.0",
|
|
37
|
+
"@cumulus/types": "11.0.0",
|
|
38
38
|
"crypto-random-string": "^3.2.0",
|
|
39
39
|
"is-valid-hostname": "0.0.1",
|
|
40
40
|
"knex": "0.95.15",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/uuid": "^8.0.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "e922ad12fd94affa6cd60a97a184a465a756c50b"
|
|
50
50
|
}
|
package/dist/translate/pdrs.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Knex } from 'knex';
|
|
2
|
-
import { CollectionPgModel } from '../models/collection';
|
|
3
|
-
import { ExecutionPgModel } from '../models/execution';
|
|
4
|
-
import { ProviderPgModel } from '../models/provider';
|
|
5
|
-
import { PostgresPdr } from '../types/pdr';
|
|
6
|
-
/**
|
|
7
|
-
* Generate a Postgres PDR record from a DynamoDB record.
|
|
8
|
-
*
|
|
9
|
-
* @param {AWS.DynamoDB.DocumentClient.AttributeMap} dynamoRecord
|
|
10
|
-
* Record from DynamoDB
|
|
11
|
-
* @param {Knex | Knex.Transaction} knexOrTransaction
|
|
12
|
-
* Knex client for reading from RDS database
|
|
13
|
-
* @param {Object} collectionPgModel - Instance of the collection database model
|
|
14
|
-
* @param {Object} providerPgModel - Instance of the provider database model
|
|
15
|
-
* @param {Object} executionPgModel - Instance of the execution database model
|
|
16
|
-
* @returns {PostgresPdr} A PDR PG record
|
|
17
|
-
*/
|
|
18
|
-
export declare const translateApiPdrToPostgresPdr: (dynamoRecord: AWS.DynamoDB.DocumentClient.AttributeMap, knexOrTransaction: Knex | Knex.Transaction, collectionPgModel?: CollectionPgModel, providerPgModel?: ProviderPgModel, executionPgModel?: ExecutionPgModel) => Promise<PostgresPdr>;
|
|
19
|
-
//# sourceMappingURL=pdrs.d.ts.map
|
package/dist/translate/pdrs.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.translateApiPdrToPostgresPdr = void 0;
|
|
4
|
-
const collection_1 = require("../models/collection");
|
|
5
|
-
const execution_1 = require("../models/execution");
|
|
6
|
-
const provider_1 = require("../models/provider");
|
|
7
|
-
const { deconstructCollectionId } = require('@cumulus/message/Collections');
|
|
8
|
-
/**
|
|
9
|
-
* Generate a Postgres PDR record from a DynamoDB record.
|
|
10
|
-
*
|
|
11
|
-
* @param {AWS.DynamoDB.DocumentClient.AttributeMap} dynamoRecord
|
|
12
|
-
* Record from DynamoDB
|
|
13
|
-
* @param {Knex | Knex.Transaction} knexOrTransaction
|
|
14
|
-
* Knex client for reading from RDS database
|
|
15
|
-
* @param {Object} collectionPgModel - Instance of the collection database model
|
|
16
|
-
* @param {Object} providerPgModel - Instance of the provider database model
|
|
17
|
-
* @param {Object} executionPgModel - Instance of the execution database model
|
|
18
|
-
* @returns {PostgresPdr} A PDR PG record
|
|
19
|
-
*/
|
|
20
|
-
const translateApiPdrToPostgresPdr = async (dynamoRecord, knexOrTransaction, collectionPgModel = new collection_1.CollectionPgModel(), providerPgModel = new provider_1.ProviderPgModel(), executionPgModel = new execution_1.ExecutionPgModel()) => {
|
|
21
|
-
const { name, version } = deconstructCollectionId(dynamoRecord.collectionId);
|
|
22
|
-
const pdrRecord = {
|
|
23
|
-
name: dynamoRecord.pdrName,
|
|
24
|
-
provider_cumulus_id: await providerPgModel.getRecordCumulusId(knexOrTransaction, { name: dynamoRecord.provider }),
|
|
25
|
-
collection_cumulus_id: await collectionPgModel.getRecordCumulusId(knexOrTransaction, { name, version }),
|
|
26
|
-
execution_cumulus_id: dynamoRecord.execution
|
|
27
|
-
? await executionPgModel.getRecordCumulusId(knexOrTransaction, { url: dynamoRecord.execution })
|
|
28
|
-
: undefined,
|
|
29
|
-
status: dynamoRecord.status,
|
|
30
|
-
progress: dynamoRecord.progress,
|
|
31
|
-
pan_sent: dynamoRecord.PANSent,
|
|
32
|
-
pan_message: dynamoRecord.PANmessage,
|
|
33
|
-
stats: dynamoRecord.stats,
|
|
34
|
-
address: dynamoRecord.address,
|
|
35
|
-
original_url: dynamoRecord.originalUrl,
|
|
36
|
-
timestamp: dynamoRecord.timestamp ? new Date(dynamoRecord.timestamp) : undefined,
|
|
37
|
-
duration: dynamoRecord.duration,
|
|
38
|
-
created_at: new Date(dynamoRecord.createdAt),
|
|
39
|
-
updated_at: dynamoRecord.updatedAt ? new Date(dynamoRecord.updatedAt) : undefined,
|
|
40
|
-
};
|
|
41
|
-
return pdrRecord;
|
|
42
|
-
};
|
|
43
|
-
exports.translateApiPdrToPostgresPdr = translateApiPdrToPostgresPdr;
|
|
44
|
-
//# sourceMappingURL=pdrs.js.map
|