@dmptool/utils 1.0.21 → 1.0.23
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/dynamo.js +13 -9
- package/dist/eventBridge.d.ts +4 -0
- package/dist/eventBridge.js +4 -0
- package/package.json +1 -1
package/dist/dynamo.js
CHANGED
|
@@ -24,17 +24,19 @@ exports.DMP_LATEST_VERSION = 'latest';
|
|
|
24
24
|
exports.DMP_TOMBSTONE_VERSION = 'tombstone';
|
|
25
25
|
// The list of properties that are extensions to the RDA Common Standard
|
|
26
26
|
const EXTENSION_KEYS = [
|
|
27
|
+
'featured',
|
|
28
|
+
'funding_opportunity',
|
|
29
|
+
'funding_project',
|
|
30
|
+
'narrative',
|
|
27
31
|
'provenance',
|
|
28
32
|
'privacy',
|
|
29
|
-
'
|
|
33
|
+
'rda_schema_version',
|
|
30
34
|
'registered',
|
|
31
|
-
'tombstoned',
|
|
32
|
-
'narrative',
|
|
33
35
|
'research_domain',
|
|
34
36
|
'research_facility',
|
|
37
|
+
'status',
|
|
38
|
+
'tombstoned',
|
|
35
39
|
'version',
|
|
36
|
-
'funding_opportunity',
|
|
37
|
-
'funding_project'
|
|
38
40
|
];
|
|
39
41
|
class DMPToolDynamoError extends Error {
|
|
40
42
|
constructor(message) {
|
|
@@ -309,10 +311,12 @@ const createDMP = async (dynamoConnectionParams, domainName, dmpId, dmp, version
|
|
|
309
311
|
throw new DMPToolDynamoError('Missing Dynamo config, DMP ID or DMP metadata record');
|
|
310
312
|
}
|
|
311
313
|
// If the version is LATEST, then first make sure there is not already one present!
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
314
|
+
if (version === exports.DMP_LATEST_VERSION) {
|
|
315
|
+
const exists = await (0, exports.DMPExists)(dynamoConnectionParams, dmpId);
|
|
316
|
+
if (exists) {
|
|
317
|
+
dynamoConnectionParams.logger.error({ dmpId }, 'Latest version already exists');
|
|
318
|
+
throw new DMPToolDynamoError('Latest version already exists');
|
|
319
|
+
}
|
|
316
320
|
}
|
|
317
321
|
try {
|
|
318
322
|
// If the metadata is nested in a top level 'dmp' property, then unwrap it
|
package/dist/eventBridge.d.ts
CHANGED
|
@@ -8,8 +8,12 @@ export interface PutEventResponse {
|
|
|
8
8
|
* Publishes an event to EventBridge.
|
|
9
9
|
*
|
|
10
10
|
* @param logger The logger to use for logging.
|
|
11
|
+
* @param busName The name of the EventBridge bus to publish the event to.
|
|
11
12
|
* @param source The name of the caller (e.g. the Lambda Function or Application Function)
|
|
12
13
|
* @param detailType The type of event (resources typically watch for specific types of events)
|
|
13
14
|
* @param detail The payload of the event (will be accessible to the invoked resource)
|
|
15
|
+
* @param region The region to publish the event in. Defaults to 'us-west-2'.
|
|
16
|
+
* @returns A PutEventResponse object containing the status code and message of the response from EventBridge.
|
|
17
|
+
* @throws Error if there was an error publishing the event.
|
|
14
18
|
*/
|
|
15
19
|
export declare const putEvent: (logger: Logger, busName: string, source: string, detailType: string, details: Record<string, unknown>, region?: string) => Promise<PutEventResponse>;
|
package/dist/eventBridge.js
CHANGED
|
@@ -7,9 +7,13 @@ const general_1 = require("./general");
|
|
|
7
7
|
* Publishes an event to EventBridge.
|
|
8
8
|
*
|
|
9
9
|
* @param logger The logger to use for logging.
|
|
10
|
+
* @param busName The name of the EventBridge bus to publish the event to.
|
|
10
11
|
* @param source The name of the caller (e.g. the Lambda Function or Application Function)
|
|
11
12
|
* @param detailType The type of event (resources typically watch for specific types of events)
|
|
12
13
|
* @param detail The payload of the event (will be accessible to the invoked resource)
|
|
14
|
+
* @param region The region to publish the event in. Defaults to 'us-west-2'.
|
|
15
|
+
* @returns A PutEventResponse object containing the status code and message of the response from EventBridge.
|
|
16
|
+
* @throws Error if there was an error publishing the event.
|
|
13
17
|
*/
|
|
14
18
|
const putEvent = async (logger, busName, source, detailType, details, region = 'us-west-2') => {
|
|
15
19
|
var _a, _b, _c, _d;
|
package/package.json
CHANGED