@webiny/feature-flags 0.0.0-unstable.e0bfc55d5a β†’ 0.0.0-unstable.e2758ee1cf

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.
@@ -0,0 +1,16 @@
1
+ import type { IFeatureFlagsDto } from "./types.js";
2
+ export declare class FeatureFlags {
3
+ private readonly flags;
4
+ static fromDto(dto: IFeatureFlagsDto): FeatureFlags;
5
+ constructor(flags?: IFeatureFlagsDto);
6
+ toDto(): IFeatureFlagsDto;
7
+ isMultiTenancyEnabled(): boolean;
8
+ isWorkflowsEnabled(): boolean;
9
+ isAaclEnabled(): boolean;
10
+ isTeamsEnabled(): boolean;
11
+ isPrivateFilesEnabled(): boolean;
12
+ isFolderLevelPermissionsEnabled(): boolean;
13
+ isAuditLogsEnabled(): boolean;
14
+ isRecordLockingEnabled(): boolean;
15
+ isFileManagerThreatDetectionEnabled(): boolean;
16
+ }
@@ -0,0 +1,58 @@
1
+ export class FeatureFlags {
2
+ static fromDto(dto) {
3
+ return new FeatureFlags(dto);
4
+ }
5
+ constructor(flags = {}) {
6
+ this.flags = flags;
7
+ }
8
+ toDto() {
9
+ return structuredClone(this.flags);
10
+ }
11
+ isMultiTenancyEnabled() {
12
+ return this.flags.multiTenancy !== false;
13
+ }
14
+ isWorkflowsEnabled() {
15
+ return this.flags.advancedPublishingWorkflow !== false;
16
+ }
17
+ isAaclEnabled() {
18
+ return this.flags.advancedAccessControlLayer !== false;
19
+ }
20
+ isTeamsEnabled() {
21
+ if (this.flags.advancedAccessControlLayer === false) {
22
+ return false;
23
+ }
24
+ if (typeof this.flags.advancedAccessControlLayer === "object") {
25
+ return this.flags.advancedAccessControlLayer.teams !== false;
26
+ }
27
+ return true;
28
+ }
29
+ isPrivateFilesEnabled() {
30
+ if (this.flags.advancedAccessControlLayer === false) {
31
+ return false;
32
+ }
33
+ if (typeof this.flags.advancedAccessControlLayer === "object") {
34
+ return this.flags.advancedAccessControlLayer.privateFiles !== false;
35
+ }
36
+ return true;
37
+ }
38
+ isFolderLevelPermissionsEnabled() {
39
+ if (this.flags.advancedAccessControlLayer === false) {
40
+ return false;
41
+ }
42
+ if (typeof this.flags.advancedAccessControlLayer === "object") {
43
+ return this.flags.advancedAccessControlLayer.folderLevelPermissions !== false;
44
+ }
45
+ return true;
46
+ }
47
+ isAuditLogsEnabled() {
48
+ return this.flags.auditLogs !== false;
49
+ }
50
+ isRecordLockingEnabled() {
51
+ return this.flags.recordLocking !== false;
52
+ }
53
+ isFileManagerThreatDetectionEnabled() {
54
+ return this.flags.fileManager?.threatDetection !== false;
55
+ }
56
+ }
57
+
58
+ //# sourceMappingURL=FeatureFlags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["FeatureFlags","fromDto","dto","constructor","flags","toDto","structuredClone","isMultiTenancyEnabled","multiTenancy","isWorkflowsEnabled","advancedPublishingWorkflow","isAaclEnabled","advancedAccessControlLayer","isTeamsEnabled","teams","isPrivateFilesEnabled","privateFiles","isFolderLevelPermissionsEnabled","folderLevelPermissions","isAuditLogsEnabled","auditLogs","isRecordLockingEnabled","recordLocking","isFileManagerThreatDetectionEnabled","fileManager","threatDetection"],"sources":["FeatureFlags.ts"],"sourcesContent":["import type { IFeatureFlagsDto } from \"./types.js\";\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 toDto(): IFeatureFlagsDto {\n return structuredClone(this.flags);\n }\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 return this.flags.fileManager?.threatDetection !== false;\n }\n}\n"],"mappings":"AAEA,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,KAAKA,CAAA,EAAqB;IACtB,OAAOC,eAAe,CAAC,IAAI,CAACF,KAAK,CAAC;EACtC;EAEAG,qBAAqBA,CAAA,EAAY;IAC7B,OAAO,IAAI,CAACH,KAAK,CAACI,YAAY,KAAK,KAAK;EAC5C;EAEAC,kBAAkBA,CAAA,EAAY;IAC1B,OAAO,IAAI,CAACL,KAAK,CAACM,0BAA0B,KAAK,KAAK;EAC1D;EAEAC,aAAaA,CAAA,EAAY;IACrB,OAAO,IAAI,CAACP,KAAK,CAACQ,0BAA0B,KAAK,KAAK;EAC1D;EAEAC,cAAcA,CAAA,EAAY;IACtB,IAAI,IAAI,CAACT,KAAK,CAACQ,0BAA0B,KAAK,KAAK,EAAE;MACjD,OAAO,KAAK;IAChB;IACA,IAAI,OAAO,IAAI,CAACR,KAAK,CAACQ,0BAA0B,KAAK,QAAQ,EAAE;MAC3D,OAAO,IAAI,CAACR,KAAK,CAACQ,0BAA0B,CAACE,KAAK,KAAK,KAAK;IAChE;IACA,OAAO,IAAI;EACf;EAEAC,qBAAqBA,CAAA,EAAY;IAC7B,IAAI,IAAI,CAACX,KAAK,CAACQ,0BAA0B,KAAK,KAAK,EAAE;MACjD,OAAO,KAAK;IAChB;IACA,IAAI,OAAO,IAAI,CAACR,KAAK,CAACQ,0BAA0B,KAAK,QAAQ,EAAE;MAC3D,OAAO,IAAI,CAACR,KAAK,CAACQ,0BAA0B,CAACI,YAAY,KAAK,KAAK;IACvE;IACA,OAAO,IAAI;EACf;EAEAC,+BAA+BA,CAAA,EAAY;IACvC,IAAI,IAAI,CAACb,KAAK,CAACQ,0BAA0B,KAAK,KAAK,EAAE;MACjD,OAAO,KAAK;IAChB;IACA,IAAI,OAAO,IAAI,CAACR,KAAK,CAACQ,0BAA0B,KAAK,QAAQ,EAAE;MAC3D,OAAO,IAAI,CAACR,KAAK,CAACQ,0BAA0B,CAACM,sBAAsB,KAAK,KAAK;IACjF;IACA,OAAO,IAAI;EACf;EAEAC,kBAAkBA,CAAA,EAAY;IAC1B,OAAO,IAAI,CAACf,KAAK,CAACgB,SAAS,KAAK,KAAK;EACzC;EAEAC,sBAAsBA,CAAA,EAAY;IAC9B,OAAO,IAAI,CAACjB,KAAK,CAACkB,aAAa,KAAK,KAAK;EAC7C;EAEAC,mCAAmCA,CAAA,EAAY;IAC3C,OAAO,IAAI,CAACnB,KAAK,CAACoB,WAAW,EAAEC,eAAe,KAAK,KAAK;EAC5D;AACJ","ignoreList":[]}
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,8 +1,2 @@
1
- export type FeatureFlags<TFeatureFlags = Record<string, any>> = {
2
- allowCmsLegacyRichTextInput?: boolean;
3
- cmsLegacyEntryEditor?: boolean;
4
- experimentalDynamicPages?: boolean;
5
- newWatchCommand?: boolean;
6
- } & TFeatureFlags;
7
- declare let featureFlags: FeatureFlags;
8
- export { featureFlags };
1
+ export * from "./types.js";
2
+ export * from "./FeatureFlags.js";
package/index.js CHANGED
@@ -1,18 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.featureFlags = void 0;
7
- let featureFlags = exports.featureFlags = {};
8
-
9
- // In API applications.
10
- if (process.env.WEBINY_FEATURE_FLAGS) {
11
- exports.featureFlags = featureFlags = JSON.parse(process.env.WEBINY_FEATURE_FLAGS);
12
-
13
- // In React applications.
14
- } else if (process.env.REACT_APP_WEBINY_FEATURE_FLAGS) {
15
- exports.featureFlags = featureFlags = JSON.parse(process.env.REACT_APP_WEBINY_FEATURE_FLAGS);
16
- }
1
+ export * from "./types.js";
2
+ export * from "./FeatureFlags.js";
17
3
 
18
4
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["featureFlags","exports","process","env","WEBINY_FEATURE_FLAGS","JSON","parse","REACT_APP_WEBINY_FEATURE_FLAGS"],"sources":["index.ts"],"sourcesContent":["export type FeatureFlags<TFeatureFlags = Record<string, any>> = {\n allowCmsLegacyRichTextInput?: boolean;\n cmsLegacyEntryEditor?: boolean;\n experimentalDynamicPages?: boolean;\n newWatchCommand?: boolean;\n} & TFeatureFlags;\n\nlet featureFlags: FeatureFlags = {};\n\n// In API applications.\nif (process.env.WEBINY_FEATURE_FLAGS) {\n featureFlags = JSON.parse(process.env.WEBINY_FEATURE_FLAGS) as FeatureFlags;\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) as FeatureFlags;\n}\n\nexport { featureFlags };\n"],"mappings":";;;;;;AAOA,IAAIA,YAA0B,GAAAC,OAAA,CAAAD,YAAA,GAAG,CAAC,CAAC;;AAEnC;AACA,IAAIE,OAAO,CAACC,GAAG,CAACC,oBAAoB,EAAE;EAClCH,OAAA,CAAAD,YAAA,GAAAA,YAAY,GAAGK,IAAI,CAACC,KAAK,CAACJ,OAAO,CAACC,GAAG,CAACC,oBAAoB,CAAiB;;EAE3E;AACJ,CAAC,MAAM,IAAIF,OAAO,CAACC,GAAG,CAACI,8BAA8B,EAAE;EACnDN,OAAA,CAAAD,YAAA,GAAAA,YAAY,GAAGK,IAAI,CAACC,KAAK,CAACJ,OAAO,CAACC,GAAG,CAACI,8BAA8B,CAAiB;AACzF","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./types.js\";\nexport * from \"./FeatureFlags.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@webiny/feature-flags",
3
- "version": "0.0.0-unstable.e0bfc55d5a",
3
+ "version": "0.0.0-unstable.e2758ee1cf",
4
+ "type": "module",
4
5
  "main": "index.js",
5
6
  "repository": {
6
7
  "type": "git",
@@ -12,18 +13,14 @@
12
13
  ],
13
14
  "license": "MIT",
14
15
  "devDependencies": {
15
- "@types/uniqid": "5.3.2",
16
- "@webiny/project-utils": "0.0.0-unstable.e0bfc55d5a",
17
- "rimraf": "6.0.1",
18
- "typescript": "5.3.3"
16
+ "@types/uniqid": "5.3.4",
17
+ "@webiny/build-tools": "0.0.0-unstable.e2758ee1cf",
18
+ "rimraf": "6.1.3",
19
+ "typescript": "5.9.3"
19
20
  },
20
21
  "publishConfig": {
21
22
  "access": "public",
22
23
  "directory": "dist"
23
24
  },
24
- "scripts": {
25
- "build": "node ../cli/bin.js run build",
26
- "watch": "node ../cli/bin.js run watch"
27
- },
28
- "gitHead": "e0bfc55d5a4d6a42b32e6558d9fb2eb6753e331b"
25
+ "gitHead": "e2758ee1cfa3b9a7152e9bb995a90ccabd33266f"
29
26
  }
package/types.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ export interface IAaclFeatureFlags {
2
+ teams?: boolean;
3
+ privateFiles?: boolean;
4
+ folderLevelPermissions?: boolean;
5
+ hcmsFieldPermissions?: boolean;
6
+ }
7
+ export interface IFileManagerFeatureFlags {
8
+ threatDetection?: boolean;
9
+ }
10
+ /**
11
+ * Top-level feature flags interface. Add new flags here as needed.
12
+ * A boolean value controls whether the feature is enabled.
13
+ * An object value means the feature is enabled, but with specific sub-options.
14
+ * Keep this file free of @webiny/* package imports.
15
+ */
16
+ export interface IFeatureFlagsDto {
17
+ multiTenancy?: boolean;
18
+ advancedPublishingWorkflow?: boolean;
19
+ advancedAccessControlLayer?: boolean | IAaclFeatureFlags;
20
+ auditLogs?: boolean;
21
+ recordLocking?: boolean;
22
+ fileManager?: IFileManagerFeatureFlags;
23
+ }
package/types.js ADDED
@@ -0,0 +1,3 @@
1
+ export {};
2
+
3
+ //# sourceMappingURL=types.js.map
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export interface IAaclFeatureFlags {\n teams?: boolean;\n privateFiles?: boolean;\n folderLevelPermissions?: boolean;\n hcmsFieldPermissions?: 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?: IFileManagerFeatureFlags;\n}\n"],"mappings":"","ignoreList":[]}