@outfitter/config 0.2.0 → 0.3.1

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/README.md CHANGED
@@ -227,6 +227,61 @@ class ParseError {
227
227
 
228
228
  ---
229
229
 
230
+ ## Environment Profiles
231
+
232
+ Unified environment detection for consistent defaults across all Outfitter packages.
233
+
234
+ ### `getEnvironment()`
235
+
236
+ Reads `OUTFITTER_ENV` and returns the current profile. Falls back to `"production"` when unset or invalid.
237
+
238
+ ```typescript
239
+ import { getEnvironment } from "@outfitter/config";
240
+
241
+ const env = getEnvironment();
242
+ // "development" | "production" | "test"
243
+ ```
244
+
245
+ ### `getEnvironmentDefaults(env)`
246
+
247
+ Returns profile-specific defaults for an environment.
248
+
249
+ ```typescript
250
+ import { getEnvironmentDefaults } from "@outfitter/config";
251
+
252
+ const defaults = getEnvironmentDefaults("development");
253
+ // { logLevel: "debug", verbose: true, errorDetail: "full" }
254
+
255
+ const prodDefaults = getEnvironmentDefaults("production");
256
+ // { logLevel: null, verbose: false, errorDetail: "message" }
257
+ ```
258
+
259
+ | Setting | `development` | `production` | `test` |
260
+ |---------|--------------|-------------|--------|
261
+ | logLevel | `"debug"` | `null` | `null` |
262
+ | verbose | `true` | `false` | `false` |
263
+ | errorDetail | `"full"` | `"message"` | `"full"` |
264
+
265
+ ### Types
266
+
267
+ #### `OutfitterEnv`
268
+
269
+ ```typescript
270
+ type OutfitterEnv = "development" | "production" | "test";
271
+ ```
272
+
273
+ #### `EnvironmentDefaults`
274
+
275
+ ```typescript
276
+ interface EnvironmentDefaults {
277
+ logLevel: "debug" | "info" | "warn" | "error" | null;
278
+ verbose: boolean;
279
+ errorDetail: "full" | "message";
280
+ }
281
+ ```
282
+
283
+ ---
284
+
230
285
  ## XDG Base Directory Specification
231
286
 
232
287
  This package follows the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) for locating configuration files.
package/dist/env.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { Env, booleanSchema, env, getEnvBoolean, optionalBooleanSchema, parseEnv, portSchema } from "./shared/@outfitter/config-veqxf02x";
2
+ export { portSchema, parseEnv, optionalBooleanSchema, getEnvBoolean, env, booleanSchema, Env };
package/dist/env.js ADDED
@@ -0,0 +1,18 @@
1
+ // @bun
2
+ import {
3
+ booleanSchema,
4
+ env,
5
+ getEnvBoolean,
6
+ optionalBooleanSchema,
7
+ parseEnv,
8
+ portSchema
9
+ } from "./shared/@outfitter/config-443pb6p2.js";
10
+ import"./shared/@outfitter/config-3n1xvxce.js";
11
+ export {
12
+ portSchema,
13
+ parseEnv,
14
+ optionalBooleanSchema,
15
+ getEnvBoolean,
16
+ env,
17
+ booleanSchema
18
+ };
@@ -0,0 +1,2 @@
1
+ import { EnvironmentDefaults, OutfitterEnv, getEnvironment, getEnvironmentDefaults } from "./shared/@outfitter/config-a6g8nmxw";
2
+ export { getEnvironmentDefaults, getEnvironment, OutfitterEnv, EnvironmentDefaults };
@@ -0,0 +1,10 @@
1
+ // @bun
2
+ import {
3
+ getEnvironment,
4
+ getEnvironmentDefaults
5
+ } from "./shared/@outfitter/config-w3pwcpr2.js";
6
+ import"./shared/@outfitter/config-3n1xvxce.js";
7
+ export {
8
+ getEnvironmentDefaults,
9
+ getEnvironment
10
+ };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,92 @@
1
+ /**
2
+ * Unified environment profiles for Outfitter packages.
3
+ *
4
+ * Provides a shared "environment" concept that cascades defaults
5
+ * across all Outfitter packages. The environment is determined by
6
+ * the `OUTFITTER_ENV` environment variable, falling back to
7
+ * `"production"` when unset or invalid.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { getEnvironment, getEnvironmentDefaults } from "@outfitter/config";
12
+ *
13
+ * const env = getEnvironment(); // "development" | "production" | "test"
14
+ * const defaults = getEnvironmentDefaults(env);
15
+ *
16
+ * if (defaults.verbose) {
17
+ * console.log("Verbose mode enabled");
18
+ * }
19
+ * ```
20
+ *
21
+ * @module
22
+ */
23
+ /**
24
+ * Valid Outfitter environment names.
25
+ *
26
+ * - `"development"` — Local development with verbose output and debug logging
27
+ * - `"production"` — Production deployments with minimal output
28
+ * - `"test"` — Test runs with full error detail but no logging
29
+ */
30
+ type OutfitterEnv = "development" | "production" | "test";
31
+ /**
32
+ * Profile-specific defaults for an environment.
33
+ *
34
+ * These defaults provide sensible starting values that individual
35
+ * packages can override or extend.
36
+ */
37
+ interface EnvironmentDefaults {
38
+ /** Default log level. `null` means logging is disabled by default. */
39
+ logLevel: "debug" | "info" | "warn" | "error" | null;
40
+ /** Whether verbose output is enabled by default. */
41
+ verbose: boolean;
42
+ /** How much error detail to include in output. */
43
+ errorDetail: "full" | "message";
44
+ }
45
+ /**
46
+ * Determine the current Outfitter environment.
47
+ *
48
+ * Reads the `OUTFITTER_ENV` environment variable. If set to a valid
49
+ * value (`"development"`, `"production"`, or `"test"`), returns that
50
+ * value. Otherwise falls back to `"production"`.
51
+ *
52
+ * @returns The current environment
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * // With OUTFITTER_ENV=development
57
+ * getEnvironment(); // "development"
58
+ *
59
+ * // With OUTFITTER_ENV unset or invalid
60
+ * getEnvironment(); // "production"
61
+ * ```
62
+ */
63
+ declare function getEnvironment(): OutfitterEnv;
64
+ /**
65
+ * Get the default settings for an environment profile.
66
+ *
67
+ * Returns a shallow copy of the defaults for the given environment.
68
+ * These defaults are intended as starting values that individual
69
+ * packages can override via their own configuration.
70
+ *
71
+ * | Setting | `development` | `production` | `test` |
72
+ * |---------|--------------|-------------|--------|
73
+ * | logLevel | `"debug"` | `null` | `null` |
74
+ * | verbose | `true` | `false` | `false` |
75
+ * | errorDetail | `"full"` | `"message"` | `"full"` |
76
+ *
77
+ * @param env - The environment to get defaults for
78
+ * @returns Profile-specific default settings
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const defaults = getEnvironmentDefaults("development");
83
+ * // { logLevel: "debug", verbose: true, errorDetail: "full" }
84
+ *
85
+ * const prodDefaults = getEnvironmentDefaults("production");
86
+ * // { logLevel: null, verbose: false, errorDetail: "message" }
87
+ * ```
88
+ */
89
+ declare function getEnvironmentDefaults(env: OutfitterEnv): EnvironmentDefaults;
1
90
  import { z } from "zod";
2
91
  /**
3
92
  * Port number schema (1-65535) with string-to-number coercion.
@@ -509,4 +598,4 @@ declare function loadConfig<T>(appName: string, schema: ZodSchema<T>, options?:
509
598
  * ```
510
599
  */
511
600
  declare function mapEnvToConfig<T>(prefix: string, _schema?: ZodSchema<T>): Partial<T>;
512
- export { resolveConfig, portSchema, parseEnv, parseConfigFile, optionalBooleanSchema, mapEnvToConfig, loadConfig, getStateDir, getEnvBoolean, getDataDir, getConfigDir, getCacheDir, env, deepMerge, booleanSchema, ParseError, LoadConfigOptions, Env, ConfigSources, CircularExtendsError };
601
+ export { resolveConfig, portSchema, parseEnv, parseConfigFile, optionalBooleanSchema, mapEnvToConfig, loadConfig, getStateDir, getEnvironmentDefaults, getEnvironment, getEnvBoolean, getDataDir, getConfigDir, getCacheDir, env, deepMerge, booleanSchema, ParseError, OutfitterEnv, LoadConfigOptions, EnvironmentDefaults, Env, ConfigSources, CircularExtendsError };