@dmptool/utils 1.0.25 → 1.0.27
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.d.ts +1 -5
- package/dist/dynamo.js +11 -9
- package/package.json +1 -1
package/dist/dynamo.d.ts
CHANGED
|
@@ -13,10 +13,6 @@ interface DMPVersionType {
|
|
|
13
13
|
SK: string;
|
|
14
14
|
modified: string;
|
|
15
15
|
}
|
|
16
|
-
export interface LatestDMPVersion {
|
|
17
|
-
dmpId: string;
|
|
18
|
-
modified: string;
|
|
19
|
-
}
|
|
20
16
|
/**
|
|
21
17
|
* Lightweight query just to check if the DMP exists.
|
|
22
18
|
*
|
|
@@ -33,7 +29,7 @@ export declare const DMPExists: (dynamoConnectionParams: DynamoConnectionParams,
|
|
|
33
29
|
* @returns The latest version for every unique DMP ID
|
|
34
30
|
* @throws DMPToolDynamoError if the records could not be fetched due to an error
|
|
35
31
|
*/
|
|
36
|
-
export declare const getAllUniqueDMPIds: (dynamoConnectionParams: DynamoConnectionParams) => Promise<
|
|
32
|
+
export declare const getAllUniqueDMPIds: (dynamoConnectionParams: DynamoConnectionParams) => Promise<Map<string, string>>;
|
|
37
33
|
/**
|
|
38
34
|
* Fetch the version timestamps (including DMP_LATEST_VERSION) for the specified DMP ID.
|
|
39
35
|
*
|
package/dist/dynamo.js
CHANGED
|
@@ -97,26 +97,28 @@ const getAllUniqueDMPIds = async (dynamoConnectionParams) => {
|
|
|
97
97
|
}
|
|
98
98
|
// Get the PK, SK and modified timestamps for all the latest versions
|
|
99
99
|
const params = {
|
|
100
|
-
ProjectionExpression: "PK,
|
|
101
|
-
FilterExpression: `SK =
|
|
100
|
+
ProjectionExpression: "PK, #mod", // `modified` is a reserved word in DynamoDB
|
|
101
|
+
FilterExpression: `SK = :sk`,
|
|
102
|
+
ExpressionAttributeNames: { "#mod": "modified" },
|
|
103
|
+
ExpressionAttributeValues: {
|
|
104
|
+
":sk": { S: `${DMP_VERSION_PREFIX}#${exports.DMP_LATEST_VERSION}` }
|
|
105
|
+
}
|
|
102
106
|
};
|
|
103
107
|
try {
|
|
104
108
|
dynamoConnectionParams.logger.debug(Object.assign({}, params), 'Scanning for latest DMP versions in DynamoDB');
|
|
105
109
|
const response = await scanTable(dynamoConnectionParams, params);
|
|
106
110
|
if (Array.isArray(response) && response.length > 0) {
|
|
107
|
-
const versions =
|
|
111
|
+
const versions = new Map();
|
|
108
112
|
for (const item of response) {
|
|
109
113
|
const unmarshalled = (0, util_dynamodb_1.unmarshall)(item);
|
|
110
|
-
if (unmarshalled.PK && unmarshalled.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
modified: unmarshalled.modified
|
|
114
|
-
});
|
|
114
|
+
if (unmarshalled.PK && unmarshalled.modified) {
|
|
115
|
+
const dmpId = unmarshalled.PK.replace(`${DMP_PK_PREFIX}#`, 'https://');
|
|
116
|
+
versions.set(dmpId, unmarshalled.modified);
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
return versions;
|
|
118
120
|
}
|
|
119
|
-
return
|
|
121
|
+
return new Map();
|
|
120
122
|
}
|
|
121
123
|
catch (err) {
|
|
122
124
|
const errMsg = (0, general_1.toErrorMessage)(err);
|
package/package.json
CHANGED