@webiny/api-core 6.4.11 → 6.6.0-alpha.1
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 +29 -5
- package/ApiCoreFeature.js.map +1 -1
- package/exports/api/security/api-key.d.ts +1 -0
- package/exports/api/security/api-key.js +1 -0
- package/exports/api.d.ts +3 -1
- package/exports/api.js +2 -1
- package/features/ai/Ai.d.ts +3 -3
- package/features/ai/Ai.js +60 -23
- package/features/ai/Ai.js.map +1 -1
- package/features/ai/AnthropicSdkFactory.js +12 -0
- package/features/ai/AnthropicSdkFactory.js.map +1 -1
- package/features/ai/OpenAiSdkFactory.js +16 -0
- package/features/ai/OpenAiSdkFactory.js.map +1 -1
- package/features/ai/TextExtractor/DefaultTextExtractor.d.ts +9 -0
- package/features/ai/TextExtractor/DefaultTextExtractor.js +28 -0
- package/features/ai/TextExtractor/DefaultTextExtractor.js.map +1 -0
- package/features/ai/TextExtractor/abstractions.d.ts +12 -0
- package/features/ai/TextExtractor/abstractions.js +5 -0
- package/features/ai/TextExtractor/abstractions.js.map +1 -0
- package/features/ai/TextExtractor/index.d.ts +3 -0
- package/features/ai/TextExtractor/index.js +2 -0
- package/features/ai/TextExtractor/parsers/docxParser.d.ts +1 -0
- package/features/ai/TextExtractor/parsers/docxParser.js +111 -0
- package/features/ai/TextExtractor/parsers/docxParser.js.map +1 -0
- package/features/ai/abstractions.d.ts +18 -7
- package/features/ai/abstractions.js +1 -2
- package/features/ai/abstractions.js.map +1 -1
- package/features/ai/events.d.ts +59 -0
- package/features/ai/events.js +41 -0
- package/features/ai/events.js.map +1 -0
- package/features/ai/feature.js +6 -2
- package/features/ai/feature.js.map +1 -1
- package/features/ai/index.d.ts +8 -2
- package/features/ai/index.js +4 -1
- package/features/ai/toolPipeline/AiOutputToolRegistry.d.ts +11 -0
- package/features/ai/toolPipeline/AiOutputToolRegistry.js +31 -0
- package/features/ai/toolPipeline/AiOutputToolRegistry.js.map +1 -0
- package/features/ai/toolPipeline/AiToolPipelineRunner.d.ts +10 -0
- package/features/ai/toolPipeline/AiToolPipelineRunner.js +36 -0
- package/features/ai/toolPipeline/AiToolPipelineRunner.js.map +1 -0
- package/features/ai/toolPipeline/abstractions.d.ts +23 -0
- package/features/ai/toolPipeline/abstractions.js +7 -0
- package/features/ai/toolPipeline/abstractions.js.map +1 -0
- package/features/ai/toolPipeline/index.d.ts +2 -0
- package/features/ai/toolPipeline/index.js +1 -0
- 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/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +49 -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/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 +53 -0
- package/features/requestContext/abstractions.js +8 -0
- package/features/requestContext/abstractions.js.map +1 -0
- package/features/requestContext/feature.d.ts +11 -0
- package/features/requestContext/feature.js +17 -0
- package/features/requestContext/feature.js.map +1 -0
- package/features/requestContext/index.d.ts +2 -0
- package/features/requestContext/index.js +2 -0
- package/features/security/IdentityContext/IdentityContext.d.ts +3 -3
- package/features/security/IdentityContext/IdentityContext.js +6 -6
- package/features/security/IdentityContext/IdentityContext.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/GetApiKey/GetApiKeyUseCase.d.ts +1 -1
- package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -3
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.d.ts +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -3
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.d.ts +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.js.map +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 +11 -2
- package/features/security/apiKeys/feature.js.map +1 -1
- package/features/security/apiKeys/shared/ApiKeyProvider.d.ts +3 -5
- package/features/security/apiKeys/shared/ApiKeyProvider.js +6 -21
- package/features/security/apiKeys/shared/ApiKeyProvider.js.map +1 -1
- package/features/security/apiKeys/shared/ApiKeysRepository.d.ts +1 -0
- package/features/security/apiKeys/shared/ApiKeysRepository.js +19 -4
- package/features/security/apiKeys/shared/ApiKeysRepository.js.map +1 -1
- package/features/security/apiKeys/shared/generateToken.d.ts +1 -1
- package/features/security/apiKeys/shared/generateToken.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/apiKeys/shared/types.d.ts +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +4 -4
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.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/Installer/RolesInstaller.js +0 -1
- package/features/security/roles/Installer/RolesInstaller.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/security/utils/getPermissionsFromRoles.d.ts +1 -1
- package/features/serviceDiscovery/ServiceDiscovery.d.ts +17 -0
- package/features/serviceDiscovery/ServiceDiscovery.js +22 -0
- package/features/serviceDiscovery/ServiceDiscovery.js.map +1 -0
- package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.d.ts +1 -0
- package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.js +111 -0
- package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.js.map +1 -0
- package/features/serviceDiscovery/index.d.ts +3 -0
- package/features/serviceDiscovery/index.js +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 +76 -4
- package/features/task/TaskDefinition/abstractions.js +2 -1
- package/features/task/TaskDefinition/abstractions.js.map +1 -1
- package/features/tenancy/CreateTenant/CreateTenantUseCase.d.ts +1 -1
- package/features/tenancy/InstallTenant/InstallTenantUseCase.d.ts +1 -1
- package/features/tenancy/UpdateTenant/UpdateTenantUseCase.d.ts +2 -2
- package/features/users/CreateUser/decorators/CreateUserWithWcpIncrement.d.ts +1 -1
- package/features/wcp/WcpContext/WcpContext.d.ts +10 -5
- package/features/wcp/WcpContext/WcpContext.js +23 -2
- package/features/wcp/WcpContext/WcpContext.js.map +1 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +25 -7
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +57 -25
- 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 +15 -0
- package/graphql/ApiCoreSchemaFactory.js +52 -0
- package/graphql/ApiCoreSchemaFactory.js.map +1 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +9 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +49 -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 +14 -0
- package/graphql/security/SecuritySchemaFactory.js +23 -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 +9 -0
- package/graphql/system/SystemSchemaFactory.js +66 -0
- package/graphql/system/SystemSchemaFactory.js.map +1 -0
- package/graphql/users/UsersSchemaFactory.d.ts +9 -0
- package/graphql/users/UsersSchemaFactory.js +191 -0
- package/graphql/users/UsersSchemaFactory.js.map +1 -0
- package/graphql/wcp/WcpSchemaFactory.d.ts +9 -0
- package/graphql/wcp/{graphql.js → WcpSchemaFactory.js} +28 -18
- package/graphql/wcp/WcpSchemaFactory.js.map +1 -0
- package/index.d.ts +3 -1
- package/index.js +3 -1
- package/package.json +21 -24
- 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 +1 -7
- package/types/tenancy.d.ts +0 -17
- package/types/users.d.ts +0 -13
- package/createApiCore.d.ts +0 -7
- package/createApiCore.js +0 -22
- package/createApiCore.js.map +0 -1
- package/features/ai/AiModelRegistry.d.ts +0 -12
- package/features/ai/AiModelRegistry.js +0 -28
- package/features/ai/AiModelRegistry.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 -33
- package/legacy/wcp/LegacyWcpContext.js +0 -84
- 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,119 +0,0 @@
|
|
|
1
|
-
import { ErrorResponse, ListErrorResponse, ListResponse, Response } from "@webiny/handler-graphql/responses.js";
|
|
2
|
-
import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js";
|
|
3
|
-
const team_gql = new GraphQLSchemaPlugin({
|
|
4
|
-
typeDefs: `
|
|
5
|
-
type SecurityTeam {
|
|
6
|
-
id: ID
|
|
7
|
-
name: String
|
|
8
|
-
slug: String
|
|
9
|
-
createdOn: DateTime
|
|
10
|
-
description: String
|
|
11
|
-
roles: [SecurityRole]
|
|
12
|
-
system: Boolean!
|
|
13
|
-
plugin: Boolean
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
input SecurityTeamCreateInput {
|
|
17
|
-
name: String!
|
|
18
|
-
slug: String!
|
|
19
|
-
description: String
|
|
20
|
-
roles: [RefInput!]!
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
input SecurityTeamUpdateInput {
|
|
24
|
-
name: String
|
|
25
|
-
description: String
|
|
26
|
-
roles: [RefInput!]
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
type SecurityTeamResponse {
|
|
30
|
-
data: SecurityTeam
|
|
31
|
-
error: SecurityError
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
type SecurityTeamListResponse {
|
|
35
|
-
data: [SecurityTeam]
|
|
36
|
-
error: SecurityError
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
input GetTeamWhereInput {
|
|
40
|
-
id: ID
|
|
41
|
-
slug: String
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
extend type SecurityQuery {
|
|
45
|
-
getTeam(where: GetTeamWhereInput!): SecurityTeamResponse
|
|
46
|
-
listTeams: SecurityTeamListResponse
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
extend type SecurityMutation {
|
|
50
|
-
createTeam(data: SecurityTeamCreateInput!): SecurityTeamResponse
|
|
51
|
-
updateTeam(id: ID!, data: SecurityTeamUpdateInput!): SecurityTeamResponse
|
|
52
|
-
deleteTeam(id: ID!): SecurityBooleanResponse
|
|
53
|
-
}
|
|
54
|
-
`,
|
|
55
|
-
resolvers: {
|
|
56
|
-
SecurityTeam: {
|
|
57
|
-
roles: async (team, __, context)=>{
|
|
58
|
-
try {
|
|
59
|
-
return context.security.listRoles({
|
|
60
|
-
where: {
|
|
61
|
-
id_in: team.roles
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
} catch (e) {
|
|
65
|
-
return new ErrorResponse(e);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
SecurityQuery: {
|
|
70
|
-
getTeam: async (_, { where }, context)=>{
|
|
71
|
-
try {
|
|
72
|
-
const team = await context.security.getTeam({
|
|
73
|
-
where
|
|
74
|
-
});
|
|
75
|
-
return new Response(team);
|
|
76
|
-
} catch (e) {
|
|
77
|
-
return new ErrorResponse(e);
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
listTeams: async (_, __, context)=>{
|
|
81
|
-
try {
|
|
82
|
-
const teamList = await context.security.listTeams();
|
|
83
|
-
return new ListResponse(teamList);
|
|
84
|
-
} catch (e) {
|
|
85
|
-
return new ListErrorResponse(e);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
SecurityMutation: {
|
|
90
|
-
createTeam: async (_, { data }, context)=>{
|
|
91
|
-
try {
|
|
92
|
-
const team = await context.security.createTeam(data);
|
|
93
|
-
return new Response(team);
|
|
94
|
-
} catch (e) {
|
|
95
|
-
return new ErrorResponse(e);
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
updateTeam: async (_, { id, data }, context)=>{
|
|
99
|
-
try {
|
|
100
|
-
const team = await context.security.updateTeam(id, data);
|
|
101
|
-
return new Response(team);
|
|
102
|
-
} catch (e) {
|
|
103
|
-
return new ErrorResponse(e);
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
deleteTeam: async (_, { id }, context)=>{
|
|
107
|
-
try {
|
|
108
|
-
await context.security.deleteTeam(id);
|
|
109
|
-
return new Response(true);
|
|
110
|
-
} catch (e) {
|
|
111
|
-
return new ErrorResponse(e);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
export default team_gql;
|
|
118
|
-
|
|
119
|
-
//# sourceMappingURL=team.gql.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/security/team.gql.js","sources":["../../../src/graphql/security/team.gql.ts"],"sourcesContent":["import {\n ErrorResponse,\n ListErrorResponse,\n ListResponse,\n Response\n} from \"@webiny/handler-graphql/responses.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\nimport type { Team } from \"~/types/security.js\";\n\nexport default new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n type SecurityTeam {\n id: ID\n name: String\n slug: String\n createdOn: DateTime\n description: String\n roles: [SecurityRole]\n system: Boolean!\n plugin: Boolean\n }\n\n input SecurityTeamCreateInput {\n name: String!\n slug: String!\n description: String\n roles: [RefInput!]!\n }\n\n input SecurityTeamUpdateInput {\n name: String\n description: String\n roles: [RefInput!]\n }\n\n type SecurityTeamResponse {\n data: SecurityTeam\n error: SecurityError\n }\n\n type SecurityTeamListResponse {\n data: [SecurityTeam]\n error: SecurityError\n }\n\n input GetTeamWhereInput {\n id: ID\n slug: String\n }\n\n extend type SecurityQuery {\n getTeam(where: GetTeamWhereInput!): SecurityTeamResponse\n listTeams: SecurityTeamListResponse\n }\n\n extend type SecurityMutation {\n createTeam(data: SecurityTeamCreateInput!): SecurityTeamResponse\n updateTeam(id: ID!, data: SecurityTeamUpdateInput!): SecurityTeamResponse\n deleteTeam(id: ID!): SecurityBooleanResponse\n }\n `,\n resolvers: {\n SecurityTeam: {\n roles: async (team: Team, __, context) => {\n try {\n return context.security.listRoles({ where: { id_in: team.roles } });\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n SecurityQuery: {\n getTeam: async (_, { where }, context) => {\n try {\n const team = await context.security.getTeam({ where });\n return new Response(team);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n listTeams: async (_, __, context) => {\n try {\n const teamList = await context.security.listTeams();\n\n return new ListResponse(teamList);\n } catch (e) {\n return new ListErrorResponse(e);\n }\n }\n },\n SecurityMutation: {\n createTeam: async (_, { data }, context) => {\n try {\n const team = await context.security.createTeam(data);\n\n return new Response(team);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n updateTeam: async (_, { id, data }, context) => {\n try {\n const team = await context.security.updateTeam(id, data);\n return new Response(team);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n deleteTeam: async (_, { id }, context) => {\n try {\n await context.security.deleteTeam(id);\n\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n }\n }\n});\n"],"names":["GraphQLSchemaPlugin","team","__","context","e","ErrorResponse","_","where","Response","teamList","ListResponse","ListErrorResponse","data","id"],"mappings":";;AAUA,iBAAe,IAAIA,oBAAoC;IACnD,UAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkDzB,CAAC;IACD,WAAW;QACP,cAAc;YACV,OAAO,OAAOC,MAAYC,IAAIC;gBAC1B,IAAI;oBACA,OAAOA,QAAQ,QAAQ,CAAC,SAAS,CAAC;wBAAE,OAAO;4BAAE,OAAOF,KAAK,KAAK;wBAAC;oBAAE;gBACrE,EAAE,OAAOG,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;QACJ;QACA,eAAe;YACX,SAAS,OAAOE,GAAG,EAAEC,KAAK,EAAE,EAAEJ;gBAC1B,IAAI;oBACA,MAAMF,OAAO,MAAME,QAAQ,QAAQ,CAAC,OAAO,CAAC;wBAAEI;oBAAM;oBACpD,OAAO,IAAIC,SAASP;gBACxB,EAAE,OAAOG,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;YACA,WAAW,OAAOE,GAAGJ,IAAIC;gBACrB,IAAI;oBACA,MAAMM,WAAW,MAAMN,QAAQ,QAAQ,CAAC,SAAS;oBAEjD,OAAO,IAAIO,aAAaD;gBAC5B,EAAE,OAAOL,GAAG;oBACR,OAAO,IAAIO,kBAAkBP;gBACjC;YACJ;QACJ;QACA,kBAAkB;YACd,YAAY,OAAOE,GAAG,EAAEM,IAAI,EAAE,EAAET;gBAC5B,IAAI;oBACA,MAAMF,OAAO,MAAME,QAAQ,QAAQ,CAAC,UAAU,CAACS;oBAE/C,OAAO,IAAIJ,SAASP;gBACxB,EAAE,OAAOG,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;YACA,YAAY,OAAOE,GAAG,EAAEO,EAAE,EAAED,IAAI,EAAE,EAAET;gBAChC,IAAI;oBACA,MAAMF,OAAO,MAAME,QAAQ,QAAQ,CAAC,UAAU,CAACU,IAAID;oBACnD,OAAO,IAAIJ,SAASP;gBACxB,EAAE,OAAOG,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;YACA,YAAY,OAAOE,GAAG,EAAEO,EAAE,EAAE,EAAEV;gBAC1B,IAAI;oBACA,MAAMA,QAAQ,QAAQ,CAAC,UAAU,CAACU;oBAElC,OAAO,IAAIL,SAAS;gBACxB,EAAE,OAAOJ,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;QACJ;IACJ;AACJ"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins/index.js";
|
|
2
|
-
import { ErrorResponse, Response } from "@webiny/handler-graphql";
|
|
3
|
-
import { GetRootTenantUseCase } from "../../features/tenancy/GetRootTenant/index.js";
|
|
4
|
-
import { InstallSystemUseCase } from "../../features/system/InstallSystem/index.js";
|
|
5
|
-
const emptyResolver = ()=>({});
|
|
6
|
-
const createSystemGraphQL = ()=>new GraphQLSchemaPlugin({
|
|
7
|
-
typeDefs: `
|
|
8
|
-
type SystemQuery {
|
|
9
|
-
isSystemInstalled: BooleanResponse
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type SystemMutation {
|
|
13
|
-
installSystem(installationInput: JSON!): BooleanResponse
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
extend type Query {
|
|
17
|
-
system: SystemQuery
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
extend type Mutation {
|
|
21
|
-
system: SystemMutation
|
|
22
|
-
}
|
|
23
|
-
`,
|
|
24
|
-
resolvers: {
|
|
25
|
-
Query: {
|
|
26
|
-
system: emptyResolver
|
|
27
|
-
},
|
|
28
|
-
Mutation: {
|
|
29
|
-
system: emptyResolver
|
|
30
|
-
},
|
|
31
|
-
SystemQuery: {
|
|
32
|
-
isSystemInstalled: async (_, __, context)=>{
|
|
33
|
-
const getRootTenant = context.container.resolve(GetRootTenantUseCase);
|
|
34
|
-
const result = await getRootTenant.execute();
|
|
35
|
-
return new Response(result.isOk());
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
SystemMutation: {
|
|
39
|
-
installSystem: async (_, args, context)=>{
|
|
40
|
-
const installSystem = context.container.resolve(InstallSystemUseCase);
|
|
41
|
-
const result = await installSystem.execute(args.installationInput);
|
|
42
|
-
if (result.isOk()) return new Response(true);
|
|
43
|
-
return new ErrorResponse({
|
|
44
|
-
code: result.error.code,
|
|
45
|
-
message: result.error.message,
|
|
46
|
-
data: result.error.data
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
export { createSystemGraphQL };
|
|
53
|
-
|
|
54
|
-
//# sourceMappingURL=createSystemGraphQL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/system/createSystemGraphQL.js","sources":["../../../src/graphql/system/createSystemGraphQL.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/index.js\";\nimport { ErrorResponse, Response } from \"@webiny/handler-graphql\";\nimport { type AppInstallationData } from \"~/features/tenancy/InstallTenant/index.js\";\nimport { GetRootTenantUseCase } from \"~/features/tenancy/GetRootTenant/index.js\";\nimport { InstallSystemUseCase } from \"~/features/system/InstallSystem/index.js\";\n\nconst emptyResolver = () => ({});\n\ninterface InstallTenantArgs {\n installationInput: AppInstallationData[];\n}\n\nexport const createSystemGraphQL = () => {\n return new GraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type SystemQuery {\n isSystemInstalled: BooleanResponse\n }\n\n type SystemMutation {\n installSystem(installationInput: JSON!): BooleanResponse\n }\n\n extend type Query {\n system: SystemQuery\n }\n\n extend type Mutation {\n system: SystemMutation\n }\n `,\n resolvers: {\n Query: {\n system: emptyResolver\n },\n Mutation: {\n system: emptyResolver\n },\n SystemQuery: {\n isSystemInstalled: async (_, __, context) => {\n const getRootTenant = context.container.resolve(GetRootTenantUseCase);\n const result = await getRootTenant.execute();\n\n return new Response(result.isOk());\n }\n },\n SystemMutation: {\n installSystem: async (_, args: InstallTenantArgs, context) => {\n const installSystem = context.container.resolve(InstallSystemUseCase);\n\n const result = await installSystem.execute(args.installationInput);\n\n if (result.isOk()) {\n return new Response(true);\n }\n\n return new ErrorResponse({\n code: result.error.code,\n message: result.error.message,\n data: result.error.data\n });\n }\n }\n }\n });\n};\n"],"names":["emptyResolver","createSystemGraphQL","GraphQLSchemaPlugin","_","__","context","getRootTenant","GetRootTenantUseCase","result","Response","args","installSystem","InstallSystemUseCase","ErrorResponse"],"mappings":";;;;AAMA,MAAMA,gBAAgB,IAAO,EAAC;AAMvB,MAAMC,sBAAsB,IACxB,IAAIC,oBAAoB;QAC3B,UAAwB,CAAC;;;;;;;;;;;;;;;;QAgBzB,CAAC;QACD,WAAW;YACP,OAAO;gBACH,QAAQF;YACZ;YACA,UAAU;gBACN,QAAQA;YACZ;YACA,aAAa;gBACT,mBAAmB,OAAOG,GAAGC,IAAIC;oBAC7B,MAAMC,gBAAgBD,QAAQ,SAAS,CAAC,OAAO,CAACE;oBAChD,MAAMC,SAAS,MAAMF,cAAc,OAAO;oBAE1C,OAAO,IAAIG,SAASD,OAAO,IAAI;gBACnC;YACJ;YACA,gBAAgB;gBACZ,eAAe,OAAOL,GAAGO,MAAyBL;oBAC9C,MAAMM,gBAAgBN,QAAQ,SAAS,CAAC,OAAO,CAACO;oBAEhD,MAAMJ,SAAS,MAAMG,cAAc,OAAO,CAACD,KAAK,iBAAiB;oBAEjE,IAAIF,OAAO,IAAI,IACX,OAAO,IAAIC,SAAS;oBAGxB,OAAO,IAAII,cAAc;wBACrB,MAAML,OAAO,KAAK,CAAC,IAAI;wBACvB,SAASA,OAAO,KAAK,CAAC,OAAO;wBAC7B,MAAMA,OAAO,KAAK,CAAC,IAAI;oBAC3B;gBACJ;YACJ;QACJ;IACJ"}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { ErrorResponse, ListErrorResponse, ListResponse, NotFoundResponse, Response } from "@webiny/handler-graphql/responses.js";
|
|
2
|
-
import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js";
|
|
3
|
-
import { GetUserUseCase } from "../../features/users/GetUser/index.js";
|
|
4
|
-
import NotAuthorizedResponse from "../security/NotAuthorizedResponse.js";
|
|
5
|
-
import { ListUsersUseCase } from "../../features/users/ListUsers/index.js";
|
|
6
|
-
const emptyResolver = ()=>({});
|
|
7
|
-
const createUsersGraphQL = ()=>[
|
|
8
|
-
new GraphQLSchemaPlugin({
|
|
9
|
-
typeDefs: `
|
|
10
|
-
type AdminUsersQuery {
|
|
11
|
-
_empty: String
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type AdminUsersMutation {
|
|
15
|
-
_empty: String
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
extend type Query {
|
|
19
|
-
adminUsers: AdminUsersQuery
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
extend type Mutation {
|
|
23
|
-
adminUsers: AdminUsersMutation
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
type AdminUsersCreatedBy {
|
|
27
|
-
id: ID
|
|
28
|
-
displayName: String
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type AdminUsersError {
|
|
32
|
-
code: String
|
|
33
|
-
message: String
|
|
34
|
-
data: JSON
|
|
35
|
-
stack: String
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
type AdminUsersBooleanResponse {
|
|
39
|
-
data: Boolean
|
|
40
|
-
error: AdminUsersError
|
|
41
|
-
}
|
|
42
|
-
`,
|
|
43
|
-
resolvers: {
|
|
44
|
-
Query: {
|
|
45
|
-
adminUsers: emptyResolver
|
|
46
|
-
},
|
|
47
|
-
Mutation: {
|
|
48
|
-
adminUsers: emptyResolver
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}),
|
|
52
|
-
new GraphQLSchemaPlugin({
|
|
53
|
-
typeDefs: `
|
|
54
|
-
type AdminUser {
|
|
55
|
-
id: ID!
|
|
56
|
-
displayName: String!
|
|
57
|
-
email: String!
|
|
58
|
-
|
|
59
|
-
roles: [SecurityRole]
|
|
60
|
-
firstName: String
|
|
61
|
-
lastName: String
|
|
62
|
-
avatar: JSON
|
|
63
|
-
external: Boolean
|
|
64
|
-
createdOn: DateTime
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
type AdminUsersResponse {
|
|
68
|
-
data: AdminUser
|
|
69
|
-
error: AdminUsersError
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
type AdminUsersListResponse {
|
|
73
|
-
data: [AdminUser]
|
|
74
|
-
error: AdminUsersError
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
input AdminUsersGetUserWhereInput {
|
|
78
|
-
id: ID
|
|
79
|
-
email: String
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
extend type AdminUsersQuery {
|
|
83
|
-
getUser(where: AdminUsersGetUserWhereInput): AdminUsersResponse
|
|
84
|
-
getCurrentUser: AdminUsersResponse
|
|
85
|
-
listUsers: AdminUsersListResponse
|
|
86
|
-
}
|
|
87
|
-
`,
|
|
88
|
-
resolvers: {
|
|
89
|
-
AdminUser: {
|
|
90
|
-
roles (user, _, context) {
|
|
91
|
-
if (!user.roles) return null;
|
|
92
|
-
return context.security.listRoles({
|
|
93
|
-
where: {
|
|
94
|
-
id_in: user.roles
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
AdminUsersQuery: {
|
|
100
|
-
getUser: async (_, { where }, context)=>{
|
|
101
|
-
const getUser = context.container.resolve(GetUserUseCase);
|
|
102
|
-
const userResult = await getUser.execute({
|
|
103
|
-
id: where.id,
|
|
104
|
-
email: where.email
|
|
105
|
-
});
|
|
106
|
-
if (userResult.isFail()) {
|
|
107
|
-
const error = userResult.error;
|
|
108
|
-
if ("AdminUser/NotFound" === error.code) return new NotFoundResponse(`User "${JSON.stringify(where)}" was not found!`);
|
|
109
|
-
return new ErrorResponse({
|
|
110
|
-
message: error.message,
|
|
111
|
-
code: error.code,
|
|
112
|
-
data: error.data
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
return new Response(userResult.value);
|
|
116
|
-
},
|
|
117
|
-
getCurrentUser: async (_, __, context)=>{
|
|
118
|
-
const identity = context.security.getIdentity();
|
|
119
|
-
if (!identity.isAdmin()) throw new NotAuthorizedResponse();
|
|
120
|
-
const getUser = context.container.resolve(GetUserUseCase);
|
|
121
|
-
const userResponse = await context.security.withoutAuthorization(async ()=>await getUser.execute({
|
|
122
|
-
id: identity.id
|
|
123
|
-
}));
|
|
124
|
-
if (userResponse.isFail()) {
|
|
125
|
-
const error = userResponse.error;
|
|
126
|
-
if ("AdminUser/NotFound" === error.code) return new NotFoundResponse(`User with ID ${identity.id} was not found!`);
|
|
127
|
-
return new ErrorResponse({
|
|
128
|
-
message: error.message,
|
|
129
|
-
code: error.code,
|
|
130
|
-
data: error.data
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
return new Response(userResponse.value);
|
|
134
|
-
},
|
|
135
|
-
listUsers: async (_, __, context)=>{
|
|
136
|
-
const listUsers = context.container.resolve(ListUsersUseCase);
|
|
137
|
-
const users = await listUsers.execute();
|
|
138
|
-
if (users.isFail()) return new ListErrorResponse(users.error);
|
|
139
|
-
return new ListResponse(users.value);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}),
|
|
144
|
-
new GraphQLSchemaPlugin({
|
|
145
|
-
typeDefs: `
|
|
146
|
-
extend type AdminUser {
|
|
147
|
-
teams: [SecurityTeam]
|
|
148
|
-
}
|
|
149
|
-
`,
|
|
150
|
-
resolvers: {
|
|
151
|
-
AdminUser: {
|
|
152
|
-
teams (user, _, context) {
|
|
153
|
-
const hasTeams = Array.isArray(user.teams) && user.teams.length > 0;
|
|
154
|
-
if (!hasTeams) return [];
|
|
155
|
-
return context.security.listTeams({
|
|
156
|
-
where: {
|
|
157
|
-
id_in: user.teams
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
})
|
|
164
|
-
].filter(Boolean);
|
|
165
|
-
export { createUsersGraphQL };
|
|
166
|
-
|
|
167
|
-
//# sourceMappingURL=user.gql.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/users/user.gql.js","sources":["../../../src/graphql/users/user.gql.ts"],"sourcesContent":["import {\n ErrorResponse,\n ListErrorResponse,\n ListResponse,\n NotFoundResponse,\n Response\n} from \"@webiny/handler-graphql/responses.js\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\nimport { AdminUser } from \"~/types/users.js\";\nimport { GetUserUseCase } from \"~/features/users/GetUser/index.js\";\nimport NotAuthorizedResponse from \"~/graphql/security/NotAuthorizedResponse.js\";\nimport { ListUsersUseCase } from \"~/features/users/ListUsers/index.js\";\n\nconst emptyResolver = () => ({});\n\nexport const createUsersGraphQL = () => {\n return [\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n type AdminUsersQuery {\n _empty: String\n }\n\n type AdminUsersMutation {\n _empty: String\n }\n\n extend type Query {\n adminUsers: AdminUsersQuery\n }\n\n extend type Mutation {\n adminUsers: AdminUsersMutation\n }\n\n type AdminUsersCreatedBy {\n id: ID\n displayName: String\n }\n\n type AdminUsersError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type AdminUsersBooleanResponse {\n data: Boolean\n error: AdminUsersError\n }\n `,\n resolvers: {\n Query: {\n adminUsers: emptyResolver\n },\n Mutation: {\n adminUsers: emptyResolver\n }\n }\n }),\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n type AdminUser {\n id: ID!\n displayName: String!\n email: String!\n\n roles: [SecurityRole]\n firstName: String\n lastName: String\n avatar: JSON\n external: Boolean\n createdOn: DateTime\n }\n\n type AdminUsersResponse {\n data: AdminUser\n error: AdminUsersError\n }\n\n type AdminUsersListResponse {\n data: [AdminUser]\n error: AdminUsersError\n }\n\n input AdminUsersGetUserWhereInput {\n id: ID\n email: String\n }\n\n extend type AdminUsersQuery {\n getUser(where: AdminUsersGetUserWhereInput): AdminUsersResponse\n getCurrentUser: AdminUsersResponse\n listUsers: AdminUsersListResponse\n }\n `,\n resolvers: {\n AdminUser: {\n roles(user: AdminUser, _, context) {\n if (!user.roles) {\n return null;\n }\n\n return context.security.listRoles({ where: { id_in: user.roles } });\n }\n },\n AdminUsersQuery: {\n getUser: async (_, { where }: any, context) => {\n const getUser = context.container.resolve(GetUserUseCase);\n\n const userResult = await getUser.execute({\n id: where.id,\n email: where.email\n });\n\n if (userResult.isFail()) {\n const error = userResult.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\n `User \"${JSON.stringify(where)}\" was not found!`\n );\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResult.value);\n },\n getCurrentUser: async (_, __, context) => {\n const identity = context.security.getIdentity();\n\n if (!identity.isAdmin()) {\n throw new NotAuthorizedResponse();\n }\n\n // Current user might not have permissions to execute `getUser` (this method can load any user in the system),\n // but loading your own user record should be allowed. For that reason, let's temporarily disable authorization.\n\n const getUser = context.container.resolve(GetUserUseCase);\n\n const userResponse = await context.security.withoutAuthorization(\n async () => {\n // Get user record using the identity ID.\n return await getUser.execute({ id: identity.id });\n }\n );\n\n if (userResponse.isFail()) {\n const error = userResponse.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\n `User with ID ${identity.id} was not found!`\n );\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResponse.value);\n },\n listUsers: async (_, __, context) => {\n const listUsers = context.container.resolve(ListUsersUseCase);\n const users = await listUsers.execute();\n\n if (users.isFail()) {\n return new ListErrorResponse(users.error);\n }\n\n return new ListResponse(users.value);\n }\n }\n }\n }),\n new GraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n extend type AdminUser {\n teams: [SecurityTeam]\n }\n `,\n resolvers: {\n AdminUser: {\n teams(user: AdminUser, _, context) {\n const hasTeams = Array.isArray(user.teams) && user.teams.length > 0;\n if (!hasTeams) {\n return [];\n }\n\n return context.security.listTeams({ where: { id_in: user.teams } });\n }\n }\n }\n })\n ].filter(Boolean);\n};\n"],"names":["emptyResolver","createUsersGraphQL","GraphQLSchemaPlugin","user","_","context","where","getUser","GetUserUseCase","userResult","error","NotFoundResponse","JSON","ErrorResponse","Response","__","identity","NotAuthorizedResponse","userResponse","listUsers","ListUsersUseCase","users","ListErrorResponse","ListResponse","hasTeams","Array","Boolean"],"mappings":";;;;;AAcA,MAAMA,gBAAgB,IAAO,EAAC;AAEvB,MAAMC,qBAAqB,IACvB;QACH,IAAIC,oBAAoC;YACpC,UAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiCzB,CAAC;YACD,WAAW;gBACP,OAAO;oBACH,YAAYF;gBAChB;gBACA,UAAU;oBACN,YAAYA;gBAChB;YACJ;QACJ;QACA,IAAIE,oBAAoC;YACpC,UAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAkCzB,CAAC;YACD,WAAW;gBACP,WAAW;oBACP,OAAMC,IAAe,EAAEC,CAAC,EAAEC,OAAO;wBAC7B,IAAI,CAACF,KAAK,KAAK,EACX,OAAO;wBAGX,OAAOE,QAAQ,QAAQ,CAAC,SAA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,IAAI;gCAChB,MAAMA,MAAM,IAAI;4BACpB;wBACJ;wBAEA,OAAO,IAAII,SAASI,aAAa,KAAK;oBAC1C;oBACA,WAAW,OAAOd,GAAGW,IAAIV;wBACrB,MAAMc,YAAYd,QAAQ,SAAS,CAAC,OAAO,CAACe;wBAC5C,MAAMC,QAAQ,MAAMF,UAAU,OAAO;wBAErC,IAAIE,MAAM,MAAM,IACZ,OAAO,IAAIC,kBAAkBD,MAAM,KAAK;wBAG5C,OAAO,IAAIE,aAAaF,MAAM,KAAK;oBACvC;gBACJ;YACJ;QACJ;QACA,IAAInB,oBAAoC;YACpC,UAAwB,CAAC;;;;YAIzB,CAAC;YACD,WAAW;gBACP,WAAW;oBACP,OAAMC,IAAe,EAAEC,CAAC,EAAEC,OAAO;wBAC7B,MAAMmB,WAAWC,MAAM,OAAO,CAACtB,KAAK,KAAK,KAAKA,KAAK,KAAK,CAAC,MAAM,GAAG;wBAClE,IAAI,CAACqB,UACD,OAAO,EAAE;wBAGb,OAAOnB,QAAQ,QAAQ,CAAC,SAAS,CAAC;4BAAE,OAAO;gCAAE,OAAOF,KAAK,KAAK;4BAAC;wBAAE;oBACrE;gBACJ;YACJ;QACJ;KACH,CAAC,MAAM,CAACuB"}
|
package/graphql/wcp/graphql.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/wcp/graphql.js","sources":["../../../src/graphql/wcp/graphql.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins/index.js\";\nimport { ErrorResponse, Response } from \"@webiny/handler-graphql/responses.js\";\nimport { WcpContext } from \"~/features/wcp/WcpContext/index.js\";\n\nconst emptyResolver = () => ({});\n\nexport const createWcpGraphQL = () => {\n return new GraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type WcpProjectPackageFeaturesFeature {\n enabled: Boolean\n options: JSON\n }\n\n type WcpProjectPackageFeatures {\n seats: WcpProjectPackageFeaturesFeature\n multiTenancy: WcpProjectPackageFeaturesFeature\n advancedPublishingWorkflow: WcpProjectPackageFeaturesFeature\n advancedAccessControlLayer: WcpProjectPackageFeaturesFeature\n auditLogs: WcpProjectPackageFeaturesFeature\n recordLocking: WcpProjectPackageFeaturesFeature\n fileManager: WcpProjectPackageFeaturesFeature\n aiPowerups: WcpProjectPackageFeaturesFeature\n }\n\n type WcpProjectPackage {\n features: WcpProjectPackageFeatures\n }\n\n type WcpProject {\n orgId: ID\n projectId: ID\n package: WcpProjectPackage\n }\n\n type WcpError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type WcpProjectResponse {\n data: WcpProject\n error: WcpError\n }\n\n type WcpQuery {\n getProject: WcpProjectResponse\n }\n\n type WcpMutation {\n updateProject: WcpProjectResponse\n }\n\n extend type Query {\n wcp: WcpQuery\n }\n\n extend type Mutation {\n wcp: WcpMutation\n }\n `,\n resolvers: {\n Query: {\n wcp: emptyResolver\n },\n WcpQuery: {\n getProject: async (_, __, context) => {\n try {\n const wcpContext = context.container.resolve(WcpContext);\n const project = wcpContext.getProjectWithFeatureFlags();\n\n if (!project) {\n throw Error(`Could not get project!`);\n }\n\n return new Response(project);\n } catch (e) {\n return new ErrorResponse({\n code: \"COULD_NOT_GET_PROJECT\",\n message: e.message,\n data: null,\n stack: e.stack\n });\n }\n }\n }\n }\n });\n};\n"],"names":["emptyResolver","createWcpGraphQL","GraphQLSchemaPlugin","_","__","context","wcpContext","WcpContext","project","Error","Response","e","ErrorResponse"],"mappings":";;;AAIA,MAAMA,gBAAgB,IAAO,EAAC;AAEvB,MAAMC,mBAAmB,IACrB,IAAIC,oBAAoB;QAC3B,UAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAsDzB,CAAC;QACD,WAAW;YACP,OAAO;gBACH,KAAKF;YACT;YACA,UAAU;gBACN,YAAY,OAAOG,GAAGC,IAAIC;oBACtB,IAAI;wBACA,MAAMC,aAAaD,QAAQ,SAAS,CAAC,OAAO,CAACE;wBAC7C,MAAMC,UAAUF,WAAW,0BAA0B;wBAErD,IAAI,CAACE,SACD,MAAMC,MAAM;wBAGhB,OAAO,IAAIC,SAASF;oBACxB,EAAE,OAAOG,GAAG;wBACR,OAAO,IAAIC,cAAc;4BACrB,MAAM;4BACN,SAASD,EAAE,OAAO;4BAClB,MAAM;4BACN,OAAOA,EAAE,KAAK;wBAClB;oBACJ;gBACJ;YACJ;QACJ;IACJ"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { type Container } from "@webiny/di";
|
|
2
|
-
import type { SecurityIdentity, SecurityPermission } from "../../types/security.js";
|
|
3
|
-
import { Authenticator } from "../../features/security/authentication/Authenticator/index.js";
|
|
4
|
-
/**
|
|
5
|
-
* Legacy bridge that implements the old Security interface.
|
|
6
|
-
* As we implement each phase, we'll replace forwarding with delegation.
|
|
7
|
-
*/
|
|
8
|
-
export declare class LegacyContext {
|
|
9
|
-
private container;
|
|
10
|
-
constructor(container: Container);
|
|
11
|
-
private get identityContext();
|
|
12
|
-
private get authenticationContext();
|
|
13
|
-
addAuthenticator(authenticator: Authenticator.Interface["authenticate"]): void;
|
|
14
|
-
authenticate(token: string): Promise<void>;
|
|
15
|
-
getIdentity(): SecurityIdentity;
|
|
16
|
-
setIdentity(identity: SecurityIdentity): void;
|
|
17
|
-
getToken(): string | undefined;
|
|
18
|
-
isAuthorizationEnabled(): boolean;
|
|
19
|
-
withoutAuthorization<T = any>(cb: () => Promise<T>): Promise<T>;
|
|
20
|
-
withIdentity<T = any>(identity: SecurityIdentity | undefined, cb: () => Promise<T>): Promise<T>;
|
|
21
|
-
getPermission<TPermission extends SecurityPermission = SecurityPermission>(permission: string): Promise<TPermission | null>;
|
|
22
|
-
getPermissions<TPermission extends SecurityPermission = SecurityPermission>(permission: string): Promise<TPermission[]>;
|
|
23
|
-
listPermissions(): Promise<SecurityPermission[]>;
|
|
24
|
-
hasFullAccess(): Promise<boolean>;
|
|
25
|
-
getRole(params: any): Promise<import("~/types/security.js").Role>;
|
|
26
|
-
listRoles(params?: any): Promise<import("~/types/security.js").Role[]>;
|
|
27
|
-
createRole(input: any): Promise<import("~/types/security.js").Role>;
|
|
28
|
-
updateRole(id: string, input: any): Promise<import("~/types/security.js").Role>;
|
|
29
|
-
deleteRole(id: string): Promise<void>;
|
|
30
|
-
addAuthorizer(authorizer: any): void;
|
|
31
|
-
getTeam(params: any): Promise<import("~/types/security.js").Team>;
|
|
32
|
-
listTeams(params?: any): Promise<import("~/types/security.js").Team[]>;
|
|
33
|
-
createTeam(input: any): Promise<import("~/types/security.js").Team>;
|
|
34
|
-
updateTeam(id: string, input: any): Promise<import("~/types/security.js").Team>;
|
|
35
|
-
deleteTeam(id: string): Promise<void>;
|
|
36
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { AuthenticationContext } from "../../features/security/authentication/AuthenticationContext/index.js";
|
|
2
|
-
import { Authenticator } from "../../features/security/authentication/Authenticator/index.js";
|
|
3
|
-
import { Authorizer } from "../../features/security/authorization/Authorizer/abstractions.js";
|
|
4
|
-
import { AuthenticatedIdentity, IdentityContext } from "../../features/security/IdentityContext/index.js";
|
|
5
|
-
import { GetRoleUseCase } from "../../features/security/roles/GetRole/index.js";
|
|
6
|
-
import { ListRolesUseCase } from "../../features/security/roles/ListRoles/index.js";
|
|
7
|
-
import { CreateRoleUseCase } from "../../features/security/roles/CreateRole/index.js";
|
|
8
|
-
import { UpdateRoleUseCase } from "../../features/security/roles/UpdateRole/index.js";
|
|
9
|
-
import { DeleteRoleUseCase } from "../../features/security/roles/DeleteRole/index.js";
|
|
10
|
-
import { GetTeamUseCase } from "../../features/security/teams/GetTeam/index.js";
|
|
11
|
-
import { ListTeamsUseCase } from "../../features/security/teams/ListTeams/index.js";
|
|
12
|
-
import { CreateTeam } from "../../features/security/teams/CreateTeam/index.js";
|
|
13
|
-
import { UpdateTeam } from "../../features/security/teams/UpdateTeam/index.js";
|
|
14
|
-
import { DeleteTeam } from "../../features/security/teams/DeleteTeam/index.js";
|
|
15
|
-
class LegacyContext {
|
|
16
|
-
constructor(container){
|
|
17
|
-
this.container = container;
|
|
18
|
-
}
|
|
19
|
-
get identityContext() {
|
|
20
|
-
return this.container.resolve(IdentityContext);
|
|
21
|
-
}
|
|
22
|
-
get authenticationContext() {
|
|
23
|
-
return this.container.resolve(AuthenticationContext);
|
|
24
|
-
}
|
|
25
|
-
addAuthenticator(authenticator) {
|
|
26
|
-
this.container.registerFactory(Authenticator, ()=>({
|
|
27
|
-
authenticate (token) {
|
|
28
|
-
return authenticator(token);
|
|
29
|
-
}
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
async authenticate(token) {
|
|
33
|
-
const identity = await this.authenticationContext.authenticate(token);
|
|
34
|
-
this.identityContext.setIdentity(identity);
|
|
35
|
-
}
|
|
36
|
-
getIdentity() {
|
|
37
|
-
const identity = this.identityContext.getIdentity();
|
|
38
|
-
if (identity.isAnonymous()) return;
|
|
39
|
-
return identity;
|
|
40
|
-
}
|
|
41
|
-
setIdentity(identity) {
|
|
42
|
-
if (!identity) return void this.identityContext.setIdentity(void 0);
|
|
43
|
-
const { id, displayName, type, ...rest } = identity;
|
|
44
|
-
const authenticatedIdentity = new AuthenticatedIdentity({
|
|
45
|
-
id,
|
|
46
|
-
displayName,
|
|
47
|
-
type,
|
|
48
|
-
...rest
|
|
49
|
-
});
|
|
50
|
-
this.identityContext.setIdentity(authenticatedIdentity);
|
|
51
|
-
}
|
|
52
|
-
getToken() {
|
|
53
|
-
return this.authenticationContext.getAuthToken();
|
|
54
|
-
}
|
|
55
|
-
isAuthorizationEnabled() {
|
|
56
|
-
return this.identityContext.isAuthorizationEnabled();
|
|
57
|
-
}
|
|
58
|
-
withoutAuthorization(cb) {
|
|
59
|
-
return this.identityContext.withoutAuthorization(cb);
|
|
60
|
-
}
|
|
61
|
-
withIdentity(identity, cb) {
|
|
62
|
-
if (!identity) return this.identityContext.withIdentity(void 0, cb);
|
|
63
|
-
const { id, displayName, type, ...rest } = identity;
|
|
64
|
-
const authenticatedIdentity = new AuthenticatedIdentity({
|
|
65
|
-
id,
|
|
66
|
-
displayName,
|
|
67
|
-
type,
|
|
68
|
-
...rest
|
|
69
|
-
});
|
|
70
|
-
return this.identityContext.withIdentity(authenticatedIdentity, cb);
|
|
71
|
-
}
|
|
72
|
-
async getPermission(permission) {
|
|
73
|
-
return this.identityContext.getPermission(permission);
|
|
74
|
-
}
|
|
75
|
-
async getPermissions(permission) {
|
|
76
|
-
return this.identityContext.getPermissions(permission);
|
|
77
|
-
}
|
|
78
|
-
async listPermissions() {
|
|
79
|
-
return this.identityContext.listPermissions();
|
|
80
|
-
}
|
|
81
|
-
async hasFullAccess() {
|
|
82
|
-
return this.identityContext.hasFullAccess();
|
|
83
|
-
}
|
|
84
|
-
async getRole(params) {
|
|
85
|
-
const useCase = this.container.resolve(GetRoleUseCase);
|
|
86
|
-
const result = await useCase.execute(params.where);
|
|
87
|
-
if (result.isFail()) throw result.error;
|
|
88
|
-
return result.value;
|
|
89
|
-
}
|
|
90
|
-
async listRoles(params) {
|
|
91
|
-
const useCase = this.container.resolve(ListRolesUseCase);
|
|
92
|
-
const result = await useCase.execute(params);
|
|
93
|
-
if (result.isFail()) throw result.error;
|
|
94
|
-
return result.value;
|
|
95
|
-
}
|
|
96
|
-
async createRole(input) {
|
|
97
|
-
const useCase = this.container.resolve(CreateRoleUseCase);
|
|
98
|
-
const result = await useCase.execute(input);
|
|
99
|
-
if (result.isFail()) throw result.error;
|
|
100
|
-
return result.value;
|
|
101
|
-
}
|
|
102
|
-
async updateRole(id, input) {
|
|
103
|
-
const useCase = this.container.resolve(UpdateRoleUseCase);
|
|
104
|
-
const result = await useCase.execute(id, input);
|
|
105
|
-
if (result.isFail()) throw result.error;
|
|
106
|
-
return result.value;
|
|
107
|
-
}
|
|
108
|
-
async deleteRole(id) {
|
|
109
|
-
const useCase = this.container.resolve(DeleteRoleUseCase);
|
|
110
|
-
const result = await useCase.execute(id);
|
|
111
|
-
if (result.isFail()) throw result.error;
|
|
112
|
-
}
|
|
113
|
-
addAuthorizer(authorizer) {
|
|
114
|
-
this.container.registerFactory(Authorizer, ()=>({
|
|
115
|
-
authorize () {
|
|
116
|
-
return authorizer();
|
|
117
|
-
}
|
|
118
|
-
}));
|
|
119
|
-
}
|
|
120
|
-
async getTeam(params) {
|
|
121
|
-
const useCase = this.container.resolve(GetTeamUseCase);
|
|
122
|
-
const result = await useCase.execute(params.where);
|
|
123
|
-
if (result.isFail()) throw result.error;
|
|
124
|
-
return result.value;
|
|
125
|
-
}
|
|
126
|
-
async listTeams(params) {
|
|
127
|
-
const useCase = this.container.resolve(ListTeamsUseCase);
|
|
128
|
-
const result = await useCase.execute(params);
|
|
129
|
-
if (result.isFail()) throw result.error;
|
|
130
|
-
return result.value;
|
|
131
|
-
}
|
|
132
|
-
async createTeam(input) {
|
|
133
|
-
const useCase = this.container.resolve(CreateTeam);
|
|
134
|
-
const result = await useCase.execute(input);
|
|
135
|
-
if (result.isFail()) throw result.error;
|
|
136
|
-
return result.value;
|
|
137
|
-
}
|
|
138
|
-
async updateTeam(id, input) {
|
|
139
|
-
const useCase = this.container.resolve(UpdateTeam);
|
|
140
|
-
const result = await useCase.execute(id, input);
|
|
141
|
-
if (result.isFail()) throw result.error;
|
|
142
|
-
return result.value;
|
|
143
|
-
}
|
|
144
|
-
async deleteTeam(id) {
|
|
145
|
-
const useCase = this.container.resolve(DeleteTeam);
|
|
146
|
-
const result = await useCase.execute(id);
|
|
147
|
-
if (result.isFail()) throw result.error;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
export { LegacyContext };
|
|
151
|
-
|
|
152
|
-
//# sourceMappingURL=LegacyContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy/security/LegacyContext.js","sources":["../../../src/legacy/security/LegacyContext.ts"],"sourcesContent":["import { type Container } from \"@webiny/di\";\nimport type { SecurityIdentity, SecurityPermission } from \"~/types/security.js\";\nimport { AuthenticationContext } from \"~/features/security/authentication/AuthenticationContext/index.js\";\nimport { Authenticator } from \"~/features/security/authentication/Authenticator/index.js\";\nimport { Authorizer } from \"~/features/security/authorization/Authorizer/abstractions.js\";\nimport {\n AuthenticatedIdentity,\n IdentityContext,\n IdentityData\n} from \"~/features/security/IdentityContext/index.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\";\nimport { GetTeamUseCase } from \"~/features/security/teams/GetTeam/index.js\";\nimport { ListTeamsUseCase } from \"~/features/security/teams/ListTeams/index.js\";\nimport { CreateTeam } from \"~/features/security/teams/CreateTeam/index.js\";\nimport { UpdateTeam } from \"~/features/security/teams/UpdateTeam/index.js\";\nimport { DeleteTeam } from \"~/features/security/teams/DeleteTeam/index.js\";\n\n/**\n * Legacy bridge that implements the old Security interface.\n * As we implement each phase, we'll replace forwarding with delegation.\n */\nexport class LegacyContext {\n constructor(private container: Container) {}\n\n private get identityContext() {\n return this.container.resolve(IdentityContext);\n }\n\n private get authenticationContext() {\n return this.container.resolve(AuthenticationContext);\n }\n\n addAuthenticator(authenticator: Authenticator.Interface[\"authenticate\"]): void {\n this.container.registerFactory(Authenticator, () => {\n return {\n authenticate(token: string): Promise<IdentityData | null> {\n return authenticator(token);\n }\n };\n });\n }\n\n async authenticate(token: string): Promise<void> {\n // Authenticate using new context\n const identity = await this.authenticationContext.authenticate(token);\n\n // Set identity in IdentityContext\n this.identityContext.setIdentity(identity);\n }\n\n getIdentity(): SecurityIdentity {\n const identity = this.identityContext.getIdentity();\n\n // Convert our Identity class to old SecurityIdentity format\n if (identity.isAnonymous()) {\n return undefined as any;\n }\n\n return identity;\n }\n\n setIdentity(identity: SecurityIdentity): void {\n if (!identity) {\n this.identityContext.setIdentity(undefined);\n return;\n }\n\n // Wrap old identity format in AuthenticatedIdentity\n const { id, displayName, type, ...rest } = identity;\n const authenticatedIdentity = new AuthenticatedIdentity({\n id,\n displayName,\n type,\n ...rest\n });\n\n this.identityContext.setIdentity(authenticatedIdentity);\n }\n\n getToken() {\n return this.authenticationContext.getAuthToken();\n }\n\n isAuthorizationEnabled(): boolean {\n return this.identityContext.isAuthorizationEnabled();\n }\n\n withoutAuthorization<T = any>(cb: () => Promise<T>): Promise<T> {\n return this.identityContext.withoutAuthorization(cb);\n }\n\n withIdentity<T = any>(\n identity: SecurityIdentity | undefined,\n cb: () => Promise<T>\n ): Promise<T> {\n if (!identity) {\n return this.identityContext.withIdentity(undefined, cb);\n }\n\n const { id, displayName, type, ...rest } = identity;\n const authenticatedIdentity = new AuthenticatedIdentity({\n id,\n displayName,\n type,\n ...rest\n });\n\n return this.identityContext.withIdentity(authenticatedIdentity, cb);\n }\n\n async getPermission<TPermission extends SecurityPermission = SecurityPermission>(\n permission: string\n ) {\n return this.identityContext.getPermission<TPermission>(permission);\n }\n\n async getPermissions<TPermission extends SecurityPermission = SecurityPermission>(\n permission: string\n ) {\n return this.identityContext.getPermissions<TPermission>(permission);\n }\n\n async listPermissions() {\n return this.identityContext.listPermissions();\n }\n\n async hasFullAccess(): Promise<boolean> {\n return this.identityContext.hasFullAccess();\n }\n\n async getRole(params: any) {\n const useCase = this.container.resolve(GetRoleUseCase);\n const result = await useCase.execute(params.where);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async listRoles(params?: any) {\n const useCase = this.container.resolve(ListRolesUseCase);\n const result = await useCase.execute(params);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async createRole(input: any) {\n const useCase = this.container.resolve(CreateRoleUseCase);\n const result = await useCase.execute(input);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async updateRole(id: string, input: any) {\n const useCase = this.container.resolve(UpdateRoleUseCase);\n const result = await useCase.execute(id, input);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async deleteRole(id: string) {\n const useCase = this.container.resolve(DeleteRoleUseCase);\n const result = await useCase.execute(id);\n\n if (result.isFail()) {\n throw result.error;\n }\n }\n\n addAuthorizer(authorizer: any) {\n // @ts-expect-error\n this.container.registerFactory(Authorizer, () => {\n return {\n authorize(): Promise<Permissions[]> {\n return authorizer();\n }\n };\n });\n }\n\n async getTeam(params: any) {\n const useCase = this.container.resolve(GetTeamUseCase);\n const result = await useCase.execute(params.where);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async listTeams(params?: any) {\n const useCase = this.container.resolve(ListTeamsUseCase);\n const result = await useCase.execute(params);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async createTeam(input: any) {\n const useCase = this.container.resolve(CreateTeam);\n const result = await useCase.execute(input);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async updateTeam(id: string, input: any) {\n const useCase = this.container.resolve(UpdateTeam);\n const result = await useCase.execute(id, input);\n\n if (result.isFail()) {\n throw result.error;\n }\n\n return result.value;\n }\n\n async deleteTeam(id: string) {\n const useCase = this.container.resolve(DeleteTeam);\n const result = await useCase.execute(id);\n\n if (result.isFail()) {\n throw result.error;\n }\n }\n}\n"],"names":["LegacyContext","container","IdentityContext","AuthenticationContext","authenticator","Authenticator","token","identity","undefined","id","displayName","type","rest","authenticatedIdentity","AuthenticatedIdentity","cb","permission","params","useCase","GetRoleUseCase","result","ListRolesUseCase","input","CreateRoleUseCase","UpdateRoleUseCase","DeleteRoleUseCase","authorizer","Authorizer","GetTeamUseCase","ListTeamsUseCase","CreateTeam","UpdateTeam","DeleteTeam"],"mappings":";;;;;;;;;;;;;;AAyBO,MAAMA;IACT,YAAoBC,SAAoB,CAAE;aAAtBA,SAAS,GAATA;IAAuB;IA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S,MAAMF,QAAQ,OAAO,CAACT,IAAIa;QAEzC,IAAIF,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;QAGtB,OAAOA,OAAO,KAAK;IACvB;IAEA,MAAM,WAAWX,EAAU,EAAE;QACzB,MAAMS,UAAU,IAAI,CAAC,SAAS,CAAC,OAAO,CAACc;QACvC,MAAMZ,SAAS,MAAMF,QAAQ,OAAO,CAACT;QAErC,IAAIW,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;IAE1B;AACJ"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ContextPlugin } from "@webiny/api";
|
|
2
|
-
import { LegacyContext } from "./LegacyContext.js";
|
|
3
|
-
import { createSecurityGraphQL } from "../../graphql/security/index.js";
|
|
4
|
-
const createSecurityContext = ()=>new ContextPlugin(async (context)=>{
|
|
5
|
-
context.security = new LegacyContext(context.container);
|
|
6
|
-
context.plugins.register(createSecurityGraphQL());
|
|
7
|
-
});
|
|
8
|
-
export { createSecurityContext };
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=createSecurityContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy/security/createSecurityContext.js","sources":["../../../src/legacy/security/createSecurityContext.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport type { ApiCoreContext } from \"~/types/core.js\";\nimport { LegacyContext } from \"~/legacy/security/LegacyContext.js\";\nimport { createSecurityGraphQL } from \"~/graphql/security/index.js\";\n\nexport const createSecurityContext = () => {\n return new ContextPlugin<ApiCoreContext>(async context => {\n // Create a legacy context that delegates to new features\n context.security = new LegacyContext(context.container);\n\n // Register GraphQL plugins\n context.plugins.register(createSecurityGraphQL());\n });\n};\n"],"names":["createSecurityContext","ContextPlugin","context","LegacyContext","createSecurityGraphQL"],"mappings":";;;AAKO,MAAMA,wBAAwB,IAC1B,IAAIC,cAA8B,OAAMC;QAE3CA,QAAQ,QAAQ,GAAG,IAAIC,cAAcD,QAAQ,SAAS;QAGtDA,QAAQ,OAAO,CAAC,QAAQ,CAACE;IAC7B"}
|