unleash-server 4.2.2 → 4.2.3
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/dist/lib/addons/addon.d.ts +2 -1
- package/dist/lib/addons/addon.js.map +1 -1
- package/dist/lib/addons/datadog.d.ts +2 -1
- package/dist/lib/addons/datadog.js.map +1 -1
- package/dist/lib/addons/datadog.test.js +3 -0
- package/dist/lib/addons/datadog.test.js.map +1 -1
- package/dist/lib/addons/feature-event-formatter-md.d.ts +1 -1
- package/dist/lib/addons/feature-event-formatter-md.js +13 -14
- package/dist/lib/addons/feature-event-formatter-md.js.map +1 -1
- package/dist/lib/addons/slack.d.ts +2 -1
- package/dist/lib/addons/slack.js.map +1 -1
- package/dist/lib/addons/slack.test.js +6 -0
- package/dist/lib/addons/slack.test.js.map +1 -1
- package/dist/lib/addons/teams.d.ts +2 -1
- package/dist/lib/addons/teams.js.map +1 -1
- package/dist/lib/addons/teams.test.js +3 -0
- package/dist/lib/addons/teams.test.js.map +1 -1
- package/dist/lib/addons/webhook.d.ts +8 -2
- package/dist/lib/addons/webhook.js +0 -1
- package/dist/lib/addons/webhook.js.map +1 -1
- package/dist/lib/addons/webhook.test.js +2 -0
- package/dist/lib/addons/webhook.test.js.map +1 -1
- package/dist/lib/db/client-metrics-store-v2.js +5 -1
- package/dist/lib/db/client-metrics-store-v2.js.map +1 -1
- package/dist/lib/db/event-store.d.ts +10 -6
- package/dist/lib/db/event-store.js +21 -1
- package/dist/lib/db/event-store.js.map +1 -1
- package/dist/lib/metrics.js +17 -8
- package/dist/lib/metrics.js.map +1 -1
- package/dist/lib/metrics.test.js +1 -0
- package/dist/lib/metrics.test.js.map +1 -1
- package/dist/lib/routes/admin-api/event.d.ts +8 -4
- package/dist/lib/routes/admin-api/event.js +8 -10
- package/dist/lib/routes/admin-api/event.js.map +1 -1
- package/dist/lib/routes/admin-api/state.js +0 -1
- package/dist/lib/routes/admin-api/state.js.map +1 -1
- package/dist/lib/services/addon-service-test-simple-addon.d.ts +1 -1
- package/dist/lib/services/addon-service-test-simple-addon.js.map +1 -1
- package/dist/lib/services/client-metrics/index.d.ts +6 -5
- package/dist/lib/services/client-metrics/index.js +6 -3
- package/dist/lib/services/client-metrics/index.js.map +1 -1
- package/dist/lib/services/client-metrics/list.d.ts +19 -16
- package/dist/lib/services/client-metrics/list.js +6 -4
- package/dist/lib/services/client-metrics/list.js.map +1 -1
- package/dist/lib/services/client-metrics/list.test.js +9 -5
- package/dist/lib/services/client-metrics/list.test.js.map +1 -1
- package/dist/lib/services/client-metrics/ttl-list.d.ts +20 -14
- package/dist/lib/services/client-metrics/ttl-list.js +17 -12
- package/dist/lib/services/client-metrics/ttl-list.js.map +1 -1
- package/dist/lib/services/client-metrics/ttl-list.test.js +14 -10
- package/dist/lib/services/client-metrics/ttl-list.test.js.map +1 -1
- package/dist/lib/services/event-service.d.ts +1 -1
- package/dist/lib/services/event-service.js +1 -1
- package/dist/lib/services/event-service.js.map +1 -1
- package/dist/lib/services/feature-tag-service.js +7 -11
- package/dist/lib/services/feature-tag-service.js.map +1 -1
- package/dist/lib/services/feature-toggle-service.d.ts +15 -14
- package/dist/lib/services/feature-toggle-service.js +142 -135
- package/dist/lib/services/feature-toggle-service.js.map +1 -1
- package/dist/lib/services/project-health-service.d.ts +2 -2
- package/dist/lib/services/project-health-service.js.map +1 -1
- package/dist/lib/services/project-service.d.ts +2 -2
- package/dist/lib/services/project-service.js +5 -3
- package/dist/lib/services/project-service.js.map +1 -1
- package/dist/lib/services/user-service.d.ts +3 -2
- package/dist/lib/services/user-service.js +37 -21
- package/dist/lib/services/user-service.js.map +1 -1
- package/dist/lib/types/events.d.ts +165 -2
- package/dist/lib/types/events.js +124 -4
- package/dist/lib/types/events.js.map +1 -1
- package/dist/lib/types/model.d.ts +0 -12
- package/dist/lib/types/model.js.map +1 -1
- package/dist/lib/types/stores/event-store.d.ts +4 -3
- package/dist/migrations/20211105104316-add-feature-name-column-to-events.d.ts +2 -0
- package/dist/migrations/20211105104316-add-feature-name-column-to-events.js +16 -0
- package/dist/migrations/20211105104316-add-feature-name-column-to-events.js.map +1 -0
- package/dist/migrations/20211105105509-add-predata-column-to-events.d.ts +2 -0
- package/dist/migrations/20211105105509-add-predata-column-to-events.js +8 -0
- package/dist/migrations/20211105105509-add-predata-column-to-events.js.map +1 -0
- package/dist/test/e2e/api/admin/client-metrics.e2e.test.js +16 -12
- package/dist/test/e2e/api/admin/client-metrics.e2e.test.js.map +1 -1
- package/dist/test/e2e/api/admin/project/features.e2e.test.js +6 -8
- package/dist/test/e2e/api/admin/project/features.e2e.test.js.map +1 -1
- package/dist/test/e2e/api/admin/user-admin.e2e.test.js +2 -16
- package/dist/test/e2e/api/admin/user-admin.e2e.test.js.map +1 -1
- package/dist/test/e2e/services/feature-toggle-service-v2.e2e.test.js.map +1 -1
- package/dist/test/e2e/services/project-health-service.e2e.test.js.map +1 -1
- package/dist/test/e2e/services/project-service.e2e.test.js.map +1 -1
- package/dist/test/e2e/stores/event-store.e2e.test.js.map +1 -1
- package/dist/test/fixtures/fake-event-store.d.ts +2 -1
- package/dist/test/fixtures/fake-event-store.js +3 -0
- package/dist/test/fixtures/fake-event-store.js.map +1 -1
- package/docs/api/oas/openapi.yaml +35 -55
- package/package.json +9 -10
- package/dist/lib/event-differ.d.ts +0 -1
- package/dist/lib/event-differ.js +0 -117
- package/dist/lib/event-differ.js.map +0 -1
- package/dist/lib/event-differ.test.d.ts +0 -1
- package/dist/lib/event-differ.test.js +0 -142
- package/dist/lib/event-differ.test.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ttl-list.test.js","sourceRoot":"","sources":["../../../../src/lib/services/client-metrics/ttl-list.test.
|
|
1
|
+
{"version":3,"file":"ttl-list.test.js","sourceRoot":"","sources":["../../../../src/lib/services/client-metrics/ttl-list.test.ts"],"names":[],"mappings":";;;;;AAAA,uCAA2C;AAC3C,0DAAiC;AAEjC,IAAI,CAAC,oBAA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G,CAAC,CAAC;IAC9B,MAAM,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAE5C,IAAI,CAAC,OAAO,EAAE,CAAC;IACf,IAAI,CAAC,aAAa,EAAE,CAAC;AACzB,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,gEAAgE,EAAE,GAAG,EAAE;IACxE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAE7B,MAAM,IAAI,GAAG,IAAI,kBAAO,CAAgB;QACpC,QAAQ,EAAE,EAAE;QACZ,YAAY,EAAE,EAAE;QAChB,UAAU,EAAE,cAAc;KAC7B,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IACjC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IAElC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;IAEjC,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAC9C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAE5C,IAAI,CAAC,aAAa,EAAE,CAAC;AACzB,CAAC,CAAC,CAAC"}
|
|
@@ -9,7 +9,7 @@ class EventService {
|
|
|
9
9
|
return this.eventStore.getEvents();
|
|
10
10
|
}
|
|
11
11
|
async getEventsForToggle(name) {
|
|
12
|
-
return this.eventStore.
|
|
12
|
+
return this.eventStore.getEventsForFeature(name);
|
|
13
13
|
}
|
|
14
14
|
async getEventsForProject(project) {
|
|
15
15
|
return this.eventStore.getEventsFilterByProject(project);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-service.js","sourceRoot":"","sources":["../../../src/lib/services/event-service.ts"],"names":[],"mappings":";;AAMA,MAAqB,YAAY;IAK7B,YACI,EAAE,UAAU,EAAsC,EAClD,EAAE,SAAS,EAAqC;QAEhD,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,2BAA2B,CAAC,CAAC;QACrD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,IAAY;QACjC,OAAO,IAAI,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"event-service.js","sourceRoot":"","sources":["../../../src/lib/services/event-service.ts"],"names":[],"mappings":";;AAMA,MAAqB,YAAY;IAK7B,YACI,EAAE,UAAU,EAAsC,EAClD,EAAE,SAAS,EAAqC;QAEhD,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,2BAA2B,CAAC,CAAC;QACrD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,IAAY;QACjC,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,OAAe;QACrC,OAAO,IAAI,CAAC,UAAU,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;IAC7D,CAAC;CACJ;AAxBD,+BAwBC;AAED,MAAM,CAAC,OAAO,GAAG,YAAY,CAAC"}
|
|
@@ -17,6 +17,7 @@ class FeatureTagService {
|
|
|
17
17
|
async listTags(featureName) {
|
|
18
18
|
return this.featureTagStore.getAllTagsForFeature(featureName);
|
|
19
19
|
}
|
|
20
|
+
// TODO: add project Id
|
|
20
21
|
async addTag(featureName, tag, userName) {
|
|
21
22
|
await feature_schema_1.nameSchema.validateAsync({ name: featureName });
|
|
22
23
|
const validatedTag = await tag_schema_1.tagSchema.validateAsync(tag);
|
|
@@ -25,10 +26,8 @@ class FeatureTagService {
|
|
|
25
26
|
await this.eventStore.store({
|
|
26
27
|
type: events_1.FEATURE_TAGGED,
|
|
27
28
|
createdBy: userName,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
tag: validatedTag,
|
|
31
|
-
},
|
|
29
|
+
featureName,
|
|
30
|
+
data: validatedTag,
|
|
32
31
|
});
|
|
33
32
|
return validatedTag;
|
|
34
33
|
}
|
|
@@ -42,22 +41,19 @@ class FeatureTagService {
|
|
|
42
41
|
await this.eventStore.store({
|
|
43
42
|
type: events_1.TAG_CREATED,
|
|
44
43
|
createdBy: userName,
|
|
45
|
-
data:
|
|
46
|
-
tag,
|
|
47
|
-
},
|
|
44
|
+
data: tag,
|
|
48
45
|
});
|
|
49
46
|
}
|
|
50
47
|
}
|
|
51
48
|
}
|
|
49
|
+
// TODO: add project Id
|
|
52
50
|
async removeTag(featureName, tag, userName) {
|
|
53
51
|
await this.featureTagStore.untagFeature(featureName, tag);
|
|
54
52
|
await this.eventStore.store({
|
|
55
53
|
type: events_1.FEATURE_UNTAGGED,
|
|
56
54
|
createdBy: userName,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
tag,
|
|
60
|
-
},
|
|
55
|
+
featureName,
|
|
56
|
+
data: tag,
|
|
61
57
|
});
|
|
62
58
|
}
|
|
63
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-tag-service.js","sourceRoot":"","sources":["../../../src/lib/services/feature-tag-service.ts"],"names":[],"mappings":";;;;;AAAA,6EAAoD;AAEpD,6DAAsD;AACtD,4CAAgF;AAGhF,6CAAyC;AAMzC,MAAM,iBAAiB;IASnB,YACI,EACI,QAAQ,EACR,eAAe,EACf,UAAU,GACwD,EACtE,EAAE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AmB,EACnB,GAAS,EACT,QAAgB;QAEhB,MAAM,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;QAC1D,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;YACxB,IAAI,EAAE,yBAAgB;YACtB,SAAS,EAAE,QAAQ;YACnB,WAAW;YACX,IAAI,EAAE,GAAG;SACZ,CAAC,CAAC;IACP,CAAC;CACJ;AAED,kBAAe,iBAAiB,CAAC"}
|
|
@@ -10,20 +10,21 @@ interface IFeatureContext {
|
|
|
10
10
|
interface IFeatureStrategyContext extends IFeatureContext {
|
|
11
11
|
environment: string;
|
|
12
12
|
}
|
|
13
|
-
declare class
|
|
13
|
+
declare class FeatureToggleService {
|
|
14
14
|
private logger;
|
|
15
15
|
private featureStrategiesStore;
|
|
16
16
|
private featureToggleStore;
|
|
17
17
|
private featureToggleClientStore;
|
|
18
|
-
private
|
|
18
|
+
private tagStore;
|
|
19
19
|
private featureEnvironmentStore;
|
|
20
20
|
private projectStore;
|
|
21
21
|
private eventStore;
|
|
22
22
|
constructor({ featureStrategiesStore, featureToggleStore, featureToggleClientStore, projectStore, eventStore, featureTagStore, featureEnvironmentStore, }: Pick<IUnleashStores, 'featureStrategiesStore' | 'featureToggleStore' | 'featureToggleClientStore' | 'projectStore' | 'eventStore' | 'featureTagStore' | 'featureEnvironmentStore'>, { getLogger }: Pick<IUnleashConfig, 'getLogger'>);
|
|
23
23
|
validateFeatureContext({ featureName, projectId, }: IFeatureContext): Promise<void>;
|
|
24
24
|
validateFeatureStrategyContext(strategy: IFeatureStrategy, { featureName, projectId }: IFeatureStrategyContext): void;
|
|
25
|
-
patchFeature(
|
|
26
|
-
|
|
25
|
+
patchFeature(project: string, featureName: string, createdBy: string, operations: Operation[]): Promise<FeatureToggle>;
|
|
26
|
+
featureStrategyToPublic(featureStrategy: IFeatureStrategy): IStrategyConfig;
|
|
27
|
+
createStrategy(strategyConfig: Omit<IStrategyConfig, 'id'>, context: IFeatureStrategyContext, createdBy: string): Promise<IStrategyConfig>;
|
|
27
28
|
/**
|
|
28
29
|
* PUT /api/admin/projects/:projectId/features/:featureName/strategies/:strategyId ?
|
|
29
30
|
* {
|
|
@@ -45,7 +46,7 @@ declare class FeatureToggleServiceV2 {
|
|
|
45
46
|
* @param context - Which context does this strategy live in (projectId, featureName, environment)
|
|
46
47
|
* @param environment - Which environment does this strategy belong to
|
|
47
48
|
*/
|
|
48
|
-
deleteStrategy(id: string, context: IFeatureStrategyContext,
|
|
49
|
+
deleteStrategy(id: string, context: IFeatureStrategyContext, createdBy: string): Promise<void>;
|
|
49
50
|
getStrategiesForEnvironment(project: string, featureName: string, environment?: string): Promise<IStrategyConfig[]>;
|
|
50
51
|
/**
|
|
51
52
|
* GET /api/admin/projects/:project/features/:featureName
|
|
@@ -69,7 +70,7 @@ declare class FeatureToggleServiceV2 {
|
|
|
69
70
|
getFeatureToggles(query?: IFeatureToggleQuery, archived?: boolean): Promise<FeatureToggle[]>;
|
|
70
71
|
getFeatureOverview(projectId: string, archived?: boolean): Promise<IFeatureOverview[]>;
|
|
71
72
|
getFeatureToggle(featureName: string): Promise<FeatureToggleWithEnvironment>;
|
|
72
|
-
createFeatureToggle(projectId: string, value: FeatureToggleDTO,
|
|
73
|
+
createFeatureToggle(projectId: string, value: FeatureToggleDTO, createdBy: string): Promise<FeatureToggle>;
|
|
73
74
|
cloneFeatureToggle(featureName: string, projectId: string, newFeatureName: string, replaceGroupId: boolean, userName: string): Promise<FeatureToggle>;
|
|
74
75
|
updateFeatureToggle(projectId: string, updatedFeature: FeatureToggleDTO, userName: string): Promise<FeatureToggle>;
|
|
75
76
|
getFeatureCountForProject(projectId: string): Promise<number>;
|
|
@@ -81,18 +82,18 @@ declare class FeatureToggleServiceV2 {
|
|
|
81
82
|
validateName(name: string): Promise<string>;
|
|
82
83
|
validateUniqueFeatureName(name: string): Promise<void>;
|
|
83
84
|
hasFeature(name: string): Promise<boolean>;
|
|
84
|
-
updateStale(featureName: string, isStale: boolean,
|
|
85
|
-
archiveToggle(
|
|
86
|
-
updateEnabled(
|
|
87
|
-
storeFeatureUpdatedEventLegacy(featureName: string,
|
|
85
|
+
updateStale(featureName: string, isStale: boolean, createdBy: string): Promise<any>;
|
|
86
|
+
archiveToggle(featureName: string, createdBy: string): Promise<void>;
|
|
87
|
+
updateEnabled(project: string, featureName: string, environment: string, enabled: boolean, createdBy: string): Promise<FeatureToggle>;
|
|
88
|
+
storeFeatureUpdatedEventLegacy(featureName: string, createdBy: string): Promise<FeatureToggleLegacy>;
|
|
88
89
|
toggle(projectId: string, featureName: string, environment: string, userName: string): Promise<FeatureToggle>;
|
|
89
90
|
getFeatureToggleLegacy(featureName: string): Promise<FeatureToggleLegacy>;
|
|
90
|
-
changeProject(featureName: string, newProject: string,
|
|
91
|
+
changeProject(featureName: string, newProject: string, createdBy: string): Promise<void>;
|
|
91
92
|
getArchivedFeatures(): Promise<FeatureToggle[]>;
|
|
92
|
-
deleteFeature(featureName: string,
|
|
93
|
-
reviveToggle(featureName: string,
|
|
93
|
+
deleteFeature(featureName: string, createdBy: string): Promise<void>;
|
|
94
|
+
reviveToggle(featureName: string, createdBy: string): Promise<void>;
|
|
94
95
|
getMetadataForAllFeatures(archived: boolean): Promise<FeatureToggle[]>;
|
|
95
96
|
getProjectId(name: string): Promise<string>;
|
|
96
97
|
updateFeatureStrategyProject(featureName: string, newProjectId: string): Promise<void>;
|
|
97
98
|
}
|
|
98
|
-
export default
|
|
99
|
+
export default FeatureToggleService;
|
|
@@ -12,13 +12,13 @@ const events_1 = require("../types/events");
|
|
|
12
12
|
const notfound_error_1 = __importDefault(require("../error/notfound-error"));
|
|
13
13
|
const constants_1 = require("../util/constants");
|
|
14
14
|
const fast_json_patch_1 = require("fast-json-patch");
|
|
15
|
-
class
|
|
15
|
+
class FeatureToggleService {
|
|
16
16
|
constructor({ featureStrategiesStore, featureToggleStore, featureToggleClientStore, projectStore, eventStore, featureTagStore, featureEnvironmentStore, }, { getLogger }) {
|
|
17
17
|
this.logger = getLogger('services/feature-toggle-service-v2.ts');
|
|
18
18
|
this.featureStrategiesStore = featureStrategiesStore;
|
|
19
19
|
this.featureToggleStore = featureToggleStore;
|
|
20
20
|
this.featureToggleClientStore = featureToggleClientStore;
|
|
21
|
-
this.
|
|
21
|
+
this.tagStore = featureTagStore;
|
|
22
22
|
this.projectStore = projectStore;
|
|
23
23
|
this.eventStore = eventStore;
|
|
24
24
|
this.featureEnvironmentStore = featureEnvironmentStore;
|
|
@@ -37,21 +37,31 @@ class FeatureToggleServiceV2 {
|
|
|
37
37
|
throw new invalid_operation_error_1.default('You can not change the featureName for an activation strategy.');
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
async patchFeature(
|
|
40
|
+
async patchFeature(project, featureName, createdBy, operations) {
|
|
41
41
|
const featureToggle = await this.getFeatureMetadata(featureName);
|
|
42
42
|
const { newDocument } = (0, fast_json_patch_1.applyPatch)((0, fast_json_patch_1.deepClone)(featureToggle), operations);
|
|
43
|
-
const updated = await this.updateFeatureToggle(
|
|
43
|
+
const updated = await this.updateFeatureToggle(project, newDocument, createdBy);
|
|
44
44
|
if (featureToggle.stale !== newDocument.stale) {
|
|
45
|
-
await this.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
project
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
|
46
|
+
await this.eventStore.store(new events_1.FeatureStaleEvent({
|
|
47
|
+
stale: newDocument.stale,
|
|
48
|
+
project,
|
|
49
|
+
featureName,
|
|
50
|
+
createdBy,
|
|
51
|
+
tags,
|
|
52
|
+
}));
|
|
51
53
|
}
|
|
52
54
|
return updated;
|
|
53
55
|
}
|
|
54
|
-
|
|
56
|
+
featureStrategyToPublic(featureStrategy) {
|
|
57
|
+
return {
|
|
58
|
+
id: featureStrategy.id,
|
|
59
|
+
name: featureStrategy.strategyName,
|
|
60
|
+
constraints: featureStrategy.constraints || [],
|
|
61
|
+
parameters: featureStrategy.parameters,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async createStrategy(strategyConfig, context, createdBy) {
|
|
55
65
|
const { featureName, projectId, environment } = context;
|
|
56
66
|
await this.validateFeatureContext(context);
|
|
57
67
|
try {
|
|
@@ -64,24 +74,17 @@ class FeatureToggleServiceV2 {
|
|
|
64
74
|
featureName,
|
|
65
75
|
environment,
|
|
66
76
|
});
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
constraints: newFeatureStrategy.constraints,
|
|
71
|
-
parameters: newFeatureStrategy.parameters,
|
|
72
|
-
};
|
|
73
|
-
await this.eventStore.store({
|
|
74
|
-
type: events_1.FEATURE_STRATEGY_ADD,
|
|
77
|
+
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
|
78
|
+
const strategy = this.featureStrategyToPublic(newFeatureStrategy);
|
|
79
|
+
await this.eventStore.store(new events_1.FeatureStrategyAddEvent({
|
|
75
80
|
project: projectId,
|
|
76
|
-
|
|
81
|
+
featureName,
|
|
82
|
+
createdBy,
|
|
77
83
|
environment,
|
|
78
|
-
data:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
return data;
|
|
84
|
+
data: strategy,
|
|
85
|
+
tags,
|
|
86
|
+
}));
|
|
87
|
+
return strategy;
|
|
85
88
|
}
|
|
86
89
|
catch (e) {
|
|
87
90
|
if (e.code === db_error_1.FOREIGN_KEY_VIOLATION) {
|
|
@@ -101,49 +104,47 @@ class FeatureToggleServiceV2 {
|
|
|
101
104
|
* @param userName - Human readable id of the user performing the update
|
|
102
105
|
*/
|
|
103
106
|
async updateStrategy(id, updates, context, userName) {
|
|
104
|
-
const { projectId, environment } = context;
|
|
107
|
+
const { projectId, environment, featureName } = context;
|
|
105
108
|
const existingStrategy = await this.featureStrategiesStore.get(id);
|
|
106
109
|
this.validateFeatureStrategyContext(existingStrategy, context);
|
|
107
110
|
if (existingStrategy.id === id) {
|
|
108
111
|
const strategy = await this.featureStrategiesStore.updateStrategy(id, updates);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
parameters: strategy.parameters,
|
|
115
|
-
};
|
|
116
|
-
await this.eventStore.store({
|
|
117
|
-
type: events_1.FEATURE_STRATEGY_UPDATE,
|
|
112
|
+
// Store event!
|
|
113
|
+
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
|
114
|
+
const data = this.featureStrategyToPublic(strategy);
|
|
115
|
+
const preData = this.featureStrategyToPublic(existingStrategy);
|
|
116
|
+
await this.eventStore.store(new events_1.FeatureStrategyUpdateEvent({
|
|
118
117
|
project: projectId,
|
|
118
|
+
featureName,
|
|
119
119
|
environment,
|
|
120
120
|
createdBy: userName,
|
|
121
121
|
data,
|
|
122
|
-
|
|
122
|
+
preData,
|
|
123
|
+
tags,
|
|
124
|
+
}));
|
|
123
125
|
return data;
|
|
124
126
|
}
|
|
125
127
|
throw new notfound_error_1.default(`Could not find strategy with id ${id}`);
|
|
126
128
|
}
|
|
127
129
|
async updateStrategyParameter(id, name, value, context, userName) {
|
|
128
|
-
const { projectId, environment } = context;
|
|
130
|
+
const { projectId, environment, featureName } = context;
|
|
129
131
|
const existingStrategy = await this.featureStrategiesStore.get(id);
|
|
130
132
|
this.validateFeatureStrategyContext(existingStrategy, context);
|
|
131
133
|
if (existingStrategy.id === id) {
|
|
132
134
|
existingStrategy.parameters[name] = value;
|
|
133
135
|
const strategy = await this.featureStrategiesStore.updateStrategy(id, existingStrategy);
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
};
|
|
140
|
-
await this.eventStore.store({
|
|
141
|
-
type: events_1.FEATURE_STRATEGY_UPDATE,
|
|
136
|
+
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
|
137
|
+
const data = this.featureStrategyToPublic(strategy);
|
|
138
|
+
const preData = this.featureStrategyToPublic(existingStrategy);
|
|
139
|
+
await this.eventStore.store(new events_1.FeatureStrategyUpdateEvent({
|
|
140
|
+
featureName,
|
|
142
141
|
project: projectId,
|
|
143
142
|
environment,
|
|
144
143
|
createdBy: userName,
|
|
145
144
|
data,
|
|
146
|
-
|
|
145
|
+
preData,
|
|
146
|
+
tags,
|
|
147
|
+
}));
|
|
147
148
|
return data;
|
|
148
149
|
}
|
|
149
150
|
throw new notfound_error_1.default(`Could not find strategy with id ${id}`);
|
|
@@ -157,21 +158,21 @@ class FeatureToggleServiceV2 {
|
|
|
157
158
|
* @param context - Which context does this strategy live in (projectId, featureName, environment)
|
|
158
159
|
* @param environment - Which environment does this strategy belong to
|
|
159
160
|
*/
|
|
160
|
-
async deleteStrategy(id, context,
|
|
161
|
+
async deleteStrategy(id, context, createdBy) {
|
|
161
162
|
const existingStrategy = await this.featureStrategiesStore.get(id);
|
|
162
163
|
const { featureName, projectId, environment } = context;
|
|
163
164
|
this.validateFeatureStrategyContext(existingStrategy, context);
|
|
164
165
|
await this.featureStrategiesStore.delete(id);
|
|
165
|
-
await this.
|
|
166
|
-
|
|
166
|
+
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
|
167
|
+
const preData = this.featureStrategyToPublic(existingStrategy);
|
|
168
|
+
await this.eventStore.store(new events_1.FeatureStrategyRemoveEvent({
|
|
169
|
+
featureName,
|
|
167
170
|
project: projectId,
|
|
168
171
|
environment,
|
|
169
|
-
createdBy
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
},
|
|
174
|
-
});
|
|
172
|
+
createdBy,
|
|
173
|
+
preData,
|
|
174
|
+
tags,
|
|
175
|
+
}));
|
|
175
176
|
// If there are no strategies left for environment disable it
|
|
176
177
|
await this.featureEnvironmentStore.disableEnvironmentIfNoStrategies(featureName, environment);
|
|
177
178
|
}
|
|
@@ -223,21 +224,23 @@ class FeatureToggleServiceV2 {
|
|
|
223
224
|
async getFeatureToggle(featureName) {
|
|
224
225
|
return this.featureStrategiesStore.getFeatureToggleWithEnvs(featureName, false);
|
|
225
226
|
}
|
|
226
|
-
async createFeatureToggle(projectId, value,
|
|
227
|
-
this.logger.info(`${
|
|
227
|
+
async createFeatureToggle(projectId, value, createdBy) {
|
|
228
|
+
this.logger.info(`${createdBy} creates feature toggle ${value.name}`);
|
|
228
229
|
await this.validateName(value.name);
|
|
229
230
|
const exists = await this.projectStore.hasProject(projectId);
|
|
230
231
|
if (exists) {
|
|
231
232
|
const featureData = await feature_schema_1.featureMetadataSchema.validateAsync(value);
|
|
233
|
+
const featureName = featureData.name;
|
|
232
234
|
const createdToggle = await this.featureToggleStore.create(projectId, featureData);
|
|
233
|
-
await this.featureEnvironmentStore.connectFeatureToEnvironmentsForProject(
|
|
234
|
-
const
|
|
235
|
-
await this.eventStore.store({
|
|
236
|
-
|
|
237
|
-
createdBy
|
|
235
|
+
await this.featureEnvironmentStore.connectFeatureToEnvironmentsForProject(featureName, projectId);
|
|
236
|
+
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
|
237
|
+
await this.eventStore.store(new events_1.FeatureCreatedEvent({
|
|
238
|
+
featureName,
|
|
239
|
+
createdBy,
|
|
238
240
|
project: projectId,
|
|
239
|
-
data,
|
|
240
|
-
|
|
241
|
+
data: createdToggle,
|
|
242
|
+
tags,
|
|
243
|
+
}));
|
|
241
244
|
return createdToggle;
|
|
242
245
|
}
|
|
243
246
|
throw new notfound_error_1.default(`Project with id ${projectId} does not exist`);
|
|
@@ -270,15 +273,17 @@ class FeatureToggleServiceV2 {
|
|
|
270
273
|
const featureName = updatedFeature.name;
|
|
271
274
|
this.logger.info(`${userName} updates feature toggle ${featureName}`);
|
|
272
275
|
const featureData = await feature_schema_1.featureMetadataSchema.validateAsync(updatedFeature);
|
|
276
|
+
const preData = await this.featureToggleStore.get(featureName);
|
|
273
277
|
const featureToggle = await this.featureToggleStore.update(projectId, featureData);
|
|
274
|
-
const tags = await this.
|
|
275
|
-
await this.eventStore.store({
|
|
276
|
-
type: events_1.FEATURE_METADATA_UPDATED,
|
|
278
|
+
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
|
279
|
+
await this.eventStore.store(new events_1.FeatureMetadataUpdateEvent({
|
|
277
280
|
createdBy: userName,
|
|
278
281
|
data: featureToggle,
|
|
282
|
+
preData,
|
|
283
|
+
featureName,
|
|
279
284
|
project: projectId,
|
|
280
285
|
tags,
|
|
281
|
-
});
|
|
286
|
+
}));
|
|
282
287
|
return featureToggle;
|
|
283
288
|
}
|
|
284
289
|
async getFeatureCountForProject(projectId) {
|
|
@@ -309,6 +314,7 @@ class FeatureToggleServiceV2 {
|
|
|
309
314
|
strategies,
|
|
310
315
|
};
|
|
311
316
|
}
|
|
317
|
+
// todo: store events for this change.
|
|
312
318
|
async deleteEnvironment(projectId, environment) {
|
|
313
319
|
await this.featureStrategiesStore.deleteConfigurationsForProjectAndEnvironment(projectId, environment);
|
|
314
320
|
await this.projectStore.deleteEnvironmentForProject(projectId, environment);
|
|
@@ -335,38 +341,38 @@ class FeatureToggleServiceV2 {
|
|
|
335
341
|
async hasFeature(name) {
|
|
336
342
|
return this.featureToggleStore.exists(name);
|
|
337
343
|
}
|
|
338
|
-
async updateStale(featureName, isStale,
|
|
344
|
+
async updateStale(featureName, isStale, createdBy) {
|
|
339
345
|
const feature = await this.featureToggleStore.get(featureName);
|
|
346
|
+
const { project } = feature;
|
|
340
347
|
feature.stale = isStale;
|
|
341
|
-
await this.featureToggleStore.update(
|
|
342
|
-
const tags = await this.
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
+
await this.featureToggleStore.update(project, feature);
|
|
349
|
+
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
|
350
|
+
await this.eventStore.store(new events_1.FeatureStaleEvent({
|
|
351
|
+
stale: isStale,
|
|
352
|
+
project,
|
|
353
|
+
featureName,
|
|
354
|
+
createdBy,
|
|
348
355
|
tags,
|
|
349
|
-
|
|
350
|
-
});
|
|
356
|
+
}));
|
|
351
357
|
return feature;
|
|
352
358
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
await this.featureToggleStore.
|
|
356
|
-
|
|
357
|
-
await this.
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
359
|
+
// todo: add projectId
|
|
360
|
+
async archiveToggle(featureName, createdBy) {
|
|
361
|
+
const feature = await this.featureToggleStore.get(featureName);
|
|
362
|
+
await this.featureToggleStore.archive(featureName);
|
|
363
|
+
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
|
364
|
+
await this.eventStore.store(new events_1.FeatureArchivedEvent({
|
|
365
|
+
featureName,
|
|
366
|
+
createdBy,
|
|
361
367
|
project: feature.project,
|
|
362
368
|
tags,
|
|
363
|
-
});
|
|
369
|
+
}));
|
|
364
370
|
}
|
|
365
|
-
async updateEnabled(
|
|
371
|
+
async updateEnabled(project, featureName, environment, enabled, createdBy) {
|
|
366
372
|
const hasEnvironment = await this.featureEnvironmentStore.featureHasEnvironment(environment, featureName);
|
|
367
373
|
if (hasEnvironment) {
|
|
368
374
|
if (enabled) {
|
|
369
|
-
const strategies = await this.getStrategiesForEnvironment(
|
|
375
|
+
const strategies = await this.getStrategiesForEnvironment(project, featureName, environment);
|
|
370
376
|
if (strategies.length === 0) {
|
|
371
377
|
throw new invalid_operation_error_1.default('You can not enable the environment before it has strategies');
|
|
372
378
|
}
|
|
@@ -374,28 +380,30 @@ class FeatureToggleServiceV2 {
|
|
|
374
380
|
const updatedEnvironmentStatus = await this.featureEnvironmentStore.setEnvironmentEnabledStatus(environment, featureName, enabled);
|
|
375
381
|
const feature = await this.featureToggleStore.get(featureName);
|
|
376
382
|
if (updatedEnvironmentStatus > 0) {
|
|
377
|
-
const tags = await this.
|
|
378
|
-
await this.eventStore.store({
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
createdBy: userName,
|
|
383
|
-
data: { name: featureName },
|
|
384
|
-
tags,
|
|
385
|
-
project: projectId,
|
|
383
|
+
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
|
384
|
+
await this.eventStore.store(new events_1.FeatureEnvironmentEvent({
|
|
385
|
+
enabled,
|
|
386
|
+
project,
|
|
387
|
+
featureName,
|
|
386
388
|
environment,
|
|
387
|
-
|
|
389
|
+
createdBy,
|
|
390
|
+
tags,
|
|
391
|
+
}));
|
|
388
392
|
}
|
|
389
393
|
return feature;
|
|
390
394
|
}
|
|
391
395
|
throw new notfound_error_1.default(`Could not find environment ${environment} for feature: ${featureName}`);
|
|
392
396
|
}
|
|
393
|
-
|
|
394
|
-
|
|
397
|
+
// @deprecated
|
|
398
|
+
async storeFeatureUpdatedEventLegacy(featureName, createdBy) {
|
|
399
|
+
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
|
395
400
|
const feature = await this.getFeatureToggleLegacy(featureName);
|
|
401
|
+
// Legacy event. Will not be used from v4.3.
|
|
402
|
+
// We do not include 'preData' on purpose.
|
|
396
403
|
await this.eventStore.store({
|
|
397
404
|
type: events_1.FEATURE_UPDATED,
|
|
398
|
-
createdBy
|
|
405
|
+
createdBy,
|
|
406
|
+
featureName,
|
|
399
407
|
data: feature,
|
|
400
408
|
tags,
|
|
401
409
|
project: feature.project,
|
|
@@ -408,6 +416,7 @@ class FeatureToggleServiceV2 {
|
|
|
408
416
|
const isEnabled = await this.featureEnvironmentStore.isEnvironmentEnabled(featureName, environment);
|
|
409
417
|
return this.updateEnabled(projectId, featureName, environment, !isEnabled, userName);
|
|
410
418
|
}
|
|
419
|
+
// @deprecated
|
|
411
420
|
async getFeatureToggleLegacy(featureName) {
|
|
412
421
|
const feature = await this.featureStrategiesStore.getFeatureToggleWithEnvs(featureName);
|
|
413
422
|
const { environments, ...legacyFeature } = feature;
|
|
@@ -416,47 +425,46 @@ class FeatureToggleServiceV2 {
|
|
|
416
425
|
const enabled = defaultEnv?.enabled || false;
|
|
417
426
|
return { ...legacyFeature, enabled, strategies };
|
|
418
427
|
}
|
|
419
|
-
async changeProject(featureName, newProject,
|
|
428
|
+
async changeProject(featureName, newProject, createdBy) {
|
|
420
429
|
const feature = await this.featureToggleStore.get(featureName);
|
|
421
430
|
const oldProject = feature.project;
|
|
422
431
|
feature.project = newProject;
|
|
423
432
|
await this.featureToggleStore.update(newProject, feature);
|
|
424
|
-
const tags = await this.
|
|
425
|
-
await this.eventStore.store({
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
oldProject,
|
|
431
|
-
newProject,
|
|
432
|
-
},
|
|
433
|
-
project: newProject,
|
|
433
|
+
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
|
434
|
+
await this.eventStore.store(new events_1.FeatureChangeProjectEvent({
|
|
435
|
+
createdBy,
|
|
436
|
+
oldProject,
|
|
437
|
+
newProject,
|
|
438
|
+
featureName,
|
|
434
439
|
tags,
|
|
435
|
-
});
|
|
440
|
+
}));
|
|
436
441
|
}
|
|
437
442
|
async getArchivedFeatures() {
|
|
438
443
|
return this.getFeatureToggles({}, true);
|
|
439
444
|
}
|
|
440
|
-
|
|
445
|
+
// TODO: add project id.
|
|
446
|
+
async deleteFeature(featureName, createdBy) {
|
|
447
|
+
const toggle = await this.featureToggleStore.get(featureName);
|
|
448
|
+
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
|
441
449
|
await this.featureToggleStore.delete(featureName);
|
|
442
|
-
await this.eventStore.store({
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
});
|
|
450
|
+
await this.eventStore.store(new events_1.FeatureDeletedEvent({
|
|
451
|
+
featureName,
|
|
452
|
+
project: toggle.project,
|
|
453
|
+
createdBy,
|
|
454
|
+
preData: toggle,
|
|
455
|
+
tags,
|
|
456
|
+
}));
|
|
449
457
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
const
|
|
453
|
-
await this.
|
|
454
|
-
|
|
455
|
-
createdBy
|
|
456
|
-
|
|
457
|
-
project:
|
|
458
|
+
// TODO: add project id.
|
|
459
|
+
async reviveToggle(featureName, createdBy) {
|
|
460
|
+
const toggle = await this.featureToggleStore.revive(featureName);
|
|
461
|
+
const tags = await this.tagStore.getAllTagsForFeature(featureName);
|
|
462
|
+
await this.eventStore.store(new events_1.FeatureRevivedEvent({
|
|
463
|
+
createdBy,
|
|
464
|
+
featureName,
|
|
465
|
+
project: toggle.project,
|
|
458
466
|
tags,
|
|
459
|
-
});
|
|
467
|
+
}));
|
|
460
468
|
}
|
|
461
469
|
async getMetadataForAllFeatures(archived) {
|
|
462
470
|
return this.featureToggleStore.getAll({ archived });
|
|
@@ -468,6 +476,5 @@ class FeatureToggleServiceV2 {
|
|
|
468
476
|
await this.featureStrategiesStore.setProjectForStrategiesBelongingToFeature(featureName, newProjectId);
|
|
469
477
|
}
|
|
470
478
|
}
|
|
471
|
-
|
|
472
|
-
exports.default = FeatureToggleServiceV2;
|
|
479
|
+
exports.default = FeatureToggleService;
|
|
473
480
|
//# sourceMappingURL=feature-toggle-service.js.map
|