@webiny/app-audit-logs 6.4.5 → 6.6.0-alpha.0
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/config/list/AuditLogsListConfig.d.ts +5 -5
- package/config/list/Browser/index.d.ts +2 -3
- package/features/listAuditLogs/ListAuditLogsGateway.d.ts +11 -0
- package/features/listAuditLogs/ListAuditLogsGateway.js +71 -0
- package/features/listAuditLogs/ListAuditLogsGateway.js.map +1 -0
- package/features/listAuditLogs/ListAuditLogsRepository.d.ts +11 -0
- package/features/listAuditLogs/ListAuditLogsRepository.js +35 -0
- package/features/listAuditLogs/ListAuditLogsRepository.js.map +1 -0
- package/features/listAuditLogs/ListAuditLogsUseCase.d.ts +10 -0
- package/features/listAuditLogs/ListAuditLogsUseCase.js +19 -0
- package/features/listAuditLogs/ListAuditLogsUseCase.js.map +1 -0
- package/features/listAuditLogs/abstractions/ListAuditLogsGateway.d.ts +20 -0
- package/features/listAuditLogs/abstractions/ListAuditLogsGateway.js +5 -0
- package/features/listAuditLogs/abstractions/ListAuditLogsGateway.js.map +1 -0
- package/features/listAuditLogs/abstractions/ListAuditLogsRepository.d.ts +20 -0
- package/features/listAuditLogs/abstractions/ListAuditLogsRepository.js +5 -0
- package/features/listAuditLogs/abstractions/ListAuditLogsRepository.js.map +1 -0
- package/features/listAuditLogs/abstractions/ListAuditLogsUseCase.d.ts +20 -0
- package/features/listAuditLogs/abstractions/ListAuditLogsUseCase.js +5 -0
- package/features/listAuditLogs/abstractions/ListAuditLogsUseCase.js.map +1 -0
- package/features/listAuditLogs/abstractions/index.d.ts +6 -0
- package/features/listAuditLogs/abstractions/index.js +3 -0
- package/features/listAuditLogs/feature.d.ts +3 -0
- package/features/listAuditLogs/feature.js +21 -0
- package/features/listAuditLogs/feature.js.map +1 -0
- package/features/listAuditLogs/index.d.ts +1 -0
- package/features/listAuditLogs/index.js +1 -0
- package/graphql.d.ts +1 -1
- package/graphql.js +1 -2
- package/graphql.js.map +1 -1
- package/hooks/graphql.d.ts +0 -18
- package/hooks/graphql.js +0 -44
- package/hooks/useAuditLogsList.d.ts +1 -1
- package/hooks/useAuditLogsList.js +24 -31
- package/hooks/useAuditLogsList.js.map +1 -1
- package/index.js +3 -0
- package/index.js.map +1 -1
- package/package.json +13 -14
- package/views/Logs/Filters/FilterByCreatedBy.js +16 -9
- package/views/Logs/Filters/FilterByCreatedBy.js.map +1 -1
- package/views/Logs/Filters/FilterByInitiator.js +16 -9
- package/views/Logs/Filters/FilterByInitiator.js.map +1 -1
- package/hooks/graphql.js.map +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
declare const ScopedAuditLogsListConfig: {
|
|
3
3
|
({ children }: {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
}): React.JSX.Element;
|
|
6
6
|
displayName: string;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
|
+
export declare const AuditLogsListConfig: typeof ScopedAuditLogsListConfig & {
|
|
8
9
|
Browser: {
|
|
9
10
|
Filter: (({ name, element, after, before, remove }: import("./Browser/Filter.js").FilterProps) => React.JSX.Element) & {
|
|
10
11
|
original: ({ name, element, after, before, remove }: import("./Browser/Filter.js").FilterProps) => React.JSX.Element;
|
|
@@ -33,9 +34,7 @@ export declare const AuditLogsListConfig: {
|
|
|
33
34
|
name: string;
|
|
34
35
|
}) => React.JSX.Element;
|
|
35
36
|
};
|
|
36
|
-
FiltersToWhere: (
|
|
37
|
-
converter: import("./Browser/FiltersToWhere.js").FiltersToWhereConverter;
|
|
38
|
-
}) => React.JSX.Element;
|
|
37
|
+
FiltersToWhere: typeof import("./Browser/FiltersToWhere.js").FiltersToWhere;
|
|
39
38
|
};
|
|
40
39
|
};
|
|
41
40
|
export declare const AuditLogsListWithConfig: ({ children }: {
|
|
@@ -47,3 +46,4 @@ export declare function useAuditLogsListConfig(): {
|
|
|
47
46
|
filtersToWhere: import("./Browser/FiltersToWhere.js").FiltersToWhereConverter[];
|
|
48
47
|
};
|
|
49
48
|
};
|
|
49
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { FilterConfig } from "./Filter.js";
|
|
2
2
|
import type { FiltersToWhereConverter } from "./FiltersToWhere.js";
|
|
3
|
+
import { FiltersToWhere } from "./FiltersToWhere.js";
|
|
3
4
|
export interface BrowserConfig {
|
|
4
5
|
filters: FilterConfig[];
|
|
5
6
|
filtersToWhere: FiltersToWhereConverter[];
|
|
@@ -32,7 +33,5 @@ export declare const Browser: {
|
|
|
32
33
|
name: string;
|
|
33
34
|
}) => React.JSX.Element;
|
|
34
35
|
};
|
|
35
|
-
FiltersToWhere:
|
|
36
|
-
converter: FiltersToWhereConverter;
|
|
37
|
-
}) => import("react").JSX.Element;
|
|
36
|
+
FiltersToWhere: typeof FiltersToWhere;
|
|
38
37
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MainGraphQLClient } from "@webiny/app/features/mainGraphQLClient";
|
|
2
|
+
import { ListAuditLogsGateway as GatewayAbstraction } from "./abstractions/index.js";
|
|
3
|
+
declare class ListAuditLogsGatewayImpl implements GatewayAbstraction.Interface {
|
|
4
|
+
private readonly client;
|
|
5
|
+
constructor(client: MainGraphQLClient.Interface);
|
|
6
|
+
execute(params: GatewayAbstraction.Params): Promise<GatewayAbstraction.Result>;
|
|
7
|
+
}
|
|
8
|
+
export declare const ListAuditLogsGateway: typeof ListAuditLogsGatewayImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions/ListAuditLogsGateway.js").IListAuditLogsGateway>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { MainGraphQLClient } from "@webiny/app/features/mainGraphQLClient";
|
|
2
|
+
import { ListAuditLogsGateway } from "./abstractions/index.js";
|
|
3
|
+
const LIST_AUDIT_LOGS = `
|
|
4
|
+
query ListAuditLogs(
|
|
5
|
+
$where: ListAuditLogsWhere!
|
|
6
|
+
$sort: AuditLogsSort
|
|
7
|
+
$after: String
|
|
8
|
+
$limit: Number
|
|
9
|
+
) {
|
|
10
|
+
auditLogs {
|
|
11
|
+
listAuditLogs(where: $where, after: $after, sort: $sort, limit: $limit) {
|
|
12
|
+
data {
|
|
13
|
+
id
|
|
14
|
+
createdBy {
|
|
15
|
+
id
|
|
16
|
+
displayName
|
|
17
|
+
type
|
|
18
|
+
}
|
|
19
|
+
createdOn
|
|
20
|
+
app
|
|
21
|
+
action
|
|
22
|
+
message
|
|
23
|
+
entity
|
|
24
|
+
entityId
|
|
25
|
+
tags
|
|
26
|
+
expiresAt
|
|
27
|
+
content
|
|
28
|
+
}
|
|
29
|
+
meta {
|
|
30
|
+
hasMoreItems
|
|
31
|
+
cursor
|
|
32
|
+
}
|
|
33
|
+
error {
|
|
34
|
+
message
|
|
35
|
+
code
|
|
36
|
+
data
|
|
37
|
+
stack
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
class ListAuditLogsGatewayImpl {
|
|
44
|
+
constructor(client){
|
|
45
|
+
this.client = client;
|
|
46
|
+
}
|
|
47
|
+
async execute(params) {
|
|
48
|
+
const response = await this.client.execute({
|
|
49
|
+
query: LIST_AUDIT_LOGS,
|
|
50
|
+
variables: params
|
|
51
|
+
});
|
|
52
|
+
const envelope = response.auditLogs.listAuditLogs;
|
|
53
|
+
if (envelope.error) throw new Error(envelope.error.message || "Could not fetch audit logs.");
|
|
54
|
+
return {
|
|
55
|
+
data: envelope.data || [],
|
|
56
|
+
meta: envelope.meta || {
|
|
57
|
+
hasMoreItems: false,
|
|
58
|
+
cursor: null
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const ListAuditLogsGateway_ListAuditLogsGateway = ListAuditLogsGateway.createImplementation({
|
|
64
|
+
implementation: ListAuditLogsGatewayImpl,
|
|
65
|
+
dependencies: [
|
|
66
|
+
MainGraphQLClient
|
|
67
|
+
]
|
|
68
|
+
});
|
|
69
|
+
export { ListAuditLogsGateway_ListAuditLogsGateway as ListAuditLogsGateway };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=ListAuditLogsGateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/listAuditLogs/ListAuditLogsGateway.js","sources":["../../../src/features/listAuditLogs/ListAuditLogsGateway.ts"],"sourcesContent":["import { MainGraphQLClient } from \"@webiny/app/features/mainGraphQLClient\";\nimport type { IAuditLogRaw, IAuditLogsMeta, IAuditLogsError } from \"~/types.js\";\nimport { ListAuditLogsGateway as GatewayAbstraction } from \"./abstractions/index.js\";\n\nconst LIST_AUDIT_LOGS = /* GraphQL */ `\n query ListAuditLogs(\n $where: ListAuditLogsWhere!\n $sort: AuditLogsSort\n $after: String\n $limit: Number\n ) {\n auditLogs {\n listAuditLogs(where: $where, after: $after, sort: $sort, limit: $limit) {\n data {\n id\n createdBy {\n id\n displayName\n type\n }\n createdOn\n app\n action\n message\n entity\n entityId\n tags\n expiresAt\n content\n }\n meta {\n hasMoreItems\n cursor\n }\n error {\n message\n code\n data\n stack\n }\n }\n }\n }\n`;\n\ninterface ListAuditLogsResponse {\n auditLogs: {\n listAuditLogs: {\n data: IAuditLogRaw[] | null;\n meta: IAuditLogsMeta | null;\n error: IAuditLogsError | null;\n };\n };\n}\n\nclass ListAuditLogsGatewayImpl implements GatewayAbstraction.Interface {\n constructor(private readonly client: MainGraphQLClient.Interface) {}\n\n async execute(params: GatewayAbstraction.Params): Promise<GatewayAbstraction.Result> {\n const response = await this.client.execute<ListAuditLogsResponse>({\n query: LIST_AUDIT_LOGS,\n variables: params\n });\n\n const envelope = response.auditLogs.listAuditLogs;\n\n if (envelope.error) {\n throw new Error(envelope.error.message || \"Could not fetch audit logs.\");\n }\n\n return {\n data: envelope.data || [],\n meta: envelope.meta || { hasMoreItems: false, cursor: null }\n };\n }\n}\n\nexport const ListAuditLogsGateway = GatewayAbstraction.createImplementation({\n implementation: ListAuditLogsGatewayImpl,\n dependencies: [MainGraphQLClient]\n});\n"],"names":["LIST_AUDIT_LOGS","ListAuditLogsGatewayImpl","client","params","response","envelope","Error","ListAuditLogsGateway","GatewayAbstraction","MainGraphQLClient"],"mappings":";;AAIA,MAAMA,kBAAgC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCvC,CAAC;AAYD,MAAMC;IACF,YAA6BC,MAAmC,CAAE;aAArCA,MAAM,GAANA;IAAsC;IAEnE,MAAM,QAAQC,MAAiC,EAAsC;QACjF,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAwB;YAC9D,OAAOJ;YACP,WAAWG;QACf;QAEA,MAAME,WAAWD,SAAS,SAAS,CAAC,aAAa;QAEjD,IAAIC,SAAS,KAAK,EACd,MAAM,IAAIC,MAAMD,SAAS,KAAK,CAAC,OAAO,IAAI;QAG9C,OAAO;YACH,MAAMA,SAAS,IAAI,IAAI,EAAE;YACzB,MAAMA,SAAS,IAAI,IAAI;gBAAE,cAAc;gBAAO,QAAQ;YAAK;QAC/D;IACJ;AACJ;AAEO,MAAME,4CAAuBC,qBAAAA,oBAAuC,CAAC;IACxE,gBAAgBP;IAChB,cAAc;QAACQ;KAAkB;AACrC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ListAuditLogsGateway } from "./abstractions/index.js";
|
|
2
|
+
import { ListAuditLogsRepository as RepositoryAbstraction } from "./abstractions/index.js";
|
|
3
|
+
declare class ListAuditLogsRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
4
|
+
private readonly gateway;
|
|
5
|
+
constructor(gateway: ListAuditLogsGateway.Interface);
|
|
6
|
+
execute(params: RepositoryAbstraction.Params): Promise<RepositoryAbstraction.Result>;
|
|
7
|
+
}
|
|
8
|
+
export declare const ListAuditLogsRepository: typeof ListAuditLogsRepositoryImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions/ListAuditLogsRepository.js").IListAuditLogsRepository>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ListAuditLogsGateway, ListAuditLogsRepository } from "./abstractions/index.js";
|
|
2
|
+
import { listAuditLogsSchema } from "../../hooks/schema.js";
|
|
3
|
+
import { transformRawAuditLog } from "../../utils/transformRawAuditLog.js";
|
|
4
|
+
class ListAuditLogsRepositoryImpl {
|
|
5
|
+
constructor(gateway){
|
|
6
|
+
this.gateway = gateway;
|
|
7
|
+
}
|
|
8
|
+
async execute(params) {
|
|
9
|
+
const response = await this.gateway.execute(params);
|
|
10
|
+
const parsed = listAuditLogsSchema.safeParse(response.data);
|
|
11
|
+
if (!parsed.success) {
|
|
12
|
+
console.error(parsed.error);
|
|
13
|
+
return {
|
|
14
|
+
records: [],
|
|
15
|
+
meta: response.meta
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const records = parsed.data.map((auditLog)=>transformRawAuditLog({
|
|
19
|
+
auditLog
|
|
20
|
+
}));
|
|
21
|
+
return {
|
|
22
|
+
records,
|
|
23
|
+
meta: response.meta
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const ListAuditLogsRepository_ListAuditLogsRepository = ListAuditLogsRepository.createImplementation({
|
|
28
|
+
implementation: ListAuditLogsRepositoryImpl,
|
|
29
|
+
dependencies: [
|
|
30
|
+
ListAuditLogsGateway
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
export { ListAuditLogsRepository_ListAuditLogsRepository as ListAuditLogsRepository };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=ListAuditLogsRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/listAuditLogs/ListAuditLogsRepository.js","sources":["../../../src/features/listAuditLogs/ListAuditLogsRepository.ts"],"sourcesContent":["import { ListAuditLogsGateway } from \"./abstractions/index.js\";\nimport { ListAuditLogsRepository as RepositoryAbstraction } from \"./abstractions/index.js\";\nimport { listAuditLogsSchema } from \"~/hooks/schema.js\";\nimport { transformRawAuditLog } from \"~/utils/transformRawAuditLog.js\";\n\nclass ListAuditLogsRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(private readonly gateway: ListAuditLogsGateway.Interface) {}\n\n async execute(params: RepositoryAbstraction.Params): Promise<RepositoryAbstraction.Result> {\n const response = await this.gateway.execute(params);\n\n const parsed = listAuditLogsSchema.safeParse(response.data);\n if (!parsed.success) {\n console.error(parsed.error);\n return {\n records: [],\n meta: response.meta\n };\n }\n\n const records = parsed.data.map(auditLog => transformRawAuditLog({ auditLog }));\n\n return {\n records,\n meta: response.meta\n };\n }\n}\n\nexport const ListAuditLogsRepository = RepositoryAbstraction.createImplementation({\n implementation: ListAuditLogsRepositoryImpl,\n dependencies: [ListAuditLogsGateway]\n});\n"],"names":["ListAuditLogsRepositoryImpl","gateway","params","response","parsed","listAuditLogsSchema","console","records","auditLog","transformRawAuditLog","ListAuditLogsRepository","RepositoryAbstraction","ListAuditLogsGateway"],"mappings":";;;AAKA,MAAMA;IACF,YAA6BC,OAAuC,CAAE;aAAzCA,OAAO,GAAPA;IAA0C;IAEvE,MAAM,QAAQC,MAAoC,EAAyC;QACvF,MAAMC,WAAW,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAACD;QAE5C,MAAME,SAASC,oBAAoB,SAAS,CAACF,SAAS,IAAI;QAC1D,IAAI,CAACC,OAAO,OAAO,EAAE;YACjBE,QAAQ,KAAK,CAACF,OAAO,KAAK;YAC1B,OAAO;gBACH,SAAS,EAAE;gBACX,MAAMD,SAAS,IAAI;YACvB;QACJ;QAEA,MAAMI,UAAUH,OAAO,IAAI,CAAC,GAAG,CAACI,CAAAA,WAAYC,qBAAqB;gBAAED;YAAS;QAE5E,OAAO;YACHD;YACA,MAAMJ,SAAS,IAAI;QACvB;IACJ;AACJ;AAEO,MAAMO,kDAA0BC,wBAAAA,oBAA0C,CAAC;IAC9E,gBAAgBX;IAChB,cAAc;QAACY;KAAqB;AACxC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ListAuditLogsRepository, ListAuditLogsUseCase as UseCaseAbstraction } from "./abstractions/index.js";
|
|
2
|
+
declare class ListAuditLogsUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
3
|
+
private readonly repository;
|
|
4
|
+
constructor(repository: ListAuditLogsRepository.Interface);
|
|
5
|
+
execute(params: UseCaseAbstraction.Params): Promise<UseCaseAbstraction.Result>;
|
|
6
|
+
}
|
|
7
|
+
export declare const ListAuditLogsUseCase: typeof ListAuditLogsUseCaseImpl & {
|
|
8
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions/ListAuditLogsUseCase.js").IListAuditLogsUseCase>;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ListAuditLogsRepository, ListAuditLogsUseCase } from "./abstractions/index.js";
|
|
2
|
+
class ListAuditLogsUseCaseImpl {
|
|
3
|
+
constructor(repository){
|
|
4
|
+
this.repository = repository;
|
|
5
|
+
}
|
|
6
|
+
async execute(params) {
|
|
7
|
+
const result = await this.repository.execute(params);
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const ListAuditLogsUseCase_ListAuditLogsUseCase = ListAuditLogsUseCase.createImplementation({
|
|
12
|
+
implementation: ListAuditLogsUseCaseImpl,
|
|
13
|
+
dependencies: [
|
|
14
|
+
ListAuditLogsRepository
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
export { ListAuditLogsUseCase_ListAuditLogsUseCase as ListAuditLogsUseCase };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=ListAuditLogsUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/listAuditLogs/ListAuditLogsUseCase.js","sources":["../../../src/features/listAuditLogs/ListAuditLogsUseCase.ts"],"sourcesContent":["import {\n ListAuditLogsRepository,\n ListAuditLogsUseCase as UseCaseAbstraction\n} from \"./abstractions/index.js\";\n\nclass ListAuditLogsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(private readonly repository: ListAuditLogsRepository.Interface) {}\n\n async execute(params: UseCaseAbstraction.Params): Promise<UseCaseAbstraction.Result> {\n const result = await this.repository.execute(params);\n return result;\n }\n}\n\nexport const ListAuditLogsUseCase = UseCaseAbstraction.createImplementation({\n implementation: ListAuditLogsUseCaseImpl,\n dependencies: [ListAuditLogsRepository]\n});\n"],"names":["ListAuditLogsUseCaseImpl","repository","params","result","ListAuditLogsUseCase","UseCaseAbstraction","ListAuditLogsRepository"],"mappings":";AAKA,MAAMA;IACF,YAA6BC,UAA6C,CAAE;aAA/CA,UAAU,GAAVA;IAAgD;IAE7E,MAAM,QAAQC,MAAiC,EAAsC;QACjF,MAAMC,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACD;QAC7C,OAAOC;IACX;AACJ;AAEO,MAAMC,4CAAuBC,qBAAAA,oBAAuC,CAAC;IACxE,gBAAgBL;IAChB,cAAc;QAACM;KAAwB;AAC3C"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IAuditLogRaw, IAuditLogsMeta } from "../../../types.js";
|
|
2
|
+
export interface IListAuditLogsGatewayParams {
|
|
3
|
+
where?: Record<string, unknown>;
|
|
4
|
+
after?: string;
|
|
5
|
+
sort?: "ASC" | "DESC";
|
|
6
|
+
limit?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface IListAuditLogsGatewayResult {
|
|
9
|
+
data: IAuditLogRaw[];
|
|
10
|
+
meta: IAuditLogsMeta;
|
|
11
|
+
}
|
|
12
|
+
export interface IListAuditLogsGateway {
|
|
13
|
+
execute(params: IListAuditLogsGatewayParams): Promise<IListAuditLogsGatewayResult>;
|
|
14
|
+
}
|
|
15
|
+
export declare const ListAuditLogsGateway: import("@webiny/di").Abstraction<IListAuditLogsGateway>;
|
|
16
|
+
export declare namespace ListAuditLogsGateway {
|
|
17
|
+
type Interface = IListAuditLogsGateway;
|
|
18
|
+
type Params = IListAuditLogsGatewayParams;
|
|
19
|
+
type Result = IListAuditLogsGatewayResult;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/listAuditLogs/abstractions/ListAuditLogsGateway.js","sources":["../../../../src/features/listAuditLogs/abstractions/ListAuditLogsGateway.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { IAuditLogRaw, IAuditLogsMeta } from \"~/types.js\";\n\nexport interface IListAuditLogsGatewayParams {\n where?: Record<string, unknown>;\n after?: string;\n sort?: \"ASC\" | \"DESC\";\n limit?: number;\n}\n\nexport interface IListAuditLogsGatewayResult {\n data: IAuditLogRaw[];\n meta: IAuditLogsMeta;\n}\n\nexport interface IListAuditLogsGateway {\n execute(params: IListAuditLogsGatewayParams): Promise<IListAuditLogsGatewayResult>;\n}\n\nexport const ListAuditLogsGateway =\n createAbstraction<IListAuditLogsGateway>(\"ListAuditLogsGateway\");\n\nexport namespace ListAuditLogsGateway {\n export type Interface = IListAuditLogsGateway;\n export type Params = IListAuditLogsGatewayParams;\n export type Result = IListAuditLogsGatewayResult;\n}\n"],"names":["ListAuditLogsGateway","createAbstraction"],"mappings":";AAmBO,MAAMA,uBACTC,kBAAyC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IAuditLog, IAuditLogsMeta } from "../../../types.js";
|
|
2
|
+
export interface IListAuditLogsRepositoryParams {
|
|
3
|
+
where?: Record<string, unknown>;
|
|
4
|
+
after?: string;
|
|
5
|
+
sort?: "ASC" | "DESC";
|
|
6
|
+
limit?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface IListAuditLogsRepositoryResult {
|
|
9
|
+
records: IAuditLog[];
|
|
10
|
+
meta: IAuditLogsMeta;
|
|
11
|
+
}
|
|
12
|
+
export interface IListAuditLogsRepository {
|
|
13
|
+
execute(params: IListAuditLogsRepositoryParams): Promise<IListAuditLogsRepositoryResult>;
|
|
14
|
+
}
|
|
15
|
+
export declare const ListAuditLogsRepository: import("@webiny/di").Abstraction<IListAuditLogsRepository>;
|
|
16
|
+
export declare namespace ListAuditLogsRepository {
|
|
17
|
+
type Interface = IListAuditLogsRepository;
|
|
18
|
+
type Params = IListAuditLogsRepositoryParams;
|
|
19
|
+
type Result = IListAuditLogsRepositoryResult;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/listAuditLogs/abstractions/ListAuditLogsRepository.js","sources":["../../../../src/features/listAuditLogs/abstractions/ListAuditLogsRepository.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { IAuditLog, IAuditLogsMeta } from \"~/types.js\";\n\nexport interface IListAuditLogsRepositoryParams {\n where?: Record<string, unknown>;\n after?: string;\n sort?: \"ASC\" | \"DESC\";\n limit?: number;\n}\n\nexport interface IListAuditLogsRepositoryResult {\n records: IAuditLog[];\n meta: IAuditLogsMeta;\n}\n\nexport interface IListAuditLogsRepository {\n execute(params: IListAuditLogsRepositoryParams): Promise<IListAuditLogsRepositoryResult>;\n}\n\nexport const ListAuditLogsRepository =\n createAbstraction<IListAuditLogsRepository>(\"ListAuditLogsRepository\");\n\nexport namespace ListAuditLogsRepository {\n export type Interface = IListAuditLogsRepository;\n export type Params = IListAuditLogsRepositoryParams;\n export type Result = IListAuditLogsRepositoryResult;\n}\n"],"names":["ListAuditLogsRepository","createAbstraction"],"mappings":";AAmBO,MAAMA,0BACTC,kBAA4C"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IAuditLog, IAuditLogsMeta } from "../../../types.js";
|
|
2
|
+
export interface IListAuditLogsUseCaseParams {
|
|
3
|
+
where?: Record<string, unknown>;
|
|
4
|
+
after?: string;
|
|
5
|
+
sort?: "ASC" | "DESC";
|
|
6
|
+
limit?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface IListAuditLogsUseCaseResult {
|
|
9
|
+
records: IAuditLog[];
|
|
10
|
+
meta: IAuditLogsMeta;
|
|
11
|
+
}
|
|
12
|
+
export interface IListAuditLogsUseCase {
|
|
13
|
+
execute(params: IListAuditLogsUseCaseParams): Promise<IListAuditLogsUseCaseResult>;
|
|
14
|
+
}
|
|
15
|
+
export declare const ListAuditLogsUseCase: import("@webiny/di").Abstraction<IListAuditLogsUseCase>;
|
|
16
|
+
export declare namespace ListAuditLogsUseCase {
|
|
17
|
+
type Interface = IListAuditLogsUseCase;
|
|
18
|
+
type Params = IListAuditLogsUseCaseParams;
|
|
19
|
+
type Result = IListAuditLogsUseCaseResult;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/listAuditLogs/abstractions/ListAuditLogsUseCase.js","sources":["../../../../src/features/listAuditLogs/abstractions/ListAuditLogsUseCase.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { IAuditLog, IAuditLogsMeta } from \"~/types.js\";\n\nexport interface IListAuditLogsUseCaseParams {\n where?: Record<string, unknown>;\n after?: string;\n sort?: \"ASC\" | \"DESC\";\n limit?: number;\n}\n\nexport interface IListAuditLogsUseCaseResult {\n records: IAuditLog[];\n meta: IAuditLogsMeta;\n}\n\nexport interface IListAuditLogsUseCase {\n execute(params: IListAuditLogsUseCaseParams): Promise<IListAuditLogsUseCaseResult>;\n}\n\nexport const ListAuditLogsUseCase =\n createAbstraction<IListAuditLogsUseCase>(\"ListAuditLogsUseCase\");\n\nexport namespace ListAuditLogsUseCase {\n export type Interface = IListAuditLogsUseCase;\n export type Params = IListAuditLogsUseCaseParams;\n export type Result = IListAuditLogsUseCaseResult;\n}\n"],"names":["ListAuditLogsUseCase","createAbstraction"],"mappings":";AAmBO,MAAMA,uBACTC,kBAAyC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ListAuditLogsGateway } from "./ListAuditLogsGateway.js";
|
|
2
|
+
export type { IListAuditLogsGateway } from "./ListAuditLogsGateway.js";
|
|
3
|
+
export { ListAuditLogsRepository } from "./ListAuditLogsRepository.js";
|
|
4
|
+
export type { IListAuditLogsRepository } from "./ListAuditLogsRepository.js";
|
|
5
|
+
export { ListAuditLogsUseCase } from "./ListAuditLogsUseCase.js";
|
|
6
|
+
export type { IListAuditLogsUseCase } from "./ListAuditLogsUseCase.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/admin";
|
|
2
|
+
import { ListAuditLogsUseCase } from "./abstractions/index.js";
|
|
3
|
+
import { ListAuditLogsUseCase as external_ListAuditLogsUseCase_js_ListAuditLogsUseCase } from "./ListAuditLogsUseCase.js";
|
|
4
|
+
import { ListAuditLogsRepository } from "./ListAuditLogsRepository.js";
|
|
5
|
+
import { ListAuditLogsGateway } from "./ListAuditLogsGateway.js";
|
|
6
|
+
const ListAuditLogsFeature = createFeature({
|
|
7
|
+
name: "AuditLogs/ListAuditLogs",
|
|
8
|
+
register (container) {
|
|
9
|
+
container.register(external_ListAuditLogsUseCase_js_ListAuditLogsUseCase);
|
|
10
|
+
container.register(ListAuditLogsRepository).inSingletonScope();
|
|
11
|
+
container.register(ListAuditLogsGateway).inSingletonScope();
|
|
12
|
+
},
|
|
13
|
+
resolve (container) {
|
|
14
|
+
return {
|
|
15
|
+
useCase: container.resolve(ListAuditLogsUseCase)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
export { ListAuditLogsFeature };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/listAuditLogs/feature.js","sources":["../../../src/features/listAuditLogs/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { ListAuditLogsUseCase as UseCaseAbstraction } from \"./abstractions/index.js\";\nimport { ListAuditLogsUseCase } from \"./ListAuditLogsUseCase.js\";\nimport { ListAuditLogsRepository } from \"./ListAuditLogsRepository.js\";\nimport { ListAuditLogsGateway } from \"./ListAuditLogsGateway.js\";\n\nexport const ListAuditLogsFeature = createFeature({\n name: \"AuditLogs/ListAuditLogs\",\n register(container) {\n container.register(ListAuditLogsUseCase);\n container.register(ListAuditLogsRepository).inSingletonScope();\n container.register(ListAuditLogsGateway).inSingletonScope();\n },\n resolve(container) {\n return {\n useCase: container.resolve(UseCaseAbstraction)\n };\n }\n});\n"],"names":["ListAuditLogsFeature","createFeature","container","ListAuditLogsUseCase","ListAuditLogsRepository","ListAuditLogsGateway","UseCaseAbstraction"],"mappings":";;;;;AAMO,MAAMA,uBAAuBC,cAAc;IAC9C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,yBAAyB,gBAAgB;QAC5DF,UAAU,QAAQ,CAACG,sBAAsB,gBAAgB;IAC7D;IACA,SAAQH,SAAS;QACb,OAAO;YACH,SAASA,UAAU,OAAO,CAACI;QAC/B;IACJ;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ListAuditLogsFeature } from "./feature.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ListAuditLogsFeature } from "./feature.js";
|
package/graphql.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LIST_USERS:
|
|
1
|
+
export declare const LIST_USERS = "\n query ListUsers {\n adminUsers {\n users: listUsers {\n data {\n id\n firstName\n lastName\n roles {\n name\n }\n }\n error {\n \n code\n message\n data\n\n }\n }\n }\n }\n";
|
package/graphql.js
CHANGED
package/graphql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.js","sources":["../src/graphql.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"graphql.js","sources":["../src/graphql.ts"],"sourcesContent":["const ERROR_FIELDS = /* GraphQL */ `\n code\n message\n data\n`;\n\nexport const LIST_USERS = /* GraphQL */ `\n query ListUsers {\n adminUsers {\n users: listUsers {\n data {\n id\n firstName\n lastName\n roles {\n name\n }\n }\n error {\n ${ERROR_FIELDS}\n }\n }\n }\n }\n`;\n"],"names":["ERROR_FIELDS","LIST_USERS"],"mappings":"AAAA,MAAMA,eAA6B,CAAC;;;;AAIpC,CAAC;AAEM,MAAMC,aAA2B,CAAC;;;;;;;;;;;;;oBAarB,EAAED,aAAa;;;;;AAKnC,CAAC"}
|
package/hooks/graphql.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { IAuditLogRaw, IAuditLogsError, IAuditLogsMeta } from "../types.js";
|
|
2
1
|
export interface IListAuditLogsVariablesWhere {
|
|
3
2
|
app?: string;
|
|
4
3
|
action?: string;
|
|
@@ -8,20 +7,3 @@ export interface IListAuditLogsVariablesWhere {
|
|
|
8
7
|
createdOn_gte?: Date;
|
|
9
8
|
createdOn_lte?: Date;
|
|
10
9
|
}
|
|
11
|
-
export interface IListAuditLogsVariables {
|
|
12
|
-
where: Partial<IListAuditLogsVariablesWhere>;
|
|
13
|
-
after: string | undefined;
|
|
14
|
-
sort: "ASC" | "DESC" | undefined;
|
|
15
|
-
limit: number | undefined;
|
|
16
|
-
}
|
|
17
|
-
export type IListAuditLogsVariablesPartial = Partial<IListAuditLogsVariables>;
|
|
18
|
-
export interface IListAuditLogsResponse {
|
|
19
|
-
auditLogs: {
|
|
20
|
-
listAuditLogs: {
|
|
21
|
-
data: IAuditLogRaw[] | null;
|
|
22
|
-
meta: IAuditLogsMeta | null;
|
|
23
|
-
error: IAuditLogsError | null;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
export declare const LIST_AUDIT_LOGS: import("graphql").DocumentNode;
|
package/hooks/graphql.js
CHANGED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import graphql_tag from "graphql-tag";
|
|
2
|
-
const LIST_AUDIT_LOGS = graphql_tag`
|
|
3
|
-
query ListAuditLogs(
|
|
4
|
-
$where: ListAuditLogsWhere!
|
|
5
|
-
$sort: AuditLogsSort
|
|
6
|
-
$after: String
|
|
7
|
-
$limit: Number
|
|
8
|
-
) {
|
|
9
|
-
auditLogs {
|
|
10
|
-
listAuditLogs(where: $where, after: $after, sort: $sort, limit: $limit) {
|
|
11
|
-
data {
|
|
12
|
-
id
|
|
13
|
-
createdBy {
|
|
14
|
-
id
|
|
15
|
-
displayName
|
|
16
|
-
type
|
|
17
|
-
}
|
|
18
|
-
createdOn
|
|
19
|
-
app
|
|
20
|
-
action
|
|
21
|
-
message
|
|
22
|
-
entity
|
|
23
|
-
entityId
|
|
24
|
-
tags
|
|
25
|
-
expiresAt
|
|
26
|
-
content
|
|
27
|
-
}
|
|
28
|
-
meta {
|
|
29
|
-
hasMoreItems
|
|
30
|
-
cursor
|
|
31
|
-
}
|
|
32
|
-
error {
|
|
33
|
-
message
|
|
34
|
-
code
|
|
35
|
-
data
|
|
36
|
-
stack
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
`;
|
|
42
|
-
export { LIST_AUDIT_LOGS };
|
|
43
|
-
|
|
44
|
-
//# sourceMappingURL=graphql.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IListAuditLogsVariablesWhere } from "../hooks/graphql.js";
|
|
2
2
|
import type { IAuditLog, IAuditLogsMeta } from "../types.js";
|
|
3
3
|
import type { OnDataTableSortingChange, DataTableSorting } from "@webiny/admin-ui";
|
|
4
4
|
export interface UseAuditLogs {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { transformRawAuditLog } from "../utils/transformRawAuditLog.js";
|
|
5
|
-
import { listAuditLogsSchema } from "./schema.js";
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { useFeature } from "@webiny/app";
|
|
3
|
+
import { ListAuditLogsFeature } from "../features/listAuditLogs/index.js";
|
|
6
4
|
const useAuditLogsList = ()=>{
|
|
5
|
+
const { useCase } = useFeature(ListAuditLogsFeature);
|
|
7
6
|
const [variables, setVariables] = useState({
|
|
8
7
|
where: {},
|
|
9
8
|
after: void 0,
|
|
@@ -11,6 +10,11 @@ const useAuditLogsList = ()=>{
|
|
|
11
10
|
limit: 25
|
|
12
11
|
});
|
|
13
12
|
const [accumulatedRecords, setAccumulatedRecords] = useState([]);
|
|
13
|
+
const [loading, setLoading] = useState(true);
|
|
14
|
+
const [meta, setMeta] = useState({
|
|
15
|
+
hasMoreItems: false,
|
|
16
|
+
cursor: null
|
|
17
|
+
});
|
|
14
18
|
const setWhere = useCallback((where)=>{
|
|
15
19
|
setVariables((prev)=>({
|
|
16
20
|
...prev,
|
|
@@ -48,32 +52,21 @@ const useAuditLogsList = ()=>{
|
|
|
48
52
|
}, [
|
|
49
53
|
acoSorting
|
|
50
54
|
]);
|
|
51
|
-
const
|
|
52
|
-
variables,
|
|
53
|
-
fetchPolicy: "network-only"
|
|
54
|
-
});
|
|
55
|
+
const requestIdRef = useRef(0);
|
|
55
56
|
useEffect(()=>{
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
logs.data?.auditLogs
|
|
68
|
-
]);
|
|
69
|
-
const meta = useMemo(()=>{
|
|
70
|
-
if (!logs.data?.auditLogs.listAuditLogs.meta) return {
|
|
71
|
-
hasMoreItems: false,
|
|
72
|
-
cursor: null
|
|
73
|
-
};
|
|
74
|
-
return logs.data.auditLogs.listAuditLogs.meta;
|
|
57
|
+
setLoading(true);
|
|
58
|
+
const requestId = ++requestIdRef.current;
|
|
59
|
+
useCase.execute(variables).then((result)=>{
|
|
60
|
+
if (requestId !== requestIdRef.current) return;
|
|
61
|
+
variables.after ? setAccumulatedRecords((prev)=>[
|
|
62
|
+
...prev,
|
|
63
|
+
...result.records
|
|
64
|
+
]) : setAccumulatedRecords(result.records);
|
|
65
|
+
setMeta(result.meta);
|
|
66
|
+
setLoading(false);
|
|
67
|
+
});
|
|
75
68
|
}, [
|
|
76
|
-
|
|
69
|
+
variables
|
|
77
70
|
]);
|
|
78
71
|
const sorting = useMemo(()=>[
|
|
79
72
|
{
|
|
@@ -84,7 +77,7 @@ const useAuditLogsList = ()=>{
|
|
|
84
77
|
variables.sort
|
|
85
78
|
]);
|
|
86
79
|
return {
|
|
87
|
-
isListLoading:
|
|
80
|
+
isListLoading: loading,
|
|
88
81
|
records: accumulatedRecords,
|
|
89
82
|
meta,
|
|
90
83
|
listMoreRecords: ()=>{
|
|
@@ -94,7 +87,7 @@ const useAuditLogsList = ()=>{
|
|
|
94
87
|
sorting,
|
|
95
88
|
setSorting: setAcoSorting,
|
|
96
89
|
setLimit,
|
|
97
|
-
isListLoadingMore:
|
|
90
|
+
isListLoadingMore: loading && !!variables.after,
|
|
98
91
|
showingFilters,
|
|
99
92
|
showFilters: ()=>{
|
|
100
93
|
setShowingFilters(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useAuditLogsList.js","sources":["../../src/hooks/useAuditLogsList.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"hooks/useAuditLogsList.js","sources":["../../src/hooks/useAuditLogsList.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useFeature } from \"@webiny/app\";\nimport { ListAuditLogsFeature } from \"~/features/listAuditLogs/index.js\";\nimport type { IListAuditLogsVariablesWhere } from \"~/hooks/graphql.js\";\nimport type { IAuditLog, IAuditLogsMeta } from \"~/types.js\";\nimport type { OnDataTableSortingChange, DataTableSorting } from \"@webiny/admin-ui\";\n\nexport interface UseAuditLogs {\n isListLoading: boolean;\n isListLoadingMore: boolean;\n records: IAuditLog[];\n meta: IAuditLogsMeta;\n listMoreRecords: () => void;\n setWhere: (where: Partial<IListAuditLogsVariablesWhere>) => void;\n setLimit: (limit: number) => void;\n after?: string;\n sorting: DataTableSorting;\n setSorting: OnDataTableSortingChange;\n showingFilters: boolean;\n showFilters: () => void;\n hideFilters: () => void;\n}\n\ninterface ListVariables {\n where: Record<string, unknown>;\n after: string | undefined;\n sort: \"ASC\" | \"DESC\";\n limit: number;\n}\n\nexport const useAuditLogsList = (): UseAuditLogs => {\n const { useCase } = useFeature(ListAuditLogsFeature);\n\n const [variables, setVariables] = useState<ListVariables>({\n where: {},\n after: undefined,\n sort: \"DESC\",\n limit: 25\n });\n\n const [accumulatedRecords, setAccumulatedRecords] = useState<IAuditLog[]>([]);\n const [loading, setLoading] = useState(true);\n const [meta, setMeta] = useState<IAuditLogsMeta>({\n hasMoreItems: false,\n cursor: null\n });\n\n const setWhere = useCallback((where: Partial<IListAuditLogsVariablesWhere>) => {\n setVariables(prev => ({ ...prev, where, after: undefined }));\n setAccumulatedRecords([]);\n }, []);\n\n const setSort = useCallback((sort: \"ASC\" | \"DESC\") => {\n setVariables(prev => ({ ...prev, sort, after: undefined }));\n setAccumulatedRecords([]);\n }, []);\n\n const setAfter = useCallback((after?: string) => {\n setVariables(prev => ({ ...prev, after }));\n }, []);\n\n const setLimit = useCallback((limit: number) => {\n setVariables(prev => ({ ...prev, limit }));\n }, []);\n\n const [showingFilters, setShowingFilters] = useState(false);\n const [acoSorting, setAcoSorting] = useState<DataTableSorting>([]);\n\n useEffect(() => {\n const sort = acoSorting[0];\n if (!sort) {\n return;\n }\n setSort(sort.desc ? \"DESC\" : \"ASC\");\n }, [acoSorting]);\n\n const requestIdRef = useRef(0);\n\n useEffect(() => {\n setLoading(true);\n const requestId = ++requestIdRef.current;\n\n useCase.execute(variables).then(result => {\n if (requestId !== requestIdRef.current) {\n return;\n }\n\n if (variables.after) {\n setAccumulatedRecords(prev => [...prev, ...result.records]);\n } else {\n setAccumulatedRecords(result.records);\n }\n\n setMeta(result.meta);\n setLoading(false);\n });\n }, [variables]);\n\n const sorting = useMemo((): DataTableSorting => {\n return [\n {\n id: \"createdOn\",\n desc: variables.sort === \"DESC\"\n }\n ];\n }, [variables.sort]);\n\n return {\n isListLoading: loading,\n records: accumulatedRecords,\n meta,\n listMoreRecords: () => {\n setAfter(meta.cursor || undefined);\n },\n setWhere,\n sorting,\n setSorting: setAcoSorting,\n setLimit,\n isListLoadingMore: loading && !!variables.after,\n showingFilters,\n showFilters: () => {\n setShowingFilters(true);\n },\n hideFilters: () => {\n setShowingFilters(false);\n }\n };\n};\n"],"names":["useAuditLogsList","useCase","useFeature","ListAuditLogsFeature","variables","setVariables","useState","undefined","accumulatedRecords","setAccumulatedRecords","loading","setLoading","meta","setMeta","setWhere","useCallback","where","prev","setSort","sort","setAfter","after","setLimit","limit","showingFilters","setShowingFilters","acoSorting","setAcoSorting","useEffect","requestIdRef","useRef","requestId","result","sorting","useMemo"],"mappings":";;;AA8BO,MAAMA,mBAAmB;IAC5B,MAAM,EAAEC,OAAO,EAAE,GAAGC,WAAWC;IAE/B,MAAM,CAACC,WAAWC,aAAa,GAAGC,SAAwB;QACtD,OAAO,CAAC;QACR,OAAOC;QACP,MAAM;QACN,OAAO;IACX;IAEA,MAAM,CAACC,oBAAoBC,sBAAsB,GAAGH,SAAsB,EAAE;IAC5E,MAAM,CAACI,SAASC,WAAW,GAAGL,SAAS;IACvC,MAAM,CAACM,MAAMC,QAAQ,GAAGP,SAAyB;QAC7C,cAAc;QACd,QAAQ;IACZ;IAEA,MAAMQ,WAAWC,YAAY,CAACC;QAC1BX,aAAaY,CAAAA,OAAS;gBAAE,GAAGA,IAAI;gBAAED;gBAAO,OAAOT;YAAU;QACzDE,sBAAsB,EAAE;IAC5B,GAAG,EAAE;IAEL,MAAMS,UAAUH,YAAY,CAACI;QACzBd,aAAaY,CAAAA,OAAS;gBAAE,GAAGA,IAAI;gBAAEE;gBAAM,OAAOZ;YAAU;QACxDE,sBAAsB,EAAE;IAC5B,GAAG,EAAE;IAEL,MAAMW,WAAWL,YAAY,CAACM;QAC1BhB,aAAaY,CAAAA,OAAS;gBAAE,GAAGA,IAAI;gBAAEI;YAAM;IAC3C,GAAG,EAAE;IAEL,MAAMC,WAAWP,YAAY,CAACQ;QAC1BlB,aAAaY,CAAAA,OAAS;gBAAE,GAAGA,IAAI;gBAAEM;YAAM;IAC3C,GAAG,EAAE;IAEL,MAAM,CAACC,gBAAgBC,kBAAkB,GAAGnB,SAAS;IACrD,MAAM,CAACoB,YAAYC,cAAc,GAAGrB,SAA2B,EAAE;IAEjEsB,UAAU;QACN,MAAMT,OAAOO,UAAU,CAAC,EAAE;QAC1B,IAAI,CAACP,MACD;QAEJD,QAAQC,KAAK,IAAI,GAAG,SAAS;IACjC,GAAG;QAACO;KAAW;IAEf,MAAMG,eAAeC,OAAO;IAE5BF,UAAU;QACNjB,WAAW;QACX,MAAMoB,YAAY,EAAEF,aAAa,OAAO;QAExC5B,QAAQ,OAAO,CAACG,WAAW,IAAI,CAAC4B,CAAAA;YAC5B,IAAID,cAAcF,aAAa,OAAO,EAClC;YAGAzB,UAAU,KAAK,GACfK,sBAAsBQ,CAAAA,OAAQ;uBAAIA;uBAASe,OAAO,OAAO;iBAAC,IAE1DvB,sBAAsBuB,OAAO,OAAO;YAGxCnB,QAAQmB,OAAO,IAAI;YACnBrB,WAAW;QACf;IACJ,GAAG;QAACP;KAAU;IAEd,MAAM6B,UAAUC,QAAQ,IACb;YACH;gBACI,IAAI;gBACJ,MAAM9B,AAAmB,WAAnBA,UAAU,IAAI;YACxB;SACH,EACF;QAACA,UAAU,IAAI;KAAC;IAEnB,OAAO;QACH,eAAeM;QACf,SAASF;QACTI;QACA,iBAAiB;YACbQ,SAASR,KAAK,MAAM,IAAIL;QAC5B;QACAO;QACAmB;QACA,YAAYN;QACZL;QACA,mBAAmBZ,WAAW,CAAC,CAACN,UAAU,KAAK;QAC/CoB;QACA,aAAa;YACTC,kBAAkB;QACtB;QACA,aAAa;YACTA,kBAAkB;QACtB;IACJ;AACJ"}
|
package/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { LogsView } from "./views/Logs/LogsView.js";
|
|
|
7
7
|
import { AuditLogsListWithConfig } from "./config/list/index.js";
|
|
8
8
|
import { Routes } from "./routes.js";
|
|
9
9
|
import { AlPermissionsFeature } from "./features/permissions/feature.js";
|
|
10
|
+
import { ListAuditLogsFeature } from "./features/listAuditLogs/index.js";
|
|
10
11
|
const { Menu: Menu, Route: Route } = AdminConfig;
|
|
11
12
|
const AuditLogs = ()=>{
|
|
12
13
|
const wcp = useWcp();
|
|
@@ -14,6 +15,8 @@ const AuditLogs = ()=>{
|
|
|
14
15
|
if (!wcp.canUseAuditLogs()) return null;
|
|
15
16
|
return /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(RegisterFeature, {
|
|
16
17
|
feature: AlPermissionsFeature
|
|
18
|
+
}), /*#__PURE__*/ react.createElement(RegisterFeature, {
|
|
19
|
+
feature: ListAuditLogsFeature
|
|
17
20
|
}), /*#__PURE__*/ react.createElement(LogsModule, null), /*#__PURE__*/ react.createElement(SecurityPermission, null), /*#__PURE__*/ react.createElement(AdminConfig, null, /*#__PURE__*/ react.createElement(HasPermission, {
|
|
18
21
|
any: [
|
|
19
22
|
"al.*"
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["import React from \"react\";\nimport { useRouter } from \"@webiny/app-admin\";\nimport { ReactComponent as Icon } from \"@webiny/icons/manage_search.svg\";\nimport { AdminConfig, AdminLayout, RegisterFeature, useWcp } from \"@webiny/app-admin\";\nimport { HasPermission } from \"@webiny/app-admin\";\nimport { LogsModule } from \"~/views/Logs/LogsModule.js\";\nimport { SecurityPermission } from \"~/SecurityPermission.js\";\nimport { LogsView } from \"~/views/Logs/LogsView.js\";\nimport { AuditLogsListWithConfig } from \"~/config/list/index.js\";\nimport { Routes } from \"~/routes.js\";\nimport { AlPermissionsFeature } from \"~/features/permissions/feature.js\";\n\nconst { Menu, Route } = AdminConfig;\n\nexport const AuditLogs = () => {\n const wcp = useWcp();\n const router = useRouter();\n\n if (!wcp.canUseAuditLogs()) {\n return null;\n }\n\n return (\n <>\n <RegisterFeature feature={AlPermissionsFeature} />\n <LogsModule />\n <SecurityPermission />\n <AdminConfig>\n <HasPermission any={[\"al.*\"]}>\n <Menu\n name=\"auditLogs\"\n pinnable\n element={\n <Menu.Link\n text={\"Audit Logs\"}\n icon={<Menu.Link.Icon element={<Icon />} label={\"Audit Logs\"} />}\n to={router.getLink(Routes.AuditLogsList)}\n />\n }\n />\n <Route\n route={Routes.AuditLogsList}\n element={\n <AdminLayout title={\"Audit Logs - Logs\"}>\n <AuditLogsListWithConfig>\n <LogsView />\n </AuditLogsListWithConfig>\n </AdminLayout>\n }\n />\n </HasPermission>\n </AdminConfig>\n </>\n );\n};\n"],"names":["Menu","Route","AdminConfig","AuditLogs","wcp","useWcp","router","useRouter","RegisterFeature","AlPermissionsFeature","LogsModule","SecurityPermission","HasPermission","Icon","Routes","AdminLayout","AuditLogsListWithConfig","LogsView"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["import React from \"react\";\nimport { useRouter } from \"@webiny/app-admin\";\nimport { ReactComponent as Icon } from \"@webiny/icons/manage_search.svg\";\nimport { AdminConfig, AdminLayout, RegisterFeature, useWcp } from \"@webiny/app-admin\";\nimport { HasPermission } from \"@webiny/app-admin\";\nimport { LogsModule } from \"~/views/Logs/LogsModule.js\";\nimport { SecurityPermission } from \"~/SecurityPermission.js\";\nimport { LogsView } from \"~/views/Logs/LogsView.js\";\nimport { AuditLogsListWithConfig } from \"~/config/list/index.js\";\nimport { Routes } from \"~/routes.js\";\nimport { AlPermissionsFeature } from \"~/features/permissions/feature.js\";\nimport { ListAuditLogsFeature } from \"~/features/listAuditLogs/index.js\";\n\nconst { Menu, Route } = AdminConfig;\n\nexport const AuditLogs = () => {\n const wcp = useWcp();\n const router = useRouter();\n\n if (!wcp.canUseAuditLogs()) {\n return null;\n }\n\n return (\n <>\n <RegisterFeature feature={AlPermissionsFeature} />\n <RegisterFeature feature={ListAuditLogsFeature} />\n <LogsModule />\n <SecurityPermission />\n <AdminConfig>\n <HasPermission any={[\"al.*\"]}>\n <Menu\n name=\"auditLogs\"\n pinnable\n element={\n <Menu.Link\n text={\"Audit Logs\"}\n icon={<Menu.Link.Icon element={<Icon />} label={\"Audit Logs\"} />}\n to={router.getLink(Routes.AuditLogsList)}\n />\n }\n />\n <Route\n route={Routes.AuditLogsList}\n element={\n <AdminLayout title={\"Audit Logs - Logs\"}>\n <AuditLogsListWithConfig>\n <LogsView />\n </AuditLogsListWithConfig>\n </AdminLayout>\n }\n />\n </HasPermission>\n </AdminConfig>\n </>\n );\n};\n"],"names":["Menu","Route","AdminConfig","AuditLogs","wcp","useWcp","router","useRouter","RegisterFeature","AlPermissionsFeature","ListAuditLogsFeature","LogsModule","SecurityPermission","HasPermission","Icon","Routes","AdminLayout","AuditLogsListWithConfig","LogsView"],"mappings":";;;;;;;;;;AAaA,MAAM,EAAEA,MAAAA,IAAI,EAAEC,OAAAA,KAAK,EAAE,GAAGC;AAEjB,MAAMC,YAAY;IACrB,MAAMC,MAAMC;IACZ,MAAMC,SAASC;IAEf,IAAI,CAACH,IAAI,eAAe,IACpB,OAAO;IAGX,OAAO,WAAP,GACI,wDACI,oBAACI,iBAAeA;QAAC,SAASC;sBAC1B,oBAACD,iBAAeA;QAAC,SAASE;sBAC1B,oBAACC,YAAUA,OAAAA,WAAAA,GACX,oBAACC,oBAAkBA,OAAAA,WAAAA,GACnB,oBAACV,aAAWA,MAAAA,WAAAA,GACR,oBAACW,eAAaA;QAAC,KAAK;YAAC;SAAO;qBACxB,oBAACb,MAAIA;QACD,MAAK;QACL;QACA,uBACI,oBAACA,KAAK,IAAI;YACN,MAAM;YACN,oBAAM,oBAACA,KAAK,IAAI,CAAC,IAAI;gBAAC,uBAAS,oBAACc,gBAAIA;gBAAK,OAAO;;YAChD,IAAIR,OAAO,OAAO,CAACS,OAAO,aAAa;;sBAInD,oBAACd,OAAKA;QACF,OAAOc,OAAO,aAAa;QAC3B,uBACI,oBAACC,aAAWA;YAAC,OAAO;yBAChB,oBAACC,yBAAuBA,MAAAA,WAAAA,GACpB,oBAACC,UAAQA;;AAS7C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-audit-logs",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0-alpha.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -13,20 +13,19 @@
|
|
|
13
13
|
"description": "",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@apollo/react-hooks": "3.1.5",
|
|
17
16
|
"@emotion/css": "11.13.5",
|
|
18
17
|
"@emotion/react": "11.14.0",
|
|
19
18
|
"@emotion/styled": "11.14.1",
|
|
20
|
-
"@webiny/admin-ui": "6.
|
|
21
|
-
"@webiny/app": "6.
|
|
22
|
-
"@webiny/app-admin": "6.
|
|
23
|
-
"@webiny/common-audit-logs": "6.
|
|
24
|
-
"@webiny/
|
|
25
|
-
"@webiny/
|
|
26
|
-
"@webiny/
|
|
27
|
-
"@webiny/react-
|
|
19
|
+
"@webiny/admin-ui": "6.6.0-alpha.0",
|
|
20
|
+
"@webiny/app": "6.6.0-alpha.0",
|
|
21
|
+
"@webiny/app-admin": "6.6.0-alpha.0",
|
|
22
|
+
"@webiny/common-audit-logs": "6.6.0-alpha.0",
|
|
23
|
+
"@webiny/feature": "6.6.0-alpha.0",
|
|
24
|
+
"@webiny/form": "6.6.0-alpha.0",
|
|
25
|
+
"@webiny/icons": "6.6.0-alpha.0",
|
|
26
|
+
"@webiny/react-composition": "6.6.0-alpha.0",
|
|
27
|
+
"@webiny/react-properties": "6.6.0-alpha.0",
|
|
28
28
|
"date-fns": "4.4.0",
|
|
29
|
-
"graphql-tag": "2.12.7",
|
|
30
29
|
"lodash": "4.18.1",
|
|
31
30
|
"zod": "4.4.3"
|
|
32
31
|
},
|
|
@@ -35,10 +34,10 @@
|
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
37
36
|
"@types/react": "18.3.31",
|
|
38
|
-
"@webiny/build-tools": "6.
|
|
39
|
-
"execa": "
|
|
37
|
+
"@webiny/build-tools": "6.6.0-alpha.0",
|
|
38
|
+
"execa": "10.0.0",
|
|
40
39
|
"rimraf": "6.1.3",
|
|
41
|
-
"typescript": "
|
|
40
|
+
"typescript": "7.0.2"
|
|
42
41
|
},
|
|
43
42
|
"publishConfig": {
|
|
44
43
|
"access": "public"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import react, { useMemo } from "react";
|
|
2
|
-
import {
|
|
1
|
+
import react, { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { useContainer } from "@webiny/app";
|
|
3
|
+
import { MainGraphQLClient } from "@webiny/app/features/mainGraphQLClient";
|
|
3
4
|
import { useBind } from "@webiny/form";
|
|
4
5
|
import { Select } from "@webiny/admin-ui";
|
|
5
6
|
import { LIST_USERS } from "../../../graphql.js";
|
|
@@ -8,16 +9,23 @@ const getValidFilterValue = (value)=>{
|
|
|
8
9
|
return value;
|
|
9
10
|
};
|
|
10
11
|
const FilterByCreatedBy = ()=>{
|
|
11
|
-
const
|
|
12
|
+
const container = useContainer();
|
|
13
|
+
const client = container.resolve(MainGraphQLClient);
|
|
14
|
+
const [users, setUsers] = useState([]);
|
|
15
|
+
useEffect(()=>{
|
|
16
|
+
client.execute({
|
|
17
|
+
query: LIST_USERS
|
|
18
|
+
}).then((response)=>{
|
|
19
|
+
setUsers(response.adminUsers.users.data || []);
|
|
20
|
+
});
|
|
21
|
+
}, []);
|
|
12
22
|
const bind = useBind({
|
|
13
23
|
name: "createdBy",
|
|
14
24
|
beforeChange (value, cb) {
|
|
15
25
|
cb(getValidFilterValue(value));
|
|
16
26
|
}
|
|
17
27
|
});
|
|
18
|
-
const options = useMemo(()=>
|
|
19
|
-
const users = listUsers?.adminUsers?.users?.data || [];
|
|
20
|
-
return [
|
|
28
|
+
const options = useMemo(()=>[
|
|
21
29
|
{
|
|
22
30
|
label: "All",
|
|
23
31
|
value: "all"
|
|
@@ -26,9 +34,8 @@ const FilterByCreatedBy = ()=>{
|
|
|
26
34
|
label: `${user.firstName} ${user.lastName}`,
|
|
27
35
|
value: user.id
|
|
28
36
|
}))
|
|
29
|
-
]
|
|
30
|
-
|
|
31
|
-
listUsers
|
|
37
|
+
], [
|
|
38
|
+
users
|
|
32
39
|
]);
|
|
33
40
|
return /*#__PURE__*/ react.createElement(Select, {
|
|
34
41
|
...bind,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"views/Logs/Filters/FilterByCreatedBy.js","sources":["../../../../src/views/Logs/Filters/FilterByCreatedBy.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"views/Logs/Filters/FilterByCreatedBy.js","sources":["../../../../src/views/Logs/Filters/FilterByCreatedBy.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from \"react\";\nimport { useContainer } from \"@webiny/app\";\nimport { MainGraphQLClient } from \"@webiny/app/features/mainGraphQLClient\";\nimport { useBind } from \"@webiny/form\";\nimport { Select } from \"@webiny/admin-ui\";\nimport { LIST_USERS } from \"~/graphql.js\";\nimport type { User } from \"~/types.js\";\n\ninterface ListUsersResponse {\n adminUsers: {\n users: {\n data: User[];\n };\n };\n}\n\nconst getValidFilterValue = (value: string): string | undefined => {\n if (value === \"all\" || value === \"\") {\n return undefined;\n }\n return value;\n};\n\nexport const FilterByCreatedBy = () => {\n const container = useContainer();\n const client = container.resolve(MainGraphQLClient);\n const [users, setUsers] = useState<User[]>([]);\n\n useEffect(() => {\n client.execute<ListUsersResponse>({ query: LIST_USERS }).then(response => {\n setUsers(response.adminUsers.users.data || []);\n });\n }, []);\n\n const bind = useBind({\n name: \"createdBy\",\n beforeChange(value, cb) {\n cb(getValidFilterValue(value));\n }\n });\n\n const options = useMemo(() => {\n return [\n { label: \"All\", value: \"all\" },\n ...users.map(user => ({ label: `${user.firstName} ${user.lastName}`, value: user.id }))\n ];\n }, [users]);\n\n return <Select {...bind} size={\"md\"} placeholder={\"Filter by Initiator\"} options={options} />;\n};\n"],"names":["getValidFilterValue","value","FilterByCreatedBy","container","useContainer","client","MainGraphQLClient","users","setUsers","useState","useEffect","LIST_USERS","response","bind","useBind","cb","options","useMemo","user","Select"],"mappings":";;;;;;AAgBA,MAAMA,sBAAsB,CAACC;IACzB,IAAIA,AAAU,UAAVA,SAAmBA,AAAU,OAAVA,OACnB;IAEJ,OAAOA;AACX;AAEO,MAAMC,oBAAoB;IAC7B,MAAMC,YAAYC;IAClB,MAAMC,SAASF,UAAU,OAAO,CAACG;IACjC,MAAM,CAACC,OAAOC,SAAS,GAAGC,SAAiB,EAAE;IAE7CC,UAAU;QACNL,OAAO,OAAO,CAAoB;YAAE,OAAOM;QAAW,GAAG,IAAI,CAACC,CAAAA;YAC1DJ,SAASI,SAAS,UAAU,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE;QACjD;IACJ,GAAG,EAAE;IAEL,MAAMC,OAAOC,QAAQ;QACjB,MAAM;QACN,cAAab,KAAK,EAAEc,EAAE;YAClBA,GAAGf,oBAAoBC;QAC3B;IACJ;IAEA,MAAMe,UAAUC,QAAQ,IACb;YACH;gBAAE,OAAO;gBAAO,OAAO;YAAM;eAC1BV,MAAM,GAAG,CAACW,CAAAA,OAAS;oBAAE,OAAO,GAAGA,KAAK,SAAS,CAAC,CAAC,EAAEA,KAAK,QAAQ,EAAE;oBAAE,OAAOA,KAAK,EAAE;gBAAC;SACvF,EACF;QAACX;KAAM;IAEV,OAAO,WAAP,GAAO,oBAACY,QAAMA;QAAE,GAAGN,IAAI;QAAE,MAAM;QAAM,aAAa;QAAuB,SAASG;;AACtF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import react, { useMemo } from "react";
|
|
2
|
-
import {
|
|
1
|
+
import react, { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { useContainer } from "@webiny/app";
|
|
3
|
+
import { MainGraphQLClient } from "@webiny/app/features/mainGraphQLClient";
|
|
3
4
|
import { useBind } from "@webiny/form";
|
|
4
5
|
import { Select } from "@webiny/admin-ui";
|
|
5
6
|
import { LIST_USERS } from "../../../graphql.js";
|
|
@@ -8,16 +9,23 @@ const getValidFilterValue = (value)=>{
|
|
|
8
9
|
return value;
|
|
9
10
|
};
|
|
10
11
|
const FilterByInitiator = ()=>{
|
|
11
|
-
const
|
|
12
|
+
const container = useContainer();
|
|
13
|
+
const client = container.resolve(MainGraphQLClient);
|
|
14
|
+
const [users, setUsers] = useState([]);
|
|
15
|
+
useEffect(()=>{
|
|
16
|
+
client.execute({
|
|
17
|
+
query: LIST_USERS
|
|
18
|
+
}).then((response)=>{
|
|
19
|
+
setUsers(response.adminUsers.users.data || []);
|
|
20
|
+
});
|
|
21
|
+
}, []);
|
|
12
22
|
const bind = useBind({
|
|
13
23
|
name: "data.initiator",
|
|
14
24
|
beforeChange (value, cb) {
|
|
15
25
|
cb(getValidFilterValue(value));
|
|
16
26
|
}
|
|
17
27
|
});
|
|
18
|
-
const options = useMemo(()=>
|
|
19
|
-
const users = listUsers?.adminUsers?.users?.data || [];
|
|
20
|
-
return [
|
|
28
|
+
const options = useMemo(()=>[
|
|
21
29
|
{
|
|
22
30
|
label: "All",
|
|
23
31
|
value: "all"
|
|
@@ -26,9 +34,8 @@ const FilterByInitiator = ()=>{
|
|
|
26
34
|
label: `${user.firstName} ${user.lastName}`,
|
|
27
35
|
value: user.id
|
|
28
36
|
}))
|
|
29
|
-
]
|
|
30
|
-
|
|
31
|
-
listUsers
|
|
37
|
+
], [
|
|
38
|
+
users
|
|
32
39
|
]);
|
|
33
40
|
return /*#__PURE__*/ react.createElement(Select, {
|
|
34
41
|
...bind,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"views/Logs/Filters/FilterByInitiator.js","sources":["../../../../src/views/Logs/Filters/FilterByInitiator.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"views/Logs/Filters/FilterByInitiator.js","sources":["../../../../src/views/Logs/Filters/FilterByInitiator.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from \"react\";\nimport { useContainer } from \"@webiny/app\";\nimport { MainGraphQLClient } from \"@webiny/app/features/mainGraphQLClient\";\nimport { useBind } from \"@webiny/form\";\nimport { Select } from \"@webiny/admin-ui\";\nimport { LIST_USERS } from \"~/graphql.js\";\nimport type { User } from \"~/types.js\";\n\ninterface ListUsersResponse {\n adminUsers: {\n users: {\n data: User[];\n };\n };\n}\n\nconst getValidFilterValue = (value: string): string | undefined => {\n if (value === \"all\" || value === \"\") {\n return undefined;\n }\n return value;\n};\n\nexport const FilterByInitiator = () => {\n const container = useContainer();\n const client = container.resolve(MainGraphQLClient);\n const [users, setUsers] = useState<User[]>([]);\n\n useEffect(() => {\n client.execute<ListUsersResponse>({ query: LIST_USERS }).then(response => {\n setUsers(response.adminUsers.users.data || []);\n });\n }, []);\n\n const bind = useBind({\n name: \"data.initiator\",\n beforeChange(value, cb) {\n cb(getValidFilterValue(value));\n }\n });\n\n const options = useMemo(() => {\n return [\n { label: \"All\", value: \"all\" },\n ...users.map(user => ({ label: `${user.firstName} ${user.lastName}`, value: user.id }))\n ];\n }, [users]);\n\n return <Select {...bind} size={\"md\"} placeholder={\"Filter by Initiator\"} options={options} />;\n};\n"],"names":["getValidFilterValue","value","FilterByInitiator","container","useContainer","client","MainGraphQLClient","users","setUsers","useState","useEffect","LIST_USERS","response","bind","useBind","cb","options","useMemo","user","Select"],"mappings":";;;;;;AAgBA,MAAMA,sBAAsB,CAACC;IACzB,IAAIA,AAAU,UAAVA,SAAmBA,AAAU,OAAVA,OACnB;IAEJ,OAAOA;AACX;AAEO,MAAMC,oBAAoB;IAC7B,MAAMC,YAAYC;IAClB,MAAMC,SAASF,UAAU,OAAO,CAACG;IACjC,MAAM,CAACC,OAAOC,SAAS,GAAGC,SAAiB,EAAE;IAE7CC,UAAU;QACNL,OAAO,OAAO,CAAoB;YAAE,OAAOM;QAAW,GAAG,IAAI,CAACC,CAAAA;YAC1DJ,SAASI,SAAS,UAAU,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE;QACjD;IACJ,GAAG,EAAE;IAEL,MAAMC,OAAOC,QAAQ;QACjB,MAAM;QACN,cAAab,KAAK,EAAEc,EAAE;YAClBA,GAAGf,oBAAoBC;QAC3B;IACJ;IAEA,MAAMe,UAAUC,QAAQ,IACb;YACH;gBAAE,OAAO;gBAAO,OAAO;YAAM;eAC1BV,MAAM,GAAG,CAACW,CAAAA,OAAS;oBAAE,OAAO,GAAGA,KAAK,SAAS,CAAC,CAAC,EAAEA,KAAK,QAAQ,EAAE;oBAAE,OAAOA,KAAK,EAAE;gBAAC;SACvF,EACF;QAACX;KAAM;IAEV,OAAO,WAAP,GAAO,oBAACY,QAAMA;QAAE,GAAGN,IAAI;QAAE,MAAM;QAAM,aAAa;QAAuB,SAASG;;AACtF"}
|
package/hooks/graphql.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/graphql.js","sources":["../../src/hooks/graphql.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport type { IAuditLogRaw, IAuditLogsError, IAuditLogsMeta } from \"~/types.js\";\n\nexport interface IListAuditLogsVariablesWhere {\n app?: string;\n action?: string;\n createdBy?: string;\n entity?: string;\n entityId?: string;\n createdOn_gte?: Date;\n createdOn_lte?: Date;\n}\n\nexport interface IListAuditLogsVariables {\n where: Partial<IListAuditLogsVariablesWhere>;\n after: string | undefined;\n sort: \"ASC\" | \"DESC\" | undefined;\n limit: number | undefined;\n}\n\nexport type IListAuditLogsVariablesPartial = Partial<IListAuditLogsVariables>;\n\nexport interface IListAuditLogsResponse {\n auditLogs: {\n listAuditLogs: {\n data: IAuditLogRaw[] | null;\n meta: IAuditLogsMeta | null;\n error: IAuditLogsError | null;\n };\n };\n}\n\nexport const LIST_AUDIT_LOGS = gql`\n query ListAuditLogs(\n $where: ListAuditLogsWhere!\n $sort: AuditLogsSort\n $after: String\n $limit: Number\n ) {\n auditLogs {\n listAuditLogs(where: $where, after: $after, sort: $sort, limit: $limit) {\n data {\n id\n createdBy {\n id\n displayName\n type\n }\n createdOn\n app\n action\n message\n entity\n entityId\n tags\n expiresAt\n content\n }\n meta {\n hasMoreItems\n cursor\n }\n error {\n message\n code\n data\n stack\n }\n }\n }\n }\n`;\n"],"names":["LIST_AUDIT_LOGS","gql"],"mappings":";AAgCO,MAAMA,kBAAkBC,WAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCnC,CAAC"}
|