@adobe/spacecat-shared-data-access 1.2.2 → 1.2.3
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/index.d.ts +3 -1
- package/src/service/audits/accessPatterns.js +13 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-data-access-v1.2.3](https://github.com/adobe-rnd/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.2.2...@adobe/spacecat-shared-data-access-v1.2.3) (2023-12-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* allow sorting for get audits for site ([#41](https://github.com/adobe-rnd/spacecat-shared/issues/41)) ([3664c97](https://github.com/adobe-rnd/spacecat-shared/commit/3664c97bd63d4f10e260582455e3763da60399dd))
|
|
7
|
+
|
|
1
8
|
# [@adobe/spacecat-shared-data-access-v1.2.2](https://github.com/adobe-rnd/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v1.2.1...@adobe/spacecat-shared-data-access-v1.2.2) (2023-12-08)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -34,13 +34,15 @@ export interface Site {
|
|
|
34
34
|
isLive: () => boolean;
|
|
35
35
|
setAudits: (audits: Audit[]) => Site;
|
|
36
36
|
toggleLive: () => Site;
|
|
37
|
+
updateGitHubURL: (gitHubURL: string) => Site;
|
|
37
38
|
updateImsOrgId: (imsOrgId: string) => Site;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
export interface DataAccess {
|
|
41
42
|
getAuditsForSite: (
|
|
42
43
|
siteId: string,
|
|
43
|
-
auditType?: string
|
|
44
|
+
auditType?: string,
|
|
45
|
+
ascending?: boolean,
|
|
44
46
|
) => Promise<Audit[]>;
|
|
45
47
|
getLatestAuditForSite: (
|
|
46
48
|
siteId: string,
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { isObject } from '@adobe/spacecat-shared-utils';
|
|
13
|
+
import { hasText, isObject } from '@adobe/spacecat-shared-utils';
|
|
14
14
|
|
|
15
15
|
import { AuditDto } from '../../dto/audit.js';
|
|
16
16
|
import { createAudit } from '../../models/audit.js';
|
|
@@ -24,19 +24,29 @@ import { createAudit } from '../../models/audit.js';
|
|
|
24
24
|
* @param {Logger} log - The logger.
|
|
25
25
|
* @param {string} siteId - The ID of the site for which audits are being retrieved.
|
|
26
26
|
* @param {string} [auditType] - Optional. The type of audits to retrieve.
|
|
27
|
+
* @param {boolean} [ascending] - Optional. Determines if the audits should be sorted
|
|
28
|
+
* ascending. Default is true.
|
|
27
29
|
* @returns {Promise<Readonly<Audit>[]>} A promise that resolves to an array of audits
|
|
28
30
|
* for the specified site.
|
|
29
31
|
*/
|
|
30
|
-
export const getAuditsForSite = async (
|
|
32
|
+
export const getAuditsForSite = async (
|
|
33
|
+
dynamoClient,
|
|
34
|
+
config,
|
|
35
|
+
log,
|
|
36
|
+
siteId,
|
|
37
|
+
auditType,
|
|
38
|
+
ascending = true,
|
|
39
|
+
) => {
|
|
31
40
|
const queryParams = {
|
|
32
41
|
TableName: config.tableNameAudits,
|
|
33
42
|
KeyConditionExpression: 'siteId = :siteId',
|
|
34
43
|
ExpressionAttributeValues: {
|
|
35
44
|
':siteId': siteId,
|
|
36
45
|
},
|
|
46
|
+
ScanIndexForward: ascending, // Sorts ascending if true, descending if false
|
|
37
47
|
};
|
|
38
48
|
|
|
39
|
-
if (auditType
|
|
49
|
+
if (hasText(auditType)) {
|
|
40
50
|
queryParams.KeyConditionExpression += ' AND begins_with(SK, :auditType)';
|
|
41
51
|
queryParams.ExpressionAttributeValues[':auditType'] = `${auditType}#`;
|
|
42
52
|
}
|