@webiny/api-core 6.4.5-beta.0 → 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,12 +1,11 @@
|
|
|
1
1
|
import type { WCP_FEATURE_LABEL } from "@webiny/wcp";
|
|
2
2
|
import type { DecryptedWcpProjectLicense, ILicense, WcpProjectEnvironment, WcpProject } from "@webiny/wcp/types.js";
|
|
3
3
|
import { WcpContext } from "./abstractions.js";
|
|
4
|
-
|
|
5
|
-
testProjectLicense?: DecryptedWcpProjectLicense;
|
|
6
|
-
}
|
|
4
|
+
import type { WcpLicenseProvider } from "../WcpLicenseProvider.js";
|
|
7
5
|
export declare class WcpContextImpl implements WcpContext.Interface {
|
|
8
|
-
private
|
|
9
|
-
constructor(
|
|
6
|
+
private licenseProvider;
|
|
7
|
+
constructor(licenseProvider: WcpLicenseProvider.Interface);
|
|
8
|
+
private get license();
|
|
10
9
|
private getWcpProjectUrl;
|
|
11
10
|
private updateSeats;
|
|
12
11
|
private updateTenants;
|
|
@@ -3,8 +3,11 @@ import error from "@webiny/error";
|
|
|
3
3
|
import { wcpFetch } from "./utils.js";
|
|
4
4
|
const wcpProjectEnvironment = getWcpProjectEnvironment();
|
|
5
5
|
class WcpContextImpl {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
6
|
+
constructor(licenseProvider){
|
|
7
|
+
this.licenseProvider = licenseProvider;
|
|
8
|
+
}
|
|
9
|
+
get license() {
|
|
10
|
+
return this.licenseProvider.get();
|
|
8
11
|
}
|
|
9
12
|
getWcpProjectUrl(path = "") {
|
|
10
13
|
if (!wcpProjectEnvironment) return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/wcp/WcpContext/WcpContext.js","sources":["../../../../src/features/wcp/WcpContext/WcpContext.ts"],"sourcesContent":["import type { WCP_FEATURE_LABEL } from \"@webiny/wcp\";\nimport { getWcpApiUrl, getWcpAppUrl, getWcpProjectEnvironment } from \"@webiny/wcp\";\nimport WError from \"@webiny/error\";\nimport type {\n DecryptedWcpProjectLicense,\n ILicense,\n WcpProjectEnvironment,\n WcpProject\n} from \"@webiny/wcp/types.js\";\nimport { WcpContext } from \"./abstractions.js\";\nimport { wcpFetch } from \"./utils.js\";\n\nconst wcpProjectEnvironment = getWcpProjectEnvironment();\n\nexport
|
|
1
|
+
{"version":3,"file":"features/wcp/WcpContext/WcpContext.js","sources":["../../../../src/features/wcp/WcpContext/WcpContext.ts"],"sourcesContent":["import type { WCP_FEATURE_LABEL } from \"@webiny/wcp\";\nimport { getWcpApiUrl, getWcpAppUrl, getWcpProjectEnvironment } from \"@webiny/wcp\";\nimport WError from \"@webiny/error\";\nimport type {\n DecryptedWcpProjectLicense,\n ILicense,\n WcpProjectEnvironment,\n WcpProject\n} from \"@webiny/wcp/types.js\";\nimport { WcpContext } from \"./abstractions.js\";\nimport { wcpFetch } from \"./utils.js\";\nimport type { WcpLicenseProvider } from \"../WcpLicenseProvider.js\";\n\nconst wcpProjectEnvironment = getWcpProjectEnvironment();\n\nexport class WcpContextImpl implements WcpContext.Interface {\n constructor(private licenseProvider: WcpLicenseProvider.Interface) {}\n\n private get license(): ILicense {\n return this.licenseProvider.get();\n }\n\n private getWcpProjectUrl(path = \"\"): string | null {\n if (!wcpProjectEnvironment) {\n return null;\n }\n\n const orgId = wcpProjectEnvironment.org.id;\n const projectId = wcpProjectEnvironment.project.id;\n const url = [\"/orgs\", orgId, \"projects\", projectId, path].filter(Boolean).join(\"/\");\n return getWcpApiUrl(url);\n }\n\n private async updateSeats(operation: \"increment\" | \"decrement\"): Promise<void> {\n if (!wcpProjectEnvironment) {\n return;\n }\n\n const updateSeatsUrl = this.getWcpProjectUrl(\"package/seats\");\n\n const response = await wcpFetch({\n url: updateSeatsUrl!,\n authorization: wcpProjectEnvironment.apiKey,\n body: { operation },\n meta: {\n action: operation + \"Seats\"\n }\n });\n\n if (response.error) {\n const message = response.message || `Failed to ${operation} user seats.`;\n console.error(message, response.status, response.statusText);\n throw new WError(message, \"WCP_CANNOT_UPDATE_USER_TENANTS\");\n }\n }\n\n private async updateTenants(operation: \"increment\" | \"decrement\"): Promise<void> {\n if (!wcpProjectEnvironment) {\n return;\n }\n\n const updateTenantsUrl = this.getWcpProjectUrl(\"package/tenants\");\n\n const response = await wcpFetch({\n url: updateTenantsUrl!,\n authorization: wcpProjectEnvironment.apiKey,\n body: { operation },\n meta: {\n action: operation + \"Tenants\"\n }\n });\n\n if (response.error) {\n const message = response.message || `Failed to ${operation} tenants.`;\n console.error(message, response.status, response.statusText);\n throw new WError(message, \"WCP_CANNOT_UPDATE_USER_TENANTS\");\n }\n }\n\n getRawLicense(): DecryptedWcpProjectLicense | null {\n return this.license.getRawLicense();\n }\n\n getProject(): WcpProject | null {\n return this.license.getProject();\n }\n\n getProjectWithFeatureFlags(): WcpProject | null {\n return this.getProject();\n }\n\n getProjectEnvironment(): WcpProjectEnvironment | null {\n return wcpProjectEnvironment;\n }\n\n getProjectLicense(): ILicense {\n return this.license;\n }\n\n canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): boolean {\n return this.license.canUseFeature(wcpFeatureId);\n }\n\n canUseAacl(): boolean {\n return this.license.canUseAacl();\n }\n\n canUseTeams(): boolean {\n return this.license.canUseTeams();\n }\n\n canUseFolderLevelPermissions(): boolean {\n return this.license.canUseFolderLevelPermissions();\n }\n\n canUsePrivateFiles(): boolean {\n return this.license.canUsePrivateFiles();\n }\n\n canUseAuditLogs(): boolean {\n return this.license.canUseAuditLogs();\n }\n\n canUseRecordLocking(): boolean {\n return this.license.canUseRecordLocking();\n }\n\n canUseFileManagerThreatDetection(): boolean {\n return this.license.canUseFileManagerThreatDetection();\n }\n\n canUseWorkflows(): boolean {\n return this.license.canUseWorkflows();\n }\n\n canUseHcmsFieldPermissions(): boolean {\n return this.license.canUseHcmsFieldPermissions();\n }\n\n canUseAiImageEnrichment(): boolean {\n return this.license.canUseAiImageEnrichment();\n }\n\n canUseAiPageGeneration(): boolean {\n return this.license.canUseAiPageGeneration();\n }\n\n canUseAiLexicalGeneration(): boolean {\n return this.license.canUseAiLexicalGeneration();\n }\n\n ensureCanUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): void {\n if (this.license.canUseFeature(wcpFeatureId)) {\n return;\n }\n\n let message = `The ${wcpFeatureId} Webiny Control Panel feature cannot be used because your project license does not permit it.`;\n if (wcpProjectEnvironment) {\n const { org, project } = wcpProjectEnvironment;\n const upgradeProjectLicenseLink = getWcpAppUrl(`/${org.id}/${project.id}/settings`);\n message += ` To upgrade your project license, please use the following link: ${upgradeProjectLicenseLink}.`;\n }\n\n throw new WError(message, \"WCP_CANNOT_USE_FEATURE\", { wcpFeatureId });\n }\n\n async incrementSeats(): Promise<void> {\n await this.updateSeats(\"increment\");\n }\n\n async decrementSeats(): Promise<void> {\n await this.updateSeats(\"decrement\");\n }\n\n async incrementTenants(): Promise<void> {\n await this.updateTenants(\"increment\");\n }\n\n async decrementTenants(): Promise<void> {\n await this.updateTenants(\"decrement\");\n }\n\n toDto() {\n return this.getRawLicense();\n }\n}\n"],"names":["wcpProjectEnvironment","getWcpProjectEnvironment","WcpContextImpl","licenseProvider","path","orgId","projectId","url","Boolean","getWcpApiUrl","operation","updateSeatsUrl","response","wcpFetch","message","console","WError","updateTenantsUrl","wcpFeatureId","org","project","upgradeProjectLicenseLink","getWcpAppUrl"],"mappings":"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"}
|
|
@@ -8,8 +8,16 @@ declare class WcpContextWithFeatureFlagsDecoratorImpl implements WcpContext.Inte
|
|
|
8
8
|
getRawLicense(): import("@webiny/wcp/types.js").DecryptedWcpProjectLicense | null;
|
|
9
9
|
getProject(): import("@webiny/wcp/types.js").WcpProject | null;
|
|
10
10
|
getProjectWithFeatureFlags(): {
|
|
11
|
+
orgId: string;
|
|
12
|
+
projectId: string;
|
|
11
13
|
package: {
|
|
12
14
|
features: {
|
|
15
|
+
seats: {
|
|
16
|
+
enabled: true;
|
|
17
|
+
options: {
|
|
18
|
+
maxCount: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
13
21
|
multiTenancy: {
|
|
14
22
|
enabled: true;
|
|
15
23
|
options: {
|
|
@@ -55,16 +63,8 @@ declare class WcpContextWithFeatureFlagsDecoratorImpl implements WcpContext.Inte
|
|
|
55
63
|
lexicalGeneration: boolean | undefined;
|
|
56
64
|
};
|
|
57
65
|
};
|
|
58
|
-
seats: {
|
|
59
|
-
enabled: true;
|
|
60
|
-
options: {
|
|
61
|
-
maxCount: number;
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
66
|
};
|
|
65
67
|
};
|
|
66
|
-
orgId: string;
|
|
67
|
-
projectId: string;
|
|
68
68
|
} | null;
|
|
69
69
|
getProjectEnvironment(): import("@webiny/wcp/types.js").WcpProjectEnvironment | null;
|
|
70
70
|
getProjectLicense(): import("@webiny/wcp/types.js").ILicense;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Container } from "@webiny/di";
|
|
2
|
-
import type { ILicense } from "@webiny/wcp/types.js";
|
|
3
2
|
export declare const WcpContextFeature: {
|
|
4
3
|
name: string;
|
|
5
|
-
register(container: Container, context:
|
|
4
|
+
register(container: Container, context: import("../WcpLicenseProvider.js").IWcpLicenseProvider): void;
|
|
6
5
|
};
|
|
@@ -3,8 +3,8 @@ import { WcpContextImpl } from "./WcpContext.js";
|
|
|
3
3
|
import { WcpContext } from "./abstractions.js";
|
|
4
4
|
const WcpContextFeature = createFeature({
|
|
5
5
|
name: "WcpContext",
|
|
6
|
-
register (container,
|
|
7
|
-
container.registerInstance(WcpContext, new WcpContextImpl(
|
|
6
|
+
register (container, provider) {
|
|
7
|
+
container.registerInstance(WcpContext, new WcpContextImpl(provider));
|
|
8
8
|
}
|
|
9
9
|
});
|
|
10
10
|
export { WcpContextFeature };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/wcp/WcpContext/feature.js","sources":["../../../../src/features/wcp/WcpContext/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { Container } from \"@webiny/di\";\nimport { WcpContextImpl } from \"./WcpContext.js\";\nimport { WcpContext } from \"./abstractions.js\";\nimport type {
|
|
1
|
+
{"version":3,"file":"features/wcp/WcpContext/feature.js","sources":["../../../../src/features/wcp/WcpContext/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { Container } from \"@webiny/di\";\nimport { WcpContextImpl } from \"./WcpContext.js\";\nimport { WcpContext } from \"./abstractions.js\";\nimport type { WcpLicenseProvider } from \"../WcpLicenseProvider.js\";\n\nexport const WcpContextFeature = createFeature({\n name: \"WcpContext\",\n register(container: Container, provider: WcpLicenseProvider.Interface) {\n container.registerInstance(WcpContext, new WcpContextImpl(provider));\n }\n});\n"],"names":["WcpContextFeature","createFeature","container","provider","WcpContext","WcpContextImpl"],"mappings":";;;AAMO,MAAMA,oBAAoBC,cAAc;IAC3C,MAAM;IACN,UAASC,SAAoB,EAAEC,QAAsC;QACjED,UAAU,gBAAgB,CAACE,YAAY,IAAIC,eAAeF;IAC9D;AACJ"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type { Context } from "@webiny/api/types.js";
|
|
2
1
|
import type { ILicense, WcpProject } from "@webiny/wcp/types.js";
|
|
3
2
|
import { IWcpContext } from "./abstractions.js";
|
|
4
|
-
export interface WcpContext extends Context {
|
|
5
|
-
wcp: IWcpContext;
|
|
6
|
-
}
|
|
7
3
|
export type WcpContextObject = IWcpContext;
|
|
8
4
|
export interface CachedWcpProjectLicense {
|
|
9
5
|
cacheKey: string | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ILicense } from "@webiny/wcp/types.js";
|
|
2
2
|
export declare const WcpFeature: {
|
|
3
3
|
name: string;
|
|
4
|
-
register(container: import("@webiny/di").Container, context
|
|
4
|
+
register(container: import("@webiny/di").Container, context?: ILicense | undefined): void;
|
|
5
5
|
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { WcpContextFeature } from "./WcpContext/feature.js";
|
|
3
3
|
import { WcpContextWithFeatureFlagsDecorator } from "./WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js";
|
|
4
|
+
import { WcpLicenseProvider, WcpLicenseProviderImpl } from "./WcpLicenseProvider.js";
|
|
4
5
|
const WcpFeature = createFeature({
|
|
5
6
|
name: "WebinyControlPanel",
|
|
6
|
-
register (container,
|
|
7
|
-
|
|
7
|
+
register (container, initialLicense) {
|
|
8
|
+
const provider = new WcpLicenseProviderImpl(initialLicense);
|
|
9
|
+
container.registerInstance(WcpLicenseProvider, provider);
|
|
10
|
+
WcpContextFeature.register(container, provider);
|
|
8
11
|
container.registerDecorator(WcpContextWithFeatureFlagsDecorator);
|
|
9
12
|
}
|
|
10
13
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/wcp/WcpFeature.js","sources":["../../../src/features/wcp/WcpFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { WcpContextFeature } from \"./WcpContext/feature.js\";\nimport { WcpContextWithFeatureFlagsDecorator } from \"./WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js\";\nimport type { ILicense } from \"@webiny/wcp/types.js\";\n\nexport const WcpFeature = createFeature<ILicense>({\n name: \"WebinyControlPanel\",\n register(container,
|
|
1
|
+
{"version":3,"file":"features/wcp/WcpFeature.js","sources":["../../../src/features/wcp/WcpFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { WcpContextFeature } from \"./WcpContext/feature.js\";\nimport { WcpContextWithFeatureFlagsDecorator } from \"./WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js\";\nimport { WcpLicenseProvider, WcpLicenseProviderImpl } from \"./WcpLicenseProvider.js\";\nimport type { ILicense } from \"@webiny/wcp/types.js\";\n\nexport const WcpFeature = createFeature<ILicense | undefined>({\n name: \"WebinyControlPanel\",\n register(container, initialLicense?) {\n const provider = new WcpLicenseProviderImpl(initialLicense);\n container.registerInstance(WcpLicenseProvider, provider);\n WcpContextFeature.register(container, provider);\n container.registerDecorator(WcpContextWithFeatureFlagsDecorator);\n // Per-request license refresh (RequestInitializer) is registered by api-event-handler-core's\n // registerApiRequestStack, keeping the domain layer free of the transport lifecycle contract.\n }\n});\n"],"names":["WcpFeature","createFeature","container","initialLicense","provider","WcpLicenseProviderImpl","WcpLicenseProvider","WcpContextFeature","WcpContextWithFeatureFlagsDecorator"],"mappings":";;;;AAMO,MAAMA,aAAaC,cAAoC;IAC1D,MAAM;IACN,UAASC,SAAS,EAAEC,cAAe;QAC/B,MAAMC,WAAW,IAAIC,uBAAuBF;QAC5CD,UAAU,gBAAgB,CAACI,oBAAoBF;QAC/CG,kBAAkB,QAAQ,CAACL,WAAWE;QACtCF,UAAU,iBAAiB,CAACM;IAGhC;AACJ"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ILicense } from "@webiny/wcp/types.js";
|
|
2
|
+
export interface IWcpLicenseProvider {
|
|
3
|
+
get(): ILicense;
|
|
4
|
+
refresh(): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export declare const WcpLicenseProvider: import("@webiny/di").Abstraction<IWcpLicenseProvider>;
|
|
7
|
+
export declare namespace WcpLicenseProvider {
|
|
8
|
+
type Interface = IWcpLicenseProvider;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Holds the current WCP license. `get()` is synchronous so the canUse* consumers (IdentityContext,
|
|
12
|
+
* GroupsTeamsAuthorizer, the WCP GraphQL query) stay sync. `refresh()` is driven once per request
|
|
13
|
+
* by WcpLicenseInitializer (a RequestInitializer), BEFORE resolvers run:
|
|
14
|
+
*
|
|
15
|
+
* - It re-reads `loadWcpLicense()`, whose process-global cache rotates ~every 5 minutes, so a
|
|
16
|
+
* license change (upgrade/downgrade/expiry) takes effect mid-Lambda-lifetime instead of only on
|
|
17
|
+
* the next cold start.
|
|
18
|
+
* - Awaiting it per request before resolvers closes the NullLicense race (no window where a
|
|
19
|
+
* resolver sees the placeholder).
|
|
20
|
+
*
|
|
21
|
+
* An optional initial license can be supplied (tests pass the pre-resolved license); otherwise it
|
|
22
|
+
* starts as NullLicense and the first refresh() (before resolvers) installs the real one.
|
|
23
|
+
*/
|
|
24
|
+
export declare class WcpLicenseProviderImpl implements IWcpLicenseProvider {
|
|
25
|
+
private current;
|
|
26
|
+
constructor(initialLicense?: ILicense);
|
|
27
|
+
get(): ILicense;
|
|
28
|
+
refresh(): Promise<void>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
import { NullLicense } from "@webiny/wcp";
|
|
3
|
+
import { loadWcpLicense } from "./loadWcpLicense.js";
|
|
4
|
+
const WcpLicenseProvider = createAbstraction("WcpLicenseProvider");
|
|
5
|
+
class WcpLicenseProviderImpl {
|
|
6
|
+
constructor(initialLicense){
|
|
7
|
+
this.current = initialLicense ?? new NullLicense();
|
|
8
|
+
}
|
|
9
|
+
get() {
|
|
10
|
+
return this.current;
|
|
11
|
+
}
|
|
12
|
+
async refresh() {
|
|
13
|
+
this.current = await loadWcpLicense();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export { WcpLicenseProvider, WcpLicenseProviderImpl };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=WcpLicenseProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/wcp/WcpLicenseProvider.js","sources":["../../../src/features/wcp/WcpLicenseProvider.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { NullLicense } from \"@webiny/wcp\";\nimport type { ILicense } from \"@webiny/wcp/types.js\";\nimport { loadWcpLicense } from \"~/features/wcp/loadWcpLicense.js\";\n\nexport interface IWcpLicenseProvider {\n get(): ILicense;\n refresh(): Promise<void>;\n}\n\nexport const WcpLicenseProvider = createAbstraction<IWcpLicenseProvider>(\"WcpLicenseProvider\");\n\nexport namespace WcpLicenseProvider {\n export type Interface = IWcpLicenseProvider;\n}\n\n/**\n * Holds the current WCP license. `get()` is synchronous so the canUse* consumers (IdentityContext,\n * GroupsTeamsAuthorizer, the WCP GraphQL query) stay sync. `refresh()` is driven once per request\n * by WcpLicenseInitializer (a RequestInitializer), BEFORE resolvers run:\n *\n * - It re-reads `loadWcpLicense()`, whose process-global cache rotates ~every 5 minutes, so a\n * license change (upgrade/downgrade/expiry) takes effect mid-Lambda-lifetime instead of only on\n * the next cold start.\n * - Awaiting it per request before resolvers closes the NullLicense race (no window where a\n * resolver sees the placeholder).\n *\n * An optional initial license can be supplied (tests pass the pre-resolved license); otherwise it\n * starts as NullLicense and the first refresh() (before resolvers) installs the real one.\n */\nexport class WcpLicenseProviderImpl implements IWcpLicenseProvider {\n private current: ILicense;\n\n constructor(initialLicense?: ILicense) {\n this.current = initialLicense ?? new NullLicense();\n }\n\n get(): ILicense {\n return this.current;\n }\n\n async refresh(): Promise<void> {\n this.current = await loadWcpLicense();\n }\n}\n"],"names":["WcpLicenseProvider","createAbstraction","WcpLicenseProviderImpl","initialLicense","NullLicense","loadWcpLicense"],"mappings":";;;AAUO,MAAMA,qBAAqBC,kBAAuC;AAoBlE,MAAMC;IAGT,YAAYC,cAAyB,CAAE;QACnC,IAAI,CAAC,OAAO,GAAGA,kBAAkB,IAAIC;IACzC;IAEA,MAAgB;QACZ,OAAO,IAAI,CAAC,OAAO;IACvB;IAEA,MAAM,UAAyB;QAC3B,IAAI,CAAC,OAAO,GAAG,MAAMC;IACzB;AACJ"}
|
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
import { License, NullLicense, getWcpProjectEnvironment, getWcpProjectLicense } from "@webiny/wcp";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
2
|
+
import { getWcpProjectLicenseCacheKey } from "./WcpContext/utils.js";
|
|
3
|
+
function resolveWcpProjectEnvironment() {
|
|
4
|
+
const fromBlob = getWcpProjectEnvironment();
|
|
5
|
+
if (fromBlob) return fromBlob;
|
|
6
|
+
const projectId = process.env.WEBINY_PROJECT_ID || process.env.WCP_PROJECT_ID;
|
|
7
|
+
const apiKey = process.env.WEBINY_PROJECT_API_KEY || process.env.WCP_PROJECT_ENVIRONMENT_API_KEY;
|
|
8
|
+
if (!projectId || !apiKey) return null;
|
|
9
|
+
const [orgId, project] = projectId.split("/");
|
|
10
|
+
if (!orgId || !project) return null;
|
|
11
|
+
return {
|
|
12
|
+
id: "",
|
|
13
|
+
apiKey,
|
|
14
|
+
org: {
|
|
15
|
+
id: orgId
|
|
16
|
+
},
|
|
17
|
+
project: {
|
|
18
|
+
id: project
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const wcpProjectEnvironment = resolveWcpProjectEnvironment();
|
|
8
23
|
const cachedLicense = {
|
|
9
24
|
cacheKey: null,
|
|
10
25
|
project: null,
|
|
11
26
|
license: new NullLicense()
|
|
12
27
|
};
|
|
13
|
-
async function
|
|
28
|
+
async function loadWcpLicense(testProjectLicense) {
|
|
14
29
|
if (testProjectLicense) cachedLicense.license = License.fromLicenseDto(testProjectLicense);
|
|
15
30
|
else if (wcpProjectEnvironment) {
|
|
16
31
|
const currentCacheKey = getWcpProjectLicenseCacheKey();
|
|
@@ -31,16 +46,6 @@ async function loadLicense(testProjectLicense) {
|
|
|
31
46
|
}
|
|
32
47
|
return cachedLicense.license;
|
|
33
48
|
}
|
|
34
|
-
|
|
35
|
-
const plugin = createRegisterExtensionPlugin(async (context)=>{
|
|
36
|
-
const license = await loadLicense(params.testProjectLicense);
|
|
37
|
-
WcpFeature.register(context.container, license);
|
|
38
|
-
context.wcp = new LegacyWcpContext(context.container);
|
|
39
|
-
context.plugins.register(createWcpGraphQL());
|
|
40
|
-
});
|
|
41
|
-
plugin.name = "wcp.context.create";
|
|
42
|
-
return plugin;
|
|
43
|
-
};
|
|
44
|
-
export { createWcpContext };
|
|
49
|
+
export { loadWcpLicense };
|
|
45
50
|
|
|
46
|
-
//# sourceMappingURL=
|
|
51
|
+
//# sourceMappingURL=loadWcpLicense.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/wcp/loadWcpLicense.js","sources":["../../../src/features/wcp/loadWcpLicense.ts"],"sourcesContent":["import { getWcpProjectLicense, getWcpProjectEnvironment, NullLicense } from \"@webiny/wcp\";\nimport type {\n DecryptedWcpProjectLicense,\n ILicense,\n WcpProjectEnvironment\n} from \"@webiny/wcp/types.js\";\nimport { License } from \"@webiny/wcp\";\nimport type { CachedWcpProjectLicense } from \"~/features/wcp/WcpContext/types.js\";\nimport { getWcpProjectLicenseCacheKey } from \"~/features/wcp/WcpContext/utils.js\";\n\n/**\n * Resolve the WCP project environment used to fetch the license. Prefer the CLI-computed\n * WCP_PROJECT_ENVIRONMENT blob (set by `applyWcpEnvVars` during `webiny serve` and the AWS deploy).\n * When it's absent — a CLI-less self-hosted deploy that boots the built handler directly (e.g.\n * `node start.mjs`) — derive the same org, project and api key straight from the runtime env, so a\n * fresh license can still be fetched.\n */\nfunction resolveWcpProjectEnvironment(): WcpProjectEnvironment | null {\n const fromBlob = getWcpProjectEnvironment();\n if (fromBlob) {\n return fromBlob;\n }\n\n const projectId = process.env.WEBINY_PROJECT_ID || process.env.WCP_PROJECT_ID;\n const apiKey =\n process.env.WEBINY_PROJECT_API_KEY || process.env.WCP_PROJECT_ENVIRONMENT_API_KEY;\n if (!projectId || !apiKey) {\n return null;\n }\n\n // WEBINY_PROJECT_ID has an \"orgId/projectId\" shape.\n const [orgId, project] = projectId.split(\"/\");\n if (!orgId || !project) {\n return null;\n }\n\n // `id` is intentionally empty. The WCP backend identifies the specific project environment\n // from the api key (sent as the request's authorization header); the license fetch only uses\n // org/project (URL path) + apiKey (auth), never the environment id. So there's nothing to fill.\n return { id: \"\", apiKey, org: { id: orgId }, project: { id: project } };\n}\n\nconst wcpProjectEnvironment = resolveWcpProjectEnvironment();\n\nconst cachedLicense: CachedWcpProjectLicense = {\n cacheKey: null,\n project: null,\n license: new NullLicense()\n};\n\nexport async function loadWcpLicense(\n testProjectLicense?: DecryptedWcpProjectLicense\n): Promise<ILicense> {\n if (testProjectLicense) {\n cachedLicense.license = License.fromLicenseDto(testProjectLicense);\n } else if (wcpProjectEnvironment) {\n const currentCacheKey = getWcpProjectLicenseCacheKey();\n if (cachedLicense.cacheKey !== currentCacheKey) {\n cachedLicense.cacheKey = currentCacheKey;\n // Pull the project license from the WCP API.\n const decryptedLicenseDto = await getWcpProjectLicense({\n orgId: wcpProjectEnvironment.org.id,\n projectId: wcpProjectEnvironment.project.id,\n projectEnvironmentApiKey: wcpProjectEnvironment.apiKey\n });\n\n if (decryptedLicenseDto) {\n cachedLicense.project = {\n orgId: decryptedLicenseDto.orgId,\n projectId: decryptedLicenseDto.projectId,\n package: decryptedLicenseDto.package\n };\n }\n\n cachedLicense.license = License.fromLicenseDto(decryptedLicenseDto);\n }\n }\n\n return cachedLicense.license;\n}\n"],"names":["resolveWcpProjectEnvironment","fromBlob","getWcpProjectEnvironment","projectId","process","apiKey","orgId","project","wcpProjectEnvironment","cachedLicense","NullLicense","loadWcpLicense","testProjectLicense","License","currentCacheKey","getWcpProjectLicenseCacheKey","decryptedLicenseDto","getWcpProjectLicense"],"mappings":";;AAiBA,SAASA;IACL,MAAMC,WAAWC;IACjB,IAAID,UACA,OAAOA;IAGX,MAAME,YAAYC,QAAQ,GAAG,CAAC,iBAAiB,IAAIA,QAAQ,GAAG,CAAC,cAAc;IAC7E,MAAMC,SACFD,QAAQ,GAAG,CAAC,sBAAsB,IAAIA,QAAQ,GAAG,CAAC,+BAA+B;IACrF,IAAI,CAACD,aAAa,CAACE,QACf,OAAO;IAIX,MAAM,CAACC,OAAOC,QAAQ,GAAGJ,UAAU,KAAK,CAAC;IACzC,IAAI,CAACG,SAAS,CAACC,SACX,OAAO;IAMX,OAAO;QAAE,IAAI;QAAIF;QAAQ,KAAK;YAAE,IAAIC;QAAM;QAAG,SAAS;YAAE,IAAIC;QAAQ;IAAE;AAC1E;AAEA,MAAMC,wBAAwBR;AAE9B,MAAMS,gBAAyC;IAC3C,UAAU;IACV,SAAS;IACT,SAAS,IAAIC;AACjB;AAEO,eAAeC,eAClBC,kBAA+C;IAE/C,IAAIA,oBACAH,cAAc,OAAO,GAAGI,QAAQ,cAAc,CAACD;SAC5C,IAAIJ,uBAAuB;QAC9B,MAAMM,kBAAkBC;QACxB,IAAIN,cAAc,QAAQ,KAAKK,iBAAiB;YAC5CL,cAAc,QAAQ,GAAGK;YAEzB,MAAME,sBAAsB,MAAMC,qBAAqB;gBACnD,OAAOT,sBAAsB,GAAG,CAAC,EAAE;gBACnC,WAAWA,sBAAsB,OAAO,CAAC,EAAE;gBAC3C,0BAA0BA,sBAAsB,MAAM;YAC1D;YAEA,IAAIQ,qBACAP,cAAc,OAAO,GAAG;gBACpB,OAAOO,oBAAoB,KAAK;gBAChC,WAAWA,oBAAoB,SAAS;gBACxC,SAASA,oBAAoB,OAAO;YACxC;YAGJP,cAAc,OAAO,GAAGI,QAAQ,cAAc,CAACG;QACnD;IACJ;IAEA,OAAOP,cAAc,OAAO;AAChC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
|
|
3
|
+
/**
|
|
4
|
+
* The base of the core API schema: the root Query/Mutation, shared scalars and their
|
|
5
|
+
* implementations, and the shared Error/BooleanResponse types. The actual domains (security,
|
|
6
|
+
* users, system, wcp) are their own CoreGraphQLSchemaFactory implementations — order between
|
|
7
|
+
* core factories does not matter, the engine merges all typeDefs in a single pass.
|
|
8
|
+
*/
|
|
9
|
+
declare class ApiCoreSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {
|
|
10
|
+
execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
|
|
11
|
+
}
|
|
12
|
+
export declare const ApiCoreSchemaFactory: typeof ApiCoreSchemaFactoryImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-graphql/graphql/abstractions.core").ICoreGraphQLSchemaFactory>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import { AnyScalar, DateScalar, DateTimeScalar, IconScalar, JsonScalar, LongScalar, NumberScalar, RefInputScalar, TimeScalar } from "@webiny/api-graphql/builtInTypes/index.js";
|
|
3
|
+
const BASE_TYPES = `
|
|
4
|
+
type Query
|
|
5
|
+
type Mutation
|
|
6
|
+
scalar JSON
|
|
7
|
+
scalar Long
|
|
8
|
+
scalar Icon
|
|
9
|
+
scalar RefInput
|
|
10
|
+
scalar Number
|
|
11
|
+
scalar Any
|
|
12
|
+
scalar Date
|
|
13
|
+
scalar DateTime
|
|
14
|
+
scalar Time
|
|
15
|
+
|
|
16
|
+
type Error {
|
|
17
|
+
code: String
|
|
18
|
+
message: String
|
|
19
|
+
data: JSON
|
|
20
|
+
stack: String
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type BooleanResponse {
|
|
24
|
+
data: Boolean
|
|
25
|
+
error: Error
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
const SCALAR_RESOLVERS = {
|
|
29
|
+
JSON: JsonScalar,
|
|
30
|
+
Long: LongScalar,
|
|
31
|
+
Icon: IconScalar,
|
|
32
|
+
RefInput: RefInputScalar,
|
|
33
|
+
Number: NumberScalar,
|
|
34
|
+
Any: AnyScalar,
|
|
35
|
+
DateTime: DateTimeScalar,
|
|
36
|
+
Date: DateScalar,
|
|
37
|
+
Time: TimeScalar
|
|
38
|
+
};
|
|
39
|
+
class ApiCoreSchemaFactoryImpl {
|
|
40
|
+
async execute(builder) {
|
|
41
|
+
builder.addTypeDefs(BASE_TYPES);
|
|
42
|
+
builder.addLegacyResolvers(SCALAR_RESOLVERS);
|
|
43
|
+
return builder;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const ApiCoreSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({
|
|
47
|
+
implementation: ApiCoreSchemaFactoryImpl,
|
|
48
|
+
dependencies: []
|
|
49
|
+
});
|
|
50
|
+
export { ApiCoreSchemaFactory };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=ApiCoreSchemaFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/ApiCoreSchemaFactory.js","sources":["../../src/graphql/ApiCoreSchemaFactory.ts"],"sourcesContent":["import { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport {\n JsonScalar,\n LongScalar,\n IconScalar,\n RefInputScalar,\n NumberScalar,\n AnyScalar,\n DateTimeScalar,\n DateScalar,\n TimeScalar\n} from \"@webiny/api-graphql/builtInTypes/index.js\";\n\nconst BASE_TYPES = `\n type Query\n type Mutation\n scalar JSON\n scalar Long\n scalar Icon\n scalar RefInput\n scalar Number\n scalar Any\n scalar Date\n scalar DateTime\n scalar Time\n\n type Error {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type BooleanResponse {\n data: Boolean\n error: Error\n }\n`;\n\nconst SCALAR_RESOLVERS: Record<string, any> = {\n JSON: JsonScalar,\n Long: LongScalar,\n Icon: IconScalar,\n RefInput: RefInputScalar,\n Number: NumberScalar,\n Any: AnyScalar,\n DateTime: DateTimeScalar,\n Date: DateScalar,\n Time: TimeScalar\n};\n\n/**\n * The base of the core API schema: the root Query/Mutation, shared scalars and their\n * implementations, and the shared Error/BooleanResponse types. The actual domains (security,\n * users, system, wcp) are their own CoreGraphQLSchemaFactory implementations — order between\n * core factories does not matter, the engine merges all typeDefs in a single pass.\n */\nclass ApiCoreSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(BASE_TYPES);\n\n // Scalar implementations (scalar type objects, not container-resolving resolvers).\n builder.addLegacyResolvers(SCALAR_RESOLVERS);\n\n return builder;\n }\n}\n\nexport const ApiCoreSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({\n implementation: ApiCoreSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["BASE_TYPES","SCALAR_RESOLVERS","JsonScalar","LongScalar","IconScalar","RefInputScalar","NumberScalar","AnyScalar","DateTimeScalar","DateScalar","TimeScalar","ApiCoreSchemaFactoryImpl","builder","ApiCoreSchemaFactory","CoreGraphQLSchemaFactory"],"mappings":";;AAcA,MAAMA,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;AAwBpB,CAAC;AAED,MAAMC,mBAAwC;IAC1C,MAAMC;IACN,MAAMC;IACN,MAAMC;IACN,UAAUC;IACV,QAAQC;IACR,KAAKC;IACL,UAAUC;IACV,MAAMC;IACN,MAAMC;AACV;AAQA,MAAMC;IACF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAACZ;QAGpBY,QAAQ,kBAAkB,CAACX;QAE3B,OAAOW;IACX;AACJ;AAEO,MAAMC,uBAAuBC,yBAAyB,oBAAoB,CAAC;IAC9E,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/security/NotAuthorizedResponse.js","sources":["../../../src/graphql/security/NotAuthorizedResponse.ts"],"sourcesContent":["import { ErrorResponse } from \"@webiny/
|
|
1
|
+
{"version":3,"file":"graphql/security/NotAuthorizedResponse.js","sources":["../../../src/graphql/security/NotAuthorizedResponse.ts"],"sourcesContent":["import { ErrorResponse } from \"@webiny/api-graphql/responses.js\";\n\ninterface NotAuthorizedResponseArgsType {\n message: string;\n code: string | null;\n data: any | null;\n}\n\n/** GraphQL not-authorized response helper. */\nexport class NotAuthorizedResponse extends ErrorResponse {\n constructor({ message, code, data }: Partial<NotAuthorizedResponseArgsType> = {}) {\n super({\n message: message || \"Not authorized!\",\n code: code || \"SECURITY_NOT_AUTHORIZED\",\n data\n });\n }\n}\n\nexport default NotAuthorizedResponse;\n"],"names":["NotAuthorizedResponse","ErrorResponse","message","code","data"],"mappings":";AASO,MAAMA,8BAA8BC;IACvC,YAAY,EAAEC,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAA0C,GAAG,CAAC,CAAC,CAAE;QAC9E,KAAK,CAAC;YACF,SAASF,WAAW;YACpB,MAAMC,QAAQ;YACdC;QACJ;IACJ;AACJ;AAEA,uCAAeJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
|
|
3
|
+
/**
|
|
4
|
+
* The security schema is one cohesive domain (it shares the SecurityQuery / SecurityMutation /
|
|
5
|
+
* SecurityError / SecurityBooleanResponse base types), composed of five internal parts:
|
|
6
|
+
* base, team, apiKey, role, identity.
|
|
7
|
+
*/
|
|
8
|
+
declare class SecuritySchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {
|
|
9
|
+
execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
|
|
10
|
+
}
|
|
11
|
+
export declare const SecuritySchemaFactory: typeof SecuritySchemaFactoryImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-graphql/graphql/abstractions.core.js").ICoreGraphQLSchemaFactory>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import { addSecurityBaseSchema } from "./addSecurityBaseSchema.js";
|
|
3
|
+
import { addApiKeySchema } from "./addApiKeySchema.js";
|
|
4
|
+
import { addRoleSchema } from "./addRoleSchema.js";
|
|
5
|
+
import { addTeamSchema } from "./addTeamSchema.js";
|
|
6
|
+
import { addIdentitySchema } from "./addIdentitySchema.js";
|
|
7
|
+
class SecuritySchemaFactoryImpl {
|
|
8
|
+
async execute(builder) {
|
|
9
|
+
addSecurityBaseSchema(builder);
|
|
10
|
+
addTeamSchema(builder);
|
|
11
|
+
addApiKeySchema(builder);
|
|
12
|
+
addRoleSchema(builder);
|
|
13
|
+
addIdentitySchema(builder);
|
|
14
|
+
return builder;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const SecuritySchemaFactory = CoreGraphQLSchemaFactory.createImplementation({
|
|
18
|
+
implementation: SecuritySchemaFactoryImpl,
|
|
19
|
+
dependencies: []
|
|
20
|
+
});
|
|
21
|
+
export { SecuritySchemaFactory };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=SecuritySchemaFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/security/SecuritySchemaFactory.js","sources":["../../../src/graphql/security/SecuritySchemaFactory.ts"],"sourcesContent":["import { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { addSecurityBaseSchema } from \"./addSecurityBaseSchema.js\";\nimport { addApiKeySchema } from \"./addApiKeySchema.js\";\nimport { addRoleSchema } from \"./addRoleSchema.js\";\nimport { addTeamSchema } from \"./addTeamSchema.js\";\nimport { addIdentitySchema } from \"./addIdentitySchema.js\";\n\n/**\n * The security schema is one cohesive domain (it shares the SecurityQuery / SecurityMutation /\n * SecurityError / SecurityBooleanResponse base types), composed of five internal parts:\n * base, team, apiKey, role, identity.\n */\nclass SecuritySchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n addSecurityBaseSchema(builder);\n addTeamSchema(builder);\n addApiKeySchema(builder);\n addRoleSchema(builder);\n addIdentitySchema(builder);\n\n return builder;\n }\n}\n\nexport const SecuritySchemaFactory = CoreGraphQLSchemaFactory.createImplementation({\n implementation: SecuritySchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["SecuritySchemaFactoryImpl","builder","addSecurityBaseSchema","addTeamSchema","addApiKeySchema","addRoleSchema","addIdentitySchema","SecuritySchemaFactory","CoreGraphQLSchemaFactory"],"mappings":";;;;;;AAaA,MAAMA;IACF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EC,sBAAsBD;QACtBE,cAAcF;QACdG,gBAAgBH;QAChBI,cAAcJ;QACdK,kBAAkBL;QAElB,OAAOA;IACX;AACJ;AAEO,MAAMM,wBAAwBC,yBAAyB,oBAAoB,CAAC;IAC/E,gBAAgBR;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { ErrorResponse, Response } from "@webiny/
|
|
2
|
-
import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/plugins/GraphQLSchemaPlugin.js";
|
|
1
|
+
import { ErrorResponse, Response } from "@webiny/api-graphql/responses.js";
|
|
3
2
|
import { CreateApiKeyUseCase } from "../../features/security/apiKeys/CreateApiKey/index.js";
|
|
4
3
|
import { UpdateApiKeyUseCase } from "../../features/security/apiKeys/UpdateApiKey/index.js";
|
|
5
4
|
import { DeleteApiKeyUseCase } from "../../features/security/apiKeys/DeleteApiKey/index.js";
|
|
6
5
|
import { ListApiKeysUseCase } from "../../features/security/apiKeys/ListApiKeys/index.js";
|
|
7
6
|
import { GetApiKeyUseCase } from "../../features/security/apiKeys/GetApiKey/index.js";
|
|
8
|
-
const
|
|
9
|
-
|
|
7
|
+
const addApiKeySchema = (builder)=>{
|
|
8
|
+
builder.addTypeDefs(`
|
|
10
9
|
type SecurityApiKey {
|
|
11
10
|
id: ID
|
|
12
11
|
name: String
|
|
@@ -47,44 +46,63 @@ const apiKey_gql = new GraphQLSchemaPlugin({
|
|
|
47
46
|
updateApiKey(id: ID!, data: SecurityApiKeyInput!): SecurityApiKeyResponse
|
|
48
47
|
deleteApiKey(id: ID!): SecurityBooleanResponse
|
|
49
48
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
`);
|
|
50
|
+
builder.addResolver({
|
|
51
|
+
path: "SecurityQuery.listApiKeys",
|
|
52
|
+
dependencies: [
|
|
53
|
+
ListApiKeysUseCase
|
|
54
|
+
],
|
|
55
|
+
resolver: (list)=>async ()=>{
|
|
55
56
|
const result = await list.execute();
|
|
56
57
|
if (result.isOk()) return new Response(result.value);
|
|
57
58
|
return new ErrorResponse(result.error);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
builder.addResolver({
|
|
62
|
+
path: "SecurityQuery.getApiKey",
|
|
63
|
+
dependencies: [
|
|
64
|
+
GetApiKeyUseCase
|
|
65
|
+
],
|
|
66
|
+
resolver: (getById)=>async ({ args })=>{
|
|
61
67
|
const result = await getById.execute(args.id);
|
|
62
68
|
if (result.isOk()) return new Response(result.value);
|
|
63
69
|
return new ErrorResponse(result.error);
|
|
64
70
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
});
|
|
72
|
+
builder.addResolver({
|
|
73
|
+
path: "SecurityMutation.createApiKey",
|
|
74
|
+
dependencies: [
|
|
75
|
+
CreateApiKeyUseCase
|
|
76
|
+
],
|
|
77
|
+
resolver: (createApiKey)=>async ({ args })=>{
|
|
69
78
|
const result = await createApiKey.execute(args.data);
|
|
70
79
|
if (result.isOk()) return new Response(result.value);
|
|
71
80
|
return new ErrorResponse(result.error);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
builder.addResolver({
|
|
84
|
+
path: "SecurityMutation.updateApiKey",
|
|
85
|
+
dependencies: [
|
|
86
|
+
UpdateApiKeyUseCase
|
|
87
|
+
],
|
|
88
|
+
resolver: (updateApiKey)=>async ({ args })=>{
|
|
75
89
|
const result = await updateApiKey.execute(args.id, args.data);
|
|
76
90
|
if (result.isOk()) return new Response(result.value);
|
|
77
91
|
return new ErrorResponse(result.error);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
builder.addResolver({
|
|
95
|
+
path: "SecurityMutation.deleteApiKey",
|
|
96
|
+
dependencies: [
|
|
97
|
+
DeleteApiKeyUseCase
|
|
98
|
+
],
|
|
99
|
+
resolver: (deleteApiKey)=>async ({ args })=>{
|
|
81
100
|
const result = await deleteApiKey.execute(args.id);
|
|
82
101
|
if (result.isOk()) return new Response(true);
|
|
83
102
|
return new ErrorResponse(result.error);
|
|
84
103
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
export default apiKey_gql;
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
export { addApiKeySchema };
|
|
89
107
|
|
|
90
|
-
//# sourceMappingURL=
|
|
108
|
+
//# sourceMappingURL=addApiKeySchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/security/addApiKeySchema.js","sources":["../../../src/graphql/security/addApiKeySchema.ts"],"sourcesContent":["import { Response, ErrorResponse } from \"@webiny/api-graphql/responses.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { CreateApiKeyUseCase } from \"~/features/security/apiKeys/CreateApiKey/index.js\";\nimport { UpdateApiKeyUseCase } from \"~/features/security/apiKeys/UpdateApiKey/index.js\";\nimport { DeleteApiKeyUseCase } from \"~/features/security/apiKeys/DeleteApiKey/index.js\";\nimport { ListApiKeysUseCase } from \"~/features/security/apiKeys/ListApiKeys/index.js\";\nimport { GetApiKeyUseCase } from \"~/features/security/apiKeys/GetApiKey/index.js\";\n\nexport const addApiKeySchema = (builder: IGraphQLSchemaBuilder): void => {\n builder.addTypeDefs(/* GraphQL */ `\n type SecurityApiKey {\n id: ID\n name: String\n slug: String\n description: String\n token: String\n permissions: [JSON]\n createdOn: DateTime\n createdBy: SecurityCreatedBy\n }\n\n input SecurityApiKeyInput {\n id: ID\n name: String!\n slug: String\n description: String\n token: String\n permissions: [JSON]!\n }\n\n type SecurityApiKeyResponse {\n data: SecurityApiKey\n error: SecurityError\n }\n\n type SecurityApiKeyListResponse {\n data: [SecurityApiKey!]\n error: SecurityError\n }\n\n extend type SecurityQuery {\n listApiKeys: SecurityApiKeyListResponse\n getApiKey(id: ID!): SecurityApiKeyResponse\n }\n\n extend type SecurityMutation {\n createApiKey(data: SecurityApiKeyInput!): SecurityApiKeyResponse\n updateApiKey(id: ID!, data: SecurityApiKeyInput!): SecurityApiKeyResponse\n deleteApiKey(id: ID!): SecurityBooleanResponse\n }\n `);\n\n builder.addResolver({\n path: \"SecurityQuery.listApiKeys\",\n dependencies: [ListApiKeysUseCase],\n resolver: (list: ListApiKeysUseCase.Interface) => async () => {\n const result = await list.execute();\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n }\n });\n\n builder.addResolver<{ id: string }>({\n path: \"SecurityQuery.getApiKey\",\n dependencies: [GetApiKeyUseCase],\n resolver:\n (getById: GetApiKeyUseCase.Interface) =>\n async ({ args }) => {\n const result = await getById.execute(args.id);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n }\n });\n\n builder.addResolver<{ data: any }>({\n path: \"SecurityMutation.createApiKey\",\n dependencies: [CreateApiKeyUseCase],\n resolver:\n (createApiKey: CreateApiKeyUseCase.Interface) =>\n async ({ args }) => {\n const result = await createApiKey.execute(args.data);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n }\n });\n\n builder.addResolver<{ id: string; data: any }>({\n path: \"SecurityMutation.updateApiKey\",\n dependencies: [UpdateApiKeyUseCase],\n resolver:\n (updateApiKey: UpdateApiKeyUseCase.Interface) =>\n async ({ args }) => {\n const result = await updateApiKey.execute(args.id, args.data);\n\n if (result.isOk()) {\n return new Response(result.value);\n }\n return new ErrorResponse(result.error);\n }\n });\n\n builder.addResolver<{ id: string }>({\n path: \"SecurityMutation.deleteApiKey\",\n dependencies: [DeleteApiKeyUseCase],\n resolver:\n (deleteApiKey: DeleteApiKeyUseCase.Interface) =>\n async ({ args }) => {\n const result = await deleteApiKey.execute(args.id);\n\n if (result.isOk()) {\n return new Response(true);\n }\n return new ErrorResponse(result.error);\n }\n });\n};\n"],"names":["addApiKeySchema","builder","ListApiKeysUseCase","list","result","Response","ErrorResponse","GetApiKeyUseCase","getById","args","CreateApiKeyUseCase","createApiKey","UpdateApiKeyUseCase","updateApiKey","DeleteApiKeyUseCase","deleteApiKey"],"mappings":";;;;;;AAQO,MAAMA,kBAAkB,CAACC;IAC5BA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAyCnC,CAAC;IAEDA,QAAQ,WAAW,CAAC;QAChB,MAAM;QACN,cAAc;YAACC;SAAmB;QAClC,UAAU,CAACC,OAAuC;gBAC9C,MAAMC,SAAS,MAAMD,KAAK,OAAO;gBAEjC,IAAIC,OAAO,IAAI,IACX,OAAO,IAAIC,SAASD,OAAO,KAAK;gBAEpC,OAAO,IAAIE,cAAcF,OAAO,KAAK;YACzC;IACJ;IAEAH,QAAQ,WAAW,CAAiB;QAChC,MAAM;QACN,cAAc;YAACM;SAAiB;QAChC,UACI,CAACC,UACD,OAAO,EAAEC,IAAI,EAAE;gBACX,MAAML,SAAS,MAAMI,QAAQ,OAAO,CAACC,KAAK,EAAE;gBAE5C,IAAIL,OAAO,IAAI,IACX,OAAO,IAAIC,SAASD,OAAO,KAAK;gBAEpC,OAAO,IAAIE,cAAcF,OAAO,KAAK;YACzC;IACR;IAEAH,QAAQ,WAAW,CAAgB;QAC/B,MAAM;QACN,cAAc;YAACS;SAAoB;QACnC,UACI,CAACC,eACD,OAAO,EAAEF,IAAI,EAAE;gBACX,MAAML,SAAS,MAAMO,aAAa,OAAO,CAACF,KAAK,IAAI;gBAEnD,IAAIL,OAAO,IAAI,IACX,OAAO,IAAIC,SAASD,OAAO,KAAK;gBAEpC,OAAO,IAAIE,cAAcF,OAAO,KAAK;YACzC;IACR;IAEAH,QAAQ,WAAW,CAA4B;QAC3C,MAAM;QACN,cAAc;YAACW;SAAoB;QACnC,UACI,CAACC,eACD,OAAO,EAAEJ,IAAI,EAAE;gBACX,MAAML,SAAS,MAAMS,aAAa,OAAO,CAACJ,KAAK,EAAE,EAAEA,KAAK,IAAI;gBAE5D,IAAIL,OAAO,IAAI,IACX,OAAO,IAAIC,SAASD,OAAO,KAAK;gBAEpC,OAAO,IAAIE,cAAcF,OAAO,KAAK;YACzC;IACR;IAEAH,QAAQ,WAAW,CAAiB;QAChC,MAAM;QACN,cAAc;YAACa;SAAoB;QACnC,UACI,CAACC,eACD,OAAO,EAAEN,IAAI,EAAE;gBACX,MAAML,SAAS,MAAMW,aAAa,OAAO,CAACN,KAAK,EAAE;gBAEjD,IAAIL,OAAO,IAAI,IACX,OAAO,IAAIC,SAAS;gBAExB,OAAO,IAAIC,cAAcF,OAAO,KAAK;YACzC;IACR;AACJ"}
|