@dmptool/utils 1.0.25 → 1.0.26
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 +8 -8
- 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,26 @@ 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: { ":sk": `${DMP_VERSION_PREFIX}#${exports.DMP_LATEST_VERSION}` }
|
|
102
104
|
};
|
|
103
105
|
try {
|
|
104
106
|
dynamoConnectionParams.logger.debug(Object.assign({}, params), 'Scanning for latest DMP versions in DynamoDB');
|
|
105
107
|
const response = await scanTable(dynamoConnectionParams, params);
|
|
106
108
|
if (Array.isArray(response) && response.length > 0) {
|
|
107
|
-
const versions =
|
|
109
|
+
const versions = new Map();
|
|
108
110
|
for (const item of response) {
|
|
109
111
|
const unmarshalled = (0, util_dynamodb_1.unmarshall)(item);
|
|
110
112
|
if (unmarshalled.PK && unmarshalled.SK && unmarshalled.modified) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
modified: unmarshalled.modified
|
|
114
|
-
});
|
|
113
|
+
const dmpId = unmarshalled.PK.replace(`${DMP_PK_PREFIX}#`, 'https://');
|
|
114
|
+
versions.set(dmpId, unmarshalled.modified);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
return versions;
|
|
118
118
|
}
|
|
119
|
-
return
|
|
119
|
+
return new Map();
|
|
120
120
|
}
|
|
121
121
|
catch (err) {
|
|
122
122
|
const errMsg = (0, general_1.toErrorMessage)(err);
|
package/package.json
CHANGED