@webiny/api-core 0.0.0-unstable.33e4fd9647 → 0.0.0-unstable.3fddf667ea
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/ApiCoreFeature.js +5 -2
- package/ApiCoreFeature.js.map +1 -1
- package/exports/api.d.ts +1 -0
- package/exports/api.js +1 -0
- package/features/ai/AiSdkTools.d.ts +1 -1
- package/features/ai/AiSdkTools.js +3 -2
- package/features/ai/AiSdkTools.js.map +1 -1
- package/features/ai/abstractions.d.ts +9 -1
- package/features/ai/abstractions.js.map +1 -1
- package/features/ai/index.d.ts +1 -0
- package/features/ai/index.js +1 -0
- package/features/ai/isReadOnlyTool.d.ts +9 -0
- package/features/ai/isReadOnlyTool.js +4 -0
- package/features/ai/isReadOnlyTool.js.map +1 -0
- package/features/cdnCache/NullCdnCache.d.ts +8 -0
- package/features/cdnCache/NullCdnCache.js +11 -0
- package/features/cdnCache/NullCdnCache.js.map +1 -0
- package/features/cdnCache/abstractions.d.ts +20 -0
- package/features/cdnCache/abstractions.js +5 -0
- package/features/cdnCache/abstractions.js.map +1 -0
- package/features/cdnCache/feature.d.ts +8 -0
- package/features/cdnCache/feature.js +11 -0
- package/features/cdnCache/feature.js.map +1 -0
- package/features/cdnCache/index.d.ts +2 -0
- package/features/cdnCache/index.js +2 -0
- package/features/debugger/DebuggerRouteDecorator.d.ts +3 -3
- package/features/debugger/DebuggerRouteDecorator.js +5 -10
- package/features/debugger/DebuggerRouteDecorator.js.map +1 -1
- package/features/debugger/__tests__/serialize.test.js.map +1 -1
- package/features/encryption/BuildParamsEncryptionConfig.d.ts +13 -0
- package/features/encryption/BuildParamsEncryptionConfig.js +19 -0
- package/features/encryption/BuildParamsEncryptionConfig.js.map +1 -0
- package/features/encryption/EncryptionService.d.ts +2 -2
- package/features/encryption/EncryptionService.js +9 -14
- package/features/encryption/EncryptionService.js.map +1 -1
- package/features/encryption/abstractions.d.ts +15 -0
- package/features/encryption/abstractions.js +2 -1
- package/features/encryption/abstractions.js.map +1 -1
- package/features/encryption/feature.js +2 -0
- package/features/encryption/feature.js.map +1 -1
- package/features/encryption/index.d.ts +2 -0
- package/features/encryption/index.js +2 -1
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +0 -1
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -1
- package/features/hashing/BuildParamsHashingConfig.d.ts +11 -0
- package/features/hashing/BuildParamsHashingConfig.js +18 -0
- package/features/hashing/BuildParamsHashingConfig.js.map +1 -0
- package/features/hashing/ScryptHasher.d.ts +2 -2
- package/features/hashing/ScryptHasher.js +6 -8
- package/features/hashing/ScryptHasher.js.map +1 -1
- package/features/hashing/abstractions.d.ts +15 -0
- package/features/hashing/abstractions.js +2 -1
- package/features/hashing/abstractions.js.map +1 -1
- package/features/hashing/feature.js +2 -0
- package/features/hashing/feature.js.map +1 -1
- package/features/hashing/index.d.ts +1 -0
- package/features/hashing/index.js +1 -1
- package/features/logger/NullLogger.d.ts +10 -0
- package/features/logger/NullLogger.js +12 -0
- package/features/logger/NullLogger.js.map +1 -0
- package/features/logger/index.d.ts +1 -0
- package/features/logger/index.js +1 -0
- package/features/requestStorage/abstractions.d.ts +23 -0
- package/features/requestStorage/abstractions.js +5 -0
- package/features/requestStorage/abstractions.js.map +1 -0
- package/features/requestStorage/index.d.ts +1 -0
- package/features/requestStorage/index.js +1 -0
- package/features/security/IdentityContext/IdentityContext.d.ts +6 -2
- package/features/security/IdentityContext/IdentityContext.js +24 -7
- package/features/security/IdentityContext/IdentityContext.js.map +1 -1
- package/features/security/IdentityContext/abstractions.d.ts +6 -1
- package/features/security/IdentityContext/abstractions.js.map +1 -1
- package/features/security/SecurityFeature.js +2 -0
- package/features/security/SecurityFeature.js.map +1 -1
- package/features/security/ai/CreateRoleTool.d.ts +54 -0
- package/features/security/ai/CreateRoleTool.js +71 -0
- package/features/security/ai/CreateRoleTool.js.map +1 -0
- package/features/security/ai/CreateTeamTool.d.ts +49 -0
- package/features/security/ai/CreateTeamTool.js +56 -0
- package/features/security/ai/CreateTeamTool.js.map +1 -0
- package/features/security/ai/DeleteRoleTool.d.ts +52 -0
- package/features/security/ai/DeleteRoleTool.js +79 -0
- package/features/security/ai/DeleteRoleTool.js.map +1 -0
- package/features/security/ai/DeleteTeamTool.d.ts +47 -0
- package/features/security/ai/DeleteTeamTool.js +56 -0
- package/features/security/ai/DeleteTeamTool.js.map +1 -0
- package/features/security/ai/ListRolesTool.d.ts +40 -0
- package/features/security/ai/ListRolesTool.js +48 -0
- package/features/security/ai/ListRolesTool.js.map +1 -0
- package/features/security/ai/ListTeamsTool.d.ts +42 -0
- package/features/security/ai/ListTeamsTool.js +49 -0
- package/features/security/ai/ListTeamsTool.js.map +1 -0
- package/features/security/ai/UpdateRoleTool.d.ts +46 -0
- package/features/security/ai/UpdateRoleTool.js +53 -0
- package/features/security/ai/UpdateRoleTool.js.map +1 -0
- package/features/security/ai/UpdateTeamTool.d.ts +53 -0
- package/features/security/ai/UpdateTeamTool.js +56 -0
- package/features/security/ai/UpdateTeamTool.js.map +1 -0
- package/features/security/ai/feature.d.ts +10 -0
- package/features/security/ai/feature.js +25 -0
- package/features/security/ai/feature.js.map +1 -0
- package/features/security/ai/index.d.ts +9 -0
- package/features/security/ai/index.js +9 -0
- package/features/security/apiKeys/ApiKeyAuthorizer.js +1 -1
- package/features/security/apiKeys/ApiKeyAuthorizer.js.map +1 -1
- package/features/security/authorization/AuthorizationContext/AuthorizationContext.d.ts +13 -3
- package/features/security/authorization/AuthorizationContext/AuthorizationContext.js +35 -22
- package/features/security/authorization/AuthorizationContext/AuthorizationContext.js.map +1 -1
- package/features/security/authorization/AuthorizationContext/abstractions.d.ts +2 -0
- package/features/security/authorization/AuthorizationContext/abstractions.js.map +1 -1
- package/features/security/authorization/AuthorizationContext/feature.js +6 -1
- package/features/security/authorization/AuthorizationContext/feature.js.map +1 -1
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleCreatedHandler.d.ts +11 -0
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleCreatedHandler.js +24 -0
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleCreatedHandler.js.map +1 -0
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleDeletedHandler.d.ts +11 -0
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleDeletedHandler.js +24 -0
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleDeletedHandler.js.map +1 -0
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleUpdatedHandler.d.ts +11 -0
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleUpdatedHandler.js +24 -0
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleUpdatedHandler.js.map +1 -0
- package/features/security/roles/NotifyRoleChange/feature.d.ts +5 -0
- package/features/security/roles/NotifyRoleChange/feature.js +15 -0
- package/features/security/roles/NotifyRoleChange/feature.js.map +1 -0
- package/features/security/roles/NotifyRoleChange/index.d.ts +2 -0
- package/features/security/roles/NotifyRoleChange/index.js +2 -0
- package/features/security/roles/NotifyRoleChange/recordType.d.ts +5 -0
- package/features/security/roles/NotifyRoleChange/recordType.js +4 -0
- package/features/security/roles/NotifyRoleChange/recordType.js.map +1 -0
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +2 -1
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
- package/features/security/roles/feature.js +2 -0
- package/features/security/roles/feature.js.map +1 -1
- package/features/security/shared/definedOnly.d.ts +1 -0
- package/features/security/shared/definedOnly.js +8 -0
- package/features/security/shared/definedOnly.js.map +1 -0
- package/features/security/shared/index.d.ts +1 -0
- package/features/security/shared/index.js +1 -0
- package/features/security/teams/NotifyTeamChange/NotifyOnTeamChangeHandlers.d.ts +29 -0
- package/features/security/teams/NotifyTeamChange/NotifyOnTeamChangeHandlers.js +62 -0
- package/features/security/teams/NotifyTeamChange/NotifyOnTeamChangeHandlers.js.map +1 -0
- package/features/security/teams/NotifyTeamChange/feature.d.ts +5 -0
- package/features/security/teams/NotifyTeamChange/feature.js +13 -0
- package/features/security/teams/NotifyTeamChange/feature.js.map +1 -0
- package/features/security/teams/NotifyTeamChange/index.d.ts +2 -0
- package/features/security/teams/NotifyTeamChange/index.js +2 -0
- package/features/security/teams/NotifyTeamChange/recordType.d.ts +5 -0
- package/features/security/teams/NotifyTeamChange/recordType.js +4 -0
- package/features/security/teams/NotifyTeamChange/recordType.js.map +1 -0
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +2 -1
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
- package/features/security/teams/feature.js +2 -0
- package/features/security/teams/feature.js.map +1 -1
- package/features/task/TaskService/abstractions.d.ts +7 -0
- package/features/task/TaskService/abstractions.js.map +1 -1
- package/features/tenancy/TenantContext/TenantContext.d.ts +5 -2
- package/features/tenancy/TenantContext/TenantContext.js +31 -28
- package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
- package/features/users/AdminUsersFeature.js +4 -0
- package/features/users/AdminUsersFeature.js.map +1 -1
- package/features/users/CreateUser/CreateUserUseCase.js +1 -1
- package/features/users/CreateUser/CreateUserUseCase.js.map +1 -1
- package/features/users/NotifyUserChange/NotifyOnUserChangeHandlers.d.ts +29 -0
- package/features/users/NotifyUserChange/NotifyOnUserChangeHandlers.js +62 -0
- package/features/users/NotifyUserChange/NotifyOnUserChangeHandlers.js.map +1 -0
- package/features/users/NotifyUserChange/feature.d.ts +5 -0
- package/features/users/NotifyUserChange/feature.js +13 -0
- package/features/users/NotifyUserChange/feature.js.map +1 -0
- package/features/users/NotifyUserChange/index.d.ts +2 -0
- package/features/users/NotifyUserChange/index.js +2 -0
- package/features/users/NotifyUserChange/recordType.d.ts +5 -0
- package/features/users/NotifyUserChange/recordType.js +4 -0
- package/features/users/NotifyUserChange/recordType.js.map +1 -0
- package/features/users/ai/ListUsersTool.d.ts +39 -0
- package/features/users/ai/ListUsersTool.js +46 -0
- package/features/users/ai/ListUsersTool.js.map +1 -0
- package/features/users/ai/UpdateUserAccessTool.d.ts +59 -0
- package/features/users/ai/UpdateUserAccessTool.js +101 -0
- package/features/users/ai/UpdateUserAccessTool.js.map +1 -0
- package/features/users/ai/feature.d.ts +11 -0
- package/features/users/ai/feature.js +13 -0
- package/features/users/ai/feature.js.map +1 -0
- package/features/users/ai/index.d.ts +3 -0
- package/features/users/ai/index.js +3 -0
- package/features/users/shared/loaders.js.map +1 -1
- package/features/users/shared/types.d.ts +9 -7
- package/features/wcp/WcpContext/WcpContext.d.ts +0 -1
- package/features/wcp/WcpContext/WcpContext.js +0 -3
- package/features/wcp/WcpContext/WcpContext.js.map +1 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +0 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +0 -4
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
- package/features/websockets/NotifyRecordChange/NotifyRecordChangeUseCase.d.ts +12 -0
- package/features/websockets/NotifyRecordChange/NotifyRecordChangeUseCase.js +38 -0
- package/features/websockets/NotifyRecordChange/NotifyRecordChangeUseCase.js.map +1 -0
- package/features/websockets/NotifyRecordChange/abstractions.d.ts +39 -0
- package/features/websockets/NotifyRecordChange/abstractions.js +6 -0
- package/features/websockets/NotifyRecordChange/abstractions.js.map +1 -0
- package/features/websockets/NotifyRecordChange/feature.d.ts +5 -0
- package/features/websockets/NotifyRecordChange/feature.js +11 -0
- package/features/websockets/NotifyRecordChange/feature.js.map +1 -0
- package/features/websockets/NotifyRecordChange/index.d.ts +2 -0
- package/features/websockets/NotifyRecordChange/index.js +2 -0
- package/features/websockets/SendToIdentity/NullSendToIdentityUseCase.d.ts +20 -0
- package/features/websockets/SendToIdentity/NullSendToIdentityUseCase.js +24 -0
- package/features/websockets/SendToIdentity/NullSendToIdentityUseCase.js.map +1 -0
- package/features/websockets/SendToIdentity/abstractions.d.ts +19 -0
- package/features/websockets/SendToIdentity/abstractions.js +5 -0
- package/features/websockets/SendToIdentity/abstractions.js.map +1 -0
- package/features/websockets/WebsocketServiceError.d.ts +7 -0
- package/features/websockets/WebsocketServiceError.js +14 -0
- package/features/websockets/WebsocketServiceError.js.map +1 -0
- package/features/websockets/index.d.ts +7 -0
- package/features/websockets/index.js +4 -0
- package/features/websockets/types.d.ts +15 -0
- package/features/websockets/types.js +0 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +19 -21
- package/types/users.d.ts +2 -3
- package/features/logger/LoggerService.d.ts +0 -14
- package/features/logger/LoggerService.js +0 -48
- package/features/logger/LoggerService.js.map +0 -1
- package/features/logger/feature.d.ts +0 -4
- package/features/logger/feature.js +0 -11
- package/features/logger/feature.js.map +0 -1
|
@@ -1,37 +1,50 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
2
|
-
const
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
const NO_TENANT = "";
|
|
3
3
|
class AuthorizationContext {
|
|
4
|
-
constructor(getAuthorizers, getTransformers){
|
|
4
|
+
constructor(getAuthorizers, getTransformers, getTenantId){
|
|
5
5
|
this.getAuthorizers = getAuthorizers;
|
|
6
6
|
this.getTransformers = getTransformers;
|
|
7
|
+
this.getTenantId = getTenantId;
|
|
8
|
+
this.permissionsByIdentity = new WeakMap();
|
|
9
|
+
this.authorizationEnabledOverrides = new AsyncLocalStorage();
|
|
7
10
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
loadPermissions(identity) {
|
|
12
|
+
let byTenant = this.permissionsByIdentity.get(identity);
|
|
13
|
+
if (!byTenant) {
|
|
14
|
+
byTenant = new Map();
|
|
15
|
+
this.permissionsByIdentity.set(identity, byTenant);
|
|
16
|
+
}
|
|
17
|
+
const tenantKey = this.getTenantId() ?? NO_TENANT;
|
|
18
|
+
const cached = byTenant.get(tenantKey);
|
|
19
|
+
if (cached) return cached;
|
|
20
|
+
const loader = this.authorize(identity);
|
|
21
|
+
byTenant.set(tenantKey, loader);
|
|
22
|
+
const cache = byTenant;
|
|
23
|
+
loader.catch(()=>{
|
|
24
|
+
if (cache.get(tenantKey) === loader) cache.delete(tenantKey);
|
|
22
25
|
});
|
|
23
|
-
return
|
|
26
|
+
return loader;
|
|
24
27
|
}
|
|
25
28
|
isAuthorizationEnabled() {
|
|
26
|
-
const override =
|
|
29
|
+
const override = this.authorizationEnabledOverrides.getStore();
|
|
27
30
|
return override ?? true;
|
|
28
31
|
}
|
|
29
32
|
withoutAuthorization(cb) {
|
|
30
|
-
return
|
|
33
|
+
return this.authorizationEnabledOverrides.run(false, cb);
|
|
34
|
+
}
|
|
35
|
+
withAuthorization(cb) {
|
|
36
|
+
return this.authorizationEnabledOverrides.run(true, cb);
|
|
31
37
|
}
|
|
32
38
|
clearPermissionsCache() {
|
|
33
|
-
this.
|
|
34
|
-
|
|
39
|
+
this.permissionsByIdentity = new WeakMap();
|
|
40
|
+
}
|
|
41
|
+
async authorize(identity) {
|
|
42
|
+
const authorizers = this.getAuthorizers();
|
|
43
|
+
for (const authorizer of authorizers){
|
|
44
|
+
const permissions = await authorizer.authorize(identity);
|
|
45
|
+
if (Array.isArray(permissions)) return this.transformPermissions(permissions);
|
|
46
|
+
}
|
|
47
|
+
return [];
|
|
35
48
|
}
|
|
36
49
|
transformPermissions(permissions) {
|
|
37
50
|
const transformers = this.getTransformers();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/security/authorization/AuthorizationContext/AuthorizationContext.js","sources":["../../../../../src/features/security/authorization/AuthorizationContext/AuthorizationContext.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"async_hooks\";\nimport { AuthorizationContext as Abstraction, PermissionTransformer } from \"./abstractions.js\";\nimport { Authorizer } from \"../Authorizer/index.js\";\nimport type { SecurityPermission } from \"~/types/security.js\";\nimport { Identity } from \"~/features/security/IdentityContext/index.js\";\n\nconst
|
|
1
|
+
{"version":3,"file":"features/security/authorization/AuthorizationContext/AuthorizationContext.js","sources":["../../../../../src/features/security/authorization/AuthorizationContext/AuthorizationContext.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { AuthorizationContext as Abstraction, PermissionTransformer } from \"./abstractions.js\";\nimport { Authorizer } from \"../Authorizer/index.js\";\nimport type { SecurityPermission } from \"~/types/security.js\";\nimport { Identity } from \"~/features/security/IdentityContext/index.js\";\n\n/** Tenant key used when no tenant is set yet (before the tenant is resolved). */\nconst NO_TENANT = \"\";\n\ntype PermissionsByTenant = Map<string, Promise<SecurityPermission[]>>;\n\n/**\n * Loads and caches permissions per identity object and tenant for the lifetime of the request.\n * `IdentityContext.withIdentity` can switch the identity mid-request and `TenantContext` the\n * tenant, so permissions loaded for one identity or tenant never answer for another. Keying by the\n * object (not by id or a fingerprint) means two identities with the same id but a different\n * context never share an entry (R69). A failed load is evicted, so the next check retries.\n */\nexport class AuthorizationContext implements Abstraction.Interface {\n private permissionsByIdentity = new WeakMap<Identity, PermissionsByTenant>();\n /*\n * `withoutAuthorization()` and `withAuthorization()` switch authorization on or off for their\n * callback's async call chain only.\n */\n private readonly authorizationEnabledOverrides = new AsyncLocalStorage<boolean>();\n\n constructor(\n private getAuthorizers: () => Authorizer.Interface[],\n private getTransformers: () => PermissionTransformer.Interface[],\n private getTenantId: () => string | null\n ) {}\n\n loadPermissions(identity: Identity): Promise<SecurityPermission[]> {\n let byTenant = this.permissionsByIdentity.get(identity);\n if (!byTenant) {\n byTenant = new Map();\n this.permissionsByIdentity.set(identity, byTenant);\n }\n\n const tenantKey = this.getTenantId() ?? NO_TENANT;\n const cached = byTenant.get(tenantKey);\n if (cached) {\n return cached;\n }\n\n const loader = this.authorize(identity);\n byTenant.set(tenantKey, loader);\n const cache = byTenant;\n loader.catch(() => {\n if (cache.get(tenantKey) === loader) {\n cache.delete(tenantKey);\n }\n });\n return loader;\n }\n\n isAuthorizationEnabled(): boolean {\n const override = this.authorizationEnabledOverrides.getStore();\n return override ?? true;\n }\n\n withoutAuthorization<T>(cb: () => Promise<T>): Promise<T> {\n return this.authorizationEnabledOverrides.run(false, cb);\n }\n\n withAuthorization<T>(cb: () => Promise<T>): Promise<T> {\n return this.authorizationEnabledOverrides.run(true, cb);\n }\n\n clearPermissionsCache(): void {\n this.permissionsByIdentity = new WeakMap();\n }\n\n private async authorize(identity: Identity): Promise<SecurityPermission[]> {\n // Execute authorizers in sequence until one returns permissions\n const authorizers = this.getAuthorizers();\n for (const authorizer of authorizers) {\n const permissions = await authorizer.authorize(identity);\n if (Array.isArray(permissions)) {\n return this.transformPermissions(permissions);\n }\n }\n\n // No authorizer returned permissions\n return [];\n }\n\n private transformPermissions(permissions: SecurityPermission[]) {\n const transformers = this.getTransformers();\n if (transformers.length === 0) {\n return this.deduplicatePermissions(permissions);\n }\n\n const transformed = permissions\n .map(permission => {\n // A transformer can return one or multiple permissions, so we flatten the result.\n return transformers.map(t => t.execute(permission)).flat();\n })\n .flat();\n\n return this.deduplicatePermissions(transformed);\n }\n\n private deduplicatePermissions(permissions: SecurityPermission[]) {\n const seen = new Set<string>();\n\n return permissions.filter(permission => {\n const key = JSON.stringify(permission);\n if (seen.has(key)) {\n return false;\n }\n seen.add(key);\n return true;\n });\n }\n}\n"],"names":["NO_TENANT","AuthorizationContext","getAuthorizers","getTransformers","getTenantId","WeakMap","AsyncLocalStorage","identity","byTenant","Map","tenantKey","cached","loader","cache","override","cb","authorizers","authorizer","permissions","Array","transformers","transformed","permission","t","seen","Set","key","JSON"],"mappings":";AAOA,MAAMA,YAAY;AAWX,MAAMC;IAQT,YACYC,cAA4C,EAC5CC,eAAwD,EACxDC,WAAgC,CAC1C;aAHUF,cAAc,GAAdA;aACAC,eAAe,GAAfA;aACAC,WAAW,GAAXA;aAVJ,qBAAqB,GAAG,IAAIC;QAInC,KACgB,6BAA6B,GAAG,IAAIC;IAMlD;IAEH,gBAAgBC,QAAkB,EAAiC;QAC/D,IAAIC,WAAW,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAACD;QAC9C,IAAI,CAACC,UAAU;YACXA,WAAW,IAAIC;YACf,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAACF,UAAUC;QAC7C;QAEA,MAAME,YAAY,IAAI,CAAC,WAAW,MAAMV;QACxC,MAAMW,SAASH,SAAS,GAAG,CAACE;QAC5B,IAAIC,QACA,OAAOA;QAGX,MAAMC,SAAS,IAAI,CAAC,SAAS,CAACL;QAC9BC,SAAS,GAAG,CAACE,WAAWE;QACxB,MAAMC,QAAQL;QACdI,OAAO,KAAK,CAAC;YACT,IAAIC,MAAM,GAAG,CAACH,eAAeE,QACzBC,MAAM,MAAM,CAACH;QAErB;QACA,OAAOE;IACX;IAEA,yBAAkC;QAC9B,MAAME,WAAW,IAAI,CAAC,6BAA6B,CAAC,QAAQ;QAC5D,OAAOA,YAAY;IACvB;IAEA,qBAAwBC,EAAoB,EAAc;QACtD,OAAO,IAAI,CAAC,6BAA6B,CAAC,GAAG,CAAC,OAAOA;IACzD;IAEA,kBAAqBA,EAAoB,EAAc;QACnD,OAAO,IAAI,CAAC,6BAA6B,CAAC,GAAG,CAAC,MAAMA;IACxD;IAEA,wBAA8B;QAC1B,IAAI,CAAC,qBAAqB,GAAG,IAAIV;IACrC;IAEA,MAAc,UAAUE,QAAkB,EAAiC;QAEvE,MAAMS,cAAc,IAAI,CAAC,cAAc;QACvC,KAAK,MAAMC,cAAcD,YAAa;YAClC,MAAME,cAAc,MAAMD,WAAW,SAAS,CAACV;YAC/C,IAAIY,MAAM,OAAO,CAACD,cACd,OAAO,IAAI,CAAC,oBAAoB,CAACA;QAEzC;QAGA,OAAO,EAAE;IACb;IAEQ,qBAAqBA,WAAiC,EAAE;QAC5D,MAAME,eAAe,IAAI,CAAC,eAAe;QACzC,IAAIA,AAAwB,MAAxBA,aAAa,MAAM,EACnB,OAAO,IAAI,CAAC,sBAAsB,CAACF;QAGvC,MAAMG,cAAcH,YACf,GAAG,CAACI,CAAAA,aAEMF,aAAa,GAAG,CAACG,CAAAA,IAAKA,EAAE,OAAO,CAACD,aAAa,IAAI,IAE3D,IAAI;QAET,OAAO,IAAI,CAAC,sBAAsB,CAACD;IACvC;IAEQ,uBAAuBH,WAAiC,EAAE;QAC9D,MAAMM,OAAO,IAAIC;QAEjB,OAAOP,YAAY,MAAM,CAACI,CAAAA;YACtB,MAAMI,MAAMC,KAAK,SAAS,CAACL;YAC3B,IAAIE,KAAK,GAAG,CAACE,MACT,OAAO;YAEXF,KAAK,GAAG,CAACE;YACT,OAAO;QACX;IACJ;AACJ"}
|
|
@@ -4,6 +4,8 @@ export interface IAuthorizationContext {
|
|
|
4
4
|
loadPermissions(identity: Identity): Promise<SecurityPermission[]>;
|
|
5
5
|
isAuthorizationEnabled(): boolean;
|
|
6
6
|
withoutAuthorization<T>(cb: () => Promise<T>): Promise<T>;
|
|
7
|
+
/** Runs `cb` with authorization enabled, also inside `withoutAuthorization`. */
|
|
8
|
+
withAuthorization<T>(cb: () => Promise<T>): Promise<T>;
|
|
7
9
|
clearPermissionsCache(): void;
|
|
8
10
|
}
|
|
9
11
|
/** Load and cache security permissions for the current identity. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/security/authorization/AuthorizationContext/abstractions.js","sources":["../../../../../src/features/security/authorization/AuthorizationContext/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { SecurityPermission } from \"~/types/security.js\";\nimport { Identity } from \"~/features/security/IdentityContext/index.js\";\n\nexport interface IAuthorizationContext {\n loadPermissions(identity: Identity): Promise<SecurityPermission[]>;\n isAuthorizationEnabled(): boolean;\n withoutAuthorization<T>(cb: () => Promise<T>): Promise<T>;\n clearPermissionsCache(): void;\n}\n\n/** Load and cache security permissions for the current identity. */\nexport const AuthorizationContext =\n createAbstraction<IAuthorizationContext>(\"AuthorizationContext\");\n\nexport namespace AuthorizationContext {\n export type Interface = IAuthorizationContext;\n}\n\nexport interface IPermissionTransformer {\n execute(permission: SecurityPermission): SecurityPermission | SecurityPermission[];\n}\n\n/** Transform security permissions before they are applied. */\nexport const PermissionTransformer =\n createAbstraction<IPermissionTransformer>(\"PermissionTransformer\");\n\nexport namespace PermissionTransformer {\n export type Interface = IPermissionTransformer;\n export type Permission = SecurityPermission;\n export type Return = SecurityPermission | SecurityPermission[];\n}\n"],"names":["AuthorizationContext","createAbstraction","PermissionTransformer"],"mappings":";
|
|
1
|
+
{"version":3,"file":"features/security/authorization/AuthorizationContext/abstractions.js","sources":["../../../../../src/features/security/authorization/AuthorizationContext/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { SecurityPermission } from \"~/types/security.js\";\nimport { Identity } from \"~/features/security/IdentityContext/index.js\";\n\nexport interface IAuthorizationContext {\n loadPermissions(identity: Identity): Promise<SecurityPermission[]>;\n isAuthorizationEnabled(): boolean;\n withoutAuthorization<T>(cb: () => Promise<T>): Promise<T>;\n /** Runs `cb` with authorization enabled, also inside `withoutAuthorization`. */\n withAuthorization<T>(cb: () => Promise<T>): Promise<T>;\n clearPermissionsCache(): void;\n}\n\n/** Load and cache security permissions for the current identity. */\nexport const AuthorizationContext =\n createAbstraction<IAuthorizationContext>(\"AuthorizationContext\");\n\nexport namespace AuthorizationContext {\n export type Interface = IAuthorizationContext;\n}\n\nexport interface IPermissionTransformer {\n execute(permission: SecurityPermission): SecurityPermission | SecurityPermission[];\n}\n\n/** Transform security permissions before they are applied. */\nexport const PermissionTransformer =\n createAbstraction<IPermissionTransformer>(\"PermissionTransformer\");\n\nexport namespace PermissionTransformer {\n export type Interface = IPermissionTransformer;\n export type Permission = SecurityPermission;\n export type Return = SecurityPermission | SecurityPermission[];\n}\n"],"names":["AuthorizationContext","createAbstraction","PermissionTransformer"],"mappings":";AAcO,MAAMA,uBACTC,kBAAyC;AAWtC,MAAMC,wBACTD,kBAA0C"}
|
|
@@ -2,12 +2,17 @@ import { createFeature } from "@webiny/feature/api";
|
|
|
2
2
|
import { AuthorizationContext } from "./AuthorizationContext.js";
|
|
3
3
|
import { AuthorizationContext as external_abstractions_js_AuthorizationContext, PermissionTransformer } from "./abstractions.js";
|
|
4
4
|
import { Authorizer } from "../Authorizer/index.js";
|
|
5
|
+
import { TenantContext } from "../../../tenancy/TenantContext/index.js";
|
|
5
6
|
const AuthorizationContextFeature = createFeature({
|
|
6
7
|
name: "AuthorizationContext",
|
|
7
8
|
register (container) {
|
|
8
9
|
const getAuthorizers = ()=>container.resolveAll(Authorizer);
|
|
9
10
|
const getTransformers = ()=>container.resolveAll(PermissionTransformer);
|
|
10
|
-
const
|
|
11
|
+
const getTenantId = ()=>{
|
|
12
|
+
const tenantContext = container.resolveAll(TenantContext).at(-1);
|
|
13
|
+
return tenantContext?.getTenant()?.id ?? null;
|
|
14
|
+
};
|
|
15
|
+
const authorizationContext = new AuthorizationContext(getAuthorizers, getTransformers, getTenantId);
|
|
11
16
|
container.registerInstance(external_abstractions_js_AuthorizationContext, authorizationContext);
|
|
12
17
|
}
|
|
13
18
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/security/authorization/AuthorizationContext/feature.js","sources":["../../../../../src/features/security/authorization/AuthorizationContext/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { AuthorizationContext } from \"./AuthorizationContext.js\";\nimport { AuthorizationContext as Abstraction, PermissionTransformer } from \"./abstractions.js\";\nimport { Authorizer } from \"~/features/security/authorization/Authorizer/index.js\";\n\nexport const AuthorizationContextFeature = createFeature({\n name: \"AuthorizationContext\",\n register(container) {\n const getAuthorizers = () => container.resolveAll(Authorizer);\n const getTransformers = () => container.resolveAll(PermissionTransformer);\n\n const authorizationContext = new AuthorizationContext(getAuthorizers
|
|
1
|
+
{"version":3,"file":"features/security/authorization/AuthorizationContext/feature.js","sources":["../../../../../src/features/security/authorization/AuthorizationContext/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { AuthorizationContext } from \"./AuthorizationContext.js\";\nimport { AuthorizationContext as Abstraction, PermissionTransformer } from \"./abstractions.js\";\nimport { Authorizer } from \"~/features/security/authorization/Authorizer/index.js\";\nimport { TenantContext } from \"~/features/tenancy/TenantContext/index.js\";\n\nexport const AuthorizationContextFeature = createFeature({\n name: \"AuthorizationContext\",\n register(container) {\n const getAuthorizers = () => container.resolveAll(Authorizer);\n const getTransformers = () => container.resolveAll(PermissionTransformer);\n // Read lazily: the tenant is set after registration, and slim test containers have none\n // (`resolve` would throw there). The last registration is the one `resolve` returns, so a\n // project override wins over the platform's.\n const getTenantId = (): string | null => {\n const tenantContext = container.resolveAll(TenantContext).at(-1);\n return tenantContext?.getTenant()?.id ?? null;\n };\n\n const authorizationContext = new AuthorizationContext(\n getAuthorizers,\n getTransformers,\n getTenantId\n );\n\n container.registerInstance(Abstraction, authorizationContext);\n }\n});\n"],"names":["AuthorizationContextFeature","createFeature","container","getAuthorizers","Authorizer","getTransformers","PermissionTransformer","getTenantId","tenantContext","TenantContext","authorizationContext","AuthorizationContext","Abstraction"],"mappings":";;;;;AAMO,MAAMA,8BAA8BC,cAAc;IACrD,MAAM;IACN,UAASC,SAAS;QACd,MAAMC,iBAAiB,IAAMD,UAAU,UAAU,CAACE;QAClD,MAAMC,kBAAkB,IAAMH,UAAU,UAAU,CAACI;QAInD,MAAMC,cAAc;YAChB,MAAMC,gBAAgBN,UAAU,UAAU,CAACO,eAAe,EAAE,CAAC;YAC7D,OAAOD,eAAe,aAAa,MAAM;QAC7C;QAEA,MAAME,uBAAuB,IAAIC,qBAC7BR,gBACAE,iBACAE;QAGJL,UAAU,gBAAgB,CAACU,+CAAaF;IAC5C;AACJ"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RoleAfterCreateEventHandler } from "../../../../features/security/roles/CreateRole/index.js";
|
|
2
|
+
import { NotifyRecordChangeUseCase } from "../../../../features/websockets/index.js";
|
|
3
|
+
declare class NotifyOnRoleCreatedHandlerImpl implements RoleAfterCreateEventHandler.Interface {
|
|
4
|
+
private notifyRecordChange;
|
|
5
|
+
constructor(notifyRecordChange: NotifyRecordChangeUseCase.Interface);
|
|
6
|
+
handle(event: RoleAfterCreateEventHandler.Event): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const NotifyOnRoleCreatedHandler: typeof NotifyOnRoleCreatedHandlerImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../../eventPublisher/abstractions.js").IEventHandler<import("~/features/security/roles/CreateRole/index.js").RoleAfterCreateEvent>>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RoleAfterCreateEventHandler } from "../CreateRole/index.js";
|
|
2
|
+
import { NotifyRecordChangeUseCase } from "../../../websockets/index.js";
|
|
3
|
+
import { ROLE_RECORD_TYPE } from "./recordType.js";
|
|
4
|
+
class NotifyOnRoleCreatedHandlerImpl {
|
|
5
|
+
constructor(notifyRecordChange){
|
|
6
|
+
this.notifyRecordChange = notifyRecordChange;
|
|
7
|
+
}
|
|
8
|
+
async handle(event) {
|
|
9
|
+
await this.notifyRecordChange.execute({
|
|
10
|
+
type: ROLE_RECORD_TYPE,
|
|
11
|
+
id: event.payload.role.id,
|
|
12
|
+
change: "created"
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const NotifyOnRoleCreatedHandler = RoleAfterCreateEventHandler.createImplementation({
|
|
17
|
+
implementation: NotifyOnRoleCreatedHandlerImpl,
|
|
18
|
+
dependencies: [
|
|
19
|
+
NotifyRecordChangeUseCase
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
export { NotifyOnRoleCreatedHandler };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=NotifyOnRoleCreatedHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/security/roles/NotifyRoleChange/NotifyOnRoleCreatedHandler.js","sources":["../../../../../src/features/security/roles/NotifyRoleChange/NotifyOnRoleCreatedHandler.ts"],"sourcesContent":["import { RoleAfterCreateEventHandler } from \"~/features/security/roles/CreateRole/index.js\";\nimport { NotifyRecordChangeUseCase } from \"~/features/websockets/index.js\";\nimport { ROLE_RECORD_TYPE } from \"./recordType.js\";\n\nclass NotifyOnRoleCreatedHandlerImpl implements RoleAfterCreateEventHandler.Interface {\n constructor(private notifyRecordChange: NotifyRecordChangeUseCase.Interface) {}\n\n async handle(event: RoleAfterCreateEventHandler.Event): Promise<void> {\n await this.notifyRecordChange.execute({\n type: ROLE_RECORD_TYPE,\n id: event.payload.role.id,\n change: \"created\"\n });\n }\n}\n\nexport const NotifyOnRoleCreatedHandler = RoleAfterCreateEventHandler.createImplementation({\n implementation: NotifyOnRoleCreatedHandlerImpl,\n dependencies: [NotifyRecordChangeUseCase]\n});\n"],"names":["NotifyOnRoleCreatedHandlerImpl","notifyRecordChange","event","ROLE_RECORD_TYPE","NotifyOnRoleCreatedHandler","RoleAfterCreateEventHandler","NotifyRecordChangeUseCase"],"mappings":";;;AAIA,MAAMA;IACF,YAAoBC,kBAAuD,CAAE;aAAzDA,kBAAkB,GAAlBA;IAA0D;IAE9E,MAAM,OAAOC,KAAwC,EAAiB;QAClE,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YAClC,MAAMC;YACN,IAAID,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE;YACzB,QAAQ;QACZ;IACJ;AACJ;AAEO,MAAME,6BAA6BC,4BAA4B,oBAAoB,CAAC;IACvF,gBAAgBL;IAChB,cAAc;QAACM;KAA0B;AAC7C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RoleAfterDeleteEventHandler } from "../../../../features/security/roles/DeleteRole/index.js";
|
|
2
|
+
import { NotifyRecordChangeUseCase } from "../../../../features/websockets/index.js";
|
|
3
|
+
declare class NotifyOnRoleDeletedHandlerImpl implements RoleAfterDeleteEventHandler.Interface {
|
|
4
|
+
private notifyRecordChange;
|
|
5
|
+
constructor(notifyRecordChange: NotifyRecordChangeUseCase.Interface);
|
|
6
|
+
handle(event: RoleAfterDeleteEventHandler.Event): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const NotifyOnRoleDeletedHandler: typeof NotifyOnRoleDeletedHandlerImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../../eventPublisher/abstractions.js").IEventHandler<import("~/features/security/roles/DeleteRole/index.js").RoleAfterDeleteEvent>>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RoleAfterDeleteEventHandler } from "../DeleteRole/index.js";
|
|
2
|
+
import { NotifyRecordChangeUseCase } from "../../../websockets/index.js";
|
|
3
|
+
import { ROLE_RECORD_TYPE } from "./recordType.js";
|
|
4
|
+
class NotifyOnRoleDeletedHandlerImpl {
|
|
5
|
+
constructor(notifyRecordChange){
|
|
6
|
+
this.notifyRecordChange = notifyRecordChange;
|
|
7
|
+
}
|
|
8
|
+
async handle(event) {
|
|
9
|
+
await this.notifyRecordChange.execute({
|
|
10
|
+
type: ROLE_RECORD_TYPE,
|
|
11
|
+
id: event.payload.role.id,
|
|
12
|
+
change: "deleted"
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const NotifyOnRoleDeletedHandler = RoleAfterDeleteEventHandler.createImplementation({
|
|
17
|
+
implementation: NotifyOnRoleDeletedHandlerImpl,
|
|
18
|
+
dependencies: [
|
|
19
|
+
NotifyRecordChangeUseCase
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
export { NotifyOnRoleDeletedHandler };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=NotifyOnRoleDeletedHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/security/roles/NotifyRoleChange/NotifyOnRoleDeletedHandler.js","sources":["../../../../../src/features/security/roles/NotifyRoleChange/NotifyOnRoleDeletedHandler.ts"],"sourcesContent":["import { RoleAfterDeleteEventHandler } from \"~/features/security/roles/DeleteRole/index.js\";\nimport { NotifyRecordChangeUseCase } from \"~/features/websockets/index.js\";\nimport { ROLE_RECORD_TYPE } from \"./recordType.js\";\n\nclass NotifyOnRoleDeletedHandlerImpl implements RoleAfterDeleteEventHandler.Interface {\n constructor(private notifyRecordChange: NotifyRecordChangeUseCase.Interface) {}\n\n async handle(event: RoleAfterDeleteEventHandler.Event): Promise<void> {\n await this.notifyRecordChange.execute({\n type: ROLE_RECORD_TYPE,\n id: event.payload.role.id,\n change: \"deleted\"\n });\n }\n}\n\nexport const NotifyOnRoleDeletedHandler = RoleAfterDeleteEventHandler.createImplementation({\n implementation: NotifyOnRoleDeletedHandlerImpl,\n dependencies: [NotifyRecordChangeUseCase]\n});\n"],"names":["NotifyOnRoleDeletedHandlerImpl","notifyRecordChange","event","ROLE_RECORD_TYPE","NotifyOnRoleDeletedHandler","RoleAfterDeleteEventHandler","NotifyRecordChangeUseCase"],"mappings":";;;AAIA,MAAMA;IACF,YAAoBC,kBAAuD,CAAE;aAAzDA,kBAAkB,GAAlBA;IAA0D;IAE9E,MAAM,OAAOC,KAAwC,EAAiB;QAClE,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YAClC,MAAMC;YACN,IAAID,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE;YACzB,QAAQ;QACZ;IACJ;AACJ;AAEO,MAAME,6BAA6BC,4BAA4B,oBAAoB,CAAC;IACvF,gBAAgBL;IAChB,cAAc;QAACM;KAA0B;AAC7C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RoleAfterUpdateEventHandler } from "../../../../features/security/roles/UpdateRole/index.js";
|
|
2
|
+
import { NotifyRecordChangeUseCase } from "../../../../features/websockets/index.js";
|
|
3
|
+
declare class NotifyOnRoleUpdatedHandlerImpl implements RoleAfterUpdateEventHandler.Interface {
|
|
4
|
+
private notifyRecordChange;
|
|
5
|
+
constructor(notifyRecordChange: NotifyRecordChangeUseCase.Interface);
|
|
6
|
+
handle(event: RoleAfterUpdateEventHandler.Event): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const NotifyOnRoleUpdatedHandler: typeof NotifyOnRoleUpdatedHandlerImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../../eventPublisher/abstractions.js").IEventHandler<import("~/features/security/roles/UpdateRole/index.js").RoleAfterUpdateEvent>>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RoleAfterUpdateEventHandler } from "../UpdateRole/index.js";
|
|
2
|
+
import { NotifyRecordChangeUseCase } from "../../../websockets/index.js";
|
|
3
|
+
import { ROLE_RECORD_TYPE } from "./recordType.js";
|
|
4
|
+
class NotifyOnRoleUpdatedHandlerImpl {
|
|
5
|
+
constructor(notifyRecordChange){
|
|
6
|
+
this.notifyRecordChange = notifyRecordChange;
|
|
7
|
+
}
|
|
8
|
+
async handle(event) {
|
|
9
|
+
await this.notifyRecordChange.execute({
|
|
10
|
+
type: ROLE_RECORD_TYPE,
|
|
11
|
+
id: event.payload.updated.id,
|
|
12
|
+
change: "updated"
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const NotifyOnRoleUpdatedHandler = RoleAfterUpdateEventHandler.createImplementation({
|
|
17
|
+
implementation: NotifyOnRoleUpdatedHandlerImpl,
|
|
18
|
+
dependencies: [
|
|
19
|
+
NotifyRecordChangeUseCase
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
export { NotifyOnRoleUpdatedHandler };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=NotifyOnRoleUpdatedHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/security/roles/NotifyRoleChange/NotifyOnRoleUpdatedHandler.js","sources":["../../../../../src/features/security/roles/NotifyRoleChange/NotifyOnRoleUpdatedHandler.ts"],"sourcesContent":["import { RoleAfterUpdateEventHandler } from \"~/features/security/roles/UpdateRole/index.js\";\nimport { NotifyRecordChangeUseCase } from \"~/features/websockets/index.js\";\nimport { ROLE_RECORD_TYPE } from \"./recordType.js\";\n\nclass NotifyOnRoleUpdatedHandlerImpl implements RoleAfterUpdateEventHandler.Interface {\n constructor(private notifyRecordChange: NotifyRecordChangeUseCase.Interface) {}\n\n async handle(event: RoleAfterUpdateEventHandler.Event): Promise<void> {\n await this.notifyRecordChange.execute({\n type: ROLE_RECORD_TYPE,\n id: event.payload.updated.id,\n change: \"updated\"\n });\n }\n}\n\nexport const NotifyOnRoleUpdatedHandler = RoleAfterUpdateEventHandler.createImplementation({\n implementation: NotifyOnRoleUpdatedHandlerImpl,\n dependencies: [NotifyRecordChangeUseCase]\n});\n"],"names":["NotifyOnRoleUpdatedHandlerImpl","notifyRecordChange","event","ROLE_RECORD_TYPE","NotifyOnRoleUpdatedHandler","RoleAfterUpdateEventHandler","NotifyRecordChangeUseCase"],"mappings":";;;AAIA,MAAMA;IACF,YAAoBC,kBAAuD,CAAE;aAAzDA,kBAAkB,GAAlBA;IAA0D;IAE9E,MAAM,OAAOC,KAAwC,EAAiB;QAClE,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YAClC,MAAMC;YACN,IAAID,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE;YAC5B,QAAQ;QACZ;IACJ;AACJ;AAEO,MAAME,6BAA6BC,4BAA4B,oBAAoB,CAAC;IACvF,gBAAgBL;IAChB,cAAc;QAACM;KAA0B;AAC7C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { NotifyOnRoleCreatedHandler } from "./NotifyOnRoleCreatedHandler.js";
|
|
3
|
+
import { NotifyOnRoleUpdatedHandler } from "./NotifyOnRoleUpdatedHandler.js";
|
|
4
|
+
import { NotifyOnRoleDeletedHandler } from "./NotifyOnRoleDeletedHandler.js";
|
|
5
|
+
const NotifyRoleChangeFeature = createFeature({
|
|
6
|
+
name: "NotifyRoleChange",
|
|
7
|
+
register (container) {
|
|
8
|
+
container.register(NotifyOnRoleCreatedHandler);
|
|
9
|
+
container.register(NotifyOnRoleUpdatedHandler);
|
|
10
|
+
container.register(NotifyOnRoleDeletedHandler);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export { NotifyRoleChangeFeature };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/security/roles/NotifyRoleChange/feature.js","sources":["../../../../../src/features/security/roles/NotifyRoleChange/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { NotifyOnRoleCreatedHandler } from \"./NotifyOnRoleCreatedHandler.js\";\nimport { NotifyOnRoleUpdatedHandler } from \"./NotifyOnRoleUpdatedHandler.js\";\nimport { NotifyOnRoleDeletedHandler } from \"./NotifyOnRoleDeletedHandler.js\";\n\n/** Tells the user's open admin tabs when a role is created, updated or deleted. */\nexport const NotifyRoleChangeFeature = createFeature({\n name: \"NotifyRoleChange\",\n register(container) {\n container.register(NotifyOnRoleCreatedHandler);\n container.register(NotifyOnRoleUpdatedHandler);\n container.register(NotifyOnRoleDeletedHandler);\n }\n});\n"],"names":["NotifyRoleChangeFeature","createFeature","container","NotifyOnRoleCreatedHandler","NotifyOnRoleUpdatedHandler","NotifyOnRoleDeletedHandler"],"mappings":";;;;AAMO,MAAMA,0BAA0BC,cAAc;IACjD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;IACvB;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/security/roles/NotifyRoleChange/recordType.js","sources":["../../../../../src/features/security/roles/NotifyRoleChange/recordType.ts"],"sourcesContent":["/**\n * The `type` of the record-changed message sent when a role changes. The admin's\n * `ApplyRoleChangeToCache` filters on the same string.\n */\nexport const ROLE_RECORD_TYPE = \"security.role\";\n"],"names":["ROLE_RECORD_TYPE"],"mappings":"AAIO,MAAMA,mBAAmB"}
|
|
@@ -6,6 +6,7 @@ import { EventPublisher } from "../../../eventPublisher/index.js";
|
|
|
6
6
|
import { updateRoleValidation } from "./schema.js";
|
|
7
7
|
import { RoleAfterUpdateEvent, RoleBeforeUpdateEvent } from "./events.js";
|
|
8
8
|
import { descriptionOnUpdate } from "../../shared/description.js";
|
|
9
|
+
import { definedOnly } from "../../shared/definedOnly.js";
|
|
9
10
|
import { CannotUpdatePluginRolesError, NotAuthorizedError, RoleValidationError } from "../shared/errors.js";
|
|
10
11
|
class UpdateRoleUseCaseImpl {
|
|
11
12
|
constructor(repository, identityContext, eventPublisher){
|
|
@@ -26,7 +27,7 @@ class UpdateRoleUseCaseImpl {
|
|
|
26
27
|
if (existingRole.plugin) return Result.fail(new CannotUpdatePluginRolesError());
|
|
27
28
|
const { description, ...rest } = validation.data;
|
|
28
29
|
const changes = {
|
|
29
|
-
...rest,
|
|
30
|
+
...definedOnly(rest),
|
|
30
31
|
...descriptionOnUpdate(description)
|
|
31
32
|
};
|
|
32
33
|
const updatedRole = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/security/roles/UpdateRole/UpdateRoleUseCase.js","sources":["../../../../../src/features/security/roles/UpdateRole/UpdateRoleUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateRoleUseCase as UseCase } from \"./abstractions.js\";\nimport { RolesRepository } from \"../shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { updateRoleValidation } from \"./schema.js\";\nimport { RoleBeforeUpdateEvent, RoleAfterUpdateEvent } from \"./events.js\";\nimport type { Role, UpdateRoleInput } from \"../shared/types.js\";\nimport { descriptionOnUpdate } from \"../../shared/description.js\";\nimport {\n NotAuthorizedError,\n CannotUpdatePluginRolesError,\n RoleValidationError\n} from \"../shared/errors.js\";\n\nclass UpdateRoleUseCaseImpl implements UseCase.Interface {\n private repository: RolesRepository.Interface;\n private identityContext: IdentityContext.Interface;\n private eventPublisher: EventPublisher.Interface;\n\n constructor(\n repository: RolesRepository.Interface,\n identityContext: IdentityContext.Interface,\n eventPublisher: EventPublisher.Interface\n ) {\n this.repository = repository;\n this.identityContext = identityContext;\n this.eventPublisher = eventPublisher;\n }\n\n async execute(id: string, input: UpdateRoleInput): Promise<Result<Role, UseCase.Error>> {\n const hasPermission = await this.identityContext.getPermission(\"security.role\");\n if (!hasPermission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n const validation = updateRoleValidation.safeParse(input);\n if (!validation.success) {\n return Result.fail(new RoleValidationError(validation.error.issues[0].message));\n }\n\n const existingResult = await this.repository.get({ id });\n if (existingResult.isFail()) {\n return Result.fail(existingResult.error);\n }\n\n const existingRole = existingResult.value;\n\n // Check if role is created via plugin\n if (existingRole.plugin) {\n return Result.fail(new CannotUpdatePluginRolesError());\n }\n\n // `description` is pulled out of the spread because it is the one field that accepts null.\n // Normalising it here keeps null out of both the entity and the published events, whose\n // input type declares `description?: string`.\n const { description, ...rest } = validation.data;\n\n const changes: UpdateRoleInput = {\n ...rest,\n ...descriptionOnUpdate(description)\n };\n\n const updatedRole: Role = {\n ...existingRole,\n ...changes\n };\n\n await this.eventPublisher.publish(\n new RoleBeforeUpdateEvent({\n original: existingRole,\n updated: updatedRole,\n input: changes\n })\n );\n\n const result = await this.repository.update(updatedRole);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new RoleAfterUpdateEvent({\n original: existingRole,\n updated: updatedRole,\n input: changes\n })\n );\n\n return Result.ok(updatedRole);\n }\n}\n\nexport const UpdateRoleUseCase = UseCase.createImplementation({\n implementation: UpdateRoleUseCaseImpl,\n dependencies: [RolesRepository, IdentityContext, EventPublisher]\n});\n"],"names":["UpdateRoleUseCaseImpl","repository","identityContext","eventPublisher","id","input","hasPermission","Result","NotAuthorizedError","validation","updateRoleValidation","RoleValidationError","existingResult","existingRole","CannotUpdatePluginRolesError","description","rest","changes","descriptionOnUpdate","updatedRole","RoleBeforeUpdateEvent","result","RoleAfterUpdateEvent","UpdateRoleUseCase","UseCase","RolesRepository","IdentityContext","EventPublisher"],"mappings":"
|
|
1
|
+
{"version":3,"file":"features/security/roles/UpdateRole/UpdateRoleUseCase.js","sources":["../../../../../src/features/security/roles/UpdateRole/UpdateRoleUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateRoleUseCase as UseCase } from \"./abstractions.js\";\nimport { RolesRepository } from \"../shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { updateRoleValidation } from \"./schema.js\";\nimport { RoleBeforeUpdateEvent, RoleAfterUpdateEvent } from \"./events.js\";\nimport type { Role, UpdateRoleInput } from \"../shared/types.js\";\nimport { descriptionOnUpdate } from \"../../shared/description.js\";\nimport { definedOnly } from \"../../shared/definedOnly.js\";\nimport {\n NotAuthorizedError,\n CannotUpdatePluginRolesError,\n RoleValidationError\n} from \"../shared/errors.js\";\n\nclass UpdateRoleUseCaseImpl implements UseCase.Interface {\n private repository: RolesRepository.Interface;\n private identityContext: IdentityContext.Interface;\n private eventPublisher: EventPublisher.Interface;\n\n constructor(\n repository: RolesRepository.Interface,\n identityContext: IdentityContext.Interface,\n eventPublisher: EventPublisher.Interface\n ) {\n this.repository = repository;\n this.identityContext = identityContext;\n this.eventPublisher = eventPublisher;\n }\n\n async execute(id: string, input: UpdateRoleInput): Promise<Result<Role, UseCase.Error>> {\n const hasPermission = await this.identityContext.getPermission(\"security.role\");\n if (!hasPermission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n const validation = updateRoleValidation.safeParse(input);\n if (!validation.success) {\n return Result.fail(new RoleValidationError(validation.error.issues[0].message));\n }\n\n const existingResult = await this.repository.get({ id });\n if (existingResult.isFail()) {\n return Result.fail(existingResult.error);\n }\n\n const existingRole = existingResult.value;\n\n // Check if role is created via plugin\n if (existingRole.plugin) {\n return Result.fail(new CannotUpdatePluginRolesError());\n }\n\n // `description` is pulled out of the spread because it is the one field that accepts null.\n // Normalising it here keeps null out of both the entity and the published events, whose\n // input type declares `description?: string`.\n const { description, ...rest } = validation.data;\n\n const changes: UpdateRoleInput = {\n ...definedOnly(rest),\n ...descriptionOnUpdate(description)\n };\n\n const updatedRole: Role = {\n ...existingRole,\n ...changes\n };\n\n await this.eventPublisher.publish(\n new RoleBeforeUpdateEvent({\n original: existingRole,\n updated: updatedRole,\n input: changes\n })\n );\n\n const result = await this.repository.update(updatedRole);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new RoleAfterUpdateEvent({\n original: existingRole,\n updated: updatedRole,\n input: changes\n })\n );\n\n return Result.ok(updatedRole);\n }\n}\n\nexport const UpdateRoleUseCase = UseCase.createImplementation({\n implementation: UpdateRoleUseCaseImpl,\n dependencies: [RolesRepository, IdentityContext, EventPublisher]\n});\n"],"names":["UpdateRoleUseCaseImpl","repository","identityContext","eventPublisher","id","input","hasPermission","Result","NotAuthorizedError","validation","updateRoleValidation","RoleValidationError","existingResult","existingRole","CannotUpdatePluginRolesError","description","rest","changes","definedOnly","descriptionOnUpdate","updatedRole","RoleBeforeUpdateEvent","result","RoleAfterUpdateEvent","UpdateRoleUseCase","UseCase","RolesRepository","IdentityContext","EventPublisher"],"mappings":";;;;;;;;;;AAgBA,MAAMA;IAKF,YACIC,UAAqC,EACrCC,eAA0C,EAC1CC,cAAwC,CAC1C;QACE,IAAI,CAAC,UAAU,GAAGF;QAClB,IAAI,CAAC,eAAe,GAAGC;QACvB,IAAI,CAAC,cAAc,GAAGC;IAC1B;IAEA,MAAM,QAAQC,EAAU,EAAEC,KAAsB,EAAwC;QACpF,MAAMC,gBAAgB,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;QAC/D,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,aAAaC,qBAAqB,SAAS,CAACL;QAClD,IAAI,CAACI,WAAW,OAAO,EACnB,OAAOF,OAAO,IAAI,CAAC,IAAII,oBAAoBF,WAAW,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO;QAGjF,MAAMG,iBAAiB,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAER;QAAG;QACtD,IAAIQ,eAAe,MAAM,IACrB,OAAOL,OAAO,IAAI,CAACK,eAAe,KAAK;QAG3C,MAAMC,eAAeD,eAAe,KAAK;QAGzC,IAAIC,aAAa,MAAM,EACnB,OAAON,OAAO,IAAI,CAAC,IAAIO;QAM3B,MAAM,EAAEC,WAAW,EAAE,GAAGC,MAAM,GAAGP,WAAW,IAAI;QAEhD,MAAMQ,UAA2B;YAC7B,GAAGC,YAAYF,KAAK;YACpB,GAAGG,oBAAoBJ,YAAY;QACvC;QAEA,MAAMK,cAAoB;YACtB,GAAGP,YAAY;YACf,GAAGI,OAAO;QACd;QAEA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAII,sBAAsB;YACtB,UAAUR;YACV,SAASO;YACT,OAAOH;QACX;QAGJ,MAAMK,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACF;QAE5C,IAAIE,OAAO,MAAM,IACb,OAAOf,OAAO,IAAI,CAACe,OAAO,KAAK;QAGnC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,qBAAqB;YACrB,UAAUV;YACV,SAASO;YACT,OAAOH;QACX;QAGJ,OAAOV,OAAO,EAAE,CAACa;IACrB;AACJ;AAEO,MAAMI,sCAAoBC,kBAAAA,oBAA4B,CAAC;IAC1D,gBAAgBzB;IAChB,cAAc;QAAC0B;QAAiBC;QAAiBC;KAAe;AACpE"}
|
|
@@ -7,6 +7,7 @@ import { ListRolesFeature } from "./ListRoles/feature.js";
|
|
|
7
7
|
import { CreateRoleFeature } from "./CreateRole/feature.js";
|
|
8
8
|
import { UpdateRoleFeature } from "./UpdateRole/feature.js";
|
|
9
9
|
import { DeleteRoleFeature } from "./DeleteRole/feature.js";
|
|
10
|
+
import { NotifyRoleChangeFeature } from "./NotifyRoleChange/index.js";
|
|
10
11
|
import { RoleInstaller } from "./Installer/RolesInstaller.js";
|
|
11
12
|
const RolesFeature = createFeature({
|
|
12
13
|
name: "Roles",
|
|
@@ -19,6 +20,7 @@ const RolesFeature = createFeature({
|
|
|
19
20
|
CreateRoleFeature.register(container);
|
|
20
21
|
UpdateRoleFeature.register(container);
|
|
21
22
|
DeleteRoleFeature.register(container);
|
|
23
|
+
NotifyRoleChangeFeature.register(container);
|
|
22
24
|
container.register(RoleInstaller);
|
|
23
25
|
}
|
|
24
26
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/security/roles/feature.js","sources":["../../../../src/features/security/roles/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { RolesRepository } from \"./shared/RolesRepository.js\";\nimport { RoleProvider } from \"./shared/RoleProvider.js\";\nimport { RolesRepositoryCachingDecorator } from \"./shared/decorators/RolesRepositoryCachingDecorator.js\";\nimport { GetRoleFeature } from \"./GetRole/feature.js\";\nimport { ListRolesFeature } from \"./ListRoles/feature.js\";\nimport { CreateRoleFeature } from \"./CreateRole/feature.js\";\nimport { UpdateRoleFeature } from \"./UpdateRole/feature.js\";\nimport { DeleteRoleFeature } from \"./DeleteRole/feature.js\";\nimport { RoleInstaller } from \"~/features/security/roles/Installer/RolesInstaller.js\";\n\nexport const RolesFeature = createFeature({\n name: \"Roles\",\n register(container) {\n // Register repository in singleton scope\n container.register(RolesRepository).inSingletonScope();\n container.register(RoleProvider).inSingletonScope();\n\n // Register caching decorator\n container.registerDecorator(RolesRepositoryCachingDecorator);\n\n // Register all use cases\n GetRoleFeature.register(container);\n ListRolesFeature.register(container);\n CreateRoleFeature.register(container);\n UpdateRoleFeature.register(container);\n DeleteRoleFeature.register(container);\n\n container.register(RoleInstaller);\n }\n});\n"],"names":["RolesFeature","createFeature","container","RolesRepository","RoleProvider","RolesRepositoryCachingDecorator","GetRoleFeature","ListRolesFeature","CreateRoleFeature","UpdateRoleFeature","DeleteRoleFeature","RoleInstaller"],"mappings":"
|
|
1
|
+
{"version":3,"file":"features/security/roles/feature.js","sources":["../../../../src/features/security/roles/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { RolesRepository } from \"./shared/RolesRepository.js\";\nimport { RoleProvider } from \"./shared/RoleProvider.js\";\nimport { RolesRepositoryCachingDecorator } from \"./shared/decorators/RolesRepositoryCachingDecorator.js\";\nimport { GetRoleFeature } from \"./GetRole/feature.js\";\nimport { ListRolesFeature } from \"./ListRoles/feature.js\";\nimport { CreateRoleFeature } from \"./CreateRole/feature.js\";\nimport { UpdateRoleFeature } from \"./UpdateRole/feature.js\";\nimport { DeleteRoleFeature } from \"./DeleteRole/feature.js\";\nimport { NotifyRoleChangeFeature } from \"./NotifyRoleChange/index.js\";\nimport { RoleInstaller } from \"~/features/security/roles/Installer/RolesInstaller.js\";\n\nexport const RolesFeature = createFeature({\n name: \"Roles\",\n register(container) {\n // Register repository in singleton scope\n container.register(RolesRepository).inSingletonScope();\n container.register(RoleProvider).inSingletonScope();\n\n // Register caching decorator\n container.registerDecorator(RolesRepositoryCachingDecorator);\n\n // Register all use cases\n GetRoleFeature.register(container);\n ListRolesFeature.register(container);\n CreateRoleFeature.register(container);\n UpdateRoleFeature.register(container);\n DeleteRoleFeature.register(container);\n NotifyRoleChangeFeature.register(container);\n\n container.register(RoleInstaller);\n }\n});\n"],"names":["RolesFeature","createFeature","container","RolesRepository","RoleProvider","RolesRepositoryCachingDecorator","GetRoleFeature","ListRolesFeature","CreateRoleFeature","UpdateRoleFeature","DeleteRoleFeature","NotifyRoleChangeFeature","RoleInstaller"],"mappings":";;;;;;;;;;;AAYO,MAAMA,eAAeC,cAAc;IACtC,MAAM;IACN,UAASC,SAAS;QAEdA,UAAU,QAAQ,CAACC,iBAAiB,gBAAgB;QACpDD,UAAU,QAAQ,CAACE,cAAc,gBAAgB;QAGjDF,UAAU,iBAAiB,CAACG;QAG5BC,eAAe,QAAQ,CAACJ;QACxBK,iBAAiB,QAAQ,CAACL;QAC1BM,kBAAkB,QAAQ,CAACN;QAC3BO,kBAAkB,QAAQ,CAACP;QAC3BQ,kBAAkB,QAAQ,CAACR;QAC3BS,wBAAwB,QAAQ,CAACT;QAEjCA,UAAU,QAAQ,CAACU;IACvB;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const definedOnly: <T extends object>(value: T) => Partial<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/security/shared/definedOnly.js","sources":["../../../../src/features/security/shared/definedOnly.ts"],"sourcesContent":["// Drops keys whose value is `undefined`. Zod copies a key the caller sent as `undefined` into the\n// parsed output, so spreading a parsed update onto a stored entity would overwrite that field with\n// `undefined`. To an update, an absent key and an `undefined` one both mean \"leave the field alone\".\nexport const definedOnly = <T extends object>(value: T): Partial<T> => {\n const defined: Partial<T> = {};\n\n // `Object.keys` types its result as `string[]`; these are the keys of `value`.\n for (const key of Object.keys(value) as Array<keyof T>) {\n if (value[key] !== undefined) {\n defined[key] = value[key];\n }\n }\n\n return defined;\n};\n"],"names":["definedOnly","value","defined","key","Object","undefined"],"mappings":"AAGO,MAAMA,cAAc,CAAmBC;IAC1C,MAAMC,UAAsB,CAAC;IAG7B,KAAK,MAAMC,OAAOC,OAAO,IAAI,CAACH,OAC1B,IAAIA,AAAeI,WAAfJ,KAAK,CAACE,IAAI,EACVD,OAAO,CAACC,IAAI,GAAGF,KAAK,CAACE,IAAI;IAIjC,OAAOD;AACX"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { TeamAfterCreateEventHandler } from "../../../../features/security/teams/CreateTeam/index.js";
|
|
2
|
+
import { TeamAfterUpdateEventHandler } from "../../../../features/security/teams/UpdateTeam/index.js";
|
|
3
|
+
import { TeamAfterDeleteEventHandler } from "../../../../features/security/teams/DeleteTeam/index.js";
|
|
4
|
+
import { NotifyRecordChangeUseCase } from "../../../../features/websockets/index.js";
|
|
5
|
+
declare class NotifyOnTeamCreatedHandlerImpl implements TeamAfterCreateEventHandler.Interface {
|
|
6
|
+
private notifyRecordChange;
|
|
7
|
+
constructor(notifyRecordChange: NotifyRecordChangeUseCase.Interface);
|
|
8
|
+
handle(event: TeamAfterCreateEventHandler.Event): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare const NotifyOnTeamCreatedHandler: typeof NotifyOnTeamCreatedHandlerImpl & {
|
|
11
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../../eventPublisher/abstractions.js").IEventHandler<import("../CreateTeam/events.js").TeamAfterCreateEvent>>;
|
|
12
|
+
};
|
|
13
|
+
declare class NotifyOnTeamUpdatedHandlerImpl implements TeamAfterUpdateEventHandler.Interface {
|
|
14
|
+
private notifyRecordChange;
|
|
15
|
+
constructor(notifyRecordChange: NotifyRecordChangeUseCase.Interface);
|
|
16
|
+
handle(event: TeamAfterUpdateEventHandler.Event): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare const NotifyOnTeamUpdatedHandler: typeof NotifyOnTeamUpdatedHandlerImpl & {
|
|
19
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../../eventPublisher/abstractions.js").IEventHandler<import("~/features/security/teams/UpdateTeam/index.js").TeamAfterUpdateEvent>>;
|
|
20
|
+
};
|
|
21
|
+
declare class NotifyOnTeamDeletedHandlerImpl implements TeamAfterDeleteEventHandler.Interface {
|
|
22
|
+
private notifyRecordChange;
|
|
23
|
+
constructor(notifyRecordChange: NotifyRecordChangeUseCase.Interface);
|
|
24
|
+
handle(event: TeamAfterDeleteEventHandler.Event): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export declare const NotifyOnTeamDeletedHandler: typeof NotifyOnTeamDeletedHandlerImpl & {
|
|
27
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../../eventPublisher/abstractions.js").IEventHandler<import("~/features/security/teams/DeleteTeam/index.js").TeamAfterDeleteEvent>>;
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { TeamAfterCreateEventHandler } from "../CreateTeam/index.js";
|
|
2
|
+
import { TeamAfterUpdateEventHandler } from "../UpdateTeam/index.js";
|
|
3
|
+
import { TeamAfterDeleteEventHandler } from "../DeleteTeam/index.js";
|
|
4
|
+
import { NotifyRecordChangeUseCase } from "../../../websockets/index.js";
|
|
5
|
+
import { TEAM_RECORD_TYPE } from "./recordType.js";
|
|
6
|
+
class NotifyOnTeamCreatedHandlerImpl {
|
|
7
|
+
constructor(notifyRecordChange){
|
|
8
|
+
this.notifyRecordChange = notifyRecordChange;
|
|
9
|
+
}
|
|
10
|
+
async handle(event) {
|
|
11
|
+
await this.notifyRecordChange.execute({
|
|
12
|
+
type: TEAM_RECORD_TYPE,
|
|
13
|
+
id: event.payload.team.id,
|
|
14
|
+
change: "created"
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const NotifyOnTeamCreatedHandler = TeamAfterCreateEventHandler.createImplementation({
|
|
19
|
+
implementation: NotifyOnTeamCreatedHandlerImpl,
|
|
20
|
+
dependencies: [
|
|
21
|
+
NotifyRecordChangeUseCase
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
class NotifyOnTeamUpdatedHandlerImpl {
|
|
25
|
+
constructor(notifyRecordChange){
|
|
26
|
+
this.notifyRecordChange = notifyRecordChange;
|
|
27
|
+
}
|
|
28
|
+
async handle(event) {
|
|
29
|
+
await this.notifyRecordChange.execute({
|
|
30
|
+
type: TEAM_RECORD_TYPE,
|
|
31
|
+
id: event.payload.updated.id,
|
|
32
|
+
change: "updated"
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const NotifyOnTeamUpdatedHandler = TeamAfterUpdateEventHandler.createImplementation({
|
|
37
|
+
implementation: NotifyOnTeamUpdatedHandlerImpl,
|
|
38
|
+
dependencies: [
|
|
39
|
+
NotifyRecordChangeUseCase
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
class NotifyOnTeamDeletedHandlerImpl {
|
|
43
|
+
constructor(notifyRecordChange){
|
|
44
|
+
this.notifyRecordChange = notifyRecordChange;
|
|
45
|
+
}
|
|
46
|
+
async handle(event) {
|
|
47
|
+
await this.notifyRecordChange.execute({
|
|
48
|
+
type: TEAM_RECORD_TYPE,
|
|
49
|
+
id: event.payload.team.id,
|
|
50
|
+
change: "deleted"
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const NotifyOnTeamDeletedHandler = TeamAfterDeleteEventHandler.createImplementation({
|
|
55
|
+
implementation: NotifyOnTeamDeletedHandlerImpl,
|
|
56
|
+
dependencies: [
|
|
57
|
+
NotifyRecordChangeUseCase
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
export { NotifyOnTeamCreatedHandler, NotifyOnTeamDeletedHandler, NotifyOnTeamUpdatedHandler };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=NotifyOnTeamChangeHandlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/security/teams/NotifyTeamChange/NotifyOnTeamChangeHandlers.js","sources":["../../../../../src/features/security/teams/NotifyTeamChange/NotifyOnTeamChangeHandlers.ts"],"sourcesContent":["import { TeamAfterCreateEventHandler } from \"~/features/security/teams/CreateTeam/index.js\";\nimport { TeamAfterUpdateEventHandler } from \"~/features/security/teams/UpdateTeam/index.js\";\nimport { TeamAfterDeleteEventHandler } from \"~/features/security/teams/DeleteTeam/index.js\";\nimport { NotifyRecordChangeUseCase } from \"~/features/websockets/index.js\";\nimport { TEAM_RECORD_TYPE } from \"./recordType.js\";\n\nclass NotifyOnTeamCreatedHandlerImpl implements TeamAfterCreateEventHandler.Interface {\n constructor(private notifyRecordChange: NotifyRecordChangeUseCase.Interface) {}\n\n async handle(event: TeamAfterCreateEventHandler.Event): Promise<void> {\n await this.notifyRecordChange.execute({\n type: TEAM_RECORD_TYPE,\n id: event.payload.team.id,\n change: \"created\"\n });\n }\n}\n\nexport const NotifyOnTeamCreatedHandler = TeamAfterCreateEventHandler.createImplementation({\n implementation: NotifyOnTeamCreatedHandlerImpl,\n dependencies: [NotifyRecordChangeUseCase]\n});\n\nclass NotifyOnTeamUpdatedHandlerImpl implements TeamAfterUpdateEventHandler.Interface {\n constructor(private notifyRecordChange: NotifyRecordChangeUseCase.Interface) {}\n\n async handle(event: TeamAfterUpdateEventHandler.Event): Promise<void> {\n await this.notifyRecordChange.execute({\n type: TEAM_RECORD_TYPE,\n id: event.payload.updated.id,\n change: \"updated\"\n });\n }\n}\n\nexport const NotifyOnTeamUpdatedHandler = TeamAfterUpdateEventHandler.createImplementation({\n implementation: NotifyOnTeamUpdatedHandlerImpl,\n dependencies: [NotifyRecordChangeUseCase]\n});\n\nclass NotifyOnTeamDeletedHandlerImpl implements TeamAfterDeleteEventHandler.Interface {\n constructor(private notifyRecordChange: NotifyRecordChangeUseCase.Interface) {}\n\n async handle(event: TeamAfterDeleteEventHandler.Event): Promise<void> {\n await this.notifyRecordChange.execute({\n type: TEAM_RECORD_TYPE,\n id: event.payload.team.id,\n change: \"deleted\"\n });\n }\n}\n\nexport const NotifyOnTeamDeletedHandler = TeamAfterDeleteEventHandler.createImplementation({\n implementation: NotifyOnTeamDeletedHandlerImpl,\n dependencies: [NotifyRecordChangeUseCase]\n});\n"],"names":["NotifyOnTeamCreatedHandlerImpl","notifyRecordChange","event","TEAM_RECORD_TYPE","NotifyOnTeamCreatedHandler","TeamAfterCreateEventHandler","NotifyRecordChangeUseCase","NotifyOnTeamUpdatedHandlerImpl","NotifyOnTeamUpdatedHandler","TeamAfterUpdateEventHandler","NotifyOnTeamDeletedHandlerImpl","NotifyOnTeamDeletedHandler","TeamAfterDeleteEventHandler"],"mappings":";;;;;AAMA,MAAMA;IACF,YAAoBC,kBAAuD,CAAE;aAAzDA,kBAAkB,GAAlBA;IAA0D;IAE9E,MAAM,OAAOC,KAAwC,EAAiB;QAClE,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YAClC,MAAMC;YACN,IAAID,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE;YACzB,QAAQ;QACZ;IACJ;AACJ;AAEO,MAAME,6BAA6BC,4BAA4B,oBAAoB,CAAC;IACvF,gBAAgBL;IAChB,cAAc;QAACM;KAA0B;AAC7C;AAEA,MAAMC;IACF,YAAoBN,kBAAuD,CAAE;aAAzDA,kBAAkB,GAAlBA;IAA0D;IAE9E,MAAM,OAAOC,KAAwC,EAAiB;QAClE,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YAClC,MAAMC;YACN,IAAID,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE;YAC5B,QAAQ;QACZ;IACJ;AACJ;AAEO,MAAMM,6BAA6BC,4BAA4B,oBAAoB,CAAC;IACvF,gBAAgBF;IAChB,cAAc;QAACD;KAA0B;AAC7C;AAEA,MAAMI;IACF,YAAoBT,kBAAuD,CAAE;aAAzDA,kBAAkB,GAAlBA;IAA0D;IAE9E,MAAM,OAAOC,KAAwC,EAAiB;QAClE,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YAClC,MAAMC;YACN,IAAID,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE;YACzB,QAAQ;QACZ;IACJ;AACJ;AAEO,MAAMS,6BAA6BC,4BAA4B,oBAAoB,CAAC;IACvF,gBAAgBF;IAChB,cAAc;QAACJ;KAA0B;AAC7C"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { NotifyOnTeamCreatedHandler, NotifyOnTeamDeletedHandler, NotifyOnTeamUpdatedHandler } from "./NotifyOnTeamChangeHandlers.js";
|
|
3
|
+
const NotifyTeamChangeFeature = createFeature({
|
|
4
|
+
name: "NotifyTeamChange",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(NotifyOnTeamCreatedHandler);
|
|
7
|
+
container.register(NotifyOnTeamUpdatedHandler);
|
|
8
|
+
container.register(NotifyOnTeamDeletedHandler);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
export { NotifyTeamChangeFeature };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/security/teams/NotifyTeamChange/feature.js","sources":["../../../../../src/features/security/teams/NotifyTeamChange/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport {\n NotifyOnTeamCreatedHandler,\n NotifyOnTeamDeletedHandler,\n NotifyOnTeamUpdatedHandler\n} from \"./NotifyOnTeamChangeHandlers.js\";\n\n/** Tells the user's open admin tabs when a team is created, updated or deleted. */\nexport const NotifyTeamChangeFeature = createFeature({\n name: \"NotifyTeamChange\",\n register(container) {\n container.register(NotifyOnTeamCreatedHandler);\n container.register(NotifyOnTeamUpdatedHandler);\n container.register(NotifyOnTeamDeletedHandler);\n }\n});\n"],"names":["NotifyTeamChangeFeature","createFeature","container","NotifyOnTeamCreatedHandler","NotifyOnTeamUpdatedHandler","NotifyOnTeamDeletedHandler"],"mappings":";;AAQO,MAAMA,0BAA0BC,cAAc;IACjD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;IACvB;AACJ"}
|