@webiny/api-core 0.0.0-unstable.a4f3e4ea8b → 0.0.0-unstable.a85ef555b2

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 (442) hide show
  1. package/ApiCoreFeature.d.ts +2 -2
  2. package/ApiCoreFeature.js +35 -5
  3. package/ApiCoreFeature.js.map +1 -1
  4. package/exports/api/tasks.d.ts +1 -0
  5. package/exports/api/tasks.js +1 -1
  6. package/exports/api.d.ts +2 -1
  7. package/exports/api.js +2 -1
  8. package/features/ai/Ai.js +16 -6
  9. package/features/ai/Ai.js.map +1 -1
  10. package/features/ai/AiModelRegistry.d.ts +3 -1
  11. package/features/ai/AiModelRegistry.js +16 -7
  12. package/features/ai/AiModelRegistry.js.map +1 -1
  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/DEVELOPERS.md +69 -12
  20. package/features/ai/OpenRouterSdkFactory.d.ts +10 -0
  21. package/features/ai/OpenRouterSdkFactory.js +112 -0
  22. package/features/ai/OpenRouterSdkFactory.js.map +1 -0
  23. package/features/ai/RemoteAiModelCatalog.d.ts +13 -0
  24. package/features/ai/RemoteAiModelCatalog.js +74 -0
  25. package/features/ai/RemoteAiModelCatalog.js.map +1 -0
  26. package/features/ai/abstractions.d.ts +90 -7
  27. package/features/ai/abstractions.js +5 -2
  28. package/features/ai/abstractions.js.map +1 -1
  29. package/features/ai/feature.js +6 -0
  30. package/features/ai/feature.js.map +1 -1
  31. package/features/ai/index.d.ts +2 -4
  32. package/features/ai/index.js +1 -1
  33. package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
  34. package/features/dateFormatter/DefaultDateFormatter.js +20 -0
  35. package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
  36. package/features/dateFormatter/abstractions.d.ts +13 -0
  37. package/features/dateFormatter/abstractions.js +5 -0
  38. package/features/dateFormatter/abstractions.js.map +1 -0
  39. package/features/dateFormatter/feature.d.ts +4 -0
  40. package/features/dateFormatter/feature.js +11 -0
  41. package/features/dateFormatter/feature.js.map +1 -0
  42. package/features/dateFormatter/index.d.ts +3 -0
  43. package/features/dateFormatter/index.js +2 -0
  44. package/features/debugger/Debugger.d.ts +30 -0
  45. package/features/debugger/Debugger.js +142 -0
  46. package/features/debugger/Debugger.js.map +1 -0
  47. package/features/debugger/DebuggerRouteDecorator.d.ts +45 -0
  48. package/features/debugger/DebuggerRouteDecorator.js +107 -0
  49. package/features/debugger/DebuggerRouteDecorator.js.map +1 -0
  50. package/features/debugger/GraphQLDebuggerTransport.d.ts +28 -0
  51. package/features/debugger/GraphQLDebuggerTransport.js +45 -0
  52. package/features/debugger/GraphQLDebuggerTransport.js.map +1 -0
  53. package/features/debugger/__tests__/matchNamespace.test.d.ts +1 -0
  54. package/features/debugger/__tests__/matchNamespace.test.js +68 -0
  55. package/features/debugger/__tests__/matchNamespace.test.js.map +1 -0
  56. package/features/debugger/__tests__/serialize.test.d.ts +1 -0
  57. package/features/debugger/__tests__/serialize.test.js +220 -0
  58. package/features/debugger/__tests__/serialize.test.js.map +1 -0
  59. package/features/debugger/abstractions.d.ts +100 -0
  60. package/features/debugger/abstractions.js +6 -0
  61. package/features/debugger/abstractions.js.map +1 -0
  62. package/features/debugger/feature.d.ts +5 -0
  63. package/features/debugger/feature.js +15 -0
  64. package/features/debugger/feature.js.map +1 -0
  65. package/features/debugger/index.d.ts +12 -0
  66. package/features/debugger/index.js +7 -0
  67. package/features/debugger/limits.d.ts +18 -0
  68. package/features/debugger/limits.js +11 -0
  69. package/features/debugger/limits.js.map +1 -0
  70. package/features/debugger/matchNamespace.d.ts +14 -0
  71. package/features/debugger/matchNamespace.js +35 -0
  72. package/features/debugger/matchNamespace.js.map +1 -0
  73. package/features/debugger/parseNamespaceHeader.d.ts +7 -0
  74. package/features/debugger/parseNamespaceHeader.js +16 -0
  75. package/features/debugger/parseNamespaceHeader.js.map +1 -0
  76. package/features/debugger/permissions.d.ts +14 -0
  77. package/features/debugger/permissions.js +8 -0
  78. package/features/debugger/permissions.js.map +1 -0
  79. package/features/debugger/permissionsSchema.d.ts +17 -0
  80. package/features/debugger/permissionsSchema.js +18 -0
  81. package/features/debugger/permissionsSchema.js.map +1 -0
  82. package/features/debugger/serialize.d.ts +11 -0
  83. package/features/debugger/serialize.js +121 -0
  84. package/features/debugger/serialize.js.map +1 -0
  85. package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
  86. package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
  87. package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
  88. package/features/encryption/EncryptionService.d.ts +2 -1
  89. package/features/encryption/EncryptionService.js +11 -4
  90. package/features/encryption/EncryptionService.js.map +1 -1
  91. package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
  92. package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
  93. package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
  94. package/features/encryption/abstractions.d.ts +11 -0
  95. package/features/encryption/abstractions.js +2 -1
  96. package/features/encryption/abstractions.js.map +1 -1
  97. package/features/encryption/index.d.ts +1 -0
  98. package/features/encryption/index.js +1 -0
  99. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
  100. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +62 -0
  101. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
  102. package/features/hashing/ScryptHasher.d.ts +11 -0
  103. package/features/hashing/ScryptHasher.js +74 -0
  104. package/features/hashing/ScryptHasher.js.map +1 -0
  105. package/features/hashing/abstractions.d.ts +18 -0
  106. package/features/hashing/abstractions.js +5 -0
  107. package/features/hashing/abstractions.js.map +1 -0
  108. package/features/hashing/feature.d.ts +4 -0
  109. package/features/hashing/feature.js +11 -0
  110. package/features/hashing/feature.js.map +1 -0
  111. package/features/hashing/index.d.ts +2 -0
  112. package/features/hashing/index.js +1 -0
  113. package/features/httpClient/HttpClient.d.ts +7 -0
  114. package/features/httpClient/HttpClient.js +72 -0
  115. package/features/httpClient/HttpClient.js.map +1 -0
  116. package/features/httpClient/HttpRequestError.d.ts +10 -0
  117. package/features/httpClient/HttpRequestError.js +13 -0
  118. package/features/httpClient/HttpRequestError.js.map +1 -0
  119. package/features/httpClient/HttpStatusError.d.ts +12 -0
  120. package/features/httpClient/HttpStatusError.js +12 -0
  121. package/features/httpClient/HttpStatusError.js.map +1 -0
  122. package/features/httpClient/abstractions.d.ts +32 -0
  123. package/features/httpClient/abstractions.js +5 -0
  124. package/features/httpClient/abstractions.js.map +1 -0
  125. package/features/httpClient/feature.d.ts +4 -0
  126. package/features/httpClient/feature.js +11 -0
  127. package/features/httpClient/feature.js.map +1 -0
  128. package/features/httpClient/index.d.ts +3 -0
  129. package/features/httpClient/index.js +3 -0
  130. package/features/keyValueStore/GlobalKeyValueStore.d.ts +9 -3
  131. package/features/keyValueStore/GlobalKeyValueStore.js +12 -2
  132. package/features/keyValueStore/GlobalKeyValueStore.js.map +1 -1
  133. package/features/keyValueStore/KeyValueStore.d.ts +6 -2
  134. package/features/keyValueStore/KeyValueStore.js +13 -3
  135. package/features/keyValueStore/KeyValueStore.js.map +1 -1
  136. package/features/keyValueStore/KeyValueStoreRepository.d.ts +8 -2
  137. package/features/keyValueStore/KeyValueStoreRepository.js +82 -4
  138. package/features/keyValueStore/KeyValueStoreRepository.js.map +1 -1
  139. package/features/keyValueStore/abstractions.d.ts +132 -14
  140. package/features/keyValueStore/abstractions.js.map +1 -1
  141. package/features/keyValueStore/errors.d.ts +29 -0
  142. package/features/keyValueStore/errors.js +49 -1
  143. package/features/keyValueStore/errors.js.map +1 -1
  144. package/features/keyValueStore/index.d.ts +4 -1
  145. package/features/keyValueStore/index.js +1 -1
  146. package/features/publicUrls/NullPublicUrls.d.ts +11 -0
  147. package/features/publicUrls/NullPublicUrls.js +17 -0
  148. package/features/publicUrls/NullPublicUrls.js.map +1 -0
  149. package/features/publicUrls/PublicUrl.d.ts +24 -0
  150. package/features/publicUrls/PublicUrl.js +43 -0
  151. package/features/publicUrls/PublicUrl.js.map +1 -0
  152. package/features/publicUrls/__tests__/PublicUrl.test.d.ts +1 -0
  153. package/features/publicUrls/__tests__/PublicUrl.test.js +38 -0
  154. package/features/publicUrls/__tests__/PublicUrl.test.js.map +1 -0
  155. package/features/publicUrls/__tests__/PublicUrls.test.d.ts +1 -0
  156. package/features/publicUrls/__tests__/PublicUrls.test.js +14 -0
  157. package/features/publicUrls/__tests__/PublicUrls.test.js.map +1 -0
  158. package/features/publicUrls/abstractions.d.ts +27 -0
  159. package/features/publicUrls/abstractions.js +5 -0
  160. package/features/publicUrls/abstractions.js.map +1 -0
  161. package/features/publicUrls/feature.d.ts +8 -0
  162. package/features/publicUrls/feature.js +11 -0
  163. package/features/publicUrls/feature.js.map +1 -0
  164. package/features/publicUrls/index.d.ts +3 -0
  165. package/features/publicUrls/index.js +3 -0
  166. package/features/requestContext/RawAssumePermissions.d.ts +14 -0
  167. package/features/requestContext/RawAssumePermissions.js +19 -0
  168. package/features/requestContext/RawAssumePermissions.js.map +1 -0
  169. package/features/requestContext/RawAuthToken.d.ts +14 -0
  170. package/features/requestContext/RawAuthToken.js +19 -0
  171. package/features/requestContext/RawAuthToken.js.map +1 -0
  172. package/features/requestContext/RawTenantId.d.ts +14 -0
  173. package/features/requestContext/RawTenantId.js +19 -0
  174. package/features/requestContext/RawTenantId.js.map +1 -0
  175. package/features/requestContext/RequestIdentityLoader.d.ts +19 -0
  176. package/features/requestContext/RequestIdentityLoader.js +26 -0
  177. package/features/requestContext/RequestIdentityLoader.js.map +1 -0
  178. package/features/requestContext/RequestTenantLoader.d.ts +18 -0
  179. package/features/requestContext/RequestTenantLoader.js +52 -0
  180. package/features/requestContext/RequestTenantLoader.js.map +1 -0
  181. package/features/requestContext/abstractions.d.ts +75 -0
  182. package/features/requestContext/abstractions.js +9 -0
  183. package/features/requestContext/abstractions.js.map +1 -0
  184. package/features/requestContext/extractAssumePermissions.d.ts +14 -0
  185. package/features/requestContext/extractAssumePermissions.js +32 -0
  186. package/features/requestContext/extractAssumePermissions.js.map +1 -0
  187. package/features/requestContext/feature.d.ts +12 -0
  188. package/features/requestContext/feature.js +19 -0
  189. package/features/requestContext/feature.js.map +1 -0
  190. package/features/requestContext/index.d.ts +4 -0
  191. package/features/requestContext/index.js +3 -0
  192. package/features/security/IdentityContext/IdentityContext.d.ts +4 -3
  193. package/features/security/IdentityContext/IdentityContext.js +9 -6
  194. package/features/security/IdentityContext/IdentityContext.js.map +1 -1
  195. package/features/security/IdentityContext/abstractions.d.ts +5 -0
  196. package/features/security/IdentityContext/abstractions.js.map +1 -1
  197. package/features/security/apiKeys/ApiKeyAuthenticator.d.ts +14 -0
  198. package/features/security/apiKeys/ApiKeyAuthenticator.js +36 -0
  199. package/features/security/apiKeys/ApiKeyAuthenticator.js.map +1 -0
  200. package/features/security/apiKeys/ApiKeyAuthorizer.d.ts +10 -0
  201. package/features/security/apiKeys/ApiKeyAuthorizer.js +15 -0
  202. package/features/security/apiKeys/ApiKeyAuthorizer.js.map +1 -0
  203. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
  204. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
  205. package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -1
  206. package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -1
  207. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
  208. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
  209. package/features/security/apiKeys/feature.js +4 -0
  210. package/features/security/apiKeys/feature.js.map +1 -1
  211. package/features/security/apiKeys/shared/schemas.d.ts +2 -2
  212. package/features/security/apiKeys/shared/schemas.js +2 -2
  213. package/features/security/apiKeys/shared/schemas.js.map +1 -1
  214. package/features/security/authorization/AuthorizationContext/AuthorizationContext.d.ts +12 -3
  215. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js +31 -18
  216. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js.map +1 -1
  217. package/features/security/authorization/AuthorizationContext/abstractions.d.ts +2 -0
  218. package/features/security/authorization/AuthorizationContext/abstractions.js.map +1 -1
  219. package/features/security/authorization/AuthorizationContext/feature.js +6 -1
  220. package/features/security/authorization/AuthorizationContext/feature.js.map +1 -1
  221. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
  222. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
  223. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
  224. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +3 -3
  225. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
  226. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
  227. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
  228. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
  229. package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
  230. package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
  231. package/features/security/roles/CreateRole/schema.d.ts +1 -1
  232. package/features/security/roles/CreateRole/schema.js +1 -1
  233. package/features/security/roles/CreateRole/schema.js.map +1 -1
  234. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
  235. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  236. package/features/security/roles/UpdateRole/schema.d.ts +1 -1
  237. package/features/security/roles/UpdateRole/schema.js +1 -1
  238. package/features/security/roles/UpdateRole/schema.js.map +1 -1
  239. package/features/security/shared/description.d.ts +4 -0
  240. package/features/security/shared/description.js +7 -0
  241. package/features/security/shared/description.js.map +1 -0
  242. package/features/security/shared/index.d.ts +1 -0
  243. package/features/security/shared/index.js +1 -0
  244. package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
  245. package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
  246. package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
  247. package/features/security/teams/CreateTeam/schema.d.ts +1 -1
  248. package/features/security/teams/CreateTeam/schema.js +1 -1
  249. package/features/security/teams/CreateTeam/schema.js.map +1 -1
  250. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
  251. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
  252. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  253. package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
  254. package/features/security/teams/UpdateTeam/schema.js +1 -1
  255. package/features/security/teams/UpdateTeam/schema.js.map +1 -1
  256. package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
  257. package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
  258. package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
  259. package/features/slugify/DefaultSlugify.d.ts +8 -0
  260. package/features/slugify/DefaultSlugify.js +20 -0
  261. package/features/slugify/DefaultSlugify.js.map +1 -0
  262. package/features/slugify/abstractions.d.ts +12 -0
  263. package/features/slugify/abstractions.js +5 -0
  264. package/features/slugify/abstractions.js.map +1 -0
  265. package/features/slugify/feature.d.ts +4 -0
  266. package/features/slugify/feature.js +11 -0
  267. package/features/slugify/feature.js.map +1 -0
  268. package/features/slugify/index.d.ts +3 -0
  269. package/features/slugify/index.js +2 -0
  270. package/features/storageOperations/abstractions.d.ts +21 -0
  271. package/features/storageOperations/abstractions.js +10 -0
  272. package/features/storageOperations/abstractions.js.map +1 -0
  273. package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
  274. package/features/stringFormatter/DefaultStringFormatter.js +19 -0
  275. package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
  276. package/features/stringFormatter/abstractions.d.ts +11 -0
  277. package/features/stringFormatter/abstractions.js +5 -0
  278. package/features/stringFormatter/abstractions.js.map +1 -0
  279. package/features/stringFormatter/feature.d.ts +4 -0
  280. package/features/stringFormatter/feature.js +13 -0
  281. package/features/stringFormatter/feature.js.map +1 -0
  282. package/features/stringFormatter/index.d.ts +3 -0
  283. package/features/stringFormatter/index.js +2 -0
  284. package/features/task/TaskDefinition/abstractions.d.ts +69 -4
  285. package/features/task/TaskDefinition/abstractions.js +2 -1
  286. package/features/task/TaskDefinition/abstractions.js.map +1 -1
  287. package/features/tenancy/TenantContext/TenantContext.d.ts +1 -0
  288. package/features/tenancy/TenantContext/TenantContext.js +13 -8
  289. package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
  290. package/features/users/shared/types.d.ts +9 -7
  291. package/features/wcp/WcpContext/WcpContext.d.ts +12 -5
  292. package/features/wcp/WcpContext/WcpContext.js +29 -2
  293. package/features/wcp/WcpContext/WcpContext.js.map +1 -1
  294. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +11 -66
  295. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +71 -33
  296. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  297. package/features/wcp/WcpContext/feature.d.ts +1 -2
  298. package/features/wcp/WcpContext/feature.js +2 -2
  299. package/features/wcp/WcpContext/feature.js.map +1 -1
  300. package/features/wcp/WcpContext/index.d.ts +0 -1
  301. package/features/wcp/WcpContext/types.d.ts +0 -4
  302. package/features/wcp/WcpFeature.d.ts +1 -1
  303. package/features/wcp/WcpFeature.js +7 -2
  304. package/features/wcp/WcpFeature.js.map +1 -1
  305. package/features/wcp/WcpLicenseLoader.d.ts +25 -0
  306. package/features/wcp/WcpLicenseLoader.js +58 -0
  307. package/features/wcp/WcpLicenseLoader.js.map +1 -0
  308. package/features/wcp/WcpLicenseProvider.d.ts +21 -0
  309. package/features/wcp/WcpLicenseProvider.js +14 -0
  310. package/features/wcp/WcpLicenseProvider.js.map +1 -0
  311. package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
  312. package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
  313. package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
  314. package/graphql/ApiCoreSchemaFactory.d.ts +16 -0
  315. package/graphql/ApiCoreSchemaFactory.js +58 -0
  316. package/graphql/ApiCoreSchemaFactory.js.map +1 -0
  317. package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +10 -0
  318. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +53 -0
  319. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
  320. package/graphql/security/NotAuthorizedResponse.d.ts +1 -1
  321. package/graphql/security/NotAuthorizedResponse.js +1 -1
  322. package/graphql/security/NotAuthorizedResponse.js.map +1 -1
  323. package/graphql/security/SecuritySchemaFactory.d.ts +15 -0
  324. package/graphql/security/SecuritySchemaFactory.js +27 -0
  325. package/graphql/security/SecuritySchemaFactory.js.map +1 -0
  326. package/graphql/security/addApiKeySchema.d.ts +2 -0
  327. package/graphql/security/{apiKey.gql.js → addApiKeySchema.js} +45 -27
  328. package/graphql/security/addApiKeySchema.js.map +1 -0
  329. package/graphql/security/addIdentitySchema.d.ts +2 -0
  330. package/graphql/security/{identity.gql.js → addIdentitySchema.js} +52 -35
  331. package/graphql/security/addIdentitySchema.js.map +1 -0
  332. package/graphql/security/addRoleSchema.d.ts +2 -0
  333. package/graphql/security/addRoleSchema.js +137 -0
  334. package/graphql/security/addRoleSchema.js.map +1 -0
  335. package/graphql/security/addSecurityBaseSchema.d.ts +2 -0
  336. package/graphql/security/{base.gql.js → addSecurityBaseSchema.js} +14 -16
  337. package/graphql/security/addSecurityBaseSchema.js.map +1 -0
  338. package/graphql/security/addTeamSchema.d.ts +2 -0
  339. package/graphql/security/addTeamSchema.js +157 -0
  340. package/graphql/security/addTeamSchema.js.map +1 -0
  341. package/graphql/system/SystemSchemaFactory.d.ts +10 -0
  342. package/graphql/system/SystemSchemaFactory.js +70 -0
  343. package/graphql/system/SystemSchemaFactory.js.map +1 -0
  344. package/graphql/users/UsersSchemaFactory.d.ts +10 -0
  345. package/graphql/users/UsersSchemaFactory.js +195 -0
  346. package/graphql/users/UsersSchemaFactory.js.map +1 -0
  347. package/graphql/wcp/WcpSchemaFactory.d.ts +10 -0
  348. package/graphql/wcp/{graphql.js → WcpSchemaFactory.js} +32 -18
  349. package/graphql/wcp/WcpSchemaFactory.js.map +1 -0
  350. package/idp/JwksCache.d.ts +14 -3
  351. package/idp/JwksCache.js +97 -17
  352. package/idp/JwksCache.js.map +1 -1
  353. package/idp/JwksStoreFeature.d.ts +8 -0
  354. package/idp/JwksStoreFeature.js +11 -0
  355. package/idp/JwksStoreFeature.js.map +1 -0
  356. package/idp/MemoryJwksStore.d.ts +14 -0
  357. package/idp/MemoryJwksStore.js +21 -0
  358. package/idp/MemoryJwksStore.js.map +1 -0
  359. package/idp/OidcJwtIdentityProvider.js +5 -1
  360. package/idp/OidcJwtIdentityProvider.js.map +1 -1
  361. package/idp/abstractions.d.ts +24 -0
  362. package/idp/abstractions.js +2 -1
  363. package/idp/abstractions.js.map +1 -1
  364. package/idp/feature.js +1 -2
  365. package/idp/feature.js.map +1 -1
  366. package/idp/index.d.ts +1 -0
  367. package/idp/index.js +1 -0
  368. package/index.d.ts +3 -1
  369. package/index.js +3 -1
  370. package/package.json +22 -22
  371. package/testing/environment.d.ts +14 -0
  372. package/testing/environment.js +18 -0
  373. package/testing/environment.js.map +1 -0
  374. package/types/core.d.ts +17 -5
  375. package/types/security.d.ts +0 -6
  376. package/types/tenancy.d.ts +0 -17
  377. package/types/users.d.ts +2 -16
  378. package/createApiCore.d.ts +0 -7
  379. package/createApiCore.js +0 -26
  380. package/createApiCore.js.map +0 -1
  381. package/graphql/security/apiKey.gql.d.ts +0 -4
  382. package/graphql/security/apiKey.gql.js.map +0 -1
  383. package/graphql/security/base.gql.d.ts +0 -4
  384. package/graphql/security/base.gql.js.map +0 -1
  385. package/graphql/security/identity.gql.d.ts +0 -4
  386. package/graphql/security/identity.gql.js.map +0 -1
  387. package/graphql/security/index.d.ts +0 -1
  388. package/graphql/security/index.js +0 -15
  389. package/graphql/security/index.js.map +0 -1
  390. package/graphql/security/role.gql.d.ts +0 -4
  391. package/graphql/security/role.gql.js +0 -106
  392. package/graphql/security/role.gql.js.map +0 -1
  393. package/graphql/security/team.gql.d.ts +0 -4
  394. package/graphql/security/team.gql.js +0 -119
  395. package/graphql/security/team.gql.js.map +0 -1
  396. package/graphql/system/createSystemGraphQL.d.ts +0 -2
  397. package/graphql/system/createSystemGraphQL.js +0 -54
  398. package/graphql/system/createSystemGraphQL.js.map +0 -1
  399. package/graphql/users/user.gql.d.ts +0 -3
  400. package/graphql/users/user.gql.js +0 -167
  401. package/graphql/users/user.gql.js.map +0 -1
  402. package/graphql/wcp/graphql.d.ts +0 -2
  403. package/graphql/wcp/graphql.js.map +0 -1
  404. package/legacy/security/LegacyContext.d.ts +0 -36
  405. package/legacy/security/LegacyContext.js +0 -152
  406. package/legacy/security/LegacyContext.js.map +0 -1
  407. package/legacy/security/createSecurityContext.d.ts +0 -3
  408. package/legacy/security/createSecurityContext.js +0 -10
  409. package/legacy/security/createSecurityContext.js.map +0 -1
  410. package/legacy/security/plugins/apiKeyAuthentication.d.ts +0 -7
  411. package/legacy/security/plugins/apiKeyAuthentication.js +0 -20
  412. package/legacy/security/plugins/apiKeyAuthentication.js.map +0 -1
  413. package/legacy/security/plugins/apiKeyAuthorization.d.ts +0 -6
  414. package/legacy/security/plugins/apiKeyAuthorization.js +0 -13
  415. package/legacy/security/plugins/apiKeyAuthorization.js.map +0 -1
  416. package/legacy/security/plugins/authenticateUsingCookie.d.ts +0 -5
  417. package/legacy/security/plugins/authenticateUsingCookie.js +0 -23
  418. package/legacy/security/plugins/authenticateUsingCookie.js.map +0 -1
  419. package/legacy/security/plugins/authenticateUsingHttpHeader.d.ts +0 -5
  420. package/legacy/security/plugins/authenticateUsingHttpHeader.js +0 -20
  421. package/legacy/security/plugins/authenticateUsingHttpHeader.js.map +0 -1
  422. package/legacy/security/plugins/secureHeaders.d.ts +0 -1
  423. package/legacy/security/plugins/secureHeaders.js +0 -30
  424. package/legacy/security/plugins/secureHeaders.js.map +0 -1
  425. package/legacy/tenancy/LegacyContext.d.ts +0 -15
  426. package/legacy/tenancy/LegacyContext.js +0 -57
  427. package/legacy/tenancy/LegacyContext.js.map +0 -1
  428. package/legacy/tenancy/createTenancyContext.d.ts +0 -3
  429. package/legacy/tenancy/createTenancyContext.js +0 -31
  430. package/legacy/tenancy/createTenancyContext.js.map +0 -1
  431. package/legacy/users/LegacyContext.d.ts +0 -13
  432. package/legacy/users/LegacyContext.js +0 -55
  433. package/legacy/users/LegacyContext.js.map +0 -1
  434. package/legacy/users/createAdminUsersContext.d.ts +0 -3
  435. package/legacy/users/createAdminUsersContext.js +0 -12
  436. package/legacy/users/createAdminUsersContext.js.map +0 -1
  437. package/legacy/wcp/LegacyWcpContext.d.ts +0 -37
  438. package/legacy/wcp/LegacyWcpContext.js +0 -96
  439. package/legacy/wcp/LegacyWcpContext.js.map +0 -1
  440. package/legacy/wcp/context.d.ts +0 -5
  441. package/legacy/wcp/context.js +0 -46
  442. package/legacy/wcp/context.js.map +0 -1
@@ -0,0 +1,142 @@
1
+ import { createImplementation } from "@webiny/feature/api";
2
+ import { Debugger, DebuggerTransport } from "./abstractions.js";
3
+ import { IdentityContext } from "../security/IdentityContext/index.js";
4
+ import { BuildParams } from "../buildParams/index.js";
5
+ import { Logger } from "../logger/index.js";
6
+ import { createNamespaceFilter } from "./matchNamespace.js";
7
+ import { DEFAULT_LIMITS } from "./limits.js";
8
+ import { serialize } from "./serialize.js";
9
+ const FLUSH_TIMEOUT_MS = 2000;
10
+ const describeError = (error)=>{
11
+ if (error instanceof Error) return `${error.name}: ${error.message}`;
12
+ return "Unknown error.";
13
+ };
14
+ class DebuggerImpl {
15
+ constructor(identityContext, buildParams, logger, transports){
16
+ this.identityContext = identityContext;
17
+ this.buildParams = buildParams;
18
+ this.logger = logger;
19
+ this.transports = transports;
20
+ this.session = void 0;
21
+ this.limits = DEFAULT_LIMITS;
22
+ }
23
+ start(params) {
24
+ if (this.isDisabled()) return;
25
+ if (0 === params.namespaces.length) return;
26
+ this.session = {
27
+ namespaces: params.namespaces,
28
+ filter: createNamespaceFilter(params.namespaces),
29
+ startedAt: Date.now(),
30
+ entries: [],
31
+ bytes: 0,
32
+ dropped: 0,
33
+ truncated: false,
34
+ seq: 0
35
+ };
36
+ }
37
+ isEnabled(namespace) {
38
+ const session = this.session;
39
+ if (!session) return false;
40
+ if (this.identityContext.getIdentity().isAnonymous()) return false;
41
+ return session.filter.matches(namespace);
42
+ }
43
+ log(namespace, payload) {
44
+ try {
45
+ const session = this.session;
46
+ if (!session || !this.isEnabled(namespace)) return;
47
+ if (session.entries.length >= this.limits.entryCount) return;
48
+ const { json, bytes, truncated } = serialize(payload(), this.limits);
49
+ const entry = {
50
+ seq: ++session.seq,
51
+ namespace,
52
+ timestamp: Date.now(),
53
+ elapsed: Date.now() - session.startedAt,
54
+ json,
55
+ bytes
56
+ };
57
+ session.entries.push(entry);
58
+ session.bytes += bytes;
59
+ session.truncated = session.truncated || truncated;
60
+ this.enforceBudget(session);
61
+ } catch (ex) {
62
+ this.logger.error({
63
+ namespace,
64
+ error: describeError(ex)
65
+ }, "Debugger failed to capture a payload.");
66
+ }
67
+ }
68
+ async flush(target) {
69
+ const session = this.session;
70
+ this.session = void 0;
71
+ if (!session) return;
72
+ const transports = this.transports.filter((transport)=>{
73
+ try {
74
+ return transport.canDeliver(target);
75
+ } catch {
76
+ return false;
77
+ }
78
+ });
79
+ if (0 === transports.length) return;
80
+ const frozen = Object.freeze({
81
+ namespaces: session.namespaces,
82
+ startedAt: session.startedAt,
83
+ entries: session.entries,
84
+ bytes: session.bytes,
85
+ dropped: session.dropped,
86
+ truncated: session.truncated
87
+ });
88
+ const delivery = Promise.allSettled(transports.map(async (transport)=>await transport.deliver({
89
+ target,
90
+ session: frozen
91
+ })));
92
+ let timer;
93
+ const timeout = new Promise((resolve)=>{
94
+ timer = setTimeout(resolve, FLUSH_TIMEOUT_MS);
95
+ });
96
+ try {
97
+ const results = await Promise.race([
98
+ delivery,
99
+ timeout
100
+ ]);
101
+ if (Array.isArray(results)) {
102
+ for (const result of results)if ("rejected" === result.status) this.logger.error({
103
+ error: describeError(result.reason)
104
+ }, "Debugger transport failed to deliver.");
105
+ }
106
+ } finally{
107
+ if (timer) clearTimeout(timer);
108
+ }
109
+ }
110
+ discard() {
111
+ this.session = void 0;
112
+ }
113
+ isDisabled() {
114
+ return true === this.buildParams.get("DebuggerDisabled");
115
+ }
116
+ enforceBudget(session) {
117
+ while(session.bytes > this.limits.totalBytes && session.entries.length > 0){
118
+ const removed = session.entries.shift();
119
+ if (!removed) break;
120
+ session.bytes -= removed.bytes;
121
+ session.dropped++;
122
+ }
123
+ }
124
+ }
125
+ const Debugger_Debugger = createImplementation({
126
+ abstraction: Debugger,
127
+ implementation: DebuggerImpl,
128
+ dependencies: [
129
+ IdentityContext,
130
+ BuildParams,
131
+ Logger,
132
+ [
133
+ DebuggerTransport,
134
+ {
135
+ multiple: true
136
+ }
137
+ ]
138
+ ]
139
+ });
140
+ export { DebuggerImpl, Debugger_Debugger as Debugger };
141
+
142
+ //# sourceMappingURL=Debugger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/debugger/Debugger.js","sources":["../../../src/features/debugger/Debugger.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Debugger as DebuggerAbstraction } from \"./abstractions.js\";\nimport { DebuggerTransport } from \"./abstractions.js\";\nimport type { DebugNamespace } from \"./abstractions.js\";\nimport type { IDebugDeliveryTarget } from \"./abstractions.js\";\nimport type { IDebugEntry } from \"./abstractions.js\";\nimport type { IDebuggerStartParams } from \"./abstractions.js\";\nimport type { IDebugPayloadFactory } from \"./abstractions.js\";\nimport type { IDebugSession } from \"./abstractions.js\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/index.js\";\nimport { BuildParams } from \"~/features/buildParams/index.js\";\nimport { Logger } from \"~/features/logger/index.js\";\nimport { createNamespaceFilter } from \"./matchNamespace.js\";\nimport type { INamespaceFilter } from \"./matchNamespace.js\";\nimport { DEFAULT_LIMITS } from \"./limits.js\";\nimport type { IDebuggerLimits } from \"./limits.js\";\nimport { serialize } from \"./serialize.js\";\n\nconst FLUSH_TIMEOUT_MS = 2000;\n\n/**\n * Renders an error for logging without touching anything that could hold a captured payload.\n *\n * Deliberately not the error object itself: loggers spread it, so an error carrying a `data`\n * property would put debug payloads into the logs - the one sink they must never reach.\n */\nconst describeError = (error: unknown): string => {\n if (error instanceof Error) {\n return `${error.name}: ${error.message}`;\n }\n return \"Unknown error.\";\n};\n\ninterface IActiveSession extends IDebugSession {\n filter: INamespaceFilter;\n seq: number;\n}\n\nexport class DebuggerImpl implements DebuggerAbstraction.Interface {\n private session: IActiveSession | undefined = undefined;\n private readonly limits: IDebuggerLimits = DEFAULT_LIMITS;\n\n public constructor(\n private readonly identityContext: IdentityContext.Interface,\n private readonly buildParams: BuildParams.Interface,\n private readonly logger: Logger.Interface,\n private readonly transports: DebuggerTransport.Interface[]\n ) {}\n\n public start(params: IDebuggerStartParams): void {\n if (this.isDisabled()) {\n return;\n }\n\n if (params.namespaces.length === 0) {\n return;\n }\n\n /**\n * Always replace. A session surviving into the next request would mean one identity\n * receiving another's entries.\n */\n this.session = {\n namespaces: params.namespaces,\n filter: createNamespaceFilter(params.namespaces),\n startedAt: Date.now(),\n entries: [],\n bytes: 0,\n dropped: 0,\n truncated: false,\n seq: 0\n };\n }\n\n public isEnabled(namespace: DebugNamespace): boolean {\n const session = this.session;\n if (!session) {\n return false;\n }\n\n /**\n * An anonymous identity must never accumulate payloads. The flush-time permission check is\n * authoritative, but this earlier gate means there is nothing to leak if a future code path\n * delivers a session without passing through it.\n */\n if (this.identityContext.getIdentity().isAnonymous()) {\n return false;\n }\n\n return session.filter.matches(namespace);\n }\n\n public log(namespace: DebugNamespace, payload: IDebugPayloadFactory): void {\n /**\n * The debugger must never be able to break the request it is observing, and payload\n * factories are written in a hurry during an incident.\n */\n try {\n const session = this.session;\n if (!session || !this.isEnabled(namespace)) {\n return;\n }\n\n if (session.entries.length >= this.limits.entryCount) {\n return;\n }\n\n /**\n * Invoke and serialize immediately: this releases the closure and the payload graph, and\n * it is what makes the entry's size known, which is what makes the budget enforceable.\n */\n const { json, bytes, truncated } = serialize(payload(), this.limits);\n\n const entry: IDebugEntry = {\n seq: ++session.seq,\n namespace,\n timestamp: Date.now(),\n elapsed: Date.now() - session.startedAt,\n json,\n bytes\n };\n\n session.entries.push(entry);\n session.bytes += bytes;\n session.truncated = session.truncated || truncated;\n\n this.enforceBudget(session);\n } catch (ex) {\n this.logger.error(\n { namespace, error: describeError(ex) },\n \"Debugger failed to capture a payload.\"\n );\n }\n }\n\n public async flush(target: IDebugDeliveryTarget): Promise<void> {\n const session = this.session;\n this.session = undefined;\n\n if (!session) {\n return;\n }\n\n const transports = this.transports.filter(transport => {\n try {\n return transport.canDeliver(target);\n } catch {\n return false;\n }\n });\n\n if (transports.length === 0) {\n return;\n }\n\n const frozen: IDebugSession = Object.freeze({\n namespaces: session.namespaces,\n startedAt: session.startedAt,\n entries: session.entries,\n bytes: session.bytes,\n dropped: session.dropped,\n truncated: session.truncated\n });\n\n const delivery = Promise.allSettled(\n transports.map(async transport => {\n return await transport.deliver({ target, session: frozen });\n })\n );\n\n /**\n * In-memory delivery is instant, but a future network sink is not, and debug data is never\n * worth making the app feel broken. The timer is cleared so it cannot hold the event loop\n * open after the response, which on Lambda would delay the freeze.\n */\n let timer: NodeJS.Timeout | undefined;\n const timeout = new Promise<void>(resolve => {\n timer = setTimeout(resolve, FLUSH_TIMEOUT_MS);\n });\n\n try {\n const results = await Promise.race([delivery, timeout]);\n if (Array.isArray(results)) {\n for (const result of results) {\n if (result.status === \"rejected\") {\n /**\n * Only the error - never the session or any entry. The logger writes to\n * CloudWatch or the server's output, which is the one place debug payloads\n * must never reach.\n */\n this.logger.error(\n { error: describeError(result.reason) },\n \"Debugger transport failed to deliver.\"\n );\n }\n }\n }\n } finally {\n if (timer) {\n clearTimeout(timer);\n }\n }\n }\n\n public discard(): void {\n this.session = undefined;\n }\n\n private isDisabled(): boolean {\n return this.buildParams.get<boolean>(\"DebuggerDisabled\") === true;\n }\n\n /**\n * Drops entries from the front until the session fits the byte budget. The client reproduces the\n * bug, so the failure is at the end of the session and the tail is what matters.\n */\n private enforceBudget(session: IActiveSession): void {\n while (session.bytes > this.limits.totalBytes && session.entries.length > 0) {\n const removed = session.entries.shift();\n if (!removed) {\n break;\n }\n session.bytes -= removed.bytes;\n session.dropped++;\n }\n }\n}\n\nexport const Debugger = createImplementation({\n abstraction: DebuggerAbstraction,\n implementation: DebuggerImpl,\n dependencies: [IdentityContext, BuildParams, Logger, [DebuggerTransport, { multiple: true }]]\n});\n"],"names":["FLUSH_TIMEOUT_MS","describeError","error","Error","DebuggerImpl","identityContext","buildParams","logger","transports","undefined","DEFAULT_LIMITS","params","createNamespaceFilter","Date","namespace","session","payload","json","bytes","truncated","serialize","entry","ex","target","transport","frozen","Object","delivery","Promise","timer","timeout","resolve","setTimeout","results","Array","result","clearTimeout","removed","Debugger","createImplementation","DebuggerAbstraction","IdentityContext","BuildParams","Logger","DebuggerTransport"],"mappings":";;;;;;;;AAkBA,MAAMA,mBAAmB;AAQzB,MAAMC,gBAAgB,CAACC;IACnB,IAAIA,iBAAiBC,OACjB,OAAO,GAAGD,MAAM,IAAI,CAAC,EAAE,EAAEA,MAAM,OAAO,EAAE;IAE5C,OAAO;AACX;AAOO,MAAME;I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C,cAAckC,OAAO,MAAM;gBAAE,GACtC;YAGZ;QAER,SAAU;YACN,IAAIN,OACAO,aAAaP;QAErB;IACJ;IAEO,UAAgB;QACnB,IAAI,CAAC,OAAO,GAAGpB;IACnB;IAEQ,aAAsB;QAC1B,OAAO,AAAsD,SAAtD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAU;IACzC;IAMQ,cAAcM,OAAuB,EAAQ;QACjD,MAAOA,QAAQ,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,IAAIA,QAAQ,OAAO,CAAC,MAAM,GAAG,EAAG;YACzE,MAAMsB,UAAUtB,QAAQ,OAAO,CAAC,KAAK;YACrC,IAAI,CAACsB,SACD;YAEJtB,QAAQ,KAAK,IAAIsB,QAAQ,KAAK;YAC9BtB,QAAQ,OAAO;QACnB;IACJ;AACJ;AAEO,MAAMuB,oBAAWC,qBAAqB;IACzC,aAAaC;IACb,gBAAgBpC;IAChB,cAAc;QAACqC;QAAiBC;QAAaC;QAAQ;YAACC;YAAmB;gBAAE,UAAU;YAAK;SAAE;KAAC;AACjG"}
@@ -0,0 +1,45 @@
1
+ import { HttpRouteHandler } from "@webiny/event-handler-core";
2
+ import { RequestId } from "@webiny/event-handler-core";
3
+ import type { IHttpResponse } from "@webiny/event-handler-core";
4
+ import type { IHttpResponseBuilder } from "@webiny/event-handler-core";
5
+ import { Debugger } from "./abstractions.js";
6
+ import { IdentityContext } from "../../features/security/IdentityContext/index.js";
7
+ import { Logger } from "../../features/logger/index.js";
8
+ export declare const DEBUG_HEADER = "x-webiny-debug";
9
+ type RouteResult = IHttpResponse | IHttpResponseBuilder | void;
10
+ /**
11
+ * Opens a capture session around every HTTP route and hands it over once the route has produced its
12
+ * response.
13
+ *
14
+ * It wraps the route rather than the GraphQL execution, because CMS resolvers run nested GraphQL
15
+ * executions internally. Attaching there would put the session on a result that is then thrown
16
+ * away; at the route there is exactly one response per request.
17
+ */
18
+ declare class DebuggerRouteDecoratorImpl implements HttpRouteHandler.Interface {
19
+ private readonly debuggerService;
20
+ private readonly identityContext;
21
+ private readonly logger;
22
+ private readonly requestId;
23
+ private readonly decoratee;
24
+ constructor(debuggerService: Debugger.Interface, identityContext: IdentityContext.Interface, logger: Logger.Interface, requestId: RequestId.Interface | undefined, decoratee: HttpRouteHandler.Interface);
25
+ handle(request: HttpRouteHandler.Request, response: HttpRouteHandler.Response): Promise<RouteResult>;
26
+ /**
27
+ * A session starts on every request, and the permission check at flush decides whether anything
28
+ * is delivered or the whole thing is discarded.
29
+ *
30
+ * Nothing is required from the client. The header is honoured when present, so a direct API
31
+ * client can narrow what it captures.
32
+ */
33
+ private start;
34
+ /**
35
+ * Performs the permission gate and hands the session to the transports.
36
+ *
37
+ * The whole body is guarded: an error here would turn a working response into a 500, and only
38
+ * for the identities that are allowed to debug.
39
+ */
40
+ private flush;
41
+ }
42
+ export declare const DebuggerRouteDecorator: typeof DebuggerRouteDecoratorImpl & {
43
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/event-handler-core").IHttpRoute>;
44
+ };
45
+ export {};
@@ -0,0 +1,107 @@
1
+ import { HttpRouteHandler, RequestId } from "@webiny/event-handler-core";
2
+ import { Debugger } from "./abstractions.js";
3
+ import { IdentityContext } from "../security/IdentityContext/index.js";
4
+ import { Logger } from "../logger/index.js";
5
+ import { parseNamespaceHeader } from "./parseNamespaceHeader.js";
6
+ import { canCaptureDebugData } from "./permissions.js";
7
+ import { GRAPHQL_TARGET } from "./GraphQLDebuggerTransport.js";
8
+ const DEBUG_HEADER = "x-webiny-debug";
9
+ const isPlainObject = (value)=>"object" == typeof value && null !== value && !Array.isArray(value);
10
+ const isGraphQLResult = (value)=>isPlainObject(value) && ("data" in value || "errors" in value);
11
+ const isResponseBuilder = (value)=>isPlainObject(value) && "function" == typeof value.toResponse;
12
+ const readBody = (result, response)=>{
13
+ if (isResponseBuilder(result)) return result.toResponse().body;
14
+ if (result) return result.body;
15
+ return response.toResponse().body;
16
+ };
17
+ const resolveTarget = (body)=>{
18
+ const candidate = Array.isArray(body) ? body.at(-1) : body;
19
+ if (isGraphQLResult(candidate)) return candidate;
20
+ };
21
+ const readOperationNames = (body)=>{
22
+ const operations = Array.isArray(body) ? body : [
23
+ body
24
+ ];
25
+ return operations.map((operation)=>{
26
+ if (isPlainObject(operation) && "string" == typeof operation.operationName) return operation.operationName;
27
+ }).filter((name)=>Boolean(name));
28
+ };
29
+ const readDebugHeader = (headers)=>{
30
+ if (!headers) return;
31
+ for (const key of Object.keys(headers))if (key.toLowerCase() === DEBUG_HEADER) return headers[key];
32
+ };
33
+ const describeError = (error)=>{
34
+ if (error instanceof Error) return `${error.name}: ${error.message}`;
35
+ return "Unknown error.";
36
+ };
37
+ class DebuggerRouteDecoratorImpl {
38
+ constructor(debuggerService, identityContext, logger, requestId, decoratee){
39
+ this.debuggerService = debuggerService;
40
+ this.identityContext = identityContext;
41
+ this.logger = logger;
42
+ this.requestId = requestId;
43
+ this.decoratee = decoratee;
44
+ }
45
+ async handle(request, response) {
46
+ this.start(request);
47
+ let result;
48
+ try {
49
+ result = await this.decoratee.handle(request, response);
50
+ } catch (ex) {
51
+ this.debuggerService.discard();
52
+ throw ex;
53
+ }
54
+ await this.flush(request, readBody(result, response));
55
+ return result;
56
+ }
57
+ start(request) {
58
+ try {
59
+ const requested = parseNamespaceHeader(readDebugHeader(request.headers));
60
+ const namespaces = requested.length > 0 ? requested : [
61
+ "*"
62
+ ];
63
+ this.debuggerService.start({
64
+ namespaces
65
+ });
66
+ } catch {}
67
+ }
68
+ async flush(request, body) {
69
+ try {
70
+ const result = resolveTarget(body);
71
+ if (!result) return void this.debuggerService.discard();
72
+ if (this.identityContext.getIdentity().isAnonymous()) return void this.debuggerService.discard();
73
+ const isAuthorized = this.identityContext.isAuthorizationEnabled() && await canCaptureDebugData(this.identityContext);
74
+ if (!isAuthorized) return void this.debuggerService.discard();
75
+ const target = {
76
+ type: GRAPHQL_TARGET,
77
+ result,
78
+ requestId: this.requestId?.value ?? "",
79
+ operations: readOperationNames(request.body),
80
+ url: request.path
81
+ };
82
+ await this.debuggerService.flush(target);
83
+ } catch (ex) {
84
+ this.logger.error({
85
+ error: describeError(ex)
86
+ }, "Debugger failed to flush.");
87
+ this.debuggerService.discard();
88
+ }
89
+ }
90
+ }
91
+ const DebuggerRouteDecorator = HttpRouteHandler.createDecorator({
92
+ decorator: DebuggerRouteDecoratorImpl,
93
+ dependencies: [
94
+ Debugger,
95
+ IdentityContext,
96
+ Logger,
97
+ [
98
+ RequestId,
99
+ {
100
+ optional: true
101
+ }
102
+ ]
103
+ ]
104
+ });
105
+ export { DEBUG_HEADER, DebuggerRouteDecorator };
106
+
107
+ //# sourceMappingURL=DebuggerRouteDecorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/debugger/DebuggerRouteDecorator.js","sources":["../../../src/features/debugger/DebuggerRouteDecorator.ts"],"sourcesContent":["import { HttpRouteHandler } from \"@webiny/event-handler-core\";\nimport { RequestId } from \"@webiny/event-handler-core\";\nimport type { IHttpResponse } from \"@webiny/event-handler-core\";\nimport type { IHttpResponseBuilder } from \"@webiny/event-handler-core\";\nimport { Debugger } from \"./abstractions.js\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/index.js\";\nimport { Logger } from \"~/features/logger/index.js\";\nimport { parseNamespaceHeader } from \"./parseNamespaceHeader.js\";\nimport { canCaptureDebugData } from \"./permissions.js\";\nimport { GRAPHQL_TARGET } from \"./GraphQLDebuggerTransport.js\";\nimport type { IGraphQLDeliveryTarget } from \"./GraphQLDebuggerTransport.js\";\n\nexport const DEBUG_HEADER = \"x-webiny-debug\";\n\ntype RouteResult = IHttpResponse | IHttpResponseBuilder | void;\n\nconst isPlainObject = (value: unknown): value is Record<string, any> => {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n};\n\n/**\n * A GraphQL result carries `data` or `errors`. Anything else (asset delivery, a plain string body)\n * is not ours to write to.\n */\nconst isGraphQLResult = (value: unknown): value is Record<string, any> => {\n return isPlainObject(value) && (\"data\" in value || \"errors\" in value);\n};\n\nconst isResponseBuilder = (value: unknown): value is IHttpResponseBuilder => {\n return isPlainObject(value) && typeof value.toResponse === \"function\";\n};\n\n/**\n * Finds the body a route produced, whichever of its three return styles it used. The body object is\n * the same reference the transport later serializes, so writing to it is enough.\n */\nconst readBody = (result: RouteResult, response: IHttpResponseBuilder): unknown => {\n if (isResponseBuilder(result)) {\n return result.toResponse().body;\n }\n if (result) {\n return result.body;\n }\n return response.toResponse().body;\n};\n\n/**\n * Batched requests produce an array of results. The session spans the whole HTTP request, so it is\n * attached once, to the last element. Duplicating it per operation would multiply it against the\n * byte budget.\n */\nconst resolveTarget = (body: unknown): Record<string, any> | undefined => {\n const candidate = Array.isArray(body) ? body.at(-1) : body;\n if (isGraphQLResult(candidate)) {\n return candidate;\n }\n return undefined;\n};\n\nconst readOperationNames = (body: unknown): string[] => {\n const operations = Array.isArray(body) ? body : [body];\n return operations\n .map(operation => {\n if (isPlainObject(operation) && typeof operation.operationName === \"string\") {\n return operation.operationName;\n }\n return undefined;\n })\n .filter((name): name is string => Boolean(name));\n};\n\n/**\n * Header names are case-insensitive, and the casing that reaches a route depends on the transport.\n */\nconst readDebugHeader = (headers: Record<string, string> | undefined): string | undefined => {\n if (!headers) {\n return undefined;\n }\n for (const key of Object.keys(headers)) {\n if (key.toLowerCase() === DEBUG_HEADER) {\n return headers[key];\n }\n }\n return undefined;\n};\n\nconst describeError = (error: unknown): string => {\n if (error instanceof Error) {\n return `${error.name}: ${error.message}`;\n }\n return \"Unknown error.\";\n};\n\n/**\n * Opens a capture session around every HTTP route and hands it over once the route has produced its\n * response.\n *\n * It wraps the route rather than the GraphQL execution, because CMS resolvers run nested GraphQL\n * executions internally. Attaching there would put the session on a result that is then thrown\n * away; at the route there is exactly one response per request.\n */\nclass DebuggerRouteDecoratorImpl implements HttpRouteHandler.Interface {\n public constructor(\n private readonly debuggerService: Debugger.Interface,\n private readonly identityContext: IdentityContext.Interface,\n private readonly logger: Logger.Interface,\n private readonly requestId: RequestId.Interface | undefined,\n private readonly decoratee: HttpRouteHandler.Interface\n ) {}\n\n public async handle(\n request: HttpRouteHandler.Request,\n response: HttpRouteHandler.Response\n ): Promise<RouteResult> {\n this.start(request);\n\n let result: RouteResult;\n try {\n result = await this.decoratee.handle(request, response);\n } catch (ex) {\n this.debuggerService.discard();\n throw ex;\n }\n\n await this.flush(request, readBody(result, response));\n\n return result;\n }\n\n /**\n * A session starts on every request, and the permission check at flush decides whether anything\n * is delivered or the whole thing is discarded.\n *\n * Nothing is required from the client. The header is honoured when present, so a direct API\n * client can narrow what it captures.\n */\n private start(request: HttpRouteHandler.Request): void {\n /**\n * Must never throw: a malformed header must not turn into a 500 for the whole request.\n */\n try {\n const requested = parseNamespaceHeader(readDebugHeader(request.headers));\n const namespaces = requested.length > 0 ? requested : [\"*\"];\n\n this.debuggerService.start({ namespaces });\n } catch {\n // A debugger that cannot start is not a reason to fail the request.\n }\n }\n\n /**\n * Performs the permission gate and hands the session to the transports.\n *\n * The whole body is guarded: an error here would turn a working response into a 500, and only\n * for the identities that are allowed to debug.\n */\n private async flush(request: HttpRouteHandler.Request, body: unknown): Promise<void> {\n try {\n const result = resolveTarget(body);\n if (!result) {\n this.debuggerService.discard();\n return;\n }\n\n /**\n * Anonymous callers are rejected before permissions are resolved, because listing them\n * runs every registered authorizer, and some of those hit the database.\n */\n if (this.identityContext.getIdentity().isAnonymous()) {\n this.debuggerService.discard();\n return;\n }\n\n /**\n * Permission lookups return a wildcard whenever authorization is disabled, so a flush\n * running inside a `withoutAuthorization` scope would pass for anyone.\n */\n const isAuthorized =\n this.identityContext.isAuthorizationEnabled() &&\n (await canCaptureDebugData(this.identityContext));\n\n if (!isAuthorized) {\n /**\n * Nothing is written. Reporting the denial would tell every unauthorized caller that\n * the feature exists, and the Admin app already knows from the identity's own\n * permissions whether capture is available to it.\n */\n this.debuggerService.discard();\n return;\n }\n\n const target: IGraphQLDeliveryTarget = {\n type: GRAPHQL_TARGET,\n result,\n requestId: this.requestId?.value ?? \"\",\n operations: readOperationNames(request.body),\n /**\n * Which endpoint this was. An Admin session talks to several (the main API and the\n * CMS manage, read and preview endpoints) and knowing which one produced an entry is\n * most of the context when reading a report.\n */\n url: request.path\n };\n\n await this.debuggerService.flush(target);\n } catch (ex) {\n /**\n * Only the message, never the session or the payload.\n */\n this.logger.error({ error: describeError(ex) }, \"Debugger failed to flush.\");\n this.debuggerService.discard();\n }\n }\n}\n\nexport const DebuggerRouteDecorator = HttpRouteHandler.createDecorator({\n decorator: DebuggerRouteDecoratorImpl,\n dependencies: [Debugger, IdentityContext, Logger, [RequestId, { optional: true }]]\n});\n"],"names":["DEBUG_HEADER","isPlainObject","value","Array","isGraphQLResult","isResponseBuilder","readBody","result","response","resolveTarget","body","candidate","readOperationNames","operations","operation","name","Boolean","readDebugHeader","headers","key","Object","describeError","error","Error","DebuggerRouteDecoratorImpl","debuggerService","identityContext","logger","requestId","decoratee","request","ex","requested","parseNamespaceHeader","namespaces","isAuthorized","canCaptureDebugData","target","GRAPHQL_TARGET","DebuggerRouteDecorator","HttpRouteHandler","Debugger","IdentityContext","Logger","RequestId"],"mappings":";;;;;;;AAYO,MAAMA,eAAe;AAI5B,MAAMC,gBAAgB,CAACC,QACZ,AAAiB,YAAjB,OAAOA,SAAsBA,AAAU,SAAVA,SAAkB,CAACC,MAAM,OAAO,CAACD;AAOzE,MAAME,kBAAkB,CAACF,QACdD,cAAcC,UAAW,WAAUA,SAAS,YAAYA,KAAI;AAGvE,MAAMG,oBAAoB,CAACH,QAChBD,cAAcC,UAAU,AAA4B,cAA5B,OAAOA,MAAM,UAAU;AAO1D,MAAMI,WAAW,CAACC,QAAqBC;IACnC,IAAIH,kBAAkBE,SAClB,OAAOA,OAAO,UAAU,GAAG,IAAI;IAEnC,IAAIA,QACA,OAAOA,OAAO,IAAI;IAEtB,OAAOC,SAAS,UAAU,GAAG,IAAI;AACrC;AAOA,MAAMC,gBAAgB,CAACC;IACnB,MAAMC,YAAYR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AAME,YAAYC,qBAAqBhB,gBAAgBa,QAAQ,OAAO;YACtE,MAAMI,aAAaF,UAAU,MAAM,GAAG,IAAIA,YAAY;gBAAC;aAAI;YAE3D,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC;gBAAEE;YAAW;QAC5C,EAAE,OAAM,CAER;IACJ;IAQA,MAAc,MAAMJ,OAAiC,EAAEpB,IAAa,EAAiB;QACjF,IAAI;YACA,MAAMH,SAASE,cAAcC;YAC7B,IAAI,CAACH,QAAQ,YACT,IAAI,CAAC,eAAe,CAAC,OAAO;YAQhC,IAAI,IAAI,CAAC,eAAe,CAAC,WAAW,GAAG,WAAW,IAAI,YAClD,IAAI,CAAC,eAAe,CAAC,OAAO;YAQhC,MAAM4B,eACF,IAAI,CAAC,eAAe,CAAC,sBAAsB,MAC1C,MAAMC,oBAAoB,IAAI,CAAC,eAAe;YAEnD,IAAI,CAACD,cAAc,YAMf,IAAI,CAAC,eAAe,CAAC,OAAO;YAIhC,MAAME,SAAiC;gBACnC,MAAMC;gBACN/B;gBACA,WAAW,IAAI,CAAC,SAAS,EAAE,SAAS;gBACpC,YAAYK,mBAAmBkB,QAAQ,IAAI;gBAM3C,KAAKA,QAAQ,IAAI;YACrB;YAEA,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAACO;QACrC,EAAE,OAAON,IAAI;YAIT,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBAAE,OAAOV,cAAcU;YAAI,GAAG;YAChD,IAAI,CAAC,eAAe,CAAC,OAAO;QAChC;IACJ;AACJ;AAEO,MAAMQ,yBAAyBC,iBAAiB,eAAe,CAAC;IACnE,WAAWhB;IACX,cAAc;QAACiB;QAAUC;QAAiBC;QAAQ;YAACC;YAAW;gBAAE,UAAU;YAAK;SAAE;KAAC;AACtF"}
@@ -0,0 +1,28 @@
1
+ import { DebuggerTransport as DebuggerTransportAbstraction } from "./abstractions.js";
2
+ import type { IDebugDeliveryTarget } from "./abstractions.js";
3
+ import type { IDebuggerTransportDeliverParams } from "./abstractions.js";
4
+ export declare const GRAPHQL_TARGET = "graphql";
5
+ export interface IGraphQLDeliveryTarget extends IDebugDeliveryTarget {
6
+ type: typeof GRAPHQL_TARGET;
7
+ /**
8
+ * Already resolved to a single result object - never the array. Batched requests are reduced to
9
+ * their last element by the route decorator, so this transport never has to know about batching.
10
+ */
11
+ result: Record<string, any>;
12
+ requestId: string;
13
+ operations: string[];
14
+ url: string;
15
+ }
16
+ /**
17
+ * Writes a finished session into the GraphQL response's `extensions` property.
18
+ */
19
+ export declare class GraphQLDebuggerTransportImpl implements DebuggerTransportAbstraction.Interface {
20
+ canDeliver(target: IDebugDeliveryTarget): boolean;
21
+ deliver({ target, session }: IDebuggerTransportDeliverParams): void;
22
+ }
23
+ /**
24
+ * Merges a value under `extensions.debug`, never assigning `extensions` wholesale - other plugins
25
+ * write to it too.
26
+ */
27
+ export declare const writeExtension: (result: Record<string, any>, debug: Record<string, any>) => void;
28
+ export declare const GraphQLDebuggerTransport: import("@webiny/di").Implementation<typeof GraphQLDebuggerTransportImpl>;
@@ -0,0 +1,45 @@
1
+ import { createImplementation } from "@webiny/feature/api";
2
+ import { DebuggerTransport } from "./abstractions.js";
3
+ const GRAPHQL_TARGET = "graphql";
4
+ const isGraphQLTarget = (target)=>target.type === GRAPHQL_TARGET;
5
+ class GraphQLDebuggerTransportImpl {
6
+ canDeliver(target) {
7
+ return isGraphQLTarget(target);
8
+ }
9
+ deliver({ target, session }) {
10
+ if (!isGraphQLTarget(target)) return;
11
+ if (0 === session.entries.length) return;
12
+ const entries = session.entries.map((entry)=>({
13
+ seq: entry.seq,
14
+ namespace: entry.namespace,
15
+ timestamp: entry.timestamp,
16
+ elapsed: entry.elapsed,
17
+ data: JSON.parse(entry.json)
18
+ }));
19
+ writeExtension(target.result, {
20
+ enabled: true,
21
+ requestId: target.requestId,
22
+ url: target.url,
23
+ namespaces: session.namespaces,
24
+ operations: target.operations,
25
+ entries,
26
+ bytes: session.bytes,
27
+ dropped: session.dropped,
28
+ truncated: session.truncated
29
+ });
30
+ }
31
+ }
32
+ const writeExtension = (result, debug)=>{
33
+ result.extensions = {
34
+ ...result.extensions,
35
+ debug
36
+ };
37
+ };
38
+ const GraphQLDebuggerTransport = createImplementation({
39
+ abstraction: DebuggerTransport,
40
+ implementation: GraphQLDebuggerTransportImpl,
41
+ dependencies: []
42
+ });
43
+ export { GRAPHQL_TARGET, GraphQLDebuggerTransport, GraphQLDebuggerTransportImpl, writeExtension };
44
+
45
+ //# sourceMappingURL=GraphQLDebuggerTransport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/debugger/GraphQLDebuggerTransport.js","sources":["../../../src/features/debugger/GraphQLDebuggerTransport.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { DebuggerTransport as DebuggerTransportAbstraction } from \"./abstractions.js\";\nimport type { IDebugDeliveryTarget } from \"./abstractions.js\";\nimport type { IDebuggerTransportDeliverParams } from \"./abstractions.js\";\n\nexport const GRAPHQL_TARGET = \"graphql\";\n\nexport interface IGraphQLDeliveryTarget extends IDebugDeliveryTarget {\n type: typeof GRAPHQL_TARGET;\n /**\n * Already resolved to a single result object - never the array. Batched requests are reduced to\n * their last element by the route decorator, so this transport never has to know about batching.\n */\n result: Record<string, any>;\n requestId: string;\n operations: string[];\n url: string;\n}\n\nconst isGraphQLTarget = (target: IDebugDeliveryTarget): target is IGraphQLDeliveryTarget => {\n return target.type === GRAPHQL_TARGET;\n};\n\n/**\n * Writes a finished session into the GraphQL response's `extensions` property.\n */\nexport class GraphQLDebuggerTransportImpl implements DebuggerTransportAbstraction.Interface {\n public canDeliver(target: IDebugDeliveryTarget): boolean {\n return isGraphQLTarget(target);\n }\n\n public deliver({ target, session }: IDebuggerTransportDeliverParams): void {\n if (!isGraphQLTarget(target)) {\n return;\n }\n\n /**\n * Nothing matched the filter on this request. Writing an envelope with an empty `entries`\n * array would put a payload on every response for no benefit, and give whoever reads the\n * report a pile of blanks to scroll past.\n */\n if (session.entries.length === 0) {\n return;\n }\n\n const entries = session.entries.map(entry => {\n return {\n seq: entry.seq,\n namespace: entry.namespace,\n timestamp: entry.timestamp,\n elapsed: entry.elapsed,\n /**\n * Entries are buffered as strings so the payload graph can be released at capture\n * time. Parsing here is what puts structured data in the response rather than JSON\n * inside JSON.\n */\n data: JSON.parse(entry.json)\n };\n });\n\n writeExtension(target.result, {\n enabled: true,\n requestId: target.requestId,\n url: target.url,\n namespaces: session.namespaces,\n operations: target.operations,\n entries,\n bytes: session.bytes,\n dropped: session.dropped,\n truncated: session.truncated\n });\n }\n}\n\n/**\n * Merges a value under `extensions.debug`, never assigning `extensions` wholesale - other plugins\n * write to it too.\n */\nexport const writeExtension = (result: Record<string, any>, debug: Record<string, any>): void => {\n result.extensions = { ...result.extensions, debug };\n};\n\nexport const GraphQLDebuggerTransport = createImplementation({\n abstraction: DebuggerTransportAbstraction,\n implementation: GraphQLDebuggerTransportImpl,\n dependencies: []\n});\n"],"names":["GRAPHQL_TARGET","isGraphQLTarget","target","GraphQLDebuggerTransportImpl","session","entries","entry","JSON","writeExtension","result","debug","GraphQLDebuggerTransport","createImplementation","DebuggerTransportAbstraction"],"mappings":";;AAKO,MAAMA,iBAAiB;AAc9B,MAAMC,kBAAkB,CAACC,SACdA,OAAO,IAAI,KAAKF;AAMpB,MAAMG;IACF,WAAWD,MAA4B,EAAW;QACrD,OAAOD,gBAAgBC;IAC3B;IAEO,QAAQ,EAAEA,MAAM,EAAEE,OAAO,EAAmC,EAAQ;QACvE,IAAI,CAACH,gBAAgBC,SACjB;QAQJ,IAAIE,AAA2B,MAA3BA,QAAQ,OAAO,CAAC,MAAM,EACtB;QAGJ,MAAMC,UAAUD,QAAQ,OAAO,CAAC,GAAG,CAACE,CAAAA,QACzB;gBACH,KAAKA,MAAM,GAAG;gBACd,WAAWA,MAAM,SAAS;gBAC1B,WAAWA,MAAM,SAAS;gBAC1B,SAASA,MAAM,OAAO;gBAMtB,MAAMC,KAAK,KAAK,CAACD,MAAM,IAAI;YAC/B;QAGJE,eAAeN,OAAO,MAAM,EAAE;YAC1B,SAAS;YACT,WAAWA,OAAO,SAAS;YAC3B,KAAKA,OAAO,GAAG;YACf,YAAYE,QAAQ,UAAU;YAC9B,YAAYF,OAAO,UAAU;YAC7BG;YACA,OAAOD,QAAQ,KAAK;YACpB,SAASA,QAAQ,OAAO;YACxB,WAAWA,QAAQ,SAAS;QAChC;IACJ;AACJ;AAMO,MAAMI,iBAAiB,CAACC,QAA6BC;IACxDD,OAAO,UAAU,GAAG;QAAE,GAAGA,OAAO,UAAU;QAAEC;IAAM;AACtD;AAEO,MAAMC,2BAA2BC,qBAAqB;IACzD,aAAaC;IACb,gBAAgBV;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,68 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { createNamespaceFilter } from "../matchNamespace.js";
3
+ import { parseNamespaceHeader } from "../parseNamespaceHeader.js";
4
+ describe("parseNamespaceHeader", ()=>{
5
+ it("should not start a session when the header is absent or empty", ()=>{
6
+ expect(parseNamespaceHeader(void 0)).toEqual([]);
7
+ expect(parseNamespaceHeader("")).toEqual([]);
8
+ expect(parseNamespaceHeader(" ")).toEqual([]);
9
+ });
10
+ it("should treat the truthy shorthands as capture-all", ()=>{
11
+ expect(parseNamespaceHeader("1")).toEqual([
12
+ "*"
13
+ ]);
14
+ expect(parseNamespaceHeader("true")).toEqual([
15
+ "*"
16
+ ]);
17
+ expect(parseNamespaceHeader("*")).toEqual([
18
+ "*"
19
+ ]);
20
+ });
21
+ it("should trim tokens, since duplicate headers arrive comma-joined with spaces", ()=>{
22
+ expect(parseNamespaceHeader("cms.os.*, fm.*")).toEqual([
23
+ "cms.os.*",
24
+ "fm.*"
25
+ ]);
26
+ });
27
+ it("should accept the array form of a repeated header", ()=>{
28
+ expect(parseNamespaceHeader([
29
+ "cms.os.*",
30
+ "fm.*"
31
+ ])).toEqual([
32
+ "cms.os.*",
33
+ "fm.*"
34
+ ]);
35
+ });
36
+ });
37
+ describe("createNamespaceFilter", ()=>{
38
+ it("should match everything for the wildcard", ()=>{
39
+ const filter = createNamespaceFilter([
40
+ "*"
41
+ ]);
42
+ expect(filter.matches("cms.os.list")).toBe(true);
43
+ expect(filter.matches("core.anything")).toBe(true);
44
+ });
45
+ it("should match a prefix glob across dots", ()=>{
46
+ const filter = createNamespaceFilter([
47
+ "cms.*"
48
+ ]);
49
+ expect(filter.matches("cms.os.list")).toBe(true);
50
+ expect(filter.matches("fm.file.get")).toBe(false);
51
+ });
52
+ it("should exclude rather than invert on negation", ()=>{
53
+ const filter = createNamespaceFilter([
54
+ "*",
55
+ "!cms.os.*"
56
+ ]);
57
+ expect(filter.matches("cms.os.list")).toBe(false);
58
+ expect(filter.matches("fm.file.get")).toBe(true);
59
+ });
60
+ it("should require at least one positive match", ()=>{
61
+ const filter = createNamespaceFilter([
62
+ "!cms.os.*"
63
+ ]);
64
+ expect(filter.matches("fm.file.get")).toBe(false);
65
+ });
66
+ });
67
+
68
+ //# sourceMappingURL=matchNamespace.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/debugger/__tests__/matchNamespace.test.js","sources":["../../../../src/features/debugger/__tests__/matchNamespace.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport { createNamespaceFilter } from \"../matchNamespace.js\";\nimport { parseNamespaceHeader } from \"../parseNamespaceHeader.js\";\n\ndescribe(\"parseNamespaceHeader\", () => {\n it(\"should not start a session when the header is absent or empty\", () => {\n expect(parseNamespaceHeader(undefined)).toEqual([]);\n expect(parseNamespaceHeader(\"\")).toEqual([]);\n expect(parseNamespaceHeader(\" \")).toEqual([]);\n });\n\n it(\"should treat the truthy shorthands as capture-all\", () => {\n expect(parseNamespaceHeader(\"1\")).toEqual([\"*\"]);\n expect(parseNamespaceHeader(\"true\")).toEqual([\"*\"]);\n expect(parseNamespaceHeader(\"*\")).toEqual([\"*\"]);\n });\n\n it(\"should trim tokens, since duplicate headers arrive comma-joined with spaces\", () => {\n expect(parseNamespaceHeader(\"cms.os.*, fm.*\")).toEqual([\"cms.os.*\", \"fm.*\"]);\n });\n\n it(\"should accept the array form of a repeated header\", () => {\n expect(parseNamespaceHeader([\"cms.os.*\", \"fm.*\"])).toEqual([\"cms.os.*\", \"fm.*\"]);\n });\n});\n\ndescribe(\"createNamespaceFilter\", () => {\n it(\"should match everything for the wildcard\", () => {\n const filter = createNamespaceFilter([\"*\"]);\n\n expect(filter.matches(\"cms.os.list\")).toBe(true);\n expect(filter.matches(\"core.anything\")).toBe(true);\n });\n\n it(\"should match a prefix glob across dots\", () => {\n const filter = createNamespaceFilter([\"cms.*\"]);\n\n expect(filter.matches(\"cms.os.list\")).toBe(true);\n expect(filter.matches(\"fm.file.get\")).toBe(false);\n });\n\n it(\"should exclude rather than invert on negation\", () => {\n const filter = createNamespaceFilter([\"*\", \"!cms.os.*\"]);\n\n expect(filter.matches(\"cms.os.list\")).toBe(false);\n expect(filter.matches(\"fm.file.get\")).toBe(true);\n });\n\n it(\"should require at least one positive match\", () => {\n const filter = createNamespaceFilter([\"!cms.os.*\"]);\n\n expect(filter.matches(\"fm.file.get\")).toBe(false);\n });\n});\n"],"names":["describe","it","expect","parseNamespaceHeader","undefined","filter","createNamespaceFilter"],"mappings":";;;AAIAA,SAAS,wBAAwB;IAC7BC,GAAG,iEAAiE;QAChEC,OAAOC,qBAAqBC,SAAY,OAAO,CAAC,EAAE;QAClDF,OAAOC,qBAAqB,KAAK,OAAO,CAAC,EAAE;QAC3CD,OAAOC,qBAAqB,QAAQ,OAAO,CAAC,EAAE;IAClD;IAEAF,GAAG,qDAAqD;QACpDC,OAAOC,qBAAqB,MAAM,OAAO,CAAC;YAAC;SAAI;QAC/CD,OAAOC,qBAAqB,SAAS,OAAO,CAAC;YAAC;SAAI;QAClDD,OAAOC,qBAAqB,MAAM,OAAO,CAAC;YAAC;SAAI;IACnD;IAEAF,GAAG,+EAA+E;QAC9EC,OAAOC,qBAAqB,mBAAmB,OA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