@smooai/config 3.0.0 → 3.1.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/browser/chunk-YMNAMX6Y.mjs +55 -0
- package/dist/browser/chunk-YMNAMX6Y.mjs.map +1 -0
- package/dist/browser/client/index.mjs +14 -0
- package/dist/browser/client/index.mjs.map +1 -0
- package/dist/browser/feature-flags/index.mjs +4 -24
- package/dist/browser/feature-flags/index.mjs.map +1 -1
- package/dist/{chunk-2DYBQ6SF.mjs → chunk-43SVVFYE.mjs} +3 -3
- package/dist/{chunk-PCXGCPWC.mjs → chunk-6XDO5B2T.mjs} +8 -8
- package/dist/{chunk-7CCXEKIK.mjs → chunk-H4YT7JJJ.mjs} +4 -4
- package/dist/{chunk-JAEJOSH5.mjs → chunk-NF7JF2UP.mjs} +2 -2
- package/dist/{chunk-7GMXNAVA.mjs → chunk-PD2SHA7M.mjs} +11 -11
- package/dist/{chunk-2CD4ZQFH.mjs → chunk-R7NMFJFJ.mjs} +2 -2
- package/dist/chunk-SAX775JO.mjs +40 -0
- package/dist/chunk-SAX775JO.mjs.map +1 -0
- package/dist/chunk-UCFP2MA2.mjs +55 -0
- package/dist/chunk-UCFP2MA2.mjs.map +1 -0
- package/dist/{chunk-4RYDS2HX.mjs → chunk-UEIVAJKL.mjs} +2 -2
- package/dist/client/index.d.mts +66 -0
- package/dist/client/index.d.ts +66 -0
- package/dist/client/index.js +82 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/index.mjs +14 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/config/config.mjs +2 -2
- package/dist/config/findAndProcessEnvConfig.mjs +5 -5
- package/dist/config/findAndProcessFileConfig.mjs +6 -6
- package/dist/config/index.mjs +6 -6
- package/dist/config/parseConfigSchema.mjs +3 -3
- package/dist/config/server.mjs +9 -9
- package/dist/feature-flags/index.d.mts +1 -59
- package/dist/feature-flags/index.d.ts +1 -59
- package/dist/feature-flags/index.js +9 -3
- package/dist/feature-flags/index.js.map +1 -1
- package/dist/feature-flags/index.mjs +4 -24
- package/dist/feature-flags/index.mjs.map +1 -1
- package/dist/integration-tests/1/smooai-config/config.mjs +3 -3
- package/dist/integration-tests/1/smooai-config/default.mjs +3 -3
- package/dist/integration-tests/1/smooai-config/development.mjs +3 -3
- package/dist/integration-tests/1/smooai-config/production.aws.mjs +3 -3
- package/dist/integration-tests/1/smooai-config/production.aws.us-east-1.mjs +3 -3
- package/dist/integration-tests/1/smooai-config/production.aws.us-east-2.mjs +3 -3
- package/dist/integration-tests/1/smooai-config/production.mjs +3 -3
- package/dist/integration-tests/1/smooai-config/staging.mjs +3 -3
- package/dist/integration-tests/2/smooai-config/config.mjs +3 -3
- package/dist/integration-tests/2/smooai-config/default.mjs +3 -3
- package/dist/integration-tests/2/smooai-config/development.mjs +3 -3
- package/dist/integration-tests/2/smooai-config/production.aws.mjs +3 -3
- package/dist/integration-tests/2/smooai-config/production.aws.us-east-1.mjs +3 -3
- package/dist/integration-tests/2/smooai-config/production.mjs +3 -3
- package/dist/nextjs/index.mjs +3 -3
- package/dist/nextjs/withFeatureFlags.d.mts +41 -0
- package/dist/nextjs/withFeatureFlags.d.ts +41 -0
- package/dist/nextjs/withFeatureFlags.js +79 -0
- package/dist/nextjs/withFeatureFlags.js.map +1 -0
- package/dist/nextjs/withFeatureFlags.mjs +20 -0
- package/dist/nextjs/withFeatureFlags.mjs.map +1 -0
- package/dist/nextjs/withSmooConfig.d.mts +63 -0
- package/dist/nextjs/withSmooConfig.d.ts +63 -0
- package/dist/nextjs/withSmooConfig.js +64 -0
- package/dist/nextjs/withSmooConfig.js.map +1 -0
- package/dist/nextjs/withSmooConfig.mjs +8 -0
- package/dist/nextjs/withSmooConfig.mjs.map +1 -0
- package/dist/platform/server/server.async.mjs +8 -8
- package/dist/platform/server/server.featureFlag.sync.mjs +8 -8
- package/dist/platform/server/server.publicConfig.sync.mjs +8 -8
- package/dist/platform/server/server.secretConfig.sync.mjs +8 -8
- package/dist/platform/server.mjs +8 -8
- package/dist/vite/smooConfigPlugin.d.mts +47 -0
- package/dist/vite/smooConfigPlugin.d.ts +47 -0
- package/dist/vite/smooConfigPlugin.js +60 -0
- package/dist/vite/smooConfigPlugin.js.map +1 -0
- package/dist/vite/smooConfigPlugin.mjs +37 -0
- package/dist/vite/smooConfigPlugin.mjs.map +1 -0
- package/package.json +25 -1
- /package/dist/{chunk-2DYBQ6SF.mjs.map → chunk-43SVVFYE.mjs.map} +0 -0
- /package/dist/{chunk-PCXGCPWC.mjs.map → chunk-6XDO5B2T.mjs.map} +0 -0
- /package/dist/{chunk-7CCXEKIK.mjs.map → chunk-H4YT7JJJ.mjs.map} +0 -0
- /package/dist/{chunk-JAEJOSH5.mjs.map → chunk-NF7JF2UP.mjs.map} +0 -0
- /package/dist/{chunk-7GMXNAVA.mjs.map → chunk-PD2SHA7M.mjs.map} +0 -0
- /package/dist/{chunk-2CD4ZQFH.mjs.map → chunk-R7NMFJFJ.mjs.map} +0 -0
- /package/dist/{chunk-4RYDS2HX.mjs.map → chunk-UEIVAJKL.mjs.map} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createFeatureFlagChecker,
|
|
3
|
+
getClientFeatureFlag,
|
|
4
|
+
getClientPublicConfig,
|
|
5
|
+
toUpperSnakeCase
|
|
6
|
+
} from "../chunk-UCFP2MA2.mjs";
|
|
7
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
8
|
+
export {
|
|
9
|
+
createFeatureFlagChecker,
|
|
10
|
+
getClientFeatureFlag,
|
|
11
|
+
getClientPublicConfig,
|
|
12
|
+
toUpperSnakeCase
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/config/config.mjs
CHANGED
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
deserializeConfigSchema,
|
|
7
7
|
generateConfigSchema,
|
|
8
8
|
serializeConfigSchema
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-H4YT7JJJ.mjs";
|
|
10
10
|
import "../chunk-LPEA3TRJ.mjs";
|
|
11
|
-
import "../chunk-CASNDTCH.mjs";
|
|
12
11
|
import "../chunk-UWV4ZGVI.mjs";
|
|
12
|
+
import "../chunk-CASNDTCH.mjs";
|
|
13
13
|
import "../chunk-J5LGTIGS.mjs";
|
|
14
14
|
export {
|
|
15
15
|
BooleanSchema,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
findAndProcessEnvConfig
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-JAEJOSH5.mjs";
|
|
5
|
-
import "../chunk-7CCXEKIK.mjs";
|
|
6
|
-
import "../chunk-LPEA3TRJ.mjs";
|
|
7
|
-
import "../chunk-CASNDTCH.mjs";
|
|
3
|
+
} from "../chunk-6XDO5B2T.mjs";
|
|
8
4
|
import "../chunk-5J6U77AV.mjs";
|
|
5
|
+
import "../chunk-NF7JF2UP.mjs";
|
|
6
|
+
import "../chunk-H4YT7JJJ.mjs";
|
|
7
|
+
import "../chunk-LPEA3TRJ.mjs";
|
|
9
8
|
import "../chunk-UWV4ZGVI.mjs";
|
|
9
|
+
import "../chunk-CASNDTCH.mjs";
|
|
10
10
|
import "../chunk-J5LGTIGS.mjs";
|
|
11
11
|
export {
|
|
12
12
|
findAndProcessEnvConfig
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
findAndProcessFileConfig,
|
|
3
3
|
findConfigDirectory
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-VLAIJ4S7.mjs";
|
|
4
|
+
} from "../chunk-PD2SHA7M.mjs";
|
|
6
5
|
import "../chunk-XKVOJHYW.mjs";
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-7CCXEKIK.mjs";
|
|
9
|
-
import "../chunk-LPEA3TRJ.mjs";
|
|
10
|
-
import "../chunk-CASNDTCH.mjs";
|
|
6
|
+
import "../chunk-VLAIJ4S7.mjs";
|
|
11
7
|
import "../chunk-5J6U77AV.mjs";
|
|
8
|
+
import "../chunk-NF7JF2UP.mjs";
|
|
9
|
+
import "../chunk-H4YT7JJJ.mjs";
|
|
10
|
+
import "../chunk-LPEA3TRJ.mjs";
|
|
12
11
|
import "../chunk-UWV4ZGVI.mjs";
|
|
12
|
+
import "../chunk-CASNDTCH.mjs";
|
|
13
13
|
import "../chunk-J5LGTIGS.mjs";
|
|
14
14
|
export {
|
|
15
15
|
findAndProcessFileConfig,
|
package/dist/config/index.mjs
CHANGED
|
@@ -4,11 +4,14 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
SecretConfigKey
|
|
6
6
|
} from "../chunk-TK4SSJRD.mjs";
|
|
7
|
+
import {
|
|
8
|
+
getCloudRegion
|
|
9
|
+
} from "../chunk-5J6U77AV.mjs";
|
|
7
10
|
import {
|
|
8
11
|
generateZodSchemas,
|
|
9
12
|
parseConfig,
|
|
10
13
|
parseConfigKey
|
|
11
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-NF7JF2UP.mjs";
|
|
12
15
|
import {
|
|
13
16
|
BooleanSchema,
|
|
14
17
|
NumberSchema,
|
|
@@ -17,15 +20,12 @@ import {
|
|
|
17
20
|
deserializeConfigSchema,
|
|
18
21
|
generateConfigSchema,
|
|
19
22
|
serializeConfigSchema
|
|
20
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-H4YT7JJJ.mjs";
|
|
21
24
|
import "../chunk-LPEA3TRJ.mjs";
|
|
25
|
+
import "../chunk-UWV4ZGVI.mjs";
|
|
22
26
|
import {
|
|
23
27
|
PublicConfigKey
|
|
24
28
|
} from "../chunk-CASNDTCH.mjs";
|
|
25
|
-
import {
|
|
26
|
-
getCloudRegion
|
|
27
|
-
} from "../chunk-5J6U77AV.mjs";
|
|
28
|
-
import "../chunk-UWV4ZGVI.mjs";
|
|
29
29
|
import "../chunk-J5LGTIGS.mjs";
|
|
30
30
|
export {
|
|
31
31
|
BooleanSchema,
|
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
generateZodSchemas,
|
|
3
3
|
parseConfig,
|
|
4
4
|
parseConfigKey
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-NF7JF2UP.mjs";
|
|
6
|
+
import "../chunk-H4YT7JJJ.mjs";
|
|
7
7
|
import "../chunk-LPEA3TRJ.mjs";
|
|
8
|
-
import "../chunk-CASNDTCH.mjs";
|
|
9
8
|
import "../chunk-UWV4ZGVI.mjs";
|
|
9
|
+
import "../chunk-CASNDTCH.mjs";
|
|
10
10
|
import "../chunk-J5LGTIGS.mjs";
|
|
11
11
|
export {
|
|
12
12
|
generateZodSchemas,
|
package/dist/config/server.mjs
CHANGED
|
@@ -6,18 +6,21 @@ import {
|
|
|
6
6
|
} from "../chunk-TK4SSJRD.mjs";
|
|
7
7
|
import {
|
|
8
8
|
findAndProcessEnvConfig
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-6XDO5B2T.mjs";
|
|
10
10
|
import {
|
|
11
11
|
findAndProcessFileConfig,
|
|
12
12
|
findConfigDirectory
|
|
13
|
-
} from "../chunk-
|
|
14
|
-
import "../chunk-VLAIJ4S7.mjs";
|
|
13
|
+
} from "../chunk-PD2SHA7M.mjs";
|
|
15
14
|
import "../chunk-XKVOJHYW.mjs";
|
|
15
|
+
import "../chunk-VLAIJ4S7.mjs";
|
|
16
|
+
import {
|
|
17
|
+
getCloudRegion
|
|
18
|
+
} from "../chunk-5J6U77AV.mjs";
|
|
16
19
|
import {
|
|
17
20
|
generateZodSchemas,
|
|
18
21
|
parseConfig,
|
|
19
22
|
parseConfigKey
|
|
20
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-NF7JF2UP.mjs";
|
|
21
24
|
import {
|
|
22
25
|
BooleanSchema,
|
|
23
26
|
NumberSchema,
|
|
@@ -26,15 +29,12 @@ import {
|
|
|
26
29
|
deserializeConfigSchema,
|
|
27
30
|
generateConfigSchema,
|
|
28
31
|
serializeConfigSchema
|
|
29
|
-
} from "../chunk-
|
|
32
|
+
} from "../chunk-H4YT7JJJ.mjs";
|
|
30
33
|
import "../chunk-LPEA3TRJ.mjs";
|
|
34
|
+
import "../chunk-UWV4ZGVI.mjs";
|
|
31
35
|
import {
|
|
32
36
|
PublicConfigKey
|
|
33
37
|
} from "../chunk-CASNDTCH.mjs";
|
|
34
|
-
import {
|
|
35
|
-
getCloudRegion
|
|
36
|
-
} from "../chunk-5J6U77AV.mjs";
|
|
37
|
-
import "../chunk-UWV4ZGVI.mjs";
|
|
38
38
|
import "../chunk-J5LGTIGS.mjs";
|
|
39
39
|
export {
|
|
40
40
|
BooleanSchema,
|
|
@@ -1,59 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Client-safe feature flag utilities.
|
|
3
|
-
*
|
|
4
|
-
* These functions read feature flags from build-time environment variables
|
|
5
|
-
* (NEXT_PUBLIC_FEATURE_FLAG_* or VITE_FEATURE_FLAG_*) and can be used
|
|
6
|
-
* in both server and client components.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```tsx
|
|
10
|
-
* // In your .smooai-config/config.ts:
|
|
11
|
-
* const config = defineConfig({
|
|
12
|
-
* featureFlagSchema: {
|
|
13
|
-
* aboutPage: BooleanSchema,
|
|
14
|
-
* contactPage: BooleanSchema,
|
|
15
|
-
* },
|
|
16
|
-
* });
|
|
17
|
-
*
|
|
18
|
-
* // In your next.config.js, inject flags as env vars:
|
|
19
|
-
* // NEXT_PUBLIC_FEATURE_FLAG_ABOUT_PAGE=true
|
|
20
|
-
*
|
|
21
|
-
* // In any component (server or client):
|
|
22
|
-
* import { getClientFeatureFlag } from '@smooai/config/feature-flags';
|
|
23
|
-
*
|
|
24
|
-
* if (getClientFeatureFlag('aboutPage')) {
|
|
25
|
-
* // show the feature
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
/**
|
|
30
|
-
* Get a feature flag value from build-time environment variables.
|
|
31
|
-
*
|
|
32
|
-
* Checks for:
|
|
33
|
-
* 1. NEXT_PUBLIC_FEATURE_FLAG_{KEY} (Next.js)
|
|
34
|
-
* 2. VITE_FEATURE_FLAG_{KEY} (Vite)
|
|
35
|
-
*
|
|
36
|
-
* The key is converted from camelCase to UPPER_SNAKE_CASE.
|
|
37
|
-
* e.g., "aboutPage" checks NEXT_PUBLIC_FEATURE_FLAG_ABOUT_PAGE
|
|
38
|
-
*
|
|
39
|
-
* @param key - The camelCase feature flag key
|
|
40
|
-
* @returns true if the flag is explicitly set to "true", false otherwise
|
|
41
|
-
*/
|
|
42
|
-
declare function getClientFeatureFlag(key: string): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Create a typed feature flag checker from a config's FeatureFlagKeys.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```tsx
|
|
48
|
-
* import config, { FeatureFlagKeys } from '../.smooai-config/config';
|
|
49
|
-
* import { createFeatureFlagChecker } from '@smooai/config/feature-flags';
|
|
50
|
-
*
|
|
51
|
-
* export const getFeatureFlag = createFeatureFlagChecker<typeof FeatureFlagKeys>();
|
|
52
|
-
*
|
|
53
|
-
* // Usage:
|
|
54
|
-
* getFeatureFlag('aboutPage') // typed to valid keys
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
declare function createFeatureFlagChecker<T extends Record<string, string>>(): (key: T[keyof T]) => boolean;
|
|
58
|
-
|
|
59
|
-
export { createFeatureFlagChecker, getClientFeatureFlag };
|
|
1
|
+
export { createFeatureFlagChecker, getClientFeatureFlag } from '../client/index.mjs';
|
|
@@ -1,59 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Client-safe feature flag utilities.
|
|
3
|
-
*
|
|
4
|
-
* These functions read feature flags from build-time environment variables
|
|
5
|
-
* (NEXT_PUBLIC_FEATURE_FLAG_* or VITE_FEATURE_FLAG_*) and can be used
|
|
6
|
-
* in both server and client components.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```tsx
|
|
10
|
-
* // In your .smooai-config/config.ts:
|
|
11
|
-
* const config = defineConfig({
|
|
12
|
-
* featureFlagSchema: {
|
|
13
|
-
* aboutPage: BooleanSchema,
|
|
14
|
-
* contactPage: BooleanSchema,
|
|
15
|
-
* },
|
|
16
|
-
* });
|
|
17
|
-
*
|
|
18
|
-
* // In your next.config.js, inject flags as env vars:
|
|
19
|
-
* // NEXT_PUBLIC_FEATURE_FLAG_ABOUT_PAGE=true
|
|
20
|
-
*
|
|
21
|
-
* // In any component (server or client):
|
|
22
|
-
* import { getClientFeatureFlag } from '@smooai/config/feature-flags';
|
|
23
|
-
*
|
|
24
|
-
* if (getClientFeatureFlag('aboutPage')) {
|
|
25
|
-
* // show the feature
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
/**
|
|
30
|
-
* Get a feature flag value from build-time environment variables.
|
|
31
|
-
*
|
|
32
|
-
* Checks for:
|
|
33
|
-
* 1. NEXT_PUBLIC_FEATURE_FLAG_{KEY} (Next.js)
|
|
34
|
-
* 2. VITE_FEATURE_FLAG_{KEY} (Vite)
|
|
35
|
-
*
|
|
36
|
-
* The key is converted from camelCase to UPPER_SNAKE_CASE.
|
|
37
|
-
* e.g., "aboutPage" checks NEXT_PUBLIC_FEATURE_FLAG_ABOUT_PAGE
|
|
38
|
-
*
|
|
39
|
-
* @param key - The camelCase feature flag key
|
|
40
|
-
* @returns true if the flag is explicitly set to "true", false otherwise
|
|
41
|
-
*/
|
|
42
|
-
declare function getClientFeatureFlag(key: string): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Create a typed feature flag checker from a config's FeatureFlagKeys.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```tsx
|
|
48
|
-
* import config, { FeatureFlagKeys } from '../.smooai-config/config';
|
|
49
|
-
* import { createFeatureFlagChecker } from '@smooai/config/feature-flags';
|
|
50
|
-
*
|
|
51
|
-
* export const getFeatureFlag = createFeatureFlagChecker<typeof FeatureFlagKeys>();
|
|
52
|
-
*
|
|
53
|
-
* // Usage:
|
|
54
|
-
* getFeatureFlag('aboutPage') // typed to valid keys
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
declare function createFeatureFlagChecker<T extends Record<string, string>>(): (key: T[keyof T]) => boolean;
|
|
58
|
-
|
|
59
|
-
export { createFeatureFlagChecker, getClientFeatureFlag };
|
|
1
|
+
export { createFeatureFlagChecker, getClientFeatureFlag } from '../client/index.js';
|
|
@@ -24,6 +24,8 @@ __export(feature_flags_exports, {
|
|
|
24
24
|
getClientFeatureFlag: () => getClientFeatureFlag
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(feature_flags_exports);
|
|
27
|
+
|
|
28
|
+
// src/client/index.ts
|
|
27
29
|
function toUpperSnakeCase(key) {
|
|
28
30
|
return key.replace(/([A-Z])/g, "_$1").toUpperCase();
|
|
29
31
|
}
|
|
@@ -33,11 +35,15 @@ function getClientFeatureFlag(key) {
|
|
|
33
35
|
if (nextValue !== void 0) {
|
|
34
36
|
return nextValue === "true" || nextValue === "1";
|
|
35
37
|
}
|
|
38
|
+
const viteValue = typeof process !== "undefined" ? process.env?.[`VITE_FEATURE_FLAG_${envKey}`] : void 0;
|
|
39
|
+
if (viteValue !== void 0) {
|
|
40
|
+
return viteValue === "true" || viteValue === "1";
|
|
41
|
+
}
|
|
36
42
|
try {
|
|
37
43
|
const viteEnv = globalThis.__VITE_ENV__;
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
return
|
|
44
|
+
const viteEnvValue = viteEnv?.[`VITE_FEATURE_FLAG_${envKey}`];
|
|
45
|
+
if (viteEnvValue !== void 0) {
|
|
46
|
+
return viteEnvValue === "true" || viteEnvValue === "1";
|
|
41
47
|
}
|
|
42
48
|
} catch {
|
|
43
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/feature-flags/index.ts"],"sourcesContent":["/**\n * Client-safe feature flag utilities.\n *\n * These functions read feature flags from build-time environment variables\n * (NEXT_PUBLIC_FEATURE_FLAG_* or VITE_FEATURE_FLAG_*) and can be used\n * in both server and client components.\n *\n * @example\n * ```tsx\n *
|
|
1
|
+
{"version":3,"sources":["../../src/feature-flags/index.ts","../../src/client/index.ts"],"sourcesContent":["/**\n * Client-safe feature flag utilities.\n *\n * These functions read feature flags from build-time environment variables\n * (NEXT_PUBLIC_FEATURE_FLAG_* or VITE_FEATURE_FLAG_*) and can be used\n * in both server and client components.\n *\n * This module re-exports from `@smooai/config/client` for backward compatibility.\n * New code should import directly from `@smooai/config/client`.\n *\n * @example\n * ```tsx\n * import { getClientFeatureFlag } from '@smooai/config/feature-flags';\n *\n * if (getClientFeatureFlag('aboutPage')) {\n * // show the feature\n * }\n * ```\n */\n\nexport { getClientFeatureFlag, createFeatureFlagChecker } from '../client';\n","/**\n * Universal client-safe config readers.\n *\n * Reads from both `NEXT_PUBLIC_` and `VITE_` prefixed env vars,\n * allowing the same code to work in Next.js and Vite environments.\n *\n * @example\n * ```tsx\n * import { getClientFeatureFlag, getClientPublicConfig } from '@smooai/config/client';\n *\n * if (getClientFeatureFlag('aboutPage')) {\n * // show the feature\n * }\n *\n * const apiUrl = getClientPublicConfig('apiBaseUrl');\n * ```\n */\n\n/**\n * Convert a camelCase key to UPPER_SNAKE_CASE.\n * e.g., \"aboutPage\" → \"ABOUT_PAGE\"\n */\nexport function toUpperSnakeCase(key: string): string {\n return key.replace(/([A-Z])/g, '_$1').toUpperCase();\n}\n\n/**\n * Get a feature flag value from build-time environment variables.\n *\n * Checks for:\n * 1. NEXT_PUBLIC_FEATURE_FLAG_{KEY} (Next.js)\n * 2. VITE_FEATURE_FLAG_{KEY} (Vite)\n *\n * The key is converted from camelCase to UPPER_SNAKE_CASE.\n * e.g., \"aboutPage\" checks NEXT_PUBLIC_FEATURE_FLAG_ABOUT_PAGE\n *\n * @param key - The camelCase feature flag key\n * @returns true if the flag is explicitly set to \"true\", false otherwise\n */\nexport function getClientFeatureFlag(key: string): boolean {\n const envKey = toUpperSnakeCase(key);\n\n // Check Next.js env var\n const nextValue = typeof process !== 'undefined' ? process.env?.[`NEXT_PUBLIC_FEATURE_FLAG_${envKey}`] : undefined;\n if (nextValue !== undefined) {\n return nextValue === 'true' || nextValue === '1';\n }\n\n // Check Vite env var\n const viteValue = typeof process !== 'undefined' ? process.env?.[`VITE_FEATURE_FLAG_${envKey}`] : undefined;\n if (viteValue !== undefined) {\n return viteValue === 'true' || viteValue === '1';\n }\n\n // Check Vite import.meta.env fallback (available via globalThis in some setups)\n try {\n const viteEnv = (globalThis as Record<string, unknown>).__VITE_ENV__ as Record<string, string> | undefined;\n const viteEnvValue = viteEnv?.[`VITE_FEATURE_FLAG_${envKey}`];\n if (viteEnvValue !== undefined) {\n return viteEnvValue === 'true' || viteEnvValue === '1';\n }\n } catch {\n // Vite env not available\n }\n\n return false;\n}\n\n/**\n * Get a public config value from build-time environment variables.\n *\n * Checks for:\n * 1. NEXT_PUBLIC_CONFIG_{KEY} (Next.js)\n * 2. VITE_CONFIG_{KEY} (Vite)\n *\n * The key is converted from camelCase to UPPER_SNAKE_CASE.\n * e.g., \"apiBaseUrl\" checks NEXT_PUBLIC_CONFIG_API_BASE_URL\n *\n * @param key - The camelCase config key\n * @returns The config value as a string, or undefined if not set\n */\nexport function getClientPublicConfig(key: string): string | undefined {\n const envKey = toUpperSnakeCase(key);\n\n // Check Next.js env var\n const nextValue = typeof process !== 'undefined' ? process.env?.[`NEXT_PUBLIC_CONFIG_${envKey}`] : undefined;\n if (nextValue !== undefined) {\n return nextValue;\n }\n\n // Check Vite env var\n const viteValue = typeof process !== 'undefined' ? process.env?.[`VITE_CONFIG_${envKey}`] : undefined;\n if (viteValue !== undefined) {\n return viteValue;\n }\n\n // Check Vite import.meta.env fallback\n try {\n const viteEnv = (globalThis as Record<string, unknown>).__VITE_ENV__ as Record<string, string> | undefined;\n const viteEnvValue = viteEnv?.[`VITE_CONFIG_${envKey}`];\n if (viteEnvValue !== undefined) {\n return viteEnvValue;\n }\n } catch {\n // Vite env not available\n }\n\n return undefined;\n}\n\n/**\n * Create a typed feature flag checker from a config's FeatureFlagKeys.\n *\n * @example\n * ```tsx\n * import { createFeatureFlagChecker } from '@smooai/config/client';\n *\n * export const getFeatureFlag = createFeatureFlagChecker<typeof FeatureFlagKeys>();\n *\n * // Usage:\n * getFeatureFlag('aboutPage') // typed to valid keys\n * ```\n */\nexport function createFeatureFlagChecker<T extends Record<string, string>>(): (key: T[keyof T]) => boolean {\n return (key: T[keyof T]) => getClientFeatureFlag(key as string);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACsBO,SAAS,iBAAiB,KAAqB;AAClD,SAAO,IAAI,QAAQ,YAAY,KAAK,EAAE,YAAY;AACtD;AAeO,SAAS,qBAAqB,KAAsB;AACvD,QAAM,SAAS,iBAAiB,GAAG;AAGnC,QAAM,YAAY,OAAO,YAAY,cAAc,QAAQ,MAAM,4BAA4B,MAAM,EAAE,IAAI;AACzG,MAAI,cAAc,QAAW;AACzB,WAAO,cAAc,UAAU,cAAc;AAAA,EACjD;AAGA,QAAM,YAAY,OAAO,YAAY,cAAc,QAAQ,MAAM,qBAAqB,MAAM,EAAE,IAAI;AAClG,MAAI,cAAc,QAAW;AACzB,WAAO,cAAc,UAAU,cAAc;AAAA,EACjD;AAGA,MAAI;AACA,UAAM,UAAW,WAAuC;AACxD,UAAM,eAAe,UAAU,qBAAqB,MAAM,EAAE;AAC5D,QAAI,iBAAiB,QAAW;AAC5B,aAAO,iBAAiB,UAAU,iBAAiB;AAAA,IACvD;AAAA,EACJ,QAAQ;AAAA,EAER;AAEA,SAAO;AACX;AAyDO,SAAS,2BAA2F;AACvG,SAAO,CAAC,QAAoB,qBAAqB,GAAa;AAClE;","names":[]}
|
|
@@ -1,28 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createFeatureFlagChecker,
|
|
3
|
+
getClientFeatureFlag
|
|
4
|
+
} from "../chunk-UCFP2MA2.mjs";
|
|
1
5
|
import "../chunk-J5LGTIGS.mjs";
|
|
2
|
-
|
|
3
|
-
// src/feature-flags/index.ts
|
|
4
|
-
function toUpperSnakeCase(key) {
|
|
5
|
-
return key.replace(/([A-Z])/g, "_$1").toUpperCase();
|
|
6
|
-
}
|
|
7
|
-
function getClientFeatureFlag(key) {
|
|
8
|
-
const envKey = toUpperSnakeCase(key);
|
|
9
|
-
const nextValue = typeof process !== "undefined" ? process.env?.[`NEXT_PUBLIC_FEATURE_FLAG_${envKey}`] : void 0;
|
|
10
|
-
if (nextValue !== void 0) {
|
|
11
|
-
return nextValue === "true" || nextValue === "1";
|
|
12
|
-
}
|
|
13
|
-
try {
|
|
14
|
-
const viteEnv = globalThis.__VITE_ENV__;
|
|
15
|
-
const viteValue = viteEnv?.[`VITE_FEATURE_FLAG_${envKey}`];
|
|
16
|
-
if (viteValue !== void 0) {
|
|
17
|
-
return viteValue === "true" || viteValue === "1";
|
|
18
|
-
}
|
|
19
|
-
} catch {
|
|
20
|
-
}
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
function createFeatureFlagChecker() {
|
|
24
|
-
return (key) => getClientFeatureFlag(key);
|
|
25
|
-
}
|
|
26
6
|
export {
|
|
27
7
|
createFeatureFlagChecker,
|
|
28
8
|
getClientFeatureFlag
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_default
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-UEIVAJKL.mjs";
|
|
4
|
+
import "../../../chunk-H4YT7JJJ.mjs";
|
|
5
5
|
import "../../../chunk-LPEA3TRJ.mjs";
|
|
6
|
-
import "../../../chunk-CASNDTCH.mjs";
|
|
7
6
|
import "../../../chunk-UWV4ZGVI.mjs";
|
|
7
|
+
import "../../../chunk-CASNDTCH.mjs";
|
|
8
8
|
import "../../../chunk-J5LGTIGS.mjs";
|
|
9
9
|
export {
|
|
10
10
|
config_default as default
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_default
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-UEIVAJKL.mjs";
|
|
4
|
+
import "../../../chunk-H4YT7JJJ.mjs";
|
|
5
5
|
import "../../../chunk-LPEA3TRJ.mjs";
|
|
6
|
-
import "../../../chunk-CASNDTCH.mjs";
|
|
7
6
|
import "../../../chunk-UWV4ZGVI.mjs";
|
|
7
|
+
import "../../../chunk-CASNDTCH.mjs";
|
|
8
8
|
import "../../../chunk-J5LGTIGS.mjs";
|
|
9
9
|
|
|
10
10
|
// src/integration-tests/1/smooai-config/default.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_default
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-UEIVAJKL.mjs";
|
|
4
|
+
import "../../../chunk-H4YT7JJJ.mjs";
|
|
5
5
|
import "../../../chunk-LPEA3TRJ.mjs";
|
|
6
|
-
import "../../../chunk-CASNDTCH.mjs";
|
|
7
6
|
import "../../../chunk-UWV4ZGVI.mjs";
|
|
7
|
+
import "../../../chunk-CASNDTCH.mjs";
|
|
8
8
|
import "../../../chunk-J5LGTIGS.mjs";
|
|
9
9
|
|
|
10
10
|
// src/integration-tests/1/smooai-config/development.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_default
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-UEIVAJKL.mjs";
|
|
4
|
+
import "../../../chunk-H4YT7JJJ.mjs";
|
|
5
5
|
import "../../../chunk-LPEA3TRJ.mjs";
|
|
6
|
-
import "../../../chunk-CASNDTCH.mjs";
|
|
7
6
|
import "../../../chunk-UWV4ZGVI.mjs";
|
|
7
|
+
import "../../../chunk-CASNDTCH.mjs";
|
|
8
8
|
import "../../../chunk-J5LGTIGS.mjs";
|
|
9
9
|
|
|
10
10
|
// src/integration-tests/1/smooai-config/production.aws.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_default
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-UEIVAJKL.mjs";
|
|
4
|
+
import "../../../chunk-H4YT7JJJ.mjs";
|
|
5
5
|
import "../../../chunk-LPEA3TRJ.mjs";
|
|
6
|
-
import "../../../chunk-CASNDTCH.mjs";
|
|
7
6
|
import "../../../chunk-UWV4ZGVI.mjs";
|
|
7
|
+
import "../../../chunk-CASNDTCH.mjs";
|
|
8
8
|
import "../../../chunk-J5LGTIGS.mjs";
|
|
9
9
|
|
|
10
10
|
// src/integration-tests/1/smooai-config/production.aws.us-east-1.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_default
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-UEIVAJKL.mjs";
|
|
4
|
+
import "../../../chunk-H4YT7JJJ.mjs";
|
|
5
5
|
import "../../../chunk-LPEA3TRJ.mjs";
|
|
6
|
-
import "../../../chunk-CASNDTCH.mjs";
|
|
7
6
|
import "../../../chunk-UWV4ZGVI.mjs";
|
|
7
|
+
import "../../../chunk-CASNDTCH.mjs";
|
|
8
8
|
import "../../../chunk-J5LGTIGS.mjs";
|
|
9
9
|
|
|
10
10
|
// src/integration-tests/1/smooai-config/production.aws.us-east-2.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_default
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-UEIVAJKL.mjs";
|
|
4
|
+
import "../../../chunk-H4YT7JJJ.mjs";
|
|
5
5
|
import "../../../chunk-LPEA3TRJ.mjs";
|
|
6
|
-
import "../../../chunk-CASNDTCH.mjs";
|
|
7
6
|
import "../../../chunk-UWV4ZGVI.mjs";
|
|
7
|
+
import "../../../chunk-CASNDTCH.mjs";
|
|
8
8
|
import "../../../chunk-J5LGTIGS.mjs";
|
|
9
9
|
|
|
10
10
|
// src/integration-tests/1/smooai-config/production.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_default
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-UEIVAJKL.mjs";
|
|
4
|
+
import "../../../chunk-H4YT7JJJ.mjs";
|
|
5
5
|
import "../../../chunk-LPEA3TRJ.mjs";
|
|
6
|
-
import "../../../chunk-CASNDTCH.mjs";
|
|
7
6
|
import "../../../chunk-UWV4ZGVI.mjs";
|
|
7
|
+
import "../../../chunk-CASNDTCH.mjs";
|
|
8
8
|
import "../../../chunk-J5LGTIGS.mjs";
|
|
9
9
|
|
|
10
10
|
// src/integration-tests/1/smooai-config/staging.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_default
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-R7NMFJFJ.mjs";
|
|
4
|
+
import "../../../chunk-H4YT7JJJ.mjs";
|
|
5
5
|
import "../../../chunk-LPEA3TRJ.mjs";
|
|
6
|
-
import "../../../chunk-CASNDTCH.mjs";
|
|
7
6
|
import "../../../chunk-UWV4ZGVI.mjs";
|
|
7
|
+
import "../../../chunk-CASNDTCH.mjs";
|
|
8
8
|
import "../../../chunk-J5LGTIGS.mjs";
|
|
9
9
|
export {
|
|
10
10
|
config_default as default
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_default
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-R7NMFJFJ.mjs";
|
|
4
|
+
import "../../../chunk-H4YT7JJJ.mjs";
|
|
5
5
|
import "../../../chunk-LPEA3TRJ.mjs";
|
|
6
|
-
import "../../../chunk-CASNDTCH.mjs";
|
|
7
6
|
import "../../../chunk-UWV4ZGVI.mjs";
|
|
7
|
+
import "../../../chunk-CASNDTCH.mjs";
|
|
8
8
|
import "../../../chunk-J5LGTIGS.mjs";
|
|
9
9
|
|
|
10
10
|
// src/integration-tests/2/smooai-config/default.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_default
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-R7NMFJFJ.mjs";
|
|
4
|
+
import "../../../chunk-H4YT7JJJ.mjs";
|
|
5
5
|
import "../../../chunk-LPEA3TRJ.mjs";
|
|
6
|
-
import "../../../chunk-CASNDTCH.mjs";
|
|
7
6
|
import "../../../chunk-UWV4ZGVI.mjs";
|
|
7
|
+
import "../../../chunk-CASNDTCH.mjs";
|
|
8
8
|
import "../../../chunk-J5LGTIGS.mjs";
|
|
9
9
|
|
|
10
10
|
// src/integration-tests/2/smooai-config/development.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_default
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-R7NMFJFJ.mjs";
|
|
4
|
+
import "../../../chunk-H4YT7JJJ.mjs";
|
|
5
5
|
import "../../../chunk-LPEA3TRJ.mjs";
|
|
6
|
-
import "../../../chunk-CASNDTCH.mjs";
|
|
7
6
|
import "../../../chunk-UWV4ZGVI.mjs";
|
|
7
|
+
import "../../../chunk-CASNDTCH.mjs";
|
|
8
8
|
import "../../../chunk-J5LGTIGS.mjs";
|
|
9
9
|
|
|
10
10
|
// src/integration-tests/2/smooai-config/production.aws.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_default
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-R7NMFJFJ.mjs";
|
|
4
|
+
import "../../../chunk-H4YT7JJJ.mjs";
|
|
5
5
|
import "../../../chunk-LPEA3TRJ.mjs";
|
|
6
|
-
import "../../../chunk-CASNDTCH.mjs";
|
|
7
6
|
import "../../../chunk-UWV4ZGVI.mjs";
|
|
7
|
+
import "../../../chunk-CASNDTCH.mjs";
|
|
8
8
|
import "../../../chunk-J5LGTIGS.mjs";
|
|
9
9
|
|
|
10
10
|
// src/integration-tests/2/smooai-config/production.aws.us-east-1.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_default
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-R7NMFJFJ.mjs";
|
|
4
|
+
import "../../../chunk-H4YT7JJJ.mjs";
|
|
5
5
|
import "../../../chunk-LPEA3TRJ.mjs";
|
|
6
|
-
import "../../../chunk-CASNDTCH.mjs";
|
|
7
6
|
import "../../../chunk-UWV4ZGVI.mjs";
|
|
7
|
+
import "../../../chunk-CASNDTCH.mjs";
|
|
8
8
|
import "../../../chunk-J5LGTIGS.mjs";
|
|
9
9
|
|
|
10
10
|
// src/integration-tests/2/smooai-config/production.ts
|
package/dist/nextjs/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SmooConfigProvider
|
|
3
3
|
} from "../chunk-22SLF4JR.mjs";
|
|
4
|
-
import {
|
|
5
|
-
getConfig
|
|
6
|
-
} from "../chunk-FAF45VZA.mjs";
|
|
7
4
|
import {
|
|
8
5
|
useFeatureFlag,
|
|
9
6
|
usePublicConfig
|
|
10
7
|
} from "../chunk-GP2JUWOD.mjs";
|
|
11
8
|
import "../chunk-N6Z4AZZA.mjs";
|
|
9
|
+
import {
|
|
10
|
+
getConfig
|
|
11
|
+
} from "../chunk-FAF45VZA.mjs";
|
|
12
12
|
import "../chunk-3B5SRHJ2.mjs";
|
|
13
13
|
import "../chunk-J5LGTIGS.mjs";
|
|
14
14
|
export {
|