@webiny/feature-flags 0.0.0-unstable.d7f521b032 β†’ 0.0.0-unstable.dbdf5d6258

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/README.md CHANGED
@@ -1,97 +1,11 @@
1
- # `@webiny/feature-flags`
2
- [![](https://img.shields.io/npm/dw/@webiny/feature-flags.svg)](https://www.npmjs.com/package/@webiny/feature-flags)
3
- [![](https://img.shields.io/npm/v/@webiny/feature-flags.svg)](https://www.npmjs.com/package/@webiny/feature-flags)
4
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
5
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
1
+ # @webiny/feature-flags
6
2
 
7
- A small library that provides a simple way to define and read feature flags in a Webiny project.
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
8
6
 
9
- ## Table of Contents
7
+ πŸ“˜ **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
10
8
 
11
- - [Installation](#installation)
12
- - [Overview](#overview)
13
- - [Examples](#examples)
14
- - [Reference](#reference)
15
- - [Objects](#objects)
16
- - [`featureFlags`](#featureFlags)
9
+ ---
17
10
 
18
- ## Installation
19
-
20
- ```
21
- npm install --save @webiny/feature-flags
22
- ```
23
-
24
- Or if you prefer yarn:
25
-
26
- ```
27
- yarn add @webiny/feature-flags
28
- ```
29
-
30
-
31
- ## Overview
32
-
33
- The `@webiny/feature-flags` exports a single `featureFlags` object which contains all of the feature flags initially set via the Webiny project's `webiny.project.ts` config file, via its `featureFlags` property.
34
-
35
- For example, given the following `webiny.project.ts` config file;
36
-
37
- ```ts
38
- // webiny.project.ts
39
- export default {
40
- name: "webiny-js",
41
- cli: {
42
- ...
43
- },
44
-
45
- // Feature flags are defined via a simple JavaScript object.
46
- featureFlags: {
47
- myCustomFeatureFlag: false,
48
- someFeature: { enabled: true, myCustomProperty: 123, thisIsJson: "yes"}
49
- }
50
- };
51
- ```
52
-
53
- Within both backend and frontend application code, the `featureFlags` object can then be read like so:
54
-
55
- ```ts
56
- import { featureFlags } from "@webiny/feature-flags";
57
-
58
- const useMyCustomFeature = featureFlags.myCustomFeatureFlag;
59
-
60
- const someOtherFeatureMyCustomProperty = featureFlags.someFeature.myCustomProperty;
61
- ```
62
-
63
- > **NOTE**
64
- >
65
- > Behind the scenes, it's the [Webiny CLI](https://www.webiny.com/docs/core-development-concepts/basics/webiny-cli) that enables the propagation of the `featureFlags` object into the actual applications. As mentioned, the `featureFlags` object can be accessed within both backend and frontend application code.
66
-
67
- ## Examples
68
-
69
- No additional examples.
70
-
71
- ## Reference
72
-
73
- ### Objects
74
-
75
- #### `featureFlags`
76
-
77
- <details>
78
- <summary>Type Declaration</summary>
79
- <p>
80
-
81
- ```ts
82
- declare let featureFlags: Record<string, any>;
83
- ```
84
-
85
- </p>
86
- </details>
87
-
88
- The `featureFlags` object contains all of the feature flags initially set via the Webiny project's `webiny.project.ts` config file, via its `featureFlags` property.
89
-
90
-
91
- ```ts
92
- import { featureFlags } from "@webiny/feature-flags";
93
-
94
- const useMyCustomFeature = featureFlags.myCustomFeatureFlag;
95
-
96
- const someOtherFeatureMyCustomProperty = featureFlags.someFeature.myCustomProperty;
97
- ```
11
+ _This README file is automatically generated during the publish process._
package/index.d.ts CHANGED
@@ -1,2 +1,36 @@
1
- declare let featureFlags: Record<string, any>;
2
- export { featureFlags };
1
+ export interface IAaclFeatureFlags {
2
+ teams?: boolean;
3
+ privateFiles?: boolean;
4
+ folderLevelPermissions?: boolean;
5
+ }
6
+ export interface IFileManagerFeatureFlags {
7
+ threatDetection?: boolean;
8
+ }
9
+ /**
10
+ * Top-level feature flags interface. Add new flags here as needed.
11
+ * A boolean value controls whether the feature is enabled.
12
+ * An object value means the feature is enabled, but with specific sub-options.
13
+ * Keep this file free of @webiny/* package imports.
14
+ */
15
+ export interface IFeatureFlagsDto {
16
+ multiTenancy?: boolean;
17
+ advancedPublishingWorkflow?: boolean;
18
+ advancedAccessControlLayer?: boolean | IAaclFeatureFlags;
19
+ auditLogs?: boolean;
20
+ recordLocking?: boolean;
21
+ fileManager?: boolean | IFileManagerFeatureFlags;
22
+ }
23
+ export declare class FeatureFlags {
24
+ private readonly flags;
25
+ static fromDto(dto: IFeatureFlagsDto): FeatureFlags;
26
+ constructor(flags?: IFeatureFlagsDto);
27
+ isMultiTenancyEnabled(): boolean;
28
+ isWorkflowsEnabled(): boolean;
29
+ isAaclEnabled(): boolean;
30
+ isTeamsEnabled(): boolean;
31
+ isPrivateFilesEnabled(): boolean;
32
+ isFolderLevelPermissionsEnabled(): boolean;
33
+ isAuditLogsEnabled(): boolean;
34
+ isRecordLockingEnabled(): boolean;
35
+ isFileManagerThreatDetectionEnabled(): boolean;
36
+ }
package/index.js CHANGED
@@ -1,15 +1,68 @@
1
- "use strict";
1
+ /**
2
+ * Top-level feature flags interface. Add new flags here as needed.
3
+ * A boolean value controls whether the feature is enabled.
4
+ * An object value means the feature is enabled, but with specific sub-options.
5
+ * Keep this file free of @webiny/* package imports.
6
+ */
2
7
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.featureFlags = void 0;
7
- let featureFlags = {}; // In API applications.
8
+ export class FeatureFlags {
9
+ static fromDto(dto) {
10
+ return new FeatureFlags(dto);
11
+ }
12
+ constructor(flags = {}) {
13
+ this.flags = flags;
14
+ }
15
+ isMultiTenancyEnabled() {
16
+ return this.flags.multiTenancy !== false;
17
+ }
18
+ isWorkflowsEnabled() {
19
+ return this.flags.advancedPublishingWorkflow !== false;
20
+ }
21
+ isAaclEnabled() {
22
+ return this.flags.advancedAccessControlLayer !== false;
23
+ }
24
+ isTeamsEnabled() {
25
+ if (this.flags.advancedAccessControlLayer === false) {
26
+ return false;
27
+ }
28
+ if (typeof this.flags.advancedAccessControlLayer === "object") {
29
+ return this.flags.advancedAccessControlLayer.teams !== false;
30
+ }
31
+ return true;
32
+ }
33
+ isPrivateFilesEnabled() {
34
+ if (this.flags.advancedAccessControlLayer === false) {
35
+ return false;
36
+ }
37
+ if (typeof this.flags.advancedAccessControlLayer === "object") {
38
+ return this.flags.advancedAccessControlLayer.privateFiles !== false;
39
+ }
40
+ return true;
41
+ }
42
+ isFolderLevelPermissionsEnabled() {
43
+ if (this.flags.advancedAccessControlLayer === false) {
44
+ return false;
45
+ }
46
+ if (typeof this.flags.advancedAccessControlLayer === "object") {
47
+ return this.flags.advancedAccessControlLayer.folderLevelPermissions !== false;
48
+ }
49
+ return true;
50
+ }
51
+ isAuditLogsEnabled() {
52
+ return this.flags.auditLogs !== false;
53
+ }
54
+ isRecordLockingEnabled() {
55
+ return this.flags.recordLocking !== false;
56
+ }
57
+ isFileManagerThreatDetectionEnabled() {
58
+ if (this.flags.fileManager === false) {
59
+ return false;
60
+ }
61
+ if (typeof this.flags.fileManager === "object") {
62
+ return this.flags.fileManager.threatDetection !== false;
63
+ }
64
+ return true;
65
+ }
66
+ }
8
67
 
9
- exports.featureFlags = featureFlags;
10
-
11
- if (process.env.WEBINY_FEATURE_FLAGS) {
12
- exports.featureFlags = featureFlags = JSON.parse(process.env.WEBINY_FEATURE_FLAGS); // In React applications.
13
- } else if (process.env.REACT_APP_WEBINY_FEATURE_FLAGS) {
14
- exports.featureFlags = featureFlags = JSON.parse(process.env.REACT_APP_WEBINY_FEATURE_FLAGS);
15
- }
68
+ //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["featureFlags","process","env","WEBINY_FEATURE_FLAGS","JSON","parse","REACT_APP_WEBINY_FEATURE_FLAGS"],"sources":["index.ts"],"sourcesContent":["let featureFlags: Record<string, any> = {};\n\n// In API applications.\nif (process.env.WEBINY_FEATURE_FLAGS) {\n featureFlags = JSON.parse(process.env.WEBINY_FEATURE_FLAGS);\n\n // In React applications.\n} else if (process.env.REACT_APP_WEBINY_FEATURE_FLAGS) {\n featureFlags = JSON.parse(process.env.REACT_APP_WEBINY_FEATURE_FLAGS);\n}\n\nexport { featureFlags };\n"],"mappings":";;;;;;AAAA,IAAIA,YAAiC,GAAG,EAAxC,C,CAEA;;;;AACA,IAAIC,OAAO,CAACC,GAAR,CAAYC,oBAAhB,EAAsC;EAClC,uBAAAH,YAAY,GAAGI,IAAI,CAACC,KAAL,CAAWJ,OAAO,CAACC,GAAR,CAAYC,oBAAvB,CAAf,CADkC,CAGlC;AACH,CAJD,MAIO,IAAIF,OAAO,CAACC,GAAR,CAAYI,8BAAhB,EAAgD;EACnD,uBAAAN,YAAY,GAAGI,IAAI,CAACC,KAAL,CAAWJ,OAAO,CAACC,GAAR,CAAYI,8BAAvB,CAAf;AACH"}
1
+ {"version":3,"names":["FeatureFlags","fromDto","dto","constructor","flags","isMultiTenancyEnabled","multiTenancy","isWorkflowsEnabled","advancedPublishingWorkflow","isAaclEnabled","advancedAccessControlLayer","isTeamsEnabled","teams","isPrivateFilesEnabled","privateFiles","isFolderLevelPermissionsEnabled","folderLevelPermissions","isAuditLogsEnabled","auditLogs","isRecordLockingEnabled","recordLocking","isFileManagerThreatDetectionEnabled","fileManager","threatDetection"],"sources":["index.ts"],"sourcesContent":["export interface IAaclFeatureFlags {\n teams?: boolean;\n privateFiles?: boolean;\n folderLevelPermissions?: boolean;\n}\n\nexport interface IFileManagerFeatureFlags {\n threatDetection?: boolean;\n}\n\n/**\n * Top-level feature flags interface. Add new flags here as needed.\n * A boolean value controls whether the feature is enabled.\n * An object value means the feature is enabled, but with specific sub-options.\n * Keep this file free of @webiny/* package imports.\n */\nexport interface IFeatureFlagsDto {\n multiTenancy?: boolean;\n advancedPublishingWorkflow?: boolean;\n advancedAccessControlLayer?: boolean | IAaclFeatureFlags;\n auditLogs?: boolean;\n recordLocking?: boolean;\n fileManager?: boolean | IFileManagerFeatureFlags;\n}\n\nexport class FeatureFlags {\n static fromDto(dto: IFeatureFlagsDto): FeatureFlags {\n return new FeatureFlags(dto);\n }\n\n constructor(private readonly flags: IFeatureFlagsDto = {}) {}\n\n isMultiTenancyEnabled(): boolean {\n return this.flags.multiTenancy !== false;\n }\n\n isWorkflowsEnabled(): boolean {\n return this.flags.advancedPublishingWorkflow !== false;\n }\n\n isAaclEnabled(): boolean {\n return this.flags.advancedAccessControlLayer !== false;\n }\n\n isTeamsEnabled(): boolean {\n if (this.flags.advancedAccessControlLayer === false) {\n return false;\n }\n if (typeof this.flags.advancedAccessControlLayer === \"object\") {\n return this.flags.advancedAccessControlLayer.teams !== false;\n }\n return true;\n }\n\n isPrivateFilesEnabled(): boolean {\n if (this.flags.advancedAccessControlLayer === false) {\n return false;\n }\n if (typeof this.flags.advancedAccessControlLayer === \"object\") {\n return this.flags.advancedAccessControlLayer.privateFiles !== false;\n }\n return true;\n }\n\n isFolderLevelPermissionsEnabled(): boolean {\n if (this.flags.advancedAccessControlLayer === false) {\n return false;\n }\n if (typeof this.flags.advancedAccessControlLayer === \"object\") {\n return this.flags.advancedAccessControlLayer.folderLevelPermissions !== false;\n }\n return true;\n }\n\n isAuditLogsEnabled(): boolean {\n return this.flags.auditLogs !== false;\n }\n\n isRecordLockingEnabled(): boolean {\n return this.flags.recordLocking !== false;\n }\n\n isFileManagerThreatDetectionEnabled(): boolean {\n if (this.flags.fileManager === false) {\n return false;\n }\n if (typeof this.flags.fileManager === \"object\") {\n return this.flags.fileManager.threatDetection !== false;\n }\n return true;\n }\n}\n"],"mappings":"AAUA;AACA;AACA;AACA;AACA;AACA;;AAUA,OAAO,MAAMA,YAAY,CAAC;EACtB,OAAOC,OAAOA,CAACC,GAAqB,EAAgB;IAChD,OAAO,IAAIF,YAAY,CAACE,GAAG,CAAC;EAChC;EAEAC,WAAWA,CAAkBC,KAAuB,GAAG,CAAC,CAAC,EAAE;IAAA,KAA9BA,KAAuB,GAAvBA,KAAuB;EAAQ;EAE5DC,qBAAqBA,CAAA,EAAY;I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ACf,KAAK,CAACgB,aAAa,KAAK,KAAK;EAC7C;EAEAC,mCAAmCA,CAAA,EAAY;IAC3C,IAAI,IAAI,CAACjB,KAAK,CAACkB,WAAW,KAAK,KAAK,EAAE;MAClC,OAAO,KAAK;IAChB;IACA,IAAI,OAAO,IAAI,CAAClB,KAAK,CAACkB,WAAW,KAAK,QAAQ,EAAE;MAC5C,OAAO,IAAI,CAAClB,KAAK,CAACkB,WAAW,CAACC,eAAe,KAAK,KAAK;IAC3D;IACA,OAAO,IAAI;EACf;AACJ","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@webiny/feature-flags",
3
- "version": "0.0.0-unstable.d7f521b032",
3
+ "version": "0.0.0-unstable.dbdf5d6258",
4
+ "type": "module",
4
5
  "main": "index.js",
5
6
  "repository": {
6
7
  "type": "git",
@@ -11,26 +12,15 @@
11
12
  "Adrian Smijulj <adrian@webiny.com>"
12
13
  ],
13
14
  "license": "MIT",
14
- "dependencies": {
15
- "@babel/runtime": "7.20.13"
16
- },
17
15
  "devDependencies": {
18
- "@babel/cli": "^7.19.3",
19
- "@babel/core": "^7.19.3",
20
- "@types/uniqid": "^5.3.2",
21
- "@webiny/cli": "^0.0.0-unstable.d7f521b032",
22
- "@webiny/project-utils": "^0.0.0-unstable.d7f521b032",
23
- "rimraf": "^3.0.2",
24
- "ttypescript": "^1.5.13",
25
- "typescript": "4.7.4"
16
+ "@types/uniqid": "5.3.4",
17
+ "@webiny/build-tools": "0.0.0-unstable.dbdf5d6258",
18
+ "rimraf": "6.1.3",
19
+ "typescript": "5.9.3"
26
20
  },
27
21
  "publishConfig": {
28
22
  "access": "public",
29
23
  "directory": "dist"
30
24
  },
31
- "scripts": {
32
- "build": "yarn webiny run build",
33
- "watch": "yarn webiny run watch"
34
- },
35
- "gitHead": "d7f521b0325964664dbeb6d2d07e2b6518e53841"
25
+ "gitHead": "dbdf5d62587b971d52125a69ad6e69bae9ce8ee7"
36
26
  }