@smooai/config 3.0.1 → 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.
Files changed (81) hide show
  1. package/dist/browser/chunk-YMNAMX6Y.mjs +55 -0
  2. package/dist/browser/chunk-YMNAMX6Y.mjs.map +1 -0
  3. package/dist/browser/client/index.mjs +14 -0
  4. package/dist/browser/client/index.mjs.map +1 -0
  5. package/dist/browser/feature-flags/index.mjs +4 -24
  6. package/dist/browser/feature-flags/index.mjs.map +1 -1
  7. package/dist/{chunk-2DYBQ6SF.mjs → chunk-43SVVFYE.mjs} +3 -3
  8. package/dist/{chunk-PCXGCPWC.mjs → chunk-6XDO5B2T.mjs} +8 -8
  9. package/dist/{chunk-7CCXEKIK.mjs → chunk-H4YT7JJJ.mjs} +4 -4
  10. package/dist/{chunk-JAEJOSH5.mjs → chunk-NF7JF2UP.mjs} +2 -2
  11. package/dist/{chunk-7GMXNAVA.mjs → chunk-PD2SHA7M.mjs} +11 -11
  12. package/dist/{chunk-2CD4ZQFH.mjs → chunk-R7NMFJFJ.mjs} +2 -2
  13. package/dist/chunk-SAX775JO.mjs +40 -0
  14. package/dist/chunk-SAX775JO.mjs.map +1 -0
  15. package/dist/chunk-UCFP2MA2.mjs +55 -0
  16. package/dist/chunk-UCFP2MA2.mjs.map +1 -0
  17. package/dist/{chunk-4RYDS2HX.mjs → chunk-UEIVAJKL.mjs} +2 -2
  18. package/dist/client/index.d.mts +66 -0
  19. package/dist/client/index.d.ts +66 -0
  20. package/dist/client/index.js +82 -0
  21. package/dist/client/index.js.map +1 -0
  22. package/dist/client/index.mjs +14 -0
  23. package/dist/client/index.mjs.map +1 -0
  24. package/dist/config/config.mjs +2 -2
  25. package/dist/config/findAndProcessEnvConfig.mjs +5 -5
  26. package/dist/config/findAndProcessFileConfig.mjs +6 -6
  27. package/dist/config/index.mjs +6 -6
  28. package/dist/config/parseConfigSchema.mjs +3 -3
  29. package/dist/config/server.mjs +9 -9
  30. package/dist/feature-flags/index.d.mts +1 -59
  31. package/dist/feature-flags/index.d.ts +1 -59
  32. package/dist/feature-flags/index.js +9 -3
  33. package/dist/feature-flags/index.js.map +1 -1
  34. package/dist/feature-flags/index.mjs +4 -24
  35. package/dist/feature-flags/index.mjs.map +1 -1
  36. package/dist/integration-tests/1/smooai-config/config.mjs +3 -3
  37. package/dist/integration-tests/1/smooai-config/default.mjs +3 -3
  38. package/dist/integration-tests/1/smooai-config/development.mjs +3 -3
  39. package/dist/integration-tests/1/smooai-config/production.aws.mjs +3 -3
  40. package/dist/integration-tests/1/smooai-config/production.aws.us-east-1.mjs +3 -3
  41. package/dist/integration-tests/1/smooai-config/production.aws.us-east-2.mjs +3 -3
  42. package/dist/integration-tests/1/smooai-config/production.mjs +3 -3
  43. package/dist/integration-tests/1/smooai-config/staging.mjs +3 -3
  44. package/dist/integration-tests/2/smooai-config/config.mjs +3 -3
  45. package/dist/integration-tests/2/smooai-config/default.mjs +3 -3
  46. package/dist/integration-tests/2/smooai-config/development.mjs +3 -3
  47. package/dist/integration-tests/2/smooai-config/production.aws.mjs +3 -3
  48. package/dist/integration-tests/2/smooai-config/production.aws.us-east-1.mjs +3 -3
  49. package/dist/integration-tests/2/smooai-config/production.mjs +3 -3
  50. package/dist/nextjs/index.mjs +3 -3
  51. package/dist/nextjs/withFeatureFlags.d.mts +15 -24
  52. package/dist/nextjs/withFeatureFlags.d.ts +15 -24
  53. package/dist/nextjs/withFeatureFlags.js +33 -6
  54. package/dist/nextjs/withFeatureFlags.js.map +1 -1
  55. package/dist/nextjs/withFeatureFlags.mjs +11 -20
  56. package/dist/nextjs/withFeatureFlags.mjs.map +1 -1
  57. package/dist/nextjs/withSmooConfig.d.mts +63 -0
  58. package/dist/nextjs/withSmooConfig.d.ts +63 -0
  59. package/dist/nextjs/withSmooConfig.js +64 -0
  60. package/dist/nextjs/withSmooConfig.js.map +1 -0
  61. package/dist/nextjs/withSmooConfig.mjs +8 -0
  62. package/dist/nextjs/withSmooConfig.mjs.map +1 -0
  63. package/dist/platform/server/server.async.mjs +8 -8
  64. package/dist/platform/server/server.featureFlag.sync.mjs +8 -8
  65. package/dist/platform/server/server.publicConfig.sync.mjs +8 -8
  66. package/dist/platform/server/server.secretConfig.sync.mjs +8 -8
  67. package/dist/platform/server.mjs +8 -8
  68. package/dist/vite/smooConfigPlugin.d.mts +47 -0
  69. package/dist/vite/smooConfigPlugin.d.ts +47 -0
  70. package/dist/vite/smooConfigPlugin.js +60 -0
  71. package/dist/vite/smooConfigPlugin.js.map +1 -0
  72. package/dist/vite/smooConfigPlugin.mjs +37 -0
  73. package/dist/vite/smooConfigPlugin.mjs.map +1 -0
  74. package/package.json +20 -1
  75. /package/dist/{chunk-2DYBQ6SF.mjs.map → chunk-43SVVFYE.mjs.map} +0 -0
  76. /package/dist/{chunk-PCXGCPWC.mjs.map → chunk-6XDO5B2T.mjs.map} +0 -0
  77. /package/dist/{chunk-7CCXEKIK.mjs.map → chunk-H4YT7JJJ.mjs.map} +0 -0
  78. /package/dist/{chunk-JAEJOSH5.mjs.map → chunk-NF7JF2UP.mjs.map} +0 -0
  79. /package/dist/{chunk-7GMXNAVA.mjs.map → chunk-PD2SHA7M.mjs.map} +0 -0
  80. /package/dist/{chunk-2CD4ZQFH.mjs.map → chunk-R7NMFJFJ.mjs.map} +0 -0
  81. /package/dist/{chunk-4RYDS2HX.mjs.map → chunk-UEIVAJKL.mjs.map} +0 -0
@@ -1,32 +1,23 @@
1
+ export { SmooConfigValues, WithSmooConfigOptions, withSmooConfig } from './withSmooConfig.mjs';
2
+
1
3
  /**
2
- * Next.js config helper that injects feature flags as NEXT_PUBLIC_ environment variables.
4
+ * @deprecated Use `withSmooConfig` from `@smooai/config/nextjs/withSmooConfig` instead.
3
5
  *
4
- * This allows client components to read feature flags via `getClientFeatureFlag()`
5
- * from `@smooai/config/feature-flags` without importing any Node.js-dependent code.
6
+ * This module is kept for backward compatibility. It wraps `withSmooConfig`
7
+ * to provide the same feature-flag-only API.
6
8
  *
7
9
  * @example
8
10
  * ```ts
9
- * // next.config.ts
11
+ * // Migrate from:
10
12
  * import { withFeatureFlags } from '@smooai/config/nextjs/withFeatureFlags';
11
- * import defaultConfig from './.smooai-config/default';
12
- * import developmentConfig from './.smooai-config/development';
13
+ * const nextConfig = withFeatureFlags({ default: { aboutPage: false }, development: { aboutPage: true } });
13
14
  *
14
- * const nextConfig = withFeatureFlags({
15
- * default: defaultConfig,
16
- * development: developmentConfig,
15
+ * // To:
16
+ * import { withSmooConfig } from '@smooai/config/nextjs/withSmooConfig';
17
+ * const nextConfig = withSmooConfig({
18
+ * default: { featureFlags: { aboutPage: false } },
19
+ * development: { featureFlags: { aboutPage: true } },
17
20
  * });
18
- *
19
- * export default nextConfig;
20
- * ```
21
- *
22
- * This will set environment variables like:
23
- * - NEXT_PUBLIC_FEATURE_FLAG_ABOUT_PAGE=true (in development)
24
- * - NEXT_PUBLIC_FEATURE_FLAG_ABOUT_PAGE=false (in production)
25
- *
26
- * Then in any client component:
27
- * ```tsx
28
- * import { getClientFeatureFlag } from '@smooai/config/feature-flags';
29
- * const isEnabled = getClientFeatureFlag('aboutPage');
30
21
  * ```
31
22
  */
32
23
  type NextConfig = Record<string, unknown>;
@@ -40,10 +31,10 @@ interface WithFeatureFlagsOptions {
40
31
  [stage: string]: FeatureFlagConfig | undefined;
41
32
  }
42
33
  /**
43
- * Wraps a Next.js config to inject feature flags as NEXT_PUBLIC_ environment variables.
34
+ * @deprecated Use `withSmooConfig` instead.
44
35
  *
45
- * Reads `NEXT_PUBLIC_SST_STAGE` (or `NODE_ENV`) to determine which config to use.
46
- * Falls back to development config if stage is not 'production'.
36
+ * Wraps a Next.js config to inject feature flags as NEXT_PUBLIC_ environment variables.
37
+ * This is a backward-compatible wrapper around `withSmooConfig`.
47
38
  */
48
39
  declare function withFeatureFlags(flagConfigs: WithFeatureFlagsOptions, nextConfig?: NextConfig): NextConfig;
49
40
 
@@ -1,32 +1,23 @@
1
+ export { SmooConfigValues, WithSmooConfigOptions, withSmooConfig } from './withSmooConfig.js';
2
+
1
3
  /**
2
- * Next.js config helper that injects feature flags as NEXT_PUBLIC_ environment variables.
4
+ * @deprecated Use `withSmooConfig` from `@smooai/config/nextjs/withSmooConfig` instead.
3
5
  *
4
- * This allows client components to read feature flags via `getClientFeatureFlag()`
5
- * from `@smooai/config/feature-flags` without importing any Node.js-dependent code.
6
+ * This module is kept for backward compatibility. It wraps `withSmooConfig`
7
+ * to provide the same feature-flag-only API.
6
8
  *
7
9
  * @example
8
10
  * ```ts
9
- * // next.config.ts
11
+ * // Migrate from:
10
12
  * import { withFeatureFlags } from '@smooai/config/nextjs/withFeatureFlags';
11
- * import defaultConfig from './.smooai-config/default';
12
- * import developmentConfig from './.smooai-config/development';
13
+ * const nextConfig = withFeatureFlags({ default: { aboutPage: false }, development: { aboutPage: true } });
13
14
  *
14
- * const nextConfig = withFeatureFlags({
15
- * default: defaultConfig,
16
- * development: developmentConfig,
15
+ * // To:
16
+ * import { withSmooConfig } from '@smooai/config/nextjs/withSmooConfig';
17
+ * const nextConfig = withSmooConfig({
18
+ * default: { featureFlags: { aboutPage: false } },
19
+ * development: { featureFlags: { aboutPage: true } },
17
20
  * });
18
- *
19
- * export default nextConfig;
20
- * ```
21
- *
22
- * This will set environment variables like:
23
- * - NEXT_PUBLIC_FEATURE_FLAG_ABOUT_PAGE=true (in development)
24
- * - NEXT_PUBLIC_FEATURE_FLAG_ABOUT_PAGE=false (in production)
25
- *
26
- * Then in any client component:
27
- * ```tsx
28
- * import { getClientFeatureFlag } from '@smooai/config/feature-flags';
29
- * const isEnabled = getClientFeatureFlag('aboutPage');
30
21
  * ```
31
22
  */
32
23
  type NextConfig = Record<string, unknown>;
@@ -40,10 +31,10 @@ interface WithFeatureFlagsOptions {
40
31
  [stage: string]: FeatureFlagConfig | undefined;
41
32
  }
42
33
  /**
43
- * Wraps a Next.js config to inject feature flags as NEXT_PUBLIC_ environment variables.
34
+ * @deprecated Use `withSmooConfig` instead.
44
35
  *
45
- * Reads `NEXT_PUBLIC_SST_STAGE` (or `NODE_ENV`) to determine which config to use.
46
- * Falls back to development config if stage is not 'production'.
36
+ * Wraps a Next.js config to inject feature flags as NEXT_PUBLIC_ environment variables.
37
+ * This is a backward-compatible wrapper around `withSmooConfig`.
47
38
  */
48
39
  declare function withFeatureFlags(flagConfigs: WithFeatureFlagsOptions, nextConfig?: NextConfig): NextConfig;
49
40
 
@@ -20,23 +20,38 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/nextjs/withFeatureFlags.ts
21
21
  var withFeatureFlags_exports = {};
22
22
  __export(withFeatureFlags_exports, {
23
- withFeatureFlags: () => withFeatureFlags
23
+ withFeatureFlags: () => withFeatureFlags,
24
+ withSmooConfig: () => withSmooConfig
24
25
  });
25
26
  module.exports = __toCommonJS(withFeatureFlags_exports);
27
+
28
+ // src/nextjs/withSmooConfig.ts
26
29
  function toUpperSnakeCase(key) {
27
30
  return key.replace(/([A-Z])/g, "_$1").toUpperCase();
28
31
  }
29
- function withFeatureFlags(flagConfigs, nextConfig = {}) {
32
+ function withSmooConfig(options, nextConfig = {}) {
30
33
  const stage = process.env.NEXT_PUBLIC_SST_STAGE ?? (process.env.NODE_ENV === "production" ? "production" : "development");
31
- const defaultFlags = flagConfigs.default ?? {};
32
- const stageOverrides = flagConfigs[stage] ?? {};
33
- const resolvedFlags = { ...defaultFlags, ...stageOverrides };
34
+ const defaultValues = options.default ?? {};
35
+ const stageOverrides = options[stage] ?? {};
36
+ const resolvedFlags = {
37
+ ...defaultValues.featureFlags,
38
+ ...stageOverrides.featureFlags
39
+ };
40
+ const resolvedConfig = {
41
+ ...defaultValues.publicConfig,
42
+ ...stageOverrides.publicConfig
43
+ };
34
44
  const env = {};
35
45
  for (const [key, value] of Object.entries(resolvedFlags)) {
36
46
  const envKey = `NEXT_PUBLIC_FEATURE_FLAG_${toUpperSnakeCase(key)}`;
37
47
  env[envKey] = String(value);
38
48
  process.env[envKey] = String(value);
39
49
  }
50
+ for (const [key, value] of Object.entries(resolvedConfig)) {
51
+ const envKey = `NEXT_PUBLIC_CONFIG_${toUpperSnakeCase(key)}`;
52
+ env[envKey] = String(value);
53
+ process.env[envKey] = String(value);
54
+ }
40
55
  return {
41
56
  ...nextConfig,
42
57
  env: {
@@ -45,8 +60,20 @@ function withFeatureFlags(flagConfigs, nextConfig = {}) {
45
60
  }
46
61
  };
47
62
  }
63
+
64
+ // src/nextjs/withFeatureFlags.ts
65
+ function withFeatureFlags(flagConfigs, nextConfig = {}) {
66
+ const smooOptions = { default: {} };
67
+ for (const [stage, flags] of Object.entries(flagConfigs)) {
68
+ if (flags !== void 0) {
69
+ smooOptions[stage] = { featureFlags: flags };
70
+ }
71
+ }
72
+ return withSmooConfig(smooOptions, nextConfig);
73
+ }
48
74
  // Annotate the CommonJS export names for ESM import in node:
49
75
  0 && (module.exports = {
50
- withFeatureFlags
76
+ withFeatureFlags,
77
+ withSmooConfig
51
78
  });
52
79
  //# sourceMappingURL=withFeatureFlags.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/nextjs/withFeatureFlags.ts"],"sourcesContent":["/**\n * Next.js config helper that injects feature flags as NEXT_PUBLIC_ environment variables.\n *\n * This allows client components to read feature flags via `getClientFeatureFlag()`\n * from `@smooai/config/feature-flags` without importing any Node.js-dependent code.\n *\n * @example\n * ```ts\n * // next.config.ts\n * import { withFeatureFlags } from '@smooai/config/nextjs/withFeatureFlags';\n * import defaultConfig from './.smooai-config/default';\n * import developmentConfig from './.smooai-config/development';\n *\n * const nextConfig = withFeatureFlags({\n * default: defaultConfig,\n * development: developmentConfig,\n * });\n *\n * export default nextConfig;\n * ```\n *\n * This will set environment variables like:\n * - NEXT_PUBLIC_FEATURE_FLAG_ABOUT_PAGE=true (in development)\n * - NEXT_PUBLIC_FEATURE_FLAG_ABOUT_PAGE=false (in production)\n *\n * Then in any client component:\n * ```tsx\n * import { getClientFeatureFlag } from '@smooai/config/feature-flags';\n * const isEnabled = getClientFeatureFlag('aboutPage');\n * ```\n */\n\ntype NextConfig = Record<string, unknown>;\ntype FeatureFlagConfig = Record<string, boolean>;\n\ninterface WithFeatureFlagsOptions {\n /** Default feature flag values (used in production). */\n default: FeatureFlagConfig;\n /** Development overrides (merged with default). */\n development?: FeatureFlagConfig;\n /** Additional stage-specific overrides. Key is the stage name. */\n [stage: string]: FeatureFlagConfig | undefined;\n}\n\n/**\n * Convert a camelCase key to UPPER_SNAKE_CASE.\n * e.g., \"aboutPage\" → \"ABOUT_PAGE\"\n */\nfunction toUpperSnakeCase(key: string): string {\n return key.replace(/([A-Z])/g, '_$1').toUpperCase();\n}\n\n/**\n * Wraps a Next.js config to inject feature flags as NEXT_PUBLIC_ environment variables.\n *\n * Reads `NEXT_PUBLIC_SST_STAGE` (or `NODE_ENV`) to determine which config to use.\n * Falls back to development config if stage is not 'production'.\n */\nexport function withFeatureFlags(flagConfigs: WithFeatureFlagsOptions, nextConfig: NextConfig = {}): NextConfig {\n const stage = process.env.NEXT_PUBLIC_SST_STAGE ?? (process.env.NODE_ENV === 'production' ? 'production' : 'development');\n\n // Merge default with stage-specific overrides\n const defaultFlags = flagConfigs.default ?? {};\n const stageOverrides = flagConfigs[stage] ?? {};\n const resolvedFlags: FeatureFlagConfig = { ...defaultFlags, ...stageOverrides };\n\n // Inject as NEXT_PUBLIC_ env vars\n const env: Record<string, string> = {};\n for (const [key, value] of Object.entries(resolvedFlags)) {\n const envKey = `NEXT_PUBLIC_FEATURE_FLAG_${toUpperSnakeCase(key)}`;\n env[envKey] = String(value);\n // Also set in process.env for SSR\n process.env[envKey] = String(value);\n }\n\n return {\n ...nextConfig,\n env: {\n ...(nextConfig.env as Record<string, string> | undefined),\n ...env,\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgDA,SAAS,iBAAiB,KAAqB;AAC3C,SAAO,IAAI,QAAQ,YAAY,KAAK,EAAE,YAAY;AACtD;AAQO,SAAS,iBAAiB,aAAsC,aAAyB,CAAC,GAAe;AAC5G,QAAM,QAAQ,QAAQ,IAAI,0BAA0B,QAAQ,IAAI,aAAa,eAAe,eAAe;AAG3G,QAAM,eAAe,YAAY,WAAW,CAAC;AAC7C,QAAM,iBAAiB,YAAY,KAAK,KAAK,CAAC;AAC9C,QAAM,gBAAmC,EAAE,GAAG,cAAc,GAAG,eAAe;AAG9E,QAAM,MAA8B,CAAC;AACrC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,aAAa,GAAG;AACtD,UAAM,SAAS,4BAA4B,iBAAiB,GAAG,CAAC;AAChE,QAAI,MAAM,IAAI,OAAO,KAAK;AAE1B,YAAQ,IAAI,MAAM,IAAI,OAAO,KAAK;AAAA,EACtC;AAEA,SAAO;AAAA,IACH,GAAG;AAAA,IACH,KAAK;AAAA,MACD,GAAI,WAAW;AAAA,MACf,GAAG;AAAA,IACP;AAAA,EACJ;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../src/nextjs/withFeatureFlags.ts","../../src/nextjs/withSmooConfig.ts"],"sourcesContent":["/**\n * @deprecated Use `withSmooConfig` from `@smooai/config/nextjs/withSmooConfig` instead.\n *\n * This module is kept for backward compatibility. It wraps `withSmooConfig`\n * to provide the same feature-flag-only API.\n *\n * @example\n * ```ts\n * // Migrate from:\n * import { withFeatureFlags } from '@smooai/config/nextjs/withFeatureFlags';\n * const nextConfig = withFeatureFlags({ default: { aboutPage: false }, development: { aboutPage: true } });\n *\n * // To:\n * import { withSmooConfig } from '@smooai/config/nextjs/withSmooConfig';\n * const nextConfig = withSmooConfig({\n * default: { featureFlags: { aboutPage: false } },\n * development: { featureFlags: { aboutPage: true } },\n * });\n * ```\n */\n\nimport { withSmooConfig } from './withSmooConfig';\nimport type { WithSmooConfigOptions } from './withSmooConfig';\n\ntype NextConfig = Record<string, unknown>;\ntype FeatureFlagConfig = Record<string, boolean>;\n\ninterface WithFeatureFlagsOptions {\n /** Default feature flag values (used in production). */\n default: FeatureFlagConfig;\n /** Development overrides (merged with default). */\n development?: FeatureFlagConfig;\n /** Additional stage-specific overrides. Key is the stage name. */\n [stage: string]: FeatureFlagConfig | undefined;\n}\n\n/**\n * @deprecated Use `withSmooConfig` instead.\n *\n * Wraps a Next.js config to inject feature flags as NEXT_PUBLIC_ environment variables.\n * This is a backward-compatible wrapper around `withSmooConfig`.\n */\nexport function withFeatureFlags(flagConfigs: WithFeatureFlagsOptions, nextConfig: NextConfig = {}): NextConfig {\n // Convert the flat flag configs into SmooConfigValues format\n const smooOptions: WithSmooConfigOptions = { default: {} };\n\n for (const [stage, flags] of Object.entries(flagConfigs)) {\n if (flags !== undefined) {\n smooOptions[stage] = { featureFlags: flags };\n }\n }\n\n return withSmooConfig(smooOptions, nextConfig);\n}\n\n// Re-export withSmooConfig types and function for convenience\nexport { withSmooConfig } from './withSmooConfig';\nexport type { SmooConfigValues, WithSmooConfigOptions } from './withSmooConfig';\n","/**\n * Next.js config helper that injects feature flags AND public config\n * as NEXT_PUBLIC_ environment variables.\n *\n * This is the unified replacement for `withFeatureFlags`, supporting both\n * feature flags (NEXT_PUBLIC_FEATURE_FLAG_*) and public config values\n * (NEXT_PUBLIC_CONFIG_*).\n *\n * @example\n * ```ts\n * // next.config.ts\n * import { withSmooConfig } from '@smooai/config/nextjs/withSmooConfig';\n *\n * const nextConfig = withSmooConfig({\n * default: {\n * featureFlags: { aboutPage: false, contactPage: true },\n * publicConfig: { apiBaseUrl: 'https://api.smooai.com', maxRetries: 3 },\n * },\n * development: {\n * featureFlags: { aboutPage: true },\n * publicConfig: { apiBaseUrl: 'http://localhost:3000' },\n * },\n * });\n *\n * export default nextConfig;\n * ```\n *\n * This will set environment variables like:\n * - NEXT_PUBLIC_FEATURE_FLAG_ABOUT_PAGE=true (in development)\n * - NEXT_PUBLIC_CONFIG_API_BASE_URL=http://localhost:3000 (in development)\n *\n * Then in any client component:\n * ```tsx\n * import { getClientFeatureFlag, getClientPublicConfig } from '@smooai/config/client';\n * const isEnabled = getClientFeatureFlag('aboutPage');\n * const apiUrl = getClientPublicConfig('apiBaseUrl');\n * ```\n */\n\ntype NextConfig = Record<string, unknown>;\n\nexport interface SmooConfigValues {\n /** Feature flag values (boolean). */\n featureFlags?: Record<string, boolean>;\n /** Public config values (string, number, or boolean). */\n publicConfig?: Record<string, string | number | boolean>;\n}\n\nexport interface WithSmooConfigOptions {\n /** Default config values (used in production). */\n default: SmooConfigValues;\n /** Development overrides (merged with default). */\n development?: SmooConfigValues;\n /** Additional stage-specific overrides. Key is the stage name. */\n [stage: string]: SmooConfigValues | undefined;\n}\n\n/**\n * Convert a camelCase key to UPPER_SNAKE_CASE.\n * e.g., \"aboutPage\" → \"ABOUT_PAGE\"\n */\nfunction toUpperSnakeCase(key: string): string {\n return key.replace(/([A-Z])/g, '_$1').toUpperCase();\n}\n\n/**\n * Wraps a Next.js config to inject feature flags and public config\n * as NEXT_PUBLIC_ environment variables.\n *\n * Reads `NEXT_PUBLIC_SST_STAGE` (or `NODE_ENV`) to determine which config to use.\n * Falls back to development config if stage is not 'production'.\n */\nexport function withSmooConfig(options: WithSmooConfigOptions, nextConfig: NextConfig = {}): NextConfig {\n const stage = process.env.NEXT_PUBLIC_SST_STAGE ?? (process.env.NODE_ENV === 'production' ? 'production' : 'development');\n\n // Merge default with stage-specific overrides\n const defaultValues = options.default ?? {};\n const stageOverrides = options[stage] ?? {};\n\n const resolvedFlags: Record<string, boolean> = {\n ...defaultValues.featureFlags,\n ...stageOverrides.featureFlags,\n };\n\n const resolvedConfig: Record<string, string | number | boolean> = {\n ...defaultValues.publicConfig,\n ...stageOverrides.publicConfig,\n };\n\n // Inject as NEXT_PUBLIC_ env vars\n const env: Record<string, string> = {};\n\n // Feature flags → NEXT_PUBLIC_FEATURE_FLAG_*\n for (const [key, value] of Object.entries(resolvedFlags)) {\n const envKey = `NEXT_PUBLIC_FEATURE_FLAG_${toUpperSnakeCase(key)}`;\n env[envKey] = String(value);\n // Also set in process.env for SSR\n process.env[envKey] = String(value);\n }\n\n // Public config → NEXT_PUBLIC_CONFIG_*\n for (const [key, value] of Object.entries(resolvedConfig)) {\n const envKey = `NEXT_PUBLIC_CONFIG_${toUpperSnakeCase(key)}`;\n env[envKey] = String(value);\n // Also set in process.env for SSR\n process.env[envKey] = String(value);\n }\n\n return {\n ...nextConfig,\n env: {\n ...(nextConfig.env as Record<string, string> | undefined),\n ...env,\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6DA,SAAS,iBAAiB,KAAqB;AAC3C,SAAO,IAAI,QAAQ,YAAY,KAAK,EAAE,YAAY;AACtD;AASO,SAAS,eAAe,SAAgC,aAAyB,CAAC,GAAe;AACpG,QAAM,QAAQ,QAAQ,IAAI,0BAA0B,QAAQ,IAAI,aAAa,eAAe,eAAe;AAG3G,QAAM,gBAAgB,QAAQ,WAAW,CAAC;AAC1C,QAAM,iBAAiB,QAAQ,KAAK,KAAK,CAAC;AAE1C,QAAM,gBAAyC;AAAA,IAC3C,GAAG,cAAc;AAAA,IACjB,GAAG,eAAe;AAAA,EACtB;AAEA,QAAM,iBAA4D;AAAA,IAC9D,GAAG,cAAc;AAAA,IACjB,GAAG,eAAe;AAAA,EACtB;AAGA,QAAM,MAA8B,CAAC;AAGrC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,aAAa,GAAG;AACtD,UAAM,SAAS,4BAA4B,iBAAiB,GAAG,CAAC;AAChE,QAAI,MAAM,IAAI,OAAO,KAAK;AAE1B,YAAQ,IAAI,MAAM,IAAI,OAAO,KAAK;AAAA,EACtC;AAGA,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,cAAc,GAAG;AACvD,UAAM,SAAS,sBAAsB,iBAAiB,GAAG,CAAC;AAC1D,QAAI,MAAM,IAAI,OAAO,KAAK;AAE1B,YAAQ,IAAI,MAAM,IAAI,OAAO,KAAK;AAAA,EACtC;AAEA,SAAO;AAAA,IACH,GAAG;AAAA,IACH,KAAK;AAAA,MACD,GAAI,WAAW;AAAA,MACf,GAAG;AAAA,IACP;AAAA,EACJ;AACJ;;;ADzEO,SAAS,iBAAiB,aAAsC,aAAyB,CAAC,GAAe;AAE5G,QAAM,cAAqC,EAAE,SAAS,CAAC,EAAE;AAEzD,aAAW,CAAC,OAAO,KAAK,KAAK,OAAO,QAAQ,WAAW,GAAG;AACtD,QAAI,UAAU,QAAW;AACrB,kBAAY,KAAK,IAAI,EAAE,cAAc,MAAM;AAAA,IAC/C;AAAA,EACJ;AAEA,SAAO,eAAe,aAAa,UAAU;AACjD;","names":[]}
@@ -1,29 +1,20 @@
1
+ import {
2
+ withSmooConfig
3
+ } from "../chunk-SAX775JO.mjs";
1
4
  import "../chunk-J5LGTIGS.mjs";
2
5
 
3
6
  // src/nextjs/withFeatureFlags.ts
4
- function toUpperSnakeCase(key) {
5
- return key.replace(/([A-Z])/g, "_$1").toUpperCase();
6
- }
7
7
  function withFeatureFlags(flagConfigs, nextConfig = {}) {
8
- const stage = process.env.NEXT_PUBLIC_SST_STAGE ?? (process.env.NODE_ENV === "production" ? "production" : "development");
9
- const defaultFlags = flagConfigs.default ?? {};
10
- const stageOverrides = flagConfigs[stage] ?? {};
11
- const resolvedFlags = { ...defaultFlags, ...stageOverrides };
12
- const env = {};
13
- for (const [key, value] of Object.entries(resolvedFlags)) {
14
- const envKey = `NEXT_PUBLIC_FEATURE_FLAG_${toUpperSnakeCase(key)}`;
15
- env[envKey] = String(value);
16
- process.env[envKey] = String(value);
17
- }
18
- return {
19
- ...nextConfig,
20
- env: {
21
- ...nextConfig.env,
22
- ...env
8
+ const smooOptions = { default: {} };
9
+ for (const [stage, flags] of Object.entries(flagConfigs)) {
10
+ if (flags !== void 0) {
11
+ smooOptions[stage] = { featureFlags: flags };
23
12
  }
24
- };
13
+ }
14
+ return withSmooConfig(smooOptions, nextConfig);
25
15
  }
26
16
  export {
27
- withFeatureFlags
17
+ withFeatureFlags,
18
+ withSmooConfig
28
19
  };
29
20
  //# sourceMappingURL=withFeatureFlags.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/nextjs/withFeatureFlags.ts"],"sourcesContent":["/**\n * Next.js config helper that injects feature flags as NEXT_PUBLIC_ environment variables.\n *\n * This allows client components to read feature flags via `getClientFeatureFlag()`\n * from `@smooai/config/feature-flags` without importing any Node.js-dependent code.\n *\n * @example\n * ```ts\n * // next.config.ts\n * import { withFeatureFlags } from '@smooai/config/nextjs/withFeatureFlags';\n * import defaultConfig from './.smooai-config/default';\n * import developmentConfig from './.smooai-config/development';\n *\n * const nextConfig = withFeatureFlags({\n * default: defaultConfig,\n * development: developmentConfig,\n * });\n *\n * export default nextConfig;\n * ```\n *\n * This will set environment variables like:\n * - NEXT_PUBLIC_FEATURE_FLAG_ABOUT_PAGE=true (in development)\n * - NEXT_PUBLIC_FEATURE_FLAG_ABOUT_PAGE=false (in production)\n *\n * Then in any client component:\n * ```tsx\n * import { getClientFeatureFlag } from '@smooai/config/feature-flags';\n * const isEnabled = getClientFeatureFlag('aboutPage');\n * ```\n */\n\ntype NextConfig = Record<string, unknown>;\ntype FeatureFlagConfig = Record<string, boolean>;\n\ninterface WithFeatureFlagsOptions {\n /** Default feature flag values (used in production). */\n default: FeatureFlagConfig;\n /** Development overrides (merged with default). */\n development?: FeatureFlagConfig;\n /** Additional stage-specific overrides. Key is the stage name. */\n [stage: string]: FeatureFlagConfig | undefined;\n}\n\n/**\n * Convert a camelCase key to UPPER_SNAKE_CASE.\n * e.g., \"aboutPage\" → \"ABOUT_PAGE\"\n */\nfunction toUpperSnakeCase(key: string): string {\n return key.replace(/([A-Z])/g, '_$1').toUpperCase();\n}\n\n/**\n * Wraps a Next.js config to inject feature flags as NEXT_PUBLIC_ environment variables.\n *\n * Reads `NEXT_PUBLIC_SST_STAGE` (or `NODE_ENV`) to determine which config to use.\n * Falls back to development config if stage is not 'production'.\n */\nexport function withFeatureFlags(flagConfigs: WithFeatureFlagsOptions, nextConfig: NextConfig = {}): NextConfig {\n const stage = process.env.NEXT_PUBLIC_SST_STAGE ?? (process.env.NODE_ENV === 'production' ? 'production' : 'development');\n\n // Merge default with stage-specific overrides\n const defaultFlags = flagConfigs.default ?? {};\n const stageOverrides = flagConfigs[stage] ?? {};\n const resolvedFlags: FeatureFlagConfig = { ...defaultFlags, ...stageOverrides };\n\n // Inject as NEXT_PUBLIC_ env vars\n const env: Record<string, string> = {};\n for (const [key, value] of Object.entries(resolvedFlags)) {\n const envKey = `NEXT_PUBLIC_FEATURE_FLAG_${toUpperSnakeCase(key)}`;\n env[envKey] = String(value);\n // Also set in process.env for SSR\n process.env[envKey] = String(value);\n }\n\n return {\n ...nextConfig,\n env: {\n ...(nextConfig.env as Record<string, string> | undefined),\n ...env,\n },\n };\n}\n"],"mappings":";;;AAgDA,SAAS,iBAAiB,KAAqB;AAC3C,SAAO,IAAI,QAAQ,YAAY,KAAK,EAAE,YAAY;AACtD;AAQO,SAAS,iBAAiB,aAAsC,aAAyB,CAAC,GAAe;AAC5G,QAAM,QAAQ,QAAQ,IAAI,0BAA0B,QAAQ,IAAI,aAAa,eAAe,eAAe;AAG3G,QAAM,eAAe,YAAY,WAAW,CAAC;AAC7C,QAAM,iBAAiB,YAAY,KAAK,KAAK,CAAC;AAC9C,QAAM,gBAAmC,EAAE,GAAG,cAAc,GAAG,eAAe;AAG9E,QAAM,MAA8B,CAAC;AACrC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,aAAa,GAAG;AACtD,UAAM,SAAS,4BAA4B,iBAAiB,GAAG,CAAC;AAChE,QAAI,MAAM,IAAI,OAAO,KAAK;AAE1B,YAAQ,IAAI,MAAM,IAAI,OAAO,KAAK;AAAA,EACtC;AAEA,SAAO;AAAA,IACH,GAAG;AAAA,IACH,KAAK;AAAA,MACD,GAAI,WAAW;AAAA,MACf,GAAG;AAAA,IACP;AAAA,EACJ;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../src/nextjs/withFeatureFlags.ts"],"sourcesContent":["/**\n * @deprecated Use `withSmooConfig` from `@smooai/config/nextjs/withSmooConfig` instead.\n *\n * This module is kept for backward compatibility. It wraps `withSmooConfig`\n * to provide the same feature-flag-only API.\n *\n * @example\n * ```ts\n * // Migrate from:\n * import { withFeatureFlags } from '@smooai/config/nextjs/withFeatureFlags';\n * const nextConfig = withFeatureFlags({ default: { aboutPage: false }, development: { aboutPage: true } });\n *\n * // To:\n * import { withSmooConfig } from '@smooai/config/nextjs/withSmooConfig';\n * const nextConfig = withSmooConfig({\n * default: { featureFlags: { aboutPage: false } },\n * development: { featureFlags: { aboutPage: true } },\n * });\n * ```\n */\n\nimport { withSmooConfig } from './withSmooConfig';\nimport type { WithSmooConfigOptions } from './withSmooConfig';\n\ntype NextConfig = Record<string, unknown>;\ntype FeatureFlagConfig = Record<string, boolean>;\n\ninterface WithFeatureFlagsOptions {\n /** Default feature flag values (used in production). */\n default: FeatureFlagConfig;\n /** Development overrides (merged with default). */\n development?: FeatureFlagConfig;\n /** Additional stage-specific overrides. Key is the stage name. */\n [stage: string]: FeatureFlagConfig | undefined;\n}\n\n/**\n * @deprecated Use `withSmooConfig` instead.\n *\n * Wraps a Next.js config to inject feature flags as NEXT_PUBLIC_ environment variables.\n * This is a backward-compatible wrapper around `withSmooConfig`.\n */\nexport function withFeatureFlags(flagConfigs: WithFeatureFlagsOptions, nextConfig: NextConfig = {}): NextConfig {\n // Convert the flat flag configs into SmooConfigValues format\n const smooOptions: WithSmooConfigOptions = { default: {} };\n\n for (const [stage, flags] of Object.entries(flagConfigs)) {\n if (flags !== undefined) {\n smooOptions[stage] = { featureFlags: flags };\n }\n }\n\n return withSmooConfig(smooOptions, nextConfig);\n}\n\n// Re-export withSmooConfig types and function for convenience\nexport { withSmooConfig } from './withSmooConfig';\nexport type { SmooConfigValues, WithSmooConfigOptions } from './withSmooConfig';\n"],"mappings":";;;;;;AA0CO,SAAS,iBAAiB,aAAsC,aAAyB,CAAC,GAAe;AAE5G,QAAM,cAAqC,EAAE,SAAS,CAAC,EAAE;AAEzD,aAAW,CAAC,OAAO,KAAK,KAAK,OAAO,QAAQ,WAAW,GAAG;AACtD,QAAI,UAAU,QAAW;AACrB,kBAAY,KAAK,IAAI,EAAE,cAAc,MAAM;AAAA,IAC/C;AAAA,EACJ;AAEA,SAAO,eAAe,aAAa,UAAU;AACjD;","names":[]}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Next.js config helper that injects feature flags AND public config
3
+ * as NEXT_PUBLIC_ environment variables.
4
+ *
5
+ * This is the unified replacement for `withFeatureFlags`, supporting both
6
+ * feature flags (NEXT_PUBLIC_FEATURE_FLAG_*) and public config values
7
+ * (NEXT_PUBLIC_CONFIG_*).
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * // next.config.ts
12
+ * import { withSmooConfig } from '@smooai/config/nextjs/withSmooConfig';
13
+ *
14
+ * const nextConfig = withSmooConfig({
15
+ * default: {
16
+ * featureFlags: { aboutPage: false, contactPage: true },
17
+ * publicConfig: { apiBaseUrl: 'https://api.smooai.com', maxRetries: 3 },
18
+ * },
19
+ * development: {
20
+ * featureFlags: { aboutPage: true },
21
+ * publicConfig: { apiBaseUrl: 'http://localhost:3000' },
22
+ * },
23
+ * });
24
+ *
25
+ * export default nextConfig;
26
+ * ```
27
+ *
28
+ * This will set environment variables like:
29
+ * - NEXT_PUBLIC_FEATURE_FLAG_ABOUT_PAGE=true (in development)
30
+ * - NEXT_PUBLIC_CONFIG_API_BASE_URL=http://localhost:3000 (in development)
31
+ *
32
+ * Then in any client component:
33
+ * ```tsx
34
+ * import { getClientFeatureFlag, getClientPublicConfig } from '@smooai/config/client';
35
+ * const isEnabled = getClientFeatureFlag('aboutPage');
36
+ * const apiUrl = getClientPublicConfig('apiBaseUrl');
37
+ * ```
38
+ */
39
+ type NextConfig = Record<string, unknown>;
40
+ interface SmooConfigValues {
41
+ /** Feature flag values (boolean). */
42
+ featureFlags?: Record<string, boolean>;
43
+ /** Public config values (string, number, or boolean). */
44
+ publicConfig?: Record<string, string | number | boolean>;
45
+ }
46
+ interface WithSmooConfigOptions {
47
+ /** Default config values (used in production). */
48
+ default: SmooConfigValues;
49
+ /** Development overrides (merged with default). */
50
+ development?: SmooConfigValues;
51
+ /** Additional stage-specific overrides. Key is the stage name. */
52
+ [stage: string]: SmooConfigValues | undefined;
53
+ }
54
+ /**
55
+ * Wraps a Next.js config to inject feature flags and public config
56
+ * as NEXT_PUBLIC_ environment variables.
57
+ *
58
+ * Reads `NEXT_PUBLIC_SST_STAGE` (or `NODE_ENV`) to determine which config to use.
59
+ * Falls back to development config if stage is not 'production'.
60
+ */
61
+ declare function withSmooConfig(options: WithSmooConfigOptions, nextConfig?: NextConfig): NextConfig;
62
+
63
+ export { type SmooConfigValues, type WithSmooConfigOptions, withSmooConfig };
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Next.js config helper that injects feature flags AND public config
3
+ * as NEXT_PUBLIC_ environment variables.
4
+ *
5
+ * This is the unified replacement for `withFeatureFlags`, supporting both
6
+ * feature flags (NEXT_PUBLIC_FEATURE_FLAG_*) and public config values
7
+ * (NEXT_PUBLIC_CONFIG_*).
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * // next.config.ts
12
+ * import { withSmooConfig } from '@smooai/config/nextjs/withSmooConfig';
13
+ *
14
+ * const nextConfig = withSmooConfig({
15
+ * default: {
16
+ * featureFlags: { aboutPage: false, contactPage: true },
17
+ * publicConfig: { apiBaseUrl: 'https://api.smooai.com', maxRetries: 3 },
18
+ * },
19
+ * development: {
20
+ * featureFlags: { aboutPage: true },
21
+ * publicConfig: { apiBaseUrl: 'http://localhost:3000' },
22
+ * },
23
+ * });
24
+ *
25
+ * export default nextConfig;
26
+ * ```
27
+ *
28
+ * This will set environment variables like:
29
+ * - NEXT_PUBLIC_FEATURE_FLAG_ABOUT_PAGE=true (in development)
30
+ * - NEXT_PUBLIC_CONFIG_API_BASE_URL=http://localhost:3000 (in development)
31
+ *
32
+ * Then in any client component:
33
+ * ```tsx
34
+ * import { getClientFeatureFlag, getClientPublicConfig } from '@smooai/config/client';
35
+ * const isEnabled = getClientFeatureFlag('aboutPage');
36
+ * const apiUrl = getClientPublicConfig('apiBaseUrl');
37
+ * ```
38
+ */
39
+ type NextConfig = Record<string, unknown>;
40
+ interface SmooConfigValues {
41
+ /** Feature flag values (boolean). */
42
+ featureFlags?: Record<string, boolean>;
43
+ /** Public config values (string, number, or boolean). */
44
+ publicConfig?: Record<string, string | number | boolean>;
45
+ }
46
+ interface WithSmooConfigOptions {
47
+ /** Default config values (used in production). */
48
+ default: SmooConfigValues;
49
+ /** Development overrides (merged with default). */
50
+ development?: SmooConfigValues;
51
+ /** Additional stage-specific overrides. Key is the stage name. */
52
+ [stage: string]: SmooConfigValues | undefined;
53
+ }
54
+ /**
55
+ * Wraps a Next.js config to inject feature flags and public config
56
+ * as NEXT_PUBLIC_ environment variables.
57
+ *
58
+ * Reads `NEXT_PUBLIC_SST_STAGE` (or `NODE_ENV`) to determine which config to use.
59
+ * Falls back to development config if stage is not 'production'.
60
+ */
61
+ declare function withSmooConfig(options: WithSmooConfigOptions, nextConfig?: NextConfig): NextConfig;
62
+
63
+ export { type SmooConfigValues, type WithSmooConfigOptions, withSmooConfig };
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/nextjs/withSmooConfig.ts
21
+ var withSmooConfig_exports = {};
22
+ __export(withSmooConfig_exports, {
23
+ withSmooConfig: () => withSmooConfig
24
+ });
25
+ module.exports = __toCommonJS(withSmooConfig_exports);
26
+ function toUpperSnakeCase(key) {
27
+ return key.replace(/([A-Z])/g, "_$1").toUpperCase();
28
+ }
29
+ function withSmooConfig(options, nextConfig = {}) {
30
+ const stage = process.env.NEXT_PUBLIC_SST_STAGE ?? (process.env.NODE_ENV === "production" ? "production" : "development");
31
+ const defaultValues = options.default ?? {};
32
+ const stageOverrides = options[stage] ?? {};
33
+ const resolvedFlags = {
34
+ ...defaultValues.featureFlags,
35
+ ...stageOverrides.featureFlags
36
+ };
37
+ const resolvedConfig = {
38
+ ...defaultValues.publicConfig,
39
+ ...stageOverrides.publicConfig
40
+ };
41
+ const env = {};
42
+ for (const [key, value] of Object.entries(resolvedFlags)) {
43
+ const envKey = `NEXT_PUBLIC_FEATURE_FLAG_${toUpperSnakeCase(key)}`;
44
+ env[envKey] = String(value);
45
+ process.env[envKey] = String(value);
46
+ }
47
+ for (const [key, value] of Object.entries(resolvedConfig)) {
48
+ const envKey = `NEXT_PUBLIC_CONFIG_${toUpperSnakeCase(key)}`;
49
+ env[envKey] = String(value);
50
+ process.env[envKey] = String(value);
51
+ }
52
+ return {
53
+ ...nextConfig,
54
+ env: {
55
+ ...nextConfig.env,
56
+ ...env
57
+ }
58
+ };
59
+ }
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ withSmooConfig
63
+ });
64
+ //# sourceMappingURL=withSmooConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/nextjs/withSmooConfig.ts"],"sourcesContent":["/**\n * Next.js config helper that injects feature flags AND public config\n * as NEXT_PUBLIC_ environment variables.\n *\n * This is the unified replacement for `withFeatureFlags`, supporting both\n * feature flags (NEXT_PUBLIC_FEATURE_FLAG_*) and public config values\n * (NEXT_PUBLIC_CONFIG_*).\n *\n * @example\n * ```ts\n * // next.config.ts\n * import { withSmooConfig } from '@smooai/config/nextjs/withSmooConfig';\n *\n * const nextConfig = withSmooConfig({\n * default: {\n * featureFlags: { aboutPage: false, contactPage: true },\n * publicConfig: { apiBaseUrl: 'https://api.smooai.com', maxRetries: 3 },\n * },\n * development: {\n * featureFlags: { aboutPage: true },\n * publicConfig: { apiBaseUrl: 'http://localhost:3000' },\n * },\n * });\n *\n * export default nextConfig;\n * ```\n *\n * This will set environment variables like:\n * - NEXT_PUBLIC_FEATURE_FLAG_ABOUT_PAGE=true (in development)\n * - NEXT_PUBLIC_CONFIG_API_BASE_URL=http://localhost:3000 (in development)\n *\n * Then in any client component:\n * ```tsx\n * import { getClientFeatureFlag, getClientPublicConfig } from '@smooai/config/client';\n * const isEnabled = getClientFeatureFlag('aboutPage');\n * const apiUrl = getClientPublicConfig('apiBaseUrl');\n * ```\n */\n\ntype NextConfig = Record<string, unknown>;\n\nexport interface SmooConfigValues {\n /** Feature flag values (boolean). */\n featureFlags?: Record<string, boolean>;\n /** Public config values (string, number, or boolean). */\n publicConfig?: Record<string, string | number | boolean>;\n}\n\nexport interface WithSmooConfigOptions {\n /** Default config values (used in production). */\n default: SmooConfigValues;\n /** Development overrides (merged with default). */\n development?: SmooConfigValues;\n /** Additional stage-specific overrides. Key is the stage name. */\n [stage: string]: SmooConfigValues | undefined;\n}\n\n/**\n * Convert a camelCase key to UPPER_SNAKE_CASE.\n * e.g., \"aboutPage\" → \"ABOUT_PAGE\"\n */\nfunction toUpperSnakeCase(key: string): string {\n return key.replace(/([A-Z])/g, '_$1').toUpperCase();\n}\n\n/**\n * Wraps a Next.js config to inject feature flags and public config\n * as NEXT_PUBLIC_ environment variables.\n *\n * Reads `NEXT_PUBLIC_SST_STAGE` (or `NODE_ENV`) to determine which config to use.\n * Falls back to development config if stage is not 'production'.\n */\nexport function withSmooConfig(options: WithSmooConfigOptions, nextConfig: NextConfig = {}): NextConfig {\n const stage = process.env.NEXT_PUBLIC_SST_STAGE ?? (process.env.NODE_ENV === 'production' ? 'production' : 'development');\n\n // Merge default with stage-specific overrides\n const defaultValues = options.default ?? {};\n const stageOverrides = options[stage] ?? {};\n\n const resolvedFlags: Record<string, boolean> = {\n ...defaultValues.featureFlags,\n ...stageOverrides.featureFlags,\n };\n\n const resolvedConfig: Record<string, string | number | boolean> = {\n ...defaultValues.publicConfig,\n ...stageOverrides.publicConfig,\n };\n\n // Inject as NEXT_PUBLIC_ env vars\n const env: Record<string, string> = {};\n\n // Feature flags → NEXT_PUBLIC_FEATURE_FLAG_*\n for (const [key, value] of Object.entries(resolvedFlags)) {\n const envKey = `NEXT_PUBLIC_FEATURE_FLAG_${toUpperSnakeCase(key)}`;\n env[envKey] = String(value);\n // Also set in process.env for SSR\n process.env[envKey] = String(value);\n }\n\n // Public config → NEXT_PUBLIC_CONFIG_*\n for (const [key, value] of Object.entries(resolvedConfig)) {\n const envKey = `NEXT_PUBLIC_CONFIG_${toUpperSnakeCase(key)}`;\n env[envKey] = String(value);\n // Also set in process.env for SSR\n process.env[envKey] = String(value);\n }\n\n return {\n ...nextConfig,\n env: {\n ...(nextConfig.env as Record<string, string> | undefined),\n ...env,\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6DA,SAAS,iBAAiB,KAAqB;AAC3C,SAAO,IAAI,QAAQ,YAAY,KAAK,EAAE,YAAY;AACtD;AASO,SAAS,eAAe,SAAgC,aAAyB,CAAC,GAAe;AACpG,QAAM,QAAQ,QAAQ,IAAI,0BAA0B,QAAQ,IAAI,aAAa,eAAe,eAAe;AAG3G,QAAM,gBAAgB,QAAQ,WAAW,CAAC;AAC1C,QAAM,iBAAiB,QAAQ,KAAK,KAAK,CAAC;AAE1C,QAAM,gBAAyC;AAAA,IAC3C,GAAG,cAAc;AAAA,IACjB,GAAG,eAAe;AAAA,EACtB;AAEA,QAAM,iBAA4D;AAAA,IAC9D,GAAG,cAAc;AAAA,IACjB,GAAG,eAAe;AAAA,EACtB;AAGA,QAAM,MAA8B,CAAC;AAGrC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,aAAa,GAAG;AACtD,UAAM,SAAS,4BAA4B,iBAAiB,GAAG,CAAC;AAChE,QAAI,MAAM,IAAI,OAAO,KAAK;AAE1B,YAAQ,IAAI,MAAM,IAAI,OAAO,KAAK;AAAA,EACtC;AAGA,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,cAAc,GAAG;AACvD,UAAM,SAAS,sBAAsB,iBAAiB,GAAG,CAAC;AAC1D,QAAI,MAAM,IAAI,OAAO,KAAK;AAE1B,YAAQ,IAAI,MAAM,IAAI,OAAO,KAAK;AAAA,EACtC;AAEA,SAAO;AAAA,IACH,GAAG;AAAA,IACH,KAAK;AAAA,MACD,GAAI,WAAW;AAAA,MACf,GAAG;AAAA,IACP;AAAA,EACJ;AACJ;","names":[]}
@@ -0,0 +1,8 @@
1
+ import {
2
+ withSmooConfig
3
+ } from "../chunk-SAX775JO.mjs";
4
+ import "../chunk-J5LGTIGS.mjs";
5
+ export {
6
+ withSmooConfig
7
+ };
8
+ //# sourceMappingURL=withSmooConfig.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  buildConfigObject
3
- } from "../../chunk-2DYBQ6SF.mjs";
4
- import "../../chunk-PCXGCPWC.mjs";
5
- import "../../chunk-7GMXNAVA.mjs";
6
- import "../../chunk-VLAIJ4S7.mjs";
3
+ } from "../../chunk-43SVVFYE.mjs";
4
+ import "../../chunk-6XDO5B2T.mjs";
5
+ import "../../chunk-PD2SHA7M.mjs";
7
6
  import "../../chunk-XKVOJHYW.mjs";
8
- import "../../chunk-JAEJOSH5.mjs";
9
- import "../../chunk-7CCXEKIK.mjs";
10
- import "../../chunk-LPEA3TRJ.mjs";
11
- import "../../chunk-CASNDTCH.mjs";
7
+ import "../../chunk-VLAIJ4S7.mjs";
12
8
  import "../../chunk-5J6U77AV.mjs";
9
+ import "../../chunk-NF7JF2UP.mjs";
10
+ import "../../chunk-H4YT7JJJ.mjs";
11
+ import "../../chunk-LPEA3TRJ.mjs";
13
12
  import "../../chunk-UWV4ZGVI.mjs";
13
+ import "../../chunk-CASNDTCH.mjs";
14
14
  import "../../chunk-J5LGTIGS.mjs";
15
15
  export {
16
16
  buildConfigObject as default
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  buildConfigObject
3
- } from "../../chunk-2DYBQ6SF.mjs";
4
- import "../../chunk-PCXGCPWC.mjs";
5
- import "../../chunk-7GMXNAVA.mjs";
6
- import "../../chunk-VLAIJ4S7.mjs";
3
+ } from "../../chunk-43SVVFYE.mjs";
4
+ import "../../chunk-6XDO5B2T.mjs";
5
+ import "../../chunk-PD2SHA7M.mjs";
7
6
  import "../../chunk-XKVOJHYW.mjs";
8
- import "../../chunk-JAEJOSH5.mjs";
9
- import "../../chunk-7CCXEKIK.mjs";
10
- import "../../chunk-LPEA3TRJ.mjs";
11
- import "../../chunk-CASNDTCH.mjs";
7
+ import "../../chunk-VLAIJ4S7.mjs";
12
8
  import "../../chunk-5J6U77AV.mjs";
9
+ import "../../chunk-NF7JF2UP.mjs";
10
+ import "../../chunk-H4YT7JJJ.mjs";
11
+ import "../../chunk-LPEA3TRJ.mjs";
13
12
  import "../../chunk-UWV4ZGVI.mjs";
13
+ import "../../chunk-CASNDTCH.mjs";
14
14
  import "../../chunk-J5LGTIGS.mjs";
15
15
 
16
16
  // src/platform/server/server.featureFlag.sync.ts
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  buildConfigObject
3
- } from "../../chunk-2DYBQ6SF.mjs";
4
- import "../../chunk-PCXGCPWC.mjs";
5
- import "../../chunk-7GMXNAVA.mjs";
6
- import "../../chunk-VLAIJ4S7.mjs";
3
+ } from "../../chunk-43SVVFYE.mjs";
4
+ import "../../chunk-6XDO5B2T.mjs";
5
+ import "../../chunk-PD2SHA7M.mjs";
7
6
  import "../../chunk-XKVOJHYW.mjs";
8
- import "../../chunk-JAEJOSH5.mjs";
9
- import "../../chunk-7CCXEKIK.mjs";
10
- import "../../chunk-LPEA3TRJ.mjs";
11
- import "../../chunk-CASNDTCH.mjs";
7
+ import "../../chunk-VLAIJ4S7.mjs";
12
8
  import "../../chunk-5J6U77AV.mjs";
9
+ import "../../chunk-NF7JF2UP.mjs";
10
+ import "../../chunk-H4YT7JJJ.mjs";
11
+ import "../../chunk-LPEA3TRJ.mjs";
13
12
  import "../../chunk-UWV4ZGVI.mjs";
13
+ import "../../chunk-CASNDTCH.mjs";
14
14
  import "../../chunk-J5LGTIGS.mjs";
15
15
 
16
16
  // src/platform/server/server.publicConfig.sync.ts
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  buildConfigObject
3
- } from "../../chunk-2DYBQ6SF.mjs";
4
- import "../../chunk-PCXGCPWC.mjs";
5
- import "../../chunk-7GMXNAVA.mjs";
6
- import "../../chunk-VLAIJ4S7.mjs";
3
+ } from "../../chunk-43SVVFYE.mjs";
4
+ import "../../chunk-6XDO5B2T.mjs";
5
+ import "../../chunk-PD2SHA7M.mjs";
7
6
  import "../../chunk-XKVOJHYW.mjs";
8
- import "../../chunk-JAEJOSH5.mjs";
9
- import "../../chunk-7CCXEKIK.mjs";
10
- import "../../chunk-LPEA3TRJ.mjs";
11
- import "../../chunk-CASNDTCH.mjs";
7
+ import "../../chunk-VLAIJ4S7.mjs";
12
8
  import "../../chunk-5J6U77AV.mjs";
9
+ import "../../chunk-NF7JF2UP.mjs";
10
+ import "../../chunk-H4YT7JJJ.mjs";
11
+ import "../../chunk-LPEA3TRJ.mjs";
13
12
  import "../../chunk-UWV4ZGVI.mjs";
13
+ import "../../chunk-CASNDTCH.mjs";
14
14
  import "../../chunk-J5LGTIGS.mjs";
15
15
 
16
16
  // src/platform/server/server.secretConfig.sync.ts
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  buildConfigObject
3
- } from "../chunk-2DYBQ6SF.mjs";
4
- import "../chunk-PCXGCPWC.mjs";
5
- import "../chunk-7GMXNAVA.mjs";
6
- import "../chunk-VLAIJ4S7.mjs";
3
+ } from "../chunk-43SVVFYE.mjs";
4
+ import "../chunk-6XDO5B2T.mjs";
5
+ import "../chunk-PD2SHA7M.mjs";
7
6
  import "../chunk-XKVOJHYW.mjs";
8
- import "../chunk-JAEJOSH5.mjs";
9
- import "../chunk-7CCXEKIK.mjs";
10
- import "../chunk-LPEA3TRJ.mjs";
11
- import "../chunk-CASNDTCH.mjs";
7
+ import "../chunk-VLAIJ4S7.mjs";
12
8
  import "../chunk-5J6U77AV.mjs";
9
+ import "../chunk-NF7JF2UP.mjs";
10
+ import "../chunk-H4YT7JJJ.mjs";
11
+ import "../chunk-LPEA3TRJ.mjs";
13
12
  import "../chunk-UWV4ZGVI.mjs";
13
+ import "../chunk-CASNDTCH.mjs";
14
14
  import "../chunk-J5LGTIGS.mjs";
15
15
 
16
16
  // src/platform/server.ts