@webiny/api-core 0.0.0-unstable.33e4fd9647 → 0.0.0-unstable.3fddf667ea

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/ApiCoreFeature.js +5 -2
  2. package/ApiCoreFeature.js.map +1 -1
  3. package/exports/api.d.ts +1 -0
  4. package/exports/api.js +1 -0
  5. package/features/ai/AiSdkTools.d.ts +1 -1
  6. package/features/ai/AiSdkTools.js +3 -2
  7. package/features/ai/AiSdkTools.js.map +1 -1
  8. package/features/ai/abstractions.d.ts +9 -1
  9. package/features/ai/abstractions.js.map +1 -1
  10. package/features/ai/index.d.ts +1 -0
  11. package/features/ai/index.js +1 -0
  12. package/features/ai/isReadOnlyTool.d.ts +9 -0
  13. package/features/ai/isReadOnlyTool.js +4 -0
  14. package/features/ai/isReadOnlyTool.js.map +1 -0
  15. package/features/cdnCache/NullCdnCache.d.ts +8 -0
  16. package/features/cdnCache/NullCdnCache.js +11 -0
  17. package/features/cdnCache/NullCdnCache.js.map +1 -0
  18. package/features/cdnCache/abstractions.d.ts +20 -0
  19. package/features/cdnCache/abstractions.js +5 -0
  20. package/features/cdnCache/abstractions.js.map +1 -0
  21. package/features/cdnCache/feature.d.ts +8 -0
  22. package/features/cdnCache/feature.js +11 -0
  23. package/features/cdnCache/feature.js.map +1 -0
  24. package/features/cdnCache/index.d.ts +2 -0
  25. package/features/cdnCache/index.js +2 -0
  26. package/features/debugger/DebuggerRouteDecorator.d.ts +3 -3
  27. package/features/debugger/DebuggerRouteDecorator.js +5 -10
  28. package/features/debugger/DebuggerRouteDecorator.js.map +1 -1
  29. package/features/debugger/__tests__/serialize.test.js.map +1 -1
  30. package/features/encryption/BuildParamsEncryptionConfig.d.ts +13 -0
  31. package/features/encryption/BuildParamsEncryptionConfig.js +19 -0
  32. package/features/encryption/BuildParamsEncryptionConfig.js.map +1 -0
  33. package/features/encryption/EncryptionService.d.ts +2 -2
  34. package/features/encryption/EncryptionService.js +9 -14
  35. package/features/encryption/EncryptionService.js.map +1 -1
  36. package/features/encryption/abstractions.d.ts +15 -0
  37. package/features/encryption/abstractions.js +2 -1
  38. package/features/encryption/abstractions.js.map +1 -1
  39. package/features/encryption/feature.js +2 -0
  40. package/features/encryption/feature.js.map +1 -1
  41. package/features/encryption/index.d.ts +2 -0
  42. package/features/encryption/index.js +2 -1
  43. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +0 -1
  44. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -1
  45. package/features/hashing/BuildParamsHashingConfig.d.ts +11 -0
  46. package/features/hashing/BuildParamsHashingConfig.js +18 -0
  47. package/features/hashing/BuildParamsHashingConfig.js.map +1 -0
  48. package/features/hashing/ScryptHasher.d.ts +2 -2
  49. package/features/hashing/ScryptHasher.js +6 -8
  50. package/features/hashing/ScryptHasher.js.map +1 -1
  51. package/features/hashing/abstractions.d.ts +15 -0
  52. package/features/hashing/abstractions.js +2 -1
  53. package/features/hashing/abstractions.js.map +1 -1
  54. package/features/hashing/feature.js +2 -0
  55. package/features/hashing/feature.js.map +1 -1
  56. package/features/hashing/index.d.ts +1 -0
  57. package/features/hashing/index.js +1 -1
  58. package/features/logger/NullLogger.d.ts +10 -0
  59. package/features/logger/NullLogger.js +12 -0
  60. package/features/logger/NullLogger.js.map +1 -0
  61. package/features/logger/index.d.ts +1 -0
  62. package/features/logger/index.js +1 -0
  63. package/features/requestStorage/abstractions.d.ts +23 -0
  64. package/features/requestStorage/abstractions.js +5 -0
  65. package/features/requestStorage/abstractions.js.map +1 -0
  66. package/features/requestStorage/index.d.ts +1 -0
  67. package/features/requestStorage/index.js +1 -0
  68. package/features/security/IdentityContext/IdentityContext.d.ts +6 -2
  69. package/features/security/IdentityContext/IdentityContext.js +24 -7
  70. package/features/security/IdentityContext/IdentityContext.js.map +1 -1
  71. package/features/security/IdentityContext/abstractions.d.ts +6 -1
  72. package/features/security/IdentityContext/abstractions.js.map +1 -1
  73. package/features/security/SecurityFeature.js +2 -0
  74. package/features/security/SecurityFeature.js.map +1 -1
  75. package/features/security/ai/CreateRoleTool.d.ts +54 -0
  76. package/features/security/ai/CreateRoleTool.js +71 -0
  77. package/features/security/ai/CreateRoleTool.js.map +1 -0
  78. package/features/security/ai/CreateTeamTool.d.ts +49 -0
  79. package/features/security/ai/CreateTeamTool.js +56 -0
  80. package/features/security/ai/CreateTeamTool.js.map +1 -0
  81. package/features/security/ai/DeleteRoleTool.d.ts +52 -0
  82. package/features/security/ai/DeleteRoleTool.js +79 -0
  83. package/features/security/ai/DeleteRoleTool.js.map +1 -0
  84. package/features/security/ai/DeleteTeamTool.d.ts +47 -0
  85. package/features/security/ai/DeleteTeamTool.js +56 -0
  86. package/features/security/ai/DeleteTeamTool.js.map +1 -0
  87. package/features/security/ai/ListRolesTool.d.ts +40 -0
  88. package/features/security/ai/ListRolesTool.js +48 -0
  89. package/features/security/ai/ListRolesTool.js.map +1 -0
  90. package/features/security/ai/ListTeamsTool.d.ts +42 -0
  91. package/features/security/ai/ListTeamsTool.js +49 -0
  92. package/features/security/ai/ListTeamsTool.js.map +1 -0
  93. package/features/security/ai/UpdateRoleTool.d.ts +46 -0
  94. package/features/security/ai/UpdateRoleTool.js +53 -0
  95. package/features/security/ai/UpdateRoleTool.js.map +1 -0
  96. package/features/security/ai/UpdateTeamTool.d.ts +53 -0
  97. package/features/security/ai/UpdateTeamTool.js +56 -0
  98. package/features/security/ai/UpdateTeamTool.js.map +1 -0
  99. package/features/security/ai/feature.d.ts +10 -0
  100. package/features/security/ai/feature.js +25 -0
  101. package/features/security/ai/feature.js.map +1 -0
  102. package/features/security/ai/index.d.ts +9 -0
  103. package/features/security/ai/index.js +9 -0
  104. package/features/security/apiKeys/ApiKeyAuthorizer.js +1 -1
  105. package/features/security/apiKeys/ApiKeyAuthorizer.js.map +1 -1
  106. package/features/security/authorization/AuthorizationContext/AuthorizationContext.d.ts +13 -3
  107. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js +35 -22
  108. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js.map +1 -1
  109. package/features/security/authorization/AuthorizationContext/abstractions.d.ts +2 -0
  110. package/features/security/authorization/AuthorizationContext/abstractions.js.map +1 -1
  111. package/features/security/authorization/AuthorizationContext/feature.js +6 -1
  112. package/features/security/authorization/AuthorizationContext/feature.js.map +1 -1
  113. package/features/security/roles/NotifyRoleChange/NotifyOnRoleCreatedHandler.d.ts +11 -0
  114. package/features/security/roles/NotifyRoleChange/NotifyOnRoleCreatedHandler.js +24 -0
  115. package/features/security/roles/NotifyRoleChange/NotifyOnRoleCreatedHandler.js.map +1 -0
  116. package/features/security/roles/NotifyRoleChange/NotifyOnRoleDeletedHandler.d.ts +11 -0
  117. package/features/security/roles/NotifyRoleChange/NotifyOnRoleDeletedHandler.js +24 -0
  118. package/features/security/roles/NotifyRoleChange/NotifyOnRoleDeletedHandler.js.map +1 -0
  119. package/features/security/roles/NotifyRoleChange/NotifyOnRoleUpdatedHandler.d.ts +11 -0
  120. package/features/security/roles/NotifyRoleChange/NotifyOnRoleUpdatedHandler.js +24 -0
  121. package/features/security/roles/NotifyRoleChange/NotifyOnRoleUpdatedHandler.js.map +1 -0
  122. package/features/security/roles/NotifyRoleChange/feature.d.ts +5 -0
  123. package/features/security/roles/NotifyRoleChange/feature.js +15 -0
  124. package/features/security/roles/NotifyRoleChange/feature.js.map +1 -0
  125. package/features/security/roles/NotifyRoleChange/index.d.ts +2 -0
  126. package/features/security/roles/NotifyRoleChange/index.js +2 -0
  127. package/features/security/roles/NotifyRoleChange/recordType.d.ts +5 -0
  128. package/features/security/roles/NotifyRoleChange/recordType.js +4 -0
  129. package/features/security/roles/NotifyRoleChange/recordType.js.map +1 -0
  130. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +2 -1
  131. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  132. package/features/security/roles/feature.js +2 -0
  133. package/features/security/roles/feature.js.map +1 -1
  134. package/features/security/shared/definedOnly.d.ts +1 -0
  135. package/features/security/shared/definedOnly.js +8 -0
  136. package/features/security/shared/definedOnly.js.map +1 -0
  137. package/features/security/shared/index.d.ts +1 -0
  138. package/features/security/shared/index.js +1 -0
  139. package/features/security/teams/NotifyTeamChange/NotifyOnTeamChangeHandlers.d.ts +29 -0
  140. package/features/security/teams/NotifyTeamChange/NotifyOnTeamChangeHandlers.js +62 -0
  141. package/features/security/teams/NotifyTeamChange/NotifyOnTeamChangeHandlers.js.map +1 -0
  142. package/features/security/teams/NotifyTeamChange/feature.d.ts +5 -0
  143. package/features/security/teams/NotifyTeamChange/feature.js +13 -0
  144. package/features/security/teams/NotifyTeamChange/feature.js.map +1 -0
  145. package/features/security/teams/NotifyTeamChange/index.d.ts +2 -0
  146. package/features/security/teams/NotifyTeamChange/index.js +2 -0
  147. package/features/security/teams/NotifyTeamChange/recordType.d.ts +5 -0
  148. package/features/security/teams/NotifyTeamChange/recordType.js +4 -0
  149. package/features/security/teams/NotifyTeamChange/recordType.js.map +1 -0
  150. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +2 -1
  151. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  152. package/features/security/teams/feature.js +2 -0
  153. package/features/security/teams/feature.js.map +1 -1
  154. package/features/task/TaskService/abstractions.d.ts +7 -0
  155. package/features/task/TaskService/abstractions.js.map +1 -1
  156. package/features/tenancy/TenantContext/TenantContext.d.ts +5 -2
  157. package/features/tenancy/TenantContext/TenantContext.js +31 -28
  158. package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
  159. package/features/users/AdminUsersFeature.js +4 -0
  160. package/features/users/AdminUsersFeature.js.map +1 -1
  161. package/features/users/CreateUser/CreateUserUseCase.js +1 -1
  162. package/features/users/CreateUser/CreateUserUseCase.js.map +1 -1
  163. package/features/users/NotifyUserChange/NotifyOnUserChangeHandlers.d.ts +29 -0
  164. package/features/users/NotifyUserChange/NotifyOnUserChangeHandlers.js +62 -0
  165. package/features/users/NotifyUserChange/NotifyOnUserChangeHandlers.js.map +1 -0
  166. package/features/users/NotifyUserChange/feature.d.ts +5 -0
  167. package/features/users/NotifyUserChange/feature.js +13 -0
  168. package/features/users/NotifyUserChange/feature.js.map +1 -0
  169. package/features/users/NotifyUserChange/index.d.ts +2 -0
  170. package/features/users/NotifyUserChange/index.js +2 -0
  171. package/features/users/NotifyUserChange/recordType.d.ts +5 -0
  172. package/features/users/NotifyUserChange/recordType.js +4 -0
  173. package/features/users/NotifyUserChange/recordType.js.map +1 -0
  174. package/features/users/ai/ListUsersTool.d.ts +39 -0
  175. package/features/users/ai/ListUsersTool.js +46 -0
  176. package/features/users/ai/ListUsersTool.js.map +1 -0
  177. package/features/users/ai/UpdateUserAccessTool.d.ts +59 -0
  178. package/features/users/ai/UpdateUserAccessTool.js +101 -0
  179. package/features/users/ai/UpdateUserAccessTool.js.map +1 -0
  180. package/features/users/ai/feature.d.ts +11 -0
  181. package/features/users/ai/feature.js +13 -0
  182. package/features/users/ai/feature.js.map +1 -0
  183. package/features/users/ai/index.d.ts +3 -0
  184. package/features/users/ai/index.js +3 -0
  185. package/features/users/shared/loaders.js.map +1 -1
  186. package/features/users/shared/types.d.ts +9 -7
  187. package/features/wcp/WcpContext/WcpContext.d.ts +0 -1
  188. package/features/wcp/WcpContext/WcpContext.js +0 -3
  189. package/features/wcp/WcpContext/WcpContext.js.map +1 -1
  190. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +0 -1
  191. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +0 -4
  192. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  193. package/features/websockets/NotifyRecordChange/NotifyRecordChangeUseCase.d.ts +12 -0
  194. package/features/websockets/NotifyRecordChange/NotifyRecordChangeUseCase.js +38 -0
  195. package/features/websockets/NotifyRecordChange/NotifyRecordChangeUseCase.js.map +1 -0
  196. package/features/websockets/NotifyRecordChange/abstractions.d.ts +39 -0
  197. package/features/websockets/NotifyRecordChange/abstractions.js +6 -0
  198. package/features/websockets/NotifyRecordChange/abstractions.js.map +1 -0
  199. package/features/websockets/NotifyRecordChange/feature.d.ts +5 -0
  200. package/features/websockets/NotifyRecordChange/feature.js +11 -0
  201. package/features/websockets/NotifyRecordChange/feature.js.map +1 -0
  202. package/features/websockets/NotifyRecordChange/index.d.ts +2 -0
  203. package/features/websockets/NotifyRecordChange/index.js +2 -0
  204. package/features/websockets/SendToIdentity/NullSendToIdentityUseCase.d.ts +20 -0
  205. package/features/websockets/SendToIdentity/NullSendToIdentityUseCase.js +24 -0
  206. package/features/websockets/SendToIdentity/NullSendToIdentityUseCase.js.map +1 -0
  207. package/features/websockets/SendToIdentity/abstractions.d.ts +19 -0
  208. package/features/websockets/SendToIdentity/abstractions.js +5 -0
  209. package/features/websockets/SendToIdentity/abstractions.js.map +1 -0
  210. package/features/websockets/WebsocketServiceError.d.ts +7 -0
  211. package/features/websockets/WebsocketServiceError.js +14 -0
  212. package/features/websockets/WebsocketServiceError.js.map +1 -0
  213. package/features/websockets/index.d.ts +7 -0
  214. package/features/websockets/index.js +4 -0
  215. package/features/websockets/types.d.ts +15 -0
  216. package/features/websockets/types.js +0 -0
  217. package/index.d.ts +1 -0
  218. package/index.js +1 -0
  219. package/package.json +19 -21
  220. package/types/users.d.ts +2 -3
  221. package/features/logger/LoggerService.d.ts +0 -14
  222. package/features/logger/LoggerService.js +0 -48
  223. package/features/logger/LoggerService.js.map +0 -1
  224. package/features/logger/feature.d.ts +0 -4
  225. package/features/logger/feature.js +0 -11
  226. package/features/logger/feature.js.map +0 -1
@@ -0,0 +1,46 @@
1
+ import { z } from "zod";
2
+ import { AiSdkToolDefinition, AiSdkToolHandler } from "../../ai/index.js";
3
+ import { ListUsersUseCase } from "../ListUsers/index.js";
4
+ const inputSchema = z.object({});
5
+ class ListUsersToolHandlerImpl {
6
+ constructor(listUsers){
7
+ this.listUsers = listUsers;
8
+ }
9
+ async execute() {
10
+ const result = await this.listUsers.execute();
11
+ if (result.isFail()) throw new Error(`Could not list users: ${result.error.message}`);
12
+ return result.value.map((user)=>({
13
+ id: user.id,
14
+ displayName: user.displayName,
15
+ email: user.email,
16
+ roles: user.roles ?? [],
17
+ teams: user.teams ?? []
18
+ }));
19
+ }
20
+ }
21
+ const ListUsersToolHandler = AiSdkToolHandler.createImplementation({
22
+ implementation: ListUsersToolHandlerImpl,
23
+ dependencies: [
24
+ ListUsersUseCase
25
+ ]
26
+ });
27
+ class ListUsersToolImpl {
28
+ constructor(){
29
+ this.name = "listUsers";
30
+ this.title = "List users";
31
+ this.description = "Lists the admin users in this project with their ids, display names, emails, role ids and team ids. updateUserAccess takes the id and the exact email. Folder permission targets for a user are 'admin:<id>'.";
32
+ this.inputSchema = inputSchema;
33
+ this.annotations = {
34
+ readOnlyHint: true,
35
+ idempotentHint: true
36
+ };
37
+ this.handler = ListUsersToolHandler;
38
+ }
39
+ }
40
+ const ListUsersTool = AiSdkToolDefinition.createImplementation({
41
+ implementation: ListUsersToolImpl,
42
+ dependencies: []
43
+ });
44
+ export { ListUsersTool };
45
+
46
+ //# sourceMappingURL=ListUsersTool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/users/ai/ListUsersTool.js","sources":["../../../../src/features/users/ai/ListUsersTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition } from \"~/features/ai/index.js\";\nimport { AiSdkToolHandler } from \"~/features/ai/index.js\";\nimport { ListUsersUseCase } from \"~/features/users/ListUsers/index.js\";\n\nconst inputSchema = z.object({});\n\ninterface UserSummary {\n id: string;\n displayName: string;\n email: string;\n /** Role ids, so `updateUserAccess` can be given the full list with one role added or removed. */\n roles: string[];\n /** Team ids, for the same reason. */\n teams: string[];\n}\n\nclass ListUsersToolHandlerImpl implements AiSdkToolHandler.Interface<Record<string, never>> {\n constructor(private listUsers: ListUsersUseCase.Interface) {}\n\n async execute(): Promise<UserSummary[]> {\n const result = await this.listUsers.execute();\n\n if (result.isFail()) {\n throw new Error(`Could not list users: ${result.error.message}`);\n }\n\n return result.value.map(user => ({\n id: user.id,\n displayName: user.displayName,\n email: user.email,\n roles: user.roles ?? [],\n teams: user.teams ?? []\n }));\n }\n}\n\nconst ListUsersToolHandler = AiSdkToolHandler.createImplementation({\n implementation: ListUsersToolHandlerImpl,\n dependencies: [ListUsersUseCase]\n});\n\n/**\n * Resolves a person (\"Jane\", \"jane@acme.com\") to the user id `updateUserAccess` takes, and shows\n * what access they have now.\n */\nclass ListUsersToolImpl implements AiSdkToolDefinition.Interface<Record<string, never>> {\n readonly name = \"listUsers\";\n readonly title = \"List users\";\n readonly description =\n \"Lists the admin users in this project with their ids, display names, emails, role ids and team ids. updateUserAccess takes the id and the exact email. Folder permission targets for a user are 'admin:<id>'.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: true, idempotentHint: true };\n readonly handler = ListUsersToolHandler;\n}\n\nexport const ListUsersTool = AiSdkToolDefinition.createImplementation({\n implementation: ListUsersToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","ListUsersToolHandlerImpl","listUsers","result","Error","user","ListUsersToolHandler","AiSdkToolHandler","ListUsersUseCase","ListUsersToolImpl","ListUsersTool","AiSdkToolDefinition"],"mappings":";;;AAKA,MAAMA,cAAcC,EAAE,MAAM,CAAC,CAAC;AAY9B,MAAMC;IACF,YAAoBC,SAAqC,CAAE;aAAvCA,SAAS,GAATA;IAAwC;IAE5D,MAAM,UAAkC;QACpC,MAAMC,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO;QAE3C,IAAIA,OAAO,MAAM,IACb,MAAM,IAAIC,MAAM,CAAC,sBAAsB,EAAED,OAAO,KAAK,CAAC,OAAO,EAAE;QAGnE,OAAOA,OAAO,KAAK,CAAC,GAAG,CAACE,CAAAA,OAAS;gBAC7B,IAAIA,KAAK,EAAE;gBACX,aAAaA,KAAK,WAAW;gBAC7B,OAAOA,KAAK,KAAK;gBACjB,OAAOA,KAAK,KAAK,IAAI,EAAE;gBACvB,OAAOA,KAAK,KAAK,IAAI,EAAE;YAC3B;IACJ;AACJ;AAEA,MAAMC,uBAAuBC,iBAAiB,oBAAoB,CAAC;IAC/D,gBAAgBN;IAChB,cAAc;QAACO;KAAiB;AACpC;AAMA,MAAMC;;aACO,IAAI,GAAG;aACP,KAAK,GAAG;aACR,WAAW,GAChB;aACK,WAAW,GAAGV;aACd,WAAW,GAAG;YAAE,cAAc;YAAM,gBAAgB;QAAK;aACzD,OAAO,GAAGO;;AACvB;AAEO,MAAMI,gBAAgBC,oBAAoB,oBAAoB,CAAC;IAClE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,59 @@
1
+ import { z } from "zod";
2
+ import { AiSdkToolDefinition } from "../../../features/ai/index.js";
3
+ import { AiSdkToolHandler } from "../../../features/ai/index.js";
4
+ import { IdentityContext } from "../../../features/security/IdentityContext/index.js";
5
+ import { GetUserUseCase } from "../../../features/users/GetUser/index.js";
6
+ import { UpdateUserUseCase } from "../../../features/users/UpdateUser/index.js";
7
+ import { ListRolesUseCase } from "../../../features/security/roles/ListRoles/index.js";
8
+ import { ListTeamsUseCase } from "../../../features/security/teams/ListTeams/index.js";
9
+ declare const inputSchema: z.ZodObject<{
10
+ userId: z.ZodString;
11
+ email: z.ZodString;
12
+ roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
13
+ teams: z.ZodOptional<z.ZodArray<z.ZodString>>;
14
+ }, z.core.$strip>;
15
+ type Input = z.infer<typeof inputSchema>;
16
+ interface UpdatedUserAccess {
17
+ id: string;
18
+ email: string;
19
+ roles: string[];
20
+ teams: string[];
21
+ }
22
+ declare class UpdateUserAccessToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {
23
+ private identityContext;
24
+ private getUser;
25
+ private listRoles;
26
+ private listTeams;
27
+ private updateUser;
28
+ constructor(identityContext: IdentityContext.Interface, getUser: GetUserUseCase.Interface, listRoles: ListRolesUseCase.Interface, listTeams: ListTeamsUseCase.Interface, updateUser: UpdateUserUseCase.Interface);
29
+ execute(input: Input): Promise<UpdatedUserAccess>;
30
+ }
31
+ /**
32
+ * Changes which roles and teams a user has.
33
+ *
34
+ * Needs approval: roles and teams decide what the user can do. Each list replaces the stored one,
35
+ * and the approval shows the whole list, so a role the model left out is visible as missing before
36
+ * anything is written.
37
+ */
38
+ declare class UpdateUserAccessToolImpl implements AiSdkToolDefinition.Interface<Input> {
39
+ readonly name = "updateUserAccess";
40
+ readonly title = "Update user access";
41
+ readonly description = "Changes which roles and teams an admin user has. Call listUsers first for the id and exact email. `roles` and `teams` each replace the user's whole list, so pass everything the user should keep; resolve them with listRoles and listTeams. Cannot change the signed-in user or users from an external identity provider, and cannot change a user's name, email or password. Requires user approval.";
42
+ readonly inputSchema: z.ZodObject<{
43
+ userId: z.ZodString;
44
+ email: z.ZodString;
45
+ roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
46
+ teams: z.ZodOptional<z.ZodArray<z.ZodString>>;
47
+ }, z.core.$strip>;
48
+ readonly annotations: {
49
+ readOnlyHint: boolean;
50
+ idempotentHint: boolean;
51
+ };
52
+ readonly handler: typeof UpdateUserAccessToolHandlerImpl & {
53
+ __abstraction: import("@webiny/di").Abstraction<import("../../ai/abstractions").IAiSdkToolHandler<any>>;
54
+ };
55
+ }
56
+ export declare const UpdateUserAccessTool: typeof UpdateUserAccessToolImpl & {
57
+ __abstraction: import("@webiny/di").Abstraction<import("../../ai/abstractions").IAiSdkToolDefinition<any>>;
58
+ };
59
+ export {};
@@ -0,0 +1,101 @@
1
+ import { z } from "zod";
2
+ import { AiSdkToolDefinition, AiSdkToolHandler } from "../../ai/index.js";
3
+ import { IdentityContext } from "../../security/IdentityContext/index.js";
4
+ import { GetUserUseCase } from "../GetUser/index.js";
5
+ import { UpdateUserUseCase } from "../UpdateUser/index.js";
6
+ import { ListRolesUseCase } from "../../security/roles/ListRoles/index.js";
7
+ import { ListTeamsUseCase } from "../../security/teams/ListTeams/index.js";
8
+ const inputSchema = z.object({
9
+ userId: z.string().describe("User id as returned by listUsers."),
10
+ email: z.string().describe("The user's current email, exactly as listUsers returned it. The change is refused if it does not match."),
11
+ roles: z.array(z.string()).optional().describe("The complete list of roles the user should have afterwards. It REPLACES the stored list, so include the roles to keep. Omit it to leave the roles alone. Role ids or slugs from listRoles."),
12
+ teams: z.array(z.string()).optional().describe("The complete list of teams the user should be in afterwards. It REPLACES the stored list, so include the teams to keep. Omit it to leave the teams alone. Team ids or slugs from listTeams.")
13
+ });
14
+ const toIds = (kind, values, known)=>{
15
+ const unknown = [];
16
+ const ids = values.map((value)=>{
17
+ const match = known.find((record)=>record.id === value || record.slug === value);
18
+ if (!match) {
19
+ unknown.push(value);
20
+ return value;
21
+ }
22
+ return match.id;
23
+ });
24
+ if (unknown.length > 0) {
25
+ const names = unknown.map((value)=>`"${value}"`).join(", ");
26
+ throw new Error(`Not a known ${kind} id or slug: ${names}. Nothing was changed. Call list${"role" === kind ? "Roles" : "Teams"} for valid values.`);
27
+ }
28
+ return Array.from(new Set(ids));
29
+ };
30
+ class UpdateUserAccessToolHandlerImpl {
31
+ constructor(identityContext, getUser, listRoles, listTeams, updateUser){
32
+ this.identityContext = identityContext;
33
+ this.getUser = getUser;
34
+ this.listRoles = listRoles;
35
+ this.listTeams = listTeams;
36
+ this.updateUser = updateUser;
37
+ }
38
+ async execute(input) {
39
+ if (void 0 === input.roles && void 0 === input.teams) throw new Error("Pass roles, teams or both. Nothing was changed.");
40
+ const found = await this.getUser.execute({
41
+ id: input.userId
42
+ });
43
+ if (found.isFail()) throw new Error(`User "${input.userId}" not found: ${found.error.message}. Call listUsers for valid ids.`);
44
+ const user = found.value;
45
+ if (user.email !== input.email) throw new Error(`User "${input.userId}" has the email "${user.email}", not "${input.email}", so nothing was changed. Check the user with listUsers.`);
46
+ if (user.id === this.identityContext.getIdentity().id) throw new Error("This is the signed-in user. Change your own roles and teams in the Users screen, so a mistake cannot lock you out. Nothing was changed.");
47
+ if (user.external) throw new Error(`"${user.email}" signs in through an external identity provider, which sets their roles and teams at every sign-in. Change them there. Nothing was changed.`);
48
+ const changes = {};
49
+ if (input.roles?.length === 0) changes.roles = [];
50
+ else if (void 0 !== input.roles) {
51
+ const roles = await this.listRoles.execute();
52
+ if (roles.isFail()) throw new Error(`Could not check the roles: ${roles.error.message}`);
53
+ changes.roles = toIds("role", input.roles, roles.value);
54
+ }
55
+ if (input.teams?.length === 0) changes.teams = [];
56
+ else if (void 0 !== input.teams) {
57
+ const teams = await this.listTeams.execute();
58
+ if (teams.isFail()) throw new Error(`Could not check the teams: ${teams.error.message}`);
59
+ changes.teams = toIds("team", input.teams, teams.value);
60
+ }
61
+ const result = await this.updateUser.execute(user.id, changes);
62
+ if (result.isFail()) throw new Error(`Could not update the user: ${result.error.message}`);
63
+ const updated = result.value;
64
+ return {
65
+ id: updated.id,
66
+ email: updated.email,
67
+ roles: updated.roles ?? [],
68
+ teams: updated.teams ?? []
69
+ };
70
+ }
71
+ }
72
+ const UpdateUserAccessToolHandler = AiSdkToolHandler.createImplementation({
73
+ implementation: UpdateUserAccessToolHandlerImpl,
74
+ dependencies: [
75
+ IdentityContext,
76
+ GetUserUseCase,
77
+ ListRolesUseCase,
78
+ ListTeamsUseCase,
79
+ UpdateUserUseCase
80
+ ]
81
+ });
82
+ class UpdateUserAccessToolImpl {
83
+ constructor(){
84
+ this.name = "updateUserAccess";
85
+ this.title = "Update user access";
86
+ this.description = "Changes which roles and teams an admin user has. Call listUsers first for the id and exact email. `roles` and `teams` each replace the user's whole list, so pass everything the user should keep; resolve them with listRoles and listTeams. Cannot change the signed-in user or users from an external identity provider, and cannot change a user's name, email or password. Requires user approval.";
87
+ this.inputSchema = inputSchema;
88
+ this.annotations = {
89
+ readOnlyHint: false,
90
+ idempotentHint: true
91
+ };
92
+ this.handler = UpdateUserAccessToolHandler;
93
+ }
94
+ }
95
+ const UpdateUserAccessTool = AiSdkToolDefinition.createImplementation({
96
+ implementation: UpdateUserAccessToolImpl,
97
+ dependencies: []
98
+ });
99
+ export { UpdateUserAccessTool };
100
+
101
+ //# sourceMappingURL=UpdateUserAccessTool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/users/ai/UpdateUserAccessTool.js","sources":["../../../../src/features/users/ai/UpdateUserAccessTool.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AiSdkToolDefinition } from \"~/features/ai/index.js\";\nimport { AiSdkToolHandler } from \"~/features/ai/index.js\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/index.js\";\nimport { GetUserUseCase } from \"~/features/users/GetUser/index.js\";\nimport { UpdateUserUseCase } from \"~/features/users/UpdateUser/index.js\";\nimport { ListRolesUseCase } from \"~/features/security/roles/ListRoles/index.js\";\nimport { ListTeamsUseCase } from \"~/features/security/teams/ListTeams/index.js\";\n\nconst inputSchema = z.object({\n userId: z.string().describe(\"User id as returned by listUsers.\"),\n email: z\n .string()\n .describe(\n \"The user's current email, exactly as listUsers returned it. The change is refused if it does not match.\"\n ),\n roles: z\n .array(z.string())\n .optional()\n .describe(\n \"The complete list of roles the user should have afterwards. It REPLACES the stored list, so include the roles to keep. Omit it to leave the roles alone. Role ids or slugs from listRoles.\"\n ),\n teams: z\n .array(z.string())\n .optional()\n .describe(\n \"The complete list of teams the user should be in afterwards. It REPLACES the stored list, so include the teams to keep. Omit it to leave the teams alone. Team ids or slugs from listTeams.\"\n )\n});\n\ntype Input = z.infer<typeof inputSchema>;\n\ninterface UpdatedUserAccess {\n id: string;\n email: string;\n roles: string[];\n teams: string[];\n}\n\ninterface NamedRecord {\n id: string;\n slug: string;\n}\n\n/*\n * A user stores role and team ids, and sign-in loads them by id only. `UpdateUserUseCase` stores\n * whatever it is given, so a slug or a typo would be saved and silently grant nothing. The tool maps\n * each value to an id here and refuses any it cannot find.\n */\nconst toIds = (kind: string, values: string[], known: NamedRecord[]): string[] => {\n const unknown: string[] = [];\n\n const ids = values.map(value => {\n const match = known.find(record => record.id === value || record.slug === value);\n if (!match) {\n unknown.push(value);\n return value;\n }\n return match.id;\n });\n\n if (unknown.length > 0) {\n const names = unknown.map(value => `\"${value}\"`).join(\", \");\n throw new Error(\n `Not a known ${kind} id or slug: ${names}. Nothing was changed. Call list${kind === \"role\" ? \"Roles\" : \"Teams\"} for valid values.`\n );\n }\n\n return Array.from(new Set(ids));\n};\n\n/*\n * The checks run before anything is written:\n *\n * - The email is in the input so the approval shows whose access changes; it is checked against the\n * stored user, so what the user approved is what is changed.\n * - The signed-in user's own access is refused. One wrong role list would lock them out of the\n * screens they would need to undo it.\n * - Users from an external identity provider (Okta, Auth0) are refused. `ExternalIdpUserSync`\n * rewrites their roles and teams from the provider at every sign-in, so a change here would be\n * reported as done and then undone.\n * - Only roles and teams are written. Name, email and password belong to the identity provider too\n * (Cognito, self-hosted sign-in), and `UpdateUserUseCase` alone would change the Webiny record\n * without it. Roles and teams exist only in Webiny, so this is safe with any provider.\n */\nclass UpdateUserAccessToolHandlerImpl implements AiSdkToolHandler.Interface<Input> {\n constructor(\n private identityContext: IdentityContext.Interface,\n private getUser: GetUserUseCase.Interface,\n private listRoles: ListRolesUseCase.Interface,\n private listTeams: ListTeamsUseCase.Interface,\n private updateUser: UpdateUserUseCase.Interface\n ) {}\n\n async execute(input: Input): Promise<UpdatedUserAccess> {\n if (input.roles === undefined && input.teams === undefined) {\n throw new Error(\"Pass roles, teams or both. Nothing was changed.\");\n }\n\n const found = await this.getUser.execute({ id: input.userId });\n if (found.isFail()) {\n throw new Error(\n `User \"${input.userId}\" not found: ${found.error.message}. Call listUsers for valid ids.`\n );\n }\n\n const user = found.value;\n\n if (user.email !== input.email) {\n throw new Error(\n `User \"${input.userId}\" has the email \"${user.email}\", not \"${input.email}\", so nothing was changed. Check the user with listUsers.`\n );\n }\n\n if (user.id === this.identityContext.getIdentity().id) {\n throw new Error(\n \"This is the signed-in user. Change your own roles and teams in the Users screen, so a mistake cannot lock you out. Nothing was changed.\"\n );\n }\n\n if (user.external) {\n throw new Error(\n `\"${user.email}\" signs in through an external identity provider, which sets their roles and teams at every sign-in. Change them there. Nothing was changed.`\n );\n }\n\n const changes: { roles?: string[]; teams?: string[] } = {};\n\n // An empty list has nothing to look up. Reading the roles or teams anyway would make clearing\n // them need security.role or security.team on top of adminUsers.user.\n if (input.roles?.length === 0) {\n changes.roles = [];\n } else if (input.roles !== undefined) {\n const roles = await this.listRoles.execute();\n if (roles.isFail()) {\n throw new Error(`Could not check the roles: ${roles.error.message}`);\n }\n changes.roles = toIds(\"role\", input.roles, roles.value);\n }\n\n if (input.teams?.length === 0) {\n changes.teams = [];\n } else if (input.teams !== undefined) {\n const teams = await this.listTeams.execute();\n if (teams.isFail()) {\n throw new Error(`Could not check the teams: ${teams.error.message}`);\n }\n changes.teams = toIds(\"team\", input.teams, teams.value);\n }\n\n const result = await this.updateUser.execute(user.id, changes);\n if (result.isFail()) {\n throw new Error(`Could not update the user: ${result.error.message}`);\n }\n\n const updated = result.value;\n\n return {\n id: updated.id,\n email: updated.email,\n roles: updated.roles ?? [],\n teams: updated.teams ?? []\n };\n }\n}\n\nconst UpdateUserAccessToolHandler = AiSdkToolHandler.createImplementation({\n implementation: UpdateUserAccessToolHandlerImpl,\n dependencies: [\n IdentityContext,\n GetUserUseCase,\n ListRolesUseCase,\n ListTeamsUseCase,\n UpdateUserUseCase\n ]\n});\n\n/**\n * Changes which roles and teams a user has.\n *\n * Needs approval: roles and teams decide what the user can do. Each list replaces the stored one,\n * and the approval shows the whole list, so a role the model left out is visible as missing before\n * anything is written.\n */\nclass UpdateUserAccessToolImpl implements AiSdkToolDefinition.Interface<Input> {\n readonly name = \"updateUserAccess\";\n readonly title = \"Update user access\";\n readonly description =\n \"Changes which roles and teams an admin user has. Call listUsers first for the id and exact email. `roles` and `teams` each replace the user's whole list, so pass everything the user should keep; resolve them with listRoles and listTeams. Cannot change the signed-in user or users from an external identity provider, and cannot change a user's name, email or password. Requires user approval.\";\n readonly inputSchema = inputSchema;\n readonly annotations = { readOnlyHint: false, idempotentHint: true };\n readonly handler = UpdateUserAccessToolHandler;\n}\n\nexport const UpdateUserAccessTool = AiSdkToolDefinition.createImplementation({\n implementation: UpdateUserAccessToolImpl,\n dependencies: []\n});\n"],"names":["inputSchema","z","toIds","kind","values","known","unknown","ids","value","match","record","names","Error","Array","Set","UpdateUserAccessToolHandlerImpl","identityContext","getUser","listRoles","listTeams","updateUser","input","undefined","found","user","changes","roles","teams","result","updated","UpdateUserAccessToolHandler","AiSdkToolHandler","IdentityContext","GetUserUseCase","ListRolesUseCase","ListTeamsUseCase","UpdateUserUseCase","UpdateUserAccessToolImpl","UpdateUserAccessTool","AiSdkToolDefinition"],"mappings":";;;;;;;AASA,MAAMA,cAAcC,EAAE,MAAM,CAAC;IACzB,QAAQA,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B,OAAOA,EAAAA,MACI,GACN,QAAQ,CACL;IAER,OAAOA,EAAAA,KACG,CAACA,EAAE,MAAM,IACd,QAAQ,GACR,QAAQ,CACL;IAER,OAAOA,EAAAA,KACG,CAACA,EAAE,MAAM,IACd,QAAQ,GACR,QAAQ,CACL;AAEZ;AAqBA,MAAMC,QAAQ,CAACC,MAAcC,QAAkBC;IAC3C,MAAMC,UAAoB,EAAE;IAE5B,MAAMC,MAAMH,OAAO,GAAG,CAACI,CAAAA;QACnB,MAAMC,QAAQJ,MAAM,IAAI,CAACK,CAAAA,SAAUA,OAAO,EAAE,KAAKF,SAASE,OAAO,IAAI,KAAKF;QAC1E,IAAI,CAACC,OAAO;YACRH,QAAQ,IAAI,CAACE;YACb,OAAOA;QACX;QACA,OAAOC,MAAM,EAAE;IACnB;IAEA,IAAIH,QAAQ,MAAM,GAAG,GAAG;QACpB,MAAMK,QAAQL,QAAQ,GAAG,CAACE,CAAAA,QAAS,CAAC,CAAC,EAAEA,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC;QACtD,MAAM,IAAII,MACN,CAAC,YAAY,EAAET,KAAK,aAAa,EAAEQ,MAA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AG;YAAE,cAAc;YAAO,gBAAgB;QAAK;aAC1D,OAAO,GAAG8B;;AACvB;AAEO,MAAMQ,uBAAuBC,oBAAoB,oBAAoB,CAAC;IACzE,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Admin user tools for AI callers.
3
+ *
4
+ * There is no create or delete tool. A user's sign-in account lives with the identity provider
5
+ * (Cognito, self-hosted sign-in), which wraps the api-core use cases with its own. Creating or deleting
6
+ * through api-core alone would leave a user who cannot sign in, or a sign-in account with no user.
7
+ */
8
+ export declare const UsersAiToolsFeature: {
9
+ name: string;
10
+ register(container: import("@webiny/di").Container): void;
11
+ };
@@ -0,0 +1,13 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { ListUsersTool } from "./ListUsersTool.js";
3
+ import { UpdateUserAccessTool } from "./UpdateUserAccessTool.js";
4
+ const UsersAiToolsFeature = createFeature({
5
+ name: "AdminUsers/AiTools",
6
+ register (container) {
7
+ container.register(ListUsersTool);
8
+ container.register(UpdateUserAccessTool);
9
+ }
10
+ });
11
+ export { UsersAiToolsFeature };
12
+
13
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/users/ai/feature.js","sources":["../../../../src/features/users/ai/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListUsersTool } from \"./ListUsersTool.js\";\nimport { UpdateUserAccessTool } from \"./UpdateUserAccessTool.js\";\n\n/**\n * Admin user tools for AI callers.\n *\n * There is no create or delete tool. A user's sign-in account lives with the identity provider\n * (Cognito, self-hosted sign-in), which wraps the api-core use cases with its own. Creating or deleting\n * through api-core alone would leave a user who cannot sign in, or a sign-in account with no user.\n */\nexport const UsersAiToolsFeature = createFeature({\n name: \"AdminUsers/AiTools\",\n register(container) {\n container.register(ListUsersTool);\n container.register(UpdateUserAccessTool);\n }\n});\n"],"names":["UsersAiToolsFeature","createFeature","container","ListUsersTool","UpdateUserAccessTool"],"mappings":";;;AAWO,MAAMA,sBAAsBC,cAAc;IAC7C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;IACvB;AACJ"}
@@ -0,0 +1,3 @@
1
+ export { UsersAiToolsFeature } from "./feature.js";
2
+ export { ListUsersTool } from "./ListUsersTool.js";
3
+ export { UpdateUserAccessTool } from "./UpdateUserAccessTool.js";
@@ -0,0 +1,3 @@
1
+ export { UsersAiToolsFeature } from "./feature.js";
2
+ export { ListUsersTool } from "./ListUsersTool.js";
3
+ export { UpdateUserAccessTool } from "./UpdateUserAccessTool.js";
@@ -1 +1 @@
1
- {"version":3,"file":"features/users/shared/loaders.js","sources":["../../../../src/features/users/shared/loaders.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport flatten from \"lodash/flatten.js\";\nimport type { AdminUsersStorageOperations } from \"~/types/users.js\";\nimport type { AdminUser } from \"./types.js\";\n\ninterface Config {\n getTenant(): string;\n storageOperations: AdminUsersStorageOperations;\n}\n\ninterface GetUserLoaderKey {\n id: string;\n tenant: string;\n}\n\nexport const createUserLoaders = ({ storageOperations }: Config) => {\n const loaders = new Map<string, DataLoader<any, any>>();\n\n async function getUserLoader(ids: readonly GetUserLoaderKey[]) {\n if (ids.length === 0) {\n return [];\n }\n\n // Group by tenant\n const byTenant = ids.reduce(\n (acc, item) => {\n acc[item.tenant] = [...(acc[item.tenant] || []), item.id];\n return acc;\n },\n {} as Record<string, string[]>\n );\n\n try {\n const results = await Promise.all(\n Object.keys(byTenant).map(tenant => {\n return storageOperations.listUsers({\n where: {\n tenant,\n id_in: byTenant[tenant]\n }\n });\n })\n ).then(res => flatten(res));\n\n return ids.map(({ tenant, id }) => {\n const user = results.find(item => item.id === id && item.tenant === tenant);\n /**\n * Casting because DataLoader expect error. But we do not.\n */\n return user || (null as unknown as Error);\n });\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not execute batch read in getUser.\",\n code: \"BATCH_READ_ERROR\",\n data: { ids }\n });\n }\n }\n\n return {\n get getUser() {\n let userLoader = loaders.get(\"getUser\");\n if (userLoader) {\n return userLoader;\n }\n userLoader = new DataLoader<GetUserLoaderKey, AdminUser, string>(getUserLoader, {\n cacheKeyFn(key) {\n return `${key.tenant}:${key.id}`;\n }\n });\n loaders.set(\"getUser\", userLoader);\n return userLoader;\n },\n\n clearLoadersCache(ids: GetUserLoaderKey[]) {\n for (const id of ids) {\n this.getUser.clear(id);\n }\n },\n\n async updateDataLoaderUserCache(id: GetUserLoaderKey, data: Partial<AdminUser>) {\n const user = await this.getUser.load(id);\n this.getUser.clear(id).prime(id, Object.assign({}, user, data));\n }\n };\n};\n"],"names":["createUserLoaders","storageOperations","loaders","Map","getUserLoader","ids","byTenant","acc","item","results","Promise","Object","tenant","res","flatten","id","user","err","WebinyError","userLoader","DataLoader","key","data"],"mappings":";;;AAgBO,MAAMA,oBAAoB,CAAC,EAAEC,iBAAiB,EAAU;IAC3D,MAAMC,UAAU,IAAIC;IAEpB,eAAeC,cAAcC,GAAgC;QACzD,IAAIA,AAAe,MAAfA,IAAI,MAAM,EACV,OAAO,EAAE;QAIb,MAAMC,WAAWD,IAAI,MAAM,CACvB,CAACE,KAAKC;YACFD,GAAG,CAACC,KAAK,MAAM,CAAC,GAAG;mBAAKD,GAAG,CAACC,KAAK,MAAM,CAAC,IAAI,EAAE;gBAAGA,KAAK,EAAE;aAAC;YACzD,OAAOD;QACX,GACA,CAAC;QAGL,IAAI;YACA,MAAME,UAAU,MAAMC,QAAQ,GAAG,CAC7BC,OAAO,IAAI,CAACL,UAAU,GAAG,CAACM,CAAAA,SACfX,kBAAkB,SAAS,CAAC;oBAC/B,OAAO;wBACHW;wBACA,OAAON,QAAQ,CAACM,OAAO;oBAC3B;gBACJ,KAEN,IAAI,CAACC,CAAAA,MAAOC,QAAQD;YAEtB,OAAOR,IAAI,GAAG,CAAC,CAAC,EAAEO,MAAM,EAAEG,EAAE,EAAE;gBAC1B,MAAMC,OAAOP,QAAQ,IAAI,CAACD,CAAAA,OAAQA,KAAK,EAAE,KAAKO,MAAMP,KAAK,MAAM,KAAKI;gBAIpE,OAAOI,QAAS;YACpB;QACJ,EAAE,OAAOC,KAAK;YACV,MAAMC,MAAAA,IAAgB,CAACD,KAAK;gBACxB,SAAS;gBACT,MAAM;gBACN,MAAM;oBAAEZ;gBAAI;YAChB;QACJ;IACJ;IAEA,OAAO;QACH,IAAI,WAAU;YACV,IAAIc,aAAajB,QAAQ,GAAG,CAAC;YAC7B,IAAIiB,YACA,OAAOA;YAEXA,aAAa,IAAIC,WAAgDhB,eAAe;gBAC5E,YAAWiB,GAAG;oBACV,OAAO,GAAGA,IAAI,MAAM,CAAC,CAAC,EAAEA,IAAI,EAAE,EAAE;gBACpC;YACJ;YACAnB,QAAQ,GAAG,CAAC,WAAWiB;YACvB,OAAOA;QACX;QAEA,mBAAkBd,GAAuB;YACrC,KAAK,MAAMU,MAAMV,IACb,IAAI,CAAC,OAAO,CAAC,KAAK,CAACU;QAE3B;QAEA,MAAM,2BAA0BA,EAAoB,EAAEO,IAAwB;YAC1E,MAAMN,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAACD;YACrC,IAAI,CAAC,OAAO,CAAC,KAAK,CAACA,IAAI,KAAK,CAACA,IAAIJ,OAAO,MAAM,CAAC,CAAC,GAAGK,MAAMM;QAC7D;IACJ;AACJ"}
1
+ {"version":3,"file":"features/users/shared/loaders.js","sources":["../../../../src/features/users/shared/loaders.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport flatten from \"lodash/flatten.js\";\nimport type { AdminUsersStorageOperations } from \"~/types/users.js\";\nimport type { AdminUser } from \"./types.js\";\n\ninterface Config {\n getTenant(): string;\n storageOperations: AdminUsersStorageOperations;\n}\n\ninterface GetUserLoaderKey {\n id: string;\n tenant: string;\n}\n\nexport const createUserLoaders = ({ storageOperations }: Config) => {\n const loaders = new Map<string, DataLoader<any, any>>();\n\n async function getUserLoader(ids: readonly GetUserLoaderKey[]) {\n if (ids.length === 0) {\n return [];\n }\n\n // Group by tenant\n const byTenant = ids.reduce(\n (acc, item) => {\n acc[item.tenant] = [...(acc[item.tenant] || []), item.id];\n return acc;\n },\n {} as Record<string, string[]>\n );\n\n try {\n const results = await Promise.all(\n Object.keys(byTenant).map(tenant => {\n return storageOperations.listUsers({\n where: {\n tenant,\n id_in: byTenant[tenant]\n }\n });\n })\n ).then(res => flatten(res));\n\n return ids.map(({ tenant, id }) => {\n const user = results.find(item => item.id === id && item.tenant === tenant);\n /**\n * Casting because DataLoader expect error. But we do not.\n */\n return user || (null as unknown as Error);\n });\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not execute batch read in getUser.\",\n code: \"BATCH_READ_ERROR\",\n data: { ids }\n });\n }\n }\n\n return {\n get getUser() {\n let userLoader = loaders.get(\"getUser\");\n if (userLoader) {\n return userLoader;\n }\n userLoader = new DataLoader<GetUserLoaderKey, AdminUser, string>(getUserLoader, {\n cacheKeyFn(key) {\n return `${key.tenant}:${key.id}`;\n }\n });\n loaders.set(\"getUser\", userLoader);\n return userLoader;\n },\n\n clearLoadersCache(ids: GetUserLoaderKey[]) {\n for (const id of ids) {\n this.getUser.clear(id);\n }\n },\n\n async updateDataLoaderUserCache(id: GetUserLoaderKey, data: Partial<AdminUser>) {\n const user = await this.getUser.load(id);\n this.getUser.clear(id).prime(id, Object.assign({}, user, data));\n }\n };\n};\n"],"names":["createUserLoaders","storageOperations","loaders","Map","getUserLoader","ids","byTenant","acc","item","results","Promise","Object","tenant","res","flatten","id","user","err","WebinyError","userLoader","DataLoader","key","data"],"mappings":";;;AAgBO,MAAMA,oBAAoB,CAAC,EAAEC,iBAAiB,EAAU;IAC3D,MAAMC,UAAU,IAAIC;IAEpB,eAAeC,cAAcC,GAAgC;QACzD,IAAIA,AAAe,MAAfA,IAAI,MAAM,EACV,OAAO,EAAE;QAIb,MAAMC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C,IAAI,CAACD;YACrC,IAAI,CAAC,OAAO,CAAC,KAAK,CAACA,IAAI,KAAK,CAACA,IAAIJ,OAAO,MAAM,CAAC,CAAC,GAAGK,MAAMM;QAC7D;IACJ;AACJ"}
@@ -27,10 +27,12 @@ export type GetUserInput = {
27
27
  id?: never;
28
28
  email: string;
29
29
  };
30
+ export interface ListUsersWhere {
31
+ id_in?: string[];
32
+ teams_in?: string[];
33
+ }
30
34
  export interface ListUsersInput {
31
- where?: {
32
- id_in?: string[];
33
- };
35
+ where?: ListUsersWhere;
34
36
  sort?: string[];
35
37
  }
36
38
  export interface StorageOperationsGetUserParams {
@@ -40,10 +42,10 @@ export interface StorageOperationsGetUserParams {
40
42
  email?: string;
41
43
  };
42
44
  }
45
+ export interface StorageOperationsListUsersWhere extends ListUsersWhere {
46
+ tenant: string;
47
+ }
43
48
  export interface StorageOperationsListUsersParams {
44
- where: {
45
- tenant: string;
46
- id_in?: string[];
47
- };
49
+ where: StorageOperationsListUsersWhere;
48
50
  sort?: string[];
49
51
  }
@@ -34,7 +34,6 @@ export declare class WcpContextImpl implements WcpContext.Interface {
34
34
  canUseAiEntryTranslation(): boolean;
35
35
  canUseAiPowerups(): boolean;
36
36
  canUseAbTesting(): boolean;
37
- canUseRemoteComponents(): boolean;
38
37
  canUseCollaboration(): boolean;
39
38
  canUseComments(): boolean;
40
39
  canUseActivityLog(): boolean;
@@ -135,9 +135,6 @@ class WcpContextImpl {
135
135
  canUseAbTesting() {
136
136
  return this.license.canUseAbTesting();
137
137
  }
138
- canUseRemoteComponents() {
139
- return this.license.canUseRemoteComponents();
140
- }
141
138
  canUseCollaboration() {
142
139
  return this.license.canUseCollaboration();
143
140
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/wcp/WcpContext/WcpContext.js","sources":["../../../../src/features/wcp/WcpContext/WcpContext.ts"],"sourcesContent":["import type { WCP_FEATURE_LABEL } from \"@webiny/wcp\";\nimport { getWcpApiUrl, getWcpAppUrl, getWcpProjectEnvironment } from \"@webiny/wcp\";\nimport WError from \"@webiny/error\";\nimport type {\n DecryptedWcpProjectLicense,\n ILicense,\n WcpProjectEnvironment,\n WcpProject\n} from \"@webiny/wcp/types.js\";\nimport { WcpContext } from \"./abstractions.js\";\nimport { wcpFetch } from \"./utils.js\";\nimport type { WcpLicenseProvider } from \"../WcpLicenseProvider.js\";\n\nconst wcpProjectEnvironment = getWcpProjectEnvironment();\n\nexport class WcpContextImpl implements WcpContext.Interface {\n constructor(private licenseProvider: WcpLicenseProvider.Interface) {}\n\n private get license(): ILicense {\n return this.licenseProvider.get();\n }\n\n private getWcpProjectUrl(path = \"\"): string | null {\n if (!wcpProjectEnvironment) {\n return null;\n }\n\n const orgId = wcpProjectEnvironment.org.id;\n const projectId = wcpProjectEnvironment.project.id;\n const url = [\"/orgs\", orgId, \"projects\", projectId, path].filter(Boolean).join(\"/\");\n return getWcpApiUrl(url);\n }\n\n private async updateSeats(operation: \"increment\" | \"decrement\"): Promise<void> {\n if (!wcpProjectEnvironment) {\n return;\n }\n\n const updateSeatsUrl = this.getWcpProjectUrl(\"package/seats\");\n\n const response = await wcpFetch({\n url: updateSeatsUrl!,\n authorization: wcpProjectEnvironment.apiKey,\n body: { operation },\n meta: {\n action: operation + \"Seats\"\n }\n });\n\n if (response.error) {\n const message = response.message || `Failed to ${operation} user seats.`;\n console.error(message, response.status, response.statusText);\n throw new WError(message, \"WCP_CANNOT_UPDATE_USER_TENANTS\");\n }\n }\n\n private async updateTenants(operation: \"increment\" | \"decrement\"): Promise<void> {\n if (!wcpProjectEnvironment) {\n return;\n }\n\n const updateTenantsUrl = this.getWcpProjectUrl(\"package/tenants\");\n\n const response = await wcpFetch({\n url: updateTenantsUrl!,\n authorization: wcpProjectEnvironment.apiKey,\n body: { operation },\n meta: {\n action: operation + \"Tenants\"\n }\n });\n\n if (response.error) {\n const message = response.message || `Failed to ${operation} tenants.`;\n console.error(message, response.status, response.statusText);\n throw new WError(message, \"WCP_CANNOT_UPDATE_USER_TENANTS\");\n }\n }\n\n getRawLicense(): DecryptedWcpProjectLicense | null {\n return this.license.getRawLicense();\n }\n\n getProject(): WcpProject | null {\n return this.license.getProject();\n }\n\n getProjectWithFeatureFlags(): WcpProject | null {\n return this.getProject();\n }\n\n getProjectEnvironment(): WcpProjectEnvironment | null {\n return wcpProjectEnvironment;\n }\n\n getProjectLicense(): ILicense {\n return this.license;\n }\n\n canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): boolean {\n return this.license.canUseFeature(wcpFeatureId);\n }\n\n canUseAacl(): boolean {\n return this.license.canUseAacl();\n }\n\n canUseTeams(): boolean {\n return this.license.canUseTeams();\n }\n\n canUseFolderLevelPermissions(): boolean {\n return this.license.canUseFolderLevelPermissions();\n }\n\n canUsePrivateFiles(): boolean {\n return this.license.canUsePrivateFiles();\n }\n\n canUseAuditLogs(): boolean {\n return this.license.canUseAuditLogs();\n }\n\n canUseRecordLocking(): boolean {\n return this.license.canUseRecordLocking();\n }\n\n canUseFileManagerThreatDetection(): boolean {\n return this.license.canUseFileManagerThreatDetection();\n }\n\n canUseWorkflows(): boolean {\n return this.license.canUseWorkflows();\n }\n\n canUseHcmsFieldPermissions(): boolean {\n return this.license.canUseHcmsFieldPermissions();\n }\n\n canUseAiImageEnrichment(): boolean {\n return this.license.canUseAiImageEnrichment();\n }\n\n canUseAiPageGeneration(): boolean {\n return this.license.canUseAiPageGeneration();\n }\n\n canUseAiPageTranslation(): boolean {\n return this.license.canUseAiPageTranslation();\n }\n\n canUseAiLexicalGeneration(): boolean {\n return this.license.canUseAiLexicalGeneration();\n }\n\n canUseAiAdminAssistant(): boolean {\n return this.license.canUseAiAdminAssistant();\n }\n\n canUseAiEntryGeneration(): boolean {\n return this.license.canUseAiEntryGeneration();\n }\n\n canUseAiEntryComparison(): boolean {\n return this.license.canUseAiEntryComparison();\n }\n\n canUseAiEntryTranslation(): boolean {\n return this.license.canUseAiEntryTranslation();\n }\n\n canUseAiPowerups(): boolean {\n return this.license.canUseAiPowerups();\n }\n\n canUseAbTesting(): boolean {\n return this.license.canUseAbTesting();\n }\n\n canUseRemoteComponents(): boolean {\n return this.license.canUseRemoteComponents();\n }\n\n canUseCollaboration(): boolean {\n return this.license.canUseCollaboration();\n }\n\n canUseComments(): boolean {\n return this.license.canUseComments();\n }\n\n canUseActivityLog(): boolean {\n return this.license.canUseActivityLog();\n }\n\n canUseLanguages(): boolean {\n return this.license.canUseLanguages();\n }\n\n ensureCanUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): void {\n if (this.license.canUseFeature(wcpFeatureId)) {\n return;\n }\n\n let message = `The ${wcpFeatureId} Webiny Control Panel feature cannot be used because your project license does not permit it.`;\n if (wcpProjectEnvironment) {\n const { org, project } = wcpProjectEnvironment;\n const upgradeProjectLicenseLink = getWcpAppUrl(`/${org.id}/${project.id}/settings`);\n message += ` To upgrade your project license, please use the following link: ${upgradeProjectLicenseLink}.`;\n }\n\n throw new WError(message, \"WCP_CANNOT_USE_FEATURE\", { wcpFeatureId });\n }\n\n async incrementSeats(): Promise<void> {\n await this.updateSeats(\"increment\");\n }\n\n async decrementSeats(): Promise<void> {\n await this.updateSeats(\"decrement\");\n }\n\n async incrementTenants(): Promise<void> {\n await this.updateTenants(\"increment\");\n }\n\n async decrementTenants(): Promise<void> {\n await this.updateTenants(\"decrement\");\n }\n\n toDto() {\n return this.getRawLicense();\n }\n}\n"],"names":["wcpProjectEnvironment","getWcpProjectEnvironment","WcpContextImpl","licenseProvider","path","orgId","projectId","url","Boolean","getWcpApiUrl","operation","updateSeatsUrl","response","wcpFetch","message","console","WError","updateTenantsUrl","wcpFeatureId","org","project","upgradeProjectLicenseLink","getWcpAppUrl"],"mappings":";;;AAaA,MAAMA,wBAAwBC;AAEvB,MAAMC;IACT,YAAoBC,eAA6C,CAAE;aAA/CA,eAAe,GAAfA;IAAgD;IAEpE,IAAY,UAAoB;QAC5B,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG;IACnC;IAEQ,iBA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AAC;IAC3B;IAEA,MAAM,mBAAkC;QACpC,MAAM,IAAI,CAAC,aAAa,CAAC;IAC7B;IAEA,MAAM,mBAAkC;QACpC,MAAM,IAAI,CAAC,aAAa,CAAC;IAC7B;IAEA,QAAQ;QACJ,OAAO,IAAI,CAAC,aAAa;IAC7B;AACJ"}
1
+ {"version":3,"file":"features/wcp/WcpContext/WcpContext.js","sources":["../../../../src/features/wcp/WcpContext/WcpContext.ts"],"sourcesContent":["import type { WCP_FEATURE_LABEL } from \"@webiny/wcp\";\nimport { getWcpApiUrl, getWcpAppUrl, getWcpProjectEnvironment } from \"@webiny/wcp\";\nimport WError from \"@webiny/error\";\nimport type {\n DecryptedWcpProjectLicense,\n ILicense,\n WcpProjectEnvironment,\n WcpProject\n} from \"@webiny/wcp/types.js\";\nimport { WcpContext } from \"./abstractions.js\";\nimport { wcpFetch } from \"./utils.js\";\nimport type { WcpLicenseProvider } from \"../WcpLicenseProvider.js\";\n\nconst wcpProjectEnvironment = getWcpProjectEnvironment();\n\nexport class WcpContextImpl implements WcpContext.Interface {\n constructor(private licenseProvider: WcpLicenseProvider.Interface) {}\n\n private get license(): ILicense {\n return this.licenseProvider.get();\n }\n\n private getWcpProjectUrl(path = \"\"): string | null {\n if (!wcpProjectEnvironment) {\n return null;\n }\n\n const orgId = wcpProjectEnvironment.org.id;\n const projectId = wcpProjectEnvironment.project.id;\n const url = [\"/orgs\", orgId, \"projects\", projectId, path].filter(Boolean).join(\"/\");\n return getWcpApiUrl(url);\n }\n\n private async updateSeats(operation: \"increment\" | \"decrement\"): Promise<void> {\n if (!wcpProjectEnvironment) {\n return;\n }\n\n const updateSeatsUrl = this.getWcpProjectUrl(\"package/seats\");\n\n const response = await wcpFetch({\n url: updateSeatsUrl!,\n authorization: wcpProjectEnvironment.apiKey,\n body: { operation },\n meta: {\n action: operation + \"Seats\"\n }\n });\n\n if (response.error) {\n const message = response.message || `Failed to ${operation} user seats.`;\n console.error(message, response.status, response.statusText);\n throw new WError(message, \"WCP_CANNOT_UPDATE_USER_TENANTS\");\n }\n }\n\n private async updateTenants(operation: \"increment\" | \"decrement\"): Promise<void> {\n if (!wcpProjectEnvironment) {\n return;\n }\n\n const updateTenantsUrl = this.getWcpProjectUrl(\"package/tenants\");\n\n const response = await wcpFetch({\n url: updateTenantsUrl!,\n authorization: wcpProjectEnvironment.apiKey,\n body: { operation },\n meta: {\n action: operation + \"Tenants\"\n }\n });\n\n if (response.error) {\n const message = response.message || `Failed to ${operation} tenants.`;\n console.error(message, response.status, response.statusText);\n throw new WError(message, \"WCP_CANNOT_UPDATE_USER_TENANTS\");\n }\n }\n\n getRawLicense(): DecryptedWcpProjectLicense | null {\n return this.license.getRawLicense();\n }\n\n getProject(): WcpProject | null {\n return this.license.getProject();\n }\n\n getProjectWithFeatureFlags(): WcpProject | null {\n return this.getProject();\n }\n\n getProjectEnvironment(): WcpProjectEnvironment | null {\n return wcpProjectEnvironment;\n }\n\n getProjectLicense(): ILicense {\n return this.license;\n }\n\n canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): boolean {\n return this.license.canUseFeature(wcpFeatureId);\n }\n\n canUseAacl(): boolean {\n return this.license.canUseAacl();\n }\n\n canUseTeams(): boolean {\n return this.license.canUseTeams();\n }\n\n canUseFolderLevelPermissions(): boolean {\n return this.license.canUseFolderLevelPermissions();\n }\n\n canUsePrivateFiles(): boolean {\n return this.license.canUsePrivateFiles();\n }\n\n canUseAuditLogs(): boolean {\n return this.license.canUseAuditLogs();\n }\n\n canUseRecordLocking(): boolean {\n return this.license.canUseRecordLocking();\n }\n\n canUseFileManagerThreatDetection(): boolean {\n return this.license.canUseFileManagerThreatDetection();\n }\n\n canUseWorkflows(): boolean {\n return this.license.canUseWorkflows();\n }\n\n canUseHcmsFieldPermissions(): boolean {\n return this.license.canUseHcmsFieldPermissions();\n }\n\n canUseAiImageEnrichment(): boolean {\n return this.license.canUseAiImageEnrichment();\n }\n\n canUseAiPageGeneration(): boolean {\n return this.license.canUseAiPageGeneration();\n }\n\n canUseAiPageTranslation(): boolean {\n return this.license.canUseAiPageTranslation();\n }\n\n canUseAiLexicalGeneration(): boolean {\n return this.license.canUseAiLexicalGeneration();\n }\n\n canUseAiAdminAssistant(): boolean {\n return this.license.canUseAiAdminAssistant();\n }\n\n canUseAiEntryGeneration(): boolean {\n return this.license.canUseAiEntryGeneration();\n }\n\n canUseAiEntryComparison(): boolean {\n return this.license.canUseAiEntryComparison();\n }\n\n canUseAiEntryTranslation(): boolean {\n return this.license.canUseAiEntryTranslation();\n }\n\n canUseAiPowerups(): boolean {\n return this.license.canUseAiPowerups();\n }\n\n canUseAbTesting(): boolean {\n return this.license.canUseAbTesting();\n }\n\n canUseCollaboration(): boolean {\n return this.license.canUseCollaboration();\n }\n\n canUseComments(): boolean {\n return this.license.canUseComments();\n }\n\n canUseActivityLog(): boolean {\n return this.license.canUseActivityLog();\n }\n\n canUseLanguages(): boolean {\n return this.license.canUseLanguages();\n }\n\n ensureCanUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): void {\n if (this.license.canUseFeature(wcpFeatureId)) {\n return;\n }\n\n let message = `The ${wcpFeatureId} Webiny Control Panel feature cannot be used because your project license does not permit it.`;\n if (wcpProjectEnvironment) {\n const { org, project } = wcpProjectEnvironment;\n const upgradeProjectLicenseLink = getWcpAppUrl(`/${org.id}/${project.id}/settings`);\n message += ` To upgrade your project license, please use the following link: ${upgradeProjectLicenseLink}.`;\n }\n\n throw new WError(message, \"WCP_CANNOT_USE_FEATURE\", { wcpFeatureId });\n }\n\n async incrementSeats(): Promise<void> {\n await this.updateSeats(\"increment\");\n }\n\n async decrementSeats(): Promise<void> {\n await this.updateSeats(\"decrement\");\n }\n\n async incrementTenants(): Promise<void> {\n await this.updateTenants(\"increment\");\n }\n\n async decrementTenants(): Promise<void> {\n await this.updateTenants(\"decrement\");\n }\n\n toDto() {\n return this.getRawLicense();\n }\n}\n"],"names":["wcpProjectEnvironment","getWcpProjectEnvironment","WcpContextImpl","licenseProvider","path","orgId","projectId","url","Boolean","getWcpApiUrl","operation","updateSeatsUrl","response","wcpFetch","message","console","WError","updateTenantsUrl","wcpFeatureId","org","project","upgradeProjectLicenseLink","getWcpAppUrl"],"mappings":";;;AAaA,MAAMA,wBAAwBC;AAEvB,MAAMC;IACT,YAAoBC,eAA6C,CAAE;aAA/CA,eAAe,GAAfA;IAAgD;IAEpE,IAAY,UAAoB;QAC5B,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG;IACnC;IAEQ,iBAAiBC,OAAO,EAAE,EAAiB;QAC/C,IAAI,CAACJ,uBACD,OAAO;QAGX,MAAMK,QAAQL,sBAAsB,GAAG,CAAC,EAAE;QAC1C,MAAMM,YAAYN,sBAAsB,OAAO,CAAC,EAAE;QAClD,MAAMO,MAAM;YAAC;YAASF;YAAO;YAAYC;YAAWF;SAAK,CAAC,MAAM,CAACI,SAAS,IAAI,CAAC;QAC/E,OAAOC,aAAaF;IACxB;IAEA,MAAc,YAAYG,SAAoC,EAAiB;QAC3E,IAAI,CAACV,uBACD;QAGJ,MAAMW,iBAAiB,IAAI,CAAC,gBAAgB,CAAC;QAE7C,MAAMC,WAAW,MAAMC,SAAS;YAC5B,KAAKF;YACL,eAAeX,sBAAsB,MAAM;YAC3C,MAAM;gBAAEU;YAAU;YAClB,MAAM;gBACF,QAAQA,YAAY;YACxB;QACJ;QAEA,IAAIE,SAAS,KAAK,EAAE;YAChB,MAAME,UAAUF,SAAS,OAAO,IAAI,CAAC,UAAU,EAAEF,UAAU,YAAY,CAAC;YACxEK,QAAQ,KAAK,CAACD,SAASF,SAAS,MAAM,EAAEA,SAAS,UAAU;YAC3D,MAAM,IAAII,MAAOF,SAAS;QAC9B;IACJ;IAEA,MAAc,cAAcJ,SAAoC,EAAiB;QAC7E,IAAI,CAACV,uBACD;QAGJ,MAAMiB,mBAAmB,IAAI,CAAC,gBAAgB,CAAC;QAE/C,MAAML,WAAW,MAAMC,SAAS;YAC5B,KAAKI;YACL,eAAejB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C,SAAS,CAAC;YAClFN,WAAW,CAAC,iEAAiE,EAAEO,0BAA0B,CAAC,CAAC;QAC/G;QAEA,MAAM,IAAIL,MAAOF,SAAS,0BAA0B;YAAEI;QAAa;IACvE;IAEA,MAAM,iBAAgC;QAClC,MAAM,IAAI,CAAC,WAAW,CAAC;IAC3B;IAEA,MAAM,iBAAgC;QAClC,MAAM,IAAI,CAAC,WAAW,CAAC;IAC3B;IAEA,MAAM,mBAAkC;QACpC,MAAM,IAAI,CAAC,aAAa,CAAC;IAC7B;IAEA,MAAM,mBAAkC;QACpC,MAAM,IAAI,CAAC,aAAa,CAAC;IAC7B;IAEA,QAAQ;QACJ,OAAO,IAAI,CAAC,aAAa;IAC7B;AACJ"}
@@ -31,7 +31,6 @@ declare class WcpContextWithFeatureFlagsDecoratorImpl implements WcpContext.Inte
31
31
  canUseAiEntryTranslation(): boolean;
32
32
  canUseAiPowerups(): boolean;
33
33
  canUseAbTesting(): boolean;
34
- canUseRemoteComponents(): boolean;
35
34
  canUseCollaboration(): boolean;
36
35
  canUseComments(): boolean;
37
36
  canUseActivityLog(): boolean;
@@ -64,7 +64,6 @@ class WcpContextWithFeatureFlagsDecoratorImpl {
64
64
  },
65
65
  lexicalGeneration: flags.isEnabled("aiPowerups.lexicalGeneration") ? project.package.features.aiPowerups?.options?.lexicalGeneration : false,
66
66
  adminAssistant: flags.isEnabled("aiPowerups.adminAssistant") ? project.package.features.aiPowerups?.options?.adminAssistant : false,
67
- remoteComponents: flags.isEnabled("aiPowerups.remoteComponents") ? project.package.features.aiPowerups?.options?.remoteComponents : false,
68
67
  cms: {
69
68
  entryGeneration: flags.isEnabled("aiPowerups.cms.entryGeneration") ? project.package.features.aiPowerups?.options?.cms?.entryGeneration : false,
70
69
  entryComparison: flags.isEnabled("aiPowerups.cms.entryComparison") ? project.package.features.aiPowerups?.options?.cms?.entryComparison : false,
@@ -154,9 +153,6 @@ class WcpContextWithFeatureFlagsDecoratorImpl {
154
153
  canUseAbTesting() {
155
154
  return this.decoratee.canUseAbTesting() && this.featureFlags.get().isEnabled("abTesting");
156
155
  }
157
- canUseRemoteComponents() {
158
- return this.decoratee.canUseRemoteComponents() && this.featureFlags.get().isEnabled("aiPowerups.remoteComponents");
159
- }
160
156
  canUseCollaboration() {
161
157
  return this.decoratee.canUseCollaboration() && this.featureFlags.get().isEnabled("collaboration");
162
158
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js","sources":["../../../../../src/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.ts"],"sourcesContent":["import type { WCP_FEATURE_LABEL } from \"@webiny/wcp\";\nimport type { WcpProject } from \"@webiny/wcp/types.js\";\nimport { WcpContext } from \"../abstractions.js\";\nimport { FeatureFlags } from \"../../../featureFlags/abstractions.js\";\n\nclass WcpContextWithFeatureFlagsDecoratorImpl implements WcpContext.Interface {\n constructor(\n private featureFlags: FeatureFlags.Interface,\n private decoratee: WcpContext.Interface\n ) {}\n\n getRawLicense() {\n return this.decoratee.getRawLicense();\n }\n\n getProject() {\n return this.decoratee.getProject();\n }\n\n getProjectWithFeatureFlags(): WcpProject | null {\n const project = this.decoratee.getProjectWithFeatureFlags();\n if (!project) {\n return null;\n }\n\n const flags = this.featureFlags.get();\n\n return {\n ...project,\n package: {\n ...project.package,\n features: {\n ...project.package.features,\n multiTenancy: project.package.features.multiTenancy,\n advancedPublishingWorkflow: {\n ...project.package.features.advancedPublishingWorkflow,\n enabled: flags.isEnabled(\"advancedPublishingWorkflow\")\n ? project.package.features.advancedPublishingWorkflow.enabled\n : false\n },\n advancedAccessControlLayer: {\n ...project.package.features.advancedAccessControlLayer,\n enabled: flags.isEnabled(\"advancedAccessControlLayer\")\n ? project.package.features.advancedAccessControlLayer.enabled\n : false,\n options: {\n teams: flags.isEnabled(\"advancedAccessControlLayer.teams\")\n ? project.package.features.advancedAccessControlLayer.options.teams\n : false,\n privateFiles: flags.isEnabled(\"advancedAccessControlLayer.privateFiles\")\n ? project.package.features.advancedAccessControlLayer.options\n .privateFiles\n : false,\n folderLevelPermissions: flags.isEnabled(\n \"advancedAccessControlLayer.folderLevelPermissions\"\n )\n ? project.package.features.advancedAccessControlLayer.options\n .folderLevelPermissions\n : false,\n hcmsFieldPermissions: flags.isEnabled(\n \"advancedAccessControlLayer.hcmsFieldPermissions\"\n )\n ? project.package.features.advancedAccessControlLayer.options\n .hcmsFieldPermissions\n : false\n }\n },\n auditLogs: {\n ...project.package.features.auditLogs,\n enabled: flags.isEnabled(\"auditLogs\")\n ? project.package.features.auditLogs.enabled\n : false\n },\n recordLocking: {\n ...project.package.features.recordLocking,\n enabled: flags.isEnabled(\"recordLocking\")\n ? project.package.features.recordLocking.enabled\n : false\n },\n fileManager: {\n ...project.package.features.fileManager,\n enabled: project.package.features.fileManager.enabled,\n options: {\n threatDetection: flags.isEnabled(\"fileManager.threatDetection\")\n ? project.package.features.fileManager.options.threatDetection\n : false\n }\n },\n aiPowerups: {\n ...project.package.features.aiPowerups,\n enabled: flags.isEnabled(\"aiPowerups\")\n ? project.package.features.aiPowerups?.enabled\n : false,\n options: {\n websiteBuilder: {\n pageGeneration: flags.isEnabled(\n \"aiPowerups.websiteBuilder.pageGeneration\"\n )\n ? project.package.features.aiPowerups?.options?.websiteBuilder\n ?.pageGeneration\n : false,\n pageTranslation: flags.isEnabled(\n \"aiPowerups.websiteBuilder.pageTranslation\"\n )\n ? project.package.features.aiPowerups?.options?.websiteBuilder\n ?.pageTranslation\n : false\n },\n fileManager: {\n imageEnrichment: flags.isEnabled(\n \"aiPowerups.fileManager.imageEnrichment\"\n )\n ? project.package.features.aiPowerups?.options?.fileManager\n ?.imageEnrichment\n : false\n },\n lexicalGeneration: flags.isEnabled(\"aiPowerups.lexicalGeneration\")\n ? project.package.features.aiPowerups?.options?.lexicalGeneration\n : false,\n adminAssistant: flags.isEnabled(\"aiPowerups.adminAssistant\")\n ? project.package.features.aiPowerups?.options?.adminAssistant\n : false,\n remoteComponents: flags.isEnabled(\"aiPowerups.remoteComponents\")\n ? project.package.features.aiPowerups?.options?.remoteComponents\n : false,\n cms: {\n entryGeneration: flags.isEnabled(\"aiPowerups.cms.entryGeneration\")\n ? project.package.features.aiPowerups?.options?.cms\n ?.entryGeneration\n : false,\n entryComparison: flags.isEnabled(\"aiPowerups.cms.entryComparison\")\n ? project.package.features.aiPowerups?.options?.cms\n ?.entryComparison\n : false,\n entryTranslation: flags.isEnabled(\"aiPowerups.cms.entryTranslation\")\n ? project.package.features.aiPowerups?.options?.cms\n ?.entryTranslation\n : false\n }\n }\n },\n abTesting: {\n ...project.package.features.abTesting,\n enabled: flags.isEnabled(\"abTesting\")\n ? project.package.features.abTesting?.enabled\n : false\n },\n collaboration: {\n ...project.package.features.collaboration,\n enabled: flags.isEnabled(\"collaboration\")\n ? project.package.features.collaboration?.enabled\n : false,\n options: {\n comments: flags.isEnabled(\"collaboration.comments\")\n ? project.package.features.collaboration?.options?.comments\n : false,\n activityLog: flags.isEnabled(\"collaboration.activityLog\")\n ? project.package.features.collaboration?.options?.activityLog\n : false\n }\n }\n }\n }\n };\n }\n\n getProjectEnvironment() {\n return this.decoratee.getProjectEnvironment();\n }\n\n getProjectLicense() {\n return this.decoratee.getProjectLicense();\n }\n\n canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL) {\n return this.decoratee.canUseFeature(wcpFeatureId);\n }\n\n canUseAacl() {\n return (\n this.decoratee.canUseAacl() &&\n this.featureFlags.get().isEnabled(\"advancedAccessControlLayer\")\n );\n }\n\n canUseTeams() {\n return (\n this.decoratee.canUseTeams() &&\n this.featureFlags.get().isEnabled(\"advancedAccessControlLayer.teams\")\n );\n }\n\n canUseFolderLevelPermissions() {\n return (\n this.decoratee.canUseFolderLevelPermissions() &&\n this.featureFlags.get().isEnabled(\"advancedAccessControlLayer.folderLevelPermissions\")\n );\n }\n\n canUsePrivateFiles() {\n return (\n this.decoratee.canUsePrivateFiles() &&\n this.featureFlags.get().isEnabled(\"advancedAccessControlLayer.privateFiles\")\n );\n }\n\n canUseAuditLogs() {\n return this.decoratee.canUseAuditLogs() && this.featureFlags.get().isEnabled(\"auditLogs\");\n }\n\n canUseRecordLocking() {\n return (\n this.decoratee.canUseRecordLocking() &&\n this.featureFlags.get().isEnabled(\"recordLocking\")\n );\n }\n\n canUseFileManagerThreatDetection() {\n return (\n this.decoratee.canUseFileManagerThreatDetection() &&\n this.featureFlags.get().isEnabled(\"fileManager.threatDetection\")\n );\n }\n\n canUseWorkflows() {\n return (\n this.decoratee.canUseWorkflows() &&\n this.featureFlags.get().isEnabled(\"advancedPublishingWorkflow\")\n );\n }\n\n canUseHcmsFieldPermissions() {\n return (\n this.decoratee.canUseHcmsFieldPermissions() &&\n this.featureFlags.get().isEnabled(\"advancedAccessControlLayer.hcmsFieldPermissions\")\n );\n }\n\n canUseAiImageEnrichment() {\n return (\n this.decoratee.canUseAiImageEnrichment() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.fileManager.imageEnrichment\")\n );\n }\n\n canUseAiPageGeneration() {\n return (\n this.decoratee.canUseAiPageGeneration() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.websiteBuilder.pageGeneration\")\n );\n }\n\n canUseAiPageTranslation() {\n return (\n this.decoratee.canUseAiPageTranslation() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.websiteBuilder.pageTranslation\")\n );\n }\n\n canUseAiLexicalGeneration() {\n return (\n this.decoratee.canUseAiLexicalGeneration() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.lexicalGeneration\")\n );\n }\n\n canUseAiAdminAssistant() {\n return (\n this.decoratee.canUseAiAdminAssistant() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.adminAssistant\")\n );\n }\n\n canUseAiEntryGeneration() {\n return (\n this.decoratee.canUseAiEntryGeneration() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.cms.entryGeneration\")\n );\n }\n\n canUseAiEntryComparison() {\n return (\n this.decoratee.canUseAiEntryComparison() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.cms.entryComparison\")\n );\n }\n\n canUseAiEntryTranslation() {\n return (\n this.decoratee.canUseAiEntryTranslation() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.cms.entryTranslation\")\n );\n }\n\n canUseAiPowerups() {\n return this.decoratee.canUseAiPowerups() && this.featureFlags.get().isEnabled(\"aiPowerups\");\n }\n\n canUseAbTesting() {\n return this.decoratee.canUseAbTesting() && this.featureFlags.get().isEnabled(\"abTesting\");\n }\n\n canUseRemoteComponents() {\n return (\n this.decoratee.canUseRemoteComponents() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.remoteComponents\")\n );\n }\n\n canUseCollaboration() {\n return (\n this.decoratee.canUseCollaboration() &&\n this.featureFlags.get().isEnabled(\"collaboration\")\n );\n }\n\n canUseComments() {\n return (\n this.decoratee.canUseComments() &&\n this.featureFlags.get().isEnabled(\"collaboration.comments\")\n );\n }\n\n canUseActivityLog() {\n return (\n this.decoratee.canUseActivityLog() &&\n this.featureFlags.get().isEnabled(\"collaboration.activityLog\")\n );\n }\n\n canUseLanguages() {\n return this.decoratee.canUseLanguages() && this.featureFlags.get().isEnabled(\"languages\");\n }\n\n ensureCanUseFeature(featureId: keyof typeof WCP_FEATURE_LABEL) {\n return this.decoratee.ensureCanUseFeature(featureId);\n }\n\n async incrementSeats() {\n return this.decoratee.incrementSeats();\n }\n\n async decrementSeats() {\n return this.decoratee.decrementSeats();\n }\n\n async incrementTenants() {\n return this.decoratee.incrementTenants();\n }\n\n async decrementTenants() {\n return this.decoratee.decrementTenants();\n }\n\n toDto() {\n return this.decoratee.toDto();\n }\n}\n\nexport const WcpContextWithFeatureFlagsDecorator = WcpContext.createDecorator({\n decorator: WcpContextWithFeatureFlagsDecoratorImpl,\n dependencies: [FeatureFlags]\n});\n"],"names":["WcpContextWithFeatureFlagsDecoratorImpl","featureFlags","decoratee","project","flags","wcpFeatureId","featureId","WcpContextWithFeatureFlagsDecorator","WcpContext","FeatureF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AC;IACjF;IAEA,yBAAyB;QACrB,OACI,IAAI,CAAC,SAAS,CAAC,sBAAsB,MACrC,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,SAAS,CAAC;IAE1C;IAEA,sBAAsB;QAClB,OACI,IAAI,CAAC,SAAS,CAAC,mBAAmB,MAClC,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,SAAS,CAAC;IAE1C;IAEA,iBAAiB;QACb,OACI,IAAI,CAAC,SAAS,CAAC,cAAc,MAC7B,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,SAAS,CAAC;IAE1C;IAEA,oBAAoB;QAChB,OACI,IAAI,CAAC,SAAS,CAAC,iBAAiB,MAChC,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,SAAS,CAAC;IAE1C;IAEA,kBAAkB;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,eAAe,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,SAAS,CAAC;IACjF;IAEA,oBAAoBC,SAAyC,EAAE;QAC3D,OAAO,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAACA;IAC9C;IAEA,MAAM,iBAAiB;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc;IACxC;IAEA,MAAM,iBAAiB;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc;IACxC;IAEA,MAAM,mBAAmB;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB;IAC1C;IAEA,MAAM,mBAAmB;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB;IAC1C;IAEA,QAAQ;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK;IAC/B;AACJ;AAEO,MAAMC,sCAAsCC,WAAW,eAAe,CAAC;IAC1E,WAAWR;IACX,cAAc;QAACS;KAAa;AAChC"}
1
+ {"version":3,"file":"features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js","sources":["../../../../../src/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.ts"],"sourcesContent":["import type { WCP_FEATURE_LABEL } from \"@webiny/wcp\";\nimport type { WcpProject } from \"@webiny/wcp/types.js\";\nimport { WcpContext } from \"../abstractions.js\";\nimport { FeatureFlags } from \"../../../featureFlags/abstractions.js\";\n\nclass WcpContextWithFeatureFlagsDecoratorImpl implements WcpContext.Interface {\n constructor(\n private featureFlags: FeatureFlags.Interface,\n private decoratee: WcpContext.Interface\n ) {}\n\n getRawLicense() {\n return this.decoratee.getRawLicense();\n }\n\n getProject() {\n return this.decoratee.getProject();\n }\n\n getProjectWithFeatureFlags(): WcpProject | null {\n const project = this.decoratee.getProjectWithFeatureFlags();\n if (!project) {\n return null;\n }\n\n const flags = this.featureFlags.get();\n\n return {\n ...project,\n package: {\n ...project.package,\n features: {\n ...project.package.features,\n multiTenancy: project.package.features.multiTenancy,\n advancedPublishingWorkflow: {\n ...project.package.features.advancedPublishingWorkflow,\n enabled: flags.isEnabled(\"advancedPublishingWorkflow\")\n ? project.package.features.advancedPublishingWorkflow.enabled\n : false\n },\n advancedAccessControlLayer: {\n ...project.package.features.advancedAccessControlLayer,\n enabled: flags.isEnabled(\"advancedAccessControlLayer\")\n ? project.package.features.advancedAccessControlLayer.enabled\n : false,\n options: {\n teams: flags.isEnabled(\"advancedAccessControlLayer.teams\")\n ? project.package.features.advancedAccessControlLayer.options.teams\n : false,\n privateFiles: flags.isEnabled(\"advancedAccessControlLayer.privateFiles\")\n ? project.package.features.advancedAccessControlLayer.options\n .privateFiles\n : false,\n folderLevelPermissions: flags.isEnabled(\n \"advancedAccessControlLayer.folderLevelPermissions\"\n )\n ? project.package.features.advancedAccessControlLayer.options\n .folderLevelPermissions\n : false,\n hcmsFieldPermissions: flags.isEnabled(\n \"advancedAccessControlLayer.hcmsFieldPermissions\"\n )\n ? project.package.features.advancedAccessControlLayer.options\n .hcmsFieldPermissions\n : false\n }\n },\n auditLogs: {\n ...project.package.features.auditLogs,\n enabled: flags.isEnabled(\"auditLogs\")\n ? project.package.features.auditLogs.enabled\n : false\n },\n recordLocking: {\n ...project.package.features.recordLocking,\n enabled: flags.isEnabled(\"recordLocking\")\n ? project.package.features.recordLocking.enabled\n : false\n },\n fileManager: {\n ...project.package.features.fileManager,\n enabled: project.package.features.fileManager.enabled,\n options: {\n threatDetection: flags.isEnabled(\"fileManager.threatDetection\")\n ? project.package.features.fileManager.options.threatDetection\n : false\n }\n },\n aiPowerups: {\n ...project.package.features.aiPowerups,\n enabled: flags.isEnabled(\"aiPowerups\")\n ? project.package.features.aiPowerups?.enabled\n : false,\n options: {\n websiteBuilder: {\n pageGeneration: flags.isEnabled(\n \"aiPowerups.websiteBuilder.pageGeneration\"\n )\n ? project.package.features.aiPowerups?.options?.websiteBuilder\n ?.pageGeneration\n : false,\n pageTranslation: flags.isEnabled(\n \"aiPowerups.websiteBuilder.pageTranslation\"\n )\n ? project.package.features.aiPowerups?.options?.websiteBuilder\n ?.pageTranslation\n : false\n },\n fileManager: {\n imageEnrichment: flags.isEnabled(\n \"aiPowerups.fileManager.imageEnrichment\"\n )\n ? project.package.features.aiPowerups?.options?.fileManager\n ?.imageEnrichment\n : false\n },\n lexicalGeneration: flags.isEnabled(\"aiPowerups.lexicalGeneration\")\n ? project.package.features.aiPowerups?.options?.lexicalGeneration\n : false,\n adminAssistant: flags.isEnabled(\"aiPowerups.adminAssistant\")\n ? project.package.features.aiPowerups?.options?.adminAssistant\n : false,\n cms: {\n entryGeneration: flags.isEnabled(\"aiPowerups.cms.entryGeneration\")\n ? project.package.features.aiPowerups?.options?.cms\n ?.entryGeneration\n : false,\n entryComparison: flags.isEnabled(\"aiPowerups.cms.entryComparison\")\n ? project.package.features.aiPowerups?.options?.cms\n ?.entryComparison\n : false,\n entryTranslation: flags.isEnabled(\"aiPowerups.cms.entryTranslation\")\n ? project.package.features.aiPowerups?.options?.cms\n ?.entryTranslation\n : false\n }\n }\n },\n abTesting: {\n ...project.package.features.abTesting,\n enabled: flags.isEnabled(\"abTesting\")\n ? project.package.features.abTesting?.enabled\n : false\n },\n collaboration: {\n ...project.package.features.collaboration,\n enabled: flags.isEnabled(\"collaboration\")\n ? project.package.features.collaboration?.enabled\n : false,\n options: {\n comments: flags.isEnabled(\"collaboration.comments\")\n ? project.package.features.collaboration?.options?.comments\n : false,\n activityLog: flags.isEnabled(\"collaboration.activityLog\")\n ? project.package.features.collaboration?.options?.activityLog\n : false\n }\n }\n }\n }\n };\n }\n\n getProjectEnvironment() {\n return this.decoratee.getProjectEnvironment();\n }\n\n getProjectLicense() {\n return this.decoratee.getProjectLicense();\n }\n\n canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL) {\n return this.decoratee.canUseFeature(wcpFeatureId);\n }\n\n canUseAacl() {\n return (\n this.decoratee.canUseAacl() &&\n this.featureFlags.get().isEnabled(\"advancedAccessControlLayer\")\n );\n }\n\n canUseTeams() {\n return (\n this.decoratee.canUseTeams() &&\n this.featureFlags.get().isEnabled(\"advancedAccessControlLayer.teams\")\n );\n }\n\n canUseFolderLevelPermissions() {\n return (\n this.decoratee.canUseFolderLevelPermissions() &&\n this.featureFlags.get().isEnabled(\"advancedAccessControlLayer.folderLevelPermissions\")\n );\n }\n\n canUsePrivateFiles() {\n return (\n this.decoratee.canUsePrivateFiles() &&\n this.featureFlags.get().isEnabled(\"advancedAccessControlLayer.privateFiles\")\n );\n }\n\n canUseAuditLogs() {\n return this.decoratee.canUseAuditLogs() && this.featureFlags.get().isEnabled(\"auditLogs\");\n }\n\n canUseRecordLocking() {\n return (\n this.decoratee.canUseRecordLocking() &&\n this.featureFlags.get().isEnabled(\"recordLocking\")\n );\n }\n\n canUseFileManagerThreatDetection() {\n return (\n this.decoratee.canUseFileManagerThreatDetection() &&\n this.featureFlags.get().isEnabled(\"fileManager.threatDetection\")\n );\n }\n\n canUseWorkflows() {\n return (\n this.decoratee.canUseWorkflows() &&\n this.featureFlags.get().isEnabled(\"advancedPublishingWorkflow\")\n );\n }\n\n canUseHcmsFieldPermissions() {\n return (\n this.decoratee.canUseHcmsFieldPermissions() &&\n this.featureFlags.get().isEnabled(\"advancedAccessControlLayer.hcmsFieldPermissions\")\n );\n }\n\n canUseAiImageEnrichment() {\n return (\n this.decoratee.canUseAiImageEnrichment() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.fileManager.imageEnrichment\")\n );\n }\n\n canUseAiPageGeneration() {\n return (\n this.decoratee.canUseAiPageGeneration() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.websiteBuilder.pageGeneration\")\n );\n }\n\n canUseAiPageTranslation() {\n return (\n this.decoratee.canUseAiPageTranslation() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.websiteBuilder.pageTranslation\")\n );\n }\n\n canUseAiLexicalGeneration() {\n return (\n this.decoratee.canUseAiLexicalGeneration() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.lexicalGeneration\")\n );\n }\n\n canUseAiAdminAssistant() {\n return (\n this.decoratee.canUseAiAdminAssistant() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.adminAssistant\")\n );\n }\n\n canUseAiEntryGeneration() {\n return (\n this.decoratee.canUseAiEntryGeneration() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.cms.entryGeneration\")\n );\n }\n\n canUseAiEntryComparison() {\n return (\n this.decoratee.canUseAiEntryComparison() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.cms.entryComparison\")\n );\n }\n\n canUseAiEntryTranslation() {\n return (\n this.decoratee.canUseAiEntryTranslation() &&\n this.featureFlags.get().isEnabled(\"aiPowerups.cms.entryTranslation\")\n );\n }\n\n canUseAiPowerups() {\n return this.decoratee.canUseAiPowerups() && this.featureFlags.get().isEnabled(\"aiPowerups\");\n }\n\n canUseAbTesting() {\n return this.decoratee.canUseAbTesting() && this.featureFlags.get().isEnabled(\"abTesting\");\n }\n\n canUseCollaboration() {\n return (\n this.decoratee.canUseCollaboration() &&\n this.featureFlags.get().isEnabled(\"collaboration\")\n );\n }\n\n canUseComments() {\n return (\n this.decoratee.canUseComments() &&\n this.featureFlags.get().isEnabled(\"collaboration.comments\")\n );\n }\n\n canUseActivityLog() {\n return (\n this.decoratee.canUseActivityLog() &&\n this.featureFlags.get().isEnabled(\"collaboration.activityLog\")\n );\n }\n\n canUseLanguages() {\n return this.decoratee.canUseLanguages() && this.featureFlags.get().isEnabled(\"languages\");\n }\n\n ensureCanUseFeature(featureId: keyof typeof WCP_FEATURE_LABEL) {\n return this.decoratee.ensureCanUseFeature(featureId);\n }\n\n async incrementSeats() {\n return this.decoratee.incrementSeats();\n }\n\n async decrementSeats() {\n return this.decoratee.decrementSeats();\n }\n\n async incrementTenants() {\n return this.decoratee.incrementTenants();\n }\n\n async decrementTenants() {\n return this.decoratee.decrementTenants();\n }\n\n toDto() {\n return this.decoratee.toDto();\n }\n}\n\nexport const WcpContextWithFeatureFlagsDecorator = WcpContext.createDecorator({\n decorator: WcpContextWithFeatureFlagsDecoratorImpl,\n dependencies: [FeatureFlags]\n});\n"],"names":["WcpContextWithFeatureFlagsDecoratorImpl","featureFlags","decoratee","project","flags","wcpFeatureId","featureId","WcpContextWithFeatureFlagsDecorator","WcpContext","FeatureFlags"],"mappings":";;AAKA,MAAMA;IACF,YACYC,YAAoC,EACpCC,SAA+B,CACzC;aAFUD,YAAY,GAAZA;aACAC,SAAS,GAATA;IACT;IAEH,gBAAgB;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa;IACvC;IAEA,aAAa;QACT,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU;IACpC;IAEA,6BAAgD;QAC5C,MAAMC,UAAU,IAAI,CAAC,SAAS,CAAC,0BAA0B;QACzD,IAAI,CAACA,SACD,OAAO;QAGX,MAAMC,QAAQ,IAAI,CAAC,YAAY,CAAC,GAAG;QAEnC,OAAO;YACH,GAAGD,OAAO;YACV,SAAS;gBACL,GAAGA,QAAQ,OAAO;gBAClB,UAAU;oBACN,GAAGA,QAAQ,OAAO,CAAC,QAAQ;oBAC3B,cAAcA,QAAQ,OAAO,CAAC,QA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AEA,MAAM,iBAAiB;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc;IACxC;IAEA,MAAM,mBAAmB;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB;IAC1C;IAEA,MAAM,mBAAmB;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB;IAC1C;IAEA,QAAQ;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK;IAC/B;AACJ;AAEO,MAAMC,sCAAsCC,WAAW,eAAe,CAAC;IAC1E,WAAWR;IACX,cAAc;QAACS;KAAa;AAChC"}
@@ -0,0 +1,12 @@
1
+ import { IdentityContext } from "../../../features/security/IdentityContext/abstractions.js";
2
+ import { WebsocketsSendToIdentityUseCase } from "../../../features/websockets/SendToIdentity/abstractions.js";
3
+ import { NotifyRecordChangeUseCase as UseCaseAbstraction } from "./abstractions.js";
4
+ declare class NotifyRecordChangeUseCaseImpl implements UseCaseAbstraction.Interface {
5
+ private identityContext;
6
+ private sendToIdentity;
7
+ constructor(identityContext: IdentityContext.Interface, sendToIdentity: WebsocketsSendToIdentityUseCase.Interface);
8
+ execute({ identityId, ...data }: UseCaseAbstraction.Params): Promise<void>;
9
+ private getSignedInIdentityId;
10
+ }
11
+ export declare const NotifyRecordChangeUseCase: import("@webiny/di").Implementation<typeof NotifyRecordChangeUseCaseImpl>;
12
+ export {};
@@ -0,0 +1,38 @@
1
+ import { createImplementation } from "@webiny/di";
2
+ import { IdentityContext } from "../../security/IdentityContext/abstractions.js";
3
+ import { WebsocketsSendToIdentityUseCase } from "../SendToIdentity/abstractions.js";
4
+ import { NotifyRecordChangeUseCase, RECORD_CHANGED_WEBSOCKET_ACTION } from "./abstractions.js";
5
+ class NotifyRecordChangeUseCaseImpl {
6
+ constructor(identityContext, sendToIdentity){
7
+ this.identityContext = identityContext;
8
+ this.sendToIdentity = sendToIdentity;
9
+ }
10
+ async execute({ identityId, ...data }) {
11
+ const recipient = identityId ?? this.getSignedInIdentityId();
12
+ if (!recipient) return;
13
+ try {
14
+ await this.sendToIdentity.execute({
15
+ id: recipient
16
+ }, {
17
+ action: RECORD_CHANGED_WEBSOCKET_ACTION,
18
+ data
19
+ });
20
+ } catch {}
21
+ }
22
+ getSignedInIdentityId() {
23
+ const identity = this.identityContext.getIdentity();
24
+ if (identity.isAnonymous()) return;
25
+ return identity.id;
26
+ }
27
+ }
28
+ const NotifyRecordChangeUseCase_NotifyRecordChangeUseCase = createImplementation({
29
+ abstraction: NotifyRecordChangeUseCase,
30
+ implementation: NotifyRecordChangeUseCaseImpl,
31
+ dependencies: [
32
+ IdentityContext,
33
+ WebsocketsSendToIdentityUseCase
34
+ ]
35
+ });
36
+ export { NotifyRecordChangeUseCase_NotifyRecordChangeUseCase as NotifyRecordChangeUseCase };
37
+
38
+ //# sourceMappingURL=NotifyRecordChangeUseCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/websockets/NotifyRecordChange/NotifyRecordChangeUseCase.js","sources":["../../../../src/features/websockets/NotifyRecordChange/NotifyRecordChangeUseCase.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/abstractions.js\";\nimport { WebsocketsSendToIdentityUseCase } from \"~/features/websockets/SendToIdentity/abstractions.js\";\nimport { RECORD_CHANGED_WEBSOCKET_ACTION } from \"./abstractions.js\";\nimport { NotifyRecordChangeUseCase as UseCaseAbstraction } from \"./abstractions.js\";\n\n/*\n * Changes the admin makes itself are announced too: the admin applies them by id, so the tab that\n * made the change ends up where it already was and the user's other tabs catch up.\n *\n * The change is saved whether or not the message goes out, so a failed send is swallowed rather than\n * failing the write. The admin then shows the change after its next reload.\n */\nclass NotifyRecordChangeUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private sendToIdentity: WebsocketsSendToIdentityUseCase.Interface\n ) {}\n\n async execute({ identityId, ...data }: UseCaseAbstraction.Params): Promise<void> {\n const recipient = identityId ?? this.getSignedInIdentityId();\n if (!recipient) {\n return;\n }\n\n try {\n await this.sendToIdentity.execute(\n { id: recipient },\n { action: RECORD_CHANGED_WEBSOCKET_ACTION, data }\n );\n } catch {\n // See above.\n }\n }\n\n private getSignedInIdentityId(): string | undefined {\n const identity = this.identityContext.getIdentity();\n if (identity.isAnonymous()) {\n return undefined;\n }\n return identity.id;\n }\n}\n\nexport const NotifyRecordChangeUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: NotifyRecordChangeUseCaseImpl,\n dependencies: [IdentityContext, WebsocketsSendToIdentityUseCase]\n});\n"],"names":["NotifyRecordChangeUseCaseImpl","identityContext","sendToIdentity","identityId","data","recipient","RECORD_CHANGED_WEBSOCKET_ACTION","identity","NotifyRecordChangeUseCase","createImplementation","UseCaseAbstraction","IdentityContext","WebsocketsSendToIdentityUseCase"],"mappings":";;;;AAaA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,cAAyD,CACnE;aAFUD,eAAe,GAAfA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QAAQ,EAAEC,UAAU,EAAE,GAAGC,MAAiC,EAAiB;QAC7E,MAAMC,YAAYF,cAAc,IAAI,CAAC,qBAAqB;QAC1D,IAAI,CAACE,WACD;QAGJ,IAAI;YACA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B;gBAAE,IAAIA;YAAU,GAChB;gBAAE,QAAQC;gBAAiCF;YAAK;QAExD,EAAE,OAAM,CAER;IACJ;IAEQ,wBAA4C;QAChD,MAAMG,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QACjD,IAAIA,SAAS,WAAW,IACpB;QAEJ,OAAOA,SAAS,EAAE;IACtB;AACJ;AAEO,MAAMC,sDAA4BC,qBAAqB;IAC1D,aAAaC;IACb,gBAAgBV;IAChB,cAAc;QAACW;QAAiBC;KAAgC;AACpE"}