@webiny/api-core 0.0.0-unstable.0d717d18dd → 0.0.0-unstable.33e4fd9647
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.js +12 -0
- package/ApiCoreFeature.js.map +1 -1
- package/exports/api/tasks.d.ts +1 -0
- package/exports/api/tasks.js +1 -1
- package/exports/api.d.ts +1 -1
- package/exports/api.js +1 -1
- package/features/ai/Ai.d.ts +3 -1
- package/features/ai/Ai.js +36 -28
- package/features/ai/Ai.js.map +1 -1
- package/features/ai/AiModelRegistry.d.ts +14 -0
- package/features/ai/AiModelRegistry.js +39 -0
- package/features/ai/AiModelRegistry.js.map +1 -0
- package/features/ai/AiSdkToolHandlerResolver.d.ts +11 -0
- package/features/ai/AiSdkToolHandlerResolver.js +19 -0
- package/features/ai/AiSdkToolHandlerResolver.js.map +1 -0
- package/features/ai/AiSdkTools.d.ts +4 -3
- package/features/ai/AiSdkTools.js +11 -9
- package/features/ai/AiSdkTools.js.map +1 -1
- package/features/ai/AnthropicSdkFactory.js +12 -4
- package/features/ai/AnthropicSdkFactory.js.map +1 -1
- package/features/ai/DEVELOPERS.md +183 -0
- package/features/ai/GoogleSdkFactory.d.ts +10 -0
- package/features/ai/GoogleSdkFactory.js +65 -0
- package/features/ai/GoogleSdkFactory.js.map +1 -0
- package/features/ai/OpenAiSdkFactory.js +51 -11
- package/features/ai/OpenAiSdkFactory.js.map +1 -1
- package/features/ai/OpenRouterSdkFactory.d.ts +10 -0
- package/features/ai/OpenRouterSdkFactory.js +112 -0
- package/features/ai/OpenRouterSdkFactory.js.map +1 -0
- package/features/ai/RemoteAiModelCatalog.d.ts +13 -0
- package/features/ai/RemoteAiModelCatalog.js +74 -0
- package/features/ai/RemoteAiModelCatalog.js.map +1 -0
- package/features/ai/abstractions.d.ts +102 -7
- package/features/ai/abstractions.js +6 -2
- package/features/ai/abstractions.js.map +1 -1
- package/features/ai/feature.js +10 -0
- package/features/ai/feature.js.map +1 -1
- package/features/ai/index.d.ts +2 -4
- package/features/ai/index.js +1 -1
- package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
- package/features/dateFormatter/DefaultDateFormatter.js +20 -0
- package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
- package/features/dateFormatter/abstractions.d.ts +13 -0
- package/features/dateFormatter/abstractions.js +5 -0
- package/features/dateFormatter/abstractions.js.map +1 -0
- package/features/dateFormatter/feature.d.ts +4 -0
- package/features/dateFormatter/feature.js +11 -0
- package/features/dateFormatter/feature.js.map +1 -0
- package/features/dateFormatter/index.d.ts +3 -0
- package/features/dateFormatter/index.js +2 -0
- package/features/debugger/Debugger.d.ts +30 -0
- package/features/debugger/Debugger.js +142 -0
- package/features/debugger/Debugger.js.map +1 -0
- package/features/debugger/DebuggerRouteDecorator.d.ts +45 -0
- package/features/debugger/DebuggerRouteDecorator.js +107 -0
- package/features/debugger/DebuggerRouteDecorator.js.map +1 -0
- package/features/debugger/GraphQLDebuggerTransport.d.ts +28 -0
- package/features/debugger/GraphQLDebuggerTransport.js +45 -0
- package/features/debugger/GraphQLDebuggerTransport.js.map +1 -0
- package/features/debugger/__tests__/matchNamespace.test.d.ts +1 -0
- package/features/debugger/__tests__/matchNamespace.test.js +68 -0
- package/features/debugger/__tests__/matchNamespace.test.js.map +1 -0
- package/features/debugger/__tests__/serialize.test.d.ts +1 -0
- package/features/debugger/__tests__/serialize.test.js +220 -0
- package/features/debugger/__tests__/serialize.test.js.map +1 -0
- package/features/debugger/abstractions.d.ts +100 -0
- package/features/debugger/abstractions.js +6 -0
- package/features/debugger/abstractions.js.map +1 -0
- package/features/debugger/feature.d.ts +5 -0
- package/features/debugger/feature.js +15 -0
- package/features/debugger/feature.js.map +1 -0
- package/features/debugger/index.d.ts +12 -0
- package/features/debugger/index.js +7 -0
- package/features/debugger/limits.d.ts +18 -0
- package/features/debugger/limits.js +11 -0
- package/features/debugger/limits.js.map +1 -0
- package/features/debugger/matchNamespace.d.ts +14 -0
- package/features/debugger/matchNamespace.js +35 -0
- package/features/debugger/matchNamespace.js.map +1 -0
- package/features/debugger/parseNamespaceHeader.d.ts +7 -0
- package/features/debugger/parseNamespaceHeader.js +16 -0
- package/features/debugger/parseNamespaceHeader.js.map +1 -0
- package/features/debugger/permissions.d.ts +14 -0
- package/features/debugger/permissions.js +8 -0
- package/features/debugger/permissions.js.map +1 -0
- package/features/debugger/permissionsSchema.d.ts +17 -0
- package/features/debugger/permissionsSchema.js +18 -0
- package/features/debugger/permissionsSchema.js.map +1 -0
- package/features/debugger/serialize.d.ts +11 -0
- package/features/debugger/serialize.js +121 -0
- package/features/debugger/serialize.js.map +1 -0
- package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
- package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
- package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
- package/features/encryption/EncryptionService.d.ts +2 -1
- package/features/encryption/EncryptionService.js +11 -4
- package/features/encryption/EncryptionService.js.map +1 -1
- package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
- package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
- package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
- package/features/encryption/abstractions.d.ts +11 -0
- package/features/encryption/abstractions.js +2 -1
- package/features/encryption/abstractions.js.map +1 -1
- package/features/encryption/index.d.ts +1 -0
- package/features/encryption/index.js +1 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +62 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
- package/features/httpClient/HttpClient.d.ts +7 -0
- package/features/httpClient/HttpClient.js +72 -0
- package/features/httpClient/HttpClient.js.map +1 -0
- package/features/httpClient/HttpRequestError.d.ts +10 -0
- package/features/httpClient/HttpRequestError.js +13 -0
- package/features/httpClient/HttpRequestError.js.map +1 -0
- package/features/httpClient/HttpStatusError.d.ts +12 -0
- package/features/httpClient/HttpStatusError.js +12 -0
- package/features/httpClient/HttpStatusError.js.map +1 -0
- package/features/httpClient/abstractions.d.ts +32 -0
- package/features/httpClient/abstractions.js +5 -0
- package/features/httpClient/abstractions.js.map +1 -0
- package/features/httpClient/feature.d.ts +4 -0
- package/features/httpClient/feature.js +11 -0
- package/features/httpClient/feature.js.map +1 -0
- package/features/httpClient/index.d.ts +3 -0
- package/features/httpClient/index.js +3 -0
- package/features/keyValueStore/GlobalKeyValueStore.d.ts +9 -3
- package/features/keyValueStore/GlobalKeyValueStore.js +12 -2
- package/features/keyValueStore/GlobalKeyValueStore.js.map +1 -1
- package/features/keyValueStore/KeyValueStore.d.ts +6 -2
- package/features/keyValueStore/KeyValueStore.js +13 -3
- package/features/keyValueStore/KeyValueStore.js.map +1 -1
- package/features/keyValueStore/KeyValueStoreRepository.d.ts +8 -2
- package/features/keyValueStore/KeyValueStoreRepository.js +82 -4
- package/features/keyValueStore/KeyValueStoreRepository.js.map +1 -1
- package/features/keyValueStore/abstractions.d.ts +132 -14
- package/features/keyValueStore/abstractions.js.map +1 -1
- package/features/keyValueStore/errors.d.ts +29 -0
- package/features/keyValueStore/errors.js +49 -1
- package/features/keyValueStore/errors.js.map +1 -1
- package/features/keyValueStore/index.d.ts +4 -1
- package/features/keyValueStore/index.js +1 -1
- package/features/publicUrls/NullPublicUrls.d.ts +11 -0
- package/features/publicUrls/NullPublicUrls.js +17 -0
- package/features/publicUrls/NullPublicUrls.js.map +1 -0
- package/features/publicUrls/PublicUrl.d.ts +24 -0
- package/features/publicUrls/PublicUrl.js +43 -0
- package/features/publicUrls/PublicUrl.js.map +1 -0
- package/features/publicUrls/__tests__/PublicUrl.test.d.ts +1 -0
- package/features/publicUrls/__tests__/PublicUrl.test.js +38 -0
- package/features/publicUrls/__tests__/PublicUrl.test.js.map +1 -0
- package/features/publicUrls/__tests__/PublicUrls.test.d.ts +1 -0
- package/features/publicUrls/__tests__/PublicUrls.test.js +14 -0
- package/features/publicUrls/__tests__/PublicUrls.test.js.map +1 -0
- package/features/publicUrls/abstractions.d.ts +27 -0
- package/features/publicUrls/abstractions.js +5 -0
- package/features/publicUrls/abstractions.js.map +1 -0
- package/features/publicUrls/feature.d.ts +8 -0
- package/features/publicUrls/feature.js +11 -0
- package/features/publicUrls/feature.js.map +1 -0
- package/features/publicUrls/index.d.ts +3 -0
- package/features/publicUrls/index.js +3 -0
- package/features/requestContext/RawAssumePermissions.d.ts +14 -0
- package/features/requestContext/RawAssumePermissions.js +19 -0
- package/features/requestContext/RawAssumePermissions.js.map +1 -0
- package/features/requestContext/abstractions.d.ts +22 -0
- package/features/requestContext/abstractions.js +2 -1
- package/features/requestContext/abstractions.js.map +1 -1
- package/features/requestContext/extractAssumePermissions.d.ts +14 -0
- package/features/requestContext/extractAssumePermissions.js +32 -0
- package/features/requestContext/extractAssumePermissions.js.map +1 -0
- package/features/requestContext/feature.d.ts +2 -1
- package/features/requestContext/feature.js +2 -0
- package/features/requestContext/feature.js.map +1 -1
- package/features/requestContext/index.d.ts +3 -1
- package/features/requestContext/index.js +2 -1
- package/features/security/IdentityContext/IdentityContext.d.ts +3 -3
- package/features/security/IdentityContext/IdentityContext.js +6 -6
- package/features/security/IdentityContext/IdentityContext.js.map +1 -1
- package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
- package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/shared/schemas.d.ts +2 -2
- package/features/security/apiKeys/shared/schemas.js +2 -2
- package/features/security/apiKeys/shared/schemas.js.map +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +3 -3
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
- package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
- package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
- package/features/security/roles/CreateRole/schema.d.ts +1 -1
- package/features/security/roles/CreateRole/schema.js +1 -1
- package/features/security/roles/CreateRole/schema.js.map +1 -1
- package/features/security/roles/Installer/RolesInstaller.js +1 -0
- package/features/security/roles/Installer/RolesInstaller.js.map +1 -1
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
- package/features/security/roles/UpdateRole/schema.d.ts +1 -1
- package/features/security/roles/UpdateRole/schema.js +1 -1
- package/features/security/roles/UpdateRole/schema.js.map +1 -1
- package/features/security/shared/description.d.ts +4 -0
- package/features/security/shared/description.js +7 -0
- package/features/security/shared/description.js.map +1 -0
- package/features/security/shared/index.d.ts +1 -0
- package/features/security/shared/index.js +1 -0
- package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
- package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
- package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
- package/features/security/teams/CreateTeam/schema.d.ts +1 -1
- package/features/security/teams/CreateTeam/schema.js +1 -1
- package/features/security/teams/CreateTeam/schema.js.map +1 -1
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
- package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
- package/features/security/teams/UpdateTeam/schema.js +1 -1
- package/features/security/teams/UpdateTeam/schema.js.map +1 -1
- package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
- package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
- package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
- package/features/slugify/DefaultSlugify.d.ts +8 -0
- package/features/slugify/DefaultSlugify.js +20 -0
- package/features/slugify/DefaultSlugify.js.map +1 -0
- package/features/slugify/abstractions.d.ts +12 -0
- package/features/slugify/abstractions.js +5 -0
- package/features/slugify/abstractions.js.map +1 -0
- package/features/slugify/feature.d.ts +4 -0
- package/features/slugify/feature.js +11 -0
- package/features/slugify/feature.js.map +1 -0
- package/features/slugify/index.d.ts +3 -0
- package/features/slugify/index.js +2 -0
- package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
- package/features/stringFormatter/DefaultStringFormatter.js +19 -0
- package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
- package/features/stringFormatter/abstractions.d.ts +11 -0
- package/features/stringFormatter/abstractions.js +5 -0
- package/features/stringFormatter/abstractions.js.map +1 -0
- package/features/stringFormatter/feature.d.ts +4 -0
- package/features/stringFormatter/feature.js +13 -0
- package/features/stringFormatter/feature.js.map +1 -0
- package/features/stringFormatter/index.d.ts +3 -0
- package/features/stringFormatter/index.js +2 -0
- package/features/task/TaskDefinition/abstractions.d.ts +69 -4
- package/features/task/TaskDefinition/abstractions.js +2 -1
- package/features/task/TaskDefinition/abstractions.js.map +1 -1
- package/features/tenancy/TenantContext/TenantContext.d.ts +1 -0
- package/features/tenancy/TenantContext/TenantContext.js +13 -8
- package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
- package/features/wcp/WcpContext/WcpContext.d.ts +7 -0
- package/features/wcp/WcpContext/WcpContext.js +21 -0
- package/features/wcp/WcpContext/WcpContext.js.map +1 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +10 -69
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +66 -35
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
- package/features/wcp/WcpFeature.js +2 -0
- package/features/wcp/WcpFeature.js.map +1 -1
- package/features/wcp/WcpLicenseLoader.d.ts +25 -0
- package/features/wcp/WcpLicenseLoader.js +58 -0
- package/features/wcp/WcpLicenseLoader.js.map +1 -0
- package/features/wcp/WcpLicenseProvider.d.ts +6 -14
- package/features/wcp/WcpLicenseProvider.js +3 -7
- package/features/wcp/WcpLicenseProvider.js.map +1 -1
- package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
- package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
- package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
- package/graphql/ApiCoreSchemaFactory.d.ts +1 -0
- package/graphql/ApiCoreSchemaFactory.js +7 -1
- package/graphql/ApiCoreSchemaFactory.js.map +1 -1
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +10 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +53 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
- package/graphql/security/SecuritySchemaFactory.d.ts +1 -0
- package/graphql/security/SecuritySchemaFactory.js +4 -0
- package/graphql/security/SecuritySchemaFactory.js.map +1 -1
- package/graphql/system/SystemSchemaFactory.d.ts +1 -0
- package/graphql/system/SystemSchemaFactory.js +4 -0
- package/graphql/system/SystemSchemaFactory.js.map +1 -1
- package/graphql/users/UsersSchemaFactory.d.ts +1 -0
- package/graphql/users/UsersSchemaFactory.js +4 -0
- package/graphql/users/UsersSchemaFactory.js.map +1 -1
- package/graphql/wcp/WcpSchemaFactory.d.ts +1 -0
- package/graphql/wcp/WcpSchemaFactory.js +5 -0
- package/graphql/wcp/WcpSchemaFactory.js.map +1 -1
- package/idp/JwksCache.d.ts +14 -3
- package/idp/JwksCache.js +97 -17
- package/idp/JwksCache.js.map +1 -1
- package/idp/JwksStoreFeature.d.ts +8 -0
- package/idp/JwksStoreFeature.js +11 -0
- package/idp/JwksStoreFeature.js.map +1 -0
- package/idp/MemoryJwksStore.d.ts +14 -0
- package/idp/MemoryJwksStore.js +21 -0
- package/idp/MemoryJwksStore.js.map +1 -0
- package/idp/OidcJwtIdentityProvider.js +5 -1
- package/idp/OidcJwtIdentityProvider.js.map +1 -1
- package/idp/abstractions.d.ts +24 -0
- package/idp/abstractions.js +2 -1
- package/idp/abstractions.js.map +1 -1
- package/idp/feature.js +1 -2
- package/idp/feature.js.map +1 -1
- package/idp/index.d.ts +1 -0
- package/idp/index.js +1 -0
- package/package.json +20 -18
- package/testing/environment.d.ts +14 -0
- package/testing/environment.js +18 -0
- package/testing/environment.js.map +1 -0
- package/features/wcp/loadWcpLicense.d.ts +0 -2
- package/features/wcp/loadWcpLicense.js +0 -51
- package/features/wcp/loadWcpLicense.js.map +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { License, NullLicense, getWcpProjectLicense } from "@webiny/wcp";
|
|
2
|
+
import { getWcpProjectLicenseCacheKey } from "./WcpContext/utils.js";
|
|
3
|
+
import { resolveWcpProjectEnvironment } from "./resolveWcpProjectEnvironment.js";
|
|
4
|
+
class WcpLicenseLoader {
|
|
5
|
+
static{
|
|
6
|
+
this.wcpProjectEnvironment = resolveWcpProjectEnvironment();
|
|
7
|
+
}
|
|
8
|
+
static{
|
|
9
|
+
this.cached = {
|
|
10
|
+
cacheKey: null,
|
|
11
|
+
project: null,
|
|
12
|
+
license: new NullLicense()
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
static{
|
|
16
|
+
this.inflight = null;
|
|
17
|
+
}
|
|
18
|
+
static getCached() {
|
|
19
|
+
return WcpLicenseLoader.cached.license;
|
|
20
|
+
}
|
|
21
|
+
static seed(license) {
|
|
22
|
+
WcpLicenseLoader.cached.license = license;
|
|
23
|
+
WcpLicenseLoader.cached.cacheKey = getWcpProjectLicenseCacheKey();
|
|
24
|
+
}
|
|
25
|
+
static async load(testProjectLicense) {
|
|
26
|
+
const cached = WcpLicenseLoader.cached;
|
|
27
|
+
if (testProjectLicense) {
|
|
28
|
+
cached.license = License.fromLicenseDto(testProjectLicense);
|
|
29
|
+
return cached.license;
|
|
30
|
+
}
|
|
31
|
+
const env = WcpLicenseLoader.wcpProjectEnvironment;
|
|
32
|
+
if (!env) return cached.license;
|
|
33
|
+
const currentCacheKey = getWcpProjectLicenseCacheKey();
|
|
34
|
+
if (cached.cacheKey === currentCacheKey) return cached.license;
|
|
35
|
+
if (WcpLicenseLoader.inflight) return WcpLicenseLoader.inflight;
|
|
36
|
+
WcpLicenseLoader.inflight = (async ()=>{
|
|
37
|
+
const decryptedLicenseDto = await getWcpProjectLicense({
|
|
38
|
+
orgId: env.org.id,
|
|
39
|
+
projectId: env.project.id,
|
|
40
|
+
projectEnvironmentApiKey: env.apiKey
|
|
41
|
+
});
|
|
42
|
+
if (decryptedLicenseDto) cached.project = {
|
|
43
|
+
orgId: decryptedLicenseDto.orgId,
|
|
44
|
+
projectId: decryptedLicenseDto.projectId,
|
|
45
|
+
package: decryptedLicenseDto.package
|
|
46
|
+
};
|
|
47
|
+
cached.license = License.fromLicenseDto(decryptedLicenseDto);
|
|
48
|
+
cached.cacheKey = currentCacheKey;
|
|
49
|
+
return cached.license;
|
|
50
|
+
})().finally(()=>{
|
|
51
|
+
WcpLicenseLoader.inflight = null;
|
|
52
|
+
});
|
|
53
|
+
return WcpLicenseLoader.inflight;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export { WcpLicenseLoader };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=WcpLicenseLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/wcp/WcpLicenseLoader.js","sources":["../../../src/features/wcp/WcpLicenseLoader.ts"],"sourcesContent":["import { getWcpProjectLicense, NullLicense, License } from \"@webiny/wcp\";\nimport type { DecryptedWcpProjectLicense, ILicense } from \"@webiny/wcp/types.js\";\nimport type { CachedWcpProjectLicense } from \"~/features/wcp/WcpContext/types.js\";\nimport { getWcpProjectLicenseCacheKey } from \"~/features/wcp/WcpContext/utils.js\";\nimport { resolveWcpProjectEnvironment } from \"~/features/wcp/resolveWcpProjectEnvironment.js\";\n\n/**\n * Loads and process-caches the WCP project license. Static because the cache is process-global (one\n * license per deployment): the pre-register refresh in `registerApiRequestStack` calls `load()` to\n * populate it, and `WcpLicenseProvider` / register-time feature-flag gates read it synchronously via\n * `getCached()`. Not DI — it must be usable before any container exists (before register).\n */\nexport class WcpLicenseLoader {\n private static readonly wcpProjectEnvironment = resolveWcpProjectEnvironment();\n\n private static cached: CachedWcpProjectLicense = {\n cacheKey: null,\n project: null,\n license: new NullLicense()\n };\n\n // In-flight fetch, memoized so concurrent cache-miss callers coalesce onto a single WCP request\n // (standalone runs many requests in one process; we never want two license fetches at once).\n private static inflight: Promise<ILicense> | null = null;\n\n /**\n * Synchronously read the currently cached license. `load()` must have been awaited at least once\n * this request (the pre-register refresh does this), so this reflects the live license — letting\n * register()-time feature-flag checks read it synchronously.\n */\n static getCached(): ILicense {\n return WcpLicenseLoader.cached.license;\n }\n\n /**\n * Seed the cache with an already-resolved license (tests pass a pre-built one). Marks it fresh so\n * a subsequent `load()` returns it without a fetch. This is how `WcpLicenseProviderImpl` installs\n * an initial license.\n */\n static seed(license: ILicense): void {\n WcpLicenseLoader.cached.license = license;\n WcpLicenseLoader.cached.cacheKey = getWcpProjectLicenseCacheKey();\n }\n\n static async load(testProjectLicense?: DecryptedWcpProjectLicense): Promise<ILicense> {\n const cached = WcpLicenseLoader.cached;\n\n if (testProjectLicense) {\n cached.license = License.fromLicenseDto(testProjectLicense);\n return cached.license;\n }\n\n const env = WcpLicenseLoader.wcpProjectEnvironment;\n if (!env) {\n return cached.license;\n }\n\n const currentCacheKey = getWcpProjectLicenseCacheKey();\n if (cached.cacheKey === currentCacheKey) {\n return cached.license;\n }\n\n // Cache miss (first load or the ~5-min key rotated). Coalesce concurrent callers onto one fetch.\n if (WcpLicenseLoader.inflight) {\n return WcpLicenseLoader.inflight;\n }\n\n WcpLicenseLoader.inflight = (async () => {\n // Pull the project license from the WCP API.\n const decryptedLicenseDto = await getWcpProjectLicense({\n orgId: env.org.id,\n projectId: env.project.id,\n projectEnvironmentApiKey: env.apiKey\n });\n\n if (decryptedLicenseDto) {\n cached.project = {\n orgId: decryptedLicenseDto.orgId,\n projectId: decryptedLicenseDto.projectId,\n package: decryptedLicenseDto.package\n };\n }\n\n cached.license = License.fromLicenseDto(decryptedLicenseDto);\n // Mark fresh only after a successful fetch — a throw leaves the key unset so the next call retries.\n cached.cacheKey = currentCacheKey;\n return cached.license;\n })().finally(() => {\n WcpLicenseLoader.inflight = null;\n });\n\n return WcpLicenseLoader.inflight;\n }\n}\n"],"names":["WcpLicenseLoader","resolveWcpProjectEnvironment","NullLicense","license","getWcpProjectLicenseCacheKey","testProjectLicense","cached","License","env","currentCacheKey","decryptedLicenseDto","getWcpProjectLicense"],"mappings":";;;AAYO,MAAMA;;aACe,qBAAqB,GAAGC;;;aAEjC,MAAM,GAA4B;YAC7C,UAAU;YACV,SAAS;YACT,SAAS,IAAIC;QACjB;;;aAIe,QAAQ,GAA6B;;IAOpD,OAAO,YAAsB;QACzB,OAAOF,iBAAiB,MAAM,CAAC,OAAO;IAC1C;IAOA,OAAO,KAAKG,OAAiB,EAAQ;QACjCH,iBAAiB,MAAM,CAAC,OAAO,GAAGG;QAClCH,iBAAiB,MAAM,CAAC,QAAQ,GAAGI;IACvC;IAEA,aAAa,KAAKC,kBAA+C,EAAqB;QAClF,MAAMC,SAASN,iBAAiB,MAAM;QAEtC,IAAIK,oBAAoB;YACpBC,OAAO,OAAO,GAAGC,QAAQ,cAAc,CAACF;YACxC,OAAOC,OAAO,OAAO;QACzB;QAEA,MAAME,MAAMR,iBAAiB,qBAAqB;QAClD,IAAI,CAACQ,KACD,OAAOF,OAAO,OAAO;QAGzB,MAAMG,kBAAkBL;QACxB,IAAIE,OAAO,QAAQ,KAAKG,iBACpB,OAAOH,OAAO,OAAO;QAIzB,IAAIN,iBAAiB,QAAQ,EACzB,OAAOA,iBAAiB,QAAQ;QAGpCA,iBAAiB,QAAQ,GAAI;YAEzB,MAAMU,sBAAsB,MAAMC,qBAAqB;gBACnD,OAAOH,IAAI,GAAG,CAAC,EAAE;gBACjB,WAAWA,IAAI,OAAO,CAAC,EAAE;gBACzB,0BAA0BA,IAAI,MAAM;YACxC;YAEA,IAAIE,qBACAJ,OAAO,OAAO,GAAG;gBACb,OAAOI,oBAAoB,KAAK;gBAChC,WAAWA,oBAAoB,SAAS;gBACxC,SAASA,oBAAoB,OAAO;YACxC;YAGJJ,OAAO,OAAO,GAAGC,QAAQ,cAAc,CAACG;YAExCJ,OAAO,QAAQ,GAAGG;YAClB,OAAOH,OAAO,OAAO;QACzB,KAAK,OAAO,CAAC;YACTN,iBAAiB,QAAQ,GAAG;QAChC;QAEA,OAAOA,iBAAiB,QAAQ;IACpC;AACJ"}
|
|
@@ -1,29 +1,21 @@
|
|
|
1
1
|
import type { ILicense } from "@webiny/wcp/types.js";
|
|
2
2
|
export interface IWcpLicenseProvider {
|
|
3
3
|
get(): ILicense;
|
|
4
|
-
refresh(): Promise<void>;
|
|
5
4
|
}
|
|
6
5
|
export declare const WcpLicenseProvider: import("@webiny/di").Abstraction<IWcpLicenseProvider>;
|
|
7
6
|
export declare namespace WcpLicenseProvider {
|
|
8
7
|
type Interface = IWcpLicenseProvider;
|
|
9
8
|
}
|
|
10
9
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Synchronous read-through to the process-cached WCP license. `get()` stays sync so the canUse*
|
|
11
|
+
* consumers (WcpContext, IdentityContext, the WCP GraphQL query) do too. The license is refreshed
|
|
12
|
+
* once per request BEFORE any feature registers — `registerApiRequestStack` awaits
|
|
13
|
+
* `WcpLicenseLoader.load()` (process-cached, ~5-min TTL, single-flighted) — so `get()` reflects the
|
|
14
|
+
* live license at both register() time (feature-flag gates) and resolver time.
|
|
14
15
|
*
|
|
15
|
-
*
|
|
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.
|
|
16
|
+
* An optional initial license can be supplied (tests pass a pre-resolved one); it seeds the cache.
|
|
23
17
|
*/
|
|
24
18
|
export declare class WcpLicenseProviderImpl implements IWcpLicenseProvider {
|
|
25
|
-
private current;
|
|
26
19
|
constructor(initialLicense?: ILicense);
|
|
27
20
|
get(): ILicense;
|
|
28
|
-
refresh(): Promise<void>;
|
|
29
21
|
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
import {
|
|
3
|
-
import { loadWcpLicense } from "./loadWcpLicense.js";
|
|
2
|
+
import { WcpLicenseLoader } from "./WcpLicenseLoader.js";
|
|
4
3
|
const WcpLicenseProvider = createAbstraction("WcpLicenseProvider");
|
|
5
4
|
class WcpLicenseProviderImpl {
|
|
6
5
|
constructor(initialLicense){
|
|
7
|
-
|
|
6
|
+
if (initialLicense) WcpLicenseLoader.seed(initialLicense);
|
|
8
7
|
}
|
|
9
8
|
get() {
|
|
10
|
-
return
|
|
11
|
-
}
|
|
12
|
-
async refresh() {
|
|
13
|
-
this.current = await loadWcpLicense();
|
|
9
|
+
return WcpLicenseLoader.getCached();
|
|
14
10
|
}
|
|
15
11
|
}
|
|
16
12
|
export { WcpLicenseProvider, WcpLicenseProviderImpl };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/wcp/WcpLicenseProvider.js","sources":["../../../src/features/wcp/WcpLicenseProvider.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport
|
|
1
|
+
{"version":3,"file":"features/wcp/WcpLicenseProvider.js","sources":["../../../src/features/wcp/WcpLicenseProvider.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { ILicense } from \"@webiny/wcp/types.js\";\nimport { WcpLicenseLoader } from \"~/features/wcp/WcpLicenseLoader.js\";\n\nexport interface IWcpLicenseProvider {\n get(): ILicense;\n}\n\nexport const WcpLicenseProvider = createAbstraction<IWcpLicenseProvider>(\"WcpLicenseProvider\");\n\nexport namespace WcpLicenseProvider {\n export type Interface = IWcpLicenseProvider;\n}\n\n/**\n * Synchronous read-through to the process-cached WCP license. `get()` stays sync so the canUse*\n * consumers (WcpContext, IdentityContext, the WCP GraphQL query) do too. The license is refreshed\n * once per request BEFORE any feature registers — `registerApiRequestStack` awaits\n * `WcpLicenseLoader.load()` (process-cached, ~5-min TTL, single-flighted) — so `get()` reflects the\n * live license at both register() time (feature-flag gates) and resolver time.\n *\n * An optional initial license can be supplied (tests pass a pre-resolved one); it seeds the cache.\n */\nexport class WcpLicenseProviderImpl implements IWcpLicenseProvider {\n constructor(initialLicense?: ILicense) {\n if (initialLicense) {\n WcpLicenseLoader.seed(initialLicense);\n }\n }\n\n get(): ILicense {\n return WcpLicenseLoader.getCached();\n }\n}\n"],"names":["WcpLicenseProvider","createAbstraction","WcpLicenseProviderImpl","initialLicense","WcpLicenseLoader"],"mappings":";;AAQO,MAAMA,qBAAqBC,kBAAuC;AAelE,MAAMC;IACT,YAAYC,cAAyB,CAAE;QACnC,IAAIA,gBACAC,iBAAiB,IAAI,CAACD;IAE9B;IAEA,MAAgB;QACZ,OAAOC,iBAAiB,SAAS;IACrC;AACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WcpProjectEnvironment } from "@webiny/wcp/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the WCP project environment used to fetch the license. Prefer the CLI-computed
|
|
4
|
+
* WCP_PROJECT_ENVIRONMENT blob (set by `applyWcpEnvVars` during `webiny serve` and the AWS deploy).
|
|
5
|
+
* When it's absent — a CLI-less standalone deploy that boots the built handler directly (e.g.
|
|
6
|
+
* `node start.mjs`) — derive the same org, project and api key straight from the runtime env, so a
|
|
7
|
+
* fresh license can still be fetched.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveWcpProjectEnvironment(): WcpProjectEnvironment | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getWcpProjectEnvironment } from "@webiny/wcp";
|
|
2
|
+
function resolveWcpProjectEnvironment() {
|
|
3
|
+
const fromBlob = getWcpProjectEnvironment();
|
|
4
|
+
if (fromBlob) return fromBlob;
|
|
5
|
+
const projectId = process.env.WEBINY_PROJECT_ID || process.env.WCP_PROJECT_ID;
|
|
6
|
+
const apiKey = process.env.WEBINY_PROJECT_API_KEY || process.env.WCP_PROJECT_ENVIRONMENT_API_KEY;
|
|
7
|
+
if (!projectId || !apiKey) return null;
|
|
8
|
+
const [orgId, project] = projectId.split("/");
|
|
9
|
+
if (!orgId || !project) return null;
|
|
10
|
+
return {
|
|
11
|
+
id: "",
|
|
12
|
+
apiKey,
|
|
13
|
+
org: {
|
|
14
|
+
id: orgId
|
|
15
|
+
},
|
|
16
|
+
project: {
|
|
17
|
+
id: project
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export { resolveWcpProjectEnvironment };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=resolveWcpProjectEnvironment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/wcp/resolveWcpProjectEnvironment.js","sources":["../../../src/features/wcp/resolveWcpProjectEnvironment.ts"],"sourcesContent":["import { getWcpProjectEnvironment } from \"@webiny/wcp\";\nimport type { WcpProjectEnvironment } from \"@webiny/wcp/types.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 standalone 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 */\nexport function 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"],"names":["resolveWcpProjectEnvironment","fromBlob","getWcpProjectEnvironment","projectId","process","apiKey","orgId","project"],"mappings":";AAUO,SAASA;IACZ,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"}
|
|
@@ -7,6 +7,7 @@ import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQL
|
|
|
7
7
|
* core factories does not matter, the engine merges all typeDefs in a single pass.
|
|
8
8
|
*/
|
|
9
9
|
declare class ApiCoreSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {
|
|
10
|
+
getSchemaKey: () => string;
|
|
10
11
|
execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
|
|
11
12
|
}
|
|
12
13
|
export declare const ApiCoreSchemaFactory: typeof ApiCoreSchemaFactoryImpl & {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
-
import {
|
|
2
|
+
import { staticSchemaKey } from "@webiny/api-graphql/graphql/staticSchemaKey.js";
|
|
3
|
+
import { AnyScalar, DateScalar, DateTimeScalar, DateTimeZScalar, IconScalar, JsonScalar, LongScalar, NumberScalar, RefInputScalar, TimeScalar } from "@webiny/api-graphql/builtInTypes/index.js";
|
|
3
4
|
const BASE_TYPES = `
|
|
4
5
|
type Query
|
|
5
6
|
type Mutation
|
|
@@ -11,6 +12,7 @@ const BASE_TYPES = `
|
|
|
11
12
|
scalar Any
|
|
12
13
|
scalar Date
|
|
13
14
|
scalar DateTime
|
|
15
|
+
scalar DateTimeZ
|
|
14
16
|
scalar Time
|
|
15
17
|
|
|
16
18
|
type Error {
|
|
@@ -33,6 +35,7 @@ const SCALAR_RESOLVERS = {
|
|
|
33
35
|
Number: NumberScalar,
|
|
34
36
|
Any: AnyScalar,
|
|
35
37
|
DateTime: DateTimeScalar,
|
|
38
|
+
DateTimeZ: DateTimeZScalar,
|
|
36
39
|
Date: DateScalar,
|
|
37
40
|
Time: TimeScalar
|
|
38
41
|
};
|
|
@@ -42,6 +45,9 @@ class ApiCoreSchemaFactoryImpl {
|
|
|
42
45
|
builder.addLegacyResolvers(SCALAR_RESOLVERS);
|
|
43
46
|
return builder;
|
|
44
47
|
}
|
|
48
|
+
constructor(){
|
|
49
|
+
this.getSchemaKey = staticSchemaKey("api-core/ApiCoreSchemaFactoryImpl");
|
|
50
|
+
}
|
|
45
51
|
}
|
|
46
52
|
const ApiCoreSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({
|
|
47
53
|
implementation: ApiCoreSchemaFactoryImpl,
|
|
@@ -1 +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":"
|
|
1
|
+
{"version":3,"file":"graphql/ApiCoreSchemaFactory.js","sources":["../../src/graphql/ApiCoreSchemaFactory.ts"],"sourcesContent":["import { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport { staticSchemaKey } from \"@webiny/api-graphql/graphql/staticSchemaKey.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 DateTimeZScalar,\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 DateTimeZ\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 DateTimeZ: DateTimeZScalar,\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 public getSchemaKey = staticSchemaKey(\"api-core/ApiCoreSchemaFactoryImpl\");\n\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","DateTimeZScalar","DateScalar","TimeScalar","ApiCoreSchemaFactoryImpl","builder","staticSchemaKey","ApiCoreSchemaFactory","CoreGraphQLSchemaFactory"],"mappings":";;;AAgBA,MAAMA,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AAyBpB,CAAC;AAED,MAAMC,mBAAwC;IAC1C,MAAMC;IACN,MAAMC;IACN,MAAMC;IACN,UAAUC;IACV,QAAQC;IACR,KAAKC;IACL,UAAUC;IACV,WAAWC;IACX,MAAMC;IACN,MAAMC;AACV;AAQA,MAAMC;IAGF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAACb;QAGpBa,QAAQ,kBAAkB,CAACZ;QAE3B,OAAOY;IACX;;aATO,YAAY,GAAGC,gBAAgB;;AAU1C;AAEO,MAAMC,uBAAuBC,yBAAyB,oBAAoB,CAAC;IAC9E,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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 FeatureFlagsSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {
|
|
4
|
+
getSchemaKey: () => string;
|
|
5
|
+
execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
|
|
6
|
+
}
|
|
7
|
+
export declare const FeatureFlagsSchemaFactory: typeof FeatureFlagsSchemaFactoryImpl & {
|
|
8
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-graphql/graphql/abstractions.core").ICoreGraphQLSchemaFactory>;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import { staticSchemaKey } from "@webiny/api-graphql/graphql/staticSchemaKey.js";
|
|
3
|
+
import { ErrorResponse, Response } from "@webiny/api-graphql/responses.js";
|
|
4
|
+
import { FeatureFlags } from "../../features/featureFlags/abstractions.js";
|
|
5
|
+
class FeatureFlagsSchemaFactoryImpl {
|
|
6
|
+
async execute(builder) {
|
|
7
|
+
builder.addTypeDefs(`
|
|
8
|
+
type FeatureFlagsError {
|
|
9
|
+
code: String
|
|
10
|
+
message: String
|
|
11
|
+
data: JSON
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type FeatureFlagsResponse {
|
|
15
|
+
data: JSON
|
|
16
|
+
error: FeatureFlagsError
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
extend type Query {
|
|
20
|
+
featureFlags: FeatureFlagsResponse
|
|
21
|
+
}
|
|
22
|
+
`);
|
|
23
|
+
builder.addResolver({
|
|
24
|
+
path: "Query.featureFlags",
|
|
25
|
+
dependencies: [
|
|
26
|
+
FeatureFlags
|
|
27
|
+
],
|
|
28
|
+
resolver: (featureFlags)=>async ()=>{
|
|
29
|
+
try {
|
|
30
|
+
return new Response(featureFlags.get().toDto());
|
|
31
|
+
} catch (e) {
|
|
32
|
+
return new ErrorResponse({
|
|
33
|
+
code: "COULD_NOT_GET_FEATURE_FLAGS",
|
|
34
|
+
message: e.message,
|
|
35
|
+
data: null,
|
|
36
|
+
stack: e.stack
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return builder;
|
|
42
|
+
}
|
|
43
|
+
constructor(){
|
|
44
|
+
this.getSchemaKey = staticSchemaKey("api-core/FeatureFlagsSchemaFactoryImpl");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const FeatureFlagsSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({
|
|
48
|
+
implementation: FeatureFlagsSchemaFactoryImpl,
|
|
49
|
+
dependencies: []
|
|
50
|
+
});
|
|
51
|
+
export { FeatureFlagsSchemaFactory };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=FeatureFlagsSchemaFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/featureFlags/FeatureFlagsSchemaFactory.js","sources":["../../../src/graphql/featureFlags/FeatureFlagsSchemaFactory.ts"],"sourcesContent":["import { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport { staticSchemaKey } from \"@webiny/api-graphql/graphql/staticSchemaKey.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { ErrorResponse, Response } from \"@webiny/api-graphql/responses.js\";\nimport { FeatureFlags } from \"~/features/featureFlags/abstractions.js\";\n\nclass FeatureFlagsSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {\n public getSchemaKey = staticSchemaKey(\"api-core/FeatureFlagsSchemaFactoryImpl\");\n\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(/* GraphQL */ `\n type FeatureFlagsError {\n code: String\n message: String\n data: JSON\n }\n\n type FeatureFlagsResponse {\n data: JSON\n error: FeatureFlagsError\n }\n\n extend type Query {\n featureFlags: FeatureFlagsResponse\n }\n `);\n\n builder.addResolver({\n path: \"Query.featureFlags\",\n dependencies: [FeatureFlags],\n resolver: (featureFlags: FeatureFlags.Interface) => async () => {\n try {\n return new Response(featureFlags.get().toDto());\n } catch (e) {\n return new ErrorResponse({\n code: \"COULD_NOT_GET_FEATURE_FLAGS\",\n message: e.message,\n data: null,\n stack: e.stack\n });\n }\n }\n });\n\n return builder;\n }\n}\n\nexport const FeatureFlagsSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({\n implementation: FeatureFlagsSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["FeatureFlagsSchemaFactoryImpl","builder","FeatureFlags","featureFlags","Response","e","ErrorResponse","staticSchemaKey","FeatureFlagsSchemaFactory","CoreGraphQLSchemaFactory"],"mappings":";;;;AAMA,MAAMA;IAGF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;;;;;;QAenC,CAAC;QAEDA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACC;aAAa;YAC5B,UAAU,CAACC,eAAyC;oBAChD,IAAI;wBACA,OAAO,IAAIC,SAASD,aAAa,GAAG,GAAG,KAAK;oBAChD,EAAE,OAAOE,GAAG;wBACR,OAAO,IAAIC,cAAc;4BACrB,MAAM;4BACN,SAASD,EAAE,OAAO;4BAClB,MAAM;4BACN,OAAOA,EAAE,KAAK;wBAClB;oBACJ;gBACJ;QACJ;QAEA,OAAOJ;IACX;;aAtCO,YAAY,GAAGM,gBAAgB;;AAuC1C;AAEO,MAAMC,4BAA4BC,yBAAyB,oBAAoB,CAAC;IACnF,gBAAgBT;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -6,6 +6,7 @@ import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQL
|
|
|
6
6
|
* base, team, apiKey, role, identity.
|
|
7
7
|
*/
|
|
8
8
|
declare class SecuritySchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {
|
|
9
|
+
getSchemaKey: () => string;
|
|
9
10
|
execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
|
|
10
11
|
}
|
|
11
12
|
export declare const SecuritySchemaFactory: typeof SecuritySchemaFactoryImpl & {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import { staticSchemaKey } from "@webiny/api-graphql/graphql/staticSchemaKey.js";
|
|
2
3
|
import { addSecurityBaseSchema } from "./addSecurityBaseSchema.js";
|
|
3
4
|
import { addApiKeySchema } from "./addApiKeySchema.js";
|
|
4
5
|
import { addRoleSchema } from "./addRoleSchema.js";
|
|
@@ -13,6 +14,9 @@ class SecuritySchemaFactoryImpl {
|
|
|
13
14
|
addIdentitySchema(builder);
|
|
14
15
|
return builder;
|
|
15
16
|
}
|
|
17
|
+
constructor(){
|
|
18
|
+
this.getSchemaKey = staticSchemaKey("api-core/SecuritySchemaFactoryImpl");
|
|
19
|
+
}
|
|
16
20
|
}
|
|
17
21
|
const SecuritySchemaFactory = CoreGraphQLSchemaFactory.createImplementation({
|
|
18
22
|
implementation: SecuritySchemaFactoryImpl,
|
|
@@ -1 +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":"
|
|
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 { staticSchemaKey } from \"@webiny/api-graphql/graphql/staticSchemaKey.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 public getSchemaKey = staticSchemaKey(\"api-core/SecuritySchemaFactoryImpl\");\n\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","staticSchemaKey","SecuritySchemaFactory","CoreGraphQLSchemaFactory"],"mappings":";;;;;;;AAcA,MAAMA;IAGF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EC,sBAAsBD;QACtBE,cAAcF;QACdG,gBAAgBH;QAChBI,cAAcJ;QACdK,kBAAkBL;QAElB,OAAOA;IACX;;aAVO,YAAY,GAAGM,gBAAgB;;AAW1C;AAEO,MAAMC,wBAAwBC,yBAAyB,oBAAoB,CAAC;IAC/E,gBAAgBT;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
2
|
import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
|
|
3
3
|
declare class SystemSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {
|
|
4
|
+
getSchemaKey: () => string;
|
|
4
5
|
execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
|
|
5
6
|
}
|
|
6
7
|
export declare const SystemSchemaFactory: typeof SystemSchemaFactoryImpl & {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import { staticSchemaKey } from "@webiny/api-graphql/graphql/staticSchemaKey.js";
|
|
2
3
|
import { ErrorResponse, Response } from "@webiny/api-graphql";
|
|
3
4
|
import { GetRootTenantUseCase } from "../../features/tenancy/GetRootTenant/index.js";
|
|
4
5
|
import { InstallSystemUseCase } from "../../features/system/InstallSystem/index.js";
|
|
@@ -56,6 +57,9 @@ class SystemSchemaFactoryImpl {
|
|
|
56
57
|
});
|
|
57
58
|
return builder;
|
|
58
59
|
}
|
|
60
|
+
constructor(){
|
|
61
|
+
this.getSchemaKey = staticSchemaKey("api-core/SystemSchemaFactoryImpl");
|
|
62
|
+
}
|
|
59
63
|
}
|
|
60
64
|
const SystemSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({
|
|
61
65
|
implementation: SystemSchemaFactoryImpl,
|
|
@@ -1 +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":"
|
|
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 { staticSchemaKey } from \"@webiny/api-graphql/graphql/staticSchemaKey.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 public getSchemaKey = staticSchemaKey(\"api-core/SystemSchemaFactoryImpl\");\n\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","staticSchemaKey","SystemSchemaFactory","CoreGraphQLSchemaFactory"],"mappings":";;;;;AAYA,MAAMA;IAGF,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;;aA9DO,YAAY,GAAGS,gBAAgB;;AA+D1C;AAEO,MAAMC,sBAAsBC,yBAAyB,oBAAoB,CAAC;IAC7E,gBAAgBZ;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
2
|
import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
|
|
3
3
|
declare class UsersSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {
|
|
4
|
+
getSchemaKey: () => string;
|
|
4
5
|
execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
|
|
5
6
|
}
|
|
6
7
|
export declare const UsersSchemaFactory: typeof UsersSchemaFactoryImpl & {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import { staticSchemaKey } from "@webiny/api-graphql/graphql/staticSchemaKey.js";
|
|
2
3
|
import { ErrorResponse, ListErrorResponse, ListResponse, NotFoundResponse, Response } from "@webiny/api-graphql/responses.js";
|
|
3
4
|
import { GetUserUseCase } from "../../features/users/GetUser/index.js";
|
|
4
5
|
import NotAuthorizedResponse from "../security/NotAuthorizedResponse.js";
|
|
@@ -181,6 +182,9 @@ class UsersSchemaFactoryImpl {
|
|
|
181
182
|
});
|
|
182
183
|
return builder;
|
|
183
184
|
}
|
|
185
|
+
constructor(){
|
|
186
|
+
this.getSchemaKey = staticSchemaKey("api-core/UsersSchemaFactoryImpl");
|
|
187
|
+
}
|
|
184
188
|
}
|
|
185
189
|
const UsersSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({
|
|
186
190
|
implementation: UsersSchemaFactoryImpl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/users/UsersSchemaFactory.js","sources":["../../../src/graphql/users/UsersSchemaFactory.ts"],"sourcesContent":["import { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport {\n ErrorResponse,\n ListErrorResponse,\n ListResponse,\n NotFoundResponse,\n Response\n} from \"@webiny/api-graphql/responses.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport type { AdminUser } from \"~/types/users.js\";\nimport { GetUserUseCase } from \"~/features/users/GetUser/index.js\";\nimport NotAuthorizedResponse from \"~/graphql/security/NotAuthorizedResponse.js\";\nimport { ListUsersUseCase } from \"~/features/users/ListUsers/index.js\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/abstractions.js\";\nimport { ListRolesUseCase } from \"~/features/security/roles/ListRoles/index.js\";\nimport { ListTeamsUseCase } from \"~/features/security/teams/ListTeams/index.js\";\n\nclass UsersSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(/* GraphQL */ `\n type AdminUsersQuery {\n _empty: String\n }\n\n type AdminUsersMutation {\n _empty: String\n }\n\n extend type Query {\n adminUsers: AdminUsersQuery\n }\n\n extend type Mutation {\n adminUsers: AdminUsersMutation\n }\n\n type AdminUsersCreatedBy {\n id: ID\n displayName: String\n }\n\n type AdminUsersError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type AdminUsersBooleanResponse {\n data: Boolean\n error: AdminUsersError\n }\n\n type AdminUser {\n id: ID!\n displayName: String!\n email: String!\n\n roles: [SecurityRole]\n firstName: String\n lastName: String\n avatar: JSON\n external: Boolean\n createdOn: DateTime\n }\n\n type AdminUsersResponse {\n data: AdminUser\n error: AdminUsersError\n }\n\n type AdminUsersListResponse {\n data: [AdminUser]\n error: AdminUsersError\n }\n\n input AdminUsersGetUserWhereInput {\n id: ID\n email: String\n }\n\n extend type AdminUsersQuery {\n getUser(where: AdminUsersGetUserWhereInput): AdminUsersResponse\n getCurrentUser: AdminUsersResponse\n listUsers: AdminUsersListResponse\n }\n\n extend type AdminUser {\n teams: [SecurityTeam]\n }\n `);\n\n builder.addResolver({\n path: \"Query.adminUsers\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"Mutation.adminUsers\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"AdminUser.roles\",\n dependencies: [ListRolesUseCase],\n resolver:\n (listRoles: ListRolesUseCase.Interface) =>\n async ({ parent }: { parent: AdminUser }) => {\n if (!parent.roles) {\n return null;\n }\n\n const result = await listRoles.execute({ where: { id_in: parent.roles } });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n }\n });\n\n builder.addResolver({\n path: \"AdminUser.teams\",\n dependencies: [ListTeamsUseCase],\n resolver:\n (listTeams: ListTeamsUseCase.Interface) =>\n async ({ parent }: { parent: AdminUser }) => {\n const hasTeams = Array.isArray(parent.teams) && parent.teams.length > 0;\n if (!hasTeams) {\n return [];\n }\n\n const result = await listTeams.execute({ where: { id_in: parent.teams } });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n }\n });\n\n builder.addResolver<{ where: any }>({\n path: \"AdminUsersQuery.getUser\",\n dependencies: [GetUserUseCase],\n resolver:\n (getUser: GetUserUseCase.Interface) =>\n async ({ args }) => {\n const { where } = args;\n const userResult = await getUser.execute({\n id: where.id,\n email: where.email\n });\n\n if (userResult.isFail()) {\n const error = userResult.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\n `User \"${JSON.stringify(where)}\" was not found!`\n );\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResult.value);\n }\n });\n\n builder.addResolver({\n path: \"AdminUsersQuery.getCurrentUser\",\n dependencies: [IdentityContext, GetUserUseCase],\n resolver:\n (identityContext: IdentityContext.Interface, getUser: GetUserUseCase.Interface) =>\n async () => {\n const identity = identityContext.getIdentity();\n\n if (!identity.isAdmin()) {\n throw new NotAuthorizedResponse();\n }\n\n // Current user might not have permissions to execute `getUser` (this method can load any user in the system),\n // but loading your own user record should be allowed. For that reason, let's temporarily disable authorization.\n const userResponse = await identityContext.withoutAuthorization(async () => {\n // Get user record using the identity ID.\n return await getUser.execute({ id: identity.id });\n });\n\n if (userResponse.isFail()) {\n const error = userResponse.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\n `User with ID ${identity.id} was not found!`\n );\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResponse.value);\n }\n });\n\n builder.addResolver({\n path: \"AdminUsersQuery.listUsers\",\n dependencies: [ListUsersUseCase],\n resolver: (listUsers: ListUsersUseCase.Interface) => async () => {\n const users = await listUsers.execute();\n\n if (users.isFail()) {\n return new ListErrorResponse(users.error);\n }\n\n return new ListResponse(users.value);\n }\n });\n\n return builder;\n }\n}\n\nexport const UsersSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({\n implementation: UsersSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["UsersSchemaFactoryImpl","builder","ListRolesUseCase","listRoles","parent","result","ListTeamsUseCase","listTeams","hasTeams","Array","GetUserUseCase","getUser","args","where","userResult","error","NotFoundResponse","JSON","ErrorResponse","Response","IdentityContext","identityContext","identity","NotAuthorizedResponse","userResponse","ListUsersUseCase","listUsers","users","ListErrorResponse","ListResponse","UsersSchemaFactory","CoreGraphQLSchemaFactory"],"mappings":";;;;;;;;AAiBA,MAAMA;IACF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAuEnC,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;aAAiB;YAChC,UACI,CAACC,YACD,OAAO,EAAEC,MAAM,EAAyB;oBACpC,IAAI,CAACA,OAAO,KAAK,EACb,OAAO;oBAGX,MAAMC,SAAS,MAAMF,UAAU,OAAO,CAAC;wBAAE,OAAO;4BAAE,OAAOC,OAAO,KAAK;wBAAC;oBAAE;oBACxE,IAAIC,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;oBAEtB,OAAOA,OAAO,KAAK;gBACvB;QACR;QAEAJ,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACK;aAAiB;YAChC,UACI,CAACC,YACD,OAAO,EAAEH,MAAM,EAAyB;oBACpC,MAAMI,WAAWC,MAAM,OAAO,CAACL,OAAO,KAAK,KAAKA,OAAO,KAAK,CAAC,MAAM,GAAG;oBACtE,IAAI,CAACI,UACD,OAAO,EAAE;oBAGb,MAAMH,SAAS,MAAME,UAAU,OAAO,CAAC;wBAAE,OAAO;4BAAE,OAAOH,OAAO,KAAK;wBAAC;oBAAE;oBACxE,IAAIC,OAAO,MAAM,IACb,MAAMA,OAAO,KAAK;oBAEtB,OAAOA,OAAO,KAAK;gBACvB;QACR;QAEAJ,QAAQ,WAAW,CAAiB;YAChC,MAAM;YACN,cAAc;gBAACS;aAAe;YAC9B,UACI,CAACC,UACD,OAAO,EAAEC,IAAI,EAAE;oBACX,MAAM,EAAEC,KAAK,EAAE,GAAGD;oBAClB,MAAME,aAAa,MAAMH,QAAQ,OAAO,CAAC;wBACrC,IAAIE,MAAM,EAAE;wBACZ,OAAOA,MAAM,KAAK;oBACtB;oBAEA,IAAIC,WAAW,MAAM,IAAI;wBACrB,MAAMC,QAAQD,WAAW,KAAK;wBAC9B,IAAIC,AAAe,yBAAfA,MAAM,IAAI,EACV,OAAO,IAAIC,iBACP,CAAC,MAAM,EAAEC,KAAK,SAAS,CAACJ,OAAO,gBAAgB,CAAC;wBAIxD,OAAO,IAAIK,cAAc;4BACrB,SAASH,MAAM,OAAO;4BACtB,MAAMA,MAAM,IAAI;4BAChB,MAAMA,MAAM,IAAI;wBACpB;oBACJ;oBAEA,OAAO,IAAII,SAASL,WAAW,KAAK;gBACxC;QACR;QAEAb,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACmB;gBAAiBV;aAAe;YAC/C,UACI,CAACW,iBAA4CV,UAC7C;oBACI,MAAMW,WAAWD,gBAAgB,WAAW;oBAE5C,IAAI,CAACC,SAAS,OAAO,IACjB,MAAM,IAAIC;oBAKd,MAAMC,eAAe,MAAMH,gBAAgB,oBAAoB,CAAC,UAErD,MAAMV,QAAQ,OAAO,CAAC;4BAAE,IAAIW,SAAS,EAAE;wBAAC;oBAGnD,IAAIE,aAAa,MAAM,IAAI;wBACvB,MAAMT,QAAQS,aAAa,KAAK;wBAChC,IAAIT,AAAe,yBAAfA,MAAM,IAAI,EACV,OAAO,IAAIC,iBACP,CAAC,aAAa,EAAEM,SAAS,EAAE,CAAC,eAAe,CAAC;wBAIpD,OAAO,IAAIJ,cAAc;4BACrB,SAASH,MAAM,OAAO;4BACtB,MAAMA,MAAM,IAAI;4BAChB,MAAMA,MAAM,IAAI;wBACpB;oBACJ;oBAEA,OAAO,IAAII,SAASK,aAAa,KAAK;gBAC1C;QACR;QAEAvB,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACwB;aAAiB;YAChC,UAAU,CAACC,YAA0C;oBACjD,MAAMC,QAAQ,MAAMD,UAAU,OAAO;oBAErC,IAAIC,MAAM,MAAM,IACZ,OAAO,IAAIC,kBAAkBD,MAAM,KAAK;oBAG5C,OAAO,IAAIE,aAAaF,MAAM,KAAK;gBACvC;QACJ;QAEA,OAAO1B;IACX;AACJ;AAEO,MAAM6B,qBAAqBC,yBAAyB,oBAAoB,CAAC;IAC5E,gBAAgB/B;IAChB,cAAc,EAAE;AACpB"}
|
|
1
|
+
{"version":3,"file":"graphql/users/UsersSchemaFactory.js","sources":["../../../src/graphql/users/UsersSchemaFactory.ts"],"sourcesContent":["import { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport { staticSchemaKey } from \"@webiny/api-graphql/graphql/staticSchemaKey.js\";\nimport {\n ErrorResponse,\n ListErrorResponse,\n ListResponse,\n NotFoundResponse,\n Response\n} from \"@webiny/api-graphql/responses.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport type { AdminUser } from \"~/types/users.js\";\nimport { GetUserUseCase } from \"~/features/users/GetUser/index.js\";\nimport NotAuthorizedResponse from \"~/graphql/security/NotAuthorizedResponse.js\";\nimport { ListUsersUseCase } from \"~/features/users/ListUsers/index.js\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/abstractions.js\";\nimport { ListRolesUseCase } from \"~/features/security/roles/ListRoles/index.js\";\nimport { ListTeamsUseCase } from \"~/features/security/teams/ListTeams/index.js\";\n\nclass UsersSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {\n public getSchemaKey = staticSchemaKey(\"api-core/UsersSchemaFactoryImpl\");\n\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(/* GraphQL */ `\n type AdminUsersQuery {\n _empty: String\n }\n\n type AdminUsersMutation {\n _empty: String\n }\n\n extend type Query {\n adminUsers: AdminUsersQuery\n }\n\n extend type Mutation {\n adminUsers: AdminUsersMutation\n }\n\n type AdminUsersCreatedBy {\n id: ID\n displayName: String\n }\n\n type AdminUsersError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type AdminUsersBooleanResponse {\n data: Boolean\n error: AdminUsersError\n }\n\n type AdminUser {\n id: ID!\n displayName: String!\n email: String!\n\n roles: [SecurityRole]\n firstName: String\n lastName: String\n avatar: JSON\n external: Boolean\n createdOn: DateTime\n }\n\n type AdminUsersResponse {\n data: AdminUser\n error: AdminUsersError\n }\n\n type AdminUsersListResponse {\n data: [AdminUser]\n error: AdminUsersError\n }\n\n input AdminUsersGetUserWhereInput {\n id: ID\n email: String\n }\n\n extend type AdminUsersQuery {\n getUser(where: AdminUsersGetUserWhereInput): AdminUsersResponse\n getCurrentUser: AdminUsersResponse\n listUsers: AdminUsersListResponse\n }\n\n extend type AdminUser {\n teams: [SecurityTeam]\n }\n `);\n\n builder.addResolver({\n path: \"Query.adminUsers\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"Mutation.adminUsers\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"AdminUser.roles\",\n dependencies: [ListRolesUseCase],\n resolver:\n (listRoles: ListRolesUseCase.Interface) =>\n async ({ parent }: { parent: AdminUser }) => {\n if (!parent.roles) {\n return null;\n }\n\n const result = await listRoles.execute({ where: { id_in: parent.roles } });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n }\n });\n\n builder.addResolver({\n path: \"AdminUser.teams\",\n dependencies: [ListTeamsUseCase],\n resolver:\n (listTeams: ListTeamsUseCase.Interface) =>\n async ({ parent }: { parent: AdminUser }) => {\n const hasTeams = Array.isArray(parent.teams) && parent.teams.length > 0;\n if (!hasTeams) {\n return [];\n }\n\n const result = await listTeams.execute({ where: { id_in: parent.teams } });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n }\n });\n\n builder.addResolver<{ where: any }>({\n path: \"AdminUsersQuery.getUser\",\n dependencies: [GetUserUseCase],\n resolver:\n (getUser: GetUserUseCase.Interface) =>\n async ({ args }) => {\n const { where } = args;\n const userResult = await getUser.execute({\n id: where.id,\n email: where.email\n });\n\n if (userResult.isFail()) {\n const error = userResult.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\n `User \"${JSON.stringify(where)}\" was not found!`\n );\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResult.value);\n }\n });\n\n builder.addResolver({\n path: \"AdminUsersQuery.getCurrentUser\",\n dependencies: [IdentityContext, GetUserUseCase],\n resolver:\n (identityContext: IdentityContext.Interface, getUser: GetUserUseCase.Interface) =>\n async () => {\n const identity = identityContext.getIdentity();\n\n if (!identity.isAdmin()) {\n throw new NotAuthorizedResponse();\n }\n\n // Current user might not have permissions to execute `getUser` (this method can load any user in the system),\n // but loading your own user record should be allowed. For that reason, let's temporarily disable authorization.\n const userResponse = await identityContext.withoutAuthorization(async () => {\n // Get user record using the identity ID.\n return await getUser.execute({ id: identity.id });\n });\n\n if (userResponse.isFail()) {\n const error = userResponse.error;\n if (error.code === \"AdminUser/NotFound\") {\n return new NotFoundResponse(\n `User with ID ${identity.id} was not found!`\n );\n }\n\n return new ErrorResponse({\n message: error.message,\n code: error.code,\n data: error.data\n });\n }\n\n return new Response(userResponse.value);\n }\n });\n\n builder.addResolver({\n path: \"AdminUsersQuery.listUsers\",\n dependencies: [ListUsersUseCase],\n resolver: (listUsers: ListUsersUseCase.Interface) => async () => {\n const users = await listUsers.execute();\n\n if (users.isFail()) {\n return new ListErrorResponse(users.error);\n }\n\n return new ListResponse(users.value);\n }\n });\n\n return builder;\n }\n}\n\nexport const UsersSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({\n implementation: UsersSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["UsersSchemaFactoryImpl","builder","ListRolesUseCase","listRoles","parent","result","ListTeamsUseCase","listTeams","hasTeams","Array","GetUserUseCase","getUser","args","where","userResult","error","NotFoundResponse","JSON","ErrorResponse","Response","IdentityContext","identityContext","identity","NotAuthorizedResponse","userResponse","ListUsersUseCase","listUsers","users","ListErrorResponse","ListResponse","staticSchemaKey","UsersSchemaFactory","CoreGraphQLSchemaFactory"],"mappings":"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"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
2
|
import type { IGraphQLSchemaBuilder } from "@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js";
|
|
3
3
|
declare class WcpSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {
|
|
4
|
+
getSchemaKey: () => string;
|
|
4
5
|
execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder>;
|
|
5
6
|
}
|
|
6
7
|
export declare const WcpSchemaFactory: typeof WcpSchemaFactoryImpl & {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CoreGraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import { staticSchemaKey } from "@webiny/api-graphql/graphql/staticSchemaKey.js";
|
|
2
3
|
import { ErrorResponse, Response } from "@webiny/api-graphql/responses.js";
|
|
3
4
|
import { WcpContext } from "../../features/wcp/WcpContext/index.js";
|
|
4
5
|
class WcpSchemaFactoryImpl {
|
|
@@ -19,6 +20,7 @@ class WcpSchemaFactoryImpl {
|
|
|
19
20
|
fileManager: WcpProjectPackageFeaturesFeature
|
|
20
21
|
aiPowerups: WcpProjectPackageFeaturesFeature
|
|
21
22
|
abTesting: WcpProjectPackageFeaturesFeature
|
|
23
|
+
collaboration: WcpProjectPackageFeaturesFeature
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
type WcpProjectPackage {
|
|
@@ -85,6 +87,9 @@ class WcpSchemaFactoryImpl {
|
|
|
85
87
|
});
|
|
86
88
|
return builder;
|
|
87
89
|
}
|
|
90
|
+
constructor(){
|
|
91
|
+
this.getSchemaKey = staticSchemaKey("api-core/WcpSchemaFactoryImpl");
|
|
92
|
+
}
|
|
88
93
|
}
|
|
89
94
|
const WcpSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({
|
|
90
95
|
implementation: WcpSchemaFactoryImpl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql/wcp/WcpSchemaFactory.js","sources":["../../../src/graphql/wcp/WcpSchemaFactory.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/responses.js\";\nimport { WcpContext } from \"~/features/wcp/WcpContext/index.js\";\n\nclass WcpSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(/* GraphQL */ `\n type WcpProjectPackageFeaturesFeature {\n enabled: Boolean\n options: JSON\n }\n\n type WcpProjectPackageFeatures {\n seats: WcpProjectPackageFeaturesFeature\n multiTenancy: WcpProjectPackageFeaturesFeature\n advancedPublishingWorkflow: WcpProjectPackageFeaturesFeature\n advancedAccessControlLayer: WcpProjectPackageFeaturesFeature\n auditLogs: WcpProjectPackageFeaturesFeature\n recordLocking: WcpProjectPackageFeaturesFeature\n fileManager: WcpProjectPackageFeaturesFeature\n aiPowerups: WcpProjectPackageFeaturesFeature\n abTesting: WcpProjectPackageFeaturesFeature\n }\n\n type WcpProjectPackage {\n features: WcpProjectPackageFeatures\n }\n\n type WcpProject {\n orgId: ID\n projectId: ID\n package: WcpProjectPackage\n }\n\n type WcpError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type WcpProjectResponse {\n data: WcpProject\n error: WcpError\n }\n\n type WcpQuery {\n getProject: WcpProjectResponse\n }\n\n type WcpMutation {\n updateProject: WcpProjectResponse\n }\n\n extend type Query {\n wcp: WcpQuery\n }\n\n extend type Mutation {\n wcp: WcpMutation\n }\n `);\n\n builder.addResolver({\n path: \"Query.wcp\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"WcpQuery.getProject\",\n dependencies: [WcpContext],\n resolver: (wcpContext: WcpContext.Interface) => async () => {\n try {\n const project = wcpContext.getProjectWithFeatureFlags();\n\n if (!project) {\n throw Error(`Could not get project!`);\n }\n\n return new Response(project);\n } catch (e) {\n return new ErrorResponse({\n code: \"COULD_NOT_GET_PROJECT\",\n message: e.message,\n data: null,\n stack: e.stack\n });\n }\n }\n });\n\n return builder;\n }\n}\n\nexport const WcpSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({\n implementation: WcpSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["WcpSchemaFactoryImpl","builder","WcpContext","wcpContext","project","Error","Response","e","ErrorResponse","WcpSchemaFactory","CoreGraphQLSchemaFactory"],"mappings":"
|
|
1
|
+
{"version":3,"file":"graphql/wcp/WcpSchemaFactory.js","sources":["../../../src/graphql/wcp/WcpSchemaFactory.ts"],"sourcesContent":["import { CoreGraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport { staticSchemaKey } from \"@webiny/api-graphql/graphql/staticSchemaKey.js\";\nimport type { IGraphQLSchemaBuilder } from \"@webiny/api-graphql/features/GraphQLSchemaBuilder/abstractions.js\";\nimport { ErrorResponse, Response } from \"@webiny/api-graphql/responses.js\";\nimport { WcpContext } from \"~/features/wcp/WcpContext/index.js\";\n\nclass WcpSchemaFactoryImpl implements CoreGraphQLSchemaFactory.Interface {\n public getSchemaKey = staticSchemaKey(\"api-core/WcpSchemaFactoryImpl\");\n\n async execute(builder: IGraphQLSchemaBuilder): Promise<IGraphQLSchemaBuilder> {\n builder.addTypeDefs(/* GraphQL */ `\n type WcpProjectPackageFeaturesFeature {\n enabled: Boolean\n options: JSON\n }\n\n type WcpProjectPackageFeatures {\n seats: WcpProjectPackageFeaturesFeature\n multiTenancy: WcpProjectPackageFeaturesFeature\n advancedPublishingWorkflow: WcpProjectPackageFeaturesFeature\n advancedAccessControlLayer: WcpProjectPackageFeaturesFeature\n auditLogs: WcpProjectPackageFeaturesFeature\n recordLocking: WcpProjectPackageFeaturesFeature\n fileManager: WcpProjectPackageFeaturesFeature\n aiPowerups: WcpProjectPackageFeaturesFeature\n abTesting: WcpProjectPackageFeaturesFeature\n collaboration: WcpProjectPackageFeaturesFeature\n }\n\n type WcpProjectPackage {\n features: WcpProjectPackageFeatures\n }\n\n type WcpProject {\n orgId: ID\n projectId: ID\n package: WcpProjectPackage\n }\n\n type WcpError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type WcpProjectResponse {\n data: WcpProject\n error: WcpError\n }\n\n type WcpQuery {\n getProject: WcpProjectResponse\n }\n\n type WcpMutation {\n updateProject: WcpProjectResponse\n }\n\n extend type Query {\n wcp: WcpQuery\n }\n\n extend type Mutation {\n wcp: WcpMutation\n }\n `);\n\n builder.addResolver({\n path: \"Query.wcp\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"WcpQuery.getProject\",\n dependencies: [WcpContext],\n resolver: (wcpContext: WcpContext.Interface) => async () => {\n try {\n const project = wcpContext.getProjectWithFeatureFlags();\n\n if (!project) {\n throw Error(`Could not get project!`);\n }\n\n return new Response(project);\n } catch (e) {\n return new ErrorResponse({\n code: \"COULD_NOT_GET_PROJECT\",\n message: e.message,\n data: null,\n stack: e.stack\n });\n }\n }\n });\n\n return builder;\n }\n}\n\nexport const WcpSchemaFactory = CoreGraphQLSchemaFactory.createImplementation({\n implementation: WcpSchemaFactoryImpl,\n dependencies: []\n});\n"],"names":["WcpSchemaFactoryImpl","builder","WcpContext","wcpContext","project","Error","Response","e","ErrorResponse","staticSchemaKey","WcpSchemaFactory","CoreGraphQLSchemaFactory"],"mappings":";;;;AAMA,MAAMA;IAGF,MAAM,QAAQC,OAA8B,EAAkC;QAC1EA,QAAQ,WAAW,CAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwDnC,CAAC;QAEDA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,UAAU,IAAM,UAAa,EAAC;QAClC;QAEAA,QAAQ,WAAW,CAAC;YAChB,MAAM;YACN,cAAc;gBAACC;aAAW;YAC1B,UAAU,CAACC,aAAqC;oBAC5C,IAAI;wBACA,MAAMC,UAAUD,WAAW,0BAA0B;wBAErD,IAAI,CAACC,SACD,MAAMC,MAAM;wBAGhB,OAAO,IAAIC,SAASF;oBACxB,EAAE,OAAOG,GAAG;wBACR,OAAO,IAAIC,cAAc;4BACrB,MAAM;4BACN,SAASD,EAAE,OAAO;4BAClB,MAAM;4BACN,OAAOA,EAAE,KAAK;wBAClB;oBACJ;gBACJ;QACJ;QAEA,OAAON;IACX;;aA1FO,YAAY,GAAGQ,gBAAgB;;AA2F1C;AAEO,MAAMC,mBAAmBC,yBAAyB,oBAAoB,CAAC;IAC1E,gBAAgBX;IAChB,cAAc,EAAE;AACpB"}
|
package/idp/JwksCache.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import type { Jwk } from "../features/security/utils/verifyJwtUsingJwk.js";
|
|
2
|
+
import { HttpClient } from "../features/httpClient/index.js";
|
|
2
3
|
import { JwkCache } from "./abstractions.js";
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import { JwksStore } from "./abstractions.js";
|
|
5
|
+
declare class JwksCacheImpl implements JwkCache.Interface {
|
|
6
|
+
private readonly httpClient;
|
|
7
|
+
private readonly store;
|
|
8
|
+
private readonly states;
|
|
9
|
+
constructor(httpClient: HttpClient.Interface, store: JwksStore.Interface | undefined);
|
|
5
10
|
getKeys(issuer: string): Promise<Jwk[]>;
|
|
6
|
-
|
|
11
|
+
refreshKeys(issuer: string): Promise<Jwk[] | null>;
|
|
12
|
+
private getState;
|
|
13
|
+
private fetchKeys;
|
|
14
|
+
private loadKeys;
|
|
15
|
+
private fetchJson;
|
|
7
16
|
}
|
|
17
|
+
export declare const JwksCache: import("@webiny/di").Implementation<typeof JwksCacheImpl>;
|
|
18
|
+
export {};
|