@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,7 +1,7 @@
1
1
  /**
2
- * Folder, team and role tools for AI callers.
2
+ * Folder tools for AI callers. The team and role tools live in api-core, next to teams and roles.
3
3
  *
4
- * The list tools are read-only and run unattended. Anything that creates, renames, moves, deletes or changes access is a write,
4
+ * listFolders is read-only and runs unattended. Anything that creates, renames, moves, deletes or changes access is a write,
5
5
  * so it pauses for the user to approve the exact arguments. Access changes are deliberately one target
6
6
  * per call — granting and revoking separately means the approval block shows the entire change, rather
7
7
  * than a desired end state whose omissions quietly remove somebody's access.
@@ -1,35 +1,19 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
- import { ListTeamsTool } from "./ListTeamsTool.js";
3
2
  import { ListFoldersTool } from "./ListFoldersTool.js";
4
3
  import { GrantFolderAccessTool } from "./GrantFolderAccessTool.js";
5
4
  import { RevokeFolderAccessTool } from "./RevokeFolderAccessTool.js";
6
5
  import { CreateFolderTool } from "./CreateFolderTool.js";
7
6
  import { UpdateFolderTool } from "./UpdateFolderTool.js";
8
7
  import { DeleteFolderTool } from "./DeleteFolderTool.js";
9
- import { CreateTeamTool } from "./CreateTeamTool.js";
10
- import { UpdateTeamTool } from "./UpdateTeamTool.js";
11
- import { DeleteTeamTool } from "./DeleteTeamTool.js";
12
- import { ListRolesTool } from "./ListRolesTool.js";
13
- import { CreateRoleTool } from "./CreateRoleTool.js";
14
- import { UpdateRoleTool } from "./UpdateRoleTool.js";
15
- import { DeleteRoleTool } from "./DeleteRoleTool.js";
16
8
  const AcoAiToolsFeature = createFeature({
17
9
  name: "Aco/AiTools",
18
10
  register (container) {
19
- container.register(ListTeamsTool);
20
11
  container.register(ListFoldersTool);
21
12
  container.register(GrantFolderAccessTool);
22
13
  container.register(RevokeFolderAccessTool);
23
14
  container.register(CreateFolderTool);
24
15
  container.register(UpdateFolderTool);
25
16
  container.register(DeleteFolderTool);
26
- container.register(CreateTeamTool);
27
- container.register(UpdateTeamTool);
28
- container.register(DeleteTeamTool);
29
- container.register(ListRolesTool);
30
- container.register(CreateRoleTool);
31
- container.register(UpdateRoleTool);
32
- container.register(DeleteRoleTool);
33
17
  }
34
18
  });
35
19
  export { AcoAiToolsFeature };
@@ -1 +1 @@
1
- {"version":3,"file":"features/ai/feature.js","sources":["../../../src/features/ai/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListTeamsTool } from \"./ListTeamsTool.js\";\nimport { ListFoldersTool } from \"./ListFoldersTool.js\";\nimport { GrantFolderAccessTool } from \"./GrantFolderAccessTool.js\";\nimport { RevokeFolderAccessTool } from \"./RevokeFolderAccessTool.js\";\nimport { CreateFolderTool } from \"./CreateFolderTool.js\";\nimport { UpdateFolderTool } from \"./UpdateFolderTool.js\";\nimport { DeleteFolderTool } from \"./DeleteFolderTool.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 * Folder, team and role tools for AI callers.\n *\n * The list tools are read-only and run unattended. Anything that creates, renames, moves, deletes or changes access is a write,\n * so it pauses for the user to approve the exact arguments. Access changes are deliberately one target\n * per call — granting and revoking separately means the approval block shows the entire change, rather\n * than a desired end state whose omissions quietly remove somebody's access.\n */\nexport const AcoAiToolsFeature = createFeature({\n name: \"Aco/AiTools\",\n register(container) {\n container.register(ListTeamsTool);\n container.register(ListFoldersTool);\n container.register(GrantFolderAccessTool);\n container.register(RevokeFolderAccessTool);\n container.register(CreateFolderTool);\n container.register(UpdateFolderTool);\n container.register(DeleteFolderTool);\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":["AcoAiToolsFeature","createFeature","container","ListTeamsTool","ListFoldersTool","GrantFolderAccessTool","RevokeFolderAccessTool","CreateFolderTool","UpdateFolderTool","DeleteFolderTool","CreateTeamTool","UpdateTeamTool","DeleteTeamTool","ListRolesTool","CreateRoleTool","UpdateRoleTool","DeleteRoleTool"],"mappings":";;;;;;;;;;;;;;;AAwBO,MAAMA,oBAAoBC,cAAc;IAC3C,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;QACnBR,UAAU,QAAQ,CAACS;QACnBT,UAAU,QAAQ,CAACU;QACnBV,UAAU,QAAQ,CAACW;QACnBX,UAAU,QAAQ,CAACY;QACnBZ,UAAU,QAAQ,CAACa;QACnBb,UAAU,QAAQ,CAACc;IACvB;AACJ"}
1
+ {"version":3,"file":"features/ai/feature.js","sources":["../../../src/features/ai/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListFoldersTool } from \"./ListFoldersTool.js\";\nimport { GrantFolderAccessTool } from \"./GrantFolderAccessTool.js\";\nimport { RevokeFolderAccessTool } from \"./RevokeFolderAccessTool.js\";\nimport { CreateFolderTool } from \"./CreateFolderTool.js\";\nimport { UpdateFolderTool } from \"./UpdateFolderTool.js\";\nimport { DeleteFolderTool } from \"./DeleteFolderTool.js\";\n\n/**\n * Folder tools for AI callers. The team and role tools live in api-core, next to teams and roles.\n *\n * listFolders is read-only and runs unattended. Anything that creates, renames, moves, deletes or changes access is a write,\n * so it pauses for the user to approve the exact arguments. Access changes are deliberately one target\n * per call — granting and revoking separately means the approval block shows the entire change, rather\n * than a desired end state whose omissions quietly remove somebody's access.\n */\nexport const AcoAiToolsFeature = createFeature({\n name: \"Aco/AiTools\",\n register(container) {\n container.register(ListFoldersTool);\n container.register(GrantFolderAccessTool);\n container.register(RevokeFolderAccessTool);\n container.register(CreateFolderTool);\n container.register(UpdateFolderTool);\n container.register(DeleteFolderTool);\n }\n});\n"],"names":["AcoAiToolsFeature","createFeature","container","ListFoldersTool","GrantFolderAccessTool","RevokeFolderAccessTool","CreateFolderTool","UpdateFolderTool","DeleteFolderTool"],"mappings":";;;;;;;AAgBO,MAAMA,oBAAoBC,cAAc;IAC3C,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;IACvB;AACJ"}
@@ -1,15 +1,7 @@
1
1
  export { AcoAiToolsFeature } from "./feature.js";
2
- export { ListTeamsTool } from "./ListTeamsTool.js";
3
2
  export { ListFoldersTool } from "./ListFoldersTool.js";
4
- export { ListRolesTool } from "./ListRolesTool.js";
5
- export { CreateRoleTool } from "./CreateRoleTool.js";
6
- export { UpdateRoleTool } from "./UpdateRoleTool.js";
7
- export { DeleteRoleTool } from "./DeleteRoleTool.js";
8
3
  export { GrantFolderAccessTool } from "./GrantFolderAccessTool.js";
9
4
  export { RevokeFolderAccessTool } from "./RevokeFolderAccessTool.js";
10
5
  export { CreateFolderTool } from "./CreateFolderTool.js";
11
6
  export { UpdateFolderTool } from "./UpdateFolderTool.js";
12
7
  export { DeleteFolderTool } from "./DeleteFolderTool.js";
13
- export { CreateTeamTool } from "./CreateTeamTool.js";
14
- export { UpdateTeamTool } from "./UpdateTeamTool.js";
15
- export { DeleteTeamTool } from "./DeleteTeamTool.js";
@@ -1,15 +1,7 @@
1
1
  export { AcoAiToolsFeature } from "./feature.js";
2
- export { ListTeamsTool } from "./ListTeamsTool.js";
3
2
  export { ListFoldersTool } from "./ListFoldersTool.js";
4
- export { ListRolesTool } from "./ListRolesTool.js";
5
- export { CreateRoleTool } from "./CreateRoleTool.js";
6
- export { UpdateRoleTool } from "./UpdateRoleTool.js";
7
- export { DeleteRoleTool } from "./DeleteRoleTool.js";
8
3
  export { GrantFolderAccessTool } from "./GrantFolderAccessTool.js";
9
4
  export { RevokeFolderAccessTool } from "./RevokeFolderAccessTool.js";
10
5
  export { CreateFolderTool } from "./CreateFolderTool.js";
11
6
  export { UpdateFolderTool } from "./UpdateFolderTool.js";
12
7
  export { DeleteFolderTool } from "./DeleteFolderTool.js";
13
- export { CreateTeamTool } from "./CreateTeamTool.js";
14
- export { UpdateTeamTool } from "./UpdateTeamTool.js";
15
- export { DeleteTeamTool } from "./DeleteTeamTool.js";
@@ -20,7 +20,6 @@ class FolderLevelPermissionsImpl {
20
20
  canUseFolderLevelPermissions(enabled) {
21
21
  if (false === enabled) return false;
22
22
  const identity = this.identityContext.getIdentity();
23
- if (!identity) return false;
24
23
  if ("admin" !== identity.type) return false;
25
24
  return this.featureFlags.get().isEnabled("advancedAccessControlLayer.folderLevelPermissions");
26
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/flp/FolderLevelPermissions/FolderLevelPermissions.js","sources":["../../../../src/features/flp/FolderLevelPermissions/FolderLevelPermissions.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { FeatureFlags } from \"@webiny/api-core/features/featureFlags/abstractions.js\";\nimport { ListUserTeamsUseCase } from \"@webiny/api-core/features/users/ListUserTeams/index.js\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared/index.js\";\nimport {\n CanAccessFolder,\n CanAccessFolderContent,\n type CanAccessFolderContentParams,\n type CanAccessFolderParams,\n CanCreateFolderInRoot,\n CheckNotInheritedPermissions,\n GetDefaultPermissions,\n GetDefaultPermissionsWithTeams,\n type IGetDefaultPermissions\n} from \"./useCases/index.js\";\nimport { FolderLevelPermissions as FolderLevelPermissionsAbstraction } from \"./abstractions.js\";\nimport { DefaultPermissionsMerger } from \"./useCases/GetDefaultPermissions/DefaultPermissionsMerger.js\";\nimport { expandTeamPermissions } from \"./useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.js\";\nimport type { Team } from \"@webiny/api-core/types/security.js\";\nimport type { FolderLevelPermission, FolderPermission } from \"~/types.js\";\nimport type { ListFolderPermissionsParams } from \"~/features/flp/FolderPermissionsRepository/abstractions.js\";\nimport { ListFlpsUseCase } from \"~/features/flp/ListFlps/index.js\";\nimport { GetFlpUseCase } from \"~/features/flp/GetFlp/index.js\";\n\nclass FolderLevelPermissionsImpl implements FolderLevelPermissionsAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private featureFlags: FeatureFlags.Interface,\n private listUserTeamsUseCase: ListUserTeamsUseCase.Interface,\n private getFlpUseCase: GetFlpUseCase.Interface,\n private listFlpsUseCase: ListFlpsUseCase.Interface\n ) {}\n\n public canUseFolderLevelPermissions(enabled?: boolean): boolean {\n if (enabled === false) {\n return false;\n }\n\n const identity = this.identityContext.getIdentity();\n\n // FLPs only work with authenticated identities (logged-in users).\n if (!identity) {\n return false;\n }\n\n // At the moment, we only want FLP to be used with identities of type \"admin\".\n // This temporarily addresses the issue of API keys not being able to access content, because\n // FLPs doesn't work with them. Once we start adding FLPs to API keys, we can remove this check.\n if (identity.type !== \"admin\") {\n return false;\n }\n\n return this.featureFlags\n .get()\n .isEnabled(\"advancedAccessControlLayer.folderLevelPermissions\");\n }\n\n public canUseTeams(): boolean {\n return this.featureFlags.get().isEnabled(\"advancedAccessControlLayer.teams\");\n }\n\n public canCreateFolderInRoot(): boolean {\n const canCreateFolderInRootUseCase = new CanCreateFolderInRoot();\n return canCreateFolderInRootUseCase.execute();\n }\n\n public permissionsIncludeNonInheritedPermissions(permissions: FolderPermission[]): boolean {\n const checkNotInheritedPermissionsUseCase = new CheckNotInheritedPermissions();\n return checkNotInheritedPermissionsUseCase.execute(permissions);\n }\n\n public async canAccessFolder(params: CanAccessFolderParams): Promise<boolean> {\n if (\n !this.canUseFolderLevelPermissions() ||\n !this.identityContext.isAuthorizationEnabled()\n ) {\n return true;\n }\n\n const canAccessFolderUseCase = new CanAccessFolder(this.identityContext);\n return await canAccessFolderUseCase.execute(params);\n }\n\n public async canAccessFolderContent(params: CanAccessFolderContentParams): Promise<boolean> {\n const canUseFlp = this.canUseFolderLevelPermissions();\n const authEnabled = this.identityContext.isAuthorizationEnabled();\n\n if (!canUseFlp || !authEnabled) {\n return true;\n }\n\n const canAccessFolderContentUseCase = new CanAccessFolderContent(this.identityContext);\n return await canAccessFolderContentUseCase.execute(params);\n }\n\n public async ensureCanAccessFolder(params: CanAccessFolderParams): Promise<void> {\n const result = await this.canAccessFolder(params);\n if (!result) {\n throw new NotAuthorizedError();\n }\n }\n\n public async ensureCanAccessFolderContent(params: CanAccessFolderContentParams): Promise<void> {\n const result = await this.canAccessFolderContent(params);\n if (!result) {\n throw new NotAuthorizedError();\n }\n }\n\n public async canManageFolderContent(flp: FolderLevelPermission): Promise<boolean> {\n if (\n !this.canUseFolderLevelPermissions() ||\n !this.identityContext.isAuthorizationEnabled()\n ) {\n return true;\n }\n\n return await this.canAccessFolderContent({ permissions: flp.permissions, rwd: \"w\" });\n }\n\n public async canManageFolderStructure(flp: FolderLevelPermission): Promise<boolean> {\n if (\n !this.canUseFolderLevelPermissions() ||\n !this.identityContext.isAuthorizationEnabled()\n ) {\n return true;\n }\n\n return await this.canAccessFolder({ permissions: flp.permissions, rwd: \"w\" });\n }\n\n public async canManageFolderPermissions(flp: FolderLevelPermission): Promise<boolean> {\n if (!this.canUseFolderLevelPermissions()) {\n return false;\n }\n\n if (!this.identityContext.isAuthorizationEnabled()) {\n return true;\n }\n\n return await this.canAccessFolder({\n permissions: flp.permissions,\n rwd: \"w\",\n managePermissions: true\n });\n }\n\n // With teams enabled, every call loads the current user's teams through `ListUserTeamsUseCase`\n // (an admin user read plus a team list). Nothing caches them between calls.\n public getDefaultPermissions(permissions: FolderPermission[]): Promise<FolderPermission[]> {\n return this.createDefaultPermissions().execute(permissions);\n }\n\n public async getDefaultPermissionsBatch(\n permissionsList: FolderPermission[][]\n ): Promise<FolderPermission[][]> {\n if (permissionsList.length === 0) {\n return [];\n }\n const identity = this.identityContext.getIdentity();\n const identityPermissions = await this.identityContext.listPermissions();\n\n let identityTeams: Team[] = [];\n if (this.canUseTeams()) {\n const result = await this.listUserTeamsUseCase.execute(identity.id);\n identityTeams = result.isOk() ? result.value : [];\n }\n\n // The same steps as getDefaultPermissions(), with the lookups done once.\n return permissionsList.map(permissions =>\n DefaultPermissionsMerger.merge(\n identity,\n identityPermissions,\n this.canUseTeams()\n ? expandTeamPermissions(identity, identityTeams, permissions)\n : permissions\n )\n );\n }\n\n public async listFolderLevelPermissions(params: ListFolderPermissionsParams): Promise<\n Array<{\n id: string;\n permissions: FolderPermission[];\n }>\n > {\n const flps = await this.listFlpsUseCase.execute(params);\n\n // One instance for every listed record: with teams enabled, the user's teams are loaded\n // once per call, not once per record.\n const defaultPermissions = this.createDefaultPermissions();\n return Promise.all(\n flps.map(async flp => ({\n id: flp.id,\n permissions: await defaultPermissions.execute(flp.permissions)\n }))\n );\n }\n\n private createDefaultPermissions(): IGetDefaultPermissions {\n const getDefaultPermissionsUseCase = new GetDefaultPermissions(this.identityContext);\n if (!this.canUseTeams()) {\n return getDefaultPermissionsUseCase;\n }\n return new GetDefaultPermissionsWithTeams(\n this.identityContext,\n this.listUserTeamsUseCase,\n getDefaultPermissionsUseCase\n );\n }\n\n public async getFolderLevelPermissions(id: string): Promise<FolderPermission[]> {\n const flp = await this.getFlpUseCase.execute(id);\n return await this.getDefaultPermissions(flp?.permissions ?? []);\n }\n}\n\nexport const FolderLevelPermissions = createImplementation({\n abstraction: FolderLevelPermissionsAbstraction,\n implementation: FolderLevelPermissionsImpl,\n dependencies: [\n IdentityContext,\n FeatureFlags,\n ListUserTeamsUseCase,\n GetFlpUseCase,\n ListFlpsUseCase\n ]\n});\n"],"names":["FolderLevelPermissionsImpl","identityContext","featureFlags","listUserTeamsUseCase","getFlpUseCase","listFlpsUseCase","enabled","identity","canCreateFolderInRootUseCase","CanCreateFolderInRoot","permissions","checkNotInheritedPermissionsUseCase","CheckNotInheritedPermissions","params","canAccessFolderUseCase","CanAccessFolder","canUseFlp","authEnabled","canAccessFolderContentUseCase","CanAccessFolderContent","result","NotAuthorizedError","flp","permissionsList","identityPermissions","identityTeams","DefaultPermissionsMerger","expandTeamPermissions","flps","defaultPermissions","Promise","getDefaultPermissionsUseCase","GetDefaultPermissions","GetDefaultPermissionsWithTeams","id","FolderLevelPermissions","createImplementation","FolderLevelPermissionsAbstraction","IdentityContext","FeatureFlags","ListUserTeamsUseCase","GetFlpUseCase","ListFlpsUseCase"],"mappings":"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"}
1
+ {"version":3,"file":"features/flp/FolderLevelPermissions/FolderLevelPermissions.js","sources":["../../../../src/features/flp/FolderLevelPermissions/FolderLevelPermissions.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { FeatureFlags } from \"@webiny/api-core/features/featureFlags/abstractions.js\";\nimport { ListUserTeamsUseCase } from \"@webiny/api-core/features/users/ListUserTeams/index.js\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared/index.js\";\nimport {\n CanAccessFolder,\n CanAccessFolderContent,\n type CanAccessFolderContentParams,\n type CanAccessFolderParams,\n CanCreateFolderInRoot,\n CheckNotInheritedPermissions,\n GetDefaultPermissions,\n GetDefaultPermissionsWithTeams,\n type IGetDefaultPermissions\n} from \"./useCases/index.js\";\nimport { FolderLevelPermissions as FolderLevelPermissionsAbstraction } from \"./abstractions.js\";\nimport { DefaultPermissionsMerger } from \"./useCases/GetDefaultPermissions/DefaultPermissionsMerger.js\";\nimport { expandTeamPermissions } from \"./useCases/GetDefaultPermissions/GetDefaultPermissionsWithTeams.js\";\nimport type { Team } from \"@webiny/api-core/types/security.js\";\nimport type { FolderLevelPermission, FolderPermission } from \"~/types.js\";\nimport type { ListFolderPermissionsParams } from \"~/features/flp/FolderPermissionsRepository/abstractions.js\";\nimport { ListFlpsUseCase } from \"~/features/flp/ListFlps/index.js\";\nimport { GetFlpUseCase } from \"~/features/flp/GetFlp/index.js\";\n\nclass FolderLevelPermissionsImpl implements FolderLevelPermissionsAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private featureFlags: FeatureFlags.Interface,\n private listUserTeamsUseCase: ListUserTeamsUseCase.Interface,\n private getFlpUseCase: GetFlpUseCase.Interface,\n private listFlpsUseCase: ListFlpsUseCase.Interface\n ) {}\n\n public canUseFolderLevelPermissions(enabled?: boolean): boolean {\n if (enabled === false) {\n return false;\n }\n\n const identity = this.identityContext.getIdentity();\n\n // At the moment, we only want FLP to be used with identities of type \"admin\".\n // This temporarily addresses the issue of API keys not being able to access content, because\n // FLPs doesn't work with them. Once we start adding FLPs to API keys, we can remove this check.\n if (identity.type !== \"admin\") {\n return false;\n }\n\n return this.featureFlags\n .get()\n .isEnabled(\"advancedAccessControlLayer.folderLevelPermissions\");\n }\n\n public canUseTeams(): boolean {\n return this.featureFlags.get().isEnabled(\"advancedAccessControlLayer.teams\");\n }\n\n public canCreateFolderInRoot(): boolean {\n const canCreateFolderInRootUseCase = new CanCreateFolderInRoot();\n return canCreateFolderInRootUseCase.execute();\n }\n\n public permissionsIncludeNonInheritedPermissions(permissions: FolderPermission[]): boolean {\n const checkNotInheritedPermissionsUseCase = new CheckNotInheritedPermissions();\n return checkNotInheritedPermissionsUseCase.execute(permissions);\n }\n\n public async canAccessFolder(params: CanAccessFolderParams): Promise<boolean> {\n if (\n !this.canUseFolderLevelPermissions() ||\n !this.identityContext.isAuthorizationEnabled()\n ) {\n return true;\n }\n\n const canAccessFolderUseCase = new CanAccessFolder(this.identityContext);\n return await canAccessFolderUseCase.execute(params);\n }\n\n public async canAccessFolderContent(params: CanAccessFolderContentParams): Promise<boolean> {\n const canUseFlp = this.canUseFolderLevelPermissions();\n const authEnabled = this.identityContext.isAuthorizationEnabled();\n\n if (!canUseFlp || !authEnabled) {\n return true;\n }\n\n const canAccessFolderContentUseCase = new CanAccessFolderContent(this.identityContext);\n return await canAccessFolderContentUseCase.execute(params);\n }\n\n public async ensureCanAccessFolder(params: CanAccessFolderParams): Promise<void> {\n const result = await this.canAccessFolder(params);\n if (!result) {\n throw new NotAuthorizedError();\n }\n }\n\n public async ensureCanAccessFolderContent(params: CanAccessFolderContentParams): Promise<void> {\n const result = await this.canAccessFolderContent(params);\n if (!result) {\n throw new NotAuthorizedError();\n }\n }\n\n public async canManageFolderContent(flp: FolderLevelPermission): Promise<boolean> {\n if (\n !this.canUseFolderLevelPermissions() ||\n !this.identityContext.isAuthorizationEnabled()\n ) {\n return true;\n }\n\n return await this.canAccessFolderContent({ permissions: flp.permissions, rwd: \"w\" });\n }\n\n public async canManageFolderStructure(flp: FolderLevelPermission): Promise<boolean> {\n if (\n !this.canUseFolderLevelPermissions() ||\n !this.identityContext.isAuthorizationEnabled()\n ) {\n return true;\n }\n\n return await this.canAccessFolder({ permissions: flp.permissions, rwd: \"w\" });\n }\n\n public async canManageFolderPermissions(flp: FolderLevelPermission): Promise<boolean> {\n if (!this.canUseFolderLevelPermissions()) {\n return false;\n }\n\n if (!this.identityContext.isAuthorizationEnabled()) {\n return true;\n }\n\n return await this.canAccessFolder({\n permissions: flp.permissions,\n rwd: \"w\",\n managePermissions: true\n });\n }\n\n // With teams enabled, every call loads the current user's teams through `ListUserTeamsUseCase`\n // (an admin user read plus a team list). Nothing caches them between calls.\n public getDefaultPermissions(permissions: FolderPermission[]): Promise<FolderPermission[]> {\n return this.createDefaultPermissions().execute(permissions);\n }\n\n public async getDefaultPermissionsBatch(\n permissionsList: FolderPermission[][]\n ): Promise<FolderPermission[][]> {\n if (permissionsList.length === 0) {\n return [];\n }\n const identity = this.identityContext.getIdentity();\n const identityPermissions = await this.identityContext.listPermissions();\n\n let identityTeams: Team[] = [];\n if (this.canUseTeams()) {\n const result = await this.listUserTeamsUseCase.execute(identity.id);\n identityTeams = result.isOk() ? result.value : [];\n }\n\n // The same steps as getDefaultPermissions(), with the lookups done once.\n return permissionsList.map(permissions =>\n DefaultPermissionsMerger.merge(\n identity,\n identityPermissions,\n this.canUseTeams()\n ? expandTeamPermissions(identity, identityTeams, permissions)\n : permissions\n )\n );\n }\n\n public async listFolderLevelPermissions(params: ListFolderPermissionsParams): Promise<\n Array<{\n id: string;\n permissions: FolderPermission[];\n }>\n > {\n const flps = await this.listFlpsUseCase.execute(params);\n\n // One instance for every listed record: with teams enabled, the user's teams are loaded\n // once per call, not once per record.\n const defaultPermissions = this.createDefaultPermissions();\n return Promise.all(\n flps.map(async flp => ({\n id: flp.id,\n permissions: await defaultPermissions.execute(flp.permissions)\n }))\n );\n }\n\n private createDefaultPermissions(): IGetDefaultPermissions {\n const getDefaultPermissionsUseCase = new GetDefaultPermissions(this.identityContext);\n if (!this.canUseTeams()) {\n return getDefaultPermissionsUseCase;\n }\n return new GetDefaultPermissionsWithTeams(\n this.identityContext,\n this.listUserTeamsUseCase,\n getDefaultPermissionsUseCase\n );\n }\n\n public async getFolderLevelPermissions(id: string): Promise<FolderPermission[]> {\n const flp = await this.getFlpUseCase.execute(id);\n return await this.getDefaultPermissions(flp?.permissions ?? []);\n }\n}\n\nexport const FolderLevelPermissions = createImplementation({\n abstraction: FolderLevelPermissionsAbstraction,\n implementation: FolderLevelPermissionsImpl,\n dependencies: [\n IdentityContext,\n FeatureFlags,\n ListUserTeamsUseCase,\n GetFlpUseCase,\n ListFlpsUseCase\n ]\n});\n"],"names":["FolderLevelPermissionsImpl","identityContext","featureFlags","listUserTeamsUseCase","getFlpUseCase","listFlpsUseCase","enabled","identity","canCreateFolderInRootUseCase","CanCreateFolderInRoot","permissions","checkNotInheritedPermissionsUseCase","CheckNotInheritedPermissions","params","canAccessFolderUseCase","CanAccessFolder","canUseFlp","authEnabled","canAccessFolderContentUseCase","CanAccessFolderContent","result","NotAuthorizedError","flp","permissionsList","identityPermissions","identityTeams","DefaultPermissionsMerger","expandTeamPermissions","flps","defaultPermissions","Promise","getDefaultPermissionsUseCase","GetDefaultPermissions","GetDefaultPermissionsWithTeams","id","FolderLevelPermissions","createImplementation","FolderLevelPermissionsAbstraction","IdentityContext","FeatureFlags","ListUserTeamsUseCase","GetFlpUseCase","ListFlpsUseCase"],"mappings":"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"}
@@ -1,6 +1,6 @@
1
1
  const mayAskAboutUser = async (identityContext, userId)=>{
2
2
  if (!identityContext.isAuthorizationEnabled()) return true;
3
- if (identityContext.getIdentity()?.id === userId) return true;
3
+ if (identityContext.getIdentity().id === userId) return true;
4
4
  const permissions = await identityContext.listPermissions();
5
5
  return permissions.some((permission)=>"*" === permission.name);
6
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"features/flp/ListFolderAccess/mayAskAboutUser.js","sources":["../../../../src/features/flp/ListFolderAccess/mayAskAboutUser.ts"],"sourcesContent":["import type { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\n\n/** About oneself, always; about others, with full access (or authorization turned off). */\nexport const mayAskAboutUser = async (\n identityContext: IdentityContext.Interface,\n userId: string\n): Promise<boolean> => {\n if (!identityContext.isAuthorizationEnabled()) {\n return true;\n }\n if (identityContext.getIdentity()?.id === userId) {\n return true;\n }\n const permissions = await identityContext.listPermissions();\n return permissions.some(permission => permission.name === \"*\");\n};\n"],"names":["mayAskAboutUser","identityContext","userId","permissions","permission"],"mappings":"AAGO,MAAMA,kBAAkB,OAC3BC,iBACAC;IAEA,IAAI,CAACD,gBAAgB,sBAAsB,IACvC,OAAO;IAEX,IAAIA,gBAAgB,WAAW,IAAI,OAAOC,QACtC,OAAO;IAEX,MAAMC,cAAc,MAAMF,gBAAgB,eAAe;IACzD,OAAOE,YAAY,IAAI,CAACC,CAAAA,aAAcA,AAAoB,QAApBA,WAAW,IAAI;AACzD"}
1
+ {"version":3,"file":"features/flp/ListFolderAccess/mayAskAboutUser.js","sources":["../../../../src/features/flp/ListFolderAccess/mayAskAboutUser.ts"],"sourcesContent":["import type { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\n\n/** About oneself, always; about others, with full access (or authorization turned off). */\nexport const mayAskAboutUser = async (\n identityContext: IdentityContext.Interface,\n userId: string\n): Promise<boolean> => {\n if (!identityContext.isAuthorizationEnabled()) {\n return true;\n }\n if (identityContext.getIdentity().id === userId) {\n return true;\n }\n const permissions = await identityContext.listPermissions();\n return permissions.some(permission => permission.name === \"*\");\n};\n"],"names":["mayAskAboutUser","identityContext","userId","permissions","permission"],"mappings":"AAGO,MAAMA,kBAAkB,OAC3BC,iBACAC;IAEA,IAAI,CAACD,gBAAgB,sBAAsB,IACvC,OAAO;IAEX,IAAIA,gBAAgB,WAAW,GAAG,EAAE,KAAKC,QACrC,OAAO;IAEX,MAAMC,cAAc,MAAMF,gBAAgB,eAAe;IACzD,OAAOE,YAAY,IAAI,CAACC,CAAAA,aAAcA,AAAoB,QAApBA,WAAW,IAAI;AACzD"}
@@ -1,9 +1,9 @@
1
1
  import { FolderAfterDeleteEventHandler } from "../../../features/folder/DeleteFolder/abstractions.js";
2
2
  import type { FolderAfterDeleteEvent } from "../../../features/folder/DeleteFolder/events.js";
3
- import { NotifyFolderChangeUseCase } from "./abstractions.js";
3
+ import { NotifyRecordChangeUseCase } from "@webiny/api-core/features/websockets/index.js";
4
4
  declare class NotifyOnFolderDeletedHandlerImpl implements FolderAfterDeleteEventHandler.Interface {
5
- private notifyFolderChange;
6
- constructor(notifyFolderChange: NotifyFolderChangeUseCase.Interface);
5
+ private notifyRecordChange;
6
+ constructor(notifyRecordChange: NotifyRecordChangeUseCase.Interface);
7
7
  handle(event: FolderAfterDeleteEvent): Promise<void>;
8
8
  }
9
9
  export declare const NotifyOnFolderDeletedHandler: typeof NotifyOnFolderDeletedHandlerImpl & {
@@ -1,22 +1,22 @@
1
1
  import { FolderAfterDeleteEventHandler } from "../DeleteFolder/abstractions.js";
2
- import { NotifyFolderChangeUseCase } from "./abstractions.js";
2
+ import { NotifyRecordChangeUseCase } from "@webiny/api-core/features/websockets/index.js";
3
+ import { FOLDER_RECORD_TYPE } from "./recordType.js";
3
4
  class NotifyOnFolderDeletedHandlerImpl {
4
- constructor(notifyFolderChange){
5
- this.notifyFolderChange = notifyFolderChange;
5
+ constructor(notifyRecordChange){
6
+ this.notifyRecordChange = notifyRecordChange;
6
7
  }
7
8
  async handle(event) {
8
- try {
9
- await this.notifyFolderChange.execute({
10
- id: event.payload.folder.id,
11
- change: "deleted"
12
- });
13
- } catch {}
9
+ await this.notifyRecordChange.execute({
10
+ type: FOLDER_RECORD_TYPE,
11
+ id: event.payload.folder.id,
12
+ change: "deleted"
13
+ });
14
14
  }
15
15
  }
16
16
  const NotifyOnFolderDeletedHandler = FolderAfterDeleteEventHandler.createImplementation({
17
17
  implementation: NotifyOnFolderDeletedHandlerImpl,
18
18
  dependencies: [
19
- NotifyFolderChangeUseCase
19
+ NotifyRecordChangeUseCase
20
20
  ]
21
21
  });
22
22
  export { NotifyOnFolderDeletedHandler };
@@ -1 +1 @@
1
- {"version":3,"file":"features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.js","sources":["../../../../src/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.ts"],"sourcesContent":["import { FolderAfterDeleteEventHandler } from \"~/features/folder/DeleteFolder/abstractions.js\";\nimport type { FolderAfterDeleteEvent } from \"~/features/folder/DeleteFolder/events.js\";\nimport { NotifyFolderChangeUseCase } from \"./abstractions.js\";\n\n/*\n * Created and updated folders are announced by the FLP tasks, once the admin can read them back. A\n * deleted folder is only dropped from the admin's cache, so there is nothing to wait for.\n */\nclass NotifyOnFolderDeletedHandlerImpl implements FolderAfterDeleteEventHandler.Interface {\n constructor(private notifyFolderChange: NotifyFolderChangeUseCase.Interface) {}\n\n async handle(event: FolderAfterDeleteEvent): Promise<void> {\n try {\n await this.notifyFolderChange.execute({\n id: event.payload.folder.id,\n change: \"deleted\"\n });\n } catch {\n // The folder is gone either way; the admin drops it on its next reload.\n }\n }\n}\n\nexport const NotifyOnFolderDeletedHandler = FolderAfterDeleteEventHandler.createImplementation({\n implementation: NotifyOnFolderDeletedHandlerImpl,\n dependencies: [NotifyFolderChangeUseCase]\n});\n"],"names":["NotifyOnFolderDeletedHandlerImpl","notifyFolderChange","event","NotifyOnFolderDeletedHandler","FolderAfterDeleteEventHandler","NotifyFolderChangeUseCase"],"mappings":";;AAQA,MAAMA;IACF,YAAoBC,kBAAuD,CAAE;aAAzDA,kBAAkB,GAAlBA;IAA0D;IAE9E,MAAM,OAAOC,KAA6B,EAAiB;QACvD,IAAI;YACA,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;gBAClC,IAAIA,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE;gBAC3B,QAAQ;YACZ;QACJ,EAAE,OAAM,CAER;IACJ;AACJ;AAEO,MAAMC,+BAA+BC,8BAA8B,oBAAoB,CAAC;IAC3F,gBAAgBJ;IAChB,cAAc;QAACK;KAA0B;AAC7C"}
1
+ {"version":3,"file":"features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.js","sources":["../../../../src/features/folder/NotifyFolderChange/NotifyOnFolderDeletedHandler.ts"],"sourcesContent":["import { FolderAfterDeleteEventHandler } from \"~/features/folder/DeleteFolder/abstractions.js\";\nimport type { FolderAfterDeleteEvent } from \"~/features/folder/DeleteFolder/events.js\";\nimport { NotifyRecordChangeUseCase } from \"@webiny/api-core/features/websockets/index.js\";\nimport { FOLDER_RECORD_TYPE } from \"./recordType.js\";\n\n/*\n * Created and updated folders are announced by the FLP tasks, once the admin can read them back. A\n * deleted folder is only dropped from the admin's cache, so there is nothing to wait for.\n */\nclass NotifyOnFolderDeletedHandlerImpl implements FolderAfterDeleteEventHandler.Interface {\n constructor(private notifyRecordChange: NotifyRecordChangeUseCase.Interface) {}\n\n async handle(event: FolderAfterDeleteEvent): Promise<void> {\n await this.notifyRecordChange.execute({\n type: FOLDER_RECORD_TYPE,\n id: event.payload.folder.id,\n change: \"deleted\"\n });\n }\n}\n\nexport const NotifyOnFolderDeletedHandler = FolderAfterDeleteEventHandler.createImplementation({\n implementation: NotifyOnFolderDeletedHandlerImpl,\n dependencies: [NotifyRecordChangeUseCase]\n});\n"],"names":["NotifyOnFolderDeletedHandlerImpl","notifyRecordChange","event","FOLDER_RECORD_TYPE","NotifyOnFolderDeletedHandler","FolderAfterDeleteEventHandler","NotifyRecordChangeUseCase"],"mappings":";;;AASA,MAAMA;IACF,YAAoBC,kBAAuD,CAAE;aAAzDA,kBAAkB,GAAlBA;IAA0D;IAE9E,MAAM,OAAOC,KAA6B,EAAiB;QACvD,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;YAClC,MAAMC;YACN,IAAID,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE;YAC3B,QAAQ;QACZ;IACJ;AACJ;AAEO,MAAME,+BAA+BC,8BAA8B,oBAAoB,CAAC;IAC3F,gBAAgBL;IAChB,cAAc;QAACM;KAA0B;AAC7C"}
@@ -1,10 +1,8 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
- import { NotifyFolderChangeUseCase } from "./NotifyFolderChangeUseCase.js";
3
2
  import { NotifyOnFolderDeletedHandler } from "./NotifyOnFolderDeletedHandler.js";
4
3
  const NotifyFolderChangeFeature = createFeature({
5
4
  name: "NotifyFolderChange",
6
5
  register (container) {
7
- container.register(NotifyFolderChangeUseCase);
8
6
  container.register(NotifyOnFolderDeletedHandler);
9
7
  }
10
8
  });
@@ -1 +1 @@
1
- {"version":3,"file":"features/folder/NotifyFolderChange/feature.js","sources":["../../../../src/features/folder/NotifyFolderChange/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { NotifyFolderChangeUseCase } from \"./NotifyFolderChangeUseCase.js\";\nimport { NotifyOnFolderDeletedHandler } from \"./NotifyOnFolderDeletedHandler.js\";\n\n/**\n * Tells the user's open admin tabs when a folder is created, updated or deleted. The FLP tasks send\n * created and updated (triggered by `TaskFolderCatalogSync`); deleted goes out from here.\n */\nexport const NotifyFolderChangeFeature = createFeature({\n name: \"NotifyFolderChange\",\n register(container) {\n container.register(NotifyFolderChangeUseCase);\n container.register(NotifyOnFolderDeletedHandler);\n }\n});\n"],"names":["NotifyFolderChangeFeature","createFeature","container","NotifyFolderChangeUseCase","NotifyOnFolderDeletedHandler"],"mappings":";;;AAQO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;IACvB;AACJ"}
1
+ {"version":3,"file":"features/folder/NotifyFolderChange/feature.js","sources":["../../../../src/features/folder/NotifyFolderChange/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { NotifyOnFolderDeletedHandler } from \"./NotifyOnFolderDeletedHandler.js\";\n\n/**\n * Tells the user's open admin tabs when a folder is created, updated or deleted. The FLP tasks send\n * created and updated (triggered by `TaskFolderCatalogSync`); deleted goes out from here.\n */\nexport const NotifyFolderChangeFeature = createFeature({\n name: \"NotifyFolderChange\",\n register(container) {\n container.register(NotifyOnFolderDeletedHandler);\n }\n});\n"],"names":["NotifyFolderChangeFeature","createFeature","container","NotifyOnFolderDeletedHandler"],"mappings":";;AAOO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
@@ -1,2 +1,2 @@
1
1
  export { NotifyFolderChangeFeature } from "./feature.js";
2
- export { NotifyFolderChangeUseCase, FOLDER_CREATED_WEBSOCKET_ACTION, FOLDER_UPDATED_WEBSOCKET_ACTION, FOLDER_DELETED_WEBSOCKET_ACTION } from "./abstractions.js";
2
+ export { FOLDER_RECORD_TYPE } from "./recordType.js";
@@ -1,2 +1,2 @@
1
1
  export { NotifyFolderChangeFeature } from "./feature.js";
2
- export { FOLDER_CREATED_WEBSOCKET_ACTION, FOLDER_DELETED_WEBSOCKET_ACTION, FOLDER_UPDATED_WEBSOCKET_ACTION, NotifyFolderChangeUseCase } from "./abstractions.js";
2
+ export { FOLDER_RECORD_TYPE } from "./recordType.js";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The `type` of the record-changed message sent when a folder changes. The admin's
3
+ * `ApplyFolderChangeToCache` filters on the same string.
4
+ *
5
+ * `created` and `updated` go out when the FLP tasks finish, since folder reads report permissions
6
+ * from the FLP records. `deleted` goes out right after the delete: nothing is read back.
7
+ */
8
+ export declare const FOLDER_RECORD_TYPE = "aco.folder";
@@ -0,0 +1,4 @@
1
+ const FOLDER_RECORD_TYPE = "aco.folder";
2
+ export { FOLDER_RECORD_TYPE };
3
+
4
+ //# sourceMappingURL=recordType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/folder/NotifyFolderChange/recordType.js","sources":["../../../../src/features/folder/NotifyFolderChange/recordType.ts"],"sourcesContent":["/**\n * The `type` of the record-changed message sent when a folder changes. The admin's\n * `ApplyFolderChangeToCache` filters on the same string.\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_RECORD_TYPE = \"aco.folder\";\n"],"names":["FOLDER_RECORD_TYPE"],"mappings":"AAOO,MAAMA,qBAAqB"}
@@ -21,6 +21,7 @@ declare class TaskFolderCatalogSyncImpl implements FolderCatalogSync.Interface {
21
21
  folderCreated(folder: Folder): Promise<void>;
22
22
  folderUpdated({ folder }: FolderCatalogSync.UpdatedParams): Promise<void>;
23
23
  folderDeleted(folder: Folder): Promise<void>;
24
+ private getNotifyIdentityId;
24
25
  private trigger;
25
26
  }
26
27
  export declare const TaskFolderCatalogSync: typeof TaskFolderCatalogSyncImpl & {
@@ -12,13 +12,13 @@ class TaskFolderCatalogSyncImpl {
12
12
  async folderCreated(folder) {
13
13
  await this.trigger(CREATE_FLP_TASK_ID, {
14
14
  folder,
15
- notifyIdentityId: this.identityContext.getIdentity()?.id
15
+ notifyIdentityId: this.getNotifyIdentityId()
16
16
  }, "Could not trigger the task that creates the folder's FLP record.");
17
17
  }
18
18
  async folderUpdated({ folder }) {
19
19
  await this.trigger(UPDATE_FLP_TASK_ID, {
20
20
  folder,
21
- notifyIdentityId: this.identityContext.getIdentity()?.id
21
+ notifyIdentityId: this.getNotifyIdentityId()
22
22
  }, "Could not trigger the task that updates the FLP records of the folder and its subtree.");
23
23
  }
24
24
  async folderDeleted(folder) {
@@ -26,6 +26,11 @@ class TaskFolderCatalogSyncImpl {
26
26
  folder
27
27
  }, "Could not trigger the task that deletes the folder's FLP record.");
28
28
  }
29
+ getNotifyIdentityId() {
30
+ const identity = this.identityContext.getIdentity();
31
+ if (identity.isAnonymous()) return;
32
+ return identity.id;
33
+ }
29
34
  async trigger(definition, input, failureMessage) {
30
35
  try {
31
36
  const result = await this.tasks.trigger({
@@ -1 +1 @@
1
- {"version":3,"file":"flpTaskCatalog/TaskFolderCatalogSync.js","sources":["../../src/flpTaskCatalog/TaskFolderCatalogSync.ts"],"sourcesContent":["import { TaskService } from \"@webiny/api-core/features/task/TaskService/index.js\";\nimport { Logger } from \"@webiny/api-core/features/logger/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport { FolderCatalogSync } from \"~/features/flp/FolderCatalogSync/abstractions.js\";\nimport type { Folder } from \"~/folder/folder.types.js\";\nimport type { ICreateFlpTaskInput, IDeleteFlpTaskInput, IUpdateFlpTaskInput } from \"~/types.js\";\nimport { CREATE_FLP_TASK_ID, DELETE_FLP_TASK_ID, UPDATE_FLP_TASK_ID } from \"~/flp/tasks/index.js\";\n\n/**\n * Keeps the FLP catalog in step by triggering the FLP tasks.\n *\n * Folder reads report permissions from the FLP records, which the tasks write later. So the create\n * and update tasks, not this class, tell the admin about the change, and they need to know whom to\n * tell. A change rewrites the folder's record and every descendant's.\n *\n * The folder change is already saved, so it stands even when a task cannot be triggered. The logged\n * error is then the only trace of why the catalog is behind.\n */\nclass TaskFolderCatalogSyncImpl implements FolderCatalogSync.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private tasks: TaskService.Interface,\n private logger: Logger.Interface\n ) {}\n\n async folderCreated(folder: Folder): Promise<void> {\n await this.trigger<ICreateFlpTaskInput>(\n CREATE_FLP_TASK_ID,\n // Nobody to tell when there is no identity, as in some system calls.\n { folder, notifyIdentityId: this.identityContext.getIdentity()?.id },\n \"Could not trigger the task that creates the folder's FLP record.\"\n );\n }\n\n async folderUpdated({ folder }: FolderCatalogSync.UpdatedParams): Promise<void> {\n await this.trigger<IUpdateFlpTaskInput>(\n UPDATE_FLP_TASK_ID,\n // Nobody to tell when there is no identity, as in some system calls.\n { folder, notifyIdentityId: this.identityContext.getIdentity()?.id },\n \"Could not trigger the task that updates the FLP records of the folder and its subtree.\"\n );\n }\n\n async folderDeleted(folder: Folder): Promise<void> {\n await this.trigger<IDeleteFlpTaskInput>(\n DELETE_FLP_TASK_ID,\n { folder },\n \"Could not trigger the task that deletes the folder's FLP record.\"\n );\n }\n\n private async trigger<TInput extends { folder: Folder }>(\n definition: string,\n input: TInput,\n failureMessage: string\n ): Promise<void> {\n try {\n const result = await this.tasks.trigger<TInput>({ definition, input });\n if (result.isFail()) {\n this.logger.error(\n { error: result.error, folderId: input.folder.id },\n failureMessage\n );\n }\n } catch (error) {\n this.logger.error({ error, folderId: input.folder.id }, failureMessage);\n }\n }\n}\n\nexport const TaskFolderCatalogSync = FolderCatalogSync.createImplementation({\n implementation: TaskFolderCatalogSyncImpl,\n dependencies: [IdentityContext, TaskService, Logger]\n});\n"],"names":["TaskFolderCatalogSyncImpl","identityContext","tasks","logger","folder","CREATE_FLP_TASK_ID","UPDATE_FLP_TASK_ID","DELETE_FLP_TASK_ID","definition","input","failureMessage","result","error","TaskFolderCatalogSync","FolderCatalogSync","IdentityContext","TaskService","Logger"],"mappings":";;;;;AAkBA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,KAA4B,EAC5BC,MAAwB,CAClC;aAHUF,eAAe,GAAfA;aACAC,KAAK,GAALA;aACAC,MAAM,GAANA;IACT;IAEH,MAAM,cAAcC,MAAc,EAAiB;QAC/C,MAAM,IAAI,CAAC,OAAO,CACdC,oBAEA;YAAED;YAAQ,kBAAkB,IAAI,CAAC,eAAe,CAAC,WAAW,IAAI;QAAG,GACnE;IAER;IAEA,MAAM,cAAc,EAAEA,MAAM,EAAmC,EAAiB;QAC5E,MAAM,IAAI,CAAC,OAAO,CACdE,oBAEA;YAAEF;YAAQ,kBAAkB,IAAI,CAAC,eAAe,CAAC,WAAW,IAAI;QAAG,GACnE;IAER;IAEA,MAAM,cAAcA,MAAc,EAAiB;QAC/C,MAAM,IAAI,CAAC,OAAO,CACdG,oBACA;YAAEH;QAAO,GACT;IAER;IAEA,MAAc,QACVI,UAAkB,EAClBC,KAAa,EACbC,cAAsB,EACT;QACb,IAAI;YACA,MAAMC,SAAS,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAS;gBAAEH;gBAAYC;YAAM;YACpE,IAAIE,OAAO,MAAM,IACb,IAAI,CAAC,MAAM,CAAC,KAAK,CACb;gBAAE,OAAOA,OAAO,KAAK;gBAAE,UAAUF,MAAM,MAAM,CAAC,EAAE;YAAC,GACjDC;QAGZ,EAAE,OAAOE,OAAO;YACZ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBAAEA;gBAAO,UAAUH,MAAM,MAAM,CAAC,EAAE;YAAC,GAAGC;QAC5D;IACJ;AACJ;AAEO,MAAMG,wBAAwBC,kBAAkB,oBAAoB,CAAC;IACxE,gBAAgBd;IAChB,cAAc;QAACe;QAAiBC;QAAaC;KAAO;AACxD"}
1
+ {"version":3,"file":"flpTaskCatalog/TaskFolderCatalogSync.js","sources":["../../src/flpTaskCatalog/TaskFolderCatalogSync.ts"],"sourcesContent":["import { TaskService } from \"@webiny/api-core/features/task/TaskService/index.js\";\nimport { Logger } from \"@webiny/api-core/features/logger/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/abstractions.js\";\nimport { FolderCatalogSync } from \"~/features/flp/FolderCatalogSync/abstractions.js\";\nimport type { Folder } from \"~/folder/folder.types.js\";\nimport type { ICreateFlpTaskInput, IDeleteFlpTaskInput, IUpdateFlpTaskInput } from \"~/types.js\";\nimport { CREATE_FLP_TASK_ID, DELETE_FLP_TASK_ID, UPDATE_FLP_TASK_ID } from \"~/flp/tasks/index.js\";\n\n/**\n * Keeps the FLP catalog in step by triggering the FLP tasks.\n *\n * Folder reads report permissions from the FLP records, which the tasks write later. So the create\n * and update tasks, not this class, tell the admin about the change, and they need to know whom to\n * tell. A change rewrites the folder's record and every descendant's.\n *\n * The folder change is already saved, so it stands even when a task cannot be triggered. The logged\n * error is then the only trace of why the catalog is behind.\n */\nclass TaskFolderCatalogSyncImpl implements FolderCatalogSync.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private tasks: TaskService.Interface,\n private logger: Logger.Interface\n ) {}\n\n async folderCreated(folder: Folder): Promise<void> {\n await this.trigger<ICreateFlpTaskInput>(\n CREATE_FLP_TASK_ID,\n { folder, notifyIdentityId: this.getNotifyIdentityId() },\n \"Could not trigger the task that creates the folder's FLP record.\"\n );\n }\n\n async folderUpdated({ folder }: FolderCatalogSync.UpdatedParams): Promise<void> {\n await this.trigger<IUpdateFlpTaskInput>(\n UPDATE_FLP_TASK_ID,\n { folder, notifyIdentityId: this.getNotifyIdentityId() },\n \"Could not trigger the task that updates the FLP records of the folder and its subtree.\"\n );\n }\n\n async folderDeleted(folder: Folder): Promise<void> {\n await this.trigger<IDeleteFlpTaskInput>(\n DELETE_FLP_TASK_ID,\n { folder },\n \"Could not trigger the task that deletes the folder's FLP record.\"\n );\n }\n\n // Nobody to tell when no one is signed in, as in some system calls.\n private getNotifyIdentityId(): string | undefined {\n const identity = this.identityContext.getIdentity();\n if (identity.isAnonymous()) {\n return undefined;\n }\n return identity.id;\n }\n\n private async trigger<TInput extends { folder: Folder }>(\n definition: string,\n input: TInput,\n failureMessage: string\n ): Promise<void> {\n try {\n const result = await this.tasks.trigger<TInput>({ definition, input });\n if (result.isFail()) {\n this.logger.error(\n { error: result.error, folderId: input.folder.id },\n failureMessage\n );\n }\n } catch (error) {\n this.logger.error({ error, folderId: input.folder.id }, failureMessage);\n }\n }\n}\n\nexport const TaskFolderCatalogSync = FolderCatalogSync.createImplementation({\n implementation: TaskFolderCatalogSyncImpl,\n dependencies: [IdentityContext, TaskService, Logger]\n});\n"],"names":["TaskFolderCatalogSyncImpl","identityContext","tasks","logger","folder","CREATE_FLP_TASK_ID","UPDATE_FLP_TASK_ID","DELETE_FLP_TASK_ID","identity","definition","input","failureMessage","result","error","TaskFolderCatalogSync","FolderCatalogSync","IdentityContext","TaskService","Logger"],"mappings":";;;;;AAkBA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,KAA4B,EAC5BC,MAAwB,CAClC;aAHUF,eAAe,GAAfA;aACAC,KAAK,GAALA;aACAC,MAAM,GAANA;IACT;IAEH,MAAM,cAAcC,MAAc,EAAiB;QAC/C,MAAM,IAAI,CAAC,OAAO,CACdC,oBACA;YAAED;YAAQ,kBAAkB,IAAI,CAAC,mBAAmB;QAAG,GACvD;IAER;IAEA,MAAM,cAAc,EAAEA,MAAM,EAAmC,EAAiB;QAC5E,MAAM,IAAI,CAAC,OAAO,CACdE,oBACA;YAAEF;YAAQ,kBAAkB,IAAI,CAAC,mBAAmB;QAAG,GACvD;IAER;IAEA,MAAM,cAAcA,MAAc,EAAiB;QAC/C,MAAM,IAAI,CAAC,OAAO,CACdG,oBACA;YAAEH;QAAO,GACT;IAER;IAGQ,sBAA0C;QAC9C,MAAMI,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QACjD,IAAIA,SAAS,WAAW,IACpB;QAEJ,OAAOA,SAAS,EAAE;IACtB;IAEA,MAAc,QACVC,UAAkB,EAClBC,KAAa,EACbC,cAAsB,EACT;QACb,IAAI;YACA,MAAMC,SAAS,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAS;gBAAEH;gBAAYC;YAAM;YACpE,IAAIE,OAAO,MAAM,IACb,IAAI,CAAC,MAAM,CAAC,KAAK,CACb;gBAAE,OAAOA,OAAO,KAAK;gBAAE,UAAUF,MAAM,MAAM,CAAC,EAAE;YAAC,GACjDC;QAGZ,EAAE,OAAOE,OAAO;YACZ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBAAEA;gBAAO,UAAUH,MAAM,MAAM,CAAC,EAAE;YAAC,GAAGC;QAC5D;IACJ;AACJ;AAEO,MAAMG,wBAAwBC,kBAAkB,oBAAoB,CAAC;IACxE,gBAAgBf;IAChB,cAAc;QAACgB;QAAiBC;QAAaC;KAAO;AACxD"}
@@ -1,11 +1,11 @@
1
1
  import { TaskDefinition, TaskHandler } from "@webiny/api-core/features/task/TaskDefinition/index.js";
2
2
  import { type ICreateFlpTaskInput } from "../../types.js";
3
3
  import { CreateFlpUseCase } from "../../features/flp/CreateFlp/abstractions.js";
4
- import { NotifyFolderChangeUseCase } from "../../features/folder/NotifyFolderChange/abstractions.js";
4
+ import { NotifyRecordChangeUseCase } from "@webiny/api-core/features/websockets/index.js";
5
5
  declare class CreateFlpTaskHandlerImpl implements TaskHandler.Interface<ICreateFlpTaskInput> {
6
6
  private createFlp;
7
- private notifyFolderChange;
8
- constructor(createFlp: CreateFlpUseCase.Interface, notifyFolderChange: NotifyFolderChangeUseCase.Interface);
7
+ private notifyRecordChange;
8
+ constructor(createFlp: CreateFlpUseCase.Interface, notifyRecordChange: NotifyRecordChangeUseCase.Interface);
9
9
  run({ input, controller }: TaskHandler.RunParams<ICreateFlpTaskInput>): Promise<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskResultAborted | import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskResultError | TaskDefinition.ResultContinue<ICreateFlpTaskInput> | TaskDefinition.ResultDone<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
10
10
  }
11
11
  declare class CreateFlpTaskImpl implements TaskDefinition.Interface {
@@ -1,18 +1,20 @@
1
1
  import { TaskDefinition, TaskHandler } from "@webiny/api-core/features/task/TaskDefinition/index.js";
2
2
  import { CREATE_FLP_TASK_ID } from "../../flp/tasks/index.js";
3
3
  import { CreateFlpUseCase } from "../../features/flp/CreateFlp/abstractions.js";
4
- import { NotifyFolderChangeUseCase } from "../../features/folder/NotifyFolderChange/abstractions.js";
4
+ import { NotifyRecordChangeUseCase } from "@webiny/api-core/features/websockets/index.js";
5
+ import { FOLDER_RECORD_TYPE } from "../../features/folder/NotifyFolderChange/recordType.js";
5
6
  class CreateFlpTaskHandlerImpl {
6
- constructor(createFlp, notifyFolderChange){
7
+ constructor(createFlp, notifyRecordChange){
7
8
  this.createFlp = createFlp;
8
- this.notifyFolderChange = notifyFolderChange;
9
+ this.notifyRecordChange = notifyRecordChange;
9
10
  }
10
11
  async run({ input, controller }) {
11
12
  try {
12
13
  if (controller.runtime.isAborted()) return controller.response.aborted();
13
14
  if (controller.runtime.isCloseToTimeout()) return controller.response.continue(input);
14
15
  await this.createFlp.execute(input.folder);
15
- if (input.notifyIdentityId) await this.notifyFolderChange.execute({
16
+ if (input.notifyIdentityId) await this.notifyRecordChange.execute({
17
+ type: FOLDER_RECORD_TYPE,
16
18
  id: input.folder.id,
17
19
  change: "created",
18
20
  identityId: input.notifyIdentityId
@@ -27,7 +29,7 @@ const CreateFlpTaskHandler = TaskHandler.createImplementation({
27
29
  implementation: CreateFlpTaskHandlerImpl,
28
30
  dependencies: [
29
31
  CreateFlpUseCase,
30
- NotifyFolderChangeUseCase
32
+ NotifyRecordChangeUseCase
31
33
  ]
32
34
  });
33
35
  class CreateFlpTaskImpl {
@@ -1 +1 @@
1
- {"version":3,"file":"flpTaskCatalog/tasks/createFlp.task.js","sources":["../../../src/flpTaskCatalog/tasks/createFlp.task.ts"],"sourcesContent":["import {\n TaskDefinition,\n TaskHandler\n} from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { CREATE_FLP_TASK_ID } from \"~/flp/tasks/index.js\";\nimport { type ICreateFlpTaskInput } from \"~/types.js\";\nimport { CreateFlpUseCase } from \"~/features/flp/CreateFlp/abstractions.js\";\nimport { NotifyFolderChangeUseCase } from \"~/features/folder/NotifyFolderChange/abstractions.js\";\n\nclass CreateFlpTaskHandlerImpl implements TaskHandler.Interface<ICreateFlpTaskInput> {\n constructor(\n private createFlp: CreateFlpUseCase.Interface,\n private notifyFolderChange: NotifyFolderChangeUseCase.Interface\n ) {}\n\n async run({ input, controller }: TaskHandler.RunParams<ICreateFlpTaskInput>) {\n try {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n }\n\n if (controller.runtime.isCloseToTimeout()) {\n return controller.response.continue(input);\n }\n\n await this.createFlp.execute(input.folder);\n\n // Only now can the admin read the folder back with its permissions.\n if (input.notifyIdentityId) {\n await this.notifyFolderChange.execute({\n id: input.folder.id,\n change: \"created\",\n identityId: input.notifyIdentityId\n });\n }\n\n return controller.response.done(\"Task done: FLP record created.\");\n } catch (error) {\n return controller.response.error(error);\n }\n }\n}\n\nconst CreateFlpTaskHandler = TaskHandler.createImplementation({\n implementation: CreateFlpTaskHandlerImpl,\n dependencies: [CreateFlpUseCase, NotifyFolderChangeUseCase]\n});\n\nclass CreateFlpTaskImpl implements TaskDefinition.Interface {\n public readonly id = CREATE_FLP_TASK_ID;\n public readonly title = \"ACO - Create FLP record\";\n public readonly description =\n \"Synchronizes the FLP catalog by creating the FLP record based on the provided folder.\";\n public readonly databaseLogs = false;\n public readonly isPrivate = true;\n public readonly selfCleanup = [\"onSuccess\" as const, \"onAbort\" as const];\n\n handler = CreateFlpTaskHandler;\n}\n\nexport const CreateFlpTask = TaskDefinition.createImplementation({\n implementation: CreateFlpTaskImpl,\n dependencies: []\n});\n"],"names":["CreateFlpTaskHandlerImpl","createFlp","notifyFolderChange","input","controller","error","CreateFlpTaskHandler","TaskHandler","CreateFlpUseCase","NotifyFolderChangeUseCase","CreateFlpTaskImpl","CREATE_FLP_TASK_ID","CreateFlpTask","TaskDefinition"],"mappings":";;;;AASA,MAAMA;IACF,YACYC,SAAqC,EACrCC,kBAAuD,CACjE;aAFUD,SAAS,GAATA;aACAC,kBAAkB,GAAlBA;IACT;IAEH,MAAM,IAAI,EAAEC,KAAK,EAAEC,UAAU,EAA8C,EAAE;QACzE,IAAI;YACA,IAAIA,WAAW,OAAO,CAAC,SAAS,IAC5B,OAAOA,WAAW,QAAQ,CAAC,OAAO;YAGtC,IAAIA,WAAW,OAAO,CAAC,gBAAgB,IACnC,OAAOA,WAAW,QAAQ,CAAC,QAAQ,CAACD;YAGxC,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACA,MAAM,MAAM;YAGzC,IAAIA,MAAM,gBAAgB,EACtB,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;gBAClC,IAAIA,MAAM,MAAM,CAAC,EAAE;gBACnB,QAAQ;gBACR,YAAYA,MAAM,gBAAgB;YACtC;YAGJ,OAAOC,WAAW,QAAQ,CAAC,IAAI,CAAC;QACpC,EAAE,OAAOC,OAAO;YACZ,OAAOD,WAAW,QAAQ,CAAC,KAAK,CAACC;QACrC;IACJ;AACJ;AAEA,MAAMC,uBAAuBC,YAAY,oBAAoB,CAAC;IAC1D,gBAAgBP;IAChB,cAAc;QAACQ;QAAkBC;KAA0B;AAC/D;AAEA,MAAMC;;aACc,EAAE,GAAGC;aACL,KAAK,GAAG;aACR,WAAW,GACvB;aACY,YAAY,GAAG;aACf,SAAS,GAAG;aACZ,WAAW,GAAG;YAAC;YAAsB;SAAmB;aAExE,OAAO,GAAGL;;AACd;AAEO,MAAMM,gBAAgBC,eAAe,oBAAoB,CAAC;IAC7D,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"flpTaskCatalog/tasks/createFlp.task.js","sources":["../../../src/flpTaskCatalog/tasks/createFlp.task.ts"],"sourcesContent":["import {\n TaskDefinition,\n TaskHandler\n} from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { CREATE_FLP_TASK_ID } from \"~/flp/tasks/index.js\";\nimport { type ICreateFlpTaskInput } from \"~/types.js\";\nimport { CreateFlpUseCase } from \"~/features/flp/CreateFlp/abstractions.js\";\nimport { NotifyRecordChangeUseCase } from \"@webiny/api-core/features/websockets/index.js\";\nimport { FOLDER_RECORD_TYPE } from \"~/features/folder/NotifyFolderChange/recordType.js\";\n\nclass CreateFlpTaskHandlerImpl implements TaskHandler.Interface<ICreateFlpTaskInput> {\n constructor(\n private createFlp: CreateFlpUseCase.Interface,\n private notifyRecordChange: NotifyRecordChangeUseCase.Interface\n ) {}\n\n async run({ input, controller }: TaskHandler.RunParams<ICreateFlpTaskInput>) {\n try {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n }\n\n if (controller.runtime.isCloseToTimeout()) {\n return controller.response.continue(input);\n }\n\n await this.createFlp.execute(input.folder);\n\n // Only now can the admin read the folder back with its permissions.\n if (input.notifyIdentityId) {\n await this.notifyRecordChange.execute({\n type: FOLDER_RECORD_TYPE,\n id: input.folder.id,\n change: \"created\",\n identityId: input.notifyIdentityId\n });\n }\n\n return controller.response.done(\"Task done: FLP record created.\");\n } catch (error) {\n return controller.response.error(error);\n }\n }\n}\n\nconst CreateFlpTaskHandler = TaskHandler.createImplementation({\n implementation: CreateFlpTaskHandlerImpl,\n dependencies: [CreateFlpUseCase, NotifyRecordChangeUseCase]\n});\n\nclass CreateFlpTaskImpl implements TaskDefinition.Interface {\n public readonly id = CREATE_FLP_TASK_ID;\n public readonly title = \"ACO - Create FLP record\";\n public readonly description =\n \"Synchronizes the FLP catalog by creating the FLP record based on the provided folder.\";\n public readonly databaseLogs = false;\n public readonly isPrivate = true;\n public readonly selfCleanup = [\"onSuccess\" as const, \"onAbort\" as const];\n\n handler = CreateFlpTaskHandler;\n}\n\nexport const CreateFlpTask = TaskDefinition.createImplementation({\n implementation: CreateFlpTaskImpl,\n dependencies: []\n});\n"],"names":["CreateFlpTaskHandlerImpl","createFlp","notifyRecordChange","input","controller","FOLDER_RECORD_TYPE","error","CreateFlpTaskHandler","TaskHandler","CreateFlpUseCase","NotifyRecordChangeUseCase","CreateFlpTaskImpl","CREATE_FLP_TASK_ID","CreateFlpTask","TaskDefinition"],"mappings":";;;;;AAUA,MAAMA;IACF,YACYC,SAAqC,EACrCC,kBAAuD,CACjE;aAFUD,SAAS,GAATA;aACAC,kBAAkB,GAAlBA;IACT;IAEH,MAAM,IAAI,EAAEC,KAAK,EAAEC,UAAU,EAA8C,EAAE;QACzE,IAAI;YACA,IAAIA,WAAW,OAAO,CAAC,SAAS,IAC5B,OAAOA,WAAW,QAAQ,CAAC,OAAO;YAGtC,IAAIA,WAAW,OAAO,CAAC,gBAAgB,IACnC,OAAOA,WAAW,QAAQ,CAAC,QAAQ,CAACD;YAGxC,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACA,MAAM,MAAM;YAGzC,IAAIA,MAAM,gBAAgB,EACtB,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;gBAClC,MAAME;gBACN,IAAIF,MAAM,MAAM,CAAC,EAAE;gBACnB,QAAQ;gBACR,YAAYA,MAAM,gBAAgB;YACtC;YAGJ,OAAOC,WAAW,QAAQ,CAAC,IAAI,CAAC;QACpC,EAAE,OAAOE,OAAO;YACZ,OAAOF,WAAW,QAAQ,CAAC,KAAK,CAACE;QACrC;IACJ;AACJ;AAEA,MAAMC,uBAAuBC,YAAY,oBAAoB,CAAC;IAC1D,gBAAgBR;IAChB,cAAc;QAACS;QAAkBC;KAA0B;AAC/D;AAEA,MAAMC;;aACc,EAAE,GAAGC;aACL,KAAK,GAAG;aACR,WAAW,GACvB;aACY,YAAY,GAAG;aACf,SAAS,GAAG;aACZ,WAAW,GAAG;YAAC;YAAsB;SAAmB;aAExE,OAAO,GAAGL;;AACd;AAEO,MAAMM,gBAAgBC,eAAe,oBAAoB,CAAC;IAC7D,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
@@ -1,11 +1,11 @@
1
1
  import { TaskDefinition, TaskHandler } from "@webiny/api-core/features/task/TaskDefinition/index.js";
2
2
  import { type IUpdateFlpTaskInput } from "../../types.js";
3
3
  import { UpdateFlpUseCase } from "../../features/flp/UpdateFlp/abstractions.js";
4
- import { NotifyFolderChangeUseCase } from "../../features/folder/NotifyFolderChange/abstractions.js";
4
+ import { NotifyRecordChangeUseCase } from "@webiny/api-core/features/websockets/index.js";
5
5
  declare class UpdateFlpTaskHandlerImpl implements TaskHandler.Interface<IUpdateFlpTaskInput> {
6
6
  private updateFlp;
7
- private notifyFolderChange;
8
- constructor(updateFlp: UpdateFlpUseCase.Interface, notifyFolderChange: NotifyFolderChangeUseCase.Interface);
7
+ private notifyRecordChange;
8
+ constructor(updateFlp: UpdateFlpUseCase.Interface, notifyRecordChange: NotifyRecordChangeUseCase.Interface);
9
9
  run({ input, controller }: TaskHandler.RunParams<IUpdateFlpTaskInput>): Promise<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskResultAborted | import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskResultError | TaskDefinition.ResultContinue<IUpdateFlpTaskInput> | TaskDefinition.ResultDone<import("@webiny/api-core/features/task/TaskDefinition/abstractions").ITaskOutput>>;
10
10
  }
11
11
  declare class UpdateFlpTaskImpl implements TaskDefinition.Interface {
@@ -1,11 +1,12 @@
1
1
  import { TaskDefinition, TaskHandler } from "@webiny/api-core/features/task/TaskDefinition/index.js";
2
2
  import { UPDATE_FLP_TASK_ID } from "../../flp/tasks/index.js";
3
3
  import { UpdateFlpUseCase } from "../../features/flp/UpdateFlp/abstractions.js";
4
- import { NotifyFolderChangeUseCase } from "../../features/folder/NotifyFolderChange/abstractions.js";
4
+ import { NotifyRecordChangeUseCase } from "@webiny/api-core/features/websockets/index.js";
5
+ import { FOLDER_RECORD_TYPE } from "../../features/folder/NotifyFolderChange/recordType.js";
5
6
  class UpdateFlpTaskHandlerImpl {
6
- constructor(updateFlp, notifyFolderChange){
7
+ constructor(updateFlp, notifyRecordChange){
7
8
  this.updateFlp = updateFlp;
8
- this.notifyFolderChange = notifyFolderChange;
9
+ this.notifyRecordChange = notifyRecordChange;
9
10
  }
10
11
  async run({ input, controller }) {
11
12
  try {
@@ -23,7 +24,8 @@ class UpdateFlpTaskHandlerImpl {
23
24
  }
24
25
  });
25
26
  if (continuation) return continuation;
26
- if (input.notifyIdentityId) await this.notifyFolderChange.execute({
27
+ if (input.notifyIdentityId) await this.notifyRecordChange.execute({
28
+ type: FOLDER_RECORD_TYPE,
27
29
  id: input.folder.id,
28
30
  change: "updated",
29
31
  identityId: input.notifyIdentityId
@@ -38,7 +40,7 @@ const UpdateFlpTaskHandler = TaskHandler.createImplementation({
38
40
  implementation: UpdateFlpTaskHandlerImpl,
39
41
  dependencies: [
40
42
  UpdateFlpUseCase,
41
- NotifyFolderChangeUseCase
43
+ NotifyRecordChangeUseCase
42
44
  ]
43
45
  });
44
46
  class UpdateFlpTaskImpl {
@@ -1 +1 @@
1
- {"version":3,"file":"flpTaskCatalog/tasks/updateFlp.task.js","sources":["../../../src/flpTaskCatalog/tasks/updateFlp.task.ts"],"sourcesContent":["import {\n TaskDefinition,\n TaskHandler\n} from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { UPDATE_FLP_TASK_ID } from \"~/flp/tasks/index.js\";\nimport { type IUpdateFlpTaskInput } from \"~/types.js\";\nimport { UpdateFlpUseCase } from \"~/features/flp/UpdateFlp/abstractions.js\";\nimport { NotifyFolderChangeUseCase } from \"~/features/folder/NotifyFolderChange/abstractions.js\";\n\nclass UpdateFlpTaskHandlerImpl implements TaskHandler.Interface<IUpdateFlpTaskInput> {\n public constructor(\n private updateFlp: UpdateFlpUseCase.Interface,\n private notifyFolderChange: NotifyFolderChangeUseCase.Interface\n ) {}\n\n async run({ input, controller }: TaskHandler.RunParams<IUpdateFlpTaskInput>) {\n try {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n }\n\n /*\n * `response.continue()` only builds the result; it does nothing until the task returns\n * it. Returning `done` regardless used to drop the continuation, leaving the rest of a\n * large subtree with its old permissions.\n */\n let continuation: ReturnType<typeof controller.response.continue> | undefined;\n\n await this.updateFlp.execute({\n folder: input.folder,\n completed: input.completed,\n isCloseToTimeout: controller.runtime.isCloseToTimeout,\n handleTimeout: completed => {\n continuation = controller.response.continue({ ...input, completed });\n }\n });\n\n if (continuation) {\n return continuation;\n }\n\n // Only the last run tells the admin: before it, part of the subtree is still stale.\n if (input.notifyIdentityId) {\n await this.notifyFolderChange.execute({\n id: input.folder.id,\n change: \"updated\",\n identityId: input.notifyIdentityId\n });\n }\n\n return controller.response.done(\"Task done: FLP record updated.\");\n } catch (error) {\n return controller.response.error(error);\n }\n }\n}\n\nconst UpdateFlpTaskHandler = TaskHandler.createImplementation({\n implementation: UpdateFlpTaskHandlerImpl,\n dependencies: [UpdateFlpUseCase, NotifyFolderChangeUseCase]\n});\n\nclass UpdateFlpTaskImpl implements TaskDefinition.Interface {\n public readonly id = UPDATE_FLP_TASK_ID;\n public readonly title = \"ACO - Update FLP record\";\n public readonly description =\n \"Synchronizes the FLP catalog by updating the FLP record and its descendants based on the provided folder.\";\n public readonly databaseLogs = false;\n public readonly isPrivate = true;\n public readonly selfCleanup = [\"onSuccess\" as const, \"onAbort\" as const];\n\n handler = UpdateFlpTaskHandler;\n}\n\nexport const UpdateFlpTask = TaskDefinition.createImplementation({\n implementation: UpdateFlpTaskImpl,\n dependencies: []\n});\n"],"names":["UpdateFlpTaskHandlerImpl","updateFlp","notifyFolderChange","input","controller","continuation","completed","error","UpdateFlpTaskHandler","TaskHandler","UpdateFlpUseCase","NotifyFolderChangeUseCase","UpdateFlpTaskImpl","UPDATE_FLP_TASK_ID","UpdateFlpTask","TaskDefinition"],"mappings":";;;;AASA,MAAMA;IACF,YACYC,SAAqC,EACrCC,kBAAuD,CACjE;aAFUD,SAAS,GAATA;aACAC,kBAAkB,GAAlBA;IACT;IAEH,MAAM,IAAI,EAAEC,KAAK,EAAEC,UAAU,EAA8C,EAAE;QACzE,IAAI;YACA,IAAIA,WAAW,OAAO,CAAC,SAAS,IAC5B,OAAOA,WAAW,QAAQ,CAAC,OAAO;YAQtC,IAAIC;YAEJ,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;gBACzB,QAAQF,MAAM,MAAM;gBACpB,WAAWA,MAAM,SAAS;gBAC1B,kBAAkBC,WAAW,OAAO,CAAC,gBAAgB;gBACrD,eAAeE,CAAAA;oBACXD,eAAeD,WAAW,QAAQ,CAAC,QAAQ,CAAC;wBAAE,GAAGD,KAAK;wBAAEG;oBAAU;gBACtE;YACJ;YAEA,IAAID,cACA,OAAOA;YAIX,IAAIF,MAAM,gBAAgB,EACtB,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;gBAClC,IAAIA,MAAM,MAAM,CAAC,EAAE;gBACnB,QAAQ;gBACR,YAAYA,MAAM,gBAAgB;YACtC;YAGJ,OAAOC,WAAW,QAAQ,CAAC,IAAI,CAAC;QACpC,EAAE,OAAOG,OAAO;YACZ,OAAOH,WAAW,QAAQ,CAAC,KAAK,CAACG;QACrC;IACJ;AACJ;AAEA,MAAMC,uBAAuBC,YAAY,oBAAoB,CAAC;IAC1D,gBAAgBT;IAChB,cAAc;QAACU;QAAkBC;KAA0B;AAC/D;AAEA,MAAMC;;aACc,EAAE,GAAGC;aACL,KAAK,GAAG;aACR,WAAW,GACvB;aACY,YAAY,GAAG;aACf,SAAS,GAAG;aACZ,WAAW,GAAG;YAAC;YAAsB;SAAmB;aAExE,OAAO,GAAGL;;AACd;AAEO,MAAMM,gBAAgBC,eAAe,oBAAoB,CAAC;IAC7D,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"flpTaskCatalog/tasks/updateFlp.task.js","sources":["../../../src/flpTaskCatalog/tasks/updateFlp.task.ts"],"sourcesContent":["import {\n TaskDefinition,\n TaskHandler\n} from \"@webiny/api-core/features/task/TaskDefinition/index.js\";\nimport { UPDATE_FLP_TASK_ID } from \"~/flp/tasks/index.js\";\nimport { type IUpdateFlpTaskInput } from \"~/types.js\";\nimport { UpdateFlpUseCase } from \"~/features/flp/UpdateFlp/abstractions.js\";\nimport { NotifyRecordChangeUseCase } from \"@webiny/api-core/features/websockets/index.js\";\nimport { FOLDER_RECORD_TYPE } from \"~/features/folder/NotifyFolderChange/recordType.js\";\n\nclass UpdateFlpTaskHandlerImpl implements TaskHandler.Interface<IUpdateFlpTaskInput> {\n public constructor(\n private updateFlp: UpdateFlpUseCase.Interface,\n private notifyRecordChange: NotifyRecordChangeUseCase.Interface\n ) {}\n\n async run({ input, controller }: TaskHandler.RunParams<IUpdateFlpTaskInput>) {\n try {\n if (controller.runtime.isAborted()) {\n return controller.response.aborted();\n }\n\n /*\n * `response.continue()` only builds the result; it does nothing until the task returns\n * it. Returning `done` regardless used to drop the continuation, leaving the rest of a\n * large subtree with its old permissions.\n */\n let continuation: ReturnType<typeof controller.response.continue> | undefined;\n\n await this.updateFlp.execute({\n folder: input.folder,\n completed: input.completed,\n isCloseToTimeout: controller.runtime.isCloseToTimeout,\n handleTimeout: completed => {\n continuation = controller.response.continue({ ...input, completed });\n }\n });\n\n if (continuation) {\n return continuation;\n }\n\n // Only the last run tells the admin: before it, part of the subtree is still stale.\n if (input.notifyIdentityId) {\n await this.notifyRecordChange.execute({\n type: FOLDER_RECORD_TYPE,\n id: input.folder.id,\n change: \"updated\",\n identityId: input.notifyIdentityId\n });\n }\n\n return controller.response.done(\"Task done: FLP record updated.\");\n } catch (error) {\n return controller.response.error(error);\n }\n }\n}\n\nconst UpdateFlpTaskHandler = TaskHandler.createImplementation({\n implementation: UpdateFlpTaskHandlerImpl,\n dependencies: [UpdateFlpUseCase, NotifyRecordChangeUseCase]\n});\n\nclass UpdateFlpTaskImpl implements TaskDefinition.Interface {\n public readonly id = UPDATE_FLP_TASK_ID;\n public readonly title = \"ACO - Update FLP record\";\n public readonly description =\n \"Synchronizes the FLP catalog by updating the FLP record and its descendants based on the provided folder.\";\n public readonly databaseLogs = false;\n public readonly isPrivate = true;\n public readonly selfCleanup = [\"onSuccess\" as const, \"onAbort\" as const];\n\n handler = UpdateFlpTaskHandler;\n}\n\nexport const UpdateFlpTask = TaskDefinition.createImplementation({\n implementation: UpdateFlpTaskImpl,\n dependencies: []\n});\n"],"names":["UpdateFlpTaskHandlerImpl","updateFlp","notifyRecordChange","input","controller","continuation","completed","FOLDER_RECORD_TYPE","error","UpdateFlpTaskHandler","TaskHandler","UpdateFlpUseCase","NotifyRecordChangeUseCase","UpdateFlpTaskImpl","UPDATE_FLP_TASK_ID","UpdateFlpTask","TaskDefinition"],"mappings":";;;;;AAUA,MAAMA;IACF,YACYC,SAAqC,EACrCC,kBAAuD,CACjE;aAFUD,SAAS,GAATA;aACAC,kBAAkB,GAAlBA;IACT;IAEH,MAAM,IAAI,EAAEC,KAAK,EAAEC,UAAU,EAA8C,EAAE;QACzE,IAAI;YACA,IAAIA,WAAW,OAAO,CAAC,SAAS,IAC5B,OAAOA,WAAW,QAAQ,CAAC,OAAO;YAQtC,IAAIC;YAEJ,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;gBACzB,QAAQF,MAAM,MAAM;gBACpB,WAAWA,MAAM,SAAS;gBAC1B,kBAAkBC,WAAW,OAAO,CAAC,gBAAgB;gBACrD,eAAeE,CAAAA;oBACXD,eAAeD,WAAW,QAAQ,CAAC,QAAQ,CAAC;wBAAE,GAAGD,KAAK;wBAAEG;oBAAU;gBACtE;YACJ;YAEA,IAAID,cACA,OAAOA;YAIX,IAAIF,MAAM,gBAAgB,EACtB,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC;gBAClC,MAAMI;gBACN,IAAIJ,MAAM,MAAM,CAAC,EAAE;gBACnB,QAAQ;gBACR,YAAYA,MAAM,gBAAgB;YACtC;YAGJ,OAAOC,WAAW,QAAQ,CAAC,IAAI,CAAC;QACpC,EAAE,OAAOI,OAAO;YACZ,OAAOJ,WAAW,QAAQ,CAAC,KAAK,CAACI;QACrC;IACJ;AACJ;AAEA,MAAMC,uBAAuBC,YAAY,oBAAoB,CAAC;IAC1D,gBAAgBV;IAChB,cAAc;QAACW;QAAkBC;KAA0B;AAC/D;AAEA,MAAMC;;aACc,EAAE,GAAGC;aACL,KAAK,GAAG;aACR,WAAW,GACvB;aACY,YAAY,GAAG;aACf,SAAS,GAAG;aACZ,WAAW,GAAG;YAAC;YAAsB;SAAmB;aAExE,OAAO,GAAGL;;AACd;AAEO,MAAMM,gBAAgBC,eAAe,oBAAoB,CAAC;IAC7D,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-aco",
3
- "version": "6.6.0-alpha.11",
3
+ "version": "6.6.0-alpha.12",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "aco:base"
@@ -21,28 +21,28 @@
21
21
  ".": "./index.js"
22
22
  },
23
23
  "dependencies": {
24
- "@webiny/api-core": "6.6.0-alpha.11",
25
- "@webiny/api-graphql": "6.6.0-alpha.11",
26
- "@webiny/api-headless-cms": "6.6.0-alpha.11",
24
+ "@webiny/api-core": "6.6.0-alpha.12",
25
+ "@webiny/api-graphql": "6.6.0-alpha.12",
26
+ "@webiny/api-headless-cms": "6.6.0-alpha.12",
27
27
  "@webiny/di": "2.0.0",
28
- "@webiny/error": "6.6.0-alpha.11",
29
- "@webiny/event-handler-core": "6.6.0-alpha.11",
30
- "@webiny/feature": "6.6.0-alpha.11",
31
- "@webiny/handler": "6.6.0-alpha.11",
32
- "@webiny/shared-aco": "6.6.0-alpha.11",
33
- "@webiny/utils": "6.6.0-alpha.11",
34
- "@webiny/validation": "6.6.0-alpha.11",
28
+ "@webiny/error": "6.6.0-alpha.12",
29
+ "@webiny/event-handler-core": "6.6.0-alpha.12",
30
+ "@webiny/feature": "6.6.0-alpha.12",
31
+ "@webiny/handler": "6.6.0-alpha.12",
32
+ "@webiny/shared-aco": "6.6.0-alpha.12",
33
+ "@webiny/utils": "6.6.0-alpha.12",
34
+ "@webiny/validation": "6.6.0-alpha.12",
35
35
  "lodash": "4.18.1",
36
36
  "zod": "4.6.7"
37
37
  },
38
38
  "devDependencies": {
39
- "@webiny/api": "6.6.0-alpha.11",
40
- "@webiny/api-core-testing": "6.6.0-alpha.11",
41
- "@webiny/api-file-manager": "6.6.0-alpha.11",
42
- "@webiny/api-headless-cms-testing": "6.6.0-alpha.11",
43
- "@webiny/build-tools": "6.6.0-alpha.11",
44
- "@webiny/plugins": "6.6.0-alpha.11",
45
- "@webiny/wcp": "6.6.0-alpha.11",
39
+ "@webiny/api": "6.6.0-alpha.12",
40
+ "@webiny/api-core-testing": "6.6.0-alpha.12",
41
+ "@webiny/api-file-manager": "6.6.0-alpha.12",
42
+ "@webiny/api-headless-cms-testing": "6.6.0-alpha.12",
43
+ "@webiny/build-tools": "6.6.0-alpha.12",
44
+ "@webiny/plugins": "6.6.0-alpha.12",
45
+ "@webiny/wcp": "6.6.0-alpha.12",
46
46
  "graphql": "16.14.2",
47
47
  "rimraf": "6.1.3",
48
48
  "typescript": "7.0.2",