@webiny/api-core 6.4.5 → 6.6.0-alpha.0
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 +23 -5
- package/ApiCoreFeature.js.map +1 -1
- package/exports/api.d.ts +2 -1
- package/exports/api.js +2 -1
- package/features/ai/feature.js +4 -0
- package/features/ai/feature.js.map +1 -1
- package/features/ai/index.d.ts +2 -0
- package/features/ai/index.js +1 -0
- 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/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/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/feature.js +4 -0
- package/features/security/apiKeys/feature.js.map +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +1 -1
- 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/storageOperations/abstractions.d.ts +21 -0
- package/features/storageOperations/abstractions.js +10 -0
- package/features/storageOperations/abstractions.js.map +1 -0
- 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 +4 -5
- package/features/wcp/WcpContext/WcpContext.js +5 -2
- package/features/wcp/WcpContext/WcpContext.js.map +1 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +8 -8
- 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 +5 -2
- package/features/wcp/WcpFeature.js.map +1 -1
- package/features/wcp/WcpLicenseProvider.d.ts +29 -0
- package/features/wcp/WcpLicenseProvider.js +18 -0
- package/features/wcp/WcpLicenseProvider.js.map +1 -0
- package/features/wcp/loadWcpLicense.d.ts +2 -0
- package/{legacy/wcp/context.js → features/wcp/loadWcpLicense.js} +24 -19
- package/features/wcp/loadWcpLicense.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/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} +26 -18
- package/graphql/wcp/WcpSchemaFactory.js.map +1 -0
- package/index.d.ts +3 -1
- package/index.js +3 -1
- package/package.json +19 -22
- 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 +0 -13
- package/createApiCore.d.ts +0 -7
- package/createApiCore.js +0 -22
- 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 -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.map +0 -1
|
@@ -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,WAAW;IAC5C,MAAMI,kBAAkBD,SAAS,OAAO,CAAC,eAAe,IAAI;IAE5D,MAAME,eAAe,MAAMJ,cAAc,OAAO,CAACG;IACjD,IAAIC,aAAa,IAAI,IACjB,OAAOA,aAAa,KAAK;IAG7B,MAAMC,aAAa,MAAMJ,cAAc,OAAO;IAC9C,IAAII,WAAW,MAAM,IACjB,MAAMA,WAAW,KAAK;IAE1B,OAAOA,WAAW,KAAK;AAC3B;AAEO,MAAMC,oBAAoB,CAACC;IAC9BA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+CnC,CAAC;IAEDA,QAAQ,WAAW,CAAC;QAChB,MAAM;QACN,cAAc;YACVC;YACAC;YACAC;YACAC;YACAC;SACH;QACD,UACI,CACIb,iBACAc,gBACAC,WACAC,WACAC,aAEJ;gBACI,MAAMd,WAAWH,gBAAgB,WAAW;gBAC5C,IAAIG,SAAS,WAAW,IACpB,OAAO,IAAIe,cAAc;oBACrB,MAAM;oBACN,SAAS;gBACb;gBAGJ,IAAI;oBACA,MAAMJ,eAAe,OAAO,CAAC,IAAIK,gBAAgB;wBAAEhB;oBAAS;gBAChE,EAAE,OAAOiB,KAAK;oBACV,OAAO,IAAIF,cAAcE;gBAC7B;gBAEA,MAAMC,SAAS,MAAMrB,gBAAgB,oBAAoB,CAAC,UAC/CiB,WAAW,OAAO,CAACd,SAAS,EAAE;gBAGzC,IAAIkB,OAAO,MAAM,IACb,OAAO,IAAIH,cAAc;oBACrB,MAAM;oBACN,SAAS;gBACb;gBAGJ,MAAMI,OAAOD,OAAO,KAAK;gBAEzB,MAAM,CAACE,OAAOC,MAAM,GAAG,MAAMC,QAAQ,GAAG,CAAC;oBACrCC,SAASJ,MAAMP;oBACfY,SAASL,MAAMN;iBAClB;gBAED,MAAMY,gBAAgB,IAAIC;gBAC1B,MAAMC,UAAU,MAAMF,cAAc,KAAK,CAACN;gBAE1C,OAAO,IAAIS,SAAS;oBAChB,GAAG5B,SAAS,MAAM,EAAE;oBACpB2B;oBACAP;oBACAC;gBACJ;YACJ;IACR;IAEAhB,QAAQ,WAAW,CAAC;QAChB,MAAM;QACN,cAAc;YAACC;YAAiBuB;YAAsBC;SAAqB;QAC3E,UACI,CACIjC,iBACAC,eACAC,gBAEJ,IACIH,iBAAiBC,iBAAiBC,eAAeC;IAC7D;IAEAM,QAAQ,WAAW,CAAC;QAChB,MAAM;QACN,cAAc;YAAC0B;SAAc;QAC7B,UAAU,CAACC,gBAA2C,IAAMA,cAAc,SAAS;IACvF;IAEA3B,QAAQ,WAAW,CAAC;QAChB,MAAM;QACN,cAAc;YAACC;SAAgB;QAC/B,UAAU,CAACT,kBAA+C,IACtDA,gBAAgB,eAAe;IACvC;AACJ;AAEA,MAAM0B,WAAW,OAAOJ,MAAiBP;IACrC,MAAMqB,UAAUd,KAAK,KAAK,IAAI,EAAE;IAChC,IAAIc,QAAQ,MAAM,GAAG,GAAG;QACpB,MAAMf,SAAS,MAAMN,UAAU,IAAI,CAAC;YAChC,OAAO;gBAAE,OAAOqB;YAAQ;QAC5B;QAEA,IAAIf,OAAO,IAAI,IACX,OAAOA,OAAO,KAAK,CAAC,GAAG,CAACgB,CAAAA,OAAS;gBAC7B,IAAIA,KAAK,EAAE;gBACX,MAAMA,KAAK,IAAI;gBACf,MAAMA,KAAK,IAAI;YACnB;IAER;IAEA,OAAO,EAAE;AACb;AAEA,MAAMV,WAAW,OAAOL,MAAiBN;IACrC,MAAMsB,UAAUhB,KAAK,KAAK,IAAI,EAAE;IAChC,IAAIgB,QAAQ,MAAM,GAAG,GAAG;QACpB,MAAMjB,SAAS,MAAML,UAAU,IAAI,CAAC;YAChC,OAAO;gBAAE,OAAOsB;YAAQ;QAC5B;QACA,IAAIjB,OAAO,IAAI,IACX,OAAOA,OAAO,KAAK,CAAC,GAAG,CAACkB,CAAAA,OAAS;gBAC7B,IAAIA,KAAK,EAAE;gBACX,MAAMA,KAAK,IAAI;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;oBAEtB,OAAO,IAAIC,SAASD,OAAO,KAAK;gBACpC,EAAE,OAAOE,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;IACR;IAEAN,QAAQ,WAAW,CAAC;QAChB,MAAM;QACN,cAAc;YAACQ;SAAiB;QAChC,UAAU,CAACN,UAAwC;gBAC/C,IAAI;oBACA,MAAME,SAAS,MAAMF,QAAQ,OAAO;oBACpC,IAAIE,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;oBAEtB,OAAO,IAAIK,aAAaL,OAAO,KAAK;gBACxC,EAAE,OAAOE,GAAG;oBACR,OAAO,IAAII,kBAAkBJ;gBACjC;YACJ;IACJ;IAEAN,QAAQ,WAAW,CAAgB;QAC/B,MAAM;QACN,cAAc;YAACW;SAAkB;QACjC,UACI,CAACT,UACD,OAAO,EAAEC,IAAI,EAAE;gBACX,IAAI;oBACA,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAACC,KAAK,IAAI;oBAC9C,IAAIC,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;oBAEtB,OAAO,IAAIC,SAASD,OAAO,KAAK;gBACpC,EAAE,OAAOE,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;IACR;IAEAN,QAAQ,WAAW,CAA4B;QAC3C,MAAM;QACN,cAAc;YAACY;SAAkB;QACjC,UACI,CAACV,UACD,OAAO,EAAEC,IAAI,EAAE;gBACX,IAAI;oBACA,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAACC,KAAK,EAAE,EAAEA,KAAK,IAAI;oBACvD,IAAIC,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;oBAEtB,OAAO,IAAIC,SAASD,OAAO,KAAK;gBACpC,EAAE,OAAOE,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;IACR;IAEAN,QAAQ,WAAW,CAAiB;QAChC,MAAM;QACN,cAAc;YAACa;SAAkB;QACjC,UACI,CAACX,UACD,OAAO,EAAEC,IAAI,EAAE;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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/security/addTeamSchema.js","sources":["../../../src/graphql/security/addTeamSchema.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 type { Team } from \"~/types/security.js\";\nimport { ListRolesUseCase } from \"~/features/security/roles/ListRoles/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\nexport const addTeamSchema = (builder: IGraphQLSchemaBuilder): void => {\n builder.addTypeDefs(/* 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\n builder.addResolver({\n path: \"SecurityTeam.roles\",\n dependencies: [ListRolesUseCase],\n resolver:\n (useCase: ListRolesUseCase.Interface) =>\n async ({ parent }: { parent: Team }) => {\n try {\n const result = await useCase.execute({ where: { id_in: parent.roles } });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n });\n\n builder.addResolver<{ where: any }>({\n path: \"SecurityQuery.getTeam\",\n dependencies: [GetTeamUseCase],\n resolver:\n (useCase: GetTeamUseCase.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.listTeams\",\n dependencies: [ListTeamsUseCase],\n resolver: (useCase: ListTeamsUseCase.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.createTeam\",\n dependencies: [CreateTeam],\n resolver:\n (useCase: CreateTeam.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.updateTeam\",\n dependencies: [UpdateTeam],\n resolver:\n (useCase: UpdateTeam.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.deleteTeam\",\n dependencies: [DeleteTeam],\n resolver:\n (useCase: DeleteTeam.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":["addTeamSchema","builder","ListRolesUseCase","useCase","parent","result","e","ErrorResponse","GetTeamUseCase","args","Response","ListTeamsUseCase","ListResponse","ListErrorResponse","CreateTeam","UpdateTeam","DeleteTeam"],"mappings":";;;;;;;AAeO,MAAMA,gBAAgB,CAACC;IAC1BA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkDnC,CAAC;IAEDA,QAAQ,WAAW,CAAC;QAChB,MAAM;QACN,cAAc;YAACC;SAAiB;QAChC,UACI,CAACC,UACD,OAAO,EAAEC,MAAM,EAAoB;gBAC/B,IAAI;oBACA,MAAMC,SAAS,MAAMF,QAAQ,OAAO,CAAC;wBAAE,OAAO;4BAAE,OAAOC,OAAO,KAAK;wBAAC;oBAAE;oBACtE,IAAIC,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;oBAEtB,OAAOA,OAAO,KAAK;gBACvB,EAAE,OAAOC,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;IACR;IAEAL,QAAQ,WAAW,CAAiB;QAChC,MAAM;QACN,cAAc;YAACO;SAAe;QAC9B,UACI,CAACL,UACD,OAAO,EAAEM,IAAI,EAAE;gBACX,IAAI;oBACA,MAAMJ,SAAS,MAAMF,QAAQ,OAAO,CAACM,KAAK,KAAK;oBAC/C,IAAIJ,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;oBAEtB,OAAO,IAAIK,SAASL,OAAO,KAAK;gBACpC,EAAE,OAAOC,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;IACR;IAEAL,QAAQ,WAAW,CAAC;QAChB,MAAM;QACN,cAAc;YAACU;SAAiB;QAChC,UAAU,CAACR,UAAwC;gBAC/C,IAAI;oBACA,MAAME,SAAS,MAAMF,QAAQ,OAAO;oBACpC,IAAIE,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;oBAEtB,OAAO,IAAIO,aAAaP,OAAO,KAAK;gBACxC,EAAE,OAAOC,GAAG;oBACR,OAAO,IAAIO,kBAAkBP;gBACjC;YACJ;IACJ;IAEAL,QAAQ,WAAW,CAAgB;QAC/B,MAAM;QACN,cAAc;YAACa;SAAW;QAC1B,UACI,CAACX,UACD,OAAO,EAAEM,IAAI,EAAE;gBACX,IAAI;oBACA,MAAMJ,SAAS,MAAMF,QAAQ,OAAO,CAACM,KAAK,IAAI;oBAC9C,IAAIJ,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;oBAEtB,OAAO,IAAIK,SAASL,OAAO,KAAK;gBACpC,EAAE,OAAOC,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;IACR;IAEAL,QAAQ,WAAW,CAA4B;QAC3C,MAAM;QACN,cAAc;YAACc;SAAW;QAC1B,UACI,CAACZ,UACD,OAAO,EAAEM,IAAI,EAAE;gBACX,IAAI;oBACA,MAAMJ,SAAS,MAAMF,QAAQ,OAAO,CAACM,KAAK,EAAE,EAAEA,KAAK,IAAI;oBACvD,IAAIJ,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;oBAEtB,OAAO,IAAIK,SAASL,OAAO,KAAK;gBACpC,EAAE,OAAOC,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;IACR;IAEAL,QAAQ,WAAW,CAAiB;QAChC,MAAM;QACN,cAAc;YAACe;SAAW;QAC1B,UACI,CAACb,UACD,OAAO,EAAEM,IAAI,EAAE;gBACX,IAAI;oBACA,MAAMJ,SAAS,MAAMF,QAAQ,OAAO,CAACM,KAAK,EAAE;oBAC5C,IAAIJ,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;oBAEtB,OAAO,IAAIK,SAAS;gBACxB,EAAE,OAAOJ,GAAG;oBACR,OAAO,IAAIC,cAAcD;gBAC7B;YACJ;IACR;AACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
|
|
3
|
+
declare class SystemSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {
|
|
4
|
+
execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
|
|
5
|
+
}
|
|
6
|
+
export declare const SystemSchemaFactory: typeof SystemSchemaFactoryImpl & {
|
|
7
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-graphql/graphql/abstractions.core").ICoreGraphQLSchemaFactory>;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import { ErrorResponse, Response } from "@webiny/api-graphql";
|
|
3
|
+
import { GetRootTenantUseCase } from "../../features/tenancy/GetRootTenant/index.js";
|
|
4
|
+
import { InstallSystemUseCase } from "../../features/system/InstallSystem/index.js";
|
|
5
|
+
class SystemSchemaFactoryImpl {
|
|
6
|
+
async execute(builder) {
|
|
7
|
+
builder.addTypeDefs(`
|
|
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
|
+
builder.addResolver({
|
|
25
|
+
path: "Query.system",
|
|
26
|
+
resolver: ()=>async ()=>({})
|
|
27
|
+
});
|
|
28
|
+
builder.addResolver({
|
|
29
|
+
path: "Mutation.system",
|
|
30
|
+
resolver: ()=>async ()=>({})
|
|
31
|
+
});
|
|
32
|
+
builder.addResolver({
|
|
33
|
+
path: "SystemQuery.isSystemInstalled",
|
|
34
|
+
dependencies: [
|
|
35
|
+
GetRootTenantUseCase
|
|
36
|
+
],
|
|
37
|
+
resolver: (getRootTenant)=>async ()=>{
|
|
38
|
+
const result = await getRootTenant.execute();
|
|
39
|
+
return new Response(result.isOk());
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
builder.addResolver({
|
|
43
|
+
path: "SystemMutation.installSystem",
|
|
44
|
+
dependencies: [
|
|
45
|
+
InstallSystemUseCase
|
|
46
|
+
],
|
|
47
|
+
resolver: (installSystem)=>async ({ args })=>{
|
|
48
|
+
const result = await installSystem.execute(args.installationInput);
|
|
49
|
+
if (result.isOk()) return new Response(true);
|
|
50
|
+
return new ErrorResponse({
|
|
51
|
+
code: result.error.code,
|
|
52
|
+
message: result.error.message,
|
|
53
|
+
data: result.error.data
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return builder;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const SystemSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({
|
|
61
|
+
implementation: SystemSchemaFactoryImpl,
|
|
62
|
+
dependencies: []
|
|
63
|
+
});
|
|
64
|
+
export { SystemSchemaFactory };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=SystemSchemaFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/system/SystemSchemaFactory.js","sources":["../../../src/graphql/system/SystemSchemaFactory.ts"],"sourcesContent":["import { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { ErrorResponse, Response } from \"@webiny/api-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\ninterface InstallTenantArgs {\n installationInput: AppInstallationData[];\n}\n\nclass SystemSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(/* 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\n builder.addResolver({\n path: \"Query.system\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"Mutation.system\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"SystemQuery.isSystemInstalled\",\n dependencies: [GetRootTenantUseCase],\n resolver: (getRootTenant: GetRootTenantUseCase.Interface) => async () => {\n const result = await getRootTenant.execute();\n\n return new Response(result.isOk());\n }\n });\n\n builder.addResolver<InstallTenantArgs>({\n path: \"SystemMutation.installSystem\",\n dependencies: [InstallSystemUseCase],\n resolver:\n (installSystem: InstallSystemUseCase.Interface) =>\n async ({ args }) => {\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 return builder;\n }\n}\n\nexport const SystemSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({\n implementation: SystemSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["SystemSchemaFactoryImpl","builder","GetRootTenantUseCase","getRootTenant","result","Response","InstallSystemUseCase","installSystem","args","ErrorResponse","SystemSchemaFactory","CoreGraphQLSchemaFactory"],"mappings":";;;;AAWA,MAAMA;IACF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;;;;;;;QAgBnC,CAAC;QAEDA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IAAM,UAAa,EAAC;QAClC;QAEAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IAAM,UAAa,EAAC;QAClC;QAEAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACC;aAAqB;YACpC,UAAU,CAACC,gBAAkD;oBACzD,MAAMC,SAAS,MAAMD,cAAc,OAAO;oBAE1C,OAAO,IAAIE,SAASD,OAAO,IAAI;gBACnC;QACJ;QAEAH,QAAQ,WAAW,CAAoB;YACnC,MAAM;YACN,cAAc;gBAACK;aAAqB;YACpC,UACI,CAACC,gBACD,OAAO,EAAEC,IAAI,EAAE;oBACX,MAAMJ,SAAS,MAAMG,cAAc,OAAO,CAACC,KAAK,iBAAiB;oBAEjE,IAAIJ,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;QACR;QAEA,OAAOH;IACX;AACJ;AAEO,MAAMS,sBAAsBC,yBAAyB,oBAAoB,CAAC;IAC7E,gBAAgBX;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
|
|
3
|
+
declare class UsersSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {
|
|
4
|
+
execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
|
|
5
|
+
}
|
|
6
|
+
export declare const UsersSchemaFactory: typeof UsersSchemaFactoryImpl & {
|
|
7
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-graphql/graphql/abstractions.core").ICoreGraphQLSchemaFactory>;
|
|
8
|
+
};
|
|
9
|
+
export {};
|