@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/security/ai/DeleteTeamTool.js","sources":["../../../../src/features/security/ai/DeleteTeamTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition } from \"~/features/ai/index.js\";\nimport { AiSdkToolHandler } from \"~/features/ai/index.js\";\nimport { GetTeamUseCase } from \"~/features/security/teams/GetTeam/index.js\";\nimport { DeleteTeam } from \"~/features/security/teams/DeleteTeam/index.js\";\n\nconst inputSchema = z.object({\n teamId: z.string().describe(\"Team id as returned by listTeams.\"),\n name: z\n .string()\n .describe(\n \"The team's current name, exactly as listTeams returned it. The delete is refused if it does not match.\"\n )\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface DeletedTeam {\n id: string;\n name: string;\n slug: string;\n}\n\n/*\n * The name is part of the input so the approval shows the user which team goes, rather than only an\n * id. The model supplies it, so it is checked against the stored team before anything is deleted:\n * what the user approved by name has to be the team that is removed.\n */\nclass DeleteTeamToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {\n constructor(\n private getTeam: GetTeamUseCase.Interface,\n private deleteTeam: DeleteTeam.Interface\n ) {}\n\n async execute(input: Input): Promise<DeletedTeam> {\n const found = await this.getTeam.execute({ id: input.teamId });\n\n if (found.isFail()) {\n throw new Error(\n `Team \"${input.teamId}\" not found: ${found.error.message}. Call listTeams for valid ids.`\n );\n }\n\n const team = found.value;\n\n if (team.name !== input.name) {\n throw new Error(\n `Team \"${input.teamId}\" is named \"${team.name}\", not \"${input.name}\", so nothing was deleted. Check the team with listTeams.`\n );\n }\n\n const result = await this.deleteTeam.execute(team.id);\n\n if (result.isFail()) {\n throw new Error(`Could not delete the team: ${result.error.message}`);\n }\n\n return { id: team.id, name: team.name, slug: team.slug };\n }\n}\n\nconst DeleteTeamToolHandler = AiSdkToolHandler.createImplementation({\n implementation: DeleteTeamToolHandlerImpl,\n dependencies: [GetTeamUseCase, DeleteTeam]\n});\n\n/**\n * Deletes one team.\n *\n * Destructive, so the approval says it cannot be undone. System teams and teams defined in code are\n * refused by `DeleteTeam`, and that error reaches the model as-is.\n */\nclass DeleteTeamToolImpl implements AiSdkToolDefinition.Interface<Input> {\n readonly name = \"deleteTeam\";\n readonly title = \"Delete team\";\n readonly description =\n \"Deletes one team. System teams and teams defined in code are refused. Call listTeams first for the id and exact name. Requires user approval.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: false, destructiveHint: true };\n readonly handler = DeleteTeamToolHandler;\n}\n\nexport const DeleteTeamTool = AiSdkToolDefinition.createImplementation({\n implementation: DeleteTeamToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","DeleteTeamToolHandlerImpl","getTeam","deleteTeam","input","found","Error","team","result","DeleteTeamToolHandler","AiSdkToolHandler","GetTeamUseCase","DeleteTeam","DeleteTeamToolImpl","DeleteTeamTool","AiSdkToolDefinition"],"mappings":";;;;AAMA,MAAMA,cAAcC,EAAE,MAAM,CAAC;IACzB,QAAQA,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B,MAAMA,EAAAA,MACK,GACN,QAAQ,CACL;AAEZ;AAeA,MAAMC;IACF,YACYC,OAAiC,EACjCC,UAAgC,CAC1C;aAFUD,OAAO,GAAPA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,QAAQC,KAAY,EAAwB;QAC9C,MAAMC,QAAQ,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;YAAE,IAAID,MAAM,MAAM;QAAC;QAE5D,IAAIC,MAAM,MAAM,IACZ,MAAM,IAAIC,MACN,CAAC,MAAM,EAAEF,MAAM,MAAM,CAAC,aAAa,EAAEC,MAAM,KAAK,CAAC,OAAO,CAAC,+BAA+B,CAAC;QAIjG,MAAME,OAAOF,MAAM,KAAK;QAExB,IAAIE,KAAK,IAAI,KAAKH,MAAM,IAAI,EACxB,MAAM,IAAIE,MACN,CAAC,MAAM,EAAEF,MAAM,MAAM,CAAC,YAAY,EAAEG,KAAK,IAAI,CAAC,QAAQ,EAAEH,MAAM,IAAI,CAAC,yDAAyD,CAAC;QAIrI,MAAMI,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACD,KAAK,EAAE;QAEpD,IAAIC,OAAO,MAAM,IACb,MAAM,IAAIF,MAAM,CAAC,2BAA2B,EAAEE,OAAO,KAAK,CAAC,OAAO,EAAE;QAGxE,OAAO;YAAE,IAAID,KAAK,EAAE;YAAE,MAAMA,KAAK,IAAI;YAAE,MAAMA,KAAK,IAAI;QAAC;IAC3D;AACJ;AAEA,MAAME,wBAAwBC,iBAAiB,oBAAoB,CAAC;IAChE,gBAAgBT;IAChB,cAAc;QAACU;QAAgBC;KAAW;AAC9C;AAQA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGd;aACd,WAAW,GAAG;YAAE,cAAc;YAAO,iBAAiB;QAAK;aAC3D,OAAO,GAAGU;;AACvB;AAEO,MAAMK,iBAAiBC,oBAAoB,oBAAoB,CAAC;IACnE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AiSdkToolDefinition } from "../../../features/ai/index.js";
|
|
3
|
+
import { AiSdkToolHandler } from "../../../features/ai/index.js";
|
|
4
|
+
import { ListRolesUseCase } from "../../../features/security/roles/ListRoles/index.js";
|
|
5
|
+
interface RoleSummary {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
slug: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
}
|
|
11
|
+
declare class ListRolesToolHandlerImpl implements AiSdkToolHandler.Interface<Record<string, never>> {
|
|
12
|
+
private listRoles;
|
|
13
|
+
constructor(listRoles: ListRolesUseCase.Interface);
|
|
14
|
+
execute(): Promise<RoleSummary[]>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolves role names to the IDs `createTeam` takes. Separate from the write, so the user approves a
|
|
18
|
+
* team with roles that were looked up rather than guessed.
|
|
19
|
+
*
|
|
20
|
+
* Returns the slug too, because it is what a human recognises and what the admin UI shows, while
|
|
21
|
+
* `id` is what a team actually stores. Nothing at the type level separates the two, so `createTeam`
|
|
22
|
+
* accepts either and resolves it rather than making the caller guess which one that field wants.
|
|
23
|
+
*/
|
|
24
|
+
declare class ListRolesToolImpl implements AiSdkToolDefinition.Interface<Record<string, never>> {
|
|
25
|
+
readonly name = "listRoles";
|
|
26
|
+
readonly title = "List roles";
|
|
27
|
+
readonly description = "Lists the security roles in this project with their ids, names and slugs. createTeam and updateTeam take role ids (a slug also works; anything else is rejected). updateRole and deleteRole take the id, and deleteRole also the exact name.";
|
|
28
|
+
readonly inputSchema: z.ZodObject<{}, z.core.$strip>;
|
|
29
|
+
readonly annotations: {
|
|
30
|
+
readOnlyHint: boolean;
|
|
31
|
+
idempotentHint: boolean;
|
|
32
|
+
};
|
|
33
|
+
readonly handler: typeof ListRolesToolHandlerImpl & {
|
|
34
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../ai/abstractions").IAiSdkToolHandler<any>>;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export declare const ListRolesTool: typeof ListRolesToolImpl & {
|
|
38
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../ai/abstractions").IAiSdkToolDefinition<any>>;
|
|
39
|
+
};
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AiSdkToolDefinition, AiSdkToolHandler } from "../../ai/index.js";
|
|
3
|
+
import { ListRolesUseCase } from "../roles/ListRoles/index.js";
|
|
4
|
+
const inputSchema = z.object({});
|
|
5
|
+
class ListRolesToolHandlerImpl {
|
|
6
|
+
constructor(listRoles){
|
|
7
|
+
this.listRoles = listRoles;
|
|
8
|
+
}
|
|
9
|
+
async execute() {
|
|
10
|
+
const result = await this.listRoles.execute();
|
|
11
|
+
if (result.isFail()) throw new Error(`Could not list roles: ${result.error.message}`);
|
|
12
|
+
return result.value.map((role)=>{
|
|
13
|
+
const summary = {
|
|
14
|
+
id: role.id,
|
|
15
|
+
name: role.name,
|
|
16
|
+
slug: role.slug
|
|
17
|
+
};
|
|
18
|
+
if (role.description) summary.description = role.description;
|
|
19
|
+
return summary;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const ListRolesToolHandler = AiSdkToolHandler.createImplementation({
|
|
24
|
+
implementation: ListRolesToolHandlerImpl,
|
|
25
|
+
dependencies: [
|
|
26
|
+
ListRolesUseCase
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
class ListRolesToolImpl {
|
|
30
|
+
constructor(){
|
|
31
|
+
this.name = "listRoles";
|
|
32
|
+
this.title = "List roles";
|
|
33
|
+
this.description = "Lists the security roles in this project with their ids, names and slugs. createTeam and updateTeam take role ids (a slug also works; anything else is rejected). updateRole and deleteRole take the id, and deleteRole also the exact name.";
|
|
34
|
+
this.inputSchema = inputSchema;
|
|
35
|
+
this.annotations = {
|
|
36
|
+
readOnlyHint: true,
|
|
37
|
+
idempotentHint: true
|
|
38
|
+
};
|
|
39
|
+
this.handler = ListRolesToolHandler;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const ListRolesTool = AiSdkToolDefinition.createImplementation({
|
|
43
|
+
implementation: ListRolesToolImpl,
|
|
44
|
+
dependencies: []
|
|
45
|
+
});
|
|
46
|
+
export { ListRolesTool };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=ListRolesTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/security/ai/ListRolesTool.js","sources":["../../../../src/features/security/ai/ListRolesTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition } from \"~/features/ai/index.js\";\nimport { AiSdkToolHandler } from \"~/features/ai/index.js\";\nimport { ListRolesUseCase } from \"~/features/security/roles/ListRoles/index.js\";\n\nconst inputSchema = z.object({});\n\ninterface RoleSummary {\n id: string;\n name: string;\n slug: string;\n description?: string;\n}\n\nclass ListRolesToolHandlerImpl implements AiSdkToolHandler.Interface<Record<string, never>> {\n constructor(private listRoles: ListRolesUseCase.Interface) {}\n\n async execute(): Promise<RoleSummary[]> {\n const result = await this.listRoles.execute();\n\n if (result.isFail()) {\n throw new Error(`Could not list roles: ${result.error.message}`);\n }\n\n return result.value.map(role => {\n const summary: RoleSummary = {\n id: role.id,\n name: role.name,\n slug: role.slug\n };\n\n if (role.description) {\n summary.description = role.description;\n }\n\n return summary;\n });\n }\n}\n\nconst ListRolesToolHandler = AiSdkToolHandler.createImplementation({\n implementation: ListRolesToolHandlerImpl,\n dependencies: [ListRolesUseCase]\n});\n\n/**\n * Resolves role names to the IDs `createTeam` takes. Separate from the write, so the user approves a\n * team with roles that were looked up rather than guessed.\n *\n * Returns the slug too, because it is what a human recognises and what the admin UI shows, while\n * `id` is what a team actually stores. Nothing at the type level separates the two, so `createTeam`\n * accepts either and resolves it rather than making the caller guess which one that field wants.\n */\nclass ListRolesToolImpl implements AiSdkToolDefinition.Interface<Record<string, never>> {\n readonly name = \"listRoles\";\n readonly title = \"List roles\";\n readonly description =\n \"Lists the security roles in this project with their ids, names and slugs. createTeam and updateTeam take role ids (a slug also works; anything else is rejected). updateRole and deleteRole take the id, and deleteRole also the exact name.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: true, idempotentHint: true };\n readonly handler = ListRolesToolHandler;\n}\n\nexport const ListRolesTool = AiSdkToolDefinition.createImplementation({\n implementation: ListRolesToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","ListRolesToolHandlerImpl","listRoles","result","Error","role","summary","ListRolesToolHandler","AiSdkToolHandler","ListRolesUseCase","ListRolesToolImpl","ListRolesTool","AiSdkToolDefinition"],"mappings":";;;AAKA,MAAMA,cAAcC,EAAE,MAAM,CAAC,CAAC;AAS9B,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;YACpB,MAAMC,UAAuB;gBACzB,IAAID,KAAK,EAAE;gBACX,MAAMA,KAAK,IAAI;gBACf,MAAMA,KAAK,IAAI;YACnB;YAEA,IAAIA,KAAK,WAAW,EAChBC,QAAQ,WAAW,GAAGD,KAAK,WAAW;YAG1C,OAAOC;QACX;IACJ;AACJ;AAEA,MAAMC,uBAAuBC,iBAAiB,oBAAoB,CAAC;IAC/D,gBAAgBP;IAChB,cAAc;QAACQ;KAAiB;AACpC;AAUA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGX;aACd,WAAW,GAAG;YAAE,cAAc;YAAM,gBAAgB;QAAK;aACzD,OAAO,GAAGQ;;AACvB;AAEO,MAAMI,gBAAgBC,oBAAoB,oBAAoB,CAAC;IAClE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AiSdkToolDefinition } from "../../../features/ai/index.js";
|
|
3
|
+
import { AiSdkToolHandler } from "../../../features/ai/index.js";
|
|
4
|
+
import { ListTeamsUseCase } from "../../../features/security/teams/ListTeams/index.js";
|
|
5
|
+
declare const inputSchema: z.ZodObject<{}, z.core.$strip>;
|
|
6
|
+
type Input = z.infer<typeof inputSchema>;
|
|
7
|
+
interface TeamSummary {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
slug: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
/** Role ids, so `updateTeam` can be given the full list with one role added or removed. */
|
|
13
|
+
roles: string[];
|
|
14
|
+
}
|
|
15
|
+
declare class ListTeamsToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {
|
|
16
|
+
private listTeams;
|
|
17
|
+
constructor(listTeams: ListTeamsUseCase.Interface);
|
|
18
|
+
execute(): Promise<TeamSummary[]>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Resolves human names ("team A") to the ids folder permissions actually take.
|
|
22
|
+
*
|
|
23
|
+
* Kept separate from setFolderPermissions rather than accepting a team name there: the user approves
|
|
24
|
+
* the arguments of a write, so the id has to be looked up and shown, not guessed inside the write.
|
|
25
|
+
*/
|
|
26
|
+
declare class ListTeamsToolImpl implements AiSdkToolDefinition.Interface<Input> {
|
|
27
|
+
readonly name = "listTeams";
|
|
28
|
+
readonly title = "List teams";
|
|
29
|
+
readonly description = "Lists the teams in this project with their ids, names, slugs and role ids. Folder permission targets use the SLUG (`team:<slug>`), not the id; updateTeam and deleteTeam take the id.";
|
|
30
|
+
readonly inputSchema: z.ZodObject<{}, z.core.$strip>;
|
|
31
|
+
readonly annotations: {
|
|
32
|
+
readOnlyHint: boolean;
|
|
33
|
+
idempotentHint: boolean;
|
|
34
|
+
};
|
|
35
|
+
readonly handler: typeof ListTeamsToolHandlerImpl & {
|
|
36
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../ai/abstractions").IAiSdkToolHandler<any>>;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export declare const ListTeamsTool: typeof ListTeamsToolImpl & {
|
|
40
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../ai/abstractions").IAiSdkToolDefinition<any>>;
|
|
41
|
+
};
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AiSdkToolDefinition, AiSdkToolHandler } from "../../ai/index.js";
|
|
3
|
+
import { ListTeamsUseCase } from "../teams/ListTeams/index.js";
|
|
4
|
+
const inputSchema = z.object({});
|
|
5
|
+
class ListTeamsToolHandlerImpl {
|
|
6
|
+
constructor(listTeams){
|
|
7
|
+
this.listTeams = listTeams;
|
|
8
|
+
}
|
|
9
|
+
async execute() {
|
|
10
|
+
const result = await this.listTeams.execute();
|
|
11
|
+
if (result.isFail()) throw new Error(`Could not list teams: ${result.error.message}`);
|
|
12
|
+
return result.value.map((team)=>{
|
|
13
|
+
const summary = {
|
|
14
|
+
id: team.id,
|
|
15
|
+
name: team.name,
|
|
16
|
+
slug: team.slug,
|
|
17
|
+
roles: team.roles
|
|
18
|
+
};
|
|
19
|
+
if (team.description) summary.description = team.description;
|
|
20
|
+
return summary;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const ListTeamsToolHandler = AiSdkToolHandler.createImplementation({
|
|
25
|
+
implementation: ListTeamsToolHandlerImpl,
|
|
26
|
+
dependencies: [
|
|
27
|
+
ListTeamsUseCase
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
class ListTeamsToolImpl {
|
|
31
|
+
constructor(){
|
|
32
|
+
this.name = "listTeams";
|
|
33
|
+
this.title = "List teams";
|
|
34
|
+
this.description = "Lists the teams in this project with their ids, names, slugs and role ids. Folder permission targets use the SLUG (`team:<slug>`), not the id; updateTeam and deleteTeam take the id.";
|
|
35
|
+
this.inputSchema = inputSchema;
|
|
36
|
+
this.annotations = {
|
|
37
|
+
readOnlyHint: true,
|
|
38
|
+
idempotentHint: true
|
|
39
|
+
};
|
|
40
|
+
this.handler = ListTeamsToolHandler;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const ListTeamsTool = AiSdkToolDefinition.createImplementation({
|
|
44
|
+
implementation: ListTeamsToolImpl,
|
|
45
|
+
dependencies: []
|
|
46
|
+
});
|
|
47
|
+
export { ListTeamsTool };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=ListTeamsTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/security/ai/ListTeamsTool.js","sources":["../../../../src/features/security/ai/ListTeamsTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition } from \"~/features/ai/index.js\";\nimport { AiSdkToolHandler } from \"~/features/ai/index.js\";\nimport { ListTeamsUseCase } from \"~/features/security/teams/ListTeams/index.js\";\n\nconst inputSchema = z.object({});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface TeamSummary {\n id: string;\n name: string;\n slug: string;\n description?: string;\n /** Role ids, so `updateTeam` can be given the full list with one role added or removed. */\n roles: string[];\n}\n\nclass ListTeamsToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {\n constructor(private listTeams: ListTeamsUseCase.Interface) {}\n\n async execute(): Promise<TeamSummary[]> {\n const result = await this.listTeams.execute();\n\n if (result.isFail()) {\n throw new Error(`Could not list teams: ${result.error.message}`);\n }\n\n return result.value.map(team => {\n const summary: TeamSummary = {\n id: team.id,\n name: team.name,\n slug: team.slug,\n roles: team.roles\n };\n\n if (team.description) {\n summary.description = team.description;\n }\n\n return summary;\n });\n }\n}\n\nconst ListTeamsToolHandler = AiSdkToolHandler.createImplementation({\n implementation: ListTeamsToolHandlerImpl,\n dependencies: [ListTeamsUseCase]\n});\n\n/**\n * Resolves human names (\"team A\") to the ids folder permissions actually take.\n *\n * Kept separate from setFolderPermissions rather than accepting a team name there: the user approves\n * the arguments of a write, so the id has to be looked up and shown, not guessed inside the write.\n */\nclass ListTeamsToolImpl implements AiSdkToolDefinition.Interface<Input> {\n readonly name = \"listTeams\";\n readonly title = \"List teams\";\n readonly description =\n \"Lists the teams in this project with their ids, names, slugs and role ids. Folder permission targets use the SLUG (`team:<slug>`), not the id; updateTeam and deleteTeam take the id.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: true, idempotentHint: true };\n readonly handler = ListTeamsToolHandler;\n}\n\nexport const ListTeamsTool = AiSdkToolDefinition.createImplementation({\n implementation: ListTeamsToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","ListTeamsToolHandlerImpl","listTeams","result","Error","team","summary","ListTeamsToolHandler","AiSdkToolHandler","ListTeamsUseCase","ListTeamsToolImpl","ListTeamsTool","AiSdkToolDefinition"],"mappings":";;;AAKA,MAAMA,cAAcC,EAAE,MAAM,CAAC,CAAC;AAa9B,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;YACpB,MAAMC,UAAuB;gBACzB,IAAID,KAAK,EAAE;gBACX,MAAMA,KAAK,IAAI;gBACf,MAAMA,KAAK,IAAI;gBACf,OAAOA,KAAK,KAAK;YACrB;YAEA,IAAIA,KAAK,WAAW,EAChBC,QAAQ,WAAW,GAAGD,KAAK,WAAW;YAG1C,OAAOC;QACX;IACJ;AACJ;AAEA,MAAMC,uBAAuBC,iBAAiB,oBAAoB,CAAC;IAC/D,gBAAgBP;IAChB,cAAc;QAACQ;KAAiB;AACpC;AAQA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGX;aACd,WAAW,GAAG;YAAE,cAAc;YAAM,gBAAgB;QAAK;aACzD,OAAO,GAAGQ;;AACvB;AAEO,MAAMI,gBAAgBC,oBAAoB,oBAAoB,CAAC;IAClE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AiSdkToolDefinition } from "../../../features/ai/index.js";
|
|
3
|
+
import { AiSdkToolHandler } from "../../../features/ai/index.js";
|
|
4
|
+
import { UpdateRoleUseCase } from "../../../features/security/roles/UpdateRole/index.js";
|
|
5
|
+
declare const inputSchema: z.ZodObject<{
|
|
6
|
+
roleId: z.ZodString;
|
|
7
|
+
name: z.ZodOptional<z.ZodString>;
|
|
8
|
+
description: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
type Input = z.infer<typeof inputSchema>;
|
|
11
|
+
interface UpdatedRole {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
slug: string;
|
|
15
|
+
description: string;
|
|
16
|
+
}
|
|
17
|
+
declare class UpdateRoleToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {
|
|
18
|
+
private updateRole;
|
|
19
|
+
constructor(updateRole: UpdateRoleUseCase.Interface);
|
|
20
|
+
execute(input: Input): Promise<UpdatedRole>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Renames a role or changes its description. Permissions are out of reach for the same reason as in
|
|
24
|
+
* `createRole`. The slug cannot change because `UpdateRoleUseCase` does not accept one.
|
|
25
|
+
*/
|
|
26
|
+
declare class UpdateRoleToolImpl implements AiSdkToolDefinition.Interface<Input> {
|
|
27
|
+
readonly name = "updateRole";
|
|
28
|
+
readonly title = "Update role";
|
|
29
|
+
readonly description = "Changes a role's name or description. Call listRoles first for the id. Permissions cannot be changed with this tool; the user edits them on the Roles screen. Roles defined in code cannot be changed. Requires user approval.";
|
|
30
|
+
readonly inputSchema: z.ZodObject<{
|
|
31
|
+
roleId: z.ZodString;
|
|
32
|
+
name: z.ZodOptional<z.ZodString>;
|
|
33
|
+
description: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
readonly annotations: {
|
|
36
|
+
readOnlyHint: boolean;
|
|
37
|
+
idempotentHint: boolean;
|
|
38
|
+
};
|
|
39
|
+
readonly handler: typeof UpdateRoleToolHandlerImpl & {
|
|
40
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../ai/abstractions").IAiSdkToolHandler<any>>;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export declare const UpdateRoleTool: typeof UpdateRoleToolImpl & {
|
|
44
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../ai/abstractions").IAiSdkToolDefinition<any>>;
|
|
45
|
+
};
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AiSdkToolDefinition, AiSdkToolHandler } from "../../ai/index.js";
|
|
3
|
+
import { UpdateRoleUseCase } from "../roles/UpdateRole/index.js";
|
|
4
|
+
const inputSchema = z.object({
|
|
5
|
+
roleId: z.string().describe("Role id as returned by listRoles."),
|
|
6
|
+
name: z.string().min(3).optional().describe("New role name. Omit it to keep the current one."),
|
|
7
|
+
description: z.string().max(500).optional().describe("New description. Omit it to keep the current one; an empty string clears it.")
|
|
8
|
+
});
|
|
9
|
+
class UpdateRoleToolHandlerImpl {
|
|
10
|
+
constructor(updateRole){
|
|
11
|
+
this.updateRole = updateRole;
|
|
12
|
+
}
|
|
13
|
+
async execute(input) {
|
|
14
|
+
const result = await this.updateRole.execute(input.roleId, {
|
|
15
|
+
name: input.name,
|
|
16
|
+
description: input.description
|
|
17
|
+
});
|
|
18
|
+
if (result.isFail()) throw new Error(`Could not update the role: ${result.error.message}`);
|
|
19
|
+
const role = result.value;
|
|
20
|
+
return {
|
|
21
|
+
id: role.id,
|
|
22
|
+
name: role.name,
|
|
23
|
+
slug: role.slug,
|
|
24
|
+
description: role.description
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const UpdateRoleToolHandler = AiSdkToolHandler.createImplementation({
|
|
29
|
+
implementation: UpdateRoleToolHandlerImpl,
|
|
30
|
+
dependencies: [
|
|
31
|
+
UpdateRoleUseCase
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
class UpdateRoleToolImpl {
|
|
35
|
+
constructor(){
|
|
36
|
+
this.name = "updateRole";
|
|
37
|
+
this.title = "Update role";
|
|
38
|
+
this.description = "Changes a role's name or description. Call listRoles first for the id. Permissions cannot be changed with this tool; the user edits them on the Roles screen. Roles defined in code cannot be changed. Requires user approval.";
|
|
39
|
+
this.inputSchema = inputSchema;
|
|
40
|
+
this.annotations = {
|
|
41
|
+
readOnlyHint: false,
|
|
42
|
+
idempotentHint: true
|
|
43
|
+
};
|
|
44
|
+
this.handler = UpdateRoleToolHandler;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const UpdateRoleTool = AiSdkToolDefinition.createImplementation({
|
|
48
|
+
implementation: UpdateRoleToolImpl,
|
|
49
|
+
dependencies: []
|
|
50
|
+
});
|
|
51
|
+
export { UpdateRoleTool };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=UpdateRoleTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/security/ai/UpdateRoleTool.js","sources":["../../../../src/features/security/ai/UpdateRoleTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition } from \"~/features/ai/index.js\";\nimport { AiSdkToolHandler } from \"~/features/ai/index.js\";\nimport { UpdateRoleUseCase } from \"~/features/security/roles/UpdateRole/index.js\";\n\nconst inputSchema = z.object({\n roleId: z.string().describe(\"Role id as returned by listRoles.\"),\n name: z.string().min(3).optional().describe(\"New role name. Omit it to keep the current one.\"),\n description: z\n .string()\n .max(500)\n .optional()\n .describe(\"New description. Omit it to keep the current one; an empty string clears it.\")\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface UpdatedRole {\n id: string;\n name: string;\n slug: string;\n description: string;\n}\n\nclass UpdateRoleToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {\n constructor(private updateRole: UpdateRoleUseCase.Interface) {}\n\n async execute(input: Input): Promise<UpdatedRole> {\n // A field the model left out arrives as `undefined`; `UpdateRoleUseCase` leaves those alone.\n const result = await this.updateRole.execute(input.roleId, {\n name: input.name,\n description: input.description\n });\n\n if (result.isFail()) {\n throw new Error(`Could not update the role: ${result.error.message}`);\n }\n\n const role = result.value;\n\n return { id: role.id, name: role.name, slug: role.slug, description: role.description };\n }\n}\n\nconst UpdateRoleToolHandler = AiSdkToolHandler.createImplementation({\n implementation: UpdateRoleToolHandlerImpl,\n dependencies: [UpdateRoleUseCase]\n});\n\n/**\n * Renames a role or changes its description. Permissions are out of reach for the same reason as in\n * `createRole`. The slug cannot change because `UpdateRoleUseCase` does not accept one.\n */\nclass UpdateRoleToolImpl implements AiSdkToolDefinition.Interface<Input> {\n readonly name = \"updateRole\";\n readonly title = \"Update role\";\n readonly description =\n \"Changes a role's name or description. Call listRoles first for the id. Permissions cannot be changed with this tool; the user edits them on the Roles screen. Roles defined in code cannot be changed. Requires user approval.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: false, idempotentHint: true };\n readonly handler = UpdateRoleToolHandler;\n}\n\nexport const UpdateRoleTool = AiSdkToolDefinition.createImplementation({\n implementation: UpdateRoleToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","UpdateRoleToolHandlerImpl","updateRole","input","result","Error","role","UpdateRoleToolHandler","AiSdkToolHandler","UpdateRoleUseCase","UpdateRoleToolImpl","UpdateRoleTool","AiSdkToolDefinition"],"mappings":";;;AAKA,MAAMA,cAAcC,EAAE,MAAM,CAAC;IACzB,QAAQA,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC5C,aAAaA,EAAAA,MACF,GACN,GAAG,CAAC,KACJ,QAAQ,GACR,QAAQ,CAAC;AAClB;AAWA,MAAMC;IACF,YAAoBC,UAAuC,CAAE;aAAzCA,UAAU,GAAVA;IAA0C;IAE9D,MAAM,QAAQC,KAAY,EAAwB;QAE9C,MAAMC,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACD,MAAM,MAAM,EAAE;YACvD,MAAMA,MAAM,IAAI;YAChB,aAAaA,MAAM,WAAW;QAClC;QAEA,IAAIC,OAAO,MAAM,IACb,MAAM,IAAIC,MAAM,CAAC,2BAA2B,EAAED,OAAO,KAAK,CAAC,OAAO,EAAE;QAGxE,MAAME,OAAOF,OAAO,KAAK;QAEzB,OAAO;YAAE,IAAIE,KAAK,EAAE;YAAE,MAAMA,KAAK,IAAI;YAAE,MAAMA,KAAK,IAAI;YAAE,aAAaA,KAAK,WAAW;QAAC;IAC1F;AACJ;AAEA,MAAMC,wBAAwBC,iBAAiB,oBAAoB,CAAC;IAChE,gBAAgBP;IAChB,cAAc;QAACQ;KAAkB;AACrC;AAMA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGX;aACd,WAAW,GAAG;YAAE,cAAc;YAAO,gBAAgB;QAAK;aAC1D,OAAO,GAAGQ;;AACvB;AAEO,MAAMI,iBAAiBC,oBAAoB,oBAAoB,CAAC;IACnE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AiSdkToolDefinition } from "../../../features/ai/index.js";
|
|
3
|
+
import { AiSdkToolHandler } from "../../../features/ai/index.js";
|
|
4
|
+
import { UpdateTeam } from "../../../features/security/teams/UpdateTeam/index.js";
|
|
5
|
+
declare const inputSchema: z.ZodObject<{
|
|
6
|
+
teamId: z.ZodString;
|
|
7
|
+
name: z.ZodOptional<z.ZodString>;
|
|
8
|
+
description: z.ZodOptional<z.ZodString>;
|
|
9
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
type Input = z.infer<typeof inputSchema>;
|
|
12
|
+
interface UpdatedTeam {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
slug: string;
|
|
16
|
+
description: string;
|
|
17
|
+
roles: string[];
|
|
18
|
+
}
|
|
19
|
+
declare class UpdateTeamToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {
|
|
20
|
+
private updateTeam;
|
|
21
|
+
constructor(updateTeam: UpdateTeam.Interface);
|
|
22
|
+
execute(input: Input): Promise<UpdatedTeam>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Changes a team's name, description or roles. The slug cannot change: folder permissions refer to
|
|
26
|
+
* teams by slug.
|
|
27
|
+
*
|
|
28
|
+
* Needs approval for the same reason as `createTeam`: the roles decide what the team's members can
|
|
29
|
+
* do. `roles` replaces the stored list, and the approval shows that whole list, so a role the model
|
|
30
|
+
* left out is visible as missing before anything is written.
|
|
31
|
+
*/
|
|
32
|
+
declare class UpdateTeamToolImpl implements AiSdkToolDefinition.Interface<Input> {
|
|
33
|
+
readonly name = "updateTeam";
|
|
34
|
+
readonly title = "Update team";
|
|
35
|
+
readonly description = "Changes a team's name, description or roles. Call listTeams first for the id. `roles` replaces the team's whole role list, so pass every role it should keep; call listRoles to resolve them. System teams and teams defined in code cannot be changed. Requires user approval.";
|
|
36
|
+
readonly inputSchema: z.ZodObject<{
|
|
37
|
+
teamId: z.ZodString;
|
|
38
|
+
name: z.ZodOptional<z.ZodString>;
|
|
39
|
+
description: z.ZodOptional<z.ZodString>;
|
|
40
|
+
roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
readonly annotations: {
|
|
43
|
+
readOnlyHint: boolean;
|
|
44
|
+
idempotentHint: boolean;
|
|
45
|
+
};
|
|
46
|
+
readonly handler: typeof UpdateTeamToolHandlerImpl & {
|
|
47
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../ai/abstractions").IAiSdkToolHandler<any>>;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export declare const UpdateTeamTool: typeof UpdateTeamToolImpl & {
|
|
51
|
+
__abstraction: import("@webiny/di").Abstraction<import("../../ai/abstractions").IAiSdkToolDefinition<any>>;
|
|
52
|
+
};
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AiSdkToolDefinition, AiSdkToolHandler } from "../../ai/index.js";
|
|
3
|
+
import { UpdateTeam } from "../teams/UpdateTeam/index.js";
|
|
4
|
+
const inputSchema = z.object({
|
|
5
|
+
teamId: z.string().describe("Team id as returned by listTeams."),
|
|
6
|
+
name: z.string().min(3).optional().describe("New team name. Omit it to keep the current one."),
|
|
7
|
+
description: z.string().max(500).optional().describe("New description. Omit it to keep the current one; an empty string clears it."),
|
|
8
|
+
roles: z.array(z.string()).optional().describe("The complete list of roles the team should have afterwards. It REPLACES the stored list, so include the roles to keep. Omit it to leave the roles alone. Resolve values with listRoles first.")
|
|
9
|
+
});
|
|
10
|
+
class UpdateTeamToolHandlerImpl {
|
|
11
|
+
constructor(updateTeam){
|
|
12
|
+
this.updateTeam = updateTeam;
|
|
13
|
+
}
|
|
14
|
+
async execute(input) {
|
|
15
|
+
const result = await this.updateTeam.execute(input.teamId, {
|
|
16
|
+
name: input.name,
|
|
17
|
+
description: input.description,
|
|
18
|
+
roles: input.roles
|
|
19
|
+
});
|
|
20
|
+
if (result.isFail()) throw new Error(`Could not update the team: ${result.error.message}`);
|
|
21
|
+
const team = result.value;
|
|
22
|
+
return {
|
|
23
|
+
id: team.id,
|
|
24
|
+
name: team.name,
|
|
25
|
+
slug: team.slug,
|
|
26
|
+
description: team.description,
|
|
27
|
+
roles: team.roles
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const UpdateTeamToolHandler = AiSdkToolHandler.createImplementation({
|
|
32
|
+
implementation: UpdateTeamToolHandlerImpl,
|
|
33
|
+
dependencies: [
|
|
34
|
+
UpdateTeam
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
class UpdateTeamToolImpl {
|
|
38
|
+
constructor(){
|
|
39
|
+
this.name = "updateTeam";
|
|
40
|
+
this.title = "Update team";
|
|
41
|
+
this.description = "Changes a team's name, description or roles. Call listTeams first for the id. `roles` replaces the team's whole role list, so pass every role it should keep; call listRoles to resolve them. System teams and teams defined in code cannot be changed. Requires user approval.";
|
|
42
|
+
this.inputSchema = inputSchema;
|
|
43
|
+
this.annotations = {
|
|
44
|
+
readOnlyHint: false,
|
|
45
|
+
idempotentHint: true
|
|
46
|
+
};
|
|
47
|
+
this.handler = UpdateTeamToolHandler;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const UpdateTeamTool = AiSdkToolDefinition.createImplementation({
|
|
51
|
+
implementation: UpdateTeamToolImpl,
|
|
52
|
+
dependencies: []
|
|
53
|
+
});
|
|
54
|
+
export { UpdateTeamTool };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=UpdateTeamTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/security/ai/UpdateTeamTool.js","sources":["../../../../src/features/security/ai/UpdateTeamTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition } from \"~/features/ai/index.js\";\nimport { AiSdkToolHandler } from \"~/features/ai/index.js\";\nimport { UpdateTeam } from \"~/features/security/teams/UpdateTeam/index.js\";\n\nconst inputSchema = z.object({\n teamId: z.string().describe(\"Team id as returned by listTeams.\"),\n name: z.string().min(3).optional().describe(\"New team name. Omit it to keep the current one.\"),\n description: z\n .string()\n .max(500)\n .optional()\n .describe(\"New description. Omit it to keep the current one; an empty string clears it.\"),\n roles: z\n .array(z.string())\n .optional()\n .describe(\n \"The complete list of roles the team should have afterwards. It REPLACES the stored list, so include the roles to keep. Omit it to leave the roles alone. Resolve values with listRoles first.\"\n )\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface UpdatedTeam {\n id: string;\n name: string;\n slug: string;\n description: string;\n roles: string[];\n}\n\nclass UpdateTeamToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {\n constructor(private updateTeam: UpdateTeam.Interface) {}\n\n async execute(input: Input): Promise<UpdatedTeam> {\n // A field the model left out arrives as `undefined`; `UpdateTeam` leaves those alone.\n const result = await this.updateTeam.execute(input.teamId, {\n name: input.name,\n description: input.description,\n roles: input.roles\n });\n\n if (result.isFail()) {\n throw new Error(`Could not update the team: ${result.error.message}`);\n }\n\n const team = result.value;\n\n return {\n id: team.id,\n name: team.name,\n slug: team.slug,\n description: team.description,\n // From the updated team, so the caller sees the resolved ids that were actually stored.\n roles: team.roles\n };\n }\n}\n\nconst UpdateTeamToolHandler = AiSdkToolHandler.createImplementation({\n implementation: UpdateTeamToolHandlerImpl,\n dependencies: [UpdateTeam]\n});\n\n/**\n * Changes a team's name, description or roles. The slug cannot change: folder permissions refer to\n * teams by slug.\n *\n * Needs approval for the same reason as `createTeam`: the roles decide what the team's members can\n * do. `roles` replaces the stored list, and the approval shows that whole list, so a role the model\n * left out is visible as missing before anything is written.\n */\nclass UpdateTeamToolImpl implements AiSdkToolDefinition.Interface<Input> {\n readonly name = \"updateTeam\";\n readonly title = \"Update team\";\n readonly description =\n \"Changes a team's name, description or roles. Call listTeams first for the id. `roles` replaces the team's whole role list, so pass every role it should keep; call listRoles to resolve them. System teams and teams defined in code cannot be changed. Requires user approval.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: false, idempotentHint: true };\n readonly handler = UpdateTeamToolHandler;\n}\n\nexport const UpdateTeamTool = AiSdkToolDefinition.createImplementation({\n implementation: UpdateTeamToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","UpdateTeamToolHandlerImpl","updateTeam","input","result","Error","team","UpdateTeamToolHandler","AiSdkToolHandler","UpdateTeam","UpdateTeamToolImpl","UpdateTeamTool","AiSdkToolDefinition"],"mappings":";;;AAKA,MAAMA,cAAcC,EAAE,MAAM,CAAC;IACzB,QAAQA,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC5C,aAAaA,EAAAA,MACF,GACN,GAAG,CAAC,KACJ,QAAQ,GACR,QAAQ,CAAC;IACd,OAAOA,EAAAA,KACG,CAACA,EAAE,MAAM,IACd,QAAQ,GACR,QAAQ,CACL;AAEZ;AAYA,MAAMC;IACF,YAAoBC,UAAgC,CAAE;aAAlCA,UAAU,GAAVA;IAAmC;IAEvD,MAAM,QAAQC,KAAY,EAAwB;QAE9C,MAAMC,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACD,MAAM,MAAM,EAAE;YACvD,MAAMA,MAAM,IAAI;YAChB,aAAaA,MAAM,WAAW;YAC9B,OAAOA,MAAM,KAAK;QACtB;QAEA,IAAIC,OAAO,MAAM,IACb,MAAM,IAAIC,MAAM,CAAC,2BAA2B,EAAED,OAAO,KAAK,CAAC,OAAO,EAAE;QAGxE,MAAME,OAAOF,OAAO,KAAK;QAEzB,OAAO;YACH,IAAIE,KAAK,EAAE;YACX,MAAMA,KAAK,IAAI;YACf,MAAMA,KAAK,IAAI;YACf,aAAaA,KAAK,WAAW;YAE7B,OAAOA,KAAK,KAAK;QACrB;IACJ;AACJ;AAEA,MAAMC,wBAAwBC,iBAAiB,oBAAoB,CAAC;IAChE,gBAAgBP;IAChB,cAAc;QAACQ;KAAW;AAC9B;AAUA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGX;aACd,WAAW,GAAG;YAAE,cAAc;YAAO,gBAAgB;QAAK;aAC1D,OAAO,GAAGQ;;AACvB;AAEO,MAAMI,iBAAiBC,oBAAoB,oBAAoB,CAAC;IACnE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Team and role tools for AI callers.
|
|
3
|
+
*
|
|
4
|
+
* The list tools are read-only and run unattended. Creating, changing or deleting a team or a role is
|
|
5
|
+
* a write, so it pauses for the user to approve the exact arguments.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SecurityAiToolsFeature: {
|
|
8
|
+
name: string;
|
|
9
|
+
register(container: import("@webiny/di").Container): void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { ListTeamsTool } from "./ListTeamsTool.js";
|
|
3
|
+
import { CreateTeamTool } from "./CreateTeamTool.js";
|
|
4
|
+
import { UpdateTeamTool } from "./UpdateTeamTool.js";
|
|
5
|
+
import { DeleteTeamTool } from "./DeleteTeamTool.js";
|
|
6
|
+
import { ListRolesTool } from "./ListRolesTool.js";
|
|
7
|
+
import { CreateRoleTool } from "./CreateRoleTool.js";
|
|
8
|
+
import { UpdateRoleTool } from "./UpdateRoleTool.js";
|
|
9
|
+
import { DeleteRoleTool } from "./DeleteRoleTool.js";
|
|
10
|
+
const SecurityAiToolsFeature = createFeature({
|
|
11
|
+
name: "Security/AiTools",
|
|
12
|
+
register (container) {
|
|
13
|
+
container.register(ListTeamsTool);
|
|
14
|
+
container.register(CreateTeamTool);
|
|
15
|
+
container.register(UpdateTeamTool);
|
|
16
|
+
container.register(DeleteTeamTool);
|
|
17
|
+
container.register(ListRolesTool);
|
|
18
|
+
container.register(CreateRoleTool);
|
|
19
|
+
container.register(UpdateRoleTool);
|
|
20
|
+
container.register(DeleteRoleTool);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
export { SecurityAiToolsFeature };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/security/ai/feature.js","sources":["../../../../src/features/security/ai/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListTeamsTool } from \"./ListTeamsTool.js\";\nimport { CreateTeamTool } from \"./CreateTeamTool.js\";\nimport { UpdateTeamTool } from \"./UpdateTeamTool.js\";\nimport { DeleteTeamTool } from \"./DeleteTeamTool.js\";\nimport { ListRolesTool } from \"./ListRolesTool.js\";\nimport { CreateRoleTool } from \"./CreateRoleTool.js\";\nimport { UpdateRoleTool } from \"./UpdateRoleTool.js\";\nimport { DeleteRoleTool } from \"./DeleteRoleTool.js\";\n\n/**\n * Team and role tools for AI callers.\n *\n * The list tools are read-only and run unattended. Creating, changing or deleting a team or a role is\n * a write, so it pauses for the user to approve the exact arguments.\n */\nexport const SecurityAiToolsFeature = createFeature({\n name: \"Security/AiTools\",\n register(container) {\n container.register(ListTeamsTool);\n container.register(CreateTeamTool);\n container.register(UpdateTeamTool);\n container.register(DeleteTeamTool);\n container.register(ListRolesTool);\n container.register(CreateRoleTool);\n container.register(UpdateRoleTool);\n container.register(DeleteRoleTool);\n }\n});\n"],"names":["SecurityAiToolsFeature","createFeature","container","ListTeamsTool","CreateTeamTool","UpdateTeamTool","DeleteTeamTool","ListRolesTool","CreateRoleTool","UpdateRoleTool","DeleteRoleTool"],"mappings":";;;;;;;;;AAgBO,MAAMA,yBAAyBC,cAAc;IAChD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;QACnBL,UAAU,QAAQ,CAACM;QACnBN,UAAU,QAAQ,CAACO;QACnBP,UAAU,QAAQ,CAACQ;IACvB;AACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { SecurityAiToolsFeature } from "./feature.js";
|
|
2
|
+
export { ListTeamsTool } from "./ListTeamsTool.js";
|
|
3
|
+
export { CreateTeamTool } from "./CreateTeamTool.js";
|
|
4
|
+
export { UpdateTeamTool } from "./UpdateTeamTool.js";
|
|
5
|
+
export { DeleteTeamTool } from "./DeleteTeamTool.js";
|
|
6
|
+
export { ListRolesTool } from "./ListRolesTool.js";
|
|
7
|
+
export { CreateRoleTool } from "./CreateRoleTool.js";
|
|
8
|
+
export { UpdateRoleTool } from "./UpdateRoleTool.js";
|
|
9
|
+
export { DeleteRoleTool } from "./DeleteRoleTool.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { SecurityAiToolsFeature } from "./feature.js";
|
|
2
|
+
export { ListTeamsTool } from "./ListTeamsTool.js";
|
|
3
|
+
export { CreateTeamTool } from "./CreateTeamTool.js";
|
|
4
|
+
export { UpdateTeamTool } from "./UpdateTeamTool.js";
|
|
5
|
+
export { DeleteTeamTool } from "./DeleteTeamTool.js";
|
|
6
|
+
export { ListRolesTool } from "./ListRolesTool.js";
|
|
7
|
+
export { CreateRoleTool } from "./CreateRoleTool.js";
|
|
8
|
+
export { UpdateRoleTool } from "./UpdateRoleTool.js";
|
|
9
|
+
export { DeleteRoleTool } from "./DeleteRoleTool.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Authorizer } from "../authorization/Authorizer/abstractions.js";
|
|
2
2
|
class ApiKeyAuthorizerImpl {
|
|
3
3
|
async authorize(identity) {
|
|
4
|
-
if (
|
|
4
|
+
if ("api-key" !== identity.type) return null;
|
|
5
5
|
const permissions = identity.permissions;
|
|
6
6
|
return Array.isArray(permissions) ? permissions : [];
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/security/apiKeys/ApiKeyAuthorizer.js","sources":["../../../../src/features/security/apiKeys/ApiKeyAuthorizer.ts"],"sourcesContent":["import { Authorizer } from \"~/features/security/authorization/Authorizer/abstractions.js\";\nimport type { IAuthorizer } from \"~/features/security/authorization/Authorizer/abstractions.js\";\nimport type { Identity } from \"~/features/security/IdentityContext/Identity.js\";\nimport type { SecurityPermission } from \"~/types/security.js\";\n\nclass ApiKeyAuthorizerImpl implements IAuthorizer {\n async authorize(identity: Identity): Promise<SecurityPermission[] | null> {\n if (
|
|
1
|
+
{"version":3,"file":"features/security/apiKeys/ApiKeyAuthorizer.js","sources":["../../../../src/features/security/apiKeys/ApiKeyAuthorizer.ts"],"sourcesContent":["import { Authorizer } from \"~/features/security/authorization/Authorizer/abstractions.js\";\nimport type { IAuthorizer } from \"~/features/security/authorization/Authorizer/abstractions.js\";\nimport type { Identity } from \"~/features/security/IdentityContext/Identity.js\";\nimport type { SecurityPermission } from \"~/types/security.js\";\n\nclass ApiKeyAuthorizerImpl implements IAuthorizer {\n async authorize(identity: Identity): Promise<SecurityPermission[] | null> {\n if (identity.type !== \"api-key\") {\n return null;\n }\n const permissions = (identity as any).permissions;\n return Array.isArray(permissions) ? (permissions as SecurityPermission[]) : [];\n }\n}\n\nexport const ApiKeyAuthorizer = Authorizer.createImplementation({\n implementation: ApiKeyAuthorizerImpl,\n dependencies: []\n});\n"],"names":["ApiKeyAuthorizerImpl","identity","permissions","Array","ApiKeyAuthorizer","Authorizer"],"mappings":";AAKA,MAAMA;IACF,MAAM,UAAUC,QAAkB,EAAwC;QACtE,IAAIA,AAAkB,cAAlBA,SAAS,IAAI,EACb,OAAO;QAEX,MAAMC,cAAeD,SAAiB,WAAW;QACjD,OAAOE,MAAM,OAAO,CAACD,eAAgBA,cAAuC,EAAE;IAClF;AACJ;AAEO,MAAME,mBAAmBC,WAAW,oBAAoB,CAAC;IAC5D,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -2,16 +2,26 @@ import { AuthorizationContext as Abstraction, PermissionTransformer } from "./ab
|
|
|
2
2
|
import { Authorizer } from "../Authorizer/index.js";
|
|
3
3
|
import type { SecurityPermission } from "../../../../types/security.js";
|
|
4
4
|
import { Identity } from "../../../../features/security/IdentityContext/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Loads and caches permissions per identity object and tenant for the lifetime of the request.
|
|
7
|
+
* `IdentityContext.withIdentity` can switch the identity mid-request and `TenantContext` the
|
|
8
|
+
* tenant, so permissions loaded for one identity or tenant never answer for another. Keying by the
|
|
9
|
+
* object (not by id or a fingerprint) means two identities with the same id but a different
|
|
10
|
+
* context never share an entry (R69). A failed load is evicted, so the next check retries.
|
|
11
|
+
*/
|
|
5
12
|
export declare class AuthorizationContext implements Abstraction.Interface {
|
|
6
13
|
private getAuthorizers;
|
|
7
14
|
private getTransformers;
|
|
8
|
-
private
|
|
9
|
-
private
|
|
10
|
-
|
|
15
|
+
private getTenantId;
|
|
16
|
+
private permissionsByIdentity;
|
|
17
|
+
private readonly authorizationEnabledOverrides;
|
|
18
|
+
constructor(getAuthorizers: () => Authorizer.Interface[], getTransformers: () => PermissionTransformer.Interface[], getTenantId: () => string | null);
|
|
11
19
|
loadPermissions(identity: Identity): Promise<SecurityPermission[]>;
|
|
12
20
|
isAuthorizationEnabled(): boolean;
|
|
13
21
|
withoutAuthorization<T>(cb: () => Promise<T>): Promise<T>;
|
|
22
|
+
withAuthorization<T>(cb: () => Promise<T>): Promise<T>;
|
|
14
23
|
clearPermissionsCache(): void;
|
|
24
|
+
private authorize;
|
|
15
25
|
private transformPermissions;
|
|
16
26
|
private deduplicatePermissions;
|
|
17
27
|
}
|