@webiny/api-aco 6.6.0-alpha.10 → 6.6.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/features/ai/UpdateFolderTool.d.ts +57 -0
  2. package/features/ai/UpdateFolderTool.js +72 -0
  3. package/features/ai/UpdateFolderTool.js.map +1 -0
  4. package/features/ai/feature.d.ts +2 -2
  5. package/features/ai/feature.js +2 -6
  6. package/features/ai/feature.js.map +1 -1
  7. package/features/ai/index.d.ts +1 -3
  8. package/features/ai/index.js +1 -3
  9. package/features/ai/loadFolderPermissions.d.ts +4 -1
  10. package/features/ai/loadFolderPermissions.js +1 -1
  11. package/features/ai/loadFolderPermissions.js.map +1 -1
  12. package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js +0 -1
  13. package/features/flp/FolderLevelPermissions/FolderLevelPermissions.js.map +1 -1
  14. package/features/flp/ListFolderAccess/mayAskAboutUser.js +1 -1
  15. package/features/flp/ListFolderAccess/mayAskAboutUser.js.map +1 -1
  16. package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.d.ts +3 -3
  17. package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.js +10 -10
  18. package/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.js.map +1 -1
  19. package/features/folder/NotifyFolderChange/feature.js +0 -2
  20. package/features/folder/NotifyFolderChange/feature.js.map +1 -1
  21. package/features/folder/NotifyFolderChange/index.d.ts +1 -1
  22. package/features/folder/NotifyFolderChange/index.js +1 -1
  23. package/features/folder/NotifyFolderChange/recordType.d.ts +8 -0
  24. package/features/folder/NotifyFolderChange/recordType.js +4 -0
  25. package/features/folder/NotifyFolderChange/recordType.js.map +1 -0
  26. package/features/folder/UpdateFolder/UpdateFolderUseCase.d.ts +1 -0
  27. package/features/folder/UpdateFolder/UpdateFolderUseCase.js +13 -0
  28. package/features/folder/UpdateFolder/UpdateFolderUseCase.js.map +1 -1
  29. package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.js +4 -2
  30. package/features/folder/UpdateFolder/decorators/UpdateFolderWithFolderLevelPermissions.js.map +1 -1
  31. package/flpTaskCatalog/TaskFolderCatalogSync.d.ts +1 -0
  32. package/flpTaskCatalog/TaskFolderCatalogSync.js +7 -2
  33. package/flpTaskCatalog/TaskFolderCatalogSync.js.map +1 -1
  34. package/flpTaskCatalog/tasks/createFlp.task.d.ts +3 -3
  35. package/flpTaskCatalog/tasks/createFlp.task.js +7 -5
  36. package/flpTaskCatalog/tasks/createFlp.task.js.map +1 -1
  37. package/flpTaskCatalog/tasks/syncFlp.task.js +20 -13
  38. package/flpTaskCatalog/tasks/syncFlp.task.js.map +1 -1
  39. package/flpTaskCatalog/tasks/updateFlp.task.d.ts +3 -3
  40. package/flpTaskCatalog/tasks/updateFlp.task.js +7 -5
  41. package/flpTaskCatalog/tasks/updateFlp.task.js.map +1 -1
  42. package/folder/folder.types.d.ts +2 -1
  43. package/package.json +18 -19
  44. package/features/ai/CreateTeamTool.d.ts +0 -48
  45. package/features/ai/CreateTeamTool.js +0 -56
  46. package/features/ai/CreateTeamTool.js.map +0 -1
  47. package/features/ai/ListRolesTool.d.ts +0 -39
  48. package/features/ai/ListRolesTool.js +0 -48
  49. package/features/ai/ListRolesTool.js.map +0 -1
  50. package/features/ai/ListTeamsTool.d.ts +0 -39
  51. package/features/ai/ListTeamsTool.js +0 -48
  52. package/features/ai/ListTeamsTool.js.map +0 -1
  53. package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.d.ts +0 -11
  54. package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.js +0 -38
  55. package/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.js.map +0 -1
  56. package/features/folder/NotifyFolderChange/abstractions.d.ts +0 -28
  57. package/features/folder/NotifyFolderChange/abstractions.js +0 -8
  58. package/features/folder/NotifyFolderChange/abstractions.js.map +0 -1
@@ -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. Call this before createTeam and pass the `id` of each role you want. A slug also works, but a value that is neither is rejected.";
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. Call this before createTeam and pass the `id` of each role you want. A slug also works, but a value that is neither is rejected.";
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. Call this before createTeam and pass the `id` of each role you want. A slug also works, but a value that is neither is rejected.\";\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"}
@@ -1,39 +0,0 @@
1
- import { z } from "zod";
2
- import { AiSdkToolDefinition, AiSdkToolHandler } from "@webiny/api-core/features/ai/index.js";
3
- import { ListTeamsUseCase } from "@webiny/api-core/features/security/teams/ListTeams/index.js";
4
- declare const inputSchema: z.ZodObject<{}, z.core.$strip>;
5
- type Input = z.infer<typeof inputSchema>;
6
- interface TeamSummary {
7
- id: string;
8
- name: string;
9
- slug: string;
10
- description?: string;
11
- }
12
- declare class ListTeamsToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {
13
- private listTeams;
14
- constructor(listTeams: ListTeamsUseCase.Interface);
15
- execute(): Promise<TeamSummary[]>;
16
- }
17
- /**
18
- * Resolves human names ("team A") to the ids folder permissions actually take.
19
- *
20
- * Kept separate from setFolderPermissions rather than accepting a team name there: the user approves
21
- * the arguments of a write, so the id has to be looked up and shown, not guessed inside the write.
22
- */
23
- declare class ListTeamsToolImpl implements AiSdkToolDefinition.Interface<Input> {
24
- readonly name = "listTeams";
25
- readonly title = "List teams";
26
- readonly description = "Lists the teams in this project with their ids, names and slugs. Folder permission targets use the SLUG (`team:<slug>`), not the id.";
27
- readonly inputSchema: z.ZodObject<{}, z.core.$strip>;
28
- readonly annotations: {
29
- readOnlyHint: boolean;
30
- idempotentHint: boolean;
31
- };
32
- readonly handler: typeof ListTeamsToolHandlerImpl & {
33
- __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-core/features/ai/abstractions").IAiSdkToolHandler<any>>;
34
- };
35
- }
36
- export declare const ListTeamsTool: typeof ListTeamsToolImpl & {
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 { ListTeamsUseCase } from "@webiny/api-core/features/security/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
- };
18
- if (team.description) summary.description = team.description;
19
- return summary;
20
- });
21
- }
22
- }
23
- const ListTeamsToolHandler = AiSdkToolHandler.createImplementation({
24
- implementation: ListTeamsToolHandlerImpl,
25
- dependencies: [
26
- ListTeamsUseCase
27
- ]
28
- });
29
- class ListTeamsToolImpl {
30
- constructor(){
31
- this.name = "listTeams";
32
- this.title = "List teams";
33
- this.description = "Lists the teams in this project with their ids, names and slugs. Folder permission targets use the SLUG (`team:<slug>`), not the id.";
34
- this.inputSchema = inputSchema;
35
- this.annotations = {
36
- readOnlyHint: true,
37
- idempotentHint: true
38
- };
39
- this.handler = ListTeamsToolHandler;
40
- }
41
- }
42
- const ListTeamsTool = AiSdkToolDefinition.createImplementation({
43
- implementation: ListTeamsToolImpl,
44
- dependencies: []
45
- });
46
- export { ListTeamsTool };
47
-
48
- //# sourceMappingURL=ListTeamsTool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"features/ai/ListTeamsTool.js","sources":["../../../src/features/ai/ListTeamsTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition, AiSdkToolHandler } from \"@webiny/api-core/features/ai/index.js\";\nimport { ListTeamsUseCase } from \"@webiny/api-core/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}\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 };\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 and slugs. Folder permission targets use the SLUG (`team:<slug>`), not 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":";;;AAIA,MAAMA,cAAcC,EAAE,MAAM,CAAC,CAAC;AAW9B,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;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"}
@@ -1,11 +0,0 @@
1
- import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
2
- import { WebsocketsSendToIdentityUseCase } from "@webiny/api-websockets/exports/api.js";
3
- import { NotifyFolderChangeUseCase as UseCaseAbstraction } from "./abstractions.js";
4
- declare class NotifyFolderChangeUseCaseImpl implements UseCaseAbstraction.Interface {
5
- private identityContext;
6
- private sendToIdentity;
7
- constructor(identityContext: IdentityContext.Interface, sendToIdentity: WebsocketsSendToIdentityUseCase.Interface);
8
- execute({ id, change, identityId }: UseCaseAbstraction.Params): Promise<void>;
9
- }
10
- export declare const NotifyFolderChangeUseCase: import("@webiny/di").Implementation<typeof NotifyFolderChangeUseCaseImpl>;
11
- export {};
@@ -1,38 +0,0 @@
1
- import { createImplementation } from "@webiny/di";
2
- import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/abstractions.js";
3
- import { WebsocketsSendToIdentityUseCase } from "@webiny/api-websockets/exports/api.js";
4
- import { FOLDER_CREATED_WEBSOCKET_ACTION, FOLDER_DELETED_WEBSOCKET_ACTION, FOLDER_UPDATED_WEBSOCKET_ACTION, NotifyFolderChangeUseCase } from "./abstractions.js";
5
- const ACTIONS = {
6
- created: FOLDER_CREATED_WEBSOCKET_ACTION,
7
- updated: FOLDER_UPDATED_WEBSOCKET_ACTION,
8
- deleted: FOLDER_DELETED_WEBSOCKET_ACTION
9
- };
10
- class NotifyFolderChangeUseCaseImpl {
11
- constructor(identityContext, sendToIdentity){
12
- this.identityContext = identityContext;
13
- this.sendToIdentity = sendToIdentity;
14
- }
15
- async execute({ id, change, identityId }) {
16
- const recipient = identityId ?? this.identityContext.getIdentity()?.id;
17
- if (!recipient) return;
18
- await this.sendToIdentity.execute({
19
- id: recipient
20
- }, {
21
- action: ACTIONS[change],
22
- data: {
23
- id
24
- }
25
- });
26
- }
27
- }
28
- const NotifyFolderChangeUseCase_NotifyFolderChangeUseCase = createImplementation({
29
- abstraction: NotifyFolderChangeUseCase,
30
- implementation: NotifyFolderChangeUseCaseImpl,
31
- dependencies: [
32
- IdentityContext,
33
- WebsocketsSendToIdentityUseCase
34
- ]
35
- });
36
- export { NotifyFolderChangeUseCase_NotifyFolderChangeUseCase as NotifyFolderChangeUseCase };
37
-
38
- //# sourceMappingURL=NotifyFolderChangeUseCase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.js","sources":["../../../../src/features/folder/NotifyFolderChange/NotifyFolderChangeUseCase.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport { WebsocketsSendToIdentityUseCase } from \"@webiny/api-websockets/exports/api.js\";\nimport {\n FOLDER_CREATED_WEBSOCKET_ACTION,\n FOLDER_DELETED_WEBSOCKET_ACTION,\n FOLDER_UPDATED_WEBSOCKET_ACTION,\n NotifyFolderChangeUseCase as UseCaseAbstraction\n} from \"./abstractions.js\";\n\nconst ACTIONS: Record<UseCaseAbstraction.Params[\"change\"], string> = {\n created: FOLDER_CREATED_WEBSOCKET_ACTION,\n updated: FOLDER_UPDATED_WEBSOCKET_ACTION,\n deleted: FOLDER_DELETED_WEBSOCKET_ACTION\n};\n\n/*\n * The change is already saved whether or not the message goes out, so the send's result is not the\n * caller's result. When it fails, the admin shows the change after its next reload, as it did before.\n */\nclass NotifyFolderChangeUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private sendToIdentity: WebsocketsSendToIdentityUseCase.Interface\n ) {}\n\n async execute({ id, change, identityId }: UseCaseAbstraction.Params): Promise<void> {\n const recipient = identityId ?? this.identityContext.getIdentity()?.id;\n if (!recipient) {\n return;\n }\n\n await this.sendToIdentity.execute(\n { id: recipient },\n { action: ACTIONS[change], data: { id } }\n );\n }\n}\n\nexport const NotifyFolderChangeUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: NotifyFolderChangeUseCaseImpl,\n dependencies: [IdentityContext, WebsocketsSendToIdentityUseCase]\n});\n"],"names":["ACTIONS","FOLDER_CREATED_WEBSOCKET_ACTION","FOLDER_UPDATED_WEBSOCKET_ACTION","FOLDER_DELETED_WEBSOCKET_ACTION","NotifyFolderChangeUseCaseImpl","identityContext","sendToIdentity","id","change","identityId","recipient","NotifyFolderChangeUseCase","createImplementation","UseCaseAbstraction","IdentityContext","WebsocketsSendToIdentityUseCase"],"mappings":";;;;AAUA,MAAMA,UAA+D;IACjE,SAASC;IACT,SAASC;IACT,SAASC;AACb;AAMA,MAAMC;IACF,YACYC,eAA0C,EAC1CC,cAAyD,CACnE;aAFUD,eAAe,GAAfA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QAAQ,EAAEC,EAAE,EAAEC,MAAM,EAAEC,UAAU,EAA6B,EAAiB;QAChF,MAAMC,YAAYD,cAAc,IAAI,CAAC,eAAe,CAAC,WAAW,IAAI;QACpE,IAAI,CAACC,WACD;QAGJ,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B;YAAE,IAAIA;QAAU,GAChB;YAAE,QAAQV,OAAO,CAACQ,OAAO;YAAE,MAAM;gBAAED;YAAG;QAAE;IAEhD;AACJ;AAEO,MAAMI,sDAA4BC,qBAAqB;IAC1D,aAAaC;IACb,gBAAgBT;IAChB,cAAc;QAACU;QAAiBC;KAAgC;AACpE"}
@@ -1,28 +0,0 @@
1
- /**
2
- * Sent to the user's open admin tabs when a folder changes. The admin keeps its own folder cache,
3
- * and a change made on the server never passes through it, so without these the admin shows the old
4
- * state until a reload. Each carries the folder id only; the admin reads the folder back.
5
- *
6
- * `created` and `updated` go out when the FLP tasks finish, since folder reads report permissions
7
- * from the FLP records. `deleted` goes out right after the delete: nothing is read back.
8
- */
9
- export declare const FOLDER_CREATED_WEBSOCKET_ACTION = "aco.folder.created";
10
- export declare const FOLDER_UPDATED_WEBSOCKET_ACTION = "aco.folder.updated";
11
- export declare const FOLDER_DELETED_WEBSOCKET_ACTION = "aco.folder.deleted";
12
- export interface NotifyFolderChangeParams {
13
- id: string;
14
- /**
15
- * Whose open tabs to tell. Defaults to the current identity. The FLP tasks pass the identity
16
- * that made the change, because they run later, outside that request.
17
- */
18
- identityId?: string;
19
- change: "created" | "updated" | "deleted";
20
- }
21
- export interface INotifyFolderChangeUseCase {
22
- execute(params: NotifyFolderChangeParams): Promise<void>;
23
- }
24
- export declare const NotifyFolderChangeUseCase: import("@webiny/di").Abstraction<INotifyFolderChangeUseCase>;
25
- export declare namespace NotifyFolderChangeUseCase {
26
- type Interface = INotifyFolderChangeUseCase;
27
- type Params = NotifyFolderChangeParams;
28
- }
@@ -1,8 +0,0 @@
1
- import { createAbstraction } from "@webiny/feature/api";
2
- const FOLDER_CREATED_WEBSOCKET_ACTION = "aco.folder.created";
3
- const FOLDER_UPDATED_WEBSOCKET_ACTION = "aco.folder.updated";
4
- const FOLDER_DELETED_WEBSOCKET_ACTION = "aco.folder.deleted";
5
- const NotifyFolderChangeUseCase = createAbstraction("Aco/NotifyFolderChangeUseCase");
6
- export { FOLDER_CREATED_WEBSOCKET_ACTION, FOLDER_DELETED_WEBSOCKET_ACTION, FOLDER_UPDATED_WEBSOCKET_ACTION, NotifyFolderChangeUseCase };
7
-
8
- //# sourceMappingURL=abstractions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"features/folder/NotifyFolderChange/abstractions.js","sources":["../../../../src/features/folder/NotifyFolderChange/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\n/**\n * Sent to the user's open admin tabs when a folder changes. The admin keeps its own folder cache,\n * and a change made on the server never passes through it, so without these the admin shows the old\n * state until a reload. Each carries the folder id only; the admin reads the folder back.\n *\n * `created` and `updated` go out when the FLP tasks finish, since folder reads report permissions\n * from the FLP records. `deleted` goes out right after the delete: nothing is read back.\n */\nexport const FOLDER_CREATED_WEBSOCKET_ACTION = \"aco.folder.created\";\nexport const FOLDER_UPDATED_WEBSOCKET_ACTION = \"aco.folder.updated\";\nexport const FOLDER_DELETED_WEBSOCKET_ACTION = \"aco.folder.deleted\";\n\nexport interface NotifyFolderChangeParams {\n id: string;\n /**\n * Whose open tabs to tell. Defaults to the current identity. The FLP tasks pass the identity\n * that made the change, because they run later, outside that request.\n */\n identityId?: string;\n change: \"created\" | \"updated\" | \"deleted\";\n}\n\nexport interface INotifyFolderChangeUseCase {\n execute(params: NotifyFolderChangeParams): Promise<void>;\n}\n\nexport const NotifyFolderChangeUseCase = createAbstraction<INotifyFolderChangeUseCase>(\n \"Aco/NotifyFolderChangeUseCase\"\n);\n\nexport namespace NotifyFolderChangeUseCase {\n export type Interface = INotifyFolderChangeUseCase;\n export type Params = NotifyFolderChangeParams;\n}\n"],"names":["FOLDER_CREATED_WEBSOCKET_ACTION","FOLDER_UPDATED_WEBSOCKET_ACTION","FOLDER_DELETED_WEBSOCKET_ACTION","NotifyFolderChangeUseCase","createAbstraction"],"mappings":";AAUO,MAAMA,kCAAkC;AACxC,MAAMC,kCAAkC;AACxC,MAAMC,kCAAkC;AAgBxC,MAAMC,4BAA4BC,kBACrC"}