@diia-inhouse/features 2.7.43 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -19
- package/dist/interfaces/index.d.ts +27 -0
- package/dist/services/feature.d.ts +23 -0
- package/dist/services/feature.js +86 -94
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +2 -18
- package/package.json +35 -25
- package/dist/index.js.map +0 -1
- package/dist/interfaces/index.js +0 -3
- package/dist/interfaces/index.js.map +0 -1
- package/dist/services/feature.js.map +0 -1
- package/dist/services/index.js.map +0 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/interfaces/index.d.ts +0 -23
- package/dist/types/services/feature.d.ts +0 -19
- package/dist/types/services/index.d.ts +0 -1
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./interfaces"), exports);
|
|
18
|
-
__exportStar(require("./services"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { FeatureService } from "./services/feature.js";
|
|
2
|
+
import "./services/index.js";
|
|
3
|
+
export { FeatureService };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Context } from "unleash-client";
|
|
2
|
+
import { PlatformType, ProfileFeature, SessionType } from "@diia-inhouse/types";
|
|
3
|
+
import { FeatureInterface as FeatureInterface$1 } from "unleash-client/lib/feature.js";
|
|
4
|
+
|
|
5
|
+
//#region src/interfaces/index.d.ts
|
|
6
|
+
interface FeatureConfig {
|
|
7
|
+
isEnabled: boolean;
|
|
8
|
+
url: string;
|
|
9
|
+
apiToken: string;
|
|
10
|
+
}
|
|
11
|
+
interface FeatureContext extends Context {
|
|
12
|
+
/**
|
|
13
|
+
* Base64 encoded userIdentifier. Due to Unleash limitation max 100 chars per value we can't use userIdentifier (sha512 hex representation) for unleash values as his length is 128.
|
|
14
|
+
* But at the same time base64 representation of it is 88 chars long which is fine.
|
|
15
|
+
*/
|
|
16
|
+
userIdBase64?: string;
|
|
17
|
+
platformType?: PlatformType;
|
|
18
|
+
/** semver major(.minor)(.patch) */
|
|
19
|
+
platformVersion?: string;
|
|
20
|
+
/** semver major.minor.patch(.build) */
|
|
21
|
+
appVersion?: string;
|
|
22
|
+
mobileUid?: string;
|
|
23
|
+
sessionType?: SessionType;
|
|
24
|
+
profileFeature?: ProfileFeature;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { FeatureConfig, FeatureContext, type FeatureInterface$1 as FeatureInterface };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FeatureConfig, FeatureContext } from "../interfaces/index.js";
|
|
2
|
+
import { AlsData, Logger, OnInit } from "@diia-inhouse/types";
|
|
3
|
+
import { FeatureInterface } from "unleash-client/lib/feature.js";
|
|
4
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5
|
+
import { EnvService } from "@diia-inhouse/env";
|
|
6
|
+
|
|
7
|
+
//#region src/services/feature.d.ts
|
|
8
|
+
declare class FeatureService implements OnInit {
|
|
9
|
+
private readonly serviceName;
|
|
10
|
+
private readonly featureConfig;
|
|
11
|
+
private readonly logger;
|
|
12
|
+
private readonly envService;
|
|
13
|
+
private readonly asyncLocalStorage;
|
|
14
|
+
private unleash;
|
|
15
|
+
constructor(serviceName: string, featureConfig: FeatureConfig, logger: Logger, envService: EnvService, asyncLocalStorage: AsyncLocalStorage<AlsData>);
|
|
16
|
+
onInit(): Promise<void>;
|
|
17
|
+
isEnabled(name: string, context?: FeatureContext): boolean;
|
|
18
|
+
isSomeEnabled(name: string, contexts: FeatureContext[]): boolean;
|
|
19
|
+
getDefinition(name: string): FeatureInterface | undefined;
|
|
20
|
+
private parseAppVersion;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { FeatureService };
|
package/dist/services/feature.js
CHANGED
|
@@ -1,95 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import semver from "semver";
|
|
2
|
+
import { startUnleash } from "unleash-client";
|
|
3
|
+
//#region src/services/feature.ts
|
|
4
|
+
var FeatureService = class {
|
|
5
|
+
serviceName;
|
|
6
|
+
featureConfig;
|
|
7
|
+
logger;
|
|
8
|
+
envService;
|
|
9
|
+
asyncLocalStorage;
|
|
10
|
+
unleash = null;
|
|
11
|
+
constructor(serviceName, featureConfig, logger, envService, asyncLocalStorage) {
|
|
12
|
+
this.serviceName = serviceName;
|
|
13
|
+
this.featureConfig = featureConfig;
|
|
14
|
+
this.logger = logger;
|
|
15
|
+
this.envService = envService;
|
|
16
|
+
this.asyncLocalStorage = asyncLocalStorage;
|
|
17
|
+
}
|
|
18
|
+
async onInit() {
|
|
19
|
+
const { isEnabled, url, apiToken } = this.featureConfig;
|
|
20
|
+
if (!isEnabled) {
|
|
21
|
+
this.logger.info("Unleash is disabled. All feature flags are set to false");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
this.unleash = await startUnleash({
|
|
25
|
+
url,
|
|
26
|
+
appName: this.serviceName,
|
|
27
|
+
customHeaders: { Authorization: apiToken },
|
|
28
|
+
environment: this.envService.isProd() ? "production" : "development",
|
|
29
|
+
tags: [{
|
|
30
|
+
name: "microservice",
|
|
31
|
+
value: this.serviceName
|
|
32
|
+
}]
|
|
33
|
+
});
|
|
34
|
+
this.unleash.on("warn", (err) => {
|
|
35
|
+
this.logger.warn("Unleash warn event", { err });
|
|
36
|
+
});
|
|
37
|
+
this.unleash.on("error", (err) => {
|
|
38
|
+
this.logger.error("Unleash error event", { err });
|
|
39
|
+
});
|
|
40
|
+
this.logger.info("Unleash has started");
|
|
41
|
+
}
|
|
42
|
+
isEnabled(name, context = {}) {
|
|
43
|
+
if (!this.unleash) {
|
|
44
|
+
this.logger.warn("Unleash is disabled");
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
const alsStore = this.asyncLocalStorage.getStore() ?? {};
|
|
48
|
+
context.userId ??= alsStore.logData?.userIdentifier;
|
|
49
|
+
context.userIdBase64 ??= context.userId && Buffer.from(context.userId, "hex").toString("base64");
|
|
50
|
+
context.sessionType ??= alsStore.logData?.sessionType;
|
|
51
|
+
context.platformType ??= alsStore.headers?.platformType;
|
|
52
|
+
context.platformVersion ??= alsStore.headers?.platformVersion;
|
|
53
|
+
context.platformVersion = semver.coerce(context.platformVersion)?.version;
|
|
54
|
+
context.appVersion ??= alsStore.headers?.appVersion;
|
|
55
|
+
context.appVersion = this.parseAppVersion(context.appVersion);
|
|
56
|
+
context.mobileUid ??= alsStore.headers?.mobileUid;
|
|
57
|
+
context.currentTime ??= /* @__PURE__ */ new Date();
|
|
58
|
+
context.environment ??= this.envService.getEnv();
|
|
59
|
+
this.logger.debug("Feature flag check", {
|
|
60
|
+
name,
|
|
61
|
+
context
|
|
62
|
+
});
|
|
63
|
+
const result = this.unleash.isEnabled(name, context);
|
|
64
|
+
if (result) {
|
|
65
|
+
alsStore.logData ??= {};
|
|
66
|
+
alsStore.logData.flags ??= [];
|
|
67
|
+
if (!alsStore.logData.flags.includes(name)) alsStore.logData.flags.push(name);
|
|
68
|
+
this.asyncLocalStorage.enterWith(alsStore);
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
isSomeEnabled(name, contexts) {
|
|
73
|
+
return contexts.some((context) => this.isEnabled(name, context));
|
|
74
|
+
}
|
|
75
|
+
getDefinition(name) {
|
|
76
|
+
return this.unleash?.getFeatureToggleDefinition(name);
|
|
77
|
+
}
|
|
78
|
+
parseAppVersion(appVersion) {
|
|
79
|
+
if (!appVersion) return;
|
|
80
|
+
const parts = appVersion.split(".");
|
|
81
|
+
if (parts.length === 3) return appVersion;
|
|
82
|
+
if (parts.length === 4) return `${parts.slice(0, 3).join(".")}-${parts[3]}`;
|
|
83
|
+
this.logger.warn("Invalid app version format for feature flag", { appVersion });
|
|
84
|
+
}
|
|
4
85
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const semver_1 = __importDefault(require("semver"));
|
|
8
|
-
const unleash_client_1 = require("unleash-client");
|
|
9
|
-
class FeatureService {
|
|
10
|
-
serviceName;
|
|
11
|
-
featureConfig;
|
|
12
|
-
logger;
|
|
13
|
-
envService;
|
|
14
|
-
asyncLocalStorage;
|
|
15
|
-
unleash = null;
|
|
16
|
-
constructor(serviceName, featureConfig, logger, envService, asyncLocalStorage) {
|
|
17
|
-
this.serviceName = serviceName;
|
|
18
|
-
this.featureConfig = featureConfig;
|
|
19
|
-
this.logger = logger;
|
|
20
|
-
this.envService = envService;
|
|
21
|
-
this.asyncLocalStorage = asyncLocalStorage;
|
|
22
|
-
}
|
|
23
|
-
async onInit() {
|
|
24
|
-
const { isEnabled, url, apiToken } = this.featureConfig;
|
|
25
|
-
if (!isEnabled) {
|
|
26
|
-
this.logger.info('Unleash is disabled. All feature flags are set to false');
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
this.unleash = await (0, unleash_client_1.startUnleash)({
|
|
30
|
-
url,
|
|
31
|
-
appName: this.serviceName,
|
|
32
|
-
customHeaders: { Authorization: apiToken },
|
|
33
|
-
environment: this.envService.isProd() ? 'production' : 'development',
|
|
34
|
-
tags: [{ name: 'microservice', value: this.serviceName }],
|
|
35
|
-
});
|
|
36
|
-
this.unleash.on('warn', (err) => {
|
|
37
|
-
this.logger.warn('Unleash warn event', { err });
|
|
38
|
-
});
|
|
39
|
-
this.unleash.on('error', (err) => {
|
|
40
|
-
this.logger.error('Unleash error event', { err });
|
|
41
|
-
});
|
|
42
|
-
this.logger.info('Unleash has started');
|
|
43
|
-
}
|
|
44
|
-
isEnabled(name, context = {}) {
|
|
45
|
-
if (!this.unleash) {
|
|
46
|
-
this.logger.warn('Unleash is disabled');
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
const alsStore = this.asyncLocalStorage.getStore() ?? {};
|
|
50
|
-
context.userId ??= alsStore.logData?.userIdentifier;
|
|
51
|
-
context.userIdBase64 ??= context.userId && Buffer.from(context.userId, 'hex').toString('base64');
|
|
52
|
-
context.sessionType ??= alsStore.logData?.sessionType;
|
|
53
|
-
context.platformType ??= alsStore.headers?.platformType;
|
|
54
|
-
context.platformVersion ??= alsStore.headers?.platformVersion;
|
|
55
|
-
context.platformVersion = semver_1.default.coerce(context.platformVersion)?.version;
|
|
56
|
-
context.appVersion ??= alsStore.headers?.appVersion;
|
|
57
|
-
context.appVersion = this.parseAppVersion(context.appVersion);
|
|
58
|
-
context.mobileUid ??= alsStore.headers?.mobileUid;
|
|
59
|
-
context.currentTime ??= new Date();
|
|
60
|
-
context.environment ??= this.envService.getEnv();
|
|
61
|
-
this.logger.debug('Feature flag check', { name, context });
|
|
62
|
-
const result = this.unleash.isEnabled(name, context);
|
|
63
|
-
if (result) {
|
|
64
|
-
alsStore.logData ??= {};
|
|
65
|
-
alsStore.logData.flags ??= [];
|
|
66
|
-
if (!alsStore.logData.flags.includes(name)) {
|
|
67
|
-
alsStore.logData.flags.push(name);
|
|
68
|
-
}
|
|
69
|
-
this.asyncLocalStorage.enterWith(alsStore);
|
|
70
|
-
}
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
|
-
isSomeEnabled(name, contexts) {
|
|
74
|
-
return contexts.some((context) => this.isEnabled(name, context));
|
|
75
|
-
}
|
|
76
|
-
getDefinition(name) {
|
|
77
|
-
return this.unleash?.getFeatureToggleDefinition(name);
|
|
78
|
-
}
|
|
79
|
-
parseAppVersion(appVersion) {
|
|
80
|
-
if (!appVersion) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const parts = appVersion.split('.');
|
|
84
|
-
if (parts.length === 3) {
|
|
85
|
-
return appVersion;
|
|
86
|
-
}
|
|
87
|
-
if (parts.length === 4) {
|
|
88
|
-
return parts.slice(0, 3).join('.') + `-${parts[3]}`;
|
|
89
|
-
}
|
|
90
|
-
this.logger.warn('Invalid app version format for feature flag', { appVersion });
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.FeatureService = FeatureService;
|
|
95
|
-
//# sourceMappingURL=feature.js.map
|
|
86
|
+
//#endregion
|
|
87
|
+
export { FeatureService };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { FeatureService } from "./feature.js";
|
package/dist/services/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./feature"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import "./feature.js";
|
|
2
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diia-inhouse/features",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "3.2.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "Features toggles",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
7
8
|
"repository": "https://github.com/diia-open-source/be-pkg-features",
|
|
8
9
|
"author": "Diia",
|
|
9
10
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
10
18
|
"files": [
|
|
11
19
|
"dist"
|
|
12
20
|
],
|
|
13
21
|
"engines": {
|
|
14
|
-
"node": ">=
|
|
22
|
+
"node": ">=24"
|
|
15
23
|
},
|
|
16
24
|
"scripts": {
|
|
17
25
|
"prebuild": "rimraf dist",
|
|
18
|
-
"build": "
|
|
26
|
+
"build": "tsdown",
|
|
19
27
|
"semantic-release": "semantic-release",
|
|
20
28
|
"start": "npm run build && node dist/index.js",
|
|
21
|
-
"lint": "
|
|
22
|
-
"lint-fix": "
|
|
29
|
+
"lint": "oxlint && oxfmt --check .",
|
|
30
|
+
"lint-fix": "oxlint --fix && oxfmt .",
|
|
23
31
|
"lint:lockfile": "lockfile-lint --path package-lock.json --allowed-hosts registry.npmjs.org --validate-https",
|
|
24
32
|
"prepare": "npm run build",
|
|
25
33
|
"test": "vitest run",
|
|
@@ -29,33 +37,36 @@
|
|
|
29
37
|
},
|
|
30
38
|
"dependencies": {
|
|
31
39
|
"semver": "7.7.4",
|
|
32
|
-
"unleash-client": "6.10.
|
|
40
|
+
"unleash-client": "6.10.1"
|
|
33
41
|
},
|
|
34
42
|
"peerDependencies": {
|
|
35
|
-
"@diia-inhouse/env": ">=
|
|
36
|
-
"@diia-inhouse/types": ">=
|
|
43
|
+
"@diia-inhouse/env": ">=3.0.0",
|
|
44
|
+
"@diia-inhouse/types": ">=13.1.0"
|
|
37
45
|
},
|
|
38
46
|
"devDependencies": {
|
|
39
47
|
"@commitlint/cli": "20.4.3",
|
|
40
|
-
"@diia-inhouse/configs": "
|
|
41
|
-
"@diia-inhouse/diia-logger": "
|
|
42
|
-
"@diia-inhouse/env": "
|
|
43
|
-
"@diia-inhouse/errors": "1.
|
|
44
|
-
"@diia-inhouse/
|
|
45
|
-
"@diia-inhouse/test": "
|
|
46
|
-
"@diia-inhouse/types": "
|
|
47
|
-
"@types/node": "25.
|
|
48
|
+
"@diia-inhouse/configs": "7.0.0",
|
|
49
|
+
"@diia-inhouse/diia-logger": "4.2.4",
|
|
50
|
+
"@diia-inhouse/env": "3.3.0",
|
|
51
|
+
"@diia-inhouse/errors": "2.1.1",
|
|
52
|
+
"@diia-inhouse/oxc-config": "1.10.0",
|
|
53
|
+
"@diia-inhouse/test": "8.2.1",
|
|
54
|
+
"@diia-inhouse/types": "13.2.0",
|
|
55
|
+
"@types/node": "25.6.2",
|
|
48
56
|
"@types/semver": "7.7.1",
|
|
49
|
-
"@vitest/coverage-v8": "4.
|
|
50
|
-
"@vitest/ui": "4.
|
|
51
|
-
"
|
|
52
|
-
"lockfile-lint": "4.14.1",
|
|
57
|
+
"@vitest/coverage-v8": "4.1.5",
|
|
58
|
+
"@vitest/ui": "4.1.5",
|
|
59
|
+
"lockfile-lint": "5.0.0",
|
|
53
60
|
"madge": "8.0.0",
|
|
61
|
+
"oxfmt": "0.48.0",
|
|
62
|
+
"oxlint": "1.63.0",
|
|
63
|
+
"oxlint-tsgolint": "0.22.1",
|
|
54
64
|
"rimraf": "6.1.3",
|
|
55
|
-
"semantic-release": "
|
|
65
|
+
"semantic-release": "25.0.3",
|
|
66
|
+
"tsdown": "0.22.0",
|
|
56
67
|
"vite-tsconfig-paths": "6.1.1",
|
|
57
|
-
"vitest": "4.
|
|
58
|
-
"vitest-mock-extended": "
|
|
68
|
+
"vitest": "4.1.5",
|
|
69
|
+
"vitest-mock-extended": "4.0.0"
|
|
59
70
|
},
|
|
60
71
|
"release": {
|
|
61
72
|
"extends": "@diia-inhouse/configs/dist/semantic-release/package",
|
|
@@ -66,7 +77,6 @@
|
|
|
66
77
|
"commitlint": {
|
|
67
78
|
"extends": "@diia-inhouse/configs/dist/commitlint"
|
|
68
79
|
},
|
|
69
|
-
"prettier": "@diia-inhouse/eslint-config/prettier",
|
|
70
80
|
"madge": {
|
|
71
81
|
"tsConfig": "./tsconfig.json"
|
|
72
82
|
}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAE5B,6CAA0B"}
|
package/dist/interfaces/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"feature.js","sourceRoot":"","sources":["../../src/services/feature.ts"],"names":[],"mappings":";;;;;;AAEA,oDAA2B;AAC3B,mDAAsD;AAQtD,MAAa,cAAc;IAIF;IACA;IACA;IACA;IACA;IAPb,OAAO,GAAmB,IAAI,CAAA;IAEtC,YACqB,WAAmB,EACnB,aAA4B,EAC5B,MAAc,EACd,UAAsB,EACtB,iBAA6C;QAJ7C,gBAAW,GAAX,WAAW,CAAQ;QACnB,kBAAa,GAAb,aAAa,CAAe;QAC5B,WAAM,GAAN,MAAM,CAAQ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AA;QAE/E,OAAM;IACV,CAAC;CACJ;AA5GD,wCA4GC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB"}
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Context } from 'unleash-client';
|
|
2
|
-
import { PlatformType, ProfileFeature, SessionType } from '@diia-inhouse/types';
|
|
3
|
-
export { FeatureInterface } from 'unleash-client/lib/feature';
|
|
4
|
-
export interface FeatureConfig {
|
|
5
|
-
isEnabled: boolean;
|
|
6
|
-
url: string;
|
|
7
|
-
apiToken: string;
|
|
8
|
-
}
|
|
9
|
-
export interface FeatureContext extends Context {
|
|
10
|
-
/**
|
|
11
|
-
* Base64 encoded userIdentifier. Due to Unleash limitation max 100 chars per value we can't use userIdentifier (sha512 hex representation) for unleash values as his length is 128.
|
|
12
|
-
* But at the same time base64 representation of it is 88 chars long which is fine.
|
|
13
|
-
*/
|
|
14
|
-
userIdBase64?: string;
|
|
15
|
-
platformType?: PlatformType;
|
|
16
|
-
/** semver major(.minor)(.patch) */
|
|
17
|
-
platformVersion?: string;
|
|
18
|
-
/** semver major.minor.patch(.build) */
|
|
19
|
-
appVersion?: string;
|
|
20
|
-
mobileUid?: string;
|
|
21
|
-
sessionType?: SessionType;
|
|
22
|
-
profileFeature?: ProfileFeature;
|
|
23
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
-
import { FeatureInterface } from 'unleash-client/lib/feature';
|
|
3
|
-
import type { EnvService } from '@diia-inhouse/env';
|
|
4
|
-
import { AlsData, Logger, OnInit } from '@diia-inhouse/types';
|
|
5
|
-
import { FeatureConfig, FeatureContext } from '../interfaces';
|
|
6
|
-
export declare class FeatureService implements OnInit {
|
|
7
|
-
private readonly serviceName;
|
|
8
|
-
private readonly featureConfig;
|
|
9
|
-
private readonly logger;
|
|
10
|
-
private readonly envService;
|
|
11
|
-
private readonly asyncLocalStorage;
|
|
12
|
-
private unleash;
|
|
13
|
-
constructor(serviceName: string, featureConfig: FeatureConfig, logger: Logger, envService: EnvService, asyncLocalStorage: AsyncLocalStorage<AlsData>);
|
|
14
|
-
onInit(): Promise<void>;
|
|
15
|
-
isEnabled(name: string, context?: FeatureContext): boolean;
|
|
16
|
-
isSomeEnabled(name: string, contexts: FeatureContext[]): boolean;
|
|
17
|
-
getDefinition(name: string): FeatureInterface | undefined;
|
|
18
|
-
private parseAppVersion;
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './feature';
|