@dmptool/utils 1.0.5 → 1.0.7
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/README.md +96 -76
- package/dist/cloudFormation.d.ts +4 -1
- package/dist/cloudFormation.js +17 -6
- package/dist/dynamo.d.ts +34 -12
- package/dist/dynamo.js +178 -86
- package/dist/eventBridge.d.ts +3 -1
- package/dist/eventBridge.js +41 -27
- package/dist/maDMP.d.ts +12 -3
- package/dist/maDMP.js +113 -73
- package/dist/rds.d.ts +11 -1
- package/dist/rds.js +33 -21
- package/dist/s3.d.ts +13 -4
- package/dist/s3.js +79 -39
- package/package.json +2 -1
package/dist/eventBridge.js
CHANGED
|
@@ -2,46 +2,60 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.putEvent = void 0;
|
|
4
4
|
const client_eventbridge_1 = require("@aws-sdk/client-eventbridge");
|
|
5
|
+
const general_1 = require("./general");
|
|
5
6
|
/**
|
|
6
7
|
* Publishes an event to EventBridge.
|
|
7
8
|
*
|
|
9
|
+
* @param logger The logger to use for logging.
|
|
8
10
|
* @param source The name of the caller (e.g. the Lambda Function or Application Function)
|
|
9
11
|
* @param detailType The type of event (resources typically watch for specific types of events)
|
|
10
12
|
* @param detail The payload of the event (will be accessible to the invoked resource)
|
|
11
13
|
*/
|
|
12
|
-
const putEvent = async (source, detailType, details) => {
|
|
13
|
-
var _a, _b, _c, _d
|
|
14
|
-
|
|
15
|
-
if (busName) {
|
|
14
|
+
const putEvent = async (logger, busName, source, detailType, details, region = 'us-west-2') => {
|
|
15
|
+
var _a, _b, _c, _d;
|
|
16
|
+
let errMsg = '';
|
|
17
|
+
if (logger && busName) {
|
|
16
18
|
// Create a new EventBridge client instance
|
|
17
|
-
const client = new client_eventbridge_1.EventBridgeClient({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
19
|
+
const client = new client_eventbridge_1.EventBridgeClient({ region });
|
|
20
|
+
logger.debug({ busName, source, detailType, details }, 'Publishing event');
|
|
21
|
+
try {
|
|
22
|
+
// Publish the event
|
|
23
|
+
const response = await client.send(new client_eventbridge_1.PutEventsCommand({
|
|
24
|
+
Entries: [
|
|
25
|
+
{
|
|
26
|
+
EventBusName: busName,
|
|
27
|
+
Detail: details ? JSON.stringify(details) : undefined,
|
|
28
|
+
DetailType: detailType,
|
|
29
|
+
Source: source,
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
}));
|
|
33
|
+
if (response) {
|
|
34
|
+
const statusCode = (_b = (_a = response.$metadata) === null || _a === void 0 ? void 0 : _a.httpStatusCode) !== null && _b !== void 0 ? _b : 500;
|
|
35
|
+
// We got a response, so return it.
|
|
36
|
+
return {
|
|
37
|
+
status: statusCode,
|
|
38
|
+
message: statusCode >= 200 && statusCode <= 300 ? "Ok" : "Failure",
|
|
39
|
+
eventId: (_d = (_c = response.Entries) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.EventId
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
logger.error({ busName, source, detailType, details }, 'No response from EventBridge');
|
|
44
|
+
errMsg = 'No response from EventBridge';
|
|
45
|
+
}
|
|
39
46
|
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
logger.fatal({ busName, source, detailType, details, error }, 'Error publishing event');
|
|
49
|
+
errMsg = `Error publishing event: ${(0, general_1.toErrorMessage)(error)}`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
errMsg = 'Missing logger or busName args!';
|
|
40
54
|
}
|
|
41
55
|
// The busName was not available or the response was undefined
|
|
42
56
|
return {
|
|
43
57
|
status: 500,
|
|
44
|
-
message:
|
|
58
|
+
message: errMsg,
|
|
45
59
|
eventId: undefined
|
|
46
60
|
};
|
|
47
61
|
};
|
package/dist/maDMP.d.ts
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
|
+
import { Logger } from 'pino';
|
|
2
|
+
import { ConnectionParams } from './rds';
|
|
3
|
+
import { EnvironmentEnum } from "./general";
|
|
1
4
|
import { DMPToolDMPType, DMPToolExtensionType } from "@dmptool/types";
|
|
2
5
|
/**
|
|
3
6
|
* Validate the specified DMP metadata record against the RDA Common Standard
|
|
4
7
|
* and DMP Tool extensions schema
|
|
5
8
|
*
|
|
9
|
+
* @param logger the logger to use for logging
|
|
6
10
|
* @param dmp The DMP metadata record to validate
|
|
7
11
|
* @returns the DMP metadata record if it is valid
|
|
8
12
|
* @throws DMPValidationError if the record is invalid with the error message(s)
|
|
9
13
|
*/
|
|
10
|
-
export declare const validateRDACommonStandard: (dmp: DMPToolDMPType) => DMPToolDMPType;
|
|
14
|
+
export declare const validateRDACommonStandard: (logger: Logger, dmp: DMPToolDMPType) => DMPToolDMPType;
|
|
11
15
|
/**
|
|
12
16
|
* Validate the specified DMP metadata record against the RDA Common Standard
|
|
13
17
|
* and DMP Tool extensions schema
|
|
14
18
|
*
|
|
19
|
+
* @param logger the logger to use for logging
|
|
15
20
|
* @param dmp The DMP metadata record to validate
|
|
16
21
|
* @returns the DMP metadata record if it is valid
|
|
17
22
|
* @throws DMPValidationError if the record is invalid with the error message(s)
|
|
18
23
|
*/
|
|
19
|
-
export declare const validateDMPToolExtensions: (dmp: DMPToolExtensionType) => DMPToolExtensionType;
|
|
24
|
+
export declare const validateDMPToolExtensions: (logger: Logger, dmpId: string, dmp: DMPToolExtensionType) => DMPToolExtensionType;
|
|
20
25
|
/**
|
|
21
26
|
*
|
|
22
27
|
* Generate a JSON representation for a DMP that confirms to the RDA Common Metadata
|
|
@@ -35,7 +40,11 @@ export declare const validateDMPToolExtensions: (dmp: DMPToolExtensionType) => D
|
|
|
35
40
|
* - The `registered` indicates whether the DMP is published/registered with DataCite/EZID
|
|
36
41
|
* - The `tombstoned` indicates that it was published/registered but is now removed
|
|
37
42
|
*
|
|
43
|
+
* @param rdsConnectionParams the connection parameters for the RDS instance
|
|
44
|
+
* @param applicationName the name of the application/service
|
|
45
|
+
* @param domainName the domain name of the application/service website
|
|
38
46
|
* @param planId the ID of the plan to generate the DMP for
|
|
47
|
+
* @param env The environment from EnvironmentEnum (defaults to EnvironmentEnum.DEV)
|
|
39
48
|
* @returns a JSON representation of the DMP
|
|
40
49
|
*/
|
|
41
|
-
export declare function planToDMPCommonStandard(planId: number): Promise<DMPToolDMPType | undefined>;
|
|
50
|
+
export declare function planToDMPCommonStandard(rdsConnectionParams: ConnectionParams, applicationName: string, domainName: string, env: EnvironmentEnum | undefined, planId: number): Promise<DMPToolDMPType | undefined>;
|