@dmptool/utils 1.0.5 → 1.0.6
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 +112 -72
- 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/README.md
CHANGED
|
@@ -61,14 +61,14 @@ Provides access to CloudFormation stack outputs.
|
|
|
61
61
|
|
|
62
62
|
For example, our CloudFormation stack for the S3 buckets outputs the names of each bucket. This code allows a Lambda Function to access those bucket names.
|
|
63
63
|
|
|
64
|
-
Environment variable requirements:
|
|
65
|
-
- `AWS_REGION` The AWS region where the DynamoDB table is located
|
|
66
|
-
|
|
67
64
|
### Example usage
|
|
68
65
|
```typescript
|
|
69
|
-
import { getExport } from '@dmptool/utils';
|
|
66
|
+
import { getExport, initializeLogger, LogLevelEnum } from '@dmptool/utils';
|
|
70
67
|
|
|
71
|
-
|
|
68
|
+
// Initialize a logger
|
|
69
|
+
const logger: Logger = initializeLogger('exampleSSM', LogLevelEnum.DEBUG);
|
|
70
|
+
|
|
71
|
+
const tableName = await getExport(logger, 'DynamoTableNames');
|
|
72
72
|
console.log(tableName);
|
|
73
73
|
```
|
|
74
74
|
|
|
@@ -95,13 +95,6 @@ A DMP SK for a specific version of the DMP Tool extensions looks like this: `EXT
|
|
|
95
95
|
|
|
96
96
|
These keys are attached to the DMP JSON when persisting it to DynamoDB and removed when returning it from DynamoDB.
|
|
97
97
|
|
|
98
|
-
Environment variable requirements:
|
|
99
|
-
- `AWS_REGION` The AWS region where the DynamoDB table is located
|
|
100
|
-
- `DOMAIN_NAME` The domain name of the application
|
|
101
|
-
- `DYNAMODB_TABLE_NAME` The name of the DynamoDB table
|
|
102
|
-
- `DYNAMO_MAX_ATTEMPTS` The maximum number of times to retry a DynamoDB operation (defaults to 3)
|
|
103
|
-
- `VERSION_GRACE_PERIOD` The number of seconds to wait before considering a change should generate a version snapshot (defaults to 7200000 => 2 hours)
|
|
104
|
-
|
|
105
98
|
## Example Usage:
|
|
106
99
|
```typescript
|
|
107
100
|
import { DMPToolDMPType } from '@dmptool/types';
|
|
@@ -112,13 +105,23 @@ import {
|
|
|
112
105
|
DMP_LATEST_VERSION,
|
|
113
106
|
getDMPs,
|
|
114
107
|
getDMPVersions,
|
|
108
|
+
initializeLogger,
|
|
109
|
+
LogLevelEnum,
|
|
115
110
|
tombstoneDMP,
|
|
116
111
|
updateDMP
|
|
117
112
|
} from '@dmptool/utils';
|
|
118
113
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
114
|
+
// Initialize a logger
|
|
115
|
+
const logger: Logger = initializeLogger('exampleSSM', LogLevelEnum.DEBUG);
|
|
116
|
+
|
|
117
|
+
const dynamoConfig = {
|
|
118
|
+
logger,
|
|
119
|
+
region: 'us-west-2',
|
|
120
|
+
tableName: 'my-dynamo-table',
|
|
121
|
+
maxAttempts: 3
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const gracePeriodInMS = 7200000;
|
|
122
125
|
|
|
123
126
|
const dmpId = '123456789';
|
|
124
127
|
|
|
@@ -159,13 +162,13 @@ const dmpObj: DMPToolDMPType = {
|
|
|
159
162
|
}
|
|
160
163
|
|
|
161
164
|
// First make sure the DMP doesn't already exist
|
|
162
|
-
const exists = await DMPExists(dmpId);
|
|
165
|
+
const exists = await DMPExists(dynamoConfig, dmpId);
|
|
163
166
|
if (exists) {
|
|
164
167
|
console.log('DMP already exists');
|
|
165
168
|
|
|
166
169
|
} else {
|
|
167
170
|
// Create the DMP
|
|
168
|
-
const created: DMPToolDMPType = await createDMP(dmpId, dmpObj);
|
|
171
|
+
const created: DMPToolDMPType = await createDMP(dynamoConfig, domainName, dmpId, dmpObj);
|
|
169
172
|
if (!created) {
|
|
170
173
|
console.log('Failed to create DMP');
|
|
171
174
|
|
|
@@ -174,17 +177,20 @@ if (exists) {
|
|
|
174
177
|
dmpObj.dmp.modified = '2026-01-10T03:43:11Z';
|
|
175
178
|
|
|
176
179
|
// Update the DMP
|
|
177
|
-
const updated: DMPToolDMPType = await updateDMP(dmpObj);
|
|
180
|
+
const updated: DMPToolDMPType = await updateDMP(dynamoConfig, domainName, dmpObj, gracePeriodInMS);
|
|
178
181
|
if (!updated) {
|
|
179
182
|
console.log('Failed to update DMP');
|
|
180
183
|
|
|
181
184
|
} else {
|
|
182
185
|
// Fetch the DMP version timestamps (should only be two)
|
|
183
|
-
const versions = await getDMPVersions(dmpId);
|
|
186
|
+
const versions = await getDMPVersions(dynamoConfig, dmpId);
|
|
184
187
|
console.log(versions);
|
|
185
188
|
|
|
186
|
-
// Fetch the latest version of the DMP
|
|
187
|
-
const latest = await
|
|
189
|
+
// Fetch the latest version of the DMP (RDA Common Standard with DMP Tool extensions)
|
|
190
|
+
const latest = await getDMPs(dynamoConfig, domainName, dmpId, DMP_LATEST_VERSION);
|
|
191
|
+
// Fetch the latest version of the DMP (RDA Common Standard only)
|
|
192
|
+
const rdaOnly = await getDMPs(dynamoConfig, domainName, dmpId, DMP_LATEST_VERSION, false);
|
|
193
|
+
|
|
188
194
|
if (!latest) {
|
|
189
195
|
console.log('Failed to fetch latest version of DMP');
|
|
190
196
|
|
|
@@ -192,11 +198,11 @@ if (exists) {
|
|
|
192
198
|
// If the DMP has a `registered` timestamp then it is published and can be tombstoned not deleted
|
|
193
199
|
// Since our example is not, we include this code here for reference only
|
|
194
200
|
|
|
195
|
-
// const tombstoned = await tombstoneDMP(dmpId);
|
|
201
|
+
// const tombstoned = await tombstoneDMP(dynamoConfig, domainName, dmpId);
|
|
196
202
|
// console.log( tombstoned
|
|
197
203
|
|
|
198
204
|
// Delete the DMP (can be done because the DMP is not published)
|
|
199
|
-
const deleted = await deleteDMP(dmpId);
|
|
205
|
+
const deleted = await deleteDMP(dynamoConfig, domainName, dmpId);
|
|
200
206
|
console.log(deleted);
|
|
201
207
|
}
|
|
202
208
|
}
|
|
@@ -207,31 +213,30 @@ if (exists) {
|
|
|
207
213
|
|
|
208
214
|
This code can be used to publish events to the EventBridge.
|
|
209
215
|
|
|
210
|
-
Environment variable requirements:
|
|
211
|
-
- `AWS_REGION` - The AWS region where the Lambda Function is running
|
|
212
|
-
- `EVENTBRIDGE_BUS_NAME` - The ARN of the EventBridge Bus to publish events to
|
|
213
|
-
|
|
214
216
|
### Example usage
|
|
215
217
|
```typescript
|
|
216
|
-
import { publishMessage } from '@dmptool/utils';
|
|
218
|
+
import { initializeLogger, LogLevelEnum, publishMessage } from '@dmptool/utils';
|
|
217
219
|
|
|
218
|
-
|
|
220
|
+
const region = 'us-west-2';
|
|
219
221
|
|
|
220
|
-
|
|
222
|
+
// Initialize a logger
|
|
223
|
+
const logger: Logger = initializeLogger('exampleSSM', LogLevelEnum.DEBUG);
|
|
224
|
+
|
|
225
|
+
const busName = 'arn:aws:sns:us-east-1:123456789012:my-topic';
|
|
221
226
|
|
|
222
227
|
// See the documentation for the AWS Lambda you are trying to invoke to determine what the
|
|
223
228
|
// `detail-type` and `detail` payload should look like.
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
property1: 'value1',
|
|
228
|
-
property2: 'value2'
|
|
229
|
-
}
|
|
230
|
-
}
|
|
229
|
+
const source = 'my-application';
|
|
230
|
+
const detailType = 'my-event';
|
|
231
|
+
const detail = { property1: 'value1', property2: 'value2' }
|
|
231
232
|
|
|
232
233
|
const response = await publishMessage(
|
|
233
|
-
|
|
234
|
-
|
|
234
|
+
logger,
|
|
235
|
+
busName,
|
|
236
|
+
source,
|
|
237
|
+
detailType,
|
|
238
|
+
detail,
|
|
239
|
+
region
|
|
235
240
|
);
|
|
236
241
|
|
|
237
242
|
if (response.statusCode === 200) {
|
|
@@ -330,12 +335,6 @@ Details about the RDA Common Metadata Standard can be found in the JSON examples
|
|
|
330
335
|
|
|
331
336
|
**Current RDA Common Metadata Standard Version:** v1.2
|
|
332
337
|
|
|
333
|
-
Environment variable requirements:
|
|
334
|
-
- `AWS_REGION` - The AWS region where the Lambda Function is running
|
|
335
|
-
- `ENV`: The AWS environment (e.g. `dev`, `stg`, `prd`)
|
|
336
|
-
- `APPLICATION_NAME`: The name of your application (NO spaces!, this is used to construct identifier namespaces)
|
|
337
|
-
- `DOMAIN_NAME`: The domain name of your application
|
|
338
|
-
|
|
339
338
|
### Notes
|
|
340
339
|
|
|
341
340
|
**DMP IDs:**
|
|
@@ -366,15 +365,33 @@ The `narrative` property in the JSON object represents the Template, Sections, Q
|
|
|
366
365
|
### Example usage
|
|
367
366
|
```typescript
|
|
368
367
|
import { DMPToolDMPType } from '@dmptool/types';
|
|
369
|
-
import { planToDMPCommonStandard } from '@dmptool/utils';
|
|
368
|
+
import { EnvironmentEnum, initializeLogger, LogLevelEnum, planToDMPCommonStandard } from '@dmptool/utils';
|
|
370
369
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
370
|
+
const region = 'us-west-2';
|
|
371
|
+
const env = EnvironmentEnum.DEV;
|
|
372
|
+
const applicationName = 'your-application';
|
|
373
|
+
const domainName = 'your-domain.com';
|
|
374
|
+
|
|
375
|
+
// Initialize a logger
|
|
376
|
+
const logger: Logger = initializeLogger('exampleSSM', LogLevelEnum.DEBUG);
|
|
377
|
+
|
|
378
|
+
const rdsConfig = {
|
|
379
|
+
logger,
|
|
380
|
+
host: 'some-rds-instance.us-east-1.rds.amazonaws.com',
|
|
381
|
+
port: 3306,
|
|
382
|
+
user: 'my_user',
|
|
383
|
+
password: 'open-sesame',
|
|
384
|
+
database: 'my_database'
|
|
385
|
+
}
|
|
375
386
|
|
|
376
387
|
const planId = '12345';
|
|
377
|
-
const dmp: DMPToolDMPType = await planToDMPCommonStandard(
|
|
388
|
+
const dmp: DMPToolDMPType = await planToDMPCommonStandard(
|
|
389
|
+
rdsConfig,
|
|
390
|
+
applicationName,
|
|
391
|
+
domainName,
|
|
392
|
+
planId,
|
|
393
|
+
env
|
|
394
|
+
);
|
|
378
395
|
```
|
|
379
396
|
|
|
380
397
|
## Example of a minimal JSON object:
|
|
@@ -674,28 +691,25 @@ This code can be used by to provide access to the RDS MySQL database.
|
|
|
674
691
|
|
|
675
692
|
It provides a simple `queryTable` function which can be used to query a table. Similar to the way we do so within the Apollo server backend code.
|
|
676
693
|
|
|
677
|
-
Environment variable requirements:
|
|
678
|
-
- `AWS_REGION` - The AWS region where the Lambda Function is running
|
|
679
|
-
- `RDS_HOST` The endpoint of the RDS instance
|
|
680
|
-
- `RDS_PORT` The port (defaults to 3306)
|
|
681
|
-
- `RDS_USER` The name of the user (defaults to "root")
|
|
682
|
-
- `RDS_PASSWORD` The user's password
|
|
683
|
-
- `RDS_DATABASE` The name of the database
|
|
684
|
-
|
|
685
694
|
### Example usage
|
|
686
695
|
```typescript
|
|
687
|
-
import { queryTable } from '@dmptool/utils';
|
|
696
|
+
import { initializeLogger, LogLevelEnum, queryTable } from '@dmptool/utils';
|
|
688
697
|
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
698
|
+
// Initialize a logger
|
|
699
|
+
const logger: Logger = initializeLogger('exampleSSM', LogLevelEnum.DEBUG);
|
|
700
|
+
|
|
701
|
+
const config = {
|
|
702
|
+
logger,
|
|
703
|
+
host: 'some-rds-instance.us-east-1.rds.amazonaws.com',
|
|
704
|
+
port: 3306,
|
|
705
|
+
user: 'my_user',
|
|
706
|
+
password: 'open-sesame',
|
|
707
|
+
database: 'my_database',
|
|
708
|
+
}
|
|
695
709
|
|
|
696
710
|
const sql = 'SELECT * FROM some_table WHERE id = ?';
|
|
697
711
|
const id = 1234;
|
|
698
|
-
const resp = await queryTable(sql, [planId.toString()])
|
|
712
|
+
const resp = await queryTable(config, sql, [planId.toString()])
|
|
699
713
|
|
|
700
714
|
if (resp && Array.isArray(resp.results) && resp.results.length > 0) {
|
|
701
715
|
console.log('It worked!', resp.results[0]);
|
|
@@ -719,9 +733,9 @@ Environment variable requirements:
|
|
|
719
733
|
|
|
720
734
|
### Example usage
|
|
721
735
|
```typescript
|
|
722
|
-
import { getObject, getPresignedURL, listBuckets, putObject } from '@dmptool/utils';
|
|
736
|
+
import { getObject, getPresignedURL, initializeLogger, listBuckets, LogLevelEnum, putObject } from '@dmptool/utils';
|
|
723
737
|
|
|
724
|
-
|
|
738
|
+
const region = 'us-west-2';
|
|
725
739
|
|
|
726
740
|
const bucketName = 'my-bucket';
|
|
727
741
|
const objectKey = 'my-object.txt';
|
|
@@ -729,31 +743,37 @@ const objectKey = 'my-object.txt';
|
|
|
729
743
|
const fileName = 'my-file.json.gz'
|
|
730
744
|
const gzippedData = zlib.gzipSync(JSON.stringify({ testing: { foo: 'bar' } }));
|
|
731
745
|
|
|
746
|
+
// Initialize a logger
|
|
747
|
+
const logger: Logger = initializeLogger('exampleSSM', LogLevelEnum.DEBUG);
|
|
748
|
+
|
|
732
749
|
// List the objects to verify that we're able to access the bucket)
|
|
733
|
-
const s3Objects = await listObjects(bucketName, '');
|
|
750
|
+
const s3Objects = await listObjects(logger, bucketName, '', region);
|
|
734
751
|
console.log('Objects in bucket:', s3Objects);
|
|
735
752
|
|
|
736
753
|
// First put the item into the bucket
|
|
737
754
|
const response = await putObject(
|
|
755
|
+
logger,
|
|
738
756
|
bucketName,
|
|
739
757
|
fileName,
|
|
740
758
|
gzippedData,
|
|
741
|
-
'application/json',
|
|
759
|
+
'application/json',
|
|
760
|
+
'gzip',
|
|
761
|
+
region
|
|
742
762
|
);
|
|
743
763
|
|
|
744
764
|
if (response) {
|
|
745
765
|
console.log('Object uploaded successfully');
|
|
746
766
|
|
|
747
767
|
// Get the object we just uploaded from the bucket
|
|
748
|
-
const object = await getObject(bucketName, objectKey);
|
|
768
|
+
const object = await getObject(logger, bucketName, objectKey, region);
|
|
749
769
|
console.log('Object fetched from bucket:', object);
|
|
750
770
|
|
|
751
771
|
// Generate a presigned URL to access the object from outside the VPC
|
|
752
|
-
const url = await getPresignedURL(bucketName, objectKey);
|
|
772
|
+
const url = await getPresignedURL(logger, bucketName, objectKey, false, region);
|
|
753
773
|
console.log('Presigned URL to fetch the Object:', url);
|
|
754
774
|
|
|
755
775
|
// Generate a presigned URL to put an object into the bucket from outside the VPC
|
|
756
|
-
const putURL = await getPresignedURL(bucketName, `2nd-${objectKey}`, true);
|
|
776
|
+
const putURL = await getPresignedURL(logger, bucketName, `2nd-${objectKey}`, true, region);
|
|
757
777
|
console.log('Presigned URL to put a new the Object into the bucket', putURL);
|
|
758
778
|
} else {
|
|
759
779
|
console.log('Failed to upload object');
|
|
@@ -768,11 +788,11 @@ The code will use that value to construct the appropriate prefix for the key. Fo
|
|
|
768
788
|
|
|
769
789
|
### Example usage
|
|
770
790
|
```typescript
|
|
771
|
-
import {
|
|
791
|
+
import {EnvironmentEnum, initializeLogger, getSSMParameter, LogLevelEnum } from '@dmptool/utils';
|
|
772
792
|
|
|
773
793
|
process.env.AWS_REGION = 'us-west-2';
|
|
774
794
|
|
|
775
|
-
// Initialize
|
|
795
|
+
// Initialize a logger
|
|
776
796
|
const logger: Logger = initializeLogger('exampleSSM', LogLevelEnum.DEBUG);
|
|
777
797
|
|
|
778
798
|
const paramName = 'RdsDatabase';
|
package/dist/cloudFormation.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { Logger } from 'pino';
|
|
1
2
|
/**
|
|
2
3
|
* Fetch the value for the specified CloudFormation stack export.
|
|
3
4
|
*
|
|
5
|
+
* @param logger The logger to use for logging.
|
|
4
6
|
* @param name The name of the CloudFormation stack export to fetch.
|
|
5
7
|
* @returns The value of the CloudFormation stack export, or undefined if the
|
|
6
8
|
* export could not be found.
|
|
9
|
+
* @throws Error if there was an error fetching the export.
|
|
7
10
|
*/
|
|
8
|
-
export declare const getExport: (name: string) => Promise<string | undefined>;
|
|
11
|
+
export declare const getExport: (logger: Logger, name: string) => Promise<string | undefined>;
|
package/dist/cloudFormation.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getExport = void 0;
|
|
4
|
+
const general_1 = require("./general");
|
|
4
5
|
const client_cloudformation_1 = require("@aws-sdk/client-cloudformation");
|
|
5
6
|
// If you want to make a CloudFormation stack output available for to this Lambda Layer, you need to
|
|
6
7
|
// ensure that your CloudFormation template "exports" the output variable. Note that you should try
|
|
@@ -40,15 +41,25 @@ const loadExports = async () => {
|
|
|
40
41
|
/**
|
|
41
42
|
* Fetch the value for the specified CloudFormation stack export.
|
|
42
43
|
*
|
|
44
|
+
* @param logger The logger to use for logging.
|
|
43
45
|
* @param name The name of the CloudFormation stack export to fetch.
|
|
44
46
|
* @returns The value of the CloudFormation stack export, or undefined if the
|
|
45
47
|
* export could not be found.
|
|
48
|
+
* @throws Error if there was an error fetching the export.
|
|
46
49
|
*/
|
|
47
|
-
const getExport = async (name) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
const getExport = async (logger, name) => {
|
|
51
|
+
try {
|
|
52
|
+
logger.debug({ name }, 'Fetching CloudFormation export');
|
|
53
|
+
await loadExports();
|
|
54
|
+
const response = cfExports.find((exp) => {
|
|
55
|
+
return (exp === null || exp === void 0 ? void 0 : exp.Name.toLowerCase().trim()) === name.toLowerCase().trim();
|
|
56
|
+
});
|
|
57
|
+
return response ? response.Value : undefined;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const errMsg = (0, general_1.toErrorMessage)(error);
|
|
61
|
+
logger.fatal({ name, error: errMsg }, 'Error fetching CloudFormation export');
|
|
62
|
+
throw new Error(errMsg);
|
|
63
|
+
}
|
|
53
64
|
};
|
|
54
65
|
exports.getExport = getExport;
|
package/dist/dynamo.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import { Logger } from 'pino';
|
|
1
2
|
import { DMPToolDMPType } from '@dmptool/types';
|
|
2
3
|
export declare const DMP_LATEST_VERSION = "latest";
|
|
3
4
|
export declare const DMP_TOMBSTONE_VERSION = "tombstone";
|
|
5
|
+
export interface DynamoConnectionParams {
|
|
6
|
+
logger: Logger;
|
|
7
|
+
region: string;
|
|
8
|
+
tableName: string;
|
|
9
|
+
maxAttempts: number;
|
|
10
|
+
}
|
|
4
11
|
interface DMPVersionType {
|
|
5
12
|
PK: string;
|
|
6
13
|
SK: string;
|
|
@@ -9,24 +16,28 @@ interface DMPVersionType {
|
|
|
9
16
|
/**
|
|
10
17
|
* Lightweight query just to check if the DMP exists.
|
|
11
18
|
*
|
|
12
|
-
* @param
|
|
19
|
+
* @param dynamoConnectionParams the DynamoDB connection parameters
|
|
20
|
+
* @param dmpId the DMP ID (e.g. 'doi.org/11.12345/A1B2C3D4')
|
|
13
21
|
* @returns true if the DMP exists, false otherwise.
|
|
14
22
|
* @throws DMPToolDynamoError if the record could not be fetched due to an error
|
|
15
23
|
*/
|
|
16
|
-
export declare const DMPExists: (dmpId: string) => Promise<boolean>;
|
|
24
|
+
export declare const DMPExists: (dynamoConnectionParams: DynamoConnectionParams, dmpId: string) => Promise<boolean>;
|
|
17
25
|
/**
|
|
18
26
|
* Fetch the version timestamps (including DMP_LATEST_VERSION) for the specified DMP ID.
|
|
19
27
|
*
|
|
20
|
-
* @param
|
|
28
|
+
* @param dynamoConnectionParams the DynamoDB connection parameters
|
|
29
|
+
* @param dmpId the DMP ID (e.g. 'doi.org/11.12345/A1B2C3D4')
|
|
21
30
|
* @returns The timestamps as strings (e.g. '2026-11-01T13:08:19Z' or 'latest')
|
|
22
31
|
* @throws DMPToolDynamoError if the records could not be fetched due to an error
|
|
23
32
|
*/
|
|
24
|
-
export declare const getDMPVersions: (dmpId: string) => Promise<DMPVersionType[] | []>;
|
|
33
|
+
export declare const getDMPVersions: (dynamoConnectionParams: DynamoConnectionParams, dmpId: string) => Promise<DMPVersionType[] | []>;
|
|
25
34
|
/**
|
|
26
35
|
* Fetch the RDA Common Standard metadata record with DMP Tool specific extensions
|
|
27
36
|
* for the specified DMP ID.
|
|
28
37
|
*
|
|
29
|
-
* @param
|
|
38
|
+
* @param dynamoConnectionParams the DynamoDB connection parameters
|
|
39
|
+
* @param domainName The domain name of the DMPTool instance (e.g. 'dmptool.org')
|
|
40
|
+
* @param dmpId the DMP ID (e.g. 'doi.org/11.12345/A1B2C3D4')
|
|
30
41
|
* @param version The version of the DMP metadata record to persist
|
|
31
42
|
* (e.g. '2026-11-01T13:08:19Z').
|
|
32
43
|
* If not provided, the latest version will be used. Defaults to DMP_LATEST_VERSION.
|
|
@@ -36,13 +47,15 @@ export declare const getDMPVersions: (dmpId: string) => Promise<DMPVersionType[]
|
|
|
36
47
|
* metadata or an empty array if none were found.
|
|
37
48
|
* @throws DMPToolDynamoError if the records could not be fetched due to an error
|
|
38
49
|
*/
|
|
39
|
-
export declare const getDMPs: (dmpId: string, version: string | null, includeExtensions?: boolean) => Promise<DMPToolDMPType[] | []>;
|
|
50
|
+
export declare const getDMPs: (dynamoConnectionParams: DynamoConnectionParams, domainName: string, dmpId: string, version: string | null, includeExtensions?: boolean) => Promise<DMPToolDMPType[] | []>;
|
|
40
51
|
/**
|
|
41
52
|
* Persists the specified DMP metadata record to the DynamoDB table.
|
|
42
53
|
* This function will handle the separation of RDA Common Standard and DMP Tool
|
|
43
54
|
* specific metadata.
|
|
44
55
|
*
|
|
45
|
-
* @param
|
|
56
|
+
* @param dynamoConnectionParams The DynamoDB connection parameters
|
|
57
|
+
* @param domainName The domain name of the DMPTool instance (e.g. 'dmptool.org')
|
|
58
|
+
* @param dmpId the DMP ID (e.g. 'doi.org/11.12345/A1B2C3D4')
|
|
46
59
|
* @param dmp The DMP metadata record to persist as either an RDA Common Standard
|
|
47
60
|
* or the standard with DMP Tool specific extensions.
|
|
48
61
|
* @param version The version of the DMP metadata record to persist
|
|
@@ -54,7 +67,7 @@ export declare const getDMPs: (dmpId: string, version: string | null, includeExt
|
|
|
54
67
|
* metadata record with the DMP Tool specific extensions merged in.
|
|
55
68
|
* @throws DMPToolDynamoError if the record could not be persisted
|
|
56
69
|
*/
|
|
57
|
-
export declare const createDMP: (dmpId: string, dmp: DMPToolDMPType, version?: string, includeExtensions?: boolean) => Promise<DMPToolDMPType | undefined>;
|
|
70
|
+
export declare const createDMP: (dynamoConnectionParams: DynamoConnectionParams, domainName: string, dmpId: string, dmp: DMPToolDMPType, version?: string, includeExtensions?: boolean) => Promise<DMPToolDMPType | undefined>;
|
|
58
71
|
/**
|
|
59
72
|
* Update the specified DMP metadata record.
|
|
60
73
|
* This function will handle the separation of RDA Common Standard and DMP Tool
|
|
@@ -70,18 +83,25 @@ export declare const createDMP: (dmpId: string, dmp: DMPToolDMPType, version?: s
|
|
|
70
83
|
* If a snapshot is made, the timestamp and link to retrieve it will appear
|
|
71
84
|
* in the `versions` array
|
|
72
85
|
*
|
|
73
|
-
* @param
|
|
86
|
+
* @param dynamoConnectionParams the DynamoDB connection parameters
|
|
87
|
+
* @param domainName The domain name of the DMPTool instance (e.g. 'dmptool.org')
|
|
88
|
+
* @param dmp The DMP metadata record to persist as either an RDA Common Standard
|
|
89
|
+
* or the standard with DMP Tool specific extensions.
|
|
90
|
+
* @param gracePeriodInMS The grace period in milliseconds to wait before creating
|
|
74
91
|
* @param includeExtensions Whether or not to include the DMP Tool specific
|
|
75
92
|
* extensions in the returned record. Defaults to true.
|
|
76
93
|
* @returns The persisted DMP metadata record as an RDA Common Standard DMP
|
|
77
94
|
* metadata record with the DMP Tool specific extensions merged in.
|
|
78
95
|
* @throws DMPToolDynamoError if the record could not be persisted
|
|
79
96
|
*/
|
|
80
|
-
export declare const updateDMP: (dmp: DMPToolDMPType,
|
|
97
|
+
export declare const updateDMP: (dynamoConnectionParams: DynamoConnectionParams, domainName: string, dmp: DMPToolDMPType, gracePeriodInMS?: number, // 2 hours in milliseconds
|
|
98
|
+
includeExtensions?: boolean) => Promise<DMPToolDMPType>;
|
|
81
99
|
/**
|
|
82
100
|
* Create a Tombstone for the specified DMP metadata record
|
|
83
101
|
* (registered/published DMPs only!)
|
|
84
102
|
*
|
|
103
|
+
* @param dynamoConnectionParams The DynamoDB connection parameters
|
|
104
|
+
* @param domainName The domain name of the DMPTool instance (e.g. 'dmptool.org')
|
|
85
105
|
* @param dmpId The DMP ID (e.g. '11.12345/A1B2C3')
|
|
86
106
|
* @param includeExtensions Whether or not to include the DMP Tool specific
|
|
87
107
|
* extensions in the returned record. Defaults to true.
|
|
@@ -89,11 +109,13 @@ export declare const updateDMP: (dmp: DMPToolDMPType, includeExtensions?: boolea
|
|
|
89
109
|
* metadata record with the DMP Tool specific extensions merged in.
|
|
90
110
|
* @throws DMPToolDynamoError if a tombstone could not be created
|
|
91
111
|
*/
|
|
92
|
-
export declare const tombstoneDMP: (dmpId: string, includeExtensions?: boolean) => Promise<DMPToolDMPType>;
|
|
112
|
+
export declare const tombstoneDMP: (dynamoConnectionParams: DynamoConnectionParams, domainName: string, dmpId: string, includeExtensions?: boolean) => Promise<DMPToolDMPType>;
|
|
93
113
|
/**
|
|
94
114
|
* Delete the specified DMP metadata record and any associated DMP Tool extension records.
|
|
95
115
|
* This will NOT work on DMPs that have been registered/published.
|
|
96
116
|
*
|
|
117
|
+
* @param dynamoConnectionParams The DynamoDB connection parameters
|
|
118
|
+
* @param domainName The domain name of the DMPTool instance (e.g. 'dmptool.org')
|
|
97
119
|
* @param dmpId The DMP ID (e.g. '11.12345/A1B2C3')
|
|
98
120
|
* @param includeExtensions Whether or not to include the DMP Tool specific extensions
|
|
99
121
|
* in the returned record. Defaults to true.
|
|
@@ -101,5 +123,5 @@ export declare const tombstoneDMP: (dmpId: string, includeExtensions?: boolean)
|
|
|
101
123
|
* record with the DMP Tool specific extensions merged in.
|
|
102
124
|
* @throws DMPToolDynamoError if the record could not be deleted
|
|
103
125
|
*/
|
|
104
|
-
export declare const deleteDMP: (dmpId: string, includeExtensions?: boolean) => Promise<DMPToolDMPType>;
|
|
126
|
+
export declare const deleteDMP: (dynamoConnectionParams: DynamoConnectionParams, domainName: string, dmpId: string, includeExtensions?: boolean) => Promise<DMPToolDMPType>;
|
|
105
127
|
export {};
|