@webiny/api-core 0.0.0-unstable.33e4fd9647 → 0.0.0-unstable.3fddf667ea
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ApiCoreFeature.js +5 -2
- package/ApiCoreFeature.js.map +1 -1
- package/exports/api.d.ts +1 -0
- package/exports/api.js +1 -0
- package/features/ai/AiSdkTools.d.ts +1 -1
- package/features/ai/AiSdkTools.js +3 -2
- package/features/ai/AiSdkTools.js.map +1 -1
- package/features/ai/abstractions.d.ts +9 -1
- package/features/ai/abstractions.js.map +1 -1
- package/features/ai/index.d.ts +1 -0
- package/features/ai/index.js +1 -0
- package/features/ai/isReadOnlyTool.d.ts +9 -0
- package/features/ai/isReadOnlyTool.js +4 -0
- package/features/ai/isReadOnlyTool.js.map +1 -0
- package/features/cdnCache/NullCdnCache.d.ts +8 -0
- package/features/cdnCache/NullCdnCache.js +11 -0
- package/features/cdnCache/NullCdnCache.js.map +1 -0
- package/features/cdnCache/abstractions.d.ts +20 -0
- package/features/cdnCache/abstractions.js +5 -0
- package/features/cdnCache/abstractions.js.map +1 -0
- package/features/cdnCache/feature.d.ts +8 -0
- package/features/cdnCache/feature.js +11 -0
- package/features/cdnCache/feature.js.map +1 -0
- package/features/cdnCache/index.d.ts +2 -0
- package/features/cdnCache/index.js +2 -0
- package/features/debugger/DebuggerRouteDecorator.d.ts +3 -3
- package/features/debugger/DebuggerRouteDecorator.js +5 -10
- package/features/debugger/DebuggerRouteDecorator.js.map +1 -1
- package/features/debugger/__tests__/serialize.test.js.map +1 -1
- package/features/encryption/BuildParamsEncryptionConfig.d.ts +13 -0
- package/features/encryption/BuildParamsEncryptionConfig.js +19 -0
- package/features/encryption/BuildParamsEncryptionConfig.js.map +1 -0
- package/features/encryption/EncryptionService.d.ts +2 -2
- package/features/encryption/EncryptionService.js +9 -14
- package/features/encryption/EncryptionService.js.map +1 -1
- package/features/encryption/abstractions.d.ts +15 -0
- package/features/encryption/abstractions.js +2 -1
- package/features/encryption/abstractions.js.map +1 -1
- package/features/encryption/feature.js +2 -0
- package/features/encryption/feature.js.map +1 -1
- package/features/encryption/index.d.ts +2 -0
- package/features/encryption/index.js +2 -1
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +0 -1
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -1
- package/features/hashing/BuildParamsHashingConfig.d.ts +11 -0
- package/features/hashing/BuildParamsHashingConfig.js +18 -0
- package/features/hashing/BuildParamsHashingConfig.js.map +1 -0
- package/features/hashing/ScryptHasher.d.ts +2 -2
- package/features/hashing/ScryptHasher.js +6 -8
- package/features/hashing/ScryptHasher.js.map +1 -1
- package/features/hashing/abstractions.d.ts +15 -0
- package/features/hashing/abstractions.js +2 -1
- package/features/hashing/abstractions.js.map +1 -1
- package/features/hashing/feature.js +2 -0
- package/features/hashing/feature.js.map +1 -1
- package/features/hashing/index.d.ts +1 -0
- package/features/hashing/index.js +1 -1
- package/features/logger/NullLogger.d.ts +10 -0
- package/features/logger/NullLogger.js +12 -0
- package/features/logger/NullLogger.js.map +1 -0
- package/features/logger/index.d.ts +1 -0
- package/features/logger/index.js +1 -0
- package/features/requestStorage/abstractions.d.ts +23 -0
- package/features/requestStorage/abstractions.js +5 -0
- package/features/requestStorage/abstractions.js.map +1 -0
- package/features/requestStorage/index.d.ts +1 -0
- package/features/requestStorage/index.js +1 -0
- package/features/security/IdentityContext/IdentityContext.d.ts +6 -2
- package/features/security/IdentityContext/IdentityContext.js +24 -7
- package/features/security/IdentityContext/IdentityContext.js.map +1 -1
- package/features/security/IdentityContext/abstractions.d.ts +6 -1
- package/features/security/IdentityContext/abstractions.js.map +1 -1
- package/features/security/SecurityFeature.js +2 -0
- package/features/security/SecurityFeature.js.map +1 -1
- package/features/security/ai/CreateRoleTool.d.ts +54 -0
- package/features/security/ai/CreateRoleTool.js +71 -0
- package/features/security/ai/CreateRoleTool.js.map +1 -0
- package/features/security/ai/CreateTeamTool.d.ts +49 -0
- package/features/security/ai/CreateTeamTool.js +56 -0
- package/features/security/ai/CreateTeamTool.js.map +1 -0
- package/features/security/ai/DeleteRoleTool.d.ts +52 -0
- package/features/security/ai/DeleteRoleTool.js +79 -0
- package/features/security/ai/DeleteRoleTool.js.map +1 -0
- package/features/security/ai/DeleteTeamTool.d.ts +47 -0
- package/features/security/ai/DeleteTeamTool.js +56 -0
- package/features/security/ai/DeleteTeamTool.js.map +1 -0
- package/features/security/ai/ListRolesTool.d.ts +40 -0
- package/features/security/ai/ListRolesTool.js +48 -0
- package/features/security/ai/ListRolesTool.js.map +1 -0
- package/features/security/ai/ListTeamsTool.d.ts +42 -0
- package/features/security/ai/ListTeamsTool.js +49 -0
- package/features/security/ai/ListTeamsTool.js.map +1 -0
- package/features/security/ai/UpdateRoleTool.d.ts +46 -0
- package/features/security/ai/UpdateRoleTool.js +53 -0
- package/features/security/ai/UpdateRoleTool.js.map +1 -0
- package/features/security/ai/UpdateTeamTool.d.ts +53 -0
- package/features/security/ai/UpdateTeamTool.js +56 -0
- package/features/security/ai/UpdateTeamTool.js.map +1 -0
- package/features/security/ai/feature.d.ts +10 -0
- package/features/security/ai/feature.js +25 -0
- package/features/security/ai/feature.js.map +1 -0
- package/features/security/ai/index.d.ts +9 -0
- package/features/security/ai/index.js +9 -0
- package/features/security/apiKeys/ApiKeyAuthorizer.js +1 -1
- package/features/security/apiKeys/ApiKeyAuthorizer.js.map +1 -1
- package/features/security/authorization/AuthorizationContext/AuthorizationContext.d.ts +13 -3
- package/features/security/authorization/AuthorizationContext/AuthorizationContext.js +35 -22
- package/features/security/authorization/AuthorizationContext/AuthorizationContext.js.map +1 -1
- package/features/security/authorization/AuthorizationContext/abstractions.d.ts +2 -0
- package/features/security/authorization/AuthorizationContext/abstractions.js.map +1 -1
- package/features/security/authorization/AuthorizationContext/feature.js +6 -1
- package/features/security/authorization/AuthorizationContext/feature.js.map +1 -1
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleCreatedHandler.d.ts +11 -0
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleCreatedHandler.js +24 -0
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleCreatedHandler.js.map +1 -0
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleDeletedHandler.d.ts +11 -0
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleDeletedHandler.js +24 -0
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleDeletedHandler.js.map +1 -0
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleUpdatedHandler.d.ts +11 -0
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleUpdatedHandler.js +24 -0
- package/features/security/roles/NotifyRoleChange/NotifyOnRoleUpdatedHandler.js.map +1 -0
- package/features/security/roles/NotifyRoleChange/feature.d.ts +5 -0
- package/features/security/roles/NotifyRoleChange/feature.js +15 -0
- package/features/security/roles/NotifyRoleChange/feature.js.map +1 -0
- package/features/security/roles/NotifyRoleChange/index.d.ts +2 -0
- package/features/security/roles/NotifyRoleChange/index.js +2 -0
- package/features/security/roles/NotifyRoleChange/recordType.d.ts +5 -0
- package/features/security/roles/NotifyRoleChange/recordType.js +4 -0
- package/features/security/roles/NotifyRoleChange/recordType.js.map +1 -0
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +2 -1
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
- package/features/security/roles/feature.js +2 -0
- package/features/security/roles/feature.js.map +1 -1
- package/features/security/shared/definedOnly.d.ts +1 -0
- package/features/security/shared/definedOnly.js +8 -0
- package/features/security/shared/definedOnly.js.map +1 -0
- package/features/security/shared/index.d.ts +1 -0
- package/features/security/shared/index.js +1 -0
- package/features/security/teams/NotifyTeamChange/NotifyOnTeamChangeHandlers.d.ts +29 -0
- package/features/security/teams/NotifyTeamChange/NotifyOnTeamChangeHandlers.js +62 -0
- package/features/security/teams/NotifyTeamChange/NotifyOnTeamChangeHandlers.js.map +1 -0
- package/features/security/teams/NotifyTeamChange/feature.d.ts +5 -0
- package/features/security/teams/NotifyTeamChange/feature.js +13 -0
- package/features/security/teams/NotifyTeamChange/feature.js.map +1 -0
- package/features/security/teams/NotifyTeamChange/index.d.ts +2 -0
- package/features/security/teams/NotifyTeamChange/index.js +2 -0
- package/features/security/teams/NotifyTeamChange/recordType.d.ts +5 -0
- package/features/security/teams/NotifyTeamChange/recordType.js +4 -0
- package/features/security/teams/NotifyTeamChange/recordType.js.map +1 -0
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +2 -1
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
- package/features/security/teams/feature.js +2 -0
- package/features/security/teams/feature.js.map +1 -1
- package/features/task/TaskService/abstractions.d.ts +7 -0
- package/features/task/TaskService/abstractions.js.map +1 -1
- package/features/tenancy/TenantContext/TenantContext.d.ts +5 -2
- package/features/tenancy/TenantContext/TenantContext.js +31 -28
- package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
- package/features/users/AdminUsersFeature.js +4 -0
- package/features/users/AdminUsersFeature.js.map +1 -1
- package/features/users/CreateUser/CreateUserUseCase.js +1 -1
- package/features/users/CreateUser/CreateUserUseCase.js.map +1 -1
- package/features/users/NotifyUserChange/NotifyOnUserChangeHandlers.d.ts +29 -0
- package/features/users/NotifyUserChange/NotifyOnUserChangeHandlers.js +62 -0
- package/features/users/NotifyUserChange/NotifyOnUserChangeHandlers.js.map +1 -0
- package/features/users/NotifyUserChange/feature.d.ts +5 -0
- package/features/users/NotifyUserChange/feature.js +13 -0
- package/features/users/NotifyUserChange/feature.js.map +1 -0
- package/features/users/NotifyUserChange/index.d.ts +2 -0
- package/features/users/NotifyUserChange/index.js +2 -0
- package/features/users/NotifyUserChange/recordType.d.ts +5 -0
- package/features/users/NotifyUserChange/recordType.js +4 -0
- package/features/users/NotifyUserChange/recordType.js.map +1 -0
- package/features/users/ai/ListUsersTool.d.ts +39 -0
- package/features/users/ai/ListUsersTool.js +46 -0
- package/features/users/ai/ListUsersTool.js.map +1 -0
- package/features/users/ai/UpdateUserAccessTool.d.ts +59 -0
- package/features/users/ai/UpdateUserAccessTool.js +101 -0
- package/features/users/ai/UpdateUserAccessTool.js.map +1 -0
- package/features/users/ai/feature.d.ts +11 -0
- package/features/users/ai/feature.js +13 -0
- package/features/users/ai/feature.js.map +1 -0
- package/features/users/ai/index.d.ts +3 -0
- package/features/users/ai/index.js +3 -0
- package/features/users/shared/loaders.js.map +1 -1
- package/features/users/shared/types.d.ts +9 -7
- package/features/wcp/WcpContext/WcpContext.d.ts +0 -1
- package/features/wcp/WcpContext/WcpContext.js +0 -3
- package/features/wcp/WcpContext/WcpContext.js.map +1 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +0 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +0 -4
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
- package/features/websockets/NotifyRecordChange/NotifyRecordChangeUseCase.d.ts +12 -0
- package/features/websockets/NotifyRecordChange/NotifyRecordChangeUseCase.js +38 -0
- package/features/websockets/NotifyRecordChange/NotifyRecordChangeUseCase.js.map +1 -0
- package/features/websockets/NotifyRecordChange/abstractions.d.ts +39 -0
- package/features/websockets/NotifyRecordChange/abstractions.js +6 -0
- package/features/websockets/NotifyRecordChange/abstractions.js.map +1 -0
- package/features/websockets/NotifyRecordChange/feature.d.ts +5 -0
- package/features/websockets/NotifyRecordChange/feature.js +11 -0
- package/features/websockets/NotifyRecordChange/feature.js.map +1 -0
- package/features/websockets/NotifyRecordChange/index.d.ts +2 -0
- package/features/websockets/NotifyRecordChange/index.js +2 -0
- package/features/websockets/SendToIdentity/NullSendToIdentityUseCase.d.ts +20 -0
- package/features/websockets/SendToIdentity/NullSendToIdentityUseCase.js +24 -0
- package/features/websockets/SendToIdentity/NullSendToIdentityUseCase.js.map +1 -0
- package/features/websockets/SendToIdentity/abstractions.d.ts +19 -0
- package/features/websockets/SendToIdentity/abstractions.js +5 -0
- package/features/websockets/SendToIdentity/abstractions.js.map +1 -0
- package/features/websockets/WebsocketServiceError.d.ts +7 -0
- package/features/websockets/WebsocketServiceError.js +14 -0
- package/features/websockets/WebsocketServiceError.js.map +1 -0
- package/features/websockets/index.d.ts +7 -0
- package/features/websockets/index.js +4 -0
- package/features/websockets/types.d.ts +15 -0
- package/features/websockets/types.js +0 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +19 -21
- package/types/users.d.ts +2 -3
- package/features/logger/LoggerService.d.ts +0 -14
- package/features/logger/LoggerService.js +0 -48
- package/features/logger/LoggerService.js.map +0 -1
- package/features/logger/feature.d.ts +0 -4
- package/features/logger/feature.js +0 -11
- package/features/logger/feature.js.map +0 -1
package/ApiCoreFeature.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { EventPublisherFeature } from "./features/eventPublisher/feature.js";
|
|
3
|
-
import { LoggerFeature } from "./features/logger/feature.js";
|
|
4
3
|
import { SecurityFeature } from "./features/security/SecurityFeature.js";
|
|
5
4
|
import { SystemFeature } from "./features/system/SystemFeature.js";
|
|
6
5
|
import { TenancyFeature } from "./features/tenancy/TenancyFeature.js";
|
|
@@ -10,6 +9,7 @@ import { IdpAuthenticatorFeature } from "./idp/feature.js";
|
|
|
10
9
|
import { KeyValueStoreFeature } from "./features/keyValueStore/feature.js";
|
|
11
10
|
import { BuildParamsFeature } from "./features/buildParams/feature.js";
|
|
12
11
|
import { PublicUrlsFeature } from "./features/publicUrls/feature.js";
|
|
12
|
+
import { CdnCacheFeature } from "./features/cdnCache/feature.js";
|
|
13
13
|
import { DebuggerFeature } from "./features/debugger/feature.js";
|
|
14
14
|
import { EncryptionFeature } from "./features/encryption/feature.js";
|
|
15
15
|
import { HasherFeature } from "./features/hashing/feature.js";
|
|
@@ -21,6 +21,7 @@ import { AiFeature } from "./features/ai/feature.js";
|
|
|
21
21
|
import { WcpFeature } from "./features/wcp/WcpFeature.js";
|
|
22
22
|
import { HttpClientFeature } from "./features/httpClient/feature.js";
|
|
23
23
|
import { NullWebhookDispatcher } from "./features/webhooks/WebhookDispatcher/NullWebhookDispatcher.js";
|
|
24
|
+
import { NotifyRecordChangeFeature, NullSendToIdentityUseCase } from "./features/websockets/index.js";
|
|
24
25
|
import { WebhookProviderFeature } from "./features/webhooks/index.js";
|
|
25
26
|
import { RequestContextFeature } from "./features/requestContext/index.js";
|
|
26
27
|
import { ApiCoreSchemaFactory } from "./graphql/ApiCoreSchemaFactory.js";
|
|
@@ -39,10 +40,10 @@ const ApiCoreFeature = createFeature({
|
|
|
39
40
|
DateFormatterFeature.register(container);
|
|
40
41
|
HttpClientFeature.register(container);
|
|
41
42
|
AiFeature.register(container);
|
|
42
|
-
LoggerFeature.register(container);
|
|
43
43
|
EventPublisherFeature.register(container);
|
|
44
44
|
BuildParamsFeature.register(container);
|
|
45
45
|
PublicUrlsFeature.register(container);
|
|
46
|
+
CdnCacheFeature.register(container);
|
|
46
47
|
DebuggerFeature.register(container);
|
|
47
48
|
EncryptionFeature.register(container);
|
|
48
49
|
HasherFeature.register(container);
|
|
@@ -55,6 +56,8 @@ const ApiCoreFeature = createFeature({
|
|
|
55
56
|
IdpAuthenticatorFeature.register(container);
|
|
56
57
|
RequestContextFeature.register(container);
|
|
57
58
|
container.register(NullWebhookDispatcher).inSingletonScope();
|
|
59
|
+
container.register(NullSendToIdentityUseCase);
|
|
60
|
+
NotifyRecordChangeFeature.register(container);
|
|
58
61
|
WebhookProviderFeature.register(container);
|
|
59
62
|
container.register(ApiCoreSchemaFactory);
|
|
60
63
|
container.register(SecuritySchemaFactory);
|
package/ApiCoreFeature.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiCoreFeature.js","sources":["../src/ApiCoreFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { Container } from \"@webiny/di\";\nimport { EventPublisherFeature } from \"~/features/eventPublisher/feature.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"ApiCoreFeature.js","sources":["../src/ApiCoreFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { Container } from \"@webiny/di\";\nimport { EventPublisherFeature } from \"~/features/eventPublisher/feature.js\";\nimport { SecurityFeature } from \"~/features/security/SecurityFeature.js\";\nimport { SystemFeature } from \"~/features/system/SystemFeature.js\";\nimport { TenancyFeature } from \"./features/tenancy/TenancyFeature.js\";\nimport { AdminUsersFeature } from \"~/features/users/AdminUsersFeature.js\";\nimport type { ApiCoreConfig } from \"~/types/core.js\";\nimport { ApiCoreStorageOperationsFactory } from \"~/features/storageOperations/abstractions.js\";\nimport { IdpAuthenticatorFeature } from \"~/idp/feature.js\";\nimport { KeyValueStoreFeature } from \"~/features/keyValueStore/feature.js\";\nimport { BuildParamsFeature } from \"~/features/buildParams/feature.js\";\nimport { PublicUrlsFeature } from \"~/features/publicUrls/feature.js\";\nimport { CdnCacheFeature } from \"~/features/cdnCache/feature.js\";\nimport { DebuggerFeature } from \"~/features/debugger/feature.js\";\nimport { EncryptionFeature } from \"~/features/encryption/feature.js\";\nimport { HasherFeature } from \"~/features/hashing/feature.js\";\nimport { FeatureFlagsFeature } from \"~/features/featureFlags/feature.js\";\nimport { MaskerFeature } from \"~/features/masker/feature.js\";\nimport { StringFormatterFeature } from \"~/features/stringFormatter/feature.js\";\nimport { DateFormatterFeature } from \"~/features/dateFormatter/feature.js\";\nimport { AiFeature } from \"~/features/ai/feature.js\";\nimport { WcpFeature } from \"~/features/wcp/WcpFeature.js\";\nimport { HttpClientFeature } from \"~/features/httpClient/feature.js\";\nimport { NullWebhookDispatcher } from \"./features/webhooks/WebhookDispatcher/NullWebhookDispatcher.js\";\nimport { NullSendToIdentityUseCase } from \"~/features/websockets/index.js\";\nimport { NotifyRecordChangeFeature } from \"~/features/websockets/index.js\";\nimport { WebhookProviderFeature } from \"~/features/webhooks/index.js\";\nimport { RequestContextFeature } from \"~/features/requestContext/index.js\";\nimport { ApiCoreSchemaFactory } from \"~/graphql/ApiCoreSchemaFactory.js\";\nimport { SecuritySchemaFactory } from \"~/graphql/security/SecuritySchemaFactory.js\";\nimport { UsersSchemaFactory } from \"~/graphql/users/UsersSchemaFactory.js\";\nimport { SystemSchemaFactory } from \"~/graphql/system/SystemSchemaFactory.js\";\nimport { WcpSchemaFactory } from \"~/graphql/wcp/WcpSchemaFactory.js\";\nimport { FeatureFlagsSchemaFactory } from \"~/graphql/featureFlags/FeatureFlagsSchemaFactory.js\";\n\nexport const ApiCoreFeature = createFeature({\n name: \"ApiCore\",\n register(container: Container, config: ApiCoreConfig = {}) {\n // Storage operations are built synchronously, here, from the adapter-provided factory —\n // the same way for every event (no out-of-feature construction, no async initializer).\n const storageOperations = container.resolve(ApiCoreStorageOperationsFactory).create();\n\n // Register features\n WcpFeature.register(container, config.wcpLicense);\n MaskerFeature.register(container);\n StringFormatterFeature.register(container);\n DateFormatterFeature.register(container);\n HttpClientFeature.register(container);\n AiFeature.register(container);\n EventPublisherFeature.register(container);\n BuildParamsFeature.register(container);\n PublicUrlsFeature.register(container);\n CdnCacheFeature.register(container);\n DebuggerFeature.register(container);\n EncryptionFeature.register(container);\n HasherFeature.register(container);\n FeatureFlagsFeature.register(container);\n TenancyFeature.register(container, storageOperations.tenancyStorageOperations);\n SecurityFeature.register(container, storageOperations.securityStorageOperations);\n AdminUsersFeature.register(container, storageOperations.usersStorageOperations);\n KeyValueStoreFeature.register(container, storageOperations.keyValueStorageOperations);\n SystemFeature.register(container);\n IdpAuthenticatorFeature.register(container);\n RequestContextFeature.register(container);\n container.register(NullWebhookDispatcher).inSingletonScope();\n container.register(NullSendToIdentityUseCase);\n NotifyRecordChangeFeature.register(container);\n WebhookProviderFeature.register(container);\n\n // Core API GraphQL schema: a base factory (root types + scalars) plus one\n // CoreGraphQLSchemaFactory per domain.\n container.register(ApiCoreSchemaFactory);\n container.register(SecuritySchemaFactory);\n container.register(UsersSchemaFactory);\n container.register(SystemSchemaFactory);\n container.register(WcpSchemaFactory);\n container.register(FeatureFlagsSchemaFactory);\n }\n});\n"],"names":["ApiCoreFeature","createFeature","container","config","storageOperations","ApiCoreStorageOperationsFactory","WcpFeature","MaskerFeature","StringFormatterFeature","DateFormatterFeature","HttpClientFeature","AiFeature","EventPublisherFeature","BuildParamsFeature","PublicUrlsFeature","CdnCacheFeature","DebuggerFeature","EncryptionFeature","HasherFeature","FeatureFlagsFeature","TenancyFeature","SecurityFeature","AdminUsersFeature","KeyValueStoreFeature","SystemFeature","IdpAuthenticatorFeature","RequestContextFeature","NullWebhookDispatcher","NullSendToIdentityUseCase","NotifyRecordChangeFeature","WebhookProviderFeature","ApiCoreSchemaFactory","SecuritySchemaFactory","UsersSchemaFactory","SystemSchemaFactory","WcpSchemaFactory","FeatureFlagsSchemaFactory"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCO,MAAMA,iBAAiBC,cAAc;IACxC,MAAM;IACN,UAASC,SAAoB,EAAEC,SAAwB,CAAC,CAAC;QAGrD,MAAMC,oBAAoBF,UAAU,OAAO,CAACG,iCAAiC,MAAM;QAGnFC,WAAW,QAAQ,CAACJ,WAAWC,OAAO,UAAU;QAChDI,cAAc,QAAQ,CAACL;QACvBM,uBAAuB,QAAQ,CAACN;QAChCO,qBAAqB,QAAQ,CAACP;QAC9BQ,kBAAkB,QAAQ,CAACR;QAC3BS,UAAU,QAAQ,CAACT;QACnBU,sBAAsB,QAAQ,CAACV;QAC/BW,mBAAmB,QAAQ,CAACX;QAC5BY,kBAAkB,QAAQ,CAACZ;QAC3Ba,gBAAgB,QAAQ,CAACb;QACzBc,gBAAgB,QAAQ,CAACd;QACzBe,kBAAkB,QAAQ,CAACf;QAC3BgB,cAAc,QAAQ,CAAChB;QACvBiB,oBAAoB,QAAQ,CAACjB;QAC7BkB,eAAe,QAAQ,CAAClB,WAAWE,kBAAkB,wBAAwB;QAC7EiB,gBAAgB,QAAQ,CAACnB,WAAWE,kBAAkB,yBAAyB;QAC/EkB,kBAAkB,QAAQ,CAACpB,WAAWE,kBAAkB,sBAAsB;QAC9EmB,qBAAqB,QAAQ,CAACrB,WAAWE,kBAAkB,yBAAyB;QACpFoB,cAAc,QAAQ,CAACtB;QACvBuB,wBAAwB,QAAQ,CAACvB;QACjCwB,sBAAsB,QAAQ,CAACxB;QAC/BA,UAAU,QAAQ,CAACyB,uBAAuB,gBAAgB;QAC1DzB,UAAU,QAAQ,CAAC0B;QACnBC,0BAA0B,QAAQ,CAAC3B;QACnC4B,uBAAuB,QAAQ,CAAC5B;QAIhCA,UAAU,QAAQ,CAAC6B;QACnB7B,UAAU,QAAQ,CAAC8B;QACnB9B,UAAU,QAAQ,CAAC+B;QACnB/B,UAAU,QAAQ,CAACgC;QACnBhC,UAAU,QAAQ,CAACiC;QACnBjC,UAAU,QAAQ,CAACkC;IACvB;AACJ"}
|
package/exports/api.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export { Hasher } from "../features/hashing/index.js";
|
|
|
6
6
|
export { BuildParam, BuildParams } from "../features/buildParams/index.js";
|
|
7
7
|
export { DomainEvent, EventPublisher } from "../features/eventPublisher/index.js";
|
|
8
8
|
export { GlobalKeyValueStore, KeyValueStore } from "../features/keyValueStore/index.js";
|
|
9
|
+
export { WebsocketsSendToIdentityUseCase } from "../features/websockets/index.js";
|
package/exports/api.js
CHANGED
|
@@ -5,3 +5,4 @@ export { Hasher } from "../features/hashing/index.js";
|
|
|
5
5
|
export { BuildParam, BuildParams } from "../features/buildParams/index.js";
|
|
6
6
|
export { DomainEvent, EventPublisher } from "../features/eventPublisher/index.js";
|
|
7
7
|
export { GlobalKeyValueStore, KeyValueStore } from "../features/keyValueStore/index.js";
|
|
8
|
+
export { WebsocketsSendToIdentityUseCase } from "../features/websockets/index.js";
|
|
@@ -4,7 +4,7 @@ declare class AiSdkToolsImpl implements AiSdkToolsAbstraction.Interface {
|
|
|
4
4
|
private definitions;
|
|
5
5
|
private resolver;
|
|
6
6
|
constructor(definitions: AiSdkToolDefinition.Interface[], resolver: AiSdkToolHandlerResolver.Interface);
|
|
7
|
-
getToolSet(): ToolSet;
|
|
7
|
+
getToolSet(options?: AiSdkToolsAbstraction.Options): ToolSet;
|
|
8
8
|
}
|
|
9
9
|
export declare const AiSdkTools: typeof AiSdkToolsImpl & {
|
|
10
10
|
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IAiSdkTools>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { AiSdkToolDefinition, AiSdkToolHandlerResolver, AiSdkTools } from "./abstractions.js";
|
|
2
|
+
import { isReadOnlyTool } from "./isReadOnlyTool.js";
|
|
2
3
|
class AiSdkToolsImpl {
|
|
3
4
|
constructor(definitions, resolver){
|
|
4
5
|
this.definitions = definitions;
|
|
5
6
|
this.resolver = resolver;
|
|
6
7
|
}
|
|
7
|
-
getToolSet() {
|
|
8
|
+
getToolSet(options = {}) {
|
|
8
9
|
const map = {};
|
|
9
|
-
for (const definition of this.definitions)map[definition.name] = {
|
|
10
|
+
for (const definition of this.definitions)if (!options.readOnly || isReadOnlyTool(definition)) map[definition.name] = {
|
|
10
11
|
description: definition.description,
|
|
11
12
|
inputSchema: definition.inputSchema,
|
|
12
13
|
execute: (input)=>this.resolver.resolve(definition.handler).execute(input)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/ai/AiSdkTools.js","sources":["../../../src/features/ai/AiSdkTools.ts"],"sourcesContent":["import {\n AiSdkToolDefinition,\n AiSdkToolHandlerResolver,\n AiSdkTools as AiSdkToolsAbstraction\n} from \"./abstractions.js\";\nimport type { ToolSet } from \"ai\";\n\nclass AiSdkToolsImpl implements AiSdkToolsAbstraction.Interface {\n constructor(\n private definitions: AiSdkToolDefinition.Interface[],\n private resolver: AiSdkToolHandlerResolver.Interface\n ) {}\n\n getToolSet(): ToolSet {\n const map: ToolSet = {};\n for (const definition of this.definitions) {\n map[definition.name] = {\n description: definition.description,\n inputSchema: definition.inputSchema,\n /*\n * Deliberately resolved inside the call, not here. The model is offered every\n * tool and calls a few, which is what keeps the rest of their use cases unbuilt.\n *\n * `resolve` IS `container.resolveImplementation`, one layer down. It lives behind\n * an abstraction so this class does not inject a container. Note it builds the\n * class the definition names; resolving the `AiSdkToolHandler` abstraction would\n * find nothing, since handlers are declared through it but never registered.\n */\n execute: (input: unknown) =>\n this.resolver.resolve(definition.handler).execute(input)\n };\n }\n return map;\n }\n}\n\nexport const AiSdkTools = AiSdkToolsAbstraction.createImplementation({\n implementation: AiSdkToolsImpl,\n dependencies: [[AiSdkToolDefinition, { multiple: true }], AiSdkToolHandlerResolver]\n});\n"],"names":["AiSdkToolsImpl","definitions","resolver","map","definition","input","AiSdkTools","AiSdkToolsAbstraction","AiSdkToolDefinition","AiSdkToolHandlerResolver"],"mappings":"
|
|
1
|
+
{"version":3,"file":"features/ai/AiSdkTools.js","sources":["../../../src/features/ai/AiSdkTools.ts"],"sourcesContent":["import {\n AiSdkToolDefinition,\n AiSdkToolHandlerResolver,\n AiSdkTools as AiSdkToolsAbstraction\n} from \"./abstractions.js\";\nimport { isReadOnlyTool } from \"./isReadOnlyTool.js\";\nimport type { ToolSet } from \"ai\";\n\nclass AiSdkToolsImpl implements AiSdkToolsAbstraction.Interface {\n constructor(\n private definitions: AiSdkToolDefinition.Interface[],\n private resolver: AiSdkToolHandlerResolver.Interface\n ) {}\n\n getToolSet(options: AiSdkToolsAbstraction.Options = {}): ToolSet {\n const map: ToolSet = {};\n for (const definition of this.definitions) {\n if (options.readOnly && !isReadOnlyTool(definition)) {\n continue;\n }\n map[definition.name] = {\n description: definition.description,\n inputSchema: definition.inputSchema,\n /*\n * Deliberately resolved inside the call, not here. The model is offered every\n * tool and calls a few, which is what keeps the rest of their use cases unbuilt.\n *\n * `resolve` IS `container.resolveImplementation`, one layer down. It lives behind\n * an abstraction so this class does not inject a container. Note it builds the\n * class the definition names; resolving the `AiSdkToolHandler` abstraction would\n * find nothing, since handlers are declared through it but never registered.\n */\n execute: (input: unknown) =>\n this.resolver.resolve(definition.handler).execute(input)\n };\n }\n return map;\n }\n}\n\nexport const AiSdkTools = AiSdkToolsAbstraction.createImplementation({\n implementation: AiSdkToolsImpl,\n dependencies: [[AiSdkToolDefinition, { multiple: true }], AiSdkToolHandlerResolver]\n});\n"],"names":["AiSdkToolsImpl","definitions","resolver","options","map","definition","isReadOnlyTool","input","AiSdkTools","AiSdkToolsAbstraction","AiSdkToolDefinition","AiSdkToolHandlerResolver"],"mappings":";;AAQA,MAAMA;IACF,YACYC,WAA4C,EAC5CC,QAA4C,CACtD;aAFUD,WAAW,GAAXA;aACAC,QAAQ,GAARA;IACT;IAEH,WAAWC,UAAyC,CAAC,CAAC,EAAW;QAC7D,MAAMC,MAAe,CAAC;QACtB,KAAK,MAAMC,cAAc,IAAI,CAAC,WAAW,CACrC,IAAIF,CAAAA,QAAQ,QAAQ,IAAKG,eAAeD,aAGxCD,GAAG,CAACC,WAAW,IAAI,CAAC,GAAG;YACnB,aAAaA,WAAW,WAAW;YACnC,aAAaA,WAAW,WAAW;YAUnC,SAAS,CAACE,QACN,IAAI,CAAC,QAAQ,CAAC,OAAO,CAACF,WAAW,OAAO,EAAE,OAAO,CAACE;QAC1D;QAEJ,OAAOH;IACX;AACJ;AAEO,MAAMI,wBAAaC,WAAAA,oBAA0C,CAAC;IACjE,gBAAgBT;IAChB,cAAc;QAAC;YAACU;YAAqB;gBAAE,UAAU;YAAK;SAAE;QAAEC;KAAyB;AACvF"}
|
|
@@ -176,12 +176,20 @@ export declare const AiSdkToolHandlerResolver: import("@webiny/di").Abstraction<
|
|
|
176
176
|
export declare namespace AiSdkToolHandlerResolver {
|
|
177
177
|
type Interface = IAiSdkToolHandlerResolver;
|
|
178
178
|
}
|
|
179
|
+
export interface IAiSdkToolSetOptions {
|
|
180
|
+
/**
|
|
181
|
+
* Leave out every tool not declared read-only (see `isReadOnlyTool`). For a run nobody watches,
|
|
182
|
+
* such as content generation: it has no one to approve a change, so it must not be offered one.
|
|
183
|
+
*/
|
|
184
|
+
readOnly?: boolean;
|
|
185
|
+
}
|
|
179
186
|
export interface IAiSdkTools {
|
|
180
|
-
getToolSet(): ToolSet;
|
|
187
|
+
getToolSet(options?: IAiSdkToolSetOptions): ToolSet;
|
|
181
188
|
}
|
|
182
189
|
/** Collection of AI SDK tools. Returns a ready-to-use ToolSet for generateText/streamText. */
|
|
183
190
|
export declare const AiSdkTools: import("@webiny/di").Abstraction<IAiSdkTools>;
|
|
184
191
|
export declare namespace AiSdkTools {
|
|
185
192
|
type Interface = IAiSdkTools;
|
|
193
|
+
type Options = IAiSdkToolSetOptions;
|
|
186
194
|
}
|
|
187
195
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/ai/abstractions.js","sources":["../../../src/features/ai/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Constructor } from \"@webiny/di\";\nimport type { generateText } from \"ai\";\nimport type { streamText } from \"ai\";\nimport type { LanguageModel } from \"ai\";\nimport type { FlexibleSchema, ToolSet } from \"ai\";\n\n// AiSdk\n\n/**\n * What a model accepts, as published in the model catalog. A capability that isn't listed is unknown,\n * and unknown is treated as unsupported: a parameter the model may reject is not sent.\n */\nexport interface IAiModelSupports {\n tools?: boolean;\n vision?: boolean;\n temperature?: boolean;\n}\n\nexport interface IAiSdkModel {\n id: string; // raw model id, e.g. \"claude-sonnet-4-5\"\n name: string; // human-friendly name, e.g. \"Claude Sonnet 4.5\"\n deprecated?: Date;\n endOfLife?: Date;\n supports?: IAiModelSupports;\n}\n\nexport interface IAiSdk {\n languageModel(modelId: string): LanguageModel;\n}\n\n/** A single AI SDK instance (e.g. OpenAI, Anthropic) that resolves model instances. */\nexport const AiSdk = createAbstraction<IAiSdk>(\"AiSdk\");\n\nexport namespace AiSdk {\n export type Interface = IAiSdk;\n}\n\n// AiSdkFactory\n\nexport interface IAiSdkFactory {\n readonly id: string; // machine id, e.g. \"anthropic\"\n readonly name: string; // human-friendly name, e.g. \"Anthropic\"\n readonly models: readonly IAiSdkModel[]; // static model list, no API call needed\n execute(apiKey?: string): Promise<IAiSdk>;\n}\n\n/** Factory that asynchronously initialises an AI SDK. Register one per provider namespace. */\nexport const AiSdkFactory = createAbstraction<IAiSdkFactory>(\"AiSdkFactory\");\n\nexport namespace AiSdkFactory {\n export type Interface = IAiSdkFactory;\n}\n\n// AiConnection\n\nexport interface IAiConnectionInline {\n readonly sdkName: string;\n readonly apiKey?: string;\n}\n\nexport interface IAiConnection extends IAiConnectionInline {\n readonly id: string;\n}\n\n// AiConnectionFactory\n\nexport interface IAiConnectionFactory {\n execute(): Promise<IAiConnection>;\n}\n\n/** Factory that asynchronously produces an AiConnection. */\nexport const AiConnectionFactory = createAbstraction<IAiConnectionFactory>(\"AiConnectionFactory\");\n\nexport namespace AiConnectionFactory {\n export type Interface = IAiConnectionFactory;\n}\n\n// Ai\n\ntype SDKGenerateTextParams = Parameters<typeof generateText>[0];\ntype SDKStreamTextParams = Parameters<typeof streamText>[0];\n\nexport type AiGenerateTextParams = Omit<SDKGenerateTextParams, \"model\"> & {\n model: string;\n connection?: string | IAiConnectionInline;\n};\nexport type AiStreamTextParams = Omit<SDKStreamTextParams, \"model\"> & {\n model: string;\n connection?: string | IAiConnectionInline;\n};\n\nexport interface AiModel {\n providerId: string; // e.g. \"anthropic\"\n providerName: string; // e.g. \"Anthropic\"\n modelId: string; // e.g. \"claude-sonnet-4-5\"\n modelName: string; // e.g. \"Claude Sonnet 4.5\"\n deprecated: Date | undefined;\n endOfLife: Date | undefined;\n supports: IAiModelSupports | undefined;\n}\n\nexport interface IAi {\n generateText(params: AiGenerateTextParams): ReturnType<typeof generateText>;\n streamText(params: AiStreamTextParams): Promise<ReturnType<typeof streamText>>;\n listModels(): Promise<AiModel[]>;\n listModelsByConnections(): Promise<AiModel[]>;\n listModelsByConnection(connection: string | IAiConnectionInline): Promise<AiModel[]>;\n}\n\n/** Interact with AI language models using registered providers. */\nexport const Ai = createAbstraction<IAi>(\"Ai\");\n\nexport namespace Ai {\n export type Interface = IAi;\n export type GenerateTextParams = AiGenerateTextParams;\n export type StreamTextParams = AiStreamTextParams;\n}\n\n// AiModelRegistry\n\nexport interface IAiModelRegistry {\n listModels(): Promise<AiModel[]>;\n}\n\n/** Single source of truth for available AI models. Decoratable to restrict the model list. */\nexport const AiModelRegistry = createAbstraction<IAiModelRegistry>(\"AiModelRegistry\");\n\nexport namespace AiModelRegistry {\n export type Interface = IAiModelRegistry;\n}\n\n// AiModelCatalog\n\nexport interface AiCatalogProvider {\n id: string; // Matches `AiSdkFactory.id`, e.g. \"anthropic\".\n name: string; // Human-friendly name, e.g. \"Anthropic\".\n models: IAiSdkModel[];\n}\n\nexport interface IAiModelCatalog {\n /** Returns `undefined` when the catalog can't be loaded. */\n listProviders(): Promise<AiCatalogProvider[] | undefined>;\n}\n\n/** The published list of providers and models Webiny supports. SDK factories still gate what is offered. */\nexport const AiModelCatalog = createAbstraction<IAiModelCatalog>(\"AiModelCatalog\");\n\nexport namespace AiModelCatalog {\n export type Interface = IAiModelCatalog;\n}\n\n// AiSdkToolDefinition\n\n/**\n * Behavioural hints about a tool. Purely advisory — they never replace a permission check.\n * Names mirror the MCP tool annotations so they can be forwarded verbatim to MCP clients,\n * which use them to decide what to auto-approve and what to confirm with the user.\n */\nexport interface IAiSdkToolAnnotations {\n /** Tool does not modify state. */\n readOnlyHint?: boolean;\n /** Tool may perform destructive updates (only meaningful when not read-only). */\n destructiveHint?: boolean;\n /** Repeated calls with the same arguments have no additional effect. */\n idempotentHint?: boolean;\n /** Tool interacts with entities outside its own closed world. */\n openWorldHint?: boolean;\n}\n\n/**\n * What a tool DOES. This is the half that injects use cases, so it is built only for a tool the\n * model actually calls, and only at the moment it calls it.\n */\nexport interface IAiSdkToolHandler<TInput = any> {\n execute(input: TInput): Promise<unknown>;\n}\n\n/**\n * What a tool IS: everything the model is told about it, plus the class that runs it.\n *\n * Carries no behaviour and no dependencies, which is what makes the registry cheap to read.\n * `AiSdkTools` builds every definition to assemble the tool set, and builds a handler only for a\n * tool the model actually calls.\n */\nexport interface IAiSdkToolDefinition<TInput = any> {\n readonly name: string;\n readonly description: string;\n readonly inputSchema: FlexibleSchema<TInput>;\n /** Human-friendly display name. Falls back to `name` when omitted. */\n readonly title?: string;\n readonly annotations?: IAiSdkToolAnnotations;\n readonly handler: Constructor<IAiSdkToolHandler<TInput>>;\n}\n\nexport const AiSdkToolDefinition = createAbstraction<IAiSdkToolDefinition>(\"AiSdkToolDefinition\");\n\n/**\n * The behaviour half of a tool, built on demand through {@link AiSdkToolHandlerResolver}.\n *\n * Implementations are NOT registered against this abstraction. The definition points at the class\n * directly, exactly as `HttpRouteDefinition` points at its `HttpRouteHandler`. Declaring them\n * through it is what attaches their dependency metadata.\n */\nexport const AiSdkToolHandler = createAbstraction<IAiSdkToolHandler>(\"AiSdkToolHandler\");\n\nexport namespace AiSdkToolDefinition {\n export type Interface<TInput = any> = IAiSdkToolDefinition<TInput>;\n export type Annotations = IAiSdkToolAnnotations;\n}\n\nexport namespace AiSdkToolHandler {\n export type Interface<TInput = any> = IAiSdkToolHandler<TInput>;\n}\n\n// AiSdkToolHandlerResolver\n\nexport interface IAiSdkToolHandlerResolver {\n resolve<TInput>(handler: Constructor<IAiSdkToolHandler<TInput>>): IAiSdkToolHandler<TInput>;\n}\n\n/**\n * Builds the behaviour half of a tool on demand.\n *\n * Something has to turn `tool.handler` (a class) into an instance, and that needs the container.\n * Rather than injecting the container into the tool registry, it lives behind this one narrow\n * abstraction, so everything else depends on `resolve(handler)` and stays testable with a stub.\n */\nexport const AiSdkToolHandlerResolver = createAbstraction<IAiSdkToolHandlerResolver>(\n \"AiSdkToolHandlerResolver\"\n);\n\nexport namespace AiSdkToolHandlerResolver {\n export type Interface = IAiSdkToolHandlerResolver;\n}\n\n// AiSdkTools\n\nexport interface IAiSdkTools {\n getToolSet(): ToolSet;\n}\n\n/** Collection of AI SDK tools. Returns a ready-to-use ToolSet for generateText/streamText. */\nexport const AiSdkTools = createAbstraction<IAiSdkTools>(\"AiSdkTools\");\n\nexport namespace AiSdkTools {\n export type Interface = IAiSdkTools;\n}\n"],"names":["AiSdk","createAbstraction","AiSdkFactory","AiConnectionFactory","Ai","AiModelRegistry","AiModelCatalog","AiSdkToolDefinition","AiSdkToolHandler","AiSdkToolHandlerResolver","AiSdkTools"],"mappings":";AAgCO,MAAMA,QAAQC,kBAA0B;AAgBxC,MAAMC,eAAeD,kBAAiC;AAwBtD,MAAME,sBAAsBF,kBAAwC;AAuCpE,MAAMG,KAAKH,kBAAuB;AAelC,MAAMI,kBAAkBJ,kBAAoC;AAoB5D,MAAMK,iBAAiBL,kBAAmC;AAiD1D,MAAMM,sBAAsBN,kBAAwC;AASpE,MAAMO,mBAAmBP,kBAAqC;AAwB9D,MAAMQ,2BAA2BR,kBACpC;
|
|
1
|
+
{"version":3,"file":"features/ai/abstractions.js","sources":["../../../src/features/ai/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Constructor } from \"@webiny/di\";\nimport type { generateText } from \"ai\";\nimport type { streamText } from \"ai\";\nimport type { LanguageModel } from \"ai\";\nimport type { FlexibleSchema, ToolSet } from \"ai\";\n\n// AiSdk\n\n/**\n * What a model accepts, as published in the model catalog. A capability that isn't listed is unknown,\n * and unknown is treated as unsupported: a parameter the model may reject is not sent.\n */\nexport interface IAiModelSupports {\n tools?: boolean;\n vision?: boolean;\n temperature?: boolean;\n}\n\nexport interface IAiSdkModel {\n id: string; // raw model id, e.g. \"claude-sonnet-4-5\"\n name: string; // human-friendly name, e.g. \"Claude Sonnet 4.5\"\n deprecated?: Date;\n endOfLife?: Date;\n supports?: IAiModelSupports;\n}\n\nexport interface IAiSdk {\n languageModel(modelId: string): LanguageModel;\n}\n\n/** A single AI SDK instance (e.g. OpenAI, Anthropic) that resolves model instances. */\nexport const AiSdk = createAbstraction<IAiSdk>(\"AiSdk\");\n\nexport namespace AiSdk {\n export type Interface = IAiSdk;\n}\n\n// AiSdkFactory\n\nexport interface IAiSdkFactory {\n readonly id: string; // machine id, e.g. \"anthropic\"\n readonly name: string; // human-friendly name, e.g. \"Anthropic\"\n readonly models: readonly IAiSdkModel[]; // static model list, no API call needed\n execute(apiKey?: string): Promise<IAiSdk>;\n}\n\n/** Factory that asynchronously initialises an AI SDK. Register one per provider namespace. */\nexport const AiSdkFactory = createAbstraction<IAiSdkFactory>(\"AiSdkFactory\");\n\nexport namespace AiSdkFactory {\n export type Interface = IAiSdkFactory;\n}\n\n// AiConnection\n\nexport interface IAiConnectionInline {\n readonly sdkName: string;\n readonly apiKey?: string;\n}\n\nexport interface IAiConnection extends IAiConnectionInline {\n readonly id: string;\n}\n\n// AiConnectionFactory\n\nexport interface IAiConnectionFactory {\n execute(): Promise<IAiConnection>;\n}\n\n/** Factory that asynchronously produces an AiConnection. */\nexport const AiConnectionFactory = createAbstraction<IAiConnectionFactory>(\"AiConnectionFactory\");\n\nexport namespace AiConnectionFactory {\n export type Interface = IAiConnectionFactory;\n}\n\n// Ai\n\ntype SDKGenerateTextParams = Parameters<typeof generateText>[0];\ntype SDKStreamTextParams = Parameters<typeof streamText>[0];\n\nexport type AiGenerateTextParams = Omit<SDKGenerateTextParams, \"model\"> & {\n model: string;\n connection?: string | IAiConnectionInline;\n};\nexport type AiStreamTextParams = Omit<SDKStreamTextParams, \"model\"> & {\n model: string;\n connection?: string | IAiConnectionInline;\n};\n\nexport interface AiModel {\n providerId: string; // e.g. \"anthropic\"\n providerName: string; // e.g. \"Anthropic\"\n modelId: string; // e.g. \"claude-sonnet-4-5\"\n modelName: string; // e.g. \"Claude Sonnet 4.5\"\n deprecated: Date | undefined;\n endOfLife: Date | undefined;\n supports: IAiModelSupports | undefined;\n}\n\nexport interface IAi {\n generateText(params: AiGenerateTextParams): ReturnType<typeof generateText>;\n streamText(params: AiStreamTextParams): Promise<ReturnType<typeof streamText>>;\n listModels(): Promise<AiModel[]>;\n listModelsByConnections(): Promise<AiModel[]>;\n listModelsByConnection(connection: string | IAiConnectionInline): Promise<AiModel[]>;\n}\n\n/** Interact with AI language models using registered providers. */\nexport const Ai = createAbstraction<IAi>(\"Ai\");\n\nexport namespace Ai {\n export type Interface = IAi;\n export type GenerateTextParams = AiGenerateTextParams;\n export type StreamTextParams = AiStreamTextParams;\n}\n\n// AiModelRegistry\n\nexport interface IAiModelRegistry {\n listModels(): Promise<AiModel[]>;\n}\n\n/** Single source of truth for available AI models. Decoratable to restrict the model list. */\nexport const AiModelRegistry = createAbstraction<IAiModelRegistry>(\"AiModelRegistry\");\n\nexport namespace AiModelRegistry {\n export type Interface = IAiModelRegistry;\n}\n\n// AiModelCatalog\n\nexport interface AiCatalogProvider {\n id: string; // Matches `AiSdkFactory.id`, e.g. \"anthropic\".\n name: string; // Human-friendly name, e.g. \"Anthropic\".\n models: IAiSdkModel[];\n}\n\nexport interface IAiModelCatalog {\n /** Returns `undefined` when the catalog can't be loaded. */\n listProviders(): Promise<AiCatalogProvider[] | undefined>;\n}\n\n/** The published list of providers and models Webiny supports. SDK factories still gate what is offered. */\nexport const AiModelCatalog = createAbstraction<IAiModelCatalog>(\"AiModelCatalog\");\n\nexport namespace AiModelCatalog {\n export type Interface = IAiModelCatalog;\n}\n\n// AiSdkToolDefinition\n\n/**\n * Behavioural hints about a tool. Purely advisory — they never replace a permission check.\n * Names mirror the MCP tool annotations so they can be forwarded verbatim to MCP clients,\n * which use them to decide what to auto-approve and what to confirm with the user.\n */\nexport interface IAiSdkToolAnnotations {\n /** Tool does not modify state. */\n readOnlyHint?: boolean;\n /** Tool may perform destructive updates (only meaningful when not read-only). */\n destructiveHint?: boolean;\n /** Repeated calls with the same arguments have no additional effect. */\n idempotentHint?: boolean;\n /** Tool interacts with entities outside its own closed world. */\n openWorldHint?: boolean;\n}\n\n/**\n * What a tool DOES. This is the half that injects use cases, so it is built only for a tool the\n * model actually calls, and only at the moment it calls it.\n */\nexport interface IAiSdkToolHandler<TInput = any> {\n execute(input: TInput): Promise<unknown>;\n}\n\n/**\n * What a tool IS: everything the model is told about it, plus the class that runs it.\n *\n * Carries no behaviour and no dependencies, which is what makes the registry cheap to read.\n * `AiSdkTools` builds every definition to assemble the tool set, and builds a handler only for a\n * tool the model actually calls.\n */\nexport interface IAiSdkToolDefinition<TInput = any> {\n readonly name: string;\n readonly description: string;\n readonly inputSchema: FlexibleSchema<TInput>;\n /** Human-friendly display name. Falls back to `name` when omitted. */\n readonly title?: string;\n readonly annotations?: IAiSdkToolAnnotations;\n readonly handler: Constructor<IAiSdkToolHandler<TInput>>;\n}\n\nexport const AiSdkToolDefinition = createAbstraction<IAiSdkToolDefinition>(\"AiSdkToolDefinition\");\n\n/**\n * The behaviour half of a tool, built on demand through {@link AiSdkToolHandlerResolver}.\n *\n * Implementations are NOT registered against this abstraction. The definition points at the class\n * directly, exactly as `HttpRouteDefinition` points at its `HttpRouteHandler`. Declaring them\n * through it is what attaches their dependency metadata.\n */\nexport const AiSdkToolHandler = createAbstraction<IAiSdkToolHandler>(\"AiSdkToolHandler\");\n\nexport namespace AiSdkToolDefinition {\n export type Interface<TInput = any> = IAiSdkToolDefinition<TInput>;\n export type Annotations = IAiSdkToolAnnotations;\n}\n\nexport namespace AiSdkToolHandler {\n export type Interface<TInput = any> = IAiSdkToolHandler<TInput>;\n}\n\n// AiSdkToolHandlerResolver\n\nexport interface IAiSdkToolHandlerResolver {\n resolve<TInput>(handler: Constructor<IAiSdkToolHandler<TInput>>): IAiSdkToolHandler<TInput>;\n}\n\n/**\n * Builds the behaviour half of a tool on demand.\n *\n * Something has to turn `tool.handler` (a class) into an instance, and that needs the container.\n * Rather than injecting the container into the tool registry, it lives behind this one narrow\n * abstraction, so everything else depends on `resolve(handler)` and stays testable with a stub.\n */\nexport const AiSdkToolHandlerResolver = createAbstraction<IAiSdkToolHandlerResolver>(\n \"AiSdkToolHandlerResolver\"\n);\n\nexport namespace AiSdkToolHandlerResolver {\n export type Interface = IAiSdkToolHandlerResolver;\n}\n\n// AiSdkTools\n\nexport interface IAiSdkToolSetOptions {\n /**\n * Leave out every tool not declared read-only (see `isReadOnlyTool`). For a run nobody watches,\n * such as content generation: it has no one to approve a change, so it must not be offered one.\n */\n readOnly?: boolean;\n}\n\nexport interface IAiSdkTools {\n getToolSet(options?: IAiSdkToolSetOptions): ToolSet;\n}\n\n/** Collection of AI SDK tools. Returns a ready-to-use ToolSet for generateText/streamText. */\nexport const AiSdkTools = createAbstraction<IAiSdkTools>(\"AiSdkTools\");\n\nexport namespace AiSdkTools {\n export type Interface = IAiSdkTools;\n export type Options = IAiSdkToolSetOptions;\n}\n"],"names":["AiSdk","createAbstraction","AiSdkFactory","AiConnectionFactory","Ai","AiModelRegistry","AiModelCatalog","AiSdkToolDefinition","AiSdkToolHandler","AiSdkToolHandlerResolver","AiSdkTools"],"mappings":";AAgCO,MAAMA,QAAQC,kBAA0B;AAgBxC,MAAMC,eAAeD,kBAAiC;AAwBtD,MAAME,sBAAsBF,kBAAwC;AAuCpE,MAAMG,KAAKH,kBAAuB;AAelC,MAAMI,kBAAkBJ,kBAAoC;AAoB5D,MAAMK,iBAAiBL,kBAAmC;AAiD1D,MAAMM,sBAAsBN,kBAAwC;AASpE,MAAMO,mBAAmBP,kBAAqC;AAwB9D,MAAMQ,2BAA2BR,kBACpC;AAsBG,MAAMS,aAAaT,kBAA+B"}
|
package/features/ai/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { AiSdk, AiSdkFactory, AiConnectionFactory, Ai, AiModelRegistry, AiModelCatalog, AiSdkToolDefinition, AiSdkToolHandler, AiSdkToolHandlerResolver, AiSdkTools } from "./abstractions.js";
|
|
2
2
|
export type { IAiConnection, IAiConnectionInline, AiModel, IAiSdkModel } from "./abstractions.js";
|
|
3
|
+
export { isReadOnlyTool } from "./isReadOnlyTool.js";
|
|
3
4
|
export { AiOutputTool, AiOutputToolRegistry, AiToolPipelineRunner } from "./toolPipeline/index.js";
|
|
4
5
|
export { TextExtractor, DefaultTextExtractor } from "./TextExtractor/index.js";
|
|
5
6
|
export { AiBeforeGenerateTextEvent, AiBeforeGenerateTextEventHandler, AiAfterGenerateTextEvent, AiAfterGenerateTextEventHandler, AiGenerateTextErrorEvent, AiGenerateTextErrorEventHandler, AiBeforeStreamTextEvent, AiBeforeStreamTextEventHandler } from "./events.js";
|
package/features/ai/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Ai, AiConnectionFactory, AiModelCatalog, AiModelRegistry, AiSdk, AiSdkFactory, AiSdkToolDefinition, AiSdkToolHandler, AiSdkToolHandlerResolver, AiSdkTools } from "./abstractions.js";
|
|
2
|
+
export { isReadOnlyTool } from "./isReadOnlyTool.js";
|
|
2
3
|
export { AiOutputTool, AiOutputToolRegistry, AiToolPipelineRunner } from "./toolPipeline/index.js";
|
|
3
4
|
export { DefaultTextExtractor, TextExtractor } from "./TextExtractor/index.js";
|
|
4
5
|
export { AiAfterGenerateTextEvent, AiAfterGenerateTextEventHandler, AiBeforeGenerateTextEvent, AiBeforeGenerateTextEventHandler, AiBeforeStreamTextEvent, AiBeforeStreamTextEventHandler, AiGenerateTextErrorEvent, AiGenerateTextErrorEventHandler } from "./events.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AiSdkToolDefinition } from "./abstractions.js";
|
|
2
|
+
/**
|
|
3
|
+
* A tool runs unattended only if it says, in its own declaration, that it does not change anything.
|
|
4
|
+
*
|
|
5
|
+
* The default is deliberately the safe one: a tool with no annotations counts as one that writes.
|
|
6
|
+
* Tools are registered by extensions as well as by Webiny, so an author who forgets to annotate gets
|
|
7
|
+
* a confirm prompt in the assistant, and no place in unattended runs, rather than silent write access.
|
|
8
|
+
*/
|
|
9
|
+
export declare const isReadOnlyTool: (tool: AiSdkToolDefinition.Interface) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ai/isReadOnlyTool.js","sources":["../../../src/features/ai/isReadOnlyTool.ts"],"sourcesContent":["import type { AiSdkToolDefinition } from \"./abstractions.js\";\n\n/**\n * A tool runs unattended only if it says, in its own declaration, that it does not change anything.\n *\n * The default is deliberately the safe one: a tool with no annotations counts as one that writes.\n * Tools are registered by extensions as well as by Webiny, so an author who forgets to annotate gets\n * a confirm prompt in the assistant, and no place in unattended runs, rather than silent write access.\n */\nexport const isReadOnlyTool = (tool: AiSdkToolDefinition.Interface): boolean =>\n tool.annotations?.readOnlyHint === true;\n"],"names":["isReadOnlyTool","tool"],"mappings":"AASO,MAAMA,iBAAiB,CAACC,OAC3BA,KAAK,WAAW,EAAE,iBAAiB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CdnCache } from "./abstractions.js";
|
|
2
|
+
declare class NullCdnCacheImpl implements CdnCache.Interface {
|
|
3
|
+
invalidate(): Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
export declare const NullCdnCache: typeof NullCdnCacheImpl & {
|
|
6
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ICdnCache>;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CdnCache } from "./abstractions.js";
|
|
2
|
+
class NullCdnCacheImpl {
|
|
3
|
+
async invalidate() {}
|
|
4
|
+
}
|
|
5
|
+
const NullCdnCache = CdnCache.createImplementation({
|
|
6
|
+
implementation: NullCdnCacheImpl,
|
|
7
|
+
dependencies: []
|
|
8
|
+
});
|
|
9
|
+
export { NullCdnCache };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=NullCdnCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/cdnCache/NullCdnCache.js","sources":["../../../src/features/cdnCache/NullCdnCache.ts"],"sourcesContent":["import { CdnCache } from \"./abstractions.js\";\n\n// Default for hosting types (and tests) with no CDN in front of the API.\nclass NullCdnCacheImpl implements CdnCache.Interface {\n async invalidate(): Promise<void> {\n // Nothing to invalidate.\n }\n}\n\nexport const NullCdnCache = CdnCache.createImplementation({\n implementation: NullCdnCacheImpl,\n dependencies: []\n});\n"],"names":["NullCdnCacheImpl","NullCdnCache","CdnCache"],"mappings":";AAGA,MAAMA;IACF,MAAM,aAA4B,CAElC;AACJ;AAEO,MAAMC,eAAeC,SAAS,oBAAoB,CAAC;IACtD,gBAAgBF;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ICdnCacheInvalidateParams {
|
|
2
|
+
caller: string;
|
|
3
|
+
paths: string[];
|
|
4
|
+
}
|
|
5
|
+
export interface ICdnCache {
|
|
6
|
+
invalidate(params: ICdnCacheInvalidateParams): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The CDN cache in front of the API, if the deployment has one. AWS caches API responses in
|
|
10
|
+
* CloudFront, and `@webiny/api-event-handler-aws` supplies the implementation that invalidates them.
|
|
11
|
+
* Standalone has no CDN, so it keeps the default, which has nothing to invalidate.
|
|
12
|
+
*
|
|
13
|
+
* Invalidating is a side effect of a write that has already succeeded, so `invalidate` never
|
|
14
|
+
* rejects: an implementation logs its own failures. Callers await it and carry on.
|
|
15
|
+
*/
|
|
16
|
+
export declare const CdnCache: import("@webiny/di").Abstraction<ICdnCache>;
|
|
17
|
+
export declare namespace CdnCache {
|
|
18
|
+
type Interface = ICdnCache;
|
|
19
|
+
type InvalidateParams = ICdnCacheInvalidateParams;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/cdnCache/abstractions.js","sources":["../../../src/features/cdnCache/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface ICdnCacheInvalidateParams {\n // Who asked, for the logs, e.g. `wb.redirects`.\n caller: string;\n // API paths to drop from the cache, e.g. `/wb/redirects`.\n paths: string[];\n}\n\nexport interface ICdnCache {\n invalidate(params: ICdnCacheInvalidateParams): Promise<void>;\n}\n\n/**\n * The CDN cache in front of the API, if the deployment has one. AWS caches API responses in\n * CloudFront, and `@webiny/api-event-handler-aws` supplies the implementation that invalidates them.\n * Standalone has no CDN, so it keeps the default, which has nothing to invalidate.\n *\n * Invalidating is a side effect of a write that has already succeeded, so `invalidate` never\n * rejects: an implementation logs its own failures. Callers await it and carry on.\n */\nexport const CdnCache = createAbstraction<ICdnCache>(\"Core/CdnCache\");\n\nexport namespace CdnCache {\n export type Interface = ICdnCache;\n export type InvalidateParams = ICdnCacheInvalidateParams;\n}\n"],"names":["CdnCache","createAbstraction"],"mappings":";AAqBO,MAAMA,WAAWC,kBAA6B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers the default, which has nothing to invalidate. A hosting type with a CDN registers its
|
|
3
|
+
* own implementation later in the request stack, which replaces this one.
|
|
4
|
+
*/
|
|
5
|
+
export declare const CdnCacheFeature: {
|
|
6
|
+
name: string;
|
|
7
|
+
register(container: import("@webiny/di").Container): void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { NullCdnCache } from "./NullCdnCache.js";
|
|
3
|
+
const CdnCacheFeature = createFeature({
|
|
4
|
+
name: "CdnCacheFeature",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(NullCdnCache);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { CdnCacheFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/cdnCache/feature.js","sources":["../../../src/features/cdnCache/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { NullCdnCache } from \"./NullCdnCache.js\";\n\n/**\n * Registers the default, which has nothing to invalidate. A hosting type with a CDN registers its\n * own implementation later in the request stack, which replaces this one.\n */\nexport const CdnCacheFeature = createFeature({\n name: \"CdnCacheFeature\",\n register(container) {\n container.register(NullCdnCache);\n }\n});\n"],"names":["CdnCacheFeature","createFeature","container","NullCdnCache"],"mappings":";;AAOO,MAAMA,kBAAkBC,cAAc;IACzC,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpRouteHandler } from "@webiny/event-handler-core";
|
|
2
|
-
import {
|
|
2
|
+
import { HandlerExecution } from "@webiny/event-handler-core";
|
|
3
3
|
import type { IHttpResponse } from "@webiny/event-handler-core";
|
|
4
4
|
import type { IHttpResponseBuilder } from "@webiny/event-handler-core";
|
|
5
5
|
import { Debugger } from "./abstractions.js";
|
|
@@ -19,9 +19,9 @@ declare class DebuggerRouteDecoratorImpl implements HttpRouteHandler.Interface {
|
|
|
19
19
|
private readonly debuggerService;
|
|
20
20
|
private readonly identityContext;
|
|
21
21
|
private readonly logger;
|
|
22
|
-
private readonly
|
|
22
|
+
private readonly handlerExecution;
|
|
23
23
|
private readonly decoratee;
|
|
24
|
-
constructor(debuggerService: Debugger.Interface, identityContext: IdentityContext.Interface, logger: Logger.Interface,
|
|
24
|
+
constructor(debuggerService: Debugger.Interface, identityContext: IdentityContext.Interface, logger: Logger.Interface, handlerExecution: HandlerExecution.Interface, decoratee: HttpRouteHandler.Interface);
|
|
25
25
|
handle(request: HttpRouteHandler.Request, response: HttpRouteHandler.Response): Promise<RouteResult>;
|
|
26
26
|
/**
|
|
27
27
|
* A session starts on every request, and the permission check at flush decides whether anything
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HandlerExecution, HttpRouteHandler } from "@webiny/event-handler-core";
|
|
2
2
|
import { Debugger } from "./abstractions.js";
|
|
3
3
|
import { IdentityContext } from "../security/IdentityContext/index.js";
|
|
4
4
|
import { Logger } from "../logger/index.js";
|
|
@@ -35,11 +35,11 @@ const describeError = (error)=>{
|
|
|
35
35
|
return "Unknown error.";
|
|
36
36
|
};
|
|
37
37
|
class DebuggerRouteDecoratorImpl {
|
|
38
|
-
constructor(debuggerService, identityContext, logger,
|
|
38
|
+
constructor(debuggerService, identityContext, logger, handlerExecution, decoratee){
|
|
39
39
|
this.debuggerService = debuggerService;
|
|
40
40
|
this.identityContext = identityContext;
|
|
41
41
|
this.logger = logger;
|
|
42
|
-
this.
|
|
42
|
+
this.handlerExecution = handlerExecution;
|
|
43
43
|
this.decoratee = decoratee;
|
|
44
44
|
}
|
|
45
45
|
async handle(request, response) {
|
|
@@ -75,7 +75,7 @@ class DebuggerRouteDecoratorImpl {
|
|
|
75
75
|
const target = {
|
|
76
76
|
type: GRAPHQL_TARGET,
|
|
77
77
|
result,
|
|
78
|
-
requestId: this.
|
|
78
|
+
requestId: this.handlerExecution.getId(),
|
|
79
79
|
operations: readOperationNames(request.body),
|
|
80
80
|
url: request.path
|
|
81
81
|
};
|
|
@@ -94,12 +94,7 @@ const DebuggerRouteDecorator = HttpRouteHandler.createDecorator({
|
|
|
94
94
|
Debugger,
|
|
95
95
|
IdentityContext,
|
|
96
96
|
Logger,
|
|
97
|
-
|
|
98
|
-
RequestId,
|
|
99
|
-
{
|
|
100
|
-
optional: true
|
|
101
|
-
}
|
|
102
|
-
]
|
|
97
|
+
HandlerExecution
|
|
103
98
|
]
|
|
104
99
|
});
|
|
105
100
|
export { DEBUG_HEADER, DebuggerRouteDecorator };
|
|
@@ -1 +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,SAA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AACO;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"}
|
|
1
|
+
{"version":3,"file":"features/debugger/DebuggerRouteDecorator.js","sources":["../../../src/features/debugger/DebuggerRouteDecorator.ts"],"sourcesContent":["import { HttpRouteHandler } from \"@webiny/event-handler-core\";\nimport { HandlerExecution } 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 handlerExecution: HandlerExecution.Interface,\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.handlerExecution.getId(),\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, HandlerExecution]\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","handlerExecution","decoratee","request","ex","requested","parseNamespaceHeader","namespaces","isAuthorized","canCaptureDebugData","target","GRAPHQL_TARGET","DebuggerRouteDecorator","HttpRouteHandler","Debugger","IdentityContext","Logger","HandlerExecution"],"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,MAAM,OAAO,CAACO,QAAQA,KAAK,EAAE,CAAC,MAAMA;IACtD,IAAIN,gBAAgBO,YAChB,OAAOA;AAGf;AAEA,MAAMC,qBAAqB,CAACF;IACxB,MAAMG,aAA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Ae,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,gBAAgB,CAAC,KAAK;gBACtC,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;QAAQC;KAAiB;AACvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/debugger/__tests__/serialize.test.js","sources":["../../../../src/features/debugger/__tests__/serialize.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport { serialize } from \"../serialize.js\";\nimport { DEFAULT_LIMITS, type IDebuggerLimits } from \"../limits.js\";\n\nconst limits = (overrides: Partial<IDebuggerLimits> = {}): IDebuggerLimits => {\n return { ...DEFAULT_LIMITS, ...overrides };\n};\n\nconst parse = (value: unknown, overrides: Partial<IDebuggerLimits> = {}) => {\n const result = serialize(value, limits(overrides));\n return { ...result, parsed: JSON.parse(result.json) };\n};\n\ndescribe(\"serialize\", () => {\n it(\"should always produce parseable JSON\", () => {\n const circular: Record<string, unknown> = { name: \"root\" };\n circular.self = circular;\n\n const { parsed } = parse(circular);\n\n expect(parsed).toEqual({ name: \"root\", self: \"#[Circular]\" });\n });\n\n it(\"should not report siblings as circular\", () => {\n const shared = { id: 1 };\n\n const { parsed } = parse({ a: shared, b: shared });\n\n expect(parsed).toEqual({ a: { id: 1 }, b: { id: 1 } });\n });\n\n it(\"should serialize an Error, which JSON.stringify renders as an empty object\", () => {\n const error = new Error(\"Boom\");\n\n const { parsed } = parse({ error });\n\n expect(parsed.error.name).toBe(\"Error\");\n expect(parsed.error.message).toBe(\"Boom\");\n expect(typeof parsed.error.stack).toBe(\"string\");\n });\n\n it(\"should serialize a BigInt, which JSON.stringify throws on\", () => {\n const { parsed } = parse({ value: BigInt(123) });\n\n expect(parsed).toEqual({ value: \"123n\" });\n });\n\n it(\"should describe binary data without including its contents\", () => {\n const { parsed } = parse({ buffer: Buffer.from(\"hello world\") });\n\n expect(parsed).toEqual({ buffer: \"#[Buffer 11 bytes]\" });\n });\n\n it(\"should serialize Map and Set\", () => {\n const { parsed } = parse({\n map: new Map([[\"a\", 1]]),\n set: new Set([1, 2])\n });\n\n expect(parsed.map).toEqual({ __type: \"Map\", entries: [[\"a\", 1]] });\n expect(parsed.set).toEqual({ __type: \"Set\", items: [1, 2] });\n });\n\n it(\"should drop an undefined property, so a logged payload matches what was sent\", () => {\n const { parsed } = parse({ kept: 1, dropped: undefined });\n\n expect(parsed).toEqual({ kept: 1 });\n });\n\n it(\"should keep undefined array elements, where dropping would shift every later index\", () => {\n const { parsed } = parse({ items: [1, undefined, 3] });\n\n expect(parsed).toEqual({ items: [1, \"#[Undefined value]\", 3] });\n });\n\n it(\"should not throw when a getter throws\", () => {\n const value = {\n get exploding() {\n throw new Error(\"Nope\");\n },\n safe: 1\n };\n\n const { parsed } = parse(value);\n\n expect(parsed.exploding).toBe(\"#[Throws: Nope]\");\n expect(parsed.safe).toBe(1);\n });\n\n it(\"should cap depth\", () => {\n const { parsed } = parse({ a: { b: { c: { d: \"deep\" } } } }, { depth: 2 });\n\n expect(parsed).toEqual({ a: { b: \"#[Depth limit]\" } });\n });\n\n it(\"should cap string length and say how much was cut\", () => {\n const { parsed } = parse({ text: \"x\".repeat(20) }, { stringLength: 5 });\n\n expect(parsed).toEqual({ text: \"xxxxx…(15 more)\" });\n });\n\n it(\"should cap array length and say how much was cut\", () => {\n const { parsed } = parse({ items: [1, 2, 3, 4, 5] }, { arrayLength: 2 });\n\n expect(parsed).toEqual({ items: [1, 2, \"…(3 more items)\"] });\n });\n\n it(\"should replace the payload wholesale when it exceeds the per-entry cap\", () => {\n const result = parse({ text: \"x\".repeat(5000) }, { entryBytes: 100, stringLength: 100000 });\n\n expect(result.truncated).toBe(true);\n expect(result.parsed.truncated).toBe(true);\n expect(result.parsed.originalBytes).toBeGreaterThan(100);\n expect(result.bytes).toBeLessThanOrEqual(100);\n });\n\n it(\"should never invoke a custom toJSON, so it cannot be broken by one\", () => {\n const value = {\n id: 1,\n toJSON() {\n throw new Error(\"Nope\");\n }\n };\n\n const { parsed } = parse({ value });\n\n expect(parsed.value.id).toBe(1);\n expect(parsed.value.toJSON).toBe(\"#[Function: toJSON]\");\n });\n\n it(\"should keep non-finite numbers readable instead of turning them into null\", () => {\n const { parsed } = parse({ a: Infinity, b: NaN });\n\n expect(parsed).toEqual({ a: \"Infinity\", b: \"NaN\" });\n });\n});\n"],"names":["limits","overrides","DEFAULT_LIMITS","parse","value","result","serialize","JSON","describe","it","circular","parsed","expect","shared","error","Error","BigInt","Buffer","Map","Set","undefined","Infinity","NaN"],"mappings":";;;AAIA,MAAMA,SAAS,CAACC,YAAsC,CAAC,CAAC,GAC7C;QAAE,GAAGC,cAAc;QAAE,GAAGD,SA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L,OAAOD,QAAQ,OAAO,CAAC;YAAE,QAAQ;QAAqB;IAC1D;IAEAF,GAAG,gCAAgC;QAC/B,MAAM,EAAEE,MAAM,EAAE,GAAGR,MAAM;YACrB,KAAK,IAAIe,IAAI;gBAAC;oBAAC;oBAAK;iBAAE;aAAC;YACvB,KAAK,IAAIC,IAAI;gBAAC;gBAAG;aAAE;QACvB;QAEAP,OAAOD,OAAO,GAAG,EAAE,OAAO,CAAC;YAAE,QAAQ;YAAO,SAAS;gBAAC;oBAAC;oBAAK;iBAAE;aAAC;QAAC;QAChEC,OAAOD,OAAO,GAAG,EAAE,OAAO,CAAC;YAAE,QAAQ;YAAO,OAAO;gBAAC;gBAAG;aAAE;QAAC;IAC9D;IAEAF,GAAG,gFAAgF;QAC/E,MAAM,EAAEE,MAAM,EAAE,GAAGR,MAAM;YAAE,MAAM;YAAG,SAASiB;QAAU;QAEvDR,OAAOD,QAAQ,OAAO,CAAC;YAAE,MAAM;QAAE;IACrC;IAEAF,GAAG,sFAAsF;QACrF,MAAM,EAAEE,MAAM,EAAE,GAAGR,MAAM;YAAE,OAAO;gBAAC;gBAAGiB;gBAAW;aAAE;QAAC;QAEpDR,OAAOD,QAAQ,OAAO,CAAC;YAAE,OAAO;gBAAC;gBAAG;gBAAsB;aAAE;QAAC;IACjE;IAEAF,GAAG,yCAAyC;QACxC,MAAML,QAAQ;YACV,IAAI
|
|
1
|
+
{"version":3,"file":"features/debugger/__tests__/serialize.test.js","sources":["../../../../src/features/debugger/__tests__/serialize.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport { serialize } from \"../serialize.js\";\nimport { DEFAULT_LIMITS, type IDebuggerLimits } from \"../limits.js\";\n\nconst limits = (overrides: Partial<IDebuggerLimits> = {}): IDebuggerLimits => {\n return { ...DEFAULT_LIMITS, ...overrides };\n};\n\nconst parse = (value: unknown, overrides: Partial<IDebuggerLimits> = {}) => {\n const result = serialize(value, limits(overrides));\n return { ...result, parsed: JSON.parse(result.json) };\n};\n\ndescribe(\"serialize\", () => {\n it(\"should always produce parseable JSON\", () => {\n const circular: Record<string, unknown> = { name: \"root\" };\n circular.self = circular;\n\n const { parsed } = parse(circular);\n\n expect(parsed).toEqual({ name: \"root\", self: \"#[Circular]\" });\n });\n\n it(\"should not report siblings as circular\", () => {\n const shared = { id: 1 };\n\n const { parsed } = parse({ a: shared, b: shared });\n\n expect(parsed).toEqual({ a: { id: 1 }, b: { id: 1 } });\n });\n\n it(\"should serialize an Error, which JSON.stringify renders as an empty object\", () => {\n const error = new Error(\"Boom\");\n\n const { parsed } = parse({ error });\n\n expect(parsed.error.name).toBe(\"Error\");\n expect(parsed.error.message).toBe(\"Boom\");\n expect(typeof parsed.error.stack).toBe(\"string\");\n });\n\n it(\"should serialize a BigInt, which JSON.stringify throws on\", () => {\n const { parsed } = parse({ value: BigInt(123) });\n\n expect(parsed).toEqual({ value: \"123n\" });\n });\n\n it(\"should describe binary data without including its contents\", () => {\n const { parsed } = parse({ buffer: Buffer.from(\"hello world\") });\n\n expect(parsed).toEqual({ buffer: \"#[Buffer 11 bytes]\" });\n });\n\n it(\"should serialize Map and Set\", () => {\n const { parsed } = parse({\n map: new Map([[\"a\", 1]]),\n set: new Set([1, 2])\n });\n\n expect(parsed.map).toEqual({ __type: \"Map\", entries: [[\"a\", 1]] });\n expect(parsed.set).toEqual({ __type: \"Set\", items: [1, 2] });\n });\n\n it(\"should drop an undefined property, so a logged payload matches what was sent\", () => {\n const { parsed } = parse({ kept: 1, dropped: undefined });\n\n expect(parsed).toEqual({ kept: 1 });\n });\n\n it(\"should keep undefined array elements, where dropping would shift every later index\", () => {\n const { parsed } = parse({ items: [1, undefined, 3] });\n\n expect(parsed).toEqual({ items: [1, \"#[Undefined value]\", 3] });\n });\n\n it(\"should not throw when a getter throws\", () => {\n const value = {\n get exploding() {\n throw new Error(\"Nope\");\n },\n safe: 1\n };\n\n const { parsed } = parse(value);\n\n expect(parsed.exploding).toBe(\"#[Throws: Nope]\");\n expect(parsed.safe).toBe(1);\n });\n\n it(\"should cap depth\", () => {\n const { parsed } = parse({ a: { b: { c: { d: \"deep\" } } } }, { depth: 2 });\n\n expect(parsed).toEqual({ a: { b: \"#[Depth limit]\" } });\n });\n\n it(\"should cap string length and say how much was cut\", () => {\n const { parsed } = parse({ text: \"x\".repeat(20) }, { stringLength: 5 });\n\n expect(parsed).toEqual({ text: \"xxxxx…(15 more)\" });\n });\n\n it(\"should cap array length and say how much was cut\", () => {\n const { parsed } = parse({ items: [1, 2, 3, 4, 5] }, { arrayLength: 2 });\n\n expect(parsed).toEqual({ items: [1, 2, \"…(3 more items)\"] });\n });\n\n it(\"should replace the payload wholesale when it exceeds the per-entry cap\", () => {\n const result = parse({ text: \"x\".repeat(5000) }, { entryBytes: 100, stringLength: 100000 });\n\n expect(result.truncated).toBe(true);\n expect(result.parsed.truncated).toBe(true);\n expect(result.parsed.originalBytes).toBeGreaterThan(100);\n expect(result.bytes).toBeLessThanOrEqual(100);\n });\n\n it(\"should never invoke a custom toJSON, so it cannot be broken by one\", () => {\n const value = {\n id: 1,\n toJSON() {\n throw new Error(\"Nope\");\n }\n };\n\n const { parsed } = parse({ value });\n\n expect(parsed.value.id).toBe(1);\n expect(parsed.value.toJSON).toBe(\"#[Function: toJSON]\");\n });\n\n it(\"should keep non-finite numbers readable instead of turning them into null\", () => {\n const { parsed } = parse({ a: Infinity, b: NaN });\n\n expect(parsed).toEqual({ a: \"Infinity\", b: \"NaN\" });\n });\n});\n"],"names":["limits","overrides","DEFAULT_LIMITS","parse","value","result","serialize","JSON","describe","it","circular","parsed","expect","shared","error","Error","BigInt","Buffer","Map","Set","undefined","Infinity","NaN"],"mappings":";;;AAIA,MAAMA,SAAS,CAACC,YAAsC,CAAC,CAAC,GAC7C;QAAE,GAAGC,cAAc;QAAE,GAAGD,SAAS;IAAC;AAG7C,MAAME,QAAQ,CAACC,OAAgBH,YAAsC,CAAC,CAAC;IACnE,MAAMI,SAASC,UAAUF,OAAOJ,OAAOC;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ncryptionConfig } from "./abstractions.js";
|
|
2
|
+
import { BuildParams } from "../buildParams/abstractions.js";
|
|
3
|
+
export declare const DEFAULT_ENCRYPTION_ALGORITHM = "aes-256-gcm";
|
|
4
|
+
declare class BuildParamsEncryptionConfigImpl implements EncryptionConfig.Interface {
|
|
5
|
+
readonly passphrase: string | null;
|
|
6
|
+
readonly salt: string;
|
|
7
|
+
readonly algorithm: string;
|
|
8
|
+
constructor(buildParams: BuildParams.Interface);
|
|
9
|
+
}
|
|
10
|
+
export declare const BuildParamsEncryptionConfig: typeof BuildParamsEncryptionConfigImpl & {
|
|
11
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IEncryptionConfig>;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EncryptionConfig } from "./abstractions.js";
|
|
2
|
+
import { BuildParams } from "../buildParams/abstractions.js";
|
|
3
|
+
const DEFAULT_ENCRYPTION_ALGORITHM = "aes-256-gcm";
|
|
4
|
+
class BuildParamsEncryptionConfigImpl {
|
|
5
|
+
constructor(buildParams){
|
|
6
|
+
this.passphrase = buildParams.get("EncryptionPassphrase") || null;
|
|
7
|
+
this.salt = buildParams.get("EncryptionSalt") ?? "";
|
|
8
|
+
this.algorithm = buildParams.get("EncryptionAlgorithm") ?? DEFAULT_ENCRYPTION_ALGORITHM;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const BuildParamsEncryptionConfig = EncryptionConfig.createImplementation({
|
|
12
|
+
implementation: BuildParamsEncryptionConfigImpl,
|
|
13
|
+
dependencies: [
|
|
14
|
+
BuildParams
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
export { BuildParamsEncryptionConfig, DEFAULT_ENCRYPTION_ALGORITHM };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=BuildParamsEncryptionConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/encryption/BuildParamsEncryptionConfig.js","sources":["../../../src/features/encryption/BuildParamsEncryptionConfig.ts"],"sourcesContent":["import { EncryptionConfig } from \"./abstractions.js\";\nimport { BuildParams } from \"../buildParams/abstractions.js\";\n\nexport const DEFAULT_ENCRYPTION_ALGORITHM = \"aes-256-gcm\";\n\nclass BuildParamsEncryptionConfigImpl implements EncryptionConfig.Interface {\n readonly passphrase: string | null;\n readonly salt: string;\n readonly algorithm: string;\n\n constructor(buildParams: BuildParams.Interface) {\n this.passphrase = buildParams.get<string>(\"EncryptionPassphrase\") || null;\n this.salt = buildParams.get<string>(\"EncryptionSalt\") ?? \"\";\n this.algorithm =\n buildParams.get<string>(\"EncryptionAlgorithm\") ?? DEFAULT_ENCRYPTION_ALGORITHM;\n }\n}\n\nexport const BuildParamsEncryptionConfig = EncryptionConfig.createImplementation({\n implementation: BuildParamsEncryptionConfigImpl,\n dependencies: [BuildParams]\n});\n"],"names":["DEFAULT_ENCRYPTION_ALGORITHM","BuildParamsEncryptionConfigImpl","buildParams","BuildParamsEncryptionConfig","EncryptionConfig","BuildParams"],"mappings":";;AAGO,MAAMA,+BAA+B;AAE5C,MAAMC;IAKF,YAAYC,WAAkC,CAAE;QAC5C,IAAI,CAAC,UAAU,GAAGA,YAAY,GAAG,CAAS,2BAA2B;QACrE,IAAI,CAAC,IAAI,GAAGA,YAAY,GAAG,CAAS,qBAAqB;QACzD,IAAI,CAAC,SAAS,GACVA,YAAY,GAAG,CAAS,0BAA0BF;IAC1D;AACJ;AAEO,MAAMG,8BAA8BC,iBAAiB,oBAAoB,CAAC;IAC7E,gBAAgBH;IAChB,cAAc;QAACI;KAAY;AAC/B"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Encryption as EncryptionAbstraction } from "./abstractions.js";
|
|
2
2
|
import { EncryptionKeyCache } from "./abstractions.js";
|
|
3
|
-
import {
|
|
3
|
+
import { EncryptionConfig } from "./abstractions.js";
|
|
4
4
|
export declare class EncryptionImpl implements EncryptionAbstraction.Interface {
|
|
5
5
|
private key;
|
|
6
6
|
private algorithm;
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(config: EncryptionConfig.Interface, keyCache: EncryptionKeyCache.Interface | undefined);
|
|
8
8
|
encrypt(value: string): Promise<string>;
|
|
9
9
|
decrypt(value: string): Promise<string>;
|
|
10
10
|
}
|