@webiny/api-core 6.4.12-beta.5 → 6.5.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ApiCoreFeature.js +0 -2
- package/ApiCoreFeature.js.map +1 -1
- package/createApiCore.d.ts +1 -1
- package/createApiCore.js +9 -7
- package/createApiCore.js.map +1 -1
- package/exports/api/security/api-key.d.ts +1 -0
- package/exports/api/security/api-key.js +1 -0
- package/exports/api.d.ts +2 -1
- package/exports/api.js +1 -1
- package/features/ai/Ai.d.ts +3 -1
- package/features/ai/Ai.js +38 -3
- package/features/ai/Ai.js.map +1 -1
- package/features/ai/AiModelRegistry.js +3 -1
- package/features/ai/AiModelRegistry.js.map +1 -1
- package/features/ai/AnthropicSdkFactory.js +24 -4
- package/features/ai/AnthropicSdkFactory.js.map +1 -1
- package/features/ai/DEVELOPERS.md +126 -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 +67 -11
- package/features/ai/OpenAiSdkFactory.js.map +1 -1
- package/features/ai/TextExtractor/DefaultTextExtractor.d.ts +9 -0
- package/features/ai/TextExtractor/DefaultTextExtractor.js +28 -0
- package/features/ai/TextExtractor/DefaultTextExtractor.js.map +1 -0
- package/features/ai/TextExtractor/abstractions.d.ts +12 -0
- package/features/ai/TextExtractor/abstractions.js +5 -0
- package/features/ai/TextExtractor/abstractions.js.map +1 -0
- package/features/ai/TextExtractor/index.d.ts +3 -0
- package/features/ai/TextExtractor/index.js +2 -0
- package/features/ai/TextExtractor/parsers/docxParser.d.ts +1 -0
- package/features/ai/TextExtractor/parsers/docxParser.js +111 -0
- package/features/ai/TextExtractor/parsers/docxParser.js.map +1 -0
- package/features/ai/abstractions.d.ts +4 -0
- package/features/ai/abstractions.js.map +1 -1
- package/features/ai/events.d.ts +59 -0
- package/features/ai/events.js +41 -0
- package/features/ai/events.js.map +1 -0
- package/features/ai/feature.js +9 -1
- package/features/ai/feature.js.map +1 -1
- package/features/ai/index.d.ts +7 -1
- package/features/ai/index.js +3 -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/security/apiKeys/GetApiKey/GetApiKeyUseCase.d.ts +1 -1
- package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -3
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.d.ts +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -3
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.d.ts +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.js.map +1 -1
- package/features/security/apiKeys/feature.js +7 -2
- package/features/security/apiKeys/feature.js.map +1 -1
- package/features/security/apiKeys/shared/ApiKeyProvider.d.ts +3 -5
- package/features/security/apiKeys/shared/ApiKeyProvider.js +6 -21
- package/features/security/apiKeys/shared/ApiKeyProvider.js.map +1 -1
- package/features/security/apiKeys/shared/ApiKeysRepository.d.ts +1 -0
- package/features/security/apiKeys/shared/ApiKeysRepository.js +19 -4
- package/features/security/apiKeys/shared/ApiKeysRepository.js.map +1 -1
- package/features/security/apiKeys/shared/generateToken.d.ts +1 -1
- package/features/security/apiKeys/shared/generateToken.js.map +1 -1
- package/features/security/apiKeys/shared/types.d.ts +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.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/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/users/shared/loaders.js.map +1 -1
- package/features/wcp/WcpContext/WcpContext.d.ts +9 -0
- package/features/wcp/WcpContext/WcpContext.js +27 -0
- package/features/wcp/WcpContext/WcpContext.js.map +1 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +31 -5
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +48 -2
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
- package/legacy/security/plugins/apiKeyAuthentication.d.ts +1 -1
- package/legacy/security/plugins/apiKeyAuthorization.d.ts +1 -1
- package/legacy/security/plugins/authenticateUsingCookie.d.ts +1 -1
- package/legacy/security/plugins/authenticateUsingHttpHeader.d.ts +1 -1
- package/legacy/security/plugins/secureHeaders.js +0 -1
- package/legacy/security/plugins/secureHeaders.js.map +1 -1
- package/legacy/wcp/LegacyWcpContext.d.ts +9 -0
- package/legacy/wcp/LegacyWcpContext.js +27 -0
- package/legacy/wcp/LegacyWcpContext.js.map +1 -1
- package/package.json +24 -25
- package/types/security.d.ts +1 -1
- package/features/debugger/Debugger.d.ts +0 -23
- package/features/debugger/Debugger.js +0 -134
- package/features/debugger/Debugger.js.map +0 -1
- package/features/debugger/GraphQLDebuggerTransport.d.ts +0 -26
- package/features/debugger/GraphQLDebuggerTransport.js +0 -45
- package/features/debugger/GraphQLDebuggerTransport.js.map +0 -1
- package/features/debugger/__tests__/matchNamespace.test.js +0 -67
- package/features/debugger/__tests__/matchNamespace.test.js.map +0 -1
- package/features/debugger/__tests__/serialize.test.d.ts +0 -1
- package/features/debugger/__tests__/serialize.test.js +0 -220
- package/features/debugger/__tests__/serialize.test.js.map +0 -1
- package/features/debugger/abstractions.d.ts +0 -100
- package/features/debugger/abstractions.js +0 -6
- package/features/debugger/abstractions.js.map +0 -1
- package/features/debugger/feature.d.ts +0 -5
- package/features/debugger/feature.js +0 -15
- package/features/debugger/feature.js.map +0 -1
- package/features/debugger/index.d.ts +0 -7
- package/features/debugger/index.js +0 -7
- package/features/debugger/limits.d.ts +0 -18
- package/features/debugger/limits.js +0 -11
- package/features/debugger/limits.js.map +0 -1
- package/features/debugger/matchNamespace.d.ts +0 -21
- package/features/debugger/matchNamespace.js +0 -48
- package/features/debugger/matchNamespace.js.map +0 -1
- package/features/debugger/permissions.d.ts +0 -33
- package/features/debugger/permissions.js +0 -12
- package/features/debugger/permissions.js.map +0 -1
- package/features/debugger/permissionsSchema.d.ts +0 -17
- package/features/debugger/permissionsSchema.js +0 -18
- package/features/debugger/permissionsSchema.js.map +0 -1
- package/features/debugger/plugins.d.ts +0 -4
- package/features/debugger/plugins.js +0 -82
- package/features/debugger/plugins.js.map +0 -1
- package/features/debugger/serialize.d.ts +0 -11
- package/features/debugger/serialize.js +0 -121
- package/features/debugger/serialize.js.map +0 -1
- /package/features/{debugger/__tests__/matchNamespace.test.d.ts → serviceDiscovery/__tests__/ServiceDiscovery.test.d.ts} +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it } from "vitest";
|
|
2
|
+
import { ServiceDiscovery } from "../ServiceDiscovery.js";
|
|
3
|
+
describe("ServiceDiscovery", ()=>{
|
|
4
|
+
beforeEach(()=>{
|
|
5
|
+
ServiceDiscovery.clear();
|
|
6
|
+
});
|
|
7
|
+
it("should throw if no loader is set", async ()=>{
|
|
8
|
+
ServiceDiscovery.loader = void 0;
|
|
9
|
+
await expect(ServiceDiscovery.load()).rejects.toThrow("ServiceDiscovery loader not configured");
|
|
10
|
+
});
|
|
11
|
+
it("should load manifests and combine them by name", async ()=>{
|
|
12
|
+
const loader = {
|
|
13
|
+
async load () {
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
name: "api",
|
|
17
|
+
manifest: {
|
|
18
|
+
cloudfront: {
|
|
19
|
+
distributionId: "123"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "core",
|
|
25
|
+
manifest: {
|
|
26
|
+
bucket: {
|
|
27
|
+
name: "my-bucket"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
ServiceDiscovery.setLoader(loader);
|
|
35
|
+
const result = await ServiceDiscovery.load();
|
|
36
|
+
expect(result).toEqual({
|
|
37
|
+
api: {
|
|
38
|
+
cloudfront: {
|
|
39
|
+
distributionId: "123"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
core: {
|
|
43
|
+
bucket: {
|
|
44
|
+
name: "my-bucket"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
it("should cache the result and not call loader again", async ()=>{
|
|
50
|
+
let callCount = 0;
|
|
51
|
+
const loader = {
|
|
52
|
+
async load () {
|
|
53
|
+
callCount++;
|
|
54
|
+
return [
|
|
55
|
+
{
|
|
56
|
+
name: "api",
|
|
57
|
+
manifest: {
|
|
58
|
+
url: "https://example.com"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
ServiceDiscovery.setLoader(loader);
|
|
65
|
+
await ServiceDiscovery.load();
|
|
66
|
+
await ServiceDiscovery.load();
|
|
67
|
+
await ServiceDiscovery.load();
|
|
68
|
+
expect(callCount).toBe(1);
|
|
69
|
+
});
|
|
70
|
+
it("should return undefined when loader returns undefined", async ()=>{
|
|
71
|
+
const loader = {
|
|
72
|
+
async load () {}
|
|
73
|
+
};
|
|
74
|
+
ServiceDiscovery.setLoader(loader);
|
|
75
|
+
const result = await ServiceDiscovery.load();
|
|
76
|
+
expect(result).toBeUndefined();
|
|
77
|
+
});
|
|
78
|
+
it("should reload after clear()", async ()=>{
|
|
79
|
+
let callCount = 0;
|
|
80
|
+
const loader = {
|
|
81
|
+
async load () {
|
|
82
|
+
callCount++;
|
|
83
|
+
return [
|
|
84
|
+
{
|
|
85
|
+
name: "api",
|
|
86
|
+
manifest: {
|
|
87
|
+
version: callCount
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
ServiceDiscovery.setLoader(loader);
|
|
94
|
+
const first = await ServiceDiscovery.load();
|
|
95
|
+
expect(first).toEqual({
|
|
96
|
+
api: {
|
|
97
|
+
version: 1
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
ServiceDiscovery.clear();
|
|
101
|
+
const second = await ServiceDiscovery.load();
|
|
102
|
+
expect(second).toEqual({
|
|
103
|
+
api: {
|
|
104
|
+
version: 2
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
expect(callCount).toBe(2);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=ServiceDiscovery.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/serviceDiscovery/__tests__/ServiceDiscovery.test.js","sources":["../../../../src/features/serviceDiscovery/__tests__/ServiceDiscovery.test.ts"],"sourcesContent":["import { describe, it, expect, beforeEach } from \"vitest\";\nimport { ServiceDiscovery } from \"../ServiceDiscovery.js\";\nimport type { IServiceManifestLoader } from \"../ServiceDiscovery.js\";\n\ndescribe(\"ServiceDiscovery\", () => {\n beforeEach(() => {\n ServiceDiscovery.clear();\n });\n\n it(\"should throw if no loader is set\", async () => {\n (ServiceDiscovery as any).loader = undefined;\n\n await expect(ServiceDiscovery.load()).rejects.toThrow(\n \"ServiceDiscovery loader not configured\"\n );\n });\n\n it(\"should load manifests and combine them by name\", async () => {\n const loader: IServiceManifestLoader = {\n async load() {\n return [\n { name: \"api\", manifest: { cloudfront: { distributionId: \"123\" } } },\n { name: \"core\", manifest: { bucket: { name: \"my-bucket\" } } }\n ];\n }\n };\n\n ServiceDiscovery.setLoader(loader);\n\n const result = await ServiceDiscovery.load();\n\n expect(result).toEqual({\n api: { cloudfront: { distributionId: \"123\" } },\n core: { bucket: { name: \"my-bucket\" } }\n });\n });\n\n it(\"should cache the result and not call loader again\", async () => {\n let callCount = 0;\n const loader: IServiceManifestLoader = {\n async load() {\n callCount++;\n return [{ name: \"api\", manifest: { url: \"https://example.com\" } }];\n }\n };\n\n ServiceDiscovery.setLoader(loader);\n\n await ServiceDiscovery.load();\n await ServiceDiscovery.load();\n await ServiceDiscovery.load();\n\n expect(callCount).toBe(1);\n });\n\n it(\"should return undefined when loader returns undefined\", async () => {\n const loader: IServiceManifestLoader = {\n async load() {\n return undefined;\n }\n };\n\n ServiceDiscovery.setLoader(loader);\n\n const result = await ServiceDiscovery.load();\n expect(result).toBeUndefined();\n });\n\n it(\"should reload after clear()\", async () => {\n let callCount = 0;\n const loader: IServiceManifestLoader = {\n async load() {\n callCount++;\n return [{ name: \"api\", manifest: { version: callCount } }];\n }\n };\n\n ServiceDiscovery.setLoader(loader);\n\n const first = await ServiceDiscovery.load();\n expect(first).toEqual({ api: { version: 1 } });\n\n ServiceDiscovery.clear();\n\n const second = await ServiceDiscovery.load();\n expect(second).toEqual({ api: { version: 2 } });\n expect(callCount).toBe(2);\n });\n});\n"],"names":["describe","beforeEach","ServiceDiscovery","it","undefined","expect","loader","result","callCount","first","second"],"mappings":";;AAIAA,SAAS,oBAAoB;IACzBC,WAAW;QACPC,iBAAiB,KAAK;IAC1B;IAEAC,GAAG,oCAAoC;QAClCD,iBAAAA,MAA+B,GAAGE;QAEnC,MAAMC,OAAOH,iBAAiB,IAAI,IAAI,OAAO,CAAC,OAAO,CACjD;IAER;IAEAC,GAAG,kDAAkD;QACjD,MAAMG,SAAiC;YACnC,MAAM;gBACF,OAAO;oBACH;wBAAE,MAAM;wBAAO,UAAU;4BAAE,YAAY;gCAAE,gBAAgB;4BAAM;wBAAE;oBAAE;oBACnE;wBAAE,MAAM;wBAAQ,UAAU;4BAAE,QAAQ;gCAAE,MAAM;4BAAY;wBAAE;oBAAE;iBAC/D;YACL;QACJ;QAEAJ,iBAAiB,SAAS,CAACI;QAE3B,MAAMC,SAAS,MAAML,iBAAiB,IAAI;QAE1CG,OAAOE,QAAQ,OAAO,CAAC;YACnB,KAAK;gBAAE,YAAY;oBAAE,gBAAgB;gBAAM;YAAE;YAC7C,MAAM;gBAAE,QAAQ;oBAAE,MAAM;gBAAY;YAAE;QAC1C;IACJ;IAEAJ,GAAG,qDAAqD;QACpD,IAAIK,YAAY;QAChB,MAAMF,SAAiC;YACnC,MAAM;gBACFE;gBACA,OAAO;oBAAC;wBAAE,MAAM;wBAAO,UAAU;4BAAE,KAAK;wBAAsB;oBAAE;iBAAE;YACtE;QACJ;QAEAN,iBAAiB,SAAS,CAACI;QAE3B,MAAMJ,iBAAiB,IAAI;QAC3B,MAAMA,iBAAiB,IAAI;QAC3B,MAAMA,iBAAiB,IAAI;QAE3BG,OAAOG,WAAW,IAAI,CAAC;IAC3B;IAEAL,GAAG,yDAAyD;QACxD,MAAMG,SAAiC;YACnC,MAAM,SAEN;QACJ;QAEAJ,iBAAiB,SAAS,CAACI;QAE3B,MAAMC,SAAS,MAAML,iBAAiB,IAAI;QAC1CG,OAAOE,QAAQ,aAAa;IAChC;IAEAJ,GAAG,+BAA+B;QAC9B,IAAIK,YAAY;QAChB,MAAMF,SAAiC;YACnC,MAAM;gBACFE;gBACA,OAAO;oBAAC;wBAAE,MAAM;wBAAO,UAAU;4BAAE,SAASA;wBAAU;oBAAE;iBAAE;YAC9D;QACJ;QAEAN,iBAAiB,SAAS,CAACI;QAE3B,MAAMG,QAAQ,MAAMP,iBAAiB,IAAI;QACzCG,OAAOI,OAAO,OAAO,CAAC;YAAE,KAAK;gBAAE,SAAS;YAAE;QAAE;QAE5CP,iBAAiB,KAAK;QAEtB,MAAMQ,SAAS,MAAMR,iBAAiB,IAAI;QAC1CG,OAAOK,QAAQ,OAAO,CAAC;YAAE,KAAK;gBAAE,SAAS;YAAE;QAAE;QAC7CL,OAAOG,WAAW,IAAI,CAAC;IAC3B;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ServiceDiscovery } from "./ServiceDiscovery.js";
|
|
@@ -8,7 +8,7 @@ declare class CreateTenantUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
|
8
8
|
private eventPublisher;
|
|
9
9
|
private repository;
|
|
10
10
|
constructor(eventPublisher: EventPublisher.Interface, repository: CreateTenantRepository.Interface);
|
|
11
|
-
execute(data: CreateTenantInput): Promise<Result<
|
|
11
|
+
execute(data: CreateTenantInput): Promise<Result<never, CreateTenantError> | Result<Tenant, never>>;
|
|
12
12
|
}
|
|
13
13
|
export declare const CreateTenantUseCase: import("@webiny/di").Implementation<typeof CreateTenantUseCaseImpl>;
|
|
14
14
|
export {};
|
|
@@ -13,7 +13,7 @@ declare class InstallTenantUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
|
13
13
|
private updateTenantUseCase;
|
|
14
14
|
private resolver;
|
|
15
15
|
constructor(tenantContext: TenantContext.Interface, eventPublisher: EventPublisher.Interface, appInstallers: AppInstaller.Interface[], updateTenantUseCase: UpdateTenantUseCase.Interface);
|
|
16
|
-
execute({ tenant, installationInput }: TenantInstallationInput): Promise<Result<void, never> | Result<never,
|
|
16
|
+
execute({ tenant, installationInput }: TenantInstallationInput): Promise<Result<void, never> | Result<never, InstallTenantError> | Result<never, InstallationDependencyError>>;
|
|
17
17
|
private rollback;
|
|
18
18
|
}
|
|
19
19
|
export declare const InstallTenantUseCase: import("@webiny/di").Implementation<typeof InstallTenantUseCaseImpl>;
|
|
@@ -9,9 +9,9 @@ declare class UpdateTenantUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
|
9
9
|
private eventPublisher;
|
|
10
10
|
private repository;
|
|
11
11
|
constructor(getTenantById: GetTenantByIdUseCase.Interface, eventPublisher: EventPublisher.Interface, repository: UpdateTenantRepository.Interface);
|
|
12
|
-
execute(id: string, data: Partial<Tenant>): Promise<({
|
|
12
|
+
execute(id: string, data: Partial<Tenant>): Promise<Result<Tenant, never> | ({
|
|
13
13
|
_error: import("../GetTenantById/abstractions.js").GetTenantByIdError;
|
|
14
|
-
} & Result<Tenant, import("../GetTenantById/abstractions.js").GetTenantByIdError>)
|
|
14
|
+
} & Result<Tenant, import("../GetTenantById/abstractions.js").GetTenantByIdError>)>;
|
|
15
15
|
}
|
|
16
16
|
export declare const UpdateTenantUseCase: import("@webiny/di").Implementation<typeof UpdateTenantUseCaseImpl>;
|
|
17
17
|
export {};
|
|
@@ -5,7 +5,7 @@ declare class CreateUserWithWcpIncrementImpl implements CreateUserUseCase.Interf
|
|
|
5
5
|
private wcp;
|
|
6
6
|
private decoratee;
|
|
7
7
|
constructor(wcp: WcpContext.Interface, decoratee: CreateUserUseCase.Interface);
|
|
8
|
-
execute(input: CreateUserInput): Promise<import("@webiny/feature/api").Result<import("~/features/users/shared/types.js").AdminUser, import("../../shared/errors.js").
|
|
8
|
+
execute(input: CreateUserInput): Promise<import("@webiny/feature/api").Result<import("~/features/users/shared/types.js").AdminUser, import("../../shared/errors.js").EmailTakenError | import("../../shared/errors.js").NotAuthorizedError | import("../../shared/errors.js").UserNotFoundError | import("../../shared/errors.js").UserStorageError | import("../../shared/errors.js").UserValidationError>>;
|
|
9
9
|
}
|
|
10
10
|
export declare const CreateUserWithWcpIncrement: typeof CreateUserWithWcpIncrementImpl;
|
|
11
11
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/users/shared/loaders.js","sources":["../../../../src/features/users/shared/loaders.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport flatten from \"lodash/flatten.js\";\nimport type { AdminUsersStorageOperations } from \"~/types/users.js\";\nimport type { AdminUser } from \"./types.js\";\n\ninterface Config {\n getTenant(): string;\n storageOperations: AdminUsersStorageOperations;\n}\n\ninterface GetUserLoaderKey {\n id: string;\n tenant: string;\n}\n\nexport const createUserLoaders = ({ storageOperations }: Config) => {\n const loaders = new Map<string, DataLoader<any, any>>();\n\n async function getUserLoader(ids: readonly GetUserLoaderKey[]) {\n if (ids.length === 0) {\n return [];\n }\n\n // Group by tenant\n const byTenant = ids.reduce(\n (acc, item) => {\n acc[item.tenant] = [...(acc[item.tenant] || []), item.id];\n return acc;\n },\n {} as Record<string, string[]>\n );\n\n try {\n const results = await Promise.all(\n Object.keys(byTenant).map(tenant => {\n return storageOperations.listUsers({\n where: {\n tenant,\n id_in: byTenant[tenant]\n }\n });\n })\n ).then(res => flatten(res));\n\n return ids.map(({ tenant, id }) => {\n const user = results.find(item => item.id === id && item.tenant === tenant);\n /**\n * Casting because DataLoader expect error. But we do not.\n */\n return user || (null as unknown as Error);\n });\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not execute batch read in getUser.\",\n code: \"BATCH_READ_ERROR\",\n data: { ids }\n });\n }\n }\n\n return {\n get getUser() {\n let userLoader = loaders.get(\"getUser\");\n if (userLoader) {\n return userLoader;\n }\n userLoader = new DataLoader<GetUserLoaderKey, AdminUser, string>(getUserLoader, {\n cacheKeyFn(key) {\n return `${key.tenant}:${key.id}`;\n }\n });\n loaders.set(\"getUser\", userLoader);\n return userLoader;\n },\n\n clearLoadersCache(ids: GetUserLoaderKey[]) {\n for (const id of ids) {\n this.getUser.clear(id);\n }\n },\n\n async updateDataLoaderUserCache(id: GetUserLoaderKey, data: Partial<AdminUser>) {\n const user = await this.getUser.load(id);\n this.getUser.clear(id).prime(id, Object.assign({}, user, data));\n }\n };\n};\n"],"names":["createUserLoaders","storageOperations","loaders","Map","getUserLoader","ids","byTenant","acc","item","results","Promise","Object","tenant","res","flatten","id","user","err","WebinyError","userLoader","DataLoader","key","data"],"mappings":";;;AAgBO,MAAMA,oBAAoB,CAAC,EAAEC,iBAAiB,EAAU;IAC3D,MAAMC,UAAU,IAAIC;IAEpB,eAAeC,cAAcC,GAAgC;QACzD,IAAIA,AAAe,MAAfA,IAAI,MAAM,EACV,OAAO,EAAE;QAIb,MAAMC,WAAWD,IAAI,MAAM,CACvB,CAACE,KAAKC;YACFD,GAAG,CAACC,KAAK,MAAM,CAAC,GAAG;mBAAKD,GAAG,CAACC,KAAK,MAAM,CAAC,IAAI,EAAE;gBAAGA,KAAK,EAAE;aAAC;YACzD,OAAOD;QACX,GACA,CAAC;QAGL,IAAI;YACA,MAAME,UAAU,MAAMC,QAAQ,GAAG,CAC7BC,OAAO,IAAI,CAACL,UAAU,GAAG,CAACM,CAAAA,SACfX,kBAAkB,SAAS,CAAC;oBAC/B,OAAO;wBACHW;wBACA,OAAON,QAAQ,CAACM,OAAO;oBAC3B;gBACJ,KAEN,IAAI,CAACC,CAAAA,MAAOC,QAAQD;YAEtB,OAAOR,IAAI,GAAG,CAAC,CAAC,EAAEO,MAAM,EAAEG,EAAE,EAAE;gBAC1B,MAAMC,OAAOP,QAAQ,IAAI,CAACD,CAAAA,OAAQA,KAAK,EAAE,KAAKO,MAAMP,KAAK,MAAM,KAAKI;gBAIpE,OAAOI,QAAS;YACpB;QACJ,EAAE,OAAOC,KAAK;YACV,MAAMC,MAAAA,IAAgB,CAACD,KAAK;gBACxB,SAAS;gBACT,MAAM;gBACN,MAAM;oBAAEZ;gBAAI;YAChB;QACJ;IACJ;IAEA,OAAO;QACH,IAAI;
|
|
1
|
+
{"version":3,"file":"features/users/shared/loaders.js","sources":["../../../../src/features/users/shared/loaders.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport flatten from \"lodash/flatten.js\";\nimport type { AdminUsersStorageOperations } from \"~/types/users.js\";\nimport type { AdminUser } from \"./types.js\";\n\ninterface Config {\n getTenant(): string;\n storageOperations: AdminUsersStorageOperations;\n}\n\ninterface GetUserLoaderKey {\n id: string;\n tenant: string;\n}\n\nexport const createUserLoaders = ({ storageOperations }: Config) => {\n const loaders = new Map<string, DataLoader<any, any>>();\n\n async function getUserLoader(ids: readonly GetUserLoaderKey[]) {\n if (ids.length === 0) {\n return [];\n }\n\n // Group by tenant\n const byTenant = ids.reduce(\n (acc, item) => {\n acc[item.tenant] = [...(acc[item.tenant] || []), item.id];\n return acc;\n },\n {} as Record<string, string[]>\n );\n\n try {\n const results = await Promise.all(\n Object.keys(byTenant).map(tenant => {\n return storageOperations.listUsers({\n where: {\n tenant,\n id_in: byTenant[tenant]\n }\n });\n })\n ).then(res => flatten(res));\n\n return ids.map(({ tenant, id }) => {\n const user = results.find(item => item.id === id && item.tenant === tenant);\n /**\n * Casting because DataLoader expect error. But we do not.\n */\n return user || (null as unknown as Error);\n });\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not execute batch read in getUser.\",\n code: \"BATCH_READ_ERROR\",\n data: { ids }\n });\n }\n }\n\n return {\n get getUser() {\n let userLoader = loaders.get(\"getUser\");\n if (userLoader) {\n return userLoader;\n }\n userLoader = new DataLoader<GetUserLoaderKey, AdminUser, string>(getUserLoader, {\n cacheKeyFn(key) {\n return `${key.tenant}:${key.id}`;\n }\n });\n loaders.set(\"getUser\", userLoader);\n return userLoader;\n },\n\n clearLoadersCache(ids: GetUserLoaderKey[]) {\n for (const id of ids) {\n this.getUser.clear(id);\n }\n },\n\n async updateDataLoaderUserCache(id: GetUserLoaderKey, data: Partial<AdminUser>) {\n const user = await this.getUser.load(id);\n this.getUser.clear(id).prime(id, Object.assign({}, user, data));\n }\n };\n};\n"],"names":["createUserLoaders","storageOperations","loaders","Map","getUserLoader","ids","byTenant","acc","item","results","Promise","Object","tenant","res","flatten","id","user","err","WebinyError","userLoader","DataLoader","key","data"],"mappings":";;;AAgBO,MAAMA,oBAAoB,CAAC,EAAEC,iBAAiB,EAAU;IAC3D,MAAMC,UAAU,IAAIC;IAEpB,eAAeC,cAAcC,GAAgC;QACzD,IAAIA,AAAe,MAAfA,IAAI,MAAM,EACV,OAAO,EAAE;QAIb,MAAMC,WAAWD,IAAI,MAAM,CACvB,CAACE,KAAKC;YACFD,GAAG,CAACC,KAAK,MAAM,CAAC,GAAG;mBAAKD,GAAG,CAACC,KAAK,MAAM,CAAC,IAAI,EAAE;gBAAGA,KAAK,EAAE;aAAC;YACzD,OAAOD;QACX,GACA,CAAC;QAGL,IAAI;YACA,MAAME,UAAU,MAAMC,QAAQ,GAAG,CAC7BC,OAAO,IAAI,CAACL,UAAU,GAAG,CAACM,CAAAA,SACfX,kBAAkB,SAAS,CAAC;oBAC/B,OAAO;wBACHW;wBACA,OAAON,QAAQ,CAACM,OAAO;oBAC3B;gBACJ,KAEN,IAAI,CAACC,CAAAA,MAAOC,QAAQD;YAEtB,OAAOR,IAAI,GAAG,CAAC,CAAC,EAAEO,MAAM,EAAEG,EAAE,EAAE;gBAC1B,MAAMC,OAAOP,QAAQ,IAAI,CAACD,CAAAA,OAAQA,KAAK,EAAE,KAAKO,MAAMP,KAAK,MAAM,KAAKI;gBAIpE,OAAOI,QAAS;YACpB;QACJ,EAAE,OAAOC,KAAK;YACV,MAAMC,MAAAA,IAAgB,CAACD,KAAK;gBACxB,SAAS;gBACT,MAAM;gBACN,MAAM;oBAAEZ;gBAAI;YAChB;QACJ;IACJ;IAEA,OAAO;QACH,IAAI,WAAU;YACV,IAAIc,aAAajB,QAAQ,GAAG,CAAC;YAC7B,IAAIiB,YACA,OAAOA;YAEXA,aAAa,IAAIC,WAAgDhB,eAAe;gBAC5E,YAAWiB,GAAG;oBACV,OAAO,GAAGA,IAAI,MAAM,CAAC,CAAC,EAAEA,IAAI,EAAE,EAAE;gBACpC;YACJ;YACAnB,QAAQ,GAAG,CAAC,WAAWiB;YACvB,OAAOA;QACX;QAEA,mBAAkBd,GAAuB;YACrC,KAAK,MAAMU,MAAMV,IACb,IAAI,CAAC,OAAO,CAAC,KAAK,CAACU;QAE3B;QAEA,MAAM,2BAA0BA,EAAoB,EAAEO,IAAwB;YAC1E,MAAMN,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAACD;YACrC,IAAI,CAAC,OAAO,CAAC,KAAK,CAACA,IAAI,KAAK,CAACA,IAAIJ,OAAO,MAAM,CAAC,CAAC,GAAGK,MAAMM;QAC7D;IACJ;AACJ"}
|
|
@@ -27,7 +27,16 @@ export declare class WcpContextImpl implements WcpContext.Interface {
|
|
|
27
27
|
canUseHcmsFieldPermissions(): boolean;
|
|
28
28
|
canUseAiImageEnrichment(): boolean;
|
|
29
29
|
canUseAiPageGeneration(): boolean;
|
|
30
|
+
canUseAiPageTranslation(): boolean;
|
|
30
31
|
canUseAiLexicalGeneration(): boolean;
|
|
32
|
+
canUseAiEntryGeneration(): boolean;
|
|
33
|
+
canUseAiEntryComparison(): boolean;
|
|
34
|
+
canUseAiEntryTranslation(): boolean;
|
|
35
|
+
canUseRemoteComponents(): boolean;
|
|
36
|
+
canUseAbTesting(): boolean;
|
|
37
|
+
canUseCollaboration(): boolean;
|
|
38
|
+
canUseComments(): boolean;
|
|
39
|
+
canUseActivityLog(): boolean;
|
|
31
40
|
ensureCanUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): void;
|
|
32
41
|
incrementSeats(): Promise<void>;
|
|
33
42
|
decrementSeats(): Promise<void>;
|
|
@@ -108,9 +108,36 @@ class WcpContextImpl {
|
|
|
108
108
|
canUseAiPageGeneration() {
|
|
109
109
|
return this.license.canUseAiPageGeneration();
|
|
110
110
|
}
|
|
111
|
+
canUseAiPageTranslation() {
|
|
112
|
+
return this.license.canUseAiPageTranslation();
|
|
113
|
+
}
|
|
111
114
|
canUseAiLexicalGeneration() {
|
|
112
115
|
return this.license.canUseAiLexicalGeneration();
|
|
113
116
|
}
|
|
117
|
+
canUseAiEntryGeneration() {
|
|
118
|
+
return this.license.canUseAiEntryGeneration();
|
|
119
|
+
}
|
|
120
|
+
canUseAiEntryComparison() {
|
|
121
|
+
return this.license.canUseAiEntryComparison();
|
|
122
|
+
}
|
|
123
|
+
canUseAiEntryTranslation() {
|
|
124
|
+
return this.license.canUseAiEntryTranslation();
|
|
125
|
+
}
|
|
126
|
+
canUseRemoteComponents() {
|
|
127
|
+
return this.license.canUseRemoteComponents();
|
|
128
|
+
}
|
|
129
|
+
canUseAbTesting() {
|
|
130
|
+
return this.license.canUseAbTesting();
|
|
131
|
+
}
|
|
132
|
+
canUseCollaboration() {
|
|
133
|
+
return this.license.canUseCollaboration();
|
|
134
|
+
}
|
|
135
|
+
canUseComments() {
|
|
136
|
+
return this.license.canUseComments();
|
|
137
|
+
}
|
|
138
|
+
canUseActivityLog() {
|
|
139
|
+
return this.license.canUseActivityLog();
|
|
140
|
+
}
|
|
114
141
|
ensureCanUseFeature(wcpFeatureId) {
|
|
115
142
|
if (this.license.canUseFeature(wcpFeatureId)) return;
|
|
116
143
|
let message = `The ${wcpFeatureId} Webiny Control Panel feature cannot be used because your project license does not permit it.`;
|
|
@@ -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 interface CreateWcpContextParams {\n testProjectLicense?: DecryptedWcpProjectLicense;\n}\n\nexport class WcpContextImpl implements WcpContext.Interface {\n constructor(private license: ILicense) {}\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","license","path","orgId","projectId","url","Boolean","getWcpApiUrl","operation","updateSeatsUrl","response","wcpFetch","message","console","WError","updateTenantsUrl","wcpFeatureId","org","project","upgradeProjectLicenseLink","getWcpAppUrl"],"mappings":";;;AAYA,MAAMA,wBAAwBC;AAMvB,MAAMC;IACT,YAAoBC,OAAiB,CAAE;aAAnBA,OAAO,GAAPA;IAAoB;IAEhC,iBAAiBC,OAAO,EAAE,EAAiB;QAC/C,IAAI,CAACJ,uBACD,OAAO;QAGX,MAAMK,QAAQL,sBAAsB,GAAG,CAAC,EAAE;QAC1C,MAAMM,YAAYN,sBAAsB,OAAO,CAAC,EAAE;QAClD,MAAMO,MAAM;YAAC;YAASF;YAAO;YAAYC;YAAWF;SAAK,CAAC,MAAM,CAACI,SAAS,IAAI,CAAC;QAC/E,OAAOC,aAAaF;IACxB;IAEA,MAAc,YAAYG,SAAoC,EAAiB;QAC3E,IAAI,CAACV,uBACD;QAGJ,MAAMW,iBAAiB,IAAI,CAAC,gBAAgB,CAAC;QAE7C,MAAMC,WAAW,MAAMC,SAAS;YAC5B,KAAKF;YACL,eAAeX,sBAAsB,MAAM;YAC3C,MAAM;gBAAEU;YAAU;YAClB,MAAM;gBACF,QAAQA,YAAY;YACxB;Q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EA,MAAM,mBAAkC;QACpC,MAAM,IAAI,CAAC,aAAa,CAAC;IAC7B;IAEA,QAAQ;QACJ,OAAO,IAAI,CAAC,aAAa;IAC7B;AACJ"}
|
|
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 interface CreateWcpContextParams {\n testProjectLicense?: DecryptedWcpProjectLicense;\n}\n\nexport class WcpContextImpl implements WcpContext.Interface {\n constructor(private license: ILicense) {}\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 canUseAiPageTranslation(): boolean {\n return this.license.canUseAiPageTranslation();\n }\n\n canUseAiLexicalGeneration(): boolean {\n return this.license.canUseAiLexicalGeneration();\n }\n\n canUseAiEntryGeneration(): boolean {\n return this.license.canUseAiEntryGeneration();\n }\n\n canUseAiEntryComparison(): boolean {\n return this.license.canUseAiEntryComparison();\n }\n\n canUseAiEntryTranslation(): boolean {\n return this.license.canUseAiEntryTranslation();\n }\n\n canUseRemoteComponents(): boolean {\n return this.license.canUseRemoteComponents();\n }\n\n canUseAbTesting(): boolean {\n return this.license.canUseAbTesting();\n }\n\n canUseCollaboration(): boolean {\n return this.license.canUseCollaboration();\n }\n\n canUseComments(): boolean {\n return this.license.canUseComments();\n }\n\n canUseActivityLog(): boolean {\n return this.license.canUseActivityLog();\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","license","path","orgId","projectId","url","Boolean","getWcpApiUrl","operation","updateSeatsUrl","response","wcpFetch","message","console","WError","updateTenantsUrl","wcpFeatureId","org","project","upgradeProjectLicenseLink","getWcpAppUrl"],"mappings":";;;AAYA,MAAMA,wBAAwBC;AAMvB,MAAMC;IACT,YAAoBC,OAAiB,CAAE;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J,OAAO,IAAI,CAAC,aAAa;IAC7B;AACJ"}
|
|
@@ -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: {
|
|
@@ -48,23 +56,32 @@ declare class WcpContextWithFeatureFlagsDecoratorImpl implements WcpContext.Inte
|
|
|
48
56
|
options: {
|
|
49
57
|
websiteBuilder: {
|
|
50
58
|
pageGeneration: boolean | undefined;
|
|
59
|
+
pageTranslation: boolean | undefined;
|
|
51
60
|
};
|
|
52
61
|
fileManager: {
|
|
53
62
|
imageEnrichment: boolean | undefined;
|
|
54
63
|
};
|
|
55
64
|
lexicalGeneration: boolean | undefined;
|
|
65
|
+
remoteComponents: boolean | undefined;
|
|
66
|
+
cms: {
|
|
67
|
+
entryGeneration: boolean | undefined;
|
|
68
|
+
entryComparison: boolean | undefined;
|
|
69
|
+
entryTranslation: boolean | undefined;
|
|
70
|
+
};
|
|
56
71
|
};
|
|
57
72
|
};
|
|
58
|
-
|
|
59
|
-
enabled:
|
|
73
|
+
abTesting: {
|
|
74
|
+
enabled: boolean;
|
|
75
|
+
};
|
|
76
|
+
collaboration: {
|
|
77
|
+
enabled: boolean;
|
|
60
78
|
options: {
|
|
61
|
-
|
|
79
|
+
comments: boolean | undefined;
|
|
80
|
+
activityLog: boolean | undefined;
|
|
62
81
|
};
|
|
63
82
|
};
|
|
64
83
|
};
|
|
65
84
|
};
|
|
66
|
-
orgId: string;
|
|
67
|
-
projectId: string;
|
|
68
85
|
} | null;
|
|
69
86
|
getProjectEnvironment(): import("@webiny/wcp/types.js").WcpProjectEnvironment | null;
|
|
70
87
|
getProjectLicense(): import("@webiny/wcp/types.js").ILicense;
|
|
@@ -80,7 +97,16 @@ declare class WcpContextWithFeatureFlagsDecoratorImpl implements WcpContext.Inte
|
|
|
80
97
|
canUseHcmsFieldPermissions(): boolean;
|
|
81
98
|
canUseAiImageEnrichment(): boolean;
|
|
82
99
|
canUseAiPageGeneration(): boolean;
|
|
100
|
+
canUseAiPageTranslation(): boolean;
|
|
83
101
|
canUseAiLexicalGeneration(): boolean;
|
|
102
|
+
canUseAiEntryGeneration(): boolean;
|
|
103
|
+
canUseAiEntryComparison(): boolean;
|
|
104
|
+
canUseAiEntryTranslation(): boolean;
|
|
105
|
+
canUseRemoteComponents(): boolean;
|
|
106
|
+
canUseAbTesting(): boolean;
|
|
107
|
+
canUseCollaboration(): boolean;
|
|
108
|
+
canUseComments(): boolean;
|
|
109
|
+
canUseActivityLog(): boolean;
|
|
84
110
|
ensureCanUseFeature(featureId: keyof typeof WCP_FEATURE_LABEL): void;
|
|
85
111
|
incrementSeats(): Promise<void>;
|
|
86
112
|
decrementSeats(): Promise<void>;
|
|
@@ -56,12 +56,31 @@ class WcpContextWithFeatureFlagsDecoratorImpl {
|
|
|
56
56
|
enabled: flags.isAiPowerupsEnabled() ? project.package.features.aiPowerups?.enabled : false,
|
|
57
57
|
options: {
|
|
58
58
|
websiteBuilder: {
|
|
59
|
-
pageGeneration: flags.isAiPageGenerationEnabled() ? project.package.features.aiPowerups?.options?.websiteBuilder?.pageGeneration : false
|
|
59
|
+
pageGeneration: flags.isAiPageGenerationEnabled() ? project.package.features.aiPowerups?.options?.websiteBuilder?.pageGeneration : false,
|
|
60
|
+
pageTranslation: flags.isAiPageTranslationEnabled() ? project.package.features.aiPowerups?.options?.websiteBuilder?.pageTranslation : false
|
|
60
61
|
},
|
|
61
62
|
fileManager: {
|
|
62
63
|
imageEnrichment: flags.isAiImageEnrichmentEnabled() ? project.package.features.aiPowerups?.options?.fileManager?.imageEnrichment : false
|
|
63
64
|
},
|
|
64
|
-
lexicalGeneration: flags.isAiLexicalGenerationEnabled() ? project.package.features.aiPowerups?.options?.lexicalGeneration : false
|
|
65
|
+
lexicalGeneration: flags.isAiLexicalGenerationEnabled() ? project.package.features.aiPowerups?.options?.lexicalGeneration : false,
|
|
66
|
+
remoteComponents: flags.isAiRemoteComponentsEnabled() ? project.package.features.aiPowerups?.options?.remoteComponents : false,
|
|
67
|
+
cms: {
|
|
68
|
+
entryGeneration: flags.isAiEntryGenerationEnabled() ? project.package.features.aiPowerups?.options?.cms?.entryGeneration : false,
|
|
69
|
+
entryComparison: flags.isAiEntryComparisonEnabled() ? project.package.features.aiPowerups?.options?.cms?.entryComparison : false,
|
|
70
|
+
entryTranslation: flags.isAiEntryTranslationEnabled() ? project.package.features.aiPowerups?.options?.cms?.entryTranslation : false
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
abTesting: {
|
|
75
|
+
...project.package.features.abTesting,
|
|
76
|
+
enabled: flags.isAbTestingEnabled() ? project.package.features.abTesting?.enabled : false
|
|
77
|
+
},
|
|
78
|
+
collaboration: {
|
|
79
|
+
...project.package.features.collaboration,
|
|
80
|
+
enabled: flags.isCollaborationEnabled() ? project.package.features.collaboration?.enabled : false,
|
|
81
|
+
options: {
|
|
82
|
+
comments: flags.isCommentsEnabled() ? project.package.features.collaboration?.options?.comments : false,
|
|
83
|
+
activityLog: flags.isActivityLogEnabled() ? project.package.features.collaboration?.options?.activityLog : false
|
|
65
84
|
}
|
|
66
85
|
}
|
|
67
86
|
}
|
|
@@ -110,9 +129,36 @@ class WcpContextWithFeatureFlagsDecoratorImpl {
|
|
|
110
129
|
canUseAiPageGeneration() {
|
|
111
130
|
return this.decoratee.canUseAiPageGeneration() && this.featureFlags.get().isAiPageGenerationEnabled();
|
|
112
131
|
}
|
|
132
|
+
canUseAiPageTranslation() {
|
|
133
|
+
return this.decoratee.canUseAiPageTranslation() && this.featureFlags.get().isAiPageTranslationEnabled();
|
|
134
|
+
}
|
|
113
135
|
canUseAiLexicalGeneration() {
|
|
114
136
|
return this.decoratee.canUseAiLexicalGeneration() && this.featureFlags.get().isAiLexicalGenerationEnabled();
|
|
115
137
|
}
|
|
138
|
+
canUseAiEntryGeneration() {
|
|
139
|
+
return this.decoratee.canUseAiEntryGeneration() && this.featureFlags.get().isAiEntryGenerationEnabled();
|
|
140
|
+
}
|
|
141
|
+
canUseAiEntryComparison() {
|
|
142
|
+
return this.decoratee.canUseAiEntryComparison() && this.featureFlags.get().isAiEntryComparisonEnabled();
|
|
143
|
+
}
|
|
144
|
+
canUseAiEntryTranslation() {
|
|
145
|
+
return this.decoratee.canUseAiEntryTranslation() && this.featureFlags.get().isAiEntryTranslationEnabled();
|
|
146
|
+
}
|
|
147
|
+
canUseRemoteComponents() {
|
|
148
|
+
return this.decoratee.canUseRemoteComponents() && this.featureFlags.get().isAiRemoteComponentsEnabled();
|
|
149
|
+
}
|
|
150
|
+
canUseAbTesting() {
|
|
151
|
+
return this.decoratee.canUseAbTesting() && this.featureFlags.get().isAbTestingEnabled();
|
|
152
|
+
}
|
|
153
|
+
canUseCollaboration() {
|
|
154
|
+
return this.decoratee.canUseCollaboration() && this.featureFlags.get().isCollaborationEnabled();
|
|
155
|
+
}
|
|
156
|
+
canUseComments() {
|
|
157
|
+
return this.decoratee.canUseComments() && this.featureFlags.get().isCommentsEnabled();
|
|
158
|
+
}
|
|
159
|
+
canUseActivityLog() {
|
|
160
|
+
return this.decoratee.canUseActivityLog() && this.featureFlags.get().isActivityLogEnabled();
|
|
161
|
+
}
|
|
116
162
|
ensureCanUseFeature(featureId) {
|
|
117
163
|
return this.decoratee.ensureCanUseFeature(featureId);
|
|
118
164
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js","sources":["../../../../../src/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.ts"],"sourcesContent":["import type { WCP_FEATURE_LABEL } from \"@webiny/wcp\";\nimport { WcpContext } from \"../abstractions.js\";\nimport { FeatureFlags } from \"../../../featureFlags/abstractions.js\";\n\nclass WcpContextWithFeatureFlagsDecoratorImpl implements WcpContext.Interface {\n constructor(\n private featureFlags: FeatureFlags.Interface,\n private decoratee: WcpContext.Interface\n ) {}\n\n getRawLicense() {\n return this.decoratee.getRawLicense();\n }\n\n getProject() {\n return this.decoratee.getProject();\n }\n\n getProjectWithFeatureFlags() {\n const project = this.decoratee.getProjectWithFeatureFlags();\n if (!project) {\n return null;\n }\n\n const flags = this.featureFlags.get();\n\n return {\n ...project,\n package: {\n ...project.package,\n features: {\n ...project.package.features,\n multiTenancy: project.package.features.multiTenancy,\n advancedPublishingWorkflow: {\n ...project.package.features.advancedPublishingWorkflow,\n enabled: flags.isWorkflowsEnabled()\n ? project.package.features.advancedPublishingWorkflow.enabled\n : false\n },\n advancedAccessControlLayer: {\n ...project.package.features.advancedAccessControlLayer,\n enabled: flags.isAaclEnabled()\n ? project.package.features.advancedAccessControlLayer.enabled\n : false,\n options: {\n teams: flags.isTeamsEnabled()\n ? project.package.features.advancedAccessControlLayer.options.teams\n : false,\n privateFiles: flags.isPrivateFilesEnabled()\n ? project.package.features.advancedAccessControlLayer.options\n .privateFiles\n : false,\n folderLevelPermissions: flags.isFolderLevelPermissionsEnabled()\n ? project.package.features.advancedAccessControlLayer.options\n .folderLevelPermissions\n : false,\n hcmsFieldPermissions: flags.isHcmsFieldPermissionsEnabled()\n ? project.package.features.advancedAccessControlLayer.options\n .hcmsFieldPermissions\n : false\n }\n },\n auditLogs: {\n ...project.package.features.auditLogs,\n enabled: flags.isAuditLogsEnabled()\n ? project.package.features.auditLogs.enabled\n : false\n },\n recordLocking: {\n ...project.package.features.recordLocking,\n enabled: flags.isRecordLockingEnabled()\n ? project.package.features.recordLocking.enabled\n : false\n },\n fileManager: {\n ...project.package.features.fileManager,\n enabled: project.package.features.fileManager.enabled,\n options: {\n threatDetection: flags.isFileManagerThreatDetectionEnabled()\n ? project.package.features.fileManager.options.threatDetection\n : false\n }\n },\n aiPowerups: {\n ...project.package.features.aiPowerups,\n enabled: flags.isAiPowerupsEnabled()\n ? project.package.features.aiPowerups?.enabled\n : false,\n options: {\n websiteBuilder: {\n pageGeneration: flags.isAiPageGenerationEnabled()\n ? project.package.features.aiPowerups?.options?.websiteBuilder\n ?.pageGeneration\n : false\n },\n fileManager: {\n imageEnrichment: flags.isAiImageEnrichmentEnabled()\n ? project.package.features.aiPowerups?.options?.fileManager\n ?.imageEnrichment\n : false\n },\n lexicalGeneration: flags.isAiLexicalGenerationEnabled()\n ? project.package.features.aiPowerups?.options?.lexicalGeneration\n : false\n }\n }\n }\n }\n };\n }\n\n getProjectEnvironment() {\n return this.decoratee.getProjectEnvironment();\n }\n\n getProjectLicense() {\n return this.decoratee.getProjectLicense();\n }\n\n canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL) {\n return this.decoratee.canUseFeature(wcpFeatureId);\n }\n\n canUseAacl() {\n return this.decoratee.canUseAacl() && this.featureFlags.get().isAaclEnabled();\n }\n\n canUseTeams() {\n return this.decoratee.canUseTeams() && this.featureFlags.get().isTeamsEnabled();\n }\n\n canUseFolderLevelPermissions() {\n return (\n this.decoratee.canUseFolderLevelPermissions() &&\n this.featureFlags.get().isFolderLevelPermissionsEnabled()\n );\n }\n\n canUsePrivateFiles() {\n return (\n this.decoratee.canUsePrivateFiles() && this.featureFlags.get().isPrivateFilesEnabled()\n );\n }\n\n canUseAuditLogs() {\n return this.decoratee.canUseAuditLogs() && this.featureFlags.get().isAuditLogsEnabled();\n }\n\n canUseRecordLocking() {\n return (\n this.decoratee.canUseRecordLocking() && this.featureFlags.get().isRecordLockingEnabled()\n );\n }\n\n canUseFileManagerThreatDetection() {\n return (\n this.decoratee.canUseFileManagerThreatDetection() &&\n this.featureFlags.get().isFileManagerThreatDetectionEnabled()\n );\n }\n\n canUseWorkflows() {\n return this.decoratee.canUseWorkflows() && this.featureFlags.get().isWorkflowsEnabled();\n }\n\n canUseHcmsFieldPermissions() {\n return (\n this.decoratee.canUseHcmsFieldPermissions() &&\n this.featureFlags.get().isHcmsFieldPermissionsEnabled()\n );\n }\n\n canUseAiImageEnrichment() {\n return (\n this.decoratee.canUseAiImageEnrichment() &&\n this.featureFlags.get().isAiImageEnrichmentEnabled()\n );\n }\n\n canUseAiPageGeneration() {\n return (\n this.decoratee.canUseAiPageGeneration() &&\n this.featureFlags.get().isAiPageGenerationEnabled()\n );\n }\n\n canUseAiLexicalGeneration() {\n return (\n this.decoratee.canUseAiLexicalGeneration() &&\n this.featureFlags.get().isAiLexicalGenerationEnabled()\n );\n }\n\n ensureCanUseFeature(featureId: keyof typeof WCP_FEATURE_LABEL) {\n return this.decoratee.ensureCanUseFeature(featureId);\n }\n\n async incrementSeats() {\n return this.decoratee.incrementSeats();\n }\n\n async decrementSeats() {\n return this.decoratee.decrementSeats();\n }\n\n async incrementTenants() {\n return this.decoratee.incrementTenants();\n }\n\n async decrementTenants() {\n return this.decoratee.decrementTenants();\n }\n\n toDto() {\n return this.decoratee.toDto();\n }\n}\n\nexport const WcpContextWithFeatureFlagsDecorator = WcpContext.createDecorator({\n decorator: WcpContextWithFeatureFlagsDecoratorImpl,\n dependencies: [FeatureFlags]\n});\n"],"names":["WcpContextWithFeatureFlagsDecoratorImpl","featureFlags","decoratee","project","flags","wcpFeatureId","featureId","WcpContextWithFeatureFlagsDecorator","WcpContext","FeatureFlags"],"mappings":";;AAIA,MAAMA;IACF,YACYC,YAAoC,EACpCC,SAA+B,CACzC;aAFUD,YAAY,GAAZA;aACAC,SAAS,GAATA;IACT;IAEH,gBAAgB;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa;IACvC;IAEA,aAAa;QACT,OAAO,IAAI,CAA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AAY,CAAC,GAAG,GAAG,yBAAyB;IAEzD;IAEA,4BAA4B;QACxB,OACI,IAAI,CAAC,SAAS,CAAC,yBAAyB,MACxC,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,4BAA4B;IAE5D;IAEA,oBAAoBC,SAAyC,EAAE;QAC3D,OAAO,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAACA;IAC9C;IAEA,MAAM,iBAAiB;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc;IACxC;IAEA,MAAM,iBAAiB;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc;IACxC;IAEA,MAAM,mBAAmB;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB;IAC1C;IAEA,MAAM,mBAAmB;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB;IAC1C;IAEA,QAAQ;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK;IAC/B;AACJ;AAEO,MAAMC,sCAAsCC,WAAW,eAAe,CAAC;IAC1E,WAAWR;IACX,cAAc;QAACS;KAAa;AAChC"}
|
|
1
|
+
{"version":3,"file":"features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js","sources":["../../../../../src/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.ts"],"sourcesContent":["import type { WCP_FEATURE_LABEL } from \"@webiny/wcp\";\nimport { WcpContext } from \"../abstractions.js\";\nimport { FeatureFlags } from \"../../../featureFlags/abstractions.js\";\n\nclass WcpContextWithFeatureFlagsDecoratorImpl implements WcpContext.Interface {\n constructor(\n private featureFlags: FeatureFlags.Interface,\n private decoratee: WcpContext.Interface\n ) {}\n\n getRawLicense() {\n return this.decoratee.getRawLicense();\n }\n\n getProject() {\n return this.decoratee.getProject();\n }\n\n getProjectWithFeatureFlags() {\n const project = this.decoratee.getProjectWithFeatureFlags();\n if (!project) {\n return null;\n }\n\n const flags = this.featureFlags.get();\n\n return {\n ...project,\n package: {\n ...project.package,\n features: {\n ...project.package.features,\n multiTenancy: project.package.features.multiTenancy,\n advancedPublishingWorkflow: {\n ...project.package.features.advancedPublishingWorkflow,\n enabled: flags.isWorkflowsEnabled()\n ? project.package.features.advancedPublishingWorkflow.enabled\n : false\n },\n advancedAccessControlLayer: {\n ...project.package.features.advancedAccessControlLayer,\n enabled: flags.isAaclEnabled()\n ? project.package.features.advancedAccessControlLayer.enabled\n : false,\n options: {\n teams: flags.isTeamsEnabled()\n ? project.package.features.advancedAccessControlLayer.options.teams\n : false,\n privateFiles: flags.isPrivateFilesEnabled()\n ? project.package.features.advancedAccessControlLayer.options\n .privateFiles\n : false,\n folderLevelPermissions: flags.isFolderLevelPermissionsEnabled()\n ? project.package.features.advancedAccessControlLayer.options\n .folderLevelPermissions\n : false,\n hcmsFieldPermissions: flags.isHcmsFieldPermissionsEnabled()\n ? project.package.features.advancedAccessControlLayer.options\n .hcmsFieldPermissions\n : false\n }\n },\n auditLogs: {\n ...project.package.features.auditLogs,\n enabled: flags.isAuditLogsEnabled()\n ? project.package.features.auditLogs.enabled\n : false\n },\n recordLocking: {\n ...project.package.features.recordLocking,\n enabled: flags.isRecordLockingEnabled()\n ? project.package.features.recordLocking.enabled\n : false\n },\n fileManager: {\n ...project.package.features.fileManager,\n enabled: project.package.features.fileManager.enabled,\n options: {\n threatDetection: flags.isFileManagerThreatDetectionEnabled()\n ? project.package.features.fileManager.options.threatDetection\n : false\n }\n },\n aiPowerups: {\n ...project.package.features.aiPowerups,\n enabled: flags.isAiPowerupsEnabled()\n ? project.package.features.aiPowerups?.enabled\n : false,\n options: {\n websiteBuilder: {\n pageGeneration: flags.isAiPageGenerationEnabled()\n ? project.package.features.aiPowerups?.options?.websiteBuilder\n ?.pageGeneration\n : false,\n pageTranslation: flags.isAiPageTranslationEnabled()\n ? project.package.features.aiPowerups?.options?.websiteBuilder\n ?.pageTranslation\n : false\n },\n fileManager: {\n imageEnrichment: flags.isAiImageEnrichmentEnabled()\n ? project.package.features.aiPowerups?.options?.fileManager\n ?.imageEnrichment\n : false\n },\n lexicalGeneration: flags.isAiLexicalGenerationEnabled()\n ? project.package.features.aiPowerups?.options?.lexicalGeneration\n : false,\n remoteComponents: flags.isAiRemoteComponentsEnabled()\n ? project.package.features.aiPowerups?.options?.remoteComponents\n : false,\n cms: {\n entryGeneration: flags.isAiEntryGenerationEnabled()\n ? project.package.features.aiPowerups?.options?.cms\n ?.entryGeneration\n : false,\n entryComparison: flags.isAiEntryComparisonEnabled()\n ? project.package.features.aiPowerups?.options?.cms\n ?.entryComparison\n : false,\n entryTranslation: flags.isAiEntryTranslationEnabled()\n ? project.package.features.aiPowerups?.options?.cms\n ?.entryTranslation\n : false\n }\n }\n },\n abTesting: {\n ...project.package.features.abTesting,\n enabled: flags.isAbTestingEnabled()\n ? project.package.features.abTesting?.enabled\n : false\n },\n collaboration: {\n ...project.package.features.collaboration,\n enabled: flags.isCollaborationEnabled()\n ? project.package.features.collaboration?.enabled\n : false,\n options: {\n comments: flags.isCommentsEnabled()\n ? project.package.features.collaboration?.options?.comments\n : false,\n activityLog: flags.isActivityLogEnabled()\n ? project.package.features.collaboration?.options?.activityLog\n : false\n }\n }\n }\n }\n };\n }\n\n getProjectEnvironment() {\n return this.decoratee.getProjectEnvironment();\n }\n\n getProjectLicense() {\n return this.decoratee.getProjectLicense();\n }\n\n canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL) {\n return this.decoratee.canUseFeature(wcpFeatureId);\n }\n\n canUseAacl() {\n return this.decoratee.canUseAacl() && this.featureFlags.get().isAaclEnabled();\n }\n\n canUseTeams() {\n return this.decoratee.canUseTeams() && this.featureFlags.get().isTeamsEnabled();\n }\n\n canUseFolderLevelPermissions() {\n return (\n this.decoratee.canUseFolderLevelPermissions() &&\n this.featureFlags.get().isFolderLevelPermissionsEnabled()\n );\n }\n\n canUsePrivateFiles() {\n return (\n this.decoratee.canUsePrivateFiles() && this.featureFlags.get().isPrivateFilesEnabled()\n );\n }\n\n canUseAuditLogs() {\n return this.decoratee.canUseAuditLogs() && this.featureFlags.get().isAuditLogsEnabled();\n }\n\n canUseRecordLocking() {\n return (\n this.decoratee.canUseRecordLocking() && this.featureFlags.get().isRecordLockingEnabled()\n );\n }\n\n canUseFileManagerThreatDetection() {\n return (\n this.decoratee.canUseFileManagerThreatDetection() &&\n this.featureFlags.get().isFileManagerThreatDetectionEnabled()\n );\n }\n\n canUseWorkflows() {\n return this.decoratee.canUseWorkflows() && this.featureFlags.get().isWorkflowsEnabled();\n }\n\n canUseHcmsFieldPermissions() {\n return (\n this.decoratee.canUseHcmsFieldPermissions() &&\n this.featureFlags.get().isHcmsFieldPermissionsEnabled()\n );\n }\n\n canUseAiImageEnrichment() {\n return (\n this.decoratee.canUseAiImageEnrichment() &&\n this.featureFlags.get().isAiImageEnrichmentEnabled()\n );\n }\n\n canUseAiPageGeneration() {\n return (\n this.decoratee.canUseAiPageGeneration() &&\n this.featureFlags.get().isAiPageGenerationEnabled()\n );\n }\n\n canUseAiPageTranslation() {\n return (\n this.decoratee.canUseAiPageTranslation() &&\n this.featureFlags.get().isAiPageTranslationEnabled()\n );\n }\n\n canUseAiLexicalGeneration() {\n return (\n this.decoratee.canUseAiLexicalGeneration() &&\n this.featureFlags.get().isAiLexicalGenerationEnabled()\n );\n }\n\n canUseAiEntryGeneration() {\n return (\n this.decoratee.canUseAiEntryGeneration() &&\n this.featureFlags.get().isAiEntryGenerationEnabled()\n );\n }\n\n canUseAiEntryComparison() {\n return (\n this.decoratee.canUseAiEntryComparison() &&\n this.featureFlags.get().isAiEntryComparisonEnabled()\n );\n }\n\n canUseAiEntryTranslation() {\n return (\n this.decoratee.canUseAiEntryTranslation() &&\n this.featureFlags.get().isAiEntryTranslationEnabled()\n );\n }\n\n canUseRemoteComponents() {\n return (\n this.decoratee.canUseRemoteComponents() &&\n this.featureFlags.get().isAiRemoteComponentsEnabled()\n );\n }\n\n canUseAbTesting() {\n return this.decoratee.canUseAbTesting() && this.featureFlags.get().isAbTestingEnabled();\n }\n\n canUseCollaboration() {\n return (\n this.decoratee.canUseCollaboration() && this.featureFlags.get().isCollaborationEnabled()\n );\n }\n\n canUseComments() {\n return this.decoratee.canUseComments() && this.featureFlags.get().isCommentsEnabled();\n }\n\n canUseActivityLog() {\n return this.decoratee.canUseActivityLog() && this.featureFlags.get().isActivityLogEnabled();\n }\n\n ensureCanUseFeature(featureId: keyof typeof WCP_FEATURE_LABEL) {\n return this.decoratee.ensureCanUseFeature(featureId);\n }\n\n async incrementSeats() {\n return this.decoratee.incrementSeats();\n }\n\n async decrementSeats() {\n return this.decoratee.decrementSeats();\n }\n\n async incrementTenants() {\n return this.decoratee.incrementTenants();\n }\n\n async decrementTenants() {\n return this.decoratee.decrementTenants();\n }\n\n toDto() {\n return this.decoratee.toDto();\n }\n}\n\nexport const WcpContextWithFeatureFlagsDecorator = WcpContext.createDecorator({\n decorator: WcpContextWithFeatureFlagsDecoratorImpl,\n dependencies: [FeatureFlags]\n});\n"],"names":["WcpContextWithFeatureFlagsDecoratorImpl","featureFlags","decoratee","project","flags","wcpFeatureId","featureId","WcpContextWithFeatureFlagsDecorator","WcpContext","FeatureFlags"],"mappings":";;AAIA,MAAMA;IACF,YACYC,YAAoC,EACpCC,SAA+B,CACzC;aAFUD,YAAY,GAAZA;aACAC,SAAS,GAATA;IACT;IAEH,gBAAgB;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa;IACvC;IAEA,aAAa;QACT,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU;IACpC;IAEA,6BAA6B;QACzB,MAAMC,UAAU,IAAI,CAAC,SAAS,CAAC,0BAA0B;QACzD,IAAI,CAACA,SACD,OAAO;QAGX,MAAMC,QAAQ,IAAI,CAAC,YAAY,CAAC,GAAG;QAEnC,OAAO;YACH,GAAGD,OAAO;YACV,SAAS;gBACL,GAAGA,QAAQ,OAAO;gBAClB,UAAU;oBACN,GAAGA,QAAQ,OAAO,CAAC,QAAQ;oBAC3B,cAAcA,QAAQ,OAAO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Context } from "../../../types/core.js";
|
|
|
3
3
|
export interface Config {
|
|
4
4
|
identityType?: string;
|
|
5
5
|
}
|
|
6
|
-
declare const _default: ({ identityType }: Config) => ContextPlugin<ApiCoreContext>;
|
|
7
6
|
export default _default;
|
|
7
|
+
declare function _default({ identityType }: Config): ContextPlugin<ApiCoreContext>;
|
|
@@ -2,5 +2,5 @@ import type { ApiCoreContext } from "../../../types/core.js";
|
|
|
2
2
|
export interface Config {
|
|
3
3
|
identityType?: string;
|
|
4
4
|
}
|
|
5
|
-
declare const _default: (config: Config) => import("@webiny/api").ContextPlugin<ApiCoreContext>;
|
|
6
5
|
export default _default;
|
|
6
|
+
declare function _default(config: Config): import("@webiny/api").ContextPlugin<ApiCoreContext>;
|
|
@@ -2,4 +2,4 @@ import type { ApiCoreContext } from "../../../types/core.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function authenticateUsingCookie(): (import("@webiny/
|
|
5
|
+
export declare function authenticateUsingCookie(): (import("@webiny/handler").BeforeHandlerPlugin<ApiCoreContext> | import("@webiny/api").ContextPlugin<ApiCoreContext>)[];
|
|
@@ -2,4 +2,4 @@ import type { ApiCoreContext } from "../../../types/core.js";
|
|
|
2
2
|
export interface GetHeader {
|
|
3
3
|
(context: ApiCoreContext): string | null | undefined;
|
|
4
4
|
}
|
|
5
|
-
export declare const authenticateUsingHttpHeader: () => (import("@webiny/handler").BeforeHandlerPlugin<ApiCoreContext> |
|
|
5
|
+
export declare const authenticateUsingHttpHeader: () => ((import("@webiny/handler").BeforeHandlerPlugin<ApiCoreContext> | import("@webiny/api/index.js").ContextPlugin<ApiCoreContext>)[] | import("@webiny/handler").BeforeHandlerPlugin<ApiCoreContext> | import("@webiny/handler").HandlerOnRequestPlugin<import("@webiny/handler/types.js").Context>)[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy/security/plugins/secureHeaders.js","sources":["../../../../src/legacy/security/plugins/secureHeaders.ts"],"sourcesContent":["import { createHandlerOnRequest, ResponseHeaders } from \"@webiny/handler\";\n\nconst whitelistedHeaders = [\n \"accept\",\n \"authorization\",\n \"cache-control\",\n \"content-type\",\n \"x-tenant\",\n \"x-apollo-tracing\",\n \"
|
|
1
|
+
{"version":3,"file":"legacy/security/plugins/secureHeaders.js","sources":["../../../../src/legacy/security/plugins/secureHeaders.ts"],"sourcesContent":["import { createHandlerOnRequest, ResponseHeaders } from \"@webiny/handler\";\n\nconst whitelistedHeaders = [\n \"accept\",\n \"authorization\",\n \"cache-control\",\n \"content-type\",\n \"x-tenant\",\n \"x-apollo-tracing\",\n \"apollo-query-plan-experimental\"\n];\n\nexport const setupSecureHeaders = () => {\n return createHandlerOnRequest(async (request, reply) => {\n const isOptions = request.method === \"OPTIONS\";\n\n const headers = ResponseHeaders.create();\n headers.set(\"access-control-allow-origin\", request.headers[\"origin\"]);\n headers.set(\"access-control-allow-credentials\", \"true\");\n\n if (isOptions) {\n headers.set(\"cache-control\", \"public, max-age=86400\");\n headers.set(\"content-type\", \"application/json; charset=utf-8\");\n headers.set(\"access-control-max-age\", \"86400\");\n headers.set(\"access-control-allow-methods\", \"OPTIONS,POST,GET,DELETE,PUT,PATCH\");\n headers.set(\"access-control-allow-headers\", whitelistedHeaders.join(\", \"));\n } else {\n headers.set(\"x-tenant\", request.headers[\"x-tenant\"] || \"root\");\n headers.set(\"vary\", \"origin\");\n }\n\n reply.headers(headers.getHeaders());\n });\n};\n"],"names":["whitelistedHeaders","setupSecureHeaders","createHandlerOnRequest","request","reply","isOptions","headers","ResponseHeaders"],"mappings":";AAEA,MAAMA,qBAAqB;IACvB;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAEM,MAAMC,qBAAqB,IACvBC,uBAAuB,OAAOC,SAASC;QAC1C,MAAMC,YAAYF,AAAmB,cAAnBA,QAAQ,MAAM;QAEhC,MAAMG,UAAUC,gBAAgB,MAAM;QACtCD,QAAQ,GAAG,CAAC,+BAA+BH,QAAQ,OAAO,CAAC,SAAS;QACpEG,QAAQ,GAAG,CAAC,oCAAoC;QAEhD,IAAID,WAAW;YACXC,QAAQ,GAAG,CAAC,iBAAiB;YAC7BA,QAAQ,GAAG,CAAC,gBAAgB;YAC5BA,QAAQ,GAAG,CAAC,0BAA0B;YACtCA,QAAQ,GAAG,CAAC,gCAAgC;YAC5CA,QAAQ,GAAG,CAAC,gCAAgCN,mBAAmB,IAAI,CAAC;QACxE,OAAO;YACHM,QAAQ,GAAG,CAAC,YAAYH,QAAQ,OAAO,CAAC,WAAW,IAAI;YACvDG,QAAQ,GAAG,CAAC,QAAQ;QACxB;QAEAF,MAAM,OAAO,CAACE,QAAQ,UAAU;IACpC"}
|
|
@@ -23,7 +23,16 @@ export declare class LegacyWcpContext implements WcpContextObject {
|
|
|
23
23
|
canUseHcmsFieldPermissions(): boolean;
|
|
24
24
|
canUseAiImageEnrichment(): boolean;
|
|
25
25
|
canUseAiPageGeneration(): boolean;
|
|
26
|
+
canUseAiPageTranslation(): boolean;
|
|
26
27
|
canUseAiLexicalGeneration(): boolean;
|
|
28
|
+
canUseAiEntryGeneration(): boolean;
|
|
29
|
+
canUseAiEntryComparison(): boolean;
|
|
30
|
+
canUseAiEntryTranslation(): boolean;
|
|
31
|
+
canUseRemoteComponents(): boolean;
|
|
32
|
+
canUseAbTesting(): boolean;
|
|
33
|
+
canUseCollaboration(): boolean;
|
|
34
|
+
canUseComments(): boolean;
|
|
35
|
+
canUseActivityLog(): boolean;
|
|
27
36
|
ensureCanUseFeature(featureId: keyof typeof WCP_FEATURE_LABEL): void;
|
|
28
37
|
incrementSeats(): Promise<void>;
|
|
29
38
|
decrementSeats(): Promise<void>;
|