@webiny/api-core 6.6.0-alpha.1 → 6.6.0-alpha.10

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 (264) hide show
  1. package/ApiCoreFeature.js +6 -2
  2. package/ApiCoreFeature.js.map +1 -1
  3. package/exports/api/tasks.d.ts +1 -0
  4. package/exports/api/tasks.js +1 -1
  5. package/exports/api.d.ts +1 -1
  6. package/exports/api.js +1 -1
  7. package/features/ai/Ai.d.ts +3 -1
  8. package/features/ai/Ai.js +36 -28
  9. package/features/ai/Ai.js.map +1 -1
  10. package/features/ai/AiModelRegistry.d.ts +14 -0
  11. package/features/ai/AiModelRegistry.js +39 -0
  12. package/features/ai/AiModelRegistry.js.map +1 -0
  13. package/features/ai/AiSdkToolHandlerResolver.d.ts +11 -0
  14. package/features/ai/AiSdkToolHandlerResolver.js +19 -0
  15. package/features/ai/AiSdkToolHandlerResolver.js.map +1 -0
  16. package/features/ai/AiSdkTools.d.ts +4 -3
  17. package/features/ai/AiSdkTools.js +11 -9
  18. package/features/ai/AiSdkTools.js.map +1 -1
  19. package/features/ai/AnthropicSdkFactory.js +12 -4
  20. package/features/ai/AnthropicSdkFactory.js.map +1 -1
  21. package/features/ai/DEVELOPERS.md +183 -0
  22. package/features/ai/GoogleSdkFactory.d.ts +10 -0
  23. package/features/ai/GoogleSdkFactory.js +65 -0
  24. package/features/ai/GoogleSdkFactory.js.map +1 -0
  25. package/features/ai/OpenAiSdkFactory.js +51 -11
  26. package/features/ai/OpenAiSdkFactory.js.map +1 -1
  27. package/features/ai/OpenRouterSdkFactory.d.ts +10 -0
  28. package/features/ai/OpenRouterSdkFactory.js +112 -0
  29. package/features/ai/OpenRouterSdkFactory.js.map +1 -0
  30. package/features/ai/RemoteAiModelCatalog.d.ts +13 -0
  31. package/features/ai/RemoteAiModelCatalog.js +74 -0
  32. package/features/ai/RemoteAiModelCatalog.js.map +1 -0
  33. package/features/ai/abstractions.d.ts +82 -6
  34. package/features/ai/abstractions.js +6 -2
  35. package/features/ai/abstractions.js.map +1 -1
  36. package/features/ai/feature.js +10 -0
  37. package/features/ai/feature.js.map +1 -1
  38. package/features/ai/index.d.ts +2 -4
  39. package/features/ai/index.js +1 -1
  40. package/features/debugger/Debugger.d.ts +30 -0
  41. package/features/debugger/Debugger.js +142 -0
  42. package/features/debugger/Debugger.js.map +1 -0
  43. package/features/debugger/DebuggerRouteDecorator.d.ts +45 -0
  44. package/features/debugger/DebuggerRouteDecorator.js +102 -0
  45. package/features/debugger/DebuggerRouteDecorator.js.map +1 -0
  46. package/features/debugger/GraphQLDebuggerTransport.d.ts +28 -0
  47. package/features/debugger/GraphQLDebuggerTransport.js +45 -0
  48. package/features/debugger/GraphQLDebuggerTransport.js.map +1 -0
  49. package/features/debugger/__tests__/matchNamespace.test.d.ts +1 -0
  50. package/features/debugger/__tests__/matchNamespace.test.js +68 -0
  51. package/features/debugger/__tests__/matchNamespace.test.js.map +1 -0
  52. package/features/debugger/__tests__/serialize.test.d.ts +1 -0
  53. package/features/debugger/__tests__/serialize.test.js +220 -0
  54. package/features/debugger/__tests__/serialize.test.js.map +1 -0
  55. package/features/debugger/abstractions.d.ts +100 -0
  56. package/features/debugger/abstractions.js +6 -0
  57. package/features/debugger/abstractions.js.map +1 -0
  58. package/features/debugger/feature.d.ts +5 -0
  59. package/features/debugger/feature.js +15 -0
  60. package/features/debugger/feature.js.map +1 -0
  61. package/features/debugger/index.d.ts +12 -0
  62. package/features/debugger/index.js +7 -0
  63. package/features/debugger/limits.d.ts +18 -0
  64. package/features/debugger/limits.js +11 -0
  65. package/features/debugger/limits.js.map +1 -0
  66. package/features/debugger/matchNamespace.d.ts +14 -0
  67. package/features/debugger/matchNamespace.js +35 -0
  68. package/features/debugger/matchNamespace.js.map +1 -0
  69. package/features/debugger/parseNamespaceHeader.d.ts +7 -0
  70. package/features/debugger/parseNamespaceHeader.js +16 -0
  71. package/features/debugger/parseNamespaceHeader.js.map +1 -0
  72. package/features/debugger/permissions.d.ts +14 -0
  73. package/features/debugger/permissions.js +8 -0
  74. package/features/debugger/permissions.js.map +1 -0
  75. package/features/debugger/permissionsSchema.d.ts +17 -0
  76. package/features/debugger/permissionsSchema.js +18 -0
  77. package/features/debugger/permissionsSchema.js.map +1 -0
  78. package/features/debugger/serialize.d.ts +11 -0
  79. package/features/debugger/serialize.js +121 -0
  80. package/features/debugger/serialize.js.map +1 -0
  81. package/features/encryption/BuildParamsEncryptionConfig.d.ts +13 -0
  82. package/features/encryption/BuildParamsEncryptionConfig.js +19 -0
  83. package/features/encryption/BuildParamsEncryptionConfig.js.map +1 -0
  84. package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
  85. package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
  86. package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
  87. package/features/encryption/EncryptionService.d.ts +3 -2
  88. package/features/encryption/EncryptionService.js +15 -13
  89. package/features/encryption/EncryptionService.js.map +1 -1
  90. package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
  91. package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
  92. package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
  93. package/features/encryption/abstractions.d.ts +26 -0
  94. package/features/encryption/abstractions.js +3 -1
  95. package/features/encryption/abstractions.js.map +1 -1
  96. package/features/encryption/feature.js +2 -0
  97. package/features/encryption/feature.js.map +1 -1
  98. package/features/encryption/index.d.ts +3 -0
  99. package/features/encryption/index.js +3 -1
  100. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +13 -1
  101. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -1
  102. package/features/hashing/BuildParamsHashingConfig.d.ts +11 -0
  103. package/features/hashing/BuildParamsHashingConfig.js +18 -0
  104. package/features/hashing/BuildParamsHashingConfig.js.map +1 -0
  105. package/features/hashing/ScryptHasher.d.ts +2 -2
  106. package/features/hashing/ScryptHasher.js +6 -8
  107. package/features/hashing/ScryptHasher.js.map +1 -1
  108. package/features/hashing/abstractions.d.ts +15 -0
  109. package/features/hashing/abstractions.js +2 -1
  110. package/features/hashing/abstractions.js.map +1 -1
  111. package/features/hashing/feature.js +2 -0
  112. package/features/hashing/feature.js.map +1 -1
  113. package/features/hashing/index.d.ts +1 -0
  114. package/features/hashing/index.js +1 -1
  115. package/features/httpClient/HttpClient.d.ts +7 -0
  116. package/features/httpClient/HttpClient.js +72 -0
  117. package/features/httpClient/HttpClient.js.map +1 -0
  118. package/features/httpClient/HttpRequestError.d.ts +10 -0
  119. package/features/httpClient/HttpRequestError.js +13 -0
  120. package/features/httpClient/HttpRequestError.js.map +1 -0
  121. package/features/httpClient/HttpStatusError.d.ts +12 -0
  122. package/features/httpClient/HttpStatusError.js +12 -0
  123. package/features/httpClient/HttpStatusError.js.map +1 -0
  124. package/features/httpClient/abstractions.d.ts +32 -0
  125. package/features/httpClient/abstractions.js +5 -0
  126. package/features/httpClient/abstractions.js.map +1 -0
  127. package/features/{logger → httpClient}/feature.d.ts +1 -1
  128. package/features/httpClient/feature.js +11 -0
  129. package/features/httpClient/feature.js.map +1 -0
  130. package/features/httpClient/index.d.ts +3 -0
  131. package/features/httpClient/index.js +3 -0
  132. package/features/keyValueStore/GlobalKeyValueStore.d.ts +9 -3
  133. package/features/keyValueStore/GlobalKeyValueStore.js +12 -2
  134. package/features/keyValueStore/GlobalKeyValueStore.js.map +1 -1
  135. package/features/keyValueStore/KeyValueStore.d.ts +6 -2
  136. package/features/keyValueStore/KeyValueStore.js +13 -3
  137. package/features/keyValueStore/KeyValueStore.js.map +1 -1
  138. package/features/keyValueStore/KeyValueStoreRepository.d.ts +8 -2
  139. package/features/keyValueStore/KeyValueStoreRepository.js +82 -4
  140. package/features/keyValueStore/KeyValueStoreRepository.js.map +1 -1
  141. package/features/keyValueStore/abstractions.d.ts +132 -14
  142. package/features/keyValueStore/abstractions.js.map +1 -1
  143. package/features/keyValueStore/errors.d.ts +29 -0
  144. package/features/keyValueStore/errors.js +49 -1
  145. package/features/keyValueStore/errors.js.map +1 -1
  146. package/features/keyValueStore/index.d.ts +4 -1
  147. package/features/keyValueStore/index.js +1 -1
  148. package/features/logger/NullLogger.d.ts +10 -0
  149. package/features/logger/NullLogger.js +12 -0
  150. package/features/logger/NullLogger.js.map +1 -0
  151. package/features/logger/index.d.ts +1 -0
  152. package/features/logger/index.js +1 -0
  153. package/features/publicUrls/NullPublicUrls.d.ts +11 -0
  154. package/features/publicUrls/NullPublicUrls.js +17 -0
  155. package/features/publicUrls/NullPublicUrls.js.map +1 -0
  156. package/features/publicUrls/PublicUrl.d.ts +24 -0
  157. package/features/publicUrls/PublicUrl.js +43 -0
  158. package/features/publicUrls/PublicUrl.js.map +1 -0
  159. package/features/publicUrls/__tests__/PublicUrl.test.d.ts +1 -0
  160. package/features/publicUrls/__tests__/PublicUrl.test.js +38 -0
  161. package/features/publicUrls/__tests__/PublicUrl.test.js.map +1 -0
  162. package/features/publicUrls/__tests__/PublicUrls.test.d.ts +1 -0
  163. package/features/publicUrls/__tests__/PublicUrls.test.js +14 -0
  164. package/features/publicUrls/__tests__/PublicUrls.test.js.map +1 -0
  165. package/features/publicUrls/abstractions.d.ts +27 -0
  166. package/features/publicUrls/abstractions.js +5 -0
  167. package/features/publicUrls/abstractions.js.map +1 -0
  168. package/features/publicUrls/feature.d.ts +8 -0
  169. package/features/publicUrls/feature.js +11 -0
  170. package/features/publicUrls/feature.js.map +1 -0
  171. package/features/publicUrls/index.d.ts +3 -0
  172. package/features/publicUrls/index.js +3 -0
  173. package/features/requestContext/RawAssumePermissions.d.ts +14 -0
  174. package/features/requestContext/RawAssumePermissions.js +19 -0
  175. package/features/requestContext/RawAssumePermissions.js.map +1 -0
  176. package/features/requestContext/abstractions.d.ts +22 -0
  177. package/features/requestContext/abstractions.js +2 -1
  178. package/features/requestContext/abstractions.js.map +1 -1
  179. package/features/requestContext/extractAssumePermissions.d.ts +14 -0
  180. package/features/requestContext/extractAssumePermissions.js +32 -0
  181. package/features/requestContext/extractAssumePermissions.js.map +1 -0
  182. package/features/requestContext/feature.d.ts +2 -1
  183. package/features/requestContext/feature.js +2 -0
  184. package/features/requestContext/feature.js.map +1 -1
  185. package/features/requestContext/index.d.ts +3 -1
  186. package/features/requestContext/index.js +2 -1
  187. package/features/security/IdentityContext/IdentityContext.d.ts +6 -2
  188. package/features/security/IdentityContext/IdentityContext.js +24 -7
  189. package/features/security/IdentityContext/IdentityContext.js.map +1 -1
  190. package/features/security/IdentityContext/abstractions.d.ts +6 -1
  191. package/features/security/IdentityContext/abstractions.js.map +1 -1
  192. package/features/security/authorization/AuthorizationContext/AuthorizationContext.d.ts +13 -3
  193. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js +35 -22
  194. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js.map +1 -1
  195. package/features/security/authorization/AuthorizationContext/abstractions.d.ts +2 -0
  196. package/features/security/authorization/AuthorizationContext/abstractions.js.map +1 -1
  197. package/features/security/authorization/AuthorizationContext/feature.js +6 -1
  198. package/features/security/authorization/AuthorizationContext/feature.js.map +1 -1
  199. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
  200. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
  201. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
  202. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
  203. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
  204. package/features/security/roles/Installer/RolesInstaller.js +1 -0
  205. package/features/security/roles/Installer/RolesInstaller.js.map +1 -1
  206. package/features/task/TaskDefinition/abstractions.d.ts +13 -20
  207. package/features/task/TaskDefinition/abstractions.js.map +1 -1
  208. package/features/tenancy/TenantContext/TenantContext.d.ts +5 -1
  209. package/features/tenancy/TenantContext/TenantContext.js +31 -23
  210. package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
  211. package/features/users/shared/loaders.js.map +1 -1
  212. package/features/users/shared/types.d.ts +9 -7
  213. package/features/wcp/WcpContext/WcpContext.d.ts +6 -1
  214. package/features/wcp/WcpContext/WcpContext.js +17 -2
  215. package/features/wcp/WcpContext/WcpContext.js.map +1 -1
  216. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +9 -73
  217. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +25 -5
  218. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  219. package/features/wcp/WcpLicenseLoader.js.map +1 -1
  220. package/features/wcp/resolveWcpProjectEnvironment.d.ts +1 -1
  221. package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -1
  222. package/graphql/ApiCoreSchemaFactory.d.ts +1 -0
  223. package/graphql/ApiCoreSchemaFactory.js +7 -1
  224. package/graphql/ApiCoreSchemaFactory.js.map +1 -1
  225. package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +1 -0
  226. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +4 -0
  227. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -1
  228. package/graphql/security/SecuritySchemaFactory.d.ts +1 -0
  229. package/graphql/security/SecuritySchemaFactory.js +4 -0
  230. package/graphql/security/SecuritySchemaFactory.js.map +1 -1
  231. package/graphql/system/SystemSchemaFactory.d.ts +1 -0
  232. package/graphql/system/SystemSchemaFactory.js +4 -0
  233. package/graphql/system/SystemSchemaFactory.js.map +1 -1
  234. package/graphql/users/UsersSchemaFactory.d.ts +1 -0
  235. package/graphql/users/UsersSchemaFactory.js +4 -0
  236. package/graphql/users/UsersSchemaFactory.js.map +1 -1
  237. package/graphql/wcp/WcpSchemaFactory.d.ts +1 -0
  238. package/graphql/wcp/WcpSchemaFactory.js +5 -1
  239. package/graphql/wcp/WcpSchemaFactory.js.map +1 -1
  240. package/idp/JwksCache.d.ts +14 -3
  241. package/idp/JwksCache.js +97 -17
  242. package/idp/JwksCache.js.map +1 -1
  243. package/idp/JwksStoreFeature.d.ts +8 -0
  244. package/idp/JwksStoreFeature.js +11 -0
  245. package/idp/JwksStoreFeature.js.map +1 -0
  246. package/idp/MemoryJwksStore.d.ts +14 -0
  247. package/idp/MemoryJwksStore.js +21 -0
  248. package/idp/MemoryJwksStore.js.map +1 -0
  249. package/idp/OidcJwtIdentityProvider.js +5 -1
  250. package/idp/OidcJwtIdentityProvider.js.map +1 -1
  251. package/idp/abstractions.d.ts +24 -0
  252. package/idp/abstractions.js +2 -1
  253. package/idp/abstractions.js.map +1 -1
  254. package/idp/feature.js +1 -2
  255. package/idp/feature.js.map +1 -1
  256. package/idp/index.d.ts +1 -0
  257. package/idp/index.js +1 -0
  258. package/package.json +21 -21
  259. package/types/users.d.ts +2 -3
  260. package/features/logger/LoggerService.d.ts +0 -14
  261. package/features/logger/LoggerService.js +0 -48
  262. package/features/logger/LoggerService.js.map +0 -1
  263. package/features/logger/feature.js +0 -11
  264. package/features/logger/feature.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"features/tenancy/TenantContext/TenantContext.js","sources":["../../../../src/features/tenancy/TenantContext/TenantContext.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { TenantContext as Abstraction } from \"./abstractions.js\";\nimport type { Tenant } from \"~/types/tenancy.js\";\nimport { GetRootTenantUseCase } from \"~/features/tenancy/GetRootTenant/index.js\";\nimport { TenantIsDisabledError } from \"./errors.js\";\n\nclass TenantContextImpl implements Abstraction.Interface {\n private currentTenant: Tenant | null = null;\n\n constructor(private getRootTenant: GetRootTenantUseCase.Interface) {}\n\n getTenant(): Tenant {\n return this.currentTenant!;\n }\n\n setTenant(tenant: Tenant): void {\n if (tenant.isInstalled && tenant.status === \"disabled\") {\n throw new TenantIsDisabledError();\n }\n this.currentTenant = tenant;\n }\n\n async withRootTenant<T>(cb: () => T): Promise<T> {\n const initialTenant = this.getTenant();\n const rootTenant = await this.getRootTenant.execute();\n if (!rootTenant.isOk()) {\n return rootTenant.error as T;\n }\n\n const tenant = rootTenant.value;\n\n this.setTenant(tenant);\n try {\n return await cb();\n } finally {\n // Make sure that, whatever happens in the callback, the tenant is set back to the initial one.\n this.setTenant(initialTenant);\n }\n }\n\n async withEachTenant<TReturn>(\n tenants: Tenant[],\n cb: (tenant: Tenant) => Promise<TReturn>\n ): Promise<TReturn[]> {\n const initialTenant = this.getTenant();\n const results = [];\n for (const tenant of tenants) {\n this.setTenant(tenant);\n try {\n results.push(await cb(tenant));\n } finally {\n this.setTenant(initialTenant);\n }\n }\n return results;\n }\n\n async withTenant<TReturn>(\n tenant: Tenant,\n cb: (tenant: Tenant) => Promise<TReturn>\n ): Promise<TReturn> {\n const initialTenant = this.getTenant();\n this.setTenant(tenant);\n const result = await cb(tenant);\n this.setTenant(initialTenant);\n return result;\n }\n}\n\nexport const TenantContext = createImplementation({\n abstraction: Abstraction,\n implementation: TenantContextImpl,\n dependencies: [GetRootTenantUseCase]\n});\n"],"names":["TenantContextImpl","getRootTenant","tenant","TenantIsDisabledError","cb","initialTenant","rootTenant","tenants","results","result","TenantContext","createImplementation","Abstraction","GetRootTenantUseCase"],"mappings":";;;;AAMA,MAAMA;IAGF,YAAoBC,aAA6C,CAAE;aAA/CA,aAAa,GAAbA;aAFZ,aAAa,GAAkB;IAE6B;IAEpE,YAAoB;QAChB,OAAO,IAAI,CAAC,aAAa;IAC7B;IAEA,UAAUC,MAAc,EAAQ;QAC5B,IAAIA,OAAO,WAAW,IAAIA,AAAkB,eAAlBA,OAAO,MAAM,EACnC,MAAM,IAAIC;QAEd,IAAI,CAAC,aAAa,GAAGD;IACzB;IAEA,MAAM,eAAkBE,EAAW,EAAc;QAC7C,MAAMC,gBAAgB,IAAI,CAAC,SAAS;QACpC,MAAMC,aAAa,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO;QACnD,IAAI,CAACA,WAAW,IAAI,IAChB,OAAOA,WAAW,KAAK;QAG3B,MAAMJ,SAASI,WAAW,KAAK;QAE/B,IAAI,CAAC,SAAS,CAACJ;QACf,IAAI;YACA,OAAO,MAAME;QACjB,SAAU;YAEN,IAAI,CAAC,SAAS,CAACC;QACnB;IACJ;IAEA,MAAM,eACFE,OAAiB,EACjBH,EAAwC,EACtB;QAClB,MAAMC,gBAAgB,IAAI,CAAC,SAAS;QACpC,MAAMG,UAAU,EAAE;QAClB,KAAK,MAAMN,UAAUK,QAAS;YAC1B,IAAI,CAAC,SAAS,CAACL;YACf,IAAI;gBACAM,QAAQ,IAAI,CAAC,MAAMJ,GAAGF;YAC1B,SAAU;gBACN,IAAI,CAAC,SAAS,CAACG;YACnB;QACJ;QACA,OAAOG;IACX;IAEA,MAAM,WACFN,MAAc,EACdE,EAAwC,EACxB;QAChB,MAAMC,gBAAgB,IAAI,CAAC,SAAS;QACpC,IAAI,CAAC,SAAS,CAACH;QACf,MAAMO,SAAS,MAAML,GAAGF;QACxB,IAAI,CAAC,SAAS,CAACG;QACf,OAAOI;IACX;AACJ;AAEO,MAAMC,8BAAgBC,qBAAqB;IAC9C,aAAaC;IACb,gBAAgBZ;IAChB,cAAc;QAACa;KAAqB;AACxC"}
1
+ {"version":3,"file":"features/tenancy/TenantContext/TenantContext.js","sources":["../../../../src/features/tenancy/TenantContext/TenantContext.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { HandlerExecution } from \"@webiny/event-handler-core\";\nimport { TenantContext as Abstraction } from \"./abstractions.js\";\nimport type { Tenant } from \"~/types/tenancy.js\";\nimport { GetRootTenantUseCase } from \"~/features/tenancy/GetRootTenant/index.js\";\nimport { TenantIsDisabledError } from \"./errors.js\";\n\nfunction assertTenantEnabled(tenant: Tenant): void {\n if (tenant.isInstalled && tenant.status === \"disabled\") {\n throw new TenantIsDisabledError();\n }\n}\n\nclass TenantContextImpl implements Abstraction.Interface {\n private currentTenant: Tenant | null = null;\n /*\n * The `with*` methods switch the tenant for their callback's async call chain only. Before, they\n * set `currentTenant` and restored it afterwards, so any other code of the same request running\n * meanwhile (a sibling GraphQL field, a `Promise.all` branch) read the switched tenant too.\n */\n private readonly overrides = new AsyncLocalStorage<Tenant>();\n\n constructor(\n private getRootTenant: GetRootTenantUseCase.Interface,\n private handlerExecution: HandlerExecution.Interface | undefined\n ) {}\n\n getTenant(): Tenant {\n this.handlerExecution?.assertCurrent(\"TenantContext\");\n const override = this.overrides.getStore();\n if (override) {\n return override;\n }\n return this.currentTenant!;\n }\n\n /*\n * Sets the request's tenant. Inside a `with*` callback it throws: the switch would either be\n * shared with every async branch of that callback or leak past it, so nest another `with*` call.\n */\n setTenant(tenant: Tenant): void {\n this.handlerExecution?.assertCurrent(\"TenantContext\");\n assertTenantEnabled(tenant);\n\n const override = this.overrides.getStore();\n if (override) {\n throw new Error(\n \"TenantContext.setTenant() was called inside a withTenant(), withRootTenant() or withEachTenant() callback. Call withTenant() instead, so the switch stays inside its own callback.\"\n );\n }\n this.currentTenant = tenant;\n }\n\n async withRootTenant<T>(cb: () => T): Promise<T> {\n const rootTenant = await this.getRootTenant.execute();\n if (!rootTenant.isOk()) {\n return rootTenant.error as T;\n }\n\n return this.runAs(rootTenant.value, async () => cb());\n }\n\n async withEachTenant<TReturn>(\n tenants: Tenant[],\n cb: (tenant: Tenant) => Promise<TReturn>\n ): Promise<TReturn[]> {\n const results = [];\n for (const tenant of tenants) {\n const result = await this.runAs(tenant, () => cb(tenant));\n results.push(result);\n }\n return results;\n }\n\n async withTenant<TReturn>(\n tenant: Tenant,\n cb: (tenant: Tenant) => Promise<TReturn>\n ): Promise<TReturn> {\n return this.runAs(tenant, () => cb(tenant));\n }\n\n private runAs<TReturn>(tenant: Tenant, cb: () => Promise<TReturn>): Promise<TReturn> {\n this.handlerExecution?.assertCurrent(\"TenantContext\");\n assertTenantEnabled(tenant);\n\n return this.overrides.run(tenant, cb);\n }\n}\n\nexport const TenantContext = createImplementation({\n abstraction: Abstraction,\n implementation: TenantContextImpl,\n dependencies: [GetRootTenantUseCase, [HandlerExecution, { optional: true }]]\n});\n"],"names":["assertTenantEnabled","tenant","TenantIsDisabledError","TenantContextImpl","getRootTenant","handlerExecution","AsyncLocalStorage","override","Error","cb","rootTenant","tenants","results","result","TenantContext","createImplementation","Abstraction","GetRootTenantUseCase","HandlerExecution"],"mappings":";;;;;;AAQA,SAASA,oBAAoBC,MAAc;IACvC,IAAIA,OAAO,WAAW,IAAIA,AAAkB,eAAlBA,OAAO,MAAM,EACnC,MAAM,IAAIC;AAElB;AAEA,MAAMC;IASF,YACYC,aAA6C,EAC7CC,gBAAwD,CAClE;aAFUD,aAAa,GAAbA;aACAC,gBAAgB,GAAhBA;aAVJ,aAAa,GAAkB;QAKtC,KACgB,SAAS,GAAG,IAAIC;IAK9B;IAEH,YAAoB;QAChB,IAAI,CAAC,gBAAgB,EAAE,cAAc;QACrC,MAAMC,WAAW,IAAI,CAAC,SAAS,CAAC,QAAQ;QACxC,IAAIA,UACA,OAAOA;QAEX,OAAO,IAAI,CAAC,aAAa;IAC7B;IAMA,UAAUN,MAAc,EAAQ;QAC5B,IAAI,CAAC,gBAAgB,EAAE,cAAc;QACrCD,oBAAoBC;QAEpB,MAAMM,WAAW,IAAI,CAAC,SAAS,CAAC,QAAQ;QACxC,IAAIA,UACA,MAAM,IAAIC,MACN;QAGR,IAAI,CAAC,aAAa,GAAGP;IACzB;IAEA,MAAM,eAAkBQ,EAAW,EAAc;QAC7C,MAAMC,aAAa,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO;QACnD,IAAI,CAACA,WAAW,IAAI,IAChB,OAAOA,WAAW,KAAK;QAG3B,OAAO,IAAI,CAAC,KAAK,CAACA,WAAW,KAAK,EAAE,UAAYD;IACpD;IAEA,MAAM,eACFE,OAAiB,EACjBF,EAAwC,EACtB;QAClB,MAAMG,UAAU,EAAE;QAClB,KAAK,MAAMX,UAAUU,QAAS;YAC1B,MAAME,SAAS,MAAM,IAAI,CAAC,KAAK,CAACZ,QAAQ,IAAMQ,GAAGR;YACjDW,QAAQ,IAAI,CAACC;QACjB;QACA,OAAOD;IACX;IAEA,MAAM,WACFX,MAAc,EACdQ,EAAwC,EACxB;QAChB,OAAO,IAAI,CAAC,KAAK,CAACR,QAAQ,IAAMQ,GAAGR;IACvC;IAEQ,MAAeA,MAAc,EAAEQ,EAA0B,EAAoB;QACjF,IAAI,CAAC,gBAAgB,EAAE,cAAc;QACrCT,oBAAoBC;QAEpB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAACA,QAAQQ;IACtC;AACJ;AAEO,MAAMK,8BAAgBC,qBAAqB;IAC9C,aAAaC;IACb,gBAAgBb;IAChB,cAAc;QAACc;QAAsB;YAACC;YAAkB;gBAAE,UAAU;YAAK;SAAE;KAAC;AAChF"}
@@ -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,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0BA,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"}
@@ -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
  }
@@ -28,11 +28,16 @@ export declare class WcpContextImpl implements WcpContext.Interface {
28
28
  canUseAiPageGeneration(): boolean;
29
29
  canUseAiPageTranslation(): boolean;
30
30
  canUseAiLexicalGeneration(): boolean;
31
+ canUseAiAdminAssistant(): boolean;
31
32
  canUseAiEntryGeneration(): boolean;
32
33
  canUseAiEntryComparison(): boolean;
33
34
  canUseAiEntryTranslation(): boolean;
35
+ canUseAiPowerups(): boolean;
34
36
  canUseAbTesting(): boolean;
35
- canUseRemoteComponents(): boolean;
37
+ canUseCollaboration(): boolean;
38
+ canUseComments(): boolean;
39
+ canUseActivityLog(): boolean;
40
+ canUseLanguages(): boolean;
36
41
  ensureCanUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): void;
37
42
  incrementSeats(): Promise<void>;
38
43
  decrementSeats(): Promise<void>;
@@ -117,6 +117,9 @@ class WcpContextImpl {
117
117
  canUseAiLexicalGeneration() {
118
118
  return this.license.canUseAiLexicalGeneration();
119
119
  }
120
+ canUseAiAdminAssistant() {
121
+ return this.license.canUseAiAdminAssistant();
122
+ }
120
123
  canUseAiEntryGeneration() {
121
124
  return this.license.canUseAiEntryGeneration();
122
125
  }
@@ -126,11 +129,23 @@ class WcpContextImpl {
126
129
  canUseAiEntryTranslation() {
127
130
  return this.license.canUseAiEntryTranslation();
128
131
  }
132
+ canUseAiPowerups() {
133
+ return this.license.canUseAiPowerups();
134
+ }
129
135
  canUseAbTesting() {
130
136
  return this.license.canUseAbTesting();
131
137
  }
132
- canUseRemoteComponents() {
133
- return this.license.canUseRemoteComponents();
138
+ canUseCollaboration() {
139
+ return this.license.canUseCollaboration();
140
+ }
141
+ canUseComments() {
142
+ return this.license.canUseComments();
143
+ }
144
+ canUseActivityLog() {
145
+ return this.license.canUseActivityLog();
146
+ }
147
+ canUseLanguages() {
148
+ return this.license.canUseLanguages();
134
149
  }
135
150
  ensureCanUseFeature(wcpFeatureId) {
136
151
  if (this.license.canUseFeature(wcpFeatureId)) return;
@@ -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 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 canUseAbTesting(): boolean {\n return this.license.canUseAbTesting();\n }\n\n canUseRemoteComponents(): boolean {\n return this.license.canUseRemoteComponents();\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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FN,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"}
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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AGJ,IAAIJ,UAAU,CAAC,IAAI,EAAEI,aAAa,6FAA6F,CAAC;QAChI,IAAIlB,uBAAuB;YACvB,MAAM,EAAEmB,GAAG,EAAEC,OAAO,EAAE,GAAGpB;YACzB,MAAMqB,4BAA4BC,aAAa,CAAC,CAAC,EAAEH,IAAI,EAAE,CAAC,CAAC,EAAEC,QAAQ,EAAE,CAAC,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"}
@@ -1,4 +1,5 @@
1
1
  import type { WCP_FEATURE_LABEL } from "@webiny/wcp";
2
+ import type { WcpProject } from "@webiny/wcp/types.js";
2
3
  import { WcpContext } from "../abstractions.js";
3
4
  import { FeatureFlags } from "../../../featureFlags/abstractions.js";
4
5
  declare class WcpContextWithFeatureFlagsDecoratorImpl implements WcpContext.Interface {
@@ -6,78 +7,8 @@ declare class WcpContextWithFeatureFlagsDecoratorImpl implements WcpContext.Inte
6
7
  private decoratee;
7
8
  constructor(featureFlags: FeatureFlags.Interface, decoratee: WcpContext.Interface);
8
9
  getRawLicense(): import("@webiny/wcp/types.js").DecryptedWcpProjectLicense | null;
9
- getProject(): import("@webiny/wcp/types.js").WcpProject | null;
10
- getProjectWithFeatureFlags(): {
11
- orgId: string;
12
- projectId: string;
13
- package: {
14
- features: {
15
- seats: {
16
- enabled: true;
17
- options: {
18
- maxCount: number;
19
- };
20
- };
21
- multiTenancy: {
22
- enabled: true;
23
- options: {
24
- maxCount: {
25
- type: import("@webiny/wcp/types.js").MT_OPTIONS_MAX_COUNT_TYPE;
26
- count?: number;
27
- };
28
- };
29
- };
30
- advancedPublishingWorkflow: {
31
- enabled: boolean;
32
- };
33
- advancedAccessControlLayer: {
34
- enabled: boolean;
35
- options: {
36
- teams: boolean;
37
- privateFiles: boolean;
38
- folderLevelPermissions: boolean;
39
- hcmsFieldPermissions: boolean;
40
- };
41
- };
42
- auditLogs: {
43
- enabled: boolean;
44
- };
45
- recordLocking: {
46
- enabled: boolean;
47
- };
48
- fileManager: {
49
- enabled: boolean;
50
- options: {
51
- threatDetection: boolean;
52
- };
53
- };
54
- aiPowerups: {
55
- enabled: boolean;
56
- options: {
57
- websiteBuilder: {
58
- pageGeneration: boolean | undefined;
59
- pageTranslation: boolean | undefined;
60
- };
61
- fileManager: {
62
- imageEnrichment: boolean | undefined;
63
- };
64
- lexicalGeneration: boolean | undefined;
65
- cms: {
66
- entryGeneration: boolean | undefined;
67
- entryComparison: boolean | undefined;
68
- entryTranslation: boolean | undefined;
69
- };
70
- };
71
- };
72
- abTesting: {
73
- enabled: boolean;
74
- };
75
- remoteComponents: {
76
- enabled: boolean;
77
- };
78
- };
79
- };
80
- } | null;
10
+ getProject(): WcpProject | null;
11
+ getProjectWithFeatureFlags(): WcpProject | null;
81
12
  getProjectEnvironment(): import("@webiny/wcp/types.js").WcpProjectEnvironment | null;
82
13
  getProjectLicense(): import("@webiny/wcp/types.js").ILicense;
83
14
  canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): boolean;
@@ -94,11 +25,16 @@ declare class WcpContextWithFeatureFlagsDecoratorImpl implements WcpContext.Inte
94
25
  canUseAiPageGeneration(): boolean;
95
26
  canUseAiPageTranslation(): boolean;
96
27
  canUseAiLexicalGeneration(): boolean;
28
+ canUseAiAdminAssistant(): boolean;
97
29
  canUseAiEntryGeneration(): boolean;
98
30
  canUseAiEntryComparison(): boolean;
99
31
  canUseAiEntryTranslation(): boolean;
32
+ canUseAiPowerups(): boolean;
100
33
  canUseAbTesting(): boolean;
101
- canUseRemoteComponents(): boolean;
34
+ canUseCollaboration(): boolean;
35
+ canUseComments(): boolean;
36
+ canUseActivityLog(): boolean;
37
+ canUseLanguages(): boolean;
102
38
  ensureCanUseFeature(featureId: keyof typeof WCP_FEATURE_LABEL): void;
103
39
  incrementSeats(): Promise<void>;
104
40
  decrementSeats(): Promise<void>;
@@ -63,6 +63,7 @@ class WcpContextWithFeatureFlagsDecoratorImpl {
63
63
  imageEnrichment: flags.isEnabled("aiPowerups.fileManager.imageEnrichment") ? project.package.features.aiPowerups?.options?.fileManager?.imageEnrichment : false
64
64
  },
65
65
  lexicalGeneration: flags.isEnabled("aiPowerups.lexicalGeneration") ? project.package.features.aiPowerups?.options?.lexicalGeneration : false,
66
+ adminAssistant: flags.isEnabled("aiPowerups.adminAssistant") ? project.package.features.aiPowerups?.options?.adminAssistant : false,
66
67
  cms: {
67
68
  entryGeneration: flags.isEnabled("aiPowerups.cms.entryGeneration") ? project.package.features.aiPowerups?.options?.cms?.entryGeneration : false,
68
69
  entryComparison: flags.isEnabled("aiPowerups.cms.entryComparison") ? project.package.features.aiPowerups?.options?.cms?.entryComparison : false,
@@ -74,9 +75,13 @@ class WcpContextWithFeatureFlagsDecoratorImpl {
74
75
  ...project.package.features.abTesting,
75
76
  enabled: flags.isEnabled("abTesting") ? project.package.features.abTesting?.enabled : false
76
77
  },
77
- remoteComponents: {
78
- ...project.package.features.remoteComponents,
79
- enabled: flags.isEnabled("remoteComponents") ? project.package.features.remoteComponents?.enabled : false
78
+ collaboration: {
79
+ ...project.package.features.collaboration,
80
+ enabled: flags.isEnabled("collaboration") ? project.package.features.collaboration?.enabled : false,
81
+ options: {
82
+ comments: flags.isEnabled("collaboration.comments") ? project.package.features.collaboration?.options?.comments : false,
83
+ activityLog: flags.isEnabled("collaboration.activityLog") ? project.package.features.collaboration?.options?.activityLog : false
84
+ }
80
85
  }
81
86
  }
82
87
  }
@@ -130,6 +135,9 @@ class WcpContextWithFeatureFlagsDecoratorImpl {
130
135
  canUseAiLexicalGeneration() {
131
136
  return this.decoratee.canUseAiLexicalGeneration() && this.featureFlags.get().isEnabled("aiPowerups.lexicalGeneration");
132
137
  }
138
+ canUseAiAdminAssistant() {
139
+ return this.decoratee.canUseAiAdminAssistant() && this.featureFlags.get().isEnabled("aiPowerups.adminAssistant");
140
+ }
133
141
  canUseAiEntryGeneration() {
134
142
  return this.decoratee.canUseAiEntryGeneration() && this.featureFlags.get().isEnabled("aiPowerups.cms.entryGeneration");
135
143
  }
@@ -139,11 +147,23 @@ class WcpContextWithFeatureFlagsDecoratorImpl {
139
147
  canUseAiEntryTranslation() {
140
148
  return this.decoratee.canUseAiEntryTranslation() && this.featureFlags.get().isEnabled("aiPowerups.cms.entryTranslation");
141
149
  }
150
+ canUseAiPowerups() {
151
+ return this.decoratee.canUseAiPowerups() && this.featureFlags.get().isEnabled("aiPowerups");
152
+ }
142
153
  canUseAbTesting() {
143
154
  return this.decoratee.canUseAbTesting() && this.featureFlags.get().isEnabled("abTesting");
144
155
  }
145
- canUseRemoteComponents() {
146
- return this.decoratee.canUseRemoteComponents() && this.featureFlags.get().isEnabled("remoteComponents");
156
+ canUseCollaboration() {
157
+ return this.decoratee.canUseCollaboration() && this.featureFlags.get().isEnabled("collaboration");
158
+ }
159
+ canUseComments() {
160
+ return this.decoratee.canUseComments() && this.featureFlags.get().isEnabled("collaboration.comments");
161
+ }
162
+ canUseActivityLog() {
163
+ return this.decoratee.canUseActivityLog() && this.featureFlags.get().isEnabled("collaboration.activityLog");
164
+ }
165
+ canUseLanguages() {
166
+ return this.decoratee.canUseLanguages() && this.featureFlags.get().isEnabled("languages");
147
167
  }
148
168
  ensureCanUseFeature(featureId) {
149
169
  return this.decoratee.ensureCanUseFeature(featureId);
@@ -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 { 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() {\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 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 remoteComponents: {\n ...project.package.features.remoteComponents,\n enabled: flags.isEnabled(\"remoteComponents\")\n ? project.package.features.remoteComponents?.enabled\n : false\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 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 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(\"remoteComponents\")\n );\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":";;AAIA,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,6BAA6B;QACzB,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,QAAQ,CAAC,YAAY;oBACnD,4BAA4B;wBACxB,GAAGA,QAAQ,OAAO,CAAC,QAAQ,CAAC,0BAA0B;wBACtD,SAASC,MAAM,SAAS,CAAC,gCACnBD,QAAQ,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAC,OAAO,GAC3D;oBACV;oBACA,4BAA4B;wBACxB,GAAGA,QAAQ,OAAO,CAAC,QAAQ,CAAC,0BAA0B;wBACtD,SAASC,MAAM,SAAS,CAAC,gCACnBD,QAAQ,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAC,OAAO,GAC3D;wBACN,SAAS;4BACL,OAAOC,MAAM,SAAS,CAAC,sCACjBD,QAAQ,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAC,OAAO,CAAC,KAAK,GACjE;4BACN,cAAcC,MAAM,SAAS,CAAC,6CACxBD,QAAQ,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAC,OAAO,CACtD,YAAY,GACjB;4BACN,wBA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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;Q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I,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 +1 @@
1
- {"version":3,"file":"features/wcp/WcpLicenseLoader.js","sources":["../../../src/features/wcp/WcpLicenseLoader.ts"],"sourcesContent":["import { getWcpProjectLicense, NullLicense, License } from \"@webiny/wcp\";\nimport type { DecryptedWcpProjectLicense, ILicense } from \"@webiny/wcp/types.js\";\nimport type { CachedWcpProjectLicense } from \"~/features/wcp/WcpContext/types.js\";\nimport { getWcpProjectLicenseCacheKey } from \"~/features/wcp/WcpContext/utils.js\";\nimport { resolveWcpProjectEnvironment } from \"~/features/wcp/resolveWcpProjectEnvironment.js\";\n\n/**\n * Loads and process-caches the WCP project license. Static because the cache is process-global (one\n * license per deployment): the pre-register refresh in `registerApiRequestStack` calls `load()` to\n * populate it, and `WcpLicenseProvider` / register-time feature-flag gates read it synchronously via\n * `getCached()`. Not DI — it must be usable before any container exists (before register).\n */\nexport class WcpLicenseLoader {\n private static readonly wcpProjectEnvironment = resolveWcpProjectEnvironment();\n\n private static cached: CachedWcpProjectLicense = {\n cacheKey: null,\n project: null,\n license: new NullLicense()\n };\n\n // In-flight fetch, memoized so concurrent cache-miss callers coalesce onto a single WCP request\n // (self-hosted runs many requests in one process; we never want two license fetches at once).\n private static inflight: Promise<ILicense> | null = null;\n\n /**\n * Synchronously read the currently cached license. `load()` must have been awaited at least once\n * this request (the pre-register refresh does this), so this reflects the live license — letting\n * register()-time feature-flag checks read it synchronously.\n */\n static getCached(): ILicense {\n return WcpLicenseLoader.cached.license;\n }\n\n /**\n * Seed the cache with an already-resolved license (tests pass a pre-built one). Marks it fresh so\n * a subsequent `load()` returns it without a fetch. This is how `WcpLicenseProviderImpl` installs\n * an initial license.\n */\n static seed(license: ILicense): void {\n WcpLicenseLoader.cached.license = license;\n WcpLicenseLoader.cached.cacheKey = getWcpProjectLicenseCacheKey();\n }\n\n static async load(testProjectLicense?: DecryptedWcpProjectLicense): Promise<ILicense> {\n const cached = WcpLicenseLoader.cached;\n\n if (testProjectLicense) {\n cached.license = License.fromLicenseDto(testProjectLicense);\n return cached.license;\n }\n\n const env = WcpLicenseLoader.wcpProjectEnvironment;\n if (!env) {\n return cached.license;\n }\n\n const currentCacheKey = getWcpProjectLicenseCacheKey();\n if (cached.cacheKey === currentCacheKey) {\n return cached.license;\n }\n\n // Cache miss (first load or the ~5-min key rotated). Coalesce concurrent callers onto one fetch.\n if (WcpLicenseLoader.inflight) {\n return WcpLicenseLoader.inflight;\n }\n\n WcpLicenseLoader.inflight = (async () => {\n // Pull the project license from the WCP API.\n const decryptedLicenseDto = await getWcpProjectLicense({\n orgId: env.org.id,\n projectId: env.project.id,\n projectEnvironmentApiKey: env.apiKey\n });\n\n if (decryptedLicenseDto) {\n cached.project = {\n orgId: decryptedLicenseDto.orgId,\n projectId: decryptedLicenseDto.projectId,\n package: decryptedLicenseDto.package\n };\n }\n\n cached.license = License.fromLicenseDto(decryptedLicenseDto);\n // Mark fresh only after a successful fetch — a throw leaves the key unset so the next call retries.\n cached.cacheKey = currentCacheKey;\n return cached.license;\n })().finally(() => {\n WcpLicenseLoader.inflight = null;\n });\n\n return WcpLicenseLoader.inflight;\n }\n}\n"],"names":["WcpLicenseLoader","resolveWcpProjectEnvironment","NullLicense","license","getWcpProjectLicenseCacheKey","testProjectLicense","cached","License","env","currentCacheKey","decryptedLicenseDto","getWcpProjectLicense"],"mappings":";;;AAYO,MAAMA;;aACe,qBAAqB,GAAGC;;;aAEjC,MAAM,GAA4B;YAC7C,UAAU;YACV,SAAS;YACT,SAAS,IAAIC;QACjB;;;aAIe,QAAQ,GAA6B;;IAOpD,OAAO,YAAsB;QACzB,OAAOF,iBAAiB,MAAM,CAAC,OAAO;IAC1C;IAOA,OAAO,KAAKG,OAAiB,EAAQ;QACjCH,iBAAiB,MAAM,CAAC,OAAO,GAAGG;QAClCH,iBAAiB,MAAM,CAAC,QAAQ,GAAGI;IACvC;IAEA,aAAa,KAAKC,kBAA+C,EAAqB;QAClF,MAAMC,SAASN,iBAAiB,MAAM;QAEtC,IAAIK,oBAAoB;YACpBC,OAAO,OAAO,GAAGC,QAAQ,cAAc,CAACF;YACxC,OAAOC,OAAO,OAAO;QACzB;QAEA,MAAME,MAAMR,iBAAiB,qBAAqB;QAClD,IAAI,CAACQ,KACD,OAAOF,OAAO,OAAO;QAGzB,MAAMG,kBAAkBL;QACxB,IAAIE,OAAO,QAAQ,KAAKG,iBACpB,OAAOH,OAAO,OAAO;QAIzB,IAAIN,iBAAiB,QAAQ,EACzB,OAAOA,iBAAiB,QAAQ;QAGpCA,iBAAiB,QAAQ,GAAI;YAEzB,MAAMU,sBAAsB,MAAMC,qBAAqB;gBACnD,OAAOH,IAAI,GAAG,CAAC,EAAE;gBACjB,WAAWA,IAAI,OAAO,CAAC,EAAE;gBACzB,0BAA0BA,IAAI,MAAM;YACxC;YAEA,IAAIE,qBACAJ,OAAO,OAAO,GAAG;gBACb,OAAOI,oBAAoB,KAAK;gBAChC,WAAWA,oBAAoB,SAAS;gBACxC,SAASA,oBAAoB,OAAO;YACxC;YAGJJ,OAAO,OAAO,GAAGC,QAAQ,cAAc,CAACG;YAExCJ,OAAO,QAAQ,GAAGG;YAClB,OAAOH,OAAO,OAAO;QACzB,KAAK,OAAO,CAAC;YACTN,iBAAiB,QAAQ,GAAG;QAChC;QAEA,OAAOA,iBAAiB,QAAQ;IACpC;AACJ"}
1
+ {"version":3,"file":"features/wcp/WcpLicenseLoader.js","sources":["../../../src/features/wcp/WcpLicenseLoader.ts"],"sourcesContent":["import { getWcpProjectLicense, NullLicense, License } from \"@webiny/wcp\";\nimport type { DecryptedWcpProjectLicense, ILicense } from \"@webiny/wcp/types.js\";\nimport type { CachedWcpProjectLicense } from \"~/features/wcp/WcpContext/types.js\";\nimport { getWcpProjectLicenseCacheKey } from \"~/features/wcp/WcpContext/utils.js\";\nimport { resolveWcpProjectEnvironment } from \"~/features/wcp/resolveWcpProjectEnvironment.js\";\n\n/**\n * Loads and process-caches the WCP project license. Static because the cache is process-global (one\n * license per deployment): the pre-register refresh in `registerApiRequestStack` calls `load()` to\n * populate it, and `WcpLicenseProvider` / register-time feature-flag gates read it synchronously via\n * `getCached()`. Not DI — it must be usable before any container exists (before register).\n */\nexport class WcpLicenseLoader {\n private static readonly wcpProjectEnvironment = resolveWcpProjectEnvironment();\n\n private static cached: CachedWcpProjectLicense = {\n cacheKey: null,\n project: null,\n license: new NullLicense()\n };\n\n // In-flight fetch, memoized so concurrent cache-miss callers coalesce onto a single WCP request\n // (standalone runs many requests in one process; we never want two license fetches at once).\n private static inflight: Promise<ILicense> | null = null;\n\n /**\n * Synchronously read the currently cached license. `load()` must have been awaited at least once\n * this request (the pre-register refresh does this), so this reflects the live license — letting\n * register()-time feature-flag checks read it synchronously.\n */\n static getCached(): ILicense {\n return WcpLicenseLoader.cached.license;\n }\n\n /**\n * Seed the cache with an already-resolved license (tests pass a pre-built one). Marks it fresh so\n * a subsequent `load()` returns it without a fetch. This is how `WcpLicenseProviderImpl` installs\n * an initial license.\n */\n static seed(license: ILicense): void {\n WcpLicenseLoader.cached.license = license;\n WcpLicenseLoader.cached.cacheKey = getWcpProjectLicenseCacheKey();\n }\n\n static async load(testProjectLicense?: DecryptedWcpProjectLicense): Promise<ILicense> {\n const cached = WcpLicenseLoader.cached;\n\n if (testProjectLicense) {\n cached.license = License.fromLicenseDto(testProjectLicense);\n return cached.license;\n }\n\n const env = WcpLicenseLoader.wcpProjectEnvironment;\n if (!env) {\n return cached.license;\n }\n\n const currentCacheKey = getWcpProjectLicenseCacheKey();\n if (cached.cacheKey === currentCacheKey) {\n return cached.license;\n }\n\n // Cache miss (first load or the ~5-min key rotated). Coalesce concurrent callers onto one fetch.\n if (WcpLicenseLoader.inflight) {\n return WcpLicenseLoader.inflight;\n }\n\n WcpLicenseLoader.inflight = (async () => {\n // Pull the project license from the WCP API.\n const decryptedLicenseDto = await getWcpProjectLicense({\n orgId: env.org.id,\n projectId: env.project.id,\n projectEnvironmentApiKey: env.apiKey\n });\n\n if (decryptedLicenseDto) {\n cached.project = {\n orgId: decryptedLicenseDto.orgId,\n projectId: decryptedLicenseDto.projectId,\n package: decryptedLicenseDto.package\n };\n }\n\n cached.license = License.fromLicenseDto(decryptedLicenseDto);\n // Mark fresh only after a successful fetch — a throw leaves the key unset so the next call retries.\n cached.cacheKey = currentCacheKey;\n return cached.license;\n })().finally(() => {\n WcpLicenseLoader.inflight = null;\n });\n\n return WcpLicenseLoader.inflight;\n }\n}\n"],"names":["WcpLicenseLoader","resolveWcpProjectEnvironment","NullLicense","license","getWcpProjectLicenseCacheKey","testProjectLicense","cached","License","env","currentCacheKey","decryptedLicenseDto","getWcpProjectLicense"],"mappings":";;;AAYO,MAAMA;;aACe,qBAAqB,GAAGC;;;aAEjC,MAAM,GAA4B;YAC7C,UAAU;YACV,SAAS;YACT,SAAS,IAAIC;QACjB;;;aAIe,QAAQ,GAA6B;;IAOpD,OAAO,YAAsB;QACzB,OAAOF,iBAAiB,MAAM,CAAC,OAAO;IAC1C;IAOA,OAAO,KAAKG,OAAiB,EAAQ;QACjCH,iBAAiB,MAAM,CAAC,OAAO,GAAGG;QAClCH,iBAAiB,MAAM,CAAC,QAAQ,GAAGI;IACvC;IAEA,aAAa,KAAKC,kBAA+C,EAAqB;QAClF,MAAMC,SAASN,iBAAiB,MAAM;QAEtC,IAAIK,oBAAoB;YACpBC,OAAO,OAAO,GAAGC,QAAQ,cAAc,CAACF;YACxC,OAAOC,OAAO,OAAO;QACzB;QAEA,MAAME,MAAMR,iBAAiB,qBAAqB;QAClD,IAAI,CAACQ,KACD,OAAOF,OAAO,OAAO;QAGzB,MAAMG,kBAAkBL;QACxB,IAAIE,OAAO,QAAQ,KAAKG,iBACpB,OAAOH,OAAO,OAAO;QAIzB,IAAIN,iBAAiB,QAAQ,EACzB,OAAOA,iBAAiB,QAAQ;QAGpCA,iBAAiB,QAAQ,GAAI;YAEzB,MAAMU,sBAAsB,MAAMC,qBAAqB;gBACnD,OAAOH,IAAI,GAAG,CAAC,EAAE;gBACjB,WAAWA,IAAI,OAAO,CAAC,EAAE;gBACzB,0BAA0BA,IAAI,MAAM;YACxC;YAEA,IAAIE,qBACAJ,OAAO,OAAO,GAAG;gBACb,OAAOI,oBAAoB,KAAK;gBAChC,WAAWA,oBAAoB,SAAS;gBACxC,SAASA,oBAAoB,OAAO;YACxC;YAGJJ,OAAO,OAAO,GAAGC,QAAQ,cAAc,CAACG;YAExCJ,OAAO,QAAQ,GAAGG;YAClB,OAAOH,OAAO,OAAO;QACzB,KAAK,OAAO,CAAC;YACTN,iBAAiB,QAAQ,GAAG;QAChC;QAEA,OAAOA,iBAAiB,QAAQ;IACpC;AACJ"}
@@ -2,7 +2,7 @@ import type { WcpProjectEnvironment } from "@webiny/wcp/types.js";
2
2
  /**
3
3
  * Resolve the WCP project environment used to fetch the license. Prefer the CLI-computed
4
4
  * WCP_PROJECT_ENVIRONMENT blob (set by `applyWcpEnvVars` during `webiny serve` and the AWS deploy).
5
- * When it's absent — a CLI-less self-hosted deploy that boots the built handler directly (e.g.
5
+ * When it's absent — a CLI-less standalone deploy that boots the built handler directly (e.g.
6
6
  * `node start.mjs`) — derive the same org, project and api key straight from the runtime env, so a
7
7
  * fresh license can still be fetched.
8
8
  */
@@ -1 +1 @@
1
- {"version":3,"file":"features/wcp/resolveWcpProjectEnvironment.js","sources":["../../../src/features/wcp/resolveWcpProjectEnvironment.ts"],"sourcesContent":["import { getWcpProjectEnvironment } from \"@webiny/wcp\";\nimport type { WcpProjectEnvironment } from \"@webiny/wcp/types.js\";\n\n/**\n * Resolve the WCP project environment used to fetch the license. Prefer the CLI-computed\n * WCP_PROJECT_ENVIRONMENT blob (set by `applyWcpEnvVars` during `webiny serve` and the AWS deploy).\n * When it's absent — a CLI-less self-hosted deploy that boots the built handler directly (e.g.\n * `node start.mjs`) — derive the same org, project and api key straight from the runtime env, so a\n * fresh license can still be fetched.\n */\nexport function resolveWcpProjectEnvironment(): WcpProjectEnvironment | null {\n const fromBlob = getWcpProjectEnvironment();\n if (fromBlob) {\n return fromBlob;\n }\n\n const projectId = process.env.WEBINY_PROJECT_ID || process.env.WCP_PROJECT_ID;\n const apiKey =\n process.env.WEBINY_PROJECT_API_KEY || process.env.WCP_PROJECT_ENVIRONMENT_API_KEY;\n if (!projectId || !apiKey) {\n return null;\n }\n\n // WEBINY_PROJECT_ID has an \"orgId/projectId\" shape.\n const [orgId, project] = projectId.split(\"/\");\n if (!orgId || !project) {\n return null;\n }\n\n // `id` is intentionally empty. The WCP backend identifies the specific project environment\n // from the api key (sent as the request's authorization header); the license fetch only uses\n // org/project (URL path) + apiKey (auth), never the environment id. So there's nothing to fill.\n return { id: \"\", apiKey, org: { id: orgId }, project: { id: project } };\n}\n"],"names":["resolveWcpProjectEnvironment","fromBlob","getWcpProjectEnvironment","projectId","process","apiKey","orgId","project"],"mappings":";AAUO,SAASA;IACZ,MAAMC,WAAWC;IACjB,IAAID,UACA,OAAOA;IAGX,MAAME,YAAYC,QAAQ,GAAG,CAAC,iBAAiB,IAAIA,QAAQ,GAAG,CAAC,cAAc;IAC7E,MAAMC,SACFD,QAAQ,GAAG,CAAC,sBAAsB,IAAIA,QAAQ,GAAG,CAAC,+BAA+B;IACrF,IAAI,CAACD,aAAa,CAACE,QACf,OAAO;IAIX,MAAM,CAACC,OAAOC,QAAQ,GAAGJ,UAAU,KAAK,CAAC;IACzC,IAAI,CAACG,SAAS,CAACC,SACX,OAAO;IAMX,OAAO;QAAE,IAAI;QAAIF;QAAQ,KAAK;YAAE,IAAIC;QAAM;QAAG,SAAS;YAAE,IAAIC;QAAQ;IAAE;AAC1E"}
1
+ {"version":3,"file":"features/wcp/resolveWcpProjectEnvironment.js","sources":["../../../src/features/wcp/resolveWcpProjectEnvironment.ts"],"sourcesContent":["import { getWcpProjectEnvironment } from \"@webiny/wcp\";\nimport type { WcpProjectEnvironment } from \"@webiny/wcp/types.js\";\n\n/**\n * Resolve the WCP project environment used to fetch the license. Prefer the CLI-computed\n * WCP_PROJECT_ENVIRONMENT blob (set by `applyWcpEnvVars` during `webiny serve` and the AWS deploy).\n * When it's absent — a CLI-less standalone deploy that boots the built handler directly (e.g.\n * `node start.mjs`) — derive the same org, project and api key straight from the runtime env, so a\n * fresh license can still be fetched.\n */\nexport function resolveWcpProjectEnvironment(): WcpProjectEnvironment | null {\n const fromBlob = getWcpProjectEnvironment();\n if (fromBlob) {\n return fromBlob;\n }\n\n const projectId = process.env.WEBINY_PROJECT_ID || process.env.WCP_PROJECT_ID;\n const apiKey =\n process.env.WEBINY_PROJECT_API_KEY || process.env.WCP_PROJECT_ENVIRONMENT_API_KEY;\n if (!projectId || !apiKey) {\n return null;\n }\n\n // WEBINY_PROJECT_ID has an \"orgId/projectId\" shape.\n const [orgId, project] = projectId.split(\"/\");\n if (!orgId || !project) {\n return null;\n }\n\n // `id` is intentionally empty. The WCP backend identifies the specific project environment\n // from the api key (sent as the request's authorization header); the license fetch only uses\n // org/project (URL path) + apiKey (auth), never the environment id. So there's nothing to fill.\n return { id: \"\", apiKey, org: { id: orgId }, project: { id: project } };\n}\n"],"names":["resolveWcpProjectEnvironment","fromBlob","getWcpProjectEnvironment","projectId","process","apiKey","orgId","project"],"mappings":";AAUO,SAASA;IACZ,MAAMC,WAAWC;IACjB,IAAID,UACA,OAAOA;IAGX,MAAME,YAAYC,QAAQ,GAAG,CAAC,iBAAiB,IAAIA,QAAQ,GAAG,CAAC,cAAc;IAC7E,MAAMC,SACFD,QAAQ,GAAG,CAAC,sBAAsB,IAAIA,QAAQ,GAAG,CAAC,+BAA+B;IACrF,IAAI,CAACD,aAAa,CAACE,QACf,OAAO;IAIX,MAAM,CAACC,OAAOC,QAAQ,GAAGJ,UAAU,KAAK,CAAC;IACzC,IAAI,CAACG,SAAS,CAACC,SACX,OAAO;IAMX,OAAO;QAAE,IAAI;QAAIF;QAAQ,KAAK;YAAE,IAAIC;QAAM;QAAG,SAAS;YAAE,IAAIC;QAAQ;IAAE;AAC1E"}
@@ -7,6 +7,7 @@ import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQL
7
7
  * core factories does not matter, the engine merges all typeDefs in a single pass.
8
8
  */
9
9
  declare class ApiCoreSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {
10
+ getSchemaKey: () => string;
10
11
  execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
11
12
  }
12
13
  export declare const ApiCoreSchemaFactory: typeof ApiCoreSchemaFactoryImpl & {
@@ -1,5 +1,6 @@
1
1
  import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
2
- import { AnyScalar, DateScalar, DateTimeScalar, IconScalar, JsonScalar, LongScalar, NumberScalar, RefInputScalar, TimeScalar } from "@webiny/api-graphql/builtInTypes/index.js";
2
+ import { staticSchemaKey } from "@webiny/api-graphql/graphql/staticSchemaKey.js";
3
+ import { AnyScalar, DateScalar, DateTimeScalar, DateTimeZScalar, IconScalar, JsonScalar, LongScalar, NumberScalar, RefInputScalar, TimeScalar } from "@webiny/api-graphql/builtInTypes/index.js";
3
4
  const BASE_TYPES = `
4
5
  type Query
5
6
  type Mutation
@@ -11,6 +12,7 @@ const BASE_TYPES = `
11
12
  scalar Any
12
13
  scalar Date
13
14
  scalar DateTime
15
+ scalar DateTimeZ
14
16
  scalar Time
15
17
 
16
18
  type Error {
@@ -33,6 +35,7 @@ const SCALAR_RESOLVERS = {
33
35
  Number: NumberScalar,
34
36
  Any: AnyScalar,
35
37
  DateTime: DateTimeScalar,
38
+ DateTimeZ: DateTimeZScalar,
36
39
  Date: DateScalar,
37
40
  Time: TimeScalar
38
41
  };
@@ -42,6 +45,9 @@ class ApiCoreSchemaFactoryImpl {
42
45
  builder.addLegacyResolvers(SCALAR_RESOLVERS);
43
46
  return builder;
44
47
  }
48
+ constructor(){
49
+ this.getSchemaKey = staticSchemaKey("api-core/ApiCoreSchemaFactoryImpl");
50
+ }
45
51
  }
46
52
  const ApiCoreSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({
47
53
  implementation: ApiCoreSchemaFactoryImpl,
@@ -1 +1 @@
1
- {"version":3,"file":"graphql/ApiCoreSchemaFactory.js","sources":["../../src/graphql/ApiCoreSchemaFactory.ts"],"sourcesContent":["import { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport {\n JsonScalar,\n LongScalar,\n IconScalar,\n RefInputScalar,\n NumberScalar,\n AnyScalar,\n DateTimeScalar,\n DateScalar,\n TimeScalar\n} from \"@webiny/api-graphql/builtInTypes/index.js\";\n\nconst BASE_TYPES = `\n type Query\n type Mutation\n scalar JSON\n scalar Long\n scalar Icon\n scalar RefInput\n scalar Number\n scalar Any\n scalar Date\n scalar DateTime\n scalar Time\n\n type Error {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type BooleanResponse {\n data: Boolean\n error: Error\n }\n`;\n\nconst SCALAR_RESOLVERS: Record<string, any> = {\n JSON: JsonScalar,\n Long: LongScalar,\n Icon: IconScalar,\n RefInput: RefInputScalar,\n Number: NumberScalar,\n Any: AnyScalar,\n DateTime: DateTimeScalar,\n Date: DateScalar,\n Time: TimeScalar\n};\n\n/**\n * The base of the core API schema: the root Query/Mutation, shared scalars and their\n * implementations, and the shared Error/BooleanResponse types. The actual domains (security,\n * users, system, wcp) are their own CoreGraphQLSchemaFactory implementations — order between\n * core factories does not matter, the engine merges all typeDefs in a single pass.\n */\nclass ApiCoreSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(BASE_TYPES);\n\n // Scalar implementations (scalar type objects, not container-resolving resolvers).\n builder.addLegacyResolvers(SCALAR_RESOLVERS);\n\n return builder;\n }\n}\n\nexport const ApiCoreSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({\n implementation: ApiCoreSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["BASE_TYPES","SCALAR_RESOLVERS","JsonScalar","LongScalar","IconScalar","RefInputScalar","NumberScalar","AnyScalar","DateTimeScalar","DateScalar","TimeScalar","ApiCoreSchemaFactoryImpl","builder","ApiCoreSchemaFactory","CoreGraphQLSchemaFactory"],"mappings":";;AAcA,MAAMA,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;AAwBpB,CAAC;AAED,MAAMC,mBAAwC;IAC1C,MAAMC;IACN,MAAMC;IACN,MAAMC;IACN,UAAUC;IACV,QAAQC;IACR,KAAKC;IACL,UAAUC;IACV,MAAMC;IACN,MAAMC;AACV;AAQA,MAAMC;IACF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAACZ;QAGpBY,QAAQ,kBAAkB,CAACX;QAE3B,OAAOW;IACX;AACJ;AAEO,MAAMC,uBAAuBC,yBAAyB,oBAAoB,CAAC;IAC9E,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"graphql/ApiCoreSchemaFactory.js","sources":["../../src/graphql/ApiCoreSchemaFactory.ts"],"sourcesContent":["import { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport { staticSchemaKey } from \"@webiny/api-graphql/graphql/staticSchemaKey.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport {\n JsonScalar,\n LongScalar,\n IconScalar,\n RefInputScalar,\n NumberScalar,\n AnyScalar,\n DateTimeScalar,\n DateTimeZScalar,\n DateScalar,\n TimeScalar\n} from \"@webiny/api-graphql/builtInTypes/index.js\";\n\nconst BASE_TYPES = `\n type Query\n type Mutation\n scalar JSON\n scalar Long\n scalar Icon\n scalar RefInput\n scalar Number\n scalar Any\n scalar Date\n scalar DateTime\n scalar DateTimeZ\n scalar Time\n\n type Error {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type BooleanResponse {\n data: Boolean\n error: Error\n }\n`;\n\nconst SCALAR_RESOLVERS: Record<string, any> = {\n JSON: JsonScalar,\n Long: LongScalar,\n Icon: IconScalar,\n RefInput: RefInputScalar,\n Number: NumberScalar,\n Any: AnyScalar,\n DateTime: DateTimeScalar,\n DateTimeZ: DateTimeZScalar,\n Date: DateScalar,\n Time: TimeScalar\n};\n\n/**\n * The base of the core API schema: the root Query/Mutation, shared scalars and their\n * implementations, and the shared Error/BooleanResponse types. The actual domains (security,\n * users, system, wcp) are their own CoreGraphQLSchemaFactory implementations — order between\n * core factories does not matter, the engine merges all typeDefs in a single pass.\n */\nclass ApiCoreSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {\n public getSchemaKey = staticSchemaKey(\"api-core/ApiCoreSchemaFactoryImpl\");\n\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(BASE_TYPES);\n\n // Scalar implementations (scalar type objects, not container-resolving resolvers).\n builder.addLegacyResolvers(SCALAR_RESOLVERS);\n\n return builder;\n }\n}\n\nexport const ApiCoreSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({\n implementation: ApiCoreSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["BASE_TYPES","SCALAR_RESOLVERS","JsonScalar","LongScalar","IconScalar","RefInputScalar","NumberScalar","AnyScalar","DateTimeScalar","DateTimeZScalar","DateScalar","TimeScalar","ApiCoreSchemaFactoryImpl","builder","staticSchemaKey","ApiCoreSchemaFactory","CoreGraphQLSchemaFactory"],"mappings":";;;AAgBA,MAAMA,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AAyBpB,CAAC;AAED,MAAMC,mBAAwC;IAC1C,MAAMC;IACN,MAAMC;IACN,MAAMC;IACN,UAAUC;IACV,QAAQC;IACR,KAAKC;IACL,UAAUC;IACV,WAAWC;IACX,MAAMC;IACN,MAAMC;AACV;AAQA,MAAMC;IAGF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAACb;QAGpBa,QAAQ,kBAAkB,CAACZ;QAE3B,OAAOY;IACX;;aATO,YAAY,GAAGC,gBAAgB;;AAU1C;AAEO,MAAMC,uBAAuBC,yBAAyB,oBAAoB,CAAC;IAC9E,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
@@ -1,6 +1,7 @@
1
1
  import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
2
2
  import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
3
3
  declare class FeatureFlagsSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {
4
+ getSchemaKey: () => string;
4
5
  execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
5
6
  }
6
7
  export declare const FeatureFlagsSchemaFactory: typeof FeatureFlagsSchemaFactoryImpl & {
@@ -1,4 +1,5 @@
1
1
  import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
2
+ import { staticSchemaKey } from "@webiny/api-graphql/graphql/staticSchemaKey.js";
2
3
  import { ErrorResponse, Response } from "@webiny/api-graphql/responses.js";
3
4
  import { FeatureFlags } from "../../features/featureFlags/abstractions.js";
4
5
  class FeatureFlagsSchemaFactoryImpl {
@@ -39,6 +40,9 @@ class FeatureFlagsSchemaFactoryImpl {
39
40
  });
40
41
  return builder;
41
42
  }
43
+ constructor(){
44
+ this.getSchemaKey = staticSchemaKey("api-core/FeatureFlagsSchemaFactoryImpl");
45
+ }
42
46
  }
43
47
  const FeatureFlagsSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({
44
48
  implementation: FeatureFlagsSchemaFactoryImpl,