@webiny/api-audit-logs 6.4.11 → 6.6.0-alpha.1
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/AuditLogsFeature.d.ts +8 -0
- package/AuditLogsFeature.js +42 -0
- package/AuditLogsFeature.js.map +1 -0
- package/abstractions.d.ts +8 -3
- package/abstractions.js +2 -1
- package/abstractions.js.map +1 -1
- package/context/AuditLogsContextValue.js +5 -3
- package/context/AuditLogsContextValue.js.map +1 -1
- package/graphql/AuditLogsGraphQLSchema.d.ts +9 -0
- package/graphql/AuditLogsGraphQLSchema.js +134 -0
- package/graphql/AuditLogsGraphQLSchema.js.map +1 -0
- package/index.d.ts +2 -8
- package/index.js +1 -25
- package/package.json +24 -24
- package/storage/types.d.ts +0 -35
- package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.js +4 -7
- package/subscriptions/aco/handlers/AuditLogFolderAfterDeleteHandler.js.map +1 -1
- package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.d.ts +11 -0
- package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.js +41 -0
- package/subscriptions/ai/handlers/AuditLogAiAfterGenerateTextHandler.js.map +1 -0
- package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.d.ts +11 -0
- package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.js +38 -0
- package/subscriptions/ai/handlers/AuditLogAiBeforeGenerateTextHandler.js.map +1 -0
- package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.d.ts +11 -0
- package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.js +40 -0
- package/subscriptions/ai/handlers/AuditLogAiGenerateTextErrorHandler.js.map +1 -0
- package/subscriptions/ai/index.d.ts +2 -0
- package/subscriptions/ai/index.js +11 -0
- package/subscriptions/ai/index.js.map +1 -0
- package/subscriptions/index.js +2 -0
- package/subscriptions/index.js.map +1 -1
- package/types.d.ts +1 -2
- package/utils/getAuditConfig.js +4 -2
- package/utils/getAuditConfig.js.map +1 -1
- package/context/index.d.ts +0 -9
- package/context/index.js +0 -31
- package/context/index.js.map +0 -1
- package/graphql/schema.d.ts +0 -3
- package/graphql/schema.js +0 -115
- package/graphql/schema.js.map +0 -1
- package/index.js.map +0 -1
- package/storage/AccessPatternHandler.d.ts +0 -14
- package/storage/AccessPatternHandler.js +0 -39
- package/storage/AccessPatternHandler.js.map +0 -1
- package/storage/Converter.d.ts +0 -16
- package/storage/Converter.js +0 -49
- package/storage/Converter.js.map +0 -1
- package/storage/Storage.d.ts +0 -18
- package/storage/Storage.js +0 -81
- package/storage/Storage.js.map +0 -1
- package/storage/abstractions/AccessPattern.d.ts +0 -24
- package/storage/abstractions/AccessPattern.js +0 -0
- package/storage/abstractions/AccessPatternHandler.d.ts +0 -13
- package/storage/abstractions/AccessPatternHandler.js +0 -0
- package/storage/abstractions/Converter.d.ts +0 -6
- package/storage/abstractions/Converter.js +0 -0
- package/storage/accessPatterns/AppAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/AppAccessPattern.js +0 -35
- package/storage/accessPatterns/AppAccessPattern.js.map +0 -1
- package/storage/accessPatterns/AppCreatedByAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/AppCreatedByAccessPattern.js +0 -38
- package/storage/accessPatterns/AppCreatedByAccessPattern.js.map +0 -1
- package/storage/accessPatterns/AppEntityAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/AppEntityAccessPattern.js +0 -35
- package/storage/accessPatterns/AppEntityAccessPattern.js.map +0 -1
- package/storage/accessPatterns/AppEntityActionAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/AppEntityActionAccessPattern.js +0 -35
- package/storage/accessPatterns/AppEntityActionAccessPattern.js.map +0 -1
- package/storage/accessPatterns/AppEntityActionCreatedByAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/AppEntityActionCreatedByAccessPattern.js +0 -38
- package/storage/accessPatterns/AppEntityActionCreatedByAccessPattern.js.map +0 -1
- package/storage/accessPatterns/AppEntityCreatedByAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/AppEntityCreatedByAccessPattern.js +0 -38
- package/storage/accessPatterns/AppEntityCreatedByAccessPattern.js.map +0 -1
- package/storage/accessPatterns/BaseAccessPattern.d.ts +0 -32
- package/storage/accessPatterns/BaseAccessPattern.js +0 -60
- package/storage/accessPatterns/BaseAccessPattern.js.map +0 -1
- package/storage/accessPatterns/CreatedByAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/CreatedByAccessPattern.js +0 -38
- package/storage/accessPatterns/CreatedByAccessPattern.js.map +0 -1
- package/storage/accessPatterns/CreatedOnAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/CreatedOnAccessPattern.js +0 -38
- package/storage/accessPatterns/CreatedOnAccessPattern.js.map +0 -1
- package/storage/accessPatterns/DefaultAccessPattern.d.ts +0 -15
- package/storage/accessPatterns/DefaultAccessPattern.js +0 -35
- package/storage/accessPatterns/DefaultAccessPattern.js.map +0 -1
- package/storage/accessPatterns/EntityIdAccessPattern.d.ts +0 -9
- package/storage/accessPatterns/EntityIdAccessPattern.js +0 -38
- package/storage/accessPatterns/EntityIdAccessPattern.js.map +0 -1
- package/storage/accessPatterns/index.d.ts +0 -6
- package/storage/accessPatterns/index.js +0 -57
- package/storage/accessPatterns/index.js.map +0 -1
- package/storage/cursorSchema.d.ts +0 -4
- package/storage/cursorSchema.js +0 -22
- package/storage/cursorSchema.js.map +0 -1
- package/storage/entity.d.ts +0 -36
- package/storage/entity.js +0 -120
- package/storage/entity.js.map +0 -1
- package/storage/results/ListErrorResult.d.ts +0 -10
- package/storage/results/ListErrorResult.js +0 -12
- package/storage/results/ListErrorResult.js.map +0 -1
- package/storage/results/ListSuccessResult.d.ts +0 -14
- package/storage/results/ListSuccessResult.js +0 -17
- package/storage/results/ListSuccessResult.js.map +0 -1
- package/storage/results/index.d.ts +0 -2
- package/storage/results/index.js +0 -2
- package/storage/startKey.d.ts +0 -6
- package/storage/startKey.js +0 -8
- package/storage/startKey.js.map +0 -1
package/storage/Storage.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { createEntity } from "./entity.js";
|
|
2
|
-
import { Converter } from "./Converter.js";
|
|
3
|
-
import { createAccessPatterns } from "./accessPatterns/index.js";
|
|
4
|
-
import { AccessPatternHandler } from "./AccessPatternHandler.js";
|
|
5
|
-
import { ListSuccessResult } from "./results/index.js";
|
|
6
|
-
class Storage {
|
|
7
|
-
constructor(params){
|
|
8
|
-
const { entity } = createEntity({
|
|
9
|
-
client: params.client,
|
|
10
|
-
tableName: params.tableName,
|
|
11
|
-
gsiAmount: 10
|
|
12
|
-
});
|
|
13
|
-
this.entity = entity;
|
|
14
|
-
const patterns = createAccessPatterns({
|
|
15
|
-
entity
|
|
16
|
-
});
|
|
17
|
-
this.patternHandler = new AccessPatternHandler({
|
|
18
|
-
patterns
|
|
19
|
-
});
|
|
20
|
-
this.converter = new Converter({
|
|
21
|
-
compressionHandler: params.compressionHandler,
|
|
22
|
-
patternHandler: this.patternHandler
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
async fetch(params) {
|
|
26
|
-
const { id, tenant } = params;
|
|
27
|
-
try {
|
|
28
|
-
const result = await this.entity.get({
|
|
29
|
-
PK: `T#${tenant}#AUDIT_LOG`,
|
|
30
|
-
SK: `${id}`
|
|
31
|
-
});
|
|
32
|
-
if (!result) return {
|
|
33
|
-
error: new Error(`Audit log entry "${id}" not found.`),
|
|
34
|
-
success: false
|
|
35
|
-
};
|
|
36
|
-
return {
|
|
37
|
-
data: await this.converter.oneFromStorage(result),
|
|
38
|
-
success: true
|
|
39
|
-
};
|
|
40
|
-
} catch (ex) {
|
|
41
|
-
return {
|
|
42
|
-
error: ex,
|
|
43
|
-
success: false
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async store(params) {
|
|
48
|
-
const auditLog = structuredClone(params.data);
|
|
49
|
-
try {
|
|
50
|
-
const item = await this.converter.oneToStorage(auditLog);
|
|
51
|
-
await this.entity.put(item);
|
|
52
|
-
} catch (ex) {
|
|
53
|
-
return {
|
|
54
|
-
error: ex,
|
|
55
|
-
success: false
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
success: true,
|
|
60
|
-
data: auditLog
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
async list(params) {
|
|
64
|
-
try {
|
|
65
|
-
const result = await this.patternHandler.handle(params);
|
|
66
|
-
return ListSuccessResult.create({
|
|
67
|
-
data: await this.converter.listFromStorage(result.items),
|
|
68
|
-
lastEvaluatedKey: result.lastEvaluatedKey
|
|
69
|
-
});
|
|
70
|
-
} catch (ex) {
|
|
71
|
-
return {
|
|
72
|
-
error: ex,
|
|
73
|
-
success: false
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
const createStorage = (params)=>new Storage(params);
|
|
79
|
-
export { Storage, createStorage };
|
|
80
|
-
|
|
81
|
-
//# sourceMappingURL=Storage.js.map
|
package/storage/Storage.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/Storage.js","sources":["../../src/storage/Storage.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createEntity } from \"~/storage/entity.js\";\nimport type {\n IStorage,\n IStorageFetchParams,\n IStorageFetchResult,\n IStorageListParams,\n IStorageListResult,\n IStorageStoreParams,\n IStorageStoreResult\n} from \"~/storage/abstractions/Storage.js\";\nimport { Converter } from \"~/storage/Converter.js\";\nimport { createAccessPatterns } from \"~/storage/accessPatterns/index.js\";\nimport { AccessPatternHandler } from \"~/storage/AccessPatternHandler.js\";\nimport { ListSuccessResult } from \"~/storage/results/index.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\n\nexport interface IStorageParams {\n compressionHandler: CompressionHandler.Interface;\n client: DynamoDBDocument;\n tableName: string | undefined;\n}\n\nexport class Storage implements IStorage {\n private readonly entity;\n private readonly converter;\n private readonly patternHandler;\n\n public constructor(params: IStorageParams) {\n const { entity } = createEntity({\n client: params.client,\n tableName: params.tableName,\n gsiAmount: 10\n });\n\n this.entity = entity;\n\n const patterns = createAccessPatterns({\n entity\n });\n this.patternHandler = new AccessPatternHandler({\n patterns\n });\n\n this.converter = new Converter({\n compressionHandler: params.compressionHandler,\n patternHandler: this.patternHandler\n });\n }\n\n public async fetch(params: IStorageFetchParams): Promise<IStorageFetchResult> {\n const { id, tenant } = params;\n\n try {\n const result = await this.entity.get({\n PK: `T#${tenant}#AUDIT_LOG`,\n SK: `${id}`\n });\n if (!result) {\n return {\n error: new Error(`Audit log entry \"${id}\" not found.`),\n success: false\n };\n }\n return {\n data: await this.converter.oneFromStorage(result),\n success: true\n };\n } catch (ex) {\n return {\n error: ex,\n success: false\n };\n }\n }\n\n public async store(params: IStorageStoreParams): Promise<IStorageStoreResult> {\n const auditLog = structuredClone(params.data);\n\n try {\n const item = await this.converter.oneToStorage(auditLog);\n await this.entity.put(item);\n } catch (ex) {\n return {\n error: ex,\n success: false\n };\n }\n\n return {\n success: true,\n data: auditLog\n };\n }\n\n public async list(params: IStorageListParams): Promise<IStorageListResult> {\n try {\n const result = await this.patternHandler.handle(params);\n\n return ListSuccessResult.create({\n data: await this.converter.listFromStorage(result.items),\n lastEvaluatedKey: result.lastEvaluatedKey\n });\n } catch (ex) {\n return {\n error: ex,\n success: false\n };\n }\n }\n}\n\nexport const createStorage = (params: IStorageParams): IStorage => {\n return new Storage(params);\n};\n"],"names":["Storage","params","entity","createEntity","patterns","createAccessPatterns","AccessPatternHandler","Converter","id","tenant","result","Error","ex","auditLog","structuredClone","item","ListSuccessResult","createStorage"],"mappings":";;;;;AAuBO,MAAMA;IAKT,YAAmBC,MAAsB,CAAE;QACvC,MAAM,EAAEC,MAAM,EAAE,GAAGC,aAAa;YAC5B,QAAQF,OAAO,MAAM;YACrB,WAAWA,OAAO,SAAS;YAC3B,WAAW;QACf;QAEA,IAAI,CAAC,MAAM,GAAGC;QAEd,MAAME,WAAWC,qBAAqB;YAClCH;QACJ;QACA,IAAI,CAAC,cAAc,GAAG,IAAII,qBAAqB;YAC3CF;QACJ;QAEA,IAAI,CAAC,SAAS,GAAG,IAAIG,UAAU;YAC3B,oBAAoBN,OAAO,kBAAkB;YAC7C,gBAAgB,IAAI,CAAC,cAAc;QACvC;IACJ;IAEA,MAAa,MAAMA,MAA2B,EAAgC;QAC1E,MAAM,EAAEO,EAAE,EAAEC,MAAM,EAAE,GAAGR;QAEvB,IAAI;YACA,MAAMS,SAAS,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;gBACjC,IAAI,CAAC,EAAE,EAAED,OAAO,UAAU,CAAC;gBAC3B,IAAI,GAAGD,IAAI;YACf;YACA,IAAI,CAACE,QACD,OAAO;gBACH,OAAO,IAAIC,MAAM,CAAC,iBAAiB,EAAEH,GAAG,YAAY,CAAC;gBACrD,SAAS;YACb;YAEJ,OAAO;gBACH,MAAM,MAAM,IAAI,CAAC,SAAS,CAAC,cAAc,CAACE;gBAC1C,SAAS;YACb;QACJ,EAAE,OAAOE,IAAI;YACT,OAAO;gBACH,OAAOA;gBACP,SAAS;YACb;QACJ;IACJ;IAEA,MAAa,MAAMX,MAA2B,EAAgC;QAC1E,MAAMY,WAAWC,gBAAgBb,OAAO,IAAI;QAE5C,IAAI;YACA,MAAMc,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,CAACF;YAC/C,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAACE;QAC1B,EAAE,OAAOH,IAAI;YACT,OAAO;gBACH,OAAOA;gBACP,SAAS;YACb;QACJ;QAEA,OAAO;YACH,SAAS;YACT,MAAMC;QACV;IACJ;IAEA,MAAa,KAAKZ,MAA0B,EAA+B;QACvE,IAAI;YACA,MAAMS,SAAS,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAACT;YAEhD,OAAOe,kBAAkB,MAAM,CAAC;gBAC5B,MAAM,MAAM,IAAI,CAAC,SAAS,CAAC,eAAe,CAACN,OAAO,KAAK;gBACvD,kBAAkBA,OAAO,gBAAgB;YAC7C;QACJ,EAAE,OAAOE,IAAI;YACT,OAAO;gBACH,OAAOA;gBACP,SAAS;YACb;QACJ;IACJ;AACJ;AAEO,MAAMK,gBAAgB,CAAChB,SACnB,IAAID,QAAQC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { IAuditLog, IStorageItem } from "../../storage/types.js";
|
|
2
|
-
import type { IStorageListParams } from "./Storage.js";
|
|
3
|
-
import type { GenericRecord } from "@webiny/api/types.js";
|
|
4
|
-
export interface IAccessPatternCreateKeysResult {
|
|
5
|
-
partitionKey: string;
|
|
6
|
-
sortKey: string | number;
|
|
7
|
-
}
|
|
8
|
-
export interface IAccessPatternListResult {
|
|
9
|
-
items: IStorageItem[];
|
|
10
|
-
lastEvaluatedKey?: GenericRecord;
|
|
11
|
-
}
|
|
12
|
-
export type IAccessPatternHandlesKeys = keyof IStorageListParams;
|
|
13
|
-
export interface IAccessPatternHandles {
|
|
14
|
-
shouldInclude?: IAccessPatternHandlesKeys[];
|
|
15
|
-
mustInclude: IAccessPatternHandlesKeys[];
|
|
16
|
-
mustNotInclude: IAccessPatternHandlesKeys[];
|
|
17
|
-
}
|
|
18
|
-
export interface IAccessPattern<T> {
|
|
19
|
-
index: string | undefined;
|
|
20
|
-
handles(): IAccessPatternHandles;
|
|
21
|
-
canHandle(params: IStorageListParams): boolean;
|
|
22
|
-
list(params: T): Promise<IAccessPatternListResult>;
|
|
23
|
-
createKeys(item: IAuditLog): IAccessPatternCreateKeysResult;
|
|
24
|
-
}
|
|
File without changes
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { GenericRecord } from "@webiny/api/types.js";
|
|
2
|
-
import type { IStorageItem } from "../types.js";
|
|
3
|
-
import type { IAccessPattern } from "./AccessPattern.js";
|
|
4
|
-
import type { IStorageListParams } from "./Storage.js";
|
|
5
|
-
export interface IAccessPatternHandlerHandleResult {
|
|
6
|
-
items: IStorageItem[];
|
|
7
|
-
lastEvaluatedKey?: GenericRecord;
|
|
8
|
-
}
|
|
9
|
-
export interface IAccessPatternHandler {
|
|
10
|
-
handle(params: IStorageListParams): Promise<IAccessPatternHandlerHandleResult>;
|
|
11
|
-
getDefaultPattern(): IAccessPattern<unknown>;
|
|
12
|
-
listIndexPatterns(): IAccessPattern<unknown>[];
|
|
13
|
-
}
|
|
File without changes
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { IAuditLog, IStorageItem } from "../../storage/types.js";
|
|
2
|
-
export interface IConverter {
|
|
3
|
-
oneFromStorage(item: IStorageItem): Promise<IAuditLog>;
|
|
4
|
-
listFromStorage(items: IStorageItem[]): Promise<IAuditLog[]>;
|
|
5
|
-
oneToStorage(auditLog: IAuditLog): Promise<IStorageItem>;
|
|
6
|
-
}
|
|
File without changes
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { IAuditLog } from "../../storage/types.js";
|
|
2
|
-
import type { IStorageListByAppParams } from "../../storage/abstractions/Storage.js";
|
|
3
|
-
import { BaseAccessPattern } from "../../storage/accessPatterns/BaseAccessPattern.js";
|
|
4
|
-
import type { IAccessPatternCreateKeysResult, IAccessPatternHandles, IAccessPatternListResult } from "../../storage/abstractions/AccessPattern.js";
|
|
5
|
-
export declare class AppAccessPattern<T extends IStorageListByAppParams = IStorageListByAppParams> extends BaseAccessPattern<T> {
|
|
6
|
-
handles(): IAccessPatternHandles;
|
|
7
|
-
list(params: T): Promise<IAccessPatternListResult>;
|
|
8
|
-
createKeys(item: IAuditLog): IAccessPatternCreateKeysResult;
|
|
9
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { BaseAccessPattern } from "./BaseAccessPattern.js";
|
|
2
|
-
const createPartitionKey = (params)=>`T#${params.tenant}#AUDIT_LOG#APP#${params.app}`;
|
|
3
|
-
class AppAccessPattern extends BaseAccessPattern {
|
|
4
|
-
handles() {
|
|
5
|
-
return {
|
|
6
|
-
mustInclude: [
|
|
7
|
-
"app"
|
|
8
|
-
],
|
|
9
|
-
mustNotInclude: [
|
|
10
|
-
"createdBy",
|
|
11
|
-
"action",
|
|
12
|
-
"entityId",
|
|
13
|
-
"entity"
|
|
14
|
-
]
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
async list(params) {
|
|
18
|
-
const options = this.createOptions(params);
|
|
19
|
-
const result = await this.query({
|
|
20
|
-
partitionKey: createPartitionKey(params),
|
|
21
|
-
options
|
|
22
|
-
});
|
|
23
|
-
return this.populateResult(result);
|
|
24
|
-
}
|
|
25
|
-
createKeys(item) {
|
|
26
|
-
const time = item.createdOn.getTime();
|
|
27
|
-
return {
|
|
28
|
-
partitionKey: createPartitionKey(item),
|
|
29
|
-
sortKey: time
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export { AppAccessPattern };
|
|
34
|
-
|
|
35
|
-
//# sourceMappingURL=AppAccessPattern.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/accessPatterns/AppAccessPattern.js","sources":["../../../src/storage/accessPatterns/AppAccessPattern.ts"],"sourcesContent":["import type { IAuditLog } from \"~/storage/types.js\";\nimport type { IStorageListByAppParams } from \"~/storage/abstractions/Storage.js\";\nimport { BaseAccessPattern } from \"~/storage/accessPatterns/BaseAccessPattern.js\";\nimport type {\n IAccessPatternCreateKeysResult,\n IAccessPatternHandles,\n IAccessPatternListResult\n} from \"~/storage/abstractions/AccessPattern.js\";\n\ninterface ICreatePartitionKeyParams {\n tenant: string;\n app: string;\n}\n\nconst createPartitionKey = (params: ICreatePartitionKeyParams) => {\n return `T#${params.tenant}#AUDIT_LOG#APP#${params.app}`;\n};\n\nexport class AppAccessPattern<\n T extends IStorageListByAppParams = IStorageListByAppParams\n> extends BaseAccessPattern<T> {\n public override handles(): IAccessPatternHandles {\n return {\n mustInclude: [\"app\"],\n mustNotInclude: [\"createdBy\", \"action\", \"entityId\", \"entity\"]\n };\n }\n\n public async list(params: T): Promise<IAccessPatternListResult> {\n const options = this.createOptions(params);\n\n const result = await this.query({\n partitionKey: createPartitionKey(params),\n options\n });\n return this.populateResult(result);\n }\n\n public createKeys(item: IAuditLog): IAccessPatternCreateKeysResult {\n const time = item.createdOn.getTime();\n return {\n partitionKey: createPartitionKey(item),\n sortKey: time\n };\n }\n}\n"],"names":["createPartitionKey","params","AppAccessPattern","BaseAccessPattern","options","result","item","time"],"mappings":";AAcA,MAAMA,qBAAqB,CAACC,SACjB,CAAC,EAAE,EAAEA,OAAO,MAAM,CAAC,eAAe,EAAEA,OAAO,GAAG,EAAE;AAGpD,MAAMC,yBAEHC;IACU,UAAiC;QAC7C,OAAO;YACH,aAAa;gBAAC;aAAM;YACpB,gBAAgB;gBAAC;gBAAa;gBAAU;gBAAY;aAAS;QACjE;IACJ;IAEA,MAAa,KAAKF,MAAS,EAAqC;QAC5D,MAAMG,UAAU,IAAI,CAAC,aAAa,CAACH;QAEnC,MAAMI,SAAS,MAAM,IAAI,CAAC,KAAK,CAAC;YAC5B,cAAcL,mBAAmBC;YACjCG;QACJ;QACA,OAAO,IAAI,CAAC,cAAc,CAACC;IAC/B;IAEO,WAAWC,IAAe,EAAkC;QAC/D,MAAMC,OAAOD,KAAK,SAAS,CAAC,OAAO;QACnC,OAAO;YACH,cAAcN,mBAAmBM;YACjC,SAASC;QACb;IACJ;AACJ"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { IAuditLog } from "../../storage/types.js";
|
|
2
|
-
import { BaseAccessPattern } from "../../storage/accessPatterns/BaseAccessPattern.js";
|
|
3
|
-
import type { IAccessPatternCreateKeysResult, IAccessPatternHandles, IAccessPatternListResult } from "../../storage/abstractions/AccessPattern.js";
|
|
4
|
-
import type { IStorageListByAppCreatedByParams } from "../../storage/abstractions/Storage.js";
|
|
5
|
-
export declare class AppCreatedByAccessPattern<T extends IStorageListByAppCreatedByParams = IStorageListByAppCreatedByParams> extends BaseAccessPattern<T> {
|
|
6
|
-
handles(): IAccessPatternHandles;
|
|
7
|
-
list(params: T): Promise<IAccessPatternListResult>;
|
|
8
|
-
createKeys(item: IAuditLog): IAccessPatternCreateKeysResult;
|
|
9
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { BaseAccessPattern } from "./BaseAccessPattern.js";
|
|
2
|
-
const createPartitionKey = (params)=>`T#${params.tenant}#AUDIT_LOG#APP#${params.app}#CREATEDBY#${params.createdBy}`;
|
|
3
|
-
class AppCreatedByAccessPattern extends BaseAccessPattern {
|
|
4
|
-
handles() {
|
|
5
|
-
return {
|
|
6
|
-
mustInclude: [
|
|
7
|
-
"app",
|
|
8
|
-
"createdBy"
|
|
9
|
-
],
|
|
10
|
-
mustNotInclude: [
|
|
11
|
-
"action",
|
|
12
|
-
"entityId",
|
|
13
|
-
"entity"
|
|
14
|
-
]
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
async list(params) {
|
|
18
|
-
const options = this.createOptions(params);
|
|
19
|
-
const result = await this.query({
|
|
20
|
-
partitionKey: createPartitionKey(params),
|
|
21
|
-
options
|
|
22
|
-
});
|
|
23
|
-
return this.populateResult(result);
|
|
24
|
-
}
|
|
25
|
-
createKeys(item) {
|
|
26
|
-
const time = item.createdOn.getTime();
|
|
27
|
-
return {
|
|
28
|
-
partitionKey: createPartitionKey({
|
|
29
|
-
...item,
|
|
30
|
-
createdBy: item.createdBy.id
|
|
31
|
-
}),
|
|
32
|
-
sortKey: time
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export { AppCreatedByAccessPattern };
|
|
37
|
-
|
|
38
|
-
//# sourceMappingURL=AppCreatedByAccessPattern.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/accessPatterns/AppCreatedByAccessPattern.js","sources":["../../../src/storage/accessPatterns/AppCreatedByAccessPattern.ts"],"sourcesContent":["import type { IAuditLog } from \"~/storage/types.js\";\nimport { BaseAccessPattern } from \"~/storage/accessPatterns/BaseAccessPattern.js\";\nimport type {\n IAccessPatternCreateKeysResult,\n IAccessPatternHandles,\n IAccessPatternListResult\n} from \"~/storage/abstractions/AccessPattern.js\";\nimport type { IStorageListByAppCreatedByParams } from \"~/storage/abstractions/Storage.js\";\n\ninterface ICreatePartitionKeyParams {\n tenant: string;\n app: string;\n createdBy: string;\n}\n\nconst createPartitionKey = (params: ICreatePartitionKeyParams) => {\n return `T#${params.tenant}#AUDIT_LOG#APP#${params.app}#CREATEDBY#${params.createdBy}`;\n};\n\nexport class AppCreatedByAccessPattern<\n T extends IStorageListByAppCreatedByParams = IStorageListByAppCreatedByParams\n> extends BaseAccessPattern<T> {\n public override handles(): IAccessPatternHandles {\n return {\n mustInclude: [\"app\", \"createdBy\"],\n mustNotInclude: [\"action\", \"entityId\", \"entity\"]\n };\n }\n\n public async list(params: T): Promise<IAccessPatternListResult> {\n const options = this.createOptions(params);\n\n const result = await this.query({\n partitionKey: createPartitionKey(params),\n options\n });\n return this.populateResult(result);\n }\n\n public createKeys(item: IAuditLog): IAccessPatternCreateKeysResult {\n const time = item.createdOn.getTime();\n\n return {\n partitionKey: createPartitionKey({\n ...item,\n createdBy: item.createdBy.id\n }),\n sortKey: time\n };\n }\n}\n"],"names":["createPartitionKey","params","AppCreatedByAccessPattern","BaseAccessPattern","options","result","item","time"],"mappings":";AAeA,MAAMA,qBAAqB,CAACC,SACjB,CAAC,EAAE,EAAEA,OAAO,MAAM,CAAC,eAAe,EAAEA,OAAO,GAAG,CAAC,WAAW,EAAEA,OAAO,SAAS,EAAE;AAGlF,MAAMC,kCAEHC;IACU,UAAiC;QAC7C,OAAO;YACH,aAAa;gBAAC;gBAAO;aAAY;YACjC,gBAAgB;gBAAC;gBAAU;gBAAY;aAAS;QACpD;IACJ;IAEA,MAAa,KAAKF,MAAS,EAAqC;QAC5D,MAAMG,UAAU,IAAI,CAAC,aAAa,CAACH;QAEnC,MAAMI,SAAS,MAAM,IAAI,CAAC,KAAK,CAAC;YAC5B,cAAcL,mBAAmBC;YACjCG;QACJ;QACA,OAAO,IAAI,CAAC,cAAc,CAACC;IAC/B;IAEO,WAAWC,IAAe,EAAkC;QAC/D,MAAMC,OAAOD,KAAK,SAAS,CAAC,OAAO;QAEnC,OAAO;YACH,cAAcN,mBAAmB;gBAC7B,GAAGM,IAAI;gBACP,WAAWA,KAAK,SAAS,CAAC,EAAE;YAChC;YACA,SAASC;QACb;IACJ;AACJ"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { IAuditLog } from "../../storage/types.js";
|
|
2
|
-
import type { IStorageListByAppEntityParams } from "../../storage/abstractions/Storage.js";
|
|
3
|
-
import { BaseAccessPattern } from "../../storage/accessPatterns/BaseAccessPattern.js";
|
|
4
|
-
import type { IAccessPatternCreateKeysResult, IAccessPatternHandles, IAccessPatternListResult } from "../../storage/abstractions/AccessPattern.js";
|
|
5
|
-
export declare class AppEntityAccessPattern<T extends IStorageListByAppEntityParams = IStorageListByAppEntityParams> extends BaseAccessPattern<T> {
|
|
6
|
-
handles(): IAccessPatternHandles;
|
|
7
|
-
list(params: T): Promise<IAccessPatternListResult>;
|
|
8
|
-
createKeys(item: IAuditLog): IAccessPatternCreateKeysResult;
|
|
9
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { BaseAccessPattern } from "./BaseAccessPattern.js";
|
|
2
|
-
const createPartitionKey = (params)=>`T#${params.tenant}#AUDIT_LOG#APP#${params.app}#ENTITY#${params.entity}`;
|
|
3
|
-
class AppEntityAccessPattern extends BaseAccessPattern {
|
|
4
|
-
handles() {
|
|
5
|
-
return {
|
|
6
|
-
mustInclude: [
|
|
7
|
-
"app",
|
|
8
|
-
"entity"
|
|
9
|
-
],
|
|
10
|
-
mustNotInclude: [
|
|
11
|
-
"createdBy",
|
|
12
|
-
"action",
|
|
13
|
-
"entityId"
|
|
14
|
-
]
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
async list(params) {
|
|
18
|
-
const options = this.createOptions(params);
|
|
19
|
-
const result = await this.query({
|
|
20
|
-
partitionKey: createPartitionKey(params),
|
|
21
|
-
options
|
|
22
|
-
});
|
|
23
|
-
return this.populateResult(result);
|
|
24
|
-
}
|
|
25
|
-
createKeys(item) {
|
|
26
|
-
const time = item.createdOn.getTime();
|
|
27
|
-
return {
|
|
28
|
-
partitionKey: createPartitionKey(item),
|
|
29
|
-
sortKey: time
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export { AppEntityAccessPattern };
|
|
34
|
-
|
|
35
|
-
//# sourceMappingURL=AppEntityAccessPattern.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/accessPatterns/AppEntityAccessPattern.js","sources":["../../../src/storage/accessPatterns/AppEntityAccessPattern.ts"],"sourcesContent":["import type { IAuditLog } from \"~/storage/types.js\";\nimport type { IStorageListByAppEntityParams } from \"~/storage/abstractions/Storage.js\";\nimport { BaseAccessPattern } from \"~/storage/accessPatterns/BaseAccessPattern.js\";\nimport type {\n IAccessPatternCreateKeysResult,\n IAccessPatternHandles,\n IAccessPatternListResult\n} from \"~/storage/abstractions/AccessPattern.js\";\n\ninterface ICreatePartitionKeyParams {\n tenant: string;\n app: string;\n entity: string;\n}\n\nconst createPartitionKey = (params: ICreatePartitionKeyParams) => {\n return `T#${params.tenant}#AUDIT_LOG#APP#${params.app}#ENTITY#${params.entity}`;\n};\nexport class AppEntityAccessPattern<\n T extends IStorageListByAppEntityParams = IStorageListByAppEntityParams\n> extends BaseAccessPattern<T> {\n public override handles(): IAccessPatternHandles {\n return {\n mustInclude: [\"app\", \"entity\"],\n mustNotInclude: [\"createdBy\", \"action\", \"entityId\"]\n };\n }\n\n public async list(params: T): Promise<IAccessPatternListResult> {\n const options = this.createOptions(params);\n\n const result = await this.query({\n partitionKey: createPartitionKey(params),\n options\n });\n return this.populateResult(result);\n }\n\n public createKeys(item: IAuditLog): IAccessPatternCreateKeysResult {\n const time = item.createdOn.getTime();\n\n return {\n partitionKey: createPartitionKey(item),\n sortKey: time\n };\n }\n}\n"],"names":["createPartitionKey","params","AppEntityAccessPattern","BaseAccessPattern","options","result","item","time"],"mappings":";AAeA,MAAMA,qBAAqB,CAACC,SACjB,CAAC,EAAE,EAAEA,OAAO,MAAM,CAAC,eAAe,EAAEA,OAAO,GAAG,CAAC,QAAQ,EAAEA,OAAO,MAAM,EAAE;AAE5E,MAAMC,+BAEHC;IACU,UAAiC;QAC7C,OAAO;YACH,aAAa;gBAAC;gBAAO;aAAS;YAC9B,gBAAgB;gBAAC;gBAAa;gBAAU;aAAW;QACvD;IACJ;IAEA,MAAa,KAAKF,MAAS,EAAqC;QAC5D,MAAMG,UAAU,IAAI,CAAC,aAAa,CAACH;QAEnC,MAAMI,SAAS,MAAM,IAAI,CAAC,KAAK,CAAC;YAC5B,cAAcL,mBAAmBC;YACjCG;QACJ;QACA,OAAO,IAAI,CAAC,cAAc,CAACC;IAC/B;IAEO,WAAWC,IAAe,EAAkC;QAC/D,MAAMC,OAAOD,KAAK,SAAS,CAAC,OAAO;QAEnC,OAAO;YACH,cAAcN,mBAAmBM;YACjC,SAASC;QACb;IACJ;AACJ"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { IAuditLog } from "../../storage/types.js";
|
|
2
|
-
import type { IStorageListByAppEntityActionParams } from "../../storage/abstractions/Storage.js";
|
|
3
|
-
import { BaseAccessPattern } from "../../storage/accessPatterns/BaseAccessPattern.js";
|
|
4
|
-
import type { IAccessPatternCreateKeysResult, IAccessPatternHandles, IAccessPatternListResult } from "../../storage/abstractions/AccessPattern.js";
|
|
5
|
-
export declare class AppEntityActionAccessPattern<T extends IStorageListByAppEntityActionParams = IStorageListByAppEntityActionParams> extends BaseAccessPattern<T> {
|
|
6
|
-
handles(): IAccessPatternHandles;
|
|
7
|
-
list(params: T): Promise<IAccessPatternListResult>;
|
|
8
|
-
createKeys(item: IAuditLog): IAccessPatternCreateKeysResult;
|
|
9
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { BaseAccessPattern } from "./BaseAccessPattern.js";
|
|
2
|
-
const createPartitionKey = (params)=>`T#${params.tenant}#AUDIT_LOG#APP#${params.app}#ENTITY#${params.entity}#ACTION#${params.action}`;
|
|
3
|
-
class AppEntityActionAccessPattern extends BaseAccessPattern {
|
|
4
|
-
handles() {
|
|
5
|
-
return {
|
|
6
|
-
mustInclude: [
|
|
7
|
-
"app",
|
|
8
|
-
"entity",
|
|
9
|
-
"action"
|
|
10
|
-
],
|
|
11
|
-
mustNotInclude: [
|
|
12
|
-
"entityId",
|
|
13
|
-
"createdBy"
|
|
14
|
-
]
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
async list(params) {
|
|
18
|
-
const options = this.createOptions(params);
|
|
19
|
-
const result = await this.query({
|
|
20
|
-
partitionKey: createPartitionKey(params),
|
|
21
|
-
options
|
|
22
|
-
});
|
|
23
|
-
return this.populateResult(result);
|
|
24
|
-
}
|
|
25
|
-
createKeys(item) {
|
|
26
|
-
const time = item.createdOn.getTime();
|
|
27
|
-
return {
|
|
28
|
-
partitionKey: createPartitionKey(item),
|
|
29
|
-
sortKey: time
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export { AppEntityActionAccessPattern };
|
|
34
|
-
|
|
35
|
-
//# sourceMappingURL=AppEntityActionAccessPattern.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/accessPatterns/AppEntityActionAccessPattern.js","sources":["../../../src/storage/accessPatterns/AppEntityActionAccessPattern.ts"],"sourcesContent":["import type { IAuditLog } from \"~/storage/types.js\";\nimport type { IStorageListByAppEntityActionParams } from \"~/storage/abstractions/Storage.js\";\nimport { BaseAccessPattern } from \"~/storage/accessPatterns/BaseAccessPattern.js\";\nimport type {\n IAccessPatternCreateKeysResult,\n IAccessPatternHandles,\n IAccessPatternListResult\n} from \"~/storage/abstractions/AccessPattern.js\";\n\ninterface ICreatePartitionKeyParams {\n tenant: string;\n app: string;\n entity: string;\n action: string;\n}\n\nconst createPartitionKey = (params: ICreatePartitionKeyParams) => {\n return `T#${params.tenant}#AUDIT_LOG#APP#${params.app}#ENTITY#${params.entity}#ACTION#${params.action}`;\n};\n\nexport class AppEntityActionAccessPattern<\n T extends IStorageListByAppEntityActionParams = IStorageListByAppEntityActionParams\n> extends BaseAccessPattern<T> {\n public override handles(): IAccessPatternHandles {\n return {\n mustInclude: [\"app\", \"entity\", \"action\"],\n mustNotInclude: [\"entityId\", \"createdBy\"]\n };\n }\n\n public async list(params: T): Promise<IAccessPatternListResult> {\n const options = this.createOptions(params);\n\n const result = await this.query({\n partitionKey: createPartitionKey(params),\n options\n });\n return this.populateResult(result);\n }\n\n public createKeys(item: IAuditLog): IAccessPatternCreateKeysResult {\n const time = item.createdOn.getTime();\n\n return {\n partitionKey: createPartitionKey(item),\n sortKey: time\n };\n }\n}\n"],"names":["createPartitionKey","params","AppEntityActionAccessPattern","BaseAccessPattern","options","result","item","time"],"mappings":";AAgBA,MAAMA,qBAAqB,CAACC,SACjB,CAAC,EAAE,EAAEA,OAAO,MAAM,CAAC,eAAe,EAAEA,OAAO,GAAG,CAAC,QAAQ,EAAEA,OAAO,MAAM,CAAC,QAAQ,EAAEA,OAAO,MAAM,EAAE;AAGpG,MAAMC,qCAEHC;IACU,UAAiC;QAC7C,OAAO;YACH,aAAa;gBAAC;gBAAO;gBAAU;aAAS;YACxC,gBAAgB;gBAAC;gBAAY;aAAY;QAC7C;IACJ;IAEA,MAAa,KAAKF,MAAS,EAAqC;QAC5D,MAAMG,UAAU,IAAI,CAAC,aAAa,CAACH;QAEnC,MAAMI,SAAS,MAAM,IAAI,CAAC,KAAK,CAAC;YAC5B,cAAcL,mBAAmBC;YACjCG;QACJ;QACA,OAAO,IAAI,CAAC,cAAc,CAACC;IAC/B;IAEO,WAAWC,IAAe,EAAkC;QAC/D,MAAMC,OAAOD,KAAK,SAAS,CAAC,OAAO;QAEnC,OAAO;YACH,cAAcN,mBAAmBM;YACjC,SAASC;QACb;IACJ;AACJ"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { IAuditLog } from "../../storage/types.js";
|
|
2
|
-
import type { IStorageListByAppEntityActionCreatedByParams } from "../../storage/abstractions/Storage.js";
|
|
3
|
-
import { BaseAccessPattern } from "../../storage/accessPatterns/BaseAccessPattern.js";
|
|
4
|
-
import type { IAccessPatternCreateKeysResult, IAccessPatternHandles, IAccessPatternListResult } from "../../storage/abstractions/AccessPattern.js";
|
|
5
|
-
export declare class AppEntityActionCreatedByAccessPattern<T extends IStorageListByAppEntityActionCreatedByParams = IStorageListByAppEntityActionCreatedByParams> extends BaseAccessPattern<T> {
|
|
6
|
-
handles(): IAccessPatternHandles;
|
|
7
|
-
list(params: T): Promise<IAccessPatternListResult>;
|
|
8
|
-
createKeys(item: IAuditLog): IAccessPatternCreateKeysResult;
|
|
9
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { BaseAccessPattern } from "./BaseAccessPattern.js";
|
|
2
|
-
const createPartitionKey = (params)=>`T#${params.tenant}#AUDIT_LOG#APP#${params.app}#ENTITY#${params.entity}#ACTION#${params.action}#CREATEDBY#${params.createdBy}`;
|
|
3
|
-
class AppEntityActionCreatedByAccessPattern extends BaseAccessPattern {
|
|
4
|
-
handles() {
|
|
5
|
-
return {
|
|
6
|
-
mustInclude: [
|
|
7
|
-
"app",
|
|
8
|
-
"action",
|
|
9
|
-
"entity",
|
|
10
|
-
"createdBy"
|
|
11
|
-
],
|
|
12
|
-
mustNotInclude: [
|
|
13
|
-
"entityId"
|
|
14
|
-
]
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
async list(params) {
|
|
18
|
-
const options = this.createOptions(params);
|
|
19
|
-
const result = await this.query({
|
|
20
|
-
partitionKey: createPartitionKey(params),
|
|
21
|
-
options
|
|
22
|
-
});
|
|
23
|
-
return this.populateResult(result);
|
|
24
|
-
}
|
|
25
|
-
createKeys(item) {
|
|
26
|
-
const time = item.createdOn.getTime();
|
|
27
|
-
return {
|
|
28
|
-
partitionKey: createPartitionKey({
|
|
29
|
-
...item,
|
|
30
|
-
createdBy: item.createdBy.id
|
|
31
|
-
}),
|
|
32
|
-
sortKey: time
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export { AppEntityActionCreatedByAccessPattern };
|
|
37
|
-
|
|
38
|
-
//# sourceMappingURL=AppEntityActionCreatedByAccessPattern.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/accessPatterns/AppEntityActionCreatedByAccessPattern.js","sources":["../../../src/storage/accessPatterns/AppEntityActionCreatedByAccessPattern.ts"],"sourcesContent":["import type { IAuditLog } from \"~/storage/types.js\";\nimport type { IStorageListByAppEntityActionCreatedByParams } from \"~/storage/abstractions/Storage.js\";\nimport { BaseAccessPattern } from \"~/storage/accessPatterns/BaseAccessPattern.js\";\nimport type {\n IAccessPatternCreateKeysResult,\n IAccessPatternHandles,\n IAccessPatternListResult\n} from \"~/storage/abstractions/AccessPattern.js\";\n\ninterface ICreatePartitionKeyParams {\n tenant: string;\n app: string;\n action: string;\n entity: string;\n createdBy: string;\n}\n\nconst createPartitionKey = (params: ICreatePartitionKeyParams) => {\n return `T#${params.tenant}#AUDIT_LOG#APP#${params.app}#ENTITY#${params.entity}#ACTION#${params.action}#CREATEDBY#${params.createdBy}`;\n};\n\nexport class AppEntityActionCreatedByAccessPattern<\n T extends IStorageListByAppEntityActionCreatedByParams =\n IStorageListByAppEntityActionCreatedByParams\n> extends BaseAccessPattern<T> {\n public override handles(): IAccessPatternHandles {\n return {\n mustInclude: [\"app\", \"action\", \"entity\", \"createdBy\"],\n mustNotInclude: [\"entityId\"]\n };\n }\n\n public async list(params: T): Promise<IAccessPatternListResult> {\n const options = this.createOptions(params);\n\n const result = await this.query({\n partitionKey: createPartitionKey(params),\n options\n });\n return this.populateResult(result);\n }\n\n public createKeys(item: IAuditLog): IAccessPatternCreateKeysResult {\n const time = item.createdOn.getTime();\n\n return {\n partitionKey: createPartitionKey({\n ...item,\n createdBy: item.createdBy.id\n }),\n sortKey: time\n };\n }\n}\n"],"names":["createPartitionKey","params","AppEntityActionCreatedByAccessPattern","BaseAccessPattern","options","result","item","time"],"mappings":";AAiBA,MAAMA,qBAAqB,CAACC,SACjB,CAAC,EAAE,EAAEA,OAAO,MAAM,CAAC,eAAe,EAAEA,OAAO,GAAG,CAAC,QAAQ,EAAEA,OAAO,MAAM,CAAC,QAAQ,EAAEA,OAAO,MAAM,CAAC,WAAW,EAAEA,OAAO,SAAS,EAAE;AAGlI,MAAMC,8CAGHC;IACU,UAAiC;QAC7C,OAAO;YACH,aAAa;gBAAC;gBAAO;gBAAU;gBAAU;aAAY;YACrD,gBAAgB;gBAAC;aAAW;QAChC;IACJ;IAEA,MAAa,KAAKF,MAAS,EAAqC;QAC5D,MAAMG,UAAU,IAAI,CAAC,aAAa,CAACH;QAEnC,MAAMI,SAAS,MAAM,IAAI,CAAC,KAAK,CAAC;YAC5B,cAAcL,mBAAmBC;YACjCG;QACJ;QACA,OAAO,IAAI,CAAC,cAAc,CAACC;IAC/B;IAEO,WAAWC,IAAe,EAAkC;QAC/D,MAAMC,OAAOD,KAAK,SAAS,CAAC,OAAO;QAEnC,OAAO;YACH,cAAcN,mBAAmB;gBAC7B,GAAGM,IAAI;gBACP,WAAWA,KAAK,SAAS,CAAC,EAAE;YAChC;YACA,SAASC;QACb;IACJ;AACJ"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { IAuditLog } from "../../storage/types.js";
|
|
2
|
-
import type { IStorageListByAppEntityCreatedByParams } from "../../storage/abstractions/Storage.js";
|
|
3
|
-
import { BaseAccessPattern } from "../../storage/accessPatterns/BaseAccessPattern.js";
|
|
4
|
-
import type { IAccessPatternCreateKeysResult, IAccessPatternHandles, IAccessPatternListResult } from "../../storage/abstractions/AccessPattern.js";
|
|
5
|
-
export declare class AppEntityCreatedByAccessPattern<T extends IStorageListByAppEntityCreatedByParams = IStorageListByAppEntityCreatedByParams> extends BaseAccessPattern<T> {
|
|
6
|
-
handles(): IAccessPatternHandles;
|
|
7
|
-
list(params: T): Promise<IAccessPatternListResult>;
|
|
8
|
-
createKeys(item: IAuditLog): IAccessPatternCreateKeysResult;
|
|
9
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { BaseAccessPattern } from "./BaseAccessPattern.js";
|
|
2
|
-
const createPartitionKey = (params)=>`T#${params.tenant}#AUDIT_LOG#APP#${params.app}#ENTITY#${params.entity}#CREATEDBY#${params.createdBy}`;
|
|
3
|
-
class AppEntityCreatedByAccessPattern extends BaseAccessPattern {
|
|
4
|
-
handles() {
|
|
5
|
-
return {
|
|
6
|
-
mustInclude: [
|
|
7
|
-
"app",
|
|
8
|
-
"createdBy",
|
|
9
|
-
"entity"
|
|
10
|
-
],
|
|
11
|
-
mustNotInclude: [
|
|
12
|
-
"action",
|
|
13
|
-
"entityId"
|
|
14
|
-
]
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
async list(params) {
|
|
18
|
-
const options = this.createOptions(params);
|
|
19
|
-
const result = await this.query({
|
|
20
|
-
partitionKey: createPartitionKey(params),
|
|
21
|
-
options
|
|
22
|
-
});
|
|
23
|
-
return this.populateResult(result);
|
|
24
|
-
}
|
|
25
|
-
createKeys(item) {
|
|
26
|
-
const time = item.createdOn.getTime();
|
|
27
|
-
return {
|
|
28
|
-
partitionKey: createPartitionKey({
|
|
29
|
-
...item,
|
|
30
|
-
createdBy: item.createdBy.id
|
|
31
|
-
}),
|
|
32
|
-
sortKey: time
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export { AppEntityCreatedByAccessPattern };
|
|
37
|
-
|
|
38
|
-
//# sourceMappingURL=AppEntityCreatedByAccessPattern.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/accessPatterns/AppEntityCreatedByAccessPattern.js","sources":["../../../src/storage/accessPatterns/AppEntityCreatedByAccessPattern.ts"],"sourcesContent":["import type { IAuditLog } from \"~/storage/types.js\";\nimport type { IStorageListByAppEntityCreatedByParams } from \"~/storage/abstractions/Storage.js\";\nimport { BaseAccessPattern } from \"~/storage/accessPatterns/BaseAccessPattern.js\";\nimport type {\n IAccessPatternCreateKeysResult,\n IAccessPatternHandles,\n IAccessPatternListResult\n} from \"~/storage/abstractions/AccessPattern.js\";\n\ninterface ICreatePartitionKeyParams {\n tenant: string;\n app: string;\n createdBy: string;\n entity: string;\n}\n\nconst createPartitionKey = (params: ICreatePartitionKeyParams) => {\n return `T#${params.tenant}#AUDIT_LOG#APP#${params.app}#ENTITY#${params.entity}#CREATEDBY#${params.createdBy}`;\n};\n\nexport class AppEntityCreatedByAccessPattern<\n T extends IStorageListByAppEntityCreatedByParams = IStorageListByAppEntityCreatedByParams\n> extends BaseAccessPattern<T> {\n public override handles(): IAccessPatternHandles {\n return {\n mustInclude: [\"app\", \"createdBy\", \"entity\"],\n mustNotInclude: [\"action\", \"entityId\"]\n };\n }\n\n public async list(params: T): Promise<IAccessPatternListResult> {\n const options = this.createOptions(params);\n\n const result = await this.query({\n partitionKey: createPartitionKey(params),\n options\n });\n return this.populateResult(result);\n }\n\n public createKeys(item: IAuditLog): IAccessPatternCreateKeysResult {\n const time = item.createdOn.getTime();\n\n return {\n partitionKey: createPartitionKey({\n ...item,\n createdBy: item.createdBy.id\n }),\n sortKey: time\n };\n }\n}\n"],"names":["createPartitionKey","params","AppEntityCreatedByAccessPattern","BaseAccessPattern","options","result","item","time"],"mappings":";AAgBA,MAAMA,qBAAqB,CAACC,SACjB,CAAC,EAAE,EAAEA,OAAO,MAAM,CAAC,eAAe,EAAEA,OAAO,GAAG,CAAC,QAAQ,EAAEA,OAAO,MAAM,CAAC,WAAW,EAAEA,OAAO,SAAS,EAAE;AAG1G,MAAMC,wCAEHC;IACU,UAAiC;QAC7C,OAAO;YACH,aAAa;gBAAC;gBAAO;gBAAa;aAAS;YAC3C,gBAAgB;gBAAC;gBAAU;aAAW;QAC1C;IACJ;IAEA,MAAa,KAAKF,MAAS,EAAqC;QAC5D,MAAMG,UAAU,IAAI,CAAC,aAAa,CAACH;QAEnC,MAAMI,SAAS,MAAM,IAAI,CAAC,KAAK,CAAC;YAC5B,cAAcL,mBAAmBC;YACjCG;QACJ;QACA,OAAO,IAAI,CAAC,cAAc,CAACC;IAC/B;IAEO,WAAWC,IAAe,EAAkC;QAC/D,MAAMC,OAAOD,KAAK,SAAS,CAAC,OAAO;QAEnC,OAAO;YACH,cAAcN,mBAAmB;gBAC7B,GAAGM,IAAI;gBACP,WAAWA,KAAK,SAAS,CAAC,EAAE;YAChC;YACA,SAASC;QACb;IACJ;AACJ"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { IAuditLog, IIndexStorageItem, IStorageItem } from "../../storage/types.js";
|
|
2
|
-
import type { IStorageListParams } from "../abstractions/Storage.js";
|
|
3
|
-
import type { IAccessPattern, IAccessPatternCreateKeysResult, IAccessPatternHandles, IAccessPatternListResult } from "../abstractions/AccessPattern.js";
|
|
4
|
-
import type { AuditLogsEntity } from "../../storage/entity.js";
|
|
5
|
-
import type { IEntityQueryAllParams, IEntityQueryPerPageResult } from "@webiny/db-dynamodb";
|
|
6
|
-
export interface ICreateOptionsParams {
|
|
7
|
-
limit?: number;
|
|
8
|
-
sort?: "ASC" | "DESC";
|
|
9
|
-
after?: string;
|
|
10
|
-
createdOn_gte?: Date;
|
|
11
|
-
createdOn_lte?: Date;
|
|
12
|
-
}
|
|
13
|
-
export interface IBaseAccessPatternParams {
|
|
14
|
-
index: string | undefined;
|
|
15
|
-
entity: AuditLogsEntity;
|
|
16
|
-
}
|
|
17
|
-
export interface IAccessPatternQueryParams {
|
|
18
|
-
partitionKey: string;
|
|
19
|
-
options: IEntityQueryAllParams["options"];
|
|
20
|
-
}
|
|
21
|
-
export declare abstract class BaseAccessPattern<T> implements IAccessPattern<T> {
|
|
22
|
-
readonly index: string | undefined;
|
|
23
|
-
protected readonly entity: AuditLogsEntity;
|
|
24
|
-
constructor(params: IBaseAccessPatternParams);
|
|
25
|
-
abstract handles(): IAccessPatternHandles;
|
|
26
|
-
canHandle(params: IStorageListParams): boolean;
|
|
27
|
-
protected query<T extends IStorageItem = IStorageItem>(params: IAccessPatternQueryParams): Promise<import("@webiny/db-dynamodb").IQueryPageResponse<T>>;
|
|
28
|
-
protected populateResult(input: Awaited<IEntityQueryPerPageResult<IIndexStorageItem>>): Promise<IEntityQueryPerPageResult<IStorageItem>>;
|
|
29
|
-
abstract list(params: T): Promise<IAccessPatternListResult>;
|
|
30
|
-
abstract createKeys(item: IAuditLog): IAccessPatternCreateKeysResult;
|
|
31
|
-
protected createOptions(params: ICreateOptionsParams): IEntityQueryAllParams["options"];
|
|
32
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { createStartKey } from "../startKey.js";
|
|
2
|
-
const toGteTime = (date)=>{
|
|
3
|
-
if (!date) return 0;
|
|
4
|
-
return date.getTime();
|
|
5
|
-
};
|
|
6
|
-
const toLteTime = (date)=>{
|
|
7
|
-
if (!date) return Date.now();
|
|
8
|
-
return date.getTime();
|
|
9
|
-
};
|
|
10
|
-
class BaseAccessPattern {
|
|
11
|
-
constructor(params){
|
|
12
|
-
this.index = params.index;
|
|
13
|
-
this.entity = params.entity;
|
|
14
|
-
}
|
|
15
|
-
canHandle(params) {
|
|
16
|
-
const handles = this.handles();
|
|
17
|
-
for (const key of handles.mustInclude)if (!params[key]) return false;
|
|
18
|
-
for (const key of handles.mustNotInclude)if (!!params[key]) return false;
|
|
19
|
-
if (!handles.shouldInclude?.length) return true;
|
|
20
|
-
for (const key of handles.shouldInclude)if (!!params[key]) return true;
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
async query(params) {
|
|
24
|
-
return this.entity.queryPerPage({
|
|
25
|
-
partitionKey: params.partitionKey,
|
|
26
|
-
options: params.options
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
async populateResult(input) {
|
|
30
|
-
const reader = this.entity.createEntityReader({
|
|
31
|
-
read: input.items.map((item)=>({
|
|
32
|
-
PK: item.PK,
|
|
33
|
-
SK: item.SK
|
|
34
|
-
}))
|
|
35
|
-
});
|
|
36
|
-
const result = await reader.execute();
|
|
37
|
-
return {
|
|
38
|
-
...input,
|
|
39
|
-
items: input.items.map((item)=>result.find((i)=>i.PK === item.PK && i.SK === item.SK)).filter((item)=>!!item)
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
createOptions(params) {
|
|
43
|
-
const options = {
|
|
44
|
-
limit: params.limit || 25,
|
|
45
|
-
startKey: createStartKey({
|
|
46
|
-
after: params.after
|
|
47
|
-
}),
|
|
48
|
-
reverse: "DESC" === params.sort,
|
|
49
|
-
index: this.index
|
|
50
|
-
};
|
|
51
|
-
if (params.createdOn_lte || params.createdOn_gte) options.between = [
|
|
52
|
-
toGteTime(params.createdOn_gte),
|
|
53
|
-
toLteTime(params.createdOn_lte)
|
|
54
|
-
];
|
|
55
|
-
return options;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
export { BaseAccessPattern };
|
|
59
|
-
|
|
60
|
-
//# sourceMappingURL=BaseAccessPattern.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/accessPatterns/BaseAccessPattern.js","sources":["../../../src/storage/accessPatterns/BaseAccessPattern.ts"],"sourcesContent":["import type { IAuditLog, IIndexStorageItem, IStorageItem } from \"~/storage/types.js\";\nimport { createStartKey } from \"~/storage/startKey.js\";\nimport type { IStorageListParams } from \"../abstractions/Storage.js\";\nimport type {\n IAccessPattern,\n IAccessPatternCreateKeysResult,\n IAccessPatternHandles,\n IAccessPatternListResult\n} from \"../abstractions/AccessPattern.js\";\nimport type { AuditLogsEntity } from \"~/storage/entity.js\";\nimport type { IEntityQueryAllParams, IEntityQueryPerPageResult } from \"@webiny/db-dynamodb\";\n\nconst toGteTime = (date?: Date): number => {\n if (!date) {\n return 0;\n }\n return date.getTime();\n};\nconst toLteTime = (date?: Date): number => {\n if (!date) {\n return Date.now();\n }\n return date.getTime();\n};\n\nexport interface ICreateOptionsParams {\n limit?: number;\n sort?: \"ASC\" | \"DESC\";\n after?: string;\n createdOn_gte?: Date;\n createdOn_lte?: Date;\n}\n\nexport interface IBaseAccessPatternParams {\n index: string | undefined;\n entity: AuditLogsEntity;\n}\n\nexport interface IAccessPatternQueryParams {\n partitionKey: string;\n options: IEntityQueryAllParams[\"options\"];\n}\n\nexport abstract class BaseAccessPattern<T> implements IAccessPattern<T> {\n public readonly index;\n protected readonly entity;\n\n public constructor(params: IBaseAccessPatternParams) {\n this.index = params.index;\n this.entity = params.entity;\n }\n\n public abstract handles(): IAccessPatternHandles;\n\n public canHandle(params: IStorageListParams): boolean {\n const handles = this.handles();\n for (const key of handles.mustInclude) {\n if (!params[key]) {\n return false;\n }\n }\n for (const key of handles.mustNotInclude) {\n if (!!params[key]) {\n return false;\n }\n }\n if (!handles.shouldInclude?.length) {\n return true;\n }\n\n for (const key of handles.shouldInclude) {\n if (!!params[key]) {\n return true;\n }\n }\n return false;\n }\n\n protected async query<T extends IStorageItem = IStorageItem>(\n params: IAccessPatternQueryParams\n ) {\n return this.entity.queryPerPage<T>({\n partitionKey: params.partitionKey,\n options: params.options\n });\n }\n\n protected async populateResult(\n input: Awaited<IEntityQueryPerPageResult<IIndexStorageItem>>\n ): Promise<IEntityQueryPerPageResult<IStorageItem>> {\n const reader = this.entity.createEntityReader({\n read: input.items.map(item => {\n return {\n PK: item.PK,\n SK: item.SK\n };\n })\n });\n const result = await reader.execute();\n\n return {\n ...input,\n items: input.items\n .map(item => {\n return result.find(i => {\n return i.PK === item.PK && i.SK === item.SK;\n });\n })\n .filter((item): item is IStorageItem => !!item)\n };\n }\n\n public abstract list(params: T): Promise<IAccessPatternListResult>;\n public abstract createKeys(item: IAuditLog): IAccessPatternCreateKeysResult;\n\n protected createOptions(params: ICreateOptionsParams): IEntityQueryAllParams[\"options\"] {\n const options: IEntityQueryAllParams[\"options\"] = {\n limit: params.limit || 25,\n // @ts-expect-error\n startKey: createStartKey({\n after: params.after\n }),\n reverse: params.sort === \"DESC\",\n index: this.index\n };\n\n if (params.createdOn_lte || params.createdOn_gte) {\n options!.between = [toGteTime(params.createdOn_gte), toLteTime(params.createdOn_lte)];\n }\n\n return options;\n }\n}\n"],"names":["toGteTime","date","toLteTime","Date","BaseAccessPattern","params","handles","key","input","reader","item","result","i","options","createStartKey"],"mappings":";AAYA,MAAMA,YAAY,CAACC;IACf,IAAI,CAACA,MACD,OAAO;IAEX,OAAOA,KAAK,OAAO;AACvB;AACA,MAAMC,YAAY,CAACD;IACf,IAAI,CAACA,MACD,OAAOE,KAAK,GAAG;IAEnB,OAAOF,KAAK,OAAO;AACvB;AAoBO,MAAeG;IAIlB,YAAmBC,MAAgC,CAAE;QACjD,IAAI,CAAC,KAAK,GAAGA,OAAO,KAAK;QACzB,IAAI,CAAC,MAAM,GAAGA,OAAO,MAAM;IAC/B;IAIO,UAAUA,MAA0B,EAAW;QAClD,MAAMC,UAAU,IAAI,CAAC,OAAO;QAC5B,KAAK,MAAMC,OAAOD,QAAQ,WAAW,CACjC,IAAI,CAACD,MAAM,CAACE,IAAI,EACZ,OAAO;QAGf,KAAK,MAAMA,OAAOD,QAAQ,cAAc,CACpC,IAAI,CAAC,CAACD,MAAM,CAACE,IAAI,EACb,OAAO;QAGf,IAAI,CAACD,QAAQ,aAAa,EAAE,QACxB,OAAO;QAGX,KAAK,MAAMC,OAAOD,QAAQ,aAAa,CACnC,IAAI,CAAC,CAACD,MAAM,CAACE,IAAI,EACb,OAAO;QAGf,OAAO;IACX;IAEA,MAAgB,MACZF,MAAiC,EACnC;QACE,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAI;YAC/B,cAAcA,OAAO,YAAY;YACjC,SAASA,OAAO,OAAO;QAC3B;IACJ;IAEA,MAAgB,eACZG,KAA4D,EACZ;QAChD,MAAMC,SAAS,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;YAC1C,MAAMD,MAAM,KAAK,CAAC,GAAG,CAACE,CAAAA,OACX;oBACH,IAAIA,KAAK,EAAE;oBACX,IAAIA,KAAK,EAAE;gBACf;QAER;QACA,MAAMC,SAAS,MAAMF,OAAO,OAAO;QAEnC,OAAO;YACH,GAAGD,KAAK;YACR,OAAOA,MAAM,KAAK,CACb,GAAG,CAACE,CAAAA,OACMC,OAAO,IAAI,CAACC,CAAAA,IACRA,EAAE,EAAE,KAAKF,KAAK,EAAE,IAAIE,EAAE,EAAE,KAAKF,KAAK,EAAE,GAGlD,MAAM,CAAC,CAACA,OAA+B,CAAC,CAACA;QAClD;IACJ;IAKU,cAAcL,MAA4B,EAAoC;QACpF,MAAMQ,UAA4C;YAC9C,OAAOR,OAAO,KAAK,IAAI;YAEvB,UAAUS,eAAe;gBACrB,OAAOT,OAAO,KAAK;YACvB;YACA,SAASA,AAAgB,WAAhBA,OAAO,IAAI;YACpB,OAAO,IAAI,CAAC,KAAK;QACrB;QAEA,IAAIA,OAAO,aAAa,IAAIA,OAAO,aAAa,EAC5CQ,QAAS,OAAO,GAAG;YAACb,UAAUK,OAAO,aAAa;YAAGH,UAAUG,OAAO,aAAa;SAAE;QAGzF,OAAOQ;IACX;AACJ"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { IAuditLog } from "../../storage/types.js";
|
|
2
|
-
import { BaseAccessPattern } from "../../storage/accessPatterns/BaseAccessPattern.js";
|
|
3
|
-
import type { IAccessPatternCreateKeysResult, IAccessPatternHandles, IAccessPatternListResult } from "../../storage/abstractions/AccessPattern.js";
|
|
4
|
-
import type { IStorageListByCreatedByParams } from "../../storage/abstractions/Storage.js";
|
|
5
|
-
export declare class CreatedByAccessPattern<T extends IStorageListByCreatedByParams = IStorageListByCreatedByParams> extends BaseAccessPattern<T> {
|
|
6
|
-
handles(): IAccessPatternHandles;
|
|
7
|
-
list(params: T): Promise<IAccessPatternListResult>;
|
|
8
|
-
createKeys(item: IAuditLog): IAccessPatternCreateKeysResult;
|
|
9
|
-
}
|