@webiny/api-core 6.6.0-alpha.10 → 6.6.0-alpha.12
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 -0
- 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/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/CanAccessCurrentTenant/CanAccessCurrentTenantUseCase.d.ts +13 -0
- package/features/security/CanAccessCurrentTenant/CanAccessCurrentTenantUseCase.js +25 -0
- package/features/security/CanAccessCurrentTenant/CanAccessCurrentTenantUseCase.js.map +1 -0
- package/features/security/CanAccessCurrentTenant/abstractions.d.ts +12 -0
- package/features/security/CanAccessCurrentTenant/abstractions.js +5 -0
- package/features/security/CanAccessCurrentTenant/abstractions.js.map +1 -0
- package/features/security/CanAccessCurrentTenant/feature.d.ts +4 -0
- package/features/security/CanAccessCurrentTenant/feature.js +11 -0
- package/features/security/CanAccessCurrentTenant/feature.js.map +1 -0
- package/features/security/CanAccessCurrentTenant/index.d.ts +2 -0
- package/features/security/CanAccessCurrentTenant/index.js +2 -0
- package/features/security/SecurityFeature.js +4 -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/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/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/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 +11 -11
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AiSdkToolDefinition } from "../../../features/ai/index.js";
|
|
3
|
+
import { AiSdkToolHandler } from "../../../features/ai/index.js";
|
|
4
|
+
import { ListUsersUseCase } from "../../../features/users/ListUsers/index.js";
|
|
5
|
+
interface UserSummary {
|
|
6
|
+
id: string;
|
|
7
|
+
displayName: string;
|
|
8
|
+
email: string;
|
|
9
|
+
/** Role ids, so `updateUserAccess` can be given the full list with one role added or removed. */
|
|
10
|
+
roles: string[];
|
|
11
|
+
/** Team ids, for the same reason. */
|
|
12
|
+
teams: string[];
|
|
13
|
+
}
|
|
14
|
+
declare class ListUsersToolHandlerImpl implements AiSdkToolHandler.Interface<Record<string, never>> {
|
|
15
|
+
private listUsers;
|
|
16
|
+
constructor(listUsers: ListUsersUseCase.Interface);
|
|
17
|
+
execute(): Promise<UserSummary[]>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolves a person ("Jane", "jane@acme.com") to the user id `updateUserAccess` takes, and shows
|
|
21
|
+
* what access they have now.
|
|
22
|
+
*/
|
|
23
|
+
declare class ListUsersToolImpl implements AiSdkToolDefinition.Interface<Record<string, never>> {
|
|
24
|
+
readonly name = "listUsers";
|
|
25
|
+
readonly title = "List users";
|
|
26
|
+
readonly description = "Lists the admin users in this project with their ids, display names, emails, role ids and team ids. updateUserAccess takes the id and the exact email. Folder permission targets for a user are 'admin:<id>'.";
|
|
27
|
+
readonly inputSchema: z.ZodObject<{}, z.core.$strip>;
|
|
28
|
+
readonly annotations: {
|
|
29
|
+
readOnlyHint: boolean;
|
|
30
|
+
idempotentHint: boolean;
|
|
31
|
+
};
|
|
32
|
+
readonly handler: typeof ListUsersToolHandlerImpl & {
|
|
33
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../ai/abstractions").IAiSdkToolHandler<any>>;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export declare const ListUsersTool: typeof ListUsersToolImpl & {
|
|
37
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../ai/abstractions").IAiSdkToolDefinition<any>>;
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AiSdkToolDefinition, AiSdkToolHandler } from "../../ai/index.js";
|
|
3
|
+
import { ListUsersUseCase } from "../ListUsers/index.js";
|
|
4
|
+
const inputSchema = z.object({});
|
|
5
|
+
class ListUsersToolHandlerImpl {
|
|
6
|
+
constructor(listUsers){
|
|
7
|
+
this.listUsers = listUsers;
|
|
8
|
+
}
|
|
9
|
+
async execute() {
|
|
10
|
+
const result = await this.listUsers.execute();
|
|
11
|
+
if (result.isFail()) throw new Error(`Could not list users: ${result.error.message}`);
|
|
12
|
+
return result.value.map((user)=>({
|
|
13
|
+
id: user.id,
|
|
14
|
+
displayName: user.displayName,
|
|
15
|
+
email: user.email,
|
|
16
|
+
roles: user.roles ?? [],
|
|
17
|
+
teams: user.teams ?? []
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const ListUsersToolHandler = AiSdkToolHandler.createImplementation({
|
|
22
|
+
implementation: ListUsersToolHandlerImpl,
|
|
23
|
+
dependencies: [
|
|
24
|
+
ListUsersUseCase
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
class ListUsersToolImpl {
|
|
28
|
+
constructor(){
|
|
29
|
+
this.name = "listUsers";
|
|
30
|
+
this.title = "List users";
|
|
31
|
+
this.description = "Lists the admin users in this project with their ids, display names, emails, role ids and team ids. updateUserAccess takes the id and the exact email. Folder permission targets for a user are 'admin:<id>'.";
|
|
32
|
+
this.inputSchema = inputSchema;
|
|
33
|
+
this.annotations = {
|
|
34
|
+
readOnlyHint: true,
|
|
35
|
+
idempotentHint: true
|
|
36
|
+
};
|
|
37
|
+
this.handler = ListUsersToolHandler;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const ListUsersTool = AiSdkToolDefinition.createImplementation({
|
|
41
|
+
implementation: ListUsersToolImpl,
|
|
42
|
+
dependencies: []
|
|
43
|
+
});
|
|
44
|
+
export { ListUsersTool };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=ListUsersTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/users/ai/ListUsersTool.js","sources":["../../../../src/features/users/ai/ListUsersTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition } from \"~/features/ai/index.js\";\nimport { AiSdkToolHandler } from \"~/features/ai/index.js\";\nimport { ListUsersUseCase } from \"~/features/users/ListUsers/index.js\";\n\nconst inputSchema = z.object({});\n\ninterface UserSummary {\n id: string;\n displayName: string;\n email: string;\n /** Role ids, so `updateUserAccess` can be given the full list with one role added or removed. */\n roles: string[];\n /** Team ids, for the same reason. */\n teams: string[];\n}\n\nclass ListUsersToolHandlerImpl implements AiSdkToolHandler.Interface<Record<string, never>> {\n constructor(private listUsers: ListUsersUseCase.Interface) {}\n\n async execute(): Promise<UserSummary[]> {\n const result = await this.listUsers.execute();\n\n if (result.isFail()) {\n throw new Error(`Could not list users: ${result.error.message}`);\n }\n\n return result.value.map(user => ({\n id: user.id,\n displayName: user.displayName,\n email: user.email,\n roles: user.roles ?? [],\n teams: user.teams ?? []\n }));\n }\n}\n\nconst ListUsersToolHandler = AiSdkToolHandler.createImplementation({\n implementation: ListUsersToolHandlerImpl,\n dependencies: [ListUsersUseCase]\n});\n\n/**\n * Resolves a person (\"Jane\", \"jane@acme.com\") to the user id `updateUserAccess` takes, and shows\n * what access they have now.\n */\nclass ListUsersToolImpl implements AiSdkToolDefinition.Interface<Record<string, never>> {\n readonly name = \"listUsers\";\n readonly title = \"List users\";\n readonly description =\n \"Lists the admin users in this project with their ids, display names, emails, role ids and team ids. updateUserAccess takes the id and the exact email. Folder permission targets for a user are 'admin:<id>'.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: true, idempotentHint: true };\n readonly handler = ListUsersToolHandler;\n}\n\nexport const ListUsersTool = AiSdkToolDefinition.createImplementation({\n implementation: ListUsersToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","ListUsersToolHandlerImpl","listUsers","result","Error","user","ListUsersToolHandler","AiSdkToolHandler","ListUsersUseCase","ListUsersToolImpl","ListUsersTool","AiSdkToolDefinition"],"mappings":";;;AAKA,MAAMA,cAAcC,EAAE,MAAM,CAAC,CAAC;AAY9B,MAAMC;IACF,YAAoBC,SAAqC,CAAE;aAAvCA,SAAS,GAATA;IAAwC;IAE5D,MAAM,UAAkC;QACpC,MAAMC,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO;QAE3C,IAAIA,OAAO,MAAM,IACb,MAAM,IAAIC,MAAM,CAAC,sBAAsB,EAAED,OAAO,KAAK,CAAC,OAAO,EAAE;QAGnE,OAAOA,OAAO,KAAK,CAAC,GAAG,CAACE,CAAAA,OAAS;gBAC7B,IAAIA,KAAK,EAAE;gBACX,aAAaA,KAAK,WAAW;gBAC7B,OAAOA,KAAK,KAAK;gBACjB,OAAOA,KAAK,KAAK,IAAI,EAAE;gBACvB,OAAOA,KAAK,KAAK,IAAI,EAAE;YAC3B;IACJ;AACJ;AAEA,MAAMC,uBAAuBC,iBAAiB,oBAAoB,CAAC;IAC/D,gBAAgBN;IAChB,cAAc;QAACO;KAAiB;AACpC;AAMA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGV;aACd,WAAW,GAAG;YAAE,cAAc;YAAM,gBAAgB;QAAK;aACzD,OAAO,GAAGO;;AACvB;AAEO,MAAMI,gBAAgBC,oBAAoB,oBAAoB,CAAC;IAClE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AiSdkToolDefinition } from "../../../features/ai/index.js";
|
|
3
|
+
import { AiSdkToolHandler } from "../../../features/ai/index.js";
|
|
4
|
+
import { IdentityContext } from "../../../features/security/IdentityContext/index.js";
|
|
5
|
+
import { GetUserUseCase } from "../../../features/users/GetUser/index.js";
|
|
6
|
+
import { UpdateUserUseCase } from "../../../features/users/UpdateUser/index.js";
|
|
7
|
+
import { ListRolesUseCase } from "../../../features/security/roles/ListRoles/index.js";
|
|
8
|
+
import { ListTeamsUseCase } from "../../../features/security/teams/ListTeams/index.js";
|
|
9
|
+
declare const inputSchema: z.ZodObject<{
|
|
10
|
+
userId: z.ZodString;
|
|
11
|
+
email: z.ZodString;
|
|
12
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
13
|
+
teams: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
type Input = z.infer<typeof inputSchema>;
|
|
16
|
+
interface UpdatedUserAccess {
|
|
17
|
+
id: string;
|
|
18
|
+
email: string;
|
|
19
|
+
roles: string[];
|
|
20
|
+
teams: string[];
|
|
21
|
+
}
|
|
22
|
+
declare class UpdateUserAccessToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {
|
|
23
|
+
private identityContext;
|
|
24
|
+
private getUser;
|
|
25
|
+
private listRoles;
|
|
26
|
+
private listTeams;
|
|
27
|
+
private updateUser;
|
|
28
|
+
constructor(identityContext: IdentityContext.Interface, getUser: GetUserUseCase.Interface, listRoles: ListRolesUseCase.Interface, listTeams: ListTeamsUseCase.Interface, updateUser: UpdateUserUseCase.Interface);
|
|
29
|
+
execute(input: Input): Promise<UpdatedUserAccess>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Changes which roles and teams a user has.
|
|
33
|
+
*
|
|
34
|
+
* Needs approval: roles and teams decide what the user can do. Each list replaces the stored one,
|
|
35
|
+
* and the approval shows the whole list, so a role the model left out is visible as missing before
|
|
36
|
+
* anything is written.
|
|
37
|
+
*/
|
|
38
|
+
declare class UpdateUserAccessToolImpl implements AiSdkToolDefinition.Interface<Input> {
|
|
39
|
+
readonly name = "updateUserAccess";
|
|
40
|
+
readonly title = "Update user access";
|
|
41
|
+
readonly description = "Changes which roles and teams an admin user has. Call listUsers first for the id and exact email. `roles` and `teams` each replace the user's whole list, so pass everything the user should keep; resolve them with listRoles and listTeams. Cannot change the signed-in user or users from an external identity provider, and cannot change a user's name, email or password. Requires user approval.";
|
|
42
|
+
readonly inputSchema: z.ZodObject<{
|
|
43
|
+
userId: z.ZodString;
|
|
44
|
+
email: z.ZodString;
|
|
45
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
46
|
+
teams: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
readonly annotations: {
|
|
49
|
+
readOnlyHint: boolean;
|
|
50
|
+
idempotentHint: boolean;
|
|
51
|
+
};
|
|
52
|
+
readonly handler: typeof UpdateUserAccessToolHandlerImpl & {
|
|
53
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../ai/abstractions").IAiSdkToolHandler<any>>;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export declare const UpdateUserAccessTool: typeof UpdateUserAccessToolImpl & {
|
|
57
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../ai/abstractions").IAiSdkToolDefinition<any>>;
|
|
58
|
+
};
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AiSdkToolDefinition, AiSdkToolHandler } from "../../ai/index.js";
|
|
3
|
+
import { IdentityContext } from "../../security/IdentityContext/index.js";
|
|
4
|
+
import { GetUserUseCase } from "../GetUser/index.js";
|
|
5
|
+
import { UpdateUserUseCase } from "../UpdateUser/index.js";
|
|
6
|
+
import { ListRolesUseCase } from "../../security/roles/ListRoles/index.js";
|
|
7
|
+
import { ListTeamsUseCase } from "../../security/teams/ListTeams/index.js";
|
|
8
|
+
const inputSchema = z.object({
|
|
9
|
+
userId: z.string().describe("User id as returned by listUsers."),
|
|
10
|
+
email: z.string().describe("The user's current email, exactly as listUsers returned it. The change is refused if it does not match."),
|
|
11
|
+
roles: z.array(z.string()).optional().describe("The complete list of roles the user should have afterwards. It REPLACES the stored list, so include the roles to keep. Omit it to leave the roles alone. Role ids or slugs from listRoles."),
|
|
12
|
+
teams: z.array(z.string()).optional().describe("The complete list of teams the user should be in afterwards. It REPLACES the stored list, so include the teams to keep. Omit it to leave the teams alone. Team ids or slugs from listTeams.")
|
|
13
|
+
});
|
|
14
|
+
const toIds = (kind, values, known)=>{
|
|
15
|
+
const unknown = [];
|
|
16
|
+
const ids = values.map((value)=>{
|
|
17
|
+
const match = known.find((record)=>record.id === value || record.slug === value);
|
|
18
|
+
if (!match) {
|
|
19
|
+
unknown.push(value);
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
return match.id;
|
|
23
|
+
});
|
|
24
|
+
if (unknown.length > 0) {
|
|
25
|
+
const names = unknown.map((value)=>`"${value}"`).join(", ");
|
|
26
|
+
throw new Error(`Not a known ${kind} id or slug: ${names}. Nothing was changed. Call list${"role" === kind ? "Roles" : "Teams"} for valid values.`);
|
|
27
|
+
}
|
|
28
|
+
return Array.from(new Set(ids));
|
|
29
|
+
};
|
|
30
|
+
class UpdateUserAccessToolHandlerImpl {
|
|
31
|
+
constructor(identityContext, getUser, listRoles, listTeams, updateUser){
|
|
32
|
+
this.identityContext = identityContext;
|
|
33
|
+
this.getUser = getUser;
|
|
34
|
+
this.listRoles = listRoles;
|
|
35
|
+
this.listTeams = listTeams;
|
|
36
|
+
this.updateUser = updateUser;
|
|
37
|
+
}
|
|
38
|
+
async execute(input) {
|
|
39
|
+
if (void 0 === input.roles && void 0 === input.teams) throw new Error("Pass roles, teams or both. Nothing was changed.");
|
|
40
|
+
const found = await this.getUser.execute({
|
|
41
|
+
id: input.userId
|
|
42
|
+
});
|
|
43
|
+
if (found.isFail()) throw new Error(`User "${input.userId}" not found: ${found.error.message}. Call listUsers for valid ids.`);
|
|
44
|
+
const user = found.value;
|
|
45
|
+
if (user.email !== input.email) throw new Error(`User "${input.userId}" has the email "${user.email}", not "${input.email}", so nothing was changed. Check the user with listUsers.`);
|
|
46
|
+
if (user.id === this.identityContext.getIdentity().id) throw new Error("This is the signed-in user. Change your own roles and teams in the Users screen, so a mistake cannot lock you out. Nothing was changed.");
|
|
47
|
+
if (user.external) throw new Error(`"${user.email}" signs in through an external identity provider, which sets their roles and teams at every sign-in. Change them there. Nothing was changed.`);
|
|
48
|
+
const changes = {};
|
|
49
|
+
if (input.roles?.length === 0) changes.roles = [];
|
|
50
|
+
else if (void 0 !== input.roles) {
|
|
51
|
+
const roles = await this.listRoles.execute();
|
|
52
|
+
if (roles.isFail()) throw new Error(`Could not check the roles: ${roles.error.message}`);
|
|
53
|
+
changes.roles = toIds("role", input.roles, roles.value);
|
|
54
|
+
}
|
|
55
|
+
if (input.teams?.length === 0) changes.teams = [];
|
|
56
|
+
else if (void 0 !== input.teams) {
|
|
57
|
+
const teams = await this.listTeams.execute();
|
|
58
|
+
if (teams.isFail()) throw new Error(`Could not check the teams: ${teams.error.message}`);
|
|
59
|
+
changes.teams = toIds("team", input.teams, teams.value);
|
|
60
|
+
}
|
|
61
|
+
const result = await this.updateUser.execute(user.id, changes);
|
|
62
|
+
if (result.isFail()) throw new Error(`Could not update the user: ${result.error.message}`);
|
|
63
|
+
const updated = result.value;
|
|
64
|
+
return {
|
|
65
|
+
id: updated.id,
|
|
66
|
+
email: updated.email,
|
|
67
|
+
roles: updated.roles ?? [],
|
|
68
|
+
teams: updated.teams ?? []
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const UpdateUserAccessToolHandler = AiSdkToolHandler.createImplementation({
|
|
73
|
+
implementation: UpdateUserAccessToolHandlerImpl,
|
|
74
|
+
dependencies: [
|
|
75
|
+
IdentityContext,
|
|
76
|
+
GetUserUseCase,
|
|
77
|
+
ListRolesUseCase,
|
|
78
|
+
ListTeamsUseCase,
|
|
79
|
+
UpdateUserUseCase
|
|
80
|
+
]
|
|
81
|
+
});
|
|
82
|
+
class UpdateUserAccessToolImpl {
|
|
83
|
+
constructor(){
|
|
84
|
+
this.name = "updateUserAccess";
|
|
85
|
+
this.title = "Update user access";
|
|
86
|
+
this.description = "Changes which roles and teams an admin user has. Call listUsers first for the id and exact email. `roles` and `teams` each replace the user's whole list, so pass everything the user should keep; resolve them with listRoles and listTeams. Cannot change the signed-in user or users from an external identity provider, and cannot change a user's name, email or password. Requires user approval.";
|
|
87
|
+
this.inputSchema = inputSchema;
|
|
88
|
+
this.annotations = {
|
|
89
|
+
readOnlyHint: false,
|
|
90
|
+
idempotentHint: true
|
|
91
|
+
};
|
|
92
|
+
this.handler = UpdateUserAccessToolHandler;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const UpdateUserAccessTool = AiSdkToolDefinition.createImplementation({
|
|
96
|
+
implementation: UpdateUserAccessToolImpl,
|
|
97
|
+
dependencies: []
|
|
98
|
+
});
|
|
99
|
+
export { UpdateUserAccessTool };
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=UpdateUserAccessTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/users/ai/UpdateUserAccessTool.js","sources":["../../../../src/features/users/ai/UpdateUserAccessTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition } from \"~/features/ai/index.js\";\nimport { AiSdkToolHandler } from \"~/features/ai/index.js\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/index.js\";\nimport { GetUserUseCase } from \"~/features/users/GetUser/index.js\";\nimport { UpdateUserUseCase } from \"~/features/users/UpdateUser/index.js\";\nimport { ListRolesUseCase } from \"~/features/security/roles/ListRoles/index.js\";\nimport { ListTeamsUseCase } from \"~/features/security/teams/ListTeams/index.js\";\n\nconst inputSchema = z.object({\n userId: z.string().describe(\"User id as returned by listUsers.\"),\n email: z\n .string()\n .describe(\n \"The user's current email, exactly as listUsers returned it. The change is refused if it does not match.\"\n ),\n roles: z\n .array(z.string())\n .optional()\n .describe(\n \"The complete list of roles the user should have afterwards. It REPLACES the stored list, so include the roles to keep. Omit it to leave the roles alone. Role ids or slugs from listRoles.\"\n ),\n teams: z\n .array(z.string())\n .optional()\n .describe(\n \"The complete list of teams the user should be in afterwards. It REPLACES the stored list, so include the teams to keep. Omit it to leave the teams alone. Team ids or slugs from listTeams.\"\n )\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface UpdatedUserAccess {\n id: string;\n email: string;\n roles: string[];\n teams: string[];\n}\n\ninterface NamedRecord {\n id: string;\n slug: string;\n}\n\n/*\n * A user stores role and team ids, and sign-in loads them by id only. `UpdateUserUseCase` stores\n * whatever it is given, so a slug or a typo would be saved and silently grant nothing. The tool maps\n * each value to an id here and refuses any it cannot find.\n */\nconst toIds = (kind: string, values: string[], known: NamedRecord[]): string[] => {\n const unknown: string[] = [];\n\n const ids = values.map(value => {\n const match = known.find(record => record.id === value || record.slug === value);\n if (!match) {\n unknown.push(value);\n return value;\n }\n return match.id;\n });\n\n if (unknown.length > 0) {\n const names = unknown.map(value => `\"${value}\"`).join(\", \");\n throw new Error(\n `Not a known ${kind} id or slug: ${names}. Nothing was changed. Call list${kind === \"role\" ? \"Roles\" : \"Teams\"} for valid values.`\n );\n }\n\n return Array.from(new Set(ids));\n};\n\n/*\n * The checks run before anything is written:\n *\n * - The email is in the input so the approval shows whose access changes; it is checked against the\n * stored user, so what the user approved is what is changed.\n * - The signed-in user's own access is refused. One wrong role list would lock them out of the\n * screens they would need to undo it.\n * - Users from an external identity provider (Okta, Auth0) are refused. `ExternalIdpUserSync`\n * rewrites their roles and teams from the provider at every sign-in, so a change here would be\n * reported as done and then undone.\n * - Only roles and teams are written. Name, email and password belong to the identity provider too\n * (Cognito, self-hosted sign-in), and `UpdateUserUseCase` alone would change the Webiny record\n * without it. Roles and teams exist only in Webiny, so this is safe with any provider.\n */\nclass UpdateUserAccessToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {\n constructor(\n private identityContext: IdentityContext.Interface,\n private getUser: GetUserUseCase.Interface,\n private listRoles: ListRolesUseCase.Interface,\n private listTeams: ListTeamsUseCase.Interface,\n private updateUser: UpdateUserUseCase.Interface\n ) {}\n\n async execute(input: Input): Promise<UpdatedUserAccess> {\n if (input.roles === undefined && input.teams === undefined) {\n throw new Error(\"Pass roles, teams or both. Nothing was changed.\");\n }\n\n const found = await this.getUser.execute({ id: input.userId });\n if (found.isFail()) {\n throw new Error(\n `User \"${input.userId}\" not found: ${found.error.message}. Call listUsers for valid ids.`\n );\n }\n\n const user = found.value;\n\n if (user.email !== input.email) {\n throw new Error(\n `User \"${input.userId}\" has the email \"${user.email}\", not \"${input.email}\", so nothing was changed. Check the user with listUsers.`\n );\n }\n\n if (user.id === this.identityContext.getIdentity().id) {\n throw new Error(\n \"This is the signed-in user. Change your own roles and teams in the Users screen, so a mistake cannot lock you out. Nothing was changed.\"\n );\n }\n\n if (user.external) {\n throw new Error(\n `\"${user.email}\" signs in through an external identity provider, which sets their roles and teams at every sign-in. Change them there. Nothing was changed.`\n );\n }\n\n const changes: { roles?: string[]; teams?: string[] } = {};\n\n // An empty list has nothing to look up. Reading the roles or teams anyway would make clearing\n // them need security.role or security.team on top of adminUsers.user.\n if (input.roles?.length === 0) {\n changes.roles = [];\n } else if (input.roles !== undefined) {\n const roles = await this.listRoles.execute();\n if (roles.isFail()) {\n throw new Error(`Could not check the roles: ${roles.error.message}`);\n }\n changes.roles = toIds(\"role\", input.roles, roles.value);\n }\n\n if (input.teams?.length === 0) {\n changes.teams = [];\n } else if (input.teams !== undefined) {\n const teams = await this.listTeams.execute();\n if (teams.isFail()) {\n throw new Error(`Could not check the teams: ${teams.error.message}`);\n }\n changes.teams = toIds(\"team\", input.teams, teams.value);\n }\n\n const result = await this.updateUser.execute(user.id, changes);\n if (result.isFail()) {\n throw new Error(`Could not update the user: ${result.error.message}`);\n }\n\n const updated = result.value;\n\n return {\n id: updated.id,\n email: updated.email,\n roles: updated.roles ?? [],\n teams: updated.teams ?? []\n };\n }\n}\n\nconst UpdateUserAccessToolHandler = AiSdkToolHandler.createImplementation({\n implementation: UpdateUserAccessToolHandlerImpl,\n dependencies: [\n IdentityContext,\n GetUserUseCase,\n ListRolesUseCase,\n ListTeamsUseCase,\n UpdateUserUseCase\n ]\n});\n\n/**\n * Changes which roles and teams a user has.\n *\n * Needs approval: roles and teams decide what the user can do. Each list replaces the stored one,\n * and the approval shows the whole list, so a role the model left out is visible as missing before\n * anything is written.\n */\nclass UpdateUserAccessToolImpl implements AiSdkToolDefinition.Interface<Input> {\n readonly name = \"updateUserAccess\";\n readonly title = \"Update user access\";\n readonly description =\n \"Changes which roles and teams an admin user has. Call listUsers first for the id and exact email. `roles` and `teams` each replace the user's whole list, so pass everything the user should keep; resolve them with listRoles and listTeams. Cannot change the signed-in user or users from an external identity provider, and cannot change a user's name, email or password. Requires user approval.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: false, idempotentHint: true };\n readonly handler = UpdateUserAccessToolHandler;\n}\n\nexport const UpdateUserAccessTool = AiSdkToolDefinition.createImplementation({\n implementation: UpdateUserAccessToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","toIds","kind","values","known","unknown","ids","value","match","record","names","Error","Array","Set","UpdateUserAccessToolHandlerImpl","identityContext","getUser","listRoles","listTeams","updateUser","input","undefined","found","user","changes","roles","teams","result","updated","UpdateUserAccessToolHandler","AiSdkToolHandler","IdentityContext","GetUserUseCase","ListRolesUseCase","ListTeamsUseCase","UpdateUserUseCase","UpdateUserAccessToolImpl","UpdateUserAccessTool","AiSdkToolDefinition"],"mappings":"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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admin user tools for AI callers.
|
|
3
|
+
*
|
|
4
|
+
* There is no create or delete tool. A user's sign-in account lives with the identity provider
|
|
5
|
+
* (Cognito, self-hosted sign-in), which wraps the api-core use cases with its own. Creating or deleting
|
|
6
|
+
* through api-core alone would leave a user who cannot sign in, or a sign-in account with no user.
|
|
7
|
+
*/
|
|
8
|
+
export declare const UsersAiToolsFeature: {
|
|
9
|
+
name: string;
|
|
10
|
+
register(container: import("@webiny/di").Container): void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { ListUsersTool } from "./ListUsersTool.js";
|
|
3
|
+
import { UpdateUserAccessTool } from "./UpdateUserAccessTool.js";
|
|
4
|
+
const UsersAiToolsFeature = createFeature({
|
|
5
|
+
name: "AdminUsers/AiTools",
|
|
6
|
+
register (container) {
|
|
7
|
+
container.register(ListUsersTool);
|
|
8
|
+
container.register(UpdateUserAccessTool);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
export { UsersAiToolsFeature };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/users/ai/feature.js","sources":["../../../../src/features/users/ai/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListUsersTool } from \"./ListUsersTool.js\";\nimport { UpdateUserAccessTool } from \"./UpdateUserAccessTool.js\";\n\n/**\n * Admin user tools for AI callers.\n *\n * There is no create or delete tool. A user's sign-in account lives with the identity provider\n * (Cognito, self-hosted sign-in), which wraps the api-core use cases with its own. Creating or deleting\n * through api-core alone would leave a user who cannot sign in, or a sign-in account with no user.\n */\nexport const UsersAiToolsFeature = createFeature({\n name: \"AdminUsers/AiTools\",\n register(container) {\n container.register(ListUsersTool);\n container.register(UpdateUserAccessTool);\n }\n});\n"],"names":["UsersAiToolsFeature","createFeature","container","ListUsersTool","UpdateUserAccessTool"],"mappings":";;;AAWO,MAAMA,sBAAsBC,cAAc;IAC7C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;IACvB;AACJ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IdentityContext } from "../../../features/security/IdentityContext/abstractions.js";
|
|
2
|
+
import { WebsocketsSendToIdentityUseCase } from "../../../features/websockets/SendToIdentity/abstractions.js";
|
|
3
|
+
import { NotifyRecordChangeUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
4
|
+
declare class NotifyRecordChangeUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
5
|
+
private identityContext;
|
|
6
|
+
private sendToIdentity;
|
|
7
|
+
constructor(identityContext: IdentityContext.Interface, sendToIdentity: WebsocketsSendToIdentityUseCase.Interface);
|
|
8
|
+
execute({ identityId, ...data }: UseCaseAbstraction.Params): Promise<void>;
|
|
9
|
+
private getSignedInIdentityId;
|
|
10
|
+
}
|
|
11
|
+
export declare const NotifyRecordChangeUseCase: import("@webiny/di").Implementation<typeof NotifyRecordChangeUseCaseImpl>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createImplementation } from "@webiny/di";
|
|
2
|
+
import { IdentityContext } from "../../security/IdentityContext/abstractions.js";
|
|
3
|
+
import { WebsocketsSendToIdentityUseCase } from "../SendToIdentity/abstractions.js";
|
|
4
|
+
import { NotifyRecordChangeUseCase, RECORD_CHANGED_WEBSOCKET_ACTION } from "./abstractions.js";
|
|
5
|
+
class NotifyRecordChangeUseCaseImpl {
|
|
6
|
+
constructor(identityContext, sendToIdentity){
|
|
7
|
+
this.identityContext = identityContext;
|
|
8
|
+
this.sendToIdentity = sendToIdentity;
|
|
9
|
+
}
|
|
10
|
+
async execute({ identityId, ...data }) {
|
|
11
|
+
const recipient = identityId ?? this.getSignedInIdentityId();
|
|
12
|
+
if (!recipient) return;
|
|
13
|
+
try {
|
|
14
|
+
await this.sendToIdentity.execute({
|
|
15
|
+
id: recipient
|
|
16
|
+
}, {
|
|
17
|
+
action: RECORD_CHANGED_WEBSOCKET_ACTION,
|
|
18
|
+
data
|
|
19
|
+
});
|
|
20
|
+
} catch {}
|
|
21
|
+
}
|
|
22
|
+
getSignedInIdentityId() {
|
|
23
|
+
const identity = this.identityContext.getIdentity();
|
|
24
|
+
if (identity.isAnonymous()) return;
|
|
25
|
+
return identity.id;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const NotifyRecordChangeUseCase_NotifyRecordChangeUseCase = createImplementation({
|
|
29
|
+
abstraction: NotifyRecordChangeUseCase,
|
|
30
|
+
implementation: NotifyRecordChangeUseCaseImpl,
|
|
31
|
+
dependencies: [
|
|
32
|
+
IdentityContext,
|
|
33
|
+
WebsocketsSendToIdentityUseCase
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
export { NotifyRecordChangeUseCase_NotifyRecordChangeUseCase as NotifyRecordChangeUseCase };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=NotifyRecordChangeUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/websockets/NotifyRecordChange/NotifyRecordChangeUseCase.js","sources":["../../../../src/features/websockets/NotifyRecordChange/NotifyRecordChangeUseCase.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/abstractions.js\";\nimport { WebsocketsSendToIdentityUseCase } from \"~/features/websockets/SendToIdentity/abstractions.js\";\nimport { RECORD_CHANGED_WEBSOCKET_ACTION } from \"./abstractions.js\";\nimport { NotifyRecordChangeUseCase as UseCaseAbstraction } from \"./abstractions.js\";\n\n/*\n * Changes the admin makes itself are announced too: the admin applies them by id, so the tab that\n * made the change ends up where it already was and the user's other tabs catch up.\n *\n * The change is saved whether or not the message goes out, so a failed send is swallowed rather than\n * failing the write. The admin then shows the change after its next reload.\n */\nclass NotifyRecordChangeUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private sendToIdentity: WebsocketsSendToIdentityUseCase.Interface\n ) {}\n\n async execute({ identityId, ...data }: UseCaseAbstraction.Params): Promise<void> {\n const recipient = identityId ?? this.getSignedInIdentityId();\n if (!recipient) {\n return;\n }\n\n try {\n await this.sendToIdentity.execute(\n { id: recipient },\n { action: RECORD_CHANGED_WEBSOCKET_ACTION, data }\n );\n } catch {\n // See above.\n }\n }\n\n private getSignedInIdentityId(): string | undefined {\n const identity = this.identityContext.getIdentity();\n if (identity.isAnonymous()) {\n return undefined;\n }\n return identity.id;\n }\n}\n\nexport const NotifyRecordChangeUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: NotifyRecordChangeUseCaseImpl,\n dependencies: [IdentityContext, WebsocketsSendToIdentityUseCase]\n});\n"],"names":["NotifyRecordChangeUseCaseImpl","identityContext","sendToIdentity","identityId","data","recipient","RECORD_CHANGED_WEBSOCKET_ACTION","identity","NotifyRecordChangeUseCase","createImplementation","UseCaseAbstraction","IdentityContext","WebsocketsSendToIdentityUseCase"],"mappings":";;;;AAaA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,cAAyD,CACnE;aAFUD,eAAe,GAAfA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QAAQ,EAAEC,UAAU,EAAE,GAAGC,MAAiC,EAAiB;QAC7E,MAAMC,YAAYF,cAAc,IAAI,CAAC,qBAAqB;QAC1D,IAAI,CAACE,WACD;QAGJ,IAAI;YACA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B;gBAAE,IAAIA;YAAU,GAChB;gBAAE,QAAQC;gBAAiCF;YAAK;QAExD,EAAE,OAAM,CAER;IACJ;IAEQ,wBAA4C;QAChD,MAAMG,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QACjD,IAAIA,SAAS,WAAW,IACpB;QAEJ,OAAOA,SAAS,EAAE;IACtB;AACJ;AAEO,MAAMC,sDAA4BC,qBAAqB;IAC1D,aAAaC;IACb,gBAAgBV;IAChB,cAAc;QAACW;QAAiBC;KAAgC;AACpE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sent to the user's open admin tabs when a record changes on the server. The admin keeps its own
|
|
3
|
+
* copies of folders, teams, roles and users, and a change made on the server (by the assistant's
|
|
4
|
+
* tools, a background task, another tab) never passes through them, so without this message the
|
|
5
|
+
* admin shows the old state until a reload.
|
|
6
|
+
*
|
|
7
|
+
* Carries the record type and id only; the admin reads the record back, or drops it for `deleted`.
|
|
8
|
+
* `RecordChangeMessages` in @webiny/app turns it into a `RecordChangedEvent`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const RECORD_CHANGED_WEBSOCKET_ACTION = "record.changed";
|
|
11
|
+
export type RecordChange = "created" | "updated" | "deleted";
|
|
12
|
+
export interface RecordChangedMessageData {
|
|
13
|
+
/** Names the kind of record, such as `security.team`. The admin handlers filter on it. */
|
|
14
|
+
type: string;
|
|
15
|
+
id: string;
|
|
16
|
+
/**
|
|
17
|
+
* For a record whose id only means something inside a parent: the parent's id. A CMS entry
|
|
18
|
+
* carries its model id here, which the admin needs to read the entry back.
|
|
19
|
+
*/
|
|
20
|
+
scope?: string;
|
|
21
|
+
change: RecordChange;
|
|
22
|
+
}
|
|
23
|
+
export interface NotifyRecordChangeParams extends RecordChangedMessageData {
|
|
24
|
+
/**
|
|
25
|
+
* Whose open tabs to tell. Defaults to the current identity. Background tasks pass the identity
|
|
26
|
+
* that made the change, because they run later, outside that request.
|
|
27
|
+
*/
|
|
28
|
+
identityId?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface INotifyRecordChangeUseCase {
|
|
31
|
+
execute(params: NotifyRecordChangeParams): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
export declare const NotifyRecordChangeUseCase: import("@webiny/di").Abstraction<INotifyRecordChangeUseCase>;
|
|
34
|
+
export declare namespace NotifyRecordChangeUseCase {
|
|
35
|
+
type Interface = INotifyRecordChangeUseCase;
|
|
36
|
+
type Params = NotifyRecordChangeParams;
|
|
37
|
+
type Change = RecordChange;
|
|
38
|
+
type MessageData = RecordChangedMessageData;
|
|
39
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
const RECORD_CHANGED_WEBSOCKET_ACTION = "record.changed";
|
|
3
|
+
const NotifyRecordChangeUseCase = createAbstraction("Websockets/NotifyRecordChangeUseCase");
|
|
4
|
+
export { NotifyRecordChangeUseCase, RECORD_CHANGED_WEBSOCKET_ACTION };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/websockets/NotifyRecordChange/abstractions.js","sources":["../../../../src/features/websockets/NotifyRecordChange/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\n/**\n * Sent to the user's open admin tabs when a record changes on the server. The admin keeps its own\n * copies of folders, teams, roles and users, and a change made on the server (by the assistant's\n * tools, a background task, another tab) never passes through them, so without this message the\n * admin shows the old state until a reload.\n *\n * Carries the record type and id only; the admin reads the record back, or drops it for `deleted`.\n * `RecordChangeMessages` in @webiny/app turns it into a `RecordChangedEvent`.\n */\nexport const RECORD_CHANGED_WEBSOCKET_ACTION = \"record.changed\";\n\nexport type RecordChange = \"created\" | \"updated\" | \"deleted\";\n\nexport interface RecordChangedMessageData {\n /** Names the kind of record, such as `security.team`. The admin handlers filter on it. */\n type: string;\n id: string;\n /**\n * For a record whose id only means something inside a parent: the parent's id. A CMS entry\n * carries its model id here, which the admin needs to read the entry back.\n */\n scope?: string;\n change: RecordChange;\n}\n\nexport interface NotifyRecordChangeParams extends RecordChangedMessageData {\n /**\n * Whose open tabs to tell. Defaults to the current identity. Background tasks pass the identity\n * that made the change, because they run later, outside that request.\n */\n identityId?: string;\n}\n\nexport interface INotifyRecordChangeUseCase {\n execute(params: NotifyRecordChangeParams): Promise<void>;\n}\n\nexport const NotifyRecordChangeUseCase = createAbstraction<INotifyRecordChangeUseCase>(\n \"Websockets/NotifyRecordChangeUseCase\"\n);\n\nexport namespace NotifyRecordChangeUseCase {\n export type Interface = INotifyRecordChangeUseCase;\n export type Params = NotifyRecordChangeParams;\n export type Change = RecordChange;\n export type MessageData = RecordChangedMessageData;\n}\n"],"names":["RECORD_CHANGED_WEBSOCKET_ACTION","NotifyRecordChangeUseCase","createAbstraction"],"mappings":";AAWO,MAAMA,kCAAkC;AA4BxC,MAAMC,4BAA4BC,kBACrC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { NotifyRecordChangeUseCase } from "./NotifyRecordChangeUseCase.js";
|
|
3
|
+
const NotifyRecordChangeFeature = createFeature({
|
|
4
|
+
name: "NotifyRecordChange",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(NotifyRecordChangeUseCase);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { NotifyRecordChangeFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/websockets/NotifyRecordChange/feature.js","sources":["../../../../src/features/websockets/NotifyRecordChange/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { NotifyRecordChangeUseCase } from \"./NotifyRecordChangeUseCase.js\";\n\n/** Tells the user's open admin tabs when a record is created, updated or deleted on the server. */\nexport const NotifyRecordChangeFeature = createFeature({\n name: \"NotifyRecordChange\",\n register(container) {\n container.register(NotifyRecordChangeUseCase);\n }\n});\n"],"names":["NotifyRecordChangeFeature","createFeature","container","NotifyRecordChangeUseCase"],"mappings":";;AAIO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { GenericRecord } from "@webiny/api/types.js";
|
|
3
|
+
import { Logger } from "../../../features/logger/index.js";
|
|
4
|
+
import { WebsocketsSendToIdentityUseCase } from "./abstractions.js";
|
|
5
|
+
/**
|
|
6
|
+
* The default when no websockets package is installed: there are no connections to send to, so the
|
|
7
|
+
* send succeeds without doing anything. `@webiny/api-websockets` registers after api-core and replaces it.
|
|
8
|
+
*
|
|
9
|
+
* Logged at debug level, so that a handler stack that forgot to register websockets can be told apart
|
|
10
|
+
* from a user who simply has no tab open.
|
|
11
|
+
*/
|
|
12
|
+
declare class NullSendToIdentityUseCaseImpl implements WebsocketsSendToIdentityUseCase.Interface {
|
|
13
|
+
private readonly logger;
|
|
14
|
+
constructor(logger: Logger.Interface);
|
|
15
|
+
execute(identity: WebsocketsSendToIdentityUseCase.Identity, data: WebsocketsSendToIdentityUseCase.Data<GenericRecord>): Promise<Result<void, never>>;
|
|
16
|
+
}
|
|
17
|
+
export declare const NullSendToIdentityUseCase: typeof NullSendToIdentityUseCaseImpl & {
|
|
18
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ISendToIdentityUseCase>;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { Logger } from "../../logger/index.js";
|
|
3
|
+
import { WebsocketsSendToIdentityUseCase } from "./abstractions.js";
|
|
4
|
+
class NullSendToIdentityUseCaseImpl {
|
|
5
|
+
constructor(logger){
|
|
6
|
+
this.logger = logger;
|
|
7
|
+
}
|
|
8
|
+
async execute(identity, data) {
|
|
9
|
+
this.logger.debug({
|
|
10
|
+
identityId: identity.id,
|
|
11
|
+
action: data.action
|
|
12
|
+
}, "No websockets package registered; message not sent.");
|
|
13
|
+
return Result.ok();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const NullSendToIdentityUseCase = WebsocketsSendToIdentityUseCase.createImplementation({
|
|
17
|
+
implementation: NullSendToIdentityUseCaseImpl,
|
|
18
|
+
dependencies: [
|
|
19
|
+
Logger
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
export { NullSendToIdentityUseCase };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=NullSendToIdentityUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/websockets/SendToIdentity/NullSendToIdentityUseCase.js","sources":["../../../../src/features/websockets/SendToIdentity/NullSendToIdentityUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { Logger } from \"~/features/logger/index.js\";\nimport { WebsocketsSendToIdentityUseCase } from \"./abstractions.js\";\n\n/**\n * The default when no websockets package is installed: there are no connections to send to, so the\n * send succeeds without doing anything. `@webiny/api-websockets` registers after api-core and replaces it.\n *\n * Logged at debug level, so that a handler stack that forgot to register websockets can be told apart\n * from a user who simply has no tab open.\n */\nclass NullSendToIdentityUseCaseImpl implements WebsocketsSendToIdentityUseCase.Interface {\n constructor(private readonly logger: Logger.Interface) {}\n\n async execute(\n identity: WebsocketsSendToIdentityUseCase.Identity,\n data: WebsocketsSendToIdentityUseCase.Data<GenericRecord>\n ) {\n this.logger.debug(\n { identityId: identity.id, action: data.action },\n \"No websockets package registered; message not sent.\"\n );\n return Result.ok();\n }\n}\n\nexport const NullSendToIdentityUseCase = WebsocketsSendToIdentityUseCase.createImplementation({\n implementation: NullSendToIdentityUseCaseImpl,\n dependencies: [Logger]\n});\n"],"names":["NullSendToIdentityUseCaseImpl","logger","identity","data","Result","NullSendToIdentityUseCase","WebsocketsSendToIdentityUseCase","Logger"],"mappings":";;;AAYA,MAAMA;IACF,YAA6BC,MAAwB,CAAE;aAA1BA,MAAM,GAANA;IAA2B;IAExD,MAAM,QACFC,QAAkD,EAClDC,IAAyD,EAC3D;QACE,IAAI,CAAC,MAAM,CAAC,KAAK,CACb;YAAE,YAAYD,SAAS,EAAE;YAAE,QAAQC,KAAK,MAAM;QAAC,GAC/C;QAEJ,OAAOC,OAAO,EAAE;IACpB;AACJ;AAEO,MAAMC,4BAA4BC,gCAAgC,oBAAoB,CAAC;IAC1F,gBAAgBN;IAChB,cAAc;QAACO;KAAO;AAC1B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { GenericRecord } from "@webiny/api/types.js";
|
|
3
|
+
import type { IWebsocketsIdentity } from "../types.js";
|
|
4
|
+
import type { IWebsocketsTransportSendData } from "../types.js";
|
|
5
|
+
import type { WebsocketServiceError } from "../WebsocketServiceError.js";
|
|
6
|
+
export interface ISendToIdentityUseCase {
|
|
7
|
+
execute<T extends GenericRecord = GenericRecord>(identity: Pick<IWebsocketsIdentity, "id">, data: IWebsocketsTransportSendData<T>): Promise<Result<void, WebsocketServiceError>>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Sends a message to every open websocket connection of an identity. Declared here so that any
|
|
11
|
+
* package can send without depending on a websockets package; `@webiny/api-websockets` implements it.
|
|
12
|
+
* Without that package the send does nothing, see `NullSendToIdentityUseCase`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const WebsocketsSendToIdentityUseCase: import("@webiny/di").Abstraction<ISendToIdentityUseCase>;
|
|
15
|
+
export declare namespace WebsocketsSendToIdentityUseCase {
|
|
16
|
+
type Interface = ISendToIdentityUseCase;
|
|
17
|
+
type Identity = Pick<IWebsocketsIdentity, "id">;
|
|
18
|
+
type Data<T extends GenericRecord> = IWebsocketsTransportSendData<T>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/websockets/SendToIdentity/abstractions.js","sources":["../../../../src/features/websockets/SendToIdentity/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Result } from \"@webiny/feature/api\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { IWebsocketsIdentity } from \"../types.js\";\nimport type { IWebsocketsTransportSendData } from \"../types.js\";\nimport type { WebsocketServiceError } from \"../WebsocketServiceError.js\";\n\nexport interface ISendToIdentityUseCase {\n execute<T extends GenericRecord = GenericRecord>(\n identity: Pick<IWebsocketsIdentity, \"id\">,\n data: IWebsocketsTransportSendData<T>\n ): Promise<Result<void, WebsocketServiceError>>;\n}\n\n/**\n * Sends a message to every open websocket connection of an identity. Declared here so that any\n * package can send without depending on a websockets package; `@webiny/api-websockets` implements it.\n * Without that package the send does nothing, see `NullSendToIdentityUseCase`.\n */\nexport const WebsocketsSendToIdentityUseCase = createAbstraction<ISendToIdentityUseCase>(\n \"Websockets/SendToIdentity\"\n);\n\nexport namespace WebsocketsSendToIdentityUseCase {\n export type Interface = ISendToIdentityUseCase;\n export type Identity = Pick<IWebsocketsIdentity, \"id\">;\n export type Data<T extends GenericRecord> = IWebsocketsTransportSendData<T>;\n}\n"],"names":["WebsocketsSendToIdentityUseCase","createAbstraction"],"mappings":";AAmBO,MAAMA,kCAAkCC,kBAC3C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseError } from "@webiny/feature/api";
|
|
2
|
+
class WebsocketServiceError extends BaseError {
|
|
3
|
+
constructor(error){
|
|
4
|
+
super({
|
|
5
|
+
message: "WebsocketService encountered an error.",
|
|
6
|
+
data: {
|
|
7
|
+
error
|
|
8
|
+
}
|
|
9
|
+
}), this.code = "Websocket/Service";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export { WebsocketServiceError };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=WebsocketServiceError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/websockets/WebsocketServiceError.js","sources":["../../../src/features/websockets/WebsocketServiceError.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\n\nexport class WebsocketServiceError extends BaseError<{ error: Error }> {\n override readonly code = \"Websocket/Service\" as const;\n\n constructor(error: Error) {\n super({\n message: \"WebsocketService encountered an error.\",\n data: { error }\n });\n }\n}\n"],"names":["WebsocketServiceError","BaseError","error"],"mappings":";AAEO,MAAMA,8BAA8BC;IAGvC,YAAYC,KAAY,CAAE;QACtB,KAAK,CAAC;YACF,SAAS;YACT,MAAM;gBAAEA;YAAM;QAClB,SANc,IAAI,GAAG;IAOzB;AACJ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { WebsocketsSendToIdentityUseCase } from "./SendToIdentity/abstractions.js";
|
|
2
|
+
export { NullSendToIdentityUseCase } from "./SendToIdentity/NullSendToIdentityUseCase.js";
|
|
3
|
+
export { NotifyRecordChangeFeature, NotifyRecordChangeUseCase, RECORD_CHANGED_WEBSOCKET_ACTION } from "./NotifyRecordChange/index.js";
|
|
4
|
+
export { WebsocketServiceError } from "./WebsocketServiceError.js";
|
|
5
|
+
export type { IWebsocketsIdentity } from "./types.js";
|
|
6
|
+
export type { IWebsocketsTransportSendData } from "./types.js";
|
|
7
|
+
export type { IWebsocketsTransportSendDataError } from "./types.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { WebsocketsSendToIdentityUseCase } from "./SendToIdentity/abstractions.js";
|
|
2
|
+
export { NullSendToIdentityUseCase } from "./SendToIdentity/NullSendToIdentityUseCase.js";
|
|
3
|
+
export { NotifyRecordChangeFeature, NotifyRecordChangeUseCase, RECORD_CHANGED_WEBSOCKET_ACTION } from "./NotifyRecordChange/index.js";
|
|
4
|
+
export { WebsocketServiceError } from "./WebsocketServiceError.js";
|