@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,12 +1,11 @@
|
|
|
1
|
-
import { ErrorResponse, Response } from "@webiny/
|
|
2
|
-
import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js";
|
|
1
|
+
import { ErrorResponse, Response } from "@webiny/api-graphql/responses.js";
|
|
3
2
|
import { CreateApiKeyUseCase } from "../../features/security/apiKeys/CreateApiKey/index.js";
|
|
4
3
|
import { UpdateApiKeyUseCase } from "../../features/security/apiKeys/UpdateApiKey/index.js";
|
|
5
4
|
import { DeleteApiKeyUseCase } from "../../features/security/apiKeys/DeleteApiKey/index.js";
|
|
6
5
|
import { ListApiKeysUseCase } from "../../features/security/apiKeys/ListApiKeys/index.js";
|
|
7
6
|
import { GetApiKeyUseCase } from "../../features/security/apiKeys/GetApiKey/index.js";
|
|
8
|
-
const
|
|
9
|
-
|
|
7
|
+
const addApiKeySchema = (builder)=>{
|
|
8
|
+
builder.addTypeDefs(`
|
|
10
9
|
type SecurityApiKey {
|
|
11
10
|
id: ID
|
|
12
11
|
name: String
|
|
@@ -47,44 +46,63 @@ const apiKey_gql = new GraphQLSchemaPlugin({
|
|
|
47
46
|
updateApiKey(id: ID!, data: SecurityApiKeyInput!): SecurityApiKeyResponse
|
|
48
47
|
deleteApiKey(id: ID!): SecurityBooleanResponse
|
|
49
48
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
`);
|
|
50
|
+
builder.addResolver({
|
|
51
|
+
path: "SecurityQuery.listApiKeys",
|
|
52
|
+
dependencies: [
|
|
53
|
+
ListApiKeysUseCase
|
|
54
|
+
],
|
|
55
|
+
resolver: (list)=>async ()=>{
|
|
55
56
|
const result = await list.execute();
|
|
56
57
|
if (result.isOk()) return new Response(result.value);
|
|
57
58
|
return new ErrorResponse(result.error);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
builder.addResolver({
|
|
62
|
+
path: "SecurityQuery.getApiKey",
|
|
63
|
+
dependencies: [
|
|
64
|
+
GetApiKeyUseCase
|
|
65
|
+
],
|
|
66
|
+
resolver: (getById)=>async ({ args })=>{
|
|
61
67
|
const result = await getById.execute(args.id);
|
|
62
68
|
if (result.isOk()) return new Response(result.value);
|
|
63
69
|
return new ErrorResponse(result.error);
|
|
64
70
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
});
|
|
72
|
+
builder.addResolver({
|
|
73
|
+
path: "SecurityMutation.createApiKey",
|
|
74
|
+
dependencies: [
|
|
75
|
+
CreateApiKeyUseCase
|
|
76
|
+
],
|
|
77
|
+
resolver: (createApiKey)=>async ({ args })=>{
|
|
69
78
|
const result = await createApiKey.execute(args.data);
|
|
70
79
|
if (result.isOk()) return new Response(result.value);
|
|
71
80
|
return new ErrorResponse(result.error);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
builder.addResolver({
|
|
84
|
+
path: "SecurityMutation.updateApiKey",
|
|
85
|
+
dependencies: [
|
|
86
|
+
UpdateApiKeyUseCase
|
|
87
|
+
],
|
|
88
|
+
resolver: (updateApiKey)=>async ({ args })=>{
|
|
75
89
|
const result = await updateApiKey.execute(args.id, args.data);
|
|
76
90
|
if (result.isOk()) return new Response(result.value);
|
|
77
91
|
return new ErrorResponse(result.error);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
builder.addResolver({
|
|
95
|
+
path: "SecurityMutation.deleteApiKey",
|
|
96
|
+
dependencies: [
|
|
97
|
+
DeleteApiKeyUseCase
|
|
98
|
+
],
|
|
99
|
+
resolver: (deleteApiKey)=>async ({ args })=>{
|
|
81
100
|
const result = await deleteApiKey.execute(args.id);
|
|
82
101
|
if (result.isOk()) return new Response(true);
|
|
83
102
|
return new ErrorResponse(result.error);
|
|
84
103
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
export default apiKey_gql;
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
export { addApiKeySchema };
|
|
89
107
|
|
|
90
|
-
//# sourceMappingURL=
|
|
108
|
+
//# sourceMappingURL=addApiKeySchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/security/addApiKeySchema.js","sources":["../../../src/graphql/security/addApiKeySchema.ts"],"sourcesContent":["import { Response, ErrorResponse } from \"@webiny/api-graphql/responses.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { CreateApiKeyUseCase } from \"~/features/security/apiKeys/CreateApiKey/index.js\";\nimport { UpdateApiKeyUseCase } from \"~/features/security/apiKeys/UpdateApiKey/index.js\";\nimport { DeleteApiKeyUseCase } from \"~/features/security/apiKeys/DeleteApiKey/index.js\";\nimport { ListApiKeysUseCase } from \"~/features/security/apiKeys/ListApiKeys/index.js\";\nimport { GetApiKeyUseCase } from \"~/features/security/apiKeys/GetApiKey/index.js\";\n\nexport const addApiKeySchema = (builder: IGraphQLSchemaBuilder): void => {\n builder.addTypeDefs(/* GraphQL */ `\n type SecurityApiKey {\n id: ID\n name: String\n slug: String\n description: String\n token: String\n permissions: [JSON]\n createdOn: DateTime\n createdBy: SecurityCreatedBy\n }\n\n input SecurityApiKeyInput {\n id: ID\n name: String!\n slug: String\n description: String\n token: String\n permissions: [JSON]!\n }\n\n type SecurityApiKeyResponse {\n data: SecurityApiKey\n error: SecurityError\n }\n\n type SecurityApiKeyListResponse {\n data: [SecurityApiKey!]\n error: SecurityError\n }\n\n extend type SecurityQuery {\n listApiKeys: SecurityApiKeyListResponse\n getApiKey(id: ID!): SecurityApiKeyResponse\n }\n\n extend type SecurityMutation {\n createApiKey(data: SecurityApiKeyInput!): SecurityApiKeyResponse\n updateApiKey(id: ID!, data: SecurityApiKeyInput!): SecurityApiKeyResponse\n deleteApiKey(id: ID!): SecurityBooleanResponse\n }\n `);\n\n builder.addResolver({\n path: \"SecurityQuery.listApiKeys\",\n dependencies: [ListApiKeysUseCase],\n resolver: (list: ListApiKeysUseCase.Interface) => async () => {\n const result = await list.execute();\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n }\n });\n\n builder.addResolver<{ id: string }>({\n path: \"SecurityQuery.getApiKey\",\n dependencies: [GetApiKeyUseCase],\n resolver:\n (getById: GetApiKeyUseCase.Interface) =>\n async ({ args }) => {\n const result = await getById.execute(args.id);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n }\n });\n\n builder.addResolver<{ data: any }>({\n path: \"SecurityMutation.createApiKey\",\n dependencies: [CreateApiKeyUseCase],\n resolver:\n (createApiKey: CreateApiKeyUseCase.Interface) =>\n async ({ args }) => {\n const result = await createApiKey.execute(args.data);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n }\n });\n\n builder.addResolver<{ id: string; data: any }>({\n path: \"SecurityMutation.updateApiKey\",\n dependencies: [UpdateApiKeyUseCase],\n resolver:\n (updateApiKey: UpdateApiKeyUseCase.Interface) =>\n async ({ args }) => {\n const result = await updateApiKey.execute(args.id, args.data);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n }\n });\n\n builder.addResolver<{ id: string }>({\n path: \"SecurityMutation.deleteApiKey\",\n dependencies: [DeleteApiKeyUseCase],\n resolver:\n (deleteApiKey: DeleteApiKeyUseCase.Interface) =>\n async ({ args }) => {\n const result = await deleteApiKey.execute(args.id);\n\n if (result.isOk()) {\n return new Response(true);\n }\n return new ErrorResponse(result.error);\n }\n });\n};\n"],"names":["addApiKeySchema","builder","ListApiKeysUseCase","list","result","Response","ErrorResponse","GetApiKeyUseCase","getById","args","CreateApiKeyUseCase","createApiKey","UpdateApiKeyUseCase","updateApiKey","DeleteApiKeyUseCase","deleteApiKey"],"mappings":";;;;;;AAQO,MAAMA,kBAAkB,CAACC;IAC5BA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;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QACnC,UACI,CAACC,eACD,OAAO,EAAEN,IAAI,EAAE;gBACX,MAAML,SAAS,MAAMW,aAAa,OAAO,CAACN,KAAK,EAAE;gBAEjD,IAAIL,OAAO,IAAI,IACX,OAAO,IAAIC,SAAS;gBAExB,OAAO,IAAIC,cAAcF,OAAO,KAAK;YACzC;IACR;AACJ"}
|
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ErrorResponse, Response } from "@webiny/handler-graphql";
|
|
1
|
+
import { ErrorResponse, Response } from "@webiny/api-graphql";
|
|
3
2
|
import { EventPublisher } from "../../features/eventPublisher/index.js";
|
|
4
3
|
import { AfterLoginEvent } from "../../features/security/login/index.js";
|
|
5
4
|
import { GetIdentityProfileUseCase } from "../../features/users/GetIdentityProfile/index.js";
|
|
6
5
|
import { TeamsRepository } from "../../features/security/teams/shared/abstractions.js";
|
|
7
6
|
import { RolesRepository } from "../../features/security/roles/shared/abstractions.js";
|
|
8
7
|
import { IdentityContext } from "../../features/security/IdentityContext/index.js";
|
|
8
|
+
import { TenantContext } from "../../features/tenancy/TenantContext/index.js";
|
|
9
|
+
import { GetTenantByIdUseCase } from "../../features/tenancy/GetTenantById/index.js";
|
|
10
|
+
import { GetRootTenantUseCase } from "../../features/tenancy/GetRootTenant/index.js";
|
|
9
11
|
import { ProfileMapper } from "./ProfileMapper.js";
|
|
10
|
-
const getDefaultTenant = async (
|
|
11
|
-
const identity =
|
|
12
|
+
const getDefaultTenant = async (identityContext, getTenantById, getRootTenant)=>{
|
|
13
|
+
const identity = identityContext.getIdentity();
|
|
12
14
|
const defaultTenantId = identity.context.defaultTenantId ?? "root";
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
15
|
-
|
|
15
|
+
const tenantResult = await getTenantById.execute(defaultTenantId);
|
|
16
|
+
if (tenantResult.isOk()) return tenantResult.value;
|
|
17
|
+
const rootResult = await getRootTenant.execute();
|
|
18
|
+
if (rootResult.isFail()) throw rootResult.error;
|
|
19
|
+
return rootResult.value;
|
|
16
20
|
};
|
|
17
|
-
const
|
|
18
|
-
|
|
21
|
+
const addIdentitySchema = (builder)=>{
|
|
22
|
+
builder.addTypeDefs(`
|
|
19
23
|
type SecurityIdentityTenant {
|
|
20
24
|
id: ID!
|
|
21
25
|
name: String!
|
|
@@ -62,28 +66,30 @@ const identity_gql = new GraphQLSchemaPlugin({
|
|
|
62
66
|
"Login using idToken obtained from a 3rd party identity provider"
|
|
63
67
|
login: SecurityIdentityLoginResponse
|
|
64
68
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
`);
|
|
70
|
+
builder.addResolver({
|
|
71
|
+
path: "SecurityMutation.login",
|
|
72
|
+
dependencies: [
|
|
73
|
+
IdentityContext,
|
|
74
|
+
EventPublisher,
|
|
75
|
+
RolesRepository,
|
|
76
|
+
TeamsRepository,
|
|
77
|
+
GetIdentityProfileUseCase
|
|
78
|
+
],
|
|
79
|
+
resolver: (identityContext, eventPublisher, rolesRepo, teamsRepo, getProfile)=>async ()=>{
|
|
70
80
|
const identity = identityContext.getIdentity();
|
|
71
81
|
if (identity.isAnonymous()) return new ErrorResponse({
|
|
72
82
|
code: "Security/Identity/NotAuthenticated",
|
|
73
83
|
message: "Unauthenticated!"
|
|
74
84
|
});
|
|
75
85
|
try {
|
|
76
|
-
const eventPublisher = context.container.resolve(EventPublisher);
|
|
77
86
|
await eventPublisher.publish(new AfterLoginEvent({
|
|
78
87
|
identity
|
|
79
88
|
}));
|
|
80
89
|
} catch (err) {
|
|
81
90
|
return new ErrorResponse(err);
|
|
82
91
|
}
|
|
83
|
-
const
|
|
84
|
-
const teamsRepo = context.container.resolve(TeamsRepository);
|
|
85
|
-
const getProfile = context.container.resolve(GetIdentityProfileUseCase);
|
|
86
|
-
const result = await context.security.withoutAuthorization(async ()=>getProfile.execute(identity.id));
|
|
92
|
+
const result = await identityContext.withoutAuthorization(async ()=>getProfile.execute(identity.id));
|
|
87
93
|
if (result.isFail()) return new ErrorResponse({
|
|
88
94
|
code: "Security/Identity/NotAuthorized",
|
|
89
95
|
message: "Missing user profile!"
|
|
@@ -102,20 +108,31 @@ const identity_gql = new GraphQLSchemaPlugin({
|
|
|
102
108
|
teams
|
|
103
109
|
});
|
|
104
110
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
});
|
|
112
|
+
builder.addResolver({
|
|
113
|
+
path: "SecurityIdentity.defaultTenant",
|
|
114
|
+
dependencies: [
|
|
115
|
+
IdentityContext,
|
|
116
|
+
GetTenantByIdUseCase,
|
|
117
|
+
GetRootTenantUseCase
|
|
118
|
+
],
|
|
119
|
+
resolver: (identityContext, getTenantById, getRootTenant)=>()=>getDefaultTenant(identityContext, getTenantById, getRootTenant)
|
|
120
|
+
});
|
|
121
|
+
builder.addResolver({
|
|
122
|
+
path: "SecurityIdentity.currentTenant",
|
|
123
|
+
dependencies: [
|
|
124
|
+
TenantContext
|
|
125
|
+
],
|
|
126
|
+
resolver: (tenantContext)=>()=>tenantContext.getTenant()
|
|
127
|
+
});
|
|
128
|
+
builder.addResolver({
|
|
129
|
+
path: "SecurityIdentity.permissions",
|
|
130
|
+
dependencies: [
|
|
131
|
+
IdentityContext
|
|
132
|
+
],
|
|
133
|
+
resolver: (identityContext)=>()=>identityContext.listPermissions()
|
|
134
|
+
});
|
|
135
|
+
};
|
|
119
136
|
const getRoles = async (user, rolesRepo)=>{
|
|
120
137
|
const roleIds = user.roles ?? [];
|
|
121
138
|
if (roleIds.length > 0) {
|
|
@@ -148,6 +165,6 @@ const getTeams = async (user, teamsRepo)=>{
|
|
|
148
165
|
}
|
|
149
166
|
return [];
|
|
150
167
|
};
|
|
151
|
-
export
|
|
168
|
+
export { addIdentitySchema };
|
|
152
169
|
|
|
153
|
-
//# sourceMappingURL=
|
|
170
|
+
//# sourceMappingURL=addIdentitySchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/security/addIdentitySchema.js","sources":["../../../src/graphql/security/addIdentitySchema.ts"],"sourcesContent":["import type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { ErrorResponse, Response } from \"@webiny/api-graphql\";\nimport { EventPublisher } from \"~/features/eventPublisher/index.js\";\nimport { AfterLoginEvent } from \"~/features/security/login/index.js\";\nimport { GetIdentityProfileUseCase } from \"~/features/users/GetIdentityProfile/index.js\";\nimport type { AdminUser } from \"~/types/users.js\";\nimport { TeamsRepository } from \"~/features/security/teams/shared/abstractions.js\";\nimport { RolesRepository } from \"~/features/security/roles/shared/abstractions.js\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/index.js\";\nimport { TenantContext } from \"~/features/tenancy/TenantContext/index.js\";\nimport { GetTenantByIdUseCase } from \"~/features/tenancy/GetTenantById/index.js\";\nimport { GetRootTenantUseCase } from \"~/features/tenancy/GetRootTenant/index.js\";\nimport { ProfileMapper } from \"./ProfileMapper.js\";\n\nconst getDefaultTenant = async (\n identityContext: IdentityContext.Interface,\n getTenantById: GetTenantByIdUseCase.Interface,\n getRootTenant: GetRootTenantUseCase.Interface\n) => {\n const identity = identityContext.getIdentity();\n const defaultTenantId = identity.context.defaultTenantId ?? \"root\";\n\n const tenantResult = await getTenantById.execute(defaultTenantId);\n if (tenantResult.isOk()) {\n return tenantResult.value;\n }\n\n const rootResult = await getRootTenant.execute();\n if (rootResult.isFail()) {\n throw rootResult.error;\n }\n return rootResult.value;\n};\n\nexport const addIdentitySchema = (builder: IGraphQLSchemaBuilder): void => {\n builder.addTypeDefs(/* GraphQL */ `\n type SecurityIdentityTenant {\n id: ID!\n name: String!\n }\n type SecurityIdentityProfileRole {\n id: String!\n slug: String!\n name: String!\n }\n\n type SecurityIdentityProfileTeam {\n id: String!\n slug: String!\n name: String!\n }\n\n type SecurityIdentityProfile {\n firstName: String\n lastName: String\n email: String\n avatar: JSON\n external: Boolean!\n createdOn: DateTime!\n }\n\n type SecurityIdentity {\n id: ID!\n type: String!\n displayName: String!\n roles: [SecurityIdentityProfileRole!]!\n teams: [SecurityIdentityProfileTeam!]!\n permissions: [JSON!]!\n profile: SecurityIdentityProfile!\n currentTenant: SecurityIdentityTenant!\n defaultTenant: SecurityIdentityTenant!\n }\n\n type SecurityIdentityLoginResponse {\n data: SecurityIdentity\n error: SecurityError\n }\n\n extend type SecurityMutation {\n \"Login using idToken obtained from a 3rd party identity provider\"\n login: SecurityIdentityLoginResponse\n }\n `);\n\n builder.addResolver({\n path: \"SecurityMutation.login\",\n dependencies: [\n IdentityContext,\n EventPublisher,\n RolesRepository,\n TeamsRepository,\n GetIdentityProfileUseCase\n ],\n resolver:\n (\n identityContext: IdentityContext.Interface,\n eventPublisher: EventPublisher.Interface,\n rolesRepo: RolesRepository.Interface,\n teamsRepo: TeamsRepository.Interface,\n getProfile: GetIdentityProfileUseCase.Interface\n ) =>\n async () => {\n const identity = identityContext.getIdentity();\n if (identity.isAnonymous()) {\n return new ErrorResponse({\n code: \"Security/Identity/NotAuthenticated\",\n message: \"Unauthenticated!\"\n });\n }\n\n try {\n await eventPublisher.publish(new AfterLoginEvent({ identity }));\n } catch (err) {\n return new ErrorResponse(err);\n }\n\n const result = await identityContext.withoutAuthorization(async () => {\n return getProfile.execute(identity.id);\n });\n\n if (result.isFail()) {\n return new ErrorResponse({\n code: \"Security/Identity/NotAuthorized\",\n message: \"Missing user profile!\"\n });\n }\n\n const user = result.value;\n\n const [roles, teams] = await Promise.all([\n getRoles(user, rolesRepo),\n getTeams(user, teamsRepo)\n ]);\n\n const profileMapper = new ProfileMapper();\n const profile = await profileMapper.toDTO(user);\n\n return new Response({\n ...identity.toJson(),\n profile,\n roles,\n teams\n });\n }\n });\n\n builder.addResolver({\n path: \"SecurityIdentity.defaultTenant\",\n dependencies: [IdentityContext, GetTenantByIdUseCase, GetRootTenantUseCase],\n resolver:\n (\n identityContext: IdentityContext.Interface,\n getTenantById: GetTenantByIdUseCase.Interface,\n getRootTenant: GetRootTenantUseCase.Interface\n ) =>\n () =>\n getDefaultTenant(identityContext, getTenantById, getRootTenant)\n });\n\n builder.addResolver({\n path: \"SecurityIdentity.currentTenant\",\n dependencies: [TenantContext],\n resolver: (tenantContext: TenantContext.Interface) => () => tenantContext.getTenant()\n });\n\n builder.addResolver({\n path: \"SecurityIdentity.permissions\",\n dependencies: [IdentityContext],\n resolver: (identityContext: IdentityContext.Interface) => () =>\n identityContext.listPermissions()\n });\n};\n\nconst getRoles = async (user: AdminUser, rolesRepo: RolesRepository.Interface) => {\n const roleIds = user.roles ?? [];\n if (roleIds.length > 0) {\n const result = await rolesRepo.list({\n where: { id_in: roleIds }\n });\n\n if (result.isOk()) {\n return result.value.map(role => ({\n id: role.id,\n slug: role.slug,\n name: role.name\n }));\n }\n }\n\n return [];\n};\n\nconst getTeams = async (user: AdminUser, teamsRepo: TeamsRepository.Interface) => {\n const teamIds = user.teams ?? [];\n if (teamIds.length > 0) {\n const result = await teamsRepo.list({\n where: { id_in: teamIds }\n });\n if (result.isOk()) {\n return result.value.map(team => ({\n id: team.id,\n slug: team.slug,\n name: team.name\n }));\n }\n }\n return [];\n};\n"],"names":["getDefaultTenant","identityContext","getTenantById","getRootTenant","identity","defaultTenantId","tenantResult","rootResult","addIdentitySchema","builder","IdentityContext","EventPublisher","RolesRepository","TeamsRepository","GetIdentityProfileUseCase","eventPublisher","rolesRepo","teamsRepo","getProfile","ErrorResponse","AfterLoginEvent","err","result","user","roles","teams","Promise","getRoles","getTeams","profileMapper","ProfileMapper","profile","Response","GetTenantByIdUseCase","GetRootTenantUseCase","TenantContext","tenantContext","roleIds","role","teamIds","team"],"mappings":";;;;;;;;;;;AAcA,MAAMA,mBAAmB,OACrBC,iBACAC,eACAC;IAEA,MAAMC,WAAWH,gBAAgB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gBACf,MAAMA,KAAK,IAAI;YACnB;IAER;IACA,OAAO,EAAE;AACb"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { ErrorResponse, ListErrorResponse, ListResponse, Response } from "@webiny/api-graphql/responses.js";
|
|
2
|
+
import { GetRoleUseCase } from "../../features/security/roles/GetRole/index.js";
|
|
3
|
+
import { ListRolesUseCase } from "../../features/security/roles/ListRoles/index.js";
|
|
4
|
+
import { CreateRoleUseCase } from "../../features/security/roles/CreateRole/index.js";
|
|
5
|
+
import { UpdateRoleUseCase } from "../../features/security/roles/UpdateRole/index.js";
|
|
6
|
+
import { DeleteRoleUseCase } from "../../features/security/roles/DeleteRole/index.js";
|
|
7
|
+
const addRoleSchema = (builder)=>{
|
|
8
|
+
builder.addTypeDefs(`
|
|
9
|
+
type SecurityRole {
|
|
10
|
+
id: ID
|
|
11
|
+
name: String
|
|
12
|
+
slug: String
|
|
13
|
+
createdOn: DateTime
|
|
14
|
+
description: String
|
|
15
|
+
permissions: [JSON]
|
|
16
|
+
system: Boolean!
|
|
17
|
+
plugin: Boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
input SecurityRoleCreateInput {
|
|
21
|
+
name: String!
|
|
22
|
+
slug: String!
|
|
23
|
+
description: String
|
|
24
|
+
permissions: [JSON!]!
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
input SecurityRoleUpdateInput {
|
|
28
|
+
name: String
|
|
29
|
+
description: String
|
|
30
|
+
permissions: [JSON!]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type SecurityRoleResponse {
|
|
34
|
+
data: SecurityRole
|
|
35
|
+
error: SecurityError
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type SecurityRoleListResponse {
|
|
39
|
+
data: [SecurityRole]
|
|
40
|
+
error: SecurityError
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
input GetRoleWhereInput {
|
|
44
|
+
id: ID
|
|
45
|
+
slug: String
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
extend type SecurityQuery {
|
|
49
|
+
getRole(where: GetRoleWhereInput!): SecurityRoleResponse
|
|
50
|
+
listRoles: SecurityRoleListResponse
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
extend type SecurityMutation {
|
|
54
|
+
createRole(data: SecurityRoleCreateInput!): SecurityRoleResponse
|
|
55
|
+
updateRole(id: ID!, data: SecurityRoleUpdateInput!): SecurityRoleResponse
|
|
56
|
+
deleteRole(id: ID!): SecurityBooleanResponse
|
|
57
|
+
}
|
|
58
|
+
`);
|
|
59
|
+
builder.addResolver({
|
|
60
|
+
path: "SecurityQuery.getRole",
|
|
61
|
+
dependencies: [
|
|
62
|
+
GetRoleUseCase
|
|
63
|
+
],
|
|
64
|
+
resolver: (useCase)=>async ({ args })=>{
|
|
65
|
+
try {
|
|
66
|
+
const result = await useCase.execute(args.where);
|
|
67
|
+
if (result.isFail()) throw result.error;
|
|
68
|
+
return new Response(result.value);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
return new ErrorResponse(e);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
builder.addResolver({
|
|
75
|
+
path: "SecurityQuery.listRoles",
|
|
76
|
+
dependencies: [
|
|
77
|
+
ListRolesUseCase
|
|
78
|
+
],
|
|
79
|
+
resolver: (useCase)=>async ()=>{
|
|
80
|
+
try {
|
|
81
|
+
const result = await useCase.execute();
|
|
82
|
+
if (result.isFail()) throw result.error;
|
|
83
|
+
return new ListResponse(result.value);
|
|
84
|
+
} catch (e) {
|
|
85
|
+
return new ListErrorResponse(e);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
builder.addResolver({
|
|
90
|
+
path: "SecurityMutation.createRole",
|
|
91
|
+
dependencies: [
|
|
92
|
+
CreateRoleUseCase
|
|
93
|
+
],
|
|
94
|
+
resolver: (useCase)=>async ({ args })=>{
|
|
95
|
+
try {
|
|
96
|
+
const result = await useCase.execute(args.data);
|
|
97
|
+
if (result.isFail()) throw result.error;
|
|
98
|
+
return new Response(result.value);
|
|
99
|
+
} catch (e) {
|
|
100
|
+
return new ErrorResponse(e);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
builder.addResolver({
|
|
105
|
+
path: "SecurityMutation.updateRole",
|
|
106
|
+
dependencies: [
|
|
107
|
+
UpdateRoleUseCase
|
|
108
|
+
],
|
|
109
|
+
resolver: (useCase)=>async ({ args })=>{
|
|
110
|
+
try {
|
|
111
|
+
const result = await useCase.execute(args.id, args.data);
|
|
112
|
+
if (result.isFail()) throw result.error;
|
|
113
|
+
return new Response(result.value);
|
|
114
|
+
} catch (e) {
|
|
115
|
+
return new ErrorResponse(e);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
builder.addResolver({
|
|
120
|
+
path: "SecurityMutation.deleteRole",
|
|
121
|
+
dependencies: [
|
|
122
|
+
DeleteRoleUseCase
|
|
123
|
+
],
|
|
124
|
+
resolver: (useCase)=>async ({ args })=>{
|
|
125
|
+
try {
|
|
126
|
+
const result = await useCase.execute(args.id);
|
|
127
|
+
if (result.isFail()) throw result.error;
|
|
128
|
+
return new Response(true);
|
|
129
|
+
} catch (e) {
|
|
130
|
+
return new ErrorResponse(e);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
export { addRoleSchema };
|
|
136
|
+
|
|
137
|
+
//# sourceMappingURL=addRoleSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/security/addRoleSchema.js","sources":["../../../src/graphql/security/addRoleSchema.ts"],"sourcesContent":["import {\n ErrorResponse,\n ListErrorResponse,\n ListResponse,\n Response\n} from \"@webiny/api-graphql/responses.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { GetRoleUseCase } from \"~/features/security/roles/GetRole/index.js\";\nimport { ListRolesUseCase } from \"~/features/security/roles/ListRoles/index.js\";\nimport { CreateRoleUseCase } from \"~/features/security/roles/CreateRole/index.js\";\nimport { UpdateRoleUseCase } from \"~/features/security/roles/UpdateRole/index.js\";\nimport { DeleteRoleUseCase } from \"~/features/security/roles/DeleteRole/index.js\";\n\nexport const addRoleSchema = (builder: IGraphQLSchemaBuilder): void => {\n builder.addTypeDefs(/* GraphQL */ `\n type SecurityRole {\n id: ID\n name: String\n slug: String\n createdOn: DateTime\n description: String\n permissions: [JSON]\n system: Boolean!\n plugin: Boolean\n }\n\n input SecurityRoleCreateInput {\n name: String!\n slug: String!\n description: String\n permissions: [JSON!]!\n }\n\n input SecurityRoleUpdateInput {\n name: String\n description: String\n permissions: [JSON!]\n }\n\n type SecurityRoleResponse {\n data: SecurityRole\n error: SecurityError\n }\n\n type SecurityRoleListResponse {\n data: [SecurityRole]\n error: SecurityError\n }\n\n input GetRoleWhereInput {\n id: ID\n slug: String\n }\n\n extend type SecurityQuery {\n getRole(where: GetRoleWhereInput!): SecurityRoleResponse\n listRoles: SecurityRoleListResponse\n }\n\n extend type SecurityMutation {\n createRole(data: SecurityRoleCreateInput!): SecurityRoleResponse\n updateRole(id: ID!, data: SecurityRoleUpdateInput!): SecurityRoleResponse\n deleteRole(id: ID!): SecurityBooleanResponse\n }\n `);\n\n builder.addResolver<{ where: any }>({\n path: \"SecurityQuery.getRole\",\n dependencies: [GetRoleUseCase],\n resolver:\n (useCase: GetRoleUseCase.Interface) =>\n async ({ args }) => {\n try {\n const result = await useCase.execute(args.where);\n if (result.isFail()) {\n throw result.error;\n }\n return new Response(result.value);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n });\n\n builder.addResolver({\n path: \"SecurityQuery.listRoles\",\n dependencies: [ListRolesUseCase],\n resolver: (useCase: ListRolesUseCase.Interface) => async () => {\n try {\n const result = await useCase.execute();\n if (result.isFail()) {\n throw result.error;\n }\n return new ListResponse(result.value);\n } catch (e) {\n return new ListErrorResponse(e);\n }\n }\n });\n\n builder.addResolver<{ data: any }>({\n path: \"SecurityMutation.createRole\",\n dependencies: [CreateRoleUseCase],\n resolver:\n (useCase: CreateRoleUseCase.Interface) =>\n async ({ args }) => {\n try {\n const result = await useCase.execute(args.data);\n if (result.isFail()) {\n throw result.error;\n }\n return new Response(result.value);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n });\n\n builder.addResolver<{ id: string; data: any }>({\n path: \"SecurityMutation.updateRole\",\n dependencies: [UpdateRoleUseCase],\n resolver:\n (useCase: UpdateRoleUseCase.Interface) =>\n async ({ args }) => {\n try {\n const result = await useCase.execute(args.id, args.data);\n if (result.isFail()) {\n throw result.error;\n }\n return new Response(result.value);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n });\n\n builder.addResolver<{ id: string }>({\n path: \"SecurityMutation.deleteRole\",\n dependencies: [DeleteRoleUseCase],\n resolver:\n (useCase: DeleteRoleUseCase.Interface) =>\n async ({ args }) => {\n try {\n const result = await useCase.execute(args.id);\n if (result.isFail()) {\n throw result.error;\n }\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n });\n};\n"],"names":["addRoleSchema","builder","GetRoleUseCase","useCase","args","result","Response","e","ErrorResponse","ListRolesUseCase","ListResponse","ListErrorResponse","CreateRoleUseCase","UpdateRoleUseCase","DeleteRoleUseCase"],"mappings":";;;;;;AAaO,MAAMA,gBAAgB,CAACC;IAC1BA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkDnC,CAAC;IAEDA,QAAQ,WAAW,CAAiB;QAChC,MAAM;QACN,cAAc;YAACC;SAAe;QAC9B,UACI,CAACC,UACD,OAAO,EAAEC,IAAI,EAAE;gBACX,IAAI;oBACA,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAACC,KAAK,KAAK;oBAC/C,IAAIC,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;oB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AAE;gBACX,IAAI;oBACA,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAACC,KAAK,EAAE;oBAC5C,IAAIC,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;oBAEtB,OAAO,IAAIC,SAAS;gBACxB,EAAE,OAAOC,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;IACR;AACJ"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const base_gql = new GraphQLSchemaPlugin({
|
|
4
|
-
typeDefs: `
|
|
1
|
+
const addSecurityBaseSchema = (builder)=>{
|
|
2
|
+
builder.addTypeDefs(`
|
|
5
3
|
type SecurityMutation {
|
|
6
4
|
_empty: String
|
|
7
5
|
}
|
|
@@ -34,16 +32,16 @@ const base_gql = new GraphQLSchemaPlugin({
|
|
|
34
32
|
data: Boolean
|
|
35
33
|
error: SecurityError
|
|
36
34
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export
|
|
35
|
+
`);
|
|
36
|
+
builder.addResolver({
|
|
37
|
+
path: "Query.security",
|
|
38
|
+
resolver: ()=>async ()=>({})
|
|
39
|
+
});
|
|
40
|
+
builder.addResolver({
|
|
41
|
+
path: "Mutation.security",
|
|
42
|
+
resolver: ()=>async ()=>({})
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
export { addSecurityBaseSchema };
|
|
48
46
|
|
|
49
|
-
//# sourceMappingURL=
|
|
47
|
+
//# sourceMappingURL=addSecurityBaseSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/security/addSecurityBaseSchema.js","sources":["../../../src/graphql/security/addSecurityBaseSchema.ts"],"sourcesContent":["import type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\n\nexport const addSecurityBaseSchema = (builder: IGraphQLSchemaBuilder): void => {\n builder.addTypeDefs(/* GraphQL */ `\n type SecurityMutation {\n _empty: String\n }\n\n type SecurityQuery {\n _empty: String\n }\n\n extend type Query {\n security: SecurityQuery\n }\n\n extend type Mutation {\n security: SecurityMutation\n }\n\n type SecurityCreatedBy {\n id: ID\n displayName: String\n }\n\n type SecurityError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type SecurityBooleanResponse {\n data: Boolean\n error: SecurityError\n }\n `);\n\n builder.addResolver({\n path: \"Query.security\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"Mutation.security\",\n resolver: () => async () => ({})\n });\n};\n"],"names":["addSecurityBaseSchema","builder"],"mappings":"AAEO,MAAMA,wBAAwB,CAACC;IAClCA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAiCnC,CAAC;IAEDA,QAAQ,WAAW,CAAC;QAChB,MAAM;QACN,UAAU,IAAM,UAAa,EAAC;IAClC;IAEAA,QAAQ,WAAW,CAAC;QAChB,MAAM;QACN,UAAU,IAAM,UAAa,EAAC;IAClC;AACJ"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { ErrorResponse, ListErrorResponse, ListResponse, Response } from "@webiny/api-graphql/responses.js";
|
|
2
|
+
import { ListRolesUseCase } from "../../features/security/roles/ListRoles/index.js";
|
|
3
|
+
import { GetTeamUseCase } from "../../features/security/teams/GetTeam/index.js";
|
|
4
|
+
import { ListTeamsUseCase } from "../../features/security/teams/ListTeams/index.js";
|
|
5
|
+
import { CreateTeam } from "../../features/security/teams/CreateTeam/index.js";
|
|
6
|
+
import { UpdateTeam } from "../../features/security/teams/UpdateTeam/index.js";
|
|
7
|
+
import { DeleteTeam } from "../../features/security/teams/DeleteTeam/index.js";
|
|
8
|
+
const addTeamSchema = (builder)=>{
|
|
9
|
+
builder.addTypeDefs(`
|
|
10
|
+
type SecurityTeam {
|
|
11
|
+
id: ID
|
|
12
|
+
name: String
|
|
13
|
+
slug: String
|
|
14
|
+
createdOn: DateTime
|
|
15
|
+
description: String
|
|
16
|
+
roles: [SecurityRole]
|
|
17
|
+
system: Boolean!
|
|
18
|
+
plugin: Boolean
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
input SecurityTeamCreateInput {
|
|
22
|
+
name: String!
|
|
23
|
+
slug: String!
|
|
24
|
+
description: String
|
|
25
|
+
roles: [RefInput!]!
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
input SecurityTeamUpdateInput {
|
|
29
|
+
name: String
|
|
30
|
+
description: String
|
|
31
|
+
roles: [RefInput!]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type SecurityTeamResponse {
|
|
35
|
+
data: SecurityTeam
|
|
36
|
+
error: SecurityError
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type SecurityTeamListResponse {
|
|
40
|
+
data: [SecurityTeam]
|
|
41
|
+
error: SecurityError
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
input GetTeamWhereInput {
|
|
45
|
+
id: ID
|
|
46
|
+
slug: String
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
extend type SecurityQuery {
|
|
50
|
+
getTeam(where: GetTeamWhereInput!): SecurityTeamResponse
|
|
51
|
+
listTeams: SecurityTeamListResponse
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
extend type SecurityMutation {
|
|
55
|
+
createTeam(data: SecurityTeamCreateInput!): SecurityTeamResponse
|
|
56
|
+
updateTeam(id: ID!, data: SecurityTeamUpdateInput!): SecurityTeamResponse
|
|
57
|
+
deleteTeam(id: ID!): SecurityBooleanResponse
|
|
58
|
+
}
|
|
59
|
+
`);
|
|
60
|
+
builder.addResolver({
|
|
61
|
+
path: "SecurityTeam.roles",
|
|
62
|
+
dependencies: [
|
|
63
|
+
ListRolesUseCase
|
|
64
|
+
],
|
|
65
|
+
resolver: (useCase)=>async ({ parent })=>{
|
|
66
|
+
try {
|
|
67
|
+
const result = await useCase.execute({
|
|
68
|
+
where: {
|
|
69
|
+
id_in: parent.roles
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
if (result.isFail()) throw result.error;
|
|
73
|
+
return result.value;
|
|
74
|
+
} catch (e) {
|
|
75
|
+
return new ErrorResponse(e);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
builder.addResolver({
|
|
80
|
+
path: "SecurityQuery.getTeam",
|
|
81
|
+
dependencies: [
|
|
82
|
+
GetTeamUseCase
|
|
83
|
+
],
|
|
84
|
+
resolver: (useCase)=>async ({ args })=>{
|
|
85
|
+
try {
|
|
86
|
+
const result = await useCase.execute(args.where);
|
|
87
|
+
if (result.isFail()) throw result.error;
|
|
88
|
+
return new Response(result.value);
|
|
89
|
+
} catch (e) {
|
|
90
|
+
return new ErrorResponse(e);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
builder.addResolver({
|
|
95
|
+
path: "SecurityQuery.listTeams",
|
|
96
|
+
dependencies: [
|
|
97
|
+
ListTeamsUseCase
|
|
98
|
+
],
|
|
99
|
+
resolver: (useCase)=>async ()=>{
|
|
100
|
+
try {
|
|
101
|
+
const result = await useCase.execute();
|
|
102
|
+
if (result.isFail()) throw result.error;
|
|
103
|
+
return new ListResponse(result.value);
|
|
104
|
+
} catch (e) {
|
|
105
|
+
return new ListErrorResponse(e);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
builder.addResolver({
|
|
110
|
+
path: "SecurityMutation.createTeam",
|
|
111
|
+
dependencies: [
|
|
112
|
+
CreateTeam
|
|
113
|
+
],
|
|
114
|
+
resolver: (useCase)=>async ({ args })=>{
|
|
115
|
+
try {
|
|
116
|
+
const result = await useCase.execute(args.data);
|
|
117
|
+
if (result.isFail()) throw result.error;
|
|
118
|
+
return new Response(result.value);
|
|
119
|
+
} catch (e) {
|
|
120
|
+
return new ErrorResponse(e);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
builder.addResolver({
|
|
125
|
+
path: "SecurityMutation.updateTeam",
|
|
126
|
+
dependencies: [
|
|
127
|
+
UpdateTeam
|
|
128
|
+
],
|
|
129
|
+
resolver: (useCase)=>async ({ args })=>{
|
|
130
|
+
try {
|
|
131
|
+
const result = await useCase.execute(args.id, args.data);
|
|
132
|
+
if (result.isFail()) throw result.error;
|
|
133
|
+
return new Response(result.value);
|
|
134
|
+
} catch (e) {
|
|
135
|
+
return new ErrorResponse(e);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
builder.addResolver({
|
|
140
|
+
path: "SecurityMutation.deleteTeam",
|
|
141
|
+
dependencies: [
|
|
142
|
+
DeleteTeam
|
|
143
|
+
],
|
|
144
|
+
resolver: (useCase)=>async ({ args })=>{
|
|
145
|
+
try {
|
|
146
|
+
const result = await useCase.execute(args.id);
|
|
147
|
+
if (result.isFail()) throw result.error;
|
|
148
|
+
return new Response(true);
|
|
149
|
+
} catch (e) {
|
|
150
|
+
return new ErrorResponse(e);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
export { addTeamSchema };
|
|
156
|
+
|
|
157
|
+
//# sourceMappingURL=addTeamSchema.js.map
|