@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
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { BaseAccessPattern } from "./BaseAccessPattern.js";
|
|
2
|
-
const createPartitionKey = (params)=>`T#${params.tenant}#AUDIT_LOG#CREATEDBY#${params.createdBy}`;
|
|
3
|
-
class CreatedByAccessPattern extends BaseAccessPattern {
|
|
4
|
-
handles() {
|
|
5
|
-
return {
|
|
6
|
-
mustInclude: [
|
|
7
|
-
"createdBy"
|
|
8
|
-
],
|
|
9
|
-
mustNotInclude: [
|
|
10
|
-
"app",
|
|
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 { CreatedByAccessPattern };
|
|
37
|
-
|
|
38
|
-
//# sourceMappingURL=CreatedByAccessPattern.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/accessPatterns/CreatedByAccessPattern.js","sources":["../../../src/storage/accessPatterns/CreatedByAccessPattern.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 { IStorageListByCreatedByParams } from \"~/storage/abstractions/Storage.js\";\n\ninterface ICreatePartitionKeyParams {\n tenant: string;\n createdBy: string;\n}\n\nconst createPartitionKey = (params: ICreatePartitionKeyParams) => {\n return `T#${params.tenant}#AUDIT_LOG#CREATEDBY#${params.createdBy}`;\n};\n\nexport class CreatedByAccessPattern<\n T extends IStorageListByCreatedByParams = IStorageListByCreatedByParams\n> extends BaseAccessPattern<T> {\n public override handles(): IAccessPatternHandles {\n return {\n mustInclude: [\"createdBy\"],\n mustNotInclude: [\"app\", \"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","CreatedByAccessPattern","BaseAccessPattern","options","result","item","time"],"mappings":";AAcA,MAAMA,qBAAqB,CAACC,SACjB,CAAC,EAAE,EAAEA,OAAO,MAAM,CAAC,qBAAqB,EAAEA,OAAO,SAAS,EAAE;AAGhE,MAAMC,+BAEHC;IACU,UAAiC;QAC7C,OAAO;YACH,aAAa;gBAAC;aAAY;YAC1B,gBAAgB;gBAAC;gBAAO;gBAAU;gBAAY;aAAS;QAC3D;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 { BaseAccessPattern } from "../../storage/accessPatterns/BaseAccessPattern.js";
|
|
3
|
-
import type { IAccessPatternCreateKeysResult, IAccessPatternHandles, IAccessPatternListResult } from "../../storage/abstractions/AccessPattern.js";
|
|
4
|
-
import type { IStorageListByCreatedOnParams } from "../../storage/abstractions/Storage.js";
|
|
5
|
-
export declare class CreatedOnAccessPattern<T extends IStorageListByCreatedOnParams = IStorageListByCreatedOnParams> 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#CREATED_ON`;
|
|
3
|
-
class CreatedOnAccessPattern extends BaseAccessPattern {
|
|
4
|
-
handles() {
|
|
5
|
-
return {
|
|
6
|
-
shouldInclude: [
|
|
7
|
-
"createdOn_gte",
|
|
8
|
-
"createdOn_lte"
|
|
9
|
-
],
|
|
10
|
-
mustInclude: [],
|
|
11
|
-
mustNotInclude: [
|
|
12
|
-
"app",
|
|
13
|
-
"createdBy",
|
|
14
|
-
"action",
|
|
15
|
-
"entityId",
|
|
16
|
-
"entity"
|
|
17
|
-
]
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
async list(params) {
|
|
21
|
-
const options = this.createOptions(params);
|
|
22
|
-
const result = await this.query({
|
|
23
|
-
partitionKey: createPartitionKey(params),
|
|
24
|
-
options
|
|
25
|
-
});
|
|
26
|
-
return this.populateResult(result);
|
|
27
|
-
}
|
|
28
|
-
createKeys(item) {
|
|
29
|
-
const time = item.createdOn.getTime();
|
|
30
|
-
return {
|
|
31
|
-
partitionKey: createPartitionKey(item),
|
|
32
|
-
sortKey: time
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export { CreatedOnAccessPattern };
|
|
37
|
-
|
|
38
|
-
//# sourceMappingURL=CreatedOnAccessPattern.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/accessPatterns/CreatedOnAccessPattern.js","sources":["../../../src/storage/accessPatterns/CreatedOnAccessPattern.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 { IStorageListByCreatedOnParams } from \"~/storage/abstractions/Storage.js\";\n\ninterface ICreatePartitionKeyParams {\n tenant: string;\n}\n\nconst createPartitionKey = (params: ICreatePartitionKeyParams) => {\n return `T#${params.tenant}#AUDIT_LOG#CREATED_ON`;\n};\n\nexport class CreatedOnAccessPattern<\n T extends IStorageListByCreatedOnParams = IStorageListByCreatedOnParams\n> extends BaseAccessPattern<T> {\n public override handles(): IAccessPatternHandles {\n return {\n shouldInclude: [\"createdOn_gte\", \"createdOn_lte\"],\n mustInclude: [],\n mustNotInclude: [\"app\", \"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\n return {\n partitionKey: createPartitionKey(item),\n sortKey: time\n };\n }\n}\n"],"names":["createPartitionKey","params","CreatedOnAccessPattern","BaseAccessPattern","options","result","item","time"],"mappings":";AAaA,MAAMA,qBAAqB,CAACC,SACjB,CAAC,EAAE,EAAEA,OAAO,MAAM,CAAC,qBAAqB,CAAC;AAG7C,MAAMC,+BAEHC;IACU,UAAiC;QAC7C,OAAO;YACH,eAAe;gBAAC;gBAAiB;aAAgB;YACjD,aAAa,EAAE;YACf,gBAAgB;gBAAC;gBAAO;gBAAa;gBAAU;gBAAY;aAAS;QACxE;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,15 +0,0 @@
|
|
|
1
|
-
import type { IAuditLog } from "../../storage/types.js";
|
|
2
|
-
import type { IStorageListDefaultParams } from "../../storage/abstractions/Storage.js";
|
|
3
|
-
import { BaseAccessPattern } from "./BaseAccessPattern.js";
|
|
4
|
-
import type { IAccessPatternCreateKeysResult, IAccessPatternHandles, IAccessPatternListResult } from "../../storage/abstractions/AccessPattern.js";
|
|
5
|
-
import type { AuditLogsEntity } from "../../storage/entity.js";
|
|
6
|
-
export interface IDefaultAccessPatternParams {
|
|
7
|
-
entity: AuditLogsEntity;
|
|
8
|
-
}
|
|
9
|
-
export declare class DefaultAccessPattern<T extends IStorageListDefaultParams = IStorageListDefaultParams> extends BaseAccessPattern<T> {
|
|
10
|
-
constructor(params: IDefaultAccessPatternParams);
|
|
11
|
-
handles(): IAccessPatternHandles;
|
|
12
|
-
canHandle(): boolean;
|
|
13
|
-
list(params: T): Promise<IAccessPatternListResult>;
|
|
14
|
-
createKeys(item: IAuditLog): IAccessPatternCreateKeysResult;
|
|
15
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { BaseAccessPattern } from "./BaseAccessPattern.js";
|
|
2
|
-
const createPartitionKey = (params)=>`T#${params.tenant}#AUDIT_LOG`;
|
|
3
|
-
class DefaultAccessPattern extends BaseAccessPattern {
|
|
4
|
-
constructor(params){
|
|
5
|
-
super({
|
|
6
|
-
index: void 0,
|
|
7
|
-
entity: params.entity
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
handles() {
|
|
11
|
-
return {
|
|
12
|
-
mustInclude: [],
|
|
13
|
-
mustNotInclude: []
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
canHandle() {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
async list(params) {
|
|
20
|
-
const options = this.createOptions(params);
|
|
21
|
-
return await this.query({
|
|
22
|
-
partitionKey: createPartitionKey(params),
|
|
23
|
-
options
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
createKeys(item) {
|
|
27
|
-
return {
|
|
28
|
-
partitionKey: createPartitionKey(item),
|
|
29
|
-
sortKey: `${item.id}`
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export { DefaultAccessPattern };
|
|
34
|
-
|
|
35
|
-
//# sourceMappingURL=DefaultAccessPattern.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/accessPatterns/DefaultAccessPattern.js","sources":["../../../src/storage/accessPatterns/DefaultAccessPattern.ts"],"sourcesContent":["import type { IAuditLog } from \"~/storage/types.js\";\nimport type { IStorageListDefaultParams } from \"~/storage/abstractions/Storage.js\";\nimport { BaseAccessPattern } from \"./BaseAccessPattern.js\";\nimport type {\n IAccessPatternCreateKeysResult,\n IAccessPatternHandles,\n IAccessPatternListResult\n} from \"~/storage/abstractions/AccessPattern.js\";\nimport type { AuditLogsEntity } from \"~/storage/entity.js\";\n\nexport interface IDefaultAccessPatternParams {\n entity: AuditLogsEntity;\n}\n\ninterface ICreatePartitionKeyParams {\n tenant: string;\n}\n\nconst createPartitionKey = (params: ICreatePartitionKeyParams) => {\n return `T#${params.tenant}#AUDIT_LOG`;\n};\n\nexport class DefaultAccessPattern<\n T extends IStorageListDefaultParams = IStorageListDefaultParams\n> extends BaseAccessPattern<T> {\n public constructor(params: IDefaultAccessPatternParams) {\n super({\n index: undefined,\n entity: params.entity\n });\n }\n\n public override handles(): IAccessPatternHandles {\n return {\n mustInclude: [],\n mustNotInclude: []\n };\n }\n\n public override canHandle(): boolean {\n return false;\n }\n\n public async list(params: T): Promise<IAccessPatternListResult> {\n const options = this.createOptions(params);\n\n return await this.query({\n partitionKey: createPartitionKey(params),\n options\n });\n }\n\n public createKeys(item: IAuditLog): IAccessPatternCreateKeysResult {\n return {\n partitionKey: createPartitionKey(item),\n sortKey: `${item.id}`\n };\n }\n}\n"],"names":["createPartitionKey","params","DefaultAccessPattern","BaseAccessPattern","undefined","options","item"],"mappings":";AAkBA,MAAMA,qBAAqB,CAACC,SACjB,CAAC,EAAE,EAAEA,OAAO,MAAM,CAAC,UAAU,CAAC;AAGlC,MAAMC,6BAEHC;IACN,YAAmBF,MAAmC,CAAE;QACpD,KAAK,CAAC;YACF,OAAOG;YACP,QAAQH,OAAO,MAAM;QACzB;IACJ;IAEgB,UAAiC;QAC7C,OAAO;YACH,aAAa,EAAE;YACf,gBAAgB,EAAE;QACtB;IACJ;IAEgB,YAAqB;QACjC,OAAO;IACX;IAEA,MAAa,KAAKA,MAAS,EAAqC;QAC5D,MAAMI,UAAU,IAAI,CAAC,aAAa,CAACJ;QAEnC,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC;YACpB,cAAcD,mBAAmBC;YACjCI;QACJ;IACJ;IAEO,WAAWC,IAAe,EAAkC;QAC/D,OAAO;YACH,cAAcN,mBAAmBM;YACjC,SAAS,GAAGA,KAAK,EAAE,EAAE;QACzB;IACJ;AACJ"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { IAuditLog } from "../../storage/types.js";
|
|
2
|
-
import type { IStorageListByEntityIdParams } 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 EntityIdGlobalAccessPattern<T extends IStorageListByEntityIdParams = IStorageListByEntityIdParams> 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
|
-
import { parseIdentifier } from "@webiny/utils";
|
|
3
|
-
const createPartitionKey = (params)=>{
|
|
4
|
-
const { id } = parseIdentifier(params.entityId);
|
|
5
|
-
return `T#${params.tenant}#AUDIT_LOG#ENTITY_ID#${id}`;
|
|
6
|
-
};
|
|
7
|
-
class EntityIdGlobalAccessPattern extends BaseAccessPattern {
|
|
8
|
-
handles() {
|
|
9
|
-
return {
|
|
10
|
-
mustInclude: [
|
|
11
|
-
"entityId"
|
|
12
|
-
],
|
|
13
|
-
mustNotInclude: [
|
|
14
|
-
"entity",
|
|
15
|
-
"createdBy",
|
|
16
|
-
"action"
|
|
17
|
-
]
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
async list(params) {
|
|
21
|
-
const options = this.createOptions(params);
|
|
22
|
-
const result = await this.query({
|
|
23
|
-
partitionKey: createPartitionKey(params),
|
|
24
|
-
options
|
|
25
|
-
});
|
|
26
|
-
return this.populateResult(result);
|
|
27
|
-
}
|
|
28
|
-
createKeys(item) {
|
|
29
|
-
const time = item.createdOn.getTime();
|
|
30
|
-
return {
|
|
31
|
-
partitionKey: createPartitionKey(item),
|
|
32
|
-
sortKey: time
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export { EntityIdGlobalAccessPattern };
|
|
37
|
-
|
|
38
|
-
//# sourceMappingURL=EntityIdAccessPattern.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/accessPatterns/EntityIdAccessPattern.js","sources":["../../../src/storage/accessPatterns/EntityIdAccessPattern.ts"],"sourcesContent":["import type { IAuditLog } from \"~/storage/types.js\";\nimport type { IStorageListByEntityIdParams } 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\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\ninterface ICreatePartitionKeyParams {\n entityId: string;\n tenant: string;\n}\n\nconst createPartitionKey = (params: ICreatePartitionKeyParams) => {\n const { id } = parseIdentifier(params.entityId);\n return `T#${params.tenant}#AUDIT_LOG#ENTITY_ID#${id}`;\n};\n\nexport class EntityIdGlobalAccessPattern<\n T extends IStorageListByEntityIdParams = IStorageListByEntityIdParams\n> extends BaseAccessPattern<T> {\n public override handles(): IAccessPatternHandles {\n return {\n mustInclude: [\"entityId\"],\n mustNotInclude: [\"entity\", \"createdBy\", \"action\"]\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","id","parseIdentifier","EntityIdGlobalAccessPattern","BaseAccessPattern","options","result","item","time"],"mappings":";;AAeA,MAAMA,qBAAqB,CAACC;IACxB,MAAM,EAAEC,EAAE,EAAE,GAAGC,gBAAgBF,OAAO,QAAQ;IAC9C,OAAO,CAAC,EAAE,EAAEA,OAAO,MAAM,CAAC,qBAAqB,EAAEC,IAAI;AACzD;AAEO,MAAME,oCAEHC;IACU,UAAiC;QAC7C,OAAO;YACH,aAAa;gBAAC;aAAW;YACzB,gBAAgB;gBAAC;gBAAU;gBAAa;aAAS;QACrD;IACJ;IAEA,MAAa,KAAKJ,MAAS,EAAqC;QAC5D,MAAMK,UAAU,IAAI,CAAC,aAAa,CAACL;QAEnC,MAAMM,SAAS,MAAM,IAAI,CAAC,KAAK,CAAC;YAC5B,cAAcP,mBAAmBC;YACjCK;QACJ;QACA,OAAO,IAAI,CAAC,cAAc,CAACC;IAC/B;IAEO,WAAWC,IAAe,EAAkC;QAC/D,MAAMC,OAAOD,KAAK,SAAS,CAAC,OAAO;QAEnC,OAAO;YACH,cAAcR,mBAAmBQ;YACjC,SAASC;QACb;IACJ;AACJ"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { IAccessPattern } from "../abstractions/AccessPattern.js";
|
|
2
|
-
import type { AuditLogsEntity } from "../../storage/entity.js";
|
|
3
|
-
export interface ICreateAccessPatternsParams {
|
|
4
|
-
entity: AuditLogsEntity;
|
|
5
|
-
}
|
|
6
|
-
export declare const createAccessPatterns: (params: ICreateAccessPatternsParams) => IAccessPattern<unknown>[];
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { DefaultAccessPattern } from "./DefaultAccessPattern.js";
|
|
2
|
-
import { AppAccessPattern } from "./AppAccessPattern.js";
|
|
3
|
-
import { AppCreatedByAccessPattern } from "./AppCreatedByAccessPattern.js";
|
|
4
|
-
import { AppEntityActionCreatedByAccessPattern } from "./AppEntityActionCreatedByAccessPattern.js";
|
|
5
|
-
import { AppEntityCreatedByAccessPattern } from "./AppEntityCreatedByAccessPattern.js";
|
|
6
|
-
import { AppEntityAccessPattern } from "./AppEntityAccessPattern.js";
|
|
7
|
-
import { AppEntityActionAccessPattern } from "./AppEntityActionAccessPattern.js";
|
|
8
|
-
import { EntityIdGlobalAccessPattern } from "./EntityIdAccessPattern.js";
|
|
9
|
-
import { CreatedByAccessPattern } from "./CreatedByAccessPattern.js";
|
|
10
|
-
import { CreatedOnAccessPattern } from "./CreatedOnAccessPattern.js";
|
|
11
|
-
const createAccessPatterns = (params)=>{
|
|
12
|
-
const { entity } = params;
|
|
13
|
-
return [
|
|
14
|
-
new DefaultAccessPattern({
|
|
15
|
-
entity
|
|
16
|
-
}),
|
|
17
|
-
new AppAccessPattern({
|
|
18
|
-
entity,
|
|
19
|
-
index: "GSI1"
|
|
20
|
-
}),
|
|
21
|
-
new AppCreatedByAccessPattern({
|
|
22
|
-
entity,
|
|
23
|
-
index: "GSI2"
|
|
24
|
-
}),
|
|
25
|
-
new AppEntityAccessPattern({
|
|
26
|
-
entity,
|
|
27
|
-
index: "GSI3"
|
|
28
|
-
}),
|
|
29
|
-
new EntityIdGlobalAccessPattern({
|
|
30
|
-
entity,
|
|
31
|
-
index: "GSI4"
|
|
32
|
-
}),
|
|
33
|
-
new AppEntityActionCreatedByAccessPattern({
|
|
34
|
-
entity,
|
|
35
|
-
index: "GSI5"
|
|
36
|
-
}),
|
|
37
|
-
new AppEntityActionAccessPattern({
|
|
38
|
-
entity,
|
|
39
|
-
index: "GSI6"
|
|
40
|
-
}),
|
|
41
|
-
new AppEntityCreatedByAccessPattern({
|
|
42
|
-
entity,
|
|
43
|
-
index: "GSI7"
|
|
44
|
-
}),
|
|
45
|
-
new CreatedByAccessPattern({
|
|
46
|
-
entity,
|
|
47
|
-
index: "GSI8"
|
|
48
|
-
}),
|
|
49
|
-
new CreatedOnAccessPattern({
|
|
50
|
-
entity,
|
|
51
|
-
index: "GSI9"
|
|
52
|
-
})
|
|
53
|
-
];
|
|
54
|
-
};
|
|
55
|
-
export { createAccessPatterns };
|
|
56
|
-
|
|
57
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/accessPatterns/index.js","sources":["../../../src/storage/accessPatterns/index.ts"],"sourcesContent":["import type { IAccessPattern } from \"../abstractions/AccessPattern.js\";\nimport { DefaultAccessPattern } from \"~/storage/accessPatterns/DefaultAccessPattern.js\";\nimport { AppAccessPattern } from \"~/storage/accessPatterns/AppAccessPattern.js\";\nimport { AppCreatedByAccessPattern } from \"~/storage/accessPatterns/AppCreatedByAccessPattern.js\";\nimport { AppEntityActionCreatedByAccessPattern } from \"~/storage/accessPatterns/AppEntityActionCreatedByAccessPattern.js\";\nimport { AppEntityCreatedByAccessPattern } from \"~/storage/accessPatterns/AppEntityCreatedByAccessPattern.js\";\nimport { AppEntityAccessPattern } from \"~/storage/accessPatterns/AppEntityAccessPattern.js\";\nimport { AppEntityActionAccessPattern } from \"~/storage/accessPatterns/AppEntityActionAccessPattern.js\";\nimport { EntityIdGlobalAccessPattern } from \"~/storage/accessPatterns/EntityIdAccessPattern.js\";\nimport { CreatedByAccessPattern } from \"~/storage/accessPatterns/CreatedByAccessPattern.js\";\nimport { CreatedOnAccessPattern } from \"~/storage/accessPatterns/CreatedOnAccessPattern.js\";\nimport type { AuditLogsEntity } from \"~/storage/entity.js\";\n\nexport interface ICreateAccessPatternsParams {\n entity: AuditLogsEntity;\n}\n\nexport const createAccessPatterns = (\n params: ICreateAccessPatternsParams\n): IAccessPattern<unknown>[] => {\n const { entity } = params;\n return [\n new DefaultAccessPattern({\n entity\n }),\n new AppAccessPattern({\n entity,\n index: \"GSI1\"\n }),\n new AppCreatedByAccessPattern({\n entity,\n index: \"GSI2\"\n }),\n new AppEntityAccessPattern({\n entity,\n index: \"GSI3\"\n }),\n new EntityIdGlobalAccessPattern({\n entity,\n index: \"GSI4\"\n }),\n new AppEntityActionCreatedByAccessPattern({\n entity,\n index: \"GSI5\"\n }),\n new AppEntityActionAccessPattern({\n entity,\n index: \"GSI6\"\n }),\n new AppEntityCreatedByAccessPattern({\n entity,\n index: \"GSI7\"\n }),\n new CreatedByAccessPattern({\n entity,\n index: \"GSI8\"\n }),\n new CreatedOnAccessPattern({\n entity,\n index: \"GSI9\"\n })\n ];\n};\n"],"names":["createAccessPatterns","params","entity","DefaultAccessPattern","AppAccessPattern","AppCreatedByAccessPattern","AppEntityAccessPattern","EntityIdGlobalAccessPattern","AppEntityActionCreatedByAccessPattern","AppEntityActionAccessPattern","AppEntityCreatedByAccessPattern","CreatedByAccessPattern","CreatedOnAccessPattern"],"mappings":";;;;;;;;;;AAiBO,MAAMA,uBAAuB,CAChCC;IAEA,MAAM,EAAEC,MAAM,EAAE,GAAGD;IACnB,OAAO;QACH,IAAIE,qBAAqB;YACrBD;QACJ;QACA,IAAIE,iBAAiB;YACjBF;YACA,OAAO;QACX;QACA,IAAIG,0BAA0B;YAC1BH;YACA,OAAO;QACX;QACA,IAAII,uBAAuB;YACvBJ;YACA,OAAO;QACX;QACA,IAAIK,4BAA4B;YAC5BL;YACA,OAAO;QACX;QACA,IAAIM,sCAAsC;YACtCN;YACA,OAAO;QACX;QACA,IAAIO,6BAA6B;YAC7BP;YACA,OAAO;QACX;QACA,IAAIQ,gCAAgC;YAChCR;YACA,OAAO;QACX;QACA,IAAIS,uBAAuB;YACvBT;YACA,OAAO;QACX;QACA,IAAIU,uBAAuB;YACvBV;YACA,OAAO;QACX;KACH;AACL"}
|
package/storage/cursorSchema.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import zod from "zod";
|
|
2
|
-
import { decodeCursor } from "@webiny/db-dynamodb";
|
|
3
|
-
const schema = zod.string().transform((value)=>{
|
|
4
|
-
const decoded = decodeCursor(value);
|
|
5
|
-
if (!decoded) throw new Error("Invalid cursor.");
|
|
6
|
-
try {
|
|
7
|
-
return JSON.parse(decoded);
|
|
8
|
-
} catch {
|
|
9
|
-
return decoded;
|
|
10
|
-
}
|
|
11
|
-
}).pipe(zod.object({
|
|
12
|
-
PK: zod.string(),
|
|
13
|
-
SK: zod.string()
|
|
14
|
-
}));
|
|
15
|
-
const fetchCursor = (input)=>{
|
|
16
|
-
const result = schema.safeParse(input);
|
|
17
|
-
if (!result.success) return;
|
|
18
|
-
return result.data;
|
|
19
|
-
};
|
|
20
|
-
export { fetchCursor };
|
|
21
|
-
|
|
22
|
-
//# sourceMappingURL=cursorSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/cursorSchema.js","sources":["../../src/storage/cursorSchema.ts"],"sourcesContent":["import zod from \"zod\";\nimport { decodeCursor } from \"@webiny/db-dynamodb\";\n\nconst schema = zod\n .string()\n .transform(value => {\n const decoded = decodeCursor(value);\n if (!decoded) {\n throw new Error(\"Invalid cursor.\");\n }\n try {\n return JSON.parse(decoded);\n } catch {\n return decoded;\n }\n })\n .pipe(\n zod.object({\n PK: zod.string(),\n SK: zod.string()\n })\n );\n\nexport const fetchCursor = (input: unknown) => {\n const result = schema.safeParse(input);\n if (!result.success) {\n return undefined;\n }\n return result.data;\n};\n"],"names":["schema","zod","value","decoded","decodeCursor","Error","JSON","fetchCursor","input","result"],"mappings":";;AAGA,MAAMA,SAASC,IAAAA,MACJ,GACN,SAAS,CAACC,CAAAA;IACP,MAAMC,UAAUC,aAAaF;IAC7B,IAAI,CAACC,SACD,MAAM,IAAIE,MAAM;IAEpB,IAAI;QACA,OAAOC,KAAK,KAAK,CAACH;IACtB,EAAE,OAAM;QACJ,OAAOA;IACX;AACJ,GACC,IAAI,CACDF,IAAI,MAAM,CAAC;IACP,IAAIA,IAAI,MAAM;IACd,IAAIA,IAAI,MAAM;AAClB;AAGD,MAAMM,cAAc,CAACC;IACxB,MAAMC,SAAST,OAAO,SAAS,CAACQ;IAChC,IAAI,CAACC,OAAO,OAAO,EACf;IAEJ,OAAOA,OAAO,IAAI;AACtB"}
|
package/storage/entity.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
2
|
-
import type { IEntity, IStandardEntityAttributes } from "@webiny/db-dynamodb";
|
|
3
|
-
import { createTable } from "@webiny/db-dynamodb";
|
|
4
|
-
import type { IStorageAuditLog } from "../storage/types.js";
|
|
5
|
-
export interface IAuditLogsEntityAttributes extends Omit<IStandardEntityAttributes<IStorageAuditLog>, "GSI1_SK" | "GSI2_SK" | "expiresAt"> {
|
|
6
|
-
GSI1_PK: string;
|
|
7
|
-
GSI1_SK: number;
|
|
8
|
-
GSI2_PK: string;
|
|
9
|
-
GSI2_SK: number;
|
|
10
|
-
GSI3_PK: string;
|
|
11
|
-
GSI3_SK: number;
|
|
12
|
-
GSI4_PK: string;
|
|
13
|
-
GSI4_SK: number;
|
|
14
|
-
GSI5_PK: string;
|
|
15
|
-
GSI5_SK: number;
|
|
16
|
-
GSI6_PK: string;
|
|
17
|
-
GSI6_SK: number;
|
|
18
|
-
GSI7_PK: string;
|
|
19
|
-
GSI7_SK: number;
|
|
20
|
-
GSI8_PK: string;
|
|
21
|
-
GSI8_SK: number;
|
|
22
|
-
GSI9_PK: string;
|
|
23
|
-
GSI9_SK: number;
|
|
24
|
-
expiresAt: number;
|
|
25
|
-
}
|
|
26
|
-
export type AuditLogsEntity = IEntity<IAuditLogsEntityAttributes>;
|
|
27
|
-
export interface ICreateEntityParams {
|
|
28
|
-
client: DynamoDBDocument;
|
|
29
|
-
gsiAmount: number;
|
|
30
|
-
tableName: string | undefined;
|
|
31
|
-
}
|
|
32
|
-
export interface ICreateEntityResult {
|
|
33
|
-
entity: AuditLogsEntity;
|
|
34
|
-
table: ReturnType<typeof createTable>;
|
|
35
|
-
}
|
|
36
|
-
export declare const createEntity: (params: ICreateEntityParams) => ICreateEntityResult;
|
package/storage/entity.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { createEntity, createTable } from "@webiny/db-dynamodb";
|
|
2
|
-
const createTableGSIIndexes = (count)=>{
|
|
3
|
-
const result = {};
|
|
4
|
-
for(let i = 1; i <= count; i++)result[`GSI${i}`] = {
|
|
5
|
-
partitionKey: `GSI${i}_PK`,
|
|
6
|
-
sortKey: `GSI${i}_SK`
|
|
7
|
-
};
|
|
8
|
-
return result;
|
|
9
|
-
};
|
|
10
|
-
const entity_createEntity = (params)=>{
|
|
11
|
-
const { gsiAmount, client, tableName } = params;
|
|
12
|
-
const name = tableName || process.env.DB_TABLE_AUDIT_LOGS;
|
|
13
|
-
if (!name) throw new Error("Missing env.DB_TABLE_AUDIT_LOGS environment variable.");
|
|
14
|
-
const table = createTable({
|
|
15
|
-
documentClient: client,
|
|
16
|
-
name,
|
|
17
|
-
indexes: {
|
|
18
|
-
...createTableGSIIndexes(gsiAmount)
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
const entity = createEntity({
|
|
22
|
-
name: "AuditLogs",
|
|
23
|
-
table: table.table,
|
|
24
|
-
attributes: {
|
|
25
|
-
PK: {
|
|
26
|
-
partitionKey: true
|
|
27
|
-
},
|
|
28
|
-
SK: {
|
|
29
|
-
sortKey: true
|
|
30
|
-
},
|
|
31
|
-
GSI_TENANT: {
|
|
32
|
-
type: "string",
|
|
33
|
-
required: true
|
|
34
|
-
},
|
|
35
|
-
GSI1_PK: {
|
|
36
|
-
type: "string",
|
|
37
|
-
required: true
|
|
38
|
-
},
|
|
39
|
-
GSI1_SK: {
|
|
40
|
-
type: "number",
|
|
41
|
-
required: true
|
|
42
|
-
},
|
|
43
|
-
GSI2_PK: {
|
|
44
|
-
type: "string",
|
|
45
|
-
required: true
|
|
46
|
-
},
|
|
47
|
-
GSI2_SK: {
|
|
48
|
-
type: "number",
|
|
49
|
-
required: true
|
|
50
|
-
},
|
|
51
|
-
GSI3_PK: {
|
|
52
|
-
type: "string",
|
|
53
|
-
required: true
|
|
54
|
-
},
|
|
55
|
-
GSI3_SK: {
|
|
56
|
-
type: "number",
|
|
57
|
-
required: true
|
|
58
|
-
},
|
|
59
|
-
GSI4_PK: {
|
|
60
|
-
type: "string",
|
|
61
|
-
required: true
|
|
62
|
-
},
|
|
63
|
-
GSI4_SK: {
|
|
64
|
-
type: "number",
|
|
65
|
-
required: true
|
|
66
|
-
},
|
|
67
|
-
GSI5_PK: {
|
|
68
|
-
type: "string",
|
|
69
|
-
required: true
|
|
70
|
-
},
|
|
71
|
-
GSI5_SK: {
|
|
72
|
-
type: "number",
|
|
73
|
-
required: true
|
|
74
|
-
},
|
|
75
|
-
GSI6_PK: {
|
|
76
|
-
type: "string",
|
|
77
|
-
required: true
|
|
78
|
-
},
|
|
79
|
-
GSI6_SK: {
|
|
80
|
-
type: "number",
|
|
81
|
-
required: true
|
|
82
|
-
},
|
|
83
|
-
GSI7_PK: {
|
|
84
|
-
type: "string",
|
|
85
|
-
required: true
|
|
86
|
-
},
|
|
87
|
-
GSI7_SK: {
|
|
88
|
-
type: "number",
|
|
89
|
-
required: true
|
|
90
|
-
},
|
|
91
|
-
GSI8_PK: {
|
|
92
|
-
type: "string",
|
|
93
|
-
required: true
|
|
94
|
-
},
|
|
95
|
-
GSI8_SK: {
|
|
96
|
-
type: "number",
|
|
97
|
-
required: true
|
|
98
|
-
},
|
|
99
|
-
GSI9_PK: {
|
|
100
|
-
type: "string",
|
|
101
|
-
required: true
|
|
102
|
-
},
|
|
103
|
-
GSI9_SK: {
|
|
104
|
-
type: "number",
|
|
105
|
-
required: true
|
|
106
|
-
},
|
|
107
|
-
data: {
|
|
108
|
-
type: "map",
|
|
109
|
-
required: true
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
return {
|
|
114
|
-
entity,
|
|
115
|
-
table
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
export { entity_createEntity as createEntity };
|
|
119
|
-
|
|
120
|
-
//# sourceMappingURL=entity.js.map
|
package/storage/entity.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/entity.js","sources":["../../src/storage/entity.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { IEntity, IStandardEntityAttributes } from \"@webiny/db-dynamodb\";\nimport { createEntity as baseCreateEntity, createTable } from \"@webiny/db-dynamodb\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { IStorageAuditLog } from \"~/storage/types.js\";\n\nexport interface IAuditLogsEntityAttributes extends Omit<\n IStandardEntityAttributes<IStorageAuditLog>,\n \"GSI1_SK\" | \"GSI2_SK\" | \"expiresAt\"\n> {\n GSI1_PK: string;\n GSI1_SK: number;\n GSI2_PK: string;\n GSI2_SK: number;\n GSI3_PK: string;\n GSI3_SK: number;\n GSI4_PK: string;\n GSI4_SK: number;\n GSI5_PK: string;\n GSI5_SK: number;\n GSI6_PK: string;\n GSI6_SK: number;\n GSI7_PK: string;\n GSI7_SK: number;\n GSI8_PK: string;\n GSI8_SK: number;\n GSI9_PK: string;\n GSI9_SK: number;\n expiresAt: number;\n}\n\nexport type AuditLogsEntity = IEntity<IAuditLogsEntityAttributes>;\n\nexport interface ICreateEntityParams {\n client: DynamoDBDocument;\n gsiAmount: number;\n tableName: string | undefined;\n}\n\nexport interface ICreateEntityResult {\n entity: AuditLogsEntity;\n table: ReturnType<typeof createTable>;\n}\n\nconst createTableGSIIndexes = (count: number) => {\n const result: GenericRecord = {};\n for (let i = 1; i <= count; i++) {\n result[`GSI${i}`] = {\n partitionKey: `GSI${i}_PK`,\n sortKey: `GSI${i}_SK`\n };\n }\n return result;\n};\n\nexport const createEntity = (params: ICreateEntityParams): ICreateEntityResult => {\n const { gsiAmount, client, tableName } = params;\n const name = tableName || process.env.DB_TABLE_AUDIT_LOGS;\n if (!name) {\n throw new Error(\"Missing env.DB_TABLE_AUDIT_LOGS environment variable.\");\n }\n const table = createTable({\n documentClient: client,\n name,\n indexes: {\n ...createTableGSIIndexes(gsiAmount)\n }\n });\n\n const entity = baseCreateEntity<IAuditLogsEntityAttributes>({\n name: \"AuditLogs\",\n table: table.table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n GSI_TENANT: {\n type: \"string\",\n required: true\n },\n GSI1_PK: {\n type: \"string\",\n required: true\n },\n GSI1_SK: {\n type: \"number\",\n required: true\n },\n GSI2_PK: {\n type: \"string\",\n required: true\n },\n GSI2_SK: {\n type: \"number\",\n required: true\n },\n GSI3_PK: {\n type: \"string\",\n required: true\n },\n GSI3_SK: {\n type: \"number\",\n required: true\n },\n GSI4_PK: {\n type: \"string\",\n required: true\n },\n GSI4_SK: {\n type: \"number\",\n required: true\n },\n GSI5_PK: {\n type: \"string\",\n required: true\n },\n GSI5_SK: {\n type: \"number\",\n required: true\n },\n GSI6_PK: {\n type: \"string\",\n required: true\n },\n GSI6_SK: {\n type: \"number\",\n required: true\n },\n GSI7_PK: {\n type: \"string\",\n required: true\n },\n GSI7_SK: {\n type: \"number\",\n required: true\n },\n GSI8_PK: {\n type: \"string\",\n required: true\n },\n GSI8_SK: {\n type: \"number\",\n required: true\n },\n GSI9_PK: {\n type: \"string\",\n required: true\n },\n GSI9_SK: {\n type: \"number\",\n required: true\n },\n data: {\n type: \"map\",\n required: true\n }\n }\n });\n\n return {\n entity,\n table\n };\n};\n"],"names":["createTableGSIIndexes","count","result","i","createEntity","params","gsiAmount","client","tableName","name","process","Error","table","createTable","entity","baseCreateEntity"],"mappings":";AA4CA,MAAMA,wBAAwB,CAACC;IAC3B,MAAMC,SAAwB,CAAC;IAC/B,IAAK,IAAIC,IAAI,GAAGA,KAAKF,OAAOE,IACxBD,MAAM,CAAC,CAAC,GAAG,EAAEC,GAAG,CAAC,GAAG;QAChB,cAAc,CAAC,GAAG,EAAEA,EAAE,GAAG,CAAC;QAC1B,SAAS,CAAC,GAAG,EAAEA,EAAE,GAAG,CAAC;IACzB;IAEJ,OAAOD;AACX;AAEO,MAAME,sBAAe,CAACC;IACzB,MAAM,EAAEC,SAAS,EAAEC,MAAM,EAAEC,SAAS,EAAE,GAAGH;IACzC,MAAMI,OAAOD,aAAaE,QAAQ,GAAG,CAAC,mBAAmB;IACzD,IAAI,CAACD,MACD,MAAM,IAAIE,MAAM;IAEpB,MAAMC,QAAQC,YAAY;QACtB,gBAAgBN;QAChBE;QACA,SAAS;YACL,GAAGT,sBAAsBM,UAAU;QACvC;IACJ;IAEA,MAAMQ,SAASC,aAA6C;QACxD,MAAM;QACN,OAAOH,MAAM,KAAK;QAClB,YAAY;YACR,IAAI;gBACA,cAAc;YAClB;YACA,IAAI;gBACA,SAAS;YACb;YACA,YAAY;gBACR,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,SAAS;gBACL,MAAM;gBACN,UAAU;YACd;YACA,MAAM;gBACF,MAAM;gBACN,UAAU;YACd;QACJ;IACJ;IAEA,OAAO;QACHE;QACAF;IACJ;AACJ"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { IStorageListErrorResult } from "../../storage/abstractions/Storage.js";
|
|
2
|
-
export interface IListErrorResultParams {
|
|
3
|
-
error: Error;
|
|
4
|
-
}
|
|
5
|
-
export declare class ListErrorResult implements IStorageListErrorResult {
|
|
6
|
-
readonly error: Error;
|
|
7
|
-
readonly success = false;
|
|
8
|
-
private constructor();
|
|
9
|
-
static create(params: IListErrorResultParams): IStorageListErrorResult;
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/results/ListErrorResult.js","sources":["../../../src/storage/results/ListErrorResult.ts"],"sourcesContent":["import type { IStorageListErrorResult } from \"~/storage/abstractions/Storage.js\";\n\nexport interface IListErrorResultParams {\n error: Error;\n}\n\nexport class ListErrorResult implements IStorageListErrorResult {\n public readonly error: Error;\n public readonly success = false;\n\n private constructor(params: IListErrorResultParams) {\n this.error = params.error;\n }\n\n public static create(params: IListErrorResultParams): IStorageListErrorResult {\n return new ListErrorResult(params);\n }\n}\n"],"names":["ListErrorResult","params"],"mappings":"AAMO,MAAMA;IAIT,YAAoBC,MAA8B,CAAE;aAFpC,OAAO,GAAG;QAGtB,IAAI,CAAC,KAAK,GAAGA,OAAO,KAAK;IAC7B;IAEA,OAAc,OAAOA,MAA8B,EAA2B;QAC1E,OAAO,IAAID,gBAAgBC;IAC/B;AACJ"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { IStorageListSuccessResult, IStorageListSuccessResultMeta } from "../../storage/abstractions/Storage.js";
|
|
2
|
-
import type { GenericRecord } from "@webiny/api/types.js";
|
|
3
|
-
import type { IAuditLog } from "../../storage/types.js";
|
|
4
|
-
export interface IListSuccessResultParams {
|
|
5
|
-
data: IAuditLog[];
|
|
6
|
-
lastEvaluatedKey?: GenericRecord;
|
|
7
|
-
}
|
|
8
|
-
export declare class ListSuccessResult implements IStorageListSuccessResult {
|
|
9
|
-
readonly data: IAuditLog[];
|
|
10
|
-
readonly meta: IStorageListSuccessResultMeta;
|
|
11
|
-
readonly success = true;
|
|
12
|
-
protected constructor(params: IListSuccessResultParams);
|
|
13
|
-
static create(params: IListSuccessResultParams): IStorageListSuccessResult;
|
|
14
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { encodeCursor } from "@webiny/db-dynamodb";
|
|
2
|
-
class ListSuccessResult {
|
|
3
|
-
constructor(params){
|
|
4
|
-
this.success = true;
|
|
5
|
-
this.data = params.data;
|
|
6
|
-
this.meta = {
|
|
7
|
-
after: encodeCursor(params.lastEvaluatedKey) || void 0,
|
|
8
|
-
hasMoreItems: !!params.lastEvaluatedKey
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
static create(params) {
|
|
12
|
-
return new ListSuccessResult(params);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export { ListSuccessResult };
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=ListSuccessResult.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/results/ListSuccessResult.js","sources":["../../../src/storage/results/ListSuccessResult.ts"],"sourcesContent":["import type {\n IStorageListSuccessResult,\n IStorageListSuccessResultMeta\n} from \"~/storage/abstractions/Storage.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { encodeCursor } from \"@webiny/db-dynamodb\";\nimport type { IAuditLog } from \"~/storage/types.js\";\n\nexport interface IListSuccessResultParams {\n data: IAuditLog[];\n lastEvaluatedKey?: GenericRecord;\n}\n\nexport class ListSuccessResult implements IStorageListSuccessResult {\n public readonly data: IAuditLog[];\n public readonly meta: IStorageListSuccessResultMeta;\n public readonly success = true;\n\n protected constructor(params: IListSuccessResultParams) {\n this.data = params.data;\n this.meta = {\n after: encodeCursor(params.lastEvaluatedKey) || undefined,\n hasMoreItems: !!params.lastEvaluatedKey\n };\n }\n\n public static create(params: IListSuccessResultParams): IStorageListSuccessResult {\n return new ListSuccessResult(params);\n }\n}\n"],"names":["ListSuccessResult","params","encodeCursor","undefined"],"mappings":";AAaO,MAAMA;IAKT,YAAsBC,MAAgC,CAAE;aAFxC,OAAO,GAAG;QAGtB,IAAI,CAAC,IAAI,GAAGA,OAAO,IAAI;QACvB,IAAI,CAAC,IAAI,GAAG;YACR,OAAOC,aAAaD,OAAO,gBAAgB,KAAKE;YAChD,cAAc,CAAC,CAACF,OAAO,gBAAgB;QAC3C;IACJ;IAEA,OAAc,OAAOA,MAAgC,EAA6B;QAC9E,OAAO,IAAID,kBAAkBC;IACjC;AACJ"}
|
package/storage/results/index.js
DELETED
package/storage/startKey.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { IStorageListParams } from "../storage/abstractions/Storage.js";
|
|
2
|
-
export interface ICreateStartKeyResult {
|
|
3
|
-
PK: string;
|
|
4
|
-
SK: string;
|
|
5
|
-
}
|
|
6
|
-
export declare const createStartKey: (params: Pick<IStorageListParams, "after">) => ICreateStartKeyResult | undefined;
|
package/storage/startKey.js
DELETED
package/storage/startKey.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage/startKey.js","sources":["../../src/storage/startKey.ts"],"sourcesContent":["import type { IStorageListParams } from \"~/storage/abstractions/Storage.js\";\nimport { fetchCursor } from \"~/storage/cursorSchema.js\";\n\nexport interface ICreateStartKeyResult {\n PK: string;\n SK: string;\n}\n\nexport const createStartKey = (\n params: Pick<IStorageListParams, \"after\">\n): ICreateStartKeyResult | undefined => {\n if (!params.after) {\n return undefined;\n }\n return fetchCursor(params.after);\n};\n"],"names":["createStartKey","params","fetchCursor"],"mappings":";AAQO,MAAMA,iBAAiB,CAC1BC;IAEA,IAAI,CAACA,OAAO,KAAK,EACb;IAEJ,OAAOC,YAAYD,OAAO,KAAK;AACnC"}
|