@webiny/api-core 0.0.0-unstable.a4f3e4ea8b → 0.0.0-unstable.a85ef555b2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ApiCoreFeature.d.ts +2 -2
- package/ApiCoreFeature.js +35 -5
- package/ApiCoreFeature.js.map +1 -1
- package/exports/api/tasks.d.ts +1 -0
- package/exports/api/tasks.js +1 -1
- package/exports/api.d.ts +2 -1
- package/exports/api.js +2 -1
- package/features/ai/Ai.js +16 -6
- package/features/ai/Ai.js.map +1 -1
- package/features/ai/AiModelRegistry.d.ts +3 -1
- package/features/ai/AiModelRegistry.js +16 -7
- package/features/ai/AiModelRegistry.js.map +1 -1
- package/features/ai/AiSdkToolHandlerResolver.d.ts +11 -0
- package/features/ai/AiSdkToolHandlerResolver.js +19 -0
- package/features/ai/AiSdkToolHandlerResolver.js.map +1 -0
- package/features/ai/AiSdkTools.d.ts +4 -3
- package/features/ai/AiSdkTools.js +11 -9
- package/features/ai/AiSdkTools.js.map +1 -1
- package/features/ai/DEVELOPERS.md +69 -12
- package/features/ai/OpenRouterSdkFactory.d.ts +10 -0
- package/features/ai/OpenRouterSdkFactory.js +112 -0
- package/features/ai/OpenRouterSdkFactory.js.map +1 -0
- package/features/ai/RemoteAiModelCatalog.d.ts +13 -0
- package/features/ai/RemoteAiModelCatalog.js +74 -0
- package/features/ai/RemoteAiModelCatalog.js.map +1 -0
- package/features/ai/abstractions.d.ts +90 -7
- package/features/ai/abstractions.js +5 -2
- package/features/ai/abstractions.js.map +1 -1
- package/features/ai/feature.js +6 -0
- package/features/ai/feature.js.map +1 -1
- package/features/ai/index.d.ts +2 -4
- package/features/ai/index.js +1 -1
- package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
- package/features/dateFormatter/DefaultDateFormatter.js +20 -0
- package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
- package/features/dateFormatter/abstractions.d.ts +13 -0
- package/features/dateFormatter/abstractions.js +5 -0
- package/features/dateFormatter/abstractions.js.map +1 -0
- package/features/dateFormatter/feature.d.ts +4 -0
- package/features/dateFormatter/feature.js +11 -0
- package/features/dateFormatter/feature.js.map +1 -0
- package/features/dateFormatter/index.d.ts +3 -0
- package/features/dateFormatter/index.js +2 -0
- package/features/debugger/Debugger.d.ts +30 -0
- package/features/debugger/Debugger.js +142 -0
- package/features/debugger/Debugger.js.map +1 -0
- package/features/debugger/DebuggerRouteDecorator.d.ts +45 -0
- package/features/debugger/DebuggerRouteDecorator.js +107 -0
- package/features/debugger/DebuggerRouteDecorator.js.map +1 -0
- package/features/debugger/GraphQLDebuggerTransport.d.ts +28 -0
- package/features/debugger/GraphQLDebuggerTransport.js +45 -0
- package/features/debugger/GraphQLDebuggerTransport.js.map +1 -0
- package/features/debugger/__tests__/matchNamespace.test.d.ts +1 -0
- package/features/debugger/__tests__/matchNamespace.test.js +68 -0
- package/features/debugger/__tests__/matchNamespace.test.js.map +1 -0
- package/features/debugger/__tests__/serialize.test.d.ts +1 -0
- package/features/debugger/__tests__/serialize.test.js +220 -0
- package/features/debugger/__tests__/serialize.test.js.map +1 -0
- package/features/debugger/abstractions.d.ts +100 -0
- package/features/debugger/abstractions.js +6 -0
- package/features/debugger/abstractions.js.map +1 -0
- package/features/debugger/feature.d.ts +5 -0
- package/features/debugger/feature.js +15 -0
- package/features/debugger/feature.js.map +1 -0
- package/features/debugger/index.d.ts +12 -0
- package/features/debugger/index.js +7 -0
- package/features/debugger/limits.d.ts +18 -0
- package/features/debugger/limits.js +11 -0
- package/features/debugger/limits.js.map +1 -0
- package/features/debugger/matchNamespace.d.ts +14 -0
- package/features/debugger/matchNamespace.js +35 -0
- package/features/debugger/matchNamespace.js.map +1 -0
- package/features/debugger/parseNamespaceHeader.d.ts +7 -0
- package/features/debugger/parseNamespaceHeader.js +16 -0
- package/features/debugger/parseNamespaceHeader.js.map +1 -0
- package/features/debugger/permissions.d.ts +14 -0
- package/features/debugger/permissions.js +8 -0
- package/features/debugger/permissions.js.map +1 -0
- package/features/debugger/permissionsSchema.d.ts +17 -0
- package/features/debugger/permissionsSchema.js +18 -0
- package/features/debugger/permissionsSchema.js.map +1 -0
- package/features/debugger/serialize.d.ts +11 -0
- package/features/debugger/serialize.js +121 -0
- package/features/debugger/serialize.js.map +1 -0
- package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
- package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
- package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
- package/features/encryption/EncryptionService.d.ts +2 -1
- package/features/encryption/EncryptionService.js +11 -4
- package/features/encryption/EncryptionService.js.map +1 -1
- package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
- package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
- package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
- package/features/encryption/abstractions.d.ts +11 -0
- package/features/encryption/abstractions.js +2 -1
- package/features/encryption/abstractions.js.map +1 -1
- package/features/encryption/index.d.ts +1 -0
- package/features/encryption/index.js +1 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +62 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
- package/features/hashing/ScryptHasher.d.ts +11 -0
- package/features/hashing/ScryptHasher.js +74 -0
- package/features/hashing/ScryptHasher.js.map +1 -0
- package/features/hashing/abstractions.d.ts +18 -0
- package/features/hashing/abstractions.js +5 -0
- package/features/hashing/abstractions.js.map +1 -0
- package/features/hashing/feature.d.ts +4 -0
- package/features/hashing/feature.js +11 -0
- package/features/hashing/feature.js.map +1 -0
- package/features/hashing/index.d.ts +2 -0
- package/features/hashing/index.js +1 -0
- package/features/httpClient/HttpClient.d.ts +7 -0
- package/features/httpClient/HttpClient.js +72 -0
- package/features/httpClient/HttpClient.js.map +1 -0
- package/features/httpClient/HttpRequestError.d.ts +10 -0
- package/features/httpClient/HttpRequestError.js +13 -0
- package/features/httpClient/HttpRequestError.js.map +1 -0
- package/features/httpClient/HttpStatusError.d.ts +12 -0
- package/features/httpClient/HttpStatusError.js +12 -0
- package/features/httpClient/HttpStatusError.js.map +1 -0
- package/features/httpClient/abstractions.d.ts +32 -0
- package/features/httpClient/abstractions.js +5 -0
- package/features/httpClient/abstractions.js.map +1 -0
- package/features/httpClient/feature.d.ts +4 -0
- package/features/httpClient/feature.js +11 -0
- package/features/httpClient/feature.js.map +1 -0
- package/features/httpClient/index.d.ts +3 -0
- package/features/httpClient/index.js +3 -0
- package/features/keyValueStore/GlobalKeyValueStore.d.ts +9 -3
- package/features/keyValueStore/GlobalKeyValueStore.js +12 -2
- package/features/keyValueStore/GlobalKeyValueStore.js.map +1 -1
- package/features/keyValueStore/KeyValueStore.d.ts +6 -2
- package/features/keyValueStore/KeyValueStore.js +13 -3
- package/features/keyValueStore/KeyValueStore.js.map +1 -1
- package/features/keyValueStore/KeyValueStoreRepository.d.ts +8 -2
- package/features/keyValueStore/KeyValueStoreRepository.js +82 -4
- package/features/keyValueStore/KeyValueStoreRepository.js.map +1 -1
- package/features/keyValueStore/abstractions.d.ts +132 -14
- package/features/keyValueStore/abstractions.js.map +1 -1
- package/features/keyValueStore/errors.d.ts +29 -0
- package/features/keyValueStore/errors.js +49 -1
- package/features/keyValueStore/errors.js.map +1 -1
- package/features/keyValueStore/index.d.ts +4 -1
- package/features/keyValueStore/index.js +1 -1
- package/features/publicUrls/NullPublicUrls.d.ts +11 -0
- package/features/publicUrls/NullPublicUrls.js +17 -0
- package/features/publicUrls/NullPublicUrls.js.map +1 -0
- package/features/publicUrls/PublicUrl.d.ts +24 -0
- package/features/publicUrls/PublicUrl.js +43 -0
- package/features/publicUrls/PublicUrl.js.map +1 -0
- package/features/publicUrls/__tests__/PublicUrl.test.d.ts +1 -0
- package/features/publicUrls/__tests__/PublicUrl.test.js +38 -0
- package/features/publicUrls/__tests__/PublicUrl.test.js.map +1 -0
- package/features/publicUrls/__tests__/PublicUrls.test.d.ts +1 -0
- package/features/publicUrls/__tests__/PublicUrls.test.js +14 -0
- package/features/publicUrls/__tests__/PublicUrls.test.js.map +1 -0
- package/features/publicUrls/abstractions.d.ts +27 -0
- package/features/publicUrls/abstractions.js +5 -0
- package/features/publicUrls/abstractions.js.map +1 -0
- package/features/publicUrls/feature.d.ts +8 -0
- package/features/publicUrls/feature.js +11 -0
- package/features/publicUrls/feature.js.map +1 -0
- package/features/publicUrls/index.d.ts +3 -0
- package/features/publicUrls/index.js +3 -0
- package/features/requestContext/RawAssumePermissions.d.ts +14 -0
- package/features/requestContext/RawAssumePermissions.js +19 -0
- package/features/requestContext/RawAssumePermissions.js.map +1 -0
- package/features/requestContext/RawAuthToken.d.ts +14 -0
- package/features/requestContext/RawAuthToken.js +19 -0
- package/features/requestContext/RawAuthToken.js.map +1 -0
- package/features/requestContext/RawTenantId.d.ts +14 -0
- package/features/requestContext/RawTenantId.js +19 -0
- package/features/requestContext/RawTenantId.js.map +1 -0
- package/features/requestContext/RequestIdentityLoader.d.ts +19 -0
- package/features/requestContext/RequestIdentityLoader.js +26 -0
- package/features/requestContext/RequestIdentityLoader.js.map +1 -0
- package/features/requestContext/RequestTenantLoader.d.ts +18 -0
- package/features/requestContext/RequestTenantLoader.js +52 -0
- package/features/requestContext/RequestTenantLoader.js.map +1 -0
- package/features/requestContext/abstractions.d.ts +75 -0
- package/features/requestContext/abstractions.js +9 -0
- package/features/requestContext/abstractions.js.map +1 -0
- package/features/requestContext/extractAssumePermissions.d.ts +14 -0
- package/features/requestContext/extractAssumePermissions.js +32 -0
- package/features/requestContext/extractAssumePermissions.js.map +1 -0
- package/features/requestContext/feature.d.ts +12 -0
- package/features/requestContext/feature.js +19 -0
- package/features/requestContext/feature.js.map +1 -0
- package/features/requestContext/index.d.ts +4 -0
- package/features/requestContext/index.js +3 -0
- package/features/security/IdentityContext/IdentityContext.d.ts +4 -3
- package/features/security/IdentityContext/IdentityContext.js +9 -6
- package/features/security/IdentityContext/IdentityContext.js.map +1 -1
- package/features/security/IdentityContext/abstractions.d.ts +5 -0
- package/features/security/IdentityContext/abstractions.js.map +1 -1
- package/features/security/apiKeys/ApiKeyAuthenticator.d.ts +14 -0
- package/features/security/apiKeys/ApiKeyAuthenticator.js +36 -0
- package/features/security/apiKeys/ApiKeyAuthenticator.js.map +1 -0
- package/features/security/apiKeys/ApiKeyAuthorizer.d.ts +10 -0
- package/features/security/apiKeys/ApiKeyAuthorizer.js +15 -0
- package/features/security/apiKeys/ApiKeyAuthorizer.js.map +1 -0
- package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
- package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -1
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/feature.js +4 -0
- package/features/security/apiKeys/feature.js.map +1 -1
- package/features/security/apiKeys/shared/schemas.d.ts +2 -2
- package/features/security/apiKeys/shared/schemas.js +2 -2
- package/features/security/apiKeys/shared/schemas.js.map +1 -1
- package/features/security/authorization/AuthorizationContext/AuthorizationContext.d.ts +12 -3
- package/features/security/authorization/AuthorizationContext/AuthorizationContext.js +31 -18
- 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/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +3 -3
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
- package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
- package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
- package/features/security/roles/CreateRole/schema.d.ts +1 -1
- package/features/security/roles/CreateRole/schema.js +1 -1
- package/features/security/roles/CreateRole/schema.js.map +1 -1
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
- package/features/security/roles/UpdateRole/schema.d.ts +1 -1
- package/features/security/roles/UpdateRole/schema.js +1 -1
- package/features/security/roles/UpdateRole/schema.js.map +1 -1
- package/features/security/shared/description.d.ts +4 -0
- package/features/security/shared/description.js +7 -0
- package/features/security/shared/description.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/CreateTeam/CreateTeamUseCase.d.ts +3 -1
- package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
- package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
- package/features/security/teams/CreateTeam/schema.d.ts +1 -1
- package/features/security/teams/CreateTeam/schema.js +1 -1
- package/features/security/teams/CreateTeam/schema.js.map +1 -1
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
- package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
- package/features/security/teams/UpdateTeam/schema.js +1 -1
- package/features/security/teams/UpdateTeam/schema.js.map +1 -1
- package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
- package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
- package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
- package/features/slugify/DefaultSlugify.d.ts +8 -0
- package/features/slugify/DefaultSlugify.js +20 -0
- package/features/slugify/DefaultSlugify.js.map +1 -0
- package/features/slugify/abstractions.d.ts +12 -0
- package/features/slugify/abstractions.js +5 -0
- package/features/slugify/abstractions.js.map +1 -0
- package/features/slugify/feature.d.ts +4 -0
- package/features/slugify/feature.js +11 -0
- package/features/slugify/feature.js.map +1 -0
- package/features/slugify/index.d.ts +3 -0
- package/features/slugify/index.js +2 -0
- package/features/storageOperations/abstractions.d.ts +21 -0
- package/features/storageOperations/abstractions.js +10 -0
- package/features/storageOperations/abstractions.js.map +1 -0
- package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
- package/features/stringFormatter/DefaultStringFormatter.js +19 -0
- package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
- package/features/stringFormatter/abstractions.d.ts +11 -0
- package/features/stringFormatter/abstractions.js +5 -0
- package/features/stringFormatter/abstractions.js.map +1 -0
- package/features/stringFormatter/feature.d.ts +4 -0
- package/features/stringFormatter/feature.js +13 -0
- package/features/stringFormatter/feature.js.map +1 -0
- package/features/stringFormatter/index.d.ts +3 -0
- package/features/stringFormatter/index.js +2 -0
- package/features/task/TaskDefinition/abstractions.d.ts +69 -4
- package/features/task/TaskDefinition/abstractions.js +2 -1
- package/features/task/TaskDefinition/abstractions.js.map +1 -1
- package/features/tenancy/TenantContext/TenantContext.d.ts +1 -0
- package/features/tenancy/TenantContext/TenantContext.js +13 -8
- package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
- package/features/users/shared/types.d.ts +9 -7
- package/features/wcp/WcpContext/WcpContext.d.ts +12 -5
- package/features/wcp/WcpContext/WcpContext.js +29 -2
- package/features/wcp/WcpContext/WcpContext.js.map +1 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +11 -66
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +71 -33
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
- package/features/wcp/WcpContext/feature.d.ts +1 -2
- package/features/wcp/WcpContext/feature.js +2 -2
- package/features/wcp/WcpContext/feature.js.map +1 -1
- package/features/wcp/WcpContext/index.d.ts +0 -1
- package/features/wcp/WcpContext/types.d.ts +0 -4
- package/features/wcp/WcpFeature.d.ts +1 -1
- package/features/wcp/WcpFeature.js +7 -2
- package/features/wcp/WcpFeature.js.map +1 -1
- package/features/wcp/WcpLicenseLoader.d.ts +25 -0
- package/features/wcp/WcpLicenseLoader.js +58 -0
- package/features/wcp/WcpLicenseLoader.js.map +1 -0
- package/features/wcp/WcpLicenseProvider.d.ts +21 -0
- package/features/wcp/WcpLicenseProvider.js +14 -0
- package/features/wcp/WcpLicenseProvider.js.map +1 -0
- package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
- package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
- package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
- package/graphql/ApiCoreSchemaFactory.d.ts +16 -0
- package/graphql/ApiCoreSchemaFactory.js +58 -0
- package/graphql/ApiCoreSchemaFactory.js.map +1 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +10 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +53 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
- package/graphql/security/NotAuthorizedResponse.d.ts +1 -1
- package/graphql/security/NotAuthorizedResponse.js +1 -1
- package/graphql/security/NotAuthorizedResponse.js.map +1 -1
- package/graphql/security/SecuritySchemaFactory.d.ts +15 -0
- package/graphql/security/SecuritySchemaFactory.js +27 -0
- package/graphql/security/SecuritySchemaFactory.js.map +1 -0
- package/graphql/security/addApiKeySchema.d.ts +2 -0
- package/graphql/security/{apiKey.gql.js → addApiKeySchema.js} +45 -27
- package/graphql/security/addApiKeySchema.js.map +1 -0
- package/graphql/security/addIdentitySchema.d.ts +2 -0
- package/graphql/security/{identity.gql.js → addIdentitySchema.js} +52 -35
- package/graphql/security/addIdentitySchema.js.map +1 -0
- package/graphql/security/addRoleSchema.d.ts +2 -0
- package/graphql/security/addRoleSchema.js +137 -0
- package/graphql/security/addRoleSchema.js.map +1 -0
- package/graphql/security/addSecurityBaseSchema.d.ts +2 -0
- package/graphql/security/{base.gql.js → addSecurityBaseSchema.js} +14 -16
- package/graphql/security/addSecurityBaseSchema.js.map +1 -0
- package/graphql/security/addTeamSchema.d.ts +2 -0
- package/graphql/security/addTeamSchema.js +157 -0
- package/graphql/security/addTeamSchema.js.map +1 -0
- package/graphql/system/SystemSchemaFactory.d.ts +10 -0
- package/graphql/system/SystemSchemaFactory.js +70 -0
- package/graphql/system/SystemSchemaFactory.js.map +1 -0
- package/graphql/users/UsersSchemaFactory.d.ts +10 -0
- package/graphql/users/UsersSchemaFactory.js +195 -0
- package/graphql/users/UsersSchemaFactory.js.map +1 -0
- package/graphql/wcp/WcpSchemaFactory.d.ts +10 -0
- package/graphql/wcp/{graphql.js → WcpSchemaFactory.js} +32 -18
- package/graphql/wcp/WcpSchemaFactory.js.map +1 -0
- package/idp/JwksCache.d.ts +14 -3
- package/idp/JwksCache.js +97 -17
- package/idp/JwksCache.js.map +1 -1
- package/idp/JwksStoreFeature.d.ts +8 -0
- package/idp/JwksStoreFeature.js +11 -0
- package/idp/JwksStoreFeature.js.map +1 -0
- package/idp/MemoryJwksStore.d.ts +14 -0
- package/idp/MemoryJwksStore.js +21 -0
- package/idp/MemoryJwksStore.js.map +1 -0
- package/idp/OidcJwtIdentityProvider.js +5 -1
- package/idp/OidcJwtIdentityProvider.js.map +1 -1
- package/idp/abstractions.d.ts +24 -0
- package/idp/abstractions.js +2 -1
- package/idp/abstractions.js.map +1 -1
- package/idp/feature.js +1 -2
- package/idp/feature.js.map +1 -1
- package/idp/index.d.ts +1 -0
- package/idp/index.js +1 -0
- package/index.d.ts +3 -1
- package/index.js +3 -1
- package/package.json +22 -22
- package/testing/environment.d.ts +14 -0
- package/testing/environment.js +18 -0
- package/testing/environment.js.map +1 -0
- package/types/core.d.ts +17 -5
- package/types/security.d.ts +0 -6
- package/types/tenancy.d.ts +0 -17
- package/types/users.d.ts +2 -16
- package/createApiCore.d.ts +0 -7
- package/createApiCore.js +0 -26
- package/createApiCore.js.map +0 -1
- package/graphql/security/apiKey.gql.d.ts +0 -4
- package/graphql/security/apiKey.gql.js.map +0 -1
- package/graphql/security/base.gql.d.ts +0 -4
- package/graphql/security/base.gql.js.map +0 -1
- package/graphql/security/identity.gql.d.ts +0 -4
- package/graphql/security/identity.gql.js.map +0 -1
- package/graphql/security/index.d.ts +0 -1
- package/graphql/security/index.js +0 -15
- package/graphql/security/index.js.map +0 -1
- package/graphql/security/role.gql.d.ts +0 -4
- package/graphql/security/role.gql.js +0 -106
- package/graphql/security/role.gql.js.map +0 -1
- package/graphql/security/team.gql.d.ts +0 -4
- package/graphql/security/team.gql.js +0 -119
- package/graphql/security/team.gql.js.map +0 -1
- package/graphql/system/createSystemGraphQL.d.ts +0 -2
- package/graphql/system/createSystemGraphQL.js +0 -54
- package/graphql/system/createSystemGraphQL.js.map +0 -1
- package/graphql/users/user.gql.d.ts +0 -3
- package/graphql/users/user.gql.js +0 -167
- package/graphql/users/user.gql.js.map +0 -1
- package/graphql/wcp/graphql.d.ts +0 -2
- package/graphql/wcp/graphql.js.map +0 -1
- package/legacy/security/LegacyContext.d.ts +0 -36
- package/legacy/security/LegacyContext.js +0 -152
- package/legacy/security/LegacyContext.js.map +0 -1
- package/legacy/security/createSecurityContext.d.ts +0 -3
- package/legacy/security/createSecurityContext.js +0 -10
- package/legacy/security/createSecurityContext.js.map +0 -1
- package/legacy/security/plugins/apiKeyAuthentication.d.ts +0 -7
- package/legacy/security/plugins/apiKeyAuthentication.js +0 -20
- package/legacy/security/plugins/apiKeyAuthentication.js.map +0 -1
- package/legacy/security/plugins/apiKeyAuthorization.d.ts +0 -6
- package/legacy/security/plugins/apiKeyAuthorization.js +0 -13
- package/legacy/security/plugins/apiKeyAuthorization.js.map +0 -1
- package/legacy/security/plugins/authenticateUsingCookie.d.ts +0 -5
- package/legacy/security/plugins/authenticateUsingCookie.js +0 -23
- package/legacy/security/plugins/authenticateUsingCookie.js.map +0 -1
- package/legacy/security/plugins/authenticateUsingHttpHeader.d.ts +0 -5
- package/legacy/security/plugins/authenticateUsingHttpHeader.js +0 -20
- package/legacy/security/plugins/authenticateUsingHttpHeader.js.map +0 -1
- package/legacy/security/plugins/secureHeaders.d.ts +0 -1
- package/legacy/security/plugins/secureHeaders.js +0 -30
- package/legacy/security/plugins/secureHeaders.js.map +0 -1
- package/legacy/tenancy/LegacyContext.d.ts +0 -15
- package/legacy/tenancy/LegacyContext.js +0 -57
- package/legacy/tenancy/LegacyContext.js.map +0 -1
- package/legacy/tenancy/createTenancyContext.d.ts +0 -3
- package/legacy/tenancy/createTenancyContext.js +0 -31
- package/legacy/tenancy/createTenancyContext.js.map +0 -1
- package/legacy/users/LegacyContext.d.ts +0 -13
- package/legacy/users/LegacyContext.js +0 -55
- package/legacy/users/LegacyContext.js.map +0 -1
- package/legacy/users/createAdminUsersContext.d.ts +0 -3
- package/legacy/users/createAdminUsersContext.js +0 -12
- package/legacy/users/createAdminUsersContext.js.map +0 -1
- package/legacy/wcp/LegacyWcpContext.d.ts +0 -37
- package/legacy/wcp/LegacyWcpContext.js +0 -96
- package/legacy/wcp/LegacyWcpContext.js.map +0 -1
- package/legacy/wcp/context.d.ts +0 -5
- package/legacy/wcp/context.js +0 -46
- package/legacy/wcp/context.js.map +0 -1
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { Result, createImplementation } from "@webiny/feature/api";
|
|
2
2
|
import { UpdateTeam } from "./abstractions.js";
|
|
3
3
|
import { TeamsRepository } from "../shared/abstractions.js";
|
|
4
|
+
import { RolesRepository } from "../../roles/shared/abstractions.js";
|
|
4
5
|
import { IdentityContext } from "../../IdentityContext/abstractions.js";
|
|
5
6
|
import { EventPublisher } from "../../../eventPublisher/index.js";
|
|
6
7
|
import { updateTeamValidation } from "./schema.js";
|
|
7
8
|
import { TeamAfterUpdateEvent, TeamBeforeUpdateEvent } from "./events.js";
|
|
9
|
+
import { descriptionOnUpdate } from "../../shared/description.js";
|
|
10
|
+
import { resolveRoleIdentifiers } from "../shared/resolveRoleIdentifiers.js";
|
|
8
11
|
import { CannotUpdatePluginTeamsError, CannotUpdateSystemTeamsError, NotAuthorizedError, TeamValidationError } from "../shared/errors.js";
|
|
9
12
|
class UpdateTeamUseCase {
|
|
10
|
-
constructor(repository, identityContext, eventPublisher){
|
|
13
|
+
constructor(repository, identityContext, eventPublisher, rolesRepository){
|
|
11
14
|
this.repository = repository;
|
|
12
15
|
this.identityContext = identityContext;
|
|
13
16
|
this.eventPublisher = eventPublisher;
|
|
17
|
+
this.rolesRepository = rolesRepository;
|
|
14
18
|
}
|
|
15
19
|
async execute(id, input) {
|
|
16
20
|
const hasPermission = await this.identityContext.getPermission("security.team");
|
|
@@ -24,21 +28,31 @@ class UpdateTeamUseCase {
|
|
|
24
28
|
const existingTeam = existingResult.value;
|
|
25
29
|
if (existingTeam.system) return Result.fail(new CannotUpdateSystemTeamsError());
|
|
26
30
|
if (existingTeam.plugin) return Result.fail(new CannotUpdatePluginTeamsError());
|
|
31
|
+
const { description, ...rest } = validation.data;
|
|
32
|
+
const changes = {
|
|
33
|
+
...rest,
|
|
34
|
+
...descriptionOnUpdate(description)
|
|
35
|
+
};
|
|
36
|
+
if (changes.roles) {
|
|
37
|
+
const roleIdsResult = await resolveRoleIdentifiers(this.rolesRepository, changes.roles);
|
|
38
|
+
if (roleIdsResult.isFail()) return Result.fail(roleIdsResult.error);
|
|
39
|
+
changes.roles = roleIdsResult.value;
|
|
40
|
+
}
|
|
27
41
|
const updatedTeam = {
|
|
28
42
|
...existingTeam,
|
|
29
|
-
...
|
|
43
|
+
...changes
|
|
30
44
|
};
|
|
31
45
|
await this.eventPublisher.publish(new TeamBeforeUpdateEvent({
|
|
32
46
|
original: existingTeam,
|
|
33
47
|
updated: updatedTeam,
|
|
34
|
-
input:
|
|
48
|
+
input: changes
|
|
35
49
|
}));
|
|
36
50
|
const result = await this.repository.update(updatedTeam);
|
|
37
51
|
if (result.isFail()) return Result.fail(result.error);
|
|
38
52
|
await this.eventPublisher.publish(new TeamAfterUpdateEvent({
|
|
39
53
|
original: existingTeam,
|
|
40
54
|
updated: updatedTeam,
|
|
41
|
-
input:
|
|
55
|
+
input: changes
|
|
42
56
|
}));
|
|
43
57
|
return Result.ok(updatedTeam);
|
|
44
58
|
}
|
|
@@ -49,7 +63,8 @@ const UpdateTeamUseCaseImpl = createImplementation({
|
|
|
49
63
|
dependencies: [
|
|
50
64
|
TeamsRepository,
|
|
51
65
|
IdentityContext,
|
|
52
|
-
EventPublisher
|
|
66
|
+
EventPublisher,
|
|
67
|
+
RolesRepository
|
|
53
68
|
]
|
|
54
69
|
});
|
|
55
70
|
export { UpdateTeamUseCase, UpdateTeamUseCaseImpl };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/security/teams/UpdateTeam/UpdateTeamUseCase.js","sources":["../../../../../src/features/security/teams/UpdateTeam/UpdateTeamUseCase.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { UpdateTeam } from \"./abstractions.js\";\nimport { TeamsRepository } from \"../shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { updateTeamValidation } from \"./schema.js\";\nimport { TeamBeforeUpdateEvent, TeamAfterUpdateEvent } from \"./events.js\";\nimport type { Team, UpdateTeamInput } from \"../shared/types.js\";\nimport {\n NotAuthorizedError,\n CannotUpdatePluginTeamsError,\n CannotUpdateSystemTeamsError,\n TeamValidationError\n} from \"../shared/errors.js\";\n\nexport class UpdateTeamUseCase {\n private repository: TeamsRepository.Interface;\n private identityContext: IdentityContext.Interface;\n private eventPublisher: EventPublisher.Interface;\n\n constructor(\n repository: TeamsRepository.Interface,\n identityContext: IdentityContext.Interface,\n eventPublisher: EventPublisher.Interface\n ) {\n this.repository = repository;\n this.identityContext = identityContext;\n this.eventPublisher = eventPublisher;\n }\n\n async execute(id: string, input: UpdateTeamInput): Promise<Result<Team, UpdateTeam.Error>> {\n const hasPermission = await this.identityContext.getPermission(\"security.team\");\n if (!hasPermission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n const validation = updateTeamValidation.safeParse(input);\n if (!validation.success) {\n return Result.fail(new TeamValidationError(validation.error.issues[0].message));\n }\n\n const existingResult = await this.repository.get({ id });\n if (existingResult.isFail()) {\n return Result.fail(existingResult.error);\n }\n\n const existingTeam = existingResult.value;\n\n // Check if team is system team\n if (existingTeam.system) {\n return Result.fail(new CannotUpdateSystemTeamsError());\n }\n\n // Check if team is created via plugin\n if (existingTeam.plugin) {\n return Result.fail(new CannotUpdatePluginTeamsError());\n }\n\n const updatedTeam: Team = {\n ...existingTeam,\n ...
|
|
1
|
+
{"version":3,"file":"features/security/teams/UpdateTeam/UpdateTeamUseCase.js","sources":["../../../../../src/features/security/teams/UpdateTeam/UpdateTeamUseCase.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { UpdateTeam } from \"./abstractions.js\";\nimport { TeamsRepository } from \"../shared/abstractions.js\";\nimport { RolesRepository } from \"../../roles/shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { updateTeamValidation } from \"./schema.js\";\nimport { TeamBeforeUpdateEvent, TeamAfterUpdateEvent } from \"./events.js\";\nimport type { Team, UpdateTeamInput } from \"../shared/types.js\";\nimport { descriptionOnUpdate } from \"../../shared/description.js\";\nimport { resolveRoleIdentifiers } from \"../shared/resolveRoleIdentifiers.js\";\nimport {\n NotAuthorizedError,\n CannotUpdatePluginTeamsError,\n CannotUpdateSystemTeamsError,\n TeamValidationError\n} from \"../shared/errors.js\";\n\nexport class UpdateTeamUseCase {\n private repository: TeamsRepository.Interface;\n private identityContext: IdentityContext.Interface;\n private eventPublisher: EventPublisher.Interface;\n private rolesRepository: RolesRepository.Interface;\n\n constructor(\n repository: TeamsRepository.Interface,\n identityContext: IdentityContext.Interface,\n eventPublisher: EventPublisher.Interface,\n rolesRepository: RolesRepository.Interface\n ) {\n this.repository = repository;\n this.identityContext = identityContext;\n this.eventPublisher = eventPublisher;\n this.rolesRepository = rolesRepository;\n }\n\n async execute(id: string, input: UpdateTeamInput): Promise<Result<Team, UpdateTeam.Error>> {\n const hasPermission = await this.identityContext.getPermission(\"security.team\");\n if (!hasPermission) {\n return Result.fail(new NotAuthorizedError());\n }\n\n const validation = updateTeamValidation.safeParse(input);\n if (!validation.success) {\n return Result.fail(new TeamValidationError(validation.error.issues[0].message));\n }\n\n const existingResult = await this.repository.get({ id });\n if (existingResult.isFail()) {\n return Result.fail(existingResult.error);\n }\n\n const existingTeam = existingResult.value;\n\n // Check if team is system team\n if (existingTeam.system) {\n return Result.fail(new CannotUpdateSystemTeamsError());\n }\n\n // Check if team is created via plugin\n if (existingTeam.plugin) {\n return Result.fail(new CannotUpdatePluginTeamsError());\n }\n\n // `description` is pulled out of the spread because it is the one field that accepts null.\n // Normalising it here keeps null out of both the entity and the published events, whose\n // input type declares `description?: string`.\n const { description, ...rest } = validation.data;\n\n const changes: UpdateTeamInput = {\n ...rest,\n ...descriptionOnUpdate(description)\n };\n\n /*\n * Only when the update mentions roles. An update that omits them must leave the stored ones\n * alone, and resolving an absent list would cost a read and write an empty array.\n */\n if (changes.roles) {\n const roleIdsResult = await resolveRoleIdentifiers(this.rolesRepository, changes.roles);\n\n if (roleIdsResult.isFail()) {\n return Result.fail(roleIdsResult.error);\n }\n\n changes.roles = roleIdsResult.value;\n }\n\n const updatedTeam: Team = {\n ...existingTeam,\n ...changes\n };\n\n await this.eventPublisher.publish(\n new TeamBeforeUpdateEvent({\n original: existingTeam,\n updated: updatedTeam,\n input: changes\n })\n );\n\n const result = await this.repository.update(updatedTeam);\n\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new TeamAfterUpdateEvent({\n original: existingTeam,\n updated: updatedTeam,\n input: changes\n })\n );\n\n return Result.ok(updatedTeam);\n }\n}\n\nexport const UpdateTeamUseCaseImpl = createImplementation({\n abstraction: UpdateTeam,\n implementation: UpdateTeamUseCase,\n dependencies: [TeamsRepository, IdentityContext, EventPublisher, RolesRepository]\n});\n"],"names":["UpdateTeamUseCase","repository","identityContext","eventPublisher","rolesRepository","id","input","hasPermission","Result","NotAuthorizedError","validation","updateTeamValidation","TeamValidationError","existingResult","existingTeam","CannotUpdateSystemTeamsError","CannotUpdatePluginTeamsError","description","rest","changes","descriptionOnUpdate","roleIdsResult","resolveRoleIdentifiers","updatedTeam","TeamBeforeUpdateEvent","result","TeamAfterUpdateEvent","UpdateTeamUseCaseImpl","createImplementation","UpdateTeam","TeamsRepository","IdentityContext","EventPublisher","RolesRepository"],"mappings":";;;;;;;;;;;AAmBO,MAAMA;IAMT,YACIC,UAAqC,EACrCC,eAA0C,EAC1CC,cAAwC,EACxCC,eAA0C,CAC5C;QACE,IAAI,CAAC,UAAU,GAAGH;QAClB,IAAI,CAAC,eAAe,GAAGC;QACvB,IAAI,CAAC,cAAc,GAAGC;QACtB,IAAI,CAAC,eAAe,GAAGC;IAC3B;IAEA,MAAM,QAAQC,EAAU,EAAEC,KAAsB,EAA2C;QACvF,MAAMC,gBAAgB,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;QAC/D,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,MAAMC,aAAaC,qBAAqB,SAAS,CAACL;QAClD,IAAI,CAACI,WAAW,OAAO,EACnB,OAAOF,OAAO,IAAI,CAAC,IAAII,oBAAoBF,WAAW,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO;QAGjF,MAAMG,iBAAiB,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAER;QAAG;QACtD,IAAIQ,eAAe,MAAM,IACrB,OAAOL,OAAO,IAAI,CAACK,eAAe,KAAK;QAG3C,MAAMC,eAAeD,eAAe,KAAK;QAGzC,IAAIC,aAAa,MAAM,EACnB,OAAON,OAAO,IAAI,CAAC,IAAIO;QAI3B,IAAID,aAAa,MAAM,EACnB,OAAON,OAAO,IAAI,CAAC,IAAIQ;QAM3B,MAAM,EAAEC,WAAW,EAAE,GAAGC,MAAM,GAAGR,WAAW,IAAI;QAEhD,MAAMS,UAA2B;YAC7B,GAAGD,IAAI;YACP,GAAGE,oBAAoBH,YAAY;QACvC;QAMA,IAAIE,QAAQ,KAAK,EAAE;YACf,MAAME,gBAAgB,MAAMC,uBAAuB,IAAI,CAAC,eAAe,EAAEH,QAAQ,KAAK;YAEtF,IAAIE,cAAc,MAAM,IACpB,OAAOb,OAAO,IAAI,CAACa,cAAc,KAAK;YAG1CF,QAAQ,KAAK,GAAGE,cAAc,KAAK;QACvC;QAEA,MAAME,cAAoB;YACtB,GAAGT,YAAY;YACf,GAAGK,OAAO;QACd;QAEA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIK,sBAAsB;YACtB,UAAUV;YACV,SAASS;YACT,OAAOJ;QACX;QAGJ,MAAMM,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACF;QAE5C,IAAIE,OAAO,MAAM,IACb,OAAOjB,OAAO,IAAI,CAACiB,OAAO,KAAK;QAGnC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,qBAAqB;YACrB,UAAUZ;YACV,SAASS;YACT,OAAOJ;QACX;QAGJ,OAAOX,OAAO,EAAE,CAACe;IACrB;AACJ;AAEO,MAAMI,wBAAwBC,qBAAqB;IACtD,aAAaC;IACb,gBAAgB7B;IAChB,cAAc;QAAC8B;QAAiBC;QAAiBC;QAAgBC;KAAgB;AACrF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const updateTeamValidation: z.ZodObject<{
|
|
3
3
|
name: z.ZodOptional<z.ZodString>;
|
|
4
|
-
description: z.ZodOptional<z.ZodString
|
|
4
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
5
5
|
roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6
6
|
}, z.core.$strip>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
const updateTeamValidation = z.object({
|
|
3
3
|
name: z.string().min(3).optional(),
|
|
4
|
-
description: z.string().max(500).
|
|
4
|
+
description: z.string().max(500).nullish(),
|
|
5
5
|
roles: z.array(z.string()).optional()
|
|
6
6
|
});
|
|
7
7
|
export { updateTeamValidation };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/security/teams/UpdateTeam/schema.js","sources":["../../../../../src/features/security/teams/UpdateTeam/schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const updateTeamValidation = z.object({\n name: z.string().min(3).optional(),\n description: z.string().max(500).
|
|
1
|
+
{"version":3,"file":"features/security/teams/UpdateTeam/schema.js","sources":["../../../../../src/features/security/teams/UpdateTeam/schema.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const updateTeamValidation = z.object({\n name: z.string().min(3).optional(),\n // Nullable in the GraphQL schema - see `descriptionOnUpdate` for why this is `.nullish()` and\n // must not carry a `.transform()`.\n description: z.string().max(500).nullish(),\n roles: z.array(z.string()).optional()\n});\n"],"names":["updateTeamValidation","z"],"mappings":";AAEO,MAAMA,uBAAuBC,EAAE,MAAM,CAAC;IACzC,MAAMA,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG,QAAQ;IAGhC,aAAaA,EAAE,MAAM,GAAG,GAAG,CAAC,KAAK,OAAO;IACxC,OAAOA,EAAE,KAAK,CAACA,EAAE,MAAM,IAAI,QAAQ;AACvC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { RolesRepository } from "../../roles/shared/abstractions.js";
|
|
3
|
+
import { TeamValidationError } from "./errors.js";
|
|
4
|
+
/**
|
|
5
|
+
* Maps whatever a caller used to name a role onto the role IDs a team stores.
|
|
6
|
+
*
|
|
7
|
+
* `team.roles` holds IDs and only IDs: GetPermissionsFromIdentity resolves them with `id_in` against
|
|
8
|
+
* the roles repository. A slug stored here matches nothing, so the team is created, reads correctly
|
|
9
|
+
* in the admin UI, and grants no permissions at all. Nothing previously caught that, because the
|
|
10
|
+
* field is typed `string[]` and the use case wrote it through untouched.
|
|
11
|
+
*
|
|
12
|
+
* Accepting both forms rather than rejecting slugs: which identifier a given field wants is not
|
|
13
|
+
* guessable from the outside, and a few lines away in the same area a team is identified by SLUG
|
|
14
|
+
* (folder permission targets are `team:<slug>`). An identifier that is neither is a genuine mistake
|
|
15
|
+
* and is reported.
|
|
16
|
+
*/
|
|
17
|
+
export declare const resolveRoleIdentifiers: (rolesRepository: RolesRepository.Interface, identifiers: string[]) => Promise<Result<string[], TeamValidationError>>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { TeamValidationError } from "./errors.js";
|
|
3
|
+
const resolveRoleIdentifiers = async (rolesRepository, identifiers)=>{
|
|
4
|
+
if (0 === identifiers.length) return Result.ok([]);
|
|
5
|
+
const rolesResult = await rolesRepository.list({});
|
|
6
|
+
if (rolesResult.isFail()) return Result.fail(new TeamValidationError(`Could not load roles: ${rolesResult.error}`));
|
|
7
|
+
const byId = new Map(rolesResult.value.map((role)=>[
|
|
8
|
+
role.id,
|
|
9
|
+
role.id
|
|
10
|
+
]));
|
|
11
|
+
const bySlug = new Map(rolesResult.value.map((role)=>[
|
|
12
|
+
role.slug,
|
|
13
|
+
role.id
|
|
14
|
+
]));
|
|
15
|
+
const unknown = [];
|
|
16
|
+
const roleIds = identifiers.map((identifier)=>{
|
|
17
|
+
const resolved = byId.get(identifier) ?? bySlug.get(identifier);
|
|
18
|
+
if (!resolved) {
|
|
19
|
+
unknown.push(identifier);
|
|
20
|
+
return identifier;
|
|
21
|
+
}
|
|
22
|
+
return resolved;
|
|
23
|
+
});
|
|
24
|
+
if (unknown.length > 0) {
|
|
25
|
+
const names = unknown.map((identifier)=>`"${identifier}"`).join(", ");
|
|
26
|
+
return Result.fail(new TeamValidationError(`Not a known role id or slug: ${names}.`));
|
|
27
|
+
}
|
|
28
|
+
return Result.ok(roleIds);
|
|
29
|
+
};
|
|
30
|
+
export { resolveRoleIdentifiers };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=resolveRoleIdentifiers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/security/teams/shared/resolveRoleIdentifiers.js","sources":["../../../../../src/features/security/teams/shared/resolveRoleIdentifiers.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { RolesRepository } from \"../../roles/shared/abstractions.js\";\nimport { TeamValidationError } from \"./errors.js\";\n\n/**\n * Maps whatever a caller used to name a role onto the role IDs a team stores.\n *\n * `team.roles` holds IDs and only IDs: GetPermissionsFromIdentity resolves them with `id_in` against\n * the roles repository. A slug stored here matches nothing, so the team is created, reads correctly\n * in the admin UI, and grants no permissions at all. Nothing previously caught that, because the\n * field is typed `string[]` and the use case wrote it through untouched.\n *\n * Accepting both forms rather than rejecting slugs: which identifier a given field wants is not\n * guessable from the outside, and a few lines away in the same area a team is identified by SLUG\n * (folder permission targets are `team:<slug>`). An identifier that is neither is a genuine mistake\n * and is reported.\n */\nexport const resolveRoleIdentifiers = async (\n rolesRepository: RolesRepository.Interface,\n identifiers: string[]\n): Promise<Result<string[], TeamValidationError>> => {\n if (identifiers.length === 0) {\n return Result.ok([]);\n }\n\n /*\n * Every role, in one read. `id_in` and `slug_in` are ANDed by the repository, so they cannot\n * express \"either of these\", and a project has few enough roles for the distinction not to\n * matter. Plugin-defined roles are included, which a filtered query would also have to cover.\n */\n const rolesResult = await rolesRepository.list({});\n\n if (rolesResult.isFail()) {\n return Result.fail(new TeamValidationError(`Could not load roles: ${rolesResult.error}`));\n }\n\n const byId = new Map(rolesResult.value.map(role => [role.id, role.id]));\n const bySlug = new Map(rolesResult.value.map(role => [role.slug, role.id]));\n\n const unknown: string[] = [];\n\n // ID first, so a slug that happens to equal another role's ID cannot shadow it.\n const roleIds = identifiers.map(identifier => {\n const resolved = byId.get(identifier) ?? bySlug.get(identifier);\n\n if (!resolved) {\n unknown.push(identifier);\n return identifier;\n }\n\n return resolved;\n });\n\n if (unknown.length > 0) {\n const names = unknown.map(identifier => `\"${identifier}\"`).join(\", \");\n return Result.fail(new TeamValidationError(`Not a known role id or slug: ${names}.`));\n }\n\n return Result.ok(roleIds);\n};\n"],"names":["resolveRoleIdentifiers","rolesRepository","identifiers","Result","rolesResult","TeamValidationError","byId","Map","role","bySlug","unknown","roleIds","identifier","resolved","names"],"mappings":";;AAiBO,MAAMA,yBAAyB,OAClCC,iBACAC;IAEA,IAAIA,AAAuB,MAAvBA,YAAY,MAAM,EAClB,OAAOC,OAAO,EAAE,CAAC,EAAE;IAQvB,MAAMC,cAAc,MAAMH,gBAAgB,IAAI,CAAC,CAAC;IAEhD,IAAIG,YAAY,MAAM,IAClB,OAAOD,OAAO,IAAI,CAAC,IAAIE,oBAAoB,CAAC,sBAAsB,EAAED,YAAY,KAAK,EAAE;IAG3F,MAAME,OAAO,IAAIC,IAAIH,YAAY,KAAK,CAAC,GAAG,CAACI,CAAAA,OAAQ;YAACA,KAAK,EAAE;YAAEA,KAAK,EAAE;SAAC;IACrE,MAAMC,SAAS,IAAIF,IAAIH,YAAY,KAAK,CAAC,GAAG,CAACI,CAAAA,OAAQ;YAACA,KAAK,IAAI;YAAEA,KAAK,EAAE;SAAC;IAEzE,MAAME,UAAoB,EAAE;IAG5B,MAAMC,UAAUT,YAAY,GAAG,CAACU,CAAAA;QAC5B,MAAMC,WAAWP,KAAK,GAAG,CAACM,eAAeH,OAAO,GAAG,CAACG;QAEpD,IAAI,CAACC,UAAU;YACXH,QAAQ,IAAI,CAACE;YACb,OAAOA;QACX;QAEA,OAAOC;IACX;IAEA,IAAIH,QAAQ,MAAM,GAAG,GAAG;QACpB,MAAMI,QAAQJ,QAAQ,GAAG,CAACE,CAAAA,aAAc,CAAC,CAAC,EAAEA,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC;QAChE,OAAOT,OAAO,IAAI,CAAC,IAAIE,oBAAoB,CAAC,6BAA6B,EAAES,MAAM,CAAC,CAAC;IACvF;IAEA,OAAOX,OAAO,EAAE,CAACQ;AACrB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Slugify } from "./abstractions.js";
|
|
2
|
+
declare class DefaultSlugifyImpl implements Slugify.Interface {
|
|
3
|
+
execute(value: string): string;
|
|
4
|
+
}
|
|
5
|
+
export declare const DefaultSlugify: typeof DefaultSlugifyImpl & {
|
|
6
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ISlugify>;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import slugify from "slugify";
|
|
2
|
+
import { Slugify } from "./abstractions.js";
|
|
3
|
+
const DEFAULT_OPTIONS = {
|
|
4
|
+
replacement: "-",
|
|
5
|
+
lower: true,
|
|
6
|
+
remove: /[*#?<>_{}[\]+~.()'"!:;@]/g,
|
|
7
|
+
trim: false
|
|
8
|
+
};
|
|
9
|
+
class DefaultSlugifyImpl {
|
|
10
|
+
execute(value) {
|
|
11
|
+
return slugify(value, DEFAULT_OPTIONS);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const DefaultSlugify = Slugify.createImplementation({
|
|
15
|
+
implementation: DefaultSlugifyImpl,
|
|
16
|
+
dependencies: []
|
|
17
|
+
});
|
|
18
|
+
export { DefaultSlugify };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=DefaultSlugify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/slugify/DefaultSlugify.js","sources":["../../../src/features/slugify/DefaultSlugify.ts"],"sourcesContent":["import baseSlugify from \"slugify\";\nimport { Slugify } from \"./abstractions.js\";\n\n/**\n * Webiny's canonical slug options. These were previously duplicated at every call site; keeping them\n * in one private place means projects can change slug generation everywhere at once by decorating\n * Slugify — not by passing per-call options, so the abstraction stays independent of this library.\n */\nconst DEFAULT_OPTIONS = {\n replacement: \"-\",\n lower: true,\n remove: /[*#?<>_{}[\\]+~.()'\"!:;@]/g,\n trim: false\n};\n\nclass DefaultSlugifyImpl implements Slugify.Interface {\n execute(value: string): string {\n return baseSlugify(value, DEFAULT_OPTIONS);\n }\n}\n\nexport const DefaultSlugify = Slugify.createImplementation({\n implementation: DefaultSlugifyImpl,\n dependencies: []\n});\n"],"names":["DEFAULT_OPTIONS","DefaultSlugifyImpl","value","baseSlugify","DefaultSlugify","Slugify"],"mappings":";;AAQA,MAAMA,kBAAkB;IACpB,aAAa;IACb,OAAO;IACP,QAAQ;IACR,MAAM;AACV;AAEA,MAAMC;IACF,QAAQC,KAAa,EAAU;QAC3B,OAAOC,QAAYD,OAAOF;IAC9B;AACJ;AAEO,MAAMI,iBAAiBC,QAAQ,oBAAoB,CAAC;IACvD,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ISlugify {
|
|
2
|
+
/**
|
|
3
|
+
* Turns a value into a URL-friendly slug using Webiny's canonical options. This is the
|
|
4
|
+
* fine-grained seam behind `StringFormatter.slugify()` — decorate `Slugify` alone to change slug
|
|
5
|
+
* logic without touching the rest of the string formatter.
|
|
6
|
+
*/
|
|
7
|
+
execute(value: string): string;
|
|
8
|
+
}
|
|
9
|
+
export declare const Slugify: import("@webiny/di").Abstraction<ISlugify>;
|
|
10
|
+
export declare namespace Slugify {
|
|
11
|
+
type Interface = ISlugify;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/slugify/abstractions.js","sources":["../../../src/features/slugify/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface ISlugify {\n /**\n * Turns a value into a URL-friendly slug using Webiny's canonical options. This is the\n * fine-grained seam behind `StringFormatter.slugify()` — decorate `Slugify` alone to change slug\n * logic without touching the rest of the string formatter.\n */\n execute(value: string): string;\n}\n\nexport const Slugify = createAbstraction<ISlugify>(\"Slugify\");\n\nexport namespace Slugify {\n export type Interface = ISlugify;\n}\n"],"names":["Slugify","createAbstraction"],"mappings":";AAWO,MAAMA,UAAUC,kBAA4B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { DefaultSlugify } from "./DefaultSlugify.js";
|
|
3
|
+
const SlugifyFeature = createFeature({
|
|
4
|
+
name: "SlugifyFeature",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(DefaultSlugify);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { SlugifyFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/slugify/feature.js","sources":["../../../src/features/slugify/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { DefaultSlugify } from \"./DefaultSlugify.js\";\n\nexport const SlugifyFeature = createFeature({\n name: \"SlugifyFeature\",\n register(container) {\n container.register(DefaultSlugify);\n }\n});\n"],"names":["SlugifyFeature","createFeature","container","DefaultSlugify"],"mappings":";;AAGO,MAAMA,iBAAiBC,cAAc;IACxC,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Container } from "@webiny/di";
|
|
2
|
+
import type { ApiCoreStorageOperations } from "../../types/core.js";
|
|
3
|
+
/**
|
|
4
|
+
* Builds the api-core storage operations. Resolved + built synchronously inside
|
|
5
|
+
* ApiCoreFeature.register, so storage is wired the same way for every event — there is no
|
|
6
|
+
* out-of-feature construction or per-request async initializer. The concrete implementation is
|
|
7
|
+
* provided by a storage adapter (ApiCoreDdbFeature / ApiCoreSqlFeature) or, in tests, by
|
|
8
|
+
* registerApiCoreStorageOperations.
|
|
9
|
+
*/
|
|
10
|
+
export interface IApiCoreStorageOperationsFactory {
|
|
11
|
+
create(): ApiCoreStorageOperations;
|
|
12
|
+
}
|
|
13
|
+
export declare const ApiCoreStorageOperationsFactory: import("@webiny/di").Abstraction<IApiCoreStorageOperationsFactory>;
|
|
14
|
+
export declare namespace ApiCoreStorageOperationsFactory {
|
|
15
|
+
type Interface = IApiCoreStorageOperationsFactory;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Register pre-built storage operations as the factory. Used by tests (and anywhere the ops are
|
|
19
|
+
* already constructed) so ApiCoreFeature.register can resolve them like any adapter-provided factory.
|
|
20
|
+
*/
|
|
21
|
+
export declare const registerApiCoreStorageOperations: (container: Container, storageOperations: ApiCoreStorageOperations) => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
const ApiCoreStorageOperationsFactory = createAbstraction("ApiCoreStorageOperationsFactory");
|
|
3
|
+
const registerApiCoreStorageOperations = (container, storageOperations)=>{
|
|
4
|
+
container.registerInstance(ApiCoreStorageOperationsFactory, {
|
|
5
|
+
create: ()=>storageOperations
|
|
6
|
+
});
|
|
7
|
+
};
|
|
8
|
+
export { ApiCoreStorageOperationsFactory, registerApiCoreStorageOperations };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/storageOperations/abstractions.js","sources":["../../../src/features/storageOperations/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Container } from \"@webiny/di\";\nimport type { ApiCoreStorageOperations } from \"~/types/core.js\";\n\n/**\n * Builds the api-core storage operations. Resolved + built synchronously inside\n * ApiCoreFeature.register, so storage is wired the same way for every event — there is no\n * out-of-feature construction or per-request async initializer. The concrete implementation is\n * provided by a storage adapter (ApiCoreDdbFeature / ApiCoreSqlFeature) or, in tests, by\n * registerApiCoreStorageOperations.\n */\nexport interface IApiCoreStorageOperationsFactory {\n create(): ApiCoreStorageOperations;\n}\n\nexport const ApiCoreStorageOperationsFactory = createAbstraction<IApiCoreStorageOperationsFactory>(\n \"ApiCoreStorageOperationsFactory\"\n);\n\nexport namespace ApiCoreStorageOperationsFactory {\n export type Interface = IApiCoreStorageOperationsFactory;\n}\n\n/**\n * Register pre-built storage operations as the factory. Used by tests (and anywhere the ops are\n * already constructed) so ApiCoreFeature.register can resolve them like any adapter-provided factory.\n */\nexport const registerApiCoreStorageOperations = (\n container: Container,\n storageOperations: ApiCoreStorageOperations\n): void => {\n container.registerInstance(ApiCoreStorageOperationsFactory, {\n create: () => storageOperations\n });\n};\n"],"names":["ApiCoreStorageOperationsFactory","createAbstraction","registerApiCoreStorageOperations","container","storageOperations"],"mappings":";AAeO,MAAMA,kCAAkCC,kBAC3C;AAWG,MAAMC,mCAAmC,CAC5CC,WACAC;IAEAD,UAAU,gBAAgB,CAACH,iCAAiC;QACxD,QAAQ,IAAMI;IAClB;AACJ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Slugify } from "../../features/slugify/abstractions.js";
|
|
2
|
+
import { StringFormatter } from "./abstractions.js";
|
|
3
|
+
/**
|
|
4
|
+
* The string formatter is the consumer-facing API for string transforms. It keeps each transform's
|
|
5
|
+
* logic in its own fine-grained, decoratable feature (e.g. `Slugify`) and just delegates to it, so a
|
|
6
|
+
* project can change one transform without reimplementing the whole formatter. More methods will be
|
|
7
|
+
* added here over time.
|
|
8
|
+
*/
|
|
9
|
+
declare class DefaultStringFormatterImpl implements StringFormatter.Interface {
|
|
10
|
+
private readonly slugifier;
|
|
11
|
+
constructor(slugifier: Slugify.Interface);
|
|
12
|
+
slugify(value: string): string;
|
|
13
|
+
}
|
|
14
|
+
export declare const DefaultStringFormatter: typeof DefaultStringFormatterImpl & {
|
|
15
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IStringFormatter>;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Slugify } from "../slugify/abstractions.js";
|
|
2
|
+
import { StringFormatter } from "./abstractions.js";
|
|
3
|
+
class DefaultStringFormatterImpl {
|
|
4
|
+
constructor(slugifier){
|
|
5
|
+
this.slugifier = slugifier;
|
|
6
|
+
}
|
|
7
|
+
slugify(value) {
|
|
8
|
+
return this.slugifier.execute(value);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const DefaultStringFormatter = StringFormatter.createImplementation({
|
|
12
|
+
implementation: DefaultStringFormatterImpl,
|
|
13
|
+
dependencies: [
|
|
14
|
+
Slugify
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
export { DefaultStringFormatter };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=DefaultStringFormatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/stringFormatter/DefaultStringFormatter.js","sources":["../../../src/features/stringFormatter/DefaultStringFormatter.ts"],"sourcesContent":["import { Slugify } from \"~/features/slugify/abstractions.js\";\nimport { StringFormatter } from \"./abstractions.js\";\n\n/**\n * The string formatter is the consumer-facing API for string transforms. It keeps each transform's\n * logic in its own fine-grained, decoratable feature (e.g. `Slugify`) and just delegates to it, so a\n * project can change one transform without reimplementing the whole formatter. More methods will be\n * added here over time.\n */\nclass DefaultStringFormatterImpl implements StringFormatter.Interface {\n constructor(private readonly slugifier: Slugify.Interface) {}\n\n slugify(value: string): string {\n return this.slugifier.execute(value);\n }\n}\n\nexport const DefaultStringFormatter = StringFormatter.createImplementation({\n implementation: DefaultStringFormatterImpl,\n dependencies: [Slugify]\n});\n"],"names":["DefaultStringFormatterImpl","slugifier","value","DefaultStringFormatter","StringFormatter","Slugify"],"mappings":";;AASA,MAAMA;IACF,YAA6BC,SAA4B,CAAE;aAA9BA,SAAS,GAATA;IAA+B;IAE5D,QAAQC,KAAa,EAAU;QAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAACA;IAClC;AACJ;AAEO,MAAMC,yBAAyBC,gBAAgB,oBAAoB,CAAC;IACvE,gBAAgBJ;IAChB,cAAc;QAACK;KAAQ;AAC3B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface IStringFormatter {
|
|
2
|
+
/**
|
|
3
|
+
* Turns a value into a URL-friendly slug. Delegates to the `Slugify` feature, so to change slug
|
|
4
|
+
* logic decorate `Slugify` alone rather than the whole string formatter.
|
|
5
|
+
*/
|
|
6
|
+
slugify(value: string): string;
|
|
7
|
+
}
|
|
8
|
+
export declare const StringFormatter: import("@webiny/di").Abstraction<IStringFormatter>;
|
|
9
|
+
export declare namespace StringFormatter {
|
|
10
|
+
type Interface = IStringFormatter;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/stringFormatter/abstractions.js","sources":["../../../src/features/stringFormatter/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface IStringFormatter {\n /**\n * Turns a value into a URL-friendly slug. Delegates to the `Slugify` feature, so to change slug\n * logic decorate `Slugify` alone rather than the whole string formatter.\n */\n slugify(value: string): string;\n}\n\nexport const StringFormatter = createAbstraction<IStringFormatter>(\"StringFormatter\");\n\nexport namespace StringFormatter {\n export type Interface = IStringFormatter;\n}\n"],"names":["StringFormatter","createAbstraction"],"mappings":";AAUO,MAAMA,kBAAkBC,kBAAoC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { SlugifyFeature } from "../slugify/feature.js";
|
|
3
|
+
import { DefaultStringFormatter } from "./DefaultStringFormatter.js";
|
|
4
|
+
const StringFormatterFeature = createFeature({
|
|
5
|
+
name: "StringFormatterFeature",
|
|
6
|
+
register (container) {
|
|
7
|
+
SlugifyFeature.register(container);
|
|
8
|
+
container.register(DefaultStringFormatter);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
export { StringFormatterFeature };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/stringFormatter/feature.js","sources":["../../../src/features/stringFormatter/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { SlugifyFeature } from \"~/features/slugify/feature.js\";\nimport { DefaultStringFormatter } from \"./DefaultStringFormatter.js\";\n\nexport const StringFormatterFeature = createFeature({\n name: \"StringFormatterFeature\",\n register(container) {\n // Register the transforms the formatter delegates to, then the formatter itself.\n SlugifyFeature.register(container);\n container.register(DefaultStringFormatter);\n }\n});\n"],"names":["StringFormatterFeature","createFeature","container","SlugifyFeature","DefaultStringFormatter"],"mappings":";;;AAIO,MAAMA,yBAAyBC,cAAc;IAChD,MAAM;IACN,UAASC,SAAS;QAEdC,eAAe,QAAQ,CAACD;QACxBA,UAAU,QAAQ,CAACE;IACvB;AACJ"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import zod from "zod";
|
|
2
|
+
import type { Constructor } from "@webiny/di";
|
|
2
3
|
import type { GenericRecord } from "@webiny/api/types";
|
|
3
4
|
import type { ITask } from "../../../features/task/TaskService/index.js";
|
|
4
5
|
import { TaskController } from "../../../features/task/TaskController/index.js";
|
|
@@ -14,12 +15,34 @@ export interface ITaskOutput {
|
|
|
14
15
|
[key: string]: any;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* The task's own definition, minus its behaviour.
|
|
19
|
+
*
|
|
20
|
+
* Handed to `run()` and to every lifecycle hook so a decorator can tell which task it is wrapping
|
|
21
|
+
* and act on the definition's own fields. A decorator is registered against the abstraction, so it
|
|
22
|
+
* wraps every task; without this it has nothing to branch on but a hardcoded list of ids, which
|
|
23
|
+
* means editing the decorator every time a task is added.
|
|
24
|
+
*
|
|
25
|
+
* This is {@link ITaskMetadata}: identity and policy, no behaviour and no handler pointer. The
|
|
26
|
+
* object passed at runtime is the resolved task, so `run` is physically present; naming the metadata
|
|
27
|
+
* type here stops the obvious mistake of a handler calling `params.definition.run(...)` and
|
|
28
|
+
* recursing forever.
|
|
29
|
+
*
|
|
30
|
+
* Only the fields declared here arrive. A field a project adds to its own definition class is
|
|
31
|
+
* currently dropped, because `TaskDefinitionDefaultsDecorator` is a fixed pass-through that
|
|
32
|
+
* exposes a known set of getters and nothing else. Making them forward unknown
|
|
33
|
+
* properties would turn a definition into a place to declare policy (a rate limit, a set of tags)
|
|
34
|
+
* that a decorator acts on; `taskDefinitionInParams.test.ts` pins the current behaviour so that
|
|
35
|
+
* change announces itself.
|
|
36
|
+
*/
|
|
37
|
+
export type ITaskDefinitionInfo = ITaskMetadata;
|
|
38
|
+
/**
|
|
39
|
+
* Task run params - the input data, plus the definition being run
|
|
18
40
|
* All runtime dependencies come from TaskController (injected separately)
|
|
19
41
|
*/
|
|
20
42
|
export interface ITaskRunParams<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> {
|
|
21
43
|
input: I;
|
|
22
44
|
controller: TaskController.Interface<I, O>;
|
|
45
|
+
definition: ITaskDefinitionInfo;
|
|
23
46
|
}
|
|
24
47
|
/**
|
|
25
48
|
* Data for creating a new task
|
|
@@ -35,6 +58,7 @@ export interface ITaskCreateData<I = ITaskInput> {
|
|
|
35
58
|
*/
|
|
36
59
|
export interface ITaskBeforeTriggerParams<I = ITaskInput> {
|
|
37
60
|
data: ITaskCreateData<I>;
|
|
61
|
+
definition: ITaskDefinitionInfo;
|
|
38
62
|
}
|
|
39
63
|
/**
|
|
40
64
|
* Task result status enum
|
|
@@ -70,11 +94,16 @@ export type ISelfCleanupEvent = "onSuccess" | "onError" | "onAbort";
|
|
|
70
94
|
export type ISelfCleanup = "always" | "never" | ISelfCleanupEvent | ISelfCleanupEvent[];
|
|
71
95
|
export type ITaskLifecycleHook<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = {
|
|
72
96
|
task: ITask<I, O>;
|
|
97
|
+
definition: ITaskDefinitionInfo;
|
|
73
98
|
};
|
|
74
99
|
/**
|
|
75
|
-
*
|
|
100
|
+
* What a task IS: identity and runtime policy, with no behaviour and no dependencies.
|
|
101
|
+
*
|
|
102
|
+
* Listing tasks, resolving one by id, and applying defaults all need only this. Keeping it free of
|
|
103
|
+
* dependencies is the whole point — `GetRunnableTaskDefinitionUseCase` builds every registered definition
|
|
104
|
+
* to find one by id, so anything expensive here is paid 24 times per lookup.
|
|
76
105
|
*/
|
|
77
|
-
export interface
|
|
106
|
+
export interface ITaskMetadata {
|
|
78
107
|
id: string;
|
|
79
108
|
title: string;
|
|
80
109
|
description?: string;
|
|
@@ -82,6 +111,16 @@ export interface ITaskDefinition<I extends ITaskInput = ITaskInput, O extends IT
|
|
|
82
111
|
databaseLogs?: boolean;
|
|
83
112
|
isPrivate?: boolean;
|
|
84
113
|
selfCleanup?: ISelfCleanup;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* What a task DOES. This is the half that carries dependencies (a CMS context, an OpenSearch
|
|
117
|
+
* client), so it is built only for the task actually being run.
|
|
118
|
+
*
|
|
119
|
+
* The lifecycle hooks live here rather than on {@link ITaskMetadata} because they need the same
|
|
120
|
+
* dependencies `run()` does — see `MockDataManagerTask`, whose `onError` and `onAbort` both use the
|
|
121
|
+
* OpenSearch client injected for `run()`.
|
|
122
|
+
*/
|
|
123
|
+
export interface ITaskHandler<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> {
|
|
85
124
|
/**
|
|
86
125
|
* Core run method - receives ONLY input params
|
|
87
126
|
* All runtime dependencies (logging, state management, etc.) come from TaskController
|
|
@@ -101,23 +140,48 @@ export interface ITaskDefinition<I extends ITaskInput = ITaskInput, O extends IT
|
|
|
101
140
|
*/
|
|
102
141
|
createInputValidation?(params: ITaskCreateInputValidationParams): GenericRecord<keyof I, zod.Schema> | zod.Schema;
|
|
103
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* What you register: a task's {@link ITaskMetadata} plus the class that does the work.
|
|
145
|
+
*
|
|
146
|
+
* The definition takes no dependencies of its own, so `GetRunnableTaskDefinitionUseCase` can build every
|
|
147
|
+
* registered one to find a task by id without constructing anything expensive. Only the winner's
|
|
148
|
+
* `handler` gets built.
|
|
149
|
+
*/
|
|
150
|
+
export interface ITaskDefinition<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> extends ITaskMetadata {
|
|
151
|
+
handler: Constructor<ITaskHandler<I, O>>;
|
|
152
|
+
}
|
|
104
153
|
export interface ITaskCreateInputValidationParams {
|
|
105
154
|
validator: typeof zod;
|
|
106
155
|
}
|
|
107
156
|
/** Define a long-running background task with lifecycle hooks. */
|
|
108
157
|
export declare const TaskDefinition: import("@webiny/di").Abstraction<ITaskDefinition<ITaskInput, ITaskOutput>>;
|
|
158
|
+
/**
|
|
159
|
+
* The behaviour half of a task, resolved on demand by the runner via
|
|
160
|
+
* `container.resolveImplementation(definition.handler)`. Registered implementations are NOT
|
|
161
|
+
* registered against this abstraction — the definition points at the class directly, exactly as
|
|
162
|
+
* `HttpRouteDefinition` points at its `HttpRouteHandler`.
|
|
163
|
+
*/
|
|
164
|
+
export declare const TaskHandler: import("@webiny/di").Abstraction<ITaskHandler<ITaskInput, ITaskOutput>>;
|
|
109
165
|
/**
|
|
110
166
|
* IRunnableTaskDefinition represents a TaskDefinition after decoration/processing.
|
|
111
167
|
* All optional runtime properties are guaranteed to have values (with defaults applied).
|
|
112
168
|
* Used internally by the task runner to ensure consistent behavior.
|
|
113
169
|
*/
|
|
114
|
-
export interface IRunnableTaskDefinition<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> extends
|
|
170
|
+
export interface IRunnableTaskDefinition<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> extends ITaskMetadata, ITaskHandler<I, O> {
|
|
115
171
|
isPrivate: boolean;
|
|
116
172
|
databaseLogs: boolean;
|
|
117
173
|
maxIterations: number;
|
|
118
174
|
}
|
|
175
|
+
export declare namespace TaskHandler {
|
|
176
|
+
type Interface<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskHandler<I, O>;
|
|
177
|
+
type RunParams<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskRunParams<I, O>;
|
|
178
|
+
type Result<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskResult<I, O>;
|
|
179
|
+
type LifecycleHookParams<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskLifecycleHook<I, O>;
|
|
180
|
+
}
|
|
119
181
|
export declare namespace TaskDefinition {
|
|
120
182
|
type Interface<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskDefinition<I, O>;
|
|
183
|
+
type Metadata = ITaskMetadata;
|
|
184
|
+
type Handler<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskHandler<I, O>;
|
|
121
185
|
type TaskInput = ITaskInput;
|
|
122
186
|
type TaskOutput = ITaskOutput;
|
|
123
187
|
type Runnable<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = IRunnableTaskDefinition<I, O>;
|
|
@@ -132,6 +196,7 @@ export declare namespace TaskDefinition {
|
|
|
132
196
|
type TaskCreateData<I = ITaskInput> = ITaskCreateData<I>;
|
|
133
197
|
type BeforeTriggerParams<I = ITaskInput> = ITaskBeforeTriggerParams<I>;
|
|
134
198
|
type LifecycleHookParams<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskLifecycleHook<I, O>;
|
|
199
|
+
type Info = ITaskDefinitionInfo;
|
|
135
200
|
type SelfCleanupEvent = ISelfCleanupEvent;
|
|
136
201
|
type SelfCleanup = ISelfCleanup;
|
|
137
202
|
}
|
|
@@ -7,6 +7,7 @@ var abstractions_TaskResultStatus = /*#__PURE__*/ function(TaskResultStatus) {
|
|
|
7
7
|
return TaskResultStatus;
|
|
8
8
|
}({});
|
|
9
9
|
const TaskDefinition = createAbstraction("TaskDefinition");
|
|
10
|
-
|
|
10
|
+
const TaskHandler = createAbstraction("TaskHandler");
|
|
11
|
+
export { TaskDefinition, TaskHandler, abstractions_TaskResultStatus as TaskResultStatus };
|
|
11
12
|
|
|
12
13
|
//# sourceMappingURL=abstractions.js.map
|