@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,41 @@
|
|
|
1
|
+
export { SmooConfigValues, WithSmooConfigOptions, withSmooConfig } from './withSmooConfig.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use `withSmooConfig` from `@smooai/config/nextjs/withSmooConfig` instead.
|
|
5
|
+
*
|
|
6
|
+
* This module is kept for backward compatibility. It wraps `withSmooConfig`
|
|
7
|
+
* to provide the same feature-flag-only API.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* // Migrate from:
|
|
12
|
+
* import { withFeatureFlags } from '@smooai/config/nextjs/withFeatureFlags';
|
|
13
|
+
* const nextConfig = withFeatureFlags({ default: { aboutPage: false }, development: { aboutPage: true } });
|
|
14
|
+
*
|
|
15
|
+
* // To:
|
|
16
|
+
* import { withSmooConfig } from '@smooai/config/nextjs/withSmooConfig';
|
|
17
|
+
* const nextConfig = withSmooConfig({
|
|
18
|
+
* default: { featureFlags: { aboutPage: false } },
|
|
19
|
+
* development: { featureFlags: { aboutPage: true } },
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
type NextConfig = Record<string, unknown>;
|
|
24
|
+
type FeatureFlagConfig = Record<string, boolean>;
|
|
25
|
+
interface WithFeatureFlagsOptions {
|
|
26
|
+
/** Default feature flag values (used in production). */
|
|
27
|
+
default: FeatureFlagConfig;
|
|
28
|
+
/** Development overrides (merged with default). */
|
|
29
|
+
development?: FeatureFlagConfig;
|
|
30
|
+
/** Additional stage-specific overrides. Key is the stage name. */
|
|
31
|
+
[stage: string]: FeatureFlagConfig | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated Use `withSmooConfig` instead.
|
|
35
|
+
*
|
|
36
|
+
* Wraps a Next.js config to inject feature flags as NEXT_PUBLIC_ environment variables.
|
|
37
|
+
* This is a backward-compatible wrapper around `withSmooConfig`.
|
|
38
|
+
*/
|
|
39
|
+
declare function withFeatureFlags(flagConfigs: WithFeatureFlagsOptions, nextConfig?: NextConfig): NextConfig;
|
|
40
|
+
|
|
41
|
+
export { withFeatureFlags };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export { SmooConfigValues, WithSmooConfigOptions, withSmooConfig } from './withSmooConfig.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use `withSmooConfig` from `@smooai/config/nextjs/withSmooConfig` instead.
|
|
5
|
+
*
|
|
6
|
+
* This module is kept for backward compatibility. It wraps `withSmooConfig`
|
|
7
|
+
* to provide the same feature-flag-only API.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* // Migrate from:
|
|
12
|
+
* import { withFeatureFlags } from '@smooai/config/nextjs/withFeatureFlags';
|
|
13
|
+
* const nextConfig = withFeatureFlags({ default: { aboutPage: false }, development: { aboutPage: true } });
|
|
14
|
+
*
|
|
15
|
+
* // To:
|
|
16
|
+
* import { withSmooConfig } from '@smooai/config/nextjs/withSmooConfig';
|
|
17
|
+
* const nextConfig = withSmooConfig({
|
|
18
|
+
* default: { featureFlags: { aboutPage: false } },
|
|
19
|
+
* development: { featureFlags: { aboutPage: true } },
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
type NextConfig = Record<string, unknown>;
|
|
24
|
+
type FeatureFlagConfig = Record<string, boolean>;
|
|
25
|
+
interface WithFeatureFlagsOptions {
|
|
26
|
+
/** Default feature flag values (used in production). */
|
|
27
|
+
default: FeatureFlagConfig;
|
|
28
|
+
/** Development overrides (merged with default). */
|
|
29
|
+
development?: FeatureFlagConfig;
|
|
30
|
+
/** Additional stage-specific overrides. Key is the stage name. */
|
|
31
|
+
[stage: string]: FeatureFlagConfig | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated Use `withSmooConfig` instead.
|
|
35
|
+
*
|
|
36
|
+
* Wraps a Next.js config to inject feature flags as NEXT_PUBLIC_ environment variables.
|
|
37
|
+
* This is a backward-compatible wrapper around `withSmooConfig`.
|
|
38
|
+
*/
|
|
39
|
+
declare function withFeatureFlags(flagConfigs: WithFeatureFlagsOptions, nextConfig?: NextConfig): NextConfig;
|
|
40
|
+
|
|
41
|
+
export { withFeatureFlags };
|
|
@@ -0,0 +1,79 @@
|
|
|
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/withFeatureFlags.ts
|
|
21
|
+
var withFeatureFlags_exports = {};
|
|
22
|
+
__export(withFeatureFlags_exports, {
|
|
23
|
+
withFeatureFlags: () => withFeatureFlags,
|
|
24
|
+
withSmooConfig: () => withSmooConfig
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(withFeatureFlags_exports);
|
|
27
|
+
|
|
28
|
+
// src/nextjs/withSmooConfig.ts
|
|
29
|
+
function toUpperSnakeCase(key) {
|
|
30
|
+
return key.replace(/([A-Z])/g, "_$1").toUpperCase();
|
|
31
|
+
}
|
|
32
|
+
function withSmooConfig(options, nextConfig = {}) {
|
|
33
|
+
const stage = process.env.NEXT_PUBLIC_SST_STAGE ?? (process.env.NODE_ENV === "production" ? "production" : "development");
|
|
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
|
+
};
|
|
44
|
+
const env = {};
|
|
45
|
+
for (const [key, value] of Object.entries(resolvedFlags)) {
|
|
46
|
+
const envKey = `NEXT_PUBLIC_FEATURE_FLAG_${toUpperSnakeCase(key)}`;
|
|
47
|
+
env[envKey] = String(value);
|
|
48
|
+
process.env[envKey] = String(value);
|
|
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
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
...nextConfig,
|
|
57
|
+
env: {
|
|
58
|
+
...nextConfig.env,
|
|
59
|
+
...env
|
|
60
|
+
}
|
|
61
|
+
};
|
|
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
|
+
}
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
withFeatureFlags,
|
|
77
|
+
withSmooConfig
|
|
78
|
+
});
|
|
79
|
+
//# sourceMappingURL=withFeatureFlags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
withSmooConfig
|
|
3
|
+
} from "../chunk-SAX775JO.mjs";
|
|
4
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
5
|
+
|
|
6
|
+
// src/nextjs/withFeatureFlags.ts
|
|
7
|
+
function withFeatureFlags(flagConfigs, nextConfig = {}) {
|
|
8
|
+
const smooOptions = { default: {} };
|
|
9
|
+
for (const [stage, flags] of Object.entries(flagConfigs)) {
|
|
10
|
+
if (flags !== void 0) {
|
|
11
|
+
smooOptions[stage] = { featureFlags: flags };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return withSmooConfig(smooOptions, nextConfig);
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
withFeatureFlags,
|
|
18
|
+
withSmooConfig
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=withFeatureFlags.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildConfigObject
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
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-
|
|
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-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
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-
|
|
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-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
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-
|
|
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-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
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-
|
|
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
|
package/dist/platform/server.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildConfigObject
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
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-
|
|
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
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Vite plugin that injects feature flags and public config as
|
|
5
|
+
* VITE_FEATURE_FLAG_* and VITE_CONFIG_* environment variables.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* // vite.config.ts
|
|
10
|
+
* import { smooConfigPlugin } from '@smooai/config/vite/smooConfigPlugin';
|
|
11
|
+
*
|
|
12
|
+
* export default defineConfig({
|
|
13
|
+
* plugins: [
|
|
14
|
+
* smooConfigPlugin({
|
|
15
|
+
* featureFlags: { aboutPage: true, contactPage: false },
|
|
16
|
+
* publicConfig: { apiBaseUrl: 'http://localhost:3000' },
|
|
17
|
+
* stage: 'development',
|
|
18
|
+
* }),
|
|
19
|
+
* ],
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Then in client code:
|
|
24
|
+
* ```tsx
|
|
25
|
+
* import { getClientFeatureFlag, getClientPublicConfig } from '@smooai/config/client';
|
|
26
|
+
* const isEnabled = getClientFeatureFlag('aboutPage');
|
|
27
|
+
* const apiUrl = getClientPublicConfig('apiBaseUrl');
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
interface SmooConfigPluginOptions {
|
|
32
|
+
/** Feature flag values (boolean). */
|
|
33
|
+
featureFlags?: Record<string, boolean>;
|
|
34
|
+
/** Public config values (string, number, or boolean). */
|
|
35
|
+
publicConfig?: Record<string, string | number | boolean>;
|
|
36
|
+
/** Optional stage name — currently informational; config resolution should happen before calling the plugin. */
|
|
37
|
+
stage?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Vite plugin that injects feature flags and public config as environment variables.
|
|
41
|
+
*
|
|
42
|
+
* Sets `process.env.VITE_FEATURE_FLAG_*` and `process.env.VITE_CONFIG_*` in the
|
|
43
|
+
* Vite `config` hook so they are available at build time via `import.meta.env`.
|
|
44
|
+
*/
|
|
45
|
+
declare function smooConfigPlugin(options: SmooConfigPluginOptions): Plugin;
|
|
46
|
+
|
|
47
|
+
export { type SmooConfigPluginOptions, smooConfigPlugin };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Vite plugin that injects feature flags and public config as
|
|
5
|
+
* VITE_FEATURE_FLAG_* and VITE_CONFIG_* environment variables.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* // vite.config.ts
|
|
10
|
+
* import { smooConfigPlugin } from '@smooai/config/vite/smooConfigPlugin';
|
|
11
|
+
*
|
|
12
|
+
* export default defineConfig({
|
|
13
|
+
* plugins: [
|
|
14
|
+
* smooConfigPlugin({
|
|
15
|
+
* featureFlags: { aboutPage: true, contactPage: false },
|
|
16
|
+
* publicConfig: { apiBaseUrl: 'http://localhost:3000' },
|
|
17
|
+
* stage: 'development',
|
|
18
|
+
* }),
|
|
19
|
+
* ],
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Then in client code:
|
|
24
|
+
* ```tsx
|
|
25
|
+
* import { getClientFeatureFlag, getClientPublicConfig } from '@smooai/config/client';
|
|
26
|
+
* const isEnabled = getClientFeatureFlag('aboutPage');
|
|
27
|
+
* const apiUrl = getClientPublicConfig('apiBaseUrl');
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
interface SmooConfigPluginOptions {
|
|
32
|
+
/** Feature flag values (boolean). */
|
|
33
|
+
featureFlags?: Record<string, boolean>;
|
|
34
|
+
/** Public config values (string, number, or boolean). */
|
|
35
|
+
publicConfig?: Record<string, string | number | boolean>;
|
|
36
|
+
/** Optional stage name — currently informational; config resolution should happen before calling the plugin. */
|
|
37
|
+
stage?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Vite plugin that injects feature flags and public config as environment variables.
|
|
41
|
+
*
|
|
42
|
+
* Sets `process.env.VITE_FEATURE_FLAG_*` and `process.env.VITE_CONFIG_*` in the
|
|
43
|
+
* Vite `config` hook so they are available at build time via `import.meta.env`.
|
|
44
|
+
*/
|
|
45
|
+
declare function smooConfigPlugin(options: SmooConfigPluginOptions): Plugin;
|
|
46
|
+
|
|
47
|
+
export { type SmooConfigPluginOptions, smooConfigPlugin };
|