@webiny/api-core 6.6.0-alpha.0 → 6.6.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ApiCoreFeature.js +6 -0
- package/ApiCoreFeature.js.map +1 -1
- package/exports/api/security/api-key.d.ts +1 -0
- package/exports/api/security/api-key.js +1 -0
- package/features/ai/Ai.d.ts +3 -1
- package/features/ai/Ai.js +39 -4
- package/features/ai/Ai.js.map +1 -1
- package/features/ai/AnthropicSdkFactory.js +12 -0
- package/features/ai/AnthropicSdkFactory.js.map +1 -1
- package/features/ai/OpenAiSdkFactory.js +16 -0
- package/features/ai/OpenAiSdkFactory.js.map +1 -1
- package/features/ai/TextExtractor/DefaultTextExtractor.d.ts +9 -0
- package/features/ai/TextExtractor/DefaultTextExtractor.js +28 -0
- package/features/ai/TextExtractor/DefaultTextExtractor.js.map +1 -0
- package/features/ai/TextExtractor/abstractions.d.ts +12 -0
- package/features/ai/TextExtractor/abstractions.js +5 -0
- package/features/ai/TextExtractor/abstractions.js.map +1 -0
- package/features/ai/TextExtractor/index.d.ts +3 -0
- package/features/ai/TextExtractor/index.js +2 -0
- package/features/ai/TextExtractor/parsers/docxParser.d.ts +1 -0
- package/features/ai/TextExtractor/parsers/docxParser.js +111 -0
- package/features/ai/TextExtractor/parsers/docxParser.js.map +1 -0
- package/features/ai/abstractions.d.ts +19 -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 +2 -0
- package/features/ai/feature.js.map +1 -1
- package/features/ai/index.d.ts +5 -1
- package/features/ai/index.js +2 -0
- package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
- package/features/dateFormatter/DefaultDateFormatter.js +20 -0
- package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
- package/features/dateFormatter/abstractions.d.ts +13 -0
- package/features/dateFormatter/abstractions.js +5 -0
- package/features/dateFormatter/abstractions.js.map +1 -0
- package/features/dateFormatter/feature.d.ts +4 -0
- package/features/dateFormatter/feature.js +11 -0
- package/features/dateFormatter/feature.js.map +1 -0
- package/features/dateFormatter/index.d.ts +3 -0
- package/features/dateFormatter/index.js +2 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +49 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
- package/features/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/GetApiKey/GetApiKeyUseCase.d.ts +1 -1
- package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -3
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.d.ts +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -3
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.d.ts +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.js.map +1 -1
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/feature.js +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/schemas.d.ts +2 -2
- package/features/security/apiKeys/shared/schemas.js +2 -2
- package/features/security/apiKeys/shared/schemas.js.map +1 -1
- package/features/security/apiKeys/shared/types.d.ts +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +3 -3
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
- package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
- package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
- package/features/security/roles/CreateRole/schema.d.ts +1 -1
- package/features/security/roles/CreateRole/schema.js +1 -1
- package/features/security/roles/CreateRole/schema.js.map +1 -1
- package/features/security/roles/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 +76 -4
- package/features/task/TaskDefinition/abstractions.js +2 -1
- package/features/task/TaskDefinition/abstractions.js.map +1 -1
- package/features/wcp/WcpContext/WcpContext.d.ts +6 -0
- package/features/wcp/WcpContext/WcpContext.js +18 -0
- package/features/wcp/WcpContext/WcpContext.js.map +1 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +18 -0
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +57 -25
- 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/featureFlags/FeatureFlagsSchemaFactory.d.ts +9 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +49 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
- package/graphql/wcp/WcpSchemaFactory.js +2 -0
- package/graphql/wcp/WcpSchemaFactory.js.map +1 -1
- package/package.json +18 -18
- package/testing/environment.d.ts +14 -0
- package/testing/environment.js +18 -0
- package/testing/environment.js.map +1 -0
- package/types/security.d.ts +1 -1
- 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,19 @@
|
|
|
1
|
+
import { Slugify } from "../slugify/abstractions.js";
|
|
2
|
+
import { StringFormatter } from "./abstractions.js";
|
|
3
|
+
class DefaultStringFormatterImpl {
|
|
4
|
+
constructor(slugifier){
|
|
5
|
+
this.slugifier = slugifier;
|
|
6
|
+
}
|
|
7
|
+
slugify(value) {
|
|
8
|
+
return this.slugifier.execute(value);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const DefaultStringFormatter = StringFormatter.createImplementation({
|
|
12
|
+
implementation: DefaultStringFormatterImpl,
|
|
13
|
+
dependencies: [
|
|
14
|
+
Slugify
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
export { DefaultStringFormatter };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=DefaultStringFormatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/stringFormatter/DefaultStringFormatter.js","sources":["../../../src/features/stringFormatter/DefaultStringFormatter.ts"],"sourcesContent":["import { Slugify } from \"~/features/slugify/abstractions.js\";\nimport { StringFormatter } from \"./abstractions.js\";\n\n/**\n * The string formatter is the consumer-facing API for string transforms. It keeps each transform's\n * logic in its own fine-grained, decoratable feature (e.g. `Slugify`) and just delegates to it, so a\n * project can change one transform without reimplementing the whole formatter. More methods will be\n * added here over time.\n */\nclass DefaultStringFormatterImpl implements StringFormatter.Interface {\n constructor(private readonly slugifier: Slugify.Interface) {}\n\n slugify(value: string): string {\n return this.slugifier.execute(value);\n }\n}\n\nexport const DefaultStringFormatter = StringFormatter.createImplementation({\n implementation: DefaultStringFormatterImpl,\n dependencies: [Slugify]\n});\n"],"names":["DefaultStringFormatterImpl","slugifier","value","DefaultStringFormatter","StringFormatter","Slugify"],"mappings":";;AASA,MAAMA;IACF,YAA6BC,SAA4B,CAAE;aAA9BA,SAAS,GAATA;IAA+B;IAE5D,QAAQC,KAAa,EAAU;QAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAACA;IAClC;AACJ;AAEO,MAAMC,yBAAyBC,gBAAgB,oBAAoB,CAAC;IACvE,gBAAgBJ;IAChB,cAAc;QAACK;KAAQ;AAC3B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface IStringFormatter {
|
|
2
|
+
/**
|
|
3
|
+
* Turns a value into a URL-friendly slug. Delegates to the `Slugify` feature, so to change slug
|
|
4
|
+
* logic decorate `Slugify` alone rather than the whole string formatter.
|
|
5
|
+
*/
|
|
6
|
+
slugify(value: string): string;
|
|
7
|
+
}
|
|
8
|
+
export declare const StringFormatter: import("@webiny/di").Abstraction<IStringFormatter>;
|
|
9
|
+
export declare namespace StringFormatter {
|
|
10
|
+
type Interface = IStringFormatter;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/stringFormatter/abstractions.js","sources":["../../../src/features/stringFormatter/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface IStringFormatter {\n /**\n * Turns a value into a URL-friendly slug. Delegates to the `Slugify` feature, so to change slug\n * logic decorate `Slugify` alone rather than the whole string formatter.\n */\n slugify(value: string): string;\n}\n\nexport const StringFormatter = createAbstraction<IStringFormatter>(\"StringFormatter\");\n\nexport namespace StringFormatter {\n export type Interface = IStringFormatter;\n}\n"],"names":["StringFormatter","createAbstraction"],"mappings":";AAUO,MAAMA,kBAAkBC,kBAAoC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { SlugifyFeature } from "../slugify/feature.js";
|
|
3
|
+
import { DefaultStringFormatter } from "./DefaultStringFormatter.js";
|
|
4
|
+
const StringFormatterFeature = createFeature({
|
|
5
|
+
name: "StringFormatterFeature",
|
|
6
|
+
register (container) {
|
|
7
|
+
SlugifyFeature.register(container);
|
|
8
|
+
container.register(DefaultStringFormatter);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
export { StringFormatterFeature };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/stringFormatter/feature.js","sources":["../../../src/features/stringFormatter/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { SlugifyFeature } from \"~/features/slugify/feature.js\";\nimport { DefaultStringFormatter } from \"./DefaultStringFormatter.js\";\n\nexport const StringFormatterFeature = createFeature({\n name: \"StringFormatterFeature\",\n register(container) {\n // Register the transforms the formatter delegates to, then the formatter itself.\n SlugifyFeature.register(container);\n container.register(DefaultStringFormatter);\n }\n});\n"],"names":["StringFormatterFeature","createFeature","container","SlugifyFeature","DefaultStringFormatter"],"mappings":";;;AAIO,MAAMA,yBAAyBC,cAAc;IAChD,MAAM;IACN,UAASC,SAAS;QAEdC,eAAe,QAAQ,CAACD;QACxBA,UAAU,QAAQ,CAACE;IACvB;AACJ"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import zod from "zod";
|
|
2
|
+
import type { Constructor } from "@webiny/di";
|
|
2
3
|
import type { GenericRecord } from "@webiny/api/types";
|
|
3
4
|
import type { ITask } from "../../../features/task/TaskService/index.js";
|
|
4
5
|
import { TaskController } from "../../../features/task/TaskController/index.js";
|
|
@@ -14,12 +15,33 @@ export interface ITaskOutput {
|
|
|
14
15
|
[key: string]: any;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* The task's own definition, minus its behaviour.
|
|
19
|
+
*
|
|
20
|
+
* Handed to `run()` and to every lifecycle hook so a decorator can tell which task it is wrapping
|
|
21
|
+
* and act on the definition's own fields. A decorator is registered against the abstraction, so it
|
|
22
|
+
* wraps every task; without this it has nothing to branch on but a hardcoded list of ids, which
|
|
23
|
+
* means editing the decorator every time a task is added.
|
|
24
|
+
*
|
|
25
|
+
* This is {@link ITaskMetadata}: identity and policy, no behaviour. The object passed at runtime is
|
|
26
|
+
* the resolved task, so `run` is physically present; naming the metadata type here stops the obvious
|
|
27
|
+
* mistake of a handler calling `params.definition.run(...)` and recursing forever.
|
|
28
|
+
*
|
|
29
|
+
* Only the fields declared here arrive. A field a project adds to its own definition class is
|
|
30
|
+
* currently dropped, because `RunnableTaskDecorator` and `SelfCleaningTaskDecorator` are fixed
|
|
31
|
+
* pass-throughs that expose a known set of getters and nothing else. Making them forward unknown
|
|
32
|
+
* properties would turn a definition into a place to declare policy (a rate limit, a set of tags)
|
|
33
|
+
* that a decorator acts on; `taskDefinitionInParams.test.ts` pins the current behaviour so that
|
|
34
|
+
* change announces itself.
|
|
35
|
+
*/
|
|
36
|
+
export type ITaskDefinitionInfo = ITaskMetadata;
|
|
37
|
+
/**
|
|
38
|
+
* Task run params - the input data, plus the definition being run
|
|
18
39
|
* All runtime dependencies come from TaskController (injected separately)
|
|
19
40
|
*/
|
|
20
41
|
export interface ITaskRunParams<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> {
|
|
21
42
|
input: I;
|
|
22
43
|
controller: TaskController.Interface<I, O>;
|
|
44
|
+
definition: ITaskDefinitionInfo;
|
|
23
45
|
}
|
|
24
46
|
/**
|
|
25
47
|
* Data for creating a new task
|
|
@@ -35,6 +57,7 @@ export interface ITaskCreateData<I = ITaskInput> {
|
|
|
35
57
|
*/
|
|
36
58
|
export interface ITaskBeforeTriggerParams<I = ITaskInput> {
|
|
37
59
|
data: ITaskCreateData<I>;
|
|
60
|
+
definition: ITaskDefinitionInfo;
|
|
38
61
|
}
|
|
39
62
|
/**
|
|
40
63
|
* Task result status enum
|
|
@@ -70,11 +93,16 @@ export type ISelfCleanupEvent = "onSuccess" | "onError" | "onAbort";
|
|
|
70
93
|
export type ISelfCleanup = "always" | "never" | ISelfCleanupEvent | ISelfCleanupEvent[];
|
|
71
94
|
export type ITaskLifecycleHook<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = {
|
|
72
95
|
task: ITask<I, O>;
|
|
96
|
+
definition: ITaskDefinitionInfo;
|
|
73
97
|
};
|
|
74
98
|
/**
|
|
75
|
-
*
|
|
99
|
+
* What a task IS: identity and runtime policy, with no behaviour and no dependencies.
|
|
100
|
+
*
|
|
101
|
+
* Listing tasks, resolving one by id, and applying defaults all need only this. Keeping it free of
|
|
102
|
+
* dependencies is the whole point — `GetTaskDefinitionUseCase` builds every registered definition
|
|
103
|
+
* to find one by id, so anything expensive here is paid 24 times per lookup.
|
|
76
104
|
*/
|
|
77
|
-
export interface
|
|
105
|
+
export interface ITaskMetadata {
|
|
78
106
|
id: string;
|
|
79
107
|
title: string;
|
|
80
108
|
description?: string;
|
|
@@ -82,6 +110,16 @@ export interface ITaskDefinition<I extends ITaskInput = ITaskInput, O extends IT
|
|
|
82
110
|
databaseLogs?: boolean;
|
|
83
111
|
isPrivate?: boolean;
|
|
84
112
|
selfCleanup?: ISelfCleanup;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* What a task DOES. This is the half that carries dependencies (a CMS context, an OpenSearch
|
|
116
|
+
* client), so it is built only for the task actually being run.
|
|
117
|
+
*
|
|
118
|
+
* The lifecycle hooks live here rather than on {@link ITaskMetadata} because they need the same
|
|
119
|
+
* dependencies `run()` does — see `MockDataManagerTask`, whose `onError` and `onAbort` both use the
|
|
120
|
+
* OpenSearch client injected for `run()`.
|
|
121
|
+
*/
|
|
122
|
+
export interface ITaskHandler<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> {
|
|
85
123
|
/**
|
|
86
124
|
* Core run method - receives ONLY input params
|
|
87
125
|
* All runtime dependencies (logging, state management, etc.) come from TaskController
|
|
@@ -101,23 +139,56 @@ export interface ITaskDefinition<I extends ITaskInput = ITaskInput, O extends IT
|
|
|
101
139
|
*/
|
|
102
140
|
createInputValidation?(params: ITaskCreateInputValidationParams): GenericRecord<keyof I, zod.Schema> | zod.Schema;
|
|
103
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Core TaskDefinition - minimal interface
|
|
144
|
+
*
|
|
145
|
+
* TRANSITIONAL SHAPE. A definition supplies its behaviour in one of two ways:
|
|
146
|
+
*
|
|
147
|
+
* - the new way: `handler` names a {@link ITaskHandler} class, which the runner builds only for the
|
|
148
|
+
* task it is about to run;
|
|
149
|
+
* - the old way: the definition implements `run()` and the hooks itself, which forces every
|
|
150
|
+
* definition (and every dependency it injects) to be built just to look one up by id.
|
|
151
|
+
*
|
|
152
|
+
* `run` is optional ONLY to let both shapes coexist while packages migrate. Once every definition
|
|
153
|
+
* carries a `handler`, this interface becomes `ITaskMetadata & { handler }` and the optionality
|
|
154
|
+
* goes away. Exactly one of `run` or `handler` must be present; `GetTaskDefinitionUseCase` fails
|
|
155
|
+
* with {@link TaskDefinitionNotRunnableError} if neither is.
|
|
156
|
+
*/
|
|
157
|
+
export interface ITaskDefinition<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> extends ITaskMetadata, Partial<ITaskHandler<I, O>> {
|
|
158
|
+
handler?: Constructor<ITaskHandler<I, O>>;
|
|
159
|
+
}
|
|
104
160
|
export interface ITaskCreateInputValidationParams {
|
|
105
161
|
validator: typeof zod;
|
|
106
162
|
}
|
|
107
163
|
/** Define a long-running background task with lifecycle hooks. */
|
|
108
164
|
export declare const TaskDefinition: import("@webiny/di").Abstraction<ITaskDefinition<ITaskInput, ITaskOutput>>;
|
|
165
|
+
/**
|
|
166
|
+
* The behaviour half of a task, resolved on demand by the runner via
|
|
167
|
+
* `container.resolveImplementation(definition.handler)`. Registered implementations are NOT
|
|
168
|
+
* registered against this abstraction — the definition points at the class directly, exactly as
|
|
169
|
+
* `HttpRouteDefinition` points at its `HttpRouteHandler`.
|
|
170
|
+
*/
|
|
171
|
+
export declare const TaskHandler: import("@webiny/di").Abstraction<ITaskHandler<ITaskInput, ITaskOutput>>;
|
|
109
172
|
/**
|
|
110
173
|
* IRunnableTaskDefinition represents a TaskDefinition after decoration/processing.
|
|
111
174
|
* All optional runtime properties are guaranteed to have values (with defaults applied).
|
|
112
175
|
* Used internally by the task runner to ensure consistent behavior.
|
|
113
176
|
*/
|
|
114
|
-
export interface IRunnableTaskDefinition<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> extends
|
|
177
|
+
export interface IRunnableTaskDefinition<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> extends ITaskMetadata, ITaskHandler<I, O> {
|
|
115
178
|
isPrivate: boolean;
|
|
116
179
|
databaseLogs: boolean;
|
|
117
180
|
maxIterations: number;
|
|
118
181
|
}
|
|
182
|
+
export declare namespace TaskHandler {
|
|
183
|
+
type Interface<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskHandler<I, O>;
|
|
184
|
+
type RunParams<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskRunParams<I, O>;
|
|
185
|
+
type Result<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskResult<I, O>;
|
|
186
|
+
type LifecycleHookParams<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskLifecycleHook<I, O>;
|
|
187
|
+
}
|
|
119
188
|
export declare namespace TaskDefinition {
|
|
120
189
|
type Interface<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskDefinition<I, O>;
|
|
190
|
+
type Metadata = ITaskMetadata;
|
|
191
|
+
type Handler<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskHandler<I, O>;
|
|
121
192
|
type TaskInput = ITaskInput;
|
|
122
193
|
type TaskOutput = ITaskOutput;
|
|
123
194
|
type Runnable<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = IRunnableTaskDefinition<I, O>;
|
|
@@ -132,6 +203,7 @@ export declare namespace TaskDefinition {
|
|
|
132
203
|
type TaskCreateData<I = ITaskInput> = ITaskCreateData<I>;
|
|
133
204
|
type BeforeTriggerParams<I = ITaskInput> = ITaskBeforeTriggerParams<I>;
|
|
134
205
|
type LifecycleHookParams<I extends ITaskInput = ITaskInput, O extends ITaskOutput = ITaskOutput> = ITaskLifecycleHook<I, O>;
|
|
206
|
+
type Info = ITaskDefinitionInfo;
|
|
135
207
|
type SelfCleanupEvent = ISelfCleanupEvent;
|
|
136
208
|
type SelfCleanup = ISelfCleanup;
|
|
137
209
|
}
|
|
@@ -7,6 +7,7 @@ var abstractions_TaskResultStatus = /*#__PURE__*/ function(TaskResultStatus) {
|
|
|
7
7
|
return TaskResultStatus;
|
|
8
8
|
}({});
|
|
9
9
|
const TaskDefinition = createAbstraction("TaskDefinition");
|
|
10
|
-
|
|
10
|
+
const TaskHandler = createAbstraction("TaskHandler");
|
|
11
|
+
export { TaskDefinition, TaskHandler, abstractions_TaskResultStatus as TaskResultStatus };
|
|
11
12
|
|
|
12
13
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/task/TaskDefinition/abstractions.js","sources":["../../../../src/features/task/TaskDefinition/abstractions.ts"],"sourcesContent":["import zod from \"zod\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { GenericRecord } from \"@webiny/api/types\";\nimport type { ITask } from \"~/features/task/TaskService/index.js\";\nimport { TaskController } from \"~/features/task/TaskController/index.js\";\n\nexport type ITaskInput = GenericRecord;\n\nexport interface IResponseError {\n message: string;\n code?: string | null;\n data?: GenericRecord | null;\n stack?: string;\n}\n\nexport interface ITaskOutput {\n error?: IResponseError;\n [key: string]: any;\n}\n\n/**\n * Task run params - ONLY the input data\n * All runtime dependencies come from TaskController (injected separately)\n */\nexport interface ITaskRunParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> {\n input: I;\n controller: TaskController.Interface<I, O>;\n}\n\n/**\n * Data for creating a new task\n */\nexport interface ITaskCreateData<I = ITaskInput> {\n definitionId: string;\n name: string;\n input: I;\n parentId?: string;\n}\n\n/**\n * Parameters for onBeforeTrigger lifecycle hook\n */\nexport interface ITaskBeforeTriggerParams<I = ITaskInput> {\n data: ITaskCreateData<I>;\n}\n\n/**\n * Task result status enum\n */\nexport enum TaskResultStatus {\n DONE = \"done\",\n CONTINUE = \"continue\",\n ERROR = \"error\",\n ABORTED = \"aborted\"\n}\n\n/**\n * Specific result types\n */\nexport interface ITaskResultDone<O extends ITaskOutput = ITaskOutput> {\n status: TaskResultStatus.DONE;\n message?: string;\n output?: O;\n}\n\nexport interface ITaskResultContinue<I = ITaskInput> {\n status: TaskResultStatus.CONTINUE;\n input: I;\n wait?: number; // seconds to wait before next iteration\n}\n\nexport interface ITaskResultError {\n status: TaskResultStatus.ERROR;\n error: IResponseError;\n}\n\nexport interface ITaskResultAborted {\n status: TaskResultStatus.ABORTED;\n}\n\nexport type ITaskResult<I = ITaskInput, O extends ITaskOutput = ITaskOutput> =\n | ITaskResultDone<O>\n | ITaskResultContinue<I>\n | ITaskResultError\n | ITaskResultAborted;\n\nexport type ISelfCleanupEvent = \"onSuccess\" | \"onError\" | \"onAbort\";\n\nexport type ISelfCleanup = \"always\" | \"never\" | ISelfCleanupEvent | ISelfCleanupEvent[];\n\nexport type ITaskLifecycleHook<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> = {\n task: ITask<I, O>;\n};\n\n/**\n * Core TaskDefinition - minimal interface\n */\nexport interface ITaskDefinition<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> {\n id: string;\n title: string;\n description?: string;\n maxIterations?: number;\n databaseLogs?: boolean;\n isPrivate?: boolean;\n selfCleanup?: ISelfCleanup;\n\n /**\n * Core run method - receives ONLY input params\n * All runtime dependencies (logging, state management, etc.) come from TaskController\n */\n run(params: ITaskRunParams<I, O>): Promise<ITaskResult<I, O>>;\n\n /**\n * Optional lifecycle hooks - receive task data, no context.\n */\n onBeforeTrigger?(params: ITaskBeforeTriggerParams<I>): Promise<void>;\n onDone?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onError?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onAbort?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onMaxIterations?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n /**\n * Create a validation schema for the task input.\n * This will be used to validate the input before the task is triggered.\n */\n createInputValidation?(\n params: ITaskCreateInputValidationParams\n ): GenericRecord<keyof I, zod.Schema> | zod.Schema;\n}\n\nexport interface ITaskCreateInputValidationParams {\n validator: typeof zod;\n}\n\n/** Define a long-running background task with lifecycle hooks. */\nexport const TaskDefinition = createAbstraction<ITaskDefinition>(\"TaskDefinition\");\n\n/**\n * IRunnableTaskDefinition represents a TaskDefinition after decoration/processing.\n * All optional runtime properties are guaranteed to have values (with defaults applied).\n * Used internally by the task runner to ensure consistent behavior.\n */\nexport interface IRunnableTaskDefinition<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> extends ITaskDefinition<I, O> {\n // Override optional properties to be required with guaranteed values\n isPrivate: boolean;\n databaseLogs: boolean;\n maxIterations: number;\n}\n\nexport namespace TaskDefinition {\n export type Interface<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskDefinition<I, O>;\n\n export type TaskInput = ITaskInput;\n\n export type TaskOutput = ITaskOutput;\n\n export type Runnable<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = IRunnableTaskDefinition<I, O>;\n\n export type RunParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskRunParams<I, O>;\n\n export type Result<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskResult<I, O>;\n\n export type Task<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITask<I, O>;\n\n export type ResultDone<O extends ITaskOutput = ITaskOutput> = ITaskResultDone<O>;\n export type ResultContinue<I = ITaskInput> = ITaskResultContinue<I>;\n export type ResultError = ITaskResultError;\n export type ResultAborted = ITaskResultAborted;\n export type CreateInputValidationParams = ITaskCreateInputValidationParams;\n export type TaskCreateData<I = ITaskInput> = ITaskCreateData<I>;\n export type BeforeTriggerParams<I = ITaskInput> = ITaskBeforeTriggerParams<I>;\n export type LifecycleHookParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskLifecycleHook<I, O>;\n\n export type SelfCleanupEvent = ISelfCleanupEvent;\n export type SelfCleanup = ISelfCleanup;\n}\n"],"names":["TaskResultStatus","TaskDefinition","createAbstraction"],"mappings":";AAoDO,IAAKA,gCAAgBA,WAAAA,GAAAA,SAAhBA,gBAAgB;;;;;WAAhBA;;AA2FL,MAAMC,iBAAiBC,kBAAmC"}
|
|
1
|
+
{"version":3,"file":"features/task/TaskDefinition/abstractions.js","sources":["../../../../src/features/task/TaskDefinition/abstractions.ts"],"sourcesContent":["import zod from \"zod\";\nimport type { Constructor } from \"@webiny/di\";\nimport { createAbstraction } from \"@webiny/feature/api\";\nimport type { GenericRecord } from \"@webiny/api/types\";\nimport type { ITask } from \"~/features/task/TaskService/index.js\";\nimport { TaskController } from \"~/features/task/TaskController/index.js\";\n\nexport type ITaskInput = GenericRecord;\n\nexport interface IResponseError {\n message: string;\n code?: string | null;\n data?: GenericRecord | null;\n stack?: string;\n}\n\nexport interface ITaskOutput {\n error?: IResponseError;\n [key: string]: any;\n}\n\n/**\n * The task's own definition, minus its behaviour.\n *\n * Handed to `run()` and to every lifecycle hook so a decorator can tell which task it is wrapping\n * and act on the definition's own fields. A decorator is registered against the abstraction, so it\n * wraps every task; without this it has nothing to branch on but a hardcoded list of ids, which\n * means editing the decorator every time a task is added.\n *\n * This is {@link ITaskMetadata}: identity and policy, no behaviour. The object passed at runtime is\n * the resolved task, so `run` is physically present; naming the metadata type here stops the obvious\n * mistake of a handler calling `params.definition.run(...)` and recursing forever.\n *\n * Only the fields declared here arrive. A field a project adds to its own definition class is\n * currently dropped, because `RunnableTaskDecorator` and `SelfCleaningTaskDecorator` are fixed\n * pass-throughs that expose a known set of getters and nothing else. Making them forward unknown\n * properties would turn a definition into a place to declare policy (a rate limit, a set of tags)\n * that a decorator acts on; `taskDefinitionInParams.test.ts` pins the current behaviour so that\n * change announces itself.\n */\nexport type ITaskDefinitionInfo = ITaskMetadata;\n\n/**\n * Task run params - the input data, plus the definition being run\n * All runtime dependencies come from TaskController (injected separately)\n */\nexport interface ITaskRunParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> {\n input: I;\n controller: TaskController.Interface<I, O>;\n definition: ITaskDefinitionInfo;\n}\n\n/**\n * Data for creating a new task\n */\nexport interface ITaskCreateData<I = ITaskInput> {\n definitionId: string;\n name: string;\n input: I;\n parentId?: string;\n}\n\n/**\n * Parameters for onBeforeTrigger lifecycle hook\n */\nexport interface ITaskBeforeTriggerParams<I = ITaskInput> {\n data: ITaskCreateData<I>;\n definition: ITaskDefinitionInfo;\n}\n\n/**\n * Task result status enum\n */\nexport enum TaskResultStatus {\n DONE = \"done\",\n CONTINUE = \"continue\",\n ERROR = \"error\",\n ABORTED = \"aborted\"\n}\n\n/**\n * Specific result types\n */\nexport interface ITaskResultDone<O extends ITaskOutput = ITaskOutput> {\n status: TaskResultStatus.DONE;\n message?: string;\n output?: O;\n}\n\nexport interface ITaskResultContinue<I = ITaskInput> {\n status: TaskResultStatus.CONTINUE;\n input: I;\n wait?: number; // seconds to wait before next iteration\n}\n\nexport interface ITaskResultError {\n status: TaskResultStatus.ERROR;\n error: IResponseError;\n}\n\nexport interface ITaskResultAborted {\n status: TaskResultStatus.ABORTED;\n}\n\nexport type ITaskResult<I = ITaskInput, O extends ITaskOutput = ITaskOutput> =\n | ITaskResultDone<O>\n | ITaskResultContinue<I>\n | ITaskResultError\n | ITaskResultAborted;\n\nexport type ISelfCleanupEvent = \"onSuccess\" | \"onError\" | \"onAbort\";\n\nexport type ISelfCleanup = \"always\" | \"never\" | ISelfCleanupEvent | ISelfCleanupEvent[];\n\nexport type ITaskLifecycleHook<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> = {\n task: ITask<I, O>;\n definition: ITaskDefinitionInfo;\n};\n\n/**\n * What a task IS: identity and runtime policy, with no behaviour and no dependencies.\n *\n * Listing tasks, resolving one by id, and applying defaults all need only this. Keeping it free of\n * dependencies is the whole point — `GetTaskDefinitionUseCase` builds every registered definition\n * to find one by id, so anything expensive here is paid 24 times per lookup.\n */\nexport interface ITaskMetadata {\n id: string;\n title: string;\n description?: string;\n maxIterations?: number;\n databaseLogs?: boolean;\n isPrivate?: boolean;\n selfCleanup?: ISelfCleanup;\n}\n\n/**\n * What a task DOES. This is the half that carries dependencies (a CMS context, an OpenSearch\n * client), so it is built only for the task actually being run.\n *\n * The lifecycle hooks live here rather than on {@link ITaskMetadata} because they need the same\n * dependencies `run()` does — see `MockDataManagerTask`, whose `onError` and `onAbort` both use the\n * OpenSearch client injected for `run()`.\n */\nexport interface ITaskHandler<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n> {\n /**\n * Core run method - receives ONLY input params\n * All runtime dependencies (logging, state management, etc.) come from TaskController\n */\n run(params: ITaskRunParams<I, O>): Promise<ITaskResult<I, O>>;\n\n /**\n * Optional lifecycle hooks - receive task data, no context.\n */\n onBeforeTrigger?(params: ITaskBeforeTriggerParams<I>): Promise<void>;\n onDone?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onError?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onAbort?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n onMaxIterations?(params: ITaskLifecycleHook<I, O>): Promise<void>;\n /**\n * Create a validation schema for the task input.\n * This will be used to validate the input before the task is triggered.\n */\n createInputValidation?(\n params: ITaskCreateInputValidationParams\n ): GenericRecord<keyof I, zod.Schema> | zod.Schema;\n}\n\n/**\n * Core TaskDefinition - minimal interface\n *\n * TRANSITIONAL SHAPE. A definition supplies its behaviour in one of two ways:\n *\n * - the new way: `handler` names a {@link ITaskHandler} class, which the runner builds only for the\n * task it is about to run;\n * - the old way: the definition implements `run()` and the hooks itself, which forces every\n * definition (and every dependency it injects) to be built just to look one up by id.\n *\n * `run` is optional ONLY to let both shapes coexist while packages migrate. Once every definition\n * carries a `handler`, this interface becomes `ITaskMetadata & { handler }` and the optionality\n * goes away. Exactly one of `run` or `handler` must be present; `GetTaskDefinitionUseCase` fails\n * with {@link TaskDefinitionNotRunnableError} if neither is.\n */\nexport interface ITaskDefinition<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n>\n extends ITaskMetadata, Partial<ITaskHandler<I, O>> {\n handler?: Constructor<ITaskHandler<I, O>>;\n}\n\nexport interface ITaskCreateInputValidationParams {\n validator: typeof zod;\n}\n\n/** Define a long-running background task with lifecycle hooks. */\nexport const TaskDefinition = createAbstraction<ITaskDefinition>(\"TaskDefinition\");\n\n/**\n * The behaviour half of a task, resolved on demand by the runner via\n * `container.resolveImplementation(definition.handler)`. Registered implementations are NOT\n * registered against this abstraction — the definition points at the class directly, exactly as\n * `HttpRouteDefinition` points at its `HttpRouteHandler`.\n */\nexport const TaskHandler = createAbstraction<ITaskHandler>(\"TaskHandler\");\n\n/**\n * IRunnableTaskDefinition represents a TaskDefinition after decoration/processing.\n * All optional runtime properties are guaranteed to have values (with defaults applied).\n * Used internally by the task runner to ensure consistent behavior.\n */\nexport interface IRunnableTaskDefinition<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n>\n extends ITaskMetadata, ITaskHandler<I, O> {\n // Override optional properties to be required with guaranteed values\n isPrivate: boolean;\n databaseLogs: boolean;\n maxIterations: number;\n}\n\nexport namespace TaskHandler {\n export type Interface<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskHandler<I, O>;\n\n export type RunParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskRunParams<I, O>;\n\n export type Result<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskResult<I, O>;\n\n export type LifecycleHookParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskLifecycleHook<I, O>;\n}\n\nexport namespace TaskDefinition {\n export type Interface<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskDefinition<I, O>;\n\n export type Metadata = ITaskMetadata;\n\n export type Handler<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskHandler<I, O>;\n\n export type TaskInput = ITaskInput;\n\n export type TaskOutput = ITaskOutput;\n\n export type Runnable<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = IRunnableTaskDefinition<I, O>;\n\n export type RunParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskRunParams<I, O>;\n\n export type Result<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskResult<I, O>;\n\n export type Task<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITask<I, O>;\n\n export type ResultDone<O extends ITaskOutput = ITaskOutput> = ITaskResultDone<O>;\n export type ResultContinue<I = ITaskInput> = ITaskResultContinue<I>;\n export type ResultError = ITaskResultError;\n export type ResultAborted = ITaskResultAborted;\n export type CreateInputValidationParams = ITaskCreateInputValidationParams;\n export type TaskCreateData<I = ITaskInput> = ITaskCreateData<I>;\n export type BeforeTriggerParams<I = ITaskInput> = ITaskBeforeTriggerParams<I>;\n export type LifecycleHookParams<\n I extends ITaskInput = ITaskInput,\n O extends ITaskOutput = ITaskOutput\n > = ITaskLifecycleHook<I, O>;\n\n export type Info = ITaskDefinitionInfo;\n\n export type SelfCleanupEvent = ISelfCleanupEvent;\n export type SelfCleanup = ISelfCleanup;\n}\n"],"names":["TaskResultStatus","TaskDefinition","createAbstraction","TaskHandler"],"mappings":";AA4EO,IAAKA,gCAAgBA,WAAAA,GAAAA,SAAhBA,gBAAgB;;;;;WAAhBA;;AAiIL,MAAMC,iBAAiBC,kBAAmC;AAQ1D,MAAMC,cAAcD,kBAAgC"}
|
|
@@ -26,7 +26,13 @@ export declare class WcpContextImpl implements WcpContext.Interface {
|
|
|
26
26
|
canUseHcmsFieldPermissions(): boolean;
|
|
27
27
|
canUseAiImageEnrichment(): boolean;
|
|
28
28
|
canUseAiPageGeneration(): boolean;
|
|
29
|
+
canUseAiPageTranslation(): boolean;
|
|
29
30
|
canUseAiLexicalGeneration(): boolean;
|
|
31
|
+
canUseAiEntryGeneration(): boolean;
|
|
32
|
+
canUseAiEntryComparison(): boolean;
|
|
33
|
+
canUseAiEntryTranslation(): boolean;
|
|
34
|
+
canUseAbTesting(): boolean;
|
|
35
|
+
canUseRemoteComponents(): boolean;
|
|
30
36
|
ensureCanUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): void;
|
|
31
37
|
incrementSeats(): Promise<void>;
|
|
32
38
|
decrementSeats(): Promise<void>;
|
|
@@ -111,9 +111,27 @@ class WcpContextImpl {
|
|
|
111
111
|
canUseAiPageGeneration() {
|
|
112
112
|
return this.license.canUseAiPageGeneration();
|
|
113
113
|
}
|
|
114
|
+
canUseAiPageTranslation() {
|
|
115
|
+
return this.license.canUseAiPageTranslation();
|
|
116
|
+
}
|
|
114
117
|
canUseAiLexicalGeneration() {
|
|
115
118
|
return this.license.canUseAiLexicalGeneration();
|
|
116
119
|
}
|
|
120
|
+
canUseAiEntryGeneration() {
|
|
121
|
+
return this.license.canUseAiEntryGeneration();
|
|
122
|
+
}
|
|
123
|
+
canUseAiEntryComparison() {
|
|
124
|
+
return this.license.canUseAiEntryComparison();
|
|
125
|
+
}
|
|
126
|
+
canUseAiEntryTranslation() {
|
|
127
|
+
return this.license.canUseAiEntryTranslation();
|
|
128
|
+
}
|
|
129
|
+
canUseAbTesting() {
|
|
130
|
+
return this.license.canUseAbTesting();
|
|
131
|
+
}
|
|
132
|
+
canUseRemoteComponents() {
|
|
133
|
+
return this.license.canUseRemoteComponents();
|
|
134
|
+
}
|
|
117
135
|
ensureCanUseFeature(wcpFeatureId) {
|
|
118
136
|
if (this.license.canUseFeature(wcpFeatureId)) return;
|
|
119
137
|
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\";\nimport type { WcpLicenseProvider } from \"../WcpLicenseProvider.js\";\n\nconst wcpProjectEnvironment = getWcpProjectEnvironment();\n\nexport class WcpContextImpl implements WcpContext.Interface {\n constructor(private licenseProvider: WcpLicenseProvider.Interface) {}\n\n private get license(): ILicense {\n return this.licenseProvider.get();\n }\n\n private getWcpProjectUrl(path = \"\"): string | null {\n if (!wcpProjectEnvironment) {\n return null;\n }\n\n const orgId = wcpProjectEnvironment.org.id;\n const projectId = wcpProjectEnvironment.project.id;\n const url = [\"/orgs\", orgId, \"projects\", projectId, path].filter(Boolean).join(\"/\");\n return getWcpApiUrl(url);\n }\n\n private async updateSeats(operation: \"increment\" | \"decrement\"): Promise<void> {\n if (!wcpProjectEnvironment) {\n return;\n }\n\n const updateSeatsUrl = this.getWcpProjectUrl(\"package/seats\");\n\n const response = await wcpFetch({\n url: updateSeatsUrl!,\n authorization: wcpProjectEnvironment.apiKey,\n body: { operation },\n meta: {\n action: operation + \"Seats\"\n }\n });\n\n if (response.error) {\n const message = response.message || `Failed to ${operation} user seats.`;\n console.error(message, response.status, response.statusText);\n throw new WError(message, \"WCP_CANNOT_UPDATE_USER_TENANTS\");\n }\n }\n\n private async updateTenants(operation: \"increment\" | \"decrement\"): Promise<void> {\n if (!wcpProjectEnvironment) {\n return;\n }\n\n const updateTenantsUrl = this.getWcpProjectUrl(\"package/tenants\");\n\n const response = await wcpFetch({\n url: updateTenantsUrl!,\n authorization: wcpProjectEnvironment.apiKey,\n body: { operation },\n meta: {\n action: operation + \"Tenants\"\n }\n });\n\n if (response.error) {\n const message = response.message || `Failed to ${operation} tenants.`;\n console.error(message, response.status, response.statusText);\n throw new WError(message, \"WCP_CANNOT_UPDATE_USER_TENANTS\");\n }\n }\n\n getRawLicense(): DecryptedWcpProjectLicense | null {\n return this.license.getRawLicense();\n }\n\n getProject(): WcpProject | null {\n return this.license.getProject();\n }\n\n getProjectWithFeatureFlags(): WcpProject | null {\n return this.getProject();\n }\n\n getProjectEnvironment(): WcpProjectEnvironment | null {\n return wcpProjectEnvironment;\n }\n\n getProjectLicense(): ILicense {\n return this.license;\n }\n\n canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): boolean {\n return this.license.canUseFeature(wcpFeatureId);\n }\n\n canUseAacl(): boolean {\n return this.license.canUseAacl();\n }\n\n canUseTeams(): boolean {\n return this.license.canUseTeams();\n }\n\n canUseFolderLevelPermissions(): boolean {\n return this.license.canUseFolderLevelPermissions();\n }\n\n canUsePrivateFiles(): boolean {\n return this.license.canUsePrivateFiles();\n }\n\n canUseAuditLogs(): boolean {\n return this.license.canUseAuditLogs();\n }\n\n canUseRecordLocking(): boolean {\n return this.license.canUseRecordLocking();\n }\n\n canUseFileManagerThreatDetection(): boolean {\n return this.license.canUseFileManagerThreatDetection();\n }\n\n canUseWorkflows(): boolean {\n return this.license.canUseWorkflows();\n }\n\n canUseHcmsFieldPermissions(): boolean {\n return this.license.canUseHcmsFieldPermissions();\n }\n\n canUseAiImageEnrichment(): boolean {\n return this.license.canUseAiImageEnrichment();\n }\n\n canUseAiPageGeneration(): boolean {\n return this.license.canUseAiPageGeneration();\n }\n\n canUseAiLexicalGeneration(): boolean {\n return this.license.canUseAiLexicalGeneration();\n }\n\n ensureCanUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): void {\n if (this.license.canUseFeature(wcpFeatureId)) {\n return;\n }\n\n let message = `The ${wcpFeatureId} Webiny Control Panel feature cannot be used because your project license does not permit it.`;\n if (wcpProjectEnvironment) {\n const { org, project } = wcpProjectEnvironment;\n const upgradeProjectLicenseLink = getWcpAppUrl(`/${org.id}/${project.id}/settings`);\n message += ` To upgrade your project license, please use the following link: ${upgradeProjectLicenseLink}.`;\n }\n\n throw new WError(message, \"WCP_CANNOT_USE_FEATURE\", { wcpFeatureId });\n }\n\n async incrementSeats(): Promise<void> {\n await this.updateSeats(\"increment\");\n }\n\n async decrementSeats(): Promise<void> {\n await this.updateSeats(\"decrement\");\n }\n\n async incrementTenants(): Promise<void> {\n await this.updateTenants(\"increment\");\n }\n\n async decrementTenants(): Promise<void> {\n await this.updateTenants(\"decrement\");\n }\n\n toDto() {\n return this.getRawLicense();\n }\n}\n"],"names":["wcpProjectEnvironment","getWcpProjectEnvironment","WcpContextImpl","licenseProvider","path","orgId","projectId","url","Boolean","getWcpApiUrl","operation","updateSeatsUrl","response","wcpFetch","message","console","WError","updateTenantsUrl","wcpFeatureId","org","project","upgradeProjectLicenseLink","getWcpAppUrl"],"mappings":";;;AAaA,MAAMA,wBAAwBC;AAEvB,MAAMC;IACT,YAAoBC,eAA6C,CAAE;aAA/CA,eAAe,GAAfA;IAAgD;IAEpE,IAAY,UAAoB;QAC5B,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG;IACnC;IAEQ,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;QAG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AAM,iBAAgC;QAClC,MAAM,IAAI,CAAC,WAAW,CAAC;IAC3B;IAEA,MAAM,iBAAgC;QAClC,MAAM,IAAI,CAAC,WAAW,CAAC;IAC3B;IAEA,MAAM,mBAAkC;QACpC,MAAM,IAAI,CAAC,aAAa,CAAC;IAC7B;IAEA,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\";\nimport type { WcpLicenseProvider } from \"../WcpLicenseProvider.js\";\n\nconst wcpProjectEnvironment = getWcpProjectEnvironment();\n\nexport class WcpContextImpl implements WcpContext.Interface {\n constructor(private licenseProvider: WcpLicenseProvider.Interface) {}\n\n private get license(): ILicense {\n return this.licenseProvider.get();\n }\n\n private getWcpProjectUrl(path = \"\"): string | null {\n if (!wcpProjectEnvironment) {\n return null;\n }\n\n const orgId = wcpProjectEnvironment.org.id;\n const projectId = wcpProjectEnvironment.project.id;\n const url = [\"/orgs\", orgId, \"projects\", projectId, path].filter(Boolean).join(\"/\");\n return getWcpApiUrl(url);\n }\n\n private async updateSeats(operation: \"increment\" | \"decrement\"): Promise<void> {\n if (!wcpProjectEnvironment) {\n return;\n }\n\n const updateSeatsUrl = this.getWcpProjectUrl(\"package/seats\");\n\n const response = await wcpFetch({\n url: updateSeatsUrl!,\n authorization: wcpProjectEnvironment.apiKey,\n body: { operation },\n meta: {\n action: operation + \"Seats\"\n }\n });\n\n if (response.error) {\n const message = response.message || `Failed to ${operation} user seats.`;\n console.error(message, response.status, response.statusText);\n throw new WError(message, \"WCP_CANNOT_UPDATE_USER_TENANTS\");\n }\n }\n\n private async updateTenants(operation: \"increment\" | \"decrement\"): Promise<void> {\n if (!wcpProjectEnvironment) {\n return;\n }\n\n const updateTenantsUrl = this.getWcpProjectUrl(\"package/tenants\");\n\n const response = await wcpFetch({\n url: updateTenantsUrl!,\n authorization: wcpProjectEnvironment.apiKey,\n body: { operation },\n meta: {\n action: operation + \"Tenants\"\n }\n });\n\n if (response.error) {\n const message = response.message || `Failed to ${operation} tenants.`;\n console.error(message, response.status, response.statusText);\n throw new WError(message, \"WCP_CANNOT_UPDATE_USER_TENANTS\");\n }\n }\n\n getRawLicense(): DecryptedWcpProjectLicense | null {\n return this.license.getRawLicense();\n }\n\n getProject(): WcpProject | null {\n return this.license.getProject();\n }\n\n getProjectWithFeatureFlags(): WcpProject | null {\n return this.getProject();\n }\n\n getProjectEnvironment(): WcpProjectEnvironment | null {\n return wcpProjectEnvironment;\n }\n\n getProjectLicense(): ILicense {\n return this.license;\n }\n\n canUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): boolean {\n return this.license.canUseFeature(wcpFeatureId);\n }\n\n canUseAacl(): boolean {\n return this.license.canUseAacl();\n }\n\n canUseTeams(): boolean {\n return this.license.canUseTeams();\n }\n\n canUseFolderLevelPermissions(): boolean {\n return this.license.canUseFolderLevelPermissions();\n }\n\n canUsePrivateFiles(): boolean {\n return this.license.canUsePrivateFiles();\n }\n\n canUseAuditLogs(): boolean {\n return this.license.canUseAuditLogs();\n }\n\n canUseRecordLocking(): boolean {\n return this.license.canUseRecordLocking();\n }\n\n canUseFileManagerThreatDetection(): boolean {\n return this.license.canUseFileManagerThreatDetection();\n }\n\n canUseWorkflows(): boolean {\n return this.license.canUseWorkflows();\n }\n\n canUseHcmsFieldPermissions(): boolean {\n return this.license.canUseHcmsFieldPermissions();\n }\n\n canUseAiImageEnrichment(): boolean {\n return this.license.canUseAiImageEnrichment();\n }\n\n canUseAiPageGeneration(): boolean {\n return this.license.canUseAiPageGeneration();\n }\n\n 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 canUseAbTesting(): boolean {\n return this.license.canUseAbTesting();\n }\n\n canUseRemoteComponents(): boolean {\n return this.license.canUseRemoteComponents();\n }\n\n ensureCanUseFeature(wcpFeatureId: keyof typeof WCP_FEATURE_LABEL): void {\n if (this.license.canUseFeature(wcpFeatureId)) {\n return;\n }\n\n let message = `The ${wcpFeatureId} Webiny Control Panel feature cannot be used because your project license does not permit it.`;\n if (wcpProjectEnvironment) {\n const { org, project } = wcpProjectEnvironment;\n const upgradeProjectLicenseLink = getWcpAppUrl(`/${org.id}/${project.id}/settings`);\n message += ` To upgrade your project license, please use the following link: ${upgradeProjectLicenseLink}.`;\n }\n\n throw new WError(message, \"WCP_CANNOT_USE_FEATURE\", { wcpFeatureId });\n }\n\n async incrementSeats(): Promise<void> {\n await this.updateSeats(\"increment\");\n }\n\n async decrementSeats(): Promise<void> {\n await this.updateSeats(\"decrement\");\n }\n\n async incrementTenants(): Promise<void> {\n await this.updateTenants(\"increment\");\n }\n\n async decrementTenants(): Promise<void> {\n await this.updateTenants(\"decrement\");\n }\n\n toDto() {\n return this.getRawLicense();\n }\n}\n"],"names":["wcpProjectEnvironment","getWcpProjectEnvironment","WcpContextImpl","licenseProvider","path","orgId","projectId","url","Boolean","getWcpApiUrl","operation","updateSeatsUrl","response","wcpFetch","message","console","WError","updateTenantsUrl","wcpFeatureId","org","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C,aAAa;IAC7B;AACJ"}
|
|
@@ -56,13 +56,25 @@ declare class WcpContextWithFeatureFlagsDecoratorImpl implements WcpContext.Inte
|
|
|
56
56
|
options: {
|
|
57
57
|
websiteBuilder: {
|
|
58
58
|
pageGeneration: boolean | undefined;
|
|
59
|
+
pageTranslation: boolean | undefined;
|
|
59
60
|
};
|
|
60
61
|
fileManager: {
|
|
61
62
|
imageEnrichment: boolean | undefined;
|
|
62
63
|
};
|
|
63
64
|
lexicalGeneration: boolean | undefined;
|
|
65
|
+
cms: {
|
|
66
|
+
entryGeneration: boolean | undefined;
|
|
67
|
+
entryComparison: boolean | undefined;
|
|
68
|
+
entryTranslation: boolean | undefined;
|
|
69
|
+
};
|
|
64
70
|
};
|
|
65
71
|
};
|
|
72
|
+
abTesting: {
|
|
73
|
+
enabled: boolean;
|
|
74
|
+
};
|
|
75
|
+
remoteComponents: {
|
|
76
|
+
enabled: boolean;
|
|
77
|
+
};
|
|
66
78
|
};
|
|
67
79
|
};
|
|
68
80
|
} | null;
|
|
@@ -80,7 +92,13 @@ declare class WcpContextWithFeatureFlagsDecoratorImpl implements WcpContext.Inte
|
|
|
80
92
|
canUseHcmsFieldPermissions(): boolean;
|
|
81
93
|
canUseAiImageEnrichment(): boolean;
|
|
82
94
|
canUseAiPageGeneration(): boolean;
|
|
95
|
+
canUseAiPageTranslation(): boolean;
|
|
83
96
|
canUseAiLexicalGeneration(): boolean;
|
|
97
|
+
canUseAiEntryGeneration(): boolean;
|
|
98
|
+
canUseAiEntryComparison(): boolean;
|
|
99
|
+
canUseAiEntryTranslation(): boolean;
|
|
100
|
+
canUseAbTesting(): boolean;
|
|
101
|
+
canUseRemoteComponents(): boolean;
|
|
84
102
|
ensureCanUseFeature(featureId: keyof typeof WCP_FEATURE_LABEL): void;
|
|
85
103
|
incrementSeats(): Promise<void>;
|
|
86
104
|
decrementSeats(): Promise<void>;
|
|
@@ -24,45 +24,59 @@ class WcpContextWithFeatureFlagsDecoratorImpl {
|
|
|
24
24
|
multiTenancy: project.package.features.multiTenancy,
|
|
25
25
|
advancedPublishingWorkflow: {
|
|
26
26
|
...project.package.features.advancedPublishingWorkflow,
|
|
27
|
-
enabled: flags.
|
|
27
|
+
enabled: flags.isEnabled("advancedPublishingWorkflow") ? project.package.features.advancedPublishingWorkflow.enabled : false
|
|
28
28
|
},
|
|
29
29
|
advancedAccessControlLayer: {
|
|
30
30
|
...project.package.features.advancedAccessControlLayer,
|
|
31
|
-
enabled: flags.
|
|
31
|
+
enabled: flags.isEnabled("advancedAccessControlLayer") ? project.package.features.advancedAccessControlLayer.enabled : false,
|
|
32
32
|
options: {
|
|
33
|
-
teams: flags.
|
|
34
|
-
privateFiles: flags.
|
|
35
|
-
folderLevelPermissions: flags.
|
|
36
|
-
hcmsFieldPermissions: flags.
|
|
33
|
+
teams: flags.isEnabled("advancedAccessControlLayer.teams") ? project.package.features.advancedAccessControlLayer.options.teams : false,
|
|
34
|
+
privateFiles: flags.isEnabled("advancedAccessControlLayer.privateFiles") ? project.package.features.advancedAccessControlLayer.options.privateFiles : false,
|
|
35
|
+
folderLevelPermissions: flags.isEnabled("advancedAccessControlLayer.folderLevelPermissions") ? project.package.features.advancedAccessControlLayer.options.folderLevelPermissions : false,
|
|
36
|
+
hcmsFieldPermissions: flags.isEnabled("advancedAccessControlLayer.hcmsFieldPermissions") ? project.package.features.advancedAccessControlLayer.options.hcmsFieldPermissions : false
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
auditLogs: {
|
|
40
40
|
...project.package.features.auditLogs,
|
|
41
|
-
enabled: flags.
|
|
41
|
+
enabled: flags.isEnabled("auditLogs") ? project.package.features.auditLogs.enabled : false
|
|
42
42
|
},
|
|
43
43
|
recordLocking: {
|
|
44
44
|
...project.package.features.recordLocking,
|
|
45
|
-
enabled: flags.
|
|
45
|
+
enabled: flags.isEnabled("recordLocking") ? project.package.features.recordLocking.enabled : false
|
|
46
46
|
},
|
|
47
47
|
fileManager: {
|
|
48
48
|
...project.package.features.fileManager,
|
|
49
49
|
enabled: project.package.features.fileManager.enabled,
|
|
50
50
|
options: {
|
|
51
|
-
threatDetection: flags.
|
|
51
|
+
threatDetection: flags.isEnabled("fileManager.threatDetection") ? project.package.features.fileManager.options.threatDetection : false
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
aiPowerups: {
|
|
55
55
|
...project.package.features.aiPowerups,
|
|
56
|
-
enabled: flags.
|
|
56
|
+
enabled: flags.isEnabled("aiPowerups") ? project.package.features.aiPowerups?.enabled : false,
|
|
57
57
|
options: {
|
|
58
58
|
websiteBuilder: {
|
|
59
|
-
pageGeneration: flags.
|
|
59
|
+
pageGeneration: flags.isEnabled("aiPowerups.websiteBuilder.pageGeneration") ? project.package.features.aiPowerups?.options?.websiteBuilder?.pageGeneration : false,
|
|
60
|
+
pageTranslation: flags.isEnabled("aiPowerups.websiteBuilder.pageTranslation") ? project.package.features.aiPowerups?.options?.websiteBuilder?.pageTranslation : false
|
|
60
61
|
},
|
|
61
62
|
fileManager: {
|
|
62
|
-
imageEnrichment: flags.
|
|
63
|
+
imageEnrichment: flags.isEnabled("aiPowerups.fileManager.imageEnrichment") ? project.package.features.aiPowerups?.options?.fileManager?.imageEnrichment : false
|
|
63
64
|
},
|
|
64
|
-
lexicalGeneration: flags.
|
|
65
|
+
lexicalGeneration: flags.isEnabled("aiPowerups.lexicalGeneration") ? project.package.features.aiPowerups?.options?.lexicalGeneration : false,
|
|
66
|
+
cms: {
|
|
67
|
+
entryGeneration: flags.isEnabled("aiPowerups.cms.entryGeneration") ? project.package.features.aiPowerups?.options?.cms?.entryGeneration : false,
|
|
68
|
+
entryComparison: flags.isEnabled("aiPowerups.cms.entryComparison") ? project.package.features.aiPowerups?.options?.cms?.entryComparison : false,
|
|
69
|
+
entryTranslation: flags.isEnabled("aiPowerups.cms.entryTranslation") ? project.package.features.aiPowerups?.options?.cms?.entryTranslation : false
|
|
70
|
+
}
|
|
65
71
|
}
|
|
72
|
+
},
|
|
73
|
+
abTesting: {
|
|
74
|
+
...project.package.features.abTesting,
|
|
75
|
+
enabled: flags.isEnabled("abTesting") ? project.package.features.abTesting?.enabled : false
|
|
76
|
+
},
|
|
77
|
+
remoteComponents: {
|
|
78
|
+
...project.package.features.remoteComponents,
|
|
79
|
+
enabled: flags.isEnabled("remoteComponents") ? project.package.features.remoteComponents?.enabled : false
|
|
66
80
|
}
|
|
67
81
|
}
|
|
68
82
|
}
|
|
@@ -78,40 +92,58 @@ class WcpContextWithFeatureFlagsDecoratorImpl {
|
|
|
78
92
|
return this.decoratee.canUseFeature(wcpFeatureId);
|
|
79
93
|
}
|
|
80
94
|
canUseAacl() {
|
|
81
|
-
return this.decoratee.canUseAacl() && this.featureFlags.get().
|
|
95
|
+
return this.decoratee.canUseAacl() && this.featureFlags.get().isEnabled("advancedAccessControlLayer");
|
|
82
96
|
}
|
|
83
97
|
canUseTeams() {
|
|
84
|
-
return this.decoratee.canUseTeams() && this.featureFlags.get().
|
|
98
|
+
return this.decoratee.canUseTeams() && this.featureFlags.get().isEnabled("advancedAccessControlLayer.teams");
|
|
85
99
|
}
|
|
86
100
|
canUseFolderLevelPermissions() {
|
|
87
|
-
return this.decoratee.canUseFolderLevelPermissions() && this.featureFlags.get().
|
|
101
|
+
return this.decoratee.canUseFolderLevelPermissions() && this.featureFlags.get().isEnabled("advancedAccessControlLayer.folderLevelPermissions");
|
|
88
102
|
}
|
|
89
103
|
canUsePrivateFiles() {
|
|
90
|
-
return this.decoratee.canUsePrivateFiles() && this.featureFlags.get().
|
|
104
|
+
return this.decoratee.canUsePrivateFiles() && this.featureFlags.get().isEnabled("advancedAccessControlLayer.privateFiles");
|
|
91
105
|
}
|
|
92
106
|
canUseAuditLogs() {
|
|
93
|
-
return this.decoratee.canUseAuditLogs() && this.featureFlags.get().
|
|
107
|
+
return this.decoratee.canUseAuditLogs() && this.featureFlags.get().isEnabled("auditLogs");
|
|
94
108
|
}
|
|
95
109
|
canUseRecordLocking() {
|
|
96
|
-
return this.decoratee.canUseRecordLocking() && this.featureFlags.get().
|
|
110
|
+
return this.decoratee.canUseRecordLocking() && this.featureFlags.get().isEnabled("recordLocking");
|
|
97
111
|
}
|
|
98
112
|
canUseFileManagerThreatDetection() {
|
|
99
|
-
return this.decoratee.canUseFileManagerThreatDetection() && this.featureFlags.get().
|
|
113
|
+
return this.decoratee.canUseFileManagerThreatDetection() && this.featureFlags.get().isEnabled("fileManager.threatDetection");
|
|
100
114
|
}
|
|
101
115
|
canUseWorkflows() {
|
|
102
|
-
return this.decoratee.canUseWorkflows() && this.featureFlags.get().
|
|
116
|
+
return this.decoratee.canUseWorkflows() && this.featureFlags.get().isEnabled("advancedPublishingWorkflow");
|
|
103
117
|
}
|
|
104
118
|
canUseHcmsFieldPermissions() {
|
|
105
|
-
return this.decoratee.canUseHcmsFieldPermissions() && this.featureFlags.get().
|
|
119
|
+
return this.decoratee.canUseHcmsFieldPermissions() && this.featureFlags.get().isEnabled("advancedAccessControlLayer.hcmsFieldPermissions");
|
|
106
120
|
}
|
|
107
121
|
canUseAiImageEnrichment() {
|
|
108
|
-
return this.decoratee.canUseAiImageEnrichment() && this.featureFlags.get().
|
|
122
|
+
return this.decoratee.canUseAiImageEnrichment() && this.featureFlags.get().isEnabled("aiPowerups.fileManager.imageEnrichment");
|
|
109
123
|
}
|
|
110
124
|
canUseAiPageGeneration() {
|
|
111
|
-
return this.decoratee.canUseAiPageGeneration() && this.featureFlags.get().
|
|
125
|
+
return this.decoratee.canUseAiPageGeneration() && this.featureFlags.get().isEnabled("aiPowerups.websiteBuilder.pageGeneration");
|
|
126
|
+
}
|
|
127
|
+
canUseAiPageTranslation() {
|
|
128
|
+
return this.decoratee.canUseAiPageTranslation() && this.featureFlags.get().isEnabled("aiPowerups.websiteBuilder.pageTranslation");
|
|
112
129
|
}
|
|
113
130
|
canUseAiLexicalGeneration() {
|
|
114
|
-
return this.decoratee.canUseAiLexicalGeneration() && this.featureFlags.get().
|
|
131
|
+
return this.decoratee.canUseAiLexicalGeneration() && this.featureFlags.get().isEnabled("aiPowerups.lexicalGeneration");
|
|
132
|
+
}
|
|
133
|
+
canUseAiEntryGeneration() {
|
|
134
|
+
return this.decoratee.canUseAiEntryGeneration() && this.featureFlags.get().isEnabled("aiPowerups.cms.entryGeneration");
|
|
135
|
+
}
|
|
136
|
+
canUseAiEntryComparison() {
|
|
137
|
+
return this.decoratee.canUseAiEntryComparison() && this.featureFlags.get().isEnabled("aiPowerups.cms.entryComparison");
|
|
138
|
+
}
|
|
139
|
+
canUseAiEntryTranslation() {
|
|
140
|
+
return this.decoratee.canUseAiEntryTranslation() && this.featureFlags.get().isEnabled("aiPowerups.cms.entryTranslation");
|
|
141
|
+
}
|
|
142
|
+
canUseAbTesting() {
|
|
143
|
+
return this.decoratee.canUseAbTesting() && this.featureFlags.get().isEnabled("abTesting");
|
|
144
|
+
}
|
|
145
|
+
canUseRemoteComponents() {
|
|
146
|
+
return this.decoratee.canUseRemoteComponents() && this.featureFlags.get().isEnabled("remoteComponents");
|
|
115
147
|
}
|
|
116
148
|
ensureCanUseFeature(featureId) {
|
|
117
149
|
return this.decoratee.ensureCanUseFeature(featureId);
|