@webiny/api-aco 6.6.0-alpha.11 → 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.
Files changed (59) hide show
  1. package/features/ai/feature.d.ts +2 -2
  2. package/features/ai/feature.js +0 -16
  3. package/features/ai/feature.js.map +1 -1
  4. package/features/ai/index.d.ts +0 -8
  5. package/features/ai/index.js +0 -8
  6. package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js +0 -1
  7. package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js.map +1 -1
  8. package/features/flp/ListFolderAccess/mayAskAboutUser.js +1 -1
  9. package/features/flp/ListFolderAccess/mayAskAboutUser.js.map +1 -1
  10. package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.d.ts +3 -3
  11. package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.js +10 -10
  12. package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.js.map +1 -1
  13. package/features/folder/NotifyFolderChange/feature.js +0 -2
  14. package/features/folder/NotifyFolderChange/feature.js.map +1 -1
  15. package/features/folder/NotifyFolderChange/index.d.ts +1 -1
  16. package/features/folder/NotifyFolderChange/index.js +1 -1
  17. package/features/folder/NotifyFolderChange/recordType.d.ts +8 -0
  18. package/features/folder/NotifyFolderChange/recordType.js +4 -0
  19. package/features/folder/NotifyFolderChange/recordType.js.map +1 -0
  20. package/flpTaskCatalog/TaskFolderCatalogSync.d.ts +1 -0
  21. package/flpTaskCatalog/TaskFolderCatalogSync.js +7 -2
  22. package/flpTaskCatalog/TaskFolderCatalogSync.js.map +1 -1
  23. package/flpTaskCatalog/tasks/createFlp.task.d.ts +3 -3
  24. package/flpTaskCatalog/tasks/createFlp.task.js +7 -5
  25. package/flpTaskCatalog/tasks/createFlp.task.js.map +1 -1
  26. package/flpTaskCatalog/tasks/updateFlp.task.d.ts +3 -3
  27. package/flpTaskCatalog/tasks/updateFlp.task.js +7 -5
  28. package/flpTaskCatalog/tasks/updateFlp.task.js.map +1 -1
  29. package/package.json +18 -18
  30. package/features/ai/CreateRoleTool.d.ts +0 -54
  31. package/features/ai/CreateRoleTool.js +0 -71
  32. package/features/ai/CreateRoleTool.js.map +0 -1
  33. package/features/ai/CreateTeamTool.d.ts +0 -48
  34. package/features/ai/CreateTeamTool.js +0 -56
  35. package/features/ai/CreateTeamTool.js.map +0 -1
  36. package/features/ai/DeleteRoleTool.d.ts +0 -52
  37. package/features/ai/DeleteRoleTool.js +0 -79
  38. package/features/ai/DeleteRoleTool.js.map +0 -1
  39. package/features/ai/DeleteTeamTool.d.ts +0 -46
  40. package/features/ai/DeleteTeamTool.js +0 -56
  41. package/features/ai/DeleteTeamTool.js.map +0 -1
  42. package/features/ai/ListRolesTool.d.ts +0 -39
  43. package/features/ai/ListRolesTool.js +0 -48
  44. package/features/ai/ListRolesTool.js.map +0 -1
  45. package/features/ai/ListTeamsTool.d.ts +0 -41
  46. package/features/ai/ListTeamsTool.js +0 -49
  47. package/features/ai/ListTeamsTool.js.map +0 -1
  48. package/features/ai/UpdateRoleTool.d.ts +0 -46
  49. package/features/ai/UpdateRoleTool.js +0 -53
  50. package/features/ai/UpdateRoleTool.js.map +0 -1
  51. package/features/ai/UpdateTeamTool.d.ts +0 -52
  52. package/features/ai/UpdateTeamTool.js +0 -56
  53. package/features/ai/UpdateTeamTool.js.map +0 -1
  54. package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.d.ts +0 -11
  55. package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.js +0 -38
  56. package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.js.map +0 -1
  57. package/features/folder/NotifyFolderChange/abstractions.d.ts +0 -28
  58. package/features/folder/NotifyFolderChange/abstractions.js +0 -8
  59. package/features/folder/NotifyFolderChange/abstractions.js.map +0 -1
@@ -1,54 +0,0 @@
1
- import { z } from "zod";
2
- import { AiSdkToolDefinition } from "@webiny/api-core/features/ai/index.js";
3
- import { AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
4
- import { CreateRoleUseCase } from "@webiny/api-core/features/security/roles/CreateRole/index.js";
5
- import { GetRoleUseCase } from "@webiny/api-core/features/security/roles/GetRole/index.js";
6
- declare const inputSchema: z.ZodObject<{
7
- name: z.ZodString;
8
- slug: z.ZodString;
9
- description: z.ZodOptional<z.ZodString>;
10
- copyPermissionsFrom: z.ZodOptional<z.ZodString>;
11
- }, z.core.$strip>;
12
- type Input = z.infer<typeof inputSchema>;
13
- interface CreatedRole {
14
- id: string;
15
- name: string;
16
- slug: string;
17
- /** The role the permissions were copied from, so the reply can say where they came from. */
18
- permissionsCopiedFrom?: string;
19
- }
20
- declare class CreateRoleToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {
21
- private getRole;
22
- private createRole;
23
- constructor(getRole: GetRoleUseCase.Interface, createRole: CreateRoleUseCase.Interface);
24
- execute(input: Input): Promise<CreatedRole>;
25
- }
26
- /**
27
- * Creates a role, empty or with the permissions of an existing one.
28
- *
29
- * The model never writes permission objects. They are app-specific records with keys the model
30
- * would have to guess, and the approval card would show a list of them the user cannot check. A
31
- * role it creates either starts empty, for the user to fill in on the Roles screen, or copies a
32
- * role the user names, which the approval shows by id.
33
- */
34
- declare class CreateRoleToolImpl implements AiSdkToolDefinition.Interface<Input> {
35
- readonly name = "createRole";
36
- readonly title = "Create role";
37
- readonly description = "Creates a security role. It starts with no permissions, or with a copy of an existing role's permissions when `copyPermissionsFrom` is given (call listRoles for the id). Permissions cannot be written directly; the user edits them on the Roles screen. Requires user approval.";
38
- readonly inputSchema: z.ZodObject<{
39
- name: z.ZodString;
40
- slug: z.ZodString;
41
- description: z.ZodOptional<z.ZodString>;
42
- copyPermissionsFrom: z.ZodOptional<z.ZodString>;
43
- }, z.core.$strip>;
44
- readonly annotations: {
45
- readOnlyHint: boolean;
46
- };
47
- readonly handler: typeof CreateRoleToolHandlerImpl & {
48
- __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolHandler<any>>;
49
- };
50
- }
51
- export declare const CreateRoleTool: typeof CreateRoleToolImpl & {
52
- __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolDefinition<any>>;
53
- };
54
- export {};
@@ -1,71 +0,0 @@
1
- import { z } from "zod";
2
- import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
3
- import { CreateRoleUseCase } from "@webiny/api-core/features/security/roles/CreateRole/index.js";
4
- import { GetRoleUseCase } from "@webiny/api-core/features/security/roles/GetRole/index.js";
5
- import { descriptionOnCreate } from "@webiny/api-core/features/security/shared/index.js";
6
- const inputSchema = z.object({
7
- name: z.string().min(3).describe("Human-readable role name, e.g. 'Blog editor'."),
8
- slug: z.string().min(3).describe("URL-safe identifier, e.g. 'blog-editor'. Lowercase, hyphens instead of spaces."),
9
- description: z.string().max(500).optional().describe("What the role is for. Shown in the admin UI. Omit it if the user did not say."),
10
- copyPermissionsFrom: z.string().optional().describe("Id of an existing role, from listRoles, whose permissions the new role starts with. Omit it to create the role with no permissions.")
11
- });
12
- class CreateRoleToolHandlerImpl {
13
- constructor(getRole, createRole){
14
- this.getRole = getRole;
15
- this.createRole = createRole;
16
- }
17
- async execute(input) {
18
- let permissions = [];
19
- let source;
20
- if (input.copyPermissionsFrom) {
21
- const found = await this.getRole.execute({
22
- id: input.copyPermissionsFrom
23
- });
24
- if (found.isFail()) throw new Error(`Role "${input.copyPermissionsFrom}" not found: ${found.error.message}. Call listRoles for valid ids.`);
25
- permissions = found.value.permissions;
26
- source = found.value.name;
27
- }
28
- const description = descriptionOnCreate(input.description);
29
- const result = await this.createRole.execute({
30
- name: input.name,
31
- slug: input.slug,
32
- description,
33
- permissions
34
- });
35
- if (result.isFail()) throw new Error(`Could not create the role: ${result.error.message}`);
36
- const role = result.value;
37
- const created = {
38
- id: role.id,
39
- name: role.name,
40
- slug: role.slug
41
- };
42
- if (source) created.permissionsCopiedFrom = source;
43
- return created;
44
- }
45
- }
46
- const CreateRoleToolHandler = AiSdkToolHandler.createImplementation({
47
- implementation: CreateRoleToolHandlerImpl,
48
- dependencies: [
49
- GetRoleUseCase,
50
- CreateRoleUseCase
51
- ]
52
- });
53
- class CreateRoleToolImpl {
54
- constructor(){
55
- this.name = "createRole";
56
- this.title = "Create role";
57
- this.description = "Creates a security role. It starts with no permissions, or with a copy of an existing role's permissions when `copyPermissionsFrom` is given (call listRoles for the id). Permissions cannot be written directly; the user edits them on the Roles screen. Requires user approval.";
58
- this.inputSchema = inputSchema;
59
- this.annotations = {
60
- readOnlyHint: false
61
- };
62
- this.handler = CreateRoleToolHandler;
63
- }
64
- }
65
- const CreateRoleTool = AiSdkToolDefinition.createImplementation({
66
- implementation: CreateRoleToolImpl,
67
- dependencies: []
68
- });
69
- export { CreateRoleTool };
70
-
71
- //# sourceMappingURL=CreateRoleTool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"features/ai/CreateRoleTool.js","sources":["../../../src/features/ai/CreateRoleTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition } from \"@webiny/api-core/features/ai/index.js\";\nimport { AiSdkToolHandler } from \"@webiny/api-core/features/ai/index.js\";\nimport { CreateRoleUseCase } from \"@webiny/api-core/features/security/roles/CreateRole/index.js\";\nimport { GetRoleUseCase } from \"@webiny/api-core/features/security/roles/GetRole/index.js\";\nimport { descriptionOnCreate } from \"@webiny/api-core/features/security/shared/index.js\";\nimport type { SecurityPermission } from \"@webiny/api-core/types/security.js\";\n\nconst inputSchema = z.object({\n name: z.string().min(3).describe(\"Human-readable role name, e.g. 'Blog editor'.\"),\n slug: z\n .string()\n .min(3)\n .describe(\"URL-safe identifier, e.g. 'blog-editor'. Lowercase, hyphens instead of spaces.\"),\n description: z\n .string()\n .max(500)\n .optional()\n .describe(\"What the role is for. Shown in the admin UI. Omit it if the user did not say.\"),\n copyPermissionsFrom: z\n .string()\n .optional()\n .describe(\n \"Id of an existing role, from listRoles, whose permissions the new role starts with. Omit it to create the role with no permissions.\"\n )\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface CreatedRole {\n id: string;\n name: string;\n slug: string;\n /** The role the permissions were copied from, so the reply can say where they came from. */\n permissionsCopiedFrom?: string;\n}\n\nclass CreateRoleToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {\n constructor(\n private getRole: GetRoleUseCase.Interface,\n private createRole: CreateRoleUseCase.Interface\n ) {}\n\n async execute(input: Input): Promise<CreatedRole> {\n let permissions: SecurityPermission[] = [];\n let source: string | undefined;\n\n if (input.copyPermissionsFrom) {\n const found = await this.getRole.execute({ id: input.copyPermissionsFrom });\n\n if (found.isFail()) {\n throw new Error(\n `Role \"${input.copyPermissionsFrom}\" not found: ${found.error.message}. Call listRoles for valid ids.`\n );\n }\n\n permissions = found.value.permissions;\n source = found.value.name;\n }\n\n const description = descriptionOnCreate(input.description);\n const result = await this.createRole.execute({\n name: input.name,\n slug: input.slug,\n description,\n permissions\n });\n\n if (result.isFail()) {\n throw new Error(`Could not create the role: ${result.error.message}`);\n }\n\n const role = result.value;\n const created: CreatedRole = { id: role.id, name: role.name, slug: role.slug };\n\n if (source) {\n created.permissionsCopiedFrom = source;\n }\n\n return created;\n }\n}\n\nconst CreateRoleToolHandler = AiSdkToolHandler.createImplementation({\n implementation: CreateRoleToolHandlerImpl,\n dependencies: [GetRoleUseCase, CreateRoleUseCase]\n});\n\n/**\n * Creates a role, empty or with the permissions of an existing one.\n *\n * The model never writes permission objects. They are app-specific records with keys the model\n * would have to guess, and the approval card would show a list of them the user cannot check. A\n * role it creates either starts empty, for the user to fill in on the Roles screen, or copies a\n * role the user names, which the approval shows by id.\n */\nclass CreateRoleToolImpl implements AiSdkToolDefinition.Interface<Input> {\n readonly name = \"createRole\";\n readonly title = \"Create role\";\n readonly description =\n \"Creates a security role. It starts with no permissions, or with a copy of an existing role's permissions when `copyPermissionsFrom` is given (call listRoles for the id). Permissions cannot be written directly; the user edits them on the Roles screen. Requires user approval.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: false };\n readonly handler = CreateRoleToolHandler;\n}\n\nexport const CreateRoleTool = AiSdkToolDefinition.createImplementation({\n implementation: CreateRoleToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","CreateRoleToolHandlerImpl","getRole","createRole","input","permissions","source","found","Error","description","descriptionOnCreate","result","role","created","CreateRoleToolHandler","AiSdkToolHandler","GetRoleUseCase","CreateRoleUseCase","CreateRoleToolImpl","CreateRoleTool","AiSdkToolDefinition"],"mappings":";;;;;AAQA,MAAMA,cAAcC,EAAE,MAAM,CAAC;IACzB,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG,QAAQ,CAAC;IACjC,MAAMA,EAAAA,MACK,GACN,GAAG,CAAC,GACJ,QAAQ,CAAC;IACd,aAAaA,EAAAA,MACF,GACN,GAAG,CAAC,KACJ,QAAQ,GACR,QAAQ,CAAC;IACd,qBAAqBA,EAAAA,MACV,GACN,QAAQ,GACR,QAAQ,CACL;AAEZ;AAYA,MAAMC;IACF,YACYC,OAAiC,EACjCC,UAAuC,CACjD;aAFUD,OAAO,GAAPA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,QAAQC,KAAY,EAAwB;QAC9C,IAAIC,cAAoC,EAAE;QAC1C,IAAIC;QAEJ,IAAIF,MAAM,mBAAmB,EAAE;YAC3B,MAAMG,QAAQ,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;gBAAE,IAAIH,MAAM,mBAAmB;YAAC;YAEzE,IAAIG,MAAM,MAAM,IACZ,MAAM,IAAIC,MACN,CAAC,MAAM,EAAEJ,MAAM,mBAAmB,CAAC,aAAa,EAAEG,MAAM,KAAK,CAAC,OAAO,CAAC,+BAA+B,CAAC;YAI9GF,cAAcE,MAAM,KAAK,CAAC,WAAW;YACrCD,SAASC,MAAM,KAAK,CAAC,IAAI;QAC7B;QAEA,MAAME,cAAcC,oBAAoBN,MAAM,WAAW;QACzD,MAAMO,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YACzC,MAAMP,MAAM,IAAI;YAChB,MAAMA,MAAM,IAAI;YAChBK;YACAJ;QACJ;QAEA,IAAIM,OAAO,MAAM,IACb,MAAM,IAAIH,MAAM,CAAC,2BAA2B,EAAEG,OAAO,KAAK,CAAC,OAAO,EAAE;QAGxE,MAAMC,OAAOD,OAAO,KAAK;QACzB,MAAME,UAAuB;YAAE,IAAID,KAAK,EAAE;YAAE,MAAMA,KAAK,IAAI;YAAE,MAAMA,KAAK,IAAI;QAAC;QAE7E,IAAIN,QACAO,QAAQ,qBAAqB,GAAGP;QAGpC,OAAOO;IACX;AACJ;AAEA,MAAMC,wBAAwBC,iBAAiB,oBAAoB,CAAC;IAChE,gBAAgBd;IAChB,cAAc;QAACe;QAAgBC;KAAkB;AACrD;AAUA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGnB;aACd,WAAW,GAAG;YAAE,cAAc;QAAM;aACpC,OAAO,GAAGe;;AACvB;AAEO,MAAMK,iBAAiBC,oBAAoB,oBAAoB,CAAC;IACnE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
@@ -1,48 +0,0 @@
1
- import { z } from "zod";
2
- import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
3
- import { CreateTeam } from "@webiny/api-core/features/security/teams/CreateTeam/index.js";
4
- declare const inputSchema: z.ZodObject<{
5
- name: z.ZodString;
6
- slug: z.ZodString;
7
- description: z.ZodOptional<z.ZodString>;
8
- roles: z.ZodArray<z.ZodString>;
9
- }, z.core.$strip>;
10
- type Input = z.infer<typeof inputSchema>;
11
- interface CreatedTeam {
12
- id: string;
13
- name: string;
14
- slug: string;
15
- roles: string[];
16
- }
17
- declare class CreateTeamToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {
18
- private createTeam;
19
- constructor(createTeam: CreateTeam.Interface);
20
- execute(input: Input): Promise<CreatedTeam>;
21
- }
22
- /**
23
- * Creates a team.
24
- *
25
- * Not read-only, so it needs approval: a team is an access-control object, and the roles it carries
26
- * decide what its members can do. The user should see which roles are being granted before it exists.
27
- */
28
- declare class CreateTeamToolImpl implements AiSdkToolDefinition.Interface<Input> {
29
- readonly name = "createTeam";
30
- readonly title = "Create team";
31
- readonly description = "Creates a team with a set of roles. Call listRoles first and pass what it returns; do not guess role identifiers. Requires user approval.";
32
- readonly inputSchema: z.ZodObject<{
33
- name: z.ZodString;
34
- slug: z.ZodString;
35
- description: z.ZodOptional<z.ZodString>;
36
- roles: z.ZodArray<z.ZodString>;
37
- }, z.core.$strip>;
38
- readonly annotations: {
39
- readOnlyHint: boolean;
40
- };
41
- readonly handler: typeof CreateTeamToolHandlerImpl & {
42
- __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolHandler<any>>;
43
- };
44
- }
45
- export declare const CreateTeamTool: typeof CreateTeamToolImpl & {
46
- __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolDefinition<any>>;
47
- };
48
- export {};
@@ -1,56 +0,0 @@
1
- import { z } from "zod";
2
- import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
3
- import { CreateTeam } from "@webiny/api-core/features/security/teams/CreateTeam/index.js";
4
- import { descriptionOnCreate } from "@webiny/api-core/features/security/shared/index.js";
5
- const inputSchema = z.object({
6
- name: z.string().describe("Human-readable team name, e.g. 'Marketing'."),
7
- slug: z.string().describe("URL-safe identifier, e.g. 'marketing'. Lowercase, hyphens instead of spaces."),
8
- description: z.string().max(500).optional().describe("What the team is for. Shown in the admin UI. Omit it if the user did not say."),
9
- roles: z.array(z.string()).describe("Roles from listRoles. Prefer the `id`; a `slug` is accepted and resolved for you. Resolve them with listRoles first, since an unknown value is rejected rather than stored.")
10
- });
11
- class CreateTeamToolHandlerImpl {
12
- constructor(createTeam){
13
- this.createTeam = createTeam;
14
- }
15
- async execute(input) {
16
- const result = await this.createTeam.execute({
17
- name: input.name,
18
- slug: input.slug,
19
- description: descriptionOnCreate(input.description),
20
- roles: input.roles
21
- });
22
- if (result.isFail()) throw new Error(`Could not create the team: ${result.error.message}`);
23
- const team = result.value;
24
- return {
25
- id: team.id,
26
- name: team.name,
27
- slug: team.slug,
28
- roles: team.roles
29
- };
30
- }
31
- }
32
- const CreateTeamToolHandler = AiSdkToolHandler.createImplementation({
33
- implementation: CreateTeamToolHandlerImpl,
34
- dependencies: [
35
- CreateTeam
36
- ]
37
- });
38
- class CreateTeamToolImpl {
39
- constructor(){
40
- this.name = "createTeam";
41
- this.title = "Create team";
42
- this.description = "Creates a team with a set of roles. Call listRoles first and pass what it returns; do not guess role identifiers. Requires user approval.";
43
- this.inputSchema = inputSchema;
44
- this.annotations = {
45
- readOnlyHint: false
46
- };
47
- this.handler = CreateTeamToolHandler;
48
- }
49
- }
50
- const CreateTeamTool = AiSdkToolDefinition.createImplementation({
51
- implementation: CreateTeamToolImpl,
52
- dependencies: []
53
- });
54
- export { CreateTeamTool };
55
-
56
- //# sourceMappingURL=CreateTeamTool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"features/ai/CreateTeamTool.js","sources":["../../../src/features/ai/CreateTeamTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition, AiSdkToolHandler } from \"@webiny/api-core/features/ai/index.js\";\nimport { CreateTeam } from \"@webiny/api-core/features/security/teams/CreateTeam/index.js\";\nimport { descriptionOnCreate } from \"@webiny/api-core/features/security/shared/index.js\";\n\nconst inputSchema = z.object({\n name: z.string().describe(\"Human-readable team name, e.g. 'Marketing'.\"),\n slug: z\n .string()\n .describe(\"URL-safe identifier, e.g. 'marketing'. Lowercase, hyphens instead of spaces.\"),\n /*\n * Optional and capped, mirroring the use case's own schema. Requiring it made the model invent a\n * description for every team; `CreateTeam` treats an absent one as empty via `descriptionOnCreate`.\n */\n description: z\n .string()\n .max(500)\n .optional()\n .describe(\"What the team is for. Shown in the admin UI. Omit it if the user did not say.\"),\n roles: z\n .array(z.string())\n .describe(\n \"Roles from listRoles. Prefer the `id`; a `slug` is accepted and resolved for you. Resolve them with listRoles first, since an unknown value is rejected rather than stored.\"\n )\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface CreatedTeam {\n id: string;\n name: string;\n slug: string;\n roles: string[];\n}\n\nclass CreateTeamToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {\n constructor(private createTeam: CreateTeam.Interface) {}\n\n async execute(input: Input): Promise<CreatedTeam> {\n /*\n * Roles go through untouched. `CreateTeam` accepts a role id or a slug and resolves either to\n * the id a team stores, so the tool has nothing to add: doing it here too would read the roles\n * a second time and leave two copies of the same rule to keep in step.\n */\n const result = await this.createTeam.execute({\n name: input.name,\n slug: input.slug,\n // An omitted description becomes \"\", the same mapping the use case applies to its own input.\n description: descriptionOnCreate(input.description),\n roles: input.roles\n });\n\n if (result.isFail()) {\n throw new Error(`Could not create 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 // From the created team, so the caller sees the resolved ids that were actually stored.\n roles: team.roles\n };\n }\n}\n\nconst CreateTeamToolHandler = AiSdkToolHandler.createImplementation({\n implementation: CreateTeamToolHandlerImpl,\n dependencies: [CreateTeam]\n});\n\n/**\n * Creates a team.\n *\n * Not read-only, so it needs approval: a team is an access-control object, and the roles it carries\n * decide what its members can do. The user should see which roles are being granted before it exists.\n */\nclass CreateTeamToolImpl implements AiSdkToolDefinition.Interface<Input> {\n readonly name = \"createTeam\";\n readonly title = \"Create team\";\n readonly description =\n \"Creates a team with a set of roles. Call listRoles first and pass what it returns; do not guess role identifiers. Requires user approval.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: false };\n readonly handler = CreateTeamToolHandler;\n}\n\nexport const CreateTeamTool = AiSdkToolDefinition.createImplementation({\n implementation: CreateTeamToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","CreateTeamToolHandlerImpl","createTeam","input","result","descriptionOnCreate","Error","team","CreateTeamToolHandler","AiSdkToolHandler","CreateTeam","CreateTeamToolImpl","CreateTeamTool","AiSdkToolDefinition"],"mappings":";;;;AAKA,MAAMA,cAAcC,EAAE,MAAM,CAAC;IACzB,MAAMA,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC1B,MAAMA,EAAAA,MACK,GACN,QAAQ,CAAC;IAKd,aAAaA,EAAAA,MACF,GACN,GAAG,CAAC,KACJ,QAAQ,GACR,QAAQ,CAAC;IACd,OAAOA,EAAAA,KACG,CAACA,EAAE,MAAM,IACd,QAAQ,CACL;AAEZ;AAWA,MAAMC;IACF,YAAoBC,UAAgC,CAAE;aAAlCA,UAAU,GAAVA;IAAmC;IAEvD,MAAM,QAAQC,KAAY,EAAwB;QAM9C,MAAMC,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YACzC,MAAMD,MAAM,IAAI;YAChB,MAAMA,MAAM,IAAI;YAEhB,aAAaE,oBAAoBF,MAAM,WAAW;YAClD,OAAOA,MAAM,KAAK;QACtB;QAEA,IAAIC,OAAO,MAAM,IACb,MAAM,IAAIE,MAAM,CAAC,2BAA2B,EAAEF,OAAO,KAAK,CAAC,OAAO,EAAE;QAGxE,MAAMG,OAAOH,OAAO,KAAK;QAEzB,OAAO;YACH,IAAIG,KAAK,EAAE;YACX,MAAMA,KAAK,IAAI;YACf,MAAMA,KAAK,IAAI;YAEf,OAAOA,KAAK,KAAK;QACrB;IACJ;AACJ;AAEA,MAAMC,wBAAwBC,iBAAiB,oBAAoB,CAAC;IAChE,gBAAgBR;IAChB,cAAc;QAACS;KAAW;AAC9B;AAQA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGZ;aACd,WAAW,GAAG;YAAE,cAAc;QAAM;aACpC,OAAO,GAAGS;;AACvB;AAEO,MAAMI,iBAAiBC,oBAAoB,oBAAoB,CAAC;IACnE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
@@ -1,52 +0,0 @@
1
- import { z } from "zod";
2
- import { AiSdkToolDefinition } from "@webiny/api-core/features/ai/index.js";
3
- import { AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
4
- import { GetRoleUseCase } from "@webiny/api-core/features/security/roles/GetRole/index.js";
5
- import { DeleteRoleUseCase } from "@webiny/api-core/features/security/roles/DeleteRole/index.js";
6
- import { ListTeamsUseCase } from "@webiny/api-core/features/security/teams/ListTeams/index.js";
7
- import { ListUsersUseCase } from "@webiny/api-core/features/users/ListUsers/index.js";
8
- declare const inputSchema: z.ZodObject<{
9
- roleId: z.ZodString;
10
- name: z.ZodString;
11
- }, z.core.$strip>;
12
- type Input = z.infer<typeof inputSchema>;
13
- interface DeletedRole {
14
- id: string;
15
- name: string;
16
- slug: string;
17
- }
18
- declare class DeleteRoleToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {
19
- private getRole;
20
- private listTeams;
21
- private listUsers;
22
- private deleteRole;
23
- constructor(getRole: GetRoleUseCase.Interface, listTeams: ListTeamsUseCase.Interface, listUsers: ListUsersUseCase.Interface, deleteRole: DeleteRoleUseCase.Interface);
24
- execute(input: Input): Promise<DeletedRole>;
25
- private findHolders;
26
- }
27
- /**
28
- * Deletes one role that nothing uses.
29
- *
30
- * Destructive, so the approval says it cannot be undone. Refuses system roles, roles defined in
31
- * code, and roles still given to a team or a user.
32
- */
33
- declare class DeleteRoleToolImpl implements AiSdkToolDefinition.Interface<Input> {
34
- readonly name = "deleteRole";
35
- readonly title = "Delete role";
36
- readonly description = "Deletes one role. Refused for system roles, roles defined in code, and roles still given to a team or user (the error names them). Call listRoles first for the id and exact name. Requires user approval.";
37
- readonly inputSchema: z.ZodObject<{
38
- roleId: z.ZodString;
39
- name: z.ZodString;
40
- }, z.core.$strip>;
41
- readonly annotations: {
42
- readOnlyHint: boolean;
43
- destructiveHint: boolean;
44
- };
45
- readonly handler: typeof DeleteRoleToolHandlerImpl & {
46
- __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolHandler<any>>;
47
- };
48
- }
49
- export declare const DeleteRoleTool: typeof DeleteRoleToolImpl & {
50
- __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolDefinition<any>>;
51
- };
52
- export {};
@@ -1,79 +0,0 @@
1
- import { z } from "zod";
2
- import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
3
- import { GetRoleUseCase } from "@webiny/api-core/features/security/roles/GetRole/index.js";
4
- import { DeleteRoleUseCase } from "@webiny/api-core/features/security/roles/DeleteRole/index.js";
5
- import { ListTeamsUseCase } from "@webiny/api-core/features/security/teams/ListTeams/index.js";
6
- import { ListUsersUseCase } from "@webiny/api-core/features/users/ListUsers/index.js";
7
- const inputSchema = z.object({
8
- roleId: z.string().describe("Role id as returned by listRoles."),
9
- name: z.string().describe("The role's current name, exactly as listRoles returned it. The delete is refused if it does not match.")
10
- });
11
- class DeleteRoleToolHandlerImpl {
12
- constructor(getRole, listTeams, listUsers, deleteRole){
13
- this.getRole = getRole;
14
- this.listTeams = listTeams;
15
- this.listUsers = listUsers;
16
- this.deleteRole = deleteRole;
17
- }
18
- async execute(input) {
19
- const found = await this.getRole.execute({
20
- id: input.roleId
21
- });
22
- if (found.isFail()) throw new Error(`Role "${input.roleId}" not found: ${found.error.message}. Call listRoles for valid ids.`);
23
- const role = found.value;
24
- if (role.name !== input.name) throw new Error(`Role "${input.roleId}" is named "${role.name}", not "${input.name}", so nothing was deleted. Check the role with listRoles.`);
25
- if (role.system) throw new Error(`"${role.name}" is a system role and cannot be deleted.`);
26
- const holders = await this.findHolders([
27
- role.id,
28
- role.slug
29
- ]);
30
- if (holders.length > 0) throw new Error(`"${role.name}" is still given to ${holders.join(", ")}, so nothing was deleted. Remove it from them first.`);
31
- const result = await this.deleteRole.execute(role.id);
32
- if (result.isFail()) throw new Error(`Could not delete the role: ${result.error.message}`);
33
- return {
34
- id: role.id,
35
- name: role.name,
36
- slug: role.slug
37
- };
38
- }
39
- async findHolders(identifiers) {
40
- const holds = (roles)=>(roles ?? []).some((role)=>identifiers.includes(role));
41
- const teams = await this.listTeams.execute();
42
- if (teams.isFail()) throw new Error(`Could not check which teams still have the role, so nothing was deleted. Deleting a role here also needs permission to list teams: ${teams.error.message}`);
43
- const users = await this.listUsers.execute();
44
- if (users.isFail()) throw new Error(`Could not check which users still have the role, so nothing was deleted. Deleting a role here also needs permission to list users: ${users.error.message}`);
45
- return [
46
- ...teams.value.filter((team)=>holds(team.roles)).map((team)=>`team "${team.name}"`),
47
- ...users.value.filter((user)=>holds(user.roles)).map((user)=>`user "${user.displayName || user.email}"`)
48
- ];
49
- }
50
- }
51
- const DeleteRoleToolHandler = AiSdkToolHandler.createImplementation({
52
- implementation: DeleteRoleToolHandlerImpl,
53
- dependencies: [
54
- GetRoleUseCase,
55
- ListTeamsUseCase,
56
- ListUsersUseCase,
57
- DeleteRoleUseCase
58
- ]
59
- });
60
- class DeleteRoleToolImpl {
61
- constructor(){
62
- this.name = "deleteRole";
63
- this.title = "Delete role";
64
- this.description = "Deletes one role. Refused for system roles, roles defined in code, and roles still given to a team or user (the error names them). Call listRoles first for the id and exact name. Requires user approval.";
65
- this.inputSchema = inputSchema;
66
- this.annotations = {
67
- readOnlyHint: false,
68
- destructiveHint: true
69
- };
70
- this.handler = DeleteRoleToolHandler;
71
- }
72
- }
73
- const DeleteRoleTool = AiSdkToolDefinition.createImplementation({
74
- implementation: DeleteRoleToolImpl,
75
- dependencies: []
76
- });
77
- export { DeleteRoleTool };
78
-
79
- //# sourceMappingURL=DeleteRoleTool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"features/ai/DeleteRoleTool.js","sources":["../../../src/features/ai/DeleteRoleTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition } from \"@webiny/api-core/features/ai/index.js\";\nimport { AiSdkToolHandler } from \"@webiny/api-core/features/ai/index.js\";\nimport { GetRoleUseCase } from \"@webiny/api-core/features/security/roles/GetRole/index.js\";\nimport { DeleteRoleUseCase } from \"@webiny/api-core/features/security/roles/DeleteRole/index.js\";\nimport { ListTeamsUseCase } from \"@webiny/api-core/features/security/teams/ListTeams/index.js\";\nimport { ListUsersUseCase } from \"@webiny/api-core/features/users/ListUsers/index.js\";\n\nconst inputSchema = z.object({\n roleId: z.string().describe(\"Role id as returned by listRoles.\"),\n name: z\n .string()\n .describe(\n \"The role's current name, exactly as listRoles returned it. The delete is refused if it does not match.\"\n )\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface DeletedRole {\n id: string;\n name: string;\n slug: string;\n}\n\n/*\n * The checks run before anything is deleted, in this order:\n *\n * - The name is in the input so the approval shows which role goes; it is checked against the\n * stored role, so what the user approved by name is what is removed.\n * - System roles (the Full Access role the installer creates) are refused. `DeleteRoleUseCase`\n * cannot refuse them itself: `RolesInstaller.uninstall()` uses it to roll back that same role.\n * - A role still given to a team or a user is refused, with their names. `DeleteRoleUseCase` would\n * delete it and leave them holding the id of a role that no longer exists. Both the id and the\n * slug are matched, since a record written before roles were resolved to ids can hold the slug.\n * The check goes through the list use cases, so it needs the caller's permission to list teams\n * and users. Without it the delete is refused and the error says why.\n */\nclass DeleteRoleToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {\n constructor(\n private getRole: GetRoleUseCase.Interface,\n private listTeams: ListTeamsUseCase.Interface,\n private listUsers: ListUsersUseCase.Interface,\n private deleteRole: DeleteRoleUseCase.Interface\n ) {}\n\n async execute(input: Input): Promise<DeletedRole> {\n const found = await this.getRole.execute({ id: input.roleId });\n\n if (found.isFail()) {\n throw new Error(\n `Role \"${input.roleId}\" not found: ${found.error.message}. Call listRoles for valid ids.`\n );\n }\n\n const role = found.value;\n\n if (role.name !== input.name) {\n throw new Error(\n `Role \"${input.roleId}\" is named \"${role.name}\", not \"${input.name}\", so nothing was deleted. Check the role with listRoles.`\n );\n }\n\n if (role.system) {\n throw new Error(`\"${role.name}\" is a system role and cannot be deleted.`);\n }\n\n const holders = await this.findHolders([role.id, role.slug]);\n\n if (holders.length > 0) {\n throw new Error(\n `\"${role.name}\" is still given to ${holders.join(\", \")}, so nothing was deleted. Remove it from them first.`\n );\n }\n\n const result = await this.deleteRole.execute(role.id);\n\n if (result.isFail()) {\n throw new Error(`Could not delete the role: ${result.error.message}`);\n }\n\n return { id: role.id, name: role.name, slug: role.slug };\n }\n\n private async findHolders(identifiers: string[]): Promise<string[]> {\n const holds = (roles: string[] | undefined) =>\n (roles ?? []).some(role => identifiers.includes(role));\n\n const teams = await this.listTeams.execute();\n if (teams.isFail()) {\n throw new Error(\n `Could not check which teams still have the role, so nothing was deleted. Deleting a role here also needs permission to list teams: ${teams.error.message}`\n );\n }\n\n const users = await this.listUsers.execute();\n if (users.isFail()) {\n throw new Error(\n `Could not check which users still have the role, so nothing was deleted. Deleting a role here also needs permission to list users: ${users.error.message}`\n );\n }\n\n return [\n ...teams.value.filter(team => holds(team.roles)).map(team => `team \"${team.name}\"`),\n ...users.value\n .filter(user => holds(user.roles))\n .map(user => `user \"${user.displayName || user.email}\"`)\n ];\n }\n}\n\nconst DeleteRoleToolHandler = AiSdkToolHandler.createImplementation({\n implementation: DeleteRoleToolHandlerImpl,\n dependencies: [GetRoleUseCase, ListTeamsUseCase, ListUsersUseCase, DeleteRoleUseCase]\n});\n\n/**\n * Deletes one role that nothing uses.\n *\n * Destructive, so the approval says it cannot be undone. Refuses system roles, roles defined in\n * code, and roles still given to a team or a user.\n */\nclass DeleteRoleToolImpl implements AiSdkToolDefinition.Interface<Input> {\n readonly name = \"deleteRole\";\n readonly title = \"Delete role\";\n readonly description =\n \"Deletes one role. Refused for system roles, roles defined in code, and roles still given to a team or user (the error names them). Call listRoles first for the id and exact name. Requires user approval.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: false, destructiveHint: true };\n readonly handler = DeleteRoleToolHandler;\n}\n\nexport const DeleteRoleTool = AiSdkToolDefinition.createImplementation({\n implementation: DeleteRoleToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","DeleteRoleToolHandlerImpl","getRole","listTeams","listUsers","deleteRole","input","found","Error","role","holders","result","identifiers","holds","roles","teams","users","team","user","DeleteRoleToolHandler","AiSdkToolHandler","GetRoleUseCase","ListTeamsUseCase","ListUsersUseCase","DeleteRoleUseCase","DeleteRoleToolImpl","DeleteRoleTool","AiSdkToolDefinition"],"mappings":";;;;;;AAQA,MAAMA,cAAcC,EAAE,MAAM,CAAC;IACzB,QAAQA,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B,MAAMA,EAAAA,MACK,GACN,QAAQ,CACL;AAEZ;AAuBA,MAAMC;IACF,YACYC,OAAiC,EACjCC,SAAqC,EACrCC,SAAqC,EACrCC,UAAuC,CACjD;aAJUH,OAAO,GAAPA;aACAC,SAAS,GAATA;aACAC,SAAS,GAATA;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,IAAIG,KAAK,MAAM,EACX,MAAM,IAAID,MAAM,CAAC,CAAC,EAAEC,KAAK,IAAI,CAAC,yCAAyC,CAAC;QAG5E,MAAMC,UAAU,MAAM,IAAI,CAAC,WAAW,CAAC;YAACD,KAAK,EAAE;YAAEA,KAAK,IAAI;SAAC;QAE3D,IAAIC,QAAQ,MAAM,GAAG,GACjB,MAAM,IAAIF,MACN,CAAC,CAAC,EAAEC,KAAK,IAAI,CAAC,oBAAoB,EAAEC,QAAQ,IAAI,CAAC,MAAM,oDAAoD,CAAC;QAIpH,MAAMC,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACF,KAAK,EAAE;QAEpD,IAAIE,OAAO,MAAM,IACb,MAAM,IAAIH,MAAM,CAAC,2BAA2B,EAAEG,OAAO,KAAK,CAAC,OAAO,EAAE;QAGxE,OAAO;YAAE,IAAIF,KAAK,EAAE;YAAE,MAAMA,KAAK,IAAI;YAAE,MAAMA,KAAK,IAAI;QAAC;IAC3D;IAEA,MAAc,YAAYG,WAAqB,EAAqB;QAChE,MAAMC,QAAQ,CAACC,QACVA,AAAAA,CAAAA,SAAS,EAAC,EAAG,IAAI,CAACL,CAAAA,OAAQG,YAAY,QAAQ,CAACH;QAEpD,MAAMM,QAAQ,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO;QAC1C,IAAIA,MAAM,MAAM,IACZ,MAAM,IAAIP,MACN,CAAC,mIAAmI,EAAEO,MAAM,KAAK,CAAC,OAAO,EAAE;QAInK,MAAMC,QAAQ,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO;QAC1C,IAAIA,MAAM,MAAM,IACZ,MAAM,IAAIR,MACN,CAAC,mIAAmI,EAAEQ,MAAM,KAAK,CAAC,OAAO,EAAE;QAInK,OAAO;eACAD,MAAM,KAAK,CAAC,MAAM,CAACE,CAAAA,OAAQJ,MAAMI,KAAK,KAAK,GAAG,GAAG,CAACA,CAAAA,OAAQ,CAAC,MAAM,EAAEA,KAAK,IAAI,CAAC,CAAC,CAAC;eAC/ED,MAAM,KAAK,CACT,MAAM,CAACE,CAAAA,OAAQL,MAAMK,KAAK,KAAK,GAC/B,GAAG,CAACA,CAAAA,OAAQ,CAAC,MAAM,EAAEA,KAAK,WAAW,IAAIA,KAAK,KAAK,CAAC,CAAC,CAAC;SAC9D;IACL;AACJ;AAEA,MAAMC,wBAAwBC,iBAAiB,oBAAoB,CAAC;IAChE,gBAAgBnB;IAChB,cAAc;QAACoB;QAAgBC;QAAkBC;QAAkBC;KAAkB;AACzF;AAQA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAG1B;aACd,WAAW,GAAG;YAAE,cAAc;YAAO,iBAAiB;QAAK;aAC3D,OAAO,GAAGoB;;AACvB;AAEO,MAAMO,iBAAiBC,oBAAoB,oBAAoB,CAAC;IACnE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
@@ -1,46 +0,0 @@
1
- import { z } from "zod";
2
- import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
3
- import { GetTeamUseCase } from "@webiny/api-core/features/security/teams/GetTeam/index.js";
4
- import { DeleteTeam } from "@webiny/api-core/features/security/teams/DeleteTeam/index.js";
5
- declare const inputSchema: z.ZodObject<{
6
- teamId: z.ZodString;
7
- name: z.ZodString;
8
- }, z.core.$strip>;
9
- type Input = z.infer<typeof inputSchema>;
10
- interface DeletedTeam {
11
- id: string;
12
- name: string;
13
- slug: string;
14
- }
15
- declare class DeleteTeamToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {
16
- private getTeam;
17
- private deleteTeam;
18
- constructor(getTeam: GetTeamUseCase.Interface, deleteTeam: DeleteTeam.Interface);
19
- execute(input: Input): Promise<DeletedTeam>;
20
- }
21
- /**
22
- * Deletes one team.
23
- *
24
- * Destructive, so the approval says it cannot be undone. System teams and teams defined in code are
25
- * refused by `DeleteTeam`, and that error reaches the model as-is.
26
- */
27
- declare class DeleteTeamToolImpl implements AiSdkToolDefinition.Interface<Input> {
28
- readonly name = "deleteTeam";
29
- readonly title = "Delete team";
30
- readonly description = "Deletes one team. System teams and teams defined in code are refused. Call listTeams first for the id and exact name. Requires user approval.";
31
- readonly inputSchema: z.ZodObject<{
32
- teamId: z.ZodString;
33
- name: z.ZodString;
34
- }, z.core.$strip>;
35
- readonly annotations: {
36
- readOnlyHint: boolean;
37
- destructiveHint: boolean;
38
- };
39
- readonly handler: typeof DeleteTeamToolHandlerImpl & {
40
- __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolHandler<any>>;
41
- };
42
- }
43
- export declare const DeleteTeamTool: typeof DeleteTeamToolImpl & {
44
- __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolDefinition<any>>;
45
- };
46
- export {};
@@ -1,56 +0,0 @@
1
- import { z } from "zod";
2
- import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
3
- import { GetTeamUseCase } from "@webiny/api-core/features/security/teams/GetTeam/index.js";
4
- import { DeleteTeam } from "@webiny/api-core/features/security/teams/DeleteTeam/index.js";
5
- const inputSchema = z.object({
6
- teamId: z.string().describe("Team id as returned by listTeams."),
7
- name: z.string().describe("The team's current name, exactly as listTeams returned it. The delete is refused if it does not match.")
8
- });
9
- class DeleteTeamToolHandlerImpl {
10
- constructor(getTeam, deleteTeam){
11
- this.getTeam = getTeam;
12
- this.deleteTeam = deleteTeam;
13
- }
14
- async execute(input) {
15
- const found = await this.getTeam.execute({
16
- id: input.teamId
17
- });
18
- if (found.isFail()) throw new Error(`Team "${input.teamId}" not found: ${found.error.message}. Call listTeams for valid ids.`);
19
- const team = found.value;
20
- if (team.name !== input.name) throw new Error(`Team "${input.teamId}" is named "${team.name}", not "${input.name}", so nothing was deleted. Check the team with listTeams.`);
21
- const result = await this.deleteTeam.execute(team.id);
22
- if (result.isFail()) throw new Error(`Could not delete the team: ${result.error.message}`);
23
- return {
24
- id: team.id,
25
- name: team.name,
26
- slug: team.slug
27
- };
28
- }
29
- }
30
- const DeleteTeamToolHandler = AiSdkToolHandler.createImplementation({
31
- implementation: DeleteTeamToolHandlerImpl,
32
- dependencies: [
33
- GetTeamUseCase,
34
- DeleteTeam
35
- ]
36
- });
37
- class DeleteTeamToolImpl {
38
- constructor(){
39
- this.name = "deleteTeam";
40
- this.title = "Delete team";
41
- this.description = "Deletes one team. System teams and teams defined in code are refused. Call listTeams first for the id and exact name. Requires user approval.";
42
- this.inputSchema = inputSchema;
43
- this.annotations = {
44
- readOnlyHint: false,
45
- destructiveHint: true
46
- };
47
- this.handler = DeleteTeamToolHandler;
48
- }
49
- }
50
- const DeleteTeamTool = AiSdkToolDefinition.createImplementation({
51
- implementation: DeleteTeamToolImpl,
52
- dependencies: []
53
- });
54
- export { DeleteTeamTool };
55
-
56
- //# sourceMappingURL=DeleteTeamTool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"features/ai/DeleteTeamTool.js","sources":["../../../src/features/ai/DeleteTeamTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition, AiSdkToolHandler } from \"@webiny/api-core/features/ai/index.js\";\nimport { GetTeamUseCase } from \"@webiny/api-core/features/security/teams/GetTeam/index.js\";\nimport { DeleteTeam } from \"@webiny/api-core/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":";;;;AAKA,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"}
@@ -1,39 +0,0 @@
1
- import { z } from "zod";
2
- import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
3
- import { ListRolesUseCase } from "@webiny/api-core/features/security/roles/ListRoles/index.js";
4
- interface RoleSummary {
5
- id: string;
6
- name: string;
7
- slug: string;
8
- description?: string;
9
- }
10
- declare class ListRolesToolHandlerImpl implements AiSdkToolHandler.Interface<Record<string, never>> {
11
- private listRoles;
12
- constructor(listRoles: ListRolesUseCase.Interface);
13
- execute(): Promise<RoleSummary[]>;
14
- }
15
- /**
16
- * Resolves role names to the IDs `createTeam` takes. Separate from the write, so the user approves a
17
- * team with roles that were looked up rather than guessed.
18
- *
19
- * Returns the slug too, because it is what a human recognises and what the admin UI shows, while
20
- * `id` is what a team actually stores. Nothing at the type level separates the two, so `createTeam`
21
- * accepts either and resolves it rather than making the caller guess which one that field wants.
22
- */
23
- declare class ListRolesToolImpl implements AiSdkToolDefinition.Interface<Record<string, never>> {
24
- readonly name = "listRoles";
25
- readonly title = "List roles";
26
- 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.";
27
- readonly inputSchema: z.ZodObject<{}, z.core.$strip>;
28
- readonly annotations: {
29
- readOnlyHint: boolean;
30
- idempotentHint: boolean;
31
- };
32
- readonly handler: typeof ListRolesToolHandlerImpl & {
33
- __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolHandler<any>>;
34
- };
35
- }
36
- export declare const ListRolesTool: typeof ListRolesToolImpl & {
37
- __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolDefinition<any>>;
38
- };
39
- export {};
@@ -1,48 +0,0 @@
1
- import { z } from "zod";
2
- import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
3
- import { ListRolesUseCase } from "@webiny/api-core/features/security/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
@@ -1 +0,0 @@
1
- {"version":3,"file":"features/ai/ListRolesTool.js","sources":["../../../src/features/ai/ListRolesTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition, AiSdkToolHandler } from \"@webiny/api-core/features/ai/index.js\";\nimport { ListRolesUseCase } from \"@webiny/api-core/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":";;;AAIA,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"}