@webiny/api-core 0.0.0-unstable.b9b64acb6d → 0.0.0-unstable.c27f4d8a31

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 (161) hide show
  1. package/exports/api/security/api-key.d.ts +3 -3
  2. package/exports/api/security/api-key.js +3 -3
  3. package/exports/api/security/api-key.js.map +1 -1
  4. package/exports/api/security/authentication.d.ts +1 -1
  5. package/exports/api/security/authentication.js +1 -1
  6. package/exports/api/security/authentication.js.map +1 -1
  7. package/exports/api/security/role.d.ts +3 -3
  8. package/exports/api/security/role.js +3 -3
  9. package/exports/api/security/role.js.map +1 -1
  10. package/exports/api/security/user.d.ts +3 -3
  11. package/exports/api/security/user.js +3 -3
  12. package/exports/api/security/user.js.map +1 -1
  13. package/exports/api/system.d.ts +1 -1
  14. package/exports/api/system.js +1 -1
  15. package/exports/api/system.js.map +1 -1
  16. package/exports/api/tenancy.d.ts +4 -4
  17. package/exports/api/tenancy.js +4 -4
  18. package/exports/api/tenancy.js.map +1 -1
  19. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +1 -1
  20. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
  21. package/features/security/apiKeys/CreateApiKey/events.d.ts +4 -4
  22. package/features/security/apiKeys/CreateApiKey/events.js +4 -4
  23. package/features/security/apiKeys/CreateApiKey/events.js.map +1 -1
  24. package/features/security/apiKeys/DeleteApiKey/events.d.ts +4 -4
  25. package/features/security/apiKeys/DeleteApiKey/events.js +4 -4
  26. package/features/security/apiKeys/DeleteApiKey/events.js.map +1 -1
  27. package/features/security/apiKeys/ListApiKeys/ListApiKeysUseCase.js +1 -1
  28. package/features/security/apiKeys/ListApiKeys/ListApiKeysUseCase.js.map +1 -1
  29. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +1 -1
  30. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
  31. package/features/security/apiKeys/UpdateApiKey/events.d.ts +4 -4
  32. package/features/security/apiKeys/UpdateApiKey/events.js +4 -4
  33. package/features/security/apiKeys/UpdateApiKey/events.js.map +1 -1
  34. package/features/security/apiKeys/shared/schemas.d.ts +10 -71
  35. package/features/security/apiKeys/shared/schemas.js +4 -4
  36. package/features/security/apiKeys/shared/schemas.js.map +1 -1
  37. package/features/security/authentication/AuthenticationContext/SetIdTokenCookie.d.ts +2 -2
  38. package/features/security/authentication/AuthenticationContext/SetIdTokenCookie.js +2 -2
  39. package/features/security/authentication/AuthenticationContext/SetIdTokenCookie.js.map +1 -1
  40. package/features/security/authentication/AuthenticationContext/events.d.ts +4 -4
  41. package/features/security/authentication/AuthenticationContext/events.js +4 -4
  42. package/features/security/authentication/AuthenticationContext/events.js.map +1 -1
  43. package/features/security/login/abstractions.d.ts +2 -2
  44. package/features/security/login/abstractions.js +2 -2
  45. package/features/security/login/abstractions.js.map +1 -1
  46. package/features/security/roles/CreateRole/CreateRoleUseCase.js +1 -1
  47. package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
  48. package/features/security/roles/CreateRole/events.d.ts +4 -4
  49. package/features/security/roles/CreateRole/events.js +4 -4
  50. package/features/security/roles/CreateRole/events.js.map +1 -1
  51. package/features/security/roles/CreateRole/schema.d.ts +2 -20
  52. package/features/security/roles/CreateRole/schema.js +2 -2
  53. package/features/security/roles/CreateRole/schema.js.map +1 -1
  54. package/features/security/roles/DeleteRole/events.d.ts +4 -4
  55. package/features/security/roles/DeleteRole/events.js +4 -4
  56. package/features/security/roles/DeleteRole/events.js.map +1 -1
  57. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +1 -1
  58. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  59. package/features/security/roles/UpdateRole/events.d.ts +4 -4
  60. package/features/security/roles/UpdateRole/events.js +4 -4
  61. package/features/security/roles/UpdateRole/events.js.map +1 -1
  62. package/features/security/roles/UpdateRole/schema.d.ts +2 -18
  63. package/features/security/roles/UpdateRole/schema.js +2 -2
  64. package/features/security/roles/UpdateRole/schema.js.map +1 -1
  65. package/features/security/teams/CreateTeam/CreateTeamUseCase.js +1 -1
  66. package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
  67. package/features/security/teams/CreateTeam/events.d.ts +4 -4
  68. package/features/security/teams/CreateTeam/events.js +4 -4
  69. package/features/security/teams/CreateTeam/events.js.map +1 -1
  70. package/features/security/teams/CreateTeam/index.d.ts +1 -1
  71. package/features/security/teams/CreateTeam/index.js +1 -1
  72. package/features/security/teams/CreateTeam/index.js.map +1 -1
  73. package/features/security/teams/CreateTeam/schema.d.ts +2 -12
  74. package/features/security/teams/DeleteTeam/events.d.ts +4 -4
  75. package/features/security/teams/DeleteTeam/events.js +4 -4
  76. package/features/security/teams/DeleteTeam/events.js.map +1 -1
  77. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +1 -1
  78. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  79. package/features/security/teams/UpdateTeam/events.d.ts +4 -4
  80. package/features/security/teams/UpdateTeam/events.js +4 -4
  81. package/features/security/teams/UpdateTeam/events.js.map +1 -1
  82. package/features/security/teams/UpdateTeam/schema.d.ts +2 -10
  83. package/features/system/InstallSystem/abstractions.d.ts +2 -2
  84. package/features/system/InstallSystem/abstractions.js +1 -1
  85. package/features/system/InstallSystem/abstractions.js.map +1 -1
  86. package/features/system/InstallSystem/events.js +2 -2
  87. package/features/system/InstallSystem/events.js.map +1 -1
  88. package/features/system/InstallSystem/index.d.ts +1 -1
  89. package/features/system/InstallSystem/index.js +1 -1
  90. package/features/system/InstallSystem/index.js.map +1 -1
  91. package/features/tenancy/CreateTenant/abstractions.d.ts +4 -4
  92. package/features/tenancy/CreateTenant/abstractions.js +2 -2
  93. package/features/tenancy/CreateTenant/abstractions.js.map +1 -1
  94. package/features/tenancy/CreateTenant/events.js +3 -3
  95. package/features/tenancy/CreateTenant/events.js.map +1 -1
  96. package/features/tenancy/CreateTenant/index.d.ts +1 -1
  97. package/features/tenancy/CreateTenant/index.js +1 -1
  98. package/features/tenancy/CreateTenant/index.js.map +1 -1
  99. package/features/tenancy/DeleteTenant/abstractions.d.ts +4 -4
  100. package/features/tenancy/DeleteTenant/abstractions.js +2 -2
  101. package/features/tenancy/DeleteTenant/abstractions.js.map +1 -1
  102. package/features/tenancy/DeleteTenant/events.js +3 -3
  103. package/features/tenancy/DeleteTenant/events.js.map +1 -1
  104. package/features/tenancy/DeleteTenant/index.d.ts +1 -1
  105. package/features/tenancy/DeleteTenant/index.js +1 -1
  106. package/features/tenancy/DeleteTenant/index.js.map +1 -1
  107. package/features/tenancy/InstallTenant/abstractions.d.ts +2 -2
  108. package/features/tenancy/InstallTenant/abstractions.js +1 -1
  109. package/features/tenancy/InstallTenant/abstractions.js.map +1 -1
  110. package/features/tenancy/InstallTenant/events.js +2 -2
  111. package/features/tenancy/InstallTenant/events.js.map +1 -1
  112. package/features/tenancy/InstallTenant/index.d.ts +1 -1
  113. package/features/tenancy/InstallTenant/index.js +1 -1
  114. package/features/tenancy/InstallTenant/index.js.map +1 -1
  115. package/features/tenancy/UpdateTenant/abstractions.d.ts +4 -4
  116. package/features/tenancy/UpdateTenant/abstractions.js +2 -2
  117. package/features/tenancy/UpdateTenant/abstractions.js.map +1 -1
  118. package/features/tenancy/UpdateTenant/events.js +3 -3
  119. package/features/tenancy/UpdateTenant/events.js.map +1 -1
  120. package/features/tenancy/UpdateTenant/index.d.ts +1 -1
  121. package/features/tenancy/UpdateTenant/index.js +1 -1
  122. package/features/tenancy/UpdateTenant/index.js.map +1 -1
  123. package/features/users/CreateUser/CreateUserUseCase.js +1 -1
  124. package/features/users/CreateUser/CreateUserUseCase.js.map +1 -1
  125. package/features/users/CreateUser/events.d.ts +4 -4
  126. package/features/users/CreateUser/events.js +4 -4
  127. package/features/users/CreateUser/events.js.map +1 -1
  128. package/features/users/CreateUser/schema.d.ts +4 -36
  129. package/features/users/DeleteUser/events.d.ts +4 -4
  130. package/features/users/DeleteUser/events.js +4 -4
  131. package/features/users/DeleteUser/events.js.map +1 -1
  132. package/features/users/ExternalIdpUserSync/ExternalIdpUserSyncHandler.d.ts +3 -3
  133. package/features/users/ExternalIdpUserSync/ExternalIdpUserSyncHandler.js +2 -2
  134. package/features/users/ExternalIdpUserSync/ExternalIdpUserSyncHandler.js.map +1 -1
  135. package/features/users/UpdateUser/UpdateUserUseCase.js +1 -1
  136. package/features/users/UpdateUser/UpdateUserUseCase.js.map +1 -1
  137. package/features/users/UpdateUser/events.d.ts +4 -4
  138. package/features/users/UpdateUser/events.js +4 -4
  139. package/features/users/UpdateUser/events.js.map +1 -1
  140. package/features/users/UpdateUser/schema.d.ts +4 -30
  141. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +0 -1
  142. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  143. package/models/base/BaseModel.js +2 -2
  144. package/models/base/BaseModel.js.map +1 -1
  145. package/models/base/ModelBuilder.d.ts +2 -2
  146. package/models/base/ModelBuilder.js +21 -2
  147. package/models/base/ModelBuilder.js.map +1 -1
  148. package/models/cms/FieldBuilder.d.ts +3 -2
  149. package/models/cms/FieldBuilder.js +12 -17
  150. package/models/cms/FieldBuilder.js.map +1 -1
  151. package/models/cms/FieldBuilderRegistry.d.ts +1 -1
  152. package/models/cms/FieldBuilderRegistry.js.map +1 -1
  153. package/models/cms/FieldDefinitionsBuilder.d.ts +1 -0
  154. package/models/cms/FieldDefinitionsBuilder.js +13 -15
  155. package/models/cms/FieldDefinitionsBuilder.js.map +1 -1
  156. package/models/cms/PrivateCmsModelBuilder.js.map +1 -1
  157. package/models/cms/abstractions.d.ts +1 -1
  158. package/models/cms/abstractions.js.map +1 -1
  159. package/models/cms/fieldsBuilder.md +1 -1
  160. package/models/simple/Page/abstractions.d.ts +1 -11
  161. package/package.json +17 -17
@@ -3,16 +3,16 @@ export const createApiKeyInputSchema = z.object({
3
3
  name: z.string().min(1),
4
4
  slug: z.string().min(1),
5
5
  description: z.string(),
6
- permissions: z.array(z.object({
6
+ permissions: z.array(z.looseObject({
7
7
  name: z.string()
8
- }).passthrough()).optional().default([])
8
+ })).optional().default([])
9
9
  });
10
10
  export const updateApiKeyInputSchema = z.object({
11
11
  name: z.string().min(1).optional(),
12
12
  description: z.string().optional(),
13
- permissions: z.array(z.object({
13
+ permissions: z.array(z.looseObject({
14
14
  name: z.string()
15
- }).passthrough()).optional().default([])
15
+ })).optional().default([])
16
16
  });
17
17
  export const listApiKeysInputSchema = z.object({
18
18
  where: z.object({
@@ -1 +1 @@
1
- {"version":3,"names":["z","createApiKeyInputSchema","object","name","string","min","slug","description","permissions","array","passthrough","optional","default","updateApiKeyInputSchema","listApiKeysInputSchema","where","name_contains","description_contains","limit","number","int","positive","max","after","sort","enum"],"sources":["schemas.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const createApiKeyInputSchema = z.object({\n name: z.string().min(1),\n slug: z.string().min(1),\n description: z.string(),\n permissions: z\n .array(z.object({ name: z.string() }).passthrough())\n .optional()\n .default([])\n});\n\nexport const updateApiKeyInputSchema = z.object({\n name: z.string().min(1).optional(),\n description: z.string().optional(),\n permissions: z\n .array(z.object({ name: z.string() }).passthrough())\n .optional()\n .default([])\n});\n\nexport const listApiKeysInputSchema = z.object({\n where: z\n .object({\n name: z.string().optional(),\n name_contains: z.string().optional(),\n description: z.string().optional(),\n description_contains: z.string().optional()\n })\n .optional(),\n limit: z.number().int().positive().max(100).optional(),\n after: z.string().optional(),\n sort: z.array(z.enum([\"createdOn_ASC\", \"createdOn_DESC\"])).optional()\n});\n"],"mappings":"AAAA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,uBAAuB,GAAGD,CAAC,CAACE,MAAM,CAAC;EAC5CC,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC;EACvBC,IAAI,EAAEN,CAAC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,CACDA,QAAQ,CAAC,CAAC;EACfO,KAAK,EAAElB,CAAC,CAACmB,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,GAAG,CAAC,GAAG,CAAC,CAACX,QAAQ,CAAC,CAAC;EACtDY,KAAK,EAAEvB,CAAC,CAACI,MAAM,CAAC,CAAC,CAACO,QAAQ,CAAC,CAAC;EAC5Ba,IAAI,EAAExB,CAAC,CAACS,KAAK,CAACT,CAAC,CAACyB,IAAI,CAAC,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAACd,QAAQ,CAAC;AACxE,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["z","createApiKeyInputSchema","object","name","string","min","slug","description","permissions","array","looseObject","optional","default","updateApiKeyInputSchema","listApiKeysInputSchema","where","name_contains","description_contains","limit","number","int","positive","max","after","sort","enum"],"sources":["schemas.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const createApiKeyInputSchema = z.object({\n name: z.string().min(1),\n slug: z.string().min(1),\n description: z.string(),\n permissions: z\n .array(z.looseObject({ name: z.string() }))\n .optional()\n .default([])\n});\n\nexport const updateApiKeyInputSchema = z.object({\n name: z.string().min(1).optional(),\n description: z.string().optional(),\n permissions: z\n .array(z.looseObject({ name: z.string() }))\n .optional()\n .default([])\n});\n\nexport const listApiKeysInputSchema = z.object({\n where: z\n .object({\n name: z.string().optional(),\n name_contains: z.string().optional(),\n description: z.string().optional(),\n description_contains: z.string().optional()\n })\n .optional(),\n limit: z.number().int().positive().max(100).optional(),\n after: z.string().optional(),\n sort: z.array(z.enum([\"createdOn_ASC\", \"createdOn_DESC\"])).optional()\n});\n"],"mappings":"AAAA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,uBAAuB,GAAGD,CAAC,CAACE,MAAM,CAAC;EAC5CC,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAA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C,CAAC;EACfO,KAAK,EAAElB,CAAC,CAACmB,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,GAAG,CAAC,GAAG,CAAC,CAACX,QAAQ,CAAC,CAAC;EACtDY,KAAK,EAAEvB,CAAC,CAACI,MAAM,CAAC,CAAC,CAACO,QAAQ,CAAC,CAAC;EAC5Ba,IAAI,EAAExB,CAAC,CAACS,KAAK,CAACT,CAAC,CAACyB,IAAI,CAAC,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAACd,QAAQ,CAAC;AACxE,CAAC,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import { Reply } from "@webiny/handler";
2
- import { AfterAuthenticationHandler } from "../../../../features/security/authentication/AuthenticationContext/index.js";
2
+ import { AfterAuthenticationEventHandler } from "../../../../features/security/authentication/AuthenticationContext/index.js";
3
3
  import { AuthenticationContext } from "../../../../features/security/authentication/AuthenticationContext/index.js";
4
- declare class SetIdTokenCookieImpl implements AfterAuthenticationHandler.Interface {
4
+ declare class SetIdTokenCookieImpl implements AfterAuthenticationEventHandler.Interface {
5
5
  private authenticationContext;
6
6
  private reply;
7
7
  constructor(authenticationContext: AuthenticationContext.Interface, reply: Reply.Interface);
@@ -1,7 +1,7 @@
1
1
  import jwt from "jsonwebtoken";
2
2
  import { createImplementation } from "@webiny/feature/api";
3
3
  import { Reply } from "@webiny/handler";
4
- import { AfterAuthenticationHandler } from "./index.js";
4
+ import { AfterAuthenticationEventHandler } from "./index.js";
5
5
  import { AuthenticationContext } from "./index.js";
6
6
  const get24HoursFromNow = () => {
7
7
  const oneHour = 1000 * 60 * 60;
@@ -44,7 +44,7 @@ class SetIdTokenCookieImpl {
44
44
  }
45
45
  }
46
46
  export const SetIdTokenCookie = createImplementation({
47
- abstraction: AfterAuthenticationHandler,
47
+ abstraction: AfterAuthenticationEventHandler,
48
48
  implementation: SetIdTokenCookieImpl,
49
49
  dependencies: [AuthenticationContext, Reply]
50
50
  });
@@ -1 +1 @@
1
- {"version":3,"names":["jwt","createImplementation","Reply","AfterAuthenticationHandler","AuthenticationContext","get24HoursFromNow","oneHour","Date","getTime","toDate","timestamp","SetIdTokenCookieImpl","constructor","authenticationContext","reply","handle","token","getAuthToken","tokenData","decode","json","expiresOn","exp","setCookie","path","expires","sameSite","secure","httpOnly","header","SetIdTokenCookie","abstraction","implementation","dependencies"],"sources":["SetIdTokenCookie.ts"],"sourcesContent":["import jwt from \"jsonwebtoken\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { Reply } from \"@webiny/handler\";\nimport { AfterAuthenticationHandler } from \"~/features/security/authentication/AuthenticationContext/index.js\";\nimport { AuthenticationContext } from \"~/features/security/authentication/AuthenticationContext/index.js\";\n\nconst get24HoursFromNow = () => {\n const oneHour = 1000 * 60 * 60;\n return new Date(new Date().getTime() + oneHour * 24);\n};\n\nconst toDate = (timestamp: number | undefined) => {\n return timestamp ? new Date(timestamp * 1000) : get24HoursFromNow();\n};\n\nclass SetIdTokenCookieImpl implements AfterAuthenticationHandler.Interface {\n constructor(\n private authenticationContext: AuthenticationContext.Interface,\n private reply: Reply.Interface\n ) {}\n\n async handle(): Promise<void> {\n const token = this.authenticationContext.getAuthToken();\n\n if (!token) {\n return;\n }\n\n // Attempt to acquire expiration from the token; fall back to \"expire in 24 hours\".\n // In most cases the token will be a JWT token, but it can also be a custom token, or an API key.\n const tokenData = jwt.decode(token, { json: true });\n const expiresOn = tokenData ? toDate(tokenData.exp) : get24HoursFromNow();\n\n // @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie\n this.reply.setCookie(\"wby-id-token\", token, {\n path: \"/\",\n expires: expiresOn,\n // Allow this cookie to be sent with cross-origin requests.\n sameSite: \"none\",\n // Only send this cookie to the server when HTTPS is used.\n // NOTE: `https` requirement is ignored for `localhost.\n secure: true,\n // Forbids JavaScript from accessing the cookie.\n httpOnly: true\n });\n\n this.reply.header(\"cache-control\", `no-cache=\"Set-Cookie\"`);\n }\n}\n\nexport const SetIdTokenCookie = createImplementation({\n abstraction: AfterAuthenticationHandler,\n implementation: SetIdTokenCookieImpl,\n dependencies: [AuthenticationContext, Reply]\n});\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,cAAc;AAC9B,SAASC,oBAAoB,QAAQ,qBAAqB;AAC1D,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,0BAA0B;AACnC,SAASC,qBAAqB;AAE9B,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EAC5B,MAAMC,OAAO,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE;EAC9B,OAAO,IAAIC,IAAI,CAAC,IAAIA,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,GAAGF,OAAO,GAAG,EAAE,CAAC;AACxD,CAAC;AAED,MAAMG,MAAM,GAAIC,SAA6B,IAAK;EAC9C,OAAOA,SAAS,GAAG,IAAIH,IAAI,CAACG,SAAS,GAAG,IAAI,CAAC,GAAGL,iBAAiB,CAAC,CAAC;AACvE,CAAC;AAED,MAAMM,oBAAoB,CAAiD;EACvEC,WAAWA,CACCC,qBAAsD,EACtDC,KAAsB,EAChC;IAAA,KAFUD,qBAAsD,GAAtDA,qBAAsD;IAAA,KACtDC,KAAsB,GAAtBA,KAAsB;EAC/B;EAEH,MAAMC,MAAMA,CAAA,EAAkB;IAC1B,MAAMC,KAAK,GAAG,IAAI,CAACH,qBAAqB,CAACI,YAAY,CAAC,CAAC;IAEvD,IAAI,CAACD,KAAK,EAAE;MACR;IACJ;;IAEA;IACA;IACA,MAAME,SAAS,GAAGlB,GAAG,CAACmB,MAAM,CAACH,KAAK,EAAE;MAAEI,IAAI,EAAE;IAAK,CAAC,CAAC;IACnD,MAAMC,SAAS,GAAGH,SAAS,GAAGT,MAAM,CAACS,SAAS,CAACI,GAAG,CAAC,GAAGjB,iBAAiB,CAAC,CAAC;;IAEzE;IACA,IAAI,CAACS,KAAK,CAACS,SAAS,CAAC,cAAc,EAAEP,KAAK,EAAE;MACxCQ,IAAI,EAAE,GAAG;MACTC,OAAO,EAAEJ,SAAS;MAClB;MACAK,QAAQ,EAAE,MAAM;MAChB;MACA;MACAC,MAAM,EAAE,IAAI;MACZ;MACAC,QAAQ,EAAE;IACd,CAAC,CAAC;IAEF,IAAI,CAACd,KAAK,CAACe,MAAM,CAAC,eAAe,EAAE,uBAAuB,CAAC;EAC/D;AACJ;AAEA,OAAO,MAAMC,gBAAgB,GAAG7B,oBAAoB,CAAC;EACjD8B,WAAW,EAAE5B,0BAA0B;EACvC6B,cAAc,EAAErB,oBAAoB;EACpCsB,YAAY,EAAE,CAAC7B,qBAAqB,EAAEF,KAAK;AAC/C,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["jwt","createImplementation","Reply","AfterAuthenticationEventHandler","AuthenticationContext","get24HoursFromNow","oneHour","Date","getTime","toDate","timestamp","SetIdTokenCookieImpl","constructor","authenticationContext","reply","handle","token","getAuthToken","tokenData","decode","json","expiresOn","exp","setCookie","path","expires","sameSite","secure","httpOnly","header","SetIdTokenCookie","abstraction","implementation","dependencies"],"sources":["SetIdTokenCookie.ts"],"sourcesContent":["import jwt from \"jsonwebtoken\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { Reply } from \"@webiny/handler\";\nimport { AfterAuthenticationEventHandler } from \"~/features/security/authentication/AuthenticationContext/index.js\";\nimport { AuthenticationContext } from \"~/features/security/authentication/AuthenticationContext/index.js\";\n\nconst get24HoursFromNow = () => {\n const oneHour = 1000 * 60 * 60;\n return new Date(new Date().getTime() + oneHour * 24);\n};\n\nconst toDate = (timestamp: number | undefined) => {\n return timestamp ? new Date(timestamp * 1000) : get24HoursFromNow();\n};\n\nclass SetIdTokenCookieImpl implements AfterAuthenticationEventHandler.Interface {\n constructor(\n private authenticationContext: AuthenticationContext.Interface,\n private reply: Reply.Interface\n ) {}\n\n async handle(): Promise<void> {\n const token = this.authenticationContext.getAuthToken();\n\n if (!token) {\n return;\n }\n\n // Attempt to acquire expiration from the token; fall back to \"expire in 24 hours\".\n // In most cases the token will be a JWT token, but it can also be a custom token, or an API key.\n const tokenData = jwt.decode(token, { json: true });\n const expiresOn = tokenData ? toDate(tokenData.exp) : get24HoursFromNow();\n\n // @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie\n this.reply.setCookie(\"wby-id-token\", token, {\n path: \"/\",\n expires: expiresOn,\n // Allow this cookie to be sent with cross-origin requests.\n sameSite: \"none\",\n // Only send this cookie to the server when HTTPS is used.\n // NOTE: `https` requirement is ignored for `localhost.\n secure: true,\n // Forbids JavaScript from accessing the cookie.\n httpOnly: true\n });\n\n this.reply.header(\"cache-control\", `no-cache=\"Set-Cookie\"`);\n }\n}\n\nexport const SetIdTokenCookie = createImplementation({\n abstraction: AfterAuthenticationEventHandler,\n implementation: SetIdTokenCookieImpl,\n dependencies: [AuthenticationContext, Reply]\n});\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,cAAc;AAC9B,SAASC,oBAAoB,QAAQ,qBAAqB;AAC1D,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,+BAA+B;AACxC,SAASC,qBAAqB;AAE9B,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EAC5B,MAAMC,OAAO,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE;EAC9B,OAAO,IAAIC,IAAI,CAAC,IAAIA,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,GAAGF,OAAO,GAAG,EAAE,CAAC;AACxD,CAAC;AAED,MAAMG,MAAM,GAAIC,SAA6B,IAAK;EAC9C,OAAOA,SAAS,GAAG,IAAIH,IAAI,CAACG,SAAS,GAAG,IAAI,CAAC,GAAGL,iBAAiB,CAAC,CAAC;AACvE,CAAC;AAED,MAAMM,oBAAoB,CAAsD;EAC5EC,WAAWA,CACCC,qBAAsD,EACtDC,KAAsB,EAChC;IAAA,KAFUD,qBAAsD,GAAtDA,qBAAsD;IAAA,KACtDC,KAAsB,GAAtBA,KAAsB;EAC/B;EAEH,MAAMC,MAAMA,CAAA,EAAkB;IAC1B,MAAMC,KAAK,GAAG,IAAI,CAACH,qBAAqB,CAACI,YAAY,CAAC,CAAC;IAEvD,IAAI,CAACD,KAAK,EAAE;MACR;IACJ;;IAEA;IACA;IACA,MAAME,SAAS,GAAGlB,GAAG,CAACmB,MAAM,CAACH,KAAK,EAAE;MAAEI,IAAI,EAAE;IAAK,CAAC,CAAC;IACnD,MAAMC,SAAS,GAAGH,SAAS,GAAGT,MAAM,CAACS,SAAS,CAACI,GAAG,CAAC,GAAGjB,iBAAiB,CAAC,CAAC;;IAEzE;IACA,IAAI,CAACS,KAAK,CAACS,SAAS,CAAC,cAAc,EAAEP,KAAK,EAAE;MACxCQ,IAAI,EAAE,GAAG;MACTC,OAAO,EAAEJ,SAAS;MAClB;MACAK,QAAQ,EAAE,MAAM;MAChB;MACA;MACAC,MAAM,EAAE,IAAI;MACZ;MACAC,QAAQ,EAAE;IACd,CAAC,CAAC;IAEF,IAAI,CAACd,KAAK,CAACe,MAAM,CAAC,eAAe,EAAE,uBAAuB,CAAC;EAC/D;AACJ;AAEA,OAAO,MAAMC,gBAAgB,GAAG7B,oBAAoB,CAAC;EACjD8B,WAAW,EAAE5B,+BAA+B;EAC5C6B,cAAc,EAAErB,oBAAoB;EACpCsB,YAAY,EAAE,CAAC7B,qBAAqB,EAAEF,KAAK;AAC/C,CAAC,CAAC","ignoreList":[]}
@@ -8,8 +8,8 @@ export declare class BeforeAuthenticationEvent extends DomainEvent<BeforeAuthent
8
8
  eventType: "authentication.beforeAuthentication";
9
9
  getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<BeforeAuthenticationEvent>>;
10
10
  }
11
- export declare const BeforeAuthenticationHandler: import("@webiny/di").Abstraction<IEventHandler<BeforeAuthenticationEvent>>;
12
- export declare namespace BeforeAuthenticationHandler {
11
+ export declare const BeforeAuthenticationEventHandler: import("@webiny/di").Abstraction<IEventHandler<BeforeAuthenticationEvent>>;
12
+ export declare namespace BeforeAuthenticationEventHandler {
13
13
  type Interface = IEventHandler<BeforeAuthenticationEvent>;
14
14
  type Event = BeforeAuthenticationEvent;
15
15
  }
@@ -21,8 +21,8 @@ export declare class AfterAuthenticationEvent extends DomainEvent<AfterAuthentic
21
21
  eventType: "authentication.afterAuthentication";
22
22
  getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<AfterAuthenticationEvent>>;
23
23
  }
24
- export declare const AfterAuthenticationHandler: import("@webiny/di").Abstraction<IEventHandler<AfterAuthenticationEvent>>;
25
- export declare namespace AfterAuthenticationHandler {
24
+ export declare const AfterAuthenticationEventHandler: import("@webiny/di").Abstraction<IEventHandler<AfterAuthenticationEvent>>;
25
+ export declare namespace AfterAuthenticationEventHandler {
26
26
  type Interface = IEventHandler<AfterAuthenticationEvent>;
27
27
  type Event = AfterAuthenticationEvent;
28
28
  }
@@ -3,16 +3,16 @@ import { createAbstraction } from "@webiny/feature/api";
3
3
  export class BeforeAuthenticationEvent extends DomainEvent {
4
4
  eventType = "authentication.beforeAuthentication";
5
5
  getHandlerAbstraction() {
6
- return BeforeAuthenticationHandler;
6
+ return BeforeAuthenticationEventHandler;
7
7
  }
8
8
  }
9
- export const BeforeAuthenticationHandler = createAbstraction("BeforeAuthenticationHandler");
9
+ export const BeforeAuthenticationEventHandler = createAbstraction("BeforeAuthenticationEventHandler");
10
10
  export class AfterAuthenticationEvent extends DomainEvent {
11
11
  eventType = "authentication.afterAuthentication";
12
12
  getHandlerAbstraction() {
13
- return AfterAuthenticationHandler;
13
+ return AfterAuthenticationEventHandler;
14
14
  }
15
15
  }
16
- export const AfterAuthenticationHandler = createAbstraction("AfterAuthenticationHandler");
16
+ export const AfterAuthenticationEventHandler = createAbstraction("AfterAuthenticationEventHandler");
17
17
 
18
18
  //# sourceMappingURL=events.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["DomainEvent","createAbstraction","BeforeAuthenticationEvent","eventType","getHandlerAbstraction","BeforeAuthenticationHandler","AfterAuthenticationEvent","AfterAuthenticationHandler"],"sources":["events.ts"],"sourcesContent":["import { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport type { Identity } from \"~/features/security/IdentityContext/Identity.js\";\n\nexport interface BeforeAuthenticationPayload {\n token: string;\n}\n\nexport class BeforeAuthenticationEvent extends DomainEvent<BeforeAuthenticationPayload> {\n eventType = \"authentication.beforeAuthentication\" as const;\n\n getHandlerAbstraction() {\n return BeforeAuthenticationHandler;\n }\n}\n\nexport const BeforeAuthenticationHandler = createAbstraction<\n IEventHandler<BeforeAuthenticationEvent>\n>(\"BeforeAuthenticationHandler\");\n\nexport namespace BeforeAuthenticationHandler {\n export type Interface = IEventHandler<BeforeAuthenticationEvent>;\n export type Event = BeforeAuthenticationEvent;\n}\n\nexport interface AfterAuthenticationPayload {\n identity: Identity;\n token: string;\n}\n\nexport class AfterAuthenticationEvent extends DomainEvent<AfterAuthenticationPayload> {\n eventType = \"authentication.afterAuthentication\" as const;\n\n getHandlerAbstraction() {\n return AfterAuthenticationHandler;\n }\n}\n\nexport const AfterAuthenticationHandler = createAbstraction<\n IEventHandler<AfterAuthenticationEvent>\n>(\"AfterAuthenticationHandler\");\n\nexport namespace AfterAuthenticationHandler {\n export type Interface = IEventHandler<AfterAuthenticationEvent>;\n export type Event = AfterAuthenticationEvent;\n}\n"],"mappings":"AAAA,SAASA,WAAW;AACpB,SAASC,iBAAiB,QAAQ,qBAAqB;AAQvD,OAAO,MAAMC,yBAAyB,SAASF,WAAW,CAA8B;EACpFG,SAAS,GAAG,qCAAqC;EAEjDC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,2BAA2B;EACtC;AACJ;AAEA,OAAO,MAAMA,2BAA2B,GAAGJ,iBAAiB,CAE1D,6BAA6B,CAAC;AAYhC,OAAO,MAAMK,wBAAwB,SAASN,WAAW,CAA6B;EAClFG,SAAS,GAAG,oCAAoC;EAEhDC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,0BAA0B;EACrC;AACJ;AAEA,OAAO,MAAMA,0BAA0B,GAAGN,iBAAiB,CAEzD,4BAA4B,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["DomainEvent","createAbstraction","BeforeAuthenticationEvent","eventType","getHandlerAbstraction","BeforeAuthenticationEventHandler","AfterAuthenticationEvent","AfterAuthenticationEventHandler"],"sources":["events.ts"],"sourcesContent":["import { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport type { Identity } from \"~/features/security/IdentityContext/Identity.js\";\n\nexport interface BeforeAuthenticationPayload {\n token: string;\n}\n\nexport class BeforeAuthenticationEvent extends DomainEvent<BeforeAuthenticationPayload> {\n eventType = \"authentication.beforeAuthentication\" as const;\n\n getHandlerAbstraction() {\n return BeforeAuthenticationEventHandler;\n }\n}\n\nexport const BeforeAuthenticationEventHandler = createAbstraction<\n IEventHandler<BeforeAuthenticationEvent>\n>(\"BeforeAuthenticationEventHandler\");\n\nexport namespace BeforeAuthenticationEventHandler {\n export type Interface = IEventHandler<BeforeAuthenticationEvent>;\n export type Event = BeforeAuthenticationEvent;\n}\n\nexport interface AfterAuthenticationPayload {\n identity: Identity;\n token: string;\n}\n\nexport class AfterAuthenticationEvent extends DomainEvent<AfterAuthenticationPayload> {\n eventType = \"authentication.afterAuthentication\" as const;\n\n getHandlerAbstraction() {\n return AfterAuthenticationEventHandler;\n }\n}\n\nexport const AfterAuthenticationEventHandler = createAbstraction<\n IEventHandler<AfterAuthenticationEvent>\n>(\"AfterAuthenticationEventHandler\");\n\nexport namespace AfterAuthenticationEventHandler {\n export type Interface = IEventHandler<AfterAuthenticationEvent>;\n export type Event = AfterAuthenticationEvent;\n}\n"],"mappings":"AAAA,SAASA,WAAW;AACpB,SAASC,iBAAiB,QAAQ,qBAAqB;AAQvD,OAAO,MAAMC,yBAAyB,SAASF,WAAW,CAA8B;EACpFG,SAAS,GAAG,qCAAqC;EAEjDC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,gCAAgC;EAC3C;AACJ;AAEA,OAAO,MAAMA,gCAAgC,GAAGJ,iBAAiB,CAE/D,kCAAkC,CAAC;AAYrC,OAAO,MAAMK,wBAAwB,SAASN,WAAW,CAA6B;EAClFG,SAAS,GAAG,oCAAoC;EAEhDC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,+BAA+B;EAC1C;AACJ;AAEA,OAAO,MAAMA,+BAA+B,GAAGN,iBAAiB,CAE9D,iCAAiC,CAAC","ignoreList":[]}
@@ -8,8 +8,8 @@ export declare class AfterLoginEvent extends DomainEvent<AfterLoginPayload> {
8
8
  eventType: "login.afterLogin";
9
9
  getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<AfterLoginEvent>>;
10
10
  }
11
- export declare const AfterLoginHandler: import("@webiny/di").Abstraction<IEventHandler<AfterLoginEvent>>;
12
- export declare namespace AfterLoginHandler {
11
+ export declare const AfterLoginEventHandler: import("@webiny/di").Abstraction<IEventHandler<AfterLoginEvent>>;
12
+ export declare namespace AfterLoginEventHandler {
13
13
  type Interface = IEventHandler<AfterLoginEvent>;
14
14
  type Event = AfterLoginEvent;
15
15
  }
@@ -3,9 +3,9 @@ import { createAbstraction } from "@webiny/feature/api";
3
3
  export class AfterLoginEvent extends DomainEvent {
4
4
  eventType = "login.afterLogin";
5
5
  getHandlerAbstraction() {
6
- return AfterLoginHandler;
6
+ return AfterLoginEventHandler;
7
7
  }
8
8
  }
9
- export const AfterLoginHandler = createAbstraction("AfterLoginHandler");
9
+ export const AfterLoginEventHandler = createAbstraction("AfterLoginEventHandler");
10
10
 
11
11
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["DomainEvent","createAbstraction","AfterLoginEvent","eventType","getHandlerAbstraction","AfterLoginHandler"],"sources":["abstractions.ts"],"sourcesContent":["import { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport { Identity } from \"~/features/security/IdentityContext/index.js\";\n\nexport interface AfterLoginPayload {\n identity: Identity;\n}\n\nexport class AfterLoginEvent extends DomainEvent<AfterLoginPayload> {\n eventType = \"login.afterLogin\" as const;\n\n getHandlerAbstraction() {\n return AfterLoginHandler;\n }\n}\n\nexport const AfterLoginHandler =\n createAbstraction<IEventHandler<AfterLoginEvent>>(\"AfterLoginHandler\");\n\nexport namespace AfterLoginHandler {\n export type Interface = IEventHandler<AfterLoginEvent>;\n export type Event = AfterLoginEvent;\n}\n"],"mappings":"AAAA,SAASA,WAAW;AAEpB,SAASC,iBAAiB,QAAQ,qBAAqB;AAOvD,OAAO,MAAMC,eAAe,SAASF,WAAW,CAAoB;EAChEG,SAAS,GAAG,kBAAkB;EAE9BC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,iBAAiB;EAC5B;AACJ;AAEA,OAAO,MAAMA,iBAAiB,GAC1BJ,iBAAiB,CAAiC,mBAAmB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["DomainEvent","createAbstraction","AfterLoginEvent","eventType","getHandlerAbstraction","AfterLoginEventHandler"],"sources":["abstractions.ts"],"sourcesContent":["import { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport { Identity } from \"~/features/security/IdentityContext/index.js\";\n\nexport interface AfterLoginPayload {\n identity: Identity;\n}\n\nexport class AfterLoginEvent extends DomainEvent<AfterLoginPayload> {\n eventType = \"login.afterLogin\" as const;\n\n getHandlerAbstraction() {\n return AfterLoginEventHandler;\n }\n}\n\nexport const AfterLoginEventHandler =\n createAbstraction<IEventHandler<AfterLoginEvent>>(\"AfterLoginEventHandler\");\n\nexport namespace AfterLoginEventHandler {\n export type Interface = IEventHandler<AfterLoginEvent>;\n export type Event = AfterLoginEvent;\n}\n"],"mappings":"AAAA,SAASA,WAAW;AAEpB,SAASC,iBAAiB,QAAQ,qBAAqB;AAOvD,OAAO,MAAMC,eAAe,SAASF,WAAW,CAAoB;EAChEG,SAAS,GAAG,kBAAkB;EAE9BC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,sBAAsB;EACjC;AACJ;AAEA,OAAO,MAAMA,sBAAsB,GAC/BJ,iBAAiB,CAAiC,wBAAwB,CAAC","ignoreList":[]}
@@ -23,7 +23,7 @@ class CreateRoleUseCaseImpl {
23
23
  }
24
24
  const validation = createRoleValidation.safeParse(input);
25
25
  if (!validation.success) {
26
- return Result.fail(new RoleValidationError(validation.error.errors[0].message));
26
+ return Result.fail(new RoleValidationError(validation.error.issues[0].message));
27
27
  }
28
28
  const tenant = this.tenantContext.getTenant();
29
29
  const identity = this.identityContext.getIdentity();
@@ -1 +1 @@
1
- {"version":3,"names":["mdbid","createImplementation","Result","TenantContext","EventPublisher","CreateRoleUseCase","UseCaseAbstraction","RolesRepository","IdentityContext","createRoleValidation","RoleBeforeCreateEvent","RoleAfterCreateEvent","NotAuthorizedError","RoleExistsError","RoleValidationError","CreateRoleUseCaseImpl","constructor","tenantContext","identityContext","eventPublisher","repository","execute","input","hasPermission","getPermission","fail","validation","safeParse","success","error","errors","message","tenant","getTenant","identity","getIdentity","data","existingRoleResult","get","slug","isOk","role","id","name","description","permissions","system","createdOn","Date","toISOString","createdBy","displayName","type","plugin","publish","result","create","isFail","ok","abstraction","implementation","dependencies"],"sources":["CreateRoleUseCase.ts"],"sourcesContent":["import { mdbid } from \"@webiny/utils\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { TenantContext } from \"~/features/tenancy/TenantContext/index.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { CreateRoleUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { RolesRepository } from \"../shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport { createRoleValidation } from \"./schema.js\";\nimport { RoleBeforeCreateEvent, RoleAfterCreateEvent } from \"./events.js\";\nimport type { Role, CreateRoleInput } from \"../shared/types.js\";\nimport { NotAuthorizedError, RoleExistsError, RoleValidationError } from \"../shared/errors.js\";\n\nclass CreateRoleUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private tenantContext: TenantContext.Interface,\n private identityContext: IdentityContext.Interface,\n private eventPublisher: EventPublisher.Interface,\n private repository: RolesRepository.Interface\n ) {}\n\n async execute(input: CreateRoleInput): Promise<Result<Role, UseCaseAbstraction.Error>> {\n const hasPermission = await this.identityContext.getPermission(\"security.role\");\n\n if (!hasPermission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n const validation = createRoleValidation.safeParse(input);\n if (!validation.success) {\n return Result.fail(new RoleValidationError(validation.error.errors[0].message));\n }\n\n const tenant = this.tenantContext.getTenant();\n const identity = this.identityContext.getIdentity();\n const data = validation.data;\n\n // Check if role with same slug already exists\n const existingRoleResult = await this.repository.get({ slug: data.slug });\n if (existingRoleResult.isOk()) {\n return Result.fail(new RoleExistsError(data.slug));\n }\n\n const role: Role = {\n id: mdbid(),\n name: data.name,\n slug: data.slug,\n description: data.description,\n permissions: data.permissions,\n system: input.system || false,\n tenant: tenant.id,\n createdOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n plugin: false\n };\n\n await this.eventPublisher.publish(\n new RoleBeforeCreateEvent({ role, input: validation.data })\n );\n\n const result = await this.repository.create(role);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new RoleAfterCreateEvent({ role, input: validation.data })\n );\n\n return Result.ok(role);\n }\n}\n\nexport const CreateRoleUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: CreateRoleUseCaseImpl,\n dependencies: [TenantContext, IdentityContext, EventPublisher, RolesR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,IAAI,CAACV,cAAc,CAACmC,OAAO,CAC7B,IAAI3C,oBAAoB,CAAC;MAAE8B,IAAI;MAAEnB,KAAK,EAAEI,UAAU,CAACU;IAAK,CAAC,CAC7D,CAAC;IAED,OAAOlC,MAAM,CAACwD,EAAE,CAACjB,IAAI,CAAC;EAC1B;AACJ;AAEA,OAAO,MAAMpC,iBAAiB,GAAGJ,oBAAoB,CAAC;EAClD0D,WAAW,EAAErD,kBAAkB;EAC/BsD,cAAc,EAAE7C,qBAAqB;EACrC8C,YAAY,EAAE,CAAC1D,aAAa,EAAEK,eAAe,EAAEJ,cAAc,EAAEG,eAAe;AAClF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["mdbid","createImplementation","Result","TenantContext","EventPublisher","CreateRoleUseCase","UseCaseAbstraction","RolesRepository","IdentityContext","createRoleValidation","RoleBeforeCreateEvent","RoleAfterCreateEvent","NotAuthorizedError","RoleExistsError","RoleValidationError","CreateRoleUseCaseImpl","constructor","tenantContext","identityContext","eventPublisher","repository","execute","input","hasPermission","getPermission","fail","validation","safeParse","success","error","issues","message","tenant","getTenant","identity","getIdentity","data","existingRoleResult","get","slug","isOk","role","id","name","description","permissions","system","createdOn","Date","toISOString","createdBy","displayName","type","plugin","publish","result","create","isFail","ok","abstraction","implementation","dependencies"],"sources":["CreateRoleUseCase.ts"],"sourcesContent":["import { mdbid } from \"@webiny/utils\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { TenantContext } from \"~/features/tenancy/TenantContext/index.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { CreateRoleUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { RolesRepository } from \"../shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport { createRoleValidation } from \"./schema.js\";\nimport { RoleBeforeCreateEvent, RoleAfterCreateEvent } from \"./events.js\";\nimport type { Role, CreateRoleInput } from \"../shared/types.js\";\nimport { NotAuthorizedError, RoleExistsError, RoleValidationError } from \"../shared/errors.js\";\n\nclass CreateRoleUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private tenantContext: TenantContext.Interface,\n private identityContext: IdentityContext.Interface,\n private eventPublisher: EventPublisher.Interface,\n private repository: RolesRepository.Interface\n ) {}\n\n async execute(input: CreateRoleInput): Promise<Result<Role, UseCaseAbstraction.Error>> {\n const hasPermission = await this.identityContext.getPermission(\"security.role\");\n\n if (!hasPermission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n const validation = createRoleValidation.safeParse(input);\n if (!validation.success) {\n return Result.fail(new RoleValidationError(validation.error.issues[0].message));\n }\n\n const tenant = this.tenantContext.getTenant();\n const identity = this.identityContext.getIdentity();\n const data = validation.data;\n\n // Check if role with same slug already exists\n const existingRoleResult = await this.repository.get({ slug: data.slug });\n if (existingRoleResult.isOk()) {\n return Result.fail(new RoleExistsError(data.slug));\n }\n\n const role: Role = {\n id: mdbid(),\n name: data.name,\n slug: data.slug,\n description: data.description,\n permissions: data.permissions,\n system: input.system || false,\n tenant: tenant.id,\n createdOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n plugin: false\n };\n\n await this.eventPublisher.publish(\n new RoleBeforeCreateEvent({ role, input: validation.data })\n );\n\n const result = await this.repository.create(role);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new RoleAfterCreateEvent({ role, input: validation.data })\n );\n\n return Result.ok(role);\n }\n}\n\nexport const CreateRoleUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: CreateRoleUseCaseImpl,\n dependencies: [TenantContext, IdentityContext, EventPublisher, RolesRepository]\n});\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,eAAe;AACrC,SAASC,oBAAoB,QAAQ,qBAAqB;AAC1D,SAASC,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,aAAa;AACtB,SAASC,cAAc;AACvB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AAE,CAACjB,IAAI,CAAC;EAC1B;AACJ;AAEA,OAAO,MAAMpC,iBAAiB,GAAGJ,oBAAoB,CAAC;EAClD0D,WAAW,EAAErD,kBAAkB;EAC/BsD,cAAc,EAAE7C,qBAAqB;EACrC8C,YAAY,EAAE,CAAC1D,aAAa,EAAEK,eAAe,EAAEJ,cAAc,EAAEG,eAAe;AAClF,CAAC,CAAC","ignoreList":[]}
@@ -5,8 +5,8 @@ export declare class RoleBeforeCreateEvent extends DomainEvent<RoleBeforeCreateP
5
5
  eventType: "role.beforeCreate";
6
6
  getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<RoleBeforeCreateEvent>>;
7
7
  }
8
- export declare const RoleBeforeCreateHandler: import("@webiny/di").Abstraction<IEventHandler<RoleBeforeCreateEvent>>;
9
- export declare namespace RoleBeforeCreateHandler {
8
+ export declare const RoleBeforeCreateEventHandler: import("@webiny/di").Abstraction<IEventHandler<RoleBeforeCreateEvent>>;
9
+ export declare namespace RoleBeforeCreateEventHandler {
10
10
  type Interface = IEventHandler<RoleBeforeCreateEvent>;
11
11
  type Event = RoleBeforeCreateEvent;
12
12
  }
@@ -14,8 +14,8 @@ export declare class RoleAfterCreateEvent extends DomainEvent<RoleAfterCreatePay
14
14
  eventType: "role.afterCreate";
15
15
  getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<RoleAfterCreateEvent>>;
16
16
  }
17
- export declare const RoleAfterCreateHandler: import("@webiny/di").Abstraction<IEventHandler<RoleAfterCreateEvent>>;
18
- export declare namespace RoleAfterCreateHandler {
17
+ export declare const RoleAfterCreateEventHandler: import("@webiny/di").Abstraction<IEventHandler<RoleAfterCreateEvent>>;
18
+ export declare namespace RoleAfterCreateEventHandler {
19
19
  type Interface = IEventHandler<RoleAfterCreateEvent>;
20
20
  type Event = RoleAfterCreateEvent;
21
21
  }
@@ -3,16 +3,16 @@ import { DomainEvent } from "../../../eventPublisher/index.js";
3
3
  export class RoleBeforeCreateEvent extends DomainEvent {
4
4
  eventType = "role.beforeCreate";
5
5
  getHandlerAbstraction() {
6
- return RoleBeforeCreateHandler;
6
+ return RoleBeforeCreateEventHandler;
7
7
  }
8
8
  }
9
- export const RoleBeforeCreateHandler = createAbstraction("RoleBeforeCreateHandler");
9
+ export const RoleBeforeCreateEventHandler = createAbstraction("RoleBeforeCreateEventHandler");
10
10
  export class RoleAfterCreateEvent extends DomainEvent {
11
11
  eventType = "role.afterCreate";
12
12
  getHandlerAbstraction() {
13
- return RoleAfterCreateHandler;
13
+ return RoleAfterCreateEventHandler;
14
14
  }
15
15
  }
16
- export const RoleAfterCreateHandler = createAbstraction("RoleAfterCreateHandler");
16
+ export const RoleAfterCreateEventHandler = createAbstraction("RoleAfterCreateEventHandler");
17
17
 
18
18
  //# sourceMappingURL=events.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","DomainEvent","RoleBeforeCreateEvent","eventType","getHandlerAbstraction","RoleBeforeCreateHandler","RoleAfterCreateEvent","RoleAfterCreateHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport type { RoleBeforeCreatePayload, RoleAfterCreatePayload } from \"./abstractions.js\";\n\nexport class RoleBeforeCreateEvent extends DomainEvent<RoleBeforeCreatePayload> {\n eventType = \"role.beforeCreate\" as const;\n\n getHandlerAbstraction() {\n return RoleBeforeCreateHandler;\n }\n}\n\nexport const RoleBeforeCreateHandler =\n createAbstraction<IEventHandler<RoleBeforeCreateEvent>>(\"RoleBeforeCreateHandler\");\n\nexport namespace RoleBeforeCreateHandler {\n export type Interface = IEventHandler<RoleBeforeCreateEvent>;\n export type Event = RoleBeforeCreateEvent;\n}\n\nexport class RoleAfterCreateEvent extends DomainEvent<RoleAfterCreatePayload> {\n eventType = \"role.afterCreate\" as const;\n\n getHandlerAbstraction() {\n return RoleAfterCreateHandler;\n }\n}\n\nexport const RoleAfterCreateHandler =\n createAbstraction<IEventHandler<RoleAfterCreateEvent>>(\"RoleAfterCreateHandler\");\n\nexport namespace RoleAfterCreateHandler {\n export type Interface = IEventHandler<RoleAfterCreateEvent>;\n export type Event = RoleAfterCreateEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW;AAIpB,OAAO,MAAMC,qBAAqB,SAASD,WAAW,CAA0B;EAC5EE,SAAS,GAAG,mBAAmB;EAE/BC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,uBAAuB;EAClC;AACJ;AAEA,OAAO,MAAMA,uBAAuB,GAChCL,iBAAiB,CAAuC,yBAAyB,CAAC;AAOtF,OAAO,MAAMM,oBAAoB,SAASL,WAAW,CAAyB;EAC1EE,SAAS,GAAG,kBAAkB;EAE9BC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,sBAAsB;EACjC;AACJ;AAEA,OAAO,MAAMA,sBAAsB,GAC/BP,iBAAiB,CAAsC,wBAAwB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createAbstraction","DomainEvent","RoleBeforeCreateEvent","eventType","getHandlerAbstraction","RoleBeforeCreateEventHandler","RoleAfterCreateEvent","RoleAfterCreateEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport type { RoleBeforeCreatePayload, RoleAfterCreatePayload } from \"./abstractions.js\";\n\nexport class RoleBeforeCreateEvent extends DomainEvent<RoleBeforeCreatePayload> {\n eventType = \"role.beforeCreate\" as const;\n\n getHandlerAbstraction() {\n return RoleBeforeCreateEventHandler;\n }\n}\n\nexport const RoleBeforeCreateEventHandler = createAbstraction<IEventHandler<RoleBeforeCreateEvent>>(\n \"RoleBeforeCreateEventHandler\"\n);\n\nexport namespace RoleBeforeCreateEventHandler {\n export type Interface = IEventHandler<RoleBeforeCreateEvent>;\n export type Event = RoleBeforeCreateEvent;\n}\n\nexport class RoleAfterCreateEvent extends DomainEvent<RoleAfterCreatePayload> {\n eventType = \"role.afterCreate\" as const;\n\n getHandlerAbstraction() {\n return RoleAfterCreateEventHandler;\n }\n}\n\nexport const RoleAfterCreateEventHandler = createAbstraction<IEventHandler<RoleAfterCreateEvent>>(\n \"RoleAfterCreateEventHandler\"\n);\n\nexport namespace RoleAfterCreateEventHandler {\n export type Interface = IEventHandler<RoleAfterCreateEvent>;\n export type Event = RoleAfterCreateEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW;AAIpB,OAAO,MAAMC,qBAAqB,SAASD,WAAW,CAA0B;EAC5EE,SAAS,GAAG,mBAAmB;EAE/BC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,4BAA4B;EACvC;AACJ;AAEA,OAAO,MAAMA,4BAA4B,GAAGL,iBAAiB,CACzD,8BACJ,CAAC;AAOD,OAAO,MAAMM,oBAAoB,SAASL,WAAW,CAAyB;EAC1EE,SAAS,GAAG,kBAAkB;EAE9BC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,2BAA2B;EACtC;AACJ;AAEA,OAAO,MAAMA,2BAA2B,GAAGP,iBAAiB,CACxD,6BACJ,CAAC","ignoreList":[]}
@@ -5,23 +5,5 @@ export declare const createRoleValidation: z.ZodObject<{
5
5
  description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
6
6
  permissions: z.ZodArray<z.ZodObject<{
7
7
  name: z.ZodString;
8
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
9
- name: z.ZodString;
10
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
11
- name: z.ZodString;
12
- }, z.ZodTypeAny, "passthrough">>, "many">;
13
- }, "strip", z.ZodTypeAny, {
14
- permissions: z.objectOutputType<{
15
- name: z.ZodString;
16
- }, z.ZodTypeAny, "passthrough">[];
17
- name: string;
18
- description: string;
19
- slug: string;
20
- }, {
21
- permissions: z.objectInputType<{
22
- name: z.ZodString;
23
- }, z.ZodTypeAny, "passthrough">[];
24
- name: string;
25
- slug: string;
26
- description?: string | undefined;
27
- }>;
8
+ }, z.core.$loose>>;
9
+ }, z.core.$strip>;
@@ -3,9 +3,9 @@ export const createRoleValidation = z.object({
3
3
  name: z.string().min(3),
4
4
  slug: z.string().min(3),
5
5
  description: z.string().max(500).optional().default(""),
6
- permissions: z.array(z.object({
6
+ permissions: z.array(z.looseObject({
7
7
  name: z.string()
8
- }).passthrough())
8
+ }))
9
9
  });
10
10
 
11
11
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["z","createRoleValidation","object","name","string","min","slug","description","max","optional","default","permissions","array","passthrough"],"sources":["schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const createRoleValidation = z.object({\n name: z.string().min(3),\n slug: z.string().min(3),\n description: z.string().max(500).optional().default(\"\"),\n permissions: z.array(z.object({ name: z.string() }).passthrough())\n});\n"],"mappings":"AAAA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,oBAAoB,GAAGD,CAAC,CAACE,MAAM,CAAC;EACzCC,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC;EACvBC,IAAI,EAAEN,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC;EACvBE,WAAW,EAAEP,CAAC,CAACI,MAAM,CAAC,CAAC,CAACI,GAAG,CAAC,GAAG,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,OAAO,CAAC,EAAE,CAAC;EACvDC,WAAW,EAAEX,CAAC,CAACY,KAAK,CAACZ,CAAC,CAACE,MAAM,CAAC;IAAEC,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC;EAAE,CAAC,CAAC,CAACS,WAAW,CAAC,CAAC;AACrE,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["z","createRoleValidation","object","name","string","min","slug","description","max","optional","default","permissions","array","looseObject"],"sources":["schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const createRoleValidation = z.object({\n name: z.string().min(3),\n slug: z.string().min(3),\n description: z.string().max(500).optional().default(\"\"),\n permissions: z.array(z.looseObject({ name: z.string() }))\n});\n"],"mappings":"AAAA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,oBAAoB,GAAGD,CAAC,CAACE,MAAM,CAAC;EACzCC,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC;EACvBC,IAAI,EAAEN,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC;EACvBE,WAAW,EAAEP,CAAC,CAACI,MAAM,CAAC,CAAC,CAACI,GAAG,CAAC,GAAG,CAAC,CAACC,QAAQ,CAAC,CAAC,CAACC,OAAO,CAAC,EAAE,CAAC;EACvDC,WAAW,EAAEX,CAAC,CAACY,KAAK,CAACZ,CAAC,CAACa,WAAW,CAAC;IAAEV,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC;EAAE,CAAC,CAAC;AAC5D,CAAC,CAAC","ignoreList":[]}
@@ -5,8 +5,8 @@ export declare class RoleBeforeDeleteEvent extends DomainEvent<RoleBeforeDeleteP
5
5
  eventType: "role.beforeDelete";
6
6
  getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<RoleBeforeDeleteEvent>>;
7
7
  }
8
- export declare const RoleBeforeDeleteHandler: import("@webiny/di").Abstraction<IEventHandler<RoleBeforeDeleteEvent>>;
9
- export declare namespace RoleBeforeDeleteHandler {
8
+ export declare const RoleBeforeDeleteEventHandler: import("@webiny/di").Abstraction<IEventHandler<RoleBeforeDeleteEvent>>;
9
+ export declare namespace RoleBeforeDeleteEventHandler {
10
10
  type Interface = IEventHandler<RoleBeforeDeleteEvent>;
11
11
  type Event = RoleBeforeDeleteEvent;
12
12
  }
@@ -14,8 +14,8 @@ export declare class RoleAfterDeleteEvent extends DomainEvent<RoleAfterDeletePay
14
14
  eventType: "role.afterDelete";
15
15
  getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<RoleAfterDeleteEvent>>;
16
16
  }
17
- export declare const RoleAfterDeleteHandler: import("@webiny/di").Abstraction<IEventHandler<RoleAfterDeleteEvent>>;
18
- export declare namespace RoleAfterDeleteHandler {
17
+ export declare const RoleAfterDeleteEventHandler: import("@webiny/di").Abstraction<IEventHandler<RoleAfterDeleteEvent>>;
18
+ export declare namespace RoleAfterDeleteEventHandler {
19
19
  type Interface = IEventHandler<RoleAfterDeleteEvent>;
20
20
  type Event = RoleAfterDeleteEvent;
21
21
  }
@@ -3,16 +3,16 @@ import { DomainEvent } from "../../../eventPublisher/index.js";
3
3
  export class RoleBeforeDeleteEvent extends DomainEvent {
4
4
  eventType = "role.beforeDelete";
5
5
  getHandlerAbstraction() {
6
- return RoleBeforeDeleteHandler;
6
+ return RoleBeforeDeleteEventHandler;
7
7
  }
8
8
  }
9
- export const RoleBeforeDeleteHandler = createAbstraction("RoleBeforeDeleteHandler");
9
+ export const RoleBeforeDeleteEventHandler = createAbstraction("RoleBeforeDeleteEventHandler");
10
10
  export class RoleAfterDeleteEvent extends DomainEvent {
11
11
  eventType = "role.afterDelete";
12
12
  getHandlerAbstraction() {
13
- return RoleAfterDeleteHandler;
13
+ return RoleAfterDeleteEventHandler;
14
14
  }
15
15
  }
16
- export const RoleAfterDeleteHandler = createAbstraction("RoleAfterDeleteHandler");
16
+ export const RoleAfterDeleteEventHandler = createAbstraction("RoleAfterDeleteEventHandler");
17
17
 
18
18
  //# sourceMappingURL=events.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","DomainEvent","RoleBeforeDeleteEvent","eventType","getHandlerAbstraction","RoleBeforeDeleteHandler","RoleAfterDeleteEvent","RoleAfterDeleteHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport type { RoleBeforeDeletePayload, RoleAfterDeletePayload } from \"./abstractions.js\";\n\nexport class RoleBeforeDeleteEvent extends DomainEvent<RoleBeforeDeletePayload> {\n eventType = \"role.beforeDelete\" as const;\n\n getHandlerAbstraction() {\n return RoleBeforeDeleteHandler;\n }\n}\n\nexport const RoleBeforeDeleteHandler =\n createAbstraction<IEventHandler<RoleBeforeDeleteEvent>>(\"RoleBeforeDeleteHandler\");\n\nexport namespace RoleBeforeDeleteHandler {\n export type Interface = IEventHandler<RoleBeforeDeleteEvent>;\n export type Event = RoleBeforeDeleteEvent;\n}\n\nexport class RoleAfterDeleteEvent extends DomainEvent<RoleAfterDeletePayload> {\n eventType = \"role.afterDelete\" as const;\n\n getHandlerAbstraction() {\n return RoleAfterDeleteHandler;\n }\n}\n\nexport const RoleAfterDeleteHandler =\n createAbstraction<IEventHandler<RoleAfterDeleteEvent>>(\"RoleAfterDeleteHandler\");\n\nexport namespace RoleAfterDeleteHandler {\n export type Interface = IEventHandler<RoleAfterDeleteEvent>;\n export type Event = RoleAfterDeleteEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW;AAIpB,OAAO,MAAMC,qBAAqB,SAASD,WAAW,CAA0B;EAC5EE,SAAS,GAAG,mBAAmB;EAE/BC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,uBAAuB;EAClC;AACJ;AAEA,OAAO,MAAMA,uBAAuB,GAChCL,iBAAiB,CAAuC,yBAAyB,CAAC;AAOtF,OAAO,MAAMM,oBAAoB,SAASL,WAAW,CAAyB;EAC1EE,SAAS,GAAG,kBAAkB;EAE9BC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,sBAAsB;EACjC;AACJ;AAEA,OAAO,MAAMA,sBAAsB,GAC/BP,iBAAiB,CAAsC,wBAAwB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createAbstraction","DomainEvent","RoleBeforeDeleteEvent","eventType","getHandlerAbstraction","RoleBeforeDeleteEventHandler","RoleAfterDeleteEvent","RoleAfterDeleteEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport type { RoleBeforeDeletePayload, RoleAfterDeletePayload } from \"./abstractions.js\";\n\nexport class RoleBeforeDeleteEvent extends DomainEvent<RoleBeforeDeletePayload> {\n eventType = \"role.beforeDelete\" as const;\n\n getHandlerAbstraction() {\n return RoleBeforeDeleteEventHandler;\n }\n}\n\nexport const RoleBeforeDeleteEventHandler = createAbstraction<IEventHandler<RoleBeforeDeleteEvent>>(\n \"RoleBeforeDeleteEventHandler\"\n);\n\nexport namespace RoleBeforeDeleteEventHandler {\n export type Interface = IEventHandler<RoleBeforeDeleteEvent>;\n export type Event = RoleBeforeDeleteEvent;\n}\n\nexport class RoleAfterDeleteEvent extends DomainEvent<RoleAfterDeletePayload> {\n eventType = \"role.afterDelete\" as const;\n\n getHandlerAbstraction() {\n return RoleAfterDeleteEventHandler;\n }\n}\n\nexport const RoleAfterDeleteEventHandler = createAbstraction<IEventHandler<RoleAfterDeleteEvent>>(\n \"RoleAfterDeleteEventHandler\"\n);\n\nexport namespace RoleAfterDeleteEventHandler {\n export type Interface = IEventHandler<RoleAfterDeleteEvent>;\n export type Event = RoleAfterDeleteEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW;AAIpB,OAAO,MAAMC,qBAAqB,SAASD,WAAW,CAA0B;EAC5EE,SAAS,GAAG,mBAAmB;EAE/BC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,4BAA4B;EACvC;AACJ;AAEA,OAAO,MAAMA,4BAA4B,GAAGL,iBAAiB,CACzD,8BACJ,CAAC;AAOD,OAAO,MAAMM,oBAAoB,SAASL,WAAW,CAAyB;EAC1EE,SAAS,GAAG,kBAAkB;EAE9BC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,2BAA2B;EACtC;AACJ;AAEA,OAAO,MAAMA,2BAA2B,GAAGP,iBAAiB,CACxD,6BACJ,CAAC","ignoreList":[]}
@@ -19,7 +19,7 @@ class UpdateRoleUseCaseImpl {
19
19
  }
20
20
  const validation = updateRoleValidation.safeParse(input);
21
21
  if (!validation.success) {
22
- return Result.fail(new RoleValidationError(validation.error.errors[0].message));
22
+ return Result.fail(new RoleValidationError(validation.error.issues[0].message));
23
23
  }
24
24
  const existingResult = await this.repository.get({
25
25
  id
@@ -1 +1 @@
1
- {"version":3,"names":["Result","UpdateRoleUseCase","UseCase","RolesRepository","IdentityContext","EventPublisher","updateRoleValidation","RoleBeforeUpdateEvent","RoleAfterUpdateEvent","NotAuthorizedError","CannotUpdatePluginRolesError","RoleValidationError","UpdateRoleUseCaseImpl","constructor","repository","identityContext","eventPublisher","execute","id","input","hasPermission","getPermission","fail","validation","safeParse","success","error","errors","message","existingResult","get","isFail","existingRole","value","plugin","updatedRole","data","publish","original","updated","result","update","ok","createImplementation","implementation","dependencies"],"sources":["UpdateRoleUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateRoleUseCase as UseCase } from \"./abstractions.js\";\nimport { RolesRepository } from \"../shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { updateRoleValidation } from \"./schema.js\";\nimport { RoleBeforeUpdateEvent, RoleAfterUpdateEvent } from \"./events.js\";\nimport type { Role, UpdateRoleInput } from \"../shared/types.js\";\nimport {\n NotAuthorizedError,\n CannotUpdatePluginRolesError,\n RoleValidationError\n} from \"../shared/errors.js\";\n\nclass UpdateRoleUseCaseImpl implements UseCase.Interface {\n private repository: RolesRepository.Interface;\n private identityContext: IdentityContext.Interface;\n private eventPublisher: EventPublisher.Interface;\n\n constructor(\n repository: RolesRepository.Interface,\n identityContext: IdentityContext.Interface,\n eventPublisher: EventPublisher.Interface\n ) {\n this.repository = repository;\n this.identityContext = identityContext;\n this.eventPublisher = eventPublisher;\n }\n\n async execute(id: string, input: UpdateRoleInput): Promise<Result<Role, UseCase.Error>> {\n const hasPermission = await this.identityContext.getPermission(\"security.role\");\n if (!hasPermission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n const validation = updateRoleValidation.safeParse(input);\n if (!validation.success) {\n return Result.fail(new RoleValidationError(validation.error.errors[0].message));\n }\n\n const existingResult = await this.repository.get({ id });\n if (existingResult.isFail()) {\n return Result.fail(existingResult.error);\n }\n\n const existingRole = existingResult.value;\n\n // Check if role is created via plugin\n if (existingRole.plugin) {\n return Result.fail(new CannotUpdatePluginRolesError());\n }\n\n const updatedRole: Role = {\n ...existingRole,\n ...validation.data\n };\n\n await this.eventPublisher.publish(\n new RoleBeforeUpdateEvent({\n original: existingRole,\n updated: updatedRole,\n input: validation.data\n })\n );\n\n const result = await this.repository.update(updatedRole);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new RoleAfterUpdateEvent({\n original: existingRole,\n updated: updatedRole,\n input: validation.data\n })\n );\n\n return Result.ok(updatedRole);\n }\n}\n\nexport const UpdateRoleUseCase = UseCase.createImplementation({\n implementation: UpdateRoleUseCaseImpl,\n dependencies: [RolesRepository, IdentityContext, EventPublisher]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,iBAAiB,IAAIC,OAAO;AACrC,SAASC,eAAe;AACxB,SAASC,eAAe;AACxB,SAASC,cAAc;AACvB,SAASC,oBAAoB;AAC7B,SAASC,qBAAqB,EAAEC,oBAAoB;AAEpD,SACIC,kBAAkB,EAClBC,4BAA4B,EAC5BC,mBAAmB;AAGvB,MAAMC,qBAAqB,CAA8B;EAKrDC,WAAWA,CACPC,UAAqC,EACrCC,eA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AAW;MACpBhB,KAAK,EAAEI,UAAU,CAACa;IACtB,CAAC,CACL,CAAC;IAED,MAAMI,MAAM,GAAG,MAAM,IAAI,CAAC1B,UAAU,CAAC2B,MAAM,CAACN,WAAW,CAAC;IAExD,IAAIK,MAAM,CAACT,MAAM,CAAC,CAAC,EAAE;MACjB,OAAO/B,MAAM,CAACsB,IAAI,CAACkB,MAAM,CAACd,KAAK,CAAC;IACpC;IAEA,MAAM,IAAI,CAACV,cAAc,CAACqB,OAAO,CAC7B,IAAI7B,oBAAoB,CAAC;MACrB8B,QAAQ,EAAEN,YAAY;MACtBO,OAAO,EAAEJ,WAAW;MACpBhB,KAAK,EAAEI,UAAU,CAACa;IACtB,CAAC,CACL,CAAC;IAED,OAAOpC,MAAM,CAAC0C,EAAE,CAACP,WAAW,CAAC;EACjC;AACJ;AAEA,OAAO,MAAMlC,iBAAiB,GAAGC,OAAO,CAACyC,oBAAoB,CAAC;EAC1DC,cAAc,EAAEhC,qBAAqB;EACrCiC,YAAY,EAAE,CAAC1C,eAAe,EAAEC,eAAe,EAAEC,cAAc;AACnE,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Result","UpdateRoleUseCase","UseCase","RolesRepository","IdentityContext","EventPublisher","updateRoleValidation","RoleBeforeUpdateEvent","RoleAfterUpdateEvent","NotAuthorizedError","CannotUpdatePluginRolesError","RoleValidationError","UpdateRoleUseCaseImpl","constructor","repository","identityContext","eventPublisher","execute","id","input","hasPermission","getPermission","fail","validation","safeParse","success","error","issues","message","existingResult","get","isFail","existingRole","value","plugin","updatedRole","data","publish","original","updated","result","update","ok","createImplementation","implementation","dependencies"],"sources":["UpdateRoleUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UpdateRoleUseCase as UseCase } from \"./abstractions.js\";\nimport { RolesRepository } from \"../shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { updateRoleValidation } from \"./schema.js\";\nimport { RoleBeforeUpdateEvent, RoleAfterUpdateEvent } from \"./events.js\";\nimport type { Role, UpdateRoleInput } from \"../shared/types.js\";\nimport {\n NotAuthorizedError,\n CannotUpdatePluginRolesError,\n RoleValidationError\n} from \"../shared/errors.js\";\n\nclass UpdateRoleUseCaseImpl implements UseCase.Interface {\n private repository: RolesRepository.Interface;\n private identityContext: IdentityContext.Interface;\n private eventPublisher: EventPublisher.Interface;\n\n constructor(\n repository: RolesRepository.Interface,\n identityContext: IdentityContext.Interface,\n eventPublisher: EventPublisher.Interface\n ) {\n this.repository = repository;\n this.identityContext = identityContext;\n this.eventPublisher = eventPublisher;\n }\n\n async execute(id: string, input: UpdateRoleInput): Promise<Result<Role, UseCase.Error>> {\n const hasPermission = await this.identityContext.getPermission(\"security.role\");\n if (!hasPermission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n const validation = updateRoleValidation.safeParse(input);\n if (!validation.success) {\n return Result.fail(new RoleValidationError(validation.error.issues[0].message));\n }\n\n const existingResult = await this.repository.get({ id });\n if (existingResult.isFail()) {\n return Result.fail(existingResult.error);\n }\n\n const existingRole = existingResult.value;\n\n // Check if role is created via plugin\n if (existingRole.plugin) {\n return Result.fail(new CannotUpdatePluginRolesError());\n }\n\n const updatedRole: Role = {\n ...existingRole,\n ...validation.data\n };\n\n await this.eventPublisher.publish(\n new RoleBeforeUpdateEvent({\n original: existingRole,\n updated: updatedRole,\n input: validation.data\n })\n );\n\n const result = await this.repository.update(updatedRole);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new RoleAfterUpdateEvent({\n original: existingRole,\n updated: updatedRole,\n input: validation.data\n })\n );\n\n return Result.ok(updatedRole);\n }\n}\n\nexport const UpdateRoleUseCase = UseCase.createImplementation({\n implementation: UpdateRoleUseCaseImpl,\n dependencies: [RolesRepository, IdentityContext, EventPublisher]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AA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ACsB,IAAI,CAAC,IAAIZ,4BAA4B,CAAC,CAAC,CAAC;IAC1D;IAEA,MAAMyB,WAAiB,GAAG;MACtB,GAAGH,YAAY;MACf,GAAGT,UAAU,CAACa;IAClB,CAAC;IAED,MAAM,IAAI,CAACpB,cAAc,CAACqB,OAAO,CAC7B,IAAI9B,qBAAqB,CAAC;MACtB+B,QAAQ,EAAEN,YAAY;MACtBO,OAAO,EAAEJ,WAAW;MACpBhB,KAAK,EAAEI,UAAU,CAACa;IACtB,CAAC,CACL,CAAC;IAED,MAAMI,MAAM,GAAG,MAAM,IAAI,CAAC1B,UAAU,CAAC2B,MAAM,CAACN,WAAW,CAAC;IAExD,IAAIK,MAAM,CAACT,MAAM,CAAC,CAAC,EAAE;MACjB,OAAO/B,MAAM,CAACsB,IAAI,CAACkB,MAAM,CAACd,KAAK,CAAC;IACpC;IAEA,MAAM,IAAI,CAACV,cAAc,CAACqB,OAAO,CAC7B,IAAI7B,oBAAoB,CAAC;MACrB8B,QAAQ,EAAEN,YAAY;MACtBO,OAAO,EAAEJ,WAAW;MACpBhB,KAAK,EAAEI,UAAU,CAACa;IACtB,CAAC,CACL,CAAC;IAED,OAAOpC,MAAM,CAAC0C,EAAE,CAACP,WAAW,CAAC;EACjC;AACJ;AAEA,OAAO,MAAMlC,iBAAiB,GAAGC,OAAO,CAACyC,oBAAoB,CAAC;EAC1DC,cAAc,EAAEhC,qBAAqB;EACrCiC,YAAY,EAAE,CAAC1C,eAAe,EAAEC,eAAe,EAAEC,cAAc;AACnE,CAAC,CAAC","ignoreList":[]}
@@ -5,8 +5,8 @@ export declare class RoleBeforeUpdateEvent extends DomainEvent<RoleBeforeUpdateP
5
5
  eventType: "role.beforeUpdate";
6
6
  getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<RoleBeforeUpdateEvent>>;
7
7
  }
8
- export declare const RoleBeforeUpdateHandler: import("@webiny/di").Abstraction<IEventHandler<RoleBeforeUpdateEvent>>;
9
- export declare namespace RoleBeforeUpdateHandler {
8
+ export declare const RoleBeforeUpdateEventHandler: import("@webiny/di").Abstraction<IEventHandler<RoleBeforeUpdateEvent>>;
9
+ export declare namespace RoleBeforeUpdateEventHandler {
10
10
  type Interface = IEventHandler<RoleBeforeUpdateEvent>;
11
11
  type Event = RoleBeforeUpdateEvent;
12
12
  }
@@ -14,8 +14,8 @@ export declare class RoleAfterUpdateEvent extends DomainEvent<RoleAfterUpdatePay
14
14
  eventType: "role.afterUpdate";
15
15
  getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<RoleAfterUpdateEvent>>;
16
16
  }
17
- export declare const RoleAfterUpdateHandler: import("@webiny/di").Abstraction<IEventHandler<RoleAfterUpdateEvent>>;
18
- export declare namespace RoleAfterUpdateHandler {
17
+ export declare const RoleAfterUpdateEventHandler: import("@webiny/di").Abstraction<IEventHandler<RoleAfterUpdateEvent>>;
18
+ export declare namespace RoleAfterUpdateEventHandler {
19
19
  type Interface = IEventHandler<RoleAfterUpdateEvent>;
20
20
  type Event = RoleAfterUpdateEvent;
21
21
  }
@@ -3,16 +3,16 @@ import { DomainEvent } from "../../../eventPublisher/index.js";
3
3
  export class RoleBeforeUpdateEvent extends DomainEvent {
4
4
  eventType = "role.beforeUpdate";
5
5
  getHandlerAbstraction() {
6
- return RoleBeforeUpdateHandler;
6
+ return RoleBeforeUpdateEventHandler;
7
7
  }
8
8
  }
9
- export const RoleBeforeUpdateHandler = createAbstraction("RoleBeforeUpdateHandler");
9
+ export const RoleBeforeUpdateEventHandler = createAbstraction("RoleBeforeUpdateEventHandler");
10
10
  export class RoleAfterUpdateEvent extends DomainEvent {
11
11
  eventType = "role.afterUpdate";
12
12
  getHandlerAbstraction() {
13
- return RoleAfterUpdateHandler;
13
+ return RoleAfterUpdateEventHandler;
14
14
  }
15
15
  }
16
- export const RoleAfterUpdateHandler = createAbstraction("RoleAfterUpdateHandler");
16
+ export const RoleAfterUpdateEventHandler = createAbstraction("RoleAfterUpdateEventHandler");
17
17
 
18
18
  //# sourceMappingURL=events.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","DomainEvent","RoleBeforeUpdateEvent","eventType","getHandlerAbstraction","RoleBeforeUpdateHandler","RoleAfterUpdateEvent","RoleAfterUpdateHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport type { RoleBeforeUpdatePayload, RoleAfterUpdatePayload } from \"./abstractions.js\";\n\nexport class RoleBeforeUpdateEvent extends DomainEvent<RoleBeforeUpdatePayload> {\n eventType = \"role.beforeUpdate\" as const;\n\n getHandlerAbstraction() {\n return RoleBeforeUpdateHandler;\n }\n}\n\nexport const RoleBeforeUpdateHandler =\n createAbstraction<IEventHandler<RoleBeforeUpdateEvent>>(\"RoleBeforeUpdateHandler\");\n\nexport namespace RoleBeforeUpdateHandler {\n export type Interface = IEventHandler<RoleBeforeUpdateEvent>;\n export type Event = RoleBeforeUpdateEvent;\n}\n\nexport class RoleAfterUpdateEvent extends DomainEvent<RoleAfterUpdatePayload> {\n eventType = \"role.afterUpdate\" as const;\n\n getHandlerAbstraction() {\n return RoleAfterUpdateHandler;\n }\n}\n\nexport const RoleAfterUpdateHandler =\n createAbstraction<IEventHandler<RoleAfterUpdateEvent>>(\"RoleAfterUpdateHandler\");\n\nexport namespace RoleAfterUpdateHandler {\n export type Interface = IEventHandler<RoleAfterUpdateEvent>;\n export type Event = RoleAfterUpdateEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW;AAIpB,OAAO,MAAMC,qBAAqB,SAASD,WAAW,CAA0B;EAC5EE,SAAS,GAAG,mBAAmB;EAE/BC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,uBAAuB;EAClC;AACJ;AAEA,OAAO,MAAMA,uBAAuB,GAChCL,iBAAiB,CAAuC,yBAAyB,CAAC;AAOtF,OAAO,MAAMM,oBAAoB,SAASL,WAAW,CAAyB;EAC1EE,SAAS,GAAG,kBAAkB;EAE9BC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,sBAAsB;EACjC;AACJ;AAEA,OAAO,MAAMA,sBAAsB,GAC/BP,iBAAiB,CAAsC,wBAAwB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createAbstraction","DomainEvent","RoleBeforeUpdateEvent","eventType","getHandlerAbstraction","RoleBeforeUpdateEventHandler","RoleAfterUpdateEvent","RoleAfterUpdateEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport type { RoleBeforeUpdatePayload, RoleAfterUpdatePayload } from \"./abstractions.js\";\n\nexport class RoleBeforeUpdateEvent extends DomainEvent<RoleBeforeUpdatePayload> {\n eventType = \"role.beforeUpdate\" as const;\n\n getHandlerAbstraction() {\n return RoleBeforeUpdateEventHandler;\n }\n}\n\nexport const RoleBeforeUpdateEventHandler = createAbstraction<IEventHandler<RoleBeforeUpdateEvent>>(\n \"RoleBeforeUpdateEventHandler\"\n);\n\nexport namespace RoleBeforeUpdateEventHandler {\n export type Interface = IEventHandler<RoleBeforeUpdateEvent>;\n export type Event = RoleBeforeUpdateEvent;\n}\n\nexport class RoleAfterUpdateEvent extends DomainEvent<RoleAfterUpdatePayload> {\n eventType = \"role.afterUpdate\" as const;\n\n getHandlerAbstraction() {\n return RoleAfterUpdateEventHandler;\n }\n}\n\nexport const RoleAfterUpdateEventHandler = createAbstraction<IEventHandler<RoleAfterUpdateEvent>>(\n \"RoleAfterUpdateEventHandler\"\n);\n\nexport namespace RoleAfterUpdateEventHandler {\n export type Interface = IEventHandler<RoleAfterUpdateEvent>;\n export type Event = RoleAfterUpdateEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW;AAIpB,OAAO,MAAMC,qBAAqB,SAASD,WAAW,CAA0B;EAC5EE,SAAS,GAAG,mBAAmB;EAE/BC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,4BAA4B;EACvC;AACJ;AAEA,OAAO,MAAMA,4BAA4B,GAAGL,iBAAiB,CACzD,8BACJ,CAAC;AAOD,OAAO,MAAMM,oBAAoB,SAASL,WAAW,CAAyB;EAC1EE,SAAS,GAAG,kBAAkB;EAE9BC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,2BAA2B;EACtC;AACJ;AAEA,OAAO,MAAMA,2BAA2B,GAAGP,iBAAiB,CACxD,6BACJ,CAAC","ignoreList":[]}
@@ -4,21 +4,5 @@ export declare const updateRoleValidation: z.ZodObject<{
4
4
  description: z.ZodOptional<z.ZodString>;
5
5
  permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
6
6
  name: z.ZodString;
7
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
8
- name: z.ZodString;
9
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
10
- name: z.ZodString;
11
- }, z.ZodTypeAny, "passthrough">>, "many">>;
12
- }, "strip", z.ZodTypeAny, {
13
- permissions?: z.objectOutputType<{
14
- name: z.ZodString;
15
- }, z.ZodTypeAny, "passthrough">[] | undefined;
16
- name?: string | undefined;
17
- description?: string | undefined;
18
- }, {
19
- permissions?: z.objectInputType<{
20
- name: z.ZodString;
21
- }, z.ZodTypeAny, "passthrough">[] | undefined;
22
- name?: string | undefined;
23
- description?: string | undefined;
24
- }>;
7
+ }, z.core.$loose>>>;
8
+ }, z.core.$strip>;
@@ -2,9 +2,9 @@ import { z } from "zod";
2
2
  export const updateRoleValidation = z.object({
3
3
  name: z.string().min(3).optional(),
4
4
  description: z.string().max(500).optional(),
5
- permissions: z.array(z.object({
5
+ permissions: z.array(z.looseObject({
6
6
  name: z.string()
7
- }).passthrough()).optional()
7
+ })).optional()
8
8
  });
9
9
 
10
10
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["z","updateRoleValidation","object","name","string","min","optional","description","max","permissions","array","passthrough"],"sources":["schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const updateRoleValidation = z.object({\n name: z.string().min(3).optional(),\n description: z.string().max(500).optional(),\n permissions: z.array(z.object({ name: z.string() }).passthrough()).optional()\n});\n"],"mappings":"AAAA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,oBAAoB,GAAGD,CAAC,CAACE,MAAM,CAAC;EACzCC,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAClCC,WAAW,EAAEP,CAAC,CAACI,MAAM,CAAC,CAAC,CAACI,GAAG,CAAC,GAAG,CAAC,CAACF,QAAQ,CAAC,CAAC;EAC3CG,WAAW,EAAET,CAAC,CAACU,KAAK,CAACV,CAAC,CAACE,MAAM,CAAC;IAAEC,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC;EAAE,CAAC,CAAC,CAACO,WAAW,CAAC,CAAC,CAAC,CAACL,QAAQ,CAAC;AAChF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["z","updateRoleValidation","object","name","string","min","optional","description","max","permissions","array","looseObject"],"sources":["schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const updateRoleValidation = z.object({\n name: z.string().min(3).optional(),\n description: z.string().max(500).optional(),\n permissions: z.array(z.looseObject({ name: z.string() })).optional()\n});\n"],"mappings":"AAAA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,oBAAoB,GAAGD,CAAC,CAACE,MAAM,CAAC;EACzCC,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAClCC,WAAW,EAAEP,CAAC,CAACI,MAAM,CAAC,CAAC,CAACI,GAAG,CAAC,GAAG,CAAC,CAACF,QAAQ,CAAC,CAAC;EAC3CG,WAAW,EAAET,CAAC,CAACU,KAAK,CAACV,CAAC,CAACW,WAAW,CAAC;IAAER,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC;EAAE,CAAC,CAAC,CAAC,CAACE,QAAQ,CAAC;AACvE,CAAC,CAAC","ignoreList":[]}
@@ -23,7 +23,7 @@ export class CreateTeamUseCase {
23
23
  }
24
24
  const validation = createTeamValidation.safeParse(input);
25
25
  if (!validation.success) {
26
- return Result.fail(new TeamValidationError(validation.error.errors[0].message));
26
+ return Result.fail(new TeamValidationError(validation.error.issues[0].message));
27
27
  }
28
28
  const tenant = this.tenantContext.getTenant();
29
29
  const identity = this.identityContext.getIdentity();