@equinor/fusion-framework-app
Advanced tools
Comparing version 7.1.15 to 8.0.0
# Change Log | ||
## 8.0.0 | ||
### Minor Changes | ||
- [#1747](https://github.com/equinor/fusion-framework/pull/1747) [`8b031c3`](https://github.com/equinor/fusion-framework/commit/8b031c31f314deeffdf395fc847e4279b61aab7e) Thanks [@odinr](https://github.com/odinr)! - Added method to `AppConfigurator` to enabled `Feature Flag Module` | ||
```ts | ||
export const configure: ModuleInitiator = (appConfigurator, args) => { | ||
/** provide a list of features that should be available in the application */ | ||
appConfigurator.useFeatureFlags([ | ||
{ | ||
key: MyFeatures.MyFlag, | ||
title: "this is a flag", | ||
}, | ||
{ | ||
key: MyFeatures.MyUrlFlag, | ||
title: "this feature can be toggled by ?my-url-flag=true", | ||
allowUrl: true, | ||
}, | ||
]); | ||
}; | ||
``` | ||
### Patch Changes | ||
- Updated dependencies [[`8b031c3`](https://github.com/equinor/fusion-framework/commit/8b031c31f314deeffdf395fc847e4279b61aab7e)]: | ||
- @equinor/fusion-framework-module-feature-flag@1.0.0 | ||
## 7.1.15 | ||
@@ -4,0 +32,0 @@ |
@@ -10,2 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
import { ModuleConsoleLogger, ModulesConfigurator, } from '@equinor/fusion-framework-module'; | ||
@@ -15,5 +26,8 @@ import event from '@equinor/fusion-framework-module-event'; | ||
import auth, { configureMsal } from '@equinor/fusion-framework-module-msal'; | ||
import { enableFeatureFlagging, } from '@equinor/fusion-framework-module-feature-flag'; | ||
import { createLocalStoragePlugin, createUrlPlugin, } from '@equinor/fusion-framework-module-feature-flag/plugins'; | ||
export class AppConfigurator extends ModulesConfigurator { | ||
constructor() { | ||
constructor(env) { | ||
super([event, http, auth]); | ||
this.env = env; | ||
this.logger = new ModuleConsoleLogger('AppConfigurator'); | ||
@@ -42,4 +56,29 @@ } | ||
} | ||
useFeatureFlags(flags_cb) { | ||
switch (typeof flags_cb) { | ||
case 'function': { | ||
enableFeatureFlagging(this, flags_cb); | ||
break; | ||
} | ||
case 'object': { | ||
const urlFlags = []; | ||
const localFlags = (flags_cb !== null && flags_cb !== void 0 ? flags_cb : []).map((flag) => { | ||
const { allowUrl } = flag, localFlag = __rest(flag, ["allowUrl"]); | ||
if (allowUrl) { | ||
urlFlags.push(flag); | ||
} | ||
return localFlag; | ||
}); | ||
enableFeatureFlagging(this, (builder) => __awaiter(this, void 0, void 0, function* () { | ||
builder.addPlugin(createLocalStoragePlugin(localFlags, { | ||
name: this.env.manifest.key, | ||
})); | ||
builder.addPlugin(createUrlPlugin(urlFlags)); | ||
})); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
export default AppConfigurator; | ||
//# sourceMappingURL=AppConfigurator.js.map |
@@ -13,3 +13,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
var _a; | ||
const configurator = new AppConfigurator(); | ||
const configurator = new AppConfigurator(args.env); | ||
if (cb) { | ||
@@ -16,0 +16,0 @@ yield Promise.resolve(cb(configurator, args)); |
@@ -1,2 +0,2 @@ | ||
export const version = '7.1.15'; | ||
export const version = '8.0.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -5,3 +5,4 @@ import { type FusionModulesInstance } from '@equinor/fusion-framework'; | ||
import { configureMsal } from '@equinor/fusion-framework-module-msal'; | ||
import { AppModules } from './types'; | ||
import { type IFeatureFlag, type FeatureFlagBuilderCallback } from '@equinor/fusion-framework-module-feature-flag'; | ||
import { AppEnv, AppModules } from './types'; | ||
export interface IAppConfigurator<TModules extends Array<AnyModule> | unknown = unknown, TRef extends FusionModulesInstance = FusionModulesInstance> extends IModulesConfigurator<AppModules<TModules>, TRef> { | ||
@@ -12,5 +13,11 @@ configureHttp(...args: Parameters<typeof configureHttp>): void; | ||
useFrameworkServiceClient(serviceName: string): void; | ||
useFeatureFlags(flags: Array<IFeatureFlag & { | ||
allowUrl?: boolean; | ||
}>): void; | ||
useFeatureFlags(cb: FeatureFlagBuilderCallback): void; | ||
useFeatureFlags(): void; | ||
} | ||
export declare class AppConfigurator<TModules extends Array<AnyModule> | unknown = unknown, TRef extends FusionModulesInstance = FusionModulesInstance> extends ModulesConfigurator<AppModules<TModules>, TRef> implements IAppConfigurator<TModules, TRef> { | ||
constructor(); | ||
export declare class AppConfigurator<TModules extends Array<AnyModule> | unknown = unknown, TRef extends FusionModulesInstance = FusionModulesInstance, TEnv extends AppEnv = AppEnv> extends ModulesConfigurator<AppModules<TModules>, TRef> implements IAppConfigurator<TModules, TRef> { | ||
readonly env: TEnv; | ||
constructor(env: TEnv); | ||
configureHttp(...args: Parameters<typeof configureHttp>): void; | ||
@@ -20,3 +27,6 @@ configureHttpClient(...args: Parameters<typeof configureHttpClient>): void; | ||
configureMsal(...args: Parameters<typeof configureMsal>): void; | ||
useFeatureFlags(flags_cb?: Array<IFeatureFlag<unknown> & { | ||
allowUrl?: boolean | undefined; | ||
}> | FeatureFlagBuilderCallback): void; | ||
} | ||
export default AppConfigurator; |
@@ -1,1 +0,1 @@ | ||
export declare const version = "7.1.15"; | ||
export declare const version = "8.0.0"; |
{ | ||
"name": "@equinor/fusion-framework-app", | ||
"version": "7.1.15", | ||
"version": "8.0.0", | ||
"description": "", | ||
@@ -31,12 +31,21 @@ "main": "dist/esm/index.js", | ||
"dependencies": { | ||
"@equinor/fusion-framework-module": "^4.2.6", | ||
"@equinor/fusion-framework": "^7.0.28", | ||
"@equinor/fusion-framework-module": "^4.2.6", | ||
"@equinor/fusion-framework-module-app": "^5.2.12", | ||
"@equinor/fusion-framework-module-http": "^5.1.5", | ||
"@equinor/fusion-framework-module-msal": "^3.0.9", | ||
"@equinor/fusion-framework-module-event": "^4.0.7" | ||
"@equinor/fusion-framework-module-event": "^4.0.7", | ||
"@equinor/fusion-framework-module-app": "^5.2.12" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^5.1.3" | ||
"typescript": "^5.1.3", | ||
"@equinor/fusion-framework-module-feature-flag": "^1.0.0" | ||
}, | ||
"peerDependencies": { | ||
"@equinor/fusion-framework-module-feature-flag": "^1.0.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@equinor/fusion-framework-module-feature-flag": { | ||
"optional": true | ||
} | ||
}, | ||
"scripts": { | ||
@@ -43,0 +52,0 @@ "build": "tsc -b" |
@@ -7,1 +7,33 @@ # @equinor/fusion-framework-app | ||
## Feature Flag | ||
> [!IMPORTANT] | ||
> `@equinor/fusion-framework-module-feature-flag` must be installed to make this module available | ||
### Simple | ||
```ts | ||
export const configure: ModuleInitiator = (appConfigurator, args) => { | ||
/** provide a list of features that should be available in the application */ | ||
appConfigurator.useFeatureFlags([ | ||
{ | ||
key: MyFeatures.MyFlag, | ||
title: 'this is a flag', | ||
}, | ||
{ | ||
key: MyFeatures.MyUrlFlag, | ||
title: 'this feature can be toggled by ?my-url-flag=true', | ||
allowUrl: true, | ||
} | ||
]); | ||
} | ||
``` | ||
### Custom | ||
```ts | ||
export const configure: ModuleInitiator = (appConfigurator, args) => { | ||
appConfigurator.useFeatureFlags(builder => /** see module for building custom config */); | ||
} | ||
``` | ||
[see module](../modules/feature-flag/README.md) for more technical information; | ||
@@ -20,4 +20,14 @@ import { type FusionModulesInstance } from '@equinor/fusion-framework'; | ||
import { AppModules } from './types'; | ||
import { | ||
enableFeatureFlagging, | ||
type IFeatureFlag, | ||
type FeatureFlagBuilderCallback, | ||
} from '@equinor/fusion-framework-module-feature-flag'; | ||
import { | ||
createLocalStoragePlugin, | ||
createUrlPlugin, | ||
} from '@equinor/fusion-framework-module-feature-flag/plugins'; | ||
import { AppEnv, AppModules } from './types'; | ||
/** | ||
@@ -81,2 +91,23 @@ * Configurator for configuring application modules | ||
useFrameworkServiceClient(serviceName: string): void; | ||
/** | ||
* enable feature flagging with predefined flags | ||
* @param flags array of flags | ||
* @remarks | ||
* this will store defined flags in local storage | ||
*/ | ||
useFeatureFlags(flags: Array<IFeatureFlag & { allowUrl?: boolean }>): void; | ||
/** | ||
* enable feature flagging with callback | ||
* @param cb callback for configuring module | ||
*/ | ||
useFeatureFlags(cb: FeatureFlagBuilderCallback): void; | ||
/** | ||
* enable feature flags | ||
* @remarks | ||
* this function does nothing atm since api is not implemented yet | ||
*/ | ||
useFeatureFlags(): void; | ||
} | ||
@@ -87,2 +118,3 @@ | ||
TRef extends FusionModulesInstance = FusionModulesInstance, | ||
TEnv extends AppEnv = AppEnv, | ||
> | ||
@@ -92,3 +124,3 @@ extends ModulesConfigurator<AppModules<TModules>, TRef> | ||
{ | ||
constructor() { | ||
constructor(public readonly env: TEnv) { | ||
super([event, http, auth]); | ||
@@ -130,4 +162,36 @@ this.logger = new ModuleConsoleLogger('AppConfigurator'); | ||
} | ||
useFeatureFlags( | ||
flags_cb?: | ||
| Array<IFeatureFlag<unknown> & { allowUrl?: boolean | undefined }> | ||
| FeatureFlagBuilderCallback, | ||
): void { | ||
switch (typeof flags_cb) { | ||
case 'function': { | ||
enableFeatureFlagging(this, flags_cb); | ||
break; | ||
} | ||
case 'object': { | ||
const urlFlags: IFeatureFlag[] = []; | ||
const localFlags = (flags_cb ?? []).map((flag) => { | ||
const { allowUrl, ...localFlag } = flag; | ||
if (allowUrl) { | ||
urlFlags.push(flag); | ||
} | ||
return localFlag; | ||
}); | ||
enableFeatureFlagging(this, async (builder) => { | ||
builder.addPlugin( | ||
createLocalStoragePlugin(localFlags, { | ||
name: this.env.manifest.key, | ||
}), | ||
); | ||
builder.addPlugin(createUrlPlugin(urlFlags)); | ||
}); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
export default AppConfigurator; |
@@ -42,3 +42,3 @@ import { Fusion } from '@equinor/fusion-framework'; | ||
async (args: { fusion: TRef; env: TEnv }): Promise<AppModulesInstance<TModules>> => { | ||
const configurator = new AppConfigurator<TModules, TRef['modules']>(); | ||
const configurator = new AppConfigurator<TModules, TRef['modules'], TEnv>(args.env); | ||
if (cb) { | ||
@@ -45,0 +45,0 @@ await Promise.resolve(cb(configurator, args)); |
// Generated by genversion. | ||
export const version = '7.1.15'; | ||
export const version = '8.0.0'; |
@@ -26,2 +26,5 @@ { | ||
{ | ||
"path": "../modules/feature-flag" | ||
}, | ||
{ | ||
"path": "../framework" | ||
@@ -28,0 +31,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
220654
503
39
7
2