@smooai/config 2.0.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/LICENSE +21 -0
- package/README.md +430 -0
- package/dist/chunk-3SU3SMKN.mjs +73 -0
- package/dist/chunk-3SU3SMKN.mjs.map +1 -0
- package/dist/chunk-CASNDTCH.mjs +12 -0
- package/dist/chunk-CASNDTCH.mjs.map +1 -0
- package/dist/chunk-GLLYQ6FK.mjs +173 -0
- package/dist/chunk-GLLYQ6FK.mjs.map +1 -0
- package/dist/chunk-HPSOF46N.mjs +71 -0
- package/dist/chunk-HPSOF46N.mjs.map +1 -0
- package/dist/chunk-HPXCKD6M.mjs +118 -0
- package/dist/chunk-HPXCKD6M.mjs.map +1 -0
- package/dist/chunk-J5LGTIGS.mjs +10 -0
- package/dist/chunk-J5LGTIGS.mjs.map +1 -0
- package/dist/chunk-LKV73SD2.mjs +25 -0
- package/dist/chunk-LKV73SD2.mjs.map +1 -0
- package/dist/chunk-MJ52ZIWV.mjs +98 -0
- package/dist/chunk-MJ52ZIWV.mjs.map +1 -0
- package/dist/chunk-O7BSFCCY.mjs +89 -0
- package/dist/chunk-O7BSFCCY.mjs.map +1 -0
- package/dist/chunk-QBM74JB5.mjs +47 -0
- package/dist/chunk-QBM74JB5.mjs.map +1 -0
- package/dist/chunk-QGMLTMB5.mjs +37 -0
- package/dist/chunk-QGMLTMB5.mjs.map +1 -0
- package/dist/chunk-SKX7CPGS.mjs +73 -0
- package/dist/chunk-SKX7CPGS.mjs.map +1 -0
- package/dist/chunk-VPKO6D4W.mjs +33 -0
- package/dist/chunk-VPKO6D4W.mjs.map +1 -0
- package/dist/chunk-YQWYYS7P.mjs +12194 -0
- package/dist/chunk-YQWYYS7P.mjs.map +1 -0
- package/dist/chunk-Z3CZGNU5.mjs +99 -0
- package/dist/chunk-Z3CZGNU5.mjs.map +1 -0
- package/dist/chunk-ZOKHXR5I.mjs +33 -0
- package/dist/chunk-ZOKHXR5I.mjs.map +1 -0
- package/dist/cli.mjs +1562 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/config/FeatureFlagKey.d.mts +24 -0
- package/dist/config/FeatureFlagKey.d.ts +24 -0
- package/dist/config/FeatureFlagKey.js +31 -0
- package/dist/config/FeatureFlagKey.js.map +1 -0
- package/dist/config/FeatureFlagKey.mjs +8 -0
- package/dist/config/FeatureFlagKey.mjs.map +1 -0
- package/dist/config/PublicConfigKey.d.mts +22 -0
- package/dist/config/PublicConfigKey.d.ts +22 -0
- package/dist/config/PublicConfigKey.js +36 -0
- package/dist/config/PublicConfigKey.js.map +1 -0
- package/dist/config/PublicConfigKey.mjs +8 -0
- package/dist/config/PublicConfigKey.mjs.map +1 -0
- package/dist/config/SecretConfigKey.d.mts +22 -0
- package/dist/config/SecretConfigKey.d.ts +22 -0
- package/dist/config/SecretConfigKey.js +31 -0
- package/dist/config/SecretConfigKey.js.map +1 -0
- package/dist/config/SecretConfigKey.mjs +8 -0
- package/dist/config/SecretConfigKey.mjs.map +1 -0
- package/dist/config/config.d.mts +178 -0
- package/dist/config/config.d.ts +178 -0
- package/dist/config/config.js +12364 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/config.mjs +23 -0
- package/dist/config/config.mjs.map +1 -0
- package/dist/config/findAndProcessEnvConfig.d.mts +17 -0
- package/dist/config/findAndProcessEnvConfig.d.ts +17 -0
- package/dist/config/findAndProcessEnvConfig.js +12290 -0
- package/dist/config/findAndProcessEnvConfig.js.map +1 -0
- package/dist/config/findAndProcessEnvConfig.mjs +14 -0
- package/dist/config/findAndProcessEnvConfig.mjs.map +1 -0
- package/dist/config/findAndProcessFileConfig.d.mts +38 -0
- package/dist/config/findAndProcessFileConfig.d.ts +38 -0
- package/dist/config/findAndProcessFileConfig.js +12431 -0
- package/dist/config/findAndProcessFileConfig.js.map +1 -0
- package/dist/config/findAndProcessFileConfig.mjs +18 -0
- package/dist/config/findAndProcessFileConfig.mjs.map +1 -0
- package/dist/config/getCloudRegion.d.mts +8 -0
- package/dist/config/getCloudRegion.d.ts +8 -0
- package/dist/config/getCloudRegion.js +92 -0
- package/dist/config/getCloudRegion.js.map +1 -0
- package/dist/config/getCloudRegion.mjs +9 -0
- package/dist/config/getCloudRegion.mjs.map +1 -0
- package/dist/config/index.d.mts +5 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.js +12638 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/index.mjs +33 -0
- package/dist/config/index.mjs.map +1 -0
- package/dist/config/parseConfigSchema.d.mts +13 -0
- package/dist/config/parseConfigSchema.d.ts +13 -0
- package/dist/config/parseConfigSchema.js +12177 -0
- package/dist/config/parseConfigSchema.js.map +1 -0
- package/dist/config/parseConfigSchema.mjs +16 -0
- package/dist/config/parseConfigSchema.mjs.map +1 -0
- package/dist/config/standardSchemaToJson.d.mts +6 -0
- package/dist/config/standardSchemaToJson.d.ts +6 -0
- package/dist/config/standardSchemaToJson.js +138 -0
- package/dist/config/standardSchemaToJson.js.map +1 -0
- package/dist/config/standardSchemaToJson.mjs +9 -0
- package/dist/config/standardSchemaToJson.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -0
- package/dist/integration-tests/1/smooai-config/config.d.mts +4108 -0
- package/dist/integration-tests/1/smooai-config/config.d.ts +4108 -0
- package/dist/integration-tests/1/smooai-config/config.js +12353 -0
- package/dist/integration-tests/1/smooai-config/config.js.map +1 -0
- package/dist/integration-tests/1/smooai-config/config.mjs +12 -0
- package/dist/integration-tests/1/smooai-config/config.mjs.map +1 -0
- package/dist/integration-tests/1/smooai-config/default.d.mts +55 -0
- package/dist/integration-tests/1/smooai-config/default.d.ts +55 -0
- package/dist/integration-tests/1/smooai-config/default.js +12419 -0
- package/dist/integration-tests/1/smooai-config/default.js.map +1 -0
- package/dist/integration-tests/1/smooai-config/default.mjs +78 -0
- package/dist/integration-tests/1/smooai-config/default.mjs.map +1 -0
- package/dist/integration-tests/1/smooai-config/development.d.mts +41 -0
- package/dist/integration-tests/1/smooai-config/development.d.ts +41 -0
- package/dist/integration-tests/1/smooai-config/development.js +12403 -0
- package/dist/integration-tests/1/smooai-config/development.js.map +1 -0
- package/dist/integration-tests/1/smooai-config/development.mjs +62 -0
- package/dist/integration-tests/1/smooai-config/development.mjs.map +1 -0
- package/dist/integration-tests/1/smooai-config/production.aws.d.mts +128 -0
- package/dist/integration-tests/1/smooai-config/production.aws.d.ts +128 -0
- package/dist/integration-tests/1/smooai-config/production.aws.js +12371 -0
- package/dist/integration-tests/1/smooai-config/production.aws.js.map +1 -0
- package/dist/integration-tests/1/smooai-config/production.aws.mjs +30 -0
- package/dist/integration-tests/1/smooai-config/production.aws.mjs.map +1 -0
- package/dist/integration-tests/1/smooai-config/production.aws.us-east-1.d.mts +64 -0
- package/dist/integration-tests/1/smooai-config/production.aws.us-east-1.d.ts +64 -0
- package/dist/integration-tests/1/smooai-config/production.aws.us-east-1.js +12364 -0
- package/dist/integration-tests/1/smooai-config/production.aws.us-east-1.js.map +1 -0
- package/dist/integration-tests/1/smooai-config/production.aws.us-east-1.mjs +23 -0
- package/dist/integration-tests/1/smooai-config/production.aws.us-east-1.mjs.map +1 -0
- package/dist/integration-tests/1/smooai-config/production.aws.us-east-2.d.mts +64 -0
- package/dist/integration-tests/1/smooai-config/production.aws.us-east-2.d.ts +64 -0
- package/dist/integration-tests/1/smooai-config/production.aws.us-east-2.js +12364 -0
- package/dist/integration-tests/1/smooai-config/production.aws.us-east-2.js.map +1 -0
- package/dist/integration-tests/1/smooai-config/production.aws.us-east-2.mjs +23 -0
- package/dist/integration-tests/1/smooai-config/production.aws.us-east-2.mjs.map +1 -0
- package/dist/integration-tests/1/smooai-config/production.d.mts +42 -0
- package/dist/integration-tests/1/smooai-config/production.d.ts +42 -0
- package/dist/integration-tests/1/smooai-config/production.js +12399 -0
- package/dist/integration-tests/1/smooai-config/production.js.map +1 -0
- package/dist/integration-tests/1/smooai-config/production.mjs +58 -0
- package/dist/integration-tests/1/smooai-config/production.mjs.map +1 -0
- package/dist/integration-tests/1/smooai-config/staging.d.mts +129 -0
- package/dist/integration-tests/1/smooai-config/staging.d.ts +129 -0
- package/dist/integration-tests/1/smooai-config/staging.js +12377 -0
- package/dist/integration-tests/1/smooai-config/staging.js.map +1 -0
- package/dist/integration-tests/1/smooai-config/staging.mjs +36 -0
- package/dist/integration-tests/1/smooai-config/staging.mjs.map +1 -0
- package/dist/integration-tests/2/smooai-config/config.d.mts +1262 -0
- package/dist/integration-tests/2/smooai-config/config.d.ts +1262 -0
- package/dist/integration-tests/2/smooai-config/config.js +12301 -0
- package/dist/integration-tests/2/smooai-config/config.js.map +1 -0
- package/dist/integration-tests/2/smooai-config/config.mjs +12 -0
- package/dist/integration-tests/2/smooai-config/config.mjs.map +1 -0
- package/dist/integration-tests/2/smooai-config/default.d.mts +19 -0
- package/dist/integration-tests/2/smooai-config/default.d.ts +19 -0
- package/dist/integration-tests/2/smooai-config/default.js +12321 -0
- package/dist/integration-tests/2/smooai-config/default.js.map +1 -0
- package/dist/integration-tests/2/smooai-config/default.mjs +32 -0
- package/dist/integration-tests/2/smooai-config/default.mjs.map +1 -0
- package/dist/integration-tests/2/smooai-config/development.d.mts +9 -0
- package/dist/integration-tests/2/smooai-config/development.d.ts +9 -0
- package/dist/integration-tests/2/smooai-config/development.js +12311 -0
- package/dist/integration-tests/2/smooai-config/development.js.map +1 -0
- package/dist/integration-tests/2/smooai-config/development.mjs +22 -0
- package/dist/integration-tests/2/smooai-config/development.mjs.map +1 -0
- package/dist/integration-tests/2/smooai-config/production.aws.d.mts +26 -0
- package/dist/integration-tests/2/smooai-config/production.aws.d.ts +26 -0
- package/dist/integration-tests/2/smooai-config/production.aws.js +12311 -0
- package/dist/integration-tests/2/smooai-config/production.aws.js.map +1 -0
- package/dist/integration-tests/2/smooai-config/production.aws.mjs +22 -0
- package/dist/integration-tests/2/smooai-config/production.aws.mjs.map +1 -0
- package/dist/integration-tests/2/smooai-config/production.aws.us-east-1.d.mts +25 -0
- package/dist/integration-tests/2/smooai-config/production.aws.us-east-1.d.ts +25 -0
- package/dist/integration-tests/2/smooai-config/production.aws.us-east-1.js +12310 -0
- package/dist/integration-tests/2/smooai-config/production.aws.us-east-1.js.map +1 -0
- package/dist/integration-tests/2/smooai-config/production.aws.us-east-1.mjs +21 -0
- package/dist/integration-tests/2/smooai-config/production.aws.us-east-1.mjs.map +1 -0
- package/dist/integration-tests/2/smooai-config/production.d.mts +19 -0
- package/dist/integration-tests/2/smooai-config/production.d.ts +19 -0
- package/dist/integration-tests/2/smooai-config/production.js +12321 -0
- package/dist/integration-tests/2/smooai-config/production.js.map +1 -0
- package/dist/integration-tests/2/smooai-config/production.mjs +32 -0
- package/dist/integration-tests/2/smooai-config/production.mjs.map +1 -0
- package/dist/platform/client.d.mts +49 -0
- package/dist/platform/client.d.ts +49 -0
- package/dist/platform/client.js +123 -0
- package/dist/platform/client.js.map +1 -0
- package/dist/platform/client.mjs +8 -0
- package/dist/platform/client.mjs.map +1 -0
- package/dist/platform/server/server.async.d.mts +12 -0
- package/dist/platform/server/server.async.d.ts +12 -0
- package/dist/platform/server/server.async.js +12586 -0
- package/dist/platform/server/server.async.js.map +1 -0
- package/dist/platform/server/server.async.mjs +18 -0
- package/dist/platform/server/server.async.mjs.map +1 -0
- package/dist/platform/server/server.featureFlag.sync.d.mts +2 -0
- package/dist/platform/server/server.featureFlag.sync.d.ts +2 -0
- package/dist/platform/server/server.featureFlag.sync.js +12589 -0
- package/dist/platform/server/server.featureFlag.sync.js.map +1 -0
- package/dist/platform/server/server.featureFlag.sync.mjs +24 -0
- package/dist/platform/server/server.featureFlag.sync.mjs.map +1 -0
- package/dist/platform/server/server.publicConfig.sync.d.mts +2 -0
- package/dist/platform/server/server.publicConfig.sync.d.ts +2 -0
- package/dist/platform/server/server.publicConfig.sync.js +12589 -0
- package/dist/platform/server/server.publicConfig.sync.js.map +1 -0
- package/dist/platform/server/server.publicConfig.sync.mjs +24 -0
- package/dist/platform/server/server.publicConfig.sync.mjs.map +1 -0
- package/dist/platform/server/server.secretConfig.sync.d.mts +2 -0
- package/dist/platform/server/server.secretConfig.sync.d.ts +2 -0
- package/dist/platform/server/server.secretConfig.sync.js +12589 -0
- package/dist/platform/server/server.secretConfig.sync.js.map +1 -0
- package/dist/platform/server/server.secretConfig.sync.mjs +24 -0
- package/dist/platform/server/server.secretConfig.sync.mjs.map +1 -0
- package/dist/platform/server.d.mts +21 -0
- package/dist/platform/server.d.ts +21 -0
- package/dist/platform/server.js +12626 -0
- package/dist/platform/server.js.map +1 -0
- package/dist/platform/server.mjs +58 -0
- package/dist/platform/server.mjs.map +1 -0
- package/dist/react/hooks.d.mts +36 -0
- package/dist/react/hooks.d.ts +36 -0
- package/dist/react/hooks.js +90 -0
- package/dist/react/hooks.js.map +1 -0
- package/dist/react/hooks.mjs +14 -0
- package/dist/react/hooks.mjs.map +1 -0
- package/dist/react/index.d.mts +28 -0
- package/dist/react/index.d.ts +28 -0
- package/dist/react/index.js +194 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/index.mjs +17 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/schema-spec/smooai-config-schema-spec.d.mts +25 -0
- package/dist/schema-spec/smooai-config-schema-spec.d.ts +25 -0
- package/dist/schema-spec/smooai-config-schema-spec.js +177 -0
- package/dist/schema-spec/smooai-config-schema-spec.js.map +1 -0
- package/dist/schema-spec/smooai-config-schema-spec.mjs +154 -0
- package/dist/schema-spec/smooai-config-schema-spec.mjs.map +1 -0
- package/dist/utils/fs.d.mts +10 -0
- package/dist/utils/fs.d.ts +10 -0
- package/dist/utils/fs.js +74 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/fs.mjs +11 -0
- package/dist/utils/fs.mjs.map +1 -0
- package/dist/utils/index.d.mts +29 -0
- package/dist/utils/index.d.ts +29 -0
- package/dist/utils/index.js +113 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +18 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/utils/mergeReplaceArrays.d.mts +9 -0
- package/dist/utils/mergeReplaceArrays.d.ts +9 -0
- package/dist/utils/mergeReplaceArrays.js +63 -0
- package/dist/utils/mergeReplaceArrays.js.map +1 -0
- package/dist/utils/mergeReplaceArrays.mjs +9 -0
- package/dist/utils/mergeReplaceArrays.mjs.map +1 -0
- package/package.json +133 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildConfigObject
|
|
3
|
+
} from "../chunk-HPXCKD6M.mjs";
|
|
4
|
+
import "../chunk-HPSOF46N.mjs";
|
|
5
|
+
import "../chunk-GLLYQ6FK.mjs";
|
|
6
|
+
import "../chunk-ZOKHXR5I.mjs";
|
|
7
|
+
import "../chunk-LKV73SD2.mjs";
|
|
8
|
+
import "../chunk-VPKO6D4W.mjs";
|
|
9
|
+
import "../chunk-YQWYYS7P.mjs";
|
|
10
|
+
import "../chunk-MJ52ZIWV.mjs";
|
|
11
|
+
import "../chunk-CASNDTCH.mjs";
|
|
12
|
+
import "../chunk-QBM74JB5.mjs";
|
|
13
|
+
import "../chunk-3SU3SMKN.mjs";
|
|
14
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
15
|
+
|
|
16
|
+
// src/platform/server.ts
|
|
17
|
+
import path from "path";
|
|
18
|
+
import { createSyncFn } from "synckit";
|
|
19
|
+
function buildConfigObject2(configSchema) {
|
|
20
|
+
const PublicConfigKeys = configSchema.PublicConfigKeys;
|
|
21
|
+
const config = buildConfigObject(configSchema);
|
|
22
|
+
const buildAndGetPublicConfigSync = createSyncFn(path.resolve(__dirname, "../../dist/platform/server/server.publicConfig.sync.js"), {
|
|
23
|
+
tsRunner: "tsx"
|
|
24
|
+
});
|
|
25
|
+
const buildAndGetSecretConfigSync = createSyncFn(path.resolve(__dirname, "../../dist/platform/server/server.secretConfig.sync.js"), {
|
|
26
|
+
tsRunner: "tsx"
|
|
27
|
+
});
|
|
28
|
+
const buildAndGetFeatureFlagSync = createSyncFn(path.resolve(__dirname, "../../dist/platform/server/server.featureFlag.sync.js"), {
|
|
29
|
+
tsRunner: "tsx"
|
|
30
|
+
});
|
|
31
|
+
function getPublicConfigSync(key) {
|
|
32
|
+
return buildAndGetPublicConfigSync(configSchema, key);
|
|
33
|
+
}
|
|
34
|
+
function getSecretConfigSync(key) {
|
|
35
|
+
return buildAndGetSecretConfigSync(configSchema, key);
|
|
36
|
+
}
|
|
37
|
+
function getFeatureFlagSync(key) {
|
|
38
|
+
return buildAndGetFeatureFlagSync(configSchema, key);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
publicConfig: {
|
|
42
|
+
getAsync: config.getPublicConfig,
|
|
43
|
+
getSync: getPublicConfigSync
|
|
44
|
+
},
|
|
45
|
+
secretConfig: {
|
|
46
|
+
getAsync: config.getSecretConfig,
|
|
47
|
+
getSync: getSecretConfigSync
|
|
48
|
+
},
|
|
49
|
+
featureFlag: {
|
|
50
|
+
getAsync: config.getFeatureFlag,
|
|
51
|
+
getSync: getFeatureFlagSync
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
buildConfigObject2 as default
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=server.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/platform/server.ts"],"sourcesContent":["import path from 'path';\nimport { defineConfig, InferConfigTypes } from '@/config/config';\nimport { createSyncFn } from 'synckit';\nimport buildConfigObjectAsync from './server/server.async';\n\nexport default function buildConfigObject<Schema extends ReturnType<typeof defineConfig>>(configSchema: Schema) {\n type ConfigType = InferConfigTypes<Schema>['ConfigType'];\n const PublicConfigKeys = configSchema.PublicConfigKeys;\n type PublicConfigKeys = InferConfigTypes<Schema>['PublicConfigKeys'];\n type SecretConfigKeys = InferConfigTypes<Schema>['SecretConfigKeys'];\n type FeatureFlagKeys = InferConfigTypes<Schema>['FeatureFlagKeys'];\n\n type PublicConfigKey = Extract<PublicConfigKeys[keyof PublicConfigKeys], keyof ConfigType>;\n type SecretConfigKey = Extract<SecretConfigKeys[keyof SecretConfigKeys], keyof ConfigType>;\n type FeatureFlagKey = Extract<FeatureFlagKeys[keyof FeatureFlagKeys], keyof ConfigType>;\n\n const config = buildConfigObjectAsync(configSchema);\n\n const buildAndGetPublicConfigSync = createSyncFn(path.resolve(__dirname, '../../dist/platform/server/server.publicConfig.sync.js'), {\n tsRunner: 'tsx',\n });\n const buildAndGetSecretConfigSync = createSyncFn(path.resolve(__dirname, '../../dist/platform/server/server.secretConfig.sync.js'), {\n tsRunner: 'tsx',\n });\n const buildAndGetFeatureFlagSync = createSyncFn(path.resolve(__dirname, '../../dist/platform/server/server.featureFlag.sync.js'), {\n tsRunner: 'tsx',\n });\n\n function getPublicConfigSync<K extends PublicConfigKey>(key: K): ConfigType[K] | undefined {\n return buildAndGetPublicConfigSync(configSchema, key);\n }\n\n function getSecretConfigSync<K extends SecretConfigKey>(key: K): ConfigType[K] | undefined {\n return buildAndGetSecretConfigSync(configSchema, key);\n }\n\n function getFeatureFlagSync<K extends FeatureFlagKey>(key: K): ConfigType[K] | undefined {\n return buildAndGetFeatureFlagSync(configSchema, key);\n }\n\n return {\n publicConfig: {\n getAsync: config.getPublicConfig,\n getSync: getPublicConfigSync,\n },\n secretConfig: {\n getAsync: config.getSecretConfig,\n getSync: getSecretConfigSync,\n },\n featureFlag: {\n getAsync: config.getFeatureFlag,\n getSync: getFeatureFlagSync,\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AAEjB,SAAS,oBAAoB;AAGd,SAARA,mBAAmF,cAAsB;AAE5G,QAAM,mBAAmB,aAAa;AAStC,QAAM,SAAS,kBAAuB,YAAY;AAElD,QAAM,8BAA8B,aAAa,KAAK,QAAQ,WAAW,wDAAwD,GAAG;AAAA,IAChI,UAAU;AAAA,EACd,CAAC;AACD,QAAM,8BAA8B,aAAa,KAAK,QAAQ,WAAW,wDAAwD,GAAG;AAAA,IAChI,UAAU;AAAA,EACd,CAAC;AACD,QAAM,6BAA6B,aAAa,KAAK,QAAQ,WAAW,uDAAuD,GAAG;AAAA,IAC9H,UAAU;AAAA,EACd,CAAC;AAED,WAAS,oBAA+C,KAAmC;AACvF,WAAO,4BAA4B,cAAc,GAAG;AAAA,EACxD;AAEA,WAAS,oBAA+C,KAAmC;AACvF,WAAO,4BAA4B,cAAc,GAAG;AAAA,EACxD;AAEA,WAAS,mBAA6C,KAAmC;AACrF,WAAO,2BAA2B,cAAc,GAAG;AAAA,EACvD;AAEA,SAAO;AAAA,IACH,cAAc;AAAA,MACV,UAAU,OAAO;AAAA,MACjB,SAAS;AAAA,IACb;AAAA,IACA,cAAc;AAAA,MACV,UAAU,OAAO;AAAA,MACjB,SAAS;AAAA,IACb;AAAA,IACA,aAAa;AAAA,MACT,UAAU,OAAO;AAAA,MACjB,SAAS;AAAA,IACb;AAAA,EACJ;AACJ;","names":["buildConfigObject"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
interface UseConfigResult<T = unknown> {
|
|
2
|
+
/** The resolved config value, or undefined while loading. */
|
|
3
|
+
value: T | undefined;
|
|
4
|
+
/** True while the initial fetch is in progress. */
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
/** The error if the fetch failed. */
|
|
7
|
+
error: Error | null;
|
|
8
|
+
/** Re-fetch the value (bypasses cache). */
|
|
9
|
+
refetch: () => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Fetch a public config value by key.
|
|
13
|
+
*
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const { value, isLoading, error } = usePublicConfig('API_URL');
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare function usePublicConfig<T = unknown>(key: string, environment?: string): UseConfigResult<T>;
|
|
19
|
+
/**
|
|
20
|
+
* Fetch a secret config value by key.
|
|
21
|
+
*
|
|
22
|
+
* ```tsx
|
|
23
|
+
* const { value, isLoading } = useSecretConfig('DATABASE_URL');
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
declare function useSecretConfig<T = unknown>(key: string, environment?: string): UseConfigResult<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Fetch a feature flag value by key.
|
|
29
|
+
*
|
|
30
|
+
* ```tsx
|
|
31
|
+
* const { value: enableNewUI } = useFeatureFlag<boolean>('ENABLE_NEW_UI');
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
declare function useFeatureFlag<T = unknown>(key: string, environment?: string): UseConfigResult<T>;
|
|
35
|
+
|
|
36
|
+
export { useFeatureFlag, usePublicConfig, useSecretConfig };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
interface UseConfigResult<T = unknown> {
|
|
2
|
+
/** The resolved config value, or undefined while loading. */
|
|
3
|
+
value: T | undefined;
|
|
4
|
+
/** True while the initial fetch is in progress. */
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
/** The error if the fetch failed. */
|
|
7
|
+
error: Error | null;
|
|
8
|
+
/** Re-fetch the value (bypasses cache). */
|
|
9
|
+
refetch: () => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Fetch a public config value by key.
|
|
13
|
+
*
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const { value, isLoading, error } = usePublicConfig('API_URL');
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare function usePublicConfig<T = unknown>(key: string, environment?: string): UseConfigResult<T>;
|
|
19
|
+
/**
|
|
20
|
+
* Fetch a secret config value by key.
|
|
21
|
+
*
|
|
22
|
+
* ```tsx
|
|
23
|
+
* const { value, isLoading } = useSecretConfig('DATABASE_URL');
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
declare function useSecretConfig<T = unknown>(key: string, environment?: string): UseConfigResult<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Fetch a feature flag value by key.
|
|
29
|
+
*
|
|
30
|
+
* ```tsx
|
|
31
|
+
* const { value: enableNewUI } = useFeatureFlag<boolean>('ENABLE_NEW_UI');
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
declare function useFeatureFlag<T = unknown>(key: string, environment?: string): UseConfigResult<T>;
|
|
35
|
+
|
|
36
|
+
export { useFeatureFlag, usePublicConfig, useSecretConfig };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/react/hooks.ts
|
|
22
|
+
var hooks_exports = {};
|
|
23
|
+
__export(hooks_exports, {
|
|
24
|
+
useFeatureFlag: () => useFeatureFlag,
|
|
25
|
+
usePublicConfig: () => usePublicConfig,
|
|
26
|
+
useSecretConfig: () => useSecretConfig
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
29
|
+
var import_react2 = require("react");
|
|
30
|
+
|
|
31
|
+
// src/react/ConfigProvider.tsx
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var ConfigContext = (0, import_react.createContext)(null);
|
|
35
|
+
function useConfigClient() {
|
|
36
|
+
const client = (0, import_react.useContext)(ConfigContext);
|
|
37
|
+
if (!client) {
|
|
38
|
+
throw new Error("useConfigClient must be used within a <ConfigProvider>");
|
|
39
|
+
}
|
|
40
|
+
return client;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/react/hooks.ts
|
|
44
|
+
function useConfigValue(key, environment) {
|
|
45
|
+
const client = useConfigClient();
|
|
46
|
+
const [value, setValue] = (0, import_react2.useState)(void 0);
|
|
47
|
+
const [isLoading, setIsLoading] = (0, import_react2.useState)(true);
|
|
48
|
+
const [error, setError] = (0, import_react2.useState)(null);
|
|
49
|
+
const [fetchCount, setFetchCount] = (0, import_react2.useState)(0);
|
|
50
|
+
const refetch = (0, import_react2.useCallback)(() => {
|
|
51
|
+
client.invalidateCache();
|
|
52
|
+
setFetchCount((c) => c + 1);
|
|
53
|
+
}, [client]);
|
|
54
|
+
(0, import_react2.useEffect)(() => {
|
|
55
|
+
let cancelled = false;
|
|
56
|
+
setIsLoading(true);
|
|
57
|
+
setError(null);
|
|
58
|
+
client.getValue(key, environment).then((result) => {
|
|
59
|
+
if (!cancelled) {
|
|
60
|
+
setValue(result);
|
|
61
|
+
setIsLoading(false);
|
|
62
|
+
}
|
|
63
|
+
}).catch((err) => {
|
|
64
|
+
if (!cancelled) {
|
|
65
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
66
|
+
setIsLoading(false);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return () => {
|
|
70
|
+
cancelled = true;
|
|
71
|
+
};
|
|
72
|
+
}, [client, key, environment, fetchCount]);
|
|
73
|
+
return { value, isLoading, error, refetch };
|
|
74
|
+
}
|
|
75
|
+
function usePublicConfig(key, environment) {
|
|
76
|
+
return useConfigValue(key, environment);
|
|
77
|
+
}
|
|
78
|
+
function useSecretConfig(key, environment) {
|
|
79
|
+
return useConfigValue(key, environment);
|
|
80
|
+
}
|
|
81
|
+
function useFeatureFlag(key, environment) {
|
|
82
|
+
return useConfigValue(key, environment);
|
|
83
|
+
}
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
useFeatureFlag,
|
|
87
|
+
usePublicConfig,
|
|
88
|
+
useSecretConfig
|
|
89
|
+
});
|
|
90
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/react/hooks.ts","../../src/react/ConfigProvider.tsx"],"sourcesContent":["'use client';\n\nimport { useCallback, useEffect, useState } from 'react';\nimport { useConfigClient } from './ConfigProvider';\n\ninterface UseConfigResult<T = unknown> {\n /** The resolved config value, or undefined while loading. */\n value: T | undefined;\n /** True while the initial fetch is in progress. */\n isLoading: boolean;\n /** The error if the fetch failed. */\n error: Error | null;\n /** Re-fetch the value (bypasses cache). */\n refetch: () => void;\n}\n\nfunction useConfigValue(key: string, environment?: string): UseConfigResult {\n const client = useConfigClient();\n const [value, setValue] = useState<unknown>(undefined);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const [fetchCount, setFetchCount] = useState(0);\n\n const refetch = useCallback(() => {\n client.invalidateCache();\n setFetchCount((c) => c + 1);\n }, [client]);\n\n useEffect(() => {\n let cancelled = false;\n setIsLoading(true);\n setError(null);\n\n client\n .getValue(key, environment)\n .then((result) => {\n if (!cancelled) {\n setValue(result);\n setIsLoading(false);\n }\n })\n .catch((err: unknown) => {\n if (!cancelled) {\n setError(err instanceof Error ? err : new Error(String(err)));\n setIsLoading(false);\n }\n });\n\n return () => {\n cancelled = true;\n };\n }, [client, key, environment, fetchCount]);\n\n return { value, isLoading, error, refetch };\n}\n\n/**\n * Fetch a public config value by key.\n *\n * ```tsx\n * const { value, isLoading, error } = usePublicConfig('API_URL');\n * ```\n */\nexport function usePublicConfig<T = unknown>(key: string, environment?: string): UseConfigResult<T> {\n return useConfigValue(key, environment) as UseConfigResult<T>;\n}\n\n/**\n * Fetch a secret config value by key.\n *\n * ```tsx\n * const { value, isLoading } = useSecretConfig('DATABASE_URL');\n * ```\n */\nexport function useSecretConfig<T = unknown>(key: string, environment?: string): UseConfigResult<T> {\n return useConfigValue(key, environment) as UseConfigResult<T>;\n}\n\n/**\n * Fetch a feature flag value by key.\n *\n * ```tsx\n * const { value: enableNewUI } = useFeatureFlag<boolean>('ENABLE_NEW_UI');\n * ```\n */\nexport function useFeatureFlag<T = unknown>(key: string, environment?: string): UseConfigResult<T> {\n return useConfigValue(key, environment) as UseConfigResult<T>;\n}\n","'use client';\n\nimport { createContext, useContext, useMemo, type ReactNode } from 'react';\nimport { ConfigClient, type ConfigClientOptions } from '../platform/client';\n\nconst ConfigContext = createContext<ConfigClient | null>(null);\n\nexport interface ConfigProviderProps extends ConfigClientOptions {\n children: ReactNode;\n}\n\n/**\n * Provides a ConfigClient instance to all descendant components.\n *\n * ```tsx\n * <ConfigProvider baseUrl=\"https://api.smooai.dev\" apiKey=\"...\" orgId=\"...\" environment=\"production\">\n * <App />\n * </ConfigProvider>\n * ```\n *\n * All props are optional if the corresponding environment variables are set:\n * SMOOAI_CONFIG_API_URL, SMOOAI_CONFIG_API_KEY, SMOOAI_CONFIG_ORG_ID, SMOOAI_CONFIG_ENV\n */\nexport function ConfigProvider({ children, ...options }: ConfigProviderProps) {\n const client = useMemo(() => new ConfigClient(options), [options.baseUrl, options.apiKey, options.orgId, options.environment]);\n\n return <ConfigContext.Provider value={client}>{children}</ConfigContext.Provider>;\n}\n\n/**\n * Access the ConfigClient instance from the nearest ConfigProvider.\n * Throws if used outside a ConfigProvider.\n */\nexport function useConfigClient(): ConfigClient {\n const client = useContext(ConfigContext);\n if (!client) {\n throw new Error('useConfigClient must be used within a <ConfigProvider>');\n }\n return client;\n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AASO,SAAS,gBAA6B,KAAa,aAA0C;AAChG,SAAO,eAAe,KAAK,WAAW;AAC1C;AASO,SAAS,gBAA6B,KAAa,aAA0C;AAChG,SAAO,eAAe,KAAK,WAAW;AAC1C;AASO,SAAS,eAA4B,KAAa,aAA0C;AAC/F,SAAO,eAAe,KAAK,WAAW;AAC1C;","names":["import_react"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useFeatureFlag,
|
|
4
|
+
usePublicConfig,
|
|
5
|
+
useSecretConfig
|
|
6
|
+
} from "../chunk-SKX7CPGS.mjs";
|
|
7
|
+
import "../chunk-Z3CZGNU5.mjs";
|
|
8
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
9
|
+
export {
|
|
10
|
+
useFeatureFlag,
|
|
11
|
+
usePublicConfig,
|
|
12
|
+
useSecretConfig
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=hooks.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { ConfigClientOptions, ConfigClient } from '../platform/client.mjs';
|
|
4
|
+
export { useFeatureFlag, usePublicConfig, useSecretConfig } from './hooks.mjs';
|
|
5
|
+
|
|
6
|
+
interface ConfigProviderProps extends ConfigClientOptions {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Provides a ConfigClient instance to all descendant components.
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <ConfigProvider baseUrl="https://api.smooai.dev" apiKey="..." orgId="..." environment="production">
|
|
14
|
+
* <App />
|
|
15
|
+
* </ConfigProvider>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* All props are optional if the corresponding environment variables are set:
|
|
19
|
+
* SMOOAI_CONFIG_API_URL, SMOOAI_CONFIG_API_KEY, SMOOAI_CONFIG_ORG_ID, SMOOAI_CONFIG_ENV
|
|
20
|
+
*/
|
|
21
|
+
declare function ConfigProvider({ children, ...options }: ConfigProviderProps): react_jsx_runtime.JSX.Element;
|
|
22
|
+
/**
|
|
23
|
+
* Access the ConfigClient instance from the nearest ConfigProvider.
|
|
24
|
+
* Throws if used outside a ConfigProvider.
|
|
25
|
+
*/
|
|
26
|
+
declare function useConfigClient(): ConfigClient;
|
|
27
|
+
|
|
28
|
+
export { ConfigProvider, type ConfigProviderProps, useConfigClient };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { ConfigClientOptions, ConfigClient } from '../platform/client.js';
|
|
4
|
+
export { useFeatureFlag, usePublicConfig, useSecretConfig } from './hooks.js';
|
|
5
|
+
|
|
6
|
+
interface ConfigProviderProps extends ConfigClientOptions {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Provides a ConfigClient instance to all descendant components.
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <ConfigProvider baseUrl="https://api.smooai.dev" apiKey="..." orgId="..." environment="production">
|
|
14
|
+
* <App />
|
|
15
|
+
* </ConfigProvider>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* All props are optional if the corresponding environment variables are set:
|
|
19
|
+
* SMOOAI_CONFIG_API_URL, SMOOAI_CONFIG_API_KEY, SMOOAI_CONFIG_ORG_ID, SMOOAI_CONFIG_ENV
|
|
20
|
+
*/
|
|
21
|
+
declare function ConfigProvider({ children, ...options }: ConfigProviderProps): react_jsx_runtime.JSX.Element;
|
|
22
|
+
/**
|
|
23
|
+
* Access the ConfigClient instance from the nearest ConfigProvider.
|
|
24
|
+
* Throws if used outside a ConfigProvider.
|
|
25
|
+
*/
|
|
26
|
+
declare function useConfigClient(): ConfigClient;
|
|
27
|
+
|
|
28
|
+
export { ConfigProvider, type ConfigProviderProps, useConfigClient };
|
|
@@ -0,0 +1,194 @@
|
|
|
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/react/index.ts
|
|
21
|
+
var react_exports = {};
|
|
22
|
+
__export(react_exports, {
|
|
23
|
+
ConfigProvider: () => ConfigProvider,
|
|
24
|
+
useConfigClient: () => useConfigClient,
|
|
25
|
+
useFeatureFlag: () => useFeatureFlag,
|
|
26
|
+
usePublicConfig: () => usePublicConfig,
|
|
27
|
+
useSecretConfig: () => useSecretConfig
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(react_exports);
|
|
30
|
+
|
|
31
|
+
// src/react/ConfigProvider.tsx
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
|
|
34
|
+
// src/platform/client.ts
|
|
35
|
+
function getEnv(key) {
|
|
36
|
+
if (typeof process !== "undefined" && process.env) {
|
|
37
|
+
return process.env[key];
|
|
38
|
+
}
|
|
39
|
+
return void 0;
|
|
40
|
+
}
|
|
41
|
+
var ConfigClient = class {
|
|
42
|
+
baseUrl;
|
|
43
|
+
orgId;
|
|
44
|
+
apiKey;
|
|
45
|
+
defaultEnvironment;
|
|
46
|
+
cacheTtlMs;
|
|
47
|
+
cache = /* @__PURE__ */ new Map();
|
|
48
|
+
constructor(options = {}) {
|
|
49
|
+
const baseUrl = options.baseUrl ?? getEnv("SMOOAI_CONFIG_API_URL");
|
|
50
|
+
const apiKey = options.apiKey ?? getEnv("SMOOAI_CONFIG_API_KEY");
|
|
51
|
+
const orgId = options.orgId ?? getEnv("SMOOAI_CONFIG_ORG_ID");
|
|
52
|
+
if (!baseUrl) throw new Error("@smooai/config: baseUrl is required (or set SMOOAI_CONFIG_API_URL)");
|
|
53
|
+
if (!apiKey) throw new Error("@smooai/config: apiKey is required (or set SMOOAI_CONFIG_API_KEY)");
|
|
54
|
+
if (!orgId) throw new Error("@smooai/config: orgId is required (or set SMOOAI_CONFIG_ORG_ID)");
|
|
55
|
+
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
56
|
+
this.apiKey = apiKey;
|
|
57
|
+
this.orgId = orgId;
|
|
58
|
+
this.defaultEnvironment = options.environment ?? getEnv("SMOOAI_CONFIG_ENV") ?? "development";
|
|
59
|
+
this.cacheTtlMs = options.cacheTtlMs ?? 0;
|
|
60
|
+
}
|
|
61
|
+
computeExpiresAt() {
|
|
62
|
+
return this.cacheTtlMs > 0 ? Date.now() + this.cacheTtlMs : 0;
|
|
63
|
+
}
|
|
64
|
+
getCached(cacheKey) {
|
|
65
|
+
const entry = this.cache.get(cacheKey);
|
|
66
|
+
if (!entry) return void 0;
|
|
67
|
+
if (entry.expiresAt > 0 && Date.now() > entry.expiresAt) {
|
|
68
|
+
this.cache.delete(cacheKey);
|
|
69
|
+
return void 0;
|
|
70
|
+
}
|
|
71
|
+
return entry.value;
|
|
72
|
+
}
|
|
73
|
+
async fetchJson(path) {
|
|
74
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
75
|
+
headers: { Authorization: `Bearer ${this.apiKey}` }
|
|
76
|
+
});
|
|
77
|
+
if (!response.ok) {
|
|
78
|
+
throw new Error(`Config API error: HTTP ${response.status} ${response.statusText}`);
|
|
79
|
+
}
|
|
80
|
+
return response.json();
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get a single config value by key.
|
|
84
|
+
* Results are cached locally after the first fetch.
|
|
85
|
+
*/
|
|
86
|
+
async getValue(key, environment) {
|
|
87
|
+
const env = environment ?? this.defaultEnvironment;
|
|
88
|
+
const cacheKey = `${env}:${key}`;
|
|
89
|
+
const cached = this.getCached(cacheKey);
|
|
90
|
+
if (cached !== void 0) {
|
|
91
|
+
return cached;
|
|
92
|
+
}
|
|
93
|
+
const result = await this.fetchJson(
|
|
94
|
+
`/organizations/${this.orgId}/config/values/${encodeURIComponent(key)}?environment=${encodeURIComponent(env)}`
|
|
95
|
+
);
|
|
96
|
+
this.cache.set(cacheKey, { value: result.value, expiresAt: this.computeExpiresAt() });
|
|
97
|
+
return result.value;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get all config values for an environment.
|
|
101
|
+
* All returned values are cached locally.
|
|
102
|
+
*/
|
|
103
|
+
async getAllValues(environment) {
|
|
104
|
+
const env = environment ?? this.defaultEnvironment;
|
|
105
|
+
const result = await this.fetchJson(
|
|
106
|
+
`/organizations/${this.orgId}/config/values?environment=${encodeURIComponent(env)}`
|
|
107
|
+
);
|
|
108
|
+
const expiresAt = this.computeExpiresAt();
|
|
109
|
+
for (const [key, value] of Object.entries(result.values)) {
|
|
110
|
+
this.cache.set(`${env}:${key}`, { value, expiresAt });
|
|
111
|
+
}
|
|
112
|
+
return result.values;
|
|
113
|
+
}
|
|
114
|
+
/** Clear the entire local cache. */
|
|
115
|
+
invalidateCache() {
|
|
116
|
+
this.cache.clear();
|
|
117
|
+
}
|
|
118
|
+
/** Clear cached values for a specific environment. */
|
|
119
|
+
invalidateCacheForEnvironment(environment) {
|
|
120
|
+
const prefix = `${environment}:`;
|
|
121
|
+
for (const key of this.cache.keys()) {
|
|
122
|
+
if (key.startsWith(prefix)) {
|
|
123
|
+
this.cache.delete(key);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// src/react/ConfigProvider.tsx
|
|
130
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
131
|
+
var ConfigContext = (0, import_react.createContext)(null);
|
|
132
|
+
function ConfigProvider({ children, ...options }) {
|
|
133
|
+
const client = (0, import_react.useMemo)(() => new ConfigClient(options), [options.baseUrl, options.apiKey, options.orgId, options.environment]);
|
|
134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConfigContext.Provider, { value: client, children });
|
|
135
|
+
}
|
|
136
|
+
function useConfigClient() {
|
|
137
|
+
const client = (0, import_react.useContext)(ConfigContext);
|
|
138
|
+
if (!client) {
|
|
139
|
+
throw new Error("useConfigClient must be used within a <ConfigProvider>");
|
|
140
|
+
}
|
|
141
|
+
return client;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/react/hooks.ts
|
|
145
|
+
var import_react2 = require("react");
|
|
146
|
+
function useConfigValue(key, environment) {
|
|
147
|
+
const client = useConfigClient();
|
|
148
|
+
const [value, setValue] = (0, import_react2.useState)(void 0);
|
|
149
|
+
const [isLoading, setIsLoading] = (0, import_react2.useState)(true);
|
|
150
|
+
const [error, setError] = (0, import_react2.useState)(null);
|
|
151
|
+
const [fetchCount, setFetchCount] = (0, import_react2.useState)(0);
|
|
152
|
+
const refetch = (0, import_react2.useCallback)(() => {
|
|
153
|
+
client.invalidateCache();
|
|
154
|
+
setFetchCount((c) => c + 1);
|
|
155
|
+
}, [client]);
|
|
156
|
+
(0, import_react2.useEffect)(() => {
|
|
157
|
+
let cancelled = false;
|
|
158
|
+
setIsLoading(true);
|
|
159
|
+
setError(null);
|
|
160
|
+
client.getValue(key, environment).then((result) => {
|
|
161
|
+
if (!cancelled) {
|
|
162
|
+
setValue(result);
|
|
163
|
+
setIsLoading(false);
|
|
164
|
+
}
|
|
165
|
+
}).catch((err) => {
|
|
166
|
+
if (!cancelled) {
|
|
167
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
168
|
+
setIsLoading(false);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
return () => {
|
|
172
|
+
cancelled = true;
|
|
173
|
+
};
|
|
174
|
+
}, [client, key, environment, fetchCount]);
|
|
175
|
+
return { value, isLoading, error, refetch };
|
|
176
|
+
}
|
|
177
|
+
function usePublicConfig(key, environment) {
|
|
178
|
+
return useConfigValue(key, environment);
|
|
179
|
+
}
|
|
180
|
+
function useSecretConfig(key, environment) {
|
|
181
|
+
return useConfigValue(key, environment);
|
|
182
|
+
}
|
|
183
|
+
function useFeatureFlag(key, environment) {
|
|
184
|
+
return useConfigValue(key, environment);
|
|
185
|
+
}
|
|
186
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
187
|
+
0 && (module.exports = {
|
|
188
|
+
ConfigProvider,
|
|
189
|
+
useConfigClient,
|
|
190
|
+
useFeatureFlag,
|
|
191
|
+
usePublicConfig,
|
|
192
|
+
useSecretConfig
|
|
193
|
+
});
|
|
194
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/react/index.ts","../../src/react/ConfigProvider.tsx","../../src/platform/client.ts","../../src/react/hooks.ts"],"sourcesContent":["export { ConfigProvider, useConfigClient } from './ConfigProvider';\nexport type { ConfigProviderProps } from './ConfigProvider';\nexport { usePublicConfig, useSecretConfig, useFeatureFlag } from './hooks';\n","'use client';\n\nimport { createContext, useContext, useMemo, type ReactNode } from 'react';\nimport { ConfigClient, type ConfigClientOptions } from '../platform/client';\n\nconst ConfigContext = createContext<ConfigClient | null>(null);\n\nexport interface ConfigProviderProps extends ConfigClientOptions {\n children: ReactNode;\n}\n\n/**\n * Provides a ConfigClient instance to all descendant components.\n *\n * ```tsx\n * <ConfigProvider baseUrl=\"https://api.smooai.dev\" apiKey=\"...\" orgId=\"...\" environment=\"production\">\n * <App />\n * </ConfigProvider>\n * ```\n *\n * All props are optional if the corresponding environment variables are set:\n * SMOOAI_CONFIG_API_URL, SMOOAI_CONFIG_API_KEY, SMOOAI_CONFIG_ORG_ID, SMOOAI_CONFIG_ENV\n */\nexport function ConfigProvider({ children, ...options }: ConfigProviderProps) {\n const client = useMemo(() => new ConfigClient(options), [options.baseUrl, options.apiKey, options.orgId, options.environment]);\n\n return <ConfigContext.Provider value={client}>{children}</ConfigContext.Provider>;\n}\n\n/**\n * Access the ConfigClient instance from the nearest ConfigProvider.\n * Throws if used outside a ConfigProvider.\n */\nexport function useConfigClient(): ConfigClient {\n const client = useContext(ConfigContext);\n if (!client) {\n throw new Error('useConfigClient must be used within a <ConfigProvider>');\n }\n return client;\n}\n","/**\n * Browser/universal HTTP client for fetching config values from the Smoo AI config server.\n *\n * Environment variables (optional — used as defaults when constructor args are omitted):\n * SMOOAI_CONFIG_API_URL — Base URL of the config API\n * SMOOAI_CONFIG_API_KEY — Bearer token for authentication\n * SMOOAI_CONFIG_ORG_ID — Organization ID\n * SMOOAI_CONFIG_ENV — Default environment name (e.g. \"production\")\n */\n\nexport interface ConfigClientOptions {\n /** Base URL of the config API server. Falls back to SMOOAI_CONFIG_API_URL env var. */\n baseUrl?: string;\n /** API key (M2M / client credentials token). Falls back to SMOOAI_CONFIG_API_KEY env var. */\n apiKey?: string;\n /** Organization ID. Falls back to SMOOAI_CONFIG_ORG_ID env var. */\n orgId?: string;\n /** Default environment name. Falls back to SMOOAI_CONFIG_ENV env var, then \"development\". */\n environment?: string;\n /** Cache TTL in milliseconds. 0 or undefined means cache never expires (manual invalidation only). */\n cacheTtlMs?: number;\n}\n\ninterface CacheEntry {\n value: unknown;\n expiresAt: number; // 0 = never expires\n}\n\nfunction getEnv(key: string): string | undefined {\n if (typeof process !== 'undefined' && process.env) {\n return process.env[key];\n }\n return undefined;\n}\n\nexport class ConfigClient {\n private baseUrl: string;\n private orgId: string;\n private apiKey: string;\n private defaultEnvironment: string;\n private cacheTtlMs: number;\n private cache: Map<string, CacheEntry> = new Map();\n\n constructor(options: ConfigClientOptions = {}) {\n const baseUrl = options.baseUrl ?? getEnv('SMOOAI_CONFIG_API_URL');\n const apiKey = options.apiKey ?? getEnv('SMOOAI_CONFIG_API_KEY');\n const orgId = options.orgId ?? getEnv('SMOOAI_CONFIG_ORG_ID');\n\n if (!baseUrl) throw new Error('@smooai/config: baseUrl is required (or set SMOOAI_CONFIG_API_URL)');\n if (!apiKey) throw new Error('@smooai/config: apiKey is required (or set SMOOAI_CONFIG_API_KEY)');\n if (!orgId) throw new Error('@smooai/config: orgId is required (or set SMOOAI_CONFIG_ORG_ID)');\n\n this.baseUrl = baseUrl.replace(/\\/+$/, '');\n this.apiKey = apiKey;\n this.orgId = orgId;\n this.defaultEnvironment = options.environment ?? getEnv('SMOOAI_CONFIG_ENV') ?? 'development';\n this.cacheTtlMs = options.cacheTtlMs ?? 0;\n }\n\n private computeExpiresAt(): number {\n return this.cacheTtlMs > 0 ? Date.now() + this.cacheTtlMs : 0;\n }\n\n private getCached(cacheKey: string): unknown | undefined {\n const entry = this.cache.get(cacheKey);\n if (!entry) return undefined;\n if (entry.expiresAt > 0 && Date.now() > entry.expiresAt) {\n this.cache.delete(cacheKey);\n return undefined;\n }\n return entry.value;\n }\n\n private async fetchJson<T>(path: string): Promise<T> {\n const response = await fetch(`${this.baseUrl}${path}`, {\n headers: { Authorization: `Bearer ${this.apiKey}` },\n });\n if (!response.ok) {\n throw new Error(`Config API error: HTTP ${response.status} ${response.statusText}`);\n }\n return response.json() as Promise<T>;\n }\n\n /**\n * Get a single config value by key.\n * Results are cached locally after the first fetch.\n */\n async getValue(key: string, environment?: string): Promise<unknown> {\n const env = environment ?? this.defaultEnvironment;\n const cacheKey = `${env}:${key}`;\n\n const cached = this.getCached(cacheKey);\n if (cached !== undefined) {\n return cached;\n }\n\n const result = await this.fetchJson<{ value: unknown }>(\n `/organizations/${this.orgId}/config/values/${encodeURIComponent(key)}?environment=${encodeURIComponent(env)}`,\n );\n this.cache.set(cacheKey, { value: result.value, expiresAt: this.computeExpiresAt() });\n return result.value;\n }\n\n /**\n * Get all config values for an environment.\n * All returned values are cached locally.\n */\n async getAllValues(environment?: string): Promise<Record<string, unknown>> {\n const env = environment ?? this.defaultEnvironment;\n\n const result = await this.fetchJson<{ values: Record<string, unknown> }>(\n `/organizations/${this.orgId}/config/values?environment=${encodeURIComponent(env)}`,\n );\n\n const expiresAt = this.computeExpiresAt();\n for (const [key, value] of Object.entries(result.values)) {\n this.cache.set(`${env}:${key}`, { value, expiresAt });\n }\n\n return result.values;\n }\n\n /** Clear the entire local cache. */\n invalidateCache(): void {\n this.cache.clear();\n }\n\n /** Clear cached values for a specific environment. */\n invalidateCacheForEnvironment(environment: string): void {\n const prefix = `${environment}:`;\n for (const key of this.cache.keys()) {\n if (key.startsWith(prefix)) {\n this.cache.delete(key);\n }\n }\n }\n}\n","'use client';\n\nimport { useCallback, useEffect, useState } from 'react';\nimport { useConfigClient } from './ConfigProvider';\n\ninterface UseConfigResult<T = unknown> {\n /** The resolved config value, or undefined while loading. */\n value: T | undefined;\n /** True while the initial fetch is in progress. */\n isLoading: boolean;\n /** The error if the fetch failed. */\n error: Error | null;\n /** Re-fetch the value (bypasses cache). */\n refetch: () => void;\n}\n\nfunction useConfigValue(key: string, environment?: string): UseConfigResult {\n const client = useConfigClient();\n const [value, setValue] = useState<unknown>(undefined);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const [fetchCount, setFetchCount] = useState(0);\n\n const refetch = useCallback(() => {\n client.invalidateCache();\n setFetchCount((c) => c + 1);\n }, [client]);\n\n useEffect(() => {\n let cancelled = false;\n setIsLoading(true);\n setError(null);\n\n client\n .getValue(key, environment)\n .then((result) => {\n if (!cancelled) {\n setValue(result);\n setIsLoading(false);\n }\n })\n .catch((err: unknown) => {\n if (!cancelled) {\n setError(err instanceof Error ? err : new Error(String(err)));\n setIsLoading(false);\n }\n });\n\n return () => {\n cancelled = true;\n };\n }, [client, key, environment, fetchCount]);\n\n return { value, isLoading, error, refetch };\n}\n\n/**\n * Fetch a public config value by key.\n *\n * ```tsx\n * const { value, isLoading, error } = usePublicConfig('API_URL');\n * ```\n */\nexport function usePublicConfig<T = unknown>(key: string, environment?: string): UseConfigResult<T> {\n return useConfigValue(key, environment) as UseConfigResult<T>;\n}\n\n/**\n * Fetch a secret config value by key.\n *\n * ```tsx\n * const { value, isLoading } = useSecretConfig('DATABASE_URL');\n * ```\n */\nexport function useSecretConfig<T = unknown>(key: string, environment?: string): UseConfigResult<T> {\n return useConfigValue(key, environment) as UseConfigResult<T>;\n}\n\n/**\n * Fetch a feature flag value by key.\n *\n * ```tsx\n * const { value: enableNewUI } = useFeatureFlag<boolean>('ENABLE_NEW_UI');\n * ```\n */\nexport function useFeatureFlag<T = unknown>(key: string, environment?: string): UseConfigResult<T> {\n return useConfigValue(key, environment) as UseConfigResult<T>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,mBAAmE;;;AC0BnE,SAAS,OAAO,KAAiC;AAC7C,MAAI,OAAO,YAAY,eAAe,QAAQ,KAAK;AAC/C,WAAO,QAAQ,IAAI,GAAG;AAAA,EAC1B;AACA,SAAO;AACX;AAEO,IAAM,eAAN,MAAmB;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAiC,oBAAI,IAAI;AAAA,EAEjD,YAAY,UAA+B,CAAC,GAAG;AAC3C,UAAM,UAAU,QAAQ,WAAW,OAAO,uBAAuB;AACjE,UAAM,SAAS,QAAQ,UAAU,OAAO,uBAAuB;AAC/D,UA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AASO,SAAS,eAA4B,KAAa,aAA0C;AAC/F,SAAO,eAAe,KAAK,WAAW;AAC1C;","names":["import_react"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigProvider,
|
|
3
|
+
useConfigClient,
|
|
4
|
+
useFeatureFlag,
|
|
5
|
+
usePublicConfig,
|
|
6
|
+
useSecretConfig
|
|
7
|
+
} from "../chunk-SKX7CPGS.mjs";
|
|
8
|
+
import "../chunk-Z3CZGNU5.mjs";
|
|
9
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
10
|
+
export {
|
|
11
|
+
ConfigProvider,
|
|
12
|
+
useConfigClient,
|
|
13
|
+
useFeatureFlag,
|
|
14
|
+
usePublicConfig,
|
|
15
|
+
useSecretConfig
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-language JSON Schema validation for the Smoo AI config SDK.
|
|
3
|
+
*
|
|
4
|
+
* Validates that a JSON Schema uses only the subset of keywords that all
|
|
5
|
+
* four language SDKs (TypeScript, Python, Rust, Go) can reliably support.
|
|
6
|
+
*/
|
|
7
|
+
interface SchemaValidationError {
|
|
8
|
+
path: string;
|
|
9
|
+
keyword: string;
|
|
10
|
+
message: string;
|
|
11
|
+
suggestion: string;
|
|
12
|
+
}
|
|
13
|
+
interface SchemaValidationResult {
|
|
14
|
+
valid: boolean;
|
|
15
|
+
errors: SchemaValidationError[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Validate that a JSON Schema uses only the cross-language-compatible subset.
|
|
19
|
+
*
|
|
20
|
+
* Walks the schema tree and reports unsupported keywords with actionable
|
|
21
|
+
* error messages and suggestions for compatible alternatives.
|
|
22
|
+
*/
|
|
23
|
+
declare function validateSmooaiSchema(schema: Record<string, unknown>): SchemaValidationResult;
|
|
24
|
+
|
|
25
|
+
export { type SchemaValidationError, type SchemaValidationResult, validateSmooaiSchema };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-language JSON Schema validation for the Smoo AI config SDK.
|
|
3
|
+
*
|
|
4
|
+
* Validates that a JSON Schema uses only the subset of keywords that all
|
|
5
|
+
* four language SDKs (TypeScript, Python, Rust, Go) can reliably support.
|
|
6
|
+
*/
|
|
7
|
+
interface SchemaValidationError {
|
|
8
|
+
path: string;
|
|
9
|
+
keyword: string;
|
|
10
|
+
message: string;
|
|
11
|
+
suggestion: string;
|
|
12
|
+
}
|
|
13
|
+
interface SchemaValidationResult {
|
|
14
|
+
valid: boolean;
|
|
15
|
+
errors: SchemaValidationError[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Validate that a JSON Schema uses only the cross-language-compatible subset.
|
|
19
|
+
*
|
|
20
|
+
* Walks the schema tree and reports unsupported keywords with actionable
|
|
21
|
+
* error messages and suggestions for compatible alternatives.
|
|
22
|
+
*/
|
|
23
|
+
declare function validateSmooaiSchema(schema: Record<string, unknown>): SchemaValidationResult;
|
|
24
|
+
|
|
25
|
+
export { type SchemaValidationError, type SchemaValidationResult, validateSmooaiSchema };
|